@instructure/platform-notebook 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,102 +1,112 @@
1
- import { z as i } from "zod";
2
- import le from "diff-match-patch";
3
- import { useQueryClient as j, useMutation as P, useQuery as ce } from "@tanstack/react-query";
4
- import { jsx as _ } from "react/jsx-runtime";
5
- import { createContext as G, useContext as Y, useReducer as ue, useMemo as de } from "react";
6
- const fe = i.object({
7
- startContainer: i.string(),
8
- endContainer: i.string(),
9
- startOffset: i.number(),
10
- endOffset: i.number()
11
- }), ge = i.object({
12
- start: i.number(),
13
- end: i.number()
14
- }), q = i.object({
15
- selectedText: i.string(),
16
- hasNoHighlightAnymore: i.boolean().optional(),
17
- textPosition: ge.nullable(),
18
- range: fe.nullable(),
19
- pageLastModifiedAt: i.string()
1
+ import { jsx as a, jsxs as C } from "react/jsx-runtime";
2
+ import { Flex as x } from "@instructure/ui-flex";
3
+ import { IconWarningLine as De, IconQuestionLine as ee, IconPinLine as te, IconArrowOpenDownLine as Ae, IconEditLine as ue, IconTrashLine as fe } from "@instructure/ui-icons";
4
+ import { TruncateText as J } from "@instructure/ui-truncate-text";
5
+ import { z as l } from "zod";
6
+ import Le from "diff-match-patch";
7
+ import { createContext as ye, useContext as Ce, useMemo as Ee, useReducer as Me, useState as j, useRef as K, useCallback as Pe, useEffect as Fe } from "react";
8
+ import { useQueryClient as ne, useMutation as oe, useQuery as Be } from "@tanstack/react-query";
9
+ import { ScreenReaderContent as He } from "@instructure/ui-a11y-content";
10
+ import { Button as q, IconButton as Z } from "@instructure/ui-buttons";
11
+ import { Text as P } from "@instructure/ui-text";
12
+ import { TextArea as _e } from "@instructure/ui-text-area";
13
+ import { View as je } from "@instructure/ui-view";
14
+ import { Menu as F } from "@instructure/ui-menu";
15
+ import { Pill as me } from "@instructure/ui-pill";
16
+ const Ue = l.object({
17
+ startContainer: l.string(),
18
+ endContainer: l.string(),
19
+ startOffset: l.number(),
20
+ endOffset: l.number()
21
+ }), We = l.object({
22
+ start: l.number(),
23
+ end: l.number()
24
+ }), re = l.object({
25
+ selectedText: l.string(),
26
+ hasNoHighlightAnymore: l.boolean().optional(),
27
+ textPosition: We.nullable(),
28
+ range: Ue.nullable(),
29
+ pageLastModifiedAt: l.string()
20
30
  });
21
- var I = /* @__PURE__ */ ((n) => (n.IMPORTANT = "Important", n.CONFUSING = "Confusing", n))(I || {});
22
- const M = i.enum([
31
+ var b = /* @__PURE__ */ ((n) => (n.IMPORTANT = "Important", n.CONFUSING = "Confusing", n))(b || {});
32
+ const se = l.enum([
23
33
  "Important",
24
34
  "Confusing"
25
35
  /* CONFUSING */
26
- ]), z = i.object({
27
- startCursor: i.string().nullish(),
28
- endCursor: i.string().nullish(),
29
- hasNextPage: i.boolean().nullish(),
30
- hasPreviousPage: i.boolean().nullish()
31
- }), L = i.object({
32
- id: i.string(),
33
- rootAccountUuid: i.string(),
34
- userId: i.string(),
35
- courseId: i.string(),
36
- objectId: i.string(),
37
- objectType: i.string(),
38
- userText: i.string().optional(),
39
- reaction: i.array(M),
40
- highlightData: q,
41
- createdAt: i.string(),
42
- updatedAt: i.string()
43
- }), he = i.object({
44
- cursor: i.string(),
45
- node: L
36
+ ]), Se = l.object({
37
+ startCursor: l.string().nullish(),
38
+ endCursor: l.string().nullish(),
39
+ hasNextPage: l.boolean().nullish(),
40
+ hasPreviousPage: l.boolean().nullish()
41
+ }), X = l.object({
42
+ id: l.string(),
43
+ rootAccountUuid: l.string(),
44
+ userId: l.string(),
45
+ courseId: l.string(),
46
+ objectId: l.string(),
47
+ objectType: l.string(),
48
+ userText: l.string().optional(),
49
+ reaction: l.array(se),
50
+ highlightData: re,
51
+ createdAt: l.string(),
52
+ updatedAt: l.string()
53
+ }), qe = l.object({
54
+ cursor: l.string(),
55
+ node: X
46
56
  });
47
- i.object({
48
- notes: i.object({
49
- edges: i.array(he),
50
- nodes: i.array(L),
51
- pageInfo: z
57
+ l.object({
58
+ notes: l.object({
59
+ edges: l.array(qe),
60
+ nodes: l.array(X),
61
+ pageInfo: Se
52
62
  })
53
63
  });
54
- const me = i.object({
55
- type: i.string(),
56
- id: i.string()
57
- }), Ne = i.object({
58
- courseId: i.string().optional(),
59
- learningObject: me.optional(),
60
- reactions: i.array(i.string()).optional()
64
+ const ze = l.object({
65
+ type: l.string(),
66
+ id: l.string()
67
+ }), $e = l.object({
68
+ courseId: l.string().optional(),
69
+ learningObject: ze.optional(),
70
+ reactions: l.array(l.string()).optional()
61
71
  }).optional();
62
- i.object({
63
- courseId: i.string().optional(),
64
- filter: Ne,
65
- pageParams: z.optional(),
66
- direction: i.enum(["next", "prev"]).optional(),
67
- pageSize: i.number().optional()
72
+ l.object({
73
+ courseId: l.string().optional(),
74
+ filter: $e,
75
+ pageParams: Se.optional(),
76
+ direction: l.enum(["next", "prev"]).optional(),
77
+ pageSize: l.number().optional()
68
78
  });
69
- i.object({
70
- courseId: i.string(),
71
- objectId: i.string(),
72
- objectType: i.string(),
73
- userText: i.string().optional(),
74
- reaction: i.array(M),
75
- highlightData: q
79
+ l.object({
80
+ courseId: l.string(),
81
+ objectId: l.string(),
82
+ objectType: l.string(),
83
+ userText: l.string().optional(),
84
+ reaction: l.array(se),
85
+ highlightData: re
76
86
  });
77
- i.object({
78
- createNote: L
87
+ l.object({
88
+ createNote: X
79
89
  });
80
- i.object({
81
- id: i.string(),
82
- userText: i.string().optional(),
83
- reaction: i.array(M),
84
- highlightData: q
90
+ l.object({
91
+ id: l.string(),
92
+ userText: l.string().optional(),
93
+ reaction: l.array(se),
94
+ highlightData: re
85
95
  });
86
- i.object({
87
- updateNote: L
96
+ l.object({
97
+ updateNote: X
88
98
  });
89
- i.object({
90
- deleteNote: i.string()
99
+ l.object({
100
+ deleteNote: l.string()
91
101
  });
92
- var Z = /* @__PURE__ */ ((n) => (n[n.FORWARDS = 1] = "FORWARDS", n[n.BACKWARDS = 2] = "BACKWARDS", n))(Z || {});
93
- class S {
102
+ var Te = /* @__PURE__ */ ((n) => (n[n.FORWARDS = 1] = "FORWARDS", n[n.BACKWARDS = 2] = "BACKWARDS", n))(Te || {});
103
+ class R {
94
104
  constructor(e, t) {
95
105
  this.start = e, this.end = t;
96
106
  }
97
107
  toRange() {
98
108
  let e, t;
99
- if (this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = ee(this.start.element, this.start.offset, this.end.offset) : (e = this.start.resolve({
109
+ if (this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = Oe(this.start.element, this.start.offset, this.end.offset) : (e = this.start.resolve({
100
110
  direction: 1
101
111
  /* FORWARDS */
102
112
  }), t = this.end.resolve({
@@ -108,28 +118,28 @@ class S {
108
118
  return o.setStart(e.node, e.offset), o.setEnd(t.node, t.offset), o;
109
119
  }
110
120
  static fromRange(e) {
111
- const t = E.fromPoint(e.startContainer, e.startOffset), o = E.fromPoint(e.endContainer, e.endOffset);
112
- return !t || !o ? null : new S(t, o);
121
+ const t = O.fromPoint(e.startContainer, e.startOffset), o = O.fromPoint(e.endContainer, e.endOffset);
122
+ return !t || !o ? null : new R(t, o);
113
123
  }
114
124
  static fromOffsets(e, t, o) {
115
- return new S(new E(e, t), new E(e, o));
125
+ return new R(new O(e, t), new O(e, o));
116
126
  }
117
127
  relativeTo(e) {
118
- return new S(this.start.relativeTo(e), this.end.relativeTo(e));
128
+ return new R(this.start.relativeTo(e), this.end.relativeTo(e));
119
129
  }
120
130
  }
121
- class E {
131
+ class O {
122
132
  constructor(e, t) {
123
133
  t < 0 && console.error("Offset is invalid"), this.element = e, this.offset = t;
124
134
  }
125
135
  resolve(e = {}) {
126
136
  try {
127
- return ee(this.element, this.offset)[0];
137
+ return Oe(this.element, this.offset)[0];
128
138
  } catch (t) {
129
139
  if (this.offset === 0 && e.direction !== void 0) {
130
140
  const o = document.createTreeWalker(this.element.getRootNode(), NodeFilter.SHOW_TEXT);
131
141
  o.currentNode = this.element;
132
- const r = e.direction === Z.FORWARDS, s = r ? o.nextNode() : o.previousNode();
142
+ const r = e.direction === Te.FORWARDS, s = r ? o.nextNode() : o.previousNode();
133
143
  if (!s)
134
144
  throw t;
135
145
  return { node: s, offset: r ? 0 : s.data.length };
@@ -140,9 +150,9 @@ class E {
140
150
  static fromCharOffset(e, t) {
141
151
  switch (e.nodeType) {
142
152
  case Node.TEXT_NODE:
143
- return E.fromPoint(e, t);
153
+ return O.fromPoint(e, t);
144
154
  case Node.ELEMENT_NODE:
145
- return new E(e, t);
155
+ return new O(e, t);
146
156
  default:
147
157
  return console.error("Node is not an element or text node"), null;
148
158
  }
@@ -154,16 +164,16 @@ class E {
154
164
  return console.error("Text node offset is out of range"), null;
155
165
  if (!e.parentElement)
156
166
  return console.error("Text node has no parent"), null;
157
- const o = V(e) + t;
158
- return new E(e.parentElement, o);
167
+ const o = pe(e) + t;
168
+ return new O(e.parentElement, o);
159
169
  }
160
170
  case Node.ELEMENT_NODE: {
161
171
  if (t < 0 || t > e.childNodes.length)
162
172
  return console.error("Child node offset is out of range"), null;
163
173
  let o = 0;
164
174
  for (let r = 0; r < t; r++)
165
- o += J(e.childNodes[r]);
166
- return new E(e, o);
175
+ o += Ie(e.childNodes[r]);
176
+ return new O(e, o);
167
177
  }
168
178
  default:
169
179
  return console.error("Point is not in an element or text node"), null;
@@ -174,99 +184,99 @@ class E {
174
184
  throw new Error("Parent is not an ancestor of current element");
175
185
  let t = this.element, o = this.offset;
176
186
  for (; t !== e; )
177
- o += V(t), t.parentElement && (t = t.parentElement);
178
- return new E(t, o);
187
+ o += pe(t), t.parentElement && (t = t.parentElement);
188
+ return new O(t, o);
179
189
  }
180
190
  }
181
- const pe = (n) => {
191
+ const Ke = (n) => {
182
192
  const e = n.nodeName.toLowerCase();
183
193
  return e === "#text" ? "text()" : e;
184
194
  };
185
- function ye(n) {
195
+ function Ge(n) {
186
196
  let e = 0, t = n;
187
197
  for (; t; )
188
198
  t.nodeName === n.nodeName && (e += 1), t = t.previousSibling;
189
199
  return e;
190
200
  }
191
- const Ee = (n) => {
192
- const e = pe(n), t = ye(n);
201
+ const Xe = (n) => {
202
+ const e = Ke(n), t = Ge(n);
193
203
  return `${e}[${t}]`;
194
- }, K = (n, e) => {
204
+ }, ge = (n, e) => {
195
205
  let t = "", o = n;
196
206
  for (; o !== e; ) {
197
207
  if (!o) {
198
208
  console.error("Node is not a descendant of root");
199
209
  return;
200
210
  }
201
- t = `${Ee(o)}/${t}`, o = o.parentNode;
211
+ t = `${Xe(o)}/${t}`, o = o.parentNode;
202
212
  }
203
213
  return t = `/${t}`, t = t.replace(/\/$/, ""), t;
204
- }, Se = (n, e, t) => {
214
+ }, Qe = (n, e, t) => {
205
215
  const o = e.toUpperCase();
206
216
  let r = -1;
207
217
  for (let s = 0; s < n.children.length; s++) {
208
- const a = n.children[s];
209
- if (a.nodeName.toUpperCase() === o && (++r, r === t))
210
- return a;
218
+ const i = n.children[s];
219
+ if (i.nodeName.toUpperCase() === o && (++r, r === t))
220
+ return i;
211
221
  }
212
222
  return null;
213
- }, be = (n, e) => {
223
+ }, Ye = (n, e) => {
214
224
  if (!(n.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+])?)+$/) !== null))
215
225
  return console.error("Expression is not a simple XPath"), null;
216
226
  const o = n.split("/");
217
227
  let r = e;
218
228
  o.shift();
219
229
  for (const s of o) {
220
- let a, c;
221
- const u = s.indexOf("[");
222
- if (u !== -1) {
223
- a = s.slice(0, u);
224
- const h = s.slice(u + 1, s.indexOf("]"));
225
- if (c = Number.parseInt(h, 10) - 1, c < 0)
230
+ let i, d;
231
+ const f = s.indexOf("[");
232
+ if (f !== -1) {
233
+ i = s.slice(0, f);
234
+ const g = s.slice(f + 1, s.indexOf("]"));
235
+ if (d = Number.parseInt(g, 10) - 1, d < 0)
226
236
  return null;
227
237
  } else
228
- a = s, c = 0;
229
- const d = Se(r, a, c);
230
- if (!d)
238
+ i = s, d = 0;
239
+ const c = Qe(r, i, d);
240
+ if (!c)
231
241
  return null;
232
- r = d;
242
+ r = c;
233
243
  }
234
244
  return r;
235
- }, Q = (n, e = document.body) => {
245
+ }, he = (n, e = document.body) => {
236
246
  try {
237
- return be(n, e);
247
+ return Ye(n, e);
238
248
  } catch {
239
249
  return document.evaluate(`.${n}`, e, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
240
250
  }
241
251
  };
242
- class A {
252
+ class G {
243
253
  constructor(e, t) {
244
254
  this.root = e, this.range = t;
245
255
  }
246
256
  static fromRange(e, t) {
247
- return new A(e, t);
257
+ return new G(e, t);
248
258
  }
249
259
  static fromSelector(e, t) {
250
260
  if (!(t != null && t.startContainer) || !(t != null && t.endContainer))
251
261
  return console.error("No start or end container in selector"), null;
252
- const o = Q(t.startContainer, e);
262
+ const o = he(t.startContainer, e);
253
263
  if (!o)
254
264
  return console.error("Failed to resolve startContainer XPath"), null;
255
- const r = Q(t.endContainer, e);
265
+ const r = he(t.endContainer, e);
256
266
  if (!r)
257
267
  return console.error("Failed to resolve endContainer XPath"), null;
258
- const s = E.fromCharOffset(o, t.startOffset), a = E.fromCharOffset(r, t.endOffset);
259
- if (!s || !a)
268
+ const s = O.fromCharOffset(o, t.startOffset), i = O.fromCharOffset(r, t.endOffset);
269
+ if (!s || !i)
260
270
  return null;
261
- const c = new S(s, a).toRange();
262
- return c ? new A(e, c) : null;
271
+ const d = new R(s, i).toRange();
272
+ return d ? new G(e, d) : null;
263
273
  }
264
274
  toRange() {
265
275
  return this.range;
266
276
  }
267
277
  toSelector() {
268
278
  var s;
269
- const e = (s = S.fromRange(this.range)) == null ? void 0 : s.toRange(), t = e && S.fromRange(e), o = t && K(t.start.element, this.root), r = t && K(t.end.element, this.root);
279
+ const e = (s = R.fromRange(this.range)) == null ? void 0 : s.toRange(), t = e && R.fromRange(e), o = t && ge(t.start.element, this.root), r = t && ge(t.end.element, this.root);
270
280
  return !o || !r ? null : {
271
281
  startContainer: o,
272
282
  startOffset: t.start.offset,
@@ -275,17 +285,17 @@ class A {
275
285
  };
276
286
  }
277
287
  }
278
- class v {
288
+ class H {
279
289
  constructor(e, t, o) {
280
290
  this.root = e, this.start = t, this.end = o;
281
291
  }
282
292
  static fromRange(e, t) {
283
293
  var r;
284
- const o = (r = S.fromRange(t)) == null ? void 0 : r.relativeTo(e);
285
- return o ? new v(e, o.start.offset, o.end.offset) : null;
294
+ const o = (r = R.fromRange(t)) == null ? void 0 : r.relativeTo(e);
295
+ return o ? new H(e, o.start.offset, o.end.offset) : null;
286
296
  }
287
297
  static fromSelector(e, t) {
288
- return new v(e, t.start, t.end);
298
+ return new H(e, t.start, t.end);
289
299
  }
290
300
  toSelector() {
291
301
  return {
@@ -294,10 +304,10 @@ class v {
294
304
  };
295
305
  }
296
306
  toRange() {
297
- return S.fromOffsets(this.root, this.start, this.end).toRange();
307
+ return R.fromOffsets(this.root, this.start, this.end).toRange();
298
308
  }
299
309
  }
300
- const J = (n) => {
310
+ const Ie = (n) => {
301
311
  var e;
302
312
  switch (n.nodeType) {
303
313
  case Node.ELEMENT_NODE:
@@ -306,70 +316,70 @@ const J = (n) => {
306
316
  default:
307
317
  return 0;
308
318
  }
309
- }, V = (n) => {
319
+ }, pe = (n) => {
310
320
  let e = n.previousSibling, t = 0;
311
321
  for (; e; )
312
- t += J(e), e = e.previousSibling;
322
+ t += Ie(e), e = e.previousSibling;
313
323
  return t;
314
- }, ee = (n, ...e) => {
324
+ }, Oe = (n, ...e) => {
315
325
  let t = e.shift();
316
326
  const o = n.ownerDocument.createNodeIterator(n, NodeFilter.SHOW_TEXT), r = [];
317
- let s = o.nextNode(), a = null, c = 0;
327
+ let s = o.nextNode(), i = null, d = 0;
318
328
  for (; t !== void 0 && s; )
319
- a = s, c + a.data.length > t ? (r.push({ node: a, offset: t - c }), t = e.shift()) : (s = o.nextNode(), c += a.data.length);
320
- for (; t !== void 0 && a && c === t; )
321
- r.push({ node: a, offset: a.data.length }), t = e.shift();
329
+ i = s, d + i.data.length > t ? (r.push({ node: i, offset: t - d }), t = e.shift()) : (s = o.nextNode(), d += i.data.length);
330
+ for (; t !== void 0 && i && d === t; )
331
+ r.push({ node: i, offset: i.data.length }), t = e.shift();
322
332
  return t !== void 0 && console.error("Offset exceeds text length"), r;
323
- }, Te = (n, e, t, o) => {
333
+ }, Ve = (n, e, t, o) => {
324
334
  const r = t - e;
325
- return Math.abs(r - o) <= 5 ? v.fromSelector(n, {
335
+ return Math.abs(r - o) <= 5 ? H.fromSelector(n, {
326
336
  start: e,
327
337
  end: t
328
338
  }) : null;
329
- }, Ce = (n, e, t, o) => {
330
- const r = new le();
339
+ }, Ze = (n, e, t, o) => {
340
+ const r = new Le();
331
341
  r.Match_Distance = 5e3;
332
342
  const s = n.textContent;
333
343
  if (!s)
334
344
  return null;
335
345
  if (e.length > 32) {
336
- const a = e.slice(0, 32), c = e.slice(-32), u = o - t;
337
- let d = r.match_main(s, a, t);
338
- const h = r.match_main(s, c, o), f = h + c.length;
339
- if (d === -1 || h === -1)
346
+ const i = e.slice(0, 32), d = e.slice(-32), f = o - t;
347
+ let c = r.match_main(s, i, t);
348
+ const g = r.match_main(s, d, o), m = g + d.length;
349
+ if (c === -1 || g === -1)
340
350
  return null;
341
- const l = f - d, m = Math.abs(l - u);
342
- if ((d > f || m > 5) && (r.Match_Distance = e.length + 100, d = r.match_main(s, a, f), d !== -1 && d < f))
343
- return Te(n, d, f, u);
344
- if (d < f && m <= 5)
345
- return v.fromSelector(n, {
346
- start: d,
347
- end: f
351
+ const u = m - c, p = Math.abs(u - f);
352
+ if ((c > m || p > 5) && (r.Match_Distance = e.length + 100, c = r.match_main(s, i, m), c !== -1 && c < m))
353
+ return Ve(n, c, m, f);
354
+ if (c < m && p <= 5)
355
+ return H.fromSelector(n, {
356
+ start: c,
357
+ end: m
348
358
  });
349
359
  } else {
350
- const a = r.match_main(s, e, t);
351
- if (a !== -1)
352
- return v.fromSelector(n, {
353
- start: a,
354
- end: a + e.length
360
+ const i = r.match_main(s, e, t);
361
+ if (i !== -1)
362
+ return H.fromSelector(n, {
363
+ start: i,
364
+ end: i + e.length
355
365
  });
356
366
  }
357
367
  return null;
358
- }, ve = (n, e) => {
368
+ }, Je = (n, e) => {
359
369
  if (!e) return null;
360
370
  const { highlightData: t } = n, { textPosition: o, selectedText: r } = t;
361
- return Ce(
371
+ return Ze(
362
372
  e,
363
373
  r,
364
374
  (o == null ? void 0 : o.start) ?? 0,
365
375
  (o == null ? void 0 : o.end) ?? 0
366
376
  );
367
- }, ht = (n, e, t) => {
377
+ }, ln = (n, e, t) => {
368
378
  const o = [], r = [];
369
379
  for (const s of e) {
370
- const a = ve(s, n);
371
- if (a) {
372
- const c = a.toRange(), u = c && A.fromRange(n, c);
380
+ const i = Je(s, n);
381
+ if (i) {
382
+ const d = i.toRange(), f = d && G.fromRange(n, d);
373
383
  o.push({
374
384
  id: s.id,
375
385
  reaction: s.reaction,
@@ -377,8 +387,8 @@ const J = (n) => {
377
387
  highlightData: {
378
388
  ...s.highlightData,
379
389
  hasNoHighlightAnymore: !1,
380
- range: (u == null ? void 0 : u.toSelector()) ?? null,
381
- textPosition: a.toSelector(),
390
+ range: (f == null ? void 0 : f.toSelector()) ?? null,
391
+ textPosition: i.toSelector(),
382
392
  pageLastModifiedAt: t
383
393
  }
384
394
  });
@@ -395,54 +405,54 @@ const J = (n) => {
395
405
  }) : r.push(s.id);
396
406
  }
397
407
  return { notesForUpdate: o, noteIdsForDelete: r };
398
- }, mt = (n) => {
399
- const e = document.getElementById($(n));
408
+ }, an = (n) => {
409
+ const e = document.getElementById(le(n));
400
410
  if (e) {
401
411
  const t = e.getBoundingClientRect();
402
412
  t.top >= 0 && t.left >= 0 && t.bottom <= (window.innerHeight || document.documentElement.clientHeight) && t.right <= (window.innerWidth || document.documentElement.clientWidth) || e.scrollIntoView({ behavior: "smooth", block: "start" });
403
413
  }
404
- }, R = 90, k = 172, Nt = (n) => {
414
+ }, z = 90, $ = 172, cn = (n) => {
405
415
  const e = n.getClientRects();
406
416
  if (!e.length)
407
417
  return null;
408
- const t = e[0], o = e[e.length - 1], r = 4, s = 16, a = window.innerWidth || document.documentElement.clientWidth, c = window.innerHeight || document.documentElement.clientHeight, u = (N) => {
409
- const b = N + k;
410
- return N >= s && b <= a - s;
411
- }, d = (N) => {
412
- const b = N + R;
413
- return N >= s && b <= c - s;
418
+ const t = e[0], o = e[e.length - 1], r = 4, s = 16, i = window.innerWidth || document.documentElement.clientWidth, d = window.innerHeight || document.documentElement.clientHeight, f = (N) => {
419
+ const v = N + $;
420
+ return N >= s && v <= i - s;
421
+ }, c = (N) => {
422
+ const v = N + z;
423
+ return N >= s && v <= d - s;
414
424
  };
415
- let h;
416
- const f = t.right - k;
417
- if (u(f))
418
- h = f;
425
+ let g;
426
+ const m = t.right - $;
427
+ if (f(m))
428
+ g = m;
419
429
  else {
420
430
  const N = t.left;
421
- if (u(N))
422
- h = N;
431
+ if (f(N))
432
+ g = N;
423
433
  else {
424
- const T = (t.left + t.right) / 2 - k / 2;
425
- u(T) ? h = T : f < s ? h = s : h = a - k - s;
434
+ const I = (t.left + t.right) / 2 - $ / 2;
435
+ f(I) ? g = I : m < s ? g = s : g = i - $ - s;
426
436
  }
427
437
  }
428
- let l;
429
- const m = o.bottom + r;
430
- if (d(m))
431
- l = m;
438
+ let u;
439
+ const p = o.bottom + r;
440
+ if (c(p))
441
+ u = p;
432
442
  else {
433
- const N = t.top - R - r;
434
- d(N) ? l = N : m + R > c - s ? l = c - R - s : l = s;
443
+ const N = t.top - z - r;
444
+ c(N) ? u = N : p + z > d - s ? u = d - z - s : u = s;
435
445
  }
436
- return { top: l, left: h };
437
- }, pt = (n, e) => {
446
+ return { top: u, left: g };
447
+ }, dn = (n, e) => {
438
448
  for (const t of e)
439
449
  if (n.start < t.end && n.end > t.start)
440
450
  return !0;
441
451
  return !1;
442
- }, W = (n) => `highlight-wrapper-${n}`, $ = (n) => `${W(n)}-start`, te = (n) => `${W(n)}-end`, D = (n) => `[data-highlight-id="${CSS.escape(n)}"]`, ne = (n, e) => {
452
+ }, ie = (n) => `highlight-wrapper-${n}`, le = (n) => `${ie(n)}-start`, xe = (n) => `${ie(n)}-end`, U = (n) => `[data-highlight-id="${CSS.escape(n)}"]`, Q = (n, e) => {
443
453
  const t = Number.parseInt(n.slice(1, 3), 16), o = Number.parseInt(n.slice(3, 5), 16), r = Number.parseInt(n.slice(5, 7), 16);
444
454
  return `rgba(${t}, ${o}, ${r}, ${e})`;
445
- }, Oe = (n, e) => {
455
+ }, et = (n, e) => {
446
456
  var t;
447
457
  try {
448
458
  const o = ((t = e.nodeValue) == null ? void 0 : t.length) ?? e.childNodes.length;
@@ -450,7 +460,7 @@ const J = (n) => {
450
460
  } catch {
451
461
  return !1;
452
462
  }
453
- }, we = (n) => {
463
+ }, tt = (n) => {
454
464
  var s;
455
465
  if (n.collapsed)
456
466
  return [];
@@ -460,216 +470,249 @@ const J = (n) => {
460
470
  const t = [], o = (s = e == null ? void 0 : e.ownerDocument) == null ? void 0 : s.createNodeIterator(e, NodeFilter.SHOW_TEXT);
461
471
  let r = (o == null ? void 0 : o.nextNode()) || null;
462
472
  for (; r; ) {
463
- if (!Oe(n, r)) {
473
+ if (!et(n, r)) {
464
474
  r = (o == null ? void 0 : o.nextNode()) || null;
465
475
  continue;
466
476
  }
467
- const a = r;
468
- if (a === n.startContainer && n.startOffset > 0) {
469
- a.splitText(n.startOffset), r = (o == null ? void 0 : o.nextNode()) || null;
477
+ const i = r;
478
+ if (i === n.startContainer && n.startOffset > 0) {
479
+ i.splitText(n.startOffset), r = (o == null ? void 0 : o.nextNode()) || null;
470
480
  continue;
471
481
  }
472
- a === n.endContainer && n.endOffset < a.data.length && a.splitText(n.endOffset), t.push(a), r = (o == null ? void 0 : o.nextNode()) || null;
482
+ i === n.endContainer && n.endOffset < i.data.length && i.splitText(n.endOffset), t.push(i), r = (o == null ? void 0 : o.nextNode()) || null;
473
483
  }
474
484
  return t;
475
- }, yt = (n, e, t) => {
485
+ }, un = (n, e, t) => {
476
486
  if (n.collapsed) return;
477
- const o = e.id ?? "", r = W(o);
478
- if (document.getElementById($(o))) {
479
- Ie(e, t);
487
+ const o = e.id ?? "", r = ie(o);
488
+ if (document.getElementById(le(o))) {
489
+ nt(e, t);
480
490
  return;
481
491
  }
482
- const a = e.type === I.IMPORTANT ? t.colors.importantBackground : t.colors.confusingBackground, u = e.id === e.selectedNoteId ? a : ne(a, 0.5), d = e.type === I.IMPORTANT ? t.colors.importantUnderline : t.colors.confusingUnderline, h = e.type === I.IMPORTANT ? "solid" : "dashed", f = n.toString(), l = document.createElement("span");
483
- l.id = `${r}-start`, l.className = "highlight-marker-start", l.dataset.highlightId = o || "", l.setAttribute("role", "button"), l.setAttribute("tabindex", "0"), l.setAttribute("aria-label", f), l.style.position = "relative", l.style.fontSize = "0", l.style.lineHeight = "0", l.style.width = "0", l.style.height = "0", l.style.margin = "0", l.style.padding = "0", l.style.border = "0";
484
- const m = document.createElement("span");
485
- m.id = te(o), m.className = "highlight-marker-end", m.dataset.highlightId = o || "";
492
+ const i = e.type === b.IMPORTANT ? t.colors.importantBackground : t.colors.confusingBackground, f = e.id === e.selectedNoteId ? i : Q(i, 0.5), c = e.type === b.IMPORTANT ? t.colors.importantUnderline : t.colors.confusingUnderline, g = e.type === b.IMPORTANT ? "solid" : "dashed", m = n.toString(), u = document.createElement("span");
493
+ u.id = `${r}-start`, u.className = "highlight-marker-start", u.dataset.highlightId = o || "", u.setAttribute("role", "button"), u.setAttribute("tabindex", "0"), u.setAttribute("aria-label", m), u.style.position = "relative", u.style.fontSize = "0", u.style.lineHeight = "0", u.style.width = "0", u.style.height = "0", u.style.margin = "0", u.style.padding = "0", u.style.border = "0";
494
+ const p = document.createElement("span");
495
+ p.id = xe(o), p.className = "highlight-marker-end", p.dataset.highlightId = o || "";
486
496
  const N = n.cloneRange();
487
- N.collapse(!1), N.insertNode(m);
488
- const b = n.cloneRange();
489
- b.collapse(!0), b.insertNode(l);
490
- const T = document.createRange();
491
- T.setStartAfter(l), T.setEndBefore(m);
492
- const H = we(T).filter((g) => g.textContent && g.textContent.length > 0);
493
- H.forEach((g, y) => {
494
- var U;
495
- const O = g.parentElement;
496
- if ((O == null ? void 0 : O.dataset.highlightId) === o) return;
497
- const F = y === 0, x = y === H.length - 1, ie = H.length === 1;
498
- let w;
499
- ie ? w = "single" : F ? w = "first" : x ? w = "last" : w = "middle";
500
- const p = document.createElement("span");
501
- p.className = "highlight-content", p.dataset.highlightId = o || "", p.dataset.position = w, p.style.backgroundColor = u, p.style.textDecorationLine = "underline", p.style.textDecorationColor = d, p.style.textDecorationStyle = h, p.style.textDecorationThickness = t.borderWidthSmall, p.style.textUnderlineOffset = t.underlineOffset, p.style.cursor = "pointer", p.addEventListener("click", (ae) => {
502
- var X;
503
- ae.target.tagName !== "A" && ((X = e.onClick) == null || X.call(e));
504
- }), (U = g.parentNode) == null || U.insertBefore(p, g), p.appendChild(g);
505
- }), l.addEventListener("click", (g) => {
497
+ N.collapse(!1), N.insertNode(p);
498
+ const v = n.cloneRange();
499
+ v.collapse(!0), v.insertNode(u);
500
+ const I = document.createRange();
501
+ I.setStartAfter(u), I.setEndBefore(p);
502
+ const D = tt(I).filter((h) => h.textContent && h.textContent.length > 0);
503
+ D.forEach((h, y) => {
504
+ var W;
505
+ const w = h.parentElement;
506
+ if ((w == null ? void 0 : w.dataset.highlightId) === o) return;
507
+ const A = y === 0, L = y === D.length - 1, V = D.length === 1;
508
+ let k;
509
+ V ? k = "single" : A ? k = "first" : L ? k = "last" : k = "middle";
510
+ const S = document.createElement("span");
511
+ S.className = "highlight-content", S.dataset.highlightId = o || "", S.dataset.position = k, S.style.backgroundColor = f, S.style.textDecorationLine = "underline", S.style.textDecorationColor = c, S.style.textDecorationStyle = g, S.style.textDecorationThickness = t.borderWidthSmall, S.style.textUnderlineOffset = t.underlineOffset, S.style.cursor = "pointer", S.addEventListener("click", (M) => {
512
+ var _;
513
+ M.target.tagName !== "A" && ((_ = e.onClick) == null || _.call(e));
514
+ }), (W = h.parentNode) == null || W.insertBefore(S, h), S.appendChild(h);
515
+ }), u.addEventListener("click", (h) => {
506
516
  var y;
507
- g.target.tagName !== "A" && ((y = e.onClick) == null || y.call(e));
508
- }), l.addEventListener("keydown", (g) => {
517
+ h.target.tagName !== "A" && ((y = e.onClick) == null || y.call(e));
518
+ }), u.addEventListener("keydown", (h) => {
509
519
  var y;
510
- if (g.key === "Enter" || g.key === " ")
511
- g.preventDefault(), (y = e.onClick) == null || y.call(e);
512
- else if (g.key === "Tab" && !g.shiftKey) {
513
- const O = document.querySelectorAll(D(o));
514
- for (const F of O) {
515
- const x = F.querySelector("a");
516
- if (x) {
517
- g.preventDefault(), x.focus();
520
+ if (h.key === "Enter" || h.key === " ")
521
+ h.preventDefault(), (y = e.onClick) == null || y.call(e);
522
+ else if (h.key === "Tab" && !h.shiftKey) {
523
+ const w = document.querySelectorAll(U(o));
524
+ for (const A of w) {
525
+ const L = A.querySelector("a");
526
+ if (L) {
527
+ h.preventDefault(), L.focus();
518
528
  break;
519
529
  }
520
530
  }
521
531
  }
522
- }), l.addEventListener("focus", () => {
532
+ }), u.addEventListener("focus", () => {
523
533
  document.querySelectorAll(
524
- D(o)
534
+ U(o)
525
535
  ).forEach((y) => {
526
536
  y.classList.add("highlight-focused");
527
537
  });
528
- }), l.addEventListener("blur", () => {
538
+ }), u.addEventListener("blur", () => {
529
539
  document.querySelectorAll(
530
- D(o)
540
+ U(o)
531
541
  ).forEach((y) => {
532
542
  y.classList.remove("highlight-focused");
533
543
  });
534
544
  });
535
545
  };
536
- function Ie(n, e) {
537
- const t = n.type === I.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground, r = n.id === n.selectedNoteId ? t : ne(t, 0.5);
546
+ function nt(n, e) {
547
+ const t = n.type === b.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground, r = n.id === n.selectedNoteId ? t : Q(t, 0.5);
538
548
  document.querySelectorAll(
539
- D(n.id ?? "")
540
- ).forEach((a) => {
541
- a.style.backgroundColor = r;
549
+ U(n.id ?? "")
550
+ ).forEach((i) => {
551
+ i.style.backgroundColor = r;
542
552
  });
543
553
  }
544
- const Et = (n) => {
545
- const e = n.id ?? "", t = document.getElementById($(e)), o = document.getElementById(te(e));
554
+ const fn = (n) => {
555
+ const e = n.id ?? "", t = document.getElementById(le(e)), o = document.getElementById(xe(e));
546
556
  document.querySelectorAll(
547
- D(e)
557
+ U(e)
548
558
  ).forEach((s) => {
549
- var a;
559
+ var i;
550
560
  for (; s.firstChild; )
551
- (a = s.parentNode) == null || a.insertBefore(s.firstChild, s);
561
+ (i = s.parentNode) == null || i.insertBefore(s.firstChild, s);
552
562
  s.remove();
553
563
  }), t == null || t.remove(), o == null || o.remove();
554
- }, C = {
564
+ }, ot = "Notebook", rt = "Notes", st = "Important", it = "Unclear", lt = "Edit note", at = "Save", ct = "Cancel", dt = "Delete note", ut = "note", ft = "Add note (optional)", mt = "Remove from Notebook", gt = "Add a note (optional).", ht = "Mark important", pt = "Mark unclear", Nt = "Saved to Notebook.", bt = "Note updated", yt = "Note deleted", Ct = "Error saving to Notebook.", Et = "Error updating note", St = "Note deletion failed", Tt = "Loading notes", It = "Failed to load notes", Ot = "Start capturing your notes", xt = "Your notes from learning materials will appear here. Highlight key ideas, reflections, or questions as you learn—they'll all be saved in your Notebook for easy review later.", vt = "Nothing here yet", wt = "Adjust your filters or create a new note to get started.", kt = "You have no notes for the selected filter", Rt = "Previous page", Dt = "Next page", At = "All courses", Lt = "All notes", Mt = "Close Notebook panel", Pt = "To use the Notebook feature, highlight an excerpt from your learning material to flag it as 'confusing' or 'important' and leave an optional note.", Ft = "The content you highlighted is no longer available.", ae = {
565
+ notebook: ot,
566
+ notes: rt,
567
+ important: st,
568
+ unclear: it,
569
+ editNote: lt,
570
+ save: at,
571
+ cancel: ct,
572
+ deleteNote: dt,
573
+ note: ut,
574
+ addNotePrompt: ft,
575
+ removeFromNotebook: mt,
576
+ addNoteOptional: gt,
577
+ markImportant: ht,
578
+ markUnclear: pt,
579
+ savedToNotebook: Nt,
580
+ noteUpdated: bt,
581
+ noteDeleted: yt,
582
+ errorSavingNote: Ct,
583
+ errorUpdatingNote: Et,
584
+ noteDeletionFailed: St,
585
+ loadingNotes: Tt,
586
+ failedToLoadNotes: It,
587
+ emptyStateHeading: Ot,
588
+ emptyStateDescription: xt,
589
+ nothingHereYet: vt,
590
+ adjustFiltersOrCreate: wt,
591
+ noNotesForFilter: kt,
592
+ previousPage: Rt,
593
+ nextPage: Dt,
594
+ allCourses: At,
595
+ allNotes: Lt,
596
+ closeNotebookPanel: Mt,
597
+ featureDescription: Pt,
598
+ highlightUnavailable: Ft
599
+ }, ve = ye(null);
600
+ function we(n, e) {
601
+ const t = ae[n] ?? n;
602
+ return e ? t.replace(/%\{([^}]+)}/g, (o, r) => String(e[r] ?? `%{${r}}`)) : t;
603
+ }
604
+ function Bt({
605
+ translations: n,
606
+ translate: e,
607
+ children: t
608
+ }) {
609
+ const o = Ee(
610
+ () => ({
611
+ translations: { ...ae, ...n },
612
+ translate: e ?? we
613
+ }),
614
+ [n, e]
615
+ );
616
+ return /* @__PURE__ */ a(ve.Provider, { value: o, children: t });
617
+ }
618
+ function Y() {
619
+ const n = Ce(ve);
620
+ return n || { translations: ae, translate: we };
621
+ }
622
+ const Ht = (n, e) => ({
623
+ backgroundColor: n === b.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground,
624
+ underlineColor: n === b.IMPORTANT ? e.colors.importantUnderline : e.colors.confusingUnderline,
625
+ underlineStyle: n === b.IMPORTANT ? "solid" : "dashed"
626
+ }), Ne = ({
627
+ children: n,
628
+ type: e = b.IMPORTANT,
629
+ isCardActive: t = !0,
630
+ theme: o
631
+ }) => {
632
+ const r = Ht(e, o), i = {
633
+ position: "relative",
634
+ backgroundColor: t ? r.backgroundColor : Q(r.backgroundColor, 0.5),
635
+ textDecorationLine: "underline",
636
+ textDecorationStyle: r.underlineStyle,
637
+ textDecorationColor: r.underlineColor,
638
+ textDecorationThickness: o.borderWidthSmall,
639
+ textUnderlineOffset: o.underlineOffset,
640
+ lineHeight: "normal"
641
+ };
642
+ return /* @__PURE__ */ a("span", { "data-note-highlight": "true", style: i, children: n });
643
+ }, _t = () => {
644
+ const { translations: n } = Y();
645
+ return /* @__PURE__ */ C(x, { gap: "xx-small", alignItems: "start", as: "div", children: [
646
+ /* @__PURE__ */ a(x.Item, { as: "div", children: /* @__PURE__ */ a(De, { color: "error" }) }),
647
+ /* @__PURE__ */ a(x.Item, { padding: "xxx-small none", shouldShrink: !0, children: /* @__PURE__ */ a(J, { maxLines: 3, children: n.highlightUnavailable }) })
648
+ ] });
649
+ }, B = {
555
650
  all: ["notebook"],
556
651
  notes: (n) => ["notebook", "notes", n]
557
652
  };
558
- function St(n) {
559
- const e = j();
560
- return P({
653
+ function mn(n) {
654
+ const e = ne();
655
+ return oe({
561
656
  mutationFn: (t) => n.createNote(t),
562
657
  onSuccess: () => {
563
- e.invalidateQueries({ queryKey: C.all });
658
+ e.invalidateQueries({ queryKey: B.all });
564
659
  }
565
660
  });
566
661
  }
567
- function bt(n) {
568
- const e = j();
569
- return P({
662
+ function gn(n) {
663
+ const e = ne();
664
+ return oe({
570
665
  mutationFn: (t) => n.deleteNote(t),
571
666
  onSuccess: () => {
572
- e.invalidateQueries({ queryKey: C.all });
667
+ e.invalidateQueries({ queryKey: B.all });
573
668
  }
574
669
  });
575
670
  }
576
- function Tt({
671
+ function hn({
577
672
  api: n,
578
673
  enabled: e = !0,
579
674
  ...t
580
675
  }) {
581
- return ce({
582
- queryKey: C.notes(t),
676
+ return Be({
677
+ queryKey: B.notes(t),
583
678
  queryFn: () => n.getNotes(t),
584
679
  enabled: e
585
680
  });
586
681
  }
587
- function Ct(n) {
588
- const e = j();
589
- return P({
682
+ function pn(n) {
683
+ const e = ne();
684
+ return oe({
590
685
  mutationFn: ({ id: t, input: o }) => n.updateNote(t, o),
591
686
  onMutate: async ({ id: t, input: o }) => {
592
- await e.cancelQueries({ queryKey: C.all });
593
- const s = e.getQueryCache().findAll({ queryKey: C.all }), a = /* @__PURE__ */ new Map();
594
- for (const c of s) {
595
- const u = c.state.data;
596
- u && (a.set(c.queryKey, u), e.setQueryData(c.queryKey, {
597
- ...u,
598
- notes: u.notes.map(
599
- (d) => d.id === t ? { ...d, ...o, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } : d
687
+ await e.cancelQueries({ queryKey: B.all });
688
+ const s = e.getQueryCache().findAll({ queryKey: B.all }), i = /* @__PURE__ */ new Map();
689
+ for (const d of s) {
690
+ const f = d.state.data;
691
+ f && (i.set(d.queryKey, f), e.setQueryData(d.queryKey, {
692
+ ...f,
693
+ notes: f.notes.map(
694
+ (c) => c.id === t ? { ...c, ...o, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } : c
600
695
  )
601
696
  }));
602
697
  }
603
- return { previousData: a };
698
+ return { previousData: i };
604
699
  },
605
700
  onError: (t, o, r) => {
606
701
  if (r != null && r.previousData)
607
- for (const [s, a] of r.previousData)
608
- e.setQueryData(s, a);
702
+ for (const [s, i] of r.previousData)
703
+ e.setQueryData(s, i);
609
704
  },
610
705
  onSettled: () => {
611
- e.invalidateQueries({ queryKey: C.all });
706
+ e.invalidateQueries({ queryKey: B.all });
612
707
  }
613
708
  });
614
709
  }
615
- const De = "Notebook", xe = "Notes", Re = "Important", ke = "Unclear", Ae = "Edit note", Le = "Save", He = "Cancel", Fe = "Delete note", _e = "Remove from Notebook", je = "Add a note (optional).", Pe = "Mark important", qe = "Mark unclear", Me = "Saved to Notebook.", We = "Note updated", $e = "Note deleted", Be = "Error saving to Notebook.", Ue = "Error updating note", Xe = "Note deletion failed", Ke = "Loading notes", Qe = "Failed to load notes", Ve = "Start capturing your notes", Ge = "Your notes from learning materials will appear here. Highlight key ideas, reflections, or questions as you learn—they'll all be saved in your Notebook for easy review later.", Ye = "Nothing here yet", ze = "Adjust your filters or create a new note to get started.", Ze = "You have no notes for the selected filter", Je = "Previous page", et = "Next page", tt = "All courses", nt = "All notes", ot = "Close Notebook panel", rt = "To use the Notebook feature, highlight an excerpt from your learning material to flag it as 'confusing' or 'important' and leave an optional note.", B = {
616
- notebook: De,
617
- notes: xe,
618
- important: Re,
619
- unclear: ke,
620
- editNote: Ae,
621
- save: Le,
622
- cancel: He,
623
- deleteNote: Fe,
624
- removeFromNotebook: _e,
625
- addNoteOptional: je,
626
- markImportant: Pe,
627
- markUnclear: qe,
628
- savedToNotebook: Me,
629
- noteUpdated: We,
630
- noteDeleted: $e,
631
- errorSavingNote: Be,
632
- errorUpdatingNote: Ue,
633
- noteDeletionFailed: Xe,
634
- loadingNotes: Ke,
635
- failedToLoadNotes: Qe,
636
- emptyStateHeading: Ve,
637
- emptyStateDescription: Ge,
638
- nothingHereYet: Ye,
639
- adjustFiltersOrCreate: ze,
640
- noNotesForFilter: Ze,
641
- previousPage: Je,
642
- nextPage: et,
643
- allCourses: tt,
644
- allNotes: nt,
645
- closeNotebookPanel: ot,
646
- featureDescription: rt
647
- }, oe = G(null);
648
- function re(n, e) {
649
- const t = B[n] ?? n;
650
- return e ? t.replace(/%\{([^}]+)}/g, (o, r) => String(e[r] ?? `%{${r}}`)) : t;
651
- }
652
- function st({
653
- translations: n,
654
- translate: e,
655
- children: t
656
- }) {
657
- const r = {
658
- translations: { ...B, ...n },
659
- translate: e ?? re
660
- };
661
- return /* @__PURE__ */ _(oe.Provider, { value: r, children: t });
662
- }
663
- function vt() {
664
- const n = Y(oe);
665
- return n || { translations: B, translate: re };
666
- }
667
- const it = {
710
+ const jt = {
668
711
  selectedNoteId: null,
669
712
  isNoteEditing: !1,
670
713
  isTrayOpen: !1
671
714
  };
672
- function at(n, e) {
715
+ function Ut(n, e) {
673
716
  switch (e.type) {
674
717
  case "SELECT_NOTE":
675
718
  return {
@@ -689,20 +732,20 @@ function at(n, e) {
689
732
  return n;
690
733
  }
691
734
  }
692
- const se = G(null);
693
- function Ot({
735
+ const ke = ye(null);
736
+ function Nn({
694
737
  api: n,
695
738
  currentUserId: e,
696
739
  objectId: t,
697
740
  objectType: o,
698
741
  courseId: r,
699
742
  pageLastModifiedAt: s,
700
- onAnalyticsEvent: a,
701
- translations: c,
702
- translate: u,
703
- children: d
743
+ onAnalyticsEvent: i,
744
+ translations: d,
745
+ translate: f,
746
+ children: c
704
747
  }) {
705
- const [h, f] = ue(at, it), l = de(
748
+ const [g, m] = Me(Ut, jt), u = Ee(
706
749
  () => ({
707
750
  api: n,
708
751
  currentUserId: e,
@@ -710,13 +753,13 @@ function Ot({
710
753
  objectType: o,
711
754
  courseId: r,
712
755
  pageLastModifiedAt: s,
713
- onAnalyticsEvent: a,
714
- ...h,
715
- selectNote: (m, N = !1) => f({ type: "SELECT_NOTE", payload: { id: m, isEditing: N } }),
716
- clearSelectedNote: () => f({ type: "CLEAR_SELECTED_NOTE" }),
717
- setEditing: (m) => f({ type: "SET_EDITING", payload: m }),
718
- openTray: () => f({ type: "OPEN_TRAY" }),
719
- closeTray: () => f({ type: "CLOSE_TRAY" })
756
+ onAnalyticsEvent: i,
757
+ ...g,
758
+ selectNote: (p, N = !1) => m({ type: "SELECT_NOTE", payload: { id: p, isEditing: N } }),
759
+ clearSelectedNote: () => m({ type: "CLEAR_SELECTED_NOTE" }),
760
+ setEditing: (p) => m({ type: "SET_EDITING", payload: p }),
761
+ openTray: () => m({ type: "OPEN_TRAY" }),
762
+ closeTray: () => m({ type: "CLOSE_TRAY" })
720
763
  }),
721
764
  [
722
765
  n,
@@ -725,37 +768,329 @@ function Ot({
725
768
  o,
726
769
  r,
727
770
  s,
728
- a,
729
- h
771
+ i,
772
+ g
730
773
  ]
731
774
  );
732
- return /* @__PURE__ */ _(se.Provider, { value: l, children: /* @__PURE__ */ _(st, { translations: c, translate: u, children: d }) });
775
+ return /* @__PURE__ */ a(ke.Provider, { value: u, children: /* @__PURE__ */ a(Bt, { translations: d, translate: f, children: c }) });
733
776
  }
734
- function wt() {
735
- const n = Y(se);
777
+ function bn() {
778
+ const n = Ce(ke);
736
779
  if (!n)
737
780
  throw new Error("useNotebook must be used within a NotebookProvider");
738
781
  return n;
739
782
  }
783
+ const Wt = {
784
+ [b.IMPORTANT]: {
785
+ color: "info",
786
+ translationKey: "important",
787
+ icon: /* @__PURE__ */ a(te, { size: "x-small" })
788
+ },
789
+ [b.CONFUSING]: {
790
+ color: "danger",
791
+ translationKey: "unclear",
792
+ icon: /* @__PURE__ */ a(ee, { size: "x-small" })
793
+ }
794
+ }, qt = ({ type: n, onTypeChange: e, renderAsMenuTrigger: t = !1 }) => {
795
+ const { translations: o } = Y(), r = Wt[n], s = o[r.translationKey], [i, d] = j(!1), f = K(null), c = K(null), g = Pe(
796
+ (m) => {
797
+ e == null || e(m), d(!1);
798
+ },
799
+ [e]
800
+ );
801
+ return t && e ? /* @__PURE__ */ C(
802
+ F,
803
+ {
804
+ placement: "bottom start",
805
+ show: i,
806
+ onToggle: (m) => d(m),
807
+ shouldHideOnSelect: !0,
808
+ shouldFocusTriggerOnClose: !0,
809
+ trigger: /* @__PURE__ */ C(me, { color: r.color, renderIcon: r.icon, children: [
810
+ s,
811
+ " ",
812
+ /* @__PURE__ */ a(Ae, { size: "x-small" })
813
+ ] }),
814
+ children: [
815
+ /* @__PURE__ */ C(F.Item, { ref: f, onClick: () => g(b.CONFUSING), children: [
816
+ /* @__PURE__ */ a(ee, { size: "x-small" }),
817
+ ` ${o.markUnclear}`
818
+ ] }),
819
+ /* @__PURE__ */ C(F.Item, { ref: c, onClick: () => g(b.IMPORTANT), children: [
820
+ /* @__PURE__ */ a(te, { size: "x-small" }),
821
+ ` ${o.markImportant}`
822
+ ] })
823
+ ]
824
+ }
825
+ ) : /* @__PURE__ */ a(me, { color: r.color, renderIcon: r.icon, children: s });
826
+ };
827
+ function be(n, e) {
828
+ return (n instanceof Date ? n : new Date(n)).toLocaleString(e, {
829
+ year: "numeric",
830
+ month: "short",
831
+ day: "numeric"
832
+ });
833
+ }
834
+ const yn = ({
835
+ noteId: n,
836
+ date: e,
837
+ highlight: t,
838
+ note: o,
839
+ type: r,
840
+ onClick: s,
841
+ onDelete: i,
842
+ onSaveNote: d,
843
+ onTypeChange: f,
844
+ isActive: c,
845
+ isPanelView: g = !1,
846
+ courseName: m,
847
+ locale: u,
848
+ highlightTheme: p,
849
+ cardTheme: N,
850
+ renderLink: v,
851
+ href: I
852
+ }) => {
853
+ const { translations: T } = Y(), [D, h] = j(!1), [y, w] = j(!1), [A, L] = j(o || ""), [V, k] = j(!1), S = r === b.IMPORTANT ? T.important : T.unclear, W = (E) => {
854
+ E.key === "Enter" && (E.preventDefault(), s == null || s());
855
+ }, M = [S, T.note];
856
+ t && M.push(t), o && M.push(o), e && M.push(be(e, u)), m && M.push(m);
857
+ const _ = M.join(", "), ce = r === b.CONFUSING ? N.confusingBorderColor : N.importantBorderColor, Re = {
858
+ borderStyle: "solid",
859
+ borderColor: c || D ? ce : Q(ce, 0.5),
860
+ borderWidth: "0.0625rem 0.0625rem 0.25rem 0.25rem",
861
+ borderRadius: "1rem",
862
+ padding: "1rem",
863
+ cursor: y ? "default" : "pointer",
864
+ position: "relative"
865
+ }, de = (
866
+ // biome-ignore lint/a11y/noStaticElementInteractions: role is conditionally set to "button"
867
+ // biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-label applies when role="button"
868
+ /* @__PURE__ */ C(
869
+ "div",
870
+ {
871
+ role: I || y ? void 0 : "button",
872
+ "aria-label": I ? void 0 : _,
873
+ "aria-pressed": I || y ? void 0 : c,
874
+ tabIndex: I || c ? -1 : 0,
875
+ "data-testid": "note-card",
876
+ onClick: c ? void 0 : s,
877
+ onMouseEnter: () => h(!0),
878
+ onMouseLeave: () => h(!1),
879
+ onKeyDown: c ? void 0 : W,
880
+ style: Re,
881
+ children: [
882
+ /* @__PURE__ */ C(x, { direction: "column", gap: "small", children: [
883
+ /* @__PURE__ */ a(
884
+ qt,
885
+ {
886
+ type: r,
887
+ onTypeChange: g && f ? (E) => f(n, E) : void 0,
888
+ renderAsMenuTrigger: g && !!f && !!c
889
+ }
890
+ ),
891
+ t ? /* @__PURE__ */ a("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: /* @__PURE__ */ a(P, { children: c && g ? /* @__PURE__ */ a(
892
+ Ne,
893
+ {
894
+ type: r,
895
+ isCardActive: !!c || D,
896
+ theme: p,
897
+ children: t
898
+ }
899
+ ) : /* @__PURE__ */ a(J, { maxLines: 3, truncate: "word", children: /* @__PURE__ */ a(
900
+ Ne,
901
+ {
902
+ type: r,
903
+ isCardActive: !!c || D,
904
+ theme: p,
905
+ children: t
906
+ }
907
+ ) }) }) }) : /* @__PURE__ */ a(_t, {}),
908
+ /* @__PURE__ */ C(x, { direction: "column", gap: c ? "small" : "none", children: [
909
+ y && g ? /* @__PURE__ */ C(x, { direction: "column", gap: "x-small", children: [
910
+ /* @__PURE__ */ a(
911
+ _e,
912
+ {
913
+ label: /* @__PURE__ */ a(He, { children: T.editNote }),
914
+ value: A,
915
+ onChange: (E) => L(E.target.value),
916
+ placeholder: T.addNoteOptional
917
+ }
918
+ ),
919
+ /* @__PURE__ */ C(x, { gap: "xx-small", children: [
920
+ /* @__PURE__ */ a(x.Item, { shouldGrow: !0, children: /* @__PURE__ */ a(
921
+ q,
922
+ {
923
+ display: "block",
924
+ size: "small",
925
+ onClick: () => {
926
+ L(o || ""), w(!1);
927
+ },
928
+ children: T.cancel
929
+ }
930
+ ) }),
931
+ /* @__PURE__ */ a(x.Item, { shouldGrow: !0, children: /* @__PURE__ */ a(
932
+ q,
933
+ {
934
+ display: "block",
935
+ color: "primary",
936
+ size: "small",
937
+ onClick: () => {
938
+ d == null || d(n, A), w(!1);
939
+ },
940
+ interaction: A.trim() ? "enabled" : "disabled",
941
+ children: T.save
942
+ }
943
+ ) })
944
+ ] })
945
+ ] }) : o ? /* @__PURE__ */ a("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: c && g ? /* @__PURE__ */ C(P, { children: [
946
+ o,
947
+ " ",
948
+ /* @__PURE__ */ a(
949
+ Z,
950
+ {
951
+ size: "small",
952
+ withBackground: !1,
953
+ withBorder: !1,
954
+ screenReaderLabel: T.editNote,
955
+ onClick: (E) => {
956
+ E.stopPropagation(), w(!0);
957
+ },
958
+ children: /* @__PURE__ */ a(ue, {})
959
+ }
960
+ )
961
+ ] }) : /* @__PURE__ */ a(P, { children: /* @__PURE__ */ a(J, { maxLines: 3, truncate: "word", children: o }) }) }) : g && c ? /* @__PURE__ */ a("div", { children: /* @__PURE__ */ C(P, { color: "secondary", children: [
962
+ T.addNotePrompt,
963
+ " ",
964
+ /* @__PURE__ */ a(
965
+ Z,
966
+ {
967
+ size: "small",
968
+ withBackground: !1,
969
+ withBorder: !1,
970
+ screenReaderLabel: T.editNote,
971
+ onClick: (E) => {
972
+ E.stopPropagation(), w(!0);
973
+ },
974
+ children: /* @__PURE__ */ a(ue, {})
975
+ }
976
+ )
977
+ ] }) }) : null,
978
+ /* @__PURE__ */ C(x, { justifyItems: "space-between", alignItems: "center", children: [
979
+ /* @__PURE__ */ a(P, { size: "small", color: "secondary", children: be(e, u) }),
980
+ c && i && /* @__PURE__ */ a(
981
+ Z,
982
+ {
983
+ size: "small",
984
+ withBackground: !1,
985
+ withBorder: !1,
986
+ color: "danger",
987
+ screenReaderLabel: T.deleteNote,
988
+ onClick: (E) => {
989
+ E.stopPropagation(), k(!0);
990
+ },
991
+ children: /* @__PURE__ */ a(fe, {})
992
+ }
993
+ )
994
+ ] }),
995
+ m && /* @__PURE__ */ a(P, { size: "small", color: "secondary", children: m })
996
+ ] })
997
+ ] }),
998
+ V && i && /* @__PURE__ */ a(
999
+ je,
1000
+ {
1001
+ as: "div",
1002
+ background: "primary",
1003
+ padding: "medium",
1004
+ borderRadius: "large",
1005
+ position: "absolute",
1006
+ insetBlockStart: "0",
1007
+ insetBlockEnd: "0",
1008
+ insetInlineStart: "0",
1009
+ insetInlineEnd: "0",
1010
+ stacking: "above",
1011
+ children: /* @__PURE__ */ C(
1012
+ x,
1013
+ {
1014
+ direction: "column",
1015
+ justifyItems: "center",
1016
+ alignItems: "center",
1017
+ gap: "x-small",
1018
+ height: "100%",
1019
+ children: [
1020
+ /* @__PURE__ */ a(
1021
+ q,
1022
+ {
1023
+ display: "block",
1024
+ color: "danger",
1025
+ size: "small",
1026
+ renderIcon: /* @__PURE__ */ a(fe, {}),
1027
+ onClick: (E) => {
1028
+ E.stopPropagation(), i(n), k(!1);
1029
+ },
1030
+ children: T.deleteNote
1031
+ }
1032
+ ),
1033
+ /* @__PURE__ */ a(
1034
+ q,
1035
+ {
1036
+ display: "block",
1037
+ size: "small",
1038
+ onClick: (E) => {
1039
+ E.stopPropagation(), k(!1);
1040
+ },
1041
+ children: T.cancel
1042
+ }
1043
+ )
1044
+ ]
1045
+ }
1046
+ )
1047
+ }
1048
+ )
1049
+ ]
1050
+ }
1051
+ )
1052
+ );
1053
+ return I && v ? v({ href: I, children: de, ariaLabel: _ }) : de;
1054
+ }, Cn = ({ currentType: n, onSelectReaction: e }) => {
1055
+ const { translations: t } = Y(), o = K(null), r = K(null);
1056
+ return Fe(() => {
1057
+ n === b.CONFUSING && o.current ? o.current.focus() : n === b.IMPORTANT && r.current ? r.current.focus() : o.current && o.current.focus();
1058
+ }, [n]), /* @__PURE__ */ C(F, { children: [
1059
+ /* @__PURE__ */ C(F.Item, { ref: o, onClick: () => e(b.CONFUSING), children: [
1060
+ /* @__PURE__ */ a(ee, { size: "x-small" }),
1061
+ ` ${t.markUnclear}`
1062
+ ] }),
1063
+ /* @__PURE__ */ C(F.Item, { ref: r, onClick: () => e(b.IMPORTANT), children: [
1064
+ /* @__PURE__ */ a(te, { size: "x-small" }),
1065
+ ` ${t.markImportant}`
1066
+ ] })
1067
+ ] });
1068
+ };
740
1069
  export {
741
- Ot as NotebookProvider,
742
- I as REACTION_TYPE,
743
- A as RangeAnchor,
744
- E as TextPosition,
745
- v as TextPositionAnchor,
746
- S as TextRange,
747
- yt as addHighlight,
748
- Nt as getPlacement,
749
- pt as isOverlapping,
750
- Q as nodeFromXPath,
751
- ht as recoverHighlights,
752
- Et as removeHighlights,
753
- mt as scrollToHighlight,
754
- St as useCreateNote,
755
- bt as useDeleteNote,
756
- Tt as useGetNotes,
757
- wt as useNotebook,
758
- vt as useNotebookTranslations,
759
- Ct as useUpdateNote,
760
- K as xpathFromNode
1070
+ Ne as Highlight,
1071
+ _t as HighlightError,
1072
+ yn as NoteCard,
1073
+ qt as NoteChip,
1074
+ Cn as NoteReactionMenu,
1075
+ Nn as NotebookProvider,
1076
+ b as REACTION_TYPE,
1077
+ G as RangeAnchor,
1078
+ O as TextPosition,
1079
+ H as TextPositionAnchor,
1080
+ R as TextRange,
1081
+ un as addHighlight,
1082
+ Q as createTransparentColor,
1083
+ cn as getPlacement,
1084
+ dn as isOverlapping,
1085
+ he as nodeFromXPath,
1086
+ ln as recoverHighlights,
1087
+ fn as removeHighlights,
1088
+ an as scrollToHighlight,
1089
+ mn as useCreateNote,
1090
+ gn as useDeleteNote,
1091
+ hn as useGetNotes,
1092
+ bn as useNotebook,
1093
+ Y as useNotebookTranslations,
1094
+ pn as useUpdateNote,
1095
+ ge as xpathFromNode
761
1096
  };