akeyless-client-commons 1.1.70 → 1.1.72

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.
@@ -516,9 +516,15 @@ __export(index_exports, {
516
516
  isNodeEnv: function() {
517
517
  return isNodeEnv;
518
518
  },
519
+ is_fixed_or_service_number: function() {
520
+ return is_fixed_or_service_number;
521
+ },
519
522
  is_iccid: function() {
520
523
  return is_iccid;
521
524
  },
525
+ is_msisdn: function() {
526
+ return is_msisdn;
527
+ },
522
528
  local_israel_phone_format: function() {
523
529
  return local_israel_phone_format;
524
530
  },
@@ -644,7 +650,7 @@ var import_app = require("firebase/app");
644
650
  var import_storage = require("firebase/storage");
645
651
  var import_auth = require("firebase/auth");
646
652
  var import_app_check = require("firebase/app-check");
647
- var import_firestore = require("firebase/firestore");
653
+ var import_firestore2 = require("firebase/firestore");
648
654
  // src/helpers/cars.ts
649
655
  var formatCarNumber = function(car_number) {
650
656
  var cn2 = car_number;
@@ -672,18 +678,30 @@ var international_israel_phone_format = function(phone) {
672
678
  return "+972".concat(validNumber);
673
679
  };
674
680
  var get_international_phone_number = function(phone) {
675
- if (!phone) return "+972";
681
+ if (!phone) return "-";
676
682
  return isInternational(phone) ? phone : international_israel_phone_format(phone);
677
683
  };
678
684
  var displayFormatPhoneNumber = function(phoneNumber, separator) {
679
- if (isInternational(phoneNumber)) {
680
- var phoneNumberObject = (0, import_libphonenumber_js.parsePhoneNumberFromString)(phoneNumber);
681
- if (!phoneNumberObject) {
682
- return phoneNumber;
685
+ if (!phoneNumber) return "";
686
+ var cleaned = phoneNumber.replace(/[\s\-]/g, "");
687
+ var sep = separator !== null && separator !== void 0 ? separator : "-";
688
+ if (isInternational(cleaned)) {
689
+ var phone_obj = (0, import_libphonenumber_js.parsePhoneNumberFromString)(cleaned);
690
+ if (!phone_obj) return cleaned;
691
+ return phone_obj.formatInternational().replace(/\s/g, sep);
692
+ }
693
+ if (is_fixed_or_service_number(cleaned)) {
694
+ if (/^(1700|1800|1900|1599)/.test(cleaned)) {
695
+ return cleaned.replace(/^(\d{4})(\d{3})(\d{3,4})$/, "$1".concat(sep, "$2").concat(sep, "$3"));
696
+ }
697
+ if (/^07[2-8]/.test(cleaned)) {
698
+ return cleaned.replace(/^(\d{3})(\d{3})(\d{4})$/, "$1".concat(sep, "$2").concat(sep, "$3"));
699
+ }
700
+ if (/^(02|03|04|08|09)/.test(cleaned)) {
701
+ return cleaned.replace(/^(\d{2})(\d{3})(\d{4})$/, "$1".concat(sep, "$2").concat(sep, "$3"));
683
702
  }
684
- return phoneNumberObject.formatInternational().replace(/\s/g, separator !== null && separator !== void 0 ? separator : "");
685
703
  }
686
- return phoneNumber.replace(/(\d{3})(\d{3})(\d{4})/, "$1-$2-$3");
704
+ return cleaned.replace(/^(\d{3})(\d{3})(\d{4})$/, "$1".concat(sep, "$2").concat(sep, "$3"));
687
705
  };
688
706
  var is_iccid = function(number) {
689
707
  if (number.length < 19 || number.length > 22) return false;
@@ -691,6 +709,47 @@ var is_iccid = function(number) {
691
709
  if (!number.startsWith("89")) return false;
692
710
  return true;
693
711
  };
712
+ var is_msisdn = function(number) {
713
+ if (number.length < 10 || number.length > 15) return false;
714
+ if (!/^\d+$/.test(number)) return false;
715
+ return true;
716
+ };
717
+ var is_fixed_or_service_number = function(number) {
718
+ if (!number) return false;
719
+ var cleaned = number.replace(/[\s\-]/g, "");
720
+ if (!/^\d+$/.test(cleaned)) return false;
721
+ if (cleaned.length < 7 || cleaned.length > 15) return false;
722
+ var landline_prefixes = [
723
+ "02",
724
+ "03",
725
+ "04",
726
+ "08",
727
+ "09"
728
+ ];
729
+ var voip_prefixes = [
730
+ "072",
731
+ "073",
732
+ "074",
733
+ "076",
734
+ "077",
735
+ "078"
736
+ ];
737
+ var service_prefixes = [
738
+ "1700",
739
+ "1800",
740
+ "1900",
741
+ "1599",
742
+ "1200",
743
+ "1212"
744
+ ];
745
+ return landline_prefixes.some(function(p) {
746
+ return cleaned.startsWith(p);
747
+ }) || voip_prefixes.some(function(p) {
748
+ return cleaned.startsWith(p);
749
+ }) || service_prefixes.some(function(p) {
750
+ return cleaned.startsWith(p);
751
+ });
752
+ };
694
753
  // src/helpers/permissions.ts
695
754
  var checkUserPermissions = function(userPermissions, entity, permissions, mode2) {
696
755
  var userValues = userPermissions[entity];
@@ -810,6 +869,134 @@ var initializeUserPermissions = /*#__PURE__*/ function() {
810
869
  }();
811
870
  // src/helpers/firebase.ts
812
871
  var import_storage2 = require("firebase/storage");
872
+ // src/helpers/time_helpers.ts
873
+ var import_firestore = require("firebase/firestore");
874
+ var import_moment_timezone = __toESM(require("moment-timezone"));
875
+ function timestamp_to_string(firebaseTimestamp, options) {
876
+ var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
877
+ var _ref = {
878
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
879
+ format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
880
+ fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
881
+ tz: options === null || options === void 0 ? void 0 : options.tz,
882
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
883
+ }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
884
+ var date;
885
+ switch(true){
886
+ case !firebaseTimestamp:
887
+ {
888
+ return defaultReturnedValue;
889
+ }
890
+ case _instanceof(firebaseTimestamp, import_firestore.Timestamp):
891
+ {
892
+ date = firebaseTimestamp.toDate();
893
+ break;
894
+ }
895
+ case _instanceof(firebaseTimestamp, Date):
896
+ {
897
+ date = firebaseTimestamp;
898
+ break;
899
+ }
900
+ case typeof firebaseTimestamp === "string":
901
+ {
902
+ var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
903
+ switch(m.isValid()){
904
+ case true:
905
+ date = m.toDate();
906
+ break;
907
+ default:
908
+ return defaultReturnedValue;
909
+ }
910
+ break;
911
+ }
912
+ case !!firebaseTimestamp._seconds:
913
+ {
914
+ var ft = firebaseTimestamp;
915
+ var _ft__nanoseconds;
916
+ date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
917
+ break;
918
+ }
919
+ case !!firebaseTimestamp.seconds:
920
+ {
921
+ var ft1 = firebaseTimestamp;
922
+ date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
923
+ break;
924
+ }
925
+ default:
926
+ {
927
+ if (debug) {
928
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
929
+ }
930
+ return defaultReturnedValue;
931
+ }
932
+ }
933
+ switch(Boolean(tz)){
934
+ case true:
935
+ return (0, import_moment_timezone.default)(date).tz(tz).format(format);
936
+ default:
937
+ return import_moment_timezone.default.utc(date).format(format);
938
+ }
939
+ }
940
+ function timestamp_to_millis(firebaseTimestamp, options) {
941
+ var _options_defaultReturnedValue, _options_fromFormat, _options_debug;
942
+ var _ref = {
943
+ defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0,
944
+ fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
945
+ tz: options === null || options === void 0 ? void 0 : options.tz,
946
+ debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
947
+ }, defaultReturnedValue = _ref.defaultReturnedValue, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
948
+ switch(true){
949
+ case !firebaseTimestamp:
950
+ {
951
+ return defaultReturnedValue;
952
+ }
953
+ case _instanceof(firebaseTimestamp, import_firestore.Timestamp):
954
+ {
955
+ return firebaseTimestamp.toMillis();
956
+ }
957
+ case _instanceof(firebaseTimestamp, Date):
958
+ {
959
+ var ms = firebaseTimestamp.getTime();
960
+ return isNaN(ms) ? defaultReturnedValue : ms;
961
+ }
962
+ case typeof firebaseTimestamp === "string":
963
+ {
964
+ var m = tz ? import_moment_timezone.default.tz(firebaseTimestamp, fromFormat, tz) : import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
965
+ switch(m.isValid()){
966
+ case true:
967
+ return m.valueOf();
968
+ default:
969
+ return defaultReturnedValue;
970
+ }
971
+ }
972
+ case !!firebaseTimestamp._seconds:
973
+ {
974
+ var seconds = firebaseTimestamp._seconds;
975
+ var _firebaseTimestamp__nanoseconds;
976
+ var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
977
+ return seconds * 1e3 + Math.floor(nanos / 1e6);
978
+ }
979
+ case !!firebaseTimestamp.seconds:
980
+ {
981
+ var seconds1 = firebaseTimestamp.seconds;
982
+ var _firebaseTimestamp_nanoseconds;
983
+ var nanos1 = (_firebaseTimestamp_nanoseconds = firebaseTimestamp.nanoseconds) !== null && _firebaseTimestamp_nanoseconds !== void 0 ? _firebaseTimestamp_nanoseconds : 0;
984
+ return seconds1 * 1e3 + Math.floor(nanos1 / 1e6);
985
+ }
986
+ default:
987
+ {
988
+ if (debug) {
989
+ console.error("Invalid timestamp format: ", firebaseTimestamp);
990
+ }
991
+ return defaultReturnedValue;
992
+ }
993
+ }
994
+ }
995
+ function sort_by_timestamp(a, b) {
996
+ var reverse = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
997
+ return reverse ? timestamp_to_millis(b) - timestamp_to_millis(a) : timestamp_to_millis(a) - timestamp_to_millis(b);
998
+ }
999
+ // src/helpers/firebase.ts
813
1000
  var import_meta = {};
814
1001
  var initApp = function() {
815
1002
  var isNodeEnv2 = typeof process !== "undefined" && process.env;
@@ -825,7 +1012,7 @@ var initApp = function() {
825
1012
  var app2 = (0, import_app.initializeApp)(firebaseConfig);
826
1013
  var auth2 = (0, import_auth.getAuth)(app2);
827
1014
  auth2.settings.appVerificationDisabledForTesting = false;
828
- var db2 = (0, import_firestore.getFirestore)(app2);
1015
+ var db2 = (0, import_firestore2.getFirestore)(app2);
829
1016
  var storage2 = (0, import_storage.getStorage)(app2);
830
1017
  var googleLoginProvider2 = new import_auth.GoogleAuthProvider();
831
1018
  var recaptchaSiteKey = isNodeEnv2 ? process.env.NEXT_PUBLIC_RECAPTCHA_SITE_KEY : import_meta.env.VITE_RECAPTCHA_SITE_KEY;
@@ -875,33 +1062,33 @@ var useLoginWithGoogle = function() {
875
1062
  return signInWithGoogle;
876
1063
  };
877
1064
  var collections = {
878
- clients: (0, import_firestore.collection)(db, "nx-clients"),
879
- sites: (0, import_firestore.collection)(db, "nx-sites"),
880
- cars: (0, import_firestore.collection)(db, "units"),
881
- users: (0, import_firestore.collection)(db, "nx-users"),
882
- lastLocations: (0, import_firestore.collection)(db, "last_locations"),
883
- ermEvents: (0, import_firestore.collection)(db, "erm_events_general"),
884
- erm2Events: (0, import_firestore.collection)(db, "erm2_events_general"),
885
- ruptelaEvents: (0, import_firestore.collection)(db, "ruptela_events_general"),
886
- polygons: (0, import_firestore.collection)(db, "nx-polygons"),
887
- polygonEvents: (0, import_firestore.collection)(db, "polygon_events"),
888
- polygonCars: (0, import_firestore.collection)(db, "polygon_cars"),
889
- canbus: (0, import_firestore.collection)(db, "erm_canbus_parameters"),
890
- states: (0, import_firestore.collection)(db, "erm_states"),
891
- app_pro_commands_queue: (0, import_firestore.collection)(db, "app_pro_commands_queue"),
892
- trips: (0, import_firestore.collection)(db, "erm2_trip"),
893
- tripsDetails: (0, import_firestore.collection)(db, "erm2_trip_details"),
894
- audit: (0, import_firestore.collection)(db, "nx-audit"),
895
- nx_settings: (0, import_firestore.collection)(db, "nx-settings"),
896
- settings: (0, import_firestore.collection)(db, "settings"),
897
- translations: (0, import_firestore.collection)(db, "nx-translations"),
898
- nx_cars: (0, import_firestore.collection)(db, "nx-cars"),
899
- boards: (0, import_firestore.collection)(db, "boards"),
900
- protection_types: (0, import_firestore.collection)(db, "protectionTypes"),
901
- board_types: (0, import_firestore.collection)(db, "boardTypes"),
902
- charge_capacities: (0, import_firestore.collection)(db, "nx-charge-capacities")
1065
+ clients: (0, import_firestore2.collection)(db, "nx-clients"),
1066
+ sites: (0, import_firestore2.collection)(db, "nx-sites"),
1067
+ cars: (0, import_firestore2.collection)(db, "units"),
1068
+ users: (0, import_firestore2.collection)(db, "nx-users"),
1069
+ lastLocations: (0, import_firestore2.collection)(db, "last_locations"),
1070
+ ermEvents: (0, import_firestore2.collection)(db, "erm_events_general"),
1071
+ erm2Events: (0, import_firestore2.collection)(db, "erm2_events_general"),
1072
+ ruptelaEvents: (0, import_firestore2.collection)(db, "ruptela_events_general"),
1073
+ polygons: (0, import_firestore2.collection)(db, "nx-polygons"),
1074
+ polygonEvents: (0, import_firestore2.collection)(db, "polygon_events"),
1075
+ polygonCars: (0, import_firestore2.collection)(db, "polygon_cars"),
1076
+ canbus: (0, import_firestore2.collection)(db, "erm_canbus_parameters"),
1077
+ states: (0, import_firestore2.collection)(db, "erm_states"),
1078
+ app_pro_commands_queue: (0, import_firestore2.collection)(db, "app_pro_commands_queue"),
1079
+ trips: (0, import_firestore2.collection)(db, "erm2_trip"),
1080
+ tripsDetails: (0, import_firestore2.collection)(db, "erm2_trip_details"),
1081
+ audit: (0, import_firestore2.collection)(db, "nx-audit"),
1082
+ nx_settings: (0, import_firestore2.collection)(db, "nx-settings"),
1083
+ settings: (0, import_firestore2.collection)(db, "settings"),
1084
+ translations: (0, import_firestore2.collection)(db, "nx-translations"),
1085
+ nx_cars: (0, import_firestore2.collection)(db, "nx-cars"),
1086
+ boards: (0, import_firestore2.collection)(db, "boards"),
1087
+ protection_types: (0, import_firestore2.collection)(db, "protectionTypes"),
1088
+ board_types: (0, import_firestore2.collection)(db, "boardTypes"),
1089
+ charge_capacities: (0, import_firestore2.collection)(db, "nx-charge-capacities")
903
1090
  };
904
- var fire_base_TIME_TEMP = import_firestore.Timestamp.now;
1091
+ var fire_base_TIME_TEMP = import_firestore2.Timestamp.now;
905
1092
  var extractAlertsData = function(doc2) {
906
1093
  var data = doc2.data();
907
1094
  var car_number = data.car_number, timestamp = data.timestamp;
@@ -918,34 +1105,26 @@ var simpleExtractData = function(doc2) {
918
1105
  });
919
1106
  };
920
1107
  var extractSiteData = function(doc2) {
921
- var _data_updated, _data_created;
922
1108
  var data = doc2.data();
923
- var dateUpdated = new Date(((_data_updated = data.updated) === null || _data_updated === void 0 ? void 0 : _data_updated.seconds) * 1e3 + data.updated.nanoseconds / 1e6);
924
- var dateCreated = new Date(((_data_created = data.created) === null || _data_created === void 0 ? void 0 : _data_created.seconds) * 1e3 + data.created.nanoseconds / 1e6);
925
1109
  return _object_spread_props(_object_spread({}, data), {
926
1110
  id: doc2.id,
927
- created: (0, import_moment.default)(dateCreated).format("DD.MM.YYYY - HH:mm"),
928
- updated: (0, import_moment.default)(dateUpdated).format("DD.MM.YYYY - HH:mm")
1111
+ created: timestamp_to_string(data.created),
1112
+ updated: timestamp_to_string(data.updated)
929
1113
  });
930
1114
  };
931
1115
  var extractClientData = function(doc2) {
932
- var _data_updated, _data_created;
933
1116
  var data = doc2.data();
934
- var dateUpdated = new Date(((_data_updated = data.updated) === null || _data_updated === void 0 ? void 0 : _data_updated.seconds) * 1e3 + data.updated.nanoseconds / 1e6);
935
- var dateCreated = new Date(((_data_created = data.created) === null || _data_created === void 0 ? void 0 : _data_created.seconds) * 1e3 + data.created.nanoseconds / 1e6);
936
1117
  return _object_spread_props(_object_spread({}, data), {
937
1118
  id: doc2.id,
938
- created: (0, import_moment.default)(dateCreated).format("HH:mm DD/MM/YY"),
939
- updated: (0, import_moment.default)(dateUpdated).format("HH:mm DD/MM/YY")
1119
+ created: timestamp_to_string(data.created),
1120
+ updated: timestamp_to_string(data.updated)
940
1121
  });
941
1122
  };
942
1123
  var extractBoardsData = function(doc2) {
943
- var _data_uploaded;
944
1124
  var data = doc2.data();
945
- var dateUploaded = typeof data.uploaded === "string" ? data.uploaded : import_moment.default.unix((_data_uploaded = data.uploaded) === null || _data_uploaded === void 0 ? void 0 : _data_uploaded.seconds).format("DD/MM/YY HH:mm");
946
1125
  return _object_spread_props(_object_spread({}, data), {
947
1126
  id: doc2.id,
948
- uploaded: dateUploaded
1127
+ uploaded: timestamp_to_string(data.uploaded)
949
1128
  });
950
1129
  };
951
1130
  var extractCarsData = function(doc2) {
@@ -1009,7 +1188,7 @@ var get_all_documents = /*#__PURE__*/ function() {
1009
1188
  ]);
1010
1189
  return [
1011
1190
  4,
1012
- (0, import_firestore.getDocs)((0, import_firestore.collection)(db, collection_path))
1191
+ (0, import_firestore2.getDocs)((0, import_firestore2.collection)(db, collection_path))
1013
1192
  ];
1014
1193
  case 1:
1015
1194
  snapshot2 = _state.sent();
@@ -1049,10 +1228,10 @@ var get_document_by_id = /*#__PURE__*/ function() {
1049
1228
  ,
1050
1229
  3
1051
1230
  ]);
1052
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
1231
+ doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
1053
1232
  return [
1054
1233
  4,
1055
- (0, import_firestore.getDoc)(doc_ref)
1234
+ (0, import_firestore2.getDoc)(doc_ref)
1056
1235
  ];
1057
1236
  case 1:
1058
1237
  doc_snap = _state.sent();
@@ -1093,10 +1272,10 @@ var set_document = /*#__PURE__*/ function() {
1093
1272
  ,
1094
1273
  3
1095
1274
  ]);
1096
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
1275
+ doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
1097
1276
  return [
1098
1277
  4,
1099
- (0, import_firestore.setDoc)(doc_ref, data, {
1278
+ (0, import_firestore2.setDoc)(doc_ref, data, {
1100
1279
  merge: true
1101
1280
  })
1102
1281
  ];
@@ -1143,10 +1322,10 @@ var add_document = /*#__PURE__*/ function() {
1143
1322
  ,
1144
1323
  6
1145
1324
  ]);
1146
- col_ref = (0, import_firestore.collection)(db, collection_path);
1325
+ col_ref = (0, import_firestore2.collection)(db, collection_path);
1147
1326
  return [
1148
1327
  4,
1149
- (0, import_firestore.addDoc)(col_ref, data)
1328
+ (0, import_firestore2.addDoc)(col_ref, data)
1150
1329
  ];
1151
1330
  case 2:
1152
1331
  doc_ref = _state.sent();
@@ -1156,7 +1335,7 @@ var add_document = /*#__PURE__*/ function() {
1156
1335
  ];
1157
1336
  return [
1158
1337
  4,
1159
- (0, import_firestore.setDoc)(doc_ref, _object_spread_props(_object_spread({}, data), {
1338
+ (0, import_firestore2.setDoc)(doc_ref, _object_spread_props(_object_spread({}, data), {
1160
1339
  id: doc_ref.id
1161
1340
  }), {
1162
1341
  merge: true
@@ -1200,10 +1379,10 @@ var delete_document = /*#__PURE__*/ function() {
1200
1379
  ,
1201
1380
  3
1202
1381
  ]);
1203
- doc_ref = (0, import_firestore.doc)(db, collection_path, doc_id);
1382
+ doc_ref = (0, import_firestore2.doc)(db, collection_path, doc_id);
1204
1383
  return [
1205
1384
  4,
1206
- (0, import_firestore.deleteDoc)(doc_ref)
1385
+ (0, import_firestore2.deleteDoc)(doc_ref)
1207
1386
  ];
1208
1387
  case 1:
1209
1388
  _state.sent();
@@ -1245,10 +1424,10 @@ var query_document = /*#__PURE__*/ function() {
1245
1424
  ,
1246
1425
  4
1247
1426
  ]);
1248
- q = (0, import_firestore.query)((0, import_firestore.collection)(db, collection_path), (0, import_firestore.where)(field_name, operator, value));
1427
+ q = (0, import_firestore2.query)((0, import_firestore2.collection)(db, collection_path), (0, import_firestore2.where)(field_name, operator, value));
1249
1428
  return [
1250
1429
  4,
1251
- (0, import_firestore.getDocs)(q)
1430
+ (0, import_firestore2.getDocs)(q)
1252
1431
  ];
1253
1432
  case 2:
1254
1433
  query_snapshot = _state.sent();
@@ -1294,10 +1473,10 @@ var query_documents = /*#__PURE__*/ function() {
1294
1473
  ,
1295
1474
  3
1296
1475
  ]);
1297
- q = (0, import_firestore.query)((0, import_firestore.collection)(db, collection_path), (0, import_firestore.where)(field_name, operator, value));
1476
+ q = (0, import_firestore2.query)((0, import_firestore2.collection)(db, collection_path), (0, import_firestore2.where)(field_name, operator, value));
1298
1477
  return [
1299
1478
  4,
1300
- (0, import_firestore.getDocs)(q)
1479
+ (0, import_firestore2.getDocs)(q)
1301
1480
  ];
1302
1481
  case 1:
1303
1482
  query_snapshot = _state.sent();
@@ -1338,13 +1517,13 @@ var query_documents_by_conditions = /*#__PURE__*/ function() {
1338
1517
  ,
1339
1518
  3
1340
1519
  ]);
1341
- db_query = (0, import_firestore.collection)(db, collection_path);
1520
+ db_query = (0, import_firestore2.collection)(db, collection_path);
1342
1521
  where_conditions.forEach(function(condition) {
1343
- db_query = (0, import_firestore.query)(db_query, (0, import_firestore.where)(condition.field_name, condition.operator, condition.value));
1522
+ db_query = (0, import_firestore2.query)(db_query, (0, import_firestore2.where)(condition.field_name, condition.operator, condition.value));
1344
1523
  });
1345
1524
  return [
1346
1525
  4,
1347
- (0, import_firestore.getDocs)(db_query)
1526
+ (0, import_firestore2.getDocs)(db_query)
1348
1527
  ];
1349
1528
  case 1:
1350
1529
  query_snapshot = _state.sent();
@@ -1385,13 +1564,13 @@ var query_document_by_conditions = /*#__PURE__*/ function() {
1385
1564
  ,
1386
1565
  3
1387
1566
  ]);
1388
- db_query = (0, import_firestore.collection)(db, collection_path);
1567
+ db_query = (0, import_firestore2.collection)(db, collection_path);
1389
1568
  where_conditions.forEach(function(condition) {
1390
- db_query = (0, import_firestore.query)(db_query, (0, import_firestore.where)(condition.field_name, condition.operator, condition.value));
1569
+ db_query = (0, import_firestore2.query)(db_query, (0, import_firestore2.where)(condition.field_name, condition.operator, condition.value));
1391
1570
  });
1392
1571
  return [
1393
1572
  4,
1394
- (0, import_firestore.getDocs)(db_query)
1573
+ (0, import_firestore2.getDocs)(db_query)
1395
1574
  ];
1396
1575
  case 1:
1397
1576
  query_snapshot = _state.sent();
@@ -1437,18 +1616,18 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
1437
1616
  }
1438
1617
  };
1439
1618
  });
1440
- var collectionRef = (0, import_firestore.collection)(db, config.collectionName);
1619
+ var collectionRef = (0, import_firestore2.collection)(db, config.collectionName);
1441
1620
  if (config.conditions) {
1442
1621
  config.conditions.forEach(function(condition) {
1443
- collectionRef = (0, import_firestore.query)(collectionRef, (0, import_firestore.where)(condition.field_name, condition.operator, condition.value));
1622
+ collectionRef = (0, import_firestore2.query)(collectionRef, (0, import_firestore2.where)(condition.field_name, condition.operator, condition.value));
1444
1623
  });
1445
1624
  }
1446
1625
  if (config.orderBy) {
1447
1626
  config.orderBy.forEach(function(order) {
1448
- collectionRef = (0, import_firestore.query)(collectionRef, (0, import_firestore.orderBy)(order.fieldName, order.direction));
1627
+ collectionRef = (0, import_firestore2.query)(collectionRef, (0, import_firestore2.orderBy)(order.fieldName, order.direction));
1449
1628
  });
1450
1629
  }
1451
- var unsubscribe = (0, import_firestore.onSnapshot)(collectionRef, function(snapshot2) {
1630
+ var unsubscribe = (0, import_firestore2.onSnapshot)(collectionRef, function(snapshot2) {
1452
1631
  var firstTimeKey = JSON.stringify({
1453
1632
  collectionName: config.collectionName,
1454
1633
  conditions: config.conditions || [],
@@ -1511,8 +1690,8 @@ var snapshotDocument = function(config, snapshotsFirstTime) {
1511
1690
  }
1512
1691
  };
1513
1692
  });
1514
- var documentRef = (0, import_firestore.doc)(db, config.collectionName, config.documentId);
1515
- var unsubscribe = (0, import_firestore.onSnapshot)(documentRef, function(docSnapshot) {
1693
+ var documentRef = (0, import_firestore2.doc)(db, config.collectionName, config.documentId);
1694
+ var unsubscribe = (0, import_firestore2.onSnapshot)(documentRef, function(docSnapshot) {
1516
1695
  if (!snapshotsFirstTime.includes(config.collectionName)) {
1517
1696
  snapshotsFirstTime.push(config.collectionName);
1518
1697
  if (docSnapshot.exists()) {
@@ -1776,7 +1955,7 @@ var addAuditRecord = /*#__PURE__*/ function() {
1776
1955
  ,
1777
1956
  3
1778
1957
  ]);
1779
- ref2 = (0, import_firestore.doc)(collections.audit);
1958
+ ref2 = (0, import_firestore2.doc)(collections.audit);
1780
1959
  data = {
1781
1960
  action: action,
1782
1961
  entity: entity,
@@ -1791,7 +1970,7 @@ var addAuditRecord = /*#__PURE__*/ function() {
1791
1970
  };
1792
1971
  return [
1793
1972
  4,
1794
- (0, import_firestore.setDoc)(ref2, _object_spread_props(_object_spread({}, data), {
1973
+ (0, import_firestore2.setDoc)(ref2, _object_spread_props(_object_spread({}, data), {
1795
1974
  datetime: fire_base_TIME_TEMP()
1796
1975
  }))
1797
1976
  ];
@@ -2334,133 +2513,6 @@ function cn() {
2334
2513
  }
2335
2514
  return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
2336
2515
  }
2337
- // src/helpers/time_helpers.ts
2338
- var import_firestore2 = require("firebase/firestore");
2339
- var import_moment_timezone = __toESM(require("moment-timezone"));
2340
- function timestamp_to_string(firebaseTimestamp, options) {
2341
- var _options_defaultReturnedValue, _options_format, _options_fromFormat, _options_debug;
2342
- var _ref = {
2343
- defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : "-",
2344
- format: (_options_format = options === null || options === void 0 ? void 0 : options.format) !== null && _options_format !== void 0 ? _options_format : "DD/MM/YYYY HH:mm:ss",
2345
- fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
2346
- tz: options === null || options === void 0 ? void 0 : options.tz,
2347
- debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
2348
- }, defaultReturnedValue = _ref.defaultReturnedValue, format = _ref.format, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
2349
- var date;
2350
- switch(true){
2351
- case !firebaseTimestamp:
2352
- {
2353
- return defaultReturnedValue;
2354
- }
2355
- case _instanceof(firebaseTimestamp, import_firestore2.Timestamp):
2356
- {
2357
- date = firebaseTimestamp.toDate();
2358
- break;
2359
- }
2360
- case _instanceof(firebaseTimestamp, Date):
2361
- {
2362
- date = firebaseTimestamp;
2363
- break;
2364
- }
2365
- case typeof firebaseTimestamp === "string":
2366
- {
2367
- var m = import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
2368
- switch(m.isValid()){
2369
- case true:
2370
- date = m.toDate();
2371
- break;
2372
- default:
2373
- return defaultReturnedValue;
2374
- }
2375
- break;
2376
- }
2377
- case !!firebaseTimestamp._seconds:
2378
- {
2379
- var ft = firebaseTimestamp;
2380
- var _ft__nanoseconds;
2381
- date = new Date(ft._seconds * 1e3 + ((_ft__nanoseconds = ft._nanoseconds) !== null && _ft__nanoseconds !== void 0 ? _ft__nanoseconds : 0) / 1e6);
2382
- break;
2383
- }
2384
- case !!firebaseTimestamp.seconds:
2385
- {
2386
- var ft1 = firebaseTimestamp;
2387
- date = new Date(ft1.seconds * 1e3 + ft1.nanoseconds / 1e6);
2388
- break;
2389
- }
2390
- default:
2391
- {
2392
- if (debug) {
2393
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2394
- }
2395
- return defaultReturnedValue;
2396
- }
2397
- }
2398
- switch(Boolean(tz)){
2399
- case true:
2400
- return (0, import_moment_timezone.default)(date).tz(tz).format(format);
2401
- default:
2402
- return import_moment_timezone.default.utc(date).format(format);
2403
- }
2404
- }
2405
- function timestamp_to_millis(firebaseTimestamp, options) {
2406
- var _options_defaultReturnedValue, _options_fromFormat, _options_debug;
2407
- var _ref = {
2408
- defaultReturnedValue: (_options_defaultReturnedValue = options === null || options === void 0 ? void 0 : options.defaultReturnedValue) !== null && _options_defaultReturnedValue !== void 0 ? _options_defaultReturnedValue : 0,
2409
- fromFormat: (_options_fromFormat = options === null || options === void 0 ? void 0 : options.fromFormat) !== null && _options_fromFormat !== void 0 ? _options_fromFormat : "DD/MM/YYYY HH:mm:ss",
2410
- tz: options === null || options === void 0 ? void 0 : options.tz,
2411
- debug: (_options_debug = options === null || options === void 0 ? void 0 : options.debug) !== null && _options_debug !== void 0 ? _options_debug : false
2412
- }, defaultReturnedValue = _ref.defaultReturnedValue, fromFormat = _ref.fromFormat, tz = _ref.tz, debug = _ref.debug;
2413
- switch(true){
2414
- case !firebaseTimestamp:
2415
- {
2416
- return defaultReturnedValue;
2417
- }
2418
- case _instanceof(firebaseTimestamp, import_firestore2.Timestamp):
2419
- {
2420
- return firebaseTimestamp.toMillis();
2421
- }
2422
- case _instanceof(firebaseTimestamp, Date):
2423
- {
2424
- var ms = firebaseTimestamp.getTime();
2425
- return isNaN(ms) ? defaultReturnedValue : ms;
2426
- }
2427
- case typeof firebaseTimestamp === "string":
2428
- {
2429
- var m = tz ? import_moment_timezone.default.tz(firebaseTimestamp, fromFormat, tz) : import_moment_timezone.default.utc(firebaseTimestamp, fromFormat);
2430
- switch(m.isValid()){
2431
- case true:
2432
- return m.valueOf();
2433
- default:
2434
- return defaultReturnedValue;
2435
- }
2436
- }
2437
- case !!firebaseTimestamp._seconds:
2438
- {
2439
- var seconds = firebaseTimestamp._seconds;
2440
- var _firebaseTimestamp__nanoseconds;
2441
- var nanos = (_firebaseTimestamp__nanoseconds = firebaseTimestamp._nanoseconds) !== null && _firebaseTimestamp__nanoseconds !== void 0 ? _firebaseTimestamp__nanoseconds : 0;
2442
- return seconds * 1e3 + Math.floor(nanos / 1e6);
2443
- }
2444
- case !!firebaseTimestamp.seconds:
2445
- {
2446
- var seconds1 = firebaseTimestamp.seconds;
2447
- var _firebaseTimestamp_nanoseconds;
2448
- var nanos1 = (_firebaseTimestamp_nanoseconds = firebaseTimestamp.nanoseconds) !== null && _firebaseTimestamp_nanoseconds !== void 0 ? _firebaseTimestamp_nanoseconds : 0;
2449
- return seconds1 * 1e3 + Math.floor(nanos1 / 1e6);
2450
- }
2451
- default:
2452
- {
2453
- if (debug) {
2454
- console.error("Invalid timestamp format: ", firebaseTimestamp);
2455
- }
2456
- return defaultReturnedValue;
2457
- }
2458
- }
2459
- }
2460
- function sort_by_timestamp(a, b) {
2461
- var reverse = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
2462
- return reverse ? timestamp_to_millis(b) - timestamp_to_millis(a) : timestamp_to_millis(a) - timestamp_to_millis(b);
2463
- }
2464
2516
  // src/helpers/api.ts
2465
2517
  var import_axios2 = __toESM(require("axios"));
2466
2518
  var baseDomain = mode === "qa" ? "https://nx-api.xyz/api" : "https://nx-api.info/api";
@@ -2686,57 +2738,6 @@ var createAttachmentFromUrl = /*#__PURE__*/ function() {
2686
2738
  // src/helpers/socket.ts
2687
2739
  var import_socket = require("socket.io-client");
2688
2740
  var SESSION_STORAGE_KEY = "sessionId";
2689
- var safeSessionStorage = function() {
2690
- var memoryValue;
2691
- var canUseStorage = function() {
2692
- if (typeof window === "undefined") return false;
2693
- try {
2694
- var testKey = "".concat(SESSION_STORAGE_KEY, "_test");
2695
- window.localStorage.setItem(testKey, "1");
2696
- window.localStorage.removeItem(testKey);
2697
- return true;
2698
- } catch (error) {
2699
- console.warn("localStorage check failed, falling back to memory store", error);
2700
- return false;
2701
- }
2702
- };
2703
- var storageAvailable = canUseStorage();
2704
- return {
2705
- read: function read() {
2706
- if (!storageAvailable) {
2707
- return memoryValue;
2708
- }
2709
- try {
2710
- return window.localStorage.getItem(SESSION_STORAGE_KEY) || memoryValue;
2711
- } catch (error) {
2712
- console.warn("localStorage read failed, using memory store", error);
2713
- return memoryValue;
2714
- }
2715
- },
2716
- write: function write(value) {
2717
- memoryValue = value;
2718
- if (!storageAvailable || typeof value === "undefined") {
2719
- return;
2720
- }
2721
- try {
2722
- window.localStorage.setItem(SESSION_STORAGE_KEY, value);
2723
- } catch (error) {
2724
- console.warn("localStorage write failed, persisting in memory store", error);
2725
- }
2726
- },
2727
- clear: function clear() {
2728
- memoryValue = void 0;
2729
- if (!storageAvailable) {
2730
- return;
2731
- }
2732
- try {
2733
- window.localStorage.removeItem(SESSION_STORAGE_KEY);
2734
- } catch (error) {
2735
- console.warn("localStorage clear failed", error);
2736
- }
2737
- }
2738
- };
2739
- }();
2740
2741
  var SocketService = /*#__PURE__*/ function() {
2741
2742
  "use strict";
2742
2743
  function _SocketService() {
@@ -2757,7 +2758,7 @@ var SocketService = /*#__PURE__*/ function() {
2757
2758
  this.socket = (0, import_socket.io)(socketUrl, {
2758
2759
  path: "/api/data-socket/connect",
2759
2760
  auth: function(cb) {
2760
- var sessionId = safeSessionStorage.read();
2761
+ var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
2761
2762
  var token = _this.authToken;
2762
2763
  var authPayload = {};
2763
2764
  if (token) authPayload.token = token;
@@ -2799,7 +2800,7 @@ var SocketService = /*#__PURE__*/ function() {
2799
2800
  this.socket.on("session", function(param) {
2800
2801
  var session_id = param.session_id;
2801
2802
  if (session_id) {
2802
- safeSessionStorage.write(session_id);
2803
+ localStorage.setItem(SESSION_STORAGE_KEY, session_id);
2803
2804
  }
2804
2805
  });
2805
2806
  this.socket.on("connect_error", function(error) {
@@ -3119,7 +3120,9 @@ var socketServiceInstance = SocketService.getInstance();
3119
3120
  isInternationalIsraelPhone: isInternationalIsraelPhone,
3120
3121
  isLocal: isLocal,
3121
3122
  isNodeEnv: isNodeEnv,
3123
+ is_fixed_or_service_number: is_fixed_or_service_number,
3122
3124
  is_iccid: is_iccid,
3125
+ is_msisdn: is_msisdn,
3123
3126
  local_israel_phone_format: local_israel_phone_format,
3124
3127
  mode: mode,
3125
3128
  multiStringFormat: multiStringFormat,