@blackcode_sa/metaestetics-api 1.15.16 → 1.15.17-staging.0

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.
Files changed (326) hide show
  1. package/dist/admin/index.d.mts +377 -222
  2. package/dist/admin/index.d.ts +377 -222
  3. package/dist/admin/index.js +625 -206
  4. package/dist/admin/index.mjs +624 -206
  5. package/dist/backoffice/index.d.mts +24 -0
  6. package/dist/backoffice/index.d.ts +24 -0
  7. package/dist/index.d.mts +292 -4
  8. package/dist/index.d.ts +292 -4
  9. package/dist/index.js +1142 -630
  10. package/dist/index.mjs +1137 -617
  11. package/package.json +2 -1
  12. package/src/__mocks__/firstore.ts +10 -10
  13. package/src/admin/aggregation/README.md +79 -79
  14. package/src/admin/aggregation/appointment/README.md +151 -129
  15. package/src/admin/aggregation/appointment/appointment.aggregation.service.ts +2137 -2091
  16. package/src/admin/aggregation/appointment/index.ts +1 -1
  17. package/src/admin/aggregation/clinic/README.md +52 -52
  18. package/src/admin/aggregation/clinic/clinic.aggregation.service.ts +966 -966
  19. package/src/admin/aggregation/clinic/index.ts +1 -1
  20. package/src/admin/aggregation/forms/README.md +13 -13
  21. package/src/admin/aggregation/forms/filled-forms.aggregation.service.ts +322 -322
  22. package/src/admin/aggregation/forms/index.ts +1 -1
  23. package/src/admin/aggregation/index.ts +8 -8
  24. package/src/admin/aggregation/patient/README.md +27 -27
  25. package/src/admin/aggregation/patient/index.ts +1 -1
  26. package/src/admin/aggregation/patient/patient.aggregation.service.ts +141 -141
  27. package/src/admin/aggregation/practitioner/README.md +42 -42
  28. package/src/admin/aggregation/practitioner/index.ts +1 -1
  29. package/src/admin/aggregation/practitioner/practitioner.aggregation.service.ts +433 -433
  30. package/src/admin/aggregation/practitioner-invite/index.ts +1 -1
  31. package/src/admin/aggregation/practitioner-invite/practitioner-invite.aggregation.service.ts +961 -961
  32. package/src/admin/aggregation/procedure/README.md +43 -43
  33. package/src/admin/aggregation/procedure/index.ts +1 -1
  34. package/src/admin/aggregation/procedure/procedure.aggregation.service.ts +702 -702
  35. package/src/admin/aggregation/reviews/index.ts +1 -1
  36. package/src/admin/aggregation/reviews/reviews.aggregation.service.ts +689 -689
  37. package/src/admin/analytics/analytics.admin.service.ts +278 -278
  38. package/src/admin/analytics/index.ts +2 -2
  39. package/src/admin/booking/README.md +184 -125
  40. package/src/admin/booking/booking.admin.ts +1330 -1073
  41. package/src/admin/booking/booking.calculator.ts +850 -712
  42. package/src/admin/booking/booking.types.ts +76 -59
  43. package/src/admin/booking/index.ts +3 -3
  44. package/src/admin/booking/timezones-problem.md +185 -185
  45. package/src/admin/calendar/README.md +62 -7
  46. package/src/admin/calendar/calendar.admin.service.ts +345 -345
  47. package/src/admin/calendar/index.ts +2 -1
  48. package/src/admin/calendar/resource-calendar.admin.ts +198 -0
  49. package/src/admin/documentation-templates/document-manager.admin.ts +260 -260
  50. package/src/admin/documentation-templates/index.ts +1 -1
  51. package/src/admin/free-consultation/free-consultation-utils.admin.ts +148 -148
  52. package/src/admin/free-consultation/index.ts +1 -1
  53. package/src/admin/index.ts +83 -83
  54. package/src/admin/logger/index.ts +78 -78
  55. package/src/admin/mailing/README.md +139 -139
  56. package/src/admin/mailing/appointment/appointment.mailing.service.ts +1253 -1253
  57. package/src/admin/mailing/appointment/index.ts +1 -1
  58. package/src/admin/mailing/appointment/templates/patient/appointment-confirmed.html +40 -40
  59. package/src/admin/mailing/base.mailing.service.ts +208 -208
  60. package/src/admin/mailing/clinicWelcome/clinicWelcome.mailing.ts +292 -292
  61. package/src/admin/mailing/clinicWelcome/index.ts +1 -1
  62. package/src/admin/mailing/clinicWelcome/templates/welcome.template.ts +225 -225
  63. package/src/admin/mailing/index.ts +5 -5
  64. package/src/admin/mailing/patientInvite/index.ts +2 -2
  65. package/src/admin/mailing/patientInvite/patientInvite.mailing.ts +415 -415
  66. package/src/admin/mailing/patientInvite/templates/invitation.template.ts +105 -105
  67. package/src/admin/mailing/practitionerInvite/existing-practitioner-invite.mailing.ts +611 -611
  68. package/src/admin/mailing/practitionerInvite/index.ts +2 -2
  69. package/src/admin/mailing/practitionerInvite/practitionerInvite.mailing.ts +395 -395
  70. package/src/admin/mailing/practitionerInvite/templates/existing-practitioner-invitation.template.ts +155 -155
  71. package/src/admin/mailing/practitionerInvite/templates/invitation.template.ts +101 -101
  72. package/src/admin/mailing/practitionerInvite/templates/invite-accepted-notification.template.ts +228 -228
  73. package/src/admin/mailing/practitionerInvite/templates/invite-rejected-notification.template.ts +242 -242
  74. package/src/admin/notifications/index.ts +1 -1
  75. package/src/admin/notifications/notifications.admin.ts +818 -818
  76. package/src/admin/requirements/README.md +128 -128
  77. package/src/admin/requirements/index.ts +1 -1
  78. package/src/admin/requirements/patient-requirements.admin.service.ts +475 -475
  79. package/src/admin/users/index.ts +1 -1
  80. package/src/admin/users/user-profile.admin.ts +405 -405
  81. package/src/backoffice/constants/certification.constants.ts +13 -13
  82. package/src/backoffice/constants/index.ts +1 -1
  83. package/src/backoffice/errors/backoffice.errors.ts +181 -181
  84. package/src/backoffice/errors/index.ts +1 -1
  85. package/src/backoffice/expo-safe/README.md +26 -26
  86. package/src/backoffice/expo-safe/index.ts +41 -41
  87. package/src/backoffice/index.ts +5 -5
  88. package/src/backoffice/services/FIXES_README.md +102 -102
  89. package/src/backoffice/services/README.md +57 -57
  90. package/src/backoffice/services/analytics.service.proposal.md +863 -863
  91. package/src/backoffice/services/analytics.service.summary.md +143 -143
  92. package/src/backoffice/services/brand.service.ts +260 -260
  93. package/src/backoffice/services/category.service.ts +384 -384
  94. package/src/backoffice/services/constants.service.ts +385 -385
  95. package/src/backoffice/services/documentation-template.service.ts +202 -202
  96. package/src/backoffice/services/index.ts +10 -10
  97. package/src/backoffice/services/migrate-products.ts +116 -116
  98. package/src/backoffice/services/product.service.ts +557 -557
  99. package/src/backoffice/services/requirement.service.ts +235 -235
  100. package/src/backoffice/services/subcategory.service.ts +461 -461
  101. package/src/backoffice/services/technology.service.ts +1153 -1153
  102. package/src/backoffice/types/README.md +12 -12
  103. package/src/backoffice/types/admin-constants.types.ts +69 -69
  104. package/src/backoffice/types/brand.types.ts +29 -29
  105. package/src/backoffice/types/category.types.ts +67 -67
  106. package/src/backoffice/types/documentation-templates.types.ts +28 -28
  107. package/src/backoffice/types/index.ts +10 -10
  108. package/src/backoffice/types/procedure-product.types.ts +38 -38
  109. package/src/backoffice/types/product.types.ts +239 -239
  110. package/src/backoffice/types/requirement.types.ts +63 -63
  111. package/src/backoffice/types/static/README.md +18 -18
  112. package/src/backoffice/types/static/blocking-condition.types.ts +21 -21
  113. package/src/backoffice/types/static/certification.types.ts +37 -37
  114. package/src/backoffice/types/static/contraindication.types.ts +19 -19
  115. package/src/backoffice/types/static/index.ts +6 -6
  116. package/src/backoffice/types/static/pricing.types.ts +16 -16
  117. package/src/backoffice/types/static/procedure-family.types.ts +14 -14
  118. package/src/backoffice/types/static/treatment-benefit.types.ts +22 -22
  119. package/src/backoffice/types/subcategory.types.ts +34 -34
  120. package/src/backoffice/types/technology.types.ts +168 -168
  121. package/src/backoffice/validations/index.ts +1 -1
  122. package/src/backoffice/validations/schemas.ts +164 -164
  123. package/src/config/__mocks__/firebase.ts +99 -99
  124. package/src/config/firebase.ts +78 -78
  125. package/src/config/index.ts +17 -17
  126. package/src/config/tiers.config.ts +255 -229
  127. package/src/errors/auth.error.ts +6 -6
  128. package/src/errors/auth.errors.ts +211 -211
  129. package/src/errors/clinic.errors.ts +32 -32
  130. package/src/errors/firebase.errors.ts +47 -47
  131. package/src/errors/user.errors.ts +99 -99
  132. package/src/index.backup.ts +407 -407
  133. package/src/index.ts +6 -6
  134. package/src/locales/en.ts +31 -31
  135. package/src/recommender/admin/index.ts +1 -1
  136. package/src/recommender/admin/services/recommender.service.admin.ts +5 -5
  137. package/src/recommender/front/index.ts +1 -1
  138. package/src/recommender/front/services/onboarding.service.ts +5 -5
  139. package/src/recommender/front/services/recommender.service.ts +3 -3
  140. package/src/recommender/index.ts +1 -1
  141. package/src/services/PATIENTAUTH.MD +197 -197
  142. package/src/services/README.md +106 -106
  143. package/src/services/__tests__/auth/auth.mock.test.ts +17 -17
  144. package/src/services/__tests__/auth/auth.setup.ts +298 -298
  145. package/src/services/__tests__/auth.service.test.ts +310 -310
  146. package/src/services/__tests__/base.service.test.ts +36 -36
  147. package/src/services/__tests__/user.service.test.ts +530 -530
  148. package/src/services/analytics/ARCHITECTURE.md +199 -199
  149. package/src/services/analytics/CLOUD_FUNCTIONS.md +225 -225
  150. package/src/services/analytics/GROUPED_ANALYTICS.md +501 -501
  151. package/src/services/analytics/QUICK_START.md +393 -393
  152. package/src/services/analytics/README.md +304 -304
  153. package/src/services/analytics/SUMMARY.md +141 -141
  154. package/src/services/analytics/TRENDS.md +380 -380
  155. package/src/services/analytics/USAGE_GUIDE.md +518 -518
  156. package/src/services/analytics/analytics-cloud.service.ts +222 -222
  157. package/src/services/analytics/analytics.service.ts +2148 -2148
  158. package/src/services/analytics/index.ts +4 -4
  159. package/src/services/analytics/review-analytics.service.ts +941 -941
  160. package/src/services/analytics/utils/appointment-filtering.utils.ts +138 -138
  161. package/src/services/analytics/utils/cost-calculation.utils.ts +182 -182
  162. package/src/services/analytics/utils/grouping.utils.ts +434 -434
  163. package/src/services/analytics/utils/stored-analytics.utils.ts +347 -347
  164. package/src/services/analytics/utils/time-calculation.utils.ts +186 -186
  165. package/src/services/analytics/utils/trend-calculation.utils.ts +200 -200
  166. package/src/services/appointment/README.md +17 -17
  167. package/src/services/appointment/appointment.service.ts +2943 -2941
  168. package/src/services/appointment/index.ts +1 -1
  169. package/src/services/appointment/utils/appointment.utils.ts +620 -620
  170. package/src/services/appointment/utils/extended-procedure.utils.ts +354 -354
  171. package/src/services/appointment/utils/form-initialization.utils.ts +516 -516
  172. package/src/services/appointment/utils/recommended-procedure.utils.ts +195 -195
  173. package/src/services/appointment/utils/zone-management.utils.ts +468 -468
  174. package/src/services/appointment/utils/zone-photo.utils.ts +302 -302
  175. package/src/services/auth/auth.service.ts +1435 -1435
  176. package/src/services/auth/auth.v2.service.ts +961 -961
  177. package/src/services/auth/index.ts +7 -7
  178. package/src/services/auth/utils/error.utils.ts +90 -90
  179. package/src/services/auth/utils/firebase.utils.ts +49 -49
  180. package/src/services/auth/utils/index.ts +21 -21
  181. package/src/services/auth/utils/practitioner.utils.ts +125 -125
  182. package/src/services/base.service.ts +41 -41
  183. package/src/services/calendar/calendar.service.ts +1077 -1077
  184. package/src/services/calendar/calendar.v2.service.ts +1693 -1693
  185. package/src/services/calendar/calendar.v3.service.ts +313 -313
  186. package/src/services/calendar/externalCalendar.service.ts +178 -178
  187. package/src/services/calendar/index.ts +5 -5
  188. package/src/services/calendar/synced-calendars.service.ts +743 -743
  189. package/src/services/calendar/utils/appointment.utils.ts +265 -265
  190. package/src/services/calendar/utils/calendar-event.utils.ts +676 -676
  191. package/src/services/calendar/utils/clinic.utils.ts +237 -237
  192. package/src/services/calendar/utils/docs.utils.ts +157 -157
  193. package/src/services/calendar/utils/google-calendar.utils.ts +697 -697
  194. package/src/services/calendar/utils/index.ts +8 -8
  195. package/src/services/calendar/utils/patient.utils.ts +198 -198
  196. package/src/services/calendar/utils/practitioner.utils.ts +221 -221
  197. package/src/services/calendar/utils/synced-calendar.utils.ts +472 -472
  198. package/src/services/clinic/README.md +204 -204
  199. package/src/services/clinic/__tests__/clinic-admin.service.test.ts +265 -265
  200. package/src/services/clinic/__tests__/clinic-group.service.test.ts +222 -222
  201. package/src/services/clinic/__tests__/clinic.service.test.ts +302 -302
  202. package/src/services/clinic/billing-transactions.service.ts +217 -217
  203. package/src/services/clinic/clinic-admin.service.ts +202 -202
  204. package/src/services/clinic/clinic-group.service.ts +310 -310
  205. package/src/services/clinic/clinic.service.ts +720 -720
  206. package/src/services/clinic/index.ts +5 -5
  207. package/src/services/clinic/practitioner-invite.service.ts +519 -519
  208. package/src/services/clinic/utils/admin.utils.ts +551 -551
  209. package/src/services/clinic/utils/clinic-group.utils.ts +646 -646
  210. package/src/services/clinic/utils/clinic.utils.ts +1023 -1023
  211. package/src/services/clinic/utils/filter.utils.d.ts +23 -23
  212. package/src/services/clinic/utils/filter.utils.ts +462 -462
  213. package/src/services/clinic/utils/index.ts +10 -10
  214. package/src/services/clinic/utils/photos.utils.ts +188 -188
  215. package/src/services/clinic/utils/search.utils.ts +83 -83
  216. package/src/services/clinic/utils/tag.utils.ts +124 -124
  217. package/src/services/documentation-templates/documentation-template.service.ts +537 -537
  218. package/src/services/documentation-templates/filled-document.service.ts +597 -597
  219. package/src/services/documentation-templates/index.ts +2 -2
  220. package/src/services/index.ts +16 -15
  221. package/src/services/media/index.ts +1 -1
  222. package/src/services/media/media.service.ts +418 -418
  223. package/src/services/notifications/__tests__/notification.service.test.ts +242 -242
  224. package/src/services/notifications/index.ts +1 -1
  225. package/src/services/notifications/notification.service.ts +215 -215
  226. package/src/services/patient/README.md +48 -48
  227. package/src/services/patient/To-Do.md +43 -43
  228. package/src/services/patient/__tests__/patient.service.test.ts +286 -286
  229. package/src/services/patient/index.ts +2 -2
  230. package/src/services/patient/patient.service.ts +1021 -1021
  231. package/src/services/patient/patientRequirements.service.ts +309 -309
  232. package/src/services/patient/utils/aesthetic-analysis.utils.ts +176 -176
  233. package/src/services/patient/utils/body-assessment.utils.ts +159 -159
  234. package/src/services/patient/utils/clinic.utils.ts +159 -159
  235. package/src/services/patient/utils/docs.utils.ts +142 -142
  236. package/src/services/patient/utils/hair-scalp-assessment.utils.ts +158 -158
  237. package/src/services/patient/utils/index.ts +9 -9
  238. package/src/services/patient/utils/location.utils.ts +126 -126
  239. package/src/services/patient/utils/medical-stuff.utils.ts +143 -143
  240. package/src/services/patient/utils/medical.utils.ts +458 -458
  241. package/src/services/patient/utils/practitioner.utils.ts +260 -260
  242. package/src/services/patient/utils/pre-surgical-assessment.utils.ts +161 -161
  243. package/src/services/patient/utils/profile.utils.ts +510 -510
  244. package/src/services/patient/utils/sensitive.utils.ts +260 -260
  245. package/src/services/patient/utils/skin-quality-assessment.utils.ts +160 -160
  246. package/src/services/patient/utils/token.utils.ts +211 -211
  247. package/src/services/practitioner/README.md +145 -145
  248. package/src/services/practitioner/index.ts +1 -1
  249. package/src/services/practitioner/practitioner.service.ts +2355 -2354
  250. package/src/services/procedure/README.md +163 -163
  251. package/src/services/procedure/index.ts +1 -1
  252. package/src/services/procedure/procedure.service.ts +2521 -2521
  253. package/src/services/resource/README.md +119 -0
  254. package/src/services/resource/index.ts +1 -0
  255. package/src/services/resource/resource.service.ts +555 -0
  256. package/src/services/reviews/index.ts +1 -1
  257. package/src/services/reviews/reviews.service.ts +745 -745
  258. package/src/services/tier-enforcement.ts +240 -240
  259. package/src/services/user/index.ts +1 -1
  260. package/src/services/user/user.service.ts +533 -533
  261. package/src/services/user/user.v2.service.ts +467 -467
  262. package/src/types/analytics/analytics.types.ts +597 -597
  263. package/src/types/analytics/grouped-analytics.types.ts +173 -173
  264. package/src/types/analytics/index.ts +4 -4
  265. package/src/types/analytics/stored-analytics.types.ts +137 -137
  266. package/src/types/appointment/index.ts +524 -517
  267. package/src/types/calendar/index.ts +261 -260
  268. package/src/types/calendar/synced-calendar.types.ts +66 -66
  269. package/src/types/clinic/index.ts +530 -529
  270. package/src/types/clinic/practitioner-invite.types.ts +91 -91
  271. package/src/types/clinic/preferences.types.ts +159 -159
  272. package/src/types/clinic/rbac.types.ts +64 -63
  273. package/src/types/clinic/to-do +3 -3
  274. package/src/types/documentation-templates/index.ts +308 -308
  275. package/src/types/index.ts +50 -47
  276. package/src/types/notifications/README.md +77 -77
  277. package/src/types/notifications/index.ts +300 -300
  278. package/src/types/patient/aesthetic-analysis.types.ts +66 -66
  279. package/src/types/patient/allergies.ts +58 -58
  280. package/src/types/patient/body-assessment.types.ts +93 -93
  281. package/src/types/patient/hair-scalp-assessment.types.ts +98 -98
  282. package/src/types/patient/index.ts +279 -279
  283. package/src/types/patient/medical-info.types.ts +152 -152
  284. package/src/types/patient/patient-requirements.ts +92 -92
  285. package/src/types/patient/pre-surgical-assessment.types.ts +95 -95
  286. package/src/types/patient/skin-quality-assessment.types.ts +105 -105
  287. package/src/types/patient/token.types.ts +61 -61
  288. package/src/types/practitioner/index.ts +208 -208
  289. package/src/types/procedure/index.ts +189 -183
  290. package/src/types/profile/index.ts +39 -39
  291. package/src/types/resource/README.md +153 -0
  292. package/src/types/resource/index.ts +199 -0
  293. package/src/types/reviews/index.ts +132 -132
  294. package/src/types/tz-lookup.d.ts +4 -4
  295. package/src/types/user/index.ts +60 -60
  296. package/src/utils/TIMESTAMPS.md +176 -176
  297. package/src/utils/TimestampUtils.ts +241 -241
  298. package/src/utils/index.ts +1 -1
  299. package/src/validations/README.md +94 -0
  300. package/src/validations/appointment.schema.ts +589 -589
  301. package/src/validations/calendar.schema.ts +225 -225
  302. package/src/validations/clinic.schema.ts +494 -494
  303. package/src/validations/common.schema.ts +25 -25
  304. package/src/validations/documentation-templates/index.ts +1 -1
  305. package/src/validations/documentation-templates/template.schema.ts +220 -220
  306. package/src/validations/documentation-templates.schema.ts +10 -10
  307. package/src/validations/index.ts +21 -20
  308. package/src/validations/media.schema.ts +10 -10
  309. package/src/validations/notification.schema.ts +90 -90
  310. package/src/validations/patient/aesthetic-analysis.schema.ts +55 -55
  311. package/src/validations/patient/body-assessment.schema.ts +82 -82
  312. package/src/validations/patient/hair-scalp-assessment.schema.ts +70 -70
  313. package/src/validations/patient/medical-info.schema.ts +177 -177
  314. package/src/validations/patient/patient-requirements.schema.ts +84 -84
  315. package/src/validations/patient/pre-surgical-assessment.schema.ts +78 -78
  316. package/src/validations/patient/skin-quality-assessment.schema.ts +70 -70
  317. package/src/validations/patient/token.schema.ts +29 -29
  318. package/src/validations/patient.schema.ts +217 -217
  319. package/src/validations/practitioner.schema.ts +224 -224
  320. package/src/validations/procedure-product.schema.ts +41 -41
  321. package/src/validations/procedure.schema.ts +136 -124
  322. package/src/validations/profile-info.schema.ts +41 -41
  323. package/src/validations/resource.schema.ts +57 -0
  324. package/src/validations/reviews.schema.ts +195 -195
  325. package/src/validations/schemas.ts +109 -109
  326. package/src/validations/shared.schema.ts +78 -78
package/dist/index.js CHANGED
@@ -132,9 +132,15 @@ __export(index_exports, {
132
132
  ProcedureService: () => ProcedureService,
133
133
  ProductService: () => ProductService,
134
134
  REGISTER_TOKENS_COLLECTION: () => REGISTER_TOKENS_COLLECTION,
135
+ RESOURCES_COLLECTION: () => RESOURCES_COLLECTION,
136
+ RESOURCE_CALENDAR_SUBCOLLECTION: () => RESOURCE_CALENDAR_SUBCOLLECTION,
137
+ RESOURCE_INSTANCES_SUBCOLLECTION: () => RESOURCE_INSTANCES_SUBCOLLECTION,
135
138
  REVENUE_ANALYTICS_SUBCOLLECTION: () => REVENUE_ANALYTICS_SUBCOLLECTION,
136
139
  REVIEWS_COLLECTION: () => REVIEWS_COLLECTION,
137
140
  RequirementType: () => RequirementType,
141
+ ResourceCategory: () => ResourceCategory,
142
+ ResourceService: () => ResourceService,
143
+ ResourceStatus: () => ResourceStatus,
138
144
  ReviewAnalyticsService: () => ReviewAnalyticsService,
139
145
  ReviewService: () => ReviewService,
140
146
  SKIN_QUALITY_ASSESSMENT_COLLECTION: () => SKIN_QUALITY_ASSESSMENT_COLLECTION,
@@ -681,6 +687,7 @@ var BillingTransactionType = /* @__PURE__ */ ((BillingTransactionType2) => {
681
687
  BillingTransactionType2["SUBSCRIPTION_CANCELED"] = "subscription_canceled";
682
688
  BillingTransactionType2["SUBSCRIPTION_REACTIVATED"] = "subscription_reactivated";
683
689
  BillingTransactionType2["SUBSCRIPTION_DELETED"] = "subscription_deleted";
690
+ BillingTransactionType2["ADDON_PURCHASED"] = "addon_purchased";
684
691
  return BillingTransactionType2;
685
692
  })(BillingTransactionType || {});
686
693
 
@@ -1278,12 +1285,12 @@ var ReviewAnalyticsService = class extends BaseService {
1278
1285
  q = (0, import_firestore2.query)(q, (0, import_firestore2.where)("createdAt", ">=", startTimestamp), (0, import_firestore2.where)("createdAt", "<=", endTimestamp));
1279
1286
  }
1280
1287
  const snapshot = await (0, import_firestore2.getDocs)(q);
1281
- const reviews = snapshot.docs.map((doc52) => {
1288
+ const reviews = snapshot.docs.map((doc53) => {
1282
1289
  var _a, _b;
1283
- const data = doc52.data();
1290
+ const data = doc53.data();
1284
1291
  return {
1285
1292
  ...data,
1286
- id: doc52.id,
1293
+ id: doc53.id,
1287
1294
  createdAt: ((_a = data.createdAt) == null ? void 0 : _a.toDate) ? data.createdAt.toDate() : new Date(data.createdAt),
1288
1295
  updatedAt: ((_b = data.updatedAt) == null ? void 0 : _b.toDate) ? data.updatedAt.toDate() : new Date(data.updatedAt)
1289
1296
  };
@@ -1300,10 +1307,10 @@ var ReviewAnalyticsService = class extends BaseService {
1300
1307
  (0, import_firestore2.where)("id", "in", batch)
1301
1308
  );
1302
1309
  const appointmentSnapshot = await (0, import_firestore2.getDocs)(appointmentsQuery);
1303
- appointmentSnapshot.docs.forEach((doc52) => {
1304
- const appointment = doc52.data();
1310
+ appointmentSnapshot.docs.forEach((doc53) => {
1311
+ const appointment = doc53.data();
1305
1312
  if (appointment.clinicBranchId === filters.clinicBranchId) {
1306
- validAppointmentIds.add(doc52.id);
1313
+ validAppointmentIds.add(doc53.id);
1307
1314
  }
1308
1315
  });
1309
1316
  }
@@ -4490,7 +4497,7 @@ var MediaService = class extends BaseService {
4490
4497
  try {
4491
4498
  const querySnapshot = await (0, import_firestore5.getDocs)(finalQuery);
4492
4499
  const mediaList = querySnapshot.docs.map(
4493
- (doc52) => doc52.data()
4500
+ (doc53) => doc53.data()
4494
4501
  );
4495
4502
  console.log(`[MediaService] Found ${mediaList.length} media items.`);
4496
4503
  return mediaList;
@@ -4541,6 +4548,7 @@ var CalendarEventType = /* @__PURE__ */ ((CalendarEventType3) => {
4541
4548
  CalendarEventType3["BLOCKING"] = "blocking";
4542
4549
  CalendarEventType3["BREAK"] = "break";
4543
4550
  CalendarEventType3["FREE_DAY"] = "free_day";
4551
+ CalendarEventType3["RESOURCE_BOOKING"] = "resource_booking";
4544
4552
  CalendarEventType3["OTHER"] = "other";
4545
4553
  return CalendarEventType3;
4546
4554
  })(CalendarEventType || {});
@@ -4757,6 +4765,25 @@ var PatientTokenStatus = /* @__PURE__ */ ((PatientTokenStatus2) => {
4757
4765
  return PatientTokenStatus2;
4758
4766
  })(PatientTokenStatus || {});
4759
4767
 
4768
+ // src/types/resource/index.ts
4769
+ var RESOURCES_COLLECTION = "resources";
4770
+ var RESOURCE_INSTANCES_SUBCOLLECTION = "instances";
4771
+ var RESOURCE_CALENDAR_SUBCOLLECTION = "calendar";
4772
+ var ResourceCategory = /* @__PURE__ */ ((ResourceCategory2) => {
4773
+ ResourceCategory2["MEDICAL_DEVICE"] = "medical_device";
4774
+ ResourceCategory2["ROOM"] = "room";
4775
+ ResourceCategory2["SURGERY_SUITE"] = "surgery_suite";
4776
+ ResourceCategory2["EQUIPMENT"] = "equipment";
4777
+ ResourceCategory2["OTHER"] = "other";
4778
+ return ResourceCategory2;
4779
+ })(ResourceCategory || {});
4780
+ var ResourceStatus = /* @__PURE__ */ ((ResourceStatus2) => {
4781
+ ResourceStatus2["ACTIVE"] = "active";
4782
+ ResourceStatus2["INACTIVE"] = "inactive";
4783
+ ResourceStatus2["MAINTENANCE"] = "maintenance";
4784
+ return ResourceStatus2;
4785
+ })(ResourceStatus || {});
4786
+
4760
4787
  // src/validations/patient.schema.ts
4761
4788
  var import_zod6 = require("zod");
4762
4789
  var import_firestore7 = require("firebase/firestore");
@@ -5306,8 +5333,8 @@ var getPatientsByPractitionerUtil = async (db, practitionerId, options) => {
5306
5333
  }
5307
5334
  const patientsSnapshot = await (0, import_firestore8.getDocs)(q);
5308
5335
  const patients = [];
5309
- patientsSnapshot.forEach((doc52) => {
5310
- patients.push(doc52.data());
5336
+ patientsSnapshot.forEach((doc53) => {
5337
+ patients.push(doc53.data());
5311
5338
  });
5312
5339
  console.log(
5313
5340
  `[getPatientsByPractitionerUtil] Found ${patients.length} patients for practitioner ID: ${practitionerId}`
@@ -6123,7 +6150,7 @@ async function getClinicAdminsByGroup(db, clinicGroupId) {
6123
6150
  (0, import_firestore10.where)("clinicGroupId", "==", clinicGroupId)
6124
6151
  );
6125
6152
  const querySnapshot = await (0, import_firestore10.getDocs)(q);
6126
- return querySnapshot.docs.map((doc52) => doc52.data());
6153
+ return querySnapshot.docs.map((doc53) => doc53.data());
6127
6154
  }
6128
6155
  async function updateClinicAdmin(db, adminId, data) {
6129
6156
  const admin = await getClinicAdmin(db, adminId);
@@ -6710,7 +6737,7 @@ async function searchAppointmentsUtil(db, params) {
6710
6737
  }
6711
6738
  const q = (0, import_firestore13.query)((0, import_firestore13.collection)(db, APPOINTMENTS_COLLECTION), ...constraints);
6712
6739
  const querySnapshot = await (0, import_firestore13.getDocs)(q);
6713
- const appointments = querySnapshot.docs.map((doc52) => doc52.data());
6740
+ const appointments = querySnapshot.docs.map((doc53) => doc53.data());
6714
6741
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
6715
6742
  return { appointments, lastDoc };
6716
6743
  } catch (error) {
@@ -7750,7 +7777,8 @@ var AppointmentService = class extends BaseService {
7750
7777
  if (!currentUser) {
7751
7778
  throw new Error("User must be authenticated to get available booking slots");
7752
7779
  }
7753
- const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/bookingApi/getAvailableBookingSlots`;
7780
+ const projectId = this.app.options.projectId;
7781
+ const functionUrl = `https://europe-west6-${projectId}.cloudfunctions.net/bookingApi/getAvailableBookingSlots`;
7754
7782
  const idToken = await currentUser.getIdToken();
7755
7783
  console.log(`[APPOINTMENT_SERVICE] Got user token, user ID: ${currentUser.uid}`);
7756
7784
  const requestData = {
@@ -7819,7 +7847,8 @@ var AppointmentService = class extends BaseService {
7819
7847
  throw new Error("User must be authenticated to create an appointment");
7820
7848
  }
7821
7849
  const idToken = await currentUser.getIdToken();
7822
- const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/bookingApi/orchestrateAppointmentCreation`;
7850
+ const projectId = this.app.options.projectId;
7851
+ const functionUrl = `https://europe-west6-${projectId}.cloudfunctions.net/bookingApi/orchestrateAppointmentCreation`;
7823
7852
  const requestData = {
7824
7853
  patientId: data.patientId,
7825
7854
  procedureId: data.procedureId,
@@ -8404,7 +8433,7 @@ var AppointmentService = class extends BaseService {
8404
8433
  }
8405
8434
  const q = (0, import_firestore21.query)((0, import_firestore21.collection)(this.db, APPOINTMENTS_COLLECTION), ...constraints);
8406
8435
  const querySnapshot = await (0, import_firestore21.getDocs)(q);
8407
- const appointments = querySnapshot.docs.map((doc52) => doc52.data());
8436
+ const appointments = querySnapshot.docs.map((doc53) => doc53.data());
8408
8437
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
8409
8438
  console.log(
8410
8439
  `[APPOINTMENT_SERVICE] Found ${appointments.length} upcoming appointments for patient ${patientId}`
@@ -8460,7 +8489,7 @@ var AppointmentService = class extends BaseService {
8460
8489
  }
8461
8490
  const q = (0, import_firestore21.query)((0, import_firestore21.collection)(this.db, APPOINTMENTS_COLLECTION), ...constraints);
8462
8491
  const querySnapshot = await (0, import_firestore21.getDocs)(q);
8463
- const appointments = querySnapshot.docs.map((doc52) => doc52.data());
8492
+ const appointments = querySnapshot.docs.map((doc53) => doc53.data());
8464
8493
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
8465
8494
  console.log(
8466
8495
  `[APPOINTMENT_SERVICE] Found ${appointments.length} past appointments for patient ${patientId}`
@@ -9740,7 +9769,7 @@ var AppointmentService = class extends BaseService {
9740
9769
  );
9741
9770
  const proceduresSnapshot = await (0, import_firestore21.getDocs)(proceduresQuery);
9742
9771
  availableProcedureIds = new Set(
9743
- proceduresSnapshot.docs.map((doc52) => doc52.id)
9772
+ proceduresSnapshot.docs.map((doc53) => doc53.id)
9744
9773
  );
9745
9774
  console.log(
9746
9775
  `[APPOINTMENT_SERVICE] Found ${availableProcedureIds.size} procedures available at clinic ${options.clinicBranchId}`
@@ -9969,8 +9998,8 @@ var getPatientsByClinicUtil = async (db, clinicId, options) => {
9969
9998
  }
9970
9999
  const patientsSnapshot = await (0, import_firestore22.getDocs)(q);
9971
10000
  const patients = [];
9972
- patientsSnapshot.forEach((doc52) => {
9973
- patients.push(doc52.data());
10001
+ patientsSnapshot.forEach((doc53) => {
10002
+ patients.push(doc53.data());
9974
10003
  });
9975
10004
  console.log(
9976
10005
  `[getPatientsByClinicUtil] Found ${patients.length} patients for clinic ID: ${clinicId}`
@@ -10327,9 +10356,9 @@ var updateAllergyUtil = async (db, patientId, data, requesterId, requesterRoles)
10327
10356
  };
10328
10357
  var removeAllergyUtil = async (db, patientId, allergyIndex, requesterId, requesterRoles) => {
10329
10358
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10330
- const doc52 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10331
- if (!doc52.exists()) throw new Error("Medical info not found");
10332
- const medicalInfo = doc52.data();
10359
+ const doc53 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10360
+ if (!doc53.exists()) throw new Error("Medical info not found");
10361
+ const medicalInfo = doc53.data();
10333
10362
  if (allergyIndex >= medicalInfo.allergies.length) {
10334
10363
  throw new Error("Invalid allergy index");
10335
10364
  }
@@ -10356,9 +10385,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
10356
10385
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10357
10386
  const validatedData = updateBlockingConditionSchema.parse(data);
10358
10387
  const { conditionIndex, ...updateData } = validatedData;
10359
- const doc52 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10360
- if (!doc52.exists()) throw new Error("Medical info not found");
10361
- const medicalInfo = doc52.data();
10388
+ const doc53 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10389
+ if (!doc53.exists()) throw new Error("Medical info not found");
10390
+ const medicalInfo = doc53.data();
10362
10391
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
10363
10392
  throw new Error("Invalid blocking condition index");
10364
10393
  }
@@ -10375,9 +10404,9 @@ var updateBlockingConditionUtil = async (db, patientId, data, requesterId, reque
10375
10404
  };
10376
10405
  var removeBlockingConditionUtil = async (db, patientId, conditionIndex, requesterId, requesterRoles) => {
10377
10406
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10378
- const doc52 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10379
- if (!doc52.exists()) throw new Error("Medical info not found");
10380
- const medicalInfo = doc52.data();
10407
+ const doc53 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10408
+ if (!doc53.exists()) throw new Error("Medical info not found");
10409
+ const medicalInfo = doc53.data();
10381
10410
  if (conditionIndex >= medicalInfo.blockingConditions.length) {
10382
10411
  throw new Error("Invalid blocking condition index");
10383
10412
  }
@@ -10404,9 +10433,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
10404
10433
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10405
10434
  const validatedData = updateContraindicationSchema.parse(data);
10406
10435
  const { contraindicationIndex, ...updateData } = validatedData;
10407
- const doc52 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10408
- if (!doc52.exists()) throw new Error("Medical info not found");
10409
- const medicalInfo = doc52.data();
10436
+ const doc53 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10437
+ if (!doc53.exists()) throw new Error("Medical info not found");
10438
+ const medicalInfo = doc53.data();
10410
10439
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
10411
10440
  throw new Error("Invalid contraindication index");
10412
10441
  }
@@ -10423,9 +10452,9 @@ var updateContraindicationUtil = async (db, patientId, data, requesterId, reques
10423
10452
  };
10424
10453
  var removeContraindicationUtil = async (db, patientId, contraindicationIndex, requesterId, requesterRoles) => {
10425
10454
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10426
- const doc52 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10427
- if (!doc52.exists()) throw new Error("Medical info not found");
10428
- const medicalInfo = doc52.data();
10455
+ const doc53 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10456
+ if (!doc53.exists()) throw new Error("Medical info not found");
10457
+ const medicalInfo = doc53.data();
10429
10458
  if (contraindicationIndex >= medicalInfo.contraindications.length) {
10430
10459
  throw new Error("Invalid contraindication index");
10431
10460
  }
@@ -10452,9 +10481,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
10452
10481
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10453
10482
  const validatedData = updateMedicationSchema.parse(data);
10454
10483
  const { medicationIndex, ...updateData } = validatedData;
10455
- const doc52 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10456
- if (!doc52.exists()) throw new Error("Medical info not found");
10457
- const medicalInfo = doc52.data();
10484
+ const doc53 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10485
+ if (!doc53.exists()) throw new Error("Medical info not found");
10486
+ const medicalInfo = doc53.data();
10458
10487
  if (medicationIndex >= medicalInfo.currentMedications.length) {
10459
10488
  throw new Error("Invalid medication index");
10460
10489
  }
@@ -10471,9 +10500,9 @@ var updateMedicationUtil = async (db, patientId, data, requesterId, requesterRol
10471
10500
  };
10472
10501
  var removeMedicationUtil = async (db, patientId, medicationIndex, requesterId, requesterRoles) => {
10473
10502
  await checkMedicalAccessUtil(db, patientId, requesterId, requesterRoles);
10474
- const doc52 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10475
- if (!doc52.exists()) throw new Error("Medical info not found");
10476
- const medicalInfo = doc52.data();
10503
+ const doc53 = await (0, import_firestore25.getDoc)(getMedicalInfoDocRef(db, patientId));
10504
+ if (!doc53.exists()) throw new Error("Medical info not found");
10505
+ const medicalInfo = doc53.data();
10477
10506
  if (medicationIndex >= medicalInfo.currentMedications.length) {
10478
10507
  throw new Error("Invalid medication index");
10479
10508
  }
@@ -10760,7 +10789,7 @@ var searchPatientsUtil = async (db, params, requester) => {
10760
10789
  const finalQuery = (0, import_firestore26.query)(patientsCollectionRef, ...constraints);
10761
10790
  const querySnapshot = await (0, import_firestore26.getDocs)(finalQuery);
10762
10791
  const patients = querySnapshot.docs.map(
10763
- (doc52) => doc52.data()
10792
+ (doc53) => doc53.data()
10764
10793
  );
10765
10794
  console.log(
10766
10795
  `[searchPatientsUtil] Found ${patients.length} patients matching criteria.`
@@ -10792,8 +10821,8 @@ var getAllPatientsUtil = async (db, options) => {
10792
10821
  }
10793
10822
  const patientsSnapshot = await (0, import_firestore26.getDocs)(q);
10794
10823
  const patients = [];
10795
- patientsSnapshot.forEach((doc52) => {
10796
- patients.push(doc52.data());
10824
+ patientsSnapshot.forEach((doc53) => {
10825
+ patients.push(doc53.data());
10797
10826
  });
10798
10827
  console.log(`[getAllPatientsUtil] Found ${patients.length} patients`);
10799
10828
  return patients;
@@ -10915,7 +10944,7 @@ var getActiveInviteTokensByClinicUtil = async (db, clinicId) => {
10915
10944
  if (querySnapshot.empty) {
10916
10945
  return [];
10917
10946
  }
10918
- return querySnapshot.docs.map((doc52) => doc52.data());
10947
+ return querySnapshot.docs.map((doc53) => doc53.data());
10919
10948
  };
10920
10949
  var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
10921
10950
  const tokensRef = (0, import_firestore27.collection)(
@@ -10933,7 +10962,7 @@ var getActiveInviteTokensByPatientUtil = async (db, patientId) => {
10933
10962
  if (querySnapshot.empty) {
10934
10963
  return [];
10935
10964
  }
10936
- return querySnapshot.docs.map((doc52) => doc52.data());
10965
+ return querySnapshot.docs.map((doc53) => doc53.data());
10937
10966
  };
10938
10967
 
10939
10968
  // src/services/patient/utils/aesthetic-analysis.utils.ts
@@ -12715,6 +12744,11 @@ var PERMISSION_KEYS = {
12715
12744
  "procedures.create": true,
12716
12745
  "procedures.edit": true,
12717
12746
  "procedures.delete": true,
12747
+ // Resources
12748
+ "resources.view": true,
12749
+ "resources.create": true,
12750
+ "resources.edit": true,
12751
+ "resources.delete": true,
12718
12752
  // Patients
12719
12753
  "patients.view": true,
12720
12754
  "patients.edit": true,
@@ -12772,6 +12806,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
12772
12806
  "procedures.create": true,
12773
12807
  "procedures.edit": true,
12774
12808
  "procedures.delete": true,
12809
+ "resources.view": true,
12810
+ "resources.create": true,
12811
+ "resources.edit": true,
12812
+ "resources.delete": true,
12775
12813
  "patients.view": true,
12776
12814
  "patients.edit": true,
12777
12815
  "providers.view": true,
@@ -12794,6 +12832,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
12794
12832
  "procedures.create": true,
12795
12833
  "procedures.edit": true,
12796
12834
  "procedures.delete": true,
12835
+ "resources.view": true,
12836
+ "resources.create": true,
12837
+ "resources.edit": true,
12838
+ "resources.delete": true,
12797
12839
  "patients.view": true,
12798
12840
  "patients.edit": true,
12799
12841
  "providers.view": true,
@@ -12816,6 +12858,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
12816
12858
  "procedures.create": false,
12817
12859
  "procedures.edit": false,
12818
12860
  "procedures.delete": false,
12861
+ "resources.view": true,
12862
+ "resources.create": false,
12863
+ "resources.edit": false,
12864
+ "resources.delete": false,
12819
12865
  "patients.view": true,
12820
12866
  "patients.edit": true,
12821
12867
  "providers.view": true,
@@ -12838,6 +12884,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
12838
12884
  "procedures.create": false,
12839
12885
  "procedures.edit": false,
12840
12886
  "procedures.delete": false,
12887
+ "resources.view": true,
12888
+ "resources.create": false,
12889
+ "resources.edit": false,
12890
+ "resources.delete": false,
12841
12891
  "patients.view": true,
12842
12892
  "patients.edit": false,
12843
12893
  "providers.view": true,
@@ -12860,6 +12910,10 @@ var DEFAULT_ROLE_PERMISSIONS = {
12860
12910
  "procedures.create": false,
12861
12911
  "procedures.edit": false,
12862
12912
  "procedures.delete": false,
12913
+ "resources.view": true,
12914
+ "resources.create": false,
12915
+ "resources.edit": false,
12916
+ "resources.delete": false,
12863
12917
  "patients.view": true,
12864
12918
  "patients.edit": false,
12865
12919
  "providers.view": true,
@@ -13524,7 +13578,7 @@ var PractitionerService = class extends BaseService {
13524
13578
  }
13525
13579
  const q = (0, import_firestore37.query)(tokensRef, ...conditions);
13526
13580
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
13527
- return querySnapshot.docs.map((doc52) => doc52.data());
13581
+ return querySnapshot.docs.map((doc53) => doc53.data());
13528
13582
  }
13529
13583
  /**
13530
13584
  * Gets a token by its string value and validates it
@@ -13736,20 +13790,20 @@ var PractitionerService = class extends BaseService {
13736
13790
  const debugSnapshot = await (0, import_firestore37.getDocs)(debugQ);
13737
13791
  console.log("[PRACTITIONER] Debug: Found practitioners with this email (any status):", {
13738
13792
  count: debugSnapshot.size,
13739
- practitioners: debugSnapshot.docs.map((doc52) => {
13793
+ practitioners: debugSnapshot.docs.map((doc53) => {
13740
13794
  var _a;
13741
13795
  return {
13742
- id: doc52.id,
13743
- email: (_a = doc52.data().basicInfo) == null ? void 0 : _a.email,
13744
- status: doc52.data().status,
13745
- userRef: doc52.data().userRef
13796
+ id: doc53.id,
13797
+ email: (_a = doc53.data().basicInfo) == null ? void 0 : _a.email,
13798
+ status: doc53.data().status,
13799
+ userRef: doc53.data().userRef
13746
13800
  };
13747
13801
  })
13748
13802
  });
13749
13803
  return [];
13750
13804
  }
13751
13805
  const draftPractitioners = querySnapshot.docs.map(
13752
- (doc52) => doc52.data()
13806
+ (doc53) => doc53.data()
13753
13807
  );
13754
13808
  console.log("[PRACTITIONER] Found draft practitioners", {
13755
13809
  email: normalizedEmail,
@@ -13962,7 +14016,7 @@ var PractitionerService = class extends BaseService {
13962
14016
  (0, import_firestore37.where)("status", "==", "active" /* ACTIVE */)
13963
14017
  );
13964
14018
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
13965
- return querySnapshot.docs.map((doc52) => doc52.data());
14019
+ return querySnapshot.docs.map((doc53) => doc53.data());
13966
14020
  }
13967
14021
  /**
13968
14022
  * Dohvata sve zdravstvene radnike za određenu kliniku
@@ -13974,7 +14028,7 @@ var PractitionerService = class extends BaseService {
13974
14028
  (0, import_firestore37.where)("isActive", "==", true)
13975
14029
  );
13976
14030
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
13977
- return querySnapshot.docs.map((doc52) => doc52.data());
14031
+ return querySnapshot.docs.map((doc53) => doc53.data());
13978
14032
  }
13979
14033
  /**
13980
14034
  * Dohvata sve draft zdravstvene radnike za određenu kliniku sa statusom DRAFT
@@ -13986,7 +14040,7 @@ var PractitionerService = class extends BaseService {
13986
14040
  (0, import_firestore37.where)("status", "==", "draft" /* DRAFT */)
13987
14041
  );
13988
14042
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
13989
- return querySnapshot.docs.map((doc52) => doc52.data());
14043
+ return querySnapshot.docs.map((doc53) => doc53.data());
13990
14044
  }
13991
14045
  /**
13992
14046
  * Updates a practitioner
@@ -14203,7 +14257,7 @@ var PractitionerService = class extends BaseService {
14203
14257
  );
14204
14258
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
14205
14259
  const practitioners = querySnapshot.docs.map(
14206
- (doc52) => doc52.data()
14260
+ (doc53) => doc53.data()
14207
14261
  );
14208
14262
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
14209
14263
  return {
@@ -14301,7 +14355,7 @@ var PractitionerService = class extends BaseService {
14301
14355
  );
14302
14356
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
14303
14357
  let practitioners = querySnapshot.docs.map(
14304
- (doc52) => ({ ...doc52.data(), id: doc52.id })
14358
+ (doc53) => ({ ...doc53.data(), id: doc53.id })
14305
14359
  );
14306
14360
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
14307
14361
  if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
@@ -14379,7 +14433,7 @@ var PractitionerService = class extends BaseService {
14379
14433
  );
14380
14434
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
14381
14435
  let practitioners = querySnapshot.docs.map(
14382
- (doc52) => ({ ...doc52.data(), id: doc52.id })
14436
+ (doc53) => ({ ...doc53.data(), id: doc53.id })
14383
14437
  );
14384
14438
  if (filters.location && filters.radiusInKm && filters.radiusInKm > 0) {
14385
14439
  const location = filters.location;
@@ -14423,7 +14477,7 @@ var PractitionerService = class extends BaseService {
14423
14477
  );
14424
14478
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
14425
14479
  let practitioners = querySnapshot.docs.map(
14426
- (doc52) => ({ ...doc52.data(), id: doc52.id })
14480
+ (doc53) => ({ ...doc53.data(), id: doc53.id })
14427
14481
  );
14428
14482
  practitioners = this.applyInMemoryFilters(practitioners, filters);
14429
14483
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -14453,7 +14507,7 @@ var PractitionerService = class extends BaseService {
14453
14507
  );
14454
14508
  const querySnapshot = await (0, import_firestore37.getDocs)(q);
14455
14509
  let practitioners = querySnapshot.docs.map(
14456
- (doc52) => ({ ...doc52.data(), id: doc52.id })
14510
+ (doc53) => ({ ...doc53.data(), id: doc53.id })
14457
14511
  );
14458
14512
  practitioners = this.applyInMemoryFilters(practitioners, filters);
14459
14513
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
@@ -14757,7 +14811,8 @@ var PractitionerService = class extends BaseService {
14757
14811
  "User must be authenticated to ensure free consultation infrastructure"
14758
14812
  );
14759
14813
  }
14760
- const functionUrl = `https://europe-west6-metaestetics.cloudfunctions.net/bookingApi/ensureFreeConsultationInfrastructure`;
14814
+ const projectId = this.app.options.projectId;
14815
+ const functionUrl = `https://europe-west6-${projectId}.cloudfunctions.net/bookingApi/ensureFreeConsultationInfrastructure`;
14761
14816
  const idToken = await currentUser.getIdToken();
14762
14817
  console.log(
14763
14818
  `[PRACTITIONER_SERVICE] Making fetch request to ${functionUrl}`
@@ -15081,7 +15136,7 @@ var UserService = class extends BaseService {
15081
15136
  const constraints = [(0, import_firestore38.where)("roles", "array-contains", role)];
15082
15137
  const q = (0, import_firestore38.query)((0, import_firestore38.collection)(this.db, USERS_COLLECTION), ...constraints);
15083
15138
  const querySnapshot = await (0, import_firestore38.getDocs)(q);
15084
- const users = querySnapshot.docs.map((doc52) => doc52.data());
15139
+ const users = querySnapshot.docs.map((doc53) => doc53.data());
15085
15140
  return users.map((userData) => userSchema.parse(userData));
15086
15141
  }
15087
15142
  /**
@@ -15262,9 +15317,9 @@ var BillingTransactionsService = class extends BaseService {
15262
15317
  const querySnapshot = await (0, import_firestore39.getDocs)(q);
15263
15318
  const docs = querySnapshot.docs;
15264
15319
  const hasMore = docs.length > queryLimit;
15265
- const transactions = docs.slice(0, queryLimit).map((doc52) => ({
15266
- id: doc52.id,
15267
- ...doc52.data()
15320
+ const transactions = docs.slice(0, queryLimit).map((doc53) => ({
15321
+ id: doc53.id,
15322
+ ...doc53.data()
15268
15323
  }));
15269
15324
  const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
15270
15325
  return {
@@ -15340,9 +15395,9 @@ var BillingTransactionsService = class extends BaseService {
15340
15395
  const querySnapshot = await (0, import_firestore39.getDocs)(q);
15341
15396
  const docs = querySnapshot.docs;
15342
15397
  const hasMore = docs.length > queryLimit;
15343
- const transactions = docs.slice(0, queryLimit).map((doc52) => ({
15344
- id: doc52.id,
15345
- ...doc52.data()
15398
+ const transactions = docs.slice(0, queryLimit).map((doc53) => ({
15399
+ id: doc53.id,
15400
+ ...doc53.data()
15346
15401
  }));
15347
15402
  const lastDoc = transactions.length > 0 ? docs[transactions.length - 1] : null;
15348
15403
  return {
@@ -15591,7 +15646,7 @@ async function getAllActiveGroups(db) {
15591
15646
  (0, import_firestore40.where)("isActive", "==", true)
15592
15647
  );
15593
15648
  const querySnapshot = await (0, import_firestore40.getDocs)(q);
15594
- return querySnapshot.docs.map((doc52) => doc52.data());
15649
+ return querySnapshot.docs.map((doc53) => doc53.data());
15595
15650
  }
15596
15651
  async function updateClinicGroup(db, groupId, data, app) {
15597
15652
  console.log("[CLINIC_GROUP] Updating clinic group", { groupId });
@@ -16055,8 +16110,8 @@ async function getClinicsByGroup(db, groupId, excludeDraftPractitioners = false)
16055
16110
  (0, import_firestore41.where)("isActive", "==", true)
16056
16111
  );
16057
16112
  const querySnapshot = await (0, import_firestore41.getDocs)(q);
16058
- return querySnapshot.docs.map((doc52) => {
16059
- const clinicData = doc52.data();
16113
+ return querySnapshot.docs.map((doc53) => {
16114
+ const clinicData = doc53.data();
16060
16115
  return filterClinicEmbeddedArrays(clinicData, excludeDraftPractitioners);
16061
16116
  });
16062
16117
  }
@@ -16254,7 +16309,7 @@ async function getClinicsByAdmin(db, adminId, options = {}, clinicAdminService,
16254
16309
  }
16255
16310
  const q = (0, import_firestore41.query)((0, import_firestore41.collection)(db, CLINICS_COLLECTION), ...constraints);
16256
16311
  const querySnapshot = await (0, import_firestore41.getDocs)(q);
16257
- return querySnapshot.docs.map((doc52) => doc52.data());
16312
+ return querySnapshot.docs.map((doc53) => doc53.data());
16258
16313
  }
16259
16314
  async function getActiveClinicsByAdmin(db, adminId, clinicAdminService, clinicGroupService) {
16260
16315
  return getClinicsByAdmin(
@@ -16300,11 +16355,11 @@ async function getAllClinics(db, pagination, lastDoc, excludeDraftPractitioners
16300
16355
  }
16301
16356
  const clinicsSnapshot = await (0, import_firestore41.getDocs)(clinicsQuery);
16302
16357
  const lastVisible = clinicsSnapshot.docs[clinicsSnapshot.docs.length - 1];
16303
- const clinics = clinicsSnapshot.docs.map((doc52) => {
16304
- const data = doc52.data();
16358
+ const clinics = clinicsSnapshot.docs.map((doc53) => {
16359
+ const data = doc53.data();
16305
16360
  const clinicWithId = {
16306
16361
  ...data,
16307
- id: doc52.id
16362
+ id: doc53.id
16308
16363
  };
16309
16364
  return filterClinicEmbeddedArrays(clinicWithId, excludeDraftPractitioners);
16310
16365
  });
@@ -16332,8 +16387,8 @@ async function getAllClinicsInRange(db, center, rangeInKm, pagination, lastDoc,
16332
16387
  ];
16333
16388
  const q = (0, import_firestore41.query)((0, import_firestore41.collection)(db, CLINICS_COLLECTION), ...constraints);
16334
16389
  const querySnapshot = await (0, import_firestore41.getDocs)(q);
16335
- for (const doc52 of querySnapshot.docs) {
16336
- const clinic = doc52.data();
16390
+ for (const doc53 of querySnapshot.docs) {
16391
+ const clinic = doc53.data();
16337
16392
  const distance = (0, import_geofire_common4.distanceBetween)(
16338
16393
  [center.latitude, center.longitude],
16339
16394
  [clinic.location.latitude, clinic.location.longitude]
@@ -16451,8 +16506,8 @@ async function findClinicsInRadius(db, center, radiusInKm, filters) {
16451
16506
  }
16452
16507
  const q = (0, import_firestore42.query)((0, import_firestore42.collection)(db, CLINICS_COLLECTION), ...constraints);
16453
16508
  const querySnapshot = await (0, import_firestore42.getDocs)(q);
16454
- for (const doc52 of querySnapshot.docs) {
16455
- const clinic = doc52.data();
16509
+ for (const doc53 of querySnapshot.docs) {
16510
+ const clinic = doc53.data();
16456
16511
  const distance = (0, import_geofire_common5.distanceBetween)(
16457
16512
  [center.latitude, center.longitude],
16458
16513
  [clinic.location.latitude, clinic.location.longitude]
@@ -16576,7 +16631,7 @@ async function getClinicsByFilters(db, filters) {
16576
16631
  constraints.push((0, import_firestore43.limit)(filters.pagination || 5));
16577
16632
  const q = (0, import_firestore43.query)((0, import_firestore43.collection)(db, CLINICS_COLLECTION), ...constraints);
16578
16633
  const querySnapshot = await (0, import_firestore43.getDocs)(q);
16579
- let clinics = querySnapshot.docs.map((doc52) => ({ ...doc52.data(), id: doc52.id }));
16634
+ let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
16580
16635
  const excludeDrafts = filters.excludeDraftPractitioners === true;
16581
16636
  console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
16582
16637
  clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
@@ -16611,7 +16666,7 @@ async function getClinicsByFilters(db, filters) {
16611
16666
  constraints.push((0, import_firestore43.limit)(filters.pagination || 5));
16612
16667
  const q = (0, import_firestore43.query)((0, import_firestore43.collection)(db, CLINICS_COLLECTION), ...constraints);
16613
16668
  const querySnapshot = await (0, import_firestore43.getDocs)(q);
16614
- let clinics = querySnapshot.docs.map((doc52) => ({ ...doc52.data(), id: doc52.id }));
16669
+ let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
16615
16670
  const excludeDrafts = filters.excludeDraftPractitioners === true;
16616
16671
  console.log(`[CLINIC_SERVICE] getClinicsByFilters - excludeDraftPractitioners from filters: ${filters.excludeDraftPractitioners}, resolved to: ${excludeDrafts}`);
16617
16672
  clinics = clinics.map((clinic) => filterClinicEmbeddedArrays(clinic, excludeDrafts));
@@ -16644,7 +16699,7 @@ async function getClinicsByFilters(db, filters) {
16644
16699
  constraints.push((0, import_firestore43.limit)(filters.pagination || 5));
16645
16700
  const q = (0, import_firestore43.query)((0, import_firestore43.collection)(db, CLINICS_COLLECTION), ...constraints);
16646
16701
  const querySnapshot = await (0, import_firestore43.getDocs)(q);
16647
- let clinics = querySnapshot.docs.map((doc52) => ({ ...doc52.data(), id: doc52.id }));
16702
+ let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
16648
16703
  clinics = applyInMemoryFilters(clinics, filters);
16649
16704
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
16650
16705
  console.log(`[CLINIC_SERVICE] Strategy 3 success: ${clinics.length} clinics`);
@@ -16664,7 +16719,7 @@ async function getClinicsByFilters(db, filters) {
16664
16719
  ];
16665
16720
  const q = (0, import_firestore43.query)((0, import_firestore43.collection)(db, CLINICS_COLLECTION), ...constraints);
16666
16721
  const querySnapshot = await (0, import_firestore43.getDocs)(q);
16667
- let clinics = querySnapshot.docs.map((doc52) => ({ ...doc52.data(), id: doc52.id }));
16722
+ let clinics = querySnapshot.docs.map((doc53) => ({ ...doc53.data(), id: doc53.id }));
16668
16723
  clinics = applyInMemoryFilters(clinics, filters);
16669
16724
  const lastDoc = querySnapshot.docs.length > 0 ? querySnapshot.docs[querySnapshot.docs.length - 1] : null;
16670
16725
  console.log(`[CLINIC_SERVICE] Strategy 4 success: ${clinics.length} clinics`);
@@ -17241,11 +17296,11 @@ var ClinicService = class extends BaseService {
17241
17296
  async getClinicsForMap() {
17242
17297
  const clinicsRef = (0, import_firestore44.collection)(this.db, CLINICS_COLLECTION);
17243
17298
  const snapshot = await (0, import_firestore44.getDocs)(clinicsRef);
17244
- const clinicsForMap = snapshot.docs.map((doc52) => {
17299
+ const clinicsForMap = snapshot.docs.map((doc53) => {
17245
17300
  var _a, _b, _c;
17246
- const data = doc52.data();
17301
+ const data = doc53.data();
17247
17302
  return {
17248
- id: doc52.id,
17303
+ id: doc53.id,
17249
17304
  name: data.name,
17250
17305
  address: ((_a = data.location) == null ? void 0 : _a.address) || "",
17251
17306
  latitude: (_b = data.location) == null ? void 0 : _b.latitude,
@@ -18738,7 +18793,7 @@ async function searchCalendarEventsUtil(db, params) {
18738
18793
  const finalQuery = (0, import_firestore50.query)(collectionRef, ...constraints);
18739
18794
  const querySnapshot = await (0, import_firestore50.getDocs)(finalQuery);
18740
18795
  let events = querySnapshot.docs.map(
18741
- (doc52) => ({ id: doc52.id, ...doc52.data() })
18796
+ (doc53) => ({ id: doc53.id, ...doc53.data() })
18742
18797
  );
18743
18798
  if (filters.dateRange) {
18744
18799
  events = events.filter((event) => {
@@ -18838,7 +18893,7 @@ async function getPractitionerSyncedCalendarsUtil(db, practitionerId) {
18838
18893
  );
18839
18894
  const q = (0, import_firestore51.query)(calendarsRef, (0, import_firestore51.orderBy)("createdAt", "desc"));
18840
18895
  const querySnapshot = await (0, import_firestore51.getDocs)(q);
18841
- return querySnapshot.docs.map((doc52) => doc52.data());
18896
+ return querySnapshot.docs.map((doc53) => doc53.data());
18842
18897
  }
18843
18898
  async function getPatientSyncedCalendarUtil(db, patientId, calendarId) {
18844
18899
  const calendarRef = getPatientSyncedCalendarDocRef(db, patientId, calendarId);
@@ -18855,7 +18910,7 @@ async function getPatientSyncedCalendarsUtil(db, patientId) {
18855
18910
  );
18856
18911
  const q = (0, import_firestore51.query)(calendarsRef, (0, import_firestore51.orderBy)("createdAt", "desc"));
18857
18912
  const querySnapshot = await (0, import_firestore51.getDocs)(q);
18858
- return querySnapshot.docs.map((doc52) => doc52.data());
18913
+ return querySnapshot.docs.map((doc53) => doc53.data());
18859
18914
  }
18860
18915
  async function getClinicSyncedCalendarUtil(db, clinicId, calendarId) {
18861
18916
  const calendarRef = getClinicSyncedCalendarDocRef(db, clinicId, calendarId);
@@ -18872,7 +18927,7 @@ async function getClinicSyncedCalendarsUtil(db, clinicId) {
18872
18927
  );
18873
18928
  const q = (0, import_firestore51.query)(calendarsRef, (0, import_firestore51.orderBy)("createdAt", "desc"));
18874
18929
  const querySnapshot = await (0, import_firestore51.getDocs)(q);
18875
- return querySnapshot.docs.map((doc52) => doc52.data());
18930
+ return querySnapshot.docs.map((doc53) => doc53.data());
18876
18931
  }
18877
18932
  async function updatePractitionerSyncedCalendarUtil(db, practitionerId, calendarId, updateData) {
18878
18933
  const calendarRef = getPractitionerSyncedCalendarDocRef(
@@ -20227,9 +20282,9 @@ var CalendarServiceV2 = class extends BaseService {
20227
20282
  (0, import_firestore54.where)("eventTime.start", "<=", import_firestore53.Timestamp.fromDate(endDate))
20228
20283
  );
20229
20284
  const eventsSnapshot = await (0, import_firestore54.getDocs)(q);
20230
- const events = eventsSnapshot.docs.map((doc52) => ({
20231
- id: doc52.id,
20232
- ...doc52.data()
20285
+ const events = eventsSnapshot.docs.map((doc53) => ({
20286
+ id: doc53.id,
20287
+ ...doc53.data()
20233
20288
  }));
20234
20289
  const calendars = await this.syncedCalendarsService.getPractitionerSyncedCalendars(
20235
20290
  doctorId
@@ -20873,7 +20928,7 @@ var CalendarServiceV2 = class extends BaseService {
20873
20928
  ])
20874
20929
  );
20875
20930
  const querySnapshot = await (0, import_firestore54.getDocs)(q);
20876
- return querySnapshot.docs.map((doc52) => doc52.data());
20931
+ return querySnapshot.docs.map((doc53) => doc53.data());
20877
20932
  }
20878
20933
  /**
20879
20934
  * Calculates available time slots based on working hours, schedule and existing appointments
@@ -21404,7 +21459,7 @@ var PractitionerInviteService = class extends BaseService {
21404
21459
  ...constraints
21405
21460
  );
21406
21461
  const querySnapshot = await (0, import_firestore57.getDocs)(q);
21407
- return querySnapshot.docs.map((doc52) => doc52.data());
21462
+ return querySnapshot.docs.map((doc53) => doc53.data());
21408
21463
  } catch (error) {
21409
21464
  console.error(
21410
21465
  "[PractitionerInviteService] Error getting doctor invites:",
@@ -21433,7 +21488,7 @@ var PractitionerInviteService = class extends BaseService {
21433
21488
  ...constraints
21434
21489
  );
21435
21490
  const querySnapshot = await (0, import_firestore57.getDocs)(q);
21436
- return querySnapshot.docs.map((doc52) => doc52.data());
21491
+ return querySnapshot.docs.map((doc53) => doc53.data());
21437
21492
  } catch (error) {
21438
21493
  console.error(
21439
21494
  "[PractitionerInviteService] Error getting clinic invites:",
@@ -21589,7 +21644,7 @@ var PractitionerInviteService = class extends BaseService {
21589
21644
  );
21590
21645
  const querySnapshot = await (0, import_firestore57.getDocs)(q);
21591
21646
  let invites = querySnapshot.docs.map(
21592
- (doc52) => doc52.data()
21647
+ (doc53) => doc53.data()
21593
21648
  );
21594
21649
  if (filters.fromDate) {
21595
21650
  invites = invites.filter(
@@ -21847,8 +21902,8 @@ var DocumentationTemplateService = class extends BaseService {
21847
21902
  const q = (0, import_firestore58.query)(versionsCollectionRef, (0, import_firestore58.orderBy)("version", "desc"));
21848
21903
  const querySnapshot = await (0, import_firestore58.getDocs)(q);
21849
21904
  const versions = [];
21850
- querySnapshot.forEach((doc52) => {
21851
- versions.push(doc52.data());
21905
+ querySnapshot.forEach((doc53) => {
21906
+ versions.push(doc53.data());
21852
21907
  });
21853
21908
  return versions;
21854
21909
  }
@@ -21879,9 +21934,9 @@ var DocumentationTemplateService = class extends BaseService {
21879
21934
  const querySnapshot = await (0, import_firestore58.getDocs)(q);
21880
21935
  const templates = [];
21881
21936
  let lastVisible = null;
21882
- querySnapshot.forEach((doc52) => {
21883
- templates.push(doc52.data());
21884
- lastVisible = doc52;
21937
+ querySnapshot.forEach((doc53) => {
21938
+ templates.push(doc53.data());
21939
+ lastVisible = doc53;
21885
21940
  });
21886
21941
  return {
21887
21942
  templates,
@@ -21923,9 +21978,9 @@ var DocumentationTemplateService = class extends BaseService {
21923
21978
  const querySnapshot = await (0, import_firestore58.getDocs)(q);
21924
21979
  const templates = [];
21925
21980
  let lastVisible = null;
21926
- querySnapshot.forEach((doc52) => {
21927
- templates.push(doc52.data());
21928
- lastVisible = doc52;
21981
+ querySnapshot.forEach((doc53) => {
21982
+ templates.push(doc53.data());
21983
+ lastVisible = doc53;
21929
21984
  });
21930
21985
  return {
21931
21986
  templates,
@@ -21965,8 +22020,8 @@ var DocumentationTemplateService = class extends BaseService {
21965
22020
  );
21966
22021
  const querySnapshot = await (0, import_firestore58.getDocs)(q);
21967
22022
  const templates = [];
21968
- querySnapshot.forEach((doc52) => {
21969
- templates.push(doc52.data());
22023
+ querySnapshot.forEach((doc53) => {
22024
+ templates.push(doc53.data());
21970
22025
  });
21971
22026
  return templates;
21972
22027
  }
@@ -21991,9 +22046,9 @@ var DocumentationTemplateService = class extends BaseService {
21991
22046
  const querySnapshot = await (0, import_firestore58.getDocs)(q);
21992
22047
  const templates = [];
21993
22048
  let lastVisible = null;
21994
- querySnapshot.forEach((doc52) => {
21995
- templates.push(doc52.data());
21996
- lastVisible = doc52;
22049
+ querySnapshot.forEach((doc53) => {
22050
+ templates.push(doc53.data());
22051
+ lastVisible = doc53;
21997
22052
  });
21998
22053
  return {
21999
22054
  templates,
@@ -22020,9 +22075,9 @@ var DocumentationTemplateService = class extends BaseService {
22020
22075
  const querySnapshot = await (0, import_firestore58.getDocs)(q);
22021
22076
  const templates = [];
22022
22077
  let lastVisible = null;
22023
- querySnapshot.forEach((doc52) => {
22024
- templates.push(doc52.data());
22025
- lastVisible = doc52;
22078
+ querySnapshot.forEach((doc53) => {
22079
+ templates.push(doc53.data());
22080
+ lastVisible = doc53;
22026
22081
  });
22027
22082
  return {
22028
22083
  templates,
@@ -22048,8 +22103,8 @@ var DocumentationTemplateService = class extends BaseService {
22048
22103
  }
22049
22104
  const querySnapshot = await (0, import_firestore58.getDocs)(q);
22050
22105
  const templates = [];
22051
- querySnapshot.forEach((doc52) => {
22052
- templates.push(doc52.data());
22106
+ querySnapshot.forEach((doc53) => {
22107
+ templates.push(doc53.data());
22053
22108
  });
22054
22109
  return templates;
22055
22110
  }
@@ -22463,9 +22518,9 @@ var NotificationService = class extends BaseService {
22463
22518
  (0, import_firestore61.orderBy)("notificationTime", "desc")
22464
22519
  );
22465
22520
  const querySnapshot = await (0, import_firestore61.getDocs)(q);
22466
- return querySnapshot.docs.map((doc52) => ({
22467
- id: doc52.id,
22468
- ...doc52.data()
22521
+ return querySnapshot.docs.map((doc53) => ({
22522
+ id: doc53.id,
22523
+ ...doc53.data()
22469
22524
  }));
22470
22525
  }
22471
22526
  /**
@@ -22479,9 +22534,9 @@ var NotificationService = class extends BaseService {
22479
22534
  (0, import_firestore61.orderBy)("notificationTime", "desc")
22480
22535
  );
22481
22536
  const querySnapshot = await (0, import_firestore61.getDocs)(q);
22482
- return querySnapshot.docs.map((doc52) => ({
22483
- id: doc52.id,
22484
- ...doc52.data()
22537
+ return querySnapshot.docs.map((doc53) => ({
22538
+ id: doc53.id,
22539
+ ...doc53.data()
22485
22540
  }));
22486
22541
  }
22487
22542
  /**
@@ -22553,9 +22608,9 @@ var NotificationService = class extends BaseService {
22553
22608
  (0, import_firestore61.orderBy)("notificationTime", "desc")
22554
22609
  );
22555
22610
  const querySnapshot = await (0, import_firestore61.getDocs)(q);
22556
- return querySnapshot.docs.map((doc52) => ({
22557
- id: doc52.id,
22558
- ...doc52.data()
22611
+ return querySnapshot.docs.map((doc53) => ({
22612
+ id: doc53.id,
22613
+ ...doc53.data()
22559
22614
  }));
22560
22615
  }
22561
22616
  /**
@@ -22568,9 +22623,9 @@ var NotificationService = class extends BaseService {
22568
22623
  (0, import_firestore61.orderBy)("notificationTime", "desc")
22569
22624
  );
22570
22625
  const querySnapshot = await (0, import_firestore61.getDocs)(q);
22571
- return querySnapshot.docs.map((doc52) => ({
22572
- id: doc52.id,
22573
- ...doc52.data()
22626
+ return querySnapshot.docs.map((doc53) => ({
22627
+ id: doc53.id,
22628
+ ...doc53.data()
22574
22629
  }));
22575
22630
  }
22576
22631
  };
@@ -22796,6 +22851,11 @@ var procedureProductDataSchema = import_zod29.z.object({
22796
22851
  });
22797
22852
 
22798
22853
  // src/validations/procedure.schema.ts
22854
+ var resourceRequirementSchema = import_zod30.z.object({
22855
+ resourceId: import_zod30.z.string().min(1),
22856
+ resourceName: import_zod30.z.string().min(1),
22857
+ resourceCategory: import_zod30.z.nativeEnum(ResourceCategory)
22858
+ });
22799
22859
  var storedProcedureProductSchema = import_zod30.z.object({
22800
22860
  /**
22801
22861
  * The full product object used in the procedure.
@@ -22838,7 +22898,8 @@ var createProcedureSchema = import_zod30.z.object({
22838
22898
  // Max 8 hours
22839
22899
  practitionerId: import_zod30.z.string().min(1),
22840
22900
  clinicBranchId: import_zod30.z.string().min(1),
22841
- photos: import_zod30.z.array(mediaResourceSchema).optional()
22901
+ photos: import_zod30.z.array(mediaResourceSchema).optional(),
22902
+ resourceRequirements: import_zod30.z.array(resourceRequirementSchema).optional()
22842
22903
  });
22843
22904
  var updateProcedureSchema = import_zod30.z.object({
22844
22905
  name: import_zod30.z.string().min(3).max(100).optional(),
@@ -22857,7 +22918,8 @@ var updateProcedureSchema = import_zod30.z.object({
22857
22918
  technologyId: import_zod30.z.string().optional(),
22858
22919
  productId: import_zod30.z.string().optional(),
22859
22920
  clinicBranchId: import_zod30.z.string().optional(),
22860
- photos: import_zod30.z.array(mediaResourceSchema).optional()
22921
+ photos: import_zod30.z.array(mediaResourceSchema).optional(),
22922
+ resourceRequirements: import_zod30.z.array(resourceRequirementSchema).optional()
22861
22923
  });
22862
22924
  var procedureSchema = import_zod30.z.object({
22863
22925
  id: import_zod30.z.string().min(1),
@@ -23133,7 +23195,7 @@ var ProcedureService = class extends BaseService {
23133
23195
  (0, import_firestore63.where)("isActive", "==", true)
23134
23196
  );
23135
23197
  const existingProceduresSnapshot = await (0, import_firestore63.getDocs)(existingProceduresQuery);
23136
- const existingProcedures = existingProceduresSnapshot.docs.map((doc52) => doc52.data());
23198
+ const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
23137
23199
  const hasSameTechnology = existingProcedures.some(
23138
23200
  (proc) => {
23139
23201
  var _a2;
@@ -23321,7 +23383,7 @@ var ProcedureService = class extends BaseService {
23321
23383
  (0, import_firestore63.where)("isActive", "==", true)
23322
23384
  );
23323
23385
  const existingProceduresSnapshot = await (0, import_firestore63.getDocs)(existingProceduresQuery);
23324
- const existingProcedures = existingProceduresSnapshot.docs.map((doc52) => doc52.data());
23386
+ const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
23325
23387
  const hasSameTechnology = existingProcedures.some(
23326
23388
  (proc) => {
23327
23389
  var _a2, _b2;
@@ -23418,7 +23480,7 @@ var ProcedureService = class extends BaseService {
23418
23480
  (0, import_firestore63.where)("isActive", "==", true)
23419
23481
  );
23420
23482
  const existingProceduresSnapshot = await (0, import_firestore63.getDocs)(existingProceduresQuery);
23421
- const existingProcedures = existingProceduresSnapshot.docs.map((doc52) => doc52.data());
23483
+ const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
23422
23484
  const hasSameTechnology = existingProcedures.some(
23423
23485
  (proc) => {
23424
23486
  var _a2;
@@ -23559,8 +23621,8 @@ var ProcedureService = class extends BaseService {
23559
23621
  (0, import_firestore63.where)((0, import_firestore63.documentId)(), "in", chunk)
23560
23622
  );
23561
23623
  const practitionersSnapshot = await (0, import_firestore63.getDocs)(practitionersQuery);
23562
- practitionersSnapshot.docs.forEach((doc52) => {
23563
- practitionersMap.set(doc52.id, doc52.data());
23624
+ practitionersSnapshot.docs.forEach((doc53) => {
23625
+ practitionersMap.set(doc53.id, doc53.data());
23564
23626
  });
23565
23627
  }
23566
23628
  if (practitionersMap.size !== practitionerIds.length) {
@@ -23578,7 +23640,7 @@ var ProcedureService = class extends BaseService {
23578
23640
  (0, import_firestore63.where)("isActive", "==", true)
23579
23641
  );
23580
23642
  const existingProceduresSnapshot = await (0, import_firestore63.getDocs)(existingProceduresQuery);
23581
- const existingProcedures = existingProceduresSnapshot.docs.map((doc52) => doc52.data());
23643
+ const existingProcedures = existingProceduresSnapshot.docs.map((doc53) => doc53.data());
23582
23644
  const hasSameTechnology = existingProcedures.some(
23583
23645
  (proc) => {
23584
23646
  var _a2;
@@ -23689,8 +23751,8 @@ var ProcedureService = class extends BaseService {
23689
23751
  const chunk = createdProcedureIds.slice(i, i + 30);
23690
23752
  const q = (0, import_firestore63.query)((0, import_firestore63.collection)(this.db, PROCEDURES_COLLECTION), (0, import_firestore63.where)((0, import_firestore63.documentId)(), "in", chunk));
23691
23753
  const snapshot = await (0, import_firestore63.getDocs)(q);
23692
- snapshot.forEach((doc52) => {
23693
- fetchedProcedures.push(doc52.data());
23754
+ snapshot.forEach((doc53) => {
23755
+ fetchedProcedures.push(doc53.data());
23694
23756
  });
23695
23757
  }
23696
23758
  return fetchedProcedures;
@@ -23721,7 +23783,7 @@ var ProcedureService = class extends BaseService {
23721
23783
  (0, import_firestore63.where)("isActive", "==", true)
23722
23784
  );
23723
23785
  const snapshot = await (0, import_firestore63.getDocs)(q);
23724
- const procedures = snapshot.docs.map((doc52) => doc52.data());
23786
+ const procedures = snapshot.docs.map((doc53) => doc53.data());
23725
23787
  if (excludeDraftPractitioners) {
23726
23788
  return await this.filterDraftPractitionerProcedures(procedures);
23727
23789
  }
@@ -23747,7 +23809,7 @@ var ProcedureService = class extends BaseService {
23747
23809
  ...constraints
23748
23810
  );
23749
23811
  const snapshot = await (0, import_firestore63.getDocs)(q);
23750
- const procedures = snapshot.docs.map((doc52) => doc52.data());
23812
+ const procedures = snapshot.docs.map((doc53) => doc53.data());
23751
23813
  if (excludeDraftPractitioners && this.practitionerService) {
23752
23814
  try {
23753
23815
  const practitioner = await this.practitionerService.getPractitioner(practitionerId);
@@ -23773,7 +23835,7 @@ var ProcedureService = class extends BaseService {
23773
23835
  (0, import_firestore63.where)("isActive", "==", false)
23774
23836
  );
23775
23837
  const snapshot = await (0, import_firestore63.getDocs)(q);
23776
- return snapshot.docs.map((doc52) => doc52.data());
23838
+ return snapshot.docs.map((doc53) => doc53.data());
23777
23839
  }
23778
23840
  /**
23779
23841
  * Updates a procedure
@@ -23992,11 +24054,11 @@ var ProcedureService = class extends BaseService {
23992
24054
  proceduresQuery = (0, import_firestore63.query)(proceduresCollection, (0, import_firestore63.orderBy)("name"));
23993
24055
  }
23994
24056
  const proceduresSnapshot = await (0, import_firestore63.getDocs)(proceduresQuery);
23995
- let procedures = proceduresSnapshot.docs.map((doc52) => {
23996
- const data = doc52.data();
24057
+ let procedures = proceduresSnapshot.docs.map((doc53) => {
24058
+ const data = doc53.data();
23997
24059
  return {
23998
24060
  ...data,
23999
- id: doc52.id
24061
+ id: doc53.id
24000
24062
  // Ensure ID is present
24001
24063
  };
24002
24064
  });
@@ -24021,10 +24083,10 @@ var ProcedureService = class extends BaseService {
24021
24083
  * @param orderByField - The field used in orderBy clause
24022
24084
  * @returns Serializable cursor object with values needed for startAfter
24023
24085
  */
24024
- createSerializableCursor(doc52, orderByField = "createdAt") {
24025
- if (!doc52) return null;
24026
- const data = typeof doc52.data === "function" ? doc52.data() : doc52;
24027
- const docId = doc52.id || (data == null ? void 0 : data.id);
24086
+ createSerializableCursor(doc53, orderByField = "createdAt") {
24087
+ if (!doc53) return null;
24088
+ const data = typeof doc53.data === "function" ? doc53.data() : doc53;
24089
+ const docId = doc53.id || (data == null ? void 0 : data.id);
24028
24090
  if (!docId) return null;
24029
24091
  let orderByValue = data == null ? void 0 : data[orderByField];
24030
24092
  if (orderByValue && typeof orderByValue.toDate === "function") {
@@ -24184,7 +24246,7 @@ var ProcedureService = class extends BaseService {
24184
24246
  const q = (0, import_firestore63.query)((0, import_firestore63.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
24185
24247
  const querySnapshot = await (0, import_firestore63.getDocs)(q);
24186
24248
  let procedures = querySnapshot.docs.map(
24187
- (doc52) => ({ ...doc52.data(), id: doc52.id })
24249
+ (doc53) => ({ ...doc53.data(), id: doc53.id })
24188
24250
  );
24189
24251
  if (hasNestedFilters) {
24190
24252
  procedures = this.applyInMemoryFilters(procedures, filters);
@@ -24226,7 +24288,7 @@ var ProcedureService = class extends BaseService {
24226
24288
  const q = (0, import_firestore63.query)((0, import_firestore63.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
24227
24289
  const querySnapshot = await (0, import_firestore63.getDocs)(q);
24228
24290
  let procedures = querySnapshot.docs.map(
24229
- (doc52) => ({ ...doc52.data(), id: doc52.id })
24291
+ (doc53) => ({ ...doc53.data(), id: doc53.id })
24230
24292
  );
24231
24293
  if (hasNestedFilters) {
24232
24294
  procedures = this.applyInMemoryFilters(procedures, filters);
@@ -24300,7 +24362,7 @@ var ProcedureService = class extends BaseService {
24300
24362
  const q = (0, import_firestore63.query)((0, import_firestore63.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
24301
24363
  const querySnapshot = await (0, import_firestore63.getDocs)(q);
24302
24364
  let procedures = querySnapshot.docs.map(
24303
- (doc52) => ({ ...doc52.data(), id: doc52.id })
24365
+ (doc53) => ({ ...doc53.data(), id: doc53.id })
24304
24366
  );
24305
24367
  console.log("[PROCEDURE_SERVICE] Before applyInMemoryFilters (Strategy 3):", {
24306
24368
  procedureCount: procedures.length,
@@ -24353,7 +24415,7 @@ var ProcedureService = class extends BaseService {
24353
24415
  const q = (0, import_firestore63.query)((0, import_firestore63.collection)(this.db, PROCEDURES_COLLECTION), ...constraints);
24354
24416
  const querySnapshot = await (0, import_firestore63.getDocs)(q);
24355
24417
  let procedures = querySnapshot.docs.map(
24356
- (doc52) => ({ ...doc52.data(), id: doc52.id })
24418
+ (doc53) => ({ ...doc53.data(), id: doc53.id })
24357
24419
  );
24358
24420
  procedures = this.applyInMemoryFilters(procedures, filters);
24359
24421
  if (filters.excludeDraftPractitioners) {
@@ -24690,9 +24752,9 @@ var ProcedureService = class extends BaseService {
24690
24752
  async getProceduresForMap() {
24691
24753
  const proceduresRef = (0, import_firestore63.collection)(this.db, PROCEDURES_COLLECTION);
24692
24754
  const snapshot = await (0, import_firestore63.getDocs)(proceduresRef);
24693
- let procedures = snapshot.docs.map((doc52) => ({
24694
- id: doc52.id,
24695
- ...doc52.data()
24755
+ let procedures = snapshot.docs.map((doc53) => ({
24756
+ id: doc53.id,
24757
+ ...doc53.data()
24696
24758
  }));
24697
24759
  procedures = await this.filterDraftPractitionerProcedures(procedures);
24698
24760
  const proceduresForMap = procedures.map((procedure) => {
@@ -24741,18 +24803,462 @@ var ProcedureService = class extends BaseService {
24741
24803
  (0, import_firestore63.orderBy)("name", "asc")
24742
24804
  );
24743
24805
  const querySnapshot = await (0, import_firestore63.getDocs)(proceduresQuery);
24744
- let procedures = querySnapshot.docs.map((doc52) => ({
24745
- id: doc52.id,
24746
- ...doc52.data()
24806
+ let procedures = querySnapshot.docs.map((doc53) => ({
24807
+ id: doc53.id,
24808
+ ...doc53.data()
24747
24809
  }));
24748
24810
  procedures = await this.filterDraftPractitionerProcedures(procedures);
24749
24811
  return procedures;
24750
24812
  }
24751
24813
  };
24752
24814
 
24753
- // src/services/reviews/reviews.service.ts
24815
+ // src/services/resource/resource.service.ts
24754
24816
  var import_firestore64 = require("firebase/firestore");
24817
+
24818
+ // src/validations/resource.schema.ts
24755
24819
  var import_zod31 = require("zod");
24820
+ var createResourceSchema = import_zod31.z.object({
24821
+ clinicBranchId: import_zod31.z.string().min(1),
24822
+ name: import_zod31.z.string().min(1).max(200),
24823
+ category: import_zod31.z.nativeEnum(ResourceCategory),
24824
+ description: import_zod31.z.string().max(1e3).optional(),
24825
+ quantity: import_zod31.z.number().int().min(1).max(100)
24826
+ });
24827
+ var updateResourceSchema = import_zod31.z.object({
24828
+ name: import_zod31.z.string().min(1).max(200).optional(),
24829
+ category: import_zod31.z.nativeEnum(ResourceCategory).optional(),
24830
+ description: import_zod31.z.string().max(1e3).optional(),
24831
+ quantity: import_zod31.z.number().int().min(1).max(100).optional(),
24832
+ status: import_zod31.z.nativeEnum(ResourceStatus).optional()
24833
+ });
24834
+ var createResourceBlockingEventSchema = import_zod31.z.object({
24835
+ clinicBranchId: import_zod31.z.string().min(1),
24836
+ resourceId: import_zod31.z.string().min(1),
24837
+ resourceInstanceId: import_zod31.z.string().min(1),
24838
+ eventName: import_zod31.z.string().min(1).max(200),
24839
+ eventTime: import_zod31.z.object({
24840
+ start: import_zod31.z.any(),
24841
+ end: import_zod31.z.any()
24842
+ }),
24843
+ description: import_zod31.z.string().max(1e3).optional()
24844
+ });
24845
+ var updateResourceBlockingEventSchema = import_zod31.z.object({
24846
+ clinicBranchId: import_zod31.z.string().min(1),
24847
+ resourceId: import_zod31.z.string().min(1),
24848
+ resourceInstanceId: import_zod31.z.string().min(1),
24849
+ eventId: import_zod31.z.string().min(1),
24850
+ eventName: import_zod31.z.string().min(1).max(200).optional(),
24851
+ eventTime: import_zod31.z.object({
24852
+ start: import_zod31.z.any(),
24853
+ end: import_zod31.z.any()
24854
+ }).optional(),
24855
+ description: import_zod31.z.string().max(1e3).optional()
24856
+ });
24857
+
24858
+ // src/services/resource/resource.service.ts
24859
+ var ResourceService = class extends BaseService {
24860
+ /**
24861
+ * Gets reference to a clinic's resources collection
24862
+ */
24863
+ getResourcesRef(clinicBranchId) {
24864
+ return (0, import_firestore64.collection)(this.db, "clinics", clinicBranchId, RESOURCES_COLLECTION);
24865
+ }
24866
+ /**
24867
+ * Gets reference to a specific resource document
24868
+ */
24869
+ getResourceDocRef(clinicBranchId, resourceId) {
24870
+ return (0, import_firestore64.doc)(
24871
+ this.db,
24872
+ "clinics",
24873
+ clinicBranchId,
24874
+ RESOURCES_COLLECTION,
24875
+ resourceId
24876
+ );
24877
+ }
24878
+ /**
24879
+ * Gets reference to a resource's instances subcollection
24880
+ */
24881
+ getInstancesRef(clinicBranchId, resourceId) {
24882
+ return (0, import_firestore64.collection)(
24883
+ this.db,
24884
+ "clinics",
24885
+ clinicBranchId,
24886
+ RESOURCES_COLLECTION,
24887
+ resourceId,
24888
+ RESOURCE_INSTANCES_SUBCOLLECTION
24889
+ );
24890
+ }
24891
+ /**
24892
+ * Gets reference to an instance's calendar subcollection
24893
+ */
24894
+ getInstanceCalendarRef(clinicBranchId, resourceId, instanceId) {
24895
+ return (0, import_firestore64.collection)(
24896
+ this.db,
24897
+ "clinics",
24898
+ clinicBranchId,
24899
+ RESOURCES_COLLECTION,
24900
+ resourceId,
24901
+ RESOURCE_INSTANCES_SUBCOLLECTION,
24902
+ instanceId,
24903
+ RESOURCE_CALENDAR_SUBCOLLECTION
24904
+ );
24905
+ }
24906
+ /**
24907
+ * Creates a new resource with its instances.
24908
+ * Creates the resource document and N instance subdocuments in a single batch.
24909
+ */
24910
+ async createResource(data) {
24911
+ const batch = (0, import_firestore64.writeBatch)(this.db);
24912
+ const resourceRef = (0, import_firestore64.doc)(this.getResourcesRef(data.clinicBranchId));
24913
+ const resourceId = resourceRef.id;
24914
+ const now = (0, import_firestore64.serverTimestamp)();
24915
+ const resourceData = {
24916
+ id: resourceId,
24917
+ clinicBranchId: data.clinicBranchId,
24918
+ name: data.name,
24919
+ nameLower: data.name.toLowerCase(),
24920
+ category: data.category,
24921
+ description: data.description || void 0,
24922
+ quantity: data.quantity,
24923
+ status: "active" /* ACTIVE */,
24924
+ linkedProcedureIds: [],
24925
+ createdAt: now,
24926
+ updatedAt: now
24927
+ };
24928
+ batch.set(resourceRef, resourceData);
24929
+ for (let i = 1; i <= data.quantity; i++) {
24930
+ const instanceRef = (0, import_firestore64.doc)(
24931
+ this.getInstancesRef(data.clinicBranchId, resourceId)
24932
+ );
24933
+ const instanceData = {
24934
+ id: instanceRef.id,
24935
+ resourceId,
24936
+ clinicBranchId: data.clinicBranchId,
24937
+ label: `${data.name} #${i}`,
24938
+ index: i,
24939
+ status: "active" /* ACTIVE */,
24940
+ createdAt: now,
24941
+ updatedAt: now
24942
+ };
24943
+ batch.set(instanceRef, instanceData);
24944
+ }
24945
+ await batch.commit();
24946
+ const created = await this.getResource(data.clinicBranchId, resourceId);
24947
+ if (!created) throw new Error("Failed to read created resource");
24948
+ return created;
24949
+ }
24950
+ /**
24951
+ * Gets a single resource by ID
24952
+ */
24953
+ async getResource(clinicBranchId, resourceId) {
24954
+ const docRef = this.getResourceDocRef(clinicBranchId, resourceId);
24955
+ const docSnap = await (0, import_firestore64.getDoc)(docRef);
24956
+ if (!docSnap.exists()) return null;
24957
+ return { id: docSnap.id, ...docSnap.data() };
24958
+ }
24959
+ /**
24960
+ * Gets all resources for a clinic branch
24961
+ */
24962
+ async getResourcesByClinic(clinicBranchId) {
24963
+ const q = (0, import_firestore64.query)(
24964
+ this.getResourcesRef(clinicBranchId),
24965
+ (0, import_firestore64.orderBy)("nameLower")
24966
+ );
24967
+ const snapshot = await (0, import_firestore64.getDocs)(q);
24968
+ return snapshot.docs.map(
24969
+ (d) => ({ id: d.id, ...d.data() })
24970
+ );
24971
+ }
24972
+ /**
24973
+ * Gets all active resources for a clinic branch
24974
+ */
24975
+ async getActiveResourcesByClinic(clinicBranchId) {
24976
+ const q = (0, import_firestore64.query)(
24977
+ this.getResourcesRef(clinicBranchId),
24978
+ (0, import_firestore64.where)("status", "==", "active" /* ACTIVE */),
24979
+ (0, import_firestore64.orderBy)("nameLower")
24980
+ );
24981
+ const snapshot = await (0, import_firestore64.getDocs)(q);
24982
+ return snapshot.docs.map(
24983
+ (d) => ({ id: d.id, ...d.data() })
24984
+ );
24985
+ }
24986
+ /**
24987
+ * Updates a resource. Handles quantity changes:
24988
+ * - Increasing quantity: creates new instances
24989
+ * - Decreasing quantity: blocked if affected instances have future bookings
24990
+ */
24991
+ async updateResource(clinicBranchId, resourceId, data) {
24992
+ const existing = await this.getResource(clinicBranchId, resourceId);
24993
+ if (!existing) throw new Error(`Resource ${resourceId} not found`);
24994
+ const updateData = {
24995
+ updatedAt: (0, import_firestore64.serverTimestamp)()
24996
+ };
24997
+ if (data.name !== void 0) {
24998
+ updateData.name = data.name;
24999
+ updateData.nameLower = data.name.toLowerCase();
25000
+ }
25001
+ if (data.category !== void 0) updateData.category = data.category;
25002
+ if (data.description !== void 0)
25003
+ updateData.description = data.description;
25004
+ if (data.status !== void 0) updateData.status = data.status;
25005
+ if (data.quantity !== void 0 && data.quantity !== existing.quantity) {
25006
+ if (data.quantity > existing.quantity) {
25007
+ const batch = (0, import_firestore64.writeBatch)(this.db);
25008
+ const now = (0, import_firestore64.serverTimestamp)();
25009
+ const resourceName = data.name || existing.name;
25010
+ for (let i = existing.quantity + 1; i <= data.quantity; i++) {
25011
+ const instanceRef = (0, import_firestore64.doc)(
25012
+ this.getInstancesRef(clinicBranchId, resourceId)
25013
+ );
25014
+ const instanceData = {
25015
+ id: instanceRef.id,
25016
+ resourceId,
25017
+ clinicBranchId,
25018
+ label: `${resourceName} #${i}`,
25019
+ index: i,
25020
+ status: "active" /* ACTIVE */,
25021
+ createdAt: now,
25022
+ updatedAt: now
25023
+ };
25024
+ batch.set(instanceRef, instanceData);
25025
+ }
25026
+ updateData.quantity = data.quantity;
25027
+ const resourceDocRef2 = this.getResourceDocRef(
25028
+ clinicBranchId,
25029
+ resourceId
25030
+ );
25031
+ batch.update(resourceDocRef2, updateData);
25032
+ await batch.commit();
25033
+ const updated2 = await this.getResource(clinicBranchId, resourceId);
25034
+ if (!updated2) throw new Error("Failed to read updated resource");
25035
+ return updated2;
25036
+ } else {
25037
+ const instances = await this.getResourceInstances(
25038
+ clinicBranchId,
25039
+ resourceId
25040
+ );
25041
+ const instancesToRemove = instances.filter((inst) => inst.index > data.quantity).filter((inst) => inst.status === "active" /* ACTIVE */);
25042
+ for (const instance of instancesToRemove) {
25043
+ const hasFutureBookings = await this.instanceHasFutureBookings(
25044
+ clinicBranchId,
25045
+ resourceId,
25046
+ instance.id
25047
+ );
25048
+ if (hasFutureBookings) {
25049
+ throw new Error(
25050
+ `Cannot reduce quantity: instance "${instance.label}" has future bookings. Cancel those bookings first.`
25051
+ );
25052
+ }
25053
+ }
25054
+ const batch = (0, import_firestore64.writeBatch)(this.db);
25055
+ for (const instance of instancesToRemove) {
25056
+ const instanceRef = (0, import_firestore64.doc)(
25057
+ this.getInstancesRef(clinicBranchId, resourceId),
25058
+ instance.id
25059
+ );
25060
+ batch.update(instanceRef, {
25061
+ status: "inactive" /* INACTIVE */,
25062
+ updatedAt: (0, import_firestore64.serverTimestamp)()
25063
+ });
25064
+ }
25065
+ updateData.quantity = data.quantity;
25066
+ const resourceDocRef2 = this.getResourceDocRef(
25067
+ clinicBranchId,
25068
+ resourceId
25069
+ );
25070
+ batch.update(resourceDocRef2, updateData);
25071
+ await batch.commit();
25072
+ const updated2 = await this.getResource(clinicBranchId, resourceId);
25073
+ if (!updated2) throw new Error("Failed to read updated resource");
25074
+ return updated2;
25075
+ }
25076
+ }
25077
+ const resourceDocRef = this.getResourceDocRef(clinicBranchId, resourceId);
25078
+ await (0, import_firestore64.updateDoc)(resourceDocRef, updateData);
25079
+ const updated = await this.getResource(clinicBranchId, resourceId);
25080
+ if (!updated) throw new Error("Failed to read updated resource");
25081
+ return updated;
25082
+ }
25083
+ /**
25084
+ * Soft deletes a resource by setting status to INACTIVE
25085
+ */
25086
+ async deleteResource(clinicBranchId, resourceId) {
25087
+ await this.updateResource(clinicBranchId, resourceId, {
25088
+ status: "inactive" /* INACTIVE */
25089
+ });
25090
+ }
25091
+ /**
25092
+ * Gets all instances for a resource
25093
+ */
25094
+ async getResourceInstances(clinicBranchId, resourceId) {
25095
+ const q = (0, import_firestore64.query)(
25096
+ this.getInstancesRef(clinicBranchId, resourceId),
25097
+ (0, import_firestore64.orderBy)("index")
25098
+ );
25099
+ const snapshot = await (0, import_firestore64.getDocs)(q);
25100
+ return snapshot.docs.map(
25101
+ (d) => ({ id: d.id, ...d.data() })
25102
+ );
25103
+ }
25104
+ /**
25105
+ * Gets active instances for a resource
25106
+ */
25107
+ async getActiveResourceInstances(clinicBranchId, resourceId) {
25108
+ const q = (0, import_firestore64.query)(
25109
+ this.getInstancesRef(clinicBranchId, resourceId),
25110
+ (0, import_firestore64.where)("status", "==", "active" /* ACTIVE */),
25111
+ (0, import_firestore64.orderBy)("index")
25112
+ );
25113
+ const snapshot = await (0, import_firestore64.getDocs)(q);
25114
+ return snapshot.docs.map(
25115
+ (d) => ({ id: d.id, ...d.data() })
25116
+ );
25117
+ }
25118
+ /**
25119
+ * Gets calendar events for a specific resource instance within a time range
25120
+ */
25121
+ async getResourceCalendarEvents(clinicBranchId, resourceId, instanceId, start, end) {
25122
+ const calendarRef = this.getInstanceCalendarRef(
25123
+ clinicBranchId,
25124
+ resourceId,
25125
+ instanceId
25126
+ );
25127
+ const q = (0, import_firestore64.query)(
25128
+ calendarRef,
25129
+ (0, import_firestore64.where)("eventTime.start", ">=", start),
25130
+ (0, import_firestore64.where)("eventTime.start", "<=", end),
25131
+ (0, import_firestore64.orderBy)("eventTime.start")
25132
+ );
25133
+ const snapshot = await (0, import_firestore64.getDocs)(q);
25134
+ return snapshot.docs.map(
25135
+ (d) => ({ id: d.id, ...d.data() })
25136
+ );
25137
+ }
25138
+ /**
25139
+ * Checks if a resource instance has any future active bookings
25140
+ */
25141
+ async instanceHasFutureBookings(clinicBranchId, resourceId, instanceId) {
25142
+ const now = import_firestore64.Timestamp.now();
25143
+ const calendarRef = this.getInstanceCalendarRef(
25144
+ clinicBranchId,
25145
+ resourceId,
25146
+ instanceId
25147
+ );
25148
+ const q = (0, import_firestore64.query)(
25149
+ calendarRef,
25150
+ (0, import_firestore64.where)("eventTime.start", ">=", now),
25151
+ (0, import_firestore64.where)("status", "in", ["pending", "confirmed"])
25152
+ );
25153
+ const snapshot = await (0, import_firestore64.getDocs)(q);
25154
+ return !snapshot.empty;
25155
+ }
25156
+ // --- Resource Instance Blocking Events ---
25157
+ /**
25158
+ * Creates a blocking event on a resource instance's calendar.
25159
+ * Blocking events prevent the instance from being booked during the specified time.
25160
+ */
25161
+ async createResourceBlockingEvent(params) {
25162
+ createResourceBlockingEventSchema.parse(params);
25163
+ const calendarRef = this.getInstanceCalendarRef(
25164
+ params.clinicBranchId,
25165
+ params.resourceId,
25166
+ params.resourceInstanceId
25167
+ );
25168
+ const eventRef = (0, import_firestore64.doc)(calendarRef);
25169
+ const now = (0, import_firestore64.serverTimestamp)();
25170
+ const eventData = {
25171
+ id: eventRef.id,
25172
+ resourceId: params.resourceId,
25173
+ resourceInstanceId: params.resourceInstanceId,
25174
+ clinicBranchId: params.clinicBranchId,
25175
+ eventType: "blocking" /* BLOCKING */,
25176
+ eventName: params.eventName,
25177
+ eventTime: params.eventTime,
25178
+ status: "confirmed" /* CONFIRMED */,
25179
+ description: params.description || "",
25180
+ createdAt: now,
25181
+ updatedAt: now
25182
+ };
25183
+ await (0, import_firestore64.setDoc)(eventRef, eventData);
25184
+ return {
25185
+ ...eventData,
25186
+ createdAt: import_firestore64.Timestamp.now(),
25187
+ updatedAt: import_firestore64.Timestamp.now()
25188
+ };
25189
+ }
25190
+ /**
25191
+ * Updates an existing blocking event on a resource instance's calendar.
25192
+ * Only provided fields are updated.
25193
+ */
25194
+ async updateResourceBlockingEvent(params) {
25195
+ updateResourceBlockingEventSchema.parse(params);
25196
+ const calendarRef = this.getInstanceCalendarRef(
25197
+ params.clinicBranchId,
25198
+ params.resourceId,
25199
+ params.resourceInstanceId
25200
+ );
25201
+ const eventRef = (0, import_firestore64.doc)(calendarRef, params.eventId);
25202
+ const eventSnap = await (0, import_firestore64.getDoc)(eventRef);
25203
+ if (!eventSnap.exists()) {
25204
+ throw new Error(`Blocking event ${params.eventId} not found`);
25205
+ }
25206
+ const updateData = {
25207
+ updatedAt: (0, import_firestore64.serverTimestamp)()
25208
+ };
25209
+ if (params.eventName !== void 0) {
25210
+ updateData.eventName = params.eventName;
25211
+ }
25212
+ if (params.eventTime !== void 0) {
25213
+ updateData.eventTime = params.eventTime;
25214
+ }
25215
+ if (params.description !== void 0) {
25216
+ updateData.description = params.description;
25217
+ }
25218
+ await (0, import_firestore64.updateDoc)(eventRef, updateData);
25219
+ const updatedSnap = await (0, import_firestore64.getDoc)(eventRef);
25220
+ return { id: updatedSnap.id, ...updatedSnap.data() };
25221
+ }
25222
+ /**
25223
+ * Deletes a blocking event from a resource instance's calendar (hard delete).
25224
+ */
25225
+ async deleteResourceBlockingEvent(clinicBranchId, resourceId, instanceId, eventId) {
25226
+ const calendarRef = this.getInstanceCalendarRef(
25227
+ clinicBranchId,
25228
+ resourceId,
25229
+ instanceId
25230
+ );
25231
+ const eventRef = (0, import_firestore64.doc)(calendarRef, eventId);
25232
+ const eventSnap = await (0, import_firestore64.getDoc)(eventRef);
25233
+ if (!eventSnap.exists()) {
25234
+ throw new Error(`Blocking event ${eventId} not found`);
25235
+ }
25236
+ await (0, import_firestore64.deleteDoc)(eventRef);
25237
+ }
25238
+ /**
25239
+ * Gets all blocking events for a resource instance, ordered by start time.
25240
+ */
25241
+ async getResourceInstanceBlockingEvents(clinicBranchId, resourceId, instanceId) {
25242
+ const calendarRef = this.getInstanceCalendarRef(
25243
+ clinicBranchId,
25244
+ resourceId,
25245
+ instanceId
25246
+ );
25247
+ const q = (0, import_firestore64.query)(
25248
+ calendarRef,
25249
+ (0, import_firestore64.where)("eventType", "==", "blocking" /* BLOCKING */),
25250
+ (0, import_firestore64.orderBy)("eventTime.start")
25251
+ );
25252
+ const snapshot = await (0, import_firestore64.getDocs)(q);
25253
+ return snapshot.docs.map(
25254
+ (d) => ({ id: d.id, ...d.data() })
25255
+ );
25256
+ }
25257
+ };
25258
+
25259
+ // src/services/reviews/reviews.service.ts
25260
+ var import_firestore65 = require("firebase/firestore");
25261
+ var import_zod32 = require("zod");
24756
25262
  var ReviewService = class extends BaseService {
24757
25263
  constructor(db, auth, app) {
24758
25264
  super(db, auth, app);
@@ -24904,16 +25410,16 @@ var ReviewService = class extends BaseService {
24904
25410
  reviewSchema.parse(review);
24905
25411
  const firestoreData = {
24906
25412
  ...review,
24907
- createdAt: (0, import_firestore64.serverTimestamp)(),
24908
- updatedAt: (0, import_firestore64.serverTimestamp)()
25413
+ createdAt: (0, import_firestore65.serverTimestamp)(),
25414
+ updatedAt: (0, import_firestore65.serverTimestamp)()
24909
25415
  };
24910
25416
  Object.keys(firestoreData).forEach((key) => {
24911
25417
  if (firestoreData[key] === void 0) {
24912
25418
  delete firestoreData[key];
24913
25419
  }
24914
25420
  });
24915
- const docRef = (0, import_firestore64.doc)(this.db, REVIEWS_COLLECTION, reviewId);
24916
- await (0, import_firestore64.setDoc)(docRef, firestoreData);
25421
+ const docRef = (0, import_firestore65.doc)(this.db, REVIEWS_COLLECTION, reviewId);
25422
+ await (0, import_firestore65.setDoc)(docRef, firestoreData);
24917
25423
  console.log("\u2705 ReviewService.createReview - Review saved to Firestore:", {
24918
25424
  reviewId,
24919
25425
  practitionerId: (_e = review.practitionerReview) == null ? void 0 : _e.practitionerId,
@@ -24923,7 +25429,7 @@ var ReviewService = class extends BaseService {
24923
25429
  });
24924
25430
  return review;
24925
25431
  } catch (error) {
24926
- if (error instanceof import_zod31.z.ZodError) {
25432
+ if (error instanceof import_zod32.z.ZodError) {
24927
25433
  throw new Error(`Invalid review data: ${error.message}`);
24928
25434
  }
24929
25435
  throw error;
@@ -24937,16 +25443,16 @@ var ReviewService = class extends BaseService {
24937
25443
  async getReview(reviewId) {
24938
25444
  var _a, _b, _c, _d, _e;
24939
25445
  console.log("\u{1F50D} ReviewService.getReview - Getting review:", reviewId);
24940
- const docRef = (0, import_firestore64.doc)(this.db, REVIEWS_COLLECTION, reviewId);
24941
- const docSnap = await (0, import_firestore64.getDoc)(docRef);
25446
+ const docRef = (0, import_firestore65.doc)(this.db, REVIEWS_COLLECTION, reviewId);
25447
+ const docSnap = await (0, import_firestore65.getDoc)(docRef);
24942
25448
  if (!docSnap.exists()) {
24943
25449
  console.log("\u274C ReviewService.getReview - Review not found:", reviewId);
24944
25450
  return null;
24945
25451
  }
24946
25452
  const review = { ...this.convertDocToReview(docSnap.data()), id: reviewId };
24947
25453
  try {
24948
- const appointmentDoc = await (0, import_firestore64.getDoc)(
24949
- (0, import_firestore64.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25454
+ const appointmentDoc = await (0, import_firestore65.getDoc)(
25455
+ (0, import_firestore65.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
24950
25456
  );
24951
25457
  if (appointmentDoc.exists()) {
24952
25458
  const appointment = appointmentDoc.data();
@@ -25006,14 +25512,14 @@ var ReviewService = class extends BaseService {
25006
25512
  * @returns Array of reviews for the patient with clinic, practitioner, and procedure names
25007
25513
  */
25008
25514
  async getReviewsByPatient(patientId) {
25009
- const q = (0, import_firestore64.query)((0, import_firestore64.collection)(this.db, REVIEWS_COLLECTION), (0, import_firestore64.where)("patientId", "==", patientId));
25010
- const snapshot = await (0, import_firestore64.getDocs)(q);
25011
- const reviews = snapshot.docs.map((doc52) => this.convertDocToReview(doc52.data()));
25515
+ const q = (0, import_firestore65.query)((0, import_firestore65.collection)(this.db, REVIEWS_COLLECTION), (0, import_firestore65.where)("patientId", "==", patientId));
25516
+ const snapshot = await (0, import_firestore65.getDocs)(q);
25517
+ const reviews = snapshot.docs.map((doc53) => this.convertDocToReview(doc53.data()));
25012
25518
  const enhancedReviews = await Promise.all(
25013
25519
  reviews.map(async (review) => {
25014
25520
  try {
25015
- const appointmentDoc = await (0, import_firestore64.getDoc)(
25016
- (0, import_firestore64.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25521
+ const appointmentDoc = await (0, import_firestore65.getDoc)(
25522
+ (0, import_firestore65.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25017
25523
  );
25018
25524
  if (appointmentDoc.exists()) {
25019
25525
  const appointment = appointmentDoc.data();
@@ -25057,14 +25563,14 @@ var ReviewService = class extends BaseService {
25057
25563
  */
25058
25564
  async getReviewsByClinic(clinicId) {
25059
25565
  console.log("\u{1F50D} ReviewService.getReviewsByClinic - Querying for clinic:", clinicId);
25060
- const q = (0, import_firestore64.query)(
25061
- (0, import_firestore64.collection)(this.db, REVIEWS_COLLECTION),
25062
- (0, import_firestore64.where)("clinicReview.clinicId", "==", clinicId)
25063
- );
25064
- const snapshot = await (0, import_firestore64.getDocs)(q);
25065
- const reviews = snapshot.docs.map((doc52) => {
25066
- const review = this.convertDocToReview(doc52.data());
25067
- return { ...review, id: doc52.id };
25566
+ const q = (0, import_firestore65.query)(
25567
+ (0, import_firestore65.collection)(this.db, REVIEWS_COLLECTION),
25568
+ (0, import_firestore65.where)("clinicReview.clinicId", "==", clinicId)
25569
+ );
25570
+ const snapshot = await (0, import_firestore65.getDocs)(q);
25571
+ const reviews = snapshot.docs.map((doc53) => {
25572
+ const review = this.convertDocToReview(doc53.data());
25573
+ return { ...review, id: doc53.id };
25068
25574
  });
25069
25575
  console.log("\u{1F50D} ReviewService.getReviewsByClinic - Found reviews before enhancement:", {
25070
25576
  clinicId,
@@ -25074,8 +25580,8 @@ var ReviewService = class extends BaseService {
25074
25580
  const enhancedReviews = await Promise.all(
25075
25581
  reviews.map(async (review) => {
25076
25582
  try {
25077
- const appointmentDoc = await (0, import_firestore64.getDoc)(
25078
- (0, import_firestore64.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25583
+ const appointmentDoc = await (0, import_firestore65.getDoc)(
25584
+ (0, import_firestore65.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25079
25585
  );
25080
25586
  if (appointmentDoc.exists()) {
25081
25587
  const appointment = appointmentDoc.data();
@@ -25133,14 +25639,14 @@ var ReviewService = class extends BaseService {
25133
25639
  "\u{1F50D} ReviewService.getReviewsByPractitioner - Querying for practitioner:",
25134
25640
  practitionerId
25135
25641
  );
25136
- const q = (0, import_firestore64.query)(
25137
- (0, import_firestore64.collection)(this.db, REVIEWS_COLLECTION),
25138
- (0, import_firestore64.where)("practitionerReview.practitionerId", "==", practitionerId)
25642
+ const q = (0, import_firestore65.query)(
25643
+ (0, import_firestore65.collection)(this.db, REVIEWS_COLLECTION),
25644
+ (0, import_firestore65.where)("practitionerReview.practitionerId", "==", practitionerId)
25139
25645
  );
25140
- const snapshot = await (0, import_firestore64.getDocs)(q);
25141
- const reviews = snapshot.docs.map((doc52) => {
25142
- const review = this.convertDocToReview(doc52.data());
25143
- return { ...review, id: doc52.id };
25646
+ const snapshot = await (0, import_firestore65.getDocs)(q);
25647
+ const reviews = snapshot.docs.map((doc53) => {
25648
+ const review = this.convertDocToReview(doc53.data());
25649
+ return { ...review, id: doc53.id };
25144
25650
  });
25145
25651
  console.log("\u{1F50D} ReviewService.getReviewsByPractitioner - Found reviews before enhancement:", {
25146
25652
  practitionerId,
@@ -25150,8 +25656,8 @@ var ReviewService = class extends BaseService {
25150
25656
  const enhancedReviews = await Promise.all(
25151
25657
  reviews.map(async (review) => {
25152
25658
  try {
25153
- const appointmentDoc = await (0, import_firestore64.getDoc)(
25154
- (0, import_firestore64.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25659
+ const appointmentDoc = await (0, import_firestore65.getDoc)(
25660
+ (0, import_firestore65.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25155
25661
  );
25156
25662
  if (appointmentDoc.exists()) {
25157
25663
  const appointment = appointmentDoc.data();
@@ -25206,14 +25712,14 @@ var ReviewService = class extends BaseService {
25206
25712
  */
25207
25713
  async getReviewsByProcedure(procedureId) {
25208
25714
  console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Querying for procedure:", procedureId);
25209
- const q = (0, import_firestore64.query)(
25210
- (0, import_firestore64.collection)(this.db, REVIEWS_COLLECTION),
25211
- (0, import_firestore64.where)("procedureReview.procedureId", "==", procedureId)
25212
- );
25213
- const snapshot = await (0, import_firestore64.getDocs)(q);
25214
- const reviews = snapshot.docs.map((doc52) => {
25215
- const data = doc52.data();
25216
- return { ...data, id: doc52.id };
25715
+ const q = (0, import_firestore65.query)(
25716
+ (0, import_firestore65.collection)(this.db, REVIEWS_COLLECTION),
25717
+ (0, import_firestore65.where)("procedureReview.procedureId", "==", procedureId)
25718
+ );
25719
+ const snapshot = await (0, import_firestore65.getDocs)(q);
25720
+ const reviews = snapshot.docs.map((doc53) => {
25721
+ const data = doc53.data();
25722
+ return { ...data, id: doc53.id };
25217
25723
  });
25218
25724
  console.log("\u{1F50D} ReviewService.getReviewsByProcedure - Found reviews before enhancement:", {
25219
25725
  procedureId,
@@ -25223,8 +25729,8 @@ var ReviewService = class extends BaseService {
25223
25729
  const enhancedReviews = await Promise.all(
25224
25730
  reviews.map(async (review) => {
25225
25731
  try {
25226
- const appointmentDoc = await (0, import_firestore64.getDoc)(
25227
- (0, import_firestore64.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25732
+ const appointmentDoc = await (0, import_firestore65.getDoc)(
25733
+ (0, import_firestore65.doc)(this.db, APPOINTMENTS_COLLECTION, review.appointmentId)
25228
25734
  );
25229
25735
  if (appointmentDoc.exists()) {
25230
25736
  const appointment = appointmentDoc.data();
@@ -25278,11 +25784,11 @@ var ReviewService = class extends BaseService {
25278
25784
  * @returns The review for the appointment if found, null otherwise
25279
25785
  */
25280
25786
  async getReviewByAppointment(appointmentId) {
25281
- const q = (0, import_firestore64.query)(
25282
- (0, import_firestore64.collection)(this.db, REVIEWS_COLLECTION),
25283
- (0, import_firestore64.where)("appointmentId", "==", appointmentId)
25787
+ const q = (0, import_firestore65.query)(
25788
+ (0, import_firestore65.collection)(this.db, REVIEWS_COLLECTION),
25789
+ (0, import_firestore65.where)("appointmentId", "==", appointmentId)
25284
25790
  );
25285
- const snapshot = await (0, import_firestore64.getDocs)(q);
25791
+ const snapshot = await (0, import_firestore65.getDocs)(q);
25286
25792
  if (snapshot.empty) {
25287
25793
  return null;
25288
25794
  }
@@ -25297,7 +25803,7 @@ var ReviewService = class extends BaseService {
25297
25803
  if (!review) {
25298
25804
  throw new Error(`Review with ID ${reviewId} not found`);
25299
25805
  }
25300
- await (0, import_firestore64.deleteDoc)((0, import_firestore64.doc)(this.db, REVIEWS_COLLECTION, reviewId));
25806
+ await (0, import_firestore65.deleteDoc)((0, import_firestore65.doc)(this.db, REVIEWS_COLLECTION, reviewId));
25301
25807
  }
25302
25808
  /**
25303
25809
  * Calculates the average of an array of numbers
@@ -25316,7 +25822,7 @@ var ReviewService = class extends BaseService {
25316
25822
 
25317
25823
  // src/config/firebase.ts
25318
25824
  var import_app = require("firebase/app");
25319
- var import_firestore65 = require("firebase/firestore");
25825
+ var import_firestore66 = require("firebase/firestore");
25320
25826
  var import_auth14 = require("firebase/auth");
25321
25827
  var import_analytics2 = require("firebase/analytics");
25322
25828
  var import_react_native = require("react-native");
@@ -25326,7 +25832,7 @@ var firebaseInstance = null;
25326
25832
  var initializeFirebase = (config) => {
25327
25833
  if (!firebaseInstance) {
25328
25834
  const app = (0, import_app.initializeApp)(config);
25329
- const db = (0, import_firestore65.getFirestore)(app);
25835
+ const db = (0, import_firestore66.getFirestore)(app);
25330
25836
  const auth = (0, import_auth14.getAuth)(app);
25331
25837
  const storage = (0, import_storage4.getStorage)(app);
25332
25838
  const functions = (0, import_functions4.getFunctions)(app);
@@ -25368,7 +25874,7 @@ var getFirebaseFunctions = async () => {
25368
25874
  };
25369
25875
 
25370
25876
  // src/backoffice/services/brand.service.ts
25371
- var import_firestore66 = require("firebase/firestore");
25877
+ var import_firestore67 = require("firebase/firestore");
25372
25878
 
25373
25879
  // src/backoffice/types/brand.types.ts
25374
25880
  var BRANDS_COLLECTION = "brands";
@@ -25379,7 +25885,7 @@ var BrandService = class extends BaseService {
25379
25885
  * Gets reference to brands collection
25380
25886
  */
25381
25887
  getBrandsRef() {
25382
- return (0, import_firestore66.collection)(this.db, BRANDS_COLLECTION);
25888
+ return (0, import_firestore67.collection)(this.db, BRANDS_COLLECTION);
25383
25889
  }
25384
25890
  /**
25385
25891
  * Creates a new brand
@@ -25393,7 +25899,7 @@ var BrandService = class extends BaseService {
25393
25899
  updatedAt: now,
25394
25900
  isActive: true
25395
25901
  };
25396
- const docRef = await (0, import_firestore66.addDoc)(this.getBrandsRef(), newBrand);
25902
+ const docRef = await (0, import_firestore67.addDoc)(this.getBrandsRef(), newBrand);
25397
25903
  return { id: docRef.id, ...newBrand };
25398
25904
  }
25399
25905
  /**
@@ -25404,26 +25910,26 @@ var BrandService = class extends BaseService {
25404
25910
  */
25405
25911
  async getAll(rowsPerPage, searchTerm, lastVisible) {
25406
25912
  const constraints = [
25407
- (0, import_firestore66.where)("isActive", "==", true),
25408
- (0, import_firestore66.orderBy)("name_lowercase")
25913
+ (0, import_firestore67.where)("isActive", "==", true),
25914
+ (0, import_firestore67.orderBy)("name_lowercase")
25409
25915
  ];
25410
25916
  if (searchTerm) {
25411
25917
  const lowercasedSearchTerm = searchTerm.toLowerCase();
25412
- constraints.push((0, import_firestore66.where)("name_lowercase", ">=", lowercasedSearchTerm));
25918
+ constraints.push((0, import_firestore67.where)("name_lowercase", ">=", lowercasedSearchTerm));
25413
25919
  constraints.push(
25414
- (0, import_firestore66.where)("name_lowercase", "<=", lowercasedSearchTerm + "\uF8FF")
25920
+ (0, import_firestore67.where)("name_lowercase", "<=", lowercasedSearchTerm + "\uF8FF")
25415
25921
  );
25416
25922
  }
25417
25923
  if (lastVisible) {
25418
- constraints.push((0, import_firestore66.startAfter)(lastVisible));
25924
+ constraints.push((0, import_firestore67.startAfter)(lastVisible));
25419
25925
  }
25420
- constraints.push((0, import_firestore66.limit)(rowsPerPage));
25421
- const q = (0, import_firestore66.query)(this.getBrandsRef(), ...constraints);
25422
- const snapshot = await (0, import_firestore66.getDocs)(q);
25926
+ constraints.push((0, import_firestore67.limit)(rowsPerPage));
25927
+ const q = (0, import_firestore67.query)(this.getBrandsRef(), ...constraints);
25928
+ const snapshot = await (0, import_firestore67.getDocs)(q);
25423
25929
  const brands = snapshot.docs.map(
25424
- (doc52) => ({
25425
- id: doc52.id,
25426
- ...doc52.data()
25930
+ (doc53) => ({
25931
+ id: doc53.id,
25932
+ ...doc53.data()
25427
25933
  })
25428
25934
  );
25429
25935
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -25434,32 +25940,32 @@ var BrandService = class extends BaseService {
25434
25940
  * @param searchTerm - An optional string to filter brand names by (starts-with search).
25435
25941
  */
25436
25942
  async getBrandsCount(searchTerm) {
25437
- const constraints = [(0, import_firestore66.where)("isActive", "==", true)];
25943
+ const constraints = [(0, import_firestore67.where)("isActive", "==", true)];
25438
25944
  if (searchTerm) {
25439
25945
  const lowercasedSearchTerm = searchTerm.toLowerCase();
25440
- constraints.push((0, import_firestore66.where)("name_lowercase", ">=", lowercasedSearchTerm));
25946
+ constraints.push((0, import_firestore67.where)("name_lowercase", ">=", lowercasedSearchTerm));
25441
25947
  constraints.push(
25442
- (0, import_firestore66.where)("name_lowercase", "<=", lowercasedSearchTerm + "\uF8FF")
25948
+ (0, import_firestore67.where)("name_lowercase", "<=", lowercasedSearchTerm + "\uF8FF")
25443
25949
  );
25444
25950
  }
25445
- const q = (0, import_firestore66.query)(this.getBrandsRef(), ...constraints);
25446
- const snapshot = await (0, import_firestore66.getCountFromServer)(q);
25951
+ const q = (0, import_firestore67.query)(this.getBrandsRef(), ...constraints);
25952
+ const snapshot = await (0, import_firestore67.getCountFromServer)(q);
25447
25953
  return snapshot.data().count;
25448
25954
  }
25449
25955
  /**
25450
25956
  * Gets all active brands for filter dropdowns (not paginated).
25451
25957
  */
25452
25958
  async getAllForFilter() {
25453
- const q = (0, import_firestore66.query)(
25959
+ const q = (0, import_firestore67.query)(
25454
25960
  this.getBrandsRef(),
25455
- (0, import_firestore66.where)("isActive", "==", true),
25456
- (0, import_firestore66.orderBy)("name")
25961
+ (0, import_firestore67.where)("isActive", "==", true),
25962
+ (0, import_firestore67.orderBy)("name")
25457
25963
  );
25458
- const snapshot = await (0, import_firestore66.getDocs)(q);
25964
+ const snapshot = await (0, import_firestore67.getDocs)(q);
25459
25965
  return snapshot.docs.map(
25460
- (doc52) => ({
25461
- id: doc52.id,
25462
- ...doc52.data()
25966
+ (doc53) => ({
25967
+ id: doc53.id,
25968
+ ...doc53.data()
25463
25969
  })
25464
25970
  );
25465
25971
  }
@@ -25474,8 +25980,8 @@ var BrandService = class extends BaseService {
25474
25980
  if (brand.name) {
25475
25981
  updateData.name_lowercase = brand.name.toLowerCase();
25476
25982
  }
25477
- const docRef = (0, import_firestore66.doc)(this.getBrandsRef(), brandId);
25478
- await (0, import_firestore66.updateDoc)(docRef, updateData);
25983
+ const docRef = (0, import_firestore67.doc)(this.getBrandsRef(), brandId);
25984
+ await (0, import_firestore67.updateDoc)(docRef, updateData);
25479
25985
  return this.getById(brandId);
25480
25986
  }
25481
25987
  /**
@@ -25490,8 +25996,8 @@ var BrandService = class extends BaseService {
25490
25996
  * Gets a brand by ID
25491
25997
  */
25492
25998
  async getById(brandId) {
25493
- const docRef = (0, import_firestore66.doc)(this.getBrandsRef(), brandId);
25494
- const docSnap = await (0, import_firestore66.getDoc)(docRef);
25999
+ const docRef = (0, import_firestore67.doc)(this.getBrandsRef(), brandId);
26000
+ const docSnap = await (0, import_firestore67.getDoc)(docRef);
25495
26001
  if (!docSnap.exists()) return null;
25496
26002
  return {
25497
26003
  id: docSnap.id,
@@ -25521,14 +26027,14 @@ var BrandService = class extends BaseService {
25521
26027
  let cursor;
25522
26028
  const baseConstraints = [];
25523
26029
  if (!includeInactive) {
25524
- baseConstraints.push((0, import_firestore66.where)("isActive", "==", true));
26030
+ baseConstraints.push((0, import_firestore67.where)("isActive", "==", true));
25525
26031
  }
25526
- baseConstraints.push((0, import_firestore66.orderBy)("name_lowercase"));
26032
+ baseConstraints.push((0, import_firestore67.orderBy)("name_lowercase"));
25527
26033
  while (true) {
25528
- const constraints = [...baseConstraints, (0, import_firestore66.limit)(PAGE_SIZE)];
25529
- if (cursor) constraints.push((0, import_firestore66.startAfter)(cursor));
25530
- const q = (0, import_firestore66.query)(this.getBrandsRef(), ...constraints);
25531
- const snapshot = await (0, import_firestore66.getDocs)(q);
26034
+ const constraints = [...baseConstraints, (0, import_firestore67.limit)(PAGE_SIZE)];
26035
+ if (cursor) constraints.push((0, import_firestore67.startAfter)(cursor));
26036
+ const q = (0, import_firestore67.query)(this.getBrandsRef(), ...constraints);
26037
+ const snapshot = await (0, import_firestore67.getDocs)(q);
25532
26038
  if (snapshot.empty) break;
25533
26039
  for (const d of snapshot.docs) {
25534
26040
  const brand = { id: d.id, ...d.data() };
@@ -25568,7 +26074,7 @@ var BrandService = class extends BaseService {
25568
26074
  };
25569
26075
 
25570
26076
  // src/backoffice/services/category.service.ts
25571
- var import_firestore67 = require("firebase/firestore");
26077
+ var import_firestore68 = require("firebase/firestore");
25572
26078
 
25573
26079
  // src/backoffice/types/category.types.ts
25574
26080
  var CATEGORIES_COLLECTION = "backoffice_categories";
@@ -25588,7 +26094,7 @@ var CategoryService = class extends BaseService {
25588
26094
  * Referenca na Firestore kolekciju kategorija
25589
26095
  */
25590
26096
  get categoriesRef() {
25591
- return (0, import_firestore67.collection)(this.db, CATEGORIES_COLLECTION);
26097
+ return (0, import_firestore68.collection)(this.db, CATEGORIES_COLLECTION);
25592
26098
  }
25593
26099
  /**
25594
26100
  * Kreira novu kategoriju u sistemu
@@ -25603,7 +26109,7 @@ var CategoryService = class extends BaseService {
25603
26109
  updatedAt: now,
25604
26110
  isActive: true
25605
26111
  };
25606
- const docRef = await (0, import_firestore67.addDoc)(this.categoriesRef, newCategory);
26112
+ const docRef = await (0, import_firestore68.addDoc)(this.categoriesRef, newCategory);
25607
26113
  return { id: docRef.id, ...newCategory };
25608
26114
  }
25609
26115
  /**
@@ -25615,13 +26121,13 @@ var CategoryService = class extends BaseService {
25615
26121
  const counts = {};
25616
26122
  const families = Object.values(ProcedureFamily);
25617
26123
  for (const family of families) {
25618
- const q = (0, import_firestore67.query)(
26124
+ const q = (0, import_firestore68.query)(
25619
26125
  this.categoriesRef,
25620
- (0, import_firestore67.where)("family", "==", family),
25621
- (0, import_firestore67.where)("isActive", "==", active)
26126
+ (0, import_firestore68.where)("family", "==", family),
26127
+ (0, import_firestore68.where)("isActive", "==", active)
25622
26128
  );
25623
- const snapshot = await (0, import_firestore67.getDocs)(q);
25624
- const filteredDocs = snapshot.docs.filter((doc52) => doc52.id !== EXCLUDED_CATEGORY_ID);
26129
+ const snapshot = await (0, import_firestore68.getDocs)(q);
26130
+ const filteredDocs = snapshot.docs.filter((doc53) => doc53.id !== EXCLUDED_CATEGORY_ID);
25625
26131
  counts[family] = filteredDocs.length;
25626
26132
  }
25627
26133
  return counts;
@@ -25631,12 +26137,12 @@ var CategoryService = class extends BaseService {
25631
26137
  * @returns Lista svih aktivnih kategorija
25632
26138
  */
25633
26139
  async getAllForFilter() {
25634
- const q = (0, import_firestore67.query)(this.categoriesRef, (0, import_firestore67.where)("isActive", "==", true));
25635
- const snapshot = await (0, import_firestore67.getDocs)(q);
26140
+ const q = (0, import_firestore68.query)(this.categoriesRef, (0, import_firestore68.where)("isActive", "==", true));
26141
+ const snapshot = await (0, import_firestore68.getDocs)(q);
25636
26142
  const categories = snapshot.docs.map(
25637
- (doc52) => ({
25638
- id: doc52.id,
25639
- ...doc52.data()
26143
+ (doc53) => ({
26144
+ id: doc53.id,
26145
+ ...doc53.data()
25640
26146
  })
25641
26147
  );
25642
26148
  return this.filterExcludedCategories(categories);
@@ -25647,17 +26153,17 @@ var CategoryService = class extends BaseService {
25647
26153
  * @returns Lista aktivnih kategorija koje pripadaju traženoj familiji
25648
26154
  */
25649
26155
  async getAllForFilterByFamily(family) {
25650
- const q = (0, import_firestore67.query)(
26156
+ const q = (0, import_firestore68.query)(
25651
26157
  this.categoriesRef,
25652
- (0, import_firestore67.where)("family", "==", family),
25653
- (0, import_firestore67.where)("isActive", "==", true),
25654
- (0, import_firestore67.orderBy)("name")
26158
+ (0, import_firestore68.where)("family", "==", family),
26159
+ (0, import_firestore68.where)("isActive", "==", true),
26160
+ (0, import_firestore68.orderBy)("name")
25655
26161
  );
25656
- const snapshot = await (0, import_firestore67.getDocs)(q);
26162
+ const snapshot = await (0, import_firestore68.getDocs)(q);
25657
26163
  const categories = snapshot.docs.map(
25658
- (doc52) => ({
25659
- id: doc52.id,
25660
- ...doc52.data()
26164
+ (doc53) => ({
26165
+ id: doc53.id,
26166
+ ...doc53.data()
25661
26167
  })
25662
26168
  );
25663
26169
  return this.filterExcludedCategories(categories);
@@ -25670,17 +26176,17 @@ var CategoryService = class extends BaseService {
25670
26176
  async getAll(options = {}) {
25671
26177
  const { active = true, limit: queryLimit = 10, lastVisible } = options;
25672
26178
  const constraints = [
25673
- (0, import_firestore67.where)("isActive", "==", active),
25674
- (0, import_firestore67.orderBy)("name"),
25675
- queryLimit ? (0, import_firestore67.limit)(queryLimit) : void 0,
25676
- lastVisible ? (0, import_firestore67.startAfter)(lastVisible) : void 0
26179
+ (0, import_firestore68.where)("isActive", "==", active),
26180
+ (0, import_firestore68.orderBy)("name"),
26181
+ queryLimit ? (0, import_firestore68.limit)(queryLimit) : void 0,
26182
+ lastVisible ? (0, import_firestore68.startAfter)(lastVisible) : void 0
25677
26183
  ].filter((c) => !!c);
25678
- const q = (0, import_firestore67.query)(this.categoriesRef, ...constraints);
25679
- const snapshot = await (0, import_firestore67.getDocs)(q);
26184
+ const q = (0, import_firestore68.query)(this.categoriesRef, ...constraints);
26185
+ const snapshot = await (0, import_firestore68.getDocs)(q);
25680
26186
  const categories = snapshot.docs.map(
25681
- (doc52) => ({
25682
- id: doc52.id,
25683
- ...doc52.data()
26187
+ (doc53) => ({
26188
+ id: doc53.id,
26189
+ ...doc53.data()
25684
26190
  })
25685
26191
  );
25686
26192
  const filteredCategories = this.filterExcludedCategories(categories);
@@ -25696,18 +26202,18 @@ var CategoryService = class extends BaseService {
25696
26202
  async getAllByFamily(family, options = {}) {
25697
26203
  const { active = true, limit: queryLimit = 10, lastVisible } = options;
25698
26204
  const constraints = [
25699
- (0, import_firestore67.where)("family", "==", family),
25700
- (0, import_firestore67.where)("isActive", "==", active),
25701
- (0, import_firestore67.orderBy)("name"),
25702
- queryLimit ? (0, import_firestore67.limit)(queryLimit) : void 0,
25703
- lastVisible ? (0, import_firestore67.startAfter)(lastVisible) : void 0
26205
+ (0, import_firestore68.where)("family", "==", family),
26206
+ (0, import_firestore68.where)("isActive", "==", active),
26207
+ (0, import_firestore68.orderBy)("name"),
26208
+ queryLimit ? (0, import_firestore68.limit)(queryLimit) : void 0,
26209
+ lastVisible ? (0, import_firestore68.startAfter)(lastVisible) : void 0
25704
26210
  ].filter((c) => !!c);
25705
- const q = (0, import_firestore67.query)(this.categoriesRef, ...constraints);
25706
- const snapshot = await (0, import_firestore67.getDocs)(q);
26211
+ const q = (0, import_firestore68.query)(this.categoriesRef, ...constraints);
26212
+ const snapshot = await (0, import_firestore68.getDocs)(q);
25707
26213
  const categories = snapshot.docs.map(
25708
- (doc52) => ({
25709
- id: doc52.id,
25710
- ...doc52.data()
26214
+ (doc53) => ({
26215
+ id: doc53.id,
26216
+ ...doc53.data()
25711
26217
  })
25712
26218
  );
25713
26219
  const filteredCategories = this.filterExcludedCategories(categories);
@@ -25725,8 +26231,8 @@ var CategoryService = class extends BaseService {
25725
26231
  ...category,
25726
26232
  updatedAt: /* @__PURE__ */ new Date()
25727
26233
  };
25728
- const docRef = (0, import_firestore67.doc)(this.categoriesRef, id);
25729
- await (0, import_firestore67.updateDoc)(docRef, updateData);
26234
+ const docRef = (0, import_firestore68.doc)(this.categoriesRef, id);
26235
+ await (0, import_firestore68.updateDoc)(docRef, updateData);
25730
26236
  return this.getById(id);
25731
26237
  }
25732
26238
  /**
@@ -25750,8 +26256,8 @@ var CategoryService = class extends BaseService {
25750
26256
  */
25751
26257
  async getById(id) {
25752
26258
  if (id === EXCLUDED_CATEGORY_ID) return null;
25753
- const docRef = (0, import_firestore67.doc)(this.categoriesRef, id);
25754
- const docSnap = await (0, import_firestore67.getDoc)(docRef);
26259
+ const docRef = (0, import_firestore68.doc)(this.categoriesRef, id);
26260
+ const docSnap = await (0, import_firestore68.getDoc)(docRef);
25755
26261
  if (!docSnap.exists()) return null;
25756
26262
  return {
25757
26263
  id: docSnap.id,
@@ -25765,8 +26271,8 @@ var CategoryService = class extends BaseService {
25765
26271
  * @returns Category or null if not found
25766
26272
  */
25767
26273
  async getByIdInternal(id) {
25768
- const docRef = (0, import_firestore67.doc)(this.categoriesRef, id);
25769
- const docSnap = await (0, import_firestore67.getDoc)(docRef);
26274
+ const docRef = (0, import_firestore68.doc)(this.categoriesRef, id);
26275
+ const docSnap = await (0, import_firestore68.getDoc)(docRef);
25770
26276
  if (!docSnap.exists()) return null;
25771
26277
  return {
25772
26278
  id: docSnap.id,
@@ -25781,19 +26287,19 @@ var CategoryService = class extends BaseService {
25781
26287
  * @returns Category if found, null otherwise
25782
26288
  */
25783
26289
  async findByNameAndFamily(name, family) {
25784
- const q = (0, import_firestore67.query)(
26290
+ const q = (0, import_firestore68.query)(
25785
26291
  this.categoriesRef,
25786
- (0, import_firestore67.where)("name", "==", name),
25787
- (0, import_firestore67.where)("family", "==", family),
25788
- (0, import_firestore67.where)("isActive", "==", true)
26292
+ (0, import_firestore68.where)("name", "==", name),
26293
+ (0, import_firestore68.where)("family", "==", family),
26294
+ (0, import_firestore68.where)("isActive", "==", true)
25789
26295
  );
25790
- const snapshot = await (0, import_firestore67.getDocs)(q);
26296
+ const snapshot = await (0, import_firestore68.getDocs)(q);
25791
26297
  if (snapshot.empty) return null;
25792
- const doc52 = snapshot.docs[0];
25793
- if (doc52.id === EXCLUDED_CATEGORY_ID) return null;
26298
+ const doc53 = snapshot.docs[0];
26299
+ if (doc53.id === EXCLUDED_CATEGORY_ID) return null;
25794
26300
  return {
25795
- id: doc52.id,
25796
- ...doc52.data()
26301
+ id: doc53.id,
26302
+ ...doc53.data()
25797
26303
  };
25798
26304
  }
25799
26305
  /**
@@ -25818,14 +26324,14 @@ var CategoryService = class extends BaseService {
25818
26324
  let cursor;
25819
26325
  const constraints = [];
25820
26326
  if (!includeInactive) {
25821
- constraints.push((0, import_firestore67.where)("isActive", "==", true));
26327
+ constraints.push((0, import_firestore68.where)("isActive", "==", true));
25822
26328
  }
25823
- constraints.push((0, import_firestore67.orderBy)("name"));
26329
+ constraints.push((0, import_firestore68.orderBy)("name"));
25824
26330
  while (true) {
25825
- const queryConstraints = [...constraints, (0, import_firestore67.limit)(PAGE_SIZE)];
25826
- if (cursor) queryConstraints.push((0, import_firestore67.startAfter)(cursor));
25827
- const q = (0, import_firestore67.query)(this.categoriesRef, ...queryConstraints);
25828
- const snapshot = await (0, import_firestore67.getDocs)(q);
26331
+ const queryConstraints = [...constraints, (0, import_firestore68.limit)(PAGE_SIZE)];
26332
+ if (cursor) queryConstraints.push((0, import_firestore68.startAfter)(cursor));
26333
+ const q = (0, import_firestore68.query)(this.categoriesRef, ...queryConstraints);
26334
+ const snapshot = await (0, import_firestore68.getDocs)(q);
25829
26335
  if (snapshot.empty) break;
25830
26336
  for (const d of snapshot.docs) {
25831
26337
  if (d.id === EXCLUDED_CATEGORY_ID) continue;
@@ -25865,7 +26371,7 @@ var CategoryService = class extends BaseService {
25865
26371
  };
25866
26372
 
25867
26373
  // src/backoffice/services/subcategory.service.ts
25868
- var import_firestore68 = require("firebase/firestore");
26374
+ var import_firestore69 = require("firebase/firestore");
25869
26375
 
25870
26376
  // src/backoffice/types/subcategory.types.ts
25871
26377
  var SUBCATEGORIES_COLLECTION = "subcategories";
@@ -25886,7 +26392,7 @@ var SubcategoryService = class extends BaseService {
25886
26392
  * @param categoryId - ID roditeljske kategorije
25887
26393
  */
25888
26394
  getSubcategoriesRef(categoryId) {
25889
- return (0, import_firestore68.collection)(
26395
+ return (0, import_firestore69.collection)(
25890
26396
  this.db,
25891
26397
  CATEGORIES_COLLECTION,
25892
26398
  categoryId,
@@ -25908,7 +26414,7 @@ var SubcategoryService = class extends BaseService {
25908
26414
  updatedAt: now,
25909
26415
  isActive: true
25910
26416
  };
25911
- const docRef = await (0, import_firestore68.addDoc)(
26417
+ const docRef = await (0, import_firestore69.addDoc)(
25912
26418
  this.getSubcategoriesRef(categoryId),
25913
26419
  newSubcategory
25914
26420
  );
@@ -25920,15 +26426,15 @@ var SubcategoryService = class extends BaseService {
25920
26426
  * @returns A record mapping category ID to subcategory count.
25921
26427
  */
25922
26428
  async getSubcategoryCounts(active = true) {
25923
- const categoriesRef = (0, import_firestore68.collection)(this.db, CATEGORIES_COLLECTION);
25924
- const categoriesSnapshot = await (0, import_firestore68.getDocs)(categoriesRef);
26429
+ const categoriesRef = (0, import_firestore69.collection)(this.db, CATEGORIES_COLLECTION);
26430
+ const categoriesSnapshot = await (0, import_firestore69.getDocs)(categoriesRef);
25925
26431
  const counts = {};
25926
26432
  for (const categoryDoc of categoriesSnapshot.docs) {
25927
26433
  const categoryId = categoryDoc.id;
25928
26434
  const subcategoriesRef = this.getSubcategoriesRef(categoryId);
25929
- const q = (0, import_firestore68.query)(subcategoriesRef, (0, import_firestore68.where)("isActive", "==", active));
25930
- const snapshot = await (0, import_firestore68.getDocs)(q);
25931
- const filteredDocs = snapshot.docs.filter((doc52) => doc52.id !== EXCLUDED_SUBCATEGORY_ID);
26435
+ const q = (0, import_firestore69.query)(subcategoriesRef, (0, import_firestore69.where)("isActive", "==", active));
26436
+ const snapshot = await (0, import_firestore69.getDocs)(q);
26437
+ const filteredDocs = snapshot.docs.filter((doc53) => doc53.id !== EXCLUDED_SUBCATEGORY_ID);
25932
26438
  counts[categoryId] = filteredDocs.length;
25933
26439
  }
25934
26440
  return counts;
@@ -25942,17 +26448,17 @@ var SubcategoryService = class extends BaseService {
25942
26448
  async getAllByCategoryId(categoryId, options = {}) {
25943
26449
  const { active = true, limit: queryLimit = 10, lastVisible } = options;
25944
26450
  const constraints = [
25945
- (0, import_firestore68.where)("isActive", "==", active),
25946
- (0, import_firestore68.orderBy)("name"),
25947
- queryLimit ? (0, import_firestore68.limit)(queryLimit) : void 0,
25948
- lastVisible ? (0, import_firestore68.startAfter)(lastVisible) : void 0
26451
+ (0, import_firestore69.where)("isActive", "==", active),
26452
+ (0, import_firestore69.orderBy)("name"),
26453
+ queryLimit ? (0, import_firestore69.limit)(queryLimit) : void 0,
26454
+ lastVisible ? (0, import_firestore69.startAfter)(lastVisible) : void 0
25949
26455
  ].filter((c) => !!c);
25950
- const q = (0, import_firestore68.query)(this.getSubcategoriesRef(categoryId), ...constraints);
25951
- const querySnapshot = await (0, import_firestore68.getDocs)(q);
26456
+ const q = (0, import_firestore69.query)(this.getSubcategoriesRef(categoryId), ...constraints);
26457
+ const querySnapshot = await (0, import_firestore69.getDocs)(q);
25952
26458
  const subcategories = querySnapshot.docs.map(
25953
- (doc52) => ({
25954
- id: doc52.id,
25955
- ...doc52.data()
26459
+ (doc53) => ({
26460
+ id: doc53.id,
26461
+ ...doc53.data()
25956
26462
  })
25957
26463
  );
25958
26464
  const filteredSubcategories = this.filterExcludedSubcategories(subcategories);
@@ -25970,20 +26476,20 @@ var SubcategoryService = class extends BaseService {
25970
26476
  async getAll(options = {}) {
25971
26477
  const { active = true, limit: queryLimit = 10, lastVisible } = options;
25972
26478
  const constraints = [
25973
- (0, import_firestore68.where)("isActive", "==", active),
25974
- (0, import_firestore68.orderBy)("name"),
25975
- queryLimit ? (0, import_firestore68.limit)(queryLimit) : void 0,
25976
- lastVisible ? (0, import_firestore68.startAfter)(lastVisible) : void 0
26479
+ (0, import_firestore69.where)("isActive", "==", active),
26480
+ (0, import_firestore69.orderBy)("name"),
26481
+ queryLimit ? (0, import_firestore69.limit)(queryLimit) : void 0,
26482
+ lastVisible ? (0, import_firestore69.startAfter)(lastVisible) : void 0
25977
26483
  ].filter((c) => !!c);
25978
- const q = (0, import_firestore68.query)(
25979
- (0, import_firestore68.collectionGroup)(this.db, SUBCATEGORIES_COLLECTION),
26484
+ const q = (0, import_firestore69.query)(
26485
+ (0, import_firestore69.collectionGroup)(this.db, SUBCATEGORIES_COLLECTION),
25980
26486
  ...constraints
25981
26487
  );
25982
- const querySnapshot = await (0, import_firestore68.getDocs)(q);
26488
+ const querySnapshot = await (0, import_firestore69.getDocs)(q);
25983
26489
  const subcategories = querySnapshot.docs.map(
25984
- (doc52) => ({
25985
- id: doc52.id,
25986
- ...doc52.data()
26490
+ (doc53) => ({
26491
+ id: doc53.id,
26492
+ ...doc53.data()
25987
26493
  })
25988
26494
  );
25989
26495
  const filteredSubcategories = this.filterExcludedSubcategories(subcategories);
@@ -25996,15 +26502,15 @@ var SubcategoryService = class extends BaseService {
25996
26502
  * @returns Lista svih aktivnih subkategorija
25997
26503
  */
25998
26504
  async getAllForFilterByCategoryId(categoryId) {
25999
- const q = (0, import_firestore68.query)(
26505
+ const q = (0, import_firestore69.query)(
26000
26506
  this.getSubcategoriesRef(categoryId),
26001
- (0, import_firestore68.where)("isActive", "==", true)
26507
+ (0, import_firestore69.where)("isActive", "==", true)
26002
26508
  );
26003
- const querySnapshot = await (0, import_firestore68.getDocs)(q);
26509
+ const querySnapshot = await (0, import_firestore69.getDocs)(q);
26004
26510
  const subcategories = querySnapshot.docs.map(
26005
- (doc52) => ({
26006
- id: doc52.id,
26007
- ...doc52.data()
26511
+ (doc53) => ({
26512
+ id: doc53.id,
26513
+ ...doc53.data()
26008
26514
  })
26009
26515
  );
26010
26516
  return this.filterExcludedSubcategories(subcategories);
@@ -26014,15 +26520,15 @@ var SubcategoryService = class extends BaseService {
26014
26520
  * @returns Lista svih aktivnih subkategorija
26015
26521
  */
26016
26522
  async getAllForFilter() {
26017
- const q = (0, import_firestore68.query)(
26018
- (0, import_firestore68.collectionGroup)(this.db, SUBCATEGORIES_COLLECTION),
26019
- (0, import_firestore68.where)("isActive", "==", true)
26523
+ const q = (0, import_firestore69.query)(
26524
+ (0, import_firestore69.collectionGroup)(this.db, SUBCATEGORIES_COLLECTION),
26525
+ (0, import_firestore69.where)("isActive", "==", true)
26020
26526
  );
26021
- const querySnapshot = await (0, import_firestore68.getDocs)(q);
26527
+ const querySnapshot = await (0, import_firestore69.getDocs)(q);
26022
26528
  const subcategories = querySnapshot.docs.map(
26023
- (doc52) => ({
26024
- id: doc52.id,
26025
- ...doc52.data()
26529
+ (doc53) => ({
26530
+ id: doc53.id,
26531
+ ...doc53.data()
26026
26532
  })
26027
26533
  );
26028
26534
  return this.filterExcludedSubcategories(subcategories);
@@ -26037,11 +26543,11 @@ var SubcategoryService = class extends BaseService {
26037
26543
  async update(categoryId, subcategoryId, subcategory) {
26038
26544
  const newCategoryId = subcategory.categoryId;
26039
26545
  if (newCategoryId && newCategoryId !== categoryId) {
26040
- const oldDocRef = (0, import_firestore68.doc)(
26546
+ const oldDocRef = (0, import_firestore69.doc)(
26041
26547
  this.getSubcategoriesRef(categoryId),
26042
26548
  subcategoryId
26043
26549
  );
26044
- const docSnap = await (0, import_firestore68.getDoc)(oldDocRef);
26550
+ const docSnap = await (0, import_firestore69.getDoc)(oldDocRef);
26045
26551
  if (!docSnap.exists()) {
26046
26552
  throw new Error("Subcategory to update does not exist.");
26047
26553
  }
@@ -26055,20 +26561,20 @@ var SubcategoryService = class extends BaseService {
26055
26561
  // Preserve original creation date
26056
26562
  updatedAt: /* @__PURE__ */ new Date()
26057
26563
  };
26058
- const newDocRef = (0, import_firestore68.doc)(
26564
+ const newDocRef = (0, import_firestore69.doc)(
26059
26565
  this.getSubcategoriesRef(newCategoryId),
26060
26566
  subcategoryId
26061
26567
  );
26062
- await (0, import_firestore68.setDoc)(newDocRef, newData);
26063
- await (0, import_firestore68.deleteDoc)(oldDocRef);
26568
+ await (0, import_firestore69.setDoc)(newDocRef, newData);
26569
+ await (0, import_firestore69.deleteDoc)(oldDocRef);
26064
26570
  return { id: subcategoryId, ...newData };
26065
26571
  } else {
26066
26572
  const updateData = {
26067
26573
  ...subcategory,
26068
26574
  updatedAt: /* @__PURE__ */ new Date()
26069
26575
  };
26070
- const docRef = (0, import_firestore68.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
26071
- await (0, import_firestore68.updateDoc)(docRef, updateData);
26576
+ const docRef = (0, import_firestore69.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
26577
+ await (0, import_firestore69.updateDoc)(docRef, updateData);
26072
26578
  return this.getById(categoryId, subcategoryId);
26073
26579
  }
26074
26580
  }
@@ -26096,8 +26602,8 @@ var SubcategoryService = class extends BaseService {
26096
26602
  */
26097
26603
  async getById(categoryId, subcategoryId) {
26098
26604
  if (subcategoryId === EXCLUDED_SUBCATEGORY_ID) return null;
26099
- const docRef = (0, import_firestore68.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
26100
- const docSnap = await (0, import_firestore68.getDoc)(docRef);
26605
+ const docRef = (0, import_firestore69.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
26606
+ const docSnap = await (0, import_firestore69.getDoc)(docRef);
26101
26607
  if (!docSnap.exists()) return null;
26102
26608
  return {
26103
26609
  id: docSnap.id,
@@ -26112,8 +26618,8 @@ var SubcategoryService = class extends BaseService {
26112
26618
  * @returns Subcategory or null if not found
26113
26619
  */
26114
26620
  async getByIdInternal(categoryId, subcategoryId) {
26115
- const docRef = (0, import_firestore68.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
26116
- const docSnap = await (0, import_firestore68.getDoc)(docRef);
26621
+ const docRef = (0, import_firestore69.doc)(this.getSubcategoriesRef(categoryId), subcategoryId);
26622
+ const docSnap = await (0, import_firestore69.getDoc)(docRef);
26117
26623
  if (!docSnap.exists()) return null;
26118
26624
  return {
26119
26625
  id: docSnap.id,
@@ -26128,18 +26634,18 @@ var SubcategoryService = class extends BaseService {
26128
26634
  * @returns Subcategory if found, null otherwise
26129
26635
  */
26130
26636
  async findByNameAndCategory(name, categoryId) {
26131
- const q = (0, import_firestore68.query)(
26637
+ const q = (0, import_firestore69.query)(
26132
26638
  this.getSubcategoriesRef(categoryId),
26133
- (0, import_firestore68.where)("name", "==", name),
26134
- (0, import_firestore68.where)("isActive", "==", true)
26639
+ (0, import_firestore69.where)("name", "==", name),
26640
+ (0, import_firestore69.where)("isActive", "==", true)
26135
26641
  );
26136
- const querySnapshot = await (0, import_firestore68.getDocs)(q);
26642
+ const querySnapshot = await (0, import_firestore69.getDocs)(q);
26137
26643
  if (querySnapshot.empty) return null;
26138
- const doc52 = querySnapshot.docs[0];
26139
- if (doc52.id === EXCLUDED_SUBCATEGORY_ID) return null;
26644
+ const doc53 = querySnapshot.docs[0];
26645
+ if (doc53.id === EXCLUDED_SUBCATEGORY_ID) return null;
26140
26646
  return {
26141
- id: doc52.id,
26142
- ...doc52.data()
26647
+ id: doc53.id,
26648
+ ...doc53.data()
26143
26649
  };
26144
26650
  }
26145
26651
  /**
@@ -26164,17 +26670,17 @@ var SubcategoryService = class extends BaseService {
26164
26670
  let cursor;
26165
26671
  const constraints = [];
26166
26672
  if (!includeInactive) {
26167
- constraints.push((0, import_firestore68.where)("isActive", "==", true));
26673
+ constraints.push((0, import_firestore69.where)("isActive", "==", true));
26168
26674
  }
26169
- constraints.push((0, import_firestore68.orderBy)("name"));
26675
+ constraints.push((0, import_firestore69.orderBy)("name"));
26170
26676
  while (true) {
26171
- const queryConstraints = [...constraints, (0, import_firestore68.limit)(PAGE_SIZE)];
26172
- if (cursor) queryConstraints.push((0, import_firestore68.startAfter)(cursor));
26173
- const q = (0, import_firestore68.query)(
26174
- (0, import_firestore68.collectionGroup)(this.db, SUBCATEGORIES_COLLECTION),
26677
+ const queryConstraints = [...constraints, (0, import_firestore69.limit)(PAGE_SIZE)];
26678
+ if (cursor) queryConstraints.push((0, import_firestore69.startAfter)(cursor));
26679
+ const q = (0, import_firestore69.query)(
26680
+ (0, import_firestore69.collectionGroup)(this.db, SUBCATEGORIES_COLLECTION),
26175
26681
  ...queryConstraints
26176
26682
  );
26177
- const snapshot = await (0, import_firestore68.getDocs)(q);
26683
+ const snapshot = await (0, import_firestore69.getDocs)(q);
26178
26684
  if (snapshot.empty) break;
26179
26685
  for (const d of snapshot.docs) {
26180
26686
  if (d.id === EXCLUDED_SUBCATEGORY_ID) continue;
@@ -26214,7 +26720,7 @@ var SubcategoryService = class extends BaseService {
26214
26720
  };
26215
26721
 
26216
26722
  // src/backoffice/services/technology.service.ts
26217
- var import_firestore69 = require("firebase/firestore");
26723
+ var import_firestore70 = require("firebase/firestore");
26218
26724
 
26219
26725
  // src/backoffice/types/product.types.ts
26220
26726
  var PRODUCTS_COLLECTION = "products";
@@ -26238,7 +26744,7 @@ var TechnologyService = class extends BaseService {
26238
26744
  * Reference to the Firestore collection of technologies.
26239
26745
  */
26240
26746
  get technologiesRef() {
26241
- return (0, import_firestore69.collection)(this.db, TECHNOLOGIES_COLLECTION);
26747
+ return (0, import_firestore70.collection)(this.db, TECHNOLOGIES_COLLECTION);
26242
26748
  }
26243
26749
  /**
26244
26750
  * Creates a new technology.
@@ -26269,7 +26775,7 @@ var TechnologyService = class extends BaseService {
26269
26775
  if (technology.photoTemplate) {
26270
26776
  newTechnology.photoTemplate = technology.photoTemplate;
26271
26777
  }
26272
- const docRef = await (0, import_firestore69.addDoc)(this.technologiesRef, newTechnology);
26778
+ const docRef = await (0, import_firestore70.addDoc)(this.technologiesRef, newTechnology);
26273
26779
  return { id: docRef.id, ...newTechnology };
26274
26780
  }
26275
26781
  /**
@@ -26278,12 +26784,12 @@ var TechnologyService = class extends BaseService {
26278
26784
  * @returns A record mapping subcategory ID to technology count.
26279
26785
  */
26280
26786
  async getTechnologyCounts(active = true) {
26281
- const q = (0, import_firestore69.query)(this.technologiesRef, (0, import_firestore69.where)("isActive", "==", active));
26282
- const snapshot = await (0, import_firestore69.getDocs)(q);
26787
+ const q = (0, import_firestore70.query)(this.technologiesRef, (0, import_firestore70.where)("isActive", "==", active));
26788
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26283
26789
  const counts = {};
26284
- snapshot.docs.forEach((doc52) => {
26285
- if (doc52.id === EXCLUDED_TECHNOLOGY_ID) return;
26286
- const tech = doc52.data();
26790
+ snapshot.docs.forEach((doc53) => {
26791
+ if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return;
26792
+ const tech = doc53.data();
26287
26793
  counts[tech.subcategoryId] = (counts[tech.subcategoryId] || 0) + 1;
26288
26794
  });
26289
26795
  return counts;
@@ -26294,12 +26800,12 @@ var TechnologyService = class extends BaseService {
26294
26800
  * @returns A record mapping category ID to technology count.
26295
26801
  */
26296
26802
  async getTechnologyCountsByCategory(active = true) {
26297
- const q = (0, import_firestore69.query)(this.technologiesRef, (0, import_firestore69.where)("isActive", "==", active));
26298
- const snapshot = await (0, import_firestore69.getDocs)(q);
26803
+ const q = (0, import_firestore70.query)(this.technologiesRef, (0, import_firestore70.where)("isActive", "==", active));
26804
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26299
26805
  const counts = {};
26300
- snapshot.docs.forEach((doc52) => {
26301
- if (doc52.id === EXCLUDED_TECHNOLOGY_ID) return;
26302
- const tech = doc52.data();
26806
+ snapshot.docs.forEach((doc53) => {
26807
+ if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return;
26808
+ const tech = doc53.data();
26303
26809
  counts[tech.categoryId] = (counts[tech.categoryId] || 0) + 1;
26304
26810
  });
26305
26811
  return counts;
@@ -26312,17 +26818,17 @@ var TechnologyService = class extends BaseService {
26312
26818
  async getAll(options = {}) {
26313
26819
  const { active = true, limit: queryLimit = 10, lastVisible } = options;
26314
26820
  const constraints = [
26315
- (0, import_firestore69.where)("isActive", "==", active),
26316
- (0, import_firestore69.orderBy)("name"),
26317
- queryLimit ? (0, import_firestore69.limit)(queryLimit) : void 0,
26318
- lastVisible ? (0, import_firestore69.startAfter)(lastVisible) : void 0
26821
+ (0, import_firestore70.where)("isActive", "==", active),
26822
+ (0, import_firestore70.orderBy)("name"),
26823
+ queryLimit ? (0, import_firestore70.limit)(queryLimit) : void 0,
26824
+ lastVisible ? (0, import_firestore70.startAfter)(lastVisible) : void 0
26319
26825
  ].filter((c) => !!c);
26320
- const q = (0, import_firestore69.query)(this.technologiesRef, ...constraints);
26321
- const snapshot = await (0, import_firestore69.getDocs)(q);
26826
+ const q = (0, import_firestore70.query)(this.technologiesRef, ...constraints);
26827
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26322
26828
  const technologies = snapshot.docs.map(
26323
- (doc52) => ({
26324
- id: doc52.id,
26325
- ...doc52.data()
26829
+ (doc53) => ({
26830
+ id: doc53.id,
26831
+ ...doc53.data()
26326
26832
  })
26327
26833
  );
26328
26834
  const filteredTechnologies = this.filterExcludedTechnologies(technologies);
@@ -26338,18 +26844,18 @@ var TechnologyService = class extends BaseService {
26338
26844
  async getAllByCategoryId(categoryId, options = {}) {
26339
26845
  const { active = true, limit: queryLimit = 10, lastVisible } = options;
26340
26846
  const constraints = [
26341
- (0, import_firestore69.where)("categoryId", "==", categoryId),
26342
- (0, import_firestore69.where)("isActive", "==", active),
26343
- (0, import_firestore69.orderBy)("name"),
26344
- queryLimit ? (0, import_firestore69.limit)(queryLimit) : void 0,
26345
- lastVisible ? (0, import_firestore69.startAfter)(lastVisible) : void 0
26847
+ (0, import_firestore70.where)("categoryId", "==", categoryId),
26848
+ (0, import_firestore70.where)("isActive", "==", active),
26849
+ (0, import_firestore70.orderBy)("name"),
26850
+ queryLimit ? (0, import_firestore70.limit)(queryLimit) : void 0,
26851
+ lastVisible ? (0, import_firestore70.startAfter)(lastVisible) : void 0
26346
26852
  ].filter((c) => !!c);
26347
- const q = (0, import_firestore69.query)(this.technologiesRef, ...constraints);
26348
- const snapshot = await (0, import_firestore69.getDocs)(q);
26853
+ const q = (0, import_firestore70.query)(this.technologiesRef, ...constraints);
26854
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26349
26855
  const technologies = snapshot.docs.map(
26350
- (doc52) => ({
26351
- id: doc52.id,
26352
- ...doc52.data()
26856
+ (doc53) => ({
26857
+ id: doc53.id,
26858
+ ...doc53.data()
26353
26859
  })
26354
26860
  );
26355
26861
  const filteredTechnologies = this.filterExcludedTechnologies(technologies);
@@ -26365,18 +26871,18 @@ var TechnologyService = class extends BaseService {
26365
26871
  async getAllBySubcategoryId(subcategoryId, options = {}) {
26366
26872
  const { active = true, limit: queryLimit = 10, lastVisible } = options;
26367
26873
  const constraints = [
26368
- (0, import_firestore69.where)("subcategoryId", "==", subcategoryId),
26369
- (0, import_firestore69.where)("isActive", "==", active),
26370
- (0, import_firestore69.orderBy)("name"),
26371
- queryLimit ? (0, import_firestore69.limit)(queryLimit) : void 0,
26372
- lastVisible ? (0, import_firestore69.startAfter)(lastVisible) : void 0
26874
+ (0, import_firestore70.where)("subcategoryId", "==", subcategoryId),
26875
+ (0, import_firestore70.where)("isActive", "==", active),
26876
+ (0, import_firestore70.orderBy)("name"),
26877
+ queryLimit ? (0, import_firestore70.limit)(queryLimit) : void 0,
26878
+ lastVisible ? (0, import_firestore70.startAfter)(lastVisible) : void 0
26373
26879
  ].filter((c) => !!c);
26374
- const q = (0, import_firestore69.query)(this.technologiesRef, ...constraints);
26375
- const snapshot = await (0, import_firestore69.getDocs)(q);
26880
+ const q = (0, import_firestore70.query)(this.technologiesRef, ...constraints);
26881
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26376
26882
  const technologies = snapshot.docs.map(
26377
- (doc52) => ({
26378
- id: doc52.id,
26379
- ...doc52.data()
26883
+ (doc53) => ({
26884
+ id: doc53.id,
26885
+ ...doc53.data()
26380
26886
  })
26381
26887
  );
26382
26888
  const filteredTechnologies = this.filterExcludedTechnologies(technologies);
@@ -26404,9 +26910,9 @@ var TechnologyService = class extends BaseService {
26404
26910
  }
26405
26911
  }
26406
26912
  updateData.updatedAt = /* @__PURE__ */ new Date();
26407
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, id);
26913
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, id);
26408
26914
  const beforeTech = await this.getById(id);
26409
- await (0, import_firestore69.updateDoc)(docRef, updateData);
26915
+ await (0, import_firestore70.updateDoc)(docRef, updateData);
26410
26916
  const categoryChanged = beforeTech && updateData.categoryId && beforeTech.categoryId !== updateData.categoryId;
26411
26917
  const subcategoryChanged = beforeTech && updateData.subcategoryId && beforeTech.subcategoryId !== updateData.subcategoryId;
26412
26918
  const nameChanged = beforeTech && updateData.name && beforeTech.name !== updateData.name;
@@ -26440,8 +26946,8 @@ var TechnologyService = class extends BaseService {
26440
26946
  */
26441
26947
  async getById(id) {
26442
26948
  if (id === EXCLUDED_TECHNOLOGY_ID) return null;
26443
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, id);
26444
- const docSnap = await (0, import_firestore69.getDoc)(docRef);
26949
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, id);
26950
+ const docSnap = await (0, import_firestore70.getDoc)(docRef);
26445
26951
  if (!docSnap.exists()) return null;
26446
26952
  return {
26447
26953
  id: docSnap.id,
@@ -26455,8 +26961,8 @@ var TechnologyService = class extends BaseService {
26455
26961
  * @returns The technology or null if it doesn't exist
26456
26962
  */
26457
26963
  async getByIdInternal(id) {
26458
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, id);
26459
- const docSnap = await (0, import_firestore69.getDoc)(docRef);
26964
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, id);
26965
+ const docSnap = await (0, import_firestore70.getDoc)(docRef);
26460
26966
  if (!docSnap.exists()) return null;
26461
26967
  return {
26462
26968
  id: docSnap.id,
@@ -26470,18 +26976,18 @@ var TechnologyService = class extends BaseService {
26470
26976
  * @returns Technology if found, null otherwise
26471
26977
  */
26472
26978
  async findByName(name) {
26473
- const q = (0, import_firestore69.query)(
26979
+ const q = (0, import_firestore70.query)(
26474
26980
  this.technologiesRef,
26475
- (0, import_firestore69.where)("name", "==", name),
26476
- (0, import_firestore69.where)("isActive", "==", true)
26981
+ (0, import_firestore70.where)("name", "==", name),
26982
+ (0, import_firestore70.where)("isActive", "==", true)
26477
26983
  );
26478
- const snapshot = await (0, import_firestore69.getDocs)(q);
26984
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26479
26985
  if (snapshot.empty) return null;
26480
- const doc52 = snapshot.docs[0];
26481
- if (doc52.id === EXCLUDED_TECHNOLOGY_ID) return null;
26986
+ const doc53 = snapshot.docs[0];
26987
+ if (doc53.id === EXCLUDED_TECHNOLOGY_ID) return null;
26482
26988
  return {
26483
- id: doc52.id,
26484
- ...doc52.data()
26989
+ id: doc53.id,
26990
+ ...doc53.data()
26485
26991
  };
26486
26992
  }
26487
26993
  /**
@@ -26491,10 +26997,10 @@ var TechnologyService = class extends BaseService {
26491
26997
  * @returns Ažurirana tehnologija sa novim zahtevom
26492
26998
  */
26493
26999
  async addRequirement(technologyId, requirement) {
26494
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
27000
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
26495
27001
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
26496
- await (0, import_firestore69.updateDoc)(docRef, {
26497
- [requirementType]: (0, import_firestore69.arrayUnion)(requirement),
27002
+ await (0, import_firestore70.updateDoc)(docRef, {
27003
+ [requirementType]: (0, import_firestore70.arrayUnion)(requirement),
26498
27004
  updatedAt: /* @__PURE__ */ new Date()
26499
27005
  });
26500
27006
  return this.getById(technologyId);
@@ -26506,10 +27012,10 @@ var TechnologyService = class extends BaseService {
26506
27012
  * @returns Ažurirana tehnologija bez uklonjenog zahteva
26507
27013
  */
26508
27014
  async removeRequirement(technologyId, requirement) {
26509
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
27015
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
26510
27016
  const requirementType = requirement.type === "pre" ? "requirements.pre" : "requirements.post";
26511
- await (0, import_firestore69.updateDoc)(docRef, {
26512
- [requirementType]: (0, import_firestore69.arrayRemove)(requirement),
27017
+ await (0, import_firestore70.updateDoc)(docRef, {
27018
+ [requirementType]: (0, import_firestore70.arrayRemove)(requirement),
26513
27019
  updatedAt: /* @__PURE__ */ new Date()
26514
27020
  });
26515
27021
  return this.getById(technologyId);
@@ -26546,9 +27052,9 @@ var TechnologyService = class extends BaseService {
26546
27052
  * @returns Ažurirana tehnologija
26547
27053
  */
26548
27054
  async addBlockingCondition(technologyId, condition) {
26549
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
26550
- await (0, import_firestore69.updateDoc)(docRef, {
26551
- blockingConditions: (0, import_firestore69.arrayUnion)(condition),
27055
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
27056
+ await (0, import_firestore70.updateDoc)(docRef, {
27057
+ blockingConditions: (0, import_firestore70.arrayUnion)(condition),
26552
27058
  updatedAt: /* @__PURE__ */ new Date()
26553
27059
  });
26554
27060
  return this.getById(technologyId);
@@ -26560,9 +27066,9 @@ var TechnologyService = class extends BaseService {
26560
27066
  * @returns Ažurirana tehnologija
26561
27067
  */
26562
27068
  async removeBlockingCondition(technologyId, condition) {
26563
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
26564
- await (0, import_firestore69.updateDoc)(docRef, {
26565
- blockingConditions: (0, import_firestore69.arrayRemove)(condition),
27069
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
27070
+ await (0, import_firestore70.updateDoc)(docRef, {
27071
+ blockingConditions: (0, import_firestore70.arrayRemove)(condition),
26566
27072
  updatedAt: /* @__PURE__ */ new Date()
26567
27073
  });
26568
27074
  return this.getById(technologyId);
@@ -26574,7 +27080,7 @@ var TechnologyService = class extends BaseService {
26574
27080
  * @returns Ažurirana tehnologija
26575
27081
  */
26576
27082
  async addContraindication(technologyId, contraindication) {
26577
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
27083
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
26578
27084
  const technology = await this.getById(technologyId);
26579
27085
  if (!technology) {
26580
27086
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -26583,7 +27089,7 @@ var TechnologyService = class extends BaseService {
26583
27089
  if (existingContraindications.some((c) => c.id === contraindication.id)) {
26584
27090
  return technology;
26585
27091
  }
26586
- await (0, import_firestore69.updateDoc)(docRef, {
27092
+ await (0, import_firestore70.updateDoc)(docRef, {
26587
27093
  contraindications: [...existingContraindications, contraindication],
26588
27094
  updatedAt: /* @__PURE__ */ new Date()
26589
27095
  });
@@ -26596,7 +27102,7 @@ var TechnologyService = class extends BaseService {
26596
27102
  * @returns Ažurirana tehnologija
26597
27103
  */
26598
27104
  async removeContraindication(technologyId, contraindication) {
26599
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
27105
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
26600
27106
  const technology = await this.getById(technologyId);
26601
27107
  if (!technology) {
26602
27108
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -26604,7 +27110,7 @@ var TechnologyService = class extends BaseService {
26604
27110
  const updatedContraindications = (technology.contraindications || []).filter(
26605
27111
  (c) => c.id !== contraindication.id
26606
27112
  );
26607
- await (0, import_firestore69.updateDoc)(docRef, {
27113
+ await (0, import_firestore70.updateDoc)(docRef, {
26608
27114
  contraindications: updatedContraindications,
26609
27115
  updatedAt: /* @__PURE__ */ new Date()
26610
27116
  });
@@ -26618,7 +27124,7 @@ var TechnologyService = class extends BaseService {
26618
27124
  * @returns The updated technology
26619
27125
  */
26620
27126
  async updateContraindication(technologyId, contraindication) {
26621
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
27127
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
26622
27128
  const technology = await this.getById(technologyId);
26623
27129
  if (!technology) {
26624
27130
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -26633,7 +27139,7 @@ var TechnologyService = class extends BaseService {
26633
27139
  }
26634
27140
  const updatedContraindications = [...contraindications];
26635
27141
  updatedContraindications[index] = contraindication;
26636
- await (0, import_firestore69.updateDoc)(docRef, {
27142
+ await (0, import_firestore70.updateDoc)(docRef, {
26637
27143
  contraindications: updatedContraindications,
26638
27144
  updatedAt: /* @__PURE__ */ new Date()
26639
27145
  });
@@ -26646,7 +27152,7 @@ var TechnologyService = class extends BaseService {
26646
27152
  * @returns Ažurirana tehnologija
26647
27153
  */
26648
27154
  async addBenefit(technologyId, benefit) {
26649
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
27155
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
26650
27156
  const technology = await this.getById(technologyId);
26651
27157
  if (!technology) {
26652
27158
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -26655,7 +27161,7 @@ var TechnologyService = class extends BaseService {
26655
27161
  if (existingBenefits.some((b) => b.id === benefit.id)) {
26656
27162
  return technology;
26657
27163
  }
26658
- await (0, import_firestore69.updateDoc)(docRef, {
27164
+ await (0, import_firestore70.updateDoc)(docRef, {
26659
27165
  benefits: [...existingBenefits, benefit],
26660
27166
  updatedAt: /* @__PURE__ */ new Date()
26661
27167
  });
@@ -26668,13 +27174,13 @@ var TechnologyService = class extends BaseService {
26668
27174
  * @returns Ažurirana tehnologija
26669
27175
  */
26670
27176
  async removeBenefit(technologyId, benefit) {
26671
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
27177
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
26672
27178
  const technology = await this.getById(technologyId);
26673
27179
  if (!technology) {
26674
27180
  throw new Error(`Technology with id ${technologyId} not found`);
26675
27181
  }
26676
27182
  const updatedBenefits = (technology.benefits || []).filter((b) => b.id !== benefit.id);
26677
- await (0, import_firestore69.updateDoc)(docRef, {
27183
+ await (0, import_firestore70.updateDoc)(docRef, {
26678
27184
  benefits: updatedBenefits,
26679
27185
  updatedAt: /* @__PURE__ */ new Date()
26680
27186
  });
@@ -26688,7 +27194,7 @@ var TechnologyService = class extends BaseService {
26688
27194
  * @returns The updated technology
26689
27195
  */
26690
27196
  async updateBenefit(technologyId, benefit) {
26691
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
27197
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
26692
27198
  const technology = await this.getById(technologyId);
26693
27199
  if (!technology) {
26694
27200
  throw new Error(`Technology with id ${technologyId} not found`);
@@ -26703,7 +27209,7 @@ var TechnologyService = class extends BaseService {
26703
27209
  }
26704
27210
  const updatedBenefits = [...benefits];
26705
27211
  updatedBenefits[index] = benefit;
26706
- await (0, import_firestore69.updateDoc)(docRef, {
27212
+ await (0, import_firestore70.updateDoc)(docRef, {
26707
27213
  benefits: updatedBenefits,
26708
27214
  updatedAt: /* @__PURE__ */ new Date()
26709
27215
  });
@@ -26743,8 +27249,8 @@ var TechnologyService = class extends BaseService {
26743
27249
  * @returns Ažurirana tehnologija
26744
27250
  */
26745
27251
  async updateCertificationRequirement(technologyId, certificationRequirement) {
26746
- const docRef = (0, import_firestore69.doc)(this.technologiesRef, technologyId);
26747
- await (0, import_firestore69.updateDoc)(docRef, {
27252
+ const docRef = (0, import_firestore70.doc)(this.technologiesRef, technologyId);
27253
+ await (0, import_firestore70.updateDoc)(docRef, {
26748
27254
  certificationRequirement,
26749
27255
  updatedAt: /* @__PURE__ */ new Date()
26750
27256
  });
@@ -26837,17 +27343,17 @@ var TechnologyService = class extends BaseService {
26837
27343
  * @param subcategoryId - The ID of the subcategory.
26838
27344
  */
26839
27345
  async getAllForFilterBySubcategory(subcategoryId) {
26840
- const q = (0, import_firestore69.query)(
26841
- (0, import_firestore69.collection)(this.db, TECHNOLOGIES_COLLECTION),
26842
- (0, import_firestore69.where)("isActive", "==", true),
26843
- (0, import_firestore69.where)("subcategoryId", "==", subcategoryId),
26844
- (0, import_firestore69.orderBy)("name")
27346
+ const q = (0, import_firestore70.query)(
27347
+ (0, import_firestore70.collection)(this.db, TECHNOLOGIES_COLLECTION),
27348
+ (0, import_firestore70.where)("isActive", "==", true),
27349
+ (0, import_firestore70.where)("subcategoryId", "==", subcategoryId),
27350
+ (0, import_firestore70.orderBy)("name")
26845
27351
  );
26846
- const snapshot = await (0, import_firestore69.getDocs)(q);
27352
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26847
27353
  const technologies = snapshot.docs.map(
26848
- (doc52) => ({
26849
- id: doc52.id,
26850
- ...doc52.data()
27354
+ (doc53) => ({
27355
+ id: doc53.id,
27356
+ ...doc53.data()
26851
27357
  })
26852
27358
  );
26853
27359
  return this.filterExcludedTechnologies(technologies);
@@ -26858,18 +27364,18 @@ var TechnologyService = class extends BaseService {
26858
27364
  * @param subcategoryId - The ID of the subcategory.
26859
27365
  */
26860
27366
  async getAllForFilterBySubcategoryId(categoryId, subcategoryId) {
26861
- const q = (0, import_firestore69.query)(
26862
- (0, import_firestore69.collection)(this.db, TECHNOLOGIES_COLLECTION),
26863
- (0, import_firestore69.where)("isActive", "==", true),
26864
- (0, import_firestore69.where)("categoryId", "==", categoryId),
26865
- (0, import_firestore69.where)("subcategoryId", "==", subcategoryId),
26866
- (0, import_firestore69.orderBy)("name")
27367
+ const q = (0, import_firestore70.query)(
27368
+ (0, import_firestore70.collection)(this.db, TECHNOLOGIES_COLLECTION),
27369
+ (0, import_firestore70.where)("isActive", "==", true),
27370
+ (0, import_firestore70.where)("categoryId", "==", categoryId),
27371
+ (0, import_firestore70.where)("subcategoryId", "==", subcategoryId),
27372
+ (0, import_firestore70.orderBy)("name")
26867
27373
  );
26868
- const snapshot = await (0, import_firestore69.getDocs)(q);
27374
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26869
27375
  const technologies = snapshot.docs.map(
26870
- (doc52) => ({
26871
- id: doc52.id,
26872
- ...doc52.data()
27376
+ (doc53) => ({
27377
+ id: doc53.id,
27378
+ ...doc53.data()
26873
27379
  })
26874
27380
  );
26875
27381
  return this.filterExcludedTechnologies(technologies);
@@ -26878,16 +27384,16 @@ var TechnologyService = class extends BaseService {
26878
27384
  * Gets all active technologies for filter dropdowns.
26879
27385
  */
26880
27386
  async getAllForFilter() {
26881
- const q = (0, import_firestore69.query)(
26882
- (0, import_firestore69.collection)(this.db, TECHNOLOGIES_COLLECTION),
26883
- (0, import_firestore69.where)("isActive", "==", true),
26884
- (0, import_firestore69.orderBy)("name")
27387
+ const q = (0, import_firestore70.query)(
27388
+ (0, import_firestore70.collection)(this.db, TECHNOLOGIES_COLLECTION),
27389
+ (0, import_firestore70.where)("isActive", "==", true),
27390
+ (0, import_firestore70.orderBy)("name")
26885
27391
  );
26886
- const snapshot = await (0, import_firestore69.getDocs)(q);
27392
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26887
27393
  const technologies = snapshot.docs.map(
26888
- (doc52) => ({
26889
- id: doc52.id,
26890
- ...doc52.data()
27394
+ (doc53) => ({
27395
+ id: doc53.id,
27396
+ ...doc53.data()
26891
27397
  })
26892
27398
  );
26893
27399
  return this.filterExcludedTechnologies(technologies);
@@ -26900,11 +27406,11 @@ var TechnologyService = class extends BaseService {
26900
27406
  * Updates each product's assignedTechnologyIds array
26901
27407
  */
26902
27408
  async assignProducts(technologyId, productIds) {
26903
- const batch = (0, import_firestore69.writeBatch)(this.db);
27409
+ const batch = (0, import_firestore70.writeBatch)(this.db);
26904
27410
  for (const productId of productIds) {
26905
- const productRef = (0, import_firestore69.doc)(this.db, PRODUCTS_COLLECTION, productId);
27411
+ const productRef = (0, import_firestore70.doc)(this.db, PRODUCTS_COLLECTION, productId);
26906
27412
  batch.update(productRef, {
26907
- assignedTechnologyIds: (0, import_firestore69.arrayUnion)(technologyId),
27413
+ assignedTechnologyIds: (0, import_firestore70.arrayUnion)(technologyId),
26908
27414
  updatedAt: /* @__PURE__ */ new Date()
26909
27415
  });
26910
27416
  }
@@ -26915,11 +27421,11 @@ var TechnologyService = class extends BaseService {
26915
27421
  * Updates each product's assignedTechnologyIds array
26916
27422
  */
26917
27423
  async unassignProducts(technologyId, productIds) {
26918
- const batch = (0, import_firestore69.writeBatch)(this.db);
27424
+ const batch = (0, import_firestore70.writeBatch)(this.db);
26919
27425
  for (const productId of productIds) {
26920
- const productRef = (0, import_firestore69.doc)(this.db, PRODUCTS_COLLECTION, productId);
27426
+ const productRef = (0, import_firestore70.doc)(this.db, PRODUCTS_COLLECTION, productId);
26921
27427
  batch.update(productRef, {
26922
- assignedTechnologyIds: (0, import_firestore69.arrayRemove)(technologyId),
27428
+ assignedTechnologyIds: (0, import_firestore70.arrayRemove)(technologyId),
26923
27429
  updatedAt: /* @__PURE__ */ new Date()
26924
27430
  });
26925
27431
  }
@@ -26930,17 +27436,17 @@ var TechnologyService = class extends BaseService {
26930
27436
  * Reads from top-level collection for immediate consistency (Cloud Functions may lag)
26931
27437
  */
26932
27438
  async getAssignedProducts(technologyId) {
26933
- const q = (0, import_firestore69.query)(
26934
- (0, import_firestore69.collection)(this.db, PRODUCTS_COLLECTION),
26935
- (0, import_firestore69.where)("assignedTechnologyIds", "array-contains", technologyId),
26936
- (0, import_firestore69.where)("isActive", "==", true),
26937
- (0, import_firestore69.orderBy)("name")
27439
+ const q = (0, import_firestore70.query)(
27440
+ (0, import_firestore70.collection)(this.db, PRODUCTS_COLLECTION),
27441
+ (0, import_firestore70.where)("assignedTechnologyIds", "array-contains", technologyId),
27442
+ (0, import_firestore70.where)("isActive", "==", true),
27443
+ (0, import_firestore70.orderBy)("name")
26938
27444
  );
26939
- const snapshot = await (0, import_firestore69.getDocs)(q);
27445
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26940
27446
  return snapshot.docs.map(
26941
- (doc52) => ({
26942
- id: doc52.id,
26943
- ...doc52.data()
27447
+ (doc53) => ({
27448
+ id: doc53.id,
27449
+ ...doc53.data()
26944
27450
  })
26945
27451
  );
26946
27452
  }
@@ -26948,16 +27454,16 @@ var TechnologyService = class extends BaseService {
26948
27454
  * Gets products NOT assigned to a specific technology
26949
27455
  */
26950
27456
  async getUnassignedProducts(technologyId) {
26951
- const q = (0, import_firestore69.query)(
26952
- (0, import_firestore69.collection)(this.db, PRODUCTS_COLLECTION),
26953
- (0, import_firestore69.where)("isActive", "==", true),
26954
- (0, import_firestore69.orderBy)("name")
27457
+ const q = (0, import_firestore70.query)(
27458
+ (0, import_firestore70.collection)(this.db, PRODUCTS_COLLECTION),
27459
+ (0, import_firestore70.where)("isActive", "==", true),
27460
+ (0, import_firestore70.orderBy)("name")
26955
27461
  );
26956
- const snapshot = await (0, import_firestore69.getDocs)(q);
27462
+ const snapshot = await (0, import_firestore70.getDocs)(q);
26957
27463
  const allProducts = snapshot.docs.map(
26958
- (doc52) => ({
26959
- id: doc52.id,
26960
- ...doc52.data()
27464
+ (doc53) => ({
27465
+ id: doc53.id,
27466
+ ...doc53.data()
26961
27467
  })
26962
27468
  );
26963
27469
  return allProducts.filter(
@@ -26988,12 +27494,12 @@ var TechnologyService = class extends BaseService {
26988
27494
  * @param updates - Fields to update (categoryId, subcategoryId, technologyName)
26989
27495
  */
26990
27496
  async updateProductsInSubcollection(technologyId, updates) {
26991
- const productsRef = (0, import_firestore69.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
26992
- const productsSnapshot = await (0, import_firestore69.getDocs)(productsRef);
27497
+ const productsRef = (0, import_firestore70.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
27498
+ const productsSnapshot = await (0, import_firestore70.getDocs)(productsRef);
26993
27499
  if (productsSnapshot.empty) {
26994
27500
  return;
26995
27501
  }
26996
- const batch = (0, import_firestore69.writeBatch)(this.db);
27502
+ const batch = (0, import_firestore70.writeBatch)(this.db);
26997
27503
  for (const productDoc of productsSnapshot.docs) {
26998
27504
  const productRef = productDoc.ref;
26999
27505
  const updateFields = {};
@@ -27047,14 +27553,14 @@ var TechnologyService = class extends BaseService {
27047
27553
  let cursor;
27048
27554
  const constraints = [];
27049
27555
  if (!includeInactive) {
27050
- constraints.push((0, import_firestore69.where)("isActive", "==", true));
27556
+ constraints.push((0, import_firestore70.where)("isActive", "==", true));
27051
27557
  }
27052
- constraints.push((0, import_firestore69.orderBy)("name"));
27558
+ constraints.push((0, import_firestore70.orderBy)("name"));
27053
27559
  while (true) {
27054
- const queryConstraints = [...constraints, (0, import_firestore69.limit)(PAGE_SIZE)];
27055
- if (cursor) queryConstraints.push((0, import_firestore69.startAfter)(cursor));
27056
- const q = (0, import_firestore69.query)(this.technologiesRef, ...queryConstraints);
27057
- const snapshot = await (0, import_firestore69.getDocs)(q);
27560
+ const queryConstraints = [...constraints, (0, import_firestore70.limit)(PAGE_SIZE)];
27561
+ if (cursor) queryConstraints.push((0, import_firestore70.startAfter)(cursor));
27562
+ const q = (0, import_firestore70.query)(this.technologiesRef, ...queryConstraints);
27563
+ const snapshot = await (0, import_firestore70.getDocs)(q);
27058
27564
  if (snapshot.empty) break;
27059
27565
  for (const d of snapshot.docs) {
27060
27566
  if (d.id === EXCLUDED_TECHNOLOGY_ID) continue;
@@ -27073,11 +27579,11 @@ var TechnologyService = class extends BaseService {
27073
27579
  */
27074
27580
  async getProductNamesForTechnology(technologyId) {
27075
27581
  try {
27076
- const productsRef = (0, import_firestore69.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
27077
- const q = (0, import_firestore69.query)(productsRef, (0, import_firestore69.where)("isActive", "==", true));
27078
- const snapshot = await (0, import_firestore69.getDocs)(q);
27079
- return snapshot.docs.map((doc52) => {
27080
- const product = doc52.data();
27582
+ const productsRef = (0, import_firestore70.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
27583
+ const q = (0, import_firestore70.query)(productsRef, (0, import_firestore70.where)("isActive", "==", true));
27584
+ const snapshot = await (0, import_firestore70.getDocs)(q);
27585
+ return snapshot.docs.map((doc53) => {
27586
+ const product = doc53.data();
27081
27587
  return product.name || "";
27082
27588
  }).filter((name) => name);
27083
27589
  } catch (error) {
@@ -27116,14 +27622,14 @@ var TechnologyService = class extends BaseService {
27116
27622
  };
27117
27623
 
27118
27624
  // src/backoffice/services/product.service.ts
27119
- var import_firestore70 = require("firebase/firestore");
27625
+ var import_firestore71 = require("firebase/firestore");
27120
27626
  var ProductService = class extends BaseService {
27121
27627
  /**
27122
27628
  * Gets reference to top-level products collection (source of truth)
27123
27629
  * @returns Firestore collection reference
27124
27630
  */
27125
27631
  getTopLevelProductsRef() {
27126
- return (0, import_firestore70.collection)(this.db, PRODUCTS_COLLECTION);
27632
+ return (0, import_firestore71.collection)(this.db, PRODUCTS_COLLECTION);
27127
27633
  }
27128
27634
  /**
27129
27635
  * Gets reference to products collection under a technology (backward compatibility)
@@ -27131,7 +27637,7 @@ var ProductService = class extends BaseService {
27131
27637
  * @returns Firestore collection reference
27132
27638
  */
27133
27639
  getProductsRef(technologyId) {
27134
- return (0, import_firestore70.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
27640
+ return (0, import_firestore71.collection)(this.db, TECHNOLOGIES_COLLECTION, technologyId, PRODUCTS_COLLECTION);
27135
27641
  }
27136
27642
  /**
27137
27643
  * Creates a new product under technology
@@ -27147,7 +27653,7 @@ var ProductService = class extends BaseService {
27147
27653
  updatedAt: now,
27148
27654
  isActive: true
27149
27655
  };
27150
- const productRef = await (0, import_firestore70.addDoc)(this.getProductsRef(technologyId), newProduct);
27656
+ const productRef = await (0, import_firestore71.addDoc)(this.getProductsRef(technologyId), newProduct);
27151
27657
  return { id: productRef.id, ...newProduct };
27152
27658
  }
27153
27659
  /**
@@ -27156,26 +27662,26 @@ var ProductService = class extends BaseService {
27156
27662
  */
27157
27663
  async getAll(options) {
27158
27664
  const { rowsPerPage, lastVisible, categoryId, subcategoryId, technologyId } = options;
27159
- const constraints = [(0, import_firestore70.where)("isActive", "==", true), (0, import_firestore70.orderBy)("name")];
27665
+ const constraints = [(0, import_firestore71.where)("isActive", "==", true), (0, import_firestore71.orderBy)("name")];
27160
27666
  if (categoryId) {
27161
- constraints.push((0, import_firestore70.where)("categoryId", "==", categoryId));
27667
+ constraints.push((0, import_firestore71.where)("categoryId", "==", categoryId));
27162
27668
  }
27163
27669
  if (subcategoryId) {
27164
- constraints.push((0, import_firestore70.where)("subcategoryId", "==", subcategoryId));
27670
+ constraints.push((0, import_firestore71.where)("subcategoryId", "==", subcategoryId));
27165
27671
  }
27166
27672
  if (technologyId) {
27167
- constraints.push((0, import_firestore70.where)("technologyId", "==", technologyId));
27673
+ constraints.push((0, import_firestore71.where)("technologyId", "==", technologyId));
27168
27674
  }
27169
27675
  if (lastVisible) {
27170
- constraints.push((0, import_firestore70.startAfter)(lastVisible));
27676
+ constraints.push((0, import_firestore71.startAfter)(lastVisible));
27171
27677
  }
27172
- constraints.push((0, import_firestore70.limit)(rowsPerPage));
27173
- const q = (0, import_firestore70.query)((0, import_firestore70.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
27174
- const snapshot = await (0, import_firestore70.getDocs)(q);
27678
+ constraints.push((0, import_firestore71.limit)(rowsPerPage));
27679
+ const q = (0, import_firestore71.query)((0, import_firestore71.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
27680
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27175
27681
  const products = snapshot.docs.map(
27176
- (doc52) => ({
27177
- id: doc52.id,
27178
- ...doc52.data()
27682
+ (doc53) => ({
27683
+ id: doc53.id,
27684
+ ...doc53.data()
27179
27685
  })
27180
27686
  );
27181
27687
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -27186,18 +27692,18 @@ var ProductService = class extends BaseService {
27186
27692
  */
27187
27693
  async getProductsCount(options) {
27188
27694
  const { categoryId, subcategoryId, technologyId } = options;
27189
- const constraints = [(0, import_firestore70.where)("isActive", "==", true)];
27695
+ const constraints = [(0, import_firestore71.where)("isActive", "==", true)];
27190
27696
  if (categoryId) {
27191
- constraints.push((0, import_firestore70.where)("categoryId", "==", categoryId));
27697
+ constraints.push((0, import_firestore71.where)("categoryId", "==", categoryId));
27192
27698
  }
27193
27699
  if (subcategoryId) {
27194
- constraints.push((0, import_firestore70.where)("subcategoryId", "==", subcategoryId));
27700
+ constraints.push((0, import_firestore71.where)("subcategoryId", "==", subcategoryId));
27195
27701
  }
27196
27702
  if (technologyId) {
27197
- constraints.push((0, import_firestore70.where)("technologyId", "==", technologyId));
27703
+ constraints.push((0, import_firestore71.where)("technologyId", "==", technologyId));
27198
27704
  }
27199
- const q = (0, import_firestore70.query)((0, import_firestore70.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
27200
- const snapshot = await (0, import_firestore70.getCountFromServer)(q);
27705
+ const q = (0, import_firestore71.query)((0, import_firestore71.collectionGroup)(this.db, PRODUCTS_COLLECTION), ...constraints);
27706
+ const snapshot = await (0, import_firestore71.getCountFromServer)(q);
27201
27707
  return snapshot.data().count;
27202
27708
  }
27203
27709
  /**
@@ -27210,10 +27716,10 @@ var ProductService = class extends BaseService {
27210
27716
  bySubcategory: {},
27211
27717
  byTechnology: {}
27212
27718
  };
27213
- const q = (0, import_firestore70.query)((0, import_firestore70.collectionGroup)(this.db, PRODUCTS_COLLECTION), (0, import_firestore70.where)("isActive", "==", true));
27214
- const snapshot = await (0, import_firestore70.getDocs)(q);
27215
- snapshot.docs.forEach((doc52) => {
27216
- const product = doc52.data();
27719
+ const q = (0, import_firestore71.query)((0, import_firestore71.collectionGroup)(this.db, PRODUCTS_COLLECTION), (0, import_firestore71.where)("isActive", "==", true));
27720
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27721
+ snapshot.docs.forEach((doc53) => {
27722
+ const product = doc53.data();
27217
27723
  if (product.categoryId) {
27218
27724
  counts.byCategory[product.categoryId] = (counts.byCategory[product.categoryId] || 0) + 1;
27219
27725
  }
@@ -27230,16 +27736,16 @@ var ProductService = class extends BaseService {
27230
27736
  * Gets all products for a specific technology (non-paginated, for filters/dropdowns)
27231
27737
  */
27232
27738
  async getAllByTechnology(technologyId) {
27233
- const q = (0, import_firestore70.query)(
27739
+ const q = (0, import_firestore71.query)(
27234
27740
  this.getProductsRef(technologyId),
27235
- (0, import_firestore70.where)("isActive", "==", true),
27236
- (0, import_firestore70.orderBy)("name")
27741
+ (0, import_firestore71.where)("isActive", "==", true),
27742
+ (0, import_firestore71.orderBy)("name")
27237
27743
  );
27238
- const snapshot = await (0, import_firestore70.getDocs)(q);
27744
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27239
27745
  return snapshot.docs.map(
27240
- (doc52) => ({
27241
- id: doc52.id,
27242
- ...doc52.data()
27746
+ (doc53) => ({
27747
+ id: doc53.id,
27748
+ ...doc53.data()
27243
27749
  })
27244
27750
  );
27245
27751
  }
@@ -27247,21 +27753,21 @@ var ProductService = class extends BaseService {
27247
27753
  * Gets all products for a brand by filtering through all technologies
27248
27754
  */
27249
27755
  async getAllByBrand(brandId) {
27250
- const allTechnologiesRef = (0, import_firestore70.collection)(this.db, TECHNOLOGIES_COLLECTION);
27251
- const technologiesSnapshot = await (0, import_firestore70.getDocs)(allTechnologiesRef);
27756
+ const allTechnologiesRef = (0, import_firestore71.collection)(this.db, TECHNOLOGIES_COLLECTION);
27757
+ const technologiesSnapshot = await (0, import_firestore71.getDocs)(allTechnologiesRef);
27252
27758
  const products = [];
27253
27759
  for (const techDoc of technologiesSnapshot.docs) {
27254
- const q = (0, import_firestore70.query)(
27760
+ const q = (0, import_firestore71.query)(
27255
27761
  this.getProductsRef(techDoc.id),
27256
- (0, import_firestore70.where)("brandId", "==", brandId),
27257
- (0, import_firestore70.where)("isActive", "==", true)
27762
+ (0, import_firestore71.where)("brandId", "==", brandId),
27763
+ (0, import_firestore71.where)("isActive", "==", true)
27258
27764
  );
27259
- const snapshot = await (0, import_firestore70.getDocs)(q);
27765
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27260
27766
  products.push(
27261
27767
  ...snapshot.docs.map(
27262
- (doc52) => ({
27263
- id: doc52.id,
27264
- ...doc52.data()
27768
+ (doc53) => ({
27769
+ id: doc53.id,
27770
+ ...doc53.data()
27265
27771
  })
27266
27772
  )
27267
27773
  );
@@ -27276,8 +27782,8 @@ var ProductService = class extends BaseService {
27276
27782
  ...product,
27277
27783
  updatedAt: /* @__PURE__ */ new Date()
27278
27784
  };
27279
- const docRef = (0, import_firestore70.doc)(this.getProductsRef(technologyId), productId);
27280
- await (0, import_firestore70.updateDoc)(docRef, updateData);
27785
+ const docRef = (0, import_firestore71.doc)(this.getProductsRef(technologyId), productId);
27786
+ await (0, import_firestore71.updateDoc)(docRef, updateData);
27281
27787
  return this.getById(technologyId, productId);
27282
27788
  }
27283
27789
  /**
@@ -27292,8 +27798,8 @@ var ProductService = class extends BaseService {
27292
27798
  * Gets a product by ID
27293
27799
  */
27294
27800
  async getById(technologyId, productId) {
27295
- const docRef = (0, import_firestore70.doc)(this.getProductsRef(technologyId), productId);
27296
- const docSnap = await (0, import_firestore70.getDoc)(docRef);
27801
+ const docRef = (0, import_firestore71.doc)(this.getProductsRef(technologyId), productId);
27802
+ const docSnap = await (0, import_firestore71.getDoc)(docRef);
27297
27803
  if (!docSnap.exists()) return null;
27298
27804
  return {
27299
27805
  id: docSnap.id,
@@ -27315,7 +27821,7 @@ var ProductService = class extends BaseService {
27315
27821
  updatedAt: now,
27316
27822
  isActive: true
27317
27823
  };
27318
- const productRef = await (0, import_firestore70.addDoc)(this.getTopLevelProductsRef(), newProduct);
27824
+ const productRef = await (0, import_firestore71.addDoc)(this.getTopLevelProductsRef(), newProduct);
27319
27825
  return { id: productRef.id, ...newProduct };
27320
27826
  }
27321
27827
  /**
@@ -27329,25 +27835,25 @@ var ProductService = class extends BaseService {
27329
27835
  brandId: brandId || "none",
27330
27836
  category: category || "none"
27331
27837
  });
27332
- const constraints = [(0, import_firestore70.where)("isActive", "==", true), (0, import_firestore70.orderBy)("name")];
27838
+ const constraints = [(0, import_firestore71.where)("isActive", "==", true), (0, import_firestore71.orderBy)("name")];
27333
27839
  if (brandId) {
27334
27840
  console.log("[ProductService.getAllTopLevel] Adding brandId filter:", brandId);
27335
- constraints.push((0, import_firestore70.where)("brandId", "==", brandId));
27841
+ constraints.push((0, import_firestore71.where)("brandId", "==", brandId));
27336
27842
  }
27337
27843
  if (category) {
27338
27844
  console.log("[ProductService.getAllTopLevel] Adding category filter:", category);
27339
- constraints.push((0, import_firestore70.where)("category", "==", category));
27845
+ constraints.push((0, import_firestore71.where)("category", "==", category));
27340
27846
  }
27341
27847
  if (lastVisible) {
27342
- constraints.push((0, import_firestore70.startAfter)(lastVisible));
27848
+ constraints.push((0, import_firestore71.startAfter)(lastVisible));
27343
27849
  }
27344
- constraints.push((0, import_firestore70.limit)(rowsPerPage));
27345
- const q = (0, import_firestore70.query)(this.getTopLevelProductsRef(), ...constraints);
27346
- const snapshot = await (0, import_firestore70.getDocs)(q);
27850
+ constraints.push((0, import_firestore71.limit)(rowsPerPage));
27851
+ const q = (0, import_firestore71.query)(this.getTopLevelProductsRef(), ...constraints);
27852
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27347
27853
  const products = snapshot.docs.map(
27348
- (doc52) => ({
27349
- id: doc52.id,
27350
- ...doc52.data()
27854
+ (doc53) => ({
27855
+ id: doc53.id,
27856
+ ...doc53.data()
27351
27857
  })
27352
27858
  );
27353
27859
  const newLastVisible = snapshot.docs[snapshot.docs.length - 1];
@@ -27357,8 +27863,8 @@ var ProductService = class extends BaseService {
27357
27863
  * Gets a product by ID from the top-level collection
27358
27864
  */
27359
27865
  async getByIdTopLevel(productId) {
27360
- const docRef = (0, import_firestore70.doc)(this.getTopLevelProductsRef(), productId);
27361
- const docSnap = await (0, import_firestore70.getDoc)(docRef);
27866
+ const docRef = (0, import_firestore71.doc)(this.getTopLevelProductsRef(), productId);
27867
+ const docSnap = await (0, import_firestore71.getDoc)(docRef);
27362
27868
  if (!docSnap.exists()) return null;
27363
27869
  return {
27364
27870
  id: docSnap.id,
@@ -27373,8 +27879,8 @@ var ProductService = class extends BaseService {
27373
27879
  ...product,
27374
27880
  updatedAt: /* @__PURE__ */ new Date()
27375
27881
  };
27376
- const docRef = (0, import_firestore70.doc)(this.getTopLevelProductsRef(), productId);
27377
- await (0, import_firestore70.updateDoc)(docRef, updateData);
27882
+ const docRef = (0, import_firestore71.doc)(this.getTopLevelProductsRef(), productId);
27883
+ await (0, import_firestore71.updateDoc)(docRef, updateData);
27378
27884
  return this.getByIdTopLevel(productId);
27379
27885
  }
27380
27886
  /**
@@ -27389,9 +27895,9 @@ var ProductService = class extends BaseService {
27389
27895
  * Assigns a product to a technology
27390
27896
  */
27391
27897
  async assignToTechnology(productId, technologyId) {
27392
- const docRef = (0, import_firestore70.doc)(this.getTopLevelProductsRef(), productId);
27393
- await (0, import_firestore70.updateDoc)(docRef, {
27394
- assignedTechnologyIds: (0, import_firestore70.arrayUnion)(technologyId),
27898
+ const docRef = (0, import_firestore71.doc)(this.getTopLevelProductsRef(), productId);
27899
+ await (0, import_firestore71.updateDoc)(docRef, {
27900
+ assignedTechnologyIds: (0, import_firestore71.arrayUnion)(technologyId),
27395
27901
  updatedAt: /* @__PURE__ */ new Date()
27396
27902
  });
27397
27903
  }
@@ -27399,9 +27905,9 @@ var ProductService = class extends BaseService {
27399
27905
  * Unassigns a product from a technology
27400
27906
  */
27401
27907
  async unassignFromTechnology(productId, technologyId) {
27402
- const docRef = (0, import_firestore70.doc)(this.getTopLevelProductsRef(), productId);
27403
- await (0, import_firestore70.updateDoc)(docRef, {
27404
- assignedTechnologyIds: (0, import_firestore70.arrayRemove)(technologyId),
27908
+ const docRef = (0, import_firestore71.doc)(this.getTopLevelProductsRef(), productId);
27909
+ await (0, import_firestore71.updateDoc)(docRef, {
27910
+ assignedTechnologyIds: (0, import_firestore71.arrayRemove)(technologyId),
27405
27911
  updatedAt: /* @__PURE__ */ new Date()
27406
27912
  });
27407
27913
  }
@@ -27409,17 +27915,17 @@ var ProductService = class extends BaseService {
27409
27915
  * Gets products assigned to a specific technology
27410
27916
  */
27411
27917
  async getAssignedProducts(technologyId) {
27412
- const q = (0, import_firestore70.query)(
27918
+ const q = (0, import_firestore71.query)(
27413
27919
  this.getTopLevelProductsRef(),
27414
- (0, import_firestore70.where)("assignedTechnologyIds", "array-contains", technologyId),
27415
- (0, import_firestore70.where)("isActive", "==", true),
27416
- (0, import_firestore70.orderBy)("name")
27920
+ (0, import_firestore71.where)("assignedTechnologyIds", "array-contains", technologyId),
27921
+ (0, import_firestore71.where)("isActive", "==", true),
27922
+ (0, import_firestore71.orderBy)("name")
27417
27923
  );
27418
- const snapshot = await (0, import_firestore70.getDocs)(q);
27924
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27419
27925
  return snapshot.docs.map(
27420
- (doc52) => ({
27421
- id: doc52.id,
27422
- ...doc52.data()
27926
+ (doc53) => ({
27927
+ id: doc53.id,
27928
+ ...doc53.data()
27423
27929
  })
27424
27930
  );
27425
27931
  }
@@ -27427,16 +27933,16 @@ var ProductService = class extends BaseService {
27427
27933
  * Gets products NOT assigned to a specific technology
27428
27934
  */
27429
27935
  async getUnassignedProducts(technologyId) {
27430
- const q = (0, import_firestore70.query)(
27936
+ const q = (0, import_firestore71.query)(
27431
27937
  this.getTopLevelProductsRef(),
27432
- (0, import_firestore70.where)("isActive", "==", true),
27433
- (0, import_firestore70.orderBy)("name")
27938
+ (0, import_firestore71.where)("isActive", "==", true),
27939
+ (0, import_firestore71.orderBy)("name")
27434
27940
  );
27435
- const snapshot = await (0, import_firestore70.getDocs)(q);
27941
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27436
27942
  const allProducts = snapshot.docs.map(
27437
- (doc52) => ({
27438
- id: doc52.id,
27439
- ...doc52.data()
27943
+ (doc53) => ({
27944
+ id: doc53.id,
27945
+ ...doc53.data()
27440
27946
  })
27441
27947
  );
27442
27948
  return allProducts.filter(
@@ -27450,17 +27956,17 @@ var ProductService = class extends BaseService {
27450
27956
  * Gets all products for a brand (from top-level collection)
27451
27957
  */
27452
27958
  async getByBrand(brandId) {
27453
- const q = (0, import_firestore70.query)(
27959
+ const q = (0, import_firestore71.query)(
27454
27960
  this.getTopLevelProductsRef(),
27455
- (0, import_firestore70.where)("brandId", "==", brandId),
27456
- (0, import_firestore70.where)("isActive", "==", true),
27457
- (0, import_firestore70.orderBy)("name")
27961
+ (0, import_firestore71.where)("brandId", "==", brandId),
27962
+ (0, import_firestore71.where)("isActive", "==", true),
27963
+ (0, import_firestore71.orderBy)("name")
27458
27964
  );
27459
- const snapshot = await (0, import_firestore70.getDocs)(q);
27965
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27460
27966
  return snapshot.docs.map(
27461
- (doc52) => ({
27462
- id: doc52.id,
27463
- ...doc52.data()
27967
+ (doc53) => ({
27968
+ id: doc53.id,
27969
+ ...doc53.data()
27464
27970
  })
27465
27971
  );
27466
27972
  }
@@ -27490,14 +27996,14 @@ var ProductService = class extends BaseService {
27490
27996
  let cursor;
27491
27997
  const constraints = [];
27492
27998
  if (!includeInactive) {
27493
- constraints.push((0, import_firestore70.where)("isActive", "==", true));
27999
+ constraints.push((0, import_firestore71.where)("isActive", "==", true));
27494
28000
  }
27495
- constraints.push((0, import_firestore70.orderBy)("name"));
28001
+ constraints.push((0, import_firestore71.orderBy)("name"));
27496
28002
  while (true) {
27497
- const queryConstraints = [...constraints, (0, import_firestore70.limit)(PAGE_SIZE)];
27498
- if (cursor) queryConstraints.push((0, import_firestore70.startAfter)(cursor));
27499
- const q = (0, import_firestore70.query)(this.getTopLevelProductsRef(), ...queryConstraints);
27500
- const snapshot = await (0, import_firestore70.getDocs)(q);
28003
+ const queryConstraints = [...constraints, (0, import_firestore71.limit)(PAGE_SIZE)];
28004
+ if (cursor) queryConstraints.push((0, import_firestore71.startAfter)(cursor));
28005
+ const q = (0, import_firestore71.query)(this.getTopLevelProductsRef(), ...queryConstraints);
28006
+ const snapshot = await (0, import_firestore71.getDocs)(q);
27501
28007
  if (snapshot.empty) break;
27502
28008
  for (const d of snapshot.docs) {
27503
28009
  const product = { id: d.id, ...d.data() };
@@ -27540,7 +28046,7 @@ var ProductService = class extends BaseService {
27540
28046
  };
27541
28047
 
27542
28048
  // src/backoffice/services/constants.service.ts
27543
- var import_firestore71 = require("firebase/firestore");
28049
+ var import_firestore72 = require("firebase/firestore");
27544
28050
  var ADMIN_CONSTANTS_COLLECTION = "admin-constants";
27545
28051
  var TREATMENT_BENEFITS_DOC = "treatment-benefits";
27546
28052
  var CONTRAINDICATIONS_DOC = "contraindications";
@@ -27551,7 +28057,7 @@ var ConstantsService = class extends BaseService {
27551
28057
  * @type {DocumentReference}
27552
28058
  */
27553
28059
  get treatmentBenefitsDocRef() {
27554
- return (0, import_firestore71.doc)(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
28060
+ return (0, import_firestore72.doc)(this.db, ADMIN_CONSTANTS_COLLECTION, TREATMENT_BENEFITS_DOC);
27555
28061
  }
27556
28062
  /**
27557
28063
  * @description Gets the reference to the document holding contraindications.
@@ -27559,7 +28065,7 @@ var ConstantsService = class extends BaseService {
27559
28065
  * @type {DocumentReference}
27560
28066
  */
27561
28067
  get contraindicationsDocRef() {
27562
- return (0, import_firestore71.doc)(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
28068
+ return (0, import_firestore72.doc)(this.db, ADMIN_CONSTANTS_COLLECTION, CONTRAINDICATIONS_DOC);
27563
28069
  }
27564
28070
  // =================================================================
27565
28071
  // Treatment Benefits
@@ -27569,7 +28075,7 @@ var ConstantsService = class extends BaseService {
27569
28075
  * @returns {Promise<TreatmentBenefitDynamic[]>} An array of all treatment benefits.
27570
28076
  */
27571
28077
  async getAllBenefitsForFilter() {
27572
- const docSnap = await (0, import_firestore71.getDoc)(this.treatmentBenefitsDocRef);
28078
+ const docSnap = await (0, import_firestore72.getDoc)(this.treatmentBenefitsDocRef);
27573
28079
  if (!docSnap.exists()) {
27574
28080
  return [];
27575
28081
  }
@@ -27598,12 +28104,12 @@ var ConstantsService = class extends BaseService {
27598
28104
  id: this.generateId(),
27599
28105
  ...benefit
27600
28106
  };
27601
- const docSnap = await (0, import_firestore71.getDoc)(this.treatmentBenefitsDocRef);
28107
+ const docSnap = await (0, import_firestore72.getDoc)(this.treatmentBenefitsDocRef);
27602
28108
  if (!docSnap.exists()) {
27603
- await (0, import_firestore71.setDoc)(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
28109
+ await (0, import_firestore72.setDoc)(this.treatmentBenefitsDocRef, { benefits: [newBenefit] });
27604
28110
  } else {
27605
- await (0, import_firestore71.updateDoc)(this.treatmentBenefitsDocRef, {
27606
- benefits: (0, import_firestore71.arrayUnion)(newBenefit)
28111
+ await (0, import_firestore72.updateDoc)(this.treatmentBenefitsDocRef, {
28112
+ benefits: (0, import_firestore72.arrayUnion)(newBenefit)
27607
28113
  });
27608
28114
  }
27609
28115
  return newBenefit;
@@ -27642,7 +28148,7 @@ var ConstantsService = class extends BaseService {
27642
28148
  throw new Error("Treatment benefit not found.");
27643
28149
  }
27644
28150
  benefits[benefitIndex] = benefit;
27645
- await (0, import_firestore71.updateDoc)(this.treatmentBenefitsDocRef, { benefits });
28151
+ await (0, import_firestore72.updateDoc)(this.treatmentBenefitsDocRef, { benefits });
27646
28152
  return benefit;
27647
28153
  }
27648
28154
  /**
@@ -27656,8 +28162,8 @@ var ConstantsService = class extends BaseService {
27656
28162
  if (!benefitToRemove) {
27657
28163
  return;
27658
28164
  }
27659
- await (0, import_firestore71.updateDoc)(this.treatmentBenefitsDocRef, {
27660
- benefits: (0, import_firestore71.arrayRemove)(benefitToRemove)
28165
+ await (0, import_firestore72.updateDoc)(this.treatmentBenefitsDocRef, {
28166
+ benefits: (0, import_firestore72.arrayRemove)(benefitToRemove)
27661
28167
  });
27662
28168
  }
27663
28169
  // =================================================================
@@ -27668,7 +28174,7 @@ var ConstantsService = class extends BaseService {
27668
28174
  * @returns {Promise<ContraindicationDynamic[]>} An array of all contraindications.
27669
28175
  */
27670
28176
  async getAllContraindicationsForFilter() {
27671
- const docSnap = await (0, import_firestore71.getDoc)(this.contraindicationsDocRef);
28177
+ const docSnap = await (0, import_firestore72.getDoc)(this.contraindicationsDocRef);
27672
28178
  if (!docSnap.exists()) {
27673
28179
  return [];
27674
28180
  }
@@ -27703,14 +28209,14 @@ var ConstantsService = class extends BaseService {
27703
28209
  id: this.generateId(),
27704
28210
  ...contraindication
27705
28211
  };
27706
- const docSnap = await (0, import_firestore71.getDoc)(this.contraindicationsDocRef);
28212
+ const docSnap = await (0, import_firestore72.getDoc)(this.contraindicationsDocRef);
27707
28213
  if (!docSnap.exists()) {
27708
- await (0, import_firestore71.setDoc)(this.contraindicationsDocRef, {
28214
+ await (0, import_firestore72.setDoc)(this.contraindicationsDocRef, {
27709
28215
  contraindications: [newContraindication]
27710
28216
  });
27711
28217
  } else {
27712
- await (0, import_firestore71.updateDoc)(this.contraindicationsDocRef, {
27713
- contraindications: (0, import_firestore71.arrayUnion)(newContraindication)
28218
+ await (0, import_firestore72.updateDoc)(this.contraindicationsDocRef, {
28219
+ contraindications: (0, import_firestore72.arrayUnion)(newContraindication)
27714
28220
  });
27715
28221
  }
27716
28222
  return newContraindication;
@@ -27751,7 +28257,7 @@ var ConstantsService = class extends BaseService {
27751
28257
  throw new Error("Contraindication not found.");
27752
28258
  }
27753
28259
  contraindications[index] = contraindication;
27754
- await (0, import_firestore71.updateDoc)(this.contraindicationsDocRef, { contraindications });
28260
+ await (0, import_firestore72.updateDoc)(this.contraindicationsDocRef, { contraindications });
27755
28261
  return contraindication;
27756
28262
  }
27757
28263
  /**
@@ -27765,8 +28271,8 @@ var ConstantsService = class extends BaseService {
27765
28271
  if (!toRemove) {
27766
28272
  return;
27767
28273
  }
27768
- await (0, import_firestore71.updateDoc)(this.contraindicationsDocRef, {
27769
- contraindications: (0, import_firestore71.arrayRemove)(toRemove)
28274
+ await (0, import_firestore72.updateDoc)(this.contraindicationsDocRef, {
28275
+ contraindications: (0, import_firestore72.arrayRemove)(toRemove)
27770
28276
  });
27771
28277
  }
27772
28278
  // =================================================================
@@ -27983,9 +28489,15 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
27983
28489
  ProcedureService,
27984
28490
  ProductService,
27985
28491
  REGISTER_TOKENS_COLLECTION,
28492
+ RESOURCES_COLLECTION,
28493
+ RESOURCE_CALENDAR_SUBCOLLECTION,
28494
+ RESOURCE_INSTANCES_SUBCOLLECTION,
27986
28495
  REVENUE_ANALYTICS_SUBCOLLECTION,
27987
28496
  REVIEWS_COLLECTION,
27988
28497
  RequirementType,
28498
+ ResourceCategory,
28499
+ ResourceService,
28500
+ ResourceStatus,
27989
28501
  ReviewAnalyticsService,
27990
28502
  ReviewService,
27991
28503
  SKIN_QUALITY_ASSESSMENT_COLLECTION,