@holistics/anfra-sdk 0.13.4 → 0.14.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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/api.d.ts +1 -1
  3. package/dist/app.d.ts +5 -4
  4. package/dist/app.js +17 -7
  5. package/dist/{bootstrap-DctKHBAj.d.ts → bootstrap-MhTSkiA1.d.ts} +97 -4
  6. package/dist/build.d.ts +2 -0
  7. package/dist/chunk-7IHICYVH.js +10 -0
  8. package/dist/chunk-CYZQ7ZTJ.js +237 -0
  9. package/dist/chunk-DITKCHFQ.js +166 -0
  10. package/dist/chunk-F6MRA7J4.js +65 -0
  11. package/dist/chunk-GBXK7F2V.js +431 -0
  12. package/dist/chunk-GOUDXWG4.js +750 -0
  13. package/dist/chunk-GV7SVWEK.js +84 -0
  14. package/dist/chunk-H52PO7MP.js +105 -0
  15. package/dist/chunk-HI3ZAXJK.js +8 -0
  16. package/dist/{chunk-ZHIDMLJH.js → chunk-HZEECB6R.js} +477 -25
  17. package/dist/chunk-K633QHGO.js +51 -0
  18. package/dist/chunk-KFD6CHLI.js +38 -0
  19. package/dist/{chunk-2Q4HPPUK.js → chunk-NOFPRSSI.js} +1 -1
  20. package/dist/{chunk-ADWBOQW2.js → chunk-S6XLP6U4.js} +31 -1
  21. package/dist/{chunk-TQ7S5DRE.js → chunk-WI5VJ2Z6.js} +1 -1
  22. package/dist/common.d.ts +2 -2
  23. package/dist/common.js +14 -4
  24. package/dist/data-UCCW2VWH.js +233 -0
  25. package/dist/declaration-GVDOGQY6.js +218 -0
  26. package/dist/host.d.ts +42 -4
  27. package/dist/host.js +412 -9
  28. package/dist/menu-CdGVKc4_.d.ts +151 -0
  29. package/dist/overview-3DNXEQNY.js +358 -0
  30. package/dist/plugin-BmIDirTx.d.ts +303 -0
  31. package/dist/plugins.d.ts +6 -8
  32. package/dist/plugins.js +98 -69
  33. package/dist/queries-2OHKMTPC.js +661 -0
  34. package/dist/structure-WRDUXHD4.js +256 -0
  35. package/dist/tab-HMQOITVM.js +932 -0
  36. package/dist/testing.js +4 -4
  37. package/dist/{types-B9DqPgWS.d.ts → types-CWNv6N0y.d.ts} +10 -0
  38. package/package.json +1 -1
  39. package/dist/bridge-_Ez5VZV9.d.ts +0 -73
  40. package/dist/chunk-33B2D4U5.js +0 -6
  41. package/dist/plugin-056-SKwd.d.ts +0 -132
  42. /package/dist/{chunk-52LXBYQM.js → chunk-UUKXJSE4.js} +0 -0
@@ -0,0 +1,303 @@
1
+ import { L as InspectedApp, Q as InspectedStructure, Z as LocateTarget, aj as User, D as DatasetDescriptor } from './types-CWNv6N0y.js';
2
+ import { c as MenuTargetKind, b as MenuTarget, d as PluginInfo, g as Theme } from './menu-CdGVKc4_.js';
3
+
4
+ /**
5
+ * The panel: one per mounted Data App, the host's devtools over it. The runtime owns its state (open
6
+ * or not, the tab it shows, the node selected, the frame's last snapshot, pick mode) and the frame
7
+ * side it needs (`anfra.*`), so every host's panel has them whatever plugins it installs. The host
8
+ * draws the panel's chrome itself; plugins add its tabs (docs/designs/sdk-plugins.md, The panel).
9
+ */
10
+
11
+ /** What the frame says while the panel is open: every app's state, and the page's structure. No rows. */
12
+ interface Snapshot {
13
+ apps: InspectedApp[];
14
+ structure: InspectedStructure;
15
+ }
16
+ /** One mounted Data App's panel. Read its state, change it, and subscribe to hear of each change. */
17
+ interface Panel {
18
+ /** Whether the panel is open. The frame posts snapshots only while it is. */
19
+ readonly open: boolean;
20
+ /** The tab it shows, by full id; undefined until one is chosen. */
21
+ readonly tab: string | undefined;
22
+ /** The node every tab is about, by its key in the snapshot's structure; null for none. */
23
+ readonly selection: string | null;
24
+ /** The frame's last snapshot while open; undefined until it reports, and once closed. */
25
+ readonly snapshot: Snapshot | undefined;
26
+ /** Whether pick mode is on: pointing at the page outlines marked elements, and a click selects one. */
27
+ readonly picking: boolean;
28
+ /** Open the panel, at `tab` if given (else the last one), with `target` selected if given. */
29
+ show: (tab?: string, target?: string | null) => void;
30
+ /** Close the panel: ends pick mode and clears the selection. */
31
+ hide: () => void;
32
+ /** Open the panel at `tab`, or close it when it is already open there (or anywhere, with no tab). */
33
+ toggle: (tab?: string) => void;
34
+ /** Select a node, by key, or none. */
35
+ select: (node: string | null) => void;
36
+ /** Show a node on the page, by key, or nothing. */
37
+ highlight: (node: string | null) => void;
38
+ /** Scroll a node, or an entity wherever it is drawn, into view, and hold the highlight on it. */
39
+ locate: (target: LocateTarget) => void;
40
+ /** Turn pick mode on or off. A pick selects the node and ends the mode; Escape in the frame ends it. */
41
+ pick: (on: boolean) => void;
42
+ /** Each change to any of the above. Returns the function that stops listening. */
43
+ subscribe: (listener: () => void) => () => void;
44
+ /**
45
+ * Draw a tab, by full id, into `element` (in its shadow root, made if it has none), where the host
46
+ * placed it in its chrome. Returns the function that takes the tab down again.
47
+ */
48
+ mountTab: (id: string, element: HTMLElement) => () => void;
49
+ }
50
+
51
+ /**
52
+ * Contributions: the UI a plugin, or the host itself, adds to the host page, as data each host
53
+ * renders in its own chrome. A command is something to run (from the host's action bar, its command
54
+ * palette, a shortcut); a tab is a view in the mount's panel. Plugins never name a host's layout:
55
+ * where each one goes, and how it looks, is the host's (docs/designs/sdk-plugins.md, Plugin UI).
56
+ */
57
+
58
+ /** What running a command does: make a call, or open the panel at a tab (toggling it). */
59
+ type CommandRun =
60
+ /** A call by its full name, made as the command's plugin (or the host), about the mount. */
61
+ {
62
+ call: string;
63
+ request?: unknown;
64
+ }
65
+ /** Open the panel at this tab, by its full id, with `target` (a node's key) selected if given. */
66
+ | {
67
+ tab: string;
68
+ target?: string | null;
69
+ };
70
+ /** How a command shows right now. */
71
+ interface CommandState {
72
+ /** Shown as on, such as a panel's command while the panel is open. */
73
+ pressed?: boolean;
74
+ /** Shown as off, with this reason (a tooltip): a command that can't run always says why. */
75
+ disabled?: string;
76
+ }
77
+ /** What a command's `state` gets: the mount it is about, and its panel. */
78
+ interface CommandStateContext {
79
+ readonly mount: MountContext;
80
+ readonly panel: Panel;
81
+ }
82
+ interface CommandContribution {
83
+ /** Under its plugin's name once installed (`toggle` is `inspect.toggle`); a host's own, as given. */
84
+ id: string;
85
+ /** Its label, and its entry in a command palette. */
86
+ title: string;
87
+ /** A short name for an icon (`inspect`, `download`, `comment`), which the host maps to its own. */
88
+ icon?: string;
89
+ /** A hint for the host: `primary` for its action bar, `overflow` for a menu. A host may ignore it. */
90
+ placement?: 'primary' | 'overflow';
91
+ /** A key combination, `Alt+Shift+I`: modifiers (`Ctrl`, `Alt`, `Shift`, `Meta`) then a key. */
92
+ shortcut?: string;
93
+ run: CommandRun;
94
+ /**
95
+ * Set, the command is for the menu on the page's content instead of the host's chrome: on a marked
96
+ * block (`node`) or on a query's rows (`rows`, from the definition's `query.menu`). It runs with
97
+ * that target: a call gets it as `target` in its request, a tab is opened with the node selected.
98
+ */
99
+ target?: MenuTargetKind;
100
+ /**
101
+ * For a command with a `target`: whether it applies to this one. The target comes from the frame
102
+ * and is checked only for its shape: decide on it, never trust it.
103
+ */
104
+ when?: (target: MenuTarget, context: CommandStateContext) => boolean;
105
+ /**
106
+ * How it shows now, read again on each change the plugin signals (`MountContext.commandsChanged`)
107
+ * and on each change to the panel. Unless given, a command that opens a tab is pressed while the
108
+ * panel shows one of its plugin's tabs (or that tab, for the host's own).
109
+ */
110
+ state?: (context: CommandStateContext, target?: MenuTarget) => CommandState;
111
+ }
112
+ /** What a tab gets: its panel, its calls, and the page around it. */
113
+ interface TabContext {
114
+ /** The tab's full id. */
115
+ readonly tab: string;
116
+ /** The panel it is in: the node selected, the frame's snapshot, highlight, locate, pick. */
117
+ readonly panel: Panel;
118
+ /** The mount the panel is for: a plugin keys what it keeps about the frame by it. */
119
+ readonly mount: MountContext;
120
+ /** The plugins the host installed. */
121
+ readonly plugins: readonly PluginInfo[];
122
+ /** The host page's document. */
123
+ readonly document: Document;
124
+ /**
125
+ * The host's theme now. Its tokens are also set as `--anfra-*` custom properties on the tab's
126
+ * element, which its shadow root inherits, and follow each change: style with `var(--anfra-color-bg)`.
127
+ */
128
+ readonly theme: Theme;
129
+ /** Make a call about this mount, through the pipeline, as the tab's plugin (or the host). */
130
+ call: <T = unknown>(name: string, request?: unknown, options?: CallOptions) => Promise<T>;
131
+ }
132
+ interface TabContribution {
133
+ /** Under its plugin's name once installed (`structure` is `inspect.structure`); a host's own, as given. */
134
+ id: string;
135
+ title: string;
136
+ /** A short name for an icon, which the host maps to its own. */
137
+ icon?: string;
138
+ /** Lower comes first; ties keep install order (the host's own last). */
139
+ order?: number;
140
+ /**
141
+ * Draw the tab into `root`, a shadow root the host owns, with any framework or none: the host's
142
+ * styles don't reach in, and the tab's don't reach out. What it returns runs when the tab is
143
+ * taken down. Load what is heavy from here, so a host that never shows the tab never loads it.
144
+ */
145
+ mount: (root: ShadowRoot, context: TabContext) => void | (() => void) | Promise<void | (() => void)>;
146
+ }
147
+ /** An installed command: its full id, and the plugin it came from (none for the host's own). */
148
+ interface Command extends CommandContribution {
149
+ readonly plugin?: string;
150
+ }
151
+ /** An installed tab: its full id, and the plugin it came from (none for the host's own). */
152
+ interface Tab extends TabContribution {
153
+ readonly plugin?: string;
154
+ }
155
+ type Contribution = {
156
+ kind: 'command';
157
+ command: Command;
158
+ } | {
159
+ kind: 'tab';
160
+ tab: Tab;
161
+ };
162
+
163
+ /**
164
+ * What a plugin is, the host's side: a name, a version, the plugins it needs, a host half that
165
+ * answers its calls, and the frame half's code. See docs/designs/sdk-plugins.md.
166
+ */
167
+ /** Who made a call. Middleware and handlers can tell the definition's calls from a plugin's. */
168
+ type Caller =
169
+ /** The Data App's frame: its definition, or a plugin's frame half there. */
170
+ {
171
+ kind: 'frame';
172
+ }
173
+ /** The host page's own code, through `Host.call` or `MountedDataApp.call`. */
174
+ | {
175
+ kind: 'host';
176
+ }
177
+ /** Another plugin's host half, by its name. */
178
+ | {
179
+ kind: 'plugin';
180
+ plugin: string;
181
+ };
182
+ interface CallOptions {
183
+ signal?: AbortSignal;
184
+ }
185
+ /** One call, as its handler and each middleware see it. */
186
+ interface CallContext {
187
+ /** The call's full name, `<plugin>.<name>`. */
188
+ readonly name: string;
189
+ readonly caller: Caller;
190
+ /**
191
+ * Who led to this call, outermost first, ending with `caller`: a query an agent plugin runs for
192
+ * the frame's prompt is `[frame, plugin agent]`. Decide by it, or by `origin`, what a call started
193
+ * by the frame may do, since a plugin's call made for the frame has the plugin as its `caller`.
194
+ */
195
+ readonly chain: readonly Caller[];
196
+ /** Who started the chain: the frame, or the host (`chain[0]`). */
197
+ readonly origin: Caller;
198
+ /** Aborts when the caller cancels. */
199
+ readonly signal: AbortSignal;
200
+ /** The frame the call is about: the one that made it, or the one the host named. */
201
+ readonly mount?: MountContext;
202
+ /** The middleware the call has passed through so far, by name, outermost first. */
203
+ readonly trace: readonly string[];
204
+ }
205
+ interface HandlerCallOptions extends CallOptions {
206
+ /**
207
+ * Hold the call to what this chain's origin may call: started by the frame, it is refused unless
208
+ * the frame could make it itself. For a handler that forwards a call, or a request, the frame
209
+ * chose, so the plugin can't be made to make a host-only call for it.
210
+ */
211
+ asOrigin?: boolean;
212
+ }
213
+ /** What a plugin's handler gets: the call, and a way to make calls of its own as that plugin. */
214
+ interface HandlerContext extends CallContext {
215
+ /**
216
+ * Make another plugin's call, through the same pipeline, as this plugin, about the same frame. It
217
+ * carries this call's chain, with this plugin added.
218
+ */
219
+ call: <T = unknown>(name: string, request?: unknown, options?: HandlerCallOptions) => Promise<T>;
220
+ }
221
+ type CallHandler = (request: any, context: HandlerContext) => unknown;
222
+ interface CallDefinition {
223
+ handler: CallHandler;
224
+ /** Whether a frame may make this call. Off unless true: a call is the host's until its plugin says. */
225
+ frame?: boolean;
226
+ }
227
+ /**
228
+ * Code around calls, chosen by name: `*`, `<plugin>.*`, or one call's full name. It may change the
229
+ * request, answer in place of the plugin (not calling `next`), refuse the call (throwing), or change
230
+ * the answer. Every call passes through it, whoever made it. A plugin's middleware is as powerful as
231
+ * the host's: it sees and may change every call on the page, not only its plugin's.
232
+ */
233
+ interface Middleware {
234
+ /** Names the middleware in a call's trace, and orders it among middleware of the same stage. */
235
+ name: string;
236
+ match: string | readonly string[];
237
+ /** Lower runs first (outermost). 0 unless given. Ties are ordered by name, never by registration. */
238
+ stage?: number;
239
+ handle: (request: unknown, context: CallContext, next: (request?: unknown) => Promise<unknown>) => unknown;
240
+ }
241
+ /** One mounted frame, as a plugin's host half sees it. */
242
+ interface MountContext {
243
+ readonly id: number;
244
+ readonly frame: HTMLIFrameElement;
245
+ /** The host page's document, where the frame is. */
246
+ readonly document: Document;
247
+ /** Who reads the Data App, and the datasets it may query: what the frame is provisioned with. */
248
+ readonly user: User;
249
+ readonly datasets: Readonly<Record<string, DatasetDescriptor>>;
250
+ /** Make a call a frame half answers, in this frame. */
251
+ call: <T = unknown>(name: string, request?: unknown, options?: CallOptions) => Promise<T>;
252
+ /** Send this frame an event. */
253
+ emit: (name: string, payload?: unknown) => void;
254
+ /** Listen to this frame's events, by full name. Returns the function that stops listening. */
255
+ on: (name: string, listener: (payload: any) => void) => () => void;
256
+ /** Each time the frame's document (re)loads and its kernel runs. */
257
+ onReady: (listener: () => void) => () => void;
258
+ /** Tell the host its commands' state changed for this frame, so it reads each `state` again. */
259
+ commandsChanged: () => void;
260
+ }
261
+ /**
262
+ * Checks one of a frame's events before the host hears it: what it returns is what listeners get,
263
+ * and `undefined` drops the event. A frame's events are as untrusted as its calls.
264
+ */
265
+ type EventCheck = (payload: unknown, mount: MountContext) => unknown;
266
+ interface HostHalf {
267
+ /** The calls this plugin answers, by their name under the plugin (`submitQuery`, not `core.submitQuery`). */
268
+ calls?: Record<string, CallHandler | CallDefinition>;
269
+ /**
270
+ * The events a frame may send under this plugin's name (`snapshot`, not `inspect.snapshot`), each
271
+ * with its check. An event no installed plugin declares never reaches the host.
272
+ */
273
+ events?: Record<string, EventCheck>;
274
+ /** Middleware this plugin puts around calls, its own or others'. */
275
+ middleware?: readonly Middleware[];
276
+ /** Each time a frame is mounted. What it returns runs when the frame is unmounted. */
277
+ mount?: (mount: MountContext) => void | (() => void);
278
+ /** Commands for the host's action bar and command palette, ids under the plugin's name. */
279
+ commands?: readonly CommandContribution[];
280
+ /** Tabs for the mount's panel, ids under the plugin's name. */
281
+ tabs?: readonly TabContribution[];
282
+ }
283
+ /** A frame half: code the host provisions into the frame, as script source (docs/designs/sdk-plugins.md). */
284
+ interface FrameHalf {
285
+ /** Runs before the definition, once per document: registers the plugin's API. */
286
+ setup: string;
287
+ /** Loaded on first use, through the kernel. */
288
+ body?: string;
289
+ }
290
+ interface Plugin {
291
+ /** Lowercase letters, digits and dashes, starting with a letter. Names its calls, events and API. */
292
+ name: string;
293
+ version: string;
294
+ /** Plugins this one needs; installing it without them fails. */
295
+ requires?: readonly string[];
296
+ host?: HostHalf;
297
+ frame?: FrameHalf;
298
+ }
299
+ /** A plugin, checked (`checkPlugin`). A host checks every plugin it installs anyway. */
300
+ declare function definePlugin<P extends Plugin>(plugin: P): P;
301
+
302
+ export { definePlugin as q };
303
+ export type { Command as C, EventCheck as E, FrameHalf as F, HandlerCallOptions as H, Middleware as M, Panel as P, Snapshot as S, Tab as T, CallOptions as a, CommandState as b, Plugin as c, CommandContribution as d, TabContribution as e, Contribution as f, CallContext as g, CallDefinition as h, CallHandler as i, Caller as j, CommandRun as k, CommandStateContext as l, HandlerContext as m, HostHalf as n, MountContext as o, TabContext as p };
package/dist/plugins.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Backend } from './app.js';
2
2
  import { Plugin } from './host.js';
3
+ import './menu-CdGVKc4_.js';
3
4
 
4
5
  /**
5
6
  * `core`: running a Data App's queries and suggesting a filter's values. Every host installs it:
@@ -19,7 +20,11 @@ declare function corePlugin(backend: CoreBackend): Plugin;
19
20
  /** `backend` must have `exportQuery` (`coreApiBackend` does). */
20
21
  declare function exportPlugin(backend: Pick<Backend, 'exportQuery'>): Plugin;
21
22
 
22
- /** `lineage`: tracing fields through the repo's catalog (`Anfra.lineage()`). */
23
+ /**
24
+ * `lineage`: tracing fields through the repo's catalog (`Anfra.lineage()`), and the panel's Lineage
25
+ * tab, which draws where each number on the page comes from. The tab loads the first time a host
26
+ * shows it.
27
+ */
23
28
 
24
29
  /** `backend` must have `lineage` (`coreApiBackend` does). */
25
30
  declare function lineagePlugin(backend: Pick<Backend, 'lineage'>): Plugin;
@@ -40,13 +45,6 @@ interface RenderPluginOptions {
40
45
  */
41
46
  declare function renderPlugin(options?: RenderPluginOptions): Plugin;
42
47
 
43
- /**
44
- * `inspect`: what the host's inspect panel needs of a frame. While the host watches, the frame posts
45
- * a snapshot of its apps and its structure (`inspect.snapshot`) on each change; the host can
46
- * highlight a node, locate a node or an entity, and turn pick mode on, where a click reports a node
47
- * (`inspect.picked`). Calls the host page makes, never the frame.
48
- */
49
-
50
48
  declare function inspectPlugin(): Plugin;
51
49
 
52
50
  export { corePlugin, exportPlugin, inspectPlugin, lineagePlugin, pictureFilename, renderPlugin };
package/dist/plugins.js CHANGED
@@ -1,17 +1,27 @@
1
1
  import {
2
- definePlugin
3
- } from "./chunk-TQ7S5DRE.js";
2
+ PLUGIN_VERSION
3
+ } from "./chunk-7IHICYVH.js";
4
+ import {
5
+ dropState as dropState2,
6
+ stateOf as stateOf2
7
+ } from "./chunk-CYZQ7ZTJ.js";
4
8
  import {
5
- version
6
- } from "./chunk-2Q4HPPUK.js";
9
+ definePlugin
10
+ } from "./chunk-WI5VJ2Z6.js";
11
+ import "./chunk-NOFPRSSI.js";
7
12
  import {
8
13
  ValidationError
9
14
  } from "./chunk-KCTLO3CO.js";
15
+ import {
16
+ dropState,
17
+ stateOf
18
+ } from "./chunk-GBXK7F2V.js";
19
+ import "./chunk-K633QHGO.js";
20
+ import {
21
+ OVERVIEW_TAB
22
+ } from "./chunk-H52PO7MP.js";
10
23
  import "./chunk-PKBMQBKP.js";
11
24
 
12
- // src/plugins/version.ts
13
- var PLUGIN_VERSION = version;
14
-
15
25
  // src/plugins/core/index.ts
16
26
  function corePlugin(backend) {
17
27
  return definePlugin({
@@ -78,14 +88,26 @@ function lineagePlugin(backend) {
78
88
  host: {
79
89
  calls: {
80
90
  trace: { frame: true, handler: (request, { signal }) => lineage.call(backend, request, signal) }
81
- }
91
+ },
92
+ mount: (mount) => {
93
+ stateOf(mount);
94
+ return () => dropState(mount);
95
+ },
96
+ tabs: [{
97
+ id: "lineage",
98
+ title: "Lineage",
99
+ icon: "lineage",
100
+ // Between `inspect`'s Queries (30) and Structure (40).
101
+ order: 35,
102
+ mount: async (root, context) => (await import("./tab-HMQOITVM.js")).default(root, context)
103
+ }]
82
104
  },
83
105
  frame: { setup: lineage_default }
84
106
  });
85
107
  }
86
108
 
87
109
  // anfra-sdk:anfra-sdk:setup/render
88
- var render_default = '"use strict";var __anfraPlugin=(()=>{var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var i=(e,t)=>p(e,"name",{value:t,configurable:!0});var $=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},E=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of R(t))!w.call(e,a)&&a!==n&&p(e,a,{get:()=>t[a],enumerable:!(o=k(t,a))||o.enumerable});return e};var A=e=>E(p({},"__esModule",{value:!0}),e);var O={};$(O,{SETTLE_MS:()=>b,SKIP_ATTRIBUTE:()=>f,createRender:()=>g,default:()=>h,settle:()=>y});var S="data-anfra-layer";function m(e){return e.hasAttribute(S)}i(m,"isLayer");var c={container:"data-anfra-container",block:"data-anfra-block",query:"data-anfra-query",control:"data-anfra-control",label:"data-anfra-label"},F=`[${c.container}],[${c.block}],[${c.query}],[${c.control}]`;var f="data-anfra-render",x={png:"png",pdf:"pdf"},b=1e4;function T(e,t,n,o){let a=x[e.format],r=e.filename?.trim();if(!r){let s=n.find(d=>d.title)?.title||t.title.trim()||"Data App",l=o&&(o.getAttribute(c.label)||e.block||e.container);r=l?`${s} - ${l}`:s}return r=r.replace(/[/\\\\]/g,"-").replace(/\\p{Cc}/gu,"").trim()||"Data App",r.toLowerCase().endsWith(`.${a}`)?r:`${r}.${a}`}i(T,"filenameFor");function v(e,t,{ValidationError:n}){if(e.block!==void 0&&e.container!==void 0)throw new n("Render a block or a container, not both.",e.block);if(e.format!=="png"&&e.format!=="pdf")throw new n(`Can\'t render as \'${String(e.format)}\': the formats are \'png\' and \'pdf\'.`);let{pixelRatio:o}=e;if(o!==void 0&&!(Number.isFinite(o)&&o>0))throw new n(`pixelRatio ${String(o)} is not a positive number.`);let a=e.block!==void 0?"block":e.container!==void 0?"container":void 0;if(!a)return{element:null};let r=e.block??e.container,s=[...t.querySelectorAll(`[${c[a]}]`)].find(l=>l.getAttribute(c[a])===r);if(!s)throw new n(`No element is marked ${c[a]}="${r}" on the page.`,r);return{element:s,entity:r}}i(v,"targetOf");function L(e){return m(e)||e.getAttribute(f)==="skip"}i(L,"skip");function g(e,t){let{ValidationError:n}=t.errors;return async o=>{let a=e.document,{element:r,entity:s}=v(o??{},a,t.errors),l=T(o,a,t.apps(),r);try{let u=await(await t.renderer()).draw(r,{format:o.format,pixelRatio:o.pixelRatio,skip:L});return await t.saveFile({blob:u.blob,filename:l}),{filename:l,format:o.format,...u}}catch(d){throw d instanceof n&&d.entity?d:new n(d?.message||"The rendering failed.",s)}}}i(g,"createRender");async function y(e,t,n=b){let o=i(()=>t().some(r=>Object.values(r.queries).some(s=>s.state==="executing")),"busy"),a=Date.now()+n;for(;o()&&Date.now()<a;)await new Promise(r=>{e.setTimeout(r,100)});await new Promise(r=>{e.requestAnimationFrame(()=>r(void 0))})}i(y,"settle");function h(e){let t=g(e.window,{renderer:i(()=>e.body(),"renderer"),saveFile:i(n=>e.call("render.save",n),"saveFile"),apps:i(()=>e.sdk.apps,"apps"),errors:e.errors});e.provide(n=>t(n)),e.handle("draw",n=>y(e.window,()=>e.sdk.apps).then(()=>t(n)))}i(h,"setup");return A(O);})();\n';
110
+ var render_default = '"use strict";var __anfraPlugin=(()=>{var m=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var a=(e,t)=>m(e,"name",{value:t,configurable:!0});var w=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of T(t))!R.call(e,s)&&s!==n&&m(e,s,{get:()=>t[s],enumerable:!(r=k(t,s))||r.enumerable});return e};var E=e=>S(m({},"__esModule",{value:!0}),e);var N={};w(N,{SETTLE_MS:()=>h,SKIP_ATTRIBUTE:()=>f,createRender:()=>b,default:()=>g,settle:()=>y});var x="data-anfra-layer";function u(e){return e.hasAttribute(x)}a(u,"isLayer");var c={container:"data-anfra-container",block:"data-anfra-block",query:"data-anfra-query",control:"data-anfra-control",label:"data-anfra-label"},P=`[${c.container}],[${c.block}],[${c.query}],[${c.control}]`;var f="data-anfra-render",$={png:"png",pdf:"pdf"},h=1e4;function A(e,t,n,r){let s=$[e.format],o=e.filename?.trim();if(!o){let i=n.find(p=>p.title)?.title||t.title.trim()||"Data App",l=r&&(r.getAttribute(c.label)||e.block||e.container);o=l?`${i} - ${l}`:i}return o=o.replace(/[/\\\\]/g,"-").replace(/\\p{Cc}/gu,"").trim()||"Data App",o.toLowerCase().endsWith(`.${s}`)?o:`${o}.${s}`}a(A,"filenameFor");function O(e,t,{ValidationError:n}){if(e.block!==void 0&&e.container!==void 0)throw new n("Render a block or a container, not both.",e.block);if(e.format!=="png"&&e.format!=="pdf")throw new n(`Can\'t render as \'${String(e.format)}\': the formats are \'png\' and \'pdf\'.`);let{pixelRatio:r}=e;if(r!==void 0&&!(Number.isFinite(r)&&r>0))throw new n(`pixelRatio ${String(r)} is not a positive number.`);let s=e.block!==void 0?"block":e.container!==void 0?"container":void 0;if(!s)return{element:null};let o=e.block??e.container,i=[...t.querySelectorAll(`[${c[s]}]`)].find(l=>l.getAttribute(c[s])===o);if(!i)throw new n(`No element is marked ${c[s]}="${o}" on the page.`,o);return{element:i,entity:o}}a(O,"targetOf");function v(e){return u(e)||e.getAttribute(f)==="skip"}a(v,"skip");function b(e,t){let{ValidationError:n}=t.errors;return async r=>{let s=e.document,{element:o,entity:i}=O(r??{},s,t.errors),l=A(r,s,t.apps(),o);try{let d=await(await t.renderer()).draw(o,{format:r.format,pixelRatio:r.pixelRatio,skip:v});return await t.saveFile({blob:d.blob,filename:l}),{filename:l,format:r.format,...d}}catch(p){throw p instanceof n&&p.entity?p:new n(p?.message||"The rendering failed.",i)}}}a(b,"createRender");async function y(e,t,n=h){let r=a(()=>t().some(o=>Object.values(o.queries).some(i=>i.state==="executing")),"busy"),s=Date.now()+n;for(;r()&&Date.now()<s;)await new Promise(o=>{e.setTimeout(o,100)});await new Promise(o=>{e.requestAnimationFrame(()=>o(void 0))})}a(y,"settle");function g(e){let t=b(e.window,{renderer:a(()=>e.body(),"renderer"),saveFile:a(n=>e.call("render.save",n),"saveFile"),apps:a(()=>e.sdk.apps,"apps"),errors:e.errors});e.provide(n=>t(n)),e.handle("draw",n=>y(e.window,()=>e.sdk.apps).then(()=>t(n)))}a(g,"setup");return E(N);})();\n';
89
111
 
90
112
  // anfra-sdk:anfra-sdk:body/render
91
113
  var render_default2 = '"use strict";var __anfraBody=(()=>{var $=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var i=(e,t)=>$(e,"name",{value:t,configurable:!0});var me=(e,t)=>{for(var n in t)$(e,n,{get:t[n],enumerable:!0})},he=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ue(t))!fe.call(e,o)&&o!==n&&$(e,o,{get:()=>t[o],enumerable:!(r=le(t,o))||r.enumerable});return e};var ge=e=>he($({},"__esModule",{value:!0}),e);var it={};me(it,{default:()=>ce});function H(e,t){if(e.match(/^[a-z]+:\\/\\//i))return e;if(e.match(/^\\/\\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;let n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),t&&(r.href=t),o.href=e,o.href}i(H,"resolveUrl");var V=(()=>{let e=0,t=i(()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4),"random");return()=>(e+=1,`u${t()}${e}`)})();function p(e){let t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}i(p,"toArray");var b=null;function L(e={}){return b||(e.includeStyleProperties?(b=e.includeStyleProperties,b):(b=p(window.getComputedStyle(document.documentElement)),b))}i(L,"getStyleProperties");function D(e,t){let r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}i(D,"px");function de(e){let t=D(e,"border-left-width"),n=D(e,"border-right-width");return e.clientWidth+t+n}i(de,"getNodeWidth");function pe(e){let t=D(e,"border-top-width"),n=D(e,"border-bottom-width");return e.clientHeight+t+n}i(pe,"getNodeHeight");function I(e,t={}){let n=t.width||de(e),r=t.height||pe(e);return{width:n,height:r}}i(I,"getImageSize");function W(){let e,t;try{t=process}catch{}let n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}i(W,"getPixelRatio");var g=16384;function _(e){(e.width>g||e.height>g)&&(e.width>g&&e.height>g?e.width>e.height?(e.height*=g/e.width,e.width=g):(e.width*=g/e.height,e.height=g):e.width>g?(e.height*=g/e.width,e.width=g):(e.width*=g/e.height,e.height=g))}i(_,"checkCanvasDimensions");function x(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}i(x,"createImage");async function ye(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}i(ye,"svgToDataURL");async function j(e,t,n){let r="http://www.w3.org/2000/svg",o=document.createElementNS(r,"svg"),a=document.createElementNS(r,"foreignObject");return o.setAttribute("width",`${t}`),o.setAttribute("height",`${n}`),o.setAttribute("viewBox",`0 0 ${t} ${n}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),o.appendChild(a),a.appendChild(e),ye(o)}i(j,"nodeToDataURL");var m=i((e,t)=>{if(e instanceof t)return!0;let n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||m(n,t)},"isInstanceOfElement");function we(e){let t=e.getPropertyValue("content");return`${e.cssText} content: \'${t.replace(/\'|"/g,"")}\';`}i(we,"formatCSSText");function be(e,t){return L(t).map(n=>{let r=e.getPropertyValue(n),o=e.getPropertyPriority(n);return`${n}: ${r}${o?" !important":""};`}).join(" ")}i(be,"formatCSSProperties");function xe(e,t,n,r){let o=`.${e}:${t}`,a=n.cssText?we(n):be(n,r);return document.createTextNode(`${o}{${a}}`)}i(xe,"getPseudoElementStyle");function q(e,t,n,r){let o=window.getComputedStyle(e,n),a=o.getPropertyValue("content");if(a===""||a==="none")return;let s=V();try{t.className=`${t.className} ${s}`}catch{return}let c=document.createElement("style");c.appendChild(xe(s,n,o,r)),t.appendChild(c)}i(q,"clonePseudoElement");function z(e,t,n){q(e,t,":before",n),q(e,t,":after",n)}i(z,"clonePseudoElements");var G="application/font-woff",X="image/jpeg",Se={woff:G,woff2:G,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:X,jpeg:X,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Ee(e){let t=/\\.([^./]*?)$/g.exec(e);return t?t[1]:""}i(Ee,"getExtension");function S(e){let t=Ee(e).toLowerCase();return Se[t]||""}i(S,"getMimeType");function Re(e){return e.split(/,/)[1]}i(Re,"getContentFromDataUrl");function C(e){return e.search(/^(data:)/)!==-1}i(C,"isDataUrl");function v(e,t){return`data:${t};base64,${e}`}i(v,"makeDataUrl");async function k(e,t,n){let r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);let o=await r.blob();return new Promise((a,s)=>{let c=new FileReader;c.onerror=s,c.onloadend=()=>{try{a(n({res:r,result:c.result}))}catch(l){s(l)}},c.readAsDataURL(o)})}i(k,"fetchAsDataURL");var U={};function Ae(e,t,n){let r=e.replace(/\\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\\//,"")),t?`[${t}]${r}`:r}i(Ae,"getCacheKey");async function E(e,t,n){let r=Ae(e,t,n.includeQueryParams);if(U[r]!=null)return U[r];n.cacheBust&&(e+=(/\\?/.test(e)?"&":"?")+new Date().getTime());let o;try{let a=await k(e,n.fetchRequestInit,({res:s,result:c})=>(t||(t=s.headers.get("Content-Type")||""),Re(c)));o=v(a,t)}catch(a){o=n.imagePlaceholder||"";let s=`Failed to fetch resource: ${e}`;a&&(s=typeof a=="string"?a:a.message),s&&console.warn(s)}return U[r]=o,o}i(E,"resourceToDataURL");async function Ce(e){let t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):x(t)}i(Ce,"cloneCanvasElement");async function Pe(e,t){if(e.currentSrc){let a=document.createElement("canvas"),s=a.getContext("2d");a.width=e.clientWidth,a.height=e.clientHeight,s?.drawImage(e,0,0,a.width,a.height);let c=a.toDataURL();return x(c)}let n=e.poster,r=S(n),o=await E(n,r,t);return x(o)}i(Pe,"cloneVideoElement");async function Te(e,t){var n;try{if(!((n=e?.contentDocument)===null||n===void 0)&&n.body)return await P(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}i(Te,"cloneIFrameElement");async function $e(e,t){return m(e,HTMLCanvasElement)?Ce(e):m(e,HTMLVideoElement)?Pe(e,t):m(e,HTMLIFrameElement)?Te(e,t):e.cloneNode(J(e))}i($e,"cloneSingleNode");var De=i(e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT","isSlotElement"),J=i(e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG","isSVGElement");async function Le(e,t,n){var r,o;if(J(t))return t;let a=[];return De(e)&&e.assignedNodes?a=p(e.assignedNodes()):m(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?a=p(e.contentDocument.body.childNodes):a=p(((o=e.shadowRoot)!==null&&o!==void 0?o:e).childNodes),a.length===0||m(e,HTMLVideoElement)||await a.reduce((s,c)=>s.then(()=>P(c,n)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}i(Le,"cloneChildren");function Fe(e,t,n){let r=t.style;if(!r)return;let o=window.getComputedStyle(e);o.cssText?(r.cssText=o.cssText,r.transformOrigin=o.transformOrigin):L(n).forEach(a=>{let s=o.getPropertyValue(a);a==="font-size"&&s.endsWith("px")&&(s=`${Math.floor(parseFloat(s.substring(0,s.length-2)))-.1}px`),m(e,HTMLIFrameElement)&&a==="display"&&s==="inline"&&(s="block"),a==="d"&&t.getAttribute("d")&&(s=`path(${t.getAttribute("d")})`),r.setProperty(a,s,o.getPropertyPriority(a))})}i(Fe,"cloneCSSStyle");function Ie(e,t){m(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),m(e,HTMLInputElement)&&t.setAttribute("value",e.value)}i(Ie,"cloneInputValue");function Ue(e,t){if(m(e,HTMLSelectElement)){let r=Array.from(t.children).find(o=>e.value===o.getAttribute("value"));r&&r.setAttribute("selected","")}}i(Ue,"cloneSelectValue");function ve(e,t,n){return m(t,Element)&&(Fe(e,t,n),z(e,t,n),Ie(e,t),Ue(e,t)),t}i(ve,"decorate");async function ke(e,t){let n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;let r={};for(let a=0;a<n.length;a++){let c=n[a].getAttribute("xlink:href");if(c){let l=e.querySelector(c),f=document.querySelector(c);!l&&f&&!r[c]&&(r[c]=await P(f,t,!0))}}let o=Object.values(r);if(o.length){let a="http://www.w3.org/1999/xhtml",s=document.createElementNS(a,"svg");s.setAttribute("xmlns",a),s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.overflow="hidden",s.style.display="none";let c=document.createElementNS(a,"defs");s.appendChild(c);for(let l=0;l<o.length;l++)c.appendChild(o[l]);e.appendChild(s)}return e}i(ke,"ensureSVGSymbols");async function P(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>$e(r,t)).then(r=>Le(e,r,t)).then(r=>ve(e,r,t)).then(r=>ke(r,t))}i(P,"cloneNode");var K=/url\\(([\'"]?)([^\'"]+?)\\1\\)/g,Oe=/url\\([^)]+\\)\\s*format\\((["\']?)([^"\']+)\\1\\)/g,Be=/src:\\s*(?:url\\([^)]+\\)\\s*format\\([^)]+\\)[,;]\\s*)+/g;function Me(e){let t=e.replace(/([.*+?^${}()|\\[\\]\\/\\\\])/g,"\\\\$1");return new RegExp(`(url\\\\([\'"]?)(${t})([\'"]?\\\\))`,"g")}i(Me,"toRegex");function He(e){let t=[];return e.replace(K,(n,r,o)=>(t.push(o),n)),t.filter(n=>!C(n))}i(He,"parseURLs");async function Ve(e,t,n,r,o){try{let a=n?H(t,n):t,s=S(t),c;if(o){let l=await o(a);c=v(l,s)}else c=await E(a,s,r);return e.replace(Me(t),`$1${c}$3`)}catch{}return e}i(Ve,"embed");function We(e,{preferredFontFormat:t}){return t?e.replace(Be,n=>{for(;;){let[r,,o]=Oe.exec(n)||[];if(!o)return"";if(o===t)return`src: ${r};`}}):e}i(We,"filterPreferredFontFormat");function O(e){return e.search(K)!==-1}i(O,"shouldEmbed");async function F(e,t,n){if(!O(e))return e;let r=We(e,n);return He(r).reduce((a,s)=>a.then(c=>Ve(c,s,t,n)),Promise.resolve(r))}i(F,"embedResources");async function R(e,t,n){var r;let o=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(o){let a=await F(o,null,n);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}i(R,"embedProp");async function _e(e,t){await R("background",e,t)||await R("background-image",e,t),await R("mask",e,t)||await R("-webkit-mask",e,t)||await R("mask-image",e,t)||await R("-webkit-mask-image",e,t)}i(_e,"embedBackground");async function je(e,t){let n=m(e,HTMLImageElement);if(!(n&&!C(e.src))&&!(m(e,SVGImageElement)&&!C(e.href.baseVal)))return;let r=n?e.src:e.href.baseVal,o=await E(r,S(r),t);await new Promise((a,s)=>{e.onload=a,e.onerror=t.onImageErrorHandler?(...l)=>{try{a(t.onImageErrorHandler(...l))}catch(f){s(f)}}:s;let c=e;c.decode&&(c.decode=a),c.loading==="lazy"&&(c.loading="eager"),n?(e.srcset="",e.src=o):e.href.baseVal=o})}i(je,"embedImageNode");async function qe(e,t){let r=p(e.childNodes).map(o=>B(o,t));await Promise.all(r).then(()=>e)}i(qe,"embedChildren");async function B(e,t){m(e,Element)&&(await _e(e,t),await je(e,t),await qe(e,t))}i(B,"embedImages");function Q(e,t){let{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);let r=t.style;return r!=null&&Object.keys(r).forEach(o=>{n[o]=r[o]}),e}i(Q,"applyStyle");var Y={};async function Z(e){let t=Y[e];if(t!=null)return t;let r=await(await fetch(e)).text();return t={url:e,cssText:r},Y[e]=t,t}i(Z,"fetchCSS");async function N(e,t){let n=e.cssText,r=/url\\(["\']?([^"\')]+)["\']?\\)/g,a=(n.match(/url\\([^)]+\\)/g)||[]).map(async s=>{let c=s.replace(r,"$1");return c.startsWith("https://")||(c=new URL(c,e.url).href),k(c,t.fetchRequestInit,({result:l})=>(n=n.replace(s,`url(${l})`),[s,l]))});return Promise.all(a).then(()=>n)}i(N,"embedFonts");function ee(e){if(e==null)return[];let t=[],n=/(\\/\\*[\\s\\S]*?\\*\\/)/gi,r=e.replace(n,""),o=new RegExp("((@.*?keyframes [\\\\s\\\\S]*?){([\\\\s\\\\S]*?}\\\\s*?)})","gi");for(;;){let l=o.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(o,"");let a=/@import[\\s\\S]*?url\\([^)]*\\)[\\s\\S]*?;/gi,s="((\\\\s*?(?:\\\\/\\\\*[\\\\s\\\\S]*?\\\\*\\\\/)?\\\\s*?@media[\\\\s\\\\S]*?){([\\\\s\\\\S]*?)}\\\\s*?})|(([\\\\s\\\\S]*?){([\\\\s\\\\S]*?)})",c=new RegExp(s,"gi");for(;;){let l=a.exec(r);if(l===null){if(l=c.exec(r),l===null)break;a.lastIndex=c.lastIndex}else c.lastIndex=a.lastIndex;t.push(l[0])}return t}i(ee,"parseCSS");async function ze(e,t){let n=[],r=[];return e.forEach(o=>{if("cssRules"in o)try{p(o.cssRules||[]).forEach((a,s)=>{if(a.type===CSSRule.IMPORT_RULE){let c=s+1,l=a.href,f=Z(l).then(u=>N(u,t)).then(u=>ee(u).forEach(h=>{try{o.insertRule(h,h.startsWith("@import")?c+=1:o.cssRules.length)}catch(A){console.error("Error inserting rule from remote css",{rule:h,error:A})}})).catch(u=>{console.error("Error loading remote css",u.toString())});r.push(f)}})}catch(a){let s=e.find(c=>c.href==null)||document.styleSheets[0];o.href!=null&&r.push(Z(o.href).then(c=>N(c,t)).then(c=>ee(c).forEach(l=>{s.insertRule(l,s.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",a)}}),Promise.all(r).then(()=>(e.forEach(o=>{if("cssRules"in o)try{p(o.cssRules||[]).forEach(a=>{n.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${o.href}`,a)}}),n))}i(ze,"getCSSRules");function Ge(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>O(t.style.getPropertyValue("src")))}i(Ge,"getWebFontRules");async function Xe(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");let n=p(e.ownerDocument.styleSheets),r=await ze(n,t);return Ge(r)}i(Xe,"parseWebFontRules");function te(e){return e.trim().replace(/["\']/g,"")}i(te,"normalizeFontFamily");function Je(e){let t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(a=>{t.add(te(a))}),Array.from(r.children).forEach(a=>{a instanceof HTMLElement&&n(a)})}return i(n,"traverse"),n(e),t}i(Je,"getUsedFonts");async function re(e,t){let n=await Xe(e,t),r=Je(e);return(await Promise.all(n.filter(a=>r.has(te(a.style.fontFamily))).map(a=>{let s=a.parentStyleSheet?a.parentStyleSheet.href:null;return F(a.cssText,s,t)}))).join(`\n`)}i(re,"getWebFontCSS");async function ne(e,t){let n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await re(e,t);if(n){let r=document.createElement("style"),o=document.createTextNode(n);r.appendChild(o),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}i(ne,"embedWebFonts");async function Ke(e,t={}){let{width:n,height:r}=I(e,t),o=await P(e,t,!0);return await ne(o,t),await B(o,t),Q(o,t),await j(o,n,r)}i(Ke,"toSvg");async function oe(e,t={}){let{width:n,height:r}=I(e,t),o=await Ke(e,t),a=await x(o),s=document.createElement("canvas"),c=s.getContext("2d"),l=t.pixelRatio||W(),f=t.canvasWidth||n,u=t.canvasHeight||r;return s.width=f*l,s.height=u*l,t.skipAutoScale||_(s),s.style.width=`${f}`,s.style.height=`${u}`,t.backgroundColor&&(c.fillStyle=t.backgroundColor,c.fillRect(0,0,s.width,s.height)),c.drawImage(a,0,0,s.width,s.height),s}i(oe,"toCanvas");function ae(e,t,n){let r=(n.width*.75).toFixed(2),o=(n.height*.75).toFixed(2),a=`q ${r} 0 0 ${o} 0 0 cm /Im0 Do Q`,s=new TextEncoder,c=[],l=[],f=0,u=i(d=>{let w=typeof d=="string"?s.encode(d):d;c.push(w),f+=w.length},"push"),h=i((d,w)=>{l[d]=f,u(`${d} 0 obj\n`),(Array.isArray(w)?w:[w]).forEach(u),u(`\nendobj\n`)},"object");u(`%PDF-1.4\n`),u(new Uint8Array([37,226,227,207,211,10])),h(1,"<< /Type /Catalog /Pages 2 0 R >>"),h(2,"<< /Type /Pages /Kids [3 0 R] /Count 1 >>"),h(3,`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${r} ${o}] /Resources << /XObject << /Im0 4 0 R >> >> /Contents 5 0 R >>`),h(4,[`<< /Type /XObject /Subtype /Image /Width ${t.width} /Height ${t.height} /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ${e.length} >>\nstream\n`,e,`\nendstream`]),h(5,`<< /Length ${a.length} >>\nstream\n${a}\nendstream`);let A=f;return u(`xref\n0 6\n0000000000 65535 f \n${l.slice(1).map(d=>`${String(d).padStart(10,"0")} 00000 n \n`).join("")}`),u(`trailer\n<< /Size 6 /Root 1 0 R >>\nstartxref\n${A}\n%%EOF\n`),new Blob(c,{type:"application/pdf"})}i(ae,"pdfOfJpeg");var M=class M extends Error{constructor(t){super(t),this.name="RenderFailure"}};i(M,"RenderFailure");var y=M;var T=16384,ie=12e7;function Qe(e,t,n){let r=i(c=>e*c<=T&&t*c<=T&&e*t*c*c<=ie,"fits"),o=i(c=>new y(`${e}\\xD7${t} px at pixelRatio ${c} is over a canvas\'s limit (${T} px a side): render a smaller node, or a lower pixelRatio.`),"tooBig");if(n!==void 0){if(!r(n))throw o(n);return n}let a=Math.max(globalThis.devicePixelRatio||1,2);if(r(a))return a;let s=Math.floor(Math.min(T/e,T/t,Math.sqrt(ie/(e*t)))*100)/100;if(s<1)throw o(1);return s}i(Qe,"ratioFor");function Ye(e){return!!e&&e!=="transparent"&&!/rgba\\(.*,\\s*0\\)$/.test(e)}i(Ye,"opaque");function Ze(e,t){let n=[];if(e){for(let r=e;r;r=r.parentElement)n.push(r);n.push(t.body)}else n.push(t.documentElement,t.body);return n.map(r=>getComputedStyle(r).backgroundColor).find(Ye)??"#ffffff"}i(Ze,"backgroundOf");function Ne(e,t){let n=[],r=i(o=>{if(!t(o)){n.push(o);for(let a of o.children)r(a)}},"walk");return r(e),n}i(Ne,"drawnElements");async function et(e){let t=new Set;for(let r of e)if(r instanceof HTMLImageElement){let o=r.currentSrc||r.src;o&&!/^(data|blob):/.test(o)&&t.add(o)}let n=await Promise.all([...t].map(async r=>{try{return(await fetch(r,{mode:"cors",cache:"force-cache"})).ok}catch{return!1}}));return[...t].filter((r,o)=>!n[o])}i(et,"unreadableImages");var tt="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";function rt(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}i(rt,"dataUrlOf");function nt(e){let t=new Set;for(let n of e)for(let r of getComputedStyle(n).fontFamily.split(","))t.add(r.trim().replace(/^["\']|["\']$/g,"").toLowerCase());return t}i(nt,"familiesOf");async function ot(e,t){let n=nt(t),r=[];return await Promise.all([...e.styleSheets].map(async a=>{let s=a.href??e.baseURI;try{for(let c of a.cssRules)c instanceof CSSFontFaceRule&&r.push({css:c.cssText,base:s})}catch{if(!a.href)return;try{let c=await(await fetch(a.href,{mode:"cors",cache:"force-cache"})).text();for(let l of c.match(/@font-face\\s*{[^}]*}/g)??[])r.push({css:l,base:s})}catch{}}})),(await Promise.all(r.map(async({css:a,base:s})=>{let c=/font-family:\\s*["\']?([^;"\']+)/.exec(a)?.[1]?.trim().toLowerCase();if(!c||!n.has(c))return"";let l=a;for(let[f,,u]of a.matchAll(/url\\((["\']?)([^"\')]+)\\1\\)/g))if(!u.startsWith("data:"))try{let h=await fetch(new URL(u,s).href,{mode:"cors",cache:"force-cache"});l=l.replace(f,`url(${await rt(await h.blob())})`)}catch{return""}return l}))).filter(Boolean).join(`\n`)}i(ot,"embedFonts");function se(e,t,n){return new Promise((r,o)=>{try{e.toBlob(a=>a?r(a):o(new y("The browser made no image of the canvas.")),t,n)}catch{o(new y(\'The page holds something read from another server without CORS (a canvas or a font), so the browser refuses to make an image of it. Load it with CORS, or mark it data-anfra-render="skip".\'))}})}i(se,"toBlob");async function at(e,t){let n=document,r=e??n.body,o=r.getBoundingClientRect(),a=Math.ceil(e?o.width:n.documentElement.scrollWidth),s=Math.ceil(e?o.height:n.documentElement.scrollHeight);if(!a||!s)throw new y("There is nothing to draw: it has no size (hidden, or empty).");let c=Qe(a,s,t.pixelRatio),l=Ne(r,t.skip),f=await et(l),u=await ot(n,l),h=await oe(r,{width:a,height:s,pixelRatio:c,skipAutoScale:!0,backgroundColor:Ze(e,n),fontEmbedCSS:u,imagePlaceholder:tt,filter:i(d=>!(d instanceof Element&&t.skip(d)),"filter"),style:e?{boxSizing:"border-box",margin:"0"}:{boxSizing:"border-box",width:`${o.width}px`,height:"auto"}});if(t.format==="png")return{blob:await se(h,"image/png"),width:a,height:s,omitted:f};let A=new Uint8Array(await(await se(h,"image/jpeg",.92)).arrayBuffer());return{blob:ae(A,h,{width:a,height:s}),width:a,height:s,omitted:f}}i(at,"draw");var ce={draw:at};return ge(it);})();\n';
@@ -126,9 +148,26 @@ function renderPlugin(options = {}) {
126
148
  version: PLUGIN_VERSION,
127
149
  host: {
128
150
  mount(mount) {
129
- states.set(mount, { saving: false, saves: [] });
151
+ states.set(mount, { rendering: false, saving: false, saves: [] });
130
152
  },
131
153
  calls: {
154
+ /**
155
+ * Draw the page in the frame and save it, for the host's commands: one at a time, the commands
156
+ * disabled until it is done. Answers what the frame's `render.draw` does.
157
+ */
158
+ async download(request, { mount, call, signal }) {
159
+ const state = mount && states.get(mount);
160
+ if (!mount || !state) throw new ValidationError("A rendering is drawn for a frame.");
161
+ if (state.rendering) throw new ValidationError("A picture is being drawn already.");
162
+ state.rendering = true;
163
+ mount.commandsChanged();
164
+ try {
165
+ return await call("render.draw", request, { signal });
166
+ } finally {
167
+ state.rendering = false;
168
+ mount.commandsChanged();
169
+ }
170
+ },
132
171
  /** Save a rendering the frame made: one at a time, and only so many in a window. */
133
172
  save: {
134
173
  frame: true,
@@ -142,85 +181,75 @@ function renderPlugin(options = {}) {
142
181
  }
143
182
  state.saving = true;
144
183
  state.saves.push(now);
184
+ mount.commandsChanged();
145
185
  try {
146
186
  await saveBlob(mount.document, request);
147
187
  } finally {
148
188
  state.saving = false;
189
+ mount.commandsChanged();
149
190
  }
150
191
  return null;
151
192
  }
152
193
  }
153
- }
194
+ },
195
+ // The whole page as a picture, for the host's menus and palette. What a run answers (the
196
+ // rendering, with the images left blank) is the host's to tell the reader.
197
+ commands: ["png", "pdf"].map((format) => ({
198
+ id: format,
199
+ title: `Download as ${format.toUpperCase()}`,
200
+ icon: "download",
201
+ placement: "overflow",
202
+ run: { call: "render.download", request: { format } },
203
+ state: ({ mount }) => {
204
+ const state = states.get(mount);
205
+ return state?.rendering ? { disabled: "Drawing a picture\u2026" } : state?.saving ? { disabled: "Saving a picture\u2026" } : {};
206
+ }
207
+ }))
154
208
  },
155
209
  frame: { setup: render_default, ...renderer ? { body: renderer } : {} }
156
210
  });
157
211
  }
158
212
 
159
- // anfra-sdk:anfra-sdk:setup/inspect
160
- var inspect_default = '"use strict";var __anfraPlugin=(()=>{var b=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var o=(e,n)=>b(e,"name",{value:n,configurable:!0});var N=(e,n)=>{for(var i in n)b(e,i,{get:n[i],enumerable:!0})},C=(e,n,i,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of M(n))!R.call(e,r)&&r!==i&&b(e,r,{get:()=>n[r],enumerable:!(s=O(n,r))||s.enumerable});return e};var H=e=>C(b({},"__esModule",{value:!0}),e);var B={};N(B,{default:()=>S});var m={container:"data-anfra-container",block:"data-anfra-block",query:"data-anfra-query",control:"data-anfra-control",label:"data-anfra-label"},E=`[${m.container}],[${m.block}],[${m.query}],[${m.control}]`;var I=o((e,n,i)=>`${e}:${n}/${i}`,"usageKey");function q(e){let n=e.getBoundingClientRect();return`${Math.round(n.width)} \\xD7 ${Math.round(n.height)}`}o(q,"sizeOf");function k(e,n,i){let s=q(n);if(e.kind==="container"||e.kind==="block")return{kind:e.kind,name:e.id??"",...e.label?{label:e.label}:{},size:s};let r=i.usage[I(e.kind,e.app??0,e.name??"")];return{kind:e.kind,name:e.name??"",...r&&r.markers>1?{note:`1 of ${r.markers}`}:{},size:s}}o(k,"describeNode");function x(e){typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}o(x,"scrollTo");function w(e,n){let i=null,s=o(l=>l.target instanceof Element?l.target.closest(E):null,"under"),r=o(l=>{let p=s(l);p!==i&&(i=p,n.onHover(p))},"onMove"),a=o(l=>{l.preventDefault(),l.stopPropagation();let p=s(l);p&&n.onPick(p)},"onClick"),f=o(l=>{l.key==="Escape"&&n.onCancel()},"onKey"),c={capture:!0};return e.addEventListener("mousemove",r,c),e.addEventListener("click",a,c),e.addEventListener("keydown",f,c),()=>{e.removeEventListener("mousemove",r,c),e.removeEventListener("click",a,c),e.removeEventListener("keydown",f,c)}}o(w,"startPick");function L(e,n){for(let i of e){if(i.key===n)return i;let s=L(i.children,n);if(s)return s}}o(L,"findNode");function S(e){let n=e.window,i=n.document,s=!1,r,a,f="",c,l;function p(){if(r=void 0,!!s)try{a=e.structure(),f=JSON.stringify(a.nodes),e.emit("snapshot",{apps:e.sdk.apps.map(t=>t.toInspectJSON()),structure:{nodes:a.nodes,usage:a.usage}})}catch{}}o(p,"postSnapshot");function h(){s&&r===void 0&&(r=setTimeout(p,50))}o(h,"scheduleSnapshot");function T(){let t=n.MutationObserver;if(c||typeof t!="function")return;let u=new t(()=>{if(!(!s||r!==void 0))try{JSON.stringify(e.structure().nodes)!==f&&h()}catch{}});c=u,u.observe(i.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:Object.values(m)})}o(T,"observeStructure");function y(t){let u=t!==null&&a?L(a.nodes,t):void 0,d=t!==null?a?.elements.get(t):void 0;if(!u||!d||!a){e.overlay.hide();return}e.overlay.show([d],k(u,d,a))}o(y,"highlight");function g(t){if(!t){l?.(),l=void 0;return}if(l)return;let u=o(d=>a?.keysOf.get(d)?.[0],"keyOf");l=w(i,{onHover:o(d=>y(d?u(d)??null:null),"onHover"),onPick:o(d=>{let v=u(d);v!==void 0&&e.emit("picked",{node:v})},"onPick"),onCancel:o(()=>{g(!1),e.overlay.hide(),e.emit("picked",{node:null})},"onCancel")})}o(g,"setPicking");function $(t){s=t,t?(T(),p()):(c?.disconnect(),c=void 0,g(!1),e.overlay.hide(),a=void 0,f="")}o($,"setInspecting");function A(t){if("node"in t){let u=a?.elements.get(t.node);u&&x(u),y(t.node)}else e.sdk.apps[t.app]?.locate(t.kind,t.name);h()}o(A,"locate"),e.on("watch",t=>$(t===!0)),e.on("highlight",t=>y(t)),e.on("locate",t=>A(t)),e.on("pick",t=>g(t===!0)),e.onApp(t=>{t.subscribe(h),h()})}o(S,"setup");return H(B);})();\n';
161
-
162
213
  // src/plugins/inspect/index.ts
163
- var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
164
- function checkSnapshot(payload) {
165
- if (!isObject(payload) || !Array.isArray(payload.apps) || !payload.apps.every(isObject)) return void 0;
166
- const structure = payload.structure ?? { nodes: [], usage: {} };
167
- if (!isObject(structure) || !Array.isArray(structure.nodes) || !isObject(structure.usage ?? {})) return void 0;
168
- return {
169
- apps: payload.apps,
170
- structure: { nodes: structure.nodes, usage: structure.usage ?? {} }
171
- };
172
- }
173
- function checkPicked(payload) {
174
- if (!isObject(payload) || !(typeof payload.node === "string" || payload.node === null)) return void 0;
175
- return { node: payload.node };
176
- }
214
+ var tab = (id, title, icon, order, load) => ({
215
+ id,
216
+ title,
217
+ icon,
218
+ order,
219
+ mount: async (root, context) => (await load()).default(root, context)
220
+ });
177
221
  function inspectPlugin() {
178
- const watching = /* @__PURE__ */ new WeakMap();
179
- const frameOf = (mount) => {
180
- if (!mount) throw new Error("inspect: call it on a mounted Data App.");
181
- return mount;
182
- };
183
222
  return definePlugin({
184
223
  name: "inspect",
185
224
  version: PLUGIN_VERSION,
186
225
  host: {
187
- mount(mount) {
188
- return mount.onReady(() => {
189
- if (watching.get(mount)) mount.emit("inspect.watch", true);
190
- });
226
+ // Innermost, so the log has what reaches the plugin, and the trace of what it passed.
227
+ middleware: [{
228
+ name: "inspect",
229
+ match: "*",
230
+ stage: 1e3,
231
+ handle: (request, context, next) => context.mount ? stateOf2(context.mount).record(request, context, next) : next(request)
232
+ }],
233
+ mount: (mount) => {
234
+ stateOf2(mount);
235
+ return () => dropState2(mount);
191
236
  },
192
- events: {
193
- /** The frame's apps and structure, while watched. Only while watched, and only of its shape. */
194
- snapshot: (payload, mount) => watching.get(mount) ? checkSnapshot(payload) : void 0,
195
- /** The node the reader picked, or null on leaving pick mode. */
196
- picked: (payload, mount) => watching.get(mount) ? checkPicked(payload) : void 0
197
- },
198
- calls: {
199
- /** Start or stop the snapshots; survives the frame reloading. */
200
- watch(open, { mount }) {
201
- const frame = frameOf(mount);
202
- watching.set(frame, open === true);
203
- frame.emit("inspect.watch", open === true);
204
- return null;
205
- },
206
- /** Show a node of the last snapshot's structure on the page, or nothing (null). */
207
- highlight(node, { mount }) {
208
- frameOf(mount).emit("inspect.highlight", node);
209
- return null;
210
- },
211
- /** Scroll a node, or an entity wherever it is drawn, into view, and hold the highlight on it. */
212
- locate(target, { mount }) {
213
- frameOf(mount).emit("inspect.locate", target);
214
- return null;
215
- },
216
- /** Start or stop pick mode: pointing outlines marked elements, a click reports one. */
217
- pick(on, { mount }) {
218
- frameOf(mount).emit("inspect.pick", on === true);
219
- return null;
220
- }
221
- }
222
- },
223
- frame: { setup: inspect_default }
237
+ commands: [{
238
+ id: "toggle",
239
+ title: "Inspect",
240
+ icon: "inspect",
241
+ placement: "primary",
242
+ shortcut: "Alt+Shift+I",
243
+ run: { tab: OVERVIEW_TAB }
244
+ }],
245
+ tabs: [
246
+ tab("overview", "Overview", "overview", 10, () => import("./overview-3DNXEQNY.js")),
247
+ tab("data", "Data", "table", 20, () => import("./data-UCCW2VWH.js")),
248
+ tab("queries", "Queries", "query", 30, () => import("./queries-2OHKMTPC.js")),
249
+ tab("structure", "Structure", "tree", 40, () => import("./structure-WRDUXHD4.js")),
250
+ tab("declaration", "Declaration", "code", 50, () => import("./declaration-GVDOGQY6.js"))
251
+ ]
252
+ }
224
253
  });
225
254
  }
226
255
  export {