@platforma-sdk/model 1.30.24 → 1.30.26
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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +622 -608
- package/dist/index.mjs.map +1 -1
- package/dist/render/api.d.ts +2 -1
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/util/column_collection.d.ts +3 -1
- package/dist/render/util/column_collection.d.ts.map +1 -1
- package/dist/render/util/label.d.ts +2 -0
- package/dist/render/util/label.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/render/api.ts +2 -0
- package/src/render/util/column_collection.ts +18 -1
- package/src/render/util/label.test.ts +78 -0
- package/src/render/util/label.ts +8 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var et=Object.defineProperty;var tt=(t,e,n)=>e in t?et(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var O=(t,e,n)=>tt(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@milaboratories/pl-model-common"),Ce=require("canonicalize"),J=require("zod"),be=require("@milaboratories/pl-error-like");class we extends Error{constructor(e,n){super(`${e.length}${n?"+":""} errors, first error: `+e[0].message),this.errors=e,this.moreErrors=n}}function Ie(t){if(!t.ok)throw new we(t.errors,t.moreErrors);return t.value}function nt(t){return new Proxy(t,{get(e,n){return Ie(e[n])}})}function w(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"||t===null?H(t):t}function B(t){return{type:"GetFromCtx",variable:t}}function rt(t){return{type:"Isolate",cfg:t}}const it=B("$args"),st=B("$it"),ot=B("$prod"),at=B("$staging"),lt=B("$ui");function H(t){return{type:"Immediate",value:t}}function fe(t){const e={};for(const[n,r]of Object.entries(t))e[n]=w(r);return{type:"MakeObject",template:e}}function ut(...t){const e=[];for(const n of t)e.push(w(n));return{type:"MakeArray",template:e}}function Y(t,e){return{type:"GetJsonField",source:w(t),field:w(e)}}function ct(t,e,n="$it"){return{type:"MapRecordValues",source:t,mapping:e,itVar:n}}function dt(t,e,n="$it"){return{type:"MapArrayValues",source:t,mapping:e,itVar:n}}function pt(t){return{type:"Flatten",source:t}}function ft(t){return{type:"IsEmpty",arg:t}}function ht(t){return{type:"Not",operand:t}}function gt(t,e){return{type:"And",operand1:t,operand2:e}}function mt(t,e){return{type:"Or",operand1:t,operand2:e}}function yt(t,e){return{type:"GetResourceField",source:w(t),field:w(e)}}function bt(){return function(t){return{type:"GetResourceValueAsJson",source:w(t)}}}function vt(t,e,n="$it"){return{type:"MapResourceFields",source:t,mapping:e,itVar:n}}function At(t){return{type:"GetBlobContent",source:w(t)}}function Pt(t){return{type:"GetBlobContentAsString",source:w(t)}}function Ct(){return function(t){return{type:"GetBlobContentAsJson",source:w(t)}}}function wt(t){return{type:"GetDownloadedBlobContent",source:w(t)}}function It(t){return{type:"GetOnDemandBlobContent",source:w(t)}}function xt(t,e){return{type:"ExtractArchiveAndGetURL",format:e,source:w(t)}}function St(t){return{type:"GetImportProgress",source:w(t)}}function _t(t,e){return{type:"GetLastLogs",source:w(t),lines:e}}function Tt(t,e){return{type:"GetProgressLog",source:w(t),patternToSearch:e}}function Lt(t,e){return{type:"GetProgressLogWithInfo",source:w(t),patternToSearch:e}}function Ot(t){return{type:"GetLogHandle",source:w(t)}}function Et(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function xe(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 Rt(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function b(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function G(t,e){const n=Rt();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 le=new Map;function Dt(t,e){t in b().callbackRegistry||(b().callbackRegistry[t]=n=>{for(const r of le.get(t))r(n)},le.set(t,[])),le.get(t).push(e)}class x{constructor(e,n=r=>r){O(this,"isResolved",!1);O(this,"resolvedValue");this.handle=e,this.postProcess=n,Dt(e,r=>{this.resolvedValue=n(r),this.isResolved=!0})}map(e){return new x(this.handle,n=>e(this.postProcess(n)))}mapDefined(e){return new x(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 ie(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 ie(b().resolveWithCommon(this.handle,e,...n),i=>new L(i,r))}get resourceType(){return b().getResourceType(this.handle)}getInputsLocked(){return b().getInputsLocked(this.handle)}getOutputsLocked(){return b().getOutputsLocked(this.handle)}getIsReadyOrError(){return b().getIsReadyOrError(this.handle)}getIsFinal(){return b().getIsFinal(this.handle)}getError(){const e=[...this.resolvePath,"error"];return ie(b().getError(this.handle),n=>new L(n,e))}listInputFields(){return b().listInputFields(this.handle)}listOutputFields(){return b().listOutputFields(this.handle)}listDynamicFields(){return b().listDynamicFields(this.handle)}getKeyValueBase64(e){return b().getKeyValueBase64(this.handle,e)}getKeyValueAsString(e){return b().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 b().getDataBase64(this.handle)}getDataAsString(){return b().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(!u.isPColumn(s))throw new Error(`not a PColumn (kind = ${s.spec.kind})`);return s})}parsePObjectCollection(e=!1,n=""){const r=b().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]=u.mapPObjectData(o,l=>new L(l,a))}return i}getFileContentAsBase64(){return new x(b().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new x(b().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new x(b().getBlobContentAsString(this.handle)).mapDefined(e=>JSON.parse(e))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new x(b().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new x(b().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}extractArchiveAndGetURL(e){return new x(b().extractArchiveAndGetURL(this.handle,e))}getImportProgress(){return new x(b().getImportProgress(this.handle))}getLastLogs(e){return new x(b().getLastLogs(this.handle,e))}getProgressLog(e){return new x(b().getProgressLog(this.handle,e))}getProgressLogWithInfo(e){return new x(b().getProgressLogWithInfo(this.handle,e))}getLogHandle(){return new x(b().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(c=>[c,this.resolve({field:c,assertFieldType:r})]);return s&&(l=l.filter(c=>c[1]!==void 0)),l.map(([c,f])=>o(c,f))}}const Se="staging",_e="main",Ft={explicitColumnsSupport:!0,inlineColumnsSupport:!0,activeArgs:!0};function Te(t){return typeof t=="object"&&t!==null&&"__awaited_futures__"in t}function ce(t,e,n){if(e.has(n))return;if(e.add(n),typeof n==="object")if(Te(n))n.__awaited_futures__.forEach(i=>t.add(i));else if(Array.isArray(n))for(const i of n)ce(t,e,i);else for(const[,i]of Object.entries(n))i!==n&&ce(t,e,i)}function kt(t){const e=new Set;return ce(e,new Set,t),e}const jt=Object.freeze(Object.defineProperty({__proto__:null,GlobalCfgRenderCtxFeatureFlags:Ft,MainAccessorName:_e,StagingAccessorName:Se,getAllFutureAwaits:kt,isFutureAwait:Te},Symbol.toStringTag,{value:"Module"})),Le="pl7.app/label",Oe="pl7.app/trace",Ee=J.z.object({type:J.z.string(),importance:J.z.number().optional(),id:J.z.string().optional(),label:J.z.string()}),Re=J.z.array(Ee),Vt=.001,Nt="__LABEL__",ve="__LABEL__@1";function he(t,e,n={}){const r=new Map,i=new Map,s=t.map(g=>{var R,M;const d=e(g);let y,A,C;"spec"in d&&typeof d.spec=="object"?(y=d.spec,A=d.prefixTrace,C=d.suffixTrace):y=d;const p=(R=y.annotations)==null?void 0:R[Le],m=(M=y.annotations)==null?void 0:M[Oe],P=(m?Re.safeParse(JSON.parse(m)).data:void 0)??[],h=[...A??[],...P,...C??[]];if(p!==void 0){const E={label:p,type:Nt,importance:-2};n.addLabelAsSuffix?h.push(E):h.splice(0,0,E)}const S=[],I=new Map;for(let E=h.length-1;E>=0;--E){const{type:D}=h[E],te=h[E].importance??0,V=(I.get(D)??0)+1;I.set(D,V);const F=`${D}@${V}`;i.set(F,(i.get(F)??0)+1),r.set(F,Math.max(r.get(F)??Number.NEGATIVE_INFINITY,te-(h.length-E)*Vt)),S.push({...h[E],fullType:F,occurrenceIndex:V})}return S.reverse(),{value:g,spec:y,label:p,fullTrace:S}}),o=[],a=[],l=[...r];l.sort(([,g],[,d])=>d-g);for(const[g]of l)g.endsWith("@1")||i.get(g)===t.length?o.push(g):a.push(g);const c=(g,d=!1)=>{const y=[];for(let A=0;A<s.length;A++){const C=s[A],p=C.fullTrace.filter(h=>g.has(h.fullType));if(p.length===0)if(d)y.push({label:"Unlabeled",value:C.value});else return;const m=p.map(h=>h.label),P=n.separator??" / ";y.push({label:m.join(P),value:C.value})}return y};if(o.length===0){if(a.length!==0)throw new Error("Non-empty secondary types list while main types list is empty.");return c(new Set(ve),!0)}let f=0,v=-1;for(;f<o.length;){const g=new Set;n.includeNativeLabel&&g.add(ve);for(let y=0;y<f;++y)g.add(o[y]);v>=0&&g.add(o[v]);const d=c(g);if(d!==void 0&&new Set(d.map(y=>y.label)).size===t.length)return d;v++,v>=o.length&&(f++,v=f)}return c(new Set([...o,...a]),!0)}const ee="PColumnData/",X=ee+"ResourceMap",Q=ee+"Partitioned/ResourceMap",$=ee+"JsonPartitioned",j=ee+"BinaryPartitioned",De=ee+"Partitioned/",Z=De+"JsonPartitioned",U=De+"BinaryPartitioned";function Fe(t,e,n,r=[],i){if(t===void 0)return!1;switch(t.resourceType.name){case X:{let s=t.getInputsLocked();for(const o of t.listInputFields()){const a=t.resolve({field:o,assertFieldType:"Input"}),l=[...r,...JSON.parse(o)],c=a===void 0?void 0:e(a);c===void 0&&(s=!1),(c!==void 0||i)&&n.push({key:l,value:c})}return s}case Q:{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)],c=Fe(a,e,n,l,i);s=s&&c}}return s}default:throw new Error(`Unknown resource type: ${t.resourceType.name}`)}}function Kt(t,e,n=!1){const r=[];return{isComplete:Fe(t,e,r,[],n),data:r}}const de=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 ke(t){if(!t)return;const e=t.resourceType.name,n=t.getDataAsJson(),r=[];let i=0;switch(e){case X:i=n.keyLength;break;case Q:i=n.partitionKeyLength+n.keyLength;break;case $:case j:i=n.partitionKeyLength;break;case U:case Z:i=n.superPartitionKeyLength+n.partitionKeyLength;break}switch(e){case X:case $:case j:for(let s of t.listInputFields()){e===j&&(s=de(s).baseKey);const o=[...JSON.parse(s)];r.push(o)}break;case Q:case U:case Z: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===U&&(l=de(l).baseKey);const c=[...o,...JSON.parse(l)];r.push(c)}}break}return{data:r,keyLength:i}}function Jt(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 je(t){if(t===void 0)return;if(u.isDataInfoEntries(t))return Jt(t);const e=ke(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 se(t,e=[]){if(t===void 0||!t.getIsReadyOrError())return;const n=t.resourceType.name,r=t.getDataAsJson();if(e.length>0&&(n===Z||n===U))throw new Error(`Unexpected nested super-partitioned resource: ${n}`);switch(n){case X:case Q:throw new Error(`Only data columns are supported, got: ${n}`);case $:{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 j:{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=de(o),l=t.resolve({field:o,assertFieldType:"Input"});if(l===void 0)return;let c=s.get(a.baseKey);c||(c={},s.set(a.baseKey,c)),a.type==="index"?c.index=l:c.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 Z:{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!==$)throw new Error(`Expected ${$} inside ${n}, but got ${a.resourceType.name}`);const l=se(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 U:{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!==j)throw new Error(`Expected ${j} inside ${n}, but got ${a.resourceType.name}`);const l=se(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 Ve(t){if(t!==void 0){if(u.isDataInfoEntries(t))return t;if(u.isDataInfo(t))return u.dataInfoToEntries(t);if(t instanceof L)return se(t);throw new Error(`Unexpected input type: ${typeof t}`)}}function Ne(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}}}}class $t{constructor(e){this.columns=e}selectColumns(e){const n=typeof e=="function"?e:u.selectorsToPredicate(e);return this.columns.filter(r=>n(r.spec))}}function Ut(t){if(t)return t.map(e=>({type:`split:${u.canonicalizeAxisId(e.axisId)}`,label:e.label,importance:1e6}))}function Bt(t){if(t)return t.map(e=>[e.axisIdx,e.value])}function Mt(t,e){if(!e||e.length===0)return t;const n=[...e].sort((r,i)=>r[0]-i[0]);return Ce({id:t,axisFilters:n})}function Wt(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 Gt(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 oe{constructor(){O(this,"defaultProviderStore",[]);O(this,"providers",[new $t(this.defaultProviderStore)]);O(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}=n??{},a={...o&&(i==null?void 0:i.includeNativeLabel)!==!1?{includeNativeLabel:!0}:{},...i??{}},l=typeof e=="function"?[e]:Array.isArray(e)?e:[e],c=[],f=new Set;for(const d of l){const y=Wt(d);let A;if(y){if(!r)throw new Error("Anchored selectors require an AnchoredIdDeriver to be provided in options.");A=u.resolveAnchors(r.anchors,d,n)}else A=d;const C=new Set,p=[];for(const h of this.providers){const S=h.selectColumns(A);for(const I of S){if(C.has(I.id))throw new Error(`Duplicate column id ${I.id} in provider ${h.constructor.name}`);const R=u.deriveNativeId(I.spec);f.has(R)||(C.add(I.id),f.add(R),p.push(I))}}if(p.length===0)continue;const m=Gt(d),P=m.length>0;for(const h of p){if(!u.isPColumnSpec(h.spec))continue;const S=h.spec;if(P){const I=Ve(h.data);if(!I){if(s)continue;return}if(!u.isPartitionedDataInfoEntries(I))throw new Error(`Splitting requires Partitioned DataInfoEntries, but parsing resulted in ${I.type} for column ${h.id}`);const R=je(I),M=m[m.length-1];if(M>=I.partitionKeyLength)throw new Error(`Not enough partition keys (${I.partitionKeyLength}) for requested split axes (max index ${M}) in column ${S.name}`);const E=m.map(_=>this.findLabels(u.getAxisId(S.axesSpec[_]))),D=[],te=(_,W)=>{if(W>=m.length){if(D.push([..._]),D.length>1e4)throw new Error("Too many key combinations, aborting.");return}const k=m[W];if(k>=R.length)throw new Error(`Axis index ${k} out of bounds for unique keys array (length ${R.length}) during split key generation for column ${h.id}`);const N=R[k];if(!N||N.length===0){D.length=0;return}for(const ne of N)_.push(ne),te(_,W+1),_.pop()};if(te([],0),D.length===0)continue;const V=[...S.axesSpec],F=m.map(_=>_);for(let _=m.length-1;_>=0;_--)V.splice(m[_],1);const Xe={...S,axesSpec:V};for(const _ of D){const W=_.map((k,N)=>{const ne=F[N],Qe=u.getAxisId(S.axesSpec[ne]),ae=E[N],Ze=(ae==null?void 0:ae[k])??String(k);return{axisIdx:ne,axisId:Qe,value:k,label:Ze}});c.push({type:"split",originalColumn:h,spec:S,adjustedSpec:Xe,dataEntries:I,axisFilters:W})}}else c.push({type:"direct",originalColumn:h,spec:S,adjustedSpec:S})}}if(c.length===0)return[];const v=he(c,d=>({spec:d.spec,suffixTrace:d.type==="split"?Ut(d.axisFilters):void 0}),a),g=[];for(const{value:d,label:y}of v){const{originalColumn:A,spec:C}=d,p=d.type==="split"?d.axisFilters:void 0,m=Bt(p);let P;r?P=r.deriveS(C,m):P=Mt(A.id,m);let h={...d.adjustedSpec};o&&(h={...h,annotations:{...h.annotations??{},"pl7.app/label":y}}),g.push({id:P,spec:h,data:()=>d.type==="split"?u.entriesToDataInfo(Ne(d.dataEntries,m)):d.originalColumn.data,label:y})}return g}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 ue(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 Ae(t){return u.mapPObjectData(t,e=>e instanceof L?e.handle:u.isDataInfo(e)?u.mapDataInfo(e,n=>n.handle):e)}class Ke{constructor(){O(this,"ctx",b())}calculateOptions(e){return this.ctx.calculateOptions(e)}getOptions(e,n){const r=typeof e=="function"?e:u.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"?he(i,a=>a.obj,s??{}).map(({value:{ref:a},label:l})=>({ref:u.withEnrichments(a,o),label:l})):i.map(({ref:a,obj:l})=>({ref:u.withEnrichments(a,o),label:s(l,a)}))}resolveAnchorCtx(e){if(e instanceof u.AnchoredIdDeriver)return e;const n={};for(const[r,i]of Object.entries(e))if(u.isPlRef(i)){const s=this.getPColumnSpecByRef(i);if(!s)return;n[r]=s}else n[r]=i;return new u.AnchoredIdDeriver(n)}getAnchoredPColumns(e,n,r){const i=this.resolveAnchorCtx(e);if(i)return new oe().addColumnProvider(this).addAxisLabelProvider(this).getColumns(n,{...r,anchorCtx:i})}getCanonicalOptions(e,n,r){const i=this.resolveAnchorCtx(e);if(!i)return;const s=new oe().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:u.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 u.mapPObjectData(n,i=>new L(i,[e.blockId,e.name]))}getPColumnByRef(e){const n=this.getDataByRef(e);if(n)return u.ensurePColumn(n)}getPColumnSpecByRef(e){const n=this.getSpecByRef(e);if(n){if(!u.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(!u.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&&ue(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||!ue(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(!u.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&&ue(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:u.selectorsToPredicate(e);return this.getSpecs().entries.filter(({obj:i})=>u.isPColumnSpec(i)?n(i):!1).map(({ref:i,obj:s})=>{const o=s;let a=null;const l=this;return{id:Ce(i),spec:o,get data(){var c;return a!==null||(a=(c=l.getPColumnByRef(i))==null?void 0:c.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 z{constructor(){O(this,"ctx");O(this,"args");O(this,"uiState");O(this,"_activeArgsCache");O(this,"resultPool",new Ke);this.ctx=b(),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 ie(this.ctx.getAccessorHandleByName(e),n=>new L(n,[e]))}get prerun(){return this.getNamedAccessor(Se)}get outputs(){return this.getNamedAccessor(_e)}findLabels(e){return this.resultPool.findLabels(e)}verifyInlineAndExplicitColumnsSupport(e){var i;const n=e.some(s=>!(s.data instanceof L)||u.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=>Ae(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(u.extractAllColumns(n.src)),this.ctx.createPTable(u.mapPTableDef(n,r=>Ae(r)))}getBlockLabel(e){return this.ctx.getBlockLabel(e)}getCurrentUnstableMarker(){return this.ctx.getCurrentUnstableMarker()}}const q="1.30.24";function Je(t){return t.__renderLambda===!0}function re(t){if(t!==void 0)return Je(t)?t.handle:t}function K(t){if(t!==void 0)return typeof t=="string"?{__renderLambda:!0,handle:t,retentive:!1}:t}function zt(t){if(t.v3!==void 0){const{initialArgs:e,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:o,sections:a,title:l,enrichmentTargets:c}=t.v3,{code:f}=t;return{initialArgs:e,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:o,sections:a,title:l,code:f,enrichmentTargets:c}}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(([c,f])=>[c,K(f)])),inputsValid:K(i),sections:K(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(([c,f])=>[c,K(f)])),inputsValid:K(n),sections:K(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 T{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 T(e,void 0,{},{},H(!0),H([]),void 0,void 0)}output(e,n,r={}){if(typeof n=="function"){const i=`output#${e}`;return G(i,()=>n(new z)),new T(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 T(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"?(G("inputsValid",()=>e(new z)),new T(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title,this._enrichmentTargets)):new T(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,e,this._sections,this._title,this._enrichmentTargets)}sections(e){return Array.isArray(e)?this.sections(H(e)):typeof e=="function"?(G("sections",()=>e(new z)),new T(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title,this._enrichmentTargets)):new T(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,e,this._title,this._enrichmentTargets)}title(e){return G("title",()=>e(new z)),new T(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"},this._enrichmentTargets)}initialArgs(e){return new T(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}withArgs(e){return new T(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}withUiState(e){return new T(this._renderingMode,this._initialArgs,e,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}enriches(e){return G("enrichmentTargets",e),new T(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:q,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:q,renderingMode:this._renderingMode,initialArgs:this._initialArgs,inputsValid:re(this._inputsValid),sections:re(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,re(r)]))};return Et()?xe({sdkVersion:q}):{config:e}}}function Ht(t){const e=t.type;switch(e){case"axis":return u.canonicalizeJson(t);case"column":return u.canonicalizeJson(t);default:throw Error(`unsupported column type: ${e}`)}}function $e(t){return JSON.parse(t)}function Ue(t){return t.axesSpec.length===1&&t.name==="pl7.app/label"}function ge(t){return new oe().addAxisLabelProvider(t).addColumnProvider(t).getColumns({name:"pl7.app/label",axes:[{}]},{dontWaitAllData:!0})}function me(t,e){const n=[],r=[];for(const a of t)Ue(a.spec)?n.push(a):r.push(a);const i=[];for(const a of r)for(const l of a.spec.axesSpec){const c=u.getAxisId(l);i.some(f=>u.matchAxisId(f,c))||i.push(c)}for(const a of n){const l=u.getAxisId(a.spec.axesSpec[0]),c=i.findIndex(f=>u.matchAxisId(f,l));c!==-1&&i.splice(c,1)}const s=(a,l)=>{let c=a.toString();if(l)for(const f in l)c+=f,c+=l[f];return c},o=[];for(const a of e){const l=a.spec.axesSpec[0],c=u.getAxisId(l),f=i.findIndex(v=>u.matchAxisId(v,c));if(f!==-1){const v=i[f],g=Object.keys(v.domain??{}).length,d=Object.keys(l.domain??{}).length;g>d?o.push({id:s(a.id,v.domain),spec:{...a.spec,axesSpec:[{...v,annotations:l.annotations}]},data:a.data}):o.push(a),i.splice(f,1)}}return o}function ye(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 Be(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 qt(t,e,n,r){var c,f;Array.isArray(r)&&(r={filters:r});const i=(r==null?void 0:r.coreJoinType)??"full",s=[...(r==null?void 0:r.filters)??[],...((c=n==null?void 0:n.pTableParams)==null?void 0:c.filters)??[]],o=((f=n==null?void 0:n.pTableParams)==null?void 0:f.sorting)??[],a=ge(t.resultPool);if(!a)return;const l=me(e.map(u.getColumnIdAndSpec),a);if(ye([...e,...l]))return t.createPTable(Be(e,l,i,s,o,r==null?void 0:r.coreColumnPredicate))}function Me(t){var e;return((e=t.annotations)==null?void 0:e["pl7.app/table/visibility"])==="optional"}function Yt(t,e,n,r,i){var A,C;const s=(i==null?void 0:i.coreJoinType)??"full",o=[...(i==null?void 0:i.filters)??[],...((A=r==null?void 0:r.pTableParams)==null?void 0:A.filters)??[]],a=((C=r==null?void 0:r.pTableParams)==null?void 0:C.sorting)??[],l=e.find(p=>n(p.spec));if(!l)return;const c=ge(t.resultPool);if(!c)return;const f=new Set((()=>{var m,P;if(s==="inner")return[];const p=(P=(m=r==null?void 0:r.gridState.columnVisibility)==null?void 0:m.hiddenColIds)==null?void 0:P.map($e).filter(h=>h.type==="column").map(h=>h.id);return p||e.filter(h=>Me(h.spec)).map(h=>h.id)})());f.delete(l.id),[...o.map(p=>p.column),...a.map(p=>p.column)].filter(p=>p.type==="column").map(p=>f.delete(p.id));const v=e.filter(p=>!f.has(p.id)),g=me(v.map(u.getColumnIdAndSpec),c),d=[...l.spec.axesSpec.map(p=>({type:"axis",id:u.getAxisId(p),spec:p})),...[...e,...g].map(p=>({type:"column",id:p.id,spec:p.spec}))];if(!ye([...v,...g]))return;const y=t.createPTable(Be(e,g,s,o,a,i==null?void 0:i.coreColumnPredicate));return{tableSpec:d,tableHandle:y}}function Xt(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 Qt=(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 Zt(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 en(t,e){const n=t.axesSpec.map(u.getAxisId);return e.axesSpec.map(u.getAxisId).every(i=>n.some(s=>u.matchAxisId(s,i)&&u.matchAxisId(i,s)))}function We(t,e){const n=t.axesSpec.map(u.getAxisId);return e.axesSpec.map(u.getAxisId).every(i=>n.some(s=>u.matchAxisId(s,i)))}const Ge="pl7.app/graph/isVirtual",pe="pl7.app/label";function Pe(t,e){const n=t.spec.axesSpec.map(u.getAxisId),r=e.spec.axesSpec.map(u.getAxisId);if(en(t.spec,e.spec))return[];if(!We(t.spec,e.spec))return[];const o=r.map(v=>n.filter(g=>u.matchAxisId(g,v))),a=Zt(o),l=new Set,c=new Set,f=a.map(v=>{const g=new Set;return v.map((d,y)=>{const A=e.spec.axesSpec[y].domain,C=d.domain;return Object.entries(C??{}).forEach(([p,m])=>{if((A==null?void 0:A[p])===void 0){const P=JSON.stringify([p,m]);g.add(P),l.add(P)}}),{...d,annotations:e.spec.axesSpec[y].annotations}}),g});return[...l].forEach(v=>{f.some(g=>!g.has(v))&&c.add(v)}),a.map((v,g)=>{var p;const d=Qt(e.id,v.map(m=>m.domain)),y=((p=e.spec.annotations)==null?void 0:p[pe])??"",A=[...f[g]].filter(m=>c.has(m)).sort().map(m=>{var P;return(P=JSON.parse(m))==null?void 0:P[1]}).join(" / "),C={...e.spec.annotations,[Ge]:"true"};return(y||A)&&(C[pe]=y&&A?y+" / "+A:y+A),{id:d,spec:{...e.spec,axesSpec:v.map((m,P)=>({...m,annotations:e.spec.axesSpec[P].annotations})),annotations:C},data:e.data}})}function ze(t){const e=[];for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){const i=t[n],s=t[r];e.push(...Pe(i,s),...Pe(s,i))}return e}function He(t,e){const n=new Set,r=new Map;t.forEach(s=>{n.add(s.id),r.set(u.canonicalizeJson(u.getPColumnSpecId(s.spec)),s)});const i=new Map;for(const s of e){if(n.has(s.id))continue;const o=u.canonicalizeJson(u.getPColumnSpecId(s.spec));if(!r.has(o)){for(const a of r.values())if(We(a.spec,s.spec)){i.set(o,s);break}}}return[...r.values(),...i.values()]}function tn(t,e){if(!e)return;const n=t.resultPool.getData().entries.map(s=>s.obj).filter(u.isPColumn),r=He(e,n),i=[...r,...ze(r)];if(!i.some(s=>s.data instanceof L&&!s.data.getIsReadyOrError()))return t.createPFrame(i)}class nn{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){return await platforma.pFrameDriver.calculateTableData(this.handle,e)}async getUniqueValues(e){return await platforma.pFrameDriver.getUniqueValues(this.handle,e)}}function qe(t){return fe({__isRef:!0,blockId:Y(t,"blockId"),name:Y(t,"name")})}function rn(t){return fe({ref:qe(Y(t,"ref")),label:Y(t,"label")})}const sn={sdkVersion:q};function Ye(){return xe({sdkVersion:q})}function on(t){try{return Ye()}catch{return t}}function an(t){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(t)}exports.Args=it;exports.BlockModel=T;exports.CurrentSdkInfo=sn;exports.FutureRef=x;exports.IS_VIRTUAL_COLUMN=Ge;exports.It=st;exports.JsRenderInternal=jt;exports.LABEL_ANNOTATION=pe;exports.MainOutputs=ot;exports.OutputError=we;exports.PAnnotationLabel=Le;exports.PAnnotationTrace=Oe;exports.PColumnCollection=oe;exports.PFrameImpl=nn;exports.RT_BINARY_PARTITIONED=j;exports.RT_BINARY_SUPER_PARTITIONED=U;exports.RT_JSON_PARTITIONED=$;exports.RT_JSON_SUPER_PARTITIONED=Z;exports.RT_RESOURCE_MAP=X;exports.RT_RESOURCE_MAP_PARTITIONED=Q;exports.RenderCtx=z;exports.ResultPool=Ke;exports.StagingOutputs=at;exports.Trace=Re;exports.TraceEntry=Ee;exports.TreeNodeAccessor=L;exports.UiState=lt;exports.allColumnsComputed=ye;exports.and=gt;exports.convertOrParsePColumnData=Ve;exports.createPFrameForGraphs=tn;exports.createPlDataTable=qt;exports.createPlDataTableSheet=Xt;exports.createPlDataTableV2=Yt;exports.deriveLabels=he;exports.downgradeCfgOrLambda=re;exports.enrichColumnsWithCompatible=He;exports.extractArchiveAndGetURL=xt;exports.extractConfig=zt;exports.filterDataInfoEntries=Ne;exports.flatten=pt;exports.fromPlOption=rn;exports.fromPlRef=qe;exports.getAdditionalColumns=ze;exports.getAllLabelColumns=ge;exports.getBlobContent=At;exports.getBlobContentAsJson=Ct;exports.getBlobContentAsString=Pt;exports.getDownloadedBlobContent=wt;exports.getEnvironmentValue=an;exports.getFromCfg=B;exports.getImmediate=H;exports.getImportProgress=St;exports.getJsonField=Y;exports.getLastLogs=_t;exports.getLogHandle=Ot;exports.getMatchingLabelColumns=me;exports.getOnDemandBlobContent=It;exports.getPartitionKeysList=ke;exports.getPlatformaOrDefault=on;exports.getProgressLog=Tt;exports.getProgressLogWithInfo=Lt;exports.getRawPlatformaInstance=Ye;exports.getResourceField=yt;exports.getResourceValueAsJson=bt;exports.getUniquePartitionKeys=je;exports.ifDef=ie;exports.isColumnOptional=Me;exports.isConfigLambda=Je;exports.isEmpty=ft;exports.isLabelColumn=Ue;exports.isolate=rt;exports.makeArray=ut;exports.makeObject=fe;exports.mapArrayValues=dt;exports.mapRecordValues=ct;exports.mapResourceFields=vt;exports.not=ht;exports.or=mt;exports.parsePColumnData=se;exports.parsePTableColumnId=$e;exports.parseResourceMap=Kt;exports.readOutput=Ie;exports.stringifyPTableColumnId=Ht;exports.wrapOutputs=nt;Object.keys(u).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>u[t]})});Object.keys(be).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>be[t]})});
|
|
1
|
+
"use strict";var rt=Object.defineProperty;var it=(t,e,n)=>e in t?rt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var D=(t,e,n)=>it(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@milaboratories/pl-model-common"),Ie=require("canonicalize"),U=require("zod"),ve=require("@milaboratories/pl-error-like");class xe 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 xe(t.errors,t.moreErrors);return t.value}function st(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 ot(t){return{type:"Isolate",cfg:t}}const at=W("$args"),lt=W("$it"),ut=W("$prod"),ct=W("$staging"),dt=W("$ui");function Y(t){return{type:"Immediate",value:t}}function he(t){const e={};for(const[n,r]of Object.entries(t))e[n]=x(r);return{type:"MakeObject",template:e}}function pt(...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 ft(t,e,n="$it"){return{type:"MapRecordValues",source:t,mapping:e,itVar:n}}function ht(t,e,n="$it"){return{type:"MapArrayValues",source:t,mapping:e,itVar:n}}function gt(t){return{type:"Flatten",source:t}}function mt(t){return{type:"IsEmpty",arg:t}}function yt(t){return{type:"Not",operand:t}}function bt(t,e){return{type:"And",operand1:t,operand2:e}}function vt(t,e){return{type:"Or",operand1:t,operand2:e}}function At(t,e){return{type:"GetResourceField",source:x(t),field:x(e)}}function Pt(){return function(t){return{type:"GetResourceValueAsJson",source:x(t)}}}function Ct(t,e,n="$it"){return{type:"MapResourceFields",source:t,mapping:e,itVar:n}}function wt(t){return{type:"GetBlobContent",source:x(t)}}function It(t){return{type:"GetBlobContentAsString",source:x(t)}}function xt(){return function(t){return{type:"GetBlobContentAsJson",source:x(t)}}}function St(t){return{type:"GetDownloadedBlobContent",source:x(t)}}function _t(t){return{type:"GetOnDemandBlobContent",source:x(t)}}function Tt(t,e){return{type:"ExtractArchiveAndGetURL",format:e,source:x(t)}}function Lt(t){return{type:"GetImportProgress",source:x(t)}}function Et(t,e){return{type:"GetLastLogs",source:x(t),lines:e}}function Ot(t,e){return{type:"GetProgressLog",source:x(t),patternToSearch:e}}function Rt(t,e){return{type:"GetProgressLogWithInfo",source:x(t),patternToSearch:e}}function Dt(t){return{type:"GetLogHandle",source:x(t)}}function Ft(){return typeof globalThis.getPlatforma<"u"||typeof globalThis.platforma<"u"}function _e(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 kt(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx}function h(){if(typeof globalThis.cfgRenderCtx<"u")return globalThis.cfgRenderCtx;throw new Error("Not in config rendering context")}function z(t,e){const n=kt();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 ue=new Map;function jt(t,e){t in h().callbackRegistry||(h().callbackRegistry[t]=n=>{for(const r of ue.get(t))r(n)},ue.set(t,[])),ue.get(t).push(e)}class _{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 _(this.handle,n=>e(this.postProcess(n)))}mapDefined(e){return new _(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 se(t,e){return t===void 0?void 0:e(t)}class E{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 se(h().resolveWithCommon(this.handle,e,...n),i=>new E(i,r))}get resourceType(){return h().getResourceType(this.handle)}getInputsLocked(){return h().getInputsLocked(this.handle)}getOutputsLocked(){return h().getOutputsLocked(this.handle)}getIsReadyOrError(){return h().getIsReadyOrError(this.handle)}getIsFinal(){return h().getIsFinal(this.handle)}getError(){const e=[...this.resolvePath,"error"];return se(h().getError(this.handle),n=>new E(n,e))}listInputFields(){return h().listInputFields(this.handle)}listOutputFields(){return h().listOutputFields(this.handle)}listDynamicFields(){return h().listDynamicFields(this.handle)}getKeyValueBase64(e){return h().getKeyValueBase64(this.handle,e)}getKeyValueAsString(e){return h().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 h().getDataBase64(this.handle)}getDataAsString(){return h().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(!u.isPColumn(s))throw new Error(`not a PColumn (kind = ${s.spec.kind})`);return s})}parsePObjectCollection(e=!1,n=""){const r=h().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]=u.mapPObjectData(o,l=>new E(l,a))}return i}getFileContentAsBase64(){return new _(h().getBlobContentAsBase64(this.handle))}getFileContentAsString(){return new _(h().getBlobContentAsString(this.handle))}getFileContentAsJson(){return new _(h().getBlobContentAsString(this.handle)).mapDefined(e=>JSON.parse(e))}getBlobContentAsBase64(){return this.getFileContentAsBase64()}getBlobContentAsString(){return this.getFileContentAsString()}getFileHandle(){return new _(h().getDownloadedBlobContentHandle(this.handle))}getDownloadedBlobHandle(){return this.getFileHandle()}getRemoteFileHandle(){return new _(h().getOnDemandBlobContentHandle(this.handle))}getOnDemandBlobHandle(){return this.getRemoteFileHandle()}extractArchiveAndGetURL(e){return new _(h().extractArchiveAndGetURL(this.handle,e))}getImportProgress(){return new _(h().getImportProgress(this.handle))}getLastLogs(e){return new _(h().getLastLogs(this.handle,e))}getProgressLog(e){return new _(h().getProgressLog(this.handle,e))}getProgressLogWithInfo(e){return new _(h().getProgressLogWithInfo(this.handle,e))}getLogHandle(){return new _(h().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(c=>[c,this.resolve({field:c,assertFieldType:r})]);return s&&(l=l.filter(c=>c[1]!==void 0)),l.map(([c,f])=>o(c,f))}}const Te="staging",Le="main",Vt={explicitColumnsSupport:!0,inlineColumnsSupport:!0,activeArgs:!0};function Ee(t){return typeof t=="object"&&t!==null&&"__awaited_futures__"in t}function de(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)de(t,e,i);else for(const[,i]of Object.entries(n))i!==n&&de(t,e,i)}function Nt(t){const e=new Set;return de(e,new Set,t),e}const Kt=Object.freeze(Object.defineProperty({__proto__:null,GlobalCfgRenderCtxFeatureFlags:Vt,MainAccessorName:Le,StagingAccessorName:Te,getAllFutureAwaits:Nt,isFutureAwait:Ee},Symbol.toStringTag,{value:"Module"})),Oe="pl7.app/label",Re="pl7.app/trace",De=U.z.object({type:U.z.string(),importance:U.z.number().optional(),id:U.z.string().optional(),label:U.z.string()}),Fe=U.z.array(De),Jt=.001,$t="__LABEL__",Ae="__LABEL__@1";function ge(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(m=>{var S,F;const y=e(m);let d,b,p;"spec"in y&&typeof y.spec=="object"?(d=y.spec,b=y.prefixTrace,p=y.suffixTrace):d=y;const A=(S=d.annotations)==null?void 0:S[Oe],C=(F=d.annotations)==null?void 0:F[Re],v=(C?Fe.safeParse(JSON.parse(C)).data:void 0)??[],I=[...b??[],...v,...p??[]];if(A!==void 0){const R={label:A,type:$t,importance:-2};n.addLabelAsSuffix?I.push(R):I.splice(0,0,R)}const w=[],O=new Map;for(let R=I.length-1;R>=0;--R){const{type:G}=I[R],j=I[R].importance??0,K=(O.get(G)??0)+1;O.set(G,K);const k=`${G}@${K}`;s.set(k,(s.get(k)??0)+1),r.set(k,Math.max(r.get(k)??Number.NEGATIVE_INFINITY,j-(I.length-R)*Jt)),w.push({...I[R],fullType:k,occurrenceIndex:K})}return w.reverse(),{value:m,spec:d,label:A,fullTrace:w}}),a=[],l=[],c=[...r];c.sort(([,m],[,y])=>y-m);for(const[m]of c)m.endsWith("@1")||s.get(m)===t.length?a.push(m):l.push(m);const f=(m,y=!1)=>{const d=[];for(let b=0;b<o.length;b++){const p=o[b],A=p.fullTrace.filter(I=>m.has(I.fullType)||i&&i.has(I.type));if(A.length===0)if(y)d.push({label:"Unlabeled",value:p.value});else return;const C=A.map(I=>I.label),v=n.separator??" / ";d.push({label:C.join(v),value:p.value})}return d};if(a.length===0){if(l.length!==0)throw new Error("Non-empty secondary types list while main types list is empty.");return f(new Set(Ae),!0)}let g=0,P=-1;for(;g<a.length;){const m=new Set;n.includeNativeLabel&&m.add(Ae);for(let d=0;d<g;++d)m.add(a[d]);P>=0&&m.add(a[P]);const y=f(m);if(y!==void 0&&new Set(y.map(d=>d.label)).size===t.length)return y;P++,P>=a.length&&(g++,P=g)}return f(new Set([...a,...l]),!0)}const ne="PColumnData/",Z=ne+"ResourceMap",ee=ne+"Partitioned/ResourceMap",B=ne+"JsonPartitioned",N=ne+"BinaryPartitioned",ke=ne+"Partitioned/",te=ke+"JsonPartitioned",M=ke+"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)],c=a===void 0?void 0:e(a);c===void 0&&(s=!1),(c!==void 0||i)&&n.push({key:l,value:c})}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)],c=je(a,e,n,l,i);s=s&&c}}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 pe=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 Ve(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 B:case N:i=n.partitionKeyLength;break;case M:case te:i=n.superPartitionKeyLength+n.partitionKeyLength;break}switch(e){case Z:case B:case N:for(let s of t.listInputFields()){e===N&&(s=pe(s).baseKey);const o=[...JSON.parse(s)];r.push(o)}break;case ee:case M: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===M&&(l=pe(l).baseKey);const c=[...o,...JSON.parse(l)];r.push(c)}}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 Ne(t){if(t===void 0)return;if(u.isDataInfoEntries(t))return Bt(t);const e=Ve(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 oe(t,e=[]){if(t===void 0||!t.getIsReadyOrError())return;const n=t.resourceType.name,r=t.getDataAsJson();if(e.length>0&&(n===te||n===M))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 B:{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 N:{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=pe(o),l=t.resolve({field:o,assertFieldType:"Input"});if(l===void 0)return;let c=s.get(a.baseKey);c||(c={},s.set(a.baseKey,c)),a.type==="index"?c.index=l:c.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!==B)throw new Error(`Expected ${B} inside ${n}, but got ${a.resourceType.name}`);const l=oe(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 M:{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!==N)throw new Error(`Expected ${N} inside ${n}, but got ${a.resourceType.name}`);const l=oe(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(u.isDataInfoEntries(t))return t;if(u.isDataInfo(t))return u.dataInfoToEntries(t);if(t instanceof E)return oe(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}}}}class Mt{constructor(e){this.columns=e}selectColumns(e){const n=typeof e=="function"?e:u.selectorsToPredicate(e);return this.columns.filter(r=>n(r.spec))}}function Wt(t){if(t)return t.map(e=>({type:`split:${u.canonicalizeAxisId(e.axisId)}`,label:e.label,importance:1e6}))}function Gt(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 Ie({id:t,axisFilters:n})}function Pe(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 zt(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 ae{constructor(){D(this,"defaultProviderStore",[]);D(this,"providers",[new Mt(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 c=()=>!1;if(a){const d=(Array.isArray(a)?a:[a]).map(b=>{if(Pe(b)){if(!r)throw new Error("Anchored selectors in exclude require an AnchoredIdDeriver to be provided in options.");return u.selectorsToPredicate(u.resolveAnchors(r.anchors,b,n))}else return u.selectorsToPredicate(b)});c=b=>d.some(p=>p(b))}const f=typeof e=="function"?[e]:Array.isArray(e)?e:[e],g=[],P=new Set;for(const d of f){const b=Pe(d);let p;if(b){if(!r)throw new Error("Anchored selectors require an AnchoredIdDeriver to be provided in options.");p=u.resolveAnchors(r.anchors,d,n)}else p=d;const A=new Set,C=[];for(const w of this.providers){const O=w.selectColumns(p);for(const S of O){if(c(S.spec))continue;if(A.has(S.id))throw new Error(`Duplicate column id ${S.id} in provider ${w.constructor.name}`);const F=u.deriveNativeId(S.spec);P.has(F)||(A.add(S.id),P.add(F),C.push(S))}}if(C.length===0)continue;const v=zt(d),I=v.length>0;for(const w of C){if(!u.isPColumnSpec(w.spec))continue;const O=w.spec;if(I){const S=Ke(w.data);if(!S){if(s)continue;return}if(!u.isPartitionedDataInfoEntries(S))throw new Error(`Splitting requires Partitioned DataInfoEntries, but parsing resulted in ${S.type} for column ${w.id}`);const F=Ne(S),R=v[v.length-1];if(R>=S.partitionKeyLength)throw new Error(`Not enough partition keys (${S.partitionKeyLength}) for requested split axes (max index ${R}) in column ${O.name}`);const G=v.map(T=>this.findLabels(u.getAxisId(O.axesSpec[T]))),j=[],K=(T,q)=>{if(q>=v.length){if(j.push([...T]),j.length>1e4)throw new Error("Too many key combinations, aborting.");return}const V=v[q];if(V>=F.length)throw new Error(`Axis index ${V} out of bounds for unique keys array (length ${F.length}) during split key generation for column ${w.id}`);const J=F[V];if(!J||J.length===0){j.length=0;return}for(const re of J)T.push(re),K(T,q+1),T.pop()};if(K([],0),j.length===0)continue;const k=[...O.axesSpec],Ze=v.map(T=>T);for(let T=v.length-1;T>=0;T--)k.splice(v[T],1);const et={...O,axesSpec:k};for(const T of j){const q=T.map((V,J)=>{const re=Ze[J],tt=u.getAxisId(O.axesSpec[re]),le=G[J],nt=(le==null?void 0:le[V])??String(V);return{axisIdx:re,axisId:tt,value:V,label:nt}});g.push({type:"split",originalColumn:w,spec:O,adjustedSpec:et,dataEntries:S,axisFilters:q})}}else g.push({type:"direct",originalColumn:w,spec:O,adjustedSpec:O})}}if(g.length===0)return[];const m=ge(g,d=>({spec:d.spec,suffixTrace:d.type==="split"?Wt(d.axisFilters):void 0}),l),y=[];for(const{value:d,label:b}of m){const{originalColumn:p,spec:A}=d,C=d.type==="split"?d.axisFilters:void 0,v=Gt(C);let I;r?I=r.deriveS(A,v):I=qt(p.id,v);let w={...d.adjustedSpec};o&&(w={...w,annotations:{...w.annotations??{},"pl7.app/label":b}}),y.push({id:I,spec:w,data:()=>d.type==="split"?u.entriesToDataInfo(Je(d.dataEntries,v)):d.originalColumn.data,label:b})}return y}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 ce(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 Ce(t){return u.mapPObjectData(t,e=>e instanceof E?e.handle:u.isDataInfo(e)?u.mapDataInfo(e,n=>n.handle):e)}class $e{constructor(){D(this,"ctx",h())}calculateOptions(e){return this.ctx.calculateOptions(e)}getOptions(e,n){const r=typeof e=="function"?e:u.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"?ge(i,a=>a.obj,s??{}).map(({value:{ref:a},label:l})=>({ref:u.withEnrichments(a,o),label:l})):i.map(({ref:a,obj:l})=>({ref:u.withEnrichments(a,o),label:s(l,a)}))}resolveAnchorCtx(e){if(e instanceof u.AnchoredIdDeriver)return e;const n={};for(const[r,i]of Object.entries(e))if(u.isPlRef(i)){const s=this.getPColumnSpecByRef(i);if(!s)return;n[r]=s}else n[r]=i;return new u.AnchoredIdDeriver(n)}getAnchoredPColumns(e,n,r){const i=this.resolveAnchorCtx(e);if(i)return new ae().addColumnProvider(this).addAxisLabelProvider(this).getColumns(n,{...r,anchorCtx:i})}getCanonicalOptions(e,n,r){const i=this.resolveAnchorCtx(e);if(!i)return;const s=new ae().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 E(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:u.mapValueInVOE(n.obj.data,r=>new E(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 u.mapPObjectData(n,i=>new E(i,[e.blockId,e.name]))}getPColumnByRef(e){const n=this.getDataByRef(e);if(n)return u.ensurePColumn(n)}getPColumnSpecByRef(e){const n=this.getSpecByRef(e);if(n){if(!u.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(!u.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&&ce(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||!ce(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(!u.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&&ce(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:u.selectorsToPredicate(e);return this.getSpecs().entries.filter(({obj:i})=>u.isPColumnSpec(i)?n(i):!1).map(({ref:i,obj:s})=>{const o=s;let a=null;const l=this;return{id:Ie(i),spec:o,get data(){var c;return a!==null||(a=(c=l.getPColumnByRef(i))==null?void 0:c.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 H{constructor(){D(this,"ctx");D(this,"args");D(this,"uiState");D(this,"_activeArgsCache");D(this,"resultPool",new $e);this.ctx=h(),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 se(this.ctx.getAccessorHandleByName(e),n=>new E(n,[e]))}get prerun(){return this.getNamedAccessor(Te)}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 E)||u.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=>Ce(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(u.extractAllColumns(n.src)),this.ctx.createPTable(u.mapPTableDef(n,r=>Ce(r)))}getBlockLabel(e){return this.ctx.getBlockLabel(e)}getCurrentUnstableMarker(){return this.ctx.getCurrentUnstableMarker()}}const X="1.30.26";function Ue(t){return t.__renderLambda===!0}function ie(t){if(t!==void 0)return Ue(t)?t.handle:t}function $(t){if(t!==void 0)return typeof t=="string"?{__renderLambda:!0,handle:t,retentive:!1}:t}function Ht(t){if(t.v3!==void 0){const{initialArgs:e,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:o,sections:a,title:l,enrichmentTargets:c}=t.v3,{code:f}=t;return{initialArgs:e,initialUiState:n,inputsValid:r,outputs:i,renderingMode:s,sdkVersion:o,sections:a,title:l,code:f,enrichmentTargets:c}}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(([c,f])=>[c,$(f)])),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(([c,f])=>[c,$(f)])),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 L{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 L(e,void 0,{},{},Y(!0),Y([]),void 0,void 0)}output(e,n,r={}){if(typeof n=="function"){const i=`output#${e}`;return z(i,()=>n(new H)),new L(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 L(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"?(z("inputsValid",()=>e(new H)),new L(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,{__renderLambda:!0,handle:"inputsValid"},this._sections,this._title,this._enrichmentTargets)):new L(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"?(z("sections",()=>e(new H)),new L(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,{__renderLambda:!0,handle:"sections"},this._title,this._enrichmentTargets)):new L(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,e,this._title,this._enrichmentTargets)}title(e){return z("title",()=>e(new H)),new L(this._renderingMode,this._initialArgs,this._initialUiState,this._outputs,this._inputsValid,this._sections,{__renderLambda:!0,handle:"title"},this._enrichmentTargets)}initialArgs(e){return new L(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}withArgs(e){return new L(this._renderingMode,e,this._initialUiState,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}withUiState(e){return new L(this._renderingMode,this._initialArgs,e,this._outputs,this._inputsValid,this._sections,this._title,this._enrichmentTargets)}enriches(e){return z("enrichmentTargets",e),new L(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:ie(this._inputsValid),sections:ie(this._sections),outputs:Object.fromEntries(Object.entries(this._outputs).map(([n,r])=>[n,ie(r)]))};return Ft()?_e({sdkVersion:X}):{config:e}}}function Yt(t){const e=t.type;switch(e){case"axis":return u.canonicalizeJson(t);case"column":return u.canonicalizeJson(t);default:throw Error(`unsupported column type: ${e}`)}}function Be(t){return JSON.parse(t)}function Me(t){return t.axesSpec.length===1&&t.name==="pl7.app/label"}function me(t){return new ae().addAxisLabelProvider(t).addColumnProvider(t).getColumns({name:"pl7.app/label",axes:[{}]},{dontWaitAllData:!0})}function ye(t,e){const n=[],r=[];for(const a of t)Me(a.spec)?n.push(a):r.push(a);const i=[];for(const a of r)for(const l of a.spec.axesSpec){const c=u.getAxisId(l);i.some(f=>u.matchAxisId(f,c))||i.push(c)}for(const a of n){const l=u.getAxisId(a.spec.axesSpec[0]),c=i.findIndex(f=>u.matchAxisId(f,l));c!==-1&&i.splice(c,1)}const s=(a,l)=>{let c=a.toString();if(l)for(const f in l)c+=f,c+=l[f];return c},o=[];for(const a of e){const l=a.spec.axesSpec[0],c=u.getAxisId(l),f=i.findIndex(g=>u.matchAxisId(g,c));if(f!==-1){const g=i[f],P=Object.keys(g.domain??{}).length,m=Object.keys(l.domain??{}).length;P>m?o.push({id:s(a.id,g.domain),spec:{...a.spec,axesSpec:[{...g,annotations:l.annotations}]},data:a.data}):o.push(a),i.splice(f,1)}}return o}function be(t){const e=i=>Array.isArray(i),n=i=>i instanceof E,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 We(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 Xt(t,e,n,r){var c,f;Array.isArray(r)&&(r={filters:r});const i=(r==null?void 0:r.coreJoinType)??"full",s=[...(r==null?void 0:r.filters)??[],...((c=n==null?void 0:n.pTableParams)==null?void 0:c.filters)??[]],o=((f=n==null?void 0:n.pTableParams)==null?void 0:f.sorting)??[],a=me(t.resultPool);if(!a)return;const l=ye(e.map(u.getColumnIdAndSpec),a);if(be([...e,...l]))return t.createPTable(We(e,l,i,s,o,r==null?void 0:r.coreColumnPredicate))}function Ge(t){var e;return((e=t.annotations)==null?void 0:e["pl7.app/table/visibility"])==="optional"}function Qt(t,e,n,r,i){var d,b;const s=(i==null?void 0:i.coreJoinType)??"full",o=[...(i==null?void 0:i.filters)??[],...((d=r==null?void 0:r.pTableParams)==null?void 0:d.filters)??[]],a=((b=r==null?void 0:r.pTableParams)==null?void 0:b.sorting)??[],l=e.find(p=>n(p.spec));if(!l)return;const c=me(t.resultPool);if(!c)return;const f=new Set((()=>{var A,C;if(s==="inner")return[];const p=(C=(A=r==null?void 0:r.gridState.columnVisibility)==null?void 0:A.hiddenColIds)==null?void 0:C.map(Be).filter(v=>v.type==="column").map(v=>v.id);return p||e.filter(v=>Ge(v.spec)).map(v=>v.id)})());f.delete(l.id),[...o.map(p=>p.column),...a.map(p=>p.column)].filter(p=>p.type==="column").map(p=>f.delete(p.id));const g=e.filter(p=>!f.has(p.id)),P=ye(g.map(u.getColumnIdAndSpec),c),m=[...l.spec.axesSpec.map(p=>({type:"axis",id:u.getAxisId(p),spec:p})),...[...e,...P].map(p=>({type:"column",id:p.id,spec:p.spec}))];if(!be([...g,...P]))return;const y=t.createPTable(We(e,P,s,o,a,i==null?void 0:i.coreColumnPredicate));return{tableSpec:m,tableHandle:y}}function Zt(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 en=(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 tn(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 nn(t,e){const n=t.axesSpec.map(u.getAxisId);return e.axesSpec.map(u.getAxisId).every(i=>n.some(s=>u.matchAxisId(s,i)&&u.matchAxisId(i,s)))}function qe(t,e){const n=t.axesSpec.map(u.getAxisId);return e.axesSpec.map(u.getAxisId).every(i=>n.some(s=>u.matchAxisId(s,i)))}const ze="pl7.app/graph/isVirtual",fe="pl7.app/label";function we(t,e){const n=t.spec.axesSpec.map(u.getAxisId),r=e.spec.axesSpec.map(u.getAxisId);if(nn(t.spec,e.spec))return[];if(!qe(t.spec,e.spec))return[];const o=r.map(g=>n.filter(P=>u.matchAxisId(P,g))),a=tn(o),l=new Set,c=new Set,f=a.map(g=>{const P=new Set;return g.map((m,y)=>{const d=e.spec.axesSpec[y].domain,b=m.domain;return Object.entries(b??{}).forEach(([p,A])=>{if((d==null?void 0:d[p])===void 0){const C=JSON.stringify([p,A]);P.add(C),l.add(C)}}),{...m,annotations:e.spec.axesSpec[y].annotations}}),P});return[...l].forEach(g=>{f.some(P=>!P.has(g))&&c.add(g)}),a.map((g,P)=>{var p;const m=en(e.id,g.map(A=>A.domain)),y=((p=e.spec.annotations)==null?void 0:p[fe])??"",d=[...f[P]].filter(A=>c.has(A)).sort().map(A=>{var C;return(C=JSON.parse(A))==null?void 0:C[1]}).join(" / "),b={...e.spec.annotations,[ze]:"true"};return(y||d)&&(b[fe]=y&&d?y+" / "+d:y+d),{id:m,spec:{...e.spec,axesSpec:g.map((A,C)=>({...A,annotations:e.spec.axesSpec[C].annotations})),annotations:b},data:e.data}})}function He(t){const e=[];for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){const i=t[n],s=t[r];e.push(...we(i,s),...we(s,i))}return e}function Ye(t,e){const n=new Set,r=new Map;t.forEach(s=>{n.add(s.id),r.set(u.canonicalizeJson(u.getPColumnSpecId(s.spec)),s)});const i=new Map;for(const s of e){if(n.has(s.id))continue;const o=u.canonicalizeJson(u.getPColumnSpecId(s.spec));if(!r.has(o)){for(const a of r.values())if(qe(a.spec,s.spec)){i.set(o,s);break}}}return[...r.values(),...i.values()]}function rn(t,e){if(!e)return;const n=t.resultPool.getData().entries.map(s=>s.obj).filter(u.isPColumn),r=Ye(e,n),i=[...r,...He(r)];if(!i.some(s=>s.data instanceof E&&!s.data.getIsReadyOrError()))return t.createPFrame(i)}class sn{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){return await platforma.pFrameDriver.calculateTableData(this.handle,e)}async getUniqueValues(e){return await platforma.pFrameDriver.getUniqueValues(this.handle,e)}}function Xe(t){return he({__isRef:!0,blockId:Q(t,"blockId"),name:Q(t,"name")})}function on(t){return he({ref:Xe(Q(t,"ref")),label:Q(t,"label")})}const an={sdkVersion:X};function Qe(){return _e({sdkVersion:X})}function ln(t){try{return Qe()}catch{return t}}function un(t){if(typeof globalThis.getEnvironmentValue=="function")return globalThis.getEnvironmentValue(t)}exports.Args=at;exports.BlockModel=L;exports.CurrentSdkInfo=an;exports.FutureRef=_;exports.IS_VIRTUAL_COLUMN=ze;exports.It=lt;exports.JsRenderInternal=Kt;exports.LABEL_ANNOTATION=fe;exports.MainOutputs=ut;exports.OutputError=xe;exports.PAnnotationLabel=Oe;exports.PAnnotationTrace=Re;exports.PColumnCollection=ae;exports.PFrameImpl=sn;exports.RT_BINARY_PARTITIONED=N;exports.RT_BINARY_SUPER_PARTITIONED=M;exports.RT_JSON_PARTITIONED=B;exports.RT_JSON_SUPER_PARTITIONED=te;exports.RT_RESOURCE_MAP=Z;exports.RT_RESOURCE_MAP_PARTITIONED=ee;exports.RenderCtx=H;exports.ResultPool=$e;exports.StagingOutputs=ct;exports.Trace=Fe;exports.TraceEntry=De;exports.TreeNodeAccessor=E;exports.UiState=dt;exports.allColumnsComputed=be;exports.and=bt;exports.convertOrParsePColumnData=Ke;exports.createPFrameForGraphs=rn;exports.createPlDataTable=Xt;exports.createPlDataTableSheet=Zt;exports.createPlDataTableV2=Qt;exports.deriveLabels=ge;exports.downgradeCfgOrLambda=ie;exports.enrichColumnsWithCompatible=Ye;exports.extractArchiveAndGetURL=Tt;exports.extractConfig=Ht;exports.filterDataInfoEntries=Je;exports.flatten=gt;exports.fromPlOption=on;exports.fromPlRef=Xe;exports.getAdditionalColumns=He;exports.getAllLabelColumns=me;exports.getBlobContent=wt;exports.getBlobContentAsJson=xt;exports.getBlobContentAsString=It;exports.getDownloadedBlobContent=St;exports.getEnvironmentValue=un;exports.getFromCfg=W;exports.getImmediate=Y;exports.getImportProgress=Lt;exports.getJsonField=Q;exports.getLastLogs=Et;exports.getLogHandle=Dt;exports.getMatchingLabelColumns=ye;exports.getOnDemandBlobContent=_t;exports.getPartitionKeysList=Ve;exports.getPlatformaOrDefault=ln;exports.getProgressLog=Ot;exports.getProgressLogWithInfo=Rt;exports.getRawPlatformaInstance=Qe;exports.getResourceField=At;exports.getResourceValueAsJson=Pt;exports.getUniquePartitionKeys=Ne;exports.ifDef=se;exports.isColumnOptional=Ge;exports.isConfigLambda=Ue;exports.isEmpty=mt;exports.isLabelColumn=Me;exports.isolate=ot;exports.makeArray=pt;exports.makeObject=he;exports.mapArrayValues=ht;exports.mapRecordValues=ft;exports.mapResourceFields=Ct;exports.not=yt;exports.or=vt;exports.parsePColumnData=oe;exports.parsePTableColumnId=Be;exports.parseResourceMap=Ut;exports.readOutput=Se;exports.stringifyPTableColumnId=Yt;exports.wrapOutputs=st;Object.keys(u).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>u[t]})});Object.keys(ve).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>ve[t]})});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|