@holistics/anfra-sdk 0.14.2 → 0.15.1
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/dist/api.d.ts +1 -1
- package/dist/app.d.ts +4 -4
- package/dist/app.js +2 -2
- package/dist/{bootstrap-n07aQzlx.d.ts → bootstrap-hLhpijIb.d.ts} +2 -2
- package/dist/build.d.ts +2 -2
- package/dist/{chunk-KA6ZNM7N.js → chunk-GIHCQT6L.js} +1 -1
- package/dist/{chunk-OWXUFJQA.js → chunk-PYAVAIAX.js} +1 -1
- package/dist/{chunk-DFZTWEXW.js → chunk-YB7VYY72.js} +1 -1
- package/dist/common.d.ts +2 -2
- package/dist/host.d.ts +2 -2
- package/dist/host.js +1 -1
- package/dist/{menu-COEAKOnm.d.ts → menu-BFLb7dVq.d.ts} +1 -1
- package/dist/{overview-B2BWUICP.js → overview-L4KLGZNP.js} +2 -2
- package/dist/{plugin-CMJFCV3-.d.ts → plugin-B7SpJLBm.d.ts} +2 -2
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js +3 -3
- package/dist/testing.js +2 -2
- package/dist/{types-CWNv6N0y.d.ts → types-CKytl8ds.d.ts} +14 -3
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from 'openapi-fetch';
|
|
2
|
-
import { ak as paths, al as components } from './types-
|
|
2
|
+
import { ak as paths, al as components } from './types-CKytl8ds.js';
|
|
3
3
|
import { DatasetDescriptor, Backend, BackendExportRequest, BackendQueryRequest } from './app.js';
|
|
4
4
|
import { DataAppError } from './app.js';
|
|
5
5
|
|
package/dist/app.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as Sdk } from './bootstrap-
|
|
2
|
-
export { A as AnfraPlugins, a as App, C as Control, b as CrossFilter, D as DateDrillControl, c as DeprecatedFeatures, E as Edge, F as Filter, d as FrameKernel, e as FrameMenuItem, I as InstalledPlugins, M as Mapping, f as ModalInput, O as OVERLAY_ID, g as Opened, h as PluginApi, i as PluginMembers, j as PluginName, P as PluginSetup, k as PopoverInput, l as PopoverSide, Q as Query, m as STRUCTURE_ATTRIBUTES, V as VERSION, n as bootstrap, o as buildStructure, p as createSdk, q as parseRef } from './bootstrap-
|
|
1
|
+
import { S as Sdk } from './bootstrap-hLhpijIb.js';
|
|
2
|
+
export { A as AnfraPlugins, a as App, C as Control, b as CrossFilter, D as DateDrillControl, c as DeprecatedFeatures, E as Edge, F as Filter, d as FrameKernel, e as FrameMenuItem, I as InstalledPlugins, M as Mapping, f as ModalInput, O as OVERLAY_ID, g as Opened, h as PluginApi, i as PluginMembers, j as PluginName, P as PluginSetup, k as PopoverInput, l as PopoverSide, Q as Query, m as STRUCTURE_ATTRIBUTES, V as VERSION, n as bootstrap, o as buildStructure, p as createSdk, q as parseRef } from './bootstrap-hLhpijIb.js';
|
|
3
3
|
export { D as DataAppError, P as PermissionError, Q as QueryError, T as TransportError, V as ValidationError } from './errors-CKvqVaqU.js';
|
|
4
|
-
export { A as Aggregation, a as AppDeclaration, b as AppJson, c as ArrowType, B as Backend, d as BackendCondition, e as BackendDateDrill, f as BackendExportRequest, g as BackendFilter, h as BackendLineageRequest, i as BackendQueryRequest, j as BackendQueryResult, k as BackendSort, C as ColumnMeta, l as Condition, m as ConditionValue, n as ControlMappingJson, o as CrossFilterJson, D as DatasetDescriptor, p as DateDrillDeclaration, q as DateGrain, r as DateTransformation, E as EntityKind, s as EntityRef, t as EntityUsage, u as ExecuteOptions, v as ExecuteSummary, w as ExportFormat, x as ExportFormatOptions, y as ExportOptions, z as ExportResult, F as FILTER_AGGREGATIONS, G as FieldLineage, H as FieldSuggestionsRequest, I as FilterAggregation, J as FilterDeclaration, K as FilterValueType, L as InspectedApp, M as InspectedControl, N as InspectedError, O as InspectedQuery, P as InspectedSelection, Q as InspectedStructure, R as LineageCard, S as LineageDiagram, T as LineageNode, U as LineageOptions, V as LineageResult, W as LineageTarget, X as Listener, Y as LocateKind, Z as LocateTarget, _ as MappingJson, $ as Operator, a0 as QueryDebug, a1 as QueryDeclaration, a2 as QueryInput, a3 as QueryResult, a4 as QuerySort, a5 as QueryState, a6 as QueryTimings, a7 as RenderFormat, a8 as RenderRequest, a9 as Rendering, aa as Row, ab as SdkEnvironment, ac as SdkFeatures, ad as Selection, ae as SelectionCondition, af as SemanticType, ag as StructureKind, ah as StructureNode, ai as Unsubscribe, aj as User } from './types-
|
|
5
|
-
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetRect, h as Theme, i as ThemeInput, j as ThemeScheme, k as ThemeToken, l as ThemeTokens, m as checkTarget, n as designTheme, r as resolveTheme } from './menu-
|
|
4
|
+
export { A as Aggregation, a as AppDeclaration, b as AppJson, c as ArrowType, B as Backend, d as BackendCondition, e as BackendDateDrill, f as BackendExportRequest, g as BackendFilter, h as BackendLineageRequest, i as BackendQueryRequest, j as BackendQueryResult, k as BackendSort, C as ColumnMeta, l as Condition, m as ConditionValue, n as ControlMappingJson, o as CrossFilterJson, D as DatasetDescriptor, p as DateDrillDeclaration, q as DateGrain, r as DateTransformation, E as EntityKind, s as EntityRef, t as EntityUsage, u as ExecuteOptions, v as ExecuteSummary, w as ExportFormat, x as ExportFormatOptions, y as ExportOptions, z as ExportResult, F as FILTER_AGGREGATIONS, G as FieldLineage, H as FieldSuggestionsRequest, I as FilterAggregation, J as FilterDeclaration, K as FilterValueType, L as InspectedApp, M as InspectedControl, N as InspectedError, O as InspectedQuery, P as InspectedSelection, Q as InspectedStructure, R as LineageCard, S as LineageDiagram, T as LineageNode, U as LineageOptions, V as LineageResult, W as LineageTarget, X as Listener, Y as LocateKind, Z as LocateTarget, _ as MappingJson, $ as Operator, a0 as QueryDebug, a1 as QueryDeclaration, a2 as QueryInput, a3 as QueryResult, a4 as QuerySort, a5 as QueryState, a6 as QueryTimings, a7 as RenderFormat, a8 as RenderRequest, a9 as Rendering, aa as Row, ab as SdkEnvironment, ac as SdkFeatures, ad as Selection, ae as SelectionCondition, af as SemanticType, ag as StructureKind, ah as StructureNode, ai as Unsubscribe, aj as User } from './types-CKytl8ds.js';
|
|
5
|
+
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetRect, h as Theme, i as ThemeInput, j as ThemeScheme, k as ThemeToken, l as ThemeTokens, m as checkTarget, n as designTheme, r as resolveTheme } from './menu-BFLb7dVq.js';
|
|
6
6
|
|
|
7
7
|
declare const SANDBOX_GLOBAL = "Anfra";
|
|
8
8
|
/**
|
package/dist/app.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
createSdk,
|
|
23
23
|
installSandbox,
|
|
24
24
|
parseRef
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-YB7VYY72.js";
|
|
26
26
|
import {
|
|
27
27
|
FILTER_AGGREGATIONS
|
|
28
28
|
} from "./chunk-XIUFHRZE.js";
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
designTheme,
|
|
36
36
|
resolveTheme
|
|
37
37
|
} from "./chunk-RXPNL7UR.js";
|
|
38
|
-
import "./chunk-
|
|
38
|
+
import "./chunk-GIHCQT6L.js";
|
|
39
39
|
import {
|
|
40
40
|
DataAppError,
|
|
41
41
|
PermissionError,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { D as DataAppError, V as ValidationError, Q as QueryError, P as PermissionError, T as TransportError } from './errors-CKvqVaqU.js';
|
|
2
|
-
import { X as Listener, ai as Unsubscribe, D as DatasetDescriptor, y as ExportOptions, z as ExportResult, a8 as RenderRequest, a9 as Rendering, W as LineageTarget, U as LineageOptions, V as LineageResult, E as EntityKind, l as Condition, J as FilterDeclaration, K as FilterValueType, B as Backend, m as ConditionValue, p as DateDrillDeclaration, q as DateGrain, I as FilterAggregation, n as ControlMappingJson, o as CrossFilterJson, ac as SdkFeatures, ad as Selection, ae as SelectionCondition, aa as Row, Y as LocateKind, a1 as QueryDeclaration, a5 as QueryState, a3 as QueryResult, a4 as QuerySort, a as AppDeclaration, u as ExecuteOptions, v as ExecuteSummary, f as BackendExportRequest, b as AppJson, L as InspectedApp, aj as User, ab as SdkEnvironment, Q as InspectedStructure } from './types-
|
|
3
|
-
import { e as PluginInfo, j as ThemeScheme, l as ThemeTokens, h as Theme, d as MenuTargetKind, c as MenuTarget, N as NodeTarget } from './menu-
|
|
2
|
+
import { X as Listener, ai as Unsubscribe, D as DatasetDescriptor, y as ExportOptions, z as ExportResult, a8 as RenderRequest, a9 as Rendering, W as LineageTarget, U as LineageOptions, V as LineageResult, E as EntityKind, l as Condition, J as FilterDeclaration, K as FilterValueType, B as Backend, m as ConditionValue, p as DateDrillDeclaration, q as DateGrain, I as FilterAggregation, n as ControlMappingJson, o as CrossFilterJson, ac as SdkFeatures, ad as Selection, ae as SelectionCondition, aa as Row, Y as LocateKind, a1 as QueryDeclaration, a5 as QueryState, a3 as QueryResult, a4 as QuerySort, a as AppDeclaration, u as ExecuteOptions, v as ExecuteSummary, f as BackendExportRequest, b as AppJson, L as InspectedApp, aj as User, ab as SdkEnvironment, Q as InspectedStructure } from './types-CKytl8ds.js';
|
|
3
|
+
import { e as PluginInfo, j as ThemeScheme, l as ThemeTokens, h as Theme, d as MenuTargetKind, c as MenuTarget, N as NodeTarget } from './menu-BFLb7dVq.js';
|
|
4
4
|
|
|
5
5
|
interface NotificationTarget {
|
|
6
6
|
notifyChange(): void;
|
package/dist/build.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FrameHalf } from './host.js';
|
|
2
|
-
import './types-
|
|
3
|
-
import './menu-
|
|
2
|
+
import './types-CKytl8ds.js';
|
|
3
|
+
import './menu-BFLb7dVq.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @holistics/anfra-sdk/build: building an SDK plugin's frame half into the script source a host
|
package/dist/common.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { D as DataAppError, P as PermissionError, Q as QueryError, T as TransportError, V as ValidationError } from './errors-CKvqVaqU.js';
|
|
2
|
-
export { A as Aggregation, a as AppDeclaration, b as AppJson, c as ArrowType, B as Backend, d as BackendCondition, e as BackendDateDrill, f as BackendExportRequest, g as BackendFilter, h as BackendLineageRequest, i as BackendQueryRequest, j as BackendQueryResult, k as BackendSort, C as ColumnMeta, l as Condition, m as ConditionValue, n as ControlMappingJson, o as CrossFilterJson, D as DatasetDescriptor, p as DateDrillDeclaration, q as DateGrain, r as DateTransformation, E as EntityKind, s as EntityRef, t as EntityUsage, u as ExecuteOptions, v as ExecuteSummary, w as ExportFormat, x as ExportFormatOptions, y as ExportOptions, z as ExportResult, F as FILTER_AGGREGATIONS, G as FieldLineage, H as FieldSuggestionsRequest, I as FilterAggregation, J as FilterDeclaration, K as FilterValueType, L as InspectedApp, M as InspectedControl, N as InspectedError, O as InspectedQuery, P as InspectedSelection, Q as InspectedStructure, R as LineageCard, S as LineageDiagram, T as LineageNode, U as LineageOptions, V as LineageResult, W as LineageTarget, X as Listener, Y as LocateKind, Z as LocateTarget, _ as MappingJson, $ as Operator, a0 as QueryDebug, a1 as QueryDeclaration, a2 as QueryInput, a3 as QueryResult, a4 as QuerySort, a5 as QueryState, a6 as QueryTimings, a7 as RenderFormat, a8 as RenderRequest, a9 as Rendering, aa as Row, ab as SdkEnvironment, ac as SdkFeatures, ad as Selection, ae as SelectionCondition, af as SemanticType, ag as StructureKind, ah as StructureNode, ai as Unsubscribe, aj as User } from './types-
|
|
3
|
-
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetRect, h as Theme, i as ThemeInput, j as ThemeScheme, k as ThemeToken, l as ThemeTokens, m as checkTarget, n as designTheme, r as resolveTheme } from './menu-
|
|
2
|
+
export { A as Aggregation, a as AppDeclaration, b as AppJson, c as ArrowType, B as Backend, d as BackendCondition, e as BackendDateDrill, f as BackendExportRequest, g as BackendFilter, h as BackendLineageRequest, i as BackendQueryRequest, j as BackendQueryResult, k as BackendSort, C as ColumnMeta, l as Condition, m as ConditionValue, n as ControlMappingJson, o as CrossFilterJson, D as DatasetDescriptor, p as DateDrillDeclaration, q as DateGrain, r as DateTransformation, E as EntityKind, s as EntityRef, t as EntityUsage, u as ExecuteOptions, v as ExecuteSummary, w as ExportFormat, x as ExportFormatOptions, y as ExportOptions, z as ExportResult, F as FILTER_AGGREGATIONS, G as FieldLineage, H as FieldSuggestionsRequest, I as FilterAggregation, J as FilterDeclaration, K as FilterValueType, L as InspectedApp, M as InspectedControl, N as InspectedError, O as InspectedQuery, P as InspectedSelection, Q as InspectedStructure, R as LineageCard, S as LineageDiagram, T as LineageNode, U as LineageOptions, V as LineageResult, W as LineageTarget, X as Listener, Y as LocateKind, Z as LocateTarget, _ as MappingJson, $ as Operator, a0 as QueryDebug, a1 as QueryDeclaration, a2 as QueryInput, a3 as QueryResult, a4 as QuerySort, a5 as QueryState, a6 as QueryTimings, a7 as RenderFormat, a8 as RenderRequest, a9 as Rendering, aa as Row, ab as SdkEnvironment, ac as SdkFeatures, ad as Selection, ae as SelectionCondition, af as SemanticType, ag as StructureKind, ah as StructureNode, ai as Unsubscribe, aj as User } from './types-CKytl8ds.js';
|
|
3
|
+
export { B as BridgeError, a as BridgeMessage, D as DEFAULT_TOKENS, b as DESIGN_TOKENS, F as FrameMessage, H as HostMessage, M as MenuEntry, c as MenuTarget, d as MenuTargetKind, N as NodeTarget, P as PROVISION_ELEMENT_ID, e as PluginInfo, f as Provision, R as RowsTarget, T as THEME_TOKENS, g as TargetRect, h as Theme, i as ThemeInput, j as ThemeScheme, k as ThemeToken, l as ThemeTokens, m as checkTarget, n as designTheme, r as resolveTheme } from './menu-BFLb7dVq.js';
|
package/dist/host.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PluginInfo, Theme, ThemeInput, Provision } from './app.js';
|
|
2
2
|
import { DatasetDescriptor, User } from './app.js';
|
|
3
|
-
import { C as Command, T as Tab, a as CallOptions, P as Panel, b as CommandState, c as Plugin, M as Middleware, d as CommandContribution, e as TabContribution, f as Contribution } from './plugin-
|
|
4
|
-
export { g as CallContext, h as CallDefinition, i as CallHandler, j as Caller, k as CommandRun, l as CommandStateContext, E as EventCheck, F as FrameHalf, H as HandlerCallOptions, m as HandlerContext, n as HostHalf, o as MountContext, p as PanelVerb, S as Snapshot, q as TabContext, r as definePlugin } from './plugin-
|
|
3
|
+
import { C as Command, T as Tab, a as CallOptions, P as Panel, b as CommandState, c as Plugin, M as Middleware, d as CommandContribution, e as TabContribution, f as Contribution } from './plugin-B7SpJLBm.js';
|
|
4
|
+
export { g as CallContext, h as CallDefinition, i as CallHandler, j as Caller, k as CommandRun, l as CommandStateContext, E as EventCheck, F as FrameHalf, H as HandlerCallOptions, m as HandlerContext, n as HostHalf, o as MountContext, p as PanelVerb, S as Snapshot, q as TabContext, r as definePlugin } from './plugin-B7SpJLBm.js';
|
|
5
5
|
|
|
6
6
|
interface HostOptions {
|
|
7
7
|
/** The plugins this page's Data Apps get. `core` is required: the app model runs its queries with it. */
|
package/dist/host.js
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import "./chunk-PKBMQBKP.js";
|
|
25
25
|
|
|
26
26
|
// anfra-sdk:anfra-sdk:frame-script
|
|
27
|
-
var anfra_sdk_frame_script_default = '"use strict";var __anfraKernel=(()=>{var z=Object.defineProperty;var Ft=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Pt=Object.prototype.hasOwnProperty;var Qt=(e,n,t)=>n in e?z(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var i=(e,n)=>z(e,"name",{value:n,configurable:!0});var Lt=(e,n)=>{for(var t in n)z(e,t,{get:n[t],enumerable:!0})},Bt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of It(n))!Pt.call(e,o)&&o!==t&&z(e,o,{get:()=>n[o],enumerable:!(r=Ft(n,o))||r.enumerable});return e};var zt=e=>Bt(z({},"__esModule",{value:!0}),e);var u=(e,n,t)=>Qt(e,typeof n!="symbol"?n+"":n,t);var Qn={};Lt(Qn,{bootstrap:()=>Nt});var Le="anfra-provision";var re=class re extends Error{constructor(t,r){super(t);u(this,"entity");this.name=new.target.name,this.entity=r,Object.setPrototypeOf(this,new.target.prototype)}};i(re,"DataAppError");var O=re,oe=class oe extends O{};i(oe,"ValidationError");var g=oe,ie=class ie extends O{constructor(t,r,o){super(t,r);u(this,"cause");this.cause=o}};i(ie,"QueryError");var _=ie,se=class se extends O{};i(se,"PermissionError");var N=se,ae=class ae extends O{constructor(t,r,o){super(t,o);u(this,"status");this.status=r}};i(ae,"TransportError");var $=ae;function Be(){let e=new Error("Aborted");return e.name="AbortError",e}i(Be,"abortError");function Vt(e){return e?.name==="AbortError"}i(Vt,"isAbortError");var Kt=new Set(["ValidationError","QueryError","PermissionError","TransportError"]);function jt(e){let n=e;return n instanceof Error&&Kt.has(n.name)?{name:n.name,message:n.message||"The call failed."}:{name:"QueryError",message:"The call failed."}}i(jt,"toBridgeError");function Ut(e){switch(e?.name){case"PermissionError":return new N(e.message);case"TransportError":return new $(e.message);case"ValidationError":return new g(e.message);default:return new _(e?.message||"The call failed.")}}i(Ut,"fromBridgeError");function ze(e,n){let t=new Map,r=new Map,o=1,a=i((l,s,c)=>{let f=new AbortController;r.set(l,f),Promise.resolve().then(()=>n.answer(s,c,f.signal)).then(w=>{f.signal.aborted||e({type:"anfra:result",id:l,ok:!0,result:w})}).catch(w=>{f.signal.aborted||Vt(w)||e({type:"anfra:result",id:l,ok:!1,error:jt(w)})}).finally(()=>{r.get(l)===f&&r.delete(l)})},"answer");return{call(l,s,c){return new Promise((f,w)=>{if(c?.aborted){w(Be());return}let S=o++;t.set(S,{resolve:f,reject:w}),c?.addEventListener("abort",()=>{t.delete(S)&&(e({type:"anfra:cancel",id:S}),w(Be()))},{once:!0}),e({type:"anfra:call",id:S,name:l,request:s})})},emit(l,s){e({type:"anfra:event",name:l,payload:s})},receive(l){switch(l?.type){case"anfra:call":return a(l.id,l.name,l.request),!0;case"anfra:result":{let s=t.get(l.id);return s&&(t.delete(l.id),l.ok?s.resolve(l.result):s.reject(Ut(l.error))),!0}case"anfra:cancel":return r.get(l.id)?.abort(),r.delete(l.id),!0;case"anfra:event":return n.event(l.name,l.payload),!0;default:return!1}},close(l){r.forEach(s=>s.abort()),r.clear(),t.forEach(({reject:s})=>s(l)),t.clear()}}}i(ze,"createEndpoint");var le=class le{constructor(n){u(this,"listeners",new Set);u(this,"parent");this.parent=n}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}notifyChange(){this.listeners.forEach(n=>n()),this.parent?.notifyChange()}notify(){this.notifyChange()}};i(le,"Observable");var P=le;var Ve=["year","quarter","month","week","day","hour","minute"];function Jt(e,n){if(!Ve.includes(n))throw new g(`Invalid grain \'${n}\'. Expected one of: ${Ve.join(", ")}.`,e)}i(Jt,"assertGrain");function Ke(e,n){return n?(Jt(e,n),{operator:"transform_date_drill",values:[`datetrunc ${n}`]}):{operator:"none"}}i(Ke,"drillCondition");function Gt(e){let n=e.toLowerCase();return n.includes("date")||n.includes("time")?"date":n.includes("int")||n.includes("number")||n.includes("float")||n.includes("decimal")?"number":n.includes("bool")?"boolean":"string"}i(Gt,"inferType");function qt(e,n){return JSON.stringify(e??null)===JSON.stringify(n??null)}i(qt,"sameCondition");var ce=class ce extends P{constructor(t,r,o){super(r);u(this,"name");u(this,"app");u(this,"pending");u(this,"applied");u(this,"initial");this.name=t,this.app=r,this.initial=o,this.pending=o}locate(){return this.app.locate("control",this.name)}get condition(){return this.pending}get appliedCondition(){return this.applied}get isDirty(){return this.applied!==void 0&&!qt(this.pending,this.applied)}setCondition(t){this.pending=t,this.notify()}reset(){this.setCondition(this.initial)}commit(){this.applied=this.pending}};i(ce,"Control");var F=ce,de=class de extends F{constructor(t,r,o,a,l){super(t,r,o.default??{operator:"is",values:[]});u(this,"kind","filter");u(this,"declaration");u(this,"type");u(this,"resolved");u(this,"datasetName");u(this,"backend");u(this,"loadedOptions");if(this.declaration=o,this.backend=l,o.field){if(!a)throw new g(`Filter \'${t}\' names a field but no dataset. Pass \\`dataset\\` alongside \\`field\\`.`,t);this.resolved=a.resolve(o.field,t),this.datasetName=a.descriptor.name,this.type=o.type??Gt(this.resolved.type)}else{if(!o.type)throw new g(`Filter \'${t}\' is a manual filter, so it needs a \\`type\\`.`,t);this.type=o.type}this.assertValues(this.condition.values??[]),this.assertValues(o.options??[])}setCondition(t){this.assertValues(t.values??[]),super.setCondition(t)}assertValues(t){if(this.type!=="number")return;let r=t.find(o=>typeof o=="number");if(r!==void 0)throw new g(`Filter \'${this.name}\' filters numbers: give its values as strings, as query results give them (${JSON.stringify(String(r))}, not ${String(r)}), so none has lost a digit.`,this.name)}get isFieldBacked(){return this.resolved!==void 0}get options(){return this.loadedOptions??this.declaration.options??[]}async loadOptions(t,r=new AbortController().signal){let o=this.resolved?.modelName;if(!this.resolved||!o||!this.backend||!this.datasetName)return this.options;let a=await this.backend.fieldSuggestions({dataset:this.datasetName,model:o,field:this.resolved.fieldName,q:t??""},r);return this.loadedOptions=[...a??[]],this.notify(),this.loadedOptions}toJSON(){return this.declaration}};i(de,"Filter");var U=de,ue=class ue extends F{constructor(t,r,o={}){super(t,r,Ke(t,o.default));u(this,"kind","dateDrill");u(this,"declaration");this.declaration=o}setGrain(t){this.setCondition(Ke(this.name,t))}toJSON(){return this.declaration}};i(ue,"DateDrillControl");var J=ue;var A={container:"data-anfra-container",block:"data-anfra-block",query:"data-anfra-query",control:"data-anfra-control",label:"data-anfra-label"},G=`[${A.container}],[${A.block}],[${A.query}],[${A.control}]`;function je(e){let n=/^(?:(\\d+)\\/)?([^/\\s]+)$/.exec(e);if(n)return{app:n[1]===void 0?0:Number(n[1]),name:n[2]}}i(je,"parseRef");var Ue=i(e=>(e??"").split(/\\s+/).filter(Boolean),"tokens");function Je(e,n,t,r){let o=n==="query"?A.query:A.control;return[...e.querySelectorAll(`[${o}]`)].filter(a=>Ue(a.getAttribute(o)).some(l=>{let s=je(l);return s?.app===t&&s.name===r}))}i(Je,"markersFor");var Ht=i((e,n,t)=>{let r=e[t.app];return r?Object.prototype.hasOwnProperty.call(n==="query"?r.queries:r.controls,t.name):!1},"hasEntity");function Ge(e,n){var S;let t=[],r=new Map,o=new Map,a=new Map,l=new Map,s={container:new Set,block:new Set},c={},f=i((k,x,T)=>{let C=k?a.get(k).children:t,p=k?`${a.get(k).key}.`:"",m={...x,key:`${p}${C.length}`,children:[]};return C.push(m),r.set(m.key,T),o.set(T,[...o.get(T)??[],m.key]),m},"place");for(let k of e.querySelectorAll(G)){let x=k.parentElement?.closest(G)??null,T=k.getAttribute(A.container),C=k.getAttribute(A.block),p=k.getAttribute(A.label)??void 0,m=x&&(l.get(x)==="block"?x:x.closest(`[${A.block}]`)),d;if(T!==null||C!==null){let y=T!==null?"container":"block",b=(T??C??"").trim(),v=[];T!==null&&C!==null&&v.push("This element is marked as a container and as a block. It counts as a container."),b?s[y].has(b)?v.push(`Another ${y} already has the id "${b}".`):s[y].add(b):v.push(`This ${y} has no id.`),m&&v.push(`A block can\'t hold a ${y}. This one is inside the block "${m.getAttribute(A.block)}".`),d=f(x,{kind:y,id:b,...p!==void 0?{label:p}:{},problems:v},k),a.set(k,d),l.set(k,y)}let h=d?k:x;for(let y of["query","control"])for(let b of Ue(k.getAttribute(y==="query"?A.query:A.control))){let v=je(b),E=[];if(v?Ht(n,y,v)||E.push(n[v.app]?`No ${y} is called "${v.name}" in app ${v.app}.`:`The page has no app ${v.app}.`):E.push(`Can\'t read "${b}". Write the ${y}\'s name, or app/name when the page has several apps.`),f(h,{kind:y,name:v?.name??b,app:v?.app??0,problems:E},k),v&&!E.length){let R=`${v.app}/${v.name}`,D=c[S=`${y}:${R}`]??(c[S]={elements:new Set,blocks:new Set});D.elements.add(k);let M=d?.kind==="block"?d.id:m?.getAttribute(A.block);M&&D.blocks.add(M)}}}let w=Object.fromEntries(Object.entries(c).map(([k,x])=>[k,{markers:x.elements.size,blocks:[...x.blocks]}]));return{nodes:t,usage:w,elements:r,keysOf:o}}i(Ge,"buildStructure");var Wt=i((e,n,t)=>`${e}:${n}/${t}`,"usageKey");function Yt(e){let n=e.getBoundingClientRect();return`${Math.round(n.width)} \\xD7 ${Math.round(n.height)}`}i(Yt,"sizeOf");function qe(e,n,t){let r=Yt(n);if(e.kind==="container"||e.kind==="block")return{kind:e.kind,name:e.id??"",...e.label?{label:e.label}:{},size:r};let o=t.usage[Wt(e.kind,e.app??0,e.name??"")];return{kind:e.kind,name:e.name??"",...o&&o.markers>1?{note:`1 of ${o.markers}`}:{},size:r}}i(qe,"describeNode");var Ye=["color-bg","color-fg","color-muted","color-border","color-accent","color-danger","radius","font","font-mono","color-bg-sunken","color-fg-weak","color-border-strong","color-hover","color-active","color-selected","color-warning","color-success"],He="\'Inter Variable\', ui-sans-serif, system-ui, sans-serif",We="\'Geist Mono Variable\', ui-monospace, monospace",pe={light:{"color-bg":"oklch(1 0 0)","color-bg-sunken":"oklch(0.973 0.005 95.1)","color-fg":"oklch(0.201 0.022 301.1)","color-fg-weak":"oklch(0.392 0.021 304.3)","color-muted":"oklch(0.485 0.022 306.3)","color-border":"oklch(0.201 0.022 301.1 / 0.12)","color-border-strong":"oklch(0.201 0.022 301.1 / 0.24)","color-accent":"oklch(0.484 0.181 298.1)","color-danger":"oklch(0.501 0.17 27.2)","color-warning":"oklch(0.501 0.1 70.3)","color-success":"oklch(0.479 0.1 151.8)","color-hover":"oklch(0.201 0.022 301.1 / 0.05)","color-active":"oklch(0.201 0.022 301.1 / 0.09)","color-selected":"oklch(0.946 0.027 304.8)",radius:"10px",font:He,"font-mono":We},dark:{"color-bg":"oklch(0.19 0.012 300)","color-bg-sunken":"oklch(0.157 0.009 296.9)","color-fg":"oklch(0.961 0.007 304.2)","color-fg-weak":"oklch(0.879 0.016 302.5)","color-muted":"oklch(0.835 0.018 300)","color-border":"oklch(0.343 0.025 298.2)","color-border-strong":"oklch(0.392 0.021 304.3)","color-accent":"oklch(0.845 0.085 300)","color-danger":"oklch(0.82 0.09 27)","color-warning":"oklch(0.84 0.12 69.6)","color-success":"oklch(0.8 0.12 151.9)","color-hover":"oklch(1 0 0 / 0.06)","color-active":"oklch(1 0 0 / 0.1)","color-selected":"oklch(0.565 0.194 300.3 / 0.18)",radius:"10px",font:He,"font-mono":We}};var Xt=/[;{}<>]|url\\(|expression\\(|@import|\\\\/i;function Xe(e){let n=typeof e=="object"&&e!==null?e:{},t=n.scheme==="dark"?"dark":"light",r={...pe[t]},o=typeof n.tokens=="object"&&n.tokens!==null?n.tokens:{},a=new Set;for(let l of Ye){let s=o[l];typeof s=="string"&&s.trim()!==""&&s.length<=200&&!Xt.test(s)&&(r[l]=s.trim(),a.add(l))}for(let[l,{from:s,value:c}]of Object.entries(Zt)){if(a.has(l)||!s.some(w=>a.has(w)))continue;let f=c(r);f.length<=200&&(r[l]=f)}return Object.freeze({scheme:t,tokens:Object.freeze(r)})}i(Xe,"resolveTheme");var Zt={"color-bg-sunken":{from:["color-fg","color-bg"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 4%, ${e["color-bg"]})`,"value")},"color-fg-weak":{from:["color-fg","color-bg"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 80%, ${e["color-bg"]})`,"value")},"color-border-strong":{from:["color-fg","color-border"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 10%, ${e["color-border"]})`,"value")},"color-hover":{from:["color-fg"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 7%, transparent)`,"value")},"color-active":{from:["color-fg"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 12%, transparent)`,"value")},"color-selected":{from:["color-accent"],value:i(e=>`color-mix(in srgb, ${e["color-accent"]} 14%, transparent)`,"value")}};function fe(e,n){for(let t of Ye)e.setProperty(`--anfra-${t}`,n.tokens[t]);e.setProperty("color-scheme",n.scheme)}i(fe,"applyTheme");var me="data-anfra-layer",Ze=new WeakMap,en="position:absolute;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483647;";function tn(e){let n=e.querySelector(`[${me}]`);if(n instanceof(e.defaultView?.HTMLElement??HTMLElement))return n;let t=e.createElement("div");t.setAttribute(me,""),t.setAttribute("style",en);let r=Ze.get(e);return r&&fe(t.style,r),(e.body??e.documentElement).appendChild(t),t}i(tn,"layerOf");function L(e,n){let t=tn(e),r=[...t.children].find(a=>a.getAttribute("data-part")===n);if(r?.shadowRoot)return r.shadowRoot;let o=e.createElement("div");return o.setAttribute("data-part",n),t.appendChild(o),o.attachShadow({mode:"open"})}i(L,"layerRoot");function et(e,n){Ze.set(e,n);let t=e.querySelector(`[${me}]`);t&&fe(t.style,n)}i(et,"themeLayer");var tt="anfra-overlay",nn=1500,rn="position:fixed;box-sizing:border-box;background:oklch(0.546 0.215 262.9 / 0.22);outline:1px solid oklch(0.546 0.215 262.9);outline-offset:-1px;",on="position:fixed;max-width:60vw;display:flex;gap:6px;align-items:baseline;padding:3px 8px;border-radius:4px;background:oklch(0.208 0.04 265.8);color:oklch(0.984 0.003 247.9);font:12px/1.4 system-ui,sans-serif;white-space:nowrap;box-shadow:0 2px 8px oklch(0 0 0 / 0.35);",sn={kind:"color:oklch(0.711 0.035 256.8);",name:"color:oklch(0.809 0.096 251.8);font-weight:700;",label:"color:oklch(0.984 0.003 247.9);",note:"color:oklch(0.711 0.035 256.8);",size:"color:oklch(0.711 0.035 256.8);margin-left:10px;"},ge=class ge{constructor(n){u(this,"doc",n);u(this,"root");u(this,"shown",[]);u(this,"text",{kind:"",name:""});u(this,"timer");u(this,"reposition",i(()=>this.draw(),"reposition"));let t=L(n,"anfra"),r=t.getElementById(tt);r instanceof(n.defaultView?.HTMLElement??HTMLElement)?this.root=r:(this.root=n.createElement("div"),this.root.id=tt,this.root.setAttribute("aria-hidden","true"),this.root.setAttribute("style","position:fixed;inset:0;z-index:2147483647;pointer-events:none;display:none;"),t.appendChild(this.root))}show(n,t){if(this.clearTimer(),this.root.isConnected||L(this.doc,"anfra").appendChild(this.root),this.shown=[...n],this.text=t,!this.shown.length){this.hide();return}this.root.style.display="block",this.draw(),this.doc.addEventListener("scroll",this.reposition,{capture:!0,passive:!0}),this.doc.defaultView?.addEventListener("resize",this.reposition)}flash(n,t,r=nn){this.show(n,t),this.timer=setTimeout(()=>this.hide(),r)}hide(){this.clearTimer(),this.shown=[],this.root.style.display="none",this.root.replaceChildren(),this.doc.removeEventListener("scroll",this.reposition,{capture:!0}),this.doc.defaultView?.removeEventListener("resize",this.reposition)}get visible(){return this.shown.length>0}clearTimer(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}draw(){let n=this.shown.map(s=>{let c=s.getBoundingClientRect(),f=this.doc.createElement("div");return f.setAttribute("style",`${rn}left:${c.left}px;top:${c.top}px;width:${c.width}px;height:${c.height}px;`),f}),t=this.shown[0].getBoundingClientRect(),r=this.doc.createElement("div");r.setAttribute("data-testid","anfra-overlay-label");let o=this.doc.defaultView?.innerHeight??0,a=t.top>=26?t.top-24:Math.max(4,t.top+4),l=Math.max(4,Math.min(t.left,(this.doc.defaultView?.innerWidth??0)-24));r.setAttribute("style",`${on}left:${l}px;top:${Math.min(a,o-24)}px;`);for(let s of["kind","name","label","note","size"]){let c=this.text[s];if(!c)continue;let f=this.doc.createElement("span");f.setAttribute("style",sn[s]),f.setAttribute("data-part",s),f.textContent=c,r.appendChild(f)}this.root.replaceChildren(...n,r)}};i(ge,"Overlay");var he=ge,nt=new WeakMap;function q(e){let n=nt.get(e);return n||(n=new he(e),nt.set(e,n)),n}i(q,"overlayFor");function H(e){typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}i(H,"scrollTo");function rt(e,n){let t=null,r=i(c=>c.target instanceof Element?c.target.closest(G):null,"under"),o=i(c=>{let f=r(c);f!==t&&(t=f,n.onHover(f))},"onMove"),a=i(c=>{c.preventDefault(),c.stopPropagation();let f=r(c);f&&n.onPick(f)},"onClick"),l=i(c=>{c.key==="Escape"&&n.onCancel()},"onKey"),s={capture:!0};return e.addEventListener("mousemove",o,s),e.addEventListener("click",a,s),e.addEventListener("keydown",l,s),()=>{e.removeEventListener("mousemove",o,s),e.removeEventListener("click",a,s),e.removeEventListener("keydown",l,s)}}i(rt,"startPick");function ot(e,n){for(let t of e){if(t.key===n)return t;let r=ot(t.children,n);if(r)return r}}i(ot,"findNode");function it(e){let n=e.window,t=n.document,r=!1,o,a,l="",s,c;function f(){if(o=void 0,!!r)try{a=e.structure(),l=JSON.stringify(a.nodes),e.emit("snapshot",{apps:e.sdk.apps.map(p=>p.toInspectJSON()),structure:{nodes:a.nodes,usage:a.usage}})}catch{}}i(f,"postSnapshot");function w(){r&&o===void 0&&(o=setTimeout(f,50))}i(w,"scheduleSnapshot");function S(){let p=n.MutationObserver;if(s||typeof p!="function")return;let m=new p(()=>{if(!(!r||o!==void 0))try{JSON.stringify(e.structure().nodes)!==l&&w()}catch{}});s=m,m.observe(t.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:Object.values(A)})}i(S,"observeStructure");function k(p){let m=p!==null&&a?ot(a.nodes,p):void 0,d=p!==null?a?.elements.get(p):void 0;if(!m||!d||!a){e.overlay.hide();return}e.overlay.show([d],qe(m,d,a))}i(k,"highlight");function x(p){if(!p){c?.(),c=void 0;return}if(c)return;let m=i(d=>a?.keysOf.get(d)?.[0],"keyOf");c=rt(t,{onHover:i(d=>k(d?m(d)??null:null),"onHover"),onPick:i(d=>{let h=m(d);h!==void 0&&e.emit("picked",{node:h})},"onPick"),onCancel:i(()=>{x(!1),e.overlay.hide(),e.emit("picked",{node:null})},"onCancel")})}i(x,"setPicking");function T(p){r=p,p?(S(),f()):(s?.disconnect(),s=void 0,x(!1),e.overlay.hide(),a=void 0,l="")}i(T,"setInspecting");function C(p){if("node"in p){let m=a?.elements.get(p.node);m&&H(m),k(p.node)}else e.sdk.apps[p.app]?.locate(p.kind,p.name);w()}i(C,"locate"),e.on("watch",p=>T(p===!0)),e.on("highlight",p=>k(p)),e.on("locate",p=>C(p)),e.on("pick",p=>x(p===!0)),e.onApp(p=>{p.subscribe(w),w()})}i(it,"installInspection");var ye;function st(e,n){return ye?ye(e,n):!1}i(st,"openRowsMenu");var an=`[${A.block}]`,ln=\'[data-anfra-menu="off"]\',cn=i(e=>({...e,children:e.children.map(n=>({...n,children:[]}))}),"bare");function at(e,n,t=[]){for(let r of e){if(r.key===n)return[...t,r];let o=at(r.children,n,[...t,r]);if(o)return o}}i(at,"pathTo");var dn=i(e=>typeof e?.closest=="function","isElement");function lt(e){let n=e.window,t=n.document,r=[],o=new Set,a=!1,l,s=i(()=>e.body(),"ui"),c=i(()=>L(t,"anfra-ui"),"root"),f=i(d=>o.has(d)||r.some(h=>h.target===d),"offered"),w=i(()=>{let d=l;l=void 0,d?.()},"closeCurrent");function S(d){let h=dn(d)?d.closest(an):null;return h&&!h.closest(ln)?h:void 0}i(S,"blockOf");function k(d){let h=e.structure(),y=h.keysOf.get(d)?.[0],b=y!==void 0?at(h.nodes,y):void 0;if(!b)return;let{x:v,y:E,width:R,height:D}=d.getBoundingClientRect();return{kind:"node",node:cn(b[b.length-1]),ancestors:b.slice(0,-1).map(M=>({...M,children:[]})),rect:{x:v,y:E,width:R,height:D}}}i(k,"nodeTarget");function x(d){let h=new Map,y=[];for(let b of r){if(b.target!==d.kind)continue;let v=!0;try{v=b.when?b.when(d)!==!1:!0}catch{v=!1}if(!v)continue;let E=`frame:${b.full}:${d.kind}`;y.push({id:E,label:b.label}),h.set(E,()=>b.run(d))}return{entries:y,run:h}}i(x,"frameEntries");async function T(d,h){let y=new Map(h.run),b=[...h.entries];if(o.has(d.kind))try{let v=await e.call("anfra.menu",d);for(let E of Array.isArray(v)?v:[]){if(typeof E?.id!="string"||typeof E.label!="string")continue;let R=`host:${E.id}:${d.kind}`;b.push({id:R,label:E.label,...typeof E.disabled=="string"?{disabled:E.disabled}:{}}),y.set(R,()=>e.call("anfra.run",{id:E.id,target:d}))}}catch{}return{entries:b,run:y}}i(T,"entriesFor");function C(d,h){let y=h.map(R=>({target:R,own:x(R)})).filter(({target:R,own:D})=>D.entries.length||o.has(R.kind));if(!y.length)return!1;d.preventDefault();let b=d,v=typeof b.clientX=="number"?b.clientX:0,E=typeof b.clientY=="number"?b.clientY:0;return(async()=>{let[R,...D]=await Promise.all([s(),...y.map(({target:Q,own:te})=>T(Q,te))]),M=D.map(Q=>Q.entries).filter(Q=>Q.length);if(!M.length)return;w();let j=R.menu(c(),{x:v,y:E,groups:M,onPick:i(Q=>{let te=D.map(ne=>ne.run.get(Q)).find(Boolean);Promise.resolve().then(te).catch(ne=>n.console?.error("anfra: a menu item failed:",ne))},"onPick"),onClose:i(()=>{l===j&&(l=void 0)},"onClose")});l=j})().catch(R=>n.console?.error("anfra: the menu failed to open:",R)),!0}i(C,"open");function p(){a||!(f("node")||f("rows"))||(a=!0,n.addEventListener("contextmenu",d=>{if(d.defaultPrevented||d.shiftKey)return;let h=S(d.target),y=h&&k(h);y&&C(d,[y])}))}i(p,"listen"),ye=i((d,h)=>{if(d.defaultPrevented||d.shiftKey)return!1;let y=S(d.target),b=y?k(y):void 0,v=b?{...h,node:b}:h;return C(d,b?[v,b]:[v])},"rowsOpener"),e.on("menu",d=>{let h=d?.kinds;o=new Set((Array.isArray(h)?h:[]).filter(y=>y==="node"||y==="rows")),p()});async function m(d,h){let y=await s();w();let b=i(()=>{},"close");return b=h(y,i(()=>{l===b&&(l=void 0);try{d.onClose?.()}catch{}},"onClose")),l=b,{close:b}}return i(m,"show"),{addItem(d,h){r.push({...h,full:`${d}.${h.id}`}),p()},modal:i(d=>m(d,(h,y)=>h.modal(c(),{title:d.title,size:d.size,mount:d.mount,onClose:y})),"modal"),popover:i(d=>m(d,(h,y)=>{let{anchor:b}=d,v;if("kind"in b){let E=e.structure().elements.get(b.node.key);v=i(()=>{if(!E?.isConnected)return;let{x:R,y:D,width:M,height:j}=E.getBoundingClientRect();return{x:R,y:D,width:M,height:j}},"rect")}else v=i(()=>({x:b.x,y:b.y,width:0,height:0}),"rect");return h.popover(c(),{anchor:v,side:d.side,mount:d.mount,dismiss:d.dismiss,closeButton:d.closeButton,onClose:y})}),"popover")}}i(lt,"installContentUi");var ct=["ctrl","alt","shift","meta"];function dt(e){if(typeof e!="string")return;let n=e.split("+").map(o=>o.trim().toLowerCase()).filter(Boolean),t=n.pop(),r=i(o=>ct.includes(o),"isModifier");if(!(!t||r(t)||!n.every(r)))return[...ct.filter(o=>n.includes(o)),t].join("+")}i(dt,"normalizeShortcut");function ut(e){let n=e;return!n||typeof n.tagName!="string"?!1:n.isContentEditable===!0||["INPUT","TEXTAREA","SELECT"].includes(n.tagName.toUpperCase())}i(ut,"isTyping");function pt(e){let n=typeof e.code=="string"?e.code:"",t=/^Key[A-Z]$/.test(n)?n.slice(3).toLowerCase():/^Digit[0-9]$/.test(n)?n.slice(5):(e.key??"").toLowerCase();return[e.ctrlKey&&"ctrl",e.altKey&&"alt",e.shiftKey&&"shift",e.metaKey&&"meta",t].filter(Boolean).join("+")}i(pt,"eventShortcut");function be(e,n,t,r,o){if(r in n||e.has(r))throw new g(`Plugin \'${r}\' can\'t add \'${r}\' to a ${t}: it already has one.`);e.set(r,o)}i(be,"addExtension");function W(e,n){return n?.forEach((t,r)=>{let o=!1,a;Object.defineProperty(e,r,{configurable:!0,enumerable:!1,get(){return o||(a=t(e),o=!0),a}})}),e}i(W,"applyExtensions");var un="anfra.body",we="__anfraBodyExports",pn={DataAppError:O,ValidationError:g,QueryError:_,PermissionError:N,TransportError:$};function fn(e,n){let t=e,r=e.document.createElement("script");r.textContent=`(function () { var __anfraBody;\n${n}\n;self[${JSON.stringify(we)}] = __anfraBody; })();`,(e.document.head??e.document.documentElement).appendChild(r),r.remove();let o=t[we];if(delete t[we],!o)throw new g("The host sent a plugin body that did not run.");return o.default??o}i(fn,"runBody");function ke(e,n,t){let{window:r,sdk:o,endpoint:a}=n,l;return{plugin:e,window:r,sdk:o,errors:pn,get overlay(){return q(r.document)},structure:i(()=>Ge(r.document,o.apps),"structure"),call:i((s,c,f)=>a.call(s,c??null,f),"call"),emit:i((s,c)=>a.emit(`${e}.${s}`,c??null),"emit"),handle(s,c){n.handlers.set(`${e}.${s}`,c)},on(s,c){let f=`${e}.${s}`;n.listeners.has(f)||n.listeners.set(f,new Set),n.listeners.get(f).add(c)},onApp(s){n.appListeners.add(s),o.apps.forEach(c=>s(c))},provide(s){if(e in o)throw new g(`Plugin \'${e}\' can\'t add a member Anfra already has.`);Object.defineProperty(o,e,{value:s,enumerable:!0})},provideOnQuery:i(s=>be(o.extensions.query,t.Query.prototype,"query",e,s),"provideOnQuery"),provideOnControl:i(s=>be(o.extensions.control,t.Control.prototype,"control",e,s),"provideOnControl"),layer:i(()=>L(r.document,e),"layer"),menuItem:i(s=>n.contentUi?.addItem(e,s),"menuItem"),modal:i(s=>n.contentUi.modal(s),"modal"),popover:i(s=>n.contentUi.popover(s),"popover"),body(){return l??(l=a.call(un,{plugin:e}).then(s=>fn(r,s)).catch(s=>{throw l=void 0,s})),l}}}i(ke,"createKernel");var ve=class ve extends P{constructor(t,r,o){super(r);u(this,"kind","query");u(this,"name");u(this,"declaration");u(this,"dataset");u(this,"app");u(this,"_state","idle");u(this,"_result");u(this,"_error");u(this,"_page",1);u(this,"_sort",[]);u(this,"lastRunSignature");u(this,"lastPageRows",0);u(this,"controller");if(!o.aql?.trim())throw new g(`Query \'${t}\' declares no AQL.`,t);let{pageSize:a}=o;if(a!==void 0&&!(Number.isInteger(a)&&a>=1))throw new g(`Query \'${t}\' declares pageSize ${a}; it must be a whole number of at least 1.`,t);this.name=t,this.app=r,this.declaration=o,this.dataset=r.datasetIndex(o.dataset,t)}locate(){return this.app.locate("query",this.name)}get state(){return this._state}get result(){return this._result}get error(){return this._error}get pageSize(){return this.declaration.pageSize}get page(){return this._page}get sort(){return this._sort}setSort(t){this._sort=[...t],this.notify()}get hasMore(){return!this._result||this.pageSize===void 0?!1:this._result.meta.hasMore??this.lastPageRows>=this.pageSize}signature(){let t=this.app.mappingsTo(this.name).map(r=>({field:r.field,aggregation:r.aggregation,condition:r.from.condition})).sort((r,o)=>r.field.localeCompare(o.field)||JSON.stringify(r).localeCompare(JSON.stringify(o)));return JSON.stringify({declaration:this.declaration,conditions:t,selection:this.app.selectionConditionsFor(this.name,"pending"),selectionExpression:this.app.selectionExpressionFor(this.name,"pending"),sort:this._sort,timezone:this.app.timezone,page:this._page})}get isDirty(){return this.lastRunSignature!==void 0&&this.signature()!==this.lastRunSignature}shouldRun(t=!1){return t||this.lastRunSignature===void 0||this.isDirty}abort(){this.controller?.abort()}async fetchMore(){if(this.pageSize===void 0)throw new g(`Query \'${this.name}\' declares no pageSize, so it has no more pages.`,this.name);this.hasMore&&(this._page+=1,await this.app.fetchPage(this))}menu(t,r,o={}){return this.app.menu(this,t,Array.isArray(r)?r:[r],o.fields)}select(t,r={}){this.app.select(this,Array.isArray(t)?t:[t],r.fields)}get selectedRows(){let{selection:t}=this.app;if(t?.source!==this.name)return[];let r=this._result?.rows;if(!r)return t.rows;let o=i(l=>JSON.stringify(t.fields.map(s=>l[s]??null)),"key"),a=new Set(t.rows.map(o));return r.filter(l=>a.has(o(l)))}markExecuting(){this._state="executing",this._error=void 0,this.notify()}markSuccess(t,r,o){if(this._state="success",this._error=void 0,this.lastRunSignature=r,this.lastPageRows=t.rows.length,o&&this._result){let a=[...this._result.rows,...t.rows];this._result={...t,rows:a,meta:{...t.meta,numRows:a.length}}}else this._result=t;this.notify()}markError(t){this._state="error",this._error=t,this.notify()}rewindPage(){this._page>1&&(this._page-=1)}resetPage(){this._page=1,this.lastPageRows=0}toJSON(){return this.declaration}};i(ve,"Query");var I=ve;var xe=class xe{constructor(n,t,r,o){u(this,"kind","control");u(this,"from");u(this,"to");u(this,"field");u(this,"aggregation");this.from=n,this.to=t,this.field=r,this.aggregation=o}get id(){return`${this.from.name}.${this.to.name}.${this.field}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:this.from.kind,name:this.from.name},to:{kind:"query",name:this.to.name},field:this.field,...this.aggregation?{aggregation:this.aggregation}:{}}}};i(xe,"Mapping");var Y=xe,Ee=class Ee{constructor(n,t){u(this,"kind","crossFilter");u(this,"from");u(this,"to");this.from=n,this.to=t}get id(){return`${this.from.name}.${this.to.name}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:"query",name:this.from.name},to:{kind:"query",name:this.to.name}}}};i(Ee,"CrossFilter");var X=Ee;var Se=["sum","avg","max","min","count","count distinct","median","stdev","stdevp","var","varp"];function mn(e,n){let t=e.length+1,r=n.length+1,o=Array.from({length:r},(a,l)=>l);for(let a=1;a<t;a++){let l=[a];for(let s=1;s<r;s++)l[s]=Math.min(o[s]+1,l[s-1]+1,o[s-1]+(e[a-1]===n[s-1]?0:1));o=l}return o[r-1]}i(mn,"editDistance");function hn(e,n){let t,r=1/0;n.forEach(a=>{let l=mn(e.toLowerCase(),a.toLowerCase());l<r&&(r=l,t=a)});let o=Math.max(2,Math.floor(e.length/3));return r<=o?t:void 0}i(hn,"suggest");function B(e,n,t){let r=hn(n,t);return r?`${e} Did you mean \'${r}\'?`:e}i(B,"withSuggestion");var Te=class Te{constructor(n){u(this,"descriptor");u(this,"fields",new Map);u(this,"references");this.descriptor=n,n.data_models.forEach(t=>{t.fields.forEach(r=>{let o=String(t.name);this.fields.set(`${o}.${r.name}`,{modelName:o,fieldName:r.name,isMetric:!1,type:r.type,label:r.label??r.name})})}),n.metrics.forEach(t=>{this.fields.set(t.name,{fieldName:t.name,isMetric:!0,type:t.type,label:t.label??t.name})}),this.references=[...this.fields.keys()]}resolve(n,t){let r=this.fields.get(n);if(r)return r;throw new g(B(`Unknown field \'${n}\' on dataset \'${this.descriptor.name}\'.`,n,this.references),t)}};i(Te,"DatasetIndex");var Z=Te;function ft(e,n,t){let r=e[n];if(r)return r;throw new g(B(`Unknown dataset \'${n}\'.`,n,Object.keys(e)),t)}i(ft,"resolveDataset");function mt(e,n){if(!Se.includes(e))throw new g(B(`Invalid filter aggregation \'${e}\'.`,e,[...Se]),n)}i(mt,"assertValidFilterAggregation");function ht(e,n,t){if(!n)throw new g(`A ${t} needs a name.`);for(let r of e)if(r===n)throw new g(`\'${n}\' is already declared in this app.`,n)}i(ht,"assertUniqueName");function gn(e,n){if(!(!n||n.operator==="none"||n.operator==="transform_date_drill"||!["is_null","not_null","is_true","is_false","transform_pop_none"].includes(n.operator)&&!n.values?.length))return{field:e.field,operator:n.operator,values:n.values??[],...n.modifier?{modifier:n.modifier}:{},...e.aggregation?{aggregation:e.aggregation}:{}}}i(gn,"toFilter");function yn(e,n){if(n?.operator!=="transform_date_drill")return;let t=n.values?.[0];if(typeof t!="string")return;let r=t.replace(/^datetrunc\\s+/,"");return{field:e.field,grain:r}}i(yn,"toDateDrill");function bn(e,n){let t=n.columns??[],r=(n.values??[]).map(a=>{let l={};return t.forEach((s,c)=>{l[s.name]=a[c]}),l}),{pageSize:o}=e;return{columns:t,rows:r,meta:{...o!==void 0?{page:n.meta?.page??e.page,pageSize:n.meta?.pageSize??o,...n.meta?.hasMore!==void 0?{hasMore:n.meta.hasMore}:{}}:{},numRows:n.meta?.numRows??r.length},...n.debug?{debug:n.debug}:{}}}i(bn,"toResult");function gt(e,n,t,r){let o=n.map(c=>gn(c,c.from.appliedCondition)).filter(c=>c!==void 0),a=n.map(c=>yn(c,c.from.appliedCondition)).filter(c=>c!==void 0),l=t.conditions.map(c=>({field:c.field,operator:c.operator,values:c.values})),s=t.expression?[{expr:t.expression}]:[];return{dataset:e.dataset.descriptor.name,aql:e.declaration.aql,input:{filters:[...o,...l],conditions:s,sorts:e.sort.map(c=>({field:c.field,direction:c.direction??"asc"})),dateDrills:a},...r.timezone?{timezone:r.timezone}:{}}}i(gt,"buildQuery");function wn(e,n,t,r){return{...gt(e,n,t,r),...e.pageSize!==void 0?{page:e.page,pageSize:e.pageSize}:{},...r.bustCache?{bustCache:!0}:{}}}i(wn,"buildRequest");function kn(e,n){let t=n?.replace(/[/\\\\]/g,"-").replace(/\\p{Cc}/gu,"").trim();return t?`${t} - ${e.name}`:e.name}i(kn,"defaultExportFilename");function yt(e,n,t,r,o){let a=o.format??"csv",l=a==="csv"?{bom:!0,...o.formatOptions}:o.formatOptions;return{...gt(e,n,t,r),format:a,...l?{formatOptions:l}:{},filename:o.filename?.trim()||kn(e,r.title)}}i(yt,"buildExportRequest");async function Ce(e,n,t,r,o){let a=wn(e,n,t,r),l=await r.backend.submitQuery(a,o);return bn(e,l)}i(Ce,"runQuery");function vn(e,n){if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(n==="number"&&typeof e=="string")return Sn(e);if(typeof e=="number"){if(!Number.isFinite(e))throw new RangeError(`Cannot express ${e} in AQL.`);return Math.abs(e)>=1e21?BigInt(e).toString():String(e)}return JSON.stringify(e).split("\\u2028").join("\\\\u2028").split("\\u2029").join("\\\\u2029")}i(vn,"literal");function bt(e,n,t){return n===null?`is(${e}, null)`:`${e} is ${vn(n,t)}`}i(bt,"equals");var xn=new Set(["NaN","Infinity","-Infinity"]),En=/^(-?)(0|[1-9]\\d*)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/;function Sn(e){let n=En.exec(e);if(!n)throw xn.has(e)?new RangeError(`Cannot express ${e} in AQL.`):new TypeError(`${JSON.stringify(e)} is not a number: a number is a string in JSON\'s number syntax.`);let[,t,r,o="",a]=n;if(a===void 0)return e;let l=r+o,s=r.length+Number(a),c;return s<=0?c=`0.${"0".repeat(-s)}${l}`:s>=l.length?c=l+"0".repeat(s-l.length):c=`${l.slice(0,s)}.${l.slice(s)}`,t+c.replace(/^0+(?=\\d)/,"")}i(Sn,"numberLiteral");function wt(e,n,t){return`${e} matches @(${n} until ${t})`}i(wt,"dateRange");function kt(e,n){if(n.length===0)throw new RangeError(`\\`${e}\\` needs at least one operand.`);return n.length===1?n[0]:`${e}(${n.join(", ")})`}i(kt,"combine");var vt=i(e=>kt("and",e),"and"),xt=i(e=>kt("or",e),"or");var Tn=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?)?/,Cn={week:7*864e5,day:864e5,hour:36e5,minute:6e4};function Et(e){if(typeof e!="string")return;let n=Tn.exec(e);if(n)return{year:Number(n[1]),month:Number(n[2])-1,day:Number(n[3]),hour:Number(n[4]??0),minute:Number(n[5]??0),second:Number(n[6]??0),hasTime:n[4]!==void 0}}i(Et,"parseStamp");function V(e,n){let t=new Date(e),r=i(a=>String(a).padStart(2,"0"),"pad"),o=`${t.getUTCFullYear()}-${r(t.getUTCMonth()+1)}-${r(t.getUTCDate())}`;return n?`${o} ${r(t.getUTCHours())}:${r(t.getUTCMinutes())}:${r(t.getUTCSeconds())}`:o}i(V,"format");function St(e){return Date.UTC(e.year,e.month,e.day,e.hour,e.minute,e.second)}i(St,"toMs");function Ae(e){let n=Et(e);if(n)return V(St(n),n.hasTime)}i(Ae,"normalise");function Re(e,n){let t=Et(e);if(!t)return;let{year:r,month:o,day:a,hour:l,minute:s,second:c,hasTime:f}=t;return V(n==="year"?Date.UTC(r+1,o,a,l,s,c):n==="quarter"?Date.UTC(r,o+3,a,l,s,c):n==="month"?Date.UTC(r,o+1,a,l,s,c):St(t)+Cn[n],f)}i(Re,"addGrain");function Tt(e){if(e?.startsWith("datetrunc "))return e.slice(10)}i(Tt,"grainOf");function An(e){let n=new Set;return e.filter(t=>{let r=`${typeof t}:${String(t)}`;return n.has(r)?!1:(n.add(r),!0)})}i(An,"distinct");function Rn(e,n){let t=e.map(Ae);if(t.some(o=>o===void 0))return!1;let r=t.slice().sort();for(let o=1;o<r.length;o+=1)if(Re(r[o-1],n)!==r[o])return!1;return!0}i(Rn,"isContiguous");function Dn(e,n,t){let r=n.map(Ae);if(r.some(c=>c===void 0))return;let o=r.slice().sort(),a=o[0],l=Re(o[o.length-1],t);if(!l)return;let s=Rn(n,t);return{condition:{field:e,operator:"matches",values:[`${a} until ${l}`]},admits:s?n.length:Number.POSITIVE_INFINITY,lossy:!s}}i(Dn,"dateRange");function On(e,n,t){let r=t.filter(s=>s!=null),o=An(r);if(!o.length)return{condition:{field:e,operator:"is_null",values:[]},admits:1,lossy:!1};let a=r.length!==t.length,l=Tt(n);if(l){let s=Dn(e,o,l);if(s)return{...s,lossy:s.lossy||a}}return{condition:{field:e,operator:"is",values:o},admits:o.length,lossy:a}}i(On,"deriveOne");function Ct(e){return e.modelId?`${e.modelId}.${e.fieldName}`:e.fieldName}i(Ct,"fieldReferenceOf");function $n(e,n,t,r){try{let o=t.map(a=>vt(n.map(l=>{let s=e.get(l),c=Ct(s),f=a[l]??null,w=Tt(r[c]);if(w&&typeof f=="string"){let S=Ae(f),k=Re(f,w);if(S&&k)return wt(c,S,k)}if(f!==null&&typeof f!="string"&&typeof f!="number"&&typeof f!="boolean")throw new TypeError("no AQL spelling");return bt(c,f,s.semantic_type)})));return xt(o)}catch{return}}i($n,"selectionExpression");function De(e,n,t,r={}){let o=e.result?.columns??[],a=new Map(o.map(p=>[p.name,p]));t?.forEach(p=>{let m=a.get(p);if(m){if(m.adhoc)throw new g(`Query \'${e.name}\' cannot cross-filter on \'${p}\': it is a query-local AQL expression, which only this query\'s result carries. The target query would receive a condition naming a field it has never heard of.`,e.name);if(m.isMeasure)throw new g(`Query \'${e.name}\' cannot cross-filter on \'${p}\': it is a measure, and a selection conditions dimensions only.`,e.name);return}throw new g(B(`Query \'${e.name}\' has no column \'${p}\' in its last result.`,p,[...a.keys()]),e.name)});let l=o.filter(p=>!p.isMeasure),s=l.filter(p=>!p.adhoc).map(p=>p.name),c=t?[...t]:s;if(!n.length||!c.length)return;let f=[],w=1,S=!t&&s.length!==l.length,k=!1;c.forEach(p=>{let m=a.get(p),d=Ct(m),h=On(d,r[d],n.map(y=>y[p]));f.push(h.condition),w*=h.admits,k=k||h.lossy});let x=new Set(n.map(p=>JSON.stringify(c.map(m=>p[m]??null))));w>x.size&&(k=!0);let T=f.sort((p,m)=>p.field.localeCompare(m.field)),C={source:e.name,rows:[...n],fields:c};if(k){let p=$n(a,c,n,r);if(p)return{...C,conditions:[],expression:p,lossy:S}}return{...C,conditions:T,lossy:S||k}}i(De,"deriveSelection");var Oe=Object.freeze([]);function $e(e){return e instanceof Error&&e.name==="AbortError"}i($e,"isAbort");function At(e,n){return e.controller!==n}i(At,"superseded");function Mn(e){return{name:e.name,message:e.message,...e.entity?{entity:e.entity}:{},...typeof e.status=="number"?{status:e.status}:{},...e.stack?{stack:e.stack}:{}}}i(Mn,"inspectError");function _n(e){let{result:n}=e;return{state:e.state,isDirty:e.isDirty,page:e.page,hasMore:e.hasMore,columns:n?n.columns.map(t=>({...t})):[],rowCount:n?.meta.numRows??0,selectedRowCount:e.selectedRows.length,signature:e.signature(),...e.error?{error:Mn(e.error)}:{},...n?.debug?{debug:{...n.debug}}:{}}}i(_n,"inspectQuery");function Nn(e){let{options:n}=e;return{kind:e.kind,condition:{...e.condition},...e.appliedCondition?{appliedCondition:{...e.appliedCondition}}:{},isDirty:e.isDirty,...n?{options:[...n]}:{}}}i(Nn,"inspectControl");function Rt(e){return{source:e.source,fields:[...e.fields],rowCount:e.rows.length,conditions:e.conditions.map(n=>({...n})),...e.expression?{expression:e.expression}:{},lossy:e.lossy}}i(Rt,"inspectSelection");function Dt(e){return e?JSON.stringify({source:e.source,conditions:e.conditions,expression:e.expression}):"none"}i(Dt,"selectionKey");function Ot(e,n){return e instanceof O?e:new _(e?.message??"The query failed.",n,e)}i(Ot,"toDataAppError");function Fn(e,n){if(e instanceof O&&e.entity)return e;let t=e?.message||"The export failed.";return e instanceof N?new N(t,n):e instanceof $?new $(t,e.status,n):e instanceof g?new g(t,n):new _(t,n,e)}i(Fn,"toExportError");var Me=class Me extends P{constructor(t,r,o,a,l){super();u(this,"extensions",l);u(this,"title");u(this,"_timezone");u(this,"datasets");u(this,"backend");u(this,"features");u(this,"_queries",new Map);u(this,"_controls",new Map);u(this,"_mappings",[]);u(this,"_crossFilters",[]);u(this,"_selection");u(this,"_appliedSelection");u(this,"selectionCommitted",!1);u(this,"index",0);this.title=t.title,this._timezone=t.timezone,this.datasets=r,this.backend=o,this.features=a}get queries(){return Object.fromEntries(this._queries)}get controls(){return Object.fromEntries(this._controls)}get mappings(){return[...this._mappings,...this._crossFilters]}get crossFilters(){return this._crossFilters}createQuery(t,r){this.assertNameFree(t,"query");let o=W(new I(t,this,r),this.extensions?.query);return this._queries.set(t,o),this.notify(),o}createFilter(t,r){this.assertNameFree(t,"filter");let o=r.dataset?this.datasetIndex(r.dataset,t):this.soleDataset(t,r.field),a=W(new U(t,this,r,o,this.backend),this.extensions?.control);return this._controls.set(t,a),this.notify(),a}createDateDrill(t,r={}){if(this.features?.dateDrill===!1)throw new g(`Date drill \'${t}\' needs a capability this workspace has not enabled. Ask an admin to turn on \\`interactive_control:date_drill\\`.`,t);this.assertNameFree(t,"date drill control");let o=W(new J(t,this,r),this.extensions?.control);return this._controls.set(t,o),this.notify(),o}mapControl(t,r,o){if(!(t instanceof F))throw new g("mapControl expects a control as its source. To let one query cross-filter another, use app.mapCrossFilter(from, to) \\u2014 a cross-filter edge names no field.");if(this._controls.get(t.name)!==t)throw new g(`Control \'${t.name}\' belongs to a different app.`,t.name);if(this._queries.get(r.name)!==r)throw new g(`Query \'${r.name}\' belongs to a different app.`,r.name);o.aggregation&&mt(o.aggregation,t.name);let a=new Y(t,r,o.field,o.aggregation);if(this._mappings.some(l=>l.id===a.id))throw new g(`Mapping \'${a.id}\' is already declared.`,t.name);return this.assertAcyclic(a),this._mappings.push(a),this.notify(),a}mapCrossFilter(t,r){if(!(t instanceof I)||!(r instanceof I))throw new g("mapCrossFilter expects two queries. To let a control condition a query, use app.mapControl(from, to, { field }).");if(this._queries.get(t.name)!==t)throw new g(`Query \'${t.name}\' belongs to a different app.`,t.name);if(this._queries.get(r.name)!==r)throw new g(`Query \'${r.name}\' belongs to a different app.`,r.name);if(t===r)throw new g(`Query \'${t.name}\' cannot cross-filter itself. A source keeps its own rows so it can show what is selected; filtering it would erase the very rows the reader clicked.`,t.name);if(t.declaration.dataset!==r.declaration.dataset)throw new g(`Cross-filter \'${t.name}\' -> \'${r.name}\' spans two datasets (\'${t.declaration.dataset}\' and \'${r.declaration.dataset}\'). A selection carries field references, which mean nothing outside the dataset that resolved them.`,t.name);let o=new X(t,r);if(this._crossFilters.some(a=>a.id===o.id))throw new g(`Cross-filter \'${o.id}\' is already declared.`,t.name);return this._crossFilters.push(o),this.notify(),o}get selection(){return this._selection}get appliedSelection(){return this._appliedSelection}clearSelection(){this._selection&&(this._selection=void 0,this.notify())}setTimezone(t){this._timezone=t,this.notify()}get timezone(){return this._timezone}datasetIndex(t,r){return ft(this.datasets,t,r)}mappingsTo(t){return this._mappings.filter(r=>r.to.name===t)}selectionExpressionFor(t,r){return this.selectionFor(t,r)?.expression}selectionFor(t,r){let o=r==="pending"?this._selection:this._appliedSelection;return!o||o.source===t?void 0:this._crossFilters.some(l=>l.from.name===o.source&&l.to.name===t)?o:void 0}selectionConditionsFor(t,r){let o=r==="pending"?this._selection:this._appliedSelection;return!o||o.source===t?Oe:this._crossFilters.some(l=>l.from.name===o.source&&l.to.name===t)?o.conditions:Oe}drillTransformations(t){let r={};return this._mappings.forEach(o=>{if(o.to!==t)return;let a=o.from.appliedCondition;if(a?.operator!=="transform_date_drill")return;let[l]=a.values??[];typeof l=="string"&&(r[o.field]=l)}),r}menu(t,r,o,a){if(this._queries.get(t.name)!==t)throw new g(`Query \'${t.name}\' belongs to a different app.`,t.name);let l=De(t,o,a,this.drillTransformations(t));return st(r,{kind:"rows",app:this.index,query:t.name,rows:[...o],fields:l?.fields?[...l.fields]:[],conditions:l?.conditions?[...l.conditions]:[],...l?.expression?{expression:l.expression}:{}})}select(t,r,o){if(this._queries.get(t.name)!==t)throw new g(`Query \'${t.name}\' belongs to a different app.`,t.name);let a=De(t,r,o,this.drillTransformations(t));a?.lossy&&console.warn(`[anfra-sdk] The selection in \'${t.name}\' filters more broadly than it was made. Its conditions are combined field by field and ANDed, which cannot express "(A and B) or (C and D)", so the targets will also show combinations that were not selected. Select within one dimension, or narrow with \\`fields\\`, to avoid this.`),this._selection=a,this.notify()}get hasChanges(){return[...this._controls.values()].some(t=>t.isDirty)||this.isSelectionDirty}get isSelectionDirty(){return this.selectionCommitted?Dt(this._selection)!==Dt(this._appliedSelection):!1}async execute(t={}){let r=[...this._queries.values()].filter(s=>s.shouldRun(t.force));this._controls.forEach(s=>s.commit()),this._appliedSelection=this._selection,this.selectionCommitted=!0,r.forEach(s=>{s.controller?.abort(),s.resetPage()});let o={backend:this.backend,timezone:this._timezone,bustCache:t.bustCache},a=[],l=[];return await Promise.all(r.map(async s=>{let c=new AbortController;s.controller=c;let f=s.signature();s.markExecuting();try{let w=await Ce(s,this.mappingsTo(s.name),{conditions:this.selectionConditionsFor(s.name,"applied"),expression:this.selectionExpressionFor(s.name,"applied")},o,c.signal);if(At(s,c))return;s.markSuccess(w,f,!1),a.push(s.name)}catch(w){if(At(s,c)||$e(w))return;s.markError(Ot(w,s.name)),l.push(s.name)}finally{s.controller===c&&(s.controller=void 0)}})),{succeeded:a,failed:l}}async refresh(){return this.execute({force:!0,bustCache:!0})}abort(){this._queries.forEach(t=>t.abort())}async fetchPage(t){let r=new AbortController;t.controller=r;let o=t.signature();t.markExecuting();try{let a=await Ce(t,this.mappingsTo(t.name),{conditions:this.selectionConditionsFor(t.name,"applied"),expression:this.selectionExpressionFor(t.name,"applied")},{backend:this.backend,timezone:this._timezone},r.signal);t.markSuccess(a,o,!0)}catch(a){if(t.rewindPage(),$e(a))return;let l=Ot(a,t.name);throw t.markError(l),l}finally{t.controller===r&&(t.controller=void 0)}}async exportQuery(t,r,o){let a=yt(t,this.mappingsTo(t.name),{conditions:this.selectionConditionsFor(t.name,"applied"),expression:this.selectionExpressionFor(t.name,"applied")},{backend:this.backend,timezone:this._timezone,title:this.title},r);try{return await o(a,r.signal??new AbortController().signal)}catch(l){throw $e(l)?l:Fn(l,t.name)}}toJSON(){let t=i(r=>Object.fromEntries([...this._controls.entries()].filter(([,o])=>o.kind===r).map(([o,a])=>[o,a.toJSON()])),"byKind");return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},queries:Object.fromEntries([...this._queries.entries()].map(([r,o])=>[r,o.toJSON()])),filters:t("filter"),dateDrills:t("dateDrill"),mappings:[...this._mappings.map(r=>r.toJSON()),...this._crossFilters.map(r=>r.toJSON())]}}toInspectJSON(){return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},hasChanges:this.hasChanges,declaration:this.toJSON(),queries:Object.fromEntries([...this._queries.entries()].map(([t,r])=>[t,_n(r)])),controls:Object.fromEntries([...this._controls.entries()].map(([t,r])=>[t,Nn(r)])),...this._selection?{selection:Rt(this._selection)}:{},...this._appliedSelection?{appliedSelection:Rt(this._appliedSelection)}:{}}}locate(t,r){let o=globalThis.document;if(!o)return!1;let a=Je(o,t,this.index,r);return a.length?(H(a[0]),q(o).flash(a,{kind:t,name:r,...a.length>1?{note:`in ${a.length} places`}:{}}),!0):!1}assertNameFree(t,r){ht([...this._queries.keys(),...this._controls.keys()],t,r)}soleDataset(t,r){if(!r)return;let o=Object.keys(this.datasets);if(o.length===1)return this.datasets[o[0]];throw new g(o.length?`Filter \'${t}\' names a field but the environment has ${o.length} datasets. Say which one: ${o.join(", ")}.`:`Filter \'${t}\' names a field but the environment has no datasets.`,t)}assertAcyclic(t){let r=[...this._mappings,t],o=new Map;r.forEach(c=>{let f=c.from.name;o.set(f,[...o.get(f)??[],c.to.name])});let a=new Set,l=new Set,s=i(c=>{if(a.has(c))return!0;if(l.has(c))return!1;a.add(c);let f=(o.get(c)??[]).some(s);return a.delete(c),l.add(c),f},"walk");if([...o.keys()].some(s))throw new g(`Mapping \'${t.id}\' would make the app\'s mappings cyclic.`,t.from.name)}};i(Me,"App");var ee=Me;var $t="0.14.2";var Ie=class Ie{constructor(){u(this,"current",{scheme:"light",tokens:pe.light});u(this,"listeners",new Set)}get scheme(){return this.current.scheme}get tokens(){return this.current.tokens}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}set(n){this.current=n,this.listeners.forEach(t=>{try{t(n)}catch{}})}};i(Ie,"HostTheme");var _e=Ie,Pe=class Pe{constructor(n){u(this,"list");this.list=Object.freeze(n.map(({name:t,version:r})=>Object.freeze({name:t,version:r})))}has(n){return this.list.some(t=>t.name===n)}version(n){return this.list.find(t=>t.name===n)?.version}};i(Pe,"InstalledPlugins");var Ne=Pe,Pn=$t,Qe=class Qe{constructor(n){u(this,"version",Pn);u(this,"_apps",[]);u(this,"datasets");u(this,"user");u(this,"indices");u(this,"backend");u(this,"plugins");u(this,"theme",new _e);u(this,"gates");u(this,"deprecatedFeatures");u(this,"extensions",{query:new Map,control:new Map});if(!n?.datasets)throw new g("No datasets provided. The host must call createSdk({ datasets }) before an app can be declared.");if(!n.user)throw new g("No user provided. The host must call createSdk({ user }) before an app can be declared.");if(!n.backend)throw new g("No backend provided. The host must call createSdk({ backend }) before an app can run a query.");this.datasets=Object.freeze({...n.datasets}),this.user=Object.freeze({...n.user,permissions:Object.freeze({...n.user.permissions})}),this.indices=Object.fromEntries(Object.entries(n.datasets).map(([t,r])=>[t,new Z(r)])),this.backend=n.backend,this.gates=Object.freeze({...n.features}),this.plugins=new Ne(n.plugins??[])}get features(){return this.deprecatedFeatures||(console.warn("anfra: Anfra.features is deprecated and will be removed. Check Anfra.plugins.has(\'export\'), Anfra.plugins.has(\'render\') or Anfra.plugins.has(\'lineage\') instead."),this.deprecatedFeatures=Object.freeze({...this.gates,export:this.plugins.has("export"),render:this.plugins.has("render"),lineage:this.plugins.has("lineage")})),this.deprecatedFeatures}createApp(n={}){let t=new ee(n,this.indices,this.backend,this.gates,this.extensions);return t.index=this._apps.length,this._apps.push(t),t}get apps(){return this._apps}};i(Qe,"Sdk");var Fe=Qe;function Mt(e){return new Fe(e)}i(Mt,"createSdk");var K="Anfra";function _t(e,n=globalThis){let t=n[K],r=K in n;return n[K]=e,()=>{r?n[K]=t:delete n[K]}}i(_t,"installSandbox");function Nt(e,n=[]){let t=e.document.getElementById(Le);if(!t?.textContent)throw new Error("anfra: this frame was not provisioned by a host.");let r=JSON.parse(t.textContent),o=i(m=>e.parent.postMessage(m,r.hostOrigin),"post"),a=new Map,l=new Map,s=ze(o,{answer:i(async(m,d,h)=>{let y=a.get(m);if(!y)throw new $(`Nothing in this frame answers \'${m}\'.`);return y(d,h)},"answer"),event:i((m,d)=>{l.get(m)?.forEach(h=>{try{h(d)}catch{}})},"event")}),c=i(m=>m.source===e.parent||!!r.hostOrigin&&r.hostOrigin!=="null"&&m.origin===r.hostOrigin,"fromHost");e.addEventListener("message",m=>{c(m)&&s.receive(m.data)});let f={submitQuery:i((m,d)=>s.call("core.submitQuery",m,d).then(h=>(h.debug?.executedAt&&(h.debug.executedAt=new Date(h.debug.executedAt)),h)),"submitQuery"),fieldSuggestions:i((m,d)=>s.call("core.fieldSuggestions",m,d),"fieldSuggestions")},w=Mt({datasets:r.datasets,user:r.user,backend:f,plugins:r.plugins??[]}),S=new Set,k=w.createApp.bind(w);w.createApp=m=>{let d=k(m);return S.forEach(h=>{try{h(d)}catch{}}),d};let x={window:e,sdk:w,endpoint:s,handlers:a,listeners:l,appListeners:S},T=ke("anfra",x,{Query:I,Control:F});it(T),x.contentUi=lt(T),T.on("theme",m=>{let d=Xe(m);et(e.document,d),w.theme.set(d)});let C=new Set,p=!1;T.on("shortcuts",m=>{C=new Set((Array.isArray(m)?m:[]).map(dt).filter(d=>!!d)),!(p||!C.size)&&(p=!0,e.addEventListener("keydown",d=>{if(d.defaultPrevented||d.repeat||ut(d.target))return;let h=pt(d);C.has(h)&&(d.preventDefault(),T.emit("shortcut",h))}))});for(let[m,d]of n)if(typeof d=="function")try{d(ke(m,x,{Query:I,Control:F}))}catch(h){e.console?.error(`anfra: plugin \'${m}\' failed to set up:`,h)}_t(w,e),o({type:"anfra:ready"})}i(Nt,"bootstrap");return zt(Qn);})();\n';
|
|
27
|
+
var anfra_sdk_frame_script_default = '"use strict";var __anfraKernel=(()=>{var z=Object.defineProperty;var Ft=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Pt=Object.prototype.hasOwnProperty;var Qt=(e,n,t)=>n in e?z(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var i=(e,n)=>z(e,"name",{value:n,configurable:!0});var Lt=(e,n)=>{for(var t in n)z(e,t,{get:n[t],enumerable:!0})},Bt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of It(n))!Pt.call(e,o)&&o!==t&&z(e,o,{get:()=>n[o],enumerable:!(r=Ft(n,o))||r.enumerable});return e};var zt=e=>Bt(z({},"__esModule",{value:!0}),e);var u=(e,n,t)=>Qt(e,typeof n!="symbol"?n+"":n,t);var Qn={};Lt(Qn,{bootstrap:()=>Nt});var Le="anfra-provision";var re=class re extends Error{constructor(t,r){super(t);u(this,"entity");this.name=new.target.name,this.entity=r,Object.setPrototypeOf(this,new.target.prototype)}};i(re,"DataAppError");var O=re,oe=class oe extends O{};i(oe,"ValidationError");var g=oe,ie=class ie extends O{constructor(t,r,o){super(t,r);u(this,"cause");this.cause=o}};i(ie,"QueryError");var _=ie,se=class se extends O{};i(se,"PermissionError");var N=se,ae=class ae extends O{constructor(t,r,o){super(t,o);u(this,"status");this.status=r}};i(ae,"TransportError");var $=ae;function Be(){let e=new Error("Aborted");return e.name="AbortError",e}i(Be,"abortError");function Vt(e){return e?.name==="AbortError"}i(Vt,"isAbortError");var Kt=new Set(["ValidationError","QueryError","PermissionError","TransportError"]);function jt(e){let n=e;return n instanceof Error&&Kt.has(n.name)?{name:n.name,message:n.message||"The call failed."}:{name:"QueryError",message:"The call failed."}}i(jt,"toBridgeError");function Ut(e){switch(e?.name){case"PermissionError":return new N(e.message);case"TransportError":return new $(e.message);case"ValidationError":return new g(e.message);default:return new _(e?.message||"The call failed.")}}i(Ut,"fromBridgeError");function ze(e,n){let t=new Map,r=new Map,o=1,a=i((l,s,c)=>{let f=new AbortController;r.set(l,f),Promise.resolve().then(()=>n.answer(s,c,f.signal)).then(w=>{f.signal.aborted||e({type:"anfra:result",id:l,ok:!0,result:w})}).catch(w=>{f.signal.aborted||Vt(w)||e({type:"anfra:result",id:l,ok:!1,error:jt(w)})}).finally(()=>{r.get(l)===f&&r.delete(l)})},"answer");return{call(l,s,c){return new Promise((f,w)=>{if(c?.aborted){w(Be());return}let S=o++;t.set(S,{resolve:f,reject:w}),c?.addEventListener("abort",()=>{t.delete(S)&&(e({type:"anfra:cancel",id:S}),w(Be()))},{once:!0}),e({type:"anfra:call",id:S,name:l,request:s})})},emit(l,s){e({type:"anfra:event",name:l,payload:s})},receive(l){switch(l?.type){case"anfra:call":return a(l.id,l.name,l.request),!0;case"anfra:result":{let s=t.get(l.id);return s&&(t.delete(l.id),l.ok?s.resolve(l.result):s.reject(Ut(l.error))),!0}case"anfra:cancel":return r.get(l.id)?.abort(),r.delete(l.id),!0;case"anfra:event":return n.event(l.name,l.payload),!0;default:return!1}},close(l){r.forEach(s=>s.abort()),r.clear(),t.forEach(({reject:s})=>s(l)),t.clear()}}}i(ze,"createEndpoint");var le=class le{constructor(n){u(this,"listeners",new Set);u(this,"parent");this.parent=n}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}notifyChange(){this.listeners.forEach(n=>n()),this.parent?.notifyChange()}notify(){this.notifyChange()}};i(le,"Observable");var P=le;var Ve=["year","quarter","month","week","day","hour","minute"];function Jt(e,n){if(!Ve.includes(n))throw new g(`Invalid grain \'${n}\'. Expected one of: ${Ve.join(", ")}.`,e)}i(Jt,"assertGrain");function Ke(e,n){return n?(Jt(e,n),{operator:"transform_date_drill",values:[`datetrunc ${n}`]}):{operator:"none"}}i(Ke,"drillCondition");function Gt(e){let n=e.toLowerCase();return n.includes("date")||n.includes("time")?"date":n.includes("int")||n.includes("number")||n.includes("float")||n.includes("decimal")?"number":n.includes("bool")?"boolean":"string"}i(Gt,"inferType");function qt(e,n){return JSON.stringify(e??null)===JSON.stringify(n??null)}i(qt,"sameCondition");var ce=class ce extends P{constructor(t,r,o){super(r);u(this,"name");u(this,"app");u(this,"pending");u(this,"applied");u(this,"initial");this.name=t,this.app=r,this.initial=o,this.pending=o}locate(){return this.app.locate("control",this.name)}get condition(){return this.pending}get appliedCondition(){return this.applied}get isDirty(){return this.applied!==void 0&&!qt(this.pending,this.applied)}setCondition(t){this.pending=t,this.notify()}reset(){this.setCondition(this.initial)}commit(){this.applied=this.pending}};i(ce,"Control");var F=ce,de=class de extends F{constructor(t,r,o,a,l){super(t,r,o.default??{operator:"is",values:[]});u(this,"kind","filter");u(this,"declaration");u(this,"type");u(this,"resolved");u(this,"datasetName");u(this,"backend");u(this,"loadedOptions");if(this.declaration=o,this.backend=l,o.field){if(!a)throw new g(`Filter \'${t}\' names a field but no dataset. Pass \\`dataset\\` alongside \\`field\\`.`,t);this.resolved=a.resolve(o.field,t),this.datasetName=a.descriptor.name,this.type=o.type??Gt(this.resolved.type)}else{if(!o.type)throw new g(`Filter \'${t}\' is a manual filter, so it needs a \\`type\\`.`,t);this.type=o.type}this.assertValues(this.condition.values??[]),this.assertValues(o.options??[])}setCondition(t){this.assertValues(t.values??[]),super.setCondition(t)}assertValues(t){if(this.type!=="number")return;let r=t.find(o=>typeof o=="number");if(r!==void 0)throw new g(`Filter \'${this.name}\' filters numbers: give its values as strings, as query results give them (${JSON.stringify(String(r))}, not ${String(r)}), so none has lost a digit.`,this.name)}get isFieldBacked(){return this.resolved!==void 0}get options(){return this.loadedOptions??this.declaration.options??[]}async loadOptions(t,r=new AbortController().signal){let o=this.resolved?.modelName;if(!this.resolved||!o||!this.backend||!this.datasetName)return this.options;let a=await this.backend.fieldSuggestions({dataset:this.datasetName,model:o,field:this.resolved.fieldName,q:t??""},r);return this.loadedOptions=[...a??[]],this.notify(),this.loadedOptions}toJSON(){return this.declaration}};i(de,"Filter");var U=de,ue=class ue extends F{constructor(t,r,o={}){super(t,r,Ke(t,o.default));u(this,"kind","dateDrill");u(this,"declaration");this.declaration=o}setGrain(t){this.setCondition(Ke(this.name,t))}toJSON(){return this.declaration}};i(ue,"DateDrillControl");var J=ue;var A={container:"data-anfra-container",block:"data-anfra-block",query:"data-anfra-query",control:"data-anfra-control",label:"data-anfra-label"},G=`[${A.container}],[${A.block}],[${A.query}],[${A.control}]`;function je(e){let n=/^(?:(\\d+)\\/)?([^/\\s]+)$/.exec(e);if(n)return{app:n[1]===void 0?0:Number(n[1]),name:n[2]}}i(je,"parseRef");var Ue=i(e=>(e??"").split(/\\s+/).filter(Boolean),"tokens");function Je(e,n,t,r){let o=n==="query"?A.query:A.control;return[...e.querySelectorAll(`[${o}]`)].filter(a=>Ue(a.getAttribute(o)).some(l=>{let s=je(l);return s?.app===t&&s.name===r}))}i(Je,"markersFor");var Ht=i((e,n,t)=>{let r=e[t.app];return r?Object.prototype.hasOwnProperty.call(n==="query"?r.queries:r.controls,t.name):!1},"hasEntity");function Ge(e,n){var S;let t=[],r=new Map,o=new Map,a=new Map,l=new Map,s={container:new Set,block:new Set},c={},f=i((k,x,T)=>{let C=k?a.get(k).children:t,p=k?`${a.get(k).key}.`:"",m={...x,key:`${p}${C.length}`,children:[]};return C.push(m),r.set(m.key,T),o.set(T,[...o.get(T)??[],m.key]),m},"place");for(let k of e.querySelectorAll(G)){let x=k.parentElement?.closest(G)??null,T=k.getAttribute(A.container),C=k.getAttribute(A.block),p=k.getAttribute(A.label)??void 0,m=x&&(l.get(x)==="block"?x:x.closest(`[${A.block}]`)),d;if(T!==null||C!==null){let y=T!==null?"container":"block",b=(T??C??"").trim(),v=[];T!==null&&C!==null&&v.push("This element is marked as a container and as a block. It counts as a container."),b?s[y].has(b)?v.push(`Another ${y} already has the id "${b}".`):s[y].add(b):v.push(`This ${y} has no id.`),m&&v.push(`A block can\'t hold a ${y}. This one is inside the block "${m.getAttribute(A.block)}".`),d=f(x,{kind:y,id:b,...p!==void 0?{label:p}:{},problems:v},k),a.set(k,d),l.set(k,y)}let h=d?k:x;for(let y of["query","control"])for(let b of Ue(k.getAttribute(y==="query"?A.query:A.control))){let v=je(b),E=[];if(v?Ht(n,y,v)||E.push(n[v.app]?`No ${y} is called "${v.name}" in app ${v.app}.`:`The page has no app ${v.app}.`):E.push(`Can\'t read "${b}". Write the ${y}\'s name, or app/name when the page has several apps.`),f(h,{kind:y,name:v?.name??b,app:v?.app??0,problems:E},k),v&&!E.length){let R=`${v.app}/${v.name}`,D=c[S=`${y}:${R}`]??(c[S]={elements:new Set,blocks:new Set});D.elements.add(k);let M=d?.kind==="block"?d.id:m?.getAttribute(A.block);M&&D.blocks.add(M)}}}let w=Object.fromEntries(Object.entries(c).map(([k,x])=>[k,{markers:x.elements.size,blocks:[...x.blocks]}]));return{nodes:t,usage:w,elements:r,keysOf:o}}i(Ge,"buildStructure");var Wt=i((e,n,t)=>`${e}:${n}/${t}`,"usageKey");function Yt(e){let n=e.getBoundingClientRect();return`${Math.round(n.width)} \\xD7 ${Math.round(n.height)}`}i(Yt,"sizeOf");function qe(e,n,t){let r=Yt(n);if(e.kind==="container"||e.kind==="block")return{kind:e.kind,name:e.id??"",...e.label?{label:e.label}:{},size:r};let o=t.usage[Wt(e.kind,e.app??0,e.name??"")];return{kind:e.kind,name:e.name??"",...o&&o.markers>1?{note:`1 of ${o.markers}`}:{},size:r}}i(qe,"describeNode");var Ye=["color-bg","color-fg","color-muted","color-border","color-accent","color-danger","radius","font","font-mono","color-bg-sunken","color-fg-weak","color-border-strong","color-hover","color-active","color-selected","color-warning","color-success"],He="\'Inter Variable\', ui-sans-serif, system-ui, sans-serif",We="\'Geist Mono Variable\', ui-monospace, monospace",pe={light:{"color-bg":"oklch(1 0 0)","color-bg-sunken":"oklch(0.973 0.005 95.1)","color-fg":"oklch(0.201 0.022 301.1)","color-fg-weak":"oklch(0.392 0.021 304.3)","color-muted":"oklch(0.485 0.022 306.3)","color-border":"oklch(0.201 0.022 301.1 / 0.12)","color-border-strong":"oklch(0.201 0.022 301.1 / 0.24)","color-accent":"oklch(0.484 0.181 298.1)","color-danger":"oklch(0.501 0.17 27.2)","color-warning":"oklch(0.501 0.1 70.3)","color-success":"oklch(0.479 0.1 151.8)","color-hover":"oklch(0.201 0.022 301.1 / 0.05)","color-active":"oklch(0.201 0.022 301.1 / 0.09)","color-selected":"oklch(0.946 0.027 304.8)",radius:"10px",font:He,"font-mono":We},dark:{"color-bg":"oklch(0.19 0.012 300)","color-bg-sunken":"oklch(0.157 0.009 296.9)","color-fg":"oklch(0.961 0.007 304.2)","color-fg-weak":"oklch(0.879 0.016 302.5)","color-muted":"oklch(0.835 0.018 300)","color-border":"oklch(0.343 0.025 298.2)","color-border-strong":"oklch(0.392 0.021 304.3)","color-accent":"oklch(0.845 0.085 300)","color-danger":"oklch(0.82 0.09 27)","color-warning":"oklch(0.84 0.12 69.6)","color-success":"oklch(0.8 0.12 151.9)","color-hover":"oklch(1 0 0 / 0.06)","color-active":"oklch(1 0 0 / 0.1)","color-selected":"oklch(0.565 0.194 300.3 / 0.18)",radius:"10px",font:He,"font-mono":We}};var Xt=/[;{}<>]|url\\(|expression\\(|@import|\\\\/i;function Xe(e){let n=typeof e=="object"&&e!==null?e:{},t=n.scheme==="dark"?"dark":"light",r={...pe[t]},o=typeof n.tokens=="object"&&n.tokens!==null?n.tokens:{},a=new Set;for(let l of Ye){let s=o[l];typeof s=="string"&&s.trim()!==""&&s.length<=200&&!Xt.test(s)&&(r[l]=s.trim(),a.add(l))}for(let[l,{from:s,value:c}]of Object.entries(Zt)){if(a.has(l)||!s.some(w=>a.has(w)))continue;let f=c(r);f.length<=200&&(r[l]=f)}return Object.freeze({scheme:t,tokens:Object.freeze(r)})}i(Xe,"resolveTheme");var Zt={"color-bg-sunken":{from:["color-fg","color-bg"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 4%, ${e["color-bg"]})`,"value")},"color-fg-weak":{from:["color-fg","color-bg"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 80%, ${e["color-bg"]})`,"value")},"color-border-strong":{from:["color-fg","color-border"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 10%, ${e["color-border"]})`,"value")},"color-hover":{from:["color-fg"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 7%, transparent)`,"value")},"color-active":{from:["color-fg"],value:i(e=>`color-mix(in srgb, ${e["color-fg"]} 12%, transparent)`,"value")},"color-selected":{from:["color-accent"],value:i(e=>`color-mix(in srgb, ${e["color-accent"]} 14%, transparent)`,"value")}};function fe(e,n){for(let t of Ye)e.setProperty(`--anfra-${t}`,n.tokens[t]);e.setProperty("color-scheme",n.scheme)}i(fe,"applyTheme");var me="data-anfra-layer",Ze=new WeakMap,en="position:absolute;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483647;";function tn(e){let n=e.querySelector(`[${me}]`);if(n instanceof(e.defaultView?.HTMLElement??HTMLElement))return n;let t=e.createElement("div");t.setAttribute(me,""),t.setAttribute("style",en);let r=Ze.get(e);return r&&fe(t.style,r),(e.body??e.documentElement).appendChild(t),t}i(tn,"layerOf");function L(e,n){let t=tn(e),r=[...t.children].find(a=>a.getAttribute("data-part")===n);if(r?.shadowRoot)return r.shadowRoot;let o=e.createElement("div");return o.setAttribute("data-part",n),t.appendChild(o),o.attachShadow({mode:"open"})}i(L,"layerRoot");function et(e,n){Ze.set(e,n);let t=e.querySelector(`[${me}]`);t&&fe(t.style,n)}i(et,"themeLayer");var tt="anfra-overlay",nn=1500,rn="position:fixed;box-sizing:border-box;background:oklch(0.546 0.215 262.9 / 0.22);outline:1px solid oklch(0.546 0.215 262.9);outline-offset:-1px;",on="position:fixed;max-width:60vw;display:flex;gap:6px;align-items:baseline;padding:3px 8px;border-radius:4px;background:oklch(0.208 0.04 265.8);color:oklch(0.984 0.003 247.9);font:12px/1.4 system-ui,sans-serif;white-space:nowrap;box-shadow:0 2px 8px oklch(0 0 0 / 0.35);",sn={kind:"color:oklch(0.711 0.035 256.8);",name:"color:oklch(0.809 0.096 251.8);font-weight:700;",label:"color:oklch(0.984 0.003 247.9);",note:"color:oklch(0.711 0.035 256.8);",size:"color:oklch(0.711 0.035 256.8);margin-left:10px;"},ge=class ge{constructor(n){u(this,"doc",n);u(this,"root");u(this,"shown",[]);u(this,"text",{kind:"",name:""});u(this,"timer");u(this,"reposition",i(()=>this.draw(),"reposition"));let t=L(n,"anfra"),r=t.getElementById(tt);r instanceof(n.defaultView?.HTMLElement??HTMLElement)?this.root=r:(this.root=n.createElement("div"),this.root.id=tt,this.root.setAttribute("aria-hidden","true"),this.root.setAttribute("style","position:fixed;inset:0;z-index:2147483647;pointer-events:none;display:none;"),t.appendChild(this.root))}show(n,t){if(this.clearTimer(),this.root.isConnected||L(this.doc,"anfra").appendChild(this.root),this.shown=[...n],this.text=t,!this.shown.length){this.hide();return}this.root.style.display="block",this.draw(),this.doc.addEventListener("scroll",this.reposition,{capture:!0,passive:!0}),this.doc.defaultView?.addEventListener("resize",this.reposition)}flash(n,t,r=nn){this.show(n,t),this.timer=setTimeout(()=>this.hide(),r)}hide(){this.clearTimer(),this.shown=[],this.root.style.display="none",this.root.replaceChildren(),this.doc.removeEventListener("scroll",this.reposition,{capture:!0}),this.doc.defaultView?.removeEventListener("resize",this.reposition)}get visible(){return this.shown.length>0}clearTimer(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}draw(){let n=this.shown.map(s=>{let c=s.getBoundingClientRect(),f=this.doc.createElement("div");return f.setAttribute("style",`${rn}left:${c.left}px;top:${c.top}px;width:${c.width}px;height:${c.height}px;`),f}),t=this.shown[0].getBoundingClientRect(),r=this.doc.createElement("div");r.setAttribute("data-testid","anfra-overlay-label");let o=this.doc.defaultView?.innerHeight??0,a=t.top>=26?t.top-24:Math.max(4,t.top+4),l=Math.max(4,Math.min(t.left,(this.doc.defaultView?.innerWidth??0)-24));r.setAttribute("style",`${on}left:${l}px;top:${Math.min(a,o-24)}px;`);for(let s of["kind","name","label","note","size"]){let c=this.text[s];if(!c)continue;let f=this.doc.createElement("span");f.setAttribute("style",sn[s]),f.setAttribute("data-part",s),f.textContent=c,r.appendChild(f)}this.root.replaceChildren(...n,r)}};i(ge,"Overlay");var he=ge,nt=new WeakMap;function q(e){let n=nt.get(e);return n||(n=new he(e),nt.set(e,n)),n}i(q,"overlayFor");function H(e){typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}i(H,"scrollTo");function rt(e,n){let t=null,r=i(c=>c.target instanceof Element?c.target.closest(G):null,"under"),o=i(c=>{let f=r(c);f!==t&&(t=f,n.onHover(f))},"onMove"),a=i(c=>{c.preventDefault(),c.stopPropagation();let f=r(c);f&&n.onPick(f)},"onClick"),l=i(c=>{c.key==="Escape"&&n.onCancel()},"onKey"),s={capture:!0};return e.addEventListener("mousemove",o,s),e.addEventListener("click",a,s),e.addEventListener("keydown",l,s),()=>{e.removeEventListener("mousemove",o,s),e.removeEventListener("click",a,s),e.removeEventListener("keydown",l,s)}}i(rt,"startPick");function ot(e,n){for(let t of e){if(t.key===n)return t;let r=ot(t.children,n);if(r)return r}}i(ot,"findNode");function it(e){let n=e.window,t=n.document,r=!1,o,a,l="",s,c;function f(){if(o=void 0,!!r)try{a=e.structure(),l=JSON.stringify(a.nodes),e.emit("snapshot",{apps:e.sdk.apps.map(p=>p.toInspectJSON()),structure:{nodes:a.nodes,usage:a.usage}})}catch{}}i(f,"postSnapshot");function w(){r&&o===void 0&&(o=setTimeout(f,50))}i(w,"scheduleSnapshot");function S(){let p=n.MutationObserver;if(s||typeof p!="function")return;let m=new p(()=>{if(!(!r||o!==void 0))try{JSON.stringify(e.structure().nodes)!==l&&w()}catch{}});s=m,m.observe(t.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:Object.values(A)})}i(S,"observeStructure");function k(p){let m=p!==null&&a?ot(a.nodes,p):void 0,d=p!==null?a?.elements.get(p):void 0;if(!m||!d||!a){e.overlay.hide();return}e.overlay.show([d],qe(m,d,a))}i(k,"highlight");function x(p){if(!p){c?.(),c=void 0;return}if(c)return;let m=i(d=>a?.keysOf.get(d)?.[0],"keyOf");c=rt(t,{onHover:i(d=>k(d?m(d)??null:null),"onHover"),onPick:i(d=>{let h=m(d);h!==void 0&&e.emit("picked",{node:h})},"onPick"),onCancel:i(()=>{x(!1),e.overlay.hide(),e.emit("picked",{node:null})},"onCancel")})}i(x,"setPicking");function T(p){r=p,p?(S(),f()):(s?.disconnect(),s=void 0,x(!1),e.overlay.hide(),a=void 0,l="")}i(T,"setInspecting");function C(p){if("node"in p){let m=a?.elements.get(p.node);m&&H(m),k(p.node)}else e.sdk.apps[p.app]?.locate(p.kind,p.name);w()}i(C,"locate"),e.on("watch",p=>T(p===!0)),e.on("highlight",p=>k(p)),e.on("locate",p=>C(p)),e.on("pick",p=>x(p===!0)),e.onApp(p=>{p.subscribe(w),w()})}i(it,"installInspection");var ye;function st(e,n){return ye?ye(e,n):!1}i(st,"openRowsMenu");var an=`[${A.block}]`,ln=\'[data-anfra-menu="off"]\',cn=i(e=>({...e,children:e.children.map(n=>({...n,children:[]}))}),"bare");function at(e,n,t=[]){for(let r of e){if(r.key===n)return[...t,r];let o=at(r.children,n,[...t,r]);if(o)return o}}i(at,"pathTo");var dn=i(e=>typeof e?.closest=="function","isElement");function lt(e){let n=e.window,t=n.document,r=[],o=new Set,a=!1,l,s=i(()=>e.body(),"ui"),c=i(()=>L(t,"anfra-ui"),"root"),f=i(d=>o.has(d)||r.some(h=>h.target===d),"offered"),w=i(()=>{let d=l;l=void 0,d?.()},"closeCurrent");function S(d){let h=dn(d)?d.closest(an):null;return h&&!h.closest(ln)?h:void 0}i(S,"blockOf");function k(d){let h=e.structure(),y=h.keysOf.get(d)?.[0],b=y!==void 0?at(h.nodes,y):void 0;if(!b)return;let{x:v,y:E,width:R,height:D}=d.getBoundingClientRect();return{kind:"node",node:cn(b[b.length-1]),ancestors:b.slice(0,-1).map(M=>({...M,children:[]})),rect:{x:v,y:E,width:R,height:D}}}i(k,"nodeTarget");function x(d){let h=new Map,y=[];for(let b of r){if(b.target!==d.kind)continue;let v=!0;try{v=b.when?b.when(d)!==!1:!0}catch{v=!1}if(!v)continue;let E=`frame:${b.full}:${d.kind}`;y.push({id:E,label:b.label}),h.set(E,()=>b.run(d))}return{entries:y,run:h}}i(x,"frameEntries");async function T(d,h){let y=new Map(h.run),b=[...h.entries];if(o.has(d.kind))try{let v=await e.call("anfra.menu",d);for(let E of Array.isArray(v)?v:[]){if(typeof E?.id!="string"||typeof E.label!="string")continue;let R=`host:${E.id}:${d.kind}`;b.push({id:R,label:E.label,...typeof E.disabled=="string"?{disabled:E.disabled}:{}}),y.set(R,()=>e.call("anfra.run",{id:E.id,target:d}))}}catch{}return{entries:b,run:y}}i(T,"entriesFor");function C(d,h){let y=h.map(R=>({target:R,own:x(R)})).filter(({target:R,own:D})=>D.entries.length||o.has(R.kind));if(!y.length)return!1;d.preventDefault();let b=d,v=typeof b.clientX=="number"?b.clientX:0,E=typeof b.clientY=="number"?b.clientY:0;return(async()=>{let[R,...D]=await Promise.all([s(),...y.map(({target:Q,own:te})=>T(Q,te))]),M=D.map(Q=>Q.entries).filter(Q=>Q.length);if(!M.length)return;w();let j=R.menu(c(),{x:v,y:E,groups:M,onPick:i(Q=>{let te=D.map(ne=>ne.run.get(Q)).find(Boolean);Promise.resolve().then(te).catch(ne=>n.console?.error("anfra: a menu item failed:",ne))},"onPick"),onClose:i(()=>{l===j&&(l=void 0)},"onClose")});l=j})().catch(R=>n.console?.error("anfra: the menu failed to open:",R)),!0}i(C,"open");function p(){a||!(f("node")||f("rows"))||(a=!0,n.addEventListener("contextmenu",d=>{if(d.defaultPrevented||d.shiftKey)return;let h=S(d.target),y=h&&k(h);y&&C(d,[y])}))}i(p,"listen"),ye=i((d,h)=>{if(d.defaultPrevented||d.shiftKey)return!1;let y=S(d.target),b=y?k(y):void 0,v=b?{...h,node:b}:h;return C(d,b?[v,b]:[v])},"rowsOpener"),e.on("menu",d=>{let h=d?.kinds;o=new Set((Array.isArray(h)?h:[]).filter(y=>y==="node"||y==="rows")),p()});async function m(d,h){let y=await s();w();let b=i(()=>{},"close");return b=h(y,i(()=>{l===b&&(l=void 0);try{d.onClose?.()}catch{}},"onClose")),l=b,{close:b}}return i(m,"show"),{addItem(d,h){r.push({...h,full:`${d}.${h.id}`}),p()},modal:i(d=>m(d,(h,y)=>h.modal(c(),{title:d.title,size:d.size,mount:d.mount,onClose:y})),"modal"),popover:i(d=>m(d,(h,y)=>{let{anchor:b}=d,v;if("kind"in b){let E=e.structure().elements.get(b.node.key);v=i(()=>{if(!E?.isConnected)return;let{x:R,y:D,width:M,height:j}=E.getBoundingClientRect();return{x:R,y:D,width:M,height:j}},"rect")}else v=i(()=>({x:b.x,y:b.y,width:0,height:0}),"rect");return h.popover(c(),{anchor:v,side:d.side,mount:d.mount,dismiss:d.dismiss,closeButton:d.closeButton,onClose:y})}),"popover")}}i(lt,"installContentUi");var ct=["ctrl","alt","shift","meta"];function dt(e){if(typeof e!="string")return;let n=e.split("+").map(o=>o.trim().toLowerCase()).filter(Boolean),t=n.pop(),r=i(o=>ct.includes(o),"isModifier");if(!(!t||r(t)||!n.every(r)))return[...ct.filter(o=>n.includes(o)),t].join("+")}i(dt,"normalizeShortcut");function ut(e){let n=e;return!n||typeof n.tagName!="string"?!1:n.isContentEditable===!0||["INPUT","TEXTAREA","SELECT"].includes(n.tagName.toUpperCase())}i(ut,"isTyping");function pt(e){let n=typeof e.code=="string"?e.code:"",t=/^Key[A-Z]$/.test(n)?n.slice(3).toLowerCase():/^Digit[0-9]$/.test(n)?n.slice(5):(e.key??"").toLowerCase();return[e.ctrlKey&&"ctrl",e.altKey&&"alt",e.shiftKey&&"shift",e.metaKey&&"meta",t].filter(Boolean).join("+")}i(pt,"eventShortcut");function be(e,n,t,r,o){if(r in n||e.has(r))throw new g(`Plugin \'${r}\' can\'t add \'${r}\' to a ${t}: it already has one.`);e.set(r,o)}i(be,"addExtension");function W(e,n){return n?.forEach((t,r)=>{let o=!1,a;Object.defineProperty(e,r,{configurable:!0,enumerable:!1,get(){return o||(a=t(e),o=!0),a}})}),e}i(W,"applyExtensions");var un="anfra.body",we="__anfraBodyExports",pn={DataAppError:O,ValidationError:g,QueryError:_,PermissionError:N,TransportError:$};function fn(e,n){let t=e,r=e.document.createElement("script");r.textContent=`(function () { var __anfraBody;\n${n}\n;self[${JSON.stringify(we)}] = __anfraBody; })();`,(e.document.head??e.document.documentElement).appendChild(r),r.remove();let o=t[we];if(delete t[we],!o)throw new g("The host sent a plugin body that did not run.");return o.default??o}i(fn,"runBody");function ke(e,n,t){let{window:r,sdk:o,endpoint:a}=n,l;return{plugin:e,window:r,sdk:o,errors:pn,get overlay(){return q(r.document)},structure:i(()=>Ge(r.document,o.apps),"structure"),call:i((s,c,f)=>a.call(s,c??null,f),"call"),emit:i((s,c)=>a.emit(`${e}.${s}`,c??null),"emit"),handle(s,c){n.handlers.set(`${e}.${s}`,c)},on(s,c){let f=`${e}.${s}`;n.listeners.has(f)||n.listeners.set(f,new Set),n.listeners.get(f).add(c)},onApp(s){n.appListeners.add(s),o.apps.forEach(c=>s(c))},provide(s){if(e in o)throw new g(`Plugin \'${e}\' can\'t add a member Anfra already has.`);Object.defineProperty(o,e,{value:s,enumerable:!0})},provideOnQuery:i(s=>be(o.extensions.query,t.Query.prototype,"query",e,s),"provideOnQuery"),provideOnControl:i(s=>be(o.extensions.control,t.Control.prototype,"control",e,s),"provideOnControl"),layer:i(()=>L(r.document,e),"layer"),menuItem:i(s=>n.contentUi?.addItem(e,s),"menuItem"),modal:i(s=>n.contentUi.modal(s),"modal"),popover:i(s=>n.contentUi.popover(s),"popover"),body(){return l??(l=a.call(un,{plugin:e}).then(s=>fn(r,s)).catch(s=>{throw l=void 0,s})),l}}}i(ke,"createKernel");var ve=class ve extends P{constructor(t,r,o){super(r);u(this,"kind","query");u(this,"name");u(this,"declaration");u(this,"dataset");u(this,"app");u(this,"_state","idle");u(this,"_result");u(this,"_error");u(this,"_page",1);u(this,"_sort",[]);u(this,"lastRunSignature");u(this,"lastPageRows",0);u(this,"controller");if(!o.aql?.trim())throw new g(`Query \'${t}\' declares no AQL.`,t);let{pageSize:a}=o;if(a!==void 0&&!(Number.isInteger(a)&&a>=1))throw new g(`Query \'${t}\' declares pageSize ${a}; it must be a whole number of at least 1.`,t);this.name=t,this.app=r,this.declaration=o,this.dataset=r.datasetIndex(o.dataset,t)}locate(){return this.app.locate("query",this.name)}get state(){return this._state}get result(){return this._result}get error(){return this._error}get pageSize(){return this.declaration.pageSize}get page(){return this._page}get sort(){return this._sort}setSort(t){this._sort=[...t],this.notify()}get hasMore(){return!this._result||this.pageSize===void 0?!1:this._result.meta.hasMore??this.lastPageRows>=this.pageSize}signature(){let t=this.app.mappingsTo(this.name).map(r=>({field:r.field,aggregation:r.aggregation,condition:r.from.condition})).sort((r,o)=>r.field.localeCompare(o.field)||JSON.stringify(r).localeCompare(JSON.stringify(o)));return JSON.stringify({declaration:this.declaration,conditions:t,selection:this.app.selectionConditionsFor(this.name,"pending"),selectionExpression:this.app.selectionExpressionFor(this.name,"pending"),sort:this._sort,timezone:this.app.timezone,page:this._page})}get isDirty(){return this.lastRunSignature!==void 0&&this.signature()!==this.lastRunSignature}shouldRun(t=!1){return t||this.lastRunSignature===void 0||this.isDirty}abort(){this.controller?.abort()}async fetchMore(){if(this.pageSize===void 0)throw new g(`Query \'${this.name}\' declares no pageSize, so it has no more pages.`,this.name);this.hasMore&&(this._page+=1,await this.app.fetchPage(this))}menu(t,r,o={}){return this.app.menu(this,t,Array.isArray(r)?r:[r],o.fields)}select(t,r={}){this.app.select(this,Array.isArray(t)?t:[t],r.fields)}get selectedRows(){let{selection:t}=this.app;if(t?.source!==this.name)return[];let r=this._result?.rows;if(!r)return t.rows;let o=i(l=>JSON.stringify(t.fields.map(s=>l[s]??null)),"key"),a=new Set(t.rows.map(o));return r.filter(l=>a.has(o(l)))}markExecuting(){this._state="executing",this._error=void 0,this.notify()}markSuccess(t,r,o){if(this._state="success",this._error=void 0,this.lastRunSignature=r,this.lastPageRows=t.rows.length,o&&this._result){let a=[...this._result.rows,...t.rows];this._result={...t,rows:a,meta:{...t.meta,numRows:a.length}}}else this._result=t;this.notify()}markError(t){this._state="error",this._error=t,this.notify()}rewindPage(){this._page>1&&(this._page-=1)}resetPage(){this._page=1,this.lastPageRows=0}toJSON(){return this.declaration}};i(ve,"Query");var I=ve;var xe=class xe{constructor(n,t,r,o){u(this,"kind","control");u(this,"from");u(this,"to");u(this,"field");u(this,"aggregation");this.from=n,this.to=t,this.field=r,this.aggregation=o}get id(){return`${this.from.name}.${this.to.name}.${this.field}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:this.from.kind,name:this.from.name},to:{kind:"query",name:this.to.name},field:this.field,...this.aggregation?{aggregation:this.aggregation}:{}}}};i(xe,"Mapping");var Y=xe,Ee=class Ee{constructor(n,t){u(this,"kind","crossFilter");u(this,"from");u(this,"to");this.from=n,this.to=t}get id(){return`${this.from.name}.${this.to.name}`}toJSON(){return{kind:this.kind,id:this.id,from:{kind:"query",name:this.from.name},to:{kind:"query",name:this.to.name}}}};i(Ee,"CrossFilter");var X=Ee;var Se=["sum","avg","max","min","count","count distinct","median","stdev","stdevp","var","varp"];function mn(e,n){let t=e.length+1,r=n.length+1,o=Array.from({length:r},(a,l)=>l);for(let a=1;a<t;a++){let l=[a];for(let s=1;s<r;s++)l[s]=Math.min(o[s]+1,l[s-1]+1,o[s-1]+(e[a-1]===n[s-1]?0:1));o=l}return o[r-1]}i(mn,"editDistance");function hn(e,n){let t,r=1/0;n.forEach(a=>{let l=mn(e.toLowerCase(),a.toLowerCase());l<r&&(r=l,t=a)});let o=Math.max(2,Math.floor(e.length/3));return r<=o?t:void 0}i(hn,"suggest");function B(e,n,t){let r=hn(n,t);return r?`${e} Did you mean \'${r}\'?`:e}i(B,"withSuggestion");var Te=class Te{constructor(n){u(this,"descriptor");u(this,"fields",new Map);u(this,"references");this.descriptor=n,n.data_models.forEach(t=>{t.fields.forEach(r=>{let o=String(t.name);this.fields.set(`${o}.${r.name}`,{modelName:o,fieldName:r.name,isMetric:!1,type:r.type,label:r.label??r.name})})}),n.metrics.forEach(t=>{this.fields.set(t.name,{fieldName:t.name,isMetric:!0,type:t.type,label:t.label??t.name})}),this.references=[...this.fields.keys()]}resolve(n,t){let r=this.fields.get(n);if(r)return r;throw new g(B(`Unknown field \'${n}\' on dataset \'${this.descriptor.name}\'.`,n,this.references),t)}};i(Te,"DatasetIndex");var Z=Te;function ft(e,n,t){let r=e[n];if(r)return r;throw new g(B(`Unknown dataset \'${n}\'.`,n,Object.keys(e)),t)}i(ft,"resolveDataset");function mt(e,n){if(!Se.includes(e))throw new g(B(`Invalid filter aggregation \'${e}\'.`,e,[...Se]),n)}i(mt,"assertValidFilterAggregation");function ht(e,n,t){if(!n)throw new g(`A ${t} needs a name.`);for(let r of e)if(r===n)throw new g(`\'${n}\' is already declared in this app.`,n)}i(ht,"assertUniqueName");function gn(e,n){if(!(!n||n.operator==="none"||n.operator==="transform_date_drill"||!["is_null","not_null","is_true","is_false","transform_pop_none"].includes(n.operator)&&!n.values?.length))return{field:e.field,operator:n.operator,values:n.values??[],...n.modifier?{modifier:n.modifier}:{},...e.aggregation?{aggregation:e.aggregation}:{}}}i(gn,"toFilter");function yn(e,n){if(n?.operator!=="transform_date_drill")return;let t=n.values?.[0];if(typeof t!="string")return;let r=t.replace(/^datetrunc\\s+/,"");return{field:e.field,grain:r}}i(yn,"toDateDrill");function bn(e,n){let t=n.columns??[],r=(n.values??[]).map(a=>{let l={};return t.forEach((s,c)=>{l[s.name]=a[c]}),l}),{pageSize:o}=e;return{columns:t,rows:r,meta:{...o!==void 0?{page:n.meta?.page??e.page,pageSize:n.meta?.pageSize??o,...n.meta?.hasMore!==void 0?{hasMore:n.meta.hasMore}:{}}:{},numRows:n.meta?.numRows??r.length},...n.debug?{debug:n.debug}:{}}}i(bn,"toResult");function gt(e,n,t,r){let o=n.map(c=>gn(c,c.from.appliedCondition)).filter(c=>c!==void 0),a=n.map(c=>yn(c,c.from.appliedCondition)).filter(c=>c!==void 0),l=t.conditions.map(c=>({field:c.field,operator:c.operator,values:c.values})),s=t.expression?[{expr:t.expression}]:[];return{dataset:e.dataset.descriptor.name,aql:e.declaration.aql,input:{filters:[...o,...l],conditions:s,sorts:e.sort.map(c=>({field:c.field,direction:c.direction??"asc"})),dateDrills:a},...r.timezone?{timezone:r.timezone}:{}}}i(gt,"buildQuery");function wn(e,n,t,r){return{...gt(e,n,t,r),...e.pageSize!==void 0?{page:e.page,pageSize:e.pageSize}:{},...r.bustCache?{bustCache:!0}:{}}}i(wn,"buildRequest");function kn(e,n){let t=n?.replace(/[/\\\\]/g,"-").replace(/\\p{Cc}/gu,"").trim();return t?`${t} - ${e.name}`:e.name}i(kn,"defaultExportFilename");function yt(e,n,t,r,o){let a=o.format??"csv",l=a==="csv"?{bom:!0,...o.formatOptions}:o.formatOptions;return{...gt(e,n,t,r),format:a,...l?{formatOptions:l}:{},filename:o.filename?.trim()||kn(e,r.title)}}i(yt,"buildExportRequest");async function Ce(e,n,t,r,o){let a=wn(e,n,t,r),l=await r.backend.submitQuery(a,o);return bn(e,l)}i(Ce,"runQuery");function vn(e,n){if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(n==="number"&&typeof e=="string")return Sn(e);if(typeof e=="number"){if(!Number.isFinite(e))throw new RangeError(`Cannot express ${e} in AQL.`);return Math.abs(e)>=1e21?BigInt(e).toString():String(e)}return JSON.stringify(e).split("\\u2028").join("\\\\u2028").split("\\u2029").join("\\\\u2029")}i(vn,"literal");function bt(e,n,t){return n===null?`is(${e}, null)`:`${e} is ${vn(n,t)}`}i(bt,"equals");var xn=new Set(["NaN","Infinity","-Infinity"]),En=/^(-?)(0|[1-9]\\d*)(?:\\.(\\d+))?(?:[eE]([+-]?\\d+))?$/;function Sn(e){let n=En.exec(e);if(!n)throw xn.has(e)?new RangeError(`Cannot express ${e} in AQL.`):new TypeError(`${JSON.stringify(e)} is not a number: a number is a string in JSON\'s number syntax.`);let[,t,r,o="",a]=n;if(a===void 0)return e;let l=r+o,s=r.length+Number(a),c;return s<=0?c=`0.${"0".repeat(-s)}${l}`:s>=l.length?c=l+"0".repeat(s-l.length):c=`${l.slice(0,s)}.${l.slice(s)}`,t+c.replace(/^0+(?=\\d)/,"")}i(Sn,"numberLiteral");function wt(e,n,t){return`${e} matches @(${n} until ${t})`}i(wt,"dateRange");function kt(e,n){if(n.length===0)throw new RangeError(`\\`${e}\\` needs at least one operand.`);return n.length===1?n[0]:`${e}(${n.join(", ")})`}i(kt,"combine");var vt=i(e=>kt("and",e),"and"),xt=i(e=>kt("or",e),"or");var Tn=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?)?/,Cn={week:7*864e5,day:864e5,hour:36e5,minute:6e4};function Et(e){if(typeof e!="string")return;let n=Tn.exec(e);if(n)return{year:Number(n[1]),month:Number(n[2])-1,day:Number(n[3]),hour:Number(n[4]??0),minute:Number(n[5]??0),second:Number(n[6]??0),hasTime:n[4]!==void 0}}i(Et,"parseStamp");function V(e,n){let t=new Date(e),r=i(a=>String(a).padStart(2,"0"),"pad"),o=`${t.getUTCFullYear()}-${r(t.getUTCMonth()+1)}-${r(t.getUTCDate())}`;return n?`${o} ${r(t.getUTCHours())}:${r(t.getUTCMinutes())}:${r(t.getUTCSeconds())}`:o}i(V,"format");function St(e){return Date.UTC(e.year,e.month,e.day,e.hour,e.minute,e.second)}i(St,"toMs");function Ae(e){let n=Et(e);if(n)return V(St(n),n.hasTime)}i(Ae,"normalise");function Re(e,n){let t=Et(e);if(!t)return;let{year:r,month:o,day:a,hour:l,minute:s,second:c,hasTime:f}=t;return V(n==="year"?Date.UTC(r+1,o,a,l,s,c):n==="quarter"?Date.UTC(r,o+3,a,l,s,c):n==="month"?Date.UTC(r,o+1,a,l,s,c):St(t)+Cn[n],f)}i(Re,"addGrain");function Tt(e){if(e?.startsWith("datetrunc "))return e.slice(10)}i(Tt,"grainOf");function An(e){let n=new Set;return e.filter(t=>{let r=`${typeof t}:${String(t)}`;return n.has(r)?!1:(n.add(r),!0)})}i(An,"distinct");function Rn(e,n){let t=e.map(Ae);if(t.some(o=>o===void 0))return!1;let r=t.slice().sort();for(let o=1;o<r.length;o+=1)if(Re(r[o-1],n)!==r[o])return!1;return!0}i(Rn,"isContiguous");function Dn(e,n,t){let r=n.map(Ae);if(r.some(c=>c===void 0))return;let o=r.slice().sort(),a=o[0],l=Re(o[o.length-1],t);if(!l)return;let s=Rn(n,t);return{condition:{field:e,operator:"matches",values:[`${a} until ${l}`]},admits:s?n.length:Number.POSITIVE_INFINITY,lossy:!s}}i(Dn,"dateRange");function On(e,n,t){let r=t.filter(s=>s!=null),o=An(r);if(!o.length)return{condition:{field:e,operator:"is_null",values:[]},admits:1,lossy:!1};let a=r.length!==t.length,l=Tt(n);if(l){let s=Dn(e,o,l);if(s)return{...s,lossy:s.lossy||a}}return{condition:{field:e,operator:"is",values:o},admits:o.length,lossy:a}}i(On,"deriveOne");function Ct(e){return e.modelId?`${e.modelId}.${e.fieldName}`:e.fieldName}i(Ct,"fieldReferenceOf");function $n(e,n,t,r){try{let o=t.map(a=>vt(n.map(l=>{let s=e.get(l),c=Ct(s),f=a[l]??null,w=Tt(r[c]);if(w&&typeof f=="string"){let S=Ae(f),k=Re(f,w);if(S&&k)return wt(c,S,k)}if(f!==null&&typeof f!="string"&&typeof f!="number"&&typeof f!="boolean")throw new TypeError("no AQL spelling");return bt(c,f,s.semantic_type)})));return xt(o)}catch{return}}i($n,"selectionExpression");function De(e,n,t,r={}){let o=e.result?.columns??[],a=new Map(o.map(p=>[p.name,p]));t?.forEach(p=>{let m=a.get(p);if(m){if(m.adhoc)throw new g(`Query \'${e.name}\' cannot cross-filter on \'${p}\': it is a query-local AQL expression, which only this query\'s result carries. The target query would receive a condition naming a field it has never heard of.`,e.name);if(m.isMeasure)throw new g(`Query \'${e.name}\' cannot cross-filter on \'${p}\': it is a measure, and a selection conditions dimensions only.`,e.name);return}throw new g(B(`Query \'${e.name}\' has no column \'${p}\' in its last result.`,p,[...a.keys()]),e.name)});let l=o.filter(p=>!p.isMeasure),s=l.filter(p=>!p.adhoc).map(p=>p.name),c=t?[...t]:s;if(!n.length||!c.length)return;let f=[],w=1,S=!t&&s.length!==l.length,k=!1;c.forEach(p=>{let m=a.get(p),d=Ct(m),h=On(d,r[d],n.map(y=>y[p]));f.push(h.condition),w*=h.admits,k=k||h.lossy});let x=new Set(n.map(p=>JSON.stringify(c.map(m=>p[m]??null))));w>x.size&&(k=!0);let T=f.sort((p,m)=>p.field.localeCompare(m.field)),C={source:e.name,rows:[...n],fields:c};if(k){let p=$n(a,c,n,r);if(p)return{...C,conditions:[],expression:p,lossy:S}}return{...C,conditions:T,lossy:S||k}}i(De,"deriveSelection");var Oe=Object.freeze([]);function $e(e){return e instanceof Error&&e.name==="AbortError"}i($e,"isAbort");function At(e,n){return e.controller!==n}i(At,"superseded");function Mn(e){return{name:e.name,message:e.message,...e.entity?{entity:e.entity}:{},...typeof e.status=="number"?{status:e.status}:{},...e.stack?{stack:e.stack}:{}}}i(Mn,"inspectError");function _n(e){let{result:n}=e;return{state:e.state,isDirty:e.isDirty,page:e.page,hasMore:e.hasMore,columns:n?n.columns.map(t=>({...t})):[],rowCount:n?.meta.numRows??0,selectedRowCount:e.selectedRows.length,signature:e.signature(),...e.error?{error:Mn(e.error)}:{},...n?.debug?{debug:{...n.debug}}:{}}}i(_n,"inspectQuery");function Nn(e){let{options:n}=e;return{kind:e.kind,condition:{...e.condition},...e.appliedCondition?{appliedCondition:{...e.appliedCondition}}:{},isDirty:e.isDirty,...n?{options:[...n]}:{}}}i(Nn,"inspectControl");function Rt(e){return{source:e.source,fields:[...e.fields],rowCount:e.rows.length,conditions:e.conditions.map(n=>({...n})),...e.expression?{expression:e.expression}:{},lossy:e.lossy}}i(Rt,"inspectSelection");function Dt(e){return e?JSON.stringify({source:e.source,conditions:e.conditions,expression:e.expression}):"none"}i(Dt,"selectionKey");function Ot(e,n){return e instanceof O?e:new _(e?.message??"The query failed.",n,e)}i(Ot,"toDataAppError");function Fn(e,n){if(e instanceof O&&e.entity)return e;let t=e?.message||"The export failed.";return e instanceof N?new N(t,n):e instanceof $?new $(t,e.status,n):e instanceof g?new g(t,n):new _(t,n,e)}i(Fn,"toExportError");var Me=class Me extends P{constructor(t,r,o,a,l){super();u(this,"extensions",l);u(this,"title");u(this,"_timezone");u(this,"datasets");u(this,"backend");u(this,"features");u(this,"_queries",new Map);u(this,"_controls",new Map);u(this,"_mappings",[]);u(this,"_crossFilters",[]);u(this,"_selection");u(this,"_appliedSelection");u(this,"selectionCommitted",!1);u(this,"index",0);this.title=t.title,this._timezone=t.timezone,this.datasets=r,this.backend=o,this.features=a}get queries(){return Object.fromEntries(this._queries)}get controls(){return Object.fromEntries(this._controls)}get mappings(){return[...this._mappings,...this._crossFilters]}get crossFilters(){return this._crossFilters}createQuery(t,r){this.assertNameFree(t,"query");let o=W(new I(t,this,r),this.extensions?.query);return this._queries.set(t,o),this.notify(),o}createFilter(t,r){this.assertNameFree(t,"filter");let o=r.dataset?this.datasetIndex(r.dataset,t):this.soleDataset(t,r.field),a=W(new U(t,this,r,o,this.backend),this.extensions?.control);return this._controls.set(t,a),this.notify(),a}createDateDrill(t,r={}){if(this.features?.dateDrill===!1)throw new g(`Date drill \'${t}\' needs a capability this workspace has not enabled. Ask an admin to turn on \\`interactive_control:date_drill\\`.`,t);this.assertNameFree(t,"date drill control");let o=W(new J(t,this,r),this.extensions?.control);return this._controls.set(t,o),this.notify(),o}mapControl(t,r,o){if(!(t instanceof F))throw new g("mapControl expects a control as its source. To let one query cross-filter another, use app.mapCrossFilter(from, to) \\u2014 a cross-filter edge names no field.");if(this._controls.get(t.name)!==t)throw new g(`Control \'${t.name}\' belongs to a different app.`,t.name);if(this._queries.get(r.name)!==r)throw new g(`Query \'${r.name}\' belongs to a different app.`,r.name);o.aggregation&&mt(o.aggregation,t.name);let a=new Y(t,r,o.field,o.aggregation);if(this._mappings.some(l=>l.id===a.id))throw new g(`Mapping \'${a.id}\' is already declared.`,t.name);return this.assertAcyclic(a),this._mappings.push(a),this.notify(),a}mapCrossFilter(t,r){if(!(t instanceof I)||!(r instanceof I))throw new g("mapCrossFilter expects two queries. To let a control condition a query, use app.mapControl(from, to, { field }).");if(this._queries.get(t.name)!==t)throw new g(`Query \'${t.name}\' belongs to a different app.`,t.name);if(this._queries.get(r.name)!==r)throw new g(`Query \'${r.name}\' belongs to a different app.`,r.name);if(t===r)throw new g(`Query \'${t.name}\' cannot cross-filter itself. A source keeps its own rows so it can show what is selected; filtering it would erase the very rows the reader clicked.`,t.name);if(t.declaration.dataset!==r.declaration.dataset)throw new g(`Cross-filter \'${t.name}\' -> \'${r.name}\' spans two datasets (\'${t.declaration.dataset}\' and \'${r.declaration.dataset}\'). A selection carries field references, which mean nothing outside the dataset that resolved them.`,t.name);let o=new X(t,r);if(this._crossFilters.some(a=>a.id===o.id))throw new g(`Cross-filter \'${o.id}\' is already declared.`,t.name);return this._crossFilters.push(o),this.notify(),o}get selection(){return this._selection}get appliedSelection(){return this._appliedSelection}clearSelection(){this._selection&&(this._selection=void 0,this.notify())}setTimezone(t){this._timezone=t,this.notify()}get timezone(){return this._timezone}datasetIndex(t,r){return ft(this.datasets,t,r)}mappingsTo(t){return this._mappings.filter(r=>r.to.name===t)}selectionExpressionFor(t,r){return this.selectionFor(t,r)?.expression}selectionFor(t,r){let o=r==="pending"?this._selection:this._appliedSelection;return!o||o.source===t?void 0:this._crossFilters.some(l=>l.from.name===o.source&&l.to.name===t)?o:void 0}selectionConditionsFor(t,r){let o=r==="pending"?this._selection:this._appliedSelection;return!o||o.source===t?Oe:this._crossFilters.some(l=>l.from.name===o.source&&l.to.name===t)?o.conditions:Oe}drillTransformations(t){let r={};return this._mappings.forEach(o=>{if(o.to!==t)return;let a=o.from.appliedCondition;if(a?.operator!=="transform_date_drill")return;let[l]=a.values??[];typeof l=="string"&&(r[o.field]=l)}),r}menu(t,r,o,a){if(this._queries.get(t.name)!==t)throw new g(`Query \'${t.name}\' belongs to a different app.`,t.name);let l=De(t,o,a,this.drillTransformations(t));return st(r,{kind:"rows",app:this.index,query:t.name,rows:[...o],fields:l?.fields?[...l.fields]:[],conditions:l?.conditions?[...l.conditions]:[],...l?.expression?{expression:l.expression}:{}})}select(t,r,o){if(this._queries.get(t.name)!==t)throw new g(`Query \'${t.name}\' belongs to a different app.`,t.name);let a=De(t,r,o,this.drillTransformations(t));a?.lossy&&console.warn(`[anfra-sdk] The selection in \'${t.name}\' filters more broadly than it was made. Its conditions are combined field by field and ANDed, which cannot express "(A and B) or (C and D)", so the targets will also show combinations that were not selected. Select within one dimension, or narrow with \\`fields\\`, to avoid this.`),this._selection=a,this.notify()}get hasChanges(){return[...this._controls.values()].some(t=>t.isDirty)||this.isSelectionDirty}get isSelectionDirty(){return this.selectionCommitted?Dt(this._selection)!==Dt(this._appliedSelection):!1}async execute(t={}){let r=[...this._queries.values()].filter(s=>s.shouldRun(t.force));this._controls.forEach(s=>s.commit()),this._appliedSelection=this._selection,this.selectionCommitted=!0,r.forEach(s=>{s.controller?.abort(),s.resetPage()});let o={backend:this.backend,timezone:this._timezone,bustCache:t.bustCache},a=[],l=[];return await Promise.all(r.map(async s=>{let c=new AbortController;s.controller=c;let f=s.signature();s.markExecuting();try{let w=await Ce(s,this.mappingsTo(s.name),{conditions:this.selectionConditionsFor(s.name,"applied"),expression:this.selectionExpressionFor(s.name,"applied")},o,c.signal);if(At(s,c))return;s.markSuccess(w,f,!1),a.push(s.name)}catch(w){if(At(s,c)||$e(w))return;s.markError(Ot(w,s.name)),l.push(s.name)}finally{s.controller===c&&(s.controller=void 0)}})),{succeeded:a,failed:l}}async refresh(){return this.execute({force:!0,bustCache:!0})}abort(){this._queries.forEach(t=>t.abort())}async fetchPage(t){let r=new AbortController;t.controller=r;let o=t.signature();t.markExecuting();try{let a=await Ce(t,this.mappingsTo(t.name),{conditions:this.selectionConditionsFor(t.name,"applied"),expression:this.selectionExpressionFor(t.name,"applied")},{backend:this.backend,timezone:this._timezone},r.signal);t.markSuccess(a,o,!0)}catch(a){if(t.rewindPage(),$e(a))return;let l=Ot(a,t.name);throw t.markError(l),l}finally{t.controller===r&&(t.controller=void 0)}}async exportQuery(t,r,o){let a=yt(t,this.mappingsTo(t.name),{conditions:this.selectionConditionsFor(t.name,"applied"),expression:this.selectionExpressionFor(t.name,"applied")},{backend:this.backend,timezone:this._timezone,title:this.title},r);try{return await o(a,r.signal??new AbortController().signal)}catch(l){throw $e(l)?l:Fn(l,t.name)}}toJSON(){let t=i(r=>Object.fromEntries([...this._controls.entries()].filter(([,o])=>o.kind===r).map(([o,a])=>[o,a.toJSON()])),"byKind");return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},queries:Object.fromEntries([...this._queries.entries()].map(([r,o])=>[r,o.toJSON()])),filters:t("filter"),dateDrills:t("dateDrill"),mappings:[...this._mappings.map(r=>r.toJSON()),...this._crossFilters.map(r=>r.toJSON())]}}toInspectJSON(){return{...this.title?{title:this.title}:{},...this._timezone?{timezone:this._timezone}:{},hasChanges:this.hasChanges,declaration:this.toJSON(),queries:Object.fromEntries([...this._queries.entries()].map(([t,r])=>[t,_n(r)])),controls:Object.fromEntries([...this._controls.entries()].map(([t,r])=>[t,Nn(r)])),...this._selection?{selection:Rt(this._selection)}:{},...this._appliedSelection?{appliedSelection:Rt(this._appliedSelection)}:{}}}locate(t,r){let o=globalThis.document;if(!o)return!1;let a=Je(o,t,this.index,r);return a.length?(H(a[0]),q(o).flash(a,{kind:t,name:r,...a.length>1?{note:`in ${a.length} places`}:{}}),!0):!1}assertNameFree(t,r){ht([...this._queries.keys(),...this._controls.keys()],t,r)}soleDataset(t,r){if(!r)return;let o=Object.keys(this.datasets);if(o.length===1)return this.datasets[o[0]];throw new g(o.length?`Filter \'${t}\' names a field but the environment has ${o.length} datasets. Say which one: ${o.join(", ")}.`:`Filter \'${t}\' names a field but the environment has no datasets.`,t)}assertAcyclic(t){let r=[...this._mappings,t],o=new Map;r.forEach(c=>{let f=c.from.name;o.set(f,[...o.get(f)??[],c.to.name])});let a=new Set,l=new Set,s=i(c=>{if(a.has(c))return!0;if(l.has(c))return!1;a.add(c);let f=(o.get(c)??[]).some(s);return a.delete(c),l.add(c),f},"walk");if([...o.keys()].some(s))throw new g(`Mapping \'${t.id}\' would make the app\'s mappings cyclic.`,t.from.name)}};i(Me,"App");var ee=Me;var $t="0.15.1";var Ie=class Ie{constructor(){u(this,"current",{scheme:"light",tokens:pe.light});u(this,"listeners",new Set)}get scheme(){return this.current.scheme}get tokens(){return this.current.tokens}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}set(n){this.current=n,this.listeners.forEach(t=>{try{t(n)}catch{}})}};i(Ie,"HostTheme");var _e=Ie,Pe=class Pe{constructor(n){u(this,"list");this.list=Object.freeze(n.map(({name:t,version:r})=>Object.freeze({name:t,version:r})))}has(n){return this.list.some(t=>t.name===n)}version(n){return this.list.find(t=>t.name===n)?.version}};i(Pe,"InstalledPlugins");var Ne=Pe,Pn=$t,Qe=class Qe{constructor(n){u(this,"version",Pn);u(this,"_apps",[]);u(this,"datasets");u(this,"user");u(this,"indices");u(this,"backend");u(this,"plugins");u(this,"theme",new _e);u(this,"gates");u(this,"deprecatedFeatures");u(this,"extensions",{query:new Map,control:new Map});if(!n?.datasets)throw new g("No datasets provided. The host must call createSdk({ datasets }) before an app can be declared.");if(!n.user)throw new g("No user provided. The host must call createSdk({ user }) before an app can be declared.");if(!n.backend)throw new g("No backend provided. The host must call createSdk({ backend }) before an app can run a query.");this.datasets=Object.freeze({...n.datasets}),this.user=Object.freeze({...n.user,permissions:Object.freeze({...n.user.permissions})}),this.indices=Object.fromEntries(Object.entries(n.datasets).map(([t,r])=>[t,new Z(r)])),this.backend=n.backend,this.gates=Object.freeze({...n.features}),this.plugins=new Ne(n.plugins??[])}get features(){return this.deprecatedFeatures||(console.warn("anfra: Anfra.features is deprecated and will be removed. Check Anfra.plugins.has(\'export\'), Anfra.plugins.has(\'render\') or Anfra.plugins.has(\'lineage\') instead."),this.deprecatedFeatures=Object.freeze({...this.gates,export:this.plugins.has("export"),render:this.plugins.has("render"),lineage:this.plugins.has("lineage")})),this.deprecatedFeatures}createApp(n={}){let t=new ee(n,this.indices,this.backend,this.gates,this.extensions);return t.index=this._apps.length,this._apps.push(t),t}get apps(){return this._apps}};i(Qe,"Sdk");var Fe=Qe;function Mt(e){return new Fe(e)}i(Mt,"createSdk");var K="Anfra";function _t(e,n=globalThis){let t=n[K],r=K in n;return n[K]=e,()=>{r?n[K]=t:delete n[K]}}i(_t,"installSandbox");function Nt(e,n=[]){let t=e.document.getElementById(Le);if(!t?.textContent)throw new Error("anfra: this frame was not provisioned by a host.");let r=JSON.parse(t.textContent),o=i(m=>e.parent.postMessage(m,r.hostOrigin),"post"),a=new Map,l=new Map,s=ze(o,{answer:i(async(m,d,h)=>{let y=a.get(m);if(!y)throw new $(`Nothing in this frame answers \'${m}\'.`);return y(d,h)},"answer"),event:i((m,d)=>{l.get(m)?.forEach(h=>{try{h(d)}catch{}})},"event")}),c=i(m=>m.source===e.parent||!!r.hostOrigin&&r.hostOrigin!=="null"&&m.origin===r.hostOrigin,"fromHost");e.addEventListener("message",m=>{c(m)&&s.receive(m.data)});let f={submitQuery:i((m,d)=>s.call("core.submitQuery",m,d).then(h=>(h.debug?.executedAt&&(h.debug.executedAt=new Date(h.debug.executedAt)),h)),"submitQuery"),fieldSuggestions:i((m,d)=>s.call("core.fieldSuggestions",m,d),"fieldSuggestions")},w=Mt({datasets:r.datasets,user:r.user,backend:f,plugins:r.plugins??[]}),S=new Set,k=w.createApp.bind(w);w.createApp=m=>{let d=k(m);return S.forEach(h=>{try{h(d)}catch{}}),d};let x={window:e,sdk:w,endpoint:s,handlers:a,listeners:l,appListeners:S},T=ke("anfra",x,{Query:I,Control:F});it(T),x.contentUi=lt(T),T.on("theme",m=>{let d=Xe(m);et(e.document,d),w.theme.set(d)});let C=new Set,p=!1;T.on("shortcuts",m=>{C=new Set((Array.isArray(m)?m:[]).map(dt).filter(d=>!!d)),!(p||!C.size)&&(p=!0,e.addEventListener("keydown",d=>{if(d.defaultPrevented||d.repeat||ut(d.target))return;let h=pt(d);C.has(h)&&(d.preventDefault(),T.emit("shortcut",h))}))});for(let[m,d]of n)if(typeof d=="function")try{d(ke(m,x,{Query:I,Control:F}))}catch(h){e.console?.error(`anfra: plugin \'${m}\' failed to set up:`,h)}_t(w,e),o({type:"anfra:ready"})}i(Nt,"bootstrap");return zt(Qn);})();\n';
|
|
28
28
|
|
|
29
29
|
// anfra-sdk:anfra-sdk:ui
|
|
30
30
|
var anfra_sdk_ui_default = '"use strict";var __anfraBody=(()=>{var R=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var a=(n,t)=>R(n,"name",{value:t,configurable:!0});var B=(n,t)=>{for(var e in t)R(n,e,{get:t[e],enumerable:!0})},D=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of I(t))!O.call(n,d)&&d!==e&&R(n,d,{get:()=>t[d],enumerable:!(r=C(t,d))||r.enumerable});return n};var T=n=>D(R({},"__esModule",{value:!0}),n);var Y={};B(Y,{default:()=>z});var W=`\n:host { all: initial; }\n* { box-sizing: border-box; }\n/* A part\'s container: over the whole viewport in the top layer, letting the pointer through to the page. */\n.part { position: fixed; inset: 0; width: auto; height: auto; margin: 0; padding: 0; border: 0; overflow: visible; background: none; pointer-events: none; }\n.surface, .backdrop { pointer-events: auto; }\n.surface { position: fixed; z-index: 1; color: var(--anfra-color-fg, oklch(0.201 0.022 301.1)); background: var(--anfra-color-bg, oklch(1 0 0));\n border: 1px solid var(--anfra-color-border, oklch(0.201 0.022 301.1 / 0.12)); border-radius: calc(var(--anfra-radius, 10px) + 4px); /* a surface: the controls\' radius plus 4px, anfra-design\'s xl */\n box-shadow: 0 8px 24px oklch(0 0 0 / 18%), 0 1px 3px oklch(0 0 0 / 10%); font: 13px/1.45 var(--anfra-font, system-ui, sans-serif); }\n.menu { min-width: 180px; max-width: 320px; padding: 4px; outline: none; }\n.menu button { display: block; width: 100%; padding: 6px 10px; border: 0; border-radius: var(--anfra-radius, 10px); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }\n/* One highlight, as a native menu has: the focused entry, which the pointer and the arrows both move. */\n.menu button:focus { outline: none; background: color-mix(in srgb, var(--anfra-color-accent, oklch(0.484 0.181 298.1)) 14%, transparent); }\n.menu button[aria-disabled="true"] { color: var(--anfra-color-muted, oklch(0.485 0.022 306.3)); cursor: default; }\n.menu .reason { display: block; font-size: 11px; color: var(--anfra-color-muted, oklch(0.485 0.022 306.3)); }\n.menu hr { margin: 4px 0; border: 0; border-top: 1px solid var(--anfra-color-border, oklch(0.201 0.022 301.1 / 0.12)); }\n.backdrop { position: fixed; inset: 0; background: oklch(0 0 0 / 40%); }\n.modal { display: flex; flex-direction: column; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); }\n.modal.sm { width: 360px; } .modal.md { width: 560px; } .modal.lg { width: 860px; }\n.modal.full { width: calc(100vw - 32px); height: calc(100vh - 32px); }\n.modal header { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--anfra-color-border, oklch(0.201 0.022 301.1 / 0.12)); }\n.modal h2 { flex: 1; margin: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.close { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--anfra-color-muted, oklch(0.485 0.022 306.3)); cursor: pointer; font: 18px/1 var(--anfra-font, system-ui, sans-serif); }\n.close:hover { color: var(--anfra-color-fg, oklch(0.201 0.022 301.1)); background: color-mix(in srgb, var(--anfra-color-fg, oklch(0.201 0.022 301.1)) 7%, transparent); }\n.content { flex: 1; min-height: 0; overflow: auto; }\n.popover { max-width: min(360px, calc(100vw - 16px)); outline: none; }\n.popover > .close { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; font-size: 16px; }\n.popover.closable > .content { padding-right: 26px; }\n`;function N(n){return{width:n.innerWidth,height:n.innerHeight}}a(N,"viewport");function H(n,t,e,r,d){let{width:y,height:o}=N(n),s=e,g=r;return s+t.width>y-8&&(s=d?d.left-t.width:y-8-t.width),g+t.height>o-8&&(g=d?d.top-t.height:o-8-t.height),{left:Math.max(8,s),top:Math.max(8,g)}}a(H,"place");var P={right:"left",left:"right",bottom:"top",top:"bottom"};function K(n,t,e,r){let{width:d,height:y}=N(n),o=a(c=>c==="right"?{left:e.x+e.width+6,top:e.y}:c==="left"?{left:e.x-t.width-6,top:e.y}:c==="bottom"?{left:e.x,top:e.y+e.height+6}:{left:e.x,top:e.y-t.height-6},"at"),s=a(c=>{let{left:w,top:v}=o(c);return c==="right"||c==="left"?w>=8&&w+t.width<=d-8:v>=8&&v+t.height<=y-8},"fits"),g=[r,P[r],...["right","bottom","left","top"].filter(c=>c!==r&&c!==P[r])],{left:x,top:b}=o(g.find(s)??r),f=a((c,w,v)=>Math.max(8,Math.min(c,v-8-w)),"clamp");return{left:f(x,t.width,d),top:f(b,t.height,y)}}a(K,"beside");function L(n){let t=n.ownerDocument,e=t.createElement("div");e.className="part",e.setAttribute("popover","manual");let r=t.createElement("style");return r.textContent=W,e.append(r),n.append(e),e.showPopover?.(),{container:e,remove:a(()=>e.remove(),"remove")}}a(L,"part");function S(n,t){let e=n.createElement("div");return e.className=t,{element:e,root:e.attachShadow({mode:"open"})}}a(S,"contentRoot");function G(n,t,e){try{let r=t(e);return typeof r=="function"?r:()=>{}}catch(r){return n.console?.error("anfra: a plugin failed to draw:",r),()=>{}}}a(G,"mountContent");function $(n,t){let e=n.ownerDocument,r=e.defaultView,{container:d,remove:y}=L(n),o=e.createElement("div");o.className="surface menu",o.setAttribute("role","menu");let s=[];t.groups.filter(i=>i.length).forEach((i,m)=>{m>0&&o.append(e.createElement("hr"));for(let u of i){let p=e.createElement("button");if(p.type="button",p.setAttribute("role","menuitem"),p.dataset.item=u.id,p.textContent=u.label,u.disabled){p.setAttribute("aria-disabled","true"),p.title=u.disabled;let A=e.createElement("span");A.className="reason",A.textContent=u.disabled,p.append(A)}p.addEventListener("click",()=>{u.disabled||(h(),t.onPick(u.id))}),s.push(p),o.append(p)}}),d.append(o);let g=o.getBoundingClientRect(),{left:x,top:b}=H(r,g,t.x,t.y,{left:t.x,top:t.y});o.style.left=`${x}px`,o.style.top=`${b}px`,o.tabIndex=-1,o.focus();let f=s.filter(i=>!i.hasAttribute("aria-disabled"));o.addEventListener("pointermove",i=>{let m=i.composedPath().find(u=>s.includes(u));m&&f.includes(m)?n.activeElement!==m&&m.focus():n.activeElement!==o&&o.focus()}),o.addEventListener("pointerleave",()=>o.focus());let c=a(i=>{if(i.key==="Escape"){i.preventDefault(),h();return}if(i.key!=="ArrowDown"&&i.key!=="ArrowUp"||(i.preventDefault(),!f.length))return;let m=f.indexOf(n.activeElement),u=i.key==="ArrowDown"?1:-1,p=m===-1?u===1?0:f.length-1:(m+u+f.length)%f.length;f[p].focus()},"onKey"),w=a(i=>{i.composedPath().includes(o)||h()},"onOutside"),v=a(()=>h(),"onAway"),E=[[e,"keydown",c,!0],[e,"pointerdown",w,!0],[r,"scroll",v,!0],[r,"resize",v,!1],[r,"blur",v,!1]];E.forEach(([i,m,u,p])=>i.addEventListener(m,u,p));let l=!1;function h(){l||(l=!0,E.forEach(([i,m,u,p])=>i.removeEventListener(m,u,p)),y(),t.onClose())}return a(h,"close"),h}a($,"menu");function V(n,t){let e=n.ownerDocument,r=e.defaultView,{container:d,remove:y}=L(n),o=e.createElement("div");o.className="backdrop";let s=e.createElement("section");s.className=`surface modal ${t.size??"md"}`,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true");let g=e.createElement("header"),x=e.createElement("h2");x.id="anfra-modal-title",x.textContent=t.title,s.setAttribute("aria-labelledby",x.id);let b=e.createElement("button");b.type="button",b.className="close",b.setAttribute("aria-label","Close"),b.textContent="\\xD7",b.addEventListener("click",()=>A()),g.append(x,b);let f=S(e,"content");s.append(g,f.element),d.append(o,s);let c=n.host.parentElement,w=r,v=[],E=a(k=>{for(let M of k)!(M instanceof w.Element)||M===c||M.hasAttribute("inert")||(M.setAttribute("inert",""),v.push(M))},"inert");E(e.body.children);let l=new w.MutationObserver(k=>k.forEach(M=>E(M.addedNodes)));l.observe(e.body,{childList:!0});let h=e.documentElement,i={overflow:h.style.overflow,gutter:h.style.getPropertyValue("scrollbar-gutter")};r.innerWidth>h.clientWidth&&h.style.setProperty("scrollbar-gutter","stable"),h.style.overflow="hidden";let m=G(r,t.mount,f.root);b.focus();let u=a(k=>{k.key==="Escape"&&(k.preventDefault(),A())},"onKey");e.addEventListener("keydown",u,!0);let p=!1;function A(){if(!p){p=!0,e.removeEventListener("keydown",u,!0);try{m()}catch{}l.disconnect(),v.forEach(k=>k.removeAttribute("inert")),h.style.overflow=i.overflow,i.gutter?h.style.setProperty("scrollbar-gutter",i.gutter):h.style.removeProperty("scrollbar-gutter"),y(),t.onClose()}}return a(A,"close"),A}a(V,"modal");function U(n,t){let e=n.ownerDocument,r=e.defaultView,{container:d,remove:y}=L(n),o=e.createElement("section");o.className="surface popover",o.setAttribute("role","dialog"),o.tabIndex=-1;let s=S(e,"content");if(o.append(s.element),t.closeButton!==!1){o.classList.add("closable");let l=e.createElement("button");l.type="button",l.className="close",l.setAttribute("aria-label","Close"),l.textContent="\\xD7",l.addEventListener("click",()=>E()),o.append(l)}d.append(o);let g=G(r,t.mount,s.root);s.root.activeElement||o.focus();let x=!1,b=a(()=>{x=!1;let l=t.anchor();if(!l){E();return}let h=o.getBoundingClientRect(),{left:i,top:m}=K(r,h,l,t.side??"right");o.style.left=`${i}px`,o.style.top=`${m}px`},"position"),f=a(()=>{x||(x=!0,r.requestAnimationFrame(b))},"schedule");b();let c=a(l=>{l.key==="Escape"&&(l.preventDefault(),E())},"onKey"),w=a(l=>{l.composedPath().includes(o)||E()},"onOutside");e.addEventListener("keydown",c,!0),r.addEventListener("scroll",f,!0),r.addEventListener("resize",f),t.dismiss==="outside"&&e.addEventListener("pointerdown",w,!0);let v=!1;function E(){if(!v){v=!0,e.removeEventListener("keydown",c,!0),r.removeEventListener("scroll",f,!0),r.removeEventListener("resize",f),e.removeEventListener("pointerdown",w,!0);try{g()}catch{}y(),t.onClose()}}return a(E,"close"),E}a(U,"popover");var q={menu:$,modal:V,popover:U},z=q;return T(Y);})();\n';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DatasetDescriptor, aj as User, ah as StructureNode, aa as Row, ae as SelectionCondition } from './types-
|
|
1
|
+
import { D as DatasetDescriptor, aj as User, ah as StructureNode, aa as Row, ae as SelectionCondition } from './types-CKytl8ds.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The bridge: the postMessage protocol between a Data App's frame (`app`'s bootstrap) and the
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
} from "./chunk-DITKCHFQ.js";
|
|
9
9
|
import {
|
|
10
10
|
PLUGIN_VERSION
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PYAVAIAX.js";
|
|
12
12
|
import {
|
|
13
13
|
queriesOf,
|
|
14
14
|
stateOf
|
|
15
15
|
} from "./chunk-CYZQ7ZTJ.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-GIHCQT6L.js";
|
|
17
17
|
import {
|
|
18
18
|
LEVELS,
|
|
19
19
|
TRUST_LEVELS,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as InspectedApp, Q as InspectedStructure, Z as LocateTarget, aj as User, D as DatasetDescriptor } from './types-
|
|
2
|
-
import { d as MenuTargetKind, c as MenuTarget, e as PluginInfo, h as Theme } from './menu-
|
|
1
|
+
import { L as InspectedApp, Q as InspectedStructure, Z as LocateTarget, aj as User, D as DatasetDescriptor } from './types-CKytl8ds.js';
|
|
2
|
+
import { d as MenuTargetKind, c as MenuTarget, e as PluginInfo, h as Theme } from './menu-BFLb7dVq.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The panel: one per mounted Data App, the host's devtools over it. The runtime owns its state (open
|
package/dist/plugins.d.ts
CHANGED
package/dist/plugins.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PLUGIN_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PYAVAIAX.js";
|
|
4
4
|
import {
|
|
5
5
|
dropState as dropState2,
|
|
6
6
|
stateOf as stateOf2
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
definePlugin
|
|
10
10
|
} from "./chunk-7K6Z63QO.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-GIHCQT6L.js";
|
|
12
12
|
import {
|
|
13
13
|
ValidationError
|
|
14
14
|
} from "./chunk-KCTLO3CO.js";
|
|
@@ -245,7 +245,7 @@ function inspectPlugin() {
|
|
|
245
245
|
run: { tab: OVERVIEW_TAB }
|
|
246
246
|
}],
|
|
247
247
|
tabs: [
|
|
248
|
-
tab("overview", "Overview", "overview", 10, () => import("./overview-
|
|
248
|
+
tab("overview", "Overview", "overview", 10, () => import("./overview-L4KLGZNP.js")),
|
|
249
249
|
tab("data", "Data", "table", 20, () => import("./data-BGX3V42T.js")),
|
|
250
250
|
tab("queries", "Queries", "query", 30, () => import("./queries-QFN4DI25.js")),
|
|
251
251
|
tab("structure", "Structure", "tree", 40, () => import("./structure-Z2QK5MGH.js"), "pick"),
|
package/dist/testing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bootstrap
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YB7VYY72.js";
|
|
4
4
|
import "./chunk-XIUFHRZE.js";
|
|
5
5
|
import {
|
|
6
6
|
createEndpoint
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
PROVISION_ELEMENT_ID
|
|
10
10
|
} from "./chunk-RXPNL7UR.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-GIHCQT6L.js";
|
|
12
12
|
import "./chunk-KCTLO3CO.js";
|
|
13
13
|
import "./chunk-PKBMQBKP.js";
|
|
14
14
|
|
|
@@ -204,7 +204,7 @@ interface paths {
|
|
|
204
204
|
};
|
|
205
205
|
get?: never;
|
|
206
206
|
put?: never;
|
|
207
|
-
/** Print the anfra version */
|
|
207
|
+
/** Print the anfra version, and say when anfra or the anfra skills are behind */
|
|
208
208
|
post: operations["core.version"];
|
|
209
209
|
delete?: never;
|
|
210
210
|
options?: never;
|
|
@@ -871,6 +871,11 @@ interface components {
|
|
|
871
871
|
"canal-query": string;
|
|
872
872
|
node: string;
|
|
873
873
|
};
|
|
874
|
+
SkillsResult: {
|
|
875
|
+
checked?: string;
|
|
876
|
+
latest?: string;
|
|
877
|
+
version?: string;
|
|
878
|
+
};
|
|
874
879
|
StatusResult: {
|
|
875
880
|
server?: components["schemas"]["ServerInfo"];
|
|
876
881
|
sidecars?: components["schemas"]["SidecarHealth"];
|
|
@@ -939,7 +944,7 @@ interface components {
|
|
|
939
944
|
latest: string;
|
|
940
945
|
};
|
|
941
946
|
ValidateInput: {
|
|
942
|
-
/** @description optional file globs; report only diagnostics for matching files */
|
|
947
|
+
/** @description optional file globs, at most 100; report only diagnostics for matching files */
|
|
943
948
|
globs?: string[];
|
|
944
949
|
};
|
|
945
950
|
ValidationReport: {
|
|
@@ -952,7 +957,13 @@ interface components {
|
|
|
952
957
|
type: string;
|
|
953
958
|
validator: string;
|
|
954
959
|
};
|
|
960
|
+
VersionInput: {
|
|
961
|
+
/** @description the version of the anfra skills in use, from the line ending each skill (anfra skills <version>), or unknown when a skill has no such line; adds the latest skills version to the answer */
|
|
962
|
+
skills?: string;
|
|
963
|
+
};
|
|
955
964
|
VersionResult: {
|
|
965
|
+
hints?: string[];
|
|
966
|
+
skills?: components["schemas"]["SkillsResult"];
|
|
956
967
|
update?: components["schemas"]["UpdateInfo"];
|
|
957
968
|
version: string;
|
|
958
969
|
};
|
|
@@ -1664,7 +1675,7 @@ interface operations {
|
|
|
1664
1675
|
};
|
|
1665
1676
|
requestBody: {
|
|
1666
1677
|
content: {
|
|
1667
|
-
"application/json": components["schemas"]["
|
|
1678
|
+
"application/json": components["schemas"]["VersionInput"];
|
|
1668
1679
|
};
|
|
1669
1680
|
};
|
|
1670
1681
|
responses: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holistics/anfra-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Data Apps on anfra: the authoring layer (app), what hosts one (host), anfra's plugins (plugins), the core API client (api), and their shared contract (common)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|