ocean-brain 0.14.0 → 0.15.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/package.json +2 -1
- package/server/client/dist/assets/ArrowClockwise.es-BwtKWcmj.js +1 -0
- package/server/client/dist/assets/{ArrowRight.es-nBJws3ws.js → ArrowRight.es-E09Lfefr.js} +1 -1
- package/server/client/dist/assets/{AuxiliaryPanelHeader-BN_2axQu.js → AuxiliaryPanelHeader-Bys98BJJ.js} +1 -1
- package/server/client/dist/assets/Calendar-BOhJYi8K.js +25 -0
- package/server/client/dist/assets/Callout-CAH1ua9B.js +1 -0
- package/server/client/dist/assets/{CaretUp.es-DDbqKn78.js → CaretUp.es-DSWjIa-J.js} +1 -1
- package/server/client/dist/assets/{CheckCircle.es-CyY9aLBF.js → CheckCircle.es-Cou6rItm.js} +1 -1
- package/server/client/dist/assets/{Copy.es-BwX4tEoU.js → Copy.es-ftEldGIL.js} +1 -1
- package/server/client/dist/assets/{File.es-DeTgvUnI.js → File.es-DlKAX1uO.js} +1 -1
- package/server/client/dist/assets/{FileText.es-C-bpw8dQ.js → FileText.es-D6JM_MqM.js} +1 -1
- package/server/client/dist/assets/{FlowArrow.es-CKcMBOmX.js → FlowArrow.es-BRWXqf9A.js} +1 -1
- package/server/client/dist/assets/{Graph-BNoSRJP3.js → Graph-BaqGi3M7.js} +1 -1
- package/server/client/dist/assets/{Graph-DYYxNAWn.js → Graph-L-d0cdMk.js} +1 -1
- package/server/client/dist/assets/{Image.es-d4jWnijM.js → Image.es-Bh2mTNtr.js} +1 -1
- package/server/client/dist/assets/{Info.es-DVzN2joA.js → Info.es-Bwz4CSvS.js} +1 -1
- package/server/client/dist/assets/Integration-C-rva2X9.js +1 -0
- package/server/client/dist/assets/{LinkSimple.es-BD4aGTc3.js → LinkSimple.es-iJvLf-MB.js} +1 -1
- package/server/client/dist/assets/{Note-FL31jb2U.js → Note-OO_uh2a7.js} +4 -4
- package/server/client/dist/assets/{NotePropertiesPanel-os22Ppnu.js → NotePropertiesPanel-BFWjxL_w.js} +1 -1
- package/server/client/dist/assets/{Plus.es-Cl8zOOZa.js → Plus.es-Dmb3oijD.js} +1 -1
- package/server/client/dist/assets/Reminders-CtpFtvu6.js +1 -0
- package/server/client/dist/assets/{Search-CPPTW2PO.js → Search-t48pkUg-.js} +2 -2
- package/server/client/dist/assets/{SurfaceCard-jL2qzrzF.js → SurfaceCard-zdJ8k1o0.js} +1 -1
- package/server/client/dist/assets/{Tag-3DbGmuxa.js → Tag-BL2h3ZaX.js} +1 -1
- package/server/client/dist/assets/TagNotes-BpRTCEBf.js +1 -0
- package/server/client/dist/assets/{Trash.es-fxukjAO6.js → Trash.es-DFnO8iF5.js} +1 -1
- package/server/client/dist/assets/{ViewChip-CVe_HNyd.js → ViewChip-BdPhSEvG.js} +1 -1
- package/server/client/dist/assets/Views-BoO6vgnF.js +1 -0
- package/server/client/dist/assets/WarningCircle.es-BAvgGuQK.js +1 -0
- package/server/client/dist/assets/app-OGsLwSqJ.js +151 -0
- package/server/client/dist/assets/app-yYMsgUrz.css +1 -0
- package/server/client/dist/assets/{calendar-data-BQ24n348.js → calendar-data-CwVF7Pz3.js} +1 -1
- package/server/client/dist/assets/{image.api-CyIIEGkG.js → image.api-CHuhmq_G.js} +1 -1
- package/server/client/dist/assets/index-CuCzOHJ6.js +1 -0
- package/server/client/dist/assets/integrations-B5SIEnG_.js +1 -0
- package/server/client/dist/assets/{manage-image-DXedfr7U.js → manage-image-Kd-7IGfB.js} +1 -1
- package/server/client/dist/assets/{manage-image-detail-DmifOPNU.js → manage-image-detail-HU0QLP-t.js} +1 -1
- package/server/client/dist/assets/mcp-BQ418pyx.js +5 -0
- package/server/client/dist/assets/{mcp-admin-adapter-CmKsg1vd.js → mcp-admin-adapter-CUakQ_Xm.js} +1 -1
- package/server/client/dist/assets/{note-ui-DRnAnwKv.js → note-ui-CRcP5BjO.js} +1 -1
- package/server/client/dist/assets/{placeholder-G6iEBbDy.js → placeholder-D7JKnpuh.js} +1 -1
- package/server/client/dist/assets/{properties-BPobx_Qk.js → properties-CtagYHMr.js} +1 -1
- package/server/client/dist/assets/route-preload.js +2 -2
- package/server/client/dist/assets/search-B5tCkhwj.js +1 -0
- package/server/client/dist/assets/{search-admin-adapter-7sTcWTmv.js → search-admin-adapter-Be9xSY88.js} +1 -1
- package/server/client/dist/assets/{tag.api-kKZl04yY.js → tag.api-DGfi8hWL.js} +1 -1
- package/server/client/dist/assets/{time-BwwQGbK-.js → time-Kh6oav5R.js} +9 -9
- package/server/client/dist/assets/{trash-Cepvi7G8.js → trash-Di2BWyUO.js} +1 -1
- package/server/client/dist/assets/{useNoteMutate-D-mZKXjl.js → useNoteMutate-BQj6jHhV.js} +1 -1
- package/server/client/dist/assets/{useReminderMutate-Cexk1ydX.js → useReminderMutate-jubqwSD9.js} +1 -1
- package/server/client/dist/index.html +5 -5
- package/server/dist/app.js +9 -1
- package/server/dist/features/app-gateway/access.js +73 -0
- package/server/dist/features/app-gateway/database.js +20 -0
- package/server/dist/features/app-gateway/gateway.js +208 -0
- package/server/dist/features/integration/access-events.js +17 -0
- package/server/dist/features/integration/manifest.js +31 -2
- package/server/dist/features/integration/note-sync.js +156 -0
- package/server/dist/features/integration/service.js +80 -7
- package/server/dist/features/integration/status-report.js +22 -0
- package/server/dist/features/note/graphql/note.mutation.resolver.js +20 -12
- package/server/dist/features/note/graphql/note.query.resolver.js +4 -1
- package/server/dist/features/note/services/change-events.js +26 -0
- package/server/dist/features/search/search-manager.js +4 -7
- package/server/dist/modules/server-events.js +3 -0
- package/server/dist/routes/apps.js +163 -0
- package/server/dist/routes/index.js +2 -0
- package/server/dist/routes/integrations.js +21 -1
- package/server/prisma/migrations/20260919090000_0022_integration_proxy_url/migration.sql +2 -0
- package/server/prisma/schema.prisma +2 -0
- package/server/client/dist/assets/Calendar-vA4Xa4Qr.js +0 -25
- package/server/client/dist/assets/Callout-Bo2P960P.js +0 -1
- package/server/client/dist/assets/Integration-gDDtIJYJ.js +0 -1
- package/server/client/dist/assets/Reminders-Dt2JuGci.js +0 -1
- package/server/client/dist/assets/TagNotes-DLwRF8pT.js +0 -1
- package/server/client/dist/assets/Views-8ghLRax7.js +0 -1
- package/server/client/dist/assets/app-Bcl0U7r9.css +0 -1
- package/server/client/dist/assets/app-DzChh-V0.js +0 -151
- package/server/client/dist/assets/index-Iy_BgP1R.js +0 -1
- package/server/client/dist/assets/integrations-LOdTs1T6.js +0 -1
- package/server/client/dist/assets/mcp-d8IzsoRz.js +0 -5
- package/server/client/dist/assets/search-DanMKCC8.js +0 -1
- package/server/dist/features/search/note-change.js +0 -16
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { buildUnauthorizedPayload } from "@baejino/auth";
|
|
2
|
+
import fastifyHttpProxy from "@fastify/http-proxy";
|
|
3
|
+
import {
|
|
4
|
+
APP_GATEWAY_ACCESS_COOKIE_NAME,
|
|
5
|
+
APP_GATEWAY_ACCESS_HEADER,
|
|
6
|
+
APP_GATEWAY_ACCESS_TTL_MS,
|
|
7
|
+
createAppGatewayAccessService,
|
|
8
|
+
extractAppGatewayAccessCookie,
|
|
9
|
+
extractAppGatewayAccessToken,
|
|
10
|
+
selectAppGatewayProtocol
|
|
11
|
+
} from "../features/app-gateway/access.js";
|
|
12
|
+
import {
|
|
13
|
+
APP_GATEWAY_PUBLIC_PREFIX,
|
|
14
|
+
createGatewayResponseHeaders,
|
|
15
|
+
createProxyRequestHeaders,
|
|
16
|
+
createProxyWebSocketHeaders,
|
|
17
|
+
getAppGatewayUpstream,
|
|
18
|
+
resolveAppGatewayConnection,
|
|
19
|
+
resolveAppGatewayOptions,
|
|
20
|
+
validateAppGatewayRequestPath
|
|
21
|
+
} from "../features/app-gateway/gateway.js";
|
|
22
|
+
import { createCsrfProtection, requireSessionForWrite } from "../modules/auth-guard.js";
|
|
23
|
+
import { createAppError } from "../modules/error-handler.js";
|
|
24
|
+
import { createSessionAccessRateLimit } from "../modules/rate-limit.js";
|
|
25
|
+
const PROXY_PREFIX = `${APP_GATEWAY_PUBLIC_PREFIX}/:connectionId`;
|
|
26
|
+
const SUPPORTED_METHODS = "DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT";
|
|
27
|
+
const CORS_ASSET_DESTINATIONS = /* @__PURE__ */ new Set(["audio", "font", "image", "manifest", "script", "style", "video", "worker"]);
|
|
28
|
+
const getConnectionId = (request) => {
|
|
29
|
+
const params = request.params;
|
|
30
|
+
return typeof params.connectionId === "string" ? params.connectionId : "";
|
|
31
|
+
};
|
|
32
|
+
const isWebSocketUpgrade = (request) => request.headers.upgrade?.toLowerCase() === "websocket";
|
|
33
|
+
const getHeaderValue = (value) => Array.isArray(value) ? value[0] : value;
|
|
34
|
+
const getPublicProtocol = (request) => {
|
|
35
|
+
const origin = getHeaderValue(request.headers.origin);
|
|
36
|
+
if (origin && origin !== "null") {
|
|
37
|
+
try {
|
|
38
|
+
const url = new URL(origin);
|
|
39
|
+
if (url.host === request.headers.host && (url.protocol === "http:" || url.protocol === "https:")) {
|
|
40
|
+
return url.protocol.slice(0, -1);
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return request.protocol === "https" ? "https" : "http";
|
|
46
|
+
};
|
|
47
|
+
const requireAllowedOrigin = (request) => {
|
|
48
|
+
const origin = request.headers.origin;
|
|
49
|
+
if (!origin || origin === "null") return;
|
|
50
|
+
try {
|
|
51
|
+
if (new URL(origin).host === request.headers.host) return;
|
|
52
|
+
} catch {
|
|
53
|
+
}
|
|
54
|
+
throw createAppError(403, "APP_ORIGIN_FORBIDDEN", "App requests must originate from Ocean Brain.");
|
|
55
|
+
};
|
|
56
|
+
const isCorsPreflight = (request) => request.method === "OPTIONS" && request.headers.origin === "null" && typeof request.headers["access-control-request-method"] === "string";
|
|
57
|
+
const sendCorsPreflight = (request, reply) => {
|
|
58
|
+
const requestedHeaders = request.headers["access-control-request-headers"];
|
|
59
|
+
return reply.status(204).headers({
|
|
60
|
+
"Access-Control-Allow-Credentials": "true",
|
|
61
|
+
"Access-Control-Allow-Headers": requestedHeaders ?? "Content-Type",
|
|
62
|
+
"Access-Control-Allow-Methods": SUPPORTED_METHODS,
|
|
63
|
+
"Access-Control-Allow-Origin": "null",
|
|
64
|
+
"Access-Control-Max-Age": "600",
|
|
65
|
+
Vary: "Origin, Access-Control-Request-Headers"
|
|
66
|
+
}).send();
|
|
67
|
+
};
|
|
68
|
+
const createAppGatewayRouter = (authConfig, gatewayOptions) => {
|
|
69
|
+
return async (app) => {
|
|
70
|
+
const accessRouteOptions = {
|
|
71
|
+
preHandler: [
|
|
72
|
+
app.rateLimit(createSessionAccessRateLimit()),
|
|
73
|
+
requireSessionForWrite(authConfig),
|
|
74
|
+
createCsrfProtection(authConfig)
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
const options = resolveAppGatewayOptions(gatewayOptions);
|
|
78
|
+
const access = createAppGatewayAccessService();
|
|
79
|
+
const wsClientOptions = {
|
|
80
|
+
headers: {},
|
|
81
|
+
rewriteRequestHeaders: (_headers, request) => createProxyWebSocketHeaders(request)
|
|
82
|
+
};
|
|
83
|
+
app.post(
|
|
84
|
+
"/api/app-gateway/connections/:connectionId/access",
|
|
85
|
+
accessRouteOptions,
|
|
86
|
+
async (request, reply) => {
|
|
87
|
+
requireAllowedOrigin(request);
|
|
88
|
+
const connection = await resolveAppGatewayConnection(options, request.params.connectionId);
|
|
89
|
+
const grant = access.issue(connection.id, getPublicProtocol(request));
|
|
90
|
+
return reply.header("Cache-Control", "no-store").setCookie(APP_GATEWAY_ACCESS_COOKIE_NAME, grant.token, {
|
|
91
|
+
httpOnly: true,
|
|
92
|
+
maxAge: APP_GATEWAY_ACCESS_TTL_MS / 1e3,
|
|
93
|
+
path: `${APP_GATEWAY_PUBLIC_PREFIX}/${connection.id}`,
|
|
94
|
+
// The sandbox has an opaque origin, so app subresources need an explicitly cross-site cookie.
|
|
95
|
+
sameSite: "none",
|
|
96
|
+
secure: true
|
|
97
|
+
}).send({
|
|
98
|
+
connectionId: connection.id,
|
|
99
|
+
...grant
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
app.removeContentTypeParser("application/x-www-form-urlencoded");
|
|
104
|
+
app.decorateRequest("appGatewayCorsAllowed", false);
|
|
105
|
+
app.decorateRequest("appGatewayConnection", null);
|
|
106
|
+
app.decorateRequest("appGatewayPublicProtocol", null);
|
|
107
|
+
app.register(fastifyHttpProxy, {
|
|
108
|
+
upstream: "",
|
|
109
|
+
prefix: PROXY_PREFIX,
|
|
110
|
+
rewritePrefix: "/",
|
|
111
|
+
websocket: true,
|
|
112
|
+
preHandler: async (request, reply) => {
|
|
113
|
+
validateAppGatewayRequestPath(request.url);
|
|
114
|
+
requireAllowedOrigin(request);
|
|
115
|
+
if (isCorsPreflight(request)) return sendCorsPreflight(request, reply);
|
|
116
|
+
const connectionId = getConnectionId(request);
|
|
117
|
+
const headerToken = getHeaderValue(request.headers[APP_GATEWAY_ACCESS_HEADER]);
|
|
118
|
+
const accessToken = isWebSocketUpgrade(request) ? extractAppGatewayAccessToken(request.headers["sec-websocket-protocol"]) : headerToken ?? extractAppGatewayAccessCookie(request.headers.cookie);
|
|
119
|
+
const accessGrant = access.resolve(connectionId, accessToken);
|
|
120
|
+
if (!accessGrant) {
|
|
121
|
+
const unauthorized = buildUnauthorizedPayload();
|
|
122
|
+
throw createAppError(401, unauthorized.code, unauthorized.message);
|
|
123
|
+
}
|
|
124
|
+
request.appGatewayPublicProtocol = accessGrant.publicProtocol;
|
|
125
|
+
request.appGatewayConnection = await resolveAppGatewayConnection(options, connectionId);
|
|
126
|
+
const requestUrl = new URL(request.url, "http://ocean-brain.invalid");
|
|
127
|
+
const publicRoot = `${APP_GATEWAY_PUBLIC_PREFIX}/${connectionId}`;
|
|
128
|
+
if (!isWebSocketUpgrade(request) && ["GET", "HEAD"].includes(request.method) && requestUrl.pathname === publicRoot) {
|
|
129
|
+
return reply.redirect(`${publicRoot}/${requestUrl.search}`, 308);
|
|
130
|
+
}
|
|
131
|
+
if (request.headers.origin === "null" && !["GET", "HEAD"].includes(request.method) && !headerToken && !isWebSocketUpgrade(request)) {
|
|
132
|
+
throw createAppError(
|
|
133
|
+
403,
|
|
134
|
+
"APP_ACCESS_HEADER_REQUIRED",
|
|
135
|
+
"Sandboxed app writes require the app access header."
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
const fetchDestination = request.headers["sec-fetch-dest"];
|
|
139
|
+
request.appGatewayCorsAllowed = request.headers.origin === "null" && (Boolean(headerToken) || typeof fetchDestination === "string" && CORS_ASSET_DESTINATIONS.has(fetchDestination));
|
|
140
|
+
},
|
|
141
|
+
replyOptions: {
|
|
142
|
+
timeout: options.requestTimeoutMs,
|
|
143
|
+
getUpstream: (request) => getAppGatewayUpstream(request),
|
|
144
|
+
rewriteRequestHeaders: (request, headers) => createProxyRequestHeaders(request, headers),
|
|
145
|
+
rewriteHeaders: (headers, request) => request ? createGatewayResponseHeaders(headers, request) : headers,
|
|
146
|
+
onError: (reply, { error }) => {
|
|
147
|
+
const timeout = error.name === "TimeoutError" || error.message.toLowerCase().includes("timeout");
|
|
148
|
+
return reply.status(timeout ? 504 : 502).send({
|
|
149
|
+
code: timeout ? "APP_PROXY_TIMEOUT" : "APP_PROXY_UNAVAILABLE",
|
|
150
|
+
message: timeout ? "The proxied app did not respond in time." : "The proxied app could not be reached."
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
wsClientOptions,
|
|
155
|
+
wsServerOptions: {
|
|
156
|
+
handleProtocols: selectAppGatewayProtocol
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export {
|
|
162
|
+
createAppGatewayRouter
|
|
163
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createApiRouter } from "./api.js";
|
|
2
|
+
import { createAppGatewayRouter } from "./apps.js";
|
|
2
3
|
import { createAuthPagesRouter } from "./auth-pages.js";
|
|
3
4
|
import { createClientRouter } from "./client.js";
|
|
4
5
|
import { createGraphqlRouter } from "./graphql.js";
|
|
5
6
|
export {
|
|
6
7
|
createApiRouter,
|
|
8
|
+
createAppGatewayRouter,
|
|
7
9
|
createAuthPagesRouter,
|
|
8
10
|
createClientRouter,
|
|
9
11
|
createGraphqlRouter
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import mercurius from "mercurius";
|
|
2
2
|
import { requireIntegrationPermission } from "../features/integration/auth.js";
|
|
3
|
+
import {
|
|
4
|
+
createIntegrationNoteCatalogHandler,
|
|
5
|
+
createIntegrationNoteEventsHandler
|
|
6
|
+
} from "../features/integration/note-sync.js";
|
|
3
7
|
import { integrationReadSchema } from "../features/integration/schema.js";
|
|
4
8
|
import { createIntegrationService } from "../features/integration/service.js";
|
|
5
9
|
import {
|
|
@@ -38,6 +42,21 @@ const createIntegrationRouter = (authConfig) => async (app) => {
|
|
|
38
42
|
...request.integration
|
|
39
43
|
})
|
|
40
44
|
);
|
|
45
|
+
api.post(
|
|
46
|
+
"/status",
|
|
47
|
+
{ bodyLimit: 2048, preHandler: requireIntegrationPermission("notes:read", service) },
|
|
48
|
+
async (request) => service.reportStatus(request.headers.authorization?.slice(7).trim() ?? "", request.body)
|
|
49
|
+
);
|
|
50
|
+
api.get(
|
|
51
|
+
"/events",
|
|
52
|
+
{ preHandler: requireIntegrationPermission("notes:read", service) },
|
|
53
|
+
createIntegrationNoteEventsHandler()
|
|
54
|
+
);
|
|
55
|
+
api.post(
|
|
56
|
+
"/notes/catalog",
|
|
57
|
+
{ preHandler: requireIntegrationPermission("notes:read", service) },
|
|
58
|
+
createIntegrationNoteCatalogHandler()
|
|
59
|
+
);
|
|
41
60
|
api.post(
|
|
42
61
|
"/notes/create",
|
|
43
62
|
{ preHandler: requireIntegrationPermission("notes:create", service) },
|
|
@@ -87,7 +106,8 @@ const createIntegrationRouter = (authConfig) => async (app) => {
|
|
|
87
106
|
throw createAppError(400, "INVALID_INTEGRATION_MANIFEST", "A manifest is required.");
|
|
88
107
|
const connection = await service.connect({
|
|
89
108
|
manifest: request.body.manifest,
|
|
90
|
-
grantedPermissions: request.body.grantedPermissions
|
|
109
|
+
grantedPermissions: request.body.grantedPermissions,
|
|
110
|
+
proxyUrl: request.body.proxyUrl
|
|
91
111
|
});
|
|
92
112
|
return reply.status(201).send(connection);
|
|
93
113
|
});
|
|
@@ -30,6 +30,7 @@ model IntegrationConnection {
|
|
|
30
30
|
integrationId String
|
|
31
31
|
native Boolean @default(false)
|
|
32
32
|
manifest String
|
|
33
|
+
proxyUrl String?
|
|
33
34
|
grantedPermissions String @default("[]")
|
|
34
35
|
enabled Boolean @default(false)
|
|
35
36
|
pinned Boolean @default(false)
|
|
@@ -47,6 +48,7 @@ model IntegrationCredential {
|
|
|
47
48
|
tokenHash String @unique
|
|
48
49
|
createdAt DateTime @default(now())
|
|
49
50
|
lastUsedAt DateTime?
|
|
51
|
+
statusReport String?
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
model Note {
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{j as e,r as j}from"./floating-ui.react-dom-BWTnA00G.js";import{T as p,x as H,y as E,M as C,q as S,g as Y,P as Q,h as V}from"./time-BwwQGbK-.js";import{d as b,s as F,a as $}from"./useNoteMutate-D-mZKXjl.js";import{C as U}from"./url-Bp8sXMb4.js";import{C as z,a as P,b as B,c as J,g as G,s as W,d as X}from"./calendar-data-BQ24n348.js";import{e as K}from"./app-DzChh-V0.js";import{s as Z}from"./FileText.es-C-bpw8dQ.js";import{C as ee}from"./Callout-Bo2P960P.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-BNoSRJP3.js";import"./Info.es-DVzN2joA.js";const D=2,te=({year:t,month:a,day:n,isCurrentMonth:r,isSunday:l,isToday:m,isSelected:d,isPast:c,notes:h,reminders:g,onSelect:s})=>{const f=h.slice(0,D).map(y=>({key:`note-${y.id}`,type:"note",title:y.title})),N=g.slice(0,D).map(y=>({key:`reminder-${y.id}`,type:"reminder",title:y.content||y.note?.title||"No title",isCompleted:y.completed})),M=(c?[...f,...N]:[...N,...f]).slice(0,D),R=()=>r?d?"bg-elevated shadow-[inset_0_0_0_1px_var(--border-secondary)] hover:bg-surface":"bg-surface hover:bg-muted":"cursor-default bg-[var(--page-bg)] text-fg-disabled",k=()=>m?"bg-cta font-semibold text-fg-on-filled":r?l?"font-semibold text-fg-weekend":"font-semibold text-fg-secondary":"font-medium text-fg-tertiary";return e.jsx(z,{day:n,dateLabel:b(new Date(t,a-1,n)).format("dddd, MMMM D, YYYY"),cellClassName:R(),dayNumberClassName:k(),isCurrentMonth:r,isToday:m,isSelected:d,noteCount:h.length,reminderCount:g.length,previewItems:M,overflowCount:Math.max(0,h.length+g.length-D),onSelect:s})},ae=te,ne=({note:t,type:a})=>e.jsx(P,{params:{id:t.id},header:e.jsx(Z,{size:12}),title:t.title,meta:b(Number(a==="create"?t.createdAt:t.updatedAt)).format("HH:mm")}),se=({reminder:t})=>e.jsx(P,{params:{id:String(t.note?.id??t.noteId)},header:e.jsx(F,{size:12}),title:t.content||t.note?.title||"No title",titleClassName:t.completed?"line-through":"",meta:b(Number(t.reminderDate)).format("HH:mm")}),re=(t,a)=>t.map(n=>n.type==="note"?e.jsx(ne,{note:n.item,type:a},`note-${n.item.id}`):e.jsx(se,{reminder:n.item},`reminder-${n.item.id}`)),I=(t,a)=>`${t} ${t===1?a:`${a}s`}`,oe="mt-3 flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overscroll-y-contain pr-2 [scrollbar-color:var(--border-secondary)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-border-secondary [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar]:w-1.5",L=t=>b(new Date(t.year,t.month-1,t.day)).format("dddd, MMMM D"),T=({day:t,type:a,isLoading:n,presentation:r="rail"})=>{const l=j.useMemo(()=>{if(!t)return[];const h=t.notes.map(s=>({type:"note",item:s})),g=t.reminders.map(s=>({type:"reminder",item:s}));return t.isPast?[...h,...g]:[...g,...h]},[t]);if(!t)return e.jsx("section",{"aria-label":"Day details",className:"flex h-full min-h-40 items-center justify-center text-center",children:e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",children:"Select a day to see its activity."})});const m=L(t),d=n?"Loading activity...":[I(t.notes.length,"note"),I(t.reminders.length,"reminder")].join(" · "),c=n?null:e.jsx("div",{className:r==="rail"?oe:"flex flex-col gap-1",children:l.length>0?re(l,a):e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",className:"py-8 text-center",children:"No activity on this day."})});return r==="modal"?e.jsxs("div",{"aria-label":`${m} activity`,children:[e.jsx(p,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mb-3",children:d}),c]}):e.jsxs("section",{"aria-label":`${m} details`,className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex shrink-0 items-start gap-2 border-b border-border-subtle/80 pb-3",children:[e.jsx(K,{"aria-hidden":"true",className:"mt-0.5 shrink-0 text-fg-tertiary",size:15}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(p,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",children:m}),e.jsx(p,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mt-0.5",children:d})]})]}),c]})},ie=["January","February","March","April","May","June","July","August","September","October","November","December"],le=({month:t,year:a,type:n,onPrevMonth:r,onNextMonth:l,onToday:m,onTypeChange:d})=>e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2.5 gap-y-1",children:[e.jsx(p,{as:"h1",variant:"display",weight:"bold",tracking:"tighter",className:"text-2xl leading-none sm:text-[2.15rem]",children:ie[t-1]}),e.jsx(p,{as:"span",variant:"subheading",weight:"medium",tone:"secondary",tracking:"tight",className:"pb-0.5",children:a})]}),e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",className:"hidden sm:block",children:"Track note activity and reminders across the month"})]}),e.jsx("div",{className:"flex lg:justify-end",children:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:inline-flex sm:w-auto sm:flex-row sm:items-center sm:gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(p,{id:"calendar-note-date-label",as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Note date"}),e.jsxs(H,{value:n,"aria-labelledby":"calendar-note-date-label",onValueChange:h=>d(h),variant:"ghost",size:"sm",children:[e.jsx(E,{value:"create",children:"Created"}),e.jsx(E,{value:"update",children:"Updated"})]})]}),e.jsx("div",{className:"hidden h-5 w-px bg-divider sm:block"}),e.jsx(B,{onPrevMonth:r,onNextMonth:l,onToday:m})]})})]}),_="(min-width: 1280px)",de=({days:t,type:a,isLoading:n,selectedDayKey:r,onSelectedDayChange:l})=>{const[m,d]=j.useState(!1),c=j.useMemo(()=>t.find(s=>s.key===r),[t,r]);j.useEffect(()=>{const s=window.matchMedia(_),f=N=>{N.matches&&d(!1)};return s.addEventListener("change",f),()=>s.removeEventListener("change",f)},[]);const h=s=>{l(s),window.matchMedia(_).matches||d(!0)},g=c?L(c):"Day details";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-0 xl:grid xl:grid-cols-[minmax(0,1fr)_20rem] 2xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx(J,{isLoading:n,className:"xl:pr-5",children:t.map(s=>e.jsx(ae,{year:s.year,month:s.month,day:s.day,isCurrentMonth:s.isCurrentMonth,isSunday:s.isSunday,isToday:s.isToday,isSelected:s.key===r,isPast:s.isPast,notes:s.notes,reminders:s.reminders,onSelect:()=>h(s.key)},s.key))}),e.jsx("aside",{className:"relative hidden min-h-0 border-l border-border-subtle xl:block","aria-label":"Selected day",children:e.jsx("div",{className:"absolute inset-y-0 right-0 left-5",children:e.jsx(T,{day:c,type:a,isLoading:n})})})]}),e.jsxs(C,{isOpen:m&&!!c,onClose:()=>d(!1),variant:"inspect",className:"xl:hidden",children:[e.jsx(C.Header,{title:g,onClose:()=>d(!1)}),e.jsxs(C.Body,{children:[e.jsxs(C.Description,{className:"sr-only",children:["View notes and reminders for ",g,"."]}),e.jsx(T,{day:c,type:a,isLoading:n,presentation:"modal"})]})]})]})},ce=`
|
|
2
|
-
query NotesInDateRange($dateRange: DateRangeInput) {
|
|
3
|
-
notesInDateRange(dateRange: $dateRange) {
|
|
4
|
-
id
|
|
5
|
-
title
|
|
6
|
-
createdAt
|
|
7
|
-
updatedAt
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
`,me=`
|
|
11
|
-
query RemindersInDateRange($dateRange: DateRangeInput) {
|
|
12
|
-
remindersInDateRange(dateRange: $dateRange) {
|
|
13
|
-
id
|
|
14
|
-
noteId
|
|
15
|
-
reminderDate
|
|
16
|
-
completed
|
|
17
|
-
priority
|
|
18
|
-
content
|
|
19
|
-
note {
|
|
20
|
-
id
|
|
21
|
-
title
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
`,he=async t=>{const a=await Y(ce,{dateRange:t});if(a.type==="error")throw a;return a.notesInDateRange},ue=async t=>{const a=await Y(me,{dateRange:t});if(a.type==="error")throw a;return a.remindersInDateRange},ge=({year:t,month:a})=>{const n=G(t,a),r=$({queryKey:S.calendar.notesInDateRange(t,a),queryFn:()=>he(n)}),l=$({queryKey:S.reminders.inDateRange(t,a),queryFn:()=>ue(n)});return{notes:r.data??[],reminders:l.data??[],isLoading:r.isLoading||l.isLoading,isError:r.isError||l.isError}},xe=[],ye=[],A=V(U);function ke(){const t=A.useNavigate(),{year:a,month:n,type:r}=A.useSearch(),l=`${a}-${n}`,[m,d]=j.useState(()=>({monthKey:l})),{notes:c,reminders:h,isLoading:g,isError:s}=ge({year:a,month:n}),f=j.useMemo(()=>{const o=new Map;for(const i of c){const x=r==="create"?b(Number(i.createdAt)):b(Number(i.updatedAt)),v=`${x.year()}-${x.month()+1}-${x.date()}`,w=o.get(v)||[];w.push(i),o.set(v,w)}for(const[i,x]of o)o.set(i,W(x,r));const u=new Map;for(const i of h){const x=b(Number(i.reminderDate)),v=`${x.year()}-${x.month()+1}-${x.date()}`,w=u.get(v)||[];w.push(i),u.set(v,w)}return X(a,n).map(i=>({...i,notes:o.get(i.key)||xe,reminders:u.get(i.key)||ye}))},[a,n,c,h,r]),N=f.find(o=>o.isCurrentMonth&&o.isToday)?.key,M=m.monthKey===l?m.dayKey??N:N,R=()=>{const o=n===1?12:n-1,u=n===1?a-1:a;t({search:i=>({...i,month:o,year:u})})},k=()=>{const o=n===12?1:n+1,u=n===12?a+1:a;t({search:i=>({...i,month:o,year:u})})},y=()=>{const o=b(),u=o.month()+1,i=o.year();d({monthKey:`${i}-${u}`,dayKey:`${i}-${u}-${o.date()}`}),t({search:x=>({...x,month:u,year:i})})},O=o=>{o&&t({search:u=>({...u,type:o})})},q=o=>{d({monthKey:l,dayKey:o})};return e.jsx(Q,{title:"Calendar",variant:"none",children:s?e.jsx(ee,{children:"Failed to load calendar data. Please try again later."}):e.jsxs("div",{className:"sm:-mr-4",children:[e.jsx("div",{className:"border-b border-border-subtle/80 pb-4",children:e.jsx(le,{month:n,year:a,type:r,onPrevMonth:R,onNextMonth:k,onToday:y,onTypeChange:O})}),e.jsx("div",{className:"pt-4",children:e.jsx(de,{days:f,type:r,isLoading:g,selectedDayKey:M,onSelectedDayChange:q})})]})})}export{ke as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,j as n}from"./floating-ui.react-dom-BWTnA00G.js";import{A as d,T as Z}from"./time-BwwQGbK-.js";import{c as i}from"./Info.es-DVzN2joA.js";const p=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm-12-80V80a12,12,0,0,1,24,0v52a12,12,0,0,1-24,0Zm28,40a16,16,0,1,1-16-16A16,16,0,0,1,144,172Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm-6-82V80a6,6,0,0,1,12,0v56a6,6,0,0,1-12,0Zm16,36a10,10,0,1,1-10-10A10,10,0,0,1,138,172Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm-4-84V80a4,4,0,0,1,8,0v56a4,4,0,0,1-8,0Zm12,36a8,8,0,1,1-8-8A8,8,0,0,1,136,172Z"}))]]),m=e.forwardRef((t,r)=>e.createElement(d,{ref:r,...t,weights:p}));m.displayName="WarningCircleIcon";const g=m,u=({children:t,className:r="",tone:a="info"})=>{const l=a==="danger"?g:i,o=a==="danger"?"border-border-error/70 bg-accent-soft-danger/60":"border-border-subtle bg-hover-subtle/50",s=a==="danger"?"text-fg-error":"text-fg-tertiary",c=a==="danger"?"error":"secondary";return n.jsxs("div",{className:`flex items-center gap-2.5 rounded-[12px] border px-4 py-3 ${o} ${r}`,children:[n.jsx(l,{className:`h-4 w-4 shrink-0 ${s}`}),n.jsx(Z,{as:"div",variant:"meta",weight:"medium",tone:c,children:t})]})};export{u as C,g as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{a as x,n as f}from"./useNoteMutate-D-mZKXjl.js";import{A as g,G as j,q as H,P as l,T as i,B as c,D as m}from"./time-BwwQGbK-.js";import{f as E}from"./app-DzChh-V0.js";import{I as V,S as h}from"./url-Bp8sXMb4.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-BNoSRJP3.js";const w=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M228,104a12,12,0,0,1-24,0V69l-59.51,59.51a12,12,0,0,1-17-17L187,52H152a12,12,0,0,1,0-24h64a12,12,0,0,1,12,12Zm-44,24a12,12,0,0,0-12,12v64H52V84h64a12,12,0,0,0,0-24H48A20,20,0,0,0,28,80V208a20,20,0,0,0,20,20H176a20,20,0,0,0,20-20V140A12,12,0,0,0,184,128Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M184,80V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H176A8,8,0,0,1,184,80Z",opacity:"0.2"}),a.createElement("path",{d:"M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M192,136v72a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V80A16,16,0,0,1,48,64h72a8,8,0,0,1,0,16H48V208H176V136a8,8,0,0,1,16,0Zm32-96a8,8,0,0,0-8-8H152a8,8,0,0,0-5.66,13.66L172.69,72l-42.35,42.34a8,8,0,0,0,11.32,11.32L184,83.31l26.34,26.35A8,8,0,0,0,224,104Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M222,104a6,6,0,0,1-12,0V54.49l-69.75,69.75a6,6,0,0,1-8.48-8.48L201.51,46H152a6,6,0,0,1,0-12h64a6,6,0,0,1,6,6Zm-38,26a6,6,0,0,0-6,6v72a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V80a2,2,0,0,1,2-2h72a6,6,0,0,0,0-12H48A14,14,0,0,0,34,80V208a14,14,0,0,0,14,14H176a14,14,0,0,0,14-14V136A6,6,0,0,0,184,130Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M220,104a4,4,0,0,1-8,0V49.66l-73.16,73.17a4,4,0,0,1-5.66-5.66L206.34,44H152a4,4,0,0,1,0-8h64a4,4,0,0,1,4,4Zm-36,28a4,4,0,0,0-4,4v72a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V80a4,4,0,0,1,4-4h72a4,4,0,0,0,0-8H48A12,12,0,0,0,36,80V208a12,12,0,0,0,12,12H176a12,12,0,0,0,12-12V136A4,4,0,0,0,184,132Z"}))]]),d=a.forwardRef((r,t)=>a.createElement(g,{ref:t,...r,weights:w}));d.displayName="ArrowSquareOutIcon";const N=d;function T(){const{connectionId:r}=j({from:V}),t=x({queryKey:H.integrations.list(),queryFn:E}),n=t.data?.find(u=>u.id===r);if(t.isPending)return e.jsx("div",{className:"p-4",children:e.jsx(l,{title:"External app",children:e.jsx(i,{as:"p",children:"Loading app…"})})});if(t.error)return e.jsx("div",{className:"p-4",children:e.jsxs(l,{title:"External app",children:[e.jsx("p",{role:"alert",children:"Could not load this app."}),e.jsx(c,{onClick:()=>t.refetch(),children:"Retry"})]})});if(!n||!n.enabled||!n.manifest.launch)return e.jsx("div",{className:"p-4",children:e.jsxs(l,{title:"App unavailable",children:[e.jsx(i,{as:"p",children:"This app is disconnected, disabled, or has no page."}),e.jsx(m,{to:h,search:{connection:r},children:"Manage integrations"})]})});const s=n.manifest.launch,o=new URL(s.url),p=s.mode==="iframe"&&o.origin!==window.location.origin&&!(window.location.protocol==="https:"&&o.protocol!=="https:");return e.jsx(l,{title:n.manifest.name,variant:"none",children:e.jsxs("section",{"aria-label":"External app workspace",className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border-subtle px-4 py-1",children:[e.jsx(i,{as:"h1",variant:"meta",weight:"medium",className:"min-w-0 truncate",children:n.manifest.name}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(c,{asChild:!0,variant:"ghost",size:"sm",className:"min-h-11",children:e.jsxs(m,{to:h,search:{connection:r},title:"Manage access",children:[e.jsx(f,{"aria-hidden":"true",className:"h-4 w-4"}),e.jsx("span",{className:"sr-only sm:not-sr-only",children:"Manage access"})]})}),e.jsx(c,{asChild:!0,variant:"ghost",size:"sm",className:"min-h-11",children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",title:"Open in a new tab",children:[e.jsx(N,{"aria-hidden":"true",className:"h-4 w-4"}),e.jsx("span",{className:"sr-only sm:not-sr-only",children:"Open in a new tab"})]})})]})]}),p?e.jsx("iframe",{title:n.manifest.name,src:s.url,sandbox:"allow-scripts allow-forms",referrerPolicy:"no-referrer",className:"min-h-0 w-full flex-1 border-0 bg-surface"}):e.jsx("div",{className:"flex flex-1 items-center justify-center p-6",children:e.jsx(i,{as:"p",tone:"secondary",children:"Open this app in a new tab to use its service."})})]})})}export{T as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{A as V,N as K,T as m,D as k,O as Y,P as G,Q,a as W,b as I,x as J,y as C,h as X,i as F,q as $,E as q,B,k as ee,l as M}from"./time-BwwQGbK-.js";import{h as te,d as w,u as ae}from"./useNoteMutate-D-mZKXjl.js";import{u as re,R as se,f as ne,a as oe}from"./useReminderMutate-Cexk1ydX.js";import{N as L,R as ie}from"./url-Bp8sXMb4.js";import{s as le}from"./ArrowRight.es-nBJws3ws.js";const de=new Map([["bold",s.createElement(s.Fragment,null,s.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H69l51.52,51.51a12,12,0,0,1-17,17l-72-72a12,12,0,0,1,0-17l72-72a12,12,0,0,1,17,17L69,116H216A12,12,0,0,1,228,128Z"}))],["duotone",s.createElement(s.Fragment,null,s.createElement("path",{d:"M112,56V200L40,128Z",opacity:"0.2"}),s.createElement("path",{d:"M216,120H120V56a8,8,0,0,0-13.66-5.66l-72,72a8,8,0,0,0,0,11.32l72,72A8,8,0,0,0,120,200V136h96a8,8,0,0,0,0-16ZM104,180.69,51.31,128,104,75.31Z"}))],["fill",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H120v64a8,8,0,0,1-13.66,5.66l-72-72a8,8,0,0,1,0-11.32l72-72A8,8,0,0,1,120,56v64h96A8,8,0,0,1,224,128Z"}))],["light",s.createElement(s.Fragment,null,s.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H54.49l61.75,61.76a6,6,0,1,1-8.48,8.48l-72-72a6,6,0,0,1,0-8.48l72-72a6,6,0,0,1,8.48,8.48L54.49,122H216A6,6,0,0,1,222,128Z"}))],["regular",s.createElement(s.Fragment,null,s.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"}))],["thin",s.createElement(s.Fragment,null,s.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H49.66l65.17,65.17a4,4,0,0,1-5.66,5.66l-72-72a4,4,0,0,1,0-5.66l72-72a4,4,0,0,1,5.66,5.66L49.66,124H216A4,4,0,0,1,220,128Z"}))]]),P=s.forwardRef((t,a)=>s.createElement(V,{ref:a,...t,weights:de}));P.displayName="ArrowLeftIcon";const ce=P,me={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function pe({reminder:t,onUpdate:a,onDelete:r,onEdit:n}){const d=E=>{const v=w(Number(E)),b=w();return v.isSame(b,"day")?`Today at ${v.format("HH:mm")}`:v.isSame(b.add(1,"day"),"day")?`Tomorrow at ${v.format("HH:mm")}`:v.format("YYYY-MM-DD HH:mm")},i=E=>{const v=w(Number(E)),b=w(),O=v.diff(b,"hour"),T=v.diff(b,"minute")%60;return O<0||T<0?"Overdue":O===0?`${T}m remaining`:`${O}h ${T}m remaining`},x=t.completed?"Completed":i(t.reminderDate),p=x==="Overdue",h=t.priority||"low",g=h==="high"?"High":h==="medium"?"Medium":"Low",l=me[h],u=t.noteId.toString(),j=p?"text-fg-error":"text-fg-tertiary",f=t.content?.trim(),y=f||t.note?.title||"Untitled reminder",o=t.note?.title||"Untitled note",c=!!(f&&t.note?.title),R=d(t.reminderDate),H=[...!t.completed&&n?[{name:"Edit",onClick:()=>n(t)}]:[],...t.completed?[{name:"Reopen",onClick:()=>a(t.id,u,{completed:!1})}]:[]],U=[...H,...H.length>0?[{type:"separator",key:"destructive-actions"}]:[],{name:"Delete",onClick:()=>r(t.id,u)}];return e.jsxs("div",{className:"surface-base grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-x-2.5 gap-y-2 px-4 py-3 sm:grid-cols-[auto_minmax(0,1fr)_auto_auto] sm:items-center sm:gap-x-4 sm:gap-y-0",children:[e.jsx(K,{checked:t.completed,onChange:()=>a(t.id,u,{completed:!t.completed}),size:"sm","aria-label":`${t.completed?"Reopen":"Complete"} reminder: ${y}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(m,{as:"p",variant:"body",weight:"semibold",className:t.completed?"truncate text-fg-tertiary line-through":"truncate",children:!f&&t.note?e.jsx(k,{to:L,params:{id:String(t.note.id)},className:"transition-colors hover:text-fg-default hover:underline",children:y}):y}),c&&e.jsx(m,{as:"div",variant:"meta",tone:"secondary",className:t.completed?"mt-0.5 truncate text-fg-tertiary":"mt-0.5 truncate",children:e.jsx(k,{to:L,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:o})})]}),e.jsxs("div",{className:"col-start-2 row-start-2 flex flex-wrap items-center gap-x-2 gap-y-1 sm:col-start-auto sm:row-start-auto sm:shrink-0",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 rounded-full border border-border-subtle ${l}`,"aria-label":`${g} priority`,title:`${g} priority`}),e.jsx(m,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:t.completed?"text-fg-tertiary":void 0,children:R}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsx(m,{as:"span",variant:"label",weight:"medium",className:t.completed?"text-accent-success":j,children:x})]}),e.jsx("div",{className:"col-start-3 row-start-1 flex items-center justify-end gap-1.5 sm:col-start-auto sm:row-start-auto sm:shrink-0",children:e.jsx(Y,{button:e.jsx(te,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:U})})]})}const A=X(ie),D=25,_=5,Z={overdue:{title:"Overdue",description:"Recently missed reminders that still need a decision.",empty:"Nothing overdue"},today:{title:"Today",description:"Open reminders due before the day ends.",empty:"Nothing else due today"},upcoming:{title:"Upcoming",description:"Reminders scheduled after today.",empty:"Nothing upcoming"}},N=t=>t==="all"?void 0:t,ue=(t,a,r)=>{const n={status:"open",...N(a)?{priority:N(a)}:{},sortBy:"reminderDate"};return t==="overdue"?{...n,end:r.now,sortOrder:"desc"}:t==="today"?{...n,start:r.now,end:r.tomorrow,sortOrder:"asc"}:{...n,start:r.tomorrow,sortOrder:"asc"}};function he(){return e.jsxs("div",{role:"status","aria-label":"Loading reminders",className:"flex flex-col gap-2.5",children:[e.jsx(M,{height:"72px"}),e.jsx(M,{height:"72px"}),e.jsx(M,{height:"72px"})]})}function z({reminders:t,actions:a}){return e.jsx("div",{className:"flex flex-col gap-2.5",children:t.map(r=>e.jsx(pe,{reminder:r,onUpdate:a.onUpdate,onDelete:a.onDelete,onEdit:a.onEdit},r.id))})}function S({scope:t,collection:a,actions:r,onViewAll:n}){const d=Z[t],i=`reminder-${t}-heading`;return e.jsxs("section",{"aria-labelledby":i,className:"border-b border-border-subtle pb-5 last:border-b-0 last:pb-0",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{as:"h2",id:i,variant:"body",weight:"bold",children:d.title}),e.jsx(m,{as:"span",variant:"label",weight:"semibold",tone:"tertiary",className:"rounded-full bg-hover-subtle px-2 py-0.5",children:a.totalCount})]}),e.jsx(m,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:d.description})]}),a.totalCount>_?e.jsxs(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>n(t),children:["View all",e.jsx(le,{className:"size-3.5","aria-hidden":"true"})]}):null]}),a.reminders.length>0?e.jsx(z,{reminders:a.reminders,actions:r}):e.jsx("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-4",children:e.jsx(m,{as:"p",variant:"meta",weight:"medium",tone:"tertiary",children:d.empty})})]})}function ge({priority:t,boundaries:a,actions:r,onViewAll:n}){const d={now:a.now,tomorrow:a.tomorrow,priority:N(t),limit:_},{data:i}=F({queryKey:$.reminders.overview(d),queryFn:async()=>{const p=await ne(d);if(p.type==="error")throw p;return{overdue:p.overdue,today:p.today,upcoming:p.upcoming}}});return i.overdue.totalCount+i.today.totalCount+i.upcoming.totalCount===0?e.jsx(q,{title:"No open reminders",description:t==="all"?"Add a reminder inside any note to see it here.":"Try another priority or add a matching reminder."}):e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(S,{scope:"overdue",collection:i.overdue,actions:r,onViewAll:n}),e.jsx(S,{scope:"today",collection:i.today,actions:r,onViewAll:n}),e.jsx(S,{scope:"upcoming",collection:i.upcoming,actions:r,onViewAll:n})]})}function xe({status:t,scope:a,priority:r,page:n,boundaries:d,actions:i,onPageChange:x,onBackToOverview:p}){const g={filter:t==="completed"?{status:"completed",...N(r)?{priority:N(r)}:{},sortBy:"updatedAt",sortOrder:"desc"}:ue(a,r,d),limit:D,offset:(n-1)*D},{data:l}=F({queryKey:$.reminders.list(g),queryFn:async()=>{const y=await oe(g);if(y.type==="error")throw y;return y.reminders}}),u=Math.max(1,Math.ceil(l.totalCount/D));s.useEffect(()=>{n>u&&x(u)},[u,x,n]);const j=t==="completed"?null:Z[a],f=t==="completed"?"Completed":j?.title??"Open reminders";return e.jsxs("section",{"aria-labelledby":"reminder-list-heading",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[t==="open"?e.jsxs(B,{type:"button",variant:"ghost",size:"sm",className:"-ml-3 mb-1",onClick:p,children:[e.jsx(ce,{className:"size-3.5","aria-hidden":"true"}),"All open reminders"]}):null,e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{as:"h2",id:"reminder-list-heading",variant:"body",weight:"bold",children:f}),e.jsx(m,{as:"span",variant:"label",weight:"semibold",tone:"tertiary",className:"rounded-full bg-hover-subtle px-2 py-0.5",children:l.totalCount})]}),e.jsx(m,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:t==="completed"?"Completed reminders can be reopened or permanently deleted.":j?.description})]}),l.totalCount>0?e.jsxs(m,{as:"span",variant:"label",tone:"tertiary",children:[Math.min(g.offset+1,l.totalCount),"–",Math.min(g.offset+l.reminders.length,l.totalCount)," of ",l.totalCount]}):null]}),l.reminders.length>0?e.jsxs(e.Fragment,{children:[e.jsx(z,{reminders:l.reminders,actions:i}),u>1?e.jsx(ee,{page:n,last:u,onChange:x}):null]}):e.jsx(q,{title:t==="completed"?"No completed reminders":j?.empty,description:r==="all"?"There is nothing to manage in this list yet.":"Try another priority to see more reminders."})]})}function Ne(){const t=A.useNavigate(),{status:a,scope:r,priority:n,page:d}=A.useSearch(),{onUpdate:i,onDelete:x}=re(),p=ae(),[h,g]=s.useState(),[l]=s.useState(()=>{const o=w();return{now:o.toISOString(),tomorrow:o.add(1,"day").startOf("day").toISOString()}}),u=o=>{t({search:c=>({...c,page:o})})},f={onUpdate:i,onDelete:async(o,c)=>{await p("Delete this reminder? This cannot be undone.")&&await x(o,c)},onEdit:g},y=e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(W,{type:"single",variant:"quiet",size:"sm",value:a,onValueChange:o=>{o&&t({search:c=>({...c,status:o,scope:"all",page:1})})},children:[e.jsx(I,{value:"open",children:"Open"}),e.jsx(I,{value:"completed",children:"Completed"})]}),e.jsxs(J,{value:n,size:"sm",ariaLabel:"Filter reminders by priority",className:"w-[148px]",onValueChange:o=>{t({search:c=>({...c,priority:o,page:1})})},children:[e.jsx(C,{value:"all",children:"All priorities"}),e.jsx(C,{value:"high",children:"High priority"}),e.jsx(C,{value:"medium",children:"Medium priority"}),e.jsx(C,{value:"low",children:"Low priority"})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(G,{title:"Reminders",description:a==="completed"?"Review completed reminders and reopen anything that still needs attention.":"Act on what is overdue, due today, and coming next.",headerRight:y,children:e.jsx(Q,{fallback:e.jsx(he,{}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading the reminder workspace.",resetKeys:[a,r,n,d,l.now],children:a==="open"&&r==="all"?e.jsx(ge,{priority:n,boundaries:l,actions:f,onViewAll:o=>{t({search:c=>({...c,scope:o,page:1})})}}):e.jsx(xe,{status:a,scope:r,priority:n,page:d,boundaries:l,actions:f,onPageChange:u,onBackToOverview:()=>{t({search:o=>({...o,scope:"all",page:1})})}})})}),e.jsx(se,{isOpen:!!h,mode:"edit",reminder:h,onClose:()=>g(void 0),onSave:(o,c,R)=>{h&&i(h.id,String(h.noteId),{reminderDate:o,priority:c,content:R})}})]})}export{Ne as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as x,C as N,q as j,Q as y,P as c,k as P,E as T,l as o,h as v}from"./time-BwwQGbK-.js";import{F as h,N as k}from"./app-DzChh-V0.js";import{T as q}from"./url-Bp8sXMb4.js";import"./NotePropertiesPanel-os22Ppnu.js";import{e as w}from"./useNoteMutate-D-mZKXjl.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-BNoSRJP3.js";import"./AuxiliaryPanelHeader-BN_2axQu.js";import"./LinkSimple.es-BD4aGTc3.js";import"./Plus.es-Cl8zOOZa.js";const R=s=>{const{data:r}=x({queryKey:j.notes.tagList(s.searchParams),async queryFn(){const t=await N({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit});if(t.type==="error")throw t;return t.tagNotes}});return s.render(r)},g=v(q);function B(){const s=g.useNavigate(),{id:r}=g.useParams(),{page:t}=g.useSearch(),i=25,{onDelete:m,onPinned:u,deleteWarningDialog:f}=w();return e.jsxs(y,{fallback:e.jsx(c,{title:"Tagged Notes",heading:e.jsx(o,{width:148,height:24,className:"rounded-full"}),description:e.jsx(o,{width:196,height:16,className:"rounded-full"}),variant:"default",children:e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"})]})}),errorTitle:"Failed to load tagged notes",errorDescription:"Retry loading notes for this tag",resetKeys:[r,t,i],children:[e.jsx(R,{searchParams:{query:r,offset:(t-1)*i,limit:i},render:({notes:l,totalCount:n})=>{const d=l.flatMap(a=>a.tags).find(a=>a.id===r)?.name;return e.jsx(c,{title:d??"Tagged Notes",heading:d?n>0?`${d} (${n})`:d:"Tagged Notes",description:"Browse every note linked to this tag",variant:"default",children:e.jsx(h,{fallback:e.jsx(T,{title:"No tagged notes yet",description:"Notes tagged with this label will appear here"}),children:l.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-5",children:l.map(a=>e.jsx(k,{...a,onPinned:()=>u(a.id,a.pinned),onDelete:()=>m(a.id)},a.id))}),e.jsx(h,{fallback:null,children:n&&i<n&&e.jsx(P,{page:t,last:Math.ceil(n/i),onChange:a=>{s({search:p=>({...p,page:a})})}})})]})})})}}),f]})}export{B as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as h,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{l as Lt,m as Se,n as de,K as Pe,P as ut,D as Ae,o as Ve,p as _t,q as qt,t as Ut,v as mt,C as Me,w as Wt,x as pt,M as Gt,y as Qt,S as ht,z as Yt,A as bt,B as Ht,E as Zt,G as Xt,H as Jt,I as ea,J as Ie,L as ta,O as aa,Q as sa,R as Be,U as ra,V as na,W as ia,X as la}from"./app-DzChh-V0.js";import{d as se,a as be,k as oa,h as Fe,m as xt,M as yt,u as da}from"./useNoteMutate-D-mZKXjl.js";import{aa as ca,ab as Ke,ac as ua,ad as ma,ae as pa,A as ha,q as _,T as o,B,M as Q,u as gt,X as ba,e as ft,l as xe,c as ie,D as Ee,R as Ne,O as Oe,af as xa,k as ya,L as W,I as Ce,a as Le,b as oe,N as _e,x as ee,y as I,d as ga,ag as fa,P as va,E as qe,h as ja}from"./time-BwwQGbK-.js";import{f as wa}from"./tag.api-kKZl04yY.js";import{S as ke}from"./SurfaceCard-jL2qzrzF.js";import{N as Re,V as Na}from"./url-Bp8sXMb4.js";import{V as G}from"./ViewChip-CVe_HNyd.js";import{e as Ca,g as ka,t as ye,d as Ta,b as Da,c as Sa,C as Pa,a as Aa}from"./calendar-data-BQ24n348.js";import{s as Va}from"./FileText.es-C-bpw8dQ.js";import{s as Ma}from"./ArrowRight.es-nBJws3ws.js";import{s as Fa}from"./CheckCircle.es-CyY9aLBF.js";import{n as Te}from"./Plus.es-Cl8zOOZa.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-BNoSRJP3.js";var Ea=class extends ca{constructor(t,a){super(t,a)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){super.setOptions({...t,behavior:Ke()})}getOptimisticResult(t){return t.behavior=Ke(),super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,a){const{state:s}=t,i=super.createResult(t,a),{isFetching:n,isRefetching:c,isError:b,isRefetchError:d}=i,j=s.fetchMeta?.fetchMore?.direction,k=b&&j==="forward",A=n&&j==="forward",x=b&&j==="backward",E=n&&j==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ma(a,s.data),hasPreviousPage:ua(a,s.data),isFetchNextPageError:k,isFetchingNextPage:A,isFetchPreviousPageError:x,isFetchingPreviousPage:E,isRefetchError:d&&!k&&!x,isRefetching:c&&!A&&!E}}};function Oa(t,a){return pa(t,Ea)}const Ra=new Map([["bold",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Z"}))],["duotone",h.createElement(h.Fragment,null,h.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),h.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["fill",h.createElement(h.Fragment,null,h.createElement("path",{d:"M232,128A104,104,0,1,1,128,24,104.13,104.13,0,0,1,232,128Z"}))],["light",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"}))],["regular",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Z"}))],["thin",h.createElement(h.Fragment,null,h.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Z"}))]]),vt=h.forwardRef((t,a)=>h.createElement(ha,{ref:a,...t,weights:Ra}));vt.displayName="CircleIcon";const za=vt,Ue=2,$a=(t,a)=>t.displayOptions.calendarDateField==="property"?a?.name??t.displayOptions.calendarDatePropertyKey??"Date property":t.displayOptions.calendarDateField==="updatedAt"?"Updated date":"Created date",Ia=t=>{const a=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!a)return null;const s=Number(a[1]),i=Number(a[2]),n=Number(a[3]),c=new Date(Date.UTC(s,i-1,n));return c.getUTCFullYear()!==s||c.getUTCMonth()!==i-1||c.getUTCDate()!==n?null:`${s}-${i}-${n}`},Ba=t=>{const a=ye(t);if(!Number.isFinite(a))return null;const s=se(a);return`${s.year()}-${s.month()+1}-${s.date()}`},Ka=(t,a)=>t.isCurrentMonth?a?"bg-elevated shadow-[inset_0_0_0_1px_var(--border-secondary)] hover:bg-surface":"bg-surface hover:bg-muted":"cursor-default bg-[var(--page-bg)] text-fg-disabled",La=t=>t.isToday?"bg-cta font-semibold text-fg-on-filled":t.isCurrentMonth?t.isSunday?"font-semibold text-fg-weekend":"font-semibold text-fg-secondary":"font-medium text-fg-tertiary";function _a({section:t,calendarDateProperty:a,navigationState:s,onNavigationStateChange:i}){const n=se(),c=s.calendar?.year??n.year(),b=s.calendar?.month??n.month()+1,d=se(new Date(c,b-1,1)).format("MMMM YYYY"),j=t.displayOptions.calendarDateField,k=j==="property",A=$a(t,a),x=k?Ca(c,b):ka(c,b),[E,p]=h.useState(),{data:m,isPending:v,isError:D,refetch:P}=be({queryKey:_.views.sectionCalendar(t.id,{year:c,month:b,dateField:j,propertyKey:t.displayOptions.calendarDatePropertyKey}),async queryFn(){const u=await Lt(t.id,x);if(u.type==="error")throw u;return u.viewSectionCalendarNotes}}),V=h.useMemo(()=>{const u=new Map;for(const C of m??[]){const y=k?Ia(C.calendarDate):Ba(C.calendarDate);if(!y)continue;const T=u.get(y)??[];T.push(C),u.set(y,T)}for(const C of u.values())C.sort((y,T)=>(k?y.calendarDate.localeCompare(T.calendarDate):ye(y.calendarDate)-ye(T.calendarDate))||y.id.localeCompare(T.id));return Ta(c,b).map(C=>({...C,notes:u.get(C.key)??[]}))},[m,k,b,c]),w=V.find(u=>u.key===E),R=w?se(new Date(w.year,w.month-1,w.day)).format("dddd, MMMM D"):"Day notes",f=(u,C)=>{const y=u===n.year()&&C===n.month()+1;p(void 0),i(T=>({...T,calendar:y?void 0:{year:u,month:C}}))},S=u=>{const C=new Date(c,b-1+u,1);f(C.getFullYear(),C.getMonth()+1)},z=m?.length??0;return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/75 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"h3",variant:"subheading",weight:"semibold",tracking:"tight",children:d}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:["Notes placed by ",A.toLowerCase()]})]}),e.jsx(Da,{onToday:()=>f(n.year(),n.month()+1),onPrevMonth:()=>S(-1),onNextMonth:()=>S(1)})]}),D?e.jsxs("div",{className:"m-4 rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this calendar"}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:["Retry to refresh notes for ",d,"."]}),e.jsx("div",{className:"mt-3",children:e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>{P()},children:"Retry"})})]}):e.jsx("div",{className:"min-w-0 px-4 py-3.5",children:e.jsx(Sa,{isLoading:v,ariaLabel:`${d} note calendar`,children:V.map(u=>{const C=u.key===E,y=u.notes.slice(0,Ue).map(T=>({key:`note-${T.id}`,type:"note",title:T.title||"Untitled"}));return e.jsx(Pa,{day:u.day,dateLabel:se(new Date(u.year,u.month-1,u.day)).format("dddd, MMMM D, YYYY"),cellClassName:Ka(u,C),dayNumberClassName:La(u),isCurrentMonth:u.isCurrentMonth,isToday:u.isToday,isSelected:C,noteCount:u.notes.length,reminderCount:0,previewItems:y,overflowCount:Math.max(0,u.notes.length-Ue),density:"compact",showReminderSummary:!1,onSelect:()=>p(u.key)},u.key)})})}),e.jsx("div",{className:"mt-auto border-t border-border-subtle/75 px-4 py-3",children:e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:v?"Loading calendar notes...":D?`Calendar notes for ${d} are unavailable`:z===0?`No matching notes in ${d}`:`${z} matching note${z===1?"":"s"} in ${d}`})}),e.jsxs(Q,{isOpen:!!w,onClose:()=>p(void 0),variant:"inspect",children:[e.jsx(Q.Header,{title:R,onClose:()=>p(void 0)}),e.jsxs(Q.Body,{children:[e.jsxs(Q.Description,{className:"sr-only",children:["View matching notes placed on ",R," by ",A.toLowerCase(),"."]}),e.jsxs(o,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mb-3",children:[w?.notes.length??0," matching"," ",(w?.notes.length??0)===1?"note":"notes"]}),e.jsx("div",{className:"flex flex-col gap-1",children:w?.notes.map(u=>e.jsx(Aa,{params:{id:u.id},header:e.jsx(Va,{size:12}),title:u.title||"Untitled",meta:k?void 0:se(ye(u.calendarDate)).format("HH:mm")},u.id))})]})]})]})}const ge=6,De=["title","tags","properties","createdAt","updatedAt"],jt="createdAt",qa={activeTabId:null,tabs:[]},Ua=t=>{const a=t.trim();return a?a.startsWith("@")?a:a.startsWith("#")?"":`@${a}`:""},wt=(t,a,s)=>{if(a===s)return t;const i=t.findIndex(d=>d.id===a),n=t.findIndex(d=>d.id===s);if(i<0||n<0)return t;const c=[...t],[b]=c.splice(i,1);return c.splice(n,0,b),c},Nt=(t,a,s)=>{const i=t.findIndex(c=>c.id===a),n=i+(s==="previous"?-1:1);return i>=0&&n>=0&&n<t.length?t[n]?.id:void 0},We=t=>{const a=t.flatMap(s=>typeof s=="string"?s.split(","):[]);return Array.from(new Set(a.map(Ua).filter(Boolean)))},Wa=t=>t.tabs.length===0?null:t.activeTabId?t.tabs.find(a=>a.id===t.activeTabId)??t.tabs[0]??null:t.tabs[0]??null,Ga=(t,a)=>t.tabs.some(s=>s.id===a)?{...t,activeTabId:a}:t,Ct=(t,a,s)=>({...t,tabs:wt(t.tabs,a,s)}),kt=(t,a,s,i)=>({...t,tabs:t.tabs.map(n=>n.id===a?{...n,sections:wt(n.sections,s,i)}:n)}),Qa=(t,a,s)=>{const i=Nt(t.tabs,a,s);return i?Ct(t,a,i):t},Ya=(t,a,s,i)=>{const n=t.tabs.find(b=>b.id===a)?.sections??[],c=Nt(n,s,i);return c?kt(t,a,s,c):t},Ge=t=>t==="or"?"OR — any selected tag":"AND — all selected tags",Ha=t=>t==="or"?"OR":"AND",Tt=t=>{switch(t){case"notEquals":return"is not";case"contains":return"contains";case"notContains":return"does not contain";case"before":return"before";case"after":return"after";case"exists":return"is set";case"notExists":return"is empty";default:return"is"}},Za=t=>{switch(t){case"table":return"Table";case"board":return"Board";case"calendar":return"Calendar";default:return"List"}},Dt=t=>{switch(t){case"tags":return"Tags";case"properties":return"Properties";case"createdAt":return"Created";case"updatedAt":return"Updated";default:return"Title"}},fe=t=>{const a=new Set(De),s=(t??[]).filter(n=>a.has(n)),i=Array.from(new Set(s));return i.length===0?[...De]:i.includes("title")?i:["title",...i]},ze=t=>Array.from(new Set((t??[]).map(a=>a.trim()).filter(Boolean))).slice(0,ge),St=t=>t==="updatedAt"||t==="property"?t:jt,Pt=t=>{const a=St(t?.calendarDateField);return{tableColumns:fe(t?.tableColumns),tablePropertyKeys:ze(t?.tablePropertyKeys),boardGroupByPropertyKey:t?.boardGroupByPropertyKey?.trim()||null,calendarDateField:a,calendarDatePropertyKey:a==="property"&&t?.calendarDatePropertyKey?.trim()||null}},Xa=t=>{const a=Tt(t.operator);return t.operator==="exists"||t.operator==="notExists"?`${t.name} ${a}`:`${t.name} ${a} ${t.value??""}`.trim()},Ja=(t,a={})=>{const s={...t,...a};return{title:s.title,displayType:s.displayType,displayOptions:Pt(s.displayOptions),tagNames:s.tagNames,mode:s.mode,propertyFilters:s.propertyFilters.map(i=>({key:i.key,valueType:i.valueType,operator:i.operator,value:i.value})),sortBy:s.sortBy,sortOrder:s.sortOrder,limit:s.limit}},At="view-board-column:unassigned",es=t=>t===null?At:`view-board-column:value:${encodeURIComponent(t)}`,ts=t=>[...[...t].sort((a,s)=>a.order-s.order||a.label.localeCompare(s.label)).map(a=>({id:es(a.value),label:a.label,value:a.value,color:a.color??null})),{id:At,label:"Unassigned",value:null,color:null}];function as({note:t,column:a,columns:s,isMoving:i,onMove:n}){const{attributes:c,listeners:b,setNodeRef:d,setActivatorNodeRef:j,transform:k,isDragging:A}=Ut({id:`view-board-note:${t.id}`,data:{note:t,sourceValue:a.value},disabled:i});return e.jsx("article",{ref:d,style:{transform:Me.Translate.toString(k)},className:ie("group rounded-[14px] border border-border-subtle bg-elevated px-3 py-2.5 transition-[opacity,background-color,border-color] hover:border-border-secondary/80 hover:bg-hover-subtle/35",(A||i)&&"opacity-55",A&&"z-20 border-accent-primary/45 bg-elevated ring-2 ring-accent-primary/10"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("button",{type:"button",ref:j,"aria-label":`Drag ${t.title||"Untitled"} to another column`,...c,...b,className:"focus-ring-soft mt-0.5 hidden size-7 shrink-0 touch-none items-center justify-center rounded-[9px] text-fg-tertiary outline-none hover:bg-hover-subtle hover:text-fg-default sm:inline-flex",children:e.jsx(mt,{className:"size-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(o,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"leading-[1.4]",children:e.jsx(Ee,{to:Re,params:{id:t.id},className:"line-clamp-2 transition-colors hover:text-fg-default/80",children:t.title||"Untitled"})}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:["Updated ",Ne(Number(t.updatedAt))]})]}),e.jsx(Oe,{button:e.jsx(Fe,{label:`Move ${t.title||"Untitled"}`,size:"sm"}),items:s.filter(x=>x.value!==a.value).map(x=>({name:`Move to ${x.label}`,onClick:()=>n(t,a.value,x.value)}))})]})})}function ss({section:t,groupProperty:a,column:s,columns:i,index:n,scrollRootRef:c,movingNoteIds:b,onMove:d,pageCount:j,onPageCountChange:k}){const A=h.useRef(null),[x,E]=h.useState(n<4),{isOver:p,setNodeRef:m}=_t({id:s.id,data:{optionValue:s.value}});h.useEffect(()=>{if(x||!A.current)return;if(typeof IntersectionObserver>"u"){E(!0);return}const y=new IntersectionObserver(T=>{T.some(Y=>Y.isIntersecting)&&(E(!0),y.disconnect())},{root:c.current,rootMargin:"0px 320px",threshold:.01});return y.observe(A.current),()=>y.disconnect()},[c,x]);const{data:v,isPending:D,isError:P,refetch:V,fetchNextPage:w,hasNextPage:R,isFetchingNextPage:f,isFetchNextPageError:S}=Oa({queryKey:_.views.sectionBoardColumnPages(t.id,a.key,s.value,t.limit),enabled:x,initialPageParam:0,async queryFn({pageParam:y}){const T=await qt(t.id,{optionValue:s.value,limit:t.limit,offset:y});if(T.type==="error")throw T;return T.viewSectionBoardColumn},getNextPageParam(y,T){return T.reduce((te,H)=>te+H.notes.length,0)<y.totalCount?T.length*t.limit:void 0}}),z=h.useMemo(()=>Array.from(new Map((v?.pages??[]).flatMap(y=>y.notes).map(y=>[y.id,y])).values()),[v?.pages]),u=v?.pages[0]?.totalCount;h.useEffect(()=>{!x||!v||v.pages.length>=j||!R||f||S||w()},[v,w,R,S,f,j,x]),h.useEffect(()=>{if(u===void 0)return;const y=Math.max(1,Math.ceil(u/t.limit));j>y&&k(y)},[k,j,t.limit,u]);const C=y=>{A.current=y,m(y)};return e.jsxs("section",{ref:C,"aria-label":`${s.label} column`,className:ie("flex min-h-[248px] w-[17rem] shrink-0 flex-col rounded-[18px] border bg-subtle/30 transition-[border-color,background-color] sm:w-[18rem]",p?"border-accent-primary/50 bg-accent-primary/6":"border-border-subtle"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border-subtle/75 px-3.5 py-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2.5 shrink-0 rounded-full border border-black/5",style:{backgroundColor:s.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx(o,{as:"h3",variant:"label",weight:"semibold",className:"truncate",children:s.label})]}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary","aria-label":u===void 0?"Card count loading":`${u} cards`,className:"inline-flex min-w-6 justify-center rounded-full bg-elevated px-2 py-0.5 tabular-nums",children:u??"–"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 p-2.5",children:[x?D&&!v?e.jsxs(e.Fragment,{children:[e.jsx(xe,{height:"76px",className:"rounded-[14px]"}),e.jsx(xe,{height:"76px",className:"rounded-[14px]"})]}):P?e.jsxs("div",{className:"rounded-[14px] border border-dashed border-border-subtle bg-elevated/60 p-3",children:[e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Failed to load this column."}),e.jsx(B,{type:"button",variant:"ghost",size:"sm",className:"mt-2",onClick:()=>{V()},children:"Retry"})]}):z.length===0?e.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-center",children:e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Drop a note here"})}):z.map(y=>e.jsx(as,{note:y,column:s,columns:i,isMoving:b.has(y.id),onMove:d},y.id)):e.jsx("button",{type:"button",className:"focus-ring-soft flex min-h-28 items-center justify-center rounded-[14px] border border-dashed border-border-subtle px-3 text-sm text-fg-tertiary outline-none hover:bg-elevated",onClick:()=>E(!0),children:"Load cards"}),R?e.jsx(B,{type:"button",variant:"ghost",size:"sm",className:"mt-auto w-full",disabled:f,onClick:()=>{S||k(j+1),w()},children:f?"Loading...":S?"Retry loading cards":`Load more (${Math.max(0,(u??0)-z.length)})`}):null]})]})}function rs({section:t,groupProperty:a,navigationState:s={},onNavigationStateChange:i=()=>{}}){const n=gt(),c=ft(),b=h.useRef(null),[d,j]=h.useState(()=>new Set),k=h.useMemo(()=>ts(a.options),[a.options]),A=Se(de(ut,{activationConstraint:{distance:6}}),de(Pe)),x=h.useCallback(async(p,m,v)=>{if(m===v||d.has(p.id))return;j(V=>new Set(V).add(p.id));const D=_.views.sectionBoardAll(t.id),P=n.getQueriesData({queryKey:D});for(const[V,w]of P){if(!w||!Array.isArray(w.pages))continue;const R=V[3];if(R?.groupPropertyKey!==a.key)continue;const f=R.optionValue===m,S=R.optionValue===v,z=R.pageSize??t.limit;let u=w.pages.flatMap(y=>y.notes).filter(y=>y.id!==p.id);S&&(u=[p,...u]);const C=Math.max(0,(w.pages[0]?.totalCount??0)-(f?1:0)+(S?1:0));n.setQueryData(V,{...w,pages:w.pages.map((y,T)=>({totalCount:C,notes:u.slice(T*z,(T+1)*z)}))})}try{const V=await ba({id:p.id,expectedUpdatedAt:p.updatedAt,...v===null?{deleteKeys:[a.key]}:{set:[{key:a.key,name:a.name,value:v,valueType:"select"}]}});if(V.type==="error"){for(const[w,R]of P)n.setQueryData(w,R);c(V.errors[0]?.message??"Failed to move this note.");return}await Promise.all([oa(n),n.invalidateQueries({queryKey:_.notes.propertyKeysAll(),exact:!1})])}catch{for(const[V,w]of P)n.setQueryData(V,w);c("Failed to move this note.")}finally{j(V=>{const w=new Set(V);return w.delete(p.id),w})}},[a.key,a.name,d,n,t.id,t.limit,c]),E=({active:p,over:m})=>{const v=p.data.current?.note,D=p.data.current?.sourceValue,P=m?.data.current?.optionValue;!v||D===void 0||P===void 0||x(v,D,P)};return e.jsx(Ae,{sensors:A,collisionDetection:Ve,onDragEnd:E,children:e.jsx("div",{ref:b,"data-scroll-restoration-id":`view-board-${t.id}`,className:"overflow-x-auto overscroll-x-contain px-3 py-3.5 [scrollbar-gutter:stable] sm:px-4","aria-label":`Board grouped by ${a.name}`,children:e.jsx("div",{className:"flex min-w-max items-stretch gap-3 pb-1",children:k.map((p,m)=>e.jsx(ss,{section:t,groupProperty:a,column:p,columns:k,index:m,scrollRootRef:b,movingNoteIds:d,pageCount:s.columns?.[p.id]??1,onPageCountChange:v=>i(D=>({...D,columns:{...D.columns,[p.id]:v}})),onMove:(v,D,P)=>{x(v,D,P)}},p.id))})})})}const ns="group flex min-h-[72px] items-center justify-between gap-3 px-4 py-3 transition-colors hover:bg-hover-subtle",is=t=>t.valueType==="select"?t.option?.label??t.value:t.valueType==="boolean"?t.value==="true"?"True":"False":t.value,ls=t=>{const a=t.tags.slice(0,2),s=t.tags.length-a.length;return a.length===0?null:e.jsxs(e.Fragment,{children:[a.map(i=>e.jsx(G,{size:"compact",className:"max-w-[116px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:i.name},i.id)),s>0&&e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]})]})},os=t=>{const a=t.properties??[],s=a.slice(0,2),i=a.length-s.length;return s.length===0?null:e.jsxs(e.Fragment,{children:[s.map(n=>e.jsxs(G,{size:"compact",truncateContent:!1,className:"max-w-[220px] gap-1.5 border-border-subtle bg-subtle/55 text-fg-secondary",children:[n.valueType==="select"?e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:n.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}):null,e.jsx("span",{className:"max-w-[72px] shrink truncate text-fg-tertiary",children:n.name}),e.jsx("span",{className:"min-w-0 truncate",children:is(n)||"—"})]},n.key)),i>0?e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",i," properties"]}):null]})};function ds({notes:t,isPending:a,isError:s,onRetry:i}){return a?e.jsxs("div",{className:"overflow-hidden bg-transparent",children:[e.jsx("div",{className:"h-[72px] animate-pulse bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"}),e.jsx("div",{className:"h-[72px] animate-pulse border-t border-border-subtle/70 bg-subtle/35"})]}):s?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this section"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Retry"})})]}):t.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"No notes match yet"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:"divide-y divide-border-subtle/70 bg-transparent",children:t.map(n=>e.jsxs(Ee,{to:Re,params:{id:n.id},className:ns,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n.pinned?e.jsx(xt,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(o,{as:"div",variant:"body",weight:"semibold",tracking:"tight",className:"line-clamp-1",children:n.title||"Untitled"})]}),e.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap items-center gap-1.5",children:[os(n),ls(n),e.jsxs(o,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"sm:hidden",children:["Updated ",Ne(Number(n.updatedAt))]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 pl-2",children:[e.jsx(o,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"hidden sm:inline",children:Ne(Number(n.updatedAt))}),e.jsx(Ma,{className:"size-4 text-fg-tertiary transition-transform group-hover:translate-x-0.5"})]})]},n.id))})}const cs={title:300,tags:200,createdAt:148,updatedAt:148},us={title:"title",createdAt:"createdAt",updatedAt:"updatedAt"},ms="flex h-[24px] min-w-0 max-w-full items-center gap-1.5 overflow-hidden whitespace-nowrap",Vt="text-xs leading-5 text-fg-tertiary",ps=t=>se(Number(t)).format("MMM D, YYYY"),hs=t=>t==="text"||t==="url"?220:t==="date"?168:156,Mt=t=>t.kind==="property"?hs(t.valueType):cs[t.key],bs=(t,a,s)=>{const i=new Map(s.map(d=>[d.key,d])),n=new Map(a.flatMap(d=>d.properties??[]).map(d=>[d.key,d])),c=ze(t.displayOptions.tablePropertyKeys),b=Array.from(new Set([...t.propertyFilters.map(d=>d.key),...a.flatMap(d=>(d.properties??[]).map(j=>j.key))])).slice(0,3);return(c.length>0?c:b).flatMap(d=>{const j=i.get(d),k=n.get(d);return!j&&!k?[]:[{kind:"property",key:d,name:j?.name??k?.name??d,valueType:j?.valueType??k?.valueType??"text"}]})},xs=(t,a,s)=>{const i=bs(t,a,s);return fe(t.displayOptions.tableColumns).reduce((n,c)=>(c==="properties"?n.push(...i):n.push({kind:"base",key:c}),n),[])},ys=t=>t.reduce((a,s)=>a+Mt(s),0),gs=t=>{if(t.tags.length===0)return e.jsx("span",{className:Vt,children:"—"});const a=t.tags.slice(0,3),s=t.tags.length-a.length;return e.jsxs("div",{className:ms,children:[a.map(i=>e.jsx(G,{size:"compact",className:"max-w-[132px] shrink-0 border-border-subtle bg-transparent text-fg-secondary",children:i.name},i.id)),s>0?e.jsxs(G,{size:"compact",className:"shrink-0 border-border-subtle bg-subtle text-fg-tertiary",children:["+",s]}):null]})},fs=t=>{if(!t)return e.jsx("span",{className:Vt,children:"—"});if(t.valueType==="select")return e.jsx(G,{size:"compact",className:"max-w-full border-border-subtle bg-subtle/65 text-fg-secondary",truncateContent:!1,children:e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"size-2 shrink-0 rounded-full border border-black/5",style:{backgroundColor:t.option?.color??"var(--color-fg-tertiary)"},"aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate",children:t.option?.label??t.value})]})});if(t.valueType==="boolean"){const a=t.value==="true",s=a?Fa:za;return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-fg-secondary",children:[e.jsx(s,{className:"size-3.5 text-fg-tertiary",weight:a?"fill":"regular"}),a?"True":"False"]})}return e.jsx("span",{className:ie("block truncate text-sm text-fg-secondary",t.valueType==="number"&&"tabular-nums"),title:t.value,children:t.value||"—"})};function vs({section:t,notes:a,isPending:s,isError:i,onRetry:n,onSortChange:c,isSortPending:b,activeSortBy:d=t.sortBy,activeSortOrder:j=t.sortOrder,availableProperties:k=[],surface:A="flush"}){const x=xs(t,a,k),E=ys(x),p=A==="card"?"overflow-x-auto rounded-[16px] border border-border-subtle bg-elevated":"overflow-x-auto bg-transparent",m=A==="card"?"overflow-hidden rounded-[16px] border border-border-subtle bg-elevated":"overflow-hidden bg-transparent",v=A==="card"?"bg-elevated":"bg-transparent",D=A==="card"?"bg-subtle/65":"bg-subtle/45",P=A==="card"?"bg-elevated":"bg-transparent",V=A==="card"?"var(--elevated)":"var(--surface)",w=f=>{if(f.kind==="property")return e.jsxs("th",{className:"px-3 py-2 text-left",children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",className:"truncate",title:f.name,children:f.name}),e.jsx(o,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5 capitalize",children:f.valueType})]},`property:${f.key}`);const S=us[f.key],z=Dt(f.key),u=S?d===S:!1,C=f.key==="title";return e.jsx("th",{"aria-sort":u?j==="asc"?"ascending":"descending":void 0,className:ie("px-3 py-2.5 text-xs font-semibold text-fg-tertiary",C&&"lg:sticky lg:left-0 lg:z-20"),style:C?{background:`linear-gradient(var(--subtle), var(--subtle)), ${V}`}:void 0,children:S?e.jsxs("button",{type:"button",className:"focus-ring-soft -ml-1 inline-flex items-center gap-1 rounded-[8px] px-1 py-0.5 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-secondary disabled:cursor-wait disabled:opacity-60",disabled:b,onClick:()=>c(S),children:[e.jsx("span",{children:z}),e.jsx("span",{"aria-hidden":"true",className:"text-[10px] text-fg-tertiary",children:u?j==="asc"?"↑":"↓":"↕"})]}):z},f.key)},R=(f,S)=>{if(S.kind==="property")return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:fs(f.properties?.find(z=>z.key===S.key))},`property:${S.key}`);switch(S.key){case"tags":return e.jsx("td",{className:"overflow-hidden px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:gs(f)},S.key);case"createdAt":case"updatedAt":{const z=S.key==="createdAt"?f.createdAt:f.updatedAt;return e.jsx("td",{className:"whitespace-nowrap px-3 py-2.5 align-middle transition-colors group-hover:bg-hover-subtle",children:e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",title:se(Number(z)).format("MMM D, YYYY h:mm A"),children:ps(z)})},S.key)}default:return e.jsxs("td",{className:"relative px-3 py-2.5 align-middle lg:sticky lg:left-0 lg:z-10",style:{background:V},children:[e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-hover-subtle opacity-0 transition-opacity group-hover:opacity-100"}),e.jsxs("div",{className:"relative z-10 flex min-w-0 items-center gap-2",children:[f.pinned?e.jsx(xt,{className:"size-3.5 shrink-0 text-fg-tertiary",weight:"fill","aria-label":"Pinned"}):null,e.jsx(o,{as:"div",variant:"body",weight:"semibold",className:"min-w-0 line-clamp-1",children:e.jsx(Ee,{to:Re,params:{id:f.id},className:"focus-ring-soft rounded-[6px] outline-none transition-colors hover:text-fg-default/80",children:f.title||"Untitled"})})]})]},S.key)}};return s?e.jsxs("div",{className:m,children:[e.jsx("div",{className:"h-11 animate-pulse bg-subtle/50"}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`}),e.jsx("div",{className:`h-14 animate-pulse border-t border-border-subtle ${v}`})]}):i?e.jsxs("div",{className:"rounded-[16px] border border-border-subtle bg-subtle/30 p-4",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load this table"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to refresh this saved query."}),e.jsx("div",{className:"mt-3",children:e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:n,children:"Retry"})})]}):a.length===0?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"No rows yet"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add matching notes, or edit this view query."})]}):e.jsx("div",{className:p,"data-scroll-restoration-id":`view-table-${t.id}`,"aria-label":"Scrollable view table",children:e.jsxs("table",{className:"w-full table-fixed border-collapse text-left",style:{minWidth:E},children:[e.jsx("caption",{className:"sr-only",children:"View query results as a table"}),e.jsx("colgroup",{children:x.map(f=>e.jsx("col",{style:{width:`${Mt(f)/E*100}%`}},f.kind==="property"?`property:${f.key}`:f.key))}),e.jsx("thead",{className:D,children:e.jsx("tr",{className:"border-b border-border-subtle",children:x.map(w)})}),e.jsx("tbody",{className:P,children:a.map(f=>e.jsx("tr",{className:"group h-12 border-b border-border-subtle/70 last:border-b-0",children:x.map(S=>R(f,S))},f.id))})]})})}const Qe=({displayName:t,onRetry:a})=>e.jsxs("div",{className:"m-4 rounded-[16px] border border-border-subtle bg-hover-subtle/70 p-4",children:[e.jsxs(o,{as:"p",variant:"body",weight:"semibold",children:["Failed to load ",t," properties"]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry to check the configured property without changing this view."}),e.jsx("div",{className:"mt-3",children:e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:a,children:"Retry"})})]});function js({section:t,notes:a,isPending:s,isError:i,onRetry:n,onEdit:c,onSortChange:b,isSortPending:d,activeSortBy:j=t.sortBy,activeSortOrder:k=t.sortOrder,availableProperties:A=[],isPropertiesLoading:x=!1,isPropertiesError:E=!1,onRetryProperties:p=()=>{},navigationState:m={},onNavigationStateChange:v=()=>{}}){if(t.displayType==="board"){const D=A.find(P=>P.key===t.displayOptions.boardGroupByPropertyKey&&P.valueType==="select");return!D&&x?e.jsxs("div",{className:"flex gap-3 overflow-hidden px-4 py-3.5",children:[e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"}),e.jsx("div",{className:"h-[248px] w-[18rem] shrink-0 animate-pulse rounded-[18px] bg-subtle/50"})]}):!D&&E?e.jsx(Qe,{displayName:"board",onRetry:p}):!D||D.options.length===0?e.jsxs("div",{className:"m-4 rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Board grouping is unavailable"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Choose an existing select property with options to restore this board."}),e.jsx("div",{className:"mt-3",children:e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Edit board"})})]}):e.jsx(rs,{section:t,groupProperty:D,navigationState:m,onNavigationStateChange:v})}if(t.displayType==="table")return e.jsx(vs,{section:t,notes:a,isPending:s,isError:i,onRetry:n,onSortChange:b,isSortPending:d,activeSortBy:j,activeSortOrder:k,availableProperties:A});if(t.displayType==="calendar"){const D=t.displayOptions.calendarDateField==="property"?A.find(P=>P.key===t.displayOptions.calendarDatePropertyKey&&P.valueType==="date"):void 0;return t.displayOptions.calendarDateField==="property"&&!D?x?e.jsx("div",{className:"m-4 h-[320px] animate-pulse rounded-[18px] bg-subtle/50"}):E?e.jsx(Qe,{displayName:"calendar",onRetry:p}):e.jsxs("div",{className:"m-4 rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-5",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Calendar date property is unavailable"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Choose an existing date property to restore this calendar."}),e.jsx("div",{className:"mt-3",children:e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:c,children:"Edit calendar"})})]}):e.jsx(_a,{section:t,calendarDateProperty:D,navigationState:m,onNavigationStateChange:v})}return e.jsx(ds,{notes:a,isPending:s,isError:i,onRetry:n})}function ws({section:t,onEdit:a,onDuplicate:s,onDelete:i,onMoveUp:n,onMoveDown:c,dragHandle:b,availableProperties:d=[],isPropertiesLoading:j=!1,isPropertiesError:k=!1,onRetryProperties:A=()=>{},navigationState:x={},onNavigationStateChange:E=()=>{}}){const p=t.displayType==="board",m=t.displayType==="calendar",v=x.page??1,D=(v-1)*t.limit,P=x.sort?.by??t.sortBy,V=x.sort?.order??t.sortOrder,{data:w,isPending:R,isError:f,isPlaceholderData:S,refetch:z}=be({queryKey:_.views.sectionNotes(t.id,{limit:t.limit,offset:D,sortBy:P,sortOrder:V}),enabled:!p&&!m,placeholderData:xa,async queryFn(){const M=await Wt(t.id,{limit:t.limit,offset:D,sortBy:P,sortOrder:V});if(M.type==="error")throw M;return M.viewSectionNotes}}),u=w?.notes??[],C=w?.totalCount??0,y=Math.max(1,Math.ceil(C/t.limit)),T=Ha(t.mode),Y=t.tagNames.length>0||t.propertyFilters.length>0,te=p?d.find(M=>M.key===t.displayOptions.boardGroupByPropertyKey):null,H=m?d.find(M=>M.key===t.displayOptions.calendarDatePropertyKey):null,ae=t.displayOptions.calendarDateField==="property"?H?.name??t.displayOptions.calendarDatePropertyKey??"Date property":t.displayOptions.calendarDateField==="updatedAt"?"Updated date":"Created date",re=M=>{const q=P===M?V==="asc"?"desc":"asc":M==="title"?"asc":"desc";E(ce=>({...ce,page:1,sort:{by:M,order:q}}))};return h.useEffect(()=>{p||m||R||f||S||!w||v<=y||E(M=>({...M,page:y}))},[w,p,m,f,R,S,y,E,v]),e.jsxs(ke,{flush:!0,className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 border-b border-border-subtle/75 px-4 py-3.5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[b&&e.jsx("div",{className:"-mr-1 shrink-0 self-center",children:b}),e.jsx("div",{className:"min-w-0",children:e.jsx(o,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",className:"min-w-0",children:e.jsx("span",{className:"truncate",children:t.title})})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-elevated text-fg-secondary",children:Za(t.displayType)}),p&&t.displayOptions.boardGroupByPropertyKey?e.jsxs(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:["Grouped by ",te?.name??t.displayOptions.boardGroupByPropertyKey]}):null,m?e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:ae}):null,t.tagNames.map((M,q)=>e.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[q>0&&e.jsx("span",{className:"px-0.5 text-[10px] font-semibold tracking-[0.08em] text-fg-tertiary/85",children:T}),e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-secondary",children:M})]},M)),t.propertyFilters.map(M=>e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-subtle text-fg-secondary",children:Xa(M)},`${M.key}-${M.operator}-${M.value??""}`)),!Y&&e.jsx(G,{className:"max-w-full border-border-subtle/80 bg-transparent text-fg-tertiary",children:"All notes"})]})]}),e.jsx(Oe,{button:e.jsx(Fe,{label:"Section actions"}),items:[...n?[{name:"Move up",onClick:n}]:[],...c?[{name:"Move down",onClick:c}]:[],...n||c?[{type:"separator"}]:[],{name:"Edit section",onClick:a},{name:"Duplicate section",onClick:s},{type:"separator"},{name:"Delete section",onClick:i}]})]}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx(js,{section:t,notes:u,isPending:R,isError:f,onRetry:()=>{z()},onEdit:a,onSortChange:re,isSortPending:S,activeSortBy:P,activeSortOrder:V,availableProperties:d,isPropertiesLoading:j,isPropertiesError:k,onRetryProperties:A,navigationState:x,onNavigationStateChange:E})}),m?null:e.jsxs("div",{className:"flex flex-col gap-3 border-t border-border-subtle/75 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:p?`${t.limit} cards per column load`:R||S?"Loading notes...":C===0?"No matching notes":`Showing ${D+1}–${Math.min(D+u.length,C)} of ${C} notes`}),!p&&y>1?e.jsx(ya,{page:Math.min(v,y),last:y,className:"!mt-0 shrink-0 sm:justify-end",onChange:M=>E(q=>({...q,page:M}))}):null]})]})}const ve="__choose_property__",je="__choose_board_group__",Ns=["title","tags","properties","createdAt","updatedAt"],Ye=t=>String(t?.limit??5),He=t=>t?.displayType??"list",Ze=t=>fe(t?.displayOptions?.tableColumns??De),Xe=t=>ze(t?.displayOptions?.tablePropertyKeys),Je=t=>t?.displayOptions?.boardGroupByPropertyKey??"",et=t=>St(t?.displayOptions?.calendarDateField??jt),tt=t=>t?.displayOptions?.calendarDatePropertyKey??"",at=t=>t?.mode??"and",st=t=>t?t.tagNames.join(", "):"",rt=t=>t?.title??"",nt=t=>t?.sortBy??"updatedAt",it=t=>t?.sortOrder??"desc",Ft=t=>`property-filter-${Date.now()}-${t}`,lt=t=>(t?.propertyFilters??[]).map((a,s)=>({id:Ft(s),key:a.key,operator:a.operator,value:a.value??""})),ot=t=>t?t.valueType==="date"||t.valueType==="number"?["equals","notEquals","before","after","exists","notExists"]:t.valueType==="text"||t.valueType==="url"?["equals","notEquals","contains","notContains","exists","notExists"]:["equals","notEquals","exists","notExists"]:["exists","notExists"],dt=t=>t?"equals":"exists",Cs=t=>t?t.valueType==="boolean"?"true":t.valueType==="select"?t.options[0]?.value??"":"":"",we=t=>t!=="exists"&&t!=="notExists",Et=t=>t==="contains"||t==="notContains",ks=(t,a)=>t.valueType==="date"?"date":t.valueType==="number"?"number":t.valueType==="url"&&!Et(a)?"url":"text",Ts=(t,a)=>{if(t.valueType==="url")return Et(a)?"example.com":"https://example.com";if(t.valueType==="text")return"Value"};function Ds({open:t,mode:a,initialSection:s=null,availableTags:i,availableProperties:n,isTagsLoading:c=!1,isPropertiesLoading:b=!1,onClose:d,onSubmit:j}){const[k,A]=h.useState(rt(s)),[x,E]=h.useState(He(s)),[p,m]=h.useState(Ze(s)),[v,D]=h.useState(Xe(s)),[P,V]=h.useState(Je(s)),[w,R]=h.useState(et(s)),[f,S]=h.useState(tt(s)),[z,u]=h.useState(st(s)),[C,y]=h.useState(at(s)),[T,Y]=h.useState(nt(s)),[te,H]=h.useState(it(s)),[ae,re]=h.useState(Ye(s)),[M,q]=h.useState(lt(s)),[ce,ue]=h.useState((s?.tagNames.length??0)>0),[me,$]=h.useState(""),Z=h.useMemo(()=>new Map(n.map(r=>[r.key,r])),[n]);h.useEffect(()=>{t&&(A(rt(s)),E(He(s)),m(Ze(s)),D(Xe(s)),V(Je(s)),R(et(s)),S(tt(s)),u(st(s)),y(at(s)),Y(nt(s)),H(it(s)),re(Ye(s)),q(lt(s)),ue((s?.tagNames.length??0)>0),$(""))},[s,t]);const X=We([z]),le=ce||X.length>0,l=X.length===0&&M.length===0,g=n.filter(r=>r.valueType==="select"&&r.options.length>0),O=n.filter(r=>r.valueType==="date"),L=w==="property"&&!!f&&!O.some(r=>r.key===f),pe=r=>{r!=="title"&&(m(N=>{if(N.includes(r)){const K=N.filter(F=>F!==r);return K.length>0?K:N}return fe([...N,r])}),$(""))},Ot=r=>{D(N=>N.includes(r)?N.filter(K=>K!==r):N.length>=ge?N:[...N,r])},Rt=r=>{const N=X.includes(r)?X.filter(K=>K!==r):[...X,r];u(N.join(", ")),$("")},zt=()=>{ue(!0),$("")},$t=()=>{u(""),y("and"),ue(!1),$("")},It=()=>{if(n.length===0){$("Create a shared property before adding a filter.");return}q(r=>[...r,{id:Ft(r.length),key:"",operator:"exists",value:""}]),$("")},he=(r,N)=>{q(K=>K.map(F=>{if(F.id!==r)return F;const J={...F,...N},ne=Z.get(J.key);return ot(ne).includes(J.operator)||(J.operator=dt(ne)),"key"in N&&(J.value=Cs(ne),J.operator=dt(ne)),J})),$("")},Bt=r=>{q(N=>N.filter(K=>K.id!==r)),$("")};return e.jsxs(Q,{isOpen:t,onClose:d,variant:"form",className:"sm:max-w-[720px]",children:[e.jsx(Q.Header,{title:a==="create"?"Create section":"Edit section",onClose:d}),e.jsx(Q.Body,{children:e.jsxs("form",{id:"view-section-form",className:"flex flex-col gap-5",onSubmit:r=>{r.preventDefault();const N=We([z]);if(le&&N.length===0){$("Choose at least one tag, or remove this tag filter.");return}if(M.find(U=>!U.key||!Z.has(U.key))){$("Choose a property for every filter.");return}const F=Z.get(P);if(x==="board"&&(!F||F.valueType!=="select"||F.options.length===0)){$("Choose a select property with at least one option for the board columns.");return}if(x==="board"&&M.some(U=>U.key===P)){$("Use different properties for the board columns and the section filter.");return}const J=Z.get(f);if(x==="calendar"&&w==="property"&&(!J||J.valueType!=="date")){$("Choose a date property for the calendar.");return}const ne=M.map(U=>{const $e=Z.get(U.key);return{key:$e?.key??U.key,valueType:$e?.valueType??"text",operator:U.operator,value:we(U.operator)?U.value:null}});if(ne.some(U=>we(U.operator)&&!U.value?.trim())){$("Fill every filter value, or switch it to is set / is empty.");return}j({title:k,displayType:x,displayOptions:Pt({tableColumns:p,tablePropertyKeys:v,boardGroupByPropertyKey:P,calendarDateField:w,calendarDatePropertyKey:f}),tagNames:N,mode:C,propertyFilters:ne,sortBy:T,sortOrder:te,limit:Number(ae)})},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-section-title",size:"md",children:"Section name"}),e.jsx(Ce,{id:"view-section-title",value:k,onChange:r=>A(r.target.value),placeholder:"Doing notes",autoFocus:!0})]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(W,{size:"md",children:"Display"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Show the same note set as a list, table, property board, or calendar."})]}),e.jsxs(Le,{type:"single",value:x,onValueChange:r=>{(r==="list"||r==="table"||r==="board"||r==="calendar")&&(E(r),r==="board"&&!g.some(N=>N.key===P)&&V(g[0]?.key??""),$(""))},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(oe,{value:"list","aria-label":"Show as list",children:"List"}),e.jsx(oe,{value:"table","aria-label":"Show as table",children:"Table"}),e.jsx(oe,{value:"board","aria-label":"Show as board",children:"Board"}),e.jsx(oe,{value:"calendar","aria-label":"Show as calendar",children:"Calendar"})]}),x==="table"?e.jsxs("div",{className:"border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx(W,{size:"sm",children:"Table columns"}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:p.includes("properties")&&v.length===0?"Properties automatic":`${p.length-(p.includes("properties")?1:0)+(p.includes("properties")?v.length:0)} shown`})]}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:Ns.map(r=>{const N=Dt(r);return e.jsxs("div",{className:"flex items-center gap-2 px-1 py-2",children:[e.jsx(_e,{size:"sm",checked:p.includes(r),disabled:r==="title","aria-label":`Show ${N} column`,onChange:()=>pe(r)}),e.jsx(o,{as:"span",variant:"label",tone:"secondary",children:N})]},r)})}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Title is always shown because it opens the note."}),p.includes("properties")?e.jsxs("div",{className:"mt-3 border-t border-border-subtle/80 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",children:"Property columns"}),e.jsxs(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-0.5",children:["Select up to ",ge," properties to compare."]})]}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:v.length>0?`${v.length} selected`:"Automatic"})]}),n.length>0?e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-2",children:n.map(r=>{const N=v.includes(r.key),K=v.length>=ge;return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1 py-2",children:[e.jsx(_e,{size:"sm",checked:N,disabled:!N&&K,"aria-label":`Show ${r.name} property column`,onChange:()=>Ot(r.key)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"p",variant:"label",tone:"secondary",truncate:!0,children:r.name}),e.jsx(o,{as:"p",variant:"micro",tone:"tertiary",children:r.valueType})]})]},r.key)})}):e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-3",children:"Shared properties will appear here after you create them."}),v.length===0&&n.length>0?e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-2",children:"Automatic mode shows up to three properties relevant to the current notes."}):null]}):null]}):null,x==="board"?e.jsx("div",{className:"border-t border-border-subtle/80 pt-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-board-group-label",htmlFor:"view-section-board-group",size:"sm",children:"Board columns"}),e.jsxs(ee,{id:"view-section-board-group",value:P||je,"aria-labelledby":"view-section-board-group-label",className:"w-full",onValueChange:r=>{r!==je&&(V(r),$(""))},children:[e.jsx(I,{value:je,disabled:!0,children:"Choose a select property"}),g.map(r=>e.jsxs(I,{value:r.key,children:[r.name," · ",r.options.length," columns"]},r.key))]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Moving a card changes this property. Notes without a value stay in Unassigned."}),g.length===0&&!b?e.jsx(o,{as:"p",variant:"meta",className:"text-fg-error",children:"Create a shared select property with options before using a board."}):null]})}):null,x==="calendar"?e.jsx("div",{className:"border-t border-border-subtle/80 pt-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-calendar-date-label",htmlFor:"view-section-calendar-date",size:"sm",children:"Place notes by"}),e.jsxs(ee,{id:"view-section-calendar-date",value:w==="property"&&f?`property:${f}`:w,"aria-labelledby":"view-section-calendar-date-label",className:"w-full",onValueChange:r=>{if(r==="createdAt"||r==="updatedAt"){R(r),S(""),$("");return}if(r.startsWith("property:")){const N=r.slice(9),K=Z.get(N);K?.valueType==="date"&&(R("property"),S(K.key),$(""))}},children:[e.jsx(I,{value:"createdAt",children:"Created date"}),e.jsx(I,{value:"updatedAt",children:"Updated date"}),L?e.jsxs(I,{value:`property:${f}`,disabled:!0,children:[f," · unavailable"]}):null,O.map(r=>e.jsxs(I,{value:`property:${r.key}`,children:[r.name," · date property"]},r.key))]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"The calendar loads every matching note in the visible month. Date properties use their saved day; reminders are not included."})]})}):null]}),e.jsxs("section",{className:"flex flex-col gap-3 border-b border-border-subtle pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(W,{size:"md",children:"Filters"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Use properties for structured fields, and tags for loose topics or context."})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(B,{type:"button",variant:"subtle",size:"sm",onClick:It,children:"Add property filter"}),!le&&e.jsx(B,{type:"button",variant:"subtle",size:"sm",onClick:zt,children:"Add tag filter"})]})]}),M.length===0&&!le?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-elevated/60 px-4 py-3",children:[e.jsx(o,{as:"p",variant:"label",tone:"default",children:l?"All notes":"No filters"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Add a property filter, a tag filter, or leave this view open to all notes."})]}):null,M.length>0?e.jsx("div",{className:"flex flex-col gap-2.5",children:M.map(r=>{const N=Z.get(r.key),K=ot(N);return e.jsxs("div",{className:"grid gap-2 rounded-[16px] border border-border-subtle bg-elevated p-3 md:grid-cols-[minmax(0,1fr)_minmax(10.5rem,12rem)_minmax(0,1fr)_auto] md:items-center",children:[e.jsxs(ee,{value:r.key||ve,ariaLabel:"Property filter property",className:"w-full min-w-0",onValueChange:F=>{F!==ve&&he(r.id,{key:F})},children:[e.jsx(I,{value:ve,disabled:!0,children:"Choose property"}),n.map(F=>e.jsx(I,{value:F.key,children:F.name},F.key))]}),e.jsx(ee,{value:r.operator,disabled:!N,ariaLabel:"Property filter operator",className:"w-full min-w-0",onValueChange:F=>he(r.id,{operator:F}),children:K.map(F=>e.jsx(I,{value:F,children:Tt(F)},F))}),we(r.operator)&&N?N.valueType==="select"?e.jsx(ee,{value:r.value,ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:F=>he(r.id,{value:F}),children:N.options.map(F=>e.jsx(I,{value:F.value,children:F.label},F.value))}):N.valueType==="boolean"?e.jsxs(ee,{value:r.value||"true",ariaLabel:"Property filter value",className:"w-full min-w-0",onValueChange:F=>he(r.id,{value:F}),children:[e.jsx(I,{value:"true",children:"True"}),e.jsx(I,{value:"false",children:"False"})]}):e.jsx(Ce,{type:ks(N,r.operator),value:r.value,onChange:F=>he(r.id,{value:F.target.value}),placeholder:Ts(N,r.operator),"aria-label":"Property filter value"}):e.jsx(o,{as:"span",variant:"label",tone:"tertiary",children:N?"No value needed":"Choose a property first"}),e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>Bt(r.id),children:"Remove"})]},r.id)})}):null,le?e.jsxs("div",{className:"flex flex-col gap-3 rounded-[16px] border border-border-subtle bg-elevated p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"p",variant:"label",tone:"default",children:"Tag filter"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Match notes by selected tags."})]}),e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:$t,children:"Remove"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-section-tags",size:"sm",children:"Tag names"}),e.jsx(ga,{id:"view-section-tags",value:z,onChange:r=>{u(r.target.value),$("")},placeholder:"@OceanBrain, @todo",size:"sm"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"You can use tags only, properties only, both together, or no filters."})]}),X.length>1?e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{size:"sm",children:"Tag match"}),e.jsxs(Le,{type:"single",value:C,onValueChange:r=>{(r==="and"||r==="or")&&y(r)},variant:"quiet",size:"sm",className:"self-start",children:[e.jsx(oe,{value:"and","aria-label":Ge("and"),children:"AND"}),e.jsx(oe,{value:"or","aria-label":Ge("or"),children:"OR"})]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"AND requires every selected tag. OR accepts any selected tag."})]}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(W,{size:"sm",children:"Existing tags"}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",children:c?"Loading...":`${i.length} available`})]}),i.length>0?e.jsx("div",{className:"max-h-44 overflow-y-auto rounded-[16px] border border-border-subtle bg-hover-subtle/60 p-3",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(r=>{const N=X.includes(r.name);return e.jsx("button",{type:"button",className:`inline-flex items-center rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${N?"border-border-secondary bg-elevated text-fg-default":"border-border-subtle bg-transparent text-fg-secondary hover:border-border-secondary hover:bg-elevated hover:text-fg-default"}`,"aria-pressed":N,onClick:()=>Rt(r.name),children:r.name},r.id)})})}):e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"No tags yet. You can still type tag names manually."})]}):null,e.jsx(o,{as:"p",variant:"meta",tone:me?"default":"tertiary",className:me?"text-fg-error":void 0,children:me||(b||c?"Loading filter options...":`${n.length} properties · ${i.length} tags available`)})]}),x==="calendar"?e.jsxs("div",{className:"rounded-[16px] border border-dashed border-border-subtle bg-subtle/40 px-4 py-3",children:[e.jsx(o,{as:"p",variant:"label",weight:"semibold",children:"Month view"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Calendar sections use month navigation instead of row sorting or pagination."})]}):e.jsxs("details",{className:"group pb-1",children:[e.jsx("summary",{className:"cursor-pointer list-none",children:e.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1",children:[e.jsx(o,{as:"span",variant:"label",tone:"default",children:"Sort and page size"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"col-start-1 row-start-2",children:x==="board"?"Controls how many cards each board column loads at a time.":"Controls how many matching notes appear on each section page."}),e.jsx(o,{as:"span",variant:"meta",tone:"tertiary",className:"col-start-2 row-span-2 row-start-1 whitespace-nowrap",children:x==="board"?`${ae} per column`:`${ae} notes`})]})}),e.jsxs("div",{className:"mt-4 grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-sort-by-label",htmlFor:"view-section-sort-by",size:"sm",children:"Sort by"}),e.jsxs(ee,{id:"view-section-sort-by",value:T,"aria-labelledby":"view-section-sort-by-label",onValueChange:r=>Y(r),children:[e.jsx(I,{value:"updatedAt",children:"Updated time"}),e.jsx(I,{value:"createdAt",children:"Created time"}),e.jsx(I,{value:"title",children:"Title"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-sort-order-label",htmlFor:"view-section-sort-order",size:"sm",children:"Order"}),e.jsxs(ee,{id:"view-section-sort-order",value:te,"aria-labelledby":"view-section-sort-order-label",onValueChange:r=>H(r),children:[e.jsx(I,{value:"desc",children:"Descending"}),e.jsx(I,{value:"asc",children:"Ascending"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{id:"view-section-limit-label",htmlFor:"view-section-limit",size:"sm",children:x==="board"?"Cards per load":"Rows per page"}),e.jsxs(ee,{id:"view-section-limit",value:ae,"aria-labelledby":"view-section-limit-label",onValueChange:re,children:[e.jsxs(I,{value:"3",children:["3 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"5",children:["5 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"8",children:["8 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"10",children:["10 ",x==="board"?"cards":"rows"]}),e.jsxs(I,{value:"12",children:["12 ",x==="board"?"cards":"rows"]})]})]})]})]})]})}),e.jsx(Q.Footer,{children:e.jsxs(yt,{children:[e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:d,children:"Cancel"}),e.jsx(B,{type:"submit",size:"sm",form:"view-section-form",children:a==="create"?"Create section":"Save section"})]})})]})}const Ss="group flex h-10 max-w-[72vw] shrink-0 items-center rounded-[12px] border transition-[background-color,border-color,color,box-shadow] sm:max-w-[176px]",Ps="focus-ring-soft inline-flex h-full min-w-0 flex-1 touch-pan-x items-center gap-1 rounded-[11px] px-3 text-[13px] font-medium outline-none transition-colors";function As({tab:t,isActive:a,onSelect:s}){const{attributes:i,listeners:n,setNodeRef:c,setActivatorNodeRef:b,transform:d,transition:j,isDragging:k}=bt({id:t.id});return e.jsx("div",{ref:c,style:{transform:Me.Translate.toString(d),transition:j,opacity:k?.6:1},className:ie(Ss,a?"border-border-secondary/80 bg-elevated text-fg-default shadow-[0_8px_18px_-18px_rgba(15,18,24,0.28)]":"border-transparent bg-transparent text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default"),children:e.jsxs("button",{type:"button",ref:b,...i,...n,role:"tab","aria-selected":a,title:`${t.title}. Drag to reorder.`,className:ie(Ps,a?"text-fg-default":"text-fg-secondary group-hover:text-fg-default",k?"cursor-grabbing":"cursor-pointer"),onClick:s,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.title}),e.jsx("span",{className:"inline-flex min-w-4 shrink-0 items-center justify-center rounded-full bg-hover-subtle/75 px-1 py-0 text-[10px] leading-4 text-current/70",children:t.sections.length})]})})}function Vs({tabs:t,activeTabId:a,onSelectTab:s,onReorderTabs:i,onCreateTab:n}){const c=Se(de(Gt,{activationConstraint:{distance:8}}),de(Pe,{coordinateGetter:pt}));return e.jsx("div",{className:"-mx-1 rounded-[16px] border border-border-subtle/75 bg-subtle/50 p-1 sm:mx-0",children:e.jsx(Ae,{sensors:c,collisionDetection:Ve,modifiers:[Qt],autoScroll:!1,onDragEnd:b=>{i(b)},children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ht,{items:t.map(b=>b.id),strategy:Yt,children:e.jsx("div",{role:"tablist","aria-label":"Views tab list",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto overflow-y-hidden",children:t.map(b=>e.jsx(As,{tab:b,isActive:b.id===a,onSelect:()=>{s(b)}},b.id))})}),e.jsxs(B,{type:"button","aria-label":"New view tab",variant:"ghost",size:"sm",className:"h-10 w-10 shrink-0 rounded-[12px] border-transparent bg-transparent px-0 text-[13px] text-fg-secondary hover:border-border-subtle/80 hover:bg-hover-subtle hover:text-fg-default sm:w-auto sm:px-2.5",onClick:n,children:[e.jsx(Te,{className:"h-5 w-5 shrink-0"}),e.jsx("span",{className:"hidden sm:inline",children:"New view tab"})]})]})})})}function Ms({open:t,mode:a,initialTitle:s="",onClose:i,onSubmit:n}){const[c,b]=h.useState(s);return h.useEffect(()=>{t&&b(s)},[s,t]),e.jsxs(Q,{isOpen:t,onClose:i,variant:"form",className:"sm:max-w-[480px]",children:[e.jsx(Q.Header,{title:a==="create"?"Create view tab":"Rename view tab",onClose:i}),e.jsx(Q.Body,{children:e.jsxs("form",{id:"view-tab-form",className:"flex flex-col gap-4",onSubmit:d=>{d.preventDefault(),n(c)},children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(W,{htmlFor:"view-tab-title",size:"md",children:"Tab name"}),e.jsx(Ce,{id:"view-tab-title",value:c,onChange:d=>b(d.target.value),placeholder:"Now",autoFocus:!0})]}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",children:"Each tab is one saved view inside the Views page."})]})}),e.jsx(Q.Footer,{children:e.jsxs(yt,{children:[e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:i,children:"Cancel"}),e.jsx(B,{type:"submit",size:"sm",form:"view-tab-form",children:a==="create"?"Create tab":"Save tab"})]})})]})}const ct=ja(Na),Fs="Save reusable note queries with tags, shared properties, and sorting.",Es="focus-ring-soft hidden h-8 w-8 items-center justify-center rounded-[10px] text-fg-default/70 outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default sm:inline-flex touch-none",Os=({section:t,availableProperties:a,isPropertiesLoading:s,isPropertiesError:i,onRetryProperties:n,onEdit:c,onDuplicate:b,onDelete:d,onMoveUp:j,onMoveDown:k,navigationState:A,onNavigationStateChange:x})=>{const{attributes:E,listeners:p,setNodeRef:m,setActivatorNodeRef:v,transform:D,transition:P,isDragging:V}=bt({id:t.id}),w=h.useCallback(R=>x(t.id,R),[x,t.id]);return e.jsx("div",{ref:m,style:{transform:Me.Translate.toString(D),transition:P,opacity:V?.6:1},children:e.jsx(ws,{section:t,availableProperties:a,isPropertiesLoading:s,isPropertiesError:i,onRetryProperties:n,onEdit:c,onDuplicate:b,onDelete:d,onMoveUp:j,onMoveDown:k,navigationState:A,onNavigationStateChange:w,dragHandle:e.jsx("button",{type:"button",ref:v,"aria-label":`Reorder section ${t.title}`,...E,...p,className:ie(Es,V?"cursor-grabbing":"cursor-grab"),children:e.jsx(mt,{className:"size-4"})})})})};function Zs(){const t=da(),a=ft(),s=gt(),i=ct.useSearch(),n=ct.useNavigate(),[c,b]=h.useState(null),[d,j]=h.useState(null),{data:k,isPending:A,isError:x,refetch:E}=be({queryKey:_.views.workspace(),async queryFn(){const l=await Ht();if(l.type==="error")throw l;return l.viewWorkspace}}),p=k??qa,m=p.tabs.find(l=>l.id===i.tab)??Wa(p),v=m?p.tabs.findIndex(l=>l.id===m.id):-1,{data:D,isPending:P}=be({queryKey:_.tags.list({limit:200}),async queryFn(){const l=await wa({limit:200});if(l.type==="error")throw l;return l.allTags}}),V=Se(de(ut,{activationConstraint:{distance:8}}),de(Pe,{coordinateGetter:pt})),w=D?.tags??[],{data:R,isPending:f,isError:S,refetch:z}=be({queryKey:_.notes.propertyKeysCatalog(),async queryFn(){const l=await fa();if(l.type==="error")throw l;return l.notePropertyKeys}}),u=R?.keys??[],C=l=>{s.setQueryData(_.views.workspace(),l)},y=h.useCallback((l,g)=>{n({search:O=>({...O,state:Zt(O.state,l,g)}),replace:!0,resetScroll:!1})},[n]),T=async()=>{await s.invalidateQueries({queryKey:_.views.all(),exact:!1})},Y=async(l,g)=>{C(g);const O=await ia(g.tabs.map(L=>L.id));if(O.type==="error"){C(l),a(O.errors[0].message);return}await T()},te=async({active:l,over:g})=>{if(!g||l.id===g.id)return;const O=s.getQueryData(_.views.workspace())??p,L=Ct(O,String(l.id),String(g.id));await Y(O,L)},H=async l=>{if(!m)return;const g=s.getQueryData(_.views.workspace())??p,O=Qa(g,m.id,l);O!==g&&await Y(g,O)},ae=async l=>{const g=s.getQueryData(_.views.workspace())??p,O=i,L=Ga(g,l.id);C(L),await n({search:{tab:l.id,state:void 0},resetScroll:!1});const pe=await Ie(l.id);if(pe.type==="error"){C(g),await n({search:O,replace:!0,resetScroll:!1}),a(pe.errors[0].message);return}C(pe.setActiveViewTab)},re=async(l,g)=>{if(!m)return;C(g);const O=await la(m.id,g.tabs.find(L=>L.id===m.id)?.sections.map(L=>L.id)??[]);if(O.type==="error"){C(l),a(O.errors[0].message);return}await T()},M=async({active:l,over:g})=>{if(!m||!g||l.id===g.id)return;const O=s.getQueryData(_.views.workspace())??p,L=kt(O,m.id,String(l.id),String(g.id));await re(O,L)},q=async(l,g)=>{if(!m)return;const O=s.getQueryData(_.views.workspace())??p,L=Ya(O,m.id,l,g);L!==O&&await re(O,L)},ce=async l=>{const g=await ta(l);if(g.type==="error"){a(g.errors[0].message);return}const O=await Ie(g.createViewTab.id);O.type==="success"?C(O.setActiveViewTab):a(O.errors[0].message),await T(),await n({search:{tab:g.createViewTab.id,state:void 0},resetScroll:!1}),b(null)},ue=async l=>{if(!m)return;const g=await aa(m.id,l);if(g.type==="error"){a(g.errors[0].message);return}await T(),b(null)},me=async()=>{if(!m||!await t("Delete this view tab and all of its sections?"))return;const l=await sa(m.id);if(l.type==="error"){a(l.errors[0].message);return}await T(),await n({search:{tab:void 0,state:void 0},replace:!0,resetScroll:!1})},$=async l=>{if(!m)return;const g=await Be(m.id,l);if(g.type==="error"){a(g.errors[0].message);return}await T(),j(null)},Z=async l=>{if(!m||!d||d.mode!=="edit")return;const g=await ra(d.section.id,l);if(g.type==="error"){a(g.errors[0].message);return}y(d.section.id,{}),await T(),j(null)},X=async l=>{const g=await Be(l.tabId,{...Ja(l),title:`${l.title} copy`});if(g.type==="error"){a(g.errors[0].message);return}await T(),a("Section duplicated.")},le=async l=>{if(!m||!await t("Delete this section from the current view tab?"))return;const g=await na(l);if(g.type==="error"){a(g.errors[0].message);return}y(l,{}),await T()};return e.jsxs(e.Fragment,{children:[e.jsx(va,{title:"Views",description:Fs,children:A&&!k?e.jsx(ke,{className:"px-6 py-8 sm:px-8 sm:py-10",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(xe,{height:20,width:180,className:"rounded-full"}),e.jsx(xe,{height:16,width:260,className:"rounded-full"}),e.jsx(xe,{height:44,width:140,className:"rounded-[12px]"})]})}):x?e.jsxs(ke,{className:"px-6 py-8 sm:px-8 sm:py-10",children:[e.jsx(o,{as:"p",variant:"body",weight:"semibold",children:"Failed to load saved views"}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:"Retry loading your saved view tabs."}),e.jsx("div",{className:"mt-4",children:e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>{E()},children:"Retry"})})]}):p.tabs.length===0?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(qe,{title:"Create your first view tab",description:"Start with a saved view tab, then add sections that query notes by tags, properties, or both.",className:"h-[320px]"}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(B,{type:"button",onClick:()=>b({mode:"create"}),children:[e.jsx(Te,{className:"h-4 w-4"}),"Create first tab"]})})]}):e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx(Vs,{tabs:p.tabs,activeTabId:m?.id??null,onSelectTab:ae,onReorderTabs:te,onCreateTab:()=>b({mode:"create"})}),m&&e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b border-border-subtle/80 px-1 pb-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(o,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",truncate:!0,children:m.title}),e.jsx(o,{as:"p",variant:"meta",tone:"tertiary",className:"mt-1",children:m.sections.length>0?`${m.sections.length} section${m.sections.length===1?"":"s"} in this view`:"Add sections to build this view"})]}),e.jsxs("div",{className:"inline-flex flex-wrap items-center gap-2 self-start sm:self-center",children:[e.jsxs(B,{type:"button",size:"sm",onClick:()=>j({mode:"create"}),children:[e.jsx(Te,{className:"h-4 w-4"}),"Add section"]}),e.jsx(Oe,{button:e.jsx(Fe,{label:"View tab actions"}),items:[...v>0?[{name:"Move tab left",onClick:()=>{H("previous")}}]:[],...v>=0&&v<p.tabs.length-1?[{name:"Move tab right",onClick:()=>{H("next")}}]:[],...p.tabs.length>1?[{type:"separator"}]:[],{name:"Rename tab",onClick:()=>b({mode:"edit",tab:m})},{type:"separator"},{name:"Delete tab",onClick:()=>{me()}}]})]})]}),m.sections.length===0?e.jsx(qe,{title:"Add the first section to this tab",description:"Sections can pull notes by tags, properties, or both.",className:"h-[300px]"}):e.jsx("div",{className:"flex flex-col",children:e.jsx(Ae,{sensors:V,collisionDetection:Ve,modifiers:[Xt],onDragEnd:M,children:e.jsx(ht,{items:m.sections.map(l=>l.id),strategy:Jt,children:e.jsx("div",{className:"flex flex-col gap-4",children:m.sections.map((l,g)=>e.jsx(Os,{section:l,availableProperties:u,isPropertiesLoading:f,isPropertiesError:S,onRetryProperties:()=>{z()},navigationState:ea(i.state,l.id),onNavigationStateChange:y,onEdit:()=>j({mode:"edit",section:l}),onDuplicate:()=>{X(l)},onDelete:()=>{le(l.id)},onMoveUp:g>0?()=>{q(l.id,"previous")}:void 0,onMoveDown:g<m.sections.length-1?()=>{q(l.id,"next")}:void 0},l.id))})})})})]})]})}),e.jsx(Ms,{open:c!==null,mode:c?.mode??"create",initialTitle:c?.mode==="edit"?c.tab.title:"",onClose:()=>b(null),onSubmit:l=>{if(c?.mode==="edit"){ue(l);return}ce(l)}}),e.jsx(Ds,{open:d!==null,mode:d?.mode??"create",initialSection:d?.mode==="edit"?d.section:null,availableTags:w,availableProperties:u,isTagsLoading:P,isPropertiesLoading:f,onClose:()=>j(null),onSubmit:l=>{if(d?.mode==="edit"){Z(l);return}$(l)}})]})}export{Zs as default};
|