@datagrok/hit-triage 1.9.2 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.js CHANGED
@@ -1,2 +1,2 @@
1
- var hittriage;(()=>{var e={56:(e,t,i)=>{"use strict";e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},72:e=>{"use strict";var t=[];function i(e){for(var i=-1,n=0;n<t.length;n++)if(t[n].identifier===e){i=n;break}return i}function n(e,n){for(var a={},r=[],s=0;s<e.length;s++){var l=e[s],d=n.base?l[0]+n.base:l[0],c=a[d]||0,u="".concat(d," ").concat(c);a[d]=c+1;var p=i(u),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,n);n.byIndex=s,t.splice(s,0,{identifier:u,updater:h,references:1})}r.push(u)}return r}function o(e,t){var i=t.domAPI(t);return i.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;i.update(e=t)}else i.remove()}}e.exports=function(e,o){var a=n(e=e||[],o=o||{});return function(e){e=e||[];for(var r=0;r<a.length;r++){var s=i(a[r]);t[s].references--}for(var l=n(e,o),d=0;d<a.length;d++){var c=i(a[d]);0===t[c].references&&(t[c].updater(),t.splice(c,1))}a=l}}},113: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))}}},233:e=>{!function(){"use strict";var t=document,i=window,n=t.documentElement,o=t.createElement.bind(t),a=o("div"),r=o("table"),s=o("tbody"),l=o("tr"),d=Array.isArray,c=Array.prototype,u=c.concat,p=c.filter,m=c.indexOf,h=c.map,v=c.push,f=c.slice,g=c.some,y=c.splice,w=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,b=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,C=/<.+>/,A=/^\w+$/;function T(e,t){var i,n=!!(i=t)&&11===i.nodeType;return e&&(n||F(t)||_(t))?!n&&b.test(e)?t.getElementsByClassName(e.slice(1).replace(/\\/g,"")):!n&&A.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e):[]}var S=function(){function e(e,n){if(e){if(N(e))return e;var o=e;if(L(e)){var a=n||t;if(!(o=w.test(e)&&F(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?Z(e):N(a)?a.find(e):L(a)?I(a).find(e):T(e,a)))return}else if(P(e))return this.ready(e);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var r=0,s=this.length;r<s;r++)this[r]=o[r]}}return e.prototype.init=function(t,i){return new e(t,i)},e}(),x=S.prototype,I=x.init;function N(e){return e instanceof S}function E(e){return!!e&&e===e.window}function F(e){return!!e&&9===e.nodeType}function _(e){return!!e&&1===e.nodeType}function P(e){return"function"==typeof e}function L(e){return"string"==typeof e}function O(e){return void 0===e}function V(e){return null===e}function k(e){return!isNaN(parseFloat(e))&&isFinite(e)}function B(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function M(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(B(e))for(var o=Object.keys(e),a=(n=0,o.length);n<a;n++){var r=o[n];if(!1===t.call(e[r],r,e[r]))return e}else for(n=0,a=e.length;n<a;n++)if(!1===t.call(e[n],n,e[n]))return e;return e}function D(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i="boolean"==typeof e[0]&&e.shift(),n=e.shift(),o=e.length;if(!n)return{};if(!o)return D(i,I,n);for(var a=0;a<o;a++){var r=e[a];for(var s in r)i&&(d(r[s])||B(r[s]))?(n[s]&&n[s].constructor===r[s].constructor||(n[s]=new r[s].constructor),D(i,n[s],r[s])):n[s]=r[s]}return n}I.fn=I.prototype=x,x.length=0,x.splice=y,"function"==typeof Symbol&&(x[Symbol.iterator]=c[Symbol.iterator]),I.isWindow=E,I.isFunction=P,I.isArray=d,I.isNumeric=k,I.isPlainObject=B,I.each=M,x.each=function(e){return M(this,e)},x.empty=function(){return this.each(function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)})},I.extend=D,x.extend=function(e){return D(x,e)};var R=/\S+/g;function j(e){return L(e)&&e.match(R)||[]}function U(e,t,n){if(_(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function $(e,t){return parseInt(U(e,t),10)||0}function H(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"))}x.toggleClass=function(e,t){var i=j(e),n=!O(t);return this.each(function(e,o){_(o)&&M(i,function(e,i){n?t?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)})})},x.addClass=function(e){return this.toggleClass(e,!0)},x.removeAttr=function(e){var t=j(e);return this.each(function(e,i){_(i)&&M(t,function(e,t){i.removeAttribute(t)})})},x.attr=function(e,t){if(e){if(L(e)){if(arguments.length<2){if(!this[0]||!_(this[0]))return;var i=this[0].getAttribute(e);return V(i)?void 0:i}return O(t)?this:V(t)?this.removeAttr(e):this.each(function(i,n){_(n)&&n.setAttribute(e,t)})}for(var n in e)this.attr(n,e[n]);return this}},x.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},x.hasClass=function(e){return!!e&&g.call(this,function(t){return _(t)&&t.classList.contains(e)})},x.get=function(e){return O(e)?f.call(this):this[(e=Number(e))<0?e+this.length:e]},x.eq=function(e){return I(this.get(e))},x.first=function(){return this.eq(0)},x.last=function(){return this.eq(-1)},x.text=function(e){return O(e)?this.get().map(function(e){return _(e)||(t=e)&&3===t.nodeType?e.textContent:"";var t}).join(""):this.each(function(t,i){_(i)&&(i.textContent=e)})};var q={};function G(e){return"none"===U(e,"display")}function Y(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function W(e){return L(e)?function(t,i){return Y(i,e)}:P(e)?e:N(e)?function(t,i){return e.is(i)}:e?function(t,i){return i===e}:function(){return!1}}function J(e,t){return t?e.filter(t):e}x.filter=function(e){var t=W(e);return I(p.call(this,function(e,i){return t.call(e,i,e)}))},x.detach=function(e){return J(this,e).each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)}),this};var z=/^\s*<(\w+)[^>]*>/,K=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,Q={"*":a,tr:s,td:l,th:l,thead:r,tbody:r,tfoot:r};function Z(e){if(!L(e))return[];if(K.test(e))return[o(RegExp.$1)];var t=z.test(e)&&RegExp.$1,i=Q[t]||Q["*"];return i.innerHTML=e,I(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],a=P(t),r=n&&W(n),s=0,l=e.length;s<l;s++)if(a){var d=t(e[s]);d.length&&v.apply(o,d)}else for(var c=e[s][t];!(null==c||n&&r(-1,c));)o.push(c),c=i?c[t]:null;return o}function ee(e){return e.multiple&&e.options?X(p.call(e.options,function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled}),"value"):e.value||""}function te(e){return e.length>1?p.call(e,function(e,t,i){return m.call(i,e)===t}):e}I.parseHTML=Z,x.has=function(e){var t=L(e)?function(t,i){return T(e,i).length}:function(t,i){return i.contains(e)};return this.filter(t)},x.not=function(e){var t=W(e);return this.filter(function(i,n){return(!L(e)||_(n))&&!t.call(n,i,n)})},x.val=function(e){return arguments.length?this.each(function(t,i){var n=i.multiple&&i.options;if(n||Le.test(i.type)){var o=d(e)?h.call(e,String):V(e)?[]:[String(e)];n?M(i.options,function(e,t){t.selected=o.indexOf(t.value)>=0},!0):i.checked=o.indexOf(i.value)>=0}else i.value=O(e)||V(e)?"":e}):this[0]&&ee(this[0])},x.is=function(e){var t=W(e);return g.call(this,function(e,i){return t.call(e,i,e)})},I.guid=1,I.unique=te,x.add=function(e,t){return I(te(this.get().concat(I(e,t).get())))},x.children=function(e){return J(I(te(X(this,function(e){return e.children}))),e)},x.parent=function(e){return J(I(te(X(this,"parentNode"))),e)},x.index=function(e){var t=e?I(e)[0]:this[0],i=e?this:I(t).parent().children();return m.call(i,t)},x.closest=function(e){var t=this.filter(e);if(t.length)return t;var i=this.parent();return i.length?i.closest(e):t},x.siblings=function(e){return J(I(te(X(this,function(e){return I(e).parent().children().not(e)}))),e)},x.find=function(e){return I(te(X(this,function(t){return T(e,t)})))};var ie=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ne=/^$|^module$|\/(java|ecma)script/i,oe=["type","src","nonce","noModule"];function ae(e,t,i,a,r,s,l,d){return M(e,function(e,s){M(I(s),function(e,s){M(I(t),function(t,l){var d=i?l:s,c=i?e:t;!function(e,t,i,a,r){a?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),r&&function(e,t){var i=I(e);i.filter("script").add(i.find("script")).each(function(e,i){if(ne.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(ie,""),M(oe,function(e,t){i[t]&&(a[t]=i[t])}),t.head.insertBefore(a,null),t.head.removeChild(a)}})}(t,e.ownerDocument)}(i?s:l,c?d.cloneNode(!0):d,a,r,!c)},d)},l)},s),t}x.after=function(){return ae(arguments,this,!1,!1,!1,!0,!0)},x.append=function(){return ae(arguments,this,!1,!1,!0)},x.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(O(e))return this;var t=/<script[\s>]/.test(e);return this.each(function(i,n){_(n)&&(t?I(n).empty().append(e):n.innerHTML=e)})},x.appendTo=function(e){return ae(arguments,this,!0,!1,!0)},x.wrapInner=function(e){return this.each(function(t,i){var n=I(i),o=n.contents();o.length?o.wrapAll(e):n.append(e)})},x.before=function(){return ae(arguments,this,!1,!0)},x.wrapAll=function(e){for(var t=I(e),i=t[0];i.children.length;)i=i.firstElementChild;return this.first().before(t),this.appendTo(i)},x.wrap=function(e){return this.each(function(t,i){var n=I(e)[0];I(i).wrapAll(t?n.cloneNode(!0):n)})},x.insertAfter=function(e){return ae(arguments,this,!0,!1,!1,!1,!1,!0)},x.insertBefore=function(e){return ae(arguments,this,!0,!0)},x.prepend=function(){return ae(arguments,this,!1,!0,!0,!0,!0)},x.prependTo=function(e){return ae(arguments,this,!0,!0,!0,!1,!1,!0)},x.contents=function(){return I(te(X(this,function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes})))},x.next=function(e,t,i){return J(I(te(X(this,"nextElementSibling",t,i))),e)},x.nextAll=function(e){return this.next(e,!0)},x.nextUntil=function(e,t){return this.next(t,!0,e)},x.parents=function(e,t){return J(I(te(X(this,"parentElement",!0,t))),e)},x.parentsUntil=function(e,t){return this.parents(t,e)},x.prev=function(e,t,i){return J(I(te(X(this,"previousElementSibling",t,i))),e)},x.prevAll=function(e){return this.prev(e,!0)},x.prevUntil=function(e,t){return this.prev(t,!0,e)},x.map=function(e){return I(u.apply([],h.call(this,function(t,i){return e.call(t,i,t)})))},x.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},x.offsetParent=function(){return this.map(function(e,t){for(var i=t.offsetParent;i&&"static"===U(i,"position");)i=i.offsetParent;return i||n})},x.slice=function(e,t){return I(f.call(this,e,t))};var re=/-([a-z])/g;function se(e){return e.replace(re,function(e,t){return t.toUpperCase()})}x.ready=function(e){var i=function(){return setTimeout(e,0,I)};return"loading"!==t.readyState?i():t.addEventListener("DOMContentLoaded",i),this},x.unwrap=function(){return this.parent().each(function(e,t){if("BODY"!==t.tagName){var i=I(t);i.replaceWith(i.children())}}),this},x.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}}},x.position=function(){var e=this[0];if(e){var t="fixed"===U(e,"position"),i=t?e.getBoundingClientRect():this.offset();if(!t){for(var n=e.ownerDocument,o=e.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==e&&_(o)){var a=I(o).offset();i.top-=a.top+$(o,"borderTopWidth"),i.left-=a.left+$(o,"borderLeftWidth")}}return{top:i.top-$(e,"marginTop"),left:i.left-$(e,"marginLeft")}}};var le={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};x.prop=function(e,t){if(e){if(L(e))return e=le[e]||e,arguments.length<2?this[0]&&this[0][e]:this.each(function(i,n){n[e]=t});for(var i in e)this.prop(i,e[i]);return this}},x.removeProp=function(e){return this.each(function(t,i){delete i[le[e]||e]})};var de=/^--/;function ce(e){return de.test(e)}var ue={},pe=a.style,me=["webkit","moz","ms"],he={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 ve(e,t,i){return void 0===i&&(i=ce(e)),i||he[e]||!k(t)?t:"".concat(t,"px")}function fe(e,t){try{return e(t)}catch(e){return t}}x.css=function(e,t){if(L(e)){var i=ce(e);return e=function(e,t){if(void 0===t&&(t=ce(e)),t)return e;if(!ue[e]){var i=se(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));M("".concat(i," ").concat(me.join("".concat(n," "))).concat(n).split(" "),function(t,i){if(i in pe)return ue[e]=i,!1})}return ue[e]}(e,i),arguments.length<2?this[0]&&U(this[0],e,i):e?(t=ve(e,t,i),this.each(function(n,o){_(o)&&(i?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var n in e)this.css(n,e[n]);return this};var ge=/^\s+|\s+$/;function ye(e,t){var i=e.dataset[t]||e.dataset[se(t)];return ge.test(i)?i:fe(JSON.parse,i)}function we(e,t){var i=e.documentElement;return Math.max(e.body["scroll".concat(t)],i["scroll".concat(t)],e.body["offset".concat(t)],i["offset".concat(t)],i["client".concat(t)])}x.data=function(e,t){if(!e){if(!this[0])return;var i={};for(var n in this[0].dataset)i[n]=ye(this[0],n);return i}if(L(e))return arguments.length<2?this[0]&&ye(this[0],e):O(t)?this:this.each(function(i,n){!function(e,t,i){i=fe(JSON.stringify,i),e.dataset[se(t)]=i}(n,e,t)});for(var n in e)this.data(n,e[n]);return this},M([!0,!1],function(e,t){M(["Width","Height"],function(e,i){var n="".concat(t?"outer":"inner").concat(i);x[n]=function(n){if(this[0])return E(this[0])?t?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:F(this[0])?we(this[0],i):this[0]["".concat(t?"offset":"client").concat(i)]+(n&&t?$(this[0],"margin".concat(e?"Top":"Left"))+$(this[0],"margin".concat(e?"Bottom":"Right")):0)}})}),M(["Width","Height"],function(e,t){var i=t.toLowerCase();x[i]=function(n){if(!this[0])return O(n)?void 0:this;if(!arguments.length)return E(this[0])?this[0].document.documentElement["client".concat(t)]:F(this[0])?we(this[0],t):this[0].getBoundingClientRect()[i]-H(this[0],!e);var o=parseInt(n,10);return this.each(function(t,n){if(_(n)){var a=U(n,"boxSizing");n.style[i]=ve(i,o+("border-box"===a?H(n,!e):0))}})}});var be="___cd";x.toggle=function(e){return this.each(function(i,n){if(_(n)){var a=G(n);(O(e)?a:e)?(n.style.display=n[be]||"",G(n)&&(n.style.display=function(e){if(q[e])return q[e];var i=o(e);t.body.insertBefore(i,null);var n=U(i,"display");return t.body.removeChild(i),q[e]="none"!==n?n:"block"}(n.tagName))):a||(n[be]=U(n,"display"),n.style.display="none")}})},x.hide=function(){return this.toggle(!1)},x.show=function(){return this.toggle(!0)};var Ce="___ce",Ae={focus:"focusin",blur:"focusout"},Te={mouseenter:"mouseover",mouseleave:"mouseout"},Se=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function xe(e){return Te[e]||Ae[e]||e}function Ie(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Ne(e){return e[Ce]=e[Ce]||{}}function Ee(e,t){return!t||!g.call(t,function(t){return e.indexOf(t)<0})}function Fe(e,t,i,n,o){var a=Ne(e);if(t)a[t]&&(a[t]=a[t].filter(function(a){var r=a[0],s=a[1],l=a[2];if(o&&l.guid!==o.guid||!Ee(r,i)||n&&n!==s)return!0;e.removeEventListener(t,l)}));else for(t in a)Fe(e,t,i,n,o)}x.trigger=function(e,i){if(L(e)){var n=Ie(e),o=n[0],a=n[1],r=xe(o);if(!r)return this;var s=Se.test(r)?"MouseEvents":"HTMLEvents";(e=t.createEvent(s)).initEvent(r,!0,!0),e.namespace=a.join("."),e.___ot=o}e.___td=i;var l=e.___ot in Ae;return this.each(function(t,i){l&&P(i[e.___ot])&&(i["___i".concat(e.type)]=!0,i[e.___ot](),i["___i".concat(e.type)]=!1),i.dispatchEvent(e)})},x.off=function(e,t,i){var n=this;if(O(e))this.each(function(e,t){(_(t)||F(t)||E(t))&&Fe(t)});else if(L(e))P(t)&&(i=t,t=""),M(j(e),function(e,o){var a=Ie(o),r=a[0],s=a[1],l=xe(r);n.each(function(e,n){(_(n)||F(n)||E(n))&&Fe(n,l,s,t,i)})});else for(var o in e)this.off(o,e[o]);return this},x.remove=function(e){return J(this,e).detach().off(),this},x.replaceWith=function(e){return this.before(e).remove()},x.replaceAll=function(e){return I(e).replaceWith(this),this},x.on=function(e,t,i,n,o){var a=this;if(!L(e)){for(var r in e)this.on(r,t,i,e[r],o);return this}return L(t)||(O(t)||V(t)?t="":O(i)?(i=t,t=""):(n=i,i=t,t="")),P(n)||(n=i,i=void 0),n?(M(j(e),function(e,r){var s=Ie(r),l=s[0],d=s[1],c=xe(l),u=l in Te,p=l in Ae;c&&a.each(function(e,a){if(_(a)||F(a)||E(a)){var r=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Ee(d,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===c)||u&&e.relatedTarget&&a.contains(e.relatedTarget)))){var s=a;if(t){for(var l=e.target;!Y(l,t);){if(l===a)return;if(!(l=l.parentNode))return}s=l}Object.defineProperty(e,"currentTarget",{configurable:!0,get:function(){return s}}),Object.defineProperty(e,"delegateTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var m=n.call(s,e,e.___td);o&&Fe(a,c,d,t,r),!1===m&&(e.preventDefault(),e.stopPropagation())}};r.guid=n.guid=n.guid||I.guid++,function(e,t,i,n,o){var a=Ne(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,c,d,t,r)}})}),this):this},x.one=function(e,t,i,n){return this.on(e,t,i,n,!0)};var _e=/\r?\n/g,Pe=/file|reset|submit|button|image/i,Le=/radio|checkbox/i;x.serialize=function(){var e="";return this.each(function(t,i){M(i.elements||[i],function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Pe.test(i.type)||Le.test(i.type)&&!i.checked)){var n=ee(i);O(n)||M(d(n)?n:[n],function(t,n){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(_e,"\r\n")))}(i.name,n)})}})}),e.slice(1)},e.exports=I}()},314:e=>{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var i="",n=void 0!==t[5];return t[4]&&(i+="@supports (".concat(t[4],") {")),t[2]&&(i+="@media ".concat(t[2]," {")),n&&(i+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),i+=e(t),n&&(i+="}"),t[2]&&(i+="}"),t[4]&&(i+="}"),i}).join("")},t.i=function(e,i,n,o,a){"string"==typeof e&&(e=[[null,e,void 0]]);var r={};if(n)for(var s=0;s<this.length;s++){var l=this[s][0];null!=l&&(r[l]=!0)}for(var d=0;d<e.length;d++){var c=[].concat(e[d]);n&&r[c[0]]||(void 0!==a&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=a),i&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=i):c[2]=i),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),t.push(c))}},t}},354:e=>{"use strict";e.exports=function(e){var t=e[1],i=e[3];if(!i)return t;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[t].concat([a]).join("\n")}return[t].join("\n")}},540:e=>{"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},542:(e,t,i)=>{"use strict";i.d(t,{A:()=>s});var n=i(354),o=i.n(n),a=i(314),r=i.n(a)()(o());r.push([e.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !important;\n}\n\n.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {\n margin: 0 !important;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB;;AAEA;IACI,yBAAyB;AAC7B;;AAEA;IACI,oBAAoB;AACxB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !important;\n}\n\n.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {\n margin: 0 !important;\n}"],sourceRoot:""}]);const s=r},558:(e,t,i)=>{"use strict";i.d(t,{A:()=>s});var n=i(354),o=i.n(n),a=i(314),r=i.n(a)()(o());r.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: 800px;\n min-width: 550px;\n overflow: clip;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n overflow: hidden;\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}\n\n.hit-triage-info-view-container .fa-trash-alt:hover {\n color: #ff0000 !important;\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;IAChB,cAAc;AAClB;;AAEA;IACI,iBAAiB;IACjB,gBAAgB;AACpB;;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;;AAEA;IACI,yBAAyB;AAC7B",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 overflow: clip;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n overflow: hidden;\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}\n\n.hit-triage-info-view-container .fa-trash-alt:hover {\n color: #ff0000 !important;\n}"],sourceRoot:""}]);const s=r},659:e=>{"use strict";var t={};e.exports=function(e,i){var n=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);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)}},677:(e,t,i)=>{"use strict";i.d(t,{A:()=>s});var n=i(354),o=i.n(n),a=i(314),r=i.n(a)()(o());r.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 s=r},825:e=>{"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,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))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}}},t={};function i(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={id:n,exports:{}};return e[n](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{HTPackage:()=>qt,PackageFunctions:()=>Wt,_package:()=>Gt,demoFileIngest:()=>Lt,demoFileIngest1:()=>Ot,demoFileIngest2:()=>Vt,demoFileSubmit:()=>kt,gasteigerCellRenderer:()=>Dt,hitDesignApp:()=>_t,hitDesignAppTreeBrowser:()=>Nt,hitDesignVidPanel:()=>Mt,hitTriageApp:()=>Ft,hitTriageAppTreeBrowser:()=>It,htPackageSettingEditor:()=>Rt,peptiHitApp:()=>Pt,peptiHitAppTreeBrowser:()=>Et,registerMoleculesToViD:()=>Bt});const e=grok,t=ui,o=DG,a="campaignId",r="campaignId",s="enriched_table.csv",l="campaign.json",d="HitTriageFunction",c="HitTriageDataSource",u="HitTriageSubmitFunction",p="Selected hits",m="Stage",h="Molecule",v="Helm",f="V-iD",g="HIT_DESIGN_VID",y="HTScript",w="HTQuery",b="molecules",C="Source",A="New Template",T="Start",S="Create",x="Download",I="Cancel",N="Continue Campaign",E="New Campaign",F="No Information",_="script",P="function-package",L="data-query",O="HDCampaignsGrouping",V="HDCampaignTableColumns",k="HDCampaignsTableSorting";var B;!function(e){e.None="None",e.Template="Template",e.Status="Status",e.Author="Author",e.LastModifiedUser="Last Modified User"}(B||(B={}));const M={Name:e=>{var t;return null!==(t=e.friendlyName)&&void 0!==t?t:e.name},Code:e=>e.name,Created:e=>e.createDate,Author:e=>{var t;return null!==(t=e.authorUserFriendlyName)&&void 0!==t?t:""},"Last Modified by":e=>{var t;return null!==(t=e.lastModifiedUserName)&&void 0!==t?t:""},Molecules:e=>{var t;return(null!==(t=e.rowCount)&&void 0!==t?t:0).toString()},Status:e=>e.status},D="HTFunctionOrderingLS";var R=i(72),j=i.n(R),U=i(825),$=i.n(U),H=i(659),q=i.n(H),G=i(56),Y=i.n(G),W=i(540),J=i.n(W),z=i(113),K=i.n(z),Q=i(558),Z={};Z.styleTagTransform=K(),Z.setAttributes=Y(),Z.insert=q().bind(null,"head"),Z.domAPI=$(),Z.insertStyleElement=J(),j()(Q.A,Z),Q.A&&Q.A.locals&&Q.A.locals;var X=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};const ee=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function te(e,t){const i=document.title,n=window.location.href.split("?")[0]+"?"+e+"="+t;if(history.replaceState){const e={Title:i,Url:n};history.replaceState(e,e.Title,e.Url)}}function ie(i,n,o,a){var r;const s=t.breadcrumbs([n,o]),l=s.onPathClick.subscribe(e=>{1===e.length&&(l.unsubscribe(),ne(i),a())}),d=null===(r=e.shell.v.ribbonMenu.root.parentElement)||void 0===r?void 0:r.getElementsByClassName("d4-ribbon-name")[0];return d&&(d.textContent="",d.appendChild(s.root)),{breadcrumbs:s,sub:l}}function ne(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function oe(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 ae(e,t,i){return X(this,void 0,void 0,function*(){if(0===i.rowCount)return;if(!e.col(t))throw new Error("There is no molecule column in dataframe");let n=i.col(b);if(n||(yield i.meta.detectSemanticTypes(),n=i.columns.bySemType(o.SEMTYPE.MOLECULE)),!n)throw new Error("There is no original molecule column in query result dataframe");const a=i.columns.names().filter(e=>e!==b);e.join(i,[t],[n.name],void 0,a,void 0,!0)})}function re(t,i){return X(this,void 0,void 0,function*(){var n,a,r,s,l;const d=o.User.current().id,c=null===(n=o.User.current().group)||void 0===n?void 0:n.id;if(t===d)return!0;for(const t of i){const i=yield e.dapi.groups.find(t);if(i)if(i.personal){const t=yield e.dapi.groups.getUser(i);if((null==t?void 0:t.id)===d)return!0}else if(c){if((null!==(r=null===(a=i.members)||void 0===a?void 0:a.length)&&void 0!==r?r:0)>0&&i.members.some(e=>e.id===c))return!0;if((null!==(l=null===(s=i.adminMembers)||void 0===s?void 0:s.length)&&void 0!==l?l:0)>0&&i.adminMembers.some(e=>e.id===c))return!0}}return!1})}function se(e,t){return X(this,void 0,void 0,function*(){return re(e,t.edit)})}function le(e,t){return X(this,void 0,void 0,function*(){return re(e,Array.from(new Set([...t.view,...t.edit])))})}function de(e){return localStorage.getItem(e)}function ce(e,t){localStorage.setItem(e,t)}function ue(e){ce(O,e)}function pe(){const e=de(V),t=["Code","Created","Author","Last Modified by","Molecules","Status"];if(!e)return t;try{const i=JSON.parse(e);return Array.isArray(i)&&i.every(e=>"string"==typeof e)?i:t}catch(e){return console.error("error parsing campaign table columns",e),t}}function me(e){ce(V,JSON.stringify(e))}const he=(e,t)=>{var i,n,o,a,r,s;switch(e){case B.Template:return null!==(n=null===(i=t.template)||void 0===i?void 0:i.key)&&void 0!==n?n:t.templateName;case B.Status:return t.status;case B.Author:return null!==(o=t.authorUserFriendlyName)&&void 0!==o?o:F;case B.LastModifiedUser:return null!==(a=t.lastModifiedUserName)&&void 0!==a?a:F;default:if(e.startsWith("campaignFields.")){const i=e.replace("campaignFields.","");return null!==(s=null===(r=t.campaignFields)||void 0===r?void 0:r[i])&&void 0!==s?s:F}return""}};function ve(){var e,t,i;const n=null!==(e=de(D))&&void 0!==e?e:"{}";try{const e=JSON.parse(n);return{order:null!==(t=null==e?void 0:e.order)&&void 0!==t?t:[],hidden:null!==(i=null==e?void 0:e.hidden)&&void 0!==i?i:[]}}catch(e){console.error("error parsing function ordering",e)}return{order:[],hidden:[]}}function fe(e){var t;try{return null===(t=e.package)||void 0===t?void 0:t.name}catch(e){return}}function ge(e){return""===e||null==e||"number"==typeof e&&isNaN(e)}const ye={String:o.TYPE.STRING,Number:o.TYPE.FLOAT,Boolean:o.TYPE.BOOL,Date:o.TYPE.DATE_TIME,Molecule:o.SEMTYPE.MOLECULE};var we=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})},be=i(233),Ce=i.n(be),Ae=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};function Te(i,n,a,r,s){return Ae(this,void 0,void 0,function*(){var l,d,c,u,p,m,h,v,f,g,b,C,A,T,S,x;const I=i.computeFunctions,N=[];I.functions.filter(({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType).forEach(e=>{var t,i,n,o;N.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==r?void 0:r.compute)||void 0===t?void 0:t.functions)||void 0===i?void 0:i.find(t=>t.name===e.name&&t.package===e.package.name))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})}),I.scripts.filter(({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType).forEach(e=>{var t,i,n,o;N.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==r?void 0:r.compute)||void 0===t?void 0:t.scripts)||void 0===i?void 0:i.find(t=>t.id===e.id))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})}),I.queries.filter(e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType).forEach(e=>{var t,i,n,o;N.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==r?void 0:r.compute)||void 0===t?void 0:t.queries)||void 0===i?void 0:i.find(t=>t.id===e.id))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})});const E=t.div([],{classes:"hit-triage-compute-dialog-host"}),F=[],O=t.tree(),V=t.wait(()=>Ae(this,void 0,void 0,function*(){var i,n,o;try{const a=yield e.chem.descriptorsTree();function s(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}O.root.classList.add("hit-triage-compute-dialog-descriptors-group");const l=Object.keys(a),d=null!==(o=null===(n=null===(i=null==r?void 0:r.compute)||void 0===i?void 0:i.descriptors)||void 0===n?void 0:n.args)&&void 0!==o?o:[];for(const c of l){const u=s(c,O);for(const p of a[c].descriptors){const m=u.item(p.name,p);F.push(m),m.enableCheckBox(d.includes(p.name))}}return O.root}catch(h){console.error(h)}return t.divText("Failed to load descriptors")}));V.classList.add("oy-scroll");const k="Descriptors",B={[k]:k},M={[k]:V},R={},j={[k]:!1};j[k]=!!(null===(d=null===(l=null==r?void 0:r.compute)||void 0===l?void 0:l.descriptors)||void 0===d?void 0:d.enabled)&&(null===(p=null===(u=null===(c=null==r?void 0:r.compute)||void 0===c?void 0:c.descriptors)||void 0===u?void 0:u.args)||void 0===p?void 0:p.length)>0;for(const e of N)try{const i=e.func,n=i.prepare(e.args),o=i.type===P?`${i.package.name}:${i.name}`:i.type===_?`${y}:${null!==(m=i.name)&&void 0!==m?m:""}:${i.id}`:`${w}:${null!==(h=i.name)&&void 0!==h?h:""}:${i.id}`;R[o]=n;const a=t.div();t.setUpdateIndicator(a,!0),n.buildEditor(a,{condensed:!1}).then(t=>{var n,o;(null===(n=null==t?void 0:t[0])||void 0===n?void 0:n.root)&&(t[0].root.style.display="none"),(null===(o=null==t?void 0:t[1])||void 0===o?void 0:o.root)&&i.type!==L&&(t[1].root.style.display="none"),t.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(e=>{console.error(e),t.setUpdateIndicator(a,!1),a.appendChild(t.divText("Failed to build function editor"))}).finally(()=>t.setUpdateIndicator(a,!1)),a.classList.add("oy-scroll"),a.style.marginLeft="15px",a.style.removeProperty("max-width"),M[null!==(v=i.friendlyName)&&void 0!==v?v:i.name]=a,B[null!==(f=i.friendlyName)&&void 0!==f?f:i.name]=o,j[o]=null!==(x=(null===(b=null===(g=null==r?void 0:r.compute)||void 0===g?void 0:g.functions)||void 0===b?void 0:b.some(t=>e.func.type===P&&t.name===e.func.name&&t.package===fe(e.func)))||(null===(A=null===(C=null==r?void 0:r.compute)||void 0===C?void 0:C.scripts)||void 0===A?void 0:A.some(e=>e.id===i.id))||(null===(S=null===(T=null==r?void 0:r.compute)||void 0===T?void 0:T.queries)||void 0===S?void 0:S.some(e=>e.id===i.id)))&&void 0!==x&&x}catch(e){console.error(e);continue}const U=t.tabControl(M,!0);function $(e){var i,n;U.clear();let o=null!==(i=e.order)&&void 0!==i?i:Object.keys(M);0===o.length&&(o=Object.keys(M)),o.forEach(e=>{M[e]&&U.addPane(e,()=>M[e])}),Object.keys(M).forEach(t=>{var i;o.includes(t)||!M[t]||(null!==(i=e.hidden)&&void 0!==i?i:[]).includes(t)||U.addPane(t,()=>M[t])}),(null!==(n=e.hidden)&&void 0!==n?n:[]).forEach(e=>{j[B[e]]=!1}),U.panes.forEach(e=>{const i=t.input.bool("",{value:j[B[e.name]],onValueChanged:t=>{var i,n;j[B[e.name]]=!!t,t?null===(n=Ce()(e.content).find("input"))||void 0===n||n.removeAttr("disabled"):null===(i=Ce()(e.content).find("input"))||void 0===i||i.attr("disabled","true")}});i.setTooltip("Toggle calculation of this function"),e.header.appendChild(i.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")}),U.panes.length>0&&(U.currentPane=U.panes[0])}function H(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=j[k]?F.filter(e=>e.checked).map(e=>e.value.name):[];const t=Object.entries(R).filter(([e,t])=>j[e]);t.filter(([e,t])=>!e.startsWith(y)&&!e.startsWith(w)).forEach(([t,i])=>{e.externals[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach(([i,n])=>{e.externals[t][i]=n})}),t.filter(([e,t])=>e.startsWith(y)).forEach(([t,i])=>{e.scripts[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach(([i,n])=>{e.scripts[t][i]=n})}),t.filter(([e,t])=>e.startsWith(w)).forEach(([t,i])=>{e.queries[t]={};const n=i.inputs;Object.entries(n).slice(1).forEach(([i,n])=>{e.queries[t][i]=n})}),console.log(e),n(e)}return U.onTabChanged.subscribe(()=>{try{U.currentPane.content.style.removeProperty("max-width")}catch(e){}}),U.header.style.overflow="scroll",U.root.style.width="100%",U.root.style.minWidth="350px",E.appendChild(U.root),$(ve()),U.root.appendChild(function(e,i){var n;const a=ve(),r=o.DataFrame.fromColumns(e.map(e=>o.Column.fromStrings(e,[e])));r.columns.setOrder(null!==(n=a.order)&&void 0!==n?n:[]);const s=t.input.columns("reorder",{table:r,value:r.columns.toList().filter(e=>!a.hidden.includes(e.name))});s.onChanged.subscribe(()=>{try{const n=s.value.map(e=>e.name),o=e.filter(e=>!n.includes(e)),a={order:s.value.map(e=>e.name),hidden:o};r.columns.setOrder(a.order),t=a,ce(D,JSON.stringify(t)),i(a)}catch(e){console.error(e)}var t});const l=Array.from(s.root.children);setTimeout(()=>{l.forEach(e=>{e.style.maxWidth="0px",e.style.overflow="hidden",e.style.padding="0px",e.style.paddingRight="0px",e.style.visibility="hidden",e instanceof HTMLLabelElement&&(e.style.display="none")})},200),s.root.style.justifyContent="end",s.root.style.width="40px",s.root.style.height="0px",s.root.style.overflow="visible",s.root.style.padding="0px";const d=t.icons.edit(()=>{l.forEach(e=>{e.click()})},"Order or hide functions");return s.addOptions(d),Array.from(s.root.children).forEach(e=>{e.style.borderBottom="unset"}),d.style.fontSize="16px",s.root}(Object.keys(M),e=>{$(e)})),s&&t.dialog("Compute").add(E).onOK(()=>H()).onCancel(a).show({resizable:!0}),{root:E,okProxy:H}})}const Se=rxjs;class xe{constructor(e,i=[],n={}){this.onItemChanged=new Se.Subject,this.onAddingItemChanged=new Se.Subject,this.onItemAdded=new Se.Subject,this.onItemRemoved=new Se.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.addingItemInputs={},this.properties=e,this.options=Object.assign(Object.assign({},this.options),n),this._root=t.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=i,this.render()}get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t=!0){this._items.push(e),this.render(),t&&this.onItemAdded.next(e)}removeItem(e,t=!0){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),t&&this.onItemRemoved.next(e))}removeAtIndex(e,t=!0){if(e<0||e>=this._items.length)return;const i=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(i[0])}removeAllItems(){this._items=[],this.render()}render(){var e,i,n,o,a;if(t.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let o=null!==(e=n.caption)&&void 0!==e?e:n.name;(null===(i=this.options.customLabels)||void 0===i?void 0:i[n.name])&&(o=this.options.customLabels[n.name]);const a=t.divText(o);a.style.fontWeight="bold",this._root.appendChild(a)}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!==(a=null===(o=(n=this.options).newItemFunction)||void 0===o?void 0:o.call(n))&&void 0!==a?a:void 0,!0);for(const t of e)this._root.appendChild(t)}}get addingItem(){const e={};return Object.keys(this.addingItemInputs).forEach(t=>{e[t]=this.addingItemInputs[t].value}),e}getItemDiv(e={},i){var n,a;const r=[],s={};let l=null;for(const d of this.properties){void 0===e[d.name]&&(e[d.name]=null);const c=(null===(n=this.options.customInputs)||void 0===n?void 0:n[d.name])?this.options.customInputs[d.name](e):t.input.forProperty(d,e),u=null===(a=this.options.validators)||void 0===a?void 0:a[d.name];u&&c.addValidator(u),r.push(this.options.horizontalInputNames?c.root:this.hideLabel(c.root)),d.propertyType!==o.TYPE.BOOL&&"color"!==d.name.toLowerCase()&&c.input&&(c.input.style.width="100%"),s[d.name]=c,c.onChanged.subscribe(()=>{e[d.name]=c.value,i?this.onAddingItemChanged.next({item:e,fieldName:d.name}):this.onItemChanged.next({item:e,fieldName:d.name})}),c.root.style.alignItems="center",l=c}let d=null;if(i)this.addingItemInputs=s,d=t.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 r;d=t.icons.delete(()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()},this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(d):null==l||l.root.appendChild(d),d.style.color="#2083d5",r}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}function Ie(){const i=o.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),n=o.InputBase.forProperty(i);let a=null,r=null,s=null,l=null;return n.onChanged.subscribe(t=>{return i=this,d=void 0,u=function*(){const t=n.value;if(t){try{const i=!!t.fullPath&&(yield e.dapi.files.exists(t.fullPath));s=i?t.fullPath:null}catch(e){s=null}try{const e=yield t.readAsString(),i=o.ViewLayout.fromJson(e);i?(a=i,r=i.viewState,l=null):(a=null,r=null,s=null,l="Invalid layout file")}catch(e){a=null,r=null,s=null,l="Invalid layout file"}n.input.classList[l?"add":"remove"]("d4-invalid")}else a=null,r=null,s=null},new((c=void 0)||(c=Promise))(function(e,t){function n(e){try{a(u.next(e))}catch(e){t(e)}}function o(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var i;t.done?e(t.value):(i=t.value,i instanceof c?i:new c(function(e){e(i)})).then(n,o)}a((u=u.apply(i,d||[])).next())});var i,d,c,u}),t.tooltip.bind(n.root,()=>l||"Select a layout file"),{dataFileInput:n,getLayout:()=>a,getLayoutViewState:()=>r,getLocalFilePath:()=>s}}var Ne=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};function Ee(i,n){return Ne(this,void 0,void 0,function*(){var a,r;const s=(yield Gt.files.list("Hit Triage/templates")).map(e=>e.name.slice(0,-5)),l=[];for(const e of s){const t=JSON.parse(yield Gt.files.readAsText(`Hit Triage/templates/${e}.json`));l.push(t.key)}const d=Array.from(new Set(o.Func.find({meta:{role:u}}).concat(o.Func.find({tags:[u]})))),p={};d.forEach(e=>{var t;p[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const m=t.input.choice("Submit function",{value:null,items:[null,...Object.keys(p)]});m.value=null,m.nullable=!0,m.fireChanged(),m.setTooltip("Select function to be called upon submitting");const h=Ie(),v=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),f=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),g=t.input.string("Name",{value:"",onValueChanged:e=>{""===e||s.includes(e)?(g.root.style.borderBottom="1px solid red",v.style.opacity="100%"):(g.root.style.borderBottom="none",v.style.opacity="0%")}}),b=t.input.string("Key",{value:"",onValueChanged:e=>{""===e||l.includes(e)?(b.root.style.borderBottom="1px solid red",f.style.opacity="100%"):(b.root.style.borderBottom="none",f.style.opacity="0%")}});b.setTooltip("Template key used for campaign prefix"),g.setTooltip("Template name"),g.root.style.borderBottom="none",b.root.style.borderBottom="none",v.style.opacity="0%",f.style.opacity="0%";let A=null;const T=yield Te(i,e=>{A=e},()=>null,{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);T.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&Array.from(new Set(o.Func.find({meta:{role:c}}).concat(o.Func.find({tags:[c]})))).forEach(e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const x=Object.keys(n),N=t.input.choice(C,{value:x[0],items:x}),E=t.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:e=>{N.root.style.display="Query"===e?"block":"none"}}),F=Fe(),_=t.div([t.h2("Details"),t.div([g,v]),t.div([b,f]),E.root,N.root,h.dataFileInput,F.fieldsDiv,t.h2("Compute"),T.root,t.h2("Submit"),m.root],"ui-form"),P=t.buttonsInput([]),L=null!==(r=null===(a=P.getElementsByClassName("ui-input-editor"))||void 0===a?void 0:a[0])&&void 0!==r?r:P;_.appendChild(P);const O=new Promise(e=>{const i=t.button(I,()=>e());L.appendChild(i)}),V=new Promise(i=>{const n=t.bigButton(S,()=>function(){return Ne(this,void 0,void 0,function*(){var t,n,o,a,r,s,l,d;if(T.okProxy(),"100%"===v.style.opacity)return void e.shell.error("Template name is empty or already exists");const c=m.value?p[m.value]:void 0,u=Object.assign(Object.assign({name:g.value,key:b.value,campaignFields:F.getFields(),dataSourceType:null!==(t=E.value)&&void 0!==t?t:"Query",layoutViewState:null!==(n=h.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==A?void 0:A.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==A?void 0:A.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(r=null==A?void 0:A.externals)&&void 0!==r?r:{}).map(([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(s=null==A?void 0:A.scripts)&&void 0!==s?s:{}).filter(([e,t])=>e.startsWith(y)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(l=null==A?void 0:A.queries)&&void 0!==l?l:{}).filter(([e,t])=>e.startsWith(w)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})}},c?{submit:{fName:c.name,package:fe(c)}}:{}),{queryFunctionName:"Query"===E.value&&null!==(d=N.value)&&void 0!==d?d:void 0});var f;f=u,Gt.files.writeAsText(`Hit Triage/templates/${f.name}.json`,JSON.stringify(f)),e.shell.info("Template created successfully"),i(u)})}());L.appendChild(n)});return{root:_,template:V,cancelPromise:O}})}function Fe(e){const i=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING}),o.Property.fromOptions({name:"Type",type:o.TYPE.STRING,choices:Object.keys(ye)}),o.Property.fromOptions({name:"Required",type:o.TYPE.BOOL})],n=new xe(i,e?e.map(e=>({Name:e.name,Type:e.type,Required:e.required})):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe(e=>{a={}}),n.onAddingItemChanged.subscribe(e=>{e&&(a=e.item)});const r=t.h2("Additional fields");t.tooltip.bind(r,"Additional fields to be filled by user for each campaign");const s=t.div([r,n.root]);return{getFields:function(){var e;const t=n.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:t.div([s])}}var _e=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class Pe extends o.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return _e(this,void 0,void 0,function*(){})}deleteCampaign(e,t){return _e(this,void 0,void 0,function*(){yield Gt.files.delete(`${e}/campaigns/${t}`)})}}var Le=i(677),Oe={};Oe.styleTagTransform=K(),Oe.setAttributes=Y(),Oe.insert=q().bind(null,"head"),Oe.domAPI=$(),Oe.insertStyleElement=J(),j()(Le.A,Oe),Le.A&&Le.A.locals&&Le.A.locals;var Ve;!function(i){let n,o;!function(e){e.vert=function(e){return t.divV(e.map(e=>t.render(e)),{classes:"u2-panel"})},e.horz=function(e){return t.divH(e.map(e=>t.render(e)),{classes:"u2-panel"})}}(n=i.panels||(i.panels={})),i.appHeader=function(e){const i=t.iconImage("",e.iconPath);return Ce()(i).addClass("ui-app-header-icon").css("margin-right","20px"),n.horz([i,n.vert([t.markdown(e.description),e.learnMoreUrl?t.link("Learn more",e.learnMoreUrl):null])])},function(i){i.runAsync=function(i,n){return o=this,a=void 0,s=function*(){t.setUpdateIndicator(i,!0);try{return yield n()}catch(t){e.log.error(t)}finally{t.setUpdateIndicator(i,!1)}},new((r=void 0)||(r=Promise))(function(e,t){function i(e){try{l(s.next(e))}catch(e){t(e)}}function n(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof r?o:new r(function(e){e(o)})).then(i,n)}l((s=s.apply(o,a||[])).next())});var o,a,r,s}}(o=i.tools||(i.tools={}))}(Ve||(Ve={}));var ke=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};const Be={view:[o.Group.defaultGroupsIds["All users"]],edit:[o.Group.defaultGroupsIds["All users"]]};class Me{constructor(e){this.permissions=null!=e?e:Be,this.editGroupsInput=t.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=t.input.userGroups("Can View")}getDialogContent(){return ke(this,void 0,void 0,function*(){const i=[],n=[];for(const t of this.permissions.view){const n=yield e.dapi.groups.find(t);n&&i.push(n)}for(const t of this.permissions.edit){const i=yield e.dapi.groups.find(t);i&&n.push(i)}return this.editGroupsInput.value=n,this.viewGroupsInput.value=i,t.divV([this.viewGroupsInput.root,this.editGroupsInput.root])})}show(e){return ke(this,void 0,void 0,function*(){var i;const n=yield this.getDialogContent(),o=t.dialog("Edit Permissions").add(n).onOK(()=>{const t=new Set(this.editGroupsInput.value.map(e=>e.id)),i=new Set(this.viewGroupsInput.value.map(e=>e.id));this.permissions.edit=Array.from(t),t.forEach(e=>i.add(e)),this.permissions.view=Array.from(i),0===this.permissions.view.length&&(this.permissions.view=Be.view),e(this.permissions)});(null===(i=n.parentElement)||void 0===i?void 0:i.style)&&(n.parentElement.style.overflow="visible"),o.show()})}}var De=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class Re extends Pe{constructor(t){super(t),this.readmePath=Gt.webRoot+"README_HT.md",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 De(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const i=t.h1(N),n=t.h1(E,{style:{marginLeft:"10px"}}),o=Ve.appHeader({iconPath:Gt.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=t.div(),r=t.div([],{classes:"ui-form"}),s=yield this.getCampaignsTable();yield this.startNewCampaign(a,r,e),Ce()(this.root).empty(),this.root.appendChild(t.div([t.divV([o,i],{style:{marginLeft:"10px"}}),s,n,r,a]))}catch(e){throw t.setUpdateIndicator(this.root,!1),e}finally{t.setUpdateIndicator(this.root,!1)}})}startNewCampaign(e,i,n){return De(this,void 0,void 0,function*(){var o;const a=(yield Gt.files.list("Hit Triage/templates")).map(e=>e.name.slice(0,-5));n&&!a.includes(n.name)&&a.push(n.name);const r=()=>De(this,void 0,void 0,function*(){const t=s.value,i=n&&n.name===t?n:JSON.parse(yield Gt.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(i,e);Ce()(e).empty(),e.className="ui-form",e.appendChild(o)}),s=t.input.choice("Template",{value:null!==(o=null==n?void 0:n.name)&&void 0!==o?o:a[0],items:a,onValueChanged:()=>De(this,void 0,void 0,function*(){yield r()})}),l=t.icons.add(()=>De(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),t.setUpdateIndicator(this.root,!1)}),A);s.addOptions(l),yield r(),Ce()(i).empty(),i.appendChild(s.root)})}checkCampaign(e){return De(this,void 0,void 0,function*(){const t=location.search,i=new URLSearchParams(t);if(!i.has(a)&&!e)return;const n=null!=e?e:i.get(a);if(!(yield Gt.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield Gt.files.readAsText(`Hit Triage/campaigns/${n}/${l}`));if(o){if(o.authorUserId&&o.permissions&&!(yield le(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const r=JSON.parse(yield Gt.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(r,o.filters,n,o.ingest),e&&te(a,e),o})}getCampaignsTable(){return De(this,void 0,void 0,function*(){const e=yield Gt.loadCampaigns("Hit Triage",this.deletedCampaigns),i=e=>{var i,n;const a=t.icons.delete(()=>De(this,void 0,void 0,function*(){t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK(()=>De(this,void 0,void 0,function*(){yield this.deleteCampaign("Hit Triage",e.name),this.deletedCampaigns.push(e.name),yield this.init()})).show()}),"Delete campaign");return a.style.display="none",se(null!==(i=e.authorUserId)&&void 0!==i?i:o.User.current().id,null!==(n=e.permissions)&&void 0!==n?n:Be).then(e=>{e&&(a.style.display="inline-block")}),a},n=Object.values(e),a=t.table(n,e=>[t.link(e.name,()=>this.setCampaign(e.name),"",""),e.createDate,e.rowCount,e.filteredRowCount,e.status,i(e)],["Name","Created","Total","Selected","Status",""]);return a.style.color="var(--grey-5)",a})}setCampaign(e){return De(this,void 0,void 0,function*(){const t=yield this.checkCampaign(e);this.app.campaign=t})}getNewCampaignAccordeon(i,n){return De(this,void 0,void 0,function*(){t.setUpdateIndicator(n,!0);const{root:a,promise:r,cancelPromise:s}=yield function(i,n){return we(this,void 0,void 0,function*(){var a,r;const s=t.divText("",{style:{color:"red"}});let l=null;const d=()=>we(this,void 0,void 0,function*(){try{if(l=u.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(o.SEMTYPE.MOLECULE))return void(s.innerText="No molecules column found");s.innerText=""}catch(e){s.innerText="Error parsing file"}}),u=t.input.table("Dataframe",{onValueChanged:d});yield d();const p=t.div([u,s]);0===Object.keys(n).length&&Array.from(new Set(o.Func.find({meta:{role:c}}).concat(o.Func.find({tags:[c]})))).forEach(e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});let m=null;const h=()=>we(this,void 0,void 0,function*(){const e=n[f.value];m=e.prepare();const t=yield m.getEditor();t.classList.remove("ui-form"),v.innerHTML="",v.appendChild(t)}),v=t.div([]),f=t.input.choice(C,{value:null!==(a=i.queryFunctionName)&&void 0!==a?a:Object.keys(n)[0],items:Object.keys(n),onValueChanged:h});yield h(),i.queryFunctionName&&(null===(r=f.root.getElementsByTagName("select").item(0))||void 0===r||r.setAttribute("disabled","true"));const g=t.div([f,v]);g.style.display="none";const y=t.div([p,g]),w=i.campaignFields.map(e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e).map(e=>o.Property.fromOptions(Object.assign({name:e.name,type:ye[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{}))),b={},A=w.length?t.input.form(b,w):t.div();A.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const S=t.div([y,...w.length?[A]:[]]),x=t.buttonsInput([]);return S.appendChild(x),{promise:new Promise(o=>{const a=()=>we(this,void 0,void 0,function*(){if("File"===i.dataSourceType){if(!l)return void e.shell.error("No file selected");const t=l;t.name=l.name,o({df:t,type:"File",campaignProps:b})}else{const t=n[f.value];if(!t)return void e.shell.error("No function selected");const i={};Object.entries(m.inputs).forEach(([e,t])=>{i[e]=t});const a=yield t.apply(i);o({df:a,type:"Query",campaignProps:b})}}),r=t.bigButton(T,()=>a());x.appendChild(r)}),root:S,cancelPromise:new Promise(e=>{t.button(I,()=>e())})}})}(i,this.dataSourceFunctionsMap);return t.setUpdateIndicator(n,!1),r.then(e=>De(this,void 0,void 0,function*(){this.app.dataFrame=e.df,this.app._fileInputType=e.type,yield this.app.setTemplate(i),this.app.campaignProps=e.campaignProps,yield this.app.saveCampaign(void 0,!1),i.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=i.layoutViewState)})),s.then(()=>{this.init()}),a})}createNewTemplate(){return De(this,void 0,void 0,function*(){const t=yield Ee(this.app,this.dataSourceFunctionsMap),i=new o.ViewBase,n=e.shell.v;i.name="New Template",i.root.appendChild(t.root),i.parentCall=this.app.parentCall,e.shell.addView(i),i.path=new URL(this.app.baseUrl).pathname+"/new-template",i.parentView=n;const{sub:a}=ie(e.shell.v,"Hit Triage",A,()=>{e.shell.v=n,i.close()});t.template.then(t=>De(this,void 0,void 0,function*(){yield this.init(t),i.close(),ne(i),e.shell.v=n,a.unsubscribe()})),t.cancelPromise.then(()=>{a.unsubscribe(),i.close(),e.shell.v=n})})}}class je extends Pe{constructor(e){super(e),this.name="Submit"}render(){return t.empty(this.root),t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return t=this,i=void 0,a=function*(){const t=this.app.submitParams;if(!t)return;const i=o.Func.find({name:t.fName,package:t.package})[0];if(!i)return void e.shell.error(`Function ${t.fName} not found.`);const n=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield i.apply({df:n,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((n=void 0)||(n=Promise))(function(e,o){function r(e){try{l(a.next(e))}catch(e){o(e)}}function s(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n(function(e){e(i)})).then(r,s)}l((a=a.apply(t,i||[])).next())});var t,i,n,a}}var Ue,$e,He=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};!function(t){t.acquireCampaignLock=function(t,i,n){return He(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AcquireCampaignLock",{appName:t,campaignId:i,lockedBy:n})})},t.releaseCampaignLock=function(t,i){return He(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:ReleaseCampaignLock",{appName:t,campaignId:i})})},t.getLastModified=function(t,i){return He(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetLastModified",{appName:t,campaignId:i})})},t.addMolecule=function(t,i,n,o){return He(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AddMolecule",{canonicalSmiles:t,appName:i,campaignId:n,createdBy:o})})},t.addMolecules=function(t,i,n,o){return He(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AddMolecules",{smiles:t,appName:i,campaignId:n,createdBy:o})})},t.getMoleculeByVid=function(t){return He(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetMoleculeByVid",{vid:t})})},t.getCampaignsByVid=function(t,i){return He(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetCampaignsByVid",{vid:t,appName:i})})}}(Ue||(Ue={})),function(t){t.hitTriageAppTreeBrowser=function(t){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitTriageAppTreeBrowser",{treeNode:t})})},t.hitDesignAppTreeBrowser=function(t){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignAppTreeBrowser",{treeNode:t})})},t.peptiHitAppTreeBrowser=function(t){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PeptiHitAppTreeBrowser",{treeNode:t})})},t.hitTriageApp=function(){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitTriageApp",{})})},t.hitDesignApp=function(){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignApp",{})})},t.peptiHitApp=function(){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PeptiHitApp",{})})},t.demoFileIngest=function(){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest",{})})},t.demoFileIngest1=function(){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest1",{})})},t.demoFileIngest2=function(t){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest2",{numberOfMolecules:t})})},t.demoFileSubmit=function(t,i){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileSubmit",{df:t,molecules:i})})},t.registerMoleculesToViD=function(){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:RegisterMoleculesToViD",{})})},t.hitDesignVidPanel=function(t){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignVidPanel",{vid:t})})},t.gasteigerCellRenderer=function(){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:GasteigerCellRenderer",{})})},t.htPackageSettingEditor=function(t){return He(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HtPackageSettingEditor",{propList:t})})}}($e||($e={}));var qe=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class Ge{get appName(){return this._appName}constructor(e,t){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this.baseUrl=new URL(window.location.href).origin+`/apps/HitTriage/${t.replace(" ","")}`,this._appName=t;const i=Array.from(new Set(o.Func.find({meta:{role:d}}).concat(o.Func.find({tags:[d]})))),n=i.filter(e=>e.type===P),a=i.filter(e=>e.type===_),r=i.filter(e=>e.type===L);this.computeFunctions={functions:n,scripts:a,queries:r}}setCanEdit(e){return qe(this,void 0,void 0,function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield se(e.authorUserId,e.permissions):this.hasEditPermission=!0})}getFilterType(e){const t=this.dataFrame.col(e);return(null==t?void 0:t.semType)===o.SEMTYPE.MOLECULE?o.FILTER_TYPE.SUBSTRUCTURE:(null==t?void 0:t.type)===o.COLUMN_TYPE.BOOL?o.FILTER_TYPE.BOOL_COLUMNS:(null==t?void 0:t.type)===o.COLUMN_TYPE.STRING?o.FILTER_TYPE.CATEGORICAL:o.FILTER_TYPE.HISTOGRAM}download(e,t,i=!1){const n=document.createElement("a"),a=o.DataFrame.fromColumns(e.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv({filteredRowsOnly:i});n.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),n.setAttribute("download",t+".csv"),n.click()}getNewCampaignName(e,t){return qe(this,void 0,void 0,function*(){const i=(yield Gt.files.list(e)).map(e=>e.name).filter(e=>e.startsWith(`${t}-`)&&!!parseInt(e.substring(t.length+1)));if(0===i.length)return t+"-1";const n=i.map(e=>e.substring(t.length+1)).filter(Boolean).map(e=>parseInt(e,10)).sort((e,t)=>e-t);return t+"-"+(n[n.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)}}unionDataframes(e,t,i,n){var a,r,s,l;const d=i;e.col(i).name=n,i=n;const c=null===(r=null===(a=e.col(i))||void 0===a?void 0:a.toList())||void 0===r?void 0:r.map(e=>Gt.convertToSmiles(e)),u=null===(l=null===(s=t.col(n))||void 0===s?void 0:s.toList())||void 0===l?void 0:l.map(e=>Gt.convertToSmiles(e));if(!c||!u)throw new Error("Molecule column not found");const p=new Map;u.forEach((e,t)=>{e&&"MALFORMED_INPUT_VALUE"!==e&&p.set(e,t)});const m=(e,t,i,n)=>{try{if(e.type===t.type)e.set(i,t.get(n),!1);else if(e.type===o.COLUMN_TYPE.STRING)e.set(i,t.getString(n),!1);else if(e.type===o.COLUMN_TYPE.INT){const o=t.get(n);"number"==typeof o?e.set(i,Math.round(o),!1):"string"==typeof o&&o.length>0&&!isNaN(Number(o))&&e.set(i,Math.round(Number(o)),!1)}else if(e.type===o.COLUMN_TYPE.FLOAT){const o=t.get(n);"number"==typeof o?e.set(i,o,!1):"string"==typeof o&&o.length>0&&!isNaN(Number(o))&&e.set(i,Number(o),!1)}else e.set(i,t.get(n),!1)}catch(o){Gt.logger.error(`Error setting column value for column ${e.name} at row ${i} from column ${t.name} at row ${n}: ${o}`)}};this.isJoining=!0;try{const i=[];for(const n of e.columns)if(!t.columns.contains(n.name)){const e=t.columns.addNew(n.name,n.type);n.semType&&(e.semType=n.semType),i.push(n.name)}for(let n=0;n<c.length;n++)if(c[n]&&"MALFORMED_INPUT_VALUE"!==c[n])if(p.has(c[n])){if(i.length>0){const o=p.get(c[n]);for(const a of i)m(t.col(a),e.col(a),o,n)}}else{t.rows.addNew(null,!0);for(const i of e.columns)m(t.col(i.name),i,t.rowCount-1,n)}}finally{setTimeout(()=>{this.isJoining=!1},500),e.col(i).name=d}return t}aquireAndWaitCampaignLock(e){return qe(this,arguments,void 0,function*(e,t=3e4){var i;const n=Date.now();let a=0,r=null;const s=o.User.current(),l=s&&(s.friendlyName||s.name)||"unknown";for(;Date.now()-n<t&&a<5;)try{const t=yield Ue.acquireCampaignLock(this.appName,e,l);if(t&&t.rowCount>0)return{aquired:!0,expires_at:null===(i=null==t?void 0:t.col("expires_at"))||void 0===i?void 0:i.getString(0)};r=null,yield o.delay(200)}catch(e){r=e,a++}if(r)throw r;return{aquired:!1,expires_at:null}})}releaseCampaignLock(e){return qe(this,void 0,void 0,function*(){var t,i;return(null===(i=null===(t=yield Ue.releaseCampaignLock(this.appName,e))||void 0===t?void 0:t.col("updated_at"))||void 0===i?void 0:i.getString(0))||null})}}Ge.molFileExtReaders=["sdf","mol","smi","mol2"].map(e=>{const t=o.Func.find({meta:{role:o.FUNC_TYPES.FILE_IMPORTER}}).concat(o.Func.find({tags:["file-handler"]})).find(t=>{var i;return(null===(i=null==t?void 0:t.options)||void 0===i?void 0:i.ext)&&"string"==typeof t.options.ext&&t.options.ext.split(",").includes(e)});return{ext:e,handlerFunc:t}}).filter(e=>e.handlerFunc);var Ye=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})},We=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};function Je(t,i,n){return We(this,arguments,void 0,function*(t,i,n,a=[],r=[]){const s=o.TaskBarProgressIndicator.create("Calculating ..."),l=t.map(e=>Gt.convertToSmiles(e)),d=o.Column.fromStrings(h,l),c=o.DataFrame.fromColumns([d]);c.name="HD cell values",yield c.meta.detectSemanticTypes();const u=[];u.push(new Promise(t=>We(this,void 0,void 0,function*(){try{i.length&&(yield e.chem.descriptors(c,d.name,i))}catch(e){Gt.logger.error("Descriptors calculation error"),Gt.logger.error(e)}t()})));for(const e of n)u.push(new Promise(t=>We(this,void 0,void 0,function*(){try{const i=e.args,n=o.Func.find({package:e.package,name:e.name});if(!n.length||!n[0])return console.warn(`Function ${e.name} from package ${e.package} is not found`),void t();const a=n[0],r=a.inputs[0].name,s=a.inputs[1].name;yield a.apply(Object.assign(Object.assign({},i),{[r]:c,[s]:d.name}))}catch(e){Gt.logger.error(e)}t()})));for(const e of a){const t=e.args;u.push(new Promise(i=>We(this,void 0,void 0,function*(){try{const i=o.Func.find({name:e.name}).filter(t=>t.type===_&&t.id===e.id)[0];if(i){const e=i.inputs[0].name,n=i.inputs[1].name,o=yield i.apply(Object.assign(Object.assign({},t),{[e]:c,[n]:d.name}));if(o&&o.rowCount===c.rowCount&&"python"===i.language)for(const e of o.columns)e.name=c.columns.getUnusedName(e.name),c.columns.add(e)}}catch(e){Gt.logger.error(e)}i()})))}for(const e of r){const t=e.args;u.push(new Promise(i=>We(this,void 0,void 0,function*(){try{const n=o.Func.find({name:e.name}).filter(t=>t.type===L&&t.id===e.id)[0];if(n){const e=n.inputs[0].name,o=[l],a=yield n.apply(Object.assign(Object.assign({},t),{[e]:o}));if(!a||0===a.rowCount)return void i();yield ae(c,h,a)}}catch(e){Gt.logger.error(e)}i()})))}yield Promise.all(u),s.close();const p=c.col(h);for(let e=0;e<p.length;e++)p.set(e,t[e],!1);return c})}function ze(t,i,n){return We(this,void 0,void 0,function*(){var a,r;const s=o.TaskBarProgressIndicator.create("Calculating ..."),l=i.col(n);if(!l)throw new Error("There is no molecule column in dataframe");const d=`~${n}.canonicalSmiles`,c=i.columns.getOrCreate(d,o.TYPE.STRING);c.semType=o.SEMTYPE.MOLECULE;const u=l.toList();for(let e=0;e<u.length;e++){if(l.isNone(e))continue;const t=u[e];if(!t)continue;const i=Gt.convertToSmiles(t);c.set(e,i,!1)}const p=[];p.push(new Promise(n=>We(this,void 0,void 0,function*(){try{t.descriptors&&t.descriptors.length>0&&(yield e.chem.descriptors(i,d,t.descriptors))}catch(e){Gt.logger.error("Descriptors calculation error"),Gt.logger.error(e)}n()})));for(const e of Object.keys(t.externals))p.push(new Promise(n=>We(this,void 0,void 0,function*(){try{const n=t.externals[e],a=o.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=a.inputs[0].name,s=a.inputs[1].name;n&&(yield a.apply(Object.assign(Object.assign({},n),{[r]:i,[s]:d})))}catch(e){Gt.logger.error(e)}n()})));for(const e of Object.keys(null!==(a=t.scripts)&&void 0!==a?a:{})){const n=t.scripts[e];p.push(new Promise(t=>We(this,void 0,void 0,function*(){if(n){const a=e.split(":"),r=a[2];if(!r)return void t();try{const e=a[1],s=o.Func.find({name:e}).filter(e=>e.type===_&&e.id===r)[0];if(!s)return void t();const l=s.inputs[0].name,c=s.inputs[1].name,u=yield s.apply(Object.assign(Object.assign({},n),{[l]:i,[c]:d}));if(u&&u.rowCount===i.rowCount&&"python"===s.language)for(const e of u.columns)e.name=i.columns.getUnusedName(e.name),i.columns.add(e)}catch(e){Gt.logger.error(e)}}t()})))}for(const e of Object.keys(null!==(r=t.queries)&&void 0!==r?r:{})){const n=t.queries[e];p.push(new Promise(t=>We(this,void 0,void 0,function*(){if(n){const a=e.split(":"),r=a[2];if(!r)return void t();try{const e=a[1],s=o.Func.find({name:e}).filter(e=>e.type===L&&e.id===r)[0];if(!s)return void t();const l=s.inputs[0].name,u=yield s.apply(Object.assign(Object.assign({},n),{[l]:c.toList()}));u&&(yield ae(i,d,u))}catch(e){console.error(e)}}t()})))}yield Promise.all(p),s.close()})}var Ke=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class Qe extends Ge{get infoView(){return this._infoView}constructor(t){super(t,"Hit Triage"),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new Re(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe(e=>{this.multiView.currentView instanceof Pe&&this.multiView.currentView.onActivated()}),this.multiView.parentCall=t,e.events.onCurrentViewChanged.subscribe(()=>{var t,i,n,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),te(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(e){console.error(e)}})}get submitParams(){var e,t,i,n;return null!==(i=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.submit)&&void 0!==i?i:null===(n=this.template)||void 0===n?void 0:n.submit}setTemplate(t,i,n,r){return Ke(this,void 0,void 0,function*(){var s,l,d,c,u,p,m,h,v,f,g,b,C,A,T;if((null===(s=this._pickView)||void 0===s?void 0:s.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,n?r&&(this._fileInputType=r.type,"File"===r.type?this.dataFrame=yield e.dapi.files.readCsv(r.query):this.dataFrame=yield e.functions.call(r.query)):(n=yield this.getNewCampaignName("Hit Triage/campaigns",t.key),te(a,n)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(d=this._campaign)||void 0===d?void 0:d.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach(([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&i.semType!==t&&(i.semType=t)}),(null===(c=this._campaign)||void 0===c?void 0:c.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach(([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{i.convertTo(t)}catch(e){console.error(e)}}),yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(p=null===(u=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===u?void 0:u.name)&&void 0!==p?p:void 0,this._dfName=null!==(m=this.dataFrame.name)&&void 0!==m?m:null==r?void 0:r.query,this.dataFrame.name=null!==(v=null!==(h=this._dfName)&&void 0!==h?h:this.dataFrame.name)&&void 0!==v?v:"Molecules",this._campaignId=n,this.template=(null===(f=this.campaign)||void 0===f?void 0:f.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:t.dataSourceType,queryFunctionName:t.queryFunctionName}):t,this._campaignFilters=i,!i){const e={},i={},n={};t.compute.functions.forEach(t=>{const i=`${t.package}:${t.name}`;e[i]=t.args}),null===(g=t.compute.scripts)||void 0===g||g.forEach(e=>{const t=`${y}:${e.name}:${e.id}`;i[t]=e.args}),null===(b=t.compute.queries)||void 0===b||b.forEach(e=>{const t=`${w}:${e.name}:${e.id}`;n[t]=e.args}),yield ze({descriptors:t.compute.descriptors.enabled?t.compute.descriptors.args:[],externals:e,scripts:i,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const S=e.shell.v,x=e.shell.addView(this.pickView);this.currentPickViewId=x.name,this._submitView=new je(this),this.setBaseUrl(),te(a,null!==(T=null!==(C=this._campaignId)&&void 0!==C?C:null===(A=this._campaign)||void 0===A?void 0:A.name)&&void 0!==T?T:"");const I=x;setTimeout(()=>{this._pickViewPromise&&this._pickViewPromise.then(()=>{const{sub:t}=ie(I,"Hit Triage","Pick",()=>{e.shell.v=S,I.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,t,i;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(i=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.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(p)||this.dataFrame.columns.addNewBool(p).init(!1);const i=o.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),a=t.iconFA("wrench",()=>Ke(this,void 0,void 0,function*(){Te(this,e=>Ke(this,void 0,void 0,function*(){var t,i,n,o,a,r,s;const l=this.template.compute.descriptors.args,d=this.template.compute.functions,c=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],u=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=e.descriptors,m={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.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 i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(r=null==e?void 0:e.scripts)&&void 0!==r?r:{}).filter(([e,t])=>e.startsWith(y)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(s=null==e?void 0:e.queries)&&void 0!==s?s:{}).filter(([e,t])=>e.startsWith(w)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})};this.template.compute=m;const h=p.filter(e=>!l.includes(e)),v=m.functions.filter(e=>{if(!d.some(t=>t.name===e.name&&t.package===e.package))return!0;const t=d.find(t=>t.name===e.name&&t.package===e.package);return!Object.entries(e.args).every(([e,i])=>t.args[e]===i)}),f=m.scripts.filter(e=>{if(!c.some(t=>t.id===e.id))return!0;const t=c.find(t=>t.id===e.id);return!Object.entries(e.args).every(([e,i])=>t.args[e]===i)}),g=m.queries.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,i])=>t.args[e]===i)}),b={};v.forEach(e=>{const t=`${e.package}:${e.name}`;b[t]=e.args});const C={};f.forEach(e=>{const t=`${y}:${e.name}:${e.id}`;C[t]=e.args});const A={};g.forEach(e=>{const t=`${w}:${e.name}:${e.id}`;A[t]=e.args}),yield ze({descriptors:h,externals:b,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}),()=>null,this.template,!0)}),"Calculate additional properties"),r=t.bigButton("Submit",()=>{var e;const i=null===(e=this._submitView)||void 0===e?void 0:e.render();if(i){const e=t.dialog("Submit");e.add(i),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=t.iconFA("share",()=>Ke(this,void 0,void 0,function*(){var e;yield new Me(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show(e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)})}),"Edit permissions");r.classList.add("hit-design-submit-button");const l=oe(n);return n.push([a,...this.hasEditPermission?[s]:[],...l?[]:[r]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout(()=>Ke(this,void 0,void 0,function*(){var t,n,a;i._onAdded(),yield new Promise(e=>setTimeout(e,1e3));const r=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),s=null!==(n=null===(t=this._campaign)||void 0===t?void 0:t.layout)&&void 0!==n?n:null===(a=this.template)||void 0===a?void 0:a.layoutViewState;if(s)try{const e=o.ViewLayout.fromViewState(s);i.loadLayout(e)}catch(e){console.error(e)}i.dataFrame.onFilterChanged.subscribe(e=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=r.getOptions().look.filters}),setTimeout(()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=r.getOptions().look.filters},300),e&&e()}),300),i.parentCall=this.parentCall,i}getSummary(){var e,i,n,o,a,r,s;const l=null!==(i=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==i?i:this.campaignProps;return Object.assign(Object.assign({Template:null!==(o=null===(n=this.template)||void 0===n?void 0:n.name)&&void 0!==o?o:"Molecules","File path":t.divH([t.link(null!==(a=this._dfName)&&void 0!==a?a:"-",()=>this.download(this.dataFrame,"molecules"),x)],{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":t.divH([t.link(null!==(s=null===(r=this.dataFrame)||void 0===r?void 0:r.filter.trueCount.toString())&&void 0!==s?s:"0",()=>{this.download(this.dataFrame,"hits",!0)},x)],{style:{alignItems:"center"}})})}saveCampaign(i){return Ke(this,arguments,void 0,function*(i,n=!0){var a,r,l,d,c,u,p,m,h,v;const f=this.campaignId,g=this.filterSettings,y=this.template.name,w=this.dataFrame,b=`System:AppData/HitTriage/Hit Triage/campaigns/${f}/`,C=null!=f?f:yield function(e){return Ye(this,void 0,void 0,function*(){return new Promise(i=>Ye(this,void 0,void 0,function*(){const n=t.input.string("Campaign name",{value:""});t.dialog("Save Campaign").add(t.div(n.root)).onOK(function(){n.value&&""!==n.value?i(n.value):i(e)}).show()}))})}(f),A={};w.columns.toList().forEach(e=>A[e.name]=e.semType);const T={};w.columns.toList().forEach(e=>T[e.name]=e.type);const S=null!==(r=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==r?r:e.shell.user.id,x=null!==(d=null===(l=this.campaign)||void 0===l?void 0:l.permissions)&&void 0!==d?d:Be,I={name:C,templateName:y,filters:null!=g?g:{},ingest:{type:"File",query:`${b}${s}`,molColName:this.molColName},status:null!==(u=null!=i?i:null===(c=this.campaign)||void 0===c?void 0:c.status)&&void 0!==u?u:"In Progress",createDate:null!==(m=null===(p=this.campaign)||void 0===p?void 0:p.createDate)&&void 0!==m?m:ee(new Date),campaignFields:null!==(v=null===(h=this.campaign)||void 0===h?void 0:h.campaignFields)&&void 0!==v?v:this.campaignProps,columnSemTypes:A,rowCount:w.rowCount,filteredRowCount:w.filter.trueCount,template:this.template,columnTypes:T,authorUserId:S,permissions:x};if(this.campaign=I,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),I;const N=o.DataFrame.fromColumns(w.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv();yield Gt.files.writeAsText(`Hit Triage/campaigns/${f}/${s}`,N);const E=this._pickView.saveLayout();return E?I.layout=E.viewState:e.shell.warning("Layout cound not be saved"),yield Gt.saveCampaignJson(this.appName,I),n&&e.shell.info("Campaign saved successfully."),I})}}function Ze(i,n=!1){var a,r;const s=o.DataFrame.create(1);if(n){const e=s.columns.addNew(v,o.TYPE.STRING);e.semType=o.SEMTYPE.MACROMOLECULE,e.meta.units="helm",e.setTag("units","helm"),e.setTag("cell.renderer","helm"),e.setTag(".alphabetIsMultichar","true")}const l=s.columns.addNew(h,o.TYPE.STRING);l.semType=o.SEMTYPE.MOLECULE,l.meta.units=o.UNITS.Molecule.SMILES,l.set(0,null),(null===(a=null==i?void 0:i.stages)||void 0===a?void 0:a.length)>0&&s.columns.addNew(m,o.TYPE.STRING).set(0,i.stages[0]),s.columns.addNew(f,o.TYPE.STRING);const d=i.campaignFields.map(e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e).map(e=>o.Property.fromOptions(Object.assign({name:e.name,type:ye[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{}))),c={},u=t.input.string("Campaing Name",{tooltipText:"New campaign name. If empty, campaign code will be used."}),p=t.input.form(c,d);p.prepend(u.root),p.classList.remove("ui-form");const g=t.div([...(null===(r=i.campaignFields)||void 0===r||r.length,[]),p]),y=t.buttonsInput([]);return g.appendChild(y),{promise:new Promise(n=>{const o=t.bigButton(T,()=>{for(const t of i.campaignFields)if(t.required&&(!c[t.name]||""===c[t.name]))return void e.shell.error(`Field '${t.name}' is required`);n({df:s,campaignProps:c,name:u.value})});y.appendChild(o)}),root:g,cancelPromise:new Promise(e=>{t.button(I,()=>e())})}}var Xe=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};function et(i,n){return Xe(this,void 0,void 0,function*(){var a,r,s,l,d,c,p,m,h,v,f;const g=yield Gt.files.list(`${i.appName}/templates`);let b=!1,C=!1;const A=g.map(e=>e.name.slice(0,-5)),T=[];for(const e of g)try{const t=JSON.parse(yield Gt.files.readAsText(e));T.push(t.key)}catch(e){console.error(e)}const x=Array.from(new Set(o.Func.find({meta:{role:u}}).concat(o.Func.find({tags:[u]})))),N={};x.forEach(e=>{var t;N[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const E=t.input.choice("Submit function",{value:null,items:[null,...Object.keys(N)]});E.nullable=!0,E.value=null!==(r=null===(a=null==n?void 0:n.submit)||void 0===a?void 0:a.fName)&&void 0!==r?r:null,E.setTooltip("Select function to be called upon submitting");const F=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),_=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),P=Ie();function L(){var e,t,i,n;if(""===O.value||A.includes(null!==(t=null===(e=O.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=O.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=O.input.offsetWidth)&&void 0!==n?n:0;F.style.marginLeft=`${e}px`,F.style.width=`${t}px`,F.style.opacity="100%",F.style.borderTop="1px solid red",b=!0}else F.style.borderTop="none",F.style.opacity="0%",b=!1}const O=t.input.string("Name",{value:null!==(s=null==n?void 0:n.name)&&void 0!==s?s:"",onValueChanged:L});function V(){var e,t,i,n;if(""===k.value||T.includes(null!==(t=null===(e=k.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;_.style.marginLeft=`${e}px`,_.style.width=`${t}px`,_.style.borderTop="1px solid red",_.style.opacity="100%",C=!0}else _.style.opacity="0%",_.style.borderTop="none",C=!1}const k=t.input.string("Key",{value:null!==(l=null==n?void 0:n.key)&&void 0!==l?l:"",onValueChanged:V});k.setTooltip("Template key used for campaign prefix"),O.setTooltip("Template name"),O.root.style.borderBottom="none",k.root.style.borderBottom="none",F.style.opacity="0%",_.style.opacity="0%";let B=null;const M={compute:{descriptors:{enabled:!0,args:null!==(p=null===(c=null===(d=null==n?void 0:n.compute)||void 0===d?void 0:d.descriptors)||void 0===c?void 0:c.args)&&void 0!==p?p:[]},functions:null!==(h=null===(m=null==n?void 0:n.compute)||void 0===m?void 0:m.functions)&&void 0!==h?h:[]}},D=yield Te(i,e=>{B=e},()=>null,M,!1);D.root.classList.add("hit-triage-new-template-functions-input");const R=Fe(null==n?void 0:n.campaignFields),j=tt(null==n?void 0:n.stages),U=t.divV([t.divV([O,F]),t.divV([k,_]),P.dataFileInput,R.fieldsDiv]),$=t.h2("Stages");t.tooltip.bind($,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=t.h2("Compute");t.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=t.div([t.h2("Details"),U,$,j.fieldsDiv,H,D.root,t.h2("Submit"),E.root],"ui-form"),G=t.buttonsInput([]);q.appendChild(G);const Y=null!==(f=null===(v=G.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==f?f:G,W=new Promise(e=>{const i=t.button(I,()=>e());Y.appendChild(i)}),J=new Promise(n=>{const o=t.bigButton(S,()=>function(){return Xe(this,void 0,void 0,function*(){var t,o,a,r,s,l,d;if(L(),V(),D.okProxy(),b||!O.value||""===O.value)return void e.shell.error("Template name is empty or already exists");if(C||!k.value||""===k.value)return void e.shell.error("Template key is empty or already exists");const c=E.value?N[E.value]:void 0,u=Object.assign({name:O.value,key:k.value,campaignFields:R.getFields(),stages:j.getFields(),layoutViewState:null!==(t=P.getLayoutViewState())&&void 0!==t?t:void 0,localLayoutPath:null!==(o=P.getLocalFilePath())&&void 0!==o?o:void 0,compute:{descriptors:{enabled:!!(null===(a=null==B?void 0:B.descriptors)||void 0===a?void 0:a.length),args:null!==(r=null==B?void 0:B.descriptors)&&void 0!==r?r:[]},functions:Object.entries(null!==(s=null==B?void 0:B.externals)&&void 0!==s?s:{}).map(([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(l=null==B?void 0:B.scripts)&&void 0!==l?l:{}).filter(([e,t])=>e.startsWith(y)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(d=null==B?void 0:B.queries)&&void 0!==d?d:{}).filter(([e,t])=>e.startsWith(w)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})}},c?{submit:{fName:c.name,package:fe(c)}}:{});yield function(e,t){return Xe(this,void 0,void 0,function*(){yield Gt.files.writeAsText(`${t}/templates/${e.name}.json`,JSON.stringify(e))})}(u,i.appName),e.shell.info("Template created successfully"),n(u)})}());Y.appendChild(o)});return{root:q,template:J,cancelPromise:W}})}function tt(e){const t=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING})],i=new xe(t,e?e.map(e=>({Name:e})):void 0,{horizontalInputNames:!0});let n={};return i.onItemAdded.subscribe(e=>{n={}}),i.onAddingItemChanged.subscribe(e=>{e&&(n=e.item)}),{getFields:function(){const e=i.items.filter(e=>e.Name).map(e=>e.Name);return n.Name&&""!==n.Name&&e.push(n.Name),e},fieldsDiv:i.root,itemsGrid:i}}var it=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class nt extends Pe{constructor(t){super(t),this.currentGroupping="None",this.campaignsTableRoot=null,this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Gt.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(Gt.webRoot+"README_HD.md")}getAppHeader(){return Ve.appHeader({iconPath:Gt.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"})}refreshCampaignsTable(){return it(this,void 0,void 0,function*(){if(null!=this.campaignsTableRoot){t.setUpdateIndicator(this.campaignsTableRoot,!0);try{const e=yield this.getCampaignsTable();t.setUpdateIndicator(this.campaignsTableRoot,!1),t.empty(this.campaignsTableRoot),this.campaignsTableRoot.appendChild(e)}catch(t){e.shell.error("Failed to update campaigns table"),console.error(t)}finally{t.setUpdateIndicator(this.campaignsTableRoot,!1)}}})}init(e){return it(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const i=t.h1(N),n=t.h1(E,{style:{marginLeft:"10px"}}),a=this.getAppHeader(),r=t.div(),s=t.divH([]),l=t.div([s,r],"ui-form"),d=yield this.getCampaignsTable();this.campaignsTableRoot=t.div([d],{style:{position:"relative"}});const c=t.iconFA("layer-group",()=>it(this,void 0,void 0,function*(){const e=o.Menu.popup();Object.values(B).forEach(t=>{e.item(t,()=>it(this,void 0,void 0,function*(){ue(t),yield this.refreshCampaignsTable()}))});const t=e.group("Campaign Fields"),i=yield Gt.loadCampaigns(this.app.appName,this.deletedCampaigns),n=new Set;Object.values(i).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>n.add(e))}),Array.from(n).forEach(e=>{t.item(e,()=>it(this,void 0,void 0,function*(){ue(`campaignFields.${e}`),yield this.refreshCampaignsTable()}))}),e.show({element:m,x:120,y:m.offsetTop+30})}));c.style.marginBottom="9px",c.style.marginLeft="8px",c.style.fontSize="15px",c.style.color="var(--blue-1)",t.tooltip.bind(c,()=>`Group Campaigns. Current: ${this.currentGroupping}`);const u=t.iconFA("eye",()=>it(this,void 0,void 0,function*(){const e=o.Menu.popup(),t=yield Gt.loadCampaigns(this.app.appName,this.deletedCampaigns),i=Object.assign({},M);delete i.Name,Object.values(t).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>{i[`campaignFields.${e}`]=t=>{var i,n;return null!==(n=null===(i=t.campaignFields)||void 0===i?void 0:i[e])&&void 0!==n?n:""}})});const n=pe().reduce((e,t)=>(e[t]=!0,e),{});Object.keys(i).filter(e=>!e.startsWith("campaignFields.")).forEach(t=>{var i;e.item(t,()=>{n[t]=!n[t],me(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!==(i=n[t])&&void 0!==i&&i})});const a=e.group("Campaign Fields");Object.keys(i).filter(e=>e.startsWith("campaignFields.")).forEach(e=>{var t;a.item(e.replace("campaignFields.",""),()=>{n[e]=!n[e],me(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!==(t=n[e])&&void 0!==t&&t})}),e.show({element:m,x:100,y:m.offsetTop+30})}));t.tooltip.bind(u,"Edit visible columns in campaigns table"),u.style.marginBottom="9px",u.style.marginLeft="8px",u.style.fontSize="15px",u.style.color="var(--blue-1)";const p=t.iconFA("sync",()=>it(this,void 0,void 0,function*(){yield this.refreshCampaignsTable()}));p.style.marginBottom="9px",p.style.marginLeft="8px",p.style.color="var(--blue-1)",t.tooltip.bind(p,()=>"Refresh campaigns table");const m=t.divH([i,u,c,p],{style:{alignItems:"center"}});Ce()(this.root).empty(),this.root.appendChild(t.div([t.divV([a,m],{style:{marginLeft:"10px"}}),this.campaignsTableRoot,n,l],{classes:"hit-triage-info-view-container"})),yield this.startNewCampaign(r,s,e)}finally{t.setUpdateIndicator(this.root,!1)}})}startNewCampaign(i,n,o){return it(this,void 0,void 0,function*(){var a;const r=(yield Gt.files.list(`${this.app.appName}/templates`)).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5));o&&!r.includes(o.name)&&r.push(o.name);let s=null,l=!0;const d=()=>it(this,void 0,void 0,function*(){if(!l)return;const e=c.value,t=o&&o.name===e?o:JSON.parse(yield Gt.files.readAsText(`${this.app.appName}/templates/${e}.json`));s=t;const n=yield this.getNewCampaignAccordeon(t);Ce()(i).empty(),i.appendChild(n)}),c=t.input.choice("Template",{value:null!==(a=null==o?void 0:o.name)&&void 0!==a?a:r[0],items:r,onValueChanged:()=>it(this,void 0,void 0,function*(){yield d()})});c.root.style.width="100%";const u=t.icons.add(()=>{this.createNewTemplate()},A),p=t.icons.copy(()=>{s&&this.createNewTemplate(s)},"Clone template"),m=t.icons.delete(()=>{!c.value||c.items.length<2||t.dialog("Delete template").add(t.divText(`Are you sure you want to delete template ${c.value}?`)).onOK(()=>it(this,void 0,void 0,function*(){try{const t=c.value;yield Gt.files.delete(`${this.app.appName}/templates/${t}.json`),l=!1,c.items=c.items.filter(e=>e!==t),c.value=c.items[0],l=!0,yield d(),e.shell.info("Template "+t+" was deleted successfully")}catch(t){l=!0,e.shell.error("Failed to delete template "+c.value),console.error(t)}})).show()},"Delete template");m.style.color="var(--blue-1)",u.style.color="#2083d5",c.addOptions(u),c.addOptions(p),c.addOptions(m),yield d(),Ce()(n).empty(),n.appendChild(c.root)})}checkCampaign(e){return it(this,void 0,void 0,function*(){var t;const i=location.search,n=new URLSearchParams(i);if(!n.has(r)&&!e)return;const o=null!=e?e:n.get(r);if(!(yield Gt.files.exists(`${this.app.appName}/campaigns/${o}/${l}`)))return;const a=JSON.parse(yield Gt.files.readAsText(`${this.app.appName}/campaigns/${o}/${l}`));if(a){if(a.authorUserId&&a.permissions&&!(yield le(a.authorUserId,a.permissions)))return void this.app.setBaseUrl();this.app.campaign=a}const s=null!==(t=a.template)&&void 0!==t?t:JSON.parse(yield Gt.files.readAsText(`${this.app.appName}/templates/${a.templateName}.json`));return yield this.app.setTemplate(s,o),e&&te(r,e),a.template=s,a})}getCampaignsTable(){return it(this,void 0,void 0,function*(){const i=yield Gt.loadCampaigns(this.app.appName,this.deletedCampaigns),n=null!==(a=de(O))&&void 0!==a?a:B.None;var a;const r=function(){const e=de(k);return e?JSON.parse(e):null}(),s=Object.values(i);r&&function(e,t){if(!t)return;const i=t.columnName in M?M[t.columnName]:e=>{var i,n,o;return null!==(o=null===(i=e.campaignFields)||void 0===i?void 0:i[null!==(n=t.columnName.replace("campaignFields.",""))&&void 0!==n?n:""])&&void 0!==o?o:""},n=new Map;e.forEach(e=>{n.set(e,i(e))});const o=Array.from(n.values()).every(e=>{var t;return ge(e)||!isNaN(Number(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:""))}),a=!o&&Array.from(n.values()).every(e=>{var t;return ge(e)||!isNaN(Date.parse(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:""))});o?e.forEach(e=>{n.set(e,ge(n.get(e))?t.ascending?1/0:-1/0:Number(n.get(e)))}):a&&e.forEach(e=>{var i,o;n.set(e,ge(n.get(e))?t.ascending?1/0:-1/0:Date.parse(null!==(o=null===(i=n.get(e))||void 0===i?void 0:i.toString())&&void 0!==o?o:""))}),e.sort((e,i)=>{const r=n.get(e),s=n.get(i);if(o||a)return t.ascending?r-s:s-r;const l=ge(r)?"":r.toString(),d=ge(s)?"":s.toString();return t.ascending?l.localeCompare(d):d.localeCompare(l)}),n.clear()}(s,r);const l=function(e,t){if(t===B.None)return{"":e};const i={};for(const n of e){const e=he(t,n);i[e]||(i[e]=[]),i[e].push(n)}return i}(s,n),d=pe();this.currentGroupping=n,this.app.existingStatuses=Array.from(new Set(s.map(e=>e.status).filter(e=>!!e)));const c=i=>{var n,a;const r=t.icons.delete(()=>it(this,void 0,void 0,function*(){t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK(()=>it(this,void 0,void 0,function*(){yield this.deleteCampaign(this.app.appName,i.name),this.deletedCampaigns.push(i.name),yield this.init()})).show()}),"Delete campaign"),s=t.iconFA("share",()=>it(this,void 0,void 0,function*(){yield new Me(i.permissions).show(t=>it(this,void 0,void 0,function*(){var n;try{i.permissions=t,null!==(n=i.authorUserId)&&void 0!==n||(i.authorUserId=e.shell.user.id),yield Gt.saveCampaignJson(this.app.appName,i),e.shell.info("Permissions updated for campaign "+i.name)}catch(t){e.shell.error("Failed to update permissions for campaign "+i.name),console.error(t)}}))}),"Manage campaign permissions");return r.style.display="none",s.style.display="none",se(null!==(n=i.authorUserId)&&void 0!==n?n:o.User.current().id,null!==(a=i.permissions)&&void 0!==a?a:Be).then(e=>{e&&(r.style.display="inline-block",s.style.display="inline-block")}),r.style.color="var(--blue-1)",s.style.color="var(--blue-1)",[s,r]},u=t.table(Object.values(l).flat(),e=>{var i;return[t.link(null!==(i=e.friendlyName)&&void 0!==i?i:e.name,()=>this.setCampaign(e.name),"Continue Campaign",""),...d.map(t=>{var i,n,o;return t.startsWith("campaignFields.")?null!==(n=null===(i=e.campaignFields)||void 0===i?void 0:i[t.replace("campaignFields.","")])&&void 0!==n?n:"":null!==(o=M[t](e))&&void 0!==o?o:""}),...c(e)]},["Name",...d.map(e=>e.replace("campaignFields.","")),"",""]);return u.style.color="var(--grey-5)",u.style.marginLeft="24px",u.querySelectorAll("tr.header > td").forEach((e,i)=>{if(!e.textContent)return;const n=0===i?"Name":d[i-1];if(r&&n===r.columnName){const i=r.ascending?"↑":"↓";e.appendChild(t.span([i],{style:{fontSize:"12px",marginLeft:"2px"}}))}e.addEventListener("dblclick",()=>{let e={columnName:n,ascending:!0};var t;r&&n===r.columnName&&(e=r.ascending?{columnName:n,ascending:!1}:null),(t=e)?ce(k,JSON.stringify(t)):localStorage.removeItem(k),this.refreshCampaignsTable()})}),function(e,i,n=9){e.classList.add("hit-design-groupped-campaigns-table");const o=Object.keys(i);if(o.length<2)return e;const a=e.getElementsByTagName("tbody")[0],r=Array.from(e.getElementsByTagName("tr")).filter(e=>!e.classList.contains("header"));let s=0;const l=(e,t,i)=>{var n;for(let o=t;o<i;o++)(null===(n=r[o])||void 0===n?void 0:n.style)&&(r[o].style.display=e?"table-row":"none")};for(const e of o){const o=r[s];if(!o)break;const d=i[e].length,c=s,u=s+d,p=t.accordion(`Hit-Design-campaigns-group-${e}`).addPane(e,()=>t.div(),void 0,void 0,!1);p.root.style.marginLeft="-24px",p.root.onclick=()=>{l(p.expanded,c,u)},l(p.expanded,c,u);const m=a.insertRow(0),h=m.insertCell(0);h.appendChild(p.root),h.colSpan=n,a.insertBefore(m,o),s+=d}}(u,l),u})}setCampaign(e){return it(this,void 0,void 0,function*(){const t=yield this.checkCampaign(e);this.app.campaign=t})}getNewCampaignAccordeon(e){return it(this,void 0,void 0,function*(){const{root:t,promise:i,cancelPromise:n}=Ze(e);return i.then(t=>it(this,void 0,void 0,function*(){var i,n;this.app.clearCampaign(),this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps;const o=(null===(i=t.name)||void 0===i?void 0:i.trim())?null===(n=t.name)||void 0===n?void 0:n.trim():void 0;yield this.app.saveCampaign(!1,!0,{friendlyName:o}),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})),n.then(()=>{this.init()}),t})}createNewTemplate(i){return it(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const t=yield et(this.app,i),n=new o.ViewBase,a=e.shell.v;n.name="New Template",n.root.appendChild(t.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:r}=ie(n,this.app.appName,A,()=>it(this,void 0,void 0,function*(){e.shell.v=a,n.close()}));t.template.then(t=>it(this,void 0,void 0,function*(){yield this.init(t),n.close(),ne(n),e.shell.v=a,r.unsubscribe()})),t.cancelPromise.then(()=>it(this,void 0,void 0,function*(){r.unsubscribe(),n.close(),e.shell.v=a}))}finally{t.setUpdateIndicator(this.root,!1)}})}}class ot extends Pe{constructor(e){var i;super(e),this.name="Submit",this.statusInput=t.input.string("Status",{value:null===(i=this.app.campaign)||void 0===i?void 0:i.status,nullable:!1}),this.statusSuggestionsMenu=o.Menu.popup(),this.statusInput.root.style.marginLeft="12px",this.content=t.div(),this.statusInput.onChanged.subscribe(()=>{var e,t,i,n;this.statusSuggestionsMenu.clear();const o=(null!==(e=this.statusInput.value)&&void 0!==e?e:"").toLowerCase(),a=this.app.existingStatuses.filter(e=>{var t;return(null===(t=null==e?void 0:e.toLowerCase())||void 0===t?void 0:t.includes(o))&&(null==e?void 0:e.toLowerCase())!==o}).filter((e,t)=>t<5);if(a.length){if(a.forEach(e=>{this.statusSuggestionsMenu.item(e,()=>{this.statusInput.value=e,this.statusSuggestionsMenu.root.remove(),this.statusInput.root.focus()})}),null===(t=this.content.parentElement)||void 0===t?void 0:t.parentElement){const e=this.statusInput.root.offsetLeft+(null!==(n=null===(i=this.statusInput.input)||void 0===i?void 0:i.offsetLeft)&&void 0!==n?n:0),t=this.statusInput.root.offsetTop+this.statusInput.root.offsetHeight+this.content.parentElement.offsetTop;this.statusSuggestionsMenu.show({element:this.content.parentElement.parentElement,x:e,y:t})}}else this.statusSuggestionsMenu.root.remove()})}getStatus(){var e,t,i;return null!==(i=null!==(e=this.statusInput.value)&&void 0!==e?e:null===(t=this.app.campaign)||void 0===t?void 0:t.status)&&void 0!==i?i:"No Status"}render(){var e,i,n;this.statusInput.value=null!==(i=null===(e=this.app.campaign)||void 0===e?void 0:e.status)&&void 0!==i?i:"",t.empty(this.content),this.content=t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())]),this.statusInput.root]);const a=t.dialog("Submit");a.add(this.content),a.addButton("Save",()=>{this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),a.close()}),a.show();const r=Array.from(new Set(o.Func.find({meta:{role:u}}).concat(o.Func.find({tags:[u]})))),s=r.reduce((e,t)=>{var i;return e[null!==(i=t.friendlyName)&&void 0!==i?i:t.name]=t,e},{});if(r.length>0){const e=this.app.submitParams,i=e?r.find(t=>t.name===e.fName&&fe(t)==e.package):void 0,o=null!==(n=null==i?void 0:i.friendlyName)&&void 0!==n?n:null==i?void 0:i.name,l=t.input.choice("Submit function",{value:o,items:[...Object.keys(s)],nullable:!0});l.onChanged.subscribe(()=>{var e,t;const i=s[null!==(e=l.value)&&void 0!==e?e:""];this.app.campaign.template.submit=i?{fName:i.name,package:fe(i)}:void 0,null===(t=a.getButton("Submit"))||void 0===t||t.remove(),i&&a.addButton("Submit",()=>{this.submit(),a.close()},void 0,"Submit the campaign file to the specified function")}),l.fireChanged(),this.content.appendChild(l.root)}}onActivated(){}submit(){return t=this,i=void 0,a=function*(){const t=this.app.submitParams;if(!t)return void e.shell.error("No submit function selected. Please select a function to submit the campaign.");const i=o.Func.find({name:t.fName,package:t.package})[0];if(!i)return void e.shell.error(`Function ${t.fName} not found.`);const n=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield i.apply({df:n,molecules:this.app.molColName}),this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),e.shell.info("Submitted successfully.")},new((n=void 0)||(n=Promise))(function(e,o){function r(e){try{l(a.next(e))}catch(e){o(e)}}function s(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n(function(e){e(i)})).then(r,s)}l((a=a.apply(t,i||[])).next())});var t,i,n,a}}var at=i(542),rt={};rt.styleTagTransform=K(),rt.setAttributes=Y(),rt.insert=q().bind(null,"head"),rt.domAPI=$(),rt.insertStyleElement=J(),j()(at.A,rt),at.A&&at.A.locals&&at.A.locals;function st(i,n){var a,r,s,l,d,c,u,p,h,v;const f=null===(a=i.campaign)||void 0===a?void 0:a.tilesViewerFormSketch;let g=null;if(f&&f.length>0)try{g=JSON.parse(f)}catch(e){console.error("Failed to parse sketch state string",e)}g&&g.elementStates&&(null!==(r=g.elementStates.length)&&void 0!==r?r:0)>0&&(g.elementStates=g.elementStates.filter(e=>{var t;return(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.column)&&i.dataFrame.col(e.viewerSettings.column)}),g.elementStates.forEach(e=>{var t;(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.table)&&(e.viewerSettings.table=i.dataFrame.name)}));const y=Object.assign({lanesColumnName:m,lanes:i.stages},(null!==(l=null===(s=null==g?void 0:g.elementStates)||void 0===s?void 0:s.length)&&void 0!==l?l:0)>0?{sketchState:g}:{}),w=n();if(!w)return void e.shell.error("Failed to create tiles viewer. table view is not available.");let b=null;const C=t.dialog("Progress Tracker");try{b=w.addViewer(o.VIEWER.TILE_VIEWER,y);const e=b.getOptions();e.look.sketchState=(null!==(c=null===(d=null==g?void 0:g.elementStates)||void 0===d?void 0:d.length)&&void 0!==c?c:0)>0?g:null,b.setOptions(e),b.copyViewersLook(b)}catch(t){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",t),b&&(b.close(),b.detach()),b=w.addViewer(o.VIEWER.TILE_VIEWER,{lanesColumnName:m,lanes:i.stages})}if(!b)return void e.shell.error("Failed to create tiles viewer. check the console for more details.");let A=null;const T=()=>{try{b.detach(),b.close()}catch(e){}};C.add(b.root),C.addButton("Modify Stages",()=>{null==A||A.close();const o=tt(i.stages);A=t.dialog("Modify Stages").add(o.fieldsDiv).onOK(()=>{return a=this,r=void 0,l=function*(){T(),t.setUpdateIndicator(C.root,!0);try{yield i.setStages(o.getFields()),t.setUpdateIndicator(C.root,!1),C.close(),yield new Promise(e=>setTimeout(()=>{e(),st(i,n)},100))}catch(t){e.shell.error("Failed to update stages. check the console for more details."),console.error("Failed to update stages",t)}finally{(null==C?void 0:C.root)&&document.contains(C.root)&&C.close()}},new((s=void 0)||(s=Promise))(function(e,t){function i(e){try{o(l.next(e))}catch(e){t(e)}}function n(e){try{o(l.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof s?o:new s(function(e){e(o)})).then(i,n)}o((l=l.apply(a,r||[])).next())});var a,r,s,l}).show(),A.root.classList.add("hit-design-stage-editing-dialog")},0);const S=e.events.onCurrentViewChanged.subscribe(()=>{e.shell.v===w?C.root.style.display="flex":C.root.style.setProperty("display","none","important")}),x=null===(p=null===(u=i.dataFrame)||void 0===u?void 0:u.col(m))||void 0===p?void 0:p.version,I=C.onClose.subscribe(()=>{var t,n;I.unsubscribe(),S.unsubscribe(),null==A||A.close();try{const e=b.props.sketchState;if(e&&"object"==typeof e){const t=JSON.stringify(e);i.campaign&&(i.campaign.tilesViewerFormSketch=t)}}catch(t){e.shell.error("Failed to save sketch state. check the console for more details."),console.error("Failed to save sketch state",t)}T(),null!=x&&(null===(n=null===(t=i.dataFrame)||void 0===t?void 0:t.col(m))||void 0===n?void 0:n.version)!==x&&i.saveCampaign()});C.showModal(!0),null===(h=C.getButton("CANCEL"))||void 0===h||h.remove(),C.onOK(()=>{}),null===(v=document.querySelector(".d4-modal-background"))||void 0===v||v.remove()}const lt=rxjs.operators;var dt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};const ct="defaultCampaignFolder",ut="System.AppData/HitTriage";function pt(t){return dt(this,void 0,void 0,function*(){if(!t)return[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean);try{const i=JSON.parse(t);return(yield Promise.all(i.map(t=>e.dapi.groups.find(t)))).filter(Boolean)}catch(t){return console.error(t),[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean)}})}var mt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};function ht(e){var t;const i=null===(t=Gt.meta)||void 0===t?void 0:t.sok;if(!i)throw new Error("Secret key for SMILES obfuscation is not set");let n="";for(let t=0;t<e.length;t++){const o=e.charCodeAt(t),a=i.charCodeAt(t%i.length);n+=String.fromCharCode(o^a)}return btoa(n)}function vt(){var e,t,i;const n=o.User.current();return null!==(i=null!==(t=null!==(e=null==n?void 0:n.login)&&void 0!==e?e:null==n?void 0:n.friendlyName)&&void 0!==t?t:n.name)&&void 0!==i?i:"unknown user"}function ft(t,i,n){return mt(this,void 0,void 0,function*(){const o=Gt.convertToSmiles(t);if(!o||""===o||"MALFORMED_INPUT_VALUE"===o)return"";const a=ht(o),r=yield Ue.addMolecule(a,n,i,vt());return 0!==r.rowCount&&r.col("vid")?r.col("vid").getString(0):(e.shell.error("Molecule registration returned no data"),"")})}function gt(t,i,n){return mt(this,void 0,void 0,function*(){const o=new Map,a=new Map;if(t.forEach((e,t)=>{const i=Gt.convertToSmiles(e);i&&""!==i&&"MALFORMED_INPUT_VALUE"!==i&&(a.has(i)||a.set(i,[]),a.get(i).push(t))}),0===a.size)return o;const r=Array.from(a.keys());for(let s=0;s<r.length;s+=50){const l=r.slice(s,s+50);if(0!==l.length)try{const e=l.map(e=>ht(e)),r=yield Ue.addMolecules(e,n,i,vt());if(!r||r.rowCount!==l.length||!r.col("vid"))throw console.error("Molecule registration returned incomplete data for batch",`${s}-${s+l.length}`,`Batch size: ${l.length}, Result rows: ${null==r?void 0:r.rowCount}. Vid column found: ${!!(null==r?void 0:r.col("vid"))}`),new Error("Resulting molecule registration has no or incomplete data");const d=r.col("vid").toList();for(let e=0;e<r.rowCount;e++){const i=a.get(l[e]),n=d[e];for(const e of i)o.set(t[e],n)}}catch(t){e.shell.error("Error registering molecules batch. see console for details."),Gt.logger.error(t)}}return o})}var yt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class wt extends Ge{get infoView(){return this._infoView}get version(){var e,t;return null!==(t=null===(e=this._campaign)||void 0===e?void 0:e.version)&&void 0!==t?t:0}constructor(e,t="Hit Design",i=e=>new nt(e)){super(e,t),this._designViewName="Design",this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns`,this._molColName=h,this.campaignProps={},this.existingStatuses=[],this._refreshIconTooltip="Refresh Campaign",this._updateCheckIntervalId=null,this._needsRefresh=!1,this._lastExpiresTimeString=null,this._refreshCampaignIcon=null,this._gridSubs=null,this._isSaving=!1,this._infoView=i(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.subs.push(this.multiView.tabs.onTabChanged.subscribe(e=>{this.multiView.currentView instanceof Pe&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=e,this.mainView=this.multiView,this._initViewSubs()}handleJoiningDataframe(i){return yt(this,void 0,void 0,function*(){var n,a,r,s,l,d;const c=i.columns.bySemTypeAll(o.SEMTYPE.MOLECULE);if(!c||0===c.length)return void e.shell.error("No molecule column found");let u=null;if(c.length>1){const i=c.map(e=>e.name),o=null!==(n=c.find(e=>{var t,i;return"smiles"===(null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.toLowerCase())||"molecule"===(null===(i=null==e?void 0:e.name)||void 0===i?void 0:i.toLowerCase())}))&&void 0!==n?n:c[0],a=t.input.choice("Primary Molecule Column",{items:i,value:o.name,nullable:!1}),r=new Promise(e=>{t.dialog("Select Primary Molecule Column").add(t.divText("Multiple molecule columns found. Please select the primary molecule column to be used for calculations.")).add(a).onOK(()=>e(a.value)).onCancel(()=>e(null)).show()});if(u=yield r,!u)return void e.shell.info("Operation cancelled by user")}else u=c[0].name;const p=i.col(u);if(!p)return void e.shell.error("No molecule column found");const v=null!==(s=null===(r=null===(a=this.campaign)||void 0===a?void 0:a.template)||void 0===r?void 0:r.compute)&&void 0!==s?s:null===(l=this.template)||void 0===l?void 0:l.compute;if(!v)return void e.shell.warning("No compute functions found");const g=p.toList(),y=v.descriptors.enabled&&null!==(d=v.descriptors.args)&&void 0!==d?d:[],w=yield Je(g,y,v.functions,v.scripts,v.queries);if(this.unionDataframes(w,i,h,p.name),this.stages.length>0&&this.dataFrame.columns.contains(m)){const e=i.columns.getOrCreate(m,o.TYPE.STRING);for(let t=0;t<i.rowCount;t++)e.isNone(t)&&e.set(t,this.stages[0],!1)}i.columns.contains(f)&&i.columns.remove(f);const b=i.columns.addNewString(f),C=yield gt(g,this._campaignId,this.appName);for(let e=0;e<i.rowCount;e++){const t=p.get(e),i=C.get(t);i&&b.set(e,i)}this.unionDataframes(i,this.dataFrame,p.name,this.molColName),this.saveCampaign(!1)})}get submitParams(){var e,t,i,n;return null!==(i=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.submit)&&void 0!==i?i:null===(n=this.template)||void 0===n?void 0:n.submit}_initViewSubs(){this.multiView.subs.push(e.events.onCurrentViewChanged.subscribe(()=>yt(this,void 0,void 0,function*(){var t,i,n,o;try{if(e.shell.v===this._designView){e.shell.windows.showHelp=!1,this.setBaseUrl(),te(a,null!==(n=null!==(t=this._campaignId)&&void 0!==t?t:null===(i=this._campaign)||void 0===i?void 0:i.name)&&void 0!==n?n:"");const{sub:r}=ie(e.shell.v,this.appName,null===(o=e.shell.v)||void 0===o?void 0:o.name,()=>{var t;e.shell.v=this.mainView,null===(t=this._designView)||void 0===t||t.close(),this._infoView.init(),r.unsubscribe()})}else e.shell.v===this.mainView&&this.setBaseUrl()}catch(e){console.error(e)}}))),this.multiView.subs.push(e.events.onFileImportRequest.subscribe(t=>{var i,n;if(!e.shell.tv||!this._designView||e.shell.tv!==this._designView)return;if(!(null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.file))return;const o=t.args.file;((null===(n=o.name)||void 0===n?void 0:n.endsWith(".csv"))||Ge.molFileExtReaders.some(e=>{var t;return null===(t=o.name)||void 0===t?void 0:t.endsWith(e.ext)}))&&(t.preventDefault(),this.handleUploadingDataframe(o))}))}handleUploadingDataframe(i){return yt(this,void 0,void 0,function*(){var n;try{let a=null;if(i.name.endsWith(".csv"))a=o.DataFrame.fromCsv(yield i.text());else{const t=yield new Promise(e=>yt(this,void 0,void 0,function*(){const t=new FileReader;let n=null,o=null;t.onload=()=>{o=t.result?new Uint8Array(t.result):null,n&&clearTimeout(n),e(o)},t.readAsArrayBuffer(i),n=setTimeout(()=>{t.abort(),e(null)},1e4)}));if(!t)return void e.shell.error("Failed to read file");const n=Ge.molFileExtReaders.find(e=>i.name.endsWith(e.ext)).handlerFunc,o=n.inputs[0].name;a=(yield n.apply({[o]:t}))[0]}if(!a)throw new Error("Failed to read file");if(a.name=i.name.slice(0,i.name.lastIndexOf(".")),yield a.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(a),!a.columns.bySemType(o.SEMTYPE.MOLECULE))return void e.shell.addTableView(a);const r=t.dialog("Uploading table with molecules").add(t.divText("Add new table to workspace or join with existing Hit Design campaign")).addButton("Add to workspace",()=>{r.close(),e.shell.addTableView(a)}).addButton("Add to existing campaign",()=>{r.close(),this.handleJoiningDataframe(a)});null===(n=r.getButton("CANCEL"))||void 0===n||n.remove(),r.show()}catch(t){e.shell.error("Hit Design Failed to read file"),console.error(t)}})}get stages(){var e,t,i,n,o;return null!==(o=null!==(i=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.stages)&&void 0!==i?i:null===(n=this.template)||void 0===n?void 0:n.stages)&&void 0!==o?o:[]}setStages(t){return yt(this,void 0,void 0,function*(){var i;if(!this.campaign||!this.campaign.template||!this.template)return void e.shell.error("Campaign or template is not set");if(!(null==t?void 0:t.length))return void e.shell.error("Removing all stages is not allowed");const n=null===(i=this.dataFrame)||void 0===i?void 0:i.col(m);if(!n)return void e.shell.error("No stage column found");const o=[],a=new Set(t),r=[...a],s=this.dataFrame.rowCount,l=n.categories,d=n.getRawData();for(let e=0;e<s;e++){const i=l[d[e]];a.has(i)||(n.set(e,t[0],!1),o.push(i))}o.length>0&&e.shell.warning(`Some stages were removed: (${o.join(", ")}). Corresponding rows were set to stage "${t[0]}"`),this.campaign.template.stages=r,this.template.stages=r,yield this.saveCampaign(!0)})}refreshCampaign(){return yt(this,void 0,void 0,function*(){this._campaignId&&this.template?this._isSaving?e.shell.info("Campaign is being saved. Please wait a moment and try again."):(clearInterval(this._updateCheckIntervalId),this._refreshIconTooltip="Refresh Campaign",yield this.setTemplate(this.template,this._campaignId)):e.shell.warning("No campaign to refresh")})}setTemplate(i,n){return yt(this,void 0,void 0,function*(){var l,d,c,u,p,m,v,f,g,y,w;if(n){const t=`System.AppData/HitTriage/${this.appName}/campaigns`;this._filePath=null!==(c=null===(d=this.campaign)||void 0===d?void 0:d.savePath)&&void 0!==c?c:`${t}/${n}/${s}`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(u=this._campaign)||void 0===u?void 0:u.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach(([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)}),(null===(p=this._campaign)||void 0===p?void 0:p.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach(([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{this.dataFrame.changeColumnType(e,t)}catch(e){console.error(e)}})}else{(null===(l=this._designView)||void 0===l?void 0:l.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName(`${this.appName}/campaigns`,i.key),te(r,n);let t=yield function(){return dt(this,void 0,void 0,function*(){var t,i;const n=null!==(t=Gt.settings)&&void 0!==t?t:yield Gt.getSettings();if(!n)return ut;const o=null!==(i=n instanceof Map?n.get(ct):n[ct])&&void 0!==i?i:ut;return(yield e.dapi.files.exists(o))?o:ut})}();t.endsWith("/")||(t+="/"),this._filePath=`${t}${this.appName}/campaigns/${n}/${s}`}if(!this.dataFrame)return e.shell.error("DataFrame is empty"),clearInterval(this._updateCheckIntervalId),void(this._updateCheckIntervalId=null);yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(v=null===(m=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===m?void 0:m.name)&&void 0!==v?v:h,this._campaignId=n,this.template=i,null!==(f=this._submitView)&&void 0!==f||(this._submitView=new ot(this)),e.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const b=this.designView;this.currentDesignViewId=b.name,this.setBaseUrl(),te(a,null!==(w=null!==(g=this._campaignId)&&void 0!==g?g:null===(y=this._campaign)||void 0===y?void 0:y.name)&&void 0!==w?w:""),this.campaign&&(this.campaign.template=i),Ue.getLastModified(this.appName,this._campaignId).then(i=>{var n;const o=null===(n=null==i?void 0:i.col("updated_at"))||void 0===n?void 0:n.getString(0);this._lastExpiresTimeString=null!=o?o:null,this._needsRefresh=!1,clearInterval(this._updateCheckIntervalId);let a=!1;this._updateCheckIntervalId=setInterval(()=>yt(this,void 0,void 0,function*(){var i;if(!a&&!this._needsRefresh){if(a=!0,this._designView&&!Array.from(e.shell.tableViews).some(e=>e===this._designView))return clearInterval(this._updateCheckIntervalId),console.log("Clearing campaign update check interval"),this._updateCheckIntervalId=null,void(a=!1);if(this._campaignId&&this.template&&!this._isSaving&&!this.isJoining&&this._designView&&e.shell.v===this._designView){try{const e=yield Ue.getLastModified(this.appName,this._campaignId),n=null===(i=null==e?void 0:e.col("updated_at"))||void 0===i?void 0:i.getString(0);if(!n)return void(a=!1);this._lastExpiresTimeString!==n&&this._refreshCampaignIcon&&(this._lastExpiresTimeString=n,t.hints.addHintIndicator(this._refreshCampaignIcon,!0,1e4),this._refreshIconTooltip="New changes available. Click to refresh campaign.",this._lastExpiresTimeString=n,this._needsRefresh=!0)}catch(e){console.error(e)}a=!1}else a=!1}}),3e3)}).catch(e=>console.error(e))})}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}set designViewName(e){this._designViewName=e,this._designView&&(this._designView.name=e)}get molColName(){var e,t,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(n=null===(i=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===i?void 0:i.name)&&void 0!==n?n:h}get campaign(){return this._campaign}set campaign(e){this._campaign=e}clearCampaign(){this._campaign=void 0}cacheDuplicateVIDs(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(f);if(!t)return void(this._duplicateVidCache=void 0);const i=t.version,n=new Uint32Array(t.categories.length).fill(0),o=t.getRawData().subarray(0,t.length);o.forEach(e=>n[e]++),this._duplicateVidCache={colVersion:i,valueCounts:n,indexes:o}}get duplicateVidCache(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(f);if(t)return this._duplicateVidCache&&t.version===this._duplicateVidCache.colVersion||this.cacheDuplicateVIDs(),this._duplicateVidCache}performSingleCellCalculations(e,t){return yt(this,void 0,void 0,function*(){const i=this.template.compute;if(!t||""===t)return;const n=yield Je([t],i.descriptors.args,i.functions,i.scripts,i.queries);for(const t of n.columns.toList())t.name!==h&&(this.dataFrame.columns.contains(t.name)||(this.dataFrame.columns.addNew(t.name,t.type).semType=t.semType),this.dataFrame.col(t.name).set(e,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(!1)})}initDesignViewRibbons(i,n,a=!1){var r,s,l;const d=e.events.onViewRemoved.subscribe(e=>{e.id===(null==i?void 0:i.id)&&(n.forEach(e=>e.unsubscribe()),d.unsubscribe())});let c=null==i?void 0:i.getRibbonPanels();if(c&&!oe(c)){setTimeout(()=>{const{sub:t}=ie(i,this.appName,i.name,()=>{e.shell.v=this.mainView,null==i||i.close(),this._infoView.init(),t.unsubscribe()})},1e3);const n=()=>yt(this,void 0,void 0,function*(){var e;Te(this,e=>yt(this,void 0,void 0,function*(){var n,o,a,r,s,l,d,c,u,p;const m=this.template.compute.descriptors.args,h=this.template.compute.functions,v=null!==(n=this.template.compute.scripts)&&void 0!==n?n:[],f=null!==(o=this.template.compute.queries)&&void 0!==o?o:[],g=e.descriptors,b={descriptors:{enabled:!!(null===(a=null==e?void 0:e.descriptors)||void 0===a?void 0:a.length),args:null!==(r=null==e?void 0:e.descriptors)&&void 0!==r?r:[]},functions:Object.entries(null!==(s=null==e?void 0:e.externals)&&void 0!==s?s:{}).map(([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(l=null==e?void 0:e.scripts)&&void 0!==l?l:{}).filter(([e,t])=>e.startsWith(y)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(d=null==e?void 0:e.queries)&&void 0!==d?d:{}).filter(([e,t])=>e.startsWith(w)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})};this.template.compute=b,this.campaign.template=this.template;const C=g.filter(e=>!m.includes(e)),A={};Object.entries(null!==(c=null==e?void 0:e.externals)&&void 0!==c?c:{}).filter(([e,t])=>{const i=h.find(t=>`${t.package}:${t.name}`===e);return!i||!Object.entries(t).every(([e,t])=>i.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 i=v.find(t=>`${y}:${t.name}:${t.id}`===e);return!i||!Object.entries(t).every(([e,t])=>i.args[e]===t)}).forEach(([e,t])=>{T[e]=t});const S={};Object.entries(null!==(p=null==e?void 0:e.queries)&&void 0!==p?p:{}).filter(([e,t])=>{const i=f.find(t=>`${w}:${t.name}:${t.id}`===e);return!i||!Object.entries(t).every(([e,t])=>i.args[e]===t)}).forEach(([e,t])=>{S[e]=t}),t.setUpdateIndicator(i.grid.root,!0);try{yield ze({descriptors:C,externals:A,scripts:T,queries:S},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{t.setUpdateIndicator(i.grid.root,!1),this.saveCampaign(!1)}}),()=>null,null===(e=this.campaign)||void 0===e?void 0:e.template,!0)}),d=t.iconFA("wrench",n,"Calculate additional properties"),u=t.icons.add(()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)},"Add new row"),p=t.iconSvg("view-layout",()=>{this.applyTemplateLayout(i)},"Apply template layout "+((null===(r=this.template)||void 0===r?void 0:r.localLayoutPath)?"(Loaded from mounted file storage)":"(Static)"));this._refreshCampaignIcon=t.icons.sync(()=>yt(this,void 0,void 0,function*(){this.refreshCampaign()})),t.tooltip.bind(this._refreshCampaignIcon,()=>this._refreshIconTooltip);const m=t.iconFA("share",()=>yt(this,void 0,void 0,function*(){var e;yield new Me(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show(e=>{this.campaign.permissions=e,this.saveCampaign(!0)})}),"Edit campaign permissions"),h=t.bigButton("Progress tracker",()=>{st(this,()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null})}),v=t.bigButton("Submit...",()=>{var e;null===(e=this._submitView)||void 0===e||e.render()}),f=o.Func.find({meta:{role:"HitDesignerFunction"}}).filter(e=>1===e.outputs.length&&e.outputs[0].propertyType===o.TYPE.DATA_FRAME);v.classList.add("hit-design-submit-button");const g=[v];if(this.stages.length>0&&g.unshift(h),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),((null===(s=this.template)||void 0===s?void 0:s.layoutViewState)||(null===(l=this.template)||void 0===l?void 0:l.localLayoutPath))&&g.unshift(p),this.hasEditPermission&&g.unshift(m),f.length>0&&a){const i=f[0],n=t.iconFA("pen-nib",()=>yt(this,void 0,void 0,function*(){var n;const a={};if(i.inputs.length>0&&this.dataFrame&&this.dataFrame.currentRowIdx>=0&&i.inputs[0].semType===o.SEMTYPE.MOLECULE){const e=Gt.convertToSmiles(null===(n=this.dataFrame.col(this.molColName))||void 0===n?void 0:n.get(this.dataFrame.currentRowIdx));e&&(a[i.inputs[0].name]=e)}const r=i.prepare(a),s=yield r.getEditor();t.dialog(i.friendlyName).add(s).onOK(()=>yt(this,void 0,void 0,function*(){const t=o.TaskBarProgressIndicator.create(`Running ${i.friendlyName}`);try{yield r.call();const n=r.getOutputParamValue();if(!n||!n.rowCount)return e.shell.warning(`${i.friendlyName} returned an empty result`),void t.close();yield n.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(n),yield this.handleJoiningDataframe(n)}catch(t){e.shell.error(`Failed to run ${i.friendlyName}`),Gt.logger.error(t)}finally{t.close()}})).show()}),i.description?i.description:i.friendlyName);g.unshift(n)}g.unshift(d),g.unshift(u),g.unshift(this._refreshCampaignIcon),c.push(g),c.some(e=>{var t;const i=null!==(t=null==e?void 0:e.findIndex(e=>{var t;return"save"===(null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.toLowerCase())}))&&void 0!==t?t:-1;return-1!==i&&(e.splice(i,1),!0)}),c=c.filter(e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0}),i.setRibbonPanels(c)}return i}applyTemplateLayout(t){return yt(this,void 0,void 0,function*(){var i,n;if(t){if(null===(i=this.template)||void 0===i?void 0:i.localLayoutPath)try{const i=yield e.dapi.files.readAsText(this.template.localLayoutPath),n=o.ViewLayout.fromJson(i);return void t.loadLayout(n)}catch(t){e.shell.error("Failed to apply layout from mounted file storage. Falling back to static layout"),Gt.logger.error(t)}if(null===(n=this.template)||void 0===n?void 0:n.layoutViewState)try{const e=o.ViewLayout.fromViewState(this.template.layoutViewState);t.loadLayout(e)}catch(t){e.shell.error("Failed to apply template layout. Check console for more details."),Gt.logger.error(t)}else e.shell.error("No layout found")}else e.shell.error("No view found")})}getDesignView(){var t,i,n,a,r,s,l;this._designView&&this._designView.close();const d=[],c=null===(t=this.dataFrame.col(this.molColName))||void 0===t?void 0:t.toList().every(e=>!e&&""===e),u=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(r=null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.friendlyName)&&void 0!==n?n:null===(a=this.campaign)||void 0===a?void 0:a.name)&&void 0!==r?r:this._designViewName,u.name=this._designViewName,u._onAdded();const p=null===(s=this._campaign)||void 0===s?void 0:s.layout;if(p)try{const e=o.ViewLayout.fromViewState(p);u.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}this.checkGrid(u),c&&e.functions.call("Chem:editMoleculeCell",{cell:u.grid.cell(this._molColName,0)}),this.initGridSubs(u,d);const h=null===(l=u.grid)||void 0===l?void 0:l.col(f);h&&(h.editable=!1);const v=this.dataFrame.col(f);return v&&(v.semType=g,v.valueComparer=(e,t)=>e===t?0:null===e?-1:null===t?1:parseInt(e.substring(1))-parseInt(t.substring(1))),d.push(this.dataFrame.onRowsAdded.pipe((0,lt.filter)(()=>!this.isJoining)).subscribe(()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const i=this.dataFrame.col(m).get(e);i&&""!==i&&!(null===(t=this.dataFrame.col(m))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(m,e,this.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=u.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)}})),d.push(e.events.onContextMenu.subscribe(t=>{var i,n,a,r,s,l,d,c,p,m,h,v;try{const e=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==u.id)return;if((null===(r=null===(a=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.item)||void 0===a?void 0:a.tableColumn)||void 0===r?void 0:r.name)!==this.molColName||!(null===(l=null===(s=null==t?void 0:t.args)||void 0===s?void 0:s.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(d=null==t?void 0:t.args)||void 0===d?void 0:d.menu;if(!f)return;f.item("Add new row",()=>{this.dataFrame.rows.addNew(null,!0)}),f.item("Duplicate molecule",()=>{var e,i,n,o;try{const a=this.dataFrame.rows.addNew(null,!0);null!=a.get(this.molColName)&&a.idx>-1&&(this.dataFrame.cell(a.idx,this.molColName).value=null!==(o=null===(n=null===(i=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===i?void 0:i.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}});const g=null===(p=null===(c=null==t?void 0:t.args)||void 0===c?void 0:c.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(h=null===(m=null==t?void 0:t.args)||void 0===m?void 0:m.item)||void 0===h?void 0:h.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",()=>yt(this,void 0,void 0,function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}})),d.push(e.events.onViewLayoutApplied.subscribe(e=>{e&&e.view===u&&this.initGridSubs(u,d)})),this.initDesignViewRibbons(u,d,!0),u.parentCall=this.parentCall,u}checkGrid(t){t.grid||(e.shell.error("Applied layout created view without grid. Resetting layout."),t.resetLayout())}initGridSubs(t,i){this._gridSubs&&this._gridSubs.grid===t.grid||(this._gridSubs&&this._gridSubs.subs.forEach(e=>e.unsubscribe()),this.checkGrid(t),t.grid?(this._gridSubs={grid:t.grid,subs:[]},(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellValueEdited.subscribe(t=>yt(this,void 0,void 0,function*(){var i,n;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===m)return void(yield this.saveCampaign(!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.molColName)return;const e=t.cell.value,o=t.tableRowIndex;if(e)try{const t=yield ft(e,this._campaignId,this.appName);this.dataFrame.col(f).set(o,t,!0)}catch(e){console.error("Failed to register molecule")}yield this.performSingleCellCalculations(o,e)}catch(t){e.shell.error("Failed to process molecule edit, check console for details"),console.error(t)}}))),(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellRender.subscribe(e=>{var t;try{const i=e.cell,n=this.duplicateVidCache;if(!i||!i.isTableCell||!i.tableColumn||!n||i.tableColumn.name!==f||(null!==(t=i.tableRowIndex)&&void 0!==t?t:-1)<0)return;n.valueCounts[n.indexes[i.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(n.indexes[i.tableRowIndex]),150))}catch(e){}})),this._gridSubs.subs.forEach(e=>i.push(e))):e.shell.error("No grid found, cannot initialize grid subscriptions"))}getSummary(){var i,n,a,r,l,d,c,u,p,m,h,v,f;const g=()=>{var e,t;const i=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===i?this._filePath:this._filePath.substring(0,i-1)},y=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);this.template&&this.template.campaignFields&&Object.entries(y).forEach(([t,i])=>{const n=this.template.campaignFields.find(e=>e.name===t);n&&"Date"===n.type&&i?"Invalid Date"!==new Date(i).toString()?y[t]=new Date(i).toLocaleDateString():i.date?y[t]=new Date(i.date).toLocaleDateString():y[t]=i:n&&n.type===o.SEMTYPE.MOLECULE&&i&&(y[t]=e.chem.drawMolecule(i))});const w=null!==(d=null!==(r=null===(a=this.campaign)||void 0===a?void 0:a.friendlyName)&&void 0!==r?r:null===(l=this.campaign)||void 0===l?void 0:l.name)&&void 0!==d?d:this.campaignId,b=function(i,n){var o;const a=t.icons.edit(()=>{var o,s,l,d,c;let u=null!==(s=null!==(o=null==n?void 0:n.tooltip)&&void 0!==o?o:i.textContent)&&void 0!==s?s:"";const p=null!==(l=null==n?void 0:n.beforeEditTextContent)&&void 0!==l?l:e=>e,m=null!==(d=null==n?void 0:n.afterEditTextContent)&&void 0!==d?d:e=>e,h=t.input.string("smth",{value:p(null!==(c=i.textContent)&&void 0!==c?c:""),onValueChanged:()=>X(this,void 0,void 0,function*(){var e;const t=yield f();setTimeout(()=>{var e,o;if(t)return h.input.classList.add("d4-invalid"),void(u=t);h.input.classList.remove("d4-invalid"),u=null!==(o=null!==(e=null==n?void 0:n.tooltip)&&void 0!==e?e:i.textContent)&&void 0!==o?o:""},100),null===(e=null==n?void 0:n.onChange)||void 0===e||e.call(n,h.value)})});t.tooltip.bind(h.input,()=>u);const v=h.root.getElementsByTagName("label").item(0);v&&v.remove(),h.root.style.width="100%";const f=()=>X(this,void 0,void 0,function*(){var e;const t=(null===(e=h.value)||void 0===e?void 0:e.trim())||(null==n?void 0:n.nullable)?null:"Field cannot be empty";return null!=t?t:(null==n?void 0:n.validator)?yield n.validator(h.value):null}),g=t.button("Save",()=>X(this,void 0,void 0,function*(){var o,s;const l=yield f();l?e.shell.error(l):(yield null===(o=null==n?void 0:n.onOk)||void 0===o?void 0:o.call(n,h.value),i.textContent=null!==(s=m(h.value))&&void 0!==s?s:"",t.empty(r),r.appendChild(i),r.appendChild(a))})),y=t.button("Cancel",()=>{var e;t.empty(r),r.appendChild(i),r.appendChild(a),null===(e=null==n?void 0:n.onCancel)||void 0===e||e.call(n)});t.empty(r),h.addOptions(y),h.addOptions(g),r.appendChild(h.root),h.input.focus()},null!==(o=null==n?void 0:n.tooltip)&&void 0!==o?o:"Edit"),r=t.divH([i,a],{style:{display:"flex",alignItems:"center"}});return a.style.marginLeft="5px",r}(t.divText(w),{tooltip:"Edit Campaign Name",nullable:!1,onOk:e=>yt(this,void 0,void 0,function*(){this.campaign.friendlyName=e,yield this.saveCampaign(!0)}),validator:e=>yt(this,void 0,void 0,function*(){return(null==e?void 0:e.trim())?null:"Campaign name can not be empty"})});return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({Name:b,Code:null!==(c=this.campaignId)&&void 0!==c?c:null===(u=this._campaign)||void 0===u?void 0:u.name,Template:null!==(m=null===(p=this.template)||void 0===p?void 0:p.name)&&void 0!==m?m:"Molecules","File Path":(()=>{const i=t.icons.edit(()=>{const n=g(),r=t.input.string("Path",{value:n}),l=r.root.getElementsByTagName("label").item(0);l&&l.remove(),r.root.style.width="100%";const d=t.button("Save",()=>yt(this,void 0,void 0,function*(){if(!(yield function(t){return X(this,void 0,void 0,function*(){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)})}(r.value)))return;const n=r.value;n.endsWith("/")?this._filePath=`${n}${this.campaignId}/${s}`:this._filePath=`${n}/${this.campaignId}/${s}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(!0),t.empty(a);const l=g();o=t.link(l,()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")},x),a.appendChild(o),a.appendChild(i)})),c=t.button("Cancel",()=>{t.empty(a),a.appendChild(o),a.appendChild(i)});t.empty(a),r.addOptions(c),r.addOptions(d),a.appendChild(r.root),r.input.focus()},"Edit file path");i.style.marginLeft="5px";const n=g();let o=t.link(n,()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")},x);const a=t.divH([o,i],{style:{alignItems:"center"}});return a})()},(null===(h=this.campaign)||void 0===h?void 0:h.authorUserFriendlyName)?{Author:this.campaign.authorUserFriendlyName}:{}),(null===(v=this.campaign)||void 0===v?void 0:v.lastModifiedUserName)?{"Last Modified By":this.campaign.lastModifiedUserName}:{}),(null===(f=this.campaign)||void 0===f?void 0:f.createDate)?{"Create Date":this.campaign.createDate}:{}),y),{"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(", ")})}saveCampaign(){return yt(this,arguments,void 0,function*(i=!0,n=!1,a){var r,s,d,c,u,p,m,h,v,f,g,y,w,b,C,A,T,S,x,I,N,E,F,_,P;this._isSaving=!0;const L=this.campaignId,O=setTimeout(()=>{var e;(null===(e=this._designView)||void 0===e?void 0:e.grid)&&t.setUpdateIndicator(this._designView.grid.root,!0,"Someone else is saving the campaign. Please wait...")},500);try{const e=yield this.aquireAndWaitCampaignLock(L);if(!(null==e?void 0:e.aquired))throw new Error("Could not acquire lock for campaign during 30 seconds")}catch(i){return clearTimeout(O),(null===(r=this._designView)||void 0===r?void 0:r.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),e.shell.error("Failed to acquire campaign lock. Someone else might be editing the campaign. Please try again later."),this._isSaving=!1,this.campaign}clearTimeout(O),(null===(s=this._designView)||void 0===s?void 0:s.grid)&&t.setUpdateIndicator(this._designView.grid.root,!0,"Saving Campaign...");const V=this.template.name,k=this.dataFrame,B=L,M={};k.columns.toList().forEach(e=>M[e.name]=e.semType);const D={};k.columns.toList().forEach(e=>D[e.name]=e.type);const R=null!==(c=null===(d=this.campaign)||void 0===d?void 0:d.tilesViewerFormSketch)&&void 0!==c?c:void 0,j=null!==(p=null===(u=this.campaign)||void 0===u?void 0:u.authorUserId)&&void 0!==p?p:e.shell.user.id,U=null!==(h=null===(m=this.campaign)||void 0===m?void 0:m.permissions)&&void 0!==h?h:yield(()=>yt(this,void 0,void 0,function*(){try{const e=yield function(){return dt(this,void 0,void 0,function*(){var e,t,i,n,o;try{const a=null!==(e=Gt.settings)&&void 0!==e?e:yield Gt.getSettings(),r={view:[],edit:[]};return a?(a instanceof Map?(r.view=yield pt(null!==(t=a.get("view"))&&void 0!==t?t:""),r.edit=yield pt(null!==(i=a.get("edit"))&&void 0!==i?i:"")):(r.view=yield pt(null!==(n=a.view)&&void 0!==n?n:""),r.edit=yield pt(null!==(o=a.edit)&&void 0!==o?o:"")),r):r}catch(e){return console.error(e),{view:[],edit:[]}}})}(),t={view:e.view.map(e=>e.id),edit:e.edit.map(e=>e.id)};return 0===t.edit.length&&(t.edit=[Be.edit[0]]),0===t.view.length&&(t.view=[Be.view[0]]),t}catch(t){e.shell.error("Failed to get default permissions"),console.error(t)}return Be}))(),$=j?null!==(f=null===(v=this.campaign)||void 0===v?void 0:v.authorUserFriendlyName)&&void 0!==f?f:null===(g=yield e.dapi.users.find(j))||void 0===g?void 0:g.friendlyName:void 0,H={name:B,friendlyName:null!==(b=null!==(w=null===(y=this.campaign)||void 0===y?void 0:y.friendlyName)&&void 0!==w?w:null==a?void 0:a.friendlyName)&&void 0!==b?b:B,templateName:V,status:null!==(A=null===(C=this.campaign)||void 0===C?void 0:C.status)&&void 0!==A?A:"In Progress",createDate:null!==(S=null===(T=this.campaign)||void 0===T?void 0:T.createDate)&&void 0!==S?S:ee(new Date),campaignFields:null!==(I=null===(x=this.campaign)||void 0===x?void 0:x.campaignFields)&&void 0!==I?I:this.campaignProps,columnSemTypes:M,rowCount:k.rowCount,filteredRowCount:k.filter.trueCount,savePath:this._filePath,columnTypes:D,tilesViewerFormSketch:R,version:this.version+1,authorUserId:j,authorUserFriendlyName:$,lastModifiedUserName:e.shell.user.friendlyName,permissions:U};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),(null===(N=this._designView)||void 0===N?void 0:N.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),yield this.releaseCampaignLock(L),this._isSaving=!1,H;const q=`${this.appName}/campaigns/${L}/${l}`;let G=k;if(yield Gt.files.exists(q)){const t=JSON.parse(yield Gt.files.readAsText(q));if((null!==(E=t.version)&&void 0!==E?E:0)>this.version&&(H.version=Math.max(this.version,null!==(F=t.version)&&void 0!==F?F:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);G=this.unionDataframes(t,k,this.molColName,this.molColName)}catch(e){console.error(e)}}const Y=o.DataFrame.fromColumns(G.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv();yield e.dapi.files.writeAsText(this._filePath,Y);const W=this._designView.saveLayout();W?H.layout=W.viewState:e.shell.warning("Layout cound not be saved"),H.template=this.template,yield Gt.saveCampaignJson(this.appName,H),i&&e.shell.info("Campaign saved successfully."),!i&&n&&e.shell.info("Campaign created successfully."),this.campaign=H,this.designViewName=null!==(_=H.friendlyName)&&void 0!==_?_:H.name;const J=yield this.releaseCampaignLock(L);return this._lastExpiresTimeString=J,(null===(P=this._designView)||void 0===P?void 0:P.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),this._isSaving=!1,this._refreshIconTooltip="Refresh Campaign",H})}}class bt extends o.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,o,a,r){if(a.gridRow<0||!a.cell.value)return;const s=a.cell.value,l=new Image(n-2,o-2);l.src="data:image/png;base64,"+s,l.onload=function(){e.drawImage(l,t+2,i+2,n-2,o-2)}}}var Ct=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class At extends nt{constructor(t){super(t),this.name="PeptiHit",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(Gt.webRoot+"README_HD.md")}getNewCampaignAccordeon(e){return Ct(this,void 0,void 0,function*(){const{root:t,promise:i,cancelPromise:n}=Ze(e,!0);return i.then(t=>Ct(this,void 0,void 0,function*(){this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})),n.then(()=>{this.init()}),t})}getAppHeader(){return Ve.appHeader({iconPath:Gt.webRoot+"/images/icons/pepti-hit-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 Helm sequences in the spreadsheet\n- Annotate and share ideas with the team\n- Convert to molecular form and calculate different properties\n- Save campaigns and continue from where you left off\n- Submit final selection to the function of your choice"})}}var Tt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class St extends wt{constructor(e){super(e,"PeptiHit",e=>new At(e)),this._helmColName=v}setTemplate(e,t){const i=Object.create(null,{setTemplate:{get:()=>super.setTemplate}});return Tt(this,void 0,void 0,function*(){var n,a;yield i.setTemplate.call(this,e,t),this._helmColName=null!==(a=null===(n=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===n?void 0:n.name)&&void 0!==a?a:v})}get helmColName(){var e,t;return null!==(e=this._helmColName)&&void 0!==e?e:null===(t=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===t?void 0:t.name}performSingleCellCalculations(t,i){const n=Object.create(null,{performSingleCellCalculations:{get:()=>super.performSingleCellCalculations}});return Tt(this,void 0,void 0,function*(){var a;try{if(!i)throw new Error("No cell value provided");const r=o.Column.fromStrings(this.helmColName,[i]),s=o.DataFrame.fromColumns([r]);r.semType=o.SEMTYPE.MACROMOLECULE,r.setTag("units","helm"),r.setTag(".alphabetIsMultichar","true"),yield e.functions.call("Bio:toAtomicLevel",{table:s,seqCol:r,nonlinear:!0});const l=s.columns.names().find(e=>e.toLowerCase()!==this.helmColName.toLowerCase()),d=l?null===(a=s.col(l))||void 0===a?void 0:a.get(0):null;if(!d)throw new Error("Failed to convert sequence to atomic level");this.dataFrame.set(this.molColName,t,d),yield n.performSingleCellCalculations.call(this,t,d)}catch(e){console.error(e)}})}getDesignView(){var t,i,n,a,r,s,l;const d=[],c=null===(t=this.dataFrame.col(this.helmColName))||void 0===t?void 0:t.toList().every(e=>!e&&""===e),u=this.dataFrame.col(this.helmColName);if(!u)throw new Error("No helm column found");u.semType=o.SEMTYPE.MACROMOLECULE,u.setTag("units","helm"),u.setTag(".alphabetIsMultichar","true"),u.setTag("cell.renderer","helm");const p=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.name)&&void 0!==n?n:this._designViewName,p.name=this._designViewName,p._onAdded();const h=null!==(r=null===(a=this._campaign)||void 0===a?void 0:a.layout)&&void 0!==r?r:null===(s=this.template)||void 0===s?void 0:s.layoutViewState;if(h)try{const e=o.ViewLayout.fromViewState(h);p.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}const v=null===(l=p.grid)||void 0===l?void 0:l.col(f);v&&(v.editable=!1);const y=this.dataFrame.col(f);return y&&(y.semType=g,y.valueComparer=(e,t)=>e===t?0:null===e?-1:null===t?1:parseInt(e.substring(1))-parseInt(t.substring(1))),c&&e.functions.call("Helm:editMoleculeCell",{cell:p.grid.cell(this.helmColName,0)}),d.push(this.dataFrame.onRowsAdded.pipe((0,lt.filter)(()=>!this.isJoining)).subscribe(()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const i=this.dataFrame.col(m).get(e);i&&""!==i&&!(null===(t=this.dataFrame.col(m))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(m,e,this.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=p.grid.cell(this.helmColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(i=t))}i&&e.functions.call("Helm:editMoleculeCell",{cell:i})}catch(e){console.error(e)}})),d.push(e.events.onContextMenu.subscribe(t=>{var i,n,a,r,s,l,d,c,u,m,h,v;try{const e=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==p.id)return;if((null===(r=null===(a=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.item)||void 0===a?void 0:a.tableColumn)||void 0===r?void 0:r.name)!==this.helmColName||!(null===(l=null===(s=null==t?void 0:t.args)||void 0===s?void 0:s.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(d=null==t?void 0:t.args)||void 0===d?void 0:d.menu;if(!f)return;f.item("Add new row",()=>{this.dataFrame.rows.addNew(null,!0)}),f.item("Duplicate Sequence",()=>{var e,i,n,o;try{const a=this.dataFrame.rows.addNew(null,!0);null!=a.get(this.helmColName)&&a.idx>-1&&(this.dataFrame.cell(a.idx,this.helmColName).value=null!==(o=null===(n=null===(i=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===i?void 0:i.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}});const g=null===(u=null===(c=null==t?void 0:t.args)||void 0===c?void 0:c.item)||void 0===u?void 0:u.tableRowIndex,y=null===(v=null===(h=null===(m=null==t?void 0:t.args)||void 0===m?void 0:m.item)||void 0===h?void 0:h.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",()=>Tt(this,void 0,void 0,function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}})),(null==p?void 0:p.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),p.resetLayout()),(null==p?void 0:p.grid)&&d.push(p.grid.onCellValueEdited.subscribe(t=>Tt(this,void 0,void 0,function*(){var i,n;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===m)return void(yield this.saveCampaign(!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.helmColName)return;const e=t.cell.value,o=t.tableRowIndex;yield this.performSingleCellCalculations(o,e);try{const e=this.dataFrame.col(this.molColName).get(o),t=yield ft(null!=e?e:"",this.campaignId,this.appName);t&&this.dataFrame.col(f).set(o,t,!0)}catch(e){console.error("Error updating V-iD column:",e)}}catch(t){e.shell.error("Error performing cell calculations: "+t),console.error(t)}}))),(null==p?void 0:p.grid)&&d.push(p.grid.onCellRender.subscribe(e=>{var t;try{const i=this.duplicateVidCache,n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!i||n.tableColumn.name!==f||(null!==(t=n.tableRowIndex)&&void 0!==t?t:-1)<0)return;i.valueCounts[i.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(i.indexes[n.tableRowIndex]),150))}catch(e){}})),this.initDesignViewRibbons(p,d),p.parentCall=this.parentCall,p}}var xt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};function It(e){return xt(this,void 0,void 0,function*(){yield Wt.hitTriageAppTreeBrowser(e)})}function Nt(e){return xt(this,void 0,void 0,function*(){yield Wt.hitDesignAppTreeBrowser(e)})}function Et(e){return xt(this,void 0,void 0,function*(){yield Wt.peptiHitAppTreeBrowser(e)})}function Ft(){return xt(this,void 0,void 0,function*(){return yield Wt.hitTriageApp()})}function _t(){return xt(this,void 0,void 0,function*(){return yield Wt.hitDesignApp()})}function Pt(){return xt(this,void 0,void 0,function*(){return yield Wt.peptiHitApp()})}function Lt(){return xt(this,void 0,void 0,function*(){return yield Wt.demoFileIngest()})}function Ot(){return xt(this,void 0,void 0,function*(){return yield Wt.demoFileIngest1()})}function Vt(e){return xt(this,void 0,void 0,function*(){return yield Wt.demoFileIngest2(e)})}function kt(e,t){return xt(this,void 0,void 0,function*(){yield Wt.demoFileSubmit(e,t)})}function Bt(){return xt(this,void 0,void 0,function*(){yield Wt.registerMoleculesToViD()})}function Mt(e){return Wt.hitDesignVidPanel(e)}function Dt(){return Wt.gasteigerCellRenderer()}function Rt(e){return xt(this,void 0,void 0,function*(){return yield Wt.htPackageSettingEditor(e)})}var jt=function(e,t,i,n){var o,a=arguments.length,r=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(r=(a<3?o(r):a>3?o(t,i,r):o(t,i))||r);return a>3&&r&&Object.defineProperty(t,i,r),r},Ut=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$t=function(e,t){return function(i,n){t(i,n,e)}},Ht=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class qt extends o.Package{constructor(){super(...arguments),this.molToSmilesLruCache=new o.LruCache(2e3),this.campaignsCache={}}convertToSmiles(t){return t?this.molToSmilesLruCache.getOrCreate(t,t=>e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)):""}loadCampaigns(t,i){return Ht(this,void 0,void 0,function*(){return this.campaignsCache[t]||(this.campaignsCache[t]=yield function(t,i){return X(this,void 0,void 0,function*(){const n=(yield Gt.files.list(`${t}/campaigns`)).filter(e=>-1===i.indexOf(e.name)),o={},a=n.map(i=>X(this,void 0,void 0,function*(){try{const n=JSON.parse(yield Gt.files.readAsText(`${t}/campaigns/${i.name}/${l}`));if(n.authorUserId&&n.permissions&&!(yield le(n.authorUserId,n.permissions)))return null;if(n.authorUserId&&!n.authorUserFriendlyName){const t=yield e.dapi.users.find(n.authorUserId);t&&(n.authorUserFriendlyName=t.friendlyName)}o[n.name]=n}catch(e){console.error(e)}return null}));return yield Promise.all(a),o})}(t,null!=i?i:[])),this.campaignsCache[t]})}saveCampaignJson(e,t){return Ht(this,void 0,void 0,function*(){const i=`${e}/campaigns/${t.name}/${l}`;yield this.files.writeAsText(i,JSON.stringify(t)),this.campaignsCache[e][t.name]=t})}}const Gt=new qt;function Yt(i,n){return Ht(this,void 0,void 0,function*(){var a,r,s;const l=t.div([],{style:{width:"50px",height:"24px",position:"relative"}});l.innerHTML='<div class="grok-loader"><div></div><div></div><div></div><div></div></div>';const d=i.item(l),c=yield Gt.loadCampaigns(n,[]);let u=null,p=!0;for(const[t,n]of Object.entries(c)){const t=null!==(a=n.templateName)&&void 0!==a?a:null===(r=n.template)||void 0===r?void 0:r.name,l=t?i.getOrCreateGroup(t,null,p):i;p=!1;const d=l.item(null!==(s=n.friendlyName)&&void 0!==s?s:n.name);d.root.addEventListener("dblclick",e=>{e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault()}),o.debounce(d.onSelected,200).subscribe(t=>Ht(this,void 0,void 0,function*(){var t;try{const i="ingest"in n?n.ingest.query:n.savePath;if(!i||!(yield e.dapi.files.exists(i)))return void e.shell.error("File not found: "+i);const a=yield e.dapi.files.readCsv(i);if(!a)return;a.name=null!==(t=n.friendlyName)&&void 0!==t?t:n.name;const r=n.columnSemTypes;if(r)for(const[m,h]of Object.entries(r)){const f=a.columns.byName(m);f&&(f.semType=h,h===o.SEMTYPE.MACROMOLECULE&&m===v&&(f.setTag("units","helm"),f.setTag(".alphabetIsMultichar","true"),f.setTag("cell.renderer","helm")))}const s=document.activeElement;let l=!1;function d(){setTimeout(()=>{!l&&s&&document.activeElement!==s&&s&&"focus"in s&&s.focus()})}window.addEventListener("focusout",d);try{u&&u.close()}catch(g){}try{u=e.shell.addTableView(a);const y=n.layout;y&&u.loadLayout(o.ViewLayout.fromViewState(y))}catch(w){console.error(w)}function c(){window.removeEventListener("focusout",d)}function p(){c(),l=!0}window.addEventListener("click",p,{once:!0}),setTimeout(()=>{c(),window.removeEventListener("click",p)},5e3)}catch(b){console.error(b)}}))}d.remove()})}class Wt{static hitTriageAppTreeBrowser(e){return Ht(this,void 0,void 0,function*(){yield Yt(e,"Hit Triage")})}static hitDesignAppTreeBrowser(e){return Ht(this,void 0,void 0,function*(){yield Yt(e,"Hit Design")})}static peptiHitAppTreeBrowser(e){return Ht(this,void 0,void 0,function*(){yield Yt(e,"PeptiHit")})}static hitTriageApp(){return Ht(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return new Qe(t).multiView})}static hitDesignApp(){return Ht(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return new wt(t).multiView})}static peptiHitApp(){return Ht(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new St(t).multiView})}static demoFileIngest(){return Ht(this,void 0,void 0,function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t})}static demoFileIngest1(){return Ht(this,void 0,void 0,function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t})}static demoFileIngest2(t){return Ht(this,void 0,void 0,function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i})}static demoFileSubmit(t,i){return Ht(this,void 0,void 0,function*(){e.shell.info(t.rowCount),e.shell.info(i)})}static registerMoleculesToViD(){return Ht(this,void 0,void 0,function*(){!function(){mt(this,void 0,void 0,function*(){var i;const n="Hit Design",a=yield Gt.loadCampaigns(n),r=Object.keys(a),l=t.input.choice("Select Campaign",{value:null,nullable:!0,items:r,tooltipText:"Select campaign to register its molecules. Leave empty to register all campaigns"}),d=yield new Promise(e=>mt(this,void 0,void 0,function*(){t.dialog("Register Existing Campaign Molecules").add(t.divText("This operation will go through all molecules in the selected campaign(s) and register them into V-iD storage.\n This operation is irreversible.")).add(t.divText("You can select a specific campaign or leave it empty to process all campaigns.")).add(t.divText("After this opteration, all VIDs throughout all campaigns will become unique, and old V-iDs will no longer be valid.")).add(t.divText("WARNING: Depending on the number of molecules, this operation can take a long time.")).add(l).onOK(()=>{if(l.value){const t=a[l.value];e([t])}else{const t=r.map(e=>a[e]);e(t)}}).onCancel(()=>e(null)).show()})),c=o.TaskBarProgressIndicator.create("Registering molecules...");if(!d||0===d.length)return void c.close();const u=d.length;for(const t of d){c.update(0/u*100,`Processing campaign: ${t.name}`);try{const o=`System.AppData/HitTriage/${n}/campaigns`,a=null!==(i=null==t?void 0:t.savePath)&&void 0!==i?i:`${o}/${t.name}/${s}`,r=yield e.dapi.files.readCsv(a);if(!r){e.shell.warning(`Failed to load campaign table for campaign ${t.name} at path ${a}`),console.warn(`Failed to load campaign table for campaign ${t.name} at path ${a}`);continue}const l=r.col(h);if(!l){e.shell.warning(`Molecule column not found in campaign ${t.name} table`),console.warn(`Molecule column not found in campaign ${t.name} table`);continue}const d=r.col(f);if(!d){e.shell.warning(`V-iD column not found in campaign ${t.name} table`),console.warn(`V-iD column not found in campaign ${t.name} table`);continue}const c=l.toList(),u=yield gt(c,t.name,n);for(let e=0;e<r.rowCount;e++){const t=c[e];if(!t||""===t){d.set(e,"",!1);continue}const i=u.get(t);i&&d.set(e,i,!1)}d.fireValuesChanged(),yield e.dapi.files.writeAsText(a,r.toCsv()),e.shell.info(`Finished processing campaign ${t.name}`),console.log(`Finished processing campaign ${t.name}`)}catch(i){e.shell.error(`Error processing campaign ${t.name}. See console for details.`),console.error(`Error processing campaign ${t.name} molecules registration:`,i)}}c.close()})}()})}static hitDesignVidPanel(i){return o.Widget.fromRoot(t.card(t.wait(()=>Ht(this,void 0,void 0,function*(){if(!(null==i?void 0:i.value))return t.divText("No V-iD provided");const n=yield Ue.getCampaignsByVid(i.value,null);if(!n||0===n.rowCount)return t.divText(`No campaigns found for V-iD: ${i.value}`);const o=yield Ue.getMoleculeByVid(i.value);if(!o||0===o.rowCount)return t.divText(`No molecule found for V-iD: ${i.value}`);const a=function(e){var t;const i=null===(t=Gt.meta)||void 0===t?void 0:t.sok;if(!i)throw new Error("Secret key for SMILES deobfuscation is not set");const n=atob(e);let o="";for(let e=0;e<n.length;e++){const t=n.charCodeAt(e),a=i.charCodeAt(e%i.length);o+=String.fromCharCode(t^a)}return o}(o.col("mh_string").get(0)),r=e.chem.drawMolecule(a,300,300),s=new Map;for(let e=0;e<n.rowCount;e++){const t=n.col("app_name").get(e),i=n.col("campaign_id").get(e),o=n.col("created_by").get(e);s.has(t)||s.set(t,[]),s.get(t).push({campaignId:i,createdBy:o})}const l=t.divV([r],{style:{gap:"10px",justifyContent:"center"}});for(const[e,i]of s.entries()){const n=t.table(i.map(e=>[e.campaignId,e.createdBy]),e=>[e[0],e[1]],["Campaigns","Created By"]),o=t.divV([t.h3(`${e} Campaigns`),n],{style:{gap:"4px"}});l.appendChild(o)}return l}))))}static gasteigerCellRenderer(){return new bt}static htPackageSettingEditor(i){return Ht(this,void 0,void 0,function*(){return function(i){return dt(this,void 0,void 0,function*(){var n;const a=i.filter(e=>"DefaultUserGroupsSharing"===e.category),r=[];for(const i of a){const n=`${i.name[0].toUpperCase()}${i.name.slice(1)}`,a=i.get(null),s=yield pt(a),l=t.input.userGroups(n);yield o.delay(200),l.value=s,l.onInput.subscribe(()=>{var t;try{const e=(null===(t=l.value)||void 0===t?void 0:t.length)?JSON.stringify(l.value.map(e=>e.id)):"";i.set(null,e)}catch(t){e.shell.error("Error Setting group. Check console for more details"),console.error(t)}}),l.setTooltip(`Selected groups will be granted ${n.toLowerCase()} permissions by default on newly created campaigns`),r.push(l)}const s=o.Widget.fromRoot(t.form(r,{style:{overflow:"visible"}}));s.root.prepend(t.h1("Default Campaign Sharing",{style:{marginBottom:"6px",marginTop:"6px"}}));const l=i.find(e=>e.name===ct);if(l){const i='Default storage for newly created campaigns. For each app, folders will be created under their name. For example, for Hit Design, the campaign files will be saved under <b>"Your folder/Hit Design/campaigns/enriched_table.csv"</b>';let a=i;const r=null!==(n=l.get(null))&&void 0!==n?n:ut,d=t.h1("Default Campaign Storage",{style:{marginBottom:"6px",marginTop:"6px"}}),c=t.input.string("Folder Path",{value:r});t.tooltip.bind(c.input,()=>a),o.debounce(c.onChanged,200).subscribe(t=>dt(this,void 0,void 0,function*(){const t=c.value;try{if(!t)return l.set(null,ut),a=i+'<br><br> <b style="color: red">Cannot be empty.</b>',void c.input.classList.add("d4-invalid");if(!(yield e.dapi.files.exists(t)))return l.set(null,ut),a=i+'<br><br> <b style="color: red">Folder does not exist.</b>',void c.input.classList.add("d4-invalid");l.set(null,t),a=i,c.input.classList.remove("d4-invalid")}catch(t){e.shell.error("Error Setting default storage. Check console for more details"),console.error(t)}})),s.root.appendChild(d),s.root.appendChild(c.root)}return setTimeout(()=>{var e;return(null===(e=s.root.parentElement)||void 0===e?void 0:e.style)&&(s.root.parentElement.style.overflow="visible")},200),s})}(i)})}}jt([e.decorators.treeBrowser({meta:{app:"Hit Triage"}}),Ut("design:type",Function),Ut("design:paramtypes",[o.TreeViewGroup]),Ut("design:returntype",Promise)],Wt,"hitTriageAppTreeBrowser",null),jt([e.decorators.treeBrowser({meta:{app:"Hit Design"}}),Ut("design:type",Function),Ut("design:paramtypes",[o.TreeViewGroup]),Ut("design:returntype",Promise)],Wt,"hitDesignAppTreeBrowser",null),jt([e.decorators.treeBrowser({meta:{app:"PeptiHit"}}),Ut("design:type",Function),Ut("design:paramtypes",[o.TreeViewGroup]),Ut("design:returntype",Promise)],Wt,"peptiHitAppTreeBrowser",null),jt([e.decorators.app({browsePath:"Chem",name:"Hit Triage",tags:["app"]}),Ut("design:type",Function),Ut("design:paramtypes",[]),Ut("design:returntype",Promise)],Wt,"hitTriageApp",null),jt([e.decorators.app({icon:"images/icons/hit-design-icon.png",browsePath:"Chem",name:"Hit Design",tags:["app"]}),Ut("design:type",Function),Ut("design:paramtypes",[]),Ut("design:returntype",Promise)],Wt,"hitDesignApp",null),jt([e.decorators.app({icon:"images/icons/pepti-hit-icon.png",browsePath:"Peptides",name:"PeptiHit",tags:["app"]}),Ut("design:type",Function),Ut("design:paramtypes",[]),Ut("design:returntype",Promise)],Wt,"peptiHitApp",null),jt([e.decorators.func({name:"Demo Molecules 100",meta:{role:"hitTriageDataSource"}}),Ut("design:type",Function),Ut("design:paramtypes",[]),Ut("design:returntype",Promise)],Wt,"demoFileIngest",null),jt([e.decorators.func({name:"Demo Molecules 5000",meta:{role:"hitTriageDataSource"}}),Ut("design:type",Function),Ut("design:paramtypes",[]),Ut("design:returntype",Promise)],Wt,"demoFileIngest1",null),jt([e.decorators.func({name:"Demo Molecules variable",meta:{role:"hitTriageDataSource"}}),$t(0,e.decorators.param({type:"int",options:{description:"Molecules counts"}})),Ut("design:type",Function),Ut("design:paramtypes",[Number]),Ut("design:returntype",Promise)],Wt,"demoFileIngest2",null),jt([e.decorators.func({name:"Demo File Submit",meta:{role:"hitTriageSubmitFunction"}}),$t(0,e.decorators.param({options:{description:"Dataframe"}})),$t(1,e.decorators.param({options:{description:"Molecules column name"}})),Ut("design:type",Function),Ut("design:paramtypes",[o.DataFrame,String]),Ut("design:returntype",Promise)],Wt,"demoFileSubmit",null),jt([e.decorators.func({}),Ut("design:type",Function),Ut("design:paramtypes",[]),Ut("design:returntype",Promise)],Wt,"registerMoleculesToViD",null),jt([e.decorators.panel({name:"Hit Design V-iD"}),$t(0,e.decorators.param({type:"semantic_value",options:{semType:"HIT_DESIGN_VID"}})),Ut("design:type",Function),Ut("design:paramtypes",[o.SemanticValue]),Ut("design:returntype",o.Widget)],Wt,"hitDesignVidPanel",null),jt([e.decorators.func({meta:{cellType:"customGasteigerPNG",columnTags:"quality=customGasteigerPNG",role:"cellRenderer"},name:"gasteigerRenderer",outputs:[{type:"grid_cell_renderer",name:"result"}]}),Ut("design:type",Function),Ut("design:paramtypes",[]),Ut("design:returntype",bt)],Wt,"gasteigerCellRenderer",null),jt([e.decorators.func({name:"Hit Triage package settings editor",meta:{role:"packageSettingsEditor"},tags:["packageSettingsEditor"]}),$t(0,e.decorators.param({name:"propList",type:"object"})),Ut("design:type",Function),Ut("design:paramtypes",[Array]),Ut("design:returntype",Promise)],Wt,"htPackageSettingEditor",null)})(),hittriage=n})();
1
+ var hittriage;(()=>{var e={233(e){!function(){"use strict";var t=document,i=window,n=t.documentElement,o=t.createElement.bind(t),a=o("div"),s=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,d=Array.prototype,u=d.concat,p=d.filter,m=d.indexOf,h=d.map,v=d.push,f=d.slice,g=d.some,y=d.splice,A=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,w=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,b=/<.+>/,C=/^\w+$/;function E(e,t){var i,n=!!(i=t)&&11===i.nodeType;return e&&(n||I(t)||F(t))?!n&&w.test(e)?t.getElementsByClassName(e.slice(1).replace(/\\/g,"")):!n&&C.test(e)?t.getElementsByTagName(e):t.querySelectorAll(e):[]}var T=function(){function e(e,n){if(e){if(N(e))return e;var o=e;if(_(e)){var a=n||t;if(!(o=A.test(e)&&I(a)?a.getElementById(e.slice(1).replace(/\\/g,"")):b.test(e)?Z(e):N(a)?a.find(e):_(a)?S(a).find(e):E(e,a)))return}else if(P(e))return this.ready(e);(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 e.prototype.init=function(t,i){return new e(t,i)},e}(),x=T.prototype,S=x.init;function N(e){return e instanceof T}function B(e){return!!e&&e===e.window}function I(e){return!!e&&9===e.nodeType}function F(e){return!!e&&1===e.nodeType}function P(e){return"function"==typeof e}function _(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 O(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function D(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(O(e))for(var o=Object.keys(e),a=(n=0,o.length);n<a;n++){var s=o[n];if(!1===t.call(e[s],s,e[s]))return e}else for(n=0,a=e.length;n<a;n++)if(!1===t.call(e[n],n,e[n]))return e;return e}function $(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i="boolean"==typeof e[0]&&e.shift(),n=e.shift(),o=e.length;if(!n)return{};if(!o)return $(i,S,n);for(var a=0;a<o;a++){var s=e[a];for(var r in s)i&&(c(s[r])||O(s[r]))?(n[r]&&n[r].constructor===s[r].constructor||(n[r]=new s[r].constructor),$(i,n[r],s[r])):n[r]=s[r]}return n}S.fn=S.prototype=x,x.length=0,x.splice=y,"function"==typeof Symbol&&(x[Symbol.iterator]=d[Symbol.iterator]),S.isWindow=B,S.isFunction=P,S.isArray=c,S.isNumeric=L,S.isPlainObject=O,S.each=D,x.each=function(e){return D(this,e)},x.empty=function(){return this.each(function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)})},S.extend=$,x.extend=function(e){return $(x,e)};var M=/\S+/g;function R(e){return _(e)&&e.match(M)||[]}function j(e,t,n){if(F(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function U(e,t){return parseInt(j(e,t),10)||0}function H(e,t){return U(e,"border".concat(t?"Left":"Top","Width"))+U(e,"padding".concat(t?"Left":"Top"))+U(e,"padding".concat(t?"Right":"Bottom"))+U(e,"border".concat(t?"Right":"Bottom","Width"))}x.toggleClass=function(e,t){var i=R(e),n=!k(t);return this.each(function(e,o){F(o)&&D(i,function(e,i){n?t?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)})})},x.addClass=function(e){return this.toggleClass(e,!0)},x.removeAttr=function(e){var t=R(e);return this.each(function(e,i){F(i)&&D(t,function(e,t){i.removeAttribute(t)})})},x.attr=function(e,t){if(e){if(_(e)){if(arguments.length<2){if(!this[0]||!F(this[0]))return;var i=this[0].getAttribute(e);return V(i)?void 0:i}return k(t)?this:V(t)?this.removeAttr(e):this.each(function(i,n){F(n)&&n.setAttribute(e,t)})}for(var n in e)this.attr(n,e[n]);return this}},x.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},x.hasClass=function(e){return!!e&&g.call(this,function(t){return F(t)&&t.classList.contains(e)})},x.get=function(e){return k(e)?f.call(this):this[(e=Number(e))<0?e+this.length:e]},x.eq=function(e){return S(this.get(e))},x.first=function(){return this.eq(0)},x.last=function(){return this.eq(-1)},x.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,i){F(i)&&(i.textContent=e)})};var q={};function Y(e){return"none"===j(e,"display")}function G(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function W(e){return _(e)?function(t,i){return G(i,e)}:P(e)?e:N(e)?function(t,i){return e.is(i)}:e?function(t,i){return i===e}:function(){return!1}}function z(e,t){return t?e.filter(t):e}x.filter=function(e){var t=W(e);return S(p.call(this,function(e,i){return t.call(e,i,e)}))},x.detach=function(e){return z(this,e).each(function(e,t){t.parentNode&&t.parentNode.removeChild(t)}),this};var J=/^\s*<(\w+)[^>]*>/,Q=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,K={"*":a,tr:r,td:l,th:l,thead:s,tbody:s,tfoot:s};function Z(e){if(!_(e))return[];if(Q.test(e))return[o(RegExp.$1)];var t=J.test(e)&&RegExp.$1,i=K[t]||K["*"];return i.innerHTML=e,S(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],a=P(t),s=n&&W(n),r=0,l=e.length;r<l;r++)if(a){var c=t(e[r]);c.length&&v.apply(o,c)}else for(var d=e[r][t];!(null==d||n&&s(-1,d));)o.push(d),d=i?d[t]:null;return o}function ee(e){return e.multiple&&e.options?X(p.call(e.options,function(e){return e.selected&&!e.disabled&&!e.parentNode.disabled}),"value"):e.value||""}function te(e){return e.length>1?p.call(e,function(e,t,i){return m.call(i,e)===t}):e}S.parseHTML=Z,x.has=function(e){var t=_(e)?function(t,i){return E(e,i).length}:function(t,i){return i.contains(e)};return this.filter(t)},x.not=function(e){var t=W(e);return this.filter(function(i,n){return(!_(e)||F(n))&&!t.call(n,i,n)})},x.val=function(e){return arguments.length?this.each(function(t,i){var n=i.multiple&&i.options;if(n||_e.test(i.type)){var o=c(e)?h.call(e,String):V(e)?[]:[String(e)];n?D(i.options,function(e,t){t.selected=o.indexOf(t.value)>=0},!0):i.checked=o.indexOf(i.value)>=0}else i.value=k(e)||V(e)?"":e}):this[0]&&ee(this[0])},x.is=function(e){var t=W(e);return g.call(this,function(e,i){return t.call(e,i,e)})},S.guid=1,S.unique=te,x.add=function(e,t){return S(te(this.get().concat(S(e,t).get())))},x.children=function(e){return z(S(te(X(this,function(e){return e.children}))),e)},x.parent=function(e){return z(S(te(X(this,"parentNode"))),e)},x.index=function(e){var t=e?S(e)[0]:this[0],i=e?this:S(t).parent().children();return m.call(i,t)},x.closest=function(e){var t=this.filter(e);if(t.length)return t;var i=this.parent();return i.length?i.closest(e):t},x.siblings=function(e){return z(S(te(X(this,function(e){return S(e).parent().children().not(e)}))),e)},x.find=function(e){return S(te(X(this,function(t){return E(e,t)})))};var ie=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ne=/^$|^module$|\/(java|ecma)script/i,oe=["type","src","nonce","noModule"];function ae(e,t,i,a,s,r,l,c){return D(e,function(e,r){D(S(r),function(e,r){D(S(t),function(t,l){var c=i?l:r,d=i?e:t;!function(e,t,i,a,s){a?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),s&&function(e,t){var i=S(e);i.filter("script").add(i.find("script")).each(function(e,i){if(ne.test(i.type)&&n.contains(i)){var a=o("script");a.text=i.textContent.replace(ie,""),D(oe,function(e,t){i[t]&&(a[t]=i[t])}),t.head.insertBefore(a,null),t.head.removeChild(a)}})}(t,e.ownerDocument)}(i?r:l,d?c.cloneNode(!0):c,a,s,!d)},c)},l)},r),t}x.after=function(){return ae(arguments,this,!1,!1,!1,!0,!0)},x.append=function(){return ae(arguments,this,!1,!1,!0)},x.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(i,n){F(n)&&(t?S(n).empty().append(e):n.innerHTML=e)})},x.appendTo=function(e){return ae(arguments,this,!0,!1,!0)},x.wrapInner=function(e){return this.each(function(t,i){var n=S(i),o=n.contents();o.length?o.wrapAll(e):n.append(e)})},x.before=function(){return ae(arguments,this,!1,!0)},x.wrapAll=function(e){for(var t=S(e),i=t[0];i.children.length;)i=i.firstElementChild;return this.first().before(t),this.appendTo(i)},x.wrap=function(e){return this.each(function(t,i){var n=S(e)[0];S(i).wrapAll(t?n.cloneNode(!0):n)})},x.insertAfter=function(e){return ae(arguments,this,!0,!1,!1,!1,!1,!0)},x.insertBefore=function(e){return ae(arguments,this,!0,!0)},x.prepend=function(){return ae(arguments,this,!1,!0,!0,!0,!0)},x.prependTo=function(e){return ae(arguments,this,!0,!0,!0,!1,!1,!0)},x.contents=function(){return S(te(X(this,function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes})))},x.next=function(e,t,i){return z(S(te(X(this,"nextElementSibling",t,i))),e)},x.nextAll=function(e){return this.next(e,!0)},x.nextUntil=function(e,t){return this.next(t,!0,e)},x.parents=function(e,t){return z(S(te(X(this,"parentElement",!0,t))),e)},x.parentsUntil=function(e,t){return this.parents(t,e)},x.prev=function(e,t,i){return z(S(te(X(this,"previousElementSibling",t,i))),e)},x.prevAll=function(e){return this.prev(e,!0)},x.prevUntil=function(e,t){return this.prev(t,!0,e)},x.map=function(e){return S(u.apply([],h.call(this,function(t,i){return e.call(t,i,t)})))},x.clone=function(){return this.map(function(e,t){return t.cloneNode(!0)})},x.offsetParent=function(){return this.map(function(e,t){for(var i=t.offsetParent;i&&"static"===j(i,"position");)i=i.offsetParent;return i||n})},x.slice=function(e,t){return S(f.call(this,e,t))};var se=/-([a-z])/g;function re(e){return e.replace(se,function(e,t){return t.toUpperCase()})}x.ready=function(e){var i=function(){return setTimeout(e,0,S)};return"loading"!==t.readyState?i():t.addEventListener("DOMContentLoaded",i),this},x.unwrap=function(){return this.parent().each(function(e,t){if("BODY"!==t.tagName){var i=S(t);i.replaceWith(i.children())}}),this},x.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}}},x.position=function(){var e=this[0];if(e){var t="fixed"===j(e,"position"),i=t?e.getBoundingClientRect():this.offset();if(!t){for(var n=e.ownerDocument,o=e.offsetParent||n.documentElement;(o===n.body||o===n.documentElement)&&"static"===j(o,"position");)o=o.parentNode;if(o!==e&&F(o)){var a=S(o).offset();i.top-=a.top+U(o,"borderTopWidth"),i.left-=a.left+U(o,"borderLeftWidth")}}return{top:i.top-U(e,"marginTop"),left:i.left-U(e,"marginLeft")}}};var le={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};x.prop=function(e,t){if(e){if(_(e))return e=le[e]||e,arguments.length<2?this[0]&&this[0][e]:this.each(function(i,n){n[e]=t});for(var i in e)this.prop(i,e[i]);return this}},x.removeProp=function(e){return this.each(function(t,i){delete i[le[e]||e]})};var ce=/^--/;function de(e){return ce.test(e)}var ue={},pe=a.style,me=["webkit","moz","ms"],he={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 ve(e,t,i){return void 0===i&&(i=de(e)),i||he[e]||!L(t)?t:"".concat(t,"px")}function fe(e,t){try{return e(t)}catch(e){return t}}x.css=function(e,t){if(_(e)){var i=de(e);return e=function(e,t){if(void 0===t&&(t=de(e)),t)return e;if(!ue[e]){var i=re(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));D("".concat(i," ").concat(me.join("".concat(n," "))).concat(n).split(" "),function(t,i){if(i in pe)return ue[e]=i,!1})}return ue[e]}(e,i),arguments.length<2?this[0]&&j(this[0],e,i):e?(t=ve(e,t,i),this.each(function(n,o){F(o)&&(i?o.style.setProperty(e,t):o.style[e]=t)})):this}for(var n in e)this.css(n,e[n]);return this};var ge=/^\s+|\s+$/;function ye(e,t){var i=e.dataset[t]||e.dataset[re(t)];return ge.test(i)?i:fe(JSON.parse,i)}function Ae(e,t){var i=e.documentElement;return Math.max(e.body["scroll".concat(t)],i["scroll".concat(t)],e.body["offset".concat(t)],i["offset".concat(t)],i["client".concat(t)])}x.data=function(e,t){if(!e){if(!this[0])return;var i={};for(var n in this[0].dataset)i[n]=ye(this[0],n);return i}if(_(e))return arguments.length<2?this[0]&&ye(this[0],e):k(t)?this:this.each(function(i,n){!function(e,t,i){i=fe(JSON.stringify,i),e.dataset[re(t)]=i}(n,e,t)});for(var n in e)this.data(n,e[n]);return this},D([!0,!1],function(e,t){D(["Width","Height"],function(e,i){var n="".concat(t?"outer":"inner").concat(i);x[n]=function(n){if(this[0])return B(this[0])?t?this[0]["inner".concat(i)]:this[0].document.documentElement["client".concat(i)]:I(this[0])?Ae(this[0],i):this[0]["".concat(t?"offset":"client").concat(i)]+(n&&t?U(this[0],"margin".concat(e?"Top":"Left"))+U(this[0],"margin".concat(e?"Bottom":"Right")):0)}})}),D(["Width","Height"],function(e,t){var i=t.toLowerCase();x[i]=function(n){if(!this[0])return k(n)?void 0:this;if(!arguments.length)return B(this[0])?this[0].document.documentElement["client".concat(t)]:I(this[0])?Ae(this[0],t):this[0].getBoundingClientRect()[i]-H(this[0],!e);var o=parseInt(n,10);return this.each(function(t,n){if(F(n)){var a=j(n,"boxSizing");n.style[i]=ve(i,o+("border-box"===a?H(n,!e):0))}})}});var we="___cd";x.toggle=function(e){return this.each(function(i,n){if(F(n)){var a=Y(n);(k(e)?a:e)?(n.style.display=n[we]||"",Y(n)&&(n.style.display=function(e){if(q[e])return q[e];var i=o(e);t.body.insertBefore(i,null);var n=j(i,"display");return t.body.removeChild(i),q[e]="none"!==n?n:"block"}(n.tagName))):a||(n[we]=j(n,"display"),n.style.display="none")}})},x.hide=function(){return this.toggle(!1)},x.show=function(){return this.toggle(!0)};var be="___ce",Ce={focus:"focusin",blur:"focusout"},Ee={mouseenter:"mouseover",mouseleave:"mouseout"},Te=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function xe(e){return Ee[e]||Ce[e]||e}function Se(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Ne(e){return e[be]=e[be]||{}}function Be(e,t){return!t||!g.call(t,function(t){return e.indexOf(t)<0})}function Ie(e,t,i,n,o){var a=Ne(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||!Be(s,i)||n&&n!==r)return!0;e.removeEventListener(t,l)}));else for(t in a)Ie(e,t,i,n,o)}x.trigger=function(e,i){if(_(e)){var n=Se(e),o=n[0],a=n[1],s=xe(o);if(!s)return this;var r=Te.test(s)?"MouseEvents":"HTMLEvents";(e=t.createEvent(r)).initEvent(s,!0,!0),e.namespace=a.join("."),e.___ot=o}e.___td=i;var l=e.___ot in Ce;return this.each(function(t,i){l&&P(i[e.___ot])&&(i["___i".concat(e.type)]=!0,i[e.___ot](),i["___i".concat(e.type)]=!1),i.dispatchEvent(e)})},x.off=function(e,t,i){var n=this;if(k(e))this.each(function(e,t){(F(t)||I(t)||B(t))&&Ie(t)});else if(_(e))P(t)&&(i=t,t=""),D(R(e),function(e,o){var a=Se(o),s=a[0],r=a[1],l=xe(s);n.each(function(e,n){(F(n)||I(n)||B(n))&&Ie(n,l,r,t,i)})});else for(var o in e)this.off(o,e[o]);return this},x.remove=function(e){return z(this,e).detach().off(),this},x.replaceWith=function(e){return this.before(e).remove()},x.replaceAll=function(e){return S(e).replaceWith(this),this},x.on=function(e,t,i,n,o){var a=this;if(!_(e)){for(var s in e)this.on(s,t,i,e[s],o);return this}return _(t)||(k(t)||V(t)?t="":k(i)?(i=t,t=""):(n=i,i=t,t="")),P(n)||(n=i,i=void 0),n?(D(R(e),function(e,s){var r=Se(s),l=r[0],c=r[1],d=xe(l),u=l in Ee,p=l in Ce;d&&a.each(function(e,a){if(F(a)||I(a)||B(a)){var s=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Be(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==a||e.___ot===d)||u&&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 i}});var m=n.call(r,e,e.___td);o&&Ie(a,d,c,t,s),!1===m&&(e.preventDefault(),e.stopPropagation())}};s.guid=n.guid=n.guid||S.guid++,function(e,t,i,n,o){var a=Ne(e);a[t]=a[t]||[],a[t].push([i,n,o]),e.addEventListener(t,o)}(a,d,c,t,s)}})}),this):this},x.one=function(e,t,i,n){return this.on(e,t,i,n,!0)};var Fe=/\r?\n/g,Pe=/file|reset|submit|button|image/i,_e=/radio|checkbox/i;x.serialize=function(){var e="";return this.each(function(t,i){D(i.elements||[i],function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Pe.test(i.type)||_e.test(i.type)&&!i.checked)){var n=ee(i);k(n)||D(c(n)?n:[n],function(t,n){e+=function(e,t){return"&".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t.replace(Fe,"\r\n")))}(i.name,n)})}})}),e.slice(1)},e.exports=S}()},558(e,t,i){"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),a=i(314),s=i.n(a)()(o());s.push([e.id,".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\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.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}\n\n.hit-triage-info-view-container .fa-trash-alt:hover {\n color: #ff0000 !important;\n}","",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;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;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;;AAEA;IACI,yBAAyB;AAC7B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\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.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}\n\n.hit-triage-info-view-container .fa-trash-alt:hover {\n color: #ff0000 !important;\n}"],sourceRoot:""}]);const r=s},801(e,t,i){"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),a=i(314),s=i.n(a)()(o());s.push([e.id,".statistics-mpo-header {\n margin-top: 10px;\n padding-bottom: 5px;\n border-bottom: 1px solid var(--grey-2);\n gap: 10px;\n}\n\n.statistics-mpo-header > * {\n font-weight: bold;\n}\n\n.statistics-mpo-header > *:first-child {\n width: 130px;\n}\n\n.statistics-mpo-header > *:nth-child(2) {\n width: 120px;\n min-width: 60px;\n}\n\n.statistics-mpo-header > *:nth-child(3) {\n flex-grow: 1;\n}\n\n.statistics-mpo-property-cell {\n width: 130px;\n max-width: 130px;\n align-self: flex-end;\n margin-bottom: 20px !important;\n}\n\n.ui-form .statistics-mpo-property-cell > div:first-child {\n padding-left: 4px;\n}\n\n.statistics-mpo-property-cell > div:first-child {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.statistics-mpo-weight-input {\n width: 100px;\n}\n\n.statistics-mpo-weight-cell {\n align-self: flex-end;\n margin-bottom: 20px !important;\n align-items: center;\n gap: 4px;\n}\n\n.statistics-mpo-control-buttons {\n gap: 10px;\n margin-left: 10px;\n color: var(--blue-1);\n visibility: hidden;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.statistics-mpo-row:hover .statistics-mpo-control-buttons,\n.statistics-mpo-cat-row:hover .statistics-mpo-control-buttons {\n visibility: visible;\n}\n\n.statistics-mpo-range-input {\n width: 70px;\n}\n\n.statistics-mpo-row {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 8px 0;\n min-height: 70px;\n gap: 10px;\n\n flex-wrap: wrap;\n}\n\n.statistics-mpo-row > * {\n flex: 0 0 auto;\n}\n\n\n.statistics-mpo-row .ui-input-choice .ui-input-editor {\n width: 100px !important;\n max-width: none !important;\n}\n\n.ui-form .statistics-mpo-row .ui-input-root {\n margin-bottom: 0 !important;\n padding: 0 !important;\n}\n\n.statistics-mpo-editor-fill {\n width: 100%;\n height: 100%;\n}\n\n.statistics-mpo-cat-editor {\n width: 280px;\n margin-left: 30px;\n}\n\n.statistics-mpo-cat-row {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 2px;\n}\n\n.statistics-mpo-cat-name {\n width: 120px;\n}\n\n.statistics-mpo-cat-col-header {\n font-size: 11px;\n color: var(--grey-3);\n text-transform: uppercase;\n letter-spacing: 0.3px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-editor {\n width: auto;\n margin-left: 0;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-name {\n flex: 1;\n width: auto;\n}\n\n.statistics-mpo-cat-desirability {\n width: 70px;\n}\n\n.statistics-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-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.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\n.statistics-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n overflow: clip;\n}\n\n.statistics-compute-dialog-descriptors-group {\n margin-left: 16px;\n overflow: hidden;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.statistics-mpo-weight-toggle {\n cursor: pointer;\n color: var(--grey-4);\n font-size: 12px;\n}\n\n.statistics-mpo-weight-toggle:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-weight-toggle-active {\n color: var(--grey-4);\n}\n\n.statistics-mpo-weight-toggle-active:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-hidden {\n display: none !important;\n}\n\n.statistics-mpo-empty-state {\n text-align: center;\n padding: 48px 24px;\n color: var(--grey-4);\n border: 1px dashed var(--grey-2);\n border-radius: 8px;\n margin: 16px 12px;\n}\n\n.statistics-mpo-empty-state i {\n font-size: 48px;\n margin-bottom: 16px;\n display: block;\n color: var(--blue-1);\n opacity: 0.3;\n cursor: default;\n pointer-events: none;\n}\n\n.statistics-mpo-empty-state h3 {\n color: var(--grey-5);\n}\n\n.statistics-mpo-empty-state p {\n color: var(--grey-3);\n max-width: 360px;\n margin-inline: auto;\n}\n\n.statistics-mpo-dialog-header-row {\n gap: 12px;\n align-items: flex-end;\n margin-bottom: 8px;\n}\n\n.statistics-mpo-dialog-header-row .ui-input-root {\n flex: 0 1 auto;\n}\n\n.statistics-mpo-section-header {\n font-size: 11px;\n text-transform: uppercase;\n color: var(--blue-1);\n letter-spacing: 0.5px;\n border-bottom: 1px solid var(--grey-2);\n padding-bottom: 4px;\n margin: 12px 0 8px;\n}\n\n.statistics-mpo-param-grid.ui-form {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0 8px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-plot {\n margin: 0 auto;\n}\n\n@media (max-width: 500px) {\n .statistics-mpo-row {\n flex-direction: column;\n align-items: flex-start;\n }\n\n .statistics-mpo-row > * {\n width: 100% !important;\n margin-bottom: 5px;\n }\n\n .statistics-mpo-weight-cell {\n margin-top: 0 !important;\n }\n}\n","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/statistics/css/styles.css"],names:[],mappings:"AAAA;EACE,gBAAgB;EAChB,mBAAmB;EACnB,sCAAsC;EACtC,SAAS;AACX;;AAEA;EACE,iBAAiB;AACnB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,eAAe;AACjB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,gBAAgB;EAChB,oBAAoB;EACpB,8BAA8B;AAChC;;AAEA;EACE,iBAAiB;AACnB;;AAEA;EACE,gBAAgB;EAChB,uBAAuB;EACvB,mBAAmB;AACrB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,oBAAoB;EACpB,8BAA8B;EAC9B,mBAAmB;EACnB,QAAQ;AACV;;AAEA;EACE,SAAS;EACT,iBAAiB;EACjB,oBAAoB;EACpB,kBAAkB;EAClB,mBAAmB;EACnB,cAAc;AAChB;;AAEA;;EAEE,mBAAmB;AACrB;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,2BAA2B;EAC3B,cAAc;EACd,gBAAgB;EAChB,SAAS;;EAET,eAAe;AACjB;;AAEA;EACE,cAAc;AAChB;;;AAGA;EACE,uBAAuB;EACvB,0BAA0B;AAC5B;;AAEA;EACE,2BAA2B;EAC3B,qBAAqB;AACvB;;AAEA;EACE,WAAW;EACX,YAAY;AACd;;AAEA;EACE,YAAY;EACZ,iBAAiB;AACnB;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,QAAQ;EACR,kBAAkB;AACpB;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,yBAAyB;EACzB,qBAAqB;AACvB;;AAEA;EACE,WAAW;EACX,cAAc;AAChB;;AAEA;EACE,OAAO;EACP,WAAW;AACb;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,oBAAoB;AACtB;;AAEA;EACE,YAAY;EACZ,kCAAkC;EAClC,kBAAkB;EAClB,gBAAgB;EAChB,gBAAgB;EAChB,yBAAyB;EACzB,2BAA2B;AAC7B;;AAEA;EACE,oCAAoC;EACpC,yBAAyB;AAC3B;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,iBAAiB;EACjB,gBAAgB;EAChB,gBAAgB;EAChB,cAAc;AAChB;;AAEA;EACE,iBAAiB;EACjB,gBAAgB;AAClB;;AAEA;EACE,kBAAkB;AACpB;;AAEA;EACE,eAAe;EACf,oBAAoB;EACpB,eAAe;AACjB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,wBAAwB;AAC1B;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;EAClB,oBAAoB;EACpB,gCAAgC;EAChC,kBAAkB;EAClB,iBAAiB;AACnB;;AAEA;EACE,eAAe;EACf,mBAAmB;EACnB,cAAc;EACd,oBAAoB;EACpB,YAAY;EACZ,eAAe;EACf,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;AACtB;;AAEA;EACE,oBAAoB;EACpB,gBAAgB;EAChB,mBAAmB;AACrB;;AAEA;EACE,SAAS;EACT,qBAAqB;EACrB,kBAAkB;AACpB;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,eAAe;EACf,yBAAyB;EACzB,oBAAoB;EACpB,qBAAqB;EACrB,sCAAsC;EACtC,mBAAmB;EACnB,kBAAkB;AACpB;;AAEA;EACE,aAAa;EACb,8BAA8B;EAC9B,UAAU;AACZ;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE;IACE,sBAAsB;IACtB,uBAAuB;EACzB;;EAEA;IACE,sBAAsB;IACtB,kBAAkB;EACpB;;EAEA;IACE,wBAAwB;EAC1B;AACF",sourcesContent:[".statistics-mpo-header {\n margin-top: 10px;\n padding-bottom: 5px;\n border-bottom: 1px solid var(--grey-2);\n gap: 10px;\n}\n\n.statistics-mpo-header > * {\n font-weight: bold;\n}\n\n.statistics-mpo-header > *:first-child {\n width: 130px;\n}\n\n.statistics-mpo-header > *:nth-child(2) {\n width: 120px;\n min-width: 60px;\n}\n\n.statistics-mpo-header > *:nth-child(3) {\n flex-grow: 1;\n}\n\n.statistics-mpo-property-cell {\n width: 130px;\n max-width: 130px;\n align-self: flex-end;\n margin-bottom: 20px !important;\n}\n\n.ui-form .statistics-mpo-property-cell > div:first-child {\n padding-left: 4px;\n}\n\n.statistics-mpo-property-cell > div:first-child {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.statistics-mpo-weight-input {\n width: 100px;\n}\n\n.statistics-mpo-weight-cell {\n align-self: flex-end;\n margin-bottom: 20px !important;\n align-items: center;\n gap: 4px;\n}\n\n.statistics-mpo-control-buttons {\n gap: 10px;\n margin-left: 10px;\n color: var(--blue-1);\n visibility: hidden;\n white-space: nowrap;\n flex-shrink: 0;\n}\n\n.statistics-mpo-row:hover .statistics-mpo-control-buttons,\n.statistics-mpo-cat-row:hover .statistics-mpo-control-buttons {\n visibility: visible;\n}\n\n.statistics-mpo-range-input {\n width: 70px;\n}\n\n.statistics-mpo-row {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 8px 0;\n min-height: 70px;\n gap: 10px;\n\n flex-wrap: wrap;\n}\n\n.statistics-mpo-row > * {\n flex: 0 0 auto;\n}\n\n\n.statistics-mpo-row .ui-input-choice .ui-input-editor {\n width: 100px !important;\n max-width: none !important;\n}\n\n.ui-form .statistics-mpo-row .ui-input-root {\n margin-bottom: 0 !important;\n padding: 0 !important;\n}\n\n.statistics-mpo-editor-fill {\n width: 100%;\n height: 100%;\n}\n\n.statistics-mpo-cat-editor {\n width: 280px;\n margin-left: 30px;\n}\n\n.statistics-mpo-cat-row {\n display: flex;\n align-items: center;\n gap: 4px;\n margin-bottom: 2px;\n}\n\n.statistics-mpo-cat-name {\n width: 120px;\n}\n\n.statistics-mpo-cat-col-header {\n font-size: 11px;\n color: var(--grey-3);\n text-transform: uppercase;\n letter-spacing: 0.3px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-editor {\n width: auto;\n margin-left: 0;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-cat-name {\n flex: 1;\n width: auto;\n}\n\n.statistics-mpo-cat-desirability {\n width: 70px;\n}\n\n.statistics-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-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.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.statistics-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.statistics-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\n.statistics-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n overflow: clip;\n}\n\n.statistics-compute-dialog-descriptors-group {\n margin-left: 16px;\n overflow: hidden;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.statistics-mpo-weight-toggle {\n cursor: pointer;\n color: var(--grey-4);\n font-size: 12px;\n}\n\n.statistics-mpo-weight-toggle:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-weight-toggle-active {\n color: var(--grey-4);\n}\n\n.statistics-mpo-weight-toggle-active:hover {\n color: var(--grey-5);\n}\n\n.statistics-mpo-hidden {\n display: none !important;\n}\n\n.statistics-mpo-empty-state {\n text-align: center;\n padding: 48px 24px;\n color: var(--grey-4);\n border: 1px dashed var(--grey-2);\n border-radius: 8px;\n margin: 16px 12px;\n}\n\n.statistics-mpo-empty-state i {\n font-size: 48px;\n margin-bottom: 16px;\n display: block;\n color: var(--blue-1);\n opacity: 0.3;\n cursor: default;\n pointer-events: none;\n}\n\n.statistics-mpo-empty-state h3 {\n color: var(--grey-5);\n}\n\n.statistics-mpo-empty-state p {\n color: var(--grey-3);\n max-width: 360px;\n margin-inline: auto;\n}\n\n.statistics-mpo-dialog-header-row {\n gap: 12px;\n align-items: flex-end;\n margin-bottom: 8px;\n}\n\n.statistics-mpo-dialog-header-row .ui-input-root {\n flex: 0 1 auto;\n}\n\n.statistics-mpo-section-header {\n font-size: 11px;\n text-transform: uppercase;\n color: var(--blue-1);\n letter-spacing: 0.5px;\n border-bottom: 1px solid var(--grey-2);\n padding-bottom: 4px;\n margin: 12px 0 8px;\n}\n\n.statistics-mpo-param-grid.ui-form {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 0 8px;\n}\n\n.statistics-mpo-desirability-dialog .statistics-mpo-plot {\n margin: 0 auto;\n}\n\n@media (max-width: 500px) {\n .statistics-mpo-row {\n flex-direction: column;\n align-items: flex-start;\n }\n\n .statistics-mpo-row > * {\n width: 100% !important;\n margin-bottom: 5px;\n }\n\n .statistics-mpo-weight-cell {\n margin-top: 0 !important;\n }\n}\n"],sourceRoot:""}]);const r=s},677(e,t,i){"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),a=i(314),s=i.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}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 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;;AAEA;IACI,kCAAkC;AACtC;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,WAAW;IACX,YAAY;AAChB;;AAEA;IACI,SAAS;IACT,gBAAgB;AACpB;;AAEA;IACI,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;AACvB",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}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}"],sourceRoot:""}]);const r=s},542(e,t,i){"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),a=i(314),s=i.n(a)()(o());s.push([e.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !important;\n}\n\n.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {\n margin: 0 !important;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB;;AAEA;IACI,yBAAyB;AAC7B;;AAEA;IACI,oBAAoB;AACxB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}\n\n.hit-design-stage-editing-dialog {\n z-index: 10000 !important;\n}\n\n.hit-design-groupped-campaigns-table .d4-accordion-pane-content.expanded {\n margin: 0 !important;\n}"],sourceRoot:""}]);const r=s},314(e){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var i="",n=void 0!==t[5];return t[4]&&(i+="@supports (".concat(t[4],") {")),t[2]&&(i+="@media ".concat(t[2]," {")),n&&(i+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),i+=e(t),n&&(i+="}"),t[2]&&(i+="}"),t[4]&&(i+="}"),i}).join("")},t.i=function(e,i,n,o,a){"string"==typeof e&&(e=[[null,e,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<e.length;c++){var d=[].concat(e[c]);n&&s[d[0]]||(void 0!==a&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=a),i&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=i):d[2]=i),o&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=o):d[4]="".concat(o)),t.push(d))}},t}},354(e){"use strict";e.exports=function(e){var t=e[1],i=e[3];if(!i)return t;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[t].concat([a]).join("\n")}return[t].join("\n")}},72(e){"use strict";var t=[];function i(e){for(var i=-1,n=0;n<t.length;n++)if(t[n].identifier===e){i=n;break}return i}function n(e,n){for(var a={},s=[],r=0;r<e.length;r++){var l=e[r],c=n.base?l[0]+n.base:l[0],d=a[c]||0,u="".concat(c," ").concat(d);a[c]=d+1;var p=i(u),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,n);n.byIndex=r,t.splice(r,0,{identifier:u,updater:h,references:1})}s.push(u)}return s}function o(e,t){var i=t.domAPI(t);return i.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;i.update(e=t)}else i.remove()}}e.exports=function(e,o){var a=n(e=e||[],o=o||{});return function(e){e=e||[];for(var s=0;s<a.length;s++){var r=i(a[s]);t[r].references--}for(var l=n(e,o),c=0;c<a.length;c++){var d=i(a[c]);0===t[d].references&&(t[d].updater(),t.splice(d,1))}a=l}}},659(e){"use strict";var t={};e.exports=function(e,i){var n=function(e){if(void 0===t[e]){var i=document.querySelector(e);if(window.HTMLIFrameElement&&i instanceof window.HTMLIFrameElement)try{i=i.contentDocument.head}catch(e){i=null}t[e]=i}return t[e]}(e);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)}},540(e){"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56(e,t,i){"use strict";e.exports=function(e){var t=i.nc;t&&e.setAttribute("nonce",t)}},825(e){"use strict";e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(i){!function(e,t,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))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,i)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113(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 i(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={id:n,exports:{}};return e[n](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nc=void 0;var n={};(()=>{"use strict";i.r(n),i.d(n,{HTPackage:()=>pi,PackageFunctions:()=>vi,_package:()=>mi,demoFileIngest:()=>Zt,demoFileIngest1:()=>Xt,demoFileIngest2:()=>ei,demoFileSubmit:()=>ii,demoPeptideSequences:()=>ti,gasteigerCellRenderer:()=>ai,hitDesignApp:()=>zt,hitDesignAppTreeBrowser:()=>Yt,hitDesignVidPanel:()=>oi,hitTriageApp:()=>Wt,hitTriageAppTreeBrowser:()=>qt,htPackageSettingEditor:()=>si,pepTriageApp:()=>Kt,pepTriageAppTreeBrowser:()=>Qt,peptiHitApp:()=>Jt,peptiHitAppTreeBrowser:()=>Gt,registerMoleculesToViD:()=>ni});const e=grok,t=ui,o=DG,a="script",s="function-package",r="data-query",l="HTScript",c="HTQuery",d="molecules",u="campaignId",p="campaignId",m="enriched_table.csv",h="campaign.json",v="HitTriageDataSource",f="HitTriageSubmitFunction",g="Selected hits",y="Stage",A="Molecule",w="Helm",b="V-iD",C="HIT_DESIGN_VID",E="Source",T="New Template",x="Start",S="Create",N="Download",B="Cancel",I="Continue Campaign",F="New Campaign",P="No Information",_="HDCampaignsGrouping",k="HDCampaignTableColumns",V="HDCampaignsTableSorting";var L;!function(e){e.None="None",e.Template="Template",e.Status="Status",e.Author="Author",e.LastModifiedUser="Last Modified User"}(L||(L={}));const O={Name:e=>{var t;return null!==(t=e.friendlyName)&&void 0!==t?t:e.name},Code:e=>e.name,Created:e=>e.createDate,Author:e=>{var t;return null!==(t=e.authorUserFriendlyName)&&void 0!==t?t:""},"Last Modified by":e=>{var t;return null!==(t=e.lastModifiedUserName)&&void 0!==t?t:""},Molecules:e=>{var t;return(null!==(t=e.rowCount)&&void 0!==t?t:0).toString()},Status:e=>e.status},D="HTCampaignsGrouping",$="HTCampaignTableColumns",M="HTCampaignsTableSorting",R={Name:e=>{var t;return null!==(t=e.friendlyName)&&void 0!==t?t:e.name},Code:e=>e.name,Created:e=>e.createDate,Author:e=>{var t;return null!==(t=e.authorUserFriendlyName)&&void 0!==t?t:""},"Last Modified by":e=>{var t;return null!==(t=e.lastModifiedUserName)&&void 0!==t?t:""},Total:e=>{var t;return(null!==(t=e.rowCount)&&void 0!==t?t:0).toString()},Selected:e=>{var t;return(null!==(t=e.filteredRowCount)&&void 0!==t?t:0).toString()},Status:e=>e.status},j="pepTriageDataSource";var U=i(72),H=i.n(U),q=i(825),Y=i.n(q),G=i(659),W=i.n(G),z=i(56),J=i.n(z),Q=i(540),K=i.n(Q),Z=i(113),X=i.n(Z),ee=i(558),te={};function ie(e){var t,i,n;const o=null!==(t=localStorage.getItem(e))&&void 0!==t?t:"{}";try{const e=JSON.parse(o);return{order:null!==(i=null==e?void 0:e.order)&&void 0!==i?i:[],hidden:null!==(n=null==e?void 0:e.hidden)&&void 0!==n?n:[]}}catch(e){console.error("error parsing function ordering",e)}return{order:[],hidden:[]}}function ne(e){var t;try{return null===(t=e.package)||void 0===t?void 0:t.name}catch(e){return}}async function oe(e,t,i){if(0===i.rowCount)return;if(!e.col(t))throw new Error("There is no molecule column in dataframe");let n=i.col(d);if(n||(await i.meta.detectSemanticTypes(),n=i.columns.bySemType(o.SEMTYPE.MOLECULE)),!n)throw new Error("There is no original molecule column in query result dataframe");const a=i.columns.names().filter(e=>e!==d);e.join(i,[t],[n.name],void 0,a,void 0,!0)}te.styleTagTransform=X(),te.setAttributes=J(),te.insert=W().bind(null,"head"),te.domAPI=Y(),te.insertStyleElement=K(),H()(ee.A,te),ee.A&&ee.A.locals&&ee.A.locals;var ae=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const se=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function re(e,t){const i=document.title,n=window.location.href.split("?")[0]+"?"+e+"="+t;if(history.replaceState){const e={Title:i,Url:n};history.replaceState(e,e.Title,e.Url)}}function le(i,n,o,a){var s;const r=t.breadcrumbs([n,o]),l=r.onPathClick.subscribe(e=>{1===e.length&&(l.unsubscribe(),ce(i),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 ce(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function de(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 ue(t,i){return ae(this,void 0,void 0,function*(){var n,a,s,r,l;const c=o.User.current().id,d=null===(n=o.User.current().group)||void 0===n?void 0:n.id;if(t===c)return!0;for(const t of i){const i=yield e.dapi.groups.find(t);if(i)if(i.personal){const t=yield e.dapi.groups.getUser(i);if((null==t?void 0:t.id)===c)return!0}else if(d){if((null!==(s=null===(a=i.members)||void 0===a?void 0:a.length)&&void 0!==s?s:0)>0&&i.members.some(e=>e.id===d))return!0;if((null!==(l=null===(r=i.adminMembers)||void 0===r?void 0:r.length)&&void 0!==l?l:0)>0&&i.adminMembers.some(e=>e.id===d))return!0}}return!1})}function pe(e,t){return ae(this,void 0,void 0,function*(){return ue(e,t.edit)})}function me(e,t){return ae(this,void 0,void 0,function*(){return ue(e,Array.from(new Set([...t.view,...t.edit])))})}function he(e){return localStorage.getItem(e)}function ve(e,t){localStorage.setItem(e,t)}function fe(e){ve(_,e)}function ge(e,t,i){if(!t)return;const n=null!=i?i:O,o=t.columnName in n?n[t.columnName]:e=>{var i,n,o;return null!==(o=null===(i=e.campaignFields)||void 0===i?void 0:i[null!==(n=t.columnName.replace("campaignFields.",""))&&void 0!==n?n:""])&&void 0!==o?o:""},a=new Map;e.forEach(e=>{a.set(e,o(e))});const s=Array.from(a.values()).every(e=>{var t;return Se(e)||!isNaN(Number(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:""))}),r=!s&&Array.from(a.values()).every(e=>{var t;return Se(e)||!isNaN(Date.parse(null!==(t=null==e?void 0:e.toString())&&void 0!==t?t:""))});s?e.forEach(e=>{a.set(e,Se(a.get(e))?t.ascending?1/0:-1/0:Number(a.get(e)))}):r&&e.forEach(e=>{var i,n;a.set(e,Se(a.get(e))?t.ascending?1/0:-1/0:Date.parse(null!==(n=null===(i=a.get(e))||void 0===i?void 0:i.toString())&&void 0!==n?n:""))}),e.sort((e,i)=>{const n=a.get(e),o=a.get(i);if(s||r)return t.ascending?n-o:o-n;const l=Se(n)?"":n.toString(),c=Se(o)?"":o.toString();return t.ascending?l.localeCompare(c):c.localeCompare(l)}),a.clear()}function ye(){const e=he(k),t=["Code","Created","Author","Last Modified by","Molecules","Status"];if(!e)return t;try{const i=JSON.parse(e);return Array.isArray(i)&&i.every(e=>"string"==typeof e)?i:t}catch(e){return console.error("error parsing campaign table columns",e),t}}function Ae(e){ve(k,JSON.stringify(e))}function we(e){ve(D,e)}function be(){const e=he($),t=["Created","Author","Total","Selected","Status"];if(!e)return t;try{const i=JSON.parse(e);return Array.isArray(i)&&i.every(e=>"string"==typeof e)?i:t}catch(e){return console.error("error parsing HT campaign table columns",e),t}}function Ce(e){ve($,JSON.stringify(e))}const Ee=(e,t)=>{var i,n,o,a,s,r;switch(e){case L.Template:return null!==(n=null===(i=t.template)||void 0===i?void 0:i.key)&&void 0!==n?n:t.templateName;case L.Status:return t.status;case L.Author:return null!==(o=t.authorUserFriendlyName)&&void 0!==o?o:P;case L.LastModifiedUser:return null!==(a=t.lastModifiedUserName)&&void 0!==a?a:P;default:if(e.startsWith("campaignFields.")){const i=e.replace("campaignFields.","");return null!==(r=null===(s=t.campaignFields)||void 0===s?void 0:s[i])&&void 0!==r?r:P}return""}};function Te(e,t){if(t===L.None)return{"":e};const i={};for(const n of e){const e=Ee(t,n);i[e]||(i[e]=[]),i[e].push(n)}return i}function xe(e,i,n=9){e.classList.add("hit-design-groupped-campaigns-table");const o=Object.keys(i);if(o.length<2)return e;const a=e.getElementsByTagName("tbody")[0],s=Array.from(e.getElementsByTagName("tr")).filter(e=>!e.classList.contains("header"));let r=0;const l=(e,t,i)=>{var n;for(let o=t;o<i;o++)(null===(n=s[o])||void 0===n?void 0:n.style)&&(s[o].style.display=e?"table-row":"none")};for(const e of o){const o=s[r];if(!o)break;const c=i[e].length,d=r,u=r+c,p=t.accordion(`Hit-Design-campaigns-group-${e}`).addPane(e,()=>t.div(),void 0,void 0,!1);p.root.style.marginLeft="-24px",p.root.onclick=()=>{l(p.expanded,d,u)},l(p.expanded,d,u);const m=a.insertRow(0),h=m.insertCell(0);h.appendChild(p.root),h.colSpan=n,a.insertBefore(m,o),r+=c}}function Se(e){return""===e||null==e||"number"==typeof e&&isNaN(e)}function Ne(e){return ae(this,void 0,void 0,function*(){return JSON.parse(yield mi.files.readAsText(e))})}const Be={String:o.TYPE.STRING,Number:o.TYPE.FLOAT,Boolean:o.TYPE.BOOL,Date:o.TYPE.DATE_TIME,Molecule:o.SEMTYPE.MOLECULE};var Ie=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};function Fe(i,n){return Ie(this,arguments,void 0,function*(i,n,a=v,s){var r,l,c;const d=t.divText("",{style:{color:"red"}});let u=null;const p=()=>Ie(this,void 0,void 0,function*(){try{if(u=m.value,!u)return;if(yield u.meta.detectSemanticTypes(),!u.columns.bySemType(o.SEMTYPE.MOLECULE))return void(d.innerText="No molecules column found");d.innerText=""}catch(e){d.innerText="Error parsing file"}}),m=t.input.table("Dataframe",{onValueChanged:p});yield p();const h=t.div([m,d]);0===Object.keys(n).length&&Array.from(new Set(o.Func.find({meta:{role:a}}).concat(o.Func.find({tags:[a]})))).forEach(e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});let f=null;const g=()=>Ie(this,void 0,void 0,function*(){const e=n[A.value];f=e.prepare();const t=yield f.getEditor();t.classList.remove("ui-form"),y.innerHTML="",y.appendChild(t)}),y=t.div([]),A=t.input.choice(E,{value:null!==(r=i.queryFunctionName)&&void 0!==r?r:Object.keys(n)[0],items:Object.keys(n),onValueChanged:g});yield g(),i.queryFunctionName&&(null===(l=A.root.getElementsByTagName("select").item(0))||void 0===l||l.setAttribute("disabled","true"));const w=t.div([A,y]);w.style.display="none";const b=t.div([h,w]),C=t.input.string("Campaign Name",{value:"",nullable:!0});C.setTooltip("Optional friendly name for the campaign");const T=i.campaignFields.map(e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e).map(e=>o.Property.fromOptions(Object.assign({name:e.name,type:Be[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{}))),S={},N=T.length?t.input.form(S,T):t.div();N.classList.remove("ui-form"),"File"===i.dataSourceType?(h.style.display="inherit",w.style.display="none"):(h.style.display="none",w.style.display="inherit");const I=t.div([C.root,...null!==(c=null==s?void 0:s.extraFormElements)&&void 0!==c?c:[],b,...T.length?[N]:[]]),F=t.buttonsInput([]);I.appendChild(F);const P=new Promise(o=>{const a=()=>Ie(this,void 0,void 0,function*(){var t,a,r,l;if("File"===i.dataSourceType){if(!u)return void e.shell.error("No file selected");const i=u;i.name=u.name;const n=(null===(t=C.value)||void 0===t?void 0:t.trim())||void 0,r=null===(a=null==s?void 0:s.getExtraData)||void 0===a?void 0:a.call(s);o({df:i,type:"File",campaignProps:S,friendlyName:n,extraData:r})}else{const t=n[A.value];if(!t)return void e.shell.error("No function selected");const i={};Object.entries(f.inputs).forEach(([e,t])=>{i[e]=t});const a=yield t.apply(i),c=(null===(r=C.value)||void 0===r?void 0:r.trim())||void 0,d=null===(l=null==s?void 0:s.getExtraData)||void 0===l?void 0:l.call(s);o({df:a,type:"Query",campaignProps:S,friendlyName:c,extraData:d})}}),r=t.bigButton(x,()=>a());F.appendChild(r)});return{promise:P,root:I,cancelPromise:new Promise(e=>{t.button(B,()=>e())})}})}var Pe=i(233),_e=i.n(Pe),ke=i(801),Ve={};async function Le(e,i,n,d,u,p,m){var h,v,f,g,y,A,w,b,C,E,T,x,S,N,B,I;const F=null!=m?m:"HTFunctionOrderingLS",P=[];e.functions.filter(({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType).forEach(e=>{var t,i,n,o;P.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==d?void 0:d.compute)||void 0===t?void 0:t.functions)||void 0===i?void 0:i.find(t=>t.name===e.name&&t.package===e.package.name))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})}),e.scripts.filter(({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType).forEach(e=>{var t,i,n,o;P.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==d?void 0:d.compute)||void 0===t?void 0:t.scripts)||void 0===i?void 0:i.find(t=>t.id===e.id))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})}),e.queries.filter(e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType).forEach(e=>{var t,i,n,o;P.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==d?void 0:d.compute)||void 0===t?void 0:t.queries)||void 0===i?void 0:i.find(t=>t.id===e.id))||void 0===n?void 0:n.args)&&void 0!==o?o:{}})});const _=t.div([],{classes:"statistics-compute-dialog-host"}),k=[],V=t.tree(),L=t.wait(async()=>{var e,i,n;try{if(!p)return t.divText("No descriptors provider configured");const o=await p();function a(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}V.root.classList.add("statistics-compute-dialog-descriptors-group");const s=Object.keys(o),r=null!==(n=null===(i=null===(e=null==d?void 0:d.compute)||void 0===e?void 0:e.descriptors)||void 0===i?void 0:i.args)&&void 0!==n?n:[];for(const l of s){const c=a(l,V);for(const u of o[l].descriptors){const m=c.item(u.name,u);k.push(m),m.enableCheckBox(r.includes(u.name))}}return V.root}catch(h){console.error(h)}return t.divText("Failed to load descriptors")});L.classList.add("oy-scroll");const O="Descriptors",D={[O]:O},$={[O]:L},M={},R={[O]:!1};R[O]=!!(null===(v=null===(h=null==d?void 0:d.compute)||void 0===h?void 0:h.descriptors)||void 0===v?void 0:v.enabled)&&(null===(y=null===(g=null===(f=null==d?void 0:d.compute)||void 0===f?void 0:f.descriptors)||void 0===g?void 0:g.args)||void 0===y?void 0:y.length)>0;for(const e of P)try{const i=e.func,n=i.prepare(e.args),o=i.type===s?`${i.package.name}:${i.name}`:i.type===a?`${l}:${null!==(A=i.name)&&void 0!==A?A:""}:${i.id}`:`${c}:${null!==(w=i.name)&&void 0!==w?w:""}:${i.id}`;M[o]=n;const u=t.div();t.setUpdateIndicator(u,!0),n.buildEditor(u,{condensed:!1}).then(t=>{var n,o;(null===(n=null==t?void 0:t[0])||void 0===n?void 0:n.root)&&(t[0].root.style.display="none"),(null===(o=null==t?void 0:t[1])||void 0===o?void 0:o.root)&&i.type!==r&&(t[1].root.style.display="none"),t.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(e=>{console.error(e),t.setUpdateIndicator(u,!1),u.appendChild(t.divText("Failed to build function editor"))}).finally(()=>t.setUpdateIndicator(u,!1)),u.classList.add("oy-scroll"),u.style.marginLeft="15px",u.style.removeProperty("max-width"),$[null!==(b=i.friendlyName)&&void 0!==b?b:i.name]=u,D[null!==(C=i.friendlyName)&&void 0!==C?C:i.name]=o,R[o]=null!==(I=(null===(T=null===(E=null==d?void 0:d.compute)||void 0===E?void 0:E.functions)||void 0===T?void 0:T.some(t=>e.func.type===s&&t.name===e.func.name&&t.package===ne(e.func)))||(null===(S=null===(x=null==d?void 0:d.compute)||void 0===x?void 0:x.scripts)||void 0===S?void 0:S.some(e=>e.id===i.id))||(null===(B=null===(N=null==d?void 0:d.compute)||void 0===N?void 0:N.queries)||void 0===B?void 0:B.some(e=>e.id===i.id)))&&void 0!==I&&I}catch(e){console.error(e);continue}const j=t.tabControl($,!0);function U(e){var i,n;j.clear();let o=null!==(i=e.order)&&void 0!==i?i:Object.keys($);0===o.length&&(o=Object.keys($)),o.forEach(e=>{$[e]&&j.addPane(e,()=>$[e])}),Object.keys($).forEach(t=>{var i;o.includes(t)||!$[t]||(null!==(i=e.hidden)&&void 0!==i?i:[]).includes(t)||j.addPane(t,()=>$[t])}),(null!==(n=e.hidden)&&void 0!==n?n:[]).forEach(e=>{R[D[e]]=!1}),j.panes.forEach(e=>{const i=t.input.bool("",{value:R[D[e.name]],onValueChanged:t=>{var i,n;R[D[e.name]]=!!t,t?null===(n=_e()(e.content).find("input"))||void 0===n||n.removeAttr("disabled"):null===(i=_e()(e.content).find("input"))||void 0===i||i.attr("disabled","true")}});i.setTooltip("Toggle calculation of this function"),e.header.appendChild(i.root),e.header.classList.add("statistics-compute-dialog-pane-header")}),j.panes.length>0&&(j.currentPane=j.panes[0])}function H(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=R[O]?k.filter(e=>e.checked).map(e=>e.value.name):[];const t=Object.entries(M).filter(([e,t])=>R[e]);t.filter(([e,t])=>!e.startsWith(l)&&!e.startsWith(c)).forEach(([t,i])=>{e.externals[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach(([i,n])=>{e.externals[t][i]=n})}),t.filter(([e,t])=>e.startsWith(l)).forEach(([t,i])=>{e.scripts[t]={};const n=i.inputs;Object.entries(n).slice(2).forEach(([i,n])=>{e.scripts[t][i]=n})}),t.filter(([e,t])=>e.startsWith(c)).forEach(([t,i])=>{e.queries[t]={};const n=i.inputs;Object.entries(n).slice(1).forEach(([i,n])=>{e.queries[t][i]=n})}),console.log(e),i(e)}return j.onTabChanged.subscribe(()=>{try{j.currentPane.content.style.removeProperty("max-width")}catch(e){}}),j.header.style.overflow="scroll",j.root.style.width="100%",j.root.style.minWidth="350px",_.appendChild(j.root),U(ie(F)),j.root.appendChild(function(e,i,n){var a;const s=ie(n),r=o.DataFrame.fromColumns(e.map(e=>o.Column.fromStrings(e,[e])));r.columns.setOrder(null!==(a=s.order)&&void 0!==a?a:[]);const l=t.input.columns("reorder",{table:r,value:r.columns.toList().filter(e=>!s.hidden.includes(e.name))});l.onChanged.subscribe(()=>{try{const t=l.value.map(e=>e.name),o=e.filter(e=>!t.includes(e)),a={order:l.value.map(e=>e.name),hidden:o};r.columns.setOrder(a.order),function(e,t){localStorage.setItem(t,JSON.stringify(e))}(a,n),i(a)}catch(e){console.error(e)}});const c=Array.from(l.root.children);setTimeout(()=>{c.forEach(e=>{e.style.maxWidth="0px",e.style.overflow="hidden",e.style.padding="0px",e.style.paddingRight="0px",e.style.visibility="hidden",e instanceof HTMLLabelElement&&(e.style.display="none")})},200),l.root.style.justifyContent="end",l.root.style.width="40px",l.root.style.height="0px",l.root.style.overflow="visible",l.root.style.padding="0px";const d=t.icons.edit(()=>{c.forEach(e=>{e.click()})},"Order or hide functions");return l.addOptions(d),Array.from(l.root.children).forEach(e=>{e.style.borderBottom="unset"}),d.style.fontSize="16px",l.root}(Object.keys($),e=>{U(e)},F)),u&&t.dialog("Compute").add(_).onOK(()=>H()).onCancel(n).show({resizable:!0}),{root:_,okProxy:H}}Ve.styleTagTransform=X(),Ve.setAttributes=J(),Ve.insert=W().bind(null,"head"),Ve.domAPI=Y(),Ve.insertStyleElement=K(),H()(ke.A,Ve),ke.A&&ke.A.locals&&ke.A.locals;function Oe(t,i,n,o,a){return s=this,r=void 0,c=function*(){return Le(t.computeFunctions,i,n,o,a,()=>e.chem.descriptorsTree(),"HTFunctionOrderingLS")},new((l=void 0)||(l=Promise))(function(e,t){function i(e){try{o(c.next(e))}catch(e){t(e)}}function n(e){try{o(c.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof l?o:new l(function(e){e(o)})).then(i,n)}o((c=c.apply(s,r||[])).next())});var s,r,l,c}const De=rxjs;class $e{constructor(e,i=[],n={}){this.onItemChanged=new De.Subject,this.onAddingItemChanged=new De.Subject,this.onItemAdded=new De.Subject,this.onItemRemoved=new De.Subject,this.options={removeButtonTooltip:"Remove item",addButtonTooltip:"Add item",allowAdd:!0,allowRemove:!0},this.addingItemInputs={},this.properties=e,this.options=Object.assign(Object.assign({},this.options),n),this._root=t.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=i,this.render()}get root(){return this._root}get items(){return this._items}set items(e){this._items=e,this.render()}addItem(e,t=!0){this._items.push(e),this.render(),t&&this.onItemAdded.next(e)}removeItem(e,t=!0){-1!==this._items.indexOf(e)&&(this._items.splice(this._items.indexOf(e),1),this.render(),t&&this.onItemRemoved.next(e))}removeAtIndex(e,t=!0){if(e<0||e>=this._items.length)return;const i=this._items.splice(e,1);this.render(),t&&this.onItemRemoved.next(i[0])}removeAllItems(){this._items=[],this.render()}render(){var e,i,n,o,a;if(t.empty(this._root),!this.options.horizontalInputNames)for(const n of this.properties){let o=null!==(e=n.caption)&&void 0!==e?e:n.name;(null===(i=this.options.customLabels)||void 0===i?void 0:i[n.name])&&(o=this.options.customLabels[n.name]);const a=t.divText(o);a.style.fontWeight="bold",this._root.appendChild(a)}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!==(a=null===(o=(n=this.options).newItemFunction)||void 0===o?void 0:o.call(n))&&void 0!==a?a:void 0,!0);for(const t of e)this._root.appendChild(t)}}get addingItem(){const e={};return Object.keys(this.addingItemInputs).forEach(t=>{e[t]=this.addingItemInputs[t].value}),e}getItemDiv(e={},i){var n,a;const s=[],r={};let l=null;for(const c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const d=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](e):t.input.forProperty(c,e),u=null===(a=this.options.validators)||void 0===a?void 0:a[c.name];u&&d.addValidator(u),s.push(this.options.horizontalInputNames?d.root:this.hideLabel(d.root)),c.propertyType!==o.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&d.input&&(d.input.style.width="100%"),r[c.name]=d,d.onChanged.subscribe(()=>{e[c.name]=d.value,i?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})}),d.root.style.alignItems="center",l=d}let c=null;if(i)this.addingItemInputs=r,c=t.icons.add(()=>{const e=this.options.newItemFunction?this.options.newItemFunction():{};Object.keys(r).forEach(t=>{e[t]=r[t].value}),this._items.push(e),this.onItemAdded.next(e),this.render()},this.options.addButtonTooltip);else{if(!this.options.allowRemove)return s;c=t.icons.delete(()=>{this._items.splice(this._items.indexOf(e),1),this.onItemRemoved.next(e),this.render()},this.options.removeButtonTooltip)}return l&&l.addOptions?l.addOptions(c):null==l||l.root.appendChild(c),c.style.color="#2083d5",s}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}function Me(){const i=o.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),n=o.InputBase.forProperty(i);let a=null,s=null,r=null,l=null;return n.onChanged.subscribe(t=>{return i=this,c=void 0,u=function*(){const t=n.value;if(t){try{const i=!!t.fullPath&&(yield e.dapi.files.exists(t.fullPath));r=i?t.fullPath:null}catch(e){r=null}try{const e=yield t.readAsString(),i=o.ViewLayout.fromJson(e);i?(a=i,s=i.viewState,l=null):(a=null,s=null,r=null,l="Invalid layout file")}catch(e){a=null,s=null,r=null,l="Invalid layout file"}n.input.classList[l?"add":"remove"]("d4-invalid")}else a=null,s=null,r=null},new((d=void 0)||(d=Promise))(function(e,t){function n(e){try{a(u.next(e))}catch(e){t(e)}}function o(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var i;t.done?e(t.value):(i=t.value,i instanceof d?i:new d(function(e){e(i)})).then(n,o)}a((u=u.apply(i,c||[])).next())});var i,c,d,u}),t.tooltip.bind(n.root,()=>l||"Select a layout file"),{dataFileInput:n,getLayout:()=>a,getLayoutViewState:()=>s,getLocalFilePath:()=>r}}var Re=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};function je(i,n,a){return Re(this,void 0,void 0,function*(){var s,r,d;const u=(yield mi.files.list("Hit Triage/templates")).map(e=>e.name.slice(0,-5)),p=[];for(const e of u){const t=yield Ne(`Hit Triage/templates/${e}.json`);p.push(t.key)}const m=Array.from(new Set(o.Func.find({meta:{role:f}}).concat(o.Func.find({tags:[f]})))),h={};m.forEach(e=>{var t;h[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const g=(null==a?void 0:a.submit)?Object.keys(h).find(e=>{var t,i;return(null===(t=h[e])||void 0===t?void 0:t.name)===(null===(i=a.submit)||void 0===i?void 0:i.fName)}):null,y=t.input.choice("Submit function",{value:null!=g?g:null,items:[null,...Object.keys(h)]});g||(y.value=null),y.nullable=!0,y.fireChanged(),y.setTooltip("Select function to be called upon submitting");const A=Me(),w=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),b=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),C=t.input.string("Name",{value:a?`${a.name} (copy)`:"",onValueChanged:e=>{""===e||u.includes(e)?(C.root.style.borderBottom="1px solid red",w.style.opacity="100%"):(C.root.style.borderBottom="none",w.style.opacity="0%")}}),T=t.input.string("Key",{value:a?`${a.key}-copy`:"",onValueChanged:e=>{""===e||p.includes(e)?(T.root.style.borderBottom="1px solid red",b.style.opacity="100%"):(T.root.style.borderBottom="none",b.style.opacity="0%")}});T.setTooltip("Template key used for campaign prefix"),C.setTooltip("Template name"),C.root.style.borderBottom="none",T.root.style.borderBottom="none",w.style.opacity="0%",b.style.opacity="0%";let x=null;const N=a||{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},I=yield Oe(i,e=>{x=e},()=>null,N,!1);I.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&Array.from(new Set(o.Func.find({meta:{role:v}}).concat(o.Func.find({tags:[v]})))).forEach(e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const F=Object.keys(n),P=t.input.choice(E,{value:F[0],items:F}),_=t.input.choice("Ingest using",{value:null!==(s=null==a?void 0:a.dataSourceType)&&void 0!==s?s:"Query",items:["Query","File"],onValueChanged:e=>{P.root.style.display="Query"===e?"block":"none"}});(null==a?void 0:a.dataSourceType)&&(P.root.style.display="Query"===a.dataSourceType?"block":"none");const k=Ue(null==a?void 0:a.campaignFields),V=t.div([t.h2("Details"),t.div([C,w]),t.div([T,b]),_.root,P.root,A.dataFileInput,k.fieldsDiv,t.h2("Compute"),I.root,t.h2("Submit"),y.root],"ui-form"),L=t.buttonsInput([]),O=null!==(d=null===(r=L.getElementsByClassName("ui-input-editor"))||void 0===r?void 0:r[0])&&void 0!==d?d:L;V.appendChild(L);const D=new Promise(e=>{const i=t.button(B,()=>e());O.appendChild(i)}),$=new Promise(i=>{const n=t.bigButton(S,()=>function(){return Re(this,void 0,void 0,function*(){var t,n,o,a,s,r,d,u;if(I.okProxy(),"100%"===w.style.opacity)return void e.shell.error("Template name is empty or already exists");const p=y.value?h[y.value]:void 0,m=Object.assign(Object.assign({name:C.value,key:T.value,campaignFields:k.getFields(),dataSourceType:null!==(t=_.value)&&void 0!==t?t:"Query",layoutViewState:null!==(n=A.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==x?void 0:x.descriptors)||void 0===o?void 0:o.length),args:null!==(a=null==x?void 0:x.descriptors)&&void 0!==a?a:[]},functions:Object.entries(null!==(s=null==x?void 0:x.externals)&&void 0!==s?s:{}).map(([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(r=null==x?void 0:x.scripts)&&void 0!==r?r:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(d=null==x?void 0:x.queries)&&void 0!==d?d:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})}},p?{submit:{fName:p.name,package:ne(p)}}:{}),{queryFunctionName:"Query"===_.value&&null!==(u=P.value)&&void 0!==u?u:void 0});var v;v=m,mi.files.writeAsText(`Hit Triage/templates/${v.name}.json`,JSON.stringify(v)),e.shell.info("Template created successfully"),i(m)})}());O.appendChild(n)});return{root:V,template:$,cancelPromise:D}})}function Ue(e){const i=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING}),o.Property.fromOptions({name:"Type",type:o.TYPE.STRING,choices:Object.keys(Be)}),o.Property.fromOptions({name:"Required",type:o.TYPE.BOOL})],n=new $e(i,e?e.map(e=>({Name:e.name,Type:e.type,Required:e.required})):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let a={};n.onItemAdded.subscribe(e=>{a={}}),n.onAddingItemChanged.subscribe(e=>{e&&(a=e.item)});const s=t.h2("Additional fields");t.tooltip.bind(s,"Additional fields to be filled by user for each campaign");const r=t.div([s,n.root]);return{getFields:function(){var e;const t=n.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:t.div([r])}}var He=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class qe extends o.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return He(this,void 0,void 0,function*(){})}deleteCampaign(e,t){return He(this,void 0,void 0,function*(){yield mi.files.delete(`${e}/campaigns/${t}`)})}}var Ye=i(677),Ge={};Ge.styleTagTransform=X(),Ge.setAttributes=J(),Ge.insert=W().bind(null,"head"),Ge.domAPI=Y(),Ge.insertStyleElement=K(),H()(Ye.A,Ge),Ye.A&&Ye.A.locals&&Ye.A.locals;var We;!function(i){let n,o;!function(e){e.vert=function(e){return t.divV(e.map(e=>t.render(e)),{classes:"u2-panel"})},e.horz=function(e){return t.divH(e.map(e=>t.render(e)),{classes:"u2-panel"})}}(n=i.panels||(i.panels={})),i.appHeader=function(e){const i=t.iconImage("",e.iconPath);_e()(i).addClass("ui-app-header-icon").css("margin-right","20px"),e.iconSize&&(i.style.width=`${e.iconSize}px`,i.style.height=`${e.iconSize}px`);const o=n.horz([]);if(e.appTitle){o.classList.add("u2-app-header-with-name");const n=t.divV([t.divText(e.appTitle,"u2-app-header-app-name-div")],"u2-app-header-app-name-and-slogan-div");e.appSubTitle&&n.append(t.divText(e.appSubTitle));const a=t.div(i);o.append(t.divH([a,n]))}else o.append(i);const a=n.vert([t.markdown(e.description),e.learnMoreUrl?t.link("Learn more",e.learnMoreUrl,void 0,{style:{marginLeft:"15px"}}):null]);return a.classList.add("u2-app-header-description"),o.append(a),e.bottomLine&&o.classList.add("u2-app-header-bottom-line"),o},function(i){i.runAsync=function(i,n){return o=this,a=void 0,r=function*(){t.setUpdateIndicator(i,!0);try{return yield n()}catch(t){e.log.error(t)}finally{t.setUpdateIndicator(i,!1)}},new((s=void 0)||(s=Promise))(function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function n(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(i,n)}l((r=r.apply(o,a||[])).next())});var o,a,s,r}}(o=i.tools||(i.tools={}))}(We||(We={}));var ze=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const Je={view:[o.Group.defaultGroupsIds["All users"]],edit:[o.Group.defaultGroupsIds["All users"]]};class Qe{constructor(e){this.permissions=null!=e?e:Je,this.editGroupsInput=t.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=t.input.userGroups("Can View")}getDialogContent(){return ze(this,void 0,void 0,function*(){const i=[],n=[];for(const t of this.permissions.view){const n=yield e.dapi.groups.find(t);n&&i.push(n)}for(const t of this.permissions.edit){const i=yield e.dapi.groups.find(t);i&&n.push(i)}return this.editGroupsInput.value=n,this.viewGroupsInput.value=i,t.divV([this.viewGroupsInput.root,this.editGroupsInput.root])})}show(e){return ze(this,void 0,void 0,function*(){var i;const n=yield this.getDialogContent(),o=t.dialog("Edit Permissions").add(n).onOK(()=>{const t=new Set(this.editGroupsInput.value.map(e=>e.id)),i=new Set(this.viewGroupsInput.value.map(e=>e.id));this.permissions.edit=Array.from(t),t.forEach(e=>i.add(e)),this.permissions.view=Array.from(i),0===this.permissions.view.length&&(this.permissions.view=Je.view),e(this.permissions)});(null===(i=n.parentElement)||void 0===i?void 0:i.style)&&(n.parentElement.style.overflow="visible"),o.show()})}}var Ke=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class Ze extends qe{constructor(t){super(t),this.readmePath=mi.webRoot+"README_HT.md",this.dataSourceFunctionsMap={},this.currentGroupping="None",this.campaignsTableRoot=null,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)}refreshCampaignsTable(){return Ke(this,void 0,void 0,function*(){if(null!=this.campaignsTableRoot){t.setUpdateIndicator(this.campaignsTableRoot,!0);try{const e=yield this.getCampaignsTable();t.setUpdateIndicator(this.campaignsTableRoot,!1),t.empty(this.campaignsTableRoot),this.campaignsTableRoot.appendChild(e)}catch(t){e.shell.error("Failed to update campaigns table"),console.error(t)}finally{t.setUpdateIndicator(this.campaignsTableRoot,!1)}}})}getAppHeader(){return We.appHeader({iconPath:mi.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 "})}getTemplatesFolder(){return`${this.app.appName}/templates`}getDataSourceTag(){return v}getDataSourceFunctionsMap(){return this.dataSourceFunctionsMap}init(e){return Ke(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const i=t.h1(I),n=t.h1(F,{style:{marginLeft:"10px"}}),a=this.getAppHeader(),s=t.div(),r=t.div([],{classes:"ui-form"}),l=yield this.getCampaignsTable();this.campaignsTableRoot=t.div([l],{style:{position:"relative"}});const c=t.iconFA("layer-group",()=>Ke(this,void 0,void 0,function*(){const e=o.Menu.popup();Object.values(L).forEach(t=>{e.item(t,()=>Ke(this,void 0,void 0,function*(){we(t),yield this.refreshCampaignsTable()}))});const t=e.group("Campaign Fields"),i=yield mi.loadCampaigns(this.app.appName,this.deletedCampaigns),n=new Set;Object.values(i).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>n.add(e))}),Array.from(n).forEach(e=>{t.item(e,()=>Ke(this,void 0,void 0,function*(){we(`campaignFields.${e}`),yield this.refreshCampaignsTable()}))}),e.show({element:p,x:120,y:p.offsetTop+30})}));c.style.marginBottom="9px",c.style.marginLeft="8px",c.style.fontSize="15px",c.style.color="var(--blue-1)",t.tooltip.bind(c,()=>`Group Campaigns. Current: ${this.currentGroupping}`);const d=t.iconFA("eye",()=>Ke(this,void 0,void 0,function*(){const e=o.Menu.popup(),t=yield mi.loadCampaigns(this.app.appName,this.deletedCampaigns),i=Object.assign({},R);delete i.Name,Object.values(t).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>{i[`campaignFields.${e}`]=t=>{var i,n;return null!==(n=null===(i=t.campaignFields)||void 0===i?void 0:i[e])&&void 0!==n?n:""}})});const n=be().reduce((e,t)=>(e[t]=!0,e),{});Object.keys(i).filter(e=>!e.startsWith("campaignFields.")).forEach(t=>{var i;e.item(t,()=>{n[t]=!n[t],Ce(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!==(i=n[t])&&void 0!==i&&i})});const a=e.group("Campaign Fields");Object.keys(i).filter(e=>e.startsWith("campaignFields.")).forEach(e=>{var t;a.item(e.replace("campaignFields.",""),()=>{n[e]=!n[e],Ce(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!==(t=n[e])&&void 0!==t&&t})}),e.show({element:p,x:100,y:p.offsetTop+30})}));t.tooltip.bind(d,"Edit visible columns in campaigns table"),d.style.marginBottom="9px",d.style.marginLeft="8px",d.style.fontSize="15px",d.style.color="var(--blue-1)";const u=t.iconFA("sync",()=>Ke(this,void 0,void 0,function*(){yield this.refreshCampaignsTable()}));u.style.marginBottom="9px",u.style.marginLeft="8px",u.style.color="var(--blue-1)",t.tooltip.bind(u,()=>"Refresh campaigns table");const p=t.divH([i,d,c,u],{style:{alignItems:"center"}});yield this.startNewCampaign(s,r,e),_e()(this.root).empty(),this.root.appendChild(t.div([t.divV([a,p],{style:{marginLeft:"10px"}}),this.campaignsTableRoot,n,r,s],{classes:"hit-triage-info-view-container"}))}catch(e){throw t.setUpdateIndicator(this.root,!1),e}finally{t.setUpdateIndicator(this.root,!1)}})}startNewCampaign(i,n,o){return Ke(this,void 0,void 0,function*(){var a;const s=(yield mi.files.list(this.getTemplatesFolder())).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5));o&&!s.includes(o.name)&&s.push(o.name);let r=null,l=!0;const c=()=>Ke(this,void 0,void 0,function*(){if(!l)return;const e=d.value,t=o&&o.name===e?o:yield Ne(this.getTemplatesFolder()+"/"+e+".json");r=t;const n=yield this.getNewCampaignAccordeon(t,i);_e()(i).empty(),i.className="ui-form",i.appendChild(n)}),d=t.input.choice("Template",{value:null!==(a=null==o?void 0:o.name)&&void 0!==a?a:s[0],items:s,onValueChanged:()=>Ke(this,void 0,void 0,function*(){yield c()})});d.root.style.width="100%";const u=t.icons.add(()=>Ke(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),t.setUpdateIndicator(this.root,!1)}),T),p=t.icons.copy(()=>{r&&this.createNewTemplate(r)},"Clone template"),m=t.icons.delete(()=>{!d.value||d.items.length<2||t.dialog("Delete template").add(t.divText(`Are you sure you want to delete template ${d.value}?`)).onOK(()=>Ke(this,void 0,void 0,function*(){try{const t=d.value;yield mi.files.delete(`${this.getTemplatesFolder()}/${t}.json`),l=!1,d.items=d.items.filter(e=>e!==t),d.value=d.items[0],l=!0,yield c(),e.shell.info("Template "+t+" was deleted successfully")}catch(t){l=!0,e.shell.error("Failed to delete template "+d.value),console.error(t)}})).show()},"Delete template");m.style.color="var(--blue-1)",u.style.color="#2083d5",d.addOptions(u),d.addOptions(p),d.addOptions(m),yield c(),_e()(n).empty(),n.appendChild(d.root)})}checkCampaign(e){return Ke(this,void 0,void 0,function*(){const t=location.search,i=new URLSearchParams(t);if(!i.has(u)&&!e)return;const n=null!=e?e:i.get(u);if(!(yield mi.files.exists(`${this.app.appName}/campaigns/${n}/${h}`)))return;const o=JSON.parse(yield mi.files.readAsText(`${this.app.appName}/campaigns/${n}/${h}`));if(o){if(o.authorUserId&&o.permissions&&!(yield me(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const a=yield Ne(`${this.getTemplatesFolder()}/${o.templateName}.json`);return this.app.setTemplate(a,o.filters,n,o.ingest),e&&re(u,e),o})}getCampaignsTable(){return Ke(this,void 0,void 0,function*(){const i=yield mi.loadCampaigns(this.app.appName,this.deletedCampaigns),n=null!==(a=he(D))&&void 0!==a?a:L.None;var a;const s=function(){const e=he(M);return e?JSON.parse(e):null}(),r=Object.values(i);s&&ge(r,s,R);const l=Te(r,n),c=be();this.currentGroupping=n;const d=i=>{var n,a;const s=t.icons.delete(()=>Ke(this,void 0,void 0,function*(){var e;t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${null!==(e=i.friendlyName)&&void 0!==e?e:i.name}?`)).onOK(()=>Ke(this,void 0,void 0,function*(){yield this.deleteCampaign(this.app.appName,i.name),this.deletedCampaigns.push(i.name),yield this.init()})).show()}),"Delete campaign"),r=t.iconFA("share",()=>Ke(this,void 0,void 0,function*(){yield new Qe(i.permissions).show(t=>Ke(this,void 0,void 0,function*(){var n,o,a;try{i.permissions=t,null!==(n=i.authorUserId)&&void 0!==n||(i.authorUserId=e.shell.user.id),yield mi.saveCampaignJson(this.app.appName,i),e.shell.info("Permissions updated for campaign "+(null!==(o=i.friendlyName)&&void 0!==o?o:i.name))}catch(t){e.shell.error("Failed to update permissions for campaign "+(null!==(a=i.friendlyName)&&void 0!==a?a:i.name)),console.error(t)}}))}),"Manage campaign permissions");return s.style.display="none",r.style.display="none",pe(null!==(n=i.authorUserId)&&void 0!==n?n:o.User.current().id,null!==(a=i.permissions)&&void 0!==a?a:Je).then(e=>{e&&(s.style.display="inline-block",r.style.display="inline-block")}),s.style.color="var(--blue-1)",r.style.color="var(--blue-1)",[r,s]},u=Object.values(l).flat(),p=t.table(u,e=>{var i;return[t.link(null!==(i=e.friendlyName)&&void 0!==i?i:e.name,()=>this.setCampaign(e.name),"Continue Campaign",""),...c.map(t=>{var i,n,o,a;return t.startsWith("campaignFields.")?null!==(n=null===(i=e.campaignFields)||void 0===i?void 0:i[t.replace("campaignFields.","")])&&void 0!==n?n:"":null!==(a=null===(o=R[t])||void 0===o?void 0:o.call(R,e))&&void 0!==a?a:""}),...d(e)]},["Name",...c.map(e=>e.replace("campaignFields.","")),"",""]);return p.style.color="var(--grey-5)",p.style.marginLeft="24px",p.querySelectorAll("tr.header > td").forEach((e,i)=>{if(!e.textContent)return;const n=0===i?"Name":c[i-1];if(s&&n===s.columnName){const i=s.ascending?"↑":"↓";e.appendChild(t.span([i],{style:{fontSize:"12px",marginLeft:"2px"}}))}e.addEventListener("dblclick",()=>{let e={columnName:n,ascending:!0};var t;s&&n===s.columnName&&(e=s.ascending?{columnName:n,ascending:!1}:null),(t=e)?ve(M,JSON.stringify(t)):localStorage.removeItem(M),this.refreshCampaignsTable()})}),xe(p,l),p})}setCampaign(e){return Ke(this,void 0,void 0,function*(){const t=yield this.checkCampaign(e);this.app.campaign=t})}getNewCampaignAccordeon(e,i){return Ke(this,void 0,void 0,function*(){t.setUpdateIndicator(i,!0);const{root:n,promise:o,cancelPromise:a}=yield Fe(e,this.getDataSourceFunctionsMap(),this.getDataSourceTag());return t.setUpdateIndicator(i,!1),o.then(t=>Ke(this,void 0,void 0,function*(){this.app.dataFrame=t.df,this.app._fileInputType=t.type,yield this.app.setTemplate(e,void 0,void 0,void 0,t.friendlyName),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(void 0,!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})),a.then(()=>{this.init()}),n})}createNewTemplate(t){return Ke(this,void 0,void 0,function*(){const i=yield je(this.app,this.getDataSourceFunctionsMap(),t),n=new o.ViewBase,a=e.shell.v;n.name="New Template",n.root.appendChild(i.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template",n.parentView=a;const{sub:s}=le(e.shell.v,this.app.appName,T,()=>{e.shell.v=a,n.close()});i.template.then(t=>Ke(this,void 0,void 0,function*(){yield this.init(t),n.close(),ce(n),e.shell.v=a,s.unsubscribe()})),i.cancelPromise.then(()=>{s.unsubscribe(),n.close(),e.shell.v=a})})}}class Xe extends qe{constructor(e){super(e),this.name="Submit"}render(){return t.empty(this.root),t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return t=this,i=void 0,a=function*(){const t=this.app.submitParams;if(!t)return;const i=o.Func.find({name:t.fName,package:t.package})[0];if(!i)return void e.shell.error(`Function ${t.fName} not found.`);const n=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield i.apply({df:n,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((n=void 0)||(n=Promise))(function(e,o){function s(e){try{l(a.next(e))}catch(e){o(e)}}function r(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n(function(e){e(i)})).then(s,r)}l((a=a.apply(t,i||[])).next())});var t,i,n,a}}var et,tt,it=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};!function(t){t.acquireCampaignLock=function(t,i,n){return it(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AcquireCampaignLock",{appName:t,campaignId:i,lockedBy:n})})},t.releaseCampaignLock=function(t,i){return it(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:ReleaseCampaignLock",{appName:t,campaignId:i})})},t.getLastModified=function(t,i){return it(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetLastModified",{appName:t,campaignId:i})})},t.addMolecule=function(t,i,n,o){return it(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AddMolecule",{canonicalSmiles:t,appName:i,campaignId:n,createdBy:o})})},t.addMolecules=function(t,i,n,o){return it(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:AddMolecules",{smiles:t,appName:i,campaignId:n,createdBy:o})})},t.getMoleculeByVid=function(t){return it(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetMoleculeByVid",{vid:t})})},t.getCampaignsByVid=function(t,i){return it(this,void 0,void 0,function*(){return yield e.data.query("HitTriage:GetCampaignsByVid",{vid:t,appName:i})})}}(et||(et={})),function(t){t.hitTriageAppTreeBrowser=function(t){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitTriageAppTreeBrowser",{treeNode:t})})},t.hitDesignAppTreeBrowser=function(t){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignAppTreeBrowser",{treeNode:t})})},t.peptiHitAppTreeBrowser=function(t){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PeptiHitAppTreeBrowser",{treeNode:t})})},t.hitTriageApp=function(){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitTriageApp",{})})},t.hitDesignApp=function(){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignApp",{})})},t.peptiHitApp=function(){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PeptiHitApp",{})})},t.pepTriageAppTreeBrowser=function(t){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PepTriageAppTreeBrowser",{treeNode:t})})},t.pepTriageApp=function(){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:PepTriageApp",{})})},t.demoFileIngest=function(){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest",{})})},t.demoFileIngest1=function(){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest1",{})})},t.demoFileIngest2=function(t){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileIngest2",{numberOfMolecules:t})})},t.demoPeptideSequences=function(t){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoPeptideSequences",{peptideCount:t})})},t.demoFileSubmit=function(t,i){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:DemoFileSubmit",{df:t,molecules:i})})},t.registerMoleculesToViD=function(){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:RegisterMoleculesToViD",{})})},t.hitDesignVidPanel=function(t){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HitDesignVidPanel",{vid:t})})},t.gasteigerCellRenderer=function(){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:GasteigerCellRenderer",{})})},t.htPackageSettingEditor=function(t){return it(this,void 0,void 0,function*(){return yield e.functions.call("HitTriage:HtPackageSettingEditor",{propList:t})})}}(tt||(tt={}));var nt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class ot{get appName(){return this._appName}constructor(e,t){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this.baseUrl=new URL(window.location.href).origin+`/apps/HitTriage/${t.replace(" ","")}`,this._appName=t,this.computeFunctions=function(e){const t=Array.from(new Set(o.Func.find({meta:{role:e}}).concat(o.Func.find({tags:[e]}))));return{functions:t.filter(e=>e.type===s),scripts:t.filter(e=>e.type===a),queries:t.filter(e=>e.type===r)}}("HitTriageFunction")}setCanEdit(e){return nt(this,void 0,void 0,function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield pe(e.authorUserId,e.permissions):this.hasEditPermission=!0})}getFilterType(e){const t=this.dataFrame.col(e);return(null==t?void 0:t.semType)===o.SEMTYPE.MOLECULE?o.FILTER_TYPE.SUBSTRUCTURE:(null==t?void 0:t.type)===o.COLUMN_TYPE.BOOL?o.FILTER_TYPE.BOOL_COLUMNS:(null==t?void 0:t.type)===o.COLUMN_TYPE.STRING?o.FILTER_TYPE.CATEGORICAL:o.FILTER_TYPE.HISTOGRAM}download(e,t,i=!1){const n=document.createElement("a"),a=o.DataFrame.fromColumns(e.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv({filteredRowsOnly:i});n.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),n.setAttribute("download",t+".csv"),n.click()}getNewCampaignName(e,t){return nt(this,void 0,void 0,function*(){const i=(yield mi.files.list(e)).map(e=>e.name).filter(e=>e.startsWith(`${t}-`)&&!!parseInt(e.substring(t.length+1)));if(0===i.length)return t+"-1";const n=i.map(e=>e.substring(t.length+1)).filter(Boolean).map(e=>parseInt(e,10)).sort((e,t)=>e-t);return t+"-"+(n[n.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)}}unionDataframes(e,t,i,n){var a,s,r,l;const c=i;e.col(i).name=n,i=n;const d=null===(s=null===(a=e.col(i))||void 0===a?void 0:a.toList())||void 0===s?void 0:s.map(e=>mi.convertToSmiles(e)),u=null===(l=null===(r=t.col(n))||void 0===r?void 0:r.toList())||void 0===l?void 0:l.map(e=>mi.convertToSmiles(e));if(!d||!u)throw new Error("Molecule column not found");const p=new Map;u.forEach((e,t)=>{e&&"MALFORMED_INPUT_VALUE"!==e&&p.set(e,t)});const m=(e,t,i,n)=>{try{if(e.type===t.type)e.set(i,t.get(n),!1);else if(e.type===o.COLUMN_TYPE.STRING)e.set(i,t.getString(n),!1);else if(e.type===o.COLUMN_TYPE.INT){const o=t.get(n);"number"==typeof o?e.set(i,Math.round(o),!1):"string"==typeof o&&o.length>0&&!isNaN(Number(o))&&e.set(i,Math.round(Number(o)),!1)}else if(e.type===o.COLUMN_TYPE.FLOAT){const o=t.get(n);"number"==typeof o?e.set(i,o,!1):"string"==typeof o&&o.length>0&&!isNaN(Number(o))&&e.set(i,Number(o),!1)}else e.set(i,t.get(n),!1)}catch(o){mi.logger.error(`Error setting column value for column ${e.name} at row ${i} from column ${t.name} at row ${n}: ${o}`)}};this.isJoining=!0;try{const i=[];for(const n of e.columns)if(!t.columns.contains(n.name)){const e=t.columns.addNew(n.name,n.type);n.semType&&(e.semType=n.semType),i.push(n.name)}for(let n=0;n<d.length;n++)if(d[n]&&"MALFORMED_INPUT_VALUE"!==d[n])if(p.has(d[n])){if(i.length>0){const o=p.get(d[n]);for(const a of i)m(t.col(a),e.col(a),o,n)}}else{t.rows.addNew(null,!0);for(const i of e.columns)m(t.col(i.name),i,t.rowCount-1,n)}}finally{setTimeout(()=>{this.isJoining=!1},500),e.col(i).name=c}return t}aquireAndWaitCampaignLock(e){return nt(this,arguments,void 0,function*(e,t=3e4){var i;const n=Date.now();let a=0,s=null;const r=o.User.current(),l=r&&(r.friendlyName||r.name)||"unknown";for(;Date.now()-n<t&&a<5;)try{const t=yield et.acquireCampaignLock(this.appName,e,l);if(t&&t.rowCount>0)return{aquired:!0,expires_at:null===(i=null==t?void 0:t.col("expires_at"))||void 0===i?void 0:i.getString(0)};s=null,yield o.delay(200)}catch(e){s=e,a++}if(s)throw s;return{aquired:!1,expires_at:null}})}releaseCampaignLock(e){return nt(this,void 0,void 0,function*(){var t,i;return(null===(i=null===(t=yield et.releaseCampaignLock(this.appName,e))||void 0===t?void 0:t.col("updated_at"))||void 0===i?void 0:i.getString(0))||null})}}ot.molFileExtReaders=["sdf","mol","smi","mol2"].map(e=>{const t=o.Func.find({meta:{role:o.FUNC_TYPES.FILE_IMPORTER}}).concat(o.Func.find({tags:["file-handler"]})).find(t=>{var i;return(null===(i=null==t?void 0:t.options)||void 0===i?void 0:i.ext)&&"string"==typeof t.options.ext&&t.options.ext.split(",").includes(e)});return{ext:e,handlerFunc:t}}).filter(e=>e.handlerFunc);var at=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})},st=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};function rt(){return{convertToSmiles:e=>mi.convertToSmiles(e),logger:mi.logger,molColName:A}}function lt(t,i,n){return st(this,arguments,void 0,function*(t,i,n,s=[],l=[]){return async function(t,i,n,s=[],l=[],c){var d,u,p;const m=o.TaskBarProgressIndicator.create("Calculating ..."),h=null!==(d=null==c?void 0:c.convertToSmiles)&&void 0!==d?d:e=>e,v=null!==(u=null==c?void 0:c.logger)&&void 0!==u?u:console,f=null!==(p=null==c?void 0:c.molColName)&&void 0!==p?p:"Molecule",g=t.map(e=>h(e)),y=o.Column.fromStrings(f,g),A=o.DataFrame.fromColumns([y]);A.name="HD cell values",await A.meta.detectSemanticTypes();const w=[];w.push(new Promise(async t=>{try{i.length&&await e.chem.descriptors(A,y.name,i)}catch(e){v.error("Descriptors calculation error"),v.error(e)}t()}));for(const e of n)w.push(new Promise(async t=>{try{const i=e.args,n=o.Func.find({package:e.package,name:e.name});if(!n.length||!n[0])return console.warn(`Function ${e.name} from package ${e.package} is not found`),void t();const a=n[0],s=a.inputs[0].name,r=a.inputs[1].name;await a.apply({...i,[s]:A,[r]:y.name})}catch(e){v.error(e)}t()}));for(const e of s){const t=e.args;w.push(new Promise(async i=>{try{const i=o.Func.find({name:e.name}).filter(t=>t.type===a&&t.id===e.id)[0];if(i){const e=i.inputs[0].name,n=i.inputs[1].name,o=await i.apply({...t,[e]:A,[n]:y.name});if(o&&o.rowCount===A.rowCount&&"python"===i.language)for(const e of o.columns)e.name=A.columns.getUnusedName(e.name),A.columns.add(e)}}catch(e){v.error(e)}i()}))}for(const e of l){const t=e.args;w.push(new Promise(async i=>{try{const n=o.Func.find({name:e.name}).filter(t=>t.type===r&&t.id===e.id)[0];if(n){const e=n.inputs[0].name,o=[g],a=await n.apply({...t,[e]:o});if(!a||0===a.rowCount)return void i();await oe(A,f,a)}}catch(e){v.error(e)}i()}))}await Promise.all(w),m.close();const b=A.col(f);for(let e=0;e<b.length;e++)b.set(e,t[e],!1);return A}(t,i,n,s,l,rt())})}function ct(t,i,n){return st(this,void 0,void 0,function*(){return async function(t,i,n,s){var l,c,d,u;const p=o.TaskBarProgressIndicator.create("Calculating ..."),m=null!==(l=null==s?void 0:s.convertToSmiles)&&void 0!==l?l:e=>e,h=null!==(c=null==s?void 0:s.logger)&&void 0!==c?c:console,v=i.col(n);if(!v)throw new Error("There is no molecule column in dataframe");const f=`~${n}.canonicalSmiles`,g=i.columns.getOrCreate(f,o.TYPE.STRING);g.semType=o.SEMTYPE.MOLECULE;const y=v.toList();for(let e=0;e<y.length;e++){if(v.isNone(e))continue;const t=y[e];if(!t)continue;const i=m(t);g.set(e,i,!1)}const A=[];A.push(new Promise(async n=>{try{t.descriptors&&t.descriptors.length>0&&await e.chem.descriptors(i,f,t.descriptors)}catch(e){h.error("Descriptors calculation error"),h.error(e)}n()}));for(const e of Object.keys(t.externals))A.push(new Promise(async n=>{try{const n=t.externals[e],a=o.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],s=a.inputs[0].name,r=a.inputs[1].name;n&&await a.apply({...n,[s]:i,[r]:f})}catch(e){h.error(e)}n()}));for(const e of Object.keys(null!==(d=t.scripts)&&void 0!==d?d:{})){const n=t.scripts[e];A.push(new Promise(async t=>{if(n){const s=e.split(":"),r=s[2];if(!r)return void t();try{const e=s[1],l=o.Func.find({name:e}).filter(e=>e.type===a&&e.id===r)[0];if(!l)return void t();const c=l.inputs[0].name,d=l.inputs[1].name,u=await l.apply({...n,[c]:i,[d]:f});if(u&&u.rowCount===i.rowCount&&"python"===l.language)for(const e of u.columns)e.name=i.columns.getUnusedName(e.name),i.columns.add(e)}catch(e){h.error(e)}}t()}))}for(const e of Object.keys(null!==(u=t.queries)&&void 0!==u?u:{})){const n=t.queries[e];A.push(new Promise(async t=>{if(n){const a=e.split(":"),s=a[2];if(!s)return void t();try{const e=a[1],l=o.Func.find({name:e}).filter(e=>e.type===r&&e.id===s)[0];if(!l)return void t();const c=l.inputs[0].name,d=await l.apply({...n,[c]:g.toList()});d&&await oe(i,f,d)}catch(e){console.error(e)}}t()}))}await Promise.all(A),p.close()}(t,i,n,rt())})}var dt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class ut extends ot{get infoView(){return this._infoView}constructor(t,i="Hit Triage",n=e=>new Ze(e)){super(t,i),this._filterViewName="Hit Triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=n(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe(e=>{this.multiView.currentView instanceof qe&&this.multiView.currentView.onActivated()}),this.multiView.parentCall=t,e.events.onCurrentViewChanged.subscribe(()=>{var t,i,n,o;try{(null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentPickViewId&&(e.shell.windows.showHelp=!1,this.setBaseUrl(),re(u,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(e){console.error(e)}})}get submitParams(){var e,t,i,n;return null!==(i=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.submit)&&void 0!==i?i:null===(n=this.template)||void 0===n?void 0:n.submit}prepareDataFrame(e){return dt(this,void 0,void 0,function*(){})}setTemplate(t,i,n,a,s){return dt(this,void 0,void 0,function*(){var r,d,p,m,h,v,f,g,y,A,w,b,C,E,T,x,S,N,B,I;if(this._friendlyName=null!=s?s:null===(r=this._campaign)||void 0===r?void 0:r.friendlyName,(null===(d=this._pickView)||void 0===d?void 0:d.dataFrame)&&e.shell.closeTable(null===(p=this._pickView)||void 0===p?void 0:p.dataFrame),this._pickView=void 0,n?a&&(this._fileInputType=a.type,"File"===a.type?this.dataFrame=yield e.dapi.files.readCsv(a.query):this.dataFrame=yield e.functions.call(a.query)):(n=yield this.getNewCampaignName(`${this.appName}/campaigns`,t.key),re(u,n)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(m=this._campaign)||void 0===m?void 0:m.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach(([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&i.semType!==t&&(i.semType=t)}),(null===(h=this._campaign)||void 0===h?void 0:h.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach(([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{i.convertTo(t)}catch(e){console.error(e)}}),yield this.dataFrame.meta.detectSemanticTypes(),yield this.prepareDataFrame(t),this._molColName=null!==(f=null===(v=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===v?void 0:v.name)&&void 0!==f?f:void 0,this._dfName=null!==(g=this.dataFrame.name)&&void 0!==g?g:null==a?void 0:a.query,this.dataFrame.name=null!==(A=null!==(y=this._dfName)&&void 0!==y?y:this.dataFrame.name)&&void 0!==A?A:"Molecules",this._campaignId=n,this.template=(null===(w=this.campaign)||void 0===w?void 0:w.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:t.dataSourceType,queryFunctionName:t.queryFunctionName}):t,this._campaignFilters=i,!i){const e={},i={},n={};t.compute.functions.forEach(t=>{const i=`${t.package}:${t.name}`;e[i]=t.args}),null===(b=t.compute.scripts)||void 0===b||b.forEach(e=>{const t=`${l}:${e.name}:${e.id}`;i[t]=e.args}),null===(C=t.compute.queries)||void 0===C||C.forEach(e=>{const t=`${c}:${e.name}:${e.id}`;n[t]=e.args}),yield ct({descriptors:t.compute.descriptors.enabled?t.compute.descriptors.args:[],externals:e,scripts:i,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0,this._filterViewName=`${this.appName} | ${null!==(T=null!==(E=this._friendlyName)&&void 0!==E?E:this._campaignId)&&void 0!==T?T:"Pick"}`;const F=e.shell.v,P=e.shell.addView(this.pickView);this.currentPickViewId=P.name,this._submitView=new Xe(this),this.setBaseUrl(),re(u,null!==(N=null!==(x=this._campaignId)&&void 0!==x?x:null===(S=this._campaign)||void 0===S?void 0:S.name)&&void 0!==N?N:"");const _=P,k=null!==(I=null!==(B=this._friendlyName)&&void 0!==B?B:this._campaignId)&&void 0!==I?I:"Pick";setTimeout(()=>{this._pickViewPromise&&this._pickViewPromise.then(()=>{const{sub:t}=le(_,this.appName,k,()=>{e.shell.v=F,_.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,t,i;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(i=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.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(g)||this.dataFrame.columns.addNewBool(g).init(!1);const i=o.TableView.create(this.dataFrame,!1);let n=i.getRibbonPanels();const a=t.iconFA("wrench",()=>dt(this,void 0,void 0,function*(){Oe(this,e=>dt(this,void 0,void 0,function*(){var t,i,n,o,a,s,r;const d=this.template.compute.descriptors.args,u=this.template.compute.functions,p=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],m=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],h=e.descriptors,v={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.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 i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(s=null==e?void 0:e.scripts)&&void 0!==s?s:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(r=null==e?void 0:e.queries)&&void 0!==r?r:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})};this.template.compute=v;const f=h.filter(e=>!d.includes(e)),g=v.functions.filter(e=>{if(!u.some(t=>t.name===e.name&&t.package===e.package))return!0;const t=u.find(t=>t.name===e.name&&t.package===e.package);return!Object.entries(e.args).every(([e,i])=>t.args[e]===i)}),y=v.scripts.filter(e=>{if(!p.some(t=>t.id===e.id))return!0;const t=p.find(t=>t.id===e.id);return!Object.entries(e.args).every(([e,i])=>t.args[e]===i)}),A=v.queries.filter(e=>{if(!m.some(t=>t.id===e.id))return!0;const t=m.find(t=>t.id===e.id);return!Object.entries(e.args).every(([e,i])=>t.args[e]===i)}),w={};g.forEach(e=>{const t=`${e.package}:${e.name}`;w[t]=e.args});const b={};y.forEach(e=>{const t=`${l}:${e.name}:${e.id}`;b[t]=e.args});const C={};A.forEach(e=>{const t=`${c}:${e.name}:${e.id}`;C[t]=e.args}),yield ct({descriptors:f,externals:w,scripts:b,queries:C},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}),()=>null,this.template,!0)}),"Calculate additional properties"),s=t.bigButton("Submit",()=>{var e;const i=null===(e=this._submitView)||void 0===e?void 0:e.render();if(i){const e=t.dialog("Submit");e.add(i),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()}}),r=t.iconFA("share",()=>dt(this,void 0,void 0,function*(){var e;yield new Qe(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show(e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)})}),"Edit permissions");s.classList.add("hit-design-submit-button");const d=de(n);return n.push([a,...this.hasEditPermission?[r]:[],...d?[]:[s]]),n.some(e=>{var t;const i=null!==(t=null==e?void 0:e.findIndex(e=>{var t;return"save"===(null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.toLowerCase())}))&&void 0!==t?t:-1;return-1!==i&&(e.splice(i,1),!0)}),n=n.filter(e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0}),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout(()=>dt(this,void 0,void 0,function*(){var t,n,a;i._onAdded(),yield new Promise(e=>setTimeout(e,1e3));const s=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),r=null!==(n=null===(t=this._campaign)||void 0===t?void 0:t.layout)&&void 0!==n?n:null===(a=this.template)||void 0===a?void 0:a.layoutViewState;if(r)try{const e=o.ViewLayout.fromViewState(r);i.loadLayout(e)}catch(e){console.error(e)}i.dataFrame.onFilterChanged.subscribe(e=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=s.getOptions().look.filters}),setTimeout(()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=s.getOptions().look.filters},300),e&&e()}),300),i.parentCall=this.parentCall,i}getSummary(){var e,i,n,o,a,s,r;const l=null!==(i=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==i?i:this.campaignProps;return Object.assign(Object.assign({Template:null!==(o=null===(n=this.template)||void 0===n?void 0:n.name)&&void 0!==o?o:"Molecules","File path":t.divH([t.link(null!==(a=this._dfName)&&void 0!==a?a:"-",()=>this.download(this.dataFrame,"molecules"),N)],{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":t.divH([t.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)},N)],{style:{alignItems:"center"}})})}saveCampaign(i){return dt(this,arguments,void 0,function*(i,n=!0){var a,s,r,l,c,d,u,p,h,v,f,g,y,A,w;const b=this.campaignId,C=this.filterSettings,E=this.template.name,T=this.dataFrame,x=`System:AppData/HitTriage/${this.appName}/campaigns/${b}/`,S=null!=b?b:yield function(e){return at(this,void 0,void 0,function*(){return new Promise(i=>at(this,void 0,void 0,function*(){const n=t.input.string("Campaign name",{value:""});t.dialog("Save Campaign").add(t.div(n.root)).onOK(function(){n.value&&""!==n.value?i(n.value):i(e)}).show()}))})}(b),N={};T.columns.toList().forEach(e=>N[e.name]=e.semType);const B={};T.columns.toList().forEach(e=>B[e.name]=e.type);const I=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==s?s:e.shell.user.id,F=null!==(l=null===(r=this.campaign)||void 0===r?void 0:r.permissions)&&void 0!==l?l:Je,P=I?null!==(d=null===(c=this.campaign)||void 0===c?void 0:c.authorUserFriendlyName)&&void 0!==d?d:null===(u=yield e.dapi.users.find(I))||void 0===u?void 0:u.friendlyName:void 0,_={name:S,friendlyName:null!==(p=this._friendlyName)&&void 0!==p?p:null===(h=this.campaign)||void 0===h?void 0:h.friendlyName,templateName:E,filters:null!=C?C:{},ingest:{type:"File",query:`${x}${m}`,molColName:this.molColName},status:null!==(f=null!=i?i:null===(v=this.campaign)||void 0===v?void 0:v.status)&&void 0!==f?f:"In Progress",createDate:null!==(y=null===(g=this.campaign)||void 0===g?void 0:g.createDate)&&void 0!==y?y:se(new Date),campaignFields:null!==(w=null===(A=this.campaign)||void 0===A?void 0:A.campaignFields)&&void 0!==w?w:this.campaignProps,columnSemTypes:N,rowCount:T.rowCount,filteredRowCount:T.filter.trueCount,template:this.template,columnTypes:B,authorUserId:I,authorUserFriendlyName:P,lastModifiedUserName:e.shell.user.friendlyName,permissions:F};if(this.campaign=_,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),_;const k=o.DataFrame.fromColumns(T.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv();yield mi.files.writeAsText(`${this.appName}/campaigns/${b}/${m}`,k);const V=this._pickView.saveLayout();return V?_.layout=V.viewState:e.shell.warning("Layout cound not be saved"),yield mi.saveCampaignJson(this.appName,_),n&&e.shell.info("Campaign saved successfully."),_})}}function pt(i,n=!1){var a,s;const r=o.DataFrame.create(1);if(n){const e=r.columns.addNew(w,o.TYPE.STRING);e.semType=o.SEMTYPE.MACROMOLECULE,e.meta.units="helm",e.setTag("units","helm"),e.setTag("cell.renderer","helm"),e.setTag(".alphabetIsMultichar","true")}const l=r.columns.addNew(A,o.TYPE.STRING);l.semType=o.SEMTYPE.MOLECULE,l.meta.units=o.UNITS.Molecule.SMILES,l.set(0,null),(null===(a=null==i?void 0:i.stages)||void 0===a?void 0:a.length)>0&&r.columns.addNew(y,o.TYPE.STRING).set(0,i.stages[0]),r.columns.addNew(b,o.TYPE.STRING);const c=i.campaignFields.map(e=>e.type===o.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:o.SEMTYPE.MOLECULE}):e).map(e=>o.Property.fromOptions(Object.assign({name:e.name,type:Be[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{}))),d={},u=t.input.string("Campaing Name",{tooltipText:"New campaign name. If empty, campaign code will be used."}),p=t.input.form(d,c);p.prepend(u.root),p.classList.remove("ui-form");const m=t.div([...(null===(s=i.campaignFields)||void 0===s||s.length,[]),p]),h=t.buttonsInput([]);return m.appendChild(h),{promise:new Promise(n=>{const o=t.bigButton(x,()=>{for(const t of i.campaignFields)if(t.required&&(!d[t.name]||""===d[t.name]))return void e.shell.error(`Field '${t.name}' is required`);n({df:r,campaignProps:d,name:u.value})});h.appendChild(o)}),root:m,cancelPromise:new Promise(e=>{t.button(B,()=>e())})}}var mt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};function ht(i,n){return mt(this,void 0,void 0,function*(){var a,s,r,d,u,p,m,h,v,g,y;const A=yield mi.files.list(`${i.appName}/templates`);let w=!1,b=!1;const C=A.map(e=>e.name.slice(0,-5)),E=[];for(const e of A)try{const t=JSON.parse(yield mi.files.readAsText(e));E.push(t.key)}catch(e){console.error(e)}const T=Array.from(new Set(o.Func.find({meta:{role:f}}).concat(o.Func.find({tags:[f]})))),x={};T.forEach(e=>{var t;x[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const N=t.input.choice("Submit function",{value:null,items:[null,...Object.keys(x)]});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 I=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),F=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),P=Me();function _(){var e,t,i,n;if(""===k.value||C.includes(null!==(t=null===(e=k.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=k.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=k.input.offsetWidth)&&void 0!==n?n:0;I.style.marginLeft=`${e}px`,I.style.width=`${t}px`,I.style.opacity="100%",I.style.borderTop="1px solid red",w=!0}else I.style.borderTop="none",I.style.opacity="0%",w=!1}const k=t.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:_});function V(){var e,t,i,n;if(""===L.value||E.includes(null!==(t=null===(e=L.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=L.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=L.input.offsetWidth)&&void 0!==n?n:0;F.style.marginLeft=`${e}px`,F.style.width=`${t}px`,F.style.borderTop="1px solid red",F.style.opacity="100%",b=!0}else F.style.opacity="0%",F.style.borderTop="none",b=!1}const L=t.input.string("Key",{value:null!==(d=null==n?void 0:n.key)&&void 0!==d?d:"",onValueChanged:V});L.setTooltip("Template key used for campaign prefix"),k.setTooltip("Template name"),k.root.style.borderBottom="none",L.root.style.borderBottom="none",I.style.opacity="0%",F.style.opacity="0%";let O=null;const D={compute:{descriptors:{enabled:!0,args:null!==(m=null===(p=null===(u=null==n?void 0:n.compute)||void 0===u?void 0:u.descriptors)||void 0===p?void 0:p.args)&&void 0!==m?m:[]},functions:null!==(v=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==v?v:[]}},$=yield Oe(i,e=>{O=e},()=>null,D,!1);$.root.classList.add("hit-triage-new-template-functions-input");const M=Ue(null==n?void 0:n.campaignFields),R=vt(null==n?void 0:n.stages),j=t.divV([t.divV([k,I]),t.divV([L,F]),P.dataFileInput,M.fieldsDiv]),U=t.h2("Stages");t.tooltip.bind(U,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=t.h2("Compute");t.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=t.div([t.h2("Details"),j,U,R.fieldsDiv,H,$.root,t.h2("Submit"),N.root],"ui-form"),Y=t.buttonsInput([]);q.appendChild(Y);const G=null!==(y=null===(g=Y.getElementsByClassName("ui-input-editor"))||void 0===g?void 0:g[0])&&void 0!==y?y:Y,W=new Promise(e=>{const i=t.button(B,()=>e());G.appendChild(i)}),z=new Promise(n=>{const o=t.bigButton(S,()=>function(){return mt(this,void 0,void 0,function*(){var t,o,a,s,r,d,u;if(_(),V(),$.okProxy(),w||!k.value||""===k.value)return void e.shell.error("Template name is empty or already exists");if(b||!L.value||""===L.value)return void e.shell.error("Template key is empty or already exists");const p=N.value?x[N.value]:void 0,m=Object.assign({name:k.value,key:L.value,campaignFields:M.getFields(),stages:R.getFields(),layoutViewState:null!==(t=P.getLayoutViewState())&&void 0!==t?t:void 0,localLayoutPath:null!==(o=P.getLocalFilePath())&&void 0!==o?o:void 0,compute:{descriptors:{enabled:!!(null===(a=null==O?void 0:O.descriptors)||void 0===a?void 0:a.length),args:null!==(s=null==O?void 0:O.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(r=null==O?void 0:O.externals)&&void 0!==r?r:{}).map(([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(d=null==O?void 0:O.scripts)&&void 0!==d?d:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(u=null==O?void 0:O.queries)&&void 0!==u?u:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})}},p?{submit:{fName:p.name,package:ne(p)}}:{});yield function(e,t){return mt(this,void 0,void 0,function*(){yield mi.files.writeAsText(`${t}/templates/${e.name}.json`,JSON.stringify(e))})}(m,i.appName),e.shell.info("Template created successfully"),n(m)})}());G.appendChild(o)});return{root:q,template:z,cancelPromise:W}})}function vt(e){const t=[o.Property.fromOptions({name:"Name",type:o.TYPE.STRING})],i=new $e(t,e?e.map(e=>({Name:e})):void 0,{horizontalInputNames:!0});let n={};return i.onItemAdded.subscribe(e=>{n={}}),i.onAddingItemChanged.subscribe(e=>{e&&(n=e.item)}),{getFields:function(){const e=i.items.filter(e=>e.Name).map(e=>e.Name);return n.Name&&""!==n.Name&&e.push(n.Name),e},fieldsDiv:i.root,itemsGrid:i}}var ft=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class gt extends qe{constructor(t){super(t),this.currentGroupping="None",this.campaignsTableRoot=null,this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(mi.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(mi.webRoot+"README_HD.md")}getAppHeader(){return We.appHeader({iconPath:mi.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"})}refreshCampaignsTable(){return ft(this,void 0,void 0,function*(){if(null!=this.campaignsTableRoot){t.setUpdateIndicator(this.campaignsTableRoot,!0);try{const e=yield this.getCampaignsTable();t.setUpdateIndicator(this.campaignsTableRoot,!1),t.empty(this.campaignsTableRoot),this.campaignsTableRoot.appendChild(e)}catch(t){e.shell.error("Failed to update campaigns table"),console.error(t)}finally{t.setUpdateIndicator(this.campaignsTableRoot,!1)}}})}init(e){return ft(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const i=t.h1(I),n=t.h1(F,{style:{marginLeft:"10px"}}),a=this.getAppHeader(),s=t.div(),r=t.divH([]),l=t.div([r,s],"ui-form"),c=yield this.getCampaignsTable();this.campaignsTableRoot=t.div([c],{style:{position:"relative"}});const d=t.iconFA("layer-group",()=>ft(this,void 0,void 0,function*(){const e=o.Menu.popup();Object.values(L).forEach(t=>{e.item(t,()=>ft(this,void 0,void 0,function*(){fe(t),yield this.refreshCampaignsTable()}))});const t=e.group("Campaign Fields"),i=yield mi.loadCampaigns(this.app.appName,this.deletedCampaigns),n=new Set;Object.values(i).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>n.add(e))}),Array.from(n).forEach(e=>{t.item(e,()=>ft(this,void 0,void 0,function*(){fe(`campaignFields.${e}`),yield this.refreshCampaignsTable()}))}),e.show({element:m,x:120,y:m.offsetTop+30})}));d.style.marginBottom="9px",d.style.marginLeft="8px",d.style.fontSize="15px",d.style.color="var(--blue-1)",t.tooltip.bind(d,()=>`Group Campaigns. Current: ${this.currentGroupping}`);const u=t.iconFA("eye",()=>ft(this,void 0,void 0,function*(){const e=o.Menu.popup(),t=yield mi.loadCampaigns(this.app.appName,this.deletedCampaigns),i=Object.assign({},O);delete i.Name,Object.values(t).forEach(e=>{e.campaignFields&&Object.keys(e.campaignFields).forEach(e=>{i[`campaignFields.${e}`]=t=>{var i,n;return null!==(n=null===(i=t.campaignFields)||void 0===i?void 0:i[e])&&void 0!==n?n:""}})});const n=ye().reduce((e,t)=>(e[t]=!0,e),{});Object.keys(i).filter(e=>!e.startsWith("campaignFields.")).forEach(t=>{var i;e.item(t,()=>{n[t]=!n[t],Ae(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!==(i=n[t])&&void 0!==i&&i})});const a=e.group("Campaign Fields");Object.keys(i).filter(e=>e.startsWith("campaignFields.")).forEach(e=>{var t;a.item(e.replace("campaignFields.",""),()=>{n[e]=!n[e],Ae(Object.keys(n).filter(e=>n[e])),this.refreshCampaignsTable()},null,{check:null!==(t=n[e])&&void 0!==t&&t})}),e.show({element:m,x:100,y:m.offsetTop+30})}));t.tooltip.bind(u,"Edit visible columns in campaigns table"),u.style.marginBottom="9px",u.style.marginLeft="8px",u.style.fontSize="15px",u.style.color="var(--blue-1)";const p=t.iconFA("sync",()=>ft(this,void 0,void 0,function*(){yield this.refreshCampaignsTable()}));p.style.marginBottom="9px",p.style.marginLeft="8px",p.style.color="var(--blue-1)",t.tooltip.bind(p,()=>"Refresh campaigns table");const m=t.divH([i,u,d,p],{style:{alignItems:"center"}});_e()(this.root).empty(),this.root.appendChild(t.div([t.divV([a,m],{style:{marginLeft:"10px"}}),this.campaignsTableRoot,n,l],{classes:"hit-triage-info-view-container"})),yield this.startNewCampaign(s,r,e)}finally{t.setUpdateIndicator(this.root,!1)}})}startNewCampaign(i,n,o){return ft(this,void 0,void 0,function*(){var a;const s=(yield mi.files.list(`${this.app.appName}/templates`)).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5));o&&!s.includes(o.name)&&s.push(o.name);let r=null,l=!0;const c=()=>ft(this,void 0,void 0,function*(){if(!l)return;const e=d.value,t=o&&o.name===e?o:yield Ne(`${this.app.appName}/templates/${e}.json`);r=t;const n=yield this.getNewCampaignAccordeon(t);_e()(i).empty(),i.appendChild(n)}),d=t.input.choice("Template",{value:null!==(a=null==o?void 0:o.name)&&void 0!==a?a:s[0],items:s,onValueChanged:()=>ft(this,void 0,void 0,function*(){yield c()})});d.root.style.width="100%";const u=t.icons.add(()=>{this.createNewTemplate()},T),p=t.icons.copy(()=>{r&&this.createNewTemplate(r)},"Clone template"),m=t.icons.delete(()=>{!d.value||d.items.length<2||t.dialog("Delete template").add(t.divText(`Are you sure you want to delete template ${d.value}?`)).onOK(()=>ft(this,void 0,void 0,function*(){try{const t=d.value;yield mi.files.delete(`${this.app.appName}/templates/${t}.json`),l=!1,d.items=d.items.filter(e=>e!==t),d.value=d.items[0],l=!0,yield c(),e.shell.info("Template "+t+" was deleted successfully")}catch(t){l=!0,e.shell.error("Failed to delete template "+d.value),console.error(t)}})).show()},"Delete template");m.style.color="var(--blue-1)",u.style.color="#2083d5",d.addOptions(u),d.addOptions(p),d.addOptions(m),yield c(),_e()(n).empty(),n.appendChild(d.root)})}checkCampaign(e){return ft(this,void 0,void 0,function*(){var t;const i=location.search,n=new URLSearchParams(i);if(!n.has(p)&&!e)return;const o=null!=e?e:n.get(p);if(!(yield mi.files.exists(`${this.app.appName}/campaigns/${o}/${h}`)))return;const a=JSON.parse(yield mi.files.readAsText(`${this.app.appName}/campaigns/${o}/${h}`));if(a){if(a.authorUserId&&a.permissions&&!(yield me(a.authorUserId,a.permissions)))return void this.app.setBaseUrl();this.app.campaign=a}const s=null!==(t=a.template)&&void 0!==t?t:yield Ne(`${this.app.appName}/templates/${a.templateName}.json`);return yield this.app.setTemplate(s,o),e&&re(p,e),a.template=s,a})}getCampaignsTable(){return ft(this,void 0,void 0,function*(){const i=yield mi.loadCampaigns(this.app.appName,this.deletedCampaigns),n=null!==(a=he(_))&&void 0!==a?a:L.None;var a;const s=function(){const e=he(V);return e?JSON.parse(e):null}(),r=Object.values(i);s&&ge(r,s);const l=Te(r,n),c=ye();this.currentGroupping=n,this.app.existingStatuses=Array.from(new Set(r.map(e=>e.status).filter(e=>!!e)));const d=i=>{var n,a;const s=t.icons.delete(()=>ft(this,void 0,void 0,function*(){t.dialog("Delete campaign").add(t.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK(()=>ft(this,void 0,void 0,function*(){yield this.deleteCampaign(this.app.appName,i.name),this.deletedCampaigns.push(i.name),yield this.init()})).show()}),"Delete campaign"),r=t.iconFA("share",()=>ft(this,void 0,void 0,function*(){yield new Qe(i.permissions).show(t=>ft(this,void 0,void 0,function*(){var n;try{i.permissions=t,null!==(n=i.authorUserId)&&void 0!==n||(i.authorUserId=e.shell.user.id),yield mi.saveCampaignJson(this.app.appName,i),e.shell.info("Permissions updated for campaign "+i.name)}catch(t){e.shell.error("Failed to update permissions for campaign "+i.name),console.error(t)}}))}),"Manage campaign permissions");return s.style.display="none",r.style.display="none",pe(null!==(n=i.authorUserId)&&void 0!==n?n:o.User.current().id,null!==(a=i.permissions)&&void 0!==a?a:Je).then(e=>{e&&(s.style.display="inline-block",r.style.display="inline-block")}),s.style.color="var(--blue-1)",r.style.color="var(--blue-1)",[r,s]},u=t.table(Object.values(l).flat(),e=>{var i;return[t.link(null!==(i=e.friendlyName)&&void 0!==i?i:e.name,()=>this.setCampaign(e.name),"Continue Campaign",""),...c.map(t=>{var i,n,o;return t.startsWith("campaignFields.")?null!==(n=null===(i=e.campaignFields)||void 0===i?void 0:i[t.replace("campaignFields.","")])&&void 0!==n?n:"":null!==(o=O[t](e))&&void 0!==o?o:""}),...d(e)]},["Name",...c.map(e=>e.replace("campaignFields.","")),"",""]);return u.style.color="var(--grey-5)",u.style.marginLeft="24px",u.querySelectorAll("tr.header > td").forEach((e,i)=>{if(!e.textContent)return;const n=0===i?"Name":c[i-1];if(s&&n===s.columnName){const i=s.ascending?"↑":"↓";e.appendChild(t.span([i],{style:{fontSize:"12px",marginLeft:"2px"}}))}e.addEventListener("dblclick",()=>{let e={columnName:n,ascending:!0};var t;s&&n===s.columnName&&(e=s.ascending?{columnName:n,ascending:!1}:null),(t=e)?ve(V,JSON.stringify(t)):localStorage.removeItem(V),this.refreshCampaignsTable()})}),xe(u,l),u})}setCampaign(e){return ft(this,void 0,void 0,function*(){const t=yield this.checkCampaign(e);this.app.campaign=t})}getNewCampaignAccordeon(e){return ft(this,void 0,void 0,function*(){const{root:t,promise:i,cancelPromise:n}=pt(e);return i.then(t=>ft(this,void 0,void 0,function*(){var i,n;this.app.clearCampaign(),this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps;const o=(null===(i=t.name)||void 0===i?void 0:i.trim())?null===(n=t.name)||void 0===n?void 0:n.trim():void 0;yield this.app.saveCampaign(!1,!0,{friendlyName:o}),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})),n.then(()=>{this.init()}),t})}createNewTemplate(i){return ft(this,void 0,void 0,function*(){t.setUpdateIndicator(this.root,!0);try{const t=yield ht(this.app,i),n=new o.ViewBase,a=e.shell.v;n.name="New Template",n.root.appendChild(t.root),n.parentCall=this.app.parentCall,e.shell.addView(n),n.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:s}=le(n,this.app.appName,T,()=>ft(this,void 0,void 0,function*(){e.shell.v=a,n.close()}));t.template.then(t=>ft(this,void 0,void 0,function*(){yield this.init(t),n.close(),ce(n),e.shell.v=a,s.unsubscribe()})),t.cancelPromise.then(()=>ft(this,void 0,void 0,function*(){s.unsubscribe(),n.close(),e.shell.v=a}))}finally{t.setUpdateIndicator(this.root,!1)}})}}class yt extends qe{constructor(e){var i;super(e),this.name="Submit",this.statusInput=t.input.string("Status",{value:null===(i=this.app.campaign)||void 0===i?void 0:i.status,nullable:!1}),this.statusSuggestionsMenu=o.Menu.popup(),this.statusInput.root.style.marginLeft="12px",this.content=t.div(),this.statusInput.onChanged.subscribe(()=>{var e,t,i,n;this.statusSuggestionsMenu.clear();const o=(null!==(e=this.statusInput.value)&&void 0!==e?e:"").toLowerCase(),a=this.app.existingStatuses.filter(e=>{var t;return(null===(t=null==e?void 0:e.toLowerCase())||void 0===t?void 0:t.includes(o))&&(null==e?void 0:e.toLowerCase())!==o}).filter((e,t)=>t<5);if(a.length){if(a.forEach(e=>{this.statusSuggestionsMenu.item(e,()=>{this.statusInput.value=e,this.statusSuggestionsMenu.root.remove(),this.statusInput.root.focus()})}),null===(t=this.content.parentElement)||void 0===t?void 0:t.parentElement){const e=this.statusInput.root.offsetLeft+(null!==(n=null===(i=this.statusInput.input)||void 0===i?void 0:i.offsetLeft)&&void 0!==n?n:0),t=this.statusInput.root.offsetTop+this.statusInput.root.offsetHeight+this.content.parentElement.offsetTop;this.statusSuggestionsMenu.show({element:this.content.parentElement.parentElement,x:e,y:t})}}else this.statusSuggestionsMenu.root.remove()})}getStatus(){var e,t,i;return null!==(i=null!==(e=this.statusInput.value)&&void 0!==e?e:null===(t=this.app.campaign)||void 0===t?void 0:t.status)&&void 0!==i?i:"No Status"}render(){var e,i,n;this.statusInput.value=null!==(i=null===(e=this.app.campaign)||void 0===e?void 0:e.status)&&void 0!==i?i:"",t.empty(this.content),this.content=t.divV([t.h1("Summary"),t.div([t.tableFromMap(this.app.getSummary())]),this.statusInput.root]);const a=t.dialog("Submit");a.add(this.content),a.addButton("Save",()=>{this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),a.close()}),a.show();const s=Array.from(new Set(o.Func.find({meta:{role:f}}).concat(o.Func.find({tags:[f]})))),r=s.reduce((e,t)=>{var i;return e[null!==(i=t.friendlyName)&&void 0!==i?i:t.name]=t,e},{});if(s.length>0){const e=this.app.submitParams,i=e?s.find(t=>t.name===e.fName&&ne(t)==e.package):void 0,o=null!==(n=null==i?void 0:i.friendlyName)&&void 0!==n?n:null==i?void 0:i.name,l=t.input.choice("Submit function",{value:o,items:[...Object.keys(r)],nullable:!0});l.onChanged.subscribe(()=>{var e,t;const i=r[null!==(e=l.value)&&void 0!==e?e:""];this.app.campaign.template.submit=i?{fName:i.name,package:ne(i)}:void 0,null===(t=a.getButton("Submit"))||void 0===t||t.remove(),i&&a.addButton("Submit",()=>{this.submit(),a.close()},void 0,"Submit the campaign file to the specified function")}),l.fireChanged(),this.content.appendChild(l.root)}}onActivated(){}submit(){return t=this,i=void 0,a=function*(){const t=this.app.submitParams;if(!t)return void e.shell.error("No submit function selected. Please select a function to submit the campaign.");const i=o.Func.find({name:t.fName,package:t.package})[0];if(!i)return void e.shell.error(`Function ${t.fName} not found.`);const n=o.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield i.apply({df:n,molecules:this.app.molColName}),this.app.campaign.status=this.getStatus(),this.app.saveCampaign(),e.shell.info("Submitted successfully.")},new((n=void 0)||(n=Promise))(function(e,o){function s(e){try{l(a.next(e))}catch(e){o(e)}}function r(e){try{l(a.throw(e))}catch(e){o(e)}}function l(t){var i;t.done?e(t.value):(i=t.value,i instanceof n?i:new n(function(e){e(i)})).then(s,r)}l((a=a.apply(t,i||[])).next())});var t,i,n,a}}var At=i(542),wt={};wt.styleTagTransform=X(),wt.setAttributes=J(),wt.insert=W().bind(null,"head"),wt.domAPI=Y(),wt.insertStyleElement=K(),H()(At.A,wt),At.A&&At.A.locals&&At.A.locals;function bt(i,n){var a,s,r,l,c,d,u,p,m,h;const v=null===(a=i.campaign)||void 0===a?void 0:a.tilesViewerFormSketch;let f=null;if(v&&v.length>0)try{f=JSON.parse(v)}catch(e){console.error("Failed to parse sketch state string",e)}f&&f.elementStates&&(null!==(s=f.elementStates.length)&&void 0!==s?s:0)>0&&(f.elementStates=f.elementStates.filter(e=>{var t;return(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.column)&&i.dataFrame.col(e.viewerSettings.column)}),f.elementStates.forEach(e=>{var t;(null===(t=null==e?void 0:e.viewerSettings)||void 0===t?void 0:t.table)&&(e.viewerSettings.table=i.dataFrame.name)}));const g=Object.assign({lanesColumnName:y,lanes:i.stages},(null!==(l=null===(r=null==f?void 0:f.elementStates)||void 0===r?void 0:r.length)&&void 0!==l?l:0)>0?{sketchState:f}:{}),A=n();if(!A)return void e.shell.error("Failed to create tiles viewer. table view is not available.");let w=null;const b=t.dialog("Progress Tracker");try{w=A.addViewer(o.VIEWER.TILE_VIEWER,g);const e=w.getOptions();e.look.sketchState=(null!==(d=null===(c=null==f?void 0:f.elementStates)||void 0===c?void 0:c.length)&&void 0!==d?d:0)>0?f:null,w.setOptions(e),w.copyViewersLook(w)}catch(t){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",t),w&&(w.close(),w.detach()),w=A.addViewer(o.VIEWER.TILE_VIEWER,{lanesColumnName:y,lanes:i.stages})}if(!w)return void e.shell.error("Failed to create tiles viewer. check the console for more details.");let C=null;const E=()=>{try{w.detach(),w.close()}catch(e){}};b.add(w.root),b.addButton("Modify Stages",()=>{null==C||C.close();const o=vt(i.stages);C=t.dialog("Modify Stages").add(o.fieldsDiv).onOK(()=>{return a=this,s=void 0,l=function*(){E(),t.setUpdateIndicator(b.root,!0);try{yield i.setStages(o.getFields()),t.setUpdateIndicator(b.root,!1),b.close(),yield new Promise(e=>setTimeout(()=>{e(),bt(i,n)},100))}catch(t){e.shell.error("Failed to update stages. check the console for more details."),console.error("Failed to update stages",t)}finally{(null==b?void 0:b.root)&&document.contains(b.root)&&b.close()}},new((r=void 0)||(r=Promise))(function(e,t){function i(e){try{o(l.next(e))}catch(e){t(e)}}function n(e){try{o(l.throw(e))}catch(e){t(e)}}function o(t){var o;t.done?e(t.value):(o=t.value,o instanceof r?o:new r(function(e){e(o)})).then(i,n)}o((l=l.apply(a,s||[])).next())});var a,s,r,l}).show(),C.root.classList.add("hit-design-stage-editing-dialog")},0);const T=e.events.onCurrentViewChanged.subscribe(()=>{e.shell.v===A?b.root.style.display="flex":b.root.style.setProperty("display","none","important")}),x=null===(p=null===(u=i.dataFrame)||void 0===u?void 0:u.col(y))||void 0===p?void 0:p.version,S=b.onClose.subscribe(()=>{var t,n;S.unsubscribe(),T.unsubscribe(),null==C||C.close();try{const e=w.props.sketchState;if(e&&"object"==typeof e){const t=JSON.stringify(e);i.campaign&&(i.campaign.tilesViewerFormSketch=t)}}catch(t){e.shell.error("Failed to save sketch state. check the console for more details."),console.error("Failed to save sketch state",t)}E(),null!=x&&(null===(n=null===(t=i.dataFrame)||void 0===t?void 0:t.col(y))||void 0===n?void 0:n.version)!==x&&i.saveCampaign()});b.showModal(!0),null===(m=b.getButton("CANCEL"))||void 0===m||m.remove(),b.onOK(()=>{}),null===(h=document.querySelector(".d4-modal-background"))||void 0===h||h.remove()}const Ct=rxjs.operators;var Et=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};const Tt="defaultCampaignFolder",xt="System.AppData/HitTriage";function St(t){return Et(this,void 0,void 0,function*(){if(!t)return[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean);try{const i=JSON.parse(t);return(yield Promise.all(i.map(t=>e.dapi.groups.find(t)))).filter(Boolean)}catch(t){return console.error(t),[yield e.dapi.groups.find(o.Group.defaultGroupsIds["All users"])].filter(Boolean)}})}var Nt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};function Bt(e){var t;const i=null===(t=mi.meta)||void 0===t?void 0:t.sok;if(!i)throw new Error("Secret key for SMILES obfuscation is not set");let n="";for(let t=0;t<e.length;t++){const o=e.charCodeAt(t),a=i.charCodeAt(t%i.length);n+=String.fromCharCode(o^a)}return btoa(n)}function It(){var e,t,i;const n=o.User.current();return null!==(i=null!==(t=null!==(e=null==n?void 0:n.login)&&void 0!==e?e:null==n?void 0:n.friendlyName)&&void 0!==t?t:n.name)&&void 0!==i?i:"unknown user"}function Ft(t,i,n){return Nt(this,void 0,void 0,function*(){const o=mi.convertToSmiles(t);if(!o||""===o||"MALFORMED_INPUT_VALUE"===o)return"";const a=Bt(o),s=yield et.addMolecule(a,n,i,It());return 0!==s.rowCount&&s.col("vid")?s.col("vid").getString(0):(e.shell.error("Molecule registration returned no data"),"")})}function Pt(t,i,n){return Nt(this,void 0,void 0,function*(){const o=new Map,a=new Map;if(t.forEach((e,t)=>{const i=mi.convertToSmiles(e);i&&""!==i&&"MALFORMED_INPUT_VALUE"!==i&&(a.has(i)||a.set(i,[]),a.get(i).push(t))}),0===a.size)return o;const s=Array.from(a.keys());for(let r=0;r<s.length;r+=50){const l=s.slice(r,r+50);if(0!==l.length)try{const e=l.map(e=>Bt(e)),s=yield et.addMolecules(e,n,i,It());if(!s||s.rowCount!==l.length||!s.col("vid"))throw console.error("Molecule registration returned incomplete data for batch",`${r}-${r+l.length}`,`Batch size: ${l.length}, Result rows: ${null==s?void 0:s.rowCount}. Vid column found: ${!!(null==s?void 0:s.col("vid"))}`),new Error("Resulting molecule registration has no or incomplete data");const c=s.col("vid").toList();for(let e=0;e<s.rowCount;e++){const i=a.get(l[e]),n=c[e];for(const e of i)o.set(t[e],n)}}catch(t){e.shell.error("Error registering molecules batch. see console for details."),mi.logger.error(t)}}return o})}var _t=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class kt extends ot{get infoView(){return this._infoView}get version(){var e,t;return null!==(t=null===(e=this._campaign)||void 0===e?void 0:e.version)&&void 0!==t?t:0}constructor(e,t="Hit Design",i=e=>new gt(e)){super(e,t),this._designViewName="Design",this._filePath=`System.AppData/HitTriage/${this.appName}/campaigns`,this._molColName=A,this.campaignProps={},this.existingStatuses=[],this._refreshIconTooltip="Refresh Campaign",this._updateCheckIntervalId=null,this._needsRefresh=!1,this._lastExpiresTimeString=null,this._refreshCampaignIcon=null,this._gridSubs=null,this._isSaving=!1,this._infoView=i(this),this.multiView=new o.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.subs.push(this.multiView.tabs.onTabChanged.subscribe(e=>{this.multiView.currentView instanceof qe&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=e,this.mainView=this.multiView,this._initViewSubs()}handleJoiningDataframe(i){return _t(this,void 0,void 0,function*(){var n,a,s,r,l,c;const d=i.columns.bySemTypeAll(o.SEMTYPE.MOLECULE);if(!d||0===d.length)return void e.shell.error("No molecule column found");let u=null;if(d.length>1){const i=d.map(e=>e.name),o=null!==(n=d.find(e=>{var t,i;return"smiles"===(null===(t=null==e?void 0:e.name)||void 0===t?void 0:t.toLowerCase())||"molecule"===(null===(i=null==e?void 0:e.name)||void 0===i?void 0:i.toLowerCase())}))&&void 0!==n?n:d[0],a=t.input.choice("Primary Molecule Column",{items:i,value:o.name,nullable:!1}),s=new Promise(e=>{t.dialog("Select Primary Molecule Column").add(t.divText("Multiple molecule columns found. Please select the primary molecule column to be used for calculations.")).add(a).onOK(()=>e(a.value)).onCancel(()=>e(null)).show()});if(u=yield s,!u)return void e.shell.info("Operation cancelled by user")}else u=d[0].name;const p=i.col(u);if(!p)return void e.shell.error("No molecule column found");const m=null!==(r=null===(s=null===(a=this.campaign)||void 0===a?void 0:a.template)||void 0===s?void 0:s.compute)&&void 0!==r?r:null===(l=this.template)||void 0===l?void 0:l.compute;if(!m)return void e.shell.warning("No compute functions found");const h=p.toList(),v=m.descriptors.enabled&&null!==(c=m.descriptors.args)&&void 0!==c?c:[],f=yield lt(h,v,m.functions,m.scripts,m.queries);if(this.unionDataframes(f,i,A,p.name),this.stages.length>0&&this.dataFrame.columns.contains(y)){const e=i.columns.getOrCreate(y,o.TYPE.STRING);for(let t=0;t<i.rowCount;t++)e.isNone(t)&&e.set(t,this.stages[0],!1)}i.columns.contains(b)&&i.columns.remove(b);const g=i.columns.addNewString(b),w=yield Pt(h,this._campaignId,this.appName);for(let e=0;e<i.rowCount;e++){const t=p.get(e),i=w.get(t);i&&g.set(e,i)}this.unionDataframes(i,this.dataFrame,p.name,this.molColName),this.saveCampaign(!1)})}get submitParams(){var e,t,i,n;return null!==(i=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.submit)&&void 0!==i?i:null===(n=this.template)||void 0===n?void 0:n.submit}_initViewSubs(){this.multiView.subs.push(e.events.onCurrentViewChanged.subscribe(()=>_t(this,void 0,void 0,function*(){var t,i,n,o;try{if(e.shell.v===this._designView){e.shell.windows.showHelp=!1,this.setBaseUrl(),re(u,null!==(n=null!==(t=this._campaignId)&&void 0!==t?t:null===(i=this._campaign)||void 0===i?void 0:i.name)&&void 0!==n?n:"");const{sub:a}=le(e.shell.v,this.appName,null===(o=e.shell.v)||void 0===o?void 0:o.name,()=>{var t;e.shell.v=this.mainView,null===(t=this._designView)||void 0===t||t.close(),this._infoView.init(),a.unsubscribe()})}else e.shell.v===this.mainView&&this.setBaseUrl()}catch(e){console.error(e)}}))),this.multiView.subs.push(e.events.onFileImportRequest.subscribe(t=>{var i,n;if(!e.shell.tv||!this._designView||e.shell.tv!==this._designView)return;if(!(null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.file))return;const o=t.args.file;((null===(n=o.name)||void 0===n?void 0:n.endsWith(".csv"))||ot.molFileExtReaders.some(e=>{var t;return null===(t=o.name)||void 0===t?void 0:t.endsWith(e.ext)}))&&(t.preventDefault(),this.handleUploadingDataframe(o))}))}handleUploadingDataframe(i){return _t(this,void 0,void 0,function*(){var n;try{let a=null;if(i.name.endsWith(".csv"))a=o.DataFrame.fromCsv(yield i.text());else{const t=yield new Promise(e=>_t(this,void 0,void 0,function*(){const t=new FileReader;let n=null,o=null;t.onload=()=>{o=t.result?new Uint8Array(t.result):null,n&&clearTimeout(n),e(o)},t.readAsArrayBuffer(i),n=setTimeout(()=>{t.abort(),e(null)},1e4)}));if(!t)return void e.shell.error("Failed to read file");const n=ot.molFileExtReaders.find(e=>i.name.endsWith(e.ext)).handlerFunc,o=n.inputs[0].name;a=(yield n.apply({[o]:t}))[0]}if(!a)throw new Error("Failed to read file");if(a.name=i.name.slice(0,i.name.lastIndexOf(".")),yield a.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(a),!a.columns.bySemType(o.SEMTYPE.MOLECULE))return void e.shell.addTableView(a);const s=t.dialog("Uploading table with molecules").add(t.divText("Add new table to workspace or join with existing Hit Design campaign")).addButton("Add to workspace",()=>{s.close(),e.shell.addTableView(a)}).addButton("Add to existing campaign",()=>{s.close(),this.handleJoiningDataframe(a)});null===(n=s.getButton("CANCEL"))||void 0===n||n.remove(),s.show()}catch(t){e.shell.error("Hit Design Failed to read file"),console.error(t)}})}get stages(){var e,t,i,n,o;return null!==(o=null!==(i=null===(t=null===(e=this.campaign)||void 0===e?void 0:e.template)||void 0===t?void 0:t.stages)&&void 0!==i?i:null===(n=this.template)||void 0===n?void 0:n.stages)&&void 0!==o?o:[]}setStages(t){return _t(this,void 0,void 0,function*(){var i;if(!this.campaign||!this.campaign.template||!this.template)return void e.shell.error("Campaign or template is not set");if(!(null==t?void 0:t.length))return void e.shell.error("Removing all stages is not allowed");const n=null===(i=this.dataFrame)||void 0===i?void 0:i.col(y);if(!n)return void e.shell.error("No stage column found");const o=[],a=new Set(t),s=[...a],r=this.dataFrame.rowCount,l=n.categories,c=n.getRawData();for(let e=0;e<r;e++){const i=l[c[e]];a.has(i)||(n.set(e,t[0],!1),o.push(i))}o.length>0&&e.shell.warning(`Some stages were removed: (${o.join(", ")}). Corresponding rows were set to stage "${t[0]}"`),this.campaign.template.stages=s,this.template.stages=s,yield this.saveCampaign(!0)})}refreshCampaign(){return _t(this,void 0,void 0,function*(){this._campaignId&&this.template?this._isSaving?e.shell.info("Campaign is being saved. Please wait a moment and try again."):(clearInterval(this._updateCheckIntervalId),this._refreshIconTooltip="Refresh Campaign",yield this.setTemplate(this.template,this._campaignId)):e.shell.warning("No campaign to refresh")})}setTemplate(i,n){return _t(this,void 0,void 0,function*(){var a,s,r,l,c,d,h,v,f,g,y;if(n){const t=`System.AppData/HitTriage/${this.appName}/campaigns`;this._filePath=null!==(r=null===(s=this.campaign)||void 0===s?void 0:s.savePath)&&void 0!==r?r:`${t}/${n}/${m}`,this.dataFrame=yield e.dapi.files.readCsv(this._filePath),(null===(l=this._campaign)||void 0===l?void 0:l.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach(([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&t&&(i.semType=t)}),(null===(c=this._campaign)||void 0===c?void 0:c.columnTypes)&&Object.entries(this._campaign.columnTypes).forEach(([e,t])=>{const i=this.dataFrame.columns.byName(e);if(i&&i.type!==t)try{this.dataFrame.changeColumnType(e,t)}catch(e){console.error(e)}})}else{(null===(a=this._designView)||void 0===a?void 0:a.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName(`${this.appName}/campaigns`,i.key),re(p,n);let t=yield function(){return Et(this,void 0,void 0,function*(){var t,i;const n=null!==(t=mi.settings)&&void 0!==t?t:yield mi.getSettings();if(!n)return xt;const o=null!==(i=n instanceof Map?n.get(Tt):n[Tt])&&void 0!==i?i:xt;return(yield e.dapi.files.exists(o))?o:xt})}();t.endsWith("/")||(t+="/"),this._filePath=`${t}${this.appName}/campaigns/${n}/${m}`}if(!this.dataFrame)return e.shell.error("DataFrame is empty"),clearInterval(this._updateCheckIntervalId),void(this._updateCheckIntervalId=null);yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(h=null===(d=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==h?h:A,this._campaignId=n,this.template=i,null!==(v=this._submitView)&&void 0!==v||(this._submitView=new yt(this)),e.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const w=this.designView;this.currentDesignViewId=w.name,this.setBaseUrl(),re(u,null!==(y=null!==(f=this._campaignId)&&void 0!==f?f:null===(g=this._campaign)||void 0===g?void 0:g.name)&&void 0!==y?y:""),this.campaign&&(this.campaign.template=i),et.getLastModified(this.appName,this._campaignId).then(i=>{var n;const o=null===(n=null==i?void 0:i.col("updated_at"))||void 0===n?void 0:n.getString(0);this._lastExpiresTimeString=null!=o?o:null,this._needsRefresh=!1,clearInterval(this._updateCheckIntervalId);let a=!1;this._updateCheckIntervalId=setInterval(()=>_t(this,void 0,void 0,function*(){var i;if(!a&&!this._needsRefresh){if(a=!0,this._designView&&!Array.from(e.shell.tableViews).some(e=>e===this._designView))return clearInterval(this._updateCheckIntervalId),console.log("Clearing campaign update check interval"),this._updateCheckIntervalId=null,void(a=!1);if(this._campaignId&&this.template&&!this._isSaving&&!this.isJoining&&this._designView&&e.shell.v===this._designView){try{const e=yield et.getLastModified(this.appName,this._campaignId),n=null===(i=null==e?void 0:e.col("updated_at"))||void 0===i?void 0:i.getString(0);if(!n)return void(a=!1);this._lastExpiresTimeString!==n&&this._refreshCampaignIcon&&(this._lastExpiresTimeString=n,t.hints.addHintIndicator(this._refreshCampaignIcon,!0,1e4),this._refreshIconTooltip="New changes available. Click to refresh campaign.",this._lastExpiresTimeString=n,this._needsRefresh=!0)}catch(e){console.error(e)}a=!1}else a=!1}}),3e3)}).catch(e=>console.error(e))})}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}set designViewName(e){this._designViewName=e,this._designView&&(this._designView.name=e)}get molColName(){var e,t,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(n=null===(i=null===(t=this.dataFrame)||void 0===t?void 0:t.columns.bySemType(o.SEMTYPE.MOLECULE))||void 0===i?void 0:i.name)&&void 0!==n?n:A}get campaign(){return this._campaign}set campaign(e){this._campaign=e}clearCampaign(){this._campaign=void 0}cacheDuplicateVIDs(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(b);if(!t)return void(this._duplicateVidCache=void 0);const i=t.version,n=new Uint32Array(t.categories.length).fill(0),o=t.getRawData().subarray(0,t.length);o.forEach(e=>n[e]++),this._duplicateVidCache={colVersion:i,valueCounts:n,indexes:o}}get duplicateVidCache(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(b);if(t)return this._duplicateVidCache&&t.version===this._duplicateVidCache.colVersion||this.cacheDuplicateVIDs(),this._duplicateVidCache}performSingleCellCalculations(e,t){return _t(this,void 0,void 0,function*(){const i=this.template.compute;if(!t||""===t)return;const n=yield lt([t],i.descriptors.args,i.functions,i.scripts,i.queries);for(const t of n.columns.toList())t.name!==A&&(this.dataFrame.columns.contains(t.name)||(this.dataFrame.columns.addNew(t.name,t.type).semType=t.semType),this.dataFrame.col(t.name).set(e,t.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(!1)})}initDesignViewRibbons(i,n,a=!1){var s,r,d;const u=e.events.onViewRemoved.subscribe(e=>{e.id===(null==i?void 0:i.id)&&(n.forEach(e=>e.unsubscribe()),u.unsubscribe())});let p=null==i?void 0:i.getRibbonPanels();if(p&&!de(p)){setTimeout(()=>{const{sub:t}=le(i,this.appName,i.name,()=>{e.shell.v=this.mainView,null==i||i.close(),this._infoView.init(),t.unsubscribe()})},1e3);const n=()=>_t(this,void 0,void 0,function*(){var e;Oe(this,e=>_t(this,void 0,void 0,function*(){var n,o,a,s,r,d,u,p,m,h;const v=this.template.compute.descriptors.args,f=this.template.compute.functions,g=null!==(n=this.template.compute.scripts)&&void 0!==n?n:[],y=null!==(o=this.template.compute.queries)&&void 0!==o?o:[],A=e.descriptors,w={descriptors:{enabled:!!(null===(a=null==e?void 0:e.descriptors)||void 0===a?void 0:a.length),args:null!==(s=null==e?void 0:e.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(r=null==e?void 0:e.externals)&&void 0!==r?r:{}).map(([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(d=null==e?void 0:e.scripts)&&void 0!==d?d:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(u=null==e?void 0:e.queries)&&void 0!==u?u:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})};this.template.compute=w,this.campaign.template=this.template;const b=A.filter(e=>!v.includes(e)),C={};Object.entries(null!==(p=null==e?void 0:e.externals)&&void 0!==p?p:{}).filter(([e,t])=>{const i=f.find(t=>`${t.package}:${t.name}`===e);return!i||!Object.entries(t).every(([e,t])=>i.args[e]===t)}).forEach(([e,t])=>{C[e]=t});const E={};Object.entries(null!==(m=null==e?void 0:e.scripts)&&void 0!==m?m:{}).filter(([e,t])=>{const i=g.find(t=>`${l}:${t.name}:${t.id}`===e);return!i||!Object.entries(t).every(([e,t])=>i.args[e]===t)}).forEach(([e,t])=>{E[e]=t});const T={};Object.entries(null!==(h=null==e?void 0:e.queries)&&void 0!==h?h:{}).filter(([e,t])=>{const i=y.find(t=>`${c}:${t.name}:${t.id}`===e);return!i||!Object.entries(t).every(([e,t])=>i.args[e]===t)}).forEach(([e,t])=>{T[e]=t}),t.setUpdateIndicator(i.grid.root,!0);try{yield ct({descriptors:b,externals:C,scripts:E,queries:T},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{t.setUpdateIndicator(i.grid.root,!1),this.saveCampaign(!1)}}),()=>null,null===(e=this.campaign)||void 0===e?void 0:e.template,!0)}),u=t.iconFA("wrench",n,"Calculate additional properties"),m=t.icons.add(()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)},"Add new row"),h=t.iconSvg("view-layout",()=>{this.applyTemplateLayout(i)},"Apply template layout "+((null===(s=this.template)||void 0===s?void 0:s.localLayoutPath)?"(Loaded from mounted file storage)":"(Static)"));this._refreshCampaignIcon=t.icons.sync(()=>_t(this,void 0,void 0,function*(){this.refreshCampaign()})),t.tooltip.bind(this._refreshCampaignIcon,()=>this._refreshIconTooltip);const v=t.iconFA("share",()=>_t(this,void 0,void 0,function*(){var e;yield new Qe(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show(e=>{this.campaign.permissions=e,this.saveCampaign(!0)})}),"Edit campaign permissions"),f=t.bigButton("Progress tracker",()=>{bt(this,()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null})}),g=t.bigButton("Submit...",()=>{var e;null===(e=this._submitView)||void 0===e||e.render()}),y=o.Func.find({meta:{role:"HitDesignerFunction"}}).filter(e=>1===e.outputs.length&&e.outputs[0].propertyType===o.TYPE.DATA_FRAME);g.classList.add("hit-design-submit-button");const A=[g];if(this.stages.length>0&&A.unshift(f),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),((null===(r=this.template)||void 0===r?void 0:r.layoutViewState)||(null===(d=this.template)||void 0===d?void 0:d.localLayoutPath))&&A.unshift(h),this.hasEditPermission&&A.unshift(v),y.length>0&&a){const i=y[0],n=t.iconFA("pen-nib",()=>_t(this,void 0,void 0,function*(){var n;const a={};if(i.inputs.length>0&&this.dataFrame&&this.dataFrame.currentRowIdx>=0&&i.inputs[0].semType===o.SEMTYPE.MOLECULE){const e=mi.convertToSmiles(null===(n=this.dataFrame.col(this.molColName))||void 0===n?void 0:n.get(this.dataFrame.currentRowIdx));e&&(a[i.inputs[0].name]=e)}const s=i.prepare(a),r=yield s.getEditor();t.dialog(i.friendlyName).add(r).onOK(()=>_t(this,void 0,void 0,function*(){const t=o.TaskBarProgressIndicator.create(`Running ${i.friendlyName}`);try{yield s.call();const n=s.getOutputParamValue();if(!n||!n.rowCount)return e.shell.warning(`${i.friendlyName} returned an empty result`),void t.close();yield n.meta.detectSemanticTypes(),yield e.data.detectSemanticTypes(n),yield this.handleJoiningDataframe(n)}catch(t){e.shell.error(`Failed to run ${i.friendlyName}`),mi.logger.error(t)}finally{t.close()}})).show()}),i.description?i.description:i.friendlyName);A.unshift(n)}A.unshift(u),A.unshift(m),A.unshift(this._refreshCampaignIcon),p.push(A),p.some(e=>{var t;const i=null!==(t=null==e?void 0:e.findIndex(e=>{var t;return"save"===(null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.toLowerCase())}))&&void 0!==t?t:-1;return-1!==i&&(e.splice(i,1),!0)}),p=p.filter(e=>{var t;return(null!==(t=null==e?void 0:e.length)&&void 0!==t?t:0)>0}),i.setRibbonPanels(p)}return i}applyTemplateLayout(t){return _t(this,void 0,void 0,function*(){var i,n;if(t){if(null===(i=this.template)||void 0===i?void 0:i.localLayoutPath)try{const i=yield e.dapi.files.readAsText(this.template.localLayoutPath),n=o.ViewLayout.fromJson(i);return void t.loadLayout(n)}catch(t){e.shell.error("Failed to apply layout from mounted file storage. Falling back to static layout"),mi.logger.error(t)}if(null===(n=this.template)||void 0===n?void 0:n.layoutViewState)try{const e=o.ViewLayout.fromViewState(this.template.layoutViewState);t.loadLayout(e)}catch(t){e.shell.error("Failed to apply template layout. Check console for more details."),mi.logger.error(t)}else e.shell.error("No layout found")}else e.shell.error("No view found")})}getDesignView(){var t,i,n,a,s,r,l;this._designView&&this._designView.close();const c=[],d=null===(t=this.dataFrame.col(this.molColName))||void 0===t?void 0:t.toList().every(e=>!e&&""===e),u=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(s=null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.friendlyName)&&void 0!==n?n:null===(a=this.campaign)||void 0===a?void 0:a.name)&&void 0!==s?s:this._designViewName,u.name=this._designViewName,u._onAdded();const p=null===(r=this._campaign)||void 0===r?void 0:r.layout;if(p)try{const e=o.ViewLayout.fromViewState(p);u.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}this.checkGrid(u),d&&e.functions.call("Chem:editMoleculeCell",{cell:u.grid.cell(this._molColName,0)}),this.initGridSubs(u,c);const m=null===(l=u.grid)||void 0===l?void 0:l.col(b);m&&(m.editable=!1);const h=this.dataFrame.col(b);return h&&(h.semType=C,h.valueComparer=(e,t)=>e===t?0:null===e?-1:null===t?1:parseInt(e.substring(1))-parseInt(t.substring(1))),c.push(this.dataFrame.onRowsAdded.pipe((0,Ct.filter)(()=>!this.isJoining)).subscribe(()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const i=this.dataFrame.col(y).get(e);i&&""!==i&&!(null===(t=this.dataFrame.col(y))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(y,e,this.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=u.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)}})),c.push(e.events.onContextMenu.subscribe(t=>{var i,n,a,s,r,l,c,d,p,m,h,v;try{const e=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==u.id)return;if((null===(s=null===(a=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.molColName||!(null===(l=null===(r=null==t?void 0:t.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(c=null==t?void 0:t.args)||void 0===c?void 0:c.menu;if(!f)return;f.item("Add new row",()=>{this.dataFrame.rows.addNew(null,!0)}),f.item("Duplicate molecule",()=>{var e,i,n,o;try{const a=this.dataFrame.rows.addNew(null,!0);null!=a.get(this.molColName)&&a.idx>-1&&(this.dataFrame.cell(a.idx,this.molColName).value=null!==(o=null===(n=null===(i=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===i?void 0:i.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}});const g=null===(p=null===(d=null==t?void 0:t.args)||void 0===d?void 0:d.item)||void 0===p?void 0:p.tableRowIndex,y=null===(v=null===(h=null===(m=null==t?void 0:t.args)||void 0===m?void 0:m.item)||void 0===h?void 0:h.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",()=>_t(this,void 0,void 0,function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}})),c.push(e.events.onViewLayoutApplied.subscribe(e=>{e&&e.view===u&&this.initGridSubs(u,c)})),this.initDesignViewRibbons(u,c,!0),u.parentCall=this.parentCall,u}checkGrid(t){t.grid||(e.shell.error("Applied layout created view without grid. Resetting layout."),t.resetLayout())}initGridSubs(t,i){this._gridSubs&&this._gridSubs.grid===t.grid||(this._gridSubs&&this._gridSubs.subs.forEach(e=>e.unsubscribe()),this.checkGrid(t),t.grid?(this._gridSubs={grid:t.grid,subs:[]},(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellValueEdited.subscribe(t=>_t(this,void 0,void 0,function*(){var i,n;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===y)return void(yield this.saveCampaign(!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.molColName)return;const e=t.cell.value,o=t.tableRowIndex;if(e)try{const t=yield Ft(e,this._campaignId,this.appName);this.dataFrame.col(b).set(o,t,!0)}catch(e){console.error("Failed to register molecule")}yield this.performSingleCellCalculations(o,e)}catch(t){e.shell.error("Failed to process molecule edit, check console for details"),console.error(t)}}))),(null==t?void 0:t.grid)&&this._gridSubs.subs.push(t.grid.onCellRender.subscribe(e=>{var t;try{const i=e.cell,n=this.duplicateVidCache;if(!i||!i.isTableCell||!i.tableColumn||!n||i.tableColumn.name!==b||(null!==(t=i.tableRowIndex)&&void 0!==t?t:-1)<0)return;n.valueCounts[n.indexes[i.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(n.indexes[i.tableRowIndex]),150))}catch(e){}})),this._gridSubs.subs.forEach(e=>i.push(e))):e.shell.error("No grid found, cannot initialize grid subscriptions"))}getSummary(){var i,n,a,s,r,l,c,d,u,p,h,v,f;const g=()=>{var e,t;const i=this._filePath.indexOf(null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name);return-1===i?this._filePath:this._filePath.substring(0,i-1)},y=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);this.template&&this.template.campaignFields&&Object.entries(y).forEach(([t,i])=>{const n=this.template.campaignFields.find(e=>e.name===t);n&&"Date"===n.type&&i?"Invalid Date"!==new Date(i).toString()?y[t]=new Date(i).toLocaleDateString():i.date?y[t]=new Date(i.date).toLocaleDateString():y[t]=i:n&&n.type===o.SEMTYPE.MOLECULE&&i&&(y[t]=e.chem.drawMolecule(i))});const A=null!==(l=null!==(s=null===(a=this.campaign)||void 0===a?void 0:a.friendlyName)&&void 0!==s?s:null===(r=this.campaign)||void 0===r?void 0:r.name)&&void 0!==l?l:this.campaignId,w=function(i,n){var o;const a=t.icons.edit(()=>{var o,r,l,c,d;let u=null!==(r=null!==(o=null==n?void 0:n.tooltip)&&void 0!==o?o:i.textContent)&&void 0!==r?r:"";const p=null!==(l=null==n?void 0:n.beforeEditTextContent)&&void 0!==l?l:e=>e,m=null!==(c=null==n?void 0:n.afterEditTextContent)&&void 0!==c?c:e=>e,h=t.input.string("smth",{value:p(null!==(d=i.textContent)&&void 0!==d?d:""),onValueChanged:()=>ae(this,void 0,void 0,function*(){var e;const t=yield f();setTimeout(()=>{var e,o;if(t)return h.input.classList.add("d4-invalid"),void(u=t);h.input.classList.remove("d4-invalid"),u=null!==(o=null!==(e=null==n?void 0:n.tooltip)&&void 0!==e?e:i.textContent)&&void 0!==o?o:""},100),null===(e=null==n?void 0:n.onChange)||void 0===e||e.call(n,h.value)})});t.tooltip.bind(h.input,()=>u);const v=h.root.getElementsByTagName("label").item(0);v&&v.remove(),h.root.style.width="100%";const f=()=>ae(this,void 0,void 0,function*(){var e;const t=(null===(e=h.value)||void 0===e?void 0:e.trim())||(null==n?void 0:n.nullable)?null:"Field cannot be empty";return null!=t?t:(null==n?void 0:n.validator)?yield n.validator(h.value):null}),g=t.button("Save",()=>ae(this,void 0,void 0,function*(){var o,r;const l=yield f();l?e.shell.error(l):(yield null===(o=null==n?void 0:n.onOk)||void 0===o?void 0:o.call(n,h.value),i.textContent=null!==(r=m(h.value))&&void 0!==r?r:"",t.empty(s),s.appendChild(i),s.appendChild(a))})),y=t.button("Cancel",()=>{var e;t.empty(s),s.appendChild(i),s.appendChild(a),null===(e=null==n?void 0:n.onCancel)||void 0===e||e.call(n)});t.empty(s),h.addOptions(y),h.addOptions(g),s.appendChild(h.root),h.input.focus()},null!==(o=null==n?void 0:n.tooltip)&&void 0!==o?o:"Edit"),s=t.divH([i,a],{style:{display:"flex",alignItems:"center"}});return a.style.marginLeft="5px",s}(t.divText(A),{tooltip:"Edit Campaign Name",nullable:!1,onOk:e=>_t(this,void 0,void 0,function*(){this.campaign.friendlyName=e,yield this.saveCampaign(!0)}),validator:e=>_t(this,void 0,void 0,function*(){return(null==e?void 0:e.trim())?null:"Campaign name can not be empty"})});return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({Name:w,Code:null!==(c=this.campaignId)&&void 0!==c?c:null===(d=this._campaign)||void 0===d?void 0:d.name,Template:null!==(p=null===(u=this.template)||void 0===u?void 0:u.name)&&void 0!==p?p:"Molecules","File Path":(()=>{const i=t.icons.edit(()=>{const n=g(),s=t.input.string("Path",{value:n}),r=s.root.getElementsByTagName("label").item(0);r&&r.remove(),s.root.style.width="100%";const l=t.button("Save",()=>_t(this,void 0,void 0,function*(){if(!(yield function(t){return ae(this,void 0,void 0,function*(){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)})}(s.value)))return;const n=s.value;n.endsWith("/")?this._filePath=`${n}${this.campaignId}/${m}`:this._filePath=`${n}/${this.campaignId}/${m}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(!0),t.empty(a);const r=g();o=t.link(r,()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")},N),a.appendChild(o),a.appendChild(i)})),c=t.button("Cancel",()=>{t.empty(a),a.appendChild(o),a.appendChild(i)});t.empty(a),s.addOptions(c),s.addOptions(l),a.appendChild(s.root),s.input.focus()},"Edit file path");i.style.marginLeft="5px";const n=g();let o=t.link(n,()=>{var e,t,i;return this.download(this.dataFrame,null!==(i=null!==(e=this.campaignId)&&void 0!==e?e:null===(t=this._campaign)||void 0===t?void 0:t.name)&&void 0!==i?i:"Molecules")},N);const a=t.divH([o,i],{style:{alignItems:"center"}});return a})()},(null===(h=this.campaign)||void 0===h?void 0:h.authorUserFriendlyName)?{Author:this.campaign.authorUserFriendlyName}:{}),(null===(v=this.campaign)||void 0===v?void 0:v.lastModifiedUserName)?{"Last Modified By":this.campaign.lastModifiedUserName}:{}),(null===(f=this.campaign)||void 0===f?void 0:f.createDate)?{"Create Date":this.campaign.createDate}:{}),y),{"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(", ")})}saveCampaign(){return _t(this,arguments,void 0,function*(i=!0,n=!1,a){var s,r,l,c,d,u,p,m,v,f,g,y,A,w,b,C,E,T,x,S,N,B,I,F,P;this._isSaving=!0;const _=this.campaignId,k=setTimeout(()=>{var e;(null===(e=this._designView)||void 0===e?void 0:e.grid)&&t.setUpdateIndicator(this._designView.grid.root,!0,"Someone else is saving the campaign. Please wait...")},500);try{const e=yield this.aquireAndWaitCampaignLock(_);if(!(null==e?void 0:e.aquired))throw new Error("Could not acquire lock for campaign during 30 seconds")}catch(i){return clearTimeout(k),(null===(s=this._designView)||void 0===s?void 0:s.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),e.shell.error("Failed to acquire campaign lock. Someone else might be editing the campaign. Please try again later."),this._isSaving=!1,this.campaign}clearTimeout(k),(null===(r=this._designView)||void 0===r?void 0:r.grid)&&t.setUpdateIndicator(this._designView.grid.root,!0,"Saving Campaign...");const V=this.template.name,L=this.dataFrame,O=_,D={};L.columns.toList().forEach(e=>D[e.name]=e.semType);const $={};L.columns.toList().forEach(e=>$[e.name]=e.type);const M=null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.tilesViewerFormSketch)&&void 0!==c?c:void 0,R=null!==(u=null===(d=this.campaign)||void 0===d?void 0:d.authorUserId)&&void 0!==u?u:e.shell.user.id,j=null!==(m=null===(p=this.campaign)||void 0===p?void 0:p.permissions)&&void 0!==m?m:yield(()=>_t(this,void 0,void 0,function*(){try{const e=yield function(){return Et(this,void 0,void 0,function*(){var e,t,i,n,o;try{const a=null!==(e=mi.settings)&&void 0!==e?e:yield mi.getSettings(),s={view:[],edit:[]};return a?(a instanceof Map?(s.view=yield St(null!==(t=a.get("view"))&&void 0!==t?t:""),s.edit=yield St(null!==(i=a.get("edit"))&&void 0!==i?i:"")):(s.view=yield St(null!==(n=a.view)&&void 0!==n?n:""),s.edit=yield St(null!==(o=a.edit)&&void 0!==o?o:"")),s):s}catch(e){return console.error(e),{view:[],edit:[]}}})}(),t={view:e.view.map(e=>e.id),edit:e.edit.map(e=>e.id)};return 0===t.edit.length&&(t.edit=[Je.edit[0]]),0===t.view.length&&(t.view=[Je.view[0]]),t}catch(t){e.shell.error("Failed to get default permissions"),console.error(t)}return Je}))(),U=R?null!==(f=null===(v=this.campaign)||void 0===v?void 0:v.authorUserFriendlyName)&&void 0!==f?f:null===(g=yield e.dapi.users.find(R))||void 0===g?void 0:g.friendlyName:void 0,H={name:O,friendlyName:null!==(w=null!==(A=null===(y=this.campaign)||void 0===y?void 0:y.friendlyName)&&void 0!==A?A:null==a?void 0:a.friendlyName)&&void 0!==w?w:O,templateName:V,status:null!==(C=null===(b=this.campaign)||void 0===b?void 0:b.status)&&void 0!==C?C:"In Progress",createDate:null!==(T=null===(E=this.campaign)||void 0===E?void 0:E.createDate)&&void 0!==T?T:se(new Date),campaignFields:null!==(S=null===(x=this.campaign)||void 0===x?void 0:x.campaignFields)&&void 0!==S?S:this.campaignProps,columnSemTypes:D,rowCount:L.rowCount,filteredRowCount:L.filter.trueCount,savePath:this._filePath,columnTypes:$,tilesViewerFormSketch:M,version:this.version+1,authorUserId:R,authorUserFriendlyName:U,lastModifiedUserName:e.shell.user.friendlyName,permissions:j};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),(null===(N=this._designView)||void 0===N?void 0:N.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),yield this.releaseCampaignLock(_),this._isSaving=!1,H;const q=`${this.appName}/campaigns/${_}/${h}`;let Y=L;if(yield mi.files.exists(q)){const t=JSON.parse(yield mi.files.readAsText(q));if((null!==(B=t.version)&&void 0!==B?B:0)>this.version&&(H.version=Math.max(this.version,null!==(I=t.version)&&void 0!==I?I:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);Y=this.unionDataframes(t,L,this.molColName,this.molColName)}catch(e){console.error(e)}}const G=o.DataFrame.fromColumns(Y.columns.toList().filter(e=>!e.name.startsWith("~"))).toCsv();yield e.dapi.files.writeAsText(this._filePath,G);const W=this._designView.saveLayout();W?H.layout=W.viewState:e.shell.warning("Layout cound not be saved"),H.template=this.template,yield mi.saveCampaignJson(this.appName,H),i&&e.shell.info("Campaign saved successfully."),!i&&n&&e.shell.info("Campaign created successfully."),this.campaign=H,this.designViewName=null!==(F=H.friendlyName)&&void 0!==F?F:H.name;const z=yield this.releaseCampaignLock(_);return this._lastExpiresTimeString=z,(null===(P=this._designView)||void 0===P?void 0:P.grid)&&t.setUpdateIndicator(this._designView.grid.root,!1),this._isSaving=!1,this._refreshIconTooltip="Refresh Campaign",H})}}class Vt extends o.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,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(){e.drawImage(l,t+2,i+2,n-2,o-2)}}}var Lt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class Ot extends gt{constructor(t){super(t),this.name="PeptiHit",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(mi.webRoot+"README_HD.md")}getNewCampaignAccordeon(e){return Lt(this,void 0,void 0,function*(){const{root:t,promise:i,cancelPromise:n}=pt(e,!0);return i.then(t=>Lt(this,void 0,void 0,function*(){this.app.dataFrame=t.df,yield this.app.setTemplate(e),this.app.campaignProps=t.campaignProps,yield this.app.saveCampaign(!1),e.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=e.layoutViewState)})),n.then(()=>{this.init()}),t})}getAppHeader(){return We.appHeader({iconPath:mi.webRoot+"/images/icons/pepti-hit-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 Helm sequences in the spreadsheet\n- Annotate and share ideas with the team\n- Convert to molecular form and calculate different properties\n- Save campaigns and continue from where you left off\n- Submit final selection to the function of your choice"})}}var Dt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class $t extends kt{constructor(e){super(e,"PeptiHit",e=>new Ot(e)),this._helmColName=w}setTemplate(e,t){const i=Object.create(null,{setTemplate:{get:()=>super.setTemplate}});return Dt(this,void 0,void 0,function*(){var n,a;yield i.setTemplate.call(this,e,t),this._helmColName=null!==(a=null===(n=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===n?void 0:n.name)&&void 0!==a?a:w})}get helmColName(){var e,t;return null!==(e=this._helmColName)&&void 0!==e?e:null===(t=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE))||void 0===t?void 0:t.name}performSingleCellCalculations(t,i){const n=Object.create(null,{performSingleCellCalculations:{get:()=>super.performSingleCellCalculations}});return Dt(this,void 0,void 0,function*(){var a;try{if(!i)throw new Error("No cell value provided");const s=o.Column.fromStrings(this.helmColName,[i]),r=o.DataFrame.fromColumns([s]);s.semType=o.SEMTYPE.MACROMOLECULE,s.setTag("units","helm"),s.setTag(".alphabetIsMultichar","true"),yield e.functions.call("Bio:toAtomicLevel",{table:r,seqCol:s,nonlinear:!0});const l=r.columns.names().find(e=>e.toLowerCase()!==this.helmColName.toLowerCase()),c=l?null===(a=r.col(l))||void 0===a?void 0:a.get(0):null;if(!c)throw new Error("Failed to convert sequence to atomic level");this.dataFrame.set(this.molColName,t,c),yield n.performSingleCellCalculations.call(this,t,c)}catch(e){console.error(e)}})}getDesignView(){var t,i,n,a,s,r,l;const c=[],d=null===(t=this.dataFrame.col(this.helmColName))||void 0===t?void 0:t.toList().every(e=>!e&&""===e),u=this.dataFrame.col(this.helmColName);if(!u)throw new Error("No helm column found");u.semType=o.SEMTYPE.MACROMOLECULE,u.setTag("units","helm"),u.setTag(".alphabetIsMultichar","true"),u.setTag("cell.renderer","helm");const p=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.name)&&void 0!==n?n:this._designViewName,p.name=this._designViewName,p._onAdded();const m=null!==(s=null===(a=this._campaign)||void 0===a?void 0:a.layout)&&void 0!==s?s:null===(r=this.template)||void 0===r?void 0:r.layoutViewState;if(m)try{const e=o.ViewLayout.fromViewState(m);p.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}const h=null===(l=p.grid)||void 0===l?void 0:l.col(b);h&&(h.editable=!1);const v=this.dataFrame.col(b);return v&&(v.semType=C,v.valueComparer=(e,t)=>e===t?0:null===e?-1:null===t?1:parseInt(e.substring(1))-parseInt(t.substring(1))),d&&e.functions.call("Helm:editMoleculeCell",{cell:p.grid.cell(this.helmColName,0)}),c.push(this.dataFrame.onRowsAdded.pipe((0,Ct.filter)(()=>!this.isJoining)).subscribe(()=>{var t;try{if(this.stages.length>0)for(let e=0;e<this.dataFrame.rowCount;e++){const i=this.dataFrame.col(y).get(e);i&&""!==i&&!(null===(t=this.dataFrame.col(y))||void 0===t?void 0:t.isNone(e))||this.dataFrame.set(y,e,this.stages[0])}let i=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=p.grid.cell(this.helmColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(i=t))}i&&e.functions.call("Helm:editMoleculeCell",{cell:i})}catch(e){console.error(e)}})),c.push(e.events.onContextMenu.subscribe(t=>{var i,n,a,s,r,l,c,d,u,m,h,v;try{const e=null===(i=null==t?void 0:t.args)||void 0===i?void 0:i.context;if(!e)return;if((null==e?void 0:e.type)!==o.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==p.id)return;if((null===(s=null===(a=null===(n=null==t?void 0:t.args)||void 0===n?void 0:n.item)||void 0===a?void 0:a.tableColumn)||void 0===s?void 0:s.name)!==this.helmColName||!(null===(l=null===(r=null==t?void 0:t.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const f=null===(c=null==t?void 0:t.args)||void 0===c?void 0:c.menu;if(!f)return;f.item("Add new row",()=>{this.dataFrame.rows.addNew(null,!0)}),f.item("Duplicate Sequence",()=>{var e,i,n,o;try{const a=this.dataFrame.rows.addNew(null,!0);null!=a.get(this.helmColName)&&a.idx>-1&&(this.dataFrame.cell(a.idx,this.helmColName).value=null!==(o=null===(n=null===(i=null===(e=null==t?void 0:t.args)||void 0===e?void 0:e.item)||void 0===i?void 0:i.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}});const g=null===(u=null===(d=null==t?void 0:t.args)||void 0===d?void 0:d.item)||void 0===u?void 0:u.tableRowIndex,y=null===(v=null===(h=null===(m=null==t?void 0:t.args)||void 0===m?void 0:m.item)||void 0===h?void 0:h.cell)||void 0===v?void 0:v.value;y&&(null!=g?g:-1)>-1&&f.item("Re-Run Calculations",()=>Dt(this,void 0,void 0,function*(){try{yield this.performSingleCellCalculations(g,y)}catch(e){console.error(e)}}))}catch(t){e.log.error(t)}})),(null==p?void 0:p.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),p.resetLayout()),(null==p?void 0:p.grid)&&c.push(p.grid.onCellValueEdited.subscribe(t=>Dt(this,void 0,void 0,function*(){var i,n;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===y)return void(yield this.saveCampaign(!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.helmColName)return;const e=t.cell.value,o=t.tableRowIndex;yield this.performSingleCellCalculations(o,e);try{const e=this.dataFrame.col(this.molColName).get(o),t=yield Ft(null!=e?e:"",this.campaignId,this.appName);t&&this.dataFrame.col(b).set(o,t,!0)}catch(e){console.error("Error updating V-iD column:",e)}}catch(t){e.shell.error("Error performing cell calculations: "+t),console.error(t)}}))),(null==p?void 0:p.grid)&&c.push(p.grid.onCellRender.subscribe(e=>{var t;try{const i=this.duplicateVidCache,n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!i||n.tableColumn.name!==b||(null!==(t=n.tableRowIndex)&&void 0!==t?t:-1)<0)return;i.valueCounts[i.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=o.Color.setAlpha(o.Color.getCategoricalColor(i.indexes[n.tableRowIndex]),150))}catch(e){}})),this.initDesignViewRibbons(p,c),p.parentCall=this.parentCall,p}}var Mt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};var Rt=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class jt extends Ze{constructor(t){super(t),this.pepTriageDataSourceFunctionsMap={},this.name="PepTriage",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(mi.webRoot+"README_HT.md")}onActivated(){e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(mi.webRoot+"README_HT.md")}getAppHeader(){return We.appHeader({iconPath:mi.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- Load sequence datasets and auto-convert to molecules\n- Calculate different molecular properties\n- Filter sequences using different criteria\n- Save campaigns and continue any time from where you left off\n- Submit final selection to the function of your choice"})}getTemplatesFolder(){return`${this.app.appName}/templates`}getDataSourceTag(){return j}getDataSourceFunctionsMap(){return this.pepTriageDataSourceFunctionsMap}getNewCampaignAccordeon(e,i){return Rt(this,void 0,void 0,function*(){var n,o;const a=e,s=t.input.string("Sequence Column",{value:null!==(n=a.sequenceColumnName)&&void 0!==n?n:"",nullable:!1});s.setTooltip("Name of the sequence column in the dataset");const r=t.input.string("Molecule Column",{value:null!==(o=a.moleculeColumnName)&&void 0!==o?o:"",nullable:!0});r.setTooltip("Name of the molecule column (leave empty to auto-convert from sequences)"),t.setUpdateIndicator(i,!0);const{root:l,promise:c,cancelPromise:d}=yield Fe(e,this.getDataSourceFunctionsMap(),this.getDataSourceTag(),{extraFormElements:[s.root,r.root],getExtraData:()=>{var e,t;return{sequenceColumnName:(null===(e=s.value)||void 0===e?void 0:e.trim())||a.sequenceColumnName,moleculeColumnName:(null===(t=r.value)||void 0===t?void 0:t.trim())||void 0}}});return t.setUpdateIndicator(i,!1),c.then(e=>Rt(this,void 0,void 0,function*(){var t,i,n,o;const s=Object.assign(Object.assign({},a),{sequenceColumnName:null!==(i=null===(t=e.extraData)||void 0===t?void 0:t.sequenceColumnName)&&void 0!==i?i:a.sequenceColumnName,moleculeColumnName:null!==(o=null===(n=e.extraData)||void 0===n?void 0:n.moleculeColumnName)&&void 0!==o?o:a.moleculeColumnName});this.app.dataFrame=e.df,this.app._fileInputType=e.type,yield this.app.setTemplate(s,void 0,void 0,void 0,e.friendlyName),this.app.campaignProps=e.campaignProps,yield this.app.saveCampaign(void 0,!1),s.layoutViewState&&this.app.campaign&&(this.app.campaign.layout=s.layoutViewState)})),d.then(()=>{this.init()}),l})}createNewTemplate(i){return Rt(this,void 0,void 0,function*(){const n=yield function(i,n,a){return Mt(this,void 0,void 0,function*(){var s,r,d,u,p;const m=`${i.appName}/templates`,h=(yield mi.files.list(m)).filter(e=>e.name.endsWith(".json")).map(e=>e.name.slice(0,-5)),v=[];for(const e of h){const t=yield Ne(`${m}/${e}.json`);v.push(t.key)}const g=Array.from(new Set(o.Func.find({meta:{role:f}}).concat(o.Func.find({tags:[f]})))),y={};g.forEach(e=>{var t;y[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const A=(null==a?void 0:a.submit)?Object.keys(y).find(e=>{var t,i;return(null===(t=y[e])||void 0===t?void 0:t.name)===(null===(i=a.submit)||void 0===i?void 0:i.fName)}):null,w=t.input.choice("Submit function",{value:null!=A?A:null,items:[null,...Object.keys(y)]});A||(w.value=null),w.nullable=!0,w.fireChanged(),w.setTooltip("Select function to be called upon submitting");const b=Me(),C=t.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),T=t.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),x=t.input.string("Name",{value:a?`${a.name} (copy)`:"",onValueChanged:e=>{""===e||h.includes(e)?(x.root.style.borderBottom="1px solid red",C.style.opacity="100%"):(x.root.style.borderBottom="none",C.style.opacity="0%")}}),N=t.input.string("Key",{value:a?`${a.key}-copy`:"",onValueChanged:e=>{""===e||v.includes(e)?(N.root.style.borderBottom="1px solid red",T.style.opacity="100%"):(N.root.style.borderBottom="none",T.style.opacity="0%")}});N.setTooltip("Template key used for campaign prefix"),x.setTooltip("Template name"),x.root.style.borderBottom="none",N.root.style.borderBottom="none",C.style.opacity="0%",T.style.opacity="0%";const I=t.input.string("Sequence Column",{value:null!==(s=null==a?void 0:a.sequenceColumnName)&&void 0!==s?s:"",nullable:!1});I.setTooltip("Name of the sequence column in the dataset (mandatory)");const F=t.divText("Sequence column name is required",{classes:"hit-triage-error-div"});F.style.opacity="0%",I.onChanged.subscribe(()=>{var e;(null===(e=I.value)||void 0===e?void 0:e.trim())?(I.root.style.borderBottom="none",F.style.opacity="0%"):(I.root.style.borderBottom="1px solid red",F.style.opacity="100%")});const P=t.input.string("Molecule Column",{value:null!==(r=null==a?void 0:a.moleculeColumnName)&&void 0!==r?r:"",nullable:!0});P.setTooltip("Name of the molecule column (optional). If empty, sequences will be auto-converted to molecules.");let _=null;const k=a||{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},V=yield Oe(i,e=>{_=e},()=>null,k,!1);V.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&Array.from(new Set(o.Func.find({meta:{role:j}}).concat(o.Func.find({tags:[j]})))).forEach(e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e});const L=Object.keys(n),O=t.input.choice(E,{value:L[0],items:L}),D=t.input.choice("Ingest using",{value:null!==(d=null==a?void 0:a.dataSourceType)&&void 0!==d?d:"Query",items:["Query","File"],onValueChanged:e=>{O.root.style.display="Query"===e?"block":"none"}});(null==a?void 0:a.dataSourceType)&&(O.root.style.display="Query"===a.dataSourceType?"block":"none");const $=Ue(null==a?void 0:a.campaignFields),M=t.div([t.h2("Details"),t.div([x,C]),t.div([N,T]),t.h2("Sequence Configuration"),t.div([I,F]),P.root,t.h2("Data Ingestion"),D.root,O.root,b.dataFileInput,$.fieldsDiv,t.h2("Compute"),V.root,t.h2("Submit"),w.root],"ui-form"),R=t.buttonsInput([]),U=null!==(p=null===(u=R.getElementsByClassName("ui-input-editor"))||void 0===u?void 0:u[0])&&void 0!==p?p:R;M.appendChild(R);const H=new Promise(e=>{const i=t.button(B,()=>e());U.appendChild(i)}),q=new Promise(i=>{const n=t.bigButton(S,()=>function(){return Mt(this,void 0,void 0,function*(){var t,n,o,a,s,r,d,u,p,h;if(V.okProxy(),"100%"===C.style.opacity)return void e.shell.error("Template name is empty or already exists");if("100%"===T.style.opacity)return void e.shell.error("Template key is empty or already exists");if(!(null===(t=I.value)||void 0===t?void 0:t.trim()))return void e.shell.error("Sequence column name is required");const v=w.value?y[w.value]:void 0,f=Object.assign(Object.assign({name:x.value,key:N.value,sequenceColumnName:I.value.trim(),moleculeColumnName:(null===(n=P.value)||void 0===n?void 0:n.trim())||void 0,campaignFields:$.getFields(),dataSourceType:null!==(o=D.value)&&void 0!==o?o:"Query",layoutViewState:null!==(a=b.getLayoutViewState())&&void 0!==a?a:void 0,compute:{descriptors:{enabled:!!(null===(s=null==_?void 0:_.descriptors)||void 0===s?void 0:s.length),args:null!==(r=null==_?void 0:_.descriptors)&&void 0!==r?r:[]},functions:Object.entries(null!==(d=null==_?void 0:_.externals)&&void 0!==d?d:{}).map(([e,t])=>{const i=e.split(":");return{name:i[1],package:i[0],args:t}}),scripts:Object.entries(null!==(u=null==_?void 0:_.scripts)&&void 0!==u?u:{}).filter(([e,t])=>e.startsWith(l)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}}),queries:Object.entries(null!==(p=null==_?void 0:_.queries)&&void 0!==p?p:{}).filter(([e,t])=>e.startsWith(c)&&3===e.split(":").length).map(([e,t])=>{var i,n;const o=e.split(":");return{name:null!==(i=o[1])&&void 0!==i?i:"",id:null!==(n=o[2])&&void 0!==n?n:"",args:t}})}},v?{submit:{fName:v.name,package:ne(v)}}:{}),{queryFunctionName:"Query"===D.value&&null!==(h=O.value)&&void 0!==h?h:void 0});mi.files.writeAsText(`${m}/${f.name}.json`,JSON.stringify(f)),e.shell.info("Template created successfully"),i(f)})}());U.appendChild(n)});return{root:M,template:q,cancelPromise:H}})}(this.app,this.getDataSourceFunctionsMap(),i),a=new o.ViewBase,s=e.shell.v;a.name="New Template",a.root.appendChild(n.root),a.parentCall=this.app.parentCall,e.shell.addView(a),a.path=new URL(this.app.baseUrl).pathname+"/new-template",a.parentView=s;const{sub:r}=le(e.shell.v,this.app.appName,T,()=>{e.shell.v=s,a.close()});n.template.then(t=>Rt(this,void 0,void 0,function*(){yield this.init(t),a.close(),ce(a),e.shell.v=s,r.unsubscribe()})),n.cancelPromise.then(()=>{r.unsubscribe(),a.close(),e.shell.v=s})})}}class Ut extends ut{constructor(e){super(e,"PepTriage",e=>new jt(e))}get seqColName(){return this._seqColName}prepareDataFrame(t){return i=this,n=void 0,s=function*(){var i;const n=t;if(!this.dataFrame)return;yield this.dataFrame.meta.detectSemanticTypes();const a=n.sequenceColumnName;let s=a?this.dataFrame.col(a):null;if(s||(s=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE)),!s)throw new Error(`Sequence column '${null!=a?a:"Macromolecule"}' not found in the dataset. Make sure the data contains a column with sequences.`);this._seqColName=s.name;const r=o.TaskBarProgressIndicator.create("Initializing sequences...");try{const t=yield async function(){const e=o.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await e[0].prepare().call()).getOutputParamValue()}(),a=t.getSeqHandler(s);yield a.refinerPromise,t.getSeqHandler(s);const l=n.moleculeColumnName;let c=l?this.dataFrame.col(l):null;if(c||(c=this.dataFrame.columns.bySemType(o.SEMTYPE.MOLECULE)),!c&&(r.update(50,"Converting sequences to molecules..."),yield e.functions.call("Bio:toAtomicLevel",{table:this.dataFrame,seqCol:s,nonlinear:!0}),yield this.dataFrame.meta.detectSemanticTypes(),c=null!==(i=this.dataFrame.columns.bySemTypeAll(o.SEMTYPE.MOLECULE).find(e=>e.name.toLowerCase().includes(s.name.toLowerCase())))&&void 0!==i?i:null,!c))return void e.shell.warning("Failed to convert sequences to molecules. Calculations may not work.");this.reorderColumns(s.name,c.name)}catch(t){mi.logger.error(t),e.shell.error("Error preparing sequence data: "+(t instanceof Error?t.message:t))}finally{r.close()}},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 i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(o,r)}l((s=s.apply(i,n||[])).next())});var i,n,a,s}reorderColumns(e,t){if(!this.dataFrame)return;const i=this.dataFrame.col(e),n=this.dataFrame.col(t);i&&(this.dataFrame.columns.remove(e),this.dataFrame.columns.insert(i,0)),n&&(this.dataFrame.columns.remove(t),this.dataFrame.columns.insert(n,1))}}var Ht=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};function qt(e){return Ht(this,void 0,void 0,function*(){yield vi.hitTriageAppTreeBrowser(e)})}function Yt(e){return Ht(this,void 0,void 0,function*(){yield vi.hitDesignAppTreeBrowser(e)})}function Gt(e){return Ht(this,void 0,void 0,function*(){yield vi.peptiHitAppTreeBrowser(e)})}function Wt(){return Ht(this,void 0,void 0,function*(){return yield vi.hitTriageApp()})}function zt(){return Ht(this,void 0,void 0,function*(){return yield vi.hitDesignApp()})}function Jt(){return Ht(this,void 0,void 0,function*(){return yield vi.peptiHitApp()})}function Qt(e){return Ht(this,void 0,void 0,function*(){yield vi.pepTriageAppTreeBrowser(e)})}function Kt(){return Ht(this,void 0,void 0,function*(){return yield vi.pepTriageApp()})}function Zt(){return Ht(this,void 0,void 0,function*(){return yield vi.demoFileIngest()})}function Xt(){return Ht(this,void 0,void 0,function*(){return yield vi.demoFileIngest1()})}function ei(e){return Ht(this,void 0,void 0,function*(){return yield vi.demoFileIngest2(e)})}function ti(e){return Ht(this,void 0,void 0,function*(){return yield vi.demoPeptideSequences(e)})}function ii(e,t){return Ht(this,void 0,void 0,function*(){yield vi.demoFileSubmit(e,t)})}function ni(){return Ht(this,void 0,void 0,function*(){yield vi.registerMoleculesToViD()})}function oi(e){return vi.hitDesignVidPanel(e)}function ai(){return vi.gasteigerCellRenderer()}function si(e){return Ht(this,void 0,void 0,function*(){return yield vi.htPackageSettingEditor(e)})}var ri=function(e,t,i,n){var o,a=arguments.length,s=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,n);else for(var r=e.length-1;r>=0;r--)(o=e[r])&&(s=(a<3?o(s):a>3?o(t,i,s):o(t,i))||s);return a>3&&s&&Object.defineProperty(t,i,s),s},li=function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},ci=function(e,t){return function(i,n){t(i,n,e)}},di=function(e,t,i,n){return new(i||(i=Promise))(function(o,a){function s(e){try{l(n.next(e))}catch(e){a(e)}}function r(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,r)}l((n=n.apply(e,t||[])).next())})};class pi extends o.Package{constructor(){super(...arguments),this.molToSmilesLruCache=new o.LruCache(2e3),this.campaignsCache={}}convertToSmiles(t){return t?this.molToSmilesLruCache.getOrCreate(t,t=>e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)):""}loadCampaigns(t,i){return di(this,void 0,void 0,function*(){return this.campaignsCache[t]||(this.campaignsCache[t]=yield function(t,i){return ae(this,void 0,void 0,function*(){const n=(yield mi.files.list(`${t}/campaigns`)).filter(e=>-1===i.indexOf(e.name)),o={},a=n.map(i=>ae(this,void 0,void 0,function*(){try{const n=JSON.parse(yield mi.files.readAsText(`${t}/campaigns/${i.name}/${h}`));if(n.authorUserId&&n.permissions&&!(yield me(n.authorUserId,n.permissions)))return null;if(n.authorUserId&&!n.authorUserFriendlyName){const t=yield e.dapi.users.find(n.authorUserId);t&&(n.authorUserFriendlyName=t.friendlyName)}o[n.name]=n}catch(e){console.error(e)}return null}));return yield Promise.all(a),o})}(t,null!=i?i:[])),this.campaignsCache[t]})}saveCampaignJson(e,t){return di(this,void 0,void 0,function*(){const i=`${e}/campaigns/${t.name}/${h}`;yield this.files.writeAsText(i,JSON.stringify(t)),this.campaignsCache[e][t.name]=t})}}const mi=new pi;function hi(i,n){return di(this,void 0,void 0,function*(){var a,s,r;const l=t.div([],{style:{width:"50px",height:"24px",position:"relative"}});l.innerHTML='<div class="grok-loader"><div></div><div></div><div></div><div></div></div>';const c=i.item(l),d=yield mi.loadCampaigns(n,[]);let u=null,p=!0;for(const[t,n]of Object.entries(d)){const t=null!==(a=n.templateName)&&void 0!==a?a:null===(s=n.template)||void 0===s?void 0:s.name,l=t?i.getOrCreateGroup(t,null,p):i;p=!1;const c=l.item(null!==(r=n.friendlyName)&&void 0!==r?r:n.name);c.root.addEventListener("dblclick",e=>{e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault()}),o.debounce(c.onSelected,200).subscribe(t=>di(this,void 0,void 0,function*(){var t;try{const i="ingest"in n?n.ingest.query:n.savePath;if(!i||!(yield e.dapi.files.exists(i)))return void e.shell.error("File not found: "+i);const a=yield e.dapi.files.readCsv(i);if(!a)return;a.name=null!==(t=n.friendlyName)&&void 0!==t?t:n.name;const s=n.columnSemTypes;if(s)for(const[m,h]of Object.entries(s)){const v=a.columns.byName(m);v&&(v.semType=h,h===o.SEMTYPE.MACROMOLECULE&&m===w&&(v.setTag("units","helm"),v.setTag(".alphabetIsMultichar","true"),v.setTag("cell.renderer","helm")))}const r=document.activeElement;let l=!1;function c(){setTimeout(()=>{!l&&r&&document.activeElement!==r&&r&&"focus"in r&&r.focus()})}window.addEventListener("focusout",c);try{u&&u.close()}catch(f){}try{u=e.shell.addTableView(a);const g=n.layout;g&&u.loadLayout(o.ViewLayout.fromViewState(g))}catch(y){console.error(y)}function d(){window.removeEventListener("focusout",c)}function p(){d(),l=!0}window.addEventListener("click",p,{once:!0}),setTimeout(()=>{d(),window.removeEventListener("click",p)},5e3)}catch(A){console.error(A)}}))}c.remove()})}class vi{static hitTriageAppTreeBrowser(e){return di(this,void 0,void 0,function*(){yield hi(e,"Hit Triage")})}static hitDesignAppTreeBrowser(e){return di(this,void 0,void 0,function*(){yield hi(e,"Hit Design")})}static peptiHitAppTreeBrowser(e){return di(this,void 0,void 0,function*(){yield hi(e,"PeptiHit")})}static hitTriageApp(){return di(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return new ut(t).multiView})}static hitDesignApp(){return di(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return new kt(t).multiView})}static peptiHitApp(){return di(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new $t(t).multiView})}static pepTriageAppTreeBrowser(e){return di(this,void 0,void 0,function*(){yield hi(e,"PepTriage")})}static pepTriageApp(){return di(this,void 0,void 0,function*(){const t=e.functions.getCurrentCall();return yield e.functions.call("Bio:initBio",{}),new Ut(t).multiView})}static demoFileIngest(){return di(this,void 0,void 0,function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t})}static demoFileIngest1(){return di(this,void 0,void 0,function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t})}static demoFileIngest2(t){return di(this,void 0,void 0,function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i})}static demoPeptideSequences(e){return di(this,void 0,void 0,function*(){const t=["PEPTIDE1{A.G.L.V.K}$$$$V2.0","PEPTIDE1{G.A.V.L.I.P}$$$$V2.0","PEPTIDE1{F.W.Y.H.K.R}$$$$V2.0","PEPTIDE1{D.E.N.Q.S.T}$$$$V2.0","PEPTIDE1{A.R.N.D.C.E}$$$$V2.0","PEPTIDE1{G.H.I.L.K.M}$$$$V2.0","PEPTIDE1{F.P.S.T.W.Y}$$$$V2.0","PEPTIDE1{V.A.G.L.I}$$$$V2.0","PEPTIDE1{K.R.H.D.E}$$$$V2.0","PEPTIDE1{N.Q.S.T.C.M}$$$$V2.0","PEPTIDE1{A.V.L.I.P.F}$$$$V2.0","PEPTIDE1{W.Y.G.A.R}$$$$V2.0","PEPTIDE1{K.H.D.E.N.Q}$$$$V2.0","PEPTIDE1{S.T.C.M.F.W}$$$$V2.0","PEPTIDE1{Y.A.G.V.L.I}$$$$V2.0","PEPTIDE1{P.K.R.H.D}$$$$V2.0","PEPTIDE1{E.N.Q.S.T.C}$$$$V2.0","PEPTIDE1{M.F.W.Y.A.G}$$$$V2.0","PEPTIDE1{V.L.I.P.K.R}$$$$V2.0","PEPTIDE1{H.D.E.N.Q.S}$$$$V2.0"],i=[];for(let n=0;n<e;n++)i.push(t[n%t.length]);const n=o.Column.fromStrings("Helm",i);n.semType=o.SEMTYPE.MACROMOLECULE,n.setTag("units","helm"),n.setTag(".alphabetIsMultichar","true");const a=o.DataFrame.fromColumns([n]);return a.name="Demo Peptide Sequences",a})}static demoFileSubmit(t,i){return di(this,void 0,void 0,function*(){e.shell.info(t.rowCount),e.shell.info(i)})}static registerMoleculesToViD(){return di(this,void 0,void 0,function*(){!function(){Nt(this,void 0,void 0,function*(){var i;const n="Hit Design",a=yield mi.loadCampaigns(n),s=Object.keys(a),r=t.input.choice("Select Campaign",{value:null,nullable:!0,items:s,tooltipText:"Select campaign to register its molecules. Leave empty to register all campaigns"}),l=yield new Promise(e=>Nt(this,void 0,void 0,function*(){t.dialog("Register Existing Campaign Molecules").add(t.divText("This operation will go through all molecules in the selected campaign(s) and register them into V-iD storage.\n This operation is irreversible.")).add(t.divText("You can select a specific campaign or leave it empty to process all campaigns.")).add(t.divText("After this opteration, all VIDs throughout all campaigns will become unique, and old V-iDs will no longer be valid.")).add(t.divText("WARNING: Depending on the number of molecules, this operation can take a long time.")).add(r).onOK(()=>{if(r.value){const t=a[r.value];e([t])}else{const t=s.map(e=>a[e]);e(t)}}).onCancel(()=>e(null)).show()})),c=o.TaskBarProgressIndicator.create("Registering molecules...");if(!l||0===l.length)return void c.close();const d=l.length;for(const t of l){c.update(0/d*100,`Processing campaign: ${t.name}`);try{const o=`System.AppData/HitTriage/${n}/campaigns`,a=null!==(i=null==t?void 0:t.savePath)&&void 0!==i?i:`${o}/${t.name}/${m}`,s=yield e.dapi.files.readCsv(a);if(!s){e.shell.warning(`Failed to load campaign table for campaign ${t.name} at path ${a}`),console.warn(`Failed to load campaign table for campaign ${t.name} at path ${a}`);continue}const r=s.col(A);if(!r){e.shell.warning(`Molecule column not found in campaign ${t.name} table`),console.warn(`Molecule column not found in campaign ${t.name} table`);continue}const l=s.col(b);if(!l){e.shell.warning(`V-iD column not found in campaign ${t.name} table`),console.warn(`V-iD column not found in campaign ${t.name} table`);continue}const c=r.toList(),d=yield Pt(c,t.name,n);for(let e=0;e<s.rowCount;e++){const t=c[e];if(!t||""===t){l.set(e,"",!1);continue}const i=d.get(t);i&&l.set(e,i,!1)}l.fireValuesChanged(),yield e.dapi.files.writeAsText(a,s.toCsv()),e.shell.info(`Finished processing campaign ${t.name}`),console.log(`Finished processing campaign ${t.name}`)}catch(i){e.shell.error(`Error processing campaign ${t.name}. See console for details.`),console.error(`Error processing campaign ${t.name} molecules registration:`,i)}}c.close()})}()})}static hitDesignVidPanel(i){return o.Widget.fromRoot(t.card(t.wait(()=>di(this,void 0,void 0,function*(){if(!(null==i?void 0:i.value))return t.divText("No V-iD provided");const n=yield et.getCampaignsByVid(i.value,null);if(!n||0===n.rowCount)return t.divText(`No campaigns found for V-iD: ${i.value}`);const o=yield et.getMoleculeByVid(i.value);if(!o||0===o.rowCount)return t.divText(`No molecule found for V-iD: ${i.value}`);const a=function(e){var t;const i=null===(t=mi.meta)||void 0===t?void 0:t.sok;if(!i)throw new Error("Secret key for SMILES deobfuscation is not set");const n=atob(e);let o="";for(let e=0;e<n.length;e++){const t=n.charCodeAt(e),a=i.charCodeAt(e%i.length);o+=String.fromCharCode(t^a)}return o}(o.col("mh_string").get(0)),s=e.chem.drawMolecule(a,300,300),r=new Map;for(let e=0;e<n.rowCount;e++){const t=n.col("app_name").get(e),i=n.col("campaign_id").get(e),o=n.col("created_by").get(e);r.has(t)||r.set(t,[]),r.get(t).push({campaignId:i,createdBy:o})}const l=t.divV([s],{style:{gap:"10px",justifyContent:"center"}});for(const[e,i]of r.entries()){const n=t.table(i.map(e=>[e.campaignId,e.createdBy]),e=>[e[0],e[1]],["Campaigns","Created By"]),o=t.divV([t.h3(`${e} Campaigns`),n],{style:{gap:"4px"}});l.appendChild(o)}return l}))))}static gasteigerCellRenderer(){return new Vt}static htPackageSettingEditor(i){return di(this,void 0,void 0,function*(){return function(i){return Et(this,void 0,void 0,function*(){var n;const a=i.filter(e=>"DefaultUserGroupsSharing"===e.category),s=[];for(const i of a){const n=`${i.name[0].toUpperCase()}${i.name.slice(1)}`,a=i.get(null),r=yield St(a),l=t.input.userGroups(n);yield o.delay(200),l.value=r,l.onInput.subscribe(()=>{var t;try{const e=(null===(t=l.value)||void 0===t?void 0:t.length)?JSON.stringify(l.value.map(e=>e.id)):"";i.set(null,e)}catch(t){e.shell.error("Error Setting group. Check console for more details"),console.error(t)}}),l.setTooltip(`Selected groups will be granted ${n.toLowerCase()} permissions by default on newly created campaigns`),s.push(l)}const r=o.Widget.fromRoot(t.form(s,{style:{overflow:"visible"}}));r.root.prepend(t.h1("Default Campaign Sharing",{style:{marginBottom:"6px",marginTop:"6px"}}));const l=i.find(e=>e.name===Tt);if(l){const i='Default storage for newly created campaigns. For each app, folders will be created under their name. For example, for Hit Design, the campaign files will be saved under <b>"Your folder/Hit Design/campaigns/enriched_table.csv"</b>';let a=i;const s=null!==(n=l.get(null))&&void 0!==n?n:xt,c=t.h1("Default Campaign Storage",{style:{marginBottom:"6px",marginTop:"6px"}}),d=t.input.string("Folder Path",{value:s});t.tooltip.bind(d.input,()=>a),o.debounce(d.onChanged,200).subscribe(t=>Et(this,void 0,void 0,function*(){const t=d.value;try{if(!t)return l.set(null,xt),a=i+'<br><br> <b style="color: red">Cannot be empty.</b>',void d.input.classList.add("d4-invalid");if(!(yield e.dapi.files.exists(t)))return l.set(null,xt),a=i+'<br><br> <b style="color: red">Folder does not exist.</b>',void d.input.classList.add("d4-invalid");l.set(null,t),a=i,d.input.classList.remove("d4-invalid")}catch(t){e.shell.error("Error Setting default storage. Check console for more details"),console.error(t)}})),r.root.appendChild(c),r.root.appendChild(d.root)}return setTimeout(()=>{var e;return(null===(e=r.root.parentElement)||void 0===e?void 0:e.style)&&(r.root.parentElement.style.overflow="visible")},200),r})}(i)})}}ri([e.decorators.treeBrowser({meta:{app:"Hit Triage"}}),li("design:type",Function),li("design:paramtypes",[o.TreeViewGroup]),li("design:returntype",Promise)],vi,"hitTriageAppTreeBrowser",null),ri([e.decorators.treeBrowser({meta:{app:"Hit Design"}}),li("design:type",Function),li("design:paramtypes",[o.TreeViewGroup]),li("design:returntype",Promise)],vi,"hitDesignAppTreeBrowser",null),ri([e.decorators.treeBrowser({meta:{app:"PeptiHit"}}),li("design:type",Function),li("design:paramtypes",[o.TreeViewGroup]),li("design:returntype",Promise)],vi,"peptiHitAppTreeBrowser",null),ri([e.decorators.app({browsePath:"Chem",name:"Hit Triage",tags:["app"]}),li("design:type",Function),li("design:paramtypes",[]),li("design:returntype",Promise)],vi,"hitTriageApp",null),ri([e.decorators.app({icon:"images/icons/hit-design-icon.png",browsePath:"Chem",name:"Hit Design",tags:["app"]}),li("design:type",Function),li("design:paramtypes",[]),li("design:returntype",Promise)],vi,"hitDesignApp",null),ri([e.decorators.app({icon:"images/icons/pepti-hit-icon.png",browsePath:"Peptides",name:"PeptiHit",tags:["app"]}),li("design:type",Function),li("design:paramtypes",[]),li("design:returntype",Promise)],vi,"peptiHitApp",null),ri([e.decorators.treeBrowser({meta:{app:"PepTriage"}}),li("design:type",Function),li("design:paramtypes",[o.TreeViewGroup]),li("design:returntype",Promise)],vi,"pepTriageAppTreeBrowser",null),ri([e.decorators.app({icon:"images/icons/hit-triage-icon.png",browsePath:"Peptides",name:"PepTriage",tags:["app"]}),li("design:type",Function),li("design:paramtypes",[]),li("design:returntype",Promise)],vi,"pepTriageApp",null),ri([e.decorators.func({name:"Demo Molecules 100",meta:{role:"hitTriageDataSource"}}),li("design:type",Function),li("design:paramtypes",[]),li("design:returntype",Promise)],vi,"demoFileIngest",null),ri([e.decorators.func({name:"Demo Molecules 5000",meta:{role:"hitTriageDataSource"}}),li("design:type",Function),li("design:paramtypes",[]),li("design:returntype",Promise)],vi,"demoFileIngest1",null),ri([e.decorators.func({name:"Demo Molecules variable",meta:{role:"hitTriageDataSource"}}),ci(0,e.decorators.param({type:"int",options:{description:"Molecules counts"}})),li("design:type",Function),li("design:paramtypes",[Number]),li("design:returntype",Promise)],vi,"demoFileIngest2",null),ri([e.decorators.func({name:"Demo Peptide Sequences",meta:{role:"pepTriageDataSource"}}),li("design:type",Function),li("design:paramtypes",[Number]),li("design:returntype",Promise)],vi,"demoPeptideSequences",null),ri([e.decorators.func({name:"Demo File Submit",meta:{role:"hitTriageSubmitFunction"}}),ci(0,e.decorators.param({options:{description:"Dataframe"}})),ci(1,e.decorators.param({options:{description:"Molecules column name"}})),li("design:type",Function),li("design:paramtypes",[o.DataFrame,String]),li("design:returntype",Promise)],vi,"demoFileSubmit",null),ri([e.decorators.func({}),li("design:type",Function),li("design:paramtypes",[]),li("design:returntype",Promise)],vi,"registerMoleculesToViD",null),ri([e.decorators.panel({name:"Hit Design V-iD"}),ci(0,e.decorators.param({type:"semantic_value",options:{semType:"HIT_DESIGN_VID"}})),li("design:type",Function),li("design:paramtypes",[o.SemanticValue]),li("design:returntype",o.Widget)],vi,"hitDesignVidPanel",null),ri([e.decorators.func({meta:{cellType:"customGasteigerPNG",columnTags:"quality=customGasteigerPNG",role:"cellRenderer"},name:"gasteigerRenderer",outputs:[{type:"grid_cell_renderer",name:"result"}]}),li("design:type",Function),li("design:paramtypes",[]),li("design:returntype",Vt)],vi,"gasteigerCellRenderer",null),ri([e.decorators.func({name:"Hit Triage package settings editor",meta:{role:"packageSettingsEditor"},tags:["packageSettingsEditor"]}),ci(0,e.decorators.param({name:"propList",type:"object"})),li("design:type",Function),li("design:paramtypes",[Array]),li("design:returntype",Promise)],vi,"htPackageSettingEditor",null)})(),hittriage=n})();
2
2
  //# sourceMappingURL=package.js.map