admin-lib-cms 1.2.10 → 1.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -826,13 +826,196 @@ function EditableReference({
826
826
  }
827
827
 
828
828
  // src/admin/AdminApp.tsx
829
- var import_react5 = require("react");
829
+ var import_react5 = __toESM(require("react"));
830
830
  var import_react_dom = require("react-dom");
831
831
  var import_antd = require("antd");
832
832
  var import_dayjs = __toESM(require("dayjs"));
833
833
  var import_lucide_react2 = require("lucide-react");
834
+
835
+ // src/admin/i18n.ts
836
+ var translations = {
837
+ es: {
838
+ menuDashboard: "Dashboard",
839
+ menuPages: "P\xE1ginas",
840
+ menuCollections: "Colecciones",
841
+ menuData: "Datos",
842
+ menuConfig: "Configuraci\xF3n",
843
+ menuSettings: "Ajustes",
844
+ menuSubscription: "Suscripci\xF3n",
845
+ liveEditor: "Editor en vivo",
846
+ viewSite: "Ver sitio",
847
+ signOut: "Cerrar sesi\xF3n",
848
+ signedInAs: "Conectado como",
849
+ saving: "Guardando...",
850
+ saved: "Guardado",
851
+ saveChanges: "Guardar cambios",
852
+ discardChanges: "Descartar",
853
+ unsavedChanges: "Cambios sin guardar",
854
+ desktop: "Escritorio",
855
+ tablet: "Tableta",
856
+ mobile: "M\xF3vil",
857
+ search: "Buscar...",
858
+ filterBy: "Filtrar por...",
859
+ all: "Todos",
860
+ actions: "Acciones",
861
+ edit: "Editar",
862
+ delete: "Eliminar",
863
+ cancel: "Cancelar",
864
+ save: "Guardar",
865
+ create: "Crear",
866
+ newEntry: "Nuevo",
867
+ createNew: "Crear nuevo",
868
+ confirmDeleteTitle: "\xBFEliminar este registro?",
869
+ confirmDeleteText: "Esta acci\xF3n no se puede deshacer.",
870
+ deleteSuccess: "Registro eliminado exitosamente.",
871
+ saveSuccess: "Registro guardado exitosamente.",
872
+ noRecords: "No hay registros disponibles.",
873
+ recordsFound: "registros encontrados",
874
+ back: "Volver",
875
+ apply: "Aplicar",
876
+ close: "Cerrar",
877
+ signatureRegistered: "Firma registrada",
878
+ viewLarger: "Click en la firma para verla en pantalla grande",
879
+ previewMask: "Ver m\xE1s grande",
880
+ addSignature: "AGREGAR FIRMA",
881
+ replaceSignature: "REEMPLAZAR FIRMA",
882
+ uploadImage: "SUBIR IMAGEN",
883
+ uploadNewImage: "SUBIR NUEVA IMAGEN",
884
+ signOnScreen: "Firmar en pantalla",
885
+ signInstructions: "Dibuja la firma en el recuadro usando el dedo o el mouse:",
886
+ clear: "Limpiar",
887
+ saveSignature: "Guardar Firma",
888
+ selectOption: "-- Selecciona una opci\xF3n --",
889
+ loadingOptions: "Cargando opciones...",
890
+ cantFindClient: "\xBFNo encuentras el cliente?",
891
+ createClient: "Crear cliente",
892
+ newBtn: "Nuevo",
893
+ basicDetails: "Datos b\xE1sicos",
894
+ clientType: "Tipo",
895
+ clientDocType: "Tipo de documento",
896
+ clientIdentification: "Identificaci\xF3n",
897
+ clientBranch: "Sucursal o sede",
898
+ clientName: "Nombre",
899
+ clientEmail: "Email",
900
+ clientPhone: "Tel\xE9fono",
901
+ clientCity: "Ciudad",
902
+ clientAddress: "direcci\xF3n",
903
+ clientCreatedSuccess: "Cliente creado y seleccionado exitosamente.",
904
+ idRequired: "La identificaci\xF3n es obligatoria.",
905
+ nameRequired: "El nombre es obligatorio.",
906
+ signInTitle: "Iniciar sesi\xF3n",
907
+ signInSubtitle: "Ingresa tus credenciales para acceder al panel",
908
+ emailLabel: "Correo electr\xF3nico",
909
+ passwordLabel: "Contrase\xF1a",
910
+ signInButton: "Iniciar sesi\xF3n",
911
+ invalidCredentials: "Credenciales inv\xE1lidas",
912
+ loggingIn: "Iniciando sesi\xF3n...",
913
+ submissions: "Mensajes y Formularios",
914
+ noSubmissions: "No hay env\xEDos registrados",
915
+ exportCsv: "Exportar CSV",
916
+ markRead: "Marcar como le\xEDdo",
917
+ settingsTitle: "Ajustes del sitio",
918
+ entries: "registros"
919
+ },
920
+ en: {
921
+ menuDashboard: "Dashboard",
922
+ menuPages: "Pages",
923
+ menuCollections: "Collections",
924
+ menuData: "Data",
925
+ menuConfig: "Settings",
926
+ menuSettings: "Preferences",
927
+ menuSubscription: "Subscription",
928
+ liveEditor: "Live Editor",
929
+ viewSite: "View site",
930
+ signOut: "Sign out",
931
+ signedInAs: "Signed in as",
932
+ saving: "Saving...",
933
+ saved: "Saved",
934
+ saveChanges: "Save changes",
935
+ discardChanges: "Discard",
936
+ unsavedChanges: "Unsaved changes",
937
+ desktop: "Desktop",
938
+ tablet: "Tablet",
939
+ mobile: "Mobile",
940
+ search: "Search...",
941
+ filterBy: "Filter by...",
942
+ all: "All",
943
+ actions: "Actions",
944
+ edit: "Edit",
945
+ delete: "Delete",
946
+ cancel: "Cancel",
947
+ save: "Save",
948
+ create: "Create",
949
+ newEntry: "New",
950
+ createNew: "Create new",
951
+ confirmDeleteTitle: "Delete this record?",
952
+ confirmDeleteText: "This action cannot be undone.",
953
+ deleteSuccess: "Record deleted successfully.",
954
+ saveSuccess: "Record saved successfully.",
955
+ noRecords: "No records found.",
956
+ recordsFound: "records found",
957
+ back: "Back",
958
+ apply: "Apply",
959
+ close: "Close",
960
+ signatureRegistered: "Signature registered",
961
+ viewLarger: "Click signature to view full size",
962
+ previewMask: "View larger",
963
+ addSignature: "ADD SIGNATURE",
964
+ replaceSignature: "REPLACE SIGNATURE",
965
+ uploadImage: "UPLOAD IMAGE",
966
+ uploadNewImage: "UPLOAD NEW IMAGE",
967
+ signOnScreen: "Sign on screen",
968
+ signInstructions: "Draw signature in the box using finger or mouse:",
969
+ clear: "Clear",
970
+ saveSignature: "Save Signature",
971
+ selectOption: "-- Select an option --",
972
+ loadingOptions: "Loading options...",
973
+ cantFindClient: "Can't find the client?",
974
+ createClient: "Create client",
975
+ newBtn: "New",
976
+ basicDetails: "Basic details",
977
+ clientType: "Type",
978
+ clientDocType: "Document type",
979
+ clientIdentification: "Identification",
980
+ clientBranch: "Branch or site",
981
+ clientName: "Name",
982
+ clientEmail: "Email",
983
+ clientPhone: "Phone",
984
+ clientCity: "City",
985
+ clientAddress: "Address",
986
+ clientCreatedSuccess: "Client created and selected successfully.",
987
+ idRequired: "Identification is required.",
988
+ nameRequired: "Name is required.",
989
+ signInTitle: "Sign In",
990
+ signInSubtitle: "Enter your credentials to access the panel",
991
+ emailLabel: "Email address",
992
+ passwordLabel: "Password",
993
+ signInButton: "Sign In",
994
+ invalidCredentials: "Invalid credentials",
995
+ loggingIn: "Signing in...",
996
+ submissions: "Form Submissions",
997
+ noSubmissions: "No submissions yet",
998
+ exportCsv: "Export CSV",
999
+ markRead: "Mark as read",
1000
+ settingsTitle: "Site Settings",
1001
+ entries: "entries"
1002
+ }
1003
+ };
1004
+ function getAdminTranslations(locale) {
1005
+ const norm = String(locale || "").trim().toLowerCase();
1006
+ if (norm === "es" || norm.startsWith("es-")) {
1007
+ return translations.es;
1008
+ }
1009
+ return translations.en;
1010
+ }
1011
+
1012
+ // src/admin/AdminApp.tsx
834
1013
  var import_lucide_react3 = require("lucide-react");
835
1014
  var import_jsx_runtime5 = require("react/jsx-runtime");
1015
+ var AdminI18nContext = import_react5.default.createContext(getAdminTranslations("en"));
1016
+ function useAdminI18n() {
1017
+ return import_react5.default.useContext(AdminI18nContext);
1018
+ }
836
1019
  var TIME_STORAGE_FORMAT = "HH:mm";
837
1020
  var TIME_DISPLAY_FORMAT = "h:mm A";
838
1021
  var TIME_PICKER_THEME = {
@@ -873,23 +1056,24 @@ function AdminTimeRangePicker(props) {
873
1056
  }
874
1057
  ) });
875
1058
  }
876
- function AdminTimePicker(props) {
877
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
878
- import_antd.TimePicker,
879
- {
880
- ...props,
881
- className: `w-full min-w-0 ${props.className ?? ""}`,
882
- style: {
883
- boxShadow: "0 1px 2px rgba(15, 23, 42, 0.08)",
884
- ...props.style
885
- }
886
- }
887
- ) });
888
- }
889
1059
  function toDayjsTime(value) {
890
- const match = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(String(value ?? ""));
891
- if (!match) return null;
892
- return (0, import_dayjs.default)().hour(Number(match[1])).minute(Number(match[2])).second(0).millisecond(0);
1060
+ const str = String(value ?? "").trim();
1061
+ if (!str) return null;
1062
+ const match12 = /^(\d{1,2}):(\d{2})\s*([ap]\.?m\.?)$/i.exec(str);
1063
+ if (match12) {
1064
+ let h = Number(match12[1]);
1065
+ const m = Number(match12[2]);
1066
+ const isPm = match12[3].toLowerCase().startsWith("p");
1067
+ if (isPm && h < 12) h += 12;
1068
+ if (!isPm && h === 12) h = 0;
1069
+ return (0, import_dayjs.default)().hour(h).minute(m).second(0).millisecond(0);
1070
+ }
1071
+ const match24 = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(str);
1072
+ if (match24) {
1073
+ return (0, import_dayjs.default)().hour(Number(match24[1])).minute(Number(match24[2])).second(0).millisecond(0);
1074
+ }
1075
+ const parsed = (0, import_dayjs.default)(str, ["h:mm a", "h:mm A", "hh:mm a", "hh:mm A", "HH:mm"]);
1076
+ return parsed.isValid() ? parsed : null;
893
1077
  }
894
1078
  function toStoredTime(value) {
895
1079
  return value?.format(TIME_STORAGE_FORMAT) ?? "";
@@ -950,6 +1134,8 @@ function AdminApp(props) {
950
1134
  }
951
1135
  function AdminAppContent(props) {
952
1136
  const ctx = useCmsContext();
1137
+ const rawLocale = props.locale ?? props.lang ?? ctx.config.locale ?? ctx.config.lang ?? "en";
1138
+ const t = (0, import_react5.useMemo)(() => getAdminTranslations(rawLocale), [rawLocale]);
953
1139
  const hasDashboard = Boolean(props.dashboard);
954
1140
  const [section, setSection] = (0, import_react5.useState)(hasDashboard ? "dashboard" : "pages");
955
1141
  const [authChecking, setAuthChecking] = (0, import_react5.useState)(true);
@@ -959,13 +1145,13 @@ function AdminAppContent(props) {
959
1145
  const hideGlobals = props.hideGlobals ?? ctx.config.hideGlobals ?? false;
960
1146
  const hideConfig = props.hideConfig ?? ctx.config.hideConfig ?? false;
961
1147
  const menuLabels = {
962
- dashboard: "Dashboard",
963
- pages: "P\xE1ginas",
964
- collections: "Colecciones",
965
- data: "Datos",
966
- config: "Configuraci\xF3n",
967
- settings: "Ajustes",
968
- subscription: "Suscripci\xF3n",
1148
+ dashboard: t.menuDashboard,
1149
+ pages: t.menuPages,
1150
+ collections: t.menuCollections,
1151
+ data: t.menuData,
1152
+ config: t.menuConfig,
1153
+ settings: t.menuSettings,
1154
+ subscription: t.menuSubscription,
969
1155
  ...ctx.config.menuLabels,
970
1156
  ...props.menuLabels
971
1157
  };
@@ -1001,7 +1187,7 @@ function AdminAppContent(props) {
1001
1187
  if (!isSubscriptionActive) {
1002
1188
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-col lg:flex-row h-screen w-full overflow-hidden bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SubscriptionPage, {}) });
1003
1189
  }
1004
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-screen w-full bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900 overflow-hidden", children: [
1190
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AdminI18nContext.Provider, { value: t, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col h-screen w-full bg-slate-50 text-slate-900 font-sans selection:bg-indigo-100 selection:text-indigo-900 overflow-hidden", children: [
1005
1191
  daysOverdue > 0 && daysOverdue <= 15 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-amber-400 text-amber-950 px-4 py-2.5 text-center text-sm font-semibold shadow-sm z-50", children: "Your account has an overdue balance. Please update your payment." }),
1006
1192
  daysOverdue > 15 && daysOverdue < 30 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "bg-rose-600 text-white px-4 py-2.5 text-center text-sm font-bold shadow-sm z-50", children: "Attention: If you do not settle your balance, your account will be suspended soon." }),
1007
1193
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col lg:flex-row flex-1 overflow-hidden relative", children: [
@@ -1017,81 +1203,155 @@ function AdminAppContent(props) {
1017
1203
  ] }),
1018
1204
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "truncate font-bold text-lg text-slate-900", children: ctx.config.siteName ?? "Site Administration" })
1019
1205
  ] }),
1020
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("nav", { className: "flex flex-row lg:flex-col overflow-x-auto lg:overflow-visible space-x-2 lg:space-x-0 lg:space-y-1.5 p-3 lg:p-4 text-sm font-medium hide-scrollbar", children: [
1021
- hasDashboard && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1022
- SideItem,
1023
- {
1024
- active: section === "dashboard",
1025
- onClick: () => setSection("dashboard"),
1026
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.BarChart3, { className: "h-4 w-4 shrink-0" }),
1027
- children: menuLabels.dashboard
1028
- }
1029
- ),
1030
- props.customSections?.map((cs) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1031
- SideItem,
1032
- {
1033
- active: section === cs.id,
1034
- onClick: () => setSection(cs.id),
1035
- icon: cs.icon || /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
1036
- children: cs.label
1037
- },
1038
- cs.id
1039
- )),
1040
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1041
- SideItem,
1042
- {
1043
- active: section === "pages",
1044
- onClick: () => setSection("pages"),
1045
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileText, { className: "h-4 w-4 shrink-0" }),
1046
- children: menuLabels.pages
1047
- }
1048
- ),
1049
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1050
- SideItem,
1051
- {
1052
- active: section === "collections",
1053
- onClick: () => setSection("collections"),
1054
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
1055
- children: menuLabels.collections
1056
- }
1057
- ),
1058
- !hideData && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1059
- SideItem,
1060
- {
1061
- active: section === "submissions",
1062
- onClick: () => setSection("submissions"),
1063
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-4 w-4 shrink-0" }),
1064
- children: menuLabels.data
1065
- }
1066
- ),
1067
- !hideConfig && !hideGlobals && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1068
- SideItem,
1069
- {
1070
- active: section === "config",
1071
- onClick: () => setSection("config"),
1072
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
1073
- children: menuLabels.config
1074
- }
1075
- ),
1076
- !hideSettings && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1077
- SideItem,
1078
- {
1079
- active: section === "settings",
1080
- onClick: () => setSection("settings"),
1081
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Settings, { className: "h-4 w-4 shrink-0" }),
1082
- children: menuLabels.settings
1083
- }
1084
- ),
1085
- subscriptionCtx && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1086
- SideItem,
1087
- {
1088
- active: section === "subscription",
1089
- onClick: () => setSection("subscription"),
1090
- icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CreditCard, { className: "h-4 w-4 shrink-0" }),
1091
- children: menuLabels.subscription
1092
- }
1093
- )
1094
- ] }),
1206
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("nav", { className: "flex flex-row lg:flex-col overflow-x-auto lg:overflow-visible space-x-2 lg:space-x-0 lg:space-y-1.5 p-3 lg:p-4 text-sm font-medium hide-scrollbar", children: (() => {
1207
+ const navItemsMap = /* @__PURE__ */ new Map();
1208
+ if (hasDashboard) {
1209
+ navItemsMap.set(
1210
+ "dashboard",
1211
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1212
+ SideItem,
1213
+ {
1214
+ active: section === "dashboard",
1215
+ onClick: () => setSection("dashboard"),
1216
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.BarChart3, { className: "h-4 w-4 shrink-0" }),
1217
+ children: menuLabels.dashboard
1218
+ },
1219
+ "dashboard"
1220
+ )
1221
+ );
1222
+ }
1223
+ navItemsMap.set(
1224
+ "pages",
1225
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1226
+ SideItem,
1227
+ {
1228
+ active: section === "pages",
1229
+ onClick: () => setSection("pages"),
1230
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.FileText, { className: "h-4 w-4 shrink-0" }),
1231
+ children: menuLabels.pages
1232
+ },
1233
+ "pages"
1234
+ )
1235
+ );
1236
+ navItemsMap.set(
1237
+ "collections",
1238
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1239
+ SideItem,
1240
+ {
1241
+ active: section === "collections",
1242
+ onClick: () => setSection("collections"),
1243
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
1244
+ children: menuLabels.collections
1245
+ },
1246
+ "collections"
1247
+ )
1248
+ );
1249
+ props.customSections?.forEach((cs) => {
1250
+ navItemsMap.set(
1251
+ cs.id,
1252
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1253
+ SideItem,
1254
+ {
1255
+ active: section === cs.id,
1256
+ onClick: () => setSection(cs.id),
1257
+ icon: cs.icon || /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-4 w-4 shrink-0" }),
1258
+ children: cs.label
1259
+ },
1260
+ cs.id
1261
+ )
1262
+ );
1263
+ });
1264
+ if (!hideData) {
1265
+ navItemsMap.set(
1266
+ "submissions",
1267
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1268
+ SideItem,
1269
+ {
1270
+ active: section === "submissions",
1271
+ onClick: () => setSection("submissions"),
1272
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Inbox, { className: "h-4 w-4 shrink-0" }),
1273
+ children: menuLabels.data
1274
+ },
1275
+ "submissions"
1276
+ )
1277
+ );
1278
+ }
1279
+ if (!hideConfig && !hideGlobals) {
1280
+ navItemsMap.set(
1281
+ "config",
1282
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1283
+ SideItem,
1284
+ {
1285
+ active: section === "config",
1286
+ onClick: () => setSection("config"),
1287
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.SlidersHorizontal, { className: "h-4 w-4 shrink-0" }),
1288
+ children: menuLabels.config
1289
+ },
1290
+ "config"
1291
+ )
1292
+ );
1293
+ }
1294
+ if (!hideSettings) {
1295
+ navItemsMap.set(
1296
+ "settings",
1297
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1298
+ SideItem,
1299
+ {
1300
+ active: section === "settings",
1301
+ onClick: () => setSection("settings"),
1302
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Settings, { className: "h-4 w-4 shrink-0" }),
1303
+ children: menuLabels.settings
1304
+ },
1305
+ "settings"
1306
+ )
1307
+ );
1308
+ }
1309
+ if (subscriptionCtx) {
1310
+ navItemsMap.set(
1311
+ "subscription",
1312
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1313
+ SideItem,
1314
+ {
1315
+ active: section === "subscription",
1316
+ onClick: () => setSection("subscription"),
1317
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react3.CreditCard, { className: "h-4 w-4 shrink-0" }),
1318
+ children: menuLabels.subscription
1319
+ },
1320
+ "subscription"
1321
+ )
1322
+ );
1323
+ }
1324
+ const orderedKeys = [];
1325
+ if (props.menuOrder && Array.isArray(props.menuOrder) && props.menuOrder.length > 0) {
1326
+ props.menuOrder.forEach((k) => {
1327
+ if (navItemsMap.has(k) && !orderedKeys.includes(k)) {
1328
+ orderedKeys.push(k);
1329
+ }
1330
+ });
1331
+ navItemsMap.forEach((_, k) => {
1332
+ if (!orderedKeys.includes(k)) {
1333
+ orderedKeys.push(k);
1334
+ }
1335
+ });
1336
+ } else {
1337
+ const topCustom = (props.customSections || []).filter((cs) => cs.position === "top").map((cs) => cs.id);
1338
+ const bottomCustom = (props.customSections || []).filter((cs) => cs.position === "bottom" || cs.position === "after-collections").map((cs) => cs.id);
1339
+ const otherCustom = (props.customSections || []).filter(
1340
+ (cs) => cs.position !== "top" && cs.position !== "bottom" && cs.position !== "after-collections"
1341
+ ).map((cs) => cs.id);
1342
+ if (hasDashboard) orderedKeys.push("dashboard");
1343
+ topCustom.forEach((k) => orderedKeys.push(k));
1344
+ orderedKeys.push("pages");
1345
+ orderedKeys.push("collections");
1346
+ otherCustom.forEach((k) => orderedKeys.push(k));
1347
+ bottomCustom.forEach((k) => orderedKeys.push(k));
1348
+ if (!hideData) orderedKeys.push("submissions");
1349
+ if (!hideConfig && !hideGlobals) orderedKeys.push("config");
1350
+ if (!hideSettings) orderedKeys.push("settings");
1351
+ if (subscriptionCtx) orderedKeys.push("subscription");
1352
+ }
1353
+ return orderedKeys.map((k) => navItemsMap.get(k));
1354
+ })() }),
1095
1355
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "hidden lg:block mt-auto border-t border-slate-200 p-4 bg-slate-50/50", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1096
1356
  "button",
1097
1357
  {
@@ -1102,7 +1362,7 @@ function AdminAppContent(props) {
1102
1362
  className: "flex items-center justify-center gap-2 w-full px-3 py-2 text-sm font-medium text-red-600 bg-red-50 hover:bg-red-100 rounded-lg transition-colors",
1103
1363
  children: [
1104
1364
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.LogOut, { className: "w-4 h-4" }),
1105
- "Logout"
1365
+ t.signOut
1106
1366
  ]
1107
1367
  }
1108
1368
  ) })
@@ -1120,7 +1380,7 @@ function AdminAppContent(props) {
1120
1380
  )
1121
1381
  ] })
1122
1382
  ] })
1123
- ] });
1383
+ ] }) });
1124
1384
  }
1125
1385
  function SideItem({
1126
1386
  active,
@@ -1229,6 +1489,7 @@ function PagesSection() {
1229
1489
  }
1230
1490
  function PageEditor({ page, showList, onToggleList }) {
1231
1491
  const ctx = useCmsContext();
1492
+ const t = useAdminI18n();
1232
1493
  const iframeRef = (0, import_react5.useRef)(null);
1233
1494
  const [registered, setRegistered] = (0, import_react5.useState)([]);
1234
1495
  const [selectedId, setSelectedId] = (0, import_react5.useState)(null);
@@ -1322,7 +1583,7 @@ function PageEditor({ page, showList, onToggleList }) {
1322
1583
  className: "inline-flex items-center gap-1.5 rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700 hover:bg-slate-50 hover:text-slate-900 disabled:opacity-50 transition-colors bg-white shadow-sm shrink-0",
1323
1584
  children: [
1324
1585
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "h-3.5 w-3.5" }),
1325
- "Discard"
1586
+ t.discardChanges
1326
1587
  ]
1327
1588
  }
1328
1589
  ),
@@ -1334,7 +1595,7 @@ function PageEditor({ page, showList, onToggleList }) {
1334
1595
  className: "inline-flex items-center gap-1.5 rounded-lg bg-indigo-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-indigo-700 disabled:opacity-50 transition-colors shadow-sm shrink-0",
1335
1596
  children: [
1336
1597
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-3.5 w-3.5" }),
1337
- "Save"
1598
+ t.save
1338
1599
  ]
1339
1600
  }
1340
1601
  )
@@ -2167,13 +2428,18 @@ function CollectionsSection() {
2167
2428
  collections.find((c) => !c.isSeparator) ?? null
2168
2429
  );
2169
2430
  const [counts, setCounts] = (0, import_react5.useState)({});
2431
+ const colIds = (0, import_react5.useMemo)(
2432
+ () => (ctx.config.collections ?? []).filter((c) => !c.isSeparator).map((c) => c.id).join(","),
2433
+ [ctx.config.collections]
2434
+ );
2170
2435
  (0, import_react5.useEffect)(() => {
2171
- collections.filter((c) => !c.isSeparator).forEach((c) => {
2436
+ const list = ctx.config.collections ?? [];
2437
+ list.filter((c) => !c.isSeparator).forEach((c) => {
2172
2438
  ctx.adapter.listEntries(c.id).then((entries) => {
2173
- setCounts((prev) => ({ ...prev, [c.id]: entries.length }));
2439
+ setCounts((prev) => prev[c.id] === entries.length ? prev : { ...prev, [c.id]: entries.length });
2174
2440
  });
2175
2441
  });
2176
- }, [ctx.adapter, collections]);
2442
+ }, [ctx.adapter, colIds, ctx.collectionChangedAt]);
2177
2443
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col md:flex-row h-full bg-slate-50", children: [
2178
2444
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-slate-200 bg-white/50 p-4", children: [
2179
2445
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mb-3 px-2 text-xs font-bold uppercase tracking-widest text-slate-500", children: "Collections" }),
@@ -2183,7 +2449,8 @@ function CollectionsSection() {
2183
2449
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2184
2450
  "li",
2185
2451
  {
2186
- className: "my-2 border-t border-slate-200/80"
2452
+ className: "my-3 border-t border-slate-200/80 pt-2 px-1 list-none",
2453
+ children: c.name && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400", children: c.name })
2187
2454
  },
2188
2455
  c.id || `sep-${idx}`
2189
2456
  );
@@ -2226,6 +2493,7 @@ function CollectionsSection() {
2226
2493
  }
2227
2494
  function CollectionEditor({ collection }) {
2228
2495
  const ctx = useCmsContext();
2496
+ const t = useAdminI18n();
2229
2497
  const [entries, setEntries] = (0, import_react5.useState)([]);
2230
2498
  const [editing, setEditing] = (0, import_react5.useState)(null);
2231
2499
  const [saving, setSaving] = (0, import_react5.useState)(false);
@@ -2287,6 +2555,16 @@ function CollectionEditor({ collection }) {
2287
2555
  try {
2288
2556
  const finalEditing = { ...editing };
2289
2557
  collection.fields.forEach((f) => {
2558
+ if (f.autoIncrement && isCreatingEntry && (!finalEditing[f.id] || Number(finalEditing[f.id]) === 0)) {
2559
+ const maxVal = entries.reduce(
2560
+ (max, e) => Math.max(max, Number(e[f.id]) || 0),
2561
+ 0
2562
+ );
2563
+ finalEditing[f.id] = maxVal > 0 ? maxVal + 1 : 1;
2564
+ }
2565
+ if (f.id === "estado" && !finalEditing[f.id]) {
2566
+ finalEditing[f.id] = "Nueva";
2567
+ }
2290
2568
  if (f.type === "time-range") {
2291
2569
  delete finalEditing[f.id];
2292
2570
  } else if (f.type === "slug" && !finalEditing[f.id]) {
@@ -2350,7 +2628,7 @@ function CollectionEditor({ collection }) {
2350
2628
  setDraggedIdx(null);
2351
2629
  setDragOverIdx(null);
2352
2630
  };
2353
- const visibleFields = collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0, 5);
2631
+ const visibleFields = collection.tableFields?.length ? collection.tableFields.map((tf) => collection.fields.find((f) => f.id === tf)).filter(Boolean) : collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0, 6);
2354
2632
  const isCreatingEntry = editing ? !entries.some((entry) => entry.id === editing.id) : false;
2355
2633
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mx-auto max-w-5xl", children: [
2356
2634
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-8 flex items-center justify-between", children: [
@@ -2358,69 +2636,110 @@ function CollectionEditor({ collection }) {
2358
2636
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { className: "text-2xl font-bold text-slate-900 tracking-tight", children: collection.name }),
2359
2637
  collection.description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-sm text-slate-500 mt-1", children: collection.description })
2360
2638
  ] }),
2361
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2362
- "button",
2639
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2640
+ import_antd.Button,
2363
2641
  {
2642
+ type: "primary",
2643
+ size: "large",
2644
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
2364
2645
  onClick: startNew,
2365
- className: "inline-flex items-center gap-2 rounded-xl bg-indigo-600 px-4 py-2.5 text-sm font-bold text-white shadow-sm hover:bg-indigo-700 hover:shadow transition-all",
2366
- children: [
2367
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4" }),
2368
- " New Entry"
2369
- ]
2646
+ className: "rounded-xl font-bold shadow-sm",
2647
+ children: t.newEntry
2370
2648
  }
2371
2649
  )
2372
2650
  ] }),
2373
2651
  !editing && (collection.searchBy?.length || collection.filterBy?.length) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-6 flex flex-wrap gap-4 items-center p-4 bg-white rounded-2xl border border-slate-200 shadow-sm animate-in fade-in slide-in-from-top-2", children: [
2374
- collection.searchBy?.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative flex-1 min-w-[200px]", children: [
2375
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" }),
2376
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2377
- "input",
2378
- {
2379
- type: "text",
2380
- placeholder: `Search by ${collection.searchBy.join(", ")}...`,
2381
- value: search,
2382
- onChange: (e) => {
2383
- setSearch(e.target.value);
2384
- setPage(1);
2385
- },
2386
- className: "w-full rounded-xl border border-slate-200 bg-slate-50 py-2.5 pl-10 pr-4 text-sm focus:border-indigo-500 focus:bg-white focus:ring-4 focus:ring-indigo-500/10 outline-none transition-all"
2387
- }
2388
- )
2389
- ] }) : null,
2652
+ collection.searchBy?.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "relative flex-1 min-w-[220px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2653
+ import_antd.Input,
2654
+ {
2655
+ size: "large",
2656
+ prefix: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "h-4 w-4 text-slate-400" }),
2657
+ placeholder: `Buscar por ${collection.searchBy.map((s) => s === "numero" ? "n\xFAmero" : s === "clienteNombre" ? "cliente" : s === "clienteId" ? "identificaci\xF3n" : s === "fecha" ? "fecha" : s).join(", ")}...`,
2658
+ value: search,
2659
+ allowClear: true,
2660
+ onChange: (e) => {
2661
+ setSearch(e.target.value);
2662
+ setPage(1);
2663
+ },
2664
+ className: "rounded-xl"
2665
+ }
2666
+ ) }) : null,
2390
2667
  collection.filterBy?.map((f) => {
2391
2668
  const fieldDef = collection.fields.find((cf) => cf.id === f);
2392
- const uniqueVals = Array.from(new Set(entries.map((e) => String(e[f] || "")))).filter(Boolean);
2393
- if (!fieldDef || uniqueVals.length === 0) return null;
2394
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "min-w-[150px] relative", children: [
2395
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2396
- "select",
2669
+ if (!fieldDef) return null;
2670
+ if (fieldDef.type === "date") {
2671
+ const dateVal = filters[f] ? (0, import_dayjs.default)(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]).isValid() ? (0, import_dayjs.default)(filters[f], ["YYYY/MM/DD", "YYYY-MM-DD", "YYYY-M-D"]) : null : null;
2672
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-[180px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2673
+ import_antd.DatePicker,
2397
2674
  {
2398
- value: filters[f] || "",
2399
- onChange: (e) => {
2400
- setFilters((prev) => ({ ...prev, [f]: e.target.value }));
2675
+ size: "large",
2676
+ format: "YYYY/MM/DD",
2677
+ placeholder: `Filtrar por ${fieldDef.label}`,
2678
+ allowClear: true,
2679
+ value: dateVal,
2680
+ onChange: (_, dateStr) => {
2681
+ const val = Array.isArray(dateStr) ? dateStr[0] : dateStr;
2682
+ setFilters((prev) => ({ ...prev, [f]: val || "" }));
2401
2683
  setPage(1);
2402
2684
  },
2403
- className: "w-full rounded-xl border border-slate-200 bg-slate-50 py-2.5 px-4 pr-10 text-sm focus:border-indigo-500 focus:bg-white focus:ring-4 focus:ring-indigo-500/10 outline-none transition-all appearance-none",
2404
- children: [
2405
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
2406
- "All ",
2407
- fieldDef.label
2408
- ] }),
2409
- uniqueVals.map((v) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: v, children: v }, v))
2410
- ]
2685
+ className: "w-full rounded-xl"
2411
2686
  }
2412
- ),
2413
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
2414
- ] }, f);
2687
+ ) }, f);
2688
+ }
2689
+ const predefinedOptions = (fieldDef.options || []).map(
2690
+ (opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
2691
+ );
2692
+ const entryVals = Array.from(new Set(entries.map((e) => String(e[f] || "")))).filter(Boolean);
2693
+ const combinedOptions = [...predefinedOptions];
2694
+ for (const ev of entryVals) {
2695
+ if (!combinedOptions.some((o) => o.value === ev)) {
2696
+ combinedOptions.push({ value: ev, label: ev });
2697
+ }
2698
+ }
2699
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-w-[170px]", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2700
+ import_antd.Select,
2701
+ {
2702
+ size: "large",
2703
+ value: filters[f] || void 0,
2704
+ placeholder: `Filtrar por ${fieldDef.label}`,
2705
+ allowClear: true,
2706
+ onChange: (v) => {
2707
+ setFilters((prev) => ({ ...prev, [f]: v || "" }));
2708
+ setPage(1);
2709
+ },
2710
+ options: combinedOptions,
2711
+ className: "w-full"
2712
+ }
2713
+ ) }, f);
2415
2714
  })
2416
2715
  ] }),
2417
2716
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2418
2717
  import_antd.Modal,
2419
2718
  {
2420
2719
  open: Boolean(editing),
2421
- title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2 text-slate-900", children: [
2422
- isCreatingEntry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4 text-indigo-600" }),
2423
- isCreatingEntry ? "Create Entry" : "Edit Entry"
2720
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between pr-8", children: [
2721
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-2 text-slate-900 font-bold", children: [
2722
+ isCreatingEntry ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "h-4 w-4 text-indigo-600" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4 text-indigo-600" }),
2723
+ isCreatingEntry ? collection.createTitle || `Nueva ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}` : `Editar ${collection.name.endsWith("s") ? collection.name.slice(0, -1) : collection.name}`
2724
+ ] }),
2725
+ !isCreatingEntry && editing && editing.estado !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
2726
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-400 font-medium", children: "Estado:" }),
2727
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2728
+ import_antd.Select,
2729
+ {
2730
+ size: "middle",
2731
+ value: String(editing.estado || "Nueva"),
2732
+ onChange: (val) => setEditing({ ...editing, estado: val }),
2733
+ options: [
2734
+ { value: "Nueva", label: "Nueva" },
2735
+ { value: "Proceso", label: "Proceso" },
2736
+ { value: "Terminado", label: "Terminado" },
2737
+ { value: "Cancelado", label: "Cancelado" }
2738
+ ],
2739
+ className: "w-32"
2740
+ }
2741
+ )
2742
+ ] })
2424
2743
  ] }),
2425
2744
  onCancel: () => {
2426
2745
  if (!saving) setEditing(null);
@@ -2444,463 +2763,556 @@ function CollectionEditor({ collection }) {
2444
2763
  backdropFilter: "blur(8px)"
2445
2764
  }
2446
2765
  },
2447
- children: editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
2448
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-1 gap-5 lg:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order" && !f.hidden).map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "branch-settings" || f.type === "time-range" ? "lg:col-span-2" : ""}`, children: [
2449
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
2450
- f.label,
2451
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
2452
- ] }),
2453
- f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2454
- BranchSettingsEditor,
2455
- {
2456
- collectionId: f.collection || "",
2457
- value: editing[f.id],
2458
- globalPrice: Number(editing.price) || 0,
2459
- globalDiscount: Number(editing.discountPercent) || 0,
2460
- onChange: (val) => setEditing({ ...editing, [f.id]: val })
2766
+ children: editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.ConfigProvider, { theme: TIME_PICKER_THEME, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex max-h-[calc(100dvh-180px)] min-h-0 flex-col", children: [
2767
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto px-6 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid grid-cols-1 gap-5 lg:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order" && !f.hidden).filter((f) => {
2768
+ if (f.id === "estado" && !isCreatingEntry) return false;
2769
+ if (isCreatingEntry && f.hideOnCreate) return false;
2770
+ if (f.dependsOn) {
2771
+ const targetVal = editing[f.dependsOn.field];
2772
+ if (Array.isArray(f.dependsOn.value)) {
2773
+ if (!f.dependsOn.value.includes(targetVal)) return false;
2774
+ } else if (targetVal !== f.dependsOn.value) {
2775
+ return false;
2461
2776
  }
2462
- ) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center gap-3", children: [
2463
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "relative inline-flex items-center cursor-pointer select-none", children: [
2777
+ }
2778
+ return true;
2779
+ }).map((f) => {
2780
+ const isFullWidth = f.colSpan === 2 || f.colSpan === 12 || f.type === "signature" || f.type === "date" || f.type === "datetime" || f.type === "richtext" || f.type === "textarea" || f.type === "list" || f.type === "branch-settings" || f.type === "time-range";
2781
+ const colSpanClass = isFullWidth ? "lg:col-span-2 col-span-1" : "col-span-1";
2782
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `block ${colSpanClass}`, children: [
2783
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
2784
+ f.label,
2785
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
2786
+ ] }),
2787
+ f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2788
+ BranchSettingsEditor,
2789
+ {
2790
+ collectionId: f.collection || "",
2791
+ value: editing[f.id],
2792
+ globalPrice: Number(editing.price) || 0,
2793
+ globalDiscount: Number(editing.discountPercent) || 0,
2794
+ onChange: (val) => setEditing({ ...editing, [f.id]: val })
2795
+ }
2796
+ ) : f.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mt-1 flex items-center gap-3", children: [
2464
2797
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2465
- "input",
2798
+ import_antd.Switch,
2466
2799
  {
2467
- type: "checkbox",
2468
2800
  checked: !!editing[f.id],
2469
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.checked }),
2470
- className: "sr-only peer"
2801
+ onChange: (checked) => setEditing({ ...editing, [f.id]: checked })
2471
2802
  }
2472
2803
  ),
2473
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-11 h-6 bg-slate-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-slate-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-indigo-600" })
2474
- ] }),
2475
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-sm font-medium text-slate-700", children: editing[f.id] ? "Activado / S\xED" : "Desactivado / No" })
2476
- ] }) : f.type === "number" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2477
- FormattedNumberInput,
2478
- {
2479
- value: editing[f.id],
2480
- onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2481
- isPrice: f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.toLowerCase().includes("valor") || f.label.includes("$"),
2482
- isPercent: f.id.toLowerCase().includes("discount") || f.id.toLowerCase().includes("descuento") || f.label.toLowerCase().includes("descuento")
2483
- }
2484
- ) : f.type === "time-range" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1.5", children: [
2485
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2486
- AdminTimeRangePicker,
2804
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-sm font-medium text-slate-700", children: editing[f.id] ? "Activado / S\xED" : "Desactivado / No" })
2805
+ ] }) : f.type === "number" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2806
+ import_antd.InputNumber,
2487
2807
  {
2488
- value: [
2489
- toDayjsTime(f.startField ? editing[f.startField] : ""),
2490
- toDayjsTime(f.endField ? editing[f.endField] : "")
2491
- ],
2492
- onChange: (times) => setEditing(
2493
- (current) => current ? {
2494
- ...current,
2495
- ...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
2496
- ...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
2497
- } : current
2498
- ),
2499
- allowEmpty: [true, true],
2500
- className: "w-full",
2501
- format: TIME_DISPLAY_FORMAT,
2502
- order: false,
2503
- placeholder: ["Hora de inicio", "Hora de cierre"],
2504
- use12Hours: true
2808
+ size: "large",
2809
+ value: editing[f.id] !== void 0 && editing[f.id] !== null && editing[f.id] !== "" ? Number(editing[f.id]) : void 0,
2810
+ readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
2811
+ disabled: f.readOnly,
2812
+ onChange: (val) => setEditing({ ...editing, [f.id]: val ?? 0 }),
2813
+ className: "w-full rounded-xl",
2814
+ placeholder: "0"
2505
2815
  }
2506
- ),
2507
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: "Selecciona inicio y cierre en un mismo control. Usa AM/PM; si el cierre es anterior al inicio, el horario cruza medianoche. Deja ambos vac\xEDos para mantenerlo siempre disponible." })
2508
- ] }) : f.type === "time" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2509
- AdminTimePicker,
2510
- {
2511
- value: toDayjsTime(editing[f.id]),
2512
- onChange: (time) => setEditing({ ...editing, [f.id]: toStoredTime(time) }),
2513
- className: "w-full",
2514
- format: TIME_DISPLAY_FORMAT,
2515
- use12Hours: true
2516
- }
2517
- ) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2518
- "textarea",
2519
- {
2520
- value: String(editing[f.id] ?? ""),
2521
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2522
- rows: 4,
2523
- placeholder: `Escribe ${f.label.toLowerCase()}...`,
2524
- className: "w-full rounded-xl border border-slate-200 px-4 py-3 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all font-sans text-slate-800"
2525
- }
2526
- ) : f.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2527
- SearchableSelect,
2528
- {
2529
- value: String(editing[f.id] ?? ""),
2530
- onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2531
- options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
2532
- placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
2533
- iconMap: ctx.iconMap
2534
- }
2535
- ) : f.type === "slug" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2536
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2537
- "input",
2816
+ ) : f.type === "date" || f.type === "datetime" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2817
+ import_antd.DatePicker,
2538
2818
  {
2539
- type: "text",
2540
- value: String(editing[f.id] ?? ""),
2541
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2542
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all"
2819
+ size: "large",
2820
+ value: editing[f.id] ? (0, import_dayjs.default)(String(editing[f.id])).isValid() ? (0, import_dayjs.default)(String(editing[f.id])) : null : null,
2821
+ onChange: (date, dateString) => setEditing({ ...editing, [f.id]: (Array.isArray(dateString) ? dateString[0] : dateString) || (date ? date.format("YYYY/MM/DD") : "") }),
2822
+ format: "YYYY/MM/DD",
2823
+ placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
2824
+ className: "w-full rounded-xl"
2543
2825
  }
2544
- ),
2545
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2546
- "button",
2826
+ ) : f.type === "time-range" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-1.5", children: [
2827
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2828
+ AdminTimeRangePicker,
2829
+ {
2830
+ value: [
2831
+ toDayjsTime(f.startField ? editing[f.startField] : ""),
2832
+ toDayjsTime(f.endField ? editing[f.endField] : "")
2833
+ ],
2834
+ onChange: (times) => setEditing(
2835
+ (current) => current ? {
2836
+ ...current,
2837
+ ...f.startField ? { [f.startField]: toStoredTime(times?.[0]) } : {},
2838
+ ...f.endField ? { [f.endField]: toStoredTime(times?.[1]) } : {}
2839
+ } : current
2840
+ ),
2841
+ allowEmpty: [true, true],
2842
+ className: "w-full",
2843
+ format: "h:mm a",
2844
+ order: false,
2845
+ placeholder: ["Hora de inicio", "Hora de cierre"],
2846
+ use12Hours: true
2847
+ }
2848
+ ),
2849
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: "Selecciona inicio y cierre en un mismo control. Usa AM/PM. Deja ambos vac\xEDos para mantenerlo siempre disponible." })
2850
+ ] }) : f.type === "time" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2851
+ import_antd.TimePicker,
2547
2852
  {
2548
- type: "button",
2549
- onClick: () => {
2550
- const sourceField = f.source || "title";
2551
- let val = String(editing[sourceField] || editing.id || "");
2552
- val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
2553
- setEditing({ ...editing, [f.id]: val });
2554
- },
2555
- className: "px-4 py-2.5 bg-slate-100 hover:bg-slate-200 text-slate-700 text-sm font-semibold rounded-xl border border-slate-200 transition-colors",
2556
- children: "Generate"
2853
+ size: "large",
2854
+ use12Hours: true,
2855
+ format: "h:mm a",
2856
+ value: toDayjsTime(editing[f.id]),
2857
+ onChange: (time, timeString) => setEditing({
2858
+ ...editing,
2859
+ [f.id]: (Array.isArray(timeString) ? timeString[0] : timeString) || (time ? time.format("h:mm a") : "")
2860
+ }),
2861
+ placeholder: `Seleccionar ${f.label.toLowerCase()}...`,
2862
+ className: "w-full rounded-xl"
2557
2863
  }
2558
- )
2559
- ] }) : f.type === "reference" || f.type === "select" && f.collection ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2560
- ReferenceSelect,
2561
- {
2562
- collectionId: f.collection,
2563
- displayField: f.displayField,
2564
- valueField: f.valueField,
2565
- fallbackOptions: f.options,
2566
- multiple: f.multiple,
2567
- searchable: f.searchable,
2568
- max: f.max,
2569
- value: editing[f.id],
2570
- onChange: (val) => setEditing({ ...editing, [f.id]: val })
2571
- }
2572
- ) : f.type === "select" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
2573
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2574
- "select",
2864
+ ) : f.type === "richtext" || f.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2865
+ import_antd.Input.TextArea,
2575
2866
  {
2867
+ size: "large",
2576
2868
  value: String(editing[f.id] ?? ""),
2577
2869
  onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2578
- className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white appearance-none pr-10 cursor-pointer text-slate-800",
2579
- children: [
2580
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: "-- Selecciona una opci\xF3n --" }),
2581
- f.options?.map((opt) => {
2582
- const val = typeof opt === "string" ? opt : opt.value;
2583
- const lab = typeof opt === "string" ? opt : opt.label;
2584
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: val, children: lab }, val);
2585
- })
2586
- ]
2870
+ rows: 4,
2871
+ placeholder: `Escribe ${f.label.toLowerCase()}...`,
2872
+ className: "w-full rounded-xl font-sans"
2587
2873
  }
2588
- ),
2589
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
2590
- ] }) : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2591
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => {
2592
- const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
2593
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
2594
- isVideo ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("video", { src: url, className: "w-full h-full object-cover rounded-lg", autoPlay: true, muted: true, loop: true, playsInline: true }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
2595
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2596
- "button",
2597
- {
2598
- type: "button",
2599
- onClick: () => {
2600
- const arr = [...editing[f.id] || []];
2601
- arr.splice(i, 1);
2602
- setEditing({ ...editing, [f.id]: arr });
2603
- },
2604
- className: "absolute top-2 right-2 bg-red-500/80 text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500",
2605
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "w-3 h-3" })
2606
- }
2607
- )
2608
- ] }, i);
2609
- }) }),
2610
- (!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2611
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2612
- "input",
2613
- {
2614
- type: "url",
2615
- placeholder: "Add media URL and press Enter...",
2616
- onKeyDown: (e) => {
2617
- if (e.key === "Enter" && e.currentTarget.value) {
2618
- e.preventDefault();
2619
- const arr = [...editing[f.id] || [], e.currentTarget.value];
2620
- setEditing({ ...editing, [f.id]: arr });
2621
- e.currentTarget.value = "";
2622
- }
2623
- },
2624
- className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2625
- }
2626
- ),
2627
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2628
- FilePickerButton,
2629
- {
2630
- accept: "image/*,video/*",
2631
- multiple: true,
2632
- className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
2633
- onFiles: (files) => {
2634
- files.forEach((file) => {
2635
- void handleImageFile(
2636
- file,
2637
- (url) => {
2638
- setEditing((prev) => {
2639
- if (!prev) return prev;
2640
- const current = prev[f.id] || [];
2641
- if (f.max && current.length >= f.max) {
2642
- return prev;
2643
- }
2644
- return { ...prev, [f.id]: [...current, url] };
2645
- });
2646
- },
2647
- ctx.uploadImage
2648
- );
2649
- });
2650
- },
2651
- children: "Upload"
2652
- }
2653
- )
2654
- ] })
2655
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2656
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2874
+ ) : f.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2875
+ SearchableSelect,
2876
+ {
2877
+ value: String(editing[f.id] ?? ""),
2878
+ onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2879
+ options: f.options?.length ? f.options : ctx.iconMap ? Object.keys(ctx.iconMap) : [],
2880
+ placeholder: `Buscar icono ${f.label.toLowerCase()}...`,
2881
+ iconMap: ctx.iconMap
2882
+ }
2883
+ ) : f.type === "slug" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2657
2884
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2658
- "input",
2885
+ import_antd.Input,
2659
2886
  {
2660
- type: "url",
2887
+ size: "large",
2661
2888
  value: String(editing[f.id] ?? ""),
2662
2889
  onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2663
- placeholder: "https://...",
2664
- className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2890
+ className: "flex-1 rounded-xl"
2665
2891
  }
2666
2892
  ),
2667
2893
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2668
- FilePickerButton,
2894
+ import_antd.Button,
2669
2895
  {
2670
- accept: "image/*,video/*",
2671
- className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
2672
- onFiles: (files) => {
2673
- const file = files[0];
2674
- if (file) {
2675
- void handleImageFile(
2676
- file,
2677
- (url) => setEditing(
2678
- (current) => current ? { ...current, [f.id]: url } : current
2679
- ),
2680
- ctx.uploadImage
2681
- );
2682
- }
2896
+ size: "large",
2897
+ onClick: () => {
2898
+ const sourceField = f.source || "title";
2899
+ let val = String(editing[sourceField] || editing.id || "");
2900
+ val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
2901
+ setEditing({ ...editing, [f.id]: val });
2683
2902
  },
2684
- children: "Upload"
2903
+ className: "rounded-xl font-semibold",
2904
+ children: "Generate"
2685
2905
  }
2686
2906
  )
2687
- ] }),
2688
- editing[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(editing[f.id]).match(/\.(mp4|webm|mov|ogg)$/i) || String(editing[f.id]).includes("video") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2689
- "video",
2690
- {
2691
- src: String(editing[f.id]),
2692
- controls: true,
2693
- className: "w-full h-auto max-h-48 object-contain rounded-lg"
2694
- }
2695
- ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2696
- "img",
2697
- {
2698
- src: String(editing[f.id]),
2699
- alt: "",
2700
- className: "w-full h-auto max-h-48 object-contain rounded-lg"
2701
- }
2702
- ) }) : null
2703
- ] }) : f.type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2704
- PasswordField,
2705
- {
2706
- value: String(editing[f.id] ?? ""),
2707
- onChange: (val) => setEditing({ ...editing, [f.id]: val })
2708
- }
2709
- ) : f.type === "color" && !f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
2710
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2711
- "input",
2712
- {
2713
- type: "color",
2714
- value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
2715
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2716
- className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
2717
- }
2718
- ),
2719
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2720
- "input",
2721
- {
2722
- type: "text",
2723
- value: String(editing[f.id] ?? ""),
2724
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2725
- placeholder: "#000000",
2726
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2727
- }
2728
- ),
2729
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2730
- "div",
2907
+ ] }) : f.type === "reference" || f.type === "select" && f.collection ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2908
+ ReferenceSelect,
2731
2909
  {
2732
- className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
2733
- style: { backgroundColor: String(editing[f.id] ?? "#000000") }
2910
+ collectionId: f.collection,
2911
+ displayField: f.displayField,
2912
+ valueField: f.valueField,
2913
+ fallbackOptions: f.options,
2914
+ multiple: f.multiple,
2915
+ searchable: f.searchable,
2916
+ max: f.max,
2917
+ value: editing[f.id],
2918
+ onChange: (val) => setEditing({ ...editing, [f.id]: val }),
2919
+ onSelectRecord: (rec) => {
2920
+ if (f.id === "clienteId" && rec) {
2921
+ setEditing((prev) => prev ? {
2922
+ ...prev,
2923
+ clienteId: rec.id || prev.clienteId,
2924
+ clienteNombre: rec.nombre || rec.name || prev.clienteNombre,
2925
+ ciudad: rec.ciudad || prev.ciudad,
2926
+ direccion: rec.direccion || prev.direccion,
2927
+ telefono: rec.telefono || prev.telefono
2928
+ } : prev);
2929
+ } else if (f.id === "empleadoId" && rec) {
2930
+ setEditing((prev) => prev ? {
2931
+ ...prev,
2932
+ empleadoId: rec.id || prev.empleadoId,
2933
+ empleadoNombre: rec.apellido ? `${rec.nombre || rec.name || ""} ${rec.apellido}`.trim() : rec.nombre || rec.name || prev.empleadoNombre
2934
+ } : prev);
2935
+ }
2936
+ }
2734
2937
  }
2735
- )
2736
- ] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2737
- (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : []).map((item, idx) => {
2738
- const colorVal = String(item ?? "").trim();
2739
- const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
2740
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
2938
+ ) : f.type === "select" ? (() => {
2939
+ const dynamicOptions = f.optionsMap && f.dependsOnField ? f.optionsMap[String(editing[f.dependsOnField] || "")] || f.options || [] : f.options || [];
2940
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2941
+ import_antd.Select,
2942
+ {
2943
+ size: "large",
2944
+ value: editing[f.id] ? String(editing[f.id]) : void 0,
2945
+ placeholder: f.label,
2946
+ allowClear: true,
2947
+ onChange: (val) => {
2948
+ const next = { ...editing, [f.id]: val || "" };
2949
+ collection.fields.forEach((otherField) => {
2950
+ if (otherField.dependsOnField === f.id && otherField.optionsMap) {
2951
+ const newOpts = otherField.optionsMap[String(val || "")];
2952
+ if (newOpts && newOpts.length > 0) {
2953
+ const firstVal = typeof newOpts[0] === "string" ? newOpts[0] : newOpts[0].value;
2954
+ next[otherField.id] = firstVal;
2955
+ }
2956
+ }
2957
+ });
2958
+ setEditing(next);
2959
+ },
2960
+ options: dynamicOptions.map((opt) => ({
2961
+ label: typeof opt === "string" ? opt : opt.label,
2962
+ value: typeof opt === "string" ? opt : opt.value
2963
+ })),
2964
+ className: "w-full"
2965
+ }
2966
+ );
2967
+ })() : f.type === "image" || f.type === "file" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2968
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => {
2969
+ const isVideo = typeof url === "string" && (url.match(/\.(mp4|webm|mov|ogg)$/i) || url.includes("video"));
2970
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
2971
+ isVideo ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("video", { src: url, className: "w-full h-full object-cover rounded-lg", autoPlay: true, muted: true, loop: true, playsInline: true }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
2972
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2973
+ "button",
2974
+ {
2975
+ type: "button",
2976
+ onClick: () => {
2977
+ const arr = [...editing[f.id] || []];
2978
+ arr.splice(i, 1);
2979
+ setEditing({ ...editing, [f.id]: arr });
2980
+ },
2981
+ className: "absolute top-2 right-2 bg-red-500/80 text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500",
2982
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "w-3 h-3" })
2983
+ }
2984
+ )
2985
+ ] }, i);
2986
+ }) }),
2987
+ (!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2741
2988
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2742
2989
  "input",
2743
2990
  {
2744
- type: "color",
2745
- value: validHex.length === 7 ? validHex : "#000000",
2746
- onChange: (e) => {
2747
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
2748
- arr[idx] = e.target.value;
2749
- setEditing({ ...editing, [f.id]: arr });
2991
+ type: "url",
2992
+ placeholder: "Add media URL and press Enter...",
2993
+ onKeyDown: (e) => {
2994
+ if (e.key === "Enter" && e.currentTarget.value) {
2995
+ e.preventDefault();
2996
+ const arr = [...editing[f.id] || [], e.currentTarget.value];
2997
+ setEditing({ ...editing, [f.id]: arr });
2998
+ e.currentTarget.value = "";
2999
+ }
2750
3000
  },
2751
- className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
3001
+ className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2752
3002
  }
2753
3003
  ),
2754
3004
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2755
- "input",
3005
+ FilePickerButton,
2756
3006
  {
2757
- type: "text",
2758
- value: colorVal,
2759
- onChange: (e) => {
2760
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
2761
- arr[idx] = e.target.value;
2762
- setEditing({ ...editing, [f.id]: arr });
2763
- },
2764
- placeholder: "#1c2a44",
2765
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2766
- }
2767
- ),
2768
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2769
- "div",
2770
- {
2771
- className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
2772
- style: { backgroundColor: colorVal || "#000000" }
2773
- }
2774
- ),
2775
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2776
- "button",
2777
- {
2778
- type: "button",
2779
- onClick: () => {
2780
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
2781
- arr.splice(idx, 1);
2782
- setEditing({ ...editing, [f.id]: arr });
3007
+ accept: "image/*,video/*",
3008
+ multiple: true,
3009
+ className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
3010
+ onFiles: (files) => {
3011
+ files.forEach((file) => {
3012
+ void handleImageFile(
3013
+ file,
3014
+ (url) => {
3015
+ setEditing((prev) => {
3016
+ if (!prev) return prev;
3017
+ const current = prev[f.id] || [];
3018
+ if (f.max && current.length >= f.max) {
3019
+ return prev;
3020
+ }
3021
+ return { ...prev, [f.id]: [...current, url] };
3022
+ });
3023
+ },
3024
+ ctx.uploadImage
3025
+ );
3026
+ });
2783
3027
  },
2784
- className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
2785
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
3028
+ children: "Upload"
2786
3029
  }
2787
3030
  )
2788
- ] }, idx);
2789
- }),
2790
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2791
- "button",
2792
- {
2793
- type: "button",
2794
- onClick: () => {
2795
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
2796
- arr.push("#000000");
2797
- setEditing({ ...editing, [f.id]: arr });
2798
- },
2799
- className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 rounded-lg border border-indigo-100 transition-colors",
2800
- children: [
2801
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
2802
- " Add Color"
2803
- ]
2804
- }
2805
- )
2806
- ] }) : f.type === "list" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
2807
- (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => {
2808
- const isFeatures = f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") || f.label.toLowerCase().includes("beneficio");
2809
- const placeholder = isFeatures ? `Caracter\xEDstica o beneficio ${idx + 1}...` : `Entregable o punto clave ${idx + 1}...`;
2810
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
2811
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-mono font-bold text-slate-400 w-6 text-right shrink-0", children: [
2812
- idx + 1,
2813
- "."
2814
- ] }),
3031
+ ] })
3032
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
3033
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
2815
3034
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2816
3035
  "input",
2817
3036
  {
2818
- type: "text",
2819
- value: String(item ?? ""),
2820
- placeholder,
2821
- onChange: (e) => {
2822
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2823
- arr[idx] = e.target.value;
2824
- setEditing({ ...editing, [f.id]: arr });
2825
- },
2826
- className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white"
3037
+ type: "url",
3038
+ value: String(editing[f.id] ?? ""),
3039
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3040
+ placeholder: "https://...",
3041
+ className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
2827
3042
  }
2828
3043
  ),
2829
3044
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2830
- "button",
3045
+ FilePickerButton,
2831
3046
  {
2832
- type: "button",
2833
- onClick: () => {
2834
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2835
- arr.splice(idx, 1);
2836
- setEditing({ ...editing, [f.id]: arr });
3047
+ accept: "image/*,video/*",
3048
+ className: "flex-shrink-0 cursor-pointer rounded-xl border border-slate-200 bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 transition-colors hover:bg-slate-200",
3049
+ onFiles: (files) => {
3050
+ const file = files[0];
3051
+ if (file) {
3052
+ void handleImageFile(
3053
+ file,
3054
+ (url) => setEditing(
3055
+ (current) => current ? { ...current, [f.id]: url } : current
3056
+ ),
3057
+ ctx.uploadImage
3058
+ );
3059
+ }
2837
3060
  },
2838
- className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer",
2839
- title: "Eliminar elemento",
2840
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
3061
+ children: "Upload"
2841
3062
  }
2842
3063
  )
2843
- ] }, idx);
2844
- }),
2845
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2846
- "button",
3064
+ ] }),
3065
+ editing[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: String(editing[f.id]).match(/\.(mp4|webm|mov|ogg)$/i) || String(editing[f.id]).includes("video") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3066
+ "video",
3067
+ {
3068
+ src: String(editing[f.id]),
3069
+ controls: true,
3070
+ className: "w-full h-auto max-h-48 object-contain rounded-lg"
3071
+ }
3072
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3073
+ "img",
3074
+ {
3075
+ src: String(editing[f.id]),
3076
+ alt: "",
3077
+ className: "w-full h-auto max-h-48 object-contain rounded-lg"
3078
+ }
3079
+ ) }) : null
3080
+ ] }) : f.type === "password" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3081
+ PasswordField,
2847
3082
  {
2848
- type: "button",
2849
- onClick: () => {
2850
- let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
2851
- arr.push("");
2852
- setEditing({ ...editing, [f.id]: arr });
2853
- },
2854
- className: "inline-flex items-center gap-1.5 px-3.5 py-2 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-bold rounded-xl border border-indigo-100 transition-colors cursor-pointer",
2855
- children: [
2856
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
2857
- " ",
2858
- f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") ? "Agregar caracter\xEDstica uno a uno" : "Agregar entregable / punto uno a uno"
2859
- ]
3083
+ value: String(editing[f.id] ?? ""),
3084
+ onChange: (val) => setEditing({ ...editing, [f.id]: val })
3085
+ }
3086
+ ) : f.type === "signature" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3087
+ SignatureInput,
3088
+ {
3089
+ value: editing[f.id],
3090
+ onChange: (val) => setEditing({ ...editing, [f.id]: val }),
3091
+ label: f.label
3092
+ }
3093
+ ) : f.type === "color" && !f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
3094
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3095
+ "input",
3096
+ {
3097
+ type: "color",
3098
+ value: String(editing[f.id] ?? "#000000").startsWith("#") && String(editing[f.id] ?? "").length === 7 ? String(editing[f.id]) : "#000000",
3099
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3100
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
3101
+ }
3102
+ ),
3103
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3104
+ "input",
3105
+ {
3106
+ type: "text",
3107
+ value: String(editing[f.id] ?? ""),
3108
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3109
+ placeholder: "#000000",
3110
+ className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
3111
+ }
3112
+ ),
3113
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3114
+ "div",
3115
+ {
3116
+ className: "w-8 h-8 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
3117
+ style: { backgroundColor: String(editing[f.id] ?? "#000000") }
3118
+ }
3119
+ )
3120
+ ] }) : f.type === "color" && f.multiple || f.type === "list" && f.id === "colors" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
3121
+ (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : []).map((item, idx) => {
3122
+ const colorVal = String(item ?? "").trim();
3123
+ const validHex = colorVal.startsWith("#") && (colorVal.length === 4 || colorVal.length === 7) ? colorVal : "#000000";
3124
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
3125
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3126
+ "input",
3127
+ {
3128
+ type: "color",
3129
+ value: validHex.length === 7 ? validHex : "#000000",
3130
+ onChange: (e) => {
3131
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3132
+ arr[idx] = e.target.value;
3133
+ setEditing({ ...editing, [f.id]: arr });
3134
+ },
3135
+ className: "w-10 h-10 rounded-xl border border-slate-200 p-0.5 cursor-pointer shadow-sm flex-shrink-0"
3136
+ }
3137
+ ),
3138
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3139
+ "input",
3140
+ {
3141
+ type: "text",
3142
+ value: colorVal,
3143
+ onChange: (e) => {
3144
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3145
+ arr[idx] = e.target.value;
3146
+ setEditing({ ...editing, [f.id]: arr });
3147
+ },
3148
+ placeholder: "#1c2a44",
3149
+ className: "flex-1 rounded-xl border border-slate-200 px-4 py-2 text-sm text-slate-800 font-mono shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
3150
+ }
3151
+ ),
3152
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3153
+ "div",
3154
+ {
3155
+ className: "w-7 h-7 rounded-full border border-slate-300 shadow-inner flex-shrink-0",
3156
+ style: { backgroundColor: colorVal || "#000000" }
3157
+ }
3158
+ ),
3159
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3160
+ "button",
3161
+ {
3162
+ type: "button",
3163
+ onClick: () => {
3164
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3165
+ arr.splice(idx, 1);
3166
+ setEditing({ ...editing, [f.id]: arr });
3167
+ },
3168
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors",
3169
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
3170
+ }
3171
+ )
3172
+ ] }, idx);
3173
+ }),
3174
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3175
+ "button",
3176
+ {
3177
+ type: "button",
3178
+ onClick: () => {
3179
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split(",").map((s) => s.trim()).filter(Boolean) : [];
3180
+ arr.push("#000000");
3181
+ setEditing({ ...editing, [f.id]: arr });
3182
+ },
3183
+ className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 rounded-lg border border-indigo-100 transition-colors",
3184
+ children: [
3185
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
3186
+ " Add Color"
3187
+ ]
3188
+ }
3189
+ )
3190
+ ] }) : f.type === "list" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
3191
+ (Array.isArray(editing[f.id]) ? editing[f.id] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : []).map((item, idx) => {
3192
+ const isFeatures = f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") || f.label.toLowerCase().includes("beneficio");
3193
+ const placeholder = isFeatures ? `Caracter\xEDstica o beneficio ${idx + 1}...` : `Entregable o punto clave ${idx + 1}...`;
3194
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
3195
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-mono font-bold text-slate-400 w-6 text-right shrink-0", children: [
3196
+ idx + 1,
3197
+ "."
3198
+ ] }),
3199
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3200
+ "input",
3201
+ {
3202
+ type: "text",
3203
+ value: String(item ?? ""),
3204
+ placeholder,
3205
+ onChange: (e) => {
3206
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
3207
+ arr[idx] = e.target.value;
3208
+ setEditing({ ...editing, [f.id]: arr });
3209
+ },
3210
+ className: "flex-1 rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white"
3211
+ }
3212
+ ),
3213
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3214
+ "button",
3215
+ {
3216
+ type: "button",
3217
+ onClick: () => {
3218
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
3219
+ arr.splice(idx, 1);
3220
+ setEditing({ ...editing, [f.id]: arr });
3221
+ },
3222
+ className: "p-2 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer",
3223
+ title: "Eliminar elemento",
3224
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
3225
+ }
3226
+ )
3227
+ ] }, idx);
3228
+ }),
3229
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3230
+ "button",
3231
+ {
3232
+ type: "button",
3233
+ onClick: () => {
3234
+ let arr = Array.isArray(editing[f.id]) ? [...editing[f.id]] : typeof editing[f.id] === "string" ? String(editing[f.id]).split("\n").filter(Boolean) : [];
3235
+ arr.push("");
3236
+ setEditing({ ...editing, [f.id]: arr });
3237
+ },
3238
+ className: "inline-flex items-center gap-1.5 px-3.5 py-2 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 text-xs font-bold rounded-xl border border-indigo-100 transition-colors cursor-pointer",
3239
+ children: [
3240
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
3241
+ " ",
3242
+ f.id === "features" || f.label.toLowerCase().includes("caracter\xEDstica") ? "Agregar caracter\xEDstica uno a uno" : "Agregar entregable / punto uno a uno"
3243
+ ]
3244
+ }
3245
+ )
3246
+ ] }) : f.type === "link" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2 items-center", children: [
3247
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3248
+ import_antd.Input,
3249
+ {
3250
+ size: "large",
3251
+ value: String(editing[f.id] ?? ""),
3252
+ readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
3253
+ disabled: f.readOnly,
3254
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3255
+ placeholder: f.label,
3256
+ className: "flex-1 rounded-xl"
3257
+ }
3258
+ ),
3259
+ Boolean(editing[f.id]) && String(editing[f.id]).startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3260
+ "a",
3261
+ {
3262
+ href: String(editing[f.id]),
3263
+ target: "_blank",
3264
+ rel: "noopener noreferrer",
3265
+ className: "inline-flex items-center gap-1.5 px-3 py-2 bg-blue-50 text-blue-600 hover:bg-blue-100 rounded-xl text-xs font-bold border border-blue-200 transition-colors shrink-0",
3266
+ children: [
3267
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5" }),
3268
+ String(editing[f.id]).includes("maps") ? "Ver en Mapa" : "Abrir"
3269
+ ]
3270
+ }
3271
+ ) : null
3272
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
3273
+ import_antd.Input,
3274
+ {
3275
+ size: "large",
3276
+ value: String(editing[f.id] ?? ""),
3277
+ readOnly: f.readOnly || f.autoIncrement && !isCreatingEntry,
3278
+ disabled: f.readOnly,
3279
+ onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
3280
+ placeholder: f.label,
3281
+ className: "w-full rounded-xl"
2860
3282
  }
2861
3283
  )
2862
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2863
- "input",
2864
- {
2865
- value: String(editing[f.id] ?? ""),
2866
- onChange: (e) => setEditing({ ...editing, [f.id]: e.target.value }),
2867
- className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all"
2868
- }
2869
- )
2870
- ] }, f.id)) }) }),
3284
+ ] }, f.id);
3285
+ }) }) }),
2871
3286
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex shrink-0 justify-end gap-3 border-t border-slate-200 bg-white px-6 py-4", children: [
2872
3287
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2873
- "button",
3288
+ import_antd.Button,
2874
3289
  {
3290
+ size: "large",
2875
3291
  onClick: () => setEditing(null),
2876
3292
  disabled: saving,
2877
- className: "rounded-xl px-5 py-2.5 text-sm font-semibold text-slate-600 hover:bg-slate-100 transition-colors disabled:opacity-50",
2878
- children: "Cancel"
3293
+ className: "rounded-xl font-medium",
3294
+ children: t.cancel
2879
3295
  }
2880
3296
  ),
2881
3297
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2882
- "button",
3298
+ import_antd.Button,
2883
3299
  {
3300
+ size: "large",
3301
+ type: "primary",
2884
3302
  onClick: save,
2885
- disabled: saving,
2886
- className: "inline-flex items-center gap-2 rounded-xl bg-slate-900 px-6 py-2.5 text-sm font-bold text-white shadow-sm hover:bg-slate-800 hover:shadow transition-all disabled:opacity-60",
2887
- children: saving ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2888
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "animate-spin h-4 w-4 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
2889
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
2890
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
2891
- ] }),
2892
- "Saving..."
2893
- ] }) : "Save Entry"
3303
+ loading: saving,
3304
+ className: "min-w-[140px] rounded-xl font-bold shadow-sm bg-blue-600 hover:bg-blue-700",
3305
+ children: collection.submitLabel || (isCreatingEntry ? t.create.toUpperCase() : t.save.toUpperCase())
2894
3306
  }
2895
3307
  )
2896
3308
  ] })
2897
- ] })
3309
+ ] }) })
2898
3310
  }
2899
3311
  ),
2900
3312
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("table", { className: "w-full text-sm text-left", children: [
2901
3313
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("thead", { className: "bg-slate-50/80 border-b border-slate-200", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("tr", { children: [
2902
3314
  visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-wider", children: f.label }, f.id)),
2903
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "px-6 py-4 text-right text-xs font-bold text-slate-500 uppercase tracking-wider sticky right-0 bg-slate-50 border-l border-slate-200 z-10", children: "Actions" })
3315
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("th", { className: "px-6 py-4 text-right text-xs font-bold text-slate-500 uppercase tracking-wider sticky right-0 bg-slate-50 border-l border-slate-200 z-10", children: t.actions })
2904
3316
  ] }) }),
2905
3317
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tbody", { className: "divide-y divide-slate-100", children: loadingEntries ? (
2906
3318
  // Loading skeleton rows
@@ -2912,13 +3324,29 @@ function CollectionEditor({ collection }) {
2912
3324
  (() => {
2913
3325
  let res = entries;
2914
3326
  if (search && collection.searchBy?.length) {
2915
- const q = search.toLowerCase();
2916
- res = res.filter((e) => collection.searchBy.some((field) => String(e[field] || "").toLowerCase().includes(q)));
3327
+ const q = search.toLowerCase().trim();
3328
+ res = res.filter((e) => {
3329
+ return collection.searchBy.some((field) => {
3330
+ const val = String(e[field] ?? "").toLowerCase();
3331
+ if (!val) return false;
3332
+ if (val.includes(q)) return true;
3333
+ const normVal = val.replace(/-/g, "/");
3334
+ const normQ = q.replace(/-/g, "/");
3335
+ return normVal.includes(normQ);
3336
+ });
3337
+ });
2917
3338
  }
2918
3339
  if (Object.keys(filters).length > 0) {
2919
3340
  res = res.filter((e) => {
2920
3341
  for (const [k, v] of Object.entries(filters)) {
2921
- if (v && String(e[k] || "") !== v) return false;
3342
+ if (!v) continue;
3343
+ const entryVal = String(e[k] ?? "").trim();
3344
+ const filterVal = String(v).trim();
3345
+ const normEntry = entryVal.replace(/-/g, "/");
3346
+ const normFilter = filterVal.replace(/-/g, "/");
3347
+ if (normEntry !== normFilter && !normEntry.includes(normFilter)) {
3348
+ return false;
3349
+ }
2922
3350
  }
2923
3351
  return true;
2924
3352
  });
@@ -2934,10 +3362,22 @@ function CollectionEditor({ collection }) {
2934
3362
  onDragEnd,
2935
3363
  className: `hover:bg-slate-50/50 transition-colors group cursor-grab active:cursor-grabbing ${deletingId === e.id ? "opacity-50" : ""} ${dragOverIdx === idx ? "border-t-2 border-t-indigo-500" : ""}`,
2936
3364
  children: [
2937
- visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : f.id === "status" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-bold ${String(e[f.id]).includes("Entregado") ? "bg-emerald-100 text-emerald-800 border border-emerald-300" : String(e[f.id]).includes("Preparaci\xF3n") ? "bg-amber-100 text-amber-800 border border-amber-300" : String(e[f.id]).includes("Camino") ? "bg-blue-100 text-blue-800 border border-blue-300" : String(e[f.id]).includes("Confirmado") ? "bg-indigo-100 text-indigo-800 border border-indigo-300" : String(e[f.id]).includes("Cancelado") ? "bg-rose-100 text-rose-800 border border-rose-300" : "bg-amber-50 text-amber-800 border border-amber-200"}`, children: String(e[f.id]) }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
3365
+ visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "branch-settings" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BranchSettingsSummary, { value: e[f.id] }) : f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : (f.id === "status" || f.id === "estado") && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-semibold ${String(e[f.id]) === "Terminado" || String(e[f.id]) === "Terminada" || String(e[f.id]).includes("Entregado") ? "bg-emerald-50 text-emerald-700 border border-emerald-200" : String(e[f.id]) === "Proceso" || String(e[f.id]).includes("Preparaci\xF3n") ? "bg-amber-50 text-amber-700 border border-amber-200" : String(e[f.id]) === "Cancelado" || String(e[f.id]).includes("Cancelado") ? "bg-rose-50 text-rose-700 border border-rose-200" : "bg-blue-50 text-blue-700 border border-blue-200"}`, children: String(e[f.id]) }) : (f.type === "reference" || f.type === "select" && f.collection) && e[f.id] ? e.clienteNombre && f.id === "clienteId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.clienteNombre) }) : e.empleadoNombre && f.id === "empleadoId" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-medium text-slate-800", children: String(e.empleadoNombre) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: e[f.id], displayField: f.displayField, valueField: f.valueField, multiple: f.multiple }) : f.type === "signature" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Image, { src: String(e[f.id]), alt: "Firma", className: "h-7 max-w-[80px] object-contain rounded bg-white border border-slate-200 p-0.5 inline-block shadow-xs cursor-pointer", preview: { mask: "Ver" } }) : f.type === "number" && e[f.id] !== void 0 && e[f.id] !== null && String(e[f.id]) !== "" ? f.id.toLowerCase().includes("price") || f.id.toLowerCase().includes("precio") || f.label.toLowerCase().includes("precio") || f.label.includes("$") || f.id.toLowerCase().includes("amount") || f.id.toLowerCase().includes("total") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-semibold text-slate-800", children: [
2938
3366
  "$ ",
2939
3367
  Number(e[f.id]).toLocaleString("es-CO")
2940
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) : String(e[f.id] ?? "") }, f.id)),
3368
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: Number(e[f.id]).toLocaleString("es-CO") }) : f.type === "link" || typeof e[f.id] === "string" && String(e[f.id]).startsWith("http") ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
3369
+ "a",
3370
+ {
3371
+ href: String(e[f.id]),
3372
+ target: "_blank",
3373
+ rel: "noopener noreferrer",
3374
+ className: "inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 underline font-medium",
3375
+ children: [
3376
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ExternalLink, { className: "w-3 h-3" }),
3377
+ String(e[f.id]).includes("maps") ? "Ver mapa" : "Abrir"
3378
+ ]
3379
+ }
3380
+ ) : String(e[f.id] ?? "") }, f.id)),
2941
3381
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-end gap-2", children: [
2942
3382
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "p-2 text-slate-300 cursor-grab active:cursor-grabbing", title: "Drag to reorder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "w-4 h-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M5.5 3C6.32843 3 7 3.67157 7 4.5C7 5.32843 6.32843 6 5.5 6C4.67157 6 4 5.32843 4 4.5C4 3.67157 4.67157 3 5.5 3ZM9.5 3C10.3284 3 11 3.67157 11 4.5C11 5.32843 10.3284 6 9.5 6C8.67157 6 8 5.32843 8 4.5C8 3.67157 8.67157 3 9.5 3ZM5.5 7.5C6.32843 7.5 7 8.17157 7 9C7 9.82843 6.32843 10.5 5.5 10.5C4.67157 10.5 4 9.82843 4 9C4 8.17157 4.67157 7.5 5.5 7.5ZM9.5 7.5C10.3284 7.5 11 8.17157 11 9C11 9.82843 10.3284 10.5 9.5 10.5C8.67157 10.5 8 9.82843 8 9C8 8.17157 8.67157 7.5 9.5 7.5ZM5.5 12C6.32843 12 7 12.6716 7 13.5C7 14.3284 6.32843 15 5.5 15C4.67157 15 4 14.3284 4 13.5C4 12.6716 4.67157 12 5.5 12ZM9.5 12C10.3284 12 11 12.6716 11 13.5C11 14.3284 10.3284 15 9.5 15C8.67157 15 8 14.3284 8 13.5C8 12.6716 8.67157 12 9.5 12Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) }),
2943
3383
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
@@ -2945,7 +3385,7 @@ function CollectionEditor({ collection }) {
2945
3385
  {
2946
3386
  onClick: () => setEditing(e),
2947
3387
  className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
2948
- title: "Edit",
3388
+ title: t.edit,
2949
3389
  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4" })
2950
3390
  }
2951
3391
  ),
@@ -2955,7 +3395,7 @@ function CollectionEditor({ collection }) {
2955
3395
  onClick: () => remove(e.id),
2956
3396
  disabled: deletingId === e.id,
2957
3397
  className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
2958
- title: "Delete",
3398
+ title: t.delete,
2959
3399
  children: deletingId === e.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
2960
3400
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
2961
3401
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
@@ -2975,7 +3415,7 @@ function CollectionEditor({ collection }) {
2975
3415
  className: "px-6 py-12 text-center text-slate-500",
2976
3416
  children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col items-center justify-center", children: [
2977
3417
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Boxes, { className: "h-10 w-10 text-slate-300 mb-3" }),
2978
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: 'No entries yet. Click "New Entry" to create one.' })
3418
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: t.noRecords })
2979
3419
  ] })
2980
3420
  }
2981
3421
  ) })
@@ -2996,7 +3436,7 @@ function CollectionEditor({ collection }) {
2996
3436
  return true;
2997
3437
  });
2998
3438
  }
2999
- return `${res.length} item${res.length !== 1 ? "s" : ""}`;
3439
+ return `${res.length} ${t.entries}`;
3000
3440
  })() }),
3001
3441
  (() => {
3002
3442
  let res = entries;
@@ -3646,6 +4086,197 @@ function PasswordField({ value, onChange }) {
3646
4086
  )
3647
4087
  ] });
3648
4088
  }
4089
+ function SignatureInput({
4090
+ value,
4091
+ onChange,
4092
+ label
4093
+ }) {
4094
+ const t = useAdminI18n();
4095
+ const [modalOpen, setModalOpen] = (0, import_react5.useState)(false);
4096
+ const canvasRef = (0, import_react5.useRef)(null);
4097
+ const isDrawingRef = (0, import_react5.useRef)(false);
4098
+ const fileInputRef = (0, import_react5.useRef)(null);
4099
+ const sigVal = typeof value === "string" ? value : "";
4100
+ const displayLabel = label || t.signatureRegistered;
4101
+ const startDrawing = (e) => {
4102
+ const canvas = canvasRef.current;
4103
+ if (!canvas) return;
4104
+ const ctx = canvas.getContext("2d");
4105
+ if (!ctx) return;
4106
+ isDrawingRef.current = true;
4107
+ const rect = canvas.getBoundingClientRect();
4108
+ const x = "touches" in e ? e.touches[0].clientX - rect.left : e.clientX - rect.left;
4109
+ const y = "touches" in e ? e.touches[0].clientY - rect.top : e.clientY - rect.top;
4110
+ ctx.beginPath();
4111
+ ctx.moveTo(x, y);
4112
+ };
4113
+ const draw = (e) => {
4114
+ if (!isDrawingRef.current) return;
4115
+ const canvas = canvasRef.current;
4116
+ if (!canvas) return;
4117
+ const ctx = canvas.getContext("2d");
4118
+ if (!ctx) return;
4119
+ const rect = canvas.getBoundingClientRect();
4120
+ const x = "touches" in e ? e.touches[0].clientX - rect.left : e.clientX - rect.left;
4121
+ const y = "touches" in e ? e.touches[0].clientY - rect.top : e.clientY - rect.top;
4122
+ ctx.lineTo(x, y);
4123
+ ctx.stroke();
4124
+ };
4125
+ const stopDrawing = () => {
4126
+ isDrawingRef.current = false;
4127
+ };
4128
+ const clearCanvas = () => {
4129
+ const canvas = canvasRef.current;
4130
+ if (!canvas) return;
4131
+ const ctx = canvas.getContext("2d");
4132
+ if (!ctx) return;
4133
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
4134
+ };
4135
+ const saveDrawnSignature = () => {
4136
+ const canvas = canvasRef.current;
4137
+ if (!canvas) return;
4138
+ const dataUrl = canvas.toDataURL("image/png");
4139
+ onChange(dataUrl);
4140
+ setModalOpen(false);
4141
+ };
4142
+ const handleFileUpload = (e) => {
4143
+ const file = e.target.files?.[0];
4144
+ if (!file) return;
4145
+ const reader = new FileReader();
4146
+ reader.onload = (evt) => {
4147
+ if (typeof evt.target?.result === "string") {
4148
+ onChange(evt.target.result);
4149
+ }
4150
+ };
4151
+ reader.readAsDataURL(file);
4152
+ e.target.value = "";
4153
+ };
4154
+ (0, import_react5.useEffect)(() => {
4155
+ if (modalOpen) {
4156
+ setTimeout(() => {
4157
+ const canvas = canvasRef.current;
4158
+ if (!canvas) return;
4159
+ const ctx = canvas.getContext("2d");
4160
+ if (ctx) {
4161
+ ctx.strokeStyle = "#0f172a";
4162
+ ctx.lineWidth = 2.5;
4163
+ ctx.lineCap = "round";
4164
+ ctx.lineJoin = "round";
4165
+ }
4166
+ }, 50);
4167
+ }
4168
+ }, [modalOpen]);
4169
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
4170
+ sigVal ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between p-3 rounded-xl border border-slate-200 bg-slate-50/70", children: [
4171
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
4172
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4173
+ import_antd.Image,
4174
+ {
4175
+ src: sigVal,
4176
+ alt: displayLabel,
4177
+ className: "h-16 max-w-[220px] object-contain rounded bg-white p-1 border border-slate-200 shadow-sm cursor-pointer hover:border-blue-500",
4178
+ preview: {
4179
+ mask: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold", children: t.previewMask })
4180
+ }
4181
+ }
4182
+ ),
4183
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex flex-col gap-0.5", children: [
4184
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs font-semibold text-emerald-700 bg-emerald-50 border border-emerald-200 px-2.5 py-0.5 rounded-full w-fit", children: t.signatureRegistered }),
4185
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[11px] text-slate-500", children: t.viewLarger })
4186
+ ] })
4187
+ ] }),
4188
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4189
+ import_antd.Button,
4190
+ {
4191
+ danger: true,
4192
+ type: "text",
4193
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" }),
4194
+ onClick: () => onChange(""),
4195
+ className: "hover:bg-red-50 text-red-600 font-medium",
4196
+ children: t.delete
4197
+ }
4198
+ )
4199
+ ] }) : null,
4200
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
4201
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4202
+ import_antd.Button,
4203
+ {
4204
+ type: "primary",
4205
+ size: "large",
4206
+ onClick: () => {
4207
+ clearCanvas();
4208
+ setModalOpen(true);
4209
+ },
4210
+ className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm",
4211
+ children: sigVal ? t.replaceSignature : t.addSignature
4212
+ }
4213
+ ),
4214
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4215
+ import_antd.Button,
4216
+ {
4217
+ type: "primary",
4218
+ size: "large",
4219
+ onClick: () => fileInputRef.current?.click(),
4220
+ className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm",
4221
+ children: sigVal ? t.uploadNewImage : t.uploadImage
4222
+ }
4223
+ ),
4224
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4225
+ "input",
4226
+ {
4227
+ type: "file",
4228
+ ref: fileInputRef,
4229
+ accept: "image/*",
4230
+ onChange: handleFileUpload,
4231
+ className: "hidden"
4232
+ }
4233
+ )
4234
+ ] }),
4235
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4236
+ import_antd.Modal,
4237
+ {
4238
+ open: modalOpen,
4239
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-bold text-slate-800", children: t.signOnScreen }),
4240
+ onCancel: () => setModalOpen(false),
4241
+ centered: true,
4242
+ width: 560,
4243
+ footer: [
4244
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Button, { onClick: clearCanvas, className: "rounded-xl font-medium", children: t.clear }, "clear"),
4245
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_antd.Button, { onClick: () => setModalOpen(false), className: "rounded-xl font-medium", children: t.cancel }, "cancel"),
4246
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4247
+ import_antd.Button,
4248
+ {
4249
+ type: "primary",
4250
+ onClick: saveDrawnSignature,
4251
+ className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl",
4252
+ children: t.saveSignature
4253
+ },
4254
+ "save"
4255
+ )
4256
+ ],
4257
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "py-2 space-y-2", children: [
4258
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: t.signInstructions }),
4259
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "border-2 border-dashed border-slate-300 rounded-2xl bg-white overflow-hidden touch-none", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4260
+ "canvas",
4261
+ {
4262
+ ref: canvasRef,
4263
+ width: 500,
4264
+ height: 220,
4265
+ onMouseDown: startDrawing,
4266
+ onMouseMove: draw,
4267
+ onMouseUp: stopDrawing,
4268
+ onMouseLeave: stopDrawing,
4269
+ onTouchStart: startDrawing,
4270
+ onTouchMove: draw,
4271
+ onTouchEnd: stopDrawing,
4272
+ className: "w-full h-[220px] cursor-crosshair block"
4273
+ }
4274
+ ) })
4275
+ ] })
4276
+ }
4277
+ )
4278
+ ] });
4279
+ }
3649
4280
  function FormattedNumberInput({
3650
4281
  value,
3651
4282
  onChange,
@@ -4328,11 +4959,80 @@ function ReferenceSelect({
4328
4959
  searchable = false,
4329
4960
  max,
4330
4961
  value,
4331
- onChange
4962
+ onChange,
4963
+ onSelectRecord
4332
4964
  }) {
4333
4965
  const ctx = useCmsContext();
4966
+ const t = useAdminI18n();
4334
4967
  const [options, setOptions] = (0, import_react5.useState)([]);
4335
4968
  const [loading, setLoading] = (0, import_react5.useState)(true);
4969
+ const [clientModalOpen, setClientModalOpen] = (0, import_react5.useState)(false);
4970
+ const [creatingClient, setCreatingClient] = (0, import_react5.useState)(false);
4971
+ const [clientError, setClientError] = (0, import_react5.useState)("");
4972
+ const [newClient, setNewClient] = (0, import_react5.useState)({
4973
+ tipo: "Persona",
4974
+ tipoDocumento: "C\xE9dula de ciudadan\xEDa",
4975
+ id: "",
4976
+ sucursal: "",
4977
+ nombre: "",
4978
+ email: "",
4979
+ telefono: "",
4980
+ ciudad: "",
4981
+ direccion: ""
4982
+ });
4983
+ const handleSaveClient = async () => {
4984
+ setClientError("");
4985
+ if (!newClient.id.trim()) {
4986
+ setClientError(t.idRequired);
4987
+ return;
4988
+ }
4989
+ if (!newClient.nombre.trim()) {
4990
+ setClientError(t.nameRequired);
4991
+ return;
4992
+ }
4993
+ setCreatingClient(true);
4994
+ try {
4995
+ const entry = {
4996
+ ...newClient,
4997
+ id: newClient.id.trim(),
4998
+ nombre: newClient.nombre.trim()
4999
+ };
5000
+ await ctx.adapter.putEntry("clients", entry);
5001
+ const res = await ctx.adapter.listEntries("clients");
5002
+ const fromCollection = (res || []).map((r) => {
5003
+ const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
5004
+ const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
5005
+ const lab = fullName || String(r[displayField] || r.name || r.id);
5006
+ return {
5007
+ value: val,
5008
+ label: val && val !== lab ? `${lab} (${val})` : lab,
5009
+ raw: r
5010
+ };
5011
+ });
5012
+ setOptions(fromCollection);
5013
+ onChange(entry.id);
5014
+ if (onSelectRecord) {
5015
+ onSelectRecord(entry);
5016
+ }
5017
+ setClientModalOpen(false);
5018
+ setNewClient({
5019
+ tipo: "Persona",
5020
+ tipoDocumento: "C\xE9dula de ciudadan\xEDa",
5021
+ id: "",
5022
+ sucursal: "",
5023
+ nombre: "",
5024
+ email: "",
5025
+ telefono: "",
5026
+ ciudad: "",
5027
+ direccion: ""
5028
+ });
5029
+ import_antd.message.success(t.clientCreatedSuccess);
5030
+ } catch (err) {
5031
+ setClientError(err?.message || "Error al crear cliente.");
5032
+ } finally {
5033
+ setCreatingClient(false);
5034
+ }
5035
+ };
4336
5036
  (0, import_react5.useEffect)(() => {
4337
5037
  if (!collectionId) {
4338
5038
  if (fallbackOptions && fallbackOptions.length > 0) {
@@ -4343,65 +5043,279 @@ function ReferenceSelect({
4343
5043
  }
4344
5044
  setLoading(true);
4345
5045
  ctx.adapter.listEntries(collectionId).then((res) => {
4346
- const fromCollection = res.map((r) => {
5046
+ const fromCollection = (res || []).map((r) => {
4347
5047
  const val = valueField && r[valueField] !== void 0 ? String(r[valueField]) : r.name ? String(r.name) : r.id;
4348
- const lab = String(r[displayField] || r.name || r.id);
4349
- return { value: val, label: lab };
5048
+ const fullName = r.apellido ? `${r.nombre || r.name || ""} ${r.apellido}`.trim() : "";
5049
+ const lab = fullName || String(r[displayField] || r.name || r.id);
5050
+ return {
5051
+ value: val,
5052
+ label: val && val !== lab ? `${lab} (${val})` : lab,
5053
+ raw: r
5054
+ };
4350
5055
  });
4351
- const fallbackList = (fallbackOptions || []).map(
4352
- (opt) => typeof opt === "string" ? { value: opt, label: opt } : opt
4353
- );
4354
- const combined = [...fromCollection];
4355
- for (const fb of fallbackList) {
4356
- if (!combined.some((c) => c.value === fb.value || c.label === fb.label)) {
4357
- combined.push(fb);
4358
- }
4359
- }
4360
- setOptions(combined);
5056
+ setOptions(fromCollection);
4361
5057
  setLoading(false);
4362
5058
  }).catch(() => {
4363
- if (fallbackOptions && fallbackOptions.length > 0) {
4364
- setOptions(fallbackOptions.map((opt) => typeof opt === "string" ? { value: opt, label: opt } : opt));
4365
- }
5059
+ setOptions([]);
4366
5060
  setLoading(false);
4367
5061
  });
4368
- }, [collectionId, displayField, valueField, fallbackOptions, ctx.adapter]);
5062
+ }, [collectionId, displayField, valueField, fallbackOptions, ctx.adapter, ctx.collectionChangedAt]);
4369
5063
  if (multiple) {
4370
5064
  const selectedList = Array.isArray(value) ? value.map(String) : typeof value === "string" && value.trim() ? value.split(",").map((s) => s.trim()).filter(Boolean) : [];
4371
5065
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4372
- SearchableMultiSelect,
5066
+ import_antd.Select,
4373
5067
  {
4374
- options,
4375
- value: selectedList,
4376
- onChange,
5068
+ size: "large",
5069
+ mode: "multiple",
4377
5070
  loading,
4378
- searchable,
5071
+ showSearch: searchable,
4379
5072
  placeholder: "Seleccionar opciones...",
4380
- searchPlaceholder: `Buscar ${collectionId === "sauces" ? "salsa" : collectionId === "extras" ? "adicional" : "opci\xF3n"}...`,
4381
- emptyMessage: "No hay opciones registradas todav\xEDa.",
4382
- max
5073
+ filterOption: (input, option) => {
5074
+ if (!input) return true;
5075
+ const q = input.toLowerCase();
5076
+ const label = String(option?.label ?? "").toLowerCase();
5077
+ const val = String(option?.value ?? "").toLowerCase();
5078
+ return label.includes(q) || val.includes(q);
5079
+ },
5080
+ maxCount: max,
5081
+ value: selectedList,
5082
+ onChange,
5083
+ options,
5084
+ className: "w-full"
4383
5085
  }
4384
5086
  );
4385
5087
  }
4386
- const singleVal = String(value ?? "");
5088
+ const singleVal = value !== void 0 && value !== null && value !== "" ? String(value) : void 0;
4387
5089
  const displayOptions = [...options];
4388
5090
  if (singleVal && !displayOptions.some((o) => o.value === singleVal)) {
4389
5091
  displayOptions.unshift({ value: singleVal, label: singleVal });
4390
5092
  }
4391
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
4392
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4393
- "select",
5093
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
5094
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
5095
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5096
+ import_antd.Select,
5097
+ {
5098
+ size: "large",
5099
+ loading,
5100
+ showSearch: searchable,
5101
+ placeholder: loading ? t.loadingOptions : t.selectOption,
5102
+ allowClear: true,
5103
+ filterOption: (input, option) => {
5104
+ if (!input) return true;
5105
+ const q = input.toLowerCase();
5106
+ const label = String(option?.label ?? "").toLowerCase();
5107
+ const val = String(option?.value ?? "").toLowerCase();
5108
+ return label.includes(q) || val.includes(q);
5109
+ },
5110
+ value: singleVal,
5111
+ onChange: (v) => {
5112
+ onChange(v || "");
5113
+ if (onSelectRecord) {
5114
+ const found = options.find((o) => o.value === v);
5115
+ if (found?.raw) onSelectRecord(found.raw);
5116
+ }
5117
+ },
5118
+ options: displayOptions,
5119
+ dropdownRender: (menu) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5120
+ menu,
5121
+ collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-2 border-t border-slate-100 flex items-center justify-between bg-slate-50", children: [
5122
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xs text-slate-500 font-medium", children: t.cantFindClient }),
5123
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5124
+ import_antd.Button,
5125
+ {
5126
+ type: "primary",
5127
+ size: "small",
5128
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-3.5 h-3.5" }),
5129
+ onClick: () => {
5130
+ setClientError("");
5131
+ setClientModalOpen(true);
5132
+ },
5133
+ className: "bg-blue-600 hover:bg-blue-700 text-xs font-semibold rounded-lg shadow-sm",
5134
+ children: t.createClient
5135
+ }
5136
+ )
5137
+ ] })
5138
+ ] }),
5139
+ className: "w-full"
5140
+ }
5141
+ ) }),
5142
+ collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5143
+ import_antd.Button,
5144
+ {
5145
+ type: "primary",
5146
+ size: "large",
5147
+ icon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Plus, { className: "w-4 h-4" }),
5148
+ onClick: () => {
5149
+ setClientError("");
5150
+ setClientModalOpen(true);
5151
+ },
5152
+ className: "bg-blue-600 hover:bg-blue-700 font-bold rounded-xl shrink-0 h-10 px-4 text-xs uppercase tracking-wider",
5153
+ children: t.newBtn
5154
+ }
5155
+ )
5156
+ ] }),
5157
+ collectionId === "clients" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5158
+ import_antd.Modal,
4394
5159
  {
4395
- value: singleVal,
4396
- onChange: (e) => onChange(e.target.value),
4397
- className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white appearance-none pr-10",
4398
- children: [
4399
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: loading ? "Cargando opciones..." : "-- Selecciona una opci\xF3n --" }),
4400
- displayOptions.map((o, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: o.value, children: o.label }, `${o.value}-${idx}`))
4401
- ]
5160
+ open: clientModalOpen,
5161
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-xl font-bold text-slate-900 font-display", children: t.basicDetails }),
5162
+ onCancel: () => setClientModalOpen(false),
5163
+ centered: true,
5164
+ width: 650,
5165
+ footer: null,
5166
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "pt-2 space-y-4", children: [
5167
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
5168
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5169
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientType }),
5170
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5171
+ import_antd.Select,
5172
+ {
5173
+ size: "large",
5174
+ value: newClient.tipo,
5175
+ onChange: (val) => {
5176
+ setNewClient((prev) => ({
5177
+ ...prev,
5178
+ tipo: val,
5179
+ tipoDocumento: val === "Empresa" ? "Nit" : "C\xE9dula de ciudadan\xEDa"
5180
+ }));
5181
+ },
5182
+ options: [
5183
+ { label: "Persona", value: "Persona" },
5184
+ { label: "Empresa", value: "Empresa" }
5185
+ ],
5186
+ className: "w-full"
5187
+ }
5188
+ )
5189
+ ] }),
5190
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5191
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientDocType }),
5192
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5193
+ import_antd.Select,
5194
+ {
5195
+ size: "large",
5196
+ value: newClient.tipoDocumento,
5197
+ onChange: (val) => setNewClient((prev) => ({ ...prev, tipoDocumento: val })),
5198
+ options: newClient.tipo === "Persona" ? [
5199
+ { label: "C\xE9dula de ciudadan\xEDa", value: "C\xE9dula de ciudadan\xEDa" },
5200
+ { label: "C\xE9dula de extranjer\xEDa", value: "C\xE9dula de extranjer\xEDa" },
5201
+ { label: "Pasaporte", value: "Pasaporte" }
5202
+ ] : [{ label: "Nit", value: "Nit" }],
5203
+ className: "w-full"
5204
+ }
5205
+ )
5206
+ ] })
5207
+ ] }),
5208
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
5209
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5210
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: [
5211
+ t.clientIdentification,
5212
+ " *"
5213
+ ] }),
5214
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5215
+ import_antd.Input,
5216
+ {
5217
+ size: "large",
5218
+ placeholder: t.clientIdentification,
5219
+ value: newClient.id,
5220
+ onChange: (e) => setNewClient((prev) => ({ ...prev, id: e.target.value }))
5221
+ }
5222
+ )
5223
+ ] }),
5224
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5225
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientBranch }),
5226
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5227
+ import_antd.Input,
5228
+ {
5229
+ size: "large",
5230
+ placeholder: t.clientBranch,
5231
+ value: newClient.sucursal,
5232
+ onChange: (e) => setNewClient((prev) => ({ ...prev, sucursal: e.target.value }))
5233
+ }
5234
+ )
5235
+ ] })
5236
+ ] }),
5237
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
5238
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5239
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: [
5240
+ t.clientName,
5241
+ " *"
5242
+ ] }),
5243
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5244
+ import_antd.Input,
5245
+ {
5246
+ size: "large",
5247
+ placeholder: t.clientName,
5248
+ value: newClient.nombre,
5249
+ onChange: (e) => setNewClient((prev) => ({ ...prev, nombre: e.target.value }))
5250
+ }
5251
+ )
5252
+ ] }),
5253
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5254
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientEmail }),
5255
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5256
+ import_antd.Input,
5257
+ {
5258
+ size: "large",
5259
+ placeholder: t.clientEmail,
5260
+ value: newClient.email,
5261
+ onChange: (e) => setNewClient((prev) => ({ ...prev, email: e.target.value }))
5262
+ }
5263
+ )
5264
+ ] })
5265
+ ] }),
5266
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
5267
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5268
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientPhone }),
5269
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5270
+ import_antd.Input,
5271
+ {
5272
+ size: "large",
5273
+ placeholder: t.clientPhone,
5274
+ value: newClient.telefono,
5275
+ onChange: (e) => setNewClient((prev) => ({ ...prev, telefono: e.target.value }))
5276
+ }
5277
+ )
5278
+ ] }),
5279
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5280
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientCity }),
5281
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5282
+ import_antd.Input,
5283
+ {
5284
+ size: "large",
5285
+ placeholder: t.clientCity,
5286
+ value: newClient.ciudad,
5287
+ onChange: (e) => setNewClient((prev) => ({ ...prev, ciudad: e.target.value }))
5288
+ }
5289
+ )
5290
+ ] })
5291
+ ] }),
5292
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
5293
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-xs font-bold text-slate-700 mb-1", children: t.clientAddress }),
5294
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5295
+ import_antd.Input,
5296
+ {
5297
+ size: "large",
5298
+ placeholder: t.clientAddress,
5299
+ value: newClient.direccion,
5300
+ onChange: (e) => setNewClient((prev) => ({ ...prev, direccion: e.target.value }))
5301
+ }
5302
+ )
5303
+ ] }),
5304
+ clientError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs font-semibold text-red-600 bg-red-50 p-2.5 rounded-lg border border-red-200", children: clientError }),
5305
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5306
+ import_antd.Button,
5307
+ {
5308
+ type: "primary",
5309
+ size: "large",
5310
+ loading: creatingClient,
5311
+ onClick: handleSaveClient,
5312
+ className: "w-full bg-blue-600 hover:bg-blue-700 font-bold uppercase rounded-xl h-11 text-xs tracking-wider shadow-sm mt-2",
5313
+ children: t.create.toUpperCase()
5314
+ }
5315
+ )
5316
+ ] })
4402
5317
  }
4403
- ),
4404
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
5318
+ )
4405
5319
  ] });
4406
5320
  }
4407
5321
  function ReferenceTableCell({