@datagrok/hit-triage 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # HitTriage changelog
2
2
 
3
+ ## 1.2.2 (2024-08-26)
4
+
5
+ * Fix progress tracker layout loading
6
+
3
7
  ## 1.2.1 (2024-08-23)
4
8
 
5
9
  * Fix issues related to progress tracker
package/dist/package.js CHANGED
@@ -1,2 +1,2 @@
1
- var hittriage;(()=>{var e={233:e=>{!function(){"use strict";var t=document,i=window,n=t.documentElement,o=t.createElement.bind(t),s=o("div"),a=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,h=u.indexOf,m=u.map,v=u.push,f=u.slice,g=u.some,y=u.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 x=function(){function e(e,n){if(e){if(S(e))return e;var o=e;if(O(e)){var s=n||t;if(!(o=w.test(e)&&F(s)?s.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?Z(e):S(s)?s.find(e):O(s)?E(s).find(e):T(e,s)))return}else if(P(e))return this.ready(e);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var a=0,r=this.length;a<r;a++)this[a]=o[a]}}return e.prototype.init=function(t,i){return new e(t,i)},e}(),I=x.prototype,E=I.init;function S(e){return e instanceof x}function N(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 O(e){return"string"==typeof e}function B(e){return void 0===e}function V(e){return null===e}function k(e){return!isNaN(parseFloat(e))&&isFinite(e)}function L(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function j(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(L(e))for(var o=Object.keys(e),s=(n=0,o.length);n<s;n++){var a=o[n];if(!1===t.call(e[a],a,e[a]))return e}else for(n=0,s=e.length;n<s;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,E,n);for(var s=0;s<o;s++){var a=e[s];for(var r in a)i&&(c(a[r])||L(a[r]))?(n[r]&&n[r].constructor===a[r].constructor||(n[r]=new a[r].constructor),D(i,n[r],a[r])):n[r]=a[r]}return n}E.fn=E.prototype=I,I.length=0,I.splice=y,"function"==typeof Symbol&&(I[Symbol.iterator]=u[Symbol.iterator]),E.isWindow=N,E.isFunction=P,E.isArray=c,E.isNumeric=k,E.isPlainObject=L,E.each=j,I.each=function(e){return j(this,e)},I.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},E.extend=D,I.extend=function(e){return D(I,e)};var U=/\S+/g;function R(e){return O(e)&&e.match(U)||[]}function $(e,t,n){if(_(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function M(e,t){return parseInt($(e,t),10)||0}function H(e,t){return M(e,"border".concat(t?"Left":"Top","Width"))+M(e,"padding".concat(t?"Left":"Top"))+M(e,"padding".concat(t?"Right":"Bottom"))+M(e,"border".concat(t?"Right":"Bottom","Width"))}I.toggleClass=function(e,t){var i=R(e),n=!B(t);return this.each((function(e,o){_(o)&&j(i,(function(e,i){n?t?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},I.addClass=function(e){return this.toggleClass(e,!0)},I.removeAttr=function(e){var t=R(e);return this.each((function(e,i){_(i)&&j(t,(function(e,t){i.removeAttribute(t)}))}))},I.attr=function(e,t){if(e){if(O(e)){if(arguments.length<2){if(!this[0]||!_(this[0]))return;var i=this[0].getAttribute(e);return V(i)?void 0:i}return B(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}},I.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},I.hasClass=function(e){return!!e&&g.call(this,(function(t){return _(t)&&t.classList.contains(e)}))},I.get=function(e){return B(e)?f.call(this):this[(e=Number(e))<0?e+this.length:e]},I.eq=function(e){return E(this.get(e))},I.first=function(){return this.eq(0)},I.last=function(){return this.eq(-1)},I.text=function(e){return B(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 Y(e){return"none"===$(e,"display")}function W(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function G(e){return O(e)?function(t,i){return W(i,e)}:P(e)?e:S(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}I.filter=function(e){var t=G(e);return E(p.call(this,(function(e,i){return t.call(e,i,e)})))},I.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={"*":s,tr:r,td:l,th:l,thead:a,tbody:a,tfoot:a};function Z(e){if(!O(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,E(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],s=P(t),a=n&&G(n),r=0,l=e.length;r<l;r++)if(s){var c=t(e[r]);c.length&&v.apply(o,c)}else for(var u=e[r][t];!(null==u||n&&a(-1,u));)o.push(u),u=i?u[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 h.call(i,e)===t})):e}E.parseHTML=Z,I.has=function(e){var t=O(e)?function(t,i){return T(e,i).length}:function(t,i){return i.contains(e)};return this.filter(t)},I.not=function(e){var t=G(e);return this.filter((function(i,n){return(!O(e)||_(n))&&!t.call(n,i,n)}))},I.val=function(e){return arguments.length?this.each((function(t,i){var n=i.multiple&&i.options;if(n||Oe.test(i.type)){var o=c(e)?m.call(e,String):V(e)?[]:[String(e)];n?j(i.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=B(e)||V(e)?"":e})):this[0]&&ee(this[0])},I.is=function(e){var t=G(e);return g.call(this,(function(e,i){return t.call(e,i,e)}))},E.guid=1,E.unique=te,I.add=function(e,t){return E(te(this.get().concat(E(e,t).get())))},I.children=function(e){return J(E(te(X(this,(function(e){return e.children})))),e)},I.parent=function(e){return J(E(te(X(this,"parentNode"))),e)},I.index=function(e){var t=e?E(e)[0]:this[0],i=e?this:E(t).parent().children();return h.call(i,t)},I.closest=function(e){var t=this.filter(e);if(t.length)return t;var i=this.parent();return i.length?i.closest(e):t},I.siblings=function(e){return J(E(te(X(this,(function(e){return E(e).parent().children().not(e)})))),e)},I.find=function(e){return E(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 se(e,t,i,s,a,r,l,c){return j(e,(function(e,r){j(E(r),(function(e,r){j(E(t),(function(t,l){var c=i?l:r,u=i?e:t;!function(e,t,i,s,a){s?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),a&&function(e,t){var i=E(e);i.filter("script").add(i.find("script")).each((function(e,i){if(ne.test(i.type)&&n.contains(i)){var s=o("script");s.text=i.textContent.replace(ie,""),j(oe,(function(e,t){i[t]&&(s[t]=i[t])})),t.head.insertBefore(s,null),t.head.removeChild(s)}}))}(t,e.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,s,a,!u)}),c)}),l)}),r),t}I.after=function(){return se(arguments,this,!1,!1,!1,!0,!0)},I.append=function(){return se(arguments,this,!1,!1,!0)},I.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(B(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(i,n){_(n)&&(t?E(n).empty().append(e):n.innerHTML=e)}))},I.appendTo=function(e){return se(arguments,this,!0,!1,!0)},I.wrapInner=function(e){return this.each((function(t,i){var n=E(i),o=n.contents();o.length?o.wrapAll(e):n.append(e)}))},I.before=function(){return se(arguments,this,!1,!0)},I.wrapAll=function(e){for(var t=E(e),i=t[0];i.children.length;)i=i.firstElementChild;return this.first().before(t),this.appendTo(i)},I.wrap=function(e){return this.each((function(t,i){var n=E(e)[0];E(i).wrapAll(t?n.cloneNode(!0):n)}))},I.insertAfter=function(e){return se(arguments,this,!0,!1,!1,!1,!1,!0)},I.insertBefore=function(e){return se(arguments,this,!0,!0)},I.prepend=function(){return se(arguments,this,!1,!0,!0,!0,!0)},I.prependTo=function(e){return se(arguments,this,!0,!0,!0,!1,!1,!0)},I.contents=function(){return E(te(X(this,(function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes}))))},I.next=function(e,t,i){return J(E(te(X(this,"nextElementSibling",t,i))),e)},I.nextAll=function(e){return this.next(e,!0)},I.nextUntil=function(e,t){return this.next(t,!0,e)},I.parents=function(e,t){return J(E(te(X(this,"parentElement",!0,t))),e)},I.parentsUntil=function(e,t){return this.parents(t,e)},I.prev=function(e,t,i){return J(E(te(X(this,"previousElementSibling",t,i))),e)},I.prevAll=function(e){return this.prev(e,!0)},I.prevUntil=function(e,t){return this.prev(t,!0,e)},I.map=function(e){return E(d.apply([],m.call(this,(function(t,i){return e.call(t,i,t)}))))},I.clone=function(){return this.map((function(e,t){return t.cloneNode(!0)}))},I.offsetParent=function(){return this.map((function(e,t){for(var i=t.offsetParent;i&&"static"===$(i,"position");)i=i.offsetParent;return i||n}))},I.slice=function(e,t){return E(f.call(this,e,t))};var ae=/-([a-z])/g;function re(e){return e.replace(ae,(function(e,t){return t.toUpperCase()}))}I.ready=function(e){var i=function(){return setTimeout(e,0,E)};return"loading"!==t.readyState?i():t.addEventListener("DOMContentLoaded",i),this},I.unwrap=function(){return this.parent().each((function(e,t){if("BODY"!==t.tagName){var i=E(t);i.replaceWith(i.children())}})),this},I.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}}},I.position=function(){var e=this[0];if(e){var t="fixed"===$(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"===$(o,"position");)o=o.parentNode;if(o!==e&&_(o)){var s=E(o).offset();i.top-=s.top+M(o,"borderTopWidth"),i.left-=s.left+M(o,"borderLeftWidth")}}return{top:i.top-M(e,"marginTop"),left:i.left-M(e,"marginLeft")}}};var le={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};I.prop=function(e,t){if(e){if(O(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}},I.removeProp=function(e){return this.each((function(t,i){delete i[le[e]||e]}))};var ce=/^--/;function ue(e){return ce.test(e)}var de={},pe=s.style,he=["webkit","moz","ms"],me={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=ue(e)),i||me[e]||!k(t)?t:"".concat(t,"px")}function fe(e,t){try{return e(t)}catch(e){return t}}I.css=function(e,t){if(O(e)){var i=ue(e);return e=function(e,t){if(void 0===t&&(t=ue(e)),t)return e;if(!de[e]){var i=re(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));j("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in pe)return de[e]=i,!1}))}return de[e]}(e,i),arguments.length<2?this[0]&&$(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[re(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)])}I.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(O(e))return arguments.length<2?this[0]&&ye(this[0],e):B(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},j([!0,!1],(function(e,t){j(["Width","Height"],(function(e,i){var n="".concat(t?"outer":"inner").concat(i);I[n]=function(n){if(this[0])return N(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?M(this[0],"margin".concat(e?"Top":"Left"))+M(this[0],"margin".concat(e?"Bottom":"Right")):0)}}))})),j(["Width","Height"],(function(e,t){var i=t.toLowerCase();I[i]=function(n){if(!this[0])return B(n)?void 0:this;if(!arguments.length)return N(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 s=$(n,"boxSizing");n.style[i]=ve(i,o+("border-box"===s?H(n,!e):0))}}))}}));var be="___cd";I.toggle=function(e){return this.each((function(i,n){if(_(n)){var s=Y(n);(B(e)?s:e)?(n.style.display=n[be]||"",Y(n)&&(n.style.display=function(e){if(q[e])return q[e];var i=o(e);t.body.insertBefore(i,null);var n=$(i,"display");return t.body.removeChild(i),q[e]="none"!==n?n:"block"}(n.tagName))):s||(n[be]=$(n,"display"),n.style.display="none")}}))},I.hide=function(){return this.toggle(!1)},I.show=function(){return this.toggle(!0)};var Ce="___ce",Ae={focus:"focusin",blur:"focusout"},Te={mouseenter:"mouseover",mouseleave:"mouseout"},xe=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Ie(e){return Te[e]||Ae[e]||e}function Ee(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Se(e){return e[Ce]=e[Ce]||{}}function Ne(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function Fe(e,t,i,n,o){var s=Se(e);if(t)s[t]&&(s[t]=s[t].filter((function(s){var a=s[0],r=s[1],l=s[2];if(o&&l.guid!==o.guid||!Ne(a,i)||n&&n!==r)return!0;e.removeEventListener(t,l)})));else for(t in s)Fe(e,t,i,n,o)}I.trigger=function(e,i){if(O(e)){var n=Ee(e),o=n[0],s=n[1],a=Ie(o);if(!a)return this;var r=xe.test(a)?"MouseEvents":"HTMLEvents";(e=t.createEvent(r)).initEvent(a,!0,!0),e.namespace=s.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)}))},I.off=function(e,t,i){var n=this;if(B(e))this.each((function(e,t){(_(t)||F(t)||N(t))&&Fe(t)}));else if(O(e))P(t)&&(i=t,t=""),j(R(e),(function(e,o){var s=Ee(o),a=s[0],r=s[1],l=Ie(a);n.each((function(e,n){(_(n)||F(n)||N(n))&&Fe(n,l,r,t,i)}))}));else for(var o in e)this.off(o,e[o]);return this},I.remove=function(e){return J(this,e).detach().off(),this},I.replaceWith=function(e){return this.before(e).remove()},I.replaceAll=function(e){return E(e).replaceWith(this),this},I.on=function(e,t,i,n,o){var s=this;if(!O(e)){for(var a in e)this.on(a,t,i,e[a],o);return this}return O(t)||(B(t)||V(t)?t="":B(i)?(i=t,t=""):(n=i,i=t,t="")),P(n)||(n=i,i=void 0),n?(j(R(e),(function(e,a){var r=Ee(a),l=r[0],c=r[1],u=Ie(l),d=l in Te,p=l in Ae;u&&s.each((function(e,s){if(_(s)||F(s)||N(s)){var a=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Ne(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==s||e.___ot===u)||d&&e.relatedTarget&&s.contains(e.relatedTarget)))){var r=s;if(t){for(var l=e.target;!W(l,t);){if(l===s)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 s}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var h=n.call(r,e,e.___td);o&&Fe(s,u,c,t,a),!1===h&&(e.preventDefault(),e.stopPropagation())}};a.guid=n.guid=n.guid||E.guid++,function(e,t,i,n,o){var s=Se(e);s[t]=s[t]||[],s[t].push([i,n,o]),e.addEventListener(t,o)}(s,u,c,t,a)}}))})),this):this},I.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,Oe=/radio|checkbox/i;I.serialize=function(){var e="";return this.each((function(t,i){j(i.elements||[i],(function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Pe.test(i.type)||Oe.test(i.type)&&!i.checked)){var n=ee(i);B(n)||j(c(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=E}()},558:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.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}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}","",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,oBAAoB;AACxB;;AAEA;IACI,YAAY;IACZ,kCAAkC;IAClC,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,yBAAyB;IACzB,2BAA2B;AAC/B;;AAEA;IACI,oCAAoC;IACpC,yBAAyB;AAC7B;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,YAAY;IACZ,wBAAwB;AAC5B;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,iBAAiB;IACjB,2BAA2B;IAC3B,kBAAkB;AACtB;;;AAGA;IACI,sBAAsB;AAC1B;;AAEA;IACI,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;AACpB;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;CACC,gBAAgB;IACb,mBAAmB;IACnB,uBAAuB;CAC1B,iBAAiB;IACd,UAAU;AACd;;AAEA;CACC,cAAc;CACd,eAAe;CACf,iBAAiB;AAClB;;AAEA;CACC,mBAAmB;IAChB,gBAAgB;IAChB,uBAAuB;AAC3B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}"],sourceRoot:""}]);const r=a},677:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.push([e.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}"],sourceRoot:""}]);const r=a},542:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.push([e.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}"],sourceRoot:""}]);const r=a},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,s){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(n)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(a[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);n&&a[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},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),s="/*# ".concat(o," */");return[t].concat([s]).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 s={},a=[],r=0;r<e.length;r++){var l=e[r],c=n.base?l[0]+n.base:l[0],u=s[c]||0,d="".concat(c," ").concat(u);s[c]=u+1;var p=i(d),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(h);else{var m=o(h,n);n.byIndex=r,t.splice(r,0,{identifier:d,updater:m,references:1})}a.push(d)}return a}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 s=n(e=e||[],o=o||{});return function(e){e=e||[];for(var a=0;a<s.length;a++){var r=i(s[a]);t[r].references--}for(var l=n(e,o),c=0;c<s.length;c++){var u=i(s[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}s=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 s=i.sourceMap;s&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),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 s=t[n]={id:n,exports:{}};return e[n](s,s.exports,i),s.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,{_package:()=>He,demoFileIngest:()=>ze,demoFileIngest1:()=>Ke,demoFileIngest2:()=>Qe,demoFileSubmit:()=>Ze,gasteigerCellRenderer:()=>Xe,hitDesignApp:()=>Je,hitDesignAppTreeBrowser:()=>We,hitTriageApp:()=>Ye,hitTriageAppTreeBrowser:()=>qe});const e=grok,t=DG,o=ui,s="campaignId",a="campaignId",r="enriched_table.csv",l="campaign.json",c="HitTriageDataSource",u="HitTriageSubmitFunction",d="Selected hits",p="Stage",h="Molecule",m="V-iD",v="V######",f="HTScript",g="HTQuery",y="molecules",w="Source",b="New template",C="Start",A="Create",T="Download",x="Cancel",I="Continue a campaign",E="New campaign",S={script:"script",function:"function-package",query:"data-query"};var N=i(72),F=i.n(N),_=i(825),P=i.n(_),O=i(659),B=i.n(O),V=i(56),k=i.n(V),L=i(540),j=i.n(L),D=i(113),U=i.n(D),R=i(558),$={};$.styleTagTransform=U(),$.setAttributes=k(),$.insert=B().bind(null,"head"),$.domAPI=P(),$.insertStyleElement=j(),F()(R.A,$),R.A&&R.A.locals&&R.A.locals;var M=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};const H=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function q(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 Y(t,i,n,s){var a;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),W(t),s())})),c=null===(a=e.shell.v.ribbonMenu.root.parentElement)||void 0===a?void 0:a.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function W(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function G(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 J(e,i,n){return M(this,void 0,void 0,(function*(){if(0===n.rowCount)return;if(!e.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(y);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(t.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const s=n.columns.names().filter((e=>e!==y));e.join(n,[i],[o.name],void 0,s,void 0,!0)}))}function z(e,t){return M(this,void 0,void 0,(function*(){const i=(yield He.files.list(`${e}/campaigns`)).filter((e=>-1===t.indexOf(e.name))),n={};for(const t of i)try{const i=JSON.parse(yield He.files.readAsText(`${e}/campaigns/${t.name}/${l}`));if(i.authorUserId&&i.permissions&&!(yield Z(i.authorUserId,i.permissions)))continue;n[i.name]=i}catch(e){continue}return n}))}function K(i,n){return M(this,void 0,void 0,(function*(){var o;const s=t.User.current().id,a=null===(o=t.User.current().group)||void 0===o?void 0:o.id;if(i===s)return!0;const r=e.dapi.groups;for(const e of n){const t=yield r.find(e);if(t)if(t.personal){const e=yield r.getUser(t);if((null==e?void 0:e.id)===s)return!0}else if(a&&t.members.length>0&&t.members.some((e=>e.id===a)))return!0}return!1}))}function Q(e,t){return M(this,void 0,void 0,(function*(){return K(e,t.edit)}))}function Z(e,t){return M(this,void 0,void 0,(function*(){return K(e,Array.from(new Set([...t.view,...t.edit])))}))}const X={String:t.TYPE.STRING,Number:t.TYPE.FLOAT,Boolean:t.TYPE.BOOL,Date:t.TYPE.DATE_TIME,Molecule:t.SEMTYPE.MOLECULE};var ee=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))},te=i(233),ie=i.n(te),ne=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function oe(t,i,n,s,a){return ne(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,y,w,b,C,A,T,x,I,E,N,F,_;const P=yield t.computeFunctions,O=[];P.functions.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.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:{}})})),P.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.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:{}})})),P.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.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:{}})}));let B=!!(null===(l=null===(r=null==s?void 0:s.compute)||void 0===r?void 0:r.descriptors)||void 0===l?void 0:l.enabled)||a;const V=o.div([],{classes:"hit-triage-compute-dialog-host"}),k=[],L=o.tree();try{const q=yield e.chem.descriptorsTree();function Y(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}L.root.classList.add("hit-triage-compute-dialog-descriptors-group");const W=Object.keys(q),G=null!==(d=null===(u=null===(c=null==s?void 0:s.compute)||void 0===c?void 0:c.descriptors)||void 0===u?void 0:u.args)&&void 0!==d?d:[];for(const J of W){const z=Y(J,L);for(const K of q[J].descriptors){const Q=z.item(K.name,K);k.push(Q),Q.enableCheckBox(G.includes(K.name))}}}catch(Z){console.error(Z),B=!1}const j="Descriptors",D={[j]:j},U=B?{[j]:L.root}:{},R={},$={[j]:!1};$[j]=!!(null===(h=null===(p=null==s?void 0:s.compute)||void 0===p?void 0:p.descriptors)||void 0===h?void 0:h.enabled)&&(null===(y=null===(v=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===v?void 0:v.args)||void 0===y?void 0:y.length)>0;for(const X of O)try{const ee=X.func,te=ee.prepare(X.args),ne=ee.type===S.function?`${ee.package.name}:${ee.name}`:ee.type===S.script?`${f}:${null!==(w=ee.name)&&void 0!==w?w:""}:${ee.id}`:`${g}:${null!==(b=ee.name)&&void 0!==b?b:""}:${ee.id}`;R[ne]=te;const oe=o.div(),se=yield te.buildEditor(oe,{condensed:!1});oe.classList.add("oy-scroll"),oe.style.marginLeft="15px",oe.style.removeProperty("max-width"),U[null!==(C=ee.friendlyName)&&void 0!==C?C:ee.name]=oe,D[null!==(A=ee.friendlyName)&&void 0!==A?A:ee.name]=ne,$[ne]=null!==(_=(null===(x=null===(T=null==s?void 0:s.compute)||void 0===T?void 0:T.functions)||void 0===x?void 0:x.some((e=>{var t;return X.func.type===S.function&&e.name===X.func.name&&e.package===(null===(t=X.func.package)||void 0===t?void 0:t.name)})))||(null===(E=null===(I=null==s?void 0:s.compute)||void 0===I?void 0:I.scripts)||void 0===E?void 0:E.some((e=>e.id===ee.id)))||(null===(F=null===(N=null==s?void 0:s.compute)||void 0===N?void 0:N.queries)||void 0===F?void 0:F.some((e=>e.id===ee.id))))&&void 0!==_&&_,oe.children[0].style.display="none",ee.type!==S.query&&(oe.children[1].style.display="none"),se.forEach((e=>{var t,i;(null===(t=e.property)||void 0===t?void 0:t.name)&&Object.keys(X.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=X.args[e.property.name]),e.fireChanged()}))}catch(ae){console.error(ae);continue}const M=o.tabControl(U,!0);function H(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=$[j]?k.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(R).filter((([e,t])=>$[e]));t.filter((([e,t])=>!e.startsWith(f)&&!e.startsWith(g))).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(f))).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(g))).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 M.onTabChanged.subscribe((()=>{try{M.currentPane.content.style.removeProperty("max-width")}catch(e){}})),M.header.style.overflow="scroll",M.root.style.width="100%",M.root.style.minWidth="350px",V.appendChild(M.root),M.panes.forEach((e=>{const t=o.input.bool("",{value:$[D[e.name]],onValueChanged:i=>{$[D[e.name]]=!!t.value,i.value?ie()(e.content).find("input").removeAttr("disabled"):ie()(e.content).find("input").attr("disabled","true")}});t.setTooltip("Toggle calculation of this function"),e.header.appendChild(t.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),a&&o.dialog("Compute").add(V).onOK((()=>H())).onCancel(n).show(),{root:V,okProxy:H}}))}const se=rxjs;class ae{constructor(e,t=[],i={}){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.properties=e,this.options=Object.assign(Object.assign({},this.options),i),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,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,t,i,n,s;if(o.empty(this._root),!this.options.horizontalInputNames)for(const i of this.properties){let n=null!==(e=i.caption)&&void 0!==e?e:i.name;(null===(t=this.options.customLabels)||void 0===t?void 0:t[i.name])&&(n=this.options.customLabels[i.name]);const s=o.divText(n);s.style.fontWeight="bold",this._root.appendChild(s)}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!==(s=null===(n=(i=this.options).newItemFunction)||void 0===n?void 0:n.call(i))&&void 0!==s?s:void 0,!0);for(const t of e)this._root.appendChild(t)}}getItemDiv(e={},i){var n,s;const a=[],r={};let l=null;for(const c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const u=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](e):o.input.forProperty(c,e),d=null===(s=this.options.validators)||void 0===s?void 0:s[c.name];d&&u.addValidator(d),a.push(this.options.horizontalInputNames?u.root:this.hideLabel(u.root)),c.propertyType!==t.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&u.input&&(u.input.style.width="100%"),r[c.name]=u,u.onChanged((()=>{e[c.name]=u.value,i?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})})),u.root.style.alignItems="center",l=u}let c=null;if(i)c=o.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 a;c=o.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",a}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}var re=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function le(){const e=t.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=t.InputBase.forProperty(e);let n=null,o=null,s=null;return i.addValidator((e=>s)),i.onChanged((()=>re(this,void 0,void 0,(function*(){const e=i.value;if(e)try{const i=yield e.readAsString(),a=t.ViewLayout.fromJson(i);a?(n=a,o=a.viewState,s=null):(n=null,o=null,s="Invalid layout file")}catch(e){n=null,o=null,s="Invalid layout file"}i.setTooltip("Select a layout file")})))),{dataFileInput:i,getLayout:()=>n,getLayoutViewState:()=>o}}var ce=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function ue(i,n){return ce(this,void 0,void 0,(function*(){var s,a;const r=(yield He.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),l=[];for(const e of r){const t=JSON.parse(yield He.files.readAsText(`Hit Triage/templates/${e}.json`));l.push(t.key)}const d=t.Func.find({tags:[u]}),p={};d.forEach((e=>{var t;p[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const h=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(p)]});h.value=null,h.nullable=!0,h.fireChanged(),h.setTooltip("Select function to be called upon submitting");const m=le(),v=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),y=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),b=o.input.string("Name",{value:"",onValueChanged:()=>{""===b.value||r.includes(b.value)?(b.root.style.borderBottom="1px solid red",v.style.opacity="100%"):(b.root.style.borderBottom="none",v.style.opacity="0%")}}),C=o.input.string("Key",{value:"",onValueChanged:()=>{""===C.value||l.includes(C.value)?(C.root.style.borderBottom="1px solid red",y.style.opacity="100%"):(C.root.style.borderBottom="none",y.style.opacity="0%")}});C.setTooltip("Template key used for campaign prefix"),b.setTooltip("Template name"),b.root.style.borderBottom="none",C.root.style.borderBottom="none",v.style.opacity="0%",y.style.opacity="0%";let T=null;const I=yield oe(i,(e=>{T=e}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);I.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&t.Func.find({tags:[c]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const E=Object.keys(n),S=o.input.choice(w,{value:E[0],items:E}),N=o.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:()=>{"Query"!==N.value?S.root.style.display="none":S.root.style.display="block"}}),F=de(),_=o.div([o.h2("Details"),o.div([b,v]),o.div([C,y]),N.root,S.root,m.dataFileInput,F.fieldsDiv,o.h2("Compute"),I.root,o.h2("Submit"),h.root],"ui-form"),P=o.buttonsInput([]),O=null!==(a=null===(s=P.getElementsByClassName("ui-input-editor"))||void 0===s?void 0:s[0])&&void 0!==a?a:P;_.appendChild(P);const B=new Promise((e=>{const t=o.button(x,(()=>e()));O.appendChild(t)})),V=new Promise((t=>{const i=o.bigButton(A,(()=>function(){return ce(this,void 0,void 0,(function*(){var i,n,o,s,a,r,l,c;if(I.okProxy(),"100%"===v.style.opacity)return void e.shell.error("Template name is empty or already exists");const u=h.value?p[h.value]:void 0,d=Object.assign(Object.assign({name:b.value,key:C.value,campaignFields:F.getFields(),dataSourceType:null!==(i=N.value)&&void 0!==i?i:"Query",layoutViewState:null!==(n=m.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==T?void 0:T.descriptors)||void 0===o?void 0:o.length),args:null!==(s=null==T?void 0:T.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(a=null==T?void 0:T.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==T?void 0:T.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(f)&&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==T?void 0:T.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(g)&&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}}))}},u?{submit:{fName:u.name,package:u.package.name}}:{}),{queryFunctionName:"Query"===N.value&&null!==(c=S.value)&&void 0!==c?c:void 0});var y;y=d,He.files.writeAsText(`Hit Triage/templates/${y.name}.json`,JSON.stringify(y)),e.shell.info("Template created successfully"),t(d)}))}()));O.appendChild(i)}));return{root:_,template:V,cancelPromise:B}}))}function de(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING}),t.Property.fromOptions({name:"Type",type:t.TYPE.STRING,choices:Object.keys(X)}),t.Property.fromOptions({name:"Required",type:t.TYPE.BOOL})],n=new ae(i,e?e.map((e=>({Name:e.name,Type:e.type,Required:e.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let s={};n.onItemAdded.subscribe((e=>{s={}})),n.onAddingItemChanged.subscribe((e=>{e&&(s=e.item)}));const a=o.h2("Additional fields");o.tooltip.bind(a,"Additional fields to be filled by user for each campaign");const r=o.div([a,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 s.Name&&""!==s.Name&&s.Type&&(null!==(e=s.Required)&&void 0!==e||(s.Required=!1),t.push({name:s.Name,type:s.Type,required:s.Required})),t},fieldsDiv:o.div([r])}}var pe=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class he extends t.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return pe(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return pe(this,void 0,void 0,(function*(){yield He.files.delete(`${e}/campaigns/${t}`)}))}}var me=i(677),ve={};ve.styleTagTransform=U(),ve.setAttributes=k(),ve.insert=B().bind(null,"head"),ve.domAPI=P(),ve.insertStyleElement=j(),F()(me.A,ve),me.A&&me.A.locals&&me.A.locals;var fe;!function(t){let i,n;!function(e){e.vert=function(e){return o.divV(e.map((e=>o.render(e))),{classes:"u2-panel"})},e.horz=function(e){return o.divH(e.map((e=>o.render(e))),{classes:"u2-panel"})}}(i=t.panels||(t.panels={})),t.appHeader=function(e){const t=o.iconImage("",e.iconPath);return ie()(t).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([t,i.vert([o.markdown(e.description),e.learnMoreUrl?o.link("Learn more",e.learnMoreUrl):null])])},function(t){t.runAsync=function(t,i){return n=this,s=void 0,r=function*(){o.setUpdateIndicator(t,!0);try{return yield i()}catch(t){e.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function o(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(i,o)}l((r=r.apply(n,s||[])).next())}));var n,s,a,r}}(n=t.tools||(t.tools={}))}(fe||(fe={}));var ge=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};const ye={view:[t.Group.defaultGroupsIds["All users"]],edit:[t.Group.defaultGroupsIds["All users"]]};class we{constructor(e){this.permissions=null!=e?e:ye,this.editGroupsInput=o.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=o.input.userGroups("Can View")}getDialogContent(){return ge(this,void 0,void 0,(function*(){const t=[],i=[];for(const i of this.permissions.view){const n=yield e.dapi.groups.find(i);n&&t.push(n)}for(const t of this.permissions.edit){const n=yield e.dapi.groups.find(t);n&&i.push(n)}return this.editGroupsInput.value=i,this.viewGroupsInput.value=t,o.divV([this.editGroupsInput.root,this.viewGroupsInput.root])}))}show(e){return ge(this,void 0,void 0,(function*(){var t;const i=yield this.getDialogContent(),n=o.dialog("Edit Permissions").add(i).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=ye.view),e(this.permissions)}));(null===(t=i.parentElement)||void 0===t?void 0:t.style)&&(i.parentElement.style.overflow="visible"),n.show()}))}}var be=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class Ce extends he{constructor(t){super(t),this.readmePath=He.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 be(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(I),i=o.h1(E,{style:{marginLeft:"10px"}}),n=fe.appHeader({iconPath:He.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 "}),s=o.div(),a=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(s,a,e),ie()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),r,i,a,s])),this.app.resetBaseUrl()}catch(e){throw o.setUpdateIndicator(this.root,!1),e}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){return be(this,void 0,void 0,(function*(){var n;const s=(yield He.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));i&&!s.includes(i.name)&&s.push(i.name);const a=()=>be(this,void 0,void 0,(function*(){const t=r.value,n=i&&i.name===t?i:JSON.parse(yield He.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(n,e);ie()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=o.input.choice("Template",{value:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:s[0],items:s,onValueChanged:()=>be(this,void 0,void 0,(function*(){yield a()}))}),l=o.icons.add((()=>be(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),b);r.addOptions(l),yield a(),ie()(t).empty(),t.appendChild(r.root)}))}checkCampaign(e){return be(this,void 0,void 0,(function*(){const t=location.search,i=new URLSearchParams(t);if(!i.has(s)&&!e)return;const n=null!=e?e:i.get(s);if(!(yield He.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield He.files.readAsText(`Hit Triage/campaigns/${n}/${l}`));if(o){if(o.authorUserId&&o.permissions&&!(yield Z(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const a=JSON.parse(yield He.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(a,o.filters,n,o.ingest),e&&q(s,e),o}))}getCampaignsTable(){return be(this,void 0,void 0,(function*(){const e=yield z("Hit Triage",this.deletedCampaigns),i=e=>{var i,n;const s=o.icons.delete((()=>be(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>be(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 s.style.display="none",Q(null!==(i=e.authorUserId)&&void 0!==i?i:t.User.current().id,null!==(n=e.permissions)&&void 0!==n?n:ye).then((e=>{e&&(s.style.display="inline-block")})),s},n=Object.values(e),s=o.table(n,(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.filteredRowCount,e.status,i(e)]),["Name","Created","Total","Selected","Status",""]);return s.style.color="var(--grey-5)",s}))}setCampaign(e){return be(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return be(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:s,promise:a,cancelPromise:r}=yield function(i,n){return ee(this,void 0,void 0,(function*(){var s,a;const r=o.divText("",{style:{color:"red"}});let l=null;const u=()=>ee(this,void 0,void 0,(function*(){try{if(l=d.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(t.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),d=o.input.table("Dataframe",{onValueChanged:u});yield u();const p=o.div([d,r]);0===Object.keys(n).length&&t.Func.find({tags:[c]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));let h=null;const m=()=>ee(this,void 0,void 0,(function*(){const e=n[f.value];h=e.prepare();const t=yield h.getEditor();t.classList.remove("ui-form"),v.innerHTML="",v.appendChild(t)})),v=o.div([]),f=o.input.choice(w,{value:null!==(s=i.queryFunctionName)&&void 0!==s?s:Object.keys(n)[0],items:Object.keys(n),onValueChanged:m});yield m(),i.queryFunctionName&&(null===(a=f.root.getElementsByTagName("select").item(0))||void 0===a||a.setAttribute("disabled","true"));const g=o.div([f,v]);g.style.display="none";const y=o.div([p,g]),b=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:X[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),A={},T=b.length?o.input.form(A,b):o.div();T.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const I=o.div([y,...b.length?[T]:[]]),E=o.buttonsInput([]);return I.appendChild(E),{promise:new Promise((t=>{const s=()=>ee(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!l)return void e.shell.error("No file selected");const i=l;i.name=l.name,t({df:i,type:"File",campaignProps:A})}else{const i=n[f.value];if(!i)return void e.shell.error("No function selected");const o={};Object.entries(h.inputs).forEach((([e,t])=>{o[e]=t}));const s=yield i.apply(o);t({df:s,type:"Query",campaignProps:A})}})),a=o.bigButton(C,(()=>s()));E.appendChild(a)})),root:I,cancelPromise:new Promise((e=>{o.button(x,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),a.then((e=>be(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)})))),r.then((()=>{this.init()})),s}))}createNewTemplate(){return be(this,void 0,void 0,(function*(){const i=yield ue(this.app,this.dataSourceFunctionsMap),n=new t.ViewBase,o=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=o;const{sub:s}=Y(e.shell.v,"Hit Triage",b,(()=>{e.shell.v=o,n.close()}));i.template.then((t=>be(this,void 0,void 0,(function*(){yield this.init(t),n.close(),W(n),e.shell.v=o,s.unsubscribe()})))),i.cancelPromise.then((()=>{s.unsubscribe(),n.close(),e.shell.v=o}))}))}}class Ae extends he{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,s=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const s=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:s,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function a(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 o?i:new o((function(e){e(i)}))).then(a,r)}l((s=s.apply(i,n||[])).next())}));var i,n,o,s}}var Te=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class xe{constructor(e){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this.resetBaseUrl(),this.computeFunctions=new Promise((e=>Te(this,void 0,void 0,(function*(){const i=t.Func.find({tags:["HitTriageFunction"]}),n=i.filter((e=>e.type===S.function)),o=i.filter((e=>e.type===S.script)),s=i.filter((e=>e.type===S.query));e({functions:n,scripts:o,queries:s})}))))}setCanEdit(e){return Te(this,void 0,void 0,(function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield Q(e.authorUserId,e.permissions):this.hasEditPermission=!0}))}resetBaseUrl(){const e=window.location.href,t=new URL(e);this.baseUrl=t.origin+t.pathname}getFilterType(e){const i=this.dataFrame.col(e);return(null==i?void 0:i.semType)===t.SEMTYPE.MOLECULE?t.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===t.COLUMN_TYPE.BOOL?t.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===t.COLUMN_TYPE.STRING?t.FILTER_TYPE.CATEGORICAL:t.FILTER_TYPE.HISTOGRAM}download(e,i,n=!1){const o=document.createElement("a"),s=t.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(s)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(e,t){return Te(this,void 0,void 0,(function*(){const i=(yield He.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(t)));if(0===i.length)return t+"-1";const n=i.map((e=>e.split("-")[1])).filter(Boolean).map((e=>parseInt(e,10))).sort();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,i,n){var o,s,a,r,l;const c=null===(s=null===(o=e.col(n))||void 0===o?void 0:o.toList())||void 0===s?void 0:s.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles))),u=null===(r=null===(a=i.col(n))||void 0===a?void 0:a.toList())||void 0===r?void 0:r.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles)));if(!c||!u)throw new Error("Molecule column not found");this.isJoining=!0;try{for(const t of e.columns)i.columns.contains(t.name)||i.columns.addNew(t.name,t.type);for(let t=0;t<c.length;t++)if(!u.includes(c[t])){i.rows.addNew(null,!0);for(const n of e.columns){const e=n.get(t);null===(l=i.col(n.name))||void 0===l||l.set(i.rowCount-1,e,!1)}}}finally{setTimeout((()=>{this.isJoining=!1}),500)}return i}}var Ie=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))},Ee=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function Se(e){let t=0;if(e.length>1)for(const i of e.toList()){if(!i||!i.startsWith(v[0])||7!==i.length)continue;const e=parseInt(i.substring(1));isNaN(e)||(t=Math.max(e,t))}return`V${"".concat(...new Array(6-(t+1).toString().length).fill("0"))}${t+1}`}function Ne(i,n,o){return Ee(this,void 0,void 0,(function*(){var s,a;const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=n.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let t=0;t<l.length;t++){if(l.isNone(t))continue;const i=l.get(t);if(!i)continue;const n=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles);l.set(t,n,!1)}try{i.descriptors&&i.descriptors.length>0&&(yield e.chem.descriptors(n,o,i.descriptors))}catch(e){console.error("Descriptors calculation error",e)}for(const e of Object.keys(i.externals))try{const s=i.externals[e],a=t.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=a.inputs[0].name,l=a.inputs[1].name;s&&(yield a.apply(Object.assign(Object.assign({},s),{[r]:n,[l]:o})))}catch(e){console.error(e)}for(const e of Object.keys(null!==(s=i.scripts)&&void 0!==s?s:{})){const s=i.scripts[e];if(s){const i=e.split(":"),a=i[2];if(!a)continue;try{const e=i[1],r=t.Func.find({name:e}).filter((e=>e.type===S.script&&e.id===a))[0];if(!r)continue;const l=r.inputs[0].name,c=r.inputs[1].name,u=yield r.apply(Object.assign(Object.assign({},s),{[l]:n,[c]:o}));if(u&&u.rowCount===n.rowCount&&"python"===r.language)for(const e of u.columns)e.name=n.columns.getUnusedName(e.name),n.columns.add(e)}catch(e){console.error(e)}}}for(const e of Object.keys(null!==(a=i.queries)&&void 0!==a?a:{})){const s=i.queries[e];if(s){const i=e.split(":"),a=i[2];if(!a)continue;try{const e=i[1],r=t.Func.find({name:e}).filter((e=>e.type===S.query&&e.id===a))[0];if(!r)continue;const l=r.inputs[0].name,c=n.col(o).toList(),u=yield r.apply(Object.assign(Object.assign({},s),{[l]:c}));u&&(yield J(n,o,u))}catch(e){console.error(e)}}}r.close()}))}var Fe=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class _e extends xe{get infoView(){return this._infoView}constructor(i){super(i),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new Ce(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof he&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,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(),q(s,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)}}))}setTemplate(i,n,o,a){return Fe(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,y,w,b,C,A,T;if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?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)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),q(s,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&i.semType!==t&&(i.semType=t)})),(null===(u=this._campaign)||void 0===u?void 0:u.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===(d=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==p?p:void 0,this._dfName=null!==(h=this.dataFrame.name)&&void 0!==h?h:null==a?void 0:a.query,this.dataFrame.name=null!==(v=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==v?v:"Molecules",this._campaignId=o,this.template=(null===(y=this.campaign)||void 0===y?void 0:y.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const e={},t={},n={};i.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(w=i.compute.scripts)||void 0===w||w.forEach((e=>{const i=`${f}:${e.name}:${e.id}`;t[i]=e.args})),null===(b=i.compute.queries)||void 0===b||b.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;n[t]=e.args})),yield Ne({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:e,scripts:t,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const x=e.shell.v,I=e.shell.addView(this.pickView);this.currentPickViewId=I.name,this._submitView=new Ae(this),this.setBaseUrl(),q(s,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 E=I;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:t}=Y(E,"Hit Triage","Pick",(()=>{e.shell.v=x,E.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,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.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(d)||this.dataFrame.columns.addNewBool(d).init(!1);const i=t.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),s=o.iconFA("wrench",(()=>Fe(this,void 0,void 0,(function*(){oe(this,(e=>Fe(this,void 0,void 0,(function*(){var t,i,n,o,s,a,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=e.descriptors,h={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!==(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!==(a=null==e?void 0:e.scripts)&&void 0!==a?a:{}).filter((([e,t])=>e.startsWith(f)&&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(g)&&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=h;const m=p.filter((e=>!l.includes(e))),v=h.functions.filter((e=>{if(!c.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=c.find((t=>t.name===e.name&&t.package===e.package));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),y=h.scripts.filter((e=>{if(!u.some((t=>t.id===e.id)))return!0;const t=u.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w=h.queries.filter((e=>{if(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),b={};v.forEach((e=>{const t=`${e.package}:${e.name}`;b[t]=e.args}));const C={};y.forEach((e=>{const t=`${f}:${e.name}:${e.id}`;C[t]=e.args}));const A={};w.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;A[t]=e.args})),yield Ne({descriptors:m,externals:b,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),a=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}})),r=o.iconFA("share",(()=>Fe(this,void 0,void 0,(function*(){var e;yield new we(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)}))}))),"Edit permissions");a.classList.add("hit-design-submit-button");const l=G(n);return n.push([s,...this.hasEditPermission?[r]:[],...l?[]:[a]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>Fe(this,void 0,void 0,(function*(){var n,o,s;i._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const a=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),r=null!==(o=null===(n=this._campaign)||void 0===n?void 0:n.layout)&&void 0!==o?o:null===(s=this.template)||void 0===s?void 0:s.layoutViewState;if(r)try{const e=t.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=a.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=a.getOptions().look.filters}),300),e&&e()}))),300),i.parentCall=this.parentCall,i}getSummary(){var e,t,i,n,s,a,r;const l=null!==(t=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==t?t:this.campaignProps;return Object.assign(Object.assign({Template:null!==(n=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==n?n:"Molecules","File path":o.divH([o.link(null!==(s=this._dfName)&&void 0!==s?s:"-",(()=>this.download(this.dataFrame,"molecules")),T)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(a=this.dataFrame)||void 0===a?void 0:a.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),T)],{style:{alignItems:"center"}})})}saveCampaign(i){return Fe(this,arguments,void 0,(function*(i,n=!0){var s,a,c,u,d,p,h,m,v,f;const g=this.campaignId,y=this.filterSettings,w=this.template.name,b=this.dataFrame,C=`System:AppData/HitTriage/Hit Triage/campaigns/${g}/`,A=null!=g?g:yield function(e){return Ie(this,void 0,void 0,(function*(){return new Promise((t=>Ie(this,void 0,void 0,(function*(){const i=o.input.string("Campaign name",{value:""});o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?t(i.value):t(e)})).show()}))))}))}(g),T={};b.columns.toList().forEach((e=>T[e.name]=e.semType));const x={};b.columns.toList().forEach((e=>x[e.name]=e.type));const I=null!==(a=null===(s=this.campaign)||void 0===s?void 0:s.authorUserId)&&void 0!==a?a:e.shell.user.id,E=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.permissions)&&void 0!==u?u:ye,S={name:A,templateName:w,filters:null!=y?y:{},ingest:{type:"File",query:`${C}${r}`,molColName:this.molColName},status:null!==(p=null!=i?i:null===(d=this.campaign)||void 0===d?void 0:d.status)&&void 0!==p?p:"In Progress",createDate:null!==(m=null===(h=this.campaign)||void 0===h?void 0:h.createDate)&&void 0!==m?m:H(new Date),campaignFields:null!==(f=null===(v=this.campaign)||void 0===v?void 0:v.campaignFields)&&void 0!==f?f:this.campaignProps,columnSemTypes:T,rowCount:b.rowCount,filteredRowCount:b.filter.trueCount,template:this.template,columnTypes:x,authorUserId:I,permissions:E};if(this.campaign=S,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),S;const N=t.DataFrame.fromColumns(b.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield He.files.writeAsText(`Hit Triage/campaigns/${g}/${r}`,N);const F=this._pickView.saveLayout();return F?S.layout=F.viewState:e.shell.warning("Layout cound not be saved"),yield He.files.writeAsText(`Hit Triage/campaigns/${g}/${l}`,JSON.stringify(S)),n&&e.shell.info("Campaign saved successfully."),S}))}}var Pe=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function Oe(i,n){return Pe(this,void 0,void 0,(function*(){var s,a,r,l,c,d,p,h,m,v,y;const w=yield He.files.list("Hit Design/templates");let b=!1,C=!1;const T=w.map((e=>e.name.slice(0,-5))),I=[];for(const e of w)try{const t=JSON.parse(yield He.files.readAsText(e));I.push(t.key)}catch(e){console.error(e)}const E=t.Func.find({tags:[u]}),S={};E.forEach((e=>{var t;S[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const N=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(S)]});N.nullable=!0,N.value=null!==(a=null===(s=null==n?void 0:n.submit)||void 0===s?void 0:s.fName)&&void 0!==a?a:null,N.setTooltip("Select function to be called upon submitting");const F=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),_=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),P=le();function O(){var e,t,i,n;if(""===B.value||T.includes(null!==(t=null===(e=B.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=B.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=B.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 B=o.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:O});function V(){var e,t,i,n;if(""===k.value||I.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=o.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"),B.setTooltip("Template name"),B.root.style.borderBottom="none",k.root.style.borderBottom="none",F.style.opacity="0%",_.style.opacity="0%";let L=null;const j={compute:{descriptors:{enabled:!0,args:null!==(p=null===(d=null===(c=null==n?void 0:n.compute)||void 0===c?void 0:c.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[]},functions:null!==(m=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==m?m:[]}},D=yield oe(i,(e=>{L=e}),(()=>null),j,!1);D.root.classList.add("hit-triage-new-template-functions-input");const U=de(null==n?void 0:n.campaignFields),R=function(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING})],n=new ae(i,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((e=>{o={}})),n.onAddingItemChanged.subscribe((e=>{e&&(o=e.item)})),{getFields:function(){const e=n.items.filter((e=>e.Name)).map((e=>e.Name));return o.Name&&""!==o.Name&&e.push(o.Name),e},fieldsDiv:n.root}}(null==n?void 0:n.stages),$=o.divV([o.divV([B,F]),o.divV([k,_]),P.dataFileInput,U.fieldsDiv]),M=o.h2("Stages");o.tooltip.bind(M,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=o.h2("Compute");o.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=o.div([o.h2("Details"),$,M,R.fieldsDiv,H,D.root,o.h2("Submit"),N.root],"ui-form"),Y=o.buttonsInput([]);q.appendChild(Y);const W=null!==(y=null===(v=Y.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==y?y:Y,G=new Promise((e=>{const t=o.button(x,(()=>e()));W.appendChild(t)})),J=new Promise((t=>{const i=o.bigButton(A,(()=>function(){return Pe(this,void 0,void 0,(function*(){var i,n,o,s,a,r;if(O(),V(),D.okProxy(),b||!B.value||""===B.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 l=N.value?S[N.value]:void 0,c=Object.assign({name:B.value,key:k.value,campaignFields:U.getFields(),stages:R.getFields(),layoutViewState:null!==(i=P.getLayoutViewState())&&void 0!==i?i:void 0,compute:{descriptors:{enabled:!!(null===(n=null==L?void 0:L.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==L?void 0:L.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(s=null==L?void 0:L.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!==(a=null==L?void 0:L.scripts)&&void 0!==a?a:{}).filter((([e,t])=>e.startsWith(f)&&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==L?void 0:L.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(g)&&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}}))}},l?{submit:{fName:l.name,package:l.package.name}}:{});var u;u=c,He.files.writeAsText(`Hit Design/templates/${u.name}.json`,JSON.stringify(u)),e.shell.info("Template created successfully"),t(c)}))}()));W.appendChild(i)}));return{root:q,template:J,cancelPromise:G}}))}var Be=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class Ve extends he{constructor(t){super(t),this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(He.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(He.webRoot+"README_HD.md")}init(e){return Be(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(I),i=o.h1(E,{style:{marginLeft:"10px"}}),n=fe.appHeader({iconPath:He.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"}),s=o.div(),a=o.divH([]),r=o.div([a,s],"ui-form"),l=yield this.getCampaignsTable();ie()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(s,a,e),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,i,n){return Be(this,void 0,void 0,(function*(){var s;const a=(yield He.files.list("Hit Design/templates")).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));n&&!a.includes(n.name)&&a.push(n.name);let r=null,l=!0;const c=()=>Be(this,void 0,void 0,(function*(){if(!l)return;const e=u.value,i=n&&n.name===e?n:JSON.parse(yield He.files.readAsText("Hit Design/templates/"+e+".json"));r=i;const o=yield this.getNewCampaignAccordeon(i);ie()(t).empty(),t.appendChild(o)})),u=o.input.choice("Template",{value:null!==(s=null==n?void 0:n.name)&&void 0!==s?s:a[0],items:a,onValueChanged:()=>Be(this,void 0,void 0,(function*(){yield c()}))});u.root.style.width="100%";const d=o.icons.add((()=>{this.createNewTemplate()}),b),p=o.icons.copy((()=>{r&&this.createNewTemplate(r)}),"Clone template"),h=o.icons.delete((()=>{!u.value||u.items.length<2||o.dialog("Delete template").add(o.divText(`Are you sure you want to delete template ${u.value}?`)).onOK((()=>Be(this,void 0,void 0,(function*(){try{const t=u.value;yield He.files.delete(`Hit Design/templates/${t}.json`),l=!1,u.items=u.items.filter((e=>e!==t)),u.value=u.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 "+u.value),console.error(t)}})))).show()}),"Delete template");d.style.color="#2083d5",u.addOptions(h),u.addOptions(p),u.addOptions(d),yield c(),ie()(i).empty(),i.appendChild(u.root)}))}checkCampaign(e){return Be(this,void 0,void 0,(function*(){var t;const i=location.search,n=new URLSearchParams(i);if(!n.has(a)&&!e)return;const o=null!=e?e:n.get(a);if(!(yield He.files.exists(`Hit Design/campaigns/${o}/${l}`)))return;const s=JSON.parse(yield He.files.readAsText(`Hit Design/campaigns/${o}/${l}`));if(s){if(s.authorUserId&&s.permissions&&!(yield Z(s.authorUserId,s.permissions)))return void this.app.setBaseUrl();this.app.campaign=s}const r=null!==(t=s.template)&&void 0!==t?t:JSON.parse(yield He.files.readAsText(`Hit Design/templates/${s.templateName}.json`));return yield this.app.setTemplate(r,o),e&&q(a,e),s.template=r,s}))}getCampaignsTable(){return Be(this,void 0,void 0,(function*(){const i=yield z("Hit Design",this.deletedCampaigns),n=i=>{var n,s;const a=o.icons.delete((()=>Be(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK((()=>Be(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",i.name),this.deletedCampaigns.push(i.name),yield this.init()})))).show()}))),"Delete campaign"),r=o.iconFA("share",(()=>Be(this,void 0,void 0,(function*(){yield new we(i.permissions).show((t=>Be(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 He.files.writeAsText(`Hit Design/campaigns/${i.name}/${l}`,JSON.stringify(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 a.style.display="none",r.style.display="none",Q(null!==(n=i.authorUserId)&&void 0!==n?n:t.User.current().id,null!==(s=i.permissions)&&void 0!==s?s:ye).then((e=>{e&&(a.style.display="inline-block",r.style.display="inline-block")})),[r,a]},s=o.table(Object.values(i),(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.status,...n(e)]),["Name","Created","Molecules","Status",""]);return s.style.color="var(--grey-5)",s.style.marginLeft="24px",s}))}setCampaign(e){return Be(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i){return Be(this,void 0,void 0,(function*(){const{root:n,promise:s,cancelPromise:a}=function(i){var n,s;const a=t.DataFrame.create(1),r=a.columns.addNew(h,t.TYPE.STRING);r.semType=t.SEMTYPE.MOLECULE,r.meta.units=t.UNITS.Molecule.SMILES,r.set(0,null),(null===(n=null==i?void 0:i.stages)||void 0===n?void 0:n.length)>0&&a.columns.addNew(p,t.TYPE.STRING).set(0,i.stages[0]);const l=a.columns.addNew(m,t.TYPE.STRING);l.set(0,Se(l));const c=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:X[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),u={},d=o.input.form(u,c);d.classList.remove("ui-form");const v=o.div([...(null===(s=i.campaignFields)||void 0===s||s.length,[]),d]),f=o.buttonsInput([]);return v.appendChild(f),{promise:new Promise((t=>{const n=o.bigButton(C,(()=>{for(const t of i.campaignFields)if(t.required&&(!u[t.name]||""===u[t.name]))return void e.shell.error(`Field '${t.name}' is required`);t({df:a,campaignProps:u})}));f.appendChild(n)})),root:v,cancelPromise:new Promise((e=>{o.button(x,(()=>e()))}))}}(i);return s.then((e=>Be(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,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)})))),a.then((()=>{this.init()})),n}))}createNewTemplate(i){return Be(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield Oe(this.app,i),o=new t.ViewBase,s=e.shell.v;o.name="New Template",o.root.appendChild(n.root),o.parentCall=this.app.parentCall,e.shell.addView(o),o.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:a}=Y(o,"Hit Design",b,(()=>Be(this,void 0,void 0,(function*(){e.shell.v=s,o.close()}))));n.template.then((t=>Be(this,void 0,void 0,(function*(){yield this.init(t),o.close(),W(o),e.shell.v=s,a.unsubscribe()})))),n.cancelPromise.then((()=>Be(this,void 0,void 0,(function*(){a.unsubscribe(),o.close(),e.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class ke extends he{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,s=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const s=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:s,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function a(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 o?i:new o((function(e){e(i)}))).then(a,r)}l((s=s.apply(i,n||[])).next())}));var i,n,o,s}}var Le=i(542),je={};je.styleTagTransform=U(),je.setAttributes=k(),je.insert=B().bind(null,"head"),je.domAPI=P(),je.insertStyleElement=j(),F()(Le.A,je),Le.A&&Le.A.locals&&Le.A.locals;const De=rxjs.operators;var Ue=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class Re extends xe{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(i){super(i),this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=h,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new Ve(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof he&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=this.multiView,e.events.onCurrentViewChanged.subscribe((()=>Ue(this,void 0,void 0,(function*(){var t,i,n,o,a;try{if((null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentDesignViewId){e.shell.windows.showHelp=!1,this.setBaseUrl(),q(s,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:"");const{sub:t}=Y(e.shell.v,"Hit Design",null===(a=e.shell.v)||void 0===a?void 0:a.name,(()=>{var i;e.shell.v=this.mainView,null===(i=this._designView)||void 0===i||i.close(),this._infoView.init(),t.unsubscribe()}))}}catch(e){console.error(e)}}))))}setTemplate(i,n){return Ue(this,void 0,void 0,(function*(){var o,l,c,u,d,p,m,v,f,g,y,w,b;if(n){const t="System.AppData/HitTriage/Hit Design/campaigns";this._filePath=null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.savePath)&&void 0!==c?c:`${t}/${n}/${r}`,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===(d=this._campaign)||void 0===d?void 0:d.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===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName("Hit Design/campaigns",i.key),q(a,n),this._filePath=`System.AppData/HitTriage/Hit Design/campaigns/${n}/${r}`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(m=null===(p=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:h,this._dfName=null!==(v=(b=this.dataFrame).name)&&void 0!==v?v:b.name=n,this._campaignId=n,this.template=i,null!==(f=this._submitView)&&void 0!==f||(this._submitView=new ke(this)),e.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const C=this.designView;this.currentDesignViewId=C.name,this.setBaseUrl(),q(s,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)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var e,i,n,o;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:h}get campaign(){return this._campaign}set campaign(e){this._campaign=e}cacheDuplicateVIDs(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(m);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(m);if(t)return this._duplicateVidCache&&t.version===this._duplicateVidCache.colVersion||this.cacheDuplicateVIDs(),this._duplicateVidCache}getDesignView(){var i,n,s,a,r,l,c,u,d,v;const y=[],w=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),b=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(s=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==s?s:this._designViewName,b.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList();const C=(i,n)=>Ue(this,void 0,void 0,(function*(){const o=this.template.compute;if(!n||""===n)return;const s=yield function(i,n,o){return Ee(this,arguments,void 0,(function*(i,n,o,s=[],a=[]){const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles),c=t.Column.fromStrings(h,[l]),u=t.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes();try{n.length&&(yield e.chem.descriptors(u,c.name,n))}catch(e){console.error("Descriptors calculation error",e)}for(const e of o)try{const i=e.args,n=t.Func.find({package:e.package,name:e.name});if(!n.length||!n[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const o=n[0],s=o.inputs[0].name,a=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[s]:u,[a]:c.name}))}catch(e){console.error(e);continue}for(const e of s){const i=e.args;try{const n=t.Func.find({name:e.name}).filter((t=>t.type===S.script&&t.id===e.id))[0];if(n){const e=n.inputs[0].name,t=n.inputs[1].name,o=yield n.apply(Object.assign(Object.assign({},i),{[e]:u,[t]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===n.language)for(const e of o.columns)e.name=u.columns.getUnusedName(e.name),u.columns.add(e)}}catch(e){console.error(e)}}for(const e of a){const i=e.args;try{const n=t.Func.find({name:e.name}).filter((t=>t.type===S.query&&t.id===e.id))[0];if(n){const e=n.inputs[0].name,t=[l],o=yield n.apply(Object.assign(Object.assign({},i),{[e]:t}));if(!o||0===o.rowCount)continue;yield J(u,h,o)}}catch(e){console.error(e)}}return r.close(),u}))}(n,o.descriptors.args,o.functions,o.scripts,o.queries);for(const e of s.columns.toList())e.name!==h&&(this.dataFrame.columns.contains(e.name)||(this.dataFrame.columns.addNew(e.name,e.type).semType=e.semType),this.dataFrame.col(e.name).set(i,e.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}));b._onAdded();const A=null!==(r=null===(a=this._campaign)||void 0===a?void 0:a.layout)&&void 0!==r?r:null===(l=this.template)||void 0===l?void 0:l.layoutViewState;if(A)try{const e=t.ViewLayout.fromViewState(A);b.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}w&&e.functions.call("Chem:editMoleculeCell",{cell:b.grid.cell(this._molColName,0)}),y.push(this.dataFrame.onRowsAdded.pipe((0,De.filter)((()=>!this.isJoining))).subscribe((()=>{var t,i;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(t=this.template.stages)||void 0===t?void 0:t.length)>0)for(let e=0;e<this.dataFrame.rowCount;e++){const t=this.dataFrame.col(p).get(e);t&&""!==t&&!(null===(i=this.dataFrame.col(p))||void 0===i?void 0:i.isNone(e))||this.dataFrame.set(p,e,this.template.stages[0])}let n=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=b.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(n=t))}n&&e.functions.call("Chem:editMoleculeCell",{cell:n})}catch(e){console.error(e)}}))),this.dataFrame&&y.push(null===(c=this.dataFrame)||void 0===c?void 0:c.onRowsRemoved.subscribe((()=>{try{this.processedValues=this.dataFrame.getCol(this.molColName).toList()}catch(e){console.error(e)}}))),y.push(e.events.onContextMenu.subscribe((i=>{var n,o,s,a,r,l,c,u,d,p,h,m;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==b.id)return;if((null===(a=null===(s=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===s?void 0:s.tableColumn)||void 0===a?void 0:a.name)!==this.molColName||!(null===(l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const v=null===(c=null==i?void 0:i.args)||void 0===c?void 0:c.menu;if(!v)return;v.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),v.item("Duplicate molecule",(()=>{var e,t,n,o;try{this.dataFrame.rows.addNew(null,!0);let s=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=b.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(s=t))}s&&(s.cell.value=null!==(o=null===(n=null===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const f=null===(d=null===(u=null==i?void 0:i.args)||void 0===u?void 0:u.item)||void 0===d?void 0:d.tableRowIndex,g=null===(m=null===(h=null===(p=null==i?void 0:i.args)||void 0===p?void 0:p.item)||void 0===h?void 0:h.cell)||void 0===m?void 0:m.value;g&&(null!=f?f:-1)>-1&&v.item("Re-Run Calculations",(()=>Ue(this,void 0,void 0,(function*(){try{yield C(f,g)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),(null==b?void 0:b.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),b.resetLayout()),(null==b?void 0:b.grid)&&y.push(b.grid.onCellValueEdited.subscribe((t=>Ue(this,void 0,void 0,(function*(){var i,n,o,s,a;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===p)return void(yield this.saveCampaign(void 0,!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.molColName)return;const r=t.cell.value,l=t.tableRowIndex;let c=null===(o=this.dataFrame.col(m))||void 0===o?void 0:o.get(l),u=!1;if(r)try{const i=t.tableColumn.toList().map((t=>{try{return e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)}catch(e){return""}})),n=e.chem.convert(r,e.chem.Notation.Unknown,e.chem.Notation.Smiles);if((null==i?void 0:i.length)===this.dataFrame.rowCount)for(let e=0;e<i.length;e++)if(i[e]===n&&e!==l&&(null===(s=this.dataFrame.col(m))||void 0===s?void 0:s.get(e))){c=null===(a=this.dataFrame.col(m))||void 0===a?void 0:a.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[l]]>1&&(c=null),c&&""!==c||(c=Se(this.dataFrame.col(m))),this.dataFrame.col(m).set(l,c,!1),C(l,r)}catch(e){console.error(e)}}))))),(null==b?void 0:b.grid)&&y.push(b.grid.onCellRender.subscribe((e=>{var i;try{const n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!this.duplicateVidCache||n.tableColumn.name!==m||(null!==(i=n.tableRowIndex)&&void 0!==i?i:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=t.Color.setAlpha(t.Color.getCategoricalColor(this.duplicateVidCache.indexes[n.tableRowIndex]),150))}catch(e){}})));const T=e.events.onViewRemoved.subscribe((e=>{e.id===(null==b?void 0:b.id)&&(y.forEach((e=>e.unsubscribe())),T.unsubscribe())})),x=null==b?void 0:b.getRibbonPanels();if(x&&!G(x)){const i=()=>Ue(this,void 0,void 0,(function*(){var e;oe(this,(e=>Ue(this,void 0,void 0,(function*(){var t,i,n,s,a,r,l,c,u,d;const p=this.template.compute.descriptors.args,h=this.template.compute.functions,m=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],v=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],y=e.descriptors,w={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(s=null==e?void 0:e.descriptors)&&void 0!==s?s:[]},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(f)&&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==e?void 0:e.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(g)&&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 C=y.filter((e=>!p.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=m.find((t=>`${f}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{T[e]=t}));const x={};Object.entries(null!==(d=null==e?void 0:e.queries)&&void 0!==d?d:{}).filter((([e,t])=>{const i=v.find((t=>`${g}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{x[e]=t})),o.setUpdateIndicator(b.grid.root,!0);try{yield Ne({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(b.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),n=o.iconFA("wrench",i,"Calculate additional properties"),s=o.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),a=o.iconFA("share",(()=>Ue(this,void 0,void 0,(function*(){var e;yield new we(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)}))}))),"Edit campaign permissions"),r=o.bigButton("Progress tracker",(()=>{!function(i,n){var s,a,r,l,c,u,d,h,m,v,f;const g=null===(s=i.campaign)||void 0===s?void 0:s.tilesViewerFormSketch;let y=null;if(g&&g.length>0)try{y=JSON.parse(g)}catch(e){console.error("Failed to parse sketch state string",e)}y&&y.elementStates&&(null!==(a=y.elementStates.length)&&void 0!==a?a:0)>0&&(y.elementStates=y.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)})));const w=Object.assign({lanesColumnName:p,lanes:null!==(l=null===(r=i.template)||void 0===r?void 0:r.stages)&&void 0!==l?l:[]},(null!==(u=null===(c=null==y?void 0:y.elementStates)||void 0===c?void 0:c.length)&&void 0!==u?u:0)>0?{sketchState:y}:{}),b=n();if(!b)return void e.shell.error("Failed to create tiles viewer. table view is not available.");let C=null;const A=o.dialog("Progress Tracker");try{C=b.addViewer(t.VIEWER.TILE_VIEWER,w);const e=C.getOptions();e.look.sketchState=(null!==(h=null===(d=null==y?void 0:y.elementStates)||void 0===d?void 0:d.length)&&void 0!==h?h:0)>0?y:null,C.setOptions(e),C.copyViewersLook(C)}catch(n){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",n),C&&(C.close(),C.detach()),C=b.addViewer(t.VIEWER.TILE_VIEWER,{lanesColumnName:p,lanes:null!==(v=null===(m=i.template)||void 0===m?void 0:m.stages)&&void 0!==v?v:[]})}if(!C)return void e.shell.error("Failed to create tiles viewer. check the console for more details.");A.add(C.root);const T=e.events.onCurrentViewChanged.subscribe((()=>{e.shell.v===b?A.root.style.display="flex":A.root.style.setProperty("display","none","important")})),x=A.onClose.subscribe((()=>{x.unsubscribe(),T.unsubscribe();try{const e=C.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)}C.detach(),C.close()}));A.showModal(!0),null===(f=document.querySelector(".d4-modal-background"))||void 0===f||f.remove()}(this,(()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null}))})),l=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));l.classList.add("hit-design-submit-button");const c=[l];null!==(v=null===(d=null===(u=this.template)||void 0===u?void 0:u.stages)||void 0===d?void 0:d.length)&&void 0!==v&&v&&c.unshift(r),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),this.hasEditPermission&&c.unshift(a),c.unshift(n),c.unshift(s),x.push(c),b.setRibbonPanels(x)}return b.parentCall=this.parentCall,b}getSummary(){var i,n,s,a;const l=()=>{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)},c=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);return this.template&&this.template.campaignFields&&Object.entries(c).forEach((([i,n])=>{const o=this.template.campaignFields.find((e=>e.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?c[i]=new Date(n).toLocaleDateString():n.date?c[i]=new Date(n.date).toLocaleDateString():c[i]=n:o&&o.type===t.SEMTYPE.MOLECULE&&n&&(c[i]=e.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(a=null===(s=this.template)||void 0===s?void 0:s.name)&&void 0!==a?a:"Molecules","File path":(()=>{const t=o.icons.edit((()=>{const i=l(),a=o.input.string("Path",{value:i}),c=a.root.getElementsByTagName("label").item(0);c&&c.remove(),a.root.style.width="100%";const u=o.button("Save",(()=>Ue(this,void 0,void 0,(function*(){const i=yield function(){return Ue(this,void 0,void 0,(function*(){const t=a.value;return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)}))}();if(!i)return;const c=a.value;c.endsWith("/")?this._filePath=`${c}${this.campaignId}/${r}`:this._filePath=`${c}/${this.campaignId}/${r}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(s);const u=l();n=o.link(u,(()=>{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")}),T),s.appendChild(n),s.appendChild(t)})))),d=o.button("Cancel",(()=>{o.empty(s),s.appendChild(n),s.appendChild(t)}));o.empty(s),a.addOptions(d),a.addOptions(u),s.appendChild(a.root)}),"Edit file path");t.style.marginLeft="5px";const i=l();let n=o.link(i,(()=>{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")}),T);const s=o.divH([n,t],{style:{alignItems:"center"}});return s})()},c),{"Number of molecules":(this.dataFrame.rowCount-this._extraStageColsCount).toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", ")})}saveCampaign(i){return Ue(this,arguments,void 0,(function*(i,n=!0){var o,s,a,r,c,u,d,p,h,v,f,g,y,w,b,C;const A=this.campaignId,T=this.template.name,x=this.dataFrame,I=A,E={};x.columns.toList().forEach((e=>E[e.name]=e.semType));const S={};x.columns.toList().forEach((e=>S[e.name]=e.type));const N=null!==(s=null===(o=this.campaign)||void 0===o?void 0:o.tilesViewerFormSketch)&&void 0!==s?s:void 0,F=null!==(r=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==r?r:e.shell.user.id,_=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.permissions)&&void 0!==u?u:ye,P={name:I,templateName:T,status:null!==(p=null!=i?i:null===(d=this.campaign)||void 0===d?void 0:d.status)&&void 0!==p?p:"In Progress",createDate:null!==(v=null===(h=this.campaign)||void 0===h?void 0:h.createDate)&&void 0!==v?v:H(new Date),campaignFields:null!==(g=null===(f=this.campaign)||void 0===f?void 0:f.campaignFields)&&void 0!==g?g:this.campaignProps,columnSemTypes:E,rowCount:null!==(w=null===(y=x.col(m))||void 0===y?void 0:y.toList().filter((e=>"StageDefiningRow"!==e)).length)&&void 0!==w?w:0,filteredRowCount:x.filter.trueCount,savePath:this._filePath,columnTypes:S,tilesViewerFormSketch:N,version:this.version+1,authorUserId:F,permissions:_};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),P;const O=`Hit Design/campaigns/${A}/${l}`;let B=x;if(yield He.files.exists(O)){const t=JSON.parse(yield He.files.readAsText(O));if((null!==(b=t.version)&&void 0!==b?b:0)>this.version&&(P.version=Math.max(this.version,null!==(C=t.version)&&void 0!==C?C:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);B=this.unionDataframes(t,x,this.molColName)}catch(e){console.error(e)}}const V=t.DataFrame.fromColumns(B.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,V);const k=this._designView.saveLayout();return k?P.layout=k.viewState:e.shell.warning("Layout cound not be saved"),P.template=this.template,yield He.files.writeAsText(O,JSON.stringify(P)),n&&e.shell.info("Campaign saved successfully."),this.campaign=P,P}))}}class $e extends t.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,o,s,a){if(s.gridRow<0||!s.cell.value)return;const r=s.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 Me=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};const He=new t.Package;function qe(e,t){return Me(this,void 0,void 0,(function*(){yield Ge(e,t,"Hit Triage")}))}function Ye(){return Me(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new _e(t).multiView}))}function We(e,t){return Me(this,void 0,void 0,(function*(){yield Ge(e,t,"Hit Design")}))}function Ge(i,n,o){return Me(this,void 0,void 0,(function*(){const s=yield z(o,[]);for(const[o,a]of Object.entries(s)){const o="ingest"in a?a.ingest.query:a.savePath;o&&!1!==(yield e.dapi.files.exists(o))&&i.item(a.name).onSelected.subscribe((i=>Me(this,void 0,void 0,(function*(){try{const i=yield e.dapi.files.readCsv(o);if(!i)return;const s=a.columnSemTypes;if(s)for(const[e,t]of Object.entries(s)){const n=i.columns.byName(e);n&&(n.semType=t)}const r=t.TableView.create(i,!1);n.preview=r;const l=a.layout;l&&r.loadLayout(t.ViewLayout.fromViewState(l))}catch(e){console.error(e)}}))))}}))}function Je(){return Me(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new Re(t).multiView}))}function ze(){return Me(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function Ke(){return Me(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function Qe(t){return Me(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function Ze(t,i){return Me(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function Xe(){return new $e}})(),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),s=o("div"),a=o("table"),r=o("tbody"),l=o("tr"),c=Array.isArray,u=Array.prototype,d=u.concat,p=u.filter,h=u.indexOf,m=u.map,v=u.push,f=u.slice,g=u.some,y=u.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 x=function(){function e(e,n){if(e){if(E(e))return e;var o=e;if(O(e)){var s=n||t;if(!(o=w.test(e)&&F(s)?s.getElementById(e.slice(1).replace(/\\/g,"")):C.test(e)?Z(e):E(s)?s.find(e):O(s)?S(s).find(e):T(e,s)))return}else if(P(e))return this.ready(e);(o.nodeType||o===i)&&(o=[o]),this.length=o.length;for(var a=0,r=this.length;a<r;a++)this[a]=o[a]}}return e.prototype.init=function(t,i){return new e(t,i)},e}(),I=x.prototype,S=I.init;function E(e){return e instanceof x}function N(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 O(e){return"string"==typeof e}function B(e){return void 0===e}function V(e){return null===e}function k(e){return!isNaN(parseFloat(e))&&isFinite(e)}function L(e){if("object"!=typeof e||null===e)return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function j(e,t,i){if(i){for(var n=e.length;n--;)if(!1===t.call(e[n],n,e[n]))return e}else if(L(e))for(var o=Object.keys(e),s=(n=0,o.length);n<s;n++){var a=o[n];if(!1===t.call(e[a],a,e[a]))return e}else for(n=0,s=e.length;n<s;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,S,n);for(var s=0;s<o;s++){var a=e[s];for(var r in a)i&&(c(a[r])||L(a[r]))?(n[r]&&n[r].constructor===a[r].constructor||(n[r]=new a[r].constructor),D(i,n[r],a[r])):n[r]=a[r]}return n}S.fn=S.prototype=I,I.length=0,I.splice=y,"function"==typeof Symbol&&(I[Symbol.iterator]=u[Symbol.iterator]),S.isWindow=N,S.isFunction=P,S.isArray=c,S.isNumeric=k,S.isPlainObject=L,S.each=j,I.each=function(e){return j(this,e)},I.empty=function(){return this.each((function(e,t){for(;t.firstChild;)t.removeChild(t.firstChild)}))},S.extend=D,I.extend=function(e){return D(I,e)};var U=/\S+/g;function R(e){return O(e)&&e.match(U)||[]}function $(e,t,n){if(_(e)){var o=i.getComputedStyle(e,null);return n?o.getPropertyValue(t)||void 0:o[t]||e.style[t]}}function M(e,t){return parseInt($(e,t),10)||0}function H(e,t){return M(e,"border".concat(t?"Left":"Top","Width"))+M(e,"padding".concat(t?"Left":"Top"))+M(e,"padding".concat(t?"Right":"Bottom"))+M(e,"border".concat(t?"Right":"Bottom","Width"))}I.toggleClass=function(e,t){var i=R(e),n=!B(t);return this.each((function(e,o){_(o)&&j(i,(function(e,i){n?t?o.classList.add(i):o.classList.remove(i):o.classList.toggle(i)}))}))},I.addClass=function(e){return this.toggleClass(e,!0)},I.removeAttr=function(e){var t=R(e);return this.each((function(e,i){_(i)&&j(t,(function(e,t){i.removeAttribute(t)}))}))},I.attr=function(e,t){if(e){if(O(e)){if(arguments.length<2){if(!this[0]||!_(this[0]))return;var i=this[0].getAttribute(e);return V(i)?void 0:i}return B(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}},I.removeClass=function(e){return arguments.length?this.toggleClass(e,!1):this.attr("class","")},I.hasClass=function(e){return!!e&&g.call(this,(function(t){return _(t)&&t.classList.contains(e)}))},I.get=function(e){return B(e)?f.call(this):this[(e=Number(e))<0?e+this.length:e]},I.eq=function(e){return S(this.get(e))},I.first=function(){return this.eq(0)},I.last=function(){return this.eq(-1)},I.text=function(e){return B(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 Y(e){return"none"===$(e,"display")}function W(e,t){var i=e&&(e.matches||e.webkitMatchesSelector||e.msMatchesSelector);return!!i&&!!t&&i.call(e,t)}function G(e){return O(e)?function(t,i){return W(i,e)}:P(e)?e:E(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}I.filter=function(e){var t=G(e);return S(p.call(this,(function(e,i){return t.call(e,i,e)})))},I.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={"*":s,tr:r,td:l,th:l,thead:a,tbody:a,tfoot:a};function Z(e){if(!O(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,S(i.childNodes).detach().get()}function X(e,t,i,n){for(var o=[],s=P(t),a=n&&G(n),r=0,l=e.length;r<l;r++)if(s){var c=t(e[r]);c.length&&v.apply(o,c)}else for(var u=e[r][t];!(null==u||n&&a(-1,u));)o.push(u),u=i?u[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 h.call(i,e)===t})):e}S.parseHTML=Z,I.has=function(e){var t=O(e)?function(t,i){return T(e,i).length}:function(t,i){return i.contains(e)};return this.filter(t)},I.not=function(e){var t=G(e);return this.filter((function(i,n){return(!O(e)||_(n))&&!t.call(n,i,n)}))},I.val=function(e){return arguments.length?this.each((function(t,i){var n=i.multiple&&i.options;if(n||Oe.test(i.type)){var o=c(e)?m.call(e,String):V(e)?[]:[String(e)];n?j(i.options,(function(e,t){t.selected=o.indexOf(t.value)>=0}),!0):i.checked=o.indexOf(i.value)>=0}else i.value=B(e)||V(e)?"":e})):this[0]&&ee(this[0])},I.is=function(e){var t=G(e);return g.call(this,(function(e,i){return t.call(e,i,e)}))},S.guid=1,S.unique=te,I.add=function(e,t){return S(te(this.get().concat(S(e,t).get())))},I.children=function(e){return J(S(te(X(this,(function(e){return e.children})))),e)},I.parent=function(e){return J(S(te(X(this,"parentNode"))),e)},I.index=function(e){var t=e?S(e)[0]:this[0],i=e?this:S(t).parent().children();return h.call(i,t)},I.closest=function(e){var t=this.filter(e);if(t.length)return t;var i=this.parent();return i.length?i.closest(e):t},I.siblings=function(e){return J(S(te(X(this,(function(e){return S(e).parent().children().not(e)})))),e)},I.find=function(e){return S(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 se(e,t,i,s,a,r,l,c){return j(e,(function(e,r){j(S(r),(function(e,r){j(S(t),(function(t,l){var c=i?l:r,u=i?e:t;!function(e,t,i,s,a){s?e.insertBefore(t,i?e.firstChild:null):"HTML"===e.nodeName?e.parentNode.replaceChild(t,e):e.parentNode.insertBefore(t,i?e:e.nextSibling),a&&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 s=o("script");s.text=i.textContent.replace(ie,""),j(oe,(function(e,t){i[t]&&(s[t]=i[t])})),t.head.insertBefore(s,null),t.head.removeChild(s)}}))}(t,e.ownerDocument)}(i?r:l,u?c.cloneNode(!0):c,s,a,!u)}),c)}),l)}),r),t}I.after=function(){return se(arguments,this,!1,!1,!1,!0,!0)},I.append=function(){return se(arguments,this,!1,!1,!0)},I.html=function(e){if(!arguments.length)return this[0]&&this[0].innerHTML;if(B(e))return this;var t=/<script[\s>]/.test(e);return this.each((function(i,n){_(n)&&(t?S(n).empty().append(e):n.innerHTML=e)}))},I.appendTo=function(e){return se(arguments,this,!0,!1,!0)},I.wrapInner=function(e){return this.each((function(t,i){var n=S(i),o=n.contents();o.length?o.wrapAll(e):n.append(e)}))},I.before=function(){return se(arguments,this,!1,!0)},I.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)},I.wrap=function(e){return this.each((function(t,i){var n=S(e)[0];S(i).wrapAll(t?n.cloneNode(!0):n)}))},I.insertAfter=function(e){return se(arguments,this,!0,!1,!1,!1,!1,!0)},I.insertBefore=function(e){return se(arguments,this,!0,!0)},I.prepend=function(){return se(arguments,this,!1,!0,!0,!0,!0)},I.prependTo=function(e){return se(arguments,this,!0,!0,!0,!1,!1,!0)},I.contents=function(){return S(te(X(this,(function(e){return"IFRAME"===e.tagName?[e.contentDocument]:"TEMPLATE"===e.tagName?e.content.childNodes:e.childNodes}))))},I.next=function(e,t,i){return J(S(te(X(this,"nextElementSibling",t,i))),e)},I.nextAll=function(e){return this.next(e,!0)},I.nextUntil=function(e,t){return this.next(t,!0,e)},I.parents=function(e,t){return J(S(te(X(this,"parentElement",!0,t))),e)},I.parentsUntil=function(e,t){return this.parents(t,e)},I.prev=function(e,t,i){return J(S(te(X(this,"previousElementSibling",t,i))),e)},I.prevAll=function(e){return this.prev(e,!0)},I.prevUntil=function(e,t){return this.prev(t,!0,e)},I.map=function(e){return S(d.apply([],m.call(this,(function(t,i){return e.call(t,i,t)}))))},I.clone=function(){return this.map((function(e,t){return t.cloneNode(!0)}))},I.offsetParent=function(){return this.map((function(e,t){for(var i=t.offsetParent;i&&"static"===$(i,"position");)i=i.offsetParent;return i||n}))},I.slice=function(e,t){return S(f.call(this,e,t))};var ae=/-([a-z])/g;function re(e){return e.replace(ae,(function(e,t){return t.toUpperCase()}))}I.ready=function(e){var i=function(){return setTimeout(e,0,S)};return"loading"!==t.readyState?i():t.addEventListener("DOMContentLoaded",i),this},I.unwrap=function(){return this.parent().each((function(e,t){if("BODY"!==t.tagName){var i=S(t);i.replaceWith(i.children())}})),this},I.offset=function(){var e=this[0];if(e){var t=e.getBoundingClientRect();return{top:t.top+i.pageYOffset,left:t.left+i.pageXOffset}}},I.position=function(){var e=this[0];if(e){var t="fixed"===$(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"===$(o,"position");)o=o.parentNode;if(o!==e&&_(o)){var s=S(o).offset();i.top-=s.top+M(o,"borderTopWidth"),i.left-=s.left+M(o,"borderLeftWidth")}}return{top:i.top-M(e,"marginTop"),left:i.left-M(e,"marginLeft")}}};var le={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};I.prop=function(e,t){if(e){if(O(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}},I.removeProp=function(e){return this.each((function(t,i){delete i[le[e]||e]}))};var ce=/^--/;function ue(e){return ce.test(e)}var de={},pe=s.style,he=["webkit","moz","ms"],me={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=ue(e)),i||me[e]||!k(t)?t:"".concat(t,"px")}function fe(e,t){try{return e(t)}catch(e){return t}}I.css=function(e,t){if(O(e)){var i=ue(e);return e=function(e,t){if(void 0===t&&(t=ue(e)),t)return e;if(!de[e]){var i=re(e),n="".concat(i[0].toUpperCase()).concat(i.slice(1));j("".concat(i," ").concat(he.join("".concat(n," "))).concat(n).split(" "),(function(t,i){if(i in pe)return de[e]=i,!1}))}return de[e]}(e,i),arguments.length<2?this[0]&&$(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[re(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)])}I.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(O(e))return arguments.length<2?this[0]&&ye(this[0],e):B(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},j([!0,!1],(function(e,t){j(["Width","Height"],(function(e,i){var n="".concat(t?"outer":"inner").concat(i);I[n]=function(n){if(this[0])return N(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?M(this[0],"margin".concat(e?"Top":"Left"))+M(this[0],"margin".concat(e?"Bottom":"Right")):0)}}))})),j(["Width","Height"],(function(e,t){var i=t.toLowerCase();I[i]=function(n){if(!this[0])return B(n)?void 0:this;if(!arguments.length)return N(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 s=$(n,"boxSizing");n.style[i]=ve(i,o+("border-box"===s?H(n,!e):0))}}))}}));var be="___cd";I.toggle=function(e){return this.each((function(i,n){if(_(n)){var s=Y(n);(B(e)?s:e)?(n.style.display=n[be]||"",Y(n)&&(n.style.display=function(e){if(q[e])return q[e];var i=o(e);t.body.insertBefore(i,null);var n=$(i,"display");return t.body.removeChild(i),q[e]="none"!==n?n:"block"}(n.tagName))):s||(n[be]=$(n,"display"),n.style.display="none")}}))},I.hide=function(){return this.toggle(!1)},I.show=function(){return this.toggle(!0)};var Ce="___ce",Ae={focus:"focusin",blur:"focusout"},Te={mouseenter:"mouseover",mouseleave:"mouseout"},xe=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Ie(e){return Te[e]||Ae[e]||e}function Se(e){var t=e.split(".");return[t[0],t.slice(1).sort()]}function Ee(e){return e[Ce]=e[Ce]||{}}function Ne(e,t){return!t||!g.call(t,(function(t){return e.indexOf(t)<0}))}function Fe(e,t,i,n,o){var s=Ee(e);if(t)s[t]&&(s[t]=s[t].filter((function(s){var a=s[0],r=s[1],l=s[2];if(o&&l.guid!==o.guid||!Ne(a,i)||n&&n!==r)return!0;e.removeEventListener(t,l)})));else for(t in s)Fe(e,t,i,n,o)}I.trigger=function(e,i){if(O(e)){var n=Se(e),o=n[0],s=n[1],a=Ie(o);if(!a)return this;var r=xe.test(a)?"MouseEvents":"HTMLEvents";(e=t.createEvent(r)).initEvent(a,!0,!0),e.namespace=s.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)}))},I.off=function(e,t,i){var n=this;if(B(e))this.each((function(e,t){(_(t)||F(t)||N(t))&&Fe(t)}));else if(O(e))P(t)&&(i=t,t=""),j(R(e),(function(e,o){var s=Se(o),a=s[0],r=s[1],l=Ie(a);n.each((function(e,n){(_(n)||F(n)||N(n))&&Fe(n,l,r,t,i)}))}));else for(var o in e)this.off(o,e[o]);return this},I.remove=function(e){return J(this,e).detach().off(),this},I.replaceWith=function(e){return this.before(e).remove()},I.replaceAll=function(e){return S(e).replaceWith(this),this},I.on=function(e,t,i,n,o){var s=this;if(!O(e)){for(var a in e)this.on(a,t,i,e[a],o);return this}return O(t)||(B(t)||V(t)?t="":B(i)?(i=t,t=""):(n=i,i=t,t="")),P(n)||(n=i,i=void 0),n?(j(R(e),(function(e,a){var r=Se(a),l=r[0],c=r[1],u=Ie(l),d=l in Te,p=l in Ae;u&&s.each((function(e,s){if(_(s)||F(s)||N(s)){var a=function(e){if(e.target["___i".concat(e.type)])return e.stopImmediatePropagation();if((!e.namespace||Ne(c,e.namespace.split(".")))&&(t||!(p&&(e.target!==s||e.___ot===u)||d&&e.relatedTarget&&s.contains(e.relatedTarget)))){var r=s;if(t){for(var l=e.target;!W(l,t);){if(l===s)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 s}}),Object.defineProperty(e,"data",{configurable:!0,get:function(){return i}});var h=n.call(r,e,e.___td);o&&Fe(s,u,c,t,a),!1===h&&(e.preventDefault(),e.stopPropagation())}};a.guid=n.guid=n.guid||S.guid++,function(e,t,i,n,o){var s=Ee(e);s[t]=s[t]||[],s[t].push([i,n,o]),e.addEventListener(t,o)}(s,u,c,t,a)}}))})),this):this},I.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,Oe=/radio|checkbox/i;I.serialize=function(){var e="";return this.each((function(t,i){j(i.elements||[i],(function(t,i){if(!(i.disabled||!i.name||"FIELDSET"===i.tagName||Pe.test(i.type)||Oe.test(i.type)&&!i.checked)){var n=ee(i);B(n)||j(c(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=S}()},558:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.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}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}","",{version:3,sources:["webpack://./css/hit-triage.css"],names:[],mappings:"AAAA;IACI,yBAAyB;IACzB,0BAA0B;AAC9B;;AAEA;IACI,aAAa;IACb,mBAAmB;IACnB,oBAAoB;AACxB;;AAEA;IACI,YAAY;IACZ,kCAAkC;IAClC,kBAAkB;IAClB,gBAAgB;IAChB,gBAAgB;IAChB,yBAAyB;IACzB,2BAA2B;AAC/B;;AAEA;IACI,oCAAoC;IACpC,yBAAyB;AAC7B;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,YAAY;IACZ,wBAAwB;AAC5B;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;IACjB,kBAAkB;AACtB;;AAEA;IACI,UAAU;IACV,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,iBAAiB;AACrB;;AAEA;IACI,aAAa;AACjB;;AAEA;IACI,iBAAiB;IACjB,2BAA2B;IAC3B,kBAAkB;AACtB;;;AAGA;IACI,sBAAsB;AAC1B;;AAEA;IACI,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;AACpB;;AAEA;IACI,iBAAiB;AACrB;;AAEA;IACI,kBAAkB;AACtB;;AAEA;CACC,gBAAgB;IACb,mBAAmB;IACnB,uBAAuB;CAC1B,iBAAiB;IACd,UAAU;AACd;;AAEA;CACC,cAAc;CACd,eAAe;CACf,iBAAiB;AAClB;;AAEA;CACC,mBAAmB;IAChB,gBAAgB;IAChB,uBAAuB;AAC3B",sourcesContent:[".grok-hit-triage-view .d4-grid {\n width: initial !important;\n height: initial !important;\n}\n\n.hit-triage-compute-dialog-pane-header {\n display: flex;\n align-items: center;\n justify-content: end;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header {\n border: none;\n border-left: 4px solid transparent;\n border-radius: 1px;\n padding: 4px 8px;\n min-height: 28px;\n justify-content: flex-end;\n flex-direction: row-reverse;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header.selected {\n border-left: 4px solid var(--blue-1);\n background-color: #f2f2f5;\n}\n\n.hit-triage-compute-dialog-host>.d4-tab-host.d4-tab-vertical>.d4-tab-header-stripe>.d4-tab-header.hit-triage-compute-dialog-pane-header>span {\n padding: 0 4px;\n}\n\ntable.hit-triage-table {\n margin: 10px;\n width: calc(100% - 20px);\n}\n\n.hit-triage-table-container {\n max-width: 600px;\n max-height: 500px;\n overflow-y: scroll;\n}\n\n.hit-triage-error-div {\n color: red;\n text-align: start;\n}\n\n.mx-5 {\n margin-left: 5px;\n margin-right: 5px;\n}\n\n.hit-triage-new-template-functions-input > .ui-box {\n height: 300px;\n}\n\n.hit-triage-new-template-functions-input {\n max-height: 200px;\n max-width: unset !important;\n overflow-y: scroll;\n}\n\n\n.hit-triage-new-template-functions-input > .d4-tab-host {\n width: 100% !important;\n}\n\n.hit-triage-compute-dialog-host {\n max-height: 550px;\n max-width: 800px;\n min-width: 550px;\n}\n\n.hit-triage-compute-dialog-descriptors-group {\n margin-left: 16px;\n}\n\n.oy-scroll {\n overflow-y: scroll;\n}\n\n.d4-ribbon-name .ui-breadcrumbs {\n\toverflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n\tflex-wrap: nowrap;\n padding: 0;\n}\n\n.d4-ribbon-name .ui-breadcrumbs i {\n\tpadding: 0 6px;\n\tfont-size: 10px;\n\tfont-weight: bold;\n}\n\n.d4-ribbon-name .ui-breadcrumbs-element:first-child {\n\twhite-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}"],sourceRoot:""}]);const r=a},677:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.push([e.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}"],sourceRoot:""}]);const r=a},542:(e,t,i)=>{"use strict";i.d(t,{A:()=>r});var n=i(354),o=i.n(n),s=i(314),a=i.n(s)()(o());a.push([e.id,"img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}","",{version:3,sources:["webpack://./src/app/hit-design-views/utils.css"],names:[],mappings:"AAAA;IACI,eAAe;AACnB",sourcesContent:["img[alt='hitDesignReadmeImg'] {\n max-width: 100%;\n}"],sourceRoot:""}]);const r=a},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,s){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(n)for(var r=0;r<this.length;r++){var l=this[r][0];null!=l&&(a[l]=!0)}for(var c=0;c<e.length;c++){var u=[].concat(e[c]);n&&a[u[0]]||(void 0!==s&&(void 0===u[5]||(u[1]="@layer".concat(u[5].length>0?" ".concat(u[5]):""," {").concat(u[1],"}")),u[5]=s),i&&(u[2]?(u[1]="@media ".concat(u[2]," {").concat(u[1],"}"),u[2]=i):u[2]=i),o&&(u[4]?(u[1]="@supports (".concat(u[4],") {").concat(u[1],"}"),u[4]=o):u[4]="".concat(o)),t.push(u))}},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),s="/*# ".concat(o," */");return[t].concat([s]).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 s={},a=[],r=0;r<e.length;r++){var l=e[r],c=n.base?l[0]+n.base:l[0],u=s[c]||0,d="".concat(c," ").concat(u);s[c]=u+1;var p=i(d),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)t[p].references++,t[p].updater(h);else{var m=o(h,n);n.byIndex=r,t.splice(r,0,{identifier:d,updater:m,references:1})}a.push(d)}return a}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 s=n(e=e||[],o=o||{});return function(e){e=e||[];for(var a=0;a<s.length;a++){var r=i(s[a]);t[r].references--}for(var l=n(e,o),c=0;c<s.length;c++){var u=i(s[c]);0===t[u].references&&(t[u].updater(),t.splice(u,1))}s=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 s=i.sourceMap;s&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(s))))," */")),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 s=t[n]={id:n,exports:{}};return e[n](s,s.exports,i),s.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,{_package:()=>He,demoFileIngest:()=>ze,demoFileIngest1:()=>Ke,demoFileIngest2:()=>Qe,demoFileSubmit:()=>Ze,gasteigerCellRenderer:()=>Xe,hitDesignApp:()=>Je,hitDesignAppTreeBrowser:()=>We,hitTriageApp:()=>Ye,hitTriageAppTreeBrowser:()=>qe});const e=grok,t=DG,o=ui,s="campaignId",a="campaignId",r="enriched_table.csv",l="campaign.json",c="HitTriageDataSource",u="HitTriageSubmitFunction",d="Selected hits",p="Stage",h="Molecule",m="V-iD",v="V######",f="HTScript",g="HTQuery",y="molecules",w="Source",b="New template",C="Start",A="Create",T="Download",x="Cancel",I="Continue a campaign",S="New campaign",E={script:"script",function:"function-package",query:"data-query"};var N=i(72),F=i.n(N),_=i(825),P=i.n(_),O=i(659),B=i.n(O),V=i(56),k=i.n(V),L=i(540),j=i.n(L),D=i(113),U=i.n(D),R=i(558),$={};$.styleTagTransform=U(),$.setAttributes=k(),$.insert=B().bind(null,"head"),$.domAPI=P(),$.insertStyleElement=j(),F()(R.A,$),R.A&&R.A.locals&&R.A.locals;var M=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};const H=e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`;function q(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 Y(t,i,n,s){var a;const r=o.breadcrumbs([i,n]),l=r.onPathClick.subscribe((e=>{1===e.length&&(l.unsubscribe(),W(t),s())})),c=null===(a=e.shell.v.ribbonMenu.root.parentElement)||void 0===a?void 0:a.getElementsByClassName("d4-ribbon-name")[0];return c&&(c.textContent="",c.appendChild(r.root)),{breadcrumbs:r,sub:l}}function W(e){const t=e.getRibbonPanels();(null==t?void 0:t.length)&&(t.pop(),e.setRibbonPanels(t))}function G(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 J(e,i,n){return M(this,void 0,void 0,(function*(){if(0===n.rowCount)return;if(!e.col(i))throw new Error("There is no molecule column in dataframe");let o=n.col(y);if(o||(yield n.meta.detectSemanticTypes(),o=n.columns.bySemType(t.SEMTYPE.MOLECULE)),!o)throw new Error("There is no original molecule column in query result dataframe");const s=n.columns.names().filter((e=>e!==y));e.join(n,[i],[o.name],void 0,s,void 0,!0)}))}function z(e,t){return M(this,void 0,void 0,(function*(){const i=(yield He.files.list(`${e}/campaigns`)).filter((e=>-1===t.indexOf(e.name))),n={};for(const t of i)try{const i=JSON.parse(yield He.files.readAsText(`${e}/campaigns/${t.name}/${l}`));if(i.authorUserId&&i.permissions&&!(yield Z(i.authorUserId,i.permissions)))continue;n[i.name]=i}catch(e){continue}return n}))}function K(i,n){return M(this,void 0,void 0,(function*(){var o;const s=t.User.current().id,a=null===(o=t.User.current().group)||void 0===o?void 0:o.id;if(i===s)return!0;const r=e.dapi.groups;for(const e of n){const t=yield r.find(e);if(t)if(t.personal){const e=yield r.getUser(t);if((null==e?void 0:e.id)===s)return!0}else if(a&&t.members.length>0&&t.members.some((e=>e.id===a)))return!0}return!1}))}function Q(e,t){return M(this,void 0,void 0,(function*(){return K(e,t.edit)}))}function Z(e,t){return M(this,void 0,void 0,(function*(){return K(e,Array.from(new Set([...t.view,...t.edit])))}))}const X={String:t.TYPE.STRING,Number:t.TYPE.FLOAT,Boolean:t.TYPE.BOOL,Date:t.TYPE.DATE_TIME,Molecule:t.SEMTYPE.MOLECULE};var ee=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))},te=i(233),ie=i.n(te),ne=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function oe(t,i,n,s,a){return ne(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,y,w,b,C,A,T,x,I,S,N,F,_;const P=yield t.computeFunctions,O=[];P.functions.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.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:{}})})),P.scripts.filter((({inputs:e})=>e.length>=2&&"dataframe"===e[0].propertyType&&"column"===e[1].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.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:{}})})),P.queries.filter((e=>e.inputs.length>0&&"list"===e.inputs[0].propertyType)).forEach((e=>{var t,i,n,o;O.push({func:e,args:null!==(o=null===(n=null===(i=null===(t=null==s?void 0:s.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:{}})}));let B=!!(null===(l=null===(r=null==s?void 0:s.compute)||void 0===r?void 0:r.descriptors)||void 0===l?void 0:l.enabled)||a;const V=o.div([],{classes:"hit-triage-compute-dialog-host"}),k=[],L=o.tree();try{const q=yield e.chem.descriptorsTree();function Y(e,t){const i=t.group(e,null,!1);return i.enableCheckBox(!1),i}L.root.classList.add("hit-triage-compute-dialog-descriptors-group");const W=Object.keys(q),G=null!==(d=null===(u=null===(c=null==s?void 0:s.compute)||void 0===c?void 0:c.descriptors)||void 0===u?void 0:u.args)&&void 0!==d?d:[];for(const J of W){const z=Y(J,L);for(const K of q[J].descriptors){const Q=z.item(K.name,K);k.push(Q),Q.enableCheckBox(G.includes(K.name))}}}catch(Z){console.error(Z),B=!1}const j="Descriptors",D={[j]:j},U=B?{[j]:L.root}:{},R={},$={[j]:!1};$[j]=!!(null===(h=null===(p=null==s?void 0:s.compute)||void 0===p?void 0:p.descriptors)||void 0===h?void 0:h.enabled)&&(null===(y=null===(v=null===(m=null==s?void 0:s.compute)||void 0===m?void 0:m.descriptors)||void 0===v?void 0:v.args)||void 0===y?void 0:y.length)>0;for(const X of O)try{const ee=X.func,te=ee.prepare(X.args),ne=ee.type===E.function?`${ee.package.name}:${ee.name}`:ee.type===E.script?`${f}:${null!==(w=ee.name)&&void 0!==w?w:""}:${ee.id}`:`${g}:${null!==(b=ee.name)&&void 0!==b?b:""}:${ee.id}`;R[ne]=te;const oe=o.div(),se=yield te.buildEditor(oe,{condensed:!1});oe.classList.add("oy-scroll"),oe.style.marginLeft="15px",oe.style.removeProperty("max-width"),U[null!==(C=ee.friendlyName)&&void 0!==C?C:ee.name]=oe,D[null!==(A=ee.friendlyName)&&void 0!==A?A:ee.name]=ne,$[ne]=null!==(_=(null===(x=null===(T=null==s?void 0:s.compute)||void 0===T?void 0:T.functions)||void 0===x?void 0:x.some((e=>{var t;return X.func.type===E.function&&e.name===X.func.name&&e.package===(null===(t=X.func.package)||void 0===t?void 0:t.name)})))||(null===(S=null===(I=null==s?void 0:s.compute)||void 0===I?void 0:I.scripts)||void 0===S?void 0:S.some((e=>e.id===ee.id)))||(null===(F=null===(N=null==s?void 0:s.compute)||void 0===N?void 0:N.queries)||void 0===F?void 0:F.some((e=>e.id===ee.id))))&&void 0!==_&&_,oe.children[0].style.display="none",ee.type!==E.query&&(oe.children[1].style.display="none"),se.forEach((e=>{var t,i;(null===(t=e.property)||void 0===t?void 0:t.name)&&Object.keys(X.args).includes(null===(i=e.property)||void 0===i?void 0:i.name)&&(e.value=X.args[e.property.name]),e.fireChanged()}))}catch(ae){console.error(ae);continue}const M=o.tabControl(U,!0);function H(){const e={descriptors:[],externals:{},scripts:{},queries:{}};e.descriptors=$[j]?k.filter((e=>e.checked)).map((e=>e.value.name)):[];const t=Object.entries(R).filter((([e,t])=>$[e]));t.filter((([e,t])=>!e.startsWith(f)&&!e.startsWith(g))).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(f))).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(g))).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 M.onTabChanged.subscribe((()=>{try{M.currentPane.content.style.removeProperty("max-width")}catch(e){}})),M.header.style.overflow="scroll",M.root.style.width="100%",M.root.style.minWidth="350px",V.appendChild(M.root),M.panes.forEach((e=>{const t=o.input.bool("",{value:$[D[e.name]],onValueChanged:i=>{$[D[e.name]]=!!t.value,i.value?ie()(e.content).find("input").removeAttr("disabled"):ie()(e.content).find("input").attr("disabled","true")}});t.setTooltip("Toggle calculation of this function"),e.header.appendChild(t.root),e.header.classList.add("hit-triage-compute-dialog-pane-header")})),a&&o.dialog("Compute").add(V).onOK((()=>H())).onCancel(n).show(),{root:V,okProxy:H}}))}const se=rxjs;class ae{constructor(e,t=[],i={}){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.properties=e,this.options=Object.assign(Object.assign({},this.options),i),this._root=o.divV([],{style:{display:"grid",gridTemplateColumns:`repeat(${this.properties.length}, 1fr)`,alignItems:"center",gap:"12px"},classes:"ui-items-grid"}),this._items=t,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,t,i,n,s;if(o.empty(this._root),!this.options.horizontalInputNames)for(const i of this.properties){let n=null!==(e=i.caption)&&void 0!==e?e:i.name;(null===(t=this.options.customLabels)||void 0===t?void 0:t[i.name])&&(n=this.options.customLabels[i.name]);const s=o.divText(n);s.style.fontWeight="bold",this._root.appendChild(s)}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!==(s=null===(n=(i=this.options).newItemFunction)||void 0===n?void 0:n.call(i))&&void 0!==s?s:void 0,!0);for(const t of e)this._root.appendChild(t)}}getItemDiv(e={},i){var n,s;const a=[],r={};let l=null;for(const c of this.properties){void 0===e[c.name]&&(e[c.name]=null);const u=(null===(n=this.options.customInputs)||void 0===n?void 0:n[c.name])?this.options.customInputs[c.name](e):o.input.forProperty(c,e),d=null===(s=this.options.validators)||void 0===s?void 0:s[c.name];d&&u.addValidator(d),a.push(this.options.horizontalInputNames?u.root:this.hideLabel(u.root)),c.propertyType!==t.TYPE.BOOL&&"color"!==c.name.toLowerCase()&&u.input&&(u.input.style.width="100%"),r[c.name]=u,u.onChanged((()=>{e[c.name]=u.value,i?this.onAddingItemChanged.next({item:e,fieldName:c.name}):this.onItemChanged.next({item:e,fieldName:c.name})})),u.root.style.alignItems="center",l=u}let c=null;if(i)c=o.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 a;c=o.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",a}hideLabel(e){return e.getElementsByTagName("label")[0]&&e.removeChild(e.getElementsByTagName("label")[0]),e}hasErrors(){return this._root.querySelectorAll(".d4-invalid").length>0}}var re=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function le(){const e=t.Property.fromOptions({name:"layout",caption:"Layout",type:"file"}),i=t.InputBase.forProperty(e);let n=null,o=null,s=null;return i.addValidator((e=>s)),i.onChanged((()=>re(this,void 0,void 0,(function*(){const e=i.value;if(e)try{const i=yield e.readAsString(),a=t.ViewLayout.fromJson(i);a?(n=a,o=a.viewState,s=null):(n=null,o=null,s="Invalid layout file")}catch(e){n=null,o=null,s="Invalid layout file"}i.setTooltip("Select a layout file")})))),{dataFileInput:i,getLayout:()=>n,getLayoutViewState:()=>o}}var ce=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function ue(i,n){return ce(this,void 0,void 0,(function*(){var s,a;const r=(yield He.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5))),l=[];for(const e of r){const t=JSON.parse(yield He.files.readAsText(`Hit Triage/templates/${e}.json`));l.push(t.key)}const d=t.Func.find({tags:[u]}),p={};d.forEach((e=>{var t;p[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const h=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(p)]});h.value=null,h.nullable=!0,h.fireChanged(),h.setTooltip("Select function to be called upon submitting");const m=le(),v=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),y=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),b=o.input.string("Name",{value:"",onValueChanged:()=>{""===b.value||r.includes(b.value)?(b.root.style.borderBottom="1px solid red",v.style.opacity="100%"):(b.root.style.borderBottom="none",v.style.opacity="0%")}}),C=o.input.string("Key",{value:"",onValueChanged:()=>{""===C.value||l.includes(C.value)?(C.root.style.borderBottom="1px solid red",y.style.opacity="100%"):(C.root.style.borderBottom="none",y.style.opacity="0%")}});C.setTooltip("Template key used for campaign prefix"),b.setTooltip("Template name"),b.root.style.borderBottom="none",C.root.style.borderBottom="none",v.style.opacity="0%",y.style.opacity="0%";let T=null;const I=yield oe(i,(e=>{T=e}),(()=>null),{compute:{descriptors:{enabled:!0,args:[]},functions:[]}},!1);I.root.classList.add("hit-triage-new-template-functions-input"),0===Object.entries(n).length&&t.Func.find({tags:[c]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const S=Object.keys(n),E=o.input.choice(w,{value:S[0],items:S}),N=o.input.choice("Ingest using",{value:"Query",items:["Query","File"],onValueChanged:()=>{"Query"!==N.value?E.root.style.display="none":E.root.style.display="block"}}),F=de(),_=o.div([o.h2("Details"),o.div([b,v]),o.div([C,y]),N.root,E.root,m.dataFileInput,F.fieldsDiv,o.h2("Compute"),I.root,o.h2("Submit"),h.root],"ui-form"),P=o.buttonsInput([]),O=null!==(a=null===(s=P.getElementsByClassName("ui-input-editor"))||void 0===s?void 0:s[0])&&void 0!==a?a:P;_.appendChild(P);const B=new Promise((e=>{const t=o.button(x,(()=>e()));O.appendChild(t)})),V=new Promise((t=>{const i=o.bigButton(A,(()=>function(){return ce(this,void 0,void 0,(function*(){var i,n,o,s,a,r,l,c;if(I.okProxy(),"100%"===v.style.opacity)return void e.shell.error("Template name is empty or already exists");const u=h.value?p[h.value]:void 0,d=Object.assign(Object.assign({name:b.value,key:C.value,campaignFields:F.getFields(),dataSourceType:null!==(i=N.value)&&void 0!==i?i:"Query",layoutViewState:null!==(n=m.getLayoutViewState())&&void 0!==n?n:void 0,compute:{descriptors:{enabled:!!(null===(o=null==T?void 0:T.descriptors)||void 0===o?void 0:o.length),args:null!==(s=null==T?void 0:T.descriptors)&&void 0!==s?s:[]},functions:Object.entries(null!==(a=null==T?void 0:T.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==T?void 0:T.scripts)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(f)&&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==T?void 0:T.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(g)&&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}}))}},u?{submit:{fName:u.name,package:u.package.name}}:{}),{queryFunctionName:"Query"===N.value&&null!==(c=E.value)&&void 0!==c?c:void 0});var y;y=d,He.files.writeAsText(`Hit Triage/templates/${y.name}.json`,JSON.stringify(y)),e.shell.info("Template created successfully"),t(d)}))}()));O.appendChild(i)}));return{root:_,template:V,cancelPromise:B}}))}function de(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING}),t.Property.fromOptions({name:"Type",type:t.TYPE.STRING,choices:Object.keys(X)}),t.Property.fromOptions({name:"Required",type:t.TYPE.BOOL})],n=new ae(i,e?e.map((e=>({Name:e.name,Type:e.type,Required:e.required}))):void 0,{horizontalInputNames:!1});n.root.style.maxWidth="750px";let s={};n.onItemAdded.subscribe((e=>{s={}})),n.onAddingItemChanged.subscribe((e=>{e&&(s=e.item)}));const a=o.h2("Additional fields");o.tooltip.bind(a,"Additional fields to be filled by user for each campaign");const r=o.div([a,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 s.Name&&""!==s.Name&&s.Type&&(null!==(e=s.Required)&&void 0!==e||(s.Required=!1),t.push({name:s.Name,type:s.Type,required:s.Required})),t},fieldsDiv:o.div([r])}}var pe=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class he extends t.ViewBase{constructor(e){super(),this.deletedCampaigns=[],this.app=e}get template(){return this.app.template}onActivated(){}onReset(){}process(){return pe(this,void 0,void 0,(function*(){}))}deleteCampaign(e,t){return pe(this,void 0,void 0,(function*(){yield He.files.delete(`${e}/campaigns/${t}`)}))}}var me=i(677),ve={};ve.styleTagTransform=U(),ve.setAttributes=k(),ve.insert=B().bind(null,"head"),ve.domAPI=P(),ve.insertStyleElement=j(),F()(me.A,ve),me.A&&me.A.locals&&me.A.locals;var fe;!function(t){let i,n;!function(e){e.vert=function(e){return o.divV(e.map((e=>o.render(e))),{classes:"u2-panel"})},e.horz=function(e){return o.divH(e.map((e=>o.render(e))),{classes:"u2-panel"})}}(i=t.panels||(t.panels={})),t.appHeader=function(e){const t=o.iconImage("",e.iconPath);return ie()(t).addClass("ui-app-header-icon").css("margin-right","20px"),i.horz([t,i.vert([o.markdown(e.description),e.learnMoreUrl?o.link("Learn more",e.learnMoreUrl):null])])},function(t){t.runAsync=function(t,i){return n=this,s=void 0,r=function*(){o.setUpdateIndicator(t,!0);try{return yield i()}catch(t){e.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((a=void 0)||(a=Promise))((function(e,t){function i(e){try{l(r.next(e))}catch(e){t(e)}}function o(e){try{l(r.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof a?n:new a((function(e){e(n)}))).then(i,o)}l((r=r.apply(n,s||[])).next())}));var n,s,a,r}}(n=t.tools||(t.tools={}))}(fe||(fe={}));var ge=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};const ye={view:[t.Group.defaultGroupsIds["All users"]],edit:[t.Group.defaultGroupsIds["All users"]]};class we{constructor(e){this.permissions=null!=e?e:ye,this.editGroupsInput=o.input.userGroups("Can Edit"),this.editGroupsInput.root.style.marginBottom="16px",this.viewGroupsInput=o.input.userGroups("Can View")}getDialogContent(){return ge(this,void 0,void 0,(function*(){const t=[],i=[];for(const i of this.permissions.view){const n=yield e.dapi.groups.find(i);n&&t.push(n)}for(const t of this.permissions.edit){const n=yield e.dapi.groups.find(t);n&&i.push(n)}return this.editGroupsInput.value=i,this.viewGroupsInput.value=t,o.divV([this.editGroupsInput.root,this.viewGroupsInput.root])}))}show(e){return ge(this,void 0,void 0,(function*(){var t;const i=yield this.getDialogContent(),n=o.dialog("Edit Permissions").add(i).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=ye.view),e(this.permissions)}));(null===(t=i.parentElement)||void 0===t?void 0:t.style)&&(i.parentElement.style.overflow="visible"),n.show()}))}}var be=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class Ce extends he{constructor(t){super(t),this.readmePath=He.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 be(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(I),i=o.h1(S,{style:{marginLeft:"10px"}}),n=fe.appHeader({iconPath:He.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 "}),s=o.div(),a=o.div([],{classes:"ui-form"}),r=yield this.getCampaignsTable();yield this.startNewCampaign(s,a,e),ie()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),r,i,a,s])),this.app.resetBaseUrl()}catch(e){throw o.setUpdateIndicator(this.root,!1),e}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(e,t,i){return be(this,void 0,void 0,(function*(){var n;const s=(yield He.files.list("Hit Triage/templates")).map((e=>e.name.slice(0,-5)));i&&!s.includes(i.name)&&s.push(i.name);const a=()=>be(this,void 0,void 0,(function*(){const t=r.value,n=i&&i.name===t?i:JSON.parse(yield He.files.readAsText("Hit Triage/templates/"+t+".json")),o=yield this.getNewCampaignAccordeon(n,e);ie()(e).empty(),e.className="ui-form",e.appendChild(o)})),r=o.input.choice("Template",{value:null!==(n=null==i?void 0:i.name)&&void 0!==n?n:s[0],items:s,onValueChanged:()=>be(this,void 0,void 0,(function*(){yield a()}))}),l=o.icons.add((()=>be(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0),yield this.createNewTemplate(),o.setUpdateIndicator(this.root,!1)}))),b);r.addOptions(l),yield a(),ie()(t).empty(),t.appendChild(r.root)}))}checkCampaign(e){return be(this,void 0,void 0,(function*(){const t=location.search,i=new URLSearchParams(t);if(!i.has(s)&&!e)return;const n=null!=e?e:i.get(s);if(!(yield He.files.exists(`Hit Triage/campaigns/${n}/${l}`)))return;const o=JSON.parse(yield He.files.readAsText(`Hit Triage/campaigns/${n}/${l}`));if(o){if(o.authorUserId&&o.permissions&&!(yield Z(o.authorUserId,o.permissions)))return void this.app.setBaseUrl();this.app.campaign=o}const a=JSON.parse(yield He.files.readAsText(`Hit Triage/templates/${o.templateName}.json`));return this.app.setTemplate(a,o.filters,n,o.ingest),e&&q(s,e),o}))}getCampaignsTable(){return be(this,void 0,void 0,(function*(){const e=yield z("Hit Triage",this.deletedCampaigns),i=e=>{var i,n;const s=o.icons.delete((()=>be(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${e.name}?`)).onOK((()=>be(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 s.style.display="none",Q(null!==(i=e.authorUserId)&&void 0!==i?i:t.User.current().id,null!==(n=e.permissions)&&void 0!==n?n:ye).then((e=>{e&&(s.style.display="inline-block")})),s},n=Object.values(e),s=o.table(n,(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.filteredRowCount,e.status,i(e)]),["Name","Created","Total","Selected","Status",""]);return s.style.color="var(--grey-5)",s}))}setCampaign(e){return be(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i,n){return be(this,void 0,void 0,(function*(){o.setUpdateIndicator(n,!0);const{root:s,promise:a,cancelPromise:r}=yield function(i,n){return ee(this,void 0,void 0,(function*(){var s,a;const r=o.divText("",{style:{color:"red"}});let l=null;const u=()=>ee(this,void 0,void 0,(function*(){try{if(l=d.value,!l)return;if(yield l.meta.detectSemanticTypes(),!l.columns.bySemType(t.SEMTYPE.MOLECULE))return void(r.innerText="No molecules column found");r.innerText=""}catch(e){r.innerText="Error parsing file"}})),d=o.input.table("Dataframe",{onValueChanged:u});yield u();const p=o.div([d,r]);0===Object.keys(n).length&&t.Func.find({tags:[c]}).forEach((e=>{var t;n[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));let h=null;const m=()=>ee(this,void 0,void 0,(function*(){const e=n[f.value];h=e.prepare();const t=yield h.getEditor();t.classList.remove("ui-form"),v.innerHTML="",v.appendChild(t)})),v=o.div([]),f=o.input.choice(w,{value:null!==(s=i.queryFunctionName)&&void 0!==s?s:Object.keys(n)[0],items:Object.keys(n),onValueChanged:m});yield m(),i.queryFunctionName&&(null===(a=f.root.getElementsByTagName("select").item(0))||void 0===a||a.setAttribute("disabled","true"));const g=o.div([f,v]);g.style.display="none";const y=o.div([p,g]),b=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:X[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),A={},T=b.length?o.input.form(A,b):o.div();T.classList.remove("ui-form"),"File"===i.dataSourceType?(p.style.display="inherit",g.style.display="none"):(p.style.display="none",g.style.display="inherit");const I=o.div([y,...b.length?[T]:[]]),S=o.buttonsInput([]);return I.appendChild(S),{promise:new Promise((t=>{const s=()=>ee(this,void 0,void 0,(function*(){if("File"===i.dataSourceType){if(!l)return void e.shell.error("No file selected");const i=l;i.name=l.name,t({df:i,type:"File",campaignProps:A})}else{const i=n[f.value];if(!i)return void e.shell.error("No function selected");const o={};Object.entries(h.inputs).forEach((([e,t])=>{o[e]=t}));const s=yield i.apply(o);t({df:s,type:"Query",campaignProps:A})}})),a=o.bigButton(C,(()=>s()));S.appendChild(a)})),root:I,cancelPromise:new Promise((e=>{o.button(x,(()=>e()))}))}}))}(i,this.dataSourceFunctionsMap);return o.setUpdateIndicator(n,!1),a.then((e=>be(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)})))),r.then((()=>{this.init()})),s}))}createNewTemplate(){return be(this,void 0,void 0,(function*(){const i=yield ue(this.app,this.dataSourceFunctionsMap),n=new t.ViewBase,o=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=o;const{sub:s}=Y(e.shell.v,"Hit Triage",b,(()=>{e.shell.v=o,n.close()}));i.template.then((t=>be(this,void 0,void 0,(function*(){yield this.init(t),n.close(),W(n),e.shell.v=o,s.unsubscribe()})))),i.cancelPromise.then((()=>{s.unsubscribe(),n.close(),e.shell.v=o}))}))}}class Ae extends he{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,s=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const s=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:s,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function a(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 o?i:new o((function(e){e(i)}))).then(a,r)}l((s=s.apply(i,n||[])).next())}));var i,n,o,s}}var Te=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class xe{constructor(e){this.parentCall=e,this.isJoining=!1,this.hasEditPermission=!1,this.resetBaseUrl(),this.computeFunctions=new Promise((e=>Te(this,void 0,void 0,(function*(){const i=t.Func.find({tags:["HitTriageFunction"]}),n=i.filter((e=>e.type===E.function)),o=i.filter((e=>e.type===E.script)),s=i.filter((e=>e.type===E.query));e({functions:n,scripts:o,queries:s})}))))}setCanEdit(e){return Te(this,void 0,void 0,(function*(){e.authorUserId&&e.permissions?this.hasEditPermission=yield Q(e.authorUserId,e.permissions):this.hasEditPermission=!0}))}resetBaseUrl(){const e=window.location.href,t=new URL(e);this.baseUrl=t.origin+t.pathname}getFilterType(e){const i=this.dataFrame.col(e);return(null==i?void 0:i.semType)===t.SEMTYPE.MOLECULE?t.FILTER_TYPE.SUBSTRUCTURE:(null==i?void 0:i.type)===t.COLUMN_TYPE.BOOL?t.FILTER_TYPE.BOOL_COLUMNS:(null==i?void 0:i.type)===t.COLUMN_TYPE.STRING?t.FILTER_TYPE.CATEGORICAL:t.FILTER_TYPE.HISTOGRAM}download(e,i,n=!1){const o=document.createElement("a"),s=t.DataFrame.fromColumns(e.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv({filteredRowsOnly:n});o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(s)),o.setAttribute("download",i+".csv"),o.click()}getNewCampaignName(e,t){return Te(this,void 0,void 0,(function*(){const i=(yield He.files.list(e)).map((e=>e.name)).filter((e=>e.startsWith(t)));if(0===i.length)return t+"-1";const n=i.map((e=>e.split("-")[1])).filter(Boolean).map((e=>parseInt(e,10))).sort();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,i,n){var o,s,a,r,l;const c=null===(s=null===(o=e.col(n))||void 0===o?void 0:o.toList())||void 0===s?void 0:s.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles))),u=null===(r=null===(a=i.col(n))||void 0===a?void 0:a.toList())||void 0===r?void 0:r.filter((e=>!!e)).map((e=>t.chem.convert(e,t.chem.Notation.Unknown,t.chem.Notation.Smiles)));if(!c||!u)throw new Error("Molecule column not found");this.isJoining=!0;try{for(const t of e.columns)i.columns.contains(t.name)||i.columns.addNew(t.name,t.type);for(let t=0;t<c.length;t++)if(!u.includes(c[t])){i.rows.addNew(null,!0);for(const n of e.columns){const e=n.get(t);null===(l=i.col(n.name))||void 0===l||l.set(i.rowCount-1,e,!1)}}}finally{setTimeout((()=>{this.isJoining=!1}),500)}return i}}var Ie=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))},Se=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function Ee(e){let t=0;if(e.length>1)for(const i of e.toList()){if(!i||!i.startsWith(v[0])||7!==i.length)continue;const e=parseInt(i.substring(1));isNaN(e)||(t=Math.max(e,t))}return`V${"".concat(...new Array(6-(t+1).toString().length).fill("0"))}${t+1}`}function Ne(i,n,o){return Se(this,void 0,void 0,(function*(){var s,a;const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=n.col(o);if(!l)throw new Error("There is no molecule column in dataframe");for(let t=0;t<l.length;t++){if(l.isNone(t))continue;const i=l.get(t);if(!i)continue;const n=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles);l.set(t,n,!1)}try{i.descriptors&&i.descriptors.length>0&&(yield e.chem.descriptors(n,o,i.descriptors))}catch(e){console.error("Descriptors calculation error",e)}for(const e of Object.keys(i.externals))try{const s=i.externals[e],a=t.Func.find({package:e.split(":")[0],name:e.split(":")[1]})[0],r=a.inputs[0].name,l=a.inputs[1].name;s&&(yield a.apply(Object.assign(Object.assign({},s),{[r]:n,[l]:o})))}catch(e){console.error(e)}for(const e of Object.keys(null!==(s=i.scripts)&&void 0!==s?s:{})){const s=i.scripts[e];if(s){const i=e.split(":"),a=i[2];if(!a)continue;try{const e=i[1],r=t.Func.find({name:e}).filter((e=>e.type===E.script&&e.id===a))[0];if(!r)continue;const l=r.inputs[0].name,c=r.inputs[1].name,u=yield r.apply(Object.assign(Object.assign({},s),{[l]:n,[c]:o}));if(u&&u.rowCount===n.rowCount&&"python"===r.language)for(const e of u.columns)e.name=n.columns.getUnusedName(e.name),n.columns.add(e)}catch(e){console.error(e)}}}for(const e of Object.keys(null!==(a=i.queries)&&void 0!==a?a:{})){const s=i.queries[e];if(s){const i=e.split(":"),a=i[2];if(!a)continue;try{const e=i[1],r=t.Func.find({name:e}).filter((e=>e.type===E.query&&e.id===a))[0];if(!r)continue;const l=r.inputs[0].name,c=n.col(o).toList(),u=yield r.apply(Object.assign(Object.assign({},s),{[l]:c}));u&&(yield J(n,o,u))}catch(e){console.error(e)}}}r.close()}))}var Fe=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class _e extends xe{get infoView(){return this._infoView}constructor(i){super(i),this._filterViewName="Hit triage | Pick",this._filterDescriptions=[],this.campaignProps={},this._pickViewPromise=null,this._infoView=new Ce(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof he&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,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(),q(s,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)}}))}setTemplate(i,n,o,a){return Fe(this,void 0,void 0,(function*(){var r,l,c,u,d,p,h,m,v,y,w,b,C,A,T;if((null===(r=this._pickView)||void 0===r?void 0:r.dataFrame)&&e.shell.closeTable(null===(l=this._pickView)||void 0===l?void 0:l.dataFrame),this._pickView=void 0,o?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)):(o=yield this.getNewCampaignName("Hit Triage/campaigns",i.key),q(s,o)),!this.dataFrame)return void console.error("Dataframe is empty.");if((null===(c=this._campaign)||void 0===c?void 0:c.columnSemTypes)&&Object.entries(this._campaign.columnSemTypes).forEach((([e,t])=>{const i=this.dataFrame.columns.byName(e);i&&i.semType!==t&&(i.semType=t)})),(null===(u=this._campaign)||void 0===u?void 0:u.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===(d=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===d?void 0:d.name)&&void 0!==p?p:void 0,this._dfName=null!==(h=this.dataFrame.name)&&void 0!==h?h:null==a?void 0:a.query,this.dataFrame.name=null!==(v=null!==(m=this._dfName)&&void 0!==m?m:this.dataFrame.name)&&void 0!==v?v:"Molecules",this._campaignId=o,this.template=(null===(y=this.campaign)||void 0===y?void 0:y.template)?Object.assign(Object.assign({},this.campaign.template),{dataSourceType:i.dataSourceType,queryFunctionName:i.queryFunctionName}):i,this._campaignFilters=n,!n){const e={},t={},n={};i.compute.functions.forEach((t=>{const i=`${t.package}:${t.name}`;e[i]=t.args})),null===(w=i.compute.scripts)||void 0===w||w.forEach((e=>{const i=`${f}:${e.name}:${e.id}`;t[i]=e.args})),null===(b=i.compute.queries)||void 0===b||b.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;n[t]=e.args})),yield Ne({descriptors:i.compute.descriptors.enabled?i.compute.descriptors.args:[],externals:e,scripts:t,queries:n},this.dataFrame,this._molColName)}this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0;const x=e.shell.v,I=e.shell.addView(this.pickView);this.currentPickViewId=I.name,this._submitView=new Ae(this),this.setBaseUrl(),q(s,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 S=I;setTimeout((()=>{this._pickViewPromise&&this._pickViewPromise.then((()=>{const{sub:t}=Y(S,"Hit Triage","Pick",(()=>{e.shell.v=x,S.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,i,n;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.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(d)||this.dataFrame.columns.addNewBool(d).init(!1);const i=t.TableView.create(this.dataFrame,!1),n=i.getRibbonPanels(),s=o.iconFA("wrench",(()=>Fe(this,void 0,void 0,(function*(){oe(this,(e=>Fe(this,void 0,void 0,(function*(){var t,i,n,o,s,a,r;const l=this.template.compute.descriptors.args,c=this.template.compute.functions,u=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],d=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],p=e.descriptors,h={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!==(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!==(a=null==e?void 0:e.scripts)&&void 0!==a?a:{}).filter((([e,t])=>e.startsWith(f)&&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(g)&&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=h;const m=p.filter((e=>!l.includes(e))),v=h.functions.filter((e=>{if(!c.some((t=>t.name===e.name&&t.package===e.package)))return!0;const t=c.find((t=>t.name===e.name&&t.package===e.package));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),y=h.scripts.filter((e=>{if(!u.some((t=>t.id===e.id)))return!0;const t=u.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),w=h.queries.filter((e=>{if(!d.some((t=>t.id===e.id)))return!0;const t=d.find((t=>t.id===e.id));return!Object.entries(e.args).every((([e,i])=>t.args[e]===i))})),b={};v.forEach((e=>{const t=`${e.package}:${e.name}`;b[t]=e.args}));const C={};y.forEach((e=>{const t=`${f}:${e.name}:${e.id}`;C[t]=e.args}));const A={};w.forEach((e=>{const t=`${g}:${e.name}:${e.id}`;A[t]=e.args})),yield Ne({descriptors:m,externals:b,scripts:C,queries:A},this.dataFrame,this._molColName),this.saveCampaign("In Progress",!1)}))),(()=>null),this.template,!0)}))),"Calculate additional properties"),a=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}})),r=o.iconFA("share",(()=>Fe(this,void 0,void 0,(function*(){var e;yield new we(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)}))}))),"Edit permissions");a.classList.add("hit-design-submit-button");const l=G(n);return n.push([s,...this.hasEditPermission?[r]:[],...l?[]:[a]]),i.setRibbonPanels(n),i.name=this._filterViewName,setTimeout((()=>Fe(this,void 0,void 0,(function*(){var n,o,s;i._onAdded(),yield new Promise((e=>setTimeout(e,1e3)));const a=i.filters(this._campaignFilters?{filters:this._campaignFilters}:void 0),r=null!==(o=null===(n=this._campaign)||void 0===n?void 0:n.layout)&&void 0!==o?o:null===(s=this.template)||void 0===s?void 0:s.layoutViewState;if(r)try{const e=t.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=a.getOptions().look.filters})),setTimeout((()=>{this._filterDescriptions=Array.from(i.dataFrame.rows.filters),this._campaignFilters=a.getOptions().look.filters}),300),e&&e()}))),300),i.parentCall=this.parentCall,i}getSummary(){var e,t,i,n,s,a,r;const l=null!==(t=null===(e=this.campaign)||void 0===e?void 0:e.campaignFields)&&void 0!==t?t:this.campaignProps;return Object.assign(Object.assign({Template:null!==(n=null===(i=this.template)||void 0===i?void 0:i.name)&&void 0!==n?n:"Molecules","File path":o.divH([o.link(null!==(s=this._dfName)&&void 0!==s?s:"-",(()=>this.download(this.dataFrame,"molecules")),T)],{style:{alignItems:"center"}})},l),{"Number of molecules":this.dataFrame.rowCount.toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", "),Filters:this._filterDescriptions.join(", "),"Result Molecules":o.divH([o.link(null!==(r=null===(a=this.dataFrame)||void 0===a?void 0:a.filter.trueCount.toString())&&void 0!==r?r:"0",(()=>{this.download(this.dataFrame,"hits",!0)}),T)],{style:{alignItems:"center"}})})}saveCampaign(i){return Fe(this,arguments,void 0,(function*(i,n=!0){var s,a,c,u,d,p,h,m,v,f;const g=this.campaignId,y=this.filterSettings,w=this.template.name,b=this.dataFrame,C=`System:AppData/HitTriage/Hit Triage/campaigns/${g}/`,A=null!=g?g:yield function(e){return Ie(this,void 0,void 0,(function*(){return new Promise((t=>Ie(this,void 0,void 0,(function*(){const i=o.input.string("Campaign name",{value:""});o.dialog("Save Campaign").add(o.div(i.root)).onOK((function(){i.value&&""!==i.value?t(i.value):t(e)})).show()}))))}))}(g),T={};b.columns.toList().forEach((e=>T[e.name]=e.semType));const x={};b.columns.toList().forEach((e=>x[e.name]=e.type));const I=null!==(a=null===(s=this.campaign)||void 0===s?void 0:s.authorUserId)&&void 0!==a?a:e.shell.user.id,S=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.permissions)&&void 0!==u?u:ye,E={name:A,templateName:w,filters:null!=y?y:{},ingest:{type:"File",query:`${C}${r}`,molColName:this.molColName},status:null!==(p=null!=i?i:null===(d=this.campaign)||void 0===d?void 0:d.status)&&void 0!==p?p:"In Progress",createDate:null!==(m=null===(h=this.campaign)||void 0===h?void 0:h.createDate)&&void 0!==m?m:H(new Date),campaignFields:null!==(f=null===(v=this.campaign)||void 0===v?void 0:v.campaignFields)&&void 0!==f?f:this.campaignProps,columnSemTypes:T,rowCount:b.rowCount,filteredRowCount:b.filter.trueCount,template:this.template,columnTypes:x,authorUserId:I,permissions:S};if(this.campaign=E,!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),E;const N=t.DataFrame.fromColumns(b.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield He.files.writeAsText(`Hit Triage/campaigns/${g}/${r}`,N);const F=this._pickView.saveLayout();return F?E.layout=F.viewState:e.shell.warning("Layout cound not be saved"),yield He.files.writeAsText(`Hit Triage/campaigns/${g}/${l}`,JSON.stringify(E)),n&&e.shell.info("Campaign saved successfully."),E}))}}var Pe=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};function Oe(i,n){return Pe(this,void 0,void 0,(function*(){var s,a,r,l,c,d,p,h,m,v,y;const w=yield He.files.list("Hit Design/templates");let b=!1,C=!1;const T=w.map((e=>e.name.slice(0,-5))),I=[];for(const e of w)try{const t=JSON.parse(yield He.files.readAsText(e));I.push(t.key)}catch(e){console.error(e)}const S=t.Func.find({tags:[u]}),E={};S.forEach((e=>{var t;E[null!==(t=e.friendlyName)&&void 0!==t?t:e.name]=e}));const N=o.input.choice("Submit function",{value:null,items:[null,...Object.keys(E)]});N.nullable=!0,N.value=null!==(a=null===(s=null==n?void 0:n.submit)||void 0===s?void 0:s.fName)&&void 0!==a?a:null,N.setTooltip("Select function to be called upon submitting");const F=o.divText("Template name is empty or already exists",{classes:"hit-triage-error-div"}),_=o.divText("Template key is empty or already exists",{classes:"hit-triage-error-div"}),P=le();function O(){var e,t,i,n;if(""===B.value||T.includes(null!==(t=null===(e=B.value)||void 0===e?void 0:e.trim())&&void 0!==t?t:"")){const e=null!==(i=B.input.offsetLeft)&&void 0!==i?i:0,t=null!==(n=B.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 B=o.input.string("Name",{value:null!==(r=null==n?void 0:n.name)&&void 0!==r?r:"",onValueChanged:O});function V(){var e,t,i,n;if(""===k.value||I.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=o.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"),B.setTooltip("Template name"),B.root.style.borderBottom="none",k.root.style.borderBottom="none",F.style.opacity="0%",_.style.opacity="0%";let L=null;const j={compute:{descriptors:{enabled:!0,args:null!==(p=null===(d=null===(c=null==n?void 0:n.compute)||void 0===c?void 0:c.descriptors)||void 0===d?void 0:d.args)&&void 0!==p?p:[]},functions:null!==(m=null===(h=null==n?void 0:n.compute)||void 0===h?void 0:h.functions)&&void 0!==m?m:[]}},D=yield oe(i,(e=>{L=e}),(()=>null),j,!1);D.root.classList.add("hit-triage-new-template-functions-input");const U=de(null==n?void 0:n.campaignFields),R=function(e){const i=[t.Property.fromOptions({name:"Name",type:t.TYPE.STRING})],n=new ae(i,e?e.map((e=>({Name:e}))):void 0,{horizontalInputNames:!0});let o={};return n.onItemAdded.subscribe((e=>{o={}})),n.onAddingItemChanged.subscribe((e=>{e&&(o=e.item)})),{getFields:function(){const e=n.items.filter((e=>e.Name)).map((e=>e.Name));return o.Name&&""!==o.Name&&e.push(o.Name),e},fieldsDiv:n.root}}(null==n?void 0:n.stages),$=o.divV([o.divV([B,F]),o.divV([k,_]),P.dataFileInput,U.fieldsDiv]),M=o.h2("Stages");o.tooltip.bind(M,'Define Stages for designed molecules. For example, "Design", "Synthesis", "Test", etc.');const H=o.h2("Compute");o.tooltip.bind(H,'Define functions to be calculated for each molecule. For example, "Descriptors", "Descriptors:Descriptors", etc.');const q=o.div([o.h2("Details"),$,M,R.fieldsDiv,H,D.root,o.h2("Submit"),N.root],"ui-form"),Y=o.buttonsInput([]);q.appendChild(Y);const W=null!==(y=null===(v=Y.getElementsByClassName("ui-input-editor"))||void 0===v?void 0:v[0])&&void 0!==y?y:Y,G=new Promise((e=>{const t=o.button(x,(()=>e()));W.appendChild(t)})),J=new Promise((t=>{const i=o.bigButton(A,(()=>function(){return Pe(this,void 0,void 0,(function*(){var i,n,o,s,a,r;if(O(),V(),D.okProxy(),b||!B.value||""===B.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 l=N.value?E[N.value]:void 0,c=Object.assign({name:B.value,key:k.value,campaignFields:U.getFields(),stages:R.getFields(),layoutViewState:null!==(i=P.getLayoutViewState())&&void 0!==i?i:void 0,compute:{descriptors:{enabled:!!(null===(n=null==L?void 0:L.descriptors)||void 0===n?void 0:n.length),args:null!==(o=null==L?void 0:L.descriptors)&&void 0!==o?o:[]},functions:Object.entries(null!==(s=null==L?void 0:L.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!==(a=null==L?void 0:L.scripts)&&void 0!==a?a:{}).filter((([e,t])=>e.startsWith(f)&&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==L?void 0:L.queries)&&void 0!==r?r:{}).filter((([e,t])=>e.startsWith(g)&&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}}))}},l?{submit:{fName:l.name,package:l.package.name}}:{});var u;u=c,He.files.writeAsText(`Hit Design/templates/${u.name}.json`,JSON.stringify(u)),e.shell.info("Template created successfully"),t(c)}))}()));W.appendChild(i)}));return{root:q,template:J,cancelPromise:G}}))}var Be=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class Ve extends he{constructor(t){super(t),this.name="Hit Design",e.shell.windows.showHelp=!0,e.shell.windows.help.showHelp(He.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(He.webRoot+"README_HD.md")}init(e){return Be(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const t=o.h1(I),i=o.h1(S,{style:{marginLeft:"10px"}}),n=fe.appHeader({iconPath:He.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"}),s=o.div(),a=o.divH([]),r=o.div([a,s],"ui-form"),l=yield this.getCampaignsTable();ie()(this.root).empty(),this.root.appendChild(o.div([o.divV([n,t],{style:{marginLeft:"10px"}}),l,i,r])),yield this.startNewCampaign(s,a,e),this.app.resetBaseUrl()}finally{o.setUpdateIndicator(this.root,!1)}}))}startNewCampaign(t,i,n){return Be(this,void 0,void 0,(function*(){var s;const a=(yield He.files.list("Hit Design/templates")).filter((e=>e.name.endsWith(".json"))).map((e=>e.name.slice(0,-5)));n&&!a.includes(n.name)&&a.push(n.name);let r=null,l=!0;const c=()=>Be(this,void 0,void 0,(function*(){if(!l)return;const e=u.value,i=n&&n.name===e?n:JSON.parse(yield He.files.readAsText("Hit Design/templates/"+e+".json"));r=i;const o=yield this.getNewCampaignAccordeon(i);ie()(t).empty(),t.appendChild(o)})),u=o.input.choice("Template",{value:null!==(s=null==n?void 0:n.name)&&void 0!==s?s:a[0],items:a,onValueChanged:()=>Be(this,void 0,void 0,(function*(){yield c()}))});u.root.style.width="100%";const d=o.icons.add((()=>{this.createNewTemplate()}),b),p=o.icons.copy((()=>{r&&this.createNewTemplate(r)}),"Clone template"),h=o.icons.delete((()=>{!u.value||u.items.length<2||o.dialog("Delete template").add(o.divText(`Are you sure you want to delete template ${u.value}?`)).onOK((()=>Be(this,void 0,void 0,(function*(){try{const t=u.value;yield He.files.delete(`Hit Design/templates/${t}.json`),l=!1,u.items=u.items.filter((e=>e!==t)),u.value=u.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 "+u.value),console.error(t)}})))).show()}),"Delete template");d.style.color="#2083d5",u.addOptions(h),u.addOptions(p),u.addOptions(d),yield c(),ie()(i).empty(),i.appendChild(u.root)}))}checkCampaign(e){return Be(this,void 0,void 0,(function*(){var t;const i=location.search,n=new URLSearchParams(i);if(!n.has(a)&&!e)return;const o=null!=e?e:n.get(a);if(!(yield He.files.exists(`Hit Design/campaigns/${o}/${l}`)))return;const s=JSON.parse(yield He.files.readAsText(`Hit Design/campaigns/${o}/${l}`));if(s){if(s.authorUserId&&s.permissions&&!(yield Z(s.authorUserId,s.permissions)))return void this.app.setBaseUrl();this.app.campaign=s}const r=null!==(t=s.template)&&void 0!==t?t:JSON.parse(yield He.files.readAsText(`Hit Design/templates/${s.templateName}.json`));return yield this.app.setTemplate(r,o),e&&q(a,e),s.template=r,s}))}getCampaignsTable(){return Be(this,void 0,void 0,(function*(){const i=yield z("Hit Design",this.deletedCampaigns),n=i=>{var n,s;const a=o.icons.delete((()=>Be(this,void 0,void 0,(function*(){o.dialog("Delete campaign").add(o.divText(`Are you sure you want to delete campaign ${i.name}?`)).onOK((()=>Be(this,void 0,void 0,(function*(){yield this.deleteCampaign("Hit Design",i.name),this.deletedCampaigns.push(i.name),yield this.init()})))).show()}))),"Delete campaign"),r=o.iconFA("share",(()=>Be(this,void 0,void 0,(function*(){yield new we(i.permissions).show((t=>Be(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 He.files.writeAsText(`Hit Design/campaigns/${i.name}/${l}`,JSON.stringify(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 a.style.display="none",r.style.display="none",Q(null!==(n=i.authorUserId)&&void 0!==n?n:t.User.current().id,null!==(s=i.permissions)&&void 0!==s?s:ye).then((e=>{e&&(a.style.display="inline-block",r.style.display="inline-block")})),[r,a]},s=o.table(Object.values(i),(e=>[o.link(e.name,(()=>this.setCampaign(e.name)),"",""),e.createDate,e.rowCount,e.status,...n(e)]),["Name","Created","Molecules","Status",""]);return s.style.color="var(--grey-5)",s.style.marginLeft="24px",s}))}setCampaign(e){return Be(this,void 0,void 0,(function*(){const t=yield this.checkCampaign(e);this.app.campaign=t}))}getNewCampaignAccordeon(i){return Be(this,void 0,void 0,(function*(){const{root:n,promise:s,cancelPromise:a}=function(i){var n,s;const a=t.DataFrame.create(1),r=a.columns.addNew(h,t.TYPE.STRING);r.semType=t.SEMTYPE.MOLECULE,r.meta.units=t.UNITS.Molecule.SMILES,r.set(0,null),(null===(n=null==i?void 0:i.stages)||void 0===n?void 0:n.length)>0&&a.columns.addNew(p,t.TYPE.STRING).set(0,i.stages[0]);const l=a.columns.addNew(m,t.TYPE.STRING);l.set(0,Ee(l));const c=i.campaignFields.map((e=>e.type===t.SEMTYPE.MOLECULE?Object.assign(Object.assign({},e),{type:"String",semtype:t.SEMTYPE.MOLECULE}):e)).map((e=>t.Property.fromOptions(Object.assign({name:e.name,type:X[e.type],nullable:!e.required},e.semtype?{semType:e.semtype}:{})))),u={},d=o.input.form(u,c);d.classList.remove("ui-form");const v=o.div([...(null===(s=i.campaignFields)||void 0===s||s.length,[]),d]),f=o.buttonsInput([]);return v.appendChild(f),{promise:new Promise((t=>{const n=o.bigButton(C,(()=>{for(const t of i.campaignFields)if(t.required&&(!u[t.name]||""===u[t.name]))return void e.shell.error(`Field '${t.name}' is required`);t({df:a,campaignProps:u})}));f.appendChild(n)})),root:v,cancelPromise:new Promise((e=>{o.button(x,(()=>e()))}))}}(i);return s.then((e=>Be(this,void 0,void 0,(function*(){this.app.dataFrame=e.df,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)})))),a.then((()=>{this.init()})),n}))}createNewTemplate(i){return Be(this,void 0,void 0,(function*(){o.setUpdateIndicator(this.root,!0);try{const n=yield Oe(this.app,i),o=new t.ViewBase,s=e.shell.v;o.name="New Template",o.root.appendChild(n.root),o.parentCall=this.app.parentCall,e.shell.addView(o),o.path=new URL(this.app.baseUrl).pathname+"/new-template";const{sub:a}=Y(o,"Hit Design",b,(()=>Be(this,void 0,void 0,(function*(){e.shell.v=s,o.close()}))));n.template.then((t=>Be(this,void 0,void 0,(function*(){yield this.init(t),o.close(),W(o),e.shell.v=s,a.unsubscribe()})))),n.cancelPromise.then((()=>Be(this,void 0,void 0,(function*(){a.unsubscribe(),o.close(),e.shell.v=s}))))}finally{o.setUpdateIndicator(this.root,!1)}}))}}class ke extends he{constructor(e){super(e),this.name="Submit"}render(){return o.empty(this.root),o.divV([o.h1("Summary"),o.div([o.tableFromMap(this.app.getSummary())])])}onActivated(){this.render()}submit(){return i=this,n=void 0,s=function*(){var i;const n=null===(i=this.app.template)||void 0===i?void 0:i.submit;if(!n)return;const o=t.Func.find({name:n.fName,package:n.package})[0];if(!o)return void e.shell.error(`Function ${n.fName} not found.`);const s=t.DataFrame.fromCsv(this.app.dataFrame.toCsv({filteredRowsOnly:!0}));yield o.apply({df:s,molecules:this.app.molColName}),this.app.campaign&&(this.app.campaign.status="Submitted"),this.app.saveCampaign("Submitted"),e.shell.info("Submitted successfully.")},new((o=void 0)||(o=Promise))((function(e,t){function a(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 o?i:new o((function(e){e(i)}))).then(a,r)}l((s=s.apply(i,n||[])).next())}));var i,n,o,s}}var Le=i(542),je={};je.styleTagTransform=U(),je.setAttributes=k(),je.insert=B().bind(null,"head"),je.domAPI=P(),je.insertStyleElement=j(),F()(Le.A,je),Le.A&&Le.A.locals&&Le.A.locals;const De=rxjs.operators;var Ue=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};class Re extends xe{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(i){super(i),this._designViewName="Design",this._filePath="System.AppData/HitTriage/Hit Design/campaigns",this._molColName=h,this.campaignProps={},this.processedValues=[],this._extraStageColsCount=0,this._infoView=new Ve(this),this.multiView=new t.MultiView({viewFactories:{[this._infoView.name]:()=>this._infoView}}),this.multiView.tabs.onTabChanged.subscribe((e=>{this.multiView.currentView instanceof he&&this.multiView.currentView.onActivated()})),this.multiView.parentCall=i,this.mainView=this.multiView,e.events.onCurrentViewChanged.subscribe((()=>Ue(this,void 0,void 0,(function*(){var t,i,n,o,a;try{if((null===(t=e.shell.v)||void 0===t?void 0:t.name)===this.currentDesignViewId){e.shell.windows.showHelp=!1,this.setBaseUrl(),q(s,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:"");const{sub:t}=Y(e.shell.v,"Hit Design",null===(a=e.shell.v)||void 0===a?void 0:a.name,(()=>{var i;e.shell.v=this.mainView,null===(i=this._designView)||void 0===i||i.close(),this._infoView.init(),t.unsubscribe()}))}}catch(e){console.error(e)}}))))}setTemplate(i,n){return Ue(this,void 0,void 0,(function*(){var o,l,c,u,d,p,m,v,f,g,y,w,b;if(n){const t="System.AppData/HitTriage/Hit Design/campaigns";this._filePath=null!==(c=null===(l=this.campaign)||void 0===l?void 0:l.savePath)&&void 0!==c?c:`${t}/${n}/${r}`,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===(d=this._campaign)||void 0===d?void 0:d.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===(o=this._designView)||void 0===o?void 0:o.dataFrame)&&e.shell.closeTable(this._designView.dataFrame),this._designView=void 0,n=yield this.getNewCampaignName("Hit Design/campaigns",i.key),q(a,n),this._filePath=`System.AppData/HitTriage/Hit Design/campaigns/${n}/${r}`;if(!this.dataFrame)return void console.error("DataFrame is empty");yield this.dataFrame.meta.detectSemanticTypes(),this._molColName=null!==(m=null===(p=this.dataFrame.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===p?void 0:p.name)&&void 0!==m?m:h,this._dfName=null!==(v=(b=this.dataFrame).name)&&void 0!==v?v:b.name=n,this._campaignId=n,this.template=i,null!==(f=this._submitView)&&void 0!==f||(this._submitView=new ke(this)),e.shell.windows.showHelp=!1,this.campaign?yield this.setCanEdit(this.campaign):this.hasEditPermission=!0,this._extraStageColsCount=this.dataFrame.rowCount-this.dataFrame.filter.trueCount;const C=this.designView;this.currentDesignViewId=C.name,this.setBaseUrl(),q(s,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)}))}get campaignId(){return this._campaignId}get designView(){return this._designView=this.getDesignView()}get designViewName(){return this._designViewName}get molColName(){var e,i,n,o;return null!==(e=this._molColName)&&void 0!==e?e:this._molColName=null!==(o=null===(n=null===(i=this.dataFrame)||void 0===i?void 0:i.columns.bySemType(t.SEMTYPE.MOLECULE))||void 0===n?void 0:n.name)&&void 0!==o?o:h}get campaign(){return this._campaign}set campaign(e){this._campaign=e}cacheDuplicateVIDs(){var e;const t=null===(e=this.dataFrame)||void 0===e?void 0:e.col(m);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(m);if(t)return this._duplicateVidCache&&t.version===this._duplicateVidCache.colVersion||this.cacheDuplicateVIDs(),this._duplicateVidCache}getDesignView(){var i,n,s,a,r,l,c,u,d,v;const y=[],w=null===(i=this.dataFrame.col(this.molColName))||void 0===i?void 0:i.toList().every((e=>!e&&""===e)),b=e.shell.addTableView(this.dataFrame);this._designViewName=null!==(s=null===(n=this.campaign)||void 0===n?void 0:n.name)&&void 0!==s?s:this._designViewName,b.name=this._designViewName,this.processedValues=this.dataFrame.getCol(this.molColName).toList();const C=(i,n)=>Ue(this,void 0,void 0,(function*(){const o=this.template.compute;if(!n||""===n)return;const s=yield function(i,n,o){return Se(this,arguments,void 0,(function*(i,n,o,s=[],a=[]){const r=t.TaskBarProgressIndicator.create("Calculating ..."),l=e.chem.convert(i,e.chem.Notation.Unknown,e.chem.Notation.Smiles),c=t.Column.fromStrings(h,[l]),u=t.DataFrame.fromColumns([c]);u.name="HD Single cell values",yield u.meta.detectSemanticTypes();try{n.length&&(yield e.chem.descriptors(u,c.name,n))}catch(e){console.error("Descriptors calculation error",e)}for(const e of o)try{const i=e.args,n=t.Func.find({package:e.package,name:e.name});if(!n.length||!n[0]){console.warn(`Function ${e.name} from package ${e.package} is not found`);continue}const o=n[0],s=o.inputs[0].name,a=o.inputs[1].name;yield o.apply(Object.assign(Object.assign({},i),{[s]:u,[a]:c.name}))}catch(e){console.error(e);continue}for(const e of s){const i=e.args;try{const n=t.Func.find({name:e.name}).filter((t=>t.type===E.script&&t.id===e.id))[0];if(n){const e=n.inputs[0].name,t=n.inputs[1].name,o=yield n.apply(Object.assign(Object.assign({},i),{[e]:u,[t]:c.name}));if(o&&o.rowCount===u.rowCount&&"python"===n.language)for(const e of o.columns)e.name=u.columns.getUnusedName(e.name),u.columns.add(e)}}catch(e){console.error(e)}}for(const e of a){const i=e.args;try{const n=t.Func.find({name:e.name}).filter((t=>t.type===E.query&&t.id===e.id))[0];if(n){const e=n.inputs[0].name,t=[l],o=yield n.apply(Object.assign(Object.assign({},i),{[e]:t}));if(!o||0===o.rowCount)continue;yield J(u,h,o)}}catch(e){console.error(e)}}return r.close(),u}))}(n,o.descriptors.args,o.functions,o.scripts,o.queries);for(const e of s.columns.toList())e.name!==h&&(this.dataFrame.columns.contains(e.name)||(this.dataFrame.columns.addNew(e.name,e.type).semType=e.semType),this.dataFrame.col(e.name).set(i,e.get(0),!1));this.dataFrame.fireValuesChanged(),this.saveCampaign(void 0,!1)}));b._onAdded();const A=null!==(r=null===(a=this._campaign)||void 0===a?void 0:a.layout)&&void 0!==r?r:null===(l=this.template)||void 0===l?void 0:l.layoutViewState;if(A)try{const e=t.ViewLayout.fromViewState(A);b.loadLayout(e)}catch(t){e.shell.error("Failed to apply layout. Falling back to default layout."),console.error(t)}w&&e.functions.call("Chem:editMoleculeCell",{cell:b.grid.cell(this._molColName,0)}),y.push(this.dataFrame.onRowsAdded.pipe((0,De.filter)((()=>!this.isJoining))).subscribe((()=>{var t,i;try{if(this.processedValues=this.dataFrame.getCol(this.molColName).toList(),(null===(t=this.template.stages)||void 0===t?void 0:t.length)>0)for(let e=0;e<this.dataFrame.rowCount;e++){const t=this.dataFrame.col(p).get(e);t&&""!==t&&!(null===(i=this.dataFrame.col(p))||void 0===i?void 0:i.isNone(e))||this.dataFrame.set(p,e,this.template.stages[0])}let n=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=b.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(n=t))}n&&e.functions.call("Chem:editMoleculeCell",{cell:n})}catch(e){console.error(e)}}))),this.dataFrame&&y.push(null===(c=this.dataFrame)||void 0===c?void 0:c.onRowsRemoved.subscribe((()=>{try{this.processedValues=this.dataFrame.getCol(this.molColName).toList()}catch(e){console.error(e)}}))),y.push(e.events.onContextMenu.subscribe((i=>{var n,o,s,a,r,l,c,u,d,p,h,m;try{const e=null===(n=null==i?void 0:i.args)||void 0===n?void 0:n.context;if(!e)return;if((null==e?void 0:e.type)!==t.VIEWER.GRID)return;if(!e.tableView||e.tableView.id!==b.id)return;if((null===(a=null===(s=null===(o=null==i?void 0:i.args)||void 0===o?void 0:o.item)||void 0===s?void 0:s.tableColumn)||void 0===a?void 0:a.name)!==this.molColName||!(null===(l=null===(r=null==i?void 0:i.args)||void 0===r?void 0:r.item)||void 0===l?void 0:l.isTableCell))return;const v=null===(c=null==i?void 0:i.args)||void 0===c?void 0:c.menu;if(!v)return;v.item("Add new row",(()=>{this.dataFrame.rows.addNew(null,!0)})),v.item("Duplicate molecule",(()=>{var e,t,n,o;try{this.dataFrame.rows.addNew(null,!0);let s=null;for(let e=0;e<this.dataFrame.rowCount;e++){const t=b.grid.cell(this.molColName,e);t&&(""!==t.cell.value&&null!==t.cell.value||(s=t))}s&&(s.cell.value=null!==(o=null===(n=null===(t=null===(e=null==i?void 0:i.args)||void 0===e?void 0:e.item)||void 0===t?void 0:t.cell)||void 0===n?void 0:n.value)&&void 0!==o?o:"")}catch(e){console.error(e)}}));const f=null===(d=null===(u=null==i?void 0:i.args)||void 0===u?void 0:u.item)||void 0===d?void 0:d.tableRowIndex,g=null===(m=null===(h=null===(p=null==i?void 0:i.args)||void 0===p?void 0:p.item)||void 0===h?void 0:h.cell)||void 0===m?void 0:m.value;g&&(null!=f?f:-1)>-1&&v.item("Re-Run Calculations",(()=>Ue(this,void 0,void 0,(function*(){try{yield C(f,g)}catch(e){console.error(e)}}))))}catch(t){e.log.error(t)}}))),(null==b?void 0:b.grid)||(e.shell.error("Applied layout created view without grid. Resetting layout."),b.resetLayout()),(null==b?void 0:b.grid)&&y.push(b.grid.onCellValueEdited.subscribe((t=>Ue(this,void 0,void 0,(function*(){var i,n,o,s,a;try{if((null===(i=t.tableColumn)||void 0===i?void 0:i.name)===p)return void(yield this.saveCampaign(void 0,!1));if((null===(n=t.tableColumn)||void 0===n?void 0:n.name)!==this.molColName)return;const r=t.cell.value,l=t.tableRowIndex;let c=null===(o=this.dataFrame.col(m))||void 0===o?void 0:o.get(l),u=!1;if(r)try{const i=t.tableColumn.toList().map((t=>{try{return e.chem.convert(t,e.chem.Notation.Unknown,e.chem.Notation.Smiles)}catch(e){return""}})),n=e.chem.convert(r,e.chem.Notation.Unknown,e.chem.Notation.Smiles);if((null==i?void 0:i.length)===this.dataFrame.rowCount)for(let e=0;e<i.length;e++)if(i[e]===n&&e!==l&&(null===(s=this.dataFrame.col(m))||void 0===s?void 0:s.get(e))){c=null===(a=this.dataFrame.col(m))||void 0===a?void 0:a.get(e),u=!0;break}}catch(e){console.error(e)}this.duplicateVidCache&&!u&&this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[l]]>1&&(c=null),c&&""!==c||(c=Ee(this.dataFrame.col(m))),this.dataFrame.col(m).set(l,c,!1),C(l,r)}catch(e){console.error(e)}}))))),(null==b?void 0:b.grid)&&y.push(b.grid.onCellRender.subscribe((e=>{var i;try{const n=e.cell;if(!n||!n.isTableCell||!n.tableColumn||!this.duplicateVidCache||n.tableColumn.name!==m||(null!==(i=n.tableRowIndex)&&void 0!==i?i:-1)<0)return;this.duplicateVidCache.valueCounts[this.duplicateVidCache.indexes[n.tableRowIndex]]>1&&(e.cell.style.backColor=t.Color.setAlpha(t.Color.getCategoricalColor(this.duplicateVidCache.indexes[n.tableRowIndex]),150))}catch(e){}})));const T=e.events.onViewRemoved.subscribe((e=>{e.id===(null==b?void 0:b.id)&&(y.forEach((e=>e.unsubscribe())),T.unsubscribe())})),x=null==b?void 0:b.getRibbonPanels();if(x&&!G(x)){const i=()=>Ue(this,void 0,void 0,(function*(){var e;oe(this,(e=>Ue(this,void 0,void 0,(function*(){var t,i,n,s,a,r,l,c,u,d;const p=this.template.compute.descriptors.args,h=this.template.compute.functions,m=null!==(t=this.template.compute.scripts)&&void 0!==t?t:[],v=null!==(i=this.template.compute.queries)&&void 0!==i?i:[],y=e.descriptors,w={descriptors:{enabled:!!(null===(n=null==e?void 0:e.descriptors)||void 0===n?void 0:n.length),args:null!==(s=null==e?void 0:e.descriptors)&&void 0!==s?s:[]},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(f)&&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==e?void 0:e.queries)&&void 0!==l?l:{}).filter((([e,t])=>e.startsWith(g)&&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 C=y.filter((e=>!p.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=m.find((t=>`${f}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{T[e]=t}));const x={};Object.entries(null!==(d=null==e?void 0:e.queries)&&void 0!==d?d:{}).filter((([e,t])=>{const i=v.find((t=>`${g}:${t.name}:${t.id}`===e));return!i||!Object.entries(t).every((([e,t])=>i.args[e]===t))})).forEach((([e,t])=>{x[e]=t})),o.setUpdateIndicator(b.grid.root,!0);try{yield Ne({descriptors:C,externals:A,scripts:T,queries:x},this.dataFrame,this.molColName),this.dataFrame.fireValuesChanged()}finally{o.setUpdateIndicator(b.grid.root,!1),this.saveCampaign(void 0,!1)}}))),(()=>null),null===(e=this.campaign)||void 0===e?void 0:e.template,!0)})),n=o.iconFA("wrench",i,"Calculate additional properties"),s=o.icons.add((()=>{var e;null===(e=this.dataFrame)||void 0===e||e.rows.addNew(null,!0)}),"Add new row"),a=o.iconFA("share",(()=>Ue(this,void 0,void 0,(function*(){var e;yield new we(null===(e=this.campaign)||void 0===e?void 0:e.permissions).show((e=>{this.campaign.permissions=e,this.saveCampaign(void 0,!0)}))}))),"Edit campaign permissions"),r=o.bigButton("Progress tracker",(()=>{!function(i,n){var s,a,r,l,c,u,d,h,m,v,f;const g=null===(s=i.campaign)||void 0===s?void 0:s.tilesViewerFormSketch;let y=null;if(g&&g.length>0)try{y=JSON.parse(g)}catch(e){console.error("Failed to parse sketch state string",e)}y&&y.elementStates&&(null!==(a=y.elementStates.length)&&void 0!==a?a:0)>0&&(y.elementStates=y.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)})),y.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 w=Object.assign({lanesColumnName:p,lanes:null!==(l=null===(r=i.template)||void 0===r?void 0:r.stages)&&void 0!==l?l:[]},(null!==(u=null===(c=null==y?void 0:y.elementStates)||void 0===c?void 0:c.length)&&void 0!==u?u:0)>0?{sketchState:y}:{}),b=n();if(!b)return void e.shell.error("Failed to create tiles viewer. table view is not available.");let C=null;const A=o.dialog("Progress Tracker");try{C=b.addViewer(t.VIEWER.TILE_VIEWER,w);const e=C.getOptions();e.look.sketchState=(null!==(h=null===(d=null==y?void 0:y.elementStates)||void 0===d?void 0:d.length)&&void 0!==h?h:0)>0?y:null,C.setOptions(e),C.copyViewersLook(C)}catch(n){e.shell.error("Failed to create tiles viewer with preset layout.\n Falling back to default layout."),console.error("Failed to create tiles viewer",n),C&&(C.close(),C.detach()),C=b.addViewer(t.VIEWER.TILE_VIEWER,{lanesColumnName:p,lanes:null!==(v=null===(m=i.template)||void 0===m?void 0:m.stages)&&void 0!==v?v:[]})}if(!C)return void e.shell.error("Failed to create tiles viewer. check the console for more details.");A.add(C.root);const T=e.events.onCurrentViewChanged.subscribe((()=>{e.shell.v===b?A.root.style.display="flex":A.root.style.setProperty("display","none","important")})),x=A.onClose.subscribe((()=>{x.unsubscribe(),T.unsubscribe();try{const e=C.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)}C.detach(),C.close()}));A.showModal(!0),null===(f=document.querySelector(".d4-modal-background"))||void 0===f||f.remove()}(this,(()=>{var e;return null!==(e=this._designView)&&void 0!==e?e:null}))})),l=o.bigButton("Submit",(()=>{var e;const t=null===(e=this._submitView)||void 0===e?void 0:e.render();if(t){const e=o.dialog("Submit");e.add(t),e.addButton("Save",(()=>{this.saveCampaign(),e.close()})),e.addButton("Submit",(()=>{var t;null===(t=this._submitView)||void 0===t||t.submit(),e.close()})),e.show()}}));l.classList.add("hit-design-submit-button");const c=[l];null!==(v=null===(d=null===(u=this.template)||void 0===u?void 0:u.stages)||void 0===d?void 0:d.length)&&void 0!==v&&v&&c.unshift(r),this.campaign&&this.template&&!this.campaign.template&&(this.campaign.template=this.template),this.hasEditPermission&&c.unshift(a),c.unshift(n),c.unshift(s),x.push(c),b.setRibbonPanels(x)}return b.parentCall=this.parentCall,b}getSummary(){var i,n,s,a;const l=()=>{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)},c=Object.assign({},null!==(n=null===(i=this.campaign)||void 0===i?void 0:i.campaignFields)&&void 0!==n?n:this.campaignProps);return this.template&&this.template.campaignFields&&Object.entries(c).forEach((([i,n])=>{const o=this.template.campaignFields.find((e=>e.name===i));o&&"Date"===o.type&&n?"Invalid Date"!==new Date(n).toString()?c[i]=new Date(n).toLocaleDateString():n.date?c[i]=new Date(n.date).toLocaleDateString():c[i]=n:o&&o.type===t.SEMTYPE.MOLECULE&&n&&(c[i]=e.chem.drawMolecule(n))})),Object.assign(Object.assign({Template:null!==(a=null===(s=this.template)||void 0===s?void 0:s.name)&&void 0!==a?a:"Molecules","File path":(()=>{const t=o.icons.edit((()=>{const i=l(),a=o.input.string("Path",{value:i}),c=a.root.getElementsByTagName("label").item(0);c&&c.remove(),a.root.style.width="100%";const u=o.button("Save",(()=>Ue(this,void 0,void 0,(function*(){const i=yield function(){return Ue(this,void 0,void 0,(function*(){const t=a.value;return t&&""!==t.trim()?!!(yield e.dapi.files.exists(t))||(e.shell.error("Given folder does not exist"),!1):(e.shell.error("Path can not be empty"),!1)}))}();if(!i)return;const c=a.value;c.endsWith("/")?this._filePath=`${c}${this.campaignId}/${r}`:this._filePath=`${c}/${this.campaignId}/${r}`,this._campaign&&(this._campaign.savePath=this._filePath),yield this.saveCampaign(void 0,!0),o.empty(s);const u=l();n=o.link(u,(()=>{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")}),T),s.appendChild(n),s.appendChild(t)})))),d=o.button("Cancel",(()=>{o.empty(s),s.appendChild(n),s.appendChild(t)}));o.empty(s),a.addOptions(d),a.addOptions(u),s.appendChild(a.root)}),"Edit file path");t.style.marginLeft="5px";const i=l();let n=o.link(i,(()=>{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")}),T);const s=o.divH([n,t],{style:{alignItems:"center"}});return s})()},c),{"Number of molecules":(this.dataFrame.rowCount-this._extraStageColsCount).toString(),"Enrichment methods":[this.template.compute.descriptors.enabled?"descriptors":"",...this.template.compute.functions.map((e=>e.name))].filter((e=>e&&""!==e.trim())).join(", ")})}saveCampaign(i){return Ue(this,arguments,void 0,(function*(i,n=!0){var o,s,a,r,c,u,d,p,h,v,f,g,y,w,b,C;const A=this.campaignId,T=this.template.name,x=this.dataFrame,I=A,S={};x.columns.toList().forEach((e=>S[e.name]=e.semType));const E={};x.columns.toList().forEach((e=>E[e.name]=e.type));const N=null!==(s=null===(o=this.campaign)||void 0===o?void 0:o.tilesViewerFormSketch)&&void 0!==s?s:void 0,F=null!==(r=null===(a=this.campaign)||void 0===a?void 0:a.authorUserId)&&void 0!==r?r:e.shell.user.id,_=null!==(u=null===(c=this.campaign)||void 0===c?void 0:c.permissions)&&void 0!==u?u:ye,P={name:I,templateName:T,status:null!==(p=null!=i?i:null===(d=this.campaign)||void 0===d?void 0:d.status)&&void 0!==p?p:"In Progress",createDate:null!==(v=null===(h=this.campaign)||void 0===h?void 0:h.createDate)&&void 0!==v?v:H(new Date),campaignFields:null!==(g=null===(f=this.campaign)||void 0===f?void 0:f.campaignFields)&&void 0!==g?g:this.campaignProps,columnSemTypes:S,rowCount:null!==(w=null===(y=x.col(m))||void 0===y?void 0:y.toList().filter((e=>"StageDefiningRow"!==e)).length)&&void 0!==w?w:0,filteredRowCount:x.filter.trueCount,savePath:this._filePath,columnTypes:E,tilesViewerFormSketch:N,version:this.version+1,authorUserId:F,permissions:_};if(!this.hasEditPermission)return e.shell.error("You do not have permission to modify this campaign"),P;const O=`Hit Design/campaigns/${A}/${l}`;let B=x;if(yield He.files.exists(O)){const t=JSON.parse(yield He.files.readAsText(O));if((null!==(b=t.version)&&void 0!==b?b:0)>this.version&&(P.version=Math.max(this.version,null!==(C=t.version)&&void 0!==C?C:0)+1,yield e.dapi.files.exists(this._filePath)))try{const t=yield e.dapi.files.readCsv(this._filePath);B=this.unionDataframes(t,x,this.molColName)}catch(e){console.error(e)}}const V=t.DataFrame.fromColumns(B.columns.toList().filter((e=>!e.name.startsWith("~")))).toCsv();yield e.dapi.files.writeAsText(this._filePath,V);const k=this._designView.saveLayout();return k?P.layout=k.viewState:e.shell.warning("Layout cound not be saved"),P.template=this.template,yield He.files.writeAsText(O,JSON.stringify(P)),n&&e.shell.info("Campaign saved successfully."),this.campaign=P,P}))}}class $e extends t.GridCellRenderer{get name(){return"customGasteigerPNG"}get cellType(){return"customGasteigerPNG"}get defaultHeight(){return 200}get defaultWidth(){return 200}render(e,t,i,n,o,s,a){if(s.gridRow<0||!s.cell.value)return;const r=s.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 Me=function(e,t,i,n){return new(i||(i=Promise))((function(o,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function r(e){try{l(n.throw(e))}catch(e){s(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(a,r)}l((n=n.apply(e,t||[])).next())}))};const He=new t.Package;function qe(e,t){return Me(this,void 0,void 0,(function*(){yield Ge(e,t,"Hit Triage")}))}function Ye(){return Me(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new _e(t).multiView}))}function We(e,t){return Me(this,void 0,void 0,(function*(){yield Ge(e,t,"Hit Design")}))}function Ge(i,n,o){return Me(this,void 0,void 0,(function*(){const s=yield z(o,[]);for(const[o,a]of Object.entries(s)){const o="ingest"in a?a.ingest.query:a.savePath;o&&!1!==(yield e.dapi.files.exists(o))&&i.item(a.name).onSelected.subscribe((i=>Me(this,void 0,void 0,(function*(){try{const i=yield e.dapi.files.readCsv(o);if(!i)return;const s=a.columnSemTypes;if(s)for(const[e,t]of Object.entries(s)){const n=i.columns.byName(e);n&&(n.semType=t)}const r=t.TableView.create(i,!1);n.preview=r;const l=a.layout;l&&r.loadLayout(t.ViewLayout.fromViewState(l))}catch(e){console.error(e)}}))))}}))}function Je(){return Me(this,void 0,void 0,(function*(){const t=e.functions.getCurrentCall();return new Re(t).multiView}))}function ze(){return Me(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(100);return t.name="100 Molecules",t}))}function Ke(){return Me(this,void 0,void 0,(function*(){const t=e.data.demo.molecules(5e3);return t.name="5000 Molecules",t}))}function Qe(t){return Me(this,void 0,void 0,(function*(){const i=e.data.demo.molecules(t);return i.name="Variable Molecules number",i}))}function Ze(t,i){return Me(this,void 0,void 0,(function*(){e.shell.info(t.rowCount),e.shell.info(i)}))}function Xe(){return new $e}})(),hittriage=n})();
2
2
  //# sourceMappingURL=package.js.map