@blackcode_sa/metaestetics-api 1.15.17-staging.1 → 1.15.17-staging.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -471,6 +471,13 @@ var ClinicRole = /* @__PURE__ */ ((ClinicRole2) => {
471
471
  ClinicRole2["ASSISTANT"] = "assistant";
472
472
  return ClinicRole2;
473
473
  })(ClinicRole || {});
474
+ var StaffInviteStatus = /* @__PURE__ */ ((StaffInviteStatus2) => {
475
+ StaffInviteStatus2["PENDING"] = "pending";
476
+ StaffInviteStatus2["ACCEPTED"] = "accepted";
477
+ StaffInviteStatus2["EXPIRED"] = "expired";
478
+ StaffInviteStatus2["CANCELLED"] = "cancelled";
479
+ return StaffInviteStatus2;
480
+ })(StaffInviteStatus || {});
474
481
 
475
482
  // src/types/clinic/index.ts
476
483
  var CLINIC_GROUPS_COLLECTION = "clinic_groups";
@@ -1107,12 +1114,12 @@ var ReviewAnalyticsService = class extends BaseService {
1107
1114
  q = query(q, where("createdAt", ">=", startTimestamp), where("createdAt", "<=", endTimestamp));
1108
1115
  }
1109
1116
  const snapshot = await getDocs(q);
1110
- const reviews = snapshot.docs.map((doc53) => {
1117
+ const reviews = snapshot.docs.map((doc54) => {
1111
1118
  var _a, _b;
1112
- const data = doc53.data();
1119
+ const data = doc54.data();
1113
1120
  return {
1114
1121
  ...data,
1115
- id: doc53.id,
1122
+ id: doc54.id,
1116
1123
  createdAt: ((_a = data.createdAt) == null ? void 0 : _a.toDate) ? data.createdAt.toDate() : new Date(data.createdAt),
1117
1124
  updatedAt: ((_b = data.updatedAt) == null ? void 0 : _b.toDate) ? data.updatedAt.toDate() : new Date(data.updatedAt)
1118
1125
  };
@@ -1129,10 +1136,10 @@ var ReviewAnalyticsService = class extends BaseService {
1129
1136
  where("id", "in", batch)
1130
1137
  );
1131
1138
  const appointmentSnapshot = await getDocs(appointmentsQuery);
1132
- appointmentSnapshot.docs.forEach((doc53) => {
1133
- const appointment = doc53.data();
1139
+ appointmentSnapshot.docs.forEach((doc54) => {
1140
+ const appointment = doc54.data();
1134
1141
  if (appointment.clinicBranchId === filters.clinicBranchId) {
1135
- validAppointmentIds.add(doc53.id);
1142
+ validAppointmentIds.add(doc54.id);
1136
1143
  }
1137
1144
  });
1138
1145
  }
@@ -4352,7 +4359,7 @@ var MediaService = class extends BaseService {
4352
4359
  try {
4353
4360
  const querySnapshot = await getDocs3(finalQuery);
4354
4361
  const mediaList = querySnapshot.docs.map(
4355
- (doc53) => doc53.data()
4362
+ (doc54) => doc54.data()
4356
4363
  );
4357
4364
  console.log(`[MediaService] Found ${mediaList.length} media items.`);
4358
4365
  return mediaList;
@@ -4659,6 +4666,10 @@ var ResourceStatus = /* @__PURE__ */ ((ResourceStatus2) => {
4659
4666
  return ResourceStatus2;
4660
4667
  })(ResourceStatus || {});
4661
4668
 
4669
+ // src/types/system/planConfig.types.ts
4670
+ var PLAN_CONFIG_PATH = "system/planConfig";
4671
+ var PLAN_CONFIG_HISTORY_PATH = "system/planConfig/history";
4672
+
4662
4673
  // src/validations/patient.schema.ts
4663
4674
  import { z as z6 } from "zod";
4664
4675
  import { Timestamp as Timestamp6 } from "firebase/firestore";
@@ -5217,8 +5228,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
5217
5228
  }
5218
5229
  const patientsSnapshot = await getDocs4(q);
5219
5230
  const patients = [];
5220
- patientsSnapshot.forEach((doc53) => {
5221
- patients.push(doc53.data());
5231
+ patientsSnapshot.forEach((doc54) => {
5232
+ patients.push(doc54.data());
5222
5233
  });
5223
5234
  console.log(
5224
5235
  `[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
@@ -6046,7 +6057,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
6046
6057
  where5("clinicGroupId", "==", clinicGroupId)
6047
6058
  );
6048
6059
  const querySnapshot = await getDocs5(q);
6049
- return querySnapshot.docs.map((doc53) => doc53.data());
6060
+ return querySnapshot.docs.map((doc54) => doc54.data());
6050
6061
  }
6051
6062
  async function updateClinicAdmin(db, adminId, data) {
6052
6063
  const admin = await getClinicAdmin(db, adminId);
@@ -6633,7 +6644,7 @@ async function searchAppointmentsUtil(db, params) {
6633
6644
  }
6634
6645
  const q = query7(collection7(db, APPOINTMENTS_COLLECTION), ...constraints);
6635
6646
  const querySnapshot = await getDocs7(q);
6636
- const appointments = querySnapshot.docs.map((doc53) => doc53.data());
6647
+ const appointments = querySnapshot.docs.map((doc54) => doc54.data());
6637
6648
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
6638
6649
  return { appointments, lastDoc };
6639
6650
  } catch (error) {
@@ -8329,7 +8340,7 @@ var AppointmentService = class extends BaseService {
8329
8340
  }
8330
8341
  const q = query9(collection9(this.db, APPOINTMENTS_COLLECTION), ...constraints);
8331
8342
  const querySnapshot = await getDocs9(q);
8332
- const appointments = querySnapshot.docs.map((doc53) => doc53.data());
8343
+ const appointments = querySnapshot.docs.map((doc54) => doc54.data());
8333
8344
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
8334
8345
  console.log(
8335
8346
  `[APPOINTMENT_SERVICE] Found ${appointments.length} upcoming appointments for patient ${patientId}`
@@ -8385,7 +8396,7 @@ var AppointmentService = class extends BaseService {
8385
8396
  }
8386
8397
  const q = query9(collection9(this.db, APPOINTMENTS_COLLECTION), ...constraints);
8387
8398
  const querySnapshot = await getDocs9(q);
8388
- const appointments = querySnapshot.docs.map((doc53) => doc53.data());
8399
+ const appointments = querySnapshot.docs.map((doc54) => doc54.data());
8389
8400
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
8390
8401
  console.log(
8391
8402
  `[APPOINTMENT_SERVICE] Found ${appointments.length} past appointments for patient ${patientId}`
@@ -9665,7 +9676,7 @@ var AppointmentService = class extends BaseService {
9665
9676
  );
9666
9677
  const proceduresSnapshot = await getDocs9(proceduresQuery);
9667
9678
  availableProcedureIds = new Set(
9668
- proceduresSnapshot.docs.map((doc53) => doc53.id)
9679
+ proceduresSnapshot.docs.map((doc54) => doc54.id)
9669
9680
  );
9670
9681
  console.log(
9671
9682
  `[APPOINTMENT_SERVICE] Found ${availableProcedureIds.size} procedures available at clinic ${options.clinicBranchId}`
@@ -9789,8 +9800,8 @@ var userSchema = z11.object({
9789
9800
  // src/services/user/user.service.ts
9790
9801
  import {
9791
9802
  collection as collection15,
9792
- doc as doc26,
9793
- getDoc as getDoc28,
9803
+ doc as doc27,
9804
+ getDoc as getDoc29,
9794
9805
  getDocs as getDocs15,
9795
9806
  query as query15,
9796
9807
  where as where15,
@@ -9941,8 +9952,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
9941
9952
  }
9942
9953
  const patientsSnapshot = await getDocs10(q);
9943
9954
  const patients = [];
9944
- patientsSnapshot.forEach((doc53) => {
9945
- patients.push(doc53.data());
9955
+ patientsSnapshot.forEach((doc54) => {
9956
+ patients.push(doc54.data());
9946
9957
  });
9947
9958
  console.log(
9948
9959
  `[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
@@ -10317,9 +10328,9 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
10317
10328
  };
10318
10329
  var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, requesterRoles) => {
10319
10330
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10320
- const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10321
- if (!doc53.exists()) throw new Error("Medical info not found");
10322
- const medicalInfo = doc53.data();
10331
+ const doc54 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10332
+ if (!doc54.exists()) throw new Error("Medical info not found");
10333
+ const medicalInfo = doc54.data();
10323
10334
  if (allergyIndex >= medicalInfo.allergies.length) {
10324
10335
  throw new Error("Invalid allergy index");
10325
10336
  }
@@ -10346,9 +10357,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
10346
10357
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10347
10358
  const validatedData = updateBlockingConditionSchema.parse(data);
10348
10359
  const { conditionIndex, ...updateData } = validatedData;
10349
- const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10350
- if (!doc53.exists()) throw new Error("Medical info not found");
10351
- const medicalInfo = doc53.data();
10360
+ const doc54 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10361
+ if (!doc54.exists()) throw new Error("Medical info not found");
10362
+ const medicalInfo = doc54.data();
10352
10363
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
10353
10364
  throw new Error("Invalid blocking condition index");
10354
10365
  }
@@ -10365,9 +10376,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
10365
10376
  };
10366
10377
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requesterId, requesterRoles) => {
10367
10378
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10368
- const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10369
- if (!doc53.exists()) throw new Error("Medical info not found");
10370
- const medicalInfo = doc53.data();
10379
+ const doc54 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10380
+ if (!doc54.exists()) throw new Error("Medical info not found");
10381
+ const medicalInfo = doc54.data();
10371
10382
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
10372
10383
  throw new Error("Invalid blocking condition index");
10373
10384
  }
@@ -10394,9 +10405,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
10394
10405
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10395
10406
  const validatedData = updateContraindicationSchema.parse(data);
10396
10407
  const { contraindicationIndex, ...updateData } = validatedData;
10397
- const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10398
- if (!doc53.exists()) throw new Error("Medical info not found");
10399
- const medicalInfo = doc53.data();
10408
+ const doc54 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10409
+ if (!doc54.exists()) throw new Error("Medical info not found");
10410
+ const medicalInfo = doc54.data();
10400
10411
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
10401
10412
  throw new Error("Invalid contraindication index");
10402
10413
  }
@@ -10413,9 +10424,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
10413
10424
  };
10414
10425
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, requesterId, requesterRoles) => {
10415
10426
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10416
- const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10417
- if (!doc53.exists()) throw new Error("Medical info not found");
10418
- const medicalInfo = doc53.data();
10427
+ const doc54 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10428
+ if (!doc54.exists()) throw new Error("Medical info not found");
10429
+ const medicalInfo = doc54.data();
10419
10430
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
10420
10431
  throw new Error("Invalid contraindication index");
10421
10432
  }
@@ -10442,9 +10453,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
10442
10453
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10443
10454
  const validatedData = updateMedicationSchema.parse(data);
10444
10455
  const { medicationIndex, ...updateData } = validatedData;
10445
- const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10446
- if (!doc53.exists()) throw new Error("Medical info not found");
10447
- const medicalInfo = doc53.data();
10456
+ const doc54 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10457
+ if (!doc54.exists()) throw new Error("Medical info not found");
10458
+ const medicalInfo = doc54.data();
10448
10459
  if (medicationIndex >= medicalInfo.currentMedications.length) {
10449
10460
  throw new Error("Invalid medication index");
10450
10461
  }
@@ -10461,9 +10472,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
10461
10472
  };
10462
10473
  var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, requesterRoles) => {
10463
10474
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10464
- const doc53 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10465
- if (!doc53.exists()) throw new Error("Medical info not found");
10466
- const medicalInfo = doc53.data();
10475
+ const doc54 = await getDoc17(getMedicalInfoDocRef(db, patientId));
10476
+ if (!doc54.exists()) throw new Error("Medical info not found");
10477
+ const medicalInfo = doc54.data();
10467
10478
  if (medicationIndex >= medicalInfo.currentMedications.length) {
10468
10479
  throw new Error("Invalid medication index");
10469
10480
  }
@@ -10766,7 +10777,7 @@ var searchPatientsUtil = async (db, params, requester) => {
10766
10777
  const finalQuery = query11(patientsCollectionRef, ...constraints);
10767
10778
  const querySnapshot = await getDocs11(finalQuery);
10768
10779
  const patients = querySnapshot.docs.map(
10769
- (doc53) => doc53.data()
10780
+ (doc54) => doc54.data()
10770
10781
  );
10771
10782
  console.log(
10772
10783
  `[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
@@ -10798,8 +10809,8 @@ var getAllPatientsUtil = async (db, options) => {
10798
10809
  }
10799
10810
  const patientsSnapshot = await getDocs11(q);
10800
10811
  const patients = [];
10801
- patientsSnapshot.forEach((doc53) => {
10802
- patients.push(doc53.data());
10812
+ patientsSnapshot.forEach((doc54) => {
10813
+ patients.push(doc54.data());
10803
10814
  });
10804
10815
  console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
10805
10816
  return patients;
@@ -10932,7 +10943,7 @@ var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
10932
10943
  if (querySnapshot.empty) {
10933
10944
  return [];
10934
10945
  }
10935
- return querySnapshot.docs.map((doc53) => doc53.data());
10946
+ return querySnapshot.docs.map((doc54) => doc54.data());
10936
10947
  };
10937
10948
  var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
10938
10949
  const tokensRef = collection12(
@@ -10950,7 +10961,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
10950
10961
  if (querySnapshot.empty) {
10951
10962
  return [];
10952
10963
  }
10953
- return querySnapshot.docs.map((doc53) => doc53.data());
10964
+ return querySnapshot.docs.map((doc54) => doc54.data());
10954
10965
  };
10955
10966
 
10956
10967
  // src/services/patient/utils/aesthetic-analysis.utils.ts
@@ -12711,8 +12722,8 @@ var ClinicAdminService = class extends BaseService {
12711
12722
  // src/services/practitioner/practitioner.service.ts
12712
12723
  import {
12713
12724
  collection as collection14,
12714
- doc as doc25,
12715
- getDoc as getDoc27,
12725
+ doc as doc26,
12726
+ getDoc as getDoc28,
12716
12727
  getDocs as getDocs14,
12717
12728
  query as query14,
12718
12729
  where as where14,
@@ -12731,8 +12742,8 @@ import {
12731
12742
  // src/services/tier-enforcement.ts
12732
12743
  import {
12733
12744
  collection as collection13,
12734
- doc as doc24,
12735
- getDoc as getDoc26,
12745
+ doc as doc25,
12746
+ getDoc as getDoc27,
12736
12747
  getDocs as getDocs13,
12737
12748
  query as query13,
12738
12749
  where as where13
@@ -12936,6 +12947,124 @@ var DEFAULT_ROLE_PERMISSIONS = {
12936
12947
  "billing.manage": false
12937
12948
  }
12938
12949
  };
12950
+ var DEFAULT_PLAN_CONFIG = {
12951
+ version: 1,
12952
+ updatedAt: null,
12953
+ updatedBy: "system",
12954
+ tiers: {
12955
+ free: {
12956
+ name: "Free",
12957
+ limits: { maxProvidersPerBranch: 1, maxProceduresPerProvider: 3, maxBranches: 1 }
12958
+ },
12959
+ connect: {
12960
+ name: "Connect",
12961
+ limits: { maxProvidersPerBranch: 3, maxProceduresPerProvider: 10, maxBranches: 1 }
12962
+ },
12963
+ pro: {
12964
+ name: "Pro",
12965
+ limits: { maxProvidersPerBranch: 5, maxProceduresPerProvider: 20, maxBranches: 3 }
12966
+ }
12967
+ },
12968
+ plans: {
12969
+ FREE: {
12970
+ priceId: null,
12971
+ priceMonthly: 0,
12972
+ currency: "CHF",
12973
+ description: "Get started with basic access",
12974
+ stripeProductId: null
12975
+ },
12976
+ CONNECT: {
12977
+ priceId: "price_1TD0l7AaFI0fqFWNC8Lg3QJG",
12978
+ priceMonthly: 199,
12979
+ currency: "CHF",
12980
+ description: "Consultation tools and integrated booking",
12981
+ stripeProductId: null
12982
+ },
12983
+ PRO: {
12984
+ priceId: "price_1TD0lEAaFI0fqFWN3tzCrfUb",
12985
+ priceMonthly: 449,
12986
+ currency: "CHF",
12987
+ description: "Complete clinic management with CRM and analytics",
12988
+ stripeProductId: null
12989
+ }
12990
+ },
12991
+ addons: {
12992
+ seat: {
12993
+ priceId: "price_1TD0lKAaFI0fqFWNH9pQgTzI",
12994
+ pricePerUnit: 39,
12995
+ currency: "CHF",
12996
+ allowedTiers: ["connect", "pro"]
12997
+ },
12998
+ branch: {
12999
+ connect: { priceId: "price_1TD0lSAaFI0fqFWNjsPvzW1T", pricePerUnit: 119, currency: "CHF" },
13000
+ pro: { priceId: "price_1TD0lTAaFI0fqFWNYxUnvUxH", pricePerUnit: 279, currency: "CHF" },
13001
+ allowedTiers: ["connect", "pro"]
13002
+ },
13003
+ procedure: {
13004
+ priceId: "price_1TCL3eAaFI0fqFWNJVuMYjii",
13005
+ pricePerBlock: 19,
13006
+ proceduresPerBlock: 5,
13007
+ currency: "CHF",
13008
+ allowedTiers: ["connect", "pro"]
13009
+ }
13010
+ },
13011
+ priceToModel: {
13012
+ "price_1TD0l7AaFI0fqFWNC8Lg3QJG": "connect",
13013
+ "price_1TD0lEAaFI0fqFWN3tzCrfUb": "pro"
13014
+ },
13015
+ priceToType: {
13016
+ "price_1TD0l7AaFI0fqFWNC8Lg3QJG": "CONNECT",
13017
+ "price_1TD0lEAaFI0fqFWN3tzCrfUb": "PRO"
13018
+ },
13019
+ addonPriceIds: [
13020
+ "price_1TD0lKAaFI0fqFWNH9pQgTzI",
13021
+ // seat
13022
+ "price_1TD0lSAaFI0fqFWNjsPvzW1T",
13023
+ // branch connect
13024
+ "price_1TD0lTAaFI0fqFWNYxUnvUxH",
13025
+ // branch pro
13026
+ "price_1TCL3eAaFI0fqFWNJVuMYjii"
13027
+ // procedure
13028
+ ]
13029
+ };
13030
+ var PERMISSION_LABELS = {
13031
+ "clinic.view": { label: "View Clinic", description: "See clinic information and profile", category: "Clinic" },
13032
+ "clinic.edit": { label: "Edit Clinic", description: "Modify clinic settings and profile", category: "Clinic" },
13033
+ "reviews.view": { label: "View Reviews", description: "See patient reviews and ratings", category: "Clinic" },
13034
+ "calendar.view": { label: "View Calendar", description: "See the clinic calendar and schedules", category: "Calendar" },
13035
+ "appointments.view": { label: "View Appointments", description: "See appointment list and details", category: "Appointments" },
13036
+ "appointments.confirm": { label: "Confirm Appointments", description: "Confirm pending appointment requests", category: "Appointments" },
13037
+ "appointments.cancel": { label: "Cancel Appointments", description: "Cancel existing appointments", category: "Appointments" },
13038
+ "messaging": { label: "Messaging", description: "Send and receive messages with patients", category: "Messaging" },
13039
+ "procedures.view": { label: "View Procedures", description: "See the procedures catalog", category: "Procedures" },
13040
+ "procedures.create": { label: "Create Procedures", description: "Add new procedures to the catalog", category: "Procedures" },
13041
+ "procedures.edit": { label: "Edit Procedures", description: "Modify existing procedures", category: "Procedures" },
13042
+ "procedures.delete": { label: "Delete Procedures", description: "Remove procedures from the catalog", category: "Procedures" },
13043
+ "resources.view": { label: "View Resources", description: "See clinic resources and equipment", category: "Resources" },
13044
+ "resources.create": { label: "Create Resources", description: "Add new resources", category: "Resources" },
13045
+ "resources.edit": { label: "Edit Resources", description: "Modify existing resources", category: "Resources" },
13046
+ "resources.delete": { label: "Delete Resources", description: "Remove resources", category: "Resources" },
13047
+ "patients.view": { label: "View Patients", description: "See patient list and profiles", category: "Patients" },
13048
+ "patients.edit": { label: "Edit Patients", description: "Modify patient records", category: "Patients" },
13049
+ "providers.view": { label: "View Providers", description: "See the practitioners/providers list", category: "Providers" },
13050
+ "providers.manage": { label: "Manage Providers", description: "Add, edit, or remove providers", category: "Providers" },
13051
+ "analytics.view": { label: "View Analytics", description: "Access analytics dashboards and reports", category: "Analytics" },
13052
+ "staff.manage": { label: "Manage Staff", description: "Add, remove, and assign roles to staff", category: "Administration" },
13053
+ "settings.manage": { label: "Manage Settings", description: "Modify clinic group settings", category: "Administration" },
13054
+ "billing.manage": { label: "Manage Billing", description: "Access billing, subscriptions, and payments", category: "Administration" }
13055
+ };
13056
+ var PERMISSION_CATEGORIES = [
13057
+ "Clinic",
13058
+ "Calendar",
13059
+ "Appointments",
13060
+ "Messaging",
13061
+ "Procedures",
13062
+ "Resources",
13063
+ "Patients",
13064
+ "Providers",
13065
+ "Analytics",
13066
+ "Administration"
13067
+ ];
12939
13068
  var TIER_MAP = {
12940
13069
  no_subscription: "free",
12941
13070
  free: "free",
@@ -12947,6 +13076,49 @@ function resolveEffectiveTier(subscriptionModel) {
12947
13076
  return TIER_MAP[lower] || "free";
12948
13077
  }
12949
13078
 
13079
+ // src/services/plan-config.service.ts
13080
+ import { doc as doc24, getDoc as getDoc26 } from "firebase/firestore";
13081
+ var CACHE_TTL_MS = 5 * 60 * 1e3;
13082
+ var PlanConfigService = class {
13083
+ constructor() {
13084
+ this.cachedConfig = null;
13085
+ this.cacheExpiry = 0;
13086
+ }
13087
+ /**
13088
+ * Returns the current plan config, reading from Firestore if the cache
13089
+ * has expired. Falls back to DEFAULT_PLAN_CONFIG if the doc is missing.
13090
+ */
13091
+ async getConfig(db) {
13092
+ const now = Date.now();
13093
+ if (this.cachedConfig && now < this.cacheExpiry) {
13094
+ return this.cachedConfig;
13095
+ }
13096
+ try {
13097
+ const [collectionPath, docId] = PLAN_CONFIG_PATH.split("/");
13098
+ const configRef = doc24(db, collectionPath, docId);
13099
+ const snap = await getDoc26(configRef);
13100
+ if (snap.exists()) {
13101
+ this.cachedConfig = snap.data();
13102
+ } else {
13103
+ this.cachedConfig = DEFAULT_PLAN_CONFIG;
13104
+ }
13105
+ } catch (error) {
13106
+ console.error("PlanConfigService: Firestore read failed, using fallback config", error);
13107
+ if (!this.cachedConfig) {
13108
+ this.cachedConfig = DEFAULT_PLAN_CONFIG;
13109
+ }
13110
+ }
13111
+ this.cacheExpiry = now + CACHE_TTL_MS;
13112
+ return this.cachedConfig;
13113
+ }
13114
+ /** Clears the cache — useful for testing or after config updates. */
13115
+ invalidateCache() {
13116
+ this.cachedConfig = null;
13117
+ this.cacheExpiry = 0;
13118
+ }
13119
+ };
13120
+ var planConfigService = new PlanConfigService();
13121
+
12950
13122
  // src/services/tier-enforcement.ts
12951
13123
  var TierLimitError = class extends Error {
12952
13124
  constructor(resource, currentTier, currentCount, maxAllowed) {
@@ -12965,8 +13137,8 @@ var TierLimitError = class extends Error {
12965
13137
  }
12966
13138
  };
12967
13139
  async function getClinicGroupTierData(db, clinicGroupId) {
12968
- const groupRef = doc24(db, CLINIC_GROUPS_COLLECTION, clinicGroupId);
12969
- const groupSnap = await getDoc26(groupRef);
13140
+ const groupRef = doc25(db, CLINIC_GROUPS_COLLECTION, clinicGroupId);
13141
+ const groupSnap = await getDoc27(groupRef);
12970
13142
  if (!groupSnap.exists()) {
12971
13143
  throw new Error(`Clinic group ${clinicGroupId} not found`);
12972
13144
  }
@@ -13019,14 +13191,15 @@ async function countBranchesInGroup(db, clinicGroupId) {
13019
13191
  return clinicsSnap.size;
13020
13192
  }
13021
13193
  async function enforceProviderLimit(db, clinicGroupId, branchId) {
13022
- var _a;
13194
+ var _a, _b;
13023
13195
  const { tier, billing } = await getClinicGroupTierData(db, clinicGroupId);
13024
- const config = TIER_CONFIG[tier];
13025
- if (!config) return;
13026
- const baseMax = config.limits.maxProvidersPerBranch;
13196
+ const dynamicConfig = await planConfigService.getConfig(db);
13197
+ const tierDef = (_a = dynamicConfig.tiers[tier]) != null ? _a : TIER_CONFIG[tier];
13198
+ if (!tierDef) return;
13199
+ const baseMax = tierDef.limits.maxProvidersPerBranch;
13027
13200
  if (baseMax === -1) return;
13028
13201
  const addOns = (billing == null ? void 0 : billing.addOns) || {};
13029
- const extraProviders = ((_a = addOns[branchId]) == null ? void 0 : _a.extraProviders) || 0;
13202
+ const extraProviders = ((_b = addOns[branchId]) == null ? void 0 : _b.extraProviders) || 0;
13030
13203
  const effectiveMax = baseMax + extraProviders;
13031
13204
  const currentCount = await countProvidersInBranch(db, branchId);
13032
13205
  if (currentCount + 1 > effectiveMax) {
@@ -13034,25 +13207,29 @@ async function enforceProviderLimit(db, clinicGroupId, branchId) {
13034
13207
  }
13035
13208
  }
13036
13209
  async function enforceProcedureLimit(db, clinicGroupId, branchId, providerId, count = 1) {
13037
- var _a;
13210
+ var _a, _b, _c, _d, _e;
13038
13211
  const { tier, billing } = await getClinicGroupTierData(db, clinicGroupId);
13039
- const config = TIER_CONFIG[tier];
13040
- if (!config) return;
13041
- const baseMax = config.limits.maxProceduresPerProvider;
13212
+ const dynamicConfig = await planConfigService.getConfig(db);
13213
+ const tierDef = (_a = dynamicConfig.tiers[tier]) != null ? _a : TIER_CONFIG[tier];
13214
+ if (!tierDef) return;
13215
+ const baseMax = tierDef.limits.maxProceduresPerProvider;
13042
13216
  if (baseMax === -1) return;
13043
13217
  const addOns = (billing == null ? void 0 : billing.addOns) || {};
13044
- const procedureBlocks = ((_a = addOns[branchId]) == null ? void 0 : _a.procedureBlocks) || 0;
13045
- const effectiveMax = baseMax + procedureBlocks * 5;
13218
+ const procedureBlocks = ((_b = addOns[branchId]) == null ? void 0 : _b.procedureBlocks) || 0;
13219
+ const proceduresPerBlock = (_e = (_d = (_c = dynamicConfig.addons) == null ? void 0 : _c.procedure) == null ? void 0 : _d.proceduresPerBlock) != null ? _e : 5;
13220
+ const effectiveMax = baseMax + procedureBlocks * proceduresPerBlock;
13046
13221
  const currentCount = await countProceduresForProvider(db, branchId, providerId);
13047
13222
  if (currentCount + count > effectiveMax) {
13048
13223
  throw new TierLimitError("procedures for this provider", tier, currentCount, effectiveMax);
13049
13224
  }
13050
13225
  }
13051
13226
  async function enforceBranchLimit(db, clinicGroupId) {
13227
+ var _a;
13052
13228
  const { tier, billing } = await getClinicGroupTierData(db, clinicGroupId);
13053
- const config = TIER_CONFIG[tier];
13054
- if (!config) return;
13055
- const baseMax = config.limits.maxBranches;
13229
+ const dynamicConfig = await planConfigService.getConfig(db);
13230
+ const tierDef = (_a = dynamicConfig.tiers[tier]) != null ? _a : TIER_CONFIG[tier];
13231
+ if (!tierDef) return;
13232
+ const baseMax = tierDef.limits.maxBranches;
13056
13233
  if (baseMax === -1) return;
13057
13234
  const branchAddonCount = (billing == null ? void 0 : billing.branchAddonCount) || 0;
13058
13235
  const effectiveMax = baseMax + branchAddonCount;
@@ -13309,8 +13486,8 @@ var PractitionerService = class extends BaseService {
13309
13486
  try {
13310
13487
  const validData = createPractitionerSchema.parse(data);
13311
13488
  if (validData.clinics && validData.clinics.length > 0) {
13312
- const clinicRef = doc25(this.db, CLINICS_COLLECTION, validData.clinics[0]);
13313
- const clinicSnap = await getDoc27(clinicRef);
13489
+ const clinicRef = doc26(this.db, CLINICS_COLLECTION, validData.clinics[0]);
13490
+ const clinicSnap = await getDoc28(clinicRef);
13314
13491
  if (clinicSnap.exists()) {
13315
13492
  const clinicGroupId = clinicSnap.data().clinicGroupId;
13316
13493
  if (clinicGroupId) {
@@ -13357,7 +13534,7 @@ var PractitionerService = class extends BaseService {
13357
13534
  createdAt: Timestamp18.now(),
13358
13535
  updatedAt: Timestamp18.now()
13359
13536
  });
13360
- const practitionerRef = doc25(
13537
+ const practitionerRef = doc26(
13361
13538
  this.db,
13362
13539
  PRACTITIONERS_COLLECTION,
13363
13540
  practitionerId
@@ -13468,7 +13645,7 @@ var PractitionerService = class extends BaseService {
13468
13645
  updatedAt: Timestamp18.now()
13469
13646
  });
13470
13647
  await setDoc15(
13471
- doc25(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
13648
+ doc26(this.db, PRACTITIONERS_COLLECTION, practitionerData.id),
13472
13649
  practitionerData
13473
13650
  );
13474
13651
  const savedPractitioner = await this.getPractitioner(practitionerData.id);
@@ -13490,7 +13667,7 @@ var PractitionerService = class extends BaseService {
13490
13667
  };
13491
13668
  practitionerTokenSchema.parse(token);
13492
13669
  const tokenPath = `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
13493
- await setDoc15(doc25(this.db, tokenPath), token);
13670
+ await setDoc15(doc26(this.db, tokenPath), token);
13494
13671
  return { practitioner: savedPractitioner, token };
13495
13672
  } catch (error) {
13496
13673
  if (error instanceof z21.ZodError) {
@@ -13561,7 +13738,7 @@ var PractitionerService = class extends BaseService {
13561
13738
  };
13562
13739
  practitionerTokenSchema.parse(token);
13563
13740
  const tokenPath = `${PRACTITIONERS_COLLECTION}/${validatedData.practitionerId}/${REGISTER_TOKENS_COLLECTION}/${token.id}`;
13564
- await setDoc15(doc25(this.db, tokenPath), token);
13741
+ await setDoc15(doc26(this.db, tokenPath), token);
13565
13742
  return token;
13566
13743
  } catch (error) {
13567
13744
  if (error instanceof z21.ZodError) {
@@ -13590,7 +13767,7 @@ var PractitionerService = class extends BaseService {
13590
13767
  }
13591
13768
  const q = query14(tokensRef, ...conditions);
13592
13769
  const querySnapshot = await getDocs14(q);
13593
- return querySnapshot.docs.map((doc53) => doc53.data());
13770
+ return querySnapshot.docs.map((doc54) => doc54.data());
13594
13771
  }
13595
13772
  /**
13596
13773
  * Gets a token by its string value and validates it
@@ -13653,7 +13830,7 @@ var PractitionerService = class extends BaseService {
13653
13830
  * @param userId ID of the user using the token
13654
13831
  */
13655
13832
  async markTokenAsUsed(tokenId, practitionerId, userId) {
13656
- const tokenRef = doc25(
13833
+ const tokenRef = doc26(
13657
13834
  this.db,
13658
13835
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${tokenId}`
13659
13836
  );
@@ -13671,11 +13848,11 @@ var PractitionerService = class extends BaseService {
13671
13848
  * @throws Error if token doesn't exist or doesn't belong to the specified clinic
13672
13849
  */
13673
13850
  async revokeToken(tokenId, practitionerId, clinicId) {
13674
- const tokenRef = doc25(
13851
+ const tokenRef = doc26(
13675
13852
  this.db,
13676
13853
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${REGISTER_TOKENS_COLLECTION}/${tokenId}`
13677
13854
  );
13678
- const tokenDoc = await getDoc27(tokenRef);
13855
+ const tokenDoc = await getDoc28(tokenRef);
13679
13856
  if (!tokenDoc.exists()) {
13680
13857
  throw new Error("Token not found");
13681
13858
  }
@@ -13695,8 +13872,8 @@ var PractitionerService = class extends BaseService {
13695
13872
  * Dohvata zdravstvenog radnika po ID-u
13696
13873
  */
13697
13874
  async getPractitioner(practitionerId) {
13698
- const practitionerDoc = await getDoc27(
13699
- doc25(this.db, PRACTITIONERS_COLLECTION, practitionerId)
13875
+ const practitionerDoc = await getDoc28(
13876
+ doc26(this.db, PRACTITIONERS_COLLECTION, practitionerId)
13700
13877
  );
13701
13878
  if (!practitionerDoc.exists()) {
13702
13879
  return null;
@@ -13802,20 +13979,20 @@ var PractitionerService = class extends BaseService {
13802
13979
  const debugSnapshot = await getDocs14(debugQ);
13803
13980
  console.log("[PRACTITIONER] Debug: Found practitioners with this email (any status):", {
13804
13981
  count: debugSnapshot.size,
13805
- practitioners: debugSnapshot.docs.map((doc53) => {
13982
+ practitioners: debugSnapshot.docs.map((doc54) => {
13806
13983
  var _a;
13807
13984
  return {
13808
- id: doc53.id,
13809
- email: (_a = doc53.data().basicInfo) == null ? void 0 : _a.email,
13810
- status: doc53.data().status,
13811
- userRef: doc53.data().userRef
13985
+ id: doc54.id,
13986
+ email: (_a = doc54.data().basicInfo) == null ? void 0 : _a.email,
13987
+ status: doc54.data().status,
13988
+ userRef: doc54.data().userRef
13812
13989
  };
13813
13990
  })
13814
13991
  });
13815
13992
  return [];
13816
13993
  }
13817
13994
  const draftPractitioners = querySnapshot.docs.map(
13818
- (doc53) => doc53.data()
13995
+ (doc54) => doc54.data()
13819
13996
  );
13820
13997
  console.log("[PRACTITIONER] Found draft practitioners", {
13821
13998
  email: normalizedEmail,
@@ -13876,7 +14053,7 @@ var PractitionerService = class extends BaseService {
13876
14053
  clinicWorkingHours: mergedWorkingHours,
13877
14054
  clinicsInfo: mergedClinicsInfo
13878
14055
  });
13879
- await deleteDoc4(doc25(this.db, PRACTITIONERS_COLLECTION, practitionerId));
14056
+ await deleteDoc4(doc26(this.db, PRACTITIONERS_COLLECTION, practitionerId));
13880
14057
  const activeTokens2 = await this.getPractitionerActiveTokens(practitionerId);
13881
14058
  for (const token of activeTokens2) {
13882
14059
  await this.markTokenAsUsed(token.id, practitionerId, userId);
@@ -13959,7 +14136,7 @@ var PractitionerService = class extends BaseService {
13959
14136
  clinicsInfo: mergedClinicsInfo2
13960
14137
  });
13961
14138
  for (const draft of validDrafts) {
13962
- await deleteDoc4(doc25(this.db, PRACTITIONERS_COLLECTION, draft.id));
14139
+ await deleteDoc4(doc26(this.db, PRACTITIONERS_COLLECTION, draft.id));
13963
14140
  const activeTokens = await this.getPractitionerActiveTokens(draft.id);
13964
14141
  for (const token of activeTokens) {
13965
14142
  await this.markTokenAsUsed(token.id, draft.id, userId);
@@ -13997,7 +14174,7 @@ var PractitionerService = class extends BaseService {
13997
14174
  await this.markTokenAsUsed(token.id, mainDraft.id, userId);
13998
14175
  }
13999
14176
  for (const draft of otherDrafts) {
14000
- await deleteDoc4(doc25(this.db, PRACTITIONERS_COLLECTION, draft.id));
14177
+ await deleteDoc4(doc26(this.db, PRACTITIONERS_COLLECTION, draft.id));
14001
14178
  const activeTokens = await this.getPractitionerActiveTokens(draft.id);
14002
14179
  for (const token of activeTokens) {
14003
14180
  await this.markTokenAsUsed(token.id, draft.id, userId);
@@ -14028,7 +14205,7 @@ var PractitionerService = class extends BaseService {
14028
14205
  where14("status", "==", "active" /* ACTIVE */)
14029
14206
  );
14030
14207
  const querySnapshot = await getDocs14(q);
14031
- return querySnapshot.docs.map((doc53) => doc53.data());
14208
+ return querySnapshot.docs.map((doc54) => doc54.data());
14032
14209
  }
14033
14210
  /**
14034
14211
  * Dohvata sve zdravstvene radnike za određenu kliniku
@@ -14040,7 +14217,7 @@ var PractitionerService = class extends BaseService {
14040
14217
  where14("isActive", "==", true)
14041
14218
  );
14042
14219
  const querySnapshot = await getDocs14(q);
14043
- return querySnapshot.docs.map((doc53) => doc53.data());
14220
+ return querySnapshot.docs.map((doc54) => doc54.data());
14044
14221
  }
14045
14222
  /**
14046
14223
  * Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
@@ -14052,7 +14229,7 @@ var PractitionerService = class extends BaseService {
14052
14229
  where14("status", "==", "draft" /* DRAFT */)
14053
14230
  );
14054
14231
  const querySnapshot = await getDocs14(q);
14055
- return querySnapshot.docs.map((doc53) => doc53.data());
14232
+ return querySnapshot.docs.map((doc54) => doc54.data());
14056
14233
  }
14057
14234
  /**
14058
14235
  * Updates a practitioner
@@ -14060,12 +14237,12 @@ var PractitionerService = class extends BaseService {
14060
14237
  async updatePractitioner(practitionerId, data) {
14061
14238
  try {
14062
14239
  const validData = data;
14063
- const practitionerRef = doc25(
14240
+ const practitionerRef = doc26(
14064
14241
  this.db,
14065
14242
  PRACTITIONERS_COLLECTION,
14066
14243
  practitionerId
14067
14244
  );
14068
- const practitionerDoc = await getDoc27(practitionerRef);
14245
+ const practitionerDoc = await getDoc28(practitionerRef);
14069
14246
  if (!practitionerDoc.exists()) {
14070
14247
  throw new Error(`Practitioner ${practitionerId} not found`);
14071
14248
  }
@@ -14106,12 +14283,12 @@ var PractitionerService = class extends BaseService {
14106
14283
  async addClinic(practitionerId, clinicId) {
14107
14284
  var _a;
14108
14285
  try {
14109
- const practitionerRef = doc25(
14286
+ const practitionerRef = doc26(
14110
14287
  this.db,
14111
14288
  PRACTITIONERS_COLLECTION,
14112
14289
  practitionerId
14113
14290
  );
14114
- const practitionerDoc = await getDoc27(practitionerRef);
14291
+ const practitionerDoc = await getDoc28(practitionerRef);
14115
14292
  if (!practitionerDoc.exists()) {
14116
14293
  throw new Error(`Practitioner ${practitionerId} not found`);
14117
14294
  }
@@ -14139,12 +14316,12 @@ var PractitionerService = class extends BaseService {
14139
14316
  */
14140
14317
  async removeClinic(practitionerId, clinicId) {
14141
14318
  try {
14142
- const practitionerRef = doc25(
14319
+ const practitionerRef = doc26(
14143
14320
  this.db,
14144
14321
  PRACTITIONERS_COLLECTION,
14145
14322
  practitionerId
14146
14323
  );
14147
- const practitionerDoc = await getDoc27(practitionerRef);
14324
+ const practitionerDoc = await getDoc28(practitionerRef);
14148
14325
  if (!practitionerDoc.exists()) {
14149
14326
  throw new Error(`Practitioner ${practitionerId} not found`);
14150
14327
  }
@@ -14184,7 +14361,7 @@ var PractitionerService = class extends BaseService {
14184
14361
  if (!practitioner) {
14185
14362
  throw new Error("Practitioner not found");
14186
14363
  }
14187
- await deleteDoc4(doc25(this.db, PRACTITIONERS_COLLECTION, practitionerId));
14364
+ await deleteDoc4(doc26(this.db, PRACTITIONERS_COLLECTION, practitionerId));
14188
14365
  }
14189
14366
  /**
14190
14367
  * Validates a registration token and claims the associated draft practitioner profile
@@ -14269,7 +14446,7 @@ var PractitionerService = class extends BaseService {
14269
14446
  );
14270
14447
  const querySnapshot = await getDocs14(q);
14271
14448
  const practitioners = querySnapshot.docs.map(
14272
- (doc53) => doc53.data()
14449
+ (doc54) => doc54.data()
14273
14450
  );
14274
14451
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
14275
14452
  return {
@@ -14367,7 +14544,7 @@ var PractitionerService = class extends BaseService {
14367
14544
  );
14368
14545
  const querySnapshot = await getDocs14(q);
14369
14546
  let practitioners = querySnapshot.docs.map(
14370
- (doc53) => ({ ...doc53.data(), id: doc53.id })
14547
+ (doc54) => ({ ...doc54.data(), id: doc54.id })
14371
14548
  );
14372
14549
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
14373
14550
  if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
@@ -14445,7 +14622,7 @@ var PractitionerService = class extends BaseService {
14445
14622
  );
14446
14623
  const querySnapshot = await getDocs14(q);
14447
14624
  let practitioners = querySnapshot.docs.map(
14448
- (doc53) => ({ ...doc53.data(), id: doc53.id })
14625
+ (doc54) => ({ ...doc54.data(), id: doc54.id })
14449
14626
  );
14450
14627
  if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
14451
14628
  const location = filters.location;
@@ -14489,7 +14666,7 @@ var PractitionerService = class extends BaseService {
14489
14666
  );
14490
14667
  const querySnapshot = await getDocs14(q);
14491
14668
  let practitioners = querySnapshot.docs.map(
14492
- (doc53) => ({ ...doc53.data(), id: doc53.id })
14669
+ (doc54) => ({ ...doc54.data(), id: doc54.id })
14493
14670
  );
14494
14671
  practitioners = this.applyInMemoryFilters(practitioners, filters);
14495
14672
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -14519,7 +14696,7 @@ var PractitionerService = class extends BaseService {
14519
14696
  );
14520
14697
  const querySnapshot = await getDocs14(q);
14521
14698
  let practitioners = querySnapshot.docs.map(
14522
- (doc53) => ({ ...doc53.data(), id: doc53.id })
14699
+ (doc54) => ({ ...doc54.data(), id: doc54.id })
14523
14700
  );
14524
14701
  practitioners = this.applyInMemoryFilters(practitioners, filters);
14525
14702
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -14986,12 +15163,12 @@ var UserService = class extends BaseService {
14986
15163
  updatedAt: serverTimestamp22(),
14987
15164
  lastLoginAt: serverTimestamp22()
14988
15165
  };
14989
- await setDoc16(doc26(this.db, USERS_COLLECTION, userData.uid), userData);
15166
+ await setDoc16(doc27(this.db, USERS_COLLECTION, userData.uid), userData);
14990
15167
  if (options == null ? void 0 : options.skipProfileCreation) {
14991
15168
  return this.getUserById(userData.uid);
14992
15169
  }
14993
15170
  const profiles = await this.createProfilesForRoles(userData.uid, roles, options);
14994
- await updateDoc23(doc26(this.db, USERS_COLLECTION, userData.uid), profiles);
15171
+ await updateDoc23(doc27(this.db, USERS_COLLECTION, userData.uid), profiles);
14995
15172
  return this.getUserById(userData.uid);
14996
15173
  }
14997
15174
  /**
@@ -15126,7 +15303,7 @@ var UserService = class extends BaseService {
15126
15303
  * Dohvata korisnika po ID-u
15127
15304
  */
15128
15305
  async getUserById(uid) {
15129
- const userDoc = await getDoc28(doc26(this.db, USERS_COLLECTION, uid));
15306
+ const userDoc = await getDoc29(doc27(this.db, USERS_COLLECTION, uid));
15130
15307
  if (!userDoc.exists()) {
15131
15308
  throw USER_ERRORS.NOT_FOUND;
15132
15309
  }
@@ -15148,15 +15325,15 @@ var UserService = class extends BaseService {
15148
15325
  const constraints = [where15("roles", "array-contains", role)];
15149
15326
  const q = query15(collection15(this.db, USERS_COLLECTION), ...constraints);
15150
15327
  const querySnapshot = await getDocs15(q);
15151
- const users = querySnapshot.docs.map((doc53) => doc53.data());
15328
+ const users = querySnapshot.docs.map((doc54) => doc54.data());
15152
15329
  return users.map((userData) => userSchema.parse(userData));
15153
15330
  }
15154
15331
  /**
15155
15332
  * Ažurira timestamp poslednjeg logovanja
15156
15333
  */
15157
15334
  async updateUserLoginTimestamp(uid) {
15158
- const userRef = doc26(this.db, USERS_COLLECTION, uid);
15159
- const userDoc = await getDoc28(userRef);
15335
+ const userRef = doc27(this.db, USERS_COLLECTION, uid);
15336
+ const userDoc = await getDoc29(userRef);
15160
15337
  if (!userDoc.exists()) {
15161
15338
  throw AUTH_ERRORS.USER_NOT_FOUND;
15162
15339
  }
@@ -15167,8 +15344,8 @@ var UserService = class extends BaseService {
15167
15344
  return this.getUserById(uid);
15168
15345
  }
15169
15346
  async upgradeAnonymousUser(uid, email) {
15170
- const userRef = doc26(this.db, USERS_COLLECTION, uid);
15171
- const userDoc = await getDoc28(userRef);
15347
+ const userRef = doc27(this.db, USERS_COLLECTION, uid);
15348
+ const userDoc = await getDoc29(userRef);
15172
15349
  if (!userDoc.exists()) {
15173
15350
  throw USER_ERRORS.NOT_FOUND;
15174
15351
  }
@@ -15180,8 +15357,8 @@ var UserService = class extends BaseService {
15180
15357
  return this.getUserById(uid);
15181
15358
  }
15182
15359
  async updateUser(uid, updates) {
15183
- const userRef = doc26(this.db, USERS_COLLECTION, uid);
15184
- const userDoc = await getDoc28(userRef);
15360
+ const userRef = doc27(this.db, USERS_COLLECTION, uid);
15361
+ const userDoc = await getDoc29(userRef);
15185
15362
  if (!userDoc.exists()) {
15186
15363
  throw USER_ERRORS.NOT_FOUND;
15187
15364
  }
@@ -15212,7 +15389,7 @@ var UserService = class extends BaseService {
15212
15389
  const user = await this.getUserById(uid);
15213
15390
  if (user.roles.includes(role)) return;
15214
15391
  const profiles = await this.createProfilesForRoles(uid, [role], options);
15215
- await updateDoc23(doc26(this.db, USERS_COLLECTION, uid), {
15392
+ await updateDoc23(doc27(this.db, USERS_COLLECTION, uid), {
15216
15393
  roles: [...user.roles, role],
15217
15394
  ...profiles,
15218
15395
  updatedAt: serverTimestamp22()
@@ -15241,7 +15418,7 @@ var UserService = class extends BaseService {
15241
15418
  }
15242
15419
  break;
15243
15420
  }
15244
- await updateDoc23(doc26(this.db, USERS_COLLECTION, uid), {
15421
+ await updateDoc23(doc27(this.db, USERS_COLLECTION, uid), {
15245
15422
  roles: user.roles.filter((r) => r !== role),
15246
15423
  updatedAt: serverTimestamp22()
15247
15424
  });
@@ -15252,8 +15429,8 @@ var UserService = class extends BaseService {
15252
15429
  * @param data - Acquisition source data
15253
15430
  */
15254
15431
  async updateAcquisitionSource(uid, data) {
15255
- const userRef = doc26(this.db, USERS_COLLECTION, uid);
15256
- const userDoc = await getDoc28(userRef);
15432
+ const userRef = doc27(this.db, USERS_COLLECTION, uid);
15433
+ const userDoc = await getDoc29(userRef);
15257
15434
  if (!userDoc.exists()) {
15258
15435
  throw USER_ERRORS.NOT_FOUND;
15259
15436
  }
@@ -15271,8 +15448,8 @@ var UserService = class extends BaseService {
15271
15448
  }
15272
15449
  // Delete operations
15273
15450
  async deleteUser(uid) {
15274
- const userRef = doc26(this.db, USERS_COLLECTION, uid);
15275
- const userDoc = await getDoc28(userRef);
15451
+ const userRef = doc27(this.db, USERS_COLLECTION, uid);
15452
+ const userDoc = await getDoc29(userRef);
15276
15453
  if (!userDoc.exists()) {
15277
15454
  throw USER_ERRORS.NOT_FOUND;
15278
15455
  }
@@ -15337,9 +15514,9 @@ var BillingTransactionsService = class extends BaseService {
15337
15514
  const querySnapshot = await getDocs16(q);
15338
15515
  const docs = querySnapshot.docs;
15339
15516
  const hasMore = docs.length > queryLimit;
15340
- const transactions = docs.slice(0, queryLimit).map((doc53) => ({
15341
- id: doc53.id,
15342
- ...doc53.data()
15517
+ const transactions = docs.slice(0, queryLimit).map((doc54) => ({
15518
+ id: doc54.id,
15519
+ ...doc54.data()
15343
15520
  }));
15344
15521
  const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
15345
15522
  return {
@@ -15415,9 +15592,9 @@ var BillingTransactionsService = class extends BaseService {
15415
15592
  const querySnapshot = await getDocs16(q);
15416
15593
  const docs = querySnapshot.docs;
15417
15594
  const hasMore = docs.length > queryLimit;
15418
- const transactions = docs.slice(0, queryLimit).map((doc53) => ({
15419
- id: doc53.id,
15420
- ...doc53.data()
15595
+ const transactions = docs.slice(0, queryLimit).map((doc54) => ({
15596
+ id: doc54.id,
15597
+ ...doc54.data()
15421
15598
  }));
15422
15599
  const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
15423
15600
  return {
@@ -15440,8 +15617,8 @@ var BillingTransactionsService = class extends BaseService {
15440
15617
  // src/services/clinic/utils/clinic-group.utils.ts
15441
15618
  import {
15442
15619
  collection as collection17,
15443
- doc as doc27,
15444
- getDoc as getDoc29,
15620
+ doc as doc28,
15621
+ getDoc as getDoc30,
15445
15622
  getDocs as getDocs17,
15446
15623
  query as query17,
15447
15624
  where as where17,
@@ -15573,7 +15750,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
15573
15750
  }
15574
15751
  const now = Timestamp20.now();
15575
15752
  console.log("[CLINIC_GROUP] Preparing clinic group data object");
15576
- const groupId = doc27(collection17(db, CLINIC_GROUPS_COLLECTION)).id;
15753
+ const groupId = doc28(collection17(db, CLINIC_GROUPS_COLLECTION)).id;
15577
15754
  console.log("[CLINIC_GROUP] Logo value:", {
15578
15755
  logoValue: validatedData.logo,
15579
15756
  logoType: validatedData.logo === null ? "null" : typeof validatedData.logo
@@ -15623,7 +15800,7 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
15623
15800
  groupId: groupData.id
15624
15801
  });
15625
15802
  try {
15626
- await setDoc17(doc27(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
15803
+ await setDoc17(doc28(db, CLINIC_GROUPS_COLLECTION, groupData.id), groupData);
15627
15804
  console.log("[CLINIC_GROUP] Clinic group saved successfully");
15628
15805
  } catch (firestoreError) {
15629
15806
  console.error(
@@ -15669,8 +15846,8 @@ async function createClinicGroup(db, data, ownerId, isDefault = false, clinicAdm
15669
15846
  }
15670
15847
  }
15671
15848
  async function getClinicGroup(db, groupId) {
15672
- const docRef = doc27(db, CLINIC_GROUPS_COLLECTION, groupId);
15673
- const docSnap = await getDoc29(docRef);
15849
+ const docRef = doc28(db, CLINIC_GROUPS_COLLECTION, groupId);
15850
+ const docSnap = await getDoc30(docRef);
15674
15851
  if (docSnap.exists()) {
15675
15852
  return docSnap.data();
15676
15853
  }
@@ -15682,7 +15859,7 @@ async function getAllActiveGroups(db) {
15682
15859
  where17("isActive", "==", true)
15683
15860
  );
15684
15861
  const querySnapshot = await getDocs17(q);
15685
- return querySnapshot.docs.map((doc53) => doc53.data());
15862
+ return querySnapshot.docs.map((doc54) => doc54.data());
15686
15863
  }
15687
15864
  async function updateClinicGroup(db, groupId, data, app) {
15688
15865
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -15713,7 +15890,7 @@ async function updateClinicGroup(db, groupId, data, app) {
15713
15890
  updatedAt: Timestamp20.now()
15714
15891
  };
15715
15892
  console.log("[CLINIC_GROUP] Updating clinic group in Firestore");
15716
- await updateDoc24(doc27(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
15893
+ await updateDoc24(doc28(db, CLINIC_GROUPS_COLLECTION, groupId), updatedData);
15717
15894
  console.log("[CLINIC_GROUP] Clinic group updated successfully");
15718
15895
  const updatedGroup = await getClinicGroup(db, groupId);
15719
15896
  if (!updatedGroup) {
@@ -16095,8 +16272,8 @@ var ClinicGroupService = class extends BaseService {
16095
16272
  // src/services/clinic/clinic.service.ts
16096
16273
  import {
16097
16274
  collection as collection21,
16098
- doc as doc29,
16099
- getDoc as getDoc31,
16275
+ doc as doc30,
16276
+ getDoc as getDoc32,
16100
16277
  getDocs as getDocs21,
16101
16278
  updateDoc as updateDoc26,
16102
16279
  serverTimestamp as serverTimestamp24,
@@ -16113,8 +16290,8 @@ import { z as z25 } from "zod";
16113
16290
  // src/services/clinic/utils/clinic.utils.ts
16114
16291
  import {
16115
16292
  collection as collection18,
16116
- doc as doc28,
16117
- getDoc as getDoc30,
16293
+ doc as doc29,
16294
+ getDoc as getDoc31,
16118
16295
  getDocs as getDocs18,
16119
16296
  query as query18,
16120
16297
  where as where18,
@@ -16158,8 +16335,8 @@ function filterClinicEmbeddedArrays(clinic, excludeDraftPractitioners = false) {
16158
16335
  return filteredClinic;
16159
16336
  }
16160
16337
  async function getClinic(db, clinicId, excludeDraftPractitioners = false) {
16161
- const docRef = doc28(db, CLINICS_COLLECTION, clinicId);
16162
- const docSnap = await getDoc30(docRef);
16338
+ const docRef = doc29(db, CLINICS_COLLECTION, clinicId);
16339
+ const docSnap = await getDoc31(docRef);
16163
16340
  if (docSnap.exists()) {
16164
16341
  const clinicData = docSnap.data();
16165
16342
  return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
@@ -16173,8 +16350,8 @@ async function getClinicsByGroup(db, groupId, excludeDraftPractitioners = false)
16173
16350
  where18("isActive", "==", true)
16174
16351
  );
16175
16352
  const querySnapshot = await getDocs18(q);
16176
- return querySnapshot.docs.map((doc53) => {
16177
- const clinicData = doc53.data();
16353
+ return querySnapshot.docs.map((doc54) => {
16354
+ const clinicData = doc54.data();
16178
16355
  return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
16179
16356
  });
16180
16357
  }
@@ -16337,7 +16514,7 @@ async function updateClinic(db, clinicId, data, adminId, clinicAdminService, app
16337
16514
  };
16338
16515
  console.log("[CLINIC] Updating clinic in Firestore");
16339
16516
  try {
16340
- await updateDoc25(doc28(db, CLINICS_COLLECTION, clinicId), updatedData);
16517
+ await updateDoc25(doc29(db, CLINICS_COLLECTION, clinicId), updatedData);
16341
16518
  console.log("[CLINIC] Clinic updated successfully");
16342
16519
  } catch (updateError) {
16343
16520
  console.error("[CLINIC] Error updating clinic in Firestore:", updateError);
@@ -16372,7 +16549,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
16372
16549
  }
16373
16550
  const q = query18(collection18(db, CLINICS_COLLECTION), ...constraints);
16374
16551
  const querySnapshot = await getDocs18(q);
16375
- return querySnapshot.docs.map((doc53) => doc53.data());
16552
+ return querySnapshot.docs.map((doc54) => doc54.data());
16376
16553
  }
16377
16554
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
16378
16555
  return getClinicsByAdmin(
@@ -16385,8 +16562,8 @@ async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGr
16385
16562
  }
16386
16563
  async function getClinicById(db, clinicId, excludeDraftPractitioners = false) {
16387
16564
  try {
16388
- const clinicRef = doc28(db, CLINICS_COLLECTION, clinicId);
16389
- const clinicSnapshot = await getDoc30(clinicRef);
16565
+ const clinicRef = doc29(db, CLINICS_COLLECTION, clinicId);
16566
+ const clinicSnapshot = await getDoc31(clinicRef);
16390
16567
  if (!clinicSnapshot.exists()) {
16391
16568
  return null;
16392
16569
  }
@@ -16418,11 +16595,11 @@ async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners
16418
16595
  }
16419
16596
  const clinicsSnapshot = await getDocs18(clinicsQuery);
16420
16597
  const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
16421
- const clinics = clinicsSnapshot.docs.map((doc53) => {
16422
- const data = doc53.data();
16598
+ const clinics = clinicsSnapshot.docs.map((doc54) => {
16599
+ const data = doc54.data();
16423
16600
  const clinicWithId = {
16424
16601
  ...data,
16425
- id: doc53.id
16602
+ id: doc54.id
16426
16603
  };
16427
16604
  return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
16428
16605
  });
@@ -16450,8 +16627,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc,
16450
16627
  ];
16451
16628
  const q = query18(collection18(db, CLINICS_COLLECTION), ...constraints);
16452
16629
  const querySnapshot = await getDocs18(q);
16453
- for (const doc53 of querySnapshot.docs) {
16454
- const clinic = doc53.data();
16630
+ for (const doc54 of querySnapshot.docs) {
16631
+ const clinic = doc54.data();
16455
16632
  const distance = distanceBetween2(
16456
16633
  [center.latitude, center.longitude],
16457
16634
  [clinic.location.latitude, clinic.location.longitude]
@@ -16574,8 +16751,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
16574
16751
  }
16575
16752
  const q = query19(collection19(db, CLINICS_COLLECTION), ...constraints);
16576
16753
  const querySnapshot = await getDocs19(q);
16577
- for (const doc53 of querySnapshot.docs) {
16578
- const clinic = doc53.data();
16754
+ for (const doc54 of querySnapshot.docs) {
16755
+ const clinic = doc54.data();
16579
16756
  const distance = distanceBetween3(
16580
16757
  [center.latitude, center.longitude],
16581
16758
  [clinic.location.latitude, clinic.location.longitude]
@@ -16707,7 +16884,7 @@ async function getClinicsByFilters(db, filters) {
16707
16884
  constraints.push(limit10(filters.pagination || 5));
16708
16885
  const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
16709
16886
  const querySnapshot = await getDocs20(q);
16710
- let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
16887
+ let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
16711
16888
  const excludeDrafts = filters.excludeDraftPractitioners === true;
16712
16889
  console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
16713
16890
  clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
@@ -16742,7 +16919,7 @@ async function getClinicsByFilters(db, filters) {
16742
16919
  constraints.push(limit10(filters.pagination || 5));
16743
16920
  const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
16744
16921
  const querySnapshot = await getDocs20(q);
16745
- let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
16922
+ let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
16746
16923
  const excludeDrafts = filters.excludeDraftPractitioners === true;
16747
16924
  console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
16748
16925
  clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
@@ -16775,7 +16952,7 @@ async function getClinicsByFilters(db, filters) {
16775
16952
  constraints.push(limit10(filters.pagination || 5));
16776
16953
  const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
16777
16954
  const querySnapshot = await getDocs20(q);
16778
- let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
16955
+ let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
16779
16956
  clinics = applyInMemoryFilters(clinics, filters);
16780
16957
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
16781
16958
  console.log(`[CLINIC_SERVICE] Strategy 3 success: ${clinics.length} clinics`);
@@ -16795,7 +16972,7 @@ async function getClinicsByFilters(db, filters) {
16795
16972
  ];
16796
16973
  const q = query20(collection20(db, CLINICS_COLLECTION), ...constraints);
16797
16974
  const querySnapshot = await getDocs20(q);
16798
- let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
16975
+ let clinics = querySnapshot.docs.map((doc54) => ({ ...doc54.data(), id: doc54.id }));
16799
16976
  clinics = applyInMemoryFilters(clinics, filters);
16800
16977
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
16801
16978
  console.log(`[CLINIC_SERVICE] Strategy 4 success: ${clinics.length} clinics`);
@@ -17101,9 +17278,9 @@ var ClinicService = class extends BaseService {
17101
17278
  updatedAt: serverTimestamp24()
17102
17279
  };
17103
17280
  const batch = writeBatch4(this.db);
17104
- const clinicRef = doc29(this.db, CLINICS_COLLECTION, clinicId);
17281
+ const clinicRef = doc30(this.db, CLINICS_COLLECTION, clinicId);
17105
17282
  batch.set(clinicRef, clinicData);
17106
- const adminRef = doc29(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
17283
+ const adminRef = doc30(this.db, CLINIC_ADMINS_COLLECTION, creatorAdminId);
17107
17284
  batch.update(adminRef, {
17108
17285
  clinicsManaged: arrayUnion7(clinicId),
17109
17286
  updatedAt: serverTimestamp24()
@@ -17127,8 +17304,8 @@ var ClinicService = class extends BaseService {
17127
17304
  */
17128
17305
  async updateClinic(clinicId, data, adminId) {
17129
17306
  try {
17130
- const clinicRef = doc29(this.db, CLINICS_COLLECTION, clinicId);
17131
- const clinicDoc = await getDoc31(clinicRef);
17307
+ const clinicRef = doc30(this.db, CLINICS_COLLECTION, clinicId);
17308
+ const clinicDoc = await getDoc32(clinicRef);
17132
17309
  if (!clinicDoc.exists()) {
17133
17310
  throw new Error(`Clinic ${clinicId} not found`);
17134
17311
  }
@@ -17210,7 +17387,7 @@ var ClinicService = class extends BaseService {
17210
17387
  * Deactivates a clinic.
17211
17388
  */
17212
17389
  async deactivateClinic(clinicId, adminId) {
17213
- const clinicRef = doc29(this.db, CLINICS_COLLECTION, clinicId);
17390
+ const clinicRef = doc30(this.db, CLINICS_COLLECTION, clinicId);
17214
17391
  await updateDoc26(clinicRef, {
17215
17392
  isActive: false,
17216
17393
  updatedAt: serverTimestamp24()
@@ -17220,7 +17397,7 @@ var ClinicService = class extends BaseService {
17220
17397
  * Activates a clinic.
17221
17398
  */
17222
17399
  async activateClinic(clinicId, adminId) {
17223
- const clinicRef = doc29(this.db, CLINICS_COLLECTION, clinicId);
17400
+ const clinicRef = doc30(this.db, CLINICS_COLLECTION, clinicId);
17224
17401
  await updateDoc26(clinicRef, {
17225
17402
  isActive: true,
17226
17403
  updatedAt: serverTimestamp24()
@@ -17372,11 +17549,11 @@ var ClinicService = class extends BaseService {
17372
17549
  async getClinicsForMap() {
17373
17550
  const clinicsRef = collection21(this.db, CLINICS_COLLECTION);
17374
17551
  const snapshot = await getDocs21(clinicsRef);
17375
- const clinicsForMap = snapshot.docs.map((doc53) => {
17552
+ const clinicsForMap = snapshot.docs.map((doc54) => {
17376
17553
  var _a, _b, _c;
17377
- const data = doc53.data();
17554
+ const data = doc54.data();
17378
17555
  return {
17379
- id: doc53.id,
17556
+ id: doc54.id,
17380
17557
  name: data.name,
17381
17558
  address: ((_a = data.location) == null ? void 0 : _a.address) || "",
17382
17559
  latitude: (_b = data.location) == null ? void 0 : _b.latitude,
@@ -18565,8 +18742,8 @@ var AuthService = class extends BaseService {
18565
18742
  // src/services/calendar/calendar.v2.service.ts
18566
18743
  import { Timestamp as Timestamp30, serverTimestamp as serverTimestamp30 } from "firebase/firestore";
18567
18744
  import {
18568
- doc as doc37,
18569
- getDoc as getDoc38,
18745
+ doc as doc38,
18746
+ getDoc as getDoc39,
18570
18747
  collection as collection28,
18571
18748
  query as query28,
18572
18749
  where as where28,
@@ -18578,8 +18755,8 @@ import {
18578
18755
  // src/services/calendar/utils/clinic.utils.ts
18579
18756
  import {
18580
18757
  collection as collection23,
18581
- doc as doc32,
18582
- getDoc as getDoc33,
18758
+ doc as doc33,
18759
+ getDoc as getDoc34,
18583
18760
  getDocs as getDocs23,
18584
18761
  setDoc as setDoc21,
18585
18762
  updateDoc as updateDoc28,
@@ -18592,39 +18769,39 @@ import {
18592
18769
  } from "firebase/firestore";
18593
18770
 
18594
18771
  // src/services/calendar/utils/docs.utils.ts
18595
- import { doc as doc31 } from "firebase/firestore";
18772
+ import { doc as doc32 } from "firebase/firestore";
18596
18773
  function getPractitionerCalendarEventDocRef(db, practitionerId, eventId) {
18597
- return doc31(
18774
+ return doc32(
18598
18775
  db,
18599
18776
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/${CALENDAR_COLLECTION}/${eventId}`
18600
18777
  );
18601
18778
  }
18602
18779
  function getPatientCalendarEventDocRef(db, patientId, eventId) {
18603
- return doc31(
18780
+ return doc32(
18604
18781
  db,
18605
18782
  `${PATIENTS_COLLECTION}/${patientId}/${CALENDAR_COLLECTION}/${eventId}`
18606
18783
  );
18607
18784
  }
18608
18785
  function getClinicCalendarEventDocRef(db, clinicId, eventId) {
18609
- return doc31(
18786
+ return doc32(
18610
18787
  db,
18611
18788
  `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}/${eventId}`
18612
18789
  );
18613
18790
  }
18614
18791
  function getPractitionerSyncedCalendarDocRef(db, practitionerId, syncedCalendarId) {
18615
- return doc31(
18792
+ return doc32(
18616
18793
  db,
18617
18794
  `${PRACTITIONERS_COLLECTION}/${practitionerId}/syncedCalendars/${syncedCalendarId}`
18618
18795
  );
18619
18796
  }
18620
18797
  function getPatientSyncedCalendarDocRef(db, patientId, syncedCalendarId) {
18621
- return doc31(
18798
+ return doc32(
18622
18799
  db,
18623
18800
  `${PATIENTS_COLLECTION}/${patientId}/syncedCalendars/${syncedCalendarId}`
18624
18801
  );
18625
18802
  }
18626
18803
  function getClinicSyncedCalendarDocRef(db, clinicId, syncedCalendarId) {
18627
- return doc31(
18804
+ return doc32(
18628
18805
  db,
18629
18806
  `${CLINICS_COLLECTION}/${clinicId}/syncedCalendars/${syncedCalendarId}`
18630
18807
  );
@@ -18654,14 +18831,14 @@ async function updateClinicCalendarEventUtil(db, clinicId, eventId, updateData)
18654
18831
  updatedAt: serverTimestamp25()
18655
18832
  };
18656
18833
  await updateDoc28(eventRef, updates);
18657
- const updatedDoc = await getDoc33(eventRef);
18834
+ const updatedDoc = await getDoc34(eventRef);
18658
18835
  if (!updatedDoc.exists()) {
18659
18836
  throw new Error("Event not found after update");
18660
18837
  }
18661
18838
  return updatedDoc.data();
18662
18839
  }
18663
18840
  async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
18664
- const clinicDoc = await getDoc33(doc32(db, `clinics/${clinicId}`));
18841
+ const clinicDoc = await getDoc34(doc33(db, `clinics/${clinicId}`));
18665
18842
  if (!clinicDoc.exists()) {
18666
18843
  throw new Error(`Clinic with ID ${clinicId} not found`);
18667
18844
  }
@@ -18670,8 +18847,8 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
18670
18847
  if (!clinicGroupId) {
18671
18848
  return false;
18672
18849
  }
18673
- const clinicGroupDoc = await getDoc33(
18674
- doc32(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
18850
+ const clinicGroupDoc = await getDoc34(
18851
+ doc33(db, `${CLINIC_GROUPS_COLLECTION}/${clinicGroupId}`)
18675
18852
  );
18676
18853
  if (!clinicGroupDoc.exists()) {
18677
18854
  return false;
@@ -18683,7 +18860,7 @@ async function checkAutoConfirmAppointmentsUtil(db, clinicId) {
18683
18860
  // src/services/calendar/utils/patient.utils.ts
18684
18861
  import {
18685
18862
  collection as collection24,
18686
- getDoc as getDoc34,
18863
+ getDoc as getDoc35,
18687
18864
  getDocs as getDocs24,
18688
18865
  setDoc as setDoc22,
18689
18866
  updateDoc as updateDoc29,
@@ -18717,7 +18894,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
18717
18894
  updatedAt: serverTimestamp26()
18718
18895
  };
18719
18896
  await updateDoc29(eventRef, updates);
18720
- const updatedDoc = await getDoc34(eventRef);
18897
+ const updatedDoc = await getDoc35(eventRef);
18721
18898
  if (!updatedDoc.exists()) {
18722
18899
  throw new Error("Event not found after update");
18723
18900
  }
@@ -18727,7 +18904,7 @@ async function updatePatientCalendarEventUtil(db, patientId, eventId, updateData
18727
18904
  // src/services/calendar/utils/practitioner.utils.ts
18728
18905
  import {
18729
18906
  collection as collection25,
18730
- getDoc as getDoc35,
18907
+ getDoc as getDoc36,
18731
18908
  getDocs as getDocs25,
18732
18909
  setDoc as setDoc23,
18733
18910
  updateDoc as updateDoc30,
@@ -18769,7 +18946,7 @@ async function updatePractitionerCalendarEventUtil(db, practitionerId, eventId,
18769
18946
  updatedAt: serverTimestamp27()
18770
18947
  };
18771
18948
  await updateDoc30(eventRef, updates);
18772
- const updatedDoc = await getDoc35(eventRef);
18949
+ const updatedDoc = await getDoc36(eventRef);
18773
18950
  if (!updatedDoc.exists()) {
18774
18951
  throw new Error("Event not found after update");
18775
18952
  }
@@ -18829,8 +19006,8 @@ async function updateAppointmentUtil2(db, clinicId, practitionerId, patientId, e
18829
19006
  // src/services/calendar/utils/calendar-event.utils.ts
18830
19007
  import {
18831
19008
  collection as collection26,
18832
- doc as doc35,
18833
- getDoc as getDoc36,
19009
+ doc as doc36,
19010
+ getDoc as getDoc37,
18834
19011
  getDocs as getDocs26,
18835
19012
  setDoc as setDoc24,
18836
19013
  updateDoc as updateDoc31,
@@ -18928,7 +19105,7 @@ async function searchCalendarEventsUtil(db, params) {
18928
19105
  const finalQuery = query26(collectionRef, ...constraints);
18929
19106
  const querySnapshot = await getDocs26(finalQuery);
18930
19107
  let events = querySnapshot.docs.map(
18931
- (doc53) => ({ id: doc53.id, ...doc53.data() })
19108
+ (doc54) => ({ id: doc54.id, ...doc54.data() })
18932
19109
  );
18933
19110
  if (filters.dateRange) {
18934
19111
  events = events.filter((event) => {
@@ -18958,7 +19135,7 @@ async function searchCalendarEventsUtil(db, params) {
18958
19135
  // src/services/calendar/utils/synced-calendar.utils.ts
18959
19136
  import {
18960
19137
  collection as collection27,
18961
- getDoc as getDoc37,
19138
+ getDoc as getDoc38,
18962
19139
  getDocs as getDocs27,
18963
19140
  setDoc as setDoc25,
18964
19141
  updateDoc as updateDoc32,
@@ -19026,7 +19203,7 @@ async function getPractitionerSyncedCalendarUtil(db, practitionerId, calendarId)
19026
19203
  practitionerId,
19027
19204
  calendarId
19028
19205
  );
19029
- const calendarDoc = await getDoc37(calendarRef);
19206
+ const calendarDoc = await getDoc38(calendarRef);
19030
19207
  if (!calendarDoc.exists()) {
19031
19208
  return null;
19032
19209
  }
@@ -19039,11 +19216,11 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
19039
19216
  );
19040
19217
  const q = query27(calendarsRef, orderBy12("createdAt", "desc"));
19041
19218
  const querySnapshot = await getDocs27(q);
19042
- return querySnapshot.docs.map((doc53) => doc53.data());
19219
+ return querySnapshot.docs.map((doc54) => doc54.data());
19043
19220
  }
19044
19221
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
19045
19222
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
19046
- const calendarDoc = await getDoc37(calendarRef);
19223
+ const calendarDoc = await getDoc38(calendarRef);
19047
19224
  if (!calendarDoc.exists()) {
19048
19225
  return null;
19049
19226
  }
@@ -19056,11 +19233,11 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
19056
19233
  );
19057
19234
  const q = query27(calendarsRef, orderBy12("createdAt", "desc"));
19058
19235
  const querySnapshot = await getDocs27(q);
19059
- return querySnapshot.docs.map((doc53) => doc53.data());
19236
+ return querySnapshot.docs.map((doc54) => doc54.data());
19060
19237
  }
19061
19238
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
19062
19239
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
19063
- const calendarDoc = await getDoc37(calendarRef);
19240
+ const calendarDoc = await getDoc38(calendarRef);
19064
19241
  if (!calendarDoc.exists()) {
19065
19242
  return null;
19066
19243
  }
@@ -19073,7 +19250,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
19073
19250
  );
19074
19251
  const q = query27(calendarsRef, orderBy12("createdAt", "desc"));
19075
19252
  const querySnapshot = await getDocs27(q);
19076
- return querySnapshot.docs.map((doc53) => doc53.data());
19253
+ return querySnapshot.docs.map((doc54) => doc54.data());
19077
19254
  }
19078
19255
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
19079
19256
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -19086,7 +19263,7 @@ async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendar
19086
19263
  updatedAt: serverTimestamp29()
19087
19264
  };
19088
19265
  await updateDoc32(calendarRef, updates);
19089
- const updatedDoc = await getDoc37(calendarRef);
19266
+ const updatedDoc = await getDoc38(calendarRef);
19090
19267
  if (!updatedDoc.exists()) {
19091
19268
  throw new Error("Synced calendar not found after update");
19092
19269
  }
@@ -19099,7 +19276,7 @@ async function updatePatientSyncedCalendarUtil(db, patientId, calendarId, update
19099
19276
  updatedAt: serverTimestamp29()
19100
19277
  };
19101
19278
  await updateDoc32(calendarRef, updates);
19102
- const updatedDoc = await getDoc37(calendarRef);
19279
+ const updatedDoc = await getDoc38(calendarRef);
19103
19280
  if (!updatedDoc.exists()) {
19104
19281
  throw new Error("Synced calendar not found after update");
19105
19282
  }
@@ -19112,7 +19289,7 @@ async function updateClinicSyncedCalendarUtil(db, clinicId, calendarId, updateDa
19112
19289
  updatedAt: serverTimestamp29()
19113
19290
  };
19114
19291
  await updateDoc32(calendarRef, updates);
19115
- const updatedDoc = await getDoc37(calendarRef);
19292
+ const updatedDoc = await getDoc38(calendarRef);
19116
19293
  if (!updatedDoc.exists()) {
19117
19294
  throw new Error("Synced calendar not found after update");
19118
19295
  }
@@ -20321,7 +20498,7 @@ var CalendarServiceV2 = class extends BaseService {
20321
20498
  async createDoctorBlockingEvent(doctorId, eventData) {
20322
20499
  try {
20323
20500
  const eventId = this.generateId();
20324
- const eventRef = doc37(
20501
+ const eventRef = doc38(
20325
20502
  this.db,
20326
20503
  PRACTITIONERS_COLLECTION,
20327
20504
  doctorId,
@@ -20428,9 +20605,9 @@ var CalendarServiceV2 = class extends BaseService {
20428
20605
  where28("eventTime.start", "<=", Timestamp30.fromDate(endDate))
20429
20606
  );
20430
20607
  const eventsSnapshot = await getDocs28(q);
20431
- const events = eventsSnapshot.docs.map((doc53) => ({
20432
- id: doc53.id,
20433
- ...doc53.data()
20608
+ const events = eventsSnapshot.docs.map((doc54) => ({
20609
+ id: doc54.id,
20610
+ ...doc54.data()
20434
20611
  }));
20435
20612
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
20436
20613
  doctorId
@@ -20534,7 +20711,7 @@ var CalendarServiceV2 = class extends BaseService {
20534
20711
  const endTime = new Date(
20535
20712
  externalEvent.end.dateTime || externalEvent.end.date
20536
20713
  );
20537
- const eventRef = doc37(
20714
+ const eventRef = doc38(
20538
20715
  this.db,
20539
20716
  PRACTITIONERS_COLLECTION,
20540
20717
  doctorId,
@@ -20566,7 +20743,7 @@ var CalendarServiceV2 = class extends BaseService {
20566
20743
  */
20567
20744
  async updateEventStatus(doctorId, eventId, status) {
20568
20745
  try {
20569
- const eventRef = doc37(
20746
+ const eventRef = doc38(
20570
20747
  this.db,
20571
20748
  PRACTITIONERS_COLLECTION,
20572
20749
  doctorId,
@@ -20732,8 +20909,8 @@ var CalendarServiceV2 = class extends BaseService {
20732
20909
  const startDate = eventTime.start.toDate();
20733
20910
  const startTime = startDate;
20734
20911
  const endTime = eventTime.end.toDate();
20735
- const practitionerRef = doc37(this.db, PRACTITIONERS_COLLECTION, doctorId);
20736
- const practitionerDoc = await getDoc38(practitionerRef);
20912
+ const practitionerRef = doc38(this.db, PRACTITIONERS_COLLECTION, doctorId);
20913
+ const practitionerDoc = await getDoc39(practitionerRef);
20737
20914
  if (!practitionerDoc.exists()) {
20738
20915
  throw new Error(`Doctor with ID ${doctorId} not found`);
20739
20916
  }
@@ -20791,8 +20968,8 @@ var CalendarServiceV2 = class extends BaseService {
20791
20968
  */
20792
20969
  async updateAppointmentStatus(appointmentId, clinicId, status) {
20793
20970
  const baseCollectionPath = `${CLINICS_COLLECTION}/${clinicId}/${CALENDAR_COLLECTION}`;
20794
- const appointmentRef = doc37(this.db, baseCollectionPath, appointmentId);
20795
- const appointmentDoc = await getDoc38(appointmentRef);
20971
+ const appointmentRef = doc38(this.db, baseCollectionPath, appointmentId);
20972
+ const appointmentDoc = await getDoc39(appointmentRef);
20796
20973
  if (!appointmentDoc.exists()) {
20797
20974
  throw new Error(`Appointment with ID ${appointmentId} not found`);
20798
20975
  }
@@ -20961,8 +21138,8 @@ var CalendarServiceV2 = class extends BaseService {
20961
21138
  async updateEventWithSyncId(entityId, entityType, eventId, syncEvent) {
20962
21139
  try {
20963
21140
  const collectionPath = entityType === "doctor" ? `${PRACTITIONERS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}` : `${PATIENTS_COLLECTION}/${entityId}/${CALENDAR_COLLECTION}`;
20964
- const eventRef = doc37(this.db, collectionPath, eventId);
20965
- const eventDoc = await getDoc38(eventRef);
21141
+ const eventRef = doc38(this.db, collectionPath, eventId);
21142
+ const eventDoc = await getDoc39(eventRef);
20966
21143
  if (eventDoc.exists()) {
20967
21144
  const event = eventDoc.data();
20968
21145
  const syncIds = [...event.syncedCalendarEventId || []];
@@ -21000,8 +21177,8 @@ var CalendarServiceV2 = class extends BaseService {
21000
21177
  * @returns Working hours for the clinic
21001
21178
  */
21002
21179
  async getClinicWorkingHours(clinicId, date) {
21003
- const clinicRef = doc37(this.db, CLINICS_COLLECTION, clinicId);
21004
- const clinicDoc = await getDoc38(clinicRef);
21180
+ const clinicRef = doc38(this.db, CLINICS_COLLECTION, clinicId);
21181
+ const clinicDoc = await getDoc39(clinicRef);
21005
21182
  if (!clinicDoc.exists()) {
21006
21183
  throw new Error(`Clinic with ID ${clinicId} not found`);
21007
21184
  }
@@ -21029,8 +21206,8 @@ var CalendarServiceV2 = class extends BaseService {
21029
21206
  * @returns Doctor's schedule
21030
21207
  */
21031
21208
  async getDoctorSchedule(doctorId, date) {
21032
- const practitionerRef = doc37(this.db, PRACTITIONERS_COLLECTION, doctorId);
21033
- const practitionerDoc = await getDoc38(practitionerRef);
21209
+ const practitionerRef = doc38(this.db, PRACTITIONERS_COLLECTION, doctorId);
21210
+ const practitionerDoc = await getDoc39(practitionerRef);
21034
21211
  if (!practitionerDoc.exists()) {
21035
21212
  throw new Error(`Doctor with ID ${doctorId} not found`);
21036
21213
  }
@@ -21074,7 +21251,7 @@ var CalendarServiceV2 = class extends BaseService {
21074
21251
  ])
21075
21252
  );
21076
21253
  const querySnapshot = await getDocs28(q);
21077
- return querySnapshot.docs.map((doc53) => doc53.data());
21254
+ return querySnapshot.docs.map((doc54) => doc54.data());
21078
21255
  }
21079
21256
  /**
21080
21257
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -21131,11 +21308,11 @@ var CalendarServiceV2 = class extends BaseService {
21131
21308
  var _a;
21132
21309
  try {
21133
21310
  const [clinicDoc, practitionerDoc, patientDoc, patientSensitiveInfoDoc] = await Promise.all([
21134
- getDoc38(doc37(this.db, CLINICS_COLLECTION, clinicId)),
21135
- getDoc38(doc37(this.db, PRACTITIONERS_COLLECTION, doctorId)),
21136
- getDoc38(doc37(this.db, PATIENTS_COLLECTION, patientId)),
21137
- getDoc38(
21138
- doc37(
21311
+ getDoc39(doc38(this.db, CLINICS_COLLECTION, clinicId)),
21312
+ getDoc39(doc38(this.db, PRACTITIONERS_COLLECTION, doctorId)),
21313
+ getDoc39(doc38(this.db, PATIENTS_COLLECTION, patientId)),
21314
+ getDoc39(
21315
+ doc38(
21139
21316
  this.db,
21140
21317
  PATIENTS_COLLECTION,
21141
21318
  patientId,
@@ -21200,7 +21377,7 @@ var CalendarServiceV2 = class extends BaseService {
21200
21377
 
21201
21378
  // src/services/calendar/calendar.v3.service.ts
21202
21379
  import { Timestamp as Timestamp31, serverTimestamp as serverTimestamp31 } from "firebase/firestore";
21203
- import { doc as doc38, getDoc as getDoc39, setDoc as setDoc27, updateDoc as updateDoc34, deleteDoc as deleteDoc15 } from "firebase/firestore";
21380
+ import { doc as doc39, getDoc as getDoc40, setDoc as setDoc27, updateDoc as updateDoc34, deleteDoc as deleteDoc15 } from "firebase/firestore";
21204
21381
  var CalendarServiceV3 = class extends BaseService {
21205
21382
  /**
21206
21383
  * Creates a new CalendarServiceV3 instance
@@ -21224,7 +21401,7 @@ var CalendarServiceV3 = class extends BaseService {
21224
21401
  params.entityType,
21225
21402
  params.entityId
21226
21403
  );
21227
- const eventRef = doc38(this.db, collectionPath, eventId);
21404
+ const eventRef = doc39(this.db, collectionPath, eventId);
21228
21405
  const eventData = {
21229
21406
  id: eventId,
21230
21407
  eventName: params.eventName,
@@ -21259,8 +21436,8 @@ var CalendarServiceV3 = class extends BaseService {
21259
21436
  params.entityType,
21260
21437
  params.entityId
21261
21438
  );
21262
- const eventRef = doc38(this.db, collectionPath, params.eventId);
21263
- const eventDoc = await getDoc39(eventRef);
21439
+ const eventRef = doc39(this.db, collectionPath, params.eventId);
21440
+ const eventDoc = await getDoc40(eventRef);
21264
21441
  if (!eventDoc.exists()) {
21265
21442
  throw new Error(`Blocking event with ID ${params.eventId} not found`);
21266
21443
  }
@@ -21280,7 +21457,7 @@ var CalendarServiceV3 = class extends BaseService {
21280
21457
  updateData.status = params.status;
21281
21458
  }
21282
21459
  await updateDoc34(eventRef, updateData);
21283
- const updatedEventDoc = await getDoc39(eventRef);
21460
+ const updatedEventDoc = await getDoc40(eventRef);
21284
21461
  return updatedEventDoc.data();
21285
21462
  }
21286
21463
  /**
@@ -21291,8 +21468,8 @@ var CalendarServiceV3 = class extends BaseService {
21291
21468
  */
21292
21469
  async deleteBlockingEvent(entityType, entityId, eventId) {
21293
21470
  const collectionPath = this.getEntityCalendarPath(entityType, entityId);
21294
- const eventRef = doc38(this.db, collectionPath, eventId);
21295
- const eventDoc = await getDoc39(eventRef);
21471
+ const eventRef = doc39(this.db, collectionPath, eventId);
21472
+ const eventDoc = await getDoc40(eventRef);
21296
21473
  if (!eventDoc.exists()) {
21297
21474
  throw new Error(`Blocking event with ID ${eventId} not found`);
21298
21475
  }
@@ -21307,8 +21484,8 @@ var CalendarServiceV3 = class extends BaseService {
21307
21484
  */
21308
21485
  async getBlockingEvent(entityType, entityId, eventId) {
21309
21486
  const collectionPath = this.getEntityCalendarPath(entityType, entityId);
21310
- const eventRef = doc38(this.db, collectionPath, eventId);
21311
- const eventDoc = await getDoc39(eventRef);
21487
+ const eventRef = doc39(this.db, collectionPath, eventId);
21488
+ const eventDoc = await getDoc40(eventRef);
21312
21489
  if (!eventDoc.exists()) {
21313
21490
  return null;
21314
21491
  }
@@ -21503,8 +21680,8 @@ var ExternalCalendarService = class extends BaseService {
21503
21680
  // src/services/clinic/practitioner-invite.service.ts
21504
21681
  import {
21505
21682
  collection as collection29,
21506
- doc as doc39,
21507
- getDoc as getDoc40,
21683
+ doc as doc40,
21684
+ getDoc as getDoc41,
21508
21685
  getDocs as getDocs29,
21509
21686
  query as query29,
21510
21687
  where as where29,
@@ -21588,7 +21765,7 @@ var PractitionerInviteService = class extends BaseService {
21588
21765
  rejectedAt: null,
21589
21766
  cancelledAt: null
21590
21767
  };
21591
- const docRef = doc39(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21768
+ const docRef = doc40(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21592
21769
  await setDoc28(docRef, invite);
21593
21770
  return invite;
21594
21771
  } catch (error) {
@@ -21619,7 +21796,7 @@ var PractitionerInviteService = class extends BaseService {
21619
21796
  ...constraints
21620
21797
  );
21621
21798
  const querySnapshot = await getDocs29(q);
21622
- return querySnapshot.docs.map((doc53) => doc53.data());
21799
+ return querySnapshot.docs.map((doc54) => doc54.data());
21623
21800
  } catch (error) {
21624
21801
  console.error(
21625
21802
  "[PractitionerInviteService] Error getting doctor invites:",
@@ -21648,7 +21825,7 @@ var PractitionerInviteService = class extends BaseService {
21648
21825
  ...constraints
21649
21826
  );
21650
21827
  const querySnapshot = await getDocs29(q);
21651
- return querySnapshot.docs.map((doc53) => doc53.data());
21828
+ return querySnapshot.docs.map((doc54) => doc54.data());
21652
21829
  } catch (error) {
21653
21830
  console.error(
21654
21831
  "[PractitionerInviteService] Error getting clinic invites:",
@@ -21676,7 +21853,7 @@ var PractitionerInviteService = class extends BaseService {
21676
21853
  acceptedAt: Timestamp32.now(),
21677
21854
  updatedAt: serverTimestamp32()
21678
21855
  };
21679
- const docRef = doc39(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21856
+ const docRef = doc40(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21680
21857
  await updateDoc35(docRef, updateData);
21681
21858
  return await this.getInviteById(inviteId);
21682
21859
  } catch (error) {
@@ -21708,7 +21885,7 @@ var PractitionerInviteService = class extends BaseService {
21708
21885
  rejectedAt: Timestamp32.now(),
21709
21886
  updatedAt: serverTimestamp32()
21710
21887
  };
21711
- const docRef = doc39(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21888
+ const docRef = doc40(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21712
21889
  await updateDoc35(docRef, updateData);
21713
21890
  return await this.getInviteById(inviteId);
21714
21891
  } catch (error) {
@@ -21740,7 +21917,7 @@ var PractitionerInviteService = class extends BaseService {
21740
21917
  cancelledAt: Timestamp32.now(),
21741
21918
  updatedAt: serverTimestamp32()
21742
21919
  };
21743
- const docRef = doc39(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21920
+ const docRef = doc40(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21744
21921
  await updateDoc35(docRef, updateData);
21745
21922
  return await this.getInviteById(inviteId);
21746
21923
  } catch (error) {
@@ -21758,8 +21935,8 @@ var PractitionerInviteService = class extends BaseService {
21758
21935
  */
21759
21936
  async getInviteById(inviteId) {
21760
21937
  try {
21761
- const docRef = doc39(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21762
- const docSnap = await getDoc40(docRef);
21938
+ const docRef = doc40(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21939
+ const docSnap = await getDoc41(docRef);
21763
21940
  if (docSnap.exists()) {
21764
21941
  return docSnap.data();
21765
21942
  }
@@ -21804,7 +21981,7 @@ var PractitionerInviteService = class extends BaseService {
21804
21981
  );
21805
21982
  const querySnapshot = await getDocs29(q);
21806
21983
  let invites = querySnapshot.docs.map(
21807
- (doc53) => doc53.data()
21984
+ (doc54) => doc54.data()
21808
21985
  );
21809
21986
  if (filters.fromDate) {
21810
21987
  invites = invites.filter(
@@ -21831,7 +22008,7 @@ var PractitionerInviteService = class extends BaseService {
21831
22008
  */
21832
22009
  async deleteInvite(inviteId) {
21833
22010
  try {
21834
- const docRef = doc39(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
22011
+ const docRef = doc40(this.db, PRACTITIONER_INVITES_COLLECTION, inviteId);
21835
22012
  await deleteDoc16(docRef);
21836
22013
  } catch (error) {
21837
22014
  console.error(
@@ -21849,8 +22026,8 @@ var PractitionerInviteService = class extends BaseService {
21849
22026
  */
21850
22027
  async getPractitionerById(practitionerId) {
21851
22028
  try {
21852
- const docRef = doc39(this.db, PRACTITIONERS_COLLECTION, practitionerId);
21853
- const docSnap = await getDoc40(docRef);
22029
+ const docRef = doc40(this.db, PRACTITIONERS_COLLECTION, practitionerId);
22030
+ const docSnap = await getDoc41(docRef);
21854
22031
  return docSnap.exists() ? docSnap.data() : null;
21855
22032
  } catch (error) {
21856
22033
  console.error(
@@ -21867,8 +22044,8 @@ var PractitionerInviteService = class extends BaseService {
21867
22044
  */
21868
22045
  async getClinicById(clinicId) {
21869
22046
  try {
21870
- const docRef = doc39(this.db, CLINICS_COLLECTION, clinicId);
21871
- const docSnap = await getDoc40(docRef);
22047
+ const docRef = doc40(this.db, CLINICS_COLLECTION, clinicId);
22048
+ const docSnap = await getDoc41(docRef);
21872
22049
  return docSnap.exists() ? docSnap.data() : null;
21873
22050
  } catch (error) {
21874
22051
  console.error("[PractitionerInviteService] Error getting clinic:", error);
@@ -21908,8 +22085,8 @@ var PractitionerInviteService = class extends BaseService {
21908
22085
  // src/services/documentation-templates/documentation-template.service.ts
21909
22086
  import {
21910
22087
  collection as collection30,
21911
- doc as doc40,
21912
- getDoc as getDoc41,
22088
+ doc as doc41,
22089
+ getDoc as getDoc42,
21913
22090
  getDocs as getDocs30,
21914
22091
  setDoc as setDoc29,
21915
22092
  updateDoc as updateDoc36,
@@ -21958,7 +22135,7 @@ var DocumentationTemplateService = class extends BaseService {
21958
22135
  isRequired: validatedData.isRequired || false,
21959
22136
  sortingOrder: validatedData.sortingOrder || 0
21960
22137
  };
21961
- const docRef = doc40(this.collectionRef, templateId);
22138
+ const docRef = doc41(this.collectionRef, templateId);
21962
22139
  await setDoc29(docRef, template);
21963
22140
  return template;
21964
22141
  }
@@ -21969,8 +22146,8 @@ var DocumentationTemplateService = class extends BaseService {
21969
22146
  * @returns The template or null if not found
21970
22147
  */
21971
22148
  async getTemplateById(templateId, version) {
21972
- const docRef = doc40(this.collectionRef, templateId);
21973
- const docSnap = await getDoc41(docRef);
22149
+ const docRef = doc41(this.collectionRef, templateId);
22150
+ const docSnap = await getDoc42(docRef);
21974
22151
  if (!docSnap.exists()) {
21975
22152
  return null;
21976
22153
  }
@@ -22012,7 +22189,7 @@ var DocumentationTemplateService = class extends BaseService {
22012
22189
  this.db,
22013
22190
  `${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions`
22014
22191
  );
22015
- const versionDocRef = doc40(
22192
+ const versionDocRef = doc41(
22016
22193
  versionsCollectionRef,
22017
22194
  template.version.toString()
22018
22195
  );
@@ -22040,7 +22217,7 @@ var DocumentationTemplateService = class extends BaseService {
22040
22217
  updatePayload.isUserForm = (_a = validatedData.isUserForm) != null ? _a : false;
22041
22218
  updatePayload.isRequired = (_b = validatedData.isRequired) != null ? _b : false;
22042
22219
  updatePayload.sortingOrder = (_c = validatedData.sortingOrder) != null ? _c : 0;
22043
- const docRef = doc40(this.collectionRef, templateId);
22220
+ const docRef = doc41(this.collectionRef, templateId);
22044
22221
  console.log("Update payload", updatePayload);
22045
22222
  await updateDoc36(docRef, updatePayload);
22046
22223
  return { ...template, ...updatePayload };
@@ -22052,11 +22229,11 @@ var DocumentationTemplateService = class extends BaseService {
22052
22229
  * @returns The template version or null if not found
22053
22230
  */
22054
22231
  async getTemplateVersion(templateId, versionNumber) {
22055
- const versionDocRef = doc40(
22232
+ const versionDocRef = doc41(
22056
22233
  this.db,
22057
22234
  `${DOCUMENTATION_TEMPLATES_COLLECTION}/${templateId}/versions/${versionNumber}`
22058
22235
  );
22059
- const versionDocSnap = await getDoc41(versionDocRef);
22236
+ const versionDocSnap = await getDoc42(versionDocRef);
22060
22237
  if (!versionDocSnap.exists()) {
22061
22238
  return null;
22062
22239
  }
@@ -22075,8 +22252,8 @@ var DocumentationTemplateService = class extends BaseService {
22075
22252
  const q = query30(versionsCollectionRef, orderBy14("version", "desc"));
22076
22253
  const querySnapshot = await getDocs30(q);
22077
22254
  const versions = [];
22078
- querySnapshot.forEach((doc53) => {
22079
- versions.push(doc53.data());
22255
+ querySnapshot.forEach((doc54) => {
22256
+ versions.push(doc54.data());
22080
22257
  });
22081
22258
  return versions;
22082
22259
  }
@@ -22085,7 +22262,7 @@ var DocumentationTemplateService = class extends BaseService {
22085
22262
  * @param templateId - ID of the template to delete
22086
22263
  */
22087
22264
  async deleteTemplate(templateId) {
22088
- const docRef = doc40(this.collectionRef, templateId);
22265
+ const docRef = doc41(this.collectionRef, templateId);
22089
22266
  await deleteDoc17(docRef);
22090
22267
  }
22091
22268
  /**
@@ -22107,9 +22284,9 @@ var DocumentationTemplateService = class extends BaseService {
22107
22284
  const querySnapshot = await getDocs30(q);
22108
22285
  const templates = [];
22109
22286
  let lastVisible = null;
22110
- querySnapshot.forEach((doc53) => {
22111
- templates.push(doc53.data());
22112
- lastVisible = doc53;
22287
+ querySnapshot.forEach((doc54) => {
22288
+ templates.push(doc54.data());
22289
+ lastVisible = doc54;
22113
22290
  });
22114
22291
  return {
22115
22292
  templates,
@@ -22151,9 +22328,9 @@ var DocumentationTemplateService = class extends BaseService {
22151
22328
  const querySnapshot = await getDocs30(q);
22152
22329
  const templates = [];
22153
22330
  let lastVisible = null;
22154
- querySnapshot.forEach((doc53) => {
22155
- templates.push(doc53.data());
22156
- lastVisible = doc53;
22331
+ querySnapshot.forEach((doc54) => {
22332
+ templates.push(doc54.data());
22333
+ lastVisible = doc54;
22157
22334
  });
22158
22335
  return {
22159
22336
  templates,
@@ -22193,8 +22370,8 @@ var DocumentationTemplateService = class extends BaseService {
22193
22370
  );
22194
22371
  const querySnapshot = await getDocs30(q);
22195
22372
  const templates = [];
22196
- querySnapshot.forEach((doc53) => {
22197
- templates.push(doc53.data());
22373
+ querySnapshot.forEach((doc54) => {
22374
+ templates.push(doc54.data());
22198
22375
  });
22199
22376
  return templates;
22200
22377
  }
@@ -22219,9 +22396,9 @@ var DocumentationTemplateService = class extends BaseService {
22219
22396
  const querySnapshot = await getDocs30(q);
22220
22397
  const templates = [];
22221
22398
  let lastVisible = null;
22222
- querySnapshot.forEach((doc53) => {
22223
- templates.push(doc53.data());
22224
- lastVisible = doc53;
22399
+ querySnapshot.forEach((doc54) => {
22400
+ templates.push(doc54.data());
22401
+ lastVisible = doc54;
22225
22402
  });
22226
22403
  return {
22227
22404
  templates,
@@ -22248,9 +22425,9 @@ var DocumentationTemplateService = class extends BaseService {
22248
22425
  const querySnapshot = await getDocs30(q);
22249
22426
  const templates = [];
22250
22427
  let lastVisible = null;
22251
- querySnapshot.forEach((doc53) => {
22252
- templates.push(doc53.data());
22253
- lastVisible = doc53;
22428
+ querySnapshot.forEach((doc54) => {
22429
+ templates.push(doc54.data());
22430
+ lastVisible = doc54;
22254
22431
  });
22255
22432
  return {
22256
22433
  templates,
@@ -22276,8 +22453,8 @@ var DocumentationTemplateService = class extends BaseService {
22276
22453
  }
22277
22454
  const querySnapshot = await getDocs30(q);
22278
22455
  const templates = [];
22279
- querySnapshot.forEach((doc53) => {
22280
- templates.push(doc53.data());
22456
+ querySnapshot.forEach((doc54) => {
22457
+ templates.push(doc54.data());
22281
22458
  });
22282
22459
  return templates;
22283
22460
  }
@@ -22286,8 +22463,8 @@ var DocumentationTemplateService = class extends BaseService {
22286
22463
  // src/services/documentation-templates/filled-document.service.ts
22287
22464
  import {
22288
22465
  collection as collection31,
22289
- doc as doc41,
22290
- getDoc as getDoc42,
22466
+ doc as doc42,
22467
+ getDoc as getDoc43,
22291
22468
  getDocs as getDocs31,
22292
22469
  setDoc as setDoc30,
22293
22470
  updateDoc as updateDoc37,
@@ -22350,7 +22527,7 @@ var FilledDocumentService = class extends BaseService {
22350
22527
  values: initialValues,
22351
22528
  status: initialStatus
22352
22529
  };
22353
- const docRef = doc41(
22530
+ const docRef = doc42(
22354
22531
  this.db,
22355
22532
  APPOINTMENTS_COLLECTION,
22356
22533
  // Replaced "appointments"
@@ -22370,7 +22547,7 @@ var FilledDocumentService = class extends BaseService {
22370
22547
  */
22371
22548
  async getFilledDocumentFromAppointmentById(appointmentId, formId, isUserForm) {
22372
22549
  const formSubcollection = this.getFormSubcollectionPath(isUserForm);
22373
- const docRef = doc41(
22550
+ const docRef = doc42(
22374
22551
  this.db,
22375
22552
  APPOINTMENTS_COLLECTION,
22376
22553
  // Replaced "appointments"
@@ -22378,7 +22555,7 @@ var FilledDocumentService = class extends BaseService {
22378
22555
  formSubcollection,
22379
22556
  formId
22380
22557
  );
22381
- const docSnap = await getDoc42(docRef);
22558
+ const docSnap = await getDoc43(docRef);
22382
22559
  if (!docSnap.exists()) {
22383
22560
  return null;
22384
22561
  }
@@ -22399,7 +22576,7 @@ var FilledDocumentService = class extends BaseService {
22399
22576
  */
22400
22577
  async updateFilledDocumentInAppointment(appointmentId, formId, isUserForm, values, status) {
22401
22578
  const formSubcollection = this.getFormSubcollectionPath(isUserForm);
22402
- const docRef = doc41(
22579
+ const docRef = doc42(
22403
22580
  this.db,
22404
22581
  APPOINTMENTS_COLLECTION,
22405
22582
  // Replaced "appointments"
@@ -22654,8 +22831,8 @@ var FilledDocumentService = class extends BaseService {
22654
22831
  // src/services/notifications/notification.service.ts
22655
22832
  import {
22656
22833
  collection as collection32,
22657
- doc as doc42,
22658
- getDoc as getDoc43,
22834
+ doc as doc43,
22835
+ getDoc as getDoc44,
22659
22836
  getDocs as getDocs32,
22660
22837
  query as query32,
22661
22838
  where as where32,
@@ -22691,12 +22868,12 @@ var NotificationService = class extends BaseService {
22691
22868
  * Dohvata notifikaciju po ID-u
22692
22869
  */
22693
22870
  async getNotification(notificationId) {
22694
- const notificationRef = doc42(
22871
+ const notificationRef = doc43(
22695
22872
  this.db,
22696
22873
  NOTIFICATIONS_COLLECTION,
22697
22874
  notificationId
22698
22875
  );
22699
- const notificationDoc = await getDoc43(notificationRef);
22876
+ const notificationDoc = await getDoc44(notificationRef);
22700
22877
  if (!notificationDoc.exists()) {
22701
22878
  return null;
22702
22879
  }
@@ -22715,9 +22892,9 @@ var NotificationService = class extends BaseService {
22715
22892
  orderBy16("notificationTime", "desc")
22716
22893
  );
22717
22894
  const querySnapshot = await getDocs32(q);
22718
- return querySnapshot.docs.map((doc53) => ({
22719
- id: doc53.id,
22720
- ...doc53.data()
22895
+ return querySnapshot.docs.map((doc54) => ({
22896
+ id: doc54.id,
22897
+ ...doc54.data()
22721
22898
  }));
22722
22899
  }
22723
22900
  /**
@@ -22731,16 +22908,16 @@ var NotificationService = class extends BaseService {
22731
22908
  orderBy16("notificationTime", "desc")
22732
22909
  );
22733
22910
  const querySnapshot = await getDocs32(q);
22734
- return querySnapshot.docs.map((doc53) => ({
22735
- id: doc53.id,
22736
- ...doc53.data()
22911
+ return querySnapshot.docs.map((doc54) => ({
22912
+ id: doc54.id,
22913
+ ...doc54.data()
22737
22914
  }));
22738
22915
  }
22739
22916
  /**
22740
22917
  * Označava notifikaciju kao pročitanu
22741
22918
  */
22742
22919
  async markAsRead(notificationId) {
22743
- const notificationRef = doc42(
22920
+ const notificationRef = doc43(
22744
22921
  this.db,
22745
22922
  NOTIFICATIONS_COLLECTION,
22746
22923
  notificationId
@@ -22757,7 +22934,7 @@ var NotificationService = class extends BaseService {
22757
22934
  const notifications = await this.getUnreadNotifications(userId);
22758
22935
  const batch = writeBatch5(this.db);
22759
22936
  notifications.forEach((notification) => {
22760
- const notificationRef = doc42(
22937
+ const notificationRef = doc43(
22761
22938
  this.db,
22762
22939
  NOTIFICATIONS_COLLECTION,
22763
22940
  notification.id
@@ -22773,7 +22950,7 @@ var NotificationService = class extends BaseService {
22773
22950
  * Ažurira status notifikacije
22774
22951
  */
22775
22952
  async updateNotificationStatus(notificationId, status) {
22776
- const notificationRef = doc42(
22953
+ const notificationRef = doc43(
22777
22954
  this.db,
22778
22955
  NOTIFICATIONS_COLLECTION,
22779
22956
  notificationId
@@ -22787,7 +22964,7 @@ var NotificationService = class extends BaseService {
22787
22964
  * Briše notifikaciju
22788
22965
  */
22789
22966
  async deleteNotification(notificationId) {
22790
- const notificationRef = doc42(
22967
+ const notificationRef = doc43(
22791
22968
  this.db,
22792
22969
  NOTIFICATIONS_COLLECTION,
22793
22970
  notificationId
@@ -22805,9 +22982,9 @@ var NotificationService = class extends BaseService {
22805
22982
  orderBy16("notificationTime", "desc")
22806
22983
  );
22807
22984
  const querySnapshot = await getDocs32(q);
22808
- return querySnapshot.docs.map((doc53) => ({
22809
- id: doc53.id,
22810
- ...doc53.data()
22985
+ return querySnapshot.docs.map((doc54) => ({
22986
+ id: doc54.id,
22987
+ ...doc54.data()
22811
22988
  }));
22812
22989
  }
22813
22990
  /**
@@ -22820,9 +22997,9 @@ var NotificationService = class extends BaseService {
22820
22997
  orderBy16("notificationTime", "desc")
22821
22998
  );
22822
22999
  const querySnapshot = await getDocs32(q);
22823
- return querySnapshot.docs.map((doc53) => ({
22824
- id: doc53.id,
22825
- ...doc53.data()
23000
+ return querySnapshot.docs.map((doc54) => ({
23001
+ id: doc54.id,
23002
+ ...doc54.data()
22826
23003
  }));
22827
23004
  }
22828
23005
  };
@@ -22833,13 +23010,13 @@ import {
22833
23010
  getDocs as getDocs33,
22834
23011
  query as query33,
22835
23012
  where as where33,
22836
- doc as doc43,
23013
+ doc as doc44,
22837
23014
  updateDoc as updateDoc39,
22838
23015
  Timestamp as Timestamp35,
22839
23016
  orderBy as orderBy17,
22840
23017
  limit as limit15,
22841
23018
  startAfter as startAfter13,
22842
- getDoc as getDoc44
23019
+ getDoc as getDoc45
22843
23020
  } from "firebase/firestore";
22844
23021
  var PatientRequirementsService = class extends BaseService {
22845
23022
  constructor(db, auth, app) {
@@ -22852,7 +23029,7 @@ var PatientRequirementsService = class extends BaseService {
22852
23029
  );
22853
23030
  }
22854
23031
  getPatientRequirementDocRef(patientId, instanceId) {
22855
- return doc43(
23032
+ return doc44(
22856
23033
  this.getPatientRequirementsCollectionRef(patientId),
22857
23034
  instanceId
22858
23035
  );
@@ -22865,7 +23042,7 @@ var PatientRequirementsService = class extends BaseService {
22865
23042
  */
22866
23043
  async getPatientRequirementInstance(patientId, instanceId) {
22867
23044
  const docRef = this.getPatientRequirementDocRef(patientId, instanceId);
22868
- const docSnap = await getDoc44(docRef);
23045
+ const docSnap = await getDoc45(docRef);
22869
23046
  if (!docSnap.exists()) {
22870
23047
  return null;
22871
23048
  }
@@ -22942,7 +23119,7 @@ var PatientRequirementsService = class extends BaseService {
22942
23119
  */
22943
23120
  async completeInstruction(patientId, instanceId, instructionId) {
22944
23121
  const instanceRef = this.getPatientRequirementDocRef(patientId, instanceId);
22945
- const instanceSnap = await getDoc44(instanceRef);
23122
+ const instanceSnap = await getDoc45(instanceRef);
22946
23123
  if (!instanceSnap.exists()) {
22947
23124
  throw new Error(
22948
23125
  `PatientRequirementInstance ${instanceId} not found for patient ${patientId}.`
@@ -23026,8 +23203,8 @@ var PatientRequirementsService = class extends BaseService {
23026
23203
  // src/services/procedure/procedure.service.ts
23027
23204
  import {
23028
23205
  collection as collection34,
23029
- doc as doc44,
23030
- getDoc as getDoc45,
23206
+ doc as doc45,
23207
+ getDoc as getDoc46,
23031
23208
  getDocs as getDocs34,
23032
23209
  query as query34,
23033
23210
  where as where34,
@@ -23401,15 +23578,15 @@ var ProcedureService = class extends BaseService {
23401
23578
  if (!isProductFree && !product) {
23402
23579
  throw new Error("Product not found for regular procedure");
23403
23580
  }
23404
- const clinicRef = doc44(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
23405
- const clinicSnapshot = await getDoc45(clinicRef);
23581
+ const clinicRef = doc45(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
23582
+ const clinicSnapshot = await getDoc46(clinicRef);
23406
23583
  if (!clinicSnapshot.exists()) {
23407
23584
  throw new Error(`Clinic with ID ${validatedData.clinicBranchId} not found`);
23408
23585
  }
23409
23586
  const clinic = clinicSnapshot.data();
23410
23587
  await enforceProcedureLimit(this.db, clinic.clinicGroupId, validatedData.clinicBranchId, validatedData.practitionerId);
23411
- const practitionerRef = doc44(this.db, PRACTITIONERS_COLLECTION, validatedData.practitionerId);
23412
- const practitionerSnapshot = await getDoc45(practitionerRef);
23588
+ const practitionerRef = doc45(this.db, PRACTITIONERS_COLLECTION, validatedData.practitionerId);
23589
+ const practitionerSnapshot = await getDoc46(practitionerRef);
23413
23590
  if (!practitionerSnapshot.exists()) {
23414
23591
  throw new Error(`Practitioner with ID ${validatedData.practitionerId} not found`);
23415
23592
  }
@@ -23421,7 +23598,7 @@ var ProcedureService = class extends BaseService {
23421
23598
  where34("isActive", "==", true)
23422
23599
  );
23423
23600
  const existingProceduresSnapshot = await getDocs34(existingProceduresQuery);
23424
- const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
23601
+ const existingProcedures = existingProceduresSnapshot.docs.map((doc54) => doc54.data());
23425
23602
  const hasSameTechnology = existingProcedures.some(
23426
23603
  (proc) => {
23427
23604
  var _a2;
@@ -23526,13 +23703,13 @@ var ProcedureService = class extends BaseService {
23526
23703
  throw new Error(`Cannot write procedure with undefined fields: ${undefinedFields.join(", ")}`);
23527
23704
  }
23528
23705
  console.log("\u{1F525}\u{1F525}\u{1F525} NO UNDEFINED FIELDS - Proceeding with setDoc");
23529
- const procedureRef = doc44(this.db, PROCEDURES_COLLECTION, procedureId);
23706
+ const procedureRef = doc45(this.db, PROCEDURES_COLLECTION, procedureId);
23530
23707
  await setDoc31(procedureRef, {
23531
23708
  ...newProcedure,
23532
23709
  createdAt: serverTimestamp35(),
23533
23710
  updatedAt: serverTimestamp35()
23534
23711
  });
23535
- const savedDoc = await getDoc45(procedureRef);
23712
+ const savedDoc = await getDoc46(procedureRef);
23536
23713
  return savedDoc.data();
23537
23714
  }
23538
23715
  /**
@@ -23591,8 +23768,8 @@ var ProcedureService = class extends BaseService {
23591
23768
  if (!sourceProcedure) {
23592
23769
  throw new Error(`Source procedure with ID ${sourceProcedureId} not found`);
23593
23770
  }
23594
- const practitionerRef = doc44(this.db, PRACTITIONERS_COLLECTION, targetPractitionerId);
23595
- const practitionerSnapshot = await getDoc45(practitionerRef);
23771
+ const practitionerRef = doc45(this.db, PRACTITIONERS_COLLECTION, targetPractitionerId);
23772
+ const practitionerSnapshot = await getDoc46(practitionerRef);
23596
23773
  if (!practitionerSnapshot.exists()) {
23597
23774
  throw new Error(`Target practitioner with ID ${targetPractitionerId} not found`);
23598
23775
  }
@@ -23609,7 +23786,7 @@ var ProcedureService = class extends BaseService {
23609
23786
  where34("isActive", "==", true)
23610
23787
  );
23611
23788
  const existingProceduresSnapshot = await getDocs34(existingProceduresQuery);
23612
- const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
23789
+ const existingProcedures = existingProceduresSnapshot.docs.map((doc54) => doc54.data());
23613
23790
  const hasSameTechnology = existingProcedures.some(
23614
23791
  (proc) => {
23615
23792
  var _a2, _b2;
@@ -23654,13 +23831,13 @@ var ProcedureService = class extends BaseService {
23654
23831
  // Ensure it's active by default unless specified otherwise
23655
23832
  isActive: (overrides == null ? void 0 : overrides.isActive) !== void 0 ? overrides.isActive : true
23656
23833
  };
23657
- const procedureRef = doc44(this.db, PROCEDURES_COLLECTION, newProcedureId);
23834
+ const procedureRef = doc45(this.db, PROCEDURES_COLLECTION, newProcedureId);
23658
23835
  await setDoc31(procedureRef, {
23659
23836
  ...newProcedure,
23660
23837
  createdAt: serverTimestamp35(),
23661
23838
  updatedAt: serverTimestamp35()
23662
23839
  });
23663
- const savedDoc = await getDoc45(procedureRef);
23840
+ const savedDoc = await getDoc46(procedureRef);
23664
23841
  return savedDoc.data();
23665
23842
  }
23666
23843
  /**
@@ -23683,7 +23860,7 @@ var ProcedureService = class extends BaseService {
23683
23860
  throw new Error(`Source procedure with ID ${sourceProcedureId} not found`);
23684
23861
  }
23685
23862
  const practitionerPromises = targetPractitionerIds.map(
23686
- (id) => getDoc45(doc44(this.db, PRACTITIONERS_COLLECTION, id))
23863
+ (id) => getDoc46(doc45(this.db, PRACTITIONERS_COLLECTION, id))
23687
23864
  );
23688
23865
  const practitionerSnapshots = await Promise.all(practitionerPromises);
23689
23866
  const practitioners = [];
@@ -23706,7 +23883,7 @@ var ProcedureService = class extends BaseService {
23706
23883
  where34("isActive", "==", true)
23707
23884
  );
23708
23885
  const existingProceduresSnapshot = await getDocs34(existingProceduresQuery);
23709
- const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
23886
+ const existingProcedures = existingProceduresSnapshot.docs.map((doc54) => doc54.data());
23710
23887
  const hasSameTechnology = existingProcedures.some(
23711
23888
  (proc) => {
23712
23889
  var _a2;
@@ -23756,7 +23933,7 @@ var ProcedureService = class extends BaseService {
23756
23933
  isActive: (overrides == null ? void 0 : overrides.isActive) !== void 0 ? overrides.isActive : true
23757
23934
  };
23758
23935
  newProcedures.push(newProcedure);
23759
- const procedureRef = doc44(this.db, PROCEDURES_COLLECTION, newProcedureId);
23936
+ const procedureRef = doc45(this.db, PROCEDURES_COLLECTION, newProcedureId);
23760
23937
  batch.set(procedureRef, {
23761
23938
  ...newProcedure,
23762
23939
  createdAt: serverTimestamp35(),
@@ -23795,7 +23972,7 @@ var ProcedureService = class extends BaseService {
23795
23972
  this.productService.getById(validatedData.technologyId, validatedData.productId)
23796
23973
  );
23797
23974
  }
23798
- const clinicSnapshotPromise = getDoc45(doc44(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId));
23975
+ const clinicSnapshotPromise = getDoc46(doc45(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId));
23799
23976
  const [baseResults, clinicSnapshot] = await Promise.all([
23800
23977
  Promise.all(baseEntitiesPromises),
23801
23978
  clinicSnapshotPromise
@@ -23847,8 +24024,8 @@ var ProcedureService = class extends BaseService {
23847
24024
  where34(documentId2(), "in", chunk)
23848
24025
  );
23849
24026
  const practitionersSnapshot = await getDocs34(practitionersQuery);
23850
- practitionersSnapshot.docs.forEach((doc53) => {
23851
- practitionersMap.set(doc53.id, doc53.data());
24027
+ practitionersSnapshot.docs.forEach((doc54) => {
24028
+ practitionersMap.set(doc54.id, doc54.data());
23852
24029
  });
23853
24030
  }
23854
24031
  if (practitionersMap.size !== practitionerIds.length) {
@@ -23866,7 +24043,7 @@ var ProcedureService = class extends BaseService {
23866
24043
  where34("isActive", "==", true)
23867
24044
  );
23868
24045
  const existingProceduresSnapshot = await getDocs34(existingProceduresQuery);
23869
- const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
24046
+ const existingProcedures = existingProceduresSnapshot.docs.map((doc54) => doc54.data());
23870
24047
  const hasSameTechnology = existingProcedures.some(
23871
24048
  (proc) => {
23872
24049
  var _a2;
@@ -23912,7 +24089,7 @@ var ProcedureService = class extends BaseService {
23912
24089
  };
23913
24090
  const procedureId = this.generateId();
23914
24091
  createdProcedureIds.push(procedureId);
23915
- const procedureRef = doc44(this.db, PROCEDURES_COLLECTION, procedureId);
24092
+ const procedureRef = doc45(this.db, PROCEDURES_COLLECTION, procedureId);
23916
24093
  const { productsMetadata: _, productId: __, photos: ___, ...validatedDataWithoutProductsMetadata } = validatedData;
23917
24094
  const newProcedure = {
23918
24095
  id: procedureId,
@@ -23977,8 +24154,8 @@ var ProcedureService = class extends BaseService {
23977
24154
  const chunk = createdProcedureIds.slice(i, i + 30);
23978
24155
  const q = query34(collection34(this.db, PROCEDURES_COLLECTION), where34(documentId2(), "in", chunk));
23979
24156
  const snapshot = await getDocs34(q);
23980
- snapshot.forEach((doc53) => {
23981
- fetchedProcedures.push(doc53.data());
24157
+ snapshot.forEach((doc54) => {
24158
+ fetchedProcedures.push(doc54.data());
23982
24159
  });
23983
24160
  }
23984
24161
  return fetchedProcedures;
@@ -23989,8 +24166,8 @@ var ProcedureService = class extends BaseService {
23989
24166
  * @returns The procedure if found, null otherwise
23990
24167
  */
23991
24168
  async getProcedure(id) {
23992
- const docRef = doc44(this.db, PROCEDURES_COLLECTION, id);
23993
- const docSnap = await getDoc45(docRef);
24169
+ const docRef = doc45(this.db, PROCEDURES_COLLECTION, id);
24170
+ const docSnap = await getDoc46(docRef);
23994
24171
  if (!docSnap.exists()) {
23995
24172
  return null;
23996
24173
  }
@@ -24009,7 +24186,7 @@ var ProcedureService = class extends BaseService {
24009
24186
  where34("isActive", "==", true)
24010
24187
  );
24011
24188
  const snapshot = await getDocs34(q);
24012
- const procedures = snapshot.docs.map((doc53) => doc53.data());
24189
+ const procedures = snapshot.docs.map((doc54) => doc54.data());
24013
24190
  if (excludeDraftPractitioners) {
24014
24191
  return await this.filterDraftPractitionerProcedures(procedures);
24015
24192
  }
@@ -24035,7 +24212,7 @@ var ProcedureService = class extends BaseService {
24035
24212
  ...constraints
24036
24213
  );
24037
24214
  const snapshot = await getDocs34(q);
24038
- const procedures = snapshot.docs.map((doc53) => doc53.data());
24215
+ const procedures = snapshot.docs.map((doc54) => doc54.data());
24039
24216
  if (excludeDraftPractitioners && this.practitionerService) {
24040
24217
  try {
24041
24218
  const practitioner = await this.practitionerService.getPractitioner(practitionerId);
@@ -24061,7 +24238,7 @@ var ProcedureService = class extends BaseService {
24061
24238
  where34("isActive", "==", false)
24062
24239
  );
24063
24240
  const snapshot = await getDocs34(q);
24064
- return snapshot.docs.map((doc53) => doc53.data());
24241
+ return snapshot.docs.map((doc54) => doc54.data());
24065
24242
  }
24066
24243
  /**
24067
24244
  * Updates a procedure
@@ -24072,8 +24249,8 @@ var ProcedureService = class extends BaseService {
24072
24249
  async updateProcedure(id, data) {
24073
24250
  var _a, _b, _c;
24074
24251
  const validatedData = updateProcedureSchema.parse(data);
24075
- const procedureRef = doc44(this.db, PROCEDURES_COLLECTION, id);
24076
- const procedureSnapshot = await getDoc45(procedureRef);
24252
+ const procedureRef = doc45(this.db, PROCEDURES_COLLECTION, id);
24253
+ const procedureSnapshot = await getDoc46(procedureRef);
24077
24254
  if (!procedureSnapshot.exists()) {
24078
24255
  throw new Error(`Procedure with ID ${id} not found`);
24079
24256
  }
@@ -24116,12 +24293,12 @@ var ProcedureService = class extends BaseService {
24116
24293
  }
24117
24294
  if (validatedData.practitionerId && validatedData.practitionerId !== oldPractitionerId) {
24118
24295
  practitionerChanged = true;
24119
- const newPractitionerRef = doc44(
24296
+ const newPractitionerRef = doc45(
24120
24297
  this.db,
24121
24298
  PRACTITIONERS_COLLECTION,
24122
24299
  validatedData.practitionerId
24123
24300
  );
24124
- const newPractitionerSnap = await getDoc45(newPractitionerRef);
24301
+ const newPractitionerSnap = await getDoc46(newPractitionerRef);
24125
24302
  if (!newPractitionerSnap.exists())
24126
24303
  throw new Error(`New Practitioner ${validatedData.practitionerId} not found`);
24127
24304
  newPractitioner = newPractitionerSnap.data();
@@ -24137,8 +24314,8 @@ var ProcedureService = class extends BaseService {
24137
24314
  }
24138
24315
  if (validatedData.clinicBranchId && validatedData.clinicBranchId !== oldClinicId) {
24139
24316
  clinicChanged = true;
24140
- const newClinicRef = doc44(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
24141
- const newClinicSnap = await getDoc45(newClinicRef);
24317
+ const newClinicRef = doc45(this.db, CLINICS_COLLECTION, validatedData.clinicBranchId);
24318
+ const newClinicSnap = await getDoc46(newClinicRef);
24142
24319
  if (!newClinicSnap.exists())
24143
24320
  throw new Error(`New Clinic ${validatedData.clinicBranchId} not found`);
24144
24321
  newClinic = newClinicSnap.data();
@@ -24204,7 +24381,7 @@ var ProcedureService = class extends BaseService {
24204
24381
  ...updatedProcedureData,
24205
24382
  updatedAt: serverTimestamp35()
24206
24383
  });
24207
- const updatedSnapshot = await getDoc45(procedureRef);
24384
+ const updatedSnapshot = await getDoc46(procedureRef);
24208
24385
  return updatedSnapshot.data();
24209
24386
  }
24210
24387
  /**
@@ -24212,8 +24389,8 @@ var ProcedureService = class extends BaseService {
24212
24389
  * @param id - The ID of the procedure to deactivate
24213
24390
  */
24214
24391
  async deactivateProcedure(id) {
24215
- const procedureRef = doc44(this.db, PROCEDURES_COLLECTION, id);
24216
- const procedureSnap = await getDoc45(procedureRef);
24392
+ const procedureRef = doc45(this.db, PROCEDURES_COLLECTION, id);
24393
+ const procedureSnap = await getDoc46(procedureRef);
24217
24394
  if (!procedureSnap.exists()) {
24218
24395
  console.warn(`Procedure ${id} not found for deactivation.`);
24219
24396
  return;
@@ -24229,8 +24406,8 @@ var ProcedureService = class extends BaseService {
24229
24406
  * @returns A boolean indicating if the deletion was successful
24230
24407
  */
24231
24408
  async deleteProcedure(id) {
24232
- const procedureRef = doc44(this.db, PROCEDURES_COLLECTION, id);
24233
- const procedureSnapshot = await getDoc45(procedureRef);
24409
+ const procedureRef = doc45(this.db, PROCEDURES_COLLECTION, id);
24410
+ const procedureSnapshot = await getDoc46(procedureRef);
24234
24411
  if (!procedureSnapshot.exists()) {
24235
24412
  return false;
24236
24413
  }
@@ -24280,11 +24457,11 @@ var ProcedureService = class extends BaseService {
24280
24457
  proceduresQuery = query34(proceduresCollection, orderBy18("name"));
24281
24458
  }
24282
24459
  const proceduresSnapshot = await getDocs34(proceduresQuery);
24283
- let procedures = proceduresSnapshot.docs.map((doc53) => {
24284
- const data = doc53.data();
24460
+ let procedures = proceduresSnapshot.docs.map((doc54) => {
24461
+ const data = doc54.data();
24285
24462
  return {
24286
24463
  ...data,
24287
- id: doc53.id
24464
+ id: doc54.id
24288
24465
  // Ensure ID is present
24289
24466
  };
24290
24467
  });
@@ -24309,10 +24486,10 @@ var ProcedureService = class extends BaseService {
24309
24486
  * @param orderByField - The field used in orderBy clause
24310
24487
  * @returns Serializable cursor object with values needed for startAfter
24311
24488
  */
24312
- createSerializableCursor(doc53, orderByField = "createdAt") {
24313
- if (!doc53) return null;
24314
- const data = typeof doc53.data === "function" ? doc53.data() : doc53;
24315
- const docId = doc53.id || (data == null ? void 0 : data.id);
24489
+ createSerializableCursor(doc54, orderByField = "createdAt") {
24490
+ if (!doc54) return null;
24491
+ const data = typeof doc54.data === "function" ? doc54.data() : doc54;
24492
+ const docId = doc54.id || (data == null ? void 0 : data.id);
24316
24493
  if (!docId) return null;
24317
24494
  let orderByValue = data == null ? void 0 : data[orderByField];
24318
24495
  if (orderByValue && typeof orderByValue.toDate === "function") {
@@ -24472,7 +24649,7 @@ var ProcedureService = class extends BaseService {
24472
24649
  const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
24473
24650
  const querySnapshot = await getDocs34(q);
24474
24651
  let procedures = querySnapshot.docs.map(
24475
- (doc53) => ({ ...doc53.data(), id: doc53.id })
24652
+ (doc54) => ({ ...doc54.data(), id: doc54.id })
24476
24653
  );
24477
24654
  if (hasNestedFilters) {
24478
24655
  procedures = this.applyInMemoryFilters(procedures, filters);
@@ -24514,7 +24691,7 @@ var ProcedureService = class extends BaseService {
24514
24691
  const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
24515
24692
  const querySnapshot = await getDocs34(q);
24516
24693
  let procedures = querySnapshot.docs.map(
24517
- (doc53) => ({ ...doc53.data(), id: doc53.id })
24694
+ (doc54) => ({ ...doc54.data(), id: doc54.id })
24518
24695
  );
24519
24696
  if (hasNestedFilters) {
24520
24697
  procedures = this.applyInMemoryFilters(procedures, filters);
@@ -24588,7 +24765,7 @@ var ProcedureService = class extends BaseService {
24588
24765
  const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
24589
24766
  const querySnapshot = await getDocs34(q);
24590
24767
  let procedures = querySnapshot.docs.map(
24591
- (doc53) => ({ ...doc53.data(), id: doc53.id })
24768
+ (doc54) => ({ ...doc54.data(), id: doc54.id })
24592
24769
  );
24593
24770
  console.log("[PROCEDURE_SERVICE] Before applyInMemoryFilters (Strategy 3):", {
24594
24771
  procedureCount: procedures.length,
@@ -24641,7 +24818,7 @@ var ProcedureService = class extends BaseService {
24641
24818
  const q = query34(collection34(this.db, PROCEDURES_COLLECTION), ...constraints);
24642
24819
  const querySnapshot = await getDocs34(q);
24643
24820
  let procedures = querySnapshot.docs.map(
24644
- (doc53) => ({ ...doc53.data(), id: doc53.id })
24821
+ (doc54) => ({ ...doc54.data(), id: doc54.id })
24645
24822
  );
24646
24823
  procedures = this.applyInMemoryFilters(procedures, filters);
24647
24824
  if (filters.excludeDraftPractitioners) {
@@ -24881,14 +25058,14 @@ var ProcedureService = class extends BaseService {
24881
25058
  if (!category || !subcategory || !technology) {
24882
25059
  throw new Error("One or more required base entities not found");
24883
25060
  }
24884
- const clinicRef = doc44(this.db, CLINICS_COLLECTION, data.clinicBranchId);
24885
- const clinicSnapshot = await getDoc45(clinicRef);
25061
+ const clinicRef = doc45(this.db, CLINICS_COLLECTION, data.clinicBranchId);
25062
+ const clinicSnapshot = await getDoc46(clinicRef);
24886
25063
  if (!clinicSnapshot.exists()) {
24887
25064
  throw new Error(`Clinic with ID ${data.clinicBranchId} not found`);
24888
25065
  }
24889
25066
  const clinic = clinicSnapshot.data();
24890
- const practitionerRef = doc44(this.db, PRACTITIONERS_COLLECTION, data.practitionerId);
24891
- const practitionerSnapshot = await getDoc45(practitionerRef);
25067
+ const practitionerRef = doc45(this.db, PRACTITIONERS_COLLECTION, data.practitionerId);
25068
+ const practitionerSnapshot = await getDoc46(practitionerRef);
24892
25069
  if (!practitionerSnapshot.exists()) {
24893
25070
  throw new Error(`Practitioner with ID ${data.practitionerId} not found`);
24894
25071
  }
@@ -24961,13 +25138,13 @@ var ProcedureService = class extends BaseService {
24961
25138
  },
24962
25139
  isActive: true
24963
25140
  };
24964
- const procedureRef = doc44(this.db, PROCEDURES_COLLECTION, procedureId);
25141
+ const procedureRef = doc45(this.db, PROCEDURES_COLLECTION, procedureId);
24965
25142
  await setDoc31(procedureRef, {
24966
25143
  ...newProcedure,
24967
25144
  createdAt: serverTimestamp35(),
24968
25145
  updatedAt: serverTimestamp35()
24969
25146
  });
24970
- const savedDoc = await getDoc45(procedureRef);
25147
+ const savedDoc = await getDoc46(procedureRef);
24971
25148
  return savedDoc.data();
24972
25149
  }
24973
25150
  /**
@@ -24978,9 +25155,9 @@ var ProcedureService = class extends BaseService {
24978
25155
  async getProceduresForMap() {
24979
25156
  const proceduresRef = collection34(this.db, PROCEDURES_COLLECTION);
24980
25157
  const snapshot = await getDocs34(proceduresRef);
24981
- let procedures = snapshot.docs.map((doc53) => ({
24982
- id: doc53.id,
24983
- ...doc53.data()
25158
+ let procedures = snapshot.docs.map((doc54) => ({
25159
+ id: doc54.id,
25160
+ ...doc54.data()
24984
25161
  }));
24985
25162
  procedures = await this.filterDraftPractitionerProcedures(procedures);
24986
25163
  const proceduresForMap = procedures.map((procedure) => {
@@ -25008,8 +25185,8 @@ var ProcedureService = class extends BaseService {
25008
25185
  async getProceduresForConsultation(clinicBranchId, practitionerId, filterByFamily = true, defaultProcedureId) {
25009
25186
  let familyToFilter = null;
25010
25187
  if (filterByFamily && defaultProcedureId) {
25011
- const defaultProcedureRef = doc44(this.db, PROCEDURES_COLLECTION, defaultProcedureId);
25012
- const defaultProcedureSnap = await getDoc45(defaultProcedureRef);
25188
+ const defaultProcedureRef = doc45(this.db, PROCEDURES_COLLECTION, defaultProcedureId);
25189
+ const defaultProcedureSnap = await getDoc46(defaultProcedureRef);
25013
25190
  if (defaultProcedureSnap.exists()) {
25014
25191
  const defaultProcedure = defaultProcedureSnap.data();
25015
25192
  familyToFilter = defaultProcedure.family;
@@ -25029,9 +25206,9 @@ var ProcedureService = class extends BaseService {
25029
25206
  orderBy18("name", "asc")
25030
25207
  );
25031
25208
  const querySnapshot = await getDocs34(proceduresQuery);
25032
- let procedures = querySnapshot.docs.map((doc53) => ({
25033
- id: doc53.id,
25034
- ...doc53.data()
25209
+ let procedures = querySnapshot.docs.map((doc54) => ({
25210
+ id: doc54.id,
25211
+ ...doc54.data()
25035
25212
  }));
25036
25213
  procedures = await this.filterDraftPractitionerProcedures(procedures);
25037
25214
  return procedures;
@@ -25041,8 +25218,8 @@ var ProcedureService = class extends BaseService {
25041
25218
  // src/services/resource/resource.service.ts
25042
25219
  import {
25043
25220
  collection as collection35,
25044
- doc as doc45,
25045
- getDoc as getDoc46,
25221
+ doc as doc46,
25222
+ getDoc as getDoc47,
25046
25223
  getDocs as getDocs35,
25047
25224
  setDoc as setDoc32,
25048
25225
  deleteDoc as deleteDoc20,
@@ -25107,7 +25284,7 @@ var ResourceService = class extends BaseService {
25107
25284
  * Gets reference to a specific resource document
25108
25285
  */
25109
25286
  getResourceDocRef(clinicBranchId, resourceId) {
25110
- return doc45(
25287
+ return doc46(
25111
25288
  this.db,
25112
25289
  "clinics",
25113
25290
  clinicBranchId,
@@ -25149,7 +25326,7 @@ var ResourceService = class extends BaseService {
25149
25326
  */
25150
25327
  async createResource(data) {
25151
25328
  const batch = writeBatch7(this.db);
25152
- const resourceRef = doc45(this.getResourcesRef(data.clinicBranchId));
25329
+ const resourceRef = doc46(this.getResourcesRef(data.clinicBranchId));
25153
25330
  const resourceId = resourceRef.id;
25154
25331
  const now = serverTimestamp36();
25155
25332
  const resourceData = {
@@ -25167,7 +25344,7 @@ var ResourceService = class extends BaseService {
25167
25344
  };
25168
25345
  batch.set(resourceRef, resourceData);
25169
25346
  for (let i = 1; i <= data.quantity; i++) {
25170
- const instanceRef = doc45(
25347
+ const instanceRef = doc46(
25171
25348
  this.getInstancesRef(data.clinicBranchId, resourceId)
25172
25349
  );
25173
25350
  const instanceData = {
@@ -25192,7 +25369,7 @@ var ResourceService = class extends BaseService {
25192
25369
  */
25193
25370
  async getResource(clinicBranchId, resourceId) {
25194
25371
  const docRef = this.getResourceDocRef(clinicBranchId, resourceId);
25195
- const docSnap = await getDoc46(docRef);
25372
+ const docSnap = await getDoc47(docRef);
25196
25373
  if (!docSnap.exists()) return null;
25197
25374
  return { id: docSnap.id, ...docSnap.data() };
25198
25375
  }
@@ -25248,7 +25425,7 @@ var ResourceService = class extends BaseService {
25248
25425
  const now = serverTimestamp36();
25249
25426
  const resourceName = data.name || existing.name;
25250
25427
  for (let i = existing.quantity + 1; i <= data.quantity; i++) {
25251
- const instanceRef = doc45(
25428
+ const instanceRef = doc46(
25252
25429
  this.getInstancesRef(clinicBranchId, resourceId)
25253
25430
  );
25254
25431
  const instanceData = {
@@ -25293,7 +25470,7 @@ var ResourceService = class extends BaseService {
25293
25470
  }
25294
25471
  const batch = writeBatch7(this.db);
25295
25472
  for (const instance of instancesToRemove) {
25296
- const instanceRef = doc45(
25473
+ const instanceRef = doc46(
25297
25474
  this.getInstancesRef(clinicBranchId, resourceId),
25298
25475
  instance.id
25299
25476
  );
@@ -25405,7 +25582,7 @@ var ResourceService = class extends BaseService {
25405
25582
  params.resourceId,
25406
25583
  params.resourceInstanceId
25407
25584
  );
25408
- const eventRef = doc45(calendarRef);
25585
+ const eventRef = doc46(calendarRef);
25409
25586
  const now = serverTimestamp36();
25410
25587
  const eventData = {
25411
25588
  id: eventRef.id,
@@ -25438,8 +25615,8 @@ var ResourceService = class extends BaseService {
25438
25615
  params.resourceId,
25439
25616
  params.resourceInstanceId
25440
25617
  );
25441
- const eventRef = doc45(calendarRef, params.eventId);
25442
- const eventSnap = await getDoc46(eventRef);
25618
+ const eventRef = doc46(calendarRef, params.eventId);
25619
+ const eventSnap = await getDoc47(eventRef);
25443
25620
  if (!eventSnap.exists()) {
25444
25621
  throw new Error(`Blocking event ${params.eventId} not found`);
25445
25622
  }
@@ -25456,7 +25633,7 @@ var ResourceService = class extends BaseService {
25456
25633
  updateData.description = params.description;
25457
25634
  }
25458
25635
  await updateDoc41(eventRef, updateData);
25459
- const updatedSnap = await getDoc46(eventRef);
25636
+ const updatedSnap = await getDoc47(eventRef);
25460
25637
  return { id: updatedSnap.id, ...updatedSnap.data() };
25461
25638
  }
25462
25639
  /**
@@ -25468,8 +25645,8 @@ var ResourceService = class extends BaseService {
25468
25645
  resourceId,
25469
25646
  instanceId
25470
25647
  );
25471
- const eventRef = doc45(calendarRef, eventId);
25472
- const eventSnap = await getDoc46(eventRef);
25648
+ const eventRef = doc46(calendarRef, eventId);
25649
+ const eventSnap = await getDoc47(eventRef);
25473
25650
  if (!eventSnap.exists()) {
25474
25651
  throw new Error(`Blocking event ${eventId} not found`);
25475
25652
  }
@@ -25499,8 +25676,8 @@ var ResourceService = class extends BaseService {
25499
25676
  // src/services/reviews/reviews.service.ts
25500
25677
  import {
25501
25678
  collection as collection36,
25502
- doc as doc46,
25503
- getDoc as getDoc47,
25679
+ doc as doc47,
25680
+ getDoc as getDoc48,
25504
25681
  getDocs as getDocs36,
25505
25682
  query as query36,
25506
25683
  where as where36,
@@ -25668,7 +25845,7 @@ var ReviewService = class extends BaseService {
25668
25845
  delete firestoreData[key];
25669
25846
  }
25670
25847
  });
25671
- const docRef = doc46(this.db, REVIEWS_COLLECTION, reviewId);
25848
+ const docRef = doc47(this.db, REVIEWS_COLLECTION, reviewId);
25672
25849
  await setDoc33(docRef, firestoreData);
25673
25850
  console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
25674
25851
  reviewId,
@@ -25693,16 +25870,16 @@ var ReviewService = class extends BaseService {
25693
25870
  async getReview(reviewId) {
25694
25871
  var _a, _b, _c, _d, _e;
25695
25872
  console.log("\u{1F50D} ReviewService.getReview - Getting review:", reviewId);
25696
- const docRef = doc46(this.db, REVIEWS_COLLECTION, reviewId);
25697
- const docSnap = await getDoc47(docRef);
25873
+ const docRef = doc47(this.db, REVIEWS_COLLECTION, reviewId);
25874
+ const docSnap = await getDoc48(docRef);
25698
25875
  if (!docSnap.exists()) {
25699
25876
  console.log("\u274C ReviewService.getReview - Review not found:", reviewId);
25700
25877
  return null;
25701
25878
  }
25702
25879
  const review = { ...this.convertDocToReview(docSnap.data()), id: reviewId };
25703
25880
  try {
25704
- const appointmentDoc = await getDoc47(
25705
- doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25881
+ const appointmentDoc = await getDoc48(
25882
+ doc47(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25706
25883
  );
25707
25884
  if (appointmentDoc.exists()) {
25708
25885
  const appointment = appointmentDoc.data();
@@ -25764,12 +25941,12 @@ var ReviewService = class extends BaseService {
25764
25941
  async getReviewsByPatient(patientId) {
25765
25942
  const q = query36(collection36(this.db, REVIEWS_COLLECTION), where36("patientId", "==", patientId));
25766
25943
  const snapshot = await getDocs36(q);
25767
- const reviews = snapshot.docs.map((doc53) => this.convertDocToReview(doc53.data()));
25944
+ const reviews = snapshot.docs.map((doc54) => this.convertDocToReview(doc54.data()));
25768
25945
  const enhancedReviews = await Promise.all(
25769
25946
  reviews.map(async (review) => {
25770
25947
  try {
25771
- const appointmentDoc = await getDoc47(
25772
- doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25948
+ const appointmentDoc = await getDoc48(
25949
+ doc47(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25773
25950
  );
25774
25951
  if (appointmentDoc.exists()) {
25775
25952
  const appointment = appointmentDoc.data();
@@ -25818,9 +25995,9 @@ var ReviewService = class extends BaseService {
25818
25995
  where36("clinicReview.clinicId", "==", clinicId)
25819
25996
  );
25820
25997
  const snapshot = await getDocs36(q);
25821
- const reviews = snapshot.docs.map((doc53) => {
25822
- const review = this.convertDocToReview(doc53.data());
25823
- return { ...review, id: doc53.id };
25998
+ const reviews = snapshot.docs.map((doc54) => {
25999
+ const review = this.convertDocToReview(doc54.data());
26000
+ return { ...review, id: doc54.id };
25824
26001
  });
25825
26002
  console.log("\u{1F50D} ReviewService.getReviewsByClinic - Found reviews before enhancement:", {
25826
26003
  clinicId,
@@ -25830,8 +26007,8 @@ var ReviewService = class extends BaseService {
25830
26007
  const enhancedReviews = await Promise.all(
25831
26008
  reviews.map(async (review) => {
25832
26009
  try {
25833
- const appointmentDoc = await getDoc47(
25834
- doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
26010
+ const appointmentDoc = await getDoc48(
26011
+ doc47(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25835
26012
  );
25836
26013
  if (appointmentDoc.exists()) {
25837
26014
  const appointment = appointmentDoc.data();
@@ -25894,9 +26071,9 @@ var ReviewService = class extends BaseService {
25894
26071
  where36("practitionerReview.practitionerId", "==", practitionerId)
25895
26072
  );
25896
26073
  const snapshot = await getDocs36(q);
25897
- const reviews = snapshot.docs.map((doc53) => {
25898
- const review = this.convertDocToReview(doc53.data());
25899
- return { ...review, id: doc53.id };
26074
+ const reviews = snapshot.docs.map((doc54) => {
26075
+ const review = this.convertDocToReview(doc54.data());
26076
+ return { ...review, id: doc54.id };
25900
26077
  });
25901
26078
  console.log("\u{1F50D} ReviewService.getReviewsByPractitioner - Found reviews before enhancement:", {
25902
26079
  practitionerId,
@@ -25906,8 +26083,8 @@ var ReviewService = class extends BaseService {
25906
26083
  const enhancedReviews = await Promise.all(
25907
26084
  reviews.map(async (review) => {
25908
26085
  try {
25909
- const appointmentDoc = await getDoc47(
25910
- doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
26086
+ const appointmentDoc = await getDoc48(
26087
+ doc47(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25911
26088
  );
25912
26089
  if (appointmentDoc.exists()) {
25913
26090
  const appointment = appointmentDoc.data();
@@ -25967,9 +26144,9 @@ var ReviewService = class extends BaseService {
25967
26144
  where36("procedureReview.procedureId", "==", procedureId)
25968
26145
  );
25969
26146
  const snapshot = await getDocs36(q);
25970
- const reviews = snapshot.docs.map((doc53) => {
25971
- const data = doc53.data();
25972
- return { ...data, id: doc53.id };
26147
+ const reviews = snapshot.docs.map((doc54) => {
26148
+ const data = doc54.data();
26149
+ return { ...data, id: doc54.id };
25973
26150
  });
25974
26151
  console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Found reviews before enhancement:", {
25975
26152
  procedureId,
@@ -25979,8 +26156,8 @@ var ReviewService = class extends BaseService {
25979
26156
  const enhancedReviews = await Promise.all(
25980
26157
  reviews.map(async (review) => {
25981
26158
  try {
25982
- const appointmentDoc = await getDoc47(
25983
- doc46(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
26159
+ const appointmentDoc = await getDoc48(
26160
+ doc47(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25984
26161
  );
25985
26162
  if (appointmentDoc.exists()) {
25986
26163
  const appointment = appointmentDoc.data();
@@ -26053,7 +26230,7 @@ var ReviewService = class extends BaseService {
26053
26230
  if (!review) {
26054
26231
  throw new Error(`Review with ID ${reviewId} not found`);
26055
26232
  }
26056
- await deleteDoc21(doc46(this.db, REVIEWS_COLLECTION, reviewId));
26233
+ await deleteDoc21(doc47(this.db, REVIEWS_COLLECTION, reviewId));
26057
26234
  }
26058
26235
  /**
26059
26236
  * Calculates the average of an array of numbers
@@ -26127,8 +26304,8 @@ var getFirebaseFunctions = async () => {
26127
26304
  import {
26128
26305
  addDoc as addDoc4,
26129
26306
  collection as collection37,
26130
- doc as doc47,
26131
- getDoc as getDoc48,
26307
+ doc as doc48,
26308
+ getDoc as getDoc49,
26132
26309
  getDocs as getDocs37,
26133
26310
  query as query37,
26134
26311
  updateDoc as updateDoc42,
@@ -26190,9 +26367,9 @@ var BrandService = class extends BaseService {
26190
26367
  const q = query37(this.getBrandsRef(), ...constraints);
26191
26368
  const snapshot = await getDocs37(q);
26192
26369
  const brands = snapshot.docs.map(
26193
- (doc53) => ({
26194
- id: doc53.id,
26195
- ...doc53.data()
26370
+ (doc54) => ({
26371
+ id: doc54.id,
26372
+ ...doc54.data()
26196
26373
  })
26197
26374
  );
26198
26375
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -26226,9 +26403,9 @@ var BrandService = class extends BaseService {
26226
26403
  );
26227
26404
  const snapshot = await getDocs37(q);
26228
26405
  return snapshot.docs.map(
26229
- (doc53) => ({
26230
- id: doc53.id,
26231
- ...doc53.data()
26406
+ (doc54) => ({
26407
+ id: doc54.id,
26408
+ ...doc54.data()
26232
26409
  })
26233
26410
  );
26234
26411
  }
@@ -26243,7 +26420,7 @@ var BrandService = class extends BaseService {
26243
26420
  if (brand.name) {
26244
26421
  updateData.name_lowercase = brand.name.toLowerCase();
26245
26422
  }
26246
- const docRef = doc47(this.getBrandsRef(), brandId);
26423
+ const docRef = doc48(this.getBrandsRef(), brandId);
26247
26424
  await updateDoc42(docRef, updateData);
26248
26425
  return this.getById(brandId);
26249
26426
  }
@@ -26259,8 +26436,8 @@ var BrandService = class extends BaseService {
26259
26436
  * Gets a brand by ID
26260
26437
  */
26261
26438
  async getById(brandId) {
26262
- const docRef = doc47(this.getBrandsRef(), brandId);
26263
- const docSnap = await getDoc48(docRef);
26439
+ const docRef = doc48(this.getBrandsRef(), brandId);
26440
+ const docSnap = await getDoc49(docRef);
26264
26441
  if (!docSnap.exists()) return null;
26265
26442
  return {
26266
26443
  id: docSnap.id,
@@ -26340,8 +26517,8 @@ var BrandService = class extends BaseService {
26340
26517
  import {
26341
26518
  addDoc as addDoc5,
26342
26519
  collection as collection38,
26343
- doc as doc48,
26344
- getDoc as getDoc49,
26520
+ doc as doc49,
26521
+ getDoc as getDoc50,
26345
26522
  getDocs as getDocs38,
26346
26523
  limit as limit18,
26347
26524
  orderBy as orderBy21,
@@ -26402,7 +26579,7 @@ var CategoryService = class extends BaseService {
26402
26579
  where38("isActive", "==", active)
26403
26580
  );
26404
26581
  const snapshot = await getDocs38(q);
26405
- const filteredDocs = snapshot.docs.filter((doc53) => doc53.id !== EXCLUDED_CATEGORY_ID);
26582
+ const filteredDocs = snapshot.docs.filter((doc54) => doc54.id !== EXCLUDED_CATEGORY_ID);
26406
26583
  counts[family] = filteredDocs.length;
26407
26584
  }
26408
26585
  return counts;
@@ -26415,9 +26592,9 @@ var CategoryService = class extends BaseService {
26415
26592
  const q = query38(this.categoriesRef, where38("isActive", "==", true));
26416
26593
  const snapshot = await getDocs38(q);
26417
26594
  const categories = snapshot.docs.map(
26418
- (doc53) => ({
26419
- id: doc53.id,
26420
- ...doc53.data()
26595
+ (doc54) => ({
26596
+ id: doc54.id,
26597
+ ...doc54.data()
26421
26598
  })
26422
26599
  );
26423
26600
  return this.filterExcludedCategories(categories);
@@ -26436,9 +26613,9 @@ var CategoryService = class extends BaseService {
26436
26613
  );
26437
26614
  const snapshot = await getDocs38(q);
26438
26615
  const categories = snapshot.docs.map(
26439
- (doc53) => ({
26440
- id: doc53.id,
26441
- ...doc53.data()
26616
+ (doc54) => ({
26617
+ id: doc54.id,
26618
+ ...doc54.data()
26442
26619
  })
26443
26620
  );
26444
26621
  return this.filterExcludedCategories(categories);
@@ -26459,9 +26636,9 @@ var CategoryService = class extends BaseService {
26459
26636
  const q = query38(this.categoriesRef, ...constraints);
26460
26637
  const snapshot = await getDocs38(q);
26461
26638
  const categories = snapshot.docs.map(
26462
- (doc53) => ({
26463
- id: doc53.id,
26464
- ...doc53.data()
26639
+ (doc54) => ({
26640
+ id: doc54.id,
26641
+ ...doc54.data()
26465
26642
  })
26466
26643
  );
26467
26644
  const filteredCategories = this.filterExcludedCategories(categories);
@@ -26486,9 +26663,9 @@ var CategoryService = class extends BaseService {
26486
26663
  const q = query38(this.categoriesRef, ...constraints);
26487
26664
  const snapshot = await getDocs38(q);
26488
26665
  const categories = snapshot.docs.map(
26489
- (doc53) => ({
26490
- id: doc53.id,
26491
- ...doc53.data()
26666
+ (doc54) => ({
26667
+ id: doc54.id,
26668
+ ...doc54.data()
26492
26669
  })
26493
26670
  );
26494
26671
  const filteredCategories = this.filterExcludedCategories(categories);
@@ -26506,7 +26683,7 @@ var CategoryService = class extends BaseService {
26506
26683
  ...category,
26507
26684
  updatedAt: /* @__PURE__ */ new Date()
26508
26685
  };
26509
- const docRef = doc48(this.categoriesRef, id);
26686
+ const docRef = doc49(this.categoriesRef, id);
26510
26687
  await updateDoc43(docRef, updateData);
26511
26688
  return this.getById(id);
26512
26689
  }
@@ -26531,8 +26708,8 @@ var CategoryService = class extends BaseService {
26531
26708
  */
26532
26709
  async getById(id) {
26533
26710
  if (id === EXCLUDED_CATEGORY_ID) return null;
26534
- const docRef = doc48(this.categoriesRef, id);
26535
- const docSnap = await getDoc49(docRef);
26711
+ const docRef = doc49(this.categoriesRef, id);
26712
+ const docSnap = await getDoc50(docRef);
26536
26713
  if (!docSnap.exists()) return null;
26537
26714
  return {
26538
26715
  id: docSnap.id,
@@ -26546,8 +26723,8 @@ var CategoryService = class extends BaseService {
26546
26723
  * @returns Category or null if not found
26547
26724
  */
26548
26725
  async getByIdInternal(id) {
26549
- const docRef = doc48(this.categoriesRef, id);
26550
- const docSnap = await getDoc49(docRef);
26726
+ const docRef = doc49(this.categoriesRef, id);
26727
+ const docSnap = await getDoc50(docRef);
26551
26728
  if (!docSnap.exists()) return null;
26552
26729
  return {
26553
26730
  id: docSnap.id,
@@ -26570,11 +26747,11 @@ var CategoryService = class extends BaseService {
26570
26747
  );
26571
26748
  const snapshot = await getDocs38(q);
26572
26749
  if (snapshot.empty) return null;
26573
- const doc53 = snapshot.docs[0];
26574
- if (doc53.id === EXCLUDED_CATEGORY_ID) return null;
26750
+ const doc54 = snapshot.docs[0];
26751
+ if (doc54.id === EXCLUDED_CATEGORY_ID) return null;
26575
26752
  return {
26576
- id: doc53.id,
26577
- ...doc53.data()
26753
+ id: doc54.id,
26754
+ ...doc54.data()
26578
26755
  };
26579
26756
  }
26580
26757
  /**
@@ -26651,8 +26828,8 @@ import {
26651
26828
  collection as collection39,
26652
26829
  collectionGroup as collectionGroup2,
26653
26830
  deleteDoc as deleteDoc22,
26654
- doc as doc49,
26655
- getDoc as getDoc50,
26831
+ doc as doc50,
26832
+ getDoc as getDoc51,
26656
26833
  getDocs as getDocs39,
26657
26834
  limit as limit19,
26658
26835
  orderBy as orderBy22,
@@ -26724,7 +26901,7 @@ var SubcategoryService = class extends BaseService {
26724
26901
  const subcategoriesRef = this.getSubcategoriesRef(categoryId);
26725
26902
  const q = query39(subcategoriesRef, where39("isActive", "==", active));
26726
26903
  const snapshot = await getDocs39(q);
26727
- const filteredDocs = snapshot.docs.filter((doc53) => doc53.id !== EXCLUDED_SUBCATEGORY_ID);
26904
+ const filteredDocs = snapshot.docs.filter((doc54) => doc54.id !== EXCLUDED_SUBCATEGORY_ID);
26728
26905
  counts[categoryId] = filteredDocs.length;
26729
26906
  }
26730
26907
  return counts;
@@ -26746,9 +26923,9 @@ var SubcategoryService = class extends BaseService {
26746
26923
  const q = query39(this.getSubcategoriesRef(categoryId), ...constraints);
26747
26924
  const querySnapshot = await getDocs39(q);
26748
26925
  const subcategories = querySnapshot.docs.map(
26749
- (doc53) => ({
26750
- id: doc53.id,
26751
- ...doc53.data()
26926
+ (doc54) => ({
26927
+ id: doc54.id,
26928
+ ...doc54.data()
26752
26929
  })
26753
26930
  );
26754
26931
  const filteredSubcategories = this.filterExcludedSubcategories(subcategories);
@@ -26777,9 +26954,9 @@ var SubcategoryService = class extends BaseService {
26777
26954
  );
26778
26955
  const querySnapshot = await getDocs39(q);
26779
26956
  const subcategories = querySnapshot.docs.map(
26780
- (doc53) => ({
26781
- id: doc53.id,
26782
- ...doc53.data()
26957
+ (doc54) => ({
26958
+ id: doc54.id,
26959
+ ...doc54.data()
26783
26960
  })
26784
26961
  );
26785
26962
  const filteredSubcategories = this.filterExcludedSubcategories(subcategories);
@@ -26798,9 +26975,9 @@ var SubcategoryService = class extends BaseService {
26798
26975
  );
26799
26976
  const querySnapshot = await getDocs39(q);
26800
26977
  const subcategories = querySnapshot.docs.map(
26801
- (doc53) => ({
26802
- id: doc53.id,
26803
- ...doc53.data()
26978
+ (doc54) => ({
26979
+ id: doc54.id,
26980
+ ...doc54.data()
26804
26981
  })
26805
26982
  );
26806
26983
  return this.filterExcludedSubcategories(subcategories);
@@ -26816,9 +26993,9 @@ var SubcategoryService = class extends BaseService {
26816
26993
  );
26817
26994
  const querySnapshot = await getDocs39(q);
26818
26995
  const subcategories = querySnapshot.docs.map(
26819
- (doc53) => ({
26820
- id: doc53.id,
26821
- ...doc53.data()
26996
+ (doc54) => ({
26997
+ id: doc54.id,
26998
+ ...doc54.data()
26822
26999
  })
26823
27000
  );
26824
27001
  return this.filterExcludedSubcategories(subcategories);
@@ -26833,11 +27010,11 @@ var SubcategoryService = class extends BaseService {
26833
27010
  async update(categoryId, subcategoryId, subcategory) {
26834
27011
  const newCategoryId = subcategory.categoryId;
26835
27012
  if (newCategoryId && newCategoryId !== categoryId) {
26836
- const oldDocRef = doc49(
27013
+ const oldDocRef = doc50(
26837
27014
  this.getSubcategoriesRef(categoryId),
26838
27015
  subcategoryId
26839
27016
  );
26840
- const docSnap = await getDoc50(oldDocRef);
27017
+ const docSnap = await getDoc51(oldDocRef);
26841
27018
  if (!docSnap.exists()) {
26842
27019
  throw new Error("Subcategory to update does not exist.");
26843
27020
  }
@@ -26851,7 +27028,7 @@ var SubcategoryService = class extends BaseService {
26851
27028
  // Preserve original creation date
26852
27029
  updatedAt: /* @__PURE__ */ new Date()
26853
27030
  };
26854
- const newDocRef = doc49(
27031
+ const newDocRef = doc50(
26855
27032
  this.getSubcategoriesRef(newCategoryId),
26856
27033
  subcategoryId
26857
27034
  );
@@ -26863,7 +27040,7 @@ var SubcategoryService = class extends BaseService {
26863
27040
  ...subcategory,
26864
27041
  updatedAt: /* @__PURE__ */ new Date()
26865
27042
  };
26866
- const docRef = doc49(this.getSubcategoriesRef(categoryId), subcategoryId);
27043
+ const docRef = doc50(this.getSubcategoriesRef(categoryId), subcategoryId);
26867
27044
  await updateDoc44(docRef, updateData);
26868
27045
  return this.getById(categoryId, subcategoryId);
26869
27046
  }
@@ -26892,8 +27069,8 @@ var SubcategoryService = class extends BaseService {
26892
27069
  */
26893
27070
  async getById(categoryId, subcategoryId) {
26894
27071
  if (subcategoryId === EXCLUDED_SUBCATEGORY_ID) return null;
26895
- const docRef = doc49(this.getSubcategoriesRef(categoryId), subcategoryId);
26896
- const docSnap = await getDoc50(docRef);
27072
+ const docRef = doc50(this.getSubcategoriesRef(categoryId), subcategoryId);
27073
+ const docSnap = await getDoc51(docRef);
26897
27074
  if (!docSnap.exists()) return null;
26898
27075
  return {
26899
27076
  id: docSnap.id,
@@ -26908,8 +27085,8 @@ var SubcategoryService = class extends BaseService {
26908
27085
  * @returns Subcategory or null if not found
26909
27086
  */
26910
27087
  async getByIdInternal(categoryId, subcategoryId) {
26911
- const docRef = doc49(this.getSubcategoriesRef(categoryId), subcategoryId);
26912
- const docSnap = await getDoc50(docRef);
27088
+ const docRef = doc50(this.getSubcategoriesRef(categoryId), subcategoryId);
27089
+ const docSnap = await getDoc51(docRef);
26913
27090
  if (!docSnap.exists()) return null;
26914
27091
  return {
26915
27092
  id: docSnap.id,
@@ -26931,11 +27108,11 @@ var SubcategoryService = class extends BaseService {
26931
27108
  );
26932
27109
  const querySnapshot = await getDocs39(q);
26933
27110
  if (querySnapshot.empty) return null;
26934
- const doc53 = querySnapshot.docs[0];
26935
- if (doc53.id === EXCLUDED_SUBCATEGORY_ID) return null;
27111
+ const doc54 = querySnapshot.docs[0];
27112
+ if (doc54.id === EXCLUDED_SUBCATEGORY_ID) return null;
26936
27113
  return {
26937
- id: doc53.id,
26938
- ...doc53.data()
27114
+ id: doc54.id,
27115
+ ...doc54.data()
26939
27116
  };
26940
27117
  }
26941
27118
  /**
@@ -27013,8 +27190,8 @@ var SubcategoryService = class extends BaseService {
27013
27190
  import {
27014
27191
  addDoc as addDoc7,
27015
27192
  collection as collection40,
27016
- doc as doc50,
27017
- getDoc as getDoc51,
27193
+ doc as doc51,
27194
+ getDoc as getDoc52,
27018
27195
  getDocs as getDocs40,
27019
27196
  limit as limit20,
27020
27197
  orderBy as orderBy23,
@@ -27092,9 +27269,9 @@ var TechnologyService = class extends BaseService {
27092
27269
  const q = query40(this.technologiesRef, where40("isActive", "==", active));
27093
27270
  const snapshot = await getDocs40(q);
27094
27271
  const counts = {};
27095
- snapshot.docs.forEach((doc53) => {
27096
- if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return;
27097
- const tech = doc53.data();
27272
+ snapshot.docs.forEach((doc54) => {
27273
+ if (doc54.id === EXCLUDED_TECHNOLOGY_ID) return;
27274
+ const tech = doc54.data();
27098
27275
  counts[tech.subcategoryId] = (counts[tech.subcategoryId] || 0) + 1;
27099
27276
  });
27100
27277
  return counts;
@@ -27108,9 +27285,9 @@ var TechnologyService = class extends BaseService {
27108
27285
  const q = query40(this.technologiesRef, where40("isActive", "==", active));
27109
27286
  const snapshot = await getDocs40(q);
27110
27287
  const counts = {};
27111
- snapshot.docs.forEach((doc53) => {
27112
- if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return;
27113
- const tech = doc53.data();
27288
+ snapshot.docs.forEach((doc54) => {
27289
+ if (doc54.id === EXCLUDED_TECHNOLOGY_ID) return;
27290
+ const tech = doc54.data();
27114
27291
  counts[tech.categoryId] = (counts[tech.categoryId] || 0) + 1;
27115
27292
  });
27116
27293
  return counts;
@@ -27131,9 +27308,9 @@ var TechnologyService = class extends BaseService {
27131
27308
  const q = query40(this.technologiesRef, ...constraints);
27132
27309
  const snapshot = await getDocs40(q);
27133
27310
  const technologies = snapshot.docs.map(
27134
- (doc53) => ({
27135
- id: doc53.id,
27136
- ...doc53.data()
27311
+ (doc54) => ({
27312
+ id: doc54.id,
27313
+ ...doc54.data()
27137
27314
  })
27138
27315
  );
27139
27316
  const filteredTechnologies = this.filterExcludedTechnologies(technologies);
@@ -27158,9 +27335,9 @@ var TechnologyService = class extends BaseService {
27158
27335
  const q = query40(this.technologiesRef, ...constraints);
27159
27336
  const snapshot = await getDocs40(q);
27160
27337
  const technologies = snapshot.docs.map(
27161
- (doc53) => ({
27162
- id: doc53.id,
27163
- ...doc53.data()
27338
+ (doc54) => ({
27339
+ id: doc54.id,
27340
+ ...doc54.data()
27164
27341
  })
27165
27342
  );
27166
27343
  const filteredTechnologies = this.filterExcludedTechnologies(technologies);
@@ -27185,9 +27362,9 @@ var TechnologyService = class extends BaseService {
27185
27362
  const q = query40(this.technologiesRef, ...constraints);
27186
27363
  const snapshot = await getDocs40(q);
27187
27364
  const technologies = snapshot.docs.map(
27188
- (doc53) => ({
27189
- id: doc53.id,
27190
- ...doc53.data()
27365
+ (doc54) => ({
27366
+ id: doc54.id,
27367
+ ...doc54.data()
27191
27368
  })
27192
27369
  );
27193
27370
  const filteredTechnologies = this.filterExcludedTechnologies(technologies);
@@ -27215,7 +27392,7 @@ var TechnologyService = class extends BaseService {
27215
27392
  }
27216
27393
  }
27217
27394
  updateData.updatedAt = /* @__PURE__ */ new Date();
27218
- const docRef = doc50(this.technologiesRef, id);
27395
+ const docRef = doc51(this.technologiesRef, id);
27219
27396
  const beforeTech = await this.getById(id);
27220
27397
  await updateDoc45(docRef, updateData);
27221
27398
  const categoryChanged = beforeTech && updateData.categoryId && beforeTech.categoryId !== updateData.categoryId;
@@ -27251,8 +27428,8 @@ var TechnologyService = class extends BaseService {
27251
27428
  */
27252
27429
  async getById(id) {
27253
27430
  if (id === EXCLUDED_TECHNOLOGY_ID) return null;
27254
- const docRef = doc50(this.technologiesRef, id);
27255
- const docSnap = await getDoc51(docRef);
27431
+ const docRef = doc51(this.technologiesRef, id);
27432
+ const docSnap = await getDoc52(docRef);
27256
27433
  if (!docSnap.exists()) return null;
27257
27434
  return {
27258
27435
  id: docSnap.id,
@@ -27266,8 +27443,8 @@ var TechnologyService = class extends BaseService {
27266
27443
  * @returns The technology or null if it doesn't exist
27267
27444
  */
27268
27445
  async getByIdInternal(id) {
27269
- const docRef = doc50(this.technologiesRef, id);
27270
- const docSnap = await getDoc51(docRef);
27446
+ const docRef = doc51(this.technologiesRef, id);
27447
+ const docSnap = await getDoc52(docRef);
27271
27448
  if (!docSnap.exists()) return null;
27272
27449
  return {
27273
27450
  id: docSnap.id,
@@ -27288,11 +27465,11 @@ var TechnologyService = class extends BaseService {
27288
27465
  );
27289
27466
  const snapshot = await getDocs40(q);
27290
27467
  if (snapshot.empty) return null;
27291
- const doc53 = snapshot.docs[0];
27292
- if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return null;
27468
+ const doc54 = snapshot.docs[0];
27469
+ if (doc54.id === EXCLUDED_TECHNOLOGY_ID) return null;
27293
27470
  return {
27294
- id: doc53.id,
27295
- ...doc53.data()
27471
+ id: doc54.id,
27472
+ ...doc54.data()
27296
27473
  };
27297
27474
  }
27298
27475
  /**
@@ -27302,7 +27479,7 @@ var TechnologyService = class extends BaseService {
27302
27479
  * @returns Ažurirana tehnologija sa novim zahtevom
27303
27480
  */
27304
27481
  async addRequirement(technologyId, requirement) {
27305
- const docRef = doc50(this.technologiesRef, technologyId);
27482
+ const docRef = doc51(this.technologiesRef, technologyId);
27306
27483
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
27307
27484
  await updateDoc45(docRef, {
27308
27485
  [requirementType]: arrayUnion9(requirement),
@@ -27317,7 +27494,7 @@ var TechnologyService = class extends BaseService {
27317
27494
  * @returns Ažurirana tehnologija bez uklonjenog zahteva
27318
27495
  */
27319
27496
  async removeRequirement(technologyId, requirement) {
27320
- const docRef = doc50(this.technologiesRef, technologyId);
27497
+ const docRef = doc51(this.technologiesRef, technologyId);
27321
27498
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
27322
27499
  await updateDoc45(docRef, {
27323
27500
  [requirementType]: arrayRemove8(requirement),
@@ -27357,7 +27534,7 @@ var TechnologyService = class extends BaseService {
27357
27534
  * @returns Ažurirana tehnologija
27358
27535
  */
27359
27536
  async addBlockingCondition(technologyId, condition) {
27360
- const docRef = doc50(this.technologiesRef, technologyId);
27537
+ const docRef = doc51(this.technologiesRef, technologyId);
27361
27538
  await updateDoc45(docRef, {
27362
27539
  blockingConditions: arrayUnion9(condition),
27363
27540
  updatedAt: /* @__PURE__ */ new Date()
@@ -27371,7 +27548,7 @@ var TechnologyService = class extends BaseService {
27371
27548
  * @returns Ažurirana tehnologija
27372
27549
  */
27373
27550
  async removeBlockingCondition(technologyId, condition) {
27374
- const docRef = doc50(this.technologiesRef, technologyId);
27551
+ const docRef = doc51(this.technologiesRef, technologyId);
27375
27552
  await updateDoc45(docRef, {
27376
27553
  blockingConditions: arrayRemove8(condition),
27377
27554
  updatedAt: /* @__PURE__ */ new Date()
@@ -27385,7 +27562,7 @@ var TechnologyService = class extends BaseService {
27385
27562
  * @returns Ažurirana tehnologija
27386
27563
  */
27387
27564
  async addContraindication(technologyId, contraindication) {
27388
- const docRef = doc50(this.technologiesRef, technologyId);
27565
+ const docRef = doc51(this.technologiesRef, technologyId);
27389
27566
  const technology = await this.getById(technologyId);
27390
27567
  if (!technology) {
27391
27568
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -27407,7 +27584,7 @@ var TechnologyService = class extends BaseService {
27407
27584
  * @returns Ažurirana tehnologija
27408
27585
  */
27409
27586
  async removeContraindication(technologyId, contraindication) {
27410
- const docRef = doc50(this.technologiesRef, technologyId);
27587
+ const docRef = doc51(this.technologiesRef, technologyId);
27411
27588
  const technology = await this.getById(technologyId);
27412
27589
  if (!technology) {
27413
27590
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -27429,7 +27606,7 @@ var TechnologyService = class extends BaseService {
27429
27606
  * @returns The updated technology
27430
27607
  */
27431
27608
  async updateContraindication(technologyId, contraindication) {
27432
- const docRef = doc50(this.technologiesRef, technologyId);
27609
+ const docRef = doc51(this.technologiesRef, technologyId);
27433
27610
  const technology = await this.getById(technologyId);
27434
27611
  if (!technology) {
27435
27612
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -27457,7 +27634,7 @@ var TechnologyService = class extends BaseService {
27457
27634
  * @returns Ažurirana tehnologija
27458
27635
  */
27459
27636
  async addBenefit(technologyId, benefit) {
27460
- const docRef = doc50(this.technologiesRef, technologyId);
27637
+ const docRef = doc51(this.technologiesRef, technologyId);
27461
27638
  const technology = await this.getById(technologyId);
27462
27639
  if (!technology) {
27463
27640
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -27479,7 +27656,7 @@ var TechnologyService = class extends BaseService {
27479
27656
  * @returns Ažurirana tehnologija
27480
27657
  */
27481
27658
  async removeBenefit(technologyId, benefit) {
27482
- const docRef = doc50(this.technologiesRef, technologyId);
27659
+ const docRef = doc51(this.technologiesRef, technologyId);
27483
27660
  const technology = await this.getById(technologyId);
27484
27661
  if (!technology) {
27485
27662
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -27499,7 +27676,7 @@ var TechnologyService = class extends BaseService {
27499
27676
  * @returns The updated technology
27500
27677
  */
27501
27678
  async updateBenefit(technologyId, benefit) {
27502
- const docRef = doc50(this.technologiesRef, technologyId);
27679
+ const docRef = doc51(this.technologiesRef, technologyId);
27503
27680
  const technology = await this.getById(technologyId);
27504
27681
  if (!technology) {
27505
27682
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -27554,7 +27731,7 @@ var TechnologyService = class extends BaseService {
27554
27731
  * @returns Ažurirana tehnologija
27555
27732
  */
27556
27733
  async updateCertificationRequirement(technologyId, certificationRequirement) {
27557
- const docRef = doc50(this.technologiesRef, technologyId);
27734
+ const docRef = doc51(this.technologiesRef, technologyId);
27558
27735
  await updateDoc45(docRef, {
27559
27736
  certificationRequirement,
27560
27737
  updatedAt: /* @__PURE__ */ new Date()
@@ -27656,9 +27833,9 @@ var TechnologyService = class extends BaseService {
27656
27833
  );
27657
27834
  const snapshot = await getDocs40(q);
27658
27835
  const technologies = snapshot.docs.map(
27659
- (doc53) => ({
27660
- id: doc53.id,
27661
- ...doc53.data()
27836
+ (doc54) => ({
27837
+ id: doc54.id,
27838
+ ...doc54.data()
27662
27839
  })
27663
27840
  );
27664
27841
  return this.filterExcludedTechnologies(technologies);
@@ -27678,9 +27855,9 @@ var TechnologyService = class extends BaseService {
27678
27855
  );
27679
27856
  const snapshot = await getDocs40(q);
27680
27857
  const technologies = snapshot.docs.map(
27681
- (doc53) => ({
27682
- id: doc53.id,
27683
- ...doc53.data()
27858
+ (doc54) => ({
27859
+ id: doc54.id,
27860
+ ...doc54.data()
27684
27861
  })
27685
27862
  );
27686
27863
  return this.filterExcludedTechnologies(technologies);
@@ -27696,9 +27873,9 @@ var TechnologyService = class extends BaseService {
27696
27873
  );
27697
27874
  const snapshot = await getDocs40(q);
27698
27875
  const technologies = snapshot.docs.map(
27699
- (doc53) => ({
27700
- id: doc53.id,
27701
- ...doc53.data()
27876
+ (doc54) => ({
27877
+ id: doc54.id,
27878
+ ...doc54.data()
27702
27879
  })
27703
27880
  );
27704
27881
  return this.filterExcludedTechnologies(technologies);
@@ -27713,7 +27890,7 @@ var TechnologyService = class extends BaseService {
27713
27890
  async assignProducts(technologyId, productIds) {
27714
27891
  const batch = writeBatch8(this.db);
27715
27892
  for (const productId of productIds) {
27716
- const productRef = doc50(this.db, PRODUCTS_COLLECTION, productId);
27893
+ const productRef = doc51(this.db, PRODUCTS_COLLECTION, productId);
27717
27894
  batch.update(productRef, {
27718
27895
  assignedTechnologyIds: arrayUnion9(technologyId),
27719
27896
  updatedAt: /* @__PURE__ */ new Date()
@@ -27728,7 +27905,7 @@ var TechnologyService = class extends BaseService {
27728
27905
  async unassignProducts(technologyId, productIds) {
27729
27906
  const batch = writeBatch8(this.db);
27730
27907
  for (const productId of productIds) {
27731
- const productRef = doc50(this.db, PRODUCTS_COLLECTION, productId);
27908
+ const productRef = doc51(this.db, PRODUCTS_COLLECTION, productId);
27732
27909
  batch.update(productRef, {
27733
27910
  assignedTechnologyIds: arrayRemove8(technologyId),
27734
27911
  updatedAt: /* @__PURE__ */ new Date()
@@ -27749,9 +27926,9 @@ var TechnologyService = class extends BaseService {
27749
27926
  );
27750
27927
  const snapshot = await getDocs40(q);
27751
27928
  return snapshot.docs.map(
27752
- (doc53) => ({
27753
- id: doc53.id,
27754
- ...doc53.data()
27929
+ (doc54) => ({
27930
+ id: doc54.id,
27931
+ ...doc54.data()
27755
27932
  })
27756
27933
  );
27757
27934
  }
@@ -27766,9 +27943,9 @@ var TechnologyService = class extends BaseService {
27766
27943
  );
27767
27944
  const snapshot = await getDocs40(q);
27768
27945
  const allProducts = snapshot.docs.map(
27769
- (doc53) => ({
27770
- id: doc53.id,
27771
- ...doc53.data()
27946
+ (doc54) => ({
27947
+ id: doc54.id,
27948
+ ...doc54.data()
27772
27949
  })
27773
27950
  );
27774
27951
  return allProducts.filter(
@@ -27887,8 +28064,8 @@ var TechnologyService = class extends BaseService {
27887
28064
  const productsRef = collection40(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
27888
28065
  const q = query40(productsRef, where40("isActive", "==", true));
27889
28066
  const snapshot = await getDocs40(q);
27890
- return snapshot.docs.map((doc53) => {
27891
- const product = doc53.data();
28067
+ return snapshot.docs.map((doc54) => {
28068
+ const product = doc54.data();
27892
28069
  return product.name || "";
27893
28070
  }).filter((name) => name);
27894
28071
  } catch (error) {
@@ -27931,8 +28108,8 @@ import {
27931
28108
  addDoc as addDoc8,
27932
28109
  collection as collection41,
27933
28110
  collectionGroup as collectionGroup3,
27934
- doc as doc51,
27935
- getDoc as getDoc52,
28111
+ doc as doc52,
28112
+ getDoc as getDoc53,
27936
28113
  getDocs as getDocs41,
27937
28114
  query as query41,
27938
28115
  updateDoc as updateDoc46,
@@ -28000,9 +28177,9 @@ var ProductService = class extends BaseService {
28000
28177
  const q = query41(collectionGroup3(this.db, PRODUCTS_COLLECTION), ...constraints);
28001
28178
  const snapshot = await getDocs41(q);
28002
28179
  const products = snapshot.docs.map(
28003
- (doc53) => ({
28004
- id: doc53.id,
28005
- ...doc53.data()
28180
+ (doc54) => ({
28181
+ id: doc54.id,
28182
+ ...doc54.data()
28006
28183
  })
28007
28184
  );
28008
28185
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -28039,8 +28216,8 @@ var ProductService = class extends BaseService {
28039
28216
  };
28040
28217
  const q = query41(collectionGroup3(this.db, PRODUCTS_COLLECTION), where41("isActive", "==", true));
28041
28218
  const snapshot = await getDocs41(q);
28042
- snapshot.docs.forEach((doc53) => {
28043
- const product = doc53.data();
28219
+ snapshot.docs.forEach((doc54) => {
28220
+ const product = doc54.data();
28044
28221
  if (product.categoryId) {
28045
28222
  counts.byCategory[product.categoryId] = (counts.byCategory[product.categoryId] || 0) + 1;
28046
28223
  }
@@ -28064,9 +28241,9 @@ var ProductService = class extends BaseService {
28064
28241
  );
28065
28242
  const snapshot = await getDocs41(q);
28066
28243
  return snapshot.docs.map(
28067
- (doc53) => ({
28068
- id: doc53.id,
28069
- ...doc53.data()
28244
+ (doc54) => ({
28245
+ id: doc54.id,
28246
+ ...doc54.data()
28070
28247
  })
28071
28248
  );
28072
28249
  }
@@ -28086,9 +28263,9 @@ var ProductService = class extends BaseService {
28086
28263
  const snapshot = await getDocs41(q);
28087
28264
  products.push(
28088
28265
  ...snapshot.docs.map(
28089
- (doc53) => ({
28090
- id: doc53.id,
28091
- ...doc53.data()
28266
+ (doc54) => ({
28267
+ id: doc54.id,
28268
+ ...doc54.data()
28092
28269
  })
28093
28270
  )
28094
28271
  );
@@ -28103,7 +28280,7 @@ var ProductService = class extends BaseService {
28103
28280
  ...product,
28104
28281
  updatedAt: /* @__PURE__ */ new Date()
28105
28282
  };
28106
- const docRef = doc51(this.getProductsRef(technologyId), productId);
28283
+ const docRef = doc52(this.getProductsRef(technologyId), productId);
28107
28284
  await updateDoc46(docRef, updateData);
28108
28285
  return this.getById(technologyId, productId);
28109
28286
  }
@@ -28119,8 +28296,8 @@ var ProductService = class extends BaseService {
28119
28296
  * Gets a product by ID
28120
28297
  */
28121
28298
  async getById(technologyId, productId) {
28122
- const docRef = doc51(this.getProductsRef(technologyId), productId);
28123
- const docSnap = await getDoc52(docRef);
28299
+ const docRef = doc52(this.getProductsRef(technologyId), productId);
28300
+ const docSnap = await getDoc53(docRef);
28124
28301
  if (!docSnap.exists()) return null;
28125
28302
  return {
28126
28303
  id: docSnap.id,
@@ -28172,9 +28349,9 @@ var ProductService = class extends BaseService {
28172
28349
  const q = query41(this.getTopLevelProductsRef(), ...constraints);
28173
28350
  const snapshot = await getDocs41(q);
28174
28351
  const products = snapshot.docs.map(
28175
- (doc53) => ({
28176
- id: doc53.id,
28177
- ...doc53.data()
28352
+ (doc54) => ({
28353
+ id: doc54.id,
28354
+ ...doc54.data()
28178
28355
  })
28179
28356
  );
28180
28357
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -28184,8 +28361,8 @@ var ProductService = class extends BaseService {
28184
28361
  * Gets a product by ID from the top-level collection
28185
28362
  */
28186
28363
  async getByIdTopLevel(productId) {
28187
- const docRef = doc51(this.getTopLevelProductsRef(), productId);
28188
- const docSnap = await getDoc52(docRef);
28364
+ const docRef = doc52(this.getTopLevelProductsRef(), productId);
28365
+ const docSnap = await getDoc53(docRef);
28189
28366
  if (!docSnap.exists()) return null;
28190
28367
  return {
28191
28368
  id: docSnap.id,
@@ -28200,7 +28377,7 @@ var ProductService = class extends BaseService {
28200
28377
  ...product,
28201
28378
  updatedAt: /* @__PURE__ */ new Date()
28202
28379
  };
28203
- const docRef = doc51(this.getTopLevelProductsRef(), productId);
28380
+ const docRef = doc52(this.getTopLevelProductsRef(), productId);
28204
28381
  await updateDoc46(docRef, updateData);
28205
28382
  return this.getByIdTopLevel(productId);
28206
28383
  }
@@ -28216,7 +28393,7 @@ var ProductService = class extends BaseService {
28216
28393
  * Assigns a product to a technology
28217
28394
  */
28218
28395
  async assignToTechnology(productId, technologyId) {
28219
- const docRef = doc51(this.getTopLevelProductsRef(), productId);
28396
+ const docRef = doc52(this.getTopLevelProductsRef(), productId);
28220
28397
  await updateDoc46(docRef, {
28221
28398
  assignedTechnologyIds: arrayUnion10(technologyId),
28222
28399
  updatedAt: /* @__PURE__ */ new Date()
@@ -28226,7 +28403,7 @@ var ProductService = class extends BaseService {
28226
28403
  * Unassigns a product from a technology
28227
28404
  */
28228
28405
  async unassignFromTechnology(productId, technologyId) {
28229
- const docRef = doc51(this.getTopLevelProductsRef(), productId);
28406
+ const docRef = doc52(this.getTopLevelProductsRef(), productId);
28230
28407
  await updateDoc46(docRef, {
28231
28408
  assignedTechnologyIds: arrayRemove9(technologyId),
28232
28409
  updatedAt: /* @__PURE__ */ new Date()
@@ -28244,9 +28421,9 @@ var ProductService = class extends BaseService {
28244
28421
  );
28245
28422
  const snapshot = await getDocs41(q);
28246
28423
  return snapshot.docs.map(
28247
- (doc53) => ({
28248
- id: doc53.id,
28249
- ...doc53.data()
28424
+ (doc54) => ({
28425
+ id: doc54.id,
28426
+ ...doc54.data()
28250
28427
  })
28251
28428
  );
28252
28429
  }
@@ -28261,9 +28438,9 @@ var ProductService = class extends BaseService {
28261
28438
  );
28262
28439
  const snapshot = await getDocs41(q);
28263
28440
  const allProducts = snapshot.docs.map(
28264
- (doc53) => ({
28265
- id: doc53.id,
28266
- ...doc53.data()
28441
+ (doc54) => ({
28442
+ id: doc54.id,
28443
+ ...doc54.data()
28267
28444
  })
28268
28445
  );
28269
28446
  return allProducts.filter(
@@ -28285,9 +28462,9 @@ var ProductService = class extends BaseService {
28285
28462
  );
28286
28463
  const snapshot = await getDocs41(q);
28287
28464
  return snapshot.docs.map(
28288
- (doc53) => ({
28289
- id: doc53.id,
28290
- ...doc53.data()
28465
+ (doc54) => ({
28466
+ id: doc54.id,
28467
+ ...doc54.data()
28291
28468
  })
28292
28469
  );
28293
28470
  }
@@ -28370,8 +28547,8 @@ var ProductService = class extends BaseService {
28370
28547
  import {
28371
28548
  arrayRemove as arrayRemove10,
28372
28549
  arrayUnion as arrayUnion11,
28373
- doc as doc52,
28374
- getDoc as getDoc53,
28550
+ doc as doc53,
28551
+ getDoc as getDoc54,
28375
28552
  setDoc as setDoc35,
28376
28553
  updateDoc as updateDoc47
28377
28554
  } from "firebase/firestore";
@@ -28385,7 +28562,7 @@ var ConstantsService = class extends BaseService {
28385
28562
  * @type {DocumentReference}
28386
28563
  */
28387
28564
  get treatmentBenefitsDocRef() {
28388
- return doc52(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
28565
+ return doc53(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
28389
28566
  }
28390
28567
  /**
28391
28568
  * @description Gets the reference to the document holding contraindications.
@@ -28393,7 +28570,7 @@ var ConstantsService = class extends BaseService {
28393
28570
  * @type {DocumentReference}
28394
28571
  */
28395
28572
  get contraindicationsDocRef() {
28396
- return doc52(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
28573
+ return doc53(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
28397
28574
  }
28398
28575
  // =================================================================
28399
28576
  // Treatment Benefits
@@ -28403,7 +28580,7 @@ var ConstantsService = class extends BaseService {
28403
28580
  * @returns {Promise<TreatmentBenefitDynamic[]>} An array of all treatment benefits.
28404
28581
  */
28405
28582
  async getAllBenefitsForFilter() {
28406
- const docSnap = await getDoc53(this.treatmentBenefitsDocRef);
28583
+ const docSnap = await getDoc54(this.treatmentBenefitsDocRef);
28407
28584
  if (!docSnap.exists()) {
28408
28585
  return [];
28409
28586
  }
@@ -28432,7 +28609,7 @@ var ConstantsService = class extends BaseService {
28432
28609
  id: this.generateId(),
28433
28610
  ...benefit
28434
28611
  };
28435
- const docSnap = await getDoc53(this.treatmentBenefitsDocRef);
28612
+ const docSnap = await getDoc54(this.treatmentBenefitsDocRef);
28436
28613
  if (!docSnap.exists()) {
28437
28614
  await setDoc35(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
28438
28615
  } else {
@@ -28502,7 +28679,7 @@ var ConstantsService = class extends BaseService {
28502
28679
  * @returns {Promise<ContraindicationDynamic[]>} An array of all contraindications.
28503
28680
  */
28504
28681
  async getAllContraindicationsForFilter() {
28505
- const docSnap = await getDoc53(this.contraindicationsDocRef);
28682
+ const docSnap = await getDoc54(this.contraindicationsDocRef);
28506
28683
  if (!docSnap.exists()) {
28507
28684
  return [];
28508
28685
  }
@@ -28537,7 +28714,7 @@ var ConstantsService = class extends BaseService {
28537
28714
  id: this.generateId(),
28538
28715
  ...contraindication
28539
28716
  };
28540
- const docSnap = await getDoc53(this.contraindicationsDocRef);
28717
+ const docSnap = await getDoc54(this.contraindicationsDocRef);
28541
28718
  if (!docSnap.exists()) {
28542
28719
  await setDoc35(this.contraindicationsDocRef, {
28543
28720
  contraindications: [newContraindication]
@@ -28757,6 +28934,7 @@ export {
28757
28934
  Currency,
28758
28935
  DASHBOARD_ANALYTICS_SUBCOLLECTION,
28759
28936
  DEFAULT_MEDICAL_INFO,
28937
+ DEFAULT_PLAN_CONFIG,
28760
28938
  DEFAULT_ROLE_PERMISSIONS,
28761
28939
  DOCTOR_FORMS_SUBCOLLECTION,
28762
28940
  DOCUMENTATION_TEMPLATES_COLLECTION,
@@ -28792,7 +28970,11 @@ export {
28792
28970
  PATIENT_MEDICAL_INFO_COLLECTION,
28793
28971
  PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME,
28794
28972
  PATIENT_SENSITIVE_INFO_COLLECTION,
28973
+ PERMISSION_CATEGORIES,
28795
28974
  PERMISSION_KEYS,
28975
+ PERMISSION_LABELS,
28976
+ PLAN_CONFIG_HISTORY_PATH,
28977
+ PLAN_CONFIG_PATH,
28796
28978
  PRACTITIONERS_COLLECTION,
28797
28979
  PRACTITIONER_ANALYTICS_SUBCOLLECTION,
28798
28980
  PRACTITIONER_INVITES_COLLECTION,
@@ -28830,6 +29012,7 @@ export {
28830
29012
  SKIN_QUALITY_ASSESSMENT_COLLECTION,
28831
29013
  SYNCED_CALENDARS_COLLECTION,
28832
29014
  SearchLocationEnum,
29015
+ StaffInviteStatus,
28833
29016
  SubcategoryService,
28834
29017
  SubscriptionModel,
28835
29018
  SubscriptionStatus,