myio-js-library 0.1.566 → 0.1.567

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.cjs CHANGED
@@ -222,9 +222,12 @@ __export(src_exports, {
222
222
  IMPORTANCE_COLORS: () => IMPORTANCE_COLORS,
223
223
  IMPORTANCE_LABELS: () => IMPORTANCE_LABELS,
224
224
  IMPORTANCE_LABELS_EN: () => IMPORTANCE_LABELS_EN,
225
+ ImportApiError: () => ImportApiError,
225
226
  InfoTooltip: () => InfoTooltip,
226
227
  LoadingSpinner: () => LoadingSpinner,
227
228
  LogHelper: () => LogHelper,
229
+ MANUAL_ASSET_SUFFIX: () => MANUAL_ASSET_SUFFIX,
230
+ MANUAL_DEVICE_PROFILES: () => MANUAL_DEVICE_PROFILES,
228
231
  MEASUREMENT_DOMAIN_CONFIG: () => DOMAIN_CONFIG5,
229
232
  MENU_SHOPPING_CSS_PREFIX: () => MENU_SHOPPING_CSS_PREFIX,
230
233
  METRO_TILE_COLORS: () => METRO_TILE_COLORS,
@@ -235,6 +238,7 @@ __export(src_exports, {
235
238
  MYIO_ACCENT: () => MYIO_ACCENT,
236
239
  MYIO_CHART_PALETTE: () => MYIO_CHART_PALETTE,
237
240
  MYIO_CHART_PALETTE_DARK: () => MYIO_CHART_PALETTE_DARK,
241
+ ManualDeviceError: () => ManualDeviceError,
238
242
  MenuController: () => MenuController,
239
243
  MenuShoppingView: () => MenuShoppingView,
240
244
  MenuView: () => MenuView,
@@ -377,6 +381,7 @@ __export(src_exports, {
377
381
  buildMoneyVarianceHTML: () => buildMoneyVarianceHTML,
378
382
  buildMyioIngestionAuth: () => buildMyioIngestionAuth,
379
383
  buildReportItemsList: () => buildReportItemsList,
384
+ buildTemplateCsv: () => buildTemplateCsv,
380
385
  buildTemplateExport: () => buildTemplateExport,
381
386
  buildTicketServiceOrchestrator: () => buildTicketServiceOrchestrator,
382
387
  buildVerdictHTML: () => buildVerdictHTML,
@@ -476,6 +481,7 @@ __export(src_exports, {
476
481
  createLibraryVersionChecker: () => createLibraryVersionChecker,
477
482
  createLoadingSpinner: () => createLoadingSpinner,
478
483
  createLogHelper: () => createLogHelper,
484
+ createManualDevice: () => createManualDevice,
479
485
  createMenuComponent: () => createMenuComponent,
480
486
  createMenuShoppingComponent: () => createMenuShoppingComponent,
481
487
  createModalFooter: () => createModalFooter,
@@ -512,6 +518,7 @@ __export(src_exports, {
512
518
  createTbEnvelopeStore: () => createTbEnvelopeStore,
513
519
  createTelemetryGridComponent: () => createTelemetryGridComponent,
514
520
  createTelemetryGridShoppingComponent: () => createTelemetryGridShoppingComponent,
521
+ createTelemetryImportApi: () => createTelemetryImportApi,
515
522
  createTelemetryInfoShoppingComponent: () => createTelemetryInfoShoppingComponent,
516
523
  createTicketDetailModal: () => createTicketDetailModal,
517
524
  createTicketsTab: () => createTicketsTab,
@@ -547,7 +554,7 @@ __export(src_exports, {
547
554
  doSchedulesOverlap: () => doSchedulesOverlap,
548
555
  downloadAnnotationsTextFile: () => downloadTextFile,
549
556
  encodeDeviceProductCode: () => encodeDeviceProductCode,
550
- escapeAnnotationHtml: () => escapeHtml17,
557
+ escapeAnnotationHtml: () => escapeHtml20,
551
558
  evaluateDeviceStatus: () => evaluateDeviceStatus,
552
559
  expandBandHours: () => expandBandHours,
553
560
  expandBandToHourBucketsByYear: () => expandBandToHourBucketsByYear,
@@ -691,7 +698,7 @@ __export(src_exports, {
691
698
  injectCustomerCardV1Styles: () => injectCustomerCardV1Styles,
692
699
  injectCustomerCardV2Styles: () => injectCustomerCardV2Styles,
693
700
  injectDeviceCategoryStyles: () => injectDeviceCategoryStyles,
694
- injectDeviceGridV6Styles: () => injectStyles19,
701
+ injectDeviceGridV6Styles: () => injectStyles22,
695
702
  injectDeviceOperationalCardGridStyles: () => injectDeviceOperationalCardGridStyles,
696
703
  injectDeviceOperationalCardStyles: () => injectDeviceOperationalCardStyles,
697
704
  injectExportButtonStyles: () => injectExportButtonStyles,
@@ -751,6 +758,7 @@ __export(src_exports, {
751
758
  listDeviceProductTypes: () => listDeviceProductTypes,
752
759
  listDomains: () => listDomains,
753
760
  listGroups: () => listGroups,
761
+ manualDeviceName: () => manualDeviceName,
754
762
  mapConnectionStatus: () => mapConnectionStatus,
755
763
  mapDeviceStatusToCardStatus: () => mapDeviceStatusToCardStatus,
756
764
  mapDeviceToConnectionStatus: () => mapDeviceToConnectionStatus,
@@ -759,6 +767,7 @@ __export(src_exports, {
759
767
  minutesToMs: () => minutesToMs,
760
768
  msToMinutes: () => msToMinutes,
761
769
  myioExportData: () => myioExportData,
770
+ nextManualSeq: () => nextManualSeq,
762
771
  nfdNormalizeAnnotationSearch: () => nfdNormalize,
763
772
  normalizeBudgetBlock: () => normalizeBudgetBlock,
764
773
  normalizeConnectionStatus: () => normalizeConnectionStatus,
@@ -796,6 +805,7 @@ __export(src_exports, {
796
805
  openGoalsPanel: () => openGoalsPanel,
797
806
  openHelpModal: () => openHelpModal,
798
807
  openIntegrationsModal: () => openIntegrationsModal,
808
+ openManualDeviceModal: () => openManualDeviceModal,
799
809
  openMeasurementSetupModal: () => openMeasurementSetupModal,
800
810
  openMessageDialog: () => openMessageDialog,
801
811
  openMetasGuide: () => openMetasGuide,
@@ -808,6 +818,8 @@ __export(src_exports, {
808
818
  openRealTimeTelemetryModal: () => openRealTimeTelemetryModal,
809
819
  openReportsHub: () => openReportsHub,
810
820
  openSettingsHubModal: () => openSettingsHubModal,
821
+ openStandardModal: () => openStandardModal,
822
+ openTelemetryImportModal: () => openTelemetryImportModal,
811
823
  openTemperatureComparisonModal: () => openTemperatureComparisonModal,
812
824
  openTemperatureModal: () => openTemperatureModal,
813
825
  openTemperatureSettingsModal: () => openTemperatureSettingsModal,
@@ -822,6 +834,7 @@ __export(src_exports, {
822
834
  panelTermToDeviceCategory: () => panelTermToDeviceCategory,
823
835
  parseBinaryState: () => parseBinaryState,
824
836
  parseClassificationEntities: () => parseClassificationEntities,
837
+ parseCsv: () => parseCsv,
825
838
  parseGcdrEnergyRoot: () => parseGcdrEnergyRoot,
826
839
  parseGcdrEntityForest: () => parseGcdrEntityForest,
827
840
  parseInputDateToDate: () => parseInputDateToDate,
@@ -882,17 +895,19 @@ __export(src_exports, {
882
895
  resolveSubcategory: () => resolveSubcategory,
883
896
  resolveWithFallback: () => resolveWithFallback,
884
897
  routeMoneyRender: () => routeMoneyRender,
898
+ rowsFromTable: () => rowsFromTable,
885
899
  schedCreateDateInput: () => createDateInput,
886
900
  schedCreateNumberInput: () => createNumberInput,
887
901
  schedCreateSelect: () => createSelect,
888
902
  schedCreateTimeInput: () => createTimeInput,
889
- schedEscapeHtml: () => escapeHtml16,
903
+ schedEscapeHtml: () => escapeHtml19,
890
904
  schedShowConfirmModal: () => showConfirmModal,
891
905
  schedShowNotificationModal: () => showNotificationModal,
892
906
  selectBreakdownItems: () => selectBreakdownItems,
893
907
  setActiveProfile: () => setActiveProfile,
894
908
  shouldFlashIcon: () => shouldFlashIcon,
895
909
  shouldVirtualizeAnnotationList: () => shouldVirtualize,
910
+ siglaFromManualAsset: () => siglaFromManualAsset,
896
911
  signOf: () => signOf,
897
912
  slugifyCustomerName: () => slugifyCustomerName,
898
913
  sortAnnotationGroups: () => sortGroups,
@@ -922,6 +937,7 @@ __export(src_exports, {
922
937
  validateDeviceProductName: () => validateDeviceProductName,
923
938
  validateProfile: () => validateProfile,
924
939
  validateTree: () => validateTree,
940
+ valveHistoryFromTelemetry: () => valveHistoryFromTelemetry,
925
941
  version: () => version,
926
942
  waterDeviceStatusIcons: () => waterDeviceStatusIcons,
927
943
  wireCategoryToPanel: () => wireCategoryToPanel,
@@ -934,7 +950,7 @@ module.exports = __toCommonJS(src_exports);
934
950
  // package.json
935
951
  var package_default = {
936
952
  name: "myio-js-library",
937
- version: "0.1.566",
953
+ version: "0.1.567",
938
954
  description: "A clean, standalone JS SDK for MYIO projects",
939
955
  license: "MIT",
940
956
  repository: "github:gh-myio/myio-js-library",
@@ -2449,6 +2465,9 @@ var DEVICE_TYPE_CONFIG = {
2449
2465
  HIDROMETRO: { category: "water", image: deviceIcons.HIDROMETRO },
2450
2466
  HIDROMETRO_AREA_COMUM: { category: "water", image: deviceIcons.HIDROMETRO_AREA_COMUM },
2451
2467
  HIDROMETRO_SHOPPING: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
2468
+ HIDROMETRO_ENTRADA: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
2469
+ // Virtual: Entrada − Σ consumos (calculado no dashboard; card informativo na coluna Entrada)
2470
+ HIDROMETRO_ENTRADA_RETROLAVAGEM: { category: "water", image: deviceIcons.HIDROMETRO_SHOPPING },
2452
2471
  CAIXA_DAGUA: { category: "water", image: deviceIcons.CAIXA_DAGUA },
2453
2472
  // ED-1354: poço/cisterna (nível, como CAIXA_DAGUA) — _ENTRADA vai p/ a coluna Entrada, o outro p/ Área Comum
2454
2473
  CISTERNA: { category: "water", image: deviceIcons.CISTERNA },
@@ -20848,17 +20867,34 @@ function intervalsFromTelemetry(points, opts = {}) {
20848
20867
  if (open !== null) out.push([open, null]);
20849
20868
  return out;
20850
20869
  }
20870
+ function hasUsableTelemetryPoint(points, parseValue) {
20871
+ return (points || []).some((point) => {
20872
+ const ts = Number(point?.ts);
20873
+ return point?.ts !== null && point?.ts !== void 0 && Number.isFinite(ts) && parseValue(point?.value) !== null;
20874
+ });
20875
+ }
20876
+ function parseNumericTelemetry(value) {
20877
+ if (typeof value !== "number" && typeof value !== "string") return null;
20878
+ if (typeof value === "string" && value.trim() === "") return null;
20879
+ const number = Number(value);
20880
+ return Number.isFinite(number) ? number : null;
20881
+ }
20851
20882
  var PUMP_POWER_KEY = "consumption";
20852
20883
  var VALVE_STATE_KEYS = ["state", "status"];
20853
20884
  function pumpHistoryFromConsumption(points, thresholdW = 0) {
20885
+ if (!hasUsableTelemetryPoint(points, parseNumericTelemetry)) return null;
20854
20886
  return intervalsFromTelemetry(points, { threshold: thresholdW });
20855
20887
  }
20888
+ function valveHistoryFromTelemetry(points) {
20889
+ if (!hasUsableTelemetryPoint(points, parseBinaryState)) return null;
20890
+ return intervalsFromTelemetry(points);
20891
+ }
20856
20892
  function latestPowerKw(points) {
20857
20893
  let best = null;
20858
20894
  for (const p of points || []) {
20859
20895
  const ts = Number(p?.ts);
20860
- const v = Number(p?.value);
20861
- if (!Number.isFinite(ts) || !Number.isFinite(v) || p?.value === "" || p?.value === null) continue;
20896
+ const v = parseNumericTelemetry(p?.value);
20897
+ if (!Number.isFinite(ts) || v === null) continue;
20862
20898
  if (!best || ts > best.ts) best = { ts, v };
20863
20899
  }
20864
20900
  return best ? best.v / 1e3 : null;
@@ -21131,8 +21167,10 @@ function renderCardComponentV5({
21131
21167
  // ED-1354: indicadores B1/B2/S (bombas MOTOR + solenoide) no card do poço
21132
21168
  equipmentIndicators
21133
21169
  } = entityObject;
21134
- const deviceStatus = dataLoading ? "loading" : rawDeviceStatus;
21135
- const deviceType = deviceProfile || legacyDeviceType || "";
21170
+ const rawProfile = String(deviceProfile || legacyDeviceType || "");
21171
+ const isManualDevice = /_MANUAL$/i.test(rawProfile);
21172
+ const deviceType = isManualDevice ? rawProfile.replace(/_MANUAL$/i, "") : rawProfile;
21173
+ const deviceStatus = dataLoading ? "loading" : isManualDevice ? "power_on" : rawDeviceStatus;
21136
21174
  const MyIOToast2 = (function() {
21137
21175
  let toastContainer = null;
21138
21176
  let toastTimeout = null;
@@ -32391,8 +32429,8 @@ var EnergyDataFetcher = class {
32391
32429
  // src/components/premium-modals/internal/engines/CsvExporter.ts
32392
32430
  var toCsv = (rows, locale = "pt-BR", sep = ";") => {
32393
32431
  const fmt2 = new Intl.NumberFormat(locale, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
32394
- const esc9 = (v) => (typeof v === "number" ? fmt2.format(v) : String(v)).replace(/"/g, '""');
32395
- return rows.map((r) => r.map((c) => `"${esc9(c)}"`).join(sep)).join("\r\n");
32432
+ const esc10 = (v) => (typeof v === "number" ? fmt2.format(v) : String(v)).replace(/"/g, '""');
32433
+ return rows.map((r) => r.map((c) => `"${esc10(c)}"`).join(sep)).join("\r\n");
32396
32434
  };
32397
32435
 
32398
32436
  // src/components/premium-modals/energy/types.ts
@@ -36743,14 +36781,14 @@ var DeviceReportModal = class {
36743
36781
  // Header: "Relatório - <identifier> - <label>" + nome do device (sutil, com copiar).
36744
36782
  // O customer já aparece no footer premium. Texto escapado — o shell usa innerHTML no título.
36745
36783
  buildHeaderTitleHTML() {
36746
- const esc9 = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
36747
- const base = esc9(
36784
+ const esc10 = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
36785
+ const base = esc10(
36748
36786
  `Relat\xF3rio - ${this.params.identifier || "SEM IDENTIFICADOR"} - ${this.params.label || "SEM ETIQUETA"}`
36749
36787
  );
36750
36788
  const deviceName = String(this.params.deviceName || "").trim();
36751
36789
  const deviceHTML = deviceName ? `<span class="myio-dr-devname" style="margin-left:10px;font-size:0.72em;font-weight:400;opacity:.75;display:inline-flex;align-items:center;gap:4px;vertical-align:middle;">
36752
- ${esc9(deviceName)}
36753
- <button type="button" class="myio-dr-copy" data-copy="${esc9(deviceName)}" title="Copiar nome do dispositivo"
36790
+ ${esc10(deviceName)}
36791
+ <button type="button" class="myio-dr-copy" data-copy="${esc10(deviceName)}" title="Copiar nome do dispositivo"
36754
36792
  aria-label="Copiar nome do dispositivo"
36755
36793
  style="border:none;background:transparent;color:inherit;cursor:pointer;padding:0 2px;line-height:1;opacity:.9;display:inline-flex;">
36756
36794
  <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
@@ -41318,10 +41356,10 @@ var WaterTankModalView = class {
41318
41356
  */
41319
41357
  render() {
41320
41358
  const { params } = this.config;
41321
- const STYLE_ID20 = "myio-water-tank-modal-styles";
41322
- if (!document.getElementById(STYLE_ID20)) {
41359
+ const STYLE_ID23 = "myio-water-tank-modal-styles";
41360
+ if (!document.getElementById(STYLE_ID23)) {
41323
41361
  const style = document.createElement("style");
41324
- style.id = STYLE_ID20;
41362
+ style.id = STYLE_ID23;
41325
41363
  style.textContent = `
41326
41364
  @media (max-width: 640px) {
41327
41365
  .myio-water-tank-modal { width: 100vw !important; max-width: 100vw !important; max-height: 100vh !important; border-radius: 0 !important; }
@@ -62965,6 +63003,249 @@ var DeviceProfileTab = class {
62965
63003
  }
62966
63004
  };
62967
63005
 
63006
+ // src/components/premium-modals/settings/well-equipment/WellEquipmentTab.ts
63007
+ var ATTRIBUTE_KEYS = "deviceProfile,gcdrDeviceId,pumpBindings";
63008
+ var MAX_CUSTOMER_DEVICE_PAGES = 100;
63009
+ function escapeHtml6(value) {
63010
+ return value.replace(/[&<>"']/g, (char) => ({
63011
+ "&": "&amp;",
63012
+ "<": "&lt;",
63013
+ ">": "&gt;",
63014
+ '"': "&quot;",
63015
+ "'": "&#39;"
63016
+ })[char]);
63017
+ }
63018
+ function normalizeBindings(value) {
63019
+ const parsed = typeof value === "string" ? JSON.parse(value) : value;
63020
+ const bindings = parsed && typeof parsed === "object" ? parsed : {};
63021
+ const valid = (items, codes) => (Array.isArray(items) ? items : []).filter((item) => !!item && typeof item === "object" && typeof item.tbId === "string" && codes.has(item.code)).map((item) => ({ ...item }));
63022
+ return {
63023
+ pumps: valid(bindings.pumps, /* @__PURE__ */ new Set(["B1", "B2"])),
63024
+ valves: valid(bindings.valves, /* @__PURE__ */ new Set(["S"]))
63025
+ };
63026
+ }
63027
+ var WellEquipmentTab = class {
63028
+ config;
63029
+ equipment = [];
63030
+ bindings = { pumps: [], valves: [] };
63031
+ loaded = false;
63032
+ catalogWarnings = 0;
63033
+ constructor(config2) {
63034
+ this.config = config2;
63035
+ }
63036
+ async init() {
63037
+ this.config.container.innerHTML = '<p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>';
63038
+ try {
63039
+ const [wellAttributes, equipment] = await Promise.all([
63040
+ this.fetchAttributes(this.config.deviceId, "pumpBindings"),
63041
+ this.fetchEquipment()
63042
+ ]);
63043
+ const stored = wellAttributes.get("pumpBindings");
63044
+ this.bindings = stored == null ? { pumps: [], valves: [] } : normalizeBindings(stored);
63045
+ this.equipment = equipment;
63046
+ this.loaded = true;
63047
+ this.render();
63048
+ if (this.catalogWarnings > 0) {
63049
+ this.showMessage(
63050
+ `${this.catalogWarnings} equipamento(s) n\xE3o puderam ser verificados e foram omitidos do cat\xE1logo.`,
63051
+ true
63052
+ );
63053
+ }
63054
+ } catch (error) {
63055
+ this.config.container.innerHTML = `<p class="wet-state wet-error" role="alert">N\xE3o foi poss\xEDvel carregar os v\xEDnculos ou o cat\xE1logo de equipamentos: ${escapeHtml6(this.errorMessage(error))}</p>`;
63056
+ }
63057
+ }
63058
+ destroy() {
63059
+ }
63060
+ headers() {
63061
+ return {
63062
+ "X-Authorization": `Bearer ${this.config.jwtToken}`,
63063
+ "Content-Type": "application/json"
63064
+ };
63065
+ }
63066
+ async fetchAttributes(deviceId, keys) {
63067
+ const url = `${this.config.tbBaseUrl}/api/plugins/telemetry/DEVICE/${encodeURIComponent(deviceId)}/values/attributes/SERVER_SCOPE?keys=${encodeURIComponent(keys)}`;
63068
+ const response = await fetch(url, { headers: this.headers() });
63069
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
63070
+ const raw = await response.json();
63071
+ if (!Array.isArray(raw)) throw new Error("Resposta de atributos inv\xE1lida");
63072
+ return new Map(raw.map(({ key, value }) => [key, value]));
63073
+ }
63074
+ async fetchEquipment() {
63075
+ if (!this.config.customerId) throw new Error("customerId indispon\xEDvel");
63076
+ const devices = [];
63077
+ let page = 0;
63078
+ let hasNext = true;
63079
+ while (hasNext) {
63080
+ if (page >= MAX_CUSTOMER_DEVICE_PAGES) {
63081
+ throw new Error(`Cat\xE1logo excede o limite de ${MAX_CUSTOMER_DEVICE_PAGES} p\xE1ginas`);
63082
+ }
63083
+ const query = new URLSearchParams({ pageSize: "1000", page: String(page) });
63084
+ const url = `${this.config.tbBaseUrl}/api/customer/${encodeURIComponent(this.config.customerId)}/devices?${query}`;
63085
+ const response = await fetch(url, { headers: this.headers() });
63086
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
63087
+ const result = await response.json();
63088
+ if (!Array.isArray(result.data)) throw new Error("Resposta de equipamentos inv\xE1lida");
63089
+ if (result.hasNext === true && result.data.length === 0) {
63090
+ throw new Error("Pagina\xE7\xE3o do cat\xE1logo n\xE3o avan\xE7ou");
63091
+ }
63092
+ devices.push(...result.data);
63093
+ hasNext = result.hasNext === true;
63094
+ page += 1;
63095
+ }
63096
+ const candidates = devices.map((device) => ({
63097
+ device,
63098
+ tbId: typeof device.id === "string" ? device.id : device.id?.id
63099
+ })).filter((item) => !!item.tbId);
63100
+ const queue = [...candidates];
63101
+ const matching = [];
63102
+ const worker = async () => {
63103
+ while (queue.length) {
63104
+ const item = queue.shift();
63105
+ if (!item) return;
63106
+ try {
63107
+ const attributes = await this.fetchAttributes(item.tbId, ATTRIBUTE_KEYS);
63108
+ const profile = String(attributes.get("deviceProfile") || "").toUpperCase();
63109
+ if (profile !== "BOMBA_POCO" && profile !== "SOLENOIDE") continue;
63110
+ matching.push({
63111
+ tbId: item.tbId,
63112
+ profile,
63113
+ label: String(item.device.label || item.device.name || item.tbId),
63114
+ gcdrId: attributes.get("gcdrDeviceId") == null ? void 0 : String(attributes.get("gcdrDeviceId"))
63115
+ });
63116
+ } catch (error) {
63117
+ this.catalogWarnings += 1;
63118
+ console.warn(`[WellEquipmentTab] Falha ao ler atributos do equipamento ${item.tbId}:`, error);
63119
+ }
63120
+ }
63121
+ };
63122
+ await Promise.all(Array.from({ length: Math.min(8, Math.max(1, queue.length)) }, () => worker()));
63123
+ return matching.sort((a, b) => a.label.localeCompare(b.label));
63124
+ }
63125
+ render() {
63126
+ const options = (profile, code, existing) => {
63127
+ const eligible = this.equipment.filter((item) => item.profile === profile);
63128
+ const missing = existing && !eligible.some((item) => item.tbId === existing.tbId) ? `<option value="${escapeHtml6(existing.tbId)}" selected data-unavailable="true">V\xEDnculo atual indispon\xEDvel \u2014 ${escapeHtml6(existing.label)}</option>` : "";
63129
+ const items = eligible.map(
63130
+ (item) => `<option value="${escapeHtml6(item.tbId)}"${item.tbId === existing?.tbId ? " selected" : ""}>${escapeHtml6(item.label)}</option>`
63131
+ ).join("");
63132
+ return `<select id="wet-${code.toLowerCase()}-device" data-slot="${code}" aria-label="Equipamento ${code}">
63133
+ <option value="">Nenhum</option>${missing}${items}
63134
+ </select>`;
63135
+ };
63136
+ const binding = (items, code) => items.find((item) => item.code === code);
63137
+ const labelInput = (code, existing) => `<input id="wet-${code.toLowerCase()}-label" data-label="${code}" aria-label="R\xF3tulo ${code}" value="${escapeHtml6(existing?.label || "")}" placeholder="R\xF3tulo opcional">`;
63138
+ this.config.container.innerHTML = `
63139
+ <section class="wet-tab">
63140
+ <p>Configure as bombas e o solenoide associados a este po\xE7o. O mesmo equipamento pode ser usado em outros po\xE7os.</p>
63141
+ <div class="wet-grid">
63142
+ <label for="wet-b1-device">Bomba B1</label>${options("BOMBA_POCO", "B1", binding(this.bindings.pumps, "B1"))}${labelInput("B1", binding(this.bindings.pumps, "B1"))}
63143
+ <label for="wet-b2-device">Bomba B2</label>${options("BOMBA_POCO", "B2", binding(this.bindings.pumps, "B2"))}${labelInput("B2", binding(this.bindings.pumps, "B2"))}
63144
+ <label for="wet-s-device">Solenoide S</label>${options("SOLENOIDE", "S", binding(this.bindings.valves, "S"))}${labelInput("S", binding(this.bindings.valves, "S"))}
63145
+ </div>
63146
+ <p id="wet-message" class="wet-message" role="status" aria-live="polite"></p>
63147
+ <button type="button" id="wet-save" ${this.loaded ? "" : "disabled"}>Salvar v\xEDnculos</button>
63148
+ </section>
63149
+ <style>
63150
+ .wet-tab{padding:24px;color:#374151}.wet-grid{display:grid;grid-template-columns:130px minmax(180px,1fr) minmax(180px,1fr);gap:12px;align-items:center}
63151
+ .wet-grid label{font-weight:600}.wet-grid select,.wet-grid input{box-sizing:border-box;width:100%;min-height:38px;padding:7px 9px;border:1px solid #d1d5db;border-radius:6px;background:white}
63152
+ #wet-save{margin-top:18px;padding:9px 16px;border:0;border-radius:6px;background:#2563eb;color:white;font-weight:600;cursor:pointer}
63153
+ #wet-save:disabled{opacity:.6;cursor:wait}.wet-message{min-height:20px;margin:12px 0 0}.wet-message.wet-error,.wet-error{color:#b91c1c}.wet-message.wet-success{color:#15803d}.wet-state{text-align:center;padding:30px;color:#6b7280}
63154
+ </style>`;
63155
+ this.config.container.querySelectorAll("[data-slot]").forEach((select) => {
63156
+ select.addEventListener("change", () => {
63157
+ const slot = select.dataset.slot || "";
63158
+ const selected = this.equipment.find((item) => item.tbId === select.value);
63159
+ const label = this.config.container.querySelector(`[data-label="${slot}"]`);
63160
+ if (label && selected) label.value = selected.label;
63161
+ if (label && !selected) label.value = "";
63162
+ this.showMessage("");
63163
+ });
63164
+ });
63165
+ this.config.container.querySelector("#wet-save")?.addEventListener("click", () => {
63166
+ void this.save();
63167
+ });
63168
+ }
63169
+ async save() {
63170
+ const container = this.config.container;
63171
+ const saveButton = container.querySelector("#wet-save");
63172
+ if (!this.loaded || !saveButton) return;
63173
+ const b1 = container.querySelector("#wet-b1-device")?.value || "";
63174
+ const b2 = container.querySelector("#wet-b2-device")?.value || "";
63175
+ const solenoid = container.querySelector("#wet-s-device")?.value || "";
63176
+ if (b1 && b1 === b2) {
63177
+ this.showMessage("Selecione bombas diferentes para B1 e B2.", true);
63178
+ return;
63179
+ }
63180
+ const selected = [
63181
+ ...b1 ? [{ id: b1, profile: "BOMBA_POCO", code: "B1" }] : [],
63182
+ ...b2 ? [{ id: b2, profile: "BOMBA_POCO", code: "B2" }] : [],
63183
+ ...solenoid ? [{ id: solenoid, profile: "SOLENOIDE", code: "S" }] : []
63184
+ ];
63185
+ for (const item of selected) {
63186
+ const current = item.code === "S" ? this.bindings.valves.find((binding) => binding.code === item.code) : this.bindings.pumps.find((binding) => binding.code === item.code);
63187
+ const unchangedUnavailableBinding = current?.tbId === item.id && !this.equipment.some((equipment) => equipment.tbId === item.id);
63188
+ if (!unchangedUnavailableBinding && !this.equipment.some((equipment) => equipment.tbId === item.id && equipment.profile === item.profile)) {
63189
+ this.showMessage(`O equipamento selecionado para ${item.code} n\xE3o pertence ao cat\xE1logo v\xE1lido.`, true);
63190
+ return;
63191
+ }
63192
+ }
63193
+ const oldBinding = (code) => code === "S" ? this.bindings.valves.find((item) => item.code === code) : this.bindings.pumps.find((item) => item.code === code);
63194
+ const createBinding = (id, code) => {
63195
+ if (!id) return null;
63196
+ const current = oldBinding(code);
63197
+ const equipment = this.equipment.find((item) => item.tbId === id);
63198
+ const label = container.querySelector(`[data-label="${code}"]`)?.value.trim() || equipment?.label || current?.label || id;
63199
+ return {
63200
+ tbId: id,
63201
+ ...equipment?.gcdrId || (current?.tbId === id ? current.gcdrId : void 0) ? { gcdrId: equipment?.gcdrId || current?.gcdrId } : {},
63202
+ code,
63203
+ label,
63204
+ ...code !== "S" && current?.tbId === id && current.thresholdW !== void 0 ? { thresholdW: current.thresholdW } : {}
63205
+ };
63206
+ };
63207
+ const bindings = {
63208
+ pumps: [createBinding(b1, "B1"), createBinding(b2, "B2")].filter((item) => !!item),
63209
+ valves: [createBinding(solenoid, "S")].filter((item) => !!item)
63210
+ };
63211
+ saveButton.disabled = true;
63212
+ saveButton.textContent = "Salvando\u2026";
63213
+ this.showMessage("");
63214
+ try {
63215
+ const response = await fetch(
63216
+ `${this.config.tbBaseUrl}/api/plugins/telemetry/DEVICE/${encodeURIComponent(this.config.deviceId)}/attributes/SERVER_SCOPE`,
63217
+ {
63218
+ method: "POST",
63219
+ headers: this.headers(),
63220
+ body: JSON.stringify({ pumpBindings: bindings })
63221
+ }
63222
+ );
63223
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
63224
+ this.bindings = bindings;
63225
+ this.render();
63226
+ this.showMessage("V\xEDnculos salvos com sucesso.", false, true);
63227
+ } catch (error) {
63228
+ this.showMessage(`Falha ao salvar os v\xEDnculos: ${this.errorMessage(error)}`, true);
63229
+ } finally {
63230
+ const button = container.querySelector("#wet-save");
63231
+ if (button) {
63232
+ button.disabled = false;
63233
+ button.textContent = "Salvar v\xEDnculos";
63234
+ }
63235
+ }
63236
+ }
63237
+ showMessage(message, isError = false, isSuccess = false) {
63238
+ const element = this.config.container.querySelector("#wet-message");
63239
+ if (!element) return;
63240
+ element.textContent = message;
63241
+ element.classList.toggle("wet-error", isError);
63242
+ element.classList.toggle("wet-success", isSuccess);
63243
+ }
63244
+ errorMessage(error) {
63245
+ return error instanceof Error ? error.message : String(error);
63246
+ }
63247
+ };
63248
+
62968
63249
  // src/services/freshdesk/FreshdeskClient.ts
62969
63250
  var FreshdeskClient_exports = {};
62970
63251
  __export(FreshdeskClient_exports, {
@@ -63881,10 +64162,10 @@ ${this._formatFileSize(f.size)} \xB7 ${f.type || "arquivo"}`;
63881
64162
  // Styles
63882
64163
  // ==========================================================================
63883
64164
  injectStyles() {
63884
- const STYLE_ID20 = "myio-tickets-tab-styles";
63885
- if (document.getElementById(STYLE_ID20)) return;
64165
+ const STYLE_ID23 = "myio-tickets-tab-styles";
64166
+ if (document.getElementById(STYLE_ID23)) return;
63886
64167
  const style = document.createElement("style");
63887
- style.id = STYLE_ID20;
64168
+ style.id = STYLE_ID23;
63888
64169
  style.textContent = `
63889
64170
  /* ===== TicketsTab layout ===== */
63890
64171
  .ct-tab {
@@ -64566,7 +64847,7 @@ async function createInputDateRangePickerInsideDIV(params) {
64566
64847
  placeholder = "Clique para selecionar per\xEDodo",
64567
64848
  pickerOptions = {},
64568
64849
  classNames = {},
64569
- injectStyles: injectStyles23 = true,
64850
+ injectStyles: injectStyles26 = true,
64570
64851
  showHelper = true
64571
64852
  } = params;
64572
64853
  validateId(containerId, "containerId");
@@ -64575,7 +64856,7 @@ async function createInputDateRangePickerInsideDIV(params) {
64575
64856
  if (!container) {
64576
64857
  throw new Error(`[createInputDateRangePickerInsideDIV] Container '#${containerId}' not found`);
64577
64858
  }
64578
- if (injectStyles23) {
64859
+ if (injectStyles26) {
64579
64860
  injectPremiumStyles();
64580
64861
  }
64581
64862
  let inputEl = document.getElementById(inputId);
@@ -64714,6 +64995,7 @@ var SettingsModalView = class _SettingsModalView {
64714
64995
  // Exclusão de Grupos tab
64715
64996
  exclusionGroupsTab = null;
64716
64997
  deviceProfileTab = null;
64998
+ wellEquipmentTab = null;
64717
64999
  currentTab = "general";
64718
65000
  currentUser = null;
64719
65001
  permissions = null;
@@ -64762,6 +65044,9 @@ var SettingsModalView = class _SettingsModalView {
64762
65044
  canEditIdentifier() {
64763
65045
  return this.isSuperAdmin() || this.config.holdingAdmin === true;
64764
65046
  }
65047
+ isWellEquipmentDevice() {
65048
+ return ["CISTERNA", "CISTERNA_ENTRADA"].includes(String(this.config.deviceProfile || "").toUpperCase());
65049
+ }
64765
65050
  render(initialData) {
64766
65051
  this.originalActiveElement = document.activeElement;
64767
65052
  document.body.appendChild(this.container);
@@ -64796,6 +65081,9 @@ var SettingsModalView = class _SettingsModalView {
64796
65081
  this.initChamadosTab();
64797
65082
  this.initExclusionGroupsTab();
64798
65083
  this.initDeviceProfileTab();
65084
+ if (this.isWellEquipmentDevice() && this.isSuperAdmin()) {
65085
+ this.initWellEquipmentTab();
65086
+ }
64799
65087
  if (this.config.isGateway && this.isSuperAdmin()) {
64800
65088
  this.bindIncidentsTabEvents();
64801
65089
  this.initIncidentsDateRange();
@@ -65049,6 +65337,30 @@ var SettingsModalView = class _SettingsModalView {
65049
65337
  container.innerHTML = '<p style="color:#dc3545;padding:20px;text-align:center;">Erro ao carregar perfil do dispositivo</p>';
65050
65338
  }
65051
65339
  }
65340
+ async initWellEquipmentTab() {
65341
+ const container = this.modal.querySelector("#well-equipment-tab-content");
65342
+ if (!container || !this.isWellEquipmentDevice() || !this.isSuperAdmin()) return;
65343
+ const customerId = this.config.customerId || window.MyIOUtils?.customerTB_ID;
65344
+ const { deviceId, jwtToken, tbBaseUrl, deviceProfile } = this.config;
65345
+ if (!deviceId || !jwtToken || !customerId) {
65346
+ container.innerHTML = '<p class="wet-state wet-error" role="alert">Configura\xE7\xE3o de equipamentos indispon\xEDvel: deviceId, autentica\xE7\xE3o ou customerId n\xE3o informado.</p>';
65347
+ return;
65348
+ }
65349
+ try {
65350
+ this.wellEquipmentTab = new WellEquipmentTab({
65351
+ container,
65352
+ deviceId,
65353
+ deviceProfile: String(deviceProfile || ""),
65354
+ customerId,
65355
+ jwtToken,
65356
+ tbBaseUrl: tbBaseUrl ?? window.location.origin
65357
+ });
65358
+ await this.wellEquipmentTab.init();
65359
+ } catch (error) {
65360
+ console.error("[SettingsModalView] Failed to initialize WellEquipmentTab:", error);
65361
+ container.innerHTML = '<p class="wet-state wet-error" role="alert">Erro ao carregar configura\xE7\xF5es de equipamentos do po\xE7o.</p>';
65362
+ }
65363
+ }
65052
65364
  // RFC-0104 / RFC-0180 / RFC-0198: Switch between tabs
65053
65365
  switchTab(tab) {
65054
65366
  this.currentTab = tab;
@@ -65062,12 +65374,14 @@ var SettingsModalView = class _SettingsModalView {
65062
65374
  const chamadosContent = this.modal.querySelector("#chamados-tab-content");
65063
65375
  const exclusionGroupsContent = this.modal.querySelector("#exclusion-groups-tab-content");
65064
65376
  const deviceProfileContent = this.modal.querySelector("#device-profile-tab-content");
65377
+ const wellEquipmentContent = this.modal.querySelector("#well-equipment-tab-content");
65065
65378
  const incidentsContent = this.modal.querySelector("#incidents-tab-content");
65066
65379
  if (generalContent) generalContent.style.display = tab === "general" ? "block" : "none";
65067
65380
  if (annotationsContent) annotationsContent.style.display = tab === "annotations" ? "block" : "none";
65068
65381
  if (alarmsContent) alarmsContent.style.display = tab === "alarms" ? "block" : "none";
65069
65382
  if (chamadosContent) chamadosContent.style.display = tab === "chamados" ? "block" : "none";
65070
65383
  if (deviceProfileContent) deviceProfileContent.style.display = tab === "device-profile" ? "block" : "none";
65384
+ if (wellEquipmentContent) wellEquipmentContent.style.display = tab === "well-equipment" ? "block" : "none";
65071
65385
  if (exclusionGroupsContent) exclusionGroupsContent.style.display = tab === "exclusion-groups" ? "block" : "none";
65072
65386
  if (incidentsContent) incidentsContent.style.display = tab === "incidents" ? "block" : "none";
65073
65387
  const saveBtn = this.modal.querySelector(".btn-save");
@@ -65098,6 +65412,10 @@ var SettingsModalView = class _SettingsModalView {
65098
65412
  this.deviceProfileTab.destroy();
65099
65413
  this.deviceProfileTab = null;
65100
65414
  }
65415
+ if (this.wellEquipmentTab) {
65416
+ this.wellEquipmentTab.destroy();
65417
+ this.wellEquipmentTab = null;
65418
+ }
65101
65419
  if (this.incidentsDateRangeController) {
65102
65420
  this.incidentsDateRangeController.destroy();
65103
65421
  this.incidentsDateRangeController = null;
@@ -65277,6 +65595,13 @@ var SettingsModalView = class _SettingsModalView {
65277
65595
  </svg>
65278
65596
  Perfil de Dispositivo
65279
65597
  </button>` : ""}
65598
+ ${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="well-equipment">
65599
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
65600
+ <path d="M4 18h16M6 18V8l6-4 6 4v10M9 18v-5h6v5"></path>
65601
+ <path d="M12 4v4"></path>
65602
+ </svg>
65603
+ Equipamentos do Po\xE7o
65604
+ </button>` : ""}
65280
65605
  <!-- RFC-0232: Incidentes (interpola\xE7\xE3o) \u2014 central + admin MyIO only -->
65281
65606
  ${this.config.isGateway && this.isSuperAdmin() ? `<button type="button" class="modal-tab" data-tab="incidents">
65282
65607
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
@@ -65331,6 +65656,9 @@ var SettingsModalView = class _SettingsModalView {
65331
65656
  <p>Carregando perfil do dispositivo...</p>
65332
65657
  </div>
65333
65658
  </div>
65659
+ ${this.isWellEquipmentDevice() && this.isSuperAdmin() ? `<div id="well-equipment-tab-content" class="tab-content" style="display:none;">
65660
+ <p class="wet-state">Carregando v\xEDnculos e equipamentos\u2026</p>
65661
+ </div>` : ""}
65334
65662
  <!-- RFC-0232: Incidentes (interpola\xE7\xE3o) Tab Content \u2014 central + admin MyIO only.
65335
65663
  Rendered synchronously (data comes pre-fetched via config.interpolatedSlots,
65336
65664
  same as getGatewayInfoHTML() \u2014 no async loading state needed here). -->
@@ -65478,8 +65806,8 @@ var SettingsModalView = class _SettingsModalView {
65478
65806
  const segmentEl = this.modal.querySelector("#segment");
65479
65807
  const activityEl = this.modal.querySelector("#activity");
65480
65808
  if (!segmentEl || !activityEl) return;
65481
- const esc9 = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
65482
- const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc9(v)}"${v === selected ? " selected" : ""}>${esc9(v)}</option>`).join("");
65809
+ const esc10 = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
65810
+ const options = (values, selected, placeholder) => `<option value="">${placeholder}</option>` + values.map((v) => `<option value="${esc10(v)}"${v === selected ? " selected" : ""}>${esc10(v)}</option>`).join("");
65483
65811
  const catalog = await loadStoreSegmentCatalog(this.config.segmentCatalog);
65484
65812
  const savedSegment = String(saved.segment || "");
65485
65813
  const savedActivity = String(saved.activity || "");
@@ -71962,7 +72290,7 @@ var WelcomeModalView = class _WelcomeModalView {
71962
72290
  if (this.metaTipEl) this.metaTipEl.style.display = "none";
71963
72291
  }
71964
72292
  buildMetaTipHtml(type, card) {
71965
- const esc9 = _WelcomeModalView.escapeMetaHtml;
72293
+ const esc10 = _WelcomeModalView.escapeMetaHtml;
71966
72294
  const chip = _WelcomeModalView.metaChip;
71967
72295
  const meta = card.metaCounts || {};
71968
72296
  const details = card.metaDetails || {};
@@ -71972,7 +72300,7 @@ var WelcomeModalView = class _WelcomeModalView {
71972
72300
  ).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
71973
72301
  const frame = (icon2, label, body) => `<div class="myio-welcome-meta-tip__header">
71974
72302
  <span class="myio-welcome-meta-tip__icon">${icon2}</span>
71975
- <span class="myio-welcome-meta-tip__title">${label} (${esc9(card.title)})</span>
72303
+ <span class="myio-welcome-meta-tip__title">${label} (${esc10(card.title)})</span>
71976
72304
  <span class="myio-welcome-meta-tip__timestamp">${stamp}</span>
71977
72305
  <button type="button" class="myio-welcome-meta-tip__close" title="Fechar">\u2715</button>
71978
72306
  </div>
@@ -72000,8 +72328,8 @@ var WelcomeModalView = class _WelcomeModalView {
72000
72328
  const chips = Object.entries(byState).map(([s, n]) => chip(`${s}: ${n}`)).join("");
72001
72329
  const rows = alarms.slice(0, 10).map(
72002
72330
  (a) => row(
72003
- esc9(a.deviceName ? `${a.deviceName} \u2014 ${a.title || "Alarme"}` : a.title || "Alarme"),
72004
- [a.severity, a.state].filter(Boolean).map(esc9).join(" \xB7 ")
72331
+ esc10(a.deviceName ? `${a.deviceName} \u2014 ${a.title || "Alarme"}` : a.title || "Alarme"),
72332
+ [a.severity, a.state].filter(Boolean).map(esc10).join(" \xB7 ")
72005
72333
  )
72006
72334
  ).join("");
72007
72335
  return frame(
@@ -72025,7 +72353,7 @@ var WelcomeModalView = class _WelcomeModalView {
72025
72353
  const rows = annotations.slice(0, 10).map((a) => {
72026
72354
  const when = a.createdAt ? new Date(a.createdAt).toLocaleDateString("pt-BR") : "";
72027
72355
  const text2 = a.text.length > 90 ? `${a.text.slice(0, 90)}\u2026` : a.text;
72028
- return row(esc9(a.deviceLabel || "Dispositivo"), `${esc9(text2)}${when ? ` \xB7 ${esc9(when)}` : ""}`);
72356
+ return row(esc10(a.deviceLabel || "Dispositivo"), `${esc10(text2)}${when ? ` \xB7 ${esc10(when)}` : ""}`);
72029
72357
  }).join("");
72030
72358
  return frame(
72031
72359
  "\u{1F4CB}",
@@ -72036,7 +72364,7 @@ var WelcomeModalView = class _WelcomeModalView {
72036
72364
  if (type === "users") {
72037
72365
  if (meta.users === null) return frame("\u{1F465}", "Usu\xE1rios", loadingBody);
72038
72366
  const users = details.users || [];
72039
- const rows = users.slice(0, 10).map((u) => row(esc9(u.name), esc9(u.email || ""))).join("");
72367
+ const rows = users.slice(0, 10).map((u) => row(esc10(u.name), esc10(u.email || ""))).join("");
72040
72368
  return frame(
72041
72369
  "\u{1F465}",
72042
72370
  "Usu\xE1rios",
@@ -76256,10 +76584,10 @@ function render(container, modalId, state6) {
76256
76584
  <div class="alarm-list">
76257
76585
  ${state6.alarms.map((a) => `
76258
76586
  <div class="alarm-row">
76259
- <div class="alarm-title">${escapeHtml6(a.title || a.id)}</div>
76260
- <div class="alarm-meta">${escapeHtml6(a.customerName || "")}</div>
76261
- <div class="alarm-meta">${escapeHtml6(a.severity)}</div>
76262
- <div class="alarm-meta">${escapeHtml6(a.state)}</div>
76587
+ <div class="alarm-title">${escapeHtml7(a.title || a.id)}</div>
76588
+ <div class="alarm-meta">${escapeHtml7(a.customerName || "")}</div>
76589
+ <div class="alarm-meta">${escapeHtml7(a.severity)}</div>
76590
+ <div class="alarm-meta">${escapeHtml7(a.state)}</div>
76263
76591
  <div class="alarm-meta">${formatDate2(a.lastOccurrence, state6.locale, true)}</div>
76264
76592
  </div>
76265
76593
  `).join("")}
@@ -76446,7 +76774,7 @@ function buildBars(data, order, colors2) {
76446
76774
  const pct = Math.round(value / maxVal * 100);
76447
76775
  return `
76448
76776
  <div class="bar-row">
76449
- <span class="bar-label">${escapeHtml6(String(key))}</span>
76777
+ <span class="bar-label">${escapeHtml7(String(key))}</span>
76450
76778
  <div class="bar-track"><div class="bar-fill" style="width:${pct}%"></div></div>
76451
76779
  <span class="bar-value">${value}</span>
76452
76780
  </div>
@@ -76476,7 +76804,7 @@ function toTime(value) {
76476
76804
  const parsed = new Date(value).getTime();
76477
76805
  return Number.isNaN(parsed) ? 0 : parsed;
76478
76806
  }
76479
- function escapeHtml6(text2) {
76807
+ function escapeHtml7(text2) {
76480
76808
  const div = document.createElement("div");
76481
76809
  div.textContent = text2 || "";
76482
76810
  return div.innerHTML;
@@ -76663,8 +76991,8 @@ function render2(container, modalId, state6) {
76663
76991
  </div>
76664
76992
  ${state6.devices.map((d) => `
76665
76993
  <div class="device-table-row">
76666
- <div class="col-name">${escapeHtml7(d.name)}</div>
76667
- <div class="col-customer">${escapeHtml7(d.customerName)}</div>
76994
+ <div class="col-name">${escapeHtml8(d.name)}</div>
76995
+ <div class="col-customer">${escapeHtml8(d.customerName)}</div>
76668
76996
  <div class="col-status">
76669
76997
  <span class="status-badge" style="background: ${STATUS_COLORS3[d.status] || "#6b7280"}20; color: ${STATUS_COLORS3[d.status] || "#6b7280"};">
76670
76998
  ${STATUS_LABELS5[d.status] || d.status}
@@ -76911,7 +77239,7 @@ function buildHorizontalBarChart(devices, metric, unit, colors2, getColor, inver
76911
77239
  const displayValue = metric === "availability" ? value.toFixed(1) : value.toFixed(metric === "mttr" ? 1 : 0);
76912
77240
  return `
76913
77241
  <div class="bar-row">
76914
- <span class="bar-label" title="${escapeHtml7(d.name)}">${escapeHtml7(d.name)}</span>
77242
+ <span class="bar-label" title="${escapeHtml8(d.name)}">${escapeHtml8(d.name)}</span>
76915
77243
  <div class="bar-track">
76916
77244
  <div class="bar-fill" style="width:${pct}%; background:${color};"></div>
76917
77245
  </div>
@@ -76942,7 +77270,7 @@ function formatDate3(value, locale) {
76942
77270
  if (isNaN(d.getTime())) return "-";
76943
77271
  return d.toLocaleDateString(locale, { day: "2-digit", month: "2-digit", year: "numeric" });
76944
77272
  }
76945
- function escapeHtml7(text2) {
77273
+ function escapeHtml8(text2) {
76946
77274
  const div = document.createElement("div");
76947
77275
  div.textContent = text2 || "";
76948
77276
  return div.innerHTML;
@@ -78835,8 +79163,8 @@ var SettingsController = class {
78835
79163
  // RFC-0076: Pass deviceProfile for 3F_MEDIDOR fallback
78836
79164
  customerName: params.customerName,
78837
79165
  // RFC-0077: Pass customer/shopping name for display
78838
- customerId: params.customerId,
78839
- // RFC-0080: Pass customerId for fetching GLOBAL mapInstantaneousPower
79166
+ customerId: params.customerId || window.MyIOUtils?.customerTB_ID || void 0,
79167
+ // Shared customer context for settings tabs
78840
79168
  deviceId: params.deviceId,
78841
79169
  // RFC-0077: Pass deviceId for Power Limits feature
78842
79170
  jwtToken: params.jwtToken,
@@ -79331,15 +79659,16 @@ function timelineHTML(history, now, kind) {
79331
79659
  function pumpCardHTML(p, now, images, focusWellId) {
79332
79660
  const on = isActive(p.history);
79333
79661
  const known = Array.isArray(p.history);
79662
+ const stateClass = !known ? "is-unknown" : on ? "is-on" : "is-off";
79334
79663
  const since = stateSince(p.history);
79335
- const { activeMs, starts } = dayStats(p.history, now);
79336
- const power = on ? typeof p.powerKw === "number" ? fmtKw(p.powerKw) : "\u2014" : fmtKw(0).replace(",0", "");
79664
+ const { activeMs, starts } = dayStats(p.history || [], now);
79665
+ const power = !known ? "\u2014" : on ? typeof p.powerKw === "number" ? fmtKw(p.powerKw) : "\u2014" : fmtKw(0).replace(",0", "");
79337
79666
  const hasLevel = typeof p.wellLevelMca === "number";
79338
79667
  const hasPerc = typeof p.wellPercentage === "number";
79339
79668
  const pct = hasPerc ? Math.round(Math.max(0, Math.min(1, p.wellPercentage)) * 100) : null;
79340
79669
  const meta = [p.identifier, p.wellLabel].filter(Boolean).map(escapeHtml2).join(" \xB7 ");
79341
79670
  return `
79342
- <div class="myio-wp-card ${on ? "is-on" : "is-off"} ${focusWellId && p.wellId === focusWellId ? "focus" : ""}" data-code="${escapeHtml2(p.code)}">
79671
+ <div class="myio-wp-card ${stateClass} ${focusWellId && p.wellId === focusWellId ? "focus" : ""}" data-code="${escapeHtml2(p.code)}">
79343
79672
  <div class="myio-wp-top">
79344
79673
  <img class="myio-wp-img" src="${escapeHtml2(images.pump)}" alt="">
79345
79674
  <div>
@@ -79349,25 +79678,26 @@ function pumpCardHTML(p, now, images, focusWellId) {
79349
79678
  <span class="myio-wp-state ${!known ? "unk" : on ? "on" : "off"}">${PUMP_SVG}${!known ? "SEM LEITURA" : on ? "LIGADA" : "DESLIGADA"}</span>
79350
79679
  </div>
79351
79680
  <div class="myio-wp-grid">
79352
- <div class="myio-wp-cell"><small>${on ? "Ligada desde" : "Desligada desde"}</small><span>${formatClock(since)}</span></div>
79353
- <div class="myio-wp-cell"><small>Tempo ligada hoje</small><span>${formatDuration2(activeMs)}</span></div>
79354
- <div class="myio-wp-cell"><small>Acionamentos hoje</small><span>${starts}</span></div>
79681
+ <div class="myio-wp-cell"><small>${known ? on ? "Ligada desde" : "Desligada desde" : "Estado desde"}</small><span>${formatClock(since)}</span></div>
79682
+ <div class="myio-wp-cell"><small>Tempo ligada hoje</small><span>${known ? formatDuration2(activeMs) : "\u2014"}</span></div>
79683
+ <div class="myio-wp-cell"><small>Acionamentos hoje</small><span>${known ? starts : "\u2014"}</span></div>
79355
79684
  <div class="myio-wp-cell"><small>Pot\xEAncia atual</small><span>${power}</span></div>
79356
79685
  <div class="myio-wp-cell"><small>Estado h\xE1</small><span>${since ? formatDuration2(now - since) : "\u2014"}</span></div>
79357
79686
  <div class="myio-wp-cell"><small>N\xEDvel do po\xE7o</small><span>${hasLevel ? `${(p.wellLevelMca / 100).toFixed(2).replace(".", ",")} M.C.A` : "\u2014"}</span></div>
79358
79687
  </div>
79359
79688
  ${pct !== null ? `<div class="myio-wp-level">${escapeHtml2(p.wellLabel || "Po\xE7o")}<div class="myio-wp-bar"><i style="width:${pct}%"></i></div>${pct}%</div>` : ""}
79360
- ${timelineHTML(p.history, now, "pump")}
79689
+ ${timelineHTML(p.history || [], now, "pump")}
79361
79690
  </div>`;
79362
79691
  }
79363
79692
  function valveCardHTML(v, now, images) {
79364
79693
  const open = isActive(v.history);
79365
79694
  const known = Array.isArray(v.history);
79695
+ const stateClass = !known ? "is-unknown" : open ? "is-open" : "is-closed";
79366
79696
  const since = stateSince(v.history);
79367
- const { activeMs, starts } = dayStats(v.history, now);
79697
+ const { activeMs, starts } = dayStats(v.history || [], now);
79368
79698
  const meta = [v.identifier, v.description].filter(Boolean).map(escapeHtml2).join(" \xB7 ");
79369
79699
  return `
79370
- <div class="myio-wp-card myio-wp-valve ${open ? "is-open" : "is-closed"}" data-code="${escapeHtml2(v.code)}">
79700
+ <div class="myio-wp-card myio-wp-valve ${stateClass}" data-code="${escapeHtml2(v.code)}">
79371
79701
  <img class="myio-wp-img" src="${escapeHtml2(images.valve)}" alt="">
79372
79702
  <div style="display:flex;flex-direction:column;gap:10px;min-width:0">
79373
79703
  <div class="myio-wp-top">
@@ -79378,11 +79708,11 @@ function valveCardHTML(v, now, images) {
79378
79708
  <span class="myio-wp-state ${!known ? "unk" : open ? "open" : "closed"}">${VALVE_SVG}${!known ? "SEM LEITURA" : open ? "ABERTA" : "FECHADA"}</span>
79379
79709
  </div>
79380
79710
  <div class="myio-wp-grid">
79381
- <div class="myio-wp-cell"><small>${open ? "Aberta desde" : "Fechada desde"}</small><span>${formatClock(since)}</span></div>
79382
- <div class="myio-wp-cell"><small>Tempo aberta hoje</small><span>${formatDuration2(activeMs)}</span></div>
79383
- <div class="myio-wp-cell"><small>Aberturas hoje</small><span>${starts}</span></div>
79711
+ <div class="myio-wp-cell"><small>${known ? open ? "Aberta desde" : "Fechada desde" : "Estado desde"}</small><span>${formatClock(since)}</span></div>
79712
+ <div class="myio-wp-cell"><small>Tempo aberta hoje</small><span>${known ? formatDuration2(activeMs) : "\u2014"}</span></div>
79713
+ <div class="myio-wp-cell"><small>Aberturas hoje</small><span>${known ? starts : "\u2014"}</span></div>
79384
79714
  </div>
79385
- ${timelineHTML(v.history, now, "valve")}
79715
+ ${timelineHTML(v.history || [], now, "valve")}
79386
79716
  </div>
79387
79717
  </div>`;
79388
79718
  }
@@ -79396,17 +79726,17 @@ function renderWellPumpsBodyHTML(data, opts = {}) {
79396
79726
  const valves = data?.valves || [];
79397
79727
  if (!pumps.length && !valves.length) return `<div class="myio-wp-empty">Nenhuma bomba ou solenoide vinculada a este po\xE7o.</div>`;
79398
79728
  const onPumps = pumps.filter((p) => isActive(p.history));
79729
+ const unknownPumpCount = pumps.filter((p) => !Array.isArray(p.history)).length;
79399
79730
  const knownPower = onPumps.filter((p) => typeof p.powerKw === "number");
79400
- const totalPower = knownPower.length ? fmtKw(knownPower.reduce((s, p) => s + p.powerKw, 0)) : onPumps.length ? "\u2014" : "0 kW";
79731
+ const totalPower = unknownPumpCount > 0 ? knownPower.length ? `${fmtKw(knownPower.reduce((s, p) => s + p.powerKw, 0))} parcial` : "\u2014" : knownPower.length ? fmtKw(knownPower.reduce((s, p) => s + p.powerKw, 0)) : onPumps.length ? "\u2014" : "0 kW";
79401
79732
  const openValves = valves.filter((v) => isActive(v.history));
79402
- const valveKpi = valves.length === 1 ? `<div class="myio-wp-kpi"><small>${escapeHtml2(valves[0].label)}</small><b class="${openValves.length ? "open" : "closed"}">${openValves.length ? "Aberta" : "Fechada"}</b>
79403
- <div class="sub">desde ${formatClock(stateSince(valves[0].history))}</div></div>` : valves.length > 1 ? `<div class="myio-wp-kpi"><small>Solenoides abertas</small><b>${openValves.length} de ${valves.length}</b></div>` : "";
79733
+ const unknownValveCount = valves.filter((v) => !Array.isArray(v.history)).length;
79734
+ const valveKpi = valves.length === 1 ? `<div class="myio-wp-kpi"><small>${escapeHtml2(valves[0].label)}</small><b class="${!Array.isArray(valves[0].history) ? "" : openValves.length ? "open" : "closed"}">${!Array.isArray(valves[0].history) ? "SEM LEITURA" : openValves.length ? "Aberta" : "Fechada"}</b>
79735
+ <div class="sub">${Array.isArray(valves[0].history) ? `desde ${formatClock(stateSince(valves[0].history))}` : "Estado desconhecido"}</div></div>` : valves.length > 1 ? `<div class="myio-wp-kpi"><small>Solenoides abertas</small><b>${openValves.length} de ${valves.length}</b>${unknownValveCount ? `<div class="sub">${unknownValveCount} sem leitura</div>` : ""}</div>` : "";
79736
+ const pumpKpis = pumps.length ? `<div class="myio-wp-kpi"><small>Bombas ligadas</small><b>${onPumps.length} de ${pumps.length}</b>${unknownPumpCount ? `<div class="sub">${unknownPumpCount} sem leitura</div>` : ""}</div>
79737
+ <div class="myio-wp-kpi"><small>Pot\xEAncia total</small><b>${totalPower}</b>${unknownPumpCount && knownPower.length ? `<div class="sub">${unknownPumpCount} sem leitura</div>` : ""}</div>` : "";
79404
79738
  return `
79405
- <div class="myio-wp-kpis">
79406
- <div class="myio-wp-kpi"><small>Bombas ligadas</small><b>${onPumps.length} de ${pumps.length}</b></div>
79407
- <div class="myio-wp-kpi"><small>Pot\xEAncia total</small><b>${totalPower}</b></div>
79408
- ${valveKpi}
79409
- </div>
79739
+ <div class="myio-wp-kpis">${pumpKpis}${valveKpi}</div>
79410
79740
  ${pumps.length ? `<div class="myio-wp-pumps">${pumps.map((p) => pumpCardHTML(p, now, images, opts.focusWellId)).join("")}</div>` : ""}
79411
79741
  ${valves.map((v) => valveCardHTML(v, now, images)).join("")}
79412
79742
  ${opts.footnote ? `<div class="myio-wp-foot">\u24D8 ${escapeHtml2(opts.footnote)}</div>` : ""}`;
@@ -81292,11 +81622,11 @@ function injectDialogStyles() {
81292
81622
  // src/components/premium-modals/dialog/openDialog.ts
81293
81623
  var BASE_Z_INDEX = 10500;
81294
81624
  var openCount = 0;
81295
- function escapeHtml8(value) {
81625
+ function escapeHtml9(value) {
81296
81626
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
81297
81627
  }
81298
81628
  function escapeMessage(value) {
81299
- return escapeHtml8(value).replace(/\n/g, "<br>");
81629
+ return escapeHtml9(value).replace(/\n/g, "<br>");
81300
81630
  }
81301
81631
  function cssWidth(width) {
81302
81632
  if (width == null) return "420px";
@@ -81321,7 +81651,7 @@ function openDialog(params) {
81321
81651
  overlay.style.zIndex = String(BASE_Z_INDEX + openCount);
81322
81652
  const buttonsHtml = params.buttons.map((btn, i) => {
81323
81653
  const variant = btn.variant ?? "secondary";
81324
- return `<button type="button" class="myio-dialog__btn myio-dialog__btn--${variant}" data-index="${i}">${escapeHtml8(btn.label)}</button>`;
81654
+ return `<button type="button" class="myio-dialog__btn myio-dialog__btn--${variant}" data-index="${i}">${escapeHtml9(btn.label)}</button>`;
81325
81655
  }).join("");
81326
81656
  overlay.innerHTML = `
81327
81657
  <div class="myio-dialog${params.modifier ? ` ${params.modifier}` : ""}"
@@ -81331,7 +81661,7 @@ function openDialog(params) {
81331
81661
  <div class="myio-dialog__accent"></div>
81332
81662
  <div class="myio-dialog__header">
81333
81663
  ${params.icon ? `<span class="myio-dialog__icon" aria-hidden="true">${params.icon}</span>` : ""}
81334
- <h3 class="myio-dialog__title" id="${idBase}-title">${escapeHtml8(params.title)}</h3>
81664
+ <h3 class="myio-dialog__title" id="${idBase}-title">${escapeHtml9(params.title)}</h3>
81335
81665
  ${dismissible ? `<button type="button" class="myio-dialog__close" aria-label="Fechar">\u2715</button>` : ""}
81336
81666
  </div>
81337
81667
  <p class="myio-dialog__message" id="${idBase}-message">${escapeMessage(params.message)}</p>
@@ -81427,7 +81757,7 @@ var STYLE_ID9 = "myio-genmodal-styles";
81427
81757
  var FONT_LINK_ID2 = "myio-dialog-font-nunito";
81428
81758
  var BASE_Z_INDEX2 = 10600;
81429
81759
  var openCount2 = 0;
81430
- function escapeHtml9(value) {
81760
+ function escapeHtml10(value) {
81431
81761
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
81432
81762
  }
81433
81763
  function cssSize(v, fallback) {
@@ -81476,12 +81806,15 @@ function injectGenericModalStyles() {
81476
81806
  flex-shrink: 0;
81477
81807
  }
81478
81808
  .myio-genmodal__icon { font-size: 22px; line-height: 1.3; }
81479
- .myio-genmodal__title {
81809
+ /* h3.\u2026 + prefixo do overlay: vence o "h3" global do ThingsBoard (mat-typography) */
81810
+ .myio-genmodal-overlay h3.myio-genmodal__title {
81480
81811
  flex: 1;
81481
81812
  margin: 0;
81813
+ font-family: inherit;
81482
81814
  font-size: 18px;
81483
81815
  font-weight: 700;
81484
81816
  line-height: 1.35;
81817
+ letter-spacing: normal;
81485
81818
  }
81486
81819
  .myio-genmodal__close {
81487
81820
  border: none;
@@ -81577,17 +81910,17 @@ function openGenericModal(params) {
81577
81910
  overlay.style.zIndex = String(BASE_Z_INDEX2 + openCount2);
81578
81911
  const buttonsHtml = buttons.map((btn, i) => {
81579
81912
  const variant = btn.variant ?? "secondary";
81580
- return `<button type="button" class="myio-genmodal__btn myio-genmodal__btn--${variant}" data-index="${i}">${escapeHtml9(btn.label)}</button>`;
81913
+ return `<button type="button" class="myio-genmodal__btn myio-genmodal__btn--${variant}" data-index="${i}">${escapeHtml10(btn.label)}</button>`;
81581
81914
  }).join("");
81582
81915
  overlay.innerHTML = `
81583
- <div class="myio-genmodal${params.className ? ` ${escapeHtml9(params.className)}` : ""}"
81916
+ <div class="myio-genmodal${params.className ? ` ${escapeHtml10(params.className)}` : ""}"
81584
81917
  role="dialog" aria-modal="true"
81585
81918
  aria-labelledby="${idBase}-title"
81586
81919
  style="width:${cssSize(params.width, "560px")}">
81587
81920
  <div class="myio-genmodal__accent"></div>
81588
81921
  <div class="myio-genmodal__header">
81589
81922
  ${params.icon ? `<span class="myio-genmodal__icon" aria-hidden="true">${params.icon}</span>` : ""}
81590
- <h3 class="myio-genmodal__title" id="${idBase}-title">${escapeHtml9(params.title)}</h3>
81923
+ <h3 class="myio-genmodal__title" id="${idBase}-title">${escapeHtml10(params.title)}</h3>
81591
81924
  ${dismissible ? `<button type="button" class="myio-genmodal__close" aria-label="Fechar">\u2715</button>` : ""}
81592
81925
  </div>
81593
81926
  <div class="myio-genmodal__body" id="${idBase}-body" style="max-height:${cssSize(params.bodyMaxHeight, "70vh")}"></div>
@@ -84912,7 +85245,7 @@ function openGoalsPanel(params) {
84912
85245
  function sampleHourValue() {
84913
85246
  return isAverage() ? 22 : 150;
84914
85247
  }
84915
- function buildTemplateCsv() {
85248
+ function buildTemplateCsv2() {
84916
85249
  const avg = isAverage();
84917
85250
  const monthlyValue = avg ? 22 : 1e5;
84918
85251
  const dayValue = avg ? 22 : 3200;
@@ -85014,7 +85347,7 @@ function openGoalsPanel(params) {
85014
85347
  rootEl.setAttribute("role", "dialog");
85015
85348
  rootEl.setAttribute("aria-modal", "true");
85016
85349
  container.appendChild(rootEl);
85017
- injectStyles23();
85350
+ injectStyles26();
85018
85351
  rootEl.addEventListener("click", onClick);
85019
85352
  rootEl.addEventListener("change", onChange);
85020
85353
  rootEl.addEventListener("input", onInput);
@@ -85075,7 +85408,7 @@ function openGoalsPanel(params) {
85075
85408
  openImport();
85076
85409
  break;
85077
85410
  case "download-template":
85078
- downloadCsv(buildTemplateCsv(), "template");
85411
+ downloadCsv(buildTemplateCsv2(), "template");
85079
85412
  break;
85080
85413
  case "download-hourly":
85081
85414
  downloadCsv(buildHourlyExampleCsv(), "hourly-example");
@@ -85669,7 +86002,7 @@ ${state6.year}-03-15T08,15`)}">${esc5(state6.csv)}</textarea>
85669
86002
  return "";
85670
86003
  }
85671
86004
  }
85672
- function injectStyles23() {
86005
+ function injectStyles26() {
85673
86006
  const id = "myio-goals-gcdr-styles";
85674
86007
  const prev = document.getElementById(id);
85675
86008
  if (prev) prev.remove();
@@ -92622,13 +92955,13 @@ var COLUMN_SUMMARY_CSS = `
92622
92955
  var _cssInjected2 = false;
92623
92956
  function injectCSS10() {
92624
92957
  if (_cssInjected2 || typeof document === "undefined") return;
92625
- const STYLE_ID20 = "myio-column-summary-tooltip-css";
92626
- if (document.getElementById(STYLE_ID20)) {
92958
+ const STYLE_ID23 = "myio-column-summary-tooltip-css";
92959
+ if (document.getElementById(STYLE_ID23)) {
92627
92960
  _cssInjected2 = true;
92628
92961
  return;
92629
92962
  }
92630
92963
  const style = document.createElement("style");
92631
- style.id = STYLE_ID20;
92964
+ style.id = STYLE_ID23;
92632
92965
  style.textContent = COLUMN_SUMMARY_CSS;
92633
92966
  document.head.appendChild(style);
92634
92967
  _cssInjected2 = true;
@@ -99791,7 +100124,7 @@ function createConsumptionChartWidget(config2) {
99791
100124
  </div>
99792
100125
  `;
99793
100126
  }
99794
- function injectStyles23() {
100127
+ function injectStyles26() {
99795
100128
  if (styleElement) return;
99796
100129
  styleElement = document.createElement("style");
99797
100130
  styleElement.id = `${widgetId}-styles`;
@@ -100305,7 +100638,7 @@ function createConsumptionChartWidget(config2) {
100305
100638
  console.error(`[ConsumptionWidget] Container #${config2.containerId} not found`);
100306
100639
  return;
100307
100640
  }
100308
- injectStyles23();
100641
+ injectStyles26();
100309
100642
  containerElement.innerHTML = renderHTML();
100310
100643
  setupListeners();
100311
100644
  applyCollapseState();
@@ -101759,19 +102092,19 @@ function _updateCoverageHint(topDoc) {
101759
102092
  const deviceCount = data.granularity === "DEVICE" ? data.devices?.length ?? 0 : 0;
101760
102093
  hint.textContent = `\u26A0 Meta incompleta para este dom\xEDnio/ano` + (deviceCount > 0 ? ` \xB7 Por medidor (${deviceCount})` : "") + ` \u2014 passe o mouse para detalhes`;
101761
102094
  tabs.insertAdjacentElement("afterend", hint);
101762
- const esc9 = (s) => String(s ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
102095
+ const esc10 = (s) => String(s ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
101763
102096
  try {
101764
102097
  _coverageDetach = InfoTooltip.attach(hint, () => {
101765
102098
  const d = _getGoalsData(_currentDomain);
101766
102099
  const parts = [];
101767
102100
  if (hasCoverageGaps(d?.coverageGaps)) {
101768
- parts.push(`<p style="margin:0 0 8px;">${esc9(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
102101
+ parts.push(`<p style="margin:0 0 8px;">${esc10(buildCoverageWarningTextPtBR(d?.coverageGaps, "GERAL"))}</p>`);
101769
102102
  }
101770
102103
  (d?.devices || []).forEach((dev) => {
101771
102104
  if (!hasCoverageGaps(dev?.coverageGaps)) return;
101772
102105
  const label = dev.label || dev.code || "medidor";
101773
102106
  parts.push(
101774
- `<p style="margin:0 0 8px;">${esc9(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
102107
+ `<p style="margin:0 0 8px;">${esc10(buildCoverageWarningTextPtBR(dev.coverageGaps, `do medidor ${label}`))}</p>`
101775
102108
  );
101776
102109
  });
101777
102110
  return {
@@ -104599,7 +104932,7 @@ var HUB_CSS = `
104599
104932
  color: var(--myio-brand-700, #7B2FF7);
104600
104933
  }
104601
104934
  `;
104602
- function escapeHtml10(value) {
104935
+ function escapeHtml11(value) {
104603
104936
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
104604
104937
  }
104605
104938
  function resolveTopDocument() {
@@ -104646,7 +104979,7 @@ function openSettingsHubModal(options) {
104646
104979
  <div class="myio-conf-picker__overlay"></div>
104647
104980
  <div class="myio-conf-picker__content">
104648
104981
  <div class="myio-conf-picker__header">
104649
- <h3>\u2699\uFE0F Configura\xE7\xF5es${customerName ? ` \u2014 ${escapeHtml10(customerName)}` : ""}</h3>
104982
+ <h3>\u2699\uFE0F Configura\xE7\xF5es${customerName ? ` \u2014 ${escapeHtml11(customerName)}` : ""}</h3>
104650
104983
  <button class="myio-conf-picker__close" aria-label="Fechar">&times;</button>
104651
104984
  </div>
104652
104985
  <div class="myio-conf-picker__body">${cardsHtml}
@@ -105841,7 +106174,7 @@ function createTariffApiAdapter(client, opts) {
105841
106174
 
105842
106175
  // src/components/pricing-panel/openPricingPanel.ts
105843
106176
  var MODAL_ID3 = "myio-pricing-panel";
105844
- function escapeHtml11(value) {
106177
+ function escapeHtml12(value) {
105845
106178
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
105846
106179
  }
105847
106180
  function resolveTopDocument2() {
@@ -105996,7 +106329,7 @@ function openPricingPanel(params) {
105996
106329
  }
105997
106330
  const initDomain = params.domain || "energy";
105998
106331
  const initCategory = params.category || "lojas";
105999
- const customerOptions = customers.map((c) => `<option value="${escapeHtml11(resolveCustomerId(c))}">${escapeHtml11(c.title)}</option>`).join("");
106332
+ const customerOptions = customers.map((c) => `<option value="${escapeHtml12(resolveCustomerId(c))}">${escapeHtml12(c.title)}</option>`).join("");
106000
106333
  modal.innerHTML = `
106001
106334
  <div class="myio-pricing__overlay"></div>
106002
106335
  <div class="myio-pricing__content">
@@ -106211,9 +106544,9 @@ function openPricingPanel(params) {
106211
106544
  const pushAudit = (rec) => {
106212
106545
  if (rec) auditLog = [rec, ...auditLog];
106213
106546
  };
106214
- const badge = (domain, category) => `<span class="myio-pricing__badge${domain === "water" ? " myio-pricing__badge--water" : ""}">${escapeHtml11(
106547
+ const badge = (domain, category) => `<span class="myio-pricing__badge${domain === "water" ? " myio-pricing__badge--water" : ""}">${escapeHtml12(
106215
106548
  DOMAIN_LABEL[domain]
106216
- )} \xB7 ${escapeHtml11(CATEGORY_LABEL[category])}</span>`;
106549
+ )} \xB7 ${escapeHtml12(CATEGORY_LABEL[category])}</span>`;
106217
106550
  const renderList2 = () => {
106218
106551
  const customerId = customerSel.value;
106219
106552
  const rows = entries.filter((e) => e.customerId === customerId).sort((a, b) => {
@@ -106226,15 +106559,15 @@ function openPricingPanel(params) {
106226
106559
  const boundsKey = b ? `${b.start}__${b.end}` : "";
106227
106560
  return `
106228
106561
  <li class="myio-pricing__item">
106229
- <span class="myio-pricing__item-period">${badge(e.domain, e.category)} ${escapeHtml11(
106562
+ <span class="myio-pricing__item-period">${badge(e.domain, e.category)} ${escapeHtml12(
106230
106563
  formatPeriodLabel(e)
106231
106564
  )}</span>
106232
- <span class="myio-pricing__item-price">${escapeHtml11(formatBRL2(e.pricePerKwh))} ${escapeHtml11(
106565
+ <span class="myio-pricing__item-price">${escapeHtml12(formatBRL2(e.pricePerKwh))} ${escapeHtml12(
106233
106566
  unitLabel(e.domain)
106234
106567
  )}</span>
106235
- <button class="myio-pricing__remove" data-remove="${escapeHtml11(e.domain)}|${escapeHtml11(
106568
+ <button class="myio-pricing__remove" data-remove="${escapeHtml12(e.domain)}|${escapeHtml12(
106236
106569
  e.category
106237
- )}|${escapeHtml11(boundsKey)}" aria-label="Remover" type="button">\u2715</button>
106570
+ )}|${escapeHtml12(boundsKey)}" aria-label="Remover" type="button">\u2715</button>
106238
106571
  </li>`;
106239
106572
  }).join("");
106240
106573
  emptyEl.style.display = rows.length ? "none" : "";
@@ -106333,8 +106666,8 @@ function openPricingPanel(params) {
106333
106666
  kpiEl.innerHTML = cards.map(
106334
106667
  (c) => `
106335
106668
  <div class="myio-pricing__kpi">
106336
- <div class="myio-pricing__kpi-value">${escapeHtml11(c.value)}</div>
106337
- <div class="myio-pricing__kpi-label">${escapeHtml11(c.label)}</div>
106669
+ <div class="myio-pricing__kpi-value">${escapeHtml12(c.value)}</div>
106670
+ <div class="myio-pricing__kpi-label">${escapeHtml12(c.label)}</div>
106338
106671
  </div>`
106339
106672
  ).join("");
106340
106673
  renderReport();
@@ -106353,11 +106686,11 @@ function openPricingPanel(params) {
106353
106686
  reportBody.innerHTML = rows.length ? rows.map(
106354
106687
  (e) => `
106355
106688
  <tr>
106356
- <td>${escapeHtml11(customerTitle(e.customerId))}</td>
106357
- <td>${escapeHtml11(DOMAIN_LABEL[e.domain])}</td>
106358
- <td>${escapeHtml11(CATEGORY_LABEL[e.category])}</td>
106359
- <td>${escapeHtml11(formatPeriodLabel(e))}</td>
106360
- <td>${escapeHtml11(formatBRL2(e.pricePerKwh))} ${escapeHtml11(unitLabel(e.domain))}</td>
106689
+ <td>${escapeHtml12(customerTitle(e.customerId))}</td>
106690
+ <td>${escapeHtml12(DOMAIN_LABEL[e.domain])}</td>
106691
+ <td>${escapeHtml12(CATEGORY_LABEL[e.category])}</td>
106692
+ <td>${escapeHtml12(formatPeriodLabel(e))}</td>
106693
+ <td>${escapeHtml12(formatBRL2(e.pricePerKwh))} ${escapeHtml12(unitLabel(e.domain))}</td>
106361
106694
  </tr>`
106362
106695
  ).join("") : `<tr><td colspan="5" style="text-align:center;color:var(--myio-text-muted,#6b7280);padding:24px;">Nenhum pre\xE7o para o filtro selecionado.</td></tr>`;
106363
106696
  }
@@ -106367,15 +106700,15 @@ function openPricingPanel(params) {
106367
106700
  return `
106368
106701
  <li class="myio-pricing__history-item">
106369
106702
  <div class="myio-pricing__history-head">
106370
- <span class="myio-pricing__action myio-pricing__action--${escapeHtml11(rec.action)}">${escapeHtml11(
106703
+ <span class="myio-pricing__action myio-pricing__action--${escapeHtml12(rec.action)}">${escapeHtml12(
106371
106704
  rec.action
106372
106705
  )}</span>
106373
106706
  ${badge(rec.domain, rec.category)}
106374
- <span>${escapeHtml11(rec.periodLabel)}${escapeHtml11(priceInfo)}</span>
106707
+ <span>${escapeHtml12(rec.periodLabel)}${escapeHtml12(priceInfo)}</span>
106375
106708
  </div>
106376
- <div class="myio-pricing__history-meta">${escapeHtml11(customerTitle(rec.customerId))} \xB7 ${escapeHtml11(
106709
+ <div class="myio-pricing__history-meta">${escapeHtml12(customerTitle(rec.customerId))} \xB7 ${escapeHtml12(
106377
106710
  rec.by || "\u2014"
106378
- )} \xB7 ${escapeHtml11(fmtTimestamp(rec.at))}</div>
106711
+ )} \xB7 ${escapeHtml12(fmtTimestamp(rec.at))}</div>
106379
106712
  </li>`;
106380
106713
  }).join("");
106381
106714
  historyEmpty.style.display = auditLog.length ? "none" : "";
@@ -114710,6 +115043,1116 @@ function refreshIncidentBadges(opts) {
114710
115043
  });
114711
115044
  }
114712
115045
 
115046
+ // src/components/premium-modals/standard-modal/openStandardModal.ts
115047
+ var STYLE_ID13 = "myio-stdmodal-styles";
115048
+ var FONT_LINK_ID3 = "myio-dialog-font-nunito";
115049
+ var BASE_Z_INDEX3 = 10700;
115050
+ var openCount3 = 0;
115051
+ function escapeHtml13(v) {
115052
+ return String(v).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
115053
+ }
115054
+ function injectStyles13() {
115055
+ if (!document.getElementById(FONT_LINK_ID3)) {
115056
+ const link = document.createElement("link");
115057
+ link.id = FONT_LINK_ID3;
115058
+ link.rel = "stylesheet";
115059
+ link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
115060
+ document.head.appendChild(link);
115061
+ }
115062
+ if (document.getElementById(STYLE_ID13)) return;
115063
+ const style = document.createElement("style");
115064
+ style.id = STYLE_ID13;
115065
+ style.textContent = `
115066
+ .myio-stdmodal-overlay {
115067
+ position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
115068
+ background: rgba(0, 0, 0, 0.5); font-family: 'Nunito', system-ui, sans-serif;
115069
+ }
115070
+ .myio-stdmodal {
115071
+ background: #fff; color: #1f2937; border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
115072
+ max-width: 94vw; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
115073
+ }
115074
+ .myio-stdmodal__body { padding: 20px 24px; overflow-y: auto; font-size: 14px; color: #374151; }
115075
+ .myio-stdmodal__footer {
115076
+ display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px;
115077
+ border-top: 1px solid #e0e0e0; background: #fff;
115078
+ }
115079
+ .myio-stdmodal__btn {
115080
+ font-family: inherit; padding: 10px 20px; border: none; border-radius: 6px; font-size: 14px;
115081
+ font-weight: 500; cursor: pointer; transition: all 0.2s; color: #fff;
115082
+ }
115083
+ .myio-stdmodal__btn--secondary { background: #6c757d; }
115084
+ .myio-stdmodal__btn--secondary:hover:not(:disabled) { background: #545b62; }
115085
+ .myio-stdmodal__btn--primary { background: var(--myio-brand-700, #3e1a7d); }
115086
+ .myio-stdmodal__btn--primary:hover:not(:disabled) { background: var(--myio-brand-600, #2d1458); }
115087
+ .myio-stdmodal__btn--danger { background: #dc3545; }
115088
+ .myio-stdmodal__btn--danger:hover:not(:disabled) { background: #b02a37; }
115089
+ .myio-stdmodal__btn:disabled { opacity: 0.6; cursor: not-allowed; }
115090
+ .myio-stdmodal__btn:focus-visible { outline: 2px solid #7c3aed; outline-offset: 2px; }
115091
+ `;
115092
+ document.head.appendChild(style);
115093
+ }
115094
+ var FOCUSABLE2 = 'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
115095
+ function openStandardModal(params) {
115096
+ injectStyles13();
115097
+ const dismissible = params.dismissible ?? true;
115098
+ const buttons = params.buttons ?? [];
115099
+ const modalId = `myio-stdmodal-${++openCount3}`;
115100
+ const width = params.width == null ? "480px" : typeof params.width === "number" ? `${params.width}px` : params.width;
115101
+ const overlay = document.createElement("div");
115102
+ overlay.className = "myio-stdmodal-overlay";
115103
+ overlay.style.zIndex = String(BASE_Z_INDEX3 + openCount3);
115104
+ overlay.innerHTML = `
115105
+ <div class="myio-stdmodal" role="dialog" aria-modal="true" aria-label="${escapeHtml13(params.title)}" style="width:${width}">
115106
+ ${ModalHeader.generateHTML({
115107
+ icon: params.icon,
115108
+ title: escapeHtml13(params.title),
115109
+ modalId,
115110
+ showThemeToggle: false,
115111
+ showMaximize: false,
115112
+ showClose: dismissible,
115113
+ draggable: false
115114
+ })}
115115
+ <div class="myio-stdmodal__body"></div>
115116
+ ${buttons.length ? `<div class="myio-stdmodal__footer">${buttons.map(
115117
+ (b, i) => `<button type="button" class="myio-stdmodal__btn myio-stdmodal__btn--${b.variant ?? "secondary"}" data-index="${i}" data-value="${escapeHtml13(b.value)}">${escapeHtml13(b.label)}</button>`
115118
+ ).join("")}</div>` : ""}
115119
+ </div>`;
115120
+ const root = overlay.querySelector(".myio-stdmodal");
115121
+ const bodyEl = root.querySelector(".myio-stdmodal__body");
115122
+ bodyEl.innerHTML = params.bodyHtml;
115123
+ const previousFocus = document.activeElement;
115124
+ (params.container ?? document.body).appendChild(overlay);
115125
+ let closed = false;
115126
+ const close = () => {
115127
+ if (closed) return;
115128
+ closed = true;
115129
+ document.removeEventListener("keydown", onKeydown, true);
115130
+ overlay.remove();
115131
+ if (previousFocus?.isConnected) previousFocus.focus();
115132
+ params.onClose?.();
115133
+ };
115134
+ const onKeydown = (e) => {
115135
+ if (!overlay.isConnected) return;
115136
+ if (e.key === "Escape" && dismissible) {
115137
+ e.stopPropagation();
115138
+ close();
115139
+ } else if (e.key === "Tab") {
115140
+ const f = Array.from(root.querySelectorAll(FOCUSABLE2)).filter((el2) => el2.offsetParent !== null || el2 === document.activeElement);
115141
+ if (!f.length) return;
115142
+ const first = f[0];
115143
+ const last = f[f.length - 1];
115144
+ if (e.shiftKey && document.activeElement === first) {
115145
+ e.preventDefault();
115146
+ last.focus();
115147
+ } else if (!e.shiftKey && document.activeElement === last) {
115148
+ e.preventDefault();
115149
+ first.focus();
115150
+ }
115151
+ }
115152
+ };
115153
+ document.addEventListener("keydown", onKeydown, true);
115154
+ root.querySelector(`#${modalId}-close`)?.addEventListener("click", (e) => {
115155
+ e.stopPropagation();
115156
+ close();
115157
+ });
115158
+ if (dismissible) {
115159
+ overlay.addEventListener("click", (e) => {
115160
+ if (e.target === overlay) close();
115161
+ });
115162
+ }
115163
+ root.querySelectorAll(".myio-stdmodal__btn").forEach((el2) => {
115164
+ el2.addEventListener("click", () => {
115165
+ const b = buttons[Number(el2.dataset.index)];
115166
+ if (!b || el2.disabled) return;
115167
+ params.onButton?.(b.value);
115168
+ if (b.closeOnClick !== false) close();
115169
+ });
115170
+ });
115171
+ (root.querySelector(`.myio-stdmodal__body ${FOCUSABLE2}`) ?? root.querySelector(".myio-stdmodal__btn--primary") ?? root)?.focus?.();
115172
+ return {
115173
+ close,
115174
+ getRoot: () => root,
115175
+ getBodyEl: () => bodyEl,
115176
+ setBodyHtml: (html) => {
115177
+ bodyEl.innerHTML = html;
115178
+ },
115179
+ setButton: (value, patch) => {
115180
+ const el2 = Array.from(root.querySelectorAll(".myio-stdmodal__btn")).find(
115181
+ (b) => b.dataset.value === value
115182
+ );
115183
+ if (!el2) return;
115184
+ if (patch.label !== void 0) el2.textContent = patch.label;
115185
+ if (patch.disabled !== void 0) el2.disabled = patch.disabled;
115186
+ if (patch.hidden !== void 0) el2.style.display = patch.hidden ? "none" : "";
115187
+ }
115188
+ };
115189
+ }
115190
+
115191
+ // src/components/premium-modals/telemetry-import/sheet.ts
115192
+ var VALUE_COLUMN = {
115193
+ energy: "value_kwh",
115194
+ water: "value_m3"
115195
+ };
115196
+ var MAX_IMPORT_ROWS = 5e3;
115197
+ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
115198
+ var pad24 = (n) => String(n).padStart(2, "0");
115199
+ function splitImportableDevices(devices) {
115200
+ const ok = [];
115201
+ const missingKey = [];
115202
+ for (const d of devices || []) {
115203
+ const slave = Number(d?.slaveId);
115204
+ if (d?.centralId && UUID_RE.test(String(d.centralId)) && Number.isInteger(slave) && slave >= 1 && slave <= 247) ok.push(d);
115205
+ else missingKey.push(d);
115206
+ }
115207
+ return { ok, missingKey };
115208
+ }
115209
+ function daysBetween(start, end) {
115210
+ const out = [];
115211
+ const [y1, m1, d1] = start.split("-").map(Number);
115212
+ const [y2, m2, d2] = end.split("-").map(Number);
115213
+ const cur = new Date(Date.UTC(y1, m1 - 1, d1));
115214
+ const last = Date.UTC(y2, m2 - 1, d2);
115215
+ while (cur.getTime() <= last && out.length < 400) {
115216
+ out.push(`${cur.getUTCFullYear()}-${pad24(cur.getUTCMonth() + 1)}-${pad24(cur.getUTCDate())}`);
115217
+ cur.setUTCDate(cur.getUTCDate() + 1);
115218
+ }
115219
+ return out;
115220
+ }
115221
+ function nowSaoPaulo(now) {
115222
+ const d = new Date(now - 3 * 3600 * 1e3);
115223
+ return { date: `${d.getUTCFullYear()}-${pad24(d.getUTCMonth() + 1)}-${pad24(d.getUTCDate())}`, hour: d.getUTCHours() };
115224
+ }
115225
+ function buildTemplateCsv(domain, devices, start, end, now = Date.now()) {
115226
+ const valueCol = VALUE_COLUMN[domain];
115227
+ const header = ["gateway_id", "slave_id", "device_name", "date", "hour", valueCol];
115228
+ if (domain === "energy") header.push("value_reactive_kvarh");
115229
+ const today = nowSaoPaulo(now);
115230
+ const lines = [header.join(";")];
115231
+ const esc10 = (v) => /[;"\n]/.test(v) ? `"${v.replace(/"/g, '""')}"` : v;
115232
+ const { ok } = splitImportableDevices(devices);
115233
+ for (const dev of ok) {
115234
+ for (const date of daysBetween(start, end)) {
115235
+ if (date > today.date) break;
115236
+ for (let h3 = 0; h3 < 24; h3++) {
115237
+ if (date === today.date && h3 >= today.hour) break;
115238
+ const cols = [String(dev.centralId), String(Number(dev.slaveId)), esc10(dev.label || ""), date, `${pad24(h3)}:00`, ""];
115239
+ if (domain === "energy") cols.push("");
115240
+ lines.push(cols.join(";"));
115241
+ }
115242
+ }
115243
+ }
115244
+ return { csv: "\uFEFF" + lines.join("\r\n") + "\r\n", rows: lines.length - 1 };
115245
+ }
115246
+ function parseCsv(text2) {
115247
+ const src = String(text2 || "").replace(/^/, "");
115248
+ const firstLine = src.split(/\r?\n/, 1)[0] || "";
115249
+ const sep = (firstLine.match(/;/g) || []).length >= (firstLine.match(/,/g) || []).length ? ";" : ",";
115250
+ const out = [];
115251
+ let row = [];
115252
+ let cell = "";
115253
+ let quoted = false;
115254
+ for (let i = 0; i < src.length; i++) {
115255
+ const c = src[i];
115256
+ if (quoted) {
115257
+ if (c === '"' && src[i + 1] === '"') {
115258
+ cell += '"';
115259
+ i++;
115260
+ } else if (c === '"') quoted = false;
115261
+ else cell += c;
115262
+ } else if (c === '"') quoted = true;
115263
+ else if (c === sep) {
115264
+ row.push(cell);
115265
+ cell = "";
115266
+ } else if (c === "\n" || c === "\r") {
115267
+ if (c === "\r" && src[i + 1] === "\n") i++;
115268
+ row.push(cell);
115269
+ out.push(row);
115270
+ row = [];
115271
+ cell = "";
115272
+ } else cell += c;
115273
+ }
115274
+ if (cell !== "" || row.length) {
115275
+ row.push(cell);
115276
+ out.push(row);
115277
+ }
115278
+ return out;
115279
+ }
115280
+ function normalizeDate(v) {
115281
+ if (typeof v === "number" && Number.isFinite(v) && v > 2e4 && v < 8e4) {
115282
+ const d = new Date(Date.UTC(1899, 11, 30) + Math.floor(v) * 864e5);
115283
+ return `${d.getUTCFullYear()}-${pad24(d.getUTCMonth() + 1)}-${pad24(d.getUTCDate())}`;
115284
+ }
115285
+ const s = String(v ?? "").trim();
115286
+ let m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(s);
115287
+ if (m) return `${m[1]}-${pad24(+m[2])}-${pad24(+m[3])}`;
115288
+ m = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(s);
115289
+ if (m) return `${m[3]}-${pad24(+m[2])}-${pad24(+m[1])}`;
115290
+ return null;
115291
+ }
115292
+ function normalizeHour(v) {
115293
+ if (typeof v === "number" && Number.isFinite(v) && v >= 0 && v < 1) {
115294
+ const mins = Math.round(v * 24 * 60);
115295
+ return mins % 60 === 0 ? `${pad24(mins / 60)}:00` : null;
115296
+ }
115297
+ const s = String(v ?? "").trim();
115298
+ const m = /^(\d{1,2})(?::(\d{2})(?::(\d{2}))?)?$/.exec(s);
115299
+ if (!m) return null;
115300
+ const h3 = Number(m[1]);
115301
+ if (h3 > 23 || Number(m[2] || 0) !== 0 || Number(m[3] || 0) !== 0) return null;
115302
+ return `${pad24(h3)}:00`;
115303
+ }
115304
+ function parseDecimal(v) {
115305
+ if (typeof v === "number") return Number.isFinite(v) ? v : NaN;
115306
+ const s = String(v ?? "").trim();
115307
+ if (!s) return null;
115308
+ const norm2 = s.includes(",") ? s.replace(/\./g, "").replace(",", ".") : s;
115309
+ return /^-?\d+(\.\d+)?$/.test(norm2) ? Number(norm2) : NaN;
115310
+ }
115311
+ function rowsFromTable(domain, table) {
115312
+ const errors = [];
115313
+ const rows = [];
115314
+ let skippedEmpty = 0;
115315
+ const valueCol = VALUE_COLUMN[domain];
115316
+ const header = (table[0] || []).map((h3) => String(h3 ?? "").trim().toLowerCase());
115317
+ const col2 = (name) => header.indexOf(name);
115318
+ const idx = { gw: col2("gateway_id"), slave: col2("slave_id"), date: col2("date"), hour: col2("hour"), value: col2(valueCol), reactive: col2("value_reactive_kvarh") };
115319
+ const missing = ["gateway_id", "slave_id", "date", "hour", valueCol].filter((c) => col2(c) < 0);
115320
+ if (missing.length) {
115321
+ return { rows, errors: [{ line: 1, reason: `Coluna obrigat\xF3ria ausente: ${missing.join(", ")}` }], skippedEmpty };
115322
+ }
115323
+ const seen = /* @__PURE__ */ new Map();
115324
+ for (let i = 1; i < table.length; i++) {
115325
+ const r = table[i] || [];
115326
+ const line = i + 1;
115327
+ if (r.every((c) => String(c ?? "").trim() === "")) continue;
115328
+ const gw = String(r[idx.gw] ?? "").trim();
115329
+ const slave = Number(String(r[idx.slave] ?? "").trim());
115330
+ const date = normalizeDate(r[idx.date]);
115331
+ const hour = normalizeHour(r[idx.hour]);
115332
+ const value = parseDecimal(r[idx.value]);
115333
+ if (value === null) {
115334
+ skippedEmpty++;
115335
+ continue;
115336
+ }
115337
+ const lineErrors = [];
115338
+ if (!UUID_RE.test(gw)) lineErrors.push("gateway_id inv\xE1lido");
115339
+ if (!Number.isInteger(slave) || slave < 1 || slave > 247) lineErrors.push("slave_id deve ser inteiro de 1 a 247");
115340
+ if (!date) lineErrors.push("data inv\xE1lida (use AAAA-MM-DD)");
115341
+ if (!hour) lineErrors.push("hora inv\xE1lida (use HH:00)");
115342
+ if (Number.isNaN(value) || value < 0) lineErrors.push("valor deve ser n\xFAmero \u2265 0");
115343
+ let reactive;
115344
+ if (domain === "energy" && idx.reactive >= 0) {
115345
+ const rv = parseDecimal(r[idx.reactive]);
115346
+ if (Number.isNaN(rv)) lineErrors.push("reativo inv\xE1lido");
115347
+ else if (rv !== null) reactive = rv;
115348
+ }
115349
+ if (lineErrors.length) {
115350
+ errors.push({ line, reason: lineErrors.join("; ") });
115351
+ continue;
115352
+ }
115353
+ const key = `${gw.toLowerCase()}|${slave}|${date}|${hour}`;
115354
+ if (seen.has(key)) {
115355
+ errors.push({ line, reason: `linha duplicada (mesmo device/data/hora da linha ${seen.get(key)})` });
115356
+ continue;
115357
+ }
115358
+ seen.set(key, line);
115359
+ const row = { line, gateway_id: gw, slave_id: slave, date, hour, [valueCol]: value };
115360
+ if (reactive !== void 0) row.value_reactive_kvarh = reactive;
115361
+ rows.push(row);
115362
+ }
115363
+ if (rows.length > MAX_IMPORT_ROWS) {
115364
+ errors.push({ line: 1, reason: `M\xE1ximo de ${MAX_IMPORT_ROWS} linhas por importa\xE7\xE3o (${rows.length} enviadas)` });
115365
+ }
115366
+ return { rows, errors, skippedEmpty };
115367
+ }
115368
+ var SHEETJS_URL = "https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js";
115369
+ async function loadSheetJs() {
115370
+ const w = window;
115371
+ if (w.XLSX) return w.XLSX;
115372
+ await new Promise((resolve, reject) => {
115373
+ const s = document.createElement("script");
115374
+ s.src = SHEETJS_URL;
115375
+ s.onload = () => resolve();
115376
+ s.onerror = () => reject(new Error("N\xE3o foi poss\xEDvel carregar o leitor de Excel"));
115377
+ document.head.appendChild(s);
115378
+ });
115379
+ return w.XLSX;
115380
+ }
115381
+ function readFile(file, as) {
115382
+ return new Promise((resolve, reject) => {
115383
+ const fr = new FileReader();
115384
+ fr.onload = () => resolve(fr.result);
115385
+ fr.onerror = () => reject(new Error("N\xE3o foi poss\xEDvel ler o arquivo"));
115386
+ if (as === "text") fr.readAsText(file, "utf-8");
115387
+ else fr.readAsArrayBuffer(file);
115388
+ });
115389
+ }
115390
+ async function parseSheetFile(file) {
115391
+ const name = String(file?.name || "").toLowerCase();
115392
+ if (name.endsWith(".csv") || name.endsWith(".txt")) return parseCsv(await readFile(file, "text"));
115393
+ if (name.endsWith(".xlsx") || name.endsWith(".xls")) {
115394
+ const XLSX = await loadSheetJs();
115395
+ const wb = XLSX.read(await readFile(file, "buffer"), { type: "array" });
115396
+ const ws = wb.Sheets[wb.SheetNames[0]];
115397
+ return XLSX.utils.sheet_to_json(ws, { header: 1, raw: true, defval: "" });
115398
+ }
115399
+ throw new Error("Formato n\xE3o suportado \u2014 envie .xlsx ou .csv");
115400
+ }
115401
+
115402
+ // src/components/premium-modals/telemetry-import/importApi.ts
115403
+ var TERMINAL_JOB_STATUSES = ["completed", "failed", "cancelled", "reverted"];
115404
+ var ImportApiError = class extends Error {
115405
+ constructor(message, status, detail) {
115406
+ super(message);
115407
+ this.status = status;
115408
+ this.detail = detail;
115409
+ this.name = "ImportApiError";
115410
+ }
115411
+ };
115412
+ function createTelemetryImportApi(cfg) {
115413
+ const base = String(cfg.baseUrl || "").replace(/\/+$/, "");
115414
+ const doFetch = cfg.fetchImpl ?? fetch.bind(window);
115415
+ const call = async (method, path, body, accept422 = false) => {
115416
+ const token = await cfg.getToken();
115417
+ const res = await doFetch(`${base}/import${path}`, {
115418
+ method,
115419
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
115420
+ body: body === void 0 ? void 0 : JSON.stringify(body)
115421
+ });
115422
+ const text2 = await res.text().catch(() => "");
115423
+ let data = null;
115424
+ try {
115425
+ data = text2 ? JSON.parse(text2) : null;
115426
+ } catch {
115427
+ data = null;
115428
+ }
115429
+ if (res.ok || accept422 && res.status === 422) return { status: res.status, data: data?.data ?? data };
115430
+ const apiMsg = data?.message || data?.error || "";
115431
+ const msg = res.status === 404 ? "A importa\xE7\xE3o ainda n\xE3o est\xE1 dispon\xEDvel neste ambiente." : res.status === 401 || res.status === 403 ? "Sem permiss\xE3o para importar telemetria (credencial sem o escopo telemetry.import)." : res.status === 409 ? apiMsg || "Opera\xE7\xE3o n\xE3o permitida no estado atual da importa\xE7\xE3o." : `Falha na API de importa\xE7\xE3o (${res.status}).`;
115432
+ throw new ImportApiError(msg, res.status, `${method} /import${path} \u2192 ${res.status} ${String(apiMsg || text2).slice(0, 200)}`);
115433
+ };
115434
+ return {
115435
+ async validate(body) {
115436
+ const { status, data } = await call("POST", "/validate", body, true);
115437
+ if (status === 422 || data?.valid === false) {
115438
+ return { valid: false, invalidCount: Number(data?.invalidCount ?? data?.errors?.length ?? 0), errors: data?.errors || [] };
115439
+ }
115440
+ return { valid: true, validationId: data.validationId, expiresAt: data.expiresAt, preview: data.preview || {} };
115441
+ },
115442
+ async startJob(body) {
115443
+ const { data } = await call("POST", "/jobs", body);
115444
+ return { jobId: data.jobId, status: data.status || "queued" };
115445
+ },
115446
+ async getJob(jobId) {
115447
+ const { data } = await call("GET", `/jobs/${encodeURIComponent(jobId)}`);
115448
+ return { jobId, ...data || {} };
115449
+ },
115450
+ async cancelJob(jobId) {
115451
+ const { data } = await call("POST", `/jobs/${encodeURIComponent(jobId)}/cancel`);
115452
+ return data ? { jobId, ...data } : null;
115453
+ }
115454
+ };
115455
+ }
115456
+
115457
+ // src/components/premium-modals/telemetry-import/openTelemetryImportModal.ts
115458
+ var STEPS2 = [
115459
+ { n: 1, label: "Modelo" },
115460
+ { n: 2, label: "Planilha" },
115461
+ { n: 3, label: "Valida\xE7\xE3o" },
115462
+ { n: 4, label: "Importa\xE7\xE3o" }
115463
+ ];
115464
+ var DOMAIN_TEXT = {
115465
+ energy: { noun: "energia", unit: "kWh", icon: "\u26A1" },
115466
+ water: { noun: "\xE1gua", unit: "m\xB3", icon: "\u{1F4A7}" }
115467
+ };
115468
+ var JOB_STATUS_TEXT = {
115469
+ queued: "Na fila",
115470
+ executing: "Importando",
115471
+ completed: "Conclu\xEDda",
115472
+ failed: "Falhou",
115473
+ cancelled: "Cancelada",
115474
+ reverted: "Revertida"
115475
+ };
115476
+ var STYLE_ID14 = "myio-tlmimport-styles";
115477
+ function esc9(v) {
115478
+ return String(v ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
115479
+ }
115480
+ var fmtNum = (n, d = 0) => Number.isFinite(Number(n)) ? Number(n).toLocaleString("pt-BR", { minimumFractionDigits: d, maximumFractionDigits: d }) : "\u2014";
115481
+ function injectStyles14() {
115482
+ if (document.getElementById(STYLE_ID14)) return;
115483
+ const style = document.createElement("style");
115484
+ style.id = STYLE_ID14;
115485
+ style.textContent = `
115486
+ .tlmi { --tlmi-ac: #3e1a7d; --tlmi-ac-soft: #f1ecfa; --tlmi-ok: #16a34a; --tlmi-warn: #d97706; --tlmi-err: #dc2626;
115487
+ display: flex; flex-direction: column; gap: 12px; font-size: 14px; color: #1e293b; }
115488
+ .tlmi-stepper { display: flex; gap: 6px; }
115489
+ .tlmi-step { flex: 1; display: flex; align-items: center; gap: 8px; color: #64748b; padding: 6px 8px; border-radius: 10px; font-size: 13px; }
115490
+ .tlmi-step b { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
115491
+ border: 2px solid #e2e8f0; font-size: 12px; flex-shrink: 0; }
115492
+ .tlmi-step[data-state="current"] { color: var(--tlmi-ac); font-weight: 800; background: var(--tlmi-ac-soft); }
115493
+ .tlmi-step[data-state="current"] b { border-color: var(--tlmi-ac); background: var(--tlmi-ac); color: #fff; }
115494
+ .tlmi-step[data-state="done"] { color: #1e293b; }
115495
+ .tlmi-step[data-state="done"] b { border-color: var(--tlmi-ok); background: var(--tlmi-ok); color: #fff; }
115496
+ .tlmi-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px 16px; }
115497
+ .tlmi-card h3 { margin: 0 0 10px !important; font-size: 14px !important; font-weight: 700 !important; line-height: 1.4 !important; }
115498
+ .tlmi-muted { color: #64748b; font-size: 13px; margin: 0; line-height: 1.5; }
115499
+ .tlmi-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
115500
+ .tlmi-field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 12px; color: #64748b; }
115501
+ .tlmi-field input { border: 1px solid #ddd; border-radius: 6px; padding: 8px 10px; font: inherit; color: #1e293b; }
115502
+ .tlmi-btn { font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 6px; border: 1px solid #d1d5db;
115503
+ background: #fff; color: #374151; cursor: pointer; }
115504
+ .tlmi-btn.primary { background: var(--tlmi-ac); border-color: var(--tlmi-ac); color: #fff; }
115505
+ .tlmi-btn:disabled { opacity: 0.55; cursor: not-allowed; }
115506
+ .tlmi-drop { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 22px; text-align: center; color: #64748b; cursor: pointer; }
115507
+ .tlmi-drop[data-over="1"] { border-color: var(--tlmi-ac); background: var(--tlmi-ac-soft); }
115508
+ .tlmi-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
115509
+ .tlmi-kpi { border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px; }
115510
+ .tlmi-kpi span { display: block; font-size: 11.5px; color: #64748b; }
115511
+ .tlmi-kpi strong { font-size: 18px; }
115512
+ .tlmi-banner { padding: 9px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
115513
+ .tlmi-banner.warn { background: #fef3c7; border: 1px solid #fcd34d; color: #78350f; }
115514
+ .tlmi-banner.err { background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; }
115515
+ .tlmi-banner.ok { background: #dcfce7; border: 1px solid #86efac; color: #14532d; }
115516
+ .tlmi-errors { max-height: 220px; overflow: auto; border: 1px solid #fecaca; border-radius: 8px; }
115517
+ .tlmi-errors table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
115518
+ .tlmi-errors th, .tlmi-errors td { padding: 5px 8px; border-bottom: 1px solid #fee2e2; text-align: left; }
115519
+ .tlmi-errors th { background: #fef2f2; position: sticky; top: 0; }
115520
+ .tlmi-progress { height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
115521
+ .tlmi-progress > i { display: block; height: 100%; background: var(--tlmi-ac); transition: width 0.4s; }
115522
+ .tlmi-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
115523
+ .tlmi-tech { font-size: 11.5px; color: #6b7280; word-break: break-word; }
115524
+ `;
115525
+ document.head.appendChild(style);
115526
+ }
115527
+ function issuesTable(errors, limit = 100) {
115528
+ const rows = errors.slice(0, limit).map((e) => `<tr><td>${esc9(e.line)}</td><td>${esc9(e.reason)}</td></tr>`).join("");
115529
+ const more = errors.length > limit ? `<p class="tlmi-muted">\u2026 e mais ${errors.length - limit} erro(s).</p>` : "";
115530
+ return `<div class="tlmi-errors"><table><thead><tr><th>Linha</th><th>Problema</th></tr></thead><tbody>${rows}</tbody></table></div>${more}`;
115531
+ }
115532
+ function defaultPeriod(now) {
115533
+ const sp = new Date(now - 3 * 3600 * 1e3);
115534
+ const ymd = (d) => d.toISOString().slice(0, 10);
115535
+ const end = new Date(Date.UTC(sp.getUTCFullYear(), sp.getUTCMonth(), sp.getUTCDate() - 1));
115536
+ const start = new Date(end.getTime() - 6 * 864e5);
115537
+ return { start: ymd(start), end: ymd(end) };
115538
+ }
115539
+ function openTelemetryImportModal(params) {
115540
+ injectStyles14();
115541
+ const domain = params.domain;
115542
+ const txt = DOMAIN_TEXT[domain];
115543
+ const now = params.now ?? (() => Date.now());
115544
+ const api = "validate" in params.api ? params.api : createTelemetryImportApi(params.api);
115545
+ const { ok: importable, missingKey } = splitImportableDevices(params.devices);
115546
+ const s = {
115547
+ step: 1,
115548
+ period: defaultPeriod(now()),
115549
+ fileName: "",
115550
+ rows: [],
115551
+ localErrors: [],
115552
+ skippedEmpty: 0,
115553
+ parseError: "",
115554
+ busy: false,
115555
+ validation: null,
115556
+ apiError: "",
115557
+ apiDetail: "",
115558
+ confirmReal: false,
115559
+ job: null
115560
+ };
115561
+ let pollTimer = null;
115562
+ let closed = false;
115563
+ const modal = openStandardModal({
115564
+ icon: "\u{1F4E5}",
115565
+ title: `Importar dados de ${txt.noun}`,
115566
+ width: 760,
115567
+ bodyHtml: '<div class="tlmi"></div>',
115568
+ container: params.container,
115569
+ buttons: [
115570
+ { label: "Voltar", value: "back", variant: "secondary", closeOnClick: false },
115571
+ { label: "Fechar", value: "close", variant: "secondary" },
115572
+ { label: "Avan\xE7ar", value: "next", variant: "primary", closeOnClick: false }
115573
+ ],
115574
+ onButton: (v) => {
115575
+ if (v === "back") goBack();
115576
+ if (v === "next") void goNext();
115577
+ },
115578
+ onClose: () => {
115579
+ closed = true;
115580
+ if (pollTimer) clearTimeout(pollTimer);
115581
+ }
115582
+ });
115583
+ const root = modal.getBodyEl().querySelector(".tlmi");
115584
+ const setError = (err) => {
115585
+ s.apiError = err instanceof ImportApiError ? err.message : err?.message || "Erro inesperado.";
115586
+ s.apiDetail = params.showTechnicalDetails ? err instanceof ImportApiError ? err.detail || "" : String(err) : "";
115587
+ };
115588
+ function stepper() {
115589
+ return `<div class="tlmi-stepper">${STEPS2.map((st) => {
115590
+ const state6 = st.n === s.step ? "current" : st.n < s.step ? "done" : "todo";
115591
+ return `<div class="tlmi-step" data-state="${state6}"><b>${state6 === "done" ? "\u2713" : st.n}</b>${st.label}</div>`;
115592
+ }).join("")}</div>`;
115593
+ }
115594
+ function apiErrorBanner() {
115595
+ if (!s.apiError) return "";
115596
+ return `<div class="tlmi-banner err" role="alert">${esc9(s.apiError)}${s.apiDetail ? `<div class="tlmi-tech">${esc9(s.apiDetail)}</div>` : ""}</div>`;
115597
+ }
115598
+ function step1() {
115599
+ const warn = missingKey.length ? `<div class="tlmi-banner warn">${missingKey.length} dispositivo(s) sem central/endere\xE7o cadastrados ficam fora do modelo: ${esc9(
115600
+ missingKey.slice(0, 5).map((d) => d.label).join(", ")
115601
+ )}${missingKey.length > 5 ? "\u2026" : ""}</div>` : "";
115602
+ return `
115603
+ <div class="tlmi-card"><h3>Como funciona</h3>
115604
+ <p class="tlmi-muted">1) Baixe o modelo com os dispositivos desta lista, uma linha por hora. 2) Preencha a coluna
115605
+ <strong>${VALUE_COLUMN[domain]}</strong> (${txt.unit}); apague ou deixe em branco as horas que n\xE3o quer alterar.
115606
+ 3) Envie a planilha: ela \xE9 validada por inteiro \u2014 qualquer linha inv\xE1lida cancela a importa\xE7\xE3o.
115607
+ Os valores importados <strong>substituem</strong> as leituras existentes nas horas enviadas.</p>
115608
+ </div>
115609
+ ${warn}
115610
+ <div class="tlmi-card"><h3>Modelo da planilha</h3>
115611
+ <div class="tlmi-row">
115612
+ <label class="tlmi-field">In\xEDcio<input type="date" data-field="start" value="${esc9(s.period.start)}" /></label>
115613
+ <label class="tlmi-field">Fim<input type="date" data-field="end" value="${esc9(s.period.end)}" /></label>
115614
+ <button class="tlmi-btn" type="button" data-action="template" ${importable.length ? "" : "disabled"}>\u2B07 Baixar modelo (CSV)</button>
115615
+ </div>
115616
+ <p class="tlmi-muted" style="margin-top:8px">${importable.length} dispositivo(s) no modelo. J\xE1 tem a planilha preenchida? Clique em <strong>Avan\xE7ar</strong>.</p>
115617
+ </div>`;
115618
+ }
115619
+ function step2() {
115620
+ const summary = s.fileName ? s.parseError ? `<div class="tlmi-banner err">${esc9(s.parseError)}</div>` : `<div class="tlmi-kpis">
115621
+ <div class="tlmi-kpi"><span>Arquivo</span><strong style="font-size:13px">${esc9(s.fileName)}</strong></div>
115622
+ <div class="tlmi-kpi"><span>Linhas para importar</span><strong>${fmtNum(s.rows.length)}</strong></div>
115623
+ <div class="tlmi-kpi"><span>Em branco (ignoradas)</span><strong>${fmtNum(s.skippedEmpty)}</strong></div>
115624
+ <div class="tlmi-kpi"><span>Com erro</span><strong style="color:${s.localErrors.length ? "#dc2626" : "#16a34a"}">${fmtNum(s.localErrors.length)}</strong></div>
115625
+ </div>
115626
+ ${s.localErrors.length ? `<div class="tlmi-banner err">Corrija as linhas abaixo e envie de novo \u2014 nada foi importado.</div>${issuesTable(s.localErrors)}` : ""}
115627
+ ${!s.localErrors.length && !s.rows.length ? '<div class="tlmi-banner warn">Nenhuma linha com valor preenchido.</div>' : ""}` : "";
115628
+ return `
115629
+ <div class="tlmi-card"><h3>Planilha preenchida</h3>
115630
+ <label class="tlmi-drop" data-role="drop">
115631
+ <input type="file" accept=".xlsx,.xls,.csv" data-field="file" hidden />
115632
+ \u{1F4C4} Clique ou arraste a planilha aqui (.xlsx ou .csv)
115633
+ </label>
115634
+ </div>
115635
+ ${summary}`;
115636
+ }
115637
+ function step3() {
115638
+ const v = s.validation;
115639
+ if (!v) return `${apiErrorBanner()}<div class="tlmi-card"><p class="tlmi-muted">${s.busy ? "Validando\u2026" : "Aguardando valida\xE7\xE3o."}</p></div>`;
115640
+ if (v.valid === false) {
115641
+ return `<div class="tlmi-banner err">A planilha foi recusada: ${fmtNum(v.invalidCount)} linha(s) inv\xE1lida(s). Nada foi importado.</div>
115642
+ ${issuesTable(v.errors)}`;
115643
+ }
115644
+ const p = v.preview || {};
115645
+ const real = Number(p.existingRealReadings || 0);
115646
+ const period = typeof p.period === "string" ? p.period : p.period ? `${p.period.start || ""} \u2192 ${p.period.end || ""}` : "\u2014";
115647
+ const devices = Array.isArray(p.devices) ? p.devices.length : p.devices;
115648
+ return `
115649
+ <div class="tlmi-banner ok">Planilha v\xE1lida. Confira o resumo antes de importar.</div>
115650
+ <div class="tlmi-kpis">
115651
+ <div class="tlmi-kpi"><span>Horas a gravar</span><strong>${fmtNum(p.targetSlots)}</strong></div>
115652
+ <div class="tlmi-kpi"><span>Dispositivos</span><strong>${fmtNum(devices)}</strong></div>
115653
+ <div class="tlmi-kpi"><span>Total (${txt.unit})</span><strong>${fmtNum(p.totalValue, 2)}</strong></div>
115654
+ <div class="tlmi-kpi"><span>Leituras substitu\xEDdas</span><strong>${fmtNum(p.existingReadingsInTarget)}</strong></div>
115655
+ </div>
115656
+ <p class="tlmi-muted">Per\xEDodo: ${esc9(period)}</p>
115657
+ ${real > 0 ? `<div class="tlmi-banner warn"><strong>${fmtNum(real)} leitura(s) reais do medidor</strong> ser\xE3o substitu\xEDdas pelos valores da planilha.
115658
+ <label class="tlmi-check" style="margin-top:6px"><input type="checkbox" data-field="confirmReal" ${s.confirmReal ? "checked" : ""} />
115659
+ Confirmo a substitui\xE7\xE3o das leituras reais.</label></div>` : ""}
115660
+ ${apiErrorBanner()}`;
115661
+ }
115662
+ function step4() {
115663
+ const j = s.job;
115664
+ if (!j) return `${apiErrorBanner()}<div class="tlmi-card"><p class="tlmi-muted">Iniciando importa\xE7\xE3o\u2026</p></div>`;
115665
+ const pct = Math.max(0, Math.min(100, Number(j.progress ?? (j.status === "completed" ? 100 : 0))));
115666
+ const statusText = JOB_STATUS_TEXT[j.status] || j.status;
115667
+ const terminal = TERMINAL_JOB_STATUSES.includes(j.status);
115668
+ let banner = "";
115669
+ if (j.status === "completed") {
115670
+ banner = j.refreshStatus === "failed" ? '<div class="tlmi-banner warn">Dados importados, mas a atualiza\xE7\xE3o dos totais falhou. Avise o suporte MyIO.</div>' : '<div class="tlmi-banner ok">Importa\xE7\xE3o conclu\xEDda. Os totais podem levar alguns minutos para refletir.</div>';
115671
+ } else if (j.status === "failed") {
115672
+ banner = `<div class="tlmi-banner err">A importa\xE7\xE3o falhou${j.error ? `: ${esc9(j.error)}` : "."}</div>`;
115673
+ } else if (j.status === "cancelled") {
115674
+ banner = '<div class="tlmi-banner warn">Importa\xE7\xE3o cancelada. As leituras anteriores foram mantidas.</div>';
115675
+ }
115676
+ return `
115677
+ <div class="tlmi-card"><h3>Importa\xE7\xE3o <span style="font-weight:600;color:#64748b">${esc9(statusText)}</span></h3>
115678
+ <div class="tlmi-progress" role="progressbar" aria-valuenow="${pct}" aria-valuemin="0" aria-valuemax="100"><i style="width:${pct}%"></i></div>
115679
+ <div class="tlmi-kpis" style="margin-top:12px">
115680
+ <div class="tlmi-kpi"><span>Progresso</span><strong>${fmtNum(pct)}%</strong></div>
115681
+ <div class="tlmi-kpi"><span>Leituras removidas</span><strong>${fmtNum(j.deleted)}</strong></div>
115682
+ <div class="tlmi-kpi"><span>Leituras gravadas</span><strong>${fmtNum(j.inserted)}</strong></div>
115683
+ </div>
115684
+ ${j.phase && !terminal ? `<p class="tlmi-muted" style="margin-top:8px">Etapa: ${esc9(j.phase)}</p>` : ""}
115685
+ ${!terminal ? `<div style="margin-top:12px"><button class="tlmi-btn" type="button" data-action="cancel" ${s.busy ? "disabled" : ""}>Cancelar importa\xE7\xE3o</button>
115686
+ <span class="tlmi-muted" style="margin-left:8px">Voc\xEA pode fechar esta janela; a importa\xE7\xE3o continua.</span></div>` : ""}
115687
+ </div>
115688
+ ${banner}
115689
+ ${apiErrorBanner()}`;
115690
+ }
115691
+ function render3() {
115692
+ if (closed) return;
115693
+ const body = s.step === 1 ? step1() : s.step === 2 ? step2() : s.step === 3 ? step3() : step4();
115694
+ root.innerHTML = stepper() + body;
115695
+ syncFooter();
115696
+ }
115697
+ function syncFooter() {
115698
+ const v = s.validation;
115699
+ const terminal = s.job ? TERMINAL_JOB_STATUSES.includes(s.job.status) : false;
115700
+ modal.setButton("back", { hidden: s.step === 1 || s.step === 4, disabled: s.busy });
115701
+ if (s.step === 1) modal.setButton("next", { label: "Avan\xE7ar", disabled: false, hidden: false });
115702
+ if (s.step === 2)
115703
+ modal.setButton("next", { label: "Validar planilha", disabled: s.busy || !s.rows.length || !!s.localErrors.length || !!s.parseError, hidden: false });
115704
+ if (s.step === 3) {
115705
+ const real = v && v.valid ? Number(v.preview?.existingRealReadings || 0) : 0;
115706
+ modal.setButton("next", {
115707
+ label: s.busy ? "Iniciando\u2026" : "Importar",
115708
+ hidden: !v || !v.valid,
115709
+ disabled: s.busy || real > 0 && !s.confirmReal
115710
+ });
115711
+ }
115712
+ if (s.step === 4) modal.setButton("next", { label: "Concluir", hidden: !terminal, disabled: false });
115713
+ }
115714
+ function goBack() {
115715
+ if (s.busy || s.step === 1 || s.step === 4) return;
115716
+ s.apiError = "";
115717
+ if (s.step === 3) s.validation = null;
115718
+ s.step = s.step - 1;
115719
+ render3();
115720
+ }
115721
+ async function goNext() {
115722
+ if (s.busy) return;
115723
+ if (s.step === 1) {
115724
+ s.step = 2;
115725
+ render3();
115726
+ } else if (s.step === 2) {
115727
+ await validate2();
115728
+ } else if (s.step === 3) {
115729
+ await start();
115730
+ } else if (s.step === 4) {
115731
+ if (s.job?.status === "completed") params.onCompleted?.(s.job);
115732
+ modal.close();
115733
+ }
115734
+ }
115735
+ function downloadTemplate() {
115736
+ const { csv, rows } = buildTemplateCsv(domain, importable, s.period.start, s.period.end, now());
115737
+ if (!rows) return;
115738
+ const blob = new Blob([csv], { type: "text/csv;charset=utf-8" });
115739
+ const a = document.createElement("a");
115740
+ a.href = URL.createObjectURL(blob);
115741
+ const who = (params.customerName || "shopping").replace(/[^\w-]+/g, "_");
115742
+ a.download = `importacao-${domain === "energy" ? "energia" : "agua"}-${who}-${s.period.start}_${s.period.end}.csv`;
115743
+ document.body.appendChild(a);
115744
+ a.click();
115745
+ a.remove();
115746
+ setTimeout(() => URL.revokeObjectURL(a.href), 1e3);
115747
+ }
115748
+ async function loadFile(file) {
115749
+ if (!file) return;
115750
+ s.fileName = file.name;
115751
+ s.parseError = "";
115752
+ s.rows = [];
115753
+ s.localErrors = [];
115754
+ s.skippedEmpty = 0;
115755
+ s.validation = null;
115756
+ try {
115757
+ const table = await parseSheetFile(file);
115758
+ const r = rowsFromTable(domain, table);
115759
+ s.rows = r.rows;
115760
+ s.localErrors = r.errors;
115761
+ s.skippedEmpty = r.skippedEmpty;
115762
+ } catch (err) {
115763
+ s.parseError = err?.message || "N\xE3o foi poss\xEDvel ler a planilha.";
115764
+ }
115765
+ render3();
115766
+ }
115767
+ async function validate2() {
115768
+ s.busy = true;
115769
+ s.apiError = "";
115770
+ s.validation = null;
115771
+ s.step = 3;
115772
+ render3();
115773
+ try {
115774
+ s.validation = await api.validate({ customerId: params.customerId, readingType: domain, rows: s.rows, sourceRef: s.fileName });
115775
+ } catch (err) {
115776
+ setError(err);
115777
+ } finally {
115778
+ s.busy = false;
115779
+ render3();
115780
+ }
115781
+ }
115782
+ async function start() {
115783
+ const v = s.validation;
115784
+ if (!v || !v.valid) return;
115785
+ s.busy = true;
115786
+ s.apiError = "";
115787
+ render3();
115788
+ try {
115789
+ const started = await api.startJob({ validationId: v.validationId, confirmReplaceReal: s.confirmReal || void 0 });
115790
+ s.job = { jobId: started.jobId, status: started.status };
115791
+ s.step = 4;
115792
+ s.busy = false;
115793
+ render3();
115794
+ schedulePoll(0);
115795
+ } catch (err) {
115796
+ setError(err);
115797
+ s.busy = false;
115798
+ render3();
115799
+ }
115800
+ }
115801
+ function schedulePoll(delay = params.pollMs ?? 5e3) {
115802
+ if (closed || !s.job?.jobId) return;
115803
+ pollTimer = setTimeout(async () => {
115804
+ if (closed || !s.job?.jobId) return;
115805
+ try {
115806
+ s.job = { ...await api.getJob(s.job.jobId), jobId: s.job.jobId };
115807
+ s.apiError = "";
115808
+ } catch (err) {
115809
+ setError(err);
115810
+ }
115811
+ render3();
115812
+ if (s.job && !TERMINAL_JOB_STATUSES.includes(s.job.status)) schedulePoll();
115813
+ }, delay);
115814
+ }
115815
+ async function cancelJob() {
115816
+ if (!s.job?.jobId || s.busy) return;
115817
+ s.busy = true;
115818
+ render3();
115819
+ try {
115820
+ const j = await api.cancelJob(s.job.jobId);
115821
+ if (j?.status) s.job = { ...s.job, ...j };
115822
+ } catch (err) {
115823
+ setError(err);
115824
+ } finally {
115825
+ s.busy = false;
115826
+ render3();
115827
+ }
115828
+ }
115829
+ root.addEventListener("click", (e) => {
115830
+ const el2 = e.target.closest("[data-action]");
115831
+ if (!el2) return;
115832
+ if (el2.dataset.action === "template") downloadTemplate();
115833
+ if (el2.dataset.action === "cancel") void cancelJob();
115834
+ });
115835
+ root.addEventListener("change", (e) => {
115836
+ const t = e.target;
115837
+ if (t.dataset.field === "start") s.period.start = t.value;
115838
+ if (t.dataset.field === "end") s.period.end = t.value;
115839
+ if (t.dataset.field === "file") void loadFile(t.files?.[0]);
115840
+ if (t.dataset.field === "confirmReal") {
115841
+ s.confirmReal = t.checked;
115842
+ syncFooter();
115843
+ }
115844
+ });
115845
+ root.addEventListener("dragover", (e) => {
115846
+ const drop = e.target.closest('[data-role="drop"]');
115847
+ if (!drop) return;
115848
+ e.preventDefault();
115849
+ drop.dataset.over = "1";
115850
+ });
115851
+ root.addEventListener("dragleave", (e) => {
115852
+ const drop = e.target.closest('[data-role="drop"]');
115853
+ if (drop) drop.dataset.over = "";
115854
+ });
115855
+ root.addEventListener("drop", (e) => {
115856
+ const drop = e.target.closest('[data-role="drop"]');
115857
+ if (!drop) return;
115858
+ e.preventDefault();
115859
+ void loadFile(e.dataTransfer?.files?.[0]);
115860
+ });
115861
+ render3();
115862
+ return modal;
115863
+ }
115864
+
115865
+ // src/components/premium-modals/manual-device/createManualDevice.ts
115866
+ var MANUAL_DEVICE_PROFILES = {
115867
+ energy: "3F_MEDIDOR_MANUAL",
115868
+ water: "HIDROMETRO_MANUAL"
115869
+ };
115870
+ var NAME_PREFIX = {
115871
+ energy: "3F ",
115872
+ water: "Hidr. "
115873
+ };
115874
+ var MANUAL_ASSET_SUFFIX = "_DEVICES_MANUAIS";
115875
+ var ManualDeviceError = class extends Error {
115876
+ constructor(message, detail) {
115877
+ super(message);
115878
+ this.detail = detail;
115879
+ this.name = "ManualDeviceError";
115880
+ }
115881
+ };
115882
+ function manualDeviceName(domain, sigla, seq) {
115883
+ return `${NAME_PREFIX[domain]}${sigla}_LOJA_${String(seq).padStart(3, "0")}_MANUAL`;
115884
+ }
115885
+ function siglaFromManualAsset(assetName) {
115886
+ const upper = String(assetName || "").trim().toUpperCase();
115887
+ if (!upper.endsWith(MANUAL_ASSET_SUFFIX)) return null;
115888
+ const sigla = upper.slice(0, -MANUAL_ASSET_SUFFIX.length).replace(/^ASSET_/, "");
115889
+ return /^[A-Z0-9_]+$/.test(sigla) ? sigla : null;
115890
+ }
115891
+ function nextManualSeq(domain, sigla, existingNames) {
115892
+ const esc10 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
115893
+ const re = new RegExp(`^${esc10(NAME_PREFIX[domain])}${esc10(sigla)}_LOJA_(\\d+)_MANUAL$`, "i");
115894
+ const max = existingNames.reduce((acc, n) => {
115895
+ const m = re.exec(String(n || "").trim());
115896
+ return m ? Math.max(acc, Number(m[1])) : acc;
115897
+ }, 0);
115898
+ return max + 1;
115899
+ }
115900
+ async function createManualDevice(params) {
115901
+ const domain = params.domain;
115902
+ const profile = MANUAL_DEVICE_PROFILES[domain];
115903
+ if (!profile) throw new ManualDeviceError(`Dom\xEDnio inv\xE1lido: ${domain}`);
115904
+ const label = String(params.label || "").trim();
115905
+ const identifier = String(params.identifier || "").trim();
115906
+ if (!label) throw new ManualDeviceError("Informe a etiqueta.");
115907
+ if (!identifier) throw new ManualDeviceError("Informe o identificador.");
115908
+ if (!params.customerId) throw new ManualDeviceError("Cliente n\xE3o identificado.");
115909
+ const base = params.baseUrl ?? "";
115910
+ const doFetch = params.fetchImpl ?? fetch.bind(window);
115911
+ const tokenValue = typeof params.token === "function" ? await params.token() : params.token;
115912
+ const headers = { "X-Authorization": `Bearer ${tokenValue}`, "Content-Type": "application/json" };
115913
+ const api = async (method, path, body, okStatuses = []) => {
115914
+ const res = await doFetch(`${base}${path}`, {
115915
+ method,
115916
+ headers,
115917
+ body: body === void 0 ? void 0 : JSON.stringify(body)
115918
+ });
115919
+ if (!res.ok && !okStatuses.includes(res.status)) {
115920
+ const text3 = await res.text().catch(() => "");
115921
+ throw new ManualDeviceError(`Falha na API (${res.status}).`, `${method} ${path} \u2192 ${res.status} ${text3.slice(0, 200)}`);
115922
+ }
115923
+ const text2 = await res.text().catch(() => "");
115924
+ return text2 ? JSON.parse(text2) : null;
115925
+ };
115926
+ const cid = encodeURIComponent(params.customerId);
115927
+ const assets = await api("GET", `/api/customer/${cid}/assets?pageSize=100&page=0&textSearch=MANUAIS`);
115928
+ const asset = (assets?.data || []).find(
115929
+ (a) => String(a?.name || "").toUpperCase().endsWith(MANUAL_ASSET_SUFFIX)
115930
+ );
115931
+ if (!asset) {
115932
+ throw new ManualDeviceError(
115933
+ "Local de dispositivos manuais n\xE3o configurado para este shopping.",
115934
+ `nenhum asset do customer termina em ${MANUAL_ASSET_SUFFIX}`
115935
+ );
115936
+ }
115937
+ const sigla = siglaFromManualAsset(asset.name);
115938
+ if (!sigla) {
115939
+ throw new ManualDeviceError(
115940
+ "Local de dispositivos manuais n\xE3o configurado para este shopping.",
115941
+ `n\xE3o foi poss\xEDvel extrair a sigla de "${asset.name}"`
115942
+ );
115943
+ }
115944
+ const existing = await api(
115945
+ "GET",
115946
+ `/api/customer/${cid}/devices?pageSize=1000&page=0&textSearch=${encodeURIComponent(`${sigla}_LOJA_`)}`
115947
+ );
115948
+ const existingNames = (existing?.data || []).map((d) => String(d?.name || ""));
115949
+ let seq = nextManualSeq(domain, sigla, existingNames);
115950
+ let deviceProfileId;
115951
+ try {
115952
+ const profiles = await api("GET", `/api/deviceProfileInfos?pageSize=50&page=0&textSearch=${encodeURIComponent(profile)}`);
115953
+ const p = (profiles?.data || []).find((x) => x?.name === profile);
115954
+ if (p?.id?.id) deviceProfileId = { id: p.id.id, entityType: "DEVICE_PROFILE" };
115955
+ } catch {
115956
+ }
115957
+ let name = manualDeviceName(domain, sigla, seq);
115958
+ let created = null;
115959
+ for (let attempt = 0; ; attempt++) {
115960
+ try {
115961
+ created = await api("POST", "/api/device", {
115962
+ name,
115963
+ label,
115964
+ ...deviceProfileId ? { deviceProfileId } : { type: profile },
115965
+ customerId: { id: params.customerId, entityType: "CUSTOMER" }
115966
+ });
115967
+ break;
115968
+ } catch (err) {
115969
+ const dup = /already exists|já existe/i.test(err?.detail || "");
115970
+ if (!dup || attempt >= 4) throw err;
115971
+ seq += 1;
115972
+ name = manualDeviceName(domain, sigla, seq);
115973
+ }
115974
+ }
115975
+ const deviceId = created?.id?.id;
115976
+ if (!deviceId) throw new ManualDeviceError("O dispositivo n\xE3o foi criado.", "POST /api/device sem id na resposta");
115977
+ try {
115978
+ if (created?.customerId?.id !== params.customerId) {
115979
+ try {
115980
+ await api("POST", `/api/owner/CUSTOMER/${cid}/DEVICE/${deviceId}`);
115981
+ } catch {
115982
+ await api("POST", `/api/customer/${cid}/device/${deviceId}`);
115983
+ }
115984
+ }
115985
+ await api("POST", "/api/relation", {
115986
+ from: { id: asset.id.id, entityType: "ASSET" },
115987
+ to: { id: deviceId, entityType: "DEVICE" },
115988
+ type: "Contains",
115989
+ typeGroup: "COMMON"
115990
+ });
115991
+ await api("POST", `/api/plugins/telemetry/DEVICE/${deviceId}/attributes/SERVER_SCOPE`, {
115992
+ deviceProfile: profile,
115993
+ identifier
115994
+ });
115995
+ } catch (err) {
115996
+ await api("DELETE", `/api/device/${deviceId}`).catch(() => void 0);
115997
+ throw err;
115998
+ }
115999
+ return { deviceId, name, label, identifier, deviceProfile: profile, assetId: asset.id.id, assetName: asset.name };
116000
+ }
116001
+
116002
+ // src/components/premium-modals/manual-device/openManualDeviceModal.ts
116003
+ var DOMAIN_TEXT2 = {
116004
+ energy: { title: "Novo medidor de energia manual", icon: "\u26A1", noun: "Medidor de energia" },
116005
+ water: { title: "Novo hidr\xF4metro manual", icon: "\u{1F4A7}", noun: "Hidr\xF4metro" }
116006
+ };
116007
+ var STYLE_ID15 = "myio-manualdev-styles";
116008
+ function escapeHtml14(v) {
116009
+ return String(v ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
116010
+ }
116011
+ function injectStyles15() {
116012
+ if (document.getElementById(STYLE_ID15)) return;
116013
+ const style = document.createElement("style");
116014
+ style.id = STYLE_ID15;
116015
+ style.textContent = `
116016
+ .myio-manualdev { display: flex; flex-direction: column; gap: 16px; }
116017
+ .myio-manualdev__hint { margin: 0; font-size: 13px; color: #6b7280; line-height: 1.5; }
116018
+ .myio-manualdev__field { display: flex; flex-direction: column; gap: 6px; }
116019
+ .myio-manualdev__label { font-size: 14px; font-weight: 500; color: #333; }
116020
+ .myio-manualdev__input {
116021
+ font-family: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid #ddd;
116022
+ border-radius: 6px; outline: none; color: #111827; background: #fff; box-sizing: border-box; width: 100%;
116023
+ }
116024
+ .myio-manualdev__input:focus { border-color: var(--myio-brand-700, #3e1a7d); box-shadow: 0 0 0 3px rgba(62, 26, 125, 0.12); }
116025
+ .myio-manualdev__input[aria-invalid="true"] { border-color: #dc3545; }
116026
+ .myio-manualdev__input:disabled { background: #f8f9fa; color: #6c757d; }
116027
+ .myio-manualdev__type {
116028
+ display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
116029
+ font-size: 12px; font-weight: 600; color: #3e1a7d; background: #f1ecfa;
116030
+ padding: 4px 10px; border-radius: 999px;
116031
+ }
116032
+ .myio-manualdev__error {
116033
+ margin: 0; font-size: 13px; color: #991b1b; background: #fee2e2; border-radius: 6px; padding: 8px 10px;
116034
+ }
116035
+ .myio-manualdev__detail { display: block; margin-top: 4px; font-size: 11.5px; color: #7f1d1d; opacity: 0.85; word-break: break-word; }
116036
+ .myio-manualdev__ok { text-align: center; padding: 4px 0; }
116037
+ .myio-manualdev__ok-icon { font-size: 34px; line-height: 1; }
116038
+ .myio-manualdev__ok-title { margin: 8px 0 4px; font-size: 16px; font-weight: 700; color: #065f46; }
116039
+ .myio-manualdev__ok-text { margin: 0; font-size: 13px; color: #4b5563; }
116040
+ .myio-manualdev__tech {
116041
+ margin-top: 12px; text-align: left; font-size: 11.5px; color: #6b7280; background: #f9fafb;
116042
+ border: 1px dashed #e5e7eb; border-radius: 6px; padding: 8px 10px; line-height: 1.6;
116043
+ }
116044
+ .myio-manualdev__tech code { font-size: 11.5px; color: #374151; }
116045
+ `;
116046
+ document.head.appendChild(style);
116047
+ }
116048
+ function formHtml(domain, values, error, detail) {
116049
+ const t = DOMAIN_TEXT2[domain];
116050
+ return `
116051
+ <form class="myio-manualdev" novalidate>
116052
+ <p class="myio-manualdev__hint">Cadastre um ponto de leitura manual. Ele aparece nesta lista e n\xE3o entra nos totais nem nos relat\xF3rios.</p>
116053
+ <span class="myio-manualdev__type">${t.icon} ${escapeHtml14(t.noun)} manual</span>
116054
+ <label class="myio-manualdev__field">
116055
+ <span class="myio-manualdev__label">Etiqueta</span>
116056
+ <input class="myio-manualdev__input" name="label" maxlength="80" autocomplete="off"
116057
+ placeholder="Ex.: Burger King" value="${escapeHtml14(values.label)}" />
116058
+ </label>
116059
+ <label class="myio-manualdev__field">
116060
+ <span class="myio-manualdev__label">Identificador</span>
116061
+ <input class="myio-manualdev__input" name="identifier" maxlength="40" autocomplete="off"
116062
+ placeholder="Ex.: STB01010" value="${escapeHtml14(values.identifier)}" />
116063
+ </label>
116064
+ ${error ? `<p class="myio-manualdev__error" role="alert">${escapeHtml14(error)}${detail ? `<small class="myio-manualdev__detail">${escapeHtml14(detail)}</small>` : ""}</p>` : ""}
116065
+ <button type="submit" hidden></button>
116066
+ </form>`;
116067
+ }
116068
+ function successHtml(domain, r, tech) {
116069
+ return `
116070
+ <div class="myio-manualdev__ok">
116071
+ <div class="myio-manualdev__ok-icon">\u2705</div>
116072
+ <p class="myio-manualdev__ok-title">${escapeHtml14(DOMAIN_TEXT2[domain].noun)} criado</p>
116073
+ <p class="myio-manualdev__ok-text"><strong>${escapeHtml14(r.label)}</strong> \xB7 ${escapeHtml14(r.identifier)}</p>
116074
+ ${tech ? `<div class="myio-manualdev__tech">
116075
+ device <code>${escapeHtml14(r.name)}</code><br/>
116076
+ profile <code>${escapeHtml14(r.deviceProfile)}</code><br/>
116077
+ asset <code>${escapeHtml14(r.assetName)}</code><br/>
116078
+ id <code>${escapeHtml14(r.deviceId)}</code>
116079
+ </div>` : ""}
116080
+ </div>`;
116081
+ }
116082
+ function openManualDeviceModal(params) {
116083
+ const domain = params.domain;
116084
+ if (!MANUAL_DEVICE_PROFILES[domain]) throw new Error(`[openManualDeviceModal] dom\xEDnio inv\xE1lido: ${domain}`);
116085
+ injectStyles15();
116086
+ const values = { label: "", identifier: "" };
116087
+ let busy = false;
116088
+ let created = null;
116089
+ const modal = openStandardModal({
116090
+ title: DOMAIN_TEXT2[domain].title,
116091
+ icon: DOMAIN_TEXT2[domain].icon,
116092
+ bodyHtml: formHtml(domain, values),
116093
+ width: 460,
116094
+ container: params.container,
116095
+ buttons: [
116096
+ { label: "Cancelar", value: "cancel", variant: "secondary" },
116097
+ { label: "Criar", value: "create", variant: "primary", closeOnClick: false }
116098
+ ],
116099
+ onButton: (v) => {
116100
+ if (v !== "create") return;
116101
+ if (created) {
116102
+ const r = created;
116103
+ modal.close();
116104
+ params.onCreated?.(r);
116105
+ } else {
116106
+ void submit();
116107
+ }
116108
+ }
116109
+ });
116110
+ const bindForm = (focus = true) => {
116111
+ const form = modal.getBodyEl().querySelector("form");
116112
+ form?.addEventListener("submit", (e) => {
116113
+ e.preventDefault();
116114
+ void submit();
116115
+ });
116116
+ if (focus) form?.querySelector('input[name="label"]')?.focus();
116117
+ };
116118
+ bindForm();
116119
+ async function submit() {
116120
+ if (busy || created) return;
116121
+ const body = modal.getBodyEl();
116122
+ values.label = (body.querySelector('input[name="label"]')?.value || "").trim();
116123
+ values.identifier = (body.querySelector('input[name="identifier"]')?.value || "").trim();
116124
+ const missing = !values.label ? "label" : !values.identifier ? "identifier" : null;
116125
+ if (missing) {
116126
+ modal.setBodyHtml(formHtml(domain, values, missing === "label" ? "Informe a etiqueta." : "Informe o identificador."));
116127
+ bindForm(false);
116128
+ const input = body.querySelector(`input[name="${missing}"]`);
116129
+ input?.setAttribute("aria-invalid", "true");
116130
+ input?.focus();
116131
+ return;
116132
+ }
116133
+ busy = true;
116134
+ modal.setButton("create", { disabled: true, label: "Criando\u2026" });
116135
+ modal.setButton("cancel", { disabled: true });
116136
+ body.querySelectorAll("input").forEach((i) => i.disabled = true);
116137
+ try {
116138
+ created = await createManualDevice({ ...params, label: values.label, identifier: values.identifier });
116139
+ modal.setBodyHtml(successHtml(domain, created, !!params.showTechnicalDetails));
116140
+ modal.setButton("cancel", { hidden: true });
116141
+ modal.setButton("create", { disabled: false, label: "Concluir" });
116142
+ } catch (err) {
116143
+ const msg = err instanceof ManualDeviceError ? err.message : "N\xE3o foi poss\xEDvel criar o dispositivo.";
116144
+ const detail = params.showTechnicalDetails ? (err instanceof ManualDeviceError ? err.detail : String(err?.message || err)) || void 0 : void 0;
116145
+ modal.setBodyHtml(formHtml(domain, values, msg, detail));
116146
+ bindForm();
116147
+ modal.setButton("create", { disabled: false, label: "Criar" });
116148
+ modal.setButton("cancel", { disabled: false });
116149
+ } finally {
116150
+ busy = false;
116151
+ }
116152
+ }
116153
+ return modal;
116154
+ }
116155
+
114713
116156
  // src/components/myio-gcdr-login/dom.ts
114714
116157
  function h2(doc, tag, attrs = {}, ...children) {
114715
116158
  const el2 = doc.createElement(tag);
@@ -116794,22 +118237,22 @@ function openMyioGcdrLoginModal(options) {
116794
118237
  }
116795
118238
 
116796
118239
  // src/components/img-gallery/ScrollableTabs.ts
116797
- var STYLE_ID13 = "myio-tabs-styles";
116798
- var FONT_LINK_ID3 = "myio-dialog-font-nunito";
116799
- function escapeHtml12(value) {
118240
+ var STYLE_ID16 = "myio-tabs-styles";
118241
+ var FONT_LINK_ID4 = "myio-dialog-font-nunito";
118242
+ function escapeHtml15(value) {
116800
118243
  return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
116801
118244
  }
116802
- function injectStyles13() {
116803
- if (!document.getElementById(FONT_LINK_ID3)) {
118245
+ function injectStyles16() {
118246
+ if (!document.getElementById(FONT_LINK_ID4)) {
116804
118247
  const link = document.createElement("link");
116805
- link.id = FONT_LINK_ID3;
118248
+ link.id = FONT_LINK_ID4;
116806
118249
  link.rel = "stylesheet";
116807
118250
  link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
116808
118251
  document.head.appendChild(link);
116809
118252
  }
116810
- if (document.getElementById(STYLE_ID13)) return;
118253
+ if (document.getElementById(STYLE_ID16)) return;
116811
118254
  const style = document.createElement("style");
116812
- style.id = STYLE_ID13;
118255
+ style.id = STYLE_ID16;
116813
118256
  style.textContent = `
116814
118257
  .myio-tabs {
116815
118258
  display: flex;
@@ -116884,7 +118327,7 @@ function createScrollableTabs(options) {
116884
118327
  if (typeof document === "undefined") {
116885
118328
  throw new Error("[createScrollableTabs] requires a browser environment");
116886
118329
  }
116887
- injectStyles13();
118330
+ injectStyles16();
116888
118331
  const theme = options.theme ?? "light";
116889
118332
  const accent = options.accent ?? "#7C3AED";
116890
118333
  const showArrows = options.showArrows ?? "auto";
@@ -116932,7 +118375,7 @@ function createScrollableTabs(options) {
116932
118375
  btn.setAttribute("role", "tab");
116933
118376
  btn.dataset.key = t.key;
116934
118377
  if (t.disabled) btn.disabled = true;
116935
- btn.innerHTML = `${t.icon ? `<span aria-hidden="true">${t.icon}</span>` : ""}<span>${escapeHtml12(t.label)}</span>`;
118378
+ btn.innerHTML = `${t.icon ? `<span aria-hidden="true">${t.icon}</span>` : ""}<span>${escapeHtml15(t.label)}</span>`;
116936
118379
  styleTab(btn, t.key === active);
116937
118380
  btn.addEventListener("click", () => {
116938
118381
  if (t.disabled || t.key === active) return;
@@ -117017,23 +118460,23 @@ function createScrollableTabs(options) {
117017
118460
  }
117018
118461
 
117019
118462
  // src/components/img-gallery/ImgGallery.ts
117020
- var STYLE_ID14 = "myio-gallery-styles";
117021
- var FONT_LINK_ID4 = "myio-dialog-font-nunito";
117022
- function escapeHtml13(value) {
118463
+ var STYLE_ID17 = "myio-gallery-styles";
118464
+ var FONT_LINK_ID5 = "myio-dialog-font-nunito";
118465
+ function escapeHtml16(value) {
117023
118466
  return String(value == null ? "" : value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
117024
118467
  }
117025
118468
  var PRM = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
117026
- function injectStyles14() {
117027
- if (!document.getElementById(FONT_LINK_ID4)) {
118469
+ function injectStyles17() {
118470
+ if (!document.getElementById(FONT_LINK_ID5)) {
117028
118471
  const link = document.createElement("link");
117029
- link.id = FONT_LINK_ID4;
118472
+ link.id = FONT_LINK_ID5;
117030
118473
  link.rel = "stylesheet";
117031
118474
  link.href = "https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap";
117032
118475
  document.head.appendChild(link);
117033
118476
  }
117034
- if (document.getElementById(STYLE_ID14)) return;
118477
+ if (document.getElementById(STYLE_ID17)) return;
117035
118478
  const style = document.createElement("style");
117036
- style.id = STYLE_ID14;
118479
+ style.id = STYLE_ID17;
117037
118480
  style.textContent = `
117038
118481
  .myio-gallery {
117039
118482
  font-family: 'Nunito', system-ui, sans-serif;
@@ -117192,7 +118635,7 @@ function createImgGallery(options) {
117192
118635
  if (typeof document === "undefined") {
117193
118636
  throw new Error("[createImgGallery] requires a browser environment");
117194
118637
  }
117195
- injectStyles14();
118638
+ injectStyles17();
117196
118639
  const locale = options.locale === "en-US" ? "en-US" : "pt-BR";
117197
118640
  const theme = options.theme ?? "light";
117198
118641
  const accent = options.accent ?? "#7C3AED";
@@ -117243,10 +118686,10 @@ function createImgGallery(options) {
117243
118686
  root.appendChild(grid);
117244
118687
  function detailsHtml(img) {
117245
118688
  const lines = [];
117246
- if (img.filename) lines.push(`<span title="${escapeHtml13(img.filename)}">${escapeHtml13(img.filename)}</span>`);
117247
- if (typeof img.sizeBytes === "number") lines.push(`<span>${escapeHtml13(formatSize(img.sizeBytes))}</span>`);
118689
+ if (img.filename) lines.push(`<span title="${escapeHtml16(img.filename)}">${escapeHtml16(img.filename)}</span>`);
118690
+ if (typeof img.sizeBytes === "number") lines.push(`<span>${escapeHtml16(formatSize(img.sizeBytes))}</span>`);
117248
118691
  const dims = typeof img.width === "number" && typeof img.height === "number" ? `${img.width} \xD7 ${img.height}px` : "";
117249
- lines.push(`<span data-dims>${escapeHtml13(dims)}</span>`);
118692
+ lines.push(`<span data-dims>${escapeHtml16(dims)}</span>`);
117250
118693
  return lines.join("");
117251
118694
  }
117252
118695
  function renderDescription(body, img, index) {
@@ -130831,7 +132274,7 @@ var MODAL_CSS2 = `
130831
132274
  background: rgba(255, 255, 255, 0.2);
130832
132275
  }
130833
132276
  `;
130834
- function injectStyles15() {
132277
+ function injectStyles18() {
130835
132278
  if (document.getElementById(CSS_ID5)) return;
130836
132279
  const style = document.createElement("style");
130837
132280
  style.id = CSS_ID5;
@@ -130848,7 +132291,7 @@ var FilterModalComponent = class {
130848
132291
  showDeviceGrid;
130849
132292
  deviceSearchQuery = "";
130850
132293
  constructor(options) {
130851
- injectStyles15();
132294
+ injectStyles18();
130852
132295
  this.options = options;
130853
132296
  this.themeMode = options.themeMode || "light";
130854
132297
  this.selectedCategories = new Set(
@@ -131752,7 +133195,7 @@ function createCustomerCardV1(params) {
131752
133195
  }
131753
133196
 
131754
133197
  // src/components/cards/customer-goals/v1.0.0/styles.ts
131755
- var STYLE_ID15 = "myio-customer-goals-card-css";
133198
+ var STYLE_ID18 = "myio-customer-goals-card-css";
131756
133199
  var CSS4 = `
131757
133200
  .myio-cgc{
131758
133201
  --cgc-surface:#ffffff;
@@ -131853,9 +133296,9 @@ var CSS4 = `
131853
133296
  `;
131854
133297
  function injectCustomerGoalsCardStyles() {
131855
133298
  if (typeof document === "undefined") return;
131856
- if (document.getElementById(STYLE_ID15)) return;
133299
+ if (document.getElementById(STYLE_ID18)) return;
131857
133300
  const tag = document.createElement("style");
131858
- tag.id = STYLE_ID15;
133301
+ tag.id = STYLE_ID18;
131859
133302
  tag.textContent = CSS4;
131860
133303
  document.head.appendChild(tag);
131861
133304
  }
@@ -134705,7 +136148,7 @@ var WATER_FIXTURES = {
134705
136148
  var DEFAULT_FIXTURES = ENERGY_FIXTURES;
134706
136149
 
134707
136150
  // src/components/metas-guide/openMetasGuide.ts
134708
- var STYLE_ID16 = "myio-metas-guide-styles";
136151
+ var STYLE_ID19 = "myio-metas-guide-styles";
134709
136152
  var ROOT_ID = "myio-metas-guide-root";
134710
136153
  var FALLBACK_THEME = {
134711
136154
  accent: "#6c5ce7",
@@ -134713,7 +136156,7 @@ var FALLBACK_THEME = {
134713
136156
  accentText: "#ffffff",
134714
136157
  mode: "light"
134715
136158
  };
134716
- function escapeHtml14(value) {
136159
+ function escapeHtml17(value) {
134717
136160
  return String(value ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
134718
136161
  }
134719
136162
  var nfInt = new Intl.NumberFormat("pt-BR", { maximumFractionDigits: 0 });
@@ -134741,7 +136184,7 @@ function legendHtml() {
134741
136184
  [SERIES_COLORS.orcado, "Or\xE7ado"]
134742
136185
  ];
134743
136186
  return `<div class="myio-mg-legend">${items.map(
134744
- ([c, l]) => `<span class="myio-mg-legend__item"><span class="myio-mg-legend__dot" style="background:${c}" aria-hidden="true"></span>${escapeHtml14(
136187
+ ([c, l]) => `<span class="myio-mg-legend__item"><span class="myio-mg-legend__dot" style="background:${c}" aria-hidden="true"></span>${escapeHtml17(
134745
136188
  l
134746
136189
  )}</span>`
134747
136190
  ).join("")}</div>`;
@@ -134781,7 +136224,7 @@ function miniChartSvg(s) {
134781
136224
  const pts = data.map((v, i) => `${(i * bandW + bandW / 2).toFixed(1)},${y(v).toFixed(1)}`).join(" ");
134782
136225
  return `<polyline points="${pts}" fill="none" stroke="${color}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"></polyline>`;
134783
136226
  };
134784
- return `<svg class="myio-mg-chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Gr\xE1fico ilustrativo de ${escapeHtml14(
136227
+ return `<svg class="myio-mg-chart" viewBox="0 0 ${W} ${H}" role="img" aria-label="Gr\xE1fico ilustrativo de ${escapeHtml17(
134785
136228
  s.name
134786
136229
  )}" preserveAspectRatio="none">
134787
136230
  ${bars}
@@ -134798,8 +136241,8 @@ function kpiRowHtml(s, unit) {
134798
136241
  ];
134799
136242
  return `<div class="myio-mg-kpis">${kpis.map(
134800
136243
  ([label, val, color]) => `<div class="myio-mg-kpi">
134801
- <span class="myio-mg-kpi__label" style="color:${color}">${escapeHtml14(label)}</span>
134802
- <span class="myio-mg-kpi__value">${fmtInt(val)} <small>${escapeHtml14(unit)}</small></span>
136244
+ <span class="myio-mg-kpi__label" style="color:${color}">${escapeHtml17(label)}</span>
136245
+ <span class="myio-mg-kpi__value">${fmtInt(val)} <small>${escapeHtml17(unit)}</small></span>
134803
136246
  </div>`
134804
136247
  ).join("")}</div>`;
134805
136248
  }
@@ -134807,7 +136250,7 @@ function chipsHtml(s) {
134807
136250
  const c = computeChips(s);
134808
136251
  const chip = (label, ratio) => {
134809
136252
  const cls = ratio > 0 ? "is-up" : ratio < 0 ? "is-down" : "is-flat";
134810
- return `<span class="myio-mg-chip ${cls}">${escapeHtml14(label)} <strong>${escapeHtml14(
136253
+ return `<span class="myio-mg-chip ${cls}">${escapeHtml17(label)} <strong>${escapeHtml17(
134811
136254
  fmtPct4(ratio)
134812
136255
  )}</strong></span>`;
134813
136256
  };
@@ -134822,7 +136265,7 @@ function miniCardHtml(s, unit, opts) {
134822
136265
  const showKpis = opts?.kpis !== false;
134823
136266
  const showChips = opts?.chips !== false;
134824
136267
  return `<div class="myio-mg-card">
134825
- <h5 class="myio-mg-card__title">${escapeHtml14(s.name)}</h5>
136268
+ <h5 class="myio-mg-card__title">${escapeHtml17(s.name)}</h5>
134826
136269
  ${showChart ? legendHtml() + miniChartSvg(s) : ""}
134827
136270
  ${showKpis ? kpiRowHtml(s, unit) : ""}
134828
136271
  ${showChips ? chipsHtml(s) : ""}
@@ -134832,7 +136275,7 @@ function miniSidebarHtml(shoppings, unit, prevY, curY) {
134832
136275
  const total = deriveTotal({ shoppings });
134833
136276
  const row = (name, a, r, o, m, isTotal) => `
134834
136277
  <div class="myio-mg-side__row${isTotal ? " is-total" : ""}">
134835
- <span class="myio-mg-side__name">${escapeHtml14(name)}</span>
136278
+ <span class="myio-mg-side__name">${escapeHtml17(name)}</span>
134836
136279
  <span class="myio-mg-side__vals">
134837
136280
  <b style="color:${SERIES_COLORS.aMinus1}">${fmtInt(a)}</b>
134838
136281
  <b style="color:${SERIES_COLORS.realizado}">${fmtInt(r)}</b>
@@ -134843,7 +136286,7 @@ function miniSidebarHtml(shoppings, unit, prevY, curY) {
134843
136286
  return `<div class="myio-mg-side">
134844
136287
  <div class="myio-mg-side__head">
134845
136288
  <span>Resumo por shopping</span>
134846
- <span class="myio-mg-side__unit">${escapeHtml14(unit)}</span>
136289
+ <span class="myio-mg-side__unit">${escapeHtml17(unit)}</span>
134847
136290
  </div>
134848
136291
  <div class="myio-mg-side__cols">
134849
136292
  <span>Shopping</span>
@@ -134870,10 +136313,10 @@ function miniToolbarHtml(prevY, curY, highlight) {
134870
136313
  </div>`;
134871
136314
  }
134872
136315
  function bannerHtml(text2) {
134873
- return `<p class="myio-mg-banner">${escapeHtml14(text2)}</p>`;
136316
+ return `<p class="myio-mg-banner">${escapeHtml17(text2)}</p>`;
134874
136317
  }
134875
136318
  function paras(sentences) {
134876
- return `<div class="myio-mg-copy">${sentences.map((s) => `<p>${escapeHtml14(s)}</p>`).join("")}</div>`;
136319
+ return `<div class="myio-mg-copy">${sentences.map((s) => `<p>${escapeHtml17(s)}</p>`).join("")}</div>`;
134877
136320
  }
134878
136321
  function buildSections(ctx) {
134879
136322
  const { energy, water, curY, prevY } = ctx;
@@ -134898,8 +136341,8 @@ function buildSections(ctx) {
134898
136341
  "A r\xE9gua da meta muda por dom\xEDnio: em Energia a refer\xEAncia \xE9 a ENTRADA; em \xC1gua, os hidr\xF4metros.",
134899
136342
  "Os n\xFAmeros e a unidade de cada card acompanham o dom\xEDnio selecionado."
134900
136343
  ]) + miniToolbarHtml(prevY, curY, "domain") + `<div class="myio-mg-two">
134901
- <div><div class="myio-mg-two__tag">\u26A1 Energia \xB7 ${escapeHtml14(energy.unit)}</div>${miniCardHtml(e0, energy.unit, { chips: false })}</div>
134902
- <div><div class="myio-mg-two__tag">\u{1F4A7} \xC1gua \xB7 ${escapeHtml14(water.unit)}</div>${miniCardHtml(w0, water.unit, { chips: false })}</div>
136344
+ <div><div class="myio-mg-two__tag">\u26A1 Energia \xB7 ${escapeHtml17(energy.unit)}</div>${miniCardHtml(e0, energy.unit, { chips: false })}</div>
136345
+ <div><div class="myio-mg-two__tag">\u{1F4A7} \xC1gua \xB7 ${escapeHtml17(water.unit)}</div>${miniCardHtml(w0, water.unit, { chips: false })}</div>
134903
136346
  </div>`
134904
136347
  },
134905
136348
  {
@@ -134970,7 +136413,7 @@ function buildSections(ctx) {
134970
136413
  ]) + `<div class="myio-mg-order">
134971
136414
  <span class="myio-mg-order__btn">Data de Inaugura\xE7\xE3o \u2191 \xB7 \u2699\uFE0F</span>
134972
136415
  <span class="myio-mg-order__btn">\u25BD Filtros</span>
134973
- </div><ul class="myio-mg-order__list">${energy.shoppings.slice().sort((a, b) => a.inaugurationDate.localeCompare(b.inaugurationDate)).map((s) => `<li><b>${escapeHtml14(s.name)}</b> <span>inaugurado em ${escapeHtml14(s.inaugurationDate)}</span></li>`).join("")}</ul>`
136416
+ </div><ul class="myio-mg-order__list">${energy.shoppings.slice().sort((a, b) => a.inaugurationDate.localeCompare(b.inaugurationDate)).map((s) => `<li><b>${escapeHtml17(s.name)}</b> <span>inaugurado em ${escapeHtml17(s.inaugurationDate)}</span></li>`).join("")}</ul>`
134974
136417
  },
134975
136418
  {
134976
136419
  id: "engine",
@@ -134998,10 +136441,10 @@ function buildSections(ctx) {
134998
136441
  }
134999
136442
  ];
135000
136443
  }
135001
- function injectStyles16() {
135002
- if (document.getElementById(STYLE_ID16)) return;
136444
+ function injectStyles19() {
136445
+ if (document.getElementById(STYLE_ID19)) return;
135003
136446
  const style = document.createElement("style");
135004
- style.id = STYLE_ID16;
136447
+ style.id = STYLE_ID19;
135005
136448
  style.textContent = `
135006
136449
  #${ROOT_ID}{position:fixed;inset:0;z-index:100001;display:flex;align-items:center;justify-content:center;padding:20px;background:rgba(15,23,42,.6);backdrop-filter:blur(4px);font-family:'Nunito',system-ui,sans-serif;}
135007
136450
  #${ROOT_ID} *{box-sizing:border-box;}
@@ -135100,7 +136543,7 @@ function openMetasGuide(options = {}) {
135100
136543
  const sections = buildSections({ energy, water, curY, prevY });
135101
136544
  const total = sections.length;
135102
136545
  document.getElementById(ROOT_ID)?.remove();
135103
- injectStyles16();
136546
+ injectStyles19();
135104
136547
  const previouslyFocused = document.activeElement;
135105
136548
  let index = 0;
135106
136549
  let closed = false;
@@ -135109,9 +136552,9 @@ function openMetasGuide(options = {}) {
135109
136552
  root.innerHTML = `
135110
136553
  <div class="myio-mg-modal${theme.mode === "dark" ? " is-dark" : ""}" role="dialog" aria-modal="true"
135111
136554
  aria-labelledby="myio-mg-title"
135112
- style="--mg-accent:${escapeHtml14(theme.accent)};--mg-accent-dark:${escapeHtml14(
136555
+ style="--mg-accent:${escapeHtml17(theme.accent)};--mg-accent-dark:${escapeHtml17(
135113
136556
  theme.accentDark
135114
- )};--mg-accent-text:${escapeHtml14(theme.accentText)};">
136557
+ )};--mg-accent-text:${escapeHtml17(theme.accentText)};">
135115
136558
  <div class="myio-mg-header">
135116
136559
  <div class="myio-mg-header__l">
135117
136560
  <span class="myio-mg-header__logo" aria-hidden="true">\u{1F393}</span>
@@ -138945,7 +140388,7 @@ var TELEMETRY_GRID_SHOPPING_STYLES = `
138945
140388
  text-overflow: ellipsis;
138946
140389
  }
138947
140390
  `;
138948
- function injectStyles17(_container) {
140391
+ function injectStyles20(_container) {
138949
140392
  const styleId = "telemetry-grid-shopping-styles";
138950
140393
  if (document.getElementById(styleId)) {
138951
140394
  return;
@@ -138993,7 +140436,7 @@ var TelemetryGridShoppingView = class {
138993
140436
  // Render
138994
140437
  // =========================================================================
138995
140438
  render() {
138996
- injectStyles17(this.root);
140439
+ injectStyles20(this.root);
138997
140440
  this.root.innerHTML = this.buildHTML();
138998
140441
  this.cacheElements();
138999
140442
  this.bindEvents();
@@ -140664,7 +142107,7 @@ var TELEMETRY_INFO_SHOPPING_STYLES = `
140664
142107
  }
140665
142108
  }
140666
142109
  `;
140667
- function injectStyles18(_container) {
142110
+ function injectStyles21(_container) {
140668
142111
  const styleId = "telemetry-info-shopping-styles-v2";
140669
142112
  if (document.getElementById(styleId)) {
140670
142113
  return;
@@ -140724,7 +142167,7 @@ var TelemetryInfoShoppingView = class _TelemetryInfoShoppingView {
140724
142167
  // Render
140725
142168
  // =========================================================================
140726
142169
  render() {
140727
- injectStyles18(this.root);
142170
+ injectStyles21(this.root);
140728
142171
  this.root.innerHTML = this.buildHTML();
140729
142172
  this.cacheElements();
140730
142173
  this.bindEvents();
@@ -148779,12 +150222,12 @@ var AlarmsNotificationsPanelView = class {
148779
150222
  }
148780
150223
  const badgeEl = this.root.querySelector("#alarmCountBadge");
148781
150224
  if (badgeEl) {
148782
- const openCount3 = state6.allAlarms.filter(
150225
+ const openCount4 = state6.allAlarms.filter(
148783
150226
  (a) => a.state === "OPEN" || a.state === "ESCALATED"
148784
150227
  ).length;
148785
- badgeEl.textContent = openCount3 > 99 ? "99+" : String(openCount3);
150228
+ badgeEl.textContent = openCount4 > 99 ? "99+" : String(openCount4);
148786
150229
  badgeEl.style.display = "inline-flex";
148787
- badgeEl.classList.toggle("is-zero", openCount3 === 0);
150230
+ badgeEl.classList.toggle("is-zero", openCount4 === 0);
148788
150231
  }
148789
150232
  const loadingOverlay = this.root.querySelector("#loadingOverlay");
148790
150233
  if (loadingOverlay) {
@@ -149105,10 +150548,10 @@ var AlarmsNotificationsPanelView = class {
149105
150548
  const renderListPanel = (group, items, sel) => {
149106
150549
  if (items.length === 0) return '<div class="afm-empty">Nenhum item encontrado</div>';
149107
150550
  return items.map((item) => {
149108
- const esc9 = this.esc(item);
150551
+ const esc10 = this.esc(item);
149109
150552
  return `<label class="afm-check-item">
149110
- <input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${esc9}"${sel.has(item) ? " checked" : ""}>
149111
- <span class="afm-check-label">${esc9}</span>
150553
+ <input type="checkbox" class="afm-checkbox" data-group="${group}" data-value="${esc10}"${sel.has(item) ? " checked" : ""}>
150554
+ <span class="afm-check-label">${esc10}</span>
149112
150555
  </label>`;
149113
150556
  }).join("");
149114
150557
  };
@@ -153207,8 +154650,8 @@ function renderDowntimeList(downtimeList) {
153207
154650
  <div class="downtime-item">
153208
154651
  <span class="rank">${index + 1}</span>
153209
154652
  <div class="item-info">
153210
- <span class="item-name">${escapeHtml15(item.name)}</span>
153211
- <span class="item-location">${escapeHtml15(item.location)}</span>
154653
+ <span class="item-name">${escapeHtml18(item.name)}</span>
154654
+ <span class="item-location">${escapeHtml18(item.location)}</span>
153212
154655
  </div>
153213
154656
  <div class="item-metrics">
153214
154657
  <span class="downtime-hours">${item.downtime}h</span>
@@ -153221,7 +154664,7 @@ function renderDowntimeList(downtimeList) {
153221
154664
  `
153222
154665
  ).join("");
153223
154666
  }
153224
- function escapeHtml15(text2) {
154667
+ function escapeHtml18(text2) {
153225
154668
  const div = document.createElement("div");
153226
154669
  div.textContent = text2;
153227
154670
  return div.innerHTML;
@@ -157804,7 +159247,7 @@ function removeSchedulingSharedStyles() {
157804
159247
  }
157805
159248
 
157806
159249
  // src/components/scheduling-shared/view-helpers.ts
157807
- function escapeHtml16(str) {
159250
+ function escapeHtml19(str) {
157808
159251
  const div = document.createElement("div");
157809
159252
  div.textContent = str;
157810
159253
  return div.innerHTML;
@@ -157965,7 +159408,7 @@ function showConfirmModal(container, title, message) {
157965
159408
  overlay.innerHTML = `
157966
159409
  <div class="${SCHED_CSS_PREFIX}__modal-backdrop"></div>
157967
159410
  <div class="${SCHED_CSS_PREFIX}__modal-content">
157968
- <h3>${escapeHtml16(title)}</h3>
159411
+ <h3>${escapeHtml19(title)}</h3>
157969
159412
  <p>${message}</p>
157970
159413
  <div class="${SCHED_CSS_PREFIX}__modal-actions">
157971
159414
  <button class="${SCHED_CSS_PREFIX}__modal-btn-cancel">Cancelar</button>
@@ -157999,8 +159442,8 @@ function showNotificationModal(container, type, message, autoCloseMs = 6e3) {
157999
159442
  overlay.innerHTML = `
158000
159443
  <div class="${SCHED_CSS_PREFIX}__modal-backdrop"></div>
158001
159444
  <div class="${SCHED_CSS_PREFIX}__modal-content">
158002
- <h3>${escapeHtml16(title)}</h3>
158003
- <p>${escapeHtml16(message)}</p>
159445
+ <h3>${escapeHtml19(title)}</h3>
159446
+ <p>${escapeHtml19(message)}</p>
158004
159447
  <div class="${SCHED_CSS_PREFIX}__modal-actions">
158005
159448
  <button class="${SCHED_CSS_PREFIX}__modal-btn-close">Fechar</button>
158006
159449
  </div>
@@ -159577,7 +161020,7 @@ var STYLES = `
159577
161020
  color: var(--dgv6-ink-2);
159578
161021
  }
159579
161022
  `;
159580
- function injectStyles19() {
161023
+ function injectStyles22() {
159581
161024
  if (document.getElementById(CSS_ID6)) return;
159582
161025
  const style = document.createElement("style");
159583
161026
  style.id = CSS_ID6;
@@ -159616,7 +161059,7 @@ var DeviceGridV6View = class {
159616
161059
  // Render
159617
161060
  // =========================================================================
159618
161061
  render() {
159619
- injectStyles19();
161062
+ injectStyles22();
159620
161063
  this.root.innerHTML = this.buildHTML();
159621
161064
  this.cacheElements();
159622
161065
  this.bindEvents();
@@ -161986,7 +163429,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
161986
163429
  const docTitle = buildActivationReportTitle(deviceName, opts.customerName);
161987
163430
  const issuedAt = formatIssuedAt(/* @__PURE__ */ new Date(), locale);
161988
163431
  const utilization = data.totalHours > 0 ? (data.totalOnMinutes / (data.totalHours * 60) * 100).toFixed(1) : "0.0";
161989
- const esc9 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
163432
+ const esc10 = (s) => String(s).replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
161990
163433
  const htmlContent = `
161991
163434
  <!DOCTYPE html>
161992
163435
  <html lang="pt-BR">
@@ -162038,14 +163481,14 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
162038
163481
  <div class="brand">MyIO BAS</div>
162039
163482
  <h1>Relat\xF3rio de Acionamentos</h1>
162040
163483
  <div class="meta">
162041
- <div><b>Dispositivo:</b> ${esc9(deviceName)}</div>
163484
+ <div><b>Dispositivo:</b> ${esc10(deviceName)}</div>
162042
163485
  <div><b>Per\xEDodo:</b> ${periodStart} \u2014 ${periodEnd}</div>
162043
163486
  </div>
162044
163487
  </div>
162045
163488
  ${customerName ? `
162046
163489
  <div class="customer-badge">
162047
163490
  <div class="label">Cliente</div>
162048
- <div class="value">${esc9(customerName)}</div>
163491
+ <div class="value">${esc10(customerName)}</div>
162049
163492
  </div>` : ""}
162050
163493
  </div>
162051
163494
 
@@ -162056,7 +163499,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
162056
163499
  </div>
162057
163500
  <div class="summary-card accent-green">
162058
163501
  <div class="summary-value">${formatDurationMinutes(data.totalOnMinutes)}</div>
162059
- <div class="summary-label">Tempo ${esc9(labelOn)}</div>
163502
+ <div class="summary-label">Tempo ${esc10(labelOn)}</div>
162060
163503
  </div>
162061
163504
  <div class="summary-card accent-amber">
162062
163505
  <div class="summary-value">${utilization}%</div>
@@ -162084,7 +163527,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
162084
163527
  <tr>
162085
163528
  <td>${formatDateForExport(seg.startTime, locale)}</td>
162086
163529
  <td>${formatDateForExport(seg.endTime, locale)}</td>
162087
- <td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ? esc9(labelOn) : esc9(labelOff)}</span></td>
163530
+ <td><span class="pill ${seg.state === "on" ? "pill-on" : "pill-off"}">${seg.state === "on" ? esc10(labelOn) : esc10(labelOff)}</span></td>
162088
163531
  <td>${formatDurationMinutes(seg.durationMinutes)}</td>
162089
163532
  <td>${seg.source === "manual" ? "Manual" : seg.source === "schedule" ? "Agendamento" : seg.source === "automation" ? "Automa\xE7\xE3o" : "Desconhecido"}</td>
162090
163533
  </tr>
@@ -162093,7 +163536,7 @@ function exportTimelineToPDF(data, labels = {}, locale = "pt-BR", opts = {}) {
162093
163536
  </table>
162094
163537
 
162095
163538
  <div class="footer">
162096
- <span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` &middot; ${esc9(customerName)}` : ""} &middot; <span class="brand">MyIO BAS</span>
163539
+ <span class="issued">Emitido em ${issuedAt}</span>${customerName ? ` &middot; ${esc10(customerName)}` : ""} &middot; <span class="brand">MyIO BAS</span>
162097
163540
  </div>
162098
163541
  </body>
162099
163542
  </html>
@@ -168083,7 +169526,7 @@ var STYLES2 = `
168083
169526
  }
168084
169527
  #${MODAL_ID5} .gcdr-fail-item:last-child { border-bottom: none; }
168085
169528
  `;
168086
- function injectStyles20() {
169529
+ function injectStyles23() {
168087
169530
  if (document.getElementById(`${MODAL_ID5}-styles`)) return;
168088
169531
  const style = document.createElement("style");
168089
169532
  style.id = `${MODAL_ID5}-styles`;
@@ -168192,7 +169635,7 @@ function escHtml4(str) {
168192
169635
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
168193
169636
  }
168194
169637
  async function openGCDRSyncModal(params) {
168195
- injectStyles20();
169638
+ injectStyles23();
168196
169639
  removeExistingModal();
168197
169640
  if (!params.thingsboardToken) {
168198
169641
  alert("Token ThingsBoard n\xE3o encontrado. Fa\xE7a login novamente.");
@@ -168765,7 +170208,7 @@ var STYLES3 = `
168765
170208
  .abm-confirm-btn--confirm { background: #e67e22; color: #fff; }
168766
170209
  .abm-confirm-btn--confirm:hover { background: #cf6d17; }
168767
170210
  `;
168768
- function injectStyles21() {
170211
+ function injectStyles24() {
168769
170212
  if (document.getElementById(`${MODAL_ID6}-styles`)) return;
168770
170213
  const style = document.createElement("style");
168771
170214
  style.id = `${MODAL_ID6}-styles`;
@@ -168884,7 +170327,7 @@ function openGranularValueEdit(ruleItem, rule, device, bundle, gcdrTenantId, bas
168884
170327
  const originalChipsHtml = detailEl.innerHTML;
168885
170328
  const baseRuleId = rule.parentRuleId ?? rule.id;
168886
170329
  const isOverride = !!rule.parentRuleId;
168887
- const formHtml = `
170330
+ const formHtml2 = `
168888
170331
  <div class="abm-edit-form">
168889
170332
  <div class="abm-ef-row">
168890
170333
  <span class="abm-ef-label">Valor</span>
@@ -168899,7 +170342,7 @@ function openGranularValueEdit(ruleItem, rule, device, bundle, gcdrTenantId, bas
168899
170342
  </div>
168900
170343
  </div>
168901
170344
  `;
168902
- detailEl.innerHTML = formHtml;
170345
+ detailEl.innerHTML = formHtml2;
168903
170346
  const form = detailEl.querySelector(".abm-edit-form");
168904
170347
  const valueInput = form.querySelector("#abm-ef-value");
168905
170348
  const valuePreview = form.querySelector("#abm-ef-value-preview");
@@ -168972,7 +170415,7 @@ function openFullRuleEdit(ruleItemOrDetail, rule, bundle, gcdrTenantId, baseUrl)
168972
170415
  const on = editDays[key] === true;
168973
170416
  return `<button class="abm-ef-day-btn ${on ? "on" : ""}" data-day-key="${key}" type="button">${label}</button>`;
168974
170417
  }).join("");
168975
- const formHtml = `
170418
+ const formHtml2 = `
168976
170419
  <div class="abm-edit-form">
168977
170420
  <div class="abm-ef-row" style="align-items:flex-start;">
168978
170421
  <span class="abm-ef-label">Descri\xE7\xE3o</span>
@@ -169002,7 +170445,7 @@ function openFullRuleEdit(ruleItemOrDetail, rule, bundle, gcdrTenantId, baseUrl)
169002
170445
  </div>
169003
170446
  </div>
169004
170447
  `;
169005
- detailEl.innerHTML = formHtml;
170448
+ detailEl.innerHTML = formHtml2;
169006
170449
  const form = detailEl.querySelector(".abm-edit-form");
169007
170450
  form.querySelectorAll(".abm-ef-day-btn").forEach((btn) => {
169008
170451
  btn.addEventListener("click", () => {
@@ -169444,7 +170887,7 @@ async function fetchBundle(customerTB_ID, gcdrTenantId, baseUrl) {
169444
170887
  return json.data;
169445
170888
  }
169446
170889
  async function openAlarmBundleMapModal(params) {
169447
- injectStyles21();
170890
+ injectStyles24();
169448
170891
  removeExistingModal2();
169449
170892
  if (!params.customerTB_ID) {
169450
170893
  alert("Customer TB ID n\xE3o informado. N\xE3o \xE9 poss\xEDvel carregar o mapa de alarmes.");
@@ -170614,11 +172057,11 @@ function _esc(s) {
170614
172057
  const str = s == null ? "" : String(s);
170615
172058
  return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
170616
172059
  }
170617
- var STYLE_ID17 = "ntw-styles";
172060
+ var STYLE_ID20 = "ntw-styles";
170618
172061
  function _injectStyles2() {
170619
- if (document.getElementById(STYLE_ID17)) return;
172062
+ if (document.getElementById(STYLE_ID20)) return;
170620
172063
  const s = document.createElement("style");
170621
- s.id = STYLE_ID17;
172064
+ s.id = STYLE_ID20;
170622
172065
  s.textContent = NTW_CSS;
170623
172066
  document.head.appendChild(s);
170624
172067
  }
@@ -173319,7 +174762,7 @@ var IMPORTANCE_COLORS4 = {
173319
174762
  // red
173320
174763
  };
173321
174764
  var ITEM_TEXT_MAX = 120;
173322
- function escapeHtml17(input) {
174765
+ function escapeHtml20(input) {
173323
174766
  if (input == null) return "";
173324
174767
  return String(input).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
173325
174768
  }
@@ -173357,24 +174800,24 @@ function renderAnnotationItemCard(device, annotation, searchTerm) {
173357
174800
  const domainIcon = DOMAIN_ICONS3[device.domain] ?? DOMAIN_ICONS3.unknown;
173358
174801
  const typeIcon = TYPE_ICONS[annotation.type] ?? "\xB7";
173359
174802
  const importance = Math.max(1, Math.min(5, annotation.importance || 1));
173360
- const textEscaped = escapeHtml17(truncate2(annotation.text || "", ITEM_TEXT_MAX));
173361
- const deviceLabelEscaped = escapeHtml17(device.label || device.name || device.deviceId);
173362
- const author = escapeHtml17(annotation.createdBy?.name || "sem autor");
173363
- const when = escapeHtml17(formatRelative(annotation.createdAt));
174803
+ const textEscaped = escapeHtml20(truncate2(annotation.text || "", ITEM_TEXT_MAX));
174804
+ const deviceLabelEscaped = escapeHtml20(device.label || device.name || device.deviceId);
174805
+ const author = escapeHtml20(annotation.createdBy?.name || "sem autor");
174806
+ const when = escapeHtml20(formatRelative(annotation.createdAt));
173364
174807
  const overdueTag = isOverdue(annotation) ? '<span class="myio-annotations-overdue">Vencida</span>' : "";
173365
174808
  const text2 = searchTerm ? highlightMatches(textEscaped, searchTerm) : textEscaped;
173366
174809
  const deviceLabel = searchTerm ? highlightMatches(deviceLabelEscaped, searchTerm) : deviceLabelEscaped;
173367
- const identifierEscaped = device.identifier ? escapeHtml17(device.identifier) : "";
174810
+ const identifierEscaped = device.identifier ? escapeHtml20(device.identifier) : "";
173368
174811
  const identifierHighlighted = searchTerm && identifierEscaped ? highlightMatches(identifierEscaped, searchTerm) : identifierEscaped;
173369
174812
  const identifierTag = device.identifier ? `<span class="myio-annotations-item-device">${identifierHighlighted}</span>` : "";
173370
174813
  return `
173371
174814
  <button
173372
174815
  class="myio-annotations-item"
173373
174816
  type="button"
173374
- data-device-id="${escapeHtml17(device.deviceId)}"
173375
- data-annotation-id="${escapeHtml17(annotation.id)}"
174817
+ data-device-id="${escapeHtml20(device.deviceId)}"
174818
+ data-annotation-id="${escapeHtml20(annotation.id)}"
173376
174819
  tabindex="0"
173377
- aria-label="${escapeHtml17(annotation.text)} \u2014 ${deviceLabel}"
174820
+ aria-label="${escapeHtml20(annotation.text)} \u2014 ${deviceLabel}"
173378
174821
  >
173379
174822
  <span class="myio-annotations-item-icon" aria-hidden="true">${typeIcon}</span>
173380
174823
  <div class="myio-annotations-item-body">
@@ -173581,7 +175024,7 @@ var STYLES4 = `
173581
175024
  background: #cbd5e1; border-color: #cbd5e1; cursor: not-allowed;
173582
175025
  }
173583
175026
  `;
173584
- function injectStyles22() {
175027
+ function injectStyles25() {
173585
175028
  if (typeof document === "undefined") return;
173586
175029
  if (document.getElementById(STYLES_ID4)) return;
173587
175030
  const el2 = document.createElement("style");
@@ -173591,7 +175034,7 @@ function injectStyles22() {
173591
175034
  }
173592
175035
  var _activeBackdrop = null;
173593
175036
  function openExportModal(options) {
173594
- injectStyles22();
175037
+ injectStyles25();
173595
175038
  closeExportModal();
173596
175039
  const backdrop = document.createElement("div");
173597
175040
  backdrop.className = `${MODAL_DOM_ID}-backdrop`;
@@ -174351,8 +175794,8 @@ var HeaderAnnotationsPanel = class _HeaderAnnotationsPanel {
174351
175794
  // group header
174352
175795
  render: () => `
174353
175796
  <header class="myio-annotations-group-header ${groupClass}">
174354
- ${g.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml17(g.icon)}</span>` : ""}
174355
- <span class="myio-annotations-group-label">${escapeHtml17(g.label)}</span>
175797
+ ${g.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml20(g.icon)}</span>` : ""}
175798
+ <span class="myio-annotations-group-label">${escapeHtml20(g.label)}</span>
174356
175799
  <span class="myio-annotations-group-count">${g.totalAnnotations}</span>
174357
175800
  </header>`
174358
175801
  });
@@ -174477,9 +175920,9 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
174477
175920
  }
174478
175921
  _renderToolbar(filteredCount, totalCount) {
174479
175922
  const sortOptions = SORT_OPTIONS.map(
174480
- (o) => `<option value="${o.key}" ${o.key === this.sortBy ? "selected" : ""}>${escapeHtml17(o.label)}</option>`
175923
+ (o) => `<option value="${o.key}" ${o.key === this.sortBy ? "selected" : ""}>${escapeHtml20(o.label)}</option>`
174481
175924
  ).join("");
174482
- const term = escapeHtml17(this.filter.searchTerm || "");
175925
+ const term = escapeHtml20(this.filter.searchTerm || "");
174483
175926
  const filtersActiveCount = this._activeFilterCount();
174484
175927
  const filterIndicator = filtersActiveCount > 0 ? `<span class="myio-annotations-group-count">${filtersActiveCount}</span>` : "";
174485
175928
  const showingHtml = filteredCount === totalCount ? `${totalCount} anota\xE7\xF5es` : `${filteredCount} de ${totalCount} anota\xE7\xF5es`;
@@ -174520,13 +175963,13 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
174520
175963
  const typesHtml = FILTER_TYPE_OPTIONS.map(
174521
175964
  (t) => `<label class="myio-annotations-filter-chip ${this.filter.types.has(t.id) ? "is-on" : ""}">
174522
175965
  <input type="checkbox" data-filter="type" value="${t.id}" ${this.filter.types.has(t.id) ? "checked" : ""} />
174523
- <span>${t.icon} ${escapeHtml17(t.label)}</span>
175966
+ <span>${t.icon} ${escapeHtml20(t.label)}</span>
174524
175967
  </label>`
174525
175968
  ).join("");
174526
175969
  const statusHtml = FILTER_STATUS_OPTIONS.map(
174527
175970
  (s) => `<label class="myio-annotations-filter-chip ${this.filter.statuses.has(s.id) ? "is-on" : ""}">
174528
175971
  <input type="checkbox" data-filter="status" value="${s.id}" ${this.filter.statuses.has(s.id) ? "checked" : ""} />
174529
- <span>${escapeHtml17(s.label)}</span>
175972
+ <span>${escapeHtml20(s.label)}</span>
174530
175973
  </label>`
174531
175974
  ).join("");
174532
175975
  const impHtml = [1, 2, 3, 4, 5].map(
@@ -174603,12 +176046,12 @@ ${this._renderToolbar(filteredCount, totalAllUnfiltered)}
174603
176046
  return `
174604
176047
  <section class="${groupClass}">
174605
176048
  <header class="myio-annotations-group-header" role="button" tabindex="0"
174606
- data-group-toggle="${escapeHtml17(group.key)}"
176049
+ data-group-toggle="${escapeHtml20(group.key)}"
174607
176050
  aria-expanded="${!isCollapsed}"
174608
176051
  title="${isCollapsed ? "Expandir grupo" : "Recolher grupo"}">
174609
176052
  <span class="myio-annotations-group-chevron" aria-hidden="true">${isCollapsed ? "\u25B6" : "\u25BC"}</span>
174610
- ${group.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml17(group.icon)}</span>` : ""}
174611
- <span class="myio-annotations-group-label">${escapeHtml17(group.label)}</span>
176053
+ ${group.icon ? `<span class="myio-annotations-group-icon" aria-hidden="true">${escapeHtml20(group.icon)}</span>` : ""}
176054
+ <span class="myio-annotations-group-label">${escapeHtml20(group.label)}</span>
174612
176055
  <span class="myio-annotations-group-count">${group.totalAnnotations}</span>
174613
176056
  </header>
174614
176057
  ${itemsHtml}
@@ -175150,7 +176593,7 @@ function prefixForProductType(productType) {
175150
176593
  if (entry) return entry.prefix;
175151
176594
  return `T${productType}`;
175152
176595
  }
175153
- function pad24(n) {
176596
+ function pad25(n) {
175154
176597
  return String(n).padStart(2, "0");
175155
176598
  }
175156
176599
  function pad4(n) {
@@ -175158,9 +176601,9 @@ function pad4(n) {
175158
176601
  }
175159
176602
  function deviceProductCodeToName(value) {
175160
176603
  const prefix = prefixForProductType(value.productType);
175161
- const yy = pad24(value.year % 100);
175162
- const mm = pad24(value.month);
175163
- const dd = pad24(value.day);
176604
+ const yy = pad25(value.year % 100);
176605
+ const mm = pad25(value.month);
176606
+ const dd = pad25(value.day);
175164
176607
  const unit = value.seq3 * 254 + value.seq;
175165
176608
  return `${prefix} ${yy}${mm}${dd}-${pad4(unit)}`;
175166
176609
  }
@@ -175269,7 +176712,7 @@ function validateDeviceProductCode(code) {
175269
176712
  }
175270
176713
 
175271
176714
  // src/components/cards/central-status/v1.0.0/styles.ts
175272
- var STYLE_ID18 = "myio-central-status-card-styles";
176715
+ var STYLE_ID21 = "myio-central-status-card-styles";
175273
176716
  var CSS5 = `
175274
176717
  .myio-cscard{
175275
176718
  --cscard-surface:#ffffff;
@@ -175572,9 +177015,9 @@ var CSS5 = `
175572
177015
  `;
175573
177016
  function injectCentralStatusCardStyles() {
175574
177017
  if (typeof document === "undefined") return;
175575
- if (document.getElementById(STYLE_ID18)) return;
177018
+ if (document.getElementById(STYLE_ID21)) return;
175576
177019
  const tag = document.createElement("style");
175577
- tag.id = STYLE_ID18;
177020
+ tag.id = STYLE_ID21;
175578
177021
  tag.textContent = CSS5;
175579
177022
  document.head.appendChild(tag);
175580
177023
  }
@@ -175634,7 +177077,7 @@ function deriveCentralConnectivity(ev, opts) {
175634
177077
  }
175635
177078
 
175636
177079
  // src/components/cards/central-status/v1.0.0/TimelineModal.ts
175637
- var STYLE_ID19 = "myio-cscard-timeline-styles";
177080
+ var STYLE_ID22 = "myio-cscard-timeline-styles";
175638
177081
  var DEFAULT_PERIODS = [1, 7, 30, 90];
175639
177082
  function escAttr5(s) {
175640
177083
  return String(s ?? "").replace(
@@ -175643,9 +177086,9 @@ function escAttr5(s) {
175643
177086
  );
175644
177087
  }
175645
177088
  function injectTimelineModalStyles() {
175646
- if (typeof document === "undefined" || document.getElementById(STYLE_ID19)) return;
177089
+ if (typeof document === "undefined" || document.getElementById(STYLE_ID22)) return;
175647
177090
  const tag = document.createElement("style");
175648
- tag.id = STYLE_ID19;
177091
+ tag.id = STYLE_ID22;
175649
177092
  tag.textContent = `
175650
177093
  .myio-tlmodal{
175651
177094
  --tl-online:#3b82f6;
@@ -176930,9 +178373,12 @@ var version = package_default.version || "0.0.0";
176930
178373
  IMPORTANCE_COLORS,
176931
178374
  IMPORTANCE_LABELS,
176932
178375
  IMPORTANCE_LABELS_EN,
178376
+ ImportApiError,
176933
178377
  InfoTooltip,
176934
178378
  LoadingSpinner,
176935
178379
  LogHelper,
178380
+ MANUAL_ASSET_SUFFIX,
178381
+ MANUAL_DEVICE_PROFILES,
176936
178382
  MEASUREMENT_DOMAIN_CONFIG,
176937
178383
  MENU_SHOPPING_CSS_PREFIX,
176938
178384
  METRO_TILE_COLORS,
@@ -176943,6 +178389,7 @@ var version = package_default.version || "0.0.0";
176943
178389
  MYIO_ACCENT,
176944
178390
  MYIO_CHART_PALETTE,
176945
178391
  MYIO_CHART_PALETTE_DARK,
178392
+ ManualDeviceError,
176946
178393
  MenuController,
176947
178394
  MenuShoppingView,
176948
178395
  MenuView,
@@ -177085,6 +178532,7 @@ var version = package_default.version || "0.0.0";
177085
178532
  buildMoneyVarianceHTML,
177086
178533
  buildMyioIngestionAuth,
177087
178534
  buildReportItemsList,
178535
+ buildTemplateCsv,
177088
178536
  buildTemplateExport,
177089
178537
  buildTicketServiceOrchestrator,
177090
178538
  buildVerdictHTML,
@@ -177184,6 +178632,7 @@ var version = package_default.version || "0.0.0";
177184
178632
  createLibraryVersionChecker,
177185
178633
  createLoadingSpinner,
177186
178634
  createLogHelper,
178635
+ createManualDevice,
177187
178636
  createMenuComponent,
177188
178637
  createMenuShoppingComponent,
177189
178638
  createModalFooter,
@@ -177220,6 +178669,7 @@ var version = package_default.version || "0.0.0";
177220
178669
  createTbEnvelopeStore,
177221
178670
  createTelemetryGridComponent,
177222
178671
  createTelemetryGridShoppingComponent,
178672
+ createTelemetryImportApi,
177223
178673
  createTelemetryInfoShoppingComponent,
177224
178674
  createTicketDetailModal,
177225
178675
  createTicketsTab,
@@ -177459,6 +178909,7 @@ var version = package_default.version || "0.0.0";
177459
178909
  listDeviceProductTypes,
177460
178910
  listDomains,
177461
178911
  listGroups,
178912
+ manualDeviceName,
177462
178913
  mapConnectionStatus,
177463
178914
  mapDeviceStatusToCardStatus,
177464
178915
  mapDeviceToConnectionStatus,
@@ -177467,6 +178918,7 @@ var version = package_default.version || "0.0.0";
177467
178918
  minutesToMs,
177468
178919
  msToMinutes,
177469
178920
  myioExportData,
178921
+ nextManualSeq,
177470
178922
  nfdNormalizeAnnotationSearch,
177471
178923
  normalizeBudgetBlock,
177472
178924
  normalizeConnectionStatus,
@@ -177504,6 +178956,7 @@ var version = package_default.version || "0.0.0";
177504
178956
  openGoalsPanel,
177505
178957
  openHelpModal,
177506
178958
  openIntegrationsModal,
178959
+ openManualDeviceModal,
177507
178960
  openMeasurementSetupModal,
177508
178961
  openMessageDialog,
177509
178962
  openMetasGuide,
@@ -177516,6 +178969,8 @@ var version = package_default.version || "0.0.0";
177516
178969
  openRealTimeTelemetryModal,
177517
178970
  openReportsHub,
177518
178971
  openSettingsHubModal,
178972
+ openStandardModal,
178973
+ openTelemetryImportModal,
177519
178974
  openTemperatureComparisonModal,
177520
178975
  openTemperatureModal,
177521
178976
  openTemperatureSettingsModal,
@@ -177530,6 +178985,7 @@ var version = package_default.version || "0.0.0";
177530
178985
  panelTermToDeviceCategory,
177531
178986
  parseBinaryState,
177532
178987
  parseClassificationEntities,
178988
+ parseCsv,
177533
178989
  parseGcdrEnergyRoot,
177534
178990
  parseGcdrEntityForest,
177535
178991
  parseInputDateToDate,
@@ -177590,6 +179046,7 @@ var version = package_default.version || "0.0.0";
177590
179046
  resolveSubcategory,
177591
179047
  resolveWithFallback,
177592
179048
  routeMoneyRender,
179049
+ rowsFromTable,
177593
179050
  schedCreateDateInput,
177594
179051
  schedCreateNumberInput,
177595
179052
  schedCreateSelect,
@@ -177601,6 +179058,7 @@ var version = package_default.version || "0.0.0";
177601
179058
  setActiveProfile,
177602
179059
  shouldFlashIcon,
177603
179060
  shouldVirtualizeAnnotationList,
179061
+ siglaFromManualAsset,
177604
179062
  signOf,
177605
179063
  slugifyCustomerName,
177606
179064
  sortAnnotationGroups,
@@ -177630,6 +179088,7 @@ var version = package_default.version || "0.0.0";
177630
179088
  validateDeviceProductName,
177631
179089
  validateProfile,
177632
179090
  validateTree,
179091
+ valveHistoryFromTelemetry,
177633
179092
  version,
177634
179093
  waterDeviceStatusIcons,
177635
179094
  wireCategoryToPanel,