ocean-brain 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp.js +660 -31
- package/package.json +2 -1
- package/server/client/dist/assets/{Calendar-BU9XgX2N.js → Calendar-BJHLksEZ.js} +1 -1
- package/server/client/dist/assets/{Callout-C6tVCxOT.js → Callout-wFx9oCas.js} +1 -1
- package/server/client/dist/assets/Graph-9piERaNR.js +1 -0
- package/server/client/dist/assets/{Image-DxWhlIDG.js → Image-DK0lnaK2.js} +1 -1
- package/server/client/dist/assets/{Image.es-BjGK7y6Y.js → Image.es-Be7par_j.js} +1 -1
- package/server/client/dist/assets/Note-CC9ybxXL.js +21 -0
- package/server/client/dist/assets/{Plus.es-EcmtS_uw.js → Plus.es-BKm7uDYu.js} +1 -1
- package/server/client/dist/assets/Reminders-DRxA8v98.js +1 -0
- package/server/client/dist/assets/Search-BunSQrqv.js +1 -0
- package/server/client/dist/assets/{SurfaceCard-CO0oVxeL.js → SurfaceCard-FhlC8VSR.js} +1 -1
- package/server/client/dist/assets/Tag-z_crJ5JP.js +1 -0
- package/server/client/dist/assets/TagNotes-D7wIJ4jy.js +1 -0
- package/server/client/dist/assets/{Trash.es-DmwfSy3l.js → Trash.es-ByMVwx0d.js} +1 -1
- package/server/client/dist/assets/ViewNotes-Duo9XmcJ.js +1 -0
- package/server/client/dist/assets/Views-D4Z_O9Kd.js +1 -0
- package/server/client/dist/assets/{image.api-DeF9ck7g.js → image.api-B5Qi-Txv.js} +1 -1
- package/server/client/dist/assets/{index-BZUGWdOU.css → index-Cd81UxEh.css} +1 -1
- package/server/client/dist/assets/index-cHJQCo8V.js +1 -0
- package/server/client/dist/assets/index-nYj7BL3a.js +327 -0
- package/server/client/dist/assets/manage-image-detail-DcZggB1M.js +1 -0
- package/server/client/dist/assets/manage-image-glbtBibn.js +1 -0
- package/server/client/dist/assets/{mcp-Bh743HBz.js → mcp-BBUpQdS9.js} +1 -1
- package/server/client/dist/assets/{note-core-Z6kqulGB.js → note-core-DMZcZ4yV.js} +53 -53
- package/server/client/dist/assets/{note-vendor-i1M2FSI2.js → note-vendor-uuJO2MTD.js} +1 -1
- package/server/client/dist/assets/{placeholder-XQqo1Fvr.js → placeholder-B_qb_qkc.js} +5 -5
- package/server/client/dist/assets/properties-CiyQv6Tb.js +1 -0
- package/server/client/dist/assets/trash-CQnj4Rmv.js +1 -0
- package/server/client/dist/assets/{useReminderMutate-D21PurIS.js → useReminderMutate-CSKliBcc.js} +1 -1
- package/server/client/dist/assets/view-dashboard-B5fKgvk_.js +99 -0
- package/server/client/dist/index.html +4 -4
- package/server/dist/features/note/graphql/note.field.resolver.js +2 -0
- package/server/dist/features/note/graphql/note.field.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.mutation.resolver.js +119 -0
- package/server/dist/features/note/graphql/note.mutation.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.query.resolver.js +14 -0
- package/server/dist/features/note/graphql/note.query.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.type-defs.js +100 -0
- package/server/dist/features/note/graphql/note.type-defs.js.map +1 -1
- package/server/dist/features/note/http/mcp.js +394 -1
- package/server/dist/features/note/http/mcp.js.map +1 -1
- package/server/dist/features/note/services/markdown-intent-write.js +495 -0
- package/server/dist/features/note/services/markdown-intent-write.js.map +1 -0
- package/server/dist/features/note/services/markdown-patch.js +601 -0
- package/server/dist/features/note/services/markdown-patch.js.map +1 -0
- package/server/dist/features/note/services/properties.js +874 -0
- package/server/dist/features/note/services/properties.js.map +1 -0
- package/server/dist/features/note/services/snapshot.js +94 -12
- package/server/dist/features/note/services/snapshot.js.map +1 -1
- package/server/dist/features/note/services/trash.js +70 -2
- package/server/dist/features/note/services/trash.js.map +1 -1
- package/server/dist/features/note/services/write.js +21 -7
- package/server/dist/features/note/services/write.js.map +1 -1
- package/server/dist/features/view/graphql/view.query.resolver.js +31 -1
- package/server/dist/features/view/graphql/view.query.resolver.js.map +1 -1
- package/server/dist/features/view/graphql/view.type-defs.js +57 -1
- package/server/dist/features/view/graphql/view.type-defs.js.map +1 -1
- package/server/dist/features/view/services/workspace.js +367 -43
- package/server/dist/features/view/services/workspace.js.map +1 -1
- package/server/dist/modules/blocknote.js +367 -7
- package/server/dist/modules/blocknote.js.map +1 -1
- package/server/dist/routes/mcp.js +21 -1
- package/server/dist/routes/mcp.js.map +1 -1
- package/server/prisma/migrations/20260527073000_0017_note_properties/migration.sql +105 -0
- package/server/prisma/migrations/20260531073000_0018_view_query/migration.sql +3 -0
- package/server/prisma/schema.prisma +226 -130
- package/server/client/dist/assets/Graph-Dond2hGK.js +0 -1
- package/server/client/dist/assets/Note-Cr6GtXUM.js +0 -21
- package/server/client/dist/assets/Reminders-BlLLT_x0.js +0 -1
- package/server/client/dist/assets/Search-CrZ0ap8x.js +0 -1
- package/server/client/dist/assets/Tag-vws5AfNW.js +0 -1
- package/server/client/dist/assets/TagNotes-Fmf1Kgim.js +0 -1
- package/server/client/dist/assets/ViewNotes-BALN7IfH.js +0 -1
- package/server/client/dist/assets/Views-Ccc_Ml5U.js +0 -1
- package/server/client/dist/assets/index-BSVE2cGd.js +0 -1
- package/server/client/dist/assets/index-BvKBTjQq.js +0 -246
- package/server/client/dist/assets/manage-image-IoTXaMBP.js +0 -1
- package/server/client/dist/assets/manage-image-detail-BRTXwOsh.js +0 -1
- package/server/client/dist/assets/trash-hiJIg6-c.js +0 -1
- package/server/client/dist/assets/view-dashboard-BuaZ4MvI.js +0 -90
|
@@ -1,197 +1,293 @@
|
|
|
1
1
|
generator client {
|
|
2
|
-
|
|
2
|
+
provider = "prisma-client-js"
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
datasource db {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
provider = "sqlite"
|
|
7
|
+
url = env("DATABASE_URL")
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
model Cache {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
id Int @id @default(autoincrement())
|
|
12
|
+
key String @unique
|
|
13
|
+
value String
|
|
14
|
+
createdAt DateTime @default(now())
|
|
15
|
+
updatedAt DateTime @updatedAt
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
model McpToken {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
id Int @id @default(autoincrement())
|
|
20
|
+
tokenHash String
|
|
21
|
+
createdAt DateTime @default(now())
|
|
22
|
+
lastUsedAt DateTime?
|
|
23
|
+
revokedAt DateTime?
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
@@index([revokedAt, createdAt])
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
model Note {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
id Int @id @default(autoincrement())
|
|
30
|
+
title String
|
|
31
|
+
content String
|
|
32
|
+
searchableText String @default("")
|
|
33
|
+
searchableTextVersion Int @default(0)
|
|
34
|
+
createdAt DateTime @default(now())
|
|
35
|
+
updatedAt DateTime @updatedAt
|
|
36
|
+
pinned Boolean @default(false)
|
|
37
|
+
order Int @default(0)
|
|
38
|
+
layout NoteLayout @default(wide)
|
|
39
|
+
tags Tag[] @relation("NoteToTag")
|
|
40
|
+
reminders Reminder[] @relation("NoteToReminder")
|
|
41
|
+
snapshots NoteSnapshot[]
|
|
42
|
+
properties NoteProperty[]
|
|
43
|
+
|
|
44
|
+
@@index([updatedAt, id])
|
|
45
|
+
@@index([createdAt, id])
|
|
46
|
+
@@index([pinned, updatedAt, id])
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
model PropertyDefinition {
|
|
50
|
+
id Int @id @default(autoincrement())
|
|
51
|
+
key String @unique
|
|
52
|
+
name String
|
|
53
|
+
valueType PropertyValueType
|
|
54
|
+
createdAt DateTime @default(now())
|
|
55
|
+
updatedAt DateTime @updatedAt
|
|
56
|
+
options PropertyOption[]
|
|
57
|
+
properties NoteProperty[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
model PropertyOption {
|
|
61
|
+
id Int @id @default(autoincrement())
|
|
62
|
+
propertyDefinitionId Int
|
|
63
|
+
definition PropertyDefinition @relation(fields: [propertyDefinitionId], references: [id], onDelete: Cascade)
|
|
64
|
+
label String
|
|
65
|
+
value String
|
|
66
|
+
color String?
|
|
67
|
+
order Int @default(0)
|
|
68
|
+
properties NoteProperty[]
|
|
69
|
+
createdAt DateTime @default(now())
|
|
70
|
+
updatedAt DateTime @updatedAt
|
|
71
|
+
|
|
72
|
+
@@unique([propertyDefinitionId, value])
|
|
73
|
+
@@index([propertyDefinitionId, order])
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
model NoteProperty {
|
|
77
|
+
id Int @id @default(autoincrement())
|
|
78
|
+
noteId Int
|
|
79
|
+
propertyDefinitionId Int
|
|
80
|
+
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
|
|
81
|
+
definition PropertyDefinition @relation(fields: [propertyDefinitionId], references: [id], onDelete: Cascade)
|
|
82
|
+
optionId Int?
|
|
83
|
+
option PropertyOption? @relation(fields: [optionId], references: [id], onDelete: SetNull)
|
|
84
|
+
textValue String?
|
|
85
|
+
textValueNormalized String?
|
|
86
|
+
numberValue Float?
|
|
87
|
+
dateValue DateTime?
|
|
88
|
+
boolValue Boolean?
|
|
89
|
+
createdAt DateTime @default(now())
|
|
90
|
+
updatedAt DateTime @updatedAt
|
|
91
|
+
|
|
92
|
+
@@unique([noteId, propertyDefinitionId])
|
|
93
|
+
@@index([propertyDefinitionId, noteId])
|
|
94
|
+
@@index([propertyDefinitionId, textValueNormalized, noteId])
|
|
95
|
+
@@index([propertyDefinitionId, numberValue, noteId])
|
|
96
|
+
@@index([propertyDefinitionId, dateValue, noteId])
|
|
97
|
+
@@index([propertyDefinitionId, boolValue, noteId])
|
|
98
|
+
@@index([propertyDefinitionId, optionId, noteId])
|
|
42
99
|
}
|
|
43
100
|
|
|
44
101
|
model NoteSnapshot {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
102
|
+
id Int @id @default(autoincrement())
|
|
103
|
+
noteId Int
|
|
104
|
+
note Note @relation(fields: [noteId], references: [id], onDelete: Cascade)
|
|
105
|
+
title String
|
|
106
|
+
payload String
|
|
107
|
+
editSessionId String?
|
|
108
|
+
meta String?
|
|
109
|
+
createdAt DateTime @default(now())
|
|
53
110
|
|
|
54
|
-
|
|
55
|
-
|
|
111
|
+
@@unique([noteId, editSessionId])
|
|
112
|
+
@@index([noteId, createdAt])
|
|
56
113
|
}
|
|
57
114
|
|
|
58
115
|
model DeletedNote {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
116
|
+
id Int @id
|
|
117
|
+
title String
|
|
118
|
+
content String
|
|
119
|
+
createdAt DateTime
|
|
120
|
+
updatedAt DateTime
|
|
121
|
+
deletedAt DateTime @default(now())
|
|
122
|
+
pinned Boolean @default(false)
|
|
123
|
+
order Int @default(0)
|
|
124
|
+
layout NoteLayout @default(wide)
|
|
125
|
+
tags DeletedNoteTag[]
|
|
126
|
+
reminders DeletedReminder[]
|
|
127
|
+
properties DeletedNoteProperty[]
|
|
128
|
+
|
|
129
|
+
@@index([deletedAt, updatedAt])
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
model DeletedNoteProperty {
|
|
133
|
+
id Int @id @default(autoincrement())
|
|
134
|
+
deletedNoteId Int
|
|
135
|
+
deletedNote DeletedNote @relation(fields: [deletedNoteId], references: [id], onDelete: Cascade)
|
|
136
|
+
key String
|
|
137
|
+
name String
|
|
138
|
+
valueType PropertyValueType
|
|
139
|
+
textValue String?
|
|
140
|
+
textValueNormalized String?
|
|
141
|
+
numberValue Float?
|
|
142
|
+
dateValue DateTime?
|
|
143
|
+
boolValue Boolean?
|
|
144
|
+
optionValue String?
|
|
145
|
+
optionLabel String?
|
|
146
|
+
optionColor String?
|
|
147
|
+
createdAt DateTime
|
|
148
|
+
updatedAt DateTime
|
|
70
149
|
|
|
71
|
-
|
|
150
|
+
@@unique([deletedNoteId, key])
|
|
151
|
+
@@index([deletedNoteId])
|
|
72
152
|
}
|
|
73
153
|
|
|
74
154
|
model DeletedNoteTag {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
155
|
+
id Int @id @default(autoincrement())
|
|
156
|
+
deletedNoteId Int
|
|
157
|
+
deletedNote DeletedNote @relation(fields: [deletedNoteId], references: [id], onDelete: Cascade)
|
|
158
|
+
name String
|
|
79
159
|
|
|
80
|
-
|
|
160
|
+
@@index([deletedNoteId])
|
|
81
161
|
}
|
|
82
162
|
|
|
83
163
|
model DeletedReminder {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
164
|
+
id Int @id @default(autoincrement())
|
|
165
|
+
deletedNoteId Int
|
|
166
|
+
deletedNote DeletedNote @relation(fields: [deletedNoteId], references: [id], onDelete: Cascade)
|
|
167
|
+
originalId Int?
|
|
168
|
+
reminderDate DateTime
|
|
169
|
+
completed Boolean @default(false)
|
|
170
|
+
priority ReminderPriority @default(medium)
|
|
171
|
+
content String?
|
|
172
|
+
createdAt DateTime
|
|
173
|
+
updatedAt DateTime
|
|
94
174
|
|
|
95
|
-
|
|
175
|
+
@@index([deletedNoteId])
|
|
96
176
|
}
|
|
97
177
|
|
|
98
178
|
model Image {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
179
|
+
id Int @id @default(autoincrement())
|
|
180
|
+
url String
|
|
181
|
+
hash String @unique
|
|
182
|
+
createdAt DateTime @default(now())
|
|
183
|
+
updatedAt DateTime @updatedAt
|
|
104
184
|
}
|
|
105
185
|
|
|
106
186
|
model Tag {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
187
|
+
id Int @id @default(autoincrement())
|
|
188
|
+
name String @unique
|
|
189
|
+
createdAt DateTime @default(now())
|
|
190
|
+
updatedAt DateTime @updatedAt
|
|
191
|
+
notes Note[] @relation("NoteToTag")
|
|
112
192
|
}
|
|
113
193
|
|
|
114
194
|
enum ReminderPriority {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
195
|
+
low
|
|
196
|
+
medium
|
|
197
|
+
high
|
|
118
198
|
}
|
|
119
199
|
|
|
120
200
|
enum NoteLayout {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
201
|
+
narrow
|
|
202
|
+
wide
|
|
203
|
+
full
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
enum PropertyValueType {
|
|
207
|
+
text
|
|
208
|
+
url
|
|
209
|
+
number
|
|
210
|
+
date
|
|
211
|
+
boolean
|
|
212
|
+
select
|
|
124
213
|
}
|
|
125
214
|
|
|
126
215
|
model Reminder {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
216
|
+
id Int @id @default(autoincrement())
|
|
217
|
+
noteId Int
|
|
218
|
+
note Note @relation("NoteToReminder", fields: [noteId], references: [id], onDelete: Cascade)
|
|
219
|
+
reminderDate DateTime
|
|
220
|
+
completed Boolean @default(false)
|
|
221
|
+
priority ReminderPriority @default(medium)
|
|
222
|
+
content String?
|
|
223
|
+
createdAt DateTime @default(now())
|
|
224
|
+
updatedAt DateTime @updatedAt
|
|
136
225
|
}
|
|
137
226
|
|
|
138
227
|
model Placeholder {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
228
|
+
id Int @id @default(autoincrement())
|
|
229
|
+
name String @unique
|
|
230
|
+
template String
|
|
231
|
+
replacement String
|
|
232
|
+
createdAt DateTime @default(now())
|
|
233
|
+
updatedAt DateTime @updatedAt
|
|
145
234
|
}
|
|
146
235
|
|
|
147
236
|
model ViewWorkspace {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
237
|
+
id Int @id
|
|
238
|
+
activeTabId Int?
|
|
239
|
+
activeTab ViewTab? @relation("ActiveViewTab", fields: [activeTabId], references: [id], onDelete: SetNull)
|
|
240
|
+
createdAt DateTime @default(now())
|
|
241
|
+
updatedAt DateTime @updatedAt
|
|
153
242
|
}
|
|
154
243
|
|
|
155
244
|
model ViewTab {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
245
|
+
id Int @id @default(autoincrement())
|
|
246
|
+
title String
|
|
247
|
+
order Int @default(0)
|
|
248
|
+
createdAt DateTime @default(now())
|
|
249
|
+
updatedAt DateTime @updatedAt
|
|
250
|
+
sections ViewSection[]
|
|
251
|
+
activeWorkspaces ViewWorkspace[] @relation("ActiveViewTab")
|
|
163
252
|
|
|
164
|
-
|
|
253
|
+
@@index([order, createdAt])
|
|
165
254
|
}
|
|
166
255
|
|
|
167
256
|
model ViewSection {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
257
|
+
id Int @id @default(autoincrement())
|
|
258
|
+
tabId Int
|
|
259
|
+
tab ViewTab @relation(fields: [tabId], references: [id], onDelete: Cascade)
|
|
260
|
+
title String
|
|
261
|
+
displayType ViewDisplayType @default(list)
|
|
262
|
+
query String?
|
|
263
|
+
mode ViewTagMatchMode @default(and)
|
|
264
|
+
limit Int @default(5)
|
|
265
|
+
order Int @default(0)
|
|
266
|
+
createdAt DateTime @default(now())
|
|
267
|
+
updatedAt DateTime @updatedAt
|
|
268
|
+
tags ViewSectionTag[]
|
|
178
269
|
|
|
179
|
-
|
|
270
|
+
@@index([tabId, order, createdAt])
|
|
180
271
|
}
|
|
181
272
|
|
|
182
273
|
model ViewSectionTag {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
274
|
+
id Int @id @default(autoincrement())
|
|
275
|
+
sectionId Int
|
|
276
|
+
section ViewSection @relation(fields: [sectionId], references: [id], onDelete: Cascade)
|
|
277
|
+
name String
|
|
278
|
+
order Int @default(0)
|
|
279
|
+
createdAt DateTime @default(now())
|
|
280
|
+
updatedAt DateTime @updatedAt
|
|
190
281
|
|
|
191
|
-
|
|
282
|
+
@@index([sectionId, order, createdAt])
|
|
192
283
|
}
|
|
193
284
|
|
|
194
285
|
enum ViewTagMatchMode {
|
|
195
|
-
|
|
196
|
-
|
|
286
|
+
and
|
|
287
|
+
or
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
enum ViewDisplayType {
|
|
291
|
+
list
|
|
292
|
+
calendar
|
|
197
293
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t}from"./note-vendor-i1M2FSI2.js";import{$ as _,P as C,a2 as U,i as G,a3 as Y,a4 as J,a5 as X,a6 as ee,q as ne,N as te,F as re,T as N,a7 as oe}from"./index-BvKBTjQq.js";import{a as i,F as se}from"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.js";const ae=s=>{let a=0;for(let r=0;r<s.length;r++)a+=s.charCodeAt(r);return a},ie={background:"#f4f6f8",nodeHub:"#2c2f36",nodeSelected:"#111318",nodeConnected:"#636b76",nodeDefault:["#d6dbe1","#c8ced6","#b7bec7","#a7afb9"],nodeDimmed:["rgba(214,219,225,0.28)","rgba(200,206,214,0.24)","rgba(183,190,199,0.24)","rgba(167,175,185,0.2)"],nodeHubDimmed:"rgba(44,47,54,0.16)",nodeStroke:"#eef1f4",nodeSelectedStroke:"#a6b0bc",labelBackground:"rgba(246,248,250,0.92)",labelText:"#222831",labelFontFamily:"Pretendard Variable, Pretendard, system-ui, sans-serif",linkIdle:"rgba(99, 107, 117, 0.34)",linkConnected:"#68717c",linkDimmed:"rgba(127, 136, 146, 0.12)",legendHub:"#2c2f36"},le={background:"#121316",nodeHub:"#d6dce3",nodeSelected:"#eef1f5",nodeConnected:"#9099a4",nodeDefault:["#343a43","#2d333c","#262c35","#20262f"],nodeDimmed:["rgba(52,58,67,0.28)","rgba(45,51,60,0.24)","rgba(38,44,53,0.22)","rgba(32,38,47,0.2)"],nodeHubDimmed:"rgba(214,220,227,0.16)",nodeStroke:"#171c23",nodeSelectedStroke:"#7f8a97",labelBackground:"rgba(16,18,22,0.9)",labelText:"#eef2f6",labelFontFamily:"Pretendard Variable, Pretendard, system-ui, sans-serif",linkIdle:"rgba(118, 127, 138, 0.42)",linkConnected:"#a2abb6",linkDimmed:"rgba(118, 127, 138, 0.1)",legendHub:"#d6dce3"};function D(s){return s==="dark"?le:ie}function de(s,a){const r=D(s),{connections:g,colorIndex:y,selectedNodeId:d,nodeId:b,isConnected:c}=a,h=d===b;return d!==null&&!h&&!c?g>3?r.nodeHubDimmed:r.nodeDimmed[y%r.nodeDimmed.length]:h?r.nodeSelected:c?r.nodeConnected:g>3?r.nodeHub:r.nodeDefault[y%r.nodeDefault.length]}function ce(s,a){const r=D(s);return a.selectedNodeId!==null&&!a.isConnected?r.linkDimmed:a.isConnected?r.linkConnected:r.linkIdle}function ue(s,a){const r=D(s);return`${a.emphasize?"700":"400"} ${a.fontSize}px ${r.labelFontFamily}`}function z(s){return s<=1?3.5:s<=3?4.5:s<=6?5.5:Math.min(7,5.5+Math.sqrt(s)*.5)}const fe=t.jsx(C,{title:"Knowledge Graph",description:t.jsx(G,{width:184,height:16,className:"rounded-full"}),children:t.jsx("div",{className:"flex h-[600px] items-center justify-center",children:t.jsx(G,{width:"100%",height:"100%"})})});function he(){const s=Y(),a=i.useRef(null),r=i.useRef(null),[g,y]=i.useState({width:800,height:600}),[d,b]=i.useState(null),{theme:c}=J(e=>e),h=D(c),v=i.useRef(h);v.current=h;const{data:w}=X({queryKey:ne.notes.graph(),queryFn:async()=>{const e=await ee();if(e.type==="error")throw e;return e.noteGraph}}),l=i.useMemo(()=>{if(w.nodes.length===0)return null;const e=w.nodes.filter(o=>o.connections>0);if(e.length===0)return null;const n=new Set(e.map(o=>o.id));return{nodes:e,links:w.links.filter(o=>n.has(o.source)&&n.has(o.target))}},[w]);i.useEffect(()=>{if(!l)return;const e=()=>{if(!a.current)return;const n=a.current.getBoundingClientRect();y({width:n.width,height:Math.max(600,window.innerHeight-150)})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[l]),i.useEffect(()=>{if(!l||!r.current)return;const e=window.setTimeout(()=>{r.current?.zoomToFit(400,50)},500);return()=>window.clearTimeout(e)},[l]);const R=i.useRef(d);R.current=d;const B=i.useCallback(e=>{if(R.current===e.id){s({to:te,params:{id:e.id}});return}b(e.id)},[s]),L=i.useCallback(()=>{b(null)},[]),K=i.useCallback(e=>{a.current&&(a.current.style.cursor=e?"pointer":"default")},[]),I=i.useRef(!1),$=i.useCallback(()=>{I.current||(I.current=!0,r.current?.enableZoomInteraction(!1))},[]),q=i.useCallback(()=>{I.current=!1,r.current?.enableZoomInteraction(!0)},[]),H=i.useRef(new Map),A=i.useMemo(()=>{const e=new Map;if(l)for(const n of l.links)e.has(n.source)||e.set(n.source,new Set),e.has(n.target)||e.set(n.target,new Set),e.get(n.source)?.add(n.target),e.get(n.target)?.add(n.source);return e},[l]);H.current=A;const O=i.useCallback((e,n,o)=>{const u=v.current,f=d,p=H.current,m=z(e.connections),x=e.x||0,S=e.y||0,k=f===e.id,T=f?p.get(f)?.has(e.id)??!1:!1,V=f!==null&&!k&&!T,W=ae(e.id);if(n.beginPath(),n.arc(x,S,m,0,Math.PI*2),n.fillStyle=de(c,{connections:e.connections,colorIndex:W,selectedNodeId:f,nodeId:e.id,isConnected:T}),n.fill(),V)return;n.strokeStyle=u.nodeStroke,n.lineWidth=(k?2:1)/o,n.stroke(),k&&(n.beginPath(),n.arc(x,S,m+2/o,0,Math.PI*2),n.strokeStyle=u.nodeSelectedStroke,n.lineWidth=1.5/o,n.stroke());const Q=T&&e.connections>=4;if(k||Q||o>2.5){const P=e.title||"Untitled",E=Math.max(10/o,2.5);n.font=ue(c,{fontSize:E,emphasize:k}),n.textAlign="center",n.textBaseline="top";const M=n.measureText(P).width,j=2/o,F=S+m+3/o;n.fillStyle=u.labelBackground,n.fillRect(x-M/2-j,F,M+j*2,E+j*2),n.fillStyle=u.labelText,n.fillText(P,x,F+j)}},[d,c]),Z=i.useCallback((e,n,o)=>{const u=d,f=e.source,p=e.target,m=u?f.id===u||p.id===u:!1;n.beginPath(),n.moveTo(f.x||0,f.y||0),n.lineTo(p.x||0,p.y||0),n.strokeStyle=ce(c,{selectedNodeId:u,isConnected:m}),n.lineWidth=m?2/o:.5/o,n.stroke()},[d,c]);return l?t.jsx(C,{title:"Knowledge Graph",description:`${l.nodes.length} linked notes, ${l.links.length} connections`,children:t.jsxs("div",{ref:a,className:"surface-base graph-canvas relative overflow-hidden",style:{"--graph-bg":h.background},children:[d&&(()=>{const e=l.nodes.find(n=>n.id===d);return e?t.jsxs("div",{className:"surface-floating absolute top-3 left-3 z-10 flex items-center gap-2 px-3 py-2",children:[t.jsx(N,{as:"span",variant:"meta",weight:"semibold",truncate:!0,className:"max-w-48",children:e.title}),t.jsxs(N,{as:"span",variant:"label",tone:"tertiary",children:[e.connections," links"]}),t.jsx("button",{type:"button",onClick:()=>b(null),className:"focus-ring-soft ml-1 flex h-6 w-6 cursor-pointer items-center justify-center rounded-[8px] text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default","aria-label":"Deselect node",children:t.jsx(oe,{className:"h-3.5 w-3.5"})})]}):null})(),t.jsxs("div",{className:"surface-floating absolute top-3 right-3 z-10 flex flex-col gap-1.5 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"legend-dot h-2.5 w-2.5 shrink-0 rounded-full",style:{"--legend-color":h.legendHub}}),t.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Hub notes (4+ connections)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"legend-dot h-2.5 w-2.5 shrink-0 rounded-full",style:{"--legend-color":h.nodeConnected}}),t.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Connected notes"})]})]}),t.jsx(se,{ref:r,graphData:l,width:g.width,height:g.height,nodeId:"id",nodeLabel:"",nodeCanvasObject:O,nodePointerAreaPaint:(e,n,o)=>{o.beginPath(),o.arc(e.x||0,e.y||0,Math.max(z(e.connections)+4,10),0,2*Math.PI),o.fillStyle=n,o.fill()},linkCanvasObject:Z,linkCanvasObjectMode:()=>"replace",linkDirectionalParticles:0,onNodeClick:B,onNodeHover:K,onBackgroundClick:L,onNodeDrag:$,onNodeDragEnd:q,warmupTicks:30,cooldownTicks:80,d3AlphaDecay:.05,d3VelocityDecay:.3,enableZoomInteraction:!0,enablePanInteraction:!0,minZoom:.3,maxZoom:5})]})}):t.jsx(C,{title:"Knowledge Graph",description:"0 linked notes, 0 connections",children:t.jsx(re,{title:"No constellations yet",description:"Link your notes together and watch your own starry sky unfold"})})}function ke(){return t.jsx(_,{fallback:fe,errorTitle:"Failed to load graph",errorDescription:"Retry loading your linked note constellation",renderError:({error:s,retry:a})=>t.jsx(C,{title:"Knowledge Graph",children:t.jsx(U,{title:"Failed to load graph",description:"Retry loading your linked note constellation",error:s,onRetry:a})}),children:t.jsx(he,{})})}export{ke as default};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import{j as e,i as _e,k as zt,U as tt,y as at,v as Yt,X as Kt,F as Qt}from"./note-vendor-i1M2FSI2.js";import{ae as Gt,p as Pe,T as x,c as z,M as R,r as ue,B as S,w as $e,u as Ye,af as Wt,q as k,ag as Jt,ah as Xt,ai as ea,d as q,W as nt,a5 as rt,aj as ta,l as Se,I as aa,m as na,n as ra,o as Re,g as sa,ak as oa,_ as st,D as ot,k as lt,al as it,am as la,an as ct,a3 as dt,N as ge,ac as ia,x as ca,ao as da,a4 as ua,ap as Ve,aq as Fe,$ as Oe,P as Ie,a2 as Be,ar as pa,as as fa,at as ma,au as ha,av as Ke,aw as xa,i as oe,L as ga,j as ya,ax as va,ay as ba,az as Qe}from"./index-BvKBTjQq.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{C as Ge,m as wa}from"./Callout-C6tVCxOT.js";import{S as ja}from"./SurfaceCard-CO0oVxeL.js";import{u as Na,R as Ca}from"./useReminderMutate-D21PurIS.js";import{n as Aa}from"./Plus.es-EcmtS_uw.js";import{u as ka}from"./image.api-DeF9ck7g.js";import{A as Sa,G as Ra,a3 as ut,a4 as Ea}from"./note-core-Z6kqulGB.js";function Ma(t,n){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const r=!!(t.condition??!0),l=t.blockerFn;return{shouldBlockFn:async()=>r&&l!==void 0?await l():r,enableBeforeUnload:r,withResolver:l===void 0}}function Ta(t,n){const{shouldBlockFn:r,enableBeforeUnload:l=!0,disabled:o=!1,withResolver:d=!1}=Ma(t),i=Gt(),{history:u}=i,[c,m]=a.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return a.useEffect(()=>{const p=async j=>{function w(H){const N=i.parseLocation(H),v=i.getMatchedRoutes(N.pathname);return v.foundRoute===void 0?{routeId:"__notFound__",fullPath:N.pathname,pathname:N.pathname,params:v.routeParams,search:i.options.parseSearch(H.search)}:{routeId:v.foundRoute.id,fullPath:v.foundRoute.fullPath,pathname:N.pathname,params:v.routeParams,search:i.options.parseSearch(H.search)}}const y=w(j.currentLocation),A=w(j.nextLocation);if(y.routeId==="__notFound__"&&A.routeId!=="__notFound__")return!1;const f=await r({action:j.action,current:y,next:A});if(!d)return f;if(!f)return!1;const U=await new Promise(H=>{m({status:"blocked",current:y,next:A,action:j.action,proceed:()=>H(!1),reset:()=>H(!0)})});return m({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),U};return o?void 0:u.block({blockerFn:p,enableBeforeUnload:l})},[r,l,o,d,u,i]),c}const Ha=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40V168H168V88H88V40Z",opacity:"0.2"}),a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Zm-8,128H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,36H88a4,4,0,0,0-4,4V84H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H168a4,4,0,0,0,4-4V172h44a4,4,0,0,0,4-4V40A4,4,0,0,0,216,36ZM164,212H44V92H164Zm48-48H172V88a4,4,0,0,0-4-4H92V44H212Z"}))]]),Da=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),a.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM152,88V44l44,44Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Z"}))]]),La=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M87.5,151.52l64-64a12,12,0,0,1,17,17l-64,64a12,12,0,0,1-17-17Zm131-114a60.08,60.08,0,0,0-84.87,0L103.51,67.61a12,12,0,0,0,17,17l30.07-30.06a36,36,0,0,1,50.93,50.92L171.4,135.52a12,12,0,1,0,17,17l30.08-30.06A60.09,60.09,0,0,0,218.45,37.55ZM135.52,171.4l-30.07,30.08a36,36,0,0,1-50.92-50.93l30.06-30.07a12,12,0,0,0-17-17L37.55,133.58a60,60,0,0,0,84.88,84.87l30.06-30.07a12,12,0,0,0-17-17Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M209.94,113.94l-96,96a48,48,0,0,1-67.88-67.88l96-96a48,48,0,0,1,67.88,67.88Z",opacity:"0.2"}),a.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM144.56,173.66l-21.45,21.45a44,44,0,0,1-62.22-62.22l21.45-21.46a8,8,0,0,1,11.32,11.31L72.2,144.2a28,28,0,0,0,39.6,39.6l21.45-21.46a8,8,0,0,1,11.31,11.32Zm-34.9-16a8,8,0,0,1-11.32-11.32l48-48a8,8,0,0,1,11.32,11.32Zm85.45-34.55-21.45,21.45a8,8,0,0,1-11.32-11.31L183.8,111.8a28,28,0,0,0-39.6-39.6L122.74,93.66a8,8,0,0,1-11.31-11.32l21.46-21.45a44,44,0,0,1,62.22,62.22Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M164.25,91.75a6,6,0,0,1,0,8.49l-64,64a6,6,0,0,1-8.49-8.48l64-64A6,6,0,0,1,164.25,91.75ZM214.2,41.8a54.07,54.07,0,0,0-76.38,0L107.75,71.85a6,6,0,0,0,8.49,8.49l30.07-30.06a42,42,0,0,1,59.41,59.41l-30.08,30.07a6,6,0,1,0,8.49,8.49l30.07-30.07A54,54,0,0,0,214.2,41.8ZM139.76,175.64l-30.07,30.08a42,42,0,0,1-59.41-59.41l30.06-30.07a6,6,0,0,0-8.49-8.49l-30,30.07a54,54,0,0,0,76.38,76.39l30.07-30.08a6,6,0,0,0-8.49-8.49Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M162.84,93.16a4,4,0,0,1,0,5.66l-64,64a4,4,0,0,1-5.66-5.66l64-64A4,4,0,0,1,162.84,93.16Zm49.95-49.95a52.07,52.07,0,0,0-73.56,0L109.17,73.27a4,4,0,0,0,5.65,5.66l30.07-30.06a44,44,0,0,1,62.24,62.24l-30.07,30.06a4,4,0,0,0,5.66,5.66l30.07-30.06A52.07,52.07,0,0,0,212.79,43.21ZM141.17,177.06l-30.06,30.07a44,44,0,0,1-62.24-62.24l30.06-30.06a4,4,0,0,0-5.66-5.66L43.21,139.23a52,52,0,0,0,73.56,73.56l30.06-30.07a4,4,0,1,0-5.66-5.66Z"}))]]),pt=a.forwardRef((t,n)=>a.createElement(Pe,{ref:n,...t,weights:Ha}));pt.displayName="CopyIcon";const Va=pt,ft=a.forwardRef((t,n)=>a.createElement(Pe,{ref:n,...t,weights:Da}));ft.displayName="FileIcon";const Fa=ft,mt=a.forwardRef((t,n)=>a.createElement(Pe,{ref:n,...t,weights:La}));mt.displayName="LinkSimpleIcon";const Oa=mt;function Ue({icon:t,title:n,className:r}){return e.jsxs("div",{className:z("flex items-center gap-2",r),children:[e.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-current",children:t}),e.jsx(x,{as:"span",variant:"label",weight:"semibold",className:"text-current",children:n})]})}function ce({title:t,description:n,selected:r=!1,onClick:l,children:o}){return e.jsxs("button",{type:"button","aria-pressed":r,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${r?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:l,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(x,{as:"div",variant:"body",weight:"semibold",tone:r?"default":"secondary",children:t}),e.jsx(x,{as:"div",variant:"meta",weight:"medium",tone:r?"secondary":"tertiary",className:"mt-1",children:n})]}),o?e.jsx("div",{className:"shrink-0",children:o}):null]})}const Ba=[{value:"narrow",label:"Narrow",description:"Optimized for reading long-form content"},{value:"wide",label:"Wide",description:"Balanced width suitable for most content"},{value:"full",label:"Full Width",description:"Maximize screen space utilization"}];function _a({isOpen:t,onClose:n,onSave:r,currentLayout:l="wide"}){const[o,d]=a.useState(l);a.useEffect(()=>{t&&d(l)},[t,l]);const i=()=>{r(o),n()};return e.jsxs(R,{isOpen:t,onClose:n,variant:"compact",children:[e.jsx(R.Header,{title:"Layout Settings",onClose:n}),e.jsx(R.Body,{children:e.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(x,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),e.jsx("div",{className:"flex flex-col gap-2",children:Ba.map(u=>e.jsx(ce,{title:u.label,description:u.description,selected:o===u.value,onClick:()=>d(u.value)},u.value))})]})})}),e.jsx(R.Footer,{children:e.jsxs(ue,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:i,children:"Apply"})]})})]})}const ht=t=>t==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:t==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},Pa=({isDeleted:t,isConflict:n,source:r})=>{const l=ht(r);return t?`This note was moved to trash ${l.place}`:n?`Save paused: note changed ${l.place}`:`This note changed ${l.place}`},$a=({isDeleted:t,isConflict:n,hasDraft:r,source:l})=>{const o=ht(l);return t?`${o.actor} moved this note to trash. Open trash to review or restore it.`:n&&r?`Your draft is saved locally. Reload the latest note, overwrite ${o.target}, or clone your draft into a new note.`:n?`The layout change is paused because the note changed ${o.place}. Reload the latest note or overwrite only the layout.`:`${o.actor} changed this note while it was open here. Reload the latest version before continuing.`};function Ia({isOpen:t,isDeleted:n,isConflict:r,hasDraft:l,source:o,isReloading:d,onReload:i,onOverwrite:u,onCloneDraft:c,onOpenTrash:m}){return e.jsxs(R,{isOpen:t,onClose:()=>{},variant:"inspect",children:[e.jsx(R.Header,{title:Pa({isDeleted:n,isConflict:r,source:o})}),e.jsx(R.Body,{children:e.jsx(x,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:$a({isDeleted:n,isConflict:r,hasDraft:l,source:o})})}),e.jsx(R.Footer,{children:e.jsx(ue,{children:n?e.jsx(S,{type:"button",variant:"primary",size:"sm",onClick:m,children:"Open trash"}):r?e.jsxs(e.Fragment,{children:[e.jsx(S,{type:"button",variant:"subtle",size:"sm",isLoading:d,onClick:i,children:"Reload latest"}),l&&e.jsx(S,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Clone draft"}),e.jsx(S,{type:"button",variant:"danger",size:"sm",onClick:u,children:"Overwrite"})]}):e.jsx(S,{type:"button",variant:"primary",size:"sm",isLoading:d,onClick:i,children:"Reload latest"})})})]})}const We=(t,n)=>t||(n==="mobile"?"Mobile browser":n==="mcp"?"MCP":"Web browser");function Ua({isOpen:t,noteId:n,onClose:r,onRestored:l}){const o=nt(),d=$e(),[i,u]=a.useState(null),c=a.useRef(null),m=Ye({queryKey:k.notes.snapshots(n),queryFn:async()=>{const f=await Wt(n);if(f.type==="error")throw f;return f.noteSnapshots},enabled:t}),p=Jt({mutationFn:Xt,onSuccess:async f=>{if(f.type==="error"){o(f.errors[0].message);return}await Promise.all([d.invalidateQueries({queryKey:k.notes.detail(n),exact:!0}),d.invalidateQueries({queryKey:k.notes.listAll(),exact:!1}),d.invalidateQueries({queryKey:k.notes.tagListAll(),exact:!1}),d.invalidateQueries({queryKey:k.notes.tagNameListAll(),exact:!1}),d.invalidateQueries({queryKey:k.notes.pinned(),exact:!0}),d.invalidateQueries({queryKey:k.notes.backReferencesAll(),exact:!1}),d.invalidateQueries({queryKey:k.notes.graph(),exact:!0}),d.invalidateQueries({queryKey:k.notes.snapshots(n),exact:!1}),d.invalidateQueries({queryKey:k.views.sectionNotesAll(),exact:!1}),d.invalidateQueries({queryKey:k.tags.all(),exact:!1})]),o("Previous version restored."),l?.(f.restoreNoteSnapshot),u(null),r()}}),j=m.data?.find(f=>f.id===i)??null,w=Ye({queryKey:k.notes.snapshotDetail(i??"pending"),queryFn:async()=>{if(!i)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await ea(i);if(f.type==="error")throw f;if(!f.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return f.noteSnapshot},enabled:!!i}),y=w.data?.contentAsMarkdown.trim()??"";a.useEffect(()=>{i&&c.current?.focus()},[i]);const A=()=>{u(null),r()};return e.jsxs(R,{isOpen:t,onClose:A,variant:"inspect",children:[e.jsx(R.Header,{title:j?"Snapshot Content":"Restore Previous Version",onClose:A}),e.jsx(R.Description,{className:"sr-only",children:j?"Read this snapshot content before restoring it.":"Choose a previous snapshot to restore."}),e.jsx(R.Body,{children:j?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(x,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:j.title}),e.jsxs(x,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",We(j.meta.label,j.meta.entrypoint)," ","edit - ",q(j.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),w.isLoading?e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot content..."}):w.isError?e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot content could not be loaded."}):y?e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:y}):e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this snapshot."})]}):e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(x,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),m.isLoading&&e.jsx(x,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!m.isLoading&&m.data?.length===0&&e.jsx(x,{as:"div",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"A recovery snapshot appears before the first edit in a session. Up to 10 recent snapshots are kept for 7 days, and identical versions are skipped."}),!m.isLoading&&m.data&&m.data.length>0&&e.jsx("div",{className:"flex flex-col gap-2",children:m.data.map(f=>e.jsx(ja,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs(x,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",We(f.meta.label,f.meta.entrypoint)," ","edit"]}),e.jsx(x,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:f.title}),e.jsx(x,{as:"p",variant:"label",tone:"tertiary",children:q(f.createdAt).format("YYYY-MM-DD HH:mm:ss")}),f.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:f.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(S,{variant:"subtle",size:"sm",onClick:()=>u(f.id),children:"View content"}),e.jsx(S,{size:"sm",isLoading:p.isPending,onClick:()=>p.mutate(f.id),children:"Restore"})]})]})},f.id))})]})}),j&&e.jsx(R.Footer,{children:e.jsxs(ue,{children:[e.jsx(S,{ref:c,variant:"subtle",onClick:()=>u(null),children:"Back"}),e.jsx(S,{disabled:!w.data||w.isError,isLoading:p.isPending,onClick:()=>p.mutate(j.id),children:"Restore this version"})]})})]})}const Za=t=>{const{data:n}=rt({queryKey:k.notes.backReferences(t.noteId),async queryFn(){const r=await ta(t.noteId);if(r.type==="error")throw r;return r.backReferences}});return t.render(n)};let qa="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",za=(t=21)=>{let n="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)n+=qa[r[t]&63];return n};const Je={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function Ya({isOpen:t,onClose:n,onSave:r,reminder:l,mode:o}){const[d,i]=a.useState(new Date),[u,c]=a.useState("medium"),[m,p]=a.useState("");a.useEffect(()=>{t&&o==="edit"&&l?(i(new Date(Number(l.reminderDate))),c(l.priority||"medium"),p(l.content||"")):t&&o==="create"&&(i(new Date),c("medium"),p(""))},[t,o,l]);const j=()=>{r(d,u,m||void 0),n()},w=y=>u===y?Je[y].active:Je[y].inactive;return e.jsxs(R,{isOpen:t,onClose:n,variant:"form",children:[e.jsx(R.Header,{title:o==="create"?"Create Reminder":"Edit Reminder",onClose:n}),e.jsx(R.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Se,{children:"Date & Time"}),e.jsx(aa,{type:"datetime-local",size:"sm",value:q(d).format("YYYY-MM-DDTHH:mm"),onChange:y=>i(new Date(y.target.value))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Se,{children:"Content"}),e.jsx(na,{size:"sm",placeholder:"Enter reminder content (optional)",value:m,onChange:y=>p(y.target.value)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(Se,{children:"Priority"}),e.jsxs(ra,{type:"single",variant:"quiet",value:u,onValueChange:y=>y&&c(y),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[e.jsx(Re,{value:"low",className:`flex-1 rounded-[10px] border ${w("low")}`,children:e.jsx(x,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),e.jsx(Re,{value:"medium",className:`flex-1 rounded-[10px] border ${w("medium")}`,children:e.jsx(x,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),e.jsx(Re,{value:"high",className:`flex-1 rounded-[10px] border ${w("high")}`,children:e.jsx(x,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),e.jsx(R.Footer,{children:e.jsxs(ue,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:j,children:o==="create"?"Create":"Save"})]})})]})}function Ka({noteId:t}){const[n,r]=a.useState(!1),[l,o]=a.useState(!1),[d,i]=a.useState("create"),[u,c]=a.useState(void 0),{onCreate:m,onUpdate:p,onDelete:j}=Na(),w=()=>{i("create"),c(void 0),o(!0)},y=N=>{i("edit"),c(N),o(!0)},A=(N,v,g)=>{d==="create"?m(t,N,v,()=>{o(!1)},g):d==="edit"&&u&&p(u.id,t,{reminderDate:N,priority:v,content:g},()=>{o(!1)})},f=N=>{p(N.id,t,{completed:!N.completed})},T=N=>{const v=q(Number(N)),g=q();return v.isSame(g,"day")?`Today at ${v.format("HH:mm")}`:v.isSame(g.add(1,"day"),"day")?`Tomorrow at ${v.format("HH:mm")}`:v.format("YYYY-MM-DD HH:mm")},U=N=>{const v=q(Number(N)),g=q(),V=v.diff(g,"hour");return V<=6?"high":V<=24?"medium":"low"},H=N=>{const v=q(Number(N)),g=q(),V=v.diff(g,"hour"),F=v.diff(g,"minute")%60;return V<0||F<0?"Overdue":V===0?`${F}m remaining`:`${V}h ${F}m remaining`};return e.jsxs("div",{className:"surface-base mb-5 p-4",children:[e.jsxs("div",{className:z("flex items-center justify-between",!n&&"mb-3"),children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"focus-ring-soft flex items-center gap-2 rounded-[10px] px-2 py-1.5 text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:e.jsx(Ue,{icon:n?e.jsx(sa,{size:12}):e.jsx(oa,{size:12}),title:"Reminders"})}),!n&&e.jsxs(S,{size:"sm",variant:"ghost",onClick:w,children:[e.jsx(Aa,{className:"w-3 h-3"}),e.jsx(x,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]})]}),!n&&e.jsx(Ca,{noteId:t,searchParams:{offset:0,limit:9999},render:({reminders:N,totalCount:v})=>e.jsx("div",{className:"flex flex-col gap-2",children:N.length===0?e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:v===0?"No reminders yet":"All reminders complete"}):e.jsx("div",{className:"flex flex-col",children:N.map(g=>{const V=g.priority||U(g.reminderDate),F=H(g.reminderDate),E=F==="Overdue";return e.jsxs("div",{className:z("flex items-center gap-2.5 px-2 py-1.5"),children:[e.jsx(st,{checked:g.completed,onChange:()=>f(g),size:"sm"}),e.jsx(x,{as:"div",variant:"body",weight:"medium",className:z("truncate flex-1 min-w-0",g.completed&&"line-through opacity-40"),children:g.content||T(g.reminderDate)}),e.jsxs("div",{className:z("shrink-0 flex items-center gap-1",g.completed&&"opacity-40"),children:[g.content&&e.jsx(x,{as:"span",variant:"meta",tone:"secondary",children:T(g.reminderDate)}),!g.completed&&e.jsx(x,{as:"span",variant:"label",weight:"medium",tone:E||V==="high"?"error":"tertiary",className:z(g.content&&'before:content-["·"] before:mr-1'),children:F})]}),e.jsx(ot,{button:e.jsx(lt,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>y(g)},{name:"Delete",onClick:()=>j(g.id,t)}]})]},g.id)})})})}),e.jsx(Ya,{isOpen:l,onClose:()=>o(!1),onSave:A,reminder:u,mode:d})]})}const Qa=({editor:t})=>e.jsx(_e,{triggerCharacter:"/",getItems:async n=>Sa([...zt(t).filter(r=>r.title!=="Audio"&&r.title!=="Video"&&r.title!=="File"),{title:"Table of Contents",subtext:"Insert a table of contents based on headings",onItemClick:()=>{t.insertBlocks([{type:"tableOfContents"}],t.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:e.jsx(it,{})}],n)}),Ga=(t,n)=>n?t.filter(r=>r.id!==n):t,Wa=({currentNoteId:t,onClick:n})=>e.jsx(_e,{triggerCharacter:"[",getItems:async r=>{const l=await la({query:r,limit:5});return l.type==="error"?[]:Ga(l.allNotes.notes,t).map(d=>({title:d.title,onItemClick:()=>n({type:"reference",props:{id:d.id,title:d.title}})}))}}),Ja="pointer-events-auto inline-flex h-7 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-white/10 bg-white/10 px-2.5 text-xs font-medium text-white/60 opacity-75 shadow-[0_8px_18px_-14px_rgba(0,0,0,0.45)] backdrop-blur-sm transition-colors hover:bg-white/20 hover:text-white/90 hover:opacity-100 focus-ring-soft focus:text-white/90 focus:opacity-100",Xa={idle:"",copied:"text-accent-success hover:text-accent-success focus:text-accent-success",failed:"text-fg-error hover:text-fg-error focus:text-fg-error"},en={idle:"Copy",copied:"Copied",failed:"Copy failed"},tn=({getText:t,resetDelayMs:n=2e3})=>{const[r,l]=a.useState("idle"),o=a.useRef(null),d=a.useCallback(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),i=a.useCallback(()=>{d(),o.current=setTimeout(()=>{l("idle"),o.current=null},n)},[d,n]);a.useEffect(()=>d,[d]);const u=p=>{p.stopPropagation()},c=p=>{p.preventDefault(),p.stopPropagation()},m=async p=>{u(p);try{await navigator.clipboard.writeText(t()),l("copied")}catch{l("failed")}i()};return e.jsx("div",{className:"pointer-events-none absolute right-3 top-2 z-[1]",contentEditable:!1,onMouseDown:c,children:e.jsxs("button",{type:"button",className:z(Ja,Xa[r]),contentEditable:!1,onClick:m,children:[e.jsx(Va,{className:"h-3.5 w-3.5"}),e.jsx("span",{"aria-live":"polite",children:en[r]})]})})},an=({contentRef:t})=>{const n=a.useRef(null),r=a.useCallback(l=>{n.current=l,t(l)},[t]);return e.jsxs(e.Fragment,{children:[e.jsx("pre",{children:e.jsx("code",{ref:r})}),e.jsx(tn,{getText:()=>n.current?.textContent?.trimEnd()??""})]})},nn="_Reference_102im_1",rn={Reference:nn},sn=ct.bind(rn),on={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function ln(t){const n=dt(),r=()=>{t.editor.blur(),n({to:ge,params:{id:t.inlineContent.props.id}})},l=o=>{o.preventDefault(),o.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:sn("Reference"),onMouseDown:l,onClick:o=>{l(o),r()},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(l(o),r())},children:e.jsxs("span",{children:["[",t.inlineContent.props.title,"]"]})})}const cn=tt(on,{render:t=>e.jsx(ln,{...t})}),dn=()=>{const t=Yt(),[n,r]=a.useState([]),l={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};a.useEffect(()=>{const i=()=>{const c=t.document,m=[],p=j=>{for(const w of j){if(w.type==="heading"){const y=w,A=y.props.level||1,f=y.content?.map(T=>T.text||"").join("")||"";f.trim()&&m.push({id:w.id,level:A,text:f})}w.children&&Array.isArray(w.children)&&p(w.children)}};p(c),r(m)};i();const u=t.onChange?.(i);return()=>{u&&u()}},[t]);const o=i=>{t.setTextCursorPosition(i);const u=document.querySelector(`[data-id="${i}"]`);u&&u.scrollIntoView({behavior:"smooth",block:"center"})},d=e.jsx(Ue,{icon:e.jsx(it,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return n.length===0?e.jsxs("div",{className:"surface-base w-full p-4",children:[d,e.jsx(x,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):e.jsxs("div",{className:"surface-base w-full p-4",children:[e.jsx("div",{className:"mb-2",children:d}),e.jsx("nav",{className:"space-y-0.5",children:n.map(i=>{const u=i.level===1;return e.jsxs("button",{type:"button",onClick:()=>o(i.id),className:z("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",l[i.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",u?"text-fg-default":"text-fg-secondary"),children:[e.jsxs(x,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",i.level]}),e.jsx(x,{as:"span",variant:"body",weight:u?"semibold":"medium",className:"line-clamp-2 text-current",children:i.text})]},i.id)})})]})},un=at({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>e.jsx(dn,{})})(),pn="_Tag_1gb8h_1",fn={Tag:pn},mn=ct.bind(fn),hn={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function xn(t){const n=dt(),r=()=>{t.editor.blur(),n({to:ia,params:{id:t.inlineContent.props.id},search:{page:1}})},l=o=>{o.preventDefault(),o.stopPropagation()};return e.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:mn("Tag"),onMouseDown:l,onClick:o=>{l(o),r()},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(l(o),r())},children:e.jsx("span",{children:t.inlineContent.props.tag})})}const gn=tt(hn,{render:t=>e.jsx(xn,{...t})}),yn=t=>t,vn=t=>t,bn=yn({tag:gn,reference:cn}),wn=vn({tableOfContents:un}),ae=ut.codeBlock,Xe=at(ae.config,{meta:ae.implementation.meta,parse:ae.implementation.parse,parseContent:ae.implementation.parseContent,runsBefore:ae.implementation.runsBefore,render:an})(),jn={...Xe,extensions:ae.extensions,implementation:{...Xe.implementation,toExternalHTML:ae.implementation.toExternalHTML}},Nn=Ra.create({inlineContentSpecs:{...Ea,...bn},blockSpecs:{...ut,codeBlock:jn,...wn}}),Cn=(t,n)=>n.some(r=>r.name===`@${t}`),An=({onClick:t})=>e.jsx(_e,{triggerCharacter:"@",getItems:async n=>{const r=await ca({query:n,limit:5});if(r.type==="error")return[];const{tags:l}=r.allTags,o=Cn(n,l),d=[{title:"Add a new tag",onItemClick:async()=>{const i=await da({name:"@"+n});if(i.type==="error")return;const{id:u,name:c}=i.createTag;t({type:"tag",props:{id:u,tag:c}})}}];return l.length===0?d:l.map(i=>({title:i.name,onItemClick:()=>t({type:"tag",props:{id:i.id,tag:i.name}})})).concat(n&&!o?d:[])}}),kn=new Set(["tableOfContents"]),Sn="OCEAN_BRAIN_TAG_",Rn="_TOKEN",En=t=>`${Sn}${t}${Rn}`,Mn=t=>!Array.isArray(t)&&t?.type==="tableContent",Tn=(t,n)=>Array.isArray(t)?t.map(n):Mn(t)?{...t,rows:t.rows?.map(r=>({...r,cells:r.cells?.map(l=>({...l,content:l.content?.map(n)}))}))}:t,xt=(t,n)=>t.filter(r=>!kn.has(r.type)).map(r=>({...r,content:n(r.content),children:r.children?.length?xt(r.children,n):[]}));function Hn(t){const n=new Map;let r=0;return{blocks:xt(t,o=>Tn(o,d=>{if(d.type==="reference")return{type:"text",text:`[[${d.props?.title||d.props?.id||""}]]`,styles:{}};if(d.type==="tag"){const i=d.props?.tag||"",u=En(r);return r+=1,n.set(u,i),{type:"text",text:u,styles:{}}}return d})),placeholderToTag:n}}function Dn(t,n){let r=t;for(const[l,o]of n.entries())r=r.split(l).join(`[${o}]`);return r}async function Ln(t){return new Promise((n,r)=>{const l=new FileReader;l.readAsDataURL(t),l.onload=()=>n(l.result),l.onerror=o=>r(o)})}const Vn=a.forwardRef(({content:t,currentNoteId:n,editable:r,onChange:l},o)=>{const{theme:d}=ua(u=>u),i=Kt({schema:Nn,initialContent:t&&JSON.parse(t)||void 0,uploadFile:async u=>ka({base64:await Ln(u)})},[]);return a.useImperativeHandle(o,()=>({getContent:()=>JSON.stringify(i.document),getMarkdown:()=>{const u=Hn(i.document),c=i.blocksToMarkdownLossy(u.blocks);return Dn(c,u.placeholderToTag)},getHtml:()=>i.blocksToHTMLLossy(i.document)})),e.jsxs(Qt,{slashMenu:!1,theme:d,editor:i,editable:r,onChange:l,children:[e.jsx(Qa,{editor:i}),e.jsx(Wa,{currentNoteId:n,onClick:u=>{i.insertInlineContent([u," "])}}),e.jsx(An,{onClick:u=>{i.insertInlineContent([u," "])}})]})}),Ze=t=>`ocean-brain.note-draft.${t}`,Fn=t=>{if(typeof window>"u")return null;try{const n=window.localStorage.getItem(Ze(t));if(!n)return null;const r=JSON.parse(n);return typeof r.title!="string"||typeof r.content!="string"||typeof r.baseUpdatedAt!="string"?null:{title:r.title,content:r.content,baseUpdatedAt:r.baseUpdatedAt,createdAt:typeof r.createdAt=="number"?r.createdAt:Date.now(),...r.layout==="narrow"||r.layout==="wide"||r.layout==="full"?{layout:r.layout}:{}}}catch{return null}},Ee=(t,n)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ze(t),JSON.stringify(n))}catch{}},Me=t=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Ze(t))}catch{}},On=1e3,Bn="NOTE_UPDATE_CONFLICT";function _n({noteId:t,initialContent:n,initialUpdatedAt:r,editSessionIdRef:l,getContent:o,onSaved:d,onConflict:i,onError:u}){const c=$e(),m=a.useRef(null),p=a.useRef(null),j=a.useRef(!1),w=a.useRef(null),y=a.useRef(!1),A=a.useRef(r),f=a.useRef(!1),T=a.useRef(!0),U=a.useRef(d),H=a.useRef(i),N=a.useRef(u),[v,g]=a.useState("saved"),[V,F]=a.useState(null),E=a.useCallback(()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},[]),O=a.useCallback(C=>{T.current&&g(C)},[]),X=a.useCallback(C=>{A.current=C},[]),ne=a.useCallback((C,M={})=>({title:C,content:o()??n,createdAt:Date.now(),baseUpdatedAt:A.current,...M.layout?{layout:M.layout}:{}}),[o,n]),re=a.useCallback(()=>{p.current&&Ee(t,p.current)},[t]),G=a.useCallback(C=>{f.current=!0,O("conflict"),H.current(C??A.current)},[O]),Y=a.useCallback(async({ignoreConflict:C=!1,silent:M=!1}={})=>{if(j.current)return y.current=!0,w.current??"idle";const D=p.current;if(!D)return y.current=!1,"idle";p.current=null,y.current=!1,E(),j.current=!0,M||O("saving");const I=(async()=>{let B;try{B=await Ve({id:t,title:D.title,content:D.content,...D.layout?{layout:D.layout}:{},editSessionId:l.current,...C?{force:!0}:{expectedUpdatedAt:D.baseUpdatedAt}})}catch{B={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(j.current=!1,w.current=null,B.type==="error"){p.current||(p.current=D),re();const K=B.errors[0];if(K.code===Bn&&!C){const b=K.details?.extensions?.currentUpdatedAt;return f.current=!0,!M&&T.current&&(O("conflict"),H.current(b??A.current)),"conflict"}return!M&&T.current&&(O("error"),N.current(K.message)),"error"}f.current=!1,A.current=B.updateNote.updatedAt;const _=!M&&T.current,te=k.notes.detail(t);await c.cancelQueries({queryKey:te,exact:!0}),_&&U.current(B.updateNote.updatedAt),c.setQueryData(te,K=>K&&{...K,title:B.updateNote.title,content:D.content,...D.layout?{layout:D.layout}:{},updatedAt:B.updateNote.updatedAt}),Fe({noteId:t,updatedAt:B.updateNote.updatedAt,editSessionId:l.current});const P=p.current;return P?.baseUpdatedAt===D.baseUpdatedAt?(p.current={...P,baseUpdatedAt:B.updateNote.updatedAt},re()):P||Me(t),_&&(p.current?g("pending"):(g("saved"),c.invalidateQueries({queryKey:k.notes.listAll(),exact:!1}),c.invalidateQueries({queryKey:k.notes.tagListAll(),exact:!1}),c.invalidateQueries({queryKey:k.notes.backReferencesAll(),exact:!1}),c.invalidateQueries({queryKey:k.notes.graph(),exact:!0}))),p.current||y.current?Y({silent:M}):"saved"})();return w.current=I,I},[E,l,t,re,c,O]),ee=a.useCallback((C,M={})=>{if(p.current=C,Ee(t,C),f.current){O("conflict");return}if(O("pending"),E(),M.immediate){Y();return}m.current=window.setTimeout(()=>{Y()},On)},[E,Y,t,O]),pe=a.useCallback(C=>{if(p.current=C,Ee(t,C),F(null),C.baseUpdatedAt!==A.current){G(A.current);return}ee(C)},[t,ee,G]),Z=a.useCallback(()=>{E(),p.current=null,w.current=null,y.current=!1,f.current=!1,Me(t),F(null),g("saved")},[E,t]),L=a.useCallback(()=>{E(),w.current=null,y.current=!1,f.current=!1,O(p.current?"pending":"saved")},[E,O]),ve=a.useCallback(()=>{Me(t),F(null)},[t]),se=a.useCallback(()=>p.current,[]),be=a.useCallback(C=>{E(),G(C)},[E,G]);return a.useEffect(()=>{H.current=i,N.current=u,U.current=d},[i,u,d]),a.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]),a.useEffect(()=>{p.current||j.current||f.current||(A.current=r,g("saved"))},[r]),a.useEffect(()=>{p.current=null,j.current=!1,w.current=null,y.current=!1,f.current=!1,A.current=r,F(Fn(t)),g("saved")},[t]),a.useEffect(()=>{const C=M=>{!p.current&&!j.current&&!f.current||(M.preventDefault(),M.returnValue="")};return window.addEventListener("beforeunload",C),()=>{window.removeEventListener("beforeunload",C)}},[]),a.useEffect(()=>()=>{E(),p.current&&!f.current&&Y({silent:!0})},[E,Y]),{saveStatus:v,localDraft:V,serverUpdatedAtRef:A,hasUnsavedChanges:v!=="saved",buildDraft:ne,queueSave:ee,flushPendingSave:Y,restoreLocalDraft:pe,discardLocalDraft:ve,clearDrafts:Z,resolveConflict:L,pauseForConflict:be,getPendingDraft:se,setServerUpdatedAt:X}}const Pn=/[:{}[\],&*#?|<>=!%@`-]/,$n=t=>t.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",In=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),xe=t=>t?Pn.test(t)||/^\s|\s$/.test(t)?JSON.stringify(t):t:'""',ye=t=>{if(!t)return;const n=Number(t);return Number.isFinite(n)?new Date(n).toISOString():t},Te=(t,n)=>`${$n(t)}.${n}`,Un=({id:t,title:n,createdAt:r,updatedAt:l})=>{const o=["---",`title: ${xe(n)}`,`note_id: ${xe(t)}`],d=ye(r),i=ye(l);return d&&o.push(`created_at: ${xe(d)}`),i&&o.push(`updated_at: ${xe(i)}`),o.push("source: ocean-brain","---"),o.join(`
|
|
2
|
-
`)},Zn=(t,n,r=!1)=>r?`${Un(n)}
|
|
3
|
-
|
|
4
|
-
${t}`:t,qn=(t,n,{includeMetadata:r=!1,mode:l="fragment"}={})=>{const o=r?`<!--
|
|
5
|
-
source: ocean-brain
|
|
6
|
-
note_id: ${n.id}
|
|
7
|
-
title: ${n.title}
|
|
8
|
-
created_at: ${ye(n.createdAt)??""}
|
|
9
|
-
updated_at: ${ye(n.updatedAt)??""}
|
|
10
|
-
-->
|
|
11
|
-
`:"";return l==="fragment"?`${o}${t}`:`<!doctype html>
|
|
12
|
-
<html lang="ko">
|
|
13
|
-
<head>
|
|
14
|
-
<meta charset="utf-8" />
|
|
15
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
16
|
-
<title>${In(n.title)}</title>
|
|
17
|
-
</head>
|
|
18
|
-
<body>
|
|
19
|
-
${o}${t}
|
|
20
|
-
</body>
|
|
21
|
-
</html>`},He=(t,n,r)=>{const l=new Blob([t],{type:r}),o=URL.createObjectURL(l),d=document.createElement("a");d.href=o,d.download=n,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(o)},gt=ya(ge),de=t=>{const n=/^\d+$/.test(t)?Number(t):Date.parse(t);return Number.isFinite(n)?n:null},De=t=>{const n=de(t);return q(n??Number(t)).format("YYYY-MM-DD HH:mm:ss")},zn=(t,n)=>va(de(t),n),Le=()=>za(),Yn="NOTE_UPDATE_CONFLICT",Kn=2200,Qn=t=>t?.extensions?.currentUpdatedAt,et=(t,n)=>{const r=de(t),l=de(n);return r===null||l===null?t===n?0:1:r-l},Gn={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},Wn=e.jsx(Ie,{title:"Loading note",variant:"none",children:e.jsxs("main",{className:"mx-auto max-w-[896px]",children:[e.jsx(oe,{className:"mb-8",height:"66px"}),e.jsx(oe,{className:"ml-12 mb-8",height:"150px"}),e.jsx(oe,{className:"mb-5",height:"80px"}),e.jsx(oe,{height:"80px"})]})});function Jn({id:t}){const n=nt(),r=gt.useNavigate(),l=$e(),o=a.useRef(null),d=a.useRef(null),i=a.useRef(Le()),u=rt({queryKey:k.notes.detail(t),queryFn:async()=>{const s=await pa(t);if(s.type==="error")throw s;return s.note},gcTime:0}),c=u.data,[m,p]=a.useState(c.title),[j,w]=a.useState(()=>De(c.updatedAt)),[y,A]=a.useState(c.updatedAt),[f,T]=a.useState(()=>Date.now()),[U,H]=a.useState(c.pinned),[N,v]=a.useState(c.layout||"wide"),[g,V]=a.useState(!1),[F,E]=a.useState(!1),[O,X]=a.useState(!1),[ne,re]=a.useState("markdown"),[G,Y]=a.useState(!1),[ee,pe]=a.useState("fragment"),[Z,L]=a.useState(null),[ve,se]=a.useState(null),[be,C]=a.useState(0),[M,D]=a.useState(!1),I=a.useRef(c.updatedAt),B=a.useRef(t),_=a.useRef(null),te=a.useRef(!1),P=a.useCallback(s=>{w(De(s)),A(s),T(Date.now())},[]),K=_n({noteId:t,initialContent:c.content,initialUpdatedAt:c.updatedAt,editSessionIdRef:i,getContent:()=>o.current?.getContent(),onSaved:s=>{_.current=null,I.current=s,P(s),D(!0)},onConflict:s=>{L({type:"updated",updatedAt:s,source:"unknown"}),n("This note changed elsewhere. Choose how to resolve the draft.")},onError:n}),{saveStatus:b,localDraft:Q,serverUpdatedAtRef:W,hasUnsavedChanges:le,buildDraft:fe,queueSave:me,flushPendingSave:he,restoreLocalDraft:yt,discardLocalDraft:vt,clearDrafts:we,resolveConflict:bt,pauseForConflict:ie,getPendingDraft:je,setServerUpdatedAt:J}=K,wt=a.useCallback(async()=>{if(te.current)return te.current=!1,!1;if(b==="conflict")return n("Resolve the note conflict before leaving."),!0;const s=await he();return s==="error"?(n("Save failed. Stay on this note and try again."),!0):s==="conflict"},[he,b,n]);Ta({disabled:b==="saved",enableBeforeUnload:!1,shouldBlockFn:wt}),a.useEffect(()=>{if(le){c.updatedAt!==W.current&&et(c.updatedAt,W.current)>0&&ie(c.updatedAt);return}const s=I.current;if(!(c.updatedAt!==s&&et(c.updatedAt,s)<0)&&(H(c.pinned),v(c.layout||"wide"),J(c.updatedAt),p(c.title),P(c.updatedAt),s!==c.updatedAt)){const h=o.current?.getContent();I.current=c.updatedAt,(h===void 0||h!==c.content)&&(se(null),C($=>$+1))}},[le,c.layout,c.pinned,c.title,c.updatedAt,ie,W,J,P]),a.useEffect(()=>{B.current!==t&&(B.current=t,i.current=Le(),I.current=c.updatedAt,_.current=null,L(null),se(null),C(s=>s+1),D(!1))},[t,c.updatedAt]),a.useEffect(()=>{if(b!=="saved")return;const s=window.setTimeout(()=>{T(Date.now())},fa(de(y),f));return()=>window.clearTimeout(s)},[y,f,b]),a.useEffect(()=>{if(!M)return;const s=window.setTimeout(()=>{D(!1)},Kn);return()=>window.clearTimeout(s)},[M]),a.useEffect(()=>{Z?.type!=="updated"||b==="conflict"||Z.updatedAt!==c.updatedAt||(I.current=c.updatedAt,J(c.updatedAt),P(c.updatedAt),L(null))},[Z,c.updatedAt,b,J,P]),a.useEffect(()=>ma(s=>{if(s.noteId===t&&!(s.source==="web"&&s.editSessionId===i.current)){if(s.type==="mcp.note.updated"||s.type==="web.note.updated"){if(s.updatedAt===c.updatedAt||s.updatedAt===W.current)return;if(le){ie(s.updatedAt),L({type:"updated",updatedAt:s.updatedAt,source:s.source});return}L({type:"updated",updatedAt:s.updatedAt,source:s.source});return}s.type==="mcp.note.deleted"&&L({type:"deleted",source:s.source})}}),[le,t,c.updatedAt,ie,W]);const{onCreate:jt,onDelete:Nt,onPinned:Ct,deleteWarningDialog:At}=ha(),kt=()=>{me(fe(m))},St=s=>{p(s),me(fe(s))},qe=()=>{me(fe(m),{immediate:!0})},Rt=async s=>{if(le){v(s),me(fe(m,{layout:s}),{immediate:!0}),n("Layout will be saved with your draft.");return}const h=await Ve({id:t,layout:s,editSessionId:i.current,expectedUpdatedAt:W.current});if(h.type==="error"){h.errors[0].code===Yn&&(_.current=s,v(s),ie(Qn(h.errors[0].details)??W.current)),n(h.errors[0].message);return}_.current=null,await l.cancelQueries({queryKey:k.notes.detail(t),exact:!0}),I.current=h.updateNote.updatedAt,J(h.updateNote.updatedAt),l.setQueryData(k.notes.detail(t),$=>$&&{...$,layout:s,updatedAt:h.updateNote.updatedAt}),Fe({noteId:t,updatedAt:h.updateNote.updatedAt,editSessionId:i.current}),P(h.updateNote.updatedAt),v(s),n("Layout has been updated.")},Et=()=>({id:t,title:m,createdAt:c.createdAt,updatedAt:W.current||c.updatedAt}),Mt=async()=>{const s=o.current?.getMarkdown();if(s===void 0){n("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(s),n("Copied note as Markdown.")}catch{n("Failed to copy Markdown.")}},Tt=()=>{const s=o.current?.getMarkdown();if(s===void 0){n("Markdown is not ready yet.");return}try{He(s,Te(m,"md"),"text/markdown;charset=utf-8"),n("Downloaded note as Markdown.")}catch{n("Failed to download Markdown.")}},Ht=()=>{const s=Et();try{if(ne==="markdown"){const h=o.current?.getMarkdown();if(h===void 0){n("Markdown is not ready yet.");return}He(Zn(h,s,G),Te(m,"md"),"text/markdown;charset=utf-8")}else{const h=o.current?.getHtml();if(h===void 0){n("HTML is not ready yet.");return}He(qn(h,s,{includeMetadata:G,mode:ee}),Te(m,"html"),"text/html;charset=utf-8")}X(!1),n("Downloaded note.")}catch{n("Failed to download note.")}},Dt=async()=>{const s=await u.refetch();if(s.error||!s.data){n("Failed to reload the latest note state.");return}we(),_.current=null,I.current=s.data.updatedAt,J(s.data.updatedAt),p(s.data.title),v(s.data.layout||"wide"),P(s.data.updatedAt),se(null),C(h=>h+1),L(null)},Lt=async()=>{if(je()){_.current=null,L(null),await he({ignoreConflict:!0});return}const h=_.current;if(h){const $=await Ve({id:t,layout:h,editSessionId:i.current,force:!0});if($.type==="error"){n($.errors[0].message);return}_.current=null,await l.cancelQueries({queryKey:k.notes.detail(t),exact:!0}),I.current=$.updateNote.updatedAt,bt(),L(null),J($.updateNote.updatedAt),l.setQueryData(k.notes.detail(t),ke=>ke&&{...ke,layout:h,updatedAt:$.updateNote.updatedAt}),Fe({noteId:t,updatedAt:$.updateNote.updatedAt,editSessionId:i.current}),P($.updateNote.updatedAt),v(h);return}L(null),await he({ignoreConflict:!0})},ze=async()=>{const s=je();if(!s)return;const h=await ba({title:Qe(s.title||"untitled"),content:Qe(s.content),layout:s.layout??N});if(h.type==="error"){n(h.errors[0].message);return}te.current=!0,_.current=null,L(null),we(),Promise.resolve(r({to:ge,params:{id:h.createNote.id}})).finally(()=>{te.current=!1})},Vt=()=>{Q&&(p(Q.title),Q.layout&&v(Q.layout),se(Q.content),C(s=>s+1),yt(Q))},Ft=()=>{vt()},Ot=Q?q(Q.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,Ne=b==="saved"&&M,Bt=zn(y,f),_t=De(c.createdAt),Pt=b==="pending"?"Saving...":b==="saving"?"Saving now...":b==="error"?"Save failed. Try again.":b==="conflict"?"Save paused: changed elsewhere":`Saved ${Bt}`,$t=z("inline-flex items-center gap-2 transition-colors",b==="saved"&&!Ne&&"text-fg-secondary",Ne&&"text-accent-success",(b==="pending"||b==="saving")&&"text-fg-default",(b==="error"||b==="conflict")&&"text-fg-error"),Ce=z("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(b==="pending"||b==="saving")&&"save-progress-ring-active",b==="saved"&&Ne&&"save-progress-ring-complete",(b==="error"||b==="conflict")&&"save-progress-ring-error"),It=b==="saving"?e.jsx("span",{className:Ce,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):b==="pending"?e.jsx("span",{className:Ce,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}):b==="error"||b==="conflict"?e.jsx(wa,{className:"h-3.5 w-3.5",weight:"fill"}):e.jsx("span",{className:Ce,"aria-hidden":!0,children:e.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})}),Ut=e.jsxs(x,{as:"span",variant:"label",weight:"medium",className:$t,role:"status","aria-live":"polite",title:j,children:[It,Pt]}),Ae=b==="conflict"&&Z?.type==="updated",Zt=Ae?je():null,qt=Z!==null&&!(Z.type==="updated"&&!Ae&&Z.updatedAt===c.updatedAt);return e.jsx(Ie,{title:m,variant:"none",children:e.jsxs("main",{className:z("mx-auto",Gn[N]),children:[e.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:e.jsxs("div",{className:"flex flex-col gap-3.5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-5",children:[e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx(x,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),e.jsx("input",{ref:d,placeholder:"Title",className:"text-heading sm:text-display w-full bg-transparent font-semibold leading-[1.25] tracking-[-0.02em] outline-none",type:"text",value:m,onChange:s=>St(s.target.value)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(ot,{button:e.jsx(lt,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:Mt},{name:"Download Markdown",onClick:Tt},{name:"Download in another format",onClick:()=>X(!0)},{type:"separator",key:"export-separator"},{name:U?"Unpin":"Pin",onClick:()=>Ct(t,U,()=>{H(s=>!s)})},{name:"Change layout",onClick:()=>V(!0)},{type:"separator"},{name:"Clone this note",onClick:()=>jt(d.current?.value||"untitled",o.current?.getContent()||"",N)},{name:"Restore previous version",onClick:()=>E(!0)},{type:"separator"},{name:"Delete",onClick:()=>Nt(t,()=>{r({to:Ke,search:{page:1}})})}]}),e.jsx(S,{size:"sm",variant:"subtle",isLoading:b==="saving",disabled:b==="conflict",onClick:qe,children:"Save"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-t border-border-subtle/80 pt-3",children:[U&&e.jsxs(x,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[e.jsx(xa,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),U&&e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),Ut,e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsxs(x,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",_t]})]})]})}),Q&&e.jsx(Ge,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["A draft from ",Ot," is saved only in this browser."]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:Vt,children:"Restore draft"}),e.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:Ft,children:"Discard"})]})]})}),b==="error"&&e.jsx(Ge,{tone:"danger",className:"mb-6",children:e.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(S,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:qe,children:"Retry save"}),e.jsx(S,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:()=>{ze()},children:"Save as new note"})]})]})}),e.jsx(Vn,{ref:o,content:ve??c.content,currentNoteId:t,onChange:kt},`${t}:${be}`),e.jsx(Oe,{fallback:e.jsx(oe,{className:"mb-5",height:"80px"}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:s,retry:h})=>e.jsx(Be,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:s,onRetry:h,showBackAction:!1,showHomeAction:!1}),children:e.jsx(Ka,{noteId:t})}),e.jsx(Oe,{fallback:e.jsx(oe,{height:"80px"}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:s,retry:h})=>e.jsx(Be,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:s,onRetry:h,showBackAction:!1,showHomeAction:!1}),children:e.jsx(Za,{noteId:t,render:s=>s&&s.length>0&&e.jsxs("div",{className:"surface-base p-4",children:[e.jsx(Ue,{icon:e.jsx(Oa,{className:"h-3.5 w-3.5"}),title:"Back References",className:"mb-3 text-fg-tertiary"}),e.jsx("ul",{className:"flex flex-col",children:s.map(h=>e.jsx("li",{children:e.jsxs(ga,{to:ge,params:{id:h.id},className:"flex items-center gap-2 rounded-[10px] px-2.5 py-1.5 text-fg-secondary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:[e.jsx(Fa,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),e.jsx(x,{as:"span",variant:"body",weight:"medium",className:"text-current",children:h.title})]})},h.id))})]})})}),e.jsx(_a,{isOpen:g,onClose:()=>V(!1),onSave:Rt,currentLayout:N}),e.jsx(Ia,{isOpen:qt,isDeleted:Z?.type==="deleted",isConflict:Ae,hasDraft:Zt!==null,source:Z?.source??"unknown",isReloading:u.isRefetching,onReload:Dt,onOverwrite:()=>{Lt()},onCloneDraft:()=>{ze()},onOpenTrash:()=>r({to:Ke,search:{page:1}})}),e.jsxs(R,{isOpen:O,onClose:()=>X(!1),variant:"compact",children:[e.jsx(R.Header,{title:"Download in another format",onClose:()=>X(!1)}),e.jsx(R.Body,{children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(x,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Format"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ce,{title:"Markdown",description:"Good for GitHub, static blogs, and other note apps.",selected:ne==="markdown",onClick:()=>re("markdown")}),e.jsx(ce,{title:"HTML",description:"Good for web documents or CMS editors.",selected:ne==="html",onClick:()=>re("html")})]})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-[14px] border border-border-subtle bg-subtle/60 p-3",children:[e.jsx(st,{size:"sm",checked:G,onChange:s=>Y(s.target.checked),className:"mt-0.5","aria-label":"Include metadata"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(x,{as:"span",variant:"body",weight:"semibold",children:"Include metadata"}),e.jsx(x,{as:"span",variant:"label",tone:"tertiary",children:"Add the title, note id, timestamps, and Ocean Brain source information."})]})]}),ne==="html"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(x,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"HTML style"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ce,{title:"Content only",description:"Save only the note body HTML.",selected:ee==="fragment",onClick:()=>pe("fragment")}),e.jsx(ce,{title:"Full HTML document",description:"Save a complete HTML file that opens in a browser.",selected:ee==="standalone",onClick:()=>pe("standalone")})]})]})]})}),e.jsx(R.Footer,{children:e.jsxs(ue,{children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>X(!1),children:"Cancel"}),e.jsx(S,{variant:"primary",size:"sm",onClick:Ht,children:"Download"})]})})]}),e.jsx(Ua,{isOpen:F,noteId:t,onClose:()=>E(!1),onRestored:s=>{i.current=Le(),we(),_.current=null,I.current=s.updatedAt,L(null),J(s.updatedAt),P(s.updatedAt)}}),At]})})}function ir(){const{id:t}=gt.useParams();if(!t)throw new Error("Note id is required.");return e.jsx(Oe,{fallback:Wn,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[t],renderError:({error:n,retry:r})=>e.jsx(Ie,{title:"Note",variant:"none",children:e.jsx(Be,{title:"Failed to load note",description:"Retry loading the note editor.",error:n,onRetry:r})}),children:e.jsx(Jn,{id:t},t)})}export{Jn as NoteContent,ir as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-i1M2FSI2.js";import{_ as k,T as h,L as H,N as M,D as E,k as L,d as x,$ as S,P as w,F as O,a0 as C,i as o,j as U,a1 as I}from"./index-BvKBTjQq.js";import"./graph-vendor-CUxe67Lr.js";import{u as P,R as Y}from"./useReminderMutate-D21PurIS.js";import"./note-core-Z6kqulGB.js";const u={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function B({reminder:t,onUpdate:l,onDelete:g}){const f=y=>{const r=x(Number(y)),m=x();return r.isSame(m,"day")?`Today at ${r.format("HH:mm")}`:r.isSame(m.add(1,"day"),"day")?`Tomorrow at ${r.format("HH:mm")}`:r.format("YYYY-MM-DD HH:mm")},a=y=>{const r=x(Number(y)),m=x(),N=r.diff(m,"hour"),b=r.diff(m,"minute")%60;return N<0||b<0?"Overdue":N===0?`${b}m remaining`:`${N}h ${b}m remaining`},d=a(t.reminderDate)==="Overdue",i=t.priority||"low",s=i==="high"?"High":i==="medium"?"Medium":"Low",p=u[i],c=t.noteId.toString(),n=d?"text-fg-error":"text-fg-tertiary",j=t.content?.trim()||t.note?.title||"Untitled reminder",R=t.note?.title||"Untitled note",T=!!(t.content?.trim()&&t.note?.title),D=a(t.reminderDate),$=f(t.reminderDate);return e.jsxs("div",{className:"surface-base flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[e.jsx(k,{checked:t.completed,onChange:()=>l(t.id,c,{completed:!t.completed}),size:"sm"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",className:t.completed?"truncate line-through opacity-45":"truncate",children:j}),T&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:t.completed?"mt-0.5 truncate opacity-45":"mt-0.5 truncate",children:e.jsx(H,{to:M,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:R})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 sm:shrink-0",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 rounded-full border border-border-subtle ${p}`,"aria-label":`${s} priority`,title:`${s} priority`}),e.jsx(h,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:t.completed?"opacity-45":void 0,children:$}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",className:t.completed?"opacity-45":n,children:D})]}),e.jsx("div",{className:"flex items-center justify-end gap-1.5 sm:shrink-0",children:e.jsx(E,{button:e.jsx(L,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:[{name:"Delete",onClick:()=>g(t.id,c)}]})})]})}const v=U(I),_=[{label:"High",className:u.high},{label:"Medium",className:u.medium},{label:"Low",className:u.low}];function q(){const t=v.useNavigate(),{page:l}=v.useSearch(),{onUpdate:g,onDelete:f}=P(),a=25,d=e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:_.map(({label:i,className:s})=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full border border-border-subtle ${s}`,"aria-hidden":"true"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:i})]},i))});return e.jsx(S,{fallback:e.jsx(w,{title:"Reminders",heading:e.jsx(o,{width:164,height:24,className:"rounded-full"}),description:e.jsx(o,{width:224,height:16,className:"rounded-full"}),headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"})]})}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading the upcoming reminder list",resetKeys:[l,a],children:e.jsx(Y,{searchParams:{offset:(l-1)*a,limit:a},render:({reminders:i,totalCount:s})=>{const p=s>0?`Reminders (${s})`:void 0,c="Review reminders created from notes and mark them complete here";return i.length===0?e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsx(O,{title:"No upcoming reminders",description:"Add a reminder inside any note to see it here"})}):e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-col gap-2.5",children:i.map(n=>e.jsx(B,{reminder:n,onUpdate:g,onDelete:f},n.id))}),s&&a<s&&e.jsx(C,{page:l,last:Math.ceil(s/a),onChange:n=>{t({search:j=>({...j,page:n})})}})]})})}})})}export{q as default};
|