@instructure/platform-notebook 0.2.0 → 0.4.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,116 @@
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 i, jsxs as N, Fragment as Ge } from "react/jsx-runtime";
2
+ import { createContext as De, useContext as Le, useMemo as me, useReducer as Ke, useRef as ne, useEffect as ee, useState as H, useCallback as Ae } from "react";
3
+ import { createPortal as Xe } from "react-dom";
4
+ import { z as a } from "zod";
5
+ import Qe from "diff-match-patch";
6
+ import { useQueryClient as ge, useMutation as he, useQuery as Ye } from "@tanstack/react-query";
7
+ import { IconQuestionLine as pe, IconPinLine as Ne, IconWarningLine as Ve, IconArrowOpenDownLine as Ze, IconEditLine as de, IconTrashLine as se, IconArrowOpenStartLine as Je, IconArrowOpenEndLine as et, IconArrowStartLine as tt } from "@instructure/ui-icons";
8
+ import { Menu as Z } from "@instructure/ui-menu";
9
+ import { Flex as v } from "@instructure/ui-flex";
10
+ import { TruncateText as ue } from "@instructure/ui-truncate-text";
11
+ import { CloseButton as nt, Button as W, IconButton as G } from "@instructure/ui-buttons";
12
+ import { Heading as ie } from "@instructure/ui-heading";
13
+ import { Tray as ot } from "@instructure/ui-tray";
14
+ import { View as K } from "@instructure/ui-view";
15
+ import { ScreenReaderContent as rt } from "@instructure/ui-a11y-content";
16
+ import { Text as U } from "@instructure/ui-text";
17
+ import { TextArea as Pe } from "@instructure/ui-text-area";
18
+ import { Pill as Ie } from "@instructure/ui-pill";
19
+ import { Spinner as st } from "@instructure/ui-spinner";
20
+ const it = a.object({
21
+ startContainer: a.string(),
22
+ endContainer: a.string(),
23
+ startOffset: a.number(),
24
+ endOffset: a.number()
25
+ }), lt = a.object({
26
+ start: a.number(),
27
+ end: a.number()
28
+ }), be = a.object({
29
+ selectedText: a.string(),
30
+ hasNoHighlightAnymore: a.boolean().optional(),
31
+ textPosition: lt.nullable(),
32
+ range: it.nullable(),
33
+ pageLastModifiedAt: a.string()
20
34
  });
21
- var I = /* @__PURE__ */ ((n) => (n.IMPORTANT = "Important", n.CONFUSING = "Confusing", n))(I || {});
22
- const M = i.enum([
35
+ var L = /* @__PURE__ */ ((n) => (n.IMPORTANT = "Important", n.CONFUSING = "Confusing", n))(L || {});
36
+ const ye = a.enum([
23
37
  "Important",
24
38
  "Confusing"
25
39
  /* 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
40
+ ]), Me = a.object({
41
+ startCursor: a.string().nullish(),
42
+ endCursor: a.string().nullish(),
43
+ hasNextPage: a.boolean().nullish(),
44
+ hasPreviousPage: a.boolean().nullish()
45
+ }), le = a.object({
46
+ id: a.string(),
47
+ rootAccountUuid: a.string(),
48
+ userId: a.string(),
49
+ courseId: a.string(),
50
+ objectId: a.string(),
51
+ objectType: a.string(),
52
+ userText: a.string().optional(),
53
+ reaction: a.array(ye),
54
+ highlightData: be,
55
+ createdAt: a.string(),
56
+ updatedAt: a.string()
57
+ }), at = a.object({
58
+ cursor: a.string(),
59
+ node: le
46
60
  });
47
- i.object({
48
- notes: i.object({
49
- edges: i.array(he),
50
- nodes: i.array(L),
51
- pageInfo: z
61
+ a.object({
62
+ notes: a.object({
63
+ edges: a.array(at),
64
+ nodes: a.array(le),
65
+ pageInfo: Me
52
66
  })
53
67
  });
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()
68
+ const ct = a.object({
69
+ type: a.string(),
70
+ id: a.string()
71
+ }), dt = a.object({
72
+ courseId: a.string().optional(),
73
+ learningObject: ct.optional(),
74
+ reactions: a.array(a.string()).optional()
61
75
  }).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()
76
+ a.object({
77
+ courseId: a.string().optional(),
78
+ filter: dt,
79
+ pageParams: Me.optional(),
80
+ direction: a.enum(["next", "prev"]).optional(),
81
+ pageSize: a.number().optional()
68
82
  });
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
83
+ a.object({
84
+ courseId: a.string(),
85
+ objectId: a.string(),
86
+ objectType: a.string(),
87
+ userText: a.string().optional(),
88
+ reaction: a.array(ye),
89
+ highlightData: be
76
90
  });
77
- i.object({
78
- createNote: L
91
+ a.object({
92
+ createNote: le
79
93
  });
80
- i.object({
81
- id: i.string(),
82
- userText: i.string().optional(),
83
- reaction: i.array(M),
84
- highlightData: q
94
+ a.object({
95
+ id: a.string(),
96
+ userText: a.string().optional(),
97
+ reaction: a.array(ye),
98
+ highlightData: be
85
99
  });
86
- i.object({
87
- updateNote: L
100
+ a.object({
101
+ updateNote: le
88
102
  });
89
- i.object({
90
- deleteNote: i.string()
103
+ a.object({
104
+ deleteNote: a.string()
91
105
  });
92
- var Z = /* @__PURE__ */ ((n) => (n[n.FORWARDS = 1] = "FORWARDS", n[n.BACKWARDS = 2] = "BACKWARDS", n))(Z || {});
93
- class S {
106
+ var Fe = /* @__PURE__ */ ((n) => (n[n.FORWARDS = 1] = "FORWARDS", n[n.BACKWARDS = 2] = "BACKWARDS", n))(Fe || {});
107
+ class q {
94
108
  constructor(e, t) {
95
109
  this.start = e, this.end = t;
96
110
  }
97
111
  toRange() {
98
112
  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({
113
+ if (this.start.element === this.end.element && this.start.offset <= this.end.offset ? [e, t] = He(this.start.element, this.start.offset, this.end.offset) : (e = this.start.resolve({
100
114
  direction: 1
101
115
  /* FORWARDS */
102
116
  }), t = this.end.resolve({
@@ -108,28 +122,28 @@ class S {
108
122
  return o.setStart(e.node, e.offset), o.setEnd(t.node, t.offset), o;
109
123
  }
110
124
  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);
125
+ const t = z.fromPoint(e.startContainer, e.startOffset), o = z.fromPoint(e.endContainer, e.endOffset);
126
+ return !t || !o ? null : new q(t, o);
113
127
  }
114
128
  static fromOffsets(e, t, o) {
115
- return new S(new E(e, t), new E(e, o));
129
+ return new q(new z(e, t), new z(e, o));
116
130
  }
117
131
  relativeTo(e) {
118
- return new S(this.start.relativeTo(e), this.end.relativeTo(e));
132
+ return new q(this.start.relativeTo(e), this.end.relativeTo(e));
119
133
  }
120
134
  }
121
- class E {
135
+ class z {
122
136
  constructor(e, t) {
123
137
  t < 0 && console.error("Offset is invalid"), this.element = e, this.offset = t;
124
138
  }
125
139
  resolve(e = {}) {
126
140
  try {
127
- return ee(this.element, this.offset)[0];
141
+ return He(this.element, this.offset)[0];
128
142
  } catch (t) {
129
143
  if (this.offset === 0 && e.direction !== void 0) {
130
144
  const o = document.createTreeWalker(this.element.getRootNode(), NodeFilter.SHOW_TEXT);
131
145
  o.currentNode = this.element;
132
- const r = e.direction === Z.FORWARDS, s = r ? o.nextNode() : o.previousNode();
146
+ const r = e.direction === Fe.FORWARDS, s = r ? o.nextNode() : o.previousNode();
133
147
  if (!s)
134
148
  throw t;
135
149
  return { node: s, offset: r ? 0 : s.data.length };
@@ -140,9 +154,9 @@ class E {
140
154
  static fromCharOffset(e, t) {
141
155
  switch (e.nodeType) {
142
156
  case Node.TEXT_NODE:
143
- return E.fromPoint(e, t);
157
+ return z.fromPoint(e, t);
144
158
  case Node.ELEMENT_NODE:
145
- return new E(e, t);
159
+ return new z(e, t);
146
160
  default:
147
161
  return console.error("Node is not an element or text node"), null;
148
162
  }
@@ -154,16 +168,16 @@ class E {
154
168
  return console.error("Text node offset is out of range"), null;
155
169
  if (!e.parentElement)
156
170
  return console.error("Text node has no parent"), null;
157
- const o = V(e) + t;
158
- return new E(e.parentElement, o);
171
+ const o = ke(e) + t;
172
+ return new z(e.parentElement, o);
159
173
  }
160
174
  case Node.ELEMENT_NODE: {
161
175
  if (t < 0 || t > e.childNodes.length)
162
176
  return console.error("Child node offset is out of range"), null;
163
177
  let o = 0;
164
178
  for (let r = 0; r < t; r++)
165
- o += J(e.childNodes[r]);
166
- return new E(e, o);
179
+ o += Be(e.childNodes[r]);
180
+ return new z(e, o);
167
181
  }
168
182
  default:
169
183
  return console.error("Point is not in an element or text node"), null;
@@ -174,99 +188,99 @@ class E {
174
188
  throw new Error("Parent is not an ancestor of current element");
175
189
  let t = this.element, o = this.offset;
176
190
  for (; t !== e; )
177
- o += V(t), t.parentElement && (t = t.parentElement);
178
- return new E(t, o);
191
+ o += ke(t), t.parentElement && (t = t.parentElement);
192
+ return new z(t, o);
179
193
  }
180
194
  }
181
- const pe = (n) => {
195
+ const ut = (n) => {
182
196
  const e = n.nodeName.toLowerCase();
183
197
  return e === "#text" ? "text()" : e;
184
198
  };
185
- function ye(n) {
199
+ function ft(n) {
186
200
  let e = 0, t = n;
187
201
  for (; t; )
188
202
  t.nodeName === n.nodeName && (e += 1), t = t.previousSibling;
189
203
  return e;
190
204
  }
191
- const Ee = (n) => {
192
- const e = pe(n), t = ye(n);
205
+ const mt = (n) => {
206
+ const e = ut(n), t = ft(n);
193
207
  return `${e}[${t}]`;
194
- }, K = (n, e) => {
208
+ }, xe = (n, e) => {
195
209
  let t = "", o = n;
196
210
  for (; o !== e; ) {
197
211
  if (!o) {
198
212
  console.error("Node is not a descendant of root");
199
213
  return;
200
214
  }
201
- t = `${Ee(o)}/${t}`, o = o.parentNode;
215
+ t = `${mt(o)}/${t}`, o = o.parentNode;
202
216
  }
203
217
  return t = `/${t}`, t = t.replace(/\/$/, ""), t;
204
- }, Se = (n, e, t) => {
218
+ }, gt = (n, e, t) => {
205
219
  const o = e.toUpperCase();
206
220
  let r = -1;
207
221
  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;
222
+ const l = n.children[s];
223
+ if (l.nodeName.toUpperCase() === o && (++r, r === t))
224
+ return l;
211
225
  }
212
226
  return null;
213
- }, be = (n, e) => {
227
+ }, ht = (n, e) => {
214
228
  if (!(n.match(/^(\/[A-Za-z0-9-]+(\[[0-9]+])?)+$/) !== null))
215
229
  return console.error("Expression is not a simple XPath"), null;
216
230
  const o = n.split("/");
217
231
  let r = e;
218
232
  o.shift();
219
233
  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)
234
+ let l, d;
235
+ const f = s.indexOf("[");
236
+ if (f !== -1) {
237
+ l = s.slice(0, f);
238
+ const g = s.slice(f + 1, s.indexOf("]"));
239
+ if (d = Number.parseInt(g, 10) - 1, d < 0)
226
240
  return null;
227
241
  } else
228
- a = s, c = 0;
229
- const d = Se(r, a, c);
230
- if (!d)
242
+ l = s, d = 0;
243
+ const c = gt(r, l, d);
244
+ if (!c)
231
245
  return null;
232
- r = d;
246
+ r = c;
233
247
  }
234
248
  return r;
235
- }, Q = (n, e = document.body) => {
249
+ }, we = (n, e = document.body) => {
236
250
  try {
237
- return be(n, e);
251
+ return ht(n, e);
238
252
  } catch {
239
253
  return document.evaluate(`.${n}`, e, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
240
254
  }
241
255
  };
242
- class A {
256
+ class X {
243
257
  constructor(e, t) {
244
258
  this.root = e, this.range = t;
245
259
  }
246
260
  static fromRange(e, t) {
247
- return new A(e, t);
261
+ return new X(e, t);
248
262
  }
249
263
  static fromSelector(e, t) {
250
264
  if (!(t != null && t.startContainer) || !(t != null && t.endContainer))
251
265
  return console.error("No start or end container in selector"), null;
252
- const o = Q(t.startContainer, e);
266
+ const o = we(t.startContainer, e);
253
267
  if (!o)
254
268
  return console.error("Failed to resolve startContainer XPath"), null;
255
- const r = Q(t.endContainer, e);
269
+ const r = we(t.endContainer, e);
256
270
  if (!r)
257
271
  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)
272
+ const s = z.fromCharOffset(o, t.startOffset), l = z.fromCharOffset(r, t.endOffset);
273
+ if (!s || !l)
260
274
  return null;
261
- const c = new S(s, a).toRange();
262
- return c ? new A(e, c) : null;
275
+ const d = new q(s, l).toRange();
276
+ return d ? new X(e, d) : null;
263
277
  }
264
278
  toRange() {
265
279
  return this.range;
266
280
  }
267
281
  toSelector() {
268
282
  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);
283
+ const e = (s = q.fromRange(this.range)) == null ? void 0 : s.toRange(), t = e && q.fromRange(e), o = t && xe(t.start.element, this.root), r = t && xe(t.end.element, this.root);
270
284
  return !o || !r ? null : {
271
285
  startContainer: o,
272
286
  startOffset: t.start.offset,
@@ -275,17 +289,17 @@ class A {
275
289
  };
276
290
  }
277
291
  }
278
- class v {
292
+ class $ {
279
293
  constructor(e, t, o) {
280
294
  this.root = e, this.start = t, this.end = o;
281
295
  }
282
296
  static fromRange(e, t) {
283
297
  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;
298
+ const o = (r = q.fromRange(t)) == null ? void 0 : r.relativeTo(e);
299
+ return o ? new $(e, o.start.offset, o.end.offset) : null;
286
300
  }
287
301
  static fromSelector(e, t) {
288
- return new v(e, t.start, t.end);
302
+ return new $(e, t.start, t.end);
289
303
  }
290
304
  toSelector() {
291
305
  return {
@@ -294,10 +308,10 @@ class v {
294
308
  };
295
309
  }
296
310
  toRange() {
297
- return S.fromOffsets(this.root, this.start, this.end).toRange();
311
+ return q.fromOffsets(this.root, this.start, this.end).toRange();
298
312
  }
299
313
  }
300
- const J = (n) => {
314
+ const Be = (n) => {
301
315
  var e;
302
316
  switch (n.nodeType) {
303
317
  case Node.ELEMENT_NODE:
@@ -306,70 +320,70 @@ const J = (n) => {
306
320
  default:
307
321
  return 0;
308
322
  }
309
- }, V = (n) => {
323
+ }, ke = (n) => {
310
324
  let e = n.previousSibling, t = 0;
311
325
  for (; e; )
312
- t += J(e), e = e.previousSibling;
326
+ t += Be(e), e = e.previousSibling;
313
327
  return t;
314
- }, ee = (n, ...e) => {
328
+ }, He = (n, ...e) => {
315
329
  let t = e.shift();
316
330
  const o = n.ownerDocument.createNodeIterator(n, NodeFilter.SHOW_TEXT), r = [];
317
- let s = o.nextNode(), a = null, c = 0;
331
+ let s = o.nextNode(), l = null, d = 0;
318
332
  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();
333
+ l = s, d + l.data.length > t ? (r.push({ node: l, offset: t - d }), t = e.shift()) : (s = o.nextNode(), d += l.data.length);
334
+ for (; t !== void 0 && l && d === t; )
335
+ r.push({ node: l, offset: l.data.length }), t = e.shift();
322
336
  return t !== void 0 && console.error("Offset exceeds text length"), r;
323
- }, Te = (n, e, t, o) => {
337
+ }, pt = (n, e, t, o) => {
324
338
  const r = t - e;
325
- return Math.abs(r - o) <= 5 ? v.fromSelector(n, {
339
+ return Math.abs(r - o) <= 5 ? $.fromSelector(n, {
326
340
  start: e,
327
341
  end: t
328
342
  }) : null;
329
- }, Ce = (n, e, t, o) => {
330
- const r = new le();
343
+ }, Nt = (n, e, t, o) => {
344
+ const r = new Qe();
331
345
  r.Match_Distance = 5e3;
332
346
  const s = n.textContent;
333
347
  if (!s)
334
348
  return null;
335
349
  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)
350
+ const l = e.slice(0, 32), d = e.slice(-32), f = o - t;
351
+ let c = r.match_main(s, l, t);
352
+ const g = r.match_main(s, d, o), m = g + d.length;
353
+ if (c === -1 || g === -1)
340
354
  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
355
+ const u = m - c, S = Math.abs(u - f);
356
+ if ((c > m || S > 5) && (r.Match_Distance = e.length + 100, c = r.match_main(s, l, m), c !== -1 && c < m))
357
+ return pt(n, c, m, f);
358
+ if (c < m && S <= 5)
359
+ return $.fromSelector(n, {
360
+ start: c,
361
+ end: m
348
362
  });
349
363
  } 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
364
+ const l = r.match_main(s, e, t);
365
+ if (l !== -1)
366
+ return $.fromSelector(n, {
367
+ start: l,
368
+ end: l + e.length
355
369
  });
356
370
  }
357
371
  return null;
358
- }, ve = (n, e) => {
372
+ }, bt = (n, e) => {
359
373
  if (!e) return null;
360
374
  const { highlightData: t } = n, { textPosition: o, selectedText: r } = t;
361
- return Ce(
375
+ return Nt(
362
376
  e,
363
377
  r,
364
378
  (o == null ? void 0 : o.start) ?? 0,
365
379
  (o == null ? void 0 : o.end) ?? 0
366
380
  );
367
- }, ht = (n, e, t) => {
381
+ }, yt = (n, e, t) => {
368
382
  const o = [], r = [];
369
383
  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);
384
+ const l = bt(s, n);
385
+ if (l) {
386
+ const d = l.toRange(), f = d && X.fromRange(n, d);
373
387
  o.push({
374
388
  id: s.id,
375
389
  reaction: s.reaction,
@@ -377,8 +391,8 @@ const J = (n) => {
377
391
  highlightData: {
378
392
  ...s.highlightData,
379
393
  hasNoHighlightAnymore: !1,
380
- range: (u == null ? void 0 : u.toSelector()) ?? null,
381
- textPosition: a.toSelector(),
394
+ range: (f == null ? void 0 : f.toSelector()) ?? null,
395
+ textPosition: l.toSelector(),
382
396
  pageLastModifiedAt: t
383
397
  }
384
398
  });
@@ -395,54 +409,59 @@ const J = (n) => {
395
409
  }) : r.push(s.id);
396
410
  }
397
411
  return { notesForUpdate: o, noteIdsForDelete: r };
398
- }, mt = (n) => {
399
- const e = document.getElementById($(n));
412
+ }, Oe = (n, e) => {
413
+ var l;
414
+ if (!e) return;
415
+ const { highlightData: t, id: o } = n, { range: r } = t ?? {};
416
+ r && ((l = X.fromSelector(e, r)) == null ? void 0 : l.toRange()) && wt({ id: o });
417
+ }, St = (n) => {
418
+ const e = document.getElementById(Ce(n));
400
419
  if (e) {
401
420
  const t = e.getBoundingClientRect();
402
421
  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
422
  }
404
- }, R = 90, k = 172, Nt = (n) => {
423
+ }, oe = 90, re = 172, Ct = (n) => {
405
424
  const e = n.getClientRects();
406
425
  if (!e.length)
407
426
  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;
427
+ const t = e[0], o = e[e.length - 1], r = 4, s = 16, l = window.innerWidth || document.documentElement.clientWidth, d = window.innerHeight || document.documentElement.clientHeight, f = (C) => {
428
+ const I = C + re;
429
+ return C >= s && I <= l - s;
430
+ }, c = (C) => {
431
+ const I = C + oe;
432
+ return C >= s && I <= d - s;
414
433
  };
415
- let h;
416
- const f = t.right - k;
417
- if (u(f))
418
- h = f;
434
+ let g;
435
+ const m = t.right - re;
436
+ if (f(m))
437
+ g = m;
419
438
  else {
420
- const N = t.left;
421
- if (u(N))
422
- h = N;
439
+ const C = t.left;
440
+ if (f(C))
441
+ g = C;
423
442
  else {
424
- const T = (t.left + t.right) / 2 - k / 2;
425
- u(T) ? h = T : f < s ? h = s : h = a - k - s;
443
+ const O = (t.left + t.right) / 2 - re / 2;
444
+ f(O) ? g = O : m < s ? g = s : g = l - re - s;
426
445
  }
427
446
  }
428
- let l;
429
- const m = o.bottom + r;
430
- if (d(m))
431
- l = m;
447
+ let u;
448
+ const S = o.bottom + r;
449
+ if (c(S))
450
+ u = S;
432
451
  else {
433
- const N = t.top - R - r;
434
- d(N) ? l = N : m + R > c - s ? l = c - R - s : l = s;
452
+ const C = t.top - oe - r;
453
+ c(C) ? u = C : S + oe > d - s ? u = d - oe - s : u = s;
435
454
  }
436
- return { top: l, left: h };
437
- }, pt = (n, e) => {
455
+ return { top: u, left: g };
456
+ }, vt = (n, e) => {
438
457
  for (const t of e)
439
458
  if (n.start < t.end && n.end > t.start)
440
459
  return !0;
441
460
  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) => {
461
+ }, Se = (n) => `highlight-wrapper-${n}`, Ce = (n) => `${Se(n)}-start`, ze = (n) => `${Se(n)}-end`, te = (n) => `[data-highlight-id="${CSS.escape(n)}"]`, ae = (n, e) => {
443
462
  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
463
  return `rgba(${t}, ${o}, ${r}, ${e})`;
445
- }, Oe = (n, e) => {
464
+ }, Et = (n, e) => {
446
465
  var t;
447
466
  try {
448
467
  const o = ((t = e.nodeValue) == null ? void 0 : t.length) ?? e.childNodes.length;
@@ -450,7 +469,7 @@ const J = (n) => {
450
469
  } catch {
451
470
  return !1;
452
471
  }
453
- }, we = (n) => {
472
+ }, Tt = (n) => {
454
473
  var s;
455
474
  if (n.collapsed)
456
475
  return [];
@@ -460,216 +479,223 @@ const J = (n) => {
460
479
  const t = [], o = (s = e == null ? void 0 : e.ownerDocument) == null ? void 0 : s.createNodeIterator(e, NodeFilter.SHOW_TEXT);
461
480
  let r = (o == null ? void 0 : o.nextNode()) || null;
462
481
  for (; r; ) {
463
- if (!Oe(n, r)) {
482
+ if (!Et(n, r)) {
464
483
  r = (o == null ? void 0 : o.nextNode()) || null;
465
484
  continue;
466
485
  }
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;
486
+ const l = r;
487
+ if (l === n.startContainer && n.startOffset > 0) {
488
+ l.splitText(n.startOffset), r = (o == null ? void 0 : o.nextNode()) || null;
470
489
  continue;
471
490
  }
472
- a === n.endContainer && n.endOffset < a.data.length && a.splitText(n.endOffset), t.push(a), r = (o == null ? void 0 : o.nextNode()) || null;
491
+ l === n.endContainer && n.endOffset < l.data.length && l.splitText(n.endOffset), t.push(l), r = (o == null ? void 0 : o.nextNode()) || null;
473
492
  }
474
493
  return t;
475
- }, yt = (n, e, t) => {
494
+ }, It = (n, e, t) => {
476
495
  if (n.collapsed) return;
477
- const o = e.id ?? "", r = W(o);
478
- if (document.getElementById($(o))) {
479
- Ie(e, t);
496
+ const o = e.id ?? "", r = Se(o);
497
+ if (document.getElementById(Ce(o))) {
498
+ xt(e, t);
480
499
  return;
481
500
  }
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 || "";
486
- 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) => {
506
- var y;
507
- g.target.tagName !== "A" && ((y = e.onClick) == null || y.call(e));
508
- }), l.addEventListener("keydown", (g) => {
509
- 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();
501
+ const l = e.type === L.IMPORTANT ? t.colors.importantBackground : t.colors.confusingBackground, f = e.id === e.selectedNoteId ? l : ae(l, 0.5), c = e.type === L.IMPORTANT ? t.colors.importantUnderline : t.colors.confusingUnderline, g = e.type === L.IMPORTANT ? "solid" : "dashed", m = n.toString(), u = document.createElement("span");
502
+ 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";
503
+ const S = document.createElement("span");
504
+ S.id = ze(o), S.className = "highlight-marker-end", S.dataset.highlightId = o || "";
505
+ const C = n.cloneRange();
506
+ C.collapse(!1), C.insertNode(S);
507
+ const I = n.cloneRange();
508
+ I.collapse(!0), I.insertNode(u);
509
+ const O = document.createRange();
510
+ O.setStartAfter(u), O.setEndBefore(S);
511
+ const w = Tt(O).filter((b) => b.textContent && b.textContent.length > 0);
512
+ w.forEach((b, k) => {
513
+ var Y;
514
+ const D = b.parentElement;
515
+ if ((D == null ? void 0 : D.dataset.highlightId) === o) return;
516
+ const B = k === 0, E = k === w.length - 1, j = w.length === 1;
517
+ let A;
518
+ j ? A = "single" : B ? A = "first" : E ? A = "last" : A = "middle";
519
+ const x = document.createElement("span");
520
+ x.className = "highlight-content", x.dataset.highlightId = o || "", x.dataset.position = A, x.style.backgroundColor = f, x.style.textDecorationLine = "underline", x.style.textDecorationColor = c, x.style.textDecorationStyle = g, x.style.textDecorationThickness = t.borderWidthSmall, x.style.textUnderlineOffset = t.underlineOffset, x.style.cursor = "pointer", x.addEventListener("click", (T) => {
521
+ var p;
522
+ T.target.tagName !== "A" && ((p = e.onClick) == null || p.call(e));
523
+ }), (Y = b.parentNode) == null || Y.insertBefore(x, b), x.appendChild(b);
524
+ }), u.addEventListener("click", (b) => {
525
+ var k;
526
+ b.target.tagName !== "A" && ((k = e.onClick) == null || k.call(e));
527
+ }), u.addEventListener("keydown", (b) => {
528
+ var k;
529
+ if (b.key === "Enter" || b.key === " ")
530
+ b.preventDefault(), (k = e.onClick) == null || k.call(e);
531
+ else if (b.key === "Tab" && !b.shiftKey) {
532
+ const D = document.querySelectorAll(te(o));
533
+ for (const B of D) {
534
+ const E = B.querySelector("a");
535
+ if (E) {
536
+ b.preventDefault(), E.focus();
518
537
  break;
519
538
  }
520
539
  }
521
540
  }
522
- }), l.addEventListener("focus", () => {
541
+ }), u.addEventListener("focus", () => {
523
542
  document.querySelectorAll(
524
- D(o)
525
- ).forEach((y) => {
526
- y.classList.add("highlight-focused");
543
+ te(o)
544
+ ).forEach((k) => {
545
+ k.classList.add("highlight-focused");
527
546
  });
528
- }), l.addEventListener("blur", () => {
547
+ }), u.addEventListener("blur", () => {
529
548
  document.querySelectorAll(
530
- D(o)
531
- ).forEach((y) => {
532
- y.classList.remove("highlight-focused");
549
+ te(o)
550
+ ).forEach((k) => {
551
+ k.classList.remove("highlight-focused");
533
552
  });
534
553
  });
535
554
  };
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);
555
+ function xt(n, e) {
556
+ const t = n.type === L.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground, r = n.id === n.selectedNoteId ? t : ae(t, 0.5);
538
557
  document.querySelectorAll(
539
- D(n.id ?? "")
540
- ).forEach((a) => {
541
- a.style.backgroundColor = r;
558
+ te(n.id ?? "")
559
+ ).forEach((l) => {
560
+ l.style.backgroundColor = r;
542
561
  });
543
562
  }
544
- const Et = (n) => {
545
- const e = n.id ?? "", t = document.getElementById($(e)), o = document.getElementById(te(e));
563
+ const wt = (n) => {
564
+ const e = n.id ?? "", t = document.getElementById(Ce(e)), o = document.getElementById(ze(e));
546
565
  document.querySelectorAll(
547
- D(e)
566
+ te(e)
548
567
  ).forEach((s) => {
549
- var a;
568
+ var l;
550
569
  for (; s.firstChild; )
551
- (a = s.parentNode) == null || a.insertBefore(s.firstChild, s);
570
+ (l = s.parentNode) == null || l.insertBefore(s.firstChild, s);
552
571
  s.remove();
553
572
  }), t == null || t.remove(), o == null || o.remove();
554
- }, C = {
573
+ }, J = {
555
574
  all: ["notebook"],
556
575
  notes: (n) => ["notebook", "notes", n]
557
576
  };
558
- function St(n) {
559
- const e = j();
560
- return P({
577
+ function kt(n) {
578
+ const e = ge();
579
+ return he({
561
580
  mutationFn: (t) => n.createNote(t),
562
581
  onSuccess: () => {
563
- e.invalidateQueries({ queryKey: C.all });
582
+ e.invalidateQueries({ queryKey: J.all });
564
583
  }
565
584
  });
566
585
  }
567
- function bt(n) {
568
- const e = j();
569
- return P({
586
+ function Ot(n) {
587
+ const e = ge();
588
+ return he({
570
589
  mutationFn: (t) => n.deleteNote(t),
571
590
  onSuccess: () => {
572
- e.invalidateQueries({ queryKey: C.all });
591
+ e.invalidateQueries({ queryKey: J.all });
573
592
  }
574
593
  });
575
594
  }
576
- function Tt({
595
+ function Rt({
577
596
  api: n,
578
597
  enabled: e = !0,
579
598
  ...t
580
599
  }) {
581
- return ce({
582
- queryKey: C.notes(t),
600
+ return Ye({
601
+ queryKey: J.notes(t),
583
602
  queryFn: () => n.getNotes(t),
584
603
  enabled: e
585
604
  });
586
605
  }
587
- function Ct(n) {
588
- const e = j();
589
- return P({
606
+ function Dt(n) {
607
+ const e = ge();
608
+ return he({
590
609
  mutationFn: ({ id: t, input: o }) => n.updateNote(t, o),
591
610
  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
611
+ await e.cancelQueries({ queryKey: J.all });
612
+ const s = e.getQueryCache().findAll({ queryKey: J.all }), l = /* @__PURE__ */ new Map();
613
+ for (const d of s) {
614
+ const f = d.state.data;
615
+ f && (l.set(d.queryKey, f), e.setQueryData(d.queryKey, {
616
+ ...f,
617
+ notes: f.notes.map(
618
+ (c) => c.id === t ? { ...c, ...o, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } : c
600
619
  )
601
620
  }));
602
621
  }
603
- return { previousData: a };
622
+ return { previousData: l };
604
623
  },
605
624
  onError: (t, o, r) => {
606
625
  if (r != null && r.previousData)
607
- for (const [s, a] of r.previousData)
608
- e.setQueryData(s, a);
626
+ for (const [s, l] of r.previousData)
627
+ e.setQueryData(s, l);
609
628
  },
610
629
  onSettled: () => {
611
- e.invalidateQueries({ queryKey: C.all });
630
+ e.invalidateQueries({ queryKey: J.all });
612
631
  }
613
632
  });
614
633
  }
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;
634
+ const Lt = "Notebook", At = "Notes", Pt = "Important", Mt = "Unclear", Ft = "Back", Bt = "Edit note", Ht = "Save", zt = "Cancel", jt = "Delete note", _t = "note", Ut = "Add note (optional)", Wt = "Remove from Notebook", qt = "Add a note (optional).", $t = "Mark important", Gt = "Mark unclear", Kt = "Saved to Notebook.", Xt = "Note updated", Qt = "Note deleted", Yt = "Error saving to Notebook.", Vt = "Error updating note", Zt = "Note deletion failed", Jt = "Loading notes", en = "Failed to load notes", tn = "Start capturing your notes", nn = "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.", on = "Nothing here yet", rn = "Adjust your filters or create a new note to get started.", sn = "You have no notes for the selected filter", ln = "Previous page", an = "Next page", cn = "All courses", dn = "All notes", un = "Close Notebook panel", fn = "To use the Notebook feature, highlight an excerpt from your learning material to flag it as 'confusing' or 'important' and leave an optional note.", mn = "The content you highlighted is no longer available.", ve = {
635
+ notebook: Lt,
636
+ notes: At,
637
+ important: Pt,
638
+ unclear: Mt,
639
+ back: Ft,
640
+ editNote: Bt,
641
+ save: Ht,
642
+ cancel: zt,
643
+ deleteNote: jt,
644
+ note: _t,
645
+ addNotePrompt: Ut,
646
+ removeFromNotebook: Wt,
647
+ addNoteOptional: qt,
648
+ markImportant: $t,
649
+ markUnclear: Gt,
650
+ savedToNotebook: Kt,
651
+ noteUpdated: Xt,
652
+ noteDeleted: Qt,
653
+ errorSavingNote: Yt,
654
+ errorUpdatingNote: Vt,
655
+ noteDeletionFailed: Zt,
656
+ loadingNotes: Jt,
657
+ failedToLoadNotes: en,
658
+ emptyStateHeading: tn,
659
+ emptyStateDescription: nn,
660
+ nothingHereYet: on,
661
+ adjustFiltersOrCreate: rn,
662
+ noNotesForFilter: sn,
663
+ previousPage: ln,
664
+ nextPage: an,
665
+ allCourses: cn,
666
+ allNotes: dn,
667
+ closeNotebookPanel: un,
668
+ featureDescription: fn,
669
+ highlightUnavailable: mn
670
+ }, je = De(null);
671
+ function _e(n, e) {
672
+ const t = ve[n] ?? n;
650
673
  return e ? t.replace(/%\{([^}]+)}/g, (o, r) => String(e[r] ?? `%{${r}}`)) : t;
651
674
  }
652
- function st({
675
+ function gn({
653
676
  translations: n,
654
677
  translate: e,
655
678
  children: t
656
679
  }) {
657
- const r = {
658
- translations: { ...B, ...n },
659
- translate: e ?? re
660
- };
661
- return /* @__PURE__ */ _(oe.Provider, { value: r, children: t });
680
+ const o = me(
681
+ () => ({
682
+ translations: { ...ve, ...n },
683
+ translate: e ?? _e
684
+ }),
685
+ [n, e]
686
+ );
687
+ return /* @__PURE__ */ i(je.Provider, { value: o, children: t });
662
688
  }
663
- function vt() {
664
- const n = Y(oe);
665
- return n || { translations: B, translate: re };
689
+ function Q() {
690
+ const n = Le(je);
691
+ return n || { translations: ve, translate: _e };
666
692
  }
667
- const it = {
693
+ const hn = {
668
694
  selectedNoteId: null,
669
695
  isNoteEditing: !1,
670
696
  isTrayOpen: !1
671
697
  };
672
- function at(n, e) {
698
+ function pn(n, e) {
673
699
  switch (e.type) {
674
700
  case "SELECT_NOTE":
675
701
  return {
@@ -689,20 +715,20 @@ function at(n, e) {
689
715
  return n;
690
716
  }
691
717
  }
692
- const se = G(null);
693
- function Ot({
718
+ const Ue = De(null);
719
+ function Wn({
694
720
  api: n,
695
721
  currentUserId: e,
696
722
  objectId: t,
697
723
  objectType: o,
698
724
  courseId: r,
699
725
  pageLastModifiedAt: s,
700
- onAnalyticsEvent: a,
701
- translations: c,
702
- translate: u,
703
- children: d
726
+ onAnalyticsEvent: l,
727
+ translations: d,
728
+ translate: f,
729
+ children: c
704
730
  }) {
705
- const [h, f] = ue(at, it), l = de(
731
+ const [g, m] = Ke(pn, hn), u = me(
706
732
  () => ({
707
733
  api: n,
708
734
  currentUserId: e,
@@ -710,13 +736,13 @@ function Ot({
710
736
  objectType: o,
711
737
  courseId: r,
712
738
  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" })
739
+ onAnalyticsEvent: l,
740
+ ...g,
741
+ selectNote: (S, C = !1) => m({ type: "SELECT_NOTE", payload: { id: S, isEditing: C } }),
742
+ clearSelectedNote: () => m({ type: "CLEAR_SELECTED_NOTE" }),
743
+ setEditing: (S) => m({ type: "SET_EDITING", payload: S }),
744
+ openTray: () => m({ type: "OPEN_TRAY" }),
745
+ closeTray: () => m({ type: "CLOSE_TRAY" })
720
746
  }),
721
747
  [
722
748
  n,
@@ -725,37 +751,803 @@ function Ot({
725
751
  o,
726
752
  r,
727
753
  s,
728
- a,
729
- h
754
+ l,
755
+ g
730
756
  ]
731
757
  );
732
- return /* @__PURE__ */ _(se.Provider, { value: l, children: /* @__PURE__ */ _(st, { translations: c, translate: u, children: d }) });
758
+ return /* @__PURE__ */ i(Ue.Provider, { value: u, children: /* @__PURE__ */ i(gn, { translations: d, translate: f, children: c }) });
733
759
  }
734
- function wt() {
735
- const n = Y(se);
760
+ function We() {
761
+ const n = Le(Ue);
736
762
  if (!n)
737
763
  throw new Error("useNotebook must be used within a NotebookProvider");
738
764
  return n;
739
765
  }
766
+ const Nn = ({ currentType: n, onSelectReaction: e }) => {
767
+ const { translations: t } = Q(), o = ne(null), r = ne(null);
768
+ return ee(() => {
769
+ n === L.CONFUSING && o.current ? o.current.focus() : n === L.IMPORTANT && r.current ? r.current.focus() : o.current && o.current.focus();
770
+ }, [n]), /* @__PURE__ */ N(Z, { children: [
771
+ /* @__PURE__ */ N(Z.Item, { ref: o, onClick: () => e(L.CONFUSING), children: [
772
+ /* @__PURE__ */ i(pe, { size: "x-small" }),
773
+ ` ${t.markUnclear}`
774
+ ] }),
775
+ /* @__PURE__ */ N(Z.Item, { ref: r, onClick: () => e(L.IMPORTANT), children: [
776
+ /* @__PURE__ */ i(Ne, { size: "x-small" }),
777
+ ` ${t.markImportant}`
778
+ ] })
779
+ ] });
780
+ }, ce = "notebook-inline-reaction-menu";
781
+ function qn({
782
+ containerRef: n,
783
+ highlightTheme: e,
784
+ debounceTime: t = 500
785
+ }) {
786
+ const {
787
+ api: o,
788
+ objectId: r,
789
+ objectType: s,
790
+ courseId: l,
791
+ pageLastModifiedAt: d,
792
+ selectedNoteId: f,
793
+ selectNote: c,
794
+ openTray: g
795
+ } = We(), { data: m } = Rt({
796
+ api: o,
797
+ filter: {
798
+ learningObject: { type: s, id: r }
799
+ },
800
+ courseId: l,
801
+ pageSize: 100
802
+ }), { mutate: u } = kt(o), { mutate: S } = Dt(o), { mutate: C } = Ot(o), I = ne([]), [O, R] = H([]), [w, b] = H(null), [k, D] = H(""), [B, E] = H(null), [j, A] = H(!1);
803
+ ee(() => {
804
+ const T = n.current;
805
+ if (!T) return;
806
+ const p = T.closest(".user_content") ?? T;
807
+ if (p.classList.contains("enhanced")) {
808
+ A(!0);
809
+ return;
810
+ }
811
+ const P = new MutationObserver((M) => {
812
+ for (const F of M)
813
+ if (F.type === "attributes" && F.attributeName === "class" && F.target.classList.contains("enhanced")) {
814
+ A(!0), P.disconnect();
815
+ return;
816
+ }
817
+ });
818
+ return P.observe(p, { attributes: !0, attributeFilter: ["class"] }), () => P.disconnect();
819
+ }, [n]), ee(() => {
820
+ if (!j || !n.current) return;
821
+ let p = null;
822
+ const P = () => {
823
+ p && clearTimeout(p), p = setTimeout(() => {
824
+ var Te;
825
+ const y = window.getSelection(), h = n.current;
826
+ if (!(y != null && y.rangeCount) || !h) return;
827
+ const _ = y.toString().trim();
828
+ if (_ === "") return;
829
+ const V = y.getRangeAt(0);
830
+ if (!h.contains(V.commonAncestorContainer)) return;
831
+ const Ee = (Te = $.fromRange(h, V)) == null ? void 0 : Te.toSelector();
832
+ Ee && !vt(Ee, O) && (b(V.cloneRange()), D(_), E(Ct(V)));
833
+ }, t);
834
+ }, M = (y) => {
835
+ if (!(y.target instanceof Node)) return;
836
+ const h = document.getElementById(ce);
837
+ h != null && h.contains(y.target) ? (y.preventDefault(), y.stopImmediatePropagation()) : (E(null), b(null), D(""));
838
+ }, F = () => {
839
+ E(null), b(null), D("");
840
+ };
841
+ return document.addEventListener("selectionchange", P), document.addEventListener("mousedown", M), document.addEventListener("touchstart", M), window.addEventListener("scroll", F, !0), () => {
842
+ p && clearTimeout(p), document.removeEventListener("selectionchange", P), document.removeEventListener("mousedown", M), document.removeEventListener("touchstart", M), window.removeEventListener("scroll", F, !0);
843
+ };
844
+ }, [j, O, t, n]), ee(() => {
845
+ f && St(f);
846
+ }, [f]);
847
+ const x = Ae(
848
+ (T) => {
849
+ var _;
850
+ const p = n.current;
851
+ if (!p || !T.highlightData) return null;
852
+ const { highlightData: P, reaction: M, id: F } = T, { range: y } = P, h = y && ((_ = X.fromSelector(p, y)) == null ? void 0 : _.toRange());
853
+ if (h) {
854
+ const V = {
855
+ id: F,
856
+ selectedNoteId: f,
857
+ type: M[0],
858
+ onClick: () => {
859
+ c(F), g();
860
+ }
861
+ };
862
+ return It(h, V, e), P.textPosition;
863
+ }
864
+ return null;
865
+ },
866
+ [n, f, e, c, g]
867
+ );
868
+ ee(() => {
869
+ if (!j || !m || !n.current) return;
870
+ const T = n.current, p = m.notes, P = /* @__PURE__ */ new Set(), M = [], F = [];
871
+ if (p.length === 0) {
872
+ if (I.current.length > 0) {
873
+ for (const y of I.current)
874
+ Oe(y, T);
875
+ I.current = [], R([]);
876
+ }
877
+ return;
878
+ }
879
+ if (d && p[0].highlightData.pageLastModifiedAt !== d) {
880
+ const { notesForUpdate: y, noteIdsForDelete: h } = yt(
881
+ T,
882
+ p,
883
+ d
884
+ );
885
+ for (const _ of y)
886
+ S({ id: _.id, input: _ });
887
+ for (const _ of h)
888
+ C(_);
889
+ } else {
890
+ for (const y of p) {
891
+ const h = x(y);
892
+ P.add(y.id), h && (M.push(y), F.push(h));
893
+ }
894
+ for (const y of I.current)
895
+ P.has(y.id) || Oe(y, T);
896
+ R(F), I.current = M;
897
+ }
898
+ }, [
899
+ j,
900
+ m,
901
+ x,
902
+ d,
903
+ n,
904
+ S,
905
+ C
906
+ ]);
907
+ const Y = (T) => {
908
+ const p = n.current;
909
+ if (!w || !p) return;
910
+ const P = X.fromRange(p, w), M = $.fromRange(p, w);
911
+ u(
912
+ {
913
+ courseId: l,
914
+ objectId: r,
915
+ objectType: s,
916
+ userText: "",
917
+ reaction: [T],
918
+ highlightData: {
919
+ selectedText: k,
920
+ textPosition: (M == null ? void 0 : M.toSelector()) ?? null,
921
+ range: P.toSelector(),
922
+ pageLastModifiedAt: d ?? ""
923
+ }
924
+ },
925
+ {
926
+ onSuccess: (F) => {
927
+ var h;
928
+ const y = F.id;
929
+ b(null), D(""), E(null), (h = window.getSelection()) == null || h.removeAllRanges(), c(y), g();
930
+ }
931
+ }
932
+ );
933
+ };
934
+ return !w || !B ? null : Xe(
935
+ /* @__PURE__ */ i(
936
+ "div",
937
+ {
938
+ id: ce,
939
+ role: "toolbar",
940
+ style: {
941
+ position: "fixed",
942
+ zIndex: 100,
943
+ top: B.top,
944
+ left: B.left,
945
+ whiteSpace: "nowrap"
946
+ },
947
+ onBlur: (T) => {
948
+ const p = document.getElementById(ce);
949
+ p != null && p.contains(T.relatedTarget) || (E(null), b(null), D(""));
950
+ },
951
+ children: /* @__PURE__ */ i(Nn, { onSelectReaction: Y })
952
+ }
953
+ ),
954
+ document.body
955
+ );
956
+ }
957
+ const bn = (n, e) => ({
958
+ backgroundColor: n === L.IMPORTANT ? e.colors.importantBackground : e.colors.confusingBackground,
959
+ underlineColor: n === L.IMPORTANT ? e.colors.importantUnderline : e.colors.confusingUnderline,
960
+ underlineStyle: n === L.IMPORTANT ? "solid" : "dashed"
961
+ }), fe = ({
962
+ children: n,
963
+ type: e = L.IMPORTANT,
964
+ isCardActive: t = !0,
965
+ theme: o
966
+ }) => {
967
+ const r = bn(e, o), l = {
968
+ position: "relative",
969
+ backgroundColor: t ? r.backgroundColor : ae(r.backgroundColor, 0.5),
970
+ textDecorationLine: "underline",
971
+ textDecorationStyle: r.underlineStyle,
972
+ textDecorationColor: r.underlineColor,
973
+ textDecorationThickness: o.borderWidthSmall,
974
+ textUnderlineOffset: o.underlineOffset,
975
+ lineHeight: "normal"
976
+ };
977
+ return /* @__PURE__ */ i("span", { "data-note-highlight": "true", style: l, children: n });
978
+ }, qe = () => {
979
+ const { translations: n } = Q();
980
+ return /* @__PURE__ */ N(v, { gap: "xx-small", alignItems: "start", as: "div", children: [
981
+ /* @__PURE__ */ i(v.Item, { as: "div", children: /* @__PURE__ */ i(Ve, { color: "error" }) }),
982
+ /* @__PURE__ */ i(v.Item, { padding: "xxx-small none", shouldShrink: !0, children: /* @__PURE__ */ i(ue, { maxLines: 3, children: n.highlightUnavailable }) })
983
+ ] });
984
+ }, $n = ({ children: n }) => {
985
+ const { isTrayOpen: e, closeTray: t } = We(), { translations: o } = Q();
986
+ return /* @__PURE__ */ i(
987
+ ot,
988
+ {
989
+ label: o.notebook,
990
+ open: e,
991
+ onDismiss: t,
992
+ placement: "end",
993
+ size: "regular",
994
+ children: /* @__PURE__ */ N(v, { direction: "column", height: "100vh", children: [
995
+ /* @__PURE__ */ i(v.Item, { children: /* @__PURE__ */ i(K, { as: "div", padding: "small medium", borderWidth: "0 0 small 0", children: /* @__PURE__ */ N(v, { justifyItems: "space-between", alignItems: "center", children: [
996
+ /* @__PURE__ */ i(ie, { level: "h3", children: o.notebook }),
997
+ /* @__PURE__ */ i(
998
+ nt,
999
+ {
1000
+ screenReaderLabel: o.closeNotebookPanel,
1001
+ onClick: t,
1002
+ size: "small",
1003
+ "data-testid": "notebook-tray-close"
1004
+ }
1005
+ )
1006
+ ] }) }) }),
1007
+ /* @__PURE__ */ i(v.Item, { shouldGrow: !0, shouldShrink: !0, overflowY: "auto", overflowX: "hidden", children: n })
1008
+ ] })
1009
+ }
1010
+ );
1011
+ }, yn = {
1012
+ [L.IMPORTANT]: {
1013
+ color: "info",
1014
+ translationKey: "important",
1015
+ icon: /* @__PURE__ */ i(Ne, { size: "x-small" })
1016
+ },
1017
+ [L.CONFUSING]: {
1018
+ color: "danger",
1019
+ translationKey: "unclear",
1020
+ icon: /* @__PURE__ */ i(pe, { size: "x-small" })
1021
+ }
1022
+ }, $e = ({ type: n, onTypeChange: e, renderAsMenuTrigger: t = !1 }) => {
1023
+ const { translations: o } = Q(), r = yn[n], s = o[r.translationKey], [l, d] = H(!1), f = ne(null), c = ne(null), g = Ae(
1024
+ (m) => {
1025
+ e == null || e(m), d(!1);
1026
+ },
1027
+ [e]
1028
+ );
1029
+ return t && e ? /* @__PURE__ */ N(
1030
+ Z,
1031
+ {
1032
+ placement: "bottom start",
1033
+ show: l,
1034
+ onToggle: (m) => d(m),
1035
+ shouldHideOnSelect: !0,
1036
+ shouldFocusTriggerOnClose: !0,
1037
+ trigger: /* @__PURE__ */ N(Ie, { color: r.color, renderIcon: r.icon, children: [
1038
+ s,
1039
+ " ",
1040
+ /* @__PURE__ */ i(Ze, { size: "x-small" })
1041
+ ] }),
1042
+ children: [
1043
+ /* @__PURE__ */ N(Z.Item, { ref: f, onClick: () => g(L.CONFUSING), children: [
1044
+ /* @__PURE__ */ i(pe, { size: "x-small" }),
1045
+ ` ${o.markUnclear}`
1046
+ ] }),
1047
+ /* @__PURE__ */ N(Z.Item, { ref: c, onClick: () => g(L.IMPORTANT), children: [
1048
+ /* @__PURE__ */ i(Ne, { size: "x-small" }),
1049
+ ` ${o.markImportant}`
1050
+ ] })
1051
+ ]
1052
+ }
1053
+ ) : /* @__PURE__ */ i(Ie, { color: r.color, renderIcon: r.icon, children: s });
1054
+ };
1055
+ function Re(n, e) {
1056
+ return (n instanceof Date ? n : new Date(n)).toLocaleString(e, {
1057
+ year: "numeric",
1058
+ month: "short",
1059
+ day: "numeric"
1060
+ });
1061
+ }
1062
+ const Sn = ({
1063
+ noteId: n,
1064
+ date: e,
1065
+ highlight: t,
1066
+ note: o,
1067
+ type: r,
1068
+ onClick: s,
1069
+ onDelete: l,
1070
+ onSaveNote: d,
1071
+ onTypeChange: f,
1072
+ isActive: c,
1073
+ isPanelView: g = !1,
1074
+ courseName: m,
1075
+ locale: u,
1076
+ highlightTheme: S,
1077
+ cardTheme: C,
1078
+ renderLink: I,
1079
+ href: O
1080
+ }) => {
1081
+ const { translations: R } = Q(), [w, b] = H(!1), [k, D] = H(!1), [B, E] = H(o || ""), [j, A] = H(!1), x = r === L.IMPORTANT ? R.important : R.unclear, Y = (h) => {
1082
+ h.key === "Enter" && (h.preventDefault(), s == null || s());
1083
+ }, T = [x, R.note];
1084
+ t && T.push(t), o && T.push(o), e && T.push(Re(e, u)), m && T.push(m);
1085
+ const p = T.join(", "), P = r === L.CONFUSING ? C.confusingBorderColor : C.importantBorderColor, F = {
1086
+ borderStyle: "solid",
1087
+ borderColor: c || w ? P : ae(P, 0.5),
1088
+ borderWidth: "0.0625rem 0.0625rem 0.25rem 0.25rem",
1089
+ borderRadius: "1rem",
1090
+ padding: "1rem",
1091
+ cursor: k ? "default" : "pointer",
1092
+ position: "relative"
1093
+ }, y = (
1094
+ // biome-ignore lint/a11y/noStaticElementInteractions: role is conditionally set to "button"
1095
+ // biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-label applies when role="button"
1096
+ /* @__PURE__ */ N(
1097
+ "div",
1098
+ {
1099
+ role: O || k ? void 0 : "button",
1100
+ "aria-label": O ? void 0 : p,
1101
+ "aria-pressed": O || k ? void 0 : c,
1102
+ tabIndex: O || c ? -1 : 0,
1103
+ "data-testid": "note-card",
1104
+ onClick: c ? void 0 : s,
1105
+ onMouseEnter: () => b(!0),
1106
+ onMouseLeave: () => b(!1),
1107
+ onKeyDown: c ? void 0 : Y,
1108
+ style: F,
1109
+ children: [
1110
+ /* @__PURE__ */ N(v, { direction: "column", gap: "small", children: [
1111
+ /* @__PURE__ */ i(
1112
+ $e,
1113
+ {
1114
+ type: r,
1115
+ onTypeChange: g && f ? (h) => f(n, h) : void 0,
1116
+ renderAsMenuTrigger: g && !!f && !!c
1117
+ }
1118
+ ),
1119
+ t ? /* @__PURE__ */ i("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: /* @__PURE__ */ i(U, { children: c && g ? /* @__PURE__ */ i(
1120
+ fe,
1121
+ {
1122
+ type: r,
1123
+ isCardActive: !!c || w,
1124
+ theme: S,
1125
+ children: t
1126
+ }
1127
+ ) : /* @__PURE__ */ i(ue, { maxLines: 3, truncate: "word", children: /* @__PURE__ */ i(
1128
+ fe,
1129
+ {
1130
+ type: r,
1131
+ isCardActive: !!c || w,
1132
+ theme: S,
1133
+ children: t
1134
+ }
1135
+ ) }) }) }) : /* @__PURE__ */ i(qe, {}),
1136
+ /* @__PURE__ */ N(v, { direction: "column", gap: c ? "small" : "none", children: [
1137
+ k && g ? /* @__PURE__ */ N(v, { direction: "column", gap: "x-small", children: [
1138
+ /* @__PURE__ */ i(
1139
+ Pe,
1140
+ {
1141
+ label: /* @__PURE__ */ i(rt, { children: R.editNote }),
1142
+ value: B,
1143
+ onChange: (h) => E(h.target.value),
1144
+ placeholder: R.addNoteOptional
1145
+ }
1146
+ ),
1147
+ /* @__PURE__ */ N(v, { gap: "xx-small", children: [
1148
+ /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1149
+ W,
1150
+ {
1151
+ display: "block",
1152
+ size: "small",
1153
+ "data-testid": "note-card-cancel",
1154
+ onClick: () => {
1155
+ E(o || ""), D(!1);
1156
+ },
1157
+ children: R.cancel
1158
+ }
1159
+ ) }),
1160
+ /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1161
+ W,
1162
+ {
1163
+ display: "block",
1164
+ color: "primary",
1165
+ size: "small",
1166
+ "data-testid": "note-card-save",
1167
+ onClick: () => {
1168
+ d == null || d(n, B), D(!1);
1169
+ },
1170
+ interaction: B.trim() ? "enabled" : "disabled",
1171
+ children: R.save
1172
+ }
1173
+ ) })
1174
+ ] })
1175
+ ] }) : o ? /* @__PURE__ */ i("div", { style: { wordBreak: "break-word", overflowWrap: "break-word" }, children: c && g ? /* @__PURE__ */ N(U, { children: [
1176
+ o,
1177
+ " ",
1178
+ /* @__PURE__ */ i(
1179
+ G,
1180
+ {
1181
+ size: "small",
1182
+ withBackground: !1,
1183
+ withBorder: !1,
1184
+ screenReaderLabel: R.editNote,
1185
+ "data-testid": "note-card-edit",
1186
+ onClick: (h) => {
1187
+ h.stopPropagation(), D(!0);
1188
+ },
1189
+ children: /* @__PURE__ */ i(de, {})
1190
+ }
1191
+ )
1192
+ ] }) : /* @__PURE__ */ i(U, { children: /* @__PURE__ */ i(ue, { maxLines: 3, truncate: "word", children: o }) }) }) : g && c ? /* @__PURE__ */ i("div", { children: /* @__PURE__ */ N(U, { color: "secondary", children: [
1193
+ R.addNotePrompt,
1194
+ " ",
1195
+ /* @__PURE__ */ i(
1196
+ G,
1197
+ {
1198
+ size: "small",
1199
+ withBackground: !1,
1200
+ withBorder: !1,
1201
+ screenReaderLabel: R.editNote,
1202
+ "data-testid": "note-card-edit",
1203
+ onClick: (h) => {
1204
+ h.stopPropagation(), D(!0);
1205
+ },
1206
+ children: /* @__PURE__ */ i(de, {})
1207
+ }
1208
+ )
1209
+ ] }) }) : null,
1210
+ /* @__PURE__ */ N(v, { justifyItems: "space-between", alignItems: "center", children: [
1211
+ /* @__PURE__ */ i(U, { size: "small", color: "secondary", children: Re(e, u) }),
1212
+ c && l && /* @__PURE__ */ i(
1213
+ G,
1214
+ {
1215
+ size: "small",
1216
+ withBackground: !1,
1217
+ withBorder: !1,
1218
+ color: "danger",
1219
+ screenReaderLabel: R.deleteNote,
1220
+ "data-testid": "note-card-delete",
1221
+ onClick: (h) => {
1222
+ h.stopPropagation(), A(!0);
1223
+ },
1224
+ children: /* @__PURE__ */ i(se, {})
1225
+ }
1226
+ )
1227
+ ] }),
1228
+ m && /* @__PURE__ */ i(U, { size: "small", color: "secondary", children: m })
1229
+ ] })
1230
+ ] }),
1231
+ j && l && /* @__PURE__ */ i(
1232
+ K,
1233
+ {
1234
+ as: "div",
1235
+ background: "primary",
1236
+ padding: "medium",
1237
+ borderRadius: "large",
1238
+ position: "absolute",
1239
+ insetBlockStart: "0",
1240
+ insetBlockEnd: "0",
1241
+ insetInlineStart: "0",
1242
+ insetInlineEnd: "0",
1243
+ stacking: "above",
1244
+ children: /* @__PURE__ */ N(
1245
+ v,
1246
+ {
1247
+ direction: "column",
1248
+ justifyItems: "center",
1249
+ alignItems: "center",
1250
+ gap: "x-small",
1251
+ height: "100%",
1252
+ children: [
1253
+ /* @__PURE__ */ i(
1254
+ W,
1255
+ {
1256
+ display: "block",
1257
+ color: "danger",
1258
+ size: "small",
1259
+ renderIcon: /* @__PURE__ */ i(se, {}),
1260
+ "data-testid": "note-card-confirm-delete",
1261
+ onClick: (h) => {
1262
+ h.stopPropagation(), l(n), A(!1);
1263
+ },
1264
+ children: R.deleteNote
1265
+ }
1266
+ ),
1267
+ /* @__PURE__ */ i(
1268
+ W,
1269
+ {
1270
+ display: "block",
1271
+ size: "small",
1272
+ "data-testid": "note-card-cancel-delete",
1273
+ onClick: (h) => {
1274
+ h.stopPropagation(), A(!1);
1275
+ },
1276
+ children: R.cancel
1277
+ }
1278
+ )
1279
+ ]
1280
+ }
1281
+ )
1282
+ }
1283
+ )
1284
+ ]
1285
+ }
1286
+ )
1287
+ );
1288
+ return O && I ? I({ href: O, children: y, ariaLabel: p }) : y;
1289
+ };
1290
+ function Cn(n, e) {
1291
+ const t = Array.from({ length: e }, () => []);
1292
+ return n.forEach((o, r) => {
1293
+ t[r % e].push(o);
1294
+ }), t;
1295
+ }
1296
+ const vn = {
1297
+ display: "flex",
1298
+ gap: "1rem",
1299
+ padding: "1rem",
1300
+ boxSizing: "border-box",
1301
+ width: "100%",
1302
+ alignItems: "flex-start"
1303
+ }, En = {
1304
+ display: "flex",
1305
+ flexDirection: "column",
1306
+ gap: "1rem",
1307
+ flex: 1,
1308
+ minWidth: 0
1309
+ }, Gn = ({
1310
+ notes: n,
1311
+ isLoading: e,
1312
+ isError: t,
1313
+ pageInfo: o,
1314
+ onPreviousPage: r,
1315
+ onNextPage: s,
1316
+ onNoteSelect: l,
1317
+ onNoteDelete: d,
1318
+ onNoteSave: f,
1319
+ onNoteTypeChange: c,
1320
+ selectedNoteId: g,
1321
+ hasActiveFilter: m = !1,
1322
+ columnCount: u = 1,
1323
+ highlightTheme: S,
1324
+ cardTheme: C,
1325
+ locale: I,
1326
+ renderNoteLink: O,
1327
+ noteHref: R
1328
+ }) => {
1329
+ const { translations: w } = Q(), b = me(
1330
+ () => Cn(n, u),
1331
+ [n, u]
1332
+ ), k = (o == null ? void 0 : o.hasNextPage) || (o == null ? void 0 : o.hasPreviousPage);
1333
+ if (e)
1334
+ return /* @__PURE__ */ i(K, { as: "div", textAlign: "center", padding: "large", "data-testid": "notes-loading", children: /* @__PURE__ */ i(st, { renderTitle: w.loadingNotes }) });
1335
+ if (t)
1336
+ return /* @__PURE__ */ i(K, { as: "div", textAlign: "center", padding: "large", "data-testid": "notes-error", children: /* @__PURE__ */ i(ie, { level: "h4", children: w.failedToLoadNotes }) });
1337
+ if (n.length === 0) {
1338
+ const D = m ? w.nothingHereYet : w.emptyStateHeading, B = m ? w.adjustFiltersOrCreate : w.emptyStateDescription;
1339
+ return /* @__PURE__ */ N(
1340
+ v,
1341
+ {
1342
+ direction: "column",
1343
+ alignItems: "center",
1344
+ justifyItems: "center",
1345
+ padding: "large",
1346
+ gap: "small",
1347
+ "data-testid": "empty-notes",
1348
+ children: [
1349
+ /* @__PURE__ */ i(ie, { level: "h3", children: D }),
1350
+ /* @__PURE__ */ i(U, { color: "secondary", children: B })
1351
+ ]
1352
+ }
1353
+ );
1354
+ }
1355
+ return /* @__PURE__ */ N(Ge, { children: [
1356
+ /* @__PURE__ */ i("div", { style: vn, "data-testid": "notes-grid", children: b.map((D, B) => (
1357
+ // biome-ignore lint/suspicious/noArrayIndexKey: columns are positional, index is stable
1358
+ /* @__PURE__ */ i("div", { style: En, children: D.map((E) => {
1359
+ var j;
1360
+ return /* @__PURE__ */ i(
1361
+ Sn,
1362
+ {
1363
+ noteId: E.id,
1364
+ date: E.createdAt,
1365
+ type: E.reaction[0] ?? L.IMPORTANT,
1366
+ highlight: (j = E.highlightData) == null ? void 0 : j.selectedText,
1367
+ note: E.userText,
1368
+ isActive: g === E.id,
1369
+ isPanelView: !!g,
1370
+ onClick: l ? () => l(E.id) : void 0,
1371
+ onDelete: d ? (A) => d(A) : void 0,
1372
+ onSaveNote: f ? (A, x) => f(A, x) : void 0,
1373
+ onTypeChange: c ? (A, x) => c(A, x) : void 0,
1374
+ highlightTheme: S,
1375
+ cardTheme: C,
1376
+ locale: I,
1377
+ renderLink: O,
1378
+ href: R ? R(E.id, E) : void 0
1379
+ },
1380
+ E.id
1381
+ );
1382
+ }) }, B)
1383
+ )) }),
1384
+ k && /* @__PURE__ */ N(v, { justifyItems: "center", gap: "small", padding: "small", "data-testid": "notes-pagination", children: [
1385
+ /* @__PURE__ */ i(
1386
+ G,
1387
+ {
1388
+ size: "small",
1389
+ screenReaderLabel: w.previousPage,
1390
+ "data-testid": "notes-prev-page",
1391
+ interaction: o != null && o.hasPreviousPage ? "enabled" : "disabled",
1392
+ onClick: r,
1393
+ children: /* @__PURE__ */ i(Je, {})
1394
+ }
1395
+ ),
1396
+ /* @__PURE__ */ i(
1397
+ G,
1398
+ {
1399
+ size: "small",
1400
+ screenReaderLabel: w.nextPage,
1401
+ "data-testid": "notes-next-page",
1402
+ interaction: o != null && o.hasNextPage ? "enabled" : "disabled",
1403
+ onClick: s,
1404
+ children: /* @__PURE__ */ i(et, {})
1405
+ }
1406
+ )
1407
+ ] })
1408
+ ] });
1409
+ }, Kn = ({
1410
+ noteText: n,
1411
+ reaction: e,
1412
+ highlightText: t,
1413
+ highlightTheme: o,
1414
+ onSave: r,
1415
+ onDelete: s,
1416
+ onTypeChange: l,
1417
+ onBack: d,
1418
+ editing: f = !1
1419
+ }) => {
1420
+ const { translations: c } = Q(), [g, m] = H(f), [u, S] = H(n || ""), [C, I] = H(!1);
1421
+ return /* @__PURE__ */ N(v, { direction: "column", gap: "small", "data-testid": "single-note", children: [
1422
+ t != null ? /* @__PURE__ */ i(K, { as: "div", children: /* @__PURE__ */ i(U, { children: /* @__PURE__ */ i(fe, { type: e, isCardActive: !0, theme: o, children: t }) }) }) : /* @__PURE__ */ i(qe, {}),
1423
+ /* @__PURE__ */ i($e, { type: e, onTypeChange: l, renderAsMenuTrigger: !!l }),
1424
+ g ? /* @__PURE__ */ N(v, { direction: "column", gap: "x-small", children: [
1425
+ /* @__PURE__ */ i(
1426
+ Pe,
1427
+ {
1428
+ label: c.addNoteOptional,
1429
+ value: u,
1430
+ onChange: (O) => S(O.target.value),
1431
+ resize: "vertical"
1432
+ }
1433
+ ),
1434
+ /* @__PURE__ */ N(v, { gap: "xx-small", children: [
1435
+ /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1436
+ W,
1437
+ {
1438
+ display: "block",
1439
+ size: "small",
1440
+ "data-testid": "single-note-cancel",
1441
+ onClick: () => {
1442
+ S(n || ""), m(!1);
1443
+ },
1444
+ children: c.cancel
1445
+ }
1446
+ ) }),
1447
+ /* @__PURE__ */ i(v.Item, { shouldGrow: !0, children: /* @__PURE__ */ i(
1448
+ W,
1449
+ {
1450
+ display: "block",
1451
+ color: "primary",
1452
+ size: "small",
1453
+ "data-testid": "single-note-save",
1454
+ onClick: () => {
1455
+ r(u), m(!1);
1456
+ },
1457
+ children: c.save
1458
+ }
1459
+ ) })
1460
+ ] })
1461
+ ] }) : /* @__PURE__ */ N(v, { direction: "column", gap: "small", children: [
1462
+ n && /* @__PURE__ */ N(K, { as: "div", children: [
1463
+ /* @__PURE__ */ i(ie, { level: "h4", margin: "0 0 xx-small 0", children: c.note }),
1464
+ /* @__PURE__ */ i(U, { children: n })
1465
+ ] }),
1466
+ /* @__PURE__ */ N(v, { justifyItems: "space-between", children: [
1467
+ /* @__PURE__ */ i(
1468
+ W,
1469
+ {
1470
+ size: "small",
1471
+ renderIcon: /* @__PURE__ */ i(tt, {}),
1472
+ "data-testid": "single-note-back",
1473
+ onClick: () => d == null ? void 0 : d(),
1474
+ children: c.back
1475
+ }
1476
+ ),
1477
+ /* @__PURE__ */ N(v, { gap: "xx-small", children: [
1478
+ s && /* @__PURE__ */ i(
1479
+ G,
1480
+ {
1481
+ size: "small",
1482
+ withBackground: !1,
1483
+ withBorder: !1,
1484
+ color: "danger",
1485
+ screenReaderLabel: c.deleteNote,
1486
+ "data-testid": "single-note-delete",
1487
+ onClick: () => I(!0),
1488
+ children: /* @__PURE__ */ i(se, {})
1489
+ }
1490
+ ),
1491
+ /* @__PURE__ */ i(
1492
+ G,
1493
+ {
1494
+ size: "small",
1495
+ withBackground: !1,
1496
+ withBorder: !1,
1497
+ screenReaderLabel: c.editNote,
1498
+ "data-testid": "single-note-edit",
1499
+ onClick: () => m(!0),
1500
+ children: /* @__PURE__ */ i(de, {})
1501
+ }
1502
+ )
1503
+ ] })
1504
+ ] }),
1505
+ C && s && /* @__PURE__ */ i(K, { as: "div", background: "primary", padding: "medium", borderRadius: "large", children: /* @__PURE__ */ N(v, { direction: "column", justifyItems: "center", alignItems: "center", gap: "x-small", children: [
1506
+ /* @__PURE__ */ i(
1507
+ W,
1508
+ {
1509
+ display: "block",
1510
+ color: "danger",
1511
+ size: "small",
1512
+ renderIcon: /* @__PURE__ */ i(se, {}),
1513
+ "data-testid": "single-note-confirm-delete",
1514
+ onClick: () => {
1515
+ s(), I(!1);
1516
+ },
1517
+ children: c.deleteNote
1518
+ }
1519
+ ),
1520
+ /* @__PURE__ */ i(
1521
+ W,
1522
+ {
1523
+ display: "block",
1524
+ size: "small",
1525
+ "data-testid": "single-note-cancel-delete",
1526
+ onClick: () => I(!1),
1527
+ children: c.cancel
1528
+ }
1529
+ )
1530
+ ] }) })
1531
+ ] })
1532
+ ] });
1533
+ };
740
1534
  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
1535
+ qn as ContentWithNoteWrapper,
1536
+ fe as Highlight,
1537
+ qe as HighlightError,
1538
+ Sn as NoteCard,
1539
+ $e as NoteChip,
1540
+ Nn as NoteReactionMenu,
1541
+ Wn as NotebookProvider,
1542
+ $n as NotebookTray,
1543
+ Gn as NotesListView,
1544
+ L as REACTION_TYPE,
1545
+ Kn as SingleNote,
1546
+ ae as createTransparentColor,
1547
+ kt as useCreateNote,
1548
+ Ot as useDeleteNote,
1549
+ Rt as useGetNotes,
1550
+ We as useNotebook,
1551
+ Q as useNotebookTranslations,
1552
+ Dt as useUpdateNote
761
1553
  };