@caring-dev/react-notion-x 7.7.2

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.
@@ -0,0 +1,2364 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
28
+
29
+ // ../../node_modules/.pnpm/clipboard-copy@4.0.1/node_modules/clipboard-copy/index.js
30
+ var require_clipboard_copy = __commonJS({
31
+ "../../node_modules/.pnpm/clipboard-copy@4.0.1/node_modules/clipboard-copy/index.js"(exports, module) {
32
+ "use strict";
33
+ module.exports = clipboardCopy;
34
+ function makeError() {
35
+ return new DOMException("The request is not allowed", "NotAllowedError");
36
+ }
37
+ async function copyClipboardApi(text) {
38
+ if (!navigator.clipboard) {
39
+ throw makeError();
40
+ }
41
+ return navigator.clipboard.writeText(text);
42
+ }
43
+ async function copyExecCommand(text) {
44
+ const span = document.createElement("span");
45
+ span.textContent = text;
46
+ span.style.whiteSpace = "pre";
47
+ span.style.webkitUserSelect = "auto";
48
+ span.style.userSelect = "all";
49
+ document.body.appendChild(span);
50
+ const selection = window.getSelection();
51
+ const range = window.document.createRange();
52
+ selection.removeAllRanges();
53
+ range.selectNode(span);
54
+ selection.addRange(range);
55
+ let success = false;
56
+ try {
57
+ success = window.document.execCommand("copy");
58
+ } finally {
59
+ selection.removeAllRanges();
60
+ window.document.body.removeChild(span);
61
+ }
62
+ if (!success) throw makeError();
63
+ }
64
+ async function clipboardCopy(text) {
65
+ try {
66
+ await copyClipboardApi(text);
67
+ } catch (err) {
68
+ try {
69
+ await copyExecCommand(text);
70
+ } catch (err2) {
71
+ throw err2 || err || makeError();
72
+ }
73
+ }
74
+ }
75
+ }
76
+ });
77
+
78
+ // ../../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js
79
+ var require_lodash = __commonJS({
80
+ "../../node_modules/.pnpm/lodash.throttle@4.1.1/node_modules/lodash.throttle/index.js"(exports, module) {
81
+ "use strict";
82
+ var FUNC_ERROR_TEXT = "Expected a function";
83
+ var NAN = 0 / 0;
84
+ var symbolTag = "[object Symbol]";
85
+ var reTrim = /^\s+|\s+$/g;
86
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
87
+ var reIsBinary = /^0b[01]+$/i;
88
+ var reIsOctal = /^0o[0-7]+$/i;
89
+ var freeParseInt = parseInt;
90
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
91
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
92
+ var root = freeGlobal || freeSelf || Function("return this")();
93
+ var objectProto = Object.prototype;
94
+ var objectToString = objectProto.toString;
95
+ var nativeMax = Math.max;
96
+ var nativeMin = Math.min;
97
+ var now = function() {
98
+ return root.Date.now();
99
+ };
100
+ function debounce(func, wait, options) {
101
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
102
+ if (typeof func != "function") {
103
+ throw new TypeError(FUNC_ERROR_TEXT);
104
+ }
105
+ wait = toNumber(wait) || 0;
106
+ if (isObject(options)) {
107
+ leading = !!options.leading;
108
+ maxing = "maxWait" in options;
109
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
110
+ trailing = "trailing" in options ? !!options.trailing : trailing;
111
+ }
112
+ function invokeFunc(time) {
113
+ var args = lastArgs, thisArg = lastThis;
114
+ lastArgs = lastThis = void 0;
115
+ lastInvokeTime = time;
116
+ result = func.apply(thisArg, args);
117
+ return result;
118
+ }
119
+ function leadingEdge(time) {
120
+ lastInvokeTime = time;
121
+ timerId = setTimeout(timerExpired, wait);
122
+ return leading ? invokeFunc(time) : result;
123
+ }
124
+ function remainingWait(time) {
125
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, result2 = wait - timeSinceLastCall;
126
+ return maxing ? nativeMin(result2, maxWait - timeSinceLastInvoke) : result2;
127
+ }
128
+ function shouldInvoke(time) {
129
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
130
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
131
+ }
132
+ function timerExpired() {
133
+ var time = now();
134
+ if (shouldInvoke(time)) {
135
+ return trailingEdge(time);
136
+ }
137
+ timerId = setTimeout(timerExpired, remainingWait(time));
138
+ }
139
+ function trailingEdge(time) {
140
+ timerId = void 0;
141
+ if (trailing && lastArgs) {
142
+ return invokeFunc(time);
143
+ }
144
+ lastArgs = lastThis = void 0;
145
+ return result;
146
+ }
147
+ function cancel() {
148
+ if (timerId !== void 0) {
149
+ clearTimeout(timerId);
150
+ }
151
+ lastInvokeTime = 0;
152
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
153
+ }
154
+ function flush() {
155
+ return timerId === void 0 ? result : trailingEdge(now());
156
+ }
157
+ function debounced() {
158
+ var time = now(), isInvoking = shouldInvoke(time);
159
+ lastArgs = arguments;
160
+ lastThis = this;
161
+ lastCallTime = time;
162
+ if (isInvoking) {
163
+ if (timerId === void 0) {
164
+ return leadingEdge(lastCallTime);
165
+ }
166
+ if (maxing) {
167
+ timerId = setTimeout(timerExpired, wait);
168
+ return invokeFunc(lastCallTime);
169
+ }
170
+ }
171
+ if (timerId === void 0) {
172
+ timerId = setTimeout(timerExpired, wait);
173
+ }
174
+ return result;
175
+ }
176
+ debounced.cancel = cancel;
177
+ debounced.flush = flush;
178
+ return debounced;
179
+ }
180
+ function throttle2(func, wait, options) {
181
+ var leading = true, trailing = true;
182
+ if (typeof func != "function") {
183
+ throw new TypeError(FUNC_ERROR_TEXT);
184
+ }
185
+ if (isObject(options)) {
186
+ leading = "leading" in options ? !!options.leading : leading;
187
+ trailing = "trailing" in options ? !!options.trailing : trailing;
188
+ }
189
+ return debounce(func, wait, {
190
+ "leading": leading,
191
+ "maxWait": wait,
192
+ "trailing": trailing
193
+ });
194
+ }
195
+ function isObject(value) {
196
+ var type = typeof value;
197
+ return !!value && (type == "object" || type == "function");
198
+ }
199
+ function isObjectLike(value) {
200
+ return !!value && typeof value == "object";
201
+ }
202
+ function isSymbol(value) {
203
+ return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
204
+ }
205
+ function toNumber(value) {
206
+ if (typeof value == "number") {
207
+ return value;
208
+ }
209
+ if (isSymbol(value)) {
210
+ return NAN;
211
+ }
212
+ if (isObject(value)) {
213
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
214
+ value = isObject(other) ? other + "" : other;
215
+ }
216
+ if (typeof value != "string") {
217
+ return value === 0 ? value : +value;
218
+ }
219
+ value = value.replace(reTrim, "");
220
+ var isBinary = reIsBinary.test(value);
221
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
222
+ }
223
+ module.exports = throttle2;
224
+ }
225
+ });
226
+
227
+ // src/third-party/code.tsx
228
+ var import_clipboard_copy = __toESM(require_clipboard_copy(), 1);
229
+ import "prismjs";
230
+ import "prismjs/components/prism-clike.min.js";
231
+ import "prismjs/components/prism-css-extras.min.js";
232
+ import "prismjs/components/prism-css.min.js";
233
+ import "prismjs/components/prism-javascript.min.js";
234
+ import "prismjs/components/prism-js-extras.min.js";
235
+ import "prismjs/components/prism-json.min.js";
236
+ import "prismjs/components/prism-jsx.min.js";
237
+ import "prismjs/components/prism-tsx.min.js";
238
+ import "prismjs/components/prism-typescript.min.js";
239
+ import "notion-types";
240
+ import { getBlockTitle as getBlockTitle4 } from "notion-utils";
241
+ import prism from "prismjs";
242
+ import React16 from "react";
243
+
244
+ // src/components/text.tsx
245
+ import "notion-types";
246
+ import { parsePageId as parsePageId2 } from "notion-utils";
247
+ import React15 from "react";
248
+
249
+ // src/context.tsx
250
+ import "notion-types";
251
+ import { defaultMapImageUrl, defaultMapPageUrl } from "notion-utils";
252
+ import React13 from "react";
253
+
254
+ // src/components/asset-wrapper.tsx
255
+ import "notion-types";
256
+ import { parsePageId } from "notion-utils";
257
+
258
+ // src/components/header.tsx
259
+ import { getPageBreadcrumbs } from "notion-utils";
260
+ import React9 from "react";
261
+ import { useHotkeys } from "react-hotkeys-hook";
262
+
263
+ // src/icons/search-icon.tsx
264
+ import "react";
265
+
266
+ // src/utils.ts
267
+ import "notion-types";
268
+ import { formatDate, formatNotionDateTime, isUrl } from "notion-utils";
269
+ var cs = (...classes) => classes.filter((a) => !!a).join(" ");
270
+ var getHashFragmentValue = (url) => {
271
+ return url.includes("#") ? url.replace(/^.+(#.+)$/, "$1") : "";
272
+ };
273
+ var isBrowser = !!globalThis.window;
274
+ var youtubeDomains = /* @__PURE__ */ new Set([
275
+ "youtu.be",
276
+ "youtube.com",
277
+ "www.youtube.com",
278
+ "youtube-nocookie.com",
279
+ "www.youtube-nocookie.com"
280
+ ]);
281
+ var getYoutubeId = (url) => {
282
+ var _a;
283
+ try {
284
+ const { hostname } = new URL(url);
285
+ if (!youtubeDomains.has(hostname)) {
286
+ return null;
287
+ }
288
+ const regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/i;
289
+ const match = url.match(regExp);
290
+ if (match && ((_a = match[2]) == null ? void 0 : _a.length) === 11) {
291
+ return match[2];
292
+ }
293
+ } catch (e) {
294
+ }
295
+ return null;
296
+ };
297
+ var getUrlParams = (url) => {
298
+ try {
299
+ const { searchParams } = new URL(url);
300
+ const result = {};
301
+ for (const [key, value] of searchParams.entries()) {
302
+ result[key] = value;
303
+ }
304
+ return result;
305
+ } catch (e) {
306
+ }
307
+ return;
308
+ };
309
+
310
+ // src/icons/search-icon.tsx
311
+ import { jsx } from "react/jsx-runtime";
312
+ function SearchIcon(props) {
313
+ const { className, ...rest } = props;
314
+ return /* @__PURE__ */ jsx("svg", { className: cs("notion-icon", className), viewBox: "0 0 17 17", ...rest, children: /* @__PURE__ */ jsx("path", { d: "M6.78027 13.6729C8.24805 13.6729 9.60156 13.1982 10.709 12.4072L14.875 16.5732C15.0684 16.7666 15.3232 16.8633 15.5957 16.8633C16.167 16.8633 16.5713 16.4238 16.5713 15.8613C16.5713 15.5977 16.4834 15.3516 16.29 15.1582L12.1504 11.0098C13.0205 9.86719 13.5391 8.45215 13.5391 6.91406C13.5391 3.19629 10.498 0.155273 6.78027 0.155273C3.0625 0.155273 0.0214844 3.19629 0.0214844 6.91406C0.0214844 10.6318 3.0625 13.6729 6.78027 13.6729ZM6.78027 12.2139C3.87988 12.2139 1.48047 9.81445 1.48047 6.91406C1.48047 4.01367 3.87988 1.61426 6.78027 1.61426C9.68066 1.61426 12.0801 4.01367 12.0801 6.91406C12.0801 9.81445 9.68066 12.2139 6.78027 12.2139Z" }) });
315
+ }
316
+
317
+ // src/components/page-icon.tsx
318
+ import "notion-types";
319
+ import { getBlockIcon, getBlockTitle } from "notion-utils";
320
+ import React4 from "react";
321
+
322
+ // src/icons/default-page-icon.tsx
323
+ import "react";
324
+ import { jsx as jsx2 } from "react/jsx-runtime";
325
+ function DefaultPageIcon(props) {
326
+ const { className, ...rest } = props;
327
+ return /* @__PURE__ */ jsx2("svg", { className, ...rest, viewBox: "0 0 30 30", width: "16", children: /* @__PURE__ */ jsx2("path", { d: "M16,1H4v28h22V11L16,1z M16,3.828L23.172,11H16V3.828z M24,27H6V3h8v10h10V27z M8,17h14v-2H8V17z M8,21h14v-2H8V21z M8,25h14v-2H8V25z" }) });
328
+ }
329
+
330
+ // src/components/lazy-image.tsx
331
+ import { normalizeUrl } from "notion-utils";
332
+ import React3 from "react";
333
+
334
+ // src/components/lazy-image-full.tsx
335
+ import { Component } from "react";
336
+ import { InView } from "react-intersection-observer";
337
+ import { ofType, unionize } from "unionize";
338
+ import { jsx as jsx3 } from "react/jsx-runtime";
339
+ var LazyImageFullState = unionize({
340
+ NotAsked: {},
341
+ Buffering: {},
342
+ // Could try to make it Promise<HTMLImageElement>,
343
+ // but we don't use the element anyway, and we cache promises
344
+ Loading: {},
345
+ LoadSuccess: {},
346
+ LoadError: ofType()
347
+ });
348
+ var Action = unionize({
349
+ ViewChanged: ofType(),
350
+ BufferingEnded: {},
351
+ // MAYBE: Load: {},
352
+ LoadSuccess: {},
353
+ LoadError: ofType()
354
+ });
355
+ var getBufferingCmd = (durationMs) => (instance) => {
356
+ const bufferingPromise = makeCancelable(delayedPromise(durationMs));
357
+ bufferingPromise.promise.then(() => instance.update(Action.BufferingEnded())).catch(
358
+ (_err) => {
359
+ }
360
+ //console.log({ isCanceled: _reason.isCanceled })
361
+ );
362
+ instance.promiseCache.buffering = bufferingPromise;
363
+ };
364
+ var getLoadingCmd = (imageProps, experimentalDecode) => (instance) => {
365
+ const loadingPromise = makeCancelable(
366
+ loadImage(imageProps, experimentalDecode)
367
+ );
368
+ loadingPromise.promise.then((_res) => instance.update(Action.LoadSuccess({}))).catch((err) => {
369
+ if (!err.isCanceled) {
370
+ instance.update(new Action.LoadError({ msg: "LoadError" }));
371
+ }
372
+ });
373
+ instance.promiseCache.loading = loadingPromise;
374
+ };
375
+ var cancelBufferingCmd = (instance) => {
376
+ var _a;
377
+ (_a = instance.promiseCache.buffering) == null ? void 0 : _a.cancel();
378
+ };
379
+ var _LazyImageFull = class _LazyImageFull extends Component {
380
+ constructor(props) {
381
+ super(props);
382
+ /** A central place to store promises.
383
+ * A bit silly, but passing promises directly in the state
384
+ * was giving me weird timing issues. This way we can keep
385
+ * the promises in check, and pick them up from the respective methods.
386
+ * FUTURE: Could pass the relevant key in Buffering and Loading, so
387
+ * that at least we know where they are from a single source.
388
+ */
389
+ __publicField(this, "promiseCache", {});
390
+ __publicField(this, "initialState", LazyImageFullState.NotAsked());
391
+ this.state = this.initialState;
392
+ this.update = this.update.bind(this);
393
+ }
394
+ /** Emit the next state based on actions.
395
+ * This is the core of the component!
396
+ */
397
+ static reducer(action, prevState, props) {
398
+ return Action.match(action, {
399
+ ViewChanged: ({ inView }) => {
400
+ if (inView === true) {
401
+ if (!props.src) {
402
+ return { nextState: LazyImageFullState.LoadSuccess() };
403
+ } else {
404
+ return LazyImageFullState.match(prevState, {
405
+ NotAsked: () => {
406
+ if (props.debounceDurationMs) {
407
+ return {
408
+ nextState: LazyImageFullState.Buffering(),
409
+ cmd: getBufferingCmd(props.debounceDurationMs)
410
+ };
411
+ } else {
412
+ return {
413
+ nextState: LazyImageFullState.Loading(),
414
+ cmd: getLoadingCmd(props, props.experimentalDecode)
415
+ };
416
+ }
417
+ },
418
+ // Do nothing in other states
419
+ default: () => ({ nextState: prevState })
420
+ });
421
+ }
422
+ } else {
423
+ return LazyImageFullState.match(prevState, {
424
+ Buffering: () => ({
425
+ nextState: LazyImageFullState.NotAsked(),
426
+ cmd: cancelBufferingCmd
427
+ }),
428
+ // Do nothing in other states
429
+ default: () => ({ nextState: prevState })
430
+ });
431
+ }
432
+ },
433
+ // Buffering has ended/succeeded, kick off request for image
434
+ BufferingEnded: () => ({
435
+ nextState: LazyImageFullState.Loading(),
436
+ cmd: getLoadingCmd(props, props.experimentalDecode)
437
+ }),
438
+ // Loading the image succeeded, simple
439
+ LoadSuccess: () => ({ nextState: LazyImageFullState.LoadSuccess() }),
440
+ //@ts-expect-error No need for changing structure
441
+ LoadError: (e) => ({ nextState: new LazyImageFullState.LoadError(e) })
442
+ });
443
+ }
444
+ update(action) {
445
+ const { nextState, cmd } = _LazyImageFull.reducer(
446
+ action,
447
+ this.state,
448
+ this.props
449
+ );
450
+ if (this.props.debugActions) {
451
+ if (false) {
452
+ console.warn(
453
+ 'You are running LazyImage with debugActions="true" in production. This might have performance implications.'
454
+ );
455
+ }
456
+ console.log({ action, prevState: this.state, nextState });
457
+ }
458
+ this.setState(nextState, () => cmd && cmd(this));
459
+ }
460
+ componentWillUnmount() {
461
+ if (this.promiseCache.loading) {
462
+ this.promiseCache.loading.cancel();
463
+ }
464
+ if (this.promiseCache.buffering) {
465
+ this.promiseCache.buffering.cancel();
466
+ }
467
+ this.promiseCache = {};
468
+ }
469
+ // Render function
470
+ render() {
471
+ const { children, loadEagerly, observerProps, ...imageProps } = this.props;
472
+ if (loadEagerly) {
473
+ return children({
474
+ // We know that the state tags and the enum match up
475
+ imageState: LazyImageFullState.LoadSuccess().tag,
476
+ imageProps
477
+ });
478
+ } else {
479
+ return /* @__PURE__ */ jsx3(
480
+ InView,
481
+ {
482
+ rootMargin: "50px 0px",
483
+ threshold: 0.01,
484
+ ...observerProps,
485
+ onChange: (inView) => this.update(Action.ViewChanged({ inView })),
486
+ children: ({ ref }) => children({
487
+ // We know that the state tags and the enum match up, apart
488
+ // from Buffering not being exposed
489
+ imageState: this.state.tag === "Buffering" ? "Loading" /* Loading */ : this.state.tag,
490
+ imageProps,
491
+ ref
492
+ })
493
+ }
494
+ );
495
+ }
496
+ }
497
+ };
498
+ __publicField(_LazyImageFull, "displayName", "LazyImageFull");
499
+ var LazyImageFull = _LazyImageFull;
500
+ var loadImage = ({ src, srcSet, alt, sizes }, experimentalDecode = false) => new Promise((resolve, reject) => {
501
+ const image = new Image();
502
+ if (srcSet) {
503
+ image.srcset = srcSet;
504
+ }
505
+ if (alt) {
506
+ image.alt = alt;
507
+ }
508
+ if (sizes) {
509
+ image.sizes = sizes;
510
+ }
511
+ image.src = src;
512
+ if (experimentalDecode && "decode" in image) {
513
+ return image.decode().then(() => resolve(image)).catch((err) => reject(err));
514
+ }
515
+ image.addEventListener("load", resolve);
516
+ image.addEventListener("error", reject);
517
+ });
518
+ var delayedPromise = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
519
+ var makeCancelable = (promise) => {
520
+ let hasCanceled_ = false;
521
+ const wrappedPromise = new Promise((resolve, reject) => {
522
+ void promise.then(
523
+ (val) => hasCanceled_ ? reject({ isCanceled: true }) : resolve(val)
524
+ );
525
+ promise.catch(
526
+ (err) => hasCanceled_ ? reject({ isCanceled: true }) : reject(err)
527
+ );
528
+ });
529
+ return {
530
+ promise: wrappedPromise,
531
+ cancel() {
532
+ hasCanceled_ = true;
533
+ }
534
+ };
535
+ };
536
+
537
+ // src/components/lazy-image.tsx
538
+ import { jsx as jsx4, jsxs } from "react/jsx-runtime";
539
+ function LazyImage({
540
+ src,
541
+ alt,
542
+ className,
543
+ style,
544
+ zoomable = false,
545
+ priority = false,
546
+ height,
547
+ ...rest
548
+ }) {
549
+ var _a, _b, _c;
550
+ const { recordMap, zoom, previewImages, forceCustomImages, components } = useNotionContext();
551
+ const zoomRef = React3.useRef(zoom ? zoom.clone() : null);
552
+ const previewImage = previewImages ? (_c = (_a = recordMap == null ? void 0 : recordMap.preview_images) == null ? void 0 : _a[src]) != null ? _c : (_b = recordMap == null ? void 0 : recordMap.preview_images) == null ? void 0 : _b[normalizeUrl(src)] : null;
553
+ const onLoad = React3.useCallback(
554
+ (e) => {
555
+ if (zoomable && (e.target.src || e.target.srcset)) {
556
+ if (zoomRef.current) {
557
+ ;
558
+ zoomRef.current.attach(e.target);
559
+ }
560
+ }
561
+ },
562
+ [zoomRef, zoomable]
563
+ );
564
+ const attachZoom = React3.useCallback(
565
+ (image) => {
566
+ if (zoomRef.current && image) {
567
+ ;
568
+ zoomRef.current.attach(image);
569
+ }
570
+ },
571
+ [zoomRef]
572
+ );
573
+ const attachZoomRef = React3.useMemo(
574
+ () => zoomable ? attachZoom : void 0,
575
+ [zoomable, attachZoom]
576
+ );
577
+ if (previewImage) {
578
+ const aspectRatio = previewImage.originalHeight / previewImage.originalWidth;
579
+ if (components.Image) {
580
+ return /* @__PURE__ */ jsx4(
581
+ components.Image,
582
+ {
583
+ src,
584
+ alt,
585
+ style,
586
+ className,
587
+ width: previewImage.originalWidth,
588
+ height: previewImage.originalHeight,
589
+ blurDataURL: previewImage.dataURIBase64,
590
+ placeholder: "blur",
591
+ priority,
592
+ onLoad
593
+ }
594
+ );
595
+ }
596
+ return /* @__PURE__ */ jsx4(LazyImageFull, { src, ...rest, experimentalDecode: true, children: ({ imageState, ref }) => {
597
+ const isLoaded = imageState === "LoadSuccess" /* LoadSuccess */;
598
+ const wrapperStyle = {
599
+ width: "100%"
600
+ };
601
+ const imgStyle = {};
602
+ if (height) {
603
+ wrapperStyle.height = height;
604
+ } else {
605
+ imgStyle.position = "absolute";
606
+ wrapperStyle.paddingBottom = `${aspectRatio * 100}%`;
607
+ }
608
+ return /* @__PURE__ */ jsxs(
609
+ "div",
610
+ {
611
+ className: cs(
612
+ "lazy-image-wrapper",
613
+ isLoaded && "lazy-image-loaded",
614
+ className
615
+ ),
616
+ style: wrapperStyle,
617
+ children: [
618
+ /* @__PURE__ */ jsx4(
619
+ "img",
620
+ {
621
+ className: "lazy-image-preview",
622
+ src: previewImage.dataURIBase64,
623
+ alt,
624
+ ref,
625
+ style,
626
+ decoding: "async"
627
+ }
628
+ ),
629
+ /* @__PURE__ */ jsx4(
630
+ "img",
631
+ {
632
+ className: "lazy-image-real",
633
+ src,
634
+ alt,
635
+ ref: attachZoomRef,
636
+ style: {
637
+ ...style,
638
+ ...imgStyle
639
+ },
640
+ width: previewImage.originalWidth,
641
+ height: previewImage.originalHeight,
642
+ decoding: "async",
643
+ loading: "lazy"
644
+ }
645
+ )
646
+ ]
647
+ }
648
+ );
649
+ } });
650
+ } else {
651
+ if (components.Image && forceCustomImages) {
652
+ return /* @__PURE__ */ jsx4(
653
+ components.Image,
654
+ {
655
+ src,
656
+ alt,
657
+ className,
658
+ style,
659
+ width: null,
660
+ height: height || null,
661
+ priority,
662
+ onLoad
663
+ }
664
+ );
665
+ }
666
+ return /* @__PURE__ */ jsx4(
667
+ "img",
668
+ {
669
+ className,
670
+ style,
671
+ src,
672
+ alt,
673
+ ref: attachZoomRef,
674
+ loading: "lazy",
675
+ decoding: "async",
676
+ ...rest
677
+ }
678
+ );
679
+ }
680
+ }
681
+
682
+ // src/components/page-icon.tsx
683
+ import { jsx as jsx5 } from "react/jsx-runtime";
684
+ var isIconBlock = (value) => {
685
+ return value.type === "page" || value.type === "callout" || value.type === "collection_view" || value.type === "collection_view_page";
686
+ };
687
+ function PageIconImpl({
688
+ block,
689
+ className,
690
+ inline = true,
691
+ hideDefaultIcon = false,
692
+ defaultIcon
693
+ }) {
694
+ var _a;
695
+ const { mapImageUrl, recordMap, darkMode } = useNotionContext();
696
+ let isImage = false;
697
+ let content = null;
698
+ if (isIconBlock(block)) {
699
+ const icon = ((_a = getBlockIcon(block, recordMap)) == null ? void 0 : _a.trim()) || defaultIcon;
700
+ const title = getBlockTitle(block, recordMap);
701
+ if (icon && isUrl(icon)) {
702
+ const url = mapImageUrl(icon, block);
703
+ isImage = true;
704
+ content = /* @__PURE__ */ jsx5(
705
+ LazyImage,
706
+ {
707
+ src: url,
708
+ alt: title || "page icon",
709
+ className: cs(className, "notion-page-icon")
710
+ }
711
+ );
712
+ } else if (icon && icon.startsWith("/icons/")) {
713
+ const url = "https://www.notion.so" + icon + "?mode=" + (darkMode ? "dark" : "light");
714
+ content = /* @__PURE__ */ jsx5(
715
+ LazyImage,
716
+ {
717
+ src: url,
718
+ alt: title || "page icon",
719
+ className: cs(className, "notion-page-icon")
720
+ }
721
+ );
722
+ } else if (!icon) {
723
+ if (!hideDefaultIcon) {
724
+ isImage = true;
725
+ content = /* @__PURE__ */ jsx5(
726
+ DefaultPageIcon,
727
+ {
728
+ className: cs(className, "notion-page-icon"),
729
+ alt: title || "page icon"
730
+ }
731
+ );
732
+ }
733
+ } else {
734
+ isImage = false;
735
+ content = /* @__PURE__ */ jsx5(
736
+ "span",
737
+ {
738
+ className: cs(className, "notion-page-icon"),
739
+ role: "img",
740
+ "aria-label": icon,
741
+ children: icon
742
+ }
743
+ );
744
+ }
745
+ }
746
+ if (!content) {
747
+ return null;
748
+ }
749
+ return /* @__PURE__ */ jsx5(
750
+ "div",
751
+ {
752
+ className: cs(
753
+ inline ? "notion-page-icon-inline" : "notion-page-icon-hero",
754
+ isImage ? "notion-page-icon-image" : "notion-page-icon-span"
755
+ ),
756
+ children: content
757
+ }
758
+ );
759
+ }
760
+ var PageIcon = React4.memo(PageIconImpl);
761
+
762
+ // src/components/search-dialog.tsx
763
+ var import_lodash = __toESM(require_lodash(), 1);
764
+ import { getBlockParentPage, getBlockTitle as getBlockTitle3 } from "notion-utils";
765
+ import React8 from "react";
766
+
767
+ // src/icons/clear-icon.tsx
768
+ import "react";
769
+ import { jsx as jsx6 } from "react/jsx-runtime";
770
+ function ClearIcon(props) {
771
+ const { className, ...rest } = props;
772
+ return /* @__PURE__ */ jsx6("svg", { className: cs("notion-icon", className), ...rest, viewBox: "0 0 30 30", children: /* @__PURE__ */ jsx6("path", { d: "M15,0C6.716,0,0,6.716,0,15s6.716,15,15,15s15-6.716,15-15S23.284,0,15,0z M22,20.6L20.6,22L15,16.4L9.4,22L8,20.6l5.6-5.6 L8,9.4L9.4,8l5.6,5.6L20.6,8L22,9.4L16.4,15L22,20.6z" }) });
773
+ }
774
+
775
+ // src/icons/loading-icon.tsx
776
+ import "react";
777
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
778
+ function LoadingIcon(props) {
779
+ const { className, ...rest } = props;
780
+ return /* @__PURE__ */ jsxs2("svg", { className: cs("notion-icon", className), ...rest, viewBox: "0 0 24 24", children: [
781
+ /* @__PURE__ */ jsx7("defs", { children: /* @__PURE__ */ jsxs2(
782
+ "linearGradient",
783
+ {
784
+ x1: "28.1542969%",
785
+ y1: "63.7402344%",
786
+ x2: "74.6289062%",
787
+ y2: "17.7832031%",
788
+ id: "linearGradient-1",
789
+ children: [
790
+ /* @__PURE__ */ jsx7("stop", { stopColor: "rgba(164, 164, 164, 1)", offset: "0%" }),
791
+ /* @__PURE__ */ jsx7(
792
+ "stop",
793
+ {
794
+ stopColor: "rgba(164, 164, 164, 0)",
795
+ stopOpacity: "0",
796
+ offset: "100%"
797
+ }
798
+ )
799
+ ]
800
+ }
801
+ ) }),
802
+ /* @__PURE__ */ jsx7("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", children: /* @__PURE__ */ jsx7("g", { transform: "translate(-236.000000, -286.000000)", children: /* @__PURE__ */ jsxs2("g", { transform: "translate(238.000000, 286.000000)", children: [
803
+ /* @__PURE__ */ jsx7(
804
+ "circle",
805
+ {
806
+ id: "Oval-2",
807
+ stroke: "url(#linearGradient-1)",
808
+ strokeWidth: "4",
809
+ cx: "10",
810
+ cy: "12",
811
+ r: "10"
812
+ }
813
+ ),
814
+ /* @__PURE__ */ jsx7(
815
+ "path",
816
+ {
817
+ d: "M10,2 C4.4771525,2 0,6.4771525 0,12",
818
+ id: "Oval-2",
819
+ stroke: "rgba(164, 164, 164, 1)",
820
+ strokeWidth: "4"
821
+ }
822
+ ),
823
+ /* @__PURE__ */ jsx7(
824
+ "rect",
825
+ {
826
+ id: "Rectangle-1",
827
+ fill: "rgba(164, 164, 164, 1)",
828
+ x: "8",
829
+ y: "0",
830
+ width: "4",
831
+ height: "4",
832
+ rx: "8"
833
+ }
834
+ )
835
+ ] }) }) })
836
+ ] });
837
+ }
838
+
839
+ // src/components/page-title.tsx
840
+ import "notion-types";
841
+ import { getBlockTitle as getBlockTitle2 } from "notion-utils";
842
+ import React7 from "react";
843
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
844
+ function PageTitleImpl({
845
+ block,
846
+ className,
847
+ defaultIcon,
848
+ ...rest
849
+ }) {
850
+ var _a, _b;
851
+ const { recordMap } = useNotionContext();
852
+ if (!block) return null;
853
+ if (block.type === "collection_view_page" || block.type === "collection_view") {
854
+ const title = getBlockTitle2(block, recordMap);
855
+ if (!title) {
856
+ return null;
857
+ }
858
+ const titleDecoration = [[title]];
859
+ return /* @__PURE__ */ jsxs3("span", { className: cs("notion-page-title", className), ...rest, children: [
860
+ /* @__PURE__ */ jsx8(
861
+ PageIcon,
862
+ {
863
+ block,
864
+ defaultIcon,
865
+ className: "notion-page-title-icon"
866
+ }
867
+ ),
868
+ /* @__PURE__ */ jsx8("span", { className: "notion-page-title-text", children: /* @__PURE__ */ jsx8(Text, { value: titleDecoration, block }) })
869
+ ] });
870
+ }
871
+ if (!((_a = block.properties) == null ? void 0 : _a.title)) {
872
+ return null;
873
+ }
874
+ return /* @__PURE__ */ jsxs3("span", { className: cs("notion-page-title", className), ...rest, children: [
875
+ /* @__PURE__ */ jsx8(
876
+ PageIcon,
877
+ {
878
+ block,
879
+ defaultIcon,
880
+ className: "notion-page-title-icon"
881
+ }
882
+ ),
883
+ /* @__PURE__ */ jsx8("span", { className: "notion-page-title-text", children: /* @__PURE__ */ jsx8(Text, { value: (_b = block.properties) == null ? void 0 : _b.title, block }) })
884
+ ] });
885
+ }
886
+ var PageTitle = React7.memo(PageTitleImpl);
887
+
888
+ // src/components/search-dialog.tsx
889
+ import { Fragment, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
890
+ var SearchDialog = class extends React8.Component {
891
+ constructor(props) {
892
+ super(props);
893
+ __publicField(this, "state", {
894
+ isLoading: false,
895
+ query: "",
896
+ searchResult: null,
897
+ searchError: null
898
+ });
899
+ __publicField(this, "_inputRef");
900
+ __publicField(this, "_search");
901
+ __publicField(this, "_onAfterOpen", () => {
902
+ if (this._inputRef.current) {
903
+ this._inputRef.current.focus();
904
+ }
905
+ });
906
+ __publicField(this, "_onChangeQuery", (e) => {
907
+ const query = e.target.value;
908
+ this.setState({ query });
909
+ if (!query.trim()) {
910
+ this.setState({ isLoading: false, searchResult: null, searchError: null });
911
+ return;
912
+ } else {
913
+ this._search();
914
+ }
915
+ });
916
+ __publicField(this, "_onClearQuery", () => {
917
+ this._onChangeQuery({ target: { value: "" } });
918
+ });
919
+ __publicField(this, "_warmupSearch", async () => {
920
+ const { searchNotion, rootBlockId } = this.props;
921
+ await searchNotion({
922
+ query: "",
923
+ ancestorId: rootBlockId
924
+ });
925
+ });
926
+ __publicField(this, "_searchImpl", async () => {
927
+ const { searchNotion, rootBlockId } = this.props;
928
+ const { query } = this.state;
929
+ if (!query.trim()) {
930
+ this.setState({ isLoading: false, searchResult: null, searchError: null });
931
+ return;
932
+ }
933
+ this.setState({ isLoading: true });
934
+ const result = await searchNotion({
935
+ query,
936
+ ancestorId: rootBlockId
937
+ });
938
+ console.log("search", query, result);
939
+ let searchResult = null;
940
+ let searchError = null;
941
+ if (result.error || result.errorId) {
942
+ searchError = result;
943
+ } else {
944
+ searchResult = { ...result };
945
+ const results = searchResult.results.map((result2) => {
946
+ var _a, _b;
947
+ const block = (_a = searchResult.recordMap.block[result2.id]) == null ? void 0 : _a.value;
948
+ if (!block) return;
949
+ const title = getBlockTitle3(block, searchResult.recordMap);
950
+ if (!title) {
951
+ return;
952
+ }
953
+ result2.title = title;
954
+ result2.block = block;
955
+ result2.recordMap = searchResult.recordMap;
956
+ result2.page = getBlockParentPage(block, searchResult.recordMap, {
957
+ inclusive: true
958
+ }) || block;
959
+ if (!result2.page.id) {
960
+ return;
961
+ }
962
+ if ((_b = result2.highlight) == null ? void 0 : _b.text) {
963
+ result2.highlight.html = result2.highlight.text.replaceAll(/<gzknfouu>/gi, "<b>").replaceAll(/<\/gzknfouu>/gi, "</b>");
964
+ }
965
+ return result2;
966
+ }).filter(Boolean);
967
+ const searchResultsMap = Object.fromEntries(
968
+ results.map((result2) => [result2.page.id, result2])
969
+ );
970
+ searchResult.results = Object.values(searchResultsMap);
971
+ }
972
+ if (this.state.query === query) {
973
+ this.setState({ isLoading: false, searchResult, searchError });
974
+ }
975
+ });
976
+ this._inputRef = React8.createRef();
977
+ }
978
+ componentDidMount() {
979
+ this._search = (0, import_lodash.default)(this._searchImpl.bind(this), 1e3);
980
+ void this._warmupSearch();
981
+ }
982
+ render() {
983
+ const { isOpen, onClose } = this.props;
984
+ const { isLoading, query, searchResult, searchError } = this.state;
985
+ const hasQuery = !!query.trim();
986
+ return /* @__PURE__ */ jsx9(NotionContextConsumer, { children: (ctx2) => {
987
+ const { components, defaultPageIcon, mapPageUrl } = ctx2;
988
+ return /* @__PURE__ */ jsx9(
989
+ components.Modal,
990
+ {
991
+ isOpen,
992
+ contentLabel: "Search",
993
+ className: "notion-search",
994
+ overlayClassName: "notion-search-overlay",
995
+ onRequestClose: onClose,
996
+ onAfterOpen: this._onAfterOpen,
997
+ children: /* @__PURE__ */ jsxs4("div", { className: "quickFindMenu", children: [
998
+ /* @__PURE__ */ jsxs4("div", { className: "searchBar", children: [
999
+ /* @__PURE__ */ jsx9("div", { className: "inlineIcon", children: isLoading ? /* @__PURE__ */ jsx9(LoadingIcon, { className: "loadingIcon" }) : /* @__PURE__ */ jsx9(SearchIcon, {}) }),
1000
+ /* @__PURE__ */ jsx9(
1001
+ "input",
1002
+ {
1003
+ className: "searchInput",
1004
+ placeholder: "Search",
1005
+ value: query,
1006
+ ref: this._inputRef,
1007
+ onChange: this._onChangeQuery
1008
+ }
1009
+ ),
1010
+ query && /* @__PURE__ */ jsx9(
1011
+ "div",
1012
+ {
1013
+ role: "button",
1014
+ className: "clearButton",
1015
+ onClick: this._onClearQuery,
1016
+ children: /* @__PURE__ */ jsx9(ClearIcon, { className: "clearIcon" })
1017
+ }
1018
+ )
1019
+ ] }),
1020
+ hasQuery && searchResult && /* @__PURE__ */ jsx9(Fragment, { children: searchResult.results.length ? /* @__PURE__ */ jsxs4(
1021
+ NotionContextProvider,
1022
+ {
1023
+ ...ctx2,
1024
+ recordMap: searchResult.recordMap,
1025
+ children: [
1026
+ /* @__PURE__ */ jsx9("div", { className: "resultsPane", children: searchResult.results.map((result) => {
1027
+ var _a;
1028
+ return /* @__PURE__ */ jsxs4(
1029
+ components.PageLink,
1030
+ {
1031
+ className: cs("result", "notion-page-link"),
1032
+ href: mapPageUrl(
1033
+ result.page.id,
1034
+ // TODO
1035
+ searchResult.recordMap
1036
+ ),
1037
+ children: [
1038
+ /* @__PURE__ */ jsx9(
1039
+ PageTitle,
1040
+ {
1041
+ block: result.page,
1042
+ defaultIcon: defaultPageIcon
1043
+ }
1044
+ ),
1045
+ ((_a = result.highlight) == null ? void 0 : _a.html) && /* @__PURE__ */ jsx9(
1046
+ "div",
1047
+ {
1048
+ className: "notion-search-result-highlight",
1049
+ dangerouslySetInnerHTML: {
1050
+ __html: result.highlight.html
1051
+ }
1052
+ }
1053
+ )
1054
+ ]
1055
+ },
1056
+ result.id
1057
+ );
1058
+ }) }),
1059
+ /* @__PURE__ */ jsx9("footer", { className: "resultsFooter", children: /* @__PURE__ */ jsxs4("div", { children: [
1060
+ /* @__PURE__ */ jsx9("span", { className: "resultsCount", children: searchResult.total }),
1061
+ searchResult.total === 1 ? " result" : " results"
1062
+ ] }) })
1063
+ ]
1064
+ }
1065
+ ) : /* @__PURE__ */ jsxs4("div", { className: "noResultsPane", children: [
1066
+ /* @__PURE__ */ jsx9("div", { className: "noResults", children: "No results" }),
1067
+ /* @__PURE__ */ jsx9("div", { className: "noResultsDetail", children: "Try different search terms" })
1068
+ ] }) }),
1069
+ hasQuery && !searchResult && searchError && /* @__PURE__ */ jsx9("div", { className: "noResultsPane", children: /* @__PURE__ */ jsx9("div", { className: "noResults", children: "Search error" }) })
1070
+ ] })
1071
+ }
1072
+ );
1073
+ } });
1074
+ }
1075
+ };
1076
+
1077
+ // src/components/header.tsx
1078
+ import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
1079
+ function Header({
1080
+ block
1081
+ }) {
1082
+ return /* @__PURE__ */ jsx10("header", { className: "notion-header", children: /* @__PURE__ */ jsxs5("div", { className: "notion-nav-header", children: [
1083
+ /* @__PURE__ */ jsx10(Breadcrumbs, { block }),
1084
+ /* @__PURE__ */ jsx10(Search, { block })
1085
+ ] }) });
1086
+ }
1087
+ function Breadcrumbs({
1088
+ block,
1089
+ rootOnly = false
1090
+ }) {
1091
+ const { recordMap, mapPageUrl, components } = useNotionContext();
1092
+ const breadcrumbs = React9.useMemo(() => {
1093
+ const tempBreadcrumbs = getPageBreadcrumbs(recordMap, block.id);
1094
+ if (rootOnly) {
1095
+ return [tempBreadcrumbs == null ? void 0 : tempBreadcrumbs[0]].filter(Boolean);
1096
+ }
1097
+ return tempBreadcrumbs;
1098
+ }, [recordMap, block.id, rootOnly]);
1099
+ return /* @__PURE__ */ jsx10("div", { className: "breadcrumbs", children: breadcrumbs == null ? void 0 : breadcrumbs.map((breadcrumb, index) => {
1100
+ if (!breadcrumb) {
1101
+ return null;
1102
+ }
1103
+ const pageLinkProps = {};
1104
+ const componentMap = {
1105
+ pageLink: components.PageLink
1106
+ };
1107
+ if (breadcrumb.active) {
1108
+ componentMap.pageLink = (props) => /* @__PURE__ */ jsx10("div", { ...props });
1109
+ } else {
1110
+ pageLinkProps.href = mapPageUrl(breadcrumb.pageId);
1111
+ }
1112
+ return /* @__PURE__ */ jsxs5(React9.Fragment, { children: [
1113
+ /* @__PURE__ */ jsxs5(
1114
+ componentMap.pageLink,
1115
+ {
1116
+ className: cs("breadcrumb", breadcrumb.active && "active"),
1117
+ ...pageLinkProps,
1118
+ children: [
1119
+ breadcrumb.icon && /* @__PURE__ */ jsx10(PageIcon, { className: "icon", block: breadcrumb.block }),
1120
+ breadcrumb.title && /* @__PURE__ */ jsx10("span", { className: "title", children: breadcrumb.title })
1121
+ ]
1122
+ }
1123
+ ),
1124
+ index < breadcrumbs.length - 1 && /* @__PURE__ */ jsx10("span", { className: "spacer", children: "/" })
1125
+ ] }, breadcrumb.pageId);
1126
+ }) }, "breadcrumbs");
1127
+ }
1128
+ function Search({
1129
+ block,
1130
+ search,
1131
+ title = "Search"
1132
+ }) {
1133
+ const { searchNotion, rootPageId, isShowingSearch, onHideSearch } = useNotionContext();
1134
+ const onSearchNotion = search || searchNotion;
1135
+ const [isSearchOpen, setIsSearchOpen] = React9.useState(isShowingSearch);
1136
+ React9.useEffect(() => {
1137
+ setIsSearchOpen(isShowingSearch);
1138
+ }, [isShowingSearch]);
1139
+ const onOpenSearch = React9.useCallback(() => {
1140
+ setIsSearchOpen(true);
1141
+ }, []);
1142
+ const onCloseSearch = React9.useCallback(() => {
1143
+ setIsSearchOpen(false);
1144
+ if (onHideSearch) {
1145
+ onHideSearch();
1146
+ }
1147
+ }, [onHideSearch]);
1148
+ useHotkeys("cmd+p", (event) => {
1149
+ onOpenSearch();
1150
+ event.preventDefault();
1151
+ event.stopPropagation();
1152
+ });
1153
+ useHotkeys("cmd+k", (event) => {
1154
+ onOpenSearch();
1155
+ event.preventDefault();
1156
+ event.stopPropagation();
1157
+ });
1158
+ const hasSearch = !!onSearchNotion;
1159
+ return /* @__PURE__ */ jsxs5(Fragment2, { children: [
1160
+ hasSearch && /* @__PURE__ */ jsxs5(
1161
+ "div",
1162
+ {
1163
+ role: "button",
1164
+ className: cs("breadcrumb", "button", "notion-search-button"),
1165
+ onClick: onOpenSearch,
1166
+ children: [
1167
+ /* @__PURE__ */ jsx10(SearchIcon, { className: "searchIcon" }),
1168
+ title && /* @__PURE__ */ jsx10("span", { className: "title", children: title })
1169
+ ]
1170
+ }
1171
+ ),
1172
+ isSearchOpen && hasSearch && /* @__PURE__ */ jsx10(
1173
+ SearchDialog,
1174
+ {
1175
+ isOpen: isSearchOpen,
1176
+ rootBlockId: rootPageId || (block == null ? void 0 : block.id),
1177
+ onClose: onCloseSearch,
1178
+ searchNotion: onSearchNotion
1179
+ }
1180
+ )
1181
+ ] });
1182
+ }
1183
+
1184
+ // src/components/eoi.tsx
1185
+ import "notion-types";
1186
+
1187
+ // src/icons/type-github.tsx
1188
+ import { jsx as jsx11 } from "react/jsx-runtime";
1189
+ function SvgTypeGitHub(props) {
1190
+ return /* @__PURE__ */ jsx11("svg", { viewBox: "0 0 260 260", ...props, children: /* @__PURE__ */ jsx11("g", { children: /* @__PURE__ */ jsx11(
1191
+ "path",
1192
+ {
1193
+ d: "M128.00106,0 C57.3172926,0 0,57.3066942 0,128.00106 C0,184.555281 36.6761997,232.535542 87.534937,249.460899 C93.9320223,250.645779 96.280588,246.684165 96.280588,243.303333 C96.280588,240.251045 96.1618878,230.167899 96.106777,219.472176 C60.4967585,227.215235 52.9826207,204.369712 52.9826207,204.369712 C47.1599584,189.574598 38.770408,185.640538 38.770408,185.640538 C27.1568785,177.696113 39.6458206,177.859325 39.6458206,177.859325 C52.4993419,178.762293 59.267365,191.04987 59.267365,191.04987 C70.6837675,210.618423 89.2115753,204.961093 96.5158685,201.690482 C97.6647155,193.417512 100.981959,187.77078 104.642583,184.574357 C76.211799,181.33766 46.324819,170.362144 46.324819,121.315702 C46.324819,107.340889 51.3250588,95.9223682 59.5132437,86.9583937 C58.1842268,83.7344152 53.8029229,70.715562 60.7532354,53.0843636 C60.7532354,53.0843636 71.5019501,49.6441813 95.9626412,66.2049595 C106.172967,63.368876 117.123047,61.9465949 128.00106,61.8978432 C138.879073,61.9465949 149.837632,63.368876 160.067033,66.2049595 C184.49805,49.6441813 195.231926,53.0843636 195.231926,53.0843636 C202.199197,70.715562 197.815773,83.7344152 196.486756,86.9583937 C204.694018,95.9223682 209.660343,107.340889 209.660343,121.315702 C209.660343,170.478725 179.716133,181.303747 151.213281,184.472614 C155.80443,188.444828 159.895342,196.234518 159.895342,208.176593 C159.895342,225.303317 159.746968,239.087361 159.746968,243.303333 C159.746968,246.709601 162.05102,250.70089 168.53925,249.443941 C219.370432,232.499507 256,184.536204 256,128.00106 C256,57.3066942 198.691187,0 128.00106,0 Z M47.9405593,182.340212 C47.6586465,182.976105 46.6581745,183.166873 45.7467277,182.730227 C44.8183235,182.312656 44.2968914,181.445722 44.5978808,180.80771 C44.8734344,180.152739 45.876026,179.97045 46.8023103,180.409216 C47.7328342,180.826786 48.2627451,181.702199 47.9405593,182.340212 Z M54.2367892,187.958254 C53.6263318,188.524199 52.4329723,188.261363 51.6232682,187.366874 C50.7860088,186.474504 50.6291553,185.281144 51.2480912,184.70672 C51.8776254,184.140775 53.0349512,184.405731 53.8743302,185.298101 C54.7115892,186.201069 54.8748019,187.38595 54.2367892,187.958254 Z M58.5562413,195.146347 C57.7719732,195.691096 56.4895886,195.180261 55.6968417,194.042013 C54.9125733,192.903764 54.9125733,191.538713 55.713799,190.991845 C56.5086651,190.444977 57.7719732,190.936735 58.5753181,192.066505 C59.3574669,193.22383 59.3574669,194.58888 58.5562413,195.146347 Z M65.8613592,203.471174 C65.1597571,204.244846 63.6654083,204.03712 62.5716717,202.981538 C61.4524999,201.94927 61.1409122,200.484596 61.8446341,199.710926 C62.5547146,198.935137 64.0575422,199.15346 65.1597571,200.200564 C66.2704506,201.230712 66.6095936,202.705984 65.8613592,203.471174 Z M75.3025151,206.281542 C74.9930474,207.284134 73.553809,207.739857 72.1039724,207.313809 C70.6562556,206.875043 69.7087748,205.700761 70.0012857,204.687571 C70.302275,203.678621 71.7478721,203.20382 73.2083069,203.659543 C74.6539041,204.09619 75.6035048,205.261994 75.3025151,206.281542 Z M86.046947,207.473627 C86.0829806,208.529209 84.8535871,209.404622 83.3316829,209.4237 C81.8013,209.457614 80.563428,208.603398 80.5464708,207.564772 C80.5464708,206.498591 81.7483088,205.631657 83.2786917,205.606221 C84.8005962,205.576546 86.046947,206.424403 86.046947,207.473627 Z M96.6021471,207.069023 C96.7844366,208.099171 95.7267341,209.156872 94.215428,209.438785 C92.7295577,209.710099 91.3539086,209.074206 91.1652603,208.052538 C90.9808515,206.996955 92.0576306,205.939253 93.5413813,205.66582 C95.054807,205.402984 96.4092596,206.021919 96.6021471,207.069023 Z",
1194
+ fill: "#161614"
1195
+ }
1196
+ ) }) });
1197
+ }
1198
+ var type_github_default = SvgTypeGitHub;
1199
+
1200
+ // src/components/mention-preview-card.tsx
1201
+ import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
1202
+ function capitalizeFirstLetter(str) {
1203
+ if (!str) return "";
1204
+ return str.charAt(0).toUpperCase() + str.slice(1);
1205
+ }
1206
+ function MentionPreviewCard({
1207
+ owner,
1208
+ lastUpdated,
1209
+ externalImage,
1210
+ title,
1211
+ domain
1212
+ }) {
1213
+ return /* @__PURE__ */ jsxs6("div", { className: "notion-external-subtitle", children: [
1214
+ externalImage && /* @__PURE__ */ jsxs6("div", { className: "notion-preview-card-domain-warp", children: [
1215
+ /* @__PURE__ */ jsx12("div", { className: "notion-preview-card-logo", children: externalImage }),
1216
+ /* @__PURE__ */ jsx12("div", { className: "notion-preview-card-domain", children: capitalizeFirstLetter(domain.split(".")[0]) })
1217
+ ] }),
1218
+ /* @__PURE__ */ jsx12("div", { className: "notion-preview-card-title", children: title }),
1219
+ owner && /* @__PURE__ */ jsxs6("div", { className: "notion-external-subtitle-item", children: [
1220
+ /* @__PURE__ */ jsx12("div", { className: "notion-external-subtitle-item-name", children: "Owner" }),
1221
+ /* @__PURE__ */ jsx12("span", { className: "notion-external-subtitle-item-desc", children: owner })
1222
+ ] }),
1223
+ lastUpdated && /* @__PURE__ */ jsxs6("div", { className: "notion-external-subtitle-item", children: [
1224
+ /* @__PURE__ */ jsx12("div", { className: "notion-external-subtitle-item-name", children: "Updated" }),
1225
+ /* @__PURE__ */ jsx12("span", { className: "notion-external-subtitle-item-desc", children: lastUpdated })
1226
+ ] }),
1227
+ domain === "github.com" && /* @__PURE__ */ jsxs6("div", { className: "notion-preview-card-github-shields", children: [
1228
+ /* @__PURE__ */ jsx12(
1229
+ "img",
1230
+ {
1231
+ src: `https://img.shields.io/github/stars/${owner}/${title}?logo=github`,
1232
+ alt: ""
1233
+ }
1234
+ ),
1235
+ /* @__PURE__ */ jsx12(
1236
+ "img",
1237
+ {
1238
+ src: `https://img.shields.io/github/last-commit/${owner}/${title}`,
1239
+ alt: ""
1240
+ }
1241
+ )
1242
+ ] })
1243
+ ] });
1244
+ }
1245
+
1246
+ // src/components/eoi.tsx
1247
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
1248
+ function EOI({
1249
+ block,
1250
+ inline,
1251
+ className
1252
+ }) {
1253
+ var _a, _b, _c;
1254
+ const { components } = useNotionContext();
1255
+ const { original_url, attributes, domain } = (block == null ? void 0 : block.format) || {};
1256
+ if (!original_url || !attributes) {
1257
+ return null;
1258
+ }
1259
+ const title = (_a = attributes.find((attr) => attr.id === "title")) == null ? void 0 : _a.values[0];
1260
+ let owner = (_b = attributes.find((attr) => attr.id === "owner")) == null ? void 0 : _b.values[0];
1261
+ const lastUpdatedAt = (_c = attributes.find((attr) => attr.id === "updated_at")) == null ? void 0 : _c.values[0];
1262
+ const lastUpdated = lastUpdatedAt ? formatNotionDateTime(lastUpdatedAt) : null;
1263
+ let externalImage;
1264
+ switch (domain) {
1265
+ case "github.com":
1266
+ externalImage = /* @__PURE__ */ jsx13(type_github_default, {});
1267
+ if (owner) {
1268
+ const parts = owner.split("/");
1269
+ owner = parts.at(-1);
1270
+ }
1271
+ break;
1272
+ default:
1273
+ if (true) {
1274
+ console.log(
1275
+ `Unsupported external_object_instance domain "${domain}"`,
1276
+ JSON.stringify(block, null, 2)
1277
+ );
1278
+ }
1279
+ return null;
1280
+ }
1281
+ return /* @__PURE__ */ jsxs7(
1282
+ components.Link,
1283
+ {
1284
+ target: "_blank",
1285
+ rel: "noopener noreferrer",
1286
+ href: original_url,
1287
+ className: cs(
1288
+ "notion-external",
1289
+ inline ? "notion-external-mention" : "notion-external-block notion-row",
1290
+ className
1291
+ ),
1292
+ children: [
1293
+ externalImage && /* @__PURE__ */ jsx13("div", { className: "notion-external-image", children: externalImage }),
1294
+ /* @__PURE__ */ jsxs7("div", { className: "notion-external-description", children: [
1295
+ /* @__PURE__ */ jsx13("div", { className: "notion-external-title", children: title }),
1296
+ !inline && owner ? /* @__PURE__ */ jsxs7("div", { className: "notion-external-block-desc", children: [
1297
+ owner,
1298
+ lastUpdated && /* @__PURE__ */ jsx13("span", { children: " \u2022 " }),
1299
+ lastUpdated && `Updated ${lastUpdated}`
1300
+ ] }) : null,
1301
+ inline && (owner || lastUpdated) && /* @__PURE__ */ jsx13(
1302
+ MentionPreviewCard,
1303
+ {
1304
+ title,
1305
+ owner,
1306
+ lastUpdated,
1307
+ domain,
1308
+ externalImage
1309
+ }
1310
+ )
1311
+ ] })
1312
+ ]
1313
+ }
1314
+ );
1315
+ }
1316
+
1317
+ // src/components/graceful-image.tsx
1318
+ import "react";
1319
+ import { Img } from "react-image";
1320
+ import { jsx as jsx14 } from "react/jsx-runtime";
1321
+ function GracefulImage(props) {
1322
+ if (isBrowser) {
1323
+ return /* @__PURE__ */ jsx14(Img, { ...props });
1324
+ } else {
1325
+ return /* @__PURE__ */ jsx14("img", { ...props });
1326
+ }
1327
+ }
1328
+
1329
+ // src/components/asset.tsx
1330
+ import "notion-types";
1331
+ import { getTextContent } from "notion-utils";
1332
+
1333
+ // src/components/lite-youtube-embed.tsx
1334
+ import React11 from "react";
1335
+ import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
1336
+ var qs = (params) => {
1337
+ return Object.keys(params).map(
1338
+ (key) => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`
1339
+ ).join("&");
1340
+ };
1341
+ var resolutions = [120, 320, 480, 640, 1280];
1342
+ var resolutionMap = {
1343
+ 120: "default",
1344
+ 320: "mqdefault",
1345
+ 480: "hqdefault",
1346
+ 640: "sddefault",
1347
+ 1280: "maxresdefault"
1348
+ // 2k, 4k, 8k images don't seem to be available
1349
+ // Source: https://longzero.com/articles/youtube-thumbnail-sizes-url/
1350
+ };
1351
+ var resolutionSizes = resolutions.map((resolution) => `(max-width: ${resolution}px) ${resolution}px`).join(", ");
1352
+ function getPosterUrl(id, resolution = 480, type = "jpg") {
1353
+ if (type === "webp") {
1354
+ return `https://i.ytimg.com/vi_webp/${id}/${resolutionMap[resolution]}.webp`;
1355
+ }
1356
+ return `https://i.ytimg.com/vi/${id}/${resolutionMap[resolution]}.jpg`;
1357
+ }
1358
+ function generateSrcSet(id, type = "jpg") {
1359
+ return resolutions.map((resolution) => `${getPosterUrl(id, resolution, type)} ${resolution}w`).join(", ");
1360
+ }
1361
+ function LiteYouTubeEmbed({
1362
+ id,
1363
+ defaultPlay = false,
1364
+ mute = false,
1365
+ lazyImage = false,
1366
+ iframeTitle = "YouTube video",
1367
+ alt = "Video preview",
1368
+ params = {},
1369
+ adLinksPreconnect = true,
1370
+ style,
1371
+ className
1372
+ }) {
1373
+ const muteParam = mute || defaultPlay ? "1" : "0";
1374
+ const queryString = React11.useMemo(
1375
+ () => qs({ autoplay: "1", mute: muteParam, ...params }),
1376
+ [muteParam, params]
1377
+ );
1378
+ const ytUrl = "https://www.youtube-nocookie.com";
1379
+ const iframeSrc = `${ytUrl}/embed/${id}?${queryString}`;
1380
+ const [isPreconnected, setIsPreconnected] = React11.useState(false);
1381
+ const [iframeInitialized, setIframeInitialized] = React11.useState(defaultPlay);
1382
+ const [isIframeLoaded, setIsIframeLoaded] = React11.useState(false);
1383
+ const warmConnections = React11.useCallback(() => {
1384
+ if (isPreconnected) return;
1385
+ setIsPreconnected(true);
1386
+ }, [isPreconnected]);
1387
+ const onLoadIframe = React11.useCallback(() => {
1388
+ if (iframeInitialized) return;
1389
+ setIframeInitialized(true);
1390
+ }, [iframeInitialized]);
1391
+ const onIframeLoaded = React11.useCallback(() => {
1392
+ setIsIframeLoaded(true);
1393
+ }, []);
1394
+ return /* @__PURE__ */ jsxs8(Fragment3, { children: [
1395
+ /* @__PURE__ */ jsx15(
1396
+ "link",
1397
+ {
1398
+ rel: "preload",
1399
+ as: "image",
1400
+ href: getPosterUrl(id),
1401
+ imageSrcSet: generateSrcSet(id, "webp"),
1402
+ imageSizes: resolutionSizes
1403
+ }
1404
+ ),
1405
+ isPreconnected && /* @__PURE__ */ jsxs8(Fragment3, { children: [
1406
+ /* @__PURE__ */ jsx15("link", { rel: "preconnect", href: ytUrl }),
1407
+ /* @__PURE__ */ jsx15("link", { rel: "preconnect", href: "https://www.google.com" })
1408
+ ] }),
1409
+ isPreconnected && adLinksPreconnect && /* @__PURE__ */ jsxs8(Fragment3, { children: [
1410
+ /* @__PURE__ */ jsx15("link", { rel: "preconnect", href: "https://static.doubleclick.net" }),
1411
+ /* @__PURE__ */ jsx15("link", { rel: "preconnect", href: "https://googleads.g.doubleclick.net" })
1412
+ ] }),
1413
+ /* @__PURE__ */ jsxs8(
1414
+ "div",
1415
+ {
1416
+ onClick: onLoadIframe,
1417
+ onPointerOver: warmConnections,
1418
+ className: cs(
1419
+ "notion-yt-lite",
1420
+ isIframeLoaded && "notion-yt-loaded",
1421
+ iframeInitialized && "notion-yt-initialized",
1422
+ className
1423
+ ),
1424
+ style,
1425
+ children: [
1426
+ /* @__PURE__ */ jsxs8("picture", { children: [
1427
+ resolutions.map((resolution) => /* @__PURE__ */ jsx15(
1428
+ "source",
1429
+ {
1430
+ srcSet: `${getPosterUrl(id, resolution, "webp")} ${resolution}w`,
1431
+ media: `(max-width: ${resolution}px)`,
1432
+ type: "image/webp"
1433
+ },
1434
+ resolution
1435
+ )),
1436
+ /* @__PURE__ */ jsx15(
1437
+ "img",
1438
+ {
1439
+ src: getPosterUrl(id),
1440
+ className: "notion-yt-thumbnail",
1441
+ loading: lazyImage ? "lazy" : void 0,
1442
+ alt
1443
+ }
1444
+ )
1445
+ ] }),
1446
+ /* @__PURE__ */ jsx15("div", { className: "notion-yt-playbtn" }),
1447
+ iframeInitialized && /* @__PURE__ */ jsx15(
1448
+ "iframe",
1449
+ {
1450
+ width: "560",
1451
+ height: "315",
1452
+ frameBorder: "0",
1453
+ allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
1454
+ allowFullScreen: true,
1455
+ title: iframeTitle,
1456
+ src: iframeSrc,
1457
+ onLoad: onIframeLoaded
1458
+ }
1459
+ )
1460
+ ]
1461
+ }
1462
+ )
1463
+ ] });
1464
+ }
1465
+
1466
+ // src/components/asset.tsx
1467
+ import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
1468
+ var isServer = !globalThis.window;
1469
+ var supportedAssetTypes = /* @__PURE__ */ new Set([
1470
+ "replit",
1471
+ "video",
1472
+ "image",
1473
+ "embed",
1474
+ "figma",
1475
+ "typeform",
1476
+ "excalidraw",
1477
+ "maps",
1478
+ "tweet",
1479
+ "pdf",
1480
+ "gist",
1481
+ "codepen",
1482
+ "drive"
1483
+ ]);
1484
+ function Asset({
1485
+ block,
1486
+ zoomable = true,
1487
+ children
1488
+ }) {
1489
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1490
+ const { recordMap, mapImageUrl, components } = useNotionContext();
1491
+ if (!block || !supportedAssetTypes.has(block.type)) {
1492
+ return null;
1493
+ }
1494
+ const style = {
1495
+ position: "relative",
1496
+ display: "flex",
1497
+ justifyContent: "center",
1498
+ alignSelf: "center",
1499
+ width: "100%",
1500
+ maxWidth: "100%",
1501
+ flexDirection: "column"
1502
+ };
1503
+ const assetStyle = {};
1504
+ if (block.format) {
1505
+ const {
1506
+ block_aspect_ratio,
1507
+ block_height,
1508
+ block_width,
1509
+ block_full_width,
1510
+ block_page_width,
1511
+ block_preserve_scale
1512
+ } = block.format;
1513
+ if (block_full_width || block_page_width) {
1514
+ if (block_full_width) {
1515
+ style.width = "100vw";
1516
+ } else {
1517
+ style.width = "100%";
1518
+ }
1519
+ if (block.type === "video") {
1520
+ if (block_height) {
1521
+ style.height = block_height;
1522
+ } else if (block_aspect_ratio) {
1523
+ style.paddingBottom = `${block_aspect_ratio * 100}%`;
1524
+ } else if (block_preserve_scale) {
1525
+ style.objectFit = "contain";
1526
+ }
1527
+ } else if (block_aspect_ratio && block.type !== "image") {
1528
+ style.paddingBottom = `${block_aspect_ratio * 100}%`;
1529
+ } else if (block_height) {
1530
+ style.height = block_height;
1531
+ } else if (block_preserve_scale) {
1532
+ if (block.type === "image") {
1533
+ style.height = "100%";
1534
+ } else {
1535
+ style.paddingBottom = "75%";
1536
+ style.minHeight = 100;
1537
+ }
1538
+ }
1539
+ } else {
1540
+ switch ((_a = block.format) == null ? void 0 : _a.block_alignment) {
1541
+ case "center":
1542
+ style.alignSelf = "center";
1543
+ break;
1544
+ case "left":
1545
+ style.alignSelf = "start";
1546
+ break;
1547
+ case "right":
1548
+ style.alignSelf = "end";
1549
+ break;
1550
+ }
1551
+ if (block_width) {
1552
+ style.width = block_width;
1553
+ }
1554
+ if (block_preserve_scale && block.type !== "image") {
1555
+ style.paddingBottom = "50%";
1556
+ style.minHeight = 100;
1557
+ } else {
1558
+ if (block_height && block.type !== "image") {
1559
+ style.height = block_height;
1560
+ }
1561
+ }
1562
+ }
1563
+ if (block.type === "image") {
1564
+ assetStyle.objectFit = "cover";
1565
+ } else if (block_preserve_scale) {
1566
+ assetStyle.objectFit = "contain";
1567
+ }
1568
+ }
1569
+ let source = ((_b = recordMap.signed_urls) == null ? void 0 : _b[block.id]) || ((_e = (_d = (_c = block.properties) == null ? void 0 : _c.source) == null ? void 0 : _d[0]) == null ? void 0 : _e[0]);
1570
+ if (!source) {
1571
+ return null;
1572
+ }
1573
+ if (block.space_id) {
1574
+ const url = new URL(source);
1575
+ url.searchParams.set("spaceId", block.space_id);
1576
+ source = url.toString();
1577
+ }
1578
+ let content = null;
1579
+ if (block.type === "tweet") {
1580
+ const src = source;
1581
+ if (!src) return null;
1582
+ const id = (_g = (_f = src.split("?")) == null ? void 0 : _f[0]) == null ? void 0 : _g.split("/").pop();
1583
+ if (!id) return null;
1584
+ content = /* @__PURE__ */ jsx16(
1585
+ "div",
1586
+ {
1587
+ style: {
1588
+ ...assetStyle,
1589
+ maxWidth: 420,
1590
+ width: "100%",
1591
+ marginLeft: "auto",
1592
+ marginRight: "auto"
1593
+ },
1594
+ children: /* @__PURE__ */ jsx16(components.Tweet, { id })
1595
+ }
1596
+ );
1597
+ } else if (block.type === "pdf") {
1598
+ style.overflow = "auto";
1599
+ style.background = "rgb(226, 226, 226)";
1600
+ style.display = "block";
1601
+ if (!style.padding) {
1602
+ style.padding = "8px 16px";
1603
+ }
1604
+ if (!isServer) {
1605
+ content = /* @__PURE__ */ jsx16(components.Pdf, { file: source });
1606
+ }
1607
+ } else if (block.type === "embed" || block.type === "video" || block.type === "figma" || block.type === "typeform" || block.type === "gist" || block.type === "maps" || block.type === "excalidraw" || block.type === "codepen" || block.type === "drive" || block.type === "replit") {
1608
+ if (block.type === "video" && source && !source.includes("youtube") && !source.includes("youtu.be") && !source.includes("vimeo") && !source.includes("wistia") && !source.includes("loom") && !source.includes("videoask") && !source.includes("getcloudapp") && !source.includes("tella")) {
1609
+ style.paddingBottom = void 0;
1610
+ content = /* @__PURE__ */ jsx16(
1611
+ "video",
1612
+ {
1613
+ playsInline: true,
1614
+ controls: true,
1615
+ preload: "metadata",
1616
+ style: assetStyle,
1617
+ src: source,
1618
+ title: block.type
1619
+ }
1620
+ );
1621
+ } else {
1622
+ let src = ((_h = block.format) == null ? void 0 : _h.display_source) || source;
1623
+ if (src) {
1624
+ const youtubeVideoId = block.type === "video" ? getYoutubeId(src) : null;
1625
+ if (youtubeVideoId) {
1626
+ const params = getUrlParams(src);
1627
+ content = /* @__PURE__ */ jsx16(
1628
+ LiteYouTubeEmbed,
1629
+ {
1630
+ id: youtubeVideoId,
1631
+ style: assetStyle,
1632
+ className: "notion-asset-object-fit",
1633
+ params
1634
+ }
1635
+ );
1636
+ } else if (block.type === "gist") {
1637
+ if (!src.endsWith(".pibb")) {
1638
+ src = `${src}.pibb`;
1639
+ }
1640
+ assetStyle.width = "100%";
1641
+ style.paddingBottom = "50%";
1642
+ content = /* @__PURE__ */ jsx16(
1643
+ "iframe",
1644
+ {
1645
+ style: assetStyle,
1646
+ className: "notion-asset-object-fit",
1647
+ src,
1648
+ title: "GitHub Gist",
1649
+ frameBorder: "0",
1650
+ loading: "lazy",
1651
+ scrolling: "auto"
1652
+ }
1653
+ );
1654
+ } else {
1655
+ src += block.type === "typeform" ? "&disable-auto-focus=true" : "";
1656
+ content = /* @__PURE__ */ jsx16(
1657
+ "iframe",
1658
+ {
1659
+ className: "notion-asset-object-fit",
1660
+ style: assetStyle,
1661
+ src,
1662
+ title: `iframe ${block.type}`,
1663
+ frameBorder: "0",
1664
+ allowFullScreen: true,
1665
+ loading: "lazy",
1666
+ scrolling: "auto"
1667
+ }
1668
+ );
1669
+ }
1670
+ }
1671
+ }
1672
+ } else if (block.type === "image") {
1673
+ if (!source.includes(".gif") && source.includes("file.notion.so")) {
1674
+ source = (_k = (_j = (_i = block.properties) == null ? void 0 : _i.source) == null ? void 0 : _j[0]) == null ? void 0 : _k[0];
1675
+ }
1676
+ const src = mapImageUrl(source, block);
1677
+ const altText = getTextContent((_l = block.properties) == null ? void 0 : _l.alt_text);
1678
+ const caption = getTextContent((_m = block.properties) == null ? void 0 : _m.caption);
1679
+ const alt = altText || caption || "notion image";
1680
+ content = /* @__PURE__ */ jsx16(
1681
+ LazyImage,
1682
+ {
1683
+ src,
1684
+ alt,
1685
+ zoomable,
1686
+ height: style.height,
1687
+ style: assetStyle
1688
+ }
1689
+ );
1690
+ }
1691
+ return /* @__PURE__ */ jsxs9(Fragment4, { children: [
1692
+ /* @__PURE__ */ jsxs9("div", { style, children: [
1693
+ content,
1694
+ block.type === "image" && children
1695
+ ] }),
1696
+ block.type !== "image" && children
1697
+ ] });
1698
+ }
1699
+
1700
+ // src/components/asset-wrapper.tsx
1701
+ import { jsx as jsx17 } from "react/jsx-runtime";
1702
+ var urlStyle = { width: "100%" };
1703
+ function AssetWrapper({
1704
+ blockId,
1705
+ block
1706
+ }) {
1707
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1708
+ const value = block;
1709
+ const { components, mapPageUrl, rootDomain, zoom } = useNotionContext();
1710
+ let isURL = false;
1711
+ if (block.type === "image") {
1712
+ const caption = (_c = (_b = (_a = value == null ? void 0 : value.properties) == null ? void 0 : _a.caption) == null ? void 0 : _b[0]) == null ? void 0 : _c[0];
1713
+ if (caption) {
1714
+ const id = parsePageId(caption, { uuid: true });
1715
+ const isPage = caption.charAt(0) === "/" && id;
1716
+ if (isPage || isValidURL(caption)) {
1717
+ isURL = true;
1718
+ }
1719
+ }
1720
+ }
1721
+ const figure = /* @__PURE__ */ jsx17(
1722
+ "figure",
1723
+ {
1724
+ className: cs(
1725
+ "notion-asset-wrapper",
1726
+ `notion-asset-wrapper-${block.type}`,
1727
+ ((_d = value.format) == null ? void 0 : _d.block_full_width) && "notion-asset-wrapper-full",
1728
+ blockId
1729
+ ),
1730
+ children: /* @__PURE__ */ jsx17(Asset, { block: value, zoomable: zoom && !isURL, children: ((_e = value == null ? void 0 : value.properties) == null ? void 0 : _e.caption) && !isURL && /* @__PURE__ */ jsx17("figcaption", { className: "notion-asset-caption", children: /* @__PURE__ */ jsx17(Text, { value: value.properties.caption, block }) }) })
1731
+ }
1732
+ );
1733
+ if (isURL) {
1734
+ const caption = (_h = (_g = (_f = value == null ? void 0 : value.properties) == null ? void 0 : _f.caption) == null ? void 0 : _g[0]) == null ? void 0 : _h[0];
1735
+ const id = parsePageId(caption, { uuid: true });
1736
+ const isPage = (caption == null ? void 0 : caption.charAt(0)) === "/" && id;
1737
+ const captionHostname = extractHostname(caption);
1738
+ return /* @__PURE__ */ jsx17(
1739
+ components.PageLink,
1740
+ {
1741
+ style: urlStyle,
1742
+ href: isPage ? mapPageUrl(id) : caption,
1743
+ target: captionHostname && captionHostname !== rootDomain && !(caption == null ? void 0 : caption.startsWith("/")) ? "blank_" : null,
1744
+ children: figure
1745
+ }
1746
+ );
1747
+ }
1748
+ return figure;
1749
+ }
1750
+ function isValidURL(str) {
1751
+ const pattern = new RegExp(
1752
+ "^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$",
1753
+ "i"
1754
+ );
1755
+ return !!pattern.test(str);
1756
+ }
1757
+ function extractHostname(url) {
1758
+ try {
1759
+ const hostname = new URL(url).hostname;
1760
+ return hostname;
1761
+ } catch (e) {
1762
+ return "";
1763
+ }
1764
+ }
1765
+
1766
+ // src/icons/check.tsx
1767
+ import { jsx as jsx18 } from "react/jsx-runtime";
1768
+ function SvgCheck(props) {
1769
+ return /* @__PURE__ */ jsx18("svg", { viewBox: "0 0 14 14", ...props, children: /* @__PURE__ */ jsx18("path", { d: "M5.5 12L14 3.5 12.5 2l-7 7-4-4.003L0 6.499z" }) });
1770
+ }
1771
+ var check_default = SvgCheck;
1772
+
1773
+ // src/components/checkbox.tsx
1774
+ import { jsx as jsx19 } from "react/jsx-runtime";
1775
+ function Checkbox({
1776
+ isChecked
1777
+ }) {
1778
+ let content = null;
1779
+ if (isChecked) {
1780
+ content = /* @__PURE__ */ jsx19("div", { className: "notion-property-checkbox-checked", children: /* @__PURE__ */ jsx19(check_default, {}) });
1781
+ } else {
1782
+ content = /* @__PURE__ */ jsx19("div", { className: "notion-property-checkbox-unchecked" });
1783
+ }
1784
+ return /* @__PURE__ */ jsx19("span", { className: "notion-property notion-property-checkbox", children: content });
1785
+ }
1786
+
1787
+ // src/next.tsx
1788
+ import React12 from "react";
1789
+ import isEqual from "react-fast-compare";
1790
+ import { jsx as jsx20 } from "react/jsx-runtime";
1791
+ var wrapNextImage = (NextImage) => {
1792
+ return React12.memo(function ReactNotionXNextImage({
1793
+ src,
1794
+ alt,
1795
+ width,
1796
+ height,
1797
+ className,
1798
+ fill,
1799
+ ...rest
1800
+ }) {
1801
+ if (fill === "undefined") {
1802
+ fill = !(width && height);
1803
+ }
1804
+ return /* @__PURE__ */ jsx20(
1805
+ NextImage,
1806
+ {
1807
+ className,
1808
+ src,
1809
+ alt,
1810
+ width: !fill && width && height ? width : void 0,
1811
+ height: !fill && width && height ? height : void 0,
1812
+ fill,
1813
+ ...rest
1814
+ }
1815
+ );
1816
+ }, isEqual);
1817
+ };
1818
+ var wrapNextLegacyImage = (NextLegacyImage) => {
1819
+ return React12.memo(function ReactNotionXNextLegacyImage({
1820
+ src,
1821
+ alt,
1822
+ width,
1823
+ height,
1824
+ className,
1825
+ style,
1826
+ layout,
1827
+ ...rest
1828
+ }) {
1829
+ if (!layout) {
1830
+ layout = width && height ? "intrinsic" : "fill";
1831
+ }
1832
+ return /* @__PURE__ */ jsx20(
1833
+ NextLegacyImage,
1834
+ {
1835
+ className,
1836
+ src,
1837
+ alt,
1838
+ width: layout === "intrinsic" && width,
1839
+ height: layout === "intrinsic" && height,
1840
+ objectFit: style == null ? void 0 : style.objectFit,
1841
+ objectPosition: style == null ? void 0 : style.objectPosition,
1842
+ layout,
1843
+ ...rest
1844
+ }
1845
+ );
1846
+ }, isEqual);
1847
+ };
1848
+ function wrapNextLink(NextLink) {
1849
+ return ({
1850
+ href,
1851
+ as,
1852
+ passHref,
1853
+ prefetch,
1854
+ replace,
1855
+ scroll,
1856
+ shallow,
1857
+ locale,
1858
+ ...linkProps
1859
+ }) => {
1860
+ return /* @__PURE__ */ jsx20(
1861
+ NextLink,
1862
+ {
1863
+ href,
1864
+ as,
1865
+ passHref,
1866
+ prefetch,
1867
+ replace,
1868
+ scroll,
1869
+ shallow,
1870
+ locale,
1871
+ legacyBehavior: true,
1872
+ children: /* @__PURE__ */ jsx20("a", { ...linkProps })
1873
+ }
1874
+ );
1875
+ };
1876
+ }
1877
+
1878
+ // src/context.tsx
1879
+ import { jsx as jsx21 } from "react/jsx-runtime";
1880
+ function DefaultLink(props) {
1881
+ return /* @__PURE__ */ jsx21("a", { target: "_blank", rel: "noopener noreferrer", ...props });
1882
+ }
1883
+ var DefaultLinkMemo = React13.memo(DefaultLink);
1884
+ function DefaultPageLink(props) {
1885
+ return /* @__PURE__ */ jsx21("a", { ...props });
1886
+ }
1887
+ var DefaultPageLinkMemo = React13.memo(DefaultPageLink);
1888
+ function DefaultEmbed(props) {
1889
+ return /* @__PURE__ */ jsx21(AssetWrapper, { ...props });
1890
+ }
1891
+ var DefaultHeader = Header;
1892
+ var dummyComponent = (name) => () => {
1893
+ console.warn(
1894
+ `Warning: using empty component "${name}" (you should override this in NotionRenderer.components)`
1895
+ );
1896
+ return null;
1897
+ };
1898
+ var dummyOverrideFn = (_, defaultValueFn) => defaultValueFn();
1899
+ var defaultComponents = {
1900
+ Image: null,
1901
+ // disable custom images by default
1902
+ Link: DefaultLinkMemo,
1903
+ PageLink: DefaultPageLinkMemo,
1904
+ Checkbox,
1905
+ Callout: void 0,
1906
+ // use the built-in callout rendering by default
1907
+ Code: dummyComponent("Code"),
1908
+ Equation: dummyComponent("Equation"),
1909
+ Collection: dummyComponent("Collection"),
1910
+ Property: void 0,
1911
+ // use the built-in property rendering by default
1912
+ propertyTextValue: dummyOverrideFn,
1913
+ propertySelectValue: dummyOverrideFn,
1914
+ propertyRelationValue: dummyOverrideFn,
1915
+ propertyFormulaValue: dummyOverrideFn,
1916
+ propertyTitleValue: dummyOverrideFn,
1917
+ propertyPersonValue: dummyOverrideFn,
1918
+ propertyFileValue: dummyOverrideFn,
1919
+ propertyCheckboxValue: dummyOverrideFn,
1920
+ propertyUrlValue: dummyOverrideFn,
1921
+ propertyEmailValue: dummyOverrideFn,
1922
+ propertyPhoneNumberValue: dummyOverrideFn,
1923
+ propertyNumberValue: dummyOverrideFn,
1924
+ propertyLastEditedTimeValue: dummyOverrideFn,
1925
+ propertyCreatedTimeValue: dummyOverrideFn,
1926
+ propertyDateValue: dummyOverrideFn,
1927
+ propertyAutoIncrementIdValue: dummyOverrideFn,
1928
+ Pdf: dummyComponent("Pdf"),
1929
+ Tweet: dummyComponent("Tweet"),
1930
+ Modal: dummyComponent("Modal"),
1931
+ Header: DefaultHeader,
1932
+ Embed: DefaultEmbed
1933
+ };
1934
+ var defaultNotionContext = {
1935
+ recordMap: {
1936
+ block: {},
1937
+ collection: {},
1938
+ collection_view: {},
1939
+ collection_query: {},
1940
+ notion_user: {},
1941
+ signed_urls: {}
1942
+ },
1943
+ components: defaultComponents,
1944
+ mapPageUrl: defaultMapPageUrl(),
1945
+ mapImageUrl: defaultMapImageUrl,
1946
+ searchNotion: void 0,
1947
+ isShowingSearch: false,
1948
+ onHideSearch: void 0,
1949
+ fullPage: false,
1950
+ darkMode: false,
1951
+ previewImages: false,
1952
+ forceCustomImages: false,
1953
+ showCollectionViewDropdown: true,
1954
+ linkTableTitleProperties: true,
1955
+ isLinkCollectionToUrlProperty: false,
1956
+ showTableOfContents: false,
1957
+ minTableOfContentsItems: 3,
1958
+ defaultPageIcon: null,
1959
+ defaultPageCover: null,
1960
+ defaultPageCoverPosition: 0.5,
1961
+ zoom: null
1962
+ };
1963
+ var ctx = React13.createContext(defaultNotionContext);
1964
+ function NotionContextProvider({
1965
+ components: themeComponents = {},
1966
+ children,
1967
+ mapPageUrl,
1968
+ mapImageUrl,
1969
+ rootPageId,
1970
+ ...rest
1971
+ }) {
1972
+ for (const key of Object.keys(rest)) {
1973
+ if (rest[key] === void 0) {
1974
+ delete rest[key];
1975
+ }
1976
+ }
1977
+ const wrappedThemeComponents = React13.useMemo(
1978
+ () => ({
1979
+ ...themeComponents
1980
+ }),
1981
+ [themeComponents]
1982
+ );
1983
+ if (wrappedThemeComponents.nextImage && wrappedThemeComponents.nextLegacyImage) {
1984
+ console.warn(
1985
+ "You should not pass both nextImage and nextLegacyImage. Only nextImage component will be used."
1986
+ );
1987
+ wrappedThemeComponents.Image = wrapNextImage(themeComponents.nextImage);
1988
+ } else if (wrappedThemeComponents.nextImage) {
1989
+ wrappedThemeComponents.Image = wrapNextImage(themeComponents.nextImage);
1990
+ } else if (wrappedThemeComponents.nextLegacyImage) {
1991
+ wrappedThemeComponents.Image = wrapNextLegacyImage(
1992
+ themeComponents.nextLegacyImage
1993
+ );
1994
+ }
1995
+ if (wrappedThemeComponents.nextLink) {
1996
+ wrappedThemeComponents.nextLink = wrapNextLink(themeComponents.nextLink);
1997
+ }
1998
+ for (const key of Object.keys(wrappedThemeComponents)) {
1999
+ if (!wrappedThemeComponents[key]) {
2000
+ delete wrappedThemeComponents[key];
2001
+ }
2002
+ }
2003
+ const value = React13.useMemo(
2004
+ () => ({
2005
+ ...defaultNotionContext,
2006
+ ...rest,
2007
+ rootPageId,
2008
+ mapPageUrl: mapPageUrl != null ? mapPageUrl : defaultMapPageUrl(rootPageId),
2009
+ mapImageUrl: mapImageUrl != null ? mapImageUrl : defaultMapImageUrl,
2010
+ components: { ...defaultComponents, ...wrappedThemeComponents }
2011
+ }),
2012
+ [mapImageUrl, mapPageUrl, wrappedThemeComponents, rootPageId, rest]
2013
+ );
2014
+ return /* @__PURE__ */ jsx21(ctx.Provider, { value, children });
2015
+ }
2016
+ var NotionContextConsumer = ctx.Consumer;
2017
+ var useNotionContext = () => {
2018
+ return React13.useContext(ctx);
2019
+ };
2020
+
2021
+ // src/components/link-mention.tsx
2022
+ import "react";
2023
+ import { jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
2024
+ function LinkMention({ metadata }) {
2025
+ return /* @__PURE__ */ jsxs10("span", { className: "notion-link-mention", children: [
2026
+ /* @__PURE__ */ jsx22(LinkMentionInline, { metadata }),
2027
+ /* @__PURE__ */ jsx22(LinkMentionPreview, { metadata })
2028
+ ] });
2029
+ }
2030
+ function LinkMentionInline({ metadata }) {
2031
+ return /* @__PURE__ */ jsxs10(
2032
+ "a",
2033
+ {
2034
+ href: metadata.href,
2035
+ target: "_blank",
2036
+ rel: "noopener noreferrer",
2037
+ className: "notion-link-mention-link",
2038
+ children: [
2039
+ /* @__PURE__ */ jsx22(
2040
+ "img",
2041
+ {
2042
+ className: "notion-link-mention-icon",
2043
+ src: metadata.icon_url,
2044
+ alt: metadata.link_provider
2045
+ }
2046
+ ),
2047
+ metadata.link_provider && /* @__PURE__ */ jsx22("span", { className: "notion-link-mention-provider", children: metadata.link_provider }),
2048
+ /* @__PURE__ */ jsx22("span", { className: "notion-link-mention-title", children: metadata.title })
2049
+ ]
2050
+ }
2051
+ );
2052
+ }
2053
+ function LinkMentionPreview({ metadata }) {
2054
+ return /* @__PURE__ */ jsx22("div", { className: "notion-link-mention-preview", children: /* @__PURE__ */ jsxs10("article", { className: "notion-link-mention-card", children: [
2055
+ /* @__PURE__ */ jsx22(
2056
+ "img",
2057
+ {
2058
+ className: "notion-link-mention-preview-thumbnail",
2059
+ src: metadata.thumbnail_url,
2060
+ alt: metadata.title,
2061
+ referrerPolicy: "same-origin"
2062
+ }
2063
+ ),
2064
+ /* @__PURE__ */ jsxs10("div", { className: "notion-link-mention-preview-content", children: [
2065
+ /* @__PURE__ */ jsx22("p", { className: "notion-link-mention-preview-title", children: metadata.title }),
2066
+ /* @__PURE__ */ jsx22("p", { className: "notion-link-mention-preview-description", children: metadata.description }),
2067
+ /* @__PURE__ */ jsxs10("div", { className: "notion-link-mention-preview-footer", children: [
2068
+ /* @__PURE__ */ jsx22(
2069
+ "img",
2070
+ {
2071
+ className: "notion-link-mention-preview-icon",
2072
+ src: metadata.icon_url,
2073
+ alt: metadata.link_provider,
2074
+ referrerPolicy: "same-origin"
2075
+ }
2076
+ ),
2077
+ /* @__PURE__ */ jsx22("span", { className: "notion-link-mention-preview-provider", children: metadata.link_provider })
2078
+ ] })
2079
+ ] })
2080
+ ] }) });
2081
+ }
2082
+
2083
+ // src/components/text.tsx
2084
+ import { Fragment as Fragment5, jsx as jsx23 } from "react/jsx-runtime";
2085
+ function Text({
2086
+ value,
2087
+ block,
2088
+ linkProps,
2089
+ linkProtocol
2090
+ }) {
2091
+ const { components, recordMap, mapPageUrl, mapImageUrl, rootDomain } = useNotionContext();
2092
+ return /* @__PURE__ */ jsx23(React15.Fragment, { children: value == null ? void 0 : value.map(([text, decorations], index) => {
2093
+ if (!decorations) {
2094
+ if (text === ",") {
2095
+ return /* @__PURE__ */ jsx23("span", { style: { padding: "0.5em" } }, index);
2096
+ } else {
2097
+ return /* @__PURE__ */ jsx23(React15.Fragment, { children: text }, index);
2098
+ }
2099
+ }
2100
+ const formatted = decorations.reduce(
2101
+ (element, decorator) => {
2102
+ var _a, _b, _c, _d, _e;
2103
+ switch (decorator[0]) {
2104
+ case "p": {
2105
+ const blockId = decorator[1];
2106
+ const linkedBlock = (_a = recordMap.block[blockId]) == null ? void 0 : _a.value;
2107
+ if (!linkedBlock) {
2108
+ console.log('"p" missing block', blockId);
2109
+ return null;
2110
+ }
2111
+ return /* @__PURE__ */ jsx23(
2112
+ components.PageLink,
2113
+ {
2114
+ className: "notion-link",
2115
+ href: mapPageUrl(blockId),
2116
+ children: /* @__PURE__ */ jsx23(PageTitle, { block: linkedBlock })
2117
+ }
2118
+ );
2119
+ }
2120
+ case "\u2023": {
2121
+ const linkType = decorator[1][0];
2122
+ const id = decorator[1][1];
2123
+ switch (linkType) {
2124
+ case "u": {
2125
+ const user = (_b = recordMap.notion_user[id]) == null ? void 0 : _b.value;
2126
+ if (!user) {
2127
+ console.log('"\u2023" missing user', id);
2128
+ return null;
2129
+ }
2130
+ const src = mapImageUrl(user.profile_photo, block);
2131
+ if (!src) return null;
2132
+ const name = [user.given_name, user.family_name].filter(Boolean).join(" ");
2133
+ return /* @__PURE__ */ jsx23(
2134
+ GracefulImage,
2135
+ {
2136
+ className: "notion-user",
2137
+ src,
2138
+ alt: name
2139
+ }
2140
+ );
2141
+ }
2142
+ default: {
2143
+ const linkedBlock = (_c = recordMap.block[id]) == null ? void 0 : _c.value;
2144
+ if (!linkedBlock) {
2145
+ console.log('"\u2023" missing block', linkType, id);
2146
+ return null;
2147
+ }
2148
+ return /* @__PURE__ */ jsx23(
2149
+ components.PageLink,
2150
+ {
2151
+ className: "notion-link",
2152
+ href: mapPageUrl(id),
2153
+ ...linkProps,
2154
+ target: "_blank",
2155
+ rel: "noopener noreferrer",
2156
+ children: /* @__PURE__ */ jsx23(PageTitle, { block: linkedBlock })
2157
+ }
2158
+ );
2159
+ }
2160
+ }
2161
+ }
2162
+ case "h":
2163
+ return /* @__PURE__ */ jsx23("span", { className: `notion-${decorator[1]}`, children: element });
2164
+ case "c":
2165
+ return /* @__PURE__ */ jsx23("code", { className: "notion-inline-code", children: element });
2166
+ case "b":
2167
+ return /* @__PURE__ */ jsx23("b", { children: element });
2168
+ case "i":
2169
+ return /* @__PURE__ */ jsx23("em", { children: element });
2170
+ case "s":
2171
+ return /* @__PURE__ */ jsx23("s", { children: element });
2172
+ case "_":
2173
+ return /* @__PURE__ */ jsx23("span", { className: "notion-inline-underscore", children: element });
2174
+ case "e":
2175
+ return /* @__PURE__ */ jsx23(components.Equation, { math: decorator[1], inline: true });
2176
+ case "m":
2177
+ return element;
2178
+ //still need to return the base element
2179
+ case "a": {
2180
+ const v = decorator[1];
2181
+ const pathname = v.slice(1);
2182
+ const id = parsePageId2(pathname, { uuid: true });
2183
+ if (rootDomain && v.includes(rootDomain) || id && v[0] === "/") {
2184
+ const href = rootDomain && v.includes(rootDomain) ? v : `${mapPageUrl(id)}${getHashFragmentValue(v)}`;
2185
+ return /* @__PURE__ */ jsx23(
2186
+ components.PageLink,
2187
+ {
2188
+ className: "notion-link",
2189
+ href,
2190
+ ...linkProps,
2191
+ children: element
2192
+ }
2193
+ );
2194
+ } else {
2195
+ return /* @__PURE__ */ jsx23(
2196
+ components.Link,
2197
+ {
2198
+ className: "notion-link",
2199
+ href: linkProtocol ? `${linkProtocol}:${decorator[1]}` : decorator[1],
2200
+ ...linkProps,
2201
+ children: element
2202
+ }
2203
+ );
2204
+ }
2205
+ }
2206
+ case "d": {
2207
+ const v = decorator[1];
2208
+ const type = v == null ? void 0 : v.type;
2209
+ if (type === "date") {
2210
+ const startDate = v.start_date;
2211
+ return formatDate(startDate);
2212
+ } else if (type === "datetime") {
2213
+ const startDate = v.start_date;
2214
+ const startTime = v.start_time;
2215
+ return `${formatDate(startDate)} ${startTime}`;
2216
+ } else if (type === "daterange") {
2217
+ const startDate = v.start_date;
2218
+ const endDate = v.end_date;
2219
+ return `${formatDate(startDate)} \u2192 ${formatDate(endDate)}`;
2220
+ } else {
2221
+ return element;
2222
+ }
2223
+ }
2224
+ case "u": {
2225
+ const userId = decorator[1];
2226
+ const user = (_d = recordMap.notion_user[userId]) == null ? void 0 : _d.value;
2227
+ if (!user) {
2228
+ console.log("missing user", userId);
2229
+ return null;
2230
+ }
2231
+ const src = mapImageUrl(user.profile_photo, block);
2232
+ if (!src) return null;
2233
+ const name = [user.given_name, user.family_name].filter(Boolean).join(" ");
2234
+ return /* @__PURE__ */ jsx23(GracefulImage, { className: "notion-user", src, alt: name });
2235
+ }
2236
+ case "lm": {
2237
+ const metadata = decorator[1];
2238
+ return /* @__PURE__ */ jsx23(LinkMention, { metadata });
2239
+ }
2240
+ case "eoi": {
2241
+ const blockId = decorator[1];
2242
+ const externalObjectInstance = (_e = recordMap.block[blockId]) == null ? void 0 : _e.value;
2243
+ return /* @__PURE__ */ jsx23(EOI, { block: externalObjectInstance, inline: true });
2244
+ }
2245
+ case "si":
2246
+ return null;
2247
+ default:
2248
+ if (true) {
2249
+ console.log("unsupported text format", decorator);
2250
+ }
2251
+ return element;
2252
+ }
2253
+ },
2254
+ /* @__PURE__ */ jsx23(Fragment5, { children: text })
2255
+ );
2256
+ return /* @__PURE__ */ jsx23(React15.Fragment, { children: formatted }, index);
2257
+ }) });
2258
+ }
2259
+
2260
+ // src/icons/copy.tsx
2261
+ import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
2262
+ function SvgCopy(props) {
2263
+ return /* @__PURE__ */ jsxs11(
2264
+ "svg",
2265
+ {
2266
+ fill: "currentColor",
2267
+ viewBox: "0 0 16 16",
2268
+ width: "1em",
2269
+ version: "1.1",
2270
+ ...props,
2271
+ children: [
2272
+ /* @__PURE__ */ jsx24(
2273
+ "path",
2274
+ {
2275
+ fillRule: "evenodd",
2276
+ d: "M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"
2277
+ }
2278
+ ),
2279
+ /* @__PURE__ */ jsx24(
2280
+ "path",
2281
+ {
2282
+ fillRule: "evenodd",
2283
+ d: "M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"
2284
+ }
2285
+ )
2286
+ ]
2287
+ }
2288
+ );
2289
+ }
2290
+ var copy_default = SvgCopy;
2291
+
2292
+ // src/third-party/code.tsx
2293
+ import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
2294
+ function Code({
2295
+ block,
2296
+ defaultLanguage = "typescript",
2297
+ className
2298
+ }) {
2299
+ const [isCopied, setIsCopied] = React16.useState(false);
2300
+ const copyTimeout = React16.useRef(void 0);
2301
+ const { recordMap } = useNotionContext();
2302
+ const content = getBlockTitle4(block, recordMap);
2303
+ const language = (() => {
2304
+ var _a, _b, _c;
2305
+ const languageNotion = (((_c = (_b = (_a = block.properties) == null ? void 0 : _a.language) == null ? void 0 : _b[0]) == null ? void 0 : _c[0]) || defaultLanguage).toLowerCase();
2306
+ switch (languageNotion) {
2307
+ case "c++":
2308
+ return "cpp";
2309
+ case "f#":
2310
+ return "fsharp";
2311
+ default:
2312
+ return languageNotion;
2313
+ }
2314
+ })();
2315
+ const caption = block.properties.caption;
2316
+ const codeRef = React16.useRef(null);
2317
+ React16.useEffect(() => {
2318
+ if (codeRef.current) {
2319
+ try {
2320
+ prism.highlightElement(codeRef.current);
2321
+ } catch (err) {
2322
+ console.warn("prismjs highlight error", err);
2323
+ }
2324
+ }
2325
+ }, [codeRef]);
2326
+ const onClickCopyToClipboard = React16.useCallback(() => {
2327
+ void (0, import_clipboard_copy.default)(content);
2328
+ setIsCopied(true);
2329
+ if (copyTimeout.current) {
2330
+ clearTimeout(copyTimeout.current);
2331
+ copyTimeout.current = void 0;
2332
+ }
2333
+ copyTimeout.current = setTimeout(() => {
2334
+ setIsCopied(false);
2335
+ }, 1200);
2336
+ }, [content, copyTimeout]);
2337
+ const copyButton = /* @__PURE__ */ jsx25("div", { className: "notion-code-copy-button", onClick: onClickCopyToClipboard, children: /* @__PURE__ */ jsx25(copy_default, {}) });
2338
+ return /* @__PURE__ */ jsxs12(Fragment6, { children: [
2339
+ /* @__PURE__ */ jsxs12(
2340
+ "pre",
2341
+ {
2342
+ className: cs("notion-code", `language-${language}`, className),
2343
+ tabIndex: 0,
2344
+ children: [
2345
+ /* @__PURE__ */ jsxs12("div", { className: "notion-code-copy", children: [
2346
+ copyButton,
2347
+ isCopied && /* @__PURE__ */ jsx25("div", { className: "notion-code-copy-tooltip", children: /* @__PURE__ */ jsx25("div", { children: isCopied ? "Copied" : "Copy" }) })
2348
+ ] }),
2349
+ /* @__PURE__ */ jsx25("code", { className: `language-${language}`, ref: codeRef, children: content })
2350
+ ]
2351
+ }
2352
+ ),
2353
+ caption && /* @__PURE__ */ jsx25("figcaption", { className: "notion-asset-caption", children: /* @__PURE__ */ jsx25(Text, { value: caption, block }) })
2354
+ ] });
2355
+ }
2356
+ export {
2357
+ Code
2358
+ };
2359
+ /*! Bundled license information:
2360
+
2361
+ clipboard-copy/index.js:
2362
+ (*! clipboard-copy. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
2363
+ */
2364
+ //# sourceMappingURL=code.js.map