@platforma-sdk/model 1.33.17 → 1.34.8
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/components/PFrameForGraphs.d.ts +12 -0
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +9 -7
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +216 -220
- package/dist/index.mjs.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/PFrameForGraphs.ts +12 -0
- package/src/components/PlMultiSequenceAlignment.ts +34 -49
|
@@ -10,5 +10,17 @@ export declare function getLinkerColumnsMap(linkerColumns: PColumn<PColumnDataUn
|
|
|
10
10
|
export declare function getAvailableWithLinkersAxes(linkerColumns: PColumn<PColumnDataUniversal>[], blockAxes: Map<CanonicalizedJson<AxisId>, AxisId>): Map<CanonicalizedJson<AxisId>, AxisId>;
|
|
11
11
|
/** Add columns with fully compatible axes created from partial compatible ones */
|
|
12
12
|
export declare function enrichCompatible(blockAxes: Map<string, AxisId>, columns: PColumn<PColumnDataUniversal>[]): PColumn<PColumnDataUniversal>[];
|
|
13
|
+
/**
|
|
14
|
+
The aim of createPFrameForGraphs: to create pframe with block’s columns and all compatible columns from result pool
|
|
15
|
+
(including linker columns and all label columns).
|
|
16
|
+
Block’s columns are added to pframe as is.
|
|
17
|
+
Other columns are added basing on set of axes of block’s columns, considering available with linker columns.
|
|
18
|
+
Compatible columns must have at least one axis from block’s axes set. This axis of the compatible column from
|
|
19
|
+
result pool must satisfy matchAxisId (it can have less domain keys than in block’s axis, but without conflicting values
|
|
20
|
+
among existing ones).
|
|
21
|
+
In requests to pframe (calculateTableData) columns must have strictly the same axes. For compatibility in case
|
|
22
|
+
of partially matched axis we add to pframe a copy of this column with modified axis (with filled missed domains)
|
|
23
|
+
and modified label (with added domain values in case if more than one copy with different domains exist).
|
|
24
|
+
*/
|
|
13
25
|
export declare function createPFrameForGraphs<A, U>(ctx: RenderCtx<A, U>, blockColumns: PColumn<PColumnDataUniversal>[] | undefined): PFrameHandle | undefined;
|
|
14
26
|
//# sourceMappingURL=PFrameForGraphs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PFrameForGraphs.d.ts","sourceRoot":"","sources":["../../src/components/PFrameForGraphs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,YAAY,EAEb,MAAM,iCAAiC,CAAC;AAMzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAkCjE,yCAAyC;AACzC,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,WAEjD;AAED,eAAO,MAAM,iBAAiB,4BAA4B,CAAC;AAC3D,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAChD,eAAO,MAAM,wBAAwB,2BAA2B,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC9F,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,oBAmBjF;AAED,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,EAC9C,SAAS,EAAE,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAChD,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CA4BxC;AACD,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,mCAMxG;AAwFD,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,CAAC,EACxC,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,YAAY,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,GAAG,SAAS,GACxD,YAAY,GAAG,SAAS,CAiE1B"}
|
|
1
|
+
{"version":3,"file":"PFrameForGraphs.d.ts","sourceRoot":"","sources":["../../src/components/PFrameForGraphs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,YAAY,EAEb,MAAM,iCAAiC,CAAC;AAMzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAkCjE,yCAAyC;AACzC,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,WAEjD;AAED,eAAO,MAAM,iBAAiB,4BAA4B,CAAC;AAC3D,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAChD,eAAO,MAAM,wBAAwB,2BAA2B,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC9F,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,oBAmBjF;AAED,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,EAC9C,SAAS,EAAE,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,GAChD,GAAG,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CA4BxC;AACD,kFAAkF;AAClF,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,mCAMxG;AAwFD;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,CAAC,EACxC,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACpB,YAAY,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,GAAG,SAAS,GACxD,YAAY,GAAG,SAAS,CAiE1B"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PColumn, PColumnIdAndSpec, PColumnValues, PObjectId, PTableColumnId } from '@milaboratories/pl-model-common';
|
|
2
2
|
import { PlSelectionModel } from './PlSelectionModel';
|
|
3
|
-
/** Canonicalized PTableColumnId JSON string */
|
|
4
|
-
export type PTableColumnIdJson = CanonicalizedJson<PTableColumnId>;
|
|
5
|
-
/** Encode `PTableColumnId` as canonicalized JSON string */
|
|
6
|
-
export declare function stringifyPTableColumnId(id: PTableColumnId): PTableColumnIdJson;
|
|
7
3
|
export type PColumnPredicate = (column: PColumnIdAndSpec) => boolean;
|
|
8
4
|
export type PlMultiSequenceAlignmentModel = {
|
|
5
|
+
version?: number;
|
|
9
6
|
sequenceColumnIds?: PObjectId[];
|
|
10
|
-
labelColumnIds?:
|
|
7
|
+
labelColumnIds?: PTableColumnId[];
|
|
11
8
|
};
|
|
12
|
-
export declare function createRowSelectionColumn(
|
|
9
|
+
export declare function createRowSelectionColumn({ selection, columnId, label, domain, }: {
|
|
10
|
+
selection: PlSelectionModel | undefined;
|
|
11
|
+
columnId?: PObjectId;
|
|
12
|
+
label?: string;
|
|
13
|
+
domain?: Record<string, string>;
|
|
14
|
+
}): PColumn<PColumnValues> | undefined;
|
|
13
15
|
//# sourceMappingURL=PlMultiSequenceAlignment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlMultiSequenceAlignment.d.ts","sourceRoot":"","sources":["../../src/components/PlMultiSequenceAlignment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"PlMultiSequenceAlignment.d.ts","sourceRoot":"","sources":["../../src/components/PlMultiSequenceAlignment.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,gBAAgB,EAErB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,cAAc,EAEpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,OAAO,CAAC;AAErE,MAAM,MAAM,6BAA6B,GAAG;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC;IAChC,cAAc,CAAC,EAAE,cAAc,EAAE,CAAC;CACnC,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,QAA8C,EAC9C,KAA0B,EAC1B,MAAM,GACP,EAAE;IACD,SAAS,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS,CAyBrC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var it=Object.defineProperty;var st=(t,e,n)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var D=(t,e,n)=>st(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@milaboratories/pl-model-common"),xe=require("canonicalize"),M=require("zod"),Ae=require("@milaboratories/pl-error-like");class Ie extends Error{constructor(e,n){super(`${e.length}${n?"+":""} errors, first error: `+e[0].message),this.errors=e,this.moreErrors=n}}function Se(t){if(!t.ok)throw new Ie(t.errors,t.moreErrors);return t.value}function ot(t){return new Proxy(t,{get(e,n){return Se(e[n])}})}function x(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null?Y(t):t}function W(t){return{type:"GetFromCtx",variable:t}}function at(t){return{type:"Isolate",cfg:t}}const lt=W("$args"),ut=W("$it"),ct=W("$prod"),dt=W("$staging"),pt=W("$ui");function Y(t){return{type:"Immediate",value:t}}function ge(t){const e={};for(const[n,r]of Object.entries(t))e[n]=x(r);return{type:"MakeObject",template:e}}function ft(...t){const e=[];for(const n of t)e.push(x(n));return{type:"MakeArray",template:e}}function Q(t,e){return{type:"GetJsonField",source:x(t),field:x(e)}}function ht(t,e,n="$it"){return{type:"MapRecordValues",source:t,mapping:e,itVar:n}}function gt(t,e,n="$it"){return{type:"MapArrayValues",source:t,mapping:e,itVar:n}}function mt(t){return{type:"Flatten",source:t}}function yt(t){return{type:"IsEmpty",arg:t}}function bt(t){return{type:"Not",operand:t}}function vt(t,e){return{type:"And",operand1:t,operand2:e}}function At(t,e){return{type:"Or",operand1:t,operand2:e}}function Pt(t,e){return{type:"GetResourceField",source:x(t),field:x(e)}}function Ct(){return function(t){return{type:"GetResourceValueAsJson",source:x(t)}}}function wt(t,e,n="$it"){return{type:"MapResourceFields",source:t,mapping:e,itVar:n}}function xt(t,e){return{type:"GetBlobContent",range:e,source:x(t)}}function It(t,e){return{type:"GetBlobContentAsString",range:e,source:x(t)}}function St(){return function(t,e){return{type:"GetBlobContentAsJson",range:e,source:x(t)}}}function Tt(t){return{type:"GetDownloadedBlobContent",source:x(t)}}function _t(t){return{type:"GetOnDemandBlobContent",source:x(t)}}function Lt(t,e){return{type:"ExtractArchiveAndGetURL",format:e,source:x(t)}}function Et(t){return{type:"GetImportProgress",source:x(t)}}function Ot(t,e){return{type:"GetLastLogs",source:x(t),lines:e}}function Rt(t,e){return{type:"GetProgressLog",source:x(t),patternToSearch:e}}function Dt(t,e){return{type:"GetProgressLogWithInfo",source:x(t),patternToSearch:e}}function kt(t){return{type:"GetLogHandle",source:x(t)}}function Ft(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function Te(t){if(t&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(t);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function Nt(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function y(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function H(t,e){const n=Nt();if(n===void 0)return!1;if(t in n.callbackRegistry)throw new Error(`Callback with key ${t} already registered.`);return n.callbackRegistry[t]=e,!0}const ce=new Map;function jt(t,e){t in y().callbackRegistry||(y().callbackRegistry[t]=n=>{for(const r of ce.get(t))r(n)},ce.set(t,[])),ce.get(t).push(e)}class S{constructor(e,n=r=>r){D(this,"isResolved",!1);D(this,"resolvedValue");this.handle=e,this.postProcess=n,jt(e,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(e){return new S(this.handle,n=>e(this.postProcess(n)))}mapDefined(e){return new S(this.handle,n=>{const r=this.postProcess(n);return r?e(r):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function oe(t,e){return t===void 0?void 0:e(t)}class L{constructor(e,n){this.handle=e,this.resolvePath=n}resolve(...e){const n=e.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveOutput(...e){const n=e.map(r=>({assertFieldType:"Output",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveInput(...e){const n=e.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveAny(...e){return this.resolveWithCommon({},...e)}resolveWithCommon(e,...n){const r=[...this.resolvePath,...n.map(i=>typeof i=="string"?i:i.field)];return oe(y().resolveWithCommon(this.handle,e,...n),i=>new L(i,r))}get resourceType(){return y().getResourceType(this.handle)}getInputsLocked(){return y().getInputsLocked(this.handle)}getOutputsLocked(){return y().getOutputsLocked(this.handle)}getIsReadyOrError(){return y().getIsReadyOrError(this.handle)}getIsFinal(){return y().getIsFinal(this.handle)}getError(){const e=[...this.resolvePath,"error"];return oe(y().getError(this.handle),n=>new L(n,e))}listInputFields(){return y().listInputFields(this.handle)}listOutputFields(){return y().listOutputFields(this.handle)}listDynamicFields(){return y().listDynamicFields(this.handle)}getKeyValueBase64(e){return y().getKeyValueBase64(this.handle,e)}getKeyValueAsString(e){return y().getKeyValueAsString(this.handle,e)}getKeyValueAsJson(e){const n=this.getKeyValueAsString(e);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return y().getDataBase64(this.handle)}getDataAsString(){return y().getDataAsString(this.handle)}getDataAsJson(){const e=this.getDataAsString();if(e==null)throw new Error("Resource has no content.");return JSON.parse(e)}getPColumns(e=!1,n=""){const r=this.parsePObjectCollection(e,n);return r===void 0?void 0:Object.entries(r).map(([,s])=>{if(!c.isPColumn(s))throw new Error(`not a PColumn (kind = ${s.spec.kind})`);return s})}parsePObjectCollection(e=!1,n=""){const r=y().parsePObjectCollection(this.handle,e,n,...this.resolvePath);if(r===void 0)return;const i={};for(const[s,o]of Object.entries(r)){const a=[...this.resolvePath,s];i[s]=c.mapPObjectData(o,l=>new L(l,a))}return i}getFileContentAsBase64(e){return new S(y().getBlobContentAsBase64(this.handle,e))}getFileContentAsString(e){return new S(y().getBlobContentAsString(this.handle,e))}getFileContentAsJson(e){return new S(y().getBlobContentAsString(this.handle,e)).mapDefined(n=>JSON.parse(n))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new S(y().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new S(y().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}extractArchiveAndGetURL(e){return new S(y().extractArchiveAndGetURL(this.handle,e))}getImportProgress(){return new S(y().getImportProgress(this.handle))}getLastLogs(e){return new S(y().getLastLogs(this.handle,e))}getProgressLog(e){return new S(y().getProgressLog(this.handle,e))}getProgressLogWithInfo(e){return new S(y().getProgressLogWithInfo(this.handle,e))}getLogHandle(){return new S(y().getLogHandle(this.handle))}allFieldsResolved(e="Input"){switch(e){case"Input":return this.getInputsLocked()&&this.listInputFields().every(n=>this.resolve({field:n,assertFieldType:"Input"})!==void 0);case"Output":return this.getOutputsLocked()&&this.listOutputFields().every(n=>this.resolve({field:n,assertFieldType:"Output"})!==void 0)}}mapFields(e,n){const{fieldType:r,requireLocked:i,skipUnresolved:s}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},o=e;if(i&&(r==="Input"&&!this.getInputsLocked()||r==="Output"&&!this.getOutputsLocked()))return;let l=(r==="Input"?this.listInputFields():r==="Output"?this.listOutputFields():this.listDynamicFields()).map(u=>[u,this.resolve({field:u,assertFieldType:r})]);return s&&(l=l.filter(u=>u[1]!==void 0)),l.map(([u,d])=>o(u,d))}}const _e="staging",Le="main",Vt={explicitColumnsSupport:!0,inlineColumnsSupport:!0,activeArgs:!0};function Ee(t){return typeof t=="object"&&t!==null&&"__awaited_futures__"in t}function pe(t,e,n){if(e.has(n))return;if(e.add(n),typeof n==="object")if(Ee(n))n.__awaited_futures__.forEach(i=>t.add(i));else if(Array.isArray(n))for(const i of n)pe(t,e,i);else for(const[,i]of Object.entries(n))i!==n&&pe(t,e,i)}function Kt(t){const e=new Set;return pe(e,new Set,t),e}const Jt=Object.freeze(Object.defineProperty({__proto__:null,GlobalCfgRenderCtxFeatureFlags:Vt,MainAccessorName:Le,StagingAccessorName:_e,getAllFutureAwaits:Kt,isFutureAwait:Ee},Symbol.toStringTag,{value:"Module"})),Oe="pl7.app/label",Re="pl7.app/trace",De=M.z.object({type:M.z.string(),importance:M.z.number().optional(),id:M.z.string().optional(),label:M.z.string()}),ke=M.z.array(De),$t=.001,Mt="__LABEL__",Pe="__LABEL__@1";function me(t,e,n={}){const r=new Map,i=n.forceTraceElements!==void 0&&n.forceTraceElements.length>0?new Set(n.forceTraceElements):void 0,s=new Map,o=t.map(h=>{var I,k;const P=e(h);let f,m,A;"spec"in P&&typeof P.spec=="object"?(f=P.spec,m=P.prefixTrace,A=P.suffixTrace):f=P;const g=(I=f.annotations)==null?void 0:I[Oe],E=(k=f.annotations)==null?void 0:k[Re],w=(E?ke.safeParse(JSON.parse(E)).data:void 0)??[],v=[...m??[],...w,...A??[]];if(g!==void 0){const R={label:g,type:Mt,importance:-2};n.addLabelAsSuffix?v.push(R):v.splice(0,0,R)}const C=[],O=new Map;for(let R=v.length-1;R>=0;--R){const{type:z}=v[R],N=v[R].importance??0,K=(O.get(z)??0)+1;O.set(z,K);const F=`${z}@${K}`;s.set(F,(s.get(F)??0)+1),r.set(F,Math.max(r.get(F)??Number.NEGATIVE_INFINITY,N-(v.length-R)*$t)),C.push({...v[R],fullType:F,occurrenceIndex:K})}return C.reverse(),{value:h,spec:f,label:g,fullTrace:C}}),a=[],l=[],u=[...r];u.sort(([,h],[,P])=>P-h);for(const[h]of u)h.endsWith("@1")||s.get(h)===t.length?a.push(h):l.push(h);const d=(h,P=!1)=>{const f=[];for(let m=0;m<o.length;m++){const A=o[m],g=A.fullTrace.filter(v=>h.has(v.fullType)||i&&i.has(v.type));if(g.length===0)if(P)f.push({label:"Unlabeled",value:A.value});else return;const E=g.map(v=>v.label),w=n.separator??" / ";f.push({label:E.join(w),value:A.value})}return f};if(a.length===0){if(l.length!==0)throw new Error("Non-empty secondary types list while main types list is empty.");return d(new Set(Pe),!0)}let p=0,b=-1;for(;p<a.length;){const h=new Set;n.includeNativeLabel&&h.add(Pe);for(let f=0;f<p;++f)h.add(a[f]);b>=0&&h.add(a[b]);const P=d(h);if(P!==void 0&&new Set(P.map(f=>f.label)).size===t.length)return P;b++,b>=a.length&&(p++,b=p)}return d(new Set([...a,...l]),!0)}const re="PColumnData/",Z=re+"ResourceMap",ee=re+"Partitioned/ResourceMap",U=re+"JsonPartitioned",V=re+"BinaryPartitioned",Fe=re+"Partitioned/",te=Fe+"JsonPartitioned",B=Fe+"BinaryPartitioned";function Ne(t,e,n,r=[],i){if(t===void 0)return!1;switch(t.resourceType.name){case Z:{let s=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"}),l=[...r,...JSON.parse(o)],u=a===void 0?void 0:e(a);u===void 0&&(s=!1),(u!==void 0||i)&&n.push({key:l,value:u})}return s}case ee:{let s=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"});if(a===void 0)s=!1;else{const l=[...r,...JSON.parse(o)],u=Ne(a,e,n,l,i);s=s&&u}}return s}default:throw new Error(`Unknown resource type: ${t.resourceType.name}`)}}function Ut(t,e,n=!1){const r=[];return{isComplete:Ne(t,e,r,[],n),data:r}}const fe=t=>{if(t.endsWith(".index"))return{baseKey:t.substring(0,t.length-6),type:"index"};if(t.endsWith(".values"))return{baseKey:t.substring(0,t.length-7),type:"values"};throw new Error(`key must ends on .index/.values for binary p-column, got: ${t}`)};function je(t){if(!t)return;const e=t.resourceType.name,n=t.getDataAsJson(),r=[];let i=0;switch(e){case Z:i=n.keyLength;break;case ee:i=n.partitionKeyLength+n.keyLength;break;case U:case V:i=n.partitionKeyLength;break;case B:case te:i=n.superPartitionKeyLength+n.partitionKeyLength;break}switch(e){case Z:case U:case V:for(let s of t.listInputFields()){e===V&&(s=fe(s).baseKey);const o=[...JSON.parse(s)];r.push(o)}break;case ee:case B:case te:for(const s of t.listInputFields()){const o=[...JSON.parse(s)],a=t.resolve({field:s,assertFieldType:"Input"});if(a!==void 0)for(let l of a.listInputFields()){e===B&&(l=fe(l).baseKey);const u=[...o,...JSON.parse(l)];r.push(u)}}break}return{data:r,keyLength:i}}function Bt(t){if(t.type!=="JsonPartitioned"&&t.type!=="BinaryPartitioned")throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${t.type}`);const{parts:e,partitionKeyLength:n}=t,r=[];for(let i=0;i<n;++i)r.push(new Set);for(const i of e){const s=i.key;if(s.length!==n)throw new Error(`Key length (${s.length}) does not match partition length (${n}) for key: ${JSON.stringify(s)}`);for(let o=0;o<n;++o)r[o].add(s[o])}return r.map(i=>Array.from(i.values()))}function Ve(t){if(t===void 0)return;if(c.isDataInfoEntries(t))return Bt(t);const e=je(t);if(!e)return;const{data:n,keyLength:r}=e,i=[];for(let s=0;s<r;++s)i.push(new Set);for(const s of n){if(s.length!==r)throw new Error("key length does not match partition length");for(let o=0;o<r;++o)i[o].add(s[o])}return i.map(s=>Array.from(s.values()))}function ae(t,e=[]){if(t===void 0||!t.getIsReadyOrError())return;const n=t.resourceType.name,r=t.getDataAsJson();if(e.length>0&&(n===te||n===B))throw new Error(`Unexpected nested super-partitioned resource: ${n}`);switch(n){case Z:case ee:throw new Error(`Only data columns are supported, got: ${n}`);case U:{if(typeof(r==null?void 0:r.partitionKeyLength)!="number")throw new Error(`Missing partitionKeyLength in metadata for ${n}`);const i=[];for(const s of t.listInputFields()){const o=t.resolve({field:s,assertFieldType:"Input"});if(o===void 0)return;const a=[...e,...JSON.parse(s)];i.push({key:a,value:o})}return{type:"JsonPartitioned",partitionKeyLength:r.partitionKeyLength,parts:i}}case V:{if(typeof(r==null?void 0:r.partitionKeyLength)!="number")throw new Error(`Missing partitionKeyLength in metadata for ${n}`);const i=[],s=new Map;for(const o of t.listInputFields()){const a=fe(o),l=t.resolve({field:o,assertFieldType:"Input"});if(l===void 0)return;let u=s.get(a.baseKey);u||(u={},s.set(a.baseKey,u)),a.type==="index"?u.index=l:u.values=l}for(const[o,a]of s.entries()){if(!a.index||!a.values)return;const l=[...e,...JSON.parse(o)];i.push({key:l,value:{index:a.index,values:a.values}})}return{type:"BinaryPartitioned",partitionKeyLength:r.partitionKeyLength,parts:i}}case te:{if(typeof(r==null?void 0:r.superPartitionKeyLength)!="number"||typeof(r==null?void 0:r.partitionKeyLength)!="number")throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${n}`);const i=r.superPartitionKeyLength+r.partitionKeyLength,s=[];for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"});if(a===void 0)return;if(a.resourceType.name!==U)throw new Error(`Expected ${U} inside ${n}, but got ${a.resourceType.name}`);const l=ae(a,JSON.parse(o));if(l===void 0)return;if(l.type!=="JsonPartitioned")throw new Error(`Unexpected inner result type for ${n}: ${l.type}`);s.push(...l.parts)}return{type:"JsonPartitioned",partitionKeyLength:i,parts:s}}case B:{if(typeof(r==null?void 0:r.superPartitionKeyLength)!="number"||typeof(r==null?void 0:r.partitionKeyLength)!="number")throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${n}`);const i=r.superPartitionKeyLength+r.partitionKeyLength,s=[];for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"});if(a===void 0)return;if(a.resourceType.name!==V)throw new Error(`Expected ${V} inside ${n}, but got ${a.resourceType.name}`);const l=ae(a,JSON.parse(o));if(l===void 0)return;if(l.type!=="BinaryPartitioned")throw new Error(`Unexpected inner result type for ${n}: ${l.type}`);s.push(...l.parts)}return{type:"BinaryPartitioned",partitionKeyLength:i,parts:s}}default:throw new Error(`Unknown resource type: ${n}`)}}function Ke(t){if(t!==void 0){if(c.isDataInfoEntries(t))return t;if(c.isDataInfo(t))return c.dataInfoToEntries(t);if(t instanceof L)return ae(t);throw new Error(`Unexpected input type: ${typeof t}`)}}function Je(t,e){const n=[...e].sort((s,o)=>o[0]-s[0]);if(t.type==="JsonPartitioned"||t.type==="BinaryPartitioned"){const{partitionKeyLength:s}=t;for(const[o]of e)if(o>=s)throw new Error(`Can't filter on non-partitioned axis ${o}. Must be >= ${s}`)}else if(t.type==="Json"){const{keyLength:s}=t;for(const[o]of e)if(o>=s)throw new Error(`Can't filter on non-data axis ${o}. Must be >= ${s}`)}const r=s=>{for(const[o,a]of n)if(s[o]!==a)return!1;return!0},i=s=>{const o=[...s];for(const[a]of n)o.splice(a,1);return o};switch(t.type){case"Json":{const s=t.data.filter(o=>r(o.key)).map(o=>({key:i(o.key),value:o.value}));return{type:"Json",keyLength:t.keyLength-e.length,data:s}}case"JsonPartitioned":{const s=t.parts.filter(o=>r(o.key)).map(o=>({key:i(o.key),value:o.value}));return{type:"JsonPartitioned",partitionKeyLength:t.partitionKeyLength-e.length,parts:s}}case"BinaryPartitioned":{const s=t.parts.filter(o=>r(o.key)).map(o=>({key:i(o.key),value:o.value}));return{type:"BinaryPartitioned",partitionKeyLength:t.partitionKeyLength-e.length,parts:s}}}}function Wt(t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;const e=t[0];return typeof e=="object"&&e!==null&&"key"in e&&"val"in e}class zt{constructor(e){this.columns=e}selectColumns(e){const n=typeof e=="function"?e:c.selectorsToPredicate(e);return this.columns.filter(r=>n(r.spec))}}function Gt(t){if(t)return t.map(e=>({type:`split:${c.canonicalizeAxisId(e.axisId)}`,label:e.label,importance:1e6}))}function Ht(t){if(t)return t.map(e=>[e.axisIdx,e.value])}function qt(t,e){if(!e||e.length===0)return t;const n=[...e].sort((r,i)=>r[0]-i[0]);return xe({id:t,axisFilters:n})}function Ce(t){if(!t||typeof t!="object")return!1;const e=t,n=e.domain&&typeof e.domain=="object"&&Object.values(e.domain).some(i=>typeof i=="object"&&i!==null&&"anchor"in i),r=e.axes&&Array.isArray(e.axes)&&e.axes.some(i=>typeof i=="object"&&i!==null&&"anchor"in i);return!!e.domainAnchor||n||r}function Yt(t){if(typeof t!="object"||!("axes"in t)||t.axes===void 0)return[];const e=t.axes.map((n,r)=>typeof n=="object"&&"split"in n&&n.split===!0?r:-1).filter(n=>n!==-1);if(e.length>0&&t.partialAxesMatch!==void 0)throw new Error("Axis splitting is not supported when `partialAxesMatch` is defined.");return e.sort((n,r)=>n-r),e}class ne{constructor(){D(this,"defaultProviderStore",[]);D(this,"providers",[new zt(this.defaultProviderStore)]);D(this,"axisLabelProviders",[])}addColumnProvider(e){return this.providers.push(e),this}addAxisLabelProvider(e){return this.axisLabelProviders.push(e),this}addColumns(e){return this.defaultProviderStore.push(...e),this}addColumn(e){return this.defaultProviderStore.push(e),this}findLabels(e){for(const n of this.axisLabelProviders){const r=n.findLabels(e);if(r)return r}}getUniversalEntries(e,n){const{anchorCtx:r,labelOps:i,dontWaitAllData:s=!1,overrideLabelAnnotation:o=!1,exclude:a}=n??{},l={...o&&(i==null?void 0:i.includeNativeLabel)!==!1?{includeNativeLabel:!0}:{},...i??{}};let u=()=>!1;if(a){const f=(Array.isArray(a)?a:[a]).map(m=>{if(Ce(m)){if(!r)throw new Error("Anchored selectors in exclude require an AnchoredIdDeriver to be provided in options.");return c.selectorsToPredicate(c.resolveAnchors(r.anchors,m,n))}else return c.selectorsToPredicate(m)});u=m=>f.some(A=>A(m))}const d=typeof e=="function"?[e]:Array.isArray(e)?e:[e],p=[],b=new Set;for(const f of d){const m=Ce(f);let A;if(m){if(!r)throw new Error("Anchored selectors require an AnchoredIdDeriver to be provided in options.");A=c.resolveAnchors(r.anchors,f,n)}else A=f;const g=new Set,E=[];for(const C of this.providers){const O=C.selectColumns(A);for(const I of O){if(u(I.spec))continue;if(g.has(I.id))throw new Error(`Duplicate column id ${I.id} in provider ${C.constructor.name}`);const k=c.deriveNativeId(I.spec);b.has(k)||(g.add(I.id),b.add(k),E.push(I))}}if(E.length===0)continue;const w=Yt(f),v=w.length>0;for(const C of E){if(!c.isPColumnSpec(C.spec))continue;const O=C.spec;if(v){if(Wt(C.data))throw new Error(`Splitting is not supported for PColumns with PColumnValues data format. Column id: ${C.id}`);const I=Ke(C.data);if(!I){if(s)continue;return}if(!c.isPartitionedDataInfoEntries(I))throw new Error(`Splitting requires Partitioned DataInfoEntries, but parsing resulted in ${I.type} for column ${C.id}`);const k=Ve(I),R=w[w.length-1];if(R>=I.partitionKeyLength)throw new Error(`Not enough partition keys (${I.partitionKeyLength}) for requested split axes (max index ${R}) in column ${O.name}`);const z=w.map(T=>this.findLabels(c.getAxisId(O.axesSpec[T]))),N=[],K=(T,G)=>{if(G>=w.length){if(N.push([...T]),N.length>1e4)throw new Error("Too many key combinations, aborting.");return}const j=w[G];if(j>=k.length)throw new Error(`Axis index ${j} out of bounds for unique keys array (length ${k.length}) during split key generation for column ${C.id}`);const J=k[j];if(!J||J.length===0){N.length=0;return}for(const ie of J)T.push(ie),K(T,G+1),T.pop()};if(K([],0),N.length===0)continue;const F=[...O.axesSpec],et=w.map(T=>T);for(let T=w.length-1;T>=0;T--)F.splice(w[T],1);const tt={...O,axesSpec:F};for(const T of N){const G=T.map((j,J)=>{const ie=et[J],nt=c.getAxisId(O.axesSpec[ie]),ue=z[J],rt=(ue==null?void 0:ue[j])??String(j);return{axisIdx:ie,axisId:nt,value:j,label:rt}});p.push({type:"split",originalColumn:C,spec:O,adjustedSpec:tt,dataEntries:I,axisFilters:G})}}else p.push({type:"direct",originalColumn:C,spec:O,adjustedSpec:O})}}if(p.length===0)return[];const h=me(p,f=>({spec:f.spec,suffixTrace:f.type==="split"?Gt(f.axisFilters):void 0}),l),P=[];for(const{value:f,label:m}of h){const{originalColumn:A,spec:g}=f,E=f.type==="split"?f.axisFilters:void 0,w=Ht(E);let v;r?v=r.deriveS(g,w):v=qt(A.id,w);let C={...f.adjustedSpec};o&&(C={...C,annotations:{...C.annotations??{},"pl7.app/label":m}}),P.push({id:v,spec:C,data:()=>f.type==="split"?c.entriesToDataInfo(Je(f.dataEntries,w)):f.originalColumn.data,label:m})}return P}getColumns(e,n){const r=this.getUniversalEntries(e,{overrideLabelAnnotation:!0,...n??{}});if(!r)return;const i=[];for(const s of r){const o=s.data();if(!o){if(n!=null&&n.dontWaitAllData)continue;return}i.push({id:s.id,spec:s.spec,data:o})}return i}}function de(t,e){if(t===void 0)return e===void 0;if(e===void 0)return!0;for(const n in e)if(t[n]!==e[n])return!1;return!0}function we(t){return c.mapPObjectData(t,e=>e instanceof L?e.handle:c.isDataInfo(e)?c.mapDataInfo(e,n=>n.handle):e)}class $e{constructor(){D(this,"ctx",y())}calculateOptions(e){return this.ctx.calculateOptions(e)}getOptions(e,n){const r=typeof e=="function"?e:c.selectorsToPredicate(e),i=this.getSpecs().entries.filter(a=>r(a.obj));let s={},o=!1;return typeof n<"u"&&(typeof n=="function"?s=n:typeof n=="object"&&("includeNativeLabel"in n||"separator"in n||"addLabelAsSuffix"in n?s=n:(n=n,s=n.label??{},o=n.refsWithEnrichments??!1))),typeof s=="object"?me(i,a=>a.obj,s??{}).map(({value:{ref:a},label:l})=>({ref:c.withEnrichments(a,o),label:l})):i.map(({ref:a,obj:l})=>({ref:c.withEnrichments(a,o),label:s(l,a)}))}resolveAnchorCtx(e){if(e instanceof c.AnchoredIdDeriver)return e;const n={};for(const[r,i]of Object.entries(e))if(c.isPlRef(i)){const s=this.getPColumnSpecByRef(i);if(!s)return;n[r]=s}else n[r]=i;return new c.AnchoredIdDeriver(n)}getAnchoredPColumns(e,n,r){const i=this.resolveAnchorCtx(e);if(i)return new ne().addColumnProvider(this).addAxisLabelProvider(this).getColumns(n,{...r,anchorCtx:i})}getCanonicalOptions(e,n,r){const i=this.resolveAnchorCtx(e);if(!i)return;const s=new ne().addColumnProvider(this).addAxisLabelProvider(this).getUniversalEntries(n,{...r,anchorCtx:i});if(s)return s.map(o=>({value:o.id,label:o.label}))}getDataFromResultPool(){return this.getData()}getData(){const e=this.ctx.getDataFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new L(n.obj.data,[n.ref.blockId,n.ref.name])}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const e=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:c.mapValueInVOE(n.obj.data,r=>new L(r,[n.ref.blockId,n.ref.name]))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(e){var r;if(typeof this.ctx.getDataFromResultPoolByRef>"u")return(r=this.getData().entries.find(i=>i.ref.blockId===e.blockId&&i.ref.name===e.name))==null?void 0:r.obj;const n=this.ctx.getDataFromResultPoolByRef(e.blockId,e.name);if(n)return c.mapPObjectData(n,i=>new L(i,[e.blockId,e.name]))}getPColumnByRef(e){const n=this.getDataByRef(e);if(n)return c.ensurePColumn(n)}getPColumnSpecByRef(e){const n=this.getSpecByRef(e);if(n){if(!c.isPColumnSpec(n))throw new Error(`not a PColumn spec (kind = ${n.kind})`);return n}}getSpecByRef(e){return this.ctx.getSpecFromResultPoolByRef(e.blockId,e.name)}findDataWithCompatibleSpec(e){const n=[];e:for(const r of this.getData().entries){if(!c.isPColumnSpec(r.obj.spec))continue;const i=r.obj.spec;if(e.name===i.name&&e.valueType===i.valueType&&e.axesSpec.length===i.axesSpec.length&&de(e.domain,i.domain)){for(let s=0;s<e.axesSpec.length;++s){const o=e.axesSpec[s],a=i.axesSpec[s];if(o.name!==a.name||o.type!==a.type||!de(o.domain,a.domain))continue e}n.push(r.obj)}}return n}findLabels(e){const n=this.getData();for(const r of n.entries){if(!c.isPColumn(r.obj))continue;const i=r.obj.spec;if(i.name==="pl7.app/label"&&i.axesSpec.length===1&&i.axesSpec[0].name===e.name&&i.axesSpec[0].type===e.type&&de(e.domain,i.axesSpec[0].domain)){if(r.obj.data.resourceType.name!=="PColumnData/Json")throw Error(`Expected JSON column for labels, got: ${r.obj.data.resourceType.name}`);return Object.fromEntries(Object.entries(r.obj.data.getDataAsJson().data).map(o=>[JSON.parse(o[0])[0],o[1]]))}}}selectColumns(e){const n=typeof e=="function"?e:c.selectorsToPredicate(e);return this.getSpecs().entries.filter(({obj:i})=>c.isPColumnSpec(i)?n(i):!1).map(({ref:i,obj:s})=>{const o=s;let a=null;const l=this;return{id:xe(i),spec:o,get data(){var u;return a!==null||(a=(u=l.getPColumnByRef(i))==null?void 0:u.data),a}}})}findLabelsForColumnAxis(e,n){var s;const r=this.findLabels(e.axesSpec[n]);if(!r)return;const i=(s=e.annotations)==null?void 0:s["pl7.app/axisKeys/"+n];if(i!==void 0){const o=JSON.parse(i);return Object.fromEntries(o.map(a=>[a,r[a]??"Unlabelled"]))}else return r}}class q{constructor(){D(this,"ctx");D(this,"args");D(this,"uiState");D(this,"_activeArgsCache");D(this,"resultPool",new $e);this.ctx=y(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):{}}get activeArgs(){return this._activeArgsCache===void 0&&(this._activeArgsCache={v:this.ctx.activeArgs?JSON.parse(this.ctx.activeArgs):void 0}),this._activeArgsCache.v}getNamedAccessor(e){return oe(this.ctx.getAccessorHandleByName(e),n=>new L(n,[e]))}get prerun(){return this.getNamedAccessor(_e)}get outputs(){return this.getNamedAccessor(Le)}findLabels(e){return this.resultPool.findLabels(e)}verifyInlineAndExplicitColumnsSupport(e){var i;const n=e.some(s=>!(s.data instanceof L)||c.isDataInfo(s.data)),r=((i=this.ctx.featureFlags)==null?void 0:i.inlineColumnsSupport)===!0;if(n&&!r)throw Error("Inline or explicit columns not supported")}createPFrame(e){return this.verifyInlineAndExplicitColumnsSupport(e),this.ctx.createPFrame(e.map(n=>we(n)))}createPTable(e){let n;return"columns"in e?n={src:{type:"full",entries:e.columns.map(r=>({type:"column",column:r}))},filters:e.filters??[],sorting:e.sorting??[]}:n=e,this.verifyInlineAndExplicitColumnsSupport(c.extractAllColumns(n.src)),this.ctx.createPTable(c.mapPTableDef(n,r=>we(r)))}getBlockLabel(e){return this.ctx.getBlockLabel(e)}getCurrentUnstableMarker(){return this.ctx.getCurrentUnstableMarker()}logInfo(e){this.ctx.logInfo(e)}logWarn(e){this.ctx.logWarn(e)}logError(e){this.ctx.logError(e)}}const X="1.33.17";function Me(t){return t.__renderLambda===!0}function se(t){if(t!==void 0)return Me(t)?t.handle:t}function $(t){if(t!==void 0)return typeof t=="string"?{__renderLambda:!0,handle:t,retentive:!1}:t}function Xt(t){if(t.v3!==void 0){const{initialArgs:e,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:o,sections:a,title:l,enrichmentTargets:u}=t.v3,{code:d}=t;return{initialArgs:e,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:o,sections:a,title:l,code:d,enrichmentTargets:u}}else if(t.inputsValid!==void 0){const{sdkVersion:e,renderingMode:n,outputs:r,inputsValid:i,sections:s,initialArgs:o,code:a}=t,l=Object.keys(t);if(e===void 0||n===void 0||r===void 0||i===void 0||s===void 0||o===void 0)throw new Error(`Malformed config v2. SDK version ${e}; Fields = ${l.join(", ")}`);return{sdkVersion:e,renderingMode:n,initialArgs:o,outputs:Object.fromEntries(Object.entries(r).map(([u,d])=>[u,$(d)])),inputsValid:$(i),sections:$(s),initialUiState:void 0,code:a}}else if(t.renderingMode!==void 0){const{sdkVersion:e,canRun:n,renderingMode:r,outputs:i,sections:s,initialArgs:o,code:a}=t,l=Object.keys(t);if(r===void 0||i===void 0||n===void 0||s===void 0||o===void 0)throw new Error(`Malformed config v1. SDK version ${e}; Fields = ${l.join(", ")}`);return{sdkVersion:e??"unknown",renderingMode:r,initialArgs:o,outputs:Object.fromEntries(Object.entries(i).map(([u,d])=>[u,$(d)])),inputsValid:$(n),sections:$(s),initialUiState:void 0,code:a}}else{const{sdkVersion:e}=t,n=Object.keys(t);throw new Error(`Config format not supported: SDK = ${e}; Fields = ${n.join(", ")}`)}}class _{constructor(e,n,r,i,s,o,a,l){this._renderingMode=e,this._initialArgs=n,this._initialUiState=r,this._outputs=i,this._inputsValid=s,this._sections=o,this._title=a,this._enrichmentTargets=l}static create(e="Heavy"){return new _(e,void 0,{},{},Y(!0),Y([]),void 0,void 0)}output(e,n,r={}){if(typeof n=="function"){const i=`output#${e}`;return H(i,()=>n(new q)),new _(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:{__renderLambda:!0,handle:i,...r}},this._inputsValid,this._sections,this._title,this._enrichmentTargets)}else return new _(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:n},this._inputsValid,this._sections,this._title,this._enrichmentTargets)}retentiveOutput(e,n){return this.output(e,n,{retentive:!0})}argsValid(e){return typeof e=="function"?(H("inputsValid",()=>e(new q)),new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title,this._enrichmentTargets)):new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,e,this._sections,this._title,this._enrichmentTargets)}sections(e){return Array.isArray(e)?this.sections(Y(e)):typeof e=="function"?(H("sections",()=>e(new q)),new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title,this._enrichmentTargets)):new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,e,this._title,this._enrichmentTargets)}title(e){return H("title",()=>e(new q)),new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"},this._enrichmentTargets)}initialArgs(e){return new _(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}withArgs(e){return new _(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}withUiState(e){return new _(this._renderingMode,this._initialArgs,e,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}enriches(e){return H("enrichmentTargets",e),new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,{__renderLambda:!0,handle:"enrichmentTargets"})}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const e={v3:{sdkVersion:X,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs,enrichmentTargets:this._enrichmentTargets},sdkVersion:X,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:se(this._inputsValid),sections:se(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,se(r)]))};return Ft()?Te({sdkVersion:X}):{config:e}}}function Qt(t){const e=t.type;switch(e){case"axis":return c.canonicalizeJson(t);case"column":return c.canonicalizeJson(t);default:throw Error(`unsupported column type: ${e}`)}}function le(t){return t.axesSpec.length===1&&t.name==="pl7.app/label"}function ye(t){return new ne().addAxisLabelProvider(t).addColumnProvider(t).getColumns({name:"pl7.app/label",axes:[{}]},{dontWaitAllData:!0})}function be(t,e){const n=[],r=[];for(const a of t)le(a.spec)?n.push(a):r.push(a);const i=[];for(const a of r)for(const l of a.spec.axesSpec){const u=c.getAxisId(l);i.some(d=>c.matchAxisId(d,u))||i.push(u)}for(const a of n){const l=c.getAxisId(a.spec.axesSpec[0]),u=i.findIndex(d=>c.matchAxisId(d,l));u!==-1&&i.splice(u,1)}const s=(a,l)=>{let u=a.toString();if(l)for(const d in l)u+=d,u+=l[d];return u},o=[];for(const a of e){const l=a.spec.axesSpec[0],u=c.getAxisId(l),d=i.findIndex(p=>c.matchAxisId(p,u));if(d!==-1){const p=i[d],b=Object.keys(p.domain??{}).length,h=Object.keys(l.domain??{}).length;b>h?o.push({id:s(a.id,p.domain),spec:{...a.spec,axesSpec:[{...p,annotations:l.annotations}]},data:a.data}):o.push(a),i.splice(d,1)}}return o}function ve(t){const e=i=>Array.isArray(i),n=i=>i instanceof L,r=i=>typeof i=="object"&&"type"in i;return t.map(i=>i.data).every(i=>{if(e(i))return!0;if(n(i))return i.getIsReadyOrError();if(r(i))switch(i.type){case"Json":return!0;case"JsonPartitioned":return Object.values(i.parts).every(o=>o.getIsReadyOrError());case"BinaryPartitioned":return Object.values(i.parts).every(o=>o.index.getIsReadyOrError()&&o.values.getIsReadyOrError())}else throw Error(`unsupported column data type: ${i}`)})}function Ue(t,e,n,r,i,s){let o=t;const a=[];if(s){o=[];for(const l of t)s(l.spec)?o.push(l):a.push(l)}return a.push(...e),{src:{type:"outer",primary:{type:n,entries:o.map(l=>({type:"column",column:l}))},secondary:a.map(l=>({type:"column",column:l}))},filters:r,sorting:i}}function Zt(t,e,n,r){var u,d;Array.isArray(r)&&(r={filters:r});const i=(r==null?void 0:r.coreJoinType)??"full",s=[...(r==null?void 0:r.filters)??[],...((u=n==null?void 0:n.pTableParams)==null?void 0:u.filters)??[]],o=((d=n==null?void 0:n.pTableParams)==null?void 0:d.sorting)??[],a=ye(t.resultPool);if(!a)return;const l=be(e.map(c.getColumnIdAndSpec),a);if(ve([...e,...l]))return t.createPTable(Ue(e,l,i,s,o,r==null?void 0:r.coreColumnPredicate))}function Be(t){var e;return((e=t.annotations)==null?void 0:e["pl7.app/table/visibility"])==="hidden"}function We(t){var e;return((e=t.annotations)==null?void 0:e["pl7.app/table/visibility"])==="optional"}function en(t,e,n,r,i){var m,A;const s=(i==null?void 0:i.coreJoinType)??"full",o=[...(i==null?void 0:i.filters)??[],...((m=r==null?void 0:r.pTableParams)==null?void 0:m.filters)??[]],a=((A=r==null?void 0:r.pTableParams)==null?void 0:A.sorting)??[],l=e.filter(g=>!Be(g.spec)),u=l.find(g=>n(g.spec));if(!u)return;const d=ye(t.resultPool);if(!d)return;const p=new Set((()=>{var E,w;if(s==="inner")return[];const g=(w=(E=r==null?void 0:r.gridState.columnVisibility)==null?void 0:E.hiddenColIds)==null?void 0:w.map(c.parseJson).filter(v=>v.type==="column").map(v=>v.id);return g||l.filter(v=>We(v.spec)).map(v=>v.id)})());p.delete(u.id),[...o.map(g=>g.column),...a.map(g=>g.column)].filter(g=>g.type==="column").map(g=>p.delete(g.id));const b=l.filter(g=>!p.has(g.id)),h=be(b.map(c.getColumnIdAndSpec),d),P=[...u.spec.axesSpec.map(g=>({type:"axis",id:c.getAxisId(g),spec:g})),...[...l,...h].map(g=>({type:"column",id:g.id,spec:g.spec}))];if(!ve([...b,...h]))return;const f=t.createPTable(Ue(l,h,s,o,a,i==null?void 0:i.coreColumnPredicate));return{tableSpec:P,tableHandle:f}}function tn(t,e,n){const r=t.resultPool.findLabels(e);return{axis:e,options:n.map(i=>({value:i,label:(r==null?void 0:r[i])??i.toString()})),defaultValue:n[0]}}const nn=(t,e)=>{let n=t.toString();return e==null||e.forEach(r=>{if(r)for(const[i,s]of Object.entries(r))n+=i,n+=s}),n};function rn(t){if(!t.length)return[];let e=[[]];return t.forEach(n=>{const r=[];n.forEach(i=>{r.push(...e.map(s=>[...s,i]))}),e=r}),e}function ze(t){var e;return t.axesSpec.length===2&&((e=t.annotations)==null?void 0:e[He])==="true"}const Ge="pl7.app/graph/isVirtual",he="pl7.app/label",He="pl7.app/isLinkerColumn";function qe(t){var n,r;const e=new Map;for(const{spec:i}of t){const s=i.axesSpec.map(c.getAxisId).map(c.canonicalizeJson);s.forEach(o=>{e.has(o)||e.set(o,new Set)});for(let o=0;o<s.length-1;o++)for(let a=o+1;a<s.length;a++){const l=s[o],u=s[a];(n=e.get(l))==null||n.add(u),(r=e.get(u))==null||r.add(l)}}return e}function Ye(t,e){const n=qe(t),r=[...n.keys()].map(c.parseJson),i=[];for(const l of e.values()){const u=r.find(d=>c.matchAxisId(l,d));u&&i.push(c.canonicalizeJson(u))}const s=new Set(i),o=new Map;let a=[...i];for(;a.length;){const l=[];for(const u of a)for(const d of n.get(u)??[])s.has(d)||(l.push(d),s.add(d),o.set(d,c.parseJson(d)));a=l}return o}function Xe(t,e){const n=[];return e.forEach(r=>{n.push(...sn(t,r))}),n}function sn(t,e){const n=e.spec.axesSpec.map(c.getAxisId);if(n.every(u=>t.has(c.canonicalizeJson(u))))return[e];const r=n.map(u=>{const d=[];for(const[p,b]of t)c.matchAxisId(b,u)&&!c.matchAxisId(u,b)&&d.push(b);return d}),i=rn(r),s=new Set,o=new Set,a=i.map(u=>{const d=new Set;return u.map((p,b)=>{const h=e.spec.axesSpec[b].domain,P=p.domain;return Object.entries(P??{}).forEach(([f,m])=>{if((h==null?void 0:h[f])===void 0){const A=JSON.stringify([f,m]);d.add(A),s.add(A)}}),{...p,annotations:e.spec.axesSpec[b].annotations}}),d});[...s].forEach(u=>{a.some(d=>!d.has(u))&&o.add(u)});const l=i.map((u,d)=>{var f;const p=nn(e.id,u.map(m=>m.domain)),b=((f=e.spec.annotations)==null?void 0:f[he])??"",h=[...a[d]].filter(m=>o.has(m)).sort().map(m=>{var A;return(A=JSON.parse(m))==null?void 0:A[1]}).join(" / "),P={...e.spec.annotations,[Ge]:"true"};return(b||h)&&(P[he]=b&&h?b+" / "+h:b+h),{id:p,spec:{...e.spec,axesSpec:u.map((m,A)=>({...m,annotations:e.spec.axesSpec[A].annotations})),annotations:P},data:e.data}});return[e,...l]}function on(t,e){if(!e)return;const n=new ne;n.addColumnProvider(t.resultPool),n.addColumns(e);const r=new Map,i=new Map;for(const p of e)for(const b of p.spec.axesSpec){const h=c.getAxisId(b);r.set(c.canonicalizeJson(h),h),i.set(c.canonicalizeJson(h),h)}const s=n.getColumns(p=>ze(p))??[],o=Ye(s,r);for(const p of o)r.set(...p),i.set(...p);const a=(n.getColumns([...r.values()].map(p=>({axes:[p],partialAxesMatch:!0})),{dontWaitAllData:!0,overrideLabelAnnotation:!1})??[]).filter(p=>!le(p.spec));for(const p of a)for(const b of p.spec.axesSpec){const h=c.getAxisId(b);i.set(c.canonicalizeJson(h),h)}const l=(n.getColumns([...i.values()].map(p=>({axes:[p],partialAxesMatch:!0})),{dontWaitAllData:!0,overrideLabelAnnotation:!1})??[]).filter(p=>le(p.spec)),u=[...a,...l],d=Xe(r,u);if(!d.some(p=>p.data instanceof L&&!p.data.getIsReadyOrError()))return t.createPFrame(d)}function an(t){const e=t.type;switch(e){case"axis":return c.canonicalizeJson(t);case"column":return c.canonicalizeJson(t);default:throw Error(`unsupported column type: ${e}`)}}function ln(t,e,n,r){if(!(!e||e.axesSpec.length===0))return{id:t,spec:{kind:"PColumn",valueType:"Int",name:"pl7.app/table/row-selection",axesSpec:e.axesSpec,...r&&{domain:r},annotations:{"pl7.app/label":n??"Selected rows","pl7.app/discreteValues":"[1]"}},data:e.selectedKeys.filter(i=>!i.some(s=>c.isPTableAbsent(s))).map(i=>({key:i,val:1}))}}function un(t){return t===c.PTableNA?(console.error("Axis value can never be N/A"),""):t}class cn{constructor(e){this.handle=e}async findColumns(e){return await platforma.pFrameDriver.findColumns(this.handle,e)}async getColumnSpec(e){return await platforma.pFrameDriver.getColumnSpec(this.handle,e)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(e,n){return await platforma.pFrameDriver.calculateTableData(this.handle,e,n)}async getUniqueValues(e){return await platforma.pFrameDriver.getUniqueValues(this.handle,e)}}function Qe(t){return ge({__isRef:!0,blockId:Q(t,"blockId"),name:Q(t,"name")})}function dn(t){return ge({ref:Qe(Q(t,"ref")),label:Q(t,"label")})}const pn={sdkVersion:X};function Ze(){return Te({sdkVersion:X})}function fn(t){try{return Ze()}catch{return t}}function hn(t){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(t)}exports.Args=lt;exports.BlockModel=_;exports.CurrentSdkInfo=pn;exports.FutureRef=S;exports.IS_VIRTUAL_COLUMN=Ge;exports.It=ut;exports.JsRenderInternal=Jt;exports.LABEL_ANNOTATION=he;exports.LINKER_COLUMN_ANNOTATION=He;exports.MainOutputs=ct;exports.OutputError=Ie;exports.PAnnotationLabel=Oe;exports.PAnnotationTrace=Re;exports.PColumnCollection=ne;exports.PFrameImpl=cn;exports.RT_BINARY_PARTITIONED=V;exports.RT_BINARY_SUPER_PARTITIONED=B;exports.RT_JSON_PARTITIONED=U;exports.RT_JSON_SUPER_PARTITIONED=te;exports.RT_RESOURCE_MAP=Z;exports.RT_RESOURCE_MAP_PARTITIONED=ee;exports.RenderCtx=q;exports.ResultPool=$e;exports.StagingOutputs=dt;exports.Trace=ke;exports.TraceEntry=De;exports.TreeNodeAccessor=L;exports.UiState=pt;exports.allColumnsComputed=ve;exports.and=vt;exports.convertOrParsePColumnData=Ke;exports.createPFrameForGraphs=on;exports.createPlDataTable=Zt;exports.createPlDataTableSheet=tn;exports.createPlDataTableV2=en;exports.createRowSelectionColumn=ln;exports.deriveLabels=me;exports.downgradeCfgOrLambda=se;exports.enrichCompatible=Xe;exports.extractArchiveAndGetURL=Lt;exports.extractConfig=Xt;exports.filterDataInfoEntries=Je;exports.flatten=mt;exports.fromPlOption=dn;exports.fromPlRef=Qe;exports.getAllLabelColumns=ye;exports.getAvailableWithLinkersAxes=Ye;exports.getBlobContent=xt;exports.getBlobContentAsJson=St;exports.getBlobContentAsString=It;exports.getDownloadedBlobContent=Tt;exports.getEnvironmentValue=hn;exports.getFromCfg=W;exports.getImmediate=Y;exports.getImportProgress=Et;exports.getJsonField=Q;exports.getLastLogs=Ot;exports.getLinkerColumnsMap=qe;exports.getLogHandle=kt;exports.getMatchingLabelColumns=be;exports.getOnDemandBlobContent=_t;exports.getPartitionKeysList=je;exports.getPlatformaOrDefault=fn;exports.getProgressLog=Rt;exports.getProgressLogWithInfo=Dt;exports.getRawPlatformaInstance=Ze;exports.getResourceField=Pt;exports.getResourceValueAsJson=Ct;exports.getUniquePartitionKeys=Ve;exports.ifDef=oe;exports.isColumnHidden=Be;exports.isColumnOptional=We;exports.isConfigLambda=Me;exports.isEmpty=yt;exports.isLabelColumn=le;exports.isLinkerColumn=ze;exports.isolate=at;exports.makeArray=ft;exports.makeObject=ge;exports.mapArrayValues=gt;exports.mapPTableValueToAxisKey=un;exports.mapRecordValues=ht;exports.mapResourceFields=wt;exports.not=bt;exports.or=At;exports.parsePColumnData=ae;exports.parseResourceMap=Ut;exports.readOutput=Se;exports.stringifyPTableColumnId=an;exports.stringifyPTableColumnSpec=Qt;exports.wrapOutputs=ot;Object.keys(c).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>c[t]})});Object.keys(Ae).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Ae[t]})});
|
|
1
|
+
"use strict";var it=Object.defineProperty;var st=(t,e,n)=>e in t?it(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var D=(t,e,n)=>st(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@milaboratories/pl-model-common"),xe=require("canonicalize"),$=require("zod"),Ae=require("@milaboratories/pl-error-like");class Ie extends Error{constructor(e,n){super(`${e.length}${n?"+":""} errors, first error: `+e[0].message),this.errors=e,this.moreErrors=n}}function Se(t){if(!t.ok)throw new Ie(t.errors,t.moreErrors);return t.value}function ot(t){return new Proxy(t,{get(e,n){return Se(e[n])}})}function x(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null?Y(t):t}function W(t){return{type:"GetFromCtx",variable:t}}function at(t){return{type:"Isolate",cfg:t}}const lt=W("$args"),ut=W("$it"),ct=W("$prod"),dt=W("$staging"),pt=W("$ui");function Y(t){return{type:"Immediate",value:t}}function ge(t){const e={};for(const[n,r]of Object.entries(t))e[n]=x(r);return{type:"MakeObject",template:e}}function ft(...t){const e=[];for(const n of t)e.push(x(n));return{type:"MakeArray",template:e}}function Q(t,e){return{type:"GetJsonField",source:x(t),field:x(e)}}function ht(t,e,n="$it"){return{type:"MapRecordValues",source:t,mapping:e,itVar:n}}function gt(t,e,n="$it"){return{type:"MapArrayValues",source:t,mapping:e,itVar:n}}function mt(t){return{type:"Flatten",source:t}}function yt(t){return{type:"IsEmpty",arg:t}}function bt(t){return{type:"Not",operand:t}}function vt(t,e){return{type:"And",operand1:t,operand2:e}}function At(t,e){return{type:"Or",operand1:t,operand2:e}}function Pt(t,e){return{type:"GetResourceField",source:x(t),field:x(e)}}function Ct(){return function(t){return{type:"GetResourceValueAsJson",source:x(t)}}}function wt(t,e,n="$it"){return{type:"MapResourceFields",source:t,mapping:e,itVar:n}}function xt(t,e){return{type:"GetBlobContent",range:e,source:x(t)}}function It(t,e){return{type:"GetBlobContentAsString",range:e,source:x(t)}}function St(){return function(t,e){return{type:"GetBlobContentAsJson",range:e,source:x(t)}}}function Tt(t){return{type:"GetDownloadedBlobContent",source:x(t)}}function _t(t){return{type:"GetOnDemandBlobContent",source:x(t)}}function Lt(t,e){return{type:"ExtractArchiveAndGetURL",format:e,source:x(t)}}function Et(t){return{type:"GetImportProgress",source:x(t)}}function Ot(t,e){return{type:"GetLastLogs",source:x(t),lines:e}}function Rt(t,e){return{type:"GetProgressLog",source:x(t),patternToSearch:e}}function Dt(t,e){return{type:"GetProgressLogWithInfo",source:x(t),patternToSearch:e}}function kt(t){return{type:"GetLogHandle",source:x(t)}}function Ft(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function Te(t){if(t&&typeof globalThis.getPlatforma=="function")return globalThis.getPlatforma(t);if(typeof globalThis.platforma<"u")return globalThis.platforma;throw new Error("Can't get platforma instance.")}function jt(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function y(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function H(t,e){const n=jt();if(n===void 0)return!1;if(t in n.callbackRegistry)throw new Error(`Callback with key ${t} already registered.`);return n.callbackRegistry[t]=e,!0}const ce=new Map;function Nt(t,e){t in y().callbackRegistry||(y().callbackRegistry[t]=n=>{for(const r of ce.get(t))r(n)},ce.set(t,[])),ce.get(t).push(e)}class S{constructor(e,n=r=>r){D(this,"isResolved",!1);D(this,"resolvedValue");this.handle=e,this.postProcess=n,Nt(e,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(e){return new S(this.handle,n=>e(this.postProcess(n)))}mapDefined(e){return new S(this.handle,n=>{const r=this.postProcess(n);return r?e(r):void 0})}toJSON(){return this.isResolved?this.resolvedValue:{__awaited_futures__:[this.handle]}}}function oe(t,e){return t===void 0?void 0:e(t)}class L{constructor(e,n){this.handle=e,this.resolvePath=n}resolve(...e){const n=e.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveOutput(...e){const n=e.map(r=>({assertFieldType:"Output",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveInput(...e){const n=e.map(r=>({assertFieldType:"Input",...typeof r=="string"?{field:r}:r}));return this.resolveWithCommon({},...n)}resolveAny(...e){return this.resolveWithCommon({},...e)}resolveWithCommon(e,...n){const r=[...this.resolvePath,...n.map(i=>typeof i=="string"?i:i.field)];return oe(y().resolveWithCommon(this.handle,e,...n),i=>new L(i,r))}get resourceType(){return y().getResourceType(this.handle)}getInputsLocked(){return y().getInputsLocked(this.handle)}getOutputsLocked(){return y().getOutputsLocked(this.handle)}getIsReadyOrError(){return y().getIsReadyOrError(this.handle)}getIsFinal(){return y().getIsFinal(this.handle)}getError(){const e=[...this.resolvePath,"error"];return oe(y().getError(this.handle),n=>new L(n,e))}listInputFields(){return y().listInputFields(this.handle)}listOutputFields(){return y().listOutputFields(this.handle)}listDynamicFields(){return y().listDynamicFields(this.handle)}getKeyValueBase64(e){return y().getKeyValueBase64(this.handle,e)}getKeyValueAsString(e){return y().getKeyValueAsString(this.handle,e)}getKeyValueAsJson(e){const n=this.getKeyValueAsString(e);if(n==null)throw new Error("Resource has no content.");return JSON.parse(n)}getDataBase64(){return y().getDataBase64(this.handle)}getDataAsString(){return y().getDataAsString(this.handle)}getDataAsJson(){const e=this.getDataAsString();if(e==null)throw new Error("Resource has no content.");return JSON.parse(e)}getPColumns(e=!1,n=""){const r=this.parsePObjectCollection(e,n);return r===void 0?void 0:Object.entries(r).map(([,s])=>{if(!c.isPColumn(s))throw new Error(`not a PColumn (kind = ${s.spec.kind})`);return s})}parsePObjectCollection(e=!1,n=""){const r=y().parsePObjectCollection(this.handle,e,n,...this.resolvePath);if(r===void 0)return;const i={};for(const[s,o]of Object.entries(r)){const a=[...this.resolvePath,s];i[s]=c.mapPObjectData(o,l=>new L(l,a))}return i}getFileContentAsBase64(e){return new S(y().getBlobContentAsBase64(this.handle,e))}getFileContentAsString(e){return new S(y().getBlobContentAsString(this.handle,e))}getFileContentAsJson(e){return new S(y().getBlobContentAsString(this.handle,e)).mapDefined(n=>JSON.parse(n))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new S(y().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new S(y().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}extractArchiveAndGetURL(e){return new S(y().extractArchiveAndGetURL(this.handle,e))}getImportProgress(){return new S(y().getImportProgress(this.handle))}getLastLogs(e){return new S(y().getLastLogs(this.handle,e))}getProgressLog(e){return new S(y().getProgressLog(this.handle,e))}getProgressLogWithInfo(e){return new S(y().getProgressLogWithInfo(this.handle,e))}getLogHandle(){return new S(y().getLogHandle(this.handle))}allFieldsResolved(e="Input"){switch(e){case"Input":return this.getInputsLocked()&&this.listInputFields().every(n=>this.resolve({field:n,assertFieldType:"Input"})!==void 0);case"Output":return this.getOutputsLocked()&&this.listOutputFields().every(n=>this.resolve({field:n,assertFieldType:"Output"})!==void 0)}}mapFields(e,n){const{fieldType:r,requireLocked:i,skipUnresolved:s}={fieldType:"Input",requireLocked:!0,skipUnresolved:!1,...n},o=e;if(i&&(r==="Input"&&!this.getInputsLocked()||r==="Output"&&!this.getOutputsLocked()))return;let l=(r==="Input"?this.listInputFields():r==="Output"?this.listOutputFields():this.listDynamicFields()).map(u=>[u,this.resolve({field:u,assertFieldType:r})]);return s&&(l=l.filter(u=>u[1]!==void 0)),l.map(([u,d])=>o(u,d))}}const _e="staging",Le="main",Vt={explicitColumnsSupport:!0,inlineColumnsSupport:!0,activeArgs:!0};function Ee(t){return typeof t=="object"&&t!==null&&"__awaited_futures__"in t}function pe(t,e,n){if(e.has(n))return;if(e.add(n),typeof n==="object")if(Ee(n))n.__awaited_futures__.forEach(i=>t.add(i));else if(Array.isArray(n))for(const i of n)pe(t,e,i);else for(const[,i]of Object.entries(n))i!==n&&pe(t,e,i)}function Kt(t){const e=new Set;return pe(e,new Set,t),e}const Jt=Object.freeze(Object.defineProperty({__proto__:null,GlobalCfgRenderCtxFeatureFlags:Vt,MainAccessorName:Le,StagingAccessorName:_e,getAllFutureAwaits:Kt,isFutureAwait:Ee},Symbol.toStringTag,{value:"Module"})),Oe="pl7.app/label",Re="pl7.app/trace",De=$.z.object({type:$.z.string(),importance:$.z.number().optional(),id:$.z.string().optional(),label:$.z.string()}),ke=$.z.array(De),Mt=.001,$t="__LABEL__",Pe="__LABEL__@1";function me(t,e,n={}){const r=new Map,i=n.forceTraceElements!==void 0&&n.forceTraceElements.length>0?new Set(n.forceTraceElements):void 0,s=new Map,o=t.map(h=>{var I,k;const P=e(h);let f,m,A;"spec"in P&&typeof P.spec=="object"?(f=P.spec,m=P.prefixTrace,A=P.suffixTrace):f=P;const g=(I=f.annotations)==null?void 0:I[Oe],E=(k=f.annotations)==null?void 0:k[Re],w=(E?ke.safeParse(JSON.parse(E)).data:void 0)??[],v=[...m??[],...w,...A??[]];if(g!==void 0){const R={label:g,type:$t,importance:-2};n.addLabelAsSuffix?v.push(R):v.splice(0,0,R)}const C=[],O=new Map;for(let R=v.length-1;R>=0;--R){const{type:G}=v[R],j=v[R].importance??0,K=(O.get(G)??0)+1;O.set(G,K);const F=`${G}@${K}`;s.set(F,(s.get(F)??0)+1),r.set(F,Math.max(r.get(F)??Number.NEGATIVE_INFINITY,j-(v.length-R)*Mt)),C.push({...v[R],fullType:F,occurrenceIndex:K})}return C.reverse(),{value:h,spec:f,label:g,fullTrace:C}}),a=[],l=[],u=[...r];u.sort(([,h],[,P])=>P-h);for(const[h]of u)h.endsWith("@1")||s.get(h)===t.length?a.push(h):l.push(h);const d=(h,P=!1)=>{const f=[];for(let m=0;m<o.length;m++){const A=o[m],g=A.fullTrace.filter(v=>h.has(v.fullType)||i&&i.has(v.type));if(g.length===0)if(P)f.push({label:"Unlabeled",value:A.value});else return;const E=g.map(v=>v.label),w=n.separator??" / ";f.push({label:E.join(w),value:A.value})}return f};if(a.length===0){if(l.length!==0)throw new Error("Non-empty secondary types list while main types list is empty.");return d(new Set(Pe),!0)}let p=0,b=-1;for(;p<a.length;){const h=new Set;n.includeNativeLabel&&h.add(Pe);for(let f=0;f<p;++f)h.add(a[f]);b>=0&&h.add(a[b]);const P=d(h);if(P!==void 0&&new Set(P.map(f=>f.label)).size===t.length)return P;b++,b>=a.length&&(p++,b=p)}return d(new Set([...a,...l]),!0)}const re="PColumnData/",Z=re+"ResourceMap",ee=re+"Partitioned/ResourceMap",U=re+"JsonPartitioned",V=re+"BinaryPartitioned",Fe=re+"Partitioned/",te=Fe+"JsonPartitioned",B=Fe+"BinaryPartitioned";function je(t,e,n,r=[],i){if(t===void 0)return!1;switch(t.resourceType.name){case Z:{let s=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"}),l=[...r,...JSON.parse(o)],u=a===void 0?void 0:e(a);u===void 0&&(s=!1),(u!==void 0||i)&&n.push({key:l,value:u})}return s}case ee:{let s=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"});if(a===void 0)s=!1;else{const l=[...r,...JSON.parse(o)],u=je(a,e,n,l,i);s=s&&u}}return s}default:throw new Error(`Unknown resource type: ${t.resourceType.name}`)}}function Ut(t,e,n=!1){const r=[];return{isComplete:je(t,e,r,[],n),data:r}}const fe=t=>{if(t.endsWith(".index"))return{baseKey:t.substring(0,t.length-6),type:"index"};if(t.endsWith(".values"))return{baseKey:t.substring(0,t.length-7),type:"values"};throw new Error(`key must ends on .index/.values for binary p-column, got: ${t}`)};function Ne(t){if(!t)return;const e=t.resourceType.name,n=t.getDataAsJson(),r=[];let i=0;switch(e){case Z:i=n.keyLength;break;case ee:i=n.partitionKeyLength+n.keyLength;break;case U:case V:i=n.partitionKeyLength;break;case B:case te:i=n.superPartitionKeyLength+n.partitionKeyLength;break}switch(e){case Z:case U:case V:for(let s of t.listInputFields()){e===V&&(s=fe(s).baseKey);const o=[...JSON.parse(s)];r.push(o)}break;case ee:case B:case te:for(const s of t.listInputFields()){const o=[...JSON.parse(s)],a=t.resolve({field:s,assertFieldType:"Input"});if(a!==void 0)for(let l of a.listInputFields()){e===B&&(l=fe(l).baseKey);const u=[...o,...JSON.parse(l)];r.push(u)}}break}return{data:r,keyLength:i}}function Bt(t){if(t.type!=="JsonPartitioned"&&t.type!=="BinaryPartitioned")throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${t.type}`);const{parts:e,partitionKeyLength:n}=t,r=[];for(let i=0;i<n;++i)r.push(new Set);for(const i of e){const s=i.key;if(s.length!==n)throw new Error(`Key length (${s.length}) does not match partition length (${n}) for key: ${JSON.stringify(s)}`);for(let o=0;o<n;++o)r[o].add(s[o])}return r.map(i=>Array.from(i.values()))}function Ve(t){if(t===void 0)return;if(c.isDataInfoEntries(t))return Bt(t);const e=Ne(t);if(!e)return;const{data:n,keyLength:r}=e,i=[];for(let s=0;s<r;++s)i.push(new Set);for(const s of n){if(s.length!==r)throw new Error("key length does not match partition length");for(let o=0;o<r;++o)i[o].add(s[o])}return i.map(s=>Array.from(s.values()))}function ae(t,e=[]){if(t===void 0||!t.getIsReadyOrError())return;const n=t.resourceType.name,r=t.getDataAsJson();if(e.length>0&&(n===te||n===B))throw new Error(`Unexpected nested super-partitioned resource: ${n}`);switch(n){case Z:case ee:throw new Error(`Only data columns are supported, got: ${n}`);case U:{if(typeof(r==null?void 0:r.partitionKeyLength)!="number")throw new Error(`Missing partitionKeyLength in metadata for ${n}`);const i=[];for(const s of t.listInputFields()){const o=t.resolve({field:s,assertFieldType:"Input"});if(o===void 0)return;const a=[...e,...JSON.parse(s)];i.push({key:a,value:o})}return{type:"JsonPartitioned",partitionKeyLength:r.partitionKeyLength,parts:i}}case V:{if(typeof(r==null?void 0:r.partitionKeyLength)!="number")throw new Error(`Missing partitionKeyLength in metadata for ${n}`);const i=[],s=new Map;for(const o of t.listInputFields()){const a=fe(o),l=t.resolve({field:o,assertFieldType:"Input"});if(l===void 0)return;let u=s.get(a.baseKey);u||(u={},s.set(a.baseKey,u)),a.type==="index"?u.index=l:u.values=l}for(const[o,a]of s.entries()){if(!a.index||!a.values)return;const l=[...e,...JSON.parse(o)];i.push({key:l,value:{index:a.index,values:a.values}})}return{type:"BinaryPartitioned",partitionKeyLength:r.partitionKeyLength,parts:i}}case te:{if(typeof(r==null?void 0:r.superPartitionKeyLength)!="number"||typeof(r==null?void 0:r.partitionKeyLength)!="number")throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${n}`);const i=r.superPartitionKeyLength+r.partitionKeyLength,s=[];for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"});if(a===void 0)return;if(a.resourceType.name!==U)throw new Error(`Expected ${U} inside ${n}, but got ${a.resourceType.name}`);const l=ae(a,JSON.parse(o));if(l===void 0)return;if(l.type!=="JsonPartitioned")throw new Error(`Unexpected inner result type for ${n}: ${l.type}`);s.push(...l.parts)}return{type:"JsonPartitioned",partitionKeyLength:i,parts:s}}case B:{if(typeof(r==null?void 0:r.superPartitionKeyLength)!="number"||typeof(r==null?void 0:r.partitionKeyLength)!="number")throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${n}`);const i=r.superPartitionKeyLength+r.partitionKeyLength,s=[];for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"});if(a===void 0)return;if(a.resourceType.name!==V)throw new Error(`Expected ${V} inside ${n}, but got ${a.resourceType.name}`);const l=ae(a,JSON.parse(o));if(l===void 0)return;if(l.type!=="BinaryPartitioned")throw new Error(`Unexpected inner result type for ${n}: ${l.type}`);s.push(...l.parts)}return{type:"BinaryPartitioned",partitionKeyLength:i,parts:s}}default:throw new Error(`Unknown resource type: ${n}`)}}function Ke(t){if(t!==void 0){if(c.isDataInfoEntries(t))return t;if(c.isDataInfo(t))return c.dataInfoToEntries(t);if(t instanceof L)return ae(t);throw new Error(`Unexpected input type: ${typeof t}`)}}function Je(t,e){const n=[...e].sort((s,o)=>o[0]-s[0]);if(t.type==="JsonPartitioned"||t.type==="BinaryPartitioned"){const{partitionKeyLength:s}=t;for(const[o]of e)if(o>=s)throw new Error(`Can't filter on non-partitioned axis ${o}. Must be >= ${s}`)}else if(t.type==="Json"){const{keyLength:s}=t;for(const[o]of e)if(o>=s)throw new Error(`Can't filter on non-data axis ${o}. Must be >= ${s}`)}const r=s=>{for(const[o,a]of n)if(s[o]!==a)return!1;return!0},i=s=>{const o=[...s];for(const[a]of n)o.splice(a,1);return o};switch(t.type){case"Json":{const s=t.data.filter(o=>r(o.key)).map(o=>({key:i(o.key),value:o.value}));return{type:"Json",keyLength:t.keyLength-e.length,data:s}}case"JsonPartitioned":{const s=t.parts.filter(o=>r(o.key)).map(o=>({key:i(o.key),value:o.value}));return{type:"JsonPartitioned",partitionKeyLength:t.partitionKeyLength-e.length,parts:s}}case"BinaryPartitioned":{const s=t.parts.filter(o=>r(o.key)).map(o=>({key:i(o.key),value:o.value}));return{type:"BinaryPartitioned",partitionKeyLength:t.partitionKeyLength-e.length,parts:s}}}}function Wt(t){if(!Array.isArray(t))return!1;if(t.length===0)return!0;const e=t[0];return typeof e=="object"&&e!==null&&"key"in e&&"val"in e}class Gt{constructor(e){this.columns=e}selectColumns(e){const n=typeof e=="function"?e:c.selectorsToPredicate(e);return this.columns.filter(r=>n(r.spec))}}function zt(t){if(t)return t.map(e=>({type:`split:${c.canonicalizeAxisId(e.axisId)}`,label:e.label,importance:1e6}))}function Ht(t){if(t)return t.map(e=>[e.axisIdx,e.value])}function qt(t,e){if(!e||e.length===0)return t;const n=[...e].sort((r,i)=>r[0]-i[0]);return xe({id:t,axisFilters:n})}function Ce(t){if(!t||typeof t!="object")return!1;const e=t,n=e.domain&&typeof e.domain=="object"&&Object.values(e.domain).some(i=>typeof i=="object"&&i!==null&&"anchor"in i),r=e.axes&&Array.isArray(e.axes)&&e.axes.some(i=>typeof i=="object"&&i!==null&&"anchor"in i);return!!e.domainAnchor||n||r}function Yt(t){if(typeof t!="object"||!("axes"in t)||t.axes===void 0)return[];const e=t.axes.map((n,r)=>typeof n=="object"&&"split"in n&&n.split===!0?r:-1).filter(n=>n!==-1);if(e.length>0&&t.partialAxesMatch!==void 0)throw new Error("Axis splitting is not supported when `partialAxesMatch` is defined.");return e.sort((n,r)=>n-r),e}class ne{constructor(){D(this,"defaultProviderStore",[]);D(this,"providers",[new Gt(this.defaultProviderStore)]);D(this,"axisLabelProviders",[])}addColumnProvider(e){return this.providers.push(e),this}addAxisLabelProvider(e){return this.axisLabelProviders.push(e),this}addColumns(e){return this.defaultProviderStore.push(...e),this}addColumn(e){return this.defaultProviderStore.push(e),this}findLabels(e){for(const n of this.axisLabelProviders){const r=n.findLabels(e);if(r)return r}}getUniversalEntries(e,n){const{anchorCtx:r,labelOps:i,dontWaitAllData:s=!1,overrideLabelAnnotation:o=!1,exclude:a}=n??{},l={...o&&(i==null?void 0:i.includeNativeLabel)!==!1?{includeNativeLabel:!0}:{},...i??{}};let u=()=>!1;if(a){const f=(Array.isArray(a)?a:[a]).map(m=>{if(Ce(m)){if(!r)throw new Error("Anchored selectors in exclude require an AnchoredIdDeriver to be provided in options.");return c.selectorsToPredicate(c.resolveAnchors(r.anchors,m,n))}else return c.selectorsToPredicate(m)});u=m=>f.some(A=>A(m))}const d=typeof e=="function"?[e]:Array.isArray(e)?e:[e],p=[],b=new Set;for(const f of d){const m=Ce(f);let A;if(m){if(!r)throw new Error("Anchored selectors require an AnchoredIdDeriver to be provided in options.");A=c.resolveAnchors(r.anchors,f,n)}else A=f;const g=new Set,E=[];for(const C of this.providers){const O=C.selectColumns(A);for(const I of O){if(u(I.spec))continue;if(g.has(I.id))throw new Error(`Duplicate column id ${I.id} in provider ${C.constructor.name}`);const k=c.deriveNativeId(I.spec);b.has(k)||(g.add(I.id),b.add(k),E.push(I))}}if(E.length===0)continue;const w=Yt(f),v=w.length>0;for(const C of E){if(!c.isPColumnSpec(C.spec))continue;const O=C.spec;if(v){if(Wt(C.data))throw new Error(`Splitting is not supported for PColumns with PColumnValues data format. Column id: ${C.id}`);const I=Ke(C.data);if(!I){if(s)continue;return}if(!c.isPartitionedDataInfoEntries(I))throw new Error(`Splitting requires Partitioned DataInfoEntries, but parsing resulted in ${I.type} for column ${C.id}`);const k=Ve(I),R=w[w.length-1];if(R>=I.partitionKeyLength)throw new Error(`Not enough partition keys (${I.partitionKeyLength}) for requested split axes (max index ${R}) in column ${O.name}`);const G=w.map(T=>this.findLabels(c.getAxisId(O.axesSpec[T]))),j=[],K=(T,z)=>{if(z>=w.length){if(j.push([...T]),j.length>1e4)throw new Error("Too many key combinations, aborting.");return}const N=w[z];if(N>=k.length)throw new Error(`Axis index ${N} out of bounds for unique keys array (length ${k.length}) during split key generation for column ${C.id}`);const J=k[N];if(!J||J.length===0){j.length=0;return}for(const ie of J)T.push(ie),K(T,z+1),T.pop()};if(K([],0),j.length===0)continue;const F=[...O.axesSpec],et=w.map(T=>T);for(let T=w.length-1;T>=0;T--)F.splice(w[T],1);const tt={...O,axesSpec:F};for(const T of j){const z=T.map((N,J)=>{const ie=et[J],nt=c.getAxisId(O.axesSpec[ie]),ue=G[J],rt=(ue==null?void 0:ue[N])??String(N);return{axisIdx:ie,axisId:nt,value:N,label:rt}});p.push({type:"split",originalColumn:C,spec:O,adjustedSpec:tt,dataEntries:I,axisFilters:z})}}else p.push({type:"direct",originalColumn:C,spec:O,adjustedSpec:O})}}if(p.length===0)return[];const h=me(p,f=>({spec:f.spec,suffixTrace:f.type==="split"?zt(f.axisFilters):void 0}),l),P=[];for(const{value:f,label:m}of h){const{originalColumn:A,spec:g}=f,E=f.type==="split"?f.axisFilters:void 0,w=Ht(E);let v;r?v=r.deriveS(g,w):v=qt(A.id,w);let C={...f.adjustedSpec};o&&(C={...C,annotations:{...C.annotations??{},"pl7.app/label":m}}),P.push({id:v,spec:C,data:()=>f.type==="split"?c.entriesToDataInfo(Je(f.dataEntries,w)):f.originalColumn.data,label:m})}return P}getColumns(e,n){const r=this.getUniversalEntries(e,{overrideLabelAnnotation:!0,...n??{}});if(!r)return;const i=[];for(const s of r){const o=s.data();if(!o){if(n!=null&&n.dontWaitAllData)continue;return}i.push({id:s.id,spec:s.spec,data:o})}return i}}function de(t,e){if(t===void 0)return e===void 0;if(e===void 0)return!0;for(const n in e)if(t[n]!==e[n])return!1;return!0}function we(t){return c.mapPObjectData(t,e=>e instanceof L?e.handle:c.isDataInfo(e)?c.mapDataInfo(e,n=>n.handle):e)}class Me{constructor(){D(this,"ctx",y())}calculateOptions(e){return this.ctx.calculateOptions(e)}getOptions(e,n){const r=typeof e=="function"?e:c.selectorsToPredicate(e),i=this.getSpecs().entries.filter(a=>r(a.obj));let s={},o=!1;return typeof n<"u"&&(typeof n=="function"?s=n:typeof n=="object"&&("includeNativeLabel"in n||"separator"in n||"addLabelAsSuffix"in n?s=n:(n=n,s=n.label??{},o=n.refsWithEnrichments??!1))),typeof s=="object"?me(i,a=>a.obj,s??{}).map(({value:{ref:a},label:l})=>({ref:c.withEnrichments(a,o),label:l})):i.map(({ref:a,obj:l})=>({ref:c.withEnrichments(a,o),label:s(l,a)}))}resolveAnchorCtx(e){if(e instanceof c.AnchoredIdDeriver)return e;const n={};for(const[r,i]of Object.entries(e))if(c.isPlRef(i)){const s=this.getPColumnSpecByRef(i);if(!s)return;n[r]=s}else n[r]=i;return new c.AnchoredIdDeriver(n)}getAnchoredPColumns(e,n,r){const i=this.resolveAnchorCtx(e);if(i)return new ne().addColumnProvider(this).addAxisLabelProvider(this).getColumns(n,{...r,anchorCtx:i})}getCanonicalOptions(e,n,r){const i=this.resolveAnchorCtx(e);if(!i)return;const s=new ne().addColumnProvider(this).addAxisLabelProvider(this).getUniversalEntries(n,{...r,anchorCtx:i});if(s)return s.map(o=>({value:o.id,label:o.label}))}getDataFromResultPool(){return this.getData()}getData(){const e=this.ctx.getDataFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:new L(n.obj.data,[n.ref.blockId,n.ref.name])}}))}}getDataWithErrorsFromResultPool(){return this.getDataWithErrors()}getDataWithErrors(){const e=this.ctx.getDataWithErrorsFromResultPool();return{isComplete:e.isComplete,entries:e.entries.map(n=>({ref:n.ref,obj:{...n.obj,data:c.mapValueInVOE(n.obj.data,r=>new L(r,[n.ref.blockId,n.ref.name]))}}))}}getSpecsFromResultPool(){return this.getSpecs()}getSpecs(){return this.ctx.getSpecsFromResultPool()}getDataByRef(e){var r;if(typeof this.ctx.getDataFromResultPoolByRef>"u")return(r=this.getData().entries.find(i=>i.ref.blockId===e.blockId&&i.ref.name===e.name))==null?void 0:r.obj;const n=this.ctx.getDataFromResultPoolByRef(e.blockId,e.name);if(n)return c.mapPObjectData(n,i=>new L(i,[e.blockId,e.name]))}getPColumnByRef(e){const n=this.getDataByRef(e);if(n)return c.ensurePColumn(n)}getPColumnSpecByRef(e){const n=this.getSpecByRef(e);if(n){if(!c.isPColumnSpec(n))throw new Error(`not a PColumn spec (kind = ${n.kind})`);return n}}getSpecByRef(e){return this.ctx.getSpecFromResultPoolByRef(e.blockId,e.name)}findDataWithCompatibleSpec(e){const n=[];e:for(const r of this.getData().entries){if(!c.isPColumnSpec(r.obj.spec))continue;const i=r.obj.spec;if(e.name===i.name&&e.valueType===i.valueType&&e.axesSpec.length===i.axesSpec.length&&de(e.domain,i.domain)){for(let s=0;s<e.axesSpec.length;++s){const o=e.axesSpec[s],a=i.axesSpec[s];if(o.name!==a.name||o.type!==a.type||!de(o.domain,a.domain))continue e}n.push(r.obj)}}return n}findLabels(e){const n=this.getData();for(const r of n.entries){if(!c.isPColumn(r.obj))continue;const i=r.obj.spec;if(i.name==="pl7.app/label"&&i.axesSpec.length===1&&i.axesSpec[0].name===e.name&&i.axesSpec[0].type===e.type&&de(e.domain,i.axesSpec[0].domain)){if(r.obj.data.resourceType.name!=="PColumnData/Json")throw Error(`Expected JSON column for labels, got: ${r.obj.data.resourceType.name}`);return Object.fromEntries(Object.entries(r.obj.data.getDataAsJson().data).map(o=>[JSON.parse(o[0])[0],o[1]]))}}}selectColumns(e){const n=typeof e=="function"?e:c.selectorsToPredicate(e);return this.getSpecs().entries.filter(({obj:i})=>c.isPColumnSpec(i)?n(i):!1).map(({ref:i,obj:s})=>{const o=s;let a=null;const l=this;return{id:xe(i),spec:o,get data(){var u;return a!==null||(a=(u=l.getPColumnByRef(i))==null?void 0:u.data),a}}})}findLabelsForColumnAxis(e,n){var s;const r=this.findLabels(e.axesSpec[n]);if(!r)return;const i=(s=e.annotations)==null?void 0:s["pl7.app/axisKeys/"+n];if(i!==void 0){const o=JSON.parse(i);return Object.fromEntries(o.map(a=>[a,r[a]??"Unlabelled"]))}else return r}}class q{constructor(){D(this,"ctx");D(this,"args");D(this,"uiState");D(this,"_activeArgsCache");D(this,"resultPool",new Me);this.ctx=y(),this.args=JSON.parse(this.ctx.args),this.uiState=this.ctx.uiState!==void 0?JSON.parse(this.ctx.uiState):{}}get activeArgs(){return this._activeArgsCache===void 0&&(this._activeArgsCache={v:this.ctx.activeArgs?JSON.parse(this.ctx.activeArgs):void 0}),this._activeArgsCache.v}getNamedAccessor(e){return oe(this.ctx.getAccessorHandleByName(e),n=>new L(n,[e]))}get prerun(){return this.getNamedAccessor(_e)}get outputs(){return this.getNamedAccessor(Le)}findLabels(e){return this.resultPool.findLabels(e)}verifyInlineAndExplicitColumnsSupport(e){var i;const n=e.some(s=>!(s.data instanceof L)||c.isDataInfo(s.data)),r=((i=this.ctx.featureFlags)==null?void 0:i.inlineColumnsSupport)===!0;if(n&&!r)throw Error("Inline or explicit columns not supported")}createPFrame(e){return this.verifyInlineAndExplicitColumnsSupport(e),this.ctx.createPFrame(e.map(n=>we(n)))}createPTable(e){let n;return"columns"in e?n={src:{type:"full",entries:e.columns.map(r=>({type:"column",column:r}))},filters:e.filters??[],sorting:e.sorting??[]}:n=e,this.verifyInlineAndExplicitColumnsSupport(c.extractAllColumns(n.src)),this.ctx.createPTable(c.mapPTableDef(n,r=>we(r)))}getBlockLabel(e){return this.ctx.getBlockLabel(e)}getCurrentUnstableMarker(){return this.ctx.getCurrentUnstableMarker()}logInfo(e){this.ctx.logInfo(e)}logWarn(e){this.ctx.logWarn(e)}logError(e){this.ctx.logError(e)}}const X="1.34.8";function $e(t){return t.__renderLambda===!0}function se(t){if(t!==void 0)return $e(t)?t.handle:t}function M(t){if(t!==void 0)return typeof t=="string"?{__renderLambda:!0,handle:t,retentive:!1}:t}function Xt(t){if(t.v3!==void 0){const{initialArgs:e,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:o,sections:a,title:l,enrichmentTargets:u}=t.v3,{code:d}=t;return{initialArgs:e,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:o,sections:a,title:l,code:d,enrichmentTargets:u}}else if(t.inputsValid!==void 0){const{sdkVersion:e,renderingMode:n,outputs:r,inputsValid:i,sections:s,initialArgs:o,code:a}=t,l=Object.keys(t);if(e===void 0||n===void 0||r===void 0||i===void 0||s===void 0||o===void 0)throw new Error(`Malformed config v2. SDK version ${e}; Fields = ${l.join(", ")}`);return{sdkVersion:e,renderingMode:n,initialArgs:o,outputs:Object.fromEntries(Object.entries(r).map(([u,d])=>[u,M(d)])),inputsValid:M(i),sections:M(s),initialUiState:void 0,code:a}}else if(t.renderingMode!==void 0){const{sdkVersion:e,canRun:n,renderingMode:r,outputs:i,sections:s,initialArgs:o,code:a}=t,l=Object.keys(t);if(r===void 0||i===void 0||n===void 0||s===void 0||o===void 0)throw new Error(`Malformed config v1. SDK version ${e}; Fields = ${l.join(", ")}`);return{sdkVersion:e??"unknown",renderingMode:r,initialArgs:o,outputs:Object.fromEntries(Object.entries(i).map(([u,d])=>[u,M(d)])),inputsValid:M(n),sections:M(s),initialUiState:void 0,code:a}}else{const{sdkVersion:e}=t,n=Object.keys(t);throw new Error(`Config format not supported: SDK = ${e}; Fields = ${n.join(", ")}`)}}class _{constructor(e,n,r,i,s,o,a,l){this._renderingMode=e,this._initialArgs=n,this._initialUiState=r,this._outputs=i,this._inputsValid=s,this._sections=o,this._title=a,this._enrichmentTargets=l}static create(e="Heavy"){return new _(e,void 0,{},{},Y(!0),Y([]),void 0,void 0)}output(e,n,r={}){if(typeof n=="function"){const i=`output#${e}`;return H(i,()=>n(new q)),new _(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:{__renderLambda:!0,handle:i,...r}},this._inputsValid,this._sections,this._title,this._enrichmentTargets)}else return new _(this._renderingMode,this._initialArgs,this._initialUiState,{...this._outputs,[e]:n},this._inputsValid,this._sections,this._title,this._enrichmentTargets)}retentiveOutput(e,n){return this.output(e,n,{retentive:!0})}argsValid(e){return typeof e=="function"?(H("inputsValid",()=>e(new q)),new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title,this._enrichmentTargets)):new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,e,this._sections,this._title,this._enrichmentTargets)}sections(e){return Array.isArray(e)?this.sections(Y(e)):typeof e=="function"?(H("sections",()=>e(new q)),new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title,this._enrichmentTargets)):new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,e,this._title,this._enrichmentTargets)}title(e){return H("title",()=>e(new q)),new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"},this._enrichmentTargets)}initialArgs(e){return new _(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}withArgs(e){return new _(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}withUiState(e){return new _(this._renderingMode,this._initialArgs,e,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}enriches(e){return H("enrichmentTargets",e),new _(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,{__renderLambda:!0,handle:"enrichmentTargets"})}done(){if(this._initialArgs===void 0)throw new Error("Initial arguments not set.");const e={v3:{sdkVersion:X,renderingMode:this._renderingMode,initialArgs:this._initialArgs,initialUiState:this._initialUiState,inputsValid:this._inputsValid,sections:this._sections,title:this._title,outputs:this._outputs,enrichmentTargets:this._enrichmentTargets},sdkVersion:X,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:se(this._inputsValid),sections:se(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,se(r)]))};return Ft()?Te({sdkVersion:X}):{config:e}}}function Qt(t){const e=t.type;switch(e){case"axis":return c.canonicalizeJson(t);case"column":return c.canonicalizeJson(t);default:throw Error(`unsupported column type: ${e}`)}}function le(t){return t.axesSpec.length===1&&t.name==="pl7.app/label"}function ye(t){return new ne().addAxisLabelProvider(t).addColumnProvider(t).getColumns({name:"pl7.app/label",axes:[{}]},{dontWaitAllData:!0})}function be(t,e){const n=[],r=[];for(const a of t)le(a.spec)?n.push(a):r.push(a);const i=[];for(const a of r)for(const l of a.spec.axesSpec){const u=c.getAxisId(l);i.some(d=>c.matchAxisId(d,u))||i.push(u)}for(const a of n){const l=c.getAxisId(a.spec.axesSpec[0]),u=i.findIndex(d=>c.matchAxisId(d,l));u!==-1&&i.splice(u,1)}const s=(a,l)=>{let u=a.toString();if(l)for(const d in l)u+=d,u+=l[d];return u},o=[];for(const a of e){const l=a.spec.axesSpec[0],u=c.getAxisId(l),d=i.findIndex(p=>c.matchAxisId(p,u));if(d!==-1){const p=i[d],b=Object.keys(p.domain??{}).length,h=Object.keys(l.domain??{}).length;b>h?o.push({id:s(a.id,p.domain),spec:{...a.spec,axesSpec:[{...p,annotations:l.annotations}]},data:a.data}):o.push(a),i.splice(d,1)}}return o}function ve(t){const e=i=>Array.isArray(i),n=i=>i instanceof L,r=i=>typeof i=="object"&&"type"in i;return t.map(i=>i.data).every(i=>{if(e(i))return!0;if(n(i))return i.getIsReadyOrError();if(r(i))switch(i.type){case"Json":return!0;case"JsonPartitioned":return Object.values(i.parts).every(o=>o.getIsReadyOrError());case"BinaryPartitioned":return Object.values(i.parts).every(o=>o.index.getIsReadyOrError()&&o.values.getIsReadyOrError())}else throw Error(`unsupported column data type: ${i}`)})}function Ue(t,e,n,r,i,s){let o=t;const a=[];if(s){o=[];for(const l of t)s(l.spec)?o.push(l):a.push(l)}return a.push(...e),{src:{type:"outer",primary:{type:n,entries:o.map(l=>({type:"column",column:l}))},secondary:a.map(l=>({type:"column",column:l}))},filters:r,sorting:i}}function Zt(t,e,n,r){var u,d;Array.isArray(r)&&(r={filters:r});const i=(r==null?void 0:r.coreJoinType)??"full",s=[...(r==null?void 0:r.filters)??[],...((u=n==null?void 0:n.pTableParams)==null?void 0:u.filters)??[]],o=((d=n==null?void 0:n.pTableParams)==null?void 0:d.sorting)??[],a=ye(t.resultPool);if(!a)return;const l=be(e.map(c.getColumnIdAndSpec),a);if(ve([...e,...l]))return t.createPTable(Ue(e,l,i,s,o,r==null?void 0:r.coreColumnPredicate))}function Be(t){var e;return((e=t.annotations)==null?void 0:e["pl7.app/table/visibility"])==="hidden"}function We(t){var e;return((e=t.annotations)==null?void 0:e["pl7.app/table/visibility"])==="optional"}function en(t,e,n,r,i){var m,A;const s=(i==null?void 0:i.coreJoinType)??"full",o=[...(i==null?void 0:i.filters)??[],...((m=r==null?void 0:r.pTableParams)==null?void 0:m.filters)??[]],a=((A=r==null?void 0:r.pTableParams)==null?void 0:A.sorting)??[],l=e.filter(g=>!Be(g.spec)),u=l.find(g=>n(g.spec));if(!u)return;const d=ye(t.resultPool);if(!d)return;const p=new Set((()=>{var E,w;if(s==="inner")return[];const g=(w=(E=r==null?void 0:r.gridState.columnVisibility)==null?void 0:E.hiddenColIds)==null?void 0:w.map(c.parseJson).filter(v=>v.type==="column").map(v=>v.id);return g||l.filter(v=>We(v.spec)).map(v=>v.id)})());p.delete(u.id),[...o.map(g=>g.column),...a.map(g=>g.column)].filter(g=>g.type==="column").map(g=>p.delete(g.id));const b=l.filter(g=>!p.has(g.id)),h=be(b.map(c.getColumnIdAndSpec),d),P=[...u.spec.axesSpec.map(g=>({type:"axis",id:c.getAxisId(g),spec:g})),...[...l,...h].map(g=>({type:"column",id:g.id,spec:g.spec}))];if(!ve([...b,...h]))return;const f=t.createPTable(Ue(l,h,s,o,a,i==null?void 0:i.coreColumnPredicate));return{tableSpec:P,tableHandle:f}}function tn(t,e,n){const r=t.resultPool.findLabels(e);return{axis:e,options:n.map(i=>({value:i,label:(r==null?void 0:r[i])??i.toString()})),defaultValue:n[0]}}const nn=(t,e)=>{let n=t.toString();return e==null||e.forEach(r=>{if(r)for(const[i,s]of Object.entries(r))n+=i,n+=s}),n};function rn(t){if(!t.length)return[];let e=[[]];return t.forEach(n=>{const r=[];n.forEach(i=>{r.push(...e.map(s=>[...s,i]))}),e=r}),e}function Ge(t){var e;return t.axesSpec.length===2&&((e=t.annotations)==null?void 0:e[He])==="true"}const ze="pl7.app/graph/isVirtual",he="pl7.app/label",He="pl7.app/isLinkerColumn";function qe(t){var n,r;const e=new Map;for(const{spec:i}of t){const s=i.axesSpec.map(c.getAxisId).map(c.canonicalizeJson);s.forEach(o=>{e.has(o)||e.set(o,new Set)});for(let o=0;o<s.length-1;o++)for(let a=o+1;a<s.length;a++){const l=s[o],u=s[a];(n=e.get(l))==null||n.add(u),(r=e.get(u))==null||r.add(l)}}return e}function Ye(t,e){const n=qe(t),r=[...n.keys()].map(c.parseJson),i=[];for(const l of e.values()){const u=r.find(d=>c.matchAxisId(l,d));u&&i.push(c.canonicalizeJson(u))}const s=new Set(i),o=new Map;let a=[...i];for(;a.length;){const l=[];for(const u of a)for(const d of n.get(u)??[])s.has(d)||(l.push(d),s.add(d),o.set(d,c.parseJson(d)));a=l}return o}function Xe(t,e){const n=[];return e.forEach(r=>{n.push(...sn(t,r))}),n}function sn(t,e){const n=e.spec.axesSpec.map(c.getAxisId);if(n.every(u=>t.has(c.canonicalizeJson(u))))return[e];const r=n.map(u=>{const d=[];for(const[p,b]of t)c.matchAxisId(b,u)&&!c.matchAxisId(u,b)&&d.push(b);return d}),i=rn(r),s=new Set,o=new Set,a=i.map(u=>{const d=new Set;return u.map((p,b)=>{const h=e.spec.axesSpec[b].domain,P=p.domain;return Object.entries(P??{}).forEach(([f,m])=>{if((h==null?void 0:h[f])===void 0){const A=JSON.stringify([f,m]);d.add(A),s.add(A)}}),{...p,annotations:e.spec.axesSpec[b].annotations}}),d});[...s].forEach(u=>{a.some(d=>!d.has(u))&&o.add(u)});const l=i.map((u,d)=>{var f;const p=nn(e.id,u.map(m=>m.domain)),b=((f=e.spec.annotations)==null?void 0:f[he])??"",h=[...a[d]].filter(m=>o.has(m)).sort().map(m=>{var A;return(A=JSON.parse(m))==null?void 0:A[1]}).join(" / "),P={...e.spec.annotations,[ze]:"true"};return(b||h)&&(P[he]=b&&h?b+" / "+h:b+h),{id:p,spec:{...e.spec,axesSpec:u.map((m,A)=>({...m,annotations:e.spec.axesSpec[A].annotations})),annotations:P},data:e.data}});return[e,...l]}function on(t,e){if(!e)return;const n=new ne;n.addColumnProvider(t.resultPool),n.addColumns(e);const r=new Map,i=new Map;for(const p of e)for(const b of p.spec.axesSpec){const h=c.getAxisId(b);r.set(c.canonicalizeJson(h),h),i.set(c.canonicalizeJson(h),h)}const s=n.getColumns(p=>Ge(p))??[],o=Ye(s,r);for(const p of o)r.set(...p),i.set(...p);const a=(n.getColumns([...r.values()].map(p=>({axes:[p],partialAxesMatch:!0})),{dontWaitAllData:!0,overrideLabelAnnotation:!1})??[]).filter(p=>!le(p.spec));for(const p of a)for(const b of p.spec.axesSpec){const h=c.getAxisId(b);i.set(c.canonicalizeJson(h),h)}const l=(n.getColumns([...i.values()].map(p=>({axes:[p],partialAxesMatch:!0})),{dontWaitAllData:!0,overrideLabelAnnotation:!1})??[]).filter(p=>le(p.spec)),u=[...a,...l],d=Xe(r,u);if(!d.some(p=>p.data instanceof L&&!p.data.getIsReadyOrError()))return t.createPFrame(d)}function an({selection:t,columnId:e=c.uniquePlId(),label:n="Selection marker",domain:r}){if(!(t!=null&&t.axesSpec.length))return;const i=t.selectedKeys.filter(s=>s.every(o=>!c.isPTableAbsent(o))).map(s=>({key:s,val:1}));if(i.length)return{id:e,spec:{kind:"PColumn",valueType:"Int",name:"pl7.app/table/row-selection",axesSpec:t.axesSpec,...r&&Object.keys(r).length&&{domain:r},annotations:{"pl7.app/label":n,"pl7.app/discreteValues":"[1]"}},data:i}}function ln(t){return t===c.PTableNA?(console.error("Axis value can never be N/A"),""):t}class un{constructor(e){this.handle=e}async findColumns(e){return await platforma.pFrameDriver.findColumns(this.handle,e)}async getColumnSpec(e){return await platforma.pFrameDriver.getColumnSpec(this.handle,e)}async listColumns(){return await platforma.pFrameDriver.listColumns(this.handle)}async calculateTableData(e,n){return await platforma.pFrameDriver.calculateTableData(this.handle,e,n)}async getUniqueValues(e){return await platforma.pFrameDriver.getUniqueValues(this.handle,e)}}function Qe(t){return ge({__isRef:!0,blockId:Q(t,"blockId"),name:Q(t,"name")})}function cn(t){return ge({ref:Qe(Q(t,"ref")),label:Q(t,"label")})}const dn={sdkVersion:X};function Ze(){return Te({sdkVersion:X})}function pn(t){try{return Ze()}catch{return t}}function fn(t){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(t)}exports.Args=lt;exports.BlockModel=_;exports.CurrentSdkInfo=dn;exports.FutureRef=S;exports.IS_VIRTUAL_COLUMN=ze;exports.It=ut;exports.JsRenderInternal=Jt;exports.LABEL_ANNOTATION=he;exports.LINKER_COLUMN_ANNOTATION=He;exports.MainOutputs=ct;exports.OutputError=Ie;exports.PAnnotationLabel=Oe;exports.PAnnotationTrace=Re;exports.PColumnCollection=ne;exports.PFrameImpl=un;exports.RT_BINARY_PARTITIONED=V;exports.RT_BINARY_SUPER_PARTITIONED=B;exports.RT_JSON_PARTITIONED=U;exports.RT_JSON_SUPER_PARTITIONED=te;exports.RT_RESOURCE_MAP=Z;exports.RT_RESOURCE_MAP_PARTITIONED=ee;exports.RenderCtx=q;exports.ResultPool=Me;exports.StagingOutputs=dt;exports.Trace=ke;exports.TraceEntry=De;exports.TreeNodeAccessor=L;exports.UiState=pt;exports.allColumnsComputed=ve;exports.and=vt;exports.convertOrParsePColumnData=Ke;exports.createPFrameForGraphs=on;exports.createPlDataTable=Zt;exports.createPlDataTableSheet=tn;exports.createPlDataTableV2=en;exports.createRowSelectionColumn=an;exports.deriveLabels=me;exports.downgradeCfgOrLambda=se;exports.enrichCompatible=Xe;exports.extractArchiveAndGetURL=Lt;exports.extractConfig=Xt;exports.filterDataInfoEntries=Je;exports.flatten=mt;exports.fromPlOption=cn;exports.fromPlRef=Qe;exports.getAllLabelColumns=ye;exports.getAvailableWithLinkersAxes=Ye;exports.getBlobContent=xt;exports.getBlobContentAsJson=St;exports.getBlobContentAsString=It;exports.getDownloadedBlobContent=Tt;exports.getEnvironmentValue=fn;exports.getFromCfg=W;exports.getImmediate=Y;exports.getImportProgress=Et;exports.getJsonField=Q;exports.getLastLogs=Ot;exports.getLinkerColumnsMap=qe;exports.getLogHandle=kt;exports.getMatchingLabelColumns=be;exports.getOnDemandBlobContent=_t;exports.getPartitionKeysList=Ne;exports.getPlatformaOrDefault=pn;exports.getProgressLog=Rt;exports.getProgressLogWithInfo=Dt;exports.getRawPlatformaInstance=Ze;exports.getResourceField=Pt;exports.getResourceValueAsJson=Ct;exports.getUniquePartitionKeys=Ve;exports.ifDef=oe;exports.isColumnHidden=Be;exports.isColumnOptional=We;exports.isConfigLambda=$e;exports.isEmpty=yt;exports.isLabelColumn=le;exports.isLinkerColumn=Ge;exports.isolate=at;exports.makeArray=ft;exports.makeObject=ge;exports.mapArrayValues=gt;exports.mapPTableValueToAxisKey=ln;exports.mapRecordValues=ht;exports.mapResourceFields=wt;exports.not=bt;exports.or=At;exports.parsePColumnData=ae;exports.parseResourceMap=Ut;exports.readOutput=Se;exports.stringifyPTableColumnSpec=Qt;exports.wrapOutputs=ot;Object.keys(c).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>c[t]})});Object.keys(Ae).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Ae[t]})});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|