@hpcc-js/marshaller 3.2.1 → 3.2.3

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.
@@ -1,3 +1,101 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@hpcc-js/comms"),require("@hpcc-js/common"),require("@hpcc-js/util"),require("@hpcc-js/ddl-shim"),require("@hpcc-js/chart"),require("@hpcc-js/dgrid"),require("@hpcc-js/form"),require("@hpcc-js/graph"),require("@hpcc-js/map"),require("@hpcc-js/layout"),require("@hpcc-js/phosphor"),require("@hpcc-js/codemirror"),require("@hpcc-js/other")):"function"==typeof define&&define.amd?define(["exports","@hpcc-js/comms","@hpcc-js/common","@hpcc-js/util","@hpcc-js/ddl-shim","@hpcc-js/chart","@hpcc-js/dgrid","@hpcc-js/form","@hpcc-js/graph","@hpcc-js/map","@hpcc-js/layout","@hpcc-js/phosphor","@hpcc-js/codemirror","@hpcc-js/other"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@hpcc-js/marshaller"]={},e["@hpcc-js/comms"],e["@hpcc-js/common"],e["@hpcc-js/util"],e["@hpcc-js/ddl-shim"],e["@hpcc-js/chart"],e["@hpcc-js/dgrid"],e["@hpcc-js/form"],e["@hpcc-js/graph"],e["@hpcc-js/map"],e["@hpcc-js/layout"],e["@hpcc-js/phosphor"],e["@hpcc-js/codemirror"],e["@hpcc-js/other"])}(this,function(e,t,i,s,r,a,o,n,l,h,u,c,d,p){"use strict";var m,_=Object.defineProperty,f=(e,t)=>_(e,"name",{value:t,configurable:!0}),D=(e,t,i)=>((e,t,i)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);const v="@hpcc-js/marshaller",g="3.2.1",y="3.24.0";function b(e){if(Array.isArray(e))return"["+e.map(b).join(", ")+"]";if("object"!=typeof e||null==e)return JSON.stringify(e);return`{ ${Object.keys(e).map(t=>`${t}: ${b(e[t])}`).join(", ")} }`}function w(e){switch(e){case"boolean":return"boolean";case"xs:byte":case"xs:double":case"xs:decimal":case"xs:float":case"xs:int":case"xs:short":case"xs:unsignedInt":case"xs:unsignedShort":case"xs:unsignedByte":case"number":return"number";case"xs:integer":case"xs:long":case"xs:negativeInteger":case"xs:nonNegativeInteger":case"xs:nonPositiveInteger":case"xs:positiveInteger":case"xs:unsignedLong":return"number64";case"string":return"string";case"range":return"range"}return"string"}function F(e){return e._children&&e._children.length?{type:"dataset",id:e.name,children:e._children.map(F)}:{id:e.name,type:w(e.type)}}function x(e){return e}f(b,"stringify"),f(w,"schemaType2IFieldType"),f(F,"schemaRow2IField"),f(x,"wsEclSchemaRow2IField");const P=class _Activity extends i.PropertyExt{_sourceActivity;fixInt64(e){if(!e||0===e.length)return[];const t=this.outFields().filter(t=>{switch(t.type){case"number":return"number"!=typeof e[0][t.id];case"number64":return!0}return!1});return t.length?e.map(e=>{for(const i of t)e[i.id]=+e[i.id];return e}):e}sourceActivity(e){return arguments.length?(this._sourceActivity=e,this):this._sourceActivity}hash(e={}){return s.hashSum({...e})}refreshMeta(){return this._sourceActivity?this._sourceActivity.refreshMeta():Promise.resolve()}exists(){return!0}validate(){return[]}label(){return this.id()}updatedBy(){return[]}_emptyFields=[];inFields(){return this._sourceActivity?this._sourceActivity.outFields():this._emptyFields}computeFields(e){return()=>e}outFields(){return this.computeFields(this.inFields())()}localFields(){const e=this.inFields().map(e=>e.id);return this.outFields().filter(t=>e.indexOf(t.id)<0)}fieldOrigin(e){return this.localFields().filter(t=>t.id===e).length?this:this.sourceActivity()?this.sourceActivity().fieldOrigin(e):null}resolveFields(e,t){for(const i of t){const t=this.fieldOrigin(i);t&&(e.outputs[t.id()]||(e.outputs[t.id()]=[]),e.outputs[t.id()].indexOf(i)<0&&e.outputs[t.id()].push(i))}}resolveInFields(e,t){return this._sourceActivity&&this._sourceActivity.resolveFields(e,t)}referencedFields(e){this._sourceActivity?.referencedFields(e)}exec(){return this._sourceActivity?this._sourceActivity.exec():Promise.resolve()}_emptyData=[];inData(){return this._sourceActivity&&this._sourceActivity.outData()||this._emptyData}computeData(){return this.inData()}_prevDataHash="";_prevInData=[];_prevData=[];cachedComputeData(e){const t=this.hash();return this._prevDataHash===t&&this._prevInData===e||(this._prevDataHash=t,this._prevInData=e,this._prevData=s.update(this._prevData,this.computeData())),this._prevData}outData(){return this.cachedComputeData(this.inData())}};f(P,"Activity");let S=P;const L=class _ActivityArray extends S{_activities=[];activities(e){return arguments.length?(this._activities=e,this):this._activities}};f(L,"ActivityArray");let C=L;C.prototype._class+=" ActivityArray";const I=class _ActivityPipeline extends C{activities(e){if(!arguments.length)return super.activities();let t;super.activities(e);for(const i of e)t&&i.sourceActivity(t),t=i;return this}first(){return this.activities()[0]}last(){const e=this.activities();return e[e.length-1]}calcUpdatedGraph(e){return e.updatedBy().map(t=>({from:t,to:e}))}updatedByGraph(){let e=[];for(const t of this.activities())e=e.concat(this.calcUpdatedGraph(t));return e}fetch(e=0,t=Number.MAX_VALUE){return this.exec().then(()=>{const i=this.outData();return 0===e&&i.length<=t?i:i.slice(e,e+t)})}hash(e={}){return s.hashSum({activities:[this.activities().map(e=>e.hash())],...e})}refreshMeta(){return this.last().refreshMeta()}updatedBy(){let e=[];for(const t of this.activities())e=e.concat(t.updatedBy());return e}inFields(){return this.first().inFields()}outFields(){return this.last().outFields()}localFields(){return this.last().localFields()}fieldOrigin(e){return this.last().fieldOrigin(e)}referencedFields(e){this.last().referencedFields(e)}resolveInFields(e,t){this.last().resolveInFields(e,t)}resolveFields(e,t){this.last().resolveFields(e,t)}exec(){return this.last().exec()}outData(){return this.last().outData()}};f(I,"ActivityPipeline");let $=I;$.prototype._class+=" ActivitySequence";const R=class _ActivitySelection extends C{_selection;_monitorHandle;selection(e){return void 0===e?this._selection:(this._monitorHandle&&this._monitorHandle.remove(),this._selection=e,this._monitorHandle=e.monitor((t,i,s)=>{this.broadcast(t,i,s,e)}),this)}hash(e={}){return s.hashSum({selection:this.selection().hash(),...e})}label(){return this.selection().label()}refreshMeta(){return this.selection().refreshMeta()}updatedBy(){return this.selection().updatedBy()}inFields(){return this.selection().inFields()}outFields(){return this.selection().outFields()}localFields(){return this.selection().localFields()}fieldOrigin(e){return this.selection().fieldOrigin(e)}referencedFields(e){this.selection().referencedFields(e)}resolveInFields(e,t){this.selection().resolveInFields(e,t)}resolveFields(e,t){this.selection().resolveFields(e,t)}exec(){return this.selection().exec()}outData(){return this.selection().outData()}};f(R,"ActivitySelection");let E=R;E.prototype._class+=" ActivitySelection";let A=0;const z=class _Datasource extends S{constructor(){super(),this._id="ds_"+ ++A}};f(z,"Datasource");let B=z;const M=class _DatasourceRef extends S{_origDatasource;constructor(){super()}hash(e={}){return super.hash({datasource:this._datasource?this._datasource.hash(e):void 0,...e})}toDDL(){return{id:this.datasource().id()}}};f(M,"DatasourceRef");let j=M;j.prototype._class+=" DatasourceRef",j.prototype.publish("datasource",null,"widget","Datasource Reference",null,{internal:!0}),j.prototype._origDatasource=j.prototype.datasource,j.prototype.datasource=function(e){const t=j.prototype._origDatasource.apply(this,arguments);return void 0!==e&&this.sourceActivity(e),t};const k=class _FormField extends i.PropertyExt{_owner;disableChildField(){return"dataset"!==this.type()}constructor(){super()}toDDL(){return{type:this.type(),id:this.fieldID(),default:this.default(),children:"dataset"===this.type()?this.childFields().map(e=>e.toDDL()):void 0}}fromDDL(e){return this.type(e.type).fieldID(e.id).default(e.default).childFields("dataset"===e.type&&e.children?e.children.map(_FormField.fromDDL):[])}static fromDDL(e){return(new _FormField).fromDDL(e)}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.type()&&!!this.fieldID()}coerceFunc(){switch(this.type()){case"boolean":return e=>!!e;case"number":return e=>+e;case"string":return e=>""+e}return e=>e}calcValue(){return this.value_exists()?this.value():this.default()}};f(k,"FormField");let q=k;const V=class _Form extends B{constructor(){super()}toDDL(){return{type:"form",id:this.id(),fields:this.validFields().map(e=>e.toDDL())}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).formFields(e.fields.map(q.fromDDL)),this}static fromDDL(e,t=!1){return(new _Form).fromDDL(e,t)}validFields(){return this.formFields().filter(e=>e.valid())}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}refreshMeta(){return Promise.resolve()}label(){return"Form"}computeFields(e){const t=this.validFields().map(e=>e.toDDL());return()=>t}exec(){return Promise.resolve()}computeData(){const e={};return this.validFields().forEach(t=>{e[t.fieldID()]=t.calcValue()}),[e]}total(){return 1}};f(V,"Form");let N=V;function T(e){if(s.isArray(e))return"dataset";const t=typeof e;switch(t){case"boolean":case"number":case"string":case"object":return t}return"string"}function O(e,t){const i=[];for(const s in e){const r={type:T(e[s]),id:s};switch(r.type){case"object":for(const e of t){let t=!1;for(const i in e[s]){const i=O(e[s],[e[s]]);r.fields={},i.length&&(i.forEach(e=>r.fields[e.id]=e),t=!0);break}if(t)break}break;case"dataset":for(const e of t)if(e[s]&&e[s].length){r.children=O(e[s][0],e[s]);break}}i.push(r)}return i}N.prototype._class+=" Form",q.prototype.publish("type","string","set","FormField Type",["boolean","number","string","dataset"]),q.prototype.publish("fieldID","","string","FormField Label"),q.prototype.publish("default",null,"any","Default Value",null,{optional:!0}),q.prototype.publish("value",null,"any","Default Value",null,{optional:!0}),q.prototype.publish("childFields",[],"propertyArray","Child Fields",null,{autoExpand:q,disable:f(e=>e.disableChildField(),"disable")}),N.prototype.publish("formFields",[],"propertyArray","Multi Fields",null,{autoExpand:q}),f(T,"fieldType"),f(O,"rowToFields");const W=class _Databomb extends B{_jsonData=[];constructor(){super()}toDDL(e=!1){return{type:"databomb",id:this.id(),format:this.format(),payload:e?void 0:this.payload(),fields:this.validFields().map(e=>e.toDDL())}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).format(e.format).payload(e.payload).databombFields(e.fields.map(q.fromDDL)),this}static fromDDL(e,t=!1){return(new _Databomb).fromDDL(e,t)}validFields(){return this.databombFields().filter(e=>e.valid())}updateJsonData(){try{switch(this.format()){case"csv":this._jsonData=i.csvParse(this.payload());break;case"tsv":this._jsonData=i.tsvParse(this.payload());break;default:this._jsonData=JSON.parse(this.payload())}this.databombFields(this.preCalcFields().map(q.fromDDL))}catch(e){this.databombFields([]),this._jsonData=[]}}hash(e){return super.hash({ddl:this.toDDL(!0),...e})+this.payload()}refreshMeta(){return Promise.resolve()}label(){return"Databomb"}preCalcFields(){return 0===this._jsonData.length?[]:O(this._jsonData[0],this._jsonData)}computeFields(e){return()=>this.validFields().map(e=>e.toDDL())}exec(){return Promise.resolve()}computeData(){const e={};return this.validFields().forEach(t=>{e[t.fieldID()]=t.coerceFunc()}),this._jsonData.map(t=>{const i={};for(const s in e)i[s]=e[s](t[s]);return i})}total(){return this._jsonData.length}};f(W,"Databomb");let H=W;H.prototype._class+=" Databomb",H.prototype.publish("format","json","set","Databomb Format",["json","csv","tsv"]),H.prototype.publish("payload","","string","Databomb array",null,{multiline:!0}),H.prototype.publish("databombFields",[],"propertyArray","Multi Fields",null,{autoExpand:q});const G=H.prototype.format;H.prototype.format=function(e){const t=G.apply(this,arguments);return arguments.length&&this.updateJsonData(),t};const J=H.prototype.payload;H.prototype.payload=function(e){const t=J.apply(this,arguments);return arguments.length&&this.updateJsonData(),t};const U=(new H).id("Empty").payload("[]"),Q=class _DatasourceAdapt{_activity;constructor(e){this._activity=e||U}exec(){return this._activity.refreshMeta().then(()=>this._activity.exec())}id(){return this._activity.id()}hash(e={}){return this._activity.hash(e)}label(){return this._activity.label()}outFields(){return this._activity&&this._activity.outFields?this._activity.outFields():[]}total(){return this._activity?this._activity.outData().length:0}fetch(e,t){return this.exec().then(()=>{const i=this._activity.outData();return 0===e&&i.length<=t?Promise.resolve(i):Promise.resolve(i.slice(e,e+t))})}};f(Q,"DatasourceAdapt");let K=Q;const X=class _ESPResult extends B{constructor(e){super(),this._ec=e,this.samples(this._ec.samples()).sampleSize(this._ec.sampleSize())}_ec;_result;_schema=[];_meta=[];_total;_data=[];hash(e={}){return s.hashSum({samples:this.samples(),sampleSize:this.sampleSize(),...e})}_prevMetaHash;refreshMetaPromise;refreshMeta(){return this._prevMetaHash!==this.hash()&&(this._prevMetaHash=this.hash(),delete this.refreshMetaPromise),this.refreshMetaPromise||(this.refreshMetaPromise=super.refreshMeta().then(()=>{if(this._result=this._createResult(),this._result)return this._result.refresh();throw new Error("No valid result")}).then(e=>{this._total=e.Total,this._schema=e.fields(),this._meta=this._meta&&this._meta.length?this._meta:this._schema.map(F)}).catch(e=>{this._total=0,this._schema=[],this._meta=[]})),this.refreshMetaPromise}responseFields(e){return arguments.length?(this._meta=e,this.refreshMeta(),this):this._meta}computeFields(e){return()=>this.responseFields()}exec(){return this._exec()}_prevExecHash;_exec=s.debounce(()=>this._prevExecHash!==this.hash()?(this._prevExecHash=this.hash(),super.exec().then(()=>this.sample()).then(e=>{this._data=this.fixInt64(e)}).catch(e=>{this._data=[]})):Promise.resolve());inData(){return this._data}computeData(){return this._data}total(){return this._total}async fetch(e,t){return t>this.samples()*this.sampleSize()?this.sample():this._fetch(e,t)}_fetchQ=new s.AsyncOrderedQueue;_fetch(e,t){return this._fetchQ.push(this._result?this._result.fetchRows(e,t).catch(e=>[]):Promise.resolve([]))}sample=s.debounce((e=this.samples(),t=this.sampleSize())=>{const i=[];if(e*t>=this.total())i.push(this._fetch(0,this.total()));else{const s=this.total()-t;for(let r=0;r<e;++r)i.push(this._fetch(Math.floor(r*s/e),t))}return Promise.all(i).then(e=>{let t=[];for(const i of e)t=t.concat(i);return t})})};f(X,"ESPResult");let Y=X;Y.prototype._class+=" ESPResult";const Z=class _WUResult extends Y{_origWu;_origResultName;constructor(e){super(e),this._wu=new ie(this._ec)}url(){return this._wu.url()}wuid(){return this._wu.wuid()}toDDL(){return{type:"wuresult",id:this.id(),url:this._wu.url(),wuid:this.wuid(),outputs:{[this.resultName()]:{fields:this.responseFields()}}}}fromDDL(e,t=!1){return e.outputs[this.resultName()]?this.responseFields(e.outputs[this.resultName()].fields):this}static fromDDL(e,t,i,s,r=!1){return new _WUResult(e).wu(i).resultName(s).fromDDL(t)}_createResult(){if(this._wu.url()&&this.wuid()&&this.resultName())return t.Result.attach({baseUrl:this._wu.url(),hookSend:this._ec.hookSend()},this.wuid(),this.resultName())}sourceHash(){return super.hash({wuid:this.wuid()})}hash(e){return super.hash({ddl:this.toDDL()})}label(){return`${this.wuid()}\n${this.resultName()}`}};f(Z,"WUResult");let ee=Z;ee.prototype._class+=" WUResult";const te=class _WU extends B{constructor(e){super(),this._ec=e}_ec;_origUrl;_origWuid;_workunit;_outputs={};toDDL(){const e={};for(const t in this._outputs)e[t]={fields:this._outputs[t].responseFields()};return{type:"wuresult",id:this.id(),url:this.url(),wuid:this.wuid(),outputs:e}}fromDDL(e,t=!1){(t?this:this.id(e.id)).url(e.url).wuid(e.wuid);const i={};for(const s in e.outputs)i[s]=ee.fromDDL(this._ec,e,this,s);return this._outputs=i,this}static fromDDL(e,t,i=!1){return new _WU(e).fromDDL(t,i)}hash(){return s.hashSum({url:this.url(),wuid:this.wuid()})}label(){return this.wuid()}outputs(){const e=[];for(const t in this._outputs)e.push(this._outputs[t]);return e}outputDDL(){const e={};for(const t in this._outputs)e[t]={fields:this._outputs[t].outFields()};return e}output(e){return this._outputs[e]}_prevSourceHash;refreshMetaPromise;_resultNames=[];refreshMeta(){return this.url()&&this.wuid()?(this._prevSourceHash!==this.hash()&&(this._prevSourceHash=this.hash(),delete this.refreshMetaPromise),this.refreshMetaPromise||(this.refreshMetaPromise=super.refreshMeta().then(()=>(this._workunit=t.Workunit.attach({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.wuid()),this._workunit.fetchResults())).then(e=>{this._resultNames=e.map(e=>e.Name)}).catch(e=>{})),this.refreshMetaPromise):Promise.resolve()}resultNames(){return this._resultNames}};f(te,"WU");let ie=te;ie.prototype._class+=" WU";const se=class _WUResultRef extends j{datasource(e){return super.datasource.apply(this,arguments)}resultName(e){return arguments.length?(this.datasource().resultName(e),this):this.datasource().resultName()}toDDL(){return{id:this.datasource().wu().id(),output:this.resultName()}}};f(se,"WUResultRef");let re=se;re.prototype._class+=" WUResultRef",Y.prototype.publish("samples",10,"number","Number of samples"),Y.prototype.publish("sampleSize",100,"number","Sample size"),ee.prototype.publish("wu",null,"widget","Workunit"),ee.prototype.publish("resultName","","set","Result Name",function(){return void 0!==this._wu?this._wu.resultNames():[]}),ee.prototype._origWu=ee.prototype.wu,ee.prototype.wu=function(e){const t=ee.prototype._origWu.apply(this,arguments);return void 0!==e&&this._wu.refreshMeta(),t},ee.prototype._origResultName=ee.prototype.resultName,ee.prototype.resultName=function(e){const t=this._resultName,i=ee.prototype._origResultName.apply(this,arguments);return void 0!==e&&t!==e&&this.responseFields([]),i},ie.prototype.publish("url","","string","ESP Url (http://x.x.x.x:8010)"),ie.prototype.publish("wuid","","string","Workunit ID"),ie.prototype._origUrl=ie.prototype.url,ie.prototype.url=function(e){const t=ie.prototype._origUrl.apply(this,arguments);return void 0!==e&&this.refreshMeta(),t},ie.prototype._origWuid=ie.prototype.wuid,ie.prototype.wuid=function(e){const t=ie.prototype._origWuid.apply(this,arguments);return void 0!==e&&this.refreshMeta(),t};const ae=class _LogicalFile extends Y{constructor(e){super(e)}toDDL(){return{type:"logicalfile",id:this.id(),url:this.url(),logicalFile:this.logicalFile(),fields:this.responseFields()}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).url(e.url).logicalFile(e.logicalFile),this}static fromDDL(e,t,i=!1){return new _LogicalFile(e).fromDDL(t,i)}_createResult(){return t.Result.attachLogicalFile({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.nodeGroup(),this.logicalFile())}sourceHash(){return super.hash({logicalFile:this.logicalFile()})}hash(e){return super.hash({ddl:this.toDDL()})}label(){return`${this.logicalFile()}`}};f(ae,"LogicalFile");let oe=ae;oe.prototype._class+=" LogicalFile",oe.prototype.publish("url","","string","ESP Url (http://x.x.x.x:8010)"),oe.prototype.publish("nodeGroup","","string","Node Group"),oe.prototype.publish("logicalFile","","string","Logical File Name");const ne=class _RestField extends i.PropertyExt{_owner;constructor(){super()}toDDL(){return{type:"string",id:this.fieldID()}}fromDDL(e){return this.fieldID(e.id)}static fromDDL(e){return(new _RestField).fromDDL(e)}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}};f(ne,"RestField");let le=ne;const he=class _RestService extends B{constructor(e){super(),this._ec=e}_ec;_responseFields={};toDDL(){return{type:"rest",id:this.id(),url:this.url(),action:this.action(),mode:this.mode(),inputs:this.validRequestFields().map(e=>e.toDDL()),outputs:this.outputDDL()}}fromDDL(e,t=!1){(t?this:this.id(e.id)).url(e.url).action(e.action).mode(e.mode||"get").requestFields(e.inputs.map(le.fromDDL));for(const i in e.outputs)this.responseFields(i,e.outputs[i].fields);return this}static fromDDL(e,t,i=!1){return new _RestService(e).fromDDL(t,i)}hash(e={}){return s.hashSum({url:this.url(),action:this.action(),mode:this.mode(),...e})}label(){return this.action()}responseFields(e,t){return 1===arguments.length?this._responseFields[e]||[]:(this._responseFields[e]=t,this)}validRequestFields(){return this.requestFields().filter(e=>e.valid())}_prevRequestHash;_prevPromise;_submitQ=new s.AsyncOrderedQueue;submit(e){const i=s.hashSum(e);if(!this._prevPromise||this._prevRequestHash!==i){this._prevRequestHash=i;const s=t.createConnection({baseUrl:this.url(),type:this.mode()});this._prevPromise=this._submitQ.push(s.send(this.action(),e))}return this._prevPromise}resultNames(){const e=[];for(const t in this._responseFields)e.push(t);return e}outputDDL(){const e={};return this.resultNames().forEach(t=>{e[t]={fields:this._responseFields[t]}}),e}};f(he,"RestService");let ue=he;ue.prototype._class+=" RestService";const ce=class _RestResult extends B{constructor(e){super(),this._ec=e,this._service=new ue(this._ec)}_ec;_origService;validRequestFields(){return this.service().validRequestFields()}toDDL(){return this.service().toDDL()}fromDDL(e){return this.service().fromDDL(e),this}static fromDDL(e,t,i){return new _RestResult(e).id(`${t.id()}_${i}`).service(t).resultName(i)}serviceID(){return`${this.service().url()}/${this.service().action()}}`}sourceHash(){return this.service().hash()}requestFields(){return this.service().requestFields().map(e=>e.toDDL())}responseFields(e){return arguments.length?(this.service().responseFields(this.resultName(),e),this):this.service().responseFields(this.resultName())}hash(e={}){return s.hashSum({source:this.sourceHash(),resultName:this.resultName(),...e})}label(){return`${this.service().label()}\n${this.resultName()}`}_jsonData=[];jsonDataFields(){if(!this._jsonData||!this._jsonData.length)return[];const e=O(this._jsonData[0],this._jsonData);return this.responseFields(e),e}computeFields(e){return()=>this.jsonDataFields()}computeData(){return this._jsonData}submit(e){return this.service().submit(e).then(e=>{const t=this.resultName(),i=t?t.split("."):[];for(const s of i)e=(e||{})[s];return this._jsonData=e,e})}formatRequest(){const e={};return this.service().validRequestFields().forEach(t=>{e[t.fieldID()]=""}),e}exec(){return this.submit(this.formatRequest()).then(e=>{})}};f(ce,"RestResult");let de=ce;de.prototype._class+=" RestResult";const pe=class _Param extends i.PropertyExt{constructor(e){super(),this._ec=e}_ec;validate(e){const t=[];return this.source_valid()||t.push({source:`${e}.source.${this.source()}`,msg:`Invalid source: "${this.source()}"`,hint:`expected: ${JSON.stringify(this.visualizationIDs())}`}),this.remoteField_valid()||t.push({source:`${e}.remoteField`,msg:`Invalid remoteField: "${this.remoteField()}"`,hint:`expected: ${JSON.stringify(this.sourceOutFields())}`}),this.value_valid()||t.push({source:`${e}.value`,msg:`Invalid value: "${this.value()}"`,hint:"expected: any value."}),t}toDDL(){return{source:this.source(),remoteFieldID:this.remoteField(),localFieldID:this.localField(),value:this.value()}}fromDDL(e){return this.source(e.source).remoteField(e.remoteFieldID).localField(e.localFieldID).value(e.value)}static fromDDL(e,t){return new _Param(e).fromDDL(t)}hash(){return s.hashSum({label:this.localField(),source:this.source(),sourceField:this.remoteField()})}visualizationIDs(){return this._ec.elementIDs()}sourceFields(){return this.sourceOutFields().map(e=>e.id)}sourceViz(){return this._ec.element(this.source())}sourceOutFields(){return this.sourceViz().hipiePipeline().selectionFields()}sourceSelection(){return this.sourceViz().selection()}calcValue(){if(this.source_exists()&&this.remoteField_exists()){return this.sourceSelection().map(e=>e[this.remoteField()])}return this.value_exists()?[this.value()]:[""]}exists(){return this.localField_exists()&&(this.source_exists()&&this.remoteField_exists()||this.value_exists())}};f(pe,"Param");let me=pe;me.prototype._class+=" Param";const _e=class _RestResultRef extends j{constructor(e){super(),this._ec=e}_ec;serviceID(){return this.datasource().serviceID()}_data=[];datasource(e){return super.datasource.apply(this,arguments)}url(){return this.datasource().service().url()}action(){return this.datasource().service().action()}resultName(){return this.datasource().resultName()}validate(){let e=[];for(const t of this.validParams())e=e.concat(t.validate("request"));return e}toDDL(){return{id:this.datasource().service().id(),output:this.resultName(),request:this.validParams().map(e=>({source:e.source(),remoteFieldID:e.remoteField(),localFieldID:e.localField(),value:e.value()}))}}sourceHash(){return this.datasource().hash()}requestFieldRefs(e){return arguments.length?(this.request(e.map(e=>me.fromDDL(this._ec,e))),this):this.validParams().map(e=>e.toDDL())}requestFields(){return this.datasource().requestFields()}responseFields(){return this.datasource().responseFields()}hash(){return this.datasource().hash({resultName:this.resultName(),request:this.formatRequest()})}label(){return`${this.datasource().label()}\n${this.datasource().resultName()}`}elementIDs(){return this._ec.elementIDs()}element(e){return this._ec.element(e)}referencedFields(e){super.referencedFields(e);for(const t of this.validParams()){const i=t.sourceViz().hipiePipeline();e.inputs[this.id()]||(e.inputs[this.id()]=[]),e.inputs[this.id()].push(t.localField()),i.resolveFields(e,[t.remoteField()])}super.resolveFields(e,[])}validParams(){return this.request().filter(e=>e.exists())}refreshMeta(){return this.datasource().refreshMeta().then(()=>{const e=this.request(),t=s.compare(e.map(e=>e.localField()),this.datasource().validRequestFields().map(e=>e.fieldID())),i=e.filter(e=>t.update.indexOf(e.localField())>=0);this.request(i.concat(t.enter.map(e=>new me(this._ec).localField(e))))})}updatedBy(){return this.validParams().map(e=>e.source())}computeFields(e){return this.datasource().computeFields(e)}formatRequest(){const e=this.datasource().formatRequest();return this.request().forEach(t=>{void 0!==e[t.localField()]&&(e[t.localField()]=t.calcValue()||e[t.localField()])}),e}_prevRequestHash;_prevRequestPromise;exec(){const e=this.formatRequest(),t=s.hashSum({hash:this.hash(),request:e});return this._prevRequestHash!==t&&(this._prevRequestHash=t,this._prevRequestPromise=this.datasource().submit(e).then(e=>(this._data=this.fixInt64(e),this._data))),this._prevRequestPromise}inData(){return this._data}computeData(){return this._data}};f(_e,"RestResultRef");let fe=_e;function De(e){const t=e.split("/WsEcl/submit/query/");if(t.length<2)throw new Error(`Invalid roxie URL: ${e}`);const i=t[0].split(":");if(i.length<3)throw new Error(`Invalid roxie URL: ${e}`);const s=t[1].split("/");if(s.length<2)throw new Error(`Invalid roxie URL: ${e}`);return{url:`${i[0]}:${i[1]}:${"18002"===i[2]?"18010":"8010"}`,querySet:s[0],queryID:s[1]}}function ve(e){return e.length>=8&&e.indexOf("_changed")===e.length-8}function ge(e){return e.length>=8&&e.indexOf("_changed")===e.length-8||["HIPIE_DDL","HIPIE_DDLGLOBALS","hipieversion"].indexOf(e)>=0}fe.prototype._class+=" RestResultRef",le.prototype.publish("fieldID","","string","RestField Label"),ue.prototype.publish("url","","string","REST Url"),ue.prototype.publish("action","","string","Query Set"),ue.prototype.publish("mode","get","set","Request mode",["get","post"]),ue.prototype.publish("requestFields",[],"propertyArray","Multi Fields",null,{autoExpand:le}),de.prototype.publish("service",null,"widget","Rest service"),de.prototype.publish("resultName","","string","Result Name"),de.prototype._origService=de.prototype.service,de.prototype.service=function(e){const t=de.prototype._origService.apply(this,arguments);return void 0!==e&&this._service.refreshMeta(),t},me.prototype.publish("localField",null,"string","Label"),me.prototype.publish("source",null,"set","Activity",function(){return this.visualizationIDs()},{optional:!0,disable:f(e=>e.value_exists(),"disable"),validate:f(e=>e.source_disabled()||e.visualizationIDs().indexOf(e.source())>=0,"validate")}),me.prototype.publish("remoteField",null,"set","Source Field",function(){return this.sourceFields()},{optional:!0,disable:f(e=>!e.source_exists()||e.value_exists(),"disable"),validate:f(e=>e.remoteField_disabled()||e.sourceFields().indexOf(e.remoteField())>=0,"validate")}),me.prototype.publish("value",null,"string","Static Value",null,{optional:!0,disable:f(e=>e.source_exists(),"disable"),validate:f(e=>e.value_disabled()||e.value_exists(),"validate")}),fe.prototype.publish("request",[],"propertyArray","Request Fields"),f(De,"parseUrl"),f(ve,"isHipieRequest"),f(ge,"isHipieResponse");const ye=class _RoxieService extends B{constructor(e){super(),this._ec=e}_ec;_query;_requestFields;_responseFields={};_type="roxie";toDDL(){return{type:this._type,id:this.id(),url:this.url(),querySet:this.querySet(),queryID:this.queryID(),inputs:this.requestFields(),outputs:this.outputDDL()}}fromDDL(e,t=!1){this._type=e.type,(t?this:this.id(e.id)).url(e.url).querySet(e.querySet).queryID(e.queryID),e.inputs&&e.inputs.length&&this.requestFields(e.inputs);for(const i in e.outputs)this.responseFields(i,e.outputs[i].fields);return this}static fromDDL(e,t,i=!1){return new _RoxieService(e).fromDDL(t,i)}hash(e={}){return s.hashSum({url:this.url(),querySet:this.querySet(),queryId:this.queryID(),ignoreHipieRequest:this.ignoreHipieRequest(),ignoreHipieResponse:this.ignoreHipieResponse(),...e})}label(){return this.queryID()}_prevSourceHash;refreshMetaPromise;refreshMeta(){if(this._prevSourceHash!==this.hash()&&(this._prevSourceHash=this.hash(),delete this.refreshMetaPromise),!this.refreshMetaPromise){const e=!!this._requestFields;this.refreshMetaPromise=new Promise((i,s)=>{const r=t.Query.attach({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.querySet(),this.queryID());(!e||this.ignoreHipieRequest()||this.ignoreHipieResponse())&&i(r.refresh()),i(r)}).then(t=>{this._query=t,e&&!this.ignoreHipieRequest()||(this._requestFields=t.requestFields().filter(e=>"roxie"===this._type||!ve(e.id))),e&&!this.ignoreHipieResponse()||t.resultNames().filter(e=>"roxie"===this._type||!ge(e)).forEach(e=>{this._responseFields[e]=t.resultFields(e)})})}return this.refreshMetaPromise}requestFields(e){return arguments.length?(this._requestFields=e,this):this._requestFields||[]}responseFields(e,t){return 1===arguments.length?this._responseFields[e]||[]:(this._responseFields[e]=t,this)}_prevRequestHash;_prevPromise;_submitQ=new s.AsyncOrderedQueue;submit(e){const t=s.hashSum(e);return this._prevPromise&&this._prevRequestHash===t||(this._prevRequestHash=t,this._prevPromise=this._submitQ.push(this._query.submit(e))),this._prevPromise}resultNames(){const e=[];for(const t in this._responseFields)e.push(t);return e}outputDDL(){const e={};return this.resultNames().forEach(t=>{e[t]={fields:this._responseFields[t]}}),e}};f(ye,"RoxieService");let be=ye;be.prototype._class+=" RoxieService",be.prototype.publish("url","","string","ESP Url (http://x.x.x.x:8002)"),be.prototype.publish("querySet","","string","Query Set"),be.prototype.publish("queryID","","string","Query ID"),be.prototype.publish("ignoreHipieRequest",!1,"boolean","Ignore provided DDL request"),be.prototype.publish("ignoreHipieResponse",!1,"boolean","Ignore provided DDL response");const we=class _RoxieResult extends B{constructor(e){super(),this._ec=e,this._service=new be(this._ec)}_ec;_origService;toDDL(){return this.service().toDDL()}fromDDL(e){return this.service().fromDDL(e),this}static fromDDL(e,t,i){return new _RoxieResult(e).id(`${t.id()}_${i}`).service(t).resultName(i)}serviceID(){return`${this.service().url()}/${this.service().querySet()}/${this.service().queryID()}`}sourceHash(){return this.service().hash()}requestFields(){return this.service().requestFields()}responseFields(e){return arguments.length?(this.service().responseFields(this.resultName(),e),this):this.service().responseFields(this.resultName())}hash(e={}){return s.hashSum({source:this.sourceHash(),resultName:this.resultName(),...e})}label(){return`${this.service().label()}\n${this.resultName()}`}computeFields(e){return()=>this.service().responseFields(this.resultName())}refreshMeta(){return this.service().refreshMeta()}submit(e){return this.service().submit(e)}};f(we,"RoxieResult");let Fe=we;Fe.prototype._class+=" RoxieResult",Fe.prototype.publish("service",null,"widget","Roxie service"),Fe.prototype.publish("resultName","","set","Result Name",function(){return void 0!==this._service?this._service.resultNames():[]}),Fe.prototype._origService=Fe.prototype.service,Fe.prototype.service=function(e){const t=Fe.prototype._origService.apply(this,arguments);return void 0!==e&&this._service.refreshMeta(),t};const xe=class _RoxieResultRef extends j{constructor(e){super(),this._ec=e}_ec;serviceID(){return this.datasource().serviceID()}_data=[];datasource(e){return super.datasource.apply(this,arguments)}url(){return this.datasource().service().url()}querySet(){return this.datasource().service().querySet()}queryID(){return this.datasource().service().queryID()}resultName(){return this.datasource().resultName()}validate(){let e=[];for(const t of this.validParams())e=e.concat(t.validate("request"));return e}toDDL(){return{id:this.datasource().service().id(),output:this.resultName(),request:this.validParams().map(e=>({source:e.source(),remoteFieldID:e.remoteField(),localFieldID:e.localField(),value:e.value()}))}}sourceHash(){return this.datasource().hash()}requestFieldRefs(e){return arguments.length?(this.request(e.map(e=>me.fromDDL(this._ec,e))),this):this.validParams().map(e=>e.toDDL())}requestFields(){return this.datasource().requestFields()}responseFields(){return this.datasource().responseFields()}hash(){return this.datasource().hash({resultName:this.resultName(),params:this.request().map(e=>e.hash()),request:this.formatRequest()})}label(){return`${this.datasource().label()}\n${this.datasource().resultName()}`}elementIDs(){return this._ec.elementIDs()}element(e){return this._ec.element(e)}referencedFields(e){super.referencedFields(e);const t=[];for(const i of this.validParams()){t.push(i.localField());const s=i.sourceViz().hipiePipeline();e.inputs[this.id()]||(e.inputs[this.id()]=[]),e.inputs[this.id()].push(i.localField()),s.resolveFields(e,[i.remoteField()])}super.resolveFields(e,t)}validParams(){return this.request().filter(e=>e.exists())}refreshMeta(){return this.datasource().refreshMeta().then(()=>{const e=this.request(),t=s.compare(e.map(e=>e.localField()),this.datasource().requestFields().map(e=>e.id)),i=e.filter(e=>t.update.indexOf(e.localField())>=0);this.request(i.concat(t.enter.map(e=>new me(this._ec).localField(e))))})}updatedBy(){return this.validParams().map(e=>e.source())}computeFields(e){return()=>this.datasource().responseFields()}formatRequest(){const e={};let t=!1;const i=this.datasource().requestFields();for(const s of this.validParams()){const r=s.calcValue();let a;a="set"===i.filter(e=>e.id===s.localField())[0].type?{Item:r}:r[0],void 0!==a&&(e[s.localField()]=a),t=!0}return t||(e.refresh=!0),e}_prevRequestHash;_prevRequestPromise;exec(){return super.exec().then(()=>{const e=this.formatRequest(),t=s.hashSum({hash:this.hash(),request:e});return this._prevRequestHash!==t&&(this._prevRequestHash=t,this._prevRequestPromise=this.datasource().submit(e).then(e=>{const t=this.datasource().resultName();let i=e[t];return i||(i=e[t.toLowerCase().replace(/ /g,"_")]),this.fixInt64(i)})),this._prevRequestPromise}).then(e=>{this._data=e})}inData(){return this._data}computeData(){return this._data}};f(xe,"RoxieResultRef");let Pe=xe;Pe.prototype._class+=" RoxieResultRef",Pe.prototype.publish("request",[],"propertyArray","Request Fields");const Se=class _HipieResultRef extends Pe{fullUrl(e){const t=De(e);return this.datasource().service().url(t.url),this.datasource().service().querySet(t.querySet),this.datasource().service().queryID(t.queryID),this}formatRequest(){const e=super.formatRequest(),t={};for(const i in e)t[i]=e[i],t[`${i}_changed`]=!0;return t}};f(Se,"HipieResultRef");let Le=Se;Le.prototype._class+=" HipieResultRef";let Ce=0;const Ie=class _DSPicker extends E{constructor(e){super(),this._ec=e,this._id="ds_"+ ++Ce;const t=this._ec.datasources()[0];this.datasourceID(t.id())}_ec;_nullDatasource=U;_origDatasourceID;_origDatasourceRef;datasource(){return this.datasourceRef().datasource()}refreshRef(e){const t=this._ec.datasource(e);t instanceof H||t instanceof N||t instanceof oe||t instanceof be?this.selection((new j).datasource(t)):t instanceof ee?this.selection((new re).datasource(t)):t instanceof Fe?this.selection(new Le(this._ec).datasource(t)):t instanceof de&&this.selection(new fe(this._ec).datasource(t))}selection(e){const t=super.selection.apply(this,arguments);return arguments.length?(this._datasourceID!==e.datasource().id()&&(this._datasourceID=e.datasource().id()),this):t||this._nullDatasource}validate(){return this.selection().validate()}toDDL(){return{...this.datasourceRef().toDDL(),id:this.datasourceID()}}hash(e={}){return super.hash({...e})}datasourceIDs(){return this._ec.datasources().map(e=>({value:e.id(),text:`${e.label()} ${e.id()!==e.label()?` (${e.id()})`:""}`}))}};f(Ie,"DSPicker");let $e=Ie;function Re(e,t,i){const s="string"==typeof i;switch(e){case"==":return e=>s&&"string"==typeof e[t]?e[t].trim()===i:e[t]===i;case"!=":return e=>s&&"string"==typeof e[t]?e[t].trim()!==i:e[t]!==i;case"<":return e=>e[t]<i;case"<=":return e=>e[t]<=i;case">":return e=>e[t]>i;case">=":return e=>e[t]>=i;default:throw new Error(`Unknown filter condition: ${e}`)}}$e.prototype._class+=" DSPicker",$e.prototype.publish("datasourceID","","set","Activity",function(){return this.datasourceIDs()},{optional:!1}),$e.prototype.publish("datasourceRef","","widget","Activity"),$e.prototype._origDatasourceID=$e.prototype.datasourceID,$e.prototype.datasourceID=function(e){const t=this._datasourceID,i=$e.prototype._origDatasourceID.apply(this,arguments);return void 0!==e&&t!==e&&this.refreshRef(e),i},$e.prototype._origDatasourceRef=$e.prototype.datasourceRef,$e.prototype.datasourceRef=function(e){return E.prototype.selection.apply(this,arguments)},f(Re,"createFilter");const Ee=class _ColumnMapping extends i.PropertyExt{_owner;validate(e){const t=[];return this.remoteField_valid()||t.push({source:`${e}.remoteField`,msg:`Invalid remoteField: "${this.remoteField()}"`,hint:`expected: ${JSON.stringify(this.sourceOutFields())}`}),this.localField_valid()||t.push({source:`${e}.localField`,msg:`Invalid localField: "${this.localField()}"`,hint:`expected: ${JSON.stringify(this.localFields())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return this.localField_exists()||this.remoteField_exists()}toDDL(){return{remoteFieldID:this.remoteField(),localFieldID:this.localField(),condition:this.condition(),nullable:this.nullable()}}fromDDL(e){return this.remoteField(e.remoteFieldID).localField(e.localFieldID).condition(e.condition).nullable(e.nullable)}static fromDDL(e){return(new _ColumnMapping).fromDDL(e)}hash(){return s.hashSum({remoteField:this.remoteField(),localField:this.localField(),condition:this.condition(),nullable:this.nullable()})}localFields(){return this._owner.inFields().map(e=>e.id)}sourceOutFields(){return this._owner.sourceOutFields().map(e=>e.id)}remoteValues(e){const t=this.remoteField();return e.map(e=>{const i=e[t];return"string"==typeof i?i.trim():i})}createFilterDescription(e){switch(this.condition()){case"in":case"range":return`${this.localField()} ${this.condition()} [${this.remoteValues(e).join(", ")}]`;default:return`${this.localField()} ${this.condition()} ${this.remoteValues(e)[0]}`}}createFilter(e){const t=this.localField(),i=this.remoteValues(e);switch(this.condition()){case"range":return this.nullable()&&(i.length<2||i[0]===i[1])?e=>!0:e=>e[t]>=i[0]&&e[t]<=i[1];case"in":return this.nullable()&&0===i.length?e=>!0:e=>i.some(i=>"string"==typeof e[t]?e[t].trim()===i:e[t]===i);default:const e=i[0];return!this.nullable()||null!=e&&""!==e?Re(this.condition(),t,e):e=>!0}}};f(Ee,"ColumnMapping");let Ae=Ee;Ae.prototype._class+=" ColumnMapping";const ze=class _RemoteFilter extends i.PropertyExt{_owner;validate(e){let t=[];this.source_valid()||t.push({source:`${e}.source.${this.source()}`,msg:`Invalid source: "${this.source()}"`,hint:`expected: ${JSON.stringify(this.visualizationIDs())}`}),this.source_exists()&&0===this.validMappings().length&&t.push({source:`${e}.source.${this.source()}`,msg:`Invalid mappings: "${this.source()}"`,hint:"expected minimum of 1 mapping"});for(const i of this.validMappings())t=t.concat(i.validate(`${e}.${this.source()}.mappings`));return t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.source()&&this.validMappings().length>0}toDDL(){return{viewID:this.source(),mappings:this.ddlMappings()}}fromDDL(e){return this.source(e.viewID).ddlMappings(e.mappings)}static fromDDL(e){return(new _RemoteFilter).fromDDL(e)}ddlMappings(e){return arguments.length?(this.mappings(e.map(e=>Ae.fromDDL(e))),this):this.validMappings().map(e=>e.toDDL())}visualizationIDs(){return this._owner.visualizationIDs()}hash(){return s.hashSum({source:this.source(),mappings:this.validMappings().map(e=>e.hash()),selection:this.sourceSelection()})}validMappings(){return this.mappings().filter(e=>e.valid())}appendMappings(e){for(const t of e)this.mappings().push((new Ae).owner(this).remoteField(t.remoteField).localField(t.localField).condition(t.condition));return this}inFields(){return this._owner.inFields()}sourceViz(){return this._owner.visualization(this.source())}sourceOutFields(){return this.sourceViz().hipiePipeline().selectionFields()}sourceSelection(){return this.sourceViz().selection()}createFilter(){const e=this.sourceSelection(),t=this.validMappings().map(t=>t.createFilter(e));return e=>t.every(t=>t(e))}createFilterDescription(){const e=this.sourceSelection();return this.validMappings().map(t=>t.createFilterDescription(e)).join(", ")}};f(ze,"RemoteFilter");let Be=ze;Be.prototype._class+=" Filter";const Me=class _StaticFilter extends i.PropertyExt{_owner;validate(e){const t=[];return this.localField_valid()||t.push({source:`${e}.localField`,msg:`Invalid localField: "${this.localField()}"`,hint:`expected: ${JSON.stringify(this.localFields())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}coerceValue(e){return 0===arguments.length?"number"===this.valueType()?+this.value():""+this.value():(this.value(e),"number"==typeof e?this.valueType("number"):this.valueType("string"),this)}valid(){return this.localField_exists()&&this.value_exists()}toDDL(){return{localFieldID:this.localField(),condition:this.condition(),value:this.coerceValue()}}fromDDL(e){return this.localField(e.localFieldID).condition(e.condition).coerceValue(e.value)}static fromDDL(e){return(new _StaticFilter).fromDDL(e)}hash(){return s.hashSum({localField:this.localField(),condition:this.condition(),value:this.value(),valueType:this.valueType()})}localFields(){return this._owner.inFields().map(e=>e.id)}createFilterDescription(){return`${this.localField()} ${this.condition()} ${this.coerceValue()}`}createFilter(){return Re(this.condition(),this.localField(),this.coerceValue())}};f(Me,"StaticFilter");let je=Me;je.prototype._class+=" StaticFilter";const ke=class _Filters extends S{constructor(e){super(),this._ec=e}_ec;validate(){let e=[];for(const t of this.validFilters())e=e.concat(t.validate("filter"));return e}toDDL(){return{type:"filter",conditions:this.conditions()}}fromDDL(e){return this.conditions(e.conditions)}static fromDDL(e,t){return new _Filters(e).fromDDL(t)}conditions(e){if(!arguments.length)return this.validFilters().map(e=>e.toDDL());const t=[],i=[];return e.forEach(e=>{r.DDL2.isIFilterCondition(e)?t.push(Be.fromDDL(e)):i.push(je.fromDDL(e))}),this.remoteFilter(t),this.staticFilter(i),this}visualizationIDs(){return this._ec.elementIDs()}visualization(e){return this._ec.element(e)}hash(){return s.hashSum(this.validFilters().map(e=>({filter:e.hash()})))}exists(){return this.validFilters().length>0}updatedBy(){return this.validRemoteFilters().map(e=>e.source())}referencedFields(e){super.referencedFields(e);const t=[];for(const i of this.validRemoteFilters()){const s=i.sourceViz().hipiePipeline(),r=[];for(const e of i.validMappings())t.push(e.localField()),r.push(e.remoteField());s.resolveFields(e,r)}super.resolveInFields(e,t)}exec(){return super.exec()}computeData(){const e=super.computeData();if(0===e.length||!this.exists())return e;const t=this.validFilters().map(e=>e.createFilter());return e.filter(e=>t.every(t=>t(e)))}validRemoteFilters(){return this.remoteFilter().filter(e=>e.valid())}validStaticFilters(){return this.staticFilter().filter(e=>e.valid())}validFilters(){return[...this.validRemoteFilters(),...this.validStaticFilters()]}};f(ke,"Filters"),D(ke,"Filter",Be),D(ke,"Mapping",Ae);let qe=ke;qe.prototype._class+=" Filters",Ae.prototype.publish("remoteField",null,"set","Filter Fields",function(){return this.sourceOutFields()},{optional:!0,disable:f(e=>!e._owner.source(),"disable"),validate:f(e=>e.sourceOutFields().indexOf(e.remoteField())>=0,"validate")}),Ae.prototype.publish("localField",null,"set","Local Fields",function(){return this.localFields()},{optional:!0,disable:f(e=>!e._owner.source(),"disable"),validate:f(e=>e.localFields().indexOf(e.localField())>=0,"validate")}),Ae.prototype.publish("condition","==","set","Filter Fields",["==","!=",">",">=","<","<=","range","in"]),Ae.prototype.publish("nullable",!1,"boolean","Ignore null filters"),Be.prototype.publish("source",null,"set","Activity",function(){return this.visualizationIDs()},{optional:!0,validate:f(e=>e.visualizationIDs().indexOf(e.source())>=0,"validate")}),Be.prototype.publish("mappings",[],"propertyArray","Mappings",null,{autoExpand:Ae}),je.prototype.publish("localField",null,"set","Local Fields",function(){return this.localFields()},{optional:!0,validate:f(e=>e.localFields().indexOf(e.localField())>=0,"validate")}),je.prototype.publish("condition","==","set","Filter Fields",["==","!=",">",">=","<","<="]),je.prototype.publish("value","","any","Static Value"),je.prototype.publish("valueType","number","set","Static Value Type",["number","string"]),qe.prototype.publish("remoteFilter",[],"propertyArray","Remote Filter",null,{autoExpand:Be}),qe.prototype.publish("staticFilter",[],"propertyArray","Static Filter",null,{autoExpand:je});const Ve=class _GroupByColumn extends i.PropertyExt{_owner;validate(e){const t=[];return this.label_valid()||t.push({source:`${e}.label`,msg:`Invalid label: "${this.label()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()}toDDL(){return this.label()}fromDDL(e){return this.label(e)}static fromDDL(e){return(new _GroupByColumn).fromDDL(e)}hash(){return s.hashSum(this.label())}columns(){return this._owner.inFieldIDs()}};f(Ve,"GroupByColumn");let Ne=Ve;function Te(e,t){return e.length}Ne.prototype._class+=" GroupByColumn",f(Te,"localCount");const Oe={count:Te,min:i.min,max:i.max,mean:i.mean,median:i.median,variance:i.variance,deviation:i.deviation,sum:i.sum},We=class _AggregateField extends i.PropertyExt{_owner;disableAggrColumn(){return!this.fieldID()||!this.aggrType()||"count"===this.aggrType()}disableBaseCountColumn(){return!this.fieldID()||!this.aggrType()||"mean"!==this.aggrType()}validate(e){const t=[];return this.aggrColumn_valid()||t.push({source:`${e}.${this.fieldID()}.aggrColumn`,msg:`Invalid aggrColumn: "${this.aggrColumn()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),this.baseCountColumn_valid()||t.push({source:`${e}.${this.fieldID()}.aggrColumn`,msg:`Invalid baseCountColumn: "${this.baseCountColumn()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}toDDL(){return"count"===this.aggrType()?{fieldID:this.fieldID(),type:"count"}:{fieldID:this.fieldID(),type:this.aggrType(),inFieldID:this.aggrColumn(),baseCountFieldID:this.baseCountColumn()}}fromDDL(e){const t=this.fieldID(e.fieldID).aggrType(e.type);return"count"!==e.type&&(t.aggrColumn(e.inFieldID),t.baseCountColumn(e.baseCountFieldID)),t}static fromDDL(e){return(new _AggregateField).fromDDL(e)}hash(){return s.hashSum({label:this.fieldID(),aggrType:this.aggrType(),aggrColumn:this.aggrColumn()})}columns(){return this._owner.inFieldIDs()}hasColumn(){return this.columns().length}aggregate(e){return Oe[this.aggrType()](e,e=>+e[this.aggrColumn()])}aggrFunc(){const e=Oe[this.aggrType()],t=this.aggrColumn(),i=this.baseCountColumn();return i?s=>e(s,e=>+e[t]/+e[i]):i=>e(i,e=>+e[t])}};f(We,"AggregateField");let He=We;He.prototype._class+=" AggregateField";const Ge=class _GroupBy extends S{validate(){let e=[];for(const t of this.validGroupBy())e=e.concat(t.validate("GroupBy.column"));for(const t of this.validComputedFields())e=e.concat(t.validate("GroupBy.computedFields"));return e}constructor(){super()}toDDL(){return{type:"groupby",groupByIDs:this.fieldIDs(),aggregates:this.aggregates()}}fromDDL(e){return this.fieldIDs(e.groupByIDs).aggregates(e.aggregates)}static fromDDL(e){return(new _GroupBy).fromDDL(e)}fieldIDs(e){return arguments.length?(this.column(e.map(e=>Ne.fromDDL(e))),this):this.validGroupBy().map(e=>e.toDDL())}aggregates(e){return arguments.length?(this.computedFields(e.map(e=>He.fromDDL(e))),this):this.validComputedFields().map(e=>e.toDDL())}hash(){return s.hashSum({groupBy:this.column().map(e=>e.hash()),computedFields:this.computedFields().map(e=>e.hash())})}appendGroupBys(e){for(const t of e)this.column().push((new Ne).owner(this).label(t.field));return this}validGroupBy(){return this.column().filter(e=>e.valid())}exists(){return this.validGroupBy().length>0}inFieldIDs(){return this.inFields().map(e=>e.id)}field(e){for(const t of this.inFields())if(t.id===e)return t;return null}appendComputedFields(e){for(const t of e){const e=(new He).owner(this).fieldID(t.label).aggrType(t.type);void 0!==t.column&&e.aggrColumn(t.column),this.computedFields().push(e)}return this}validComputedFields(){return this.computedFields().filter(e=>e.valid())}hasComputedFields(){return this.validComputedFields().length>0}computeFields(e){if(!this.exists())return super.computeFields(e);const t=[],i=this.validGroupBy();for(const s of i){const e=this.field(s.label()),i={type:e?e.type:"string",id:s.label()};t.push(i)}for(const s of this.computedFields())if(s.fieldID()){const e={id:s.fieldID(),type:"number"};t.push(e)}if(this.details()){let e=t;if(this.exists()){const i={id:"values",type:"dataset",children:[]};t.push(i),e=i.children}const s=i.map(e=>e.label());e.push(...this.inFields().filter(e=>this.fullDetails()||s.indexOf(e.id)<0))}return()=>t}referencedFields(e){super.referencedFields(e);const t=[];for(const i of this.validGroupBy())t.push(i.label());for(const i of this.validComputedFields())i.aggrColumn()&&t.push(i.aggrColumn());super.resolveInFields(e,t)}computeData(){const e=super.computeData();if(0===e.length||!this.exists())return e;const t=this.validGroupBy().map(e=>e.label()),s=this.validComputedFields().map(e=>({label:e.fieldID(),aggrFunc:e.aggrFunc()})),r=i.nest().key(e=>{let i="";for(const s of t)i+=":"+e[s];return i}).entries(e).map(e=>{const i=e;delete i.key;for(const s of t)i[s]=i.values[0][s];for(const t of s)i[t.label]=t.aggrFunc(i.values);return i}),a=this.outFields();return r.map(e=>{const t={};for(const i of a)t[i.id]=e[i.id];return t})}};f(Ge,"GroupBy");let Je=Ge;Je.prototype._class+=" GroupBy",Ne.prototype.publish("label",void 0,"set","Field",function(){return this.columns()},{optional:!0,validate:f(e=>e.columns().indexOf(e.label())>=0,"validate")}),He.prototype.publish("fieldID",null,"string","new Field ID",null,{optional:!0,disable:f(e=>!e.hasColumn(),"disable")}),He.prototype.publish("aggrType","count","set","Aggregation Type",["count","min","max","sum","mean","median","variance","deviation"],{optional:!0,disable:f(e=>!e.fieldID(),"disable")}),He.prototype.publish("aggrColumn",null,"set","Aggregation Field",function(){return this.columns()},{optional:!0,disable:f(e=>e.disableAggrColumn(),"disable"),validate:f(e=>e.columns().indexOf(e.aggrColumn())>=0,"validate")}),He.prototype.publish("baseCountColumn",null,"set","Base Count Field",function(){return this.columns()},{optional:!0,disable:f(e=>e.disableBaseCountColumn(),"disable"),validate:f(e=>e.columns().indexOf(e.baseCountColumn())>=0,"validate")}),Je.prototype.publish("column",[],"propertyArray","Source Columns",null,{autoExpand:Ne}),Je.prototype.publish("computedFields",[],"propertyArray","Computed Fields",null,{autoExpand:He}),Je.prototype.publish("details",!1,"boolean","Show details"),Je.prototype.publish("fullDetails",!1,"boolean","Show groupBy fileds in details");const Ue=class _Limit extends S{constructor(){super()}toDDL(){return{type:"limit",limit:this.rows()}}fromDDL(e){return this.rows(e.limit)}static fromDDL(e){return(new _Limit).fromDDL(e)}hash(){return s.hashSum({limit:this.rows()})}exists(){return this.rows_exists()&&this.rows()>0}computeData(){const e=super.computeData();return 0!==e.length&&this.exists()?e.slice(0,Math.min(this.rows(),e.length)):e}};f(Ue,"Limit");let Qe=Ue;Qe.prototype._class+=" Limit",Qe.prototype.publish("rows",void 0,"number","Limit output");const Ke=class _ComputedMapping extends i.PropertyExt{_owner;validate(e){const t=[];return this.value_valid()||t.push({source:`${e}.value`,msg:`Invalid value: "${this.value()}"`,hint:'expected: "any"'}),this.newValue_valid()||t.push({source:`${e}.newValue`,msg:`Invalid value: "${this.newValue()}"`,hint:'expected: "any"'}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.value()&&!!this.newValue()}toDDL(){return{value:this.value(),newValue:this.newValue()}}fromDDL(e){return this.value(e.value).newValue(e.newValue)}static fromDDL(e){return(new _ComputedMapping).fromDDL(e)}};f(Ke,"ComputedMapping");let Xe=Ke;Xe.prototype._class+=" ComputedMapping";const Ye=class _ComputedField extends i.PropertyExt{_owner;disableColumn1(){return!this.label()||["=","*","/","+","-","scale","map"].indexOf(this.type())<0}disableColumn2(){return!this.label()||["*","/","+","-"].indexOf(this.type())<0}disableMapping(){return!this.label()||["map"].indexOf(this.type())<0}disableChildField(){return!this.hasChildren()}validate(e){const t=[];return this.column1_valid()||t.push({source:`${e}.${this.label()}`,msg:`Invalid column1: "${this.column1()}"`,hint:`expected: ${JSON.stringify(this.columns())}`}),this.column2_valid()||t.push({source:`${e}.${this.label()}`,msg:`Invalid column2: "${this.column2()}"`,hint:`expected: ${JSON.stringify(this.columns())}`}),this.disableMapping()||this.validComputedMappings().forEach(t=>t.validate(`${e}.mapping`)),this.disableChildField()||this.validChildFields().forEach(t=>t.validate(`${e}.childField`)),t}hasChildren(){if(!this.label())return!1;if("="!==this.type())return!1;if(!this.column1())return!1;const e=this._owner.field(this.column1());return!(!e||"dataset"!==e.type||!e.children)}children(){const e=this._owner.field(this.column1());return e&&"dataset"===e.type?e.children:[]}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()}validComputedMappings(){return this.mapping().filter(e=>e.valid())}validChildFields(){return this.childField().filter(e=>e.valid())}hasChildFields(){return this.validChildFields().length}toDDL(){switch(this.type()){case"scale":return{fieldID:this.label(),type:"scale",sourceFieldID:this.column1(),factor:this.constValue()};case"template":return{fieldID:this.label(),type:"template",template:this.template()};case"=":const e=this.validChildFields().map(e=>e.toDDL());return{fieldID:this.label(),type:"=",sourceFieldID:this.column1(),transformations:e.length?e:void 0};case"map":return{fieldID:this.label(),type:"map",sourceFieldID:this.column1(),default:this.default(),mappings:this.validComputedMappings().map(e=>e.toDDL())};default:return{fieldID:this.label(),type:this.type(),sourceFieldID1:this.column1(),sourceFieldID2:this.column2()}}}fromDDL(e){const t=this.label(e.fieldID).type(e.type);switch(e.type){case"scale":t.column1(e.sourceFieldID).constValue(e.factor);break;case"template":t.template(e.template);break;case"=":t.column1(e.sourceFieldID).childField(e.transformations?e.transformations.map(e=>_ComputedField.fromDDL(e)):[]);break;case"map":t.column1(e.sourceFieldID).default(e.default).mapping(e.mappings?e.mappings.map(e=>Xe.fromDDL(e)):[]);break;default:t.column1(e.sourceFieldID1).column2(e.sourceFieldID2)}return t}static fromDDL(e){return(new _ComputedField).fromDDL(e)}hash(){return s.hashSum(this.toDDL())}columns(){return this._owner.fieldIDs()}computedField(){switch(this.type()){case"=":let e=this.validChildFields();return 0===e.length&&this.hasChildren()&&(e=this.children().map(e=>(new _ComputedField).owner(this).label(e.id).type("=").column1(e.id))),{...this._owner.field(this.column1()),id:this.label(),children:e.length?e.map(e=>e.computedField()):void 0};case"*":case"/":case"+":case"-":case"scale":return{id:this.label(),type:"number"};case"template":return{id:this.label(),type:"string"};case"map":return{id:this.label(),type:"object"}}return{id:this.label(),type:"string"}}projection(e){const t=this.hasChildFields(),i=this.validChildFields().map(t=>({label:t.label(),func:t.computeFunc(e)}));return s=>{const r=e&&t?{}:{...s};for(const e of i)r[e.label]=e.func(s);return e&&t&&(r.__lparam=s),r}}computeFunc(e){const t=this.column1(),r=this.column2();switch(this.type()){case"=":return this.hasChildFields()?i=>(i[t].Row&&s.isArray(i[t].Row)?i[t].Row:i[t]).map(this.projection(e)):e=>e[t];case"*":return e=>+e[t]*+e[r];case"/":return e=>+e[t]/+e[r];case"+":return e=>+e[t]+ +e[r];case"-":return e=>+e[t]-+e[r];case"scale":const a=this.constValue();return e=>+e[t]*a;case"template":const o=this.template();return e=>i.Utility.template(o,e);case"map":const n=this.default(),l={};for(const e of this.mapping())l[e.value()]=e.newValue();return e=>l[e[t]]||n;default:return e=>e[t]}}fieldIDs(){const e=this._owner.field(this.column1());if(e)switch(e.type){case"dataset":return e.children.map(e=>e.id);case"object":return Object.keys(e.fields)}return[]}field(e){const t=this._owner.field(this.column1());if(t)switch(t.type){case"dataset":for(const i of t.children)if(i.id===e)return i;break;case"object":return t.fields[e]}}};f(Ye,"ComputedField");let Ze=Ye;Ze.prototype._class+=" ComputedField";const et=class _MultiField extends i.PropertyExt{_owner;constructor(){super()}hash(){return s.hashSum(this.toDDL())}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()&&this.validMultiFields().length>0}validate(e){let t=[];for(const i of this.validMultiFields())t=t.concat(i.validate(`${e}.computedFields`));return t}toDDL(){return{fieldID:this.label(),type:"multi",transformations:this.transformations()}}fromDDL(e){return this.label(e.fieldID).transformations(e.transformations)}static fromDDL(e){return(new _MultiField).fromDDL(e)}validMultiFields(){return this.multiFields().filter(e=>e.valid())}transformations(e){return arguments.length?(this.multiFields(e.map(e=>Ze.fromDDL(e))),this):this.validMultiFields().map(e=>e.toDDL())}fieldIDs(){return this._owner.fieldIDs()}field(e){return this._owner.field(e)}};f(et,"MultiField");let tt=et;tt.prototype._class+=" MultiField";const it=class _ProjectBase extends S{_includeLParam=!1;_trim=!1;validate(){let e=[];for(const t of this.validComputedFields())e=e.concat(t.validate(`${this.classID()}.computedFields`));return e}constructor(){super()}transformations(e){return arguments.length?(this.computedFields(e.map(e=>"multi"===e.type?tt.fromDDL(e):Ze.fromDDL(e))),this):this.validComputedFields().map(e=>e.toDDL())}exists(){return this.validComputedFields().length>0}fieldIDs(){return this.inFields().map(e=>e.id)}field(e){for(const t of this.inFields())if(t.id===e)return t;return null}clearComputedFields(){this.computedFields([])}appendComputedFields(e){for(const t of e){const e=(new Ze).owner(this).label(t.label).type(t.type);void 0!==t.column&&e.column1(t.column),this.computedFields().push(e)}return this}validComputedFields(){return this.computedFields().filter(e=>e.valid())}hasComputedFields(){return this.validComputedFields().length}computeFields(e){if(!this.exists())return super.computeFields(e);let t=[];const i={};for(const s of this.validComputedFields())if(s instanceof tt)for(const e of s.validMultiFields()){const s=e.computedField();t.push(s),i[s.id]=!0}else{const e=s.computedField();t.push(e),i[e.id]=!0}if(this._trim&&this.hasComputedFields()){if(this._includeLParam){const e={id:"__lparam",type:"object"};t.push(e),i[e.id]=!0}}else t=t.concat(e.filter(e=>!i[e.id]));return()=>t}referencedFields(e){super.referencedFields(e);const t=[];for(const s of this.validComputedFields())if(s instanceof tt)for(const e of s.validMultiFields())t.push(e.column1()),e.column2()&&t.push(e.column2());else if("template"===s.type())for(const e of i.Utility.templateFields(s.template()))t.push(e);else t.push(s.column1()),s.column2()&&t.push(s.column2());super.resolveInFields(e,t)}projection(){const e=this._trim,t=this.hasComputedFields(),i=[];for(const s of this.validComputedFields())if(s instanceof tt)for(const t of s.validMultiFields())i.push({label:t.label(),func:t.computeFunc(e)});else i.push({label:s.label(),func:s.computeFunc(e)});return s=>{const r=e&&t?{}:{...s};for(const e of i)r[e.label]=e.func(s);return e&&t&&this._includeLParam&&(r.__lparam=s),r}}computeData(){const e=super.computeData();return 0!==e.length&&this.exists()?e.map(this.projection()):e}};f(it,"ProjectBase"),D(it,"ComputedField",Ze);let st=it;const rt=class _Project extends st{toDDL(){return{type:"project",transformations:this.transformations()}}fromDDL(e){return this.transformations(e.transformations)}static fromDDL(e){return(new _Project).fromDDL(e)}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}};f(rt,"Project");let at=rt;at.prototype._class+=" Project";const ot=class _Mappings extends st{constructor(){super(),this._trim=!0,this._includeLParam=!0}toDDL(){return{type:"mappings",transformations:this.transformations()}}fromDDL(e){const t=e||{transformations:[]};return this.transformations(t.transformations)}static fromDDL(e){return(new _Mappings).fromDDL(e)}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}referencedFields(e){if(this.hasComputedFields())return super.referencedFields(e);this.resolveInFields(e,this.inFields().filter(e=>"__lparam"!==e.id).map(e=>e.id))}};f(ot,"Mappings");let nt=ot;nt.prototype._class+=" Mappings",Xe.prototype.publish("value",null,"any","Compare Value",void 0,{validate:f(e=>!e.value()&&!e.newValue()||!!e.value()&&!!e.newValue(),"validate")}),Xe.prototype.publish("newValue",null,"any","New Value",void 0,{validate:f(e=>!e.value()&&!e.newValue()||!!e.value()&&!!e.newValue(),"validate")}),Ze.prototype.publish("label",null,"string","Label",null,{optional:!0}),Ze.prototype.publish("type","mapping","set","Project type",["=","*","/","+","-","scale","template","map"],{optional:!0,disable:f(e=>!e.label(),"disable")}),Ze.prototype.publish("column1",null,"set","Param 1",function(){return this.columns()},{optional:!0,disable:f(e=>e.disableColumn1(),"disable"),validate:f(e=>e.columns().indexOf(e.column1())>=0,"validate")}),Ze.prototype.publish("column2",null,"set","Param 2",function(){return this.columns()},{optional:!0,disable:f(e=>e.disableColumn2(),"disable"),validate:f(e=>e.columns().indexOf(e.column2())>=0,"validate")}),Ze.prototype.publish("constValue",null,"number","Const value",null,{optional:!0,disable:f(e=>!e.label()||["scale"].indexOf(e.type())<0,"disable")}),Ze.prototype.publish("template",null,"string","template",null,{optional:!0,disable:f(e=>!e.label()||["template"].indexOf(e.type())<0,"disable")}),Ze.prototype.publish("default",null,"any","Default Value",null,{optional:!0,disable:f(e=>!e.label()||["map"].indexOf(e.type())<0,"disable")}),Ze.prototype.publish("mapping",[],"propertyArray","Mapped Values",null,{autoExpand:Xe,disable:f(e=>e.disableMapping(),"disable")}),Ze.prototype.publish("childField",[],"propertyArray","Child Fields",null,{autoExpand:Ze,disable:f(e=>e.disableChildField(),"disable")}),tt.prototype.publish("label","","string","Label"),tt.prototype.publish("multiFields",[],"propertyArray","Multi Fields",null,{autoExpand:Ze}),st.prototype.publish("computedFields",[],"propertyArray","Computed Fields",null,{autoExpand:Ze});const lt=class _SortColumn extends i.PropertyExt{_owner;validate(e){const t=[];return this.fieldID_valid()||t.push({source:`${e}.fieldID`,msg:`Invalid fieldID: ${this.fieldID()}`,hint:`expected ${JSON.stringify(this.fieldIDs())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}toDDL(){return{fieldID:this.fieldID(),descending:this.descending()}}fromDDL(e){return this.fieldID(e.fieldID).descending(e.descending)}static fromDDL(e){return(new _SortColumn).fromDDL(e)}hash(){return s.hashSum({sortColumn:this.fieldID(),descending:this.descending()})}fieldIDs(){return this._owner.fieldIDs()}field(e){return this._owner.inFields().filter(t=>t.id===e)[0]}};f(lt,"SortColumn");let ht=lt;ht.prototype._class+=" SortColumn";const ut=class _Sort extends S{validate(){let e=[];for(const t of this.validSortBy())e=e.concat(t.validate("Sort.column"));return e}constructor(){super()}toDDL(){return{type:"sort",conditions:this.conditions()}}fromDDL(e){return this.conditions(e.conditions),this}static fromDDL(e){return(new _Sort).fromDDL(e)}conditions(e){return arguments.length?(this.column(e.map(e=>ht.fromDDL(e))),this):this.validSortBy().map(e=>e.toDDL())}hash(){return s.hashSum({Sort:this.column().map(e=>e.hash())})}referencedFields(e){super.referencedFields(e),super.resolveInFields(e,this.validSortBy().map(e=>e.fieldID()))}validSortBy(){return this.column().filter(e=>e.fieldID())}exists(){return this.validSortBy().length>0}fieldIDs(){return this.inFields().map(e=>e.id)}computeData(){const e=super.computeData(),t=[];for(const s of this.validSortBy())t.push({compare:s.descending()?i.descending:i.ascending,id:s.fieldID()});return t.length?[...e].sort((e,i)=>{for(const s of t){const t=s.compare(e[s.id],i[s.id]);if(0!==t)return t}return 0}):e}};f(ut,"Sort"),D(ut,"Column",ht);let ct=ut;ct.prototype._class+=" Sort",ht.prototype.publish("fieldID",null,"set","Sort Field",function(){return this.fieldIDs()},{optional:!0,validate:f(e=>e.fieldIDs().indexOf(e.fieldID())>=0,"validate")}),ht.prototype.publish("descending",!1,"boolean","Sort Field"),ct.prototype.publish("column",[],"propertyArray","Source Columns",null,{autoExpand:ht});const dt=class _HipiePipeline extends ${constructor(e,t){super(),this._ec=e,this._id=t,this._datasource=new $e(this._ec),this._filters=new qe(this._ec),this._project=new at,this._groupBy=new Je,this._sort=new ct,this._limit=new Qe,this.updateSequence()}_ec;_origDatasource;_origFilters;_origProject;_origGroupBy;_origSort;_origLimit;activities(e){return super.activities.apply(this,arguments)}updateSequence(){this.activities([this.datasource(),this.filters(),this.project(),this.groupBy(),this.sort(),this.limit()])}selectionFields(){return this.last().outFields()}};f(dt,"HipiePipeline");let pt=dt;function mt(e){const t=`_orig${e.charAt(0).toUpperCase()+e.slice(1)}`;pt.prototype[t]=pt.prototype[e],pt.prototype[e]=function(e){const i=pt.prototype[t].apply(this,arguments);return void 0!==e&&this.updateSequence(),i}}pt.prototype.publish("datasource",null,"widget","Data Source 2"),pt.prototype.publish("filters",null,"widget","Client Filters"),pt.prototype.publish("project",null,"widget","Project"),pt.prototype.publish("groupBy",null,"widget","Group By"),pt.prototype.publish("sort",null,"widget","Sort"),pt.prototype.publish("limit",null,"widget","Limit output"),f(mt,"wrapHipiePipelineProperty"),mt("datasource"),mt("filters"),mt("project"),mt("groupBy"),mt("sort"),mt("limit");const _t=class _NullView extends pt{hash(){return super.hash()}_fetch(e,t){return Promise.resolve([])}};f(_t,"NullView");let ft=_t;ft.prototype._class+=" NullView";const Dt=class _VizPopupPanel extends u.Modal{_owner;_ownerLParam;constructor(e,t){super(),this._owner=e,this._ownerLParam=t,this._drawStartPos="origin",this.visible(!1),this.minHeight_default("240px"),this.minWidth_default("320px"),this.overflowY_default("hidden")}_host;host(e){return arguments.length?(this._host&&this._host!==e&&this._host._togglePopup.selected(!1).render(),this._host=e,this._owner.vizActivation(this._ownerLParam),this):this._host}enter(e,t){e.parentElement.style.position="absolute";const i=this.widget().title();i&&(this.title(i),this.widget().titleVisible(!1)),super.enter(e,t)}update(e,t){this.fixedTop(this._pos.y+"px"),this.fixedLeft(this._pos.x+"px"),super.update(e,t)}exit(e,t){super.exit(e,t);this.widget().title()&&this.widget().titleVisible(!0)}closeModal(){super.closeModal(),this._host&&this._host._togglePopup.selected(!1).render()}};f(Dt,"VizPopupPanel");let vt=Dt;vt.prototype._class+=" marshaller_VizPopupPanel";const gt=class _VizChartPanel extends u.ChartPanel{_popup;_togglePopup=(new i.ToggleButton).faChar("fa-filter").tooltip("Filter").on("click",()=>{this._popup.host(this);const e=this.locateClosestAncestor(["marshaller_DashboardDockPanel","marshaller_DashboardGrid"]).getBBox(!0),t=this._popup.widget(),i=this._togglePopup.getBBox();this._popup.pos({x:-e.x+i.x+i.width-t.minWidth(),y:-e.y+i.y+i.height}).resize({width:t.minWidth(),height:t.minHeight()}).visible(this._togglePopup.selected()).render(e=>{const t="#"+e.id()+" .layout_Carousel .common_Widget",i=e.element().node();if(i){const{height:s,width:r}=i.querySelector(t).getBoundingClientRect();e.resizeBodySync(r,s)}})});_origButtons;_filterButtons;constructor(){super(),this._origButtons=this.buttons(),this._filterButtons=[this._togglePopup,new i.Spacer,...this._origButtons]}popup(e){return arguments.length?(this._popup=e,this._popup||this._togglePopup.selected(!1),this.buttons(this._popup?this._filterButtons:this._origButtons),this):this._popup}};f(gt,"VizChartPanel");let yt=gt;yt.prototype._class+=" marshaller_VizChartPanel",yt.prototype.publish("descriptionTemplate","","string"),yt.prototype.publish("minWidth",320,"number","Min Width"),yt.prototype.publish("minHeight",240,"number","Min Height");const bt={Table:o.Table,FieldForm:n.FieldForm,Area:a.Area,Bubble:a.Bubble,Bar:a.Bar,Column:a.Column,Contour:a.Contour,HexBin:a.HexBin,Line:a.Line,Pie:a.Pie,Radar:a.Radar,RadialBar:a.RadialBar,Scatter:a.Scatter,Step:a.Step,WordCloud:a.WordCloud,USCountiesChoropleth:h.ChoroplethCounties,USStatesChoropleth:h.ChoroplethStates,ClusterPins:h.Leaflet.ClusterPins,EntityRectList:i.EntityRectList,AdjacencyGraph:l.AdjacencyGraph,DataGraph:l.DataGraph},wt=[];for(const bi in bt)wt.push(bi);function Ft(e){return bt[e]||o.Table}function xt(e){const t=new(bt[e]||o.Table);return t instanceof n.FieldForm?t.validate(!1).allowEmptyRequest(!0):t instanceof l.AdjacencyGraph&&t.uidColumn("uid").labelColumn("label").iconColumn("icon").linksColumn("links").linkUidColumn("uid").linkLabelColumn("label"),t}function Pt(e){return Ft(e).__inputs||[]}f(Ft,"typeClass"),f(xt,"typeNew"),f(Pt,"typeInputs");const St=class _Visualization extends i.PropertyExt{constructor(e,t){super(),this._ec=e,this._hipiePipeline=t,this.mappings(new nt),this.chartPanel(new yt),this.typeChanged()}_ec;_origVisibility;_origChartType;_origChartPanel;_hipiePipeline;visualizationIDs(){return this._ec.elementIDs().filter(e=>e!==this.id())}_prevChartType;typeChanged(){if(this._prevChartType!==this._chartType){this._prevChartType=this._chartType,this.refreshMappings();const e=xt(this._chartType);this.chartPanel().widget(e)}}properties(e){return arguments.length?(this.chartPanel().deserialize(e),this):this.chartPanel().serialize()}refreshMappings(){const e=this.mappings();e.sourceActivity(this._hipiePipeline);const t=e.validComputedFields(),i=e.inFields(),s={};return e.computedFields(Pt(this._chartType).map((r,a)=>{let o=t[a];if(o)o instanceof tt||o.label(r.id);else if(r.multi){o=(new tt).owner(e).label(r.id);const t=[];for(const e of i)"any"!==r.type&&r.type!==e.type||s[e.id]||(s[e.id]=!0,t.push((new Ze).label(e.id).type("=").column1(e.id)));o.multiFields(t)}else{o=(new Ze).owner(e).label(r.id).type("=");for(const e of i)if(("any"===r.type||r.type===e.type)&&!s[e.id]){s[e.id]=!0,o.column1(e.id);break}}return o})),this}_prevFields=[];_prevLinkFields=[];_prevData=[];refreshData(){const e=this.mappings(),t=e.outFields(),i=this.toDBFields(t);let s,r=[];const a=this._ec.element(this.secondaryDataviewID());a&&(s=a.mappings().outFields(),r=this.toDBFields(s));const o=this._prevFields!==t||this._prevLinkFields!==s;if(o)if(this._prevFields=t,"DataGraph"===this.chartType()){const e=this.chartPanel().widget();e.vertexColumns(i.map(e=>e.label())),e.edgeColumns(r.map(e=>e.label()))}else this.chartPanel().fields(i.filter(e=>"__lparam"!==e.id()));else console.warn(`***${this.id()} Immutable Fields***`);const n=e.outData(),l=this._prevData!==n;if(l){this._prevData=n;const e=this.toDBData(i,n);if("DataGraph"===this.chartType()){const t=this.chartPanel().widget();if(t.vertices(e),a){const e=a.mappings().outData(),i=this.toDBData(r,e);t.edges(i)}}else this.chartPanel().data(e)}else console.warn(`${this.id()} Immutable Data!`);return o||l?this.chartPanel().renderPromise().then(()=>{}):Promise.resolve()}fieldTypeTodbFieldType(e){switch(e){case"dataset":return"nested";case"boolean":return"boolean";case"number":return"number";default:return"string"}}toDBFields(e){const t=[];for(const s of e||[]){const e=(new i.Database.Field).type(this.fieldTypeTodbFieldType(s.type)).id(s.id).label(s.id);if("dataset"===s.type)e.children(this.toDBFields(s.children));t.push(e)}return t}toDBData(e,t){return(s.isArray(t)?t:[t]).map(t=>{const i=[];for(const s of e)"nested"===s.type()?i.push(this.toDBData(s.children(),t[s.id()].Row||t[s.id()])):i.push(t[s.label()]);return i})}exec(){const e=[];if(this.secondaryDataviewID_exists()){const t=this.secondaryDataviewID(),i=this._ec.element(t);i&&e.push(i.visualization().exec())}const t=this.mappings();return t.sourceActivity(this._hipiePipeline),e.push(t.refreshMeta().then(()=>t.exec())),Promise.all(e)}refresh(){return this.chartPanel().startProgress&&this.chartPanel().startProgress(),this.exec().then(()=>(this.chartPanel().finishProgress&&this.chartPanel().finishProgress(),this.refreshData()))}click(e,t,i,s){}vertex_click(e,t,i){}};f(St,"Visualization");let Lt=St;Lt.prototype._class+=" Visualization",Lt.prototype.publishProxy("title","_chartPanel"),Lt.prototype.publishProxy("description","_chartPanel"),Lt.prototype.publish("visibility",r.DDL2.VisibilitySet[0],"set","Type",r.DDL2.VisibilitySet),Lt.prototype.publish("chartType","Table","set","Type",wt),Lt.prototype.publish("secondaryDataviewID",null,"set","Secondary Data View (e.g. graph edges)",function(){return this.visualizationIDs()},{optional:!0}),Lt.prototype.publish("mappings",null,"widget","Mappings",void 0,{render:!1,internal:!0}),Lt.prototype.publish("chartPanel",[],"widget","Widget"),Lt.prototype._origVisibility=Lt.prototype.visibility,Lt.prototype.visibility=function(e){const t=this._visibility,i=Lt.prototype._origVisibility.apply(this,arguments);return void 0!==e&&t!==e&&this.chartPanel().target(null),i},Lt.prototype._origChartType=Lt.prototype.chartType,Lt.prototype.chartType=function(e,t){void 0!==e&&-1===wt.indexOf(e)&&(e="Table");const i=Lt.prototype._origChartType.apply(this,arguments);if(void 0!==e&&(this.typeChanged(),t)){const e=this.chartPanel().widget();for(const i in t)"function"==typeof e[i]&&e[i](t[i])}return i},Lt.prototype._origChartPanel=Lt.prototype.chartPanel,Lt.prototype.chartPanel=function(e){const t=Lt.prototype._origChartPanel.apply(this,arguments);if(void 0!==e){this._chartPanel.on("click",(e,t,i,s)=>this.click(e,t,i,s)).on("vertex_click",(e,t,i)=>this.vertex_click(e,t,i));for(const e in bt)if(this._chartPanel.widget()instanceof bt[e]){this._chartType=e;break}}return t};const Ct=class _State extends i.PropertyExt{constructor(){super(),this.selection([])}set(e){return s.hashSum(this.selection())!==s.hashSum(e)&&(this.selection(e),!0)}removeInvalid(e){const t=this.selection(),i=[];for(const r of t)s.find(e,(e,t)=>{for(const i in r)if(r[i]!==e[i])return!1;return!0})&&i.push(r);return i.length!==t.length&&(this.selection(i),!0)}};f(Ct,"State");let It=Ct;It.prototype._class+=" State",It.prototype.publish("selection",[],"array","State");let $t=0;const Rt=class _Element extends i.PropertyExt{constructor(e){for(super(),this._ec=e;$t++,this._id=`e_${$t}`,this._ec.elementExists(this._id););const t=new pt(this._ec,this._id);this.hipiePipeline(t),this._vizChartPanel=new Lt(this._ec,this.hipiePipeline()).id(`viz_${$t}`).title(`Element ${$t}`),this._vizChartPanel.chartPanel().id(`cp_${$t}`),this.visualization(this._vizChartPanel),this.state(new It)}_ec;_vizChartPanel;_origVisualization;id(e){const t=super.id.apply(this,arguments);return arguments.length&&this._vizChartPanel.id(e),t}chartType(){return this._vizChartPanel.chartType()}chartPanel(e){return arguments.length?(this._vizChartPanel.chartPanel(e),this):this._vizChartPanel.chartPanel()}chart(){return this._vizChartPanel.chartPanel().widget()}mappings(e){return arguments.length?(this._vizChartPanel.mappings(e),this):this._vizChartPanel.mappings()}pipeline(e){return this.hipiePipeline().activities(e),this}updatedBy(){const e=this.hipiePipeline().updatedBy();return this.visualization().secondaryDataviewID_exists()&&e.push(this.visualization().secondaryDataviewID()),e}dataProps(){return this.hipiePipeline()}vizProps(){return this.visualization().chartPanel()}stateProps(){return this.state()}_errors=[];errors(){return this._errors}validate(){if(!this._initialized)return[];this._errors=[];const e=this.hipiePipeline();for(const t of[...e.activities(),this.mappings()])for(const e of t.validate())this._errors.push({elementID:this.id(),...e});return this._errors}_initialized=!1;refresh(){const e=this.hipiePipeline().filters().validFilters().map(e=>e.createFilterDescription());return this.visualization().chartPanel().description(e.join(", ")),this.visualization().refresh().then(()=>{this._initialized=!0;const e=this.hipiePipeline().outData();"FieldForm"===this.visualization().chartType()?this.state().set([...e])&&this.selectionChanged():this.state().removeInvalid(e)&&this.selectionChanged()})}selection(e){return arguments.length?(this.state().selection(e),this.selectionChanged(),this):this.state().selection()}selectionChanged(){const e=[];for(const t of this._ec.filteredBy(this.id()))e.push(t.refresh());Promise.all(e).then(()=>{this._ec.vizStateChanged(this)})}monitor(e){return this.hipiePipeline().monitor(e)}};f(Rt,"Element");let Et=Rt;Et.prototype._class+=" Viz",Et.prototype.publish("hipiePipeline",null,"widget","Data View"),Et.prototype.publish("visualization",null,"widget","Visualization"),Et.prototype.publish("state",null,"widget","State"),Et.prototype._origVisualization=Et.prototype.visualization,Et.prototype.visualization=function(e){const t=Et.prototype._origVisualization.apply(this,arguments);return void 0!==e&&this._visualization.on("click",(e,t,i,r)=>{if(r&&r.selection)this.selection(i?r.selection.map(e=>e.__lparam||e):[]);else{const t=s.isArray(e)?e:[e];this.selection(i?t.map(e=>e.__lparam||e):[])}}).on("vertex_click",(e,t,i)=>{const r=s.isArray(e)?e:[e];this.selection(i?r.map(e=>e.__lparam||e):[])}),t};const At=class _ElementContainer extends i.PropertyExt{_nullElement;_datasources=[U];_elements=[];constructor(){super(),this.clear(),this._nullElement=new Et(this)}clear(e){this._datasources=void 0===e?[U]:this._datasources,this._elements=void 0===e?[]:this._elements.filter(t=>t.id()!==e)}_hookSend;hookSend(e){return arguments.length?(this._hookSend=e,this):this._hookSend}datasources(e){return arguments.length?(this._datasources=e,this):this._datasources}datasource(e){return this._datasources.filter(t=>t.id()===e)[0]}appendDatasource(e){return this._datasources.push(e),this}removeDatasource(e){return this._datasources=this._datasources.filter(t=>t!==e),this}elements(){return[...this._elements]}element(e){let t;return t="string"==typeof e?this._elements.filter(t=>t.id()===e):e instanceof yt?this._elements.filter(t=>t.chartPanel()===e):this._elements.filter(t=>t.vizProps()===e),t.length?t[0]:this._nullElement}elementExists(e){return this.element(e)!==this._nullElement}elementIDs(){return this._elements.map(e=>e.id())}append(e){return this._elements.push(e),this}filteredBy(e){return this._elements.filter(t=>t.updatedBy().indexOf(e)>=0)}views(){return this._elements.map(e=>e.hipiePipeline())}view(e){return this.views().filter(t=>t.id()===e)[0]}normalizePersist(e){const t={};return e.__properties.content.map(e=>{const s=!!e.__properties.widget.__properties.chart,r=e,a=e.__properties.widget,o=s?e.__properties.widget.__properties.chart:e.__properties.widget.__properties.widget,n=e.__properties.widget.__id?e.__properties.widget.__id:e.__properties.widget.__properties.widget.__id;t[n]={id:n,package:o.__class.split("_")[0],object:o.__class.split("_")[1],cell:i(r,["chart","widget","fields"]),panel:i(a,["chart","widget","fields"]),widget:i(o,["fields"])}}),t;function i(e,t){const i={};return Object.keys(e.__properties).filter(e=>-1===t.indexOf(e)).forEach(t=>i[t]=e.__properties[t]),i}}validate(){let e=[];return this._elements.forEach(t=>{e=e.concat(t.validate())}),e}refresh(){return Promise.all(this.elements().map(e=>e.refresh())).then(()=>this)}vizStateChanged(e){}};f(At,"ElementContainer");let zt=At;function Bt(e){if(!e.ok)throw new Error(e.status+" "+e.statusText);return e.text()}function Mt(e,t){return fetch(e,t).then(Bt)}zt.prototype._class+=" dashboard_ElementContainer",zt.prototype.publish("samples",10,"number","Number of samples"),zt.prototype.publish("sampleSize",100,"number","Sample size"),f(Bt,"responseText"),f(Mt,"d3Text");const jt=class _PopupManager extends i.Widget{_ec;_popups=[];_popupIdx={};popupPanels(){return this._popups||(this._popups=[]),this._popupIdx||(this._popupIdx={}),this._popups}popupChartPanels(){return this.popupPanels().map(e=>e.widget())}addPopup(e){const t=this._ec.element(e),i=this.element().node(),s=new vt(this,t).target(i).widget(e).relativeTargetId(this.id()).size({width:e.minWidth(),height:e.minHeight()});this._popups.push(s),this._popupIdx[e.id()]={panel:s,monitorHandle:e.monitor(t=>{switch(t){case"minWidth":case"minHeight":s.resize({width:e.minWidth(),height:e.minHeight()}).render()}})},this._ec.filteredBy(t.id()).forEach(e=>{e.visualization().chartPanel().popup(s)})}removePopup(e){const t=this._ec.element(e);this._ec.filteredBy(t.id()).forEach(e=>{e.visualization().chartPanel().popup(null)}),this._popupIdx[e.id()].panel.target(null),this._popupIdx[e.id()].monitorHandle.remove(),e.target(null),delete this._popupIdx[e.id()],this._popups=this._popups.filter(t=>t.widget()!==e)}syncPopups(){const e=this.popupChartPanels(),t=s.compare(e,this._ec.elements().filter(e=>"flyout"===e.visualization().visibility()).map(e=>e.visualization().chartPanel()));for(const i of t.exit)this.removePopup(i);for(const i of t.enter)this.addPopup(i);return this}vizActivation(){}};f(jt,"PopupManager");let kt=jt;const qt=class _DashboardDockPanel extends c.DockPanel{constructor(e){super(),this._ec=e}_ec;tabTitle(e){return this.hideSingleTabs()?e.visualization().title?e.visualization().title():e.visualization().id():e.id()}titleClassed(e,t,i){let s=e.title.className.split(" ");i&&s.indexOf(t)<0?s.push(t):!i&&s.indexOf(t)>0&&(s=s.filter(e=>e!==t)),e.title.className=s.join(" ")}updateTitle(e){const t=this.getWidgetAdapter(e),i=this._ec.element(e),s=i.validate();t.title.label=this.tabTitle(i),this.titleClassed(t,"error",s.length>0),t.title.caption=s.map(e=>`${e.source}: ${e.msg}`).join("\n")}activate(e){const t=this.getWidgetAdapter(e.visualization().chartPanel());t&&t.activate()}syncMinSize(e){if(e.minWidth_exists()||e.minHeight_exists()){const t=this.getWidgetAdapter(e);return i.select(t.node).style("min-width",`${e.minWidth()}px`).style("min-height",`${e.minHeight()}px`),!0}return!1}syncWidgets(){const e=this.widgets(),t=s.compare(e,this._ec.elements().filter(e=>"normal"===e.visualization().visibility()).map(e=>e.visualization().chartPanel()));let i=!1;for(const s of t.exit)this.removeWidget(s);for(const s of t.enter){const e=this._ec.element(s);this.addWidget(s,this.tabTitle(e),"split-bottom",void 0,this.hideSingleTabs()?void 0:this),i=this.syncMinSize(s)||i}for(const s of t.update)this.updateTitle(s),i=this.syncMinSize(s)||i;return i&&this.refit(),this}childActivation(e,t){super.childActivation(e,t),this.vizActivation(this._ec.element(e));for(const i of this.widgetAdapters())i===t?(i.addClass("active"),this.titleClassed(i,"active",!0),i.title.iconClass="active"):(i.removeClass("active"),this.titleClassed(i,"active",!1),i.title.iconClass="")}vizActivation(e){}canClose(e,t){const i=this._ec.element(e).id(),s=window.confirm(`Remove Widget "${i}"?`);return s&&(this._ec.clear(i),this.syncWidgets(),this.vizActivation(void 0)),s}syncPopups(){}};f(qt,"DashboardDockPanel");let Vt=qt;Vt.prototype._class+=" marshaller_DashboardDockPanel",Vt.prototype.mixin(kt);const Nt=class _DashboardGrid extends u.Grid{constructor(e){super(),this._ec=e,this.designMode(!1),this.surfacePadding("0"),this.surfaceBorderWidth(0)}_ec;_layoutCache=[];updateGrid(e,t=0,i=!1){super.updateGrid(e,t,i),this._layoutCache=this.content().map(e=>({id:e.widget().id(),position:[e.gridCol(),e.gridRow(),e.gridColSpan(),e.gridRowSpan()]}))}layoutObj(e){if(e)if(e.main){const i=t(e,10,10);this._layoutCache=i}else e instanceof Array&&(this._layoutCache=e);return this;function t(e,t,i){const s=[];return r(e.main,0,0,t,i),s;function r(e,t,i,a,o){e.children?"split-area"===e.type?"horizontal"===e.orientation?e.children.forEach((s,n)=>{const l=e.sizes[n]*a,h=o,u=0===n?t:t+e.sizes[0]*a,c=i;r(e.children[n],u,c,l,h)}):"vertical"===e.orientation?e.children.forEach((s,n)=>{const l=a,h=e.sizes[n]*o,u=t,c=0===n?i:i+e.sizes[0]*o;r(e.children[n],u,c,l,h)}):console.error("wtf"):"tab-area"===e.type&&e.children.forEach((s,n)=>{const l=a,h=e.sizes[n]*o,u=t,c=0===n?i:i+e.sizes[0]*o;r(e.children[n],u,c,l,h)}):s.push([t,i,a,o].map(Math.round))}}}layout(){return this._layoutCache}widgets(){return this.content().map(e=>e.widget())}hideSingleTabs(){return!0}getWidgetAdapter(){}tabTitle(e){return this.hideSingleTabs()?e.visualization().title?e.visualization().title():e.visualization().id():e.id()}updateTitle(e){const t=this.getWidgetCell(e.id()),i=this._ec.element(e),s=this.tabTitle(i);t.widget().title(s)}activate(e){}removeWidget(e){const t=this.getWidgetCell(e.id());this.clearContent(t)}syncMinSize(e){if(e.minWidth_exists()||e.minHeight_exists()){return this.getWidgetCell(e.id()).element().style("min-width",`${e.minWidth()}px`).style("min-height",`${e.minHeight()}px`),!0}return!1}syncWidgets(){const e=this.widgets(),t=s.compare(e,this._ec.elements().filter(e=>"normal"===e.visualization().visibility()).map(e=>e.visualization().chartPanel()));for(const s of t.exit)this.removeWidget(s);const i=[];for(const s of t.enter){const e=this._ec.element(s),t=this.content().length;if(this._layoutCache&&this._layoutCache[t]){const t=this._layoutCache.find(e=>e.id===s.id());if(t){const[i,s,r,a]=t.position;this.setContent(s,i,e.visualization().chartPanel(),"",a,r)}else i.push(e.visualization().chartPanel())}else i.push(e.visualization().chartPanel())}let r=this.content().reduce((e,t)=>Math.max(e,t.gridRow()+t.gridRowSpan()),0);i.forEach(e=>{this.setContent(r,0,e,"",3,3),r+=3});for(const s of t.update)this.updateTitle(s);return this}childActivation(e,t){this.vizActivation(this._ec.element(e))}postSelectionChange(){super.postSelectionChange();const e=this._selectionBag.get();e.length>0&&this.childActivation(e[0].widget.widget())}vizActivation(e){}canClose(e,t){const i=this._ec.element(e).id(),s=window.confirm(`Remove Widget "${i}"?`);return s&&(this._ec.clear(i),this.syncWidgets(),this.vizActivation(void 0)),s}syncPopups(){}};f(Nt,"DashboardGrid");let Tt=Nt;Tt.prototype._class+=" marshaller_DashboardGrid",Tt.prototype.mixin(kt);const Ot=s.scopedLogger("marshaller/ddl2/ddl"),Wt=class _DDLDatasourceAdapter{_dsDedup;constructor(){}clear(){this._dsDedup={}}id(e){return e instanceof ie?`${e.url()}/${e.wuid()}`:e instanceof be?`${e.url()}/${e.querySet()}/${e.queryID()}`:e instanceof ue?`${e.url()}/${e.action()}`:e.id()}_resolveID(e){return this._dsDedup[this.id(e)].ds.id()}resolveID(e){return e instanceof re?this._resolveID(e.datasource().wu()):e instanceof Pe||e instanceof Le||e instanceof fe?this._resolveID(e.datasource().service()):void 0}append(e){const t=e instanceof $e?e.datasource():e,i=e instanceof $e?e.datasourceRef():void 0,s=t.id(),r=t instanceof ee?t.wu():t instanceof Fe||t instanceof de?t.service():t,a=this.id(r);this._dsDedup[a]||(this._dsDedup[a]={ds:r,result:{}}),this._dsDedup[a].result[s]||(this._dsDedup[a].result[s]={refType:t,ref:i})}getAll(){const e=[];for(const t in this._dsDedup){const i=this._dsDedup[t].ds.toDDL();if("roxie"===i.type||"hipie"===i.type||"rest"===i.type){const e={};for(const i in this._dsDedup[t].result){const s=this._dsDedup[t].result[i].refType.toDDL(),r={inputs:{},outputs:{}};this._dsDedup[t].result[i].ref.referencedFields(r);for(const t in r.inputs)r.inputs[t].forEach(t=>{e[t]=s.inputs.filter(e=>e.id===t)[0]})}i.inputs=[];for(const t in e)i.inputs.push(e[t])}if("wuresult"===i.type||"roxie"===i.type||"hipie"===i.type||"rest"===i.type){const e={};for(const i in this._dsDedup[t].result){const s=this._dsDedup[t].result[i].refType.toDDL();if("wuresult"===s.type||"roxie"===s.type||"hipie"===s.type||"rest"===s.type)for(const t in s.outputs)e[t]=s.outputs[t]}i.outputs={};for(const t in e)i.outputs[t]=e[t]}e.push(i)}return e}};f(Wt,"DDLDatasourceAdapter");let Ht=Wt;const Gt=class _DDLAdapter{_dashboard;_ec;_dsWriteDedup=new Ht;_dsReadDedup={};constructor(e){this._dashboard=e,this._ec=this._dashboard.elementContainer()}writeDatasources(){for(const e of this._ec.elements())this._dsWriteDedup.append(e.hipiePipeline().datasource());return this._dsWriteDedup.getAll()}writeFilters(e){if(e.exists())return e.toDDL()}readFilters(e,t){return qe.fromDDL(t,e)}writeProject(e){if(e.exists())return e.toDDL()}readProject(e){return at.fromDDL(e)}writeMappings(e){return e.exists()?e.toDDL():{type:"mappings",transformations:[]}}readMappings(e){return nt.fromDDL(e)}writeGroupBy(e){if(e.exists())return e.toDDL()}readGroupBy(e){return Je.fromDDL(e)}writeSort(e){if(e.exists())return e.toDDL()}readSort(e){return ct.fromDDL(e)}writeLimit(e){if(e.exists())return e.toDDL()}readLimit(e){return Qe.fromDDL(e)}readDatasourceRef(e,t,i){if(r.DDL2.isWUResultRef(e)){const i=this._dsReadDedup[e.id];t.datasourceID(i.output(e.output).id())}else if(r.DDL2.isRoxieServiceRef(e)){t.datasourceID(`${e.id}_${e.output}`);t.datasourceRef().request(e.request.map(e=>me.fromDDL(this._ec,e)))}else t.datasourceID(e.id);return this}writeActivities(e){return e.activities().map(e=>e instanceof qe?this.writeFilters(e):e instanceof at?this.writeProject(e):e instanceof Je?this.writeGroupBy(e):e instanceof ct?this.writeSort(e):e instanceof Qe?this.writeLimit(e):e instanceof nt?this.writeMappings(e):void(e instanceof $e||Ot.warning(`Unknown activity type: ${e.classID()}`))).filter(e=>!!e)}writeVisualization(e){return{id:e.chartPanel().id(),title:e.title(),description:e.description(),visibility:e.visibility(),chartType:e.chartType(),__class:e.chartPanel().widget().classID(),mappings:this.writeMappings(e.mappings()),properties:e.properties()}}readVisualization(e,t){const i=this.readMappings(e.mappings);return t.chartPanel().id(e.id),t.title(e.title).description(e.description).visibility(e.visibility).chartType(e.chartType).properties(e.properties).mappings(i),this}writeViewDatasource(e){const t=e.toDDL();return t.id=this._dsWriteDedup.resolveID(e)||t.id,t}writeDDLViews(){const e={inputs:{},outputs:{}};for(const t of this._ec.elements())t.visualization().mappings().referencedFields(e);return this._ec.elements().map(e=>{const t=e.hipiePipeline(),i=t.datasource();if(i instanceof $e){const s=i.datasourceRef();return{id:e.id(),datasource:this.writeViewDatasource(s),activities:this.writeActivities(t),visualization:this.writeVisualization(e.visualization())}}throw new Error("Missing DSPicker?")})}writeProperties(){return{name:v,version:g,buildVersion:y,layout:this._dashboard.layout()}}readDDLViews(e){for(const t of e){const e=new Et(this._ec).id(t.id);this._ec.append(e);const i=e.hipiePipeline();this.readDatasourceRef(t.datasource,i.datasource(),this._ec);for(const s of t.activities){if(r.DDL2.isProjectActivity(s)){const e=this.readProject(s);i.project(e)}if(r.DDL2.isFilterActivity(s)){const e=this.readFilters(s,this._ec);i.filters(e)}if(r.DDL2.isGroupByActivity(s)){const e=this.readGroupBy(s);i.groupBy(e)}if(r.DDL2.isSortActivity(s)){const e=this.readSort(s);i.sort(e)}if(r.DDL2.isLimitActivity(s)){const e=this.readLimit(s);i.limit(e)}}this.readVisualization(t.visualization,e.visualization())}}readProperties(e){e&&e.layout&&this._dashboard.layoutObj(e.layout)}write(){this._dsWriteDedup.clear();return{version:"2.2.1",createdBy:{name:v,version:g},datasources:this.writeDatasources(),dataviews:this.writeDDLViews(),properties:this.writeProperties(),hipieProperties:this._dashboard.hipieProps()}}read(e){this._dsWriteDedup.clear();for(const t of e.datasources)switch(t.type){case"databomb":this._ec.appendDatasource(H.fromDDL(t));break;case"form":this._ec.appendDatasource(N.fromDDL(t));break;case"logicalfile":this._ec.appendDatasource(oe.fromDDL(this._ec,t));break;case"wuresult":const e=ie.fromDDL(this._ec,t);this._dsReadDedup[e.id()]=e;for(const r in t.outputs)this._ec.appendDatasource(e.output(r));break;case"roxie":case"hipie":const i=be.fromDDL(this._ec,t);this._dsReadDedup[i.id()]=i;for(const r in t.outputs)this._ec.appendDatasource(Fe.fromDDL(this._ec,i,r));break;case"rest":const s=ue.fromDDL(this._ec,t);this._dsReadDedup[s.id()]=s;for(const r in t.outputs)this._ec.appendDatasource(de.fromDDL(this._ec,s,r));break;default:Ot.warning(`Unknown ddl datasource type: ${t.type} `)}this.readDDLViews(e.dataviews),this.readProperties(e.properties),this._dashboard.hipieProps(e.hipieProperties)}};f(Gt,"DDLAdapter");let Jt=Gt;const Ut=class _Imports{_moduleMap={};append(e){this._moduleMap[e.module]||(this._moduleMap[e.module]={}),this._moduleMap[e.module][e.class]=!0}write(){const e=[];for(const t in this._moduleMap){const i=[];for(const e in this._moduleMap[t])i.push(e);i.sort(),e.push(`import { ${i.join(", ")} } from "${t}";`)}return e.join("\n")}};f(Ut,"Imports");let Qt=Ut;function Kt(e){const t={};for(const i of e.publishedProperties())if(e[i.id+"_modified"]()&&"fields"!==i.id){const s=e[i.id]();if("propertyArray"===i.type){const e=s.map(Kt);e&&(t[i.id]=e)}else t[i.id]=s}return t}f(Kt,"createProps");const Xt=class _JavaScriptAdapter{_dashboard;_ec;_ddlAdapter;_ddlSchema;constructor(e){this._dashboard=e,this._ec=this._dashboard.elementContainer(),this._ddlAdapter=new Jt(this._dashboard),this._ddlSchema=this._ddlAdapter.write()}createProps(e,t,i=""){let s=[];for(const r of t.publishedProperties())if(t[r.id+"_exists"]())switch(r.type){case"string":case"set":s.push(`${e}.${r.id}("${t[r.id]()}")${i};`);break;case"number":case"boolean":s.push(`${e}.${r.id}(${t[r.id]()})${i};`);break;case"widget":s=s.concat(this.createProps(`${e}.${r.id}()`,t[r.id]()));break;case"propertyArray":r.ext&&s.push(`${e}.${r.id}([${t[r.id]()}])${i};`)}return s}writeMeta(e){return""}safeID(e){return e?e.replace(/ /g,"_").replace(/\./g,"_"):e}datasourceRefID(e){const t=e.datasource;return r.DDL2.isRoxieServiceRef(t)?`${this.safeID(t.id)}_${this.safeID(t.output)}_${this.safeID(e.id)}`:r.DDL2.isWUResultRef(t)?`${this.safeID(t.id)}_${this.safeID(t.output)}`:`${this.safeID(t.id)}`}_dedup={};writeDatasource(e){const t=e.datasource,i=[],s=this._ddlSchema.datasources.filter(e=>e.id===t.id)[0],r=t.output,a=this.datasourceRefID(e);if(!this._dedup[a])switch(this._dedup[a]=!0,s.type){case"wuresult":const o=this.safeID(e.datasource.id);this._dedup[o]||(this._dedup[o]=!0,i.push(` export const ${o} = new marshaller.WU()\n .url("${s.url}")\n .wuid("${s.wuid}")\n ;`)),i.push(` export const ${a} = new marshaller.WUResult()\n .wu(${o})\n .resultName("${r}")\n .responseFields(${b(s.outputs[r].fields)})\n ;`);break;case"logicalfile":i.push(` export const ${a} = new marshaller.LogicalFile()\n .url("${s.url}")\n .logicalFile("${s.logicalFile}")\n .responseFields(${b(s.fields)})\n ;`);break;case"hipie":case"roxie":const n=this.safeID(e.datasource.id);this._dedup[n]||(this._dedup[n]=!0,i.push(` export const ${n} = new marshaller.RoxieService(ec)\n .url("${s.url}")\n .querySet("${s.querySet}")\n .queryID("${s.queryID}")\n .requestFields(${b(s.inputs)})\n ;`));const l=n+"_"+this.safeID(r);this._dedup[l]||(this._dedup[l]=!0,i.push(` export const ${l} = new marshaller.RoxieResult(ec)\n .service(${n})\n .resultName("${r}")\n .responseFields(${b(s.outputs[r].fields)})\n ;`)),i.push(` export const ${a} = new marshaller.HipieResultRef(ec)\n .datasource(${l})\n .requestFieldRefs(${b(t.request)})\n ;`);break;case"databomb":i.push(` export const ${a} = new marshaller.Databomb()\n .format("${s.format}")\n .payload(${JSON.stringify(s.payload)})\n ;`);break;case"form":{const e=[];for(const t of s.fields)e.push(`new marshaller.FormField().fieldID("${t.id}").default("${t.default||""}")`);i.push(` export const ${a} = new marshaller.Form()\n .formFields([\n ${e.join(",\n ")}\n ])\n ;`)}}return i}writeActivity(e){switch(e.type){case"filter":return`new marshaller.Filters(ec).conditions(${b(e.conditions)})`;case"project":return`new marshaller.Project().transformations(${b(e.transformations)})`;case"groupby":return`new marshaller.GroupBy().fieldIDs(${JSON.stringify(e.groupByIDs)}).aggregates(${b(e.aggregates)})`;case"sort":return`new marshaller.Sort().conditions(${b(e.conditions)})`;case"limit":return`new marshaller.Limit().rows(${e.limit})`;case"mappings":return`new marshaller.Mappings().transformations(${b(e.transformations)})`}}writeWidgetProps(e){const t=[];for(const i of e.publishedProperties())e[i.id+"_modified"]()&&"fields"!==i.id&&t.push(`.${i.id}(${JSON.stringify(e[i.id]())})`);return t}joinWithPrefix(e,t,i,r){let a,o="";e.__class&&(a=s.classID2Meta(e.__class),t.append(a),o+=`new ${a.class}()`);for(const n in e)if("__class"===n);else if(s.isArray(e[n])){const s=`${e[n].map(e=>this.joinWithPrefix(e,t,i+" ","")).join(`,${i} `)}`;s&&(o+=`${i} .${n}([${i} ${s}${i} ])${r}`)}else o+=`${i} .${n}(${JSON.stringify(e[n])})${r}`;return o}writeWidget(e,t){return` export const ${e.visualization.id} = new marshaller.VizChartPanel()\n .id("${e.visualization.id}")\n .title("${e.visualization.title}")\n .widget(${this.joinWithPrefix(e.visualization.properties.widget,t,"\n ","")})\n ;`}writeElement(e){const t=[`data.${this.datasourceRefID(e)}`];for(const s of e.activities)t.push(this.writeActivity(s));const i=[];for(const s of this._ec.filteredBy(e.id))i.push(`${s.id()}.refresh();`);return`\nconst ${e.id} = new marshaller.Element(ec)\n .id("${e.id}")\n .pipeline([\n ${t.join(",\n ")}\n ])\n .mappings(new marshaller.Mappings().transformations(${b(e.visualization.mappings.transformations)}))\n .chartPanel(viz.${e.visualization.id})\n .on("selectionChanged", () => {\n ${i.join("\n ")}\n }, true)\n ;\n${e.id}.visualization()\n .visibility("${e.visualization.visibility}")\n .secondaryDataviewID("${e.visualization.secondaryDataviewID||""}")\n ;\nec.append(${e.id});\n`}writeDatasources(){let e=[];for(const t of this._ddlSchema.dataviews)e=e.concat(this.writeDatasource(t));return e}writeWidgets(){const e=[],t=new Qt;for(const i of this._ddlSchema.dataviews)e.push(this.writeWidget(i,t));return{widgetImports:t.write(),widgetDefs:e.join("\n\n")}}writeElements(){let e="";for(const t of this._ddlSchema.dataviews)e+=this.writeElement(t);return e}createJavaScript(){const e=this.writeWidgets();return`${e.widgetImports}\nimport * as marshaller from "@hpcc-js/marshaller";\n\n// Dashboard Element Container (Model) ---\nconst ec = new marshaller.ElementContainer();\n\nnamespace data {\n${this.writeDatasources().join("\n")}\n}\n\nnamespace viz {\n${e.widgetDefs}\n}\n\n// Dashboard Elements (Controller) ---\n${this.writeElements().trim()}\n\nec.refresh();\n\n// Optional ---\nconst errors = ec.validate();\nfor (const error of errors) {\n console.error(error.elementID + " (" + error.source + "): " + error.msg);\n}\n\nexport const dashboard = new marshaller.Dashboard(ec)\n .target("placeholder")\n .titleVisible(false)\n .hideSingleTabs(true)\n .layoutObj(${b(this._dashboard.layout())})\n .render()\n ;\n\n// @ts-ignore\nconst ddl = ${JSON.stringify(this._ddlSchema)};\n`}};f(Xt,"JavaScriptAdapter");let Yt=Xt;const Zt=class _Dashboard extends u.ChartPanel{constructor(e){super(),this._ec=e,this._ec.on("vizStateChanged",e=>{this.vizStateChanged(e)}),this.buttons([this._designModeButton,new i.Spacer,this._addButton,this._removeButton,new i.Spacer,this._reloadButton,new i.Spacer,this._addSamples]),this.ensureDockPanel("dock")}_ec;_dockPanel;_designModeButton=(new i.ToggleButton).faChar("fa-object-group").tooltip("Design Mode...").selected(!0).on("click",()=>{this._dockPanel instanceof Tt&&this._dockPanel.designMode(this._designModeButton.selected()).lazyRender()});_addButton=(new i.Button).faChar("fa-plus").tooltip("Add...").on("click",()=>{const e=new Et(this._ec);this._ec.append(e),this.renderPromise().then(()=>{e.refresh().then(()=>{this.activate(e)})})});_removeButton=(new i.Button).faChar("fa-minus").tooltip("Remove...").enabled(!1).on("click",()=>{const e=this._prevActive;e&&window.confirm(`Remove Widget "${e.id()}"?`)&&(this._ec.clear(e.id()),this.renderPromise().then(()=>{this.vizActivation(void 0)}))});_reloadButton=(new i.Button).faChar("fa-refresh").tooltip("Reload...").on("click",()=>{const e=this.save();this._ec.clear(),this.vizActivation(void 0),this.renderPromise().then(()=>{this.restore(e),this.renderPromise().then(()=>{this._ec.refresh().then(()=>{})})})});_addSamples=(new i.Button).faChar("fa-database").tooltip("Add Samples").on("click",()=>{Promise.all([Mt("https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/airports.csv"),Mt("https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/carriers.csv"),Mt("https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/stats.csv")]).then(([e,t,i])=>{const s=this.addForm("popup",{type:"form",id:"global_filter",fields:[{type:"string",id:"Airport"},{type:"string",id:"Airline"}]});s.visualization().title("Global Filter").visibility("flyout").chartType("FieldForm");const r=this.addDatabomb("airports",e,"csv",[(new q).fieldID("code").type("string"),(new q).fieldID("name").type("string"),(new q).fieldID("count").type("number")],new qe(this._ec).remoteFilter([(new qe.Filter).source(s.id()).mappings([(new qe.Mapping).remoteField("Airport").localField("code").nullable(!0)])]),(new ct).column([(new ct.Column).fieldID("count").descending(!0)]));r.chartPanel().title("Airports");const a=this.addDatabomb("carriers",t,"csv",[(new q).fieldID("code").type("string"),(new q).fieldID("name").type("string"),(new q).fieldID("count").type("number")],new qe(this._ec).remoteFilter([(new qe.Filter).source(s.id()).mappings([(new qe.Mapping).remoteField("Airline").localField("code").nullable(!0)])]),(new ct).column([(new ct.Column).fieldID("count").descending(!0)]));a.chartPanel().title("Airlines");const o=this.addDatabomb("stats",i,"csv",[],new qe(this._ec).remoteFilter([(new qe.Filter).source(r.id()).mappings([(new qe.Mapping).remoteField("code").localField("airport")]),(new qe.Filter).source(a.id()).mappings([(new qe.Mapping).remoteField("code").localField("carrier").nullable(!0)])]));return o.chartPanel().title("Stats"),Promise.all([s.refresh(),r.refresh(),a.refresh(),o.refresh()])}).then(()=>{this.render()})});addDatabomb(e,t,i="csv",s,...r){const a=(new H).id(e).format(i).payload(t);s.length>0&&a.databombFields(s),this._ec.appendDatasource(a);const o=new Et(this._ec),n=o.hipiePipeline().datasource();n instanceof $e&&n.datasourceID(a.id());for(const l of r)l instanceof qe?o.hipiePipeline().filters(l):l instanceof at?o.hipiePipeline().project(l):l instanceof Je?o.hipiePipeline().groupBy(l):l instanceof ct?o.hipiePipeline().sort(l):l instanceof Qe&&o.hipiePipeline().limit(l);return this._ec.append(o),o}addForm(e,t){const i=(new N).id(e).fromDDL(t);this._ec.appendDatasource(i);const s=new Et(this._ec),r=s.hipiePipeline().datasource();return r instanceof $e&&r.datasourceID(i.id()),this._ec.append(s),s}static create(e,t){return new Promise((i,s)=>{const r=new zt,a=new _Dashboard(r).target(e).hideSingleTabs(!0).titleVisible(!1).restore(t).render(e=>{r.refresh().then(()=>{i(a)})})})}ensureDockPanel(e="dock"){("dock"!==e||this._dockPanel instanceof Vt)&&("grid"!==e||this._dockPanel instanceof Tt)||(this._dockPanel=("dock"===e?new Vt(this._ec):new Tt(this._ec).designMode(this.titleVisible())).on("vizActivation",e=>{this.vizActivation(e)}),this.widget(this._dockPanel))}elementContainer(){return this._ec}_hipieProps;hipieProps(e){return arguments.length?(this._hipieProps=e,this):this._hipieProps}ddl(e){const t=new Jt(this);return arguments.length?(this._ec.clear(),t.read(e),this):t.write()}layoutObj(e){return this._dockPanel.layoutObj(e),this}save(){return new Jt(this).write()}serializeDDL(){return JSON.stringify(this.save())}deserializeDDL(e){return this.restore(JSON.parse(e))}restore(e,t=!1){this.ensureDockPanel(e&&e.properties&&e.properties.layout instanceof Array?"grid":"dock"),this._ec.clear();return new Jt(this).read(e),t&&this.renderPromise().then(()=>{this._ec.refresh()}),this}importDDL(e,t,i,s={}){const a=r.isDDL2Schema(e)?e:r.upgrade(e,t,i,!0,s);return this.restore(a,!0)}javascript(){return new Yt(this).createJavaScript()}layout(){return this._dockPanel.layout()}widgets(){return this._dockPanel.widgets()}activate(e){this._dockPanel.activate(e)}hideSingleTabs(e){return arguments.length?(this._dockPanel.hideSingleTabs(e),this):this._dockPanel.hideSingleTabs()}updateButtonState(){this._designModeButton.enabled(this._dockPanel instanceof Tt).render(),this._removeButton.enabled(void 0!==this._prevActive).render()}update(e,t){this._dockPanel.syncWidgets(),super.update(e,t),this.updateButtonState()}_prevActive;vizActivation(e){this._prevActive=e,this._removeButton.enabled(void 0!==e).render()}vizStateChanged(e){}render(e){return this._dockPanel.syncPopups(),super.render(t=>{e&&e(t)})}};f(Zt,"Dashboard");let ei=Zt;ei.prototype._class+=" dashboard_dashboard";const ti=class _DDLEditor extends c.SplitPanel{summary="0 Errors";_ddlEditor=(new d.JSONEditor).on("changes",e=>{this.checkSyntax()});_errorTable=(new o.Table).columns(["dataPath","keyword","message","params"]);ddl(e){return arguments.length?(this._ddlEditor.json(e),this.checkSyntax(),this):this._ddlEditor.json()}checkSyntax(){try{const t=this.ddl();try{const{success:e,errors:i}=r.validate2(t);e?this._errorTable.data([]):this._errorTable.data(i.map(e=>[e.dataPath,e.keyword,e.message,JSON.stringify(e.params)]))}catch(e){this._errorTable.data([["","Validation Failed","",""]])}}catch(e){this._errorTable.data([["ALL","Invalid JSON","",""]])}this._renderCount&&this._errorTable.lazyRender()}enter(e,t){super.enter(e,t),this.addWidget(this._ddlEditor).addWidget(this._errorTable)}update(e,t){super.update(e,t)}};f(ti,"DDLEditor");let ii=ti;ii.prototype._class+=" codemirror_DDLEditor";const si=class _GraphAdapter{constructor(e){this._ec=e}_ec;subgraphMap={};vertexMap={};edgeMap={};hierarchy=[];vertices=[];edges=[];clear(){this.subgraphMap={},this.vertexMap={},this.edgeMap={},this.hierarchy=[],this.vertices=[],this.edges=[]}createSubgraph(e,t,i){let s=this.subgraphMap[e];return s||(s=(new l.Subgraph).columns(["DS"]).data([[i]]),this.subgraphMap[e]=s),this.vertices.push(s),s.title(`${t}`),s.getBBox(!0),s}createVertex(e,t,i,s="",r="#dcf1ff"){let a=this.vertexMap[e];return a||(a=(new l.Vertex).columns(["DS"]).data([[i]]).icon_diameter(0),this.vertexMap[e]=a),this.vertices.push(a),a.textbox_shape_colorFill(r).text(s?`${t}\n${s}`:`${t}`).tooltip(s),a.getBBox(!0),a}createEdge(e,t){const i=`${e}->${t}`;let s=this.edgeMap[i];return s||(s=(new l.Edge).sourceVertex(this.vertexMap[e]).targetVertex(this.vertexMap[t]),this.edgeMap[i]=s),this.edges.push(s),s}createDatasource(e){if(e instanceof $e&&(e=e.selection().datasource()),e instanceof ee){const t=`${e.url()}`,i=this.createSubgraph(t,`${t}`),s=`${e.url()}/${e.wuid()}`,r=this.createSubgraph(s,`${e.wuid()}`);this.hierarchy.push({parent:i,child:r});const a=`${s}/${e.resultName()}`,o=this.createVertex(a,e.resultName(),{activity:e});return this.hierarchy.push({parent:r,child:o}),a}if(e instanceof oe){const t=`${e.url()}`,i=this.createSubgraph(t,`${t}`),s=`${t}/${e.logicalFile()}`,r=this.createVertex(s,e.logicalFile(),{activity:e});return this.hierarchy.push({parent:i,child:r}),s}if(e instanceof Pe){const t=`${e.url()}`,i=this.createSubgraph(t,`${t}`),s=e.serviceID(),r=this.createSubgraph(s,e.querySet());this.hierarchy.push({parent:i,child:r});const a=s;this.hierarchy.push({parent:r,child:this.createVertex(a,e.queryID())});const o=`${s}/${e.resultName()}`;return this.hierarchy.push({parent:r,child:this.createVertex(o,e.resultName(),{activity:e})}),this.createEdge(a,o),o}if(e instanceof Fe){const t=`${e.service().url()}`,i=this.createSubgraph(t,`${t}`),s=e.serviceID(),r=this.createSubgraph(s,e.service().querySet());this.hierarchy.push({parent:i,child:r});const a=`${s}/${e.service().queryID()}`,o=this.createSubgraph(a,e.service().queryID());this.hierarchy.push({parent:r,child:o});const n=`${a}/${e.resultName()}`;return this.hierarchy.push({parent:o,child:this.createVertex(n,e.resultName(),{activity:e})}),this.createEdge(a,n),n}if(e instanceof fe){const t=`${e.url()}`,i=this.createSubgraph(t,`${t}`),s=e.serviceID(),r=this.createSubgraph(s,e.action());this.hierarchy.push({parent:i,child:r});const a=s;this.hierarchy.push({parent:r,child:this.createVertex(a,e.action())});const o=`${s}/${e.resultName()}`;return this.hierarchy.push({parent:r,child:this.createVertex(o,e.resultName(),{activity:e})}),this.createEdge(a,o),o}if(e instanceof de){const t=`${e.service().url()}`,i=this.createSubgraph(t,`${t}`),s=e.serviceID(),r=`${t}/${e.service().action()}`,a=this.createSubgraph(s,e.service().action());this.hierarchy.push({parent:i,child:a});const o=`${r}/${e.resultName()}`;return this.hierarchy.push({parent:a,child:this.createVertex(o,e.resultName(),{activity:e})}),this.createEdge(r,o),o}if(e instanceof N){const t=e.hash();return this.createVertex(t,e.label(),{activity:e}),t}if(e instanceof H){const t=e.id();return this.createVertex(t,e.label(),{activity:e}),t}{const t=e.hash();return this.createVertex(t,e.label(),{activity:e}),t}}createActivity(e,t,i,s){const r=this.createSubgraph(t.id(),`${t.id()}`,{view:t});let a=null,o="";if(i.exists()){const e=i.validate();e.length&&(a="pink",o=e.map(e=>`${e.source}: ${e.msg}`).join("\n"))}else a="lightgrey";const n=this.createVertex(i.id(),s||`${i.classID()}`,{view:t,activity:i},o,a);return e&&this.createEdge(e,i.id()),this.hierarchy.push({parent:r,child:n}),i.id()}createGraph(){this.hierarchy=[],this.vertices=[],this.edges=[],this._ec.elements().forEach(e=>{this.createDatasource(e.hipiePipeline().datasource())});const e={};for(const t of this._ec.elements()){const i=t.hipiePipeline();let s=this.createDatasource(i.datasource());for(const e of i.activities())s=this.createActivity(s,t,e);const r=t.visualization(),a=r.mappings(),o=this.createActivity(s,t,a,"Mappings"),n=`${r.id()}-sg`,l=this.createSubgraph(n,"Visualization",{visualization:r});this.hierarchy.push({parent:this.subgraphMap[t.id()],child:l}),this.hierarchy.push({parent:l,child:this.vertexMap[a.id()]});const h=`${r.id()}-viz`,u=this.createVertex(h,r.chartPanel().widget().classID(),{view:t,chartPanel:r.chartPanel()});this.createEdge(o,h),this.hierarchy.push({parent:l,child:u});const c=`${r.id()}-state`,d=this.createVertex(c,"Selection",{view:t,state:t.state()});this.createEdge(h,c).weight(10).strokeDasharray("1,5").text("updates"),this.createEdge(s,c),this.hierarchy.push({parent:this.subgraphMap[t.id()],child:d}),s=c,e[i.id()]=s}for(const t of this._ec.elements()){const e=t.visualization(),i=this._ec.element(e.secondaryDataviewID());if(i){const t=i.visualization().mappings();this.createEdge(t.id(),`${e.id()}-viz`)}}for(const t of this._ec.elements()){const i=t.hipiePipeline();for(const t of i.updatedByGraph())this.createEdge(e[this._ec.element(t.from).hipiePipeline().id()],t.to.id()).weight(10).strokeDasharray("1,5").text("updates")}return{vertices:this.vertices,edges:this.edges,hierarchy:this.hierarchy}}};f(si,"GraphAdapter");let ri=si;const ai=class _DSTable extends u.ChartPanel{constructor(e){super(),this._ec=e,this.buttons([this._addButton,this._removeButton,new i.Spacer,this._cloneButton,new i.Spacer,this._addSamples]).widget(this._dstable).columns(["ID","Type","References"]).on("click",(e,t,i)=>{this._selectedDS2=e.__lparam,i&&0===e.References&&"Empty"!==e.ID?this._selectedDS=e.__lparam:delete this._selectedDS,this._removeButton.enabled(void 0!==this._selectedDS).render(),this._cloneButton.enabled(void 0!==this._selectedDS2).render()}),this.initMenu()}_ec;_addButton=(new i.Button).faChar("fa-plus").tooltip("Add...").on("click",()=>{const e=this._addButton.element().node(),t=e.getBoundingClientRect();this._contextMenu.open({target:e,currentTarget:e,clientX:t.left,clientY:t.bottom})});_removeButton=(new i.Button).faChar("fa-minus").tooltip("Remove...").enabled(!1).on("click",()=>{this.remove()});_cloneButton=(new i.Button).faChar("fa-clone").tooltip("Clone...").enabled(!1).on("click",()=>{this._selectedDS2&&(this._selectedDS2 instanceof H?this.add(H.fromDDL(this._selectedDS2.toDDL(),!0)):this._selectedDS2 instanceof N?this.add(N.fromDDL(this._selectedDS2.toDDL(),!0)):this._selectedDS2 instanceof oe?this.add(oe.fromDDL(this._ec,this._selectedDS2.toDDL(),!0)):this._selectedDS2 instanceof de?this.add(new de(this._ec).service(ue.fromDDL(this._ec,this._selectedDS2.service().toDDL(),!0)).resultName(this._selectedDS2.resultName())):this._selectedDS2 instanceof ee?this.add(new ee(this._ec).wu(ie.fromDDL(this._ec,this._selectedDS2.wu().toDDL(),!0)).resultName(this._selectedDS2.resultName())):this._selectedDS2 instanceof Fe?this.add(new Fe(this._ec).service(be.fromDDL(this._ec,this._selectedDS2.service().toDDL(),!0)).resultName(this._selectedDS2.resultName())):console.warn("Unknown datasoure type"))});_addSamples=(new i.Button).faChar("fa-database").tooltip("Add Samples").on("click",()=>{Mt("https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/airports.csv").then(e=>{this.add((new H).format("csv").payload(e))}),Mt("https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/carriers.csv").then(e=>{this.add((new H).format("csv").payload(e))}),Mt("https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/stats.csv").then(e=>{this.add((new H).format("csv").payload(e))}),this.add(new de(this._ec).service(new ue(this._ec).url("https://cmsapi.pulselive.com/").action("rugby/rankings/mru").requestFields([(new le).fieldID("xxx"),(new le).fieldID("date")])).resultName("entries")),this.add(new ee(this._ec).wu(new ie(this._ec).url("http://localhost:8010").wuid("W20190802-112509")).resultName("Result 1")),this.add(new oe(this._ec).url("http://localhost:8010").logicalFile("progguide::exampledata::peopleaccts")),this.add(new oe(this._ec).url("http://localhost:8010").logicalFile("progguide::exampledata::people"));const e=new be(this._ec).url("http://localhost:8002").querySet("roxie").queryID("peopleaccounts");this.add(new Fe(this._ec).service(e).resultName("Accounts")),this.add((new N).formFields([(new q).type("number").fieldID("id").value(8),(new q).fieldID("first_name").value("John"),(new q).fieldID("last_name").value("Doe"),(new q).fieldID("gender").default("M"),(new q).type("number").fieldID("age")])),this.render()});_dstable=new o.Table;_selectedDS;_selectedDS2;_contextMenu;initMenu(){const e=new c.CommandRegistry;e.addCommand("add_wu_result",{label:"Workunit Result",execute:f(()=>{this.add(new ee(this._ec))},"execute")}),e.addCommand("add_logicalfile",{label:"Logical File",execute:f(()=>{this.add(new oe(this._ec))},"execute")}),e.addCommand("add_roxie",{label:"Roxie Service",execute:f(()=>{this.add(new Fe(this._ec))},"execute")}),e.addCommand("add_rest",{label:"Rest",execute:f(()=>{this.add(new de(this._ec))},"execute")}),e.addCommand("add_databomb",{label:"Databomb",execute:f(()=>{this.add(new H)},"execute")}),e.addCommand("add_form",{label:"Form",execute:f(()=>{this.add(new N)},"execute")}),this._contextMenu=new c.ContextMenu({commands:e}),this._contextMenu.addItem({command:"add_wu_result",selector:".common_Button"}),this._contextMenu.addItem({command:"add_logicalfile",selector:".common_Button"}),this._contextMenu.addItem({command:"add_roxie",selector:".common_Button"}),this._contextMenu.addItem({command:"add_rest",selector:".common_Button"}),this._contextMenu.addItem({command:"add_databomb",selector:".common_Button"}),this._contextMenu.addItem({command:"add_form",selector:".common_Button"})}add(e){this._ec.appendDatasource(e),this.render()}remove(){this._selectedDS&&(this._ec.removeDatasource(this._selectedDS),this.render())}_prevDataID;render(e){const t={};this._ec.elements().forEach(e=>{let i=e.hipiePipeline().datasource();i instanceof $e&&(i=i.datasource()),void 0===t[i.id()]&&(t[i.id()]=0),t[i.id()]++});const i=this._ec.datasources().filter(e=>"Empty"!==e.id()).map(e=>(void 0===t[e.id()]&&(t[e.id()]=0),[e.id(),e.classID(),t[e.id()]||0,e])),s=JSON.stringify(t);return this._prevDataID!==s&&(this._prevDataID=s,this.data(i)),super.render(e)}};f(ai,"DSTable");let oi=ai;const ni=class _DVTable extends u.ChartPanel{constructor(e){super(),this._ec=e,this.titleVisible(!1).widget(this._dvtable).columns(["ID","Title"])}_ec;_dvtable=new o.Table;_prevDataID;render(e){const t=this._ec.elements().map(e=>[e.id(),e.visualization().title(),e]),i=s.hashSum(t.map(e=>e[0]));return this._prevDataID!==i&&(this._prevDataID=i,this.data(t)),super.render(e)}};f(ni,"DVTable");let li=ni;const hi=class _PipelineSelectionButton extends i.SelectionButton{_label;label(e){return arguments.length?(this._label=e,this.tooltip(e),this):this._label}_elementErrors=[];errors(e){return arguments.length?(this._elementErrors=e,this.classed("error",e.length>0),e.length?this.tooltip(e.map(e=>{const t=e.source.split(".");return t.splice(0,1),`${t.join(".")}: ${e.msg}`}).join("\n")):this.tooltip(this._label),this.render(),this):this._elementErrors}};f(hi,"PipelineSelectionButton");let ui=hi;const ci=class _PipelinePanel extends u.ChartPanel{_owner;datasource=(new ui).faChar("fa-database").label("Datasource").selected(!0);filter=(new ui).faChar("fa-filter").label("Filter");project=(new ui).faChar("fa-random").label("Project");groupBy=(new ui).faChar("fa-object-group").label("Group By");sort=(new ui).faChar("fa-sort-alpha-asc").label("Sort");limit=(new ui).faChar("fa-list-ol").label("Limit");mappings=(new ui).faChar("fa-random").label("Mappings");chartPanel=(new ui).faChar("fa-area-chart").label("Visualization");state=(new ui).faChar("fa-check-square-o").label("State");debug=(new ui).faChar("fa-bug").label("Debug");all=(new ui).faChar("fa-list").label("All");_propEditor=(new p.PropertyEditor).show_header(!1).show_settings(!1).showFields(!1);_buttons=[this.datasource,this.filter,this.project,this.groupBy,this.sort,this.limit,new i.Spacer,this.mappings,this.chartPanel,new i.Spacer,this.state,this.debug,new i.Spacer,this.all];_pipelineButton=this.datasource;_pipelineSelection=(new i.SelectionBar).buttons(this._buttons).on("selected",e=>{this._pipelineButton=e,this.title(e.label()).render()});constructor(e){super(),this._owner=e,this.buttons([this._pipelineSelection]),this.title(this.datasource.label()),super.widget(this._propEditor),this._propEditor.monitor((e,t,i,s)=>{s!==this._propEditor&&(this.propChanged(e,t,i,s),this.updateState())})}selectionButtons(){return this._pipelineSelection.buttons().filter(e=>e instanceof ui)}_propExt;propExt(e){return arguments.length?(this._propExt=e,this):this._propExt}peAsDatasource(){return this._propExt instanceof B||this._propExt instanceof $e?this._propExt:this._propExt instanceof Et?this._propExt.hipiePipeline().datasource():void 0}peAsFilter(){return this._propExt instanceof qe?this._propExt:this._propExt instanceof Et?this._propExt.hipiePipeline().filters():void 0}peAsProject(){return this._propExt instanceof at?this._propExt:this._propExt instanceof Et?this._propExt.hipiePipeline().project():void 0}peAsGroupBy(){return this._propExt instanceof Je?this._propExt:this._propExt instanceof Et?this._propExt.hipiePipeline().groupBy():void 0}peAsSort(){return this._propExt instanceof ct?this._propExt:this._propExt instanceof Et?this._propExt.hipiePipeline().sort():void 0}peAsLimit(){return this._propExt instanceof Qe?this._propExt:this._propExt instanceof Et?this._propExt.hipiePipeline().limit():void 0}peAsMappings(){return this._propExt instanceof nt?this._propExt:this._propExt instanceof Et?this._propExt.visualization().mappings():this._propExt instanceof Lt?this._propExt.mappings():void 0}peAsChartPanel(){return this._propExt instanceof u.ChartPanel||this._propExt instanceof Lt?this._propExt:this._propExt instanceof Et?this._propExt.visualization():void 0}peAsState(){return this._propExt instanceof It?this._propExt:this._propExt instanceof Et?this._propExt.state():void 0}selectionButton(){if(this._pipelineButton&&this._pipelineButton.enabled())return this._pipelineButton;for(const e of this.selectionButtons())if(e.enabled())return e.selected(!0),e}_prevPropExt;_prevPipelineButton;update(e,t){super.update(e,t),this.updateState();const i=this.selectionButton();if(this._prevPropExt!==this._propExt||this._prevPipelineButton!==i){if(this._prevPropExt=this._propExt,this._prevPipelineButton=i,this._propExt&&i)switch(i){case this.datasource:this._propEditor.widget(this.peAsDatasource());break;case this.filter:this._propEditor.widget(this.peAsFilter());break;case this.project:this._propEditor.widget(this.peAsProject());break;case this.groupBy:this._propEditor.widget(this.peAsGroupBy());break;case this.sort:this._propEditor.widget(this.peAsSort());break;case this.limit:this._propEditor.widget(this.peAsLimit());break;case this.mappings:this._propEditor.widget(this.peAsMappings());break;case this.chartPanel:this._propEditor.widget(this.peAsChartPanel());break;case this.state:this._propEditor.widget(this.peAsState());break;case this.all:this._propEditor.widget(this._propExt)}else this._propEditor.widget(void 0);this._owner.loadPreview(this._propEditor.widget())}}updateButtonState(e,t){t.enabled(!!e),t.errors(!!e&&e.validate()||[])}updateState(){this.selectionButtons().forEach(e=>{if(e instanceof ui&&this.disableActivities().indexOf(e.label())>=0)this.updateButtonState(void 0,e);else{switch(e){case this.datasource:this.updateButtonState(this.peAsDatasource(),e);break;case this.filter:this.updateButtonState(this.peAsFilter(),e);break;case this.project:this.updateButtonState(this.peAsProject(),e);break;case this.groupBy:this.updateButtonState(this.peAsGroupBy(),e);break;case this.sort:this.updateButtonState(this.peAsSort(),e);break;case this.limit:this.updateButtonState(this.peAsLimit(),e);break;case this.mappings:this.updateButtonState(this.peAsMappings(),e);break;case this.chartPanel:const t=this.peAsChartPanel();e.enabled(!!t);break;case this.state:const i=this.peAsState();e.enabled(!!i);break;case this.debug:e.enabled(!1);break;case this.all:e.enabled(!!this._propExt)}e.selected()&&this.title(e.enabled()?e.label():"")}})}propChanged(e,t,i,s){}};f(ci,"PipelinePanel");let di=ci;di.prototype._class+=" marshaller_PipelinePanel";let pi=(m=class extends u.ChartPanel{_save=(new i.Button).faChar("fa-save").tooltip("Save").on("click",()=>{const e=this.activity();e&&e.fromDDL&&e.fromDDL(this._jsonEditor.json()),this.updateToolbar()});_reset=(new i.Button).faChar("fa-undo").tooltip("Reset").on("click",()=>{this._jsonEditor.text(this.jsonText()).lazyRender(),this.updateToolbar()});_jsonEditor=(new d.JSONEditor).on("changes",e=>{this.updateToolbar()});constructor(){super(),this._titleBar.buttons([this._save,this._reset]),this.widget(this._jsonEditor)}_activity;activity(e){return void 0===e?this._activity:(this._activity!==e&&(this._activity=e,delete this._prevJson),this)}jsonText(){const e=this.activity();return e&&e.toDDL?JSON.stringify(e.toDDL(),void 0,4):""}_prevJson;update(e,t){super.update(e,t);const i=this.jsonText(),s=this._jsonEditor.text();void 0!==this._prevJson&&this._prevJson!==s||this._prevJson===i||(this._prevJson=i,this._jsonEditor.text(i)),this.updateToolbar()}updateToolbar(){const e=this.activity(),t=this.jsonText(),i=this._jsonEditor.text();this._save.enabled(e&&e.fromDDL&&t!==i).lazyRender(),this._reset.enabled(t!==i).lazyRender()}},f(m,"DDLPreview"),m);const mi=class _PipelineSplitPanel extends c.SplitPanel{_rhsPropsPanel=new di(this).on("propChanged",(e,t,i,s)=>{this.propChanged(e,t,i,s)});_previewPanel=new c.TabPanel;_rhsDDLPreview=new pi;_rhsDataPreview=(new o.DatasourceTable).pagination(!0);constructor(){super(),this._previewPanel.addWidget(this._rhsDataPreview,"Data").addWidget(this._rhsDDLPreview,"DDL"),this.addWidget(this._rhsPropsPanel).addWidget(this._previewPanel)}loadDataProps(e){this._rhsPropsPanel.propExt(e).render()}loadPreview(e){e=e instanceof Lt?e.mappings():e,this._rhsDataPreview.datasource(new K(e instanceof S?e:void 0)).lazyRender(),this._rhsDDLPreview.activity(e).lazyRender()}refreshPreview(){const e=this._rhsDataPreview.datasource();e?e.exec().then(()=>{this._rhsDataPreview.invalidate().lazyRender(),this._rhsDDLPreview.lazyRender()}):this._rhsDDLPreview.lazyRender()}propChanged(e,t,i,s){}};f(mi,"PipelineSplitPanel");let _i=mi;di.prototype.publish("disableActivities",[],"array","Disabled pipeline items"),_i.prototype.publishProxy("disableActivities","_rhsPropsPanel");const fi=s.scopedLogger("marshaller/dashy"),Di=class _DDLPreview extends u.ChartPanel{constructor(e){super(),this._dashy=e,this._titleBar.buttons([this._save,this._reset]),this.widget(this._jsonEditor)}_dashy;_save=(new i.Button).faChar("fa-save").tooltip("Save").on("click",()=>{const e=JSON.parse(this._jsonEditor.text());this._dashy.importDDL(e),this.updateToolbar()});_reset=(new i.Button).faChar("fa-undo").tooltip("Reset").on("click",()=>{this._jsonEditor.text(this._ddl).lazyRender(),this.updateToolbar()});_jsonEditor=(new d.JSONEditor).on("changes",e=>{this.updateToolbar()});_ddl;ddl(e){return this._ddl=JSON.stringify(e,void 0,4),this}_prevJson;update(e,t){super.update(e,t),this._prevJson!==this._ddl&&(this._prevJson=this._ddl,this._jsonEditor.text(this._ddl)),this.updateToolbar()}updateToolbar(){const e=this._jsonEditor.text();this._save.enabled(this._ddl!==e).lazyRender(),this._reset.enabled(this._ddl!==e).lazyRender()}};f(Di,"DDLPreview");let vi=Di;const gi=class _Dashy extends c.SplitPanel{_elementContainer=new zt;_lhsSheet=new c.TabPanel;_lhsDashboard=new ei(this._elementContainer).on("vizActivation",(e,t)=>{this.focus(this._lhsDashboard,e)}).on("vizStateChanged",e=>{for(const t of this._elementContainer.filteredBy(e.id()))this.focus()===t&&this._rhsSplitView.refreshPreview()});_lhsDataviews=new li(this._elementContainer).on("click",(e,t,i,s)=>{this.focus(this._lhsDataviews,e.__lparam),this._rhsSplitView.refreshPreview()});_lhsDatasources=new oi(this._elementContainer).on("click",(e,t,i,s)=>{this.focus(this._lhsDatasources,e.__lparam),this._rhsSplitView.refreshPreview()});_graphAdapter=new ri(this._elementContainer);_lhsPipeline=(new l.Graph).layout("Hierarchy").allowDragging(!1).applyScaleOnLayout(!0).on("vertex_click",(e,t,i,s)=>{const r=e.__lparam[0]||{};this.focus(this._lhsPipeline,r.state||r.chartPanel||r.visualization||r.activity||r.view)}).on("vertex_contextmenu",(e,t,i,s)=>{});_lhsDebugSheet=new c.TabPanel;_lhsDebugDDLEditor=new vi(this);_lhsDebugDDLSchema=(new d.JSONEditor).json(r.ddl2Schema);_lhsDebugJSEditor=new d.JSEditor;_lhsDebugCloneEC=new zt;_lhsDebugClone=new ei(this._lhsDebugCloneEC).hideSingleTabs(!0).titleVisible(!1);_lhsDebugDDLv1=new d.JSONEditor;_lhsDebugDDLv2=new d.JSONEditor;_rhsSplitView=new _i;_fileOpen;static create(e,t,i,s){return new Promise((r,a)=>{const o=(new _Dashy).target(e).render(e=>{t?e.importDDL(t,i,s).then(()=>{r(o)}):r(o)})})}constructor(){super("horizontal")}elementContainer(){return this._elementContainer}clear(){return this._lhsDebugSheet.removeWidget(this._lhsDebugDDLv1),this._lhsDebugSheet.removeWidget(this._lhsDebugDDLv2),this._elementContainer.clear(),this._graphAdapter.clear(),this.focus(this._lhsDashboard,void 0),this.loadDashboard().then(()=>this._elementContainer.refresh()).then(e=>{})}save(){return this._lhsDashboard.save()}serializeDDL(){return JSON.stringify(this.save())}deserializeDDL(e){return this.restore(JSON.parse(e))}restore(e){return this._lhsSheet.active(this._lhsDashboard),this.clear().then(()=>(this._lhsDashboard.restore(e),this._lhsDataviews.render(),this._lhsDatasources.render(),this._lhsDashboard.renderPromise().then(()=>{const e=this._elementContainer.elements();return e.length&&this._lhsDashboard.activate(e[0]),this._elementContainer.refresh()}).then(()=>{let e=!1;for(const t of this._elementContainer.validate())e=!0,fi.warning(t.elementID+" ("+t.source+"): "+t.msg);e&&this._lhsDashboard.renderPromise()})))}importDDL(e,t,i,s={}){const a=r.isDDL2Schema(e)?e:r.upgrade(e,t,i,!0,s),o=this.restore(a);return r.isDDL2Schema(e)?(this._lhsDebugDDLv2.json(a),this._lhsDebugSheet.addWidget(this._lhsDebugDDLv2,"orig v2")):(this._lhsDebugDDLv1.json(e),this._lhsDebugDDLv2.json(a),this._lhsDebugSheet.addWidget(this._lhsDebugDDLv1,"v1").addWidget(this._lhsDebugDDLv2,"v1 -> v2")),o}activeLHS(){let e=this._lhsSheet.active();return e===this._lhsDebugSheet&&(e=this._lhsDebugSheet.active()),e}activeRHS(){return this._rhsSplitView}_currSelection={};focusAsElement(){const e=this.focus();return e instanceof Et?e:void 0}focus(e,t){return arguments.length?(this._currSelection[e.id()]!==t&&(this._currSelection[e.id()]=t,this.loadRHSSplit()),this):this._currSelection[this.activeLHS().id()]}loadRHSSplit(){this._rhsSplitView.loadDataProps(this.focus())}loadDataviews(){return this.activeLHS()===this._lhsDataviews?this._lhsDataviews.renderPromise():Promise.resolve(void 0)}loadDatasources(){return this.activeLHS()===this._lhsDatasources?this._lhsDatasources.renderPromise():Promise.resolve(void 0)}loadDashboard(){return this.activeLHS()===this._lhsDashboard?(this._elementContainer.validate(),this._lhsDashboard.renderPromise()):Promise.resolve(void 0)}loadGraph(){this._lhsPipeline.data({...this._graphAdapter.createGraph()},!0),this.activeLHS()===this._lhsPipeline&&this._lhsPipeline.lazyRender()}loadDDL(){this._lhsDebugDDLEditor.ddl(this._lhsDashboard.ddl()),this.activeLHS()===this._lhsDebugDDLEditor&&this._lhsDebugDDLEditor.lazyRender()}loadJavaScript(){this._lhsDebugJSEditor.javascript(this._lhsDashboard.javascript()),this.activeLHS()===this._lhsDebugJSEditor&&this._lhsDebugJSEditor.lazyRender()}loadClone(){const e=this.save();this._lhsDebugCloneEC.clear(),this._lhsDebugClone.renderPromise().then(()=>{this._lhsDebugClone.restore(e),this._lhsDebugClone.renderPromise().then(()=>this._lhsDebugCloneEC.refresh()).then(()=>{for(const e of this._lhsDebugCloneEC.validate())fi.warning(e.elementID+" ("+e.source+"): "+e.msg)})})}initMenu(){const e=new c.CommandRegistry;e.addCommand("dash_add",{label:"Add View",execute:f(()=>{const e=new Et(this._elementContainer);this._elementContainer.append(e),this.loadDashboard().then(()=>{e.refresh().then(()=>{this._lhsDashboard.activate(e)})})},"execute")}),e.addCommand("dash_clear",{label:"Clear",execute:f(()=>{this.clear()},"execute")}),e.addCommand("dash_save",{label:"Save",execute:f(()=>{const e=JSON.stringify(this.save(),null," ");i.Utility.downloadString("JSON",e,"dashy")},"execute")}),e.addCommand("dash_load",{label:"Open",execute:f(()=>{this._fileOpen.property("accept",".dashy,.json"),this._fileOpen.node().click()},"execute")});const t=new c.CommandPalette({commands:e});t.addItem({command:"addWUResult",category:"Notebook"}),t.addItem({command:"addView",category:"Notebook"}),t.addItem({command:"remove",category:"Notebook"}),t.id="palette";const s=new c.ContextMenu({commands:e});s.addItem({command:"dash_add",selector:`#${this._lhsDashboard.id()}`}),s.addItem({command:"dash_clear",selector:`#${this._lhsDashboard.id()}`}),s.addItem({type:"separator",selector:`#${this._lhsDashboard.id()}`}),s.addItem({command:"dash_load",selector:`#${this.id()}`}),s.addItem({command:"dash_save",selector:`#${this.id()}`}),document.addEventListener("contextmenu",e=>{s.open(e)&&e.preventDefault()})}addDatabomb(e,t,i){const s=(new H).id(e).format(i).payload(t);this._elementContainer.appendDatasource(s);const r=new Et(this._elementContainer),a=r.hipiePipeline().datasource();a instanceof $e&&a.datasourceID(s.id()),this._elementContainer.append(r),this.loadDashboard().then(()=>{r.refresh().then(()=>{this._lhsDashboard.activate(r)})})}enter(e,t){super.enter(e,t),this.addWidget(this._lhsSheet).addWidget(this._rhsSplitView),this._lhsSheet.addWidget(this._lhsDashboard,"Dashboard").addWidget(this._lhsDataviews,"Dataviews").addWidget(this._lhsDatasources,"Datasources").addWidget(this._lhsPipeline,"Pipeline").addWidget(this._lhsDebugSheet,"Debug").on("childActivation",e=>{switch(e){case this._lhsDataviews:case this._lhsDatasources:case this._lhsDashboard:this.loadRHSSplit();break;case this._lhsPipeline:this.loadRHSSplit(),this.loadGraph();break;case this._lhsDebugSheet:this._lhsDebugSheet.childActivation(this._lhsDebugSheet.active())}}),this._lhsDebugSheet.addWidget(this._lhsDebugDDLEditor,"v2").addWidget(this._lhsDebugDDLSchema,"Schema").addWidget(this._lhsDebugJSEditor,"TS").addWidget(this._lhsDebugClone,"Clone").on("childActivation",e=>{switch(e){case this._lhsDebugDDLEditor:this.loadRHSSplit(),this.loadDDL();break;case this._lhsDebugJSEditor:this.loadRHSSplit(),this.loadJavaScript();break;case this._lhsDebugClone:this.loadClone()}}),this.initMenu(),this._rhsSplitView.on("propChanged",(e,t,i,s)=>{const r=this.focusAsElement();switch(r?r.refresh().then(()=>{this._rhsSplitView.refreshPreview()}):this._rhsSplitView.refreshPreview(),this.activeLHS()){case this._lhsDashboard:this.loadDashboard();break;case this._lhsDatasources:this._elementContainer.refresh();break;case this._lhsPipeline:this.loadGraph();break;case this._lhsDebugDDLEditor:this.loadDDL();break;case this._lhsDebugClone:this.loadClone()}});const i=this;this._fileOpen=t.append("input").attr("type","file").property("accept",".dashy,.json").style("display","none").on("change",function(){const e=this.files[0];for(;e;){const t=new FileReader;t.onload=function(){return function(e){try{const t=Array.isArray(e.target.result)?e.target.result[0]:e.target.result,s=JSON.parse(t);i.importDDL(s)}catch(t){alert("ex when trying to parse json = "+t)}}}(),t.readAsText(e);break}})}update(e,t){super.update(e,t)}};f(gi,"Dashy");let yi=gi;yi.prototype._class+=" composite_Dashy",yi.prototype.publishProxy("disableActivities","_rhsSplitView"),Object.defineProperty(e,"hookSend",{enumerable:!0,get:f(()=>t.hookSend,"get")}),e.Activity=S,e.ActivityArray=C,e.ActivityPipeline=$,e.ActivitySelection=E,e.AggregateField=He,e.BUILD_VERSION=y,e.ColumnMapping=Ae,e.ComputedField=Ze,e.ComputedMapping=Xe,e.DDLAdapter=Jt,e.DDLEditor=ii,e.DSPicker=$e,e.Dashboard=ei,e.Dashy=yi,e.Databomb=H,e.Datasource=B,e.DatasourceAdapt=K,e.DatasourceRef=j,e.ESPResult=Y,e.Element=Et,e.ElementContainer=zt,e.Filters=qe,e.Form=N,e.FormField=q,e.GraphAdapter=ri,e.GroupBy=Je,e.GroupByColumn=Ne,e.HipiePipeline=pt,e.HipieResultRef=Le,e.JavaScriptAdapter=Yt,e.Limit=Qe,e.LogicalFile=oe,e.Mappings=nt,e.MultiField=tt,e.NullView=ft,e.PKG_NAME=v,e.PKG_VERSION=g,e.Project=at,e.ProjectBase=st,e.RemoteFilter=Be,e.RoxieResult=Fe,e.RoxieResultRef=Pe,e.RoxieService=be,e.Sort=ct,e.SortColumn=ht,e.State=It,e.StaticFilter=je,e.Visualization=Lt,e.VizChartPanel=yt,e.VizPopupPanel=vt,e.VizTypeSet=wt,e.WU=ie,e.WUResult=ee,e.WUResultRef=re,e.createProps=Kt,e.emptyDatabomb=U,e.rowToFields=O,e.schemaRow2IField=F,e.schemaType2IFieldType=w,e.stringify=b,e.wsEclSchemaRow2IField=x,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@hpcc-js/comms"),require("@hpcc-js/common"),require("@hpcc-js/util"),require("@hpcc-js/ddl-shim"),require("@hpcc-js/chart"),require("@hpcc-js/dgrid"),require("@hpcc-js/form"),require("@hpcc-js/graph"),require("@hpcc-js/map"),require("@hpcc-js/layout"),require("@hpcc-js/phosphor"),require("@hpcc-js/codemirror"),require("@hpcc-js/other")):typeof define==`function`&&define.amd?define([`exports`,`@hpcc-js/comms`,`@hpcc-js/common`,`@hpcc-js/util`,`@hpcc-js/ddl-shim`,`@hpcc-js/chart`,`@hpcc-js/dgrid`,`@hpcc-js/form`,`@hpcc-js/graph`,`@hpcc-js/map`,`@hpcc-js/layout`,`@hpcc-js/phosphor`,`@hpcc-js/codemirror`,`@hpcc-js/other`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`@hpcc-js/marshaller`]={},e[`@hpcc-js/comms`],e[`@hpcc-js/common`],e[`@hpcc-js/util`],e[`@hpcc-js/ddl-shim`],e[`@hpcc-js/chart`],e[`@hpcc-js/dgrid`],e[`@hpcc-js/form`],e[`@hpcc-js/graph`],e[`@hpcc-js/map`],e[`@hpcc-js/layout`],e[`@hpcc-js/phosphor`],e[`@hpcc-js/codemirror`],e[`@hpcc-js/other`]))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,ee){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var te=Object.defineProperty,__name=(e,t)=>te(e,`name`,{value:t,configurable:!0}),p=`@hpcc-js/marshaller`,m=`3.2.3`,h=`3.25.1`;function stringify(e){return Array.isArray(e)?`[`+e.map(stringify).join(`, `)+`]`:typeof e!=`object`||!e||e===void 0?JSON.stringify(e):`{ ${Object.keys(e).map(t=>`${t}: ${stringify(e[t])}`).join(`, `)} }`}function schemaType2IFieldType(e){switch(e){case`boolean`:return`boolean`;case`xs:byte`:case`xs:double`:case`xs:decimal`:case`xs:float`:case`xs:int`:case`xs:short`:case`xs:unsignedInt`:case`xs:unsignedShort`:case`xs:unsignedByte`:case`number`:return`number`;case`xs:integer`:case`xs:long`:case`xs:negativeInteger`:case`xs:nonNegativeInteger`:case`xs:nonPositiveInteger`:case`xs:positiveInteger`:case`xs:unsignedLong`:return`number64`;case`string`:return`string`;case`range`:return`range`}return`string`}function schemaRow2IField(e){return e._children&&e._children.length?{type:`dataset`,id:e.name,children:e._children.map(schemaRow2IField)}:{id:e.name,type:schemaType2IFieldType(e.type)}}function wsEclSchemaRow2IField(e){return e}var Activity=class extends n.PropertyExt{_sourceActivity;fixInt64(e){if(!e||e.length===0)return[];let t=this.outFields().filter(t=>{switch(t.type){case`number`:return typeof e[0][t.id]!=`number`;case`number64`:return!0}return!1});return t.length?e.map(e=>{for(let n of t)e[n.id]=+e[n.id];return e}):e}sourceActivity(e){return arguments.length?(this._sourceActivity=e,this):this._sourceActivity}hash(e={}){return(0,r.hashSum)({...e})}refreshMeta(){return this._sourceActivity?this._sourceActivity.refreshMeta():Promise.resolve()}exists(){return!0}validate(){return[]}label(){return this.id()}updatedBy(){return[]}_emptyFields=[];inFields(){return this._sourceActivity?this._sourceActivity.outFields():this._emptyFields}computeFields(e){return()=>e}outFields(){return this.computeFields(this.inFields())()}localFields(){let e=this.inFields().map(e=>e.id);return this.outFields().filter(t=>e.indexOf(t.id)<0)}fieldOrigin(e){return this.localFields().filter(t=>t.id===e).length?this:this.sourceActivity()?this.sourceActivity().fieldOrigin(e):null}resolveFields(e,t){for(let n of t){let t=this.fieldOrigin(n);t&&(e.outputs[t.id()]||(e.outputs[t.id()]=[]),e.outputs[t.id()].indexOf(n)<0&&e.outputs[t.id()].push(n))}}resolveInFields(e,t){return this._sourceActivity&&this._sourceActivity.resolveFields(e,t)}referencedFields(e){this._sourceActivity?.referencedFields(e)}exec(){return this._sourceActivity?this._sourceActivity.exec():Promise.resolve()}_emptyData=[];inData(){return this._sourceActivity&&this._sourceActivity.outData()||this._emptyData}computeData(){return this.inData()}_prevDataHash=``;_prevInData=[];_prevData=[];cachedComputeData(e){let t=this.hash();return(this._prevDataHash!==t||this._prevInData!==e)&&(this._prevDataHash=t,this._prevInData=e,this._prevData=(0,r.update)(this._prevData,this.computeData())),this._prevData}outData(){return this.cachedComputeData(this.inData())}},ActivityArray=class extends Activity{_activities=[];activities(e){return arguments.length?(this._activities=e,this):this._activities}};ActivityArray.prototype._class+=` ActivityArray`;var ActivityPipeline=class extends ActivityArray{activities(e){if(!arguments.length)return super.activities();super.activities(e);let t;for(let n of e)t&&n.sourceActivity(t),t=n;return this}first(){return this.activities()[0]}last(){let e=this.activities();return e[e.length-1]}calcUpdatedGraph(e){return e.updatedBy().map(t=>({from:t,to:e}))}updatedByGraph(){let e=[];for(let t of this.activities())e=e.concat(this.calcUpdatedGraph(t));return e}fetch(e=0,t=Number.MAX_VALUE){return this.exec().then(()=>{let n=this.outData();return e===0&&n.length<=t?n:n.slice(e,e+t)})}hash(e={}){return(0,r.hashSum)({activities:[this.activities().map(e=>e.hash())],...e})}refreshMeta(){return this.last().refreshMeta()}updatedBy(){let e=[];for(let t of this.activities())e=e.concat(t.updatedBy());return e}inFields(){return this.first().inFields()}outFields(){return this.last().outFields()}localFields(){return this.last().localFields()}fieldOrigin(e){return this.last().fieldOrigin(e)}referencedFields(e){this.last().referencedFields(e)}resolveInFields(e,t){this.last().resolveInFields(e,t)}resolveFields(e,t){this.last().resolveFields(e,t)}exec(){return this.last().exec()}outData(){return this.last().outData()}};ActivityPipeline.prototype._class+=` ActivitySequence`;var ActivitySelection=class extends ActivityArray{_selection;_monitorHandle;selection(e){return e===void 0?this._selection:(this._monitorHandle&&this._monitorHandle.remove(),this._selection=e,this._monitorHandle=e.monitor((t,n,r)=>{this.broadcast(t,n,r,e)}),this)}hash(e={}){return(0,r.hashSum)({selection:this.selection().hash(),...e})}label(){return this.selection().label()}refreshMeta(){return this.selection().refreshMeta()}updatedBy(){return this.selection().updatedBy()}inFields(){return this.selection().inFields()}outFields(){return this.selection().outFields()}localFields(){return this.selection().localFields()}fieldOrigin(e){return this.selection().fieldOrigin(e)}referencedFields(e){this.selection().referencedFields(e)}resolveInFields(e,t){this.selection().resolveInFields(e,t)}resolveFields(e,t){this.selection().resolveFields(e,t)}exec(){return this.selection().exec()}outData(){return this.selection().outData()}};ActivitySelection.prototype._class+=` ActivitySelection`;var g=0,Datasource=class extends Activity{constructor(){super(),this._id=`ds_${++g}`}},DatasourceRef=class extends Activity{_origDatasource;constructor(){super()}hash(e={}){return super.hash({datasource:this._datasource?this._datasource.hash(e):void 0,...e})}toDDL(){return{id:this.datasource().id()}}};DatasourceRef.prototype._class+=` DatasourceRef`,DatasourceRef.prototype.publish(`datasource`,null,`widget`,`Datasource Reference`,null,{internal:!0}),DatasourceRef.prototype._origDatasource=DatasourceRef.prototype.datasource,DatasourceRef.prototype.datasource=function(e){let t=DatasourceRef.prototype._origDatasource.apply(this,arguments);return e!==void 0&&this.sourceActivity(e),t};var _=class FormField extends n.PropertyExt{_owner;disableChildField(){return this.type()!==`dataset`}constructor(){super()}toDDL(){return{type:this.type(),id:this.fieldID(),default:this.default(),children:this.type()===`dataset`?this.childFields().map(e=>e.toDDL()):void 0}}fromDDL(e){return this.type(e.type).fieldID(e.id).default(e.default).childFields(e.type===`dataset`&&e.children?e.children.map(FormField.fromDDL):[])}static fromDDL(e){return new FormField().fromDDL(e)}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.type()&&!!this.fieldID()}coerceFunc(){switch(this.type()){case`boolean`:return e=>!!e;case`number`:return e=>+e;case`string`:return e=>``+e}return e=>e}calcValue(){return this.value_exists()?this.value():this.default()}},v=class Form extends Datasource{constructor(){super()}toDDL(){return{type:`form`,id:this.id(),fields:this.validFields().map(e=>e.toDDL())}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).formFields(e.fields.map(_.fromDDL)),this}static fromDDL(e,t=!1){return new Form().fromDDL(e,t)}validFields(){return this.formFields().filter(e=>e.valid())}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}refreshMeta(){return Promise.resolve()}label(){return`Form`}computeFields(e){let t=this.validFields().map(e=>e.toDDL());return()=>t}exec(){return Promise.resolve()}computeData(){let e={};return this.validFields().forEach(t=>{e[t.fieldID()]=t.calcValue()}),[e]}total(){return 1}};v.prototype._class+=` Form`,_.prototype.publish(`type`,`string`,`set`,`FormField Type`,[`boolean`,`number`,`string`,`dataset`]),_.prototype.publish(`fieldID`,``,`string`,`FormField Label`),_.prototype.publish(`default`,null,`any`,`Default Value`,null,{optional:!0}),_.prototype.publish(`value`,null,`any`,`Default Value`,null,{optional:!0}),_.prototype.publish(`childFields`,[],`propertyArray`,`Child Fields`,null,{autoExpand:_,disable:e=>e.disableChildField()}),v.prototype.publish(`formFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:_});function fieldType(e){if((0,r.isArray)(e))return`dataset`;let t=typeof e;switch(t){case`boolean`:case`number`:case`string`:case`object`:return t}return`string`}function rowToFields(e,t){let n=[];for(let r in e){let i={type:fieldType(e[r]),id:r};switch(i.type){case`object`:for(let e of t){let t=!1;for(let n in e[r]){let n=rowToFields(e[r],[e[r]]);i.fields={},n.length&&(n.forEach(e=>i.fields[e.id]=e),t=!0);break}if(t)break}break;case`dataset`:for(let e of t)if(e[r]&&e[r].length){i.children=rowToFields(e[r][0],e[r]);break}break}n.push(i)}return n}var y=class Databomb extends Datasource{_jsonData=[];constructor(){super()}toDDL(e=!1){return{type:`databomb`,id:this.id(),format:this.format(),payload:e?void 0:this.payload(),fields:this.validFields().map(e=>e.toDDL())}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).format(e.format).payload(e.payload).databombFields(e.fields.map(_.fromDDL)),this}static fromDDL(e,t=!1){return new Databomb().fromDDL(e,t)}validFields(){return this.databombFields().filter(e=>e.valid())}updateJsonData(){try{switch(this.format()){case`csv`:this._jsonData=(0,n.csvParse)(this.payload());break;case`tsv`:this._jsonData=(0,n.tsvParse)(this.payload());break;default:this._jsonData=JSON.parse(this.payload());break}this.databombFields(this.preCalcFields().map(_.fromDDL))}catch{this.databombFields([]),this._jsonData=[]}}hash(e){return super.hash({ddl:this.toDDL(!0),...e})+this.payload()}refreshMeta(){return Promise.resolve()}label(){return`Databomb`}preCalcFields(){return this._jsonData.length===0?[]:rowToFields(this._jsonData[0],this._jsonData)}computeFields(e){return()=>this.validFields().map(e=>e.toDDL())}exec(){return Promise.resolve()}computeData(){let e={};return this.validFields().forEach(t=>{e[t.fieldID()]=t.coerceFunc()}),this._jsonData.map(t=>{let n={};for(let r in e)n[r]=e[r](t[r]);return n})}total(){return this._jsonData.length}};y.prototype._class+=` Databomb`,y.prototype.publish(`format`,`json`,`set`,`Databomb Format`,[`json`,`csv`,`tsv`]),y.prototype.publish(`payload`,``,`string`,`Databomb array`,null,{multiline:!0}),y.prototype.publish(`databombFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:_});var ne=y.prototype.format;y.prototype.format=function(e){let t=ne.apply(this,arguments);return arguments.length&&this.updateJsonData(),t};var re=y.prototype.payload;y.prototype.payload=function(e){let t=re.apply(this,arguments);return arguments.length&&this.updateJsonData(),t};var b=new y().id(`Empty`).payload(`[]`),DatasourceAdapt=class{_activity;constructor(e){this._activity=e||b}exec(){return this._activity.refreshMeta().then(()=>this._activity.exec())}id(){return this._activity.id()}hash(e={}){return this._activity.hash(e)}label(){return this._activity.label()}outFields(){return this._activity&&this._activity.outFields?this._activity.outFields():[]}total(){return this._activity?this._activity.outData().length:0}fetch(e,t){return this.exec().then(()=>{let n=this._activity.outData();return e===0&&n.length<=t?Promise.resolve(n):Promise.resolve(n.slice(e,e+t))})}},ESPResult=class extends Datasource{_ec;_result;_schema=[];_meta=[];_total;_data=[];constructor(e){super(),this._ec=e,this.samples(this._ec.samples()).sampleSize(this._ec.sampleSize())}hash(e={}){return(0,r.hashSum)({samples:this.samples(),sampleSize:this.sampleSize(),...e})}_prevMetaHash;refreshMetaPromise;refreshMeta(){return this._prevMetaHash!==this.hash()&&(this._prevMetaHash=this.hash(),delete this.refreshMetaPromise),this.refreshMetaPromise||=super.refreshMeta().then(()=>{if(this._result=this._createResult(),this._result)return this._result.refresh();throw Error(`No valid result`)}).then(e=>{this._total=e.Total,this._schema=e.fields(),this._meta=this._meta&&this._meta.length?this._meta:this._schema.map(schemaRow2IField)}).catch(e=>{this._total=0,this._schema=[],this._meta=[]}),this.refreshMetaPromise}responseFields(e){return arguments.length?(this._meta=e,this.refreshMeta(),this):this._meta}computeFields(e){return()=>this.responseFields()}exec(){return this._exec()}_prevExecHash;_exec=(0,r.debounce)(()=>this._prevExecHash===this.hash()?Promise.resolve():(this._prevExecHash=this.hash(),super.exec().then(()=>this.sample()).then(e=>{this._data=this.fixInt64(e)}).catch(e=>{this._data=[]})));inData(){return this._data}computeData(){return this._data}total(){return this._total}async fetch(e,t){return t>this.samples()*this.sampleSize()?this.sample():this._fetch(e,t)}_fetchQ=new r.AsyncOrderedQueue;_fetch(e,t){return this._fetchQ.push(this._result?this._result.fetchRows(e,t).catch(e=>[]):Promise.resolve([]))}sample=(0,r.debounce)((e=this.samples(),t=this.sampleSize())=>{let n=[];if(e*t>=this.total())n.push(this._fetch(0,this.total()));else{let r=this.total()-t;for(let i=0;i<e;++i)n.push(this._fetch(Math.floor(i*r/e),t))}return Promise.all(n).then(e=>{let t=[];for(let n of e)t=t.concat(n);return t})})};ESPResult.prototype._class+=` ESPResult`;var x=class WUResult extends ESPResult{_origWu;_origResultName;constructor(e){super(e),this._wu=new S(this._ec)}url(){return this._wu.url()}wuid(){return this._wu.wuid()}toDDL(){return{type:`wuresult`,id:this.id(),url:this._wu.url(),wuid:this.wuid(),outputs:{[this.resultName()]:{fields:this.responseFields()}}}}fromDDL(e,t=!1){return e.outputs[this.resultName()]?this.responseFields(e.outputs[this.resultName()].fields):this}static fromDDL(e,t,n,r,i=!1){return new WUResult(e).wu(n).resultName(r).fromDDL(t)}_createResult(){if(this._wu.url()&&this.wuid()&&this.resultName())return t.Result.attach({baseUrl:this._wu.url(),hookSend:this._ec.hookSend()},this.wuid(),this.resultName())}sourceHash(){return super.hash({wuid:this.wuid()})}hash(e){return super.hash({ddl:this.toDDL()})}label(){return`${this.wuid()}\n${this.resultName()}`}};x.prototype._class+=` WUResult`;var S=class WU extends Datasource{_ec;_origUrl;_origWuid;_workunit;_outputs={};constructor(e){super(),this._ec=e}toDDL(){let e={};for(let t in this._outputs)e[t]={fields:this._outputs[t].responseFields()};return{type:`wuresult`,id:this.id(),url:this.url(),wuid:this.wuid(),outputs:e}}fromDDL(e,t=!1){(t?this:this.id(e.id)).url(e.url).wuid(e.wuid);let n={};for(let t in e.outputs)n[t]=x.fromDDL(this._ec,e,this,t);return this._outputs=n,this}static fromDDL(e,t,n=!1){return new WU(e).fromDDL(t,n)}hash(){return(0,r.hashSum)({url:this.url(),wuid:this.wuid()})}label(){return this.wuid()}outputs(){let e=[];for(let t in this._outputs)e.push(this._outputs[t]);return e}outputDDL(){let e={};for(let t in this._outputs)e[t]={fields:this._outputs[t].outFields()};return e}output(e){return this._outputs[e]}_prevSourceHash;refreshMetaPromise;_resultNames=[];refreshMeta(){return!this.url()||!this.wuid()?Promise.resolve():(this._prevSourceHash!==this.hash()&&(this._prevSourceHash=this.hash(),delete this.refreshMetaPromise),this.refreshMetaPromise||=super.refreshMeta().then(()=>(this._workunit=t.Workunit.attach({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.wuid()),this._workunit.fetchResults())).then(e=>{this._resultNames=e.map(e=>e.Name)}).catch(e=>{}),this.refreshMetaPromise)}resultNames(){return this._resultNames}};S.prototype._class+=` WU`;var WUResultRef=class extends DatasourceRef{datasource(e){return super.datasource.apply(this,arguments)}resultName(e){return arguments.length?(this.datasource().resultName(e),this):this.datasource().resultName()}toDDL(){return{id:this.datasource().wu().id(),output:this.resultName()}}};WUResultRef.prototype._class+=` WUResultRef`,ESPResult.prototype.publish(`samples`,10,`number`,`Number of samples`),ESPResult.prototype.publish(`sampleSize`,100,`number`,`Sample size`),x.prototype.publish(`wu`,null,`widget`,`Workunit`),x.prototype.publish(`resultName`,``,`set`,`Result Name`,function(){return this._wu===void 0?[]:this._wu.resultNames()}),x.prototype._origWu=x.prototype.wu,x.prototype.wu=function(e){let t=x.prototype._origWu.apply(this,arguments);return e!==void 0&&this._wu.refreshMeta(),t},x.prototype._origResultName=x.prototype.resultName,x.prototype.resultName=function(e){let t=this._resultName,n=x.prototype._origResultName.apply(this,arguments);return e!==void 0&&t!==e&&this.responseFields([]),n},S.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8010)`),S.prototype.publish(`wuid`,``,`string`,`Workunit ID`),S.prototype._origUrl=S.prototype.url,S.prototype.url=function(e){let t=S.prototype._origUrl.apply(this,arguments);return e!==void 0&&this.refreshMeta(),t},S.prototype._origWuid=S.prototype.wuid,S.prototype.wuid=function(e){let t=S.prototype._origWuid.apply(this,arguments);return e!==void 0&&this.refreshMeta(),t};var C=class LogicalFile extends ESPResult{constructor(e){super(e)}toDDL(){return{type:`logicalfile`,id:this.id(),url:this.url(),logicalFile:this.logicalFile(),fields:this.responseFields()}}fromDDL(e,t=!1){return(t?this:this.id(e.id)).url(e.url).logicalFile(e.logicalFile),this}static fromDDL(e,t,n=!1){return new LogicalFile(e).fromDDL(t,n)}_createResult(){return t.Result.attachLogicalFile({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.nodeGroup(),this.logicalFile())}sourceHash(){return super.hash({logicalFile:this.logicalFile()})}hash(e){return super.hash({ddl:this.toDDL()})}label(){return`${this.logicalFile()}`}};C.prototype._class+=` LogicalFile`,C.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8010)`),C.prototype.publish(`nodeGroup`,``,`string`,`Node Group`),C.prototype.publish(`logicalFile`,``,`string`,`Logical File Name`);var w=class RestField extends n.PropertyExt{_owner;constructor(){super()}toDDL(){return{type:`string`,id:this.fieldID()}}fromDDL(e){return this.fieldID(e.id)}static fromDDL(e){return new RestField().fromDDL(e)}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}},T=class RestService extends Datasource{_ec;_responseFields={};constructor(e){super(),this._ec=e}toDDL(){return{type:`rest`,id:this.id(),url:this.url(),action:this.action(),mode:this.mode(),inputs:this.validRequestFields().map(e=>e.toDDL()),outputs:this.outputDDL()}}fromDDL(e,t=!1){(t?this:this.id(e.id)).url(e.url).action(e.action).mode(e.mode||`get`).requestFields(e.inputs.map(w.fromDDL));for(let t in e.outputs)this.responseFields(t,e.outputs[t].fields);return this}static fromDDL(e,t,n=!1){return new RestService(e).fromDDL(t,n)}hash(e={}){return(0,r.hashSum)({url:this.url(),action:this.action(),mode:this.mode(),...e})}label(){return this.action()}responseFields(e,t){return arguments.length===1?this._responseFields[e]||[]:(this._responseFields[e]=t,this)}validRequestFields(){return this.requestFields().filter(e=>e.valid())}_prevRequestHash;_prevPromise;_submitQ=new r.AsyncOrderedQueue;submit(e){let n=(0,r.hashSum)(e);if(!this._prevPromise||this._prevRequestHash!==n){this._prevRequestHash=n;let r=(0,t.createConnection)({baseUrl:this.url(),type:this.mode()});this._prevPromise=this._submitQ.push(r.send(this.action(),e))}return this._prevPromise}resultNames(){let e=[];for(let t in this._responseFields)e.push(t);return e}outputDDL(){let e={};return this.resultNames().forEach(t=>{e[t]={fields:this._responseFields[t]}}),e}};T.prototype._class+=` RestService`;var E=class RestResult extends Datasource{_ec;_origService;constructor(e){super(),this._ec=e,this._service=new T(this._ec)}validRequestFields(){return this.service().validRequestFields()}toDDL(){return this.service().toDDL()}fromDDL(e){return this.service().fromDDL(e),this}static fromDDL(e,t,n){return new RestResult(e).id(`${t.id()}_${n}`).service(t).resultName(n)}serviceID(){return`${this.service().url()}/${this.service().action()}}`}sourceHash(){return this.service().hash()}requestFields(){return this.service().requestFields().map(e=>e.toDDL())}responseFields(e){return arguments.length?(this.service().responseFields(this.resultName(),e),this):this.service().responseFields(this.resultName())}hash(e={}){return(0,r.hashSum)({source:this.sourceHash(),resultName:this.resultName(),...e})}label(){return`${this.service().label()}\n${this.resultName()}`}_jsonData=[];jsonDataFields(){if(!this._jsonData||!this._jsonData.length)return[];let e=rowToFields(this._jsonData[0],this._jsonData);return this.responseFields(e),e}computeFields(e){return()=>this.jsonDataFields()}computeData(){return this._jsonData}submit(e){return this.service().submit(e).then(e=>{let t=this.resultName(),n=t?t.split(`.`):[];for(let t of n)e=(e||{})[t];return this._jsonData=e,e})}formatRequest(){let e={};return this.service().validRequestFields().forEach(t=>{e[t.fieldID()]=``}),e}exec(){return this.submit(this.formatRequest()).then(e=>{})}};E.prototype._class+=` RestResult`;var D=class Param extends n.PropertyExt{_ec;validate(e){let t=[];return this.source_valid()||t.push({source:`${e}.source.${this.source()}`,msg:`Invalid source: "${this.source()}"`,hint:`expected: ${JSON.stringify(this.visualizationIDs())}`}),this.remoteField_valid()||t.push({source:`${e}.remoteField`,msg:`Invalid remoteField: "${this.remoteField()}"`,hint:`expected: ${JSON.stringify(this.sourceOutFields())}`}),this.value_valid()||t.push({source:`${e}.value`,msg:`Invalid value: "${this.value()}"`,hint:`expected: any value.`}),t}constructor(e){super(),this._ec=e}toDDL(){return{source:this.source(),remoteFieldID:this.remoteField(),localFieldID:this.localField(),value:this.value()}}fromDDL(e){return this.source(e.source).remoteField(e.remoteFieldID).localField(e.localFieldID).value(e.value)}static fromDDL(e,t){return new Param(e).fromDDL(t)}hash(){return(0,r.hashSum)({label:this.localField(),source:this.source(),sourceField:this.remoteField()})}visualizationIDs(){return this._ec.elementIDs()}sourceFields(){return this.sourceOutFields().map(e=>e.id)}sourceViz(){return this._ec.element(this.source())}sourceOutFields(){return this.sourceViz().hipiePipeline().selectionFields()}sourceSelection(){return this.sourceViz().selection()}calcValue(){return this.source_exists()&&this.remoteField_exists()?this.sourceSelection().map(e=>e[this.remoteField()]):this.value_exists()?[this.value()]:[``]}exists(){return this.localField_exists()&&(this.source_exists()&&this.remoteField_exists()||this.value_exists())}};D.prototype._class+=` Param`;var RestResultRef=class extends DatasourceRef{_ec;serviceID(){return this.datasource().serviceID()}_data=[];datasource(e){return super.datasource.apply(this,arguments)}url(){return this.datasource().service().url()}action(){return this.datasource().service().action()}resultName(){return this.datasource().resultName()}validate(){let e=[];for(let t of this.validParams())e=e.concat(t.validate(`request`));return e}constructor(e){super(),this._ec=e}toDDL(){return{id:this.datasource().service().id(),output:this.resultName(),request:this.validParams().map(e=>({source:e.source(),remoteFieldID:e.remoteField(),localFieldID:e.localField(),value:e.value()}))}}sourceHash(){return this.datasource().hash()}requestFieldRefs(e){return arguments.length?(this.request(e.map(e=>D.fromDDL(this._ec,e))),this):this.validParams().map(e=>e.toDDL())}requestFields(){return this.datasource().requestFields()}responseFields(){return this.datasource().responseFields()}hash(){return this.datasource().hash({resultName:this.resultName(),request:this.formatRequest()})}label(){return`${this.datasource().label()}\n${this.datasource().resultName()}`}elementIDs(){return this._ec.elementIDs()}element(e){return this._ec.element(e)}referencedFields(e){super.referencedFields(e);let t=[];for(let t of this.validParams()){let n=t.sourceViz().hipiePipeline();e.inputs[this.id()]||(e.inputs[this.id()]=[]),e.inputs[this.id()].push(t.localField()),n.resolveFields(e,[t.remoteField()])}super.resolveFields(e,t)}validParams(){return this.request().filter(e=>e.exists())}refreshMeta(){return this.datasource().refreshMeta().then(()=>{let e=this.request(),t=(0,r.compare)(e.map(e=>e.localField()),this.datasource().validRequestFields().map(e=>e.fieldID())),n=e.filter(e=>t.update.indexOf(e.localField())>=0);this.request(n.concat(t.enter.map(e=>new D(this._ec).localField(e))))})}updatedBy(){return this.validParams().map(e=>e.source())}computeFields(e){return this.datasource().computeFields(e)}formatRequest(){let e=this.datasource().formatRequest();return this.request().forEach(t=>{e[t.localField()]!==void 0&&(e[t.localField()]=t.calcValue()||e[t.localField()])}),e}_prevRequestHash;_prevRequestPromise;exec(){let e=this.formatRequest(),t=(0,r.hashSum)({hash:this.hash(),request:e});return this._prevRequestHash!==t&&(this._prevRequestHash=t,this._prevRequestPromise=this.datasource().submit(e).then(e=>(this._data=this.fixInt64(e),this._data))),this._prevRequestPromise}inData(){return this._data}computeData(){return this._data}};RestResultRef.prototype._class+=` RestResultRef`,w.prototype.publish(`fieldID`,``,`string`,`RestField Label`),T.prototype.publish(`url`,``,`string`,`REST Url`),T.prototype.publish(`action`,``,`string`,`Query Set`),T.prototype.publish(`mode`,`get`,`set`,`Request mode`,[`get`,`post`]),T.prototype.publish(`requestFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:w}),E.prototype.publish(`service`,null,`widget`,`Rest service`),E.prototype.publish(`resultName`,``,`string`,`Result Name`),E.prototype._origService=E.prototype.service,E.prototype.service=function(e){let t=E.prototype._origService.apply(this,arguments);return e!==void 0&&this._service.refreshMeta(),t},D.prototype.publish(`localField`,null,`string`,`Label`),D.prototype.publish(`source`,null,`set`,`Activity`,function(){return this.visualizationIDs()},{optional:!0,disable:e=>e.value_exists(),validate:e=>e.source_disabled()||e.visualizationIDs().indexOf(e.source())>=0}),D.prototype.publish(`remoteField`,null,`set`,`Source Field`,function(){return this.sourceFields()},{optional:!0,disable:e=>!e.source_exists()||e.value_exists(),validate:e=>e.remoteField_disabled()||e.sourceFields().indexOf(e.remoteField())>=0}),D.prototype.publish(`value`,null,`string`,`Static Value`,null,{optional:!0,disable:e=>e.source_exists(),validate:e=>e.value_disabled()||e.value_exists()}),RestResultRef.prototype.publish(`request`,[],`propertyArray`,`Request Fields`);function parseUrl(e){let t=e.split(`/WsEcl/submit/query/`);if(t.length<2)throw Error(`Invalid roxie URL: ${e}`);let n=t[0].split(`:`);if(n.length<3)throw Error(`Invalid roxie URL: ${e}`);let r=t[1].split(`/`);if(r.length<2)throw Error(`Invalid roxie URL: ${e}`);return{url:`${n[0]}:${n[1]}:${n[2]===`18002`?`18010`:`8010`}`,querySet:r[0],queryID:r[1]}}function isHipieRequest(e){return e.length>=8&&e.indexOf(`_changed`)===e.length-8}function isHipieResponse(e){return e.length>=8&&e.indexOf(`_changed`)===e.length-8||[`HIPIE_DDL`,`HIPIE_DDLGLOBALS`,`hipieversion`].indexOf(e)>=0}var O=class RoxieService extends Datasource{_ec;_query;_requestFields;_responseFields={};_type=`roxie`;constructor(e){super(),this._ec=e}toDDL(){return{type:this._type,id:this.id(),url:this.url(),querySet:this.querySet(),queryID:this.queryID(),inputs:this.requestFields(),outputs:this.outputDDL()}}fromDDL(e,t=!1){this._type=e.type,(t?this:this.id(e.id)).url(e.url).querySet(e.querySet).queryID(e.queryID),e.inputs&&e.inputs.length&&this.requestFields(e.inputs);for(let t in e.outputs)this.responseFields(t,e.outputs[t].fields);return this}static fromDDL(e,t,n=!1){return new RoxieService(e).fromDDL(t,n)}hash(e={}){return(0,r.hashSum)({url:this.url(),querySet:this.querySet(),queryId:this.queryID(),ignoreHipieRequest:this.ignoreHipieRequest(),ignoreHipieResponse:this.ignoreHipieResponse(),...e})}label(){return this.queryID()}_prevSourceHash;refreshMetaPromise;refreshMeta(){if(this._prevSourceHash!==this.hash()&&(this._prevSourceHash=this.hash(),delete this.refreshMetaPromise),!this.refreshMetaPromise){let e=!!this._requestFields;this.refreshMetaPromise=new Promise((n,r)=>{let i=t.Query.attach({baseUrl:this.url(),hookSend:this._ec.hookSend()},this.querySet(),this.queryID());(!e||this.ignoreHipieRequest()||this.ignoreHipieResponse())&&n(i.refresh()),n(i)}).then(t=>{this._query=t,(!e||this.ignoreHipieRequest())&&(this._requestFields=t.requestFields().filter(e=>this._type===`roxie`||!isHipieRequest(e.id))),(!e||this.ignoreHipieResponse())&&t.resultNames().filter(e=>this._type===`roxie`||!isHipieResponse(e)).forEach(e=>{this._responseFields[e]=t.resultFields(e)})})}return this.refreshMetaPromise}requestFields(e){return arguments.length?(this._requestFields=e,this):this._requestFields||[]}responseFields(e,t){return arguments.length===1?this._responseFields[e]||[]:(this._responseFields[e]=t,this)}_prevRequestHash;_prevPromise;_submitQ=new r.AsyncOrderedQueue;submit(e){let t=(0,r.hashSum)(e);return(!this._prevPromise||this._prevRequestHash!==t)&&(this._prevRequestHash=t,this._prevPromise=this._submitQ.push(this._query.submit(e))),this._prevPromise}resultNames(){let e=[];for(let t in this._responseFields)e.push(t);return e}outputDDL(){let e={};return this.resultNames().forEach(t=>{e[t]={fields:this._responseFields[t]}}),e}};O.prototype._class+=` RoxieService`,O.prototype.publish(`url`,``,`string`,`ESP Url (http://x.x.x.x:8002)`),O.prototype.publish(`querySet`,``,`string`,`Query Set`),O.prototype.publish(`queryID`,``,`string`,`Query ID`),O.prototype.publish(`ignoreHipieRequest`,!1,`boolean`,`Ignore provided DDL request`),O.prototype.publish(`ignoreHipieResponse`,!1,`boolean`,`Ignore provided DDL response`);var k=class RoxieResult extends Datasource{_ec;_origService;constructor(e){super(),this._ec=e,this._service=new O(this._ec)}toDDL(){return this.service().toDDL()}fromDDL(e){return this.service().fromDDL(e),this}static fromDDL(e,t,n){return new RoxieResult(e).id(`${t.id()}_${n}`).service(t).resultName(n)}serviceID(){return`${this.service().url()}/${this.service().querySet()}/${this.service().queryID()}`}sourceHash(){return this.service().hash()}requestFields(){return this.service().requestFields()}responseFields(e){return arguments.length?(this.service().responseFields(this.resultName(),e),this):this.service().responseFields(this.resultName())}hash(e={}){return(0,r.hashSum)({source:this.sourceHash(),resultName:this.resultName(),...e})}label(){return`${this.service().label()}\n${this.resultName()}`}computeFields(e){return()=>this.service().responseFields(this.resultName())}refreshMeta(){return this.service().refreshMeta()}submit(e){return this.service().submit(e)}};k.prototype._class+=` RoxieResult`,k.prototype.publish(`service`,null,`widget`,`Roxie service`),k.prototype.publish(`resultName`,``,`set`,`Result Name`,function(){return this._service===void 0?[]:this._service.resultNames()}),k.prototype._origService=k.prototype.service,k.prototype.service=function(e){let t=k.prototype._origService.apply(this,arguments);return e!==void 0&&this._service.refreshMeta(),t};var RoxieResultRef=class extends DatasourceRef{_ec;serviceID(){return this.datasource().serviceID()}_data=[];datasource(e){return super.datasource.apply(this,arguments)}url(){return this.datasource().service().url()}querySet(){return this.datasource().service().querySet()}queryID(){return this.datasource().service().queryID()}resultName(){return this.datasource().resultName()}validate(){let e=[];for(let t of this.validParams())e=e.concat(t.validate(`request`));return e}constructor(e){super(),this._ec=e}toDDL(){return{id:this.datasource().service().id(),output:this.resultName(),request:this.validParams().map(e=>({source:e.source(),remoteFieldID:e.remoteField(),localFieldID:e.localField(),value:e.value()}))}}sourceHash(){return this.datasource().hash()}requestFieldRefs(e){return arguments.length?(this.request(e.map(e=>D.fromDDL(this._ec,e))),this):this.validParams().map(e=>e.toDDL())}requestFields(){return this.datasource().requestFields()}responseFields(){return this.datasource().responseFields()}hash(){return this.datasource().hash({resultName:this.resultName(),params:this.request().map(e=>e.hash()),request:this.formatRequest()})}label(){return`${this.datasource().label()}\n${this.datasource().resultName()}`}elementIDs(){return this._ec.elementIDs()}element(e){return this._ec.element(e)}referencedFields(e){super.referencedFields(e);let t=[];for(let n of this.validParams()){t.push(n.localField());let r=n.sourceViz().hipiePipeline();e.inputs[this.id()]||(e.inputs[this.id()]=[]),e.inputs[this.id()].push(n.localField()),r.resolveFields(e,[n.remoteField()])}super.resolveFields(e,t)}validParams(){return this.request().filter(e=>e.exists())}refreshMeta(){return this.datasource().refreshMeta().then(()=>{let e=this.request(),t=(0,r.compare)(e.map(e=>e.localField()),this.datasource().requestFields().map(e=>e.id)),n=e.filter(e=>t.update.indexOf(e.localField())>=0);this.request(n.concat(t.enter.map(e=>new D(this._ec).localField(e))))})}updatedBy(){return this.validParams().map(e=>e.source())}computeFields(e){return()=>this.datasource().responseFields()}formatRequest(){let e={},t=!1,n=this.datasource().requestFields();for(let r of this.validParams()){let i=r.calcValue(),a=n.filter(e=>e.id===r.localField())[0],o;o=a.type===`set`?{Item:i}:i[0],o!==void 0&&(e[r.localField()]=o),t=!0}return t||(e.refresh=!0),e}_prevRequestHash;_prevRequestPromise;exec(){return super.exec().then(()=>{let e=this.formatRequest(),t=(0,r.hashSum)({hash:this.hash(),request:e});return this._prevRequestHash!==t&&(this._prevRequestHash=t,this._prevRequestPromise=this.datasource().submit(e).then(e=>{let t=this.datasource().resultName(),n=e[t];return n||=e[t.toLowerCase().replace(/ /g,`_`)],this.fixInt64(n)})),this._prevRequestPromise}).then(e=>{this._data=e})}inData(){return this._data}computeData(){return this._data}};RoxieResultRef.prototype._class+=` RoxieResultRef`,RoxieResultRef.prototype.publish(`request`,[],`propertyArray`,`Request Fields`);var HipieResultRef=class extends RoxieResultRef{fullUrl(e){let t=parseUrl(e);return this.datasource().service().url(t.url),this.datasource().service().querySet(t.querySet),this.datasource().service().queryID(t.queryID),this}formatRequest(){let e=super.formatRequest(),t={};for(let n in e)t[n]=e[n],t[`${n}_changed`]=!0;return t}};HipieResultRef.prototype._class+=` HipieResultRef`;var A=0,DSPicker=class extends ActivitySelection{_ec;_nullDatasource=b;_origDatasourceID;_origDatasourceRef;datasource(){return this.datasourceRef().datasource()}refreshRef(e){let t=this._ec.datasource(e);t instanceof y||t instanceof v||t instanceof C||t instanceof O?this.selection(new DatasourceRef().datasource(t)):t instanceof x?this.selection(new WUResultRef().datasource(t)):t instanceof k?this.selection(new HipieResultRef(this._ec).datasource(t)):t instanceof E&&this.selection(new RestResultRef(this._ec).datasource(t))}selection(e){let t=super.selection.apply(this,arguments);return arguments.length?(this._datasourceID!==e.datasource().id()&&(this._datasourceID=e.datasource().id()),this):t||this._nullDatasource}validate(){return this.selection().validate()}constructor(e){super(),this._ec=e,this._id=`ds_${++A}`;let t=this._ec.datasources()[0];this.datasourceID(t.id())}toDDL(){return{...this.datasourceRef().toDDL(),id:this.datasourceID()}}hash(e={}){return super.hash({...e})}datasourceIDs(){return this._ec.datasources().map(e=>({value:e.id(),text:`${e.label()} ${e.id()===e.label()?``:` (${e.id()})`}`}))}};DSPicker.prototype._class+=` DSPicker`,DSPicker.prototype.publish(`datasourceID`,``,`set`,`Activity`,function(){return this.datasourceIDs()},{optional:!1}),DSPicker.prototype.publish(`datasourceRef`,``,`widget`,`Activity`),DSPicker.prototype._origDatasourceID=DSPicker.prototype.datasourceID,DSPicker.prototype.datasourceID=function(e){let t=this._datasourceID,n=DSPicker.prototype._origDatasourceID.apply(this,arguments);return e!==void 0&&t!==e&&this.refreshRef(e),n},DSPicker.prototype._origDatasourceRef=DSPicker.prototype.datasourceRef,DSPicker.prototype.datasourceRef=function(e){return ActivitySelection.prototype.selection.apply(this,arguments)};function createFilter(e,t,n){let r=typeof n==`string`;switch(e){case`==`:return e=>r&&typeof e[t]==`string`?e[t].trim()===n:e[t]===n;case`!=`:return e=>r&&typeof e[t]==`string`?e[t].trim()!==n:e[t]!==n;case`<`:return e=>e[t]<n;case`<=`:return e=>e[t]<=n;case`>`:return e=>e[t]>n;case`>=`:return e=>e[t]>=n;default:throw Error(`Unknown filter condition: ${e}`)}}var j=class ColumnMapping extends n.PropertyExt{_owner;validate(e){let t=[];return this.remoteField_valid()||t.push({source:`${e}.remoteField`,msg:`Invalid remoteField: "${this.remoteField()}"`,hint:`expected: ${JSON.stringify(this.sourceOutFields())}`}),this.localField_valid()||t.push({source:`${e}.localField`,msg:`Invalid localField: "${this.localField()}"`,hint:`expected: ${JSON.stringify(this.localFields())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return this.localField_exists()||this.remoteField_exists()}toDDL(){return{remoteFieldID:this.remoteField(),localFieldID:this.localField(),condition:this.condition(),nullable:this.nullable()}}fromDDL(e){return this.remoteField(e.remoteFieldID).localField(e.localFieldID).condition(e.condition).nullable(e.nullable)}static fromDDL(e){return new ColumnMapping().fromDDL(e)}hash(){return(0,r.hashSum)({remoteField:this.remoteField(),localField:this.localField(),condition:this.condition(),nullable:this.nullable()})}localFields(){return this._owner.inFields().map(e=>e.id)}sourceOutFields(){return this._owner.sourceOutFields().map(e=>e.id)}remoteValues(e){let t=this.remoteField();return e.map(e=>{let n=e[t];return typeof n==`string`?n.trim():n})}createFilterDescription(e){switch(this.condition()){case`in`:case`range`:return`${this.localField()} ${this.condition()} [${this.remoteValues(e).join(`, `)}]`;default:return`${this.localField()} ${this.condition()} ${this.remoteValues(e)[0]}`}}createFilter(e){let t=this.localField(),n=this.remoteValues(e);switch(this.condition()){case`range`:return this.nullable()&&(n.length<2||n[0]===n[1])?e=>!0:e=>e[t]>=n[0]&&e[t]<=n[1];case`in`:return this.nullable()&&n.length===0?e=>!0:e=>n.some(n=>typeof e[t]==`string`?e[t].trim()===n:e[t]===n);default:let e=n[0];return this.nullable()&&(e==null||e===``)?e=>!0:createFilter(this.condition(),t,e)}}};j.prototype._class+=` ColumnMapping`;var M=class RemoteFilter extends n.PropertyExt{_owner;validate(e){let t=[];this.source_valid()||t.push({source:`${e}.source.${this.source()}`,msg:`Invalid source: "${this.source()}"`,hint:`expected: ${JSON.stringify(this.visualizationIDs())}`}),this.source_exists()&&this.validMappings().length===0&&t.push({source:`${e}.source.${this.source()}`,msg:`Invalid mappings: "${this.source()}"`,hint:`expected minimum of 1 mapping`});for(let n of this.validMappings())t=t.concat(n.validate(`${e}.${this.source()}.mappings`));return t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.source()&&this.validMappings().length>0}toDDL(){return{viewID:this.source(),mappings:this.ddlMappings()}}fromDDL(e){return this.source(e.viewID).ddlMappings(e.mappings)}static fromDDL(e){return new RemoteFilter().fromDDL(e)}ddlMappings(e){return arguments.length?(this.mappings(e.map(e=>j.fromDDL(e))),this):this.validMappings().map(e=>e.toDDL())}visualizationIDs(){return this._owner.visualizationIDs()}hash(){return(0,r.hashSum)({source:this.source(),mappings:this.validMappings().map(e=>e.hash()),selection:this.sourceSelection()})}validMappings(){return this.mappings().filter(e=>e.valid())}appendMappings(e){for(let t of e)this.mappings().push(new j().owner(this).remoteField(t.remoteField).localField(t.localField).condition(t.condition));return this}inFields(){return this._owner.inFields()}sourceViz(){return this._owner.visualization(this.source())}sourceOutFields(){return this.sourceViz().hipiePipeline().selectionFields()}sourceSelection(){return this.sourceViz().selection()}createFilter(){let e=this.sourceSelection(),t=this.validMappings().map(t=>t.createFilter(e));return e=>t.every(t=>t(e))}createFilterDescription(){let e=this.sourceSelection();return this.validMappings().map(t=>t.createFilterDescription(e)).join(`, `)}};M.prototype._class+=` Filter`;var N=class StaticFilter extends n.PropertyExt{_owner;validate(e){let t=[];return this.localField_valid()||t.push({source:`${e}.localField`,msg:`Invalid localField: "${this.localField()}"`,hint:`expected: ${JSON.stringify(this.localFields())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}coerceValue(e){if(arguments.length===0)switch(this.valueType()){case`number`:return+this.value();default:return``+this.value()}return this.value(e),typeof e==`number`?this.valueType(`number`):this.valueType(`string`),this}valid(){return this.localField_exists()&&this.value_exists()}toDDL(){return{localFieldID:this.localField(),condition:this.condition(),value:this.coerceValue()}}fromDDL(e){return this.localField(e.localFieldID).condition(e.condition).coerceValue(e.value)}static fromDDL(e){return new StaticFilter().fromDDL(e)}hash(){return(0,r.hashSum)({localField:this.localField(),condition:this.condition(),value:this.value(),valueType:this.valueType()})}localFields(){return this._owner.inFields().map(e=>e.id)}createFilterDescription(){return`${this.localField()} ${this.condition()} ${this.coerceValue()}`}createFilter(){return createFilter(this.condition(),this.localField(),this.coerceValue())}};N.prototype._class+=` StaticFilter`;var P=class Filters extends Activity{_ec;static Filter=M;static Mapping=j;validate(){let e=[];for(let t of this.validFilters())e=e.concat(t.validate(`filter`));return e}constructor(e){super(),this._ec=e}toDDL(){return{type:`filter`,conditions:this.conditions()}}fromDDL(e){return this.conditions(e.conditions)}static fromDDL(e,t){return new Filters(e).fromDDL(t)}conditions(e){if(!arguments.length)return this.validFilters().map(e=>e.toDDL());let t=[],n=[];return e.forEach(e=>{i.DDL2.isIFilterCondition(e)?t.push(M.fromDDL(e)):n.push(N.fromDDL(e))}),this.remoteFilter(t),this.staticFilter(n),this}visualizationIDs(){return this._ec.elementIDs()}visualization(e){return this._ec.element(e)}hash(){return(0,r.hashSum)(this.validFilters().map(e=>({filter:e.hash()})))}exists(){return this.validFilters().length>0}updatedBy(){return this.validRemoteFilters().map(e=>e.source())}referencedFields(e){super.referencedFields(e);let t=[];for(let n of this.validRemoteFilters()){let r=n.sourceViz().hipiePipeline(),i=[];for(let e of n.validMappings())t.push(e.localField()),i.push(e.remoteField());r.resolveFields(e,i)}super.resolveInFields(e,t)}exec(){return super.exec()}computeData(){let e=super.computeData();if(e.length===0||!this.exists())return e;let t=this.validFilters().map(e=>e.createFilter());return e.filter(e=>t.every(t=>t(e)))}validRemoteFilters(){return this.remoteFilter().filter(e=>e.valid())}validStaticFilters(){return this.staticFilter().filter(e=>e.valid())}validFilters(){return[...this.validRemoteFilters(),...this.validStaticFilters()]}};P.prototype._class+=` Filters`,j.prototype.publish(`remoteField`,null,`set`,`Filter Fields`,function(){return this.sourceOutFields()},{optional:!0,disable:e=>!e._owner.source(),validate:e=>e.sourceOutFields().indexOf(e.remoteField())>=0}),j.prototype.publish(`localField`,null,`set`,`Local Fields`,function(){return this.localFields()},{optional:!0,disable:e=>!e._owner.source(),validate:e=>e.localFields().indexOf(e.localField())>=0}),j.prototype.publish(`condition`,`==`,`set`,`Filter Fields`,[`==`,`!=`,`>`,`>=`,`<`,`<=`,`range`,`in`]),j.prototype.publish(`nullable`,!1,`boolean`,`Ignore null filters`),M.prototype.publish(`source`,null,`set`,`Activity`,function(){return this.visualizationIDs()},{optional:!0,validate:e=>e.visualizationIDs().indexOf(e.source())>=0}),M.prototype.publish(`mappings`,[],`propertyArray`,`Mappings`,null,{autoExpand:j}),N.prototype.publish(`localField`,null,`set`,`Local Fields`,function(){return this.localFields()},{optional:!0,validate:e=>e.localFields().indexOf(e.localField())>=0}),N.prototype.publish(`condition`,`==`,`set`,`Filter Fields`,[`==`,`!=`,`>`,`>=`,`<`,`<=`]),N.prototype.publish(`value`,``,`any`,`Static Value`),N.prototype.publish(`valueType`,`number`,`set`,`Static Value Type`,[`number`,`string`]),P.prototype.publish(`remoteFilter`,[],`propertyArray`,`Remote Filter`,null,{autoExpand:M}),P.prototype.publish(`staticFilter`,[],`propertyArray`,`Static Filter`,null,{autoExpand:N});var F=class GroupByColumn extends n.PropertyExt{_owner;validate(e){let t=[];return this.label_valid()||t.push({source:`${e}.label`,msg:`Invalid label: "${this.label()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()}toDDL(){return this.label()}fromDDL(e){return this.label(e)}static fromDDL(e){return new GroupByColumn().fromDDL(e)}hash(){return(0,r.hashSum)(this.label())}columns(){return this._owner.inFieldIDs()}};F.prototype._class+=` GroupByColumn`;function localCount(e,t){return e.length}var I={count:localCount,min:n.min,max:n.max,mean:n.mean,median:n.median,variance:n.variance,deviation:n.deviation,sum:n.sum},L=class AggregateField extends n.PropertyExt{_owner;disableAggrColumn(){return!this.fieldID()||!this.aggrType()||this.aggrType()===`count`}disableBaseCountColumn(){return!this.fieldID()||!this.aggrType()||this.aggrType()!==`mean`}validate(e){let t=[];return this.aggrColumn_valid()||t.push({source:`${e}.${this.fieldID()}.aggrColumn`,msg:`Invalid aggrColumn: "${this.aggrColumn()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),this.baseCountColumn_valid()||t.push({source:`${e}.${this.fieldID()}.aggrColumn`,msg:`Invalid baseCountColumn: "${this.baseCountColumn()}"`,hint:`expected ${JSON.stringify(this.columns())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}toDDL(){return this.aggrType()===`count`?{fieldID:this.fieldID(),type:`count`}:{fieldID:this.fieldID(),type:this.aggrType(),inFieldID:this.aggrColumn(),baseCountFieldID:this.baseCountColumn()}}fromDDL(e){let t=this.fieldID(e.fieldID).aggrType(e.type);return e.type!==`count`&&(t.aggrColumn(e.inFieldID),t.baseCountColumn(e.baseCountFieldID)),t}static fromDDL(e){return new AggregateField().fromDDL(e)}hash(){return(0,r.hashSum)({label:this.fieldID(),aggrType:this.aggrType(),aggrColumn:this.aggrColumn()})}columns(){return this._owner.inFieldIDs()}hasColumn(){return this.columns().length}aggregate(e){return I[this.aggrType()](e,e=>+e[this.aggrColumn()])}aggrFunc(){let e=I[this.aggrType()],t=this.aggrColumn(),n=this.baseCountColumn();return n?r=>e(r,e=>e[t]/+e[n]):n=>e(n,e=>+e[t])}};L.prototype._class+=` AggregateField`;var R=class GroupBy extends Activity{validate(){let e=[];for(let t of this.validGroupBy())e=e.concat(t.validate(`GroupBy.column`));for(let t of this.validComputedFields())e=e.concat(t.validate(`GroupBy.computedFields`));return e}constructor(){super()}toDDL(){return{type:`groupby`,groupByIDs:this.fieldIDs(),aggregates:this.aggregates()}}fromDDL(e){return this.fieldIDs(e.groupByIDs).aggregates(e.aggregates)}static fromDDL(e){return new GroupBy().fromDDL(e)}fieldIDs(e){return arguments.length?(this.column(e.map(e=>F.fromDDL(e))),this):this.validGroupBy().map(e=>e.toDDL())}aggregates(e){return arguments.length?(this.computedFields(e.map(e=>L.fromDDL(e))),this):this.validComputedFields().map(e=>e.toDDL())}hash(){return(0,r.hashSum)({groupBy:this.column().map(e=>e.hash()),computedFields:this.computedFields().map(e=>e.hash())})}appendGroupBys(e){for(let t of e)this.column().push(new F().owner(this).label(t.field));return this}validGroupBy(){return this.column().filter(e=>e.valid())}exists(){return this.validGroupBy().length>0}inFieldIDs(){return this.inFields().map(e=>e.id)}field(e){for(let t of this.inFields())if(t.id===e)return t;return null}appendComputedFields(e){for(let t of e){let e=new L().owner(this).fieldID(t.label).aggrType(t.type);t.column!==void 0&&e.aggrColumn(t.column),this.computedFields().push(e)}return this}validComputedFields(){return this.computedFields().filter(e=>e.valid())}hasComputedFields(){return this.validComputedFields().length>0}computeFields(e){if(!this.exists())return super.computeFields(e);let t=[],n=this.validGroupBy();for(let e of n){let n=this.field(e.label()),r={type:n?n.type:`string`,id:e.label()};t.push(r)}for(let e of this.computedFields())if(e.fieldID()){let n={id:e.fieldID(),type:`number`};t.push(n)}if(this.details()){let e=t;if(this.exists()){let n={id:`values`,type:`dataset`,children:[]};t.push(n),e=n.children}let r=n.map(e=>e.label());e.push(...this.inFields().filter(e=>this.fullDetails()||r.indexOf(e.id)<0))}return()=>t}referencedFields(e){super.referencedFields(e);let t=[];for(let e of this.validGroupBy())t.push(e.label());for(let e of this.validComputedFields())e.aggrColumn()&&t.push(e.aggrColumn());super.resolveInFields(e,t)}computeData(){let e=super.computeData();if(e.length===0||!this.exists())return e;let t=this.validGroupBy().map(e=>e.label()),r=this.validComputedFields().map(e=>({label:e.fieldID(),aggrFunc:e.aggrFunc()})),i=(0,n.nest)().key(e=>{let n=``;for(let r of t)n+=`:`+e[r];return n}).entries(e).map(e=>{let n=e;delete n.key;for(let e of t)n[e]=n.values[0][e];for(let e of r)n[e.label]=e.aggrFunc(n.values);return n}),a=this.outFields();return i.map(e=>{let t={};for(let n of a)t[n.id]=e[n.id];return t})}};R.prototype._class+=` GroupBy`,F.prototype.publish(`label`,void 0,`set`,`Field`,function(){return this.columns()},{optional:!0,validate:e=>e.columns().indexOf(e.label())>=0}),L.prototype.publish(`fieldID`,null,`string`,`new Field ID`,null,{optional:!0,disable:e=>!e.hasColumn()}),L.prototype.publish(`aggrType`,`count`,`set`,`Aggregation Type`,[`count`,`min`,`max`,`sum`,`mean`,`median`,`variance`,`deviation`],{optional:!0,disable:e=>!e.fieldID()}),L.prototype.publish(`aggrColumn`,null,`set`,`Aggregation Field`,function(){return this.columns()},{optional:!0,disable:e=>e.disableAggrColumn(),validate:e=>e.columns().indexOf(e.aggrColumn())>=0}),L.prototype.publish(`baseCountColumn`,null,`set`,`Base Count Field`,function(){return this.columns()},{optional:!0,disable:e=>e.disableBaseCountColumn(),validate:e=>e.columns().indexOf(e.baseCountColumn())>=0}),R.prototype.publish(`column`,[],`propertyArray`,`Source Columns`,null,{autoExpand:F}),R.prototype.publish(`computedFields`,[],`propertyArray`,`Computed Fields`,null,{autoExpand:L}),R.prototype.publish(`details`,!1,`boolean`,`Show details`),R.prototype.publish(`fullDetails`,!1,`boolean`,`Show groupBy fileds in details`);var z=class Limit extends Activity{constructor(){super()}toDDL(){return{type:`limit`,limit:this.rows()}}fromDDL(e){return this.rows(e.limit)}static fromDDL(e){return new Limit().fromDDL(e)}hash(){return(0,r.hashSum)({limit:this.rows()})}exists(){return this.rows_exists()&&this.rows()>0}computeData(){let e=super.computeData();return e.length===0||!this.exists()?e:e.slice(0,Math.min(this.rows(),e.length))}};z.prototype._class+=` Limit`,z.prototype.publish(`rows`,void 0,`number`,`Limit output`);var B=class ComputedMapping extends n.PropertyExt{_owner;validate(e){let t=[];return this.value_valid()||t.push({source:`${e}.value`,msg:`Invalid value: "${this.value()}"`,hint:`expected: "any"`}),this.newValue_valid()||t.push({source:`${e}.newValue`,msg:`Invalid value: "${this.newValue()}"`,hint:`expected: "any"`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.value()&&!!this.newValue()}toDDL(){return{value:this.value(),newValue:this.newValue()}}fromDDL(e){return this.value(e.value).newValue(e.newValue)}static fromDDL(e){return new ComputedMapping().fromDDL(e)}};B.prototype._class+=` ComputedMapping`;var V=class ComputedField extends n.PropertyExt{_owner;disableColumn1(){return!this.label()||[`=`,`*`,`/`,`+`,`-`,`scale`,`map`].indexOf(this.type())<0}disableColumn2(){return!this.label()||[`*`,`/`,`+`,`-`].indexOf(this.type())<0}disableMapping(){return!this.label()||[`map`].indexOf(this.type())<0}disableChildField(){return!this.hasChildren()}validate(e){let t=[];return this.column1_valid()||t.push({source:`${e}.${this.label()}`,msg:`Invalid column1: "${this.column1()}"`,hint:`expected: ${JSON.stringify(this.columns())}`}),this.column2_valid()||t.push({source:`${e}.${this.label()}`,msg:`Invalid column2: "${this.column2()}"`,hint:`expected: ${JSON.stringify(this.columns())}`}),this.disableMapping()||this.validComputedMappings().forEach(t=>t.validate(`${e}.mapping`)),this.disableChildField()||this.validChildFields().forEach(t=>t.validate(`${e}.childField`)),t}hasChildren(){if(!this.label()||this.type()!==`=`||!this.column1())return!1;let e=this._owner.field(this.column1());return!!(e&&e.type===`dataset`&&e.children)}children(){let e=this._owner.field(this.column1());return e&&e.type===`dataset`?e.children:[]}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()}validComputedMappings(){return this.mapping().filter(e=>e.valid())}validChildFields(){return this.childField().filter(e=>e.valid())}hasChildFields(){return this.validChildFields().length}toDDL(){switch(this.type()){case`scale`:return{fieldID:this.label(),type:`scale`,sourceFieldID:this.column1(),factor:this.constValue()};case`template`:return{fieldID:this.label(),type:`template`,template:this.template()};case`=`:let e=this.validChildFields().map(e=>e.toDDL());return{fieldID:this.label(),type:`=`,sourceFieldID:this.column1(),transformations:e.length?e:void 0};case`map`:return{fieldID:this.label(),type:`map`,sourceFieldID:this.column1(),default:this.default(),mappings:this.validComputedMappings().map(e=>e.toDDL())};default:return{fieldID:this.label(),type:this.type(),sourceFieldID1:this.column1(),sourceFieldID2:this.column2()}}}fromDDL(e){let t=this.label(e.fieldID).type(e.type);switch(e.type){case`scale`:t.column1(e.sourceFieldID).constValue(e.factor);break;case`template`:t.template(e.template);break;case`=`:t.column1(e.sourceFieldID).childField(e.transformations?e.transformations.map(e=>ComputedField.fromDDL(e)):[]);break;case`map`:t.column1(e.sourceFieldID).default(e.default).mapping(e.mappings?e.mappings.map(e=>B.fromDDL(e)):[]);break;default:t.column1(e.sourceFieldID1).column2(e.sourceFieldID2)}return t}static fromDDL(e){return new ComputedField().fromDDL(e)}hash(){return(0,r.hashSum)(this.toDDL())}columns(){return this._owner.fieldIDs()}computedField(){switch(this.type()){case`=`:let e=this.validChildFields();return e.length===0&&this.hasChildren()&&(e=this.children().map(e=>new ComputedField().owner(this).label(e.id).type(`=`).column1(e.id))),{...this._owner.field(this.column1()),id:this.label(),children:e.length?e.map(e=>e.computedField()):void 0};case`*`:case`/`:case`+`:case`-`:case`scale`:return{id:this.label(),type:`number`};case`template`:return{id:this.label(),type:`string`};case`map`:return{id:this.label(),type:`object`}}return{id:this.label(),type:`string`}}projection(e){let t=this.hasChildFields(),n=this.validChildFields().map(t=>({label:t.label(),func:t.computeFunc(e)}));return r=>{let i=e&&t?{}:{...r};for(let e of n)i[e.label]=e.func(r);return e&&t&&(i.__lparam=r),i}}computeFunc(e){let t=this.column1(),i=this.column2();switch(this.type()){case`=`:return this.hasChildFields()?n=>(n[t].Row&&(0,r.isArray)(n[t].Row)?n[t].Row:n[t]).map(this.projection(e)):e=>e[t];case`*`:return e=>e[t]*+e[i];case`/`:return e=>e[t]/+e[i];case`+`:return e=>+e[t]+ +e[i];case`-`:return e=>e[t]-+e[i];case`scale`:let a=this.constValue();return e=>+e[t]*a;case`template`:let o=this.template();return e=>n.Utility.template(o,e);case`map`:let s=this.default(),c={};for(let e of this.mapping())c[e.value()]=e.newValue();return e=>c[e[t]]||s;default:return e=>e[t]}}fieldIDs(){let e=this._owner.field(this.column1());if(e)switch(e.type){case`dataset`:return e.children.map(e=>e.id);case`object`:return Object.keys(e.fields)}return[]}field(e){let t=this._owner.field(this.column1());if(t)switch(t.type){case`dataset`:for(let n of t.children)if(n.id===e)return n;break;case`object`:return t.fields[e]}}};V.prototype._class+=` ComputedField`;var H=class MultiField extends n.PropertyExt{_owner;constructor(){super()}hash(){return(0,r.hashSum)(this.toDDL())}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.label()&&this.validMultiFields().length>0}validate(e){let t=[];for(let n of this.validMultiFields())t=t.concat(n.validate(`${e}.computedFields`));return t}toDDL(){return{fieldID:this.label(),type:`multi`,transformations:this.transformations()}}fromDDL(e){return this.label(e.fieldID).transformations(e.transformations)}static fromDDL(e){return new MultiField().fromDDL(e)}validMultiFields(){return this.multiFields().filter(e=>e.valid())}transformations(e){return arguments.length?(this.multiFields(e.map(e=>V.fromDDL(e))),this):this.validMultiFields().map(e=>e.toDDL())}fieldIDs(){return this._owner.fieldIDs()}field(e){return this._owner.field(e)}};H.prototype._class+=` MultiField`;var ProjectBase=class extends Activity{static ComputedField=V;_includeLParam=!1;_trim=!1;validate(){let e=[];for(let t of this.validComputedFields())e=e.concat(t.validate(`${this.classID()}.computedFields`));return e}constructor(){super()}transformations(e){return arguments.length?(this.computedFields(e.map(e=>{switch(e.type){case`multi`:return H.fromDDL(e);default:return V.fromDDL(e)}})),this):this.validComputedFields().map(e=>e.toDDL())}exists(){return this.validComputedFields().length>0}fieldIDs(){return this.inFields().map(e=>e.id)}field(e){for(let t of this.inFields())if(t.id===e)return t;return null}clearComputedFields(){this.computedFields([])}appendComputedFields(e){for(let t of e){let e=new V().owner(this).label(t.label).type(t.type);t.column!==void 0&&e.column1(t.column),this.computedFields().push(e)}return this}validComputedFields(){return this.computedFields().filter(e=>e.valid())}hasComputedFields(){return this.validComputedFields().length}computeFields(e){if(!this.exists())return super.computeFields(e);let t=[],n={};for(let e of this.validComputedFields())if(e instanceof H)for(let r of e.validMultiFields()){let e=r.computedField();t.push(e),n[e.id]=!0}else{let r=e.computedField();t.push(r),n[r.id]=!0}if(this._trim&&this.hasComputedFields()){if(this._includeLParam){let e={id:`__lparam`,type:`object`};t.push(e),n[e.id]=!0}}else t=t.concat(e.filter(e=>!n[e.id]));return()=>t}referencedFields(e){super.referencedFields(e);let t=[];for(let e of this.validComputedFields())if(e instanceof H)for(let n of e.validMultiFields())t.push(n.column1()),n.column2()&&t.push(n.column2());else if(e.type()===`template`)for(let r of n.Utility.templateFields(e.template()))t.push(r);else t.push(e.column1()),e.column2()&&t.push(e.column2());super.resolveInFields(e,t)}projection(){let e=this._trim,t=this.hasComputedFields(),n=[];for(let t of this.validComputedFields())if(t instanceof H)for(let r of t.validMultiFields())n.push({label:r.label(),func:r.computeFunc(e)});else n.push({label:t.label(),func:t.computeFunc(e)});return r=>{let i=e&&t?{}:{...r};for(let e of n)i[e.label]=e.func(r);return e&&t&&this._includeLParam&&(i.__lparam=r),i}}computeData(){let e=super.computeData();return e.length===0||!this.exists()?e:e.map(this.projection())}},U=class Project extends ProjectBase{toDDL(){return{type:`project`,transformations:this.transformations()}}fromDDL(e){return this.transformations(e.transformations)}static fromDDL(e){return new Project().fromDDL(e)}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}};U.prototype._class+=` Project`;var W=class Mappings extends ProjectBase{constructor(){super(),this._trim=!0,this._includeLParam=!0}toDDL(){return{type:`mappings`,transformations:this.transformations()}}fromDDL(e){let t=e||{transformations:[]};return this.transformations(t.transformations)}static fromDDL(e){return new Mappings().fromDDL(e)}hash(e={}){return super.hash({ddl:this.toDDL(),...e})}referencedFields(e){if(this.hasComputedFields())return super.referencedFields(e);this.resolveInFields(e,this.inFields().filter(e=>e.id!==`__lparam`).map(e=>e.id))}};W.prototype._class+=` Mappings`,B.prototype.publish(`value`,null,`any`,`Compare Value`,void 0,{validate:e=>!e.value()&&!e.newValue()||!!e.value()&&!!e.newValue()}),B.prototype.publish(`newValue`,null,`any`,`New Value`,void 0,{validate:e=>!e.value()&&!e.newValue()||!!e.value()&&!!e.newValue()}),V.prototype.publish(`label`,null,`string`,`Label`,null,{optional:!0}),V.prototype.publish(`type`,`mapping`,`set`,`Project type`,[`=`,`*`,`/`,`+`,`-`,`scale`,`template`,`map`],{optional:!0,disable:e=>!e.label()}),V.prototype.publish(`column1`,null,`set`,`Param 1`,function(){return this.columns()},{optional:!0,disable:e=>e.disableColumn1(),validate:e=>e.columns().indexOf(e.column1())>=0}),V.prototype.publish(`column2`,null,`set`,`Param 2`,function(){return this.columns()},{optional:!0,disable:e=>e.disableColumn2(),validate:e=>e.columns().indexOf(e.column2())>=0}),V.prototype.publish(`constValue`,null,`number`,`Const value`,null,{optional:!0,disable:e=>!e.label()||[`scale`].indexOf(e.type())<0}),V.prototype.publish(`template`,null,`string`,`template`,null,{optional:!0,disable:e=>!e.label()||[`template`].indexOf(e.type())<0}),V.prototype.publish(`default`,null,`any`,`Default Value`,null,{optional:!0,disable:e=>!e.label()||[`map`].indexOf(e.type())<0}),V.prototype.publish(`mapping`,[],`propertyArray`,`Mapped Values`,null,{autoExpand:B,disable:e=>e.disableMapping()}),V.prototype.publish(`childField`,[],`propertyArray`,`Child Fields`,null,{autoExpand:V,disable:e=>e.disableChildField()}),H.prototype.publish(`label`,``,`string`,`Label`),H.prototype.publish(`multiFields`,[],`propertyArray`,`Multi Fields`,null,{autoExpand:V}),ProjectBase.prototype.publish(`computedFields`,[],`propertyArray`,`Computed Fields`,null,{autoExpand:V});var G=class SortColumn extends n.PropertyExt{_owner;validate(e){let t=[];return this.fieldID_valid()||t.push({source:`${e}.fieldID`,msg:`Invalid fieldID: ${this.fieldID()}`,hint:`expected ${JSON.stringify(this.fieldIDs())}`}),t}constructor(){super()}owner(e){return arguments.length?(this._owner=e,this):this._owner}valid(){return!!this.fieldID()}toDDL(){return{fieldID:this.fieldID(),descending:this.descending()}}fromDDL(e){return this.fieldID(e.fieldID).descending(e.descending)}static fromDDL(e){return new SortColumn().fromDDL(e)}hash(){return(0,r.hashSum)({sortColumn:this.fieldID(),descending:this.descending()})}fieldIDs(){return this._owner.fieldIDs()}field(e){return this._owner.inFields().filter(t=>t.id===e)[0]}};G.prototype._class+=` SortColumn`;var K=class Sort extends Activity{static Column=G;validate(){let e=[];for(let t of this.validSortBy())e=e.concat(t.validate(`Sort.column`));return e}constructor(){super()}toDDL(){return{type:`sort`,conditions:this.conditions()}}fromDDL(e){return this.conditions(e.conditions),this}static fromDDL(e){return new Sort().fromDDL(e)}conditions(e){return arguments.length?(this.column(e.map(e=>G.fromDDL(e))),this):this.validSortBy().map(e=>e.toDDL())}hash(){return(0,r.hashSum)({Sort:this.column().map(e=>e.hash())})}referencedFields(e){super.referencedFields(e),super.resolveInFields(e,this.validSortBy().map(e=>e.fieldID()))}validSortBy(){return this.column().filter(e=>e.fieldID())}exists(){return this.validSortBy().length>0}fieldIDs(){return this.inFields().map(e=>e.id)}computeData(){let e=super.computeData(),t=[];for(let e of this.validSortBy())t.push({compare:e.descending()?n.descending:n.ascending,id:e.fieldID()});return t.length?[...e].sort((e,n)=>{for(let r of t){let t=r.compare(e[r.id],n[r.id]);if(t!==0)return t}return 0}):e}};K.prototype._class+=` Sort`,G.prototype.publish(`fieldID`,null,`set`,`Sort Field`,function(){return this.fieldIDs()},{optional:!0,validate:e=>e.fieldIDs().indexOf(e.fieldID())>=0}),G.prototype.publish(`descending`,!1,`boolean`,`Sort Field`),K.prototype.publish(`column`,[],`propertyArray`,`Source Columns`,null,{autoExpand:G});var HipiePipeline=class extends ActivityPipeline{_ec;_origDatasource;_origFilters;_origProject;_origGroupBy;_origSort;_origLimit;constructor(e,t){super(),this._ec=e,this._id=t,this._datasource=new DSPicker(this._ec),this._filters=new P(this._ec),this._project=new U,this._groupBy=new R,this._sort=new K,this._limit=new z,this.updateSequence()}activities(e){return super.activities.apply(this,arguments)}updateSequence(){this.activities([this.datasource(),this.filters(),this.project(),this.groupBy(),this.sort(),this.limit()])}selectionFields(){return this.last().outFields()}};HipiePipeline.prototype.publish(`datasource`,null,`widget`,`Data Source 2`),HipiePipeline.prototype.publish(`filters`,null,`widget`,`Client Filters`),HipiePipeline.prototype.publish(`project`,null,`widget`,`Project`),HipiePipeline.prototype.publish(`groupBy`,null,`widget`,`Group By`),HipiePipeline.prototype.publish(`sort`,null,`widget`,`Sort`),HipiePipeline.prototype.publish(`limit`,null,`widget`,`Limit output`);function wrapHipiePipelineProperty(e){let t=`_orig${e.charAt(0).toUpperCase()+e.slice(1)}`;HipiePipeline.prototype[t]=HipiePipeline.prototype[e],HipiePipeline.prototype[e]=function(e){let n=HipiePipeline.prototype[t].apply(this,arguments);return e!==void 0&&this.updateSequence(),n}}wrapHipiePipelineProperty(`datasource`),wrapHipiePipelineProperty(`filters`),wrapHipiePipelineProperty(`project`),wrapHipiePipelineProperty(`groupBy`),wrapHipiePipelineProperty(`sort`),wrapHipiePipelineProperty(`limit`);var NullView=class extends HipiePipeline{hash(){return super.hash()}_fetch(e,t){return Promise.resolve([])}};NullView.prototype._class+=` NullView`;var VizPopupPanel=class extends u.Modal{_owner;_ownerLParam;constructor(e,t){super(),this._owner=e,this._ownerLParam=t,this._drawStartPos=`origin`,this.visible(!1),this.minHeight_default(`240px`),this.minWidth_default(`320px`),this.overflowY_default(`hidden`)}_host;host(e){return arguments.length?(this._host&&this._host!==e&&this._host._togglePopup.selected(!1).render(),this._host=e,this._owner.vizActivation(this._ownerLParam),this):this._host}enter(e,t){e.parentElement.style.position=`absolute`;let n=this.widget().title();n&&(this.title(n),this.widget().titleVisible(!1)),super.enter(e,t)}update(e,t){this.fixedTop(this._pos.y+`px`),this.fixedLeft(this._pos.x+`px`),super.update(e,t)}exit(e,t){super.exit(e,t),this.widget().title()&&this.widget().titleVisible(!0)}closeModal(){super.closeModal(),this._host&&this._host._togglePopup.selected(!1).render()}};VizPopupPanel.prototype._class+=` marshaller_VizPopupPanel`;var VizChartPanel=class extends u.ChartPanel{_popup;_togglePopup=new n.ToggleButton().faChar(`fa-filter`).tooltip(`Filter`).on(`click`,()=>{this._popup.host(this);let e=this.locateClosestAncestor([`marshaller_DashboardDockPanel`,`marshaller_DashboardGrid`]).getBBox(!0),t=this._popup.widget(),n=this._togglePopup.getBBox();this._popup.pos({x:-e.x+n.x+n.width-t.minWidth(),y:-e.y+n.y+n.height}).resize({width:t.minWidth(),height:t.minHeight()}).visible(this._togglePopup.selected()).render(e=>{let t=`#`+e.id()+` .layout_Carousel .common_Widget`,n=e.element().node();if(n){let{height:r,width:i}=n.querySelector(t).getBoundingClientRect();e.resizeBodySync(i,r)}})});_origButtons;_filterButtons;constructor(){super(),this._origButtons=this.buttons(),this._filterButtons=[this._togglePopup,new n.Spacer,...this._origButtons]}popup(e){return arguments.length?(this._popup=e,this._popup||this._togglePopup.selected(!1),this.buttons(this._popup?this._filterButtons:this._origButtons),this):this._popup}};VizChartPanel.prototype._class+=` marshaller_VizChartPanel`,VizChartPanel.prototype.publish(`descriptionTemplate`,``,`string`),VizChartPanel.prototype.publish(`minWidth`,320,`number`,`Min Width`),VizChartPanel.prototype.publish(`minHeight`,240,`number`,`Min Height`);var q={Table:o.Table,FieldForm:s.FieldForm,Area:a.Area,Bubble:a.Bubble,Bar:a.Bar,Column:a.Column,Contour:a.Contour,HexBin:a.HexBin,Line:a.Line,Pie:a.Pie,Radar:a.Radar,RadialBar:a.RadialBar,Scatter:a.Scatter,Step:a.Step,WordCloud:a.WordCloud,USCountiesChoropleth:l.ChoroplethCounties,USStatesChoropleth:l.ChoroplethStates,ClusterPins:l.Leaflet.ClusterPins,EntityRectList:n.EntityRectList,AdjacencyGraph:c.AdjacencyGraph,DataGraph:c.DataGraph},J=[];for(let e in q)J.push(e);function typeClass(e){return q[e]||o.Table}function typeNew(e){let t=new(q[e]||o.Table);return t instanceof s.FieldForm?t.validate(!1).allowEmptyRequest(!0):t instanceof c.AdjacencyGraph&&t.uidColumn(`uid`).labelColumn(`label`).iconColumn(`icon`).linksColumn(`links`).linkUidColumn(`uid`).linkLabelColumn(`label`),t}function typeInputs(e){return typeClass(e).__inputs||[]}var Visualization=class extends n.PropertyExt{_ec;_origVisibility;_origChartType;_origChartPanel;_hipiePipeline;constructor(e,t){super(),this._ec=e,this._hipiePipeline=t,this.mappings(new W),this.chartPanel(new VizChartPanel),this.typeChanged()}visualizationIDs(){return this._ec.elementIDs().filter(e=>e!==this.id())}_prevChartType;typeChanged(){if(this._prevChartType!==this._chartType){this._prevChartType=this._chartType,this.refreshMappings();let e=typeNew(this._chartType);this.chartPanel().widget(e)}}properties(e){return arguments.length?(this.chartPanel().deserialize(e),this):this.chartPanel().serialize()}refreshMappings(){let e=this.mappings();e.sourceActivity(this._hipiePipeline);let t=e.validComputedFields(),n=e.inFields(),r={};return e.computedFields(typeInputs(this._chartType).map((i,a)=>{let o=t[a];if(o)o instanceof H||o.label(i.id);else if(i.multi){o=new H().owner(e).label(i.id);let t=[];for(let e of n)(i.type===`any`||i.type===e.type)&&!r[e.id]&&(r[e.id]=!0,t.push(new V().label(e.id).type(`=`).column1(e.id)));o.multiFields(t)}else{o=new V().owner(e).label(i.id).type(`=`);for(let e of n)if((i.type===`any`||i.type===e.type)&&!r[e.id]){r[e.id]=!0,o.column1(e.id);break}}return o})),this}_prevFields=[];_prevLinkFields=[];_prevData=[];refreshData(){let e=this.mappings(),t=e.outFields(),n=this.toDBFields(t),r,i=[],a=this._ec.element(this.secondaryDataviewID());a&&(r=a.mappings().outFields(),i=this.toDBFields(r));let o=this._prevFields!==t||this._prevLinkFields!==r;if(o)if(this._prevFields=t,this.chartType()===`DataGraph`){let e=this.chartPanel().widget();e.vertexColumns(n.map(e=>e.label())),e.edgeColumns(i.map(e=>e.label()))}else this.chartPanel().fields(n.filter(e=>e.id()!==`__lparam`));else console.warn(`***${this.id()} Immutable Fields***`);let s=e.outData(),c=this._prevData!==s;if(c){this._prevData=s;let e=this.toDBData(n,s);if(this.chartType()===`DataGraph`){let t=this.chartPanel().widget();if(t.vertices(e),a){let e=a.mappings().outData(),n=this.toDBData(i,e);t.edges(n)}}else this.chartPanel().data(e)}else console.warn(`${this.id()} Immutable Data!`);return o||c?this.chartPanel().renderPromise().then(()=>{}):Promise.resolve()}fieldTypeTodbFieldType(e){switch(e){case`dataset`:return`nested`;case`boolean`:return`boolean`;case`number`:return`number`;default:return`string`}}toDBFields(e){let t=[];for(let r of e||[]){let e=new n.Database.Field().type(this.fieldTypeTodbFieldType(r.type)).id(r.id).label(r.id);switch(r.type){case`dataset`:e.children(this.toDBFields(r.children));break;case`object`:break}t.push(e)}return t}toDBData(e,t){return((0,r.isArray)(t)?t:[t]).map(t=>{let n=[];for(let r of e)r.type()===`nested`?n.push(this.toDBData(r.children(),t[r.id()].Row||t[r.id()])):n.push(t[r.label()]);return n})}exec(){let e=[];if(this.secondaryDataviewID_exists()){let t=this.secondaryDataviewID(),n=this._ec.element(t);n&&e.push(n.visualization().exec())}let t=this.mappings();return t.sourceActivity(this._hipiePipeline),e.push(t.refreshMeta().then(()=>t.exec())),Promise.all(e)}refresh(){return this.chartPanel().startProgress&&this.chartPanel().startProgress(),this.exec().then(()=>(this.chartPanel().finishProgress&&this.chartPanel().finishProgress(),this.refreshData()))}click(e,t,n,r){}vertex_click(e,t,n){}};Visualization.prototype._class+=` Visualization`,Visualization.prototype.publishProxy(`title`,`_chartPanel`),Visualization.prototype.publishProxy(`description`,`_chartPanel`),Visualization.prototype.publish(`visibility`,i.DDL2.VisibilitySet[0],`set`,`Type`,i.DDL2.VisibilitySet),Visualization.prototype.publish(`chartType`,`Table`,`set`,`Type`,J),Visualization.prototype.publish(`secondaryDataviewID`,null,`set`,`Secondary Data View (e.g. graph edges)`,function(){return this.visualizationIDs()},{optional:!0}),Visualization.prototype.publish(`mappings`,null,`widget`,`Mappings`,void 0,{render:!1,internal:!0}),Visualization.prototype.publish(`chartPanel`,[],`widget`,`Widget`),Visualization.prototype._origVisibility=Visualization.prototype.visibility,Visualization.prototype.visibility=function(e){let t=this._visibility,n=Visualization.prototype._origVisibility.apply(this,arguments);return e!==void 0&&t!==e&&this.chartPanel().target(null),n},Visualization.prototype._origChartType=Visualization.prototype.chartType,Visualization.prototype.chartType=function(e,t){e!==void 0&&J.indexOf(e)===-1&&(e=`Table`);let n=Visualization.prototype._origChartType.apply(this,arguments);if(e!==void 0&&(this.typeChanged(),t)){let e=this.chartPanel().widget();for(let n in t)typeof e[n]==`function`&&e[n](t[n])}return n},Visualization.prototype._origChartPanel=Visualization.prototype.chartPanel,Visualization.prototype.chartPanel=function(e){let t=Visualization.prototype._origChartPanel.apply(this,arguments);if(e!==void 0){this._chartPanel.on(`click`,(e,t,n,r)=>this.click(e,t,n,r)).on(`vertex_click`,(e,t,n)=>this.vertex_click(e,t,n));for(let e in q)if(this._chartPanel.widget()instanceof q[e]){this._chartType=e;break}}return t};var State=class extends n.PropertyExt{constructor(){super(),this.selection([])}set(e){return(0,r.hashSum)(this.selection())===(0,r.hashSum)(e)?!1:(this.selection(e),!0)}removeInvalid(e){let t=this.selection(),n=[];for(let i of t)(0,r.find)(e,(e,t)=>{for(let t in i)if(i[t]!==e[t])return!1;return!0})&&n.push(i);return n.length===t.length?!1:(this.selection(n),!0)}};State.prototype._class+=` State`,State.prototype.publish(`selection`,[],`array`,`State`);var Y=0,Element=class extends n.PropertyExt{_ec;_vizChartPanel;_origVisualization;constructor(e){for(super(),this._ec=e;Y++,this._id=`e_${Y}`,this._ec.elementExists(this._id););let t=new HipiePipeline(this._ec,this._id);this.hipiePipeline(t),this._vizChartPanel=new Visualization(this._ec,this.hipiePipeline()).id(`viz_${Y}`).title(`Element ${Y}`),this._vizChartPanel.chartPanel().id(`cp_${Y}`),this.visualization(this._vizChartPanel),this.state(new State)}id(e){let t=super.id.apply(this,arguments);return arguments.length&&this._vizChartPanel.id(e),t}chartType(){return this._vizChartPanel.chartType()}chartPanel(e){return arguments.length?(this._vizChartPanel.chartPanel(e),this):this._vizChartPanel.chartPanel()}chart(){return this._vizChartPanel.chartPanel().widget()}mappings(e){return arguments.length?(this._vizChartPanel.mappings(e),this):this._vizChartPanel.mappings()}pipeline(e){return this.hipiePipeline().activities(e),this}updatedBy(){let e=this.hipiePipeline().updatedBy();return this.visualization().secondaryDataviewID_exists()&&e.push(this.visualization().secondaryDataviewID()),e}dataProps(){return this.hipiePipeline()}vizProps(){return this.visualization().chartPanel()}stateProps(){return this.state()}_errors=[];errors(){return this._errors}validate(){if(!this._initialized)return[];this._errors=[];let e=this.hipiePipeline();for(let t of[...e.activities(),this.mappings()])for(let e of t.validate())this._errors.push({elementID:this.id(),...e});return this._errors}_initialized=!1;refresh(){let e=this.hipiePipeline().filters().validFilters().map(e=>e.createFilterDescription());return this.visualization().chartPanel().description(e.join(`, `)),this.visualization().refresh().then(()=>{this._initialized=!0;let e=this.hipiePipeline().outData();this.visualization().chartType()===`FieldForm`?this.state().set([...e])&&this.selectionChanged():this.state().removeInvalid(e)&&this.selectionChanged()})}selection(e){return arguments.length?(this.state().selection(e),this.selectionChanged(),this):this.state().selection()}selectionChanged(){let e=[];for(let t of this._ec.filteredBy(this.id()))e.push(t.refresh());Promise.all(e).then(()=>{this._ec.vizStateChanged(this)})}monitor(e){return this.hipiePipeline().monitor(e)}};Element.prototype._class+=` Viz`,Element.prototype.publish(`hipiePipeline`,null,`widget`,`Data View`),Element.prototype.publish(`visualization`,null,`widget`,`Visualization`),Element.prototype.publish(`state`,null,`widget`,`State`),Element.prototype._origVisualization=Element.prototype.visualization,Element.prototype.visualization=function(e){let t=Element.prototype._origVisualization.apply(this,arguments);return e!==void 0&&this._visualization.on(`click`,(e,t,n,i)=>{if(i&&i.selection)this.selection(n?i.selection.map(e=>e.__lparam||e):[]);else{let t=(0,r.isArray)(e)?e:[e];this.selection(n?t.map(e=>e.__lparam||e):[])}}).on(`vertex_click`,(e,t,n)=>{let i=(0,r.isArray)(e)?e:[e];this.selection(n?i.map(e=>e.__lparam||e):[])}),t};var ElementContainer=class extends n.PropertyExt{_nullElement;_datasources=[b];_elements=[];constructor(){super(),this.clear(),this._nullElement=new Element(this)}clear(e){this._datasources=e===void 0?[b]:this._datasources,this._elements=e===void 0?[]:this._elements.filter(t=>t.id()!==e)}_hookSend;hookSend(e){return arguments.length?(this._hookSend=e,this):this._hookSend}datasources(e){return arguments.length?(this._datasources=e,this):this._datasources}datasource(e){return this._datasources.filter(t=>t.id()===e)[0]}appendDatasource(e){return this._datasources.push(e),this}removeDatasource(e){return this._datasources=this._datasources.filter(t=>t!==e),this}elements(){return[...this._elements]}element(e){let t;return t=typeof e==`string`?this._elements.filter(t=>t.id()===e):e instanceof VizChartPanel?this._elements.filter(t=>t.chartPanel()===e):this._elements.filter(t=>t.vizProps()===e),t.length?t[0]:this._nullElement}elementExists(e){return this.element(e)!==this._nullElement}elementIDs(){return this._elements.map(e=>e.id())}append(e){return this._elements.push(e),this}filteredBy(e){return this._elements.filter(t=>t.updatedBy().indexOf(e)>=0)}views(){return this._elements.map(e=>e.hipiePipeline())}view(e){return this.views().filter(t=>t.id()===e)[0]}normalizePersist(e){let t={};return e.__properties.content.map(e=>{let n=!!e.__properties.widget.__properties.chart,r=e,i=e.__properties.widget,a=n?e.__properties.widget.__properties.chart:e.__properties.widget.__properties.widget,o=e.__properties.widget.__id?e.__properties.widget.__id:e.__properties.widget.__properties.widget.__id;t[o]={id:o,package:a.__class.split(`_`)[0],object:a.__class.split(`_`)[1],cell:_get_params(r,[`chart`,`widget`,`fields`]),panel:_get_params(i,[`chart`,`widget`,`fields`]),widget:_get_params(a,[`fields`])}}),t;function _get_params(e,t){let n={};return Object.keys(e.__properties).filter(e=>t.indexOf(e)===-1).forEach(t=>n[t]=e.__properties[t]),n}}validate(){let e=[];return this._elements.forEach(t=>{e=e.concat(t.validate())}),e}refresh(){return Promise.all(this.elements().map(e=>e.refresh())).then(()=>this)}vizStateChanged(e){}};ElementContainer.prototype._class+=` dashboard_ElementContainer`,ElementContainer.prototype.publish(`samples`,10,`number`,`Number of samples`),ElementContainer.prototype.publish(`sampleSize`,100,`number`,`Sample size`);function responseText(e){if(!e.ok)throw Error(e.status+` `+e.statusText);return e.text()}function text_default(e,t){return fetch(e,t).then(responseText)}__name(text_default,`default`);var PopupManager=class extends n.Widget{_ec;_popups=[];_popupIdx={};popupPanels(){return this._popups||=[],this._popupIdx||={},this._popups}popupChartPanels(){return this.popupPanels().map(e=>e.widget())}addPopup(e){let t=this._ec.element(e),n=this.element().node(),r=new VizPopupPanel(this,t).target(n).widget(e).relativeTargetId(this.id()).size({width:e.minWidth(),height:e.minHeight()});this._popups.push(r),this._popupIdx[e.id()]={panel:r,monitorHandle:e.monitor(t=>{switch(t){case`minWidth`:case`minHeight`:r.resize({width:e.minWidth(),height:e.minHeight()}).render();break}})},this._ec.filteredBy(t.id()).forEach(e=>{e.visualization().chartPanel().popup(r)})}removePopup(e){let t=this._ec.element(e);this._ec.filteredBy(t.id()).forEach(e=>{e.visualization().chartPanel().popup(null)}),this._popupIdx[e.id()].panel.target(null),this._popupIdx[e.id()].monitorHandle.remove(),e.target(null),delete this._popupIdx[e.id()],this._popups=this._popups.filter(t=>t.widget()!==e)}syncPopups(){let e=(0,r.compare)(this.popupChartPanels(),this._ec.elements().filter(e=>e.visualization().visibility()===`flyout`).map(e=>e.visualization().chartPanel()));for(let t of e.exit)this.removePopup(t);for(let t of e.enter)this.addPopup(t);return this}vizActivation(){}},DashboardDockPanel=class extends d.DockPanel{_ec;constructor(e){super(),this._ec=e}tabTitle(e){return this.hideSingleTabs()?e.visualization().title?e.visualization().title():e.visualization().id():e.id()}titleClassed(e,t,n){let r=e.title.className.split(` `);n&&r.indexOf(t)<0?r.push(t):!n&&r.indexOf(t)>0&&(r=r.filter(e=>e!==t)),e.title.className=r.join(` `)}updateTitle(e){let t=this.getWidgetAdapter(e),n=this._ec.element(e),r=n.validate();t.title.label=this.tabTitle(n),this.titleClassed(t,`error`,r.length>0),t.title.caption=r.map(e=>`${e.source}: ${e.msg}`).join(`
2
+ `)}activate(e){let t=this.getWidgetAdapter(e.visualization().chartPanel());t&&t.activate()}syncMinSize(e){return e.minWidth_exists()||e.minHeight_exists()?((0,n.select)(this.getWidgetAdapter(e).node).style(`min-width`,`${e.minWidth()}px`).style(`min-height`,`${e.minHeight()}px`),!0):!1}syncWidgets(){let e=(0,r.compare)(this.widgets(),this._ec.elements().filter(e=>e.visualization().visibility()===`normal`).map(e=>e.visualization().chartPanel())),t=!1;for(let t of e.exit)this.removeWidget(t);for(let n of e.enter){let e=this._ec.element(n);this.addWidget(n,this.tabTitle(e),`split-bottom`,void 0,this.hideSingleTabs()?void 0:this),t=this.syncMinSize(n)||t}for(let n of e.update)this.updateTitle(n),t=this.syncMinSize(n)||t;return t&&this.refit(),this}childActivation(e,t){super.childActivation(e,t),this.vizActivation(this._ec.element(e));for(let e of this.widgetAdapters())e===t?(e.addClass(`active`),this.titleClassed(e,`active`,!0),e.title.iconClass=`active`):(e.removeClass(`active`),this.titleClassed(e,`active`,!1),e.title.iconClass=``)}vizActivation(e){}canClose(e,t){let n=this._ec.element(e).id(),r=window.confirm(`Remove Widget "${n}"?`);return r&&(this._ec.clear(n),this.syncWidgets(),this.vizActivation(void 0)),r}syncPopups(){}};DashboardDockPanel.prototype._class+=` marshaller_DashboardDockPanel`,DashboardDockPanel.prototype.mixin(PopupManager);var DashboardGrid=class extends u.Grid{_ec;_layoutCache=[];constructor(e){super(),this._ec=e,this.designMode(!1),this.surfacePadding(`0`),this.surfaceBorderWidth(0)}updateGrid(e,t=0,n=!1){super.updateGrid(e,t,n),this._layoutCache=this.content().map(e=>({id:e.widget().id(),position:[e.gridCol(),e.gridRow(),e.gridColSpan(),e.gridRowSpan()]}))}layoutObj(e){if(e)if(e.main){let t=ddl2_layout(e,10,10);this._layoutCache=t}else e instanceof Array&&(this._layoutCache=e);return this;function ddl2_layout(e,t,n){let r=[];return dive(e.main,0,0,t,n),r;function dive(e,t,n,i,a){e.children?e.type===`split-area`?e.orientation===`horizontal`?e.children.forEach((r,o)=>{let s=e.sizes[o]*i,c=a,l=o===0?t:t+e.sizes[0]*i,u=n;dive(e.children[o],l,u,s,c)}):e.orientation===`vertical`?e.children.forEach((r,o)=>{let s=i,c=e.sizes[o]*a,l=t,u=o===0?n:n+e.sizes[0]*a;dive(e.children[o],l,u,s,c)}):console.error(`wtf`):e.type===`tab-area`&&e.children.forEach((r,o)=>{let s=i,c=e.sizes[o]*a,l=t,u=o===0?n:n+e.sizes[0]*a;dive(e.children[o],l,u,s,c)}):r.push([t,n,i,a].map(Math.round))}}}layout(){return this._layoutCache}widgets(){return this.content().map(e=>e.widget())}hideSingleTabs(){return!0}getWidgetAdapter(){}tabTitle(e){return this.hideSingleTabs()?e.visualization().title?e.visualization().title():e.visualization().id():e.id()}updateTitle(e){let t=this.getWidgetCell(e.id()),n=this._ec.element(e),r=this.tabTitle(n);t.widget().title(r)}activate(e){}removeWidget(e){let t=this.getWidgetCell(e.id());this.clearContent(t)}syncMinSize(e){return e.minWidth_exists()||e.minHeight_exists()?(this.getWidgetCell(e.id()).element().style(`min-width`,`${e.minWidth()}px`).style(`min-height`,`${e.minHeight()}px`),!0):!1}syncWidgets(){let e=(0,r.compare)(this.widgets(),this._ec.elements().filter(e=>e.visualization().visibility()===`normal`).map(e=>e.visualization().chartPanel()));for(let t of e.exit)this.removeWidget(t);let t=0,n=0,i=[];for(let r of e.enter){let e=this._ec.element(r),a=this.content().length;if(this._layoutCache&&this._layoutCache[a]){let a=this._layoutCache.find(e=>e.id===r.id());if(a){let[r,i,o,s]=a.position;this.setContent(i,r,e.visualization().chartPanel(),``,s,o),r+o>t&&(t=r+o),i+s>n&&(n=i+s)}else i.push(e.visualization().chartPanel())}else i.push(e.visualization().chartPanel())}let a=this.content().reduce((e,t)=>Math.max(e,t.gridRow()+t.gridRowSpan()),0);i.forEach(e=>{this.setContent(a,0,e,``,3,3),a+=3});for(let t of e.update)this.updateTitle(t);return this}childActivation(e,t){this.vizActivation(this._ec.element(e))}postSelectionChange(){super.postSelectionChange();let e=this._selectionBag.get();e.length>0&&this.childActivation(e[0].widget.widget())}vizActivation(e){}canClose(e,t){let n=this._ec.element(e).id(),r=window.confirm(`Remove Widget "${n}"?`);return r&&(this._ec.clear(n),this.syncWidgets(),this.vizActivation(void 0)),r}syncPopups(){}};DashboardGrid.prototype._class+=` marshaller_DashboardGrid`,DashboardGrid.prototype.mixin(PopupManager);var X=(0,r.scopedLogger)(`marshaller/ddl2/ddl`),DDLDatasourceAdapter=class{_dsDedup;constructor(){}clear(){this._dsDedup={}}id(e){return e instanceof S?`${e.url()}/${e.wuid()}`:e instanceof O?`${e.url()}/${e.querySet()}/${e.queryID()}`:e instanceof T?`${e.url()}/${e.action()}`:e.id()}_resolveID(e){return this._dsDedup[this.id(e)].ds.id()}resolveID(e){if(e instanceof WUResultRef)return this._resolveID(e.datasource().wu());if(e instanceof RoxieResultRef||e instanceof HipieResultRef||e instanceof RestResultRef)return this._resolveID(e.datasource().service())}append(e){let t=e instanceof DSPicker?e.datasource():e,n=e instanceof DSPicker?e.datasourceRef():void 0,r=t.id(),i=t instanceof x?t.wu():t instanceof k||t instanceof E?t.service():t,a=this.id(i);this._dsDedup[a]||(this._dsDedup[a]={ds:i,result:{}}),this._dsDedup[a].result[r]||(this._dsDedup[a].result[r]={refType:t,ref:n})}getAll(){let e=[];for(let t in this._dsDedup){let n=this._dsDedup[t].ds.toDDL();if(n.type===`roxie`||n.type===`hipie`||n.type===`rest`){let e={};for(let n in this._dsDedup[t].result){let r=this._dsDedup[t].result[n].refType.toDDL(),i={inputs:{},outputs:{}};this._dsDedup[t].result[n].ref.referencedFields(i);for(let t in i.inputs)i.inputs[t].forEach(t=>{e[t]=r.inputs.filter(e=>e.id===t)[0]})}n.inputs=[];for(let t in e)n.inputs.push(e[t])}if(n.type===`wuresult`||n.type===`roxie`||n.type===`hipie`||n.type===`rest`){let e={};for(let n in this._dsDedup[t].result){let r=this._dsDedup[t].result[n].refType.toDDL();if(r.type===`wuresult`||r.type===`roxie`||r.type===`hipie`||r.type===`rest`)for(let t in r.outputs)e[t]=r.outputs[t]}n.outputs={};for(let t in e)n.outputs[t]=e[t]}e.push(n)}return e}},DDLAdapter=class{_dashboard;_ec;_dsWriteDedup=new DDLDatasourceAdapter;_dsReadDedup={};constructor(e){this._dashboard=e,this._ec=this._dashboard.elementContainer()}writeDatasources(){for(let e of this._ec.elements())this._dsWriteDedup.append(e.hipiePipeline().datasource());return this._dsWriteDedup.getAll()}writeFilters(e){if(e.exists())return e.toDDL()}readFilters(e,t){return P.fromDDL(t,e)}writeProject(e){if(e.exists())return e.toDDL()}readProject(e){return U.fromDDL(e)}writeMappings(e){return e.exists()?e.toDDL():{type:`mappings`,transformations:[]}}readMappings(e){return W.fromDDL(e)}writeGroupBy(e){if(e.exists())return e.toDDL()}readGroupBy(e){return R.fromDDL(e)}writeSort(e){if(e.exists())return e.toDDL()}readSort(e){return K.fromDDL(e)}writeLimit(e){if(e.exists())return e.toDDL()}readLimit(e){return z.fromDDL(e)}readDatasourceRef(e,t,n){if(i.DDL2.isWUResultRef(e)){let n=this._dsReadDedup[e.id];t.datasourceID(n.output(e.output).id())}else i.DDL2.isRoxieServiceRef(e)?(t.datasourceID(`${e.id}_${e.output}`),t.datasourceRef().request(e.request.map(e=>D.fromDDL(this._ec,e)))):t.datasourceID(e.id);return this}writeActivities(e){return e.activities().map(e=>{if(e instanceof P)return this.writeFilters(e);if(e instanceof U)return this.writeProject(e);if(e instanceof R)return this.writeGroupBy(e);if(e instanceof K)return this.writeSort(e);if(e instanceof z)return this.writeLimit(e);if(e instanceof W)return this.writeMappings(e);e instanceof DSPicker||X.warning(`Unknown activity type: ${e.classID()}`)}).filter(e=>!!e)}writeVisualization(e){return{id:e.chartPanel().id(),title:e.title(),description:e.description(),visibility:e.visibility(),chartType:e.chartType(),__class:e.chartPanel().widget().classID(),mappings:this.writeMappings(e.mappings()),properties:e.properties()}}readVisualization(e,t){let n=this.readMappings(e.mappings);return t.chartPanel().id(e.id),t.title(e.title).description(e.description).visibility(e.visibility).chartType(e.chartType).properties(e.properties).mappings(n),this}writeViewDatasource(e){let t=e.toDDL();return t.id=this._dsWriteDedup.resolveID(e)||t.id,t}writeDDLViews(){let e={inputs:{},outputs:{}};for(let t of this._ec.elements())t.visualization().mappings().referencedFields(e);return this._ec.elements().map(e=>{let t=e.hipiePipeline(),n=t.datasource();if(n instanceof DSPicker){let r=n.datasourceRef();return{id:e.id(),datasource:this.writeViewDatasource(r),activities:this.writeActivities(t),visualization:this.writeVisualization(e.visualization())}}throw Error(`Missing DSPicker?`)})}writeProperties(){return{name:p,version:m,buildVersion:h,layout:this._dashboard.layout()}}readDDLViews(e){for(let t of e){let e=new Element(this._ec).id(t.id);this._ec.append(e);let n=e.hipiePipeline();this.readDatasourceRef(t.datasource,n.datasource(),this._ec);for(let e of t.activities){if(i.DDL2.isProjectActivity(e)){let t=this.readProject(e);n.project(t)}if(i.DDL2.isFilterActivity(e)){let t=this.readFilters(e,this._ec);n.filters(t)}if(i.DDL2.isGroupByActivity(e)){let t=this.readGroupBy(e);n.groupBy(t)}if(i.DDL2.isSortActivity(e)){let t=this.readSort(e);n.sort(t)}if(i.DDL2.isLimitActivity(e)){let t=this.readLimit(e);n.limit(t)}}this.readVisualization(t.visualization,e.visualization())}}readProperties(e){e&&e.layout&&this._dashboard.layoutObj(e.layout)}write(){return this._dsWriteDedup.clear(),{version:`2.2.1`,createdBy:{name:p,version:m},datasources:this.writeDatasources(),dataviews:this.writeDDLViews(),properties:this.writeProperties(),hipieProperties:this._dashboard.hipieProps()}}read(e){this._dsWriteDedup.clear();for(let t of e.datasources)switch(t.type){case`databomb`:this._ec.appendDatasource(y.fromDDL(t));break;case`form`:this._ec.appendDatasource(v.fromDDL(t));break;case`logicalfile`:this._ec.appendDatasource(C.fromDDL(this._ec,t));break;case`wuresult`:let e=S.fromDDL(this._ec,t);this._dsReadDedup[e.id()]=e;for(let n in t.outputs)this._ec.appendDatasource(e.output(n));break;case`roxie`:case`hipie`:let n=O.fromDDL(this._ec,t);this._dsReadDedup[n.id()]=n;for(let e in t.outputs)this._ec.appendDatasource(k.fromDDL(this._ec,n,e));break;case`rest`:let r=T.fromDDL(this._ec,t);this._dsReadDedup[r.id()]=r;for(let e in t.outputs)this._ec.appendDatasource(E.fromDDL(this._ec,r,e));break;default:X.warning(`Unknown ddl datasource type: ${t.type} `)}this.readDDLViews(e.dataviews),this.readProperties(e.properties),this._dashboard.hipieProps(e.hipieProperties)}},Imports=class{_moduleMap={};append(e){this._moduleMap[e.module]||(this._moduleMap[e.module]={}),this._moduleMap[e.module][e.class]=!0}write(){let e=[];for(let t in this._moduleMap){let n=[];for(let e in this._moduleMap[t])n.push(e);n.sort(),e.push(`import { ${n.join(`, `)} } from "${t}";`)}return e.join(`
3
+ `)}};function createProps(e){let t={};for(let n of e.publishedProperties())if(e[n.id+`_modified`]()&&n.id!==`fields`){let r=e[n.id]();switch(n.type){case`propertyArray`:let e=r.map(createProps);e&&(t[n.id]=e);break;default:t[n.id]=r}}return t}var JavaScriptAdapter=class{_dashboard;_ec;_ddlAdapter;_ddlSchema;constructor(e){this._dashboard=e,this._ec=this._dashboard.elementContainer(),this._ddlAdapter=new DDLAdapter(this._dashboard),this._ddlSchema=this._ddlAdapter.write()}createProps(e,t,n=``){let r=[];for(let i of t.publishedProperties())if(t[i.id+`_exists`]())switch(i.type){case`string`:case`set`:r.push(`${e}.${i.id}("${t[i.id]()}")${n};`);break;case`number`:case`boolean`:r.push(`${e}.${i.id}(${t[i.id]()})${n};`);break;case`widget`:r=r.concat(this.createProps(`${e}.${i.id}()`,t[i.id]()));break;case`propertyArray`:i.ext&&r.push(`${e}.${i.id}([${t[i.id]()}])${n};`);break;default:break}return r}writeMeta(e){return``}safeID(e){return e&&e.replace(/ /g,`_`).replace(/\./g,`_`)}datasourceRefID(e){let t=e.datasource;return i.DDL2.isRoxieServiceRef(t)?`${this.safeID(t.id)}_${this.safeID(t.output)}_${this.safeID(e.id)}`:i.DDL2.isWUResultRef(t)?`${this.safeID(t.id)}_${this.safeID(t.output)}`:`${this.safeID(t.id)}`}_dedup={};writeDatasource(e){let t=e.datasource,n=[],r=this._ddlSchema.datasources.filter(e=>e.id===t.id)[0],i=t.output,a=this.datasourceRefID(e);if(!this._dedup[a])switch(this._dedup[a]=!0,r.type){case`wuresult`:let o=this.safeID(e.datasource.id);this._dedup[o]||(this._dedup[o]=!0,n.push(` export const ${o} = new marshaller.WU()
4
+ .url("${r.url}")
5
+ .wuid("${r.wuid}")
6
+ ;`)),n.push(` export const ${a} = new marshaller.WUResult()
7
+ .wu(${o})
8
+ .resultName("${i}")
9
+ .responseFields(${stringify(r.outputs[i].fields)})
10
+ ;`);break;case`logicalfile`:n.push(` export const ${a} = new marshaller.LogicalFile()
11
+ .url("${r.url}")
12
+ .logicalFile("${r.logicalFile}")
13
+ .responseFields(${stringify(r.fields)})
14
+ ;`);break;case`hipie`:case`roxie`:let s=this.safeID(e.datasource.id);this._dedup[s]||(this._dedup[s]=!0,n.push(` export const ${s} = new marshaller.RoxieService(ec)
15
+ .url("${r.url}")
16
+ .querySet("${r.querySet}")
17
+ .queryID("${r.queryID}")
18
+ .requestFields(${stringify(r.inputs)})
19
+ ;`));let c=s+`_`+this.safeID(i);this._dedup[c]||(this._dedup[c]=!0,n.push(` export const ${c} = new marshaller.RoxieResult(ec)
20
+ .service(${s})
21
+ .resultName("${i}")
22
+ .responseFields(${stringify(r.outputs[i].fields)})
23
+ ;`)),n.push(` export const ${a} = new marshaller.HipieResultRef(ec)
24
+ .datasource(${c})
25
+ .requestFieldRefs(${stringify(t.request)})
26
+ ;`);break;case`databomb`:n.push(` export const ${a} = new marshaller.Databomb()
27
+ .format("${r.format}")
28
+ .payload(${JSON.stringify(r.payload)})
29
+ ;`);break;case`form`:{let e=[];for(let t of r.fields)e.push(`new marshaller.FormField().fieldID("${t.id}").default("${t.default||``}")`);n.push(` export const ${a} = new marshaller.Form()
30
+ .formFields([
31
+ ${e.join(`,
32
+ `)}
33
+ ])
34
+ ;`)}break}return n}writeActivity(e){switch(e.type){case`filter`:return`new marshaller.Filters(ec).conditions(${stringify(e.conditions)})`;case`project`:return`new marshaller.Project().transformations(${stringify(e.transformations)})`;case`groupby`:return`new marshaller.GroupBy().fieldIDs(${JSON.stringify(e.groupByIDs)}).aggregates(${stringify(e.aggregates)})`;case`sort`:return`new marshaller.Sort().conditions(${stringify(e.conditions)})`;case`limit`:return`new marshaller.Limit().rows(${e.limit})`;case`mappings`:return`new marshaller.Mappings().transformations(${stringify(e.transformations)})`}}writeWidgetProps(e){let t=[];for(let n of e.publishedProperties())e[n.id+`_modified`]()&&n.id!==`fields`&&t.push(`.${n.id}(${JSON.stringify(e[n.id]())})`);return t}joinWithPrefix(e,t,n,i){let a=``,o;e.__class&&(o=(0,r.classID2Meta)(e.__class),t.append(o),a+=`new ${o.class}()`);for(let o in e)if(o!==`__class`)if((0,r.isArray)(e[o])){let r=`${e[o].map(e=>this.joinWithPrefix(e,t,n+` `,``)).join(`,${n} `)}`;r&&(a+=`${n} .${o}([${n} ${r}${n} ])${i}`)}else a+=`${n} .${o}(${JSON.stringify(e[o])})${i}`;return a}writeWidget(e,t){return` export const ${e.visualization.id} = new marshaller.VizChartPanel()
35
+ .id("${e.visualization.id}")
36
+ .title("${e.visualization.title}")
37
+ .widget(${this.joinWithPrefix(e.visualization.properties.widget,t,`
38
+ `,``)})
39
+ ;`}writeElement(e){let t=[`data.${this.datasourceRefID(e)}`];for(let n of e.activities)t.push(this.writeActivity(n));let n=[];for(let t of this._ec.filteredBy(e.id))n.push(`${t.id()}.refresh();`);return`
40
+ const ${e.id} = new marshaller.Element(ec)
41
+ .id("${e.id}")
42
+ .pipeline([
43
+ ${t.join(`,
44
+ `)}
45
+ ])
46
+ .mappings(new marshaller.Mappings().transformations(${stringify(e.visualization.mappings.transformations)}))
47
+ .chartPanel(viz.${e.visualization.id})
48
+ .on("selectionChanged", () => {
49
+ ${n.join(`
50
+ `)}
51
+ }, true)
52
+ ;
53
+ ${e.id}.visualization()
54
+ .visibility("${e.visualization.visibility}")
55
+ .secondaryDataviewID("${e.visualization.secondaryDataviewID||``}")
56
+ ;
57
+ ec.append(${e.id});
58
+ `}writeDatasources(){let e=[];for(let t of this._ddlSchema.dataviews)e=e.concat(this.writeDatasource(t));return e}writeWidgets(){let e=[],t=new Imports;for(let n of this._ddlSchema.dataviews)e.push(this.writeWidget(n,t));return{widgetImports:t.write(),widgetDefs:e.join(`
59
+
60
+ `)}}writeElements(){let e=``;for(let t of this._ddlSchema.dataviews)e+=this.writeElement(t);return e}createJavaScript(){let e=this.writeWidgets();return`\
61
+ ${e.widgetImports}
62
+ import * as marshaller from "@hpcc-js/marshaller";
63
+
64
+ // Dashboard Element Container (Model) ---
65
+ const ec = new marshaller.ElementContainer();
66
+
67
+ namespace data {
68
+ ${this.writeDatasources().join(`
69
+ `)}
70
+ }
71
+
72
+ namespace viz {
73
+ ${e.widgetDefs}
74
+ }
75
+
76
+ // Dashboard Elements (Controller) ---
77
+ ${this.writeElements().trim()}
78
+
79
+ ec.refresh();
80
+
81
+ // Optional ---
82
+ const errors = ec.validate();
83
+ for (const error of errors) {
84
+ console.error(error.elementID + " (" + error.source + "): " + error.msg);
85
+ }
86
+
87
+ export const dashboard = new marshaller.Dashboard(ec)
88
+ .target("placeholder")
89
+ .titleVisible(false)
90
+ .hideSingleTabs(true)
91
+ .layoutObj(${stringify(this._dashboard.layout())})
92
+ .render()
93
+ ;
94
+
95
+ // @ts-ignore
96
+ const ddl = ${JSON.stringify(this._ddlSchema)};
97
+ `}},Z=class Dashboard extends u.ChartPanel{_ec;_dockPanel;_designModeButton=new n.ToggleButton().faChar(`fa-object-group`).tooltip(`Design Mode...`).selected(!0).on(`click`,()=>{this._dockPanel instanceof DashboardGrid&&this._dockPanel.designMode(this._designModeButton.selected()).lazyRender()});_addButton=new n.Button().faChar(`fa-plus`).tooltip(`Add...`).on(`click`,()=>{let e=new Element(this._ec);this._ec.append(e),this.renderPromise().then(()=>{e.refresh().then(()=>{this.activate(e)})})});_removeButton=new n.Button().faChar(`fa-minus`).tooltip(`Remove...`).enabled(!1).on(`click`,()=>{let e=this._prevActive;e&&window.confirm(`Remove Widget "${e.id()}"?`)&&(this._ec.clear(e.id()),this.renderPromise().then(()=>{this.vizActivation(void 0)}))});_reloadButton=new n.Button().faChar(`fa-refresh`).tooltip(`Reload...`).on(`click`,()=>{let e=this.save();this._ec.clear(),this.vizActivation(void 0),this.renderPromise().then(()=>{this.restore(e),this.renderPromise().then(()=>{this._ec.refresh().then(()=>{})})})});_addSamples=new n.Button().faChar(`fa-database`).tooltip(`Add Samples`).on(`click`,()=>{Promise.all([text_default(`https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/airports.csv`),text_default(`https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/carriers.csv`),text_default(`https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/stats.csv`)]).then(([e,t,n])=>{let r=this.addForm(`popup`,{type:`form`,id:`global_filter`,fields:[{type:`string`,id:`Airport`},{type:`string`,id:`Airline`}]});r.visualization().title(`Global Filter`).visibility(`flyout`).chartType(`FieldForm`);let i=this.addDatabomb(`airports`,e,`csv`,[new _().fieldID(`code`).type(`string`),new _().fieldID(`name`).type(`string`),new _().fieldID(`count`).type(`number`)],new P(this._ec).remoteFilter([new P.Filter().source(r.id()).mappings([new P.Mapping().remoteField(`Airport`).localField(`code`).nullable(!0)])]),new K().column([new K.Column().fieldID(`count`).descending(!0)]));i.chartPanel().title(`Airports`);let a=this.addDatabomb(`carriers`,t,`csv`,[new _().fieldID(`code`).type(`string`),new _().fieldID(`name`).type(`string`),new _().fieldID(`count`).type(`number`)],new P(this._ec).remoteFilter([new P.Filter().source(r.id()).mappings([new P.Mapping().remoteField(`Airline`).localField(`code`).nullable(!0)])]),new K().column([new K.Column().fieldID(`count`).descending(!0)]));a.chartPanel().title(`Airlines`);let o=this.addDatabomb(`stats`,n,`csv`,[],new P(this._ec).remoteFilter([new P.Filter().source(i.id()).mappings([new P.Mapping().remoteField(`code`).localField(`airport`)]),new P.Filter().source(a.id()).mappings([new P.Mapping().remoteField(`code`).localField(`carrier`).nullable(!0)])]));return o.chartPanel().title(`Stats`),Promise.all([r.refresh(),i.refresh(),a.refresh(),o.refresh()])}).then(()=>{this.render()})});addDatabomb(e,t,n=`csv`,r,...i){let a=new y().id(e).format(n).payload(t);r.length>0&&a.databombFields(r),this._ec.appendDatasource(a);let o=new Element(this._ec),s=o.hipiePipeline().datasource();s instanceof DSPicker&&s.datasourceID(a.id());for(let e of i)e instanceof P?o.hipiePipeline().filters(e):e instanceof U?o.hipiePipeline().project(e):e instanceof R?o.hipiePipeline().groupBy(e):e instanceof K?o.hipiePipeline().sort(e):e instanceof z&&o.hipiePipeline().limit(e);return this._ec.append(o),o}addForm(e,t){let n=new v().id(e).fromDDL(t);this._ec.appendDatasource(n);let r=new Element(this._ec),i=r.hipiePipeline().datasource();return i instanceof DSPicker&&i.datasourceID(n.id()),this._ec.append(r),r}static create(e,t){return new Promise((n,r)=>{let i=new ElementContainer,a=new Dashboard(i).target(e).hideSingleTabs(!0).titleVisible(!1).restore(t).render(e=>{i.refresh().then(()=>{n(a)})})})}constructor(e){super(),this._ec=e,this._ec.on(`vizStateChanged`,e=>{this.vizStateChanged(e)}),this.buttons([this._designModeButton,new n.Spacer,this._addButton,this._removeButton,new n.Spacer,this._reloadButton,new n.Spacer,this._addSamples]),this.ensureDockPanel(`dock`)}ensureDockPanel(e=`dock`){(e===`dock`&&!(this._dockPanel instanceof DashboardDockPanel)||e===`grid`&&!(this._dockPanel instanceof DashboardGrid))&&(this._dockPanel=(e===`dock`?new DashboardDockPanel(this._ec):new DashboardGrid(this._ec).designMode(this.titleVisible())).on(`vizActivation`,e=>{this.vizActivation(e)}),this.widget(this._dockPanel))}elementContainer(){return this._ec}_hipieProps;hipieProps(e){return arguments.length?(this._hipieProps=e,this):this._hipieProps}ddl(e){let t=new DDLAdapter(this);return arguments.length?(this._ec.clear(),t.read(e),this):t.write()}layoutObj(e){return this._dockPanel.layoutObj(e),this}save(){return new DDLAdapter(this).write()}serializeDDL(){return JSON.stringify(this.save())}deserializeDDL(e){return this.restore(JSON.parse(e))}restore(e,t=!1){return this.ensureDockPanel(e&&e.properties&&e.properties.layout instanceof Array?`grid`:`dock`),this._ec.clear(),new DDLAdapter(this).read(e),t&&this.renderPromise().then(()=>{this._ec.refresh()}),this}importDDL(e,t,n,r={}){let a=(0,i.isDDL2Schema)(e)?e:(0,i.upgrade)(e,t,n,!0,r);return this.restore(a,!0)}javascript(){return new JavaScriptAdapter(this).createJavaScript()}layout(){return this._dockPanel.layout()}widgets(){return this._dockPanel.widgets()}activate(e){this._dockPanel.activate(e)}hideSingleTabs(e){return arguments.length?(this._dockPanel.hideSingleTabs(e),this):this._dockPanel.hideSingleTabs()}updateButtonState(){this._designModeButton.enabled(this._dockPanel instanceof DashboardGrid).render(),this._removeButton.enabled(this._prevActive!==void 0).render()}update(e,t){this._dockPanel.syncWidgets(),super.update(e,t),this.updateButtonState()}_prevActive;vizActivation(e){this._prevActive=e,this._removeButton.enabled(e!==void 0).render()}vizStateChanged(e){}render(e){return this._dockPanel.syncPopups(),super.render(t=>{e&&e(t)})}};Z.prototype._class+=` dashboard_dashboard`;var DDLEditor=class extends d.SplitPanel{summary=`0 Errors`;_ddlEditor=new f.JSONEditor().on(`changes`,e=>{this.checkSyntax()});_errorTable=new o.Table().columns([`dataPath`,`keyword`,`message`,`params`]);ddl(e){return arguments.length?(this._ddlEditor.json(e),this.checkSyntax(),this):this._ddlEditor.json()}checkSyntax(){try{let e=this.ddl();try{let{success:t,errors:n}=(0,i.validate2)(e);t?this._errorTable.data([]):this._errorTable.data(n.map(e=>[e.instancePath,e.keyword,e.message,JSON.stringify(e.params)]))}catch{this._errorTable.data([[``,`Validation Failed`,``,``]])}}catch{this._errorTable.data([[`ALL`,`Invalid JSON`,``,``]])}this._renderCount&&this._errorTable.lazyRender()}enter(e,t){super.enter(e,t),this.addWidget(this._ddlEditor).addWidget(this._errorTable)}update(e,t){super.update(e,t)}};DDLEditor.prototype._class+=` codemirror_DDLEditor`;var GraphAdapter=class{_ec;subgraphMap={};vertexMap={};edgeMap={};hierarchy=[];vertices=[];edges=[];constructor(e){this._ec=e}clear(){this.subgraphMap={},this.vertexMap={},this.edgeMap={},this.hierarchy=[],this.vertices=[],this.edges=[]}createSubgraph(e,t,n){let r=this.subgraphMap[e];return r||(r=new c.Subgraph().columns([`DS`]).data([[n]]),this.subgraphMap[e]=r),this.vertices.push(r),r.title(`${t}`),r.getBBox(!0),r}createVertex(e,t,n,r=``,i=`#dcf1ff`){let a=this.vertexMap[e];return a||(a=new c.Vertex().columns([`DS`]).data([[n]]).icon_diameter(0),this.vertexMap[e]=a),this.vertices.push(a),a.textbox_shape_colorFill(i).text(r?`${t}\n${r}`:`${t}`).tooltip(r),a.getBBox(!0),a}createEdge(e,t){let n=`${e}->${t}`,r=this.edgeMap[n];return r||(r=new c.Edge().sourceVertex(this.vertexMap[e]).targetVertex(this.vertexMap[t]),this.edgeMap[n]=r),this.edges.push(r),r}createDatasource(e){if(e instanceof DSPicker&&(e=e.selection().datasource()),e instanceof x){let t=`${e.url()}`,n=this.createSubgraph(t,`${t}`),r=`${e.url()}/${e.wuid()}`,i=this.createSubgraph(r,`${e.wuid()}`);this.hierarchy.push({parent:n,child:i});let a=`${r}/${e.resultName()}`,o=this.createVertex(a,e.resultName(),{activity:e});return this.hierarchy.push({parent:i,child:o}),a}else if(e instanceof C){let t=`${e.url()}`,n=this.createSubgraph(t,`${t}`),r=`${t}/${e.logicalFile()}`,i=this.createVertex(r,e.logicalFile(),{activity:e});return this.hierarchy.push({parent:n,child:i}),r}else if(e instanceof RoxieResultRef){let t=`${e.url()}`,n=this.createSubgraph(t,`${t}`),r=e.serviceID(),i=this.createSubgraph(r,e.querySet());this.hierarchy.push({parent:n,child:i});let a=r;this.hierarchy.push({parent:i,child:this.createVertex(a,e.queryID())});let o=`${r}/${e.resultName()}`;return this.hierarchy.push({parent:i,child:this.createVertex(o,e.resultName(),{activity:e})}),this.createEdge(a,o),o}else if(e instanceof k){let t=`${e.service().url()}`,n=this.createSubgraph(t,`${t}`),r=e.serviceID(),i=this.createSubgraph(r,e.service().querySet());this.hierarchy.push({parent:n,child:i});let a=`${r}/${e.service().queryID()}`,o=this.createSubgraph(a,e.service().queryID());this.hierarchy.push({parent:i,child:o});let s=`${a}/${e.resultName()}`;return this.hierarchy.push({parent:o,child:this.createVertex(s,e.resultName(),{activity:e})}),this.createEdge(a,s),s}else if(e instanceof RestResultRef){let t=`${e.url()}`,n=this.createSubgraph(t,`${t}`),r=e.serviceID(),i=this.createSubgraph(r,e.action());this.hierarchy.push({parent:n,child:i});let a=r;this.hierarchy.push({parent:i,child:this.createVertex(a,e.action())});let o=`${r}/${e.resultName()}`;return this.hierarchy.push({parent:i,child:this.createVertex(o,e.resultName(),{activity:e})}),this.createEdge(a,o),o}else if(e instanceof E){let t=`${e.service().url()}`,n=this.createSubgraph(t,`${t}`),r=e.serviceID(),i=`${t}/${e.service().action()}`,a=this.createSubgraph(r,e.service().action());this.hierarchy.push({parent:n,child:a});let o=`${i}/${e.resultName()}`;return this.hierarchy.push({parent:a,child:this.createVertex(o,e.resultName(),{activity:e})}),this.createEdge(i,o),o}else if(e instanceof v){let t=e.hash();return this.createVertex(t,e.label(),{activity:e}),t}else if(e instanceof y){let t=e.id();return this.createVertex(t,e.label(),{activity:e}),t}else{let t=e.hash();return this.createVertex(t,e.label(),{activity:e}),t}}createActivity(e,t,n,r){let i=this.createSubgraph(t.id(),`${t.id()}`,{view:t}),a=null,o=``;if(n.exists()){let e=n.validate();e.length&&(a=`pink`,o=e.map(e=>`${e.source}: ${e.msg}`).join(`
98
+ `))}else a=`lightgrey`;let s=this.createVertex(n.id(),r||`${n.classID()}`,{view:t,activity:n},o,a);return e&&this.createEdge(e,n.id()),this.hierarchy.push({parent:i,child:s}),n.id()}createGraph(){this.hierarchy=[],this.vertices=[],this.edges=[],this._ec.elements().forEach(e=>{this.createDatasource(e.hipiePipeline().datasource())});let e={};for(let t of this._ec.elements()){let n=t.hipiePipeline(),r=this.createDatasource(n.datasource());for(let e of n.activities())r=this.createActivity(r,t,e);let i=t.visualization(),a=i.mappings(),o=this.createActivity(r,t,a,`Mappings`),s=`${i.id()}-sg`,c=this.createSubgraph(s,`Visualization`,{visualization:i});this.hierarchy.push({parent:this.subgraphMap[t.id()],child:c}),this.hierarchy.push({parent:c,child:this.vertexMap[a.id()]});let l=`${i.id()}-viz`,u=this.createVertex(l,i.chartPanel().widget().classID(),{view:t,chartPanel:i.chartPanel()});this.createEdge(o,l),this.hierarchy.push({parent:c,child:u});let d=`${i.id()}-state`,f=this.createVertex(d,`Selection`,{view:t,state:t.state()});this.createEdge(l,d).weight(10).strokeDasharray(`1,5`).text(`updates`),this.createEdge(r,d),this.hierarchy.push({parent:this.subgraphMap[t.id()],child:f}),r=d,e[n.id()]=r}for(let e of this._ec.elements()){let t=e.visualization(),n=this._ec.element(t.secondaryDataviewID());if(n){let e=n.visualization().mappings();this.createEdge(e.id(),`${t.id()}-viz`)}}for(let t of this._ec.elements()){let n=t.hipiePipeline();for(let t of n.updatedByGraph())this.createEdge(e[this._ec.element(t.from).hipiePipeline().id()],t.to.id()).weight(10).strokeDasharray(`1,5`).text(`updates`)}return{vertices:this.vertices,edges:this.edges,hierarchy:this.hierarchy}}},DSTable=class extends u.ChartPanel{_ec;_addButton=new n.Button().faChar(`fa-plus`).tooltip(`Add...`).on(`click`,()=>{let e=this._addButton.element().node(),t=e.getBoundingClientRect();this._contextMenu.open({target:e,currentTarget:e,clientX:t.left,clientY:t.bottom})});_removeButton=new n.Button().faChar(`fa-minus`).tooltip(`Remove...`).enabled(!1).on(`click`,()=>{this.remove()});_cloneButton=new n.Button().faChar(`fa-clone`).tooltip(`Clone...`).enabled(!1).on(`click`,()=>{this._selectedDS2&&(this._selectedDS2 instanceof y?this.add(y.fromDDL(this._selectedDS2.toDDL(),!0)):this._selectedDS2 instanceof v?this.add(v.fromDDL(this._selectedDS2.toDDL(),!0)):this._selectedDS2 instanceof C?this.add(C.fromDDL(this._ec,this._selectedDS2.toDDL(),!0)):this._selectedDS2 instanceof E?this.add(new E(this._ec).service(T.fromDDL(this._ec,this._selectedDS2.service().toDDL(),!0)).resultName(this._selectedDS2.resultName())):this._selectedDS2 instanceof x?this.add(new x(this._ec).wu(S.fromDDL(this._ec,this._selectedDS2.wu().toDDL(),!0)).resultName(this._selectedDS2.resultName())):this._selectedDS2 instanceof k?this.add(new k(this._ec).service(O.fromDDL(this._ec,this._selectedDS2.service().toDDL(),!0)).resultName(this._selectedDS2.resultName())):console.warn(`Unknown datasoure type`))});_addSamples=new n.Button().faChar(`fa-database`).tooltip(`Add Samples`).on(`click`,()=>{text_default(`https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/airports.csv`).then(e=>{this.add(new y().format(`csv`).payload(e))}),text_default(`https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/carriers.csv`).then(e=>{this.add(new y().format(`csv`).payload(e))}),text_default(`https://raw.githubusercontent.com/hpcc-systems/Visualization/candidate-2.x.x/utils/data/data/stats.csv`).then(e=>{this.add(new y().format(`csv`).payload(e))}),this.add(new E(this._ec).service(new T(this._ec).url(`https://cmsapi.pulselive.com/`).action(`rugby/rankings/mru`).requestFields([new w().fieldID(`xxx`),new w().fieldID(`date`)])).resultName(`entries`)),this.add(new x(this._ec).wu(new S(this._ec).url(`http://localhost:8010`).wuid(`W20190802-112509`)).resultName(`Result 1`)),this.add(new C(this._ec).url(`http://localhost:8010`).logicalFile(`progguide::exampledata::peopleaccts`)),this.add(new C(this._ec).url(`http://localhost:8010`).logicalFile(`progguide::exampledata::people`));let e=new O(this._ec).url(`http://localhost:8002`).querySet(`roxie`).queryID(`peopleaccounts`);this.add(new k(this._ec).service(e).resultName(`Accounts`)),this.add(new v().formFields([new _().type(`number`).fieldID(`id`).value(8),new _().fieldID(`first_name`).value(`John`),new _().fieldID(`last_name`).value(`Doe`),new _().fieldID(`gender`).default(`M`),new _().type(`number`).fieldID(`age`)])),this.render()});_dstable=new o.Table;_selectedDS;_selectedDS2;_contextMenu;constructor(e){super(),this._ec=e,this.buttons([this._addButton,this._removeButton,new n.Spacer,this._cloneButton,new n.Spacer,this._addSamples]).widget(this._dstable).columns([`ID`,`Type`,`References`]).on(`click`,(e,t,n)=>{this._selectedDS2=e.__lparam,n&&e.References===0&&e.ID!==`Empty`?this._selectedDS=e.__lparam:delete this._selectedDS,this._removeButton.enabled(this._selectedDS!==void 0).render(),this._cloneButton.enabled(this._selectedDS2!==void 0).render()}),this.initMenu()}initMenu(){let e=new d.CommandRegistry;e.addCommand(`add_wu_result`,{label:`Workunit Result`,execute:()=>{this.add(new x(this._ec))}}),e.addCommand(`add_logicalfile`,{label:`Logical File`,execute:()=>{this.add(new C(this._ec))}}),e.addCommand(`add_roxie`,{label:`Roxie Service`,execute:()=>{this.add(new k(this._ec))}}),e.addCommand(`add_rest`,{label:`Rest`,execute:()=>{this.add(new E(this._ec))}}),e.addCommand(`add_databomb`,{label:`Databomb`,execute:()=>{this.add(new y)}}),e.addCommand(`add_form`,{label:`Form`,execute:()=>{this.add(new v)}}),this._contextMenu=new d.ContextMenu({commands:e}),this._contextMenu.addItem({command:`add_wu_result`,selector:`.common_Button`}),this._contextMenu.addItem({command:`add_logicalfile`,selector:`.common_Button`}),this._contextMenu.addItem({command:`add_roxie`,selector:`.common_Button`}),this._contextMenu.addItem({command:`add_rest`,selector:`.common_Button`}),this._contextMenu.addItem({command:`add_databomb`,selector:`.common_Button`}),this._contextMenu.addItem({command:`add_form`,selector:`.common_Button`})}add(e){this._ec.appendDatasource(e),this.render()}remove(){this._selectedDS&&(this._ec.removeDatasource(this._selectedDS),this.render())}_prevDataID;render(e){let t={};this._ec.elements().forEach(e=>{let n=e.hipiePipeline().datasource();n instanceof DSPicker&&(n=n.datasource()),t[n.id()]===void 0&&(t[n.id()]=0),t[n.id()]++});let n=this._ec.datasources().filter(e=>e.id()!==`Empty`).map(e=>(t[e.id()]===void 0&&(t[e.id()]=0),[e.id(),e.classID(),t[e.id()]||0,e])),r=JSON.stringify(t);return this._prevDataID!==r&&(this._prevDataID=r,this.data(n)),super.render(e)}},DVTable=class extends u.ChartPanel{_ec;_dvtable=new o.Table;constructor(e){super(),this._ec=e,this.titleVisible(!1).widget(this._dvtable).columns([`ID`,`Title`])}_prevDataID;render(e){let t=this._ec.elements().map(e=>[e.id(),e.visualization().title(),e]),n=(0,r.hashSum)(t.map(e=>e[0]));return this._prevDataID!==n&&(this._prevDataID=n,this.data(t)),super.render(e)}},PipelineSelectionButton=class extends n.SelectionButton{_label;label(e){return arguments.length?(this._label=e,this.tooltip(e),this):this._label}_elementErrors=[];errors(e){return arguments.length?(this._elementErrors=e,this.classed(`error`,e.length>0),e.length?this.tooltip(e.map(e=>{let t=e.source.split(`.`);return t.splice(0,1),`${t.join(`.`)}: ${e.msg}`}).join(`
99
+ `)):this.tooltip(this._label),this.render(),this):this._elementErrors}},PipelinePanel=class extends u.ChartPanel{_owner;datasource=new PipelineSelectionButton().faChar(`fa-database`).label(`Datasource`).selected(!0);filter=new PipelineSelectionButton().faChar(`fa-filter`).label(`Filter`);project=new PipelineSelectionButton().faChar(`fa-random`).label(`Project`);groupBy=new PipelineSelectionButton().faChar(`fa-object-group`).label(`Group By`);sort=new PipelineSelectionButton().faChar(`fa-sort-alpha-asc`).label(`Sort`);limit=new PipelineSelectionButton().faChar(`fa-list-ol`).label(`Limit`);mappings=new PipelineSelectionButton().faChar(`fa-random`).label(`Mappings`);chartPanel=new PipelineSelectionButton().faChar(`fa-area-chart`).label(`Visualization`);state=new PipelineSelectionButton().faChar(`fa-check-square-o`).label(`State`);debug=new PipelineSelectionButton().faChar(`fa-bug`).label(`Debug`);all=new PipelineSelectionButton().faChar(`fa-list`).label(`All`);_propEditor=new ee.PropertyEditor().show_header(!1).show_settings(!1).showFields(!1);_buttons=[this.datasource,this.filter,this.project,this.groupBy,this.sort,this.limit,new n.Spacer,this.mappings,this.chartPanel,new n.Spacer,this.state,this.debug,new n.Spacer,this.all];_pipelineButton=this.datasource;_pipelineSelection=new n.SelectionBar().buttons(this._buttons).on(`selected`,e=>{this._pipelineButton=e,this.title(e.label()).render()});constructor(e){super(),this._owner=e,this.buttons([this._pipelineSelection]),this.title(this.datasource.label()),super.widget(this._propEditor),this._propEditor.monitor((e,t,n,r)=>{r!==this._propEditor&&(this.propChanged(e,t,n,r),this.updateState())})}selectionButtons(){return this._pipelineSelection.buttons().filter(e=>e instanceof PipelineSelectionButton)}_propExt;propExt(e){return arguments.length?(this._propExt=e,this):this._propExt}peAsDatasource(){if(this._propExt instanceof Datasource||this._propExt instanceof DSPicker)return this._propExt;if(this._propExt instanceof Element)return this._propExt.hipiePipeline().datasource()}peAsFilter(){if(this._propExt instanceof P)return this._propExt;if(this._propExt instanceof Element)return this._propExt.hipiePipeline().filters()}peAsProject(){if(this._propExt instanceof U)return this._propExt;if(this._propExt instanceof Element)return this._propExt.hipiePipeline().project()}peAsGroupBy(){if(this._propExt instanceof R)return this._propExt;if(this._propExt instanceof Element)return this._propExt.hipiePipeline().groupBy()}peAsSort(){if(this._propExt instanceof K)return this._propExt;if(this._propExt instanceof Element)return this._propExt.hipiePipeline().sort()}peAsLimit(){if(this._propExt instanceof z)return this._propExt;if(this._propExt instanceof Element)return this._propExt.hipiePipeline().limit()}peAsMappings(){if(this._propExt instanceof W)return this._propExt;if(this._propExt instanceof Element)return this._propExt.visualization().mappings();if(this._propExt instanceof Visualization)return this._propExt.mappings()}peAsChartPanel(){if(this._propExt instanceof u.ChartPanel||this._propExt instanceof Visualization)return this._propExt;if(this._propExt instanceof Element)return this._propExt.visualization()}peAsState(){if(this._propExt instanceof State)return this._propExt;if(this._propExt instanceof Element)return this._propExt.state()}selectionButton(){if(this._pipelineButton&&this._pipelineButton.enabled())return this._pipelineButton;for(let e of this.selectionButtons())if(e.enabled())return e.selected(!0),e}_prevPropExt;_prevPipelineButton;update(e,t){super.update(e,t),this.updateState();let n=this.selectionButton();if(this._prevPropExt!==this._propExt||this._prevPipelineButton!==n){if(this._prevPropExt=this._propExt,this._prevPipelineButton=n,this._propExt&&n)switch(n){case this.datasource:this._propEditor.widget(this.peAsDatasource());break;case this.filter:this._propEditor.widget(this.peAsFilter());break;case this.project:this._propEditor.widget(this.peAsProject());break;case this.groupBy:this._propEditor.widget(this.peAsGroupBy());break;case this.sort:this._propEditor.widget(this.peAsSort());break;case this.limit:this._propEditor.widget(this.peAsLimit());break;case this.mappings:this._propEditor.widget(this.peAsMappings());break;case this.chartPanel:this._propEditor.widget(this.peAsChartPanel());break;case this.state:this._propEditor.widget(this.peAsState());break;case this.all:this._propEditor.widget(this._propExt);break}else this._propEditor.widget(void 0);this._owner.loadPreview(this._propEditor.widget())}}updateButtonState(e,t){t.enabled(!!e),t.errors(!!e&&e.validate()||[])}updateState(){this.selectionButtons().forEach(e=>{if(e instanceof PipelineSelectionButton&&this.disableActivities().indexOf(e.label())>=0){this.updateButtonState(void 0,e);return}switch(e){case this.datasource:this.updateButtonState(this.peAsDatasource(),e);break;case this.filter:this.updateButtonState(this.peAsFilter(),e);break;case this.project:this.updateButtonState(this.peAsProject(),e);break;case this.groupBy:this.updateButtonState(this.peAsGroupBy(),e);break;case this.sort:this.updateButtonState(this.peAsSort(),e);break;case this.limit:this.updateButtonState(this.peAsLimit(),e);break;case this.mappings:this.updateButtonState(this.peAsMappings(),e);break;case this.chartPanel:let t=this.peAsChartPanel();e.enabled(!!t);break;case this.state:let n=this.peAsState();e.enabled(!!n);break;case this.debug:e.enabled(!1);break;case this.all:e.enabled(!!this._propExt);break}e.selected()&&this.title(e.enabled()?e.label():``)})}propChanged(e,t,n,r){}};PipelinePanel.prototype._class+=` marshaller_PipelinePanel`;var DDLPreview$1=class extends u.ChartPanel{static{__name(this,`DDLPreview`)}_save=new n.Button().faChar(`fa-save`).tooltip(`Save`).on(`click`,()=>{let e=this.activity();e&&e.fromDDL&&e.fromDDL(this._jsonEditor.json()),this.updateToolbar()});_reset=new n.Button().faChar(`fa-undo`).tooltip(`Reset`).on(`click`,()=>{this._jsonEditor.text(this.jsonText()).lazyRender(),this.updateToolbar()});_jsonEditor=new f.JSONEditor().on(`changes`,e=>{this.updateToolbar()});constructor(){super(),this._titleBar.buttons([this._save,this._reset]),this.widget(this._jsonEditor)}_activity;activity(e){return e===void 0?this._activity:(this._activity!==e&&(this._activity=e,delete this._prevJson),this)}jsonText(){let e=this.activity();return e&&e.toDDL?JSON.stringify(e.toDDL(),void 0,4):``}_prevJson;update(e,t){super.update(e,t);let n=this.jsonText(),r=this._jsonEditor.text();(this._prevJson===void 0||this._prevJson===r)&&this._prevJson!==n&&(this._prevJson=n,this._jsonEditor.text(n)),this.updateToolbar()}updateToolbar(){let e=this.activity(),t=this.jsonText(),n=this._jsonEditor.text();this._save.enabled(e&&e.fromDDL&&t!==n).lazyRender(),this._reset.enabled(t!==n).lazyRender()}},PipelineSplitPanel=class extends d.SplitPanel{_rhsPropsPanel=new PipelinePanel(this).on(`propChanged`,(e,t,n,r)=>{this.propChanged(e,t,n,r)});_previewPanel=new d.TabPanel;_rhsDDLPreview=new DDLPreview$1;_rhsDataPreview=new o.DatasourceTable().pagination(!0);constructor(){super(),this._previewPanel.addWidget(this._rhsDataPreview,`Data`).addWidget(this._rhsDDLPreview,`DDL`),this.addWidget(this._rhsPropsPanel).addWidget(this._previewPanel)}loadDataProps(e){this._rhsPropsPanel.propExt(e).render()}loadPreview(e){e=e instanceof Visualization?e.mappings():e,this._rhsDataPreview.datasource(new DatasourceAdapt(e instanceof Activity?e:void 0)).lazyRender(),this._rhsDDLPreview.activity(e).lazyRender()}refreshPreview(){let e=this._rhsDataPreview.datasource();e?e.exec().then(()=>{this._rhsDataPreview.invalidate().lazyRender(),this._rhsDDLPreview.lazyRender()}):this._rhsDDLPreview.lazyRender()}propChanged(e,t,n,r){}};PipelinePanel.prototype.publish(`disableActivities`,[],`array`,`Disabled pipeline items`),PipelineSplitPanel.prototype.publishProxy(`disableActivities`,`_rhsPropsPanel`);var Q=(0,r.scopedLogger)(`marshaller/dashy`),DDLPreview=class extends u.ChartPanel{_dashy;_save=new n.Button().faChar(`fa-save`).tooltip(`Save`).on(`click`,()=>{let e=JSON.parse(this._jsonEditor.text());this._dashy.importDDL(e),this.updateToolbar()});_reset=new n.Button().faChar(`fa-undo`).tooltip(`Reset`).on(`click`,()=>{this._jsonEditor.text(this._ddl).lazyRender(),this.updateToolbar()});_jsonEditor=new f.JSONEditor().on(`changes`,e=>{this.updateToolbar()});constructor(e){super(),this._dashy=e,this._titleBar.buttons([this._save,this._reset]),this.widget(this._jsonEditor)}_ddl;ddl(e){return this._ddl=JSON.stringify(e,void 0,4),this}_prevJson;update(e,t){super.update(e,t),this._prevJson!==this._ddl&&(this._prevJson=this._ddl,this._jsonEditor.text(this._ddl)),this.updateToolbar()}updateToolbar(){let e=this._jsonEditor.text();this._save.enabled(this._ddl!==e).lazyRender(),this._reset.enabled(this._ddl!==e).lazyRender()}},$=class Dashy extends d.SplitPanel{_elementContainer=new ElementContainer;_lhsSheet=new d.TabPanel;_lhsDashboard=new Z(this._elementContainer).on(`vizActivation`,(e,t)=>{this.focus(this._lhsDashboard,e)}).on(`vizStateChanged`,e=>{for(let t of this._elementContainer.filteredBy(e.id()))this.focus()===t&&this._rhsSplitView.refreshPreview()});_lhsDataviews=new DVTable(this._elementContainer).on(`click`,(e,t,n,r)=>{this.focus(this._lhsDataviews,e.__lparam),this._rhsSplitView.refreshPreview()});_lhsDatasources=new DSTable(this._elementContainer).on(`click`,(e,t,n,r)=>{this.focus(this._lhsDatasources,e.__lparam),this._rhsSplitView.refreshPreview()});_graphAdapter=new GraphAdapter(this._elementContainer);_lhsPipeline=new c.Graph().layout(`Hierarchy`).allowDragging(!1).applyScaleOnLayout(!0).on(`vertex_click`,(e,t,n,r)=>{let i=e.__lparam[0]||{};this.focus(this._lhsPipeline,i.state||i.chartPanel||i.visualization||i.activity||i.view)}).on(`vertex_contextmenu`,(e,t,n,r)=>{});_lhsDebugSheet=new d.TabPanel;_lhsDebugDDLEditor=new DDLPreview(this);_lhsDebugDDLSchema=new f.JSONEditor().json(i.ddl2Schema);_lhsDebugJSEditor=new f.JSEditor;_lhsDebugCloneEC=new ElementContainer;_lhsDebugClone=new Z(this._lhsDebugCloneEC).hideSingleTabs(!0).titleVisible(!1);_lhsDebugDDLv1=new f.JSONEditor;_lhsDebugDDLv2=new f.JSONEditor;_rhsSplitView=new PipelineSplitPanel;_fileOpen;static create(e,t,n,r){return new Promise((i,a)=>{let o=new Dashy().target(e).render(e=>{t?e.importDDL(t,n,r).then(()=>{i(o)}):i(o)})})}constructor(){super(`horizontal`)}elementContainer(){return this._elementContainer}clear(){return this._lhsDebugSheet.removeWidget(this._lhsDebugDDLv1),this._lhsDebugSheet.removeWidget(this._lhsDebugDDLv2),this._elementContainer.clear(),this._graphAdapter.clear(),this.focus(this._lhsDashboard,void 0),this.loadDashboard().then(()=>this._elementContainer.refresh()).then(e=>{})}save(){return this._lhsDashboard.save()}serializeDDL(){return JSON.stringify(this.save())}deserializeDDL(e){return this.restore(JSON.parse(e))}restore(e){return this._lhsSheet.active(this._lhsDashboard),this.clear().then(()=>(this._lhsDashboard.restore(e),this._lhsDataviews.render(),this._lhsDatasources.render(),this._lhsDashboard.renderPromise().then(()=>{let e=this._elementContainer.elements();return e.length&&this._lhsDashboard.activate(e[0]),this._elementContainer.refresh()}).then(()=>{let e=!1;for(let t of this._elementContainer.validate())e=!0,Q.warning(t.elementID+` (`+t.source+`): `+t.msg);e&&this._lhsDashboard.renderPromise()})))}importDDL(e,t,n,r={}){let a=(0,i.isDDL2Schema)(e)?e:(0,i.upgrade)(e,t,n,!0,r),o=this.restore(a);return(0,i.isDDL2Schema)(e)?(this._lhsDebugDDLv2.json(a),this._lhsDebugSheet.addWidget(this._lhsDebugDDLv2,`orig v2`)):(this._lhsDebugDDLv1.json(e),this._lhsDebugDDLv2.json(a),this._lhsDebugSheet.addWidget(this._lhsDebugDDLv1,`v1`).addWidget(this._lhsDebugDDLv2,`v1 -> v2`)),o}activeLHS(){let e=this._lhsSheet.active();return e===this._lhsDebugSheet&&(e=this._lhsDebugSheet.active()),e}activeRHS(){return this._rhsSplitView}_currSelection={};focusAsElement(){let e=this.focus();return e instanceof Element?e:void 0}focus(e,t){return arguments.length?(this._currSelection[e.id()]!==t&&(this._currSelection[e.id()]=t,this.loadRHSSplit()),this):this._currSelection[this.activeLHS().id()]}loadRHSSplit(){this._rhsSplitView.loadDataProps(this.focus())}loadDataviews(){return this.activeLHS()===this._lhsDataviews?this._lhsDataviews.renderPromise():Promise.resolve(void 0)}loadDatasources(){return this.activeLHS()===this._lhsDatasources?this._lhsDatasources.renderPromise():Promise.resolve(void 0)}loadDashboard(){return this.activeLHS()===this._lhsDashboard?(this._elementContainer.validate(),this._lhsDashboard.renderPromise()):Promise.resolve(void 0)}loadGraph(){this._lhsPipeline.data({...this._graphAdapter.createGraph()},!0),this.activeLHS()===this._lhsPipeline&&this._lhsPipeline.lazyRender()}loadDDL(){this._lhsDebugDDLEditor.ddl(this._lhsDashboard.ddl()),this.activeLHS()===this._lhsDebugDDLEditor&&this._lhsDebugDDLEditor.lazyRender()}loadJavaScript(){this._lhsDebugJSEditor.javascript(this._lhsDashboard.javascript()),this.activeLHS()===this._lhsDebugJSEditor&&this._lhsDebugJSEditor.lazyRender()}loadClone(){let e=this.save();this._lhsDebugCloneEC.clear(),this._lhsDebugClone.renderPromise().then(()=>{this._lhsDebugClone.restore(e),this._lhsDebugClone.renderPromise().then(()=>this._lhsDebugCloneEC.refresh()).then(()=>{for(let e of this._lhsDebugCloneEC.validate())Q.warning(e.elementID+` (`+e.source+`): `+e.msg)})})}initMenu(){let e=new d.CommandRegistry;e.addCommand(`dash_add`,{label:`Add View`,execute:()=>{let e=new Element(this._elementContainer);this._elementContainer.append(e),this.loadDashboard().then(()=>{e.refresh().then(()=>{this._lhsDashboard.activate(e)})})}}),e.addCommand(`dash_clear`,{label:`Clear`,execute:()=>{this.clear()}}),e.addCommand(`dash_save`,{label:`Save`,execute:()=>{let e=JSON.stringify(this.save(),null,` `);n.Utility.downloadString(`JSON`,e,`dashy`)}}),e.addCommand(`dash_load`,{label:`Open`,execute:()=>{this._fileOpen.property(`accept`,`.dashy,.json`),this._fileOpen.node().click()}});let t=new d.CommandPalette({commands:e});t.addItem({command:`addWUResult`,category:`Notebook`}),t.addItem({command:`addView`,category:`Notebook`}),t.addItem({command:`remove`,category:`Notebook`}),t.id=`palette`;let r=new d.ContextMenu({commands:e});r.addItem({command:`dash_add`,selector:`#${this._lhsDashboard.id()}`}),r.addItem({command:`dash_clear`,selector:`#${this._lhsDashboard.id()}`}),r.addItem({type:`separator`,selector:`#${this._lhsDashboard.id()}`}),r.addItem({command:`dash_load`,selector:`#${this.id()}`}),r.addItem({command:`dash_save`,selector:`#${this.id()}`}),document.addEventListener(`contextmenu`,e=>{r.open(e)&&e.preventDefault()})}addDatabomb(e,t,n){let r=new y().id(e).format(n).payload(t);this._elementContainer.appendDatasource(r);let i=new Element(this._elementContainer),a=i.hipiePipeline().datasource();a instanceof DSPicker&&a.datasourceID(r.id()),this._elementContainer.append(i),this.loadDashboard().then(()=>{i.refresh().then(()=>{this._lhsDashboard.activate(i)})})}enter(e,t){super.enter(e,t),this.addWidget(this._lhsSheet).addWidget(this._rhsSplitView),this._lhsSheet.addWidget(this._lhsDashboard,`Dashboard`).addWidget(this._lhsDataviews,`Dataviews`).addWidget(this._lhsDatasources,`Datasources`).addWidget(this._lhsPipeline,`Pipeline`).addWidget(this._lhsDebugSheet,`Debug`).on(`childActivation`,e=>{switch(e){case this._lhsDataviews:this.loadRHSSplit();break;case this._lhsDatasources:this.loadRHSSplit();break;case this._lhsDashboard:this.loadRHSSplit();break;case this._lhsPipeline:this.loadRHSSplit(),this.loadGraph();break;case this._lhsDebugSheet:this._lhsDebugSheet.childActivation(this._lhsDebugSheet.active());break}}),this._lhsDebugSheet.addWidget(this._lhsDebugDDLEditor,`v2`).addWidget(this._lhsDebugDDLSchema,`Schema`).addWidget(this._lhsDebugJSEditor,`TS`).addWidget(this._lhsDebugClone,`Clone`).on(`childActivation`,e=>{switch(e){case this._lhsDebugDDLEditor:this.loadRHSSplit(),this.loadDDL();break;case this._lhsDebugJSEditor:this.loadRHSSplit(),this.loadJavaScript();break;case this._lhsDebugClone:this.loadClone();break}}),this.initMenu(),this._rhsSplitView.on(`propChanged`,(e,t,n,r)=>{let i=this.focusAsElement();switch(i?i.refresh().then(()=>{this._rhsSplitView.refreshPreview()}):this._rhsSplitView.refreshPreview(),this.activeLHS()){case this._lhsDashboard:this.loadDashboard();break;case this._lhsDatasources:this._elementContainer.refresh();break;case this._lhsPipeline:this.loadGraph();break;case this._lhsDebugDDLEditor:this.loadDDL();break;case this._lhsDebugClone:this.loadClone();break}});let n=this;this._fileOpen=t.append(`input`).attr(`type`,`file`).property(`accept`,`.dashy,.json`).style(`display`,`none`).on(`change`,function(){let e=this.files[0];for(;e;){let t=new FileReader;t.onload=(function(e){return function(e){try{let t=Array.isArray(e.target.result)?e.target.result[0]:e.target.result,r=JSON.parse(t);n.importDDL(r)}catch(e){alert(`ex when trying to parse json = `+e)}}})(e),t.readAsText(e);break}})}update(e,t){super.update(e,t)}};$.prototype._class+=` composite_Dashy`,$.prototype.publishProxy(`disableActivities`,`_rhsSplitView`),e.Activity=Activity,e.ActivityArray=ActivityArray,e.ActivityPipeline=ActivityPipeline,e.ActivitySelection=ActivitySelection,e.AggregateField=L,e.BUILD_VERSION=h,e.ColumnMapping=j,e.ComputedField=V,e.ComputedMapping=B,e.DDLAdapter=DDLAdapter,e.DDLEditor=DDLEditor,e.DSPicker=DSPicker,e.Dashboard=Z,e.Dashy=$,e.Databomb=y,e.Datasource=Datasource,e.DatasourceAdapt=DatasourceAdapt,e.DatasourceRef=DatasourceRef,e.ESPResult=ESPResult,e.Element=Element,e.ElementContainer=ElementContainer,e.Filters=P,e.Form=v,e.FormField=_,e.GraphAdapter=GraphAdapter,e.GroupBy=R,e.GroupByColumn=F,e.HipiePipeline=HipiePipeline,e.HipieResultRef=HipieResultRef,e.JavaScriptAdapter=JavaScriptAdapter,e.Limit=z,e.LogicalFile=C,e.Mappings=W,e.MultiField=H,e.NullView=NullView,e.PKG_NAME=p,e.PKG_VERSION=m,e.Project=U,e.ProjectBase=ProjectBase,e.RemoteFilter=M,e.RoxieResult=k,e.RoxieResultRef=RoxieResultRef,e.RoxieService=O,e.Sort=K,e.SortColumn=G,e.State=State,e.StaticFilter=N,e.Visualization=Visualization,e.VizChartPanel=VizChartPanel,e.VizPopupPanel=VizPopupPanel,e.VizTypeSet=J,e.WU=S,e.WUResult=x,e.WUResultRef=WUResultRef,e.createProps=createProps,e.emptyDatabomb=b,Object.defineProperty(e,"hookSend",{enumerable:!0,get:function(){return t.hookSend}}),e.rowToFields=rowToFields,e.schemaRow2IField=schemaRow2IField,e.schemaType2IFieldType=schemaType2IFieldType,e.stringify=stringify,e.wsEclSchemaRow2IField=wsEclSchemaRow2IField});
2
100
  //# sourceMappingURL=index.umd.cjs.map
3
- !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.lm-Widget.phosphor_WidgetAdapter.lm-DockPanel-widget.active{border-color:#5589ff;box-shadow:0 -1px #5589ff,1px 1px 2px #0003}.lm-TabBar-tab.lm-mod-current.active{border-color:#5589ff}.lm-TabBar-tab.lm-mod-current.error{background:red;background:linear-gradient(180deg,#ff000080,#fff)}.common_SelectionButton.error{background:red;background:linear-gradient(180deg,#ff000080,#fff0 80%)}body{padding:0;margin:8px;overflow:hidden}#placeholderXXX{width:100%;height:100vh}.graph_Graph .graphVertex>.subgraph .title rect{fill:#dcf1ff;border-bottom-width:0px}.graph_Graph .graphVertex>.subgraph .title text{fill:#000}.graph_Graph .graphVertex>.subgraph rect{fill:none}.graph_Graph .graphVertex>.subgraph.selected rect{stroke:red!important}.graph_Graph .graphVertex .graph_Vertex.selected .common_Shape{stroke:red!important}.graph_Graph .common_Surface .common_Menu{visibility:hidden}.lm-MenuBar{padding-left:5px;background:#fafafa;color:#000000de;border-bottom:1px solid #DDDDDD;font:13px Helvetica,Arial,sans-serif}.lm-MenuBar-menu{transform:translateY(-1px)}.lm-MenuBar-item{padding:4px 8px;border-left:1px solid transparent;border-right:1px solid transparent}.lm-MenuBar-item.lm-mod-active{background:#e5e5e5}.lm-MenuBar.lm-mod-active .lm-MenuBar-item.lm-mod-active{z-index:10001;background:#fff;border-left:1px solid #C0C0C0;border-right:1px solid #C0C0C0;box-shadow:0 0 6px #0003}.lm-Menu{padding:3px 0;background:#fff;color:#000000de;border:1px solid #C0C0C0;font:12px Helvetica,Arial,sans-serif;box-shadow:0 1px 6px #0003}.lm-Menu-item.lm-mod-active{background:#e5e5e5}.lm-Menu-item.lm-mod-disabled{color:#00000040}.lm-Menu-itemIcon{width:21px;padding:4px 2px}.lm-Menu-itemLabel{padding:4px 35px 4px 2px}.lm-Menu-itemMnemonic{text-decoration:underline}.lm-Menu-itemShortcut{padding:4px 0}.lm-Menu-itemSubmenuIcon{width:16px;padding:4px 0}.lm-Menu-item[data-type=separator]>div{padding:0;height:9px}.lm-Menu-item[data-type=separator]>div:after{content:"";display:block;position:relative;top:4px;border-top:1px solid #DDDDDD}.lm-Menu-itemIcon:before,.lm-Menu-itemSubmenuIcon:before{font-family:FontAwesome}.lm-Menu-item.lm-mod-toggled>.lm-Menu-itemIcon:before{content:""}.lm-Menu-item[data-type=submenu]>.lm-Menu-itemSubmenuIcon:before{content:""}.lm-CommandPalette{font-family:sans-serif;background:#f5f5f5}.lm-CommandPalette-search{padding:8px}.lm-CommandPalette-wrapper{padding:4px 6px;background:#fff;border:1px solid #E0E0E0}.lm-CommandPalette-input{width:100%;border:none;outline:none;font-size:16px}.lm-CommandPalette-header{padding:4px;color:#757575;font-size:12px;font-weight:600;background:#e1e1e1;cursor:pointer}.lm-CommandPalette-header:hover:before{content:"…";float:right;margin-right:4px}.lm-CommandPalette-header>mark{background-color:transparent;font-weight:700}.lm-CommandPalette-item{padding:4px 8px;color:#757575;font-size:13px;font-weight:500}.lm-CommandPalette-emptyMessage{padding:4px;color:#757575;font-size:12px;font-weight:600;text-align:center}.lm-CommandPalette-item.lm-mod-disabled{color:#00000040}.lm-CommandPalette-item.lm-mod-active{background:#7fdbff}.lm-CommandPalette-item:hover:not(.lm-mod-active):not(.lm-mod-disabled){background:#e5e5e5}.lm-CommandPalette-itemLabel>mark{background-color:transparent;font-weight:700}.lm-CommandPalette-item.lm-mod-disabled mark{color:#0006}.lm-CommandPalette-itemCaption{color:#9e9e9e;font-size:11px;font-weight:400}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
101
+ (function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`.lm-Widget.phosphor_WidgetAdapter.lm-DockPanel-widget.active{border-color:#5589ff;box-shadow:0 -1px #5589ff,1px 1px 2px #0003}.lm-TabBar-tab.lm-mod-current.active{border-color:#5589ff}.lm-TabBar-tab.lm-mod-current.error{background:linear-gradient(#ff000080 0%,#fff 100%)}.common_SelectionButton.error{background:linear-gradient(#ff000080 0%,#fff0 80%)}body{margin:8px;padding:0;overflow:hidden}#placeholderXXX{width:100%;height:100vh}.graph_Graph .graphVertex>.subgraph .title rect{fill:#dcf1ff;border-bottom-width:0}.graph_Graph .graphVertex>.subgraph .title text{fill:#000}.graph_Graph .graphVertex>.subgraph rect{fill:none}.graph_Graph .graphVertex>.subgraph.selected rect,.graph_Graph .graphVertex .graph_Vertex.selected .common_Shape{stroke:red!important}.graph_Graph .common_Surface .common_Menu{visibility:hidden}.lm-MenuBar{color:#000000de;background:#fafafa;border-bottom:1px solid #ddd;padding-left:5px;font:13px Helvetica,Arial,sans-serif}.lm-MenuBar-menu{transform:translateY(-1px)}.lm-MenuBar-item{border-left:1px solid #0000;border-right:1px solid #0000;padding:4px 8px}.lm-MenuBar-item.lm-mod-active{background:#e5e5e5}.lm-MenuBar.lm-mod-active .lm-MenuBar-item.lm-mod-active{z-index:10001;background:#fff;border-left:1px solid silver;border-right:1px solid silver;box-shadow:0 0 6px #0003}.lm-Menu{color:#000000de;background:#fff;border:1px solid silver;padding:3px 0;font:12px Helvetica,Arial,sans-serif;box-shadow:0 1px 6px #0003}.lm-Menu-item.lm-mod-active{background:#e5e5e5}.lm-Menu-item.lm-mod-disabled{color:#00000040}.lm-Menu-itemIcon{width:21px;padding:4px 2px}.lm-Menu-itemLabel{padding:4px 35px 4px 2px}.lm-Menu-itemMnemonic{text-decoration:underline}.lm-Menu-itemShortcut{padding:4px 0}.lm-Menu-itemSubmenuIcon{width:16px;padding:4px 0}.lm-Menu-item[data-type=separator]>div{height:9px;padding:0}.lm-Menu-item[data-type=separator]>div:after{content:"";border-top:1px solid #ddd;display:block;position:relative;top:4px}.lm-Menu-itemIcon:before,.lm-Menu-itemSubmenuIcon:before{font-family:FontAwesome}.lm-Menu-item.lm-mod-toggled>.lm-Menu-itemIcon:before{content:""}.lm-Menu-item[data-type=submenu]>.lm-Menu-itemSubmenuIcon:before{content:""}.lm-CommandPalette{background:#f5f5f5;font-family:sans-serif}.lm-CommandPalette-search{padding:8px}.lm-CommandPalette-wrapper{background:#fff;border:1px solid #e0e0e0;padding:4px 6px}.lm-CommandPalette-input{border:none;outline:none;width:100%;font-size:16px}.lm-CommandPalette-header{color:#757575;cursor:pointer;background:#e1e1e1;padding:4px;font-size:12px;font-weight:600}.lm-CommandPalette-header:hover:before{content:"…";float:right;margin-right:4px}.lm-CommandPalette-header>mark{background-color:#0000;font-weight:700}.lm-CommandPalette-item{color:#757575;padding:4px 8px;font-size:13px;font-weight:500}.lm-CommandPalette-emptyMessage{color:#757575;text-align:center;padding:4px;font-size:12px;font-weight:600}.lm-CommandPalette-item.lm-mod-disabled{color:#00000040}.lm-CommandPalette-item.lm-mod-active{background:#7fdbff}.lm-CommandPalette-item:hover:not(.lm-mod-active):not(.lm-mod-disabled){background:#e5e5e5}.lm-CommandPalette-itemLabel>mark{background-color:#0000;font-weight:700}.lm-CommandPalette-item.lm-mod-disabled mark{color:#0006}.lm-CommandPalette-itemCaption{color:#9e9e9e;font-size:11px;font-weight:400}/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();