@datagrok/compute 1.4.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/files/exp_data.csv +21601 -0
- package/package.json +2 -2
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var compute;(()=>{"use strict";var t={903:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".pipeline-view .d4-ribbon-name.selected {\n color: #104161;\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/pipeline-view.css"],names:[],mappings:"AAAA;EACE,cAAc;AAChB;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".pipeline-view .d4-ribbon-name.selected {\n color: #104161;\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n"],sourceRoot:""}]);const a=r},751:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".ui-input-root > input.ui-input-editor.disabled:focus {\n outline: none;\n border-bottom: 1px solid var(--grey-2)!important;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,aAAa;IACb,gDAAgD;AACpD",sourcesContent:[".ui-input-root > input.ui-input-editor.disabled:focus {\n outline: none;\n border-bottom: 1px solid var(--grey-2)!important;\n}\n"],sourceRoot:""}]);const a=r},669:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".cv-drop-area {\n position: relative;\n}\n\n.ui-form .cv-drop-area .icon {\n\tpadding-top: 10px;\n}\n\n.ui-form-condensed .cv-drop-area .icon {\n\tpadding-top: 0px;\n position: absolute;\n top: 35px;\n right: 10px;\n}\n\n.cv-drop-area .default {\n color: var(--grey-2);\n}\n\n.cv-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.cv-drop-area .error {\n color: var(--red-3);\n}\n\n.cv-drop-area .success {\n color: var(--grey-6);\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/file-input.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;CACC,iBAAiB;AAClB;;AAEA;CACC,gBAAgB;EACf,kBAAkB;EAClB,SAAS;EACT,WAAW;AACb;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,gCAAgC;EAChC,gCAAgC;EAChC,oBAAoB;AACtB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".cv-drop-area {\n position: relative;\n}\n\n.ui-form .cv-drop-area .icon {\n\tpadding-top: 10px;\n}\n\n.ui-form-condensed .cv-drop-area .icon {\n\tpadding-top: 0px;\n position: absolute;\n top: 35px;\n right: 10px;\n}\n\n.cv-drop-area .default {\n color: var(--grey-2);\n}\n\n.cv-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.cv-drop-area .error {\n color: var(--red-3);\n}\n\n.cv-drop-area .success {\n color: var(--grey-6);\n}\n"],sourceRoot:""}]);const a=r},380:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,'.no-elements-label {\n margin: 8px;\n}\n\n.arrow-box {\n position: relative;\n}\n\n.arrow-box:before {\n left: -6px;\n top: 55px;\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n background-color: white;\n\n transform-origin: center;\n transform: rotate(-135deg);\n box-shadow: -4px 4px 0px 4.5px white, #4d5261 0px 0px 5px;;\n\n border: 5px solid black;\n border-color: transparent transparent #FFFFFF #FFFFFF;\n\n margin-top: -21px;\n}\n',"",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/history-input.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,oBAAoB;IACpB,uBAAuB;;IAEvB,wBAAwB;IACxB,0BAA0B;IAC1B,yDAAyD;;IAEzD,uBAAuB;IACvB,qDAAqD;;IAErD,iBAAiB;AACrB",sourcesContent:['.no-elements-label {\n margin: 8px;\n}\n\n.arrow-box {\n position: relative;\n}\n\n.arrow-box:before {\n left: -6px;\n top: 55px;\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n background-color: white;\n\n transform-origin: center;\n transform: rotate(-135deg);\n box-shadow: -4px 4px 0px 4.5px white, #4d5261 0px 0px 5px;;\n\n border: 5px solid black;\n border-color: transparent transparent #FFFFFF #FFFFFF;\n\n margin-top: -21px;\n}\n'],sourceRoot:""}]);const a=r},778:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".hp-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px 12px 5px 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n}\n\n.hp-funccall-card-def-icon {\n display: flex;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-def-icon {\n display: none;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card-def-icon {\n margin: 5px;\n}\n\n.hp-funccall-card-icon {\n margin: 5px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/history-panel.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,eAAe;AACnB;;AAEA;IACI,eAAe;IACf,yBAAyB;IACzB,8BAA8B;AAClC;;AAEA;IACI,+BAA+B;AACnC;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,6BAA6B;IAC7B,gBAAgB;AACpB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;IAClB,oBAAoB;AACxB;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;AACpB;;AAEA;IACI,oBAAoB;IACpB,YAAY;AAChB",sourcesContent:[".hp-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px 12px 5px 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n}\n\n.hp-funccall-card-def-icon {\n display: flex;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-def-icon {\n display: none;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card-def-icon {\n margin: 5px;\n}\n\n.hp-funccall-card-icon {\n margin: 5px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n"],sourceRoot:""}]);const a=r},433:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,'.model-catalog-view .d4-gallery-card.entity-model i {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}',"",{version:3,sources:["webpack://./src/css/model-card.css"],names:[],mappings:"AAAA;IACI,YAAY;IACZ,WAAW;IACX,iBAAiB;IACjB,cAAc;AAClB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;AACvB;;AAEA;IACI,cAAc;IACd,mBAAmB;IACnB,aAAa;IACb,SAAS;IACT,YAAY;AAChB;;AAEA;IACI,6BAA6B;AACjC;;AAEA;IACI,WAAW;IACX,YAAY;IACZ,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;AACpB;;AAEA;IACI,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,aAAa;IACb,cAAc;AAClB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,mBAAmB;IACnB,qBAAqB;IACrB,+BAA+B;IAC/B,kBAAkB;IAClB,sBAAsB;IACtB,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;IAClB,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,aAAa;IACb,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,oBAAoB;IACpB,eAAe;AACnB;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,mBAAmB;AACvB",sourcesContent:['.model-catalog-view .d4-gallery-card.entity-model i {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}'],sourceRoot:""}]);const a=r},352:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var d=0;d<t.length;d++){var u=[].concat(t[d]);i&&r[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),e.push(u))}},e}},864:t=>{t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},701:t=>{var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],d=i.base?l[0]+i.base:l[0],u=s[d]||0,c="".concat(d," ").concat(u);s[d]=u+1;var p=n(c),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var f=o(h,i);i.byIndex=a,e.splice(a,0,{identifier:c,updater:f,references:1})}r.push(c)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),d=0;d<s.length;d++){var u=n(s[d]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}s=l}}},80:t=>{var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},182:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},850:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},236:t=>{t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},213:t=>{t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i](s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{n.r(i),n.d(i,{OutliersSelection:()=>Wt,PipelineStepEditor:()=>Ut,RichFunctionViewEditor:()=>$t,_package:()=>Dt,autostart:()=>qt,functionParametersGrid:()=>Ht,hof:()=>Gt,hof2:()=>Yt,importScriptGenerator:()=>Nt,init:()=>Xt,modelCatalog:()=>Jt,openModelFromFuncall:()=>jt,renderRestPanel:()=>zt});const t=grok,e=ui,o=DG,s=wu;var r=n.n(s);let a;class l extends o.CustomCardView{constructor(){super({dataSource:t.dapi.functions,permanentFilter:"#model"}),this.root.classList.add("model-catalog-view"),this.meta=new u,this.name="Models",this.permanentFilter="#model",this.renderMode=o.RENDER_MODE.BRIEF,this.objectType="Func",this.categoryFilters={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process",tag:"Tags"},this.filters={All:"",Favorites:"starredBy = @current","Used by me":"usedBy = @current"},this.hierarchy=["options.department","options.HL_process","options.process"],this.hierarchyProperties={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process"},this.showTree=!0,this.initRibbon(),this.initMenu(),this.currentCall=t.functions.getCurrentCall(),null==a&&null==window.localStorage.getItem("ModelCatalogShowProperties")&&(a=t.events.onCurrentObjectChanged.subscribe((e=>{(new u).isApplicable(e.sender)&&(t.shell.windows.showProperties=!0,window.localStorage.setItem("ModelCatalogShowProperties","false"),a.unsubscribe())})))}initRibbon(){this.setRibbonPanels([[e.icons.sync((()=>this.refresh()))]])}initMenu(){this.ribbonMenu.group("Help").item("Compute Engine",(()=>window.open("https://github.com/datagrok-ai/public/tree/master/packages/Compute","_blank"))).item("Developing Models",(()=>window.open("https://datagrok.ai/help/compute/scripting","_blank"))).endGroup()}setCurrentModel(t){let n=o.View.forObject(t),i=this.root.querySelector(".grok-gallery-grid");e.empty(i),i.appendChild(n.root)}}var d=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class u extends o.ObjectHandler{get type(){return"Model"}getById(e){return d(this,void 0,void 0,(function*(){return yield t.dapi.functions.find(e)}))}refresh(t){return d(this,void 0,void 0,(function*(){return yield this.getById(t.id)}))}getLanguageIcon(t){return"grok"==t?e.iconSvg("project"):e.iconImage("script",`/images/entities/${t}.png`)}isApplicable(t){return t instanceof o.Func&&t.hasTag("model")}getVideoBackgroundUrl(t){let e=t.options["video-preview"];if(null==e)return"";if(e.startsWith("http://")||e.startsWith("https://"))return e;if(t instanceof o.Script)return null!=t.options.icon?`${t.options.icon.substring(0,t.options.icon.lastIndexOf("/"))}/${e}`:"";let n=t.package.getIconUrl();return n=n.substring(0,n.lastIndexOf("/")),`${n}/${e}`}renderIcon(t,n=null){if(null!=t.options.icon&&(t.options.icon.startsWith("http://")||t.options.icon.startsWith("https://")))return e.iconImage("model-icon",t.options.icon);if(t instanceof o.Script)return this.getLanguageIcon(t.language);let i=(t=o.Func.find({package:t.package.name,name:t.name})[0]).package.getIconUrl();if(null!=t.options.icon){let e=i.split("/");e.pop(),e.push(t.options.icon),i=e.join("/")}return e.iconImage(t.package.name,i)}renderMarkup(t){let n=e.span([this.renderIcon(t),e.label(t.friendlyName)]);return n.ondblclick=e=>{u.openModel(t)},n}renderPreview(e){const n=Object.create(null,{renderPreview:{get:()=>super.renderPreview}});var i;return d(this,void 0,void 0,(function*(){const s=null!==(i=e.options.editor)&&void 0!==i?i:"Compute:RichFunctionEditor",r=yield t.functions.find(s);if(null!==r&&r instanceof o.Func){console.log(r);const t=r.prepare({call:e.prepare()});yield t.call(!1,void 0,{processed:!0});const n=t.getOutputParamValue();if(n instanceof o.View)return n}return n.renderPreview.call(this,e)}))}renderProperties(t){const n=e.accordion("ComputeModel");n.context=t;let i=e.div([e.span([this.renderIcon(t),e.label(t.friendlyName),e.contextActions(t),e.star(t.id)])]);if(n.addTitle(i),null!=t.description&&i.appendChild(e.div([e.markdown(t.description)],"model-catalog-description")),i.appendChild(e.tags(t)),null!=t.options["dev.status"]&&i.appendChild(e.tableFromMap({Status:t.options["dev.status"]})),null!=t.options.video||null!=t.options.education){let i=e.link("Education materials",t.options.education);e.setDisplay(i,null!=t.options.education);let o=e.div(e.icons.play((()=>{window.open(t.options.video,"_blank")})),"model-catalog-video");e.setDisplay(o,null!=t.options.video),o.style.backgroundImage=`url('${this.getVideoBackgroundUrl(t)}')`,n.addPane("Documentation",(()=>e.divV([i,o],{style:{lineHeight:"150%"}})),!0)}return n.end(),n.root}renderDetails(t){let n=e.markdown(`**Status:** ${t.options["dev.status"]}`);return e.setDisplay(n,null!=t.options["dev.status"]),e.divV([e.markdown(`**Description: ** ${t.description}`),n,e.markdown("**Tags:**"),e.tags(t),e.markdown("**Documentation:**")],{style:{lineHeight:"150%"}})}renderTooltip(t){let n=this.renderMarkup(t);n.classList.add("d4-link-label");let i=e.bind(t,e.divV([e.h2(n),e.divV([e.divText(t.description,"ui-description")],{style:{lineHeight:"150%"}})]));return i.ondblclick=e=>{u.openModel(t)},i}renderCard(t,n){let i=this.renderMarkup(t);i.classList.add("d4-link-label");let o=e.bind(t,e.h2(i));return o.ondblclick=e=>{u.openModel(t)},o}static getModelCatalogView(){let e=this.findModelCatalogView();if(null==e){let e=o.Func.find({package:"Compute",name:"ModelCatalog"})[0].prepare(),n=new l;n.name="Models",n.parentCall=e,t.shell.addView(n)}return e=this.findModelCatalogView(),e}static findModelCatalogView(){return r()(t.shell.views).find((t=>{var e;return"modelCatalog"==(null===(e=t.parentCall)||void 0===e?void 0:e.func.name)}))}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static bindModel(t){let e=u.getModelCatalogView();if(t.aux.showOnTaskBar=!1,null!=e){let n=e.parentCall;null!=n&&(n.aux.view=e,t.parentCall=n)}}init(){setTimeout((()=>{t.functions.onBeforeRunAction.subscribe((t=>{(t.func.hasTag("model")||t.func.hasTag("model-editor"))&&u.bindModel(t)}))}))}}class c extends o.JsViewer{constructor(){super()}onFrameAttached(t){this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0)return void(this.root.innerHTML="");const t=this.dataFrame,n="isOutlier",i="Rationale",s="Count",r="isConfirmed";t.columns.byName(n)||t.columns.add(o.Column.fromBitSet(n,o.BitSet.create(t.rowCount,(()=>!1)))),t.columns.byName(i)||t.columns.add(o.Column.fromStrings(i,Array.from({length:t.rowCount},(()=>""))));const a=()=>o.DataFrame.fromColumns([o.Column.fromStrings(i,[]),o.Column.fromInt32Array(s,new Int32Array([])),o.Column.fromStrings("Actions",[]),o.Column.fromBitSet(r,o.BitSet.create(0,(()=>!1)))]),l=o.Viewer.grid(a());l.root.style.width="100%",l.root.style.minWidth="230px",l.columns.setVisible([i,s,"Actions"]),l.onCellPrepare((s=>{var a,d,u;s.isTableCell&&("Actions"===s.gridColumn.name&&(s.gridColumn.cellType="html",s.style.element=e.divH([...(null===(a=s.grid.dataFrame)||void 0===a?void 0:a.get(r,s.gridRow))?[(u=null===(d=s.grid.dataFrame)||void 0===d?void 0:d.get(i,s.gridRow),e.div(e.icons.delete((()=>{for(let e=0;e<t.rowCount;e++)t.columns.byName(i).get(e)===u&&(t.columns.byName(i).set(e,"",!1),t.columns.byName(n).set(e,!1,!1));t.fireValuesChanged()}),"Remove the outliers group"),{style:{"text-align":"center",margin:"6px"}}))]:[e.div(e.iconFA("check",(()=>{var e,s;if(!l.dataFrame)return;null===(e=t.col(n))||void 0===e||e.markers.assign("true",o.MARKER_TYPE.OUTLIER);const r=null===(s=l.dataFrame)||void 0===s?void 0:s.cell(l.dataFrame.rowCount-1,i).value;t.selection.getSelectedIndexes().forEach((e=>{t.col(n).set(e,!0,!1),t.col(i).set(e,r,!1)})),t.selection.setAll(!1),t.fireValuesChanged()}),"Confirm the outliers"),{style:{"text-align":"center",margin:"6px"}}),e.div(e.iconFA("times",(()=>{l.dataFrame&&(l.dataFrame.rows.removeAt(l.dataFrame.rowCount-1),t.selection.setAll(!1))}),"Cancel the outliers"),{style:{"text-align":"center",margin:"6px"}})]])))})),l.onCellValueEdited.subscribe((e=>{var n,o;if(!l.dataFrame||e.gridColumn.name!==i)return;if(!l.dataFrame.columns.byName(r).get(e.gridRow))return;const s=new Set;for(let t=0;t<(null===(n=l.dataFrame)||void 0===n?void 0:n.rowCount);t++){const e=null===(o=l.dataFrame)||void 0===o?void 0:o.columns.byName(i).get(t);s.add(e)}for(let n=0;n<t.rowCount;n++){const o=t.columns.byName(i).get(n);""==o||s.has(o)||t.columns.byName(i).set(n,e.cell.value)}}));const d=()=>{if(t.columns.byName(i))for(let e=0;e<t.rowCount;e++)t.columns.byName(n).get(e)?""===t.columns.byName(i).get(e)&&t.columns.byName(i).set(e,"Manual",!1):""!==t.columns.byName(i).get(e)&&t.columns.byName(i).set(e,"",!1);const e={};if(t.columns.byName(i))for(let n=0;n<t.rowCount;n++){const o=t.columns.byName(i).get(n),s=e[o];""!=o&&(s?e[o]++:e[o]=1)}l.dataFrame=a(),l.columns.setVisible([i,s,"Actions"]),Object.keys(e).map((t=>{var n;null===(n=l.dataFrame)||void 0===n||n.rows.addNew([t,e[t],"",!0])}))};t.onDataChanged.subscribe(d),t.onSelectionChanged.subscribe((()=>{if(l.dataFrame&&t.selection.trueCount)if(l.dataFrame.columns.byName(r).toList().some((t=>!1===t)))l.dataFrame.set(s,l.dataFrame.rowCount-1,t.selection.trueCount);else{const e=l.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);l.dataFrame.currentCell=l.dataFrame.cell(e.idx,i)}})),t.selection.setAll(!1),d(),this.root.innerHTML="",this.root.appendChild(e.divV([e.divV([l.root],{style:{height:"75%"}})],{style:{height:"100%"}}))}}const p=rxjs,h={barchart:o.VIEWER.BAR_CHART,boxplot:o.VIEWER.BOX_PLOT,calendar:o.VIEWER.CALENDAR,corrplot:o.VIEWER.CORR_PLOT,densityplot:o.VIEWER.DENSITY_PLOT,filters:o.VIEWER.FILTERS,form:o.VIEWER.FORM,globe:o.VIEWER.GLOBE,googlemap:o.VIEWER.GOOGLE_MAP,grid:o.VIEWER.GRID,heatmap:o.VIEWER.HEAT_MAP,histogram:o.VIEWER.HISTOGRAM,linechart:o.VIEWER.LINE_CHART,markup:o.VIEWER.MARKUP,matrixplot:o.VIEWER.MATRIX_PLOT,networkdiagram:o.VIEWER.NETWORK_DIAGRAM,pcplot:o.VIEWER.PC_PLOT,piechart:o.VIEWER.PIE_CHART,scatterplot:o.VIEWER.SCATTER_PLOT,"3dscatterplot":o.VIEWER.SCATTER_PLOT_3D,shapemap:o.VIEWER.SHAPE_MAP,statistics:o.VIEWER.STATISTICS,tileviewer:o.VIEWER.TILE_VIEWER,timelines:o.VIEWER.TIMELINES,treemap:o.VIEWER.TREE_MAP,trellisplot:o.VIEWER.TRELLIS_PLOT,wordcloud:o.VIEWER.WORD_CLOUD},f="JsCardView",m="viewer";var v;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(v||(v={}));const g="experimental",y=(t,e,n)=>n===v.INPUT?t.inputs[e]instanceof o.DataFrame?t.inputs[e]:t.inputs[e].dataFrame:t.outputs[e]instanceof o.DataFrame?t.outputs[e]:t.outputs[e].dataFrame,b=t=>t.options.getRealData,A=t=>{const e=t.options[m];return void 0!==e?{name:t.name,config:JSON.parse(e,((t,e)=>"true"===e||"false"!==e&&("type"===t&&h[e]||e)))}:{name:t.name,config:[]}};var C=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const w=t=>{switch(t){case"Today":return"started > -1d";case"Yesterday":return"started > -2d and started < -1d";case"Any time":return"";case"Last year":return"started > -2y and started < -1y";case"This year":return"started > -1y";case"Last month":return"started > -2m and started < -1m";case"This month":return"started > -1m";case"Last week":return"started > -2w and started < -1w";case"This week":return"started > -1w"}};var x;!function(e){const n={};e.loadChildRuns=function(e){var i;return C(this,void 0,void 0,(function*(){const o=yield t.dapi.functions.calls.allPackageVersions().find(e),s=o.func.id,r=null!==(i=n[s])&&void 0!==i?i:yield t.dapi.functions.allPackageVersions().find(s);n[s]||(n[s]=r),o.func=r,o.options.isHistorical=!0;const a=yield t.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${e}"`).list();return yield Promise.all(a.map((e=>C(this,void 0,void 0,(function*(){var i;const o=e.func.id,s=null!==(i=n[o])&&void 0!==i?i:yield t.dapi.functions.allPackageVersions().find(o);n[o]||(n[o]=s),e.func=s}))))),{parentRun:o,childRuns:a}}))},e.loadRun=function(e,i=!1){var s;return C(this,void 0,void 0,(function*(){const a=yield t.dapi.functions.calls.allPackageVersions().include("inputs, outputs, session.user").find(e),l=a.func.id,d=null!==(s=n[l])&&void 0!==s?s:yield t.dapi.functions.allPackageVersions().find(l);if(n[l]||(n[l]=d),a.func=d,a.options.isHistorical=!0,!i){const e=r()(a.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of e)a.outputs[n.name]=yield t.dapi.tables.getTable(a.outputs[n.name]);const n=r()(a.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const e of n)a.inputs[e.name]=yield t.dapi.tables.getTable(a.inputs[e.name])}return a}))},e.saveRun=function(e){return C(this,void 0,void 0,(function*(){const n=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)yield t.dapi.tables.uploadDataFrame(y(e,i.name,v.OUTPUT));const i=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of i)yield t.dapi.tables.uploadDataFrame(y(e,n.name,v.INPUT));return yield t.dapi.functions.calls.allPackageVersions().save(e)}))},e.deleteRun=function(e){return C(this,void 0,void 0,(function*(){yield t.dapi.functions.calls.allPackageVersions().delete(e)}))},e.pullRuns=function(e,n={},i={}){return C(this,void 0,void 0,(function*(){let o=`func.id="${e}"`;return o+=n.author?` and session.user.id="${n.author.id}"`:"",o+=n.date?w(n.date):"",t.dapi.functions.calls.allPackageVersions().filter(o).include("session.user, options").list(i)}))},e.pullRunsByName=function(e,i=[],s={},a=[]){var l;return C(this,void 0,void 0,(function*(){let d="";for(const t of i){const e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(w(t.date)),t.isShared&&e.push('options.isShared="true"'),t.text&&e.push(`((options.title like "${t.text}") or (options.annotation like "${t.text}"))`);const n=e.join(" and ");""!==n&&(d+=""===d?`(${n})`:` or (${n})`)}""!==d&&(d=` and (${d})`);const u=yield t.dapi.functions.calls.allPackageVersions().filter(`func.name="${e}"${d}`).include(`${a.join(",")}`).list(s);for(const e of u){const i=e.func.id,o=null!==(l=n[i])&&void 0!==l?l:yield t.dapi.functions.allPackageVersions().find(i);n[i]||(n[i]=o),e.func=o}if(a.includes("inputs")||a.includes("func.params"))for(const e of u){const n=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.inputs[i.name]=yield t.dapi.tables.getTable(e.inputs[i.name])}if(a.includes("outputs")||a.includes("func.params"))for(const e of u){const n=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=yield t.dapi.tables.getTable(e.outputs[i.name])}return u}))}}(x||(x={}));const I=$;var R=n.n(I);const E=ExcelJS;var T,F=n.n(E),S=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.isSheetExist=(t,e)=>n=>S(this,void 0,void 0,(function*(){const i=n.worksheets.find((e=>e.name===t));return i?{isValid:!0,chainedFuncs:e,result:i}:{isValid:!1,caption:`Sheet named '${t}' is not found`,content:`Sheet name should be exactly \`${t}\` to be parsed.\n\n\nPlease double-check:\n- No extra spaces are in the sheet name\n- Capitalization is the same as in the template\n\n\n${n.worksheets.length>0?`Found sheets: \`${n.worksheets.map((t=>t.name)).join("`,`")}\``:"No columns have found."}\n `}})),t.isColumnExist=(t,e)=>n=>S(this,void 0,void 0,(function*(){const i=n.getRow(1).values;return i.includes(t)?{isValid:!0,chainedFuncs:e}:{isValid:!1,caption:`No column "${t}" in "${n.name}" sheet`,content:`Column name should be exactly \`${t}\` to be parsed.\n\n\nPlease double-check:\n- Column names are in the first row of the sheet\n- No extra spaces are in the cell\n- Capitalization is the same as in the template\n\n\n${i.length>0?`Found columns: \`${i.filter((t=>""!==t)).join("`,`")}\``:"No columns have found."}\n `}})),t.isExcelParsed=t=>e=>S(this,void 0,void 0,(function*(){return(new(F().Workbook)).xlsx.load(yield e.arrayBuffer()).then((e=>S(this,void 0,void 0,(function*(){return{isValid:!0,chainedFuncs:t,result:e}})))).catch((()=>({isValid:!1,caption:"File is failed to parse",content:"Please make sure:\n- XLSX format is used (not XLS or XLSM)\n- File should not be corrupted\n\n\nXLS could be converted to XLSX using Excel's export functionality. \n\nIf the file is corrupted, it will not open in Excel.\n "})))}))}(T||(T={}));var P=n(701),B=n.n(P),k=n(236),O=n.n(k),V=n(80),M=n.n(V),_=n(850),L=n.n(_),D=n(182),j=n.n(D),N=n(213),W=n.n(N),U=n(669),H={};H.styleTagTransform=W(),H.setAttributes=L(),H.insert=M().bind(null,"head"),H.domAPI=O(),H.insertStyleElement=j(),B()(U.Z,H),U.Z&&U.Z.locals&&U.Z.locals;var G=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const Y="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class z{constructor(t="Drag-n-drop here",n=null,i=null,s=Y){this.initialText=t,this.initialValue=n,this.onValueChanged=i,this.fileType=s,this.uploadedFile$=new p.Subject,this.onFileUploaded=new p.Subject,this.root=e.div(),this.validation=new class{constructor(t=[]){this.validators=t}validate(t){return S(this,void 0,void 0,(function*(){const n=[],i=(t,e)=>S(this,void 0,void 0,(function*(){for(const o of t){const t=yield o(e);t.isValid?t.chainedFuncs&&(yield i(t.chainedFuncs,t.result)):n.push(t)}}));for(const e of this.validators){const o=yield e(t);o.isValid?o.chainedFuncs&&(yield i(o.chainedFuncs,o.result)):n.push(o)}if(0==n.length)return!0;const s=new o.Wizard({title:"Data validation failed"});n.forEach((t=>{s.page({caption:t.caption,root:t.content instanceof HTMLElement?t.content:e.markdown(t.content)})})),s.onOK((()=>{}));const r=s.getButton("CANCEL"),a=s.getButton("<<"),l=s.getButton(">>"),d=s.getButton("OK"),u=s.pages.length,c=e.divText("1/"+u);return c.style.position="absolute",c.style.left="12px",c.style.color="var(--grey-5)",s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",R()(s.root).find(".d4-command-bar").append(c),R()(a).html("BACK"),R()(l).html("NEXT"),R()(d).addClass("disabled"),r.style.display="none",a.addEventListener("click",(()=>{const t=s.pageIndex+1,e=s.pages.length;s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",s.completable||R()(d).addClass("disabled"),c.textContent=t+"/"+e})),l.addEventListener("click",(()=>{const t=s.pageIndex+1,e=s.pages.length;s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",s.completable&&R()(d).removeClass("disabled"),c.textContent=t+"/"+e})),s.show(),!1}))}},this.visibleInput=e.stringInput("Input file",this.initialText,null),this.hiddenInput=document.createElement("input"),this.icon=e.iconFA("cloud-upload",(()=>this.hiddenInput.click())),this.isValid=new p.BehaviorSubject(!0),this.draw(),this.isValid.subscribe((t=>{if(t){this.visibleInput.input.classList.remove("error"),this.visibleInput.input.classList.add("success");const t=e.iconFA("times",(()=>this.reset()),"Reset uploaded file");this.icon.replaceWith(t),this.icon=t}else{this.visibleInput.input.classList.remove("success"),this.visibleInput.input.classList.add("error");const t=e.iconFA("redo",(()=>this.hiddenInput.click()),"Re-upload a file");this.icon.replaceWith(t),this.icon=t}})),this.uploadedFile$.subscribe((t=>this.onFileUploaded.next(t))),i&&this.uploadedFile$.subscribe((t=>i(t)))}draw(){this.clear(),["drag","dragenter"].forEach((t=>{document.getElementsByClassName("layout-workarea")[0].addEventListener(t,(t=>{t.stopPropagation()}),!1)})),this.root.style.display="flex",this.root.append((()=>{this.visibleInput.input.readOnly=!0,this.visibleInput.input.classList.add("default");const t=t=>G(this,void 0,void 0,(function*(){if(t&&t.length){if(t.length>1)throw this.isValid.next(!1),new Error("Please specify single input file");if(this.visibleInput.value=t[0].name,t[0].type!==this.fileType)throw this.isValid.next(!1),new Error("File type is not supported");this.isValid.next(yield this.validation.validate(t[0])),this.isValid.value?this.uploadedFile$.next(t[0]):this.uploadedFile$.next(null)}else this.uploadedFile$.next(null)}));return this.visibleInput.root.classList.add("cv-drop-area"),this.visibleInput.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",(()=>G(this,void 0,void 0,(function*(){return yield t(this.hiddenInput.files)}))),!1),["dragenter","dragover","dragleave","drop"].forEach((t=>{this.visibleInput.input.addEventListener(t,(t=>{t.preventDefault(),t.stopPropagation()}),!1)})),["dragenter","dragover"].forEach((t=>{this.visibleInput.input.addEventListener(t,(()=>{this.visibleInput.input.classList.add("drag-n-dropping")}),!1)})),["dragleave","drop"].forEach((t=>{this.visibleInput.input.addEventListener(t,(()=>{this.visibleInput.input.classList.remove("drag-n-dropping")}),!1)})),this.visibleInput.input.addEventListener("drop",(e=>G(this,void 0,void 0,(function*(){const n=e.dataTransfer.files;t(n)}))),!1),this.visibleInput.input.addEventListener("click",(()=>this.hiddenInput.click()),!1),this.visibleInput.root.append(e.div(this.icon,"icon")),this.visibleInput})().root)}reset(){this.visibleInput.input.classList.value="ui-input-editor default";const t=e.iconFA("cloud-upload",(()=>this.hiddenInput.click()),"Choose a file to upload");this.icon.replaceWith(t),this.icon=t,this.visibleInput.value="Drag-n-drop here",this.hiddenInput.value="",this.uploadedFile$.next(null)}clear(){e.empty(this.root)}}const Z=rxjs.operators;var q=n(380),X={};X.styleTagTransform=W(),X.setAttributes=L(),X.insert=M().bind(null,"head"),X.domAPI=O(),X.insertStyleElement=j(),B()(q.Z,X),q.Z&&q.Z.locals&&q.Z.locals;class J{static getHistoryRuns(e){return(0,p.from)((()=>{return n=this,i=void 0,s=function*(){return yield x.pullRunsByName(e,[{isShared:!0},{author:t.shell.user}],{order:"started"},["func.params","session.user","options"])},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s})())}}class K{constructor(t,n,i,s,r=[]){var a;this.label=t,this._funcName=n,this._stringValueFunc=i,this._visibleColumnsForGrid=s,this._visibleColumnsForFilter=r,this.onHistoricalRunChosen=new p.BehaviorSubject(null),this.experimentRunsUpdate=new p.Subject,this.store={experimentRuns:new p.Observable,experimentRunsDf:new p.BehaviorSubject(o.DataFrame.fromColumns([o.Column.fromStrings("Pick",[]),...Object.keys(this._visibleColumnsForGrid).map((t=>o.Column.fromStrings(t,[])))])),isExperimentRunsLoading:new p.Subject,experimentRunData:new p.BehaviorSubject("")},this._historyGrid=o.Viewer.grid(this.store.experimentRunsDf.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1}),this._historyFilters=o.Viewer.filters(this.store.experimentRunsDf.value,{title:"Filters"}),this._visibleInput=e.stringInput(this.label,"",null),this._historyGrid.columns.byName("Pick").cellType="html",this._historyGrid.columns.byName("Pick").width=30,this._historyGrid.root.style.height="100%";for(let t=0;t<this._historyGrid.columns.length;t++){const e=null===(a=this._historyGrid.columns.byIndex(t))||void 0===a?void 0:a.column;e&&e.type===o.TYPE.DATE_TIME&&(this._historyGrid.columns.byIndex(t).format="MMM d, yyyy",this._historyGrid.columns.byIndex(t).width=100)}this._visibleInput.input.addEventListener("click",(()=>{var t;const n=e.dialog();R()(n.root).addClass("arrow-box"),n.onOK((()=>{})),n.onCancel((()=>{this.onHistoricalRunChosen.next(null),this.historyGrid.dataFrame.currentRowIdx=-1})),R()(n.root).find(".d4-dialog-header").hide(),n.root.style.boxShadow="",R()(n.root).removeClass("ui-form");const i=o.Viewer.filters(this.store.experimentRunsDf.value,{title:"Filters"});this._historyFilters.root.replaceWith(i.root),this._historyFilters=i;const s=o.Viewer.grid(this.store.experimentRunsDf.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1});this._historyGrid.root.replaceWith(s.root),this._historyGrid=s,this._historyGrid.columns.byName("Pick").cellType="html",this._historyGrid.columns.byName("Pick").width=30,this._historyGrid.root.style.height="100%";for(let e=0;e<this._historyGrid.columns.length;e++){const n=null===(t=this._historyGrid.columns.byIndex(e))||void 0===t?void 0:t.column;n&&n.type===o.TYPE.DATE_TIME&&(this._historyGrid.columns.byIndex(e).format="MMM d, yyyy",this._historyGrid.columns.byIndex(e).width=100)}this._historyGrid.onCellPrepare((t=>{var n;"Pick"===(null===(n=t.tableColumn)||void 0===n?void 0:n.name)&&(t.isColHeader&&(t.customText=""),!0===t.cell.value?t.element=e.div([e.iconFA("check",null,"Confirm outliers group")],{style:{"text-align":"center",margin:"6px"}}):t.element=e.div())})),this._historyGrid.columns.setVisible(["Pick",...Object.keys(this._visibleColumnsForGrid).map((t=>t))]),this._historyFilters.setOptions({columnNames:this._visibleColumnsForFilter}),this._historyFilters.root.style.height="100%",R()(this._historyFilters.root).find(".d4-filter-group-header").hide(),this._visibleColumnsForFilter.length||R()(this._historyFilters.root.parentElement).hide(),n.add(e.divH([e.block([this._historyGrid.root]),e.block([this._historyFilters.root],{style:{"margin-left":"10px",width:"225px",height:"100%"}})])),n.show({x:this._visibleInput.input.getBoundingClientRect().x+this._visibleInput.input.clientWidth+10,y:this._visibleInput.input.getBoundingClientRect().y-30,width:Math.max(this._historyGrid.root.clientWidth+this._historyFilters.root.clientWidth+30,600)})})),this._visibleInput.readOnly=!0,this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,Z.tap)((()=>this.toggleLoaderExpRuns(!0))),(0,Z.switchMap)((()=>J.getHistoryRuns(this._funcName).pipe((0,Z.catchError)((()=>p.EMPTY)),(0,Z.finalize)((()=>this.toggleLoaderExpRuns(!1)))))),(0,Z.shareReplay)(1)),this.store.experimentRuns.pipe((0,Z.takeUntil)((0,p.from)(new p.Subject))).subscribe((t=>{const e=o.DataFrame.fromColumns([o.Column.bool("Pick",t.length).init(!1),...Object.entries(this._visibleColumnsForGrid).map((e=>o.Column.fromStrings(e[0],t.map(e[1])))),o.Column.fromStrings("ID",t.map((t=>t.id)))]);e.onCurrentRowChanged.subscribe((()=>{e.getCol("Pick").init(!1),e.set("Pick",e.currentRow.idx,!0);const n=e.getCol("ID").get(e.currentRow.idx),i=t.find((t=>t.id===n));i&&this.onHistoricalRunChosen.next(i)})),this.store.experimentRunsDf.next(e)})),this.store.experimentRunsDf.subscribe((t=>{this.historyGrid.dataFrame=t,this.historyFilters.dataFrame=t})),this.onHistoricalRunChosen.subscribe((t=>{this._visibleInput.value=t?this._stringValueFunc(t):""})),this.store.isExperimentRunsLoading.subscribe((t=>{e.setUpdateIndicator(this._visibleInput.root,t)}))}get historyGrid(){return this._historyGrid}get historyFilters(){return this._historyFilters}get root(){return this._visibleInput.root}set value(t){this._visibleInput.value=t?this._stringValueFunc(t):""}get value(){return this.onHistoricalRunChosen.value}set stringValue(t){this._visibleInput.value=t}get stringValue(){return this._visibleInput.value}toggleLoaderExpRuns(t){this.store.isExperimentRunsLoading.next(t)}}const Q=dayjs;var tt=n.n(Q),et=n(778),nt={};nt.styleTagTransform=W(),nt.setAttributes=L(),nt.insert=M().bind(null,"head"),nt.domAPI=O(),nt.insertStyleElement=j(),B()(et.Z,nt),et.Z&&et.Z.locals&&et.Z.locals;var it=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const ot={Test:"ca1e672e-e3be-40e0-b79b-d2c68e68d380",Admin:"878c42b0-9a50-11e6-c537-6bf8e9ab02ee",System:"3e32c5fa-ac9c-4d39-8b4b-4db3e576b3c3"};class st{constructor(){this.filteringOptions={text:""},this.allRuns=new p.BehaviorSubject([])}get myRuns(){return this.allRuns.value.filter((e=>e.author.id===t.shell.user.id))}get favoriteRuns(){return this.allRuns.value.filter((t=>t.options.isFavorite&&!t.options.isImported))}get sharedRuns(){return this.allRuns.value.filter((t=>t.options.isShared))}get filteredMyRuns(){return this.myRuns.filter((t=>{const e=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,n=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),i=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),o=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(n||i)&&e&&o}))}get filteredFavoriteRuns(){return this.favoriteRuns.filter((t=>{const e=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,n=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),i=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),o=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(n||i)&&e&&o}))}get filteredSharedRuns(){return this.sharedRuns.filter((t=>{const e=!this.filteringOptions.author||t.author.id===this.filteringOptions.author.id,n=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,i=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),o=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),s=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(i||o)&&n&&e&&s}))}}const rt="HISTORY",at="FAVORITES",lt="SHARED";class dt{buildActionsSection(){return e.divH([e.span([`Selected: ${this.selectedCallsSet.size}`],{style:{"align-self":"center"}}),e.divH([(()=>{const t=e.iconFA("exchange",(()=>it(this,void 0,void 0,(function*(){this.onComparison.next([...r()(this.selectedCallsSet.keys()).map((t=>t.id))])}))),"Compare selected runs");return t.style.margin="5px",this.selectedCallsSet.size<2&&t.classList.add("hp-disabled"),t})(),(()=>{const t=e.iconFA("trash-alt",(()=>this.showDeleteRunDialog(this.selectedCallsSet)),"Delete selected runs");return t.style.margin="5px",0===this.selectedCallsSet.size&&t.classList.add("hp-disabled"),t})(),...0===this.selectedCallsSet.size?[(()=>{const t=e.iconFA("square",(()=>{switch(this.tabs.currentPane.name){case rt:this.store.myRuns.forEach((t=>this.selectedCallsSet.add(t))),this.myRunsFilter.next();break;case at:this.store.favoriteRuns.forEach((t=>this.selectedCallsSet.add(t))),this.favRunsFilter.next();break;case lt:this.store.sharedRuns.forEach((t=>this.selectedCallsSet.add(t))),this.sharedRunsFilter.next()}this.updateActionsSection()}),"Select all");return t.style.margin="5px",t})()]:[(()=>{let t=0;switch(this.tabs.currentPane.name){case rt:t=this.store.myRuns.length;break;case at:t=this.store.favoriteRuns.length;break;case lt:t=this.store.sharedRuns.length}const n=this.selectedCallsSet.size===t?"check-square":"minus-square",i=e.iconFA(n,(()=>{switch(this.tabs.currentPane.name){case rt:this.store.myRuns.forEach((t=>this.selectedCallsSet.delete(t))),this.myRunsFilter.next();break;case at:this.store.favoriteRuns.forEach((t=>this.selectedCallsSet.delete(t))),this.favRunsFilter.next();break;case lt:this.store.sharedRuns.forEach((t=>this.selectedCallsSet.delete(t))),this.sharedRunsFilter.next()}this.updateActionsSection()}),"Unselect all");return i.style.margin="5px",i})()]])],{style:{"justify-content":"space-between",padding:"0 12px"}})}buildFilterPane(n){return e.wait((()=>it(this,void 0,void 0,(function*(){const i=new p.Subject,s=e.stringInput("Search","",(t=>i.next(t)));o.debounce(i.asObservable(),600).subscribe((()=>{this.store.filteringOptions.text=s.stringValue,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()}));const r=e.dateInput("Started after",tt()().subtract(1,"week"),(t=>{this.store.filteringOptions.startedAfter=t,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),a=Object.values(ot),l=(yield t.dapi.users.list()).filter((t=>!a.includes(t.id))),d=e.choiceInput("Author","Anyone",["Anyone",...l],(t=>{this.store.filteringOptions.author="Anyone"===t?void 0:t,this.sharedRunsFilter.next()}));d.root.style.display="none";let u=e.choiceInput("Tag","Choose tag to filter",["Choose tag to filter"]);const c=o.TagEditor.create(),h=e.stringInput(" ","");h.input.replaceWith(c.root),h.root.style.display="none",c.onChanged((()=>{this.store.filteringOptions.tags=c.tags.filter((t=>!!t)),0===this.store.filteringOptions.tags.length?h.root.style.display="none":h.root.style.removeProperty("display"),this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),this.store.allRuns.subscribe((()=>{const t=this.store.allRuns.value.map((t=>t.options.tags)).reduce(((t,e)=>(e&&e.forEach((e=>{t.includes(e)||t.push(e)})),t)),[]),n=e.choiceInput("Tag","Choose tag to filter",["Choose tag to filter",...t]);u.root.replaceWith(n.root),u=n,u.onChanged((()=>{u.value&&"Choose tag to filter"!==u.value&&!c.tags.includes(u.value)&&c.addTag(u.value)}))})),r.addPatternMenu("datetime");const f=e.divV([s,r,d,u,h],"ui-form ui-form-wide ui-form-left");return n===rt&&(r.root.style.removeProperty("display"),d.root.style.display="none"),n===at&&(r.root.style.removeProperty("display"),d.root.style.display="none"),n===lt&&(r.root.style.removeProperty("display"),d.root.style.removeProperty("display")),f}))))}showDeleteRunDialog(t){e.dialog({title:"Delete "+(t.size>1?"runs":"run")}).add(e.divText(`The deleted ${t.size>1?"runs":"run"} is impossible to restore. Are you sure?`)).onOK((()=>it(this,void 0,void 0,(function*(){t.forEach((t=>it(this,void 0,void 0,(function*(){this.beforeRunDeleted.next(t.id),this.selectedCallsSet.delete(t),yield x.deleteRun(t),this.afterRunDeleted.next(t.id)}))))})))).show({center:!0})}updateActionsSection(){const t=this.buildActionsSection();this.actionsSection.replaceWith(t),this.actionsSection=t}updateSharedPane(t){const n=t.length>0?this.renderSharedCards(t):e.divText("No runs are marked as shared","no-elements-label"),i=e.divV([this.sharedPaneFilter,e.element("div","splitbar-horizontal"),n]);this.sharedTab.replaceWith(i),this.sharedTab=i}updateFavoritesPane(t){const n=t.length>0?this.renderFavoriteCards(t):e.divText("No runs are marked as favorites","no-elements-label"),i=e.divV([this.favoritesPaneFilter,e.element("div","splitbar-horizontal"),n]);this.favTab.replaceWith(i),this.favTab=i}updateMyPane(t){const n=t.length>0?this.renderHistoryCards(t):e.divText("No runs are found in history","no-elements-label"),i=e.divV([this.myPaneFilter,this.actionsSection,e.element("div","splitbar-horizontal"),n]);this.historyTab.replaceWith(i),this.historyTab=i}renderCard(n){var i;const o=n.author.picture;o.style.width="25px",o.style.height="25px",o.style.fontSize="20px";const s=e.label(null!==(i=n.options.title)&&void 0!==i?i:n.author.friendlyName,{style:{color:"var(--blue-1)"}});e.bind(n.author,o);const r=e.iconFA("square",(t=>{t.stopPropagation(),this.selectedCallsSet.add(n),r.style.display="none",a.style.removeProperty("display"),this.updateActionsSection()}),"Select this run");r.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const a=e.iconFA("check-square",(t=>{t.stopPropagation(),this.selectedCallsSet.delete(n),a.style.display="none",this.updateActionsSection(),r.style.removeProperty("display")}),"Unselect this run");a.classList.add("hp-funccall-card-icon"),this.selectedCallsSet.has(n)?(r.style.display="none",a.style.removeProperty("display")):(r.style.removeProperty("display"),a.style.display="none");const l=e.iconFA("edit",(t=>{t.stopPropagation(),this.showEditDialog(n)}),"Edit selected run");l.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const d=e.iconFA("trash-alt",(t=>it(this,void 0,void 0,(function*(){t.stopPropagation();const e=new Set;e.add(n),this.showDeleteRunDialog(e)}))),"Delete selected runs");d.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const u=e.iconFA("star",null,"Unfavorite the run");u.classList.add("fas","hp-funccall-card-def-icon");const c=e.iconFA("share-alt",null,"Add to shared");c.classList.add("fas","hp-funccall-card-def-icon"),c.style.color="var(--blue-1)";const p=new Date(n.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}),h=e.divH([e.divH([o,e.divV([s,e.span([p]),...n.options.description?[e.divText(n.options.description,"description")]:[],...n.options.tags&&n.options.tags.length>0?[e.div(n.options.tags.map((t=>e.span([t],"d4-tag"))))]:[]],"hp-card-content")]),e.divH([l,d,...n.options.isFavorite?[u]:[],...n.options.isShared?[c]:[],r,a])],"hp-funccall-card");return h.addEventListener("click",(()=>it(this,void 0,void 0,(function*(){this.onRunChosen.next(n.id),[...this.myCards,...this.favoriteCards,...this.sharedCards].forEach((t=>t.classList.remove("clicked"))),h.classList.add("clicked")})))),e.tooltip.bind(h,(()=>e.tableFromMap(Object.assign(Object.assign(Object.assign({Author:t.shell.user.toMarkup(),Date:p},n.options.title?{Title:n.options.title}:{}),n.options.description?{Description:n.options.description}:{}),n.options.tags&&n.options.tags.length>0?{Tags:e.div(n.options.tags.map((t=>e.span([t],"d4-tag"))),"d4-tag-editor")}:{})))),h}showEditDialog(t){var n,i,s,r;const a=e.dialog({title:"Edit run"});let l=null!==(n=t.options.title)&&void 0!==n?n:"",d=null!==(i=t.options.description)&&void 0!==i?i:"";const u=e.stringInput("Title",l,(t=>l=t));let c=null!==(s=t.options.isShared)&&void 0!==s&&s,p=null!==(r=t.options.isFavorite)&&void 0!==r&&r;const h=o.TagEditor.create();(t.options.tags||[]).forEach((t=>{h.addTag(t)}));const f=e.stringInput(" ","");f.input.replaceWith(h.root);const m=e.stringInput("Tag",""),v=()=>{""===m.value||h.tags.includes(m.value)||(h.addTag(m.value),m.value="")};m.addOptions(e.iconFA("plus",v,"Add this tag")),m.input.onkeydown=t=>it(this,void 0,void 0,(function*(){"Enter"==t.key&&(t.stopPropagation(),v())})),a.add(e.form([u,e.stringInput("Description",d,(t=>{d=t})),e.boolInput("Favorites",p,(t=>p=t)),e.boolInput("Share",c,(t=>c=t)),m,f])).onOK((()=>it(this,void 0,void 0,(function*(){if((t=yield x.loadRun(t.id)).options.title=""!==l?l:null,t.options.description=""!==d?d:null,t.options.tags=h.tags,!!c==!!t.options.isShared&&!!p==!!t.options.isFavorite){e.setUpdateIndicator(this.tabs.root,!0),yield x.saveRun(t);const n=this.store.allRuns.value.find((e=>e.id===t.id));return n.options.title=""!==l?l:null,n.options.description=""!==d?d:null,n.options.tags=t.options.tags,this.store.allRuns.next(this.store.allRuns.value),void e.setUpdateIndicator(this.tabs.root,!1)}c&&!t.options.isShared&&(t.options.isShared=c,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToShared(t),e.setUpdateIndicator(this.tabs.root,!1)),!c&&t.options.isShared&&(t.options.isShared=c,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromShared(t),e.setUpdateIndicator(this.tabs.root,!1)),p&&!t.options.isFavorite&&(t.options.isFavorite=p,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToFavorites(t),e.setUpdateIndicator(this.tabs.root,!1)),!p&&t.options.isFavorite&&(t.options.isFavorite=p,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromFavorites(t),e.setUpdateIndicator(this.tabs.root,!1))})))).show({center:!0,width:500})}renderFavoriteCards(t){return this.favoriteCards=t.map((t=>this.renderCard(t))),e.divV(this.favoriteCards)}renderSharedCards(t){return this.sharedCards=t.map((t=>this.renderCard(t))),e.divV(this.sharedCards)}renderHistoryCards(t){return this.myCards=t.map((t=>this.renderCard(t))),e.divV(this.myCards,{style:{height:"100%"}})}constructor(t){this.func=t,this.onRunChosen=new p.Subject,this.onComparison=new p.Subject,this.beforeRunAddToFavorites=new p.Subject,this.beforeRunAddToShared=new p.Subject,this.beforeRunRemoveFromFavorites=new p.Subject,this.beforeRunRemoveFromShared=new p.Subject,this.beforeRunDeleted=new p.Subject,this.afterRunAddToFavorites=new p.Subject,this.afterRunAddToShared=new p.Subject,this.afterRunRemoveFromFavorites=new p.Subject,this.afterRunRemoveFromShared=new p.Subject,this.afterRunDeleted=new p.Subject,this.store=new st,this.myRunsFilter=new p.Subject,this.favRunsFilter=new p.Subject,this.sharedRunsFilter=new p.Subject,this.selectedCallsSet=new Set,this.allRunsFetch=new p.Subject,this.historyTab=e.div(),this.favTab=e.div(),this.sharedTab=e.div(),this.filterPane=e.div(),this.tabs=e.tabControl({[rt]:e.box(this.historyTab),[at]:e.box(this.favTab),[lt]:e.box(this.sharedTab)}),this.actionsSection=this.buildActionsSection(),this._root=e.divV([this.tabs.root],{style:{width:"100%",height:"100%"}}),this.myCards=[],this.favoriteCards=[],this.sharedCards=[],this.myPaneFilter=this.buildFilterPane(rt),this.favoritesPaneFilter=this.buildFilterPane(at),this.sharedPaneFilter=this.buildFilterPane(lt),this.tabs.root.style.width="100%",this.tabs.root.style.height="100%",this.tabs.onTabChanged.subscribe((()=>{switch(this.tabs.currentPane.name){case rt:this.myPaneFilter.append(this.actionsSection);break;case at:this.favoritesPaneFilter.append(this.actionsSection);break;case lt:this.sharedPaneFilter.append(this.actionsSection)}})),this.myRunsFilter.subscribe((()=>this.updateMyPane(this.store.filteredMyRuns))),this.favRunsFilter.subscribe((()=>this.updateFavoritesPane(this.store.filteredFavoriteRuns))),this.sharedRunsFilter.subscribe((()=>this.updateSharedPane(this.store.filteredSharedRuns))),this.store.allRuns.subscribe((()=>{this.updateMyPane(this.store.filteredMyRuns),this.updateFavoritesPane(this.store.filteredFavoriteRuns),this.updateSharedPane(this.store.filteredSharedRuns)})),this.allRunsFetch.subscribe((()=>it(this,void 0,void 0,(function*(){e.setUpdateIndicator(this.root,!0);const t=(yield x.pullRunsByName(this.func.name,[],{order:"started"},["session.user","options"])).reverse();this.store.allRuns.next(t),e.setUpdateIndicator(this.root,!1)})))),this.afterRunAddToFavorites.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.isFavorite=!0,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunAddToShared.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.isShared=!0,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunRemoveFromFavorites.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.isFavorite=!1,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunRemoveFromShared.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.isShared=!1,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunDeleted.subscribe((t=>{this.store.allRuns.next(this.store.allRuns.value.filter((e=>e.id!==t))),this.updateActionsSection()})),this.allRunsFetch.next()}addRunToFavorites(e){return it(this,void 0,void 0,(function*(){e.options.isFavorite=!0,this.beforeRunAddToFavorites.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunAddToFavorites.next(n),n}))}removeRunFromFavorites(e){return it(this,void 0,void 0,(function*(){e.options.isFavorite=!1,this.beforeRunRemoveFromFavorites.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunRemoveFromFavorites.next(n),n}))}addRunToShared(e){return it(this,void 0,void 0,(function*(){e.options.isShared=!0,this.beforeRunAddToShared.next(e);const n=yield t.dapi.groups.find("a4b45840-9a50-11e6-9cc9-8546b8bf62e6"),i=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const o of i){const i=e.outputs[o.name];yield t.dapi.permissions.grant(i.getTableInfo(),n,!1)}const s=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of s){const o=e.inputs[i.name];yield t.dapi.permissions.grant(o.getTableInfo(),n,!1)}const a=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunAddToShared.next(a),a}))}removeRunFromShared(e){return it(this,void 0,void 0,(function*(){e.options.isShared=!1,this.beforeRunRemoveFromShared.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunRemoveFromShared.next(n),n}))}get root(){return this._root}}var ut;!function(t){t.fileInput=function(t="Drag-n-drop here",e=null,n=null,i=Y){return new z(t,e,n,i)},t.historyInput=function(t,e,n,i,o=[]){return new K(t,e,n,i,o)},t.historyPanel=function(t){return new dt(t)}}(ut||(ut={}));var ct=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const pt="Run name",ht="RunId";class ft extends o.TableView{static fromComparedRuns(e,n){var i,s,r;return ct(this,void 0,void 0,(function*(){const a=null!==(i=n.configFunc)&&void 0!==i?i:e[0].func,l=[...a.inputs,...a.outputs].map((t=>A(t))).reduce(((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t)),{}),d=t=>{var n;if(t.propertyType===o.TYPE.DATA_FRAME){const n=l[t.name].map((n=>{var i;let s=null!==(i=t.caption)&&void 0!==i?i:t.name;const r=o.Column.fromType(o.TYPE.DATA_FRAME,s,e.length);r.init((n=>{var i;return null!==(i=e[n].inputs[t.name])&&void 0!==i?i:e[n].outputs[t.name]}));const a=u.columns.getUnusedName(r.name);return r.name=a,s=a,r.temp[m]=n,u.columns.add(r),r}));return n}{let i=null!==(n=t.caption)&&void 0!==n?n:t.name;const s=o.Column.fromType(t.propertyType,i,e.length);s.init((n=>{var i;return null!==(i=e[n].inputs[t.name])&&void 0!==i?i:e[n].outputs[t.name]}));const r=u.columns.getUnusedName(s.name);return s.name=r,i=r,u.columns.add(s),[s]}},u=o.DataFrame.create(e.length),c=[];e.forEach((t=>{var e;let n=null!==(e=t.options.title)&&void 0!==e?e:`${t.func.name} - ${new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`,i=2;for(;c.includes(n);)n=`${t.func.name} - ${new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})} - ${i}`,i++;c.push(n)})),u.columns.add(o.Column.fromStrings(pt,c)),u.name=(null===(s=n.parentCall)||void 0===s?void 0:s.func.name)?`${null===(r=n.parentCall)||void 0===r?void 0:r.func.name} - comparison`:`${e[0].func.name} - comparison`,a.inputs.forEach((t=>d(t))),a.outputs.forEach((t=>d(t)));const p=[...t.shell.views].find((t=>t.type===f||"scripts"===t.type||"functions"===t.type));p&&(t.shell.v=p);const h=t.shell.addTableView(u);h.temp={isComparison:!0},h.close();const v=new this(h.dart,n),g=a.options.comparator;return setTimeout((()=>ct(this,void 0,void 0,(function*(){v.defaultCustomize(),g&&(yield t.functions.call(g,{comparisonView:v}))}))),0),v}))}constructor(e,n={}){super(e),n.parentView&&(this.parentView=n.parentView),this.parentCall=n.parentCall||t.functions.getCurrentCall()}defaultCustomize(){var n;this.root.style.removeProperty("width"),this.root.firstChild.style.removeProperty("width"),this.root.firstChild.firstChild.style.removeProperty("width"),this.grid.props.rowHeight=180,this.grid.props.showAddNewRowIcon=!1,this.grid.props.allowEdit=!1,this.grid.columns.byName(pt).width=70;for(let t=0;t<this.grid.columns.length;t++){const e=this.grid.columns.byIndex(t);(null===(n=e.column)||void 0===n?void 0:n.temp[m])&&(e.width=350,e.cellType="html")}this.grid.onCellPrepare((t=>{if(!t.isColHeader&&!t.isRowHeader&&(t.tableColumn.name===pt&&(t.style.textVertical=!0),t.tableColumn&&t.tableColumn.temp[m])){const n=t.cell.value,i=t.tableColumn.temp[m],s=i.type;t.element=e.waitBox((()=>ct(this,void 0,void 0,(function*(){const e=Object.values(h).includes(s)?o.Viewer.fromType(s,n):yield n.plot.fromType(s);return t.tableColumn.temp[m].look?e.setOptions(t.tableColumn.temp[m].look):(e.setOptions(i),t.tableColumn.temp[m]=e.getOptions()),e.root})))),t.element.style.width="100%",t.element.style.height="100%"}})),t.events.onCurrentObjectChanged.subscribe((({sender:n})=>{var i;if(n instanceof o.Column&&n.type===o.TYPE.DATA_FRAME&&t.shell.tv&&t.shell.tv.temp.isComparison&&[o.VIEWER.LINE_CHART,o.VIEWER.SCATTER_PLOT,o.VIEWER.HISTOGRAM,o.VIEWER.BOX_PLOT].includes(n.temp[m].type)){t.shell.windows.showProperties=!0;const s=t=>{const e=t.get(0).clone();e.columns.addNew(ht,o.TYPE.STRING).init(t.dataFrame.get(pt,0));for(let n=1;n<t.length;n++){const i=t.get(n).clone();i.columns.addNew(ht,o.TYPE.STRING).init(t.dataFrame.get(pt,n));const s=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t),r=e.columns.byIndex(t);n.type!==r.type&&s.includes(n.type)&&s.includes(r.type)&&(n.type!==o.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(o.COLUMN_TYPE.FLOAT)),r.type!==o.COLUMN_TYPE.FLOAT&&e.columns.replace(r,r.convertTo(o.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},r=null!==(i=n.temp.unitedDf)&&void 0!==i?i:s(n);n.temp.unitedDf=r;const a=n.temp[m].look;setTimeout((()=>{switch(n.temp[m].type){case o.VIEWER.LINE_CHART:t.shell.o=e.box(r.plot.line(Object.assign(Object.assign({},a),{split:ht})).root);break;case o.VIEWER.SCATTER_PLOT:t.shell.o=e.box(r.plot.scatter(Object.assign(Object.assign({},a),{color:ht})).root);break;case o.VIEWER.HISTOGRAM:t.shell.o=e.box(r.plot.histogram(Object.assign(Object.assign({},a),{split:ht})).root);break;case o.VIEWER.BOX_PLOT:t.shell.o=e.box(r.plot.box(Object.assign(Object.assign({},a),{category:ht})).root)}}))}}))}}var mt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const vt=new URL(t.shell.startUri);class gt extends o.ViewBase{constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(),this.initValue=t,this.options=n,this._type="function",this.funcCallReplaced=new p.Subject,this.exportConfig=null,this.historyRoot=e.divV([],{style:{"justify-content":"center"}}),this.defaultExportFilename=t=>`${this.name} - ${(new Date).toLocaleString("en-US").replaceAll(/:|\//g,"-")}.${this.exportConfig.supportedExtensions[t]}`,this.defaultSupportedExportExtensions=()=>({Excel:"xlsx"}),this.defaultSupportedExportFormats=()=>["Excel"],this.box=!0,this.init()}onFuncCallReady(){return mt(this,void 0,void 0,(function*(){this.changeViewName(this.funcCall.func.friendlyName),this.build(),this.getStartId()&&(yield this.loadRun(this.funcCall.id),this.setAsLoaded())}))}changeViewName(t){var n;this.name=t,null===(n=document.querySelector("div.d4-ribbon-name"))||void 0===n||n.replaceChildren(e.span([t]))}getStartId(){return t.shell.getVar("isLoaded")?void 0:vt.searchParams.get("id")}setAsLoaded(){return t.shell.setVar("isLoaded",!0)}get funcCall(){return this._funcCall}get func(){var t;return null===(t=this.funcCall)||void 0===t?void 0:t.func}get lastCall(){return this._lastCall}set lastCall(t){this._lastCall=t}get type(){return this._type}linkFunccall(t){var e,n,i;const o=null===(e=this._funcCall)||void 0===e?void 0:e.options.isHistorical;this._funcCall=t,this.options.isTabbed||(t.options.isHistorical?(o?this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)} — ${null!==(i=t.options.title)&&void 0!==i?i:new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`):this.changeViewName(`${this.name} — ${null!==(n=t.options.title)&&void 0!==n?n:new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`),this.path=`?id=${this._funcCall.id}`):(this.path="",this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)}`))),this.funcCallReplaced.next(!0)}loadFuncCallById(){return mt(this,void 0,void 0,(function*(){if(this.initValue instanceof o.FuncCall)return yield new Promise((t=>setTimeout(t,0))),void this.linkFunccall(this.initValue);e.setUpdateIndicator(this.root,!0);const n=this.getStartId();if(n&&!this.options.isTabbed)this.linkFunccall(yield x.loadRun(n));else{const e=yield t.functions.eval(this.initValue);this.linkFunccall(e.prepare({}))}e.setUpdateIndicator(this.root,!1)}))}init(){return mt(this,void 0,void 0,(function*(){yield this.loadFuncCallById(),yield this.onFuncCallReady()}))}build(){e.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}onComparisonLaunch(e){return mt(this,void 0,void 0,(function*(){const n=t.shell.v.parentCall,i=yield Promise.all(e.map((t=>x.loadRun(t)))),o=[...t.shell.views].find((t=>t.type===f)),s=yield ft.fromComparedRuns(i,{parentView:o,parentCall:n,configFunc:this.func});t.shell.addView(s)}))}buildHistoryBlock(){const t=ut.historyPanel(this.func);return this.subs.push(t.onRunChosen.subscribe((t=>mt(this,void 0,void 0,(function*(){return this.linkFunccall(yield this.loadRun(t))})))),t.onComparison.subscribe((t=>mt(this,void 0,void 0,(function*(){return this.onComparisonLaunch(t)}))))),e.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.style.width="100%",this.historyRoot.append(t.root),t.root}buildRibbonPanels(){const n=e.iconFA("history",(()=>{t.shell.windows.showProperties=!t.shell.windows.showProperties,n.classList.toggle("d4-current"),t.shell.o=this.historyRoot}));n.classList.add("d4-toggle-button"),t.shell.windows.showProperties&&n.classList.add("d4-current");const i=[[...this.exportConfig&&this.exportConfig.supportedFormats.length>0?[e.comboPopup(e.iconFA("arrow-to-bottom"),this.exportConfig.supportedFormats,(t=>mt(this,void 0,void 0,(function*(){return o.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))}))))]:[],...this.options.historyEnabled?[n]:[]]];return this.setRibbonPanels(i),i}buildRibbonMenu(){}onBeforeSaveRun(t){return mt(this,void 0,void 0,(function*(){}))}onAfterSaveRun(t){return mt(this,void 0,void 0,(function*(){}))}saveRun(t){return mt(this,void 0,void 0,(function*(){yield this.onBeforeSaveRun(t);const e=yield x.saveRun(t);return this.linkFunccall(e),this.options.historyEnabled&&this.buildHistoryBlock(),this.options.isTabbed||(this.path=`?id=${e.id}`),yield this.onAfterSaveRun(e),e}))}onBeforeDeleteRun(t){return mt(this,void 0,void 0,(function*(){}))}onAfterDeleteRun(t){return mt(this,void 0,void 0,(function*(){}))}deleteRun(t){return mt(this,void 0,void 0,(function*(){return yield this.onBeforeDeleteRun(t),yield x.deleteRun(t),yield this.onAfterDeleteRun(t),t.id}))}onBeforeLoadRun(){return mt(this,void 0,void 0,(function*(){}))}onAfterLoadRun(t){return mt(this,void 0,void 0,(function*(){}))}loadRun(t){return mt(this,void 0,void 0,(function*(){yield this.onBeforeLoadRun();const e=yield x.loadRun(t);return this.lastCall=e,yield this.onAfterLoadRun(e),e}))}onBeforeRun(t){return mt(this,void 0,void 0,(function*(){}))}onAfterRun(t){return mt(this,void 0,void 0,(function*(){}))}run(){return mt(this,void 0,void 0,(function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const t=o.TaskBarProgressIndicator.create("Calculating...");this.funcCall.newId(),yield this.funcCall.call(),t.close(),yield this.onAfterRun(this.funcCall),this.lastCall=this.options.isTabbed||this.runningOnInput||this.runningOnStart?this.funcCall.clone():yield this.saveRun(this.funcCall)}))}get hasUploadMode(){return"true"===this.func.options.uploadMode}get runningOnInput(){return"true"===this.func.options.runOnInput}get runningOnStart(){return"true"===this.func.options.runOnOpen}}var yt=n(903),bt={};bt.styleTagTransform=W(),bt.setAttributes=L(),bt.insert=M().bind(null,"head"),bt.domAPI=O(),bt.insertStyleElement=j(),B()(yt.Z,bt),yt.Z&&yt.Z.locals&&yt.Z.locals;const At=html2canvas;var Ct=n.n(At),wt=n(751),xt={};xt.styleTagTransform=W(),xt.setAttributes=L(),xt.insert=M().bind(null,"head"),xt.domAPI=O(),xt.insertStyleElement=j(),B()(wt.Z,xt),wt.Z&&wt.Z.locals&&wt.Z.locals;var It=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const Rt="file";class Et extends gt{static fromFuncCall(t,e={historyEnabled:!0,isTabbed:!1}){return new this(t,e)}constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(t,n),this.options=n,this.checkDisability=new p.Subject,this.isRunning=!1,this.isUploadMode=new p.BehaviorSubject(!1),this.beforeInputPropertyRender=new p.Subject,this.afterInputPropertyRender=new p.Subject,this.beforeRenderControlls=new p.Subject,this.afterOutputPropertyRender=new p.Subject,this.afterOutputSacalarTableRender=new p.Subject,this.outputsTabsElem=e.tabControl(),this.formTabsElem=e.tabControl(),this.dfToViewerMapping={},this.defaultExport=t=>It(this,void 0,void 0,(function*(){const e=this.lastCall;if(!e)throw new Error("Function was not called");if(!this.exportConfig.supportedFormats.includes(t))throw new Error(`Format "${t}" is not supported.`);if(!this.func)throw new Error("The correspoding function is not specified");const n=new(F().Workbook),i=t=>o.TYPES_SCALAR.has(t),s=t=>t===o.TYPE.DATA_FRAME,r=this.func.inputs.filter((t=>s(t.propertyType))),a=this.func.inputs.filter((t=>i(t.propertyType))),l=this.func.outputs.filter((t=>s(t.propertyType))),d=this.func.outputs.filter((t=>i(t.propertyType))),u=[...e.inputParams.values()],c=[...e.outputParams.values()];if(r.forEach((t=>{const i=t.options.caption||t.name,o=n.addWorksheet(Tt(i,v.INPUT)),s=y(e,t.name,v.INPUT);St(o,s)})),a.length){const t=n.addWorksheet("Input scalars");Ft(t,a.map((t=>({caption:t.options.caption||t.name,value:e.inputs[t.name],units:t.options.units||""}))))}if(l.forEach((t=>{const i=t.options.caption||t.name,o=n.addWorksheet(Tt(i,v.OUTPUT)),s=y(e,t.name,v.OUTPUT);St(o,s)})),d.length){const t=n.addWorksheet("Output scalars");Ft(t,d.map((t=>({caption:t.options.caption||t.name,value:e.outputs[t.name],units:t.options.units||""}))))}const p=this.outputsTabsElem;for(const t of this.tabsLabels)if(p.currentPane=p.getPane(t),yield new Promise((t=>setTimeout(t,100))),"Input"===t)for(const t of u.filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME))){const i=this.dfToViewerMapping[t.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(h).includes(t.type))),s=r.find((e=>e.name===t.name)),a=s.options.caption||t.name,l=y(e,s.name,v.INPUT);for(const[t,e]of i.entries())yield Pt(n,n.getWorksheet(Tt(a,v.INPUT)),e.root,l.columns.length+2,t>0?Math.ceil(i[t-1].root.clientHeight/20)+1:0)}else for(const i of c.filter((e=>e.property.propertyType===o.TYPE.DATA_FRAME&&("Output"===t&&"Misc"===e.property.category||"Output"===e.property.category||"Output"!==t&&e.property.category===t)))){const t=this.dfToViewerMapping[i.property.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(h).includes(t.type))),s=l.find((t=>t.name===i.property.name)),r=s.options.caption||i.property.name,a=y(e,s.name,v.OUTPUT);for(const[e,i]of t.entries())if(i.type===o.VIEWER.STATISTICS){const i=a.columns.length,s=o.DataFrame.fromColumns([o.Column.string("Name",i).init((t=>a.columns.byIndex(t).name)),o.Column.int("Values",i).init((t=>a.columns.byIndex(t).stats.valueCount)),o.Column.int("Nulls",i).init((t=>a.columns.byIndex(t).stats.missingValueCount)),o.Column.float("Min",i).init((t=>a.columns.byIndex(t).stats.min)),o.Column.float("Max",i).init((t=>a.columns.byIndex(t).stats.max)),o.Column.float("Avg",i).init((t=>a.columns.byIndex(t).stats.avg)),o.Column.float("Stdev",i).init((t=>a.columns.byIndex(t).stats.stdev))]);St(n.getWorksheet(Tt(r,v.OUTPUT)),s,a.columns.length+2,e>0?Math.ceil(t[e-1].root.clientHeight/20)+1:0)}else yield Pt(n,n.getWorksheet(Tt(r,v.OUTPUT)),i.root,a.columns.length+2,e>0?Math.ceil(t[e-1].root.clientHeight/20)+1:0)}const f=yield n.xlsx.writeBuffer();return new Blob([f],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"})})),this.exportConfig={supportedExtensions:this.defaultSupportedExportExtensions(),supportedFormats:this.defaultSupportedExportFormats(),export:this.defaultExport,filename:this.defaultExportFilename}}onFuncCallReady(){const t=Object.create(null,{onFuncCallReady:{get:()=>super.onFuncCallReady}});return It(this,void 0,void 0,(function*(){yield t.onFuncCallReady.call(this),this.basePath=`scripts/${this.funcCall.func.id}/view`,this.runningOnStart&&(yield this.doRun())}))}onAfterRun(t){const e=this.outputsTabsElem.panes.find((t=>"Input"!==t.name));return e&&(this.outputsTabsElem.currentPane=e),Promise.resolve()}replaceControlls(t){this.controllsDiv=t}getRunButton(t="Run"){const n=e.bigButton(t,(()=>It(this,void 0,void 0,(function*(){return yield this.doRun()})))),i=this.checkDisability.subscribe((()=>{const t=this.isRunnable();n.disabled=!t}));return this.subs.push(i),n}buildIO(){const t=this.buildInputBlock();e.tools.handleResize(t,(t=>{t<350?(R()(this.formTabsElem.getPane("Output").content).addClass("ui-form-condensed"),R()(this.formTabsElem.getPane("Input").content).addClass("ui-form-condensed")):(R()(this.formTabsElem.getPane("Output").content).removeClass("ui-form-condensed"),R()(this.formTabsElem.getPane("Input").content).removeClass("ui-form-condensed"))}));const n=this.buildOutputBlock();n.style.height="100%",n.style.width="100%",this.outputsTabsElem.root.style.display="none",this.outputsTabsElem.getPane("Input")&&this.outputsTabsElem.panes.forEach((t=>{t.header.style.display="none"}));const i=e.splitH([t,e.panel([n],{style:{"padding-top":"0px"}})],null,!0);return i.style.padding="0 12px",t.style.maxWidth="450px",i}buildInputBlock(){const t=this.renderInputForm(),n=this.renderOutputForm();if(this.formTabsElem=e.tabControl({Input:t,Output:n}),R()(this.formTabsElem.root).removeClass("ui-box"),R()(this.formTabsElem.root).css("flex-grow",0),R()(this.formTabsElem.getPane("Output").header).hide(),R()(this.formTabsElem.getPane("Input").header).hide(),this.controllsDiv=void 0,this.beforeRenderControlls.next(!0),!this.controllsDiv){const t=this.getRunButton(),n=e.div([t]),i=e.bigButton("Save",(()=>this.saveExperimentalRun(this.funcCall)),"Save uploaded data");R()(i).hide(),this.isUploadMode.subscribe((e=>{e?(R()(i).show(),R()(t).hide()):(R()(i).hide(),R()(t).show()),this.buildRibbonPanels()})),e.tooltip.bind(n,(()=>t.disabled?this.isRunning?"Computations are in progress":"Some inputs are invalid":"")),this.controllsDiv=e.buttonsInput([i,n]),R()(this.controllsDiv.children.item(1)).css("gap","0px"),this.controllsDiv.style.position="sticky"}const i=e.div(this.controllsDiv,"ui-form");return R()(i).css("padding","0px"),e.divV([this.formTabsElem.root,...this.runningOnInput?[]:[i]],"ui-box")}buildRibbonPanels(){super.buildRibbonPanels();const n=e.iconFA("play",(()=>It(this,void 0,void 0,(function*(){return yield this.doRun()}))),"Run computations");n.classList.add("fas");const i=e.iconFA("save",(()=>It(this,void 0,void 0,(function*(){this.isUploadMode.value?yield this.saveExperimentalRun(this.funcCall):this.lastCall?yield this.saveRun(this.lastCall):t.shell.warning("Function was not called. Call it before saving")}))),this.isUploadMode.value?"Save uploaded data":"Save the last run"),o=e.iconFA("arrow-to-top",(()=>It(this,void 0,void 0,(function*(){this.isUploadMode.next(!this.isUploadMode.value),b(this.func)?(yield t.functions.eval(b(this.func))).prepare().edit():(o.classList.toggle("d4-current"),this.isUploadMode.value?(R()(this.formTabsElem.getPane("Input").header).show(),R()(this.formTabsElem.getPane("Output").header).show()):(this.formTabsElem.currentPane=this.formTabsElem.getPane("Input"),R()(this.formTabsElem.getPane("Input").header).hide(),R()(this.formTabsElem.getPane("Output").header).hide()))}))),"Upload experimental data");o.classList.add("d4-toggle-button",...this.isUploadMode.value?["d4-current"]:[]);const s=[...this.getRibbonPanels(),[...this.runningOnInput||this.options.isTabbed?[]:[n],...this.hasUploadMode&&this.isUploadMode.value?[i]:[],...this.hasUploadMode?[o]:[]]];return this.setRibbonPanels(s),s}buildOutputBlock(){this.outputsTabsElem.root.style.width="100%",this.tabsLabels.forEach((n=>{const i=this.categoryToParamMap[n].filter((t=>t.propertyType===o.TYPE.DATA_FRAME)),s=this.categoryToParamMap[n].filter((t=>t.propertyType!==o.TYPE.DATA_FRAME)),r=i.map((t=>A(t).config)),a=i.reduce(((i,s,a)=>{var l;const d=r[a].map((e=>It(this,void 0,void 0,(function*(){var n,i,r,a;const l=null!==(a=null!==(i=null===(n=this.funcCall.outputs[s.name])||void 0===n?void 0:n.value)&&void 0!==i?i:null===(r=this.funcCall.inputParams[s.name])||void 0===r?void 0:r.value)&&void 0!==a?a:t.data.demo.demog(1),d=e.type,u=Object.values(h).includes(d)?o.Viewer.fromType(d,l):yield l.plot.fromType(d);return u.setOptions(e),this.dfToViewerMapping[s.name]?this.dfToViewerMapping[s.name].push(u):this.dfToViewerMapping[s.name]=[u],this.afterOutputPropertyRender.next({prop:s,output:u}),u})))).map((t=>t.then((t=>{const e=()=>{var e;const i=null!==(e=this.funcCall.outputParams[s.name])&&void 0!==e?e:this.funcCall.inputParams[s.name],o=i.onChanged.subscribe((()=>It(this,void 0,void 0,(function*(){if(R()(this.outputsTabsElem.root).show(),R()(this.outputsTabsElem.getPane(n).header).show(),Object.values(h).includes(t.type))t.dataFrame=i.value;else{const e=yield i.value.plot.fromType(t.type);t.root.replaceWith(e.root),t=e}this.afterOutputPropertyRender.next({prop:s,output:t})}))));this.subs.push(o)};return e(),this.subs.push(this.funcCallReplaced.subscribe(e)),t})))),u=null!==(l=s.options.caption)&&void 0!==l?l:s.name;if("Input"===n){const t=()=>{var t;const e=(null!==(t=this.funcCall.outputParams[s.name])&&void 0!==t?t:this.funcCall.inputParams[s.name]).onChanged.subscribe((()=>{R()(this.outputsTabsElem.root).show(),R()(this.outputsTabsElem.getPane("Input").header).show()}));this.subs.push(e)};t(),this.subs.push(this.funcCallReplaced.subscribe(t))}const c=d.map(((t,n)=>{const i=r[a][n].block,o=e.wait((()=>It(this,void 0,void 0,(function*(){return(yield t).root}))));return R()(o).css({"min-height":"300px","flex-grow":"1"}),e.divV([...0===n?[e.h2(u)]:[e.h2(" ",{style:{"white-space":"pre"}})],o],{style:Object.assign({},i?{width:`${i}%`,"max-width":`${i}%`}:{"flex-grow":"1"})})}));return i.append(...c),i}),e.divH([],{style:{"flex-wrap":"wrap","flex-grow":"1"}})),l=()=>{const t=o.HtmlTable.create(s,(t=>{var e;return[null!==(e=t.caption)&&void 0!==e?e:t.name,this.funcCall.outputs[t.name],t.options.units]})).root;return R()(t).css({"max-width":"400px"}),this.afterOutputSacalarTableRender.next(t),t};let d=l();s.forEach((t=>{const e=()=>{const e=this.funcCall.outputParams[t.name].onChanged.subscribe((()=>{const t=l();d.replaceWith(t),d=t}));this.subs.push(e)};e(),this.subs.push(this.funcCallReplaced.subscribe(e))})),this.outputsTabsElem.addPane(n,(()=>e.divV([...i.length?[a]:[],...s.length?[e.h2("Scalar values"),d]:[]])))}));const n=e.box();return n.append(this.outputsTabsElem.root),n}onAfterLoadRun(t){return It(this,void 0,void 0,(function*(){r()(this.funcCall.outputParams.values()).forEach((e=>{this.funcCall.setParamValue(e.name,t.outputs[e.name])})),r()(this.funcCall.inputParams.values()).forEach((e=>{this.funcCall.setParamValue(e.name,t.inputs[e.name])})),this.outputsTabsElem.root.style.removeProperty("display"),this.outputsTabsElem.panes.forEach((t=>{t.header.style.removeProperty("display")}))}))}get isInputPanelRequired(){var t;return(null===(t=this.func)||void 0===t?void 0:t.inputs.some((t=>t.propertyType==o.TYPE.DATA_FRAME&&null!=t.options.viewer)))||!1}get tabsLabels(){return Object.keys(this.categoryToParamMap)}get categoryToParamMap(){const t={};return this.isInputPanelRequired&&this.func.inputs.filter((t=>t.propertyType==o.TYPE.DATA_FRAME&&null!=t.options.viewer)).forEach((e=>t.Input?t.Input.push(e):t.Input=[e])),this.func.outputs.forEach((e=>{const n="Misc"===e.category?"Output":e.category;t[n]?t[n].push(e):t[n]=[e]})),t}doRun(){return It(this,void 0,void 0,(function*(){this.isRunning=!0,this.checkDisability.next();try{yield this.run()}catch(e){t.shell.error(e)}finally{this.isRunning=!1,this.checkDisability.next()}}))}renderOutputForm(){const n=e.divV([],"ui-form");let i="Misc";return r()(this.funcCall.outputParams.values()).filter((t=>!!t)).forEach((s=>{var r,a,l;const d=s.property;if(d.propertyType.toString()===Rt){const t=ut.fileInput(null!==(r=d.caption)&&void 0!==r?r:d.name,null,(t=>{this.funcCall.outputs[d.name]=t}));d.category!==i&&n.append(e.h2(d.category)),n.append(t.root)}else{const r=d.propertyType===o.TYPE.DATA_FRAME?e.tableInput(null!==(a=d.caption)&&void 0!==a?a:d.name,null,t.shell.tables):e.input.forProperty(d);r.captionLabel.firstChild.replaceWith(e.span([null!==(l=d.caption)&&void 0!==l?l:d.name])),d.options.units&&r.addPostfix(d.options.units),r.onChanged((()=>{this.funcCall.outputs[s.name]=r.value,null===r.value?setTimeout((()=>r.input.classList.add("d4-invalid")),100):r.input.classList.remove("d4-invalid")})),d.category!==i&&n.append(e.h2(d.category)),n.append(r.root)}i=d.category})),n.classList.remove("ui-panel"),n.style.paddingTop="0px",n.style.paddingLeft="0px",n}renderInputForm(){const n=e.divV([],"ui-form");let i="Misc";if(r()(this.funcCall.inputParams.values()).filter((t=>!!t)).forEach((s=>{var r,a,l;const d=s.property;if(this.beforeInputPropertyRender.next(d),d.propertyType.toString()===Rt){const t=ut.fileInput(null!==(r=d.caption)&&void 0!==r?r:d.name,null,(t=>{this.funcCall.inputs[d.name]=t,this.checkDisability.next()}));d.category!==i&&n.append(e.h2(d.category)),n.append(t.root),this.afterInputPropertyRender.next({prop:d,input:t})}else{const r=d.propertyType===o.TYPE.DATA_FRAME?e.tableInput(null!==(a=d.caption)&&void 0!==a?a:d.name,null,t.shell.tables):e.input.forProperty(d);r.input.onkeydown=t=>It(this,void 0,void 0,(function*(){"Enter"==t.key&&(yield this.doRun())})),r.captionLabel.firstChild.replaceWith(e.span([null!==(l=d.caption)&&void 0!==l?l:d.name])),d.options.units&&r.addPostfix(d.options.units),this.syncFuncCallReplaced(r,s),this.syncOnInput(r,s),this.syncValOnChanged(r,s),this.runningOnInput&&this.runOnInput(r,s),d.category!==i&&n.append(e.h2(d.category)),n.append(r.root),this.afterInputPropertyRender.next({prop:d,input:r})}i=d.category})),this.controllsDiv=void 0,this.beforeRenderControlls.next(!0),!this.controllsDiv){const t=this.getRunButton(),n=e.div([t]);e.tooltip.bind(n,(()=>t.disabled?this.isRunning?"Computations are in progress":"Some inputs are invalid":"")),this.controllsDiv=e.buttonsInput([n])}return n.classList.remove("ui-panel"),n.style.paddingTop="0px",n.style.paddingLeft="0px",this.checkDisability.next(),n}syncFuncCallReplaced(t,e){const n=e.property,i=this.funcCallReplaced.pipe((0,Z.startWith)(!0)).subscribe((()=>{var i,s;const r=null!==(s=null!==(i=this.funcCall.inputs[e.name])&&void 0!==i?i:n.defaultValue)&&void 0!==s?s:null;e.property.propertyType===o.TYPE.DATA_FRAME?this.dfInputRecreate(t,e,r):(t.value=r,this.funcCall.inputs[e.name]=r)}));this.subs.push(i)}syncValOnChanged(t,e){const n=e.onChanged.subscribe((()=>{const n=this.funcCall.inputs[e.name];e.property.propertyType===o.TYPE.DATA_FRAME?this.dfInputRecreate(t,e,n):("number"==typeof n&&Math.abs(t.value-n)>1e-4||"number"!=typeof n)&&(t.notify=!1,t.value=n,t.notify=!0),this.checkDisability.next()}));this.subs.push(n)}isRunnable(){return r()(this.funcCall.inputs.values()).every((t=>null!=t))&&!this.isRunning}saveExperimentalRun(e){return It(this,void 0,void 0,(function*(){const n=yield(yield t.functions.eval("Sin")).prepare({x:1}).call();e.dart.r2=n.dart.r2;let i=e.options.tags;i=i?i.push(g):[g],e.options.tags=i,yield this.saveRun(e)}))}dfInputRecreate(n,i,o){var s;const r=i.property,a=e.tableInput(null!==(s=r.caption)&&void 0!==s?s:r.name,o,[...t.shell.tables,o]);n.root.replaceWith(a.root),n=a,this.syncOnInput(n,i),this.runningOnInput&&this.runOnDgInput(n,i),this.afterInputPropertyRender.next({prop:r,input:n})}syncOnInput(t,e){t.onInput((()=>{this.funcCall.inputs[e.name]=t.value,null===t.value?setTimeout((()=>t.input.classList.add("d4-invalid")),100):t.input.classList.remove("d4-invalid"),this.checkDisability.next()}))}runOnInput(t,e){t.onInput((()=>It(this,void 0,void 0,(function*(){this.isRunnable()&&(yield this.doRun())}))))}runOnDgInput(t,e){t.onInput((()=>It(this,void 0,void 0,(function*(){return yield this.doRun()}))));const n=t.value;if(n){const t=n.onDataChanged.subscribe((()=>It(this,void 0,void 0,(function*(){this.isRunnable()&&(yield this.doRun())}))));this.subs.push(t)}}}const Tt=(t,e)=>{const n=`${e} - ${t}`;return n.length>31?t.substring(0,32):n},Ft=(t,e)=>{t.addRow(["Parameter","Value","Units"]).font={bold:!0},e.forEach((e=>{t.addRow([e.caption,e.value,e.units])})),t.getColumn(1).width=1.2*Math.max(...e.map((t=>t.caption.toString().length)),9),t.getColumn(2).width=1.2*Math.max(...e.map((t=>t.value.toString().length)),5),t.getColumn(3).width=1.2*Math.max(...e.map((t=>t.units.toString().length)),5)},St=(t,e,n=0,i=0)=>{for(let o=0;o<e.columns.names().length;o++)t.getCell(1+i,1+o+n).value=e.columns.byIndex(o).name,t.getColumn(1+o+n).width=1.2*Math.max(...e.columns.byIndex(o).categories.map((t=>t.toString().length)),e.columns.byIndex(o).name.length);for(let o=0;o<e.columns.length;o++)for(let s=0;s<e.rowCount;s++)t.getCell(s+2+i,1+n+o).value=e.columns.byIndex(o).get(s)},Pt=(t,e,n,i,o=0)=>It(void 0,void 0,void 0,(function*(){const s=yield Ct()(n,{logging:!1}),r=s.toDataURL("image/png"),a=t.addImage({base64:r,extension:"png"});e.addImage(a,{tl:{col:i,row:o},ext:{width:s.width,height:s.height}})}));var Bt=n(433),kt={};kt.styleTagTransform=W(),kt.setAttributes=L(),kt.insert=M().bind(null,"head"),kt.domAPI=O(),kt.insertStyleElement=j(),B()(Bt.Z,kt),Bt.Z&&Bt.Z.locals&&Bt.Z.locals;class Ot{constructor(){this.scriptName="",this.description="",this.dfSheetsToSeek=[],this.scalarsToSeek=[],this.scriptText=new p.BehaviorSubject(""),this.infoText=new p.BehaviorSubject(""),this.lastSavedScriptId=new p.BehaviorSubject("")}}var Vt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class Mt extends o.ViewBase{constructor(){super(),this.store=new Ot,this.scriptNameInput=e.stringInput("Script name","",(t=>this.store.scriptName=t)),this.descriptionInput=e.stringInput("Description","",(t=>this.store.description=t));const t=e.bigButton("Generate script",(()=>Vt(this,void 0,void 0,(function*(){return yield this.generate()})))),n=e.bigButton("Save",(()=>Vt(this,void 0,void 0,(function*(){return yield this.save()})))),i=e.bigButton("Open",(()=>Vt(this,void 0,void 0,(function*(){return this.open()}))));i.style.display="none",this.store.lastSavedScriptId.subscribe((t=>{""!==t&&i.style.removeProperty("display")}));const o=t=>{const n=e.button("Remove",(()=>{}));n.style.width=n.style.height,n.style.alignSelf="center",this.store.dfSheetsToSeek.push("");const i=e.divH([e.stringInput(`Sheet name #${t}`,"",(e=>this.store.dfSheetsToSeek[t]=e)).root,n],{style:{"justify-content":"space-between"}});return n.addEventListener("click",(()=>{this.store.dfSheetsToSeek.splice(t,1),i.remove()})),i},s=t=>{const n=e.button("Remove",(()=>{}));n.style.width=n.style.height,n.style.alignSelf="center",this.store.scalarsToSeek.push("");const i=e.divH([e.stringInput(`Scalar name #${t}`,"",(e=>this.store.scalarsToSeek[t]=e)).root,n],{style:{"justify-content":"space-between"}});return n.addEventListener("click",(()=>{this.store.scalarsToSeek.splice(t,1),i.remove()})),i},r=e.divV([]),a=e.button("Add DF to search",(()=>{r.append(o(this.store.dfSheetsToSeek.length))})),l=e.divV([]),d=e.button("Add scalar to search",(()=>{l.append(s(this.store.scalarsToSeek.length))})),u=e.divV([e.h3("Script properties"),this.scriptNameInput.root,this.descriptionInput.root,e.h3("Dataframes to search"),r,a,e.h3("Scalars to search"),l,d,e.divH([t],{style:{"justify-content":"flex-end"}})],"ui-form");let c=e.divText(this.store.scriptText.value),p=e.info(this.store.infoText.value);const h=e.panel([e.h3("Script text"),c,p,e.divH([n,i],{style:{"justify-content":"flex-end"}})],{style:{display:"none"}});this.store.scriptText.subscribe((t=>{const n=e.divText(t);c.replaceWith(n),c=n,""!==t&&h.style.removeProperty("display")})),this.store.infoText.subscribe((t=>{const n=""===t?e.div([]):e.info(t);p.replaceWith(n),p=n})),this.root.appendChild(e.splitH([u,h],{style:{height:"100%",width:"100%"}},!0)),e.tools.handleResize(u.parentElement,(t=>{t<350?u.classList.add("ui-form-condensed"):u.classList.remove("ui-form-condensed")})),u.parentElement.style.maxWidth="340px"}generate(){return Vt(this,void 0,void 0,(function*(){const e=this.store.dfSheetsToSeek.map((t=>`//output: dataframe ${t.trim()} { viewer: Grid(); }`)).join("\n"),n=this.store.scalarsToSeek.map((t=>`//output: string ${t.trim()}`)).join("\n"),i=`\nconst wb = new ExcelJS.Workbook();\nawait wb.xlsx.load(await uploadedFile.arrayBuffer());\nconst dfSheetsToSeek = ["${this.store.dfSheetsToSeek.join('","')}"];`;let o=`//name: ${this.store.scriptName}\n`;o+=`//description: ${this.store.description}\n`,o+="//language: javascript\n",o+="//input: file uploadedFile\n",o+=n+"\n",o+=e+"\n",o+="//editor: Compute:FunctionViewEditor\n",o+=i+"\n",this.store.dfSheetsToSeek.forEach((t=>{o+=(t=>`\nconst ${t}_ws = wb.getWorksheet("${t}");\nlet ${t}_data = await ${t}_ws.workbook.csv.writeBuffer();\n${t} = grok.data.parseCsv(${t}_data.toString());`)(t.trim())+"\n"})),o+="\nconst scalarSheets = wb.worksheets.filter(ws => !dfSheetsToSeek.includes(ws.name));\nconst scalarNames = scalarSheets.flatMap((sheet) => sheet.getColumn(1).values);\nconst scalarValues = scalarSheets.flatMap((sheet) => sheet.getColumn(2).values);",this.store.scalarsToSeek.forEach((t=>{var e;o+=`\nconst ${e=t}_index = scalarNames.findIndex((scalarName) => scalarName === "${e}");\n${e} = (${e}_index >= 0) ? scalarValues[${e}_index] : '';\n`})),this.store.scriptText.next(o),(yield t.dapi.scripts.filter(`name="${this.store.scriptName}"`).list()).length>0?this.store.infoText.next(`Script named "${this.store.scriptName}" already exists`):this.store.infoText.next("")}))}save(){return Vt(this,void 0,void 0,(function*(){const e=o.Script.create(this.store.scriptText.value),n=yield t.dapi.scripts.save(e);this.store.lastSavedScriptId.next(n.id),t.shell.info(`Script "${this.store.scriptName}" has been saved successfully`)}))}open(){window.open(`${window.location.origin}/script/${this.store.lastSavedScriptId.value}`)}}var _t=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let Lt=!1;const Dt=new o.Package;function jt(t){u.openModelFromFunccall(t)}function Nt(){const e=new Mt;e.name="Import Script Gen",t.shell.addView(e),e.root.classList.remove("ui-panel")}function Wt(){return new c}function $t(t){return Et.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}function Ut(t){return Et.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}function Ht(t){return function(t){let n=o.View.create(),i=e.div(),s=e.stringInput("Function",t.name);function r(){n.name=t.name,e.empty(i);let s=o.DataFrame.fromProperties(t.inputs.concat(t.outputs),5),r=o.Grid.create(s),a=!1;r.onCellValueEdited.subscribe((e=>{var n;return function(e){for(let n=0;n<t.inputs.length;n++)if(s.columns.byIndex(n).isNone(e))return;let n={};for(let i of t.inputs)n[i.name]=s.col(i.name).get(e);a=!0;let i=t.prepare(n);i.call().then((n=>{for(let n of t.outputs)s.col(n.name).set(e,i.outputs[n.name]);a=!1}))}(null===(n=e.tableRow)||void 0===n?void 0:n.idx)})),i.appendChild(r.root)}return n.root.appendChild(s.root),n.root.appendChild(i),r(),s.onChanged((()=>{o.Func.findAll({name:s.value}).then((e=>{1==e.length&&(t=e[0],r())}))})),n}(t)}function Gt(){console.log("hof");let e=Ht(o.Func.byName("Sin"));e.parentCall=t.functions.getCurrentCall(),t.shell.addView(e)}function Yt(){var n,i,s;console.log("hof2");let r=Ht(o.Func.byName("Sin"));r.root.appendChild(e.narrowForm([e.switchInput("test",!0),e.boolInput("test",!0)])),r.root.appendChild(e.form([e.switchInput("test",!0),e.boolInput("test",!0)])),r.parentCall=t.functions.getCurrentCall(),r.parentView=null===(n=r.parentCall.parentCall)||void 0===n?void 0:n.aux.view,null===(i=r.parentCall.parentCall)||void 0===i||i.aux.url,null===(s=r.parentCall)||void 0===s||s.aux.url,r.basePath="/"+r.parentCall.func.name,r.path="/",t.shell.addView(r)}function zt(n){return _t(this,void 0,void 0,(function*(){let i={};n.inputs.forEach((t=>i[t.name]=null));let s=`\ncurl --location --request POST '${t.settings.apiUrl}/v1/func/${n.nqName}/run' \\\n--header 'Authorization: ${Zt("auth")}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '${JSON.stringify(i)}'`,r=`\nvar myHeaders = new Headers();\nmyHeaders.append("Authorization", "${Zt("auth")}");\nmyHeaders.append("Content-Type", "application/json");\n\nvar raw = JSON.stringify(${JSON.stringify(i)});\n\nvar requestOptions = {\n method: 'POST',\n headers: myHeaders,\n body: raw,\n redirect: 'follow'\n};\n\nfetch("${t.settings.apiUrl}/v1/func/${n.nqName}/run", requestOptions)\n .then(response => response.text())\n .then(result => console.log(result))\n .catch(error => console.log('error', error));`,a=e.tabControl({CURL:e.div([e.divText(s)]),JS:e.div([e.divText(r)])});return o.Widget.fromRoot(a.root)}))}function Zt(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}function qt(){}function Xt(){Lt||(o.ObjectHandler.register(new u),t.events.onAccordionConstructed.subscribe((t=>{const n=t.context;null!=n&&"script"==n.type&&(t.getPane("REST")||t.addPane("REST",(()=>e.wait((()=>_t(this,void 0,void 0,(function*(){return(yield zt(n)).root})))))))})),Lt=!0)}function Jt(){let e=u.findModelCatalogView();if(null==e){let e=new l;e.name="ModelHub";let n=document.createElement("a");n.href=window.location.href;let i=n.pathname.split("/");t.shell.addView(e),i.length>3&&t.dapi.functions.filter(`shortName = "${i[3]}" and #model`).list().then((t=>{1==t.length&&u.openModel(t[0])}))}else t.shell.v=e}})(),compute=i})();
|
|
1
|
+
var compute;(()=>{"use strict";var t={903:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".pipeline-view .d4-ribbon-name.selected {\n color: #104161;\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/pipeline-view.css"],names:[],mappings:"AAAA;EACE,cAAc;AAChB;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,oBAAoB;AACtB",sourcesContent:[".pipeline-view .d4-ribbon-name.selected {\n color: #104161;\n}\n\n.pipeline-view .d4-ribbon-name {\n color: var(--blue-1);\n margin: 12px 6px;\n font-weight: normal;\n}\n\n.pipeline-view .d4-ribbon-name + .d4-ribbon-name::before {\n color: var(--grey-3);\n}\n\n.pipeline-view .d4-ribbon-name.d4-disabled {\n cursor: default;\n pointer-events: none;\n color: var(--grey-3);\n}\n"],sourceRoot:""}]);const a=r},751:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".ui-input-root > input.ui-input-editor.disabled:focus {\n outline: none;\n border-bottom: 1px solid var(--grey-2)!important;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/function-views/css/rich-function-view.css"],names:[],mappings:"AAAA;IACI,aAAa;IACb,gDAAgD;AACpD",sourcesContent:[".ui-input-root > input.ui-input-editor.disabled:focus {\n outline: none;\n border-bottom: 1px solid var(--grey-2)!important;\n}\n"],sourceRoot:""}]);const a=r},669:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".cv-drop-area {\n position: relative;\n}\n\n.ui-form .cv-drop-area .icon {\n\tpadding-top: 10px;\n}\n\n.ui-form-condensed .cv-drop-area .icon {\n\tpadding-top: 0px;\n position: absolute;\n top: 35px;\n right: 10px;\n}\n\n.cv-drop-area .default {\n color: var(--grey-2);\n}\n\n.cv-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.cv-drop-area .error {\n color: var(--red-3);\n}\n\n.cv-drop-area .success {\n color: var(--grey-6);\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/file-input.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;CACC,iBAAiB;AAClB;;AAEA;CACC,gBAAgB;EACf,kBAAkB;EAClB,SAAS;EACT,WAAW;AACb;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,gCAAgC;EAChC,gCAAgC;EAChC,oBAAoB;AACtB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,oBAAoB;AACtB",sourcesContent:[".cv-drop-area {\n position: relative;\n}\n\n.ui-form .cv-drop-area .icon {\n\tpadding-top: 10px;\n}\n\n.ui-form-condensed .cv-drop-area .icon {\n\tpadding-top: 0px;\n position: absolute;\n top: 35px;\n right: 10px;\n}\n\n.cv-drop-area .default {\n color: var(--grey-2);\n}\n\n.cv-drop-area .drag-n-dropping {\n background-color: var(--steel-1);\n border: 1px dashed var(--blue-1);\n color: var(--grey-3);\n}\n\n.cv-drop-area .error {\n color: var(--red-3);\n}\n\n.cv-drop-area .success {\n color: var(--grey-6);\n}\n"],sourceRoot:""}]);const a=r},380:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,'.no-elements-label {\n margin: 8px;\n}\n\n.arrow-box {\n position: relative;\n}\n\n.arrow-box:before {\n left: -6px;\n top: 55px;\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n background-color: white;\n\n transform-origin: center;\n transform: rotate(-135deg);\n box-shadow: -4px 4px 0px 4.5px white, #4d5261 0px 0px 5px;;\n\n border: 5px solid black;\n border-color: transparent transparent #FFFFFF #FFFFFF;\n\n margin-top: -21px;\n}\n',"",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/history-input.css"],names:[],mappings:"AAAA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,WAAW;IACX,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,oBAAoB;IACpB,uBAAuB;;IAEvB,wBAAwB;IACxB,0BAA0B;IAC1B,yDAAyD;;IAEzD,uBAAuB;IACvB,qDAAqD;;IAErD,iBAAiB;AACrB",sourcesContent:['.no-elements-label {\n margin: 8px;\n}\n\n.arrow-box {\n position: relative;\n}\n\n.arrow-box:before {\n left: -6px;\n top: 55px;\n content: "";\n height: 0;\n width: 0;\n position: absolute;\n pointer-events: none;\n background-color: white;\n\n transform-origin: center;\n transform: rotate(-135deg);\n box-shadow: -4px 4px 0px 4.5px white, #4d5261 0px 0px 5px;;\n\n border: 5px solid black;\n border-color: transparent transparent #FFFFFF #FFFFFF;\n\n margin-top: -21px;\n}\n'],sourceRoot:""}]);const a=r},778:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,".hp-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px 12px 5px 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n}\n\n.hp-funccall-card-def-icon {\n display: flex;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-def-icon {\n display: none;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card-def-icon {\n margin: 5px;\n}\n\n.hp-funccall-card-icon {\n margin: 5px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/compute-utils/shared-components/css/history-panel.css"],names:[],mappings:"AAAA;IACI,+BAA+B;IAC/B,eAAe;AACnB;;AAEA;IACI,eAAe;IACf,yBAAyB;IACzB,8BAA8B;AAClC;;AAEA;IACI,+BAA+B;AACnC;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,6BAA6B;IAC7B,gBAAgB;AACpB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,kBAAkB;IAClB,oBAAoB;AACxB;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;AACpB;;AAEA;IACI,oBAAoB;IACpB,YAAY;AAChB",sourcesContent:[".hp-funccall-card:hover {\n box-shadow: 0px 0px 3px #b8bac0;\n cursor: pointer;\n}\n\n.hp-funccall-card {\n margin: 2px 1px;\n padding: 5px 12px 5px 5px;\n justify-content: space-between;\n}\n\n.hp-funccall-card.clicked {\n border: 1px solid var(--blue-1);\n}\n\n.hp-funccall-card-hover-icon {\n display: none;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-hover-icon {\n display: flex;\n}\n\n.hp-funccall-card-def-icon {\n display: flex;\n}\n\n.hp-funccall-card:hover .hp-funccall-card-def-icon {\n display: none;\n}\n\n.hp-funccall-card .hp-card-content {\n justify-content: space-around;\n margin-left: 5px;\n}\n\n.hp-funccall-card .hp-card-content * {\n margin-bottom: 3px;\n}\n\n.hp-funccall-card-def-icon {\n margin: 5px;\n}\n\n.hp-funccall-card-icon {\n margin: 5px;\n}\n\n.hp-funccall-card .description {\n margin-bottom: 2px;\n color: var(--grey-3);\n}\n\n.hp-funccall-card .date {\n color: var(--grey-3);\n margin-left: 5px;\n}\n\n.grok-icon.hp-disabled {\n pointer-events: none;\n opacity: 0.6;\n}\n"],sourceRoot:""}]);const a=r},433:(t,e,n)=>{n.d(e,{Z:()=>a});var i=n(864),o=n.n(i),s=n(352),r=n.n(s)()(o());r.push([t.id,'.model-catalog-view .d4-gallery-card.entity-model i {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}',"",{version:3,sources:["webpack://./src/css/model-card.css"],names:[],mappings:"AAAA;IACI,YAAY;IACZ,WAAW;IACX,iBAAiB;IACjB,cAAc;AAClB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;AACvB;;AAEA;IACI,cAAc;IACd,mBAAmB;IACnB,aAAa;IACb,SAAS;IACT,YAAY;AAChB;;AAEA;IACI,6BAA6B;AACjC;;AAEA;IACI,WAAW;IACX,YAAY;IACZ,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;AACpB;;AAEA;IACI,gBAAgB;IAChB,kBAAkB;IAClB,oBAAoB;IACpB,aAAa;IACb,cAAc;AAClB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,eAAe;IACf,cAAc;IACd,oBAAoB;AACxB;;AAEA;IACI,UAAU;IACV,SAAS;IACT,mBAAmB;IACnB,qBAAqB;IACrB,+BAA+B;IAC/B,kBAAkB;IAClB,sBAAsB;IACtB,4BAA4B;AAChC;;AAEA;IACI,kBAAkB;IAClB,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAAM;IACN,aAAa;IACb,mBAAmB;IACnB,uBAAuB;IACvB,gBAAgB;IAChB,oBAAoB;IACpB,eAAe;AACnB;;AAEA;IACI,oBAAoB;AACxB;;AAEA;IACI,mBAAmB;AACvB",sourcesContent:['.model-catalog-view .d4-gallery-card.entity-model i {\n height: 64px;\n width: 64px;\n position: initial;\n flex-shrink: 0;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model .d4-link-label i.grok-icon + label {\n margin-left: 6px;\n align-items: center;\n display: inline-flex;\n white-space: normal;\n}\n\n.model-catalog-view .d4-gallery-card.entity-model {\n padding: 0 8px;\n align-items: center;\n display: flex;\n margin: 0;\n height: 94px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid {\n flex-direction: row!important;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label i.grok-icon {\n width: 32px;\n height: 32px;\n position: initial;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .d4-link-label label {\n margin-left: 8px;\n}\n\n.model-catalog-view .grok-gallery-grid[mode="Brief"] .grok-gallery-grid .d4-link-label {\n min-width: 250px;\n margin-bottom: 9px;\n color: var(--grey-6);\n padding: 10px;\n width: initial;\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 20px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-node {\n font-size: 16px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-view .d4-tree-view-root > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group > .d4-tree-view-group-host > .d4-tree-view-group .d4-tree-view-node {\n font-size: 14px;\n padding: 4px 0;\n color: var(--grey-6);\n}\n\n.model-catalog-video {\n width: 80%;\n height: 0;\n padding-bottom: 50%;\n margin: 10px 10px 0 0;\n border: 1px solid var(--grey-2);\n position: relative;\n background-size: cover;\n background-repeat: no-repeat;\n}\n\n.model-catalog-video i {\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n font-weight: 600;\n color: var(--grey-2);\n font-size: 42px;\n}\n\n.model-catalog-video i:hover {\n color: var(--grey-1);\n}\n\n.model-catalog-description {\n padding: 10px 0 0 0;\n}'],sourceRoot:""}]);const a=r},352:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,s){"string"==typeof t&&(t=[[null,t,void 0]]);var r={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(r[l]=!0)}for(var d=0;d<t.length;d++){var u=[].concat(t[d]);i&&r[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),n&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=n):u[2]=n),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),e.push(u))}},e}},864:t=>{t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(o," */");return[e].concat([s]).join("\n")}return[e].join("\n")}},701:t=>{var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var s={},r=[],a=0;a<t.length;a++){var l=t[a],d=i.base?l[0]+i.base:l[0],u=s[d]||0,c="".concat(d," ").concat(u);s[d]=u+1;var p=n(c),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var f=o(h,i);i.byIndex=a,e.splice(a,0,{identifier:c,updater:f,references:1})}r.push(c)}return r}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var s=i(t=t||[],o=o||{});return function(t){t=t||[];for(var r=0;r<s.length;r++){var a=n(s[r]);e[a].references--}for(var l=i(t,o),d=0;d<s.length;d++){var u=n(s[d]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}s=l}}},80:t=>{var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},182:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},850:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},236:t=>{t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var s=n.sourceMap;s&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},213:t=>{t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var s=e[i]={id:i,exports:{}};return t[i](s,s.exports,n),s.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{n.r(i),n.d(i,{OutliersSelection:()=>Nt,PipelineStepEditor:()=>$t,RichFunctionViewEditor:()=>Wt,_package:()=>Lt,autostart:()=>Zt,functionParametersGrid:()=>Ht,hof:()=>Ut,hof2:()=>Gt,importScriptGenerator:()=>jt,init:()=>qt,modelCatalog:()=>Xt,openModelFromFuncall:()=>Dt,renderRestPanel:()=>Yt});const t=grok,e=ui,o=DG,s=wu;var r=n.n(s);let a;class l extends o.CustomCardView{constructor(){super({dataSource:t.dapi.functions,permanentFilter:"#model"}),this.root.classList.add("model-catalog-view"),this.meta=new u,this.name="Models",this.permanentFilter="#model",this.renderMode=o.RENDER_MODE.BRIEF,this.objectType="Func",this.categoryFilters={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process",tag:"Tags"},this.filters={All:"",Favorites:"starredBy = @current","Used by me":"usedBy = @current"},this.hierarchy=["options.department","options.HL_process","options.process"],this.hierarchyProperties={"options.department":"Department","options.HL_process":"HL_process","options.process":"Process"},this.showTree=!0,this.initRibbon(),this.initMenu(),this.currentCall=t.functions.getCurrentCall(),null==a&&null==window.localStorage.getItem("ModelCatalogShowProperties")&&(a=t.events.onCurrentObjectChanged.subscribe((e=>{(new u).isApplicable(e.sender)&&(t.shell.windows.showProperties=!0,window.localStorage.setItem("ModelCatalogShowProperties","false"),a.unsubscribe())})))}initRibbon(){this.setRibbonPanels([[e.icons.sync((()=>this.refresh()))]])}initMenu(){this.ribbonMenu.group("Help").item("Compute Engine",(()=>window.open("https://github.com/datagrok-ai/public/tree/master/packages/Compute","_blank"))).item("Developing Models",(()=>window.open("https://datagrok.ai/help/compute/scripting","_blank"))).endGroup()}setCurrentModel(t){let n=o.View.forObject(t),i=this.root.querySelector(".grok-gallery-grid");e.empty(i),i.appendChild(n.root)}}var d=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class u extends o.ObjectHandler{get type(){return"Model"}getById(e){return d(this,void 0,void 0,(function*(){return yield t.dapi.functions.find(e)}))}refresh(t){return d(this,void 0,void 0,(function*(){return yield this.getById(t.id)}))}getLanguageIcon(t){return"grok"==t?e.iconSvg("project"):e.iconImage("script",`/images/entities/${t}.png`)}isApplicable(t){return t instanceof o.Func&&t.hasTag("model")}getVideoBackgroundUrl(t){let e=t.options["video-preview"];if(null==e)return"";if(e.startsWith("http://")||e.startsWith("https://"))return e;if(t instanceof o.Script)return null!=t.options.icon?`${t.options.icon.substring(0,t.options.icon.lastIndexOf("/"))}/${e}`:"";let n=t.package.getIconUrl();return n=n.substring(0,n.lastIndexOf("/")),`${n}/${e}`}renderIcon(t,n=null){if(null!=t.options.icon&&(t.options.icon.startsWith("http://")||t.options.icon.startsWith("https://")))return e.iconImage("model-icon",t.options.icon);if(t instanceof o.Script)return this.getLanguageIcon(t.language);let i=(t=o.Func.find({package:t.package.name,name:t.name})[0]).package.getIconUrl();if(null!=t.options.icon){let e=i.split("/");e.pop(),e.push(t.options.icon),i=e.join("/")}return e.iconImage(t.package.name,i)}renderMarkup(t){let n=e.span([this.renderIcon(t),e.label(t.friendlyName)]);return n.ondblclick=e=>{u.openModel(t)},n}renderPreview(e){const n=Object.create(null,{renderPreview:{get:()=>super.renderPreview}});var i;return d(this,void 0,void 0,(function*(){const s=null!==(i=e.options.editor)&&void 0!==i?i:"Compute:RichFunctionEditor",r=yield t.functions.find(s);if(null!==r&&r instanceof o.Func){console.log(r);const t=r.prepare({call:e.prepare()});yield t.call(!1,void 0,{processed:!0});const n=t.getOutputParamValue();if(n instanceof o.View)return n}return n.renderPreview.call(this,e)}))}renderProperties(t){const n=e.accordion("ComputeModel");n.context=t;let i=e.div([e.span([this.renderIcon(t),e.label(t.friendlyName),e.contextActions(t),e.star(t.id)])]);if(n.addTitle(i),null!=t.description&&i.appendChild(e.div([e.markdown(t.description)],"model-catalog-description")),i.appendChild(e.tags(t)),null!=t.options["dev.status"]&&i.appendChild(e.tableFromMap({Status:t.options["dev.status"]})),null!=t.options.video||null!=t.options.education){let i=e.link("Education materials",t.options.education);e.setDisplay(i,null!=t.options.education);let o=e.div(e.icons.play((()=>{window.open(t.options.video,"_blank")})),"model-catalog-video");e.setDisplay(o,null!=t.options.video),o.style.backgroundImage=`url('${this.getVideoBackgroundUrl(t)}')`,n.addPane("Documentation",(()=>e.divV([i,o],{style:{lineHeight:"150%"}})),!0)}return n.end(),n.root}renderDetails(t){let n=e.markdown(`**Status:** ${t.options["dev.status"]}`);return e.setDisplay(n,null!=t.options["dev.status"]),e.divV([e.markdown(`**Description: ** ${t.description}`),n,e.markdown("**Tags:**"),e.tags(t),e.markdown("**Documentation:**")],{style:{lineHeight:"150%"}})}renderTooltip(t){let n=this.renderMarkup(t);n.classList.add("d4-link-label");let i=e.bind(t,e.divV([e.h2(n),e.divV([e.divText(t.description,"ui-description")],{style:{lineHeight:"150%"}})]));return i.ondblclick=e=>{u.openModel(t)},i}renderCard(t,n){let i=this.renderMarkup(t);i.classList.add("d4-link-label");let o=e.bind(t,e.h2(i));return o.ondblclick=e=>{u.openModel(t)},o}static getModelCatalogView(){let e=this.findModelCatalogView();if(null==e){let e=o.Func.find({package:"Compute",name:"ModelCatalog"})[0].prepare(),n=new l;n.name="Models",n.parentCall=e,t.shell.addView(n)}return e=this.findModelCatalogView(),e}static findModelCatalogView(){return r()(t.shell.views).find((t=>{var e;return"modelCatalog"==(null===(e=t.parentCall)||void 0===e?void 0:e.func.name)}))}static openModel(t){t.prepare().edit()}static openModelFromFunccall(t){t.edit()}static bindModel(t){let e=u.getModelCatalogView();if(t.aux.showOnTaskBar=!1,null!=e){let n=e.parentCall;null!=n&&(n.aux.view=e,t.parentCall=n)}}init(){setTimeout((()=>{t.functions.onBeforeRunAction.subscribe((t=>{(t.func.hasTag("model")||t.func.hasTag("model-editor"))&&u.bindModel(t)}))}))}}class c extends o.JsViewer{constructor(){super()}onFrameAttached(t){this.render()}onTableAttached(){this.render()}render(){if(!this.dataFrame||this.dataFrame.rowCount<=0)return void(this.root.innerHTML="");const t=this.dataFrame,n="isOutlier",i="Rationale",s="Count",r="isConfirmed";t.columns.byName(n)||t.columns.add(o.Column.fromBitSet(n,o.BitSet.create(t.rowCount,(()=>!1)))),t.columns.byName(i)||t.columns.add(o.Column.fromStrings(i,Array.from({length:t.rowCount},(()=>""))));const a=()=>o.DataFrame.fromColumns([o.Column.fromStrings(i,[]),o.Column.fromInt32Array(s,new Int32Array([])),o.Column.fromStrings("Actions",[]),o.Column.fromBitSet(r,o.BitSet.create(0,(()=>!1)))]),l=o.Viewer.grid(a());l.root.style.width="100%",l.root.style.minWidth="230px",l.columns.setVisible([i,s,"Actions"]),l.onCellPrepare((s=>{var a,d,u;s.isTableCell&&("Actions"===s.gridColumn.name&&(s.gridColumn.cellType="html",s.style.element=e.divH([...(null===(a=s.grid.dataFrame)||void 0===a?void 0:a.get(r,s.gridRow))?[(u=null===(d=s.grid.dataFrame)||void 0===d?void 0:d.get(i,s.gridRow),e.div(e.icons.delete((()=>{for(let e=0;e<t.rowCount;e++)t.columns.byName(i).get(e)===u&&(t.columns.byName(i).set(e,"",!1),t.columns.byName(n).set(e,!1,!1));t.fireValuesChanged()}),"Remove the outliers group"),{style:{"text-align":"center",margin:"6px"}}))]:[e.div(e.iconFA("check",(()=>{var e,s;if(!l.dataFrame)return;null===(e=t.col(n))||void 0===e||e.markers.assign("true",o.MARKER_TYPE.OUTLIER);const r=null===(s=l.dataFrame)||void 0===s?void 0:s.cell(l.dataFrame.rowCount-1,i).value;t.selection.getSelectedIndexes().forEach((e=>{t.col(n).set(e,!0,!1),t.col(i).set(e,r,!1)})),t.selection.setAll(!1),t.fireValuesChanged()}),"Confirm the outliers"),{style:{"text-align":"center",margin:"6px"}}),e.div(e.iconFA("times",(()=>{l.dataFrame&&(l.dataFrame.rows.removeAt(l.dataFrame.rowCount-1),t.selection.setAll(!1))}),"Cancel the outliers"),{style:{"text-align":"center",margin:"6px"}})]])))})),l.onCellValueEdited.subscribe((e=>{var n,o;if(!l.dataFrame||e.gridColumn.name!==i)return;if(!l.dataFrame.columns.byName(r).get(e.gridRow))return;const s=new Set;for(let t=0;t<(null===(n=l.dataFrame)||void 0===n?void 0:n.rowCount);t++){const e=null===(o=l.dataFrame)||void 0===o?void 0:o.columns.byName(i).get(t);s.add(e)}for(let n=0;n<t.rowCount;n++){const o=t.columns.byName(i).get(n);""==o||s.has(o)||t.columns.byName(i).set(n,e.cell.value)}}));const d=()=>{if(t.columns.byName(i))for(let e=0;e<t.rowCount;e++)t.columns.byName(n).get(e)?""===t.columns.byName(i).get(e)&&t.columns.byName(i).set(e,"Manual",!1):""!==t.columns.byName(i).get(e)&&t.columns.byName(i).set(e,"",!1);const e={};if(t.columns.byName(i))for(let n=0;n<t.rowCount;n++){const o=t.columns.byName(i).get(n),s=e[o];""!=o&&(s?e[o]++:e[o]=1)}l.dataFrame=a(),l.columns.setVisible([i,s,"Actions"]),Object.keys(e).map((t=>{var n;null===(n=l.dataFrame)||void 0===n||n.rows.addNew([t,e[t],"",!0])}))};t.onDataChanged.subscribe(d),t.onSelectionChanged.subscribe((()=>{if(l.dataFrame&&t.selection.trueCount)if(l.dataFrame.columns.byName(r).toList().some((t=>!1===t)))l.dataFrame.set(s,l.dataFrame.rowCount-1,t.selection.trueCount);else{const e=l.dataFrame.rows.addNew(["Manual",t.selection.trueCount,"",!1]);l.dataFrame.currentCell=l.dataFrame.cell(e.idx,i)}})),t.selection.setAll(!1),d(),this.root.innerHTML="",this.root.appendChild(e.divV([e.divV([l.root],{style:{height:"75%"}})],{style:{height:"100%"}}))}}const p=rxjs;var h=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const f=t=>{switch(t){case"Today":return"started > -1d";case"Yesterday":return"started > -2d and started < -1d";case"Any time":return"";case"Last year":return"started > -2y and started < -1y";case"This year":return"started > -1y";case"Last month":return"started > -2m and started < -1m";case"This month":return"started > -1m";case"Last week":return"started > -2w and started < -1w";case"This week":return"started > -1w"}};var m;!function(e){const n={};e.loadChildRuns=function(e){var i;return h(this,void 0,void 0,(function*(){const o=yield t.dapi.functions.calls.allPackageVersions().find(e),s=o.func.id,r=null!==(i=n[s])&&void 0!==i?i:yield t.dapi.functions.allPackageVersions().find(s);n[s]||(n[s]=r),o.func=r,o.options.isHistorical=!0;const a=yield t.dapi.functions.calls.allPackageVersions().filter(`options.parentCallId="${e}"`).list();return yield Promise.all(a.map((e=>h(this,void 0,void 0,(function*(){var i;const o=e.func.id,s=null!==(i=n[o])&&void 0!==i?i:yield t.dapi.functions.allPackageVersions().find(o);n[o]||(n[o]=s),e.func=s}))))),{parentRun:o,childRuns:a}}))},e.loadRun=function(e,i=!1){var s;return h(this,void 0,void 0,(function*(){const a=yield t.dapi.functions.calls.allPackageVersions().include("inputs, outputs, session.user").find(e),l=a.func.id,d=null!==(s=n[l])&&void 0!==s?s:yield t.dapi.functions.allPackageVersions().find(l);if(n[l]||(n[l]=d),a.func=d,a.options.isHistorical=!0,!i){const e=r()(a.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of e)a.outputs[n.name]=(yield t.dapi.tables.getTable(a.outputs[n.name])).clone();const n=r()(a.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const e of n)a.inputs[e.name]=(yield t.dapi.tables.getTable(a.inputs[e.name])).clone()}return a}))},e.saveRun=function(e){return h(this,void 0,void 0,(function*(){const n=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)yield t.dapi.tables.uploadDataFrame(e.outputs[i.name]);const i=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of i)yield t.dapi.tables.uploadDataFrame(e.inputs[n.name]);return yield t.dapi.functions.calls.allPackageVersions().save(e)}))},e.deleteRun=function(e){return h(this,void 0,void 0,(function*(){yield t.dapi.functions.calls.allPackageVersions().delete(e)}))},e.pullRuns=function(e,n={},i={}){return h(this,void 0,void 0,(function*(){let o=`func.id="${e}"`;return o+=n.author?` and session.user.id="${n.author.id}"`:"",o+=n.date?f(n.date):"",t.dapi.functions.calls.allPackageVersions().filter(o).include("session.user, options").list(i)}))},e.pullRunsByName=function(e,i=[],s={},a=[]){var l;return h(this,void 0,void 0,(function*(){let d="";for(const t of i){const e=[];t.author&&e.push(`session.user.id="${t.author.id}"`),t.date&&e.push(f(t.date)),t.isShared&&e.push('options.isShared="true"'),t.text&&e.push(`((options.title like "${t.text}") or (options.annotation like "${t.text}"))`);const n=e.join(" and ");""!==n&&(d+=""===d?`(${n})`:` or (${n})`)}""!==d&&(d=` and (${d})`);const u=yield t.dapi.functions.calls.allPackageVersions().filter(`func.name="${e}"${d}`).include(`${a.join(",")}`).list(s);for(const e of u){const i=e.func.id,o=null!==(l=n[i])&&void 0!==l?l:yield t.dapi.functions.allPackageVersions().find(i);n[i]||(n[i]=o),e.func=o}if(a.includes("inputs")||a.includes("func.params"))for(const e of u){const n=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.inputs[i.name]=yield t.dapi.tables.getTable(e.inputs[i.name])}if(a.includes("outputs")||a.includes("func.params"))for(const e of u){const n=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=yield t.dapi.tables.getTable(e.outputs[i.name])}return u}))}}(m||(m={}));const v=$;var g=n.n(v);const y=ExcelJS;var b,A=n.n(y),C=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};!function(t){t.isSheetExist=(t,e)=>n=>C(this,void 0,void 0,(function*(){const i=n.worksheets.find((e=>e.name===t));return i?{isValid:!0,chainedFuncs:e,result:i}:{isValid:!1,caption:`Sheet named '${t}' is not found`,content:`Sheet name should be exactly \`${t}\` to be parsed.\n\n\nPlease double-check:\n- No extra spaces are in the sheet name\n- Capitalization is the same as in the template\n\n\n${n.worksheets.length>0?`Found sheets: \`${n.worksheets.map((t=>t.name)).join("`,`")}\``:"No columns have found."}\n `}})),t.isColumnExist=(t,e)=>n=>C(this,void 0,void 0,(function*(){const i=n.getRow(1).values;return i.includes(t)?{isValid:!0,chainedFuncs:e}:{isValid:!1,caption:`No column "${t}" in "${n.name}" sheet`,content:`Column name should be exactly \`${t}\` to be parsed.\n\n\nPlease double-check:\n- Column names are in the first row of the sheet\n- No extra spaces are in the cell\n- Capitalization is the same as in the template\n\n\n${i.length>0?`Found columns: \`${i.filter((t=>""!==t)).join("`,`")}\``:"No columns have found."}\n `}})),t.isExcelParsed=t=>e=>C(this,void 0,void 0,(function*(){return(new(A().Workbook)).xlsx.load(yield e.arrayBuffer()).then((e=>C(this,void 0,void 0,(function*(){return{isValid:!0,chainedFuncs:t,result:e}})))).catch((()=>({isValid:!1,caption:"File is failed to parse",content:"Please make sure:\n- XLSX format is used (not XLS or XLSM)\n- File should not be corrupted\n\n\nXLS could be converted to XLSX using Excel's export functionality. \n\nIf the file is corrupted, it will not open in Excel.\n "})))}))}(b||(b={}));var w=n(701),x=n.n(w),R=n(236),I=n.n(R),E=n(80),T=n.n(E),F=n(850),S=n.n(F),P=n(182),B=n.n(P),k=n(213),O=n.n(k),V=n(669),M={};M.styleTagTransform=O(),M.setAttributes=S(),M.insert=T().bind(null,"head"),M.domAPI=I(),M.insertStyleElement=B(),x()(V.Z,M),V.Z&&V.Z.locals&&V.Z.locals;var _=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const L="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class D{constructor(t="Drag-n-drop here",n=null,i=null,s=L){this.initialText=t,this.initialValue=n,this.onValueChanged=i,this.fileType=s,this.uploadedFile$=new p.Subject,this.onFileUploaded=new p.Subject,this.root=e.div(),this.validation=new class{constructor(t=[]){this.validators=t}validate(t){return C(this,void 0,void 0,(function*(){const n=[],i=(t,e)=>C(this,void 0,void 0,(function*(){for(const o of t){const t=yield o(e);t.isValid?t.chainedFuncs&&(yield i(t.chainedFuncs,t.result)):n.push(t)}}));for(const e of this.validators){const o=yield e(t);o.isValid?o.chainedFuncs&&(yield i(o.chainedFuncs,o.result)):n.push(o)}if(0==n.length)return!0;const s=new o.Wizard({title:"Data validation failed"});n.forEach((t=>{s.page({caption:t.caption,root:t.content instanceof HTMLElement?t.content:e.markdown(t.content)})})),s.onOK((()=>{}));const r=s.getButton("CANCEL"),a=s.getButton("<<"),l=s.getButton(">>"),d=s.getButton("OK"),u=s.pages.length,c=e.divText("1/"+u);return c.style.position="absolute",c.style.left="12px",c.style.color="var(--grey-5)",s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",g()(s.root).find(".d4-command-bar").append(c),g()(a).html("BACK"),g()(l).html("NEXT"),g()(d).addClass("disabled"),r.style.display="none",a.addEventListener("click",(()=>{const t=s.pageIndex+1,e=s.pages.length;s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",s.completable||g()(d).addClass("disabled"),c.textContent=t+"/"+e})),l.addEventListener("click",(()=>{const t=s.pageIndex+1,e=s.pages.length;s.captionHost.style.fontSize="20px",s.captionHost.style.fontWeight="400",s.captionHost.style.margin="6px 0",s.completable&&g()(d).removeClass("disabled"),c.textContent=t+"/"+e})),s.show(),!1}))}},this.visibleInput=e.stringInput("Input file",this.initialText,null),this.hiddenInput=document.createElement("input"),this.icon=e.iconFA("cloud-upload",(()=>this.hiddenInput.click())),this.isValid=new p.BehaviorSubject(!0),this.draw(),this.isValid.subscribe((t=>{if(t){this.visibleInput.input.classList.remove("error"),this.visibleInput.input.classList.add("success");const t=e.iconFA("times",(()=>this.reset()),"Reset uploaded file");this.icon.replaceWith(t),this.icon=t}else{this.visibleInput.input.classList.remove("success"),this.visibleInput.input.classList.add("error");const t=e.iconFA("redo",(()=>this.hiddenInput.click()),"Re-upload a file");this.icon.replaceWith(t),this.icon=t}})),this.uploadedFile$.subscribe((t=>this.onFileUploaded.next(t))),i&&this.uploadedFile$.subscribe((t=>i(t)))}draw(){this.clear(),["drag","dragenter"].forEach((t=>{document.getElementsByClassName("layout-workarea")[0].addEventListener(t,(t=>{t.stopPropagation()}),!1)})),this.root.style.display="flex",this.root.append((()=>{this.visibleInput.input.readOnly=!0,this.visibleInput.input.classList.add("default");const t=t=>_(this,void 0,void 0,(function*(){if(t&&t.length){if(t.length>1)throw this.isValid.next(!1),new Error("Please specify single input file");if(this.visibleInput.value=t[0].name,t[0].type!==this.fileType)throw this.isValid.next(!1),new Error("File type is not supported");this.isValid.next(yield this.validation.validate(t[0])),this.isValid.value?this.uploadedFile$.next(t[0]):this.uploadedFile$.next(null)}else this.uploadedFile$.next(null)}));return this.visibleInput.root.classList.add("cv-drop-area"),this.visibleInput.root.style.width="100%",this.hiddenInput.type="file",this.hiddenInput.addEventListener("change",(()=>_(this,void 0,void 0,(function*(){return yield t(this.hiddenInput.files)}))),!1),["dragenter","dragover","dragleave","drop"].forEach((t=>{this.visibleInput.input.addEventListener(t,(t=>{t.preventDefault(),t.stopPropagation()}),!1)})),["dragenter","dragover"].forEach((t=>{this.visibleInput.input.addEventListener(t,(()=>{this.visibleInput.input.classList.add("drag-n-dropping")}),!1)})),["dragleave","drop"].forEach((t=>{this.visibleInput.input.addEventListener(t,(()=>{this.visibleInput.input.classList.remove("drag-n-dropping")}),!1)})),this.visibleInput.input.addEventListener("drop",(e=>_(this,void 0,void 0,(function*(){const n=e.dataTransfer.files;t(n)}))),!1),this.visibleInput.input.addEventListener("click",(()=>this.hiddenInput.click()),!1),this.visibleInput.root.append(e.div(this.icon,"icon")),this.visibleInput})().root)}reset(){this.visibleInput.input.classList.value="ui-input-editor default";const t=e.iconFA("cloud-upload",(()=>this.hiddenInput.click()),"Choose a file to upload");this.icon.replaceWith(t),this.icon=t,this.visibleInput.value="Drag-n-drop here",this.hiddenInput.value="",this.uploadedFile$.next(null)}clear(){e.empty(this.root)}}const j=rxjs.operators;var N=n(380),W={};W.styleTagTransform=O(),W.setAttributes=S(),W.insert=T().bind(null,"head"),W.domAPI=I(),W.insertStyleElement=B(),x()(N.Z,W),N.Z&&N.Z.locals&&N.Z.locals;class H{static getHistoryRuns(e){return(0,p.from)((()=>{return n=this,i=void 0,s=function*(){return yield m.pullRunsByName(e,[{isShared:!0},{author:t.shell.user}],{order:"started"},["func.params","session.user","options"])},new((o=void 0)||(o=Promise))((function(t,e){function r(t){try{l(s.next(t))}catch(t){e(t)}}function a(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(r,a)}l((s=s.apply(n,i||[])).next())}));var n,i,o,s})())}}class U{constructor(t,n,i,s,r=[]){var a;this.label=t,this._funcName=n,this._stringValueFunc=i,this._visibleColumnsForGrid=s,this._visibleColumnsForFilter=r,this.onHistoricalRunChosen=new p.BehaviorSubject(null),this.experimentRunsUpdate=new p.Subject,this.store={experimentRuns:new p.Observable,experimentRunsDf:new p.BehaviorSubject(o.DataFrame.fromColumns([o.Column.fromStrings("Pick",[]),...Object.keys(this._visibleColumnsForGrid).map((t=>o.Column.fromStrings(t,[])))])),isExperimentRunsLoading:new p.Subject,experimentRunData:new p.BehaviorSubject("")},this._historyGrid=o.Viewer.grid(this.store.experimentRunsDf.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1}),this._historyFilters=o.Viewer.filters(this.store.experimentRunsDf.value,{title:"Filters"}),this._visibleInput=e.stringInput(this.label,"",null),this._historyGrid.columns.byName("Pick").cellType="html",this._historyGrid.columns.byName("Pick").width=30,this._historyGrid.root.style.height="100%";for(let t=0;t<this._historyGrid.columns.length;t++){const e=null===(a=this._historyGrid.columns.byIndex(t))||void 0===a?void 0:a.column;e&&e.type===o.TYPE.DATE_TIME&&(this._historyGrid.columns.byIndex(t).format="MMM d, yyyy",this._historyGrid.columns.byIndex(t).width=100)}this._visibleInput.input.addEventListener("click",(()=>{var t;const n=e.dialog();g()(n.root).addClass("arrow-box"),n.onOK((()=>{})),n.onCancel((()=>{this.onHistoricalRunChosen.next(null),this.historyGrid.dataFrame.currentRowIdx=-1})),g()(n.root).find(".d4-dialog-header").hide(),n.root.style.boxShadow="",g()(n.root).removeClass("ui-form");const i=o.Viewer.filters(this.store.experimentRunsDf.value,{title:"Filters"});this._historyFilters.root.replaceWith(i.root),this._historyFilters=i;const s=o.Viewer.grid(this.store.experimentRunsDf.value,{showRowHeader:!1,showColumnGridlines:!1,allowEdit:!1});this._historyGrid.root.replaceWith(s.root),this._historyGrid=s,this._historyGrid.columns.byName("Pick").cellType="html",this._historyGrid.columns.byName("Pick").width=30,this._historyGrid.root.style.height="100%";for(let e=0;e<this._historyGrid.columns.length;e++){const n=null===(t=this._historyGrid.columns.byIndex(e))||void 0===t?void 0:t.column;n&&n.type===o.TYPE.DATE_TIME&&(this._historyGrid.columns.byIndex(e).format="MMM d, yyyy",this._historyGrid.columns.byIndex(e).width=100)}this._historyGrid.onCellPrepare((t=>{var n;"Pick"===(null===(n=t.tableColumn)||void 0===n?void 0:n.name)&&(t.isColHeader&&(t.customText=""),!0===t.cell.value?t.element=e.div([e.iconFA("check",null,"Confirm outliers group")],{style:{"text-align":"center",margin:"6px"}}):t.element=e.div())})),this._historyGrid.columns.setVisible(["Pick",...Object.keys(this._visibleColumnsForGrid).map((t=>t))]),this._historyFilters.setOptions({columnNames:this._visibleColumnsForFilter}),this._historyFilters.root.style.height="100%",g()(this._historyFilters.root).find(".d4-filter-group-header").hide(),this._visibleColumnsForFilter.length||g()(this._historyFilters.root.parentElement).hide(),n.add(e.divH([e.block([this._historyGrid.root]),e.block([this._historyFilters.root],{style:{"margin-left":"10px",width:"225px",height:"100%"}})])),n.show({x:this._visibleInput.input.getBoundingClientRect().x+this._visibleInput.input.clientWidth+10,y:this._visibleInput.input.getBoundingClientRect().y-30,width:Math.max(this._historyGrid.root.clientWidth+this._historyFilters.root.clientWidth+30,600)})})),this._visibleInput.readOnly=!0,this.store.experimentRuns=this.experimentRunsUpdate.pipe((0,j.tap)((()=>this.toggleLoaderExpRuns(!0))),(0,j.switchMap)((()=>H.getHistoryRuns(this._funcName).pipe((0,j.catchError)((()=>p.EMPTY)),(0,j.finalize)((()=>this.toggleLoaderExpRuns(!1)))))),(0,j.shareReplay)(1)),this.store.experimentRuns.pipe((0,j.takeUntil)((0,p.from)(new p.Subject))).subscribe((t=>{const e=o.DataFrame.fromColumns([o.Column.bool("Pick",t.length).init(!1),...Object.entries(this._visibleColumnsForGrid).map((e=>o.Column.fromStrings(e[0],t.map(e[1])))),o.Column.fromStrings("ID",t.map((t=>t.id)))]);e.onCurrentRowChanged.subscribe((()=>{e.getCol("Pick").init(!1),e.set("Pick",e.currentRow.idx,!0);const n=e.getCol("ID").get(e.currentRow.idx),i=t.find((t=>t.id===n));i&&this.onHistoricalRunChosen.next(i)})),this.store.experimentRunsDf.next(e)})),this.store.experimentRunsDf.subscribe((t=>{this.historyGrid.dataFrame=t,this.historyFilters.dataFrame=t})),this.onHistoricalRunChosen.subscribe((t=>{this._visibleInput.value=t?this._stringValueFunc(t):""})),this.store.isExperimentRunsLoading.subscribe((t=>{e.setUpdateIndicator(this._visibleInput.root,t)}))}get historyGrid(){return this._historyGrid}get historyFilters(){return this._historyFilters}get root(){return this._visibleInput.root}set value(t){this._visibleInput.value=t?this._stringValueFunc(t):""}get value(){return this.onHistoricalRunChosen.value}set stringValue(t){this._visibleInput.value=t}get stringValue(){return this._visibleInput.value}toggleLoaderExpRuns(t){this.store.isExperimentRunsLoading.next(t)}}const G=dayjs;var Y=n.n(G),z=n(778),Z={};Z.styleTagTransform=O(),Z.setAttributes=S(),Z.insert=T().bind(null,"head"),Z.domAPI=I(),Z.insertStyleElement=B(),x()(z.Z,Z),z.Z&&z.Z.locals&&z.Z.locals;var q=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const X={Test:"ca1e672e-e3be-40e0-b79b-d2c68e68d380",Admin:"878c42b0-9a50-11e6-c537-6bf8e9ab02ee",System:"3e32c5fa-ac9c-4d39-8b4b-4db3e576b3c3"};class J{constructor(){this.filteringOptions={text:""},this.allRuns=new p.BehaviorSubject([])}get myRuns(){return this.allRuns.value.filter((e=>e.author.id===t.shell.user.id))}get favoriteRuns(){return this.allRuns.value.filter((t=>t.options.isFavorite&&!t.options.isImported))}get sharedRuns(){return this.allRuns.value.filter((t=>t.options.isShared))}get filteredMyRuns(){return this.myRuns.filter((t=>{const e=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,n=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),i=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),o=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(n||i)&&e&&o}))}get filteredFavoriteRuns(){return this.favoriteRuns.filter((t=>{const e=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,n=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),i=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),o=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(n||i)&&e&&o}))}get filteredSharedRuns(){return this.sharedRuns.filter((t=>{const e=!this.filteringOptions.author||t.author.id===this.filteringOptions.author.id,n=!this.filteringOptions.startedAfter||t.started>this.filteringOptions.startedAfter,i=!this.filteringOptions.text.length||!!t.options.title&&t.options.title.includes(this.filteringOptions.text),o=!this.filteringOptions.text.length||!!t.options.description&&t.options.description.includes(this.filteringOptions.text),s=!this.filteringOptions.tags||0===this.filteringOptions.tags.length||!!t.options.tags&&this.filteringOptions.tags.every((e=>t.options.tags.includes(e)));return(i||o)&&n&&e&&s}))}}const K="HISTORY",Q="FAVORITES",tt="SHARED";class et{buildActionsSection(){return e.divH([e.span([`Selected: ${this.selectedCallsSet.size}`],{style:{"align-self":"center"}}),e.divH([(()=>{const t=e.iconFA("exchange",(()=>q(this,void 0,void 0,(function*(){this.onComparison.next([...r()(this.selectedCallsSet.keys()).map((t=>t.id))])}))),"Compare selected runs");return t.style.margin="5px",this.selectedCallsSet.size<2&&t.classList.add("hp-disabled"),t})(),(()=>{const t=e.iconFA("trash-alt",(()=>this.showDeleteRunDialog(this.selectedCallsSet)),"Delete selected runs");return t.style.margin="5px",0===this.selectedCallsSet.size&&t.classList.add("hp-disabled"),t})(),...0===this.selectedCallsSet.size?[(()=>{const t=e.iconFA("square",(()=>{switch(this.tabs.currentPane.name){case K:this.store.myRuns.forEach((t=>this.selectedCallsSet.add(t))),this.myRunsFilter.next();break;case Q:this.store.favoriteRuns.forEach((t=>this.selectedCallsSet.add(t))),this.favRunsFilter.next();break;case tt:this.store.sharedRuns.forEach((t=>this.selectedCallsSet.add(t))),this.sharedRunsFilter.next()}this.updateActionsSection()}),"Select all");return t.style.margin="5px",t})()]:[(()=>{let t=0;switch(this.tabs.currentPane.name){case K:t=this.store.myRuns.length;break;case Q:t=this.store.favoriteRuns.length;break;case tt:t=this.store.sharedRuns.length}const n=this.selectedCallsSet.size===t?"check-square":"minus-square",i=e.iconFA(n,(()=>{switch(this.tabs.currentPane.name){case K:this.store.myRuns.forEach((t=>this.selectedCallsSet.delete(t))),this.myRunsFilter.next();break;case Q:this.store.favoriteRuns.forEach((t=>this.selectedCallsSet.delete(t))),this.favRunsFilter.next();break;case tt:this.store.sharedRuns.forEach((t=>this.selectedCallsSet.delete(t))),this.sharedRunsFilter.next()}this.updateActionsSection()}),"Unselect all");return i.style.margin="5px",i})()]])],{style:{"justify-content":"space-between",padding:"0 12px"}})}buildFilterPane(n){return e.wait((()=>q(this,void 0,void 0,(function*(){const i=new p.Subject,s=e.stringInput("Search","",(t=>i.next(t)));o.debounce(i.asObservable(),600).subscribe((()=>{this.store.filteringOptions.text=s.stringValue,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()}));const r=e.dateInput("Started after",Y()().subtract(1,"week"),(t=>{this.store.filteringOptions.startedAfter=t,this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),a=Object.values(X),l=(yield t.dapi.users.list()).filter((t=>!a.includes(t.id))),d=e.choiceInput("Author","Anyone",["Anyone",...l],(t=>{this.store.filteringOptions.author="Anyone"===t?void 0:t,this.sharedRunsFilter.next()}));d.root.style.display="none";let u=e.choiceInput("Tag","Choose tag to filter",["Choose tag to filter"]);const c=o.TagEditor.create(),h=e.stringInput(" ","");h.input.replaceWith(c.root),h.root.style.display="none",c.onChanged((()=>{this.store.filteringOptions.tags=c.tags.filter((t=>!!t)),0===this.store.filteringOptions.tags.length?h.root.style.display="none":h.root.style.removeProperty("display"),this.myRunsFilter.next(),this.favRunsFilter.next(),this.sharedRunsFilter.next()})),this.store.allRuns.subscribe((()=>{const t=this.store.allRuns.value.map((t=>t.options.tags)).reduce(((t,e)=>(e&&e.forEach((e=>{t.includes(e)||t.push(e)})),t)),[]),n=e.choiceInput("Tag","Choose tag to filter",["Choose tag to filter",...t]);u.root.replaceWith(n.root),u=n,u.onChanged((()=>{u.value&&"Choose tag to filter"!==u.value&&!c.tags.includes(u.value)&&c.addTag(u.value)}))})),r.addPatternMenu("datetime");const f=e.divV([s,r,d,u,h],"ui-form ui-form-wide ui-form-left");return n===K&&(r.root.style.removeProperty("display"),d.root.style.display="none"),n===Q&&(r.root.style.removeProperty("display"),d.root.style.display="none"),n===tt&&(r.root.style.removeProperty("display"),d.root.style.removeProperty("display")),f}))))}showDeleteRunDialog(t){e.dialog({title:"Delete "+(t.size>1?"runs":"run")}).add(e.divText(`The deleted ${t.size>1?"runs":"run"} is impossible to restore. Are you sure?`)).onOK((()=>q(this,void 0,void 0,(function*(){t.forEach((t=>q(this,void 0,void 0,(function*(){this.beforeRunDeleted.next(t.id),this.selectedCallsSet.delete(t),yield m.deleteRun(t),this.afterRunDeleted.next(t.id)}))))})))).show({center:!0})}updateActionsSection(){const t=this.buildActionsSection();this.actionsSection.replaceWith(t),this.actionsSection=t}updateSharedPane(t){const n=t.length>0?this.renderSharedCards(t):e.divText("No runs are marked as shared","no-elements-label"),i=e.divV([this.sharedPaneFilter,e.element("div","splitbar-horizontal"),n]);this.sharedTab.replaceWith(i),this.sharedTab=i}updateFavoritesPane(t){const n=t.length>0?this.renderFavoriteCards(t):e.divText("No runs are marked as favorites","no-elements-label"),i=e.divV([this.favoritesPaneFilter,e.element("div","splitbar-horizontal"),n]);this.favTab.replaceWith(i),this.favTab=i}updateMyPane(t){const n=t.length>0?this.renderHistoryCards(t):e.divText("No runs are found in history","no-elements-label"),i=e.divV([this.myPaneFilter,this.actionsSection,e.element("div","splitbar-horizontal"),n]);this.historyTab.replaceWith(i),this.historyTab=i}renderCard(n){var i;const o=n.author.picture;o.style.width="25px",o.style.height="25px",o.style.fontSize="20px";const s=e.label(null!==(i=n.options.title)&&void 0!==i?i:n.author.friendlyName,{style:{color:"var(--blue-1)"}});e.bind(n.author,o);const r=e.iconFA("square",(t=>{t.stopPropagation(),this.selectedCallsSet.add(n),r.style.display="none",a.style.removeProperty("display"),this.updateActionsSection()}),"Select this run");r.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const a=e.iconFA("check-square",(t=>{t.stopPropagation(),this.selectedCallsSet.delete(n),a.style.display="none",this.updateActionsSection(),r.style.removeProperty("display")}),"Unselect this run");a.classList.add("hp-funccall-card-icon"),this.selectedCallsSet.has(n)?(r.style.display="none",a.style.removeProperty("display")):(r.style.removeProperty("display"),a.style.display="none");const l=e.iconFA("edit",(t=>{t.stopPropagation(),this.showEditDialog(n)}),"Edit selected run");l.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const d=e.iconFA("trash-alt",(t=>q(this,void 0,void 0,(function*(){t.stopPropagation();const e=new Set;e.add(n),this.showDeleteRunDialog(e)}))),"Delete selected runs");d.classList.add("hp-funccall-card-icon","hp-funccall-card-hover-icon");const u=e.iconFA("star",null,"Unfavorite the run");u.classList.add("fas","hp-funccall-card-def-icon");const c=e.iconFA("share-alt",null,"Add to shared");c.classList.add("fas","hp-funccall-card-def-icon"),c.style.color="var(--blue-1)";const p=new Date(n.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"}),h=e.divH([e.divH([o,e.divV([s,e.span([p]),...n.options.description?[e.divText(n.options.description,"description")]:[],...n.options.tags&&n.options.tags.length>0?[e.div(n.options.tags.map((t=>e.span([t],"d4-tag"))))]:[]],"hp-card-content")]),e.divH([l,d,...n.options.isFavorite?[u]:[],...n.options.isShared?[c]:[],r,a])],"hp-funccall-card");return h.addEventListener("click",(()=>q(this,void 0,void 0,(function*(){this.onRunChosen.next(n.id),[...this.myCards,...this.favoriteCards,...this.sharedCards].forEach((t=>t.classList.remove("clicked"))),h.classList.add("clicked")})))),e.tooltip.bind(h,(()=>e.tableFromMap(Object.assign(Object.assign(Object.assign({Author:t.shell.user.toMarkup(),Date:p},n.options.title?{Title:n.options.title}:{}),n.options.description?{Description:n.options.description}:{}),n.options.tags&&n.options.tags.length>0?{Tags:e.div(n.options.tags.map((t=>e.span([t],"d4-tag"))),"d4-tag-editor")}:{})))),h}showEditDialog(t){var n,i,s,r;const a=e.dialog({title:"Edit run"});let l=null!==(n=t.options.title)&&void 0!==n?n:"",d=null!==(i=t.options.description)&&void 0!==i?i:"";const u=e.stringInput("Title",l,(t=>l=t));let c=null!==(s=t.options.isShared)&&void 0!==s&&s,p=null!==(r=t.options.isFavorite)&&void 0!==r&&r;const h=o.TagEditor.create();(t.options.tags||[]).forEach((t=>{h.addTag(t)}));const f=e.stringInput(" ","");f.input.replaceWith(h.root);const v=e.stringInput("Tag",""),g=()=>{""===v.value||h.tags.includes(v.value)||(h.addTag(v.value),v.value="")};v.addOptions(e.iconFA("plus",g,"Add this tag")),v.input.onkeydown=t=>q(this,void 0,void 0,(function*(){"Enter"==t.key&&(t.stopPropagation(),g())})),a.add(e.form([u,e.stringInput("Description",d,(t=>{d=t})),e.boolInput("Favorites",p,(t=>p=t)),e.boolInput("Share",c,(t=>c=t)),v,f])).onOK((()=>q(this,void 0,void 0,(function*(){if((t=yield m.loadRun(t.id)).options.title=""!==l?l:null,t.options.description=""!==d?d:null,t.options.tags=h.tags,!!c==!!t.options.isShared&&!!p==!!t.options.isFavorite){e.setUpdateIndicator(this.tabs.root,!0),yield m.saveRun(t);const n=this.store.allRuns.value.find((e=>e.id===t.id));return n.options.title=""!==l?l:null,n.options.description=""!==d?d:null,n.options.tags=t.options.tags,this.store.allRuns.next(this.store.allRuns.value),void e.setUpdateIndicator(this.tabs.root,!1)}c&&!t.options.isShared&&(t.options.isShared=c,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToShared(t),e.setUpdateIndicator(this.tabs.root,!1)),!c&&t.options.isShared&&(t.options.isShared=c,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromShared(t),e.setUpdateIndicator(this.tabs.root,!1)),p&&!t.options.isFavorite&&(t.options.isFavorite=p,e.setUpdateIndicator(this.tabs.root,!0),yield this.addRunToFavorites(t),e.setUpdateIndicator(this.tabs.root,!1)),!p&&t.options.isFavorite&&(t.options.isFavorite=p,e.setUpdateIndicator(this.tabs.root,!0),yield this.removeRunFromFavorites(t),e.setUpdateIndicator(this.tabs.root,!1))})))).show({center:!0,width:500})}renderFavoriteCards(t){return this.favoriteCards=t.map((t=>this.renderCard(t))),e.divV(this.favoriteCards)}renderSharedCards(t){return this.sharedCards=t.map((t=>this.renderCard(t))),e.divV(this.sharedCards)}renderHistoryCards(t){return this.myCards=t.map((t=>this.renderCard(t))),e.divV(this.myCards,{style:{height:"100%"}})}constructor(t){this.func=t,this.onRunChosen=new p.Subject,this.onComparison=new p.Subject,this.beforeRunAddToFavorites=new p.Subject,this.beforeRunAddToShared=new p.Subject,this.beforeRunRemoveFromFavorites=new p.Subject,this.beforeRunRemoveFromShared=new p.Subject,this.beforeRunDeleted=new p.Subject,this.afterRunAddToFavorites=new p.Subject,this.afterRunAddToShared=new p.Subject,this.afterRunRemoveFromFavorites=new p.Subject,this.afterRunRemoveFromShared=new p.Subject,this.afterRunDeleted=new p.Subject,this.store=new J,this.myRunsFilter=new p.Subject,this.favRunsFilter=new p.Subject,this.sharedRunsFilter=new p.Subject,this.selectedCallsSet=new Set,this.allRunsFetch=new p.Subject,this.historyTab=e.div(),this.favTab=e.div(),this.sharedTab=e.div(),this.filterPane=e.div(),this.tabs=e.tabControl({[K]:e.box(this.historyTab),[Q]:e.box(this.favTab),[tt]:e.box(this.sharedTab)}),this.actionsSection=this.buildActionsSection(),this._root=e.divV([this.tabs.root],{style:{width:"100%",height:"100%"}}),this.myCards=[],this.favoriteCards=[],this.sharedCards=[],this.myPaneFilter=this.buildFilterPane(K),this.favoritesPaneFilter=this.buildFilterPane(Q),this.sharedPaneFilter=this.buildFilterPane(tt),this.tabs.root.style.width="100%",this.tabs.root.style.height="100%",this.tabs.onTabChanged.subscribe((()=>{switch(this.tabs.currentPane.name){case K:this.myPaneFilter.append(this.actionsSection);break;case Q:this.favoritesPaneFilter.append(this.actionsSection);break;case tt:this.sharedPaneFilter.append(this.actionsSection)}})),this.myRunsFilter.subscribe((()=>this.updateMyPane(this.store.filteredMyRuns))),this.favRunsFilter.subscribe((()=>this.updateFavoritesPane(this.store.filteredFavoriteRuns))),this.sharedRunsFilter.subscribe((()=>this.updateSharedPane(this.store.filteredSharedRuns))),this.store.allRuns.subscribe((()=>{this.updateMyPane(this.store.filteredMyRuns),this.updateFavoritesPane(this.store.filteredFavoriteRuns),this.updateSharedPane(this.store.filteredSharedRuns)})),this.allRunsFetch.subscribe((()=>q(this,void 0,void 0,(function*(){e.setUpdateIndicator(this.root,!0);const t=(yield m.pullRunsByName(this.func.name,[],{order:"started"},["session.user","options"])).reverse();this.store.allRuns.next(t),e.setUpdateIndicator(this.root,!1)})))),this.afterRunAddToFavorites.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.isFavorite=!0,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunAddToShared.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.isShared=!0,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunRemoveFromFavorites.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.isFavorite=!1,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunRemoveFromShared.subscribe((t=>{const e=this.store.allRuns.value.find((e=>e.id===t.id));e.options.title=t.options.title,e.options.description=t.options.description,e.options.isShared=!1,this.store.allRuns.next(this.store.allRuns.value)})),this.afterRunDeleted.subscribe((t=>{this.store.allRuns.next(this.store.allRuns.value.filter((e=>e.id!==t))),this.updateActionsSection()})),this.allRunsFetch.next()}addRunToFavorites(e){return q(this,void 0,void 0,(function*(){e.options.isFavorite=!0,this.beforeRunAddToFavorites.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunAddToFavorites.next(n),n}))}removeRunFromFavorites(e){return q(this,void 0,void 0,(function*(){e.options.isFavorite=!1,this.beforeRunRemoveFromFavorites.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunRemoveFromFavorites.next(n),n}))}addRunToShared(e){return q(this,void 0,void 0,(function*(){e.options.isShared=!0,this.beforeRunAddToShared.next(e);const n=yield t.dapi.groups.find("a4b45840-9a50-11e6-9cc9-8546b8bf62e6"),i=r()(e.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const o of i){const i=e.outputs[o.name];yield t.dapi.permissions.grant(i.getTableInfo(),n,!1)}const s=r()(e.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of s){const o=e.inputs[i.name];yield t.dapi.permissions.grant(o.getTableInfo(),n,!1)}const a=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunAddToShared.next(a),a}))}removeRunFromShared(e){return q(this,void 0,void 0,(function*(){e.options.isShared=!1,this.beforeRunRemoveFromShared.next(e);const n=yield t.dapi.functions.calls.allPackageVersions().save(e);return this.afterRunRemoveFromShared.next(n),n}))}get root(){return this._root}}var nt;!function(t){t.fileInput=function(t="Drag-n-drop here",e=null,n=null,i=L){return new D(t,e,n,i)},t.historyInput=function(t,e,n,i,o=[]){return new U(t,e,n,i,o)},t.historyPanel=function(t){return new et(t)}}(nt||(nt={}));const it={barchart:o.VIEWER.BAR_CHART,boxplot:o.VIEWER.BOX_PLOT,calendar:o.VIEWER.CALENDAR,corrplot:o.VIEWER.CORR_PLOT,densityplot:o.VIEWER.DENSITY_PLOT,filters:o.VIEWER.FILTERS,form:o.VIEWER.FORM,globe:o.VIEWER.GLOBE,googlemap:o.VIEWER.GOOGLE_MAP,grid:o.VIEWER.GRID,heatmap:o.VIEWER.HEAT_MAP,histogram:o.VIEWER.HISTOGRAM,linechart:o.VIEWER.LINE_CHART,markup:o.VIEWER.MARKUP,matrixplot:o.VIEWER.MATRIX_PLOT,networkdiagram:o.VIEWER.NETWORK_DIAGRAM,pcplot:o.VIEWER.PC_PLOT,piechart:o.VIEWER.PIE_CHART,scatterplot:o.VIEWER.SCATTER_PLOT,"3dscatterplot":o.VIEWER.SCATTER_PLOT_3D,shapemap:o.VIEWER.SHAPE_MAP,statistics:o.VIEWER.STATISTICS,tileviewer:o.VIEWER.TILE_VIEWER,timelines:o.VIEWER.TIMELINES,treemap:o.VIEWER.TREE_MAP,trellisplot:o.VIEWER.TRELLIS_PLOT,wordcloud:o.VIEWER.WORD_CLOUD},ot="JsCardView",st="viewer";var rt;!function(t){t.INPUT="Input",t.OUTPUT="Output"}(rt||(rt={}));const at="experimental",lt=t=>t.options.getRealData,dt=t=>{const e=t.options[st];return void 0!==e?{name:t.name,config:JSON.parse(e,((t,e)=>"true"===e||"false"!==e&&("type"===t&&it[e]||e)))}:{name:t.name,config:[]}};var ut=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const ct="Run name",pt="RunId";class ht extends o.TableView{static fromComparedRuns(e,n){var i,s,r;return ut(this,void 0,void 0,(function*(){const a=null!==(i=n.configFunc)&&void 0!==i?i:e[0].func,l=[...a.inputs,...a.outputs].map((t=>dt(t))).reduce(((t,e)=>(t[e.name]?t[e.name].push(...e.config):t[e.name]=e.config,t)),{}),d=t=>{var n;if(t.propertyType===o.TYPE.DATA_FRAME){const n=l[t.name].map((n=>{var i;let s=null!==(i=t.caption)&&void 0!==i?i:t.name;const r=o.Column.fromType(o.TYPE.DATA_FRAME,s,e.length);r.init((n=>{var i;return null!==(i=e[n].inputs[t.name])&&void 0!==i?i:e[n].outputs[t.name]}));const a=u.columns.getUnusedName(r.name);return r.name=a,s=a,r.temp[st]=n,u.columns.add(r),r}));return n}{let i=null!==(n=t.caption)&&void 0!==n?n:t.name;const s=o.Column.fromType(t.propertyType,i,e.length);s.init((n=>{var i;return null!==(i=e[n].inputs[t.name])&&void 0!==i?i:e[n].outputs[t.name]}));const r=u.columns.getUnusedName(s.name);return s.name=r,i=r,u.columns.add(s),[s]}},u=o.DataFrame.create(e.length),c=[];e.forEach((t=>{var e;let n=null!==(e=t.options.title)&&void 0!==e?e:`${t.func.name} - ${new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`,i=2;for(;c.includes(n);)n=`${t.func.name} - ${new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})} - ${i}`,i++;c.push(n)})),u.columns.add(o.Column.fromStrings(ct,c)),u.name=(null===(s=n.parentCall)||void 0===s?void 0:s.func.name)?`${null===(r=n.parentCall)||void 0===r?void 0:r.func.name} - comparison`:`${e[0].func.name} - comparison`,a.inputs.forEach((t=>d(t))),a.outputs.forEach((t=>d(t)));const p=[...t.shell.views].find((t=>t.type===ot||"scripts"===t.type||"functions"===t.type));p&&(t.shell.v=p);const h=t.shell.addTableView(u);h.temp={isComparison:!0},h.close();const f=new this(h.dart,n),m=a.options.comparator;return setTimeout((()=>ut(this,void 0,void 0,(function*(){f.defaultCustomize(),m&&(yield t.functions.call(m,{comparisonView:f}))}))),0),f}))}constructor(e,n={}){super(e),n.parentView&&(this.parentView=n.parentView),this.parentCall=n.parentCall||t.functions.getCurrentCall()}defaultCustomize(){var n;this.root.style.removeProperty("width"),this.root.firstChild.style.removeProperty("width"),this.root.firstChild.firstChild.style.removeProperty("width"),this.grid.props.rowHeight=180,this.grid.props.showAddNewRowIcon=!1,this.grid.props.allowEdit=!1,this.grid.columns.byName(ct).width=70;for(let t=0;t<this.grid.columns.length;t++){const e=this.grid.columns.byIndex(t);(null===(n=e.column)||void 0===n?void 0:n.temp[st])&&(e.width=350,e.cellType="html")}this.grid.onCellPrepare((t=>{if(!t.isColHeader&&!t.isRowHeader&&(t.tableColumn.name===ct&&(t.style.textVertical=!0),t.tableColumn&&t.tableColumn.temp[st])){const n=t.cell.value,i=t.tableColumn.temp[st],s=i.type;t.element=e.waitBox((()=>ut(this,void 0,void 0,(function*(){const e=Object.values(it).includes(s)?o.Viewer.fromType(s,n):yield n.plot.fromType(s);return t.tableColumn.temp[st].look?e.setOptions(t.tableColumn.temp[st].look):(e.setOptions(i),t.tableColumn.temp[st]=e.getOptions()),e.root})))),t.element.style.width="100%",t.element.style.height="100%"}})),t.events.onCurrentObjectChanged.subscribe((({sender:n})=>{var i;if(n instanceof o.Column&&n.type===o.TYPE.DATA_FRAME&&t.shell.tv&&t.shell.tv.temp.isComparison&&[o.VIEWER.LINE_CHART,o.VIEWER.SCATTER_PLOT,o.VIEWER.HISTOGRAM,o.VIEWER.BOX_PLOT].includes(n.temp[st].type)){t.shell.windows.showProperties=!0;const s=t=>{const e=t.get(0).clone();e.columns.addNew(pt,o.TYPE.STRING).init(t.dataFrame.get(ct,0));for(let n=1;n<t.length;n++){const i=t.get(n).clone();i.columns.addNew(pt,o.TYPE.STRING).init(t.dataFrame.get(ct,n));const s=[o.COLUMN_TYPE.INT,o.COLUMN_TYPE.FLOAT];for(let t=0;t<i.columns.length;t++){const n=i.columns.byIndex(t),r=e.columns.byIndex(t);n.type!==r.type&&s.includes(n.type)&&s.includes(r.type)&&(n.type!==o.COLUMN_TYPE.FLOAT&&i.columns.replace(n,n.convertTo(o.COLUMN_TYPE.FLOAT)),r.type!==o.COLUMN_TYPE.FLOAT&&e.columns.replace(r,r.convertTo(o.COLUMN_TYPE.FLOAT)))}e.append(i,!0)}return e},r=null!==(i=n.temp.unitedDf)&&void 0!==i?i:s(n);n.temp.unitedDf=r;const a=n.temp[st].look;setTimeout((()=>{switch(n.temp[st].type){case o.VIEWER.LINE_CHART:t.shell.o=e.box(r.plot.line(Object.assign(Object.assign({},a),{split:pt})).root);break;case o.VIEWER.SCATTER_PLOT:t.shell.o=e.box(r.plot.scatter(Object.assign(Object.assign({},a),{color:pt})).root);break;case o.VIEWER.HISTOGRAM:t.shell.o=e.box(r.plot.histogram(Object.assign(Object.assign({},a),{split:pt})).root);break;case o.VIEWER.BOX_PLOT:t.shell.o=e.box(r.plot.box(Object.assign(Object.assign({},a),{category:pt})).root)}}))}}))}}var ft=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const mt=new URL(t.shell.startUri);class vt extends o.ViewBase{constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(),this.initValue=t,this.options=n,this._type="function",this.funcCallReplaced=new p.Subject,this.exportConfig=null,this.historyRoot=e.divV([],{style:{"justify-content":"center"}}),this.defaultExportFilename=t=>`${this.name} - ${(new Date).toLocaleString("en-US").replaceAll(/:|\//g,"-")}.${this.exportConfig.supportedExtensions[t]}`,this.defaultSupportedExportExtensions=()=>({Excel:"xlsx"}),this.defaultSupportedExportFormats=()=>["Excel"],this.box=!0,this.init()}onFuncCallReady(){return ft(this,void 0,void 0,(function*(){this.changeViewName(this.funcCall.func.friendlyName),this.build(),this.getStartId()&&(yield this.loadRun(this.funcCall.id),this.setAsLoaded())}))}changeViewName(t){var n;this.name=t,null===(n=document.querySelector("div.d4-ribbon-name"))||void 0===n||n.replaceChildren(e.span([t]))}getStartId(){return t.shell.getVar("isLoaded")?void 0:mt.searchParams.get("id")}setAsLoaded(){return t.shell.setVar("isLoaded",!0)}get funcCall(){return this._funcCall}get func(){var t;return null===(t=this.funcCall)||void 0===t?void 0:t.func}get lastCall(){return this._lastCall}set lastCall(t){this._lastCall=t}get type(){return this._type}linkFunccall(t){var e,n,i;const o=null===(e=this._funcCall)||void 0===e?void 0:e.options.isHistorical;this._funcCall=t,this.options.isTabbed||(t.options.isHistorical?(o?this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)} — ${null!==(i=t.options.title)&&void 0!==i?i:new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`):this.changeViewName(`${this.name} — ${null!==(n=t.options.title)&&void 0!==n?n:new Date(t.started.toString()).toLocaleString("en-us",{month:"short",day:"numeric",hour:"numeric",minute:"numeric"})}`),this.path=`?id=${this._funcCall.id}`):(this.path="",this.changeViewName(`${this.name.substring(0,this.name.indexOf(" — ")>0?this.name.indexOf(" — "):void 0)}`))),this.funcCallReplaced.next(!0)}loadFuncCallById(){return ft(this,void 0,void 0,(function*(){if(this.initValue instanceof o.FuncCall)return yield new Promise((t=>setTimeout(t,0))),void this.linkFunccall(this.initValue);e.setUpdateIndicator(this.root,!0);const n=this.getStartId();if(n&&!this.options.isTabbed)this.linkFunccall(yield m.loadRun(n));else{const e=yield t.functions.eval(this.initValue);this.linkFunccall(e.prepare({}))}e.setUpdateIndicator(this.root,!1)}))}init(){return ft(this,void 0,void 0,(function*(){yield this.loadFuncCallById(),yield this.onFuncCallReady()}))}build(){e.empty(this.root),this.root.appendChild(this.buildIO()),this.options.historyEnabled&&this.buildHistoryBlock(),this.buildRibbonMenu(),this.buildRibbonPanels()}onComparisonLaunch(e){return ft(this,void 0,void 0,(function*(){const n=t.shell.v.parentCall,i=yield Promise.all(e.map((t=>m.loadRun(t)))),o=[...t.shell.views].find((t=>t.type===ot)),s=yield ht.fromComparedRuns(i,{parentView:o,parentCall:n,configFunc:this.func});t.shell.addView(s)}))}buildHistoryBlock(){const t=nt.historyPanel(this.func);return this.subs.push(t.onRunChosen.subscribe((t=>ft(this,void 0,void 0,(function*(){return this.linkFunccall(yield this.loadRun(t))})))),t.onComparison.subscribe((t=>ft(this,void 0,void 0,(function*(){return this.onComparisonLaunch(t)}))))),e.empty(this.historyRoot),this.historyRoot.style.removeProperty("justify-content"),this.historyRoot.style.width="100%",this.historyRoot.append(t.root),t.root}buildRibbonPanels(){const n=e.iconFA("history",(()=>{t.shell.windows.showProperties=!t.shell.windows.showProperties,n.classList.toggle("d4-current"),t.shell.o=this.historyRoot}));n.classList.add("d4-toggle-button"),t.shell.windows.showProperties&&n.classList.add("d4-current");const i=[[...this.exportConfig&&this.exportConfig.supportedFormats.length>0?[e.comboPopup(e.iconFA("arrow-to-bottom"),this.exportConfig.supportedFormats,(t=>ft(this,void 0,void 0,(function*(){return o.Utils.download(this.exportConfig.filename(t),yield this.exportConfig.export(t))}))))]:[],...this.options.historyEnabled?[n]:[]]];return this.setRibbonPanels(i),i}buildRibbonMenu(){}onBeforeSaveRun(t){return ft(this,void 0,void 0,(function*(){}))}onAfterSaveRun(t){return ft(this,void 0,void 0,(function*(){}))}saveRun(t){return ft(this,void 0,void 0,(function*(){yield this.onBeforeSaveRun(t);const e=yield m.saveRun(t);return this.linkFunccall(e),this.options.historyEnabled&&this.buildHistoryBlock(),this.options.isTabbed||(this.path=`?id=${e.id}`),yield this.onAfterSaveRun(e),e}))}onBeforeDeleteRun(t){return ft(this,void 0,void 0,(function*(){}))}onAfterDeleteRun(t){return ft(this,void 0,void 0,(function*(){}))}deleteRun(t){return ft(this,void 0,void 0,(function*(){return yield this.onBeforeDeleteRun(t),yield m.deleteRun(t),yield this.onAfterDeleteRun(t),t.id}))}onBeforeLoadRun(){return ft(this,void 0,void 0,(function*(){}))}onAfterLoadRun(t){return ft(this,void 0,void 0,(function*(){}))}loadRun(t){return ft(this,void 0,void 0,(function*(){yield this.onBeforeLoadRun();const e=yield m.loadRun(t);return this.lastCall=e,yield this.onAfterLoadRun(e),e}))}onBeforeRun(t){return ft(this,void 0,void 0,(function*(){}))}onAfterRun(t){return ft(this,void 0,void 0,(function*(){}))}run(){return ft(this,void 0,void 0,(function*(){if(!this.funcCall)throw new Error("The correspoding function is not specified");yield this.onBeforeRun(this.funcCall);const t=o.TaskBarProgressIndicator.create("Calculating...");this.funcCall.newId(),yield this.funcCall.call(),t.close(),yield this.onAfterRun(this.funcCall),this.lastCall=this.options.isTabbed||this.runningOnInput||this.runningOnStart?(t=>{const e=t.clone(),n=r()(t.outputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const i of n)e.outputs[i.name]=t.outputs[i.name].clone();const i=r()(t.inputParams.values()).filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME));for(const n of i)e.inputs[n.name]=t.inputs[n.name].clone();return e})(this.funcCall):yield this.saveRun(this.funcCall)}))}get hasUploadMode(){return"true"===this.func.options.uploadMode}get runningOnInput(){return"true"===this.func.options.runOnInput}get runningOnStart(){return"true"===this.func.options.runOnOpen}get isHistorical(){return!0===this.funcCall.options.isHistorical}}var gt=n(903),yt={};yt.styleTagTransform=O(),yt.setAttributes=S(),yt.insert=T().bind(null,"head"),yt.domAPI=I(),yt.insertStyleElement=B(),x()(gt.Z,yt),gt.Z&>.Z.locals&>.Z.locals;const bt=html2canvas;var At=n.n(bt),Ct=n(751),wt={};wt.styleTagTransform=O(),wt.setAttributes=S(),wt.insert=T().bind(null,"head"),wt.domAPI=I(),wt.insertStyleElement=B(),x()(Ct.Z,wt),Ct.Z&&Ct.Z.locals&&Ct.Z.locals;var xt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};const Rt="file";class It extends vt{static fromFuncCall(t,e={historyEnabled:!0,isTabbed:!1}){return new this(t,e)}constructor(t,n={historyEnabled:!0,isTabbed:!1}){super(t,n),this.options=n,this.checkDisability=new p.Subject,this.isRunning=!1,this.isUploadMode=new p.BehaviorSubject(!1),this.beforeInputPropertyRender=new p.Subject,this.afterInputPropertyRender=new p.Subject,this.beforeRenderControlls=new p.Subject,this.afterOutputPropertyRender=new p.Subject,this.afterOutputSacalarTableRender=new p.Subject,this.outputsTabsElem=e.tabControl(),this.formTabsElem=e.tabControl(),this.dfToViewerMapping={},this.defaultExport=t=>xt(this,void 0,void 0,(function*(){const e=this.lastCall;if(!e)throw new Error("Function was not called");if(!this.exportConfig.supportedFormats.includes(t))throw new Error(`Format "${t}" is not supported.`);if(!this.func)throw new Error("The correspoding function is not specified");const n=new(A().Workbook),i=t=>o.TYPES_SCALAR.has(t),s=t=>t===o.TYPE.DATA_FRAME,r=this.func.inputs.filter((t=>s(t.propertyType))),a=this.func.inputs.filter((t=>i(t.propertyType))),l=this.func.outputs.filter((t=>s(t.propertyType))),d=this.func.outputs.filter((t=>i(t.propertyType))),u=[...e.inputParams.values()],c=[...e.outputParams.values()];if(r.forEach((t=>{const i=t.options.caption||t.name,o=n.addWorksheet(Et(i,rt.INPUT)),s=e.inputs[t.name];Ft(o,s)})),a.length){const t=n.addWorksheet("Input scalars");Tt(t,a.map((t=>({caption:t.options.caption||t.name,value:e.inputs[t.name],units:t.options.units||""}))))}if(l.forEach((t=>{const i=t.options.caption||t.name,o=n.addWorksheet(Et(i,rt.OUTPUT)),s=e.outputs[t.name];Ft(o,s)})),d.length){const t=n.addWorksheet("Output scalars");Tt(t,d.map((t=>({caption:t.options.caption||t.name,value:e.outputs[t.name],units:t.options.units||""}))))}const p=this.outputsTabsElem;for(const t of this.tabsLabels)if(p.getPane(t))if(p.currentPane=p.getPane(t),yield new Promise((t=>setTimeout(t,100))),"Input"===t)for(const t of u.filter((t=>t.property.propertyType===o.TYPE.DATA_FRAME))){const i=this.dfToViewerMapping[t.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(it).includes(t.type))),s=r.find((e=>e.name===t.name)),a=s.options.caption||t.name,l=e.inputs[s.name];for(const[t,e]of i.entries())yield St(n,n.getWorksheet(Et(a,rt.INPUT)),e.root,l.columns.length+2,t>0?Math.ceil(i[t-1].root.clientHeight/20)+1:0)}else for(const i of c.filter((e=>e.property.propertyType===o.TYPE.DATA_FRAME&&("Output"===t&&"Misc"===e.property.category||"Output"===e.property.category||"Output"!==t&&e.property.category===t)))){const t=this.dfToViewerMapping[i.property.name].filter((t=>t.type!==o.VIEWER.GRID)).filter((t=>Object.values(it).includes(t.type))),s=l.find((t=>t.name===i.property.name)),r=s.options.caption||i.property.name,a=e.outputs[s.name];for(const[e,i]of t.entries())if(i.type===o.VIEWER.STATISTICS){const i=a.columns.length,s=o.DataFrame.fromColumns([o.Column.string("Name",i).init((t=>a.columns.byIndex(t).name)),o.Column.int("Values",i).init((t=>a.columns.byIndex(t).stats.valueCount)),o.Column.int("Nulls",i).init((t=>a.columns.byIndex(t).stats.missingValueCount)),o.Column.float("Min",i).init((t=>a.columns.byIndex(t).stats.min)),o.Column.float("Max",i).init((t=>a.columns.byIndex(t).stats.max)),o.Column.float("Avg",i).init((t=>a.columns.byIndex(t).stats.avg)),o.Column.float("Stdev",i).init((t=>a.columns.byIndex(t).stats.stdev))]);Ft(n.getWorksheet(Et(r,rt.OUTPUT)),s,a.columns.length+2,e>0?Math.ceil(t[e-1].root.clientHeight/20)+1:0)}else yield St(n,n.getWorksheet(Et(r,rt.OUTPUT)),i.root,a.columns.length+2,e>0?Math.ceil(t[e-1].root.clientHeight/20)+1:0)}const h=yield n.xlsx.writeBuffer();return new Blob([h],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"})})),this.exportConfig={supportedExtensions:this.defaultSupportedExportExtensions(),supportedFormats:this.defaultSupportedExportFormats(),export:this.defaultExport,filename:this.defaultExportFilename}}onFuncCallReady(){const t=Object.create(null,{onFuncCallReady:{get:()=>super.onFuncCallReady}});return xt(this,void 0,void 0,(function*(){yield t.onFuncCallReady.call(this),this.basePath=`scripts/${this.funcCall.func.id}/view`,this.runningOnStart&&(yield this.doRun())}))}onAfterRun(t){const e=this.outputsTabsElem.panes.find((t=>"Input"!==t.name));return e&&(this.outputsTabsElem.currentPane=e),Promise.resolve()}replaceControlls(t){this.controllsDiv=t}getRunButton(t="Run"){var n;const i=e.bigButton(null!==(n=this.func.options.runLabel)&&void 0!==n?n:t,(()=>xt(this,void 0,void 0,(function*(){return yield this.doRun()})))),o=this.checkDisability.subscribe((()=>{const t=this.isRunnable();i.disabled=!t}));return this.subs.push(o),i}buildIO(){const t=this.buildInputBlock();e.tools.handleResize(t,(t=>{t<350?(g()(this.formTabsElem.getPane("Output").content).addClass("ui-form-condensed"),g()(this.formTabsElem.getPane("Input").content).addClass("ui-form-condensed")):(g()(this.formTabsElem.getPane("Output").content).removeClass("ui-form-condensed"),g()(this.formTabsElem.getPane("Input").content).removeClass("ui-form-condensed"))}));const n=this.buildOutputBlock();n.style.height="100%",n.style.width="100%",this.outputsTabsElem.root.style.display="none",this.outputsTabsElem.getPane("Input")&&this.outputsTabsElem.panes.forEach((t=>{t.header.style.display="none"}));const i=e.splitH([t,e.panel([n],{style:{"padding-top":"0px"}})],null,!0);return i.style.padding="0 12px",t.style.maxWidth="450px",i}buildInputBlock(){const t=this.renderInputForm(),n=this.renderOutputForm();if(this.formTabsElem=e.tabControl({Input:t,Output:n}),g()(this.formTabsElem.root).removeClass("ui-box"),g()(this.formTabsElem.root).css("flex-grow",0),g()(this.formTabsElem.getPane("Output").header).hide(),g()(this.formTabsElem.getPane("Input").header).hide(),this.controllsDiv=void 0,this.beforeRenderControlls.next(!0),!this.controllsDiv){const t=this.getRunButton(),n=e.div([t]),i=e.bigButton("Save",(()=>xt(this,void 0,void 0,(function*(){return yield this.saveExperimentalRun(this.funcCall)}))),"Save uploaded data");g()(i).hide(),this.isUploadMode.subscribe((e=>{e?(g()(i).show(),g()(t).hide()):(g()(i).hide(),g()(t).show()),this.buildRibbonPanels()})),e.tooltip.bind(n,(()=>t.disabled?this.isRunning?"Computations are in progress":"Some inputs are invalid":"")),this.controllsDiv=e.buttonsInput([i,n]),g()(this.controllsDiv.children.item(1)).css("gap","0px"),g()(this.controllsDiv).css({"margin-top":"0px",position:"sticky"})}const i=e.div(this.controllsDiv,"ui-form");return g()(i).css("padding","0px"),e.divV([this.formTabsElem.root,...this.runningOnInput?[]:[i]],"ui-box")}buildRibbonPanels(){super.buildRibbonPanels();const n=e.iconFA("play",(()=>xt(this,void 0,void 0,(function*(){return yield this.doRun()}))),"Run computations");n.classList.add("fas");const i=e.iconFA("save",(()=>xt(this,void 0,void 0,(function*(){this.isUploadMode.value?yield this.saveExperimentalRun(this.funcCall):this.lastCall?yield this.saveRun(this.lastCall):t.shell.warning("Function was not called. Call it before saving")}))),this.isUploadMode.value?"Save uploaded data":"Save the last run"),o=e.iconFA("arrow-to-top",(()=>xt(this,void 0,void 0,(function*(){this.isUploadMode.next(!this.isUploadMode.value),lt(this.func)?(yield t.functions.eval(lt(this.func))).prepare().edit():(o.classList.toggle("d4-current"),this.isUploadMode.value?(g()(this.formTabsElem.getPane("Input").header).show(),g()(this.formTabsElem.getPane("Output").header).show()):(this.formTabsElem.currentPane=this.formTabsElem.getPane("Input"),g()(this.formTabsElem.getPane("Input").header).hide(),g()(this.formTabsElem.getPane("Output").header).hide()))}))),"Upload experimental data");o.classList.add("d4-toggle-button",...this.isUploadMode.value?["d4-current"]:[]);const s=[...this.getRibbonPanels(),[...this.runningOnInput||this.options.isTabbed?[]:[n],...this.hasUploadMode&&this.isUploadMode.value?[i]:[],...this.hasUploadMode?[o]:[]]];return this.setRibbonPanels(s),s}buildOutputBlock(){this.outputsTabsElem.root.style.width="100%",this.tabsLabels.forEach((n=>{const i=this.categoryToParamMap[n].filter((t=>t.propertyType===o.TYPE.DATA_FRAME)),s=this.categoryToParamMap[n].filter((t=>t.propertyType!==o.TYPE.DATA_FRAME)),r=i.map((t=>dt(t).config)),a=i.reduce(((i,s,a)=>{var l;const d=r[a].map((e=>xt(this,void 0,void 0,(function*(){var n,i,r,a;const l=null!==(a=null!==(i=null===(n=this.funcCall.outputs[s.name])||void 0===n?void 0:n.value)&&void 0!==i?i:null===(r=this.funcCall.inputParams[s.name])||void 0===r?void 0:r.value)&&void 0!==a?a:t.data.demo.demog(1),d=e.type,u=Object.values(it).includes(d)?o.Viewer.fromType(d,l):yield l.plot.fromType(d);return u.setOptions(e),this.dfToViewerMapping[s.name]?this.dfToViewerMapping[s.name].push(u):this.dfToViewerMapping[s.name]=[u],this.afterOutputPropertyRender.next({prop:s,output:u}),u})))).map((t=>t.then((t=>{const e=()=>{var e;const i=null!==(e=this.funcCall.outputParams[s.name])&&void 0!==e?e:this.funcCall.inputParams[s.name],o=i.onChanged.subscribe((()=>xt(this,void 0,void 0,(function*(){if(g()(this.outputsTabsElem.root).show(),g()(this.outputsTabsElem.getPane(n).header).show(),Object.values(it).includes(t.type))t.dataFrame=i.value;else{const e=yield i.value.plot.fromType(t.type);t.root.replaceWith(e.root),t=e}this.afterOutputPropertyRender.next({prop:s,output:t})}))));this.funcCallReplaced.subscribe((()=>xt(this,void 0,void 0,(function*(){var e;const i=null!==(e=this.funcCall.outputs[s.name])&&void 0!==e?e:this.funcCall.inputs[s.name];if(g()(this.outputsTabsElem.root).show(),g()(this.outputsTabsElem.getPane(n).header).show(),Object.values(it).includes(t.type))t.dataFrame=i;else{const e=yield i.plot.fromType(t.type);t.root.replaceWith(e.root),t=e}})))),this.subs.push(o)};return e(),this.subs.push(this.funcCallReplaced.subscribe(e)),t})))),u=null!==(l=s.options.caption)&&void 0!==l?l:s.name;if("Input"===n){const t=()=>{var t;const e=(null!==(t=this.funcCall.outputParams[s.name])&&void 0!==t?t:this.funcCall.inputParams[s.name]).onChanged.subscribe((()=>{g()(this.outputsTabsElem.root).show(),g()(this.outputsTabsElem.getPane("Input").header).show()}));this.subs.push(e)};t(),this.subs.push(this.funcCallReplaced.subscribe(t))}const c=d.map(((t,n)=>{const i=r[a][n].block,o=e.wait((()=>xt(this,void 0,void 0,(function*(){return(yield t).root}))));return g()(o).css({"min-height":"300px","flex-grow":"1"}),e.divV([...0===n?[e.h2(u)]:[e.h2(" ",{style:{"white-space":"pre"}})],o],{style:Object.assign({},i?{width:`${i}%`,"max-width":`${i}%`}:{"flex-grow":"1"})})}));return i.append(...c),i}),e.divH([],{style:{"flex-wrap":"wrap","flex-grow":"1"}})),l=()=>{const t=o.HtmlTable.create(s,(t=>{var e;return[null!==(e=t.caption)&&void 0!==e?e:t.name,this.funcCall.outputs[t.name],t.options.units]})).root;return g()(t).css({"max-width":"400px"}),this.afterOutputSacalarTableRender.next(t),t};let d=l();s.forEach((t=>{const e=()=>{const e=this.funcCall.outputParams[t.name].onChanged.subscribe((()=>{const t=l();d.replaceWith(t),d=t}));this.funcCallReplaced.subscribe((()=>{const t=l();d.replaceWith(t),d=t})),this.subs.push(e)};e(),this.subs.push(this.funcCallReplaced.subscribe(e))})),(s.length>0||i.reduce(((t,e)=>t+dt(e).config.length),0)>0)&&this.outputsTabsElem.addPane(n,(()=>e.divV([...i.length?[a]:[],...s.length?[e.h2("Scalar values"),d]:[]])))}));const n=e.box();return n.append(this.outputsTabsElem.root),n}onAfterLoadRun(t){return xt(this,void 0,void 0,(function*(){this.outputsTabsElem.root.style.removeProperty("display"),this.outputsTabsElem.panes.forEach((t=>{t.header.style.removeProperty("display")}))}))}get isInputPanelRequired(){var t;return(null===(t=this.func)||void 0===t?void 0:t.inputs.some((t=>t.propertyType==o.TYPE.DATA_FRAME&&null!=t.options.viewer)))||!1}get tabsLabels(){return Object.keys(this.categoryToParamMap)}get categoryToParamMap(){const t={};return this.isInputPanelRequired&&this.func.inputs.filter((t=>t.propertyType==o.TYPE.DATA_FRAME&&null!=t.options.viewer)).forEach((e=>t.Input?t.Input.push(e):t.Input=[e])),this.func.outputs.forEach((e=>{const n="Misc"===e.category?"Output":e.category;t[n]?t[n].push(e):t[n]=[e]})),t}doRun(){return xt(this,void 0,void 0,(function*(){this.isRunning=!0,this.checkDisability.next();try{yield this.run()}catch(e){t.shell.error(e)}finally{this.isRunning=!1,this.checkDisability.next()}}))}renderOutputForm(){const n=e.divV([],"ui-form");let i="Misc";return r()(this.funcCall.outputParams.values()).filter((t=>!!t)).forEach((s=>{var r,a,l;const d=s.property;if(d.propertyType.toString()===Rt){const t=nt.fileInput(null!==(r=d.caption)&&void 0!==r?r:d.name,null,(t=>{this.funcCall.outputs[d.name]=t}));d.category!==i&&n.append(e.h2(d.category)),n.append(t.root)}else{const r=d.propertyType===o.TYPE.DATA_FRAME?e.tableInput(null!==(a=d.caption)&&void 0!==a?a:d.name,null,t.shell.tables):e.input.forProperty(d);r.captionLabel.firstChild.replaceWith(e.span([null!==(l=d.caption)&&void 0!==l?l:d.name])),d.options.units&&r.addPostfix(d.options.units),r.onChanged((()=>{this.funcCall.outputs[s.name]=r.value,null===r.value?setTimeout((()=>r.input.classList.add("d4-invalid")),100):r.input.classList.remove("d4-invalid")})),d.category!==i&&n.append(e.h2(d.category)),n.append(r.root)}i=d.category})),n.classList.remove("ui-panel"),n.style.paddingTop="0px",n.style.paddingLeft="0px",n}renderInputForm(){const n=e.divV([],"ui-form");let i="Misc";if(r()(this.funcCall.inputParams.values()).filter((t=>!!t)).forEach((s=>{var r,a,l;const d=s.property;if(this.beforeInputPropertyRender.next(d),d.propertyType.toString()===Rt){const t=nt.fileInput(null!==(r=d.caption)&&void 0!==r?r:d.name,null,(t=>{this.funcCall.inputs[d.name]=t,this.checkDisability.next()}));if(this.runningOnInput){const e=t.onFileUploaded.subscribe((()=>xt(this,void 0,void 0,(function*(){return yield this.doRun()}))));this.subs.push(e)}d.category!==i&&n.append(e.h2(d.category)),n.append(t.root),this.afterInputPropertyRender.next({prop:d,input:t})}else{const r=d.propertyType===o.TYPE.DATA_FRAME?e.tableInput(null!==(a=d.caption)&&void 0!==a?a:d.name,null,t.shell.tables):e.input.forProperty(d);r.input.onkeydown=t=>xt(this,void 0,void 0,(function*(){"Enter"==t.key&&(yield this.doRun())})),r.captionLabel.firstChild.replaceWith(e.span([null!==(l=d.caption)&&void 0!==l?l:d.name])),d.options.units&&r.addPostfix(d.options.units),this.syncFuncCallReplaced(r,s),this.syncOnInput(r,s),this.syncValOnChanged(r,s),this.runningOnInput&&this.runOnInput(r,s),d.category!==i&&n.append(e.h2(d.category)),n.append(r.root),this.afterInputPropertyRender.next({prop:d,input:r})}i=d.category})),this.controllsDiv=void 0,this.beforeRenderControlls.next(!0),!this.controllsDiv){const t=this.getRunButton(),n=e.div([t]);e.tooltip.bind(n,(()=>t.disabled?this.isRunning?"Computations are in progress":"Some inputs are invalid":"")),this.controllsDiv=e.buttonsInput([n])}return n.classList.remove("ui-panel"),n.style.paddingTop="0px",n.style.paddingLeft="0px",this.checkDisability.next(),n}syncFuncCallReplaced(t,e){const n=e.property,i=this.funcCallReplaced.pipe((0,j.startWith)(!0)).subscribe((()=>{var i,s;const r=null!==(s=null!==(i=this.funcCall.inputs[e.name])&&void 0!==i?i:n.defaultValue)&&void 0!==s?s:null;e.property.propertyType===o.TYPE.DATA_FRAME?this.dfInputRecreate(t,e,r):(t.value=r,this.funcCall.inputs[e.name]=r)}));this.subs.push(i)}syncValOnChanged(t,e){const n=e.onChanged.subscribe((()=>{const n=this.funcCall.inputs[e.name];e.property.propertyType===o.TYPE.DATA_FRAME?this.dfInputRecreate(t,e,n):("number"==typeof n&&Math.abs(t.value-n)>1e-4||"number"!=typeof n)&&(t.notify=!1,t.value=n,t.notify=!0),this.checkDisability.next()}));this.subs.push(n)}isRunnable(){return r()(this.funcCall.inputs.values()).every((t=>null!=t))&&!this.isRunning}saveExperimentalRun(e){return xt(this,void 0,void 0,(function*(){const n=yield(yield t.functions.eval("Sin")).prepare({x:1}).call();e.dart.r2=n.dart.r2;let i=e.options.tags;i=i?[...i,at]:[at],e.options.tags=i,e.newId(),yield this.saveRun(e)}))}dfInputRecreate(n,i,o){var s;const r=i.property,a=e.tableInput(null!==(s=r.caption)&&void 0!==s?s:r.name,o,[...t.shell.tables,o]);n.root.replaceWith(a.root),n=a,this.syncOnInput(n,i),this.runningOnInput&&this.runOnDgInput(n,i),this.afterInputPropertyRender.next({prop:r,input:n})}syncOnInput(t,e){t.onInput((()=>{this.funcCall.inputs[e.name]=t.value,null===t.value?setTimeout((()=>t.input.classList.add("d4-invalid")),100):t.input.classList.remove("d4-invalid"),this.checkDisability.next()}))}runOnInput(t,e){t.onInput((()=>xt(this,void 0,void 0,(function*(){this.isRunnable()&&(yield this.doRun())}))))}runOnDgInput(t,e){t.onInput((()=>xt(this,void 0,void 0,(function*(){return yield this.doRun()}))));const n=t.value;if(n){const t=n.onDataChanged.subscribe((()=>xt(this,void 0,void 0,(function*(){this.isRunnable()&&(yield this.doRun())}))));this.subs.push(t)}}}const Et=(t,e)=>{const n=`${t}`;return n.length>31?t.substring(0,32):n},Tt=(t,e)=>{t.addRow(["Parameter","Value","Units"]).font={bold:!0},e.forEach((e=>{t.addRow([e.caption,e.value,e.units])})),t.getColumn(1).width=1.2*Math.max(...e.map((t=>t.caption.toString().length)),9),t.getColumn(2).width=1.2*Math.max(...e.map((t=>t.value.toString().length)),5),t.getColumn(3).width=1.2*Math.max(...e.map((t=>t.units.toString().length)),5)},Ft=(t,e,n=0,i=0)=>{for(let o=0;o<e.columns.names().length;o++)t.getCell(1+i,1+o+n).value=e.columns.byIndex(o).name,t.getColumn(1+o+n).width=1.2*Math.max(...e.columns.byIndex(o).categories.map((t=>t.toString().length)),e.columns.byIndex(o).name.length);for(let o=0;o<e.columns.length;o++)for(let s=0;s<e.rowCount;s++)t.getCell(s+2+i,1+n+o).value=e.columns.byIndex(o).get(s)},St=(t,e,n,i,o=0)=>xt(void 0,void 0,void 0,(function*(){const s=yield At()(n,{logging:!1}),r=s.toDataURL("image/png"),a=t.addImage({base64:r,extension:"png"});e.addImage(a,{tl:{col:i,row:o},ext:{width:s.width,height:s.height}})}));var Pt=n(433),Bt={};Bt.styleTagTransform=O(),Bt.setAttributes=S(),Bt.insert=T().bind(null,"head"),Bt.domAPI=I(),Bt.insertStyleElement=B(),x()(Pt.Z,Bt),Pt.Z&&Pt.Z.locals&&Pt.Z.locals;class kt{constructor(){this.scriptName="",this.description="",this.dfSheetsToSeek=[],this.scalarsToSeek=[],this.scriptText=new p.BehaviorSubject(""),this.infoText=new p.BehaviorSubject(""),this.lastSavedScriptId=new p.BehaviorSubject("")}}var Ot=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};class Vt extends o.ViewBase{constructor(){super(),this.store=new kt,this.scriptNameInput=e.stringInput("Script name","",(t=>this.store.scriptName=t)),this.descriptionInput=e.stringInput("Description","",(t=>this.store.description=t));const t=e.bigButton("Generate script",(()=>Ot(this,void 0,void 0,(function*(){return yield this.generate()})))),n=e.bigButton("Save",(()=>Ot(this,void 0,void 0,(function*(){return yield this.save()})))),i=e.bigButton("Open",(()=>Ot(this,void 0,void 0,(function*(){return this.open()}))));i.style.display="none",this.store.lastSavedScriptId.subscribe((t=>{""!==t&&i.style.removeProperty("display")}));const o=t=>{const n=e.button("Remove",(()=>{}));n.style.width=n.style.height,n.style.alignSelf="center",this.store.dfSheetsToSeek.push("");const i=e.divH([e.stringInput(`Sheet name #${t}`,"",(e=>this.store.dfSheetsToSeek[t]=e)).root,n],{style:{"justify-content":"space-between"}});return n.addEventListener("click",(()=>{this.store.dfSheetsToSeek.splice(t,1),i.remove()})),i},s=t=>{const n=e.button("Remove",(()=>{}));n.style.width=n.style.height,n.style.alignSelf="center",this.store.scalarsToSeek.push("");const i=e.divH([e.stringInput(`Scalar name #${t}`,"",(e=>this.store.scalarsToSeek[t]=e)).root,n],{style:{"justify-content":"space-between"}});return n.addEventListener("click",(()=>{this.store.scalarsToSeek.splice(t,1),i.remove()})),i},r=e.divV([]),a=e.button("Add DF to search",(()=>{r.append(o(this.store.dfSheetsToSeek.length))})),l=e.divV([]),d=e.button("Add scalar to search",(()=>{l.append(s(this.store.scalarsToSeek.length))})),u=e.divV([e.h3("Script properties"),this.scriptNameInput.root,this.descriptionInput.root,e.h3("Dataframes to search"),r,a,e.h3("Scalars to search"),l,d,e.divH([t],{style:{"justify-content":"flex-end"}})],"ui-form");let c=e.divText(this.store.scriptText.value),p=e.info(this.store.infoText.value);const h=e.panel([e.h3("Script text"),c,p,e.divH([n,i],{style:{"justify-content":"flex-end"}})],{style:{display:"none"}});this.store.scriptText.subscribe((t=>{const n=e.divText(t);c.replaceWith(n),c=n,""!==t&&h.style.removeProperty("display")})),this.store.infoText.subscribe((t=>{const n=""===t?e.div([]):e.info(t);p.replaceWith(n),p=n})),this.root.appendChild(e.splitH([u,h],{style:{height:"100%",width:"100%"}},!0)),e.tools.handleResize(u.parentElement,(t=>{t<350?u.classList.add("ui-form-condensed"):u.classList.remove("ui-form-condensed")})),u.parentElement.style.maxWidth="340px"}generate(){return Ot(this,void 0,void 0,(function*(){const e=this.store.dfSheetsToSeek.map((t=>`//output: dataframe ${t.trim()} { viewer: Grid(); }`)).join("\n"),n=this.store.scalarsToSeek.map((t=>`//output: string ${t.trim()}`)).join("\n"),i=`\nconst wb = new ExcelJS.Workbook();\nawait wb.xlsx.load(await uploadedFile.arrayBuffer());\nconst dfSheetsToSeek = ["${this.store.dfSheetsToSeek.join('","')}"];`;let o=`//name: ${this.store.scriptName}\n`;o+=`//description: ${this.store.description}\n`,o+="//language: javascript\n",o+="//input: file uploadedFile\n",o+=n+"\n",o+=e+"\n",o+="//editor: Compute:FunctionViewEditor\n",o+=i+"\n",this.store.dfSheetsToSeek.forEach((t=>{o+=(t=>`\nconst ${t}_ws = wb.getWorksheet("${t}");\nlet ${t}_data = await ${t}_ws.workbook.csv.writeBuffer();\n${t} = grok.data.parseCsv(${t}_data.toString());`)(t.trim())+"\n"})),o+="\nconst scalarSheets = wb.worksheets.filter(ws => !dfSheetsToSeek.includes(ws.name));\nconst scalarNames = scalarSheets.flatMap((sheet) => sheet.getColumn(1).values);\nconst scalarValues = scalarSheets.flatMap((sheet) => sheet.getColumn(2).values);",this.store.scalarsToSeek.forEach((t=>{var e;o+=`\nconst ${e=t}_index = scalarNames.findIndex((scalarName) => scalarName === "${e}");\n${e} = (${e}_index >= 0) ? scalarValues[${e}_index] : '';\n`})),this.store.scriptText.next(o),(yield t.dapi.scripts.filter(`name="${this.store.scriptName}"`).list()).length>0?this.store.infoText.next(`Script named "${this.store.scriptName}" already exists`):this.store.infoText.next("")}))}save(){return Ot(this,void 0,void 0,(function*(){const e=o.Script.create(this.store.scriptText.value),n=yield t.dapi.scripts.save(e);this.store.lastSavedScriptId.next(n.id),t.shell.info(`Script "${this.store.scriptName}" has been saved successfully`)}))}open(){window.open(`${window.location.origin}/script/${this.store.lastSavedScriptId.value}`)}}var Mt=function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((i=i.apply(t,e||[])).next())}))};let _t=!1;const Lt=new o.Package;function Dt(t){u.openModelFromFunccall(t)}function jt(){const e=new Vt;e.name="Import Script Gen",t.shell.addView(e),e.root.classList.remove("ui-panel")}function Nt(){return new c}function Wt(t){return It.fromFuncCall(t,{historyEnabled:!0,isTabbed:!1})}function $t(t){return It.fromFuncCall(t,{historyEnabled:!1,isTabbed:!0})}function Ht(t){return function(t){let n=o.View.create(),i=e.div(),s=e.stringInput("Function",t.name);function r(){n.name=t.name,e.empty(i);let s=o.DataFrame.fromProperties(t.inputs.concat(t.outputs),5),r=o.Grid.create(s),a=!1;r.onCellValueEdited.subscribe((e=>{var n;return function(e){for(let n=0;n<t.inputs.length;n++)if(s.columns.byIndex(n).isNone(e))return;let n={};for(let i of t.inputs)n[i.name]=s.col(i.name).get(e);a=!0;let i=t.prepare(n);i.call().then((n=>{for(let n of t.outputs)s.col(n.name).set(e,i.outputs[n.name]);a=!1}))}(null===(n=e.tableRow)||void 0===n?void 0:n.idx)})),i.appendChild(r.root)}return n.root.appendChild(s.root),n.root.appendChild(i),r(),s.onChanged((()=>{o.Func.findAll({name:s.value}).then((e=>{1==e.length&&(t=e[0],r())}))})),n}(t)}function Ut(){console.log("hof");let e=Ht(o.Func.byName("Sin"));e.parentCall=t.functions.getCurrentCall(),t.shell.addView(e)}function Gt(){var n,i,s;console.log("hof2");let r=Ht(o.Func.byName("Sin"));r.root.appendChild(e.narrowForm([e.switchInput("test",!0),e.boolInput("test",!0)])),r.root.appendChild(e.form([e.switchInput("test",!0),e.boolInput("test",!0)])),r.parentCall=t.functions.getCurrentCall(),r.parentView=null===(n=r.parentCall.parentCall)||void 0===n?void 0:n.aux.view,null===(i=r.parentCall.parentCall)||void 0===i||i.aux.url,null===(s=r.parentCall)||void 0===s||s.aux.url,r.basePath="/"+r.parentCall.func.name,r.path="/",t.shell.addView(r)}function Yt(n){return Mt(this,void 0,void 0,(function*(){let i={};n.inputs.forEach((t=>i[t.name]=null));let s=`\ncurl --location --request POST '${t.settings.apiUrl}/v1/func/${n.nqName}/run' \\\n--header 'Authorization: ${zt("auth")}' \\\n--header 'Content-Type: application/json' \\\n--data-raw '${JSON.stringify(i)}'`,r=`\nvar myHeaders = new Headers();\nmyHeaders.append("Authorization", "${zt("auth")}");\nmyHeaders.append("Content-Type", "application/json");\n\nvar raw = JSON.stringify(${JSON.stringify(i)});\n\nvar requestOptions = {\n method: 'POST',\n headers: myHeaders,\n body: raw,\n redirect: 'follow'\n};\n\nfetch("${t.settings.apiUrl}/v1/func/${n.nqName}/run", requestOptions)\n .then(response => response.text())\n .then(result => console.log(result))\n .catch(error => console.log('error', error));`,a=e.tabControl({CURL:e.div([e.divText(s)]),JS:e.div([e.divText(r)])});return o.Widget.fromRoot(a.root)}))}function zt(t){let e=document.cookie.match(new RegExp("(?:^|; )"+t.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):void 0}function Zt(){}function qt(){_t||(o.ObjectHandler.register(new u),t.events.onAccordionConstructed.subscribe((t=>{const n=t.context;null!=n&&"script"==n.type&&(t.getPane("REST")||t.addPane("REST",(()=>e.wait((()=>Mt(this,void 0,void 0,(function*(){return(yield Yt(n)).root})))))))})),_t=!0)}function Xt(){let e=u.findModelCatalogView();if(null==e){let e=new l;e.name="ModelHub";let n=document.createElement("a");n.href=window.location.href;let i=n.pathname.split("/");t.shell.addView(e),i.length>3&&t.dapi.functions.filter(`shortName = "${i[3]}" and #model`).list().then((t=>{1==t.length&&u.openModel(t[0])}))}else t.shell.v=e}})(),compute=i})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|