@getv.design/embed 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -17
- package/THIRD_PARTY_NOTICES.txt +1 -1
- package/dist/auto.d.ts +24 -0
- package/dist/auto.js +2 -0
- package/dist/chunks/chunk-62FKKJ5M.js +4 -0
- package/dist/chunks/{chunk-FGXZYG3Y.js → chunk-BESL4IJP.js} +1 -1
- package/dist/chunks/chunk-DSFLLPRE.js +6 -0
- package/dist/chunks/chunk-OMODSFXU.js +10 -0
- package/dist/chunks/chunk-R6OULTHF.js +3 -0
- package/dist/chunks/chunk-T6H6KLK6.js +2 -0
- package/dist/chunks/fonts.js +4 -4
- package/dist/cli.js +29 -0
- package/dist/edit.js +38 -31
- package/dist/index.js +2 -2
- package/dist/markdown-it.d.ts +16 -0
- package/dist/markdown-it.js +2 -0
- package/dist/markdown.d.ts +19 -0
- package/dist/markdown.js +2 -0
- package/dist/marked.d.ts +14 -0
- package/dist/marked.js +2 -0
- package/dist/rehype.d.ts +19 -0
- package/dist/rehype.js +2 -0
- package/dist/static.d.ts +29 -2
- package/dist/static.js +2 -2
- package/dist/types.d.ts +127 -0
- package/dist/view.js +8 -7
- package/fonts.css +127 -0
- package/markdown.css +72 -0
- package/package.json +30 -2
- package/view.css +5 -4
- package/dist/chunks/chunk-3XUNDFDN.js +0 -2
- package/dist/chunks/chunk-ETXF3NVH.js +0 -2
- package/dist/chunks/chunk-KODHLOJV.js +0 -8
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{a as y}from"./chunks/chunk-
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as y}from"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";var d=["view","edit","play"];async function l(a,i,e){let o=e?.mode;if(!d.includes(o))throw new TypeError(`mount: mode must be one of ${d.join(", ")}; got ${String(o)}.`);if(o==="edit"){let{edit:t}=await import("./edit.js");return t(a,i,e)}let{view:s}=await import("./view.js"),n=await s(a,i,e);if(o==="view")return n;let r;try{r=await n.play(e.page===void 0?{}:{page:e.page})}catch(t){throw n.destroy(),t}return{goTo:t=>r.goTo(t),destroy(){r.destroy(),n.destroy()}}}export{l as mount,y as version};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MarkdownItOptions } from './types.js';
|
|
2
|
+
export type { FenceOptions, FenceRenderOptions, MarkdownItOptions, Problem, Renderer, } from './types.js';
|
|
3
|
+
export { createRenderer } from './static.js';
|
|
4
|
+
/**
|
|
5
|
+
* The slice of markdown-it this plugin touches, typed loosely on purpose: any
|
|
6
|
+
* markdown-it instance, whatever its version and whichever `@types` describe
|
|
7
|
+
* it, is accepted by `md.use(vdesignMarkdownIt)`.
|
|
8
|
+
*/
|
|
9
|
+
interface MarkdownItLike {
|
|
10
|
+
renderer: {
|
|
11
|
+
rules: object;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** `md.use(vdesignMarkdownIt, options)`. */
|
|
15
|
+
export declare function vdesignMarkdownIt(md: MarkdownItLike, options?: MarkdownItOptions): void;
|
|
16
|
+
export default vdesignMarkdownIt;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as f,b as p,d as u}from"./chunks/chunk-62FKKJ5M.js";import{e as F}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";function I(l,t={}){let o=l.renderer.rules,s=o.fence,i=new WeakMap;o.fence=(n,c,k,d,g)=>{let e=n[c];if(!e||!p(e.info))return s?s(n,c,k,d,g):"";let r=t.idPrefix;r||(r=i.get(n)??f(),i.set(n,r));let{resolveSrc:a,...w}=t;return u(e.content,e.info,{...w,idPrefix:r,...e.attrs?{attributes:e.attrs}:{},...a?{resolveSrc:m=>a(m,d)}:{}})}}var b=I;export{F as createRenderer,b as default,I as vdesignMarkdownIt};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FenceOptions, FenceRenderOptions } from './types.js';
|
|
2
|
+
export type { FenceOptions, FenceRenderOptions, Problem, Renderer } from './types.js';
|
|
3
|
+
export { createRenderer } from './static.js';
|
|
4
|
+
/** Ids for one page of HTML: each fence on it gets its own prefix. */
|
|
5
|
+
export declare function createFenceIds(prefix?: string): () => string;
|
|
6
|
+
/** The language a fence must name. `vdesign` is accepted too, for hosts that know `vd` as something else. */
|
|
7
|
+
export declare function isVdFence(info: string | undefined | null): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The attributes after the language: `key=value`, `key="quoted value"`, or a
|
|
10
|
+
* bare `key` for a flag. Unknown keys are ignored, so adding one later breaks
|
|
11
|
+
* no fence written today.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseInfo(info: string): FenceOptions;
|
|
14
|
+
/**
|
|
15
|
+
* A fence to HTML. `info` is the whole info string (`vd page=1`) or options
|
|
16
|
+
* already parsed. Never throws: a fence that cannot be drawn comes back as
|
|
17
|
+
* its code block, with what was wrong.
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderFence(body: string, info: string | FenceOptions, options?: FenceRenderOptions): string;
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as b,b as c,c as d,d as e}from"./chunks/chunk-62FKKJ5M.js";import{e as a}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";export{b as createFenceIds,a as createRenderer,c as isVdFence,d as parseInfo,e as renderFence};
|
package/dist/marked.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FenceRenderOptions } from './types.js';
|
|
2
|
+
export type { FenceOptions, FenceRenderOptions, Problem, Renderer } from './types.js';
|
|
3
|
+
export { createRenderer } from './static.js';
|
|
4
|
+
interface CodeToken {
|
|
5
|
+
text: string;
|
|
6
|
+
lang?: string;
|
|
7
|
+
}
|
|
8
|
+
/** A marked extension. Returning `false` hands the block back to marked's own renderer. */
|
|
9
|
+
export declare function vdesignMarked(options?: FenceRenderOptions): {
|
|
10
|
+
renderer: {
|
|
11
|
+
code(this: unknown, token: CodeToken | string, info?: string): string | false;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default vdesignMarked;
|
package/dist/marked.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as t,b as i,d as o}from"./chunks/chunk-62FKKJ5M.js";import{e as f}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";function p(r={}){let s=r.idPrefix??t();return{renderer:{code(e,d){let c=typeof e=="string"?e:e.text,n=typeof e=="string"?d:e.lang;return i(n)?o(c,n??"vd",{...r,idPrefix:s}):!1}}}}var a=p;export{f as createRenderer,a as default,p as vdesignMarked};
|
package/dist/rehype.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RehypeOptions } from './types.js';
|
|
2
|
+
export type { FenceOptions, FenceRenderOptions, Problem, RehypeOptions, Renderer, } from './types.js';
|
|
3
|
+
interface HastNode {
|
|
4
|
+
type: string;
|
|
5
|
+
tagName?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
properties?: Record<string, unknown>;
|
|
8
|
+
data?: {
|
|
9
|
+
meta?: unknown;
|
|
10
|
+
};
|
|
11
|
+
children?: HastNode[];
|
|
12
|
+
}
|
|
13
|
+
interface VFileLike {
|
|
14
|
+
path?: string;
|
|
15
|
+
history?: string[];
|
|
16
|
+
}
|
|
17
|
+
/** `.use(rehypeVdesign, options)`. */
|
|
18
|
+
export declare function rehypeVdesign(options?: RehypeOptions): (tree: HastNode, file?: VFileLike) => Promise<void>;
|
|
19
|
+
export default rehypeVdesign;
|
package/dist/rehype.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as h,d as m}from"./chunks/chunk-62FKKJ5M.js";import{e as g}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";function x(e={}){let n,i=()=>e.renderer?Promise.resolve(e.renderer):n??=g({fonts:e.fonts??"exact",...e.fontBase===void 0?{}:{fontBase:e.fontBase}});return async(t,r)=>{let s=r?.path??r?.history?.at(-1);if(e.include&&!e.include(s))return;let o=[];if(v(t,(d,l,a)=>{if(d.type!=="element"||d.tagName!=="pre"||!l)return;let c=d.children?.find(p=>p.type==="element");c?.tagName!=="code"||!F(c)||o.push({parent:l,index:a,code:c})}),o.length===0)return;let u=await i(),f={...e};for(let d of["resolveSrc","fonts","fontBase","include"])delete f[d];let N=e.idPrefix??h(),R=e.resolveSrc??k;for(let{parent:d,index:l,code:a}of o){let c=typeof a.data?.meta=="string"?a.data.meta:"",p=m(y(a),`vd ${c}`,{...f,renderer:u,idPrefix:N,resolveSrc:H=>R(H,s)});d.children[l]={type:"raw",value:p}}}}var B=x;function F(e){let n=e.properties?.className;return(Array.isArray(n)?n:typeof n=="string"?n.split(/\s+/):[]).some(t=>t==="language-vd"||t==="language-vdesign")}function y(e){return e.type==="text"?e.value??"":(e.children??[]).map(y).join("")}function v(e,n,i,t=0){n(e,i,t),e.children?.forEach((r,s)=>v(r,n,e,s))}function k(e,n){let i=globalThis,t=i.process?.getBuiltinModule?.("node:fs"),r=i.process?.getBuiltinModule?.("node:path"),s=i.process?.cwd?.();if(!t||!r||s===void 0||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.includes("\\")||!/\.vd(\.svg)?$/i.test(e))return;let o=n===void 0?s:r.dirname(r.resolve(s,n));try{let u=t.realpathSync(r.resolve(o,e)),f=t.realpathSync(s);return u.startsWith(f+r.sep)?t.readFileSync(u,"utf8"):void 0}catch{return}}export{B as default,x as rehypeVdesign};
|
package/dist/static.d.ts
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
import type { ParseResult, RenderSvgOptions, Source } from './types.js';
|
|
2
|
-
export type { ParseResult, Problem, RenderSvgOptions, Source, VdDocument } from './types.js';
|
|
1
|
+
import type { Outline, ParseResult, Renderer, RendererOptions, RenderSvgOptions, Source } from './types.js';
|
|
2
|
+
export type { Outline, OutlinePage, ParseResult, Problem, Renderer, RendererOptions, RendererRenderOptions, RenderSvgOptions, Source, VdDocument, } from './types.js';
|
|
3
3
|
export { version } from './version.js';
|
|
4
4
|
/** Read `.vd` text. Never throws: what is wrong comes back as `problems`. */
|
|
5
5
|
export declare function parse(text: string): ParseResult;
|
|
6
6
|
/** Draw a document, or one of its pages, as a standalone SVG. */
|
|
7
7
|
export declare function renderSvg(source: Source, options?: RenderSvgOptions): Promise<string>;
|
|
8
|
+
/**
|
|
9
|
+
* The `.vd` text in `text`: itself for a `.vd`, the design it carries for a
|
|
10
|
+
* `.vd.svg`, `undefined` for an SVG that carries none. For copying a design
|
|
11
|
+
* out of an SVG as text.
|
|
12
|
+
*/
|
|
13
|
+
export declare function designOf(text: string): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* A document's title and pages, each with the line its `frame` is written on:
|
|
16
|
+
* what an editor needs for an outline, breadcrumbs, and keeping a preview on
|
|
17
|
+
* the page the cursor is in. Never throws.
|
|
18
|
+
*
|
|
19
|
+
* The line is found by reading the text for the page's top-level `frame`
|
|
20
|
+
* line, never by evaluating anything, so it is as cheap as parsing.
|
|
21
|
+
*/
|
|
22
|
+
export declare function outline(text: string): Outline;
|
|
23
|
+
/**
|
|
24
|
+
* A renderer that draws synchronously once it exists. Exact fonts are fetched
|
|
25
|
+
* here, all of them, because which ones a later document needs is not known
|
|
26
|
+
* yet and the render cannot wait to find out.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createRenderer(options?: RendererOptions): Promise<Renderer>;
|
|
29
|
+
/**
|
|
30
|
+
* The renderer with no font files, made synchronously: what the Markdown
|
|
31
|
+
* adapters use when a host does not hand them one, because a markdown-it
|
|
32
|
+
* plugin is installed in a synchronous call.
|
|
33
|
+
*/
|
|
34
|
+
export declare function approximateRenderer(): Renderer;
|
package/dist/static.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{a as
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g}from"./chunks/chunk-R6OULTHF.js";import"./chunks/chunk-DSFLLPRE.js";import"./chunks/chunk-OMODSFXU.js";import{a}from"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";export{g as approximateRenderer,f as createRenderer,d as designOf,e as outline,b as parse,c as renderSvg,a as version};
|
package/dist/types.d.ts
CHANGED
|
@@ -59,6 +59,57 @@ export interface RenderSvgOptions {
|
|
|
59
59
|
* load. Empty when nothing is.
|
|
60
60
|
*/
|
|
61
61
|
onProblems?: (problems: Problem[]) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Put in front of every id the SVG defines for itself (clips, shadows,
|
|
64
|
+
* gradients) and of every reference to one. Two SVGs inline in one page
|
|
65
|
+
* otherwise share those names, and the second one's shapes clip to the
|
|
66
|
+
* first one's rectangles. The `/markdown` entries give each fence its own.
|
|
67
|
+
*/
|
|
68
|
+
idPrefix?: string;
|
|
69
|
+
}
|
|
70
|
+
/** A page in `outline()`: what `view()` calls a page, and where it starts in the text. */
|
|
71
|
+
export interface OutlinePage {
|
|
72
|
+
id: string;
|
|
73
|
+
name?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The 1-based line of the page's `frame` line in the text given, which for
|
|
76
|
+
* a `.vd.svg` counts the SVG's own lines. Undefined only if the frame could
|
|
77
|
+
* not be found, which a document `parse` accepted does not do.
|
|
78
|
+
*/
|
|
79
|
+
line?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface Outline {
|
|
82
|
+
title?: string;
|
|
83
|
+
/** In play order: top-level frames that are not hidden. */
|
|
84
|
+
pages: OutlinePage[];
|
|
85
|
+
problems: Problem[];
|
|
86
|
+
}
|
|
87
|
+
export interface RendererOptions {
|
|
88
|
+
/**
|
|
89
|
+
* `'approximate'` (the default) needs no font files. `'exact'` fetches every
|
|
90
|
+
* bundled face once, before `createRenderer` resolves, so each later render
|
|
91
|
+
* can lay text out from them without waiting. That is all 18 faces, about
|
|
92
|
+
* 2.6 MB: meant for a build step or an editor's preview, not a web page.
|
|
93
|
+
*/
|
|
94
|
+
fonts?: 'exact' | 'approximate';
|
|
95
|
+
/** As for `renderSvg`. */
|
|
96
|
+
fontBase?: string | URL;
|
|
97
|
+
}
|
|
98
|
+
export interface RendererRenderOptions {
|
|
99
|
+
page?: string | number;
|
|
100
|
+
idPrefix?: string;
|
|
101
|
+
onProblems?: (problems: Problem[]) => void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Renders synchronously, for a caller that cannot wait: a markdown-it rule
|
|
105
|
+
* returns a string. Under `fonts: 'exact'` a document that needs a face that
|
|
106
|
+
* did not load draws approximately and `onProblems` hears `fonts-unavailable`.
|
|
107
|
+
*/
|
|
108
|
+
export interface Renderer {
|
|
109
|
+
/** `.vd` or `.vd.svg` text, or a parsed document, to an SVG string. Throws a `RangeError` for a missing page. */
|
|
110
|
+
renderSvg(source: string | VdDocument, options?: RendererRenderOptions): string;
|
|
111
|
+
/** What `createRenderer` was asked for, and what it got: `'approximate'` if the faces would not load. */
|
|
112
|
+
readonly fonts: 'exact' | 'approximate';
|
|
62
113
|
}
|
|
63
114
|
export interface ViewOptions {
|
|
64
115
|
/**
|
|
@@ -220,4 +271,80 @@ export type MountMode = 'view' | 'edit' | 'play';
|
|
|
220
271
|
export type MountOptions = {
|
|
221
272
|
mode: MountMode;
|
|
222
273
|
} & EditOptions;
|
|
274
|
+
/** What a fence's info string asks for: ` ```vd page=pricing mode=view source `. */
|
|
275
|
+
export interface FenceOptions {
|
|
276
|
+
/** One page, by id or 0-based index (a number written as digits). Default: the whole document. */
|
|
277
|
+
page?: string | number;
|
|
278
|
+
/** A file to draw instead of the body, resolved by `resolveSrc`. */
|
|
279
|
+
src?: string;
|
|
280
|
+
/** The live view's height in CSS pixels. Default: the drawing's own aspect ratio. */
|
|
281
|
+
height?: number;
|
|
282
|
+
/** `'view'` hydrates into a live view; `'static'` stays an SVG. Default: the adapter's `mode`. */
|
|
283
|
+
mode?: 'static' | 'view';
|
|
284
|
+
/** Also show the `.vd` text, folded, under the drawing. */
|
|
285
|
+
source?: boolean;
|
|
286
|
+
/** The drawing's accessible name. Default: the document's title. */
|
|
287
|
+
alt?: string;
|
|
288
|
+
}
|
|
289
|
+
export interface FenceRenderOptions {
|
|
290
|
+
/** Default: a renderer with no font files (`approximateRenderer()`). `createRenderer` makes an exact one. */
|
|
291
|
+
renderer?: Renderer;
|
|
292
|
+
/** Read a fence's `src=`. Without it, or when it returns `undefined`, the fence shows a problem. */
|
|
293
|
+
resolveSrc?: (src: string) => string | undefined;
|
|
294
|
+
/** For fences that do not say. Default `'static'`. */
|
|
295
|
+
mode?: 'static' | 'view';
|
|
296
|
+
/**
|
|
297
|
+
* `'inline'` (the default) puts the SVG in the page: its text can be selected
|
|
298
|
+
* and searched. `'img'` wraps it in `<img src="data:…">`: isolated from the
|
|
299
|
+
* page's CSS, and what a mail client or a CMS that strips `<svg>` accepts.
|
|
300
|
+
*/
|
|
301
|
+
output?: 'inline' | 'img';
|
|
302
|
+
/**
|
|
303
|
+
* `false` for a page whose content security policy refuses `style=""`. A
|
|
304
|
+
* drawing that needs one (a blend mode) is then wrapped as an `<img>`,
|
|
305
|
+
* which the policy does not reach into. Default `true`.
|
|
306
|
+
*/
|
|
307
|
+
inlineStyles?: boolean;
|
|
308
|
+
/** The most text and nodes one fence may hold. Past either it stays a code block. */
|
|
309
|
+
limits?: {
|
|
310
|
+
bytes?: number;
|
|
311
|
+
nodes?: number;
|
|
312
|
+
};
|
|
313
|
+
/** A fresh prefix for each drawing's ids. Default: `vd1-`, `vd2-`, … per call of `createFenceIds`. */
|
|
314
|
+
idPrefix?: () => string;
|
|
315
|
+
/**
|
|
316
|
+
* Extra attributes for the `<figure>`, as the host's own code block would
|
|
317
|
+
* have carried them: VS Code's preview marks blocks `class="code-line"
|
|
318
|
+
* data-line="12"` to keep its scroll in step with the editor.
|
|
319
|
+
*/
|
|
320
|
+
attributes?: readonly (readonly [string, string])[];
|
|
321
|
+
}
|
|
322
|
+
export interface MarkdownItOptions extends Omit<FenceRenderOptions, 'resolveSrc'> {
|
|
323
|
+
/** Read a fence's `src=`. `env` is what the host passed to `md.render(text, env)`. */
|
|
324
|
+
resolveSrc?: (src: string, env: unknown) => string | undefined;
|
|
325
|
+
}
|
|
326
|
+
export interface RehypeOptions extends Omit<FenceRenderOptions, 'resolveSrc' | 'renderer'> {
|
|
327
|
+
/** Default `'exact'`. Ignored when `renderer` is given. */
|
|
328
|
+
fonts?: RendererOptions['fonts'];
|
|
329
|
+
fontBase?: RendererOptions['fontBase'];
|
|
330
|
+
renderer?: Renderer;
|
|
331
|
+
/**
|
|
332
|
+
* Read a fence's `src=`. `path` is the Markdown file's own path when the
|
|
333
|
+
* pipeline knows it. Default, in Node: the file, relative to the Markdown.
|
|
334
|
+
*/
|
|
335
|
+
resolveSrc?: (src: string, path: string | undefined) => string | undefined;
|
|
336
|
+
/**
|
|
337
|
+
* Which Markdown files to draw fences in, by path. Default: all of them. For
|
|
338
|
+
* a site whose reference pages quote DSL to teach it, where the reader came
|
|
339
|
+
* for the code, not the picture.
|
|
340
|
+
*/
|
|
341
|
+
include?: (path: string | undefined) => boolean;
|
|
342
|
+
}
|
|
343
|
+
export interface HydrateOptions {
|
|
344
|
+
/** Passed to each view. Default `'exact'`, from `fontBase`. */
|
|
345
|
+
fonts?: ViewOptions['fonts'];
|
|
346
|
+
fontBase?: ViewOptions['fontBase'];
|
|
347
|
+
surface?: ViewOptions['surface'];
|
|
348
|
+
onLink?: ViewOptions['onLink'];
|
|
349
|
+
}
|
|
223
350
|
export {};
|
package/dist/view.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! @getv.design/embed v0.
|
|
2
|
-
import{
|
|
1
|
+
/*! @getv.design/embed v0.2.0. Free to use under the vDesign Embed Licence. © 2026 Sagar Saini. https://getv.design/docs/licence/ */
|
|
2
|
+
import{c as ut,e as ze,f as ce,g as Ee,h as pt,i as Le}from"./chunks/chunk-DSFLLPRE.js";import{A as lt,a as Xe,b as Je,c as Te,d as Fe,e as Qe,f as et,g as tt,h as nt,j as rt,l as it,p as Ie,q as _e,r as ot,s as Ne,v as st,w as at,x as ct,y as dt,z as ft}from"./chunks/chunk-OMODSFXU.js";import{a as qt,b as qe}from"./chunks/chunk-T6H6KLK6.js";import"./chunks/chunk-BESL4IJP.js";var Xt=.8,Jt=.2;function Ve(e,t){let i=e.createElement("canvas").getContext("2d"),n=ot(),u=new Map,s=new Map,m=new Set;function f(l){return`${l.italic?"italic ":""}${l.weight} ${l.size}px ${l.family}`}function g(){u.clear(),s.clear()}return{advance(l,p){if(!i)return n.advance(l,p);let M=f(p),S=`${M}\0${p.letterSpacing}\0${l}`,O=u.get(S);if(O!==void 0)return O;i.font=M;let w=i.measureText(l).width+p.letterSpacing*[...l].length;return u.set(S,w),w},metrics(l){if(!i)return n.metrics(l);let p=f(l),M=s.get(p);if(M)return M;i.font=p;let S=i.measureText("Hxg"),O=S.fontBoundingBoxAscent??l.size*Xt,w=S.fontBoundingBoxDescent??l.size*Jt,N={ascent:O,descent:w,lineGap:0};return s.set(p,N),N},load(l,p){let M=e.fonts;if(!M||typeof FontFace!="function")return!1;let S=!1;for(let O of Object.values(l.fonts))for(let w of Qt(O)){let N=`${O.family}\0${w.src}\0${w.weight??400}\0${w.style??"normal"}`;if(m.has(N))continue;m.add(N);let _=w.src.startsWith("data:")?void 0:p?.(w.src),x={weight:String(w.weight??400),style:w.style??"normal"},R=X=>{let z=new FontFace(O.family,typeof X=="string"?`url(${X})`:en(X),x);M.add(z),z.load().then(()=>{g(),t?.()},()=>{M.delete(z)})};_===void 0?R(w.src):(S=!0,_.then(R,()=>{}))}return S},invalidate:g,destroy(){g(),m.clear()}}}function Qt(e){return e.faces??[]}function en(e){return e instanceof Uint8Array?e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength):e}var Pe={x:0,y:0,zoom:1},ht=.02,mt=64;function Se(e){return Number.isFinite(e)?Math.min(Math.max(e,ht),mt):1}function Ce(e,t){return{x:(t.x-e.x)/e.zoom,y:(t.y-e.y)/e.zoom}}function Re(e,t){return{x:t.x*e.zoom+e.x,y:t.y*e.zoom+e.y}}function De(e,t,r){let i=Se(e.zoom*r),n=Ce(e,t);return{zoom:i,x:t.x-n.x*i,y:t.y-n.y*i}}function ke(e,t,r){return{...e,x:e.x+t,y:e.y+r}}function $e(e){return`translate(${e.x} ${e.y}) scale(${e.zoom})`}function de(e,t,r){let i={width:Math.max(1,t.width-r*2),height:Math.max(1,t.height-r*2)};if(e.width<=0||e.height<=0)return Pe;let n=Se(Math.min(i.width/e.width,i.height/e.height));return{zoom:n,x:(t.width-e.width*n)/2-(e.x??0)*n,y:(t.height-e.height*n)/2-(e.y??0)*n}}var J="http://www.w3.org/2000/svg",gt="vd-viewer-styles",yt=`
|
|
3
3
|
.vd-viewer {
|
|
4
4
|
position: relative;
|
|
5
5
|
overflow: hidden;
|
|
@@ -21,10 +21,11 @@ import{b as Qe,c as Ae,d as ee,e as ue,f as et,g as ye}from"./chunks/chunk-3XUND
|
|
|
21
21
|
.vd-viewer__surface text {
|
|
22
22
|
white-space: pre;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
/* No \`will-change\` on the camera group. It made the document its own
|
|
25
|
+
composited layer, and every camera step then rebuilt the compositor's layer
|
|
26
|
+
list from one entry per clipped or filtered item: 40 ms a step at 60 pages,
|
|
27
|
+
most of a pan. Without it a step repaints what is on screen instead, which is
|
|
28
|
+
cheap except under a large blur. */
|
|
28
29
|
.vd-viewer__page {
|
|
29
30
|
/* An embedder with a no-shadow brand sets --vd-page-shadow: none. */
|
|
30
31
|
filter: var(--vd-page-shadow, drop-shadow(0 6px 24px rgb(0 0 0 / 0.35)));
|
|
@@ -97,4 +98,4 @@ import{b as Qe,c as Ae,d as ee,e as ue,f as et,g as ye}from"./chunks/chunk-3XUND
|
|
|
97
98
|
.vd-viewer--interacting .vd-viewer__page {
|
|
98
99
|
filter: none;
|
|
99
100
|
}
|
|
100
|
-
`;function ot(e){if(e.getElementById(rt))return;let t=e.createElement("style");t.id=rt,t.textContent=it,e.head.appendChild(t)}function at(e,t,r,i){return t?$t(e,t,r,i):Vt(e,r,i)}function Vt(e,t,r){let i=Oe(e,r);return{measurer:i,update:n=>{i.load(n,t)},afterPaint:()=>{},destroy:()=>i.destroy()}}var st=new WeakMap;function $t(e,t,r,i){let n,l,c,m=()=>{if(!n)throw new Error("canvasFonts: update() before measuring");return n};return{measurer:{advance:(y,f)=>m().measurer.advance(y,f),metrics:y=>m().measurer.metrics(y),itemize:y=>m().measurer.itemize(y)},update(y){n&&y.fonts===l||(c?.(),n?.dispose(),n=t.forDocument(y,r?{loader:r}:{}),l=y.fonts,c=n.onChange(i))},afterPaint(){let y=e.fonts;if(!n||!y||typeof FontFace!="function")return;let f=st.get(e);f||st.set(e,f=new Set);for(let p of n.usedFaces()){if(f.has(p.id))continue;f.add(p.id);let A=new FontFace(p.id,Ht(p.bytes),{weight:String(p.weight),style:p.style});y.add(A),A.load().catch(()=>y.delete(A))}},destroy(){c?.(),n?.dispose(),n=void 0}}}function Ht(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var Bt=.01,jt=.004,ct=40,Ut=16;function le(e,t){ot(e.ownerDocument);let r=t.document,i=a=>at(e.ownerDocument,a,t.loadFont,()=>{$(r)}),n=i(t.fonts),l={advance:(a,v)=>n.measurer.advance(a,v),metrics:a=>n.measurer.metrics(a),itemize:a=>n.measurer.itemize?.(a)??[a]};n.update(r);let c=me(r),m=()=>t.resolveAsset?{measure:l,resolveAsset:t.resolveAsset}:{measure:l},u=ke(r,c,m()),y=t.camera??we,f=t.interactive??!0,p=t.wheel??"always";e.classList.add("vd-viewer"),t.surface&&(e.style.background=t.surface);let A=e.ownerDocument.createElementNS(j,"svg");A.setAttribute("class","vd-viewer__surface"),A.setAttribute("width","100%"),A.setAttribute("height","100%");let S=e.ownerDocument.createElementNS(j,"g");S.setAttribute("class","vd-viewer__camera"),S.style.isolation="isolate",A.appendChild(S);let E=e.ownerDocument.createElementNS(j,"defs");S.appendChild(E);let x=e.ownerDocument.createElementNS(j,"rect");x.setAttribute("class","vd-viewer__page"),S.appendChild(x),e.appendChild(A);let C=new Map;function O(){S.setAttribute("transform",_e(y))}function _(){N();let a=u.background!==void 0;x.setAttribute("x",String(u.x)),x.setAttribute("y",String(u.y)),x.setAttribute("width",String(a?u.width:0)),x.setAttribute("height",String(a?u.height:0)),D(x,"fill",u.background??null);let v=new Set,M=x;for(let w of u.items){v.add(w.id);let L=C.get(w.id);(!L||L.tagName!==dt(w))&&(L?.remove(),L=e.ownerDocument.createElementNS(j,dt(w)),L.setAttribute("data-vd-id",w.id),C.set(w.id,L)),Kt(L,w),M.nextSibling!==L&&S.insertBefore(L,M.nextSibling),M=L}for(let[w,L]of C)v.has(w)||(L.remove(),C.delete(w));n.afterPaint(),t.onSceneChange?.(u,r)}function N(){E.replaceChildren();let a=u.items.filter(v=>v.shadows.length>0);if(u.gradients.length>0||a.length>0){let v=`<svg xmlns="${j}">${u.gradients.map(Ye).join("")}${a.map(w=>qe(w)).join("")}</svg>`,M=new DOMParser().parseFromString(v,"image/svg+xml");for(let w of[...M.documentElement.children])E.appendChild(e.ownerDocument.importNode(w,!0))}for(let v of u.clips){let M=e.ownerDocument.createElementNS(j,"clipPath");M.setAttribute("id",ft(v.id)),v.parent!==void 0&&M.setAttribute("clip-path",Pe(v.parent));let w=e.ownerDocument.createElementNS(j,"rect");w.setAttribute("x",String(v.x)),w.setAttribute("y",String(v.y)),w.setAttribute("width",String(v.w)),w.setAttribute("height",String(v.h)),M.appendChild(w),E.appendChild(M)}}function $(a){r=a,n.update(r),c=me(r),u=ke(r,c,m()),_()}function P(a){let v=e.getBoundingClientRect();return{x:a.clientX-v.left,y:a.clientY-v.top}}let F=0,I=0;function U(){e.classList.add("vd-viewer--interacting"),I&&clearTimeout(I),I=setTimeout(()=>{I=0,e.classList.remove("vd-viewer--interacting")},180)}function K(){F&&(cancelAnimationFrame(F),F=0),O(),t.onCameraChange?.(y)}function z(a){y=a,K()}function q(a){y=a,U(),!F&&(F=requestAnimationFrame(()=>{F=0,O(),t.onCameraChange?.(y)}))}let X=null,W=null,B=!1,te=a=>{if(p==="modifier"&&!a.ctrlKey&&!a.metaKey)return;a.preventDefault();let v=P(a),M=a.deltaMode===1?Ut:a.deltaMode===2?e.clientHeight||800:1,w=a.deltaX*M,L=a.deltaY*M;if(a.ctrlKey||a.metaKey){let s=a.ctrlKey?Bt:jt,d=Math.max(-ct,Math.min(ct,L));q(xe(y,v,Math.exp(-d*s)));return}if(a.shiftKey&&w===0){q(fe(y,-L,0));return}q(fe(y,-w,-L))},Z=a=>{(a.button===1||a.button===0&&B)&&(a.preventDefault(),X=a.pointerId,W=P(a),e.setPointerCapture(a.pointerId))},J=a=>{if(X!==a.pointerId||!W)return;let v=P(a);q(fe(y,v.x-W.x,v.y-W.y)),W=v},H=a=>{X===a.pointerId&&(X=null,W=null,e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId))},Q=a=>{a.code==="Space"&&(B=!0)},G=a=>{a.code==="Space"&&(B=!1)};f&&(e.addEventListener("wheel",te,{passive:!1}),e.addEventListener("pointerdown",Z),e.addEventListener("pointermove",J),e.addEventListener("pointerup",H),e.addEventListener("pointercancel",H),e.ownerDocument.addEventListener("keydown",Q),e.ownerDocument.addEventListener("keyup",G)),O(),_();let ne={element:e,surface:A,update:$,getDocument:()=>r,getScene:()=>u,getResolution:()=>c,getMeasurer:()=>l,setFonts(a){n.destroy(),n=i(a),$(r)},getCamera:()=>y,setCamera:z,zoomBy(a,v){let M=e.getBoundingClientRect(),w=v??{x:M.width/2,y:M.height/2};z(xe(y,w,a))},fitToContent(a=32){let v=e.getBoundingClientRect();z(oe({x:u.x,y:u.y,width:u.width,height:u.height},{width:v.width||u.width,height:v.height||u.height},a))},screenToDocument:a=>ve(y,a),documentToScreen:a=>Te(y,a),pointerPoint:P,hitTest(a,v){for(let M=u.items.length-1;M>=0;M--){let w=u.items[M];if(w&&tn(w,a,en/y.zoom)&&(!v||v(w.id)))return w.id}return null},linkAt(a,v){for(let M=u.items.length-1;M>=0;M--){let w=u.items[M];if(w?.kind!=="text"||v&&!v(w.id))continue;let L=w.rotation===0?a:Ee(a,{x:w.x+w.w/2,y:w.y+w.h/2},-w.rotation);for(let s of w.lines){if(L.y<s.y||L.y>s.y+s.h)continue;let d=s.spans.find(o=>L.x>=o.x&&L.x<=o.x+o.w);if(d)return d.style.link}}},itemOf:a=>u.items.find(v=>v.id===a),elementOf:a=>C.get(a),destroy(){f&&(e.removeEventListener("wheel",te),e.removeEventListener("pointerdown",Z),e.removeEventListener("pointermove",J),e.removeEventListener("pointerup",H),e.removeEventListener("pointercancel",H),e.ownerDocument.removeEventListener("keydown",Q),e.ownerDocument.removeEventListener("keyup",G)),F&&cancelAnimationFrame(F),I&&clearTimeout(I),F=0,I=0,n.destroy(),e.classList.remove("vd-viewer--interacting"),A.remove(),C.clear(),e.classList.remove("vd-viewer")}};return t.autoFit&&ne.fitToContent(),ne}var Wt="vd-clip-";function ft(e){return Wt+e}function Pe(e){return`url(#${ft(e)})`}function dt(e){return Je(e)?"g":Le(e)}function Le(e){switch(e.kind){case"ellipse":return"ellipse";case"frame":return"rect";case"image":return e.href===void 0?"rect":"image";case"rect":return"rect";case"text":return"text";case"vector":return"path"}}function Kt(e,t){if(e.tagName!=="g"){ut(e,t);return}D(e,"clip-path",t.clip===void 0?null:Pe(t.clip)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend;let r=e.firstElementChild;(!r||r.tagName!==Le(t))&&(r?.remove(),r=e.ownerDocument.createElementNS(j,Le(t)),e.appendChild(r)),ut(r,{...t,clip:void 0,blend:"normal"})}function ut(e,t){switch(D(e,"clip-path",t.clip===void 0?null:Pe(t.clip)),D(e,"transform",t.rotation===0?null:Xe(t)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend,e.style.filter=t.shadows.length>0?`url(#${Ze}${t.id})`:"",t.kind){case"ellipse":Jt(e,t);return;case"frame":Gt(e,t);return;case"image":Yt(e,t);return;case"rect":Xt(e,t);return;case"text":qt(e,t);return;case"vector":Qt(e,t);return}}function Gt(e,t){e.setAttribute("class","vd-viewer__page"),e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),D(e,"fill",t.background??null)}function Yt(e,t){if(e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),D(e,"opacity",t.opacity<1?String(t.opacity):null),t.href===void 0){e.setAttribute("class","vd-viewer__missing"),D(e,"rx",t.radius>0?String(t.radius):null);return}e.setAttribute("href",t.href),e.setAttribute("preserveAspectRatio",Zt[t.fit])}var Zt={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"};function qt(e,t){D(e,"opacity",t.opacity<1?String(t.opacity):null),e.setAttribute("xml:space","preserve");let r=t.lines.flatMap(n=>n.spans).filter(n=>n.text!==""),i=e.ownerDocument;for(;e.childNodes.length>r.length;)e.lastChild?.remove();for(;e.childNodes.length<r.length;)e.appendChild(i.createElementNS(j,"tspan"));r.forEach((n,l)=>{let c=e.childNodes[l];c.textContent=n.text,c.setAttribute("x",String(n.x)),c.setAttribute("y",String(n.y)),c.setAttribute("font-family",n.style.family),c.setAttribute("font-size",String(n.style.size)),c.setAttribute("fill",n.style.fill),D(c,"font-weight",n.style.weight===400?null:String(n.style.weight)),D(c,"font-style",n.style.italic?"italic":null),D(c,"letter-spacing",n.style.letterSpacing===0?null:String(n.style.letterSpacing)),D(c,"data-vd-link",n.style.link??null);let m=[n.style.underline?"underline":"",n.style.strike?"line-through":""].filter(Boolean).join(" ");D(c,"text-decoration",m===""?null:m)})}function Xt(e,t){e.removeAttribute("class"),e.setAttribute("x",String(t.x)),e.setAttribute("y",String(t.y)),e.setAttribute("width",String(t.w)),e.setAttribute("height",String(t.h)),e.setAttribute("fill",t.fill),D(e,"rx",t.radius>0?String(t.radius):null),D(e,"stroke",t.stroke??null),D(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),D(e,"opacity",t.opacity<1?String(t.opacity):null)}function lt(e,t){e.setAttribute("fill",t.fill),D(e,"stroke",t.stroke??null),D(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),D(e,"opacity",t.opacity<1?String(t.opacity):null)}function Jt(e,t){e.setAttribute("cx",String(t.x+t.w/2)),e.setAttribute("cy",String(t.y+t.h/2)),e.setAttribute("rx",String(t.w/2)),e.setAttribute("ry",String(t.h/2)),lt(e,t)}function Qt(e,t){e.setAttribute("d",t.d),lt(e,t),D(e,"fill-rule",t.rule==="nonzero"?null:t.rule),D(e,"stroke-linecap",t.cap==="butt"?null:t.cap),D(e,"stroke-linejoin",t.join==="miter"?null:t.join)}function D(e,t,r){r===null?e.removeAttribute(t):e.setAttribute(t,r)}var en=4;function tn(e,t,r){let i=e.rotation===0?t:Ee(t,{x:e.x+e.w/2,y:e.y+e.h/2},-e.rotation),n=i.x>=e.x&&i.x<=e.x+e.w&&i.y>=e.y&&i.y<=e.y+e.h;if(e.kind==="ellipse"){let l=e.stroke!==void 0?e.strokeWidth/2:0,c=e.w/2+l,m=e.h/2+l;if(c<=0||m<=0)return!1;let u=(i.x-(e.x+e.w/2))/c,y=(i.y-(e.y+e.h/2))/m;return u*u+y*y<=1}if(e.kind==="vector"){let l=e.stroke!==void 0&&e.strokeWidth>0;return Ue(e.contours,i,{fill:e.fill!=="none",rule:e.rule,reach:(l?e.strokeWidth/2:0)+r})}return n}function ae(e,t){let r=new Map;for(let n of t.items)n.kind==="frame"&&n.w>0&&n.h>0&&r.set(n.id,{id:n.id,x:n.x,y:n.y,w:n.w,h:n.h});let i=e.root.children.flatMap(n=>{let l=n.type==="frame"?r.get(n.id):void 0;return l&&n.type==="frame"?[{...l,skip:n.skip===!0}]:[]});return i.length===0?[{id:null,x:t.x,y:t.y,w:t.width,h:t.height,skip:!1}]:i.every(n=>n.skip)?i.map(n=>({...n,skip:!1})):i}function pt(e,t){return e.root.children.find(i=>i.type==="frame"&&$e(i,t)!==void 0)?.id}function ht(e,t){let r=t===void 0?-1:e.findIndex(i=>i.id===t);return r!==-1?r:Math.max(0,e.findIndex(i=>!i.skip))}function ce(e,t,r){for(let i=t+r;i>=0&&i<e.length;i+=r)if(!e[i]?.skip)return i;return t}function gt(e){return e.filter(t=>!t.skip).length}function Ce(e,t){return e[t]?.skip!==!1?null:e.slice(0,t+1).filter(r=>!r.skip).length}function mt(e,t){if(!/^\d+$/.test(e))return null;let r=Number(e),i=t.findIndex((n,l)=>Ce(t,l)===r);return i===-1?null:i}function yt(e,t,r){let i=pt(e,r),n=t.findIndex(l=>l.id!==null&&l.id===i);return n===-1?null:n}var nn="cubic-bezier(0.2, 0, 0, 1)",rn="cubic-bezier(0.4, 0, 1, 1)",wt="cubic-bezier(0.4, 0, 0.2, 1)";function vt(e,t,r,i,n){let l={opacity:r},c=on(e,t,i,n);if(e==="cut")return{keyframes:t==="enter"?[{visibility:"hidden"},{visibility:"hidden"}]:[{visibility:"visible"},{visibility:"visible"}],easing:"linear"};if(e==="pop"){let m=`${n.x}px ${n.y}px`;l.scale="1",l.transformOrigin=m}else(e==="rise"||e==="drop")&&(l.translate="0 0");return t==="enter"?{keyframes:[c,l],easing:nn}:{keyframes:[l,c],easing:rn}}function on(e,t,r,i){switch(e){case"rise":return{opacity:0,translate:`0 ${t==="enter"?r:-r}px`};case"drop":return{opacity:0,translate:`0 ${t==="enter"?-r:r}px`};case"pop":return{opacity:0,scale:String(.85),transformOrigin:`${i.x}px ${i.y}px`};case"fade":case"cut":return{opacity:0}}}function xt(e,t){let r=t==="forward"?"-100%":"100%",i=t==="forward"?"100%":"-100%";switch(e){case"cut":return null;case"fade":return{still:[{opacity:1},{opacity:0}],live:null,stillOnTop:!0};case"push":return{still:[{translate:"0 0"},{translate:`${r} 0`}],live:[{translate:`${i} 0`},{translate:"0 0"}],stillOnTop:!1};case"slide":return t==="forward"?{still:null,live:[{translate:"100% 0"},{translate:"0 0"}],stillOnTop:!1}:{still:[{translate:"0 0"},{translate:"100% 0"}],live:null,stillOnTop:!0}}}var sn={enter:"cut",duration:0,steps:[[]],clicks:new Map};function De(e){let t=new Map,r=new Map,i=new Map;Ve(e.root,(m,u)=>{u&&(r.set(m.id,u.id),i.set(u.id,[...i.get(u.id)??[],m.id]))});let n=je(e),l=Be(e);for(let[m,u]of Object.entries(e.motion??{})){if(!l.has(m))continue;let y=[[]],f=new Map;for(let p of u.lines){if(p.id===m||n.get(p.id)!==m)continue;let A=p.go===void 0?void 0:He(p.go);A&&f.set(p.id,A);let S=p.enter!==void 0?"enter":p.exit!==void 0?"exit":null,E=p.enter??p.exit;S===null||E===void 0||(p.step&&y.push([]),y.at(-1).push({id:p.id,kind:S,effect:E,duration:E==="cut"?0:p.duration??Se,delay:p.delay??0,together:p.together===!0}))}t.set(m,{enter:u.enter??"cut",duration:u.duration??Se,steps:y,clicks:f})}let c=m=>[m,...(i.get(m)??[]).flatMap(u=>c(u))];return{pages:t,parents:r,within:c}}function bt(e,t){let r=t?.id;return(r?e.pages.get(r):void 0)??sn}function Fe(e){let t=0,r=0;return e.map((i,n)=>(t=(n===0?0:i.together?t:r)+i.delay,r=t+i.duration,{build:i,at:t}))}function St(e){return Math.max(0,...Fe(e).map(({build:t,at:r})=>r+t.duration))}function se(e,t){let r=new Set,i=new Set;for(let n of e.steps.flat())i.has(n.id)||(i.add(n.id),n.kind==="enter"&&r.add(n.id));for(let n of e.steps.slice(0,t).flat())n.kind==="enter"?r.delete(n.id):r.add(n.id);return r}function Et(e,t,r){for(let i=r;i!==void 0;i=e.parents.get(i)){let n=t.clicks.get(i);if(n)return{id:i,target:n}}}function kt(e,t,r){let i=[...e];for(;i.length>0;){let n=i.pop(),l=t.findIndex(c=>c.id!==null&&c.id===n);if(l!==-1&&l!==r)return{index:l,history:i}}return null}var cn=1500,dn=2e3,un=50;function Ie(e,t){let r=e.ownerDocument;e.classList.add("vd-player"),e.tabIndex=-1;let i=new Set,n=new Set,l=!1,c=le(e,{document:t.document,interactive:!1,surface:"#000",...t.fonts?{fonts:t.fonts}:{},...t.loadFont?{loadFont:t.loadFont}:{},...t.resolveAsset?{resolveAsset:t.resolveAsset}:{},onSceneChange:()=>{l&&z()}}),m=r.createElementNS(j,"path");m.setAttribute("class","vd-player__mask"),m.setAttribute("fill","#000"),m.setAttribute("fill-rule","evenodd"),c.surface.appendChild(m);let u=r.createElement("div");u.className="vd-player__counter",u.setAttribute("aria-live","polite"),e.appendChild(u);let y=De(t.document),f=ae(t.document,c.getScene()),p=ht(f,t.start),A=[],S=0,E=[],x,C=0,O="",_,N,$=r.defaultView,P=()=>typeof c.surface.animate=="function"&&!($?.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1),F=()=>bt(y,f[p]);function I(){let s=e.getBoundingClientRect(),d=f[p];return{width:s.width||d?.w||1,height:s.height||d?.h||1}}function U(){let s=f[p];if(!s)return;let d=I(),o=oe({x:s.x,y:s.y,width:s.w,height:s.h},d,0);c.setCamera(o);let h=s.x*o.zoom+o.x,g=s.y*o.zoom+o.y,b=s.w*o.zoom,T=s.h*o.zoom;m.setAttribute("d",`M0 0H${d.width}V${d.height}H0ZM${h} ${g}h${b}v${T}h${-b}Z`),m.dataset.slide=s.id??""}function K(){let s=Ce(f,p),d=gt(f);u.textContent=s===null?"Skipped":`${s} / ${d}`,u.classList.add("vd-player__counter--shown"),_&&clearTimeout(_),_=setTimeout(()=>u.classList.remove("vd-player__counter--shown"),cn),t.onChange?.(s,d)}function z(){let s=new Set;for(let d of i)for(let o of y.within(d))s.add(o);n=s;for(let d of c.surface.querySelectorAll("[data-vd-hidden]")){let o=d.getAttribute("data-vd-id");(o===null||!s.has(o))&&d.removeAttribute("data-vd-hidden")}for(let d of s)c.elementOf(d)?.setAttribute("data-vd-hidden","")}function q(s){return y.within(s).flatMap(d=>{let o=c.elementOf(d);return o?[o]:[]})}function X(s){let d=1/0,o=1/0,h=-1/0,g=-1/0;for(let b of y.within(s)){let T=c.itemOf(b);T&&(d=Math.min(d,T.x),o=Math.min(o,T.y),h=Math.max(h,T.x+T.w),g=Math.max(g,T.y+T.h))}return Number.isFinite(d)?{x:(d+h)/2,y:(o+g)/2}:{x:0,y:0}}function W(){if(!(E.length===0&&!x)){C+=1,S===0&&(S=1),i=se(F(),S),z();for(let s of E)s.cancel();E=[],x?.remove(),x=void 0}}function B(){return E.length===0&&!x?!1:(W(),!0)}function te(s,d){return new Promise(o=>{let h=!1,g=()=>{h||(h=!0,o())};Promise.all(s.map(b=>b.finished)).then(g,()=>{h=!0}),setTimeout(()=>{if(!h){for(let b of s)(b.playState==="running"||b.playState==="paused")&&b.finish();g()}},d+un)})}function Z(s,d,o){if(s===p||!f[s])return;let h=F();p=s;let g=F(),b=o==="forward"?g:h,T=P()?xt(b.enter,o):null;if(T&&(x=c.surface.cloneNode(!0),x.classList.add("vd-player__still"),x.setAttribute("aria-hidden","true"),T.stillOnTop?c.surface.after(x):c.surface.before(x)),U(),S=d?0:g.steps.length,i=se(g,S),z(),K(),!T||!x){d&&J();return}let R={duration:b.duration,easing:wt},k=[];T.still&&k.push(x.animate(T.still,{...R,fill:"forwards"})),T.live&&k.push(c.surface.animate(T.live,R)),E.push(...k);let re=C;te(k,b.duration).then(()=>{if(re===C){E=E.filter(ie=>!k.includes(ie));for(let ie of k)ie.cancel();x?.remove(),x=void 0,d&&J()}})}function J(){let s=F(),d=s.steps[S];if(d===void 0)return;S+=1;let o=se(s,S);if(d.length===0)return;if(!P()){i=o,z();return}let h=new Set(d.filter(k=>k.kind==="enter").map(k=>k.id));i=new Set([...se(s,S-1)].filter(k=>!h.has(k))),z();let g=f[p],b=.04*Math.min(g?.w??0,g?.h??0),T=C,R=[];for(let{build:k,at:re}of Fe(d)){let ie=X(k.id),Y=[];for(let V of q(k.id)){let de=Number(V.getAttribute("opacity")??1),{keyframes:be,easing:he}=vt(k.effect,k.kind,Number.isFinite(de)?de:1,b,ie);Y.push(V.animate(be,{duration:k.duration,delay:re,easing:he,fill:k.kind==="enter"?"backwards":"forwards"}))}R.push(...Y),k.kind==="exit"&&Y.length>0&&te(Y,re+k.duration).then(()=>{if(T===C){i.add(k.id),z();for(let V of Y)V.cancel()}})}E.push(...R),te(R,St(d)).then(()=>{if(T===C){E=E.filter(k=>!R.includes(k)),i=o,z();for(let k of R)k.cancel()}})}function H(s){let d=Math.min(Math.max(0,s),f.length-1);if(d===p)return;let o=f[p]?.id;o&&A.push(o),Z(d,!0,"forward")}function Q(){if(!B()){if(S<F().steps.length){J();return}H(ce(f,p,1))}}function G(){if(B())return;let s=kt(A,f,p);if(s){A=s.history,Z(s.index,!1,"back");return}Z(ce(f,p,-1),!1,"back")}function ne(s){switch(s.kind){case"url":t.onLink?.(s.url);return;case"back":G();return;case"next":H(ce(f,p,1));return;case"frame":{let d=yt(c.getDocument(),f,s.id);d===null?Q():H(d)}}}function a(s){let d=f[p];if(!d||s.x<d.x||s.y<d.y||s.x>d.x+d.w||s.y>d.y+d.h)return;let o=T=>!n.has(T),h=c.hitTest(s,o),g=h===null?void 0:Et(y,F(),h);if(g)return g.target;let b=c.linkAt(s,o);return b===void 0?void 0:ge(b)}let v=s=>{if(s.stopPropagation(),s.metaKey||s.ctrlKey||s.altKey)return;let d=s.key;if(/^\d$/.test(d))O+=d;else if(d==="Enter"&&O!==""){let o=mt(O,f);O="",!B()&&o!==null&&H(o)}else if(d==="Escape")O!==""?O="":t.onExit?.();else if(["ArrowRight","ArrowDown","PageDown"," ","Enter"].includes(d))O="",Q();else if(["ArrowLeft","ArrowUp","PageUp","Backspace"].includes(d))O="",G();else if(d==="Home")B()||H(ce(f,-1,1));else if(d==="End")B()||H(ce(f,f.length,-1));else return;s.preventDefault()},M=s=>{if(B())return;let d=a(c.screenToDocument(c.pointerPoint(s)));d?ne(d):Q()},w=s=>{if(e.classList.remove("vd-player--idle"),N&&clearTimeout(N),N=setTimeout(()=>e.classList.add("vd-player--idle"),dn),!s)return;let d=c.screenToDocument(c.pointerPoint(s));e.classList.toggle("vd-player--link",a(d)!==void 0)},L=$&&"ResizeObserver"in $?new $.ResizeObserver(()=>U()):void 0;return L?.observe(e),e.addEventListener("keydown",v),e.addEventListener("click",M),e.addEventListener("pointermove",w),l=!0,U(),i=se(F(),0),z(),K(),w(),e.focus({preventScroll:!0}),J(),{viewer:c,index:()=>p,count:()=>f.length,next:Q,back:G,go(s){W(),H(s)},update(s){if(s===c.getDocument())return;W();let d=f[p]?.id;c.update(s),y=De(s),f=ae(s,c.getScene());let o=f.findIndex(h=>h.id===d);p=o===-1?Math.min(p,f.length-1):o,U(),S=F().steps.length,i=se(F(),S),z()},refit:U,destroy(){C+=1;for(let s of E)s.cancel();E=[],x?.remove(),L?.disconnect(),e.removeEventListener("keydown",v),e.removeEventListener("click",M),e.removeEventListener("pointermove",w),_&&clearTimeout(_),N&&clearTimeout(N),m.remove(),u.remove(),c.destroy(),e.classList.remove("vd-player","vd-player--idle","vd-player--link"),e.removeAttribute("tabindex")}}}function At(e){let t=e,r=new Map,i=typeof URL.createObjectURL=="function"&&typeof URL.revokeObjectURL=="function";return{resolve(n){let l=r.get(n.hash);if(l!==void 0)return l;let c=t.get(n.hash);if(c===void 0)return;if(!i)return We(n.type,c);let m;try{m=Ke(c)}catch{return}let u=URL.createObjectURL(new Blob([m],{type:n.type}));return r.set(n.hash,u),u},replace(n){t=n;for(let[l,c]of r)n.has(l)||(URL.revokeObjectURL(c),r.delete(l))},destroy(){for(let n of r.values())URL.revokeObjectURL(n);r.clear(),t=new Map}}}var Ne=["page","content","none"],Ot=24;function pe(e){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}function Mt(e,t){let r=t===void 0?void 0:e.itemOf(t);if(!(!r||r.w<=0||r.h<=0))return{x:r.x,y:r.y,width:r.w,height:r.h}}function Tt(e,t,r,i){if(r==="none")return;let n=r==="page"?Mt(e,i):void 0;if(!n){e.fitToContent(Ot);return}let l=pe(t);e.setCamera(oe(n,{width:l.width||n.width,height:l.height||n.height},Ot))}function _t(e,t,r){let i=Mt(e,r);if(!i)return;let n=e.getCamera(),l=pe(t),c=l.width||i.width*n.zoom,m=l.height||i.height*n.zoom;e.setCamera({zoom:n.zoom,x:c/2-(i.x+i.width/2)*n.zoom,y:m/2-(i.y+i.height/2)*n.zoom})}var ze=Symbol.for("vdesign.embed.handover");function Lt(e){return e[ze]}var Pt=["exact","browser"],Ct=["ready","problems","page","fonts"];async function fn(e,t){try{let{exactFontsAt:r}=await import("./chunks/fonts.js"),i=r(e);return(await i.ensure(t)).length===0?i:void 0}catch{return}}async function ur(e,t,r={}){let i=r.fit??"page";if(!Ne.includes(i))throw new TypeError(`view: fit must be one of ${Ne.join(", ")}; got ${String(i)}.`);let n=r.fonts??"exact";if(!Pt.includes(n))throw new TypeError(`view: fonts must be one of ${Pt.join(", ")}; got ${String(n)}.`);let l=n==="exact"?et(r.fontBase,Re,e.ownerDocument.baseURI):void 0,c=Lt(r),m=await Ae(t),u=c?.page!==void 0&&ee(m.document).some(o=>o.id===c.page)?c.page:r.page===void 0?ee(m.document)[0]?.id:ue(m.document,r.page).id,y=c?.exact&&l?await fn(l,m.document):void 0,f=e.ownerDocument,p=f.defaultView,A=At(m.blocks),S=m.blocks,E=[...m.problems],x,C=()=>x?[...E,x]:[...E],O=f.createElement("div");O.className="vd-embed",O.style.width="100%",O.style.height="100%",e.appendChild(O);let _=le(O,{document:m.document,interactive:r.interactive??!0,wheel:"modifier",resolveAsset:o=>A.resolve(o),...r.surface?{surface:r.surface}:{},...c?{camera:c.camera}:{},...y?{fonts:y.library}:{}}),N={ready:new Set,problems:new Set,page:new Set,fonts:new Set},$=!1,P=!1,F=0,I,U,K=y,z=n==="browser"?"browser":void 0,q;function X(){$=!0;for(let o of N.ready)o()}function W(){for(let o of N.problems)o(C())}function B(o){z=o;for(let h of N.fonts)h(o)}function te(){return q??=(async()=>{if(l)try{let{exactFontsAt:o}=await import("./chunks/fonts.js");return o(l)}catch{return}})(),q}function Z(o){K=void 0,_.setFonts(void 0),I?.fonts(void 0),x=o,W(),B("browser")}async function J(){let o=await te();if(!P){if(!o){Z(ye([],l?"the fonts chunk would not load":"no fontBase was given and this build has no default"));return}for(;;){let h=_.getDocument(),g=await o.ensure(h);if(P)return;if(g.length>0){Z(ye(g));return}if(_.getDocument()===h)break}K=o,_.setFonts(o.library),I?.fonts(o),B("exact")}}function H(){let o=Q(u);if(o)for(let h of N.page)h(o)}function Q(o){let h=ee(_.getDocument()).find(g=>g.id===o);if(h)return h.name===void 0?{id:h.id}:{id:h.id,name:h.name}}let G=()=>Tt(_,O,i,u),ne=()=>_t(_,O,u);function a(o){if(P)return;let h=ue(_.getDocument(),o).id,g=h!==u;u=h,i==="page"?G():ne(),g&&H()}function v(o){r.onLink?r.onLink(o):p?.open(o,"_blank","noopener,noreferrer")}let M=o=>{if(o.button!==0||I)return;let h=_.linkAt(_.screenToDocument(_.pointerPoint(o)));if(h===void 0)return;let g=ge(h);if(g){if(o.preventDefault(),g.kind==="frame"){ee(_.getDocument()).some(b=>b.id===g.id)&&a(g.id);return}v(g.url)}};O.addEventListener("click",M);let w=pe(O),L=p&&"ResizeObserver"in p?new p.ResizeObserver(()=>{let o=pe(O);o.width===w.width&&o.height===w.height||(w=o,G())}):void 0;L?.observe(O),c||(i==="none"&&u!==void 0&&r.page!==void 0?ne():G()),X(),y?B("exact"):n==="exact"&&J();let s={async load(o){if(P)throw new Error("view: this view was destroyed.");let h=++F,g=await Ae(o),b=K,T=b?await b.ensure(g.document):[];if(U&&await U||P||h!==F)return;T.length>0&&K===b&&Z(ye(T)),A.replace(g.blocks),S=g.blocks,_.update(g.document),E=[...g.problems],I?.update(g.document),ee(g.document).some(k=>k.id===u)||(u=ee(g.document)[0]?.id,i==="page"?G():ne(),H()),W(),X()},pages:()=>ee(_.getDocument()).map(o=>o.name===void 0?{id:o.id}:{id:o.id,name:o.name}),goTo:a,fit:()=>{P||G()},play(o={}){if(P)return Promise.reject(new Error("view: this view was destroyed."));try{return I?.stop(),Promise.resolve(d(_.getDocument(),o.page))}catch(h){return Promise.reject(h instanceof Error?h:new Error(String(h)))}},async edit(o={}){if(P)throw new Error("view: this view was destroyed.");if(U)throw new Error("view: edit() is already opening an editor.");let h;U=new Promise(b=>h=b);let g=!1;try{let{edit:b}=await import("./edit.js");if(P)throw new Error("view: this view was destroyed.");let T={camera:_.getCamera(),page:u,exact:K!==void 0},R=Qe(_.getDocument(),S,E),k=await b(e,R,{...r,...o,[ze]:T});if(P)throw k.destroy(),new Error("view: this view was destroyed.");return g=!0,s.destroy(),k}finally{U=void 0,h(g)}},on(o,h){if(!Ct.includes(o))throw new TypeError(`view: on() takes one of ${Ct.join(", ")}; got ${String(o)}.`);let g=N[o];if(g.add(h),o==="ready"&&$&&queueMicrotask(()=>{g.has(h)&&h()}),o==="problems"&&queueMicrotask(()=>{g.has(h)&&h(C())}),o==="fonts"&&z!==void 0){let b=z;queueMicrotask(()=>{g.has(h)&&h(b)})}return()=>{g.delete(h)}},destroy(){if(!P){P=!0,I?.stop(),O.removeEventListener("click",M),L?.disconnect(),_.destroy(),A.destroy(),O.remove();for(let o of Object.values(N))o.clear()}}};function d(o,h){let g=h===void 0?u:ue(o,h).id,b=f.createElement("div");b.className="vd-embed__play",b.style.position="absolute",b.style.inset="0";let T=V=>V.stopPropagation();b.addEventListener("wheel",T);let R=f.activeElement;O.appendChild(b);let k=!1,re=()=>{if(k)return;k=!0,I===ie&&(I=void 0),Y.destroy(),b.removeEventListener("wheel",T);let V=b.contains(f.activeElement);b.remove(),V&&R&&"focus"in R&&typeof R.focus=="function"&&R.focus({preventScroll:!0})},ie={stop:re,update:V=>Y.update(V),fonts:V=>Y.viewer.setFonts(V?.library)},Y=Ie(b,{document:o,resolveAsset:V=>A.resolve(V),...K?{fonts:K.library}:{},...g===void 0?{}:{start:g},onExit:re,onLink:v});return I=ie,{goTo(V){if(k)return;let de=Y.viewer.getDocument(),be=ue(de,V).id,he=ae(de,Y.viewer.getScene()).findIndex(Dt=>Dt.id===be);he!==-1&&Y.go(he)},destroy:re}}return s}export{Ft as version,ur as view};
|
|
101
|
+
`;function wt(e){if(e.getElementById(gt))return;let t=e.createElement("style");t.id=gt,t.textContent=yt,e.head.appendChild(t)}function vt(e,t,r,i){return t?nn(e,t,r,i):tn(e,r,i)}function tn(e,t,r){let i=Ve(e,r);return{measurer:i,update:n=>{i.load(n,t)},afterPaint:()=>{},destroy:()=>i.destroy()}}var xt=new WeakMap;function nn(e,t,r,i){let n,u,s,m=()=>{if(!n)throw new Error("canvasFonts: update() before measuring");return n};return{measurer:{advance:(g,l)=>m().measurer.advance(g,l),metrics:g=>m().measurer.metrics(g),itemize:g=>m().measurer.itemize(g)},update(g){n&&g.fonts===u||(s?.(),n?.dispose(),n=t.forDocument(g,r?{loader:r}:{}),u=g.fonts,s=n.onChange(i))},afterPaint(){let g=e.fonts;if(!n||!g||typeof FontFace!="function")return;let l=xt.get(e);l||xt.set(e,l=new Set);for(let p of n.usedFaces()){if(l.has(p.id))continue;l.add(p.id);let M=new FontFace(p.id,rn(p.bytes),{weight:String(p.weight),style:p.style});g.add(M),M.load().catch(()=>g.delete(M))}},destroy(){s?.(),n?.dispose(),n=void 0}}}function rn(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var on=.01,sn=.004,bt=40,an=16;function Ae(e,t){wt(e.ownerDocument);let r=t.document,i=a=>vt(e.ownerDocument,a,t.loadFont,()=>{z(r)}),n=i(t.fonts),u={advance:(a,v)=>n.measurer.advance(a,v),metrics:a=>n.measurer.metrics(a),itemize:a=>n.measurer.itemize?.(a)??[a]};n.update(r);let s=_e(r),m=()=>t.resolveAsset?{measure:u,resolveAsset:t.resolveAsset}:{measure:u},f=Ne(r,s,m()),g=t.camera??Pe,l=t.interactive??!0,p=t.wheel??"always";e.classList.add("vd-viewer"),t.surface&&(e.style.background=t.surface);let M=e.ownerDocument.createElementNS(J,"svg");M.setAttribute("class","vd-viewer__surface"),M.setAttribute("width","100%"),M.setAttribute("height","100%");let S=e.ownerDocument.createElementNS(J,"g");S.setAttribute("class","vd-viewer__camera"),S.style.isolation="isolate",M.appendChild(S);let O=e.ownerDocument.createElementNS(J,"defs");S.appendChild(O);let w=e.ownerDocument.createElementNS(J,"rect");w.setAttribute("class","vd-viewer__page"),S.appendChild(w),e.appendChild(M);let N=new Map;function _(){S.setAttribute("transform",$e(g))}function x(){X();let a=f.background!==void 0;A(w,"x",String(f.x)),A(w,"y",String(f.y)),A(w,"width",String(a?f.width:0)),A(w,"height",String(a?f.height:0)),I(w,"fill",f.background??null);let v=new Set,L=w;for(let E of f.items){v.add(E.id);let b=N.get(E.id);(!b||b.tagName!==Et(E))&&(b?.remove(),b=e.ownerDocument.createElementNS(J,Et(E)),b.setAttribute("data-vd-id",E.id),N.set(E.id,b)),fn(b,E),L.nextSibling!==b&&S.insertBefore(b,L.nextSibling),L=b}for(let[E,b]of N)v.has(E)||(b.remove(),N.delete(E));n.afterPaint(),t.onSceneChange?.(f,r)}let R=new Map;function X(){let a=[...f.gradients.map(at),...f.items.filter(b=>b.shadows.length>0).map(b=>dt(b)),...f.clips.map(st)],v=new Set(a);for(let[b,H]of R)v.has(b)||(H.remove(),R.delete(b));let L=a.filter(b=>!R.has(b));if(L.length===0)return;[...new DOMParser().parseFromString(`<svg xmlns="${J}">${L.join("")}</svg>`,"image/svg+xml").documentElement.children].forEach((b,H)=>{let d=e.ownerDocument.importNode(b,!0);O.appendChild(d),R.set(L[H],d)})}function z(a){r=a,n.update(r),s=_e(r),f=Ne(r,s,m()),x()}function G(a){let v=e.getBoundingClientRect();return{x:a.clientX-v.left,y:a.clientY-v.top}}let C=0,j=0;function Y(){e.classList.add("vd-viewer--interacting"),j&&clearTimeout(j),j=setTimeout(()=>{j=0,e.classList.remove("vd-viewer--interacting")},180)}function Z(){C&&(cancelAnimationFrame(C),C=0),_(),t.onCameraChange?.(g)}function te(a){g=a,Z()}function $(a){g=a,Y(),!C&&(C=requestAnimationFrame(()=>{C=0,_(),t.onCameraChange?.(g)}))}let Q=null,B=null,fe=!1,K=a=>{if(p==="modifier"&&!a.ctrlKey&&!a.metaKey)return;a.preventDefault();let v=G(a),L=a.deltaMode===1?an:a.deltaMode===2?e.clientHeight||800:1,E=a.deltaX*L,b=a.deltaY*L;if(a.ctrlKey||a.metaKey){let H=a.ctrlKey?on:sn,d=Math.max(-bt,Math.min(bt,b));$(De(g,v,Math.exp(-d*H)));return}if(a.shiftKey&&E===0){$(ke(g,-b,0));return}$(ke(g,-E,-b))},ge=a=>{(a.button===1||a.button===0&&fe)&&(a.preventDefault(),Q=a.pointerId,B=G(a),e.setPointerCapture(a.pointerId))},pe=a=>{if(Q!==a.pointerId||!B)return;let v=G(a);$(ke(g,v.x-B.x,v.y-B.y)),B=v},ne=a=>{Q===a.pointerId&&(Q=null,B=null,e.hasPointerCapture(a.pointerId)&&e.releasePointerCapture(a.pointerId))},W=a=>{a.code==="Space"&&(fe=!0)},re=a=>{a.code==="Space"&&(fe=!1)};l&&(e.addEventListener("wheel",K,{passive:!1}),e.addEventListener("pointerdown",ge),e.addEventListener("pointermove",pe),e.addEventListener("pointerup",ne),e.addEventListener("pointercancel",ne),e.ownerDocument.addEventListener("keydown",W),e.ownerDocument.addEventListener("keyup",re)),_(),x();let se={element:e,surface:M,update:z,getDocument:()=>r,getScene:()=>f,getResolution:()=>s,getMeasurer:()=>u,setFonts(a){n.destroy(),n=i(a),z(r)},getCamera:()=>g,setCamera:te,zoomBy(a,v){let L=e.getBoundingClientRect(),E=v??{x:L.width/2,y:L.height/2};te(De(g,E,a))},fitToContent(a=32){let v=e.getBoundingClientRect();te(de({x:f.x,y:f.y,width:f.width,height:f.height},{width:v.width||f.width,height:v.height||f.height},a))},screenToDocument:a=>Ce(g,a),documentToScreen:a=>Re(g,a),pointerPoint:G,hitTest(a,v){for(let L=f.items.length-1;L>=0;L--){let E=f.items[L];if(E&&xn(E,a,wn/g.zoom)&&(!v||v(E.id)))return E.id}return null},linkAt(a,v){for(let L=f.items.length-1;L>=0;L--){let E=f.items[L];if(E?.kind!=="text"||v&&!v(E.id))continue;let b=E.rotation===0?a:Ie(a,{x:E.x+E.w/2,y:E.y+E.h/2},-E.rotation);for(let H of E.lines){if(b.y<H.y||b.y>H.y+H.h)continue;let d=H.spans.find(y=>b.x>=y.x&&b.x<=y.x+y.w);if(d)return d.style.link}}},itemOf:a=>f.items.find(v=>v.id===a),elementOf:a=>N.get(a),destroy(){l&&(e.removeEventListener("wheel",K),e.removeEventListener("pointerdown",ge),e.removeEventListener("pointermove",pe),e.removeEventListener("pointerup",ne),e.removeEventListener("pointercancel",ne),e.ownerDocument.removeEventListener("keydown",W),e.ownerDocument.removeEventListener("keyup",re)),C&&cancelAnimationFrame(C),j&&clearTimeout(j),C=0,j=0,n.destroy(),e.classList.remove("vd-viewer--interacting"),M.remove(),N.clear(),e.classList.remove("vd-viewer")}};return t.autoFit&&se.fitToContent(),se}var cn="vd-clip-";function dn(e){return cn+e}function kt(e){return`url(#${dn(e)})`}function Et(e){return lt(e)?"g":Be(e)}function Be(e){switch(e.kind){case"ellipse":return"ellipse";case"frame":return"rect";case"image":return e.href===void 0?"rect":"image";case"rect":return"rect";case"text":return"text";case"vector":return"path"}}function fn(e,t){if(e.tagName!=="g"){St(e,t);return}I(e,"clip-path",t.clip===void 0?null:kt(t.clip)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend;let r=e.firstElementChild;(!r||r.tagName!==Be(t))&&(r?.remove(),r=e.ownerDocument.createElementNS(J,Be(t)),e.appendChild(r)),St(r,{...t,clip:void 0,blend:"normal"})}function St(e,t){switch(I(e,"clip-path",t.clip===void 0?null:kt(t.clip)),I(e,"transform",t.rotation===0?null:ft(t)),e.style.mixBlendMode=t.blend==="normal"?"":t.blend,e.style.filter=t.shadows.length>0?`url(#${ct}${t.id})`:"",t.kind){case"ellipse":gn(e,t);return;case"frame":ln(e,t);return;case"image":un(e,t);return;case"rect":mn(e,t);return;case"text":hn(e,t);return;case"vector":yn(e,t);return}}function ln(e,t){A(e,"class","vd-viewer__page"),A(e,"x",String(t.x)),A(e,"y",String(t.y)),A(e,"width",String(t.w)),A(e,"height",String(t.h)),I(e,"fill",t.background??null)}function un(e,t){if(A(e,"x",String(t.x)),A(e,"y",String(t.y)),A(e,"width",String(t.w)),A(e,"height",String(t.h)),I(e,"opacity",t.opacity<1?String(t.opacity):null),t.href===void 0){A(e,"class","vd-viewer__missing"),I(e,"rx",t.radius>0?String(t.radius):null);return}A(e,"href",t.href),A(e,"preserveAspectRatio",pn[t.fit])}var pn={cover:"xMidYMid slice",contain:"xMidYMid meet",fill:"none"};function hn(e,t){I(e,"opacity",t.opacity<1?String(t.opacity):null),A(e,"xml:space","preserve");let r=t.lines.flatMap(n=>n.spans).filter(n=>n.text!==""),i=e.ownerDocument;for(;e.childNodes.length>r.length;)e.lastChild?.remove();for(;e.childNodes.length<r.length;)e.appendChild(i.createElementNS(J,"tspan"));r.forEach((n,u)=>{let s=e.childNodes[u];s.textContent!==n.text&&(s.textContent=n.text),A(s,"x",String(n.x)),A(s,"y",String(n.y)),A(s,"font-family",n.style.family),A(s,"font-size",String(n.style.size)),A(s,"fill",n.style.fill),I(s,"font-weight",n.style.weight===400?null:String(n.style.weight)),I(s,"font-style",n.style.italic?"italic":null),I(s,"letter-spacing",n.style.letterSpacing===0?null:String(n.style.letterSpacing)),I(s,"data-vd-link",n.style.link??null);let m=[n.style.underline?"underline":"",n.style.strike?"line-through":""].filter(Boolean).join(" ");I(s,"text-decoration",m===""?null:m)})}function mn(e,t){I(e,"class",null),A(e,"x",String(t.x)),A(e,"y",String(t.y)),A(e,"width",String(t.w)),A(e,"height",String(t.h)),A(e,"fill",t.fill),I(e,"rx",t.radius>0?String(t.radius):null),I(e,"stroke",t.stroke??null),I(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),I(e,"opacity",t.opacity<1?String(t.opacity):null)}function At(e,t){A(e,"fill",t.fill),I(e,"stroke",t.stroke??null),I(e,"stroke-width",t.stroke&&t.strokeWidth>0?String(t.strokeWidth):null),I(e,"opacity",t.opacity<1?String(t.opacity):null)}function gn(e,t){A(e,"cx",String(t.x+t.w/2)),A(e,"cy",String(t.y+t.h/2)),A(e,"rx",String(t.w/2)),A(e,"ry",String(t.h/2)),At(e,t)}function yn(e,t){A(e,"d",t.d),At(e,t),I(e,"fill-rule",t.rule==="nonzero"?null:t.rule),I(e,"stroke-linecap",t.cap==="butt"?null:t.cap),I(e,"stroke-linejoin",t.join==="miter"?null:t.join)}function A(e,t,r){e.getAttribute(t)!==r&&e.setAttribute(t,r)}function I(e,t,r){r===null?e.hasAttribute(t)&&e.removeAttribute(t):A(e,t,r)}var wn=4;function xn(e,t,r){let i=e.rotation===0?t:Ie(t,{x:e.x+e.w/2,y:e.y+e.h/2},-e.rotation),n=i.x>=e.x&&i.x<=e.x+e.w&&i.y>=e.y&&i.y<=e.y+e.h;if(e.kind==="ellipse"){let u=e.stroke!==void 0?e.strokeWidth/2:0,s=e.w/2+u,m=e.h/2+u;if(s<=0||m<=0)return!1;let f=(i.x-(e.x+e.w/2))/s,g=(i.y-(e.y+e.h/2))/m;return f*f+g*g<=1}if(e.kind==="vector"){let u=e.stroke!==void 0&&e.strokeWidth>0;return nt(e.contours,i,{fill:e.fill!=="none",rule:e.rule,reach:(u?e.strokeWidth/2:0)+r})}return n}function xe(e,t){let r=new Map;for(let n of t.items)n.kind==="frame"&&n.w>0&&n.h>0&&r.set(n.id,{id:n.id,x:n.x,y:n.y,w:n.w,h:n.h});let i=e.root.children.flatMap(n=>{let u=n.type==="frame"?r.get(n.id):void 0;return u&&n.type==="frame"?[{...u,skip:n.skip===!0}]:[]});return i.length===0?[{id:null,x:t.x,y:t.y,w:t.width,h:t.height,skip:!1}]:i.every(n=>n.skip)?i.map(n=>({...n,skip:!1})):i}function Mt(e,t){return e.root.children.find(i=>i.type==="frame"&&Je(i,t)!==void 0)?.id}function Ot(e,t){let r=t===void 0?-1:e.findIndex(i=>i.id===t);return r!==-1?r:Math.max(0,e.findIndex(i=>!i.skip))}function ve(e,t,r){for(let i=t+r;i>=0&&i<e.length;i+=r)if(!e[i]?.skip)return i;return t}function Tt(e){return e.filter(t=>!t.skip).length}function He(e,t){return e[t]?.skip!==!1?null:e.slice(0,t+1).filter(r=>!r.skip).length}function _t(e,t){if(!/^\d+$/.test(e))return null;let r=Number(e),i=t.findIndex((n,u)=>He(t,u)===r);return i===-1?null:i}function Lt(e,t,r){let i=Mt(e,r),n=t.findIndex(u=>u.id!==null&&u.id===i);return n===-1?null:n}var vn="cubic-bezier(0.2, 0, 0, 1)",bn="cubic-bezier(0.4, 0, 1, 1)",Pt="cubic-bezier(0.4, 0, 0.2, 1)";function Ct(e,t,r,i,n){let u={opacity:r},s=En(e,t,i,n);if(e==="cut")return{keyframes:t==="enter"?[{visibility:"hidden"},{visibility:"hidden"}]:[{visibility:"visible"},{visibility:"visible"}],easing:"linear"};if(e==="pop"){let m=`${n.x}px ${n.y}px`;u.scale="1",u.transformOrigin=m}else(e==="rise"||e==="drop")&&(u.translate="0 0");return t==="enter"?{keyframes:[s,u],easing:vn}:{keyframes:[u,s],easing:bn}}function En(e,t,r,i){switch(e){case"rise":return{opacity:0,translate:`0 ${t==="enter"?r:-r}px`};case"drop":return{opacity:0,translate:`0 ${t==="enter"?-r:r}px`};case"pop":return{opacity:0,scale:String(.85),transformOrigin:`${i.x}px ${i.y}px`};case"fade":case"cut":return{opacity:0}}}function Dt(e,t){let r=t==="forward"?"-100%":"100%",i=t==="forward"?"100%":"-100%";switch(e){case"cut":return null;case"fade":return{still:[{opacity:1},{opacity:0}],live:null,stillOnTop:!0};case"push":return{still:[{translate:"0 0"},{translate:`${r} 0`}],live:[{translate:`${i} 0`},{translate:"0 0"}],stillOnTop:!1};case"slide":return t==="forward"?{still:null,live:[{translate:"100% 0"},{translate:"0 0"}],stillOnTop:!1}:{still:[{translate:"0 0"},{translate:"100% 0"}],live:null,stillOnTop:!0}}}var Sn={enter:"cut",duration:0,steps:[[]],clicks:new Map,scroll:!1};function je(e){let t=new Map,r=new Map,i=new Map;Xe(e.root,(m,f)=>{f&&(r.set(m.id,f.id),i.set(f.id,[...i.get(f.id)??[],m.id]))});let n=tt(e),u=et(e);for(let[m,f]of Object.entries(e.motion??{})){if(!u.has(m))continue;let g=[[]],l=new Map;for(let p of f.lines){if(p.id===m||n.get(p.id)!==m)continue;let M=p.go===void 0?void 0:Qe(p.go);M&&l.set(p.id,M);let S=p.enter!==void 0?"enter":p.exit!==void 0?"exit":null,O=p.enter??p.exit;S===null||O===void 0||(p.step&&g.push([]),g.at(-1).push({id:p.id,kind:S,effect:O,duration:O==="cut"?0:p.duration??Fe,delay:p.delay??0,together:p.together===!0}))}t.set(m,{enter:f.enter??"cut",duration:f.duration??Fe,steps:g,clicks:l,scroll:f.scroll===!0})}let s=m=>[m,...(i.get(m)??[]).flatMap(f=>s(f))];return{pages:t,parents:r,within:s}}function Ft(e,t){let r=t?.id;return(r?e.pages.get(r):void 0)??Sn}function Ue(e){let t=0,r=0;return e.map((i,n)=>(t=(n===0?0:i.together?t:r)+i.delay,r=t+i.duration,{build:i,at:t}))}function It(e){return Math.max(0,...Ue(e).map(({build:t,at:r})=>r+t.duration))}function me(e,t){let r=new Set,i=new Set;for(let n of e.steps.flat())i.has(n.id)||(i.add(n.id),n.kind==="enter"&&r.add(n.id));for(let n of e.steps.slice(0,t).flat())n.kind==="enter"?r.delete(n.id):r.add(n.id);return r}function Nt(e,t,r){for(let i=r;i!==void 0;i=e.parents.get(i)){let n=t.clicks.get(i);if(n)return{id:i,target:n}}}function zt(e,t,r){let i=[...e];for(;i.length>0;){let n=i.pop(),u=t.findIndex(s=>s.id!==null&&s.id===n);if(u!==-1&&u!==r)return{index:u,history:i}}return null}function Vt(e,t,r){let i=Se(t.width/Math.max(1,e.w));if(e.h*i<=t.height)return{camera:de({x:e.x,y:e.y,width:e.w,height:e.h},t,0),top:0,max:0};let n=e.h-t.height/i,u=Math.min(Math.max(0,r),n),s=(t.width-e.w*i)/2-e.x*i;return{camera:{zoom:i,x:s,y:0-(e.y+u)*i},top:u,max:n}}var Me=.9,Ke=.1;function Rt(e,t){return e.deltaMode===1?e.deltaY*16:e.deltaMode===2?e.deltaY*t.height:e.deltaY}var An=1500,Mn=2e3,On=200,Tn=50;function We(e,t){let r=e.ownerDocument;e.classList.add("vd-player"),e.tabIndex=-1;let i=new Set,n=new Set,u=!1,s=Ae(e,{document:t.document,interactive:!1,surface:"#000",...t.fonts?{fonts:t.fonts}:{},...t.loadFont?{loadFont:t.loadFont}:{},...t.resolveAsset?{resolveAsset:t.resolveAsset}:{},onSceneChange:()=>{u&&K()}}),m=r.createElementNS(J,"path");m.setAttribute("class","vd-player__mask"),m.setAttribute("fill","#000"),m.setAttribute("fill-rule","evenodd"),s.surface.appendChild(m);let f=r.createElement("div");f.className="vd-player__counter",f.setAttribute("aria-live","polite"),e.appendChild(f);let g=je(t.document),l=xe(t.document,s.getScene()),p=Ot(l,t.start),M=[],S=0,O=[],w,N=0,_="",x=0,R=0,X=1,z=new Map,G,C=0,j,Y,Z=r.defaultView,te=()=>typeof s.surface.animate=="function"&&!(Z?.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1),$=()=>Ft(g,l[p]);function Q(){let o=e.getBoundingClientRect(),c=l[p];return{width:o.width||c?.w||1,height:o.height||c?.h||1}}function B(){let o=l[p];if(!o)return;let c=Q(),h=de({x:o.x,y:o.y,width:o.w,height:o.h},c,0);if(R=0,$().scroll){let q=Vt(o,c,x);h=q.camera,x=q.top,R=q.max}X=h.zoom,s.setCamera(h);let T=o.x*h.zoom+h.x,D=o.y*h.zoom+h.y,F=o.w*h.zoom,U=o.h*h.zoom;m.setAttribute("d",`M0 0H${c.width}V${c.height}H0ZM${T} ${D}h${F}v${U}h${-F}Z`),m.dataset.slide=o.id??""}function fe(){let o=He(l,p),c=Tt(l);f.textContent=o===null?"Skipped":`${o} / ${c}`,f.classList.add("vd-player__counter--shown"),j&&clearTimeout(j),j=setTimeout(()=>f.classList.remove("vd-player__counter--shown"),An),t.onChange?.(o,c)}function K(){let o=new Set;for(let c of i)for(let h of g.within(c))o.add(h);n=o;for(let c of s.surface.querySelectorAll("[data-vd-hidden]")){let h=c.getAttribute("data-vd-id");(h===null||!o.has(h))&&c.removeAttribute("data-vd-hidden")}for(let c of o)s.elementOf(c)?.setAttribute("data-vd-hidden","")}function ge(o){return g.within(o).flatMap(c=>{let h=s.elementOf(c);return h?[h]:[]})}function pe(o){let c=1/0,h=1/0,T=-1/0,D=-1/0;for(let F of g.within(o)){let U=s.itemOf(F);U&&(c=Math.min(c,U.x),h=Math.min(h,U.y),T=Math.max(T,U.x+U.w),D=Math.max(D,U.y+U.h))}return Number.isFinite(c)?{x:(c+T)/2,y:(h+D)/2}:{x:0,y:0}}function ne(){if(!(O.length===0&&!w)){N+=1,S===0&&(S=1),i=me($(),S),K();for(let o of O)o.cancel();O=[],w?.remove(),w=void 0}}function W(){return O.length===0&&!w?!1:(ne(),!0)}function re(o,c){return new Promise(h=>{let T=!1,D=()=>{T||(T=!0,h())};Promise.all(o.map(F=>F.finished)).then(D,()=>{T=!0}),setTimeout(()=>{if(!T){for(let F of o)(F.playState==="running"||F.playState==="paused")&&F.finish();D()}},c+Tn)})}function se(o,c,h){if(o===p||!l[o])return;let T=$(),D=l[p]?.id;D&&z.set(D,G===void 0?x:C),v(),p=o;let F=$(),U=l[o]?.id;x=c||!U?0:z.get(U)??0;let q=h==="forward"?F:T,P=te()?Dt(q.enter,h):null;if(P&&(w=s.surface.cloneNode(!0),w.classList.add("vd-player__still"),w.setAttribute("aria-hidden","true"),P.stillOnTop?s.surface.after(w):s.surface.before(w)),B(),S=c?0:F.steps.length,i=me(F,S),K(),fe(),!P||!w){c&&a();return}let be={duration:q.duration,easing:Pt},le=[];P.still&&le.push(w.animate(P.still,{...be,fill:"forwards"})),P.live&&le.push(s.surface.animate(P.live,be)),O.push(...le);let he=N;re(le,q.duration).then(()=>{if(he===N){O=O.filter(ue=>!le.includes(ue));for(let ue of le)ue.cancel();w?.remove(),w=void 0,c&&a()}})}function a(){let o=$(),c=o.steps[S];if(c===void 0)return;S+=1;let h=me(o,S);if(c.length===0)return;if(!te()){i=h,K();return}let T=new Set(c.filter(P=>P.kind==="enter").map(P=>P.id));i=new Set([...me(o,S-1)].filter(P=>!T.has(P))),K();let D=l[p],F=.04*Math.min(D?.w??0,D?.h??0),U=N,q=[];for(let{build:P,at:be}of Ue(c)){let le=pe(P.id),he=[];for(let ue of ge(P.id)){let Ze=Number(ue.getAttribute("opacity")??1),{keyframes:Yt,easing:Zt}=Ct(P.effect,P.kind,Number.isFinite(Ze)?Ze:1,F,le);he.push(ue.animate(Yt,{duration:P.duration,delay:be,easing:Zt,fill:P.kind==="enter"?"backwards":"forwards"}))}q.push(...he),P.kind==="exit"&&he.length>0&&re(he,be+P.duration).then(()=>{if(U===N){i.add(P.id),K();for(let ue of he)ue.cancel()}})}O.push(...q),re(q,It(c)).then(()=>{if(U===N){O=O.filter(P=>!q.includes(P)),i=h,K();for(let P of q)P.cancel()}})}function v(){G!==void 0&&Z?.cancelAnimationFrame(G),G=void 0}function L(o){if(v(),C=Math.min(Math.max(0,o),R),!te()||!Z?.requestAnimationFrame){x=C,B();return}let c=x,h,T=D=>{h??=D;let F=Math.min(1,(D-h)/On);x=c+(C-c)*(1-(1-F)**3),B(),G=F<1?Z.requestAnimationFrame(T):void 0};G=Z.requestAnimationFrame(T)}function E(o,c){if(W())return;let h=G===void 0?x:C;if(!(o>0?x>=R-.5:x<=.5)){L(h+o*Q().height/X);return}c||(o>0?d():y())}function b(o){if(!(!$().scroll||R<=0))switch(o.key){case" ":return o.shiftKey?-Me:Me;case"PageDown":return Me;case"PageUp":return-Me;case"ArrowDown":return Ke;case"ArrowUp":return-Ke;default:return}}function H(o){let c=Math.min(Math.max(0,o),l.length-1);if(c===p)return;let h=l[p]?.id;h&&M.push(h),se(c,!0,"forward")}function d(){if(!W()){if(S<$().steps.length){a();return}H(ve(l,p,1))}}function y(){if(W())return;let o=zt(M,l,p);if(o){M=o.history,se(o.index,!1,"back");return}se(ve(l,p,-1),!1,"back")}function k(o){switch(o.kind){case"url":t.onLink?.(o.url);return;case"back":y();return;case"next":H(ve(l,p,1));return;case"frame":{let c=Lt(s.getDocument(),l,o.id);c===null?d():V(c,o.id)}}}function V(o,c){let h=o===p;h||H(o);let T=l[p];if(!T||!$().scroll)return;let D=T.id===c?void 0:s.itemOf(c),F=D?D.y-T.y:0;h?L(F):(x=F,B())}function ie(o){let c=l[p];if(!c||o.x<c.x||o.y<c.y||o.x>c.x+c.w||o.y>c.y+c.h)return;let h=U=>!n.has(U),T=s.hitTest(o,h),D=T===null?void 0:Nt(g,$(),T);if(D)return D.target;let F=s.linkAt(o,h);return F===void 0?void 0:Te(F)}let oe=o=>{if(o.stopPropagation(),o.metaKey||o.ctrlKey||o.altKey)return;let c=o.key,h=b(o);if(h!==void 0){_="",E(h,o.repeat),o.preventDefault();return}if(/^\d$/.test(c))_+=c;else if(c==="Enter"&&_!==""){let T=_t(_,l);_="",!W()&&T!==null&&H(T)}else if(c==="Escape")_!==""?_="":t.onExit?.();else if(["ArrowRight","ArrowDown","PageDown"," ","Enter"].includes(c))_="",d();else if(["ArrowLeft","ArrowUp","PageUp","Backspace"].includes(c))_="",y();else if(c==="Home")W()||H(ve(l,-1,1));else if(c==="End")W()||H(ve(l,l.length,-1));else return;o.preventDefault()},ee=o=>{if(W())return;let c=ie(s.screenToDocument(s.pointerPoint(o)));c?k(c):d()},ye=o=>{!$().scroll||R<=0||(o.preventDefault(),!(w||o.ctrlKey||o.metaKey)&&(v(),x=Math.min(Math.max(0,x+Rt(o,Q())/X),R),B()))},we=o=>{if(e.classList.remove("vd-player--idle"),Y&&clearTimeout(Y),Y=setTimeout(()=>e.classList.add("vd-player--idle"),Mn),!o)return;let c=s.screenToDocument(s.pointerPoint(o));e.classList.toggle("vd-player--link",ie(c)!==void 0)},ae=Z&&"ResizeObserver"in Z?new Z.ResizeObserver(()=>B()):void 0;return ae?.observe(e),e.addEventListener("keydown",oe),e.addEventListener("click",ee),e.addEventListener("pointermove",we),e.addEventListener("wheel",ye,{passive:!1}),u=!0,B(),i=me($(),0),K(),fe(),we(),e.focus({preventScroll:!0}),a(),{viewer:s,index:()=>p,count:()=>l.length,next:d,back:y,go(o){ne(),H(o)},update(o){if(o===s.getDocument())return;ne();let c=l[p]?.id;s.update(o),g=je(o),l=xe(o,s.getScene());let h=l.findIndex(T=>T.id===c);p=h===-1?Math.min(p,l.length-1):h,h===-1&&(v(),x=0),B(),S=$().steps.length,i=me($(),S),K()},refit:B,destroy(){N+=1,v();for(let o of O)o.cancel();O=[],w?.remove(),ae?.disconnect(),e.removeEventListener("wheel",ye),e.removeEventListener("keydown",oe),e.removeEventListener("click",ee),e.removeEventListener("pointermove",we),j&&clearTimeout(j),Y&&clearTimeout(Y),m.remove(),f.remove(),s.destroy(),e.classList.remove("vd-player","vd-player--idle","vd-player--link"),e.removeAttribute("tabindex")}}}function $t(e){let t=e,r=new Map,i=typeof URL.createObjectURL=="function"&&typeof URL.revokeObjectURL=="function";return{resolve(n){let u=r.get(n.hash);if(u!==void 0)return u;let s=t.get(n.hash);if(s===void 0)return;if(!i)return rt(n.type,s);let m;try{m=it(s)}catch{return}let f=URL.createObjectURL(new Blob([m],{type:n.type}));return r.set(n.hash,f),f},replace(n){t=n;for(let[u,s]of r)n.has(u)||(URL.revokeObjectURL(s),r.delete(u))},destroy(){for(let n of r.values())URL.revokeObjectURL(n);r.clear(),t=new Map}}}var Ge=["page","content","none"],Bt=24;function Oe(e){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}function Ht(e,t){let r=t===void 0?void 0:e.itemOf(t);if(!(!r||r.w<=0||r.h<=0))return{x:r.x,y:r.y,width:r.w,height:r.h}}function jt(e,t,r,i){if(r==="none")return;let n=r==="page"?Ht(e,i):void 0;if(!n){e.fitToContent(Bt);return}let u=Oe(t);e.setCamera(de(n,{width:u.width||n.width,height:u.height||n.height},Bt))}function Ut(e,t,r){let i=Ht(e,r);if(!i)return;let n=e.getCamera(),u=Oe(t),s=u.width||i.width*n.zoom,m=u.height||i.height*n.zoom;e.setCamera({zoom:n.zoom,x:s/2-(i.x+i.width/2)*n.zoom,y:m/2-(i.y+i.height/2)*n.zoom})}var Ye=Symbol.for("vdesign.embed.handover");function Kt(e){return e[Ye]}var Wt=["exact","browser"],Gt=["ready","problems","page","fonts"];async function _n(e,t){try{let{exactFontsAt:r}=await import("./chunks/fonts.js"),i=r(e);return(await i.ensure(t)).length===0?i:void 0}catch{return}}async function Pr(e,t,r={}){let i=r.fit??"page";if(!Ge.includes(i))throw new TypeError(`view: fit must be one of ${Ge.join(", ")}; got ${String(i)}.`);let n=r.fonts??"exact";if(!Wt.includes(n))throw new TypeError(`view: fonts must be one of ${Wt.join(", ")}; got ${String(n)}.`);let u=n==="exact"?pt(r.fontBase,qe,e.ownerDocument.baseURI):void 0,s=Kt(r),m=await ze(t),f=s?.page!==void 0&&ce(m.document).some(d=>d.id===s.page)?s.page:r.page===void 0?ce(m.document)[0]?.id:Ee(m.document,r.page).id,g=s?.exact&&u?await _n(u,m.document):void 0,l=e.ownerDocument,p=l.defaultView,M=$t(m.blocks),S=m.blocks,O=[...m.problems],w,N=()=>w?[...O,w]:[...O],_=l.createElement("div");_.className="vd-embed",_.style.width="100%",_.style.height="100%",e.appendChild(_);let x=Ae(_,{document:m.document,interactive:r.interactive??!0,wheel:"modifier",resolveAsset:d=>M.resolve(d),...r.surface?{surface:r.surface}:{},...s?{camera:s.camera}:{},...g?{fonts:g.library}:{}}),R={ready:new Set,problems:new Set,page:new Set,fonts:new Set},X=!1,z=!1,G=0,C,j,Y=g,Z=n==="browser"?"browser":void 0,te;function $(){X=!0;for(let d of R.ready)d()}function Q(){for(let d of R.problems)d(N())}function B(d){Z=d;for(let y of R.fonts)y(d)}function fe(){return te??=(async()=>{if(u)try{let{exactFontsAt:d}=await import("./chunks/fonts.js");return d(u)}catch{return}})(),te}function K(d){Y=void 0,x.setFonts(void 0),C?.fonts(void 0),w=d,Q(),B("browser")}async function ge(){let d=await fe();if(!z){if(!d){K(Le([],u?"the fonts chunk would not load":"no fontBase was given and this build has no default"));return}for(;;){let y=x.getDocument(),k=await d.ensure(y);if(z)return;if(k.length>0){K(Le(k));return}if(x.getDocument()===y)break}Y=d,x.setFonts(d.library),C?.fonts(d),B("exact")}}function pe(){let d=ne(f);if(d)for(let y of R.page)y(d)}function ne(d){let y=ce(x.getDocument()).find(k=>k.id===d);if(y)return y.name===void 0?{id:y.id}:{id:y.id,name:y.name}}let W=()=>jt(x,_,i,f),re=()=>Ut(x,_,f);function se(d){if(z)return;let y=Ee(x.getDocument(),d).id,k=y!==f;f=y,i==="page"?W():re(),k&&pe()}function a(d){r.onLink?r.onLink(d):p?.open(d,"_blank","noopener,noreferrer")}let v=d=>{if(d.button!==0||C)return;let y=x.linkAt(x.screenToDocument(x.pointerPoint(d)));if(y===void 0)return;let k=Te(y);if(k){if(d.preventDefault(),k.kind==="frame"){ce(x.getDocument()).some(V=>V.id===k.id)&&se(k.id);return}a(k.url)}};_.addEventListener("click",v);let L=Oe(_),E=p&&"ResizeObserver"in p?new p.ResizeObserver(()=>{let d=Oe(_);d.width===L.width&&d.height===L.height||(L=d,W())}):void 0;E?.observe(_),s||(i==="none"&&f!==void 0&&r.page!==void 0?re():W()),$(),g?B("exact"):n==="exact"&&ge();let b={async load(d){if(z)throw new Error("view: this view was destroyed.");let y=++G,k=await ze(d),V=Y,ie=V?await V.ensure(k.document):[];if(j&&await j||z||y!==G)return;ie.length>0&&Y===V&&K(Le(ie)),M.replace(k.blocks),S=k.blocks,x.update(k.document),O=[...k.problems],C?.update(k.document),ce(k.document).some(ee=>ee.id===f)||(f=ce(k.document)[0]?.id,i==="page"?W():re(),pe()),Q(),$()},pages:()=>ce(x.getDocument()).map(d=>d.name===void 0?{id:d.id}:{id:d.id,name:d.name}),goTo:se,fit:()=>{z||W()},play(d={}){if(z)return Promise.reject(new Error("view: this view was destroyed."));try{return C?.stop(),Promise.resolve(H(x.getDocument(),d.page))}catch(y){return Promise.reject(y instanceof Error?y:new Error(String(y)))}},async edit(d={}){if(z)throw new Error("view: this view was destroyed.");if(j)throw new Error("view: edit() is already opening an editor.");let y;j=new Promise(V=>y=V);let k=!1;try{let{edit:V}=await import("./edit.js");if(z)throw new Error("view: this view was destroyed.");let ie={camera:x.getCamera(),page:f,exact:Y!==void 0},oe=ut(x.getDocument(),S,O),ee=await V(e,oe,{...r,...d,[Ye]:ie});if(z)throw ee.destroy(),new Error("view: this view was destroyed.");return k=!0,b.destroy(),ee}finally{j=void 0,y(k)}},on(d,y){if(!Gt.includes(d))throw new TypeError(`view: on() takes one of ${Gt.join(", ")}; got ${String(d)}.`);let k=R[d];if(k.add(y),d==="ready"&&X&&queueMicrotask(()=>{k.has(y)&&y()}),d==="problems"&&queueMicrotask(()=>{k.has(y)&&y(N())}),d==="fonts"&&Z!==void 0){let V=Z;queueMicrotask(()=>{k.has(y)&&y(V)})}return()=>{k.delete(y)}},destroy(){if(!z){z=!0,C?.stop(),_.removeEventListener("click",v),E?.disconnect(),x.destroy(),M.destroy(),_.remove();for(let d of Object.values(R))d.clear()}}};function H(d,y){let k=y===void 0?f:Ee(d,y).id,V=l.createElement("div");V.className="vd-embed__play",V.style.position="absolute",V.style.inset="0";let ie=o=>o.stopPropagation();V.addEventListener("wheel",ie);let oe=l.activeElement;_.appendChild(V);let ee=!1,ye=()=>{if(ee)return;ee=!0,C===we&&(C=void 0),ae.destroy(),V.removeEventListener("wheel",ie);let o=V.contains(l.activeElement);V.remove(),o&&oe&&"focus"in oe&&typeof oe.focus=="function"&&oe.focus({preventScroll:!0})},we={stop:ye,update:o=>ae.update(o),fonts:o=>ae.viewer.setFonts(o?.library)},ae=We(V,{document:d,resolveAsset:o=>M.resolve(o),...Y?{fonts:Y.library}:{},...k===void 0?{}:{start:k},onExit:ye,onLink:a});return C=we,{goTo(o){if(ee)return;let c=ae.viewer.getDocument(),h=Ee(c,o).id,T=xe(c,ae.viewer.getScene()).findIndex(D=>D.id===h);T!==-1&&ae.go(T)},destroy:ye}}return b}export{qt as version,Pr as view};
|
package/fonts.css
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* Inter, for the drawings the Markdown entries write. SIL Open Font License: fonts/OFL.txt. */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: Inter;
|
|
4
|
+
font-style: normal;
|
|
5
|
+
font-weight: 900;
|
|
6
|
+
font-display: swap;
|
|
7
|
+
src: url('fonts/Inter-Black.woff2') format('woff2');
|
|
8
|
+
}
|
|
9
|
+
@font-face {
|
|
10
|
+
font-family: Inter;
|
|
11
|
+
font-style: italic;
|
|
12
|
+
font-weight: 900;
|
|
13
|
+
font-display: swap;
|
|
14
|
+
src: url('fonts/Inter-BlackItalic.woff2') format('woff2');
|
|
15
|
+
}
|
|
16
|
+
@font-face {
|
|
17
|
+
font-family: Inter;
|
|
18
|
+
font-style: normal;
|
|
19
|
+
font-weight: 700;
|
|
20
|
+
font-display: swap;
|
|
21
|
+
src: url('fonts/Inter-Bold.woff2') format('woff2');
|
|
22
|
+
}
|
|
23
|
+
@font-face {
|
|
24
|
+
font-family: Inter;
|
|
25
|
+
font-style: italic;
|
|
26
|
+
font-weight: 700;
|
|
27
|
+
font-display: swap;
|
|
28
|
+
src: url('fonts/Inter-BoldItalic.woff2') format('woff2');
|
|
29
|
+
}
|
|
30
|
+
@font-face {
|
|
31
|
+
font-family: Inter;
|
|
32
|
+
font-style: normal;
|
|
33
|
+
font-weight: 800;
|
|
34
|
+
font-display: swap;
|
|
35
|
+
src: url('fonts/Inter-ExtraBold.woff2') format('woff2');
|
|
36
|
+
}
|
|
37
|
+
@font-face {
|
|
38
|
+
font-family: Inter;
|
|
39
|
+
font-style: italic;
|
|
40
|
+
font-weight: 800;
|
|
41
|
+
font-display: swap;
|
|
42
|
+
src: url('fonts/Inter-ExtraBoldItalic.woff2') format('woff2');
|
|
43
|
+
}
|
|
44
|
+
@font-face {
|
|
45
|
+
font-family: Inter;
|
|
46
|
+
font-style: normal;
|
|
47
|
+
font-weight: 200;
|
|
48
|
+
font-display: swap;
|
|
49
|
+
src: url('fonts/Inter-ExtraLight.woff2') format('woff2');
|
|
50
|
+
}
|
|
51
|
+
@font-face {
|
|
52
|
+
font-family: Inter;
|
|
53
|
+
font-style: italic;
|
|
54
|
+
font-weight: 200;
|
|
55
|
+
font-display: swap;
|
|
56
|
+
src: url('fonts/Inter-ExtraLightItalic.woff2') format('woff2');
|
|
57
|
+
}
|
|
58
|
+
@font-face {
|
|
59
|
+
font-family: Inter;
|
|
60
|
+
font-style: italic;
|
|
61
|
+
font-weight: 400;
|
|
62
|
+
font-display: swap;
|
|
63
|
+
src: url('fonts/Inter-Italic.woff2') format('woff2');
|
|
64
|
+
}
|
|
65
|
+
@font-face {
|
|
66
|
+
font-family: Inter;
|
|
67
|
+
font-style: normal;
|
|
68
|
+
font-weight: 300;
|
|
69
|
+
font-display: swap;
|
|
70
|
+
src: url('fonts/Inter-Light.woff2') format('woff2');
|
|
71
|
+
}
|
|
72
|
+
@font-face {
|
|
73
|
+
font-family: Inter;
|
|
74
|
+
font-style: italic;
|
|
75
|
+
font-weight: 300;
|
|
76
|
+
font-display: swap;
|
|
77
|
+
src: url('fonts/Inter-LightItalic.woff2') format('woff2');
|
|
78
|
+
}
|
|
79
|
+
@font-face {
|
|
80
|
+
font-family: Inter;
|
|
81
|
+
font-style: normal;
|
|
82
|
+
font-weight: 500;
|
|
83
|
+
font-display: swap;
|
|
84
|
+
src: url('fonts/Inter-Medium.woff2') format('woff2');
|
|
85
|
+
}
|
|
86
|
+
@font-face {
|
|
87
|
+
font-family: Inter;
|
|
88
|
+
font-style: italic;
|
|
89
|
+
font-weight: 500;
|
|
90
|
+
font-display: swap;
|
|
91
|
+
src: url('fonts/Inter-MediumItalic.woff2') format('woff2');
|
|
92
|
+
}
|
|
93
|
+
@font-face {
|
|
94
|
+
font-family: Inter;
|
|
95
|
+
font-style: normal;
|
|
96
|
+
font-weight: 400;
|
|
97
|
+
font-display: swap;
|
|
98
|
+
src: url('fonts/Inter-Regular.woff2') format('woff2');
|
|
99
|
+
}
|
|
100
|
+
@font-face {
|
|
101
|
+
font-family: Inter;
|
|
102
|
+
font-style: normal;
|
|
103
|
+
font-weight: 600;
|
|
104
|
+
font-display: swap;
|
|
105
|
+
src: url('fonts/Inter-SemiBold.woff2') format('woff2');
|
|
106
|
+
}
|
|
107
|
+
@font-face {
|
|
108
|
+
font-family: Inter;
|
|
109
|
+
font-style: italic;
|
|
110
|
+
font-weight: 600;
|
|
111
|
+
font-display: swap;
|
|
112
|
+
src: url('fonts/Inter-SemiBoldItalic.woff2') format('woff2');
|
|
113
|
+
}
|
|
114
|
+
@font-face {
|
|
115
|
+
font-family: Inter;
|
|
116
|
+
font-style: normal;
|
|
117
|
+
font-weight: 100;
|
|
118
|
+
font-display: swap;
|
|
119
|
+
src: url('fonts/Inter-Thin.woff2') format('woff2');
|
|
120
|
+
}
|
|
121
|
+
@font-face {
|
|
122
|
+
font-family: Inter;
|
|
123
|
+
font-style: italic;
|
|
124
|
+
font-weight: 100;
|
|
125
|
+
font-display: swap;
|
|
126
|
+
src: url('fonts/Inter-ThinItalic.woff2') format('woff2');
|
|
127
|
+
}
|