zenit-sdk 0.1.8 → 0.1.9

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.mjs CHANGED
@@ -37,7 +37,7 @@ import {
37
37
  sendMessageStream,
38
38
  useSendMessage,
39
39
  useSendMessageStream
40
- } from "./chunk-HCGYF65R.mjs";
40
+ } from "./chunk-3M57OBM6.mjs";
41
41
 
42
42
  // src/http/HttpClient.ts
43
43
  var HttpClient = class {
@@ -689,6 +689,55 @@ function useGeolocation(options) {
689
689
 
690
690
  // src/react/map/map-utils.ts
691
691
  var import_leaflet2 = __toESM(require("leaflet"));
692
+
693
+ // src/config/modalWhitelist.ts
694
+ var SECTOR_MODAL_WHITELIST = [
695
+ { key: "Sector", label: "Sector" },
696
+ { key: "Promotor", label: "Promotor" },
697
+ { key: "Capital Total", label: "Capital Total" },
698
+ { key: "Total Capital Mora", label: "Capital en Mora" },
699
+ { key: "Tendencia Mora", label: "Tendencia de Mora", hint: "trend_icon" },
700
+ { key: "Tendencia Capital", label: "Tendencia de Capital", hint: "trend_icon" },
701
+ { key: "Tendencia Castigos", label: "Tendencia de Castigos", hint: "trend_icon" },
702
+ { key: "Impacto Sector", label: "Impacto del Sector" },
703
+ { key: "Total Clientes Sector", label: "Total de Clientes" },
704
+ { key: "Total Clientes Sanos", label: "Clientes Sanos" },
705
+ { key: "Total Clientes Morosos", label: "Clientes en Mora" },
706
+ { key: "Total Clientes Castigados", label: "Clientes Castigados" },
707
+ { key: "Total Clientes Nuevos", label: "Clientes Nuevos" },
708
+ { key: "Total Clientes Salidos", label: "Clientes Salidos" },
709
+ { key: "Insights", label: "An\xE1lisis IA", hint: "collapsible" },
710
+ { key: "Recomendaciones", label: "Recomendaciones IA", hint: "collapsible" }
711
+ ];
712
+ var CLIENTE_MODAL_WHITELIST = [
713
+ { key: "nombre del cliente", label: "Nombre del Cliente" },
714
+ { key: "dpi", label: "DPI" },
715
+ { key: "kpi", label: "Estado", hint: "kpi_badge" },
716
+ { key: "tel principal", label: "Tel\xE9fono", hint: "phone_link" },
717
+ { key: "capital concedido", label: "Capital Concedido" },
718
+ { key: "mora", label: "Monto en Mora", hint: "mora_alert" },
719
+ { key: "etapa", label: "Etapa del Cr\xE9dito" },
720
+ { key: "prestamo", label: "No. de Pr\xE9stamo" },
721
+ { key: "sucursal", label: "Sucursal", aliases: ["nombre sucursal"] }
722
+ ];
723
+ function applyModalWhitelist(rawData, whitelist) {
724
+ const keys = Object.keys(rawData ?? {});
725
+ return whitelist.map(({ key, label, hint, aliases = [] }) => {
726
+ const keysToTry = [key, ...aliases];
727
+ let value = void 0;
728
+ for (const k of keysToTry) {
729
+ const match = keys.find((rawKey) => rawKey.toLowerCase() === k.toLowerCase());
730
+ if (match !== void 0 && rawData[match] !== null && rawData[match] !== void 0) {
731
+ value = rawData[match];
732
+ break;
733
+ }
734
+ }
735
+ if (value === void 0) return null;
736
+ return { label, value, hint: hint ?? null };
737
+ }).filter((entry) => Boolean(entry));
738
+ }
739
+
740
+ // src/react/map/map-utils.ts
692
741
  var POPUP_STYLE_ID = "zenit-leaflet-popup-styles";
693
742
  var POPUP_EXCLUDED_KEYS = /* @__PURE__ */ new Set(["geom", "geometry", "_private"]);
694
743
  var POPUP_TITLE_KEYS = ["id", "nombre", "name", "title", "titulo", "cluster"];
@@ -925,6 +974,10 @@ function shouldIncludePopupEntry(key, value) {
925
974
  return true;
926
975
  }
927
976
  function createPopupContent(properties) {
977
+ const whitelistedRows = buildWhitelistedRows(properties);
978
+ if (whitelistedRows) {
979
+ return whitelistedRows;
980
+ }
928
981
  const header = findHeaderProperties(properties);
929
982
  const headerText = header.title?.value ?? extractPopupHeader(properties);
930
983
  const usedKeys = new Set([header.title?.key, header.badge?.key, header.description?.key].filter(Boolean));
@@ -964,6 +1017,37 @@ function createPopupContent(properties) {
964
1017
  }).join("");
965
1018
  return `<div>${colorBar}${headerHtml}${descriptionHtml}${rowsHtml}</div>`;
966
1019
  }
1020
+ function buildWhitelistedRows(properties) {
1021
+ const whitelist = selectModalWhitelist(properties);
1022
+ if (!whitelist) return null;
1023
+ const entries = applyModalWhitelist(properties, whitelist);
1024
+ if (entries.length === 0) {
1025
+ return '<div style="padding:8px 0; color:#64748b; text-align:center;">Sin datos disponibles</div>';
1026
+ }
1027
+ const rowsHtml = entries.map(({ label, value }) => {
1028
+ const valueHtml = renderPopupValue(value);
1029
+ return `
1030
+ <div style="display:grid; grid-template-columns:minmax(90px, 35%) 1fr; gap:8px; padding:6px 0; border-bottom:1px solid #e2e8f0;">
1031
+ <div style="font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.04em; color:#64748b;">${escapeHtml(label)}</div>
1032
+ <div style="font-size:13px; color:#0f172a; word-break:break-word;">${valueHtml}</div>
1033
+ </div>
1034
+ `;
1035
+ }).join("");
1036
+ return `<div>${rowsHtml}</div>`;
1037
+ }
1038
+ function countWhitelistMatches(properties, whitelist) {
1039
+ const keys = Object.keys(properties).map((key) => key.toLowerCase());
1040
+ return whitelist.reduce((count, item) => {
1041
+ const candidates = [item.key, ...item.aliases ?? []].map((candidate) => candidate.toLowerCase());
1042
+ return candidates.some((candidate) => keys.includes(candidate)) ? count + 1 : count;
1043
+ }, 0);
1044
+ }
1045
+ function selectModalWhitelist(properties) {
1046
+ const sectorMatches = countWhitelistMatches(properties, SECTOR_MODAL_WHITELIST);
1047
+ const clienteMatches = countWhitelistMatches(properties, CLIENTE_MODAL_WHITELIST);
1048
+ if (sectorMatches === 0 && clienteMatches === 0) return null;
1049
+ return sectorMatches >= clienteMatches ? SECTOR_MODAL_WHITELIST : CLIENTE_MODAL_WHITELIST;
1050
+ }
967
1051
  function isPolygonType(layerType, geometryType) {
968
1052
  const candidate = (layerType ?? geometryType ?? "").toLowerCase();
969
1053
  return candidate === "polygon" || candidate === "multipolygon";