@datagrok/hit-triage 1.1.8 → 1.1.10
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/CHANGELOG.md +8 -0
- package/css/hit-triage.css +2 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +2 -2
- package/src/app/accordeons/new-hit-design-template-accordeon.ts +2 -9
- package/src/app/accordeons/new-template-accordeon.ts +2 -9
- package/src/app/base-view.ts +3 -3
- package/src/app/dialogs/functions-dialog.ts +4 -1
- package/src/app/hit-app-base.ts +3 -1
- package/src/app/hit-design-app.ts +36 -15
- package/src/app/hit-design-views/info-view.ts +3 -11
- package/src/app/hit-design-views/tiles-view.ts +65 -37
- package/src/app/hit-triage-app.ts +17 -2
- package/src/app/hit-triage-views/info-view.ts +3 -11
- package/src/app/types.ts +11 -2
- package/src/app/utils/calculate-single-cell.ts +23 -14
- package/src/app/utils.ts +21 -1
- package/src/package.ts +30 -4
package/CHANGELOG.md
CHANGED
package/css/hit-triage.css
CHANGED
package/dist/package.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var hittriage;(()=>{var e={553:e=>{!function(){"use strict";var t=document,n=window,i=t.documentElement,o=t.createElement.bind(t),a=o("div"),s=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,m=u.indexOf,h=u.map,f=u.push,v=u.slice,g=u.some,y=u.splice,b=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,w=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(e,t){var n,i=!!(n=t)&&11===n.nodeType;return e&&(i||_(t)||F(t))?!i&&w.test(e)?t.getElementsByClassName(e.slice(1).replace(/\\/g,"")):!i&&A.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e):[]}var x=function(){function e(e,i){if(e){if(N(e))return e;var o=e;if(P(e)){var a=i||t;if(!(o=b.test(e)&&_(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?X(e):N(a)?a.find(e):P(a)?E(a).find(e):T(e,a)))return}else if(O(e))return this.ready(e);(o.nodeType||o===n)&&(o=[o]),this.length=o.length;for(var s=0,r=this.length;s<r;s++)this[s]=o[s]}}return e.prototype.init=function(t,n){return new e(t,n)},e}(),I=x.prototype,E=I.init;function N(e){return e instanceof x}function S(e){return!!e&&e===e.window}function _(e){return!!e&&9===e.nodeType}function F(e){return!!e&&1===e.nodeType}function B(e){return"boolean"==typeof e}function O(e){return"function"==typeof e}function P(e){return"string"==typeof e}function k(e){return void 0===e}function V(e){return null===e}function L(e){return!isNaN(parseFloat(e))&&isFinite(e)}function j(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function D(e,t,n){if(n){for(var i=e.length;i--;)if(!1===t.call(e[i],i,e[i]))return e}else if(j(e))for(var o=Object.keys(e),a=(i=0,o.length);i<a;i++){var s=o[i];if(!1===t.call(e[s],s,e[s]))return e}else for(i=0,a=e.length;i<a;i++)if(!1===t.call(e[i],i,e[i]))return e;return e}function H(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=!!B(e[0])&&e.shift(),i=e.shift(),o=e.length;if(!i)return{};if(!o)return H(n,E,i);for(var a=0;a<o;a++){var s=e[a];for(var r in s)n&&(c(s[r])||j(s[r]))?(i[r]&&i[r].constructor===s[r].constructor||(i[r]=new s[r].constructor),H(n,i[r],s[r])):i[r]=s[r]}return i}E.fn=E.prototype=I,I.length=0,I.splice=y,"function"==typeof Symbol&&(I[Symbol.iterator]=u[Symbol.iterator]),E.isWindow=S,E.isFunction=O,E.isArray=c,E.isNumeric=L,E.isPlainObject=j,E.each=D,I.each=function(e){return D(this,e)},I.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},E.extend=H,I.extend=function(e){return H(I,e)};var M=/\S+/g;function R(e){return P(e)&&e.match(M)||[]}function U(e,t,i){if(F(e)){var o=n.getComputedStyle(e,null);return i?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function $(e,t){return parseInt(U(e,t),10)||0}function q(e,t){return $(e,"border".concat(t?"Left":"Top","Width"))+$(e,"padding".concat(t?"Left":"Top"))+$(e,"padding".concat(t?"Right":"Bottom"))+$(e,"border".concat(t?"Right":"Bottom","Width"))}I.toggleClass=function(e,t){var n=R(e),i=!k(t);return this.each((function(e,o){F(o)&&D(n,(function(e,n){i?t?o.classList.add(n):o.classList.remove(n):o.classList.toggle(n)}))}))},I.addClass=function(e){return this.toggleClass(e,!0)},I.removeAttr=function(e){var t=R(e);return this.each((function(e,n){F(n)&&D(t,(function(e,t){n.removeAttribute(t)}))}))},I.attr=function(e,t){if(e){if(P(e)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var n=this[0].getAttribute(e);return V(n)?void 0:n}return k(t)?this:V(t)?this.removeAttr(e):this.each((function(n,i){F(i)&&i.setAttribute(e,t)}))}for(var i in e)this.attr(i,e[i]);return this}},I.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},I.hasClass=function(e){return!!e&&g.call(this,(function(t){return F(t)&&t.classList.contains(e)}))},I.get=function(e){return k(e)?v.call(this):this[(e=Number(e))<0?e+this.length:e]},I.eq=function(e){return E(this.get(e))},I.first=function(){return this.eq(0)},I.last=function(){return this.eq(-1)},I.text=function(e){return k(e)?this.get().map((function(e){return F(e)||(t=e)&&3===t.nodeType?e.textContent:"";var t})).join(""):this.each((function(t,n){F(n)&&(n.textContent=e)}))};var Y={};function W(e){return"none"===U(e,"display")}function G(e,t){var n=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!n&&!!t&&n.call(e,t)}function J(e){return P(e)?function(t,n){return G(n,e)}:O(e)?e:N(e)?function(t,n){return e.is(n)}:e?function(t,n){return n===e}:function(){return!1}}function Z(e,t){return t?e.filter(t):e}I.filter=function(e){var t=J(e);return E(p.call(this,(function(e,n){return t.call(e,n,e)})))},I.detach=function(e){return Z(this,e).each((function(e,t){t.parentNode&&t.parentNode.removeChild(t)})),this};var z=/^\s*<(\w+)[^>]*>/,Q=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,K={"*":a,tr:r,td:l,th:l,thead:s,tbody:s,tfoot:s};function X(e){if(!P(e))return[];if(Q.test(e))return[o(RegExp.$1)];var t=z.test(e)&&RegExp.$1,n=K[t]||K["*"];return n.innerHTML=e,E(n.childNodes).detach().get()}function ee(e,t,n,i){for(var o=[],a=O(t),s=i&&J(i),r=0,l=e.length;r<l;r++)if(a){var c=t(e[r]);c.length&&f.apply(o,c)}else for(var u=e[r][t];!(null==u||i&&s(-1,u));)o.push(u),u=n?u[t]:null;return o}function te(e){return e.multiple&&e.options?ee(p.call(e.options,(function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled})),"value"):e.value||""}function ne(e){return e.length>1?p.call(e,(function(e,t,n){return m.call(n,e)===t})):e}E.parseHTML=X,I.has=function(e){var t=P(e)?function(t,n){return T(e,n).length}:function(t,n){return n.contains(e)};return this.filter(t)},I.not=function(e){var t=J(e);return this.filter((function(n,i){return(!P(e)||F(i))&&!t.call(i,n,i)}))},I.val=function(e){return arguments.length?this.each((function(t,n){var i=n.multiple&&n.options;if(i||Pe.test(n.type)){var o=c(e)?h.call(e,String):V(e)?[]:[String(e)];i?D(n.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):n.checked=o.indexOf(n.value)>=0}else n.value=k(e)||V(e)?"":e})):this[0]&&te(this[0])},I.is=function(e){var t=J(e);return g.call(this,(function(e,n){return t.call(e,n,e)}))},E.guid=1,E.unique=ne,I.add=function(e,t){return E(ne(this.get().concat(E(e,t).get())))},I.children=function(e){return Z(E(ne(ee(this,(function(e){return e.children})))),e)},I.parent=function(e){return Z(E(ne(ee(this,"parentNode"))),e)},I.index=function(e){var t=e?E(e)[0]:this[0],n=e?this:E(t).parent().children();return m.call(n,t)},I.closest=function(e){var t=this.filter(e);if(t.length)return t;var n=this.parent();return n.length?n.closest(e):t},I.siblings=function(e){return Z(E(ne(ee(this,(function(e){return E(e).parent().children().not(e)})))),e)},I.find=function(e){return E(ne(ee(this,(function(t){return T(e,t)}))))};var ie=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,oe=/^$|^module$|\/(java|ecma)script/i,ae=["type","src","nonce","noModule"];function se(e,t,n,a,s,r,l,c){return D(e,(function(e,r){D(E(r),(function(e,r){D(E(t),(function(t,l){var c=n?l:r,u=n?e:t;!function(e,t,n,a,s){a?e.insertBefore(t,n?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,n?e:e.nextSibling),s&&function(e,t){var n=E(e);n.filter("script").add(n.find("script")).each((function(e,n){if(oe.test(n.type)&&i.contains(n)){var a=o("script");a.text=n.textContent.replace(ie,""),D(ae,(function(e,t){n[t]&&(a[t]=n[t])})),t.head.insertBefore(a,null),t.head.removeChild(a)}}))}(t,e.ownerDocument)}(n?r:l,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),t}I.after=function(){return se(arguments,this,!1,!1,!1,!0,!0)},I.append=function(){return se(arguments,this,!1,!1,!0)},I.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(k(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(n,i){F(i)&&(t?E(i).empty().append(e):i.innerHTML=e)}))},I.appendTo=function(e){return se(arguments,this,!0,!1,!0)},I.wrapInner=function(e){return this.each((function(t,n){var i=E(n),o=i.contents();o.length?o.wrapAll(e):i.append(e)}))},I.before=function(){return se(arguments,this,!1,!0)},I.wrapAll=function(e){for(var t=E(e),n=t[0];n.children.length;)n=n.firstElementChild;return this.first().before(t),this.appendTo(n)},I.wrap=function(e){return this.each((function(t,n){var i=E(e)[0];E(n).wrapAll(t?i.cloneNode(!0):i)}))},I.insertAfter=function(e){return se(arguments,this,!0,!1,!1,!1,!1,!0)},I.insertBefore=function(e){return se(arguments,this,!0,!0)},I.prepend=function(){return se(arguments,this,!1,!0,!0,!0,!0)},I.prependTo=function(e){return se(arguments,this,!0,!0,!0,!1,!1,!0)},I.contents=function(){return E(ne(ee(this,(function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes}))))},I.next=function(e,t,n){return Z(E(ne(ee(this,"nextElementSibling",t,n))),e)},I.nextAll=function(e){return this.next(e,!0)},I.nextUntil=function(e,t){return this.next(t,!0,e)},I.parents=function(e,t){return Z(E(ne(ee(this,"parentElement",!0,t))),e)},I.parentsUntil=function(e,t){return this.parents(t,e)},I.prev=function(e,t,n){return Z(E(ne(ee(this,"previousElementSibling",t,n))),e)},I.prevAll=function(e){return this.prev(e,!0)},I.prevUntil=function(e,t){return this.prev(t,!0,e)},I.map=function(e){return E(d.apply([],h.call(this,(function(t,n){return e.call(t,n,t)}))))},I.clone=function(){return this.map((function(e,t){return t.cloneNode(!0)}))},I.offsetParent=function(){return this.map((function(e,t){for(var n=t.offsetParent;n&&"static"===U(n,"position");)n=n.offsetParent;return n||i}))},I.slice=function(e,t){return E(v.call(this,e,t))};var re=/-([a-z])/g;function le(e){return e.replace(re,(function(e,t){return t.toUpperCase()}))}I.ready=function(e){var n=function(){return setTimeout(e,0,E)};return"loading"!==t.readyState?n():t.addEventListener("DOMContentLoaded",n),this},I.unwrap=function(){return this.parent().each((function(e,t){if("BODY"!==t.tagName){var n=E(t);n.replaceWith(n.children())}})),this},I.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}}},I.position=function(){var e=this[0];if(e){var t="fixed"===U(e,"position"),n=t?e.getBoundingClientRect():this.offset();if(!t){for(var i=e.ownerDocument,o=e.offsetParent||i.documentElement;(o===i.body||o===i.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==e&&F(o)){var a=E(o).offset();n.top-=a.top+$(o,"borderTopWidth"),n.left-=a.left+$(o,"borderLeftWidth")}}return{top:n.top-$(e,"marginTop"),left:n.left-$(e,"marginLeft")}}};var ce={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};I.prop=function(e,t){if(e){if(P(e))return e=ce[e]||e,arguments.length<2?this[0]&&this[0][e]:this.each((function(n,i){i[e]=t}));for(var n in e)this.prop(n,e[n]);return this}},I.removeProp=function(e){return this.each((function(t,n){delete n[ce[e]||e]}))};var ue=/^--/;function de(e){return ue.test(e)}var pe={},me=a.style,he=["webkit","moz","ms"];function fe(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!pe[e]){var n=le(e),i="".concat(n[0].toUpperCase()).concat(n.slice(1));D("".concat(n," ").concat(he.join("".concat(i," "))).concat(i).split(" "),(function(t,n){if(n in me)return pe[e]=n,!1}))}return pe[e]}var ve={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function ge(e,t,n){return void 0===n&&(n=de(e)),n||ve[e]||!L(t)?t:"".concat(t,"px")}function ye(e,t){try{return e(t)}catch(e){return t}}I.css=function(e,t){if(P(e)){var n=de(e);return e=fe(e,n),arguments.length<2?this[0]&&U(this[0],e,n):e?(t=ge(e,t,n),this.each((function(i,o){F(o)&&(n?o.style.setProperty(e,t):o.style[e]=t)}))):this}for(var i in e)this.css(i,e[i]);return this};var be=/^\s+|\s+$/;function we(e,t){var n=e.dataset[t]||e.dataset[le(t)];return be.test(n)?n:ye(JSON.parse,n)}function Ce(e,t,n){n=ye(JSON.stringify,n),e.dataset[le(t)]=n}function Ae(e,t){var n=e.documentElement;return Math.max(e.body["scroll".concat(t)],n["scroll".concat(t)],e.body["offset".concat(t)],n["offset".concat(t)],n["client".concat(t)])}I.data=function(e,t){if(!e){if(!this[0])return;var n={};for(var i in this[0].dataset)n[i]=we(this[0],i);return n}if(P(e))return arguments.length<2?this[0]&&we(this[0],e):k(t)?this:this.each((function(n,i){Ce(i,e,t)}));for(var i in e)this.data(i,e[i]);return this},D([!0,!1],(function(e,t){D(["Width","Height"],(function(e,n){var i="".concat(t?"outer":"inner").concat(n);I[i]=function(i){if(this[0])return S(this[0])?t?this[0]["inner".concat(n)]:this[0].document.documentElement["client".concat(n)]:_(this[0])?Ae(this[0],n):this[0]["".concat(t?"offset":"client").concat(n)]+(i&&t?$(this[0],"margin".concat(e?"Top":"Left"))+$(this[0],"margin".concat(e?"Bottom":"Right")):0)}}))})),D(["Width","Height"],(function(e,t){var n=t.toLowerCase();I[n]=function(i){if(!this[0])return k(i)?void 0:this;if(!arguments.length)return S(this[0])?this[0].document.documentElement["client".concat(t)]:_(this[0])?Ae(this[0],t):this[0].getBoundingClientRect()[n]-q(this[0],!e);var o=parseInt(i,10);return this.each((function(t,i){if(F(i)){var a=U(i,"boxSizing");i.style[n]=ge(n,o+("border-box"===a?q(i,!e):0))}}))}})),I.toggle=function(e){return this.each((function(n,i){if(F(i)){var a=W(i);(k(e)?a:e)?(i.style.display=i.___cd||"",W(i)&&(i.style.display=function(e){if(Y[e])return Y[e];var n=o(e);t.body.insertBefore(n,null);var i=U(n,"display");return t.body.removeChild(n),Y[e]="none"!==i?i:"block"}(i.tagName))):a||(i.___cd=U(i,"display"),i.style.display="none")}}))},I.hide=function(){return this.toggle(!1)},I.show=function(){return this.toggle(!0)};var Te={focus:"focusin",blur:"focusout"},xe={mouseenter:"mouseover",mouseleave:"mouseout"},Ie=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Ee(e){return xe[e]||Te[e]||e}function Ne(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Se(e){return e.___ce=e.___ce||{}}function _e(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function Fe(e,t,n,i,o){var a=Se(e);if(t)a[t]&&(a[t]=a[t].filter((function(a){var s=a[0],r=a[1],l=a[2];if(o&&l.guid!==o.guid||!_e(s,n)||i&&i!==r)return!0;e.removeEventListener(t,l)})));else for(t in a)Fe(e,t,n,i,o)}I.trigger=function(e,n){if(P(e)){var i=Ne(e),o=i[0],a=i[1],s=Ee(o);if(!s)return this;var r=Ie.test(s)?"MouseEvents":"HTMLEvents";(e=t.createEvent(r)).initEvent(s,!0,!0),e.namespace=a.join("."),e.___ot=o}e.___td=n;var l=e.___ot in Te;return this.each((function(t,n){l&&O(n[e.___ot])&&(n["___i".concat(e.type)]=!0,n[e.___ot](),n["___i".concat(e.type)]=!1),n.dispatchEvent(e)}))},I.off=function(e,t,n){var i=this;if(k(e))this.each((function(e,t){(F(t)||_(t)||S(t))&&Fe(t)}));else if(P(e))O(t)&&(n=t,t=""),D(R(e),(function(e,o){var a=Ne(o),s=a[0],r=a[1],l=Ee(s);i.each((function(e,i){(F(i)||_(i)||S(i))&&Fe(i,l,r,t,n)}))}));else for(var o in e)this.off(o,e[o]);return this},I.remove=function(e){return Z(this,e).detach().off(),this},I.replaceWith=function(e){return this.before(e).remove()},I.replaceAll=function(e){return E(e).replaceWith(this),this},I.on=function(e,t,n,i,o){var a=this;if(!P(e)){for(var s in e)this.on(s,t,n,e[s],o);return this}return P(t)||(k(t)||V(t)?t="":k(n)?(n=t,t=""):(i=n,n=t,t="")),O(i)||(i=n,n=void 0),i?(D(R(e),(function(e,s){var r=Ne(s),l=r[0],c=r[1],u=Ee(l),d=l in xe,p=l in Te;u&&a.each((function(e,a){if(F(a)||_(a)||S(a)){var s=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||_e(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===u)||d&&e.relatedTarget&&a.contains(e.relatedTarget)))){var r=a;if(t){for(var l=e.target;!G(l,t);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return n}});var m=i.call(r,e,e.___td);o&&Fe(a,u,c,t,s),!1===m&&(e.preventDefault(),e.stopPropagation())}};s.guid=i.guid=i.guid||E.guid++,function(e,t,n,i,o){var a=Se(e);a[t]=a[t]||[],a[t].push([n,i,o]),e.addEventListener(t,o)}(a,u,c,t,s)}}))})),this):this},I.one=function(e,t,n,i){return this.on(e,t,n,i,!0)};var Be=/\r?\n/g,Oe=/file|reset|submit|button|image/i,Pe=/radio|checkbox/i;I.serialize=function(){var e="";return this.each((function(t,n){D(n.elements||[n],(function(t,n){if(!(n.disabled||!n.name||"FIELDSET"===n.tagName||Oe.test(n.type)||Pe.test(n.type)&&!n.checked)){var i=te(n);k(i)||D(c(i)?i:[i],(function(t,i){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(Be,"\r\n")))}(n.name,i)}))}}))})),e.slice(1)},e.exports=E}()},631:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var i=n(537),o=n.n(i),a=n(645),s=n.n(a)()(o());s.push([e.id,".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 700px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}","",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,oBAAoB;AACxB;;AAEA;IACI,YAAY;IACZ,kCAAkC;IAClC,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,yBAAyB;IACzB,2BAA2B;AAC/B;;AAEA;IACI,oCAAoC;IACpC,yBAAyB;AAC7B;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,YAAY;IACZ,wBAAwB;AAC5B;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,iBAAiB;IACjB,2BAA2B;IAC3B,kBAAkB;AACtB;;;AAGA;IACI,sBAAsB;AAC1B;;AAEA;IACI,iBAAiB;IACjB,gBAAgB;AACpB;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;CACC,gBAAgB;IACb,mBAAmB;IACnB,uBAAuB;CAC1B,iBAAiB;IACd,UAAU;AACd;;AAEA;CACC,cAAc;CACd,eAAe;CACf,iBAAiB;AAClB;;AAEA;CACC,mBAAmB;IAChB,gBAAgB;IAChB,uBAAuB;AAC3B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 700px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}"],sourceRoot:""}]);const r=s},290:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var i=n(537),o=n.n(i),a=n(645),s=n.n(a)()(o());s.push([e.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}"],sourceRoot:""}]);const r=s},143:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var i=n(537),o=n.n(i),a=n(645),s=n.n(a)()(o());s.push([e.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}"],sourceRoot:""}]);const r=s},645:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n="",i=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),i&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),i&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n})).join("")},t.i=function(e,n,i,o,a){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(i)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(s[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);i&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),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)),t.push(u))}},t}},537:e=>{"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),a="/*# ".concat(o," */");return[t].concat([a]).join("\n")}return[t].join("\n")}},379:e=>{"use strict";var t=[];function n(e){for(var n=-1,i=0;i<t.length;i++)if(t[i].identifier===e){n=i;break}return n}function i(e,i){for(var a={},s=[],r=0;r<e.length;r++){var l=e[r],c=i.base?l[0]+i.base:l[0],u=a[c]||0,d="".concat(c," ").concat(u);a[c]=u+1;var p=n(d),m={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(m);else{var h=o(m,i);i.byIndex=r,t.splice(r,0,{identifier:d,updater:h,references:1})}s.push(d)}return s}function o(e,t){var n=t.domAPI(t);return n.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;n.update(e=t)}else n.remove()}}e.exports=function(e,o){var a=i(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<a.length;s++){var r=n(a[s]);t[r].references--}for(var l=i(e,o),c=0;c<a.length;c++){var u=n(a[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}a=l}}},569:e=>{"use strict";var t={};e.exports=function(e,n){var i=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);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)}},216:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},565:(e,t,n)=>{"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},795:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){!function(e,t,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 a=n.sourceMap;a&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),t.styleTagTransform(i,e,t.options)}(t,e,n)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},589:e=>{"use strict";e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var a=t[i]={id:i,exports:{}};return e[i](a,a.exports,n),a.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0;var i={};(()=>{"use strict";n.r(i),n.d(i,{_package:()=>Fe,demoFileIngest:()=>Pe,demoFileIngest1:()=>ke,demoFileIngest2:()=>Ve,demoFileSubmit:()=>Le,gasteigerCellRenderer:()=>je,hitDesignApp:()=>Oe,hitTriageApp:()=>Be});const e=grok,t=DG,o=ui,a="campaignId",s="campaignId",r="HitTriageFunction",l="HitTriageDataSource",c="HitTriageSubmitFunction",u="Selected hits",d="Stage",p="Molecule",m="V-iD",h="V######",f="HTScript",v="HTQuery",g="molecules",y="Source",b="New template",w="Start",C="Create",A="Download",T="Cancel",x="Continue a campaign",I="New campaign";var E=n(379),N=n.n(E),S=n(795),_=n.n(S),F=n(569),B=n.n(F),O=n(565),P=n.n(O),k=n(216),V=n.n(k),L=n(589),j=n.n(L),D=n(631),H={};H.styleTagTransform=j(),H.setAttributes=P(),H.insert=B().bind(null,"head"),H.domAPI=_(),H.insertStyleElement=V(),N()(D.Z,H),D.Z&&D.Z.locals&&D.Z.locals;const M=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function R(e,t){const n=document.title,i=window.location.href.split("?")[0]+"?"+e+"="+t;if(history.replaceState){const e={Title:n,Url:i};history.replaceState(e,e.Title,e.Url)}}function U(t,n,i,a){var s;const r=o.breadcrumbs([n,i]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),$(t),a())})),c=null===(s=e.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function $(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function q(e){return e.reduce(((e,t)=>e||t.reduce(((e,t)=>e||t.classList.contains("hit-design-submit-button")||Array.from(t.children).some((e=>e.classList.contains("hit-design-submit-button")))),!1)),!1)}function Y(e,n,i){return o=this,a=void 0,r=function*(){if(0===i.rowCount)return;if(!e.col(n))throw new Error("There is no molecule column in dataframe");let o=i.col(g);if(o||(yield i.meta.detectSemanticTypes(),o=i.columns.bySemType(t.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=i.columns.names().filter((e=>e!==g));e.join(i,[n],[o.name],void 0,a,void 0,!0)},new((s=void 0)||(s=Promise))((function(e,t){function n(e){try{l(r.next(e))}catch(e){t(e)}}function i(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s((function(e){e(o)}))).then(n,i)}l((r=r.apply(o,a||[])).next())}));var o,a,s,r}const W={String:t.TYPE.STRING,Number:t.TYPE.FLOAT,Boolean:t.TYPE.BOOL,Date:t.TYPE.DATE_TIME,Molecule:t.SEMTYPE.MOLECULE};var G=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))},J=n(553),Z=n.n(J);function z(n,i,a,s,r){var l,c,u,d,p,m,h,g,y,b,w,C,A,T,x,I,E,N,S,_,F,B,O,P,k,V,L,j,D,H,M;return j=this,D=void 0,M=function*(){const j=yield n.computeFunctions,D=j.functions.filter((({inputs:e})=>e.length>2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).map((e=>{var t,n,i,o;return{package:e.package.name,name:e.name,args:null!==(o=null===(i=null===(n=null===(t=null==s?void 0:s.compute)||void 0===t?void 0:t.functions)||void 0===n?void 0:n.find((t=>t.name===e.name&&t.package===e.package.name)))||void 0===i?void 0:i.args)&&void 0!==o?o:{}}})),H=j.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).map((e=>{var t,n,i,o;return{name:e.name,id:e.id,args:null!==(o=null===(i=null===(n=null===(t=null==s?void 0:s.compute)||void 0===t?void 0:t.scripts)||void 0===n?void 0:n.find((t=>t.id===e.id)))||void 0===i?void 0:i.args)&&void 0!==o?o:{}}})),M=j.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).map((e=>{var t,n,i,o,a;return{name:null!==(t=e.friendlyName)&&void 0!==t?t:e.name,id:e.id,args:null!==(a=null===(o=null===(i=null===(n=null==s?void 0:s.compute)||void 0===n?void 0:n.queries)||void 0===i?void 0:i.find((t=>t.id===e.id)))||void 0===o?void 0:o.args)&&void 0!==a?a:{}}})),R=!!(null===(c=null===(l=null==s?void 0:s.compute)||void 0===l?void 0:l.descriptors)||void 0===c?void 0:c.enabled)||r,U=yield e.chem.descriptorsTree(),$=o.tree();$.root.classList.add("hit-triage-compute-dialog-descriptors-group");const q=o.div([],{classes:"hit-triage-compute-dialog-host"}),Y=[];function W(e,t){const n=t.group(e,null,!1);return n.enableCheckBox(!1),n}const G=Object.keys(U),J=null!==(p=null===(d=null===(u=null==s?void 0:s.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[];for(const e of G){const t=W(e,$);for(const n of U[e].descriptors){const e=t.item(n.name,n);Y.push(e),e.enableCheckBox(J.includes(n.name))}}const z="Descriptors",Q={[z]:z},K=R?{[z]:$.root}:{},X={},ee={[z]:!1};ee.Descriptors=!!(null===(h=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===h?void 0:h.enabled)&&(null===(b=null===(y=null===(g=null==s?void 0:s.compute)||void 0===g?void 0:g.descriptors)||void 0===y?void 0:y.args)||void 0===b?void 0:b.length)>0;for(const e of D)try{const n=t.Func.find({package:e.package,name:e.name})[0],i=n.prepare(e.args),a=`${e.package}:${e.name}`;X[a]=i;const r=o.div(),l=yield i.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(w=n.friendlyName)&&void 0!==w?w:n.name]=r,Q[null!==(C=n.friendlyName)&&void 0!==C?C:n.name]=a,ee[a]=null!==(x=null===(T=null===(A=null==s?void 0:s.compute)||void 0===A?void 0:A.functions)||void 0===T?void 0:T.some((t=>t.name===e.name&&t.package===e.package)))&&void 0!==x&&x,r.children[0].style.display="none",r.children[1].style.display="none",l.forEach((t=>{var n,i;(null===(n=t.property)||void 0===n?void 0:n.name)&&Object.keys(e.args).includes(null===(i=t.property)||void 0===i?void 0:i.name)&&(t.value=e.args[t.property.name]),t.fireChanged()}))}catch(e){console.error(e);continue}for(const t of H)try{const n=yield e.dapi.scripts.find(t.id),i=n.prepare(t.args),a=`HTScript:${null!==(I=t.name)&&void 0!==I?I:""}:${t.id}`;X[a]=i;const r=o.div(),l=yield i.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(E=n.friendlyName)&&void 0!==E?E:n.name]=r,Q[null!==(N=n.friendlyName)&&void 0!==N?N:n.name]=a,ee[a]=null!==(F=null===(_=null===(S=null==s?void 0:s.compute)||void 0===S?void 0:S.scripts)||void 0===_?void 0:_.some((e=>e.id===t.id)))&&void 0!==F&&F,r.children[0].style.display="none",r.children[1].style.display="none",l.forEach((e=>{var n,i;(null===(n=e.property)||void 0===n?void 0:n.name)&&Object.keys(t.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=t.args[e.property.name]),e.fireChanged()}))}catch(e){console.error(e);continue}for(const t of M)try{const n=yield e.dapi.queries.find(t.id),i=n.prepare(t.args),a=`HTQuery:${null!==(B=t.name)&&void 0!==B?B:""}:${t.id}`;X[a]=i;const r=o.div(),l=yield i.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",K[null!==(O=n.friendlyName)&&void 0!==O?O:n.name]=r,Q[null!==(P=n.friendlyName)&&void 0!==P?P:n.name]=a,ee[a]=null!==(L=null===(V=null===(k=null==s?void 0:s.compute)||void 0===k?void 0:k.queries)||void 0===V?void 0:V.some((e=>e.id===t.id)))&&void 0!==L&&L,r.children[0].style.display="none",l.forEach((e=>{var n,i;(null===(n=e.property)||void 0===n?void 0:n.name)&&Object.keys(t.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=t.args[e.property.name]),e.fireChanged()}))}catch(e){console.error(e);continue}const te=o.tabControl(K,!0);function ne(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=ee.Descriptors?Y.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(X).filter((([e,t])=>ee[e]));t.filter((([e,t])=>!e.startsWith(f)&&!e.startsWith(v))).forEach((([t,n])=>{e.externals[t]={};const i=n.inputs;Object.entries(i).slice(2).forEach((([n,i])=>{e.externals[t][n]=i}))})),t.filter((([e,t])=>e.startsWith(f))).forEach((([t,n])=>{e.scripts[t]={};const i=n.inputs;Object.entries(i).slice(2).forEach((([n,i])=>{e.scripts[t][n]=i}))})),t.filter((([e,t])=>e.startsWith(v))).forEach((([t,n])=>{e.queries[t]={};const i=n.inputs;Object.entries(i).slice(1).forEach((([n,i])=>{e.queries[t][n]=i}))})),console.log(e),i(e)}return te.header.style.overflow="scroll",te.root.style.width="100%",te.root.style.minWidth="350px",q.appendChild(te.root),te.panes.forEach((e=>{const t=o.boolInput("",ee[Q[e.name]],(n=>{ee[Q[e.name]]=!!t.value,n?Z()(e.content).find("input").removeAttr("disabled"):Z()(e.content).find("input").attr("disabled","true")}));t.setTooltip("Toggle calculation of this function"),e.header.appendChild(t.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),r&&o.dialog("Compute").add(q).onOK((()=>ne())).onCancel(a).show(),{root:q,okProxy:ne}},new((H=void 0)||(H=Promise))((function(e,t){function n(e){try{o(M.next(e))}catch(e){t(e)}}function i(e){try{o(M.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof H?o:new H((function(e){e(o)}))).then(n,i)}o((M=M.apply(j,D||[])).next())}))}const Q=rxjs;class K{constructor(e,t=[],n={}){this.onItemChanged=new Q.Subject,this.onAddingItemChanged=new Q.Subject,this.onItemAdded=new Q.Subject,this.onItemRemoved=new Q.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=e,this.options=Object.assign(Object.assign({},this.options),n),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,this.render()}get root(){return this._root}get items(){return this._items}render(){var e,t,n,i;if(o.empty(this._root),!this.options.horizontalInputNames)for(const t of this.properties){const n=o.divText(null!==(e=t.caption)&&void 0!==e?e:t.name);n.style.fontWeight="bold",this._root.appendChild(n)}for(const e of this._items){const t=this.getItemDiv(e);for(const e of t)this._root.appendChild(e)}if(this.options.allowAdd){const e=this.getItemDiv(null!==(i=null===(n=(t=this.options).newItemFunction)||void 0===n?void 0:n.call(t))&&void 0!==i?i:void 0,!0);for(const t of e)this._root.appendChild(t)}}getItemDiv(e={},n){var i;const a=[],s={};let r=null;for(const l of this.properties){void 0===e[l.name]&&(e[l.name]=null);const c=(null===(i=this.options.customInputs)||void 0===i?void 0:i[l.name])?this.options.customInputs[l.name](e):o.input.forProperty(l,e);a.push(this.options.horizontalInputNames?c.root:this.hideLabel(c.root)),l.propertyType!==t.TYPE.BOOL&&"color"!==l.name.toLowerCase()&&c.input&&(c.input.style.width="100%"),s[l.name]=c,c.onChanged((()=>{e[l.name]=c.value,n?this.onAddingItemChanged.next({item:e,fieldName:l.name}):this.onItemChanged.next({item:e,fieldName:l.name})})),c.root.style.alignItems="center",r=c}let l=null;if(n)l=o.icons.add((()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(s).forEach((t=>{e[t]=s[t].value})),this._items.push(e),this.onItemAdded.next(e),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return a;l=o.icons.delete((()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()}),this.options.removeButtonTooltip)}return r&&r.addOptions?r.addOptions(l):null==r||r.root.appendChild(l),l.style.color="#2083d5",a}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}}var X=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};function ee(n,i){var a,s;return X(this,void 0,void 0,(function*(){const u=t.Func.find({tags:[r]}),d=(yield Fe.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),p=[];for(const e of d){const t=JSON.parse(yield Fe.files.readAsText(`Hit Triage/templates/${e}.json`));p.push(t.key)}const m=t.Func.find({tags:[c]}),h={};m.forEach((e=>{var t;h[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const g=o.choiceInput("Submit function",null,[null,...Object.keys(h)]);g.value=null,g.nullable=!0,g.fireChanged(),g.setTooltip("Select function to be called upon submitting");const b=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),w=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),A=o.stringInput("Name","",(()=>{""===A.value||d.includes(A.value)?(A.root.style.borderBottom="1px solid red",b.style.opacity="100%"):(A.root.style.borderBottom="none",b.style.opacity="0%")})),x=o.stringInput("Key","",(()=>{""===x.value||p.includes(x.value)?(x.root.style.borderBottom="1px solid red",w.style.opacity="100%"):(x.root.style.borderBottom="none",w.style.opacity="0%")}));x.setTooltip("Template key used for campaign prefix"),A.setTooltip("Template name"),A.root.style.borderBottom="none",x.root.style.borderBottom="none",b.style.opacity="0%",w.style.opacity="0%";const I={Descriptors:"Descriptors"};u.forEach((e=>{var t;I[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=`${e.package.name}:${e.name}`}));let E=null;const N=yield z(n,(e=>{E=e}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);if(N.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(i).length){const n=t.Func.find({tags:[l]}),o=yield e.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list();n.forEach((e=>{var t;i[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})),o.forEach((e=>{var t;i[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}))}const S=Object.keys(i),_=o.choiceInput(y,S[0],S),F=o.choiceInput("Ingest using","Query",["Query","File"],(()=>{"Query"!==F.value?_.root.style.display="none":_.root.style.display="block"})),B=te(),O=o.div([o.h2("Details"),o.div([A,b]),o.div([x,w]),F.root,_.root,B.fieldsDiv,o.h2("Compute"),N.root,o.h2("Submit"),g.root],"ui-form"),P=o.buttonsInput([]),k=null!==(s=null===(a=P.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:P;O.appendChild(P);const V=new Promise((e=>{const t=o.button(T,(()=>e()));k.appendChild(t)})),L=new Promise((t=>{const n=o.bigButton(C,(()=>function(){var n,i,o,a,s,r,l;return X(this,void 0,void 0,(function*(){if(N.okProxy(),"100%"===b.style.opacity)return void e.shell.error("Template name is empty or already exists");const c=g.value?h[g.value]:void 0,u=Object.assign(Object.assign({name:A.value,key:x.value,campaignFields:B.getFields(),dataSourceType:null!==(n=F.value)&&void 0!==n?n:"Query",compute:{descriptors:{enabled:!!(null===(i=null==E?void 0:E.descriptors)||void 0===i?void 0:i.length),args:null!==(o=null==E?void 0:E.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==E?void 0:E.externals)&&void 0!==a?a:{}).map((([e,t])=>{const n=e.split(":");return{name:n[1],package:n[0],args:t}})),scripts:Object.entries(null!==(s=null==E?void 0:E.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}})),queries:Object.entries(null!==(r=null==E?void 0:E.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}}))}},c?{submit:{fName:c.name,package:c.package.name}}:{}),{queryFunctionName:"Query"===F.value&&null!==(l=_.value)&&void 0!==l?l:void 0});var d;d=u,Fe.files.writeAsText(`Hit Triage/templates/${d.name}.json`,JSON.stringify(d)),e.shell.info("Template created successfully"),t(u)}))}()));k.appendChild(n)}));return{root:O,template:L,cancelPromise:V}}))}function te(e){const n=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING}),t.Property.fromOptions({name:"Type",type:t.TYPE.STRING,choices:Object.keys(W)}),t.Property.fromOptions({name:"Required",type:t.TYPE.BOOL})],i=new K(n,e?e.map((e=>({Name:e.name,Type:e.type,Required:e.required}))):void 0,{horizontalInputNames:!1});i.root.style.maxWidth="750px";let a={};i.onItemAdded.subscribe((e=>{a=null!=e?e:{}})),i.onAddingItemChanged.subscribe((e=>{e&&(a=e.item)}));const s=o.h2("Additional fields");o.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=o.div([s,i.root]);return{getFields:function(){var e;const t=i.items.filter((e=>e.Name)).map((e=>{var t;return{name:e.Name,type:e.Type,required:null!==(t=e.Required)&&void 0!==t&&t}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(e=a.Required)&&void 0!==e||(a.Required=!1),t.push({name:a.Name,type:a.Type,required:a.Required})),t},fieldsDiv:o.div([r])}}var ne=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};class ie extends t.ViewBase{constructor(e){super(),this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return ne(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return ne(this,void 0,void 0,(function*(){yield Fe.files.delete(`${e}/campaigns/${t}`)}))}}var oe=n(290),ae={};ae.styleTagTransform=j(),ae.setAttributes=P(),ae.insert=B().bind(null,"head"),ae.domAPI=_(),ae.insertStyleElement=V(),N()(oe.Z,ae),oe.Z&&oe.Z.locals&&oe.Z.locals;var se;!function(t){let n,i;!function(e){e.vert=function(e){return o.divV(e.map((e=>o.render(e))),{classes:"u2-panel"})},e.horz=function(e){return o.divH(e.map((e=>o.render(e))),{classes:"u2-panel"})}}(n=t.panels||(t.panels={})),t.appHeader=function(e){const t=o.iconImage("",e.iconPath);return Z()(t).addClass("ui-app-header-icon").css("margin-right","20px"),n.horz([t,n.vert([o.markdown(e.description),e.learnMoreUrl?o.link("Learn more",e.learnMoreUrl):null])])},function(t){t.runAsync=function(t,n){return i=this,a=void 0,r=function*(){o.setUpdateIndicator(t,!0);try{return yield n()}catch(t){e.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))((function(e,t){function n(e){try{l(r.next(e))}catch(e){t(e)}}function o(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof s?i:new s((function(e){e(i)}))).then(n,o)}l((r=r.apply(i,a||[])).next())}));var i,a,s,r}}(i=t.tools||(t.tools={}))}(se||(se={}));var re=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};class le extends ie{constructor(t){super(t),this.readmePath=Fe.webRoot+"README_HT.md",this.deletedCampaigns=[],this.dataSourceFunctionsMap={},this.name="Hit Triage",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(this.readmePath),this.checkCampaign().then((e=>{this.app.campaign=e,this.init()}))}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(this.readmePath)}init(e){return re(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(x),n=o.h1(I,{style:{marginLeft:"10px"}}),i=se.appHeader({iconPath:Fe.webRoot+"/images/icons/hit-triage-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md",description:"- Configure your own workflow using the template editor.\n- Calculate different molecular properties.\n- Filter molecules using different criteria.\n- Submit processed dataframe to the function of your choice.\n- Save campaigns and continue any time from where you left off.\n "}),a=o.div(),s=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,e),Z()(this.root).empty(),this.root.appendChild(o.div([o.divV([i,t],{style:{marginLeft:"10px"}}),r,n,s,a])),this.app.resetBaseUrl()}catch(e){throw o.setUpdateIndicator(this.root,!1),e}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,n){var i;return re(this,void 0,void 0,(function*(){const a=(yield Fe.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));n&&!a.includes(n.name)&&a.push(n.name);const s=()=>re(this,void 0,void 0,(function*(){const t=r.value,i=n&&n.name===t?n:JSON.parse(yield Fe.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(i,e);Z()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=o.choiceInput("Template",null!==(i=null==n?void 0:n.name)&&void 0!==i?i:a[0],a,(()=>re(this,void 0,void 0,(function*(){yield s()})))),l=o.icons.add((()=>re(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),b);r.addOptions(l),yield s(),Z()(t).empty(),t.appendChild(r.root)}))}checkCampaign(e){return re(this,void 0,void 0,(function*(){const t=location.search,n=new URLSearchParams(t);if(!n.has(a)&&!e)return;const i=null!=e?e:n.get(a);if(!(yield Fe.files.exists(`Hit Triage/campaigns/${i}/campaign.json`)))return;const o=JSON.parse(yield Fe.files.readAsText(`Hit Triage/campaigns/${i}/campaign.json`)),s=JSON.parse(yield Fe.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,i,o.ingest),e&&R(a,e),o}))}getCampaignsTable(){return re(this,void 0,void 0,(function*(){const e=(yield Fe.files.list("Hit Triage/campaigns")).filter((e=>-1===this.deletedCampaigns.indexOf(e.name))),t={};for(const n of e){const e=JSON.parse(yield Fe.files.readAsText(`Hit Triage/campaigns/${n.name}/campaign.json`));t[e.name]=e}const n=Object.values(t).map((e=>({name:e.name,createDate:e.createDate,rowCount:e.rowCount,filtered:e.filteredRowCount,status:e.status}))),i=o.table(n,(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.filtered,e.status,o.icons.delete((()=>re(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>re(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Total","Selected","Status",""]);return i.style.color="var(--grey-5)",i}))}setCampaign(e){return re(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(n,i){return re(this,void 0,void 0,(function*(){o.setUpdateIndicator(i,!0);const{root:a,promise:s,cancelPromise:r}=yield function(n,i){var a,s;return G(this,void 0,void 0,(function*(){const r=o.divText("",{style:{color:"red"}});let c=null;const u=()=>G(this,void 0,void 0,(function*(){try{if(c=d.value,!c)return;if(yield c.meta.detectSemanticTypes(),!c.columns.bySemType(t.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),d=o.tableInput("Dataframe",null,void 0,u);yield u();const p=o.div([d,r]);0===Object.keys(i).length&&(t.Func.find({tags:[l]}).forEach((e=>{var t;i[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})),(yield e.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list()).forEach((e=>{var t;i[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e})));let m=null;const h=()=>G(this,void 0,void 0,(function*(){const e=i[v.value];m=e.prepare();const t=yield m.getEditor();t.classList.remove("ui-form"),f.innerHTML="",f.appendChild(t)})),f=o.div([]),v=o.choiceInput(y,null!==(a=n.queryFunctionName)&&void 0!==a?a:Object.keys(i)[0],Object.keys(i),h);yield h(),n.queryFunctionName&&(null===(s=v.root.getElementsByTagName("select").item(0))||void 0===s||s.setAttribute("disabled","true"));const g=o.div([v,f]);g.style.display="none";const b=o.div([p,g]),C=n.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:W[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),A={},x=C.length?o.input.form(A,C):o.div();x.classList.remove("ui-form"),"File"===n.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const I=o.div([b,...C.length?[x]:[]]),E=o.buttonsInput([]);return I.appendChild(E),{promise:new Promise((t=>{const a=()=>G(this,void 0,void 0,(function*(){if("File"===n.dataSourceType){if(!c)return void e.shell.error("No file selected");const n=c;n.name=c.name,t({df:n,type:"File",campaignProps:A})}else{const n=i[v.value];if(!n)return void e.shell.error("No function selected");const o={};Object.entries(m.inputs).forEach((([e,t])=>{o[e]=t}));const a=yield n.apply(o);t({df:a,type:"Query",campaignProps:A})}})),s=o.bigButton(w,(()=>a()));E.appendChild(s)})),root:I,cancelPromise:new Promise((e=>{o.button(T,(()=>e()))}))}}))}(n,this.dataSourceFunctionsMap);return o.setUpdateIndicator(i,!1),s.then((e=>re(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,this.app._fileInputType=e.type,yield this.app.setTemplate(n),this.app.campaignProps=e.campaignProps,this.app.saveCampaign(void 0,!1)})))),r.then((()=>{this.init()})),a}))}createNewTemplate(){return re(this,void 0,void 0,(function*(){const n=yield ee(this.app,this.dataSourceFunctionsMap),i=new t.ViewBase,o=e.shell.v;i.name="New Template",i.root.appendChild(n.root),i.parentCall=this.app.parentCall,e.shell.addView(i),i.path=new URL(this.app.baseUrl).pathname+"/new-template",i.parentView=o;const{sub:a}=U(e.shell.v,"Hit Triage",b,(()=>{e.shell.v=o,i.close()}));n.template.then((t=>re(this,void 0,void 0,(function*(){yield this.init(t),i.close(),$(i),e.shell.v=o,a.unsubscribe()})))),n.cancelPromise.then((()=>{a.unsubscribe(),i.close(),e.shell.v=o}))}))}}class ce extends ie{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var n,i,o,a,s;return i=this,o=void 0,s=function*(){const i=null===(n=this.app.template)||void 0===n?void 0:n.submit;if(!i)return;const o=t.Func.find({name:i.fName,package:i.package})[0];if(!o)return void e.shell.error(`Function ${i.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(e,t){function n(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(n,r)}l((s=s.apply(i,o||[])).next())}))}}var ue=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};class de{constructor(n){this.parentCall=n,this.resetBaseUrl(),this.computeFunctions=new Promise((n=>ue(this,void 0,void 0,(function*(){const i=t.Func.find({tags:[r]}),o=yield e.dapi.scripts.include("params").filter("#HitTriageFunction").list(),a=yield e.dapi.queries.include("params,connection").filter("#HitTriageFunction").list();n({functions:i,scripts:o,queries:a})}))))}resetBaseUrl(){const e=window.location.href,t=new URL(e);this.baseUrl=t.origin+t.pathname}getFilterType(e){const n=this.dataFrame.col(e);return(null==n?void 0:n.semType)===t.SEMTYPE.MOLECULE?t.FILTER_TYPE.SUBSTRUCTURE:(null==n?void 0:n.type)===t.COLUMN_TYPE.BOOL?t.FILTER_TYPE.BOOL_COLUMNS:(null==n?void 0:n.type)===t.COLUMN_TYPE.STRING?t.FILTER_TYPE.CATEGORICAL:t.FILTER_TYPE.HISTOGRAM}download(e,n,i=!1){const o=document.createElement("a"),a=t.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:i});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",n+".csv"),o.click()}getNewCampaignName(e,t){return ue(this,void 0,void 0,(function*(){const n=(yield Fe.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(t)));if(0===n.length)return t+"-1";const i=n.map((e=>e.split("-")[1])).filter(Boolean).map((e=>parseInt(e,10))).sort();return t+"-"+(i[i.length-1]+1).toString()}))}setBaseUrl(){const e=document.title;if(history.replaceState){const t={Title:e,Url:this.baseUrl};history.replaceState(t,t.Title,t.Url)}}}var pe=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))},me=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};function he(e){let t=0;if(e.length>1)for(const n of e.toList()){if(!n||!n.startsWith(h[0])||n.length!==h.length)continue;const e=parseInt(n.substring(1));isNaN(e)||(t=Math.max(e,t))}return`V${"".concat(...new Array(h.length-1-(t+1).toString().length).fill("0"))}${t+1}`}function fe(n,i,o){var a,s;return me(this,void 0,void 0,(function*(){const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=i.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let t=0;t<l.length;t++){if(l.isNone(t))continue;const n=l.get(t);if(!n)continue;const i=e.chem.convert(n,e.chem.Notation.Unknown,e.chem.Notation.Smiles);l.set(t,i,!1)}n.descriptors&&n.descriptors.length>0&&(yield e.chem.descriptors(i,o,n.descriptors));for(const e of Object.keys(n.externals)){const a=n.externals[e],s=t.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=s.inputs[0].name,l=s.inputs[1].name;a&&(yield s.apply(Object.assign(Object.assign({},a),{[r]:i,[l]:o})))}for(const t of Object.keys(null!==(a=n.scripts)&&void 0!==a?a:{})){const a=n.scripts[t];if(a){const n=t.split(":")[2];if(!n)continue;try{const t=yield e.dapi.scripts.find(n);if(!t)continue;const s=t.inputs[0].name,r=t.inputs[1].name,l=yield t.apply(Object.assign(Object.assign({},a),{[s]:i,[r]:o}));if(l&&l.rowCount===i.rowCount&&"python"===t.language)for(const e of l.columns)e.name=i.columns.getUnusedName(e.name),i.columns.add(e)}catch(e){console.error(e)}}}for(const t of Object.keys(null!==(s=n.queries)&&void 0!==s?s:{})){const a=n.queries[t];if(a){const n=t.split(":")[2];if(!n)continue;try{const t=yield e.dapi.queries.find(n);if(!t)continue;const s=t.inputs[0].name,r=i.col(o).toList(),l=yield t.apply(Object.assign(Object.assign({},a),{[s]:r}));l&&(yield Y(i,o,l))}catch(e){console.error(e)}}}r.close()}))}var ve=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};class ge extends de{constructor(n){super(n),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new le(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ie&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=n,e.shell.addView(this.multiView),e.events.onCurrentViewChanged.subscribe((()=>{var t,n,i,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),R(a,null!==(o=null!==(n=this._campaignId)&&void 0!==n?n:null===(i=this._campaign)||void 0===i?void 0:i.name)&&void 0!==o?o:""))}catch(e){console.error(e)}}))}setTemplate(n,i,o,s){var r,l,c,u,d,p,m,h,f,v,g,y,b,w;return ve(this,void 0,void 0,(function*(){if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?s&&(this._fileInputType=s.type,"File"===s.type?this.dataFrame=yield e.dapi.files.readCsv(s.query):this.dataFrame=yield e.functions.call(s.query)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",n.key),R(a,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const n=this.dataFrame.columns.byName(e);n&&(n.semType=t)})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(d=null===(u=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===u?void 0:u.name)&&void 0!==d?d:void 0,this._dfName=null!==(p=this.dataFrame.name)&&void 0!==p?p:null==s?void 0:s.query,this.dataFrame.name=null!==(h=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==h?h:"Molecules",this._campaignId=o,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:n.dataSourceType,queryFunctionName:n.queryFunctionName}):n,this._campaignFilters=i,!i){const e={},t={},i={};n.compute.functions.forEach((t=>{const n=`${t.package}:${t.name}`;e[n]=t.args})),null===(v=n.compute.scripts)||void 0===v||v.forEach((e=>{const n=`HTScript:${e.name}:${e.id}`;t[n]=e.args})),null===(g=n.compute.queries)||void 0===g||g.forEach((e=>{const t=`HTQuery:${e.name}:${e.id}`;i[t]=e.args})),yield fe({descriptors:n.compute.descriptors.enabled?n.compute.descriptors.args:[],externals:e,scripts:t,queries:i},this.dataFrame,this._molColName)}const C=e.shell.v,A=e.shell.addView(this.pickView);this.currentPickViewId=A.name,this._submitView=new ce(this),this.setBaseUrl(),R(a,null!==(w=null!==(y=this._campaignId)&&void 0!==y?y:null===(b=this._campaign)||void 0===b?void 0:b.name)&&void 0!==w?w:"");const T=A;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:t}=U(T,"Hit Triage","Pick",(()=>{e.shell.v=C,T.close(),t.unsubscribe()}))}))}),300),e.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var e,n,i;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(i=null===(n=this.dataFrame)||void 0===n?void 0:n.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===i?void 0:i.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getFilterView(){let e=null;this._pickViewPromise=new Promise((t=>{e=t})),this.dataFrame.col(u)||this.dataFrame.columns.addNewBool(u).init(!1);const n=t.TableView.create(this.dataFrame,!1),i=n.getRibbonPanels(),a=o.iconFA("wrench",(()=>ve(this,void 0,void 0,(function*(){z(this,(e=>ve(this,void 0,void 0,(function*(){var t,n,i,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],d=null!==(n=this.template.compute.queries)&&void 0!==n?n:[],p=e.descriptors,m={descriptors:{enabled:!!(null===(i=null==e?void 0:e.descriptors)||void 0===i?void 0:i.length),args:null!==(o=null==e?void 0:e.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==e?void 0:e.externals)&&void 0!==a?a:{}).map((([e,t])=>{const n=e.split(":");return{name:n[1],package:n[0],args:t}})),scripts:Object.entries(null!==(s=null==e?void 0:e.scripts)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}})),queries:Object.entries(null!==(r=null==e?void 0:e.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}}))};this.template.compute=m;const h=p.filter((e=>!l.includes(e))),g=m.functions.filter((e=>{if(!c.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=c.find((t=>t.name===e.name&&t.package===e.package));return!Object.entries(e.args).every((([e,n])=>t.args[e]===n))})),y=m.scripts.filter((e=>{if(!u.some((t=>t.id===e.id)))return!0;const t=u.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,n])=>t.args[e]===n))})),b=m.queries.filter((e=>{if(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,n])=>t.args[e]===n))})),w={};g.forEach((e=>{const t=`${e.package}:${e.name}`;w[t]=e.args}));const C={};y.forEach((e=>{const t=`HTScript:${e.name}:${e.id}`;C[t]=e.args}));const A={};b.forEach((e=>{const t=`HTQuery:${e.name}:${e.id}`;A[t]=e.args})),yield fe({descriptors:h,externals:w,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),s=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));s.classList.add("hit-design-submit-button");const r=q(i);return i.push([a,...r?[]:[s]]),n.setRibbonPanels(i),n.name=this._filterViewName,setTimeout((()=>ve(this,void 0,void 0,(function*(){var i;n._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const o=n.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0);if(null===(i=this._campaign)||void 0===i?void 0:i.layout)try{const e=t.ViewLayout.fromViewState(this._campaign.layout);n.loadLayout(e)}catch(e){console.error(e)}n.dataFrame.onFilterChanged.subscribe((e=>{this._filterDescriptions=Array.from(n.dataFrame.rows.filters),this._campaignFilters=o.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(n.dataFrame.rows.filters),this._campaignFilters=o.getOptions().look.filters}),300),e&&e()}))),300),n.parentCall=this.parentCall,n}getSummary(){var e,t,n,i,a,s,r;const l=null!==(t=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==t?t:this.campaignProps;return Object.assign(Object.assign({Template:null!==(i=null===(n=this.template)||void 0===n?void 0:n.name)&&void 0!==i?i:"Molecules","File path":o.divH([o.link(null!==(a=this._dfName)&&void 0!==a?a:"-",(()=>this.download(this.dataFrame,"molecules")),A)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(s=this.dataFrame)||void 0===s?void 0:s.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),A)],{style:{alignItems:"center"}})})}saveCampaign(n,i=!0){var a,s,r,l,c,u;return ve(this,void 0,void 0,(function*(){const d=this.campaignId,p=this.filterSettings,m=this.template.name,h=this.dataFrame,f=`System:AppData/HitTriage/Hit Triage/campaigns/${d}/`,v=null!=d?d:yield function(e){return pe(this,void 0,void 0,(function*(){return new Promise((t=>pe(this,void 0,void 0,(function*(){const n=o.stringInput("Campaign name","");o.dialog("Save Campaign").add(o.div(n.root)).onOK((function(){n.value&&""!==n.value?t(n.value):t(e)})).show()}))))}))}(d),g={};h.columns.toList().forEach((e=>g[e.name]=e.semType));const y={name:v,templateName:m,filters:null!=p?p:{},ingest:{type:"File",query:`${f}enriched_table.csv`,molColName:this.molColName},status:null!==(s=null!=n?n:null===(a=this.campaign)||void 0===a?void 0:a.status)&&void 0!==s?s:"In Progress",createDate:null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.createDate)&&void 0!==l?l:M(new Date),campaignFields:null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.campaignFields)&&void 0!==u?u:this.campaignProps,columnSemTypes:g,rowCount:h.rowCount,filteredRowCount:h.filter.trueCount,template:this.template};this.campaign=y;const b=t.DataFrame.fromColumns(h.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield Fe.files.writeAsText(`Hit Triage/campaigns/${d}/enriched_table.csv`,b);const w=this._pickView.saveLayout();w?y.layout=w.viewState:e.shell.warning("Layout cound not be saved"),yield Fe.files.writeAsText(`Hit Triage/campaigns/${d}/campaign.json`,JSON.stringify(y)),i&&e.shell.info("Campaign saved successfully.")}))}}var ye=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};function be(n,i){var a,s,l,u,d,p,m,h,g,y,b;return ye(this,void 0,void 0,(function*(){const w=t.Func.find({tags:[r]}),A=yield Fe.files.list("Hit Design/templates");let x=!1,I=!1;const E=A.map((e=>e.name.slice(0,-5))),N=[];for(const e of A)try{const t=JSON.parse(yield Fe.files.readAsText(e));N.push(t.key)}catch(e){console.error(e)}const S=t.Func.find({tags:[c]}),_={};S.forEach((e=>{var t;_[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const F=o.choiceInput("Submit function",null,[null,...Object.keys(_)]);F.nullable=!0,F.value=null!==(s=null===(a=null==i?void 0:i.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,F.setTooltip("Select function to be called upon submitting");const B=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),O=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"});function P(){var e,t,n,i;if(""===k.value||E.includes(null!==(t=null===(e=k.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(n=k.input.offsetLeft)&&void 0!==n?n:0,t=null!==(i=k.input.offsetWidth)&&void 0!==i?i:0;B.style.marginLeft=`${e}px`,B.style.width=`${t}px`,B.style.opacity="100%",B.style.borderTop="1px solid red",x=!0}else B.style.borderTop="none",B.style.opacity="0%",x=!1}const k=o.stringInput("Name",null!==(l=null==i?void 0:i.name)&&void 0!==l?l:"",P);function V(){var e,t,n,i;if(""===L.value||N.includes(null!==(t=null===(e=L.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(n=L.input.offsetLeft)&&void 0!==n?n:0,t=null!==(i=L.input.offsetWidth)&&void 0!==i?i:0;O.style.marginLeft=`${e}px`,O.style.width=`${t}px`,O.style.borderTop="1px solid red",O.style.opacity="100%",I=!0}else O.style.opacity="0%",O.style.borderTop="none",I=!1}const L=o.stringInput("Key",null!==(u=null==i?void 0:i.key)&&void 0!==u?u:"",V);L.setTooltip("Template key used for campaign prefix"),k.setTooltip("Template name"),k.root.style.borderBottom="none",L.root.style.borderBottom="none",B.style.opacity="0%",O.style.opacity="0%";const j={Descriptors:"Descriptors"};w.forEach((e=>{var t;j[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=`${e.package.name}:${e.name}`}));let D=null;const H={compute:{descriptors:{enabled:!0,args:null!==(m=null===(p=null===(d=null==i?void 0:i.compute)||void 0===d?void 0:d.descriptors)||void 0===p?void 0:p.args)&&void 0!==m?m:[]},functions:null!==(g=null===(h=null==i?void 0:i.compute)||void 0===h?void 0:h.functions)&&void 0!==g?g:[]}},M=yield z(n,(e=>{D=e}),(()=>null),H,!1);M.root.classList.add("hit-triage-new-template-functions-input");const R=te(null==i?void 0:i.campaignFields),U=function(e){const n=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING})],i=new K(n,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let o={};return i.onItemAdded.subscribe((e=>{o=null!=e?e:{}})),i.onAddingItemChanged.subscribe((e=>{e&&(o=e.item)})),{getFields:function(){const e=i.items.filter((e=>e.Name)).map((e=>e.Name));return o.Name&&""!==o.Name&&e.push(o.Name),e},fieldsDiv:i.root}}(null==i?void 0:i.stages),$=o.divV([o.divV([k,B]),o.divV([L,O]),R.fieldsDiv]),q=o.h2("Stages");o.tooltip.bind(q,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const Y=o.h2("Compute");o.tooltip.bind(Y,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const W=o.div([o.h2("Details"),$,q,U.fieldsDiv,Y,M.root,o.h2("Submit"),F.root],"ui-form"),G=o.buttonsInput([]);W.appendChild(G);const J=null!==(b=null===(y=G.getElementsByClassName("ui-input-editor"))||void 0===y?void 0:y[0])&&void 0!==b?b:G,Z=new Promise((e=>{const t=o.button(T,(()=>e()));J.appendChild(t)})),Q=new Promise((t=>{const n=o.bigButton(C,(()=>function(){var n,i,o,a,s;return ye(this,void 0,void 0,(function*(){if(P(),V(),M.okProxy(),x||!k.value||""===k.value)return void e.shell.error("Template name is empty or already exists");if(I||!L.value||""===L.value)return void e.shell.error("Template key is empty or already exists");const r=F.value?_[F.value]:void 0,l=Object.assign({name:k.value,key:L.value,campaignFields:R.getFields(),stages:U.getFields(),compute:{descriptors:{enabled:!!(null===(n=null==D?void 0:D.descriptors)||void 0===n?void 0:n.length),args:null!==(i=null==D?void 0:D.descriptors)&&void 0!==i?i:[]},functions:Object.entries(null!==(o=null==D?void 0:D.externals)&&void 0!==o?o:{}).map((([e,t])=>{const n=e.split(":");return{name:n[1],package:n[0],args:t}})),scripts:Object.entries(null!==(a=null==D?void 0:D.scripts)&&void 0!==a?a:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}})),queries:Object.entries(null!==(s=null==D?void 0:D.queries)&&void 0!==s?s:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}}))}},r?{submit:{fName:r.name,package:r.package.name}}:{});var c;c=l,Fe.files.writeAsText(`Hit Design/templates/${c.name}.json`,JSON.stringify(c)),e.shell.info("Template created successfully"),t(l)}))}()));J.appendChild(n)}));return{root:W,template:Q,cancelPromise:Z}}))}var we=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};class Ce extends ie{constructor(t){super(t),this.deletedCampaigns=[],this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Fe.webRoot+"README_HD.md"),this.checkCampaign().then((e=>{this.app.campaign=e,this.init()}))}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Fe.webRoot+"README_HD.md")}init(e){return we(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(x),n=o.h1(I,{style:{marginLeft:"10px"}}),i=se.appHeader({iconPath:Fe.webRoot+"/images/icons/hit-design-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HD.md",description:"- Configure your own workflow using the template editor\n- Sketch molecules in the molecular spreadsheet\n- Annotate and share ideas with the team\n- Calculate different molecular properties\n- Save campaigns and continue from where you left off\n- Submit final selection to the function of your choice"}),a=o.div(),s=o.divH([]),r=o.div([s,a],"ui-form"),l=yield this.getCampaignsTable();Z()(this.root).empty(),this.root.appendChild(o.div([o.divV([i,t],{style:{marginLeft:"10px"}}),l,n,r])),yield this.startNewCampaign(a,s,e),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,n){var i;return we(this,void 0,void 0,(function*(){const a=(yield Fe.files.list("Hit Design/templates")).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));n&&!a.includes(n.name)&&a.push(n.name);let s=null;const r=()=>we(this,void 0,void 0,(function*(){const t=l.value,i=n&&n.name===t?n:JSON.parse(yield Fe.files.readAsText("Hit Design/templates/"+t+".json"));s=i;const o=yield this.getNewCampaignAccordeon(i);Z()(e).empty(),e.appendChild(o)})),l=o.choiceInput("Template",null!==(i=null==n?void 0:n.name)&&void 0!==i?i:a[0],a,(()=>we(this,void 0,void 0,(function*(){yield r()}))));l.root.style.width="100%";const c=o.icons.add((()=>{this.createNewTemplate()}),b),u=o.icons.copy((()=>{s&&this.createNewTemplate(s)}),"Clone template");c.style.color="#2083d5",l.addOptions(u),l.addOptions(c),yield r(),Z()(t).empty(),t.appendChild(l.root)}))}checkCampaign(e){var t;return we(this,void 0,void 0,(function*(){const n=location.search,i=new URLSearchParams(n);if(!i.has(s)&&!e)return;const o=null!=e?e:i.get(s);if(!(yield Fe.files.exists(`Hit Design/campaigns/${o}/campaign.json`)))return;const a=JSON.parse(yield Fe.files.readAsText(`Hit Design/campaigns/${o}/campaign.json`));a&&(this.app.campaign=a);const r=null!==(t=a.template)&&void 0!==t?t:JSON.parse(yield Fe.files.readAsText(`Hit Design/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),e&&R(s,e),a.template=r,a}))}getCampaignsTable(){return we(this,void 0,void 0,(function*(){const e=(yield Fe.files.list("Hit Design/campaigns")).filter((e=>-1===this.deletedCampaigns.indexOf(e.name))),t={};for(const n of e){const e=JSON.parse(yield Fe.files.readAsText(`Hit Design/campaigns/${n.name}/campaign.json`));t[e.name]=e}const n=o.table(Object.values(t),(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.status,o.icons.delete((()=>we(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>we(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",e.name),this.deletedCampaigns.push(e.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Molecules","Status",""]);return n.style.color="var(--grey-5)",n.style.marginLeft="24px",n}))}setCampaign(e){return we(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(n){return we(this,void 0,void 0,(function*(){const{root:i,promise:a,cancelPromise:s}=function(n){var i,a;const s=t.DataFrame.create(1),r=s.columns.addNew(p,t.TYPE.STRING);r.semType=t.SEMTYPE.MOLECULE,r.setTag(t.TAGS.UNITS,t.UNITS.Molecule.SMILES),r.set(0,null),(null===(i=null==n?void 0:n.stages)||void 0===i?void 0:i.length)>0&&s.columns.addNew(d,t.TYPE.STRING).set(0,n.stages[0]);const l=s.columns.addNew(m,t.TYPE.STRING);l.set(0,he(l));const c=n.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:W[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),u={},h=o.input.form(u,c);h.classList.remove("ui-form");const f=o.div([...(null===(a=n.campaignFields)||void 0===a||a.length,[]),h]),v=o.buttonsInput([]);return f.appendChild(v),{promise:new Promise((t=>{const i=o.bigButton(w,(()=>{for(const t of n.campaignFields)if(t.required&&(!u[t.name]||""===u[t.name]))return void e.shell.error(`Field '${t.name}' is required`);t({df:s,campaignProps:u})}));v.appendChild(i)})),root:f,cancelPromise:new Promise((e=>{o.button(T,(()=>e()))}))}}(n);return a.then((e=>we(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,yield this.app.setTemplate(n),this.app.campaignProps=e.campaignProps,this.app.saveCampaign(void 0,!1)})))),s.then((()=>{this.init()})),i}))}createNewTemplate(n){return we(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const i=yield be(this.app,n),a=new t.ViewBase,s=e.shell.v;a.name="New Template",a.root.appendChild(i.root),a.parentCall=this.app.parentCall,e.shell.addView(a),a.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:r}=U(a,"Hit Design",b,(()=>we(this,void 0,void 0,(function*(){e.shell.v=s,a.close()}))));i.template.then((t=>we(this,void 0,void 0,(function*(){yield this.init(t),a.close(),$(a),e.shell.v=s,r.unsubscribe()})))),i.cancelPromise.then((()=>we(this,void 0,void 0,(function*(){r.unsubscribe(),a.close(),e.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class Ae extends ie{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var n,i,o,a,s;return i=this,o=void 0,s=function*(){const i=null===(n=this.app.template)||void 0===n?void 0:n.submit;if(!i)return;const o=t.Func.find({name:i.fName,package:i.package})[0];if(!o)return void e.shell.error(`Function ${i.fName} not found.`);const a=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(e,t){function n(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a((function(e){e(i)}))).then(n,r)}l((s=s.apply(i,o||[])).next())}))}}var Te=n(143),xe={};xe.styleTagTransform=j(),xe.setAttributes=P(),xe.insert=B().bind(null,"head"),xe.domAPI=_(),xe.insertStyleElement=V(),N()(Te.Z,xe),Te.Z&&Te.Z.locals&&Te.Z.locals;class Ie extends ie{constructor(e){super(e),this.v=null,this.name="Progress Tracker"}render(){return n=this,i=void 0,s=function*(){return new Promise((n=>{var i,a;o.empty(this.root),this.app.dataFrame.columns.names().forEach((e=>{e.startsWith("~")&&this.app.dataFrame.columns.remove(e)})),this.v=t.Viewer.fromType(t.VIEWER.TILE_VIEWER,this.app.dataFrame,{lanesColumnName:d,lanes:null!==(a=null===(i=this.app.template)||void 0===i?void 0:i.stages)&&void 0!==a?a:[]}),this.root.appendChild(this.v.root),this.v.root.style.height="100%",this.v.root.style.width="100%",setTimeout((()=>{var t,i,a;null===(i=null===(t=this.v)||void 0===t?void 0:t.view)||void 0===i||i._onAdded();const s=null===(a=e.shell.v)||void 0===a?void 0:a.getRibbonPanels();if(s){if(q(s))return void n();const t=o.bigButton("Design view",(()=>{const t=e.shell.view(this.app.designViewName);t&&(e.shell.v=t)})),i=o.bigButton("Submit",(()=>{var e;const t=null===(e=this.app._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.app.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this.app._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));i.classList.add("hit-design-submit-button"),s.push([t,i]),e.shell.v.setRibbonPanels(s)}n()}),5)}))},new((a=void 0)||(a=Promise))((function(e,t){function o(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(o,r)}l((s=s.apply(n,i||[])).next())}));var n,i,a,s}onActivated(){this.render()}destroy(){var e;null===(e=this.v)||void 0===e||e.detach()}}var Ee=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};class Ne extends de{constructor(n){super(n),this._tilesViewTab=null,this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=p,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new Ce(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof ie&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=n,this.mainView=e.shell.addView(this.multiView),e.events.onCurrentViewChanged.subscribe((()=>Ee(this,void 0,void 0,(function*(){var t,n,i,o,s,r,l,c,u;try{if((null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentDesignViewId||(null===(n=e.shell.v)||void 0===n?void 0:n.name)===this.currentTilesViewId){e.shell.windows.showHelp=!1,this.setBaseUrl(),R(a,null!==(s=null!==(i=this._campaignId)&&void 0!==i?i:null===(o=this._campaign)||void 0===o?void 0:o.name)&&void 0!==s?s:""),(null===(r=e.shell.v)||void 0===r?void 0:r.name)===this.currentTilesViewId?yield null===(l=this._tilesView)||void 0===l?void 0:l.render():null===(c=this._tilesView)||void 0===c||c.destroy();const{sub:t}=U(e.shell.v,"Hit Design",null===(u=e.shell.v)||void 0===u?void 0:u.name,(()=>{var n,i;e.shell.v=this.mainView,null===(n=this._tilesView)||void 0===n||n.close(),null===(i=this._designView)||void 0===i||i.close(),this._infoView.init(),t.unsubscribe()}))}}catch(e){console.error(e)}}))))}setTemplate(n,i){var o,r,l,c,u,d,m,h,f,v,g,y;return Ee(this,void 0,void 0,(function*(){if(i){const t="System.AppData/HitTriage/Hit Design/campaigns";this._filePath=null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.savePath)&&void 0!==l?l:`${t}/${i}/enriched_table.csv`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const n=this.dataFrame.columns.byName(e);n&&t&&(n.semType=t)}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,i=yield this.getNewCampaignName("Hit Design/campaigns",n.key),R(s,i),this._filePath=`System.AppData/HitTriage/Hit Design/campaigns/${i}/enriched_table.csv`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(d=null===(u=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===u?void 0:u.name)&&void 0!==d?d:p,this._dfName=null!==(m=(y=this.dataFrame).name)&&void 0!==m?m:y.name=i,this._campaignId=i,this.template=n,null!==(h=this._submitView)&&void 0!==h||(this._submitView=new Ae(this)),e.shell.windows.showHelp=!1,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const b=e.shell.addView(this.designView);this.currentDesignViewId=b.name,this.setBaseUrl(),R(a,null!==(g=null!==(f=this._campaignId)&&void 0!==f?f:null===(v=this._campaign)||void 0===v?void 0:v.name)&&void 0!==g?g:""),this.campaign&&(this.campaign.template=n)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var e,n,i,o;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(o=null===(i=null===(n=this.dataFrame)||void 0===n?void 0:n.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===i?void 0:i.name)&&void 0!==o?o:p}get campaign(){return this._campaign}set campaign(e){this._campaign=e}getDesignView(){var n,i,a,s,r,l;const c=[],u=null===(n=this.dataFrame.col(this.molColName))||void 0===n?void 0:n.toList().every((e=>!e&&""===e)),h=t.TableView.create(this.dataFrame,!1);this._designViewName=null!==(a=null===(i=this.campaign)||void 0===i?void 0:i.name)&&void 0!==a?a:this._designViewName,h.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList(),setTimeout((()=>Ee(this,void 0,void 0,(function*(){var n,i;if(h._onAdded(),yield new Promise((e=>setTimeout(e,1e3))),null===(n=this._campaign)||void 0===n?void 0:n.layout)try{const e=t.ViewLayout.fromViewState(this._campaign.layout);h.loadLayout(e)}catch(e){console.error(e)}u&&e.functions.call("Chem:editMoleculeCell",{cell:h.grid.cell(this._molColName,0)}),c.push(this.dataFrame.onRowsAdded.subscribe((()=>{var t,n;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(t=this.template.stages)||void 0===t?void 0:t.length)>0)for(let e=0;e<this.dataFrame.rowCount;e++){const t=this.dataFrame.col(d).get(e);t&&""!==t&&!(null===(n=this.dataFrame.col(d))||void 0===n?void 0:n.isNone(e))||this.dataFrame.set(d,e,this.template.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=h.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(i=t))}i&&e.functions.call("Chem:editMoleculeCell",{cell:i})}catch(e){console.error(e)}}))),this.dataFrame&&c.push(null===(i=this.dataFrame)||void 0===i?void 0:i.onRowsRemoved.subscribe((()=>{try{this.processedValues=this.dataFrame.getCol(this.molColName).toList()}catch(e){console.error(e)}}))),c.push(e.events.onContextMenu.subscribe((n=>{var i,o,a,s,r;try{const e=null===(i=null==n?void 0:n.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==h.id)return;if((null===(s=null===(a=null===(o=null==n?void 0:n.args)||void 0===o?void 0:o.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName)return;const l=null===(r=null==n?void 0:n.args)||void 0===r?void 0:r.menu;if(!l)return;l.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),l.item("Duplicate molecule",(()=>{var e,t,i,o;try{this.dataFrame.rows.addNew(null,!0);let a=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=h.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(a=t))}a&&(a.cell.value=null!==(o=null===(i=null===(t=null===(e=null==n?void 0:n.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===i?void 0:i.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}}))),c.push(h.grid.onCellValueEdited.subscribe((n=>Ee(this,void 0,void 0,(function*(){var i,o,a,s;try{if((null===(i=n.tableColumn)||void 0===i?void 0:i.name)===d)return void(yield this.saveCampaign(void 0,!1));if((null===(o=n.tableColumn)||void 0===o?void 0:o.name)!==this.molColName)return;const r=n.cell.value,l=n.tableRowIndex;(null===(a=this.dataFrame.col(m))||void 0===a?void 0:a.get(l))&&""!==(null===(s=this.dataFrame.col(m))||void 0===s?void 0:s.get(l))||this.dataFrame.col(m).set(l,he(this.dataFrame.col(m)),!1);const c=this.template.compute;if(!r||""===r)return;const u=yield function(n,i,o,a=[],s=[]){return me(this,void 0,void 0,(function*(){const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=e.chem.convert(n,e.chem.Notation.Unknown,e.chem.Notation.Smiles),c=t.Column.fromStrings(p,[l]),u=t.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes(),i.length&&(yield e.chem.descriptors(u,c.name,i));for(const e of o){const n=e.args,i=t.Func.find({package:e.package,name:e.name});if(!i.length||!i[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const o=i[0],a=o.inputs[0].name,s=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},n),{[a]:u,[s]:c.name}))}for(const t of a){const n=t.args;try{const i=yield e.dapi.scripts.find(t.id);if(i){const e=i.inputs[0].name,t=i.inputs[1].name,o=yield i.apply(Object.assign(Object.assign({},n),{[e]:u,[t]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===i.language)for(const e of o.columns)e.name=u.columns.getUnusedName(e.name),u.columns.add(e)}}catch(e){console.error(e)}}for(const t of s){const n=t.args;try{const i=yield e.dapi.queries.find(t.id);if(i){const e=i.inputs[0].name,t=[l],o=yield i.apply(Object.assign(Object.assign({},n),{[e]:t}));if(!o||0===o.rowCount)continue;yield Y(u,p,o)}}catch(e){console.error(e)}}return r.close(),u}))}(r,c.descriptors.args,c.functions,c.scripts,c.queries);for(const e of u.columns.toList())e.name!==p&&(this.dataFrame.columns.contains(e.name)||(this.dataFrame.columns.addNew(e.name,e.type).semType=e.semType),this.dataFrame.col(e.name).set(l,e.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}catch(e){console.error(e)}})))));const o=e.events.onViewRemoved.subscribe((e=>{e.id===h.id&&(c.forEach((e=>e.unsubscribe())),o.unsubscribe())}))}))),300);const g=null==h?void 0:h.getRibbonPanels();if(g&&!q(g)){const t=()=>Ee(this,void 0,void 0,(function*(){var e;z(this,(e=>Ee(this,void 0,void 0,(function*(){var t,n,i,a,s,r,l,c,u,d;const p=this.template.compute.descriptors.args,m=this.template.compute.functions,g=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],y=null!==(n=this.template.compute.queries)&&void 0!==n?n:[],b=e.descriptors,w={descriptors:{enabled:!!(null===(i=null==e?void 0:e.descriptors)||void 0===i?void 0:i.length),args:null!==(a=null==e?void 0:e.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==e?void 0:e.externals)&&void 0!==s?s:{}).map((([e,t])=>{const n=e.split(":");return{name:n[1],package:n[0],args:t}})),scripts:Object.entries(null!==(r=null==e?void 0:e.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(f)&&3===e.split(":").length)).map((([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}})),queries:Object.entries(null!==(l=null==e?void 0:e.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(v)&&3===e.split(":").length)).map((([e,t])=>{var n,i;const o=e.split(":");return{name:null!==(n=o[1])&&void 0!==n?n:"",id:null!==(i=o[2])&&void 0!==i?i:"",args:t}}))};this.template.compute=w,this.campaign.template=this.template;const C=b.filter((e=>!p.includes(e))),A={};Object.entries(null!==(c=null==e?void 0:e.externals)&&void 0!==c?c:{}).filter((([e,t])=>{const n=m.find((t=>`${t.package}:${t.name}`===e));return!n||!Object.entries(t).every((([e,t])=>n.args[e]===t))})).forEach((([e,t])=>{A[e]=t}));const T={};Object.entries(null!==(u=null==e?void 0:e.scripts)&&void 0!==u?u:{}).filter((([e,t])=>{const n=g.find((t=>`HTScript:${t.name}:${t.id}`===e));return!n||!Object.entries(t).every((([e,t])=>n.args[e]===t))})).forEach((([e,t])=>{T[e]=t}));const x={};Object.entries(null!==(d=null==e?void 0:e.queries)&&void 0!==d?d:{}).filter((([e,t])=>{const n=y.find((t=>`HTQuery:${t.name}:${t.id}`===e));return!n||!Object.entries(t).every((([e,t])=>n.args[e]===t))})).forEach((([e,t])=>{x[e]=t})),o.setUpdateIndicator(h.grid.root,!0);try{yield fe({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(h.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),n=o.iconFA("wrench",t,"Calculate additional properties"),i=o.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),a=o.bigButton("Progress tracker",(()=>{this.currentTilesViewId&&e.shell.view(this.currentTilesViewId)?e.shell.v=e.shell.view(this.currentTilesViewId):(this._tilesView=new Ie(this),this._tilesView.parentCall=this.parentCall,this._tilesViewTab=e.shell.addView(this._tilesView),this.currentTilesViewId=this._tilesViewTab.name,this._tilesView.onActivated())})),c=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));c.classList.add("hit-design-submit-button");const u=[c];null!==(l=null===(r=null===(s=this.template)||void 0===s?void 0:s.stages)||void 0===r?void 0:r.length)&&void 0!==l&&l&&u.unshift(a),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),u.unshift(n),u.unshift(i),g.push(u),h.setRibbonPanels(g)}return h.parentCall=this.parentCall,h}getSummary(){var n,i,a,s;const r=()=>{var e,t;const n=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===n?this._filePath:this._filePath.substring(0,n-1)},l=Object.assign({},null!==(i=null===(n=this.campaign)||void 0===n?void 0:n.campaignFields)&&void 0!==i?i:this.campaignProps);return this.template&&this.template.campaignFields&&Object.entries(l).forEach((([n,i])=>{const o=this.template.campaignFields.find((e=>e.name===n));o&&"Date"===o.type&&i?"Invalid Date"!==new Date(i).toString()?l[n]=new Date(i).toLocaleDateString():i.date?l[n]=new Date(i.date).toLocaleDateString():l[n]=i:o&&o.type===t.SEMTYPE.MOLECULE&&i&&(l[n]=e.chem.drawMolecule(i))})),Object.assign(Object.assign({Template:null!==(s=null===(a=this.template)||void 0===a?void 0:a.name)&&void 0!==s?s:"Molecules","File path":(()=>{const t=o.icons.edit((()=>{const n=r(),s=o.stringInput("Path",n),l=s.root.getElementsByTagName("label").item(0);l&&l.remove(),s.root.style.width="100%";const c=o.button("Save",(()=>Ee(this,void 0,void 0,(function*(){const n=yield function(){return Ee(this,void 0,void 0,(function*(){const t=s.value;return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)}))}();if(!n)return;const l=s.value;l.endsWith("/")?this._filePath=`${l}${this.campaignId}/enriched_table.csv`:this._filePath=`${l}/${this.campaignId}/enriched_table.csv`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(a);const c=r();i=o.link(c,(()=>{var e,t,n;return this.download(this.dataFrame,null!==(n=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==n?n:"Molecules")}),A),a.appendChild(i),a.appendChild(t)})))),u=o.button("Cancel",(()=>{o.empty(a),a.appendChild(i),a.appendChild(t)}));o.empty(a),s.addOptions(u),s.addOptions(c),a.appendChild(s.root)}),"Edit file path");t.style.marginLeft="5px";const n=r();let i=o.link(n,(()=>{var e,t,n;return this.download(this.dataFrame,null!==(n=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==n?n:"Molecules")}),A);const a=o.divH([i,t],{style:{alignItems:"center"}});return a})()},l),{"Number of molecules":(this.dataFrame.rowCount-this._extraStageColsCount).toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", ")})}saveCampaign(n,i=!0){var o,a,s,r,l,c,u,d;return Ee(this,void 0,void 0,(function*(){const p=this.campaignId,h=this.template.name,f=this.dataFrame,v=p,g={};f.columns.toList().forEach((e=>g[e.name]=e.semType));const y={name:v,templateName:h,status:null!==(a=null!=n?n:null===(o=this.campaign)||void 0===o?void 0:o.status)&&void 0!==a?a:"In Progress",createDate:null!==(r=null===(s=this.campaign)||void 0===s?void 0:s.createDate)&&void 0!==r?r:M(new Date),campaignFields:null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.campaignFields)&&void 0!==c?c:this.campaignProps,columnSemTypes:g,rowCount:null!==(d=null===(u=f.col(m))||void 0===u?void 0:u.toList().filter((e=>"StageDefiningRow"!==e)).length)&&void 0!==d?d:0,filteredRowCount:f.filter.trueCount,savePath:this._filePath};console.log(this._filePath);const b=t.DataFrame.fromColumns(f.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,b);const w=this._designView.saveLayout();return w?y.layout=w.viewState:e.shell.warning("Layout cound not be saved"),y.template=this.template,yield Fe.files.writeAsText(`Hit Design/campaigns/${p}/campaign.json`,JSON.stringify(y)),i&&e.shell.info("Campaign saved successfully."),this.campaign=y,y}))}}class Se extends t.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,n,i,o,a,s){if(a.gridRow<0||!a.cell.value)return;const r=a.cell.value,l=new Image(i-2,o-2);l.src="data:image/png;base64,"+r,l.onload=function(){e.drawImage(l,t+2,n+2,i-2,o-2)}}}var _e=function(e,t,n,i){return new(n||(n=Promise))((function(o,a){function s(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,r)}l((i=i.apply(e,t||[])).next())}))};const Fe=new t.Package;function Be(){return _e(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();new ge(t)}))}function Oe(){return _e(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();new Ne(t)}))}function Pe(){return _e(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function ke(){return _e(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function Ve(t){return _e(this,void 0,void 0,(function*(){const n=e.data.demo.molecules(t);return n.name="Variable Molecules number",n}))}function Le(t,n){return _e(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(n)}))}function je(){return new Se}})(),hittriage=i})();
|
|
1
|
+
var hittriage;(()=>{var t={553:t=>{!function(){"use strict";var e=document,i=window,n=e.documentElement,o=e.createElement.bind(e),a=o("div"),s=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,m=u.indexOf,h=u.map,f=u.push,v=u.slice,g=u.some,y=u.splice,b=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,w=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(t,e){var i,n=!!(i=e)&&11===i.nodeType;return t&&(n||_(e)||F(e))?!n&&w.test(t)?e.getElementsByClassName(t.slice(1).replace(/\\/g,"")):!n&&A.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t):[]}var x=function(){function t(t,n){if(t){if(E(t))return t;var o=t;if(P(t)){var a=n||e;if(!(o=b.test(t)&&_(a)?a.getElementById(t.slice(1).replace(/\\/g,"")):C.test(t)?X(t):E(a)?a.find(t):P(a)?S(a).find(t):T(t,a)))return}else if(O(t))return this.ready(t);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var s=0,r=this.length;s<r;s++)this[s]=o[s]}}return t.prototype.init=function(e,i){return new t(e,i)},t}(),I=x.prototype,S=I.init;function E(t){return t instanceof x}function N(t){return!!t&&t===t.window}function _(t){return!!t&&9===t.nodeType}function F(t){return!!t&&1===t.nodeType}function B(t){return"boolean"==typeof t}function O(t){return"function"==typeof t}function P(t){return"string"==typeof t}function k(t){return void 0===t}function V(t){return null===t}function L(t){return!isNaN(parseFloat(t))&&isFinite(t)}function j(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function D(t,e,i){if(i){for(var n=t.length;n--;)if(!1===e.call(t[n],n,t[n]))return t}else if(j(t))for(var o=Object.keys(t),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===e.call(t[s],s,t[s]))return t}else for(n=0,a=t.length;n<a;n++)if(!1===e.call(t[n],n,t[n]))return t;return t}function H(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=!!B(t[0])&&t.shift(),n=t.shift(),o=t.length;if(!n)return{};if(!o)return H(i,S,n);for(var a=0;a<o;a++){var s=t[a];for(var r in s)i&&(c(s[r])||j(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),H(i,n[r],s[r])):n[r]=s[r]}return n}S.fn=S.prototype=I,I.length=0,I.splice=y,"function"==typeof Symbol&&(I[Symbol.iterator]=u[Symbol.iterator]),S.isWindow=N,S.isFunction=O,S.isArray=c,S.isNumeric=L,S.isPlainObject=j,S.each=D,I.each=function(t){return D(this,t)},I.empty=function(){return this.each((function(t,e){for(;e.firstChild;)e.removeChild(e.firstChild)}))},S.extend=H,I.extend=function(t){return H(I,t)};var M=/\S+/g;function R(t){return P(t)&&t.match(M)||[]}function U(t,e,n){if(F(t)){var o=i.getComputedStyle(t,null);return n?o.getPropertyValue(e)||void 0:o[e]||t.style[e]}}function $(t,e){return parseInt(U(t,e),10)||0}function q(t,e){return $(t,"border".concat(e?"Left":"Top","Width"))+$(t,"padding".concat(e?"Left":"Top"))+$(t,"padding".concat(e?"Right":"Bottom"))+$(t,"border".concat(e?"Right":"Bottom","Width"))}I.toggleClass=function(t,e){var i=R(t),n=!k(e);return this.each((function(t,o){F(o)&&D(i,(function(t,i){n?e?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},I.addClass=function(t){return this.toggleClass(t,!0)},I.removeAttr=function(t){var e=R(t);return this.each((function(t,i){F(i)&&D(e,(function(t,e){i.removeAttribute(e)}))}))},I.attr=function(t,e){if(t){if(P(t)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var i=this[0].getAttribute(t);return V(i)?void 0:i}return k(e)?this:V(e)?this.removeAttr(t):this.each((function(i,n){F(n)&&n.setAttribute(t,e)}))}for(var n in t)this.attr(n,t[n]);return this}},I.removeClass=function(t){return arguments.length?this.toggleClass(t,!1):this.attr("class","")},I.hasClass=function(t){return!!t&&g.call(this,(function(e){return F(e)&&e.classList.contains(t)}))},I.get=function(t){return k(t)?v.call(this):this[(t=Number(t))<0?t+this.length:t]},I.eq=function(t){return S(this.get(t))},I.first=function(){return this.eq(0)},I.last=function(){return this.eq(-1)},I.text=function(t){return k(t)?this.get().map((function(t){return F(t)||(e=t)&&3===e.nodeType?t.textContent:"";var e})).join(""):this.each((function(e,i){F(i)&&(i.textContent=t)}))};var Y={};function W(t){return"none"===U(t,"display")}function G(t,e){var i=t&&(t.matches||t.webkitMatchesSelector||t.msMatchesSelector);return!!i&&!!e&&i.call(t,e)}function J(t){return P(t)?function(e,i){return G(i,t)}:O(t)?t:E(t)?function(e,i){return t.is(i)}:t?function(e,i){return i===t}:function(){return!1}}function Z(t,e){return e?t.filter(e):t}I.filter=function(t){var e=J(t);return S(p.call(this,(function(t,i){return e.call(t,i,t)})))},I.detach=function(t){return Z(this,t).each((function(t,e){e.parentNode&&e.parentNode.removeChild(e)})),this};var z=/^\s*<(\w+)[^>]*>/,Q=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,K={"*":a,tr:r,td:l,th:l,thead:s,tbody:s,tfoot:s};function X(t){if(!P(t))return[];if(Q.test(t))return[o(RegExp.$1)];var e=z.test(t)&&RegExp.$1,i=K[e]||K["*"];return i.innerHTML=t,S(i.childNodes).detach().get()}function tt(t,e,i,n){for(var o=[],a=O(e),s=n&&J(n),r=0,l=t.length;r<l;r++)if(a){var c=e(t[r]);c.length&&f.apply(o,c)}else for(var u=t[r][e];!(null==u||n&&s(-1,u));)o.push(u),u=i?u[e]:null;return o}function et(t){return t.multiple&&t.options?tt(p.call(t.options,(function(t){return t.selected&&!t.disabled&&!t.parentNode.disabled})),"value"):t.value||""}function it(t){return t.length>1?p.call(t,(function(t,e,i){return m.call(i,t)===e})):t}S.parseHTML=X,I.has=function(t){var e=P(t)?function(e,i){return T(t,i).length}:function(e,i){return i.contains(t)};return this.filter(e)},I.not=function(t){var e=J(t);return this.filter((function(i,n){return(!P(t)||F(n))&&!e.call(n,i,n)}))},I.val=function(t){return arguments.length?this.each((function(e,i){var n=i.multiple&&i.options;if(n||Pt.test(i.type)){var o=c(t)?h.call(t,String):V(t)?[]:[String(t)];n?D(i.options,(function(t,e){e.selected=o.indexOf(e.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=k(t)||V(t)?"":t})):this[0]&&et(this[0])},I.is=function(t){var e=J(t);return g.call(this,(function(t,i){return e.call(t,i,t)}))},S.guid=1,S.unique=it,I.add=function(t,e){return S(it(this.get().concat(S(t,e).get())))},I.children=function(t){return Z(S(it(tt(this,(function(t){return t.children})))),t)},I.parent=function(t){return Z(S(it(tt(this,"parentNode"))),t)},I.index=function(t){var e=t?S(t)[0]:this[0],i=t?this:S(e).parent().children();return m.call(i,e)},I.closest=function(t){var e=this.filter(t);if(e.length)return e;var i=this.parent();return i.length?i.closest(t):e},I.siblings=function(t){return Z(S(it(tt(this,(function(t){return S(t).parent().children().not(t)})))),t)},I.find=function(t){return S(it(tt(this,(function(e){return T(t,e)}))))};var nt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ot=/^$|^module$|\/(java|ecma)script/i,at=["type","src","nonce","noModule"];function st(t,e,i,a,s,r,l,c){return D(t,(function(t,r){D(S(r),(function(t,r){D(S(e),(function(e,l){var c=i?l:r,u=i?t:e;!function(t,e,i,a,s){a?t.insertBefore(e,i?t.firstChild:null):"HTML"===t.nodeName?t.parentNode.replaceChild(e,t):t.parentNode.insertBefore(e,i?t:t.nextSibling),s&&function(t,e){var i=S(t);i.filter("script").add(i.find("script")).each((function(t,i){if(ot.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(nt,""),D(at,(function(t,e){i[e]&&(a[e]=i[e])})),e.head.insertBefore(a,null),e.head.removeChild(a)}}))}(e,t.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,a,s,!u)}),c)}),l)}),r),e}I.after=function(){return st(arguments,this,!1,!1,!1,!0,!0)},I.append=function(){return st(arguments,this,!1,!1,!0)},I.html=function(t){if(!arguments.length)return this[0]&&this[0].innerHTML;if(k(t))return this;var e=/<script[\s>]/.test(t);return this.each((function(i,n){F(n)&&(e?S(n).empty().append(t):n.innerHTML=t)}))},I.appendTo=function(t){return st(arguments,this,!0,!1,!0)},I.wrapInner=function(t){return this.each((function(e,i){var n=S(i),o=n.contents();o.length?o.wrapAll(t):n.append(t)}))},I.before=function(){return st(arguments,this,!1,!0)},I.wrapAll=function(t){for(var e=S(t),i=e[0];i.children.length;)i=i.firstElementChild;return this.first().before(e),this.appendTo(i)},I.wrap=function(t){return this.each((function(e,i){var n=S(t)[0];S(i).wrapAll(e?n.cloneNode(!0):n)}))},I.insertAfter=function(t){return st(arguments,this,!0,!1,!1,!1,!1,!0)},I.insertBefore=function(t){return st(arguments,this,!0,!0)},I.prepend=function(){return st(arguments,this,!1,!0,!0,!0,!0)},I.prependTo=function(t){return st(arguments,this,!0,!0,!0,!1,!1,!0)},I.contents=function(){return S(it(tt(this,(function(t){return"IFRAME"===t.tagName?[t.contentDocument]:"TEMPLATE"===t.tagName?t.content.childNodes:t.childNodes}))))},I.next=function(t,e,i){return Z(S(it(tt(this,"nextElementSibling",e,i))),t)},I.nextAll=function(t){return this.next(t,!0)},I.nextUntil=function(t,e){return this.next(e,!0,t)},I.parents=function(t,e){return Z(S(it(tt(this,"parentElement",!0,e))),t)},I.parentsUntil=function(t,e){return this.parents(e,t)},I.prev=function(t,e,i){return Z(S(it(tt(this,"previousElementSibling",e,i))),t)},I.prevAll=function(t){return this.prev(t,!0)},I.prevUntil=function(t,e){return this.prev(e,!0,t)},I.map=function(t){return S(d.apply([],h.call(this,(function(e,i){return t.call(e,i,e)}))))},I.clone=function(){return this.map((function(t,e){return e.cloneNode(!0)}))},I.offsetParent=function(){return this.map((function(t,e){for(var i=e.offsetParent;i&&"static"===U(i,"position");)i=i.offsetParent;return i||n}))},I.slice=function(t,e){return S(v.call(this,t,e))};var rt=/-([a-z])/g;function lt(t){return t.replace(rt,(function(t,e){return e.toUpperCase()}))}I.ready=function(t){var i=function(){return setTimeout(t,0,S)};return"loading"!==e.readyState?i():e.addEventListener("DOMContentLoaded",i),this},I.unwrap=function(){return this.parent().each((function(t,e){if("BODY"!==e.tagName){var i=S(e);i.replaceWith(i.children())}})),this},I.offset=function(){var t=this[0];if(t){var e=t.getBoundingClientRect();return{top:e.top+i.pageYOffset,left:e.left+i.pageXOffset}}},I.position=function(){var t=this[0];if(t){var e="fixed"===U(t,"position"),i=e?t.getBoundingClientRect():this.offset();if(!e){for(var n=t.ownerDocument,o=t.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==t&&F(o)){var a=S(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(t,"marginTop"),left:i.left-$(t,"marginLeft")}}};var ct={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};I.prop=function(t,e){if(t){if(P(t))return t=ct[t]||t,arguments.length<2?this[0]&&this[0][t]:this.each((function(i,n){n[t]=e}));for(var i in t)this.prop(i,t[i]);return this}},I.removeProp=function(t){return this.each((function(e,i){delete i[ct[t]||t]}))};var ut=/^--/;function dt(t){return ut.test(t)}var pt={},mt=a.style,ht=["webkit","moz","ms"];function ft(t,e){if(void 0===e&&(e=dt(t)),e)return t;if(!pt[t]){var i=lt(t),n="".concat(i[0].toUpperCase()).concat(i.slice(1));D("".concat(i," ").concat(ht.join("".concat(n," "))).concat(n).split(" "),(function(e,i){if(i in mt)return pt[t]=i,!1}))}return pt[t]}var vt={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function gt(t,e,i){return void 0===i&&(i=dt(t)),i||vt[t]||!L(e)?e:"".concat(e,"px")}function yt(t,e){try{return t(e)}catch(t){return e}}I.css=function(t,e){if(P(t)){var i=dt(t);return t=ft(t,i),arguments.length<2?this[0]&&U(this[0],t,i):t?(e=gt(t,e,i),this.each((function(n,o){F(o)&&(i?o.style.setProperty(t,e):o.style[t]=e)}))):this}for(var n in t)this.css(n,t[n]);return this};var bt=/^\s+|\s+$/;function wt(t,e){var i=t.dataset[e]||t.dataset[lt(e)];return bt.test(i)?i:yt(JSON.parse,i)}function Ct(t,e,i){i=yt(JSON.stringify,i),t.dataset[lt(e)]=i}function At(t,e){var i=t.documentElement;return Math.max(t.body["scroll".concat(e)],i["scroll".concat(e)],t.body["offset".concat(e)],i["offset".concat(e)],i["client".concat(e)])}I.data=function(t,e){if(!t){if(!this[0])return;var i={};for(var n in this[0].dataset)i[n]=wt(this[0],n);return i}if(P(t))return arguments.length<2?this[0]&&wt(this[0],t):k(e)?this:this.each((function(i,n){Ct(n,t,e)}));for(var n in t)this.data(n,t[n]);return this},D([!0,!1],(function(t,e){D(["Width","Height"],(function(t,i){var n="".concat(e?"outer":"inner").concat(i);I[n]=function(n){if(this[0])return N(this[0])?e?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:_(this[0])?At(this[0],i):this[0]["".concat(e?"offset":"client").concat(i)]+(n&&e?$(this[0],"margin".concat(t?"Top":"Left"))+$(this[0],"margin".concat(t?"Bottom":"Right")):0)}}))})),D(["Width","Height"],(function(t,e){var i=e.toLowerCase();I[i]=function(n){if(!this[0])return k(n)?void 0:this;if(!arguments.length)return N(this[0])?this[0].document.documentElement["client".concat(e)]:_(this[0])?At(this[0],e):this[0].getBoundingClientRect()[i]-q(this[0],!t);var o=parseInt(n,10);return this.each((function(e,n){if(F(n)){var a=U(n,"boxSizing");n.style[i]=gt(i,o+("border-box"===a?q(n,!t):0))}}))}})),I.toggle=function(t){return this.each((function(i,n){if(F(n)){var a=W(n);(k(t)?a:t)?(n.style.display=n.___cd||"",W(n)&&(n.style.display=function(t){if(Y[t])return Y[t];var i=o(t);e.body.insertBefore(i,null);var n=U(i,"display");return e.body.removeChild(i),Y[t]="none"!==n?n:"block"}(n.tagName))):a||(n.___cd=U(n,"display"),n.style.display="none")}}))},I.hide=function(){return this.toggle(!1)},I.show=function(){return this.toggle(!0)};var Tt={focus:"focusin",blur:"focusout"},xt={mouseenter:"mouseover",mouseleave:"mouseout"},It=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function St(t){return xt[t]||Tt[t]||t}function Et(t){var e=t.split(".");return[e[0],e.slice(1).sort()]}function Nt(t){return t.___ce=t.___ce||{}}function _t(t,e){return!e||!g.call(e,(function(e){return t.indexOf(e)<0}))}function Ft(t,e,i,n,o){var a=Nt(t);if(e)a[e]&&(a[e]=a[e].filter((function(a){var s=a[0],r=a[1],l=a[2];if(o&&l.guid!==o.guid||!_t(s,i)||n&&n!==r)return!0;t.removeEventListener(e,l)})));else for(e in a)Ft(t,e,i,n,o)}I.trigger=function(t,i){if(P(t)){var n=Et(t),o=n[0],a=n[1],s=St(o);if(!s)return this;var r=It.test(s)?"MouseEvents":"HTMLEvents";(t=e.createEvent(r)).initEvent(s,!0,!0),t.namespace=a.join("."),t.___ot=o}t.___td=i;var l=t.___ot in Tt;return this.each((function(e,i){l&&O(i[t.___ot])&&(i["___i".concat(t.type)]=!0,i[t.___ot](),i["___i".concat(t.type)]=!1),i.dispatchEvent(t)}))},I.off=function(t,e,i){var n=this;if(k(t))this.each((function(t,e){(F(e)||_(e)||N(e))&&Ft(e)}));else if(P(t))O(e)&&(i=e,e=""),D(R(t),(function(t,o){var a=Et(o),s=a[0],r=a[1],l=St(s);n.each((function(t,n){(F(n)||_(n)||N(n))&&Ft(n,l,r,e,i)}))}));else for(var o in t)this.off(o,t[o]);return this},I.remove=function(t){return Z(this,t).detach().off(),this},I.replaceWith=function(t){return this.before(t).remove()},I.replaceAll=function(t){return S(t).replaceWith(this),this},I.on=function(t,e,i,n,o){var a=this;if(!P(t)){for(var s in t)this.on(s,e,i,t[s],o);return this}return P(e)||(k(e)||V(e)?e="":k(i)?(i=e,e=""):(n=i,i=e,e="")),O(n)||(n=i,i=void 0),n?(D(R(t),(function(t,s){var r=Et(s),l=r[0],c=r[1],u=St(l),d=l in xt,p=l in Tt;u&&a.each((function(t,a){if(F(a)||_(a)||N(a)){var s=function(t){if(t.target["___i".concat(t.type)])return t.stopImmediatePropagation();if((!t.namespace||_t(c,t.namespace.split(".")))&&(e||!(p&&(t.target!==a||t.___ot===u)||d&&t.relatedTarget&&a.contains(t.relatedTarget)))){var r=a;if(e){for(var l=t.target;!G(l,e);){if(l===a)return;if(!(l=l.parentNode))return}r=l}Object.defineProperty(t,"currentTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(t,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(t,"data",{configurable:!0,get:function(){return i}});var m=n.call(r,t,t.___td);o&&Ft(a,u,c,e,s),!1===m&&(t.preventDefault(),t.stopPropagation())}};s.guid=n.guid=n.guid||S.guid++,function(t,e,i,n,o){var a=Nt(t);a[e]=a[e]||[],a[e].push([i,n,o]),t.addEventListener(e,o)}(a,u,c,e,s)}}))})),this):this},I.one=function(t,e,i,n){return this.on(t,e,i,n,!0)};var Bt=/\r?\n/g,Ot=/file|reset|submit|button|image/i,Pt=/radio|checkbox/i;I.serialize=function(){var t="";return this.each((function(e,i){D(i.elements||[i],(function(e,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Ot.test(i.type)||Pt.test(i.type)&&!i.checked)){var n=et(i);k(n)||D(c(n)?n:[n],(function(e,n){t+=function(t,e){return"&".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e.replace(Bt,"\r\n")))}(i.name,n)}))}}))})),t.slice(1)},t.exports=S}()},631:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.id,".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}","",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,oBAAoB;AACxB;;AAEA;IACI,YAAY;IACZ,kCAAkC;IAClC,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,yBAAyB;IACzB,2BAA2B;AAC/B;;AAEA;IACI,oCAAoC;IACpC,yBAAyB;AAC7B;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,YAAY;IACZ,wBAAwB;AAC5B;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,iBAAiB;IACjB,2BAA2B;IAC3B,kBAAkB;AACtB;;;AAGA;IACI,sBAAsB;AAC1B;;AAEA;IACI,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;AACpB;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;CACC,gBAAgB;IACb,mBAAmB;IACnB,uBAAuB;CAC1B,iBAAiB;IACd,UAAU;AACd;;AAEA;CACC,cAAc;CACd,eAAe;CACf,iBAAiB;AAClB;;AAEA;CACC,mBAAmB;IAChB,gBAAgB;IAChB,uBAAuB;AAC3B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}"],sourceRoot:""}]);const r=s},290:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}"],sourceRoot:""}]);const r=s},143:(t,e,i)=>{"use strict";i.d(e,{Z:()=>r});var n=i(537),o=i.n(n),a=i(645),s=i.n(a)()(o());s.push([t.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}"],sourceRoot:""}]);const r=s},645:t=>{"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var i="",n=void 0!==e[5];return e[4]&&(i+="@supports (".concat(e[4],") {")),e[2]&&(i+="@media ".concat(e[2]," {")),n&&(i+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),i+=t(e),n&&(i+="}"),e[2]&&(i+="}"),e[4]&&(i+="}"),i})).join("")},e.i=function(t,i,n,o,a){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(n)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var u=[].concat(t[c]);n&&s[u[0]]||(void 0!==a&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=a),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),e.push(u))}},e}},537:t=>{"use strict";t.exports=function(t){var e=t[1],i=t[3];if(!i)return e;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),a="/*# ".concat(o," */");return[e].concat([a]).join("\n")}return[e].join("\n")}},379:t=>{"use strict";var e=[];function i(t){for(var i=-1,n=0;n<e.length;n++)if(e[n].identifier===t){i=n;break}return i}function n(t,n){for(var a={},s=[],r=0;r<t.length;r++){var l=t[r],c=n.base?l[0]+n.base:l[0],u=a[c]||0,d="".concat(c," ").concat(u);a[c]=u+1;var p=i(d),m={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(m);else{var h=o(m,n);n.byIndex=r,e.splice(r,0,{identifier:d,updater:h,references:1})}s.push(d)}return s}function o(t,e){var i=e.domAPI(e);return i.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;i.update(t=e)}else i.remove()}}t.exports=function(t,o){var a=n(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<a.length;s++){var r=i(a[s]);e[r].references--}for(var l=n(t,o),c=0;c<a.length;c++){var u=i(a[c]);0===e[u].references&&(e[u].updater(),e.splice(u,1))}a=l}}},569:t=>{"use strict";var e={};t.exports=function(t,i){var n=function(t){if(void 0===e[t]){var i=document.querySelector(t);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(t){i=null}e[t]=i}return e[t]}(t);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(i)}},216:t=>{"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,i)=>{"use strict";t.exports=function(t){var e=i.nc;e&&t.setAttribute("nonce",e)}},795:t=>{"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(i){!function(t,e,i){var n="";i.supports&&(n+="@supports (".concat(i.supports,") {")),i.media&&(n+="@media ".concat(i.media," {"));var o=void 0!==i.layer;o&&(n+="@layer".concat(i.layer.length>0?" ".concat(i.layer):""," {")),n+=i.css,o&&(n+="}"),i.media&&(n+="}"),i.supports&&(n+="}");var a=i.sourceMap;a&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleTagTransform(n,t,e.options)}(e,t,i)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{"use strict";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 i(n){var o=e[n];if(void 0!==o)return o.exports;var a=e[n]={id:n,exports:{}};return t[n](a,a.exports,i),a.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{_package:()=>Bt,demoFileIngest:()=>kt,demoFileIngest1:()=>Vt,demoFileIngest2:()=>Lt,demoFileSubmit:()=>jt,gasteigerCellRenderer:()=>Dt,hitDesignApp:()=>Pt,hitTriageApp:()=>Ot});const t=grok,e=DG,o=ui,a="campaignId",s="campaignId",r="HitTriageDataSource",l="HitTriageSubmitFunction",c="Selected hits",u="Stage",d="Molecule",p="V-iD",m="V######",h="HTScript",f="HTQuery",v="molecules",g="Source",y="New template",b="Start",w="Create",C="Download",A="Cancel",T="Continue a campaign",x="New campaign";var I=i(379),S=i.n(I),E=i(795),N=i.n(E),_=i(569),F=i.n(_),B=i(565),O=i.n(B),P=i(216),k=i.n(P),V=i(589),L=i.n(V),j=i(631),D={};D.styleTagTransform=L(),D.setAttributes=O(),D.insert=F().bind(null,"head"),D.domAPI=N(),D.insertStyleElement=k(),S()(j.Z,D),j.Z&&j.Z.locals&&j.Z.locals;var H=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};const M=t=>`${t.getFullYear()}/${t.getMonth()+1}/${t.getDate()}`;function R(t,e){const i=document.title,n=window.location.href.split("?")[0]+"?"+t+"="+e;if(history.replaceState){const t={Title:i,Url:n};history.replaceState(t,t.Title,t.Url)}}function U(e,i,n,a){var s;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((t=>{1===t.length&&(l.unsubscribe(),$(e),a())})),c=null===(s=t.shell.v.ribbonMenu.root.parentElement)||void 0===s?void 0:s.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function $(t){const e=t.getRibbonPanels();(null==e?void 0:e.length)&&(e.pop(),t.setRibbonPanels(e))}function q(t){return t.reduce(((t,e)=>t||e.reduce(((t,e)=>t||e.classList.contains("hit-design-submit-button")||Array.from(e.children).some((t=>t.classList.contains("hit-design-submit-button")))),!1)),!1)}function Y(t,i,n){return H(this,void 0,void 0,(function*(){if(0===n.rowCount)return;if(!t.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(v);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(e.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const a=n.columns.names().filter((t=>t!==v));t.join(n,[i],[o.name],void 0,a,void 0,!0)}))}function W(t,e){return H(this,void 0,void 0,(function*(){const i=(yield Bt.files.list(`${t}/campaigns`)).filter((t=>-1===e.indexOf(t.name))),n={};for(const e of i)try{const i=JSON.parse(yield Bt.files.readAsText(`${t}/campaigns/${e.name}/campaign.json`));n[i.name]=i}catch(t){continue}return n}))}const G={String:e.TYPE.STRING,Number:e.TYPE.FLOAT,Boolean:e.TYPE.BOOL,Date:e.TYPE.DATE_TIME,Molecule:e.SEMTYPE.MOLECULE};var J=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))},Z=i(553),z=i.n(Z);function Q(i,n,a,s,r){var l,c,u,d,p,m,v,g,y,b,w,C,A,T,x,I,S,E,N,_,F,B,O,P,k,V,L,j,D,H,M;return j=this,D=void 0,M=function*(){const j=yield i.computeFunctions,D=j.functions.filter((({inputs:t})=>t.length>2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType)).map((t=>{var e,i,n,o;return{package:t.package.name,name:t.name,args:null!==(o=null===(n=null===(i=null===(e=null==s?void 0:s.compute)||void 0===e?void 0:e.functions)||void 0===i?void 0:i.find((e=>e.name===t.name&&e.package===t.package.name)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),H=j.scripts.filter((({inputs:t})=>t.length>=2&&"dataframe"===t[0].propertyType&&"column"===t[1].propertyType)).map((t=>{var e,i,n,o;return{name:t.name,id:t.id,args:null!==(o=null===(n=null===(i=null===(e=null==s?void 0:s.compute)||void 0===e?void 0:e.scripts)||void 0===i?void 0:i.find((e=>e.id===t.id)))||void 0===n?void 0:n.args)&&void 0!==o?o:{}}})),M=j.queries.filter((t=>t.inputs.length>0&&"list"===t.inputs[0].propertyType)).map((t=>{var e,i,n,o,a;return{name:null!==(e=t.friendlyName)&&void 0!==e?e:t.name,id:t.id,args:null!==(a=null===(o=null===(n=null===(i=null==s?void 0:s.compute)||void 0===i?void 0:i.queries)||void 0===n?void 0:n.find((e=>e.id===t.id)))||void 0===o?void 0:o.args)&&void 0!==a?a:{}}})),R=!!(null===(c=null===(l=null==s?void 0:s.compute)||void 0===l?void 0:l.descriptors)||void 0===c?void 0:c.enabled)||r,U=yield t.chem.descriptorsTree(),$=o.tree();$.root.classList.add("hit-triage-compute-dialog-descriptors-group");const q=o.div([],{classes:"hit-triage-compute-dialog-host"}),Y=[];function W(t,e){const i=e.group(t,null,!1);return i.enableCheckBox(!1),i}const G=Object.keys(U),J=null!==(p=null===(d=null===(u=null==s?void 0:s.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[];for(const t of G){const e=W(t,$);for(const i of U[t].descriptors){const t=e.item(i.name,i);Y.push(t),t.enableCheckBox(J.includes(i.name))}}const Z="Descriptors",Q={[Z]:Z},K=R?{[Z]:$.root}:{},X={},tt={[Z]:!1};tt.Descriptors=!!(null===(v=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===v?void 0:v.enabled)&&(null===(b=null===(y=null===(g=null==s?void 0:s.compute)||void 0===g?void 0:g.descriptors)||void 0===y?void 0:y.args)||void 0===b?void 0:b.length)>0;for(const t of D)try{const i=e.Func.find({package:t.package,name:t.name})[0],n=i.prepare(t.args),a=`${t.package}:${t.name}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(w=i.friendlyName)&&void 0!==w?w:i.name]=r,Q[null!==(C=i.friendlyName)&&void 0!==C?C:i.name]=a,tt[a]=null!==(x=null===(T=null===(A=null==s?void 0:s.compute)||void 0===A?void 0:A.functions)||void 0===T?void 0:T.some((e=>e.name===t.name&&e.package===t.package)))&&void 0!==x&&x,r.children[0].style.display="none",r.children[1].style.display="none",l.forEach((e=>{var i,n;(null===(i=e.property)||void 0===i?void 0:i.name)&&Object.keys(t.args).includes(null===(n=e.property)||void 0===n?void 0:n.name)&&(e.value=t.args[e.property.name]),e.fireChanged()}))}catch(t){console.error(t);continue}for(const e of H)try{const i=yield t.dapi.scripts.find(e.id),n=i.prepare(e.args),a=`HTScript:${null!==(I=e.name)&&void 0!==I?I:""}:${e.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(S=i.friendlyName)&&void 0!==S?S:i.name]=r,Q[null!==(E=i.friendlyName)&&void 0!==E?E:i.name]=a,tt[a]=null!==(F=null===(_=null===(N=null==s?void 0:s.compute)||void 0===N?void 0:N.scripts)||void 0===_?void 0:_.some((t=>t.id===e.id)))&&void 0!==F&&F,r.children[0].style.display="none",r.children[1].style.display="none",l.forEach((t=>{var i,n;(null===(i=t.property)||void 0===i?void 0:i.name)&&Object.keys(e.args).includes(null===(n=t.property)||void 0===n?void 0:n.name)&&(t.value=e.args[t.property.name]),t.fireChanged()}))}catch(t){console.error(t);continue}for(const e of M)try{const i=yield t.dapi.queries.find(e.id),n=i.prepare(e.args),a=`HTQuery:${null!==(B=e.name)&&void 0!==B?B:""}:${e.id}`;X[a]=n;const r=o.div(),l=yield n.buildEditor(r,{condensed:!1});r.classList.add("oy-scroll"),r.style.marginLeft="15px",r.style.removeProperty("max-width"),K[null!==(O=i.friendlyName)&&void 0!==O?O:i.name]=r,Q[null!==(P=i.friendlyName)&&void 0!==P?P:i.name]=a,tt[a]=null!==(L=null===(V=null===(k=null==s?void 0:s.compute)||void 0===k?void 0:k.queries)||void 0===V?void 0:V.some((t=>t.id===e.id)))&&void 0!==L&&L,r.children[0].style.display="none",l.forEach((t=>{var i,n;(null===(i=t.property)||void 0===i?void 0:i.name)&&Object.keys(e.args).includes(null===(n=t.property)||void 0===n?void 0:n.name)&&(t.value=e.args[t.property.name]),t.fireChanged()}))}catch(t){console.error(t);continue}const et=o.tabControl(K,!0);function it(){const t={descriptors:[],externals:{},scripts:{},queries:{}};t.descriptors=tt.Descriptors?Y.filter((t=>t.checked)).map((t=>t.value.name)):[];const e=Object.entries(X).filter((([t,e])=>tt[t]));e.filter((([t,e])=>!t.startsWith(h)&&!t.startsWith(f))).forEach((([e,i])=>{t.externals[e]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{t.externals[e][i]=n}))})),e.filter((([t,e])=>t.startsWith(h))).forEach((([e,i])=>{t.scripts[e]={};const n=i.inputs;Object.entries(n).slice(2).forEach((([i,n])=>{t.scripts[e][i]=n}))})),e.filter((([t,e])=>t.startsWith(f))).forEach((([e,i])=>{t.queries[e]={};const n=i.inputs;Object.entries(n).slice(1).forEach((([i,n])=>{t.queries[e][i]=n}))})),console.log(t),n(t)}return et.onTabChanged.subscribe((()=>{try{et.currentPane.content.style.removeProperty("max-width")}catch(t){}})),et.header.style.overflow="scroll",et.root.style.width="100%",et.root.style.minWidth="350px",q.appendChild(et.root),et.panes.forEach((t=>{const e=o.boolInput("",tt[Q[t.name]],(i=>{tt[Q[t.name]]=!!e.value,i?z()(t.content).find("input").removeAttr("disabled"):z()(t.content).find("input").attr("disabled","true")}));e.setTooltip("Toggle calculation of this function"),t.header.appendChild(e.root),t.header.classList.add("hit-triage-compute-dialog-pane-header")})),r&&o.dialog("Compute").add(q).onOK((()=>it())).onCancel(a).show(),{root:q,okProxy:it}},new((H=void 0)||(H=Promise))((function(t,e){function i(t){try{o(M.next(t))}catch(t){e(t)}}function n(t){try{o(M.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof H?o:new H((function(t){t(o)}))).then(i,n)}o((M=M.apply(j,D||[])).next())}))}const K=rxjs;class X{constructor(t,e=[],i={}){this.onItemChanged=new K.Subject,this.onAddingItemChanged=new K.Subject,this.onItemAdded=new K.Subject,this.onItemRemoved=new K.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.properties=t,this.options=Object.assign(Object.assign({},this.options),i),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=e,this.render()}get root(){return this._root}get items(){return this._items}render(){var t,e,i,n;if(o.empty(this._root),!this.options.horizontalInputNames)for(const e of this.properties){const i=o.divText(null!==(t=e.caption)&&void 0!==t?t:e.name);i.style.fontWeight="bold",this._root.appendChild(i)}for(const t of this._items){const e=this.getItemDiv(t);for(const t of e)this._root.appendChild(t)}if(this.options.allowAdd){const t=this.getItemDiv(null!==(n=null===(i=(e=this.options).newItemFunction)||void 0===i?void 0:i.call(e))&&void 0!==n?n:void 0,!0);for(const e of t)this._root.appendChild(e)}}getItemDiv(t={},i){var n;const a=[],s={};let r=null;for(const l of this.properties){void 0===t[l.name]&&(t[l.name]=null);const c=(null===(n=this.options.customInputs)||void 0===n?void 0:n[l.name])?this.options.customInputs[l.name](t):o.input.forProperty(l,t);a.push(this.options.horizontalInputNames?c.root:this.hideLabel(c.root)),l.propertyType!==e.TYPE.BOOL&&"color"!==l.name.toLowerCase()&&c.input&&(c.input.style.width="100%"),s[l.name]=c,c.onChanged((()=>{t[l.name]=c.value,i?this.onAddingItemChanged.next({item:t,fieldName:l.name}):this.onItemChanged.next({item:t,fieldName:l.name})})),c.root.style.alignItems="center",r=c}let l=null;if(i)l=o.icons.add((()=>{const t=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(s).forEach((e=>{t[e]=s[e].value})),this._items.push(t),this.onItemAdded.next(t),this.render()}),this.options.addButtonTooltip);else{if(!this.options.allowRemove)return a;l=o.icons.delete((()=>{this._items.splice(this._items.indexOf(t),1),this.onItemRemoved.next(t),this.render()}),this.options.removeButtonTooltip)}return r&&r.addOptions?r.addOptions(l):null==r||r.root.appendChild(l),l.style.color="#2083d5",a}hideLabel(t){return t.getElementsByTagName("label")[0]&&t.removeChild(t.getElementsByTagName("label")[0]),t}}var tt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function et(i,n){var a,s;return tt(this,void 0,void 0,(function*(){const c=(yield Bt.files.list("Hit Triage/templates")).map((t=>t.name.slice(0,-5))),u=[];for(const t of c){const e=JSON.parse(yield Bt.files.readAsText(`Hit Triage/templates/${t}.json`));u.push(e.key)}const d=e.Func.find({tags:[l]}),p={};d.forEach((t=>{var e;p[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const m=o.choiceInput("Submit function",null,[null,...Object.keys(p)]);m.value=null,m.nullable=!0,m.fireChanged(),m.setTooltip("Select function to be called upon submitting");const v=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),y=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),b=o.stringInput("Name","",(()=>{""===b.value||c.includes(b.value)?(b.root.style.borderBottom="1px solid red",v.style.opacity="100%"):(b.root.style.borderBottom="none",v.style.opacity="0%")})),C=o.stringInput("Key","",(()=>{""===C.value||u.includes(C.value)?(C.root.style.borderBottom="1px solid red",y.style.opacity="100%"):(C.root.style.borderBottom="none",y.style.opacity="0%")}));C.setTooltip("Template key used for campaign prefix"),b.setTooltip("Template name"),b.root.style.borderBottom="none",C.root.style.borderBottom="none",v.style.opacity="0%",y.style.opacity="0%";let T=null;const x=yield Q(i,(t=>{T=t}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);if(x.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length){const i=e.Func.find({tags:[r]}),o=yield t.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list();i.forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})),o.forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}))}const I=Object.keys(n),S=o.choiceInput(g,I[0],I),E=o.choiceInput("Ingest using","Query",["Query","File"],(()=>{"Query"!==E.value?S.root.style.display="none":S.root.style.display="block"})),N=it(),_=o.div([o.h2("Details"),o.div([b,v]),o.div([C,y]),E.root,S.root,N.fieldsDiv,o.h2("Compute"),x.root,o.h2("Submit"),m.root],"ui-form"),F=o.buttonsInput([]),B=null!==(s=null===(a=F.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==s?s:F;_.appendChild(F);const O=new Promise((t=>{const e=o.button(A,(()=>t()));B.appendChild(e)})),P=new Promise((e=>{const i=o.bigButton(w,(()=>function(){var i,n,o,a,s,r,l;return tt(this,void 0,void 0,(function*(){if(x.okProxy(),"100%"===v.style.opacity)return void t.shell.error("Template name is empty or already exists");const c=m.value?p[m.value]:void 0,u=Object.assign(Object.assign({name:b.value,key:C.value,campaignFields:N.getFields(),dataSourceType:null!==(i=E.value)&&void 0!==i?i:"Query",compute:{descriptors:{enabled:!!(null===(n=null==T?void 0:T.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==T?void 0:T.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==T?void 0:T.externals)&&void 0!==a?a:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(s=null==T?void 0:T.scripts)&&void 0!==s?s:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(r=null==T?void 0:T.queries)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))}},c?{submit:{fName:c.name,package:c.package.name}}:{}),{queryFunctionName:"Query"===E.value&&null!==(l=S.value)&&void 0!==l?l:void 0});var d;d=u,Bt.files.writeAsText(`Hit Triage/templates/${d.name}.json`,JSON.stringify(d)),t.shell.info("Template created successfully"),e(u)}))}()));B.appendChild(i)}));return{root:_,template:P,cancelPromise:O}}))}function it(t){const i=[e.Property.fromOptions({name:"Name",type:e.TYPE.STRING}),e.Property.fromOptions({name:"Type",type:e.TYPE.STRING,choices:Object.keys(G)}),e.Property.fromOptions({name:"Required",type:e.TYPE.BOOL})],n=new X(i,t?t.map((t=>({Name:t.name,Type:t.type,Required:t.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe((t=>{a={}})),n.onAddingItemChanged.subscribe((t=>{t&&(a=t.item)}));const s=o.h2("Additional fields");o.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=o.div([s,n.root]);return{getFields:function(){var t;const e=n.items.filter((t=>t.Name)).map((t=>{var e;return{name:t.Name,type:t.Type,required:null!==(e=t.Required)&&void 0!==e&&e}}));return a.Name&&""!==a.Name&&a.Type&&(null!==(t=a.Required)&&void 0!==t||(a.Required=!1),e.push({name:a.Name,type:a.Type,required:a.Required})),e},fieldsDiv:o.div([r])}}var nt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class ot extends e.ViewBase{constructor(t){super(),this.deletedCampaigns=[],this.app=t}get template(){return this.app.template}onActivated(){}onReset(){}process(){return nt(this,void 0,void 0,(function*(){}))}deleteCampaign(t,e){return nt(this,void 0,void 0,(function*(){yield Bt.files.delete(`${t}/campaigns/${e}`)}))}}var at=i(290),st={};st.styleTagTransform=L(),st.setAttributes=O(),st.insert=F().bind(null,"head"),st.domAPI=N(),st.insertStyleElement=k(),S()(at.Z,st),at.Z&&at.Z.locals&&at.Z.locals;var rt;!function(e){let i,n;!function(t){t.vert=function(t){return o.divV(t.map((t=>o.render(t))),{classes:"u2-panel"})},t.horz=function(t){return o.divH(t.map((t=>o.render(t))),{classes:"u2-panel"})}}(i=e.panels||(e.panels={})),e.appHeader=function(t){const e=o.iconImage("",t.iconPath);return z()(e).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([e,i.vert([o.markdown(t.description),t.learnMoreUrl?o.link("Learn more",t.learnMoreUrl):null])])},function(e){e.runAsync=function(e,i){return n=this,a=void 0,r=function*(){o.setUpdateIndicator(e,!0);try{return yield i()}catch(e){t.log.error(e)}finally{o.setUpdateIndicator(e,!1)}},new((s=void 0)||(s=Promise))((function(t,e){function i(t){try{l(r.next(t))}catch(t){e(t)}}function o(t){try{l(r.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s((function(t){t(n)}))).then(i,o)}l((r=r.apply(n,a||[])).next())}));var n,a,s,r}}(n=e.tools||(e.tools={}))}(rt||(rt={}));var lt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class ct extends ot{constructor(e){super(e),this.readmePath=Bt.webRoot+"README_HT.md",this.dataSourceFunctionsMap={},this.name="Hit Triage",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(this.readmePath),this.checkCampaign().then((t=>{this.app.campaign=t,this.init()}))}onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(this.readmePath)}init(t){return lt(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const e=o.h1(T),i=o.h1(x,{style:{marginLeft:"10px"}}),n=rt.appHeader({iconPath:Bt.webRoot+"/images/icons/hit-triage-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HT.md",description:"- Configure your own workflow using the template editor.\n- Calculate different molecular properties.\n- Filter molecules using different criteria.\n- Submit processed dataframe to the function of your choice.\n- Save campaigns and continue any time from where you left off.\n "}),a=o.div(),s=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(a,s,t),z()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,e],{style:{marginLeft:"10px"}}),r,i,s,a])),this.app.resetBaseUrl()}catch(t){throw o.setUpdateIndicator(this.root,!1),t}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,e,i){var n;return lt(this,void 0,void 0,(function*(){const a=(yield Bt.files.list("Hit Triage/templates")).map((t=>t.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);const s=()=>lt(this,void 0,void 0,(function*(){const e=r.value,n=i&&i.name===e?i:JSON.parse(yield Bt.files.readAsText("Hit Triage/templates/"+e+".json")),o=yield this.getNewCampaignAccordeon(n,t);z()(t).empty(),t.className="ui-form",t.appendChild(o)})),r=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>lt(this,void 0,void 0,(function*(){yield s()})))),l=o.icons.add((()=>lt(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),y);r.addOptions(l),yield s(),z()(e).empty(),e.appendChild(r.root)}))}checkCampaign(t){return lt(this,void 0,void 0,(function*(){const e=location.search,i=new URLSearchParams(e);if(!i.has(a)&&!t)return;const n=null!=t?t:i.get(a);if(!(yield Bt.files.exists(`Hit Triage/campaigns/${n}/campaign.json`)))return;const o=JSON.parse(yield Bt.files.readAsText(`Hit Triage/campaigns/${n}/campaign.json`)),s=JSON.parse(yield Bt.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(s,o.filters,n,o.ingest),t&&R(a,t),o}))}getCampaignsTable(){return lt(this,void 0,void 0,(function*(){const t=yield W("Hit Triage",this.deletedCampaigns),e=Object.values(t).map((t=>({name:t.name,createDate:t.createDate,rowCount:t.rowCount,filtered:t.filteredRowCount,status:t.status}))),i=o.table(e,(t=>[o.link(t.name,(()=>this.setCampaign(t.name)),"",""),t.createDate,t.rowCount,t.filtered,t.status,o.icons.delete((()=>lt(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${t.name}?`)).onOK((()=>lt(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Triage",t.name),this.deletedCampaigns.push(t.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Total","Selected","Status",""]);return i.style.color="var(--grey-5)",i}))}setCampaign(t){return lt(this,void 0,void 0,(function*(){const e=yield this.checkCampaign(t);this.app.campaign=e}))}getNewCampaignAccordeon(i,n){return lt(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:a,promise:s,cancelPromise:l}=yield function(i,n){var a,s;return J(this,void 0,void 0,(function*(){const l=o.divText("",{style:{color:"red"}});let c=null;const u=()=>J(this,void 0,void 0,(function*(){try{if(c=d.value,!c)return;if(yield c.meta.detectSemanticTypes(),!c.columns.bySemType(e.SEMTYPE.MOLECULE))return void(l.innerText="No molecules column found");l.innerText=""}catch(t){l.innerText="Error parsing file"}})),d=o.tableInput("Dataframe",null,void 0,u);yield u();const p=o.div([d,l]);0===Object.keys(n).length&&(e.Func.find({tags:[r]}).forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})),(yield t.dapi.queries.include("params,connection").filter("#HitTriageDataSource").list()).forEach((t=>{var e;n[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t})));let m=null;const h=()=>J(this,void 0,void 0,(function*(){const t=n[v.value];m=t.prepare();const e=yield m.getEditor();e.classList.remove("ui-form"),f.innerHTML="",f.appendChild(e)})),f=o.div([]),v=o.choiceInput(g,null!==(a=i.queryFunctionName)&&void 0!==a?a:Object.keys(n)[0],Object.keys(n),h);yield h(),i.queryFunctionName&&(null===(s=v.root.getElementsByTagName("select").item(0))||void 0===s||s.setAttribute("disabled","true"));const y=o.div([v,f]);y.style.display="none";const w=o.div([p,y]),C=i.campaignFields.map((t=>t.type===e.SEMTYPE.MOLECULE?Object.assign(Object.assign({},t),{type:"String",semtype:e.SEMTYPE.MOLECULE}):t)).map((t=>e.Property.fromOptions(Object.assign({name:t.name,type:G[t.type],nullable:!t.required},t.semtype?{semType:t.semtype}:{})))),T={},x=C.length?o.input.form(T,C):o.div();x.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",y.style.display="none"):(p.style.display="none",y.style.display="inherit");const I=o.div([w,...C.length?[x]:[]]),S=o.buttonsInput([]);return I.appendChild(S),{promise:new Promise((e=>{const a=()=>J(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!c)return void t.shell.error("No file selected");const i=c;i.name=c.name,e({df:i,type:"File",campaignProps:T})}else{const i=n[v.value];if(!i)return void t.shell.error("No function selected");const o={};Object.entries(m.inputs).forEach((([t,e])=>{o[t]=e}));const a=yield i.apply(o);e({df:a,type:"Query",campaignProps:T})}})),s=o.bigButton(b,(()=>a()));S.appendChild(s)})),root:I,cancelPromise:new Promise((t=>{o.button(A,(()=>t()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),s.then((t=>lt(this,void 0,void 0,(function*(){this.app.dataFrame=t.df,this.app._fileInputType=t.type,yield this.app.setTemplate(i),this.app.campaignProps=t.campaignProps,this.app.saveCampaign(void 0,!1)})))),l.then((()=>{this.init()})),a}))}createNewTemplate(){return lt(this,void 0,void 0,(function*(){const i=yield et(this.app,this.dataSourceFunctionsMap),n=new e.ViewBase,o=t.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,t.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=o;const{sub:a}=U(t.shell.v,"Hit Triage",y,(()=>{t.shell.v=o,n.close()}));i.template.then((e=>lt(this,void 0,void 0,(function*(){yield this.init(e),n.close(),$(n),t.shell.v=o,a.unsubscribe()})))),i.cancelPromise.then((()=>{a.unsubscribe(),n.close(),t.shell.v=o}))}))}}class ut extends ot{constructor(t){super(t),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var i,n,o,a,s;return n=this,o=void 0,s=function*(){const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=e.Func.find({name:n.fName,package:n.package})[0];if(!o)return void t.shell.error(`Function ${n.fName} not found.`);const a=e.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),t.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(t,e){function i(t){try{l(s.next(t))}catch(t){e(t)}}function r(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 a?n:new a((function(t){t(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var dt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class pt{constructor(i){this.parentCall=i,this.resetBaseUrl(),this.computeFunctions=new Promise((i=>dt(this,void 0,void 0,(function*(){const n=e.Func.find({tags:["HitTriageFunction"]}).filter((t=>"function-package"===t.type)),o=yield t.dapi.scripts.include("params").filter("#HitTriageFunction").list(),a=yield t.dapi.queries.include("params,connection").filter("#HitTriageFunction").list();i({functions:n,scripts:o,queries:a})}))))}resetBaseUrl(){const t=window.location.href,e=new URL(t);this.baseUrl=e.origin+e.pathname}getFilterType(t){const i=this.dataFrame.col(t);return(null==i?void 0:i.semType)===e.SEMTYPE.MOLECULE?e.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===e.COLUMN_TYPE.BOOL?e.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===e.COLUMN_TYPE.STRING?e.FILTER_TYPE.CATEGORICAL:e.FILTER_TYPE.HISTOGRAM}download(t,i,n=!1){const o=document.createElement("a"),a=e.DataFrame.fromColumns(t.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(t,e){return dt(this,void 0,void 0,(function*(){const i=(yield Bt.files.list(t)).map((t=>t.name)).filter((t=>t.startsWith(e)));if(0===i.length)return e+"-1";const n=i.map((t=>t.split("-")[1])).filter(Boolean).map((t=>parseInt(t,10))).sort();return e+"-"+(n[n.length-1]+1).toString()}))}setBaseUrl(){const t=document.title;if(history.replaceState){const e={Title:t,Url:this.baseUrl};history.replaceState(e,e.Title,e.Url)}}}var mt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))},ht=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function ft(t){let e=0;if(t.length>1)for(const i of t.toList()){if(!i||!i.startsWith(m[0])||i.length!==m.length)continue;const t=parseInt(i.substring(1));isNaN(t)||(e=Math.max(t,e))}return`V${"".concat(...new Array(m.length-1-(e+1).toString().length).fill("0"))}${e+1}`}function vt(i,n,o){var a,s;return ht(this,void 0,void 0,(function*(){const r=e.TaskBarProgressIndicator.create("Calculating ..."),l=n.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let e=0;e<l.length;e++){if(l.isNone(e))continue;const i=l.get(e);if(!i)continue;const n=t.chem.convert(i,t.chem.Notation.Unknown,t.chem.Notation.Smiles);l.set(e,n,!1)}i.descriptors&&i.descriptors.length>0&&(yield t.chem.descriptors(n,o,i.descriptors));for(const t of Object.keys(i.externals))try{const a=i.externals[t],s=e.Func.find({package:t.split(":")[0],name:t.split(":")[1]})[0],r=s.inputs[0].name,l=s.inputs[1].name;a&&(yield s.apply(Object.assign(Object.assign({},a),{[r]:n,[l]:o})))}catch(t){console.error(t)}for(const e of Object.keys(null!==(a=i.scripts)&&void 0!==a?a:{})){const a=i.scripts[e];if(a){const i=e.split(":")[2];if(!i)continue;try{const e=yield t.dapi.scripts.find(i);if(!e)continue;const s=e.inputs[0].name,r=e.inputs[1].name,l=yield e.apply(Object.assign(Object.assign({},a),{[s]:n,[r]:o}));if(l&&l.rowCount===n.rowCount&&"python"===e.language)for(const t of l.columns)t.name=n.columns.getUnusedName(t.name),n.columns.add(t)}catch(t){console.error(t)}}}for(const e of Object.keys(null!==(s=i.queries)&&void 0!==s?s:{})){const a=i.queries[e];if(a){const i=e.split(":")[2];if(!i)continue;try{const e=yield t.dapi.queries.find(i);if(!e)continue;const s=e.inputs[0].name,r=n.col(o).toList(),l=yield e.apply(Object.assign(Object.assign({},a),{[s]:r}));l&&(yield Y(n,o,l))}catch(t){console.error(t)}}}r.close()}))}var gt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class yt extends pt{constructor(i){super(i),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new ct(this),this.multiView=new e.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((t=>{this.multiView.currentView instanceof ot&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,t.events.onCurrentViewChanged.subscribe((()=>{var e,i,n,o;try{(null===(e=t.shell.v)||void 0===e?void 0:e.name)===this.currentPickViewId&&(t.shell.windows.showHelp=!1,this.setBaseUrl(),R(a,null!==(o=null!==(i=this._campaignId)&&void 0!==i?i:null===(n=this._campaign)||void 0===n?void 0:n.name)&&void 0!==o?o:""))}catch(t){console.error(t)}}))}get infoView(){return this._infoView}setTemplate(i,n,o,s){var r,l,c,u,d,p,m,h,f,v,g,y,b,w,C;return gt(this,void 0,void 0,(function*(){if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&t.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?s&&(this._fileInputType=s.type,"File"===s.type?this.dataFrame=yield t.dapi.files.readCsv(s.query):this.dataFrame=yield t.functions.call(s.query)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),R(a,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);i&&i.semType!==e&&(i.semType=e)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);if(i&&i.type!==e)try{i.convertTo(e)}catch(t){console.error(t)}})),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(d=this.dataFrame.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==p?p:void 0,this._dfName=null!==(m=this.dataFrame.name)&&void 0!==m?m:null==s?void 0:s.query,this.dataFrame.name=null!==(f=null!==(h=this._dfName)&&void 0!==h?h:this.dataFrame.name)&&void 0!==f?f:"Molecules",this._campaignId=o,this.template=(null===(v=this.campaign)||void 0===v?void 0:v.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const t={},e={},n={};i.compute.functions.forEach((e=>{const i=`${e.package}:${e.name}`;t[i]=e.args})),null===(g=i.compute.scripts)||void 0===g||g.forEach((t=>{const i=`HTScript:${t.name}:${t.id}`;e[i]=t.args})),null===(y=i.compute.queries)||void 0===y||y.forEach((t=>{const e=`HTQuery:${t.name}:${t.id}`;n[e]=t.args})),yield vt({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:t,scripts:e,queries:n},this.dataFrame,this._molColName)}const A=t.shell.v,T=t.shell.addView(this.pickView);this.currentPickViewId=T.name,this._submitView=new ut(this),this.setBaseUrl(),R(a,null!==(C=null!==(b=this._campaignId)&&void 0!==b?b:null===(w=this._campaign)||void 0===w?void 0:w.name)&&void 0!==C?C:"");const x=T;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:e}=U(x,"Hit Triage","Pick",(()=>{t.shell.v=A,x.close(),e.unsubscribe()}))}))}),300),t.shell.windows.showHelp=!1}))}get filterSettings(){return this._campaignFilters}get campaignId(){return this._campaignId}get pickView(){return this._pickView=this.getFilterView()}get molColName(){var t,i,n;return null!==(t=this._molColName)&&void 0!==t?t:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name}get fileInputType(){return this._fileInputType}get campaign(){return this._campaign}set campaign(t){this._campaign=t}getFilterView(){let t=null;this._pickViewPromise=new Promise((e=>{t=e})),this.dataFrame.col(c)||this.dataFrame.columns.addNewBool(c).init(!1);const i=e.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=o.iconFA("wrench",(()=>gt(this,void 0,void 0,(function*(){Q(this,(t=>gt(this,void 0,void 0,(function*(){var e,i,n,o,a,s,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(e=this.template.compute.scripts)&&void 0!==e?e:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=t.descriptors,m={descriptors:{enabled:!!(null===(n=null==t?void 0:t.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==t?void 0:t.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(a=null==t?void 0:t.externals)&&void 0!==a?a:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(s=null==t?void 0:t.scripts)&&void 0!==s?s:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(r=null==t?void 0:t.queries)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))};this.template.compute=m;const v=p.filter((t=>!l.includes(t))),g=m.functions.filter((t=>{if(!c.some((e=>e.name===t.name&&e.package===t.package)))return!0;const e=c.find((e=>e.name===t.name&&e.package===t.package));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),y=m.scripts.filter((t=>{if(!u.some((e=>e.id===t.id)))return!0;const e=u.find((e=>e.id===t.id));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),b=m.queries.filter((t=>{if(!d.some((e=>e.id===t.id)))return!0;const e=d.find((e=>e.id===t.id));return!Object.entries(t.args).every((([t,i])=>e.args[t]===i))})),w={};g.forEach((t=>{const e=`${t.package}:${t.name}`;w[e]=t.args}));const C={};y.forEach((t=>{const e=`HTScript:${t.name}:${t.id}`;C[e]=t.args}));const A={};b.forEach((t=>{const e=`HTQuery:${t.name}:${t.id}`;A[e]=t.args})),yield vt({descriptors:v,externals:w,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),s=o.bigButton("Submit",(()=>{var t;const e=null===(t=this._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this._submitView)||void 0===e||e.submit(),t.close()})),t.show()}}));s.classList.add("hit-design-submit-button");const r=q(n);return n.push([a,...r?[]:[s]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>gt(this,void 0,void 0,(function*(){var n;i._onAdded(),yield new Promise((t=>setTimeout(t,1e3)));const o=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0);if(null===(n=this._campaign)||void 0===n?void 0:n.layout)try{const t=e.ViewLayout.fromViewState(this._campaign.layout);i.loadLayout(t)}catch(t){console.error(t)}i.dataFrame.onFilterChanged.subscribe((t=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=o.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=o.getOptions().look.filters}),300),t&&t()}))),300),i.parentCall=this.parentCall,i}getSummary(){var t,e,i,n,a,s,r;const l=null!==(e=null===(t=this.campaign)||void 0===t?void 0:t.campaignFields)&&void 0!==e?e:this.campaignProps;return Object.assign(Object.assign({Template:null!==(n=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==n?n:"Molecules","File path":o.divH([o.link(null!==(a=this._dfName)&&void 0!==a?a:"-",(()=>this.download(this.dataFrame,"molecules")),C)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((t=>t.name))].filter((t=>t&&""!==t.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(s=this.dataFrame)||void 0===s?void 0:s.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),C)],{style:{alignItems:"center"}})})}saveCampaign(i,n=!0){var a,s,r,l,c,u;return gt(this,void 0,void 0,(function*(){const d=this.campaignId,p=this.filterSettings,m=this.template.name,h=this.dataFrame,f=`System:AppData/HitTriage/Hit Triage/campaigns/${d}/`,v=null!=d?d:yield function(t){return mt(this,void 0,void 0,(function*(){return new Promise((e=>mt(this,void 0,void 0,(function*(){const i=o.stringInput("Campaign name","");o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?e(i.value):e(t)})).show()}))))}))}(d),g={};h.columns.toList().forEach((t=>g[t.name]=t.semType));const y={};h.columns.toList().forEach((t=>y[t.name]=t.type));const b={name:v,templateName:m,filters:null!=p?p:{},ingest:{type:"File",query:`${f}enriched_table.csv`,molColName:this.molColName},status:null!==(s=null!=i?i:null===(a=this.campaign)||void 0===a?void 0:a.status)&&void 0!==s?s:"In Progress",createDate:null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.createDate)&&void 0!==l?l:M(new Date),campaignFields:null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.campaignFields)&&void 0!==u?u:this.campaignProps,columnSemTypes:g,rowCount:h.rowCount,filteredRowCount:h.filter.trueCount,template:this.template,columnTypes:y};this.campaign=b;const w=e.DataFrame.fromColumns(h.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv();yield Bt.files.writeAsText(`Hit Triage/campaigns/${d}/enriched_table.csv`,w);const C=this._pickView.saveLayout();C?b.layout=C.viewState:t.shell.warning("Layout cound not be saved"),yield Bt.files.writeAsText(`Hit Triage/campaigns/${d}/campaign.json`,JSON.stringify(b)),n&&t.shell.info("Campaign saved successfully.")}))}}var bt=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};function wt(i,n){var a,s,r,c,u,d,p,m,v,g,y;return bt(this,void 0,void 0,(function*(){const b=yield Bt.files.list("Hit Design/templates");let C=!1,T=!1;const x=b.map((t=>t.name.slice(0,-5))),I=[];for(const t of b)try{const e=JSON.parse(yield Bt.files.readAsText(t));I.push(e.key)}catch(t){console.error(t)}const S=e.Func.find({tags:[l]}),E={};S.forEach((t=>{var e;E[null!==(e=t.friendlyName)&&void 0!==e?e:t.name]=t}));const N=o.choiceInput("Submit function",null,[null,...Object.keys(E)]);N.nullable=!0,N.value=null!==(s=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==s?s:null,N.setTooltip("Select function to be called upon submitting");const _=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),F=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"});function B(){var t,e,i,n;if(""===O.value||x.includes(null!==(e=null===(t=O.value)||void 0===t?void 0:t.trim())&&void 0!==e?e:"")){const t=null!==(i=O.input.offsetLeft)&&void 0!==i?i:0,e=null!==(n=O.input.offsetWidth)&&void 0!==n?n:0;_.style.marginLeft=`${t}px`,_.style.width=`${e}px`,_.style.opacity="100%",_.style.borderTop="1px solid red",C=!0}else _.style.borderTop="none",_.style.opacity="0%",C=!1}const O=o.stringInput("Name",null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",B);function P(){var t,e,i,n;if(""===k.value||I.includes(null!==(e=null===(t=k.value)||void 0===t?void 0:t.trim())&&void 0!==e?e:"")){const t=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,e=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;F.style.marginLeft=`${t}px`,F.style.width=`${e}px`,F.style.borderTop="1px solid red",F.style.opacity="100%",T=!0}else F.style.opacity="0%",F.style.borderTop="none",T=!1}const k=o.stringInput("Key",null!==(c=null==n?void 0:n.key)&&void 0!==c?c:"",P);k.setTooltip("Template key used for campaign prefix"),O.setTooltip("Template name"),O.root.style.borderBottom="none",k.root.style.borderBottom="none",_.style.opacity="0%",F.style.opacity="0%";let V=null;const L={compute:{descriptors:{enabled:!0,args:null!==(p=null===(d=null===(u=null==n?void 0:n.compute)||void 0===u?void 0:u.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[]},functions:null!==(v=null===(m=null==n?void 0:n.compute)||void 0===m?void 0:m.functions)&&void 0!==v?v:[]}},j=yield Q(i,(t=>{V=t}),(()=>null),L,!1);j.root.classList.add("hit-triage-new-template-functions-input");const D=it(null==n?void 0:n.campaignFields),H=function(t){const i=[e.Property.fromOptions({name:"Name",type:e.TYPE.STRING})],n=new X(i,t?t.map((t=>({Name:t}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((t=>{o={}})),n.onAddingItemChanged.subscribe((t=>{t&&(o=t.item)})),{getFields:function(){const t=n.items.filter((t=>t.Name)).map((t=>t.Name));return o.Name&&""!==o.Name&&t.push(o.Name),t},fieldsDiv:n.root}}(null==n?void 0:n.stages),M=o.divV([o.divV([O,_]),o.divV([k,F]),D.fieldsDiv]),R=o.h2("Stages");o.tooltip.bind(R,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const U=o.h2("Compute");o.tooltip.bind(U,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const $=o.div([o.h2("Details"),M,R,H.fieldsDiv,U,j.root,o.h2("Submit"),N.root],"ui-form"),q=o.buttonsInput([]);$.appendChild(q);const Y=null!==(y=null===(g=q.getElementsByClassName("ui-input-editor"))||void 0===g?void 0:g[0])&&void 0!==y?y:q,W=new Promise((t=>{const e=o.button(A,(()=>t()));Y.appendChild(e)})),G=new Promise((e=>{const i=o.bigButton(w,(()=>function(){var i,n,o,a,s;return bt(this,void 0,void 0,(function*(){if(B(),P(),j.okProxy(),C||!O.value||""===O.value)return void t.shell.error("Template name is empty or already exists");if(T||!k.value||""===k.value)return void t.shell.error("Template key is empty or already exists");const r=N.value?E[N.value]:void 0,l=Object.assign({name:O.value,key:k.value,campaignFields:D.getFields(),stages:H.getFields(),compute:{descriptors:{enabled:!!(null===(i=null==V?void 0:V.descriptors)||void 0===i?void 0:i.length),args:null!==(n=null==V?void 0:V.descriptors)&&void 0!==n?n:[]},functions:Object.entries(null!==(o=null==V?void 0:V.externals)&&void 0!==o?o:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(a=null==V?void 0:V.scripts)&&void 0!==a?a:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(s=null==V?void 0:V.queries)&&void 0!==s?s:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))}},r?{submit:{fName:r.name,package:r.package.name}}:{});var c;c=l,Bt.files.writeAsText(`Hit Design/templates/${c.name}.json`,JSON.stringify(c)),t.shell.info("Template created successfully"),e(l)}))}()));Y.appendChild(i)}));return{root:$,template:G,cancelPromise:W}}))}var Ct=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class At extends ot{constructor(e){super(e),this.name="Hit Design",t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(Bt.webRoot+"README_HD.md"),this.checkCampaign().then((t=>{this.app.campaign=t,this.init()}))}onActivated(){t.shell.windows.showHelp=!0,t.shell.windows.help.showHelp(Bt.webRoot+"README_HD.md")}init(t){return Ct(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const e=o.h1(T),i=o.h1(x,{style:{marginLeft:"10px"}}),n=rt.appHeader({iconPath:Bt.webRoot+"/images/icons/hit-design-icon.png",learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/packages/HitTriage/README_HD.md",description:"- Configure your own workflow using the template editor\n- Sketch molecules in the molecular spreadsheet\n- Annotate and share ideas with the team\n- Calculate different molecular properties\n- Save campaigns and continue from where you left off\n- Submit final selection to the function of your choice"}),a=o.div(),s=o.divH([]),r=o.div([s,a],"ui-form"),l=yield this.getCampaignsTable();z()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,e],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(a,s,t),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,e,i){var n;return Ct(this,void 0,void 0,(function*(){const a=(yield Bt.files.list("Hit Design/templates")).filter((t=>t.name.endsWith(".json"))).map((t=>t.name.slice(0,-5)));i&&!a.includes(i.name)&&a.push(i.name);let s=null;const r=()=>Ct(this,void 0,void 0,(function*(){const e=l.value,n=i&&i.name===e?i:JSON.parse(yield Bt.files.readAsText("Hit Design/templates/"+e+".json"));s=n;const o=yield this.getNewCampaignAccordeon(n);z()(t).empty(),t.appendChild(o)})),l=o.choiceInput("Template",null!==(n=null==i?void 0:i.name)&&void 0!==n?n:a[0],a,(()=>Ct(this,void 0,void 0,(function*(){yield r()}))));l.root.style.width="100%";const c=o.icons.add((()=>{this.createNewTemplate()}),y),u=o.icons.copy((()=>{s&&this.createNewTemplate(s)}),"Clone template");c.style.color="#2083d5",l.addOptions(u),l.addOptions(c),yield r(),z()(e).empty(),e.appendChild(l.root)}))}checkCampaign(t){var e;return Ct(this,void 0,void 0,(function*(){const i=location.search,n=new URLSearchParams(i);if(!n.has(s)&&!t)return;const o=null!=t?t:n.get(s);if(!(yield Bt.files.exists(`Hit Design/campaigns/${o}/campaign.json`)))return;const a=JSON.parse(yield Bt.files.readAsText(`Hit Design/campaigns/${o}/campaign.json`));a&&(this.app.campaign=a);const r=null!==(e=a.template)&&void 0!==e?e:JSON.parse(yield Bt.files.readAsText(`Hit Design/templates/${a.templateName}.json`));return yield this.app.setTemplate(r,o),t&&R(s,t),a.template=r,a}))}getCampaignsTable(){return Ct(this,void 0,void 0,(function*(){const t=yield W("Hit Design",this.deletedCampaigns),e=o.table(Object.values(t),(t=>[o.link(t.name,(()=>this.setCampaign(t.name)),"",""),t.createDate,t.rowCount,t.status,o.icons.delete((()=>Ct(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${t.name}?`)).onOK((()=>Ct(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",t.name),this.deletedCampaigns.push(t.name),yield this.init()})))).show()}))),"Delete campaign")]),["Name","Created","Molecules","Status",""]);return e.style.color="var(--grey-5)",e.style.marginLeft="24px",e}))}setCampaign(t){return Ct(this,void 0,void 0,(function*(){const e=yield this.checkCampaign(t);this.app.campaign=e}))}getNewCampaignAccordeon(i){return Ct(this,void 0,void 0,(function*(){const{root:n,promise:a,cancelPromise:s}=function(i){var n,a;const s=e.DataFrame.create(1),r=s.columns.addNew(d,e.TYPE.STRING);r.semType=e.SEMTYPE.MOLECULE,r.setTag(e.TAGS.UNITS,e.UNITS.Molecule.SMILES),r.set(0,null),(null===(n=null==i?void 0:i.stages)||void 0===n?void 0:n.length)>0&&s.columns.addNew(u,e.TYPE.STRING).set(0,i.stages[0]);const l=s.columns.addNew(p,e.TYPE.STRING);l.set(0,ft(l));const c=i.campaignFields.map((t=>t.type===e.SEMTYPE.MOLECULE?Object.assign(Object.assign({},t),{type:"String",semtype:e.SEMTYPE.MOLECULE}):t)).map((t=>e.Property.fromOptions(Object.assign({name:t.name,type:G[t.type],nullable:!t.required},t.semtype?{semType:t.semtype}:{})))),m={},h=o.input.form(m,c);h.classList.remove("ui-form");const f=o.div([...(null===(a=i.campaignFields)||void 0===a||a.length,[]),h]),v=o.buttonsInput([]);return f.appendChild(v),{promise:new Promise((e=>{const n=o.bigButton(b,(()=>{for(const e of i.campaignFields)if(e.required&&(!m[e.name]||""===m[e.name]))return void t.shell.error(`Field '${e.name}' is required`);e({df:s,campaignProps:m})}));v.appendChild(n)})),root:f,cancelPromise:new Promise((t=>{o.button(A,(()=>t()))}))}}(i);return a.then((t=>Ct(this,void 0,void 0,(function*(){this.app.dataFrame=t.df,yield this.app.setTemplate(i),this.app.campaignProps=t.campaignProps,this.app.saveCampaign(void 0,!1)})))),s.then((()=>{this.init()})),n}))}createNewTemplate(i){return Ct(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield wt(this.app,i),a=new e.ViewBase,s=t.shell.v;a.name="New Template",a.root.appendChild(n.root),a.parentCall=this.app.parentCall,t.shell.addView(a),a.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:r}=U(a,"Hit Design",y,(()=>Ct(this,void 0,void 0,(function*(){t.shell.v=s,a.close()}))));n.template.then((e=>Ct(this,void 0,void 0,(function*(){yield this.init(e),a.close(),$(a),t.shell.v=s,r.unsubscribe()})))),n.cancelPromise.then((()=>Ct(this,void 0,void 0,(function*(){r.unsubscribe(),a.close(),t.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class Tt extends ot{constructor(t){super(t),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){var i,n,o,a,s;return n=this,o=void 0,s=function*(){const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=e.Func.find({name:n.fName,package:n.package})[0];if(!o)return void t.shell.error(`Function ${n.fName} not found.`);const a=e.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:a,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),t.shell.info("Submitted successfully.")},new((a=void 0)||(a=Promise))((function(t,e){function i(t){try{l(s.next(t))}catch(t){e(t)}}function r(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 a?n:new a((function(t){t(n)}))).then(i,r)}l((s=s.apply(n,o||[])).next())}))}}var xt=i(143),It={};It.styleTagTransform=L(),It.setAttributes=O(),It.insert=F().bind(null,"head"),It.domAPI=N(),It.insertStyleElement=k(),S()(xt.Z,It),xt.Z&&xt.Z.locals&&xt.Z.locals;class St extends ot{constructor(t){super(t),this.v=null,this.name="Progress Tracker"}render(){return i=this,n=void 0,s=function*(){return new Promise((i=>{var n,a,s;this.app.dataFrame.columns.names().forEach((t=>{t.startsWith("~")&&this.app.dataFrame.columns.remove(t)}));const r=null===(n=this.app.campaign)||void 0===n?void 0:n.tilesViewerFormSketch;let l=null;if(r&&r.length>0)try{l=JSON.parse(r)}catch(t){console.error("Failed to parse sketch state string",t)}let c=!0;if(!this.v||this.v.isDetached){c=!1,this.v=e.Viewer.fromType(e.VIEWER.TILE_VIEWER,this.app.dataFrame,Object.assign({lanesColumnName:u,lanes:null!==(s=null===(a=this.app.template)||void 0===a?void 0:a.stages)&&void 0!==s?s:[]},l?{sketchState:l}:{}));const t=this.v.getOptions();l&&(t.look.sketchState=l),this.v.setOptions(t),this.v.copyViewersLook(this.v)}c?i():(o.empty(this.root),this.root.appendChild(this.v.root),this.v.root.style.height="100%",this.v.root.style.width="100%",setTimeout((()=>{var e,n,a;null===(n=null===(e=this.v)||void 0===e?void 0:e.view)||void 0===n||n._onAdded();const s=null===(a=t.shell.v)||void 0===a?void 0:a.getRibbonPanels();if(s){if(q(s))return void i();const e=o.bigButton("Design view",(()=>{const e=t.shell.view(this.app.designViewName);e&&(t.shell.v=e)})),n=o.bigButton("Submit",(()=>{var t;const e=null===(t=this.app._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.app.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this.app._submitView)||void 0===e||e.submit(),t.close()})),t.show()}}));n.classList.add("hit-design-submit-button"),s.push([e,n]),t.shell.v.setRibbonPanels(s)}i()}),5))}))},new((a=void 0)||(a=Promise))((function(t,e){function o(t){try{l(s.next(t))}catch(t){e(t)}}function r(t){try{l(s.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof a?i:new a((function(t){t(i)}))).then(o,r)}l((s=s.apply(i,n||[])).next())}));var i,n,a,s}onActivated(){this.render()}get sketchStateString(){if(!this.v)return null;const t=this.v.props.sketchState;return t&&"object"==typeof t?JSON.stringify(t):null}}var Et=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};class Nt extends pt{constructor(i){super(i),this._tilesViewTab=null,this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=d,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new At(this),this.multiView=new e.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((t=>{this.multiView.currentView instanceof ot&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=this.multiView,t.events.onCurrentViewChanged.subscribe((()=>Et(this,void 0,void 0,(function*(){var e,i,n,o,s,r,l,c,u;try{if((null===(e=t.shell.v)||void 0===e?void 0:e.name)===this.currentDesignViewId||(null===(i=t.shell.v)||void 0===i?void 0:i.name)===this.currentTilesViewId){if(t.shell.windows.showHelp=!1,this.setBaseUrl(),R(a,null!==(s=null!==(n=this._campaignId)&&void 0!==n?n:null===(o=this._campaign)||void 0===o?void 0:o.name)&&void 0!==s?s:""),this.currentTilesViewId&&(null===(r=t.shell.v)||void 0===r?void 0:r.name)===this.currentTilesViewId)yield null===(l=this._tilesView)||void 0===l?void 0:l.render();else{const t=null===(c=this._tilesView)||void 0===c?void 0:c.sketchStateString;t&&""!=t&&this.campaign&&(this.campaign.tilesViewerFormSketch=t)}const{sub:e}=U(t.shell.v,"Hit Design",null===(u=t.shell.v)||void 0===u?void 0:u.name,(()=>{var i,n;t.shell.v=this.mainView,null===(i=this._tilesView)||void 0===i||i.close(),null===(n=this._designView)||void 0===n||n.close(),this._infoView.init(),e.unsubscribe()}))}}catch(t){console.error(t)}}))))}get infoView(){return this._infoView}setTemplate(i,n){var o,r,l,c,u,p,m,h,f,v,g,y,b;return Et(this,void 0,void 0,(function*(){if(n){const e="System.AppData/HitTriage/Hit Design/campaigns";this._filePath=null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.savePath)&&void 0!==l?l:`${e}/${n}/enriched_table.csv`,this.dataFrame=yield t.dapi.files.readCsv(this._filePath),(null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);i&&e&&(i.semType=e)})),(null===(u=this._campaign)||void 0===u?void 0:u.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach((([t,e])=>{const i=this.dataFrame.columns.byName(t);if(i&&i.type!==e)try{this.dataFrame.changeColumnType(t,e)}catch(t){console.error(t)}}))}else(null===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&t.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName("Hit Design/campaigns",i.key),R(s,n),this._filePath=`System.AppData/HitTriage/Hit Design/campaigns/${n}/enriched_table.csv`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(m=null===(p=this.dataFrame.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:d,this._dfName=null!==(h=(b=this.dataFrame).name)&&void 0!==h?h:b.name=n,this._campaignId=n,this.template=i,null!==(f=this._submitView)&&void 0!==f||(this._submitView=new Tt(this)),t.shell.windows.showHelp=!1,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const w=this.designView;this.currentDesignViewId=w.name,this.setBaseUrl(),R(a,null!==(y=null!==(v=this._campaignId)&&void 0!==v?v:null===(g=this._campaign)||void 0===g?void 0:g.name)&&void 0!==y?y:""),this.campaign&&(this.campaign.template=i)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var t,i,n,o;return null!==(t=this._molColName)&&void 0!==t?t:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(e.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:d}get campaign(){return this._campaign}set campaign(t){this._campaign=t}getDesignView(){var i,n,a,s,r,l;const c=[],m=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((t=>!t&&""===t)),v=t.shell.addTableView(this.dataFrame);this._designViewName=null!==(a=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==a?a:this._designViewName,v.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList(),setTimeout((()=>Et(this,void 0,void 0,(function*(){var i,n;if(v._onAdded(),yield new Promise((t=>setTimeout(t,1e3))),null===(i=this._campaign)||void 0===i?void 0:i.layout)try{const t=e.ViewLayout.fromViewState(this._campaign.layout);v.loadLayout(t)}catch(t){console.error(t)}m&&t.functions.call("Chem:editMoleculeCell",{cell:v.grid.cell(this._molColName,0)}),c.push(this.dataFrame.onRowsAdded.subscribe((()=>{var e,i;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(e=this.template.stages)||void 0===e?void 0:e.length)>0)for(let t=0;t<this.dataFrame.rowCount;t++){const e=this.dataFrame.col(u).get(t);e&&""!==e&&!(null===(i=this.dataFrame.col(u))||void 0===i?void 0:i.isNone(t))||this.dataFrame.set(u,t,this.template.stages[0])}let n=null;for(let t=0;t<this.dataFrame.rowCount;t++){const e=v.grid.cell(this.molColName,t);e&&(""!==e.cell.value&&null!==e.cell.value||(n=e))}n&&t.functions.call("Chem:editMoleculeCell",{cell:n})}catch(t){console.error(t)}}))),this.dataFrame&&c.push(null===(n=this.dataFrame)||void 0===n?void 0:n.onRowsRemoved.subscribe((()=>{try{this.processedValues=this.dataFrame.getCol(this.molColName).toList()}catch(t){console.error(t)}}))),c.push(t.events.onContextMenu.subscribe((i=>{var n,o,a,s,r;try{const t=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!t)return;if((null==t?void 0:t.type)!==e.VIEWER.GRID)return;if(!t.tableView||t.tableView.id!==v.id)return;if((null===(s=null===(a=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName)return;const l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.menu;if(!l)return;l.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),l.item("Duplicate molecule",(()=>{var t,e,n,o;try{this.dataFrame.rows.addNew(null,!0);let a=null;for(let t=0;t<this.dataFrame.rowCount;t++){const e=v.grid.cell(this.molColName,t);e&&(""!==e.cell.value&&null!==e.cell.value||(a=e))}a&&(a.cell.value=null!==(o=null===(n=null===(e=null===(t=null==i?void 0:i.args)||void 0===t?void 0:t.item)||void 0===e?void 0:e.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(t){console.error(t)}}))}catch(e){t.log.error(e)}}))),c.push(v.grid.onCellValueEdited.subscribe((i=>Et(this,void 0,void 0,(function*(){var n,o,a,s;try{if((null===(n=i.tableColumn)||void 0===n?void 0:n.name)===u)return void(yield this.saveCampaign(void 0,!1));if((null===(o=i.tableColumn)||void 0===o?void 0:o.name)!==this.molColName)return;const r=i.cell.value,l=i.tableRowIndex;(null===(a=this.dataFrame.col(p))||void 0===a?void 0:a.get(l))&&""!==(null===(s=this.dataFrame.col(p))||void 0===s?void 0:s.get(l))||this.dataFrame.col(p).set(l,ft(this.dataFrame.col(p)),!1);const c=this.template.compute;if(!r||""===r)return;const m=yield function(i,n,o,a=[],s=[]){return ht(this,void 0,void 0,(function*(){const r=e.TaskBarProgressIndicator.create("Calculating ..."),l=t.chem.convert(i,t.chem.Notation.Unknown,t.chem.Notation.Smiles),c=e.Column.fromStrings(d,[l]),u=e.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes(),n.length&&(yield t.chem.descriptors(u,c.name,n));for(const t of o)try{const i=t.args,n=e.Func.find({package:t.package,name:t.name});if(!n.length||!n[0]){console.warn(`Function ${t.name} from package ${t.package} is not found`);continue}const o=n[0],a=o.inputs[0].name,s=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[a]:u,[s]:c.name}))}catch(t){console.error(t);continue}for(const e of a){const i=e.args;try{const n=yield t.dapi.scripts.find(e.id);if(n){const t=n.inputs[0].name,e=n.inputs[1].name,o=yield n.apply(Object.assign(Object.assign({},i),{[t]:u,[e]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===n.language)for(const t of o.columns)t.name=u.columns.getUnusedName(t.name),u.columns.add(t)}}catch(t){console.error(t)}}for(const e of s){const i=e.args;try{const n=yield t.dapi.queries.find(e.id);if(n){const t=n.inputs[0].name,e=[l],o=yield n.apply(Object.assign(Object.assign({},i),{[t]:e}));if(!o||0===o.rowCount)continue;yield Y(u,d,o)}}catch(t){console.error(t)}}return r.close(),u}))}(r,c.descriptors.args,c.functions,c.scripts,c.queries);for(const t of m.columns.toList())t.name!==d&&(this.dataFrame.columns.contains(t.name)||(this.dataFrame.columns.addNew(t.name,t.type).semType=t.semType),this.dataFrame.col(t.name).set(l,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}catch(t){console.error(t)}})))));const o=t.events.onViewRemoved.subscribe((t=>{t.id===v.id&&(c.forEach((t=>t.unsubscribe())),o.unsubscribe())}))}))),300);const g=null==v?void 0:v.getRibbonPanels();if(g&&!q(g)){const e=()=>Et(this,void 0,void 0,(function*(){var t;Q(this,(t=>Et(this,void 0,void 0,(function*(){var e,i,n,a,s,r,l,c,u,d;const p=this.template.compute.descriptors.args,m=this.template.compute.functions,g=null!==(e=this.template.compute.scripts)&&void 0!==e?e:[],y=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],b=t.descriptors,w={descriptors:{enabled:!!(null===(n=null==t?void 0:t.descriptors)||void 0===n?void 0:n.length),args:null!==(a=null==t?void 0:t.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==t?void 0:t.externals)&&void 0!==s?s:{}).map((([t,e])=>{const i=t.split(":");return{name:i[1],package:i[0],args:e}})),scripts:Object.entries(null!==(r=null==t?void 0:t.scripts)&&void 0!==r?r:{}).filter((([t,e])=>t.startsWith(h)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}})),queries:Object.entries(null!==(l=null==t?void 0:t.queries)&&void 0!==l?l:{}).filter((([t,e])=>t.startsWith(f)&&3===t.split(":").length)).map((([t,e])=>{var i,n;const o=t.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:e}}))};this.template.compute=w,this.campaign.template=this.template;const C=b.filter((t=>!p.includes(t))),A={};Object.entries(null!==(c=null==t?void 0:t.externals)&&void 0!==c?c:{}).filter((([t,e])=>{const i=m.find((e=>`${e.package}:${e.name}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{A[t]=e}));const T={};Object.entries(null!==(u=null==t?void 0:t.scripts)&&void 0!==u?u:{}).filter((([t,e])=>{const i=g.find((e=>`HTScript:${e.name}:${e.id}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{T[t]=e}));const x={};Object.entries(null!==(d=null==t?void 0:t.queries)&&void 0!==d?d:{}).filter((([t,e])=>{const i=y.find((e=>`HTQuery:${e.name}:${e.id}`===t));return!i||!Object.entries(e).every((([t,e])=>i.args[t]===e))})).forEach((([t,e])=>{x[t]=e})),o.setUpdateIndicator(v.grid.root,!0);try{yield vt({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(v.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(t=this.campaign)||void 0===t?void 0:t.template,!0)})),i=o.iconFA("wrench",e,"Calculate additional properties"),n=o.icons.add((()=>{var t;null===(t=this.dataFrame)||void 0===t||t.rows.addNew(null,!0)}),"Add new row"),a=o.bigButton("Progress tracker",(()=>{var e;this.currentTilesViewId&&t.shell.view(this.currentTilesViewId)&&(null===(e=t.shell.view(this.currentTilesViewId))||void 0===e||e.close()),this._tilesView=new St(this),this._tilesView.parentCall=this.parentCall,this._tilesViewTab=t.shell.addView(this._tilesView),this.currentTilesViewId=this._tilesViewTab.name,this._tilesView.onActivated(),t.shell.v=t.shell.view(this.currentTilesViewId)})),c=o.bigButton("Submit",(()=>{var t;const e=null===(t=this._submitView)||void 0===t?void 0:t.render();if(e){const t=o.dialog("Submit");t.add(e),t.addButton("Save",(()=>{this.saveCampaign(),t.close()})),t.addButton("Submit",(()=>{var e;null===(e=this._submitView)||void 0===e||e.submit(),t.close()})),t.show()}}));c.classList.add("hit-design-submit-button");const u=[c];null!==(l=null===(r=null===(s=this.template)||void 0===s?void 0:s.stages)||void 0===r?void 0:r.length)&&void 0!==l&&l&&u.unshift(a),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),u.unshift(i),u.unshift(n),g.push(u),v.setRibbonPanels(g)}return v.parentCall=this.parentCall,v}getSummary(){var i,n,a,s;const r=()=>{var t,e;const i=this._filePath.indexOf(null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.name);return-1===i?this._filePath:this._filePath.substring(0,i-1)},l=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);return this.template&&this.template.campaignFields&&Object.entries(l).forEach((([i,n])=>{const o=this.template.campaignFields.find((t=>t.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?l[i]=new Date(n).toLocaleDateString():n.date?l[i]=new Date(n.date).toLocaleDateString():l[i]=n:o&&o.type===e.SEMTYPE.MOLECULE&&n&&(l[i]=t.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(s=null===(a=this.template)||void 0===a?void 0:a.name)&&void 0!==s?s:"Molecules","File path":(()=>{const e=o.icons.edit((()=>{const i=r(),s=o.stringInput("Path",i),l=s.root.getElementsByTagName("label").item(0);l&&l.remove(),s.root.style.width="100%";const c=o.button("Save",(()=>Et(this,void 0,void 0,(function*(){const i=yield function(){return Et(this,void 0,void 0,(function*(){const e=s.value;return e&&""!==e.trim()?!!(yield t.dapi.files.exists(e))||(t.shell.error("Given folder does not exist"),!1):(t.shell.error("Path can not be empty"),!1)}))}();if(!i)return;const l=s.value;l.endsWith("/")?this._filePath=`${l}${this.campaignId}/enriched_table.csv`:this._filePath=`${l}/${this.campaignId}/enriched_table.csv`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(a);const c=r();n=o.link(c,(()=>{var t,e,i;return this.download(this.dataFrame,null!==(i=null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.name)&&void 0!==i?i:"Molecules")}),C),a.appendChild(n),a.appendChild(e)})))),u=o.button("Cancel",(()=>{o.empty(a),a.appendChild(n),a.appendChild(e)}));o.empty(a),s.addOptions(u),s.addOptions(c),a.appendChild(s.root)}),"Edit file path");e.style.marginLeft="5px";const i=r();let n=o.link(i,(()=>{var t,e,i;return this.download(this.dataFrame,null!==(i=null!==(t=this.campaignId)&&void 0!==t?t:null===(e=this._campaign)||void 0===e?void 0:e.name)&&void 0!==i?i:"Molecules")}),C);const a=o.divH([n,e],{style:{alignItems:"center"}});return a})()},l),{"Number of molecules":(this.dataFrame.rowCount-this._extraStageColsCount).toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((t=>t.name))].filter((t=>t&&""!==t.trim())).join(", ")})}saveCampaign(i,n=!0){var o,a,s,r,l,c,u,d,m,h,f,v;return Et(this,void 0,void 0,(function*(){const g=this.campaignId,y=this.template.name,b=this.dataFrame,w=g,C={};b.columns.toList().forEach((t=>C[t.name]=t.semType));const A={};b.columns.toList().forEach((t=>A[t.name]=t.type));const T=null!==(r=null!==(a=null===(o=this._tilesView)||void 0===o?void 0:o.sketchStateString)&&void 0!==a?a:null===(s=this.campaign)||void 0===s?void 0:s.tilesViewerFormSketch)&&void 0!==r?r:void 0,x={name:w,templateName:y,status:null!==(c=null!=i?i:null===(l=this.campaign)||void 0===l?void 0:l.status)&&void 0!==c?c:"In Progress",createDate:null!==(d=null===(u=this.campaign)||void 0===u?void 0:u.createDate)&&void 0!==d?d:M(new Date),campaignFields:null!==(h=null===(m=this.campaign)||void 0===m?void 0:m.campaignFields)&&void 0!==h?h:this.campaignProps,columnSemTypes:C,rowCount:null!==(v=null===(f=b.col(p))||void 0===f?void 0:f.toList().filter((t=>"StageDefiningRow"!==t)).length)&&void 0!==v?v:0,filteredRowCount:b.filter.trueCount,savePath:this._filePath,columnTypes:A,tilesViewerFormSketch:T};console.log(this._filePath);const I=e.DataFrame.fromColumns(b.columns.toList().filter((t=>!t.name.startsWith("~")))).toCsv();yield t.dapi.files.writeAsText(this._filePath,I);const S=this._designView.saveLayout();return S?x.layout=S.viewState:t.shell.warning("Layout cound not be saved"),x.template=this.template,yield Bt.files.writeAsText(`Hit Design/campaigns/${g}/campaign.json`,JSON.stringify(x)),n&&t.shell.info("Campaign saved successfully."),this.campaign=x,x}))}}class _t extends e.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(t,e,i,n,o,a,s){if(a.gridRow<0||!a.cell.value)return;const r=a.cell.value,l=new Image(n-2,o-2);l.src="data:image/png;base64,"+r,l.onload=function(){t.drawImage(l,e+2,i+2,n-2,o-2)}}}var Ft=function(t,e,i,n){return new(i||(i=Promise))((function(o,a){function s(t){try{l(n.next(t))}catch(t){a(t)}}function r(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,r)}l((n=n.apply(t,e||[])).next())}))};const Bt=new e.Package;function Ot(){return Ft(this,void 0,void 0,(function*(){const e=t.functions.getCurrentCall();return new yt(e).multiView}))}function Pt(){return Ft(this,void 0,void 0,(function*(){const e=t.functions.getCurrentCall();return new Nt(e).multiView}))}function kt(){return Ft(this,void 0,void 0,(function*(){const e=t.data.demo.molecules(100);return e.name="100 Molecules",e}))}function Vt(){return Ft(this,void 0,void 0,(function*(){const e=t.data.demo.molecules(5e3);return e.name="5000 Molecules",e}))}function Lt(e){return Ft(this,void 0,void 0,(function*(){const i=t.data.demo.molecules(e);return i.name="Variable Molecules number",i}))}function jt(e,i){return Ft(this,void 0,void 0,(function*(){t.shell.info(e.rowCount),t.shell.info(i)}))}function Dt(){return new _t}})(),hittriage=n})();
|
|
2
2
|
//# sourceMappingURL=package.js.map
|