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