@speakableio/core 0.1.106 → 1.0.1

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 (57) hide show
  1. package/dist/analytics.js +329 -25
  2. package/dist/analytics.js.map +1 -1
  3. package/dist/index.native.d.mts +2836 -0
  4. package/dist/index.native.d.ts +2272 -27
  5. package/dist/index.native.js +2995 -166
  6. package/dist/index.native.js.map +1 -1
  7. package/dist/index.native.mjs +3322 -0
  8. package/dist/index.native.mjs.map +1 -0
  9. package/dist/index.web.d.mts +2836 -0
  10. package/dist/index.web.js +3244 -12
  11. package/dist/index.web.js.map +1 -1
  12. package/package.json +10 -61
  13. package/dist/assignment.constants-BIKM6fYi.d.ts +0 -32
  14. package/dist/assignment.model-DLMWAp0Y.d.ts +0 -301
  15. package/dist/card.constants-DhKFipX3.d.ts +0 -54
  16. package/dist/chunk-233VJDUF.js +0 -149
  17. package/dist/chunk-233VJDUF.js.map +0 -1
  18. package/dist/chunk-2CRI5MJP.js +0 -225
  19. package/dist/chunk-2CRI5MJP.js.map +0 -1
  20. package/dist/chunk-AWVUNWML.js +0 -141
  21. package/dist/chunk-AWVUNWML.js.map +0 -1
  22. package/dist/chunk-CJ5JXKII.js +0 -129
  23. package/dist/chunk-CJ5JXKII.js.map +0 -1
  24. package/dist/chunk-EEBMPASA.js +0 -21
  25. package/dist/chunk-EEBMPASA.js.map +0 -1
  26. package/dist/chunk-H5XNOXRC.js +0 -11
  27. package/dist/chunk-H5XNOXRC.js.map +0 -1
  28. package/dist/chunk-LZG3MTSH.js +0 -53
  29. package/dist/chunk-LZG3MTSH.js.map +0 -1
  30. package/dist/chunk-OLSTHM2U.js +0 -154
  31. package/dist/chunk-OLSTHM2U.js.map +0 -1
  32. package/dist/chunk-TQGDTKTE.js +0 -13
  33. package/dist/chunk-TQGDTKTE.js.map +0 -1
  34. package/dist/chunk-YKUMIPSO.js +0 -212
  35. package/dist/chunk-YKUMIPSO.js.map +0 -1
  36. package/dist/chunk-YMJRCINF.js +0 -68
  37. package/dist/chunk-YMJRCINF.js.map +0 -1
  38. package/dist/chunk-YO34TZYN.js +0 -28
  39. package/dist/chunk-YO34TZYN.js.map +0 -1
  40. package/dist/const.d.ts +0 -331
  41. package/dist/const.js +0 -193
  42. package/dist/const.js.map +0 -1
  43. package/dist/hooks.d.ts +0 -294
  44. package/dist/hooks.js +0 -1015
  45. package/dist/hooks.js.map +0 -1
  46. package/dist/index.web.d.ts +0 -405
  47. package/dist/models.d.ts +0 -56
  48. package/dist/models.js +0 -17
  49. package/dist/models.js.map +0 -1
  50. package/dist/notification.constants-Da4-_0kX.d.ts +0 -21
  51. package/dist/repos.d.ts +0 -209
  52. package/dist/repos.js +0 -26
  53. package/dist/repos.js.map +0 -1
  54. package/dist/utils.d.ts +0 -39
  55. package/dist/utils.js +0 -180
  56. package/dist/utils.js.map +0 -1
  57. /package/dist/{analytics.d.ts → analytics.d.mts} +0 -0
@@ -0,0 +1,3322 @@
1
+ // src/providers/SpeakableProvider.tsx
2
+ import { createContext, useContext, useEffect, useState } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var FsCtx = createContext(null);
5
+ function SpeakableProvider({
6
+ user,
7
+ children,
8
+ queryClient,
9
+ permissions,
10
+ fsClient
11
+ }) {
12
+ const [speakableApi, setSpeakableApi] = useState(null);
13
+ useEffect(() => {
14
+ setSpeakableApi(fsClient);
15
+ }, [fsClient]);
16
+ if (!speakableApi) return null;
17
+ return /* @__PURE__ */ jsx(
18
+ FsCtx.Provider,
19
+ {
20
+ value: {
21
+ speakableApi,
22
+ queryClient,
23
+ user,
24
+ permissions
25
+ },
26
+ children
27
+ }
28
+ );
29
+ }
30
+ function useSpeakableApi() {
31
+ const ctx = useContext(FsCtx);
32
+ if (!ctx) throw new Error("useSpeakableApi must be used within a SpeakableProvider");
33
+ return ctx;
34
+ }
35
+
36
+ // src/utils/error-handler.ts
37
+ var ServiceError = class extends Error {
38
+ constructor(message, originalError, code) {
39
+ super(message);
40
+ this.originalError = originalError;
41
+ this.code = code;
42
+ this.name = "ServiceError";
43
+ }
44
+ };
45
+ function withErrorHandler(fn, serviceName) {
46
+ return async (...args) => {
47
+ try {
48
+ return await fn(...args);
49
+ } catch (error) {
50
+ if (error instanceof Error && "code" in error) {
51
+ const firebaseError = error;
52
+ throw new ServiceError(
53
+ `Error in ${serviceName}: ${firebaseError.message}`,
54
+ error,
55
+ firebaseError.code
56
+ );
57
+ }
58
+ if (error instanceof Error) {
59
+ throw new ServiceError(`Error in ${serviceName}: ${error.message}`, error);
60
+ }
61
+ throw new ServiceError(`Unknown error in ${serviceName}`, error);
62
+ }
63
+ };
64
+ }
65
+
66
+ // src/lib/firebase/api.ts
67
+ var FirebaseAPI = class _FirebaseAPI {
68
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
69
+ constructor() {
70
+ this.config = null;
71
+ }
72
+ static getInstance() {
73
+ if (!_FirebaseAPI.instance) {
74
+ _FirebaseAPI.instance = new _FirebaseAPI();
75
+ }
76
+ return _FirebaseAPI.instance;
77
+ }
78
+ initialize(config) {
79
+ this.config = config;
80
+ }
81
+ get db() {
82
+ if (!this.config) throw new Error("Firebase API not initialized");
83
+ return this.config.db;
84
+ }
85
+ get helpers() {
86
+ if (!this.config) throw new Error("Firebase API not initialized");
87
+ return this.config.helpers;
88
+ }
89
+ get httpsCallable() {
90
+ var _a;
91
+ return (_a = this.config) == null ? void 0 : _a.httpsCallable;
92
+ }
93
+ logEvent(name, data) {
94
+ var _a;
95
+ (_a = this.config) == null ? void 0 : _a.logEvent(name, data);
96
+ }
97
+ accessQueryConstraints() {
98
+ const { query: query2, orderBy: orderBy2, limit: limit2, startAt: startAt2, startAfter: startAfter2, endAt: endAt2, endBefore: endBefore2, where: where2, increment: increment2 } = this.helpers;
99
+ return {
100
+ query: query2,
101
+ orderBy: orderBy2,
102
+ limit: limit2,
103
+ startAt: startAt2,
104
+ startAfter: startAfter2,
105
+ endAt: endAt2,
106
+ endBefore: endBefore2,
107
+ where: where2,
108
+ increment: increment2
109
+ };
110
+ }
111
+ accessHelpers() {
112
+ const { doc: doc2, collection: collection2, writeBatch: writeBatch2, serverTimestamp: serverTimestamp2, setDoc: setDoc2 } = this.helpers;
113
+ return {
114
+ doc: (path) => doc2(this.db, path),
115
+ collection: (path) => collection2(this.db, path),
116
+ writeBatch: () => writeBatch2(this.db),
117
+ serverTimestamp: serverTimestamp2,
118
+ setDoc: setDoc2
119
+ };
120
+ }
121
+ async getDoc(path) {
122
+ const { getDoc: getDoc2, doc: doc2 } = this.helpers;
123
+ const docRef = doc2(this.db, path);
124
+ const docSnap = await getDoc2(docRef);
125
+ const data = docSnap.exists() ? {
126
+ ...docSnap.data(),
127
+ id: docSnap.id
128
+ } : null;
129
+ return {
130
+ id: docSnap.id,
131
+ data
132
+ };
133
+ }
134
+ async getDocs(path, ...queryConstraints) {
135
+ const { getDocs: getDocs2, query: query2, collection: collection2 } = this.helpers;
136
+ const collectionRef = collection2(this.db, path);
137
+ const q = queryConstraints.length > 0 ? query2(collectionRef, ...queryConstraints) : collectionRef;
138
+ const querySnapshot = await getDocs2(q);
139
+ const data = querySnapshot.docs.map((doc2) => ({
140
+ data: doc2.data(),
141
+ id: doc2.id
142
+ }));
143
+ return {
144
+ data,
145
+ querySnapshot,
146
+ empty: querySnapshot.empty
147
+ };
148
+ }
149
+ async addDoc(path, data) {
150
+ const { addDoc: addDoc2, collection: collection2 } = this.helpers;
151
+ const collectionRef = collection2(this.db, path);
152
+ const docRef = await addDoc2(collectionRef, data);
153
+ return {
154
+ ...data,
155
+ id: docRef.id
156
+ };
157
+ }
158
+ async setDoc(path, data, options = {}) {
159
+ const { setDoc: setDoc2, doc: doc2 } = this.helpers;
160
+ const docRef = doc2(this.db, path);
161
+ await setDoc2(docRef, data, options);
162
+ }
163
+ async updateDoc(path, data) {
164
+ const { updateDoc: updateDoc2, doc: doc2 } = this.helpers;
165
+ const docRef = doc2(this.db, path);
166
+ await updateDoc2(docRef, data);
167
+ }
168
+ async deleteDoc(path) {
169
+ const { deleteDoc: deleteDoc2, doc: doc2 } = this.helpers;
170
+ const docRef = doc2(this.db, path);
171
+ await deleteDoc2(docRef);
172
+ }
173
+ async runTransaction(updateFunction) {
174
+ const { runTransaction: runTransaction2 } = this.helpers;
175
+ return runTransaction2(this.db, updateFunction);
176
+ }
177
+ async runBatch(operations) {
178
+ const { writeBatch: writeBatch2 } = this.helpers;
179
+ const batch = writeBatch2(this.db);
180
+ await Promise.all(operations.map((op) => op()));
181
+ await batch.commit();
182
+ }
183
+ writeBatch() {
184
+ const { writeBatch: writeBatch2 } = this.helpers;
185
+ const batch = writeBatch2(this.db);
186
+ return batch;
187
+ }
188
+ };
189
+ var api = FirebaseAPI.getInstance();
190
+
191
+ // src/domains/assignment/assignment.constants.ts
192
+ var ASSIGNMENT_ANALYTICS_TYPES = [
193
+ "macro" /* Macro */,
194
+ "gradebook" /* Gradebook */,
195
+ "cards" /* Cards */,
196
+ "student" /* Student */,
197
+ "student_summary" /* StudentSummary */
198
+ ];
199
+ var ASSIGNMENTS_COLLECTION = "assignments";
200
+ var ANALYTICS_SUBCOLLECTION = "analytics";
201
+ var SCORES_SUBCOLLECTION = "scores";
202
+ var refsAssignmentFiresotre = {
203
+ allAssignments: () => ASSIGNMENTS_COLLECTION,
204
+ assignment: (params) => `${ASSIGNMENTS_COLLECTION}/${params.id}`,
205
+ assignmentAllAnalytics: (params) => `${ASSIGNMENTS_COLLECTION}/${params.id}/${ANALYTICS_SUBCOLLECTION}`,
206
+ assignmentAnalytics: (params) => `${ASSIGNMENTS_COLLECTION}/${params.id}/${ANALYTICS_SUBCOLLECTION}/${params.type}`,
207
+ assignmentScores: (params) => `${ASSIGNMENTS_COLLECTION}/${params.id}/${SCORES_SUBCOLLECTION}/${params.userId}`
208
+ };
209
+
210
+ // src/domains/assignment/services/get-assignments-score.service.ts
211
+ var _getAssignmentScores = async ({
212
+ assignmentId,
213
+ analyticType = "macro" /* Macro */,
214
+ studentId,
215
+ currentUserId
216
+ }) => {
217
+ if (analyticType === "student" /* Student */) {
218
+ const path = refsAssignmentFiresotre.assignmentScores({
219
+ id: assignmentId,
220
+ userId: currentUserId
221
+ });
222
+ const response = await api.getDoc(path);
223
+ return { scores: response.data, id: assignmentId };
224
+ }
225
+ if (analyticType === "student_summary" /* StudentSummary */ && studentId) {
226
+ const path = refsAssignmentFiresotre.assignmentScores({
227
+ id: assignmentId,
228
+ userId: studentId
229
+ });
230
+ const response = await api.getDoc(path);
231
+ return { scores: response.data, id: assignmentId };
232
+ }
233
+ if (analyticType !== "all" /* All */ && ASSIGNMENT_ANALYTICS_TYPES.includes(analyticType)) {
234
+ const ref = refsAssignmentFiresotre.assignmentAnalytics({
235
+ id: assignmentId,
236
+ type: analyticType
237
+ });
238
+ const docData = await api.getDoc(ref);
239
+ return { scores: docData.data, id: assignmentId };
240
+ } else if (analyticType === "all" /* All */) {
241
+ const ref = refsAssignmentFiresotre.assignmentAllAnalytics({ id: assignmentId });
242
+ const response = await api.getDocs(ref);
243
+ const data = response.data.reduce((acc, curr) => {
244
+ acc[curr.id] = curr;
245
+ return acc;
246
+ }, {});
247
+ return { scores: data, id: assignmentId };
248
+ }
249
+ };
250
+ var getAssignmentScores = withErrorHandler(_getAssignmentScores, "getAssignmentScores");
251
+
252
+ // src/domains/assignment/services/attach-score-assignment.service.ts
253
+ var _attachScoresAssignment = async ({
254
+ assignments,
255
+ analyticType,
256
+ studentId,
257
+ currentUserId
258
+ }) => {
259
+ const scoresPromises = assignments.map((a) => {
260
+ return getAssignmentScores({
261
+ assignmentId: a.id,
262
+ analyticType,
263
+ studentId,
264
+ currentUserId
265
+ });
266
+ });
267
+ const scores = await Promise.all(scoresPromises);
268
+ const scoresObject = scores.reduce((acc, curr) => {
269
+ acc[curr.id] = curr.scores;
270
+ return acc;
271
+ }, {});
272
+ const assignmentsWithScores = assignments.map((a) => {
273
+ var _a;
274
+ return {
275
+ ...a,
276
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/ban-ts-comment
277
+ // @ts-ignore
278
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
279
+ scores: (_a = scoresObject[a.id]) != null ? _a : null
280
+ };
281
+ });
282
+ return assignmentsWithScores;
283
+ };
284
+ var attachScoresAssignment = withErrorHandler(
285
+ _attachScoresAssignment,
286
+ "attachScoresAssignment"
287
+ );
288
+
289
+ // src/domains/assignment/services/get-all-assignment.service.ts
290
+ async function _getAllAssignments() {
291
+ const path = refsAssignmentFiresotre.allAssignments();
292
+ const response = await api.getDocs(path);
293
+ return response.data;
294
+ }
295
+ var getAllAssignments = withErrorHandler(_getAllAssignments, "getAllAssignments");
296
+
297
+ // src/domains/assignment/utils/check-assignment-availability.ts
298
+ import dayjs from "dayjs";
299
+ var checkAssignmentAvailability = (scheduledTime) => {
300
+ if (!scheduledTime) return true;
301
+ const scheduledDate = typeof scheduledTime === "string" ? dayjs(scheduledTime) : dayjs(scheduledTime.toDate());
302
+ if (!scheduledDate.isValid()) return true;
303
+ return dayjs().isAfter(scheduledDate);
304
+ };
305
+
306
+ // src/domains/assignment/services/get-assignment.service.ts
307
+ async function _getAssignment(params) {
308
+ var _a;
309
+ const path = refsAssignmentFiresotre.assignment({ id: params.assignmentId });
310
+ const response = await api.getDoc(path);
311
+ if (!response.data) return null;
312
+ const assignment = response.data;
313
+ const isAvailable = checkAssignmentAvailability(assignment.scheduledTime);
314
+ const assignmentWithId = {
315
+ ...assignment,
316
+ isAvailable,
317
+ id: params.assignmentId,
318
+ scheduledTime: (_a = assignment.scheduledTime) != null ? _a : null
319
+ };
320
+ if (params.analyticType) {
321
+ const assignmentsWithScores = await attachScoresAssignment({
322
+ assignments: [assignmentWithId],
323
+ analyticType: params.analyticType,
324
+ currentUserId: params.currentUserId
325
+ });
326
+ return assignmentsWithScores.length > 0 ? assignmentsWithScores[0] : assignmentWithId;
327
+ }
328
+ return assignmentWithId;
329
+ }
330
+ var getAssignment = withErrorHandler(_getAssignment, "getAssignment");
331
+
332
+ // src/domains/assignment/assignment.repo.ts
333
+ var createAssignmentRepo = () => {
334
+ return {
335
+ getAssignment,
336
+ attachScoresAssignment,
337
+ getAssignmentScores,
338
+ getAllAssignments
339
+ };
340
+ };
341
+
342
+ // src/domains/assignment/hooks/assignment.hooks.ts
343
+ import { useQuery } from "@tanstack/react-query";
344
+ var assignmentQueryKeys = {
345
+ all: ["assignments"],
346
+ byId: (id) => [...assignmentQueryKeys.all, id],
347
+ list: () => [...assignmentQueryKeys.all, "list"]
348
+ };
349
+ function useAssignment({
350
+ assignmentId,
351
+ enabled = true,
352
+ analyticType,
353
+ userId
354
+ }) {
355
+ const { speakableApi } = useSpeakableApi();
356
+ return useQuery({
357
+ queryKey: assignmentQueryKeys.byId(assignmentId),
358
+ queryFn: () => speakableApi.assignmentRepo.getAssignment({
359
+ assignmentId,
360
+ analyticType,
361
+ currentUserId: userId
362
+ }),
363
+ enabled
364
+ });
365
+ }
366
+
367
+ // src/domains/assignment/hooks/score-hooks.ts
368
+ import { useMutation, useQuery as useQuery2 } from "@tanstack/react-query";
369
+
370
+ // src/utils/debounce.utils.ts
371
+ function debounce(func, waitFor) {
372
+ let timeoutId;
373
+ return (...args) => new Promise((resolve, reject) => {
374
+ if (timeoutId) {
375
+ clearTimeout(timeoutId);
376
+ }
377
+ timeoutId = setTimeout(async () => {
378
+ try {
379
+ const result = await func(...args);
380
+ resolve(result);
381
+ } catch (error) {
382
+ reject(error);
383
+ }
384
+ }, waitFor);
385
+ });
386
+ }
387
+
388
+ // src/lib/tanstack/handle-optimistic-update-query.ts
389
+ var handleOptimisticUpdate = async ({
390
+ queryClient,
391
+ queryKey,
392
+ newData
393
+ }) => {
394
+ await queryClient.cancelQueries({
395
+ queryKey
396
+ });
397
+ const previousData = queryClient.getQueryData(queryKey);
398
+ if (previousData === void 0) {
399
+ queryClient.setQueryData(queryKey, newData);
400
+ } else {
401
+ queryClient.setQueryData(queryKey, { ...previousData, ...newData });
402
+ }
403
+ return { previousData };
404
+ };
405
+
406
+ // src/constants/speakable-plans.ts
407
+ var FEEDBACK_PLANS = {
408
+ FEEDBACK_TRANSCRIPT: "FEEDBACK_TRANSCRIPT",
409
+ // Transcript from the audio
410
+ FEEDBACK_SUMMARY: "FEEDBACK_SUMMARY",
411
+ // Chatty summary (Free plan)
412
+ FEEDBACK_GRAMMAR_INSIGHTS: "FEEDBACK_GRAMMAR_INSIGHTS",
413
+ // Grammar insights
414
+ FEEDBACK_SUGGESTED_RESPONSE: "FEEDBACK_SUGGESTED_RESPONSE",
415
+ // Suggested Response
416
+ FEEDBACK_RUBRIC: "FEEDBACK_RUBRIC",
417
+ // Suggested Response
418
+ FEEDBACK_GRADING_STANDARDS: "FEEDBACK_GRADING_STANDARDS",
419
+ // ACTFL / WIDA Estimate
420
+ FEEDBACK_TARGET_LANGUAGE: "FEEDBACK_TARGET_LANGUAGE",
421
+ // Ability to set the feedback language to the target language of the student
422
+ FEEDBACK_DISABLE_ALLOW_RETRIES: "FEEDBACK_DISABLE_ALLOW_RETRIES"
423
+ // Turn of allow retries
424
+ };
425
+ var AUTO_GRADING_PLANS = {
426
+ AUTO_GRADING_PASS_FAIL: "AUTO_GRADING_PASS_FAIL",
427
+ // Pass / fail grading
428
+ AUTO_GRADING_RUBRICS: "AUTO_GRADING_RUBRICS",
429
+ // Autograded rubrics
430
+ AUTO_GRADING_STANDARDS_BASED: "AUTO_GRADING_STANDARDS_BASED"
431
+ // Standards based grading
432
+ };
433
+ var AI_ASSISTANT_PLANS = {
434
+ AI_ASSISTANT_DOCUMENT_UPLOADS: "AI_ASSISTANT_DOCUMENT_UPLOADS",
435
+ // Allow document uploading
436
+ AI_ASSISTANT_UNLIMITED_USE: "AI_ASSISTANT_UNLIMITED_USE"
437
+ // Allow unlimited use of AI assistant. Otherwise, limits are used.
438
+ };
439
+ var ASSIGNMENT_SETTINGS_PLANS = {
440
+ ASSESSMENTS: "ASSESSMENTS",
441
+ // Ability to create assessment assignment types
442
+ GOOGLE_CLASSROOM_GRADE_PASSBACK: "GOOGLE_CLASSROOM_GRADE_PASSBACK"
443
+ // Assignment scores can sync with classroom
444
+ };
445
+ var ANALYTICS_PLANS = {
446
+ ANALYTICS_GRADEBOOK: "ANALYTICS_GRADEBOOK",
447
+ // Access to the gradebook page
448
+ ANALYTICS_CLASSROOM_ANALYTICS: "ANALYTICS_CLASSROOM_ANALYTICS",
449
+ // Access to the classroom analytics page
450
+ ANALYTICS_STUDENT_PROGRESS_REPORTS: "ANALYTICS_STUDENT_PROGRESS_REPORTS",
451
+ // Access to the panel that shows an individual student's progress and assignments
452
+ ANALYTICS_ASSIGNMENT_RESULTS: "ANALYTICS_ASSIGNMENT_RESULTS",
453
+ // Access to the assigment RESULTS page
454
+ ANALYTICS_ORGANIZATION: "ANALYTICS_ORGANIZATION"
455
+ // Access to the organization analytics panel (for permitted admins)
456
+ };
457
+ var SPACES_PLANS = {
458
+ SPACES_CREATE_SPACE: "SPACES_CREATE_SPACE",
459
+ // Ability to create spaces
460
+ SPACES_CHECK_POINTS: "SPACES_CHECK_POINTS"
461
+ // Feature not available yet. Ability to create checkpoints for spaces for data aggregation
462
+ };
463
+ var DISCOVER_PLANS = {
464
+ DISCOVER_ORGANIZATION_LIBRARY: "DISCOVER_ORGANIZATION_LIBRARY"
465
+ // Access to the organizations shared library
466
+ };
467
+ var MEDIA_AREA_PLANS = {
468
+ MEDIA_AREA_DOCUMENT_UPLOAD: "MEDIA_AREA_DOCUMENT_UPLOAD",
469
+ MEDIA_AREA_AUDIO_FILES: "MEDIA_AREA_AUDIO_FILES"
470
+ };
471
+ var FREE_PLAN = [];
472
+ var TEACHER_PRO_PLAN = [
473
+ FEEDBACK_PLANS.FEEDBACK_TRANSCRIPT,
474
+ FEEDBACK_PLANS.FEEDBACK_SUMMARY,
475
+ FEEDBACK_PLANS.FEEDBACK_TARGET_LANGUAGE,
476
+ AUTO_GRADING_PLANS.AUTO_GRADING_PASS_FAIL,
477
+ ANALYTICS_PLANS.ANALYTICS_GRADEBOOK,
478
+ SPACES_PLANS.SPACES_CREATE_SPACE
479
+ // AUTO_GRADING_PLANS.AUTO_GRADING_STANDARDS_BASED,
480
+ ];
481
+ var SCHOOL_STARTER = [
482
+ FEEDBACK_PLANS.FEEDBACK_TRANSCRIPT,
483
+ FEEDBACK_PLANS.FEEDBACK_SUMMARY,
484
+ FEEDBACK_PLANS.FEEDBACK_GRAMMAR_INSIGHTS,
485
+ FEEDBACK_PLANS.FEEDBACK_SUGGESTED_RESPONSE,
486
+ FEEDBACK_PLANS.FEEDBACK_RUBRIC,
487
+ FEEDBACK_PLANS.FEEDBACK_GRADING_STANDARDS,
488
+ FEEDBACK_PLANS.FEEDBACK_DISABLE_ALLOW_RETRIES,
489
+ FEEDBACK_PLANS.FEEDBACK_TARGET_LANGUAGE,
490
+ AUTO_GRADING_PLANS.AUTO_GRADING_PASS_FAIL,
491
+ AUTO_GRADING_PLANS.AUTO_GRADING_RUBRICS,
492
+ AUTO_GRADING_PLANS.AUTO_GRADING_STANDARDS_BASED,
493
+ AI_ASSISTANT_PLANS.AI_ASSISTANT_DOCUMENT_UPLOADS,
494
+ AI_ASSISTANT_PLANS.AI_ASSISTANT_UNLIMITED_USE,
495
+ // ASSIGNMENT_SETTINGS_PLANS.ASSESSMENTS,
496
+ ASSIGNMENT_SETTINGS_PLANS.GOOGLE_CLASSROOM_GRADE_PASSBACK,
497
+ ANALYTICS_PLANS.ANALYTICS_GRADEBOOK,
498
+ ANALYTICS_PLANS.ANALYTICS_STUDENT_PROGRESS_REPORTS,
499
+ ANALYTICS_PLANS.ANALYTICS_CLASSROOM_ANALYTICS,
500
+ // ANALYTICS_PLANS.ANALYTICS_ORGANIZATION,
501
+ SPACES_PLANS.SPACES_CREATE_SPACE,
502
+ SPACES_PLANS.SPACES_CHECK_POINTS,
503
+ // DISCOVER_PLANS.DISCOVER_ORGANIZATION_LIBRARY,
504
+ MEDIA_AREA_PLANS.MEDIA_AREA_DOCUMENT_UPLOAD,
505
+ MEDIA_AREA_PLANS.MEDIA_AREA_AUDIO_FILES
506
+ ];
507
+ var ORGANIZATION_PLAN = [
508
+ FEEDBACK_PLANS.FEEDBACK_TRANSCRIPT,
509
+ FEEDBACK_PLANS.FEEDBACK_SUMMARY,
510
+ FEEDBACK_PLANS.FEEDBACK_GRAMMAR_INSIGHTS,
511
+ FEEDBACK_PLANS.FEEDBACK_SUGGESTED_RESPONSE,
512
+ FEEDBACK_PLANS.FEEDBACK_RUBRIC,
513
+ FEEDBACK_PLANS.FEEDBACK_GRADING_STANDARDS,
514
+ FEEDBACK_PLANS.FEEDBACK_DISABLE_ALLOW_RETRIES,
515
+ FEEDBACK_PLANS.FEEDBACK_TARGET_LANGUAGE,
516
+ AUTO_GRADING_PLANS.AUTO_GRADING_PASS_FAIL,
517
+ AUTO_GRADING_PLANS.AUTO_GRADING_RUBRICS,
518
+ AUTO_GRADING_PLANS.AUTO_GRADING_STANDARDS_BASED,
519
+ AI_ASSISTANT_PLANS.AI_ASSISTANT_DOCUMENT_UPLOADS,
520
+ AI_ASSISTANT_PLANS.AI_ASSISTANT_UNLIMITED_USE,
521
+ ASSIGNMENT_SETTINGS_PLANS.ASSESSMENTS,
522
+ ASSIGNMENT_SETTINGS_PLANS.GOOGLE_CLASSROOM_GRADE_PASSBACK,
523
+ ANALYTICS_PLANS.ANALYTICS_GRADEBOOK,
524
+ ANALYTICS_PLANS.ANALYTICS_STUDENT_PROGRESS_REPORTS,
525
+ ANALYTICS_PLANS.ANALYTICS_CLASSROOM_ANALYTICS,
526
+ ANALYTICS_PLANS.ANALYTICS_ORGANIZATION,
527
+ SPACES_PLANS.SPACES_CREATE_SPACE,
528
+ SPACES_PLANS.SPACES_CHECK_POINTS,
529
+ DISCOVER_PLANS.DISCOVER_ORGANIZATION_LIBRARY,
530
+ MEDIA_AREA_PLANS.MEDIA_AREA_DOCUMENT_UPLOAD,
531
+ MEDIA_AREA_PLANS.MEDIA_AREA_AUDIO_FILES
532
+ ];
533
+ var SpeakablePlanTypes = {
534
+ basic: "basic",
535
+ teacher_pro: "teacher_pro",
536
+ school_starter: "school_starter",
537
+ organization: "organization",
538
+ // OLD PLANS
539
+ starter: "starter",
540
+ growth: "growth",
541
+ professional: "professional"
542
+ };
543
+ var SpeakablePermissionsMap = {
544
+ [SpeakablePlanTypes.basic]: FREE_PLAN,
545
+ [SpeakablePlanTypes.starter]: TEACHER_PRO_PLAN,
546
+ [SpeakablePlanTypes.teacher_pro]: TEACHER_PRO_PLAN,
547
+ [SpeakablePlanTypes.growth]: ORGANIZATION_PLAN,
548
+ [SpeakablePlanTypes.professional]: ORGANIZATION_PLAN,
549
+ [SpeakablePlanTypes.organization]: ORGANIZATION_PLAN,
550
+ [SpeakablePlanTypes.school_starter]: SCHOOL_STARTER
551
+ };
552
+ var SpeakablePlanHierarchy = [
553
+ SpeakablePlanTypes.basic,
554
+ SpeakablePlanTypes.starter,
555
+ SpeakablePlanTypes.teacher_pro,
556
+ SpeakablePlanTypes.growth,
557
+ SpeakablePlanTypes.professional,
558
+ SpeakablePlanTypes.school_starter,
559
+ SpeakablePlanTypes.organization
560
+ ];
561
+
562
+ // src/hooks/usePermissions.ts
563
+ var usePermissions = () => {
564
+ const { permissions } = useSpeakableApi();
565
+ const has = (permission) => {
566
+ var _a;
567
+ return (_a = permissions.permissions) == null ? void 0 : _a.includes(permission);
568
+ };
569
+ return {
570
+ plan: permissions.plan,
571
+ permissionsLoaded: permissions.loaded,
572
+ isStripePlan: permissions.isStripePlan,
573
+ refreshDate: permissions.refreshDate,
574
+ isInstitutionPlan: permissions.isInstitutionPlan,
575
+ subscriptionId: permissions.subscriptionId,
576
+ contact: permissions.contact,
577
+ hasGradebook: has(ANALYTICS_PLANS.ANALYTICS_GRADEBOOK),
578
+ hasGoogleClassroomGradePassback: has(ASSIGNMENT_SETTINGS_PLANS.GOOGLE_CLASSROOM_GRADE_PASSBACK),
579
+ hasAssessments: has(ASSIGNMENT_SETTINGS_PLANS.ASSESSMENTS),
580
+ hasSectionAnalytics: has(ANALYTICS_PLANS.ANALYTICS_CLASSROOM_ANALYTICS),
581
+ hasStudentReports: has(ANALYTICS_PLANS.ANALYTICS_STUDENT_PROGRESS_REPORTS),
582
+ permissions: permissions || [],
583
+ hasStudentPortfolios: permissions.hasStudentPortfolios,
584
+ isFreeOrgTrial: permissions.type === "free_org_trial",
585
+ freeOrgTrialExpired: permissions.freeOrgTrialExpired
586
+ };
587
+ };
588
+ var usePermissions_default = usePermissions;
589
+
590
+ // src/domains/notification/notification.constants.ts
591
+ var SPEAKABLE_NOTIFICATIONS = {
592
+ NEW_ASSIGNMENT: "new_assignment",
593
+ ASSESSMENT_SUBMITTED: "assessment_submitted",
594
+ ASSESSMENT_SCORED: "assessment_scored",
595
+ NEW_COMMENT: "NEW_COMMENT"
596
+ };
597
+ var SpeakableNotificationTypes = {
598
+ NEW_ASSIGNMENT: "NEW_ASSIGNMENT",
599
+ FEEDBACK_FROM_TEACHER: "FEEDBACK_FROM_TEACHER",
600
+ MESSAGE_FROM_STUDENT: "MESSAGE_FROM_STUDENT",
601
+ PHRASE_MARKED_CORRECT: "PHRASE_MARKED_CORRECT",
602
+ STUDENT_PROGRESS: "STUDENT_PROGRESS",
603
+ PLAYLIST_FOLLOWERS: "PLAYLIST_FOLLOWERS",
604
+ PLAYLIST_PLAYS: "PLAYLIST_PLAYS",
605
+ // New notifications
606
+ ASSESSMENT_SUBMITTED: "ASSESSMENT_SUBMITTED",
607
+ // Notification FOR TEACHER when student submits assessment
608
+ ASSESSMENT_SCORED: "ASSESSMENT_SCORED",
609
+ // Notification FOR STUDENT when teacher scores assessment
610
+ // Comment
611
+ NEW_COMMENT: "NEW_COMMENT"
612
+ };
613
+
614
+ // src/domains/notification/services/create-notification.service.ts
615
+ import dayjs2 from "dayjs";
616
+
617
+ // src/constants/web.constants.ts
618
+ var WEB_BASE_URL = "https://app.speakable.io";
619
+
620
+ // src/domains/notification/services/send-notification.service.ts
621
+ var _sendNotification = async (sendTo, notification) => {
622
+ var _a, _b, _c;
623
+ const results = await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "createNotificationV2")) == null ? void 0 : _c({
624
+ sendTo,
625
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
626
+ notification
627
+ }));
628
+ return results;
629
+ };
630
+ var sendNotification = withErrorHandler(_sendNotification, "sendNotification");
631
+
632
+ // src/domains/notification/services/create-notification.service.ts
633
+ var createNotification = async ({
634
+ data,
635
+ type,
636
+ userId,
637
+ profile
638
+ }) => {
639
+ let result;
640
+ switch (type) {
641
+ case SPEAKABLE_NOTIFICATIONS.NEW_ASSIGNMENT:
642
+ result = await handleAssignNotifPromise({ data, profile });
643
+ break;
644
+ case SPEAKABLE_NOTIFICATIONS.ASSESSMENT_SUBMITTED:
645
+ result = await createAssessmentSubmissionNotification({
646
+ data,
647
+ profile,
648
+ userId
649
+ });
650
+ break;
651
+ case SPEAKABLE_NOTIFICATIONS.ASSESSMENT_SCORED:
652
+ result = await createAssessmentScoredNotification({
653
+ data,
654
+ profile
655
+ });
656
+ break;
657
+ default:
658
+ result = null;
659
+ break;
660
+ }
661
+ return result;
662
+ };
663
+ var handleAssignNotifPromise = async ({
664
+ data: assignments,
665
+ profile
666
+ }) => {
667
+ if (!assignments.length) return;
668
+ try {
669
+ const notifsPromises = assignments.map(async (assignment) => {
670
+ const {
671
+ section,
672
+ section: { members },
673
+ ...rest
674
+ } = assignment;
675
+ if (!section || !members) throw new Error("Invalid assignment data");
676
+ const data = { section, sendTo: members, assignment: { ...rest } };
677
+ return createNewAssignmentNotification({ data, profile });
678
+ });
679
+ await Promise.all(notifsPromises);
680
+ return {
681
+ success: true,
682
+ message: "Assignment notifications sent successfully"
683
+ };
684
+ } catch (error) {
685
+ console.error("Error in handleAssignNotifPromise:", error);
686
+ throw error;
687
+ }
688
+ };
689
+ var createNewAssignmentNotification = async ({
690
+ data,
691
+ profile
692
+ }) => {
693
+ var _a;
694
+ const { assignment, sendTo } = data;
695
+ const teacherName = profile.displayName || "Your teacher";
696
+ const dueDate = assignment.dueDateTimestamp ? dayjs2(assignment.dueDateTimestamp.toDate()).format("MMM Do") : null;
697
+ const results = await sendNotification(sendTo, {
698
+ courseId: assignment.courseId,
699
+ type: SPEAKABLE_NOTIFICATIONS.NEW_ASSIGNMENT,
700
+ senderName: teacherName,
701
+ link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
702
+ messagePreview: `A new assignment "${assignment.name}" is now available. ${dueDate ? `Due ${dueDate}` : ""}`,
703
+ title: "New Assignment Available!",
704
+ imageUrl: (_a = profile.image) == null ? void 0 : _a.url
705
+ });
706
+ return results;
707
+ };
708
+ var createAssessmentSubmissionNotification = async ({
709
+ data: assignment,
710
+ profile,
711
+ userId
712
+ }) => {
713
+ var _a;
714
+ const studentName = profile.displayName || "Your student";
715
+ const results = await sendNotification(assignment.owners, {
716
+ courseId: assignment.courseId,
717
+ type: SPEAKABLE_NOTIFICATIONS.ASSESSMENT_SUBMITTED,
718
+ link: `${WEB_BASE_URL}/a/${assignment.id}?studentId=${userId}`,
719
+ title: `Assessment Submitted!`,
720
+ senderName: studentName,
721
+ messagePreview: `${studentName} has submitted the assessment "${assignment.name}"`,
722
+ imageUrl: (_a = profile.image) == null ? void 0 : _a.url
723
+ });
724
+ return results;
725
+ };
726
+ var createAssessmentScoredNotification = async ({
727
+ data,
728
+ profile
729
+ }) => {
730
+ var _a, _b, _c, _d, _e;
731
+ const { assignment, sendTo } = data;
732
+ const teacherName = profile.displayName || "Your teacher";
733
+ const title = `${assignment.isAssessment ? "Assessment" : "Assignment"} Reviewed!`;
734
+ const messagePreview = `Your ${assignment.isAssessment ? "assessment" : "assignment"} has been reviewed by your teacher. Click to view the feedback.`;
735
+ const results = await sendNotification(sendTo, {
736
+ courseId: assignment.courseId,
737
+ type: SPEAKABLE_NOTIFICATIONS.ASSESSMENT_SCORED,
738
+ link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
739
+ title,
740
+ messagePreview,
741
+ imageUrl: (_a = profile.image) == null ? void 0 : _a.url,
742
+ senderName: teacherName
743
+ });
744
+ await ((_e = (_c = (_b = api).httpsCallable) == null ? void 0 : _c.call(_b, "sendAssessmentScoredEmail")) == null ? void 0 : _e({
745
+ assessmentTitle: assignment.name,
746
+ link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
747
+ senderImage: ((_d = profile.image) == null ? void 0 : _d.url) || "",
748
+ studentId: sendTo[0],
749
+ teacherName: profile.displayName
750
+ }));
751
+ return results;
752
+ };
753
+
754
+ // src/domains/notification/hooks/notification.hooks.ts
755
+ var notificationQueryKeys = {
756
+ all: ["notifications"],
757
+ byId: (id) => [...notificationQueryKeys.all, id]
758
+ };
759
+ var useCreateNotification = () => {
760
+ const { user, queryClient } = useSpeakableApi();
761
+ const handleCreateNotifications = async (type, data) => {
762
+ var _a, _b;
763
+ const result = await createNotification({
764
+ type,
765
+ userId: user.auth.uid,
766
+ profile: (_a = user == null ? void 0 : user.profile) != null ? _a : {},
767
+ data
768
+ });
769
+ queryClient.invalidateQueries({
770
+ queryKey: notificationQueryKeys.byId((_b = user == null ? void 0 : user.auth.uid) != null ? _b : "")
771
+ });
772
+ return result;
773
+ };
774
+ return {
775
+ createNotification: handleCreateNotifications
776
+ };
777
+ };
778
+
779
+ // src/hooks/useGoogleClassroom.ts
780
+ var useGoogleClassroom = () => {
781
+ const submitAssignmentToGoogleClassroom = async ({
782
+ assignment,
783
+ scores,
784
+ googleUserId = null
785
+ // optional to override the user's googleUserId
786
+ }) => {
787
+ var _a, _b, _c;
788
+ try {
789
+ const { googleClassroomUserId = null } = scores;
790
+ const googleId = googleUserId || googleClassroomUserId;
791
+ if (!googleId)
792
+ return {
793
+ error: true,
794
+ message: "No Google Classroom ID found"
795
+ };
796
+ const { courseWorkId, maxPoints, owners, courseId } = assignment;
797
+ const draftGrade = (scores == null ? void 0 : scores.score) ? (scores == null ? void 0 : scores.score) / 100 * maxPoints : 0;
798
+ const result = await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitAssignmentToGoogleClassroomV2")) == null ? void 0 : _c({
799
+ teacherId: owners[0],
800
+ courseId,
801
+ courseWorkId,
802
+ userId: googleId,
803
+ draftGrade
804
+ }));
805
+ return result;
806
+ } catch (error) {
807
+ return { error: true, message: error.message };
808
+ }
809
+ };
810
+ return {
811
+ submitAssignmentToGoogleClassroom
812
+ };
813
+ };
814
+
815
+ // src/lib/firebase/firebase-analytics/grading-standard.ts
816
+ var logGradingStandardLog = (data) => {
817
+ var _a, _b, _c;
818
+ if (data.courseId && data.type && data.level) {
819
+ (_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "handleCouresAnalyticsEvent")) == null ? void 0 : _c({
820
+ eventType: data.type || "custom",
821
+ level: data.level,
822
+ courseId: data.courseId
823
+ });
824
+ }
825
+ api.logEvent("logGradingStandard", data);
826
+ };
827
+
828
+ // src/constants/analytics.constants.ts
829
+ var ANALYTICS_EVENT_TYPES = {
830
+ VOICE_SUCCESS: "voice_success",
831
+ VOICE_FAIL: "voice_fail",
832
+ RESPOND_CARD_SUCCESS: "respond_card_success",
833
+ RESPOND_CARD_FAIL: "respond_card_fail",
834
+ RESPOND_WRITE_CARD_SUCCESS: "respond_write_card_success",
835
+ RESPOND_WRITE_CARD_FAIL: "respond_write_card_fail",
836
+ RESPOND_WRITE_CARD_SUBMITTED: "respond_write_card_submitted",
837
+ RESPOND_WRITE_CARD_ERROR: "respond_write_card_error",
838
+ RESPOND_CARD_ERROR: "respond_card_error",
839
+ RESPOND_CARD_SUBMITTED: "respond_card_submitted",
840
+ RESPOND_FREE_PLAN: "respond_free_plan",
841
+ RESPOND_WRITE_FREE_PLAN: "respond_write_free_plan",
842
+ SUBMISSION: "assignment_submitted",
843
+ ASSIGNMENT_STARTED: "assignment_started",
844
+ CREATE_ASSIGNMENT: "create_assignment",
845
+ MC_SUCCESS: "multiple_choice_success",
846
+ MC_FAIL: "multiple_choice_fail",
847
+ MC_ERROR: "multiple_choice_error",
848
+ ACTFL_LEVEL: "actfl_level",
849
+ WIDA_LEVEL: "wida_level"
850
+ };
851
+
852
+ // src/lib/firebase/firebase-analytics/assignment.ts
853
+ var logOpenAssignment = (data = {}) => {
854
+ api.logEvent("open_assignment", data);
855
+ };
856
+ var logOpenActivityPreview = (data = {}) => {
857
+ api.logEvent("open_activity_preview", data);
858
+ };
859
+ var logSubmitAssignment = (data = {}) => {
860
+ var _a, _b, _c;
861
+ (_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "handleCouresAnalyticsEvent")) == null ? void 0 : _c({
862
+ eventType: ANALYTICS_EVENT_TYPES.SUBMISSION,
863
+ ...data
864
+ });
865
+ api.logEvent(ANALYTICS_EVENT_TYPES.SUBMISSION, data);
866
+ };
867
+ var logStartAssignment = (data = {}) => {
868
+ var _a, _b, _c;
869
+ if (data.courseId) {
870
+ (_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "handleCouresAnalyticsEvent")) == null ? void 0 : _c({
871
+ eventType: ANALYTICS_EVENT_TYPES.ASSIGNMENT_STARTED,
872
+ ...data
873
+ });
874
+ }
875
+ api.logEvent(ANALYTICS_EVENT_TYPES.ASSIGNMENT_STARTED, data);
876
+ };
877
+
878
+ // src/domains/assignment/utils/create-default-score.ts
879
+ var defaultScore = (props) => {
880
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
881
+ const score = {
882
+ progress: 0,
883
+ score: 0,
884
+ startDate: serverTimestamp2(),
885
+ status: "IN_PROGRESS",
886
+ submitted: false,
887
+ cards: {},
888
+ lastPlayed: serverTimestamp2(),
889
+ owners: props.owners,
890
+ userId: props.userId
891
+ };
892
+ if (props.googleClassroomUserId) {
893
+ score.googleClassroomUserId = props.googleClassroomUserId;
894
+ }
895
+ if (props.courseId) {
896
+ score.courseId = props.courseId;
897
+ }
898
+ return score;
899
+ };
900
+
901
+ // src/domains/assignment/score-practice.constants.ts
902
+ var SCORES_PRACTICE_COLLECTION = "users";
903
+ var SCORES_PRACTICE_SUBCOLLECTION = "practice";
904
+ var refsScoresPractice = {
905
+ practiceScores: (params) => `${SCORES_PRACTICE_COLLECTION}/${params.userId}/${SCORES_PRACTICE_SUBCOLLECTION}/${params.setId}`,
906
+ practiceScoreHistoryRefDoc: (params) => `${SCORES_PRACTICE_COLLECTION}/${params.userId}/${SCORES_PRACTICE_SUBCOLLECTION}/${params.setId}/attempts/${params.date}`
907
+ };
908
+
909
+ // src/domains/assignment/services/create-score.service.ts
910
+ async function _createScore(params) {
911
+ var _a, _b, _c;
912
+ if (params.isAssignment) {
913
+ const ref = refsAssignmentFiresotre.assignmentScores({
914
+ id: params.activityId,
915
+ userId: params.userId
916
+ });
917
+ await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "updateAssignmentGradebookStatus")) == null ? void 0 : _c({
918
+ assignmentId: params.activityId,
919
+ userId: params.userId,
920
+ status: "IN_PROGRESS",
921
+ score: null
922
+ }));
923
+ await api.setDoc(ref, params.scoreData, { merge: true });
924
+ return {
925
+ id: params.userId
926
+ };
927
+ } else {
928
+ const ref = refsScoresPractice.practiceScores({
929
+ userId: params.userId,
930
+ setId: params.activityId
931
+ });
932
+ await api.setDoc(ref, params.scoreData);
933
+ return {
934
+ id: params.userId
935
+ };
936
+ }
937
+ }
938
+ var createScore = withErrorHandler(_createScore, "createScore");
939
+
940
+ // src/domains/assignment/services/get-score.service.ts
941
+ async function getAssignmentScore({
942
+ userId,
943
+ assignment,
944
+ googleClassroomUserId
945
+ }) {
946
+ const path = refsAssignmentFiresotre.assignmentScores({
947
+ id: assignment.id,
948
+ userId
949
+ });
950
+ const response = await api.getDoc(path);
951
+ if (response.data == null) {
952
+ const newScore = {
953
+ ...defaultScore({
954
+ owners: [userId],
955
+ userId,
956
+ courseId: assignment.courseId,
957
+ googleClassroomUserId
958
+ }),
959
+ assignmentId: assignment.id
960
+ };
961
+ logStartAssignment({
962
+ courseId: assignment.courseId
963
+ });
964
+ const result = await createScore({
965
+ activityId: assignment.id,
966
+ userId,
967
+ isAssignment: true,
968
+ scoreData: newScore
969
+ });
970
+ return {
971
+ ...newScore,
972
+ id: result.id
973
+ };
974
+ }
975
+ return response.data;
976
+ }
977
+ async function getPracticeScore({ userId, setId }) {
978
+ const path = refsScoresPractice.practiceScores({ userId, setId });
979
+ const response = await api.getDoc(path);
980
+ if (response.data == null) {
981
+ const newScore = {
982
+ ...defaultScore({
983
+ owners: [userId],
984
+ userId
985
+ }),
986
+ setId
987
+ };
988
+ const result = await createScore({
989
+ activityId: setId,
990
+ userId,
991
+ isAssignment: false,
992
+ scoreData: newScore
993
+ });
994
+ return {
995
+ ...newScore,
996
+ id: result.id
997
+ };
998
+ }
999
+ return response.data;
1000
+ }
1001
+ async function _getScore(params) {
1002
+ if (params.isAssignment) {
1003
+ return await getAssignmentScore({
1004
+ userId: params.userId,
1005
+ assignment: {
1006
+ id: params.activityId,
1007
+ courseId: params.courseId
1008
+ },
1009
+ googleClassroomUserId: params.googleClassroomUserId
1010
+ });
1011
+ } else {
1012
+ return await getPracticeScore({
1013
+ userId: params.userId,
1014
+ setId: params.activityId
1015
+ });
1016
+ }
1017
+ }
1018
+ var getScore = withErrorHandler(_getScore, "getScore");
1019
+
1020
+ // src/domains/assignment/utils/calculateScoreAndProgress.ts
1021
+ var calculateScoreAndProgress = (scores, cardsList, weights) => {
1022
+ const totalSetPoints = cardsList.reduce((acc, cardId) => {
1023
+ acc += (weights == null ? void 0 : weights[cardId]) || 1;
1024
+ return acc;
1025
+ }, 0);
1026
+ const totalPointsAwarded = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce((acc, cardId) => {
1027
+ var _a, _b;
1028
+ const cardScores = (_a = scores == null ? void 0 : scores.cards) == null ? void 0 : _a[cardId];
1029
+ if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
1030
+ const score2 = (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0 ? Number((_b = cardScores == null ? void 0 : cardScores.score) != null ? _b : 0) : null;
1031
+ const weight = (weights == null ? void 0 : weights[cardId]) || 1;
1032
+ const fraction = (score2 != null ? score2 : 0) / 100;
1033
+ if (score2 || score2 === 0) {
1034
+ acc += weight * fraction;
1035
+ } else {
1036
+ acc += weight;
1037
+ }
1038
+ }
1039
+ return acc;
1040
+ }, 0);
1041
+ const totalCompletedCards = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce((acc, cardId) => {
1042
+ var _a;
1043
+ const cardScores = (_a = scores == null ? void 0 : scores.cards) == null ? void 0 : _a[cardId];
1044
+ if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
1045
+ acc += 1;
1046
+ }
1047
+ return acc;
1048
+ }, 0);
1049
+ const percent = totalPointsAwarded / totalSetPoints;
1050
+ const score = Math.round(percent * 100);
1051
+ const progress = Math.round(totalCompletedCards / (cardsList.length || 1) * 100);
1052
+ return { score, progress };
1053
+ };
1054
+ var calculateScoreAndProgress_default = calculateScoreAndProgress;
1055
+
1056
+ // src/domains/assignment/services/update-score.service.ts
1057
+ async function _updateScore(params) {
1058
+ const path = params.isAssignment ? refsAssignmentFiresotre.assignmentScores({
1059
+ id: params.activityId,
1060
+ userId: params.userId
1061
+ }) : refsScoresPractice.practiceScores({
1062
+ setId: params.activityId,
1063
+ userId: params.userId
1064
+ });
1065
+ await api.updateDoc(path, {
1066
+ ...params.data
1067
+ });
1068
+ }
1069
+ var updateScore = withErrorHandler(_updateScore, "updateScore");
1070
+ async function _updateCardScore(params) {
1071
+ const path = params.isAssignment ? refsAssignmentFiresotre.assignmentScores({
1072
+ id: params.activityId,
1073
+ userId: params.userId
1074
+ }) : refsScoresPractice.practiceScores({
1075
+ setId: params.activityId,
1076
+ userId: params.userId
1077
+ });
1078
+ const updates = Object.keys(params.updates.cardScore).reduce(
1079
+ (acc, key) => {
1080
+ acc[`cards.${params.cardId}.${key}`] = params.updates.cardScore[key];
1081
+ return acc;
1082
+ },
1083
+ {}
1084
+ );
1085
+ if (params.updates.progress) {
1086
+ updates.progress = params.updates.progress;
1087
+ }
1088
+ if (params.updates.score) {
1089
+ updates.score = params.updates.score;
1090
+ }
1091
+ await api.updateDoc(path, {
1092
+ ...updates
1093
+ });
1094
+ }
1095
+ var updateCardScore = withErrorHandler(_updateCardScore, "updateCardScore");
1096
+
1097
+ // src/domains/assignment/services/clear-score.service.ts
1098
+ import dayjs3 from "dayjs";
1099
+ async function clearScore(params) {
1100
+ var _a, _b, _c, _d, _e;
1101
+ const update = {
1102
+ [`cards.${params.cardId}`]: {
1103
+ attempts: ((_a = params.cardScores.attempts) != null ? _a : 1) + 1,
1104
+ correct: (_b = params.cardScores.correct) != null ? _b : 0,
1105
+ // save old score history
1106
+ history: [
1107
+ {
1108
+ ...params.cardScores,
1109
+ attempts: (_c = params.cardScores.attempts) != null ? _c : 1,
1110
+ correct: (_d = params.cardScores.correct) != null ? _d : 0,
1111
+ retryTime: dayjs3().format("YYYY-MM-DD HH:mm:ss"),
1112
+ history: null
1113
+ },
1114
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1115
+ ...(_e = params.cardScores.history) != null ? _e : []
1116
+ ]
1117
+ }
1118
+ };
1119
+ const path = params.isAssignment ? refsAssignmentFiresotre.assignmentScores({
1120
+ id: params.activityId,
1121
+ userId: params.userId
1122
+ }) : refsScoresPractice.practiceScores({
1123
+ setId: params.activityId,
1124
+ userId: params.userId
1125
+ });
1126
+ await api.updateDoc(path, update);
1127
+ return {
1128
+ update,
1129
+ activityId: params.activityId
1130
+ };
1131
+ }
1132
+
1133
+ // src/domains/assignment/services/submit-assignment-score.service.ts
1134
+ import dayjs4 from "dayjs";
1135
+ async function _submitAssignmentScore({
1136
+ cardIds,
1137
+ assignment,
1138
+ weights,
1139
+ userId,
1140
+ status,
1141
+ studentName
1142
+ }) {
1143
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
1144
+ const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
1145
+ const fieldsUpdated = {
1146
+ submitted: true,
1147
+ progress: 100,
1148
+ submissionDate: serverTimestamp2(),
1149
+ status
1150
+ };
1151
+ if (assignment.isAssessment) {
1152
+ const result = await handleAssessment(
1153
+ assignment,
1154
+ userId,
1155
+ cardIds,
1156
+ weights,
1157
+ fieldsUpdated,
1158
+ studentName
1159
+ );
1160
+ return result;
1161
+ } else if (assignment.courseId) {
1162
+ await handleCourseAssignment(assignment, userId);
1163
+ }
1164
+ await api.updateDoc(path, { ...fieldsUpdated });
1165
+ return { success: true, fieldsUpdated };
1166
+ }
1167
+ var submitAssignmentScore = withErrorHandler(
1168
+ _submitAssignmentScore,
1169
+ "submitAssignmentScore"
1170
+ );
1171
+ async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpdated, studentName) {
1172
+ var _a, _b, _c;
1173
+ const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
1174
+ const response = await api.getDoc(path);
1175
+ if (!response.data) {
1176
+ throw new Error("Score not found");
1177
+ }
1178
+ const { score: scoreCalculated } = calculateScoreAndProgress_default(response.data, cardIds, weights);
1179
+ await api.updateDoc(path, { score: scoreCalculated, status: "PENDING_REVIEW" });
1180
+ await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitAssessment")) == null ? void 0 : _c({
1181
+ assignmentId: assignment.id,
1182
+ assignmentTitle: assignment.name,
1183
+ userId,
1184
+ teacherId: assignment.owners[0],
1185
+ studentName
1186
+ }));
1187
+ fieldsUpdated.status = "PENDING_REVIEW";
1188
+ return { success: true, fieldsUpdated };
1189
+ }
1190
+ async function handleCourseAssignment(assignment, userId) {
1191
+ var _a, _b, _c;
1192
+ await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitAssignmentV2")) == null ? void 0 : _c({
1193
+ assignmentId: assignment.id,
1194
+ userId
1195
+ }));
1196
+ }
1197
+ async function submitPracticeScore({
1198
+ setId,
1199
+ userId,
1200
+ scores
1201
+ }) {
1202
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
1203
+ const date = dayjs4().format("YYYY-MM-DD-HH-mm");
1204
+ const ref = refsScoresPractice.practiceScoreHistoryRefDoc({ setId, userId, date });
1205
+ const fieldsUpdated = {
1206
+ ...scores,
1207
+ submitted: true,
1208
+ progress: 100,
1209
+ submissionDate: serverTimestamp2(),
1210
+ status: "SUBMITTED"
1211
+ };
1212
+ await api.setDoc(ref, { ...fieldsUpdated });
1213
+ const refScores = refsScoresPractice.practiceScores({ userId, setId });
1214
+ await api.deleteDoc(refScores);
1215
+ return { success: true, fieldsUpdated };
1216
+ }
1217
+
1218
+ // src/domains/assignment/hooks/score-hooks.ts
1219
+ var scoreQueryKeys = {
1220
+ all: ["scores"],
1221
+ byId: (id) => [...scoreQueryKeys.all, id],
1222
+ list: () => [...scoreQueryKeys.all, "list"]
1223
+ };
1224
+ function useScore({
1225
+ isAssignment,
1226
+ activityId,
1227
+ userId = "",
1228
+ courseId,
1229
+ enabled = true,
1230
+ googleClassroomUserId
1231
+ }) {
1232
+ return useQuery2({
1233
+ queryFn: () => getScore({
1234
+ userId,
1235
+ courseId,
1236
+ activityId,
1237
+ googleClassroomUserId,
1238
+ isAssignment
1239
+ }),
1240
+ queryKey: scoreQueryKeys.byId(activityId),
1241
+ enabled
1242
+ });
1243
+ }
1244
+ var debounceUpdateScore = debounce(updateScore, 1e3);
1245
+ function useUpdateScore() {
1246
+ const { queryClient } = useSpeakableApi();
1247
+ const mutation = useMutation({
1248
+ mutationFn: debounceUpdateScore,
1249
+ onMutate: (variables) => {
1250
+ return handleOptimisticUpdate({
1251
+ queryClient,
1252
+ queryKey: scoreQueryKeys.byId(variables.activityId),
1253
+ newData: variables.data
1254
+ });
1255
+ },
1256
+ onError: (_, variables, context) => {
1257
+ if (context == null ? void 0 : context.previousData)
1258
+ queryClient.setQueryData(scoreQueryKeys.byId(variables.activityId), context.previousData);
1259
+ },
1260
+ onSettled: (_, err, variables) => {
1261
+ queryClient.invalidateQueries({
1262
+ queryKey: scoreQueryKeys.byId(variables.activityId)
1263
+ });
1264
+ }
1265
+ });
1266
+ return {
1267
+ mutationUpdateScore: mutation
1268
+ };
1269
+ }
1270
+ function useUpdateCardScore({
1271
+ isAssignment,
1272
+ activityId,
1273
+ userId,
1274
+ cardIds,
1275
+ weights
1276
+ }) {
1277
+ const { queryClient } = useSpeakableApi();
1278
+ const queryKey = scoreQueryKeys.byId(activityId);
1279
+ const mutation = useMutation({
1280
+ mutationFn: async ({ cardId, cardScore }) => {
1281
+ const previousScores = queryClient.getQueryData(queryKey);
1282
+ const { progress, score, newScoreUpdated, updatedCardScore } = getScoreUpdated({
1283
+ previousScores: previousScores != null ? previousScores : {},
1284
+ cardId,
1285
+ cardScore,
1286
+ cardIds,
1287
+ weights
1288
+ });
1289
+ await updateCardScore({
1290
+ userId,
1291
+ cardId,
1292
+ isAssignment,
1293
+ activityId,
1294
+ updates: {
1295
+ cardScore: updatedCardScore,
1296
+ progress,
1297
+ score
1298
+ }
1299
+ });
1300
+ return { cardId, scoresUpdated: newScoreUpdated };
1301
+ },
1302
+ onMutate: ({ cardId, cardScore }) => {
1303
+ queryClient.setQueryData(queryKey, (previousScore) => {
1304
+ const updates = handleOptimisticScore({
1305
+ score: previousScore,
1306
+ cardId,
1307
+ cardScore,
1308
+ cardIds,
1309
+ weights
1310
+ });
1311
+ return {
1312
+ ...previousScore,
1313
+ ...updates
1314
+ };
1315
+ });
1316
+ },
1317
+ // eslint-disable-next-line no-unused-vars
1318
+ onError: (error) => {
1319
+ console.log(error.message);
1320
+ const previousData = queryClient.getQueryData(queryKey);
1321
+ if (previousData) {
1322
+ queryClient.setQueryData(queryKey, previousData);
1323
+ }
1324
+ }
1325
+ });
1326
+ return {
1327
+ mutationUpdateCardScore: mutation
1328
+ };
1329
+ }
1330
+ var getScoreUpdated = ({
1331
+ cardId,
1332
+ cardScore,
1333
+ previousScores,
1334
+ cardIds,
1335
+ weights
1336
+ }) => {
1337
+ var _a, _b;
1338
+ const previousCard = (_a = previousScores.cards) == null ? void 0 : _a[cardId];
1339
+ const newCardScore = {
1340
+ ...previousCard != null ? previousCard : {},
1341
+ ...cardScore
1342
+ };
1343
+ const newScores = {
1344
+ ...previousScores,
1345
+ cards: {
1346
+ ...(_b = previousScores.cards) != null ? _b : {},
1347
+ [cardId]: newCardScore
1348
+ }
1349
+ };
1350
+ const { score, progress } = calculateScoreAndProgress_default(newScores, cardIds, weights);
1351
+ return {
1352
+ newScoreUpdated: newScores,
1353
+ updatedCardScore: cardScore,
1354
+ score,
1355
+ progress
1356
+ };
1357
+ };
1358
+ var handleOptimisticScore = ({
1359
+ score,
1360
+ cardId,
1361
+ cardScore,
1362
+ cardIds,
1363
+ weights
1364
+ }) => {
1365
+ var _a;
1366
+ let cards = { ...(_a = score == null ? void 0 : score.cards) != null ? _a : {} };
1367
+ cards = {
1368
+ ...cards,
1369
+ [cardId]: {
1370
+ ...cards[cardId],
1371
+ ...cardScore
1372
+ }
1373
+ };
1374
+ const { score: scoreValue, progress } = calculateScoreAndProgress_default(
1375
+ // @ts-ignore
1376
+ {
1377
+ ...score != null ? score : {},
1378
+ cards
1379
+ },
1380
+ cardIds,
1381
+ weights
1382
+ );
1383
+ return { cards, score: scoreValue, progress };
1384
+ };
1385
+ function useClearScore() {
1386
+ const { queryClient } = useSpeakableApi();
1387
+ const mutation = useMutation({
1388
+ mutationFn: clearScore,
1389
+ onSettled: (result) => {
1390
+ var _a;
1391
+ queryClient.invalidateQueries({
1392
+ queryKey: scoreQueryKeys.byId((_a = result == null ? void 0 : result.activityId) != null ? _a : "")
1393
+ });
1394
+ }
1395
+ });
1396
+ return {
1397
+ mutationClearScore: mutation
1398
+ };
1399
+ }
1400
+ function useSubmitAssignmentScore({
1401
+ onAssignmentSubmitted,
1402
+ studentName
1403
+ }) {
1404
+ const { queryClient } = useSpeakableApi();
1405
+ const { hasGoogleClassroomGradePassback } = usePermissions_default();
1406
+ const { submitAssignmentToGoogleClassroom } = useGoogleClassroom();
1407
+ const { createNotification: createNotification2 } = useCreateNotification();
1408
+ const mutation = useMutation({
1409
+ mutationFn: async ({
1410
+ assignment,
1411
+ userId,
1412
+ cardIds,
1413
+ weights,
1414
+ scores,
1415
+ status
1416
+ }) => {
1417
+ try {
1418
+ const scoreUpdated = await submitAssignmentScore({
1419
+ assignment,
1420
+ userId,
1421
+ cardIds,
1422
+ weights,
1423
+ status,
1424
+ studentName
1425
+ });
1426
+ if (assignment.courseWorkId != null && !assignment.isAssessment && hasGoogleClassroomGradePassback) {
1427
+ await submitAssignmentToGoogleClassroom({
1428
+ assignment,
1429
+ scores
1430
+ });
1431
+ }
1432
+ if (assignment.isAssessment) {
1433
+ createNotification2(SpeakableNotificationTypes.ASSESSMENT_SUBMITTED, assignment);
1434
+ }
1435
+ if (assignment == null ? void 0 : assignment.id) {
1436
+ logSubmitAssignment({
1437
+ courseId: assignment == null ? void 0 : assignment.courseId
1438
+ });
1439
+ }
1440
+ onAssignmentSubmitted(assignment.id);
1441
+ queryClient.setQueryData(scoreQueryKeys.byId(assignment.id), {
1442
+ ...scores,
1443
+ ...scoreUpdated.fieldsUpdated
1444
+ });
1445
+ return {
1446
+ success: true,
1447
+ message: "Score submitted successfully"
1448
+ };
1449
+ } catch (error) {
1450
+ return {
1451
+ success: false,
1452
+ error
1453
+ };
1454
+ }
1455
+ }
1456
+ });
1457
+ return {
1458
+ submitAssignmentScore: mutation.mutateAsync,
1459
+ isLoading: mutation.isPending
1460
+ };
1461
+ }
1462
+ function useSubmitPracticeScore() {
1463
+ const { queryClient } = useSpeakableApi();
1464
+ const mutation = useMutation({
1465
+ mutationFn: async ({
1466
+ setId,
1467
+ userId,
1468
+ scores
1469
+ }) => {
1470
+ try {
1471
+ await submitPracticeScore({
1472
+ setId,
1473
+ userId,
1474
+ scores
1475
+ });
1476
+ queryClient.invalidateQueries({
1477
+ queryKey: scoreQueryKeys.byId(setId)
1478
+ });
1479
+ return {
1480
+ success: true,
1481
+ message: "Score submitted successfully"
1482
+ };
1483
+ } catch (error) {
1484
+ return {
1485
+ success: false,
1486
+ error
1487
+ };
1488
+ }
1489
+ }
1490
+ });
1491
+ return {
1492
+ submitPracticeScore: mutation.mutateAsync,
1493
+ isLoading: mutation.isPending
1494
+ };
1495
+ }
1496
+
1497
+ // src/domains/cards/card.hooks.ts
1498
+ import { useMutation as useMutation2, useQueries, useQuery as useQuery3 } from "@tanstack/react-query";
1499
+ import { useMemo } from "react";
1500
+
1501
+ // src/domains/cards/card.constants.ts
1502
+ var FeedbackTypesCard = /* @__PURE__ */ ((FeedbackTypesCard2) => {
1503
+ FeedbackTypesCard2["SuggestedResponse"] = "suggested_response";
1504
+ FeedbackTypesCard2["Wida"] = "wida";
1505
+ FeedbackTypesCard2["GrammarInsights"] = "grammar_insights";
1506
+ FeedbackTypesCard2["Actfl"] = "actfl";
1507
+ FeedbackTypesCard2["ProficiencyLevel"] = "proficiency_level";
1508
+ return FeedbackTypesCard2;
1509
+ })(FeedbackTypesCard || {});
1510
+ var LeniencyCard = /* @__PURE__ */ ((LeniencyCard2) => {
1511
+ LeniencyCard2["CONFIDENCE"] = "confidence";
1512
+ LeniencyCard2["EASY"] = "easy";
1513
+ LeniencyCard2["NORMAL"] = "normal";
1514
+ LeniencyCard2["HARD"] = "hard";
1515
+ return LeniencyCard2;
1516
+ })(LeniencyCard || {});
1517
+ var LENIENCY_OPTIONS = [
1518
+ {
1519
+ label: "Build Confidence - most lenient",
1520
+ value: "confidence" /* CONFIDENCE */
1521
+ },
1522
+ {
1523
+ label: "Very Lenient",
1524
+ value: "easy" /* EASY */
1525
+ },
1526
+ {
1527
+ label: "Normal",
1528
+ value: "normal" /* NORMAL */
1529
+ },
1530
+ {
1531
+ label: "No leniency - most strict",
1532
+ value: "hard" /* HARD */
1533
+ }
1534
+ ];
1535
+ var STUDENT_LEVELS_OPTIONS = [
1536
+ {
1537
+ label: "Beginner",
1538
+ description: "Beginner Level: Just starting out. Can say a few basic words and phrases.",
1539
+ value: "beginner"
1540
+ },
1541
+ {
1542
+ label: "Elementary",
1543
+ description: "Elementary Level: Can understand simple sentences and have very basic conversations.",
1544
+ value: "elementary"
1545
+ },
1546
+ {
1547
+ label: "Intermediate",
1548
+ description: "Intermediate Level: Can talk about everyday topics and handle common situations.",
1549
+ value: "intermediate"
1550
+ },
1551
+ {
1552
+ label: "Advanced",
1553
+ description: "Advanced Level: Can speak and understand with ease, and explain ideas clearly.",
1554
+ value: "advanced"
1555
+ },
1556
+ {
1557
+ label: "Fluent",
1558
+ description: "Fluent Level: Speaks naturally and easily. Can use the language in work or school settings.",
1559
+ value: "fluent"
1560
+ },
1561
+ {
1562
+ label: "Native-like",
1563
+ description: "Native-like Level: Understands and speaks like a native. Can discuss complex ideas accurately.",
1564
+ value: "nativeLike"
1565
+ }
1566
+ ];
1567
+ var BASE_RESPOND_FIELD_VALUES = {
1568
+ title: "",
1569
+ allowRetries: true,
1570
+ respondTime: 180,
1571
+ maxCharacters: 1e3
1572
+ };
1573
+ var BASE_REPEAT_FIELD_VALUES = {
1574
+ repeat: 1
1575
+ };
1576
+ var BASE_MULTIPLE_CHOICE_FIELD_VALUES = {
1577
+ MCQType: "single",
1578
+ answer: ["A"],
1579
+ choices: [
1580
+ { option: "A", value: "Option A" },
1581
+ { option: "B", value: "Option B" },
1582
+ { option: "C", value: "Option C" }
1583
+ ]
1584
+ };
1585
+ var VerificationCardStatus = /* @__PURE__ */ ((VerificationCardStatus2) => {
1586
+ VerificationCardStatus2["VERIFIED"] = "VERIFIED";
1587
+ VerificationCardStatus2["WARNING"] = "WARNING";
1588
+ VerificationCardStatus2["NOT_RECOMMENDED"] = "NOT_RECOMMENDED";
1589
+ VerificationCardStatus2["NOT_WORKING"] = "NOT_WORKING";
1590
+ VerificationCardStatus2["NOT_CHECKED"] = "NOT_CHECKED";
1591
+ return VerificationCardStatus2;
1592
+ })(VerificationCardStatus || {});
1593
+ var CARDS_COLLECTION = "flashcards";
1594
+ var refsCardsFiresotre = {
1595
+ allCards: CARDS_COLLECTION,
1596
+ card: (id) => `${CARDS_COLLECTION}/${id}`
1597
+ };
1598
+
1599
+ // src/domains/cards/services/get-card.service.ts
1600
+ async function _getCard(params) {
1601
+ const ref = refsCardsFiresotre.card(params.cardId);
1602
+ const response = await api.getDoc(ref);
1603
+ if (!response.data) return null;
1604
+ return response.data;
1605
+ }
1606
+ var getCard = withErrorHandler(_getCard, "getCard");
1607
+
1608
+ // src/domains/cards/services/create-card.service.ts
1609
+ import { v4 } from "uuid";
1610
+
1611
+ // src/domains/cards/card.model.ts
1612
+ var ActivityPageType = /* @__PURE__ */ ((ActivityPageType2) => {
1613
+ ActivityPageType2["READ_REPEAT"] = "READ_REPEAT";
1614
+ ActivityPageType2["VIDEO"] = "VIDEO";
1615
+ ActivityPageType2["TEXT"] = "TEXT";
1616
+ ActivityPageType2["READ_RESPOND"] = "READ_RESPOND";
1617
+ ActivityPageType2["FREE_RESPONSE"] = "FREE_RESPONSE";
1618
+ ActivityPageType2["REPEAT"] = "REPEAT";
1619
+ ActivityPageType2["RESPOND"] = "RESPOND";
1620
+ ActivityPageType2["RESPOND_WRITE"] = "RESPOND_WRITE";
1621
+ ActivityPageType2["TEXT_TO_SPEECH"] = "TEXT_TO_SPEECH";
1622
+ ActivityPageType2["MULTIPLE_CHOICE"] = "MULTIPLE_CHOICE";
1623
+ ActivityPageType2["PODCAST"] = "PODCAST";
1624
+ ActivityPageType2["MEDIA_PAGE"] = "MEDIA_PAGE";
1625
+ ActivityPageType2["WRITE"] = "WRITE";
1626
+ ActivityPageType2["SHORT_ANSWER"] = "SHORT_ANSWER";
1627
+ ActivityPageType2["SHORT_STORY"] = "SHORT_STORY";
1628
+ ActivityPageType2["SPEAK"] = "SPEAK";
1629
+ ActivityPageType2["CONVERSATION"] = "CONVERSATION";
1630
+ ActivityPageType2["CONVERSATION_WRITE"] = "CONVERSATION_WRITE";
1631
+ ActivityPageType2["DIALOGUE"] = "DIALOGUE";
1632
+ ActivityPageType2["INSTRUCTION"] = "INSTRUCTION";
1633
+ ActivityPageType2["LISTEN"] = "LISTEN";
1634
+ ActivityPageType2["READ"] = "READ";
1635
+ ActivityPageType2["ANSWER"] = "ANSWER";
1636
+ return ActivityPageType2;
1637
+ })(ActivityPageType || {});
1638
+ var RESPOND_PAGE_ACTIVITY_TYPES = [
1639
+ "READ_RESPOND" /* READ_RESPOND */,
1640
+ "RESPOND" /* RESPOND */,
1641
+ "RESPOND_WRITE" /* RESPOND_WRITE */,
1642
+ "FREE_RESPONSE" /* FREE_RESPONSE */
1643
+ ];
1644
+ var MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES = ["MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */];
1645
+ var REPEAT_PAGE_ACTIVITY_TYPES = ["READ_REPEAT" /* READ_REPEAT */, "REPEAT" /* REPEAT */];
1646
+ var RESPOND_WRITE_PAGE_ACTIVITY_TYPES = [
1647
+ "RESPOND_WRITE" /* RESPOND_WRITE */,
1648
+ "FREE_RESPONSE" /* FREE_RESPONSE */
1649
+ ];
1650
+ var RESPOND_AUDIO_PAGE_ACTIVITY_TYPES = [
1651
+ "RESPOND" /* RESPOND */,
1652
+ "READ_RESPOND" /* READ_RESPOND */
1653
+ ];
1654
+
1655
+ // src/utils/text-utils.ts
1656
+ import sha1 from "js-sha1";
1657
+ var purify = (word) => {
1658
+ return word.normalize("NFD").replace(/\/([^" "]*)/g, "").replace(/\([^()]*\)/g, "").replace(/([^()]*)/g, "").replace(/[\u0300-\u036f]/g, "").replace(/[-]/g, " ").replace(/[.,/#!¡¿?؟。,.?$%^&*;:{}=\-_`~()’'…\s]/g, "").replace(/\s\s+/g, " ").toLowerCase().trim();
1659
+ };
1660
+ var cleanString = (words) => {
1661
+ const splitWords = words == null ? void 0 : words.split("+");
1662
+ if (splitWords && splitWords.length === 1) {
1663
+ const newWord = purify(words);
1664
+ return newWord;
1665
+ } else if (splitWords && splitWords.length > 1) {
1666
+ const split = splitWords.map((w) => purify(w));
1667
+ return split;
1668
+ } else {
1669
+ return "";
1670
+ }
1671
+ };
1672
+ var getWordHash = (word, language) => {
1673
+ const cleanedWord = cleanString(word);
1674
+ const wordHash = sha1(`${language}-${cleanedWord}`);
1675
+ console.log("wordHash core library", wordHash);
1676
+ return wordHash;
1677
+ };
1678
+ function getPhraseLength(phrase, input) {
1679
+ if (Array.isArray(phrase) && phrase.includes(input)) {
1680
+ return phrase[phrase.indexOf(input)].split(" ").length;
1681
+ } else {
1682
+ return phrase ? phrase.split(" ").length : 0;
1683
+ }
1684
+ }
1685
+
1686
+ // src/domains/cards/services/get-card-verification-status.service.ts
1687
+ var charactarLanguages = ["zh", "ja", "ko"];
1688
+ var getVerificationStatus = async (target_text, language) => {
1689
+ if ((target_text == null ? void 0 : target_text.length) < 3 && !charactarLanguages.includes(language)) {
1690
+ return "NOT_RECOMMENDED" /* NOT_RECOMMENDED */;
1691
+ }
1692
+ const hash = getWordHash(target_text, language);
1693
+ const response = await api.getDoc(`checked-pronunciations/${hash}`);
1694
+ try {
1695
+ if (response.data) {
1696
+ return processRecord(response.data);
1697
+ } else {
1698
+ return "NOT_CHECKED" /* NOT_CHECKED */;
1699
+ }
1700
+ } catch (e) {
1701
+ return "NOT_CHECKED" /* NOT_CHECKED */;
1702
+ }
1703
+ };
1704
+ var processRecord = (data) => {
1705
+ const { pronunciations = 0, fails = 0 } = data;
1706
+ const attempts = pronunciations + fails;
1707
+ const successRate = attempts > 0 ? pronunciations / attempts * 100 : 0;
1708
+ let newStatus = null;
1709
+ if (attempts < 6) {
1710
+ return "NOT_CHECKED" /* NOT_CHECKED */;
1711
+ }
1712
+ if (successRate > 25) {
1713
+ newStatus = "VERIFIED" /* VERIFIED */;
1714
+ } else if (successRate > 10) {
1715
+ newStatus = "WARNING" /* WARNING */;
1716
+ } else if (fails > 20 && successRate < 10 && pronunciations > 1) {
1717
+ newStatus = "NOT_RECOMMENDED" /* NOT_RECOMMENDED */;
1718
+ } else if (pronunciations === 0 && fails > 20) {
1719
+ newStatus = "NOT_WORKING" /* NOT_WORKING */;
1720
+ } else {
1721
+ newStatus = "NOT_CHECKED" /* NOT_CHECKED */;
1722
+ }
1723
+ return newStatus;
1724
+ };
1725
+
1726
+ // src/domains/cards/services/create-card.service.ts
1727
+ async function _createCard({ data }) {
1728
+ const response = await api.addDoc(refsCardsFiresotre.allCards, data);
1729
+ return response;
1730
+ }
1731
+ var createCard = withErrorHandler(_createCard, "createCard");
1732
+ async function _createCards({ cards }) {
1733
+ const { writeBatch: writeBatch2, doc: doc2 } = api.accessHelpers();
1734
+ const batch = writeBatch2();
1735
+ const cardsWithId = [];
1736
+ for (const card of cards) {
1737
+ const cardId = v4();
1738
+ const ref = doc2(refsCardsFiresotre.card(cardId));
1739
+ const newCardObject = {
1740
+ ...card,
1741
+ id: cardId
1742
+ };
1743
+ if (card.type === "READ_REPEAT" /* READ_REPEAT */ && card.target_text && card.language) {
1744
+ const verificationStatus = await getVerificationStatus(card.target_text, card.language);
1745
+ newCardObject.verificationStatus = verificationStatus || null;
1746
+ }
1747
+ cardsWithId.push(newCardObject);
1748
+ batch.set(ref, newCardObject);
1749
+ }
1750
+ await batch.commit();
1751
+ return cardsWithId;
1752
+ }
1753
+ var createCards = withErrorHandler(_createCards, "createCards");
1754
+
1755
+ // src/domains/cards/card.hooks.ts
1756
+ var cardsQueryKeys = {
1757
+ all: ["cards"],
1758
+ one: (params) => [...cardsQueryKeys.all, params.cardId]
1759
+ };
1760
+ function useCards({
1761
+ cardIds,
1762
+ enabled = true,
1763
+ asObject
1764
+ }) {
1765
+ const queries = useQueries({
1766
+ queries: cardIds.map((cardId) => ({
1767
+ enabled: enabled && cardIds.length > 0,
1768
+ queryKey: cardsQueryKeys.one({
1769
+ cardId
1770
+ }),
1771
+ queryFn: () => getCard({ cardId })
1772
+ }))
1773
+ });
1774
+ const cards = queries.map((query2) => query2.data).filter(Boolean);
1775
+ const cardsObject = useMemo(() => {
1776
+ if (!asObject) return null;
1777
+ return cards.reduce((acc, card) => {
1778
+ acc[card.id] = card;
1779
+ return acc;
1780
+ }, {});
1781
+ }, [asObject, cards]);
1782
+ return {
1783
+ cards,
1784
+ cardsObject,
1785
+ cardsQueries: queries
1786
+ };
1787
+ }
1788
+ function useCreateCard() {
1789
+ const { queryClient } = useSpeakableApi();
1790
+ const mutationCreateCard = useMutation2({
1791
+ mutationFn: createCard,
1792
+ onSuccess: (cardCreated) => {
1793
+ queryClient.invalidateQueries({ queryKey: cardsQueryKeys.one({ cardId: cardCreated.id }) });
1794
+ }
1795
+ });
1796
+ return {
1797
+ mutationCreateCard
1798
+ };
1799
+ }
1800
+ function useCreateCards() {
1801
+ const mutationCreateCards = useMutation2({
1802
+ mutationFn: createCards
1803
+ });
1804
+ return {
1805
+ mutationCreateCards
1806
+ };
1807
+ }
1808
+ function getCardFromCache({
1809
+ cardId,
1810
+ queryClient
1811
+ }) {
1812
+ return queryClient.getQueryData(cardsQueryKeys.one({ cardId }));
1813
+ }
1814
+ function updateCardInCache({
1815
+ cardId,
1816
+ card,
1817
+ queryClient
1818
+ }) {
1819
+ queryClient.setQueryData(cardsQueryKeys.one({ cardId }), card);
1820
+ }
1821
+ function useGetCard({ cardId, enabled = true }) {
1822
+ const query2 = useQuery3({
1823
+ queryKey: cardsQueryKeys.one({ cardId }),
1824
+ queryFn: () => getCard({ cardId }),
1825
+ enabled: enabled && !!cardId
1826
+ });
1827
+ return query2;
1828
+ }
1829
+
1830
+ // src/domains/cards/card.repo.ts
1831
+ var createCardRepo = () => {
1832
+ return {
1833
+ createCard,
1834
+ createCards,
1835
+ getCard
1836
+ };
1837
+ };
1838
+
1839
+ // src/domains/cards/utils/check-page-type.ts
1840
+ function checkIsRepeatPage(cardType) {
1841
+ if (cardType === void 0) return false;
1842
+ return REPEAT_PAGE_ACTIVITY_TYPES.includes(cardType);
1843
+ }
1844
+ function checkIsMCPage(cardType) {
1845
+ if (cardType === void 0) return false;
1846
+ return MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES.includes(cardType);
1847
+ }
1848
+ function checkIsRespondPage(cardType) {
1849
+ if (cardType === void 0) return false;
1850
+ return RESPOND_PAGE_ACTIVITY_TYPES.includes(cardType);
1851
+ }
1852
+ function checkIsRespondWrittenPage(cardType) {
1853
+ if (cardType === void 0) return false;
1854
+ return RESPOND_WRITE_PAGE_ACTIVITY_TYPES.includes(cardType);
1855
+ }
1856
+ function checkIsRespondAudioPage(cardType) {
1857
+ if (cardType === void 0) return false;
1858
+ return RESPOND_AUDIO_PAGE_ACTIVITY_TYPES.includes(cardType);
1859
+ }
1860
+ var checkIsMediaPage = (cardType) => {
1861
+ if (cardType === void 0) return false;
1862
+ return cardType === "MEDIA_PAGE" /* MEDIA_PAGE */;
1863
+ };
1864
+ var checkIsShortAnswerPage = (cardType) => {
1865
+ if (cardType === void 0) return false;
1866
+ return cardType === "SHORT_ANSWER" /* SHORT_ANSWER */;
1867
+ };
1868
+ var checkTypePageActivity = (cardType) => {
1869
+ const isRespondAudio = checkIsRespondAudioPage(cardType);
1870
+ const isRespondWritten = checkIsRespondWrittenPage(cardType);
1871
+ const isRespond = checkIsRespondPage(cardType);
1872
+ const isMC = checkIsMCPage(cardType);
1873
+ const isRepeat = checkIsRepeatPage(cardType);
1874
+ const isMediaPage = checkIsMediaPage(cardType);
1875
+ const isShortAnswer = checkIsShortAnswerPage(cardType);
1876
+ return {
1877
+ isRespondAudio,
1878
+ isRespondWritten,
1879
+ isRespond,
1880
+ isMC,
1881
+ isRepeat,
1882
+ isMediaPage,
1883
+ isShortAnswer
1884
+ };
1885
+ };
1886
+
1887
+ // src/domains/cards/utils/get-page-prompt.ts
1888
+ function extractTextFromRichText(richText) {
1889
+ if (!richText) return "";
1890
+ return richText.replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").trim();
1891
+ }
1892
+ function getPagePrompt(card) {
1893
+ if (!card) return { has: false, text: "", rich_text: "", isTextEqualToRichText: false };
1894
+ const { isMC, isRepeat, isRespond, isShortAnswer } = checkTypePageActivity(card == null ? void 0 : card.type);
1895
+ const hidePrompt = (card == null ? void 0 : card.hidePrompt) === true;
1896
+ const createReturnObject = (text, richText) => {
1897
+ const plainText = text || "";
1898
+ const richTextPlain = extractTextFromRichText(richText);
1899
+ return {
1900
+ has: true,
1901
+ text: plainText,
1902
+ rich_text: richText || "",
1903
+ isTextEqualToRichText: plainText.trim() === richTextPlain.trim()
1904
+ };
1905
+ };
1906
+ if (isRepeat) {
1907
+ return createReturnObject(card == null ? void 0 : card.target_text, card == null ? void 0 : card.rich_text);
1908
+ }
1909
+ if (isRespond && !hidePrompt) {
1910
+ return createReturnObject(card == null ? void 0 : card.prompt, card == null ? void 0 : card.rich_text);
1911
+ }
1912
+ if (isMC) {
1913
+ return createReturnObject(card == null ? void 0 : card.question, card == null ? void 0 : card.rich_text);
1914
+ }
1915
+ if (isShortAnswer && !hidePrompt) {
1916
+ return createReturnObject(card == null ? void 0 : card.prompt, card == null ? void 0 : card.rich_text);
1917
+ }
1918
+ return {
1919
+ has: false,
1920
+ text: "",
1921
+ rich_text: "",
1922
+ isTextEqualToRichText: false
1923
+ };
1924
+ }
1925
+
1926
+ // src/domains/cards/utils/get-completed-pages.ts
1927
+ var getTotalCompletedCards = (pageScores) => {
1928
+ return Object.values(pageScores != null ? pageScores : {}).reduce((acc, cardScore) => {
1929
+ var _a, _b;
1930
+ if (((_b = (_a = cardScore.completed) != null ? _a : cardScore.score) != null ? _b : cardScore.score === 0) && !cardScore.media_area_opened) {
1931
+ acc++;
1932
+ }
1933
+ return acc;
1934
+ }, 0);
1935
+ };
1936
+
1937
+ // src/domains/cards/utils/get-label-page.ts
1938
+ var labels = {
1939
+ repeat: {
1940
+ short: "Repeat",
1941
+ long: "Listen & Repeat"
1942
+ },
1943
+ mc: {
1944
+ short: "Multiple Choice",
1945
+ long: "Multiple Choice"
1946
+ },
1947
+ mediaPage: {
1948
+ short: "Media Page",
1949
+ long: "Media Page"
1950
+ },
1951
+ shortAnswer: {
1952
+ short: "Short Answer",
1953
+ long: "Short Answer"
1954
+ },
1955
+ respondWritten: {
1956
+ short: "Open Response",
1957
+ long: "Written Open Response"
1958
+ },
1959
+ respondAudio: {
1960
+ short: "Open Response",
1961
+ long: "Spoken Open Response"
1962
+ }
1963
+ };
1964
+ var getLabelPage = (pageType) => {
1965
+ if (!pageType) {
1966
+ return {
1967
+ short: "",
1968
+ long: ""
1969
+ };
1970
+ }
1971
+ const { isRepeat, isMC, isMediaPage, isShortAnswer, isRespondWritten, isRespondAudio } = checkTypePageActivity(pageType);
1972
+ if (isRepeat) {
1973
+ return labels.repeat;
1974
+ }
1975
+ if (isMC) {
1976
+ return labels.mc;
1977
+ }
1978
+ if (isMediaPage) {
1979
+ return labels.mediaPage;
1980
+ }
1981
+ if (isShortAnswer) {
1982
+ return labels.shortAnswer;
1983
+ }
1984
+ if (isRespondWritten) {
1985
+ return labels.respondWritten;
1986
+ }
1987
+ if (isRespondAudio) {
1988
+ return labels.respondAudio;
1989
+ }
1990
+ return {
1991
+ short: "",
1992
+ long: ""
1993
+ };
1994
+ };
1995
+
1996
+ // src/domains/sets/set.hooks.ts
1997
+ import { useQuery as useQuery4 } from "@tanstack/react-query";
1998
+
1999
+ // src/domains/sets/set.constants.ts
2000
+ var SETS_COLLECTION = "sets";
2001
+ var refsSetsFirestore = {
2002
+ allSets: SETS_COLLECTION,
2003
+ set: (id) => `${SETS_COLLECTION}/${id}`
2004
+ };
2005
+
2006
+ // src/domains/sets/services/get-set.service.ts
2007
+ async function _getSet({ setId }) {
2008
+ const response = await api.getDoc(refsSetsFirestore.set(setId));
2009
+ return response.data;
2010
+ }
2011
+ var getSet = withErrorHandler(_getSet, "getSet");
2012
+
2013
+ // src/domains/sets/set.hooks.ts
2014
+ var setsQueryKeys = {
2015
+ all: ["sets"],
2016
+ one: (params) => [...setsQueryKeys.all, params.setId]
2017
+ };
2018
+ var useSet = ({ setId, enabled }) => {
2019
+ return useQuery4({
2020
+ queryKey: setsQueryKeys.one({ setId }),
2021
+ queryFn: () => getSet({ setId }),
2022
+ enabled: setId !== void 0 && setId !== "" && enabled
2023
+ });
2024
+ };
2025
+ function getSetFromCache({
2026
+ setId,
2027
+ queryClient
2028
+ }) {
2029
+ if (!setId) return null;
2030
+ return queryClient.getQueryData(setsQueryKeys.one({ setId }));
2031
+ }
2032
+ function updateSetInCache({
2033
+ set,
2034
+ queryClient
2035
+ }) {
2036
+ const { id, ...setData } = set;
2037
+ queryClient.setQueryData(setsQueryKeys.one({ setId: id }), setData);
2038
+ }
2039
+
2040
+ // src/domains/sets/set.repo.ts
2041
+ var createSetRepo = () => {
2042
+ return {
2043
+ getSet
2044
+ };
2045
+ };
2046
+
2047
+ // src/constants/all-langs.json
2048
+ var all_langs_default = {
2049
+ af: "Afrikaans",
2050
+ sq: "Albanian",
2051
+ am: "Amharic",
2052
+ ar: "Arabic",
2053
+ hy: "Armenian",
2054
+ az: "Azerbaijani",
2055
+ eu: "Basque",
2056
+ be: "Belarusian",
2057
+ bn: "Bengali",
2058
+ bs: "Bosnian",
2059
+ bg: "Bulgarian",
2060
+ ca: "Catalan",
2061
+ ceb: "Cebuano",
2062
+ zh: "Chinese",
2063
+ co: "Corsican",
2064
+ hr: "Croatian",
2065
+ cs: "Czech",
2066
+ da: "Danish",
2067
+ nl: "Dutch",
2068
+ en: "English",
2069
+ eo: "Esperanto",
2070
+ et: "Estonian",
2071
+ fi: "Finnish",
2072
+ fr: "French",
2073
+ fy: "Frisian",
2074
+ gl: "Galician",
2075
+ ka: "Georgian",
2076
+ de: "German",
2077
+ el: "Greek",
2078
+ gu: "Gujarati",
2079
+ ht: "Haitian Creole",
2080
+ ha: "Hausa",
2081
+ haw: "Hawaiian",
2082
+ he: "Hebrew",
2083
+ hi: "Hindi",
2084
+ hmn: "Hmong",
2085
+ hu: "Hungarian",
2086
+ is: "Icelandic",
2087
+ ig: "Igbo",
2088
+ id: "Indonesian",
2089
+ ga: "Irish",
2090
+ it: "Italian",
2091
+ ja: "Japanese",
2092
+ jv: "Javanese",
2093
+ kn: "Kannada",
2094
+ kk: "Kazakh",
2095
+ km: "Khmer",
2096
+ ko: "Korean",
2097
+ ku: "Kurdish",
2098
+ ky: "Kyrgyz",
2099
+ lo: "Lao",
2100
+ la: "Latin",
2101
+ lv: "Latvian",
2102
+ lt: "Lithuanian",
2103
+ lb: "Luxembourgish",
2104
+ mk: "Macedonian",
2105
+ mg: "Malagasy",
2106
+ ms: "Malay",
2107
+ ml: "Malayalam",
2108
+ mt: "Maltese",
2109
+ mi: "Maori",
2110
+ mr: "Marathi",
2111
+ mn: "Mongolian",
2112
+ my: "Myanmar (Burmese)",
2113
+ ne: "Nepali",
2114
+ no: "Norwegian",
2115
+ ny: "Nyanja (Chichewa)",
2116
+ ps: "Pashto",
2117
+ fa: "Persian",
2118
+ pl: "Polish",
2119
+ pt: "Portuguese",
2120
+ pa: "Punjabi",
2121
+ ro: "Romanian",
2122
+ ru: "Russian",
2123
+ sm: "Samoan",
2124
+ gd: "Scots Gaelic",
2125
+ sr: "Serbian",
2126
+ st: "Sesotho",
2127
+ sn: "Shona",
2128
+ sd: "Sindhi",
2129
+ si: "Sinhala (Sinhalese)",
2130
+ sk: "Slovak",
2131
+ sl: "Slovenian",
2132
+ so: "Somali",
2133
+ es: "Spanish",
2134
+ su: "Sundanese",
2135
+ sw: "Swahili",
2136
+ sv: "Swedish",
2137
+ tl: "Tagalog (Filipino)",
2138
+ tg: "Tajik",
2139
+ ta: "Tamil",
2140
+ te: "Telugu",
2141
+ th: "Thai",
2142
+ tr: "Turkish",
2143
+ uk: "Ukrainian",
2144
+ ur: "Urdu",
2145
+ uz: "Uzbek",
2146
+ vi: "Vietnamese",
2147
+ cy: "Welsh",
2148
+ xh: "Xhosa",
2149
+ yi: "Yiddish",
2150
+ yo: "Yoruba",
2151
+ zu: "Zulu"
2152
+ };
2153
+
2154
+ // src/utils/ai/get-respond-card-tool.ts
2155
+ var getRespondCardTool = ({
2156
+ language,
2157
+ standard = "actfl"
2158
+ }) => {
2159
+ const lang = all_langs_default[language] || "English";
2160
+ const tool = {
2161
+ tool_choice: {
2162
+ type: "function",
2163
+ function: { name: "get_feedback" }
2164
+ },
2165
+ tools: [
2166
+ {
2167
+ type: "function",
2168
+ function: {
2169
+ name: "get_feedback",
2170
+ description: "Get feedback on a student's response",
2171
+ parameters: {
2172
+ type: "object",
2173
+ required: [
2174
+ "success",
2175
+ "score",
2176
+ "score_justification",
2177
+ "errors",
2178
+ "improvedResponse",
2179
+ "compliments"
2180
+ ],
2181
+ properties: {
2182
+ success: {
2183
+ type: "boolean",
2184
+ description: "Mark true if the student's response was on-topic and generally demonstrated understanding. A few grammar mistakes are acceptable. Mark false if the student's response was off-topic or did not demonstrate understanding."
2185
+ },
2186
+ errors: {
2187
+ type: "array",
2188
+ items: {
2189
+ type: "object",
2190
+ required: ["error", "grammar_error_type", "correction", "justification"],
2191
+ properties: {
2192
+ error: {
2193
+ type: "string",
2194
+ description: "The grammatical error in the student's response."
2195
+ },
2196
+ correction: {
2197
+ type: "string",
2198
+ description: "The suggested correction to the error"
2199
+ },
2200
+ justification: {
2201
+ type: "string",
2202
+ description: `An explanation of the rationale behind the suggested correction. WRITE THIS IN ${lang}!`
2203
+ },
2204
+ grammar_error_type: {
2205
+ type: "string",
2206
+ enum: [
2207
+ "subjVerbAgree",
2208
+ "tenseErrors",
2209
+ "articleMisuse",
2210
+ "prepositionErrors",
2211
+ "adjNounAgree",
2212
+ "pronounErrors",
2213
+ "wordOrder",
2214
+ "verbConjugation",
2215
+ "pluralization",
2216
+ "negationErrors",
2217
+ "modalVerbMisuse",
2218
+ "relativeClause",
2219
+ "auxiliaryVerb",
2220
+ "complexSentenceAgreement",
2221
+ "idiomaticExpression",
2222
+ "registerInconsistency",
2223
+ "voiceMisuse"
2224
+ ],
2225
+ description: "The type of grammatical error found. It should be one of the following categories: subject-verb agreement, tense errors, article misuse, preposition errors, adjective-noun agreement, pronoun errors, word order, verb conjugation, pluralization errors, negation errors, modal verb misuse, relative clause errors, auxiliary verb misuse, complex sentence agreement, idiomatic expression, register inconsistency, or voice misuse"
2226
+ }
2227
+ }
2228
+ },
2229
+ description: "An array of objects, each representing a grammatical error in the student's response. Each object should have the following properties: error, grammar_error_type, correction, and justification. If there were no errors, return an empty array."
2230
+ },
2231
+ compliments: {
2232
+ type: "array",
2233
+ items: {
2234
+ type: "string"
2235
+ },
2236
+ description: `An array of strings, each representing something the student did well. Each string should be WRITTEN IN ${lang}!`
2237
+ },
2238
+ improvedResponse: {
2239
+ type: "string",
2240
+ description: "An improved response with proper grammar and more detail, if applicable."
2241
+ },
2242
+ score: {
2243
+ type: "number",
2244
+ description: "A score between 0 and 100, reflecting the overall quality of the response"
2245
+ },
2246
+ score_justification: {
2247
+ type: "string",
2248
+ description: "An explanation of the rationale behind the assigned score, considering both accuracy and fluency"
2249
+ }
2250
+ }
2251
+ }
2252
+ }
2253
+ }
2254
+ ]
2255
+ };
2256
+ if (standard === "wida") {
2257
+ const wida_level = {
2258
+ type: "number",
2259
+ enum: [1, 2, 3, 4, 5, 6],
2260
+ description: `The student's WIDA (World-Class Instructional Design and Assessment) proficiency level. Choose one of the following options: 1, 2, 3, 4, 5, 6 which corresponds to
2261
+
2262
+ 1 - Entering
2263
+ 2 - Emerging
2264
+ 3 - Developing
2265
+ 4 - Expanding
2266
+ 5 - Bridging
2267
+ 6 - Reaching
2268
+
2269
+ This is an estimate based on the level of the student's response. Use the descriptions of the WIDA speaking standards to guide your decision.
2270
+ `
2271
+ };
2272
+ const wida_justification = {
2273
+ type: "string",
2274
+ description: `An explanation of the rationale behind the assigned WIDA level of the response, considering both accuracy and fluency. WRITE THIS IN ENGLISH!`
2275
+ };
2276
+ tool.tools[0].function.parameters.required.push("wida_level");
2277
+ tool.tools[0].function.parameters.required.push("wida_justification");
2278
+ tool.tools[0].function.parameters.properties.wida_level = wida_level;
2279
+ tool.tools[0].function.parameters.properties.wida_justification = wida_justification;
2280
+ } else {
2281
+ const actfl_level = {
2282
+ type: "string",
2283
+ enum: ["NL", "NM", "NH", "IL", "IM", "IH", "AL", "AM", "AH", "S", "D"],
2284
+ description: "The student's ACTFL (American Council on the Teaching of Foreign Languages) proficiency level. Choose one of the following options: NL, NM, NH, IL, IM, IH, AL, AM, AH, S, or D"
2285
+ };
2286
+ const actfl_justification = {
2287
+ type: "string",
2288
+ description: "An explanation of the rationale behind the assigned ACTFL level, considering both accuracy and fluency"
2289
+ };
2290
+ tool.tools[0].function.parameters.required.push("actfl_level");
2291
+ tool.tools[0].function.parameters.required.push("actfl_justification");
2292
+ tool.tools[0].function.parameters.properties.actfl_level = actfl_level;
2293
+ tool.tools[0].function.parameters.properties.actfl_justification = actfl_justification;
2294
+ }
2295
+ return tool;
2296
+ };
2297
+
2298
+ // src/hooks/useActivity.ts
2299
+ import { useEffect as useEffect2 } from "react";
2300
+
2301
+ // src/services/add-grading-standard.ts
2302
+ var addGradingStandardLog = async (gradingStandard, userId) => {
2303
+ logGradingStandardLog(gradingStandard);
2304
+ const path = `users/${userId}/grading_standard_logs`;
2305
+ await api.addDoc(path, gradingStandard);
2306
+ };
2307
+
2308
+ // src/hooks/useActivityTracker.ts
2309
+ import { v4 as v42 } from "uuid";
2310
+ function useActivityTracker({ userId }) {
2311
+ const trackActivity = async ({
2312
+ activityName,
2313
+ activityType,
2314
+ id = v42(),
2315
+ language = ""
2316
+ }) => {
2317
+ if (userId) {
2318
+ const { doc: doc2, serverTimestamp: serverTimestamp2, setDoc: setDoc2 } = api.accessHelpers();
2319
+ const activityRef = doc2(`users/${userId}/activity/${id}`);
2320
+ const timestamp = serverTimestamp2();
2321
+ await setDoc2(activityRef, {
2322
+ name: activityName,
2323
+ type: activityType,
2324
+ lastSeen: timestamp,
2325
+ id,
2326
+ language
2327
+ });
2328
+ }
2329
+ };
2330
+ return {
2331
+ trackActivity
2332
+ };
2333
+ }
2334
+
2335
+ // src/hooks/useActivity.ts
2336
+ function useActivity({
2337
+ id,
2338
+ isAssignment,
2339
+ onAssignmentSubmitted,
2340
+ ltiData
2341
+ }) {
2342
+ var _a, _b;
2343
+ const { queryClient, user } = useSpeakableApi();
2344
+ const userId = user.auth.uid;
2345
+ const assignmentQuery = useAssignment({
2346
+ assignmentId: id,
2347
+ userId,
2348
+ enabled: isAssignment
2349
+ });
2350
+ const activeAssignment = assignmentQuery.data;
2351
+ const setId = isAssignment ? (_a = activeAssignment == null ? void 0 : activeAssignment.setId) != null ? _a : "" : id;
2352
+ const querySet = useSet({ setId });
2353
+ const setData = querySet.data;
2354
+ const assignmentContent = activeAssignment == null ? void 0 : activeAssignment.content;
2355
+ const assignmentWeights = activeAssignment == null ? void 0 : activeAssignment.weights;
2356
+ const setContent = setData == null ? void 0 : setData.content;
2357
+ const setWeights = setData == null ? void 0 : setData.weights;
2358
+ const contentCardsToUse = isAssignment ? assignmentContent != null ? assignmentContent : setContent : setContent;
2359
+ const weightsToUse = isAssignment ? assignmentWeights != null ? assignmentWeights : setWeights : setWeights;
2360
+ const activityId = isAssignment ? (_b = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b : "" : setId;
2361
+ const { cardsObject, cardsQueries, cards } = useCards({
2362
+ cardIds: contentCardsToUse != null ? contentCardsToUse : [],
2363
+ enabled: querySet.isSuccess,
2364
+ asObject: true
2365
+ });
2366
+ const scoreQuery = useScore({
2367
+ isAssignment,
2368
+ activityId: id,
2369
+ userId,
2370
+ courseId: activeAssignment == null ? void 0 : activeAssignment.courseId,
2371
+ googleClassroomUserId: user.profile.googleClassroomUserId,
2372
+ enabled: isAssignment ? assignmentQuery.isSuccess : querySet.isSuccess
2373
+ });
2374
+ const { mutationUpdateScore } = useUpdateScore();
2375
+ const { mutationUpdateCardScore } = useUpdateCardScore({
2376
+ activityId,
2377
+ isAssignment,
2378
+ userId,
2379
+ cardIds: contentCardsToUse != null ? contentCardsToUse : [],
2380
+ weights: weightsToUse != null ? weightsToUse : {}
2381
+ });
2382
+ const { mutationClearScore } = useClearScore();
2383
+ const { submitAssignmentScore: submitAssignmentScore2 } = useSubmitAssignmentScore({
2384
+ onAssignmentSubmitted,
2385
+ studentName: user.profile.displayName
2386
+ });
2387
+ const { submitPracticeScore: submitPracticeScore2 } = useSubmitPracticeScore();
2388
+ const handleUpdateScore = (data) => {
2389
+ mutationUpdateScore.mutate({
2390
+ data,
2391
+ isAssignment,
2392
+ activityId,
2393
+ userId
2394
+ });
2395
+ };
2396
+ const handleUpdateCardScore = (cardId, cardScore) => {
2397
+ mutationUpdateCardScore.mutate({ cardId, cardScore });
2398
+ if (cardScore.proficiency_level) {
2399
+ logGradingStandardEntry({
2400
+ type: cardScore.proficiency_level.standardId,
2401
+ cardId,
2402
+ gradingStandard: cardScore.proficiency_level
2403
+ });
2404
+ } else if (cardScore.wida || cardScore.actfl) {
2405
+ logGradingStandardEntry({
2406
+ type: cardScore.wida ? "wida" : "actfl",
2407
+ cardId,
2408
+ gradingStandard: cardScore.wida || cardScore.actfl || { level: "", justification: "" }
2409
+ });
2410
+ }
2411
+ };
2412
+ const onClearScore = ({
2413
+ cardId,
2414
+ wasCompleted = true
2415
+ }) => {
2416
+ var _a2, _b2;
2417
+ const currentCard = cardsObject == null ? void 0 : cardsObject[cardId];
2418
+ if ((currentCard == null ? void 0 : currentCard.type) === "MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */ || (currentCard == null ? void 0 : currentCard.type) === "READ_REPEAT" /* READ_REPEAT */) {
2419
+ return;
2420
+ }
2421
+ const queryKeys = scoreQueryKeys.byId(activityId);
2422
+ const activeCardScores = (_b2 = (_a2 = queryClient.getQueryData(queryKeys)) == null ? void 0 : _a2.cards) == null ? void 0 : _b2[cardId];
2423
+ if (activeCardScores === void 0) return;
2424
+ mutationClearScore.mutate({
2425
+ isAssignment,
2426
+ activityId,
2427
+ cardScores: activeCardScores,
2428
+ cardId,
2429
+ userId
2430
+ });
2431
+ };
2432
+ const onSubmitScore = async () => {
2433
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
2434
+ try {
2435
+ let results;
2436
+ if (isAssignment) {
2437
+ const cardScores = ((_a2 = scoreQuery.data) == null ? void 0 : _a2.cards) || {};
2438
+ const hasPendingReview = Object.values(cardScores).some(
2439
+ (cardScore) => cardScore.status === "pending_review"
2440
+ );
2441
+ results = await submitAssignmentScore2({
2442
+ assignment: {
2443
+ id: (_c = (_b2 = assignmentQuery.data) == null ? void 0 : _b2.id) != null ? _c : "",
2444
+ name: (_e = (_d = assignmentQuery.data) == null ? void 0 : _d.name) != null ? _e : "",
2445
+ owners: (_g = (_f = assignmentQuery.data) == null ? void 0 : _f.owners) != null ? _g : [],
2446
+ courseId: (_i = (_h = assignmentQuery.data) == null ? void 0 : _h.courseId) != null ? _i : "",
2447
+ courseWorkId: (_k = (_j = assignmentQuery.data) == null ? void 0 : _j.courseWorkId) != null ? _k : "",
2448
+ isAssessment: (_m = (_l = assignmentQuery.data) == null ? void 0 : _l.isAssessment) != null ? _m : false,
2449
+ maxPoints: (_o = (_n = assignmentQuery.data) == null ? void 0 : _n.maxPoints) != null ? _o : 0
2450
+ },
2451
+ userId,
2452
+ cardIds: contentCardsToUse != null ? contentCardsToUse : [],
2453
+ scores: scoreQuery.data,
2454
+ weights: weightsToUse != null ? weightsToUse : {},
2455
+ status: hasPendingReview ? "PENDING_REVIEW" : "FINALIZED"
2456
+ });
2457
+ if ((_p = assignmentQuery.data) == null ? void 0 : _p.ltiDeeplink) {
2458
+ submitLTIScore({
2459
+ maxPoints: (_q = assignmentQuery.data) == null ? void 0 : _q.maxPoints,
2460
+ score: (_s = (_r = scoreQuery.data) == null ? void 0 : _r.score) != null ? _s : 0,
2461
+ SERVICE_KEY: (_t = ltiData == null ? void 0 : ltiData.serviceKey) != null ? _t : "",
2462
+ lineItemId: (_u = ltiData == null ? void 0 : ltiData.lineItemId) != null ? _u : "",
2463
+ lti_id: (_v = ltiData == null ? void 0 : ltiData.lti_id) != null ? _v : ""
2464
+ });
2465
+ }
2466
+ } else {
2467
+ results = await submitPracticeScore2({
2468
+ setId: (_x = (_w = querySet.data) == null ? void 0 : _w.id) != null ? _x : "",
2469
+ userId,
2470
+ scores: scoreQuery.data
2471
+ });
2472
+ }
2473
+ return results;
2474
+ } catch (error) {
2475
+ return {
2476
+ success: false,
2477
+ error
2478
+ };
2479
+ }
2480
+ };
2481
+ const logGradingStandardEntry = ({
2482
+ cardId,
2483
+ gradingStandard,
2484
+ type
2485
+ }) => {
2486
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
2487
+ const card = cardsObject == null ? void 0 : cardsObject[cardId];
2488
+ const scoresObject = queryClient.getQueryData(scoreQueryKeys.byId(activityId));
2489
+ const cardScore = (_a2 = scoresObject == null ? void 0 : scoresObject.cards) == null ? void 0 : _a2[cardId];
2490
+ const serverTimestamp2 = api.helpers.serverTimestamp;
2491
+ addGradingStandardLog(
2492
+ {
2493
+ assignmentId: (_b2 = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b2 : "",
2494
+ courseId: (_c = activeAssignment == null ? void 0 : activeAssignment.courseId) != null ? _c : "",
2495
+ teacherId: (_d = activeAssignment == null ? void 0 : activeAssignment.owners[0]) != null ? _d : "",
2496
+ setId: (_e = setData == null ? void 0 : setData.id) != null ? _e : "",
2497
+ cardId,
2498
+ level: gradingStandard.level,
2499
+ justification: gradingStandard.justification,
2500
+ transcript: (_f = cardScore == null ? void 0 : cardScore.transcript) != null ? _f : "",
2501
+ audioUrl: (_g = cardScore == null ? void 0 : cardScore.audio) != null ? _g : "",
2502
+ prompt: (_h = card == null ? void 0 : card.prompt) != null ? _h : "",
2503
+ responseType: (card == null ? void 0 : card.type) === "RESPOND_WRITE" /* RESPOND_WRITE */ ? "written" : "spoken",
2504
+ type,
2505
+ dateMade: serverTimestamp2(),
2506
+ language: (_i = card == null ? void 0 : card.language) != null ? _i : ""
2507
+ },
2508
+ userId
2509
+ );
2510
+ };
2511
+ useEffect2(() => {
2512
+ if (isAssignment) {
2513
+ logOpenAssignment({ assignmentId: id });
2514
+ } else {
2515
+ logOpenActivityPreview({ setId: id });
2516
+ }
2517
+ }, []);
2518
+ useInitActivity({
2519
+ assignment: activeAssignment != null ? activeAssignment : void 0,
2520
+ set: setData != null ? setData : void 0,
2521
+ enabled: !!setData,
2522
+ userId
2523
+ });
2524
+ return {
2525
+ set: {
2526
+ data: setData,
2527
+ query: querySet
2528
+ },
2529
+ cards: {
2530
+ data: cardsObject,
2531
+ query: cardsQueries,
2532
+ cardsArray: cards
2533
+ },
2534
+ assignment: {
2535
+ data: isAssignment ? activeAssignment : void 0,
2536
+ query: assignmentQuery
2537
+ },
2538
+ scores: {
2539
+ data: scoreQuery.data,
2540
+ query: scoreQuery,
2541
+ actions: {
2542
+ update: handleUpdateScore,
2543
+ clear: onClearScore,
2544
+ submit: onSubmitScore,
2545
+ updateCard: handleUpdateCardScore,
2546
+ logGradingStandardEntry
2547
+ }
2548
+ }
2549
+ };
2550
+ }
2551
+ var useInitActivity = ({
2552
+ assignment,
2553
+ set,
2554
+ enabled,
2555
+ userId
2556
+ }) => {
2557
+ const { trackActivity } = useActivityTracker({ userId });
2558
+ const init = () => {
2559
+ var _a, _b, _c, _d, _e, _f, _g;
2560
+ if (!enabled) return;
2561
+ if (!assignment) {
2562
+ trackActivity({
2563
+ activityName: (_a = set == null ? void 0 : set.name) != null ? _a : "",
2564
+ activityType: "set",
2565
+ id: set == null ? void 0 : set.id,
2566
+ language: set == null ? void 0 : set.language
2567
+ });
2568
+ } else if (assignment.name) {
2569
+ trackActivity({
2570
+ activityName: assignment.name,
2571
+ activityType: assignment.isAssessment ? "assessment" : "assignment",
2572
+ id: assignment.id,
2573
+ language: set == null ? void 0 : set.language
2574
+ });
2575
+ }
2576
+ if (set == null ? void 0 : set.public) {
2577
+ (_d = (_c = (_b = api).httpsCallable) == null ? void 0 : _c.call(_b, "onSetOpened")) == null ? void 0 : _d({
2578
+ setId: set.id,
2579
+ language: set.language
2580
+ });
2581
+ }
2582
+ (_g = (_f = (_e = api).httpsCallable) == null ? void 0 : _f.call(_e, "updateAlgoliaIndex")) == null ? void 0 : _g({
2583
+ updatePlays: true,
2584
+ objectID: set == null ? void 0 : set.id
2585
+ });
2586
+ };
2587
+ useEffect2(() => {
2588
+ init();
2589
+ }, [set]);
2590
+ };
2591
+ var submitLTIScore = async ({
2592
+ maxPoints,
2593
+ score,
2594
+ SERVICE_KEY,
2595
+ lineItemId,
2596
+ lti_id
2597
+ }) => {
2598
+ var _a, _b, _c;
2599
+ try {
2600
+ if (!SERVICE_KEY || !lineItemId || !lti_id) {
2601
+ throw new Error("Missing required LTI credentials");
2602
+ }
2603
+ const earnedPoints = score ? score / 100 * maxPoints : 0;
2604
+ const { data } = await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitLTIAssignmentScore")) == null ? void 0 : _c({
2605
+ SERVICE_KEY,
2606
+ scoreData: {
2607
+ lineItemId,
2608
+ userId: lti_id,
2609
+ maxPoints,
2610
+ earnedPoints
2611
+ }
2612
+ }));
2613
+ return { success: true, data };
2614
+ } catch (error) {
2615
+ console.error("Failed to submit LTI score:", error);
2616
+ return {
2617
+ success: false,
2618
+ error: error instanceof Error ? error : new Error("Unknown error occurred")
2619
+ };
2620
+ }
2621
+ };
2622
+
2623
+ // src/hooks/useCredits.ts
2624
+ import { useQuery as useQuery5 } from "@tanstack/react-query";
2625
+ var creditQueryKeys = {
2626
+ userCredits: (uid) => ["userCredits", uid]
2627
+ };
2628
+ var useUserCredits = () => {
2629
+ const { user } = useSpeakableApi();
2630
+ const email = user.auth.email;
2631
+ const uid = user.auth.uid;
2632
+ const query2 = useQuery5({
2633
+ queryKey: creditQueryKeys.userCredits(uid),
2634
+ queryFn: () => fetchUserCredits({ uid, email }),
2635
+ enabled: !!uid,
2636
+ refetchInterval: 1e3 * 60 * 5
2637
+ });
2638
+ return {
2639
+ ...query2
2640
+ };
2641
+ };
2642
+ var fetchUserCredits = async ({ uid, email }) => {
2643
+ if (!uid) {
2644
+ throw new Error("User ID is required");
2645
+ }
2646
+ const contractSnap = await api.getDoc(`creditContracts/${uid}`);
2647
+ if (contractSnap.data == null) {
2648
+ return {
2649
+ id: uid,
2650
+ userId: uid,
2651
+ email,
2652
+ effectivePlanId: "free_tier",
2653
+ status: "inactive",
2654
+ isUnlimited: false,
2655
+ creditsAvailable: 100,
2656
+ creditsAllocatedThisPeriod: 100,
2657
+ topOffCreditsAvailable: 0,
2658
+ topOffCreditsTotal: 0,
2659
+ allocationSource: "free_tier",
2660
+ sourceDetails: {},
2661
+ periodStart: null,
2662
+ periodEnd: null,
2663
+ planTermEndTimestamp: null,
2664
+ ownerType: "individual",
2665
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2666
+ lastUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
2667
+ };
2668
+ }
2669
+ const contractData = contractSnap.data;
2670
+ const monthlyCredits = (contractData == null ? void 0 : contractData.creditsAvailable) || 0;
2671
+ const topOffCredits = (contractData == null ? void 0 : contractData.topOffCreditsAvailable) || 0;
2672
+ const totalCredits = monthlyCredits + topOffCredits;
2673
+ return {
2674
+ id: contractSnap.id,
2675
+ ...contractData,
2676
+ // Add computed total for convenience
2677
+ totalCreditsAvailable: totalCredits
2678
+ };
2679
+ };
2680
+
2681
+ // src/hooks/useOrganizationAccess.ts
2682
+ import { useQuery as useQuery6 } from "@tanstack/react-query";
2683
+ var useOrganizationAccess = () => {
2684
+ const { user } = useSpeakableApi();
2685
+ const email = user.auth.email;
2686
+ const query2 = useQuery6({
2687
+ queryKey: ["organizationAccess", email],
2688
+ queryFn: async () => {
2689
+ if (!email) {
2690
+ return {
2691
+ hasUnlimitedAccess: false,
2692
+ subscriptionId: null,
2693
+ organizationId: null,
2694
+ organizationName: null,
2695
+ subscriptionEndDate: null,
2696
+ accessType: "individual"
2697
+ };
2698
+ }
2699
+ return getOrganizationAccess(email);
2700
+ },
2701
+ enabled: !!email,
2702
+ // Only run query if we have a user email
2703
+ staleTime: 5 * 60 * 1e3,
2704
+ // Consider data fresh for 5 minutes
2705
+ gcTime: 10 * 60 * 1e3,
2706
+ // Keep in cache for 10 minutes
2707
+ retry: 2
2708
+ // Retry failed requests twice
2709
+ });
2710
+ return {
2711
+ ...query2
2712
+ };
2713
+ };
2714
+ var getOrganizationAccess = async (email) => {
2715
+ const { limit: limit2, where: where2 } = api.accessQueryConstraints();
2716
+ try {
2717
+ const organizationSnapshot = await api.getDocs(
2718
+ "organizations",
2719
+ where2("members", "array-contains", email),
2720
+ where2("masterSubscriptionStatus", "==", "active"),
2721
+ limit2(1)
2722
+ );
2723
+ if (!organizationSnapshot.empty) {
2724
+ const orgData = organizationSnapshot.data[0];
2725
+ return {
2726
+ hasUnlimitedAccess: true,
2727
+ subscriptionId: orgData == null ? void 0 : orgData.masterSubscriptionId,
2728
+ organizationId: orgData.id,
2729
+ organizationName: orgData.name || "Unknown Organization",
2730
+ subscriptionEndDate: orgData.masterSubscriptionEndDate || null,
2731
+ accessType: "organization"
2732
+ };
2733
+ }
2734
+ const institutionSnapshot = await api.getDocs(
2735
+ "institution_subscriptions",
2736
+ where2("users", "array-contains", email),
2737
+ where2("active", "==", true),
2738
+ limit2(1)
2739
+ );
2740
+ if (!institutionSnapshot.empty) {
2741
+ const institutionData = institutionSnapshot.data[0];
2742
+ const isUnlimited = (institutionData == null ? void 0 : institutionData.plan) === "organization" || (institutionData == null ? void 0 : institutionData.plan) === "school_starter";
2743
+ return {
2744
+ hasUnlimitedAccess: isUnlimited,
2745
+ subscriptionId: institutionData.id,
2746
+ organizationId: institutionData == null ? void 0 : institutionData.institutionId,
2747
+ organizationName: institutionData.name || institutionData.institutionId || "Legacy Institution",
2748
+ subscriptionEndDate: institutionData.endDate || null,
2749
+ accessType: "institution_subscriptions"
2750
+ };
2751
+ }
2752
+ return {
2753
+ hasUnlimitedAccess: false,
2754
+ subscriptionId: null,
2755
+ organizationId: null,
2756
+ organizationName: null,
2757
+ subscriptionEndDate: null,
2758
+ accessType: "individual"
2759
+ };
2760
+ } catch (error) {
2761
+ console.error("Error checking organization access:", error);
2762
+ return {
2763
+ hasUnlimitedAccess: false,
2764
+ subscriptionId: null,
2765
+ organizationId: null,
2766
+ organizationName: null,
2767
+ subscriptionEndDate: null,
2768
+ accessType: "individual"
2769
+ };
2770
+ }
2771
+ };
2772
+
2773
+ // src/hooks/useUpdateStudentVoc.ts
2774
+ var useUpdateStudentVocab = (page) => {
2775
+ const { user } = useSpeakableApi();
2776
+ const currentUserId = user == null ? void 0 : user.auth.uid;
2777
+ if (!page || !currentUserId || !page.target_text || !page.language) {
2778
+ return {
2779
+ studentVocabMarkVoiceSuccess: void 0,
2780
+ studentVocabMarkVoiceFail: void 0
2781
+ };
2782
+ }
2783
+ const getDataObject = () => {
2784
+ var _a, _b;
2785
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
2786
+ const language = (_a = page.language) != null ? _a : "en";
2787
+ const word = (_b = page.target_text) != null ? _b : "";
2788
+ const phrase_length = getPhraseLength(word);
2789
+ const wordHash = getWordHash(word, language);
2790
+ const docPath = `users/${currentUserId}/vocab/${wordHash}`;
2791
+ const communityPath = `checked-pronunciations/${wordHash}`;
2792
+ const id = `${language}-${cleanString(word)}`;
2793
+ const data = {
2794
+ id,
2795
+ word,
2796
+ words: (word == null ? void 0 : word.split(" ")) || [],
2797
+ wordHash,
2798
+ language,
2799
+ lastSeen: serverTimestamp2(),
2800
+ phrase_length
2801
+ };
2802
+ return {
2803
+ docPath,
2804
+ communityPath,
2805
+ data
2806
+ };
2807
+ };
2808
+ const markVoiceSuccess = async () => {
2809
+ const { docPath, communityPath, data } = getDataObject();
2810
+ const { increment: increment2 } = api.accessQueryConstraints();
2811
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
2812
+ data.voiceSuccess = increment2(1);
2813
+ try {
2814
+ await api.updateDoc(docPath, data);
2815
+ } catch (error) {
2816
+ if (error instanceof Error && error.message === "not-found") {
2817
+ data.firstSeen = serverTimestamp2();
2818
+ await api.setDoc(docPath, data, { merge: true });
2819
+ } else {
2820
+ console.log(error);
2821
+ }
2822
+ }
2823
+ try {
2824
+ data.pronunciations = increment2(1);
2825
+ await api.setDoc(communityPath, data, { merge: true });
2826
+ } catch (error) {
2827
+ console.log(error);
2828
+ }
2829
+ };
2830
+ const markVoiceFail = async () => {
2831
+ const { docPath, communityPath, data } = getDataObject();
2832
+ const { increment: increment2 } = api.accessQueryConstraints();
2833
+ const { serverTimestamp: serverTimestamp2 } = api.accessHelpers();
2834
+ data.voiceFail = increment2(1);
2835
+ try {
2836
+ await api.updateDoc(docPath, data);
2837
+ } catch (error) {
2838
+ if (error instanceof Error && error.message === "not-found") {
2839
+ data.firstSeen = serverTimestamp2();
2840
+ await api.setDoc(docPath, data, { merge: true });
2841
+ } else {
2842
+ console.log(error);
2843
+ }
2844
+ }
2845
+ try {
2846
+ data.fails = increment2(1);
2847
+ await api.setDoc(communityPath, data, { merge: true });
2848
+ } catch (error) {
2849
+ console.log(error);
2850
+ }
2851
+ };
2852
+ return {
2853
+ studentVocabMarkVoiceSuccess: markVoiceSuccess,
2854
+ studentVocabMarkVoiceFail: markVoiceFail
2855
+ };
2856
+ };
2857
+
2858
+ // src/hooks/useActivityFeedbackAccess.ts
2859
+ import { useQuery as useQuery7 } from "@tanstack/react-query";
2860
+ var activityFeedbackAccessQueryKeys = {
2861
+ activityFeedbackAccess: (args) => ["activityFeedbackAccess", ...Object.values(args)]
2862
+ };
2863
+ var useActivityFeedbackAccess = ({
2864
+ aiEnabled = false,
2865
+ isActivityRoute = false
2866
+ }) => {
2867
+ var _a, _b, _c;
2868
+ const { user } = useSpeakableApi();
2869
+ const uid = user.auth.uid;
2870
+ const isTeacher = (_a = user.profile) == null ? void 0 : _a.isTeacher;
2871
+ const isStudent = (_b = user.profile) == null ? void 0 : _b.isStudent;
2872
+ const userRoles = ((_c = user.profile) == null ? void 0 : _c.roles) || [];
2873
+ const query2 = useQuery7({
2874
+ queryKey: activityFeedbackAccessQueryKeys.activityFeedbackAccess({
2875
+ aiEnabled,
2876
+ isActivityRoute
2877
+ }),
2878
+ queryFn: async () => {
2879
+ var _a2, _b2, _c2;
2880
+ if (!uid) {
2881
+ return {
2882
+ canAccessFeedback: false,
2883
+ reason: "Missing user ID",
2884
+ isUnlimited: false,
2885
+ accessType: "none"
2886
+ };
2887
+ }
2888
+ try {
2889
+ if (aiEnabled) {
2890
+ return {
2891
+ canAccessFeedback: true,
2892
+ reason: "AI feedback enabled",
2893
+ isUnlimited: true,
2894
+ accessType: "ai_enabled"
2895
+ };
2896
+ }
2897
+ if (isTeacher || userRoles.includes("ADMIN")) {
2898
+ return {
2899
+ canAccessFeedback: true,
2900
+ reason: "Teacher preview access",
2901
+ isUnlimited: true,
2902
+ accessType: "teacher_preview"
2903
+ };
2904
+ }
2905
+ if (isStudent && isActivityRoute) {
2906
+ try {
2907
+ const result = await ((_c2 = (_b2 = (_a2 = api).httpsCallable) == null ? void 0 : _b2.call(_a2, "checkStudentTeacherPlan")) == null ? void 0 : _c2({
2908
+ studentId: uid
2909
+ }));
2910
+ const planCheckResult = result.data;
2911
+ if (planCheckResult.canAccessFeedback) {
2912
+ return {
2913
+ canAccessFeedback: true,
2914
+ reason: planCheckResult.reason || "Student access via teacher with active plan",
2915
+ isUnlimited: planCheckResult.hasTeacherWithUnlimitedAccess,
2916
+ accessType: "student_with_teacher_plan"
2917
+ };
2918
+ } else {
2919
+ return {
2920
+ canAccessFeedback: false,
2921
+ reason: planCheckResult.reason || "No teacher with active plan found",
2922
+ isUnlimited: false,
2923
+ accessType: "none"
2924
+ };
2925
+ }
2926
+ } catch (error) {
2927
+ console.error("Error checking student teacher plan:", error);
2928
+ return {
2929
+ canAccessFeedback: false,
2930
+ reason: "Error checking teacher plans",
2931
+ isUnlimited: false,
2932
+ accessType: "none"
2933
+ };
2934
+ }
2935
+ }
2936
+ return {
2937
+ canAccessFeedback: false,
2938
+ reason: "No access permissions found for current context",
2939
+ isUnlimited: false,
2940
+ accessType: "none"
2941
+ };
2942
+ } catch (error) {
2943
+ console.error("Error checking activity feedback access:", error);
2944
+ return {
2945
+ canAccessFeedback: false,
2946
+ reason: "Error checking access permissions",
2947
+ isUnlimited: false,
2948
+ accessType: "none"
2949
+ };
2950
+ }
2951
+ },
2952
+ enabled: !!uid,
2953
+ staleTime: 5 * 60 * 1e3,
2954
+ // 5 minutes
2955
+ gcTime: 10 * 60 * 1e3
2956
+ // 10 minutes
2957
+ });
2958
+ return {
2959
+ ...query2
2960
+ };
2961
+ };
2962
+
2963
+ // src/hooks/useOpenAI.ts
2964
+ var useBaseOpenAI = ({
2965
+ onTranscriptSuccess,
2966
+ onTranscriptError,
2967
+ onCompletionSuccess,
2968
+ onCompletionError,
2969
+ aiEnabled,
2970
+ submitAudioResponse,
2971
+ uploadAudioAndGetTranscript,
2972
+ onGetAudioUrlAndTranscript
2973
+ }) => {
2974
+ const { user, queryClient } = useSpeakableApi();
2975
+ const currentUserId = user.auth.uid;
2976
+ const { data: feedbackAccess } = useActivityFeedbackAccess({
2977
+ aiEnabled
2978
+ });
2979
+ const getTranscript = async (audioUrl, language) => {
2980
+ var _a, _b;
2981
+ try {
2982
+ const getAssemblyAITranscript = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "transcribeAssemblyAIAudio");
2983
+ const response = await (getAssemblyAITranscript == null ? void 0 : getAssemblyAITranscript({
2984
+ audioUrl,
2985
+ language
2986
+ }));
2987
+ const transcript = response == null ? void 0 : response.data;
2988
+ return transcript;
2989
+ } catch (error) {
2990
+ console.log("error", error);
2991
+ onTranscriptError({
2992
+ type: "TRANSCRIPT",
2993
+ message: (error == null ? void 0 : error.message) || "Error getting transcript"
2994
+ });
2995
+ throw new Error(error);
2996
+ }
2997
+ };
2998
+ const getFreeResponseCompletion = async (messages, isFreeResponse, feedbackLanguage, gradingStandard = "actfl") => {
2999
+ var _a, _b, _c, _d, _e;
3000
+ const responseTool = getRespondCardTool({
3001
+ language: feedbackLanguage,
3002
+ standard: gradingStandard
3003
+ });
3004
+ try {
3005
+ const createChatCompletion = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "createChatCompletion");
3006
+ const {
3007
+ data: {
3008
+ response,
3009
+ prompt_tokens = 0,
3010
+ completion_tokens = 0,
3011
+ success: aiSuccess = false
3012
+ // the AI was able to generate a response
3013
+ }
3014
+ } = await (createChatCompletion == null ? void 0 : createChatCompletion({
3015
+ chat: {
3016
+ model: isFreeResponse ? "gpt-4-1106-preview" : "gpt-3.5-turbo-1106",
3017
+ messages,
3018
+ temperature: 0.7,
3019
+ ...responseTool
3020
+ },
3021
+ type: isFreeResponse ? "LONG_RESPONSE" : "SHORT_RESPONSE"
3022
+ }));
3023
+ const functionArguments = JSON.parse(((_e = (_d = (_c = response == null ? void 0 : response.tool_calls) == null ? void 0 : _c[0]) == null ? void 0 : _d.function) == null ? void 0 : _e.arguments) || "{}");
3024
+ const result = {
3025
+ ...functionArguments,
3026
+ prompt_tokens,
3027
+ completion_tokens,
3028
+ aiSuccess
3029
+ };
3030
+ onCompletionSuccess(result);
3031
+ return result;
3032
+ } catch (error) {
3033
+ onCompletionError({
3034
+ type: "COMPLETION",
3035
+ message: (error == null ? void 0 : error.message) || "Error getting completion"
3036
+ });
3037
+ throw new Error(error);
3038
+ }
3039
+ };
3040
+ const getFeedback = async ({
3041
+ cardId,
3042
+ language = "en",
3043
+ // required
3044
+ writtenResponse = null,
3045
+ // if the type = RESPOND_WRITE
3046
+ audio = null,
3047
+ autoGrade = true,
3048
+ file = null
3049
+ }) => {
3050
+ try {
3051
+ if (!(feedbackAccess == null ? void 0 : feedbackAccess.canAccessFeedback)) {
3052
+ const result = {
3053
+ noFeedbackAvailable: true,
3054
+ success: true,
3055
+ reason: (feedbackAccess == null ? void 0 : feedbackAccess.reason) || "No feedback access",
3056
+ accessType: (feedbackAccess == null ? void 0 : feedbackAccess.accessType) || "none"
3057
+ };
3058
+ onCompletionSuccess(result);
3059
+ return result;
3060
+ }
3061
+ let transcript;
3062
+ let audioUrl = void 0;
3063
+ if (writtenResponse) {
3064
+ transcript = writtenResponse;
3065
+ onTranscriptSuccess(writtenResponse);
3066
+ } else if (typeof audio === "string" && file) {
3067
+ if (feedbackAccess == null ? void 0 : feedbackAccess.canAccessFeedback) {
3068
+ transcript = await getTranscript(audio, language);
3069
+ audioUrl = audio;
3070
+ onTranscriptSuccess(transcript);
3071
+ } else {
3072
+ console.info(
3073
+ `Transcript not available: ${(feedbackAccess == null ? void 0 : feedbackAccess.reason) || "No feedback access"}`
3074
+ );
3075
+ }
3076
+ } else {
3077
+ const response = await uploadAudioAndGetTranscript(audio || "", language);
3078
+ transcript = response.transcript;
3079
+ audioUrl = response.audioUrl;
3080
+ }
3081
+ onGetAudioUrlAndTranscript == null ? void 0 : onGetAudioUrlAndTranscript({ transcript, audioUrl });
3082
+ if (feedbackAccess == null ? void 0 : feedbackAccess.canAccessFeedback) {
3083
+ const results = await getAIResponse({
3084
+ cardId,
3085
+ transcript: transcript || ""
3086
+ });
3087
+ let output = results;
3088
+ if (!autoGrade) {
3089
+ output = {
3090
+ ...output,
3091
+ noFeedbackAvailable: true,
3092
+ success: true
3093
+ };
3094
+ }
3095
+ onCompletionSuccess(output);
3096
+ return output;
3097
+ } else {
3098
+ const result = {
3099
+ noFeedbackAvailable: true,
3100
+ success: true,
3101
+ reason: (feedbackAccess == null ? void 0 : feedbackAccess.reason) || "No feedback access",
3102
+ accessType: (feedbackAccess == null ? void 0 : feedbackAccess.accessType) || "none"
3103
+ };
3104
+ onCompletionSuccess(result);
3105
+ return result;
3106
+ }
3107
+ } catch (error) {
3108
+ console.error("Error getting feedback:", error);
3109
+ throw new Error(error);
3110
+ }
3111
+ };
3112
+ const getAIResponse = async ({ cardId, transcript }) => {
3113
+ var _a, _b, _c, _d, _e;
3114
+ try {
3115
+ const getGeminiFeedback = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "callGetFeedback");
3116
+ const getProficiencyEstimate = (_d = (_c = api).httpsCallable) == null ? void 0 : _d.call(_c, "getProficiencyEstimate");
3117
+ const card = getCardFromCache({
3118
+ cardId,
3119
+ queryClient
3120
+ });
3121
+ let feedbackData;
3122
+ let proficiencyData = {};
3123
+ if (card && card.grading_method === "manual") {
3124
+ } else if (card && card.grading_method !== "standards_based") {
3125
+ const [geminiResult, proficiencyResult] = await Promise.all([
3126
+ getGeminiFeedback == null ? void 0 : getGeminiFeedback({
3127
+ cardId,
3128
+ studentId: currentUserId,
3129
+ studentResponse: transcript
3130
+ }),
3131
+ getProficiencyEstimate == null ? void 0 : getProficiencyEstimate({
3132
+ cardId,
3133
+ studentId: currentUserId,
3134
+ studentResponse: transcript
3135
+ })
3136
+ ]);
3137
+ proficiencyData = (proficiencyResult == null ? void 0 : proficiencyResult.data) || {};
3138
+ feedbackData = {
3139
+ ...(_e = geminiResult == null ? void 0 : geminiResult.data) != null ? _e : {},
3140
+ // @ts-ignore
3141
+ proficiency_level: (proficiencyData == null ? void 0 : proficiencyData.proficiency_level) || null
3142
+ };
3143
+ } else {
3144
+ const geminiResult = await (getGeminiFeedback == null ? void 0 : getGeminiFeedback({
3145
+ cardId,
3146
+ studentId: currentUserId,
3147
+ studentResponse: transcript
3148
+ }));
3149
+ feedbackData = geminiResult == null ? void 0 : geminiResult.data;
3150
+ }
3151
+ const results = {
3152
+ ...feedbackData,
3153
+ // ...proficiencyData,
3154
+ aiSuccess: true,
3155
+ promptSuccess: (feedbackData == null ? void 0 : feedbackData.success) || false,
3156
+ transcript
3157
+ };
3158
+ return results;
3159
+ } catch (error) {
3160
+ onCompletionError({
3161
+ type: "AI_FEEDBACK",
3162
+ message: (error == null ? void 0 : error.message) || "Error getting ai feedback"
3163
+ });
3164
+ throw new Error(error);
3165
+ }
3166
+ };
3167
+ return {
3168
+ submitAudioResponse,
3169
+ uploadAudioAndGetTranscript,
3170
+ getTranscript,
3171
+ getFreeResponseCompletion,
3172
+ getFeedback
3173
+ };
3174
+ };
3175
+
3176
+ // src/lib/create-firebase-client-native.ts
3177
+ import {
3178
+ getDoc,
3179
+ getDocs,
3180
+ addDoc,
3181
+ setDoc,
3182
+ updateDoc,
3183
+ deleteDoc,
3184
+ runTransaction,
3185
+ writeBatch,
3186
+ doc,
3187
+ collection,
3188
+ query,
3189
+ serverTimestamp,
3190
+ orderBy,
3191
+ limit,
3192
+ startAt,
3193
+ startAfter,
3194
+ endAt,
3195
+ endBefore,
3196
+ where,
3197
+ increment
3198
+ } from "@react-native-firebase/firestore";
3199
+
3200
+ // src/lib/create-firebase-client.ts
3201
+ function createFsClientBase({
3202
+ db,
3203
+ helpers,
3204
+ httpsCallable,
3205
+ logEvent
3206
+ }) {
3207
+ const dbAsFirestore = db;
3208
+ api.initialize({
3209
+ db: dbAsFirestore,
3210
+ helpers,
3211
+ httpsCallable,
3212
+ logEvent
3213
+ });
3214
+ return {
3215
+ assignmentRepo: createAssignmentRepo(),
3216
+ cardRepo: createCardRepo()
3217
+ };
3218
+ }
3219
+
3220
+ // src/lib/create-firebase-client-native.ts
3221
+ var createFsClientNative = ({ db, httpsCallable, logEvent }) => {
3222
+ return createFsClientBase({
3223
+ db,
3224
+ httpsCallable,
3225
+ logEvent,
3226
+ helpers: {
3227
+ getDoc,
3228
+ getDocs,
3229
+ addDoc,
3230
+ setDoc,
3231
+ updateDoc,
3232
+ deleteDoc,
3233
+ runTransaction,
3234
+ writeBatch,
3235
+ doc,
3236
+ collection,
3237
+ query,
3238
+ serverTimestamp,
3239
+ orderBy,
3240
+ limit,
3241
+ startAt,
3242
+ startAfter,
3243
+ endAt,
3244
+ endBefore,
3245
+ where,
3246
+ increment
3247
+ }
3248
+ });
3249
+ };
3250
+ export {
3251
+ ActivityPageType,
3252
+ BASE_MULTIPLE_CHOICE_FIELD_VALUES,
3253
+ BASE_REPEAT_FIELD_VALUES,
3254
+ BASE_RESPOND_FIELD_VALUES,
3255
+ FeedbackTypesCard,
3256
+ FsCtx,
3257
+ LENIENCY_OPTIONS,
3258
+ LeniencyCard,
3259
+ MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES,
3260
+ REPEAT_PAGE_ACTIVITY_TYPES,
3261
+ RESPOND_AUDIO_PAGE_ACTIVITY_TYPES,
3262
+ RESPOND_PAGE_ACTIVITY_TYPES,
3263
+ RESPOND_WRITE_PAGE_ACTIVITY_TYPES,
3264
+ SPEAKABLE_NOTIFICATIONS,
3265
+ STUDENT_LEVELS_OPTIONS,
3266
+ SpeakableNotificationTypes,
3267
+ SpeakableProvider,
3268
+ VerificationCardStatus,
3269
+ assignmentQueryKeys,
3270
+ cardsQueryKeys,
3271
+ checkIsMCPage,
3272
+ checkIsMediaPage,
3273
+ checkIsRepeatPage,
3274
+ checkIsRespondAudioPage,
3275
+ checkIsRespondPage,
3276
+ checkIsRespondWrittenPage,
3277
+ checkIsShortAnswerPage,
3278
+ checkTypePageActivity,
3279
+ cleanString,
3280
+ createAssignmentRepo,
3281
+ createCardRepo,
3282
+ createFsClientNative as createFsClient,
3283
+ createSetRepo,
3284
+ creditQueryKeys,
3285
+ debounce,
3286
+ getCardFromCache,
3287
+ getLabelPage,
3288
+ getPagePrompt,
3289
+ getPhraseLength,
3290
+ getRespondCardTool,
3291
+ getSetFromCache,
3292
+ getTotalCompletedCards,
3293
+ getWordHash,
3294
+ purify,
3295
+ refsCardsFiresotre,
3296
+ refsSetsFirestore,
3297
+ scoreQueryKeys,
3298
+ setsQueryKeys,
3299
+ updateCardInCache,
3300
+ updateSetInCache,
3301
+ useActivity,
3302
+ useActivityFeedbackAccess,
3303
+ useAssignment,
3304
+ useBaseOpenAI,
3305
+ useCards,
3306
+ useClearScore,
3307
+ useCreateCard,
3308
+ useCreateCards,
3309
+ useCreateNotification,
3310
+ useGetCard,
3311
+ useOrganizationAccess,
3312
+ useScore,
3313
+ useSet,
3314
+ useSpeakableApi,
3315
+ useSubmitAssignmentScore,
3316
+ useSubmitPracticeScore,
3317
+ useUpdateCardScore,
3318
+ useUpdateScore,
3319
+ useUpdateStudentVocab,
3320
+ useUserCredits
3321
+ };
3322
+ //# sourceMappingURL=index.native.mjs.map