@datagrok/peptides 1.27.11 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.auth.json +1 -0
- package/.grokignore +2 -0
- package/.turbo/turbo-build.log +26 -0
- package/.vscode/settings.json +16 -0
- package/CHANGELOG.md +28 -0
- package/CLAUDE.md +69 -5
- package/dist/659.js +2 -0
- package/dist/659.js.map +1 -0
- package/dist/806.js +2 -0
- package/dist/806.js.map +1 -0
- package/dist/package-test.js +396 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +361 -1
- package/dist/package.js.map +1 -1
- package/e2e/.auth.json +1 -0
- package/e2e/.auth.public.json +1 -0
- package/files/aligned_3.csv +6 -6
- package/package.json +30 -57
- package/rspack.config.js +3 -0
- package/src/demo/fasta.ts +0 -1
- package/src/model.ts +245 -131
- package/src/package-api.ts +18 -10
- package/src/package.g.ts +1 -0
- package/src/package.ts +19 -24
- package/src/tests/core.ts +6 -6
- package/src/tests/misc.ts +20 -0
- package/src/tests/model.ts +56 -6
- package/src/tests/table-view.ts +4 -4
- package/src/tests/utils.ts +56 -0
- package/src/tests/viewers.ts +270 -14
- package/src/tests/widgets.ts +13 -12
- package/src/utils/cell-renderer.ts +7 -6
- package/src/utils/constants.ts +10 -0
- package/src/utils/misc.ts +3 -3
- package/src/utils/statistics.ts +2 -2
- package/src/viewers/cluster-max-activity-viewer.ts +44 -11
- package/src/viewers/logo-summary.ts +126 -40
- package/src/viewers/mutation-cliffs-viewer.ts +56 -28
- package/src/viewers/peptide-generation-viewer.ts +7 -0
- package/src/viewers/position-statistics-viewer.ts +26 -4
- package/src/viewers/sar-viewer-status.ts +145 -0
- package/src/viewers/sar-viewer.ts +134 -42
- package/src/viewers/viewer-render-state.ts +68 -0
- package/src/widgets/distribution.ts +1 -1
- package/src/widgets/manual-alignment.ts +9 -22
- package/src/widgets/peptides.ts +101 -100
- package/src/widgets/selection.ts +1 -1
- package/src/widgets/settings.ts +11 -9
- package/test-playwright-report.json +73 -0
- package/test-report-playwright.csv +2 -0
- package/tsconfig.json +15 -69
- package/.eslintrc.json +0 -53
- package/dist/216.js +0 -2
- package/dist/216.js.map +0 -1
- package/dist/682.js +0 -2
- package/dist/682.js.map +0 -1
- package/dist/705.js +0 -2
- package/dist/705.js.map +0 -1
- package/dist/774.js +0 -2
- package/dist/774.js.map +0 -1
- package/dist/8473fcbfb6e85ca6c852.wasm +0 -0
- package/test-console-output-1.log +0 -661
- package/test-record-1.mp4 +0 -0
- package/webpack.config.js +0 -60
- /package/dist/{9a8fbf37666e32487835.wasm → wasmDbscan.wasm} +0 -0
package/dist/package.js
CHANGED
|
@@ -1,2 +1,362 @@
|
|
|
1
|
-
var peptides;(()=>{var t={854(t,e,n){"use strict";n.d(e,{oE:()=>s,kC:()=>a}),"object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,new Set;const i="object"==typeof process&&process?process:{};let o=globalThis.AbortController,r=globalThis.AbortSignal;if(void 0===o){r=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},o=class{constructor(){e()}signal=new r;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==i.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{var n,o,r,s;t&&(t=!1,n="AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",o="NO_ABORT_CONTROLLER",r="ENOTSUP",s=e,"function"==typeof i.emitWarning?i.emitWarning(n,o,r,s):console.error(`[${r}] ${o}: ${n}`))}}Symbol("type"),Symbol.iterator,Symbol.toStringTag;Error;new Map([[123,"lbrace"],[125,"rbrace"],[40,"lparen"],[41,"rparen"],[93,"rbracket"],[124,"pipe"],[46,"dot"],[44,"comma"],[43,"plus"],[58,"colon"],[45,"dash"],[36,"dollar"],[62,"gt"],[63,"question"],[42,"asterisk"],[95,"underscore"],[39,"apos"]]);new Map;var s={AA:"HELM_AA",SUGAR:"HELM_SUGAR",BASE:"HELM_BASE",LINKER:"HELM_LINKER",CHEM:"HELM_CHEM",BLOB:"HELM_BLOB",NUCLEOTIDE:"HELM_NUCLEOTIDE"},a={PEPTIDE:"PEPTIDE",RNA:"RNA",CHEM:"CHEM",BLOB:"BLOB",G:"G"};var l=class{constructor(){this._listeners=new Set,this._completed=!1}subscribe(t){return this._completed?()=>{}:(this._listeners.add(t),()=>{this._listeners.delete(t)})}next(t){if(!this._completed)for(let e of[...this._listeners])e(t)}complete(){this._completed=!0,this._listeners.clear()}get observerCount(){return this._listeners.size}};function u(t){return{line:"#202020",text:"#000000",background:t}}function c(t){return{line:"#e0e0e0",text:"#ffffff",background:_(t,.25)}}function h(t){let e=/^#([0-9a-fA-F]{6})$/.exec(t),n=/^#([0-9a-fA-F]{3})$/.exec(t);if(null!==e){let t=e[1];return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}if(null!==n){let t=n[1];return[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16)]}return null}function d(t){return t.toString(16).padStart(2,"0")}function f(t,e,n){return`#${d(t)}${d(e)}${d(n)}`}function m(t,e,n){let i=t/255,o=e/255,r=n/255,s=Math.max(i,o,r),a=Math.min(i,o,r),l=(s+a)/2;if(s===a)return[0,0,l];let u,c=s-a;return u=s===i?60*((o-r)/c+(o<r?6:0)):s===o?60*((r-i)/c+2):60*((i-o)/c+4),[u,l>.5?c/(2-s-a):c/(s+a),l]}function p(t,e,n){let i=n;return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}function g(t,e,n){if(0===e){let t=Math.round(255*n);return[t,t,t]}let i=n<.5?n*(1+e):n+e-n*e,o=2*n-i,r=t/360;return[Math.round(255*p(o,i,r+1/3)),Math.round(255*p(o,i,r)),Math.round(255*p(o,i,r-1/3))]}function v(t,e=.3,n=.1){let i=h(t);if(null===i)return t;let[o,r,s]=m(i[0],i[1],i[2]),a=Math.max(0,Math.min(1,r*(1-e))),l=Math.max(0,Math.min(.95,s+n*(1-s))),[u,c,d]=g(o,a,l);return f(u,c,d)}function C(t){let e=h(t);if(null===e)return 0;let n=t=>{let e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)};return.2126*n(e[0])+.7152*n(e[1])+.0722*n(e[2])}function y(t){let e=h(t);if(null===e)return"#1f2937";let[n,i,o]=m(e[0],e[1],e[2]);if(o>.85||i<.15&&o>.7)return"#1f2937";let r=Math.max(.08,o-.3);return function(t){let e=(t.h%360+360)%360,n=Math.max(0,Math.min(1,t.s)),i=Math.max(0,Math.min(1,t.l)),[o,r,s]=g(e,n,i);return f(o,r,s)}({h:n,s:Math.min(1,i+.1),l:r})}function b(t){let e=function(t){let e=h(t);return null===e?null:{r:e[0]/255,g:e[1]/255,b:e[2]/255}}(t);if(null===e)return"#1f2937";let n=t=>t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4),i=.2126*n(e.r)+.7152*n(e.g)+.0722*n(e.b);return 1.05/(i+.05)>(i+.05)/.05?"#ffffff":"#1f2937"}function _(t,e){let n=h(t);if(null===n)return t;let i=1-e;return f(Math.max(0,Math.min(255,Math.round(n[0]*i))),Math.max(0,Math.min(255,Math.round(n[1]*i))),Math.max(0,Math.min(255,Math.round(n[2]*i))))}var w={A:u("#A0A0FF"),G:u("#FF7070"),T:u("#A0FFA0"),C:u("#FF8C4B"),U:u("#FF8080")},A={R:u("#7a85c1"),r:u("#7a85c1")},S={P:u("#9aa5e1"),p:u("#9aa5e1")},T={A:u("#C8C8C8"),R:u("#145AFF"),N:u("#00DCDC"),D:u("#E60A0A"),C:u("#E6E600"),E:u("#00DCDC"),Q:u("#E60A0A"),G:u("#EBEBEB"),H:u("#8282D2"),I:u("#0F820F"),L:u("#0F820F"),K:u("#145AFF"),M:u("#E6E600"),F:u("#3232AA"),P:u("#DC9682"),S:u("#FA9600"),T:u("#FA9600"),W:u("#B45AB4"),Y:u("#3232AA"),V:u("#0F820F")},E={R:u("#eeeeee")},N={B:u("#999999"),G:u("#e2e2e2")},x={P:u("#9aa5e1")},M={name:"light",fallback:{line:"#202020",text:"#000000",background:"#eeeeee"},errorTriple:{line:"#cc0000",text:"#000000",background:"#FFFF00"},palette:{[s.BASE]:w,[s.SUGAR]:A,[s.LINKER]:S,[s.AA]:T,[s.CHEM]:E,[s.BLOB]:N,[s.NUCLEOTIDE]:x}};function I(t){let e={};for(let[n,i]of Object.entries(t))e[n]=c(i.background);return e}var O={name:"dark",fallback:{line:"#e0e0e0",text:"#ffffff",background:_("#eeeeee",.5)},errorTriple:{line:"#ff5050",text:"#ffffff",background:_("#FFFF00",.4)},palette:{[s.BASE]:I(w),[s.SUGAR]:I(A),[s.LINKER]:I(S),[s.AA]:I(T),[s.CHEM]:I(E),[s.BLOB]:I(N),[s.NUCLEOTIDE]:I(x)}};function P(t,e,n=M){if(null===t)return{...n.errorTriple};let i=t.meta?.colors;if(void 0!==i){let t="light"===n.name?i.light:"dark"===n.name?i.dark:void 0;if(void 0!==t)return{...t,line:y(t.background)};if(void 0!==i.default)return{...i.default,line:y(i.default.background)}}let o=t.naturalAnalog;if(void 0!==o&&""!==o){let t=n.palette[e];if(void 0!==t){let e=t[o];if(void 0!==e)return{...e,line:y(e.background),text:b(e.background)}}}return{...n.fallback,line:y(n.fallback.background),text:b(n.fallback.background)}}function L(t){switch(t.polymerType){case a.PEPTIDE:return s.AA;case a.CHEM:return s.CHEM;case a.BLOB:return s.BLOB;case a.RNA:if("Branch"===t.monomerType)return s.BASE;if("Backbone"===t.monomerType){let e=t.naturalAnalog;return"P"===e||"p"===e?s.LINKER:s.SUGAR}return null;default:return null}}new Set(["PEPTIDE","RNA","CHEM","BLOB"]),new Set(["Backbone","Branch","Terminal","Undefined"]);new Set(["?","*","_","X","N"]);Math.PI;function R(t,e){let n=Math.min(t.x,e.x),i=Math.min(t.y,e.y);return{x:n,y:i,width:Math.max(t.x+t.width,e.x+e.width)-n,height:Math.max(t.y+t.height,e.y+e.height)-i}}function k(t){if(Number.isInteger(t))return 0===t?"0":t.toString();if(!Number.isFinite(t)||Object.is(t,-0))return"0";let e=Math.round(1e3*t)/1e3;return 0===e?"0":e.toString()}function F(t){if(0===t.length)return"";let e=t[0],n=`M ${k(e.x)} ${k(e.y)}`;for(let e=1;e<t.length;e++){let i=t[e];n+=` L ${k(i.x)} ${k(i.y)}`}return n+=` L ${k(e.x)} ${k(e.y)} Z`,n}function V(t,e,n,i){let o=[],r=360/e;for(let s=0;s<e;s++){let e=(i+s*r)*Math.PI/180;o.push({x:t.x+n*Math.cos(e),y:t.y+n*Math.sin(e)})}return o}function D(t,e,n,i){let o=Math.abs(e)/2,r=Math.abs(n)/2,s=Math.max(0,Math.min(i,o,r)),a=t.x-o,l=t.y-r,u=a+2*o,c=l+2*r,h=`M ${k(a+s)} ${k(l)}`;return h+=` L ${k(u-s)} ${k(l)}`,h+=` A ${k(s)} ${k(s)} 0 0 1 ${k(u)} ${k(l+s)}`,h+=` L ${k(u)} ${k(c-s)}`,h+=` A ${k(s)} ${k(s)} 0 0 1 ${k(u-s)} ${k(c)}`,h+=` L ${k(a+s)} ${k(c)}`,h+=` A ${k(s)} ${k(s)} 0 0 1 ${k(a)} ${k(c-s)}`,h+=` L ${k(a)} ${k(l+s)}`,h+=` A ${k(s)} ${k(s)} 0 0 1 ${k(a+s)} ${k(l)}`,h+=" Z",h}function G(t,e,n){let i=Math.abs(e),o=Math.abs(n);return`M ${k(t.x-i)} ${k(t.y)} A ${k(i)} ${k(o)} 0 1 0 ${k(t.x+i)} ${k(t.y)} A ${k(i)} ${k(o)} 0 1 0 ${k(t.x-i)} ${k(t.y)} Z`}function B(t,e,n,i){switch(t){case"hexagon":{let t=n*Math.sqrt(3)/2,i=n;return{x:e.x-t,y:e.y-i,width:2*t,height:2*i}}case"diamond":return{x:e.x-n,y:e.y-n,width:2*n,height:2*n};case"pentagon":{let t=Math.cos(18*Math.PI/180)*n,i=-n,o=Math.sin(54*Math.PI/180)*n;return{x:e.x-t,y:e.y+i,width:2*t,height:o-i}}case"rounded-rect":case"blob":{let t=i??n,o=Math.abs(n)/2,r=Math.abs(t)/2;return{x:e.x-o,y:e.y-r,width:2*o,height:2*r}}case"ellipse":{let t=Math.abs(n),o=Math.abs(i??n);return{x:e.x-t,y:e.y-o,width:2*t,height:2*o}}case"circle":{let t=Math.abs(n);return{x:e.x-t,y:e.y-t,width:2*t,height:2*t}}}}var U='"Helvetica Neue", Helvetica, Arial, sans-serif';function q(t){return{aa:{size:.72*t,strokeWidth:5},sugar:{size:1.39*t,strokeWidth:5,cornerRadius:.3*t},base:{size:.88*t,strokeWidth:5},linker:{size:.63*t,strokeWidth:5},chem:{size:1.49*t,strokeWidth:5,cornerRadius:.5*t},blob:{size:1.64*t,strokeWidth:5,cornerRadius:.8*t},nucleotide:{size:.98*t,strokeWidth:5}}}var H={name:"light",background:"#ffffff",defaultStroke:"#202020",defaultFill:"#ffffff",selectionColor:"#FFC107",highlightColor:"#A4E2DC",errorColor:"#cc0000",fontSize:14,fontFamily:U,bondLength:28,textColor:"#000000",idColor:"#00aa00",annotationColor:"#FFA500",tagDotColor:"#dd2222",hbondColor:"#888888",nonCanonicalHbondColor:"#cc8800",crossPolymerBondColor:"#1f5fcd",colorTheme:M,palette:{softenCanvas:!1},shapes:q(14)};q(14);function $(t,e){switch(e){case s.AA:return t.shapes.aa;case s.SUGAR:return t.shapes.sugar;case s.BASE:return t.shapes.base;case s.LINKER:return t.shapes.linker;case s.CHEM:return t.shapes.chem;case s.BLOB:return t.shapes.blob;case s.NUCLEOTIDE:return t.shapes.nucleotide}}function Y(t){switch(t){case s.AA:return"hexagon";case s.SUGAR:return"rounded-rect";case s.BASE:return"diamond";case s.LINKER:return"circle";case s.CHEM:return"rounded-rect";case s.BLOB:return"blob";case s.NUCLEOTIDE:return"pentagon"}}function j(t,e,n=0){let i=$(e,t.biotype);if("*"===t.symbol)return function(t,e){return G(t,e,e)}(t.p,i.size+n);switch(Y(t.biotype)){case"hexagon":{let e=0===n?0:n/Math.cos(Math.PI/6);return function(t,e,n=-30){return F(V(t,6,e,n))}(t.p,i.size+e)}case"diamond":{let e=0===n?0:n/Math.cos(Math.PI/4);return function(t,e){return F([{x:t.x,y:t.y-e},{x:t.x+e,y:t.y},{x:t.x,y:t.y+e},{x:t.x-e,y:t.y}])}(t.p,i.size+e)}case"pentagon":{let e=0===n?0:n/Math.cos(Math.PI/5);return function(t,e,n=-90){return F(V(t,5,e,n))}(t.p,i.size+e)}case"rounded-rect":return D(t.p,i.size+2*n,i.size+2*n,(i.cornerRadius??0)+n);case"blob":return function(t,e,n,i){return D(t,e,n,i)}(t.p,i.size+2*n,i.size+2*n,(i.cornerRadius??0)+n);case"circle":return G(t.p,i.size+n,i.size+n)}}function W(t,e){let n,i=$(e,t.biotype),o="*"===t.symbol?"circle":Y(t.biotype);switch(o){case"hexagon":case"diamond":case"pentagon":case"circle":n=B(o,t.p,i.size);break;case"rounded-rect":case"blob":n=B(o,t.p,i.size,i.size)}let r=i.strokeWidth/2;return{x:n.x-r,y:n.y-r,width:n.width+2*r,height:n.height+2*r}}function z(t,e){return $(e,t.biotype)}var K=/[&"'<>]/;function Z(t){return K.test(t)?t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):t}function X(t){if(Number.isInteger(t))return 0===t?"0":t.toString();if(!Number.isFinite(t)||Object.is(t,-0))return"0";let e=Math.round(1e3*t)/1e3;return 0===e?"0":e.toString()}function Q(t,e,n){let i=`<${t}`;if(void 0!==e)for(let t in e){let n=e[t];if(void 0!==n&&!1!==n){if(!0===n){i+=` ${t}`;continue}i+="number"==typeof n?` ${t}="${X(n)}"`:` ${t}="${Z(n)}"`}}return void 0===n?`${i}/>`:"string"==typeof n?`${i}>${n}</${t}>`:`${i}>${n.join("")}</${t}>`}function J(t,e,n){if(0===n.size)return Q("g",{class:"hw-layer hw-highlights"},"");let i=[];for(let o of t.atoms){if(!n.has(o.id))continue;let t=j(o,e,(z(o,e).strokeWidth+3)/2);i.push(Q("path",{d:t,class:"hw-highlight",fill:"none",stroke:e.highlightColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":o.symbol,"data-ring-atom-id":o.id,"data-testid":`highlight-ring-${o.id}`}))}return Q("g",{class:"hw-layer hw-highlights"},i.join(""))}function tt(t,e,n){if(0===n.size)return Q("g",{class:"hw-layer hw-selections"},"");let i=[];for(let o of t.atoms){if(!n.has(o.id))continue;let t=j(o,e,(z(o,e).strokeWidth+3)/2);i.push(Q("path",{d:t,class:"hw-selection",fill:"none",stroke:e.selectionColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":o.symbol,"data-ring-atom-id":o.id,"data-testid":`selection-ring-${o.id}`}))}return Q("g",{class:"hw-layer hw-selections"},i.join(""))}new WeakMap;new Map;var et=class{constructor(t,e){this.atoms=t,this.bonds=e,this.isEmpty=0===t.size&&0===e.size,Object.freeze(this)}};new et(new Set,new Set);function nt(t){let e=t.ownerDocument;if(null!=e)return e;let n=globalThis;if(void 0!==n.document)return n.document;throw new Error("EditorView: no Document available (host.ownerDocument is null).")}function it(t,e,n,i){let o=t.createElement(e);if(void 0!==n)for(let t of Object.keys(n)){let e=n[t];!1===e||void 0===e||o.setAttribute(t,!0===e?"":String(e))}if(void 0!==i)for(let e of i)"string"==typeof e?o.appendChild(t.createTextNode(e)):o.appendChild(e);return o}function ot(t,e,n=220,i=140){if(null==t||""===e)return null;try{let o=t.get_mol(e);if(null===o)return null;let r=o.get_svg(n,i);return o.delete(),r}catch{return null}}function rt(t,e,n){let i="data-testid";for(let n=0;n<t.body.children.length;n++){let o=t.body.children[n];if(void 0!==o&&o.getAttribute(i)===e)return o}let o=it(t,"div",{class:n,[i]:e});return o.style.display="none",t.body.appendChild(o),o}function st(t,e,n){for(;null!==e.firstChild;)e.removeChild(e.firstChild);if(e.appendChild(it(t,"div",{class:"hw-tooltip__symbol"},[n.symbol])),void 0!==n.name&&""!==n.name&&n.name!==n.symbol&&e.appendChild(it(t,"div",{class:"hw-tooltip__name"},[n.name])),void 0!==n.rdkitSvg&&null!==n.rdkitSvg&&""!==n.rdkitSvg){let i={class:"hw-tooltip__rdkit"};void 0!==n.rdkitTestid&&(i["data-testid"]=n.rdkitTestid);let o=it(t,"div",i);o.innerHTML=n.rdkitSvg,e.appendChild(o)}void 0!==n.hint&&""!==n.hint&&e.appendChild(it(t,"div",{class:"hw-tooltip__hint"},[n.hint]))}function at(t,e,n){let i=t.style;i.display="block",i.left=`${e+12}px`,i.top=`${n+12}px`}function lt(t){null!==t&&(t.style.display="none")}function ut(t){let e=t.body;if(null!=e)for(let t=0;t<e.children.length;t++){let n=e.children[t];if(void 0===n)continue;let i=void 0===n.getAttribute?null:n.getAttribute("data-testid");null!=i&&i.endsWith("-tooltip")&<(n)}}var ct=class t{constructor(t,e,n){this._baseTransform="",this._viewport={scale:1,offset:{x:0,y:0}},this._pinnedBbox=null,this._tooltip=null,this._bondTooltip=null,this._rdkitSvgCache=new Map,this._unsubs=[],this._destroyed=!1,this.host=t,this._editor=e,this._doc=n?.documentImpl??nt(t),this._width=n?.width??400,this._height=n?.height??200,function(t){let e=nt(t);if(null!==e.querySelector("style[data-hw-editor-view-styles]"))return;let n=e.createElement("style");n.setAttribute("data-hw-editor-view-styles",""),n.textContent=".hw-editor-view{position:relative;display:block;overflow:hidden;outline:none;}.hw-editor-view svg{display:block;user-select:none;}.hw-editor-view.hw-view-only{cursor:default;}";let i=e.head??e.documentElement;null!==i&&i.appendChild(n)}(t);let i=this._doc.createElement("div");i.setAttribute("class","hw-editor-view"),t.appendChild(i),this._tooltip=rt(this._doc,"atom-tooltip","hw-atom-tooltip"),this._bondTooltip=rt(this._doc,"bond-tooltip","hw-bond-tooltip"),this._svgRoot=this._renderFresh(),this._unsubs.push(e.on("mol:changed",t=>{this._hideTooltip(),this._hideBondTooltip(),("setHelm"===t.reason||"cleanLayout"===t.reason||"initial"===t.reason)&&(this._pinnedBbox=null),this._renderFresh()})),this._unsubs.push(e.on("selection:change",t=>{this._refreshOverlays(t)})),this._unsubs.push(e.on("highlight:change",t=>{this._refreshOverlays(t)})),this._unsubs.push(e.on("theme:change",()=>{this._renderFresh()})),this._unsubs.push(e.on("view:resize",t=>{this._applyResize(t.width,t.height)})),this._unsubs.push(e.on("view:viewport-change",t=>{this._viewport=t.viewport,this._applyViewport(t.viewport)})),this._unsubs.push(e.on("view:fit-to-content",()=>{this._pinnedBbox=null,this._renderFresh()})),this._unsubs.push(e.on("monomer:hover",t=>{this._showTooltip(t.atom,t.clientX,t.clientY)})),this._unsubs.push(e.on("monomer:hover-end",()=>{this._hideTooltip()})),this._unsubs.push(e.on("bond:hover",t=>{this._showBondTooltip(t.bond,t.clientX,t.clientY)})),this._unsubs.push(e.on("bond:hover-end",()=>{this._hideBondTooltip()})),this._unsubs.push(e.on("bond:preview",t=>{this._paintBondPreview(t.start.p,t.cursor,null!==t.candidate)})),this._unsubs.push(e.on("bond:preview-end",()=>{this._clearBondPreview()})),this._unsubs.push(e.on("bond:cancel",()=>{this._clearBondPreview()})),this._unsubs.push(e.on("selection:rectangle-start",t=>{this._paintSelectionRect(t.origin,t.origin)})),this._unsubs.push(e.on("selection:rectangle-update",t=>{this._paintSelectionRectFromRect(t.rect)})),this._unsubs.push(e.on("selection:rectangle-end",()=>{this._clearSelectionRect()}))}get svgRoot(){return this._svgRoot}get width(){return this._width}get height(){return this._height}resize(t,e){this._destroyed||(this._width=t,this._height=e,this._renderFresh())}redraw(){this._destroyed||this._renderFresh()}destroy(){if(this._destroyed)return;this._destroyed=!0;for(let t of this._unsubs)t();this._unsubs.length=0;let t=this.host.querySelector(".hw-editor-view");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t),lt(this._tooltip),lt(this._bondTooltip),this._tooltip=null,this._bondTooltip=null}_renderFresh(){let t=this._editor.getService(),e=this._currentTheme(),n=this._editor.getMol();null===this._pinnedBbox&&(this._pinnedBbox=function(t,e=H){if(0===t.atoms.length)return{x:0,y:0,width:0,height:0};let n=W(t.atoms[0],e);for(let i=1;i<t.atoms.length;i++)n=R(n,W(t.atoms[i],e));return n}(n,e));let i=t.renderMol(n,{width:this._width,height:this._height,theme:e,fixedModelBbox:this._pinnedBbox});this._svgRoot=function(t,e){let n=nt(t),i=t.querySelector(".hw-editor-view");if(null===i)throw new Error("EditorView.replaceSvg: missing .hw-editor-view wrapper.");let o=n.createElement("div");o.innerHTML=e;let r=o.querySelector("svg");if(null===r)throw new Error("EditorView.replaceSvg: rendered output contained no <svg>.");for(;null!==i.firstChild;)i.removeChild(i.firstChild);return i.appendChild(r),r}(this.host,i);let o=this._svgRoot.querySelector(".hw-content");return this._baseTransform=null!==o?o.getAttribute("transform")??"":"",this._svgRoot.setAttribute("data-testid","editor-svg"),this._applyOverlaysToCurrent(),(1!==this._viewport.scale||0!==this._viewport.offset.x||0!==this._viewport.offset.y)&&this._applyViewport(this._viewport),this._svgRoot}_refreshOverlays(t){this._applyOverlaysToCurrent()}_applyOverlaysToCurrent(){let t=this._editor.getMol(),e=this._editor.getSelection(),n=function(t,e={}){let n=e.theme??H,i=e.selectedAtomIds??new Set;return{highlightLayer:J(t,n,e.highlightedAtomIds??new Set),selectionLayer:tt(t,n,i)}}(t,{theme:this._currentTheme(),selectedAtomIds:e.atoms,highlightedAtomIds:this._editorHighlights()});this._spliceLayer("hw-highlights",n.highlightLayer),this._spliceLayer("hw-selections",n.selectionLayer)}_spliceLayer(t,e){let n=this._svgRoot.querySelector(`.${t}`);if(null===n||null===n.parentNode)return;let i=this._doc.createElementNS("http://www.w3.org/2000/svg","svg");i.innerHTML=e;let o=i.querySelector(`.${t}`);null!==o&&n.parentNode.replaceChild(o,n)}_editorHighlights(){let t=this._editor;return"function"==typeof t._currentHighlights?t._currentHighlights():new Set}_currentTheme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_applyResize(t,e){this._width=t,this._height=e,this._pinnedBbox=null,this._renderFresh()}_applyViewport(t){let e=this._svgRoot.querySelector(".hw-content");if(null===e)return;let n=`translate(${t.offset.x} ${t.offset.y}) scale(${t.scale})`,i=""===this._baseTransform?n:`${n} ${this._baseTransform}`;e.setAttribute("transform",i)}_showTooltip(t,e,n){let i=this._tooltip;if(null===i)return;let o=""===t.symbol?"?":t.symbol,r=t.monomer?.name??"",s=t.bio.positionInChain,a=""===t.bio.chainId?"?":t.bio.chainId,l=""!==r&&r!==o?`${r} @ ${a}:${s}`:`${o} @ ${a}:${s}`,u=this._renderRdkitTooltipSvg(t);st(this._doc,i,{symbol:o,name:l,rdkitSvg:u,rdkitTestid:"atom-tooltip-rdkit-svg"});let c=""!==r&&r!==o?`${o} — ${r} @ ${a}:${s}`:`${o} @ ${a}:${s}`,h=this._doc.createElement("div");h.setAttribute("class","hw-atom-tooltip__text"),h.style.display="none",h.appendChild(this._doc.createTextNode(c)),i.appendChild(h),at(i,e,n)}_renderRdkitTooltipSvg(e){let n=this._editor.getService().options.rdkitModule;if(null==n)return null;let i=e.monomer;if(null===i)return null;let o=i.smiles;if(void 0===o||""===o)return null;let r=`${i.polymerType}:${i.symbol}`;if(this._rdkitSvgCache.has(r))return this._rdkitSvgCache.get(r)??null;let s=ot(n,o,220,140);if(this._rdkitSvgCache.size>=t._RDKIT_CACHE_LIMIT){let t=this._rdkitSvgCache.keys().next().value;void 0!==t&&this._rdkitSvgCache.delete(t)}return this._rdkitSvgCache.set(r,s),s}_hideTooltip(){lt(this._tooltip)}_showBondTooltip(t,e,n){let i=this._bondTooltip;if(null===i)return;let o=ht(t.r1),r=ht(t.r2),s=`${t.a1.symbol}@${t.a1.bio.chainId}:${t.a1.bio.positionInChain}`,a=`${t.a2.symbol}@${t.a2.bio.chainId}:${t.a2.bio.positionInChain}`;st(this._doc,i,{symbol:`${o}-${r} (${t.kind})`,name:`${s} ↔ ${a}`}),at(i,e,n)}_hideBondTooltip(){lt(this._bondTooltip)}_paintBondPreview(t,e,n){let i=this._svgRoot.querySelector(".hw-content");if(null===i)return;let o=i.querySelector(".hw-bond-preview");null===o&&(o=this._doc.createElementNS("http://www.w3.org/2000/svg","line"),o.setAttribute("class","hw-bond-preview"),o.setAttribute("data-testid","bond-preview"),o.setAttribute("stroke-dasharray","6 4"),o.setAttribute("stroke-width","2"),o.setAttribute("fill","none"),o.setAttribute("pointer-events","none"),i.appendChild(o)),o.setAttribute("x1",String(t.x)),o.setAttribute("y1",String(t.y)),o.setAttribute("x2",String(e.x)),o.setAttribute("y2",String(e.y)),o.setAttribute("stroke",n?"#1f5fcd":"#999999")}_clearBondPreview(){let t=this._svgRoot.querySelector(".hw-bond-preview");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)}_paintSelectionRect(t,e){let n=Math.min(t.x,e.x),i=Math.min(t.y,e.y),o=Math.abs(t.x-e.x),r=Math.abs(t.y-e.y);this._paintSelectionRectAt(n,i,o,r)}_paintSelectionRectFromRect(t){this._paintSelectionRectAt(t.x,t.y,t.width,t.height)}_paintSelectionRectAt(t,e,n,i){let o=this._svgRoot.querySelector(".hw-content");if(null===o)return;let r=o.querySelector(".hw-selection-rect");null===r&&(r=this._doc.createElementNS("http://www.w3.org/2000/svg","rect"),r.setAttribute("class","hw-selection-rect"),r.setAttribute("data-testid","selection-rect"),r.setAttribute("fill","rgba(31, 95, 205, 0.08)"),r.setAttribute("stroke","#1f5fcd"),r.setAttribute("stroke-width","1"),r.setAttribute("stroke-dasharray","4 3"),r.setAttribute("pointer-events","none"),o.appendChild(r)),r.setAttribute("x",String(t)),r.setAttribute("y",String(e)),r.setAttribute("width",String(n)),r.setAttribute("height",String(i))}_clearSelectionRect(){let t=this._svgRoot.querySelector(".hw-selection-rect");null!==t&&null!==t.parentNode&&t.parentNode.removeChild(t)}};ct._RDKIT_CACHE_LIMIT=256;function ht(t){switch(t.kind){case"numeric":return`R${t.r}`;case"unspecified":return"?";case"wildcard":return"*";case"pair":return"pair";case"positional":return`${t.position}pos:R${t.r}`}}var dt=class t{constructor(t,e){this._onClose=null,this._primaryAction=null,this._host=t,this._doc=e.documentImpl??nt(t);let n=this._doc,i={class:"hw-modal-backdrop",role:"presentation"};void 0!==e.testId&&(i["data-testid"]=`dialog-${e.testId}`);let o=it(n,"div",i),r={class:"hw-modal",role:"dialog","aria-modal":"true","aria-label":e.title};void 0!==e.testId&&(r["data-testid"]=`dialog-${e.testId}-frame`);let s=it(n,"div",r),a=it(n,"div",{class:"hw-modal__header"},[e.title]),l=it(n,"div",{class:"hw-modal__body"});s.appendChild(a),s.appendChild(l),o.appendChild(s);let u=t=>{t.stopPropagation()};for(let t of["mousedown","mousemove","mouseup","mouseover","mouseenter","mouseleave","wheel","contextmenu","dblclick","keydown","keyup","keypress"])o.addEventListener(t,u);s.addEventListener("keydown",t=>{let e=t;if("Enter"!==e.key||"TEXTAREA"===e.target?.tagName)return;let n=this._primaryAction;null!==n&&(e.preventDefault?.(),e.stopImmediatePropagation?.(),n())}),o.addEventListener("click",t=>{t.target!==o?t.stopPropagation():this.close()}),this.root=o,this.body=l}static anyOpen(){return t._openStack.length>0}static closeTopmost(){let e=t._openStack[t._openStack.length-1];return void 0!==e&&(e.close(),!0)}open(e){this._onClose=e??null,null===this.root.parentNode&&this._host.appendChild(this.root),t._openStack.includes(this)||t._openStack.push(this),ut(this._doc)}close(){let e=t._openStack.indexOf(this);e>=0&&t._openStack.splice(e,1),null!==this.root.parentNode&&this.root.parentNode.removeChild(this.root);let n=this._onClose;this._onClose=null,null!==n&&n()}setPrimaryAction(t){this._primaryAction=t}get isOpen(){return null!==this.root.parentNode}};dt._openStack=[];Object.freeze(new Set);function ft(t){return t.startsWith("[")&&t.endsWith("]")||1===t.length&&/^[A-Za-z]$/.test(t)?t:`[${t}]`}function mt(t,e,n){return`${ft(t)}(${ft(e)})${ft(n)}`}var pt="http://www.w3.org/2000/svg",gt={sugar:s.SUGAR,base:s.BASE,linker:s.LINKER},vt={sugar:["r","R"],base:["A"],linker:["p","P"]},Ct={x:70,y:60},yt={x:140,y:60},bt={x:70,y:130},_t=class t{constructor(t,e,n){this.onValueSet=new l,this.onPickModeChange=new l,this._slots=new Map,this._favStar=null,this._pickMode=null,this._destroyed=!1,this._builderRdkitCache=new Map,this._editor=e,this._doc=n?.documentImpl??nt(t),this._hooks=n?.paletteHooks??null,this._favHooks=n?.favoriteHooks??null,this.element=it(this._doc,"div",{class:"hw-rna-builder","data-testid":"rna-builder"});let i=it(this._doc,"div",{class:"hw-rna-builder__header"});if(i.appendChild(it(this._doc,"div",{class:"hw-rna-builder__title"},["RNA builder"])),null!==this._favHooks){let t=it(this._doc,"span",{class:"hw-rna-builder__fav hw-rna-builder__fav--disabled",role:"button",tabindex:"0","data-testid":"rna-builder-fav-star",title:"Favorite this triplet","aria-pressed":"false","aria-disabled":"true"},["☆"]),e=t=>{t.stopPropagation();let e=this.getSelection();""===e.preview||null===this._favHooks||this._favHooks.toggleFavoriteTriplet(e.sugar,e.base,e.linker)};t.addEventListener("click",e),t.addEventListener("keydown",t=>{let n=t;("Enter"===n.key||" "===n.key)&&e(t)}),this._favStar=t,i.appendChild(t)}this.element.appendChild(i),this._hintEl=it(this._doc,"div",{class:"hw-rna-builder__hint","data-testid":"rna-builder-hint",hidden:!0}),this.element.appendChild(this._hintEl);let o=this._buildSvg();this.element.appendChild(o),this._preview=it(this._doc,"div",{class:"hw-rna-builder__preview","data-testid":"rna-builder-preview"}),this.element.appendChild(this._preview),this._addBtn=it(this._doc,"button",{class:"hw-rna-builder__add",type:"button","data-testid":"rna-builder-add-btn"},["Add triplet"]),this._addBtn.addEventListener("click",()=>this._onAddClicked()),this.element.appendChild(this._addBtn),t.appendChild(this.element);let r=e.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),s=e.on("theme:change",()=>{this._destroyed||this._repaintSlotColors()});this._libUnsub=()=>{try{r()}catch{}try{s()}catch{}},this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}refresh(){this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}getSelection(){let t=this._slots.get("sugar")?.value??"",e=this._slots.get("base")?.value??"",n=this._slots.get("linker")?.value??"";return{sugar:t,base:e,linker:n,preview:""!==t&&""!==e&&""!==n?mt(t,e,n):""}}setField(t,e){let n=this._slots.get(t);void 0!==n&&(n.value=e,this._setLabelText(n.labelEl,e),this._repaintSlot(n),this._updatePreview(),this.onValueSet.next({field:t,symbol:e}))}startPickMode(t){this._pickMode!==t?(null!==this._pickMode&&this._setSlotPressed(this._pickMode,!1),this._pickMode=t,this._setSlotPressed(t,!0),this._setHintActive(t),this.onPickModeChange.next({field:t}),null!==this._hooks&&this._hooks.beginBiotypeFilter(gt[t],e=>{this.setField(t,e),this._exitPickMode()},()=>{this._exitPickMode()})):this.cancelPickMode()}cancelPickMode(){null!==this._pickMode&&(null!==this._hooks&&this._hooks.endBiotypeFilter(),this._exitPickMode())}getPickMode(){return this._pickMode}triggerAdd(){this._onAddClicked()}destroy(){this._destroyed||(this._destroyed=!0,null!==this._pickMode&&null!==this._hooks&&this._hooks.endBiotypeFilter(),this._libUnsub(),this.onValueSet.complete(),this.onPickModeChange.complete(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}_buildSvg(){let t=this._doc.createElementNS(pt,"svg");t.setAttribute("class","hw-rna-builder__triplet"),t.setAttribute("viewBox","0 0 200 180"),t.setAttribute("data-testid","rna-builder-triplet-svg"),t.setAttribute("role","group"),t.setAttribute("aria-label","Triplet preview");let e=this._doc.createElementNS(pt,"line");e.setAttribute("class","hw-rna-builder__bond"),e.setAttribute("x1",String(Ct.x+18)),e.setAttribute("y1",String(Ct.y)),e.setAttribute("x2",String(yt.x-18)),e.setAttribute("y2",String(yt.y)),t.appendChild(e);let n=this._doc.createElementNS(pt,"line");n.setAttribute("class","hw-rna-builder__bond"),n.setAttribute("x1",String(Ct.x)),n.setAttribute("y1",String(Ct.y+18)),n.setAttribute("x2",String(bt.x)),n.setAttribute("y2",String(bt.y-22)),t.appendChild(n);let i=this._doc.createElementNS(pt,"rect");i.setAttribute("class","hw-rna-builder__slot-shape"),i.setAttribute("x",String(-18)),i.setAttribute("y",String(-18)),i.setAttribute("width",String(36)),i.setAttribute("height",String(36)),i.setAttribute("rx","8"),i.setAttribute("ry","8");let o=this._buildSlot("sugar","Pick sugar (backbone)",Ct,i),r=this._doc.createElementNS(pt,"circle");r.setAttribute("class","hw-rna-builder__slot-shape"),r.setAttribute("cx","0"),r.setAttribute("cy","0"),r.setAttribute("r",String(18));let s=this._buildSlot("linker","Pick linker",yt,r),a=this._doc.createElementNS(pt,"path");a.setAttribute("class","hw-rna-builder__slot-shape"),a.setAttribute("d","M -22 0 L 0 -22 L 22 0 L 0 22 Z");let l=this._buildSlot("base","Pick base",bt,a);return t.appendChild(s.groupEl),t.appendChild(o.groupEl),t.appendChild(l.groupEl),this._slots.set("sugar",o),this._slots.set("linker",s),this._slots.set("base",l),t}_buildSlot(t,e,n,i){let o=this._doc.createElementNS(pt,"g");o.setAttribute("class","hw-rna-builder__slot"),o.setAttribute("data-slot",t),o.setAttribute("data-testid",`rna-builder-slot-${t}`),o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",e),o.setAttribute("aria-pressed","false"),o.setAttribute("transform",`translate(${n.x} ${n.y})`),o.appendChild(i);let r=this._doc.createElementNS(pt,"text");r.setAttribute("class","hw-rna-builder__slot-label"),r.setAttribute("data-testid",`rna-builder-${t}-value`),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("text-anchor","middle"),r.setAttribute("dominant-baseline","central"),o.appendChild(r);let s=e=>{e.stopPropagation(),this.startPickMode(t)};return o.addEventListener("click",s),o.addEventListener("keydown",t=>{let e=t;("Enter"===e.key||" "===e.key)&&s(t)}),o.addEventListener("mouseenter",e=>this._showSlotTooltip(t,e)),o.addEventListener("mouseleave",()=>this._hideSlotTooltip()),o.addEventListener("focus",()=>this._showSlotTooltip(t,null)),o.addEventListener("blur",()=>this._hideSlotTooltip()),{id:t,biotype:gt[t],groupEl:o,shapeEl:i,labelEl:r,value:""}}_setLabelText(t,e){let n=[];for(let e=t.firstChild;null!==e;e=e.nextSibling)"title"===e.nodeName||"TITLE"===e.nodeName||n.push(e);for(let e of n)t.removeChild(e);let i=function(t){let e=t.length;return e<=2?16:e<=4?11:e<=7?8:e<=10?6:5}(e);t.setAttribute("font-size",String(i)),t.setAttribute("text-anchor","middle"),t.setAttribute("dominant-baseline","central");let o=e.length>10?`${e.slice(0,9)}…`:e;t.appendChild(this._doc.createTextNode(o));let r=t.parentNode;if(null!==r){let t=null;for(let e=r.firstChild;null!==e;e=e.nextSibling)if("title"===e.nodeName||"TITLE"===e.nodeName){t=e;break}for(null===t&&(t=this._doc.createElementNS(pt,"title"),r.insertBefore(t,r.firstChild));null!==t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._doc.createTextNode(e))}}_repaintSlotColors(){for(let t of this._slots.values())this._repaintSlot(t)}_repaintSlot(t){let e=this._editor.getService().monomerLib,n=this._theme(),i=""===t.value?null:function(t,e,n){return t.getMonomerSet(e).get(n)??null}(e,t.biotype,t.value),o=P(i,t.biotype,n.colorTheme);t.shapeEl.style.fill=o.background,t.shapeEl.style.stroke=o.line,t.labelEl.style.fill=o.text}_populateDefaults(){let t=this._editor.getService().monomerLib;for(let[e,n]of this._slots.entries()){let i=At(t,n.biotype),o=St(i,vt[e]),r=""!==n.value&&i.some(t=>t.symbol===n.value)?n.value:o??i[0]?.symbol??"";n.value=r,this._setLabelText(n.labelEl,r)}}_updatePreview(){let t=this.getSelection();for(;null!==this._preview.firstChild;)this._preview.removeChild(this._preview.firstChild);this._preview.appendChild(this._doc.createTextNode(""===t.preview?"-":t.preview)),this._updateFavStar(t)}_updateFavStar(t){if(null===this._favStar||null===this._favHooks)return;let e=""!==t.preview,n=e&&this._favHooks.isFavoriteTriplet(t.sugar,t.base,t.linker);for(;null!==this._favStar.firstChild;)this._favStar.removeChild(this._favStar.firstChild);this._favStar.appendChild(this._doc.createTextNode(n?"★":"☆")),this._favStar.setAttribute("aria-pressed",n?"true":"false"),e?this._favStar.removeAttribute("aria-disabled"):this._favStar.setAttribute("aria-disabled","true");let i="hw-rna-builder__fav"+(n?" hw-rna-builder__fav--active":"")+(e?"":" hw-rna-builder__fav--disabled");this._favStar.setAttribute("class",i)}_onAddClicked(){let t=this.getSelection();""!==t.preview&&this._editor.placeRnaTriplet(t.sugar,t.base,t.linker)}_exitPickMode(){if(null===this._pickMode)return;let t=this._pickMode;this._setSlotPressed(t,!1),this._pickMode=null,this._setHintActive(null),this.onPickModeChange.next({field:null})}_setHintActive(t){let e=this._hintEl;for(;null!==e.firstChild;)e.removeChild(e.firstChild);if(null===t)return void e.setAttribute("hidden","");e.removeAttribute("hidden");let n="sugar"===t?"sugar":"base"===t?"base":"linker";e.appendChild(this._doc.createTextNode(`Pick ${n} from palette`))}_setSlotPressed(t,e){let n=this._slots.get(t);if(void 0===n)return;n.groupEl.setAttribute("aria-pressed",e?"true":"false");let i=(n.groupEl.getAttribute("class")??"").split(/\s+/).filter(t=>"hw-rna-builder__slot--active"!==t).join(" ");n.groupEl.setAttribute("class",e?`${i} hw-rna-builder__slot--active`:i)}_theme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_rdkit(){let t=this._editor.getService().options?.rdkitModule;return t??null}_builderRdkitSvgFor(e){if(null===e)return null;let n=e.smiles;if(void 0===n||""===n)return null;let i=this._rdkit();if(null===i)return null;let o=`${e.polymerType}:${e.symbol}`;if(this._builderRdkitCache.has(o))return this._builderRdkitCache.get(o)??null;let r=ot(i,n,220,140);if(this._builderRdkitCache.size>=t._BUILDER_RDKIT_CACHE_LIMIT){let t=this._builderRdkitCache.keys().next().value;void 0!==t&&this._builderRdkitCache.delete(t)}return this._builderRdkitCache.set(o,r),r}_slotHint(t){switch(t){case"sugar":return"Click to choose a different sugar";case"base":return"Click to choose a different base";case"linker":return"Click to choose a different linker"}}_slotTitle(t,e){let n=""===e?"?":e;switch(t){case"sugar":return`Sugar: ${n}`;case"base":return`Base: ${n}`;case"linker":return`Linker: ${n}`}}_showSlotTooltip(t,e){let n=this._slots.get(t);if(void 0===n)return;let i=this._editor.getService().monomerLib.getMonomerSet(n.biotype),o=""===n.value?null:i.get(n.value)??null,r=rt(this._doc,"builder-tooltip","hw-builder-tooltip");st(this._doc,r,{symbol:this._slotTitle(t,n.value),name:o?.name??"",rdkitSvg:this._builderRdkitSvgFor(o),rdkitTestid:"builder-tooltip-rdkit-svg",hint:this._slotHint(t)});let s=e;if(null!==s&&"number"==typeof s.clientX&&"number"==typeof s.clientY)at(r,s.clientX,s.clientY);else{let t=n.groupEl,e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null;null!==e?at(r,e.left+e.width/2,e.top+e.height/2):at(r,0,0)}}_hideSlotTooltip(){lt(this._doc.body.querySelector('[data-testid="builder-tooltip"]'))}};_t._BUILDER_RDKIT_CACHE_LIMIT=256;var wt=_t;function At(t,e){let n=t.getMonomerSet(e),i=[];for(let t of n.values())i.push(t);return i.sort((t,e)=>t.symbol.localeCompare(e.symbol)),i}function St(t,e){let n=new Set;for(let e of t)n.add(e.symbol);for(let t of e)if(n.has(t))return t;return null}var Tt="Favorites",Et={[Tt]:"★ Favorites",[a.PEPTIDE]:"Peptides",[a.RNA]:"RNA",[a.CHEM]:"CHEM",[a.BLOB]:"BLOB",G:"G"},Nt=[Tt,a.PEPTIDE,a.RNA,a.CHEM,a.BLOB,"G"],xt="hwe:palette:favorites",Mt="hwe:palette:active-tab";function It(t){return`${t.sugar}|${t.base}|${t.linker}`}var Ot=class t{constructor(t,e,n){this.favoritesChanged=new l,this._nextAddUnsub=()=>{},this._favorites=new Set,this._favoriteTriplets=[],this._pendingRnaSelection=null,this._visibleTabs=[Tt],this._activeTab=Tt,this._searchInput=null,this._filter="",this._destroyed=!1,this._rnaBuilder=null,this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,this._pickEscapeListener=null,this._pickOutsideClickListener=null,this._paletteRdkitCache=new Map,this._editor=e,this._doc=n?.documentImpl??nt(t),this._opts={documentImpl:this._doc,groupByNaturalAnalog:n?.groupByNaturalAnalog??!0,allowFavorites:n?.allowFavorites??!0},this._loadFavorites(),this._activeTab=this._resolveInitialTab(n?.initialTab),this.element=it(this._doc,"div",{class:"hw-palette","data-testid":"palette"}),t.appendChild(this.element),this._render(),this._libUnsub=e.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),this._themeUnsub=e.on("theme:change",()=>{this._destroyed||this.refresh()}),this._nextAddUnsub=e.on("option:change",t=>{this._destroyed||"nextAdd"===t.key&&this._updatePrimedClasses()})}refresh(){this._render()}setFilter(t){this._filter=t.trim().toLowerCase(),null!==this._searchInput&&this._searchInput.value!==t&&(this._searchInput.value=t),this._applyFilter()}setActiveTab(t){this._visibleTabs.includes(t)&&(this._activeTab=t,this._persistActiveTab(),this._applyActiveTabClasses(),this._applyFilter())}getActiveTab(){return this._activeTab}getFavorites(){let t=this._editor.getService().monomerLib,e=[];for(let n of this._favorites)null!==this._findMonomer(t,n)&&e.push(n);return e}setFavorite(t,e){e!==this._favorites.has(t)&&(e?this._favorites.add(t):this._favorites.delete(t),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}clearFavorites(){0===this._favorites.size&&0===this._favoriteTriplets.length||(this._favorites.clear(),this._favoriteTriplets.length=0,this._saveFavorites(),this._render(),this._emitFavoritesChanged())}getFavoriteTriplets(){return this._favoriteTriplets.map(t=>({...t}))}isFavoriteTriplet(t,e,n){let i=It({sugar:t,base:e,linker:n});return this._favoriteTriplets.some(t=>It(t)===i)}setFavoriteTriplet(t,e,n,i){let o=It({sugar:t,base:e,linker:n}),r=this._favoriteTriplets.findIndex(t=>It(t)===o);i!==r>=0&&(i?this._favoriteTriplets.push({sugar:t,base:e,linker:n}):this._favoriteTriplets.splice(r,1),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}_hidePaletteTooltips(){let t=this._doc.body;lt(t.querySelector('[data-testid="palette-tooltip"]')),lt(t.querySelector('[data-testid="palette-triplet-tooltip"]'))}_emitFavoritesChanged(){this.favoritesChanged.next({favorites:this.getFavorites(),triplets:this.getFavoriteTriplets()})}destroy(){this._destroyed||(this._destroyed=!0,null!==this._rnaBuilder&&(this._rnaBuilder.destroy(),this._rnaBuilder=null),this._libUnsub(),this._themeUnsub(),this._nextAddUnsub(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}getRnaBuilder(){return this._rnaBuilder}hasActiveBiotypeFilter(){return null!==this._activeBiotypeFilter}getActiveBiotypeFilter(){return this._activeBiotypeFilter}cancelBiotypeFilter(){if(null===this._activeBiotypeFilter)return;let t=this._pickCanceller;this._teardownPickMode(),t?.()}_buildPaletteFilterHooks(){return{beginBiotypeFilter:(t,e,n)=>{null!==this._activeBiotypeFilter&&this._teardownPickMode(),this._activeBiotypeFilter=t,this._pickResolver=e,this._pickCanceller=n,this._applyFilter();let i=t=>{"Escape"===t.key&&this.cancelBiotypeFilter()};this._pickEscapeListener=i,this._doc.defaultView?.addEventListener("keydown",i);let o=t=>{if(null===this._activeBiotypeFilter)return;let e=t.target;if(null==e)return;let n=this._activeBiotypeFilter,i=e;for(;null!==i;){let t=void 0===i.getAttribute?null:i.getAttribute("class");if(null!==t){let e=t.split(/\s+/);if(e.includes("hw-palette__tile")){if((i.getAttribute("data-biotype")??"")===n)return;break}if(e.includes("hw-rna-builder__slot")){if(this._isInsideOwnPalette(i))return;break}}i=i.parentElement}this.cancelBiotypeFilter()};this._pickOutsideClickListener=o,this._doc.addEventListener("mousedown",o,!0)},endBiotypeFilter:()=>this._teardownPickMode()}}_scrollActivePaneToTop(){let t=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`);if(null===t)return;let e=t;try{if("function"==typeof e.scrollTo)return void e.scrollTo({top:0,behavior:"smooth"})}catch{}"number"==typeof e.scrollTop&&(e.scrollTop=0)}_isInsideOwnPalette(t){let e=t;for(;null!==e;){if(e===this.element)return!0;e=e.parentElement}return!1}_teardownPickMode(){null!==this._activeBiotypeFilter&&(this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,null!==this._pickEscapeListener&&(this._doc.defaultView?.removeEventListener("keydown",this._pickEscapeListener),this._pickEscapeListener=null),null!==this._pickOutsideClickListener&&(this._doc.removeEventListener("mousedown",this._pickOutsideClickListener,!0),this._pickOutsideClickListener=null),this._applyFilter())}_render(){for(null!==this._rnaBuilder&&(this._pendingRnaSelection=this._rnaBuilder.getSelection(),this._rnaBuilder.destroy(),this._rnaBuilder=null);null!==this.element.firstChild;)this.element.removeChild(this.element.firstChild);let t=this._doc.createElement("input");t.setAttribute("type","search"),t.setAttribute("class","hw-palette__search"),t.setAttribute("placeholder","Search monomers..."),t.setAttribute("data-testid","palette-search"),""!==this._filter&&(t.value=this._filter),t.addEventListener("input",()=>this.setFilter(t.value)),this._searchInput=t,this.element.appendChild(t),this._visibleTabs=this._computeVisibleTabs(),this._visibleTabs.includes(this._activeTab)||(this._activeTab=Tt);let e=it(this._doc,"div",{class:"hw-palette__tabs",role:"tablist","data-testid":"palette-tabs"});for(let t of this._visibleTabs){let n=t===this._activeTab,i=it(this._doc,"button",{class:"hw-palette__tab",type:"button",role:"tab","aria-controls":`hw-palette-pane-${t}`,"aria-selected":n?"true":"false","data-testid":`palette-tab-${t}`,"data-tab":t,title:Et[t]},[Et[t]]);i.addEventListener("click",()=>this.setActiveTab(t)),e.appendChild(i)}this.element.appendChild(e);let n=it(this._doc,"div",{class:"hw-palette__panes"}),i=this._theme(),o=this._editor.getService().monomerLib;for(let t of this._visibleTabs){let e=t===this._activeTab,r=it(this._doc,"div",{class:"hw-palette__pane",id:`hw-palette-pane-${t}`,role:"tabpanel","data-testid":`palette-pane-${t}`,"data-tab":t,hidden:!e});t===Tt?this._buildFavoritesPane(r,o,i):this._buildPolymerPane(r,t,o,i),n.appendChild(r)}this.element.appendChild(n),this._applyFilter()}_computeVisibleTabs(){let t=this._editor.getService().monomerLib,e=new Set;for(let n of t.getPolymerTypes())e.add(n);let n=[];n.push(Tt);for(let t of Nt)t!==Tt&&e.has(t)&&n.push(t);return n}_buildFavoritesPane(t,e,n){let i=this._resolveFavoriteMonomers(e),o=this._favoriteTriplets;if(0===i.length&&0===o.length){let e=it(this._doc,"div",{class:"hw-palette__placeholder","data-testid":"palette-favorites-empty"},["No favorites yet — click the ☆ on any tile to add one."]);return void t.appendChild(e)}for(let[e,n]of this._groupByPolymerAndType(i))t.appendChild(this._renderGroup(e,n));o.length>0&&t.appendChild(this._renderTripletGroup("RNA · Triplets",o,e))}_groupByPolymerAndType(t){let e=new Map;for(let n of t){let t=n.polymerType,i=n.monomerType??"Undefined",o=`${t}|${i}`,r=e.get(o);void 0===r&&(r={pt:t,mt:i,list:[]},e.set(o,r)),r.list.push(n)}let n=t=>{let e=Nt.indexOf(t);return e<0?99:e},i={Backbone:0,Branch:1,Terminal:2,Undefined:3};return Array.from(e.values()).sort((t,e)=>n(t.pt)-n(e.pt)||(i[t.mt]??9)-(i[e.mt]??9)||t.mt.localeCompare(e.mt)).map(t=>[`${this._polymerLabel(t.pt)} · ${t.mt}`,t.list])}_polymerLabel(t){return Et[t]??t}_renderTripletGroup(t,e,n){let i=it(this._doc,"div",{class:"hw-palette__group","data-natural-analog":t}),o=it(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${t}`},[t]),r=it(this._doc,"div",{class:"hw-triplet-chips","data-testid":"palette-triplet-favorites"});for(let t of e)r.appendChild(this._renderTripletChip(t,n));return i.appendChild(o),i.appendChild(r),i}_renderTripletChip(t,e){let n=mt(t.sugar,t.base,t.linker),i=e.getMonomerSet(s.BASE).get(t.base)??null,o=P(i,s.BASE,this._theme().colorTheme),r=this.isFavoriteTriplet(t.sugar,t.base,t.linker),a=void 0!==i?.name&&""!==i.name?`${n} — ${i.name}`:n,{root:l}=function(t,e){let n=!1!==e.showStar,i=it(t,"span",{class:"hw-triplet-chip__star"},[e.favorite?"★":"☆"]),o=it(t,"span",{class:"hw-triplet-chip__label"},[e.label]),r=["hw-triplet-chip"];e.favorite&&r.push("hw-triplet-chip--favorite");let s=n?[i,o]:[o];return{root:it(t,"div",{class:r.join(" "),role:"button",tabindex:"0","aria-label":e.title,"data-sugar":e.sugar,"data-base":e.base,"data-linker":e.linker,"data-triplet":e.label,"data-testid":`palette-triplet-${e.label}`,title:e.title,style:`background:${e.background};color:${e.textColor};`},s),star:i}}(this._doc,{sugar:t.sugar,base:t.base,linker:t.linker,label:n,title:a,background:v(o.background),textColor:o.text,favorite:r,showStar:this._opts.allowFavorites});return this._wireTripletChip(l,t),l}_wireTripletChip(t,e){t.addEventListener("mouseenter",t=>{let n=t,i=rt(this._doc,"palette-triplet-tooltip","hw-palette-tooltip hw-triplet-tooltip");(function(t,e,n){for(;null!==e.firstChild;)e.removeChild(e.firstChild);e.appendChild(it(t,"div",{class:"hw-tooltip__symbol"},[n.title]));let i=it(t,"div",{class:"hw-tooltip__triplet"});for(let e of n.parts){let o=it(t,"div",{class:"hw-tooltip__triplet-part"});if(o.appendChild(it(t,"div",{class:"hw-tooltip__triplet-role"},[`${e.role}: ${e.symbol}`])),void 0!==e.name&&""!==e.name&&e.name!==e.symbol&&o.appendChild(it(t,"div",{class:"hw-tooltip__name"},[e.name])),void 0!==e.rdkitSvg&&null!==e.rdkitSvg&&""!==e.rdkitSvg){let i={class:"hw-tooltip__rdkit"};void 0!==n.rdkitTestid&&(i["data-testid"]=n.rdkitTestid);let r=it(t,"div",i);r.innerHTML=e.rdkitSvg,o.appendChild(r)}i.appendChild(o)}e.appendChild(i),void 0!==n.hint&&""!==n.hint&&e.appendChild(it(t,"div",{class:"hw-tooltip__hint"},[n.hint]))})(this._doc,i,{title:mt(e.sugar,e.base,e.linker),parts:this._tripletTooltipParts(e),hint:"Click to add this triplet",rdkitTestid:"palette-triplet-tooltip-rdkit-svg"}),at(i,"number"==typeof n.clientX?n.clientX:0,"number"==typeof n.clientY?n.clientY:0)}),t.addEventListener("mouseleave",()=>{lt(this._doc.body.querySelector('[data-testid="palette-triplet-tooltip"]'))}),t.addEventListener("click",t=>{let n=t.target;if(this._opts.allowFavorites&&!0===n?.classList?.contains("hw-triplet-chip__star"))return this.setFavoriteTriplet(e.sugar,e.base,e.linker,!this.isFavoriteTriplet(e.sugar,e.base,e.linker)),void t.stopPropagation();this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)}),t.addEventListener("keydown",t=>{let n=t;("Enter"===n.key||" "===n.key)&&this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)})}_buildRnaDefaultChips(e){let n=this._pickSymbol(e.getMonomerSet(s.SUGAR),["r","R"]),i=this._pickSymbol(e.getMonomerSet(s.LINKER),["p","P"]),o=e.getMonomerSet(s.BASE);if(null===n||null===i)return null;let r=t._DEFAULT_TRIPLET_BASES.filter(t=>o.has(t));if(0===r.length)return null;let a=it(this._doc,"div",{class:"hw-triplet-chips hw-triplet-chips--defaults","data-testid":"rna-default-triplets"});for(let t of r)a.appendChild(this._renderTripletChip({sugar:n,base:t,linker:i},e));return a}_tripletTooltipParts(t){let e=this._editor.getService().monomerLib,n=(t,n,i)=>{let o=e.getMonomerSet(n).get(i)??null;return{role:t,symbol:i,...void 0!==o?.name?{name:o.name}:{},rdkitSvg:null===o?null:this._paletteRdkitSvg(o)}};return[n("Sugar",s.SUGAR,t.sugar),n("Base",s.BASE,t.base),n("Linker",s.LINKER,t.linker)]}_pickSymbol(t,e){for(let n of e)if(t.has(n))return n;let n=t.keys().next();return!0===n.done?null:n.value}_restoreRnaSelection(){let t=this._pendingRnaSelection;if(this._pendingRnaSelection=null,null===t||null===this._rnaBuilder)return;let e=this._editor.getService().monomerLib;""!==t.sugar&&e.getMonomerSet(s.SUGAR).has(t.sugar)&&this._rnaBuilder.setField("sugar",t.sugar),""!==t.base&&e.getMonomerSet(s.BASE).has(t.base)&&this._rnaBuilder.setField("base",t.base),""!==t.linker&&e.getMonomerSet(s.LINKER).has(t.linker)&&this._rnaBuilder.setField("linker",t.linker)}_resolveFavoriteMonomers(t){let e=[];for(let n of this._favorites){let i=this._findMonomer(t,n);null!==i&&e.push(i)}return e}_findMonomer(t,e){for(let n of t.getPolymerTypes()){let i=t.getMonomer(n,e);if(null!==i)return i}return null}_buildPolymerPane(t,e,n,i){let o=e,r=this._monomersForPolymer(o,n);if(0===r.length)return;if(o===a.RNA){this._rnaBuilder=new wt(t,this._editor,{documentImpl:this._doc,paletteHooks:this._buildPaletteFilterHooks(),favoriteHooks:this._opts.allowFavorites?{isFavoriteTriplet:(t,e,n)=>this.isFavoriteTriplet(t,e,n),toggleFavoriteTriplet:(t,e,n)=>this.setFavoriteTriplet(t,e,n,!this.isFavoriteTriplet(t,e,n))}:null}),this._restoreRnaSelection();let e=this._buildRnaDefaultChips(n);null!==e&&t.appendChild(e);let i=this._groupRna(r);for(let[e,n]of i)0!==n.length&&t.appendChild(this._renderGroup(e,n));return}if(o===a.PEPTIDE&&this._opts.groupByNaturalAnalog){let e=this._groupByAnalog(r);for(let[n,i]of e){let e=""===n?"Other":n;t.appendChild(this._renderGroup(e,i))}return}let s=it(this._doc,"div",{class:"hw-palette__group-tiles"}),l=this._editor.getNextAddSymbol(),u=this._sortByColor(r);for(let t of u){let e=this._biotype(t,o);s.appendChild(this._renderTile(t,e,l))}t.appendChild(s)}_renderGroup(t,e){let n=it(this._doc,"div",{class:"hw-palette__group","data-natural-analog":t}),i=it(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${t}`},[t]),o=it(this._doc,"div",{class:"hw-palette__group-tiles"}),r=this._editor.getNextAddSymbol(),s=this._sortByColor(e);for(let t of s){let e=this._biotype(t,t.polymerType);o.appendChild(this._renderTile(t,e,r))}return n.appendChild(i),n.appendChild(o),n}_sortByColor(t){let e=this._theme(),n=t.map((t,n)=>{let i=function(t){let e=h(t);if(null===e)return{h:0,s:0,l:0};let[n,i,o]=m(e[0],e[1],e[2]);return{h:n,s:i,l:o}}(P(t,this._biotype(t,t.polymerType),e.colorTheme).background),o=0===i.s?1:0;return{m:t,idx:n,h:i.h,s:i.s,l:i.l,isGrey:o}});return n.sort((t,e)=>t.isGrey!==e.isGrey?t.isGrey-e.isGrey:t.h!==e.h?t.h-e.h:t.s!==e.s?t.s-e.s:t.l!==e.l?t.l-e.l:t.idx-e.idx),n.map(t=>t.m)}_monomersForPolymer(t,e){let n=e.getMonomerSymbolsByType(t),i=[];for(let o of n){let n=e.getMonomer(t,o);null!==n&&i.push(n)}return i.sort((t,e)=>t.symbol.localeCompare(e.symbol)),i}_groupByAnalog(t){let e=new Map;for(let n of t){let t=n.naturalAnalog??"",i=e.get(t);void 0===i&&(i=[],e.set(t,i)),i.push(n)}let n=[],i=Array.from(e.keys()).sort((t,e)=>""===t&&""!==e?1:""===e&&""!==t?-1:t.localeCompare(e));for(let t of i)n.push([t,e.get(t)]);return new Map(n)}_groupRna(t){let e=[],n=[],i=[],o=[];for(let r of t){let t=L(r);t===s.SUGAR?e.push(r):t===s.BASE?n.push(r):t===s.LINKER?i.push(r):o.push(r)}let r=new Map;return r.set("Backbones",e),r.set("Bases",n),r.set("Linkers",i),o.length>0&&r.set("Other",o),r}_renderTile(t,e,n){let i=this._favorites.has(t.symbol),o=null!==n&&n.symbol===t.symbol&&n.biotype===e,{root:r,star:s}=function(t,e){let n=P(e.monomer,e.biotype,e.theme.colorTheme),i=v(n.background),o=n.text,r=function(t,e){let n=C(t),i=C(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}(o,i)<5,s=e.monomer.symbol,a=function(t){return t<=3?14:t<=6?11:t<=9?9:8}(s.length),l=`font-size:${a}px;${s.length>=10?"line-height:1.1;letter-spacing:-0.02em;":""}white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:80px;display:inline-block;`,u=it(t,"span",{class:"hw-palette__star"},[e.favorite?"★":"☆"]),c=it(t,"span",{class:"hw-palette__label",style:l},[s]),h=["hw-palette__tile"];e.primed&&h.push("hw-palette__tile--primed"),e.favorite&&h.push("hw-palette__tile--favorite"),r&&h.push("hw-palette__tile--low-contrast");let d=void 0!==e.monomer.name?`${s} — ${e.monomer.name}`:s,f=`background:${i};color:${o};width:100%;min-width:48px;padding:4px 6px;height:40px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;`;return{root:it(t,"div",{class:h.join(" "),draggable:"true",role:"button","aria-pressed":e.primed?"true":"false","aria-label":d,"data-symbol":s,"data-biotype":e.biotype,"data-bg":i,"data-raw-bg":n.background,"data-testid":`palette-tile-${s}`,title:d,style:f},[u,c]),star:u}}(this._doc,{monomer:t,biotype:e,theme:this._theme(),favorite:i,primed:o});return this._wireTile(r,s,t,e),r}_rdkit(){let t=this._editor.getService().options?.rdkitModule;return t??null}_paletteRdkitSvg(e){let n=e.smiles;if(void 0===n||""===n)return null;let i=this._rdkit();if(null===i)return null;let o=`${e.polymerType}:${e.symbol}`;if(this._paletteRdkitCache.has(o))return this._paletteRdkitCache.get(o)??null;let r=ot(i,n,220,140);if(this._paletteRdkitCache.size>=t._PALETTE_RDKIT_CACHE_LIMIT){let t=this._paletteRdkitCache.keys().next().value;void 0!==t&&this._paletteRdkitCache.delete(t)}return this._paletteRdkitCache.set(o,r),r}_wireTile(t,e,n,i){t.addEventListener("mouseenter",t=>{let e=t,i=rt(this._doc,"palette-tooltip","hw-palette-tooltip");st(this._doc,i,{symbol:n.symbol,name:n.name??"",rdkitSvg:this._paletteRdkitSvg(n),rdkitTestid:"palette-tooltip-rdkit-svg"}),at(i,"number"==typeof e.clientX?e.clientX:0,"number"==typeof e.clientY?e.clientY:0)}),t.addEventListener("mouseleave",()=>{lt(this._doc.body.querySelector('[data-testid="palette-tooltip"]'))}),t.addEventListener("click",t=>{let e=t.target;if(this._opts.allowFavorites&&void 0!==e&&!0===e?.classList?.contains("hw-palette__star"))return this.setFavorite(n.symbol,!this._favorites.has(n.symbol)),void t.stopPropagation();if(null!==this._activeBiotypeFilter&&this._activeBiotypeFilter===i){let e=this._pickResolver;return this._teardownPickMode(),e?.(n.symbol),this._scrollActivePaneToTop(),void t.stopPropagation()}let o=this._editor.getSelection();if(o.atoms.size>0){let e=this._editor.getMol(),r=[];for(let t of o.atoms){let n=e.atoms.find(e=>e.id===t);void 0!==n&&r.push(n)}return r.length>0&&r.every(t=>t.biotype===i)?(this._editor.replaceMonomers(r,n.symbol),void t.stopPropagation()):(this._editor.fire("editor:status",{message:`Cannot bulk-replace ${r.length} selected atom(s) with ${n.symbol}: selection contains incompatible biotypes for ${i}.`,severity:"warn",durationMs:3e3}),void t.stopPropagation())}let r=this._editor.getNextAddSymbol();if(null!==r&&r.symbol===n.symbol&&r.biotype===i)return this._editor.setNextAddSymbol(null),void this._updatePrimedClasses();this._editor.setNextAddSymbol(n.symbol,i),this._updatePrimedClasses()}),t.addEventListener("dragstart",t=>{let e=t.dataTransfer;if(null!=e)try{e.setData("application/x-hwe-monomer",JSON.stringify({symbol:n.symbol,biotype:i})),e.effectAllowed="copy"}catch{}lt(this._doc.body.querySelector('[data-testid="palette-tooltip"]')),this._editor.startPaletteDrag(n.symbol,i)})}_biotype(t,e){let n=L(t);if(null!==n)return n;switch(e){case a.PEPTIDE:return s.AA;case a.RNA:return s.SUGAR;case a.CHEM:return s.CHEM;case a.BLOB:return s.BLOB;default:return s.CHEM}}_theme(){let t=this._editor;return"function"==typeof t._currentTheme?t._currentTheme():this._editor.getService().theme}_applyFilter(){let t=this._filter,e=this._activeBiotypeFilter,n=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`),i=(n??this.element).querySelectorAll(".hw-palette__tile");for(let n=0;n<i.length;n++){let o=i[n],r=(o.getAttribute("data-symbol")??"").toLowerCase(),s=(o.getAttribute("title")??"").toLowerCase(),a=o.getAttribute("data-biotype")??"",l=(""===t||r.indexOf(t)>=0||s.indexOf(t)>=0)&&(null===e||a===e);o.style.display=l?"":"none"}let o=(n??this.element).querySelectorAll(".hw-triplet-chip");for(let n=0;n<o.length;n++){let i=o[n],r=[i.getAttribute("data-triplet")??"",i.getAttribute("data-sugar")??"",i.getAttribute("data-base")??"",i.getAttribute("data-linker")??""].join(" ").toLowerCase(),s=(""===t||r.indexOf(t)>=0)&&null===e;i.style.display=s?"":"none"}let r=(n??this.element).querySelectorAll(".hw-palette__group");for(let t=0;t<r.length;t++){let e=r[t],n=e.querySelectorAll(".hw-palette__tile, .hw-triplet-chip"),i=!1;for(let t=0;t<n.length;t++)if("none"!==n[t].style.display){i=!0;break}i?(e.removeAttribute("hidden"),e.removeAttribute("data-section-empty")):(e.setAttribute("hidden",""),e.setAttribute("data-section-empty","true"))}}_updatePrimedClasses(){let t=this._editor.getNextAddSymbol(),e=this.element.querySelectorAll(".hw-palette__tile");for(let n=0;n<e.length;n++){let i=e[n],o=i.getAttribute("data-symbol")??"",r=i.getAttribute("data-biotype")??"",s=null!==t&&t.symbol===o&&t.biotype===r,a=(i.getAttribute("class")??"").split(/\s+/).filter(t=>"hw-palette__tile--primed"!==t).join(" ");i.setAttribute("class",s?`${a} hw-palette__tile--primed`:a),i.setAttribute("aria-pressed",s?"true":"false")}}_applyActiveTabClasses(){let t=this.element.querySelectorAll(".hw-palette__tab");for(let e=0;e<t.length;e++){let n=t[e],i=n.getAttribute("data-tab")??"";n.setAttribute("aria-selected",i===this._activeTab?"true":"false")}let e=this.element.querySelectorAll(".hw-palette__pane");for(let t=0;t<e.length;t++){let n=e[t];(n.getAttribute("data-tab")??"")===this._activeTab?n.removeAttribute("hidden"):n.setAttribute("hidden","")}}_localStorage(){if(!this._opts.allowFavorites)return null;let t=this._doc.defaultView;if(null==t)return null;try{return t.localStorage??null}catch{return null}}_resolveInitialTab(t){if(void 0!==t&&Nt.includes(t))return t;let e=this._localStorage();if(null!==e)try{let t=e.getItem(Mt);if(null!==t&&Nt.includes(t))return t}catch{}return Tt}_persistActiveTab(){let t=this._localStorage();if(null!==t)try{t.setItem(Mt,this._activeTab)}catch{}}_loadFavorites(){let t=this._localStorage();if(null!==t){try{let e=t.getItem(xt);if(null!==e&&""!==e){let t=JSON.parse(e),n=this._extractSymbols(t);for(let t of n)this._favorites.add(t);for(let e of this._extractTriplets(t))this._favoriteTriplets.push(e);return}}catch{}try{let e=t.getItem("hwe.palette.favorites");if(null===e||""===e)return;let n=JSON.parse(e);if(Array.isArray(n)){for(let t of n){if("string"!=typeof t)continue;let e=t.indexOf("|"),n=e>=0?t.slice(e+1):t;""!==n&&this._favorites.add(n)}this._saveFavorites()}}catch{}}}_extractSymbols(t){if(Array.isArray(t)){let e=[];for(let n of t)"string"==typeof n&&e.push(n);return e}if(null!==t&&"object"==typeof t){let e=t;if(Array.isArray(e.symbols)){let t=[];for(let n of e.symbols)"string"==typeof n&&t.push(n);return t}}return[]}_extractTriplets(t){if(null===t||"object"!=typeof t)return[];let e=t;if(!Array.isArray(e.triplets))return[];let n=[];for(let t of e.triplets){if(null===t||"object"!=typeof t)continue;let e=t;"string"==typeof e.sugar&&"string"==typeof e.base&&"string"==typeof e.linker&&n.push({sugar:e.sugar,base:e.base,linker:e.linker})}return n}_saveFavorites(){let t=this._localStorage();if(null!==t)try{let e={symbols:Array.from(this._favorites)};this._favoriteTriplets.length>0&&(e.triplets=this._favoriteTriplets.map(t=>({...t}))),t.setItem(xt,JSON.stringify(e))}catch{}}};Ot._DEFAULT_TRIPLET_BASES=["A","C","G","U","T"],Ot._PALETTE_RDKIT_CACHE_LIMIT=256;new Set([a.PEPTIDE,a.RNA,a.CHEM,a.BLOB]),new Set(["Backbone","Branch","Terminal","Undefined"]);var Pt,Lt;!function(t){t[t.default=0]="default",t[t.continuous=1]="continuous"}(Pt||(Pt={})),function(t){t.Sequence="sequence",t.Helm="notation",t.Properties="properties",t.StructureView="structureview"}(Lt||(Lt={}))},4971(t,e,n){"use strict";n.d(e,{pj:()=>o});var i=n(6082);async function o(){const t=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===t.length)throw new Error('Package "Bio" must be installed for MonomerLibHelper.');return(await t[0].prepare().call()).getOutputParamValue()}},439(t,e,n){"use strict";n.d(e,{B5:()=>a,Hi:()=>i,YI:()=>o,b9:()=>c,gp:()=>r,jz:()=>h,q7:()=>u});var i,o,r,s=n(2738);!function(t){t.FASTA="fasta",t.SEPARATOR="separator",t.HELM="helm",t.CUSTOM="custom",t.BILN="biln"}(i||(i={})),function(t){t.DNA="DNA",t.RNA="RNA",t.PT="PT",t.UN="UN"}(o||(o={})),function(t){t.aligned="aligned",t.alphabet="alphabet",t.alphabetSize=".alphabetSize",t.alphabetIsMultichar=".alphabetIsMultichar",t.separator="separator",t.isHelmCompatible=".isHelmCompatible",t.positionNames=".positionNames",t.positionLabels=".positionLabels",t.regions=".regions",t.positionShift=".positionShift",t.selectedPosition=".selectedPosition",t.polymerTypeColumnName=".polymerTypeColumnName",t.annotations=".annotations",t.numberingScheme=".numberingScheme",t.annotationColumnName=".annotationColumnName"}(r||(r={}));const a=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,l=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},u=[new s.aD(o.PT,l.fasta.peptide,.5),new s.aD(o.DNA,l.fasta.dna,.55),new s.aD(o.RNA,l.fasta.rna,.55)],c={[i.FASTA]:"-",[i.SEPARATOR]:"",[i.HELM]:"*",[i.BILN]:""},h=".%monomer-canonicalizer-func"},2003(t,e,n){"use strict";n.d(e,{Hi:()=>i.Hi,SM:()=>o.SM,YI:()=>i.YI,gp:()=>i.gp,ot:()=>" , ",zS:()=>o.zS});var i=n(439),o=n(7194)},4025(t,e,n){"use strict";var i=n(6082);n(439),n(7194);const o=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};i.SemanticValue,n.d(e,["j",0,o])},2738(t,e,n){"use strict";n.d(e,{XN:()=>o,aD:()=>i}),n(439);class i{constructor(t,e,n){this.name=t,this.alphabet=e,this.cutoff=n}}class o extends i{constructor(t,e,n){super(t.name,t.alphabet,t.cutoff),this.freq=e,this.similarity=n}}},7194(t,e,n){"use strict";n.d(e,{Mu:()=>S,zS:()=>O,SM:()=>L,qp:()=>M});var i=n(6082),o=n(144),r=n.n(o);class s extends Float32Array{}function a(t){let e=0;for(let n=0;n<t.length;n++)e+=t[n]*t[n];return Math.sqrt(e)}var l=n(2738),u=n(439);class c{static makePalette(t,e=!1,n=c){const i={};return t.forEach(t=>{const n=t[0],o=t[1];n.forEach((t,n)=>{i[t]=this.colourPalette[o][e?0:n]})}),new n(i)}constructor(t){this._palette=t}get(t,e){return this._palette[t]}}c.undefinedColor="rgb(100,100,100)",c.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]};class h extends c{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,h)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,h)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new h({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(t){const e=t in h.aaSynonyms?h.aaSynonyms[t]:t;return super.get(e)}}h.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class d{static getPalette(t="grok"){switch(t){case"grok":return h.GrokGroups;case"lesk":return h.Lesk;default:throw new Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(t){let e=0,n="",i="";for(const o of t)"("==o?e++:")"==o?e--:e?n+=o:i+=o;return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(t="",e="grok"){const n=this.getPalette(e);let[i,o]=this.getInnerOuter(t);if(i=i.length>6?`${i.slice(0,3)}...`:i,o=o.length>6?`${o.slice(0,3)}...`:o,1==t.length||"("==t[1]){const e=t[0]?.toUpperCase();return e in n?[n.get(e),e,o,1]:[this.undefinedColor,i,o,1]}if("d"==t[0]&&t[1]in n&&(2==t.length||"("==t[2])){const e=t[1]?.toUpperCase();return e in n?[n.get(e),e,o,2]:[this.undefinedColor,i,o,2]}if(t.substring(0,3)in this.AAFullNames&&(3==t.length||"("==t[3])){const e=this.AAFullNames[t.substring(0,3)];return e in n?[n.get(e),e,o,3]:[this.undefinedColor,i,o,3]}if(t[0]?.toLowerCase()==t[0]&&t.substring(1,3)in this.AAFullNames&&(4==t.length||"("==t[4])){const e=this.AAFullNames[t.substring(1,3)];return e in n?[n.get(e),e,o,4]:[this.undefinedColor,i,o,4]}return[this.undefinedColor,i,o,0]}}d.SemType="Aminoacids",d.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",d.undefinedColor="rgb(100,100,100)",d.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},d.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},d.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},d.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"};class f extends c{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new f({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class m{}m.SemType="Nucleotides",m.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",m.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var p=n(4971),g=n(854);function v(t,e=!0){if(null==t)return"rgb(100,100,100)";const n=i.Color.fromHtml(t);if(e){const t=i.Color.g(n),e=i.Color.r(n),o=i.Color.b(n),r=Math.sqrt(Math.pow(0-e,2)+Math.pow(0-t,2)+Math.pow(0-o,2));if(r>210)return`rgb(${e/r*210},${t/r*210},${o/r*210})`}return i.Color.toRgb(n)}class C{static hashCode(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e}}class y{}class b extends y{get(t,e){return"#666666"}}class _ extends y{static get palette(){return _._pallete||(_._pallete=_.buildPalette()),_._pallete}static buildPalette(){return(0,p.pj)().then(t=>{t.awaitLoaded(1/0).then(()=>{const e=t.getMonomerLib();e.onChanged.subscribe(()=>{_.customMonomerColors={},_.polymerTypes=e.getPolymerTypes();for(const t of this.polymerTypes){const n=e.getMonomerSymbolsByType(t);for(const i of n){const n=e.getMonomer(t,i);n?.meta?.colors?.default?.background&&(this.customMonomerColors[i]||(this.customMonomerColors[i]={}),this.customMonomerColors[i][t]=v(n.meta.colors.default.background))}}})})}),[].concat(...Object.values(c.colourPalette))}get(t,e){const n=_.palette.length,i=_.customMonomerColors[t],o=e??g.kC.PEPTIDE;if(i&&i[o])return i[o];const r=C.hashCode(t)%n;return v(_.palette[r])}}_._pallete=null,_.customMonomerColors={},_.polymerTypes=[];class w extends c{static get Gray(){return void 0===this.gray&&(this.gray=new b),this.gray}static get Color(){return void 0===this.color&&(this.color=new _),this.color}}function A(t){return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}class S{get length(){return this.mList.length}get graphInfo(){}isGap(t){return this.getOriginal(t)===this.gapOriginalMonomer}getCanonical(t){if(this.length<=t)throw new Error("Index out of bounds");const e=this.mList[t];return e!==this.gapOriginalMonomer?e:""}getOriginal(t){if(this.length<=t)throw new Error("Index out of bounds");return this.mList[t]}getCanonicalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0)-n,o=this.gapOriginalMonomer;return new Array(i).fill(null).map((t,e)=>{const i=this.mList[e+n];return i===o?"":i})}getOriginalRegion(t,e){const n=Math.min(Math.max(0,t),this.length),i=Math.max(Math.min(this.length,e),0);return new Array(i-n).fill(null).map((t,e)=>this.mList[e+n])}get gapOriginal(){return this.gapOriginalMonomer}constructor(t,e){this.mList=t,this.gapOriginalMonomer=e}}class T extends S{constructor(t,e,n,i){super(t.flat(),i),this.mListSeparated=t,this.connections=e,this._graphInfo=void 0,this.polymerTypes=t.map((t,e)=>new Array(t.length).fill(n[e])).flat()}get graphInfo(){return this._graphInfo??(this._graphInfo=this.parseConnections()),this._graphInfo}parseConnections(){const t={connections:[],disjointSeqStarts:[],polymerTypes:this.polymerTypes};let e=0;for(let n=0;n<this.mListSeparated.length;++n)t.disjointSeqStarts.push(e),e+=this.mListSeparated[n].length;if((this.connections?.length??0)>0){const e=(this.connections??"").split("|").filter(t=>(t?.length??0)>0),n=/^(PEPTIDE|RNA|BLOB|CHEM)\d{1,2}$/,i=/^\d{1,2}:R\d{1}-\d{1,2}:R\d{1}$/;for(const o of e){const e=o.split(",");if(3!==e.length||!i.test(e[2])||!n.test(e[0])||!n.test(e[1]))continue;const r=parseInt(e[0].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,s=parseInt(e[1].replace(/^(PEPTIDE|RNA|BLOB|CHEM)/,""))-1,a=e[0].replace(/\d{1,2}$/,""),l=e[1].replace(/\d{1,2}$/,"");if(r<0||r>=this.mListSeparated.length||s<0||s>=this.mListSeparated.length)continue;const u=e[2].split("-");if(2!==u.length)continue;const c=u[0].split(":"),h=u[1].split(":");if(2!==c.length||2!==h.length)continue;const d=parseInt(c[0])-1,f=parseInt(h[0])-1;d<0||d>=this.mListSeparated[r].length||f<0||f>=this.mListSeparated[s].length||t.connections.push({seq1Type:a,seq2Type:l,seqIndex1:r,seqIndex2:s,monomerIndex1:d,monomerIndex2:f,rGroup1:parseInt(c[1].substring(1)),rGroup2:parseInt(h[1].substring(1))})}}return t}}const E=t=>{const e=r()(t.toString().matchAll(u.B5)).map(t=>t[2]??t[1]).toArray();return new S(e,u.b9[u.Hi.FASTA])},N=/^((?:[^\[\]()]|\[[^\[\]]*\])+)\(((?:[^\[\]()]|\[[^\[\]]*\])+)\)((?:[^\[\]()]|\[[^\[\]]*\])+)$/,x=/^((?:[^\[\]()]|\[[^\[\]]*\])+)\(((?:[^\[\]()]|\[[^\[\]]*\])+)\)$/,M=t=>{const e=t.indexOf("}$"),n=t.substring(0,e+1),i=t.indexOf("$",e+2),o=t.substring(e+2,i),r=n.split("}|");for(let t=0;t<r.length-1;t++)r[t]=r[t]+"}";const s=r.map(t=>t.replace(/\d{1,2}\{.+\}/,"")),a=r.map((t,e)=>(t.match(/(?<=\{).+(?=})/)?.[0]?.split(".")??[]).flatMap(t=>{if(s[e]===g.kC.RNA){const e=N.exec(t);if(null!=e)return[A(e[1]),A(e[2]),A(e[3])];const n=x.exec(t);if(null!=n)return[A(n[1]),A(n[2])]}return[A(t)]}));return new T(a,o??"",s,u.b9[u.Hi.HELM])},I=/([^\W_]+)/g;function O(t,e){if(t.length<=e)return t;const n=t.match(I),i=t.length>e||(n?.length??0)>1,o=n?.[0]??" ";return i?o.substring(0,e-1)+"…":o}function P(t,e,n="-"){const i=e.map(e=>{const i=function(t,e,n="-"){const i=new Set([...new Set(Object.keys(t)),...e]);i.delete(n);const o=[],r=[];for(const n of i)o.push(n in t?t[n]:0),r.push(e.has(n)?1:0);const l=new s(o),u=new s(r);return function(t,e){if(t.length!=e.length)throw new Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<t.length;i++)n+=t[i]*e[i];return n}(l,u)/(a(l)*a(u))}(t,e.alphabet,n);return new l.XN(e,t,i)});let o;const r=Math.max(...i.map(t=>t.similarity>t.cutoff?t.similarity:-1));return o=r>0?i.find(t=>t.similarity===r).name:u.YI.UN,o}function L(t,e,n=5){let o;if(t.semType==i.SEMTYPE.MACROMOLECULE)o=e.getSeqHandler(t).alphabet;else{const e=function(t,e,n){const i=t.categories;return function(t,e){const n={};let i=!0,o=null;for(const r of t)if(null==o?o=r.length:r.length!==o&&(i=!1),r.length>=e)for(let t=0;t<r.length;++t){const e=r.getCanonical(t);e in n||(n[e]=0),n[e]+=1}return{freq:n,sameLength:i}}(r().enumerate(t.getRawData()).map(([t,e])=>n(i[t])),e)}(t,n,E);o=P(e.freq,u.q7)}return function(t){switch(t){case u.YI.PT:return h.GrokGroups;case u.YI.DNA:case u.YI.RNA:return f.Chromatogram;default:return w.Color}}(o)}},3077(t,e,n){"use strict";n.d(e,{R:()=>s});var i=n(6082),o=n(4025),r=n(439);function s(t,e){const n=t=>a[t]??null,s=t=>{const e=u.columns.addNewString((t+1).toString());return a.push(e),e},a=[],l=t.length,u=i.DataFrame.create(l),c=e.getSeqHandler(t);for(let t=0;t<l;++t){const e=c.getSplitted(t);for(let i=0;i<e.length;++i){const o=e.getOriginal(i);(n(i)||s(i)).set(t,o,!1)}}const h=t.temp[o.j.notationProvider]??null,d=h?.monomerCanonicalizerFuncName;if(d)for(const t of a)t.setTag(r.jz,d);return u}},4326(t,e,n){"use strict";n.d(e,{P4:()=>s,fH:()=>o});var i,o,r,s,a,l,u=n(6082);!function(t){t.tooltipWebLogo=".tooltipWebLogo"}(i||(i={})),function(t){t.Entropy="Entropy",t.full="100%"}(o||(o={})),function(t){t.TOP="top",t.MIDDLE="middle",t.BOTTOM="bottom"}(r||(r={})),function(t){t.LEFT="left",t.CENTER="center",t.RIGHT="right"}(s||(s={})),function(t){t.AUTO="auto",t.ON="on",t.OFF="off"}(a||(a={})),function(t){t.Filtered="Filtered",t.Selected="Selected"}(l||(l={})),new class{constructor(){this.sequenceColumnName=null,this.valueAggrType=u.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=4294967295,this.positionHeight=o.Entropy,this.positionWidth=20,this.verticalAlignment=r.MIDDLE,this.horizontalAlignment=s.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=25,this.maxHeight=300,this.maxMonomerLetters=5,this.showPositionLabels=!0,this.positionMarginState=a.AUTO,this.positionMargin=0,this.filterSource=l.Filtered}}},5540(t,e,n){"use strict";t=n.hmd(t);var i,o=(i="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(t={}){var e,n,o=void 0!==t?t:{};o.ready=new Promise(function(t,i){e=t,n=i});var r,s=Object.assign({},o),a="object"==typeof window,l="function"==typeof importScripts,u=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(a||l)&&(l?u=self.location.href:"undefined"!=typeof document&&document.currentScript&&(u=document.currentScript.src),i&&(u=i),u=0!==u.indexOf("blob:")?u.substr(0,u.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l&&(r=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)})),o.print||console.log.bind(console);var c,h,d=o.printErr||console.warn.bind(console);Object.assign(o,s),s=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit,o.wasmBinary&&(c=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&x("no native wasm support detected");var f,m,p,g=!1;function v(){var t=h.buffer;o.HEAP8=f=new Int8Array(t),o.HEAP16=new Int16Array(t),o.HEAP32=new Int32Array(t),o.HEAPU8=m=new Uint8Array(t),o.HEAPU16=new Uint16Array(t),o.HEAPU32=p=new Uint32Array(t),o.HEAPF32=new Float32Array(t),o.HEAPF64=new Float64Array(t)}var C=[],y=[],b=[];function _(t){C.unshift(t)}function w(t){b.unshift(t)}var A,S,T=0,E=null,N=null;function x(t){o.onAbort&&o.onAbort(t),d(t="Aborted("+t+")"),g=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw n(e),e}function M(t){return t.startsWith("data:application/octet-stream;base64,")}function I(t){try{if(t==A&&c)return new Uint8Array(c);if(r)return r(t);throw"both async and sync fetching of the wasm failed"}catch(t){x(t)}}function O(t,e,n){return function(t){return c||!a&&!l||"function"!=typeof fetch?Promise.resolve().then(function(){return I(t)}):fetch(t,{credentials:"same-origin"}).then(function(e){if(!e.ok)throw"failed to load wasm binary file at '"+t+"'";return e.arrayBuffer()}).catch(function(){return I(t)})}(t).then(function(t){return WebAssembly.instantiate(t,e)}).then(function(t){return t}).then(n,function(t){d("failed to asynchronously prepare wasm: "+t),x(t)})}function P(t){for(;t.length>0;)t.shift()(o)}function L(t){this.excPtr=t,this.ptr=t-24,this.set_type=function(t){p[this.ptr+4>>2]=t},this.get_type=function(){return p[this.ptr+4>>2]},this.set_destructor=function(t){p[this.ptr+8>>2]=t},this.get_destructor=function(){return p[this.ptr+8>>2]},this.set_caught=function(t){t=t?1:0,f[this.ptr+12|0]=t},this.get_caught=function(){return 0!=f[this.ptr+12|0]},this.set_rethrown=function(t){t=t?1:0,f[this.ptr+13|0]=t},this.get_rethrown=function(){return 0!=f[this.ptr+13|0]},this.init=function(t,e){this.set_adjusted_ptr(0),this.set_type(t),this.set_destructor(e)},this.set_adjusted_ptr=function(t){p[this.ptr+16>>2]=t},this.get_adjusted_ptr=function(){return p[this.ptr+16>>2]},this.get_exception_ptr=function(){if(H(this.get_type()))return p[this.excPtr>>2];var t=this.get_adjusted_ptr();return 0!==t?t:this.excPtr}}function R(t){var e=h.buffer;try{return h.grow(t-e.byteLength+65535>>>16),v(),1}catch(t){}}function k(t){return o["_"+t]}M(A="wasmDbscan.wasm")||(S=A,A=o.locateFile?o.locateFile(S,u):u+S);var F="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function V(t,e,n,i,o){var r={string:t=>{var e=0;return null!=t&&0!==t&&(e=function(t){var e=function(t){for(var e=0,n=0;n<t.length;++n){var i=t.charCodeAt(n);i<=127?e++:i<=2047?e+=2:i>=55296&&i<=57343?(e+=4,++n):e+=3}return e}(t)+1,n=q(e);return function(t,e,n){!function(t,e,n,i){if(!(i>0))return 0;for(var o=n+i-1,r=0;r<t.length;++r){var s=t.charCodeAt(r);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&t.charCodeAt(++r)),s<=127){if(n>=o)break;e[n++]=s}else if(s<=2047){if(n+1>=o)break;e[n++]=192|s>>6,e[n++]=128|63&s}else if(s<=65535){if(n+2>=o)break;e[n++]=224|s>>12,e[n++]=128|s>>6&63,e[n++]=128|63&s}else{if(n+3>=o)break;e[n++]=240|s>>18,e[n++]=128|s>>12&63,e[n++]=128|s>>6&63,e[n++]=128|63&s}}e[n]=0}(t,m,e,n)}(t,n,e),n}(t)),e},array:t=>{var e,n,i=q(t.length);return e=t,n=i,f.set(e,n),i}},s=k(t),a=[],l=0;if(i)for(var u=0;u<i.length;u++){var c=r[n[u]];c?(0===l&&(l=B()),a[u]=c(i[u])):a[u]=i[u]}var h=s.apply(null,a);return function(t){return 0!==l&&U(l),function(t){return"string"===e?(n=t)?function(t,e,n){for(var i=e+n,o=e;t[o]&&!(o>=i);)++o;if(o-e>16&&t.buffer&&F)return F.decode(t.subarray(e,o));for(var r="";e<o;){var s=t[e++];if(128&s){var a=63&t[e++];if(192!=(224&s)){var l=63&t[e++];if((s=224==(240&s)?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&t[e++])<65536)r+=String.fromCharCode(s);else{var u=s-65536;r+=String.fromCharCode(55296|u>>10,56320|1023&u)}}else r+=String.fromCharCode((31&s)<<6|a)}else r+=String.fromCharCode(s)}return r}(m,n,i):"":"boolean"===e?Boolean(t):t;var n,i}(t)}(h)}var D,G={__cxa_throw:function(t,e,n){throw new L(t).init(e,n),t},abort:function(){x("")},emscripten_memcpy_big:function(t,e,n){m.copyWithin(t,e,e+n)},emscripten_resize_heap:function(t){var e=m.length,n=2147483648;if((t>>>=0)>n)return!1;let i=(t,e)=>t+(e-t%e)%e;for(var o=1;o<=4;o*=2){var r=e*(1+.2/o);if(r=Math.min(r,t+100663296),R(Math.min(n,i(Math.max(t,r),65536))))return!0}return!1}},B=(function(){var t,e,i,r,s={env:G,wasi_snapshot_preview1:G};function a(t,e){var n,i=t.exports;return o.asm=i,h=o.asm.memory,v(),o.asm.__indirect_function_table,n=o.asm.__wasm_call_ctors,y.unshift(n),function(){if(T--,o.monitorRunDependencies&&o.monitorRunDependencies(T),0==T&&(null!==E&&(clearInterval(E),E=null),N)){var t=N;N=null,t()}}(),i}if(T++,o.monitorRunDependencies&&o.monitorRunDependencies(T),o.instantiateWasm)try{return o.instantiateWasm(s,a)}catch(t){d("Module.instantiateWasm callback failed with error: "+t),n(t)}(t=c,e=A,i=s,r=function(t){a(t.instance)},t||"function"!=typeof WebAssembly.instantiateStreaming||M(e)||"function"!=typeof fetch?O(e,i,r):fetch(e,{credentials:"same-origin"}).then(function(t){return WebAssembly.instantiateStreaming(t,i).then(r,function(t){return d("wasm streaming compile failed: "+t),d("falling back to ArrayBuffer instantiation"),O(e,i,r)})})).catch(n)}(),o._dbscan=function(){return(o._dbscan=o.asm.dbscan).apply(null,arguments)},o._malloc=function(){return(o._malloc=o.asm.malloc).apply(null,arguments)},o._free=function(){return(o._free=o.asm.free).apply(null,arguments)},function(){return(B=o.asm.stackSave).apply(null,arguments)}),U=function(){return(U=o.asm.stackRestore).apply(null,arguments)},q=function(){return(q=o.asm.stackAlloc).apply(null,arguments)},H=function(){return(H=o.asm.__cxa_is_pointer_type).apply(null,arguments)};function $(){function t(){D||(D=!0,o.calledRun=!0,g||(P(y),e(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)w(o.postRun.shift());P(b)}()))}T>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)_(o.preRun.shift());P(C)}(),T>0||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),t()},1)):t()))}if(o.ccall=V,o.cwrap=function(t,e,n,i){var o=!n||n.every(t=>"number"===t||"boolean"===t);return"string"!==e&&o&&!i?k(t):function(){return V(t,e,n,arguments)}},N=function t(){D||$(),D||(N=t)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return $(),t.ready});"object"==typeof exports?t.exports=o:"function"==typeof define&&n.amdO?define([],function(){return o}):"object"==typeof exports&&(exports.exportCppDbscanLib=o)},4329(t,e,n){"use strict";n.d(e,{_:()=>o});let i=null;function o(){return t=this,e=void 0,o=function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!i&&(i=yield navigator.gpu.requestAdapter(),null==i))return null;let t=null;return"info"in i&&(t=i.info),t?r(t.description,r(t.vendor,"No GPU description available")):"No GPU description available"},new((n=void 0)||(n=Promise))(function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())});var t,e,n,o}function r(t,e){return t&&""!=t?t:e}},1199(t,e,n){"use strict";n.d(e,{Z:()=>i});new Uint32Array(65536);var i;!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(i||(i={})),i.HAMMING,i.LEVENSHTEIN,i.NEEDLEMANN_WUNSCH,i.MONOMER_CHEMICAL_DISTANCE},8774(t,e,n){"use strict";n.d(e,{A:()=>i});class i{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,o=i._createBuffer(n);if(e)for(let t=0;t<o.length;t++)o[t]=-1;this._data=o,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,i){if(t<e||t>n)throw new Error(`Argument ${i} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let i=0;i<n;i++)e[i]=t[i]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new i(t._length);n._length=t._length,n._data=i._createBuffer(n._length),n._version=0;const o=t.lengthInInts;for(let i=0;i<o;i++)n._data[i]=t._data[i]&e._data[i];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new i(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new i(t);for(let i=0;i<t;++i)n.setBit(i,e(i));return n._version=0,n}static fromString(t){return i.fromSeq(t.length,e=>"1"==t.charAt(e))}static fromUint32Array(t,e){const n=new i(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new i(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let o=0,r=0;for(;e-r>=4;)n._data[o++]=255&t[r]|(255&t[r+1])<<8|(255&t[r+2])<<16|(255&t[r+3])<<24,r+=4;return e-r==3&&(n._data[o]=(255&t[r+2])<<16),e-r==2&&(n._data[o]|=(255&t[r+1])<<8),e-r==1&&(n._data[o]|=255&t[r]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new i(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,i=this.lengthInInts;for(let t=0;t<i;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,i=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(i)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,i=!0,o=!0){if(n&&o&&this.setAll(!e,!1),o)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(i)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return i.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let i=t;i<e;++i)n.push(this.getBit(i));return n}setRange(t,e,n,i=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const o=Math.min(t,e),r=Math.max(t,e);if(n)for(let t=o;t<=r;t++)this.setTrue(t);else for(let t=o;t<=r;t++)this.setFalse(t);return this.incrementVersion(i),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const i=this._length;this.setLength(this._length+e);for(let n=i-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let i=t;i<t+e;i++)this.setBit(i,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let i=-1;-1!=(i=t.findNext(i,!e));)this.setFast(n++,this.getBit(i));this._length=n,this._version++}return this}getBit(t){return!!(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=i._onBitCount[255&t];let n=this._data[e];const o=31&this._length;for(0!=o&&(n&=~(4294967295<<o));0!=n;n>>>=8)this._selectedCount+=i._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const o=this.lengthInInts;let r=0;for(;r<o-1;r++)for(let e=this._data[r]&t._data[r];0!=e;e>>>=8)n+=i._onBitCount[255&e];let s=this._data[r]&t._data[r];const a=31&this._length;for(0!=a&&(s&=~(4294967295<<a));0!=s;s>>>=8)n+=i._onBitCount[255&s];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const o=this.lengthInInts;for(let r=Math.floor(t/32);r<o;r++){let o=e?this._data[r]:~this._data[r];if(0!=n)o&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==o)continue;for(let e=0;0!=o;e+=8,o>>>=8){const n=i._firstOnBit[255&o];if(n>=0)return(t=n+32*r+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let o=Math.floor(t/32);o>=0;o--){let t=e?this._data[o]:~this._data[o];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=i._lastOnBit[t>>>24];if(n>=0)return n+32*o+e}}return-1}}i._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8]),i._firstOnBit=Int8Array.from([-1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0]),i._lastOnBit=Int8Array.from([-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7])},7233(t){!function(){"use strict";var e=document,n=window,i=e.documentElement,o=e.createElement.bind(e),r=o("div"),s=o("table"),a=o("tbody"),l=o("tr"),u=Array.isArray,c=Array.prototype,h=c.concat,d=c.filter,f=c.indexOf,m=c.map,p=c.push,g=c.slice,v=c.some,C=c.splice,y=/^#(?:[\w-]|\\.|[^\x00-\xa0])*$/,b=/^\.(?:[\w-]|\\.|[^\x00-\xa0])*$/,_=/<.+>/,w=/^\w+$/;function A(t,e){var n,i=!!(n=e)&&11===n.nodeType;return t&&(i||M(e)||I(e))?!i&&b.test(t)?e.getElementsByClassName(t.slice(1).replace(/\\/g,"")):!i&&w.test(t)?e.getElementsByTagName(t):e.querySelectorAll(t):[]}var S=function(){function t(t,i){if(t){if(N(t))return t;var o=t;if(P(t)){var r=i||e;if(!(o=y.test(t)&&M(r)?r.getElementById(t.slice(1).replace(/\\/g,"")):_.test(t)?Q(t):N(r)?r.find(t):P(r)?E(r).find(t):A(t,r)))return}else if(O(t))return this.ready(t);(o.nodeType||o===n)&&(o=[o]),this.length=o.length;for(var s=0,a=this.length;s<a;s++)this[s]=o[s]}}return t.prototype.init=function(e,n){return new t(e,n)},t}(),T=S.prototype,E=T.init;function N(t){return t instanceof S}function x(t){return!!t&&t===t.window}function M(t){return!!t&&9===t.nodeType}function I(t){return!!t&&1===t.nodeType}function O(t){return"function"==typeof t}function P(t){return"string"==typeof t}function L(t){return void 0===t}function R(t){return null===t}function k(t){return!isNaN(parseFloat(t))&&isFinite(t)}function F(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function V(t,e,n){if(n){for(var i=t.length;i--;)if(!1===e.call(t[i],i,t[i]))return t}else if(F(t))for(var o=Object.keys(t),r=(i=0,o.length);i<r;i++){var s=o[i];if(!1===e.call(t[s],s,t[s]))return t}else for(i=0,r=t.length;i<r;i++)if(!1===e.call(t[i],i,t[i]))return t;return t}function D(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="boolean"==typeof t[0]&&t.shift(),i=t.shift(),o=t.length;if(!i)return{};if(!o)return D(n,E,i);for(var r=0;r<o;r++){var s=t[r];for(var a in s)n&&(u(s[a])||F(s[a]))?(i[a]&&i[a].constructor===s[a].constructor||(i[a]=new s[a].constructor),D(n,i[a],s[a])):i[a]=s[a]}return i}E.fn=E.prototype=T,T.length=0,T.splice=C,"function"==typeof Symbol&&(T[Symbol.iterator]=c[Symbol.iterator]),E.isWindow=x,E.isFunction=O,E.isArray=u,E.isNumeric=k,E.isPlainObject=F,E.each=V,T.each=function(t){return V(this,t)},T.empty=function(){return this.each(function(t,e){for(;e.firstChild;)e.removeChild(e.firstChild)})},E.extend=D,T.extend=function(t){return D(T,t)};var G=/\S+/g;function B(t){return P(t)&&t.match(G)||[]}function U(t,e,i){if(I(t)){var o=n.getComputedStyle(t,null);return i?o.getPropertyValue(e)||void 0:o[e]||t.style[e]}}function q(t,e){return parseInt(U(t,e),10)||0}function H(t,e){return q(t,"border".concat(e?"Left":"Top","Width"))+q(t,"padding".concat(e?"Left":"Top"))+q(t,"padding".concat(e?"Right":"Bottom"))+q(t,"border".concat(e?"Right":"Bottom","Width"))}T.toggleClass=function(t,e){var n=B(t),i=!L(e);return this.each(function(t,o){I(o)&&V(n,function(t,n){i?e?o.classList.add(n):o.classList.remove(n):o.classList.toggle(n)})})},T.addClass=function(t){return this.toggleClass(t,!0)},T.removeAttr=function(t){var e=B(t);return this.each(function(t,n){I(n)&&V(e,function(t,e){n.removeAttribute(e)})})},T.attr=function(t,e){if(t){if(P(t)){if(arguments.length<2){if(!this[0]||!I(this[0]))return;var n=this[0].getAttribute(t);return R(n)?void 0:n}return L(e)?this:R(e)?this.removeAttr(t):this.each(function(n,i){I(i)&&i.setAttribute(t,e)})}for(var i in t)this.attr(i,t[i]);return this}},T.removeClass=function(t){return arguments.length?this.toggleClass(t,!1):this.attr("class","")},T.hasClass=function(t){return!!t&&v.call(this,function(e){return I(e)&&e.classList.contains(t)})},T.get=function(t){return L(t)?g.call(this):this[(t=Number(t))<0?t+this.length:t]},T.eq=function(t){return E(this.get(t))},T.first=function(){return this.eq(0)},T.last=function(){return this.eq(-1)},T.text=function(t){return L(t)?this.get().map(function(t){return I(t)||(e=t)&&3===e.nodeType?t.textContent:"";var e}).join(""):this.each(function(e,n){I(n)&&(n.textContent=t)})};var $={};function Y(t){return"none"===U(t,"display")}function j(t,e){var n=t&&(t.matches||t.webkitMatchesSelector||t.msMatchesSelector);return!!n&&!!e&&n.call(t,e)}function W(t){return P(t)?function(e,n){return j(n,t)}:O(t)?t:N(t)?function(e,n){return t.is(n)}:t?function(e,n){return n===t}:function(){return!1}}function z(t,e){return e?t.filter(e):t}T.filter=function(t){var e=W(t);return E(d.call(this,function(t,n){return e.call(t,n,t)}))},T.detach=function(t){return z(this,t).each(function(t,e){e.parentNode&&e.parentNode.removeChild(e)}),this};var K=/^\s*<(\w+)[^>]*>/,Z=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,X={"*":r,tr:a,td:l,th:l,thead:s,tbody:s,tfoot:s};function Q(t){if(!P(t))return[];if(Z.test(t))return[o(RegExp.$1)];var e=K.test(t)&&RegExp.$1,n=X[e]||X["*"];return n.innerHTML=t,E(n.childNodes).detach().get()}function J(t,e,n,i){for(var o=[],r=O(e),s=i&&W(i),a=0,l=t.length;a<l;a++)if(r){var u=e(t[a]);u.length&&p.apply(o,u)}else for(var c=t[a][e];!(null==c||i&&s(-1,c));)o.push(c),c=n?c[e]:null;return o}function tt(t){return t.multiple&&t.options?J(d.call(t.options,function(t){return t.selected&&!t.disabled&&!t.parentNode.disabled}),"value"):t.value||""}function et(t){return t.length>1?d.call(t,function(t,e,n){return f.call(n,t)===e}):t}E.parseHTML=Q,T.has=function(t){var e=P(t)?function(e,n){return A(t,n).length}:function(e,n){return n.contains(t)};return this.filter(e)},T.not=function(t){var e=W(t);return this.filter(function(n,i){return(!P(t)||I(i))&&!e.call(i,n,i)})},T.val=function(t){return arguments.length?this.each(function(e,n){var i=n.multiple&&n.options;if(i||Pt.test(n.type)){var o=u(t)?m.call(t,String):R(t)?[]:[String(t)];i?V(n.options,function(t,e){e.selected=o.indexOf(e.value)>=0},!0):n.checked=o.indexOf(n.value)>=0}else n.value=L(t)||R(t)?"":t}):this[0]&&tt(this[0])},T.is=function(t){var e=W(t);return v.call(this,function(t,n){return e.call(t,n,t)})},E.guid=1,E.unique=et,T.add=function(t,e){return E(et(this.get().concat(E(t,e).get())))},T.children=function(t){return z(E(et(J(this,function(t){return t.children}))),t)},T.parent=function(t){return z(E(et(J(this,"parentNode"))),t)},T.index=function(t){var e=t?E(t)[0]:this[0],n=t?this:E(e).parent().children();return f.call(n,e)},T.closest=function(t){var e=this.filter(t);if(e.length)return e;var n=this.parent();return n.length?n.closest(t):e},T.siblings=function(t){return z(E(et(J(this,function(t){return E(t).parent().children().not(t)}))),t)},T.find=function(t){return E(et(J(this,function(e){return A(t,e)})))};var nt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,it=/^$|^module$|\/(java|ecma)script/i,ot=["type","src","nonce","noModule"];function rt(t,e,n,r,s,a,l,u){return V(t,function(t,a){V(E(a),function(t,a){V(E(e),function(e,l){var u=n?l:a,c=n?t:e;!function(t,e,n,r,s){r?t.insertBefore(e,n?t.firstChild:null):"HTML"===t.nodeName?t.parentNode.replaceChild(e,t):t.parentNode.insertBefore(e,n?t:t.nextSibling),s&&function(t,e){var n=E(t);n.filter("script").add(n.find("script")).each(function(t,n){if(it.test(n.type)&&i.contains(n)){var r=o("script");r.text=n.textContent.replace(nt,""),V(ot,function(t,e){n[e]&&(r[e]=n[e])}),e.head.insertBefore(r,null),e.head.removeChild(r)}})}(e,t.ownerDocument)}(n?a:l,c?u.cloneNode(!0):u,r,s,!c)},u)},l)},a),e}T.after=function(){return rt(arguments,this,!1,!1,!1,!0,!0)},T.append=function(){return rt(arguments,this,!1,!1,!0)},T.html=function(t){if(!arguments.length)return this[0]&&this[0].innerHTML;if(L(t))return this;var e=/<script[\s>]/.test(t);return this.each(function(n,i){I(i)&&(e?E(i).empty().append(t):i.innerHTML=t)})},T.appendTo=function(t){return rt(arguments,this,!0,!1,!0)},T.wrapInner=function(t){return this.each(function(e,n){var i=E(n),o=i.contents();o.length?o.wrapAll(t):i.append(t)})},T.before=function(){return rt(arguments,this,!1,!0)},T.wrapAll=function(t){for(var e=E(t),n=e[0];n.children.length;)n=n.firstElementChild;return this.first().before(e),this.appendTo(n)},T.wrap=function(t){return this.each(function(e,n){var i=E(t)[0];E(n).wrapAll(e?i.cloneNode(!0):i)})},T.insertAfter=function(t){return rt(arguments,this,!0,!1,!1,!1,!1,!0)},T.insertBefore=function(t){return rt(arguments,this,!0,!0)},T.prepend=function(){return rt(arguments,this,!1,!0,!0,!0,!0)},T.prependTo=function(t){return rt(arguments,this,!0,!0,!0,!1,!1,!0)},T.contents=function(){return E(et(J(this,function(t){return"IFRAME"===t.tagName?[t.contentDocument]:"TEMPLATE"===t.tagName?t.content.childNodes:t.childNodes})))},T.next=function(t,e,n){return z(E(et(J(this,"nextElementSibling",e,n))),t)},T.nextAll=function(t){return this.next(t,!0)},T.nextUntil=function(t,e){return this.next(e,!0,t)},T.parents=function(t,e){return z(E(et(J(this,"parentElement",!0,e))),t)},T.parentsUntil=function(t,e){return this.parents(e,t)},T.prev=function(t,e,n){return z(E(et(J(this,"previousElementSibling",e,n))),t)},T.prevAll=function(t){return this.prev(t,!0)},T.prevUntil=function(t,e){return this.prev(e,!0,t)},T.map=function(t){return E(h.apply([],m.call(this,function(e,n){return t.call(e,n,e)})))},T.clone=function(){return this.map(function(t,e){return e.cloneNode(!0)})},T.offsetParent=function(){return this.map(function(t,e){for(var n=e.offsetParent;n&&"static"===U(n,"position");)n=n.offsetParent;return n||i})},T.slice=function(t,e){return E(g.call(this,t,e))};var st=/-([a-z])/g;function at(t){return t.replace(st,function(t,e){return e.toUpperCase()})}T.ready=function(t){var n=function(){return setTimeout(t,0,E)};return"loading"!==e.readyState?n():e.addEventListener("DOMContentLoaded",n),this},T.unwrap=function(){return this.parent().each(function(t,e){if("BODY"!==e.tagName){var n=E(e);n.replaceWith(n.children())}}),this},T.offset=function(){var t=this[0];if(t){var e=t.getBoundingClientRect();return{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}}},T.position=function(){var t=this[0];if(t){var e="fixed"===U(t,"position"),n=e?t.getBoundingClientRect():this.offset();if(!e){for(var i=t.ownerDocument,o=t.offsetParent||i.documentElement;(o===i.body||o===i.documentElement)&&"static"===U(o,"position");)o=o.parentNode;if(o!==t&&I(o)){var r=E(o).offset();n.top-=r.top+q(o,"borderTopWidth"),n.left-=r.left+q(o,"borderLeftWidth")}}return{top:n.top-q(t,"marginTop"),left:n.left-q(t,"marginLeft")}}};var lt={class:"className",contenteditable:"contentEditable",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",tabindex:"tabIndex",colspan:"colSpan",rowspan:"rowSpan",usemap:"useMap"};T.prop=function(t,e){if(t){if(P(t))return t=lt[t]||t,arguments.length<2?this[0]&&this[0][t]:this.each(function(n,i){i[t]=e});for(var n in t)this.prop(n,t[n]);return this}},T.removeProp=function(t){return this.each(function(e,n){delete n[lt[t]||t]})};var ut=/^--/;function ct(t){return ut.test(t)}var ht={},dt=r.style,ft=["webkit","moz","ms"],mt={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 pt(t,e,n){return void 0===n&&(n=ct(t)),n||mt[t]||!k(e)?e:"".concat(e,"px")}function gt(t,e){try{return t(e)}catch(t){return e}}T.css=function(t,e){if(P(t)){var n=ct(t);return t=function(t,e){if(void 0===e&&(e=ct(t)),e)return t;if(!ht[t]){var n=at(t),i="".concat(n[0].toUpperCase()).concat(n.slice(1));V("".concat(n," ").concat(ft.join("".concat(i," "))).concat(i).split(" "),function(e,n){if(n in dt)return ht[t]=n,!1})}return ht[t]}(t,n),arguments.length<2?this[0]&&U(this[0],t,n):t?(e=pt(t,e,n),this.each(function(i,o){I(o)&&(n?o.style.setProperty(t,e):o.style[t]=e)})):this}for(var i in t)this.css(i,t[i]);return this};var vt=/^\s+|\s+$/;function Ct(t,e){var n=t.dataset[e]||t.dataset[at(e)];return vt.test(n)?n:gt(JSON.parse,n)}function yt(t,e){var n=t.documentElement;return Math.max(t.body["scroll".concat(e)],n["scroll".concat(e)],t.body["offset".concat(e)],n["offset".concat(e)],n["client".concat(e)])}T.data=function(t,e){if(!t){if(!this[0])return;var n={};for(var i in this[0].dataset)n[i]=Ct(this[0],i);return n}if(P(t))return arguments.length<2?this[0]&&Ct(this[0],t):L(e)?this:this.each(function(n,i){!function(t,e,n){n=gt(JSON.stringify,n),t.dataset[at(e)]=n}(i,t,e)});for(var i in t)this.data(i,t[i]);return this},V([!0,!1],function(t,e){V(["Width","Height"],function(t,n){var i="".concat(e?"outer":"inner").concat(n);T[i]=function(i){if(this[0])return x(this[0])?e?this[0]["inner".concat(n)]:this[0].document.documentElement["client".concat(n)]:M(this[0])?yt(this[0],n):this[0]["".concat(e?"offset":"client").concat(n)]+(i&&e?q(this[0],"margin".concat(t?"Top":"Left"))+q(this[0],"margin".concat(t?"Bottom":"Right")):0)}})}),V(["Width","Height"],function(t,e){var n=e.toLowerCase();T[n]=function(i){if(!this[0])return L(i)?void 0:this;if(!arguments.length)return x(this[0])?this[0].document.documentElement["client".concat(e)]:M(this[0])?yt(this[0],e):this[0].getBoundingClientRect()[n]-H(this[0],!t);var o=parseInt(i,10);return this.each(function(e,i){if(I(i)){var r=U(i,"boxSizing");i.style[n]=pt(n,o+("border-box"===r?H(i,!t):0))}})}});var bt="___cd";T.toggle=function(t){return this.each(function(n,i){if(I(i)){var r=Y(i);(L(t)?r:t)?(i.style.display=i[bt]||"",Y(i)&&(i.style.display=function(t){if($[t])return $[t];var n=o(t);e.body.insertBefore(n,null);var i=U(n,"display");return e.body.removeChild(n),$[t]="none"!==i?i:"block"}(i.tagName))):r||(i[bt]=U(i,"display"),i.style.display="none")}})},T.hide=function(){return this.toggle(!1)},T.show=function(){return this.toggle(!0)};var _t="___ce",wt={focus:"focusin",blur:"focusout"},At={mouseenter:"mouseover",mouseleave:"mouseout"},St=/^(mouse|pointer|contextmenu|drag|drop|click|dblclick)/i;function Tt(t){return At[t]||wt[t]||t}function Et(t){var e=t.split(".");return[e[0],e.slice(1).sort()]}function Nt(t){return t[_t]=t[_t]||{}}function xt(t,e){return!e||!v.call(e,function(e){return t.indexOf(e)<0})}function Mt(t,e,n,i,o){var r=Nt(t);if(e)r[e]&&(r[e]=r[e].filter(function(r){var s=r[0],a=r[1],l=r[2];if(o&&l.guid!==o.guid||!xt(s,n)||i&&i!==a)return!0;t.removeEventListener(e,l)}));else for(e in r)Mt(t,e,n,i,o)}T.trigger=function(t,n){if(P(t)){var i=Et(t),o=i[0],r=i[1],s=Tt(o);if(!s)return this;var a=St.test(s)?"MouseEvents":"HTMLEvents";(t=e.createEvent(a)).initEvent(s,!0,!0),t.namespace=r.join("."),t.___ot=o}t.___td=n;var l=t.___ot in wt;return this.each(function(e,n){l&&O(n[t.___ot])&&(n["___i".concat(t.type)]=!0,n[t.___ot](),n["___i".concat(t.type)]=!1),n.dispatchEvent(t)})},T.off=function(t,e,n){var i=this;if(L(t))this.each(function(t,e){(I(e)||M(e)||x(e))&&Mt(e)});else if(P(t))O(e)&&(n=e,e=""),V(B(t),function(t,o){var r=Et(o),s=r[0],a=r[1],l=Tt(s);i.each(function(t,i){(I(i)||M(i)||x(i))&&Mt(i,l,a,e,n)})});else for(var o in t)this.off(o,t[o]);return this},T.remove=function(t){return z(this,t).detach().off(),this},T.replaceWith=function(t){return this.before(t).remove()},T.replaceAll=function(t){return E(t).replaceWith(this),this},T.on=function(t,e,n,i,o){var r=this;if(!P(t)){for(var s in t)this.on(s,e,n,t[s],o);return this}return P(e)||(L(e)||R(e)?e="":L(n)?(n=e,e=""):(i=n,n=e,e="")),O(i)||(i=n,n=void 0),i?(V(B(t),function(t,s){var a=Et(s),l=a[0],u=a[1],c=Tt(l),h=l in At,d=l in wt;c&&r.each(function(t,r){if(I(r)||M(r)||x(r)){var s=function(t){if(t.target["___i".concat(t.type)])return t.stopImmediatePropagation();if((!t.namespace||xt(u,t.namespace.split(".")))&&(e||!(d&&(t.target!==r||t.___ot===c)||h&&t.relatedTarget&&r.contains(t.relatedTarget)))){var a=r;if(e){for(var l=t.target;!j(l,e);){if(l===r)return;if(!(l=l.parentNode))return}a=l}Object.defineProperty(t,"currentTarget",{configurable:!0,get:function(){return a}}),Object.defineProperty(t,"delegateTarget",{configurable:!0,get:function(){return r}}),Object.defineProperty(t,"data",{configurable:!0,get:function(){return n}});var f=i.call(a,t,t.___td);o&&Mt(r,c,u,e,s),!1===f&&(t.preventDefault(),t.stopPropagation())}};s.guid=i.guid=i.guid||E.guid++,function(t,e,n,i,o){var r=Nt(t);r[e]=r[e]||[],r[e].push([n,i,o]),t.addEventListener(e,o)}(r,c,u,e,s)}})}),this):this},T.one=function(t,e,n,i){return this.on(t,e,n,i,!0)};var It=/\r?\n/g,Ot=/file|reset|submit|button|image/i,Pt=/radio|checkbox/i;T.serialize=function(){var t="";return this.each(function(e,n){V(n.elements||[n],function(e,n){if(!(n.disabled||!n.name||"FIELDSET"===n.tagName||Ot.test(n.type)||Pt.test(n.type)&&!n.checked)){var i=tt(n);L(i)||V(u(i)?i:[i],function(e,i){t+=function(t,e){return"&".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(e.replace(It,"\r\n")))}(n.name,i)})}})}),t.slice(1)},t.exports=E}()},6677(t,e,n){"use strict";var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.id,".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}","",{version:3,sources:["webpack://./node_modules/@datagrok-libraries/utils/src/u2.css"],names:[],mappings:"AAAA;;AAEA;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,kBAAkB;AACtB;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,kCAAkC;AACtC;;AAEA;IACI,SAAS;AACb;;AAEA;IACI,WAAW;IACX,YAAY;AAChB;;AAEA;IACI,SAAS;IACT,gBAAgB;AACpB;;AAEA;IACI,eAAe;IACf,iBAAiB;AACrB;;AAEA;IACI,gBAAgB;IAChB,mBAAmB;AACvB",sourcesContent:[".ui-app-header {\n\n}\n\n.ui-app-header-icon {\n width: 150px;\n height: 150px;\n margin-right: 20px;\n}\n\n.u2-panel {\n gap: 10px;\n}\n\n.u2-app-header-bottom-line {\n border-bottom: solid 1px lightgrey;\n}\n\n.u2-app-header-with-name {\n gap: 60px;\n}\n\n.u2-app-header-with-name .ui-app-header-icon{\n width: 90px;\n height: 90px;\n}\n\n.u2-app-header-app-name-and-slogan-div {\n gap: 10px;\n margin-top: 10px;\n}\n\n.u2-app-header-app-name-div {\n font-size: 20px;\n font-weight: bold;\n}\n\n.u2-app-header-description {\n margin-top: 10px;\n margin-bottom: 10px;\n}"],sourceRoot:""}]);const a=s;n.d(e,["A",0,a])},365(t,e,n){"use strict";var i=n(1354),o=n.n(i),r=n(6314),s=n.n(r)()(o());s.push([t.id,".pep-textarea-box {\n position: relative;\n}\n\n.pep-textarea-box:hover .pep-snippet-editor-icon {\n visibility: visible;\n}\n\n.pep-snippet-editor-icon {\n position: absolute;\n top: 5px;\n visibility: hidden;\n margin: 5px;\n z-index: 1;\n}\n\n.pep-reset-icon {\n right: 10px;\n}\n\n.pep-snippet-editor-icon i {\n font-size: 13px;\n}\n\n.pep-snippet-editor-icon:hover {\n background-color: var(--steel-1);\n border-radius: 2px;\n}\n\n.pep-snippet-inline-icon i {\n font-size: 13px;\n}\n\n.pep-textinput {\n height: 50px;\n overflow: hidden;\n}\n\n#pep-hist-host #center {\n height: 131px;\n}\n\n#pep-hist-host > #root {\n height: unset;\n width: 100%;\n}\n\n#pep-viewer-title {\n height: 23px;\n font-size: 1.2rem;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n color: #4D5261;\n text-align: center;\n width: 100%;\n align-self: end;\n}\n\n.pep-help-icon {\n position: absolute;\n left: 5px;\n top: 1px;\n}\n\n.panel-base:has(.peptides-viewer-show-title:only-child) > .panel-titlebar > .panel-titlebar-text {\n visibility: visible;\n display: block;\n text-align: center;\n margin-left: 36px;\n padding: 0;\n width: 100%;\n font-size: 14px !important;\n color: #4d5261 !important;\n}","",{version:3,sources:["webpack://./src/styles.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,kBAAkB;EAClB,QAAQ;EACR,kBAAkB;EAClB,WAAW;EACX,UAAU;AACZ;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,gCAAgC;EAChC,kBAAkB;AACpB;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,YAAY;EACZ,gBAAgB;AAClB;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,aAAa;EACb,WAAW;AACb;;AAEA;EACE,YAAY;EACZ,iBAAiB;EACjB,iDAAiD;EACjD,cAAc;EACd,kBAAkB;EAClB,WAAW;EACX,eAAe;AACjB;;AAEA;EACE,kBAAkB;EAClB,SAAS;EACT,QAAQ;AACV;;AAEA;IACI,mBAAmB;IACnB,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,yBAAyB;AAC7B",sourcesContent:[".pep-textarea-box {\n position: relative;\n}\n\n.pep-textarea-box:hover .pep-snippet-editor-icon {\n visibility: visible;\n}\n\n.pep-snippet-editor-icon {\n position: absolute;\n top: 5px;\n visibility: hidden;\n margin: 5px;\n z-index: 1;\n}\n\n.pep-reset-icon {\n right: 10px;\n}\n\n.pep-snippet-editor-icon i {\n font-size: 13px;\n}\n\n.pep-snippet-editor-icon:hover {\n background-color: var(--steel-1);\n border-radius: 2px;\n}\n\n.pep-snippet-inline-icon i {\n font-size: 13px;\n}\n\n.pep-textinput {\n height: 50px;\n overflow: hidden;\n}\n\n#pep-hist-host #center {\n height: 131px;\n}\n\n#pep-hist-host > #root {\n height: unset;\n width: 100%;\n}\n\n#pep-viewer-title {\n height: 23px;\n font-size: 1.2rem;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n color: #4D5261;\n text-align: center;\n width: 100%;\n align-self: end;\n}\n\n.pep-help-icon {\n position: absolute;\n left: 5px;\n top: 1px;\n}\n\n.panel-base:has(.peptides-viewer-show-title:only-child) > .panel-titlebar > .panel-titlebar-text {\n visibility: visible;\n display: block;\n text-align: center;\n margin-left: 36px;\n padding: 0;\n width: 100%;\n font-size: 14px !important;\n color: #4d5261 !important;\n}"],sourceRoot:""}]);const a=s;n.d(e,["A",0,a])},6314(t){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n}).join("")},e.i=function(t,n,i,o,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var u=0;u<t.length;u++){var c=[].concat(t[u]);i&&s[c[0]]||(void 0!==r&&(void 0===c[5]||(c[1]="@layer".concat(c[5].length>0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=r),n&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=n):c[2]=n),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),e.push(c))}},e}},1354(t){"use strict";t.exports=function(t){var e=t[1],n=t[3];if(!n)return e;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),r="/*# ".concat(o," */");return[e].concat([r]).join("\n")}return[e].join("\n")}},6572(t){var e;t.exports=(e=function(t,e){var n=Array.prototype.concat,i=Array.prototype.slice,o=Object.prototype.toString;function r(e,n){var i=e>n?e:n;return t.pow(10,17-~~(t.log(i>0?i:-i)*t.LOG10E))}var s=Array.isArray||function(t){return"[object Array]"===o.call(t)};function a(t){return"[object Function]"===o.call(t)}function l(t){return"number"==typeof t&&t-t===0}function u(){return new u._init(arguments)}function c(){return 0}function h(){return 1}function d(t,e){return t===e?1:0}u.fn=u.prototype,u._init=function(t){if(s(t[0]))if(s(t[0][0])){a(t[1])&&(t[0]=u.map(t[0],t[1]));for(var e=0;e<t[0].length;e++)this[e]=t[0][e];this.length=t[0].length}else this[0]=a(t[1])?u.map(t[0],t[1]):t[0],this.length=1;else if(l(t[0]))this[0]=u.seq.apply(null,t),this.length=1;else{if(t[0]instanceof u)return u(t[0].toArray());this[0]=[],this.length=1}return this},u._init.prototype=u.prototype,u._init.constructor=u,u.utils={calcRdx:r,isArray:s,isFunction:a,isNumber:l,toVector:function(t){return n.apply([],t)}},u._random_fn=t.random,u.setRandom=function(t){if("function"!=typeof t)throw new TypeError("fn is not a function");u._random_fn=t},u.extend=function(t){var e,n;if(1===arguments.length){for(n in t)u[n]=t[n];return this}for(e=1;e<arguments.length;e++)for(n in arguments[e])t[n]=arguments[e][n];return t},u.rows=function(t){return t.length||1},u.cols=function(t){return t[0].length||1},u.dimensions=function(t){return{rows:u.rows(t),cols:u.cols(t)}},u.row=function(t,e){return s(e)?e.map(function(e){return u.row(t,e)}):t[e]},u.rowa=function(t,e){return u.row(t,e)},u.col=function(t,e){if(s(e)){var n=u.arange(t.length).map(function(){return new Array(e.length)});return e.forEach(function(e,i){u.arange(t.length).forEach(function(o){n[o][i]=t[o][e]})}),n}for(var i=new Array(t.length),o=0;o<t.length;o++)i[o]=[t[o][e]];return i},u.cola=function(t,e){return u.col(t,e).map(function(t){return t[0]})},u.diag=function(t){for(var e=u.rows(t),n=new Array(e),i=0;i<e;i++)n[i]=[t[i][i]];return n},u.antidiag=function(t){for(var e=u.rows(t)-1,n=new Array(e),i=0;e>=0;e--,i++)n[i]=[t[i][e]];return n},u.transpose=function(t){var e,n,i,o,r,a=[];for(s(t[0])||(t=[t]),n=t.length,i=t[0].length,r=0;r<i;r++){for(e=new Array(n),o=0;o<n;o++)e[o]=t[o][r];a.push(e)}return 1===a.length?a[0]:a},u.map=function(t,e,n){var i,o,r,a,l;for(s(t[0])||(t=[t]),o=t.length,r=t[0].length,a=n?t:new Array(o),i=0;i<o;i++)for(a[i]||(a[i]=new Array(r)),l=0;l<r;l++)a[i][l]=e(t[i][l],i,l);return 1===a.length?a[0]:a},u.cumreduce=function(t,e,n){var i,o,r,a,l;for(s(t[0])||(t=[t]),o=t.length,r=t[0].length,a=n?t:new Array(o),i=0;i<o;i++)for(a[i]||(a[i]=new Array(r)),r>0&&(a[i][0]=t[i][0]),l=1;l<r;l++)a[i][l]=e(a[i][l-1],t[i][l]);return 1===a.length?a[0]:a},u.alter=function(t,e){return u.map(t,e,!0)},u.create=function(t,e,n){var i,o,r=new Array(t);for(a(e)&&(n=e,e=t),i=0;i<t;i++)for(r[i]=new Array(e),o=0;o<e;o++)r[i][o]=n(i,o);return r},u.zeros=function(t,e){return l(e)||(e=t),u.create(t,e,c)},u.ones=function(t,e){return l(e)||(e=t),u.create(t,e,h)},u.rand=function(t,e){return l(e)||(e=t),u.create(t,e,u._random_fn)},u.identity=function(t,e){return l(e)||(e=t),u.create(t,e,d)},u.symmetric=function(t){var e,n,i=t.length;if(t.length!==t[0].length)return!1;for(e=0;e<i;e++)for(n=0;n<i;n++)if(t[n][e]!==t[e][n])return!1;return!0},u.clear=function(t){return u.alter(t,c)},u.seq=function(t,e,n,i){a(i)||(i=!1);var o,s=[],l=r(t,e),u=(e*l-t*l)/((n-1)*l),c=t;for(o=0;c<=e&&o<n;c=(t*l+u*l*++o)/l)s.push(i?i(c,o):c);return s},u.arange=function(t,n,i){var o,r=[];if(i=i||1,n===e&&(n=t,t=0),t===n||0===i)return[];if(t<n&&i<0)return[];if(t>n&&i>0)return[];if(i>0)for(o=t;o<n;o+=i)r.push(o);else for(o=t;o>n;o+=i)r.push(o);return r},u.slice=function(){function t(t,n,i,o){var r,s=[],a=t.length;if(n===e&&i===e&&o===e)return u.copy(t);if(o=o||1,(n=(n=n||0)>=0?n:a+n)===(i=(i=i||t.length)>=0?i:a+i)||0===o)return[];if(n<i&&o<0)return[];if(n>i&&o>0)return[];if(o>0)for(r=n;r<i;r+=o)s.push(t[r]);else for(r=n;r>i;r+=o)s.push(t[r]);return s}return function(e,n){var i,o;return l((n=n||{}).row)?l(n.col)?e[n.row][n.col]:t(u.rowa(e,n.row),(i=n.col||{}).start,i.end,i.step):l(n.col)?t(u.cola(e,n.col),(o=n.row||{}).start,o.end,o.step):(o=n.row||{},i=n.col||{},t(e,o.start,o.end,o.step).map(function(e){return t(e,i.start,i.end,i.step)}))}}(),u.sliceAssign=function(n,i,o){var r,s;if(l(i.row)){if(l(i.col))return n[i.row][i.col]=o;i.col=i.col||{},i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,r=u.arange(i.col.start,t.min(n.length,i.col.end),i.col.step);var a=i.row;return r.forEach(function(t,e){n[a][t]=o[e]}),n}if(l(i.col)){i.row=i.row||{},i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,s=u.arange(i.row.start,t.min(n[0].length,i.row.end),i.row.step);var c=i.col;return s.forEach(function(t,e){n[t][c]=o[e]}),n}return o[0].length===e&&(o=[o]),i.row.start=i.row.start||0,i.row.end=i.row.end||n.length,i.row.step=i.row.step||1,i.col.start=i.col.start||0,i.col.end=i.col.end||n[0].length,i.col.step=i.col.step||1,s=u.arange(i.row.start,t.min(n.length,i.row.end),i.row.step),r=u.arange(i.col.start,t.min(n[0].length,i.col.end),i.col.step),s.forEach(function(t,e){r.forEach(function(i,r){n[t][i]=o[e][r]})}),n},u.diagonal=function(t){var e=u.zeros(t.length,t.length);return t.forEach(function(t,n){e[n][n]=t}),e},u.copy=function(t){return t.map(function(t){return l(t)?t:t.map(function(t){return t})})};var f=u.prototype;return f.length=0,f.push=Array.prototype.push,f.sort=Array.prototype.sort,f.splice=Array.prototype.splice,f.slice=Array.prototype.slice,f.toArray=function(){return this.length>1?i.call(this):i.call(this)[0]},f.map=function(t,e){return u(u.map(this,t,e))},f.cumreduce=function(t,e){return u(u.cumreduce(this,t,e))},f.alter=function(t){return u.alter(this,t),this},function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e){var n,i=this;return e?(setTimeout(function(){e.call(i,f[t].call(i))}),this):(n=u[t](this),s(n)?u(n):n)}})(t[e])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(e,n){var i=this;return n?(setTimeout(function(){n.call(i,f[t].call(i,e))}),this):u(u[t](this,e))}})(t[e])}("row col".split(" ")),function(t){for(var e=0;e<t.length;e++)(function(t){f[t]=function(){return u(u[t].apply(null,arguments))}})(t[e])}("create zeros ones rand identity".split(" ")),u}(Math),function(t,e){var n=t.utils.isFunction;function i(t,e){return t-e}function o(t,n,i){return e.max(n,e.min(t,i))}t.sum=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.sumsqrd=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n]*t[n];return e},t.sumsqerr=function(e){for(var n,i=t.mean(e),o=0,r=e.length;--r>=0;)o+=(n=e[r]-i)*n;return o},t.sumrow=function(t){for(var e=0,n=t.length;--n>=0;)e+=t[n];return e},t.product=function(t){for(var e=1,n=t.length;--n>=0;)e*=t[n];return e},t.min=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]<e&&(e=t[n]);return e},t.max=function(t){for(var e=t[0],n=0;++n<t.length;)t[n]>e&&(e=t[n]);return e},t.unique=function(t){for(var e={},n=[],i=0;i<t.length;i++)e[t[i]]||(e[t[i]]=!0,n.push(t[i]));return n},t.mean=function(e){return t.sum(e)/e.length},t.meansqerr=function(e){return t.sumsqerr(e)/e.length},t.geomean=function(n){var i=n.map(e.log),o=t.mean(i);return e.exp(o)},t.median=function(t){var e=t.length,n=t.slice().sort(i);return 1&e?n[e/2|0]:(n[e/2-1]+n[e/2])/2},t.cumsum=function(e){return t.cumreduce(e,function(t,e){return t+e})},t.cumprod=function(e){return t.cumreduce(e,function(t,e){return t*e})},t.diff=function(t){var e,n=[],i=t.length;for(e=1;e<i;e++)n.push(t[e]-t[e-1]);return n},t.rank=function(t){var e,n=[],o={};for(e=0;e<t.length;e++)o[l=t[e]]?o[l]++:(o[l]=1,n.push(l));var r=n.sort(i),s={},a=1;for(e=0;e<r.length;e++){var l,u=o[l=r[e]],c=(a+(a+u-1))/2;s[l]=c,a+=u}return t.map(function(t){return s[t]})},t.mode=function(t){var e,n=t.length,o=t.slice().sort(i),r=1,s=0,a=0,l=[];for(e=0;e<n;e++)o[e]===o[e+1]?r++:(r>s?(l=[o[e]],s=r,a=0):r===s&&(l.push(o[e]),a++),r=1);return 0===a?l[0]:l},t.range=function(e){return t.max(e)-t.min(e)},t.variance=function(e,n){return t.sumsqerr(e)/(e.length-(n?1:0))},t.pooledvariance=function(e){return e.reduce(function(e,n){return e+t.sumsqerr(n)},0)/(e.reduce(function(t,e){return t+e.length},0)-e.length)},t.deviation=function(e){for(var n=t.mean(e),i=e.length,o=new Array(i),r=0;r<i;r++)o[r]=e[r]-n;return o},t.stdev=function(n,i){return e.sqrt(t.variance(n,i))},t.pooledstdev=function(n){return e.sqrt(t.pooledvariance(n))},t.meandev=function(n){for(var i=t.mean(n),o=[],r=n.length-1;r>=0;r--)o.push(e.abs(n[r]-i));return t.mean(o)},t.meddev=function(n){for(var i=t.median(n),o=[],r=n.length-1;r>=0;r--)o.push(e.abs(n[r]-i));return t.median(o)},t.coeffvar=function(e){return t.stdev(e)/t.mean(e)},t.quartiles=function(t){var n=t.length,o=t.slice().sort(i);return[o[e.round(n/4)-1],o[e.round(n/2)-1],o[e.round(3*n/4)-1]]},t.quantiles=function(t,n,r,s){var a,l,u,c,h,d=t.slice().sort(i),f=[n.length],m=t.length;for(void 0===r&&(r=3/8),void 0===s&&(s=3/8),a=0;a<n.length;a++)u=m*(l=n[a])+(r+l*(1-r-s)),c=e.floor(o(u,1,m-1)),h=o(u-c,0,1),f[a]=(1-h)*d[c-1]+h*d[c];return f},t.percentile=function(t,e,n){var o=t.slice().sort(i),r=e*(o.length+(n?1:-1))+(n?0:1),s=parseInt(r),a=r-s;return s+1<o.length?o[s-1]+a*(o[s]-o[s-1]):o[s-1]},t.percentileOfScore=function(t,e,n){var i,o,r=0,s=t.length,a=!1;for("strict"===n&&(a=!0),o=0;o<s;o++)i=t[o],(a&&i<e||!a&&i<=e)&&r++;return r/s},t.histogram=function(n,i){i=i||4;var o,r=t.min(n),s=(t.max(n)-r)/i,a=n.length,l=[];for(o=0;o<i;o++)l[o]=0;for(o=0;o<a;o++)l[e.min(e.floor((n[o]-r)/s),i-1)]+=1;return l},t.covariance=function(e,n){var i,o=t.mean(e),r=t.mean(n),s=e.length,a=new Array(s);for(i=0;i<s;i++)a[i]=(e[i]-o)*(n[i]-r);return t.sum(a)/(s-1)},t.corrcoeff=function(e,n){return t.covariance(e,n)/t.stdev(e,1)/t.stdev(n,1)},t.spearmancoeff=function(e,n){return e=t.rank(e),n=t.rank(n),t.corrcoeff(e,n)},t.stanMoment=function(n,i){for(var o=t.mean(n),r=t.stdev(n),s=n.length,a=0,l=0;l<s;l++)a+=e.pow((n[l]-o)/r,i);return a/n.length},t.skewness=function(e){return t.stanMoment(e,3)},t.kurtosis=function(e){return t.stanMoment(e,4)-3};var r=t.prototype;!function(e){for(var i=0;i<e.length;i++)(function(e){r[e]=function(i,o){var s=[],a=0,l=this;if(n(i)&&(o=i,i=!1),o)return setTimeout(function(){o.call(l,r[e].call(l,i))}),this;if(this.length>1){for(l=!0===i?this:this.transpose();a<l.length;a++)s[a]=t[e](l[a]);return s}return t[e](this[0],i)}})(e[i])}("cumsum cumprod".split(" ")),function(e){for(var i=0;i<e.length;i++)(function(e){r[e]=function(i,o){var s=[],a=0,l=this;if(n(i)&&(o=i,i=!1),o)return setTimeout(function(){o.call(l,r[e].call(l,i))}),this;if(this.length>1){for("sumrow"!==e&&(l=!0===i?this:this.transpose());a<l.length;a++)s[a]=t[e](l[a]);return!0===i?t[e](t.utils.toVector(s)):s}return t[e](this[0],i)}})(e[i])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(e){for(var i=0;i<e.length;i++)(function(e){r[e]=function(){var i,o=[],s=0,a=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){i=l[l.length-1];var u=l.slice(0,l.length-1);return setTimeout(function(){i.call(a,r[e].apply(a,u))}),this}i=void 0;var c=function(n){return t[e].apply(a,[n].concat(l))};if(this.length>1){for(a=a.transpose();s<a.length;s++)o[s]=c(a[s]);return o}return c(this[0])}})(e[i])}("quantiles percentileOfScore".split(" "))}(e,Math),function(t,e){t.gammaln=function(t){var n,i,o,r=0,s=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(o=(i=n=t)+5.5,o-=(n+.5)*e.log(o);r<6;r++)a+=s[r]/++i;return e.log(2.5066282746310007*a/n)-o},t.loggam=function(t){var n,i,o,r,s,a,l,u=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=t,l=0,1==t||2==t)return 0;for(t<=7&&(n=t+(l=e.floor(7-t))),i=1/(n*n),o=2*e.PI,s=u[9],a=8;a>=0;a--)s*=i,s+=u[a];if(r=s/n+.5*e.log(o)+(n-.5)*e.log(n)-n,t<=7)for(a=1;a<=l;a++)r-=e.log(n-1),n-=1;return r},t.gammafn=function(t){var n,i,o,r,s=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],l=!1,u=0,c=0,h=0,d=t;if(t>171.6243769536076)return 1/0;if(d<=0){if(!(r=d%1+36e-17))return 1/0;l=(1&d?-1:1)*e.PI/e.sin(e.PI*r),d=1-d}for(o=d,i=d<1?d++:(d-=u=(0|d)-1)-1,n=0;n<8;++n)h=(h+s[n])*i,c=c*i+a[n];if(r=h/c+1,o<d)r/=o;else if(o>d)for(n=0;n<u;++n)r*=d,d++;return l&&(r=l/r),r},t.gammap=function(e,n){return t.lowRegGamma(e,n)*t.gammafn(e)},t.lowRegGamma=function(n,i){var o,r=t.gammaln(n),s=n,a=1/n,l=a,u=i+1-n,c=1/1e-30,h=1/u,d=h,f=1,m=-~(8.5*e.log(n>=1?n:1/n)+.4*n+17);if(i<0||n<=0)return NaN;if(i<n+1){for(;f<=m;f++)a+=l*=i/++s;return a*e.exp(-i+n*e.log(i)-r)}for(;f<=m;f++)d*=(h=1/(h=(o=-f*(f-n))*h+(u+=2)))*(c=u+o/c);return 1-d*e.exp(-i+n*e.log(i)-r)},t.factorialln=function(e){return e<0?NaN:t.gammaln(e+1)},t.factorial=function(e){return e<0?NaN:t.gammafn(e+1)},t.combination=function(n,i){return n>170||i>170?e.exp(t.combinationln(n,i)):t.factorial(n)/t.factorial(i)/t.factorial(n-i)},t.combinationln=function(e,n){return t.factorialln(e)-t.factorialln(n)-t.factorialln(e-n)},t.permutation=function(e,n){return t.factorial(e)/t.factorial(e-n)},t.betafn=function(n,i){if(!(n<=0||i<=0))return n+i>170?e.exp(t.betaln(n,i)):t.gammafn(n)*t.gammafn(i)/t.gammafn(n+i)},t.betaln=function(e,n){return t.gammaln(e)+t.gammaln(n)-t.gammaln(e+n)},t.betacf=function(t,n,i){var o,r,s,a,l=1e-30,u=1,c=n+i,h=n+1,d=n-1,f=1,m=1-c*t/h;for(e.abs(m)<l&&(m=l),a=m=1/m;u<=100&&(m=1+(r=u*(i-u)*t/((d+(o=2*u))*(n+o)))*m,e.abs(m)<l&&(m=l),f=1+r/f,e.abs(f)<l&&(f=l),a*=(m=1/m)*f,m=1+(r=-(n+u)*(c+u)*t/((n+o)*(h+o)))*m,e.abs(m)<l&&(m=l),f=1+r/f,e.abs(f)<l&&(f=l),a*=s=(m=1/m)*f,!(e.abs(s-1)<3e-7));u++);return a},t.gammapinv=function(n,i){var o,r,s,a,l,u,c=0,h=i-1,d=t.gammaln(i);if(n>=1)return e.max(100,i+100*e.sqrt(i));if(n<=0)return 0;for(i>1?(l=e.log(h),u=e.exp(h*(l-1)-d),a=n<.5?n:1-n,o=(2.30753+.27061*(r=e.sqrt(-2*e.log(a))))/(1+r*(.99229+.04481*r))-r,n<.5&&(o=-o),o=e.max(.001,i*e.pow(1-1/(9*i)-o/(3*e.sqrt(i)),3))):o=n<(r=1-i*(.253+.12*i))?e.pow(n/r,1/i):1-e.log(1-(n-r)/(1-r));c<12;c++){if(o<=0)return 0;if((o-=r=(s=(t.lowRegGamma(i,o)-n)/(r=i>1?u*e.exp(-(o-h)+h*(e.log(o)-l)):e.exp(-o+h*e.log(o)-d)))/(1-.5*e.min(1,s*((i-1)/o-1))))<=0&&(o=.5*(o+r)),e.abs(r)<1e-8*o)break}return o},t.erf=function(t){var n,i,o,r,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=s.length-1,l=!1,u=0,c=0;for(t<0&&(t=-t,l=!0),i=4*(n=2/(2+t))-2;a>0;a--)o=u,u=i*u-c+s[a],c=o;return r=n*e.exp(-t*t+.5*(s[0]+i*u)-c),l?r-1:1-r},t.erfc=function(e){return 1-t.erf(e)},t.erfcinv=function(n){var i,o,r,s,a=0;if(n>=2)return-100;if(n<=0)return 100;for(s=n<1?n:2-n,i=-.70711*((2.30753+.27061*(r=e.sqrt(-2*e.log(s/2))))/(1+r*(.99229+.04481*r))-r);a<2;a++)i+=(o=t.erfc(i)-s)/(1.1283791670955126*e.exp(-i*i)-i*o);return n<1?i:-i},t.ibetainv=function(n,i,o){var r,s,a,l,u,c,h,d,f,m,p=i-1,g=o-1,v=0;if(n<=0)return 0;if(n>=1)return 1;for(i>=1&&o>=1?(a=n<.5?n:1-n,c=(2.30753+.27061*(l=e.sqrt(-2*e.log(a))))/(1+l*(.99229+.04481*l))-l,n<.5&&(c=-c),h=(c*c-3)/6,d=2/(1/(2*i-1)+1/(2*o-1)),f=c*e.sqrt(h+d)/d-(1/(2*o-1)-1/(2*i-1))*(h+5/6-2/(3*d)),c=i/(i+o*e.exp(2*f))):(r=e.log(i/(i+o)),s=e.log(o/(i+o)),c=n<(l=e.exp(i*r)/i)/(f=l+(u=e.exp(o*s)/o))?e.pow(i*f*n,1/i):1-e.pow(o*f*(1-n),1/o)),m=-t.gammaln(i)-t.gammaln(o)+t.gammaln(i+o);v<10;v++){if(0===c||1===c)return c;if((c-=l=(u=(t.ibeta(c,i,o)-n)/(l=e.exp(p*e.log(c)+g*e.log(1-c)+m)))/(1-.5*e.min(1,u*(p/c-g/(1-c)))))<=0&&(c=.5*(c+l)),c>=1&&(c=.5*(c+l+1)),e.abs(l)<1e-8*c&&v>0)break}return c},t.ibeta=function(n,i,o){var r=0===n||1===n?0:e.exp(t.gammaln(i+o)-t.gammaln(i)-t.gammaln(o)+i*e.log(n)+o*e.log(1-n));return!(n<0||n>1)&&(n<(i+1)/(i+o+2)?r*t.betacf(n,i,o)/i:1-r*t.betacf(1-n,o,i)/o)},t.randn=function(n,i){var o,r,s,a,l;if(i||(i=n),n)return t.create(n,i,function(){return t.randn()});do{o=t._random_fn(),r=1.7156*(t._random_fn()-.5),l=(s=o-.449871)*s+(a=e.abs(r)+.386595)*(.196*a-.25472*s)}while(l>.27597&&(l>.27846||r*r>-4*e.log(o)*o*o));return r/o},t.randg=function(n,i,o){var r,s,a,l,u,c,h=n;if(o||(o=i),n||(n=1),i)return(c=t.zeros(i,o)).alter(function(){return t.randg(n)}),c;n<1&&(n+=1),r=n-1/3,s=1/e.sqrt(9*r);do{do{l=1+s*(u=t.randn())}while(l<=0);l*=l*l,a=t._random_fn()}while(a>1-.331*e.pow(u,4)&&e.log(a)>.5*u*u+r*(1-l+e.log(l)));if(n==h)return r*l;do{a=t._random_fn()}while(0===a);return e.pow(a,1/h)*r*l},function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t.map(this,function(n){return t[e](n)}))}})(e[n])}("gammaln gammafn factorial factorialln".split(" ")),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(){return t(t[e].apply(null,arguments))}})(e[n])}("randn".split(" "))}(e,Math),function(t,e){function n(t,n,i,o){for(var r,s=0,a=1,l=1,u=1,c=0,h=0;e.abs((l-h)/l)>o;)h=l,a=u+(r=-(n+c)*(n+i+c)*t/(n+2*c)/(n+2*c+1))*a,l=(s=l+r*s)+(r=(c+=1)*(i-c)*t/(n+2*c-1)/(n+2*c))*l,s/=u=a+r*u,a/=u,l/=u,u=1;return l/n}function i(n,i,o){var r=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],s=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*n;if(a>=8)return 1;var l,u=2*t.normal.cdf(a,0,1,1,0)-1;u=u>=e.exp(-50/o)?e.pow(u,o):0;for(var c=a,h=(8-a)/(l=n>3?2:3),d=c+h,f=0,m=o-1,p=1;p<=l;p++){for(var g=0,v=.5*(d+c),C=.5*(d-c),y=1;y<=12;y++){var b,_=v+C*(6<y?r[(b=12-y+1)-1]:-r[(b=y)-1]),w=_*_;if(w>60)break;var A=2*t.normal.cdf(_,0,1,1,0)*.5-2*t.normal.cdf(_,n,1,1,0)*.5;A>=e.exp(-30/m)&&(g+=A=s[b-1]*e.exp(-.5*w)*e.pow(A,m))}f+=g*=2*C*o/e.sqrt(2*e.PI),c=d,d+=h}return(u+=f)<=e.exp(-30/i)?0:(u=e.pow(u,i))>=1?1:u}!function(e){for(var n=0;n<e.length;n++)(function(e){t[e]=function t(e,n,i){return this instanceof t?(this._a=e,this._b=n,this._c=i,this):new t(e,n,i)},t.fn[e]=function(n,i,o){var r=t[e](n,i,o);return r.data=this,r},t[e].prototype.sample=function(n){var i=this._a,o=this._b,r=this._c;return n?t.alter(n,function(){return t[e].sample(i,o,r)}):t[e].sample(i,o,r)},function(n){for(var i=0;i<n.length;i++)(function(n){t[e].prototype[n]=function(i){var o=this._a,r=this._b,s=this._c;return i||0===i||(i=this.data),"number"!=typeof i?t.fn.map.call(i,function(i){return t[e][n](i,o,r,s)}):t[e][n](i,o,r,s)}})(n[i])}("pdf cdf inv".split(" ")),function(n){for(var i=0;i<n.length;i++)(function(n){t[e].prototype[n]=function(){return t[e][n](this._a,this._b,this._c)}})(n[i])}("mean median mode variance".split(" "))})(e[n])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),t.extend(t.beta,{pdf:function(n,i,o){return n>1||n<0?0:1==i&&1==o?1:i<512&&o<512?e.pow(n,i-1)*e.pow(1-n,o-1)/t.betafn(i,o):e.exp((i-1)*e.log(n)+(o-1)*e.log(1-n)-t.betaln(i,o))},cdf:function(e,n,i){return e>1||e<0?1*(e>1):t.ibeta(e,n,i)},inv:function(e,n,i){return t.ibetainv(e,n,i)},mean:function(t,e){return t/(t+e)},median:function(e,n){return t.ibetainv(.5,e,n)},mode:function(t,e){return(t-1)/(t+e-2)},sample:function(e,n){var i=t.randg(e);return i/(i+t.randg(n))},variance:function(t,n){return t*n/(e.pow(t+n,2)*(t+n+1))}}),t.extend(t.centralF,{pdf:function(n,i,o){var r;return n<0?0:i<=2?0===n&&i<2?1/0:0===n&&2===i?1:1/t.betafn(i/2,o/2)*e.pow(i/o,i/2)*e.pow(n,i/2-1)*e.pow(1+i/o*n,-(i+o)/2):(r=i*n/(o+n*i),i*(o/(o+n*i))/2*t.binomial.pdf((i-2)/2,(i+o-2)/2,r))},cdf:function(e,n,i){return e<0?0:t.ibeta(n*e/(n*e+i),n/2,i/2)},inv:function(e,n,i){return i/(n*(1/t.ibetainv(e,n/2,i/2)-1))},mean:function(t,e){return e>2?e/(e-2):void 0},mode:function(t,e){return t>2?e*(t-2)/(t*(e+2)):void 0},sample:function(e,n){return 2*t.randg(e/2)/e/(2*t.randg(n/2)/n)},variance:function(t,e){if(!(e<=4))return 2*e*e*(t+e-2)/(t*(e-2)*(e-2)*(e-4))}}),t.extend(t.cauchy,{pdf:function(t,n,i){return i<0?0:i/(e.pow(t-n,2)+e.pow(i,2))/e.PI},cdf:function(t,n,i){return e.atan((t-n)/i)/e.PI+.5},inv:function(t,n,i){return n+i*e.tan(e.PI*(t-.5))},median:function(t){return t},mode:function(t){return t},sample:function(n,i){return t.randn()*e.sqrt(1/(2*t.randg(.5)))*i+n}}),t.extend(t.chisquare,{pdf:function(n,i){return n<0?0:0===n&&2===i?.5:e.exp((i/2-1)*e.log(n)-n/2-i/2*e.log(2)-t.gammaln(i/2))},cdf:function(e,n){return e<0?0:t.lowRegGamma(n/2,e/2)},inv:function(e,n){return 2*t.gammapinv(e,.5*n)},mean:function(t){return t},median:function(t){return t*e.pow(1-2/(9*t),3)},mode:function(t){return t-2>0?t-2:0},sample:function(e){return 2*t.randg(e/2)},variance:function(t){return 2*t}}),t.extend(t.exponential,{pdf:function(t,n){return t<0?0:n*e.exp(-n*t)},cdf:function(t,n){return t<0?0:1-e.exp(-n*t)},inv:function(t,n){return-e.log(1-t)/n},mean:function(t){return 1/t},median:function(t){return 1/t*e.log(2)},mode:function(){return 0},sample:function(n){return-1/n*e.log(t._random_fn())},variance:function(t){return e.pow(t,-2)}}),t.extend(t.gamma,{pdf:function(n,i,o){return n<0?0:0===n&&1===i?1/o:e.exp((i-1)*e.log(n)-n/o-t.gammaln(i)-i*e.log(o))},cdf:function(e,n,i){return e<0?0:t.lowRegGamma(n,e/i)},inv:function(e,n,i){return t.gammapinv(e,n)*i},mean:function(t,e){return t*e},mode:function(t,e){if(t>1)return(t-1)*e},sample:function(e,n){return t.randg(e)*n},variance:function(t,e){return t*e*e}}),t.extend(t.invgamma,{pdf:function(n,i,o){return n<=0?0:e.exp(-(i+1)*e.log(n)-o/n-t.gammaln(i)+i*e.log(o))},cdf:function(e,n,i){return e<=0?0:1-t.lowRegGamma(n,i/e)},inv:function(e,n,i){return i/t.gammapinv(1-e,n)},mean:function(t,e){return t>1?e/(t-1):void 0},mode:function(t,e){return e/(t+1)},sample:function(e,n){return n/t.randg(e)},variance:function(t,e){if(!(t<=2))return e*e/((t-1)*(t-1)*(t-2))}}),t.extend(t.kumaraswamy,{pdf:function(t,n,i){return 0===t&&1===n?i:1===t&&1===i?n:e.exp(e.log(n)+e.log(i)+(n-1)*e.log(t)+(i-1)*e.log(1-e.pow(t,n)))},cdf:function(t,n,i){return t<0?0:t>1?1:1-e.pow(1-e.pow(t,n),i)},inv:function(t,n,i){return e.pow(1-e.pow(1-t,1/i),1/n)},mean:function(e,n){return n*t.gammafn(1+1/e)*t.gammafn(n)/t.gammafn(1+1/e+n)},median:function(t,n){return e.pow(1-e.pow(2,-1/n),1/t)},mode:function(t,n){if(t>=1&&n>=1&&1!==t&&1!==n)return e.pow((t-1)/(t*n-1),1/t)},variance:function(){throw new Error("variance not yet implemented")}}),t.extend(t.lognormal,{pdf:function(t,n,i){return t<=0?0:e.exp(-e.log(t)-.5*e.log(2*e.PI)-e.log(i)-e.pow(e.log(t)-n,2)/(2*i*i))},cdf:function(n,i,o){return n<0?0:.5+.5*t.erf((e.log(n)-i)/e.sqrt(2*o*o))},inv:function(n,i,o){return e.exp(-1.4142135623730951*o*t.erfcinv(2*n)+i)},mean:function(t,n){return e.exp(t+n*n/2)},median:function(t){return e.exp(t)},mode:function(t,n){return e.exp(t-n*n)},sample:function(n,i){return e.exp(t.randn()*i+n)},variance:function(t,n){return(e.exp(n*n)-1)*e.exp(2*t+n*n)}}),t.extend(t.noncentralt,{pdf:function(n,i,o){return e.abs(o)<1e-14?t.studentt.pdf(n,i):e.abs(n)<1e-14?e.exp(t.gammaln((i+1)/2)-o*o/2-.5*e.log(e.PI*i)-t.gammaln(i/2)):i/n*(t.noncentralt.cdf(n*e.sqrt(1+2/i),i+2,o)-t.noncentralt.cdf(n,i,o))},cdf:function(n,i,o){var r=1e-14;if(e.abs(o)<r)return t.studentt.cdf(n,i);var s=!1;n<0&&(s=!0,o=-o);for(var a=t.normal.cdf(-o,0,1),l=r+1,u=l,c=n*n/(n*n+i),h=0,d=e.exp(-o*o/2),f=e.exp(-o*o/2-.5*e.log(2)-t.gammaln(1.5))*o;h<200||u>r||l>r;)u=l,h>0&&(d*=o*o/(2*h),f*=o*o/(2*(h+.5))),a+=.5*(l=d*t.beta.cdf(c,h+.5,i/2)+f*t.beta.cdf(c,h+1,i/2)),h++;return s?1-a:a}}),t.extend(t.normal,{pdf:function(t,n,i){return e.exp(-.5*e.log(2*e.PI)-e.log(i)-e.pow(t-n,2)/(2*i*i))},cdf:function(n,i,o){return.5*(1+t.erf((n-i)/e.sqrt(2*o*o)))},inv:function(e,n,i){return-1.4142135623730951*i*t.erfcinv(2*e)+n},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},sample:function(e,n){return t.randn()*n+e},variance:function(t,e){return e*e}}),t.extend(t.pareto,{pdf:function(t,n,i){return t<n?0:i*e.pow(n,i)/e.pow(t,i+1)},cdf:function(t,n,i){return t<n?0:1-e.pow(n/t,i)},inv:function(t,n,i){return n/e.pow(1-t,1/i)},mean:function(t,n){if(!(n<=1))return n*e.pow(t,n)/(n-1)},median:function(t,n){return t*(n*e.SQRT2)},mode:function(t){return t},variance:function(t,n){if(!(n<=2))return t*t*n/(e.pow(n-1,2)*(n-2))}}),t.extend(t.studentt,{pdf:function(n,i){return i=i>1e100?1e100:i,1/(e.sqrt(i)*t.betafn(.5,i/2))*e.pow(1+n*n/i,-(i+1)/2)},cdf:function(n,i){var o=i/2;return t.ibeta((n+e.sqrt(n*n+i))/(2*e.sqrt(n*n+i)),o,o)},inv:function(n,i){var o=t.ibetainv(2*e.min(n,1-n),.5*i,.5);return o=e.sqrt(i*(1-o)/o),n>.5?o:-o},mean:function(t){return t>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(n){return t.randn()*e.sqrt(n/(2*t.randg(n/2)))},variance:function(t){return t>2?t/(t-2):t>1?1/0:void 0}}),t.extend(t.weibull,{pdf:function(t,n,i){return t<0||n<0||i<0?0:i/n*e.pow(t/n,i-1)*e.exp(-e.pow(t/n,i))},cdf:function(t,n,i){return t<0?0:1-e.exp(-e.pow(t/n,i))},inv:function(t,n,i){return n*e.pow(-e.log(1-t),1/i)},mean:function(e,n){return e*t.gammafn(1+1/n)},median:function(t,n){return t*e.pow(e.log(2),1/n)},mode:function(t,n){return n<=1?0:t*e.pow((n-1)/n,1/n)},sample:function(n,i){return n*e.pow(-e.log(t._random_fn()),1/i)},variance:function(n,i){return n*n*t.gammafn(1+2/i)-e.pow(t.weibull.mean(n,i),2)}}),t.extend(t.uniform,{pdf:function(t,e,n){return t<e||t>n?0:1/(n-e)},cdf:function(t,e,n){return t<e?0:t<n?(t-e)/(n-e):1},inv:function(t,e,n){return e+t*(n-e)},mean:function(t,e){return.5*(t+e)},median:function(e,n){return t.mean(e,n)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(e,n){return e/2+n/2+(n/2-e/2)*(2*t._random_fn()-1)},variance:function(t,n){return e.pow(n-t,2)/12}}),t.extend(t.binomial,{pdf:function(n,i,o){return 0===o||1===o?i*o===n?1:0:t.combination(i,n)*e.pow(o,n)*e.pow(1-o,i-n)},cdf:function(i,o,r){var s,a=1e-10;if(i<0)return 0;if(i>=o)return 1;if(r<0||r>1||o<=0)return NaN;var l=r,u=(i=e.floor(i))+1,c=o-i,h=u+c,d=e.exp(t.gammaln(h)-t.gammaln(c)-t.gammaln(u)+u*e.log(l)+c*e.log(1-l));return s=l<(u+1)/(h+2)?d*n(l,u,c,a):1-d*n(1-l,c,u,a),e.round(1/a*(1-s))/(1/a)}}),t.extend(t.negbin,{pdf:function(n,i,o){return n===n>>>0&&(n<0?0:t.combination(n+i-1,i-1)*e.pow(1-o,n)*e.pow(o,i))},cdf:function(e,n,i){var o=0,r=0;if(e<0)return 0;for(;r<=e;r++)o+=t.negbin.pdf(r,n,i);return o}}),t.extend(t.hypgeom,{pdf:function(n,i,o,r){if(n!=n|0)return!1;if(n<0||n<o-(i-r))return 0;if(n>r||n>o)return 0;if(2*o>i)return 2*r>i?t.hypgeom.pdf(i-o-r+n,i,i-o,i-r):t.hypgeom.pdf(r-n,i,i-o,r);if(2*r>i)return t.hypgeom.pdf(o-n,i,o,i-r);if(o<r)return t.hypgeom.pdf(n,i,r,o);for(var s=1,a=0,l=0;l<n;l++){for(;s>1&&a<r;)s*=1-o/(i-a),a++;s*=(r-l)*(o-l)/((l+1)*(i-o-r+l+1))}for(;a<r;a++)s*=1-o/(i-a);return e.min(1,e.max(0,s))},cdf:function(n,i,o,r){if(n<0||n<o-(i-r))return 0;if(n>=r||n>=o)return 1;if(2*o>i)return 2*r>i?t.hypgeom.cdf(i-o-r+n,i,i-o,i-r):1-t.hypgeom.cdf(r-n-1,i,i-o,r);if(2*r>i)return 1-t.hypgeom.cdf(o-n-1,i,o,i-r);if(o<r)return t.hypgeom.cdf(n,i,r,o);for(var s=1,a=1,l=0,u=0;u<n;u++){for(;s>1&&l<r;){var c=1-o/(i-l);a*=c,s*=c,l++}s+=a*=(r-u)*(o-u)/((u+1)*(i-o-r+u+1))}for(;l<r;l++)s*=1-o/(i-l);return e.min(1,e.max(0,s))}}),t.extend(t.poisson,{pdf:function(n,i){return i<0||n%1!=0||n<0?0:e.pow(i,n)*e.exp(-i)/t.factorial(n)},cdf:function(e,n){var i=[],o=0;if(e<0)return 0;for(;o<=e;o++)i.push(t.poisson.pdf(o,n));return t.sum(i)},mean:function(t){return t},variance:function(t){return t},sampleSmall:function(n){var i=1,o=0,r=e.exp(-n);do{o++,i*=t._random_fn()}while(i>r);return o-1},sampleLarge:function(n){var i,o,r,s,a,l,u,c,h,d,f=n;for(s=e.sqrt(f),a=e.log(f),l=.02483*(u=.931+2.53*s)-.059,c=1.1239+1.1328/(u-3.4),h=.9277-3.6224/(u-2);;){if(o=e.random()-.5,r=e.random(),d=.5-e.abs(o),i=e.floor((2*l/d+u)*o+f+.43),d>=.07&&r<=h)return i;if(!(i<0||d<.013&&r>d)&&e.log(r)+e.log(c)-e.log(l/(d*d)+u)<=i*a-f-t.loggam(i+1))return i}},sample:function(t){return t<10?this.sampleSmall(t):this.sampleLarge(t)}}),t.extend(t.triangular,{pdf:function(t,e,n,i){return n<=e||i<e||i>n?NaN:t<e||t>n?0:t<i?2*(t-e)/((n-e)*(i-e)):t===i?2/(n-e):2*(n-t)/((n-e)*(n-i))},cdf:function(t,n,i,o){return i<=n||o<n||o>i?NaN:t<=n?0:t>=i?1:t<=o?e.pow(t-n,2)/((i-n)*(o-n)):1-e.pow(i-t,2)/((i-n)*(i-o))},inv:function(t,n,i,o){return i<=n||o<n||o>i?NaN:t<=(o-n)/(i-n)?n+(i-n)*e.sqrt(t*((o-n)/(i-n))):n+(i-n)*(1-e.sqrt((1-t)*(1-(o-n)/(i-n))))},mean:function(t,e,n){return(t+e+n)/3},median:function(t,n,i){return i<=(t+n)/2?n-e.sqrt((n-t)*(n-i))/e.sqrt(2):i>(t+n)/2?t+e.sqrt((n-t)*(i-t))/e.sqrt(2):void 0},mode:function(t,e,n){return n},sample:function(n,i,o){var r=t._random_fn();return r<(o-n)/(i-n)?n+e.sqrt(r*(i-n)*(o-n)):i-e.sqrt((1-r)*(i-n)*(i-o))},variance:function(t,e,n){return(t*t+e*e+n*n-t*e-t*n-e*n)/18}}),t.extend(t.arcsine,{pdf:function(t,n,i){return i<=n?NaN:t<=n||t>=i?0:2/e.PI*e.pow(e.pow(i-n,2)-e.pow(2*t-n-i,2),-.5)},cdf:function(t,n,i){return t<n?0:t<i?2/e.PI*e.asin(e.sqrt((t-n)/(i-n))):1},inv:function(t,n,i){return n+(.5-.5*e.cos(e.PI*t))*(i-n)},mean:function(t,e){return e<=t?NaN:(t+e)/2},median:function(t,e){return e<=t?NaN:(t+e)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(n,i){return(n+i)/2+(i-n)/2*e.sin(2*e.PI*t.uniform.sample(0,1))},variance:function(t,n){return n<=t?NaN:e.pow(n-t,2)/8}}),t.extend(t.laplace,{pdf:function(t,n,i){return i<=0?0:e.exp(-e.abs(t-n)/i)/(2*i)},cdf:function(t,n,i){return i<=0?0:t<n?.5*e.exp((t-n)/i):1-.5*e.exp(-(t-n)/i)},mean:function(t){return t},median:function(t){return t},mode:function(t){return t},variance:function(t,e){return 2*e*e},sample:function(n,i){var o,r=t._random_fn()-.5;return n-i*((o=r)/e.abs(o))*e.log(1-2*e.abs(r))}}),t.extend(t.tukey,{cdf:function(n,o,r){var s=o,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],l=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(n<=0)return 0;if(r<2||s<2)return NaN;if(!Number.isFinite(n))return 1;if(r>25e3)return i(n,1,s);var u,c=.5*r,h=c*e.log(r)-r*e.log(2)-t.gammaln(c),d=c-1,f=.25*r;u=r<=100?1:r<=800?.5:r<=5e3?.25:.125,h+=e.log(u);for(var m=0,p=1;p<=50;p++){for(var g=0,v=(2*p-1)*u,C=1;C<=16;C++){var y,b;8<C?(y=C-8-1,b=h+d*e.log(v+a[y]*u)-(a[y]*u+v)*f):(y=C-1,b=h+d*e.log(v-a[y]*u)+(a[y]*u-v)*f),b>=-30&&(g+=i(8<C?n*e.sqrt(.5*(a[y]*u+v)):n*e.sqrt(.5*(-a[y]*u+v)),1,s)*l[y]*e.exp(b))}if(p*u>=1&&g<=1e-14)break;m+=g}if(g>1e-14)throw new Error("tukey.cdf failed to converge");return m>1&&(m=1),m},inv:function(n,i,o){if(o<2||i<2)return NaN;if(n<0||n>1)return NaN;if(0===n)return 0;if(1===n)return 1/0;var r,s=function(t,n,i){var o=.5-.5*t,r=e.sqrt(e.log(1/(o*o))),s=r+((((-453642210148e-16*r-.204231210125)*r-.342242088547)*r-1)*r+.322232421088)/((((.0038560700634*r+.10353775285)*r+.531103462366)*r+.588581570495)*r+.099348462606);i<120&&(s+=(s*s*s+s)/i/4);var a=.8832-.2368*s;return i<120&&(a+=-1.214/i+1.208*s/i),s*(a*e.log(n-1)+1.4142)}(n,i,o),a=t.tukey.cdf(s,i,o)-n;r=a>0?e.max(0,s-1):s+1;for(var l,u=t.tukey.cdf(r,i,o)-n,c=1;c<50;c++)if(l=r-u*(r-s)/(u-a),a=u,s=r,l<0&&(l=0,u=-n),u=t.tukey.cdf(l,i,o)-n,r=l,e.abs(r-s)<1e-4)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(t,e){var n,i,o=Array.prototype.push,r=t.utils.isArray;function s(e){return r(e)||e instanceof t}t.extend({add:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.map(e,function(t,e,i){return t+n[e][i]})):t.map(e,function(t){return t+n})},subtract:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.map(e,function(t,e,i){return t-n[e][i]||0})):t.map(e,function(t){return t-n})},divide:function(e,n){return s(n)?(s(n[0])||(n=[n]),t.multiply(e,t.inv(n))):t.map(e,function(t){return t/n})},multiply:function(e,n){var i,o,r,a,l,u,c,h;if(void 0===e.length&&void 0===n.length)return e*n;if(l=e.length,u=e[0].length,c=t.zeros(l,r=s(n)?n[0].length:u),h=0,s(n)){for(;h<r;h++)for(i=0;i<l;i++){for(a=0,o=0;o<u;o++)a+=e[i][o]*n[o][h];c[i][h]=a}return 1===l&&1===h?c[0][0]:c}return t.map(e,function(t){return t*n})},outer:function(e,n){return t.multiply(e.map(function(t){return[t]}),[n])},dot:function(e,n){s(e[0])||(e=[e]),s(n[0])||(n=[n]);for(var i,o,r=1===e[0].length&&1!==e.length?t.transpose(e):e,a=1===n[0].length&&1!==n.length?t.transpose(n):n,l=[],u=0,c=r.length,h=r[0].length;u<c;u++){for(l[u]=[],i=0,o=0;o<h;o++)i+=r[u][o]*a[u][o];l[u]=i}return 1===l.length?l[0]:l},pow:function(n,i){return t.map(n,function(t){return e.pow(t,i)})},exp:function(n){return t.map(n,function(t){return e.exp(t)})},log:function(n){return t.map(n,function(t){return e.log(t)})},abs:function(n){return t.map(n,function(t){return e.abs(t)})},norm:function(t,n){var i=0,o=0;for(isNaN(n)&&(n=2),s(t[0])&&(t=t[0]);o<t.length;o++)i+=e.pow(e.abs(t[o]),n);return e.pow(i,1/n)},angle:function(n,i){return e.acos(t.dot(n,i)/(t.norm(n)*t.norm(i)))},aug:function(t,e){var n,i=[];for(n=0;n<t.length;n++)i.push(t[n].slice());for(n=0;n<i.length;n++)o.apply(i[n],e[n]);return i},inv:function(e){for(var n,i=e.length,o=e[0].length,r=t.identity(i,o),s=t.gauss_jordan(e,r),a=[],l=0;l<i;l++)for(a[l]=[],n=o;n<s[0].length;n++)a[l][n-o]=s[l][n];return a},det:function t(e){if(2===e.length)return e[0][0]*e[1][1]-e[0][1]*e[1][0];for(var n=0,i=0;i<e.length;i++){for(var o=[],r=1;r<e.length;r++){o[r-1]=[];for(var s=0;s<e.length;s++)s<i?o[r-1][s]=e[r][s]:s>i&&(o[r-1][s-1]=e[r][s])}var a=i%2?-1:1;n+=t(o)*e[0][i]*a}return n},gauss_elimination:function(n,i){var o,r,s,a,l=0,u=0,c=n.length,h=n[0].length,d=1,f=0,m=[];for(o=(n=t.aug(n,i))[0].length,l=0;l<c;l++){for(r=n[l][l],u=l,a=l+1;a<h;a++)r<e.abs(n[a][l])&&(r=n[a][l],u=a);if(u!=l)for(a=0;a<o;a++)s=n[l][a],n[l][a]=n[u][a],n[u][a]=s;for(u=l+1;u<c;u++)for(d=n[u][l]/n[l][l],a=l;a<o;a++)n[u][a]=n[u][a]-d*n[l][a]}for(l=c-1;l>=0;l--){for(f=0,u=l+1;u<=c-1;u++)f+=m[u]*n[l][u];m[l]=(n[l][o-1]-f)/n[l][l]}return m},gauss_jordan:function(n,i){var o,r,s,a=t.aug(n,i),l=a.length,u=a[0].length,c=0;for(r=0;r<l;r++){var h=r;for(s=r+1;s<l;s++)e.abs(a[s][r])>e.abs(a[h][r])&&(h=s);var d=a[r];for(a[r]=a[h],a[h]=d,s=r+1;s<l;s++)for(c=a[s][r]/a[r][r],o=r;o<u;o++)a[s][o]-=a[r][o]*c}for(r=l-1;r>=0;r--){for(c=a[r][r],s=0;s<r;s++)for(o=u-1;o>r-1;o--)a[s][o]-=a[r][o]*a[s][r]/c;for(a[r][r]/=c,o=l;o<u;o++)a[r][o]/=c}return a},triaUpSolve:function(e,n){var i,o=e[0].length,r=t.zeros(1,o)[0],s=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),s=!0),t.arange(o-1,-1,-1).forEach(function(s){i=t.arange(s+1,o).map(function(t){return r[t]*e[s][t]}),r[s]=(n[s]-t.sum(i))/e[s][s]}),s?r.map(function(t){return[t]}):r},triaLowSolve:function(e,n){var i,o=e[0].length,r=t.zeros(1,o)[0],s=!1;return null!=n[0].length&&(n=n.map(function(t){return t[0]}),s=!0),t.arange(o).forEach(function(o){i=t.arange(o).map(function(t){return e[o][t]*r[t]}),r[o]=(n[o]-t.sum(i))/e[o][o]}),s?r.map(function(t){return[t]}):r},lu:function(e){var n,i=e.length,o=t.identity(i),r=t.zeros(e.length,e[0].length);return t.arange(i).forEach(function(t){r[0][t]=e[0][t]}),t.arange(1,i).forEach(function(s){t.arange(s).forEach(function(i){n=t.arange(i).map(function(t){return o[s][t]*r[t][i]}),o[s][i]=(e[s][i]-t.sum(n))/r[i][i]}),t.arange(s,i).forEach(function(i){n=t.arange(s).map(function(t){return o[s][t]*r[t][i]}),r[s][i]=e[n.length][i]-t.sum(n)})}),[o,r]},cholesky:function(n){var i,o=n.length,r=t.zeros(n.length,n[0].length);return t.arange(o).forEach(function(s){i=t.arange(s).map(function(t){return e.pow(r[s][t],2)}),r[s][s]=e.sqrt(n[s][s]-t.sum(i)),t.arange(s+1,o).forEach(function(e){i=t.arange(s).map(function(t){return r[s][t]*r[e][t]}),r[e][s]=(n[s][e]-t.sum(i))/r[s][s]})}),r},gauss_jacobi:function(n,i,o,r){for(var s,a,l,u,c=0,h=0,d=n.length,f=[],m=[],p=[];c<d;c++)for(f[c]=[],m[c]=[],p[c]=[],h=0;h<d;h++)c>h?(f[c][h]=n[c][h],m[c][h]=p[c][h]=0):c<h?(m[c][h]=n[c][h],f[c][h]=p[c][h]=0):(p[c][h]=n[c][h],f[c][h]=m[c][h]=0);for(l=t.multiply(t.multiply(t.inv(p),t.add(f,m)),-1),a=t.multiply(t.inv(p),i),s=o,u=t.add(t.multiply(l,o),a),c=2;e.abs(t.norm(t.subtract(u,s)))>r;)s=u,u=t.add(t.multiply(l,s),a),c++;return u},gauss_seidel:function(n,i,o,r){for(var s,a,l,u,c,h=0,d=n.length,f=[],m=[],p=[];h<d;h++)for(f[h]=[],m[h]=[],p[h]=[],s=0;s<d;s++)h>s?(f[h][s]=n[h][s],m[h][s]=p[h][s]=0):h<s?(m[h][s]=n[h][s],f[h][s]=p[h][s]=0):(p[h][s]=n[h][s],f[h][s]=m[h][s]=0);for(u=t.multiply(t.multiply(t.inv(t.add(p,f)),m),-1),l=t.multiply(t.inv(t.add(p,f)),i),a=o,c=t.add(t.multiply(u,o),l),h=2;e.abs(t.norm(t.subtract(c,a)))>r;)a=c,c=t.add(t.multiply(u,a),l),h+=1;return c},SOR:function(n,i,o,r,s){for(var a,l,u,c,h,d=0,f=n.length,m=[],p=[],g=[];d<f;d++)for(m[d]=[],p[d]=[],g[d]=[],a=0;a<f;a++)d>a?(m[d][a]=n[d][a],p[d][a]=g[d][a]=0):d<a?(p[d][a]=n[d][a],m[d][a]=g[d][a]=0):(g[d][a]=n[d][a],m[d][a]=p[d][a]=0);for(c=t.multiply(t.inv(t.add(g,t.multiply(m,s))),t.subtract(t.multiply(g,1-s),t.multiply(p,s))),u=t.multiply(t.multiply(t.inv(t.add(g,t.multiply(m,s))),i),s),l=o,h=t.add(t.multiply(c,o),u),d=2;e.abs(t.norm(t.subtract(h,l)))>r;)l=h,h=t.add(t.multiply(c,l),u),d++;return h},householder:function(n){for(var i,o,r,s,a=n.length,l=n[0].length,u=0,c=[],h=[];u<a-1;u++){for(i=0,s=u+1;s<l;s++)i+=n[s][u]*n[s][u];for(i=(n[u+1][u]>0?-1:1)*e.sqrt(i),o=e.sqrt((i*i-n[u+1][u]*i)/2),(c=t.zeros(a,1))[u+1][0]=(n[u+1][u]-i)/(2*o),r=u+2;r<a;r++)c[r][0]=n[r][u]/(2*o);h=t.subtract(t.identity(a,l),t.multiply(t.multiply(c,t.transpose(c)),2)),n=t.multiply(h,t.multiply(n,h))}return n},QR:(n=t.sum,i=t.arange,function(o){var r,s,a,l=o.length,u=o[0].length,c=t.zeros(u,u);for(o=t.copy(o),s=0;s<u;s++){for(c[s][s]=e.sqrt(n(i(l).map(function(t){return o[t][s]*o[t][s]}))),r=0;r<l;r++)o[r][s]=o[r][s]/c[s][s];for(a=s+1;a<u;a++)for(c[s][a]=n(i(l).map(function(t){return o[t][s]*o[t][a]})),r=0;r<l;r++)o[r][a]=o[r][a]-o[r][s]*c[s][a]}return[o,c]}),lstsq:function(e,n){var i=!1;void 0===n[0].length&&(n=n.map(function(t){return[t]}),i=!0);var o=t.QR(e),r=o[0],s=o[1],a=e[0].length,l=t.slice(r,{col:{end:a}}),u=function(e){var n=(e=t.copy(e)).length,i=t.identity(n);return t.arange(n-1,-1,-1).forEach(function(n){t.sliceAssign(i,{row:n},t.divide(t.slice(i,{row:n}),e[n][n])),t.sliceAssign(e,{row:n},t.divide(t.slice(e,{row:n}),e[n][n])),t.arange(n).forEach(function(o){var r=t.multiply(e[o][n],-1),s=t.slice(e,{row:o}),a=t.multiply(t.slice(e,{row:n}),r);t.sliceAssign(e,{row:o},t.add(s,a));var l=t.slice(i,{row:o}),u=t.multiply(t.slice(i,{row:n}),r);t.sliceAssign(i,{row:o},t.add(l,u))})}),i}(t.slice(s,{row:{end:a}})),c=t.transpose(l);void 0===c[0].length&&(c=[c]);var h=t.multiply(t.multiply(u,c),n);return void 0===h.length&&(h=[[h]]),i?h.map(function(t){return t[0]}):h},jacobi:function(n){for(var i,o,r,s,a,l,u,c=1,h=n.length,d=t.identity(h,h),f=[];1===c;){for(a=n[0][1],r=0,s=1,i=0;i<h;i++)for(o=0;o<h;o++)i!=o&&a<e.abs(n[i][o])&&(a=e.abs(n[i][o]),r=i,s=o);for(l=n[r][r]===n[s][s]?n[r][s]>0?e.PI/4:-e.PI/4:e.atan(2*n[r][s]/(n[r][r]-n[s][s]))/2,(u=t.identity(h,h))[r][r]=e.cos(l),u[r][s]=-e.sin(l),u[s][r]=e.sin(l),u[s][s]=e.cos(l),d=t.multiply(d,u),n=t.multiply(t.multiply(t.inv(u),n),u),c=0,i=1;i<h;i++)for(o=1;o<h;o++)i!=o&&e.abs(n[i][o])>.001&&(c=1)}for(i=0;i<h;i++)f.push(n[i][i]);return[d,f]},rungekutta:function(t,e,n,i,o,r){var s,a,l;if(2===r)for(;i<=n;)o+=((s=e*t(i,o))+(a=e*t(i+e,o+s)))/2,i+=e;if(4===r)for(;i<=n;)o+=((s=e*t(i,o))+2*(a=e*t(i+e/2,o+s/2))+2*(l=e*t(i+e/2,o+a/2))+e*t(i+e,o+l))/6,i+=e;return o},romberg:function(t,n,i,o){for(var r,s,a,l,u,c=0,h=(i-n)/2,d=[],f=[],m=[];c<o/2;){for(u=t(n),a=n,l=0;a<=i;a+=h,l++)d[l]=a;for(r=d.length,a=1;a<r-1;a++)u+=(a%2!=0?4:2)*t(d[a]);u=h/3*(u+t(i)),m[c]=u,h/=2,c++}for(s=m.length,r=1;1!==s;){for(a=0;a<s-1;a++)f[a]=(e.pow(4,r)*m[a+1]-m[a])/(e.pow(4,r)-1);s=f.length,m=f,f=[],r++}return m},richardson:function(t,n,i,o){function r(t,e){for(var n,i=0,o=t.length;i<o;i++)t[i]===e&&(n=i);return n}for(var s,a,l,u,c,h=e.abs(i-t[r(t,i)+1]),d=0,f=[],m=[];o>=h;)s=r(t,i+o),a=r(t,i),f[d]=(n[s]-2*n[a]+n[2*a-s])/(o*o),o/=2,d++;for(u=f.length,l=1;1!=u;){for(c=0;c<u-1;c++)m[c]=(e.pow(4,l)*f[c+1]-f[c])/(e.pow(4,l)-1);u=m.length,f=m,m=[],l++}return f},simpson:function(t,e,n,i){for(var o,r=(n-e)/i,s=t(e),a=[],l=e,u=0,c=1;l<=n;l+=r,u++)a[u]=l;for(o=a.length;c<o-1;c++)s+=(c%2!=0?4:2)*t(a[c]);return r/3*(s+t(n))},hermite:function(t,e,n,i){for(var o,r=t.length,s=0,a=0,l=[],u=[],c=[],h=[];a<r;a++){for(l[a]=1,o=0;o<r;o++)a!=o&&(l[a]*=(i-t[o])/(t[a]-t[o]));for(u[a]=0,o=0;o<r;o++)a!=o&&(u[a]+=1/(t[a]-t[o]));c[a]=(1-2*(i-t[a])*u[a])*(l[a]*l[a]),h[a]=(i-t[a])*(l[a]*l[a]),s+=c[a]*e[a]+h[a]*n[a]}return s},lagrange:function(t,e,n){for(var i,o,r=0,s=0,a=t.length;s<a;s++){for(o=e[s],i=0;i<a;i++)s!=i&&(o*=(n-t[i])/(t[s]-t[i]));r+=o}return r},cubic_spline:function(e,n,i){for(var o,r,s=e.length,a=0,l=[],u=[],c=[],h=[],d=[],f=[];a<s-1;a++)h[a]=e[a+1]-e[a];for(c[0]=0,a=1;a<s-1;a++)c[a]=3/h[a]*(n[a+1]-n[a])-3/h[a-1]*(n[a]-n[a-1]);for(a=1;a<s-1;a++)l[a]=[],u[a]=[],l[a][a-1]=h[a-1],l[a][a]=2*(h[a-1]+h[a]),l[a][a+1]=h[a],u[a][0]=c[a];for(r=t.multiply(t.inv(l),u),o=0;o<s-1;o++)d[o]=(n[o+1]-n[o])/h[o]-h[o]*(r[o+1][0]+2*r[o][0])/3,f[o]=(r[o+1][0]-r[o][0])/(3*h[o]);for(o=0;o<s&&!(e[o]>i);o++);return n[o-=1]+(i-e[o])*d[o]+t.sq(i-e[o])*r[o]+(i-e[o])*t.sq(i-e[o])*f[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(e){var n,i,o,r,s,a=e.length,l=e[0].length,u=0,c=[],h=[],d=[],f=[],m=[],p=[],g=[];for(u=0;u<a;u++)c[u]=t.sum(e[u])/l;for(u=0;u<l;u++)for(m[u]=[],n=0;n<a;n++)m[u][n]=e[n][u]-c[n];for(m=t.transpose(m),u=0;u<a;u++)for(p[u]=[],n=0;n<a;n++)p[u][n]=t.dot([m[u]],[m[n]])/(l-1);for(s=(o=t.jacobi(p))[0],h=o[1],g=t.transpose(s),u=0;u<h.length;u++)for(n=u;n<h.length;n++)h[u]<h[n]&&(i=h[u],h[u]=h[n],h[n]=i,d=g[u],g[u]=g[n],g[n]=d);for(r=t.transpose(m),u=0;u<a;u++)for(f[u]=[],n=0;n<r.length;n++)f[u][n]=t.dot([g[u]],[r[n]]);return[e,h,g,f]}}),function(e){for(var n=0;n<e.length;n++)(function(e){t.fn[e]=function(n,i){var o=this;return i?(setTimeout(function(){i.call(o,t.fn[e].call(o,n))},15),this):"number"==typeof t[e](this,n)?t[e](this,n):t(t[e](this,n))}})(e[n])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(t,e){var n=[].slice,i=t.utils.isNumber,o=t.utils.isArray;function r(t,n,i,o){if(t>1||i>1||t<=0||i<=0)throw new Error("Proportions should be greater than 0 and less than 1");var r=(t*n+i*o)/(n+o);return(t-i)/e.sqrt(r*(1-r)*(1/n+1/o))}t.extend({zscore:function(){var e=n.call(arguments);return i(e[1])?(e[0]-e[1])/e[2]:(e[0]-t.mean(e[1]))/t.stdev(e[1],e[2])},ztest:function(){var i,r=n.call(arguments);return o(r[1])?(i=t.zscore(r[0],r[1],r[3]),1===r[2]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):r.length>2?(i=t.zscore(r[0],r[1],r[2]),1===r[3]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1)):(i=r[0],1===r[1]?t.normal.cdf(-e.abs(i),0,1):2*t.normal.cdf(-e.abs(i),0,1))}}),t.extend(t.fn,{zscore:function(t,e){return(t-this.mean())/this.stdev(e)},ztest:function(n,i,o){var r=e.abs(this.zscore(n,o));return 1===i?t.normal.cdf(-r,0,1):2*t.normal.cdf(-r,0,1)}}),t.extend({tscore:function(){var i=n.call(arguments);return 4===i.length?(i[0]-i[1])/(i[2]/e.sqrt(i[3])):(i[0]-t.mean(i[1]))/(t.stdev(i[1],!0)/e.sqrt(i[1].length))},ttest:function(){var o,r=n.call(arguments);return 5===r.length?(o=e.abs(t.tscore(r[0],r[1],r[2],r[3])),1===r[4]?t.studentt.cdf(-o,r[3]-1):2*t.studentt.cdf(-o,r[3]-1)):i(r[1])?(o=e.abs(r[0]),1==r[2]?t.studentt.cdf(-o,r[1]-1):2*t.studentt.cdf(-o,r[1]-1)):(o=e.abs(t.tscore(r[0],r[1])),1==r[2]?t.studentt.cdf(-o,r[1].length-1):2*t.studentt.cdf(-o,r[1].length-1))}}),t.extend(t.fn,{tscore:function(t){return(t-this.mean())/(this.stdev(!0)/e.sqrt(this.cols()))},ttest:function(n,i){return 1===i?1-t.studentt.cdf(e.abs(this.tscore(n)),this.cols()-1):2*t.studentt.cdf(-e.abs(this.tscore(n)),this.cols()-1)}}),t.extend({anovafscore:function(){var i,o,r,s,a,l,u,c,h=n.call(arguments);if(1===h.length){for(a=new Array(h[0].length),u=0;u<h[0].length;u++)a[u]=h[0][u];h=a}for(o=new Array,u=0;u<h.length;u++)o=o.concat(h[u]);for(r=t.mean(o),i=0,u=0;u<h.length;u++)i+=h[u].length*e.pow(t.mean(h[u])-r,2);for(i/=h.length-1,l=0,u=0;u<h.length;u++)for(s=t.mean(h[u]),c=0;c<h[u].length;c++)l+=e.pow(h[u][c]-s,2);return i/(l/(o.length-h.length))},anovaftest:function(){var e,o,r,s,a=n.call(arguments);if(i(a[0]))return 1-t.centralF.cdf(a[0],a[1],a[2]);var l=t.anovafscore(a);for(e=a.length-1,r=0,s=0;s<a.length;s++)r+=a[s].length;return o=r-e-1,1-t.centralF.cdf(l,e,o)},ftest:function(e,n,i){return 1-t.centralF.cdf(e,n,i)}}),t.extend(t.fn,{anovafscore:function(){return t.anovafscore(this.toArray())},anovaftes:function(){var e,n=0;for(e=0;e<this.length;e++)n+=this[e].length;return t.ftest(this.anovafscore(),this.length-1,n-this.length)}}),t.extend({qscore:function(){var o,r,s,a,l,u=n.call(arguments);return i(u[0])?(o=u[0],r=u[1],s=u[2],a=u[3],l=u[4]):(o=t.mean(u[0]),r=t.mean(u[1]),s=u[0].length,a=u[1].length,l=u[2]),e.abs(o-r)/(l*e.sqrt((1/s+1/a)/2))},qtest:function(){var e,i=n.call(arguments);3===i.length?(e=i[0],i=i.slice(1)):7===i.length?(e=t.qscore(i[0],i[1],i[2],i[3],i[4]),i=i.slice(5)):(e=t.qscore(i[0],i[1],i[2]),i=i.slice(3));var o=i[0],r=i[1];return 1-t.tukey.cdf(e,r,o-r)},tukeyhsd:function(e){for(var n=t.pooledstdev(e),i=e.map(function(e){return t.mean(e)}),o=e.reduce(function(t,e){return t+e.length},0),r=[],s=0;s<e.length;++s)for(var a=s+1;a<e.length;++a){var l=t.qtest(i[s],i[a],e[s].length,e[a].length,n,o,e.length);r.push([[s,a],l])}return r}}),t.extend({normalci:function(){var i,o=n.call(arguments),r=new Array(2);return i=4===o.length?e.abs(t.normal.inv(o[1]/2,0,1)*o[2]/e.sqrt(o[3])):e.abs(t.normal.inv(o[1]/2,0,1)*t.stdev(o[2])/e.sqrt(o[2].length)),r[0]=o[0]-i,r[1]=o[0]+i,r},tci:function(){var i,o=n.call(arguments),r=new Array(2);return i=4===o.length?e.abs(t.studentt.inv(o[1]/2,o[3]-1)*o[2]/e.sqrt(o[3])):e.abs(t.studentt.inv(o[1]/2,o[2].length-1)*t.stdev(o[2],!0)/e.sqrt(o[2].length)),r[0]=o[0]-i,r[1]=o[0]+i,r},significant:function(t,e){return t<e}}),t.extend(t.fn,{normalci:function(e,n){return t.normalci(e,n,this.toArray())},tci:function(e,n){return t.tci(e,n,this.toArray())}}),t.extend(t.fn,{oneSidedDifferenceOfProportions:function(e,n,i,o){var s=r(e,n,i,o);return t.ztest(s,1)},twoSidedDifferenceOfProportions:function(e,n,i,o){var s=r(e,n,i,o);return t.ztest(s,2)}})}(e,Math),e.models=function(){function t(t,n){var i=t.length,o=n[0].length-1,r=i-o-1,s=e.lstsq(n,t),a=e.multiply(n,s.map(function(t){return[t]})).map(function(t){return t[0]}),l=e.subtract(t,a),u=e.mean(t),c=e.sum(a.map(function(t){return Math.pow(t-u,2)})),h=e.sum(t.map(function(t,e){return Math.pow(t-a[e],2)})),d=c+h;return{exog:n,endog:t,nobs:i,df_model:o,df_resid:r,coef:s,predict:a,resid:l,ybar:u,SST:d,SSE:c,SSR:h,R2:c/d}}function n(n){var i,o,r=(i=n.exog,o=i[0].length,e.arange(o).map(function(n){var r=e.arange(o).filter(function(t){return t!==n});return t(e.col(i,n).map(function(t){return t[0]}),e.col(i,r))})),s=Math.sqrt(n.SSR/n.df_resid),a=r.map(function(t){var e=t.SST,n=t.R2;return s/Math.sqrt(e*(1-n))}),l=n.coef.map(function(t,e){return(t-0)/a[e]}),u=l.map(function(t){var i=e.studentt.cdf(t,n.df_resid);return 2*(i>.5?1-i:i)}),c=e.studentt.inv(.975,n.df_resid),h=n.coef.map(function(t,e){var n=c*a[e];return[t-n,t+n]});return{se:a,t:l,p:u,sigmaHat:s,interval95:h}}return{ols:function(i,o){var r=t(i,o),s=n(r),a=function(t){var n,i,o,r=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:r,pvalue:1-(n=r,i=t.df_model,o=t.df_resid,e.beta.cdf(n/(o/i+n),i/2,o/2))}}(r),l=1-(1-r.R2)*((r.nobs-1)/r.df_resid);return r.t=s,r.f=a,r.adjust_R2=l,r}}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),n=0;n<arguments.length;n++){t[n]=[1].concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),n=0;n<arguments[0].length;n++){t[n]=[1].concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=new Array(t.length),i=0;i<t.length;i++)n[i]=t[i];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(t){return t.transpose()},matrixmult:function(t,n){var i,o,r,s,a;if(t.cols()==n.rows()){if(n.rows()>1){for(s=[],i=0;i<t.rows();i++)for(s[i]=[],o=0;o<n.cols();o++){for(a=0,r=0;r<t.cols();r++)a+=t.toArray()[i][r]*n.toArray()[r][o];s[i][o]=a}return e(s)}for(s=[],i=0;i<t.rows();i++)for(s[i]=[],o=0;o<n.cols();o++){for(a=0,r=0;r<t.cols();r++)a+=t.toArray()[i][r]*n.toArray()[o];s[i][o]=a}return e(s)}},regress:function(t,n){var i=e.xtranspxinv(t),o=t.transpose(),r=e.matrixmult(e(i),o);return e.matrixmult(r,n)},regresst:function(t,n,i){var o=e.regress(t,n),r={anova:{}},s=e.jMatYBar(t,o);r.yBar=s;var a=n.mean();r.anova.residuals=e.residuals(n,s),r.anova.ssr=e.ssr(s,a),r.anova.msr=r.anova.ssr/(t[0].length-1),r.anova.sse=e.sse(n,s),r.anova.mse=r.anova.sse/(n.length-(t[0].length-1)-1),r.anova.sst=e.sst(n,a),r.anova.mst=r.anova.sst/(n.length-1),r.anova.r2=1-r.anova.sse/r.anova.sst,r.anova.r2<0&&(r.anova.r2=0),r.anova.fratio=r.anova.msr/r.anova.mse,r.anova.pvalue=e.anovaftest(r.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),r.anova.rmse=Math.sqrt(r.anova.mse),r.anova.r2adj=1-r.anova.mse/r.anova.mst,r.anova.r2adj<0&&(r.anova.r2adj=0),r.stats=new Array(t[0].length);for(var l,u,c,h=e.xtranspxinv(t),d=0;d<o.length;d++)l=Math.sqrt(r.anova.mse*Math.abs(h[d][d])),u=Math.abs(o[d]/l),c=e.ttest(u,n.length-t[0].length-1,i),r.stats[d]=[o[d],l,u,c];return r.regress=o,r},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var i=e.matrixmult(t,n);return new e(i)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},sse:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e[i],2);return n},sst:function(t,e){for(var n=0,i=0;i<t.length;i++)n+=Math.pow(t[i]-e,2);return n},matrixsubtract:function(t,n){for(var i=new Array(t.length),o=0;o<t.length;o++){i[o]=new Array(t[o].length);for(var r=0;r<t[o].length;r++)i[o][r]=t[o][r]-n[o][r]}return e(i)}}),e.jStat=e,e)},4788(t,e,n){"use strict";var i=n(5072),o=n.n(i),r=n(7825),s=n.n(r),a=n(7659),l=n.n(a),u=n(5056),c=n.n(u),h=n(540),d=n.n(h),f=n(1113),m=n.n(f),p=n(365),g={};g.styleTagTransform=m(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=d(),o()(p.A,g),p.A&&p.A.locals&&p.A.locals},5072(t){"use strict";var e=[];function n(t){for(var n=-1,i=0;i<e.length;i++)if(e[i].identifier===t){n=i;break}return n}function i(t,i){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],u=i.base?l[0]+i.base:l[0],c=r[u]||0,h="".concat(u," ").concat(c);r[u]=c+1;var d=n(h),f={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==d)e[d].references++,e[d].updater(f);else{var m=o(f,i);i.byIndex=a,e.splice(a,0,{identifier:h,updater:m,references:1})}s.push(h)}return s}function o(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,o){var r=i(t=t||[],o=o||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=i(t,o),u=0;u<r.length;u++){var c=n(r[u]);0===e[c].references&&(e[c].updater(),e.splice(c,1))}r=l}}},7659(t){"use strict";var e={};t.exports=function(t,n){var i=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!i)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},540(t){"use strict";t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},5056(t,e,n){"use strict";t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},7825(t){"use strict";t.exports=function(t){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var i="";n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {"));var o=void 0!==n.layer;o&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,o&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(i,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},1113(t){"use strict";t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}},3743(t,e,n){"use strict";n.d(e,{i:()=>z,q:()=>Y});var i,o,r,s,a,l,u,c=n(7389),h=n(4328),d=n(6082),f=n(2003),m=n(8774);!function(t){t.Levenshtein="Levenshtein",t.JaroWinkler="Jaro-Winkler",t.Manhattan="Manhattan String",t.Onehot="One-Hot"}(i||(i={})),function(t){t.Euclidean="Euclidean",t.Manhattan="Manhattan",t.Cosine="Vector Cosine"}(o||(o={})),function(t){t.Tanimoto="Tanimoto",t.Dice="Dice",t.Asymmetric="Asymmetric",t.BraunBlanquet="Braun-Blanquet",t.Cosine="Cosine",t.Kulczynski="Kulczynski",t.McConnaughey="Mc-Connaughey",t.RogotGoldberg="Rogot-Goldberg",t.Russel="Russel",t.Sokal="Sokal",t.Hamming="Hamming",t.Euclidean="Euclidean BitArray"}(r||(r={})),function(t){t.TanimotoIntArray="TanimotoIntArray"}(s||(s={})),function(t){t.Vector="Vector",t.String="String",t.BitArray="BitArray",t.MacroMolecule="MacroMolecule",t.Number="Number",t.IntArray="IntArray",t.NumberArray="NumberArray"}(a||(a={})),function(t){t.Difference="Difference"}(l||(l={})),function(t){t.CommonItems="Common Items"}(u||(u={}));var p=n(1199);r.Tanimoto,r.Dice,r.Asymmetric,r.BraunBlanquet,r.Cosine,r.Kulczynski,r.McConnaughey,r.RogotGoldberg,r.Russel,r.Sokal,r.Hamming,r.Euclidean,r.Tanimoto,r.Dice,r.Asymmetric,r.BraunBlanquet,r.Cosine,r.Kulczynski,r.McConnaughey,r.RogotGoldberg,r.Russel,r.Sokal,r.Hamming,r.Euclidean,r.Tanimoto,r.Dice,r.Cosine,r.Tanimoto,r.Asymmetric,r.Cosine,r.Sokal,p.Z.HAMMING,p.Z.LEVENSHTEIN,p.Z.MONOMER_CHEMICAL_DISTANCE,p.Z.NEEDLEMANN_WUNSCH,n(854),new RegExp("[rd]\\((\\w)\\)p?","g");var g,v=n(3077),C=n(439),y=n(4971);async function b(t,e,n,i,o){const r=(0,v.R)(e,o),s=o.getSeqHandler(e).getNewColumnFromList("ref",[n]),a=o.getSeqHandler(s).getSplitted(0),l=i===g.IDENTITY?function(t,e){const n=e.columns.length,i=new Array(n),o=new Array(n),r=new Array(n);for(let s=0;s<n;++s){const n=e.columns.byIndex(s);i[s]=n.getRawData(),o[s]=n.categories.indexOf("");const a=s<t.length?t.getOriginal(s):"";r[s]=n.categories.indexOf(a)}const s=d.Column.float("Identity",e.rowCount),a=s.getRawData();for(let n=0;n<e.rowCount;++n){a[n]=0;for(let e=0;e<t.length;++e)(i[e]?i[e][n]:0)===r[e]&&++a[n];a[n]/=t.length}return s}(a,r):i===g.SIMILARITY?await async function(t,e,n){const i=e.columns.toList(),o=await async function(t,e,n){t instanceof d.Column&&(t=(0,v.R)(t,n).columns.toList());const i=(await(0,y.pj)()).getMonomerLib(),o=new Array(t.length),r=t[0].length,s=new Float32Array(r);for(let n=0;n<t.length;++n){const a=n<e.length?e.getCanonical(n):"",l=i.getMonomer("PEPTIDE",a)?.smiles??"",u=t[n],c=u.getRawData(),f=u.categories,m=f.indexOf("");if(o[n]={categories:f,data:c,emptyIndex:m},void 0===a)continue;const p=d.Column.fromStrings("smiles",f.map(t=>i.getMonomer("PEPTIDE",t)?.smiles??"")),g=(d.DataFrame.fromColumns([p]),await h.chem.getSimilarities(p,l)),v=g?g.getRawData():null;for(let t=0;t<r;++t){const e=c[t];""!==a&&e!==m?s[t]+=v[e]:""===a&&e===m&&(s[t]+=1)}}for(let n=0;n<s.length;++n){let i=s[n]/e.length;for(let r=0;r<t.length;++r){const t=o[r];if(r>=e.length&&t.data[n]!==t.emptyIndex||t.data[n]===t.emptyIndex&&r<e.length){i=d.FLOAT_NULL;break}}s[n]=i}return d.Column.fromFloat32Array("Similarity",s)}(i,t,n);return o}(a,r,o):null;if(null==l)throw new Error(`In bio library: Unknown sequence scoring method: ${i}`);return l.name=t.columns.getUnusedName(l.name),t.columns.add(l),l}!function(t){t.IDENTITY="identity",t.SIMILARITY="similarity"}(g||(g={}));var _,w=n(144),A=n.n(w),S=n(7233),T=n.n(S),E=n(4139),N=n(115),x=n(8608),M=n(3541),I=n(3163),O=n(7923),P=n(7654),L=n(5480),R=n(5429),k=n(3262),F=n(1458),V=n(4025);!function(t){t.UMAP="UMAP",t.T_SNE="t-SNE"}(_||(_={}));n(5540);var D,G,B,U,q,H,$=n(4329);!function(t){t.EUCLIDEAN="EUCLIDEAN",t.MANHATTAN="MANHATTAN"}(D||(D={})),D.EUCLIDEAN,D.MANHATTAN,function(t){t.HAMMING="Hamming",t.EUCLIDEAN="Euclidean",t.VECTOR_COSINE="Vector Cosine",t.MANHATTAN="Manhattan",t.TANIMOTO="Tanimoto",t.LEVENSTEIN="Levenshtein",t.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",t.SOKAL="Sokal",t.COSINE="Cosine",t.ASYMMETRIC="Asymmetric",t.Difference="Difference",t.OneHot="One-Hot"}(G||(G={})),G.HAMMING,G.EUCLIDEAN,G.MANHATTAN,G.VECTOR_COSINE,G.TANIMOTO,G.LEVENSTEIN,G.NEEDLEMAN_WUNSCH,G.MONOMER_CHEMICAL_DISTANCE,G.SOKAL,G.COSINE,G.ASYMMETRIC,G.Difference,G.OneHot,G.HAMMING,G.EUCLIDEAN,G.MANHATTAN,G.TANIMOTO,G.SOKAL,G.COSINE,G.ASYMMETRIC,G.LEVENSTEIN,G.NEEDLEMAN_WUNSCH,G.MONOMER_CHEMICAL_DISTANCE,G.Difference,G.OneHot,G.VECTOR_COSINE,new Set([G.HAMMING,G.LEVENSTEIN,G.NEEDLEMAN_WUNSCH,G.MONOMER_CHEMICAL_DISTANCE,G.OneHot]),new Set([G.HAMMING,G.EUCLIDEAN,G.MANHATTAN,G.MONOMER_CHEMICAL_DISTANCE,G.LEVENSTEIN,G.NEEDLEMAN_WUNSCH,G.TANIMOTO,G.COSINE,G.VECTOR_COSINE,G.SOKAL,G.ASYMMETRIC,G.OneHot,G.Difference]),new Set([G.EUCLIDEAN,G.MANHATTAN,G.OneHot,G.Difference,G.VECTOR_COSINE]),new Set([G.EUCLIDEAN,G.MANHATTAN,G.Difference,G.VECTOR_COSINE]),new Set([G.EUCLIDEAN,G.MANHATTAN,G.Difference]),new Set([G.TANIMOTO,G.COSINE,G.SOKAL,G.ASYMMETRIC]),function(t){t.ADD="ADD",t.SUB="SUB",t.MULT="MULT"}(B||(B={})),function(t){t.SQUARE="SQUARE",t.INVERSE="INVERSE",t.TRANSPOSE="TRANSPOSE",t.NORM="NORM",t.COLUMN_NORM="COLUMN_NORM"}(U||(U={})),function(t){t.SCALARMULT="SCALARMULT",t.SCALARADD="SCALARADD",t.SCALARPOW="SCALARPOW"}(q||(q={})),Object.prototype.toString,function(t){t.EUCLIDEAN="EUCLIDEAN",t.MANHATTAN="MANHATTAN"}(H||(H={}));var Y,j=n(726),W=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};!function(t){t.SEQUENCE_VARIABILITY_MAP="Sequence Variability Map",t.MOST_POTENT_RESIDUES="Most Potent Residues",t.LOGO_SUMMARY_TABLE="Logo Summary Table",t.DENDROGRAM="Dendrogram",t.CLUSTER_MAX_ACTIVITY="Active peptide selection",t.MCL="MCL",t.SEQUENCE_MUTATION_CLIFFS="Sequence Mutation Cliffs"}(Y||(Y={}));class z{constructor(t){this.isBitsetChangedInitialized=!1,this.isUserChangedSelection=!0,this._dm=null,this.isInitialized=!1,this.isRibbonSet=!1,this.webLogoSelectedMonomers={},this.webLogoBounds={},this.cachedWebLogoTooltip={bar:"",tooltip:null},this._layoutEventInitialized=!1,this.subs=[],this.isHighlighting=!1,this.controlFire=!1,this.accordionSource=null,this._sequenceSpaceViewer=null,this._mclViewer=null,this._monomerPositionStats=null,this._settings=null,this._sequenceSpaceCols=[],this._mclCols=[],this._webLogoSelection=null,this.df=t}get monomerPositionStats(){var t;if(null!==this._monomerPositionStats)return this._monomerPositionStats;const e=this.getScaledActivityColumn();return null===this.positionColumns||null===e?null:(null!==(t=this._monomerPositionStats)&&void 0!==t||(this._monomerPositionStats=(0,F.Ej)(e,this.df.filter,this.positionColumns)),this._monomerPositionStats)}get analysisView(){var t,e,n;return void 0===this._analysisView&&(this._analysisView=this.id?A()(h.shell.tableViews).find(({dataFrame:t})=>(null==t?void 0:t.getTag(d.TAGS.ID))===this.id):void 0,!this._analysisView&&(null===(t=h.shell.v)||void 0===t?void 0:t.preview)instanceof d.TableView&&(null===(n=null===(e=h.shell.v)||void 0===e?void 0:e.preview)||void 0===n?void 0:n.dataFrame)===this.df&&(this._analysisView=h.shell.v.preview),this._analysisView||(this._analysisView=h.shell.addTableView(this.df))),"1"===this.df.getTag(E.gp.MULTIPLE_VIEWS)||this._layoutEventInitialized||(0,x.Lv)()||(h.shell.v=this._analysisView),this._analysisView.grid.invalidate(),this._analysisView}get settings(){var t,e;const n=this.df.getTag(E.gp.SETTINGS);return n?(null!==(t=this._settings)&&void 0!==t||(this._settings=JSON.parse(n)),!(null===(e=this._settings)||void 0===e?void 0:e.mclSettings)||this._settings.mclSettings.webGPUDescriptionPromise instanceof Promise||(this._settings.mclSettings.webGPUDescriptionPromise=(0,$._)()),this._settings):null}set settings(t){var e,n,i;const o=Object.entries(t),r=Object.assign({},null!==(n=null===(e=this.settings)||void 0===e?void 0:e.sequenceSpaceParams)&&void 0!==n?n:{}),s=new Set;for(const[t,e]of o)switch(this.settings[t]=e,t){case"activityColumnName":case"activityScaling":s.add("activity"),s.add("stats");break;case"showDendrogram":s.add("dendrogram");break;case"showClusterMaxActivity":s.add("clusterMaxActivity");break;case"showSequenceSpace":case"sequenceSpaceParams":s.add("sequenceSpaceParams");break;case"showLogoSummaryTable":s.add("logoSummaryTable");break;case"showMonomerPosition":s.add("monomerPosition");break;case"showMostPotentResidues":s.add("mostPotentResidues");break;case"columns":s.add("columns");break;case"mclSettings":s.add("mclSettings")}if(this.df.setTag("settings",JSON.stringify(this._settings)),this.isInitialized){if(s.has("sequenceSpaceParams")){const t=this.settings.sequenceSpaceParams;Object.entries(t).some(([t,e])=>r[t]!==e&&"epsilon"!==t&&"minPts"!==t&&"clusterEmbeddings"!==t)||(s.delete("sequenceSpaceParams"),this.settings.sequenceSpaceParams.clusterEmbeddings&&s.add("clusterParams"))}s.has("sequenceSpaceParams")&&s.delete("clusterParams");for(const t of s)switch(t){case"activity":this.createScaledCol();break;case"stats":this.webLogoSelection=(0,x.ZR)(this.positionColumns),this.webLogoBounds={},this.cachedWebLogoTooltip={bar:"",tooltip:null},this._monomerPositionStats=null;break;case"dendrogram":this.settings.showDendrogram?this.addDendrogram():this.closeViewer(Y.DENDROGRAM);break;case"clusterMaxActivity":this.settings.showClusterMaxActivity?this.addClusterMaxActivityViewer():this.closeViewer(Y.CLUSTER_MAX_ACTIVITY);break;case"logoSummaryTable":this.settings.showLogoSummaryTable?this.addLogoSummaryTable():this.closeViewer(Y.LOGO_SUMMARY_TABLE);break;case"monomerPosition":this.settings.showMonomerPosition?this.addMonomerPosition():this.closeViewer(Y.SEQUENCE_VARIABILITY_MAP);break;case"mostPotentResidues":this.settings.showMostPotentResidues?this.addMostPotentResidues():this.closeViewer(Y.MOST_POTENT_RESIDUES);break;case"columns":const t=this.findViewer(Y.LOGO_SUMMARY_TABLE);t._viewerGrid=null,t._logoSummaryTable=null,t.render();const e=this.findViewer(Y.MOST_POTENT_RESIDUES);e._viewerGrid=null,e.render();break;case"sequenceSpaceParams":this.settings.showSequenceSpace&&this.addSequenceSpace({clusterEmbeddings:null===(i=this.settings.sequenceSpaceParams)||void 0===i?void 0:i.clusterEmbeddings});break;case"clusterParams":this.clusterEmbeddings();break;case"mclSettings":this.addMCLClusters()}}}get webLogoSelection(){var t,e;return null!==(t=this._webLogoSelection)&&void 0!==t||(this._webLogoSelection=(0,x.ZR)(null!==(e=this.positionColumns)&&void 0!==e?e:[])),this._webLogoSelection}set webLogoSelection(t){this._webLogoSelection=t,this.fireBitsetChanged(null),this.analysisView.grid.invalidate()}get positionColumns(){const t=A()(this.df.columns.byTags({[E.gp.POSITION_COL]:"true"})).toArray();return 0===t.length?null:t}get id(){return this.df.getTag(d.TAGS.ID)}get alphabet(){return this.df.getCol(this.settings.sequenceColumnName).getTag(f.gp.alphabet)}static getInstance(t){if(t.columns.contains(E.$2.ACTIVITY_SCALED)&&!t.columns.contains(E.$2.ACTIVITY)&&(t.getCol(E.$2.ACTIVITY_SCALED).name=E.$2.ACTIVITY),!t.temp[z.modelName]){const e=t.temp[z.modelName]=new z(t),n=e.settings;n&&e.init(n);let i=!0;e.subs.push(d.debounce(t.onSelectionChanged,10).subscribe(n=>{var o,r,s;if(i||t.selection.anyTrue||!e._analysisView||!document.contains(e._analysisView.root)||e._analysisView.dataFrame!==t)return void(i=!(null===(o=null==t?void 0:t.selection)||void 0===o?void 0:o.anyTrue));e.positionColumns&&(e.webLogoSelection=(0,x.ZR)(e.positionColumns));const a=e.findViewer(Y.SEQUENCE_VARIABILITY_MAP);if(null!=a){const t=null!==(r=e.positionColumns)&&void 0!==r?r:a.positionColumns;t&&(a.invariantMapSelection=(0,x.ZR)(t),a.mutationCliffsSelection=(0,x.ZR)(t))}const l=e.findViewer(Y.MOST_POTENT_RESIDUES);if(null!=l){const t=null!==(s=e.positionColumns)&&void 0!==s?s:l.positionColumns;t&&(l.mutationCliffsSelection=(0,x.ZR)(t),l.invariantMapSelection=(0,x.ZR)(t))}const u=e.findViewer(Y.LOGO_SUMMARY_TABLE);null!=u&&(u.initClusterSelection({notify:!0}),u.render()),i=!0}))}return t.temp[z.modelName]}modifyWebLogoSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.webLogoSelection=(0,x.vW)(this.webLogoSelection,t,e):this._webLogoSelection=(0,x.vW)(this.webLogoSelection,t,e)}getVisibleSelection(){return this.df.selection.clone().and(this.df.filter)}createAccordion(){var t,e,n,i,o,r,s,a,l;const u=null===(t=this.df)||void 0===t?void 0:t.temp[z.modelName];if(!u)return null;const h=c.accordion("Peptides analysis panel");h.root.style.width="100%";const m=u.getVisibleSelection(),p=u.df.filter.anyFalse?` among ${u.df.filter.trueCount} filtered`:"",g=t=>{const e=[];for(const[n,i]of Object.entries(t))for(const t of i)e.push(`${n}:${t}`);return e.join(", ")},v=u.findViewer(Y.LOGO_SUMMARY_TABLE),C=[],y=(null===v?[]:(null!==(n=null===(e=v.clusterSelection)||void 0===e?void 0:e[L.W.ORIGINAL])&&void 0!==n?n:[]).concat(null!==(o=null===(i=v.clusterSelection)||void 0===i?void 0:i[L.W.CUSTOM])&&void 0!==o?o:[])).join(", "),b=t=>{const e=c.divText(t);return e.innerHTML=t,e};0!==y.length&&C.push(b(`<b>Logo Summary Table</b> clusters: ${y}`));const _=u.findViewer(Y.SEQUENCE_VARIABILITY_MAP),w=g(null!==(r=null==_?void 0:_.invariantMapSelection)&&void 0!==r?r:{}),A=g(null!==(s=null==_?void 0:_.mutationCliffsSelection)&&void 0!==s?s:{});0!==w.length&&C.push(b(`<b>Invariant map</b>: ${w}`)),0!==A.length&&C.push(b(`<b>Mutation cliffs</b>: ${A}`));const S=u.findViewer(Y.MOST_POTENT_RESIDUES),T=g(null!==(a=null==S?void 0:S.invariantMapSelection)&&void 0!==a?a:{});0!==T.length&&C.push(b(`<b>Most potent residues</b>: ${T}`));const E=g(u.webLogoSelection);0!==E.length&&C.push(b(`<b>WebLogo</b>: ${E}`)),0!==C.length&&C.unshift(c.h1("Selection Sources"));const N=c.div(c.divV(C));h.addTitle(c.divV([c.h1(`${m.trueCount} selected rows${p}`),N],"css-gap-small"));let R=u.settings;const k=[_,S,v].filter(t=>null!==t&&(t.type!==this.accordionSource||(R=t,!1)));if(null===R)throw new Error("PeptidesError: Model is the source of accordion but is not initialized");R!==u.settings&&k.push(u.settings),k.filter(t=>null!==t&&(0,x.$s)(R,t)&&(t!==u.settings||u.isInitialized)).push(R);const D=R;R===u.settings||D instanceof L.s||null==D.mutationCliffs||h.addPane("Mutation Cliffs pairs",()=>(0,O.F)(u.df,{mutationCliffs:D.mutationCliffs,mutationCliffsSelection:D.mutationCliffsSelection,gridColumns:u.analysisView.grid.columns,sequenceColumnName:D.sequenceColumnName,positionColumns:D.positionColumns,activityCol:D.getScaledActivityColumn(),mutationCliffStats:D.cliffStats}).root,!0);const G=R===u.settings,B=G?this.webLogoSelection:R instanceof M.J?R.invariantMapSelection:{},U=R instanceof L.s?R.clusterSelection:null!==(l=null==v?void 0:v.clusterSelection)&&void 0!==l?l:{};h.addPane("Distribution",()=>{var t;try{return(0,P.HV)(u.df,{columns:G?null!==(t=u.settings.columns)&&void 0!==t?t:{}:R.getAggregationColumns(),activityCol:G?u.getScaledActivityColumn():R.getScaledActivityColumn(),monomerPositionSelection:B,clusterSelection:U,clusterColName:null==v?void 0:v.clustersColumnName})}catch(t){const e=c.divText("Error in Distribution");return c.tooltip.bind(e,String(t)),e}},!0);const q=(t,e)=>{if(null==t||null==e)return!1;for(const[n,i]of Object.entries(t))if(i!==e[n])return!1;return!0};return h.addPane("Selection",()=>{var t;try{return function(t,e){var n,i,o;if(0===e.tableSelection.trueCount)return c.divText("No compounds selected");const r=d.DataFrame.create(t.rowCount);r.name="Selected compounds",r.filter.copyFrom(e.tableSelection);let s=null;for(let t=1;t<e.gridColumns.length;t++){const o=e.gridColumns.byIndex(t);if(!o.visible)continue;const a=o.column;if(a.type===d.COLUMN_TYPE.BOOL)continue;null===s&&o.grid&&(null===(n=o.grid.sortByColumns)||void 0===n?void 0:n.length)>0&&(null===(i=o.grid.sortTypes)||void 0===i?void 0:i.length)===o.grid.sortByColumns.length&&(s={cols:o.grid.sortByColumns,types:o.grid.sortTypes});let l=null,u=null;try{l=a.getRawData(),u=a.categories}catch(t){}const c=l&&u?a.isNumerical?t=>l[t]:t=>u[l[t]]:t=>a.get(t),h=t=>a.isNone(t)?null:c(t),f=a.name===e.activityColumn.name?r.columns.addNewFloat(o.name).init(t=>h(t)):r.columns.addNewVirtual(o.name,t=>h(t),a.type);for(const[t,e]of a.tags)f.setTag(t,e)}const a=r.plot.grid();a.props.showRowHeader=!1,a.root.style.maxWidth="100%",d.debounce(c.onSizeChanged(a.root),50).subscribe(t=>{var e;const n=a.root.parentElement;(null===(e=null==n?void 0:n.parentElement)||void 0===e?void 0:e.classList.contains("panel-content"))&&(a.root.style.height="calc(100% - 20px)",a.root.style.width="calc(100% - 20px)",a.root.style.position="absolute",a.root.style.right="10px",a.root.style.top="10px")}),(0,x.zz)(a);const l=c.box(a.root);l.style.marginLeft="0px",setTimeout(()=>{null!==s&&a.sort(s.cols,s.types);for(let t=1;t<e.gridColumns.length;t++){const n=e.gridColumns.byIndex(t);n.visible&&a.col(n.name)&&(a.col(n.name).width=n.width)}},500);const u=(0,F.Ej)(e.activityColumn,r.filter,e.positionColumns,{isFiltered:!0}),h={isSelectionTable:!0,cachedWebLogoTooltip:()=>({bar:"",tooltip:null}),webLogoBounds:()=>({}),colorPalette:()=>e.colorPalette},f={x:0,y:0,monomerPosition:{},mpStats:u};return e.isAnalysis&&(0,I.FZ)(a,u,e.positionColumns,e.activityColumn,h,f),(null!==(o=t.columns.bySemTypeAll(d.SEMTYPE.MACROMOLECULE))&&void 0!==o?o:[]).forEach(t=>{r.col(t.name)&&(r.col(t.name).temp[V.j.notationProvider]=t.temp[V.j.notationProvider])}),l}(u.df,{positionColumns:G?u.positionColumns:R.positionColumns,columns:G?null!==(t=u.settings.columns)&&void 0!==t?t:{}:R.getAggregationColumns(),activityColumn:G?u.getScaledActivityColumn():R.getScaledActivityColumn(),gridColumns:u.analysisView.grid.columns,colorPalette:(0,f.SM)(u.df.getCol(G?u.settings.sequenceColumnName:R.sequenceColumnName),j.Z.getSeqHelper()),tableSelection:u.getCombinedSelection(),isAnalysis:null!==u.settings&&(G||q(u.settings.columns,R.getAggregationColumns()))})}catch(t){const e=c.divText("Error in Selection");return c.tooltip.bind(e,String(t)),e}},!0),h}getScaledActivityColumn(t=!1){const e=this.df.col(E.$2.ACTIVITY);return t&&null!==e?d.DataFrame.fromColumns([e]).clone(this.df.filter).getCol(e.name):e}updateGrid(){this.joinDataFrames(),this.createScaledCol(),this.webLogoBounds={};const t={selectionCallback:(t,e)=>this.modifyWebLogoSelection(t,e),unhighlightCallback:()=>this.unhighlight(),colorPalette:()=>(0,f.SM)(this.df.getCol(this.settings.sequenceColumnName),j.Z.getSeqHelper()),webLogoBounds:()=>this.webLogoBounds,cachedWebLogoTooltip:()=>this.cachedWebLogoTooltip,highlightCallback:(t,e,n)=>{(0,x.dl)(t,e,n),this.isHighlighting=!0},isSelectionTable:!1,headerSelectedMonomers:()=>this.webLogoSelectedMonomers};if(null===this.monomerPositionStats||null===this.positionColumns)throw new Error("PeptidesError: Could not updage grid: monomerPositionStats or positionColumns are null");I.FZ(this.analysisView.grid,this.monomerPositionStats,this.positionColumns,this.getScaledActivityColumn(),t),this._layoutEventInitialized||(h.events.onViewLayoutApplied.subscribe(t=>{t.view.id===this.analysisView.id&&this.updateGrid()}),this._layoutEventInitialized=!0),this.setTooltips(),this.setBitsetCallback(),this.setGridProperties()}joinDataFrames(){const t=this.df.name,e=this.df.columns,n=(0,v.R)(this.df.getCol(this.settings.sequenceColumnName),j.Z.getSeqHelper()),i=n.columns.names();if(i.every(t=>e.contains(t)))i.forEach(t=>{const e=this.df.col(t);e.setTag(E.gp.ANALYSIS_COL,"true"),e.setTag(E.gp.POSITION_COL,"true");const i=n.getCol(t).getTag(C.jz);i&&e.setTag(C.jz,i),I.rI(e,this.alphabet)});else for(const t of i){let i=this.df.col(t);const o=n.getCol(t);null!==i&&e.remove(t);const r=o.categories,s=o.getRawData();i=e.addNew(o.name,o.type).init(t=>r[s[t]]),i.setTag(E.gp.ANALYSIS_COL,"true"),i.setTag(E.gp.POSITION_COL,"true");const a=o.getTag(C.jz);a&&i.setTag(C.jz,a),I.rI(i,this.alphabet)}this.df.name=t}createScaledCol(){const t=this.analysisView.grid,e=(0,x.Y1)(this.df.getCol(this.settings.activityColumnName),this.settings.activityScaling);this.df.columns.replace(E.$2.ACTIVITY,e),t.columns.setOrder([e.name])}unhighlight(){this.isHighlighting&&(this.df.rows.highlight(null),this.isHighlighting=!1)}setTooltips(){this.analysisView.grid.onCellTooltip((t,e,n)=>{var i,o;return!(!t.isColHeader||(null===(i=t.tableColumn)||void 0===i?void 0:i.semType)!==E.uF.MONOMER)||!(!t.isTableCell||(null===(o=t.tableColumn)||void 0===o?void 0:o.semType)!==E.uF.MONOMER)})}getCombinedSelection(){var t,e,n,i,o,r,s,a;const l=new m.A(this.df.rowCount,!1),u=(t,e)=>{for(const[n,i]of Object.entries(t))for(const t of i){const i=null==e?void 0:e[n];if(void 0===i)continue;const o=i[t];void 0!==o&&l.or(o.mask)}};u(this.webLogoSelection,this.monomerPositionStats);const c=this.findViewer(Y.SEQUENCE_VARIABILITY_MAP);u(null!==(t=null==c?void 0:c.invariantMapSelection)&&void 0!==t?t:{},null!==(e=null==c?void 0:c.monomerPositionStats)&&void 0!==e?e:null),((t,e)=>{var n,i;for(const[o,r]of Object.entries(t))for(const t of r){const r=null!==(i=null===(n=null==e?void 0:e.get(t))||void 0===n?void 0:n.get(o))&&void 0!==i?i:null;if(null!==r)for(const[t,e]of r.entries()){l.setTrue(t);for(const t of e)l.setTrue(t)}}})(null!==(n=null==c?void 0:c.mutationCliffsSelection)&&void 0!==n?n:{},null!==(i=null==c?void 0:c.mutationCliffs)&&void 0!==i?i:null);const h=this.findViewer(Y.MOST_POTENT_RESIDUES);u(null!==(o=null==h?void 0:h.invariantMapSelection)&&void 0!==o?o:{},null!==(r=null==h?void 0:h.monomerPositionStats)&&void 0!==r?r:null);const f=this.findViewer(Y.LOGO_SUMMARY_TABLE);for(const t of Object.keys(null!==(s=null==f?void 0:f.clusterSelection)&&void 0!==s?s:{}))for(const e of null!==(a=f.clusterSelection[t])&&void 0!==a?a:[]){const n=f.clusterStats[t][e];l.or(n.mask)}const p=d.BitSet.fromBytes(l.buffer.buffer,l.length);return this.df.filter.anyFalse?p.and(this.df.filter):p}setBitsetCallback(){if(this.isBitsetChangedInitialized)return;const t=this.df.selection,e=this.df.filter;let n=null;const i=()=>{try{null!=n&&(clearTimeout(n),n=null);const t=this.createAccordion();if(null===t)return;h.shell.o=t.root,n=setTimeout(()=>{h.shell.o!=t.root&&(h.shell.o=t.root)},1500)}catch(t){console.error(t)}};t.onChanged.subscribe(()=>{if(this.controlFire)this.controlFire=!1;else try{this.isUserChangedSelection||t.copyFrom(this.getCombinedSelection(),!1)}catch(t){k._package.logger.debug("Peptides: Error on selection changed"),k._package.logger.debug(t)}finally{i()}}),e.onChanged.subscribe(()=>{var t,e;try{if(this.controlFire)return void(this.controlFire=!1);const n=this.findViewer(Y.LOGO_SUMMARY_TABLE);null!==n&&void 0!==n.model&&(n._logoSummaryTable=null!==(t=n.createLogoSummaryTable())&&void 0!==t?t:n._logoSummaryTable,n._viewerGrid=null!==(e=n.createLogoSummaryTableGrid())&&void 0!==e?e:n._viewerGrid,n.render())}catch(t){k._package.logger.debug("Peptides: Error on filter changed"),k._package.logger.debug(t)}finally{i()}}),this.isBitsetChangedInitialized=!0}fireBitsetChanged(t,e=!1){this.accordionSource=t,this.isBitsetChangedInitialized||this.setBitsetCallback(),this.isUserChangedSelection=!1,this.df.selection.fireChanged(),e&&this.df.filter.fireChanged(),this.controlFire=!0,this.df.selection.fireChanged(),e&&this.df.filter.fireChanged(),this.isUserChangedSelection=!0,this.webLogoSelectedMonomers=(0,x.qx)(this.df)}setGridProperties(t){var e,n,i,o;const r=this.analysisView.grid,s=r.props;s.allowColSelection=null!==(e=null==t?void 0:t.allowColSelection)&&void 0!==e&&e,s.allowEdit=null!==(n=null==t?void 0:t.allowEdit)&&void 0!==n&&n,s.showReadOnlyNotifications=null!==(i=null==t?void 0:t.showReadOnlyNotifications)&&void 0!==i&&i,s.showCurrentRowIndicator=null!==(o=null==t?void 0:t.showCurrentRowIndicator)&&void 0!==o&&o;const a=this.positionColumns;if(null===a)throw new Error("PeptidesError: Could not set grid properties: positionColumns are null");let l=10;const u=r.canvas.getContext("2d");if(null===u)throw new Error("PeptidesError: Could not set grid properties: canvas context is null");for(const t of a){const e=(0,f.zS)(t.categories.reduce((t,e)=>t.length>e.length?t:e),6),n=Math.ceil(u.measureText(e).width);l=Math.max(l,n)}const c=a.map(t=>t.name);for(let t=1;t<this.analysisView.grid.columns.length;++t){const e=this.analysisView.grid.columns.byIndex(t);if(null===e)throw new Error(`PeptidesError: Could not get analysis view: grid column with index '${t}' is null`);if(null===e.column)throw new Error(`PeptidesError: Could not get analysis view: grid column with index '${t}' has null column`);e.visible=c.includes(e.column.name)||e.column.name===E.$2.ACTIVITY}setTimeout(()=>{for(const t of a){const e=r.col(t.name);if(null===e)throw new Error(`PeptidesError: Could not set column width: grid column '${t.name}' is null`);e.width=l+15}},100)}closeViewer(t){const e=this.findViewer(t);null==e||e.detach(),null==e||e.close()}findViewerNode(t){for(const e of this.analysisView.dockManager.rootNode.children)if(e.container.containerElement.innerHTML.includes(t))return e;return null}addDendrogram(){return W(this,void 0,void 0,function*(){const t=d.TaskBarProgressIndicator.create("Calculating distance matrix...");try{const t=d.Func.find({package:"Dendrogram",name:"hierarchicalClustering"})[0];if(!t||4!==t.inputs.length)throw new Error("Correct dendrogram function is not found");yield t.apply({df:this.df,colNameList:[this.settings.sequenceColumnName],distance:"euclidean",linkage:"complete"})}catch(t){k._package.logger.error(t)}finally{t.close()}})}init(t){if(!this.isInitialized){if(this.settings=t,this.isInitialized=!0,!this.isRibbonSet&&"1"!==this.df.getTag(E.gp.MULTIPLE_VIEWS)){const t=c.iconFA("wrench",()=>(0,R.OH)(this),"Peptides analysis settings");this.analysisView.setRibbonPanels([[t]],!1),this.isRibbonSet=!0,this.updateGrid()}this.subs.push(h.events.onAccordionConstructed.subscribe(t=>{if(!(h.shell.o instanceof d.SemanticValue||h.shell.o instanceof d.Column&&this.df.columns.toList().includes(h.shell.o)))return;const e=t.getPane("Actions"),n=T()(e.root).find(".d4-flex-col"),i=c.label("Calculate identity");i.classList.add("d4-link-action"),c.tooltip.bind(i,"Adds a column with fractions of matching monomers against sequence in the current row"),i.onclick=()=>{const t=this.df.getCol(this.settings.sequenceColumnName);b(this.df,t,t.get(this.df.currentRowIdx),g.IDENTITY,j.Z.getSeqHelper()).then(e=>e.setTag(E.gp.IDENTITY_TEMPLATE,t.get(this.df.currentRowIdx))).catch(t=>k._package.logger.debug(t))},n.append(c.span([i],"d4-markdown-row"));const o=c.label("Calculate similarity");o.classList.add("d4-link-action"),c.tooltip.bind(o,"Adds a column with sequence similarity scores against sequence in the current row"),o.onclick=()=>{const t=this.df.getCol(this.settings.sequenceColumnName);b(this.df,t,t.get(this.df.currentRowIdx),g.SIMILARITY,j.Z.getSeqHelper()).then(e=>e.setTag(E.gp.SIMILARITY_TEMPLATE,t.get(this.df.currentRowIdx))).catch(t=>k._package.logger.debug(t))},n.append(c.span([o],"d4-markdown-row"))})),this.subs.push(h.events.onViewRemoved.subscribe(t=>{t.id===this.analysisView.id&&this.subs.forEach(t=>t.unsubscribe()),h.log.debug(`Peptides: view ${t.name} removed`)})),this.subs.push(h.events.onTableRemoved.subscribe(t=>{t.id===this.df.id&&this.subs.forEach(t=>t.unsubscribe()),h.log.debug(`Peptides: table ${t.name} removed`)})),this.subs.push(h.events.onProjectClosed.subscribe(t=>{t.id===h.shell.project.id&&this.subs.forEach(t=>t.unsubscribe()),h.log.debug(`Peptides: project ${t.name} closed`)})),this.fireBitsetChanged(null,!0),this.analysisView.grid.invalidate()}}findViewer(t){return A()(this.analysisView.viewers).find(e=>e.type===t)||null}addLogoSummaryTable(t){return W(this,void 0,void 0,function*(){null!=t||(t={sequenceColumnName:this.settings.sequenceColumnName,clustersColumnName:A()(this.df.columns.categorical).next().value,activityColumnName:this.settings.activityColumnName,activityScaling:this.settings.activityScaling});const e=yield this.df.plot.fromType(Y.LOGO_SUMMARY_TABLE,t);(0,x.Lv)()&&this.analysisView.addViewer(e),this.analysisView.dockManager.dock(e,d.DOCK_TYPE.RIGHT,null,Y.LOGO_SUMMARY_TABLE),e.viewerGrid.invalidate()})}addClusterMaxActivityViewer(t){return W(this,void 0,void 0,function*(){var e,n,i,o,r,s,a,l,u;const c=null!==(o=null!==(n=null===(e=this._mclCols)||void 0===e?void 0:e.find(t=>t.toLowerCase().startsWith("cluster (mcl)")))&&void 0!==n?n:null===(i=this.findViewer(Y.LOGO_SUMMARY_TABLE))||void 0===i?void 0:i.clustersColumnName)&&void 0!==o?o:null===(r=this._sequenceSpaceCols)||void 0===r?void 0:r.find(t=>t.toLowerCase().startsWith("cluster"));null!=t||(t={activityColumnName:this.settings.activityColumnName,clusterColumnName:null!=c?c:null===(s=A()(this.df.columns.categorical).next().value)||void 0===s?void 0:s.name,activityTarget:E.wf.HIGH,connectivityColumnName:null!==(l=null!==(a=this._mclCols.find(t=>t.toLowerCase().startsWith("connectivity")))&&void 0!==a?a:this.df.columns.names().find(t=>{var e;return t.toLowerCase().includes("connectivity")&&(null===(e=this.df.col(t))||void 0===e?void 0:e.isNumerical)}))&&void 0!==l?l:"",clusterSizeThreshold:20,activityThreshold:1e3});const h=yield this.df.plot.fromType(Y.CLUSTER_MAX_ACTIVITY,t),f=null!==(u=this.findViewerNode(Y.LOGO_SUMMARY_TABLE))&&void 0!==u?u:null;this.analysisView.dockManager.dock(h,f?d.DOCK_TYPE.DOWN:d.DOCK_TYPE.RIGHT,f,Y.CLUSTER_MAX_ACTIVITY)})}addMonomerPosition(t){return W(this,void 0,void 0,function*(){null!=t||(t={maxMutations:1,activityScaling:this.settings.activityScaling,activityColumnName:this.settings.activityColumnName,sequenceColumnName:this.settings.sequenceColumnName,minActivityDelta:0,activityTarget:E.wf.HIGH});const e=yield this.df.plot.fromType(Y.SEQUENCE_VARIABILITY_MAP,t);(0,x.Lv)()&&this.analysisView.addViewer(e);const n=this.findViewer(Y.MOST_POTENT_RESIDUES),i=this.analysisView.dockManager,[o,r,s]=null===n?[d.DOCK_TYPE.DOWN,null,void 0]:[d.DOCK_TYPE.LEFT,this.findViewerNode(Y.MOST_POTENT_RESIDUES),.7];i.dock(e,o,r,Y.SEQUENCE_VARIABILITY_MAP,s)})}addMostPotentResidues(t){return W(this,void 0,void 0,function*(){null!=t||(t={activityScaling:this.settings.activityScaling,activityColumnName:this.settings.activityColumnName,sequenceColumnName:this.settings.sequenceColumnName,minActivityDelta:0,maxMutations:1,activityTarget:E.wf.HIGH});const e=yield this.df.plot.fromType(Y.MOST_POTENT_RESIDUES,t);(0,x.Lv)()&&this.analysisView.addViewer(e);const n=this.findViewer(Y.SEQUENCE_VARIABILITY_MAP),i=this.analysisView.dockManager,[o,r,s]=null===n?[d.DOCK_TYPE.DOWN,null,void 0]:[d.DOCK_TYPE.RIGHT,this.findViewerNode(Y.SEQUENCE_VARIABILITY_MAP),.3];i.dock(e,o,r,Y.MOST_POTENT_RESIDUES,s)})}createNewView(){const t=this.getVisibleSelection(),e=this.df.clone(t);for(const[t,n]of e.tags)e.setTag(t,t===E.gp.SETTINGS?n:"");e.name="Peptides Multiple Views",e.setTag(E.gp.MULTIPLE_VIEWS,"1");const n=h.shell.addTableView(e),i=this.findViewer(Y.LOGO_SUMMARY_TABLE);return null!=i&&n.addViewer(Y.LOGO_SUMMARY_TABLE,{[`sequence${E.To}`]:i.sequenceColumnName,[`activity${E.To}`]:i.activityColumnName,activityScaling:i.activityScaling,webLogoMode:i.webLogoMode,membersRatioThreshold:i.membersRatioThreshold,[`clusters${E.To}`]:i.clustersColumnName}),e.getTag(d.TAGS.ID)}clusterEmbeddings(){return W(this,void 0,void 0,function*(){var t,e;if(!this._sequenceSpaceCols||0===this._sequenceSpaceCols.length)return void h.shell.warning("Embeddings columns are not initialized");const i=this._sequenceSpaceCols.filter(t=>t.toLowerCase().startsWith("embed_"));if(2!==i.length)return void h.shell.warning(`Found ${i.length} embeddings columns, expected 2`);const o=this._sequenceSpaceCols.filter(t=>t.toLowerCase().startsWith("cluster"));o.length>0&&this.df.columns.remove(o[0]);const r=this.df.getCol(i[0]).getRawData(),s=this.df.getCol(i[1]).getRawData(),a=null!==(t=this.settings.sequenceSpaceParams.epsilon)&&void 0!==t?t:.01,l=null!==(e=this.settings.sequenceSpaceParams.minPts)&&void 0!==e?e:4,u=yield function(t,e,i,o){return r=this,s=void 0,l=function*(){return new Promise(function(r,s){const a=new Worker(new URL(n.p+n.u(682),n.b));a.postMessage({embedX:t,embedY:e,minPts:o,epsilon:i}),a.onmessage=({data:{error:t,clusters:e}})=>{a.terminate(),t?s(t):r(e)}})},new((a=void 0)||(a=Promise))(function(t,e){function n(t){try{o(l.next(t))}catch(t){e(t)}}function i(t){try{o(l.throw(t))}catch(t){e(t)}}function o(e){var o;e.done?t(e.value):(o=e.value,o instanceof a?o:new a(function(t){t(o)})).then(n,i)}o((l=l.apply(r,s||[])).next())});var r,s,a,l}(r,s,a,l),c=this.df.columns.getUnusedName("Cluster (DBSCAN)"),d=this.df.columns.addNewString(c);d.init(t=>u[t].toString()),null!==this._sequenceSpaceViewer&&(this._sequenceSpaceViewer.props.colorColumnName=d.name),this._sequenceSpaceCols=[i[0],i[1],d.name];const f=this.analysisView.grid.col(d.name);f&&(f.visible=!1)})}addMCLClusters(){return W(this,void 0,void 0,function*(){var t,e,n,i,o;if(null!==this._mclViewer)try{null===(t=this._mclViewer)||void 0===t||t.detach(),null===(e=this._mclViewer)||void 0===e||e.close()}catch(t){}0!==this._mclCols.length&&this._mclCols.forEach(t=>this.df.columns.remove(t)),this._mclCols=[];const r=this.df.getCol(this.settings.sequenceColumnName);null!==(n=(o=this.settings).mclSettings)&&void 0!==n||(o.mclSettings=new N.av);const s=this.settings.mclSettings;let a=0;const l=this.df.onColumnsAdded.subscribe(t=>{for(const e of t.columns)if((e.name.toLowerCase().startsWith("embed")||e.name.toLowerCase().startsWith("cluster")||e.name.toLowerCase().startsWith("connectivity"))&&e.name.toLowerCase().includes("mcl")){const t=this.analysisView.grid.col(e.name);if(null==t||this._mclCols.includes(e.name))continue;t.visible=!1,this._mclCols.push(e.name),a++}5===a&&l.unsubscribe()}),u=h.events.onViewerAdded.subscribe(t=>{try{const e=t.args.viewer;if(e.type===d.VIEWER.SCATTER_PLOT){if(this._sequenceSpaceViewer&&this.analysisView.dockManager.findNode(this._sequenceSpaceViewer.root)){const t=this.analysisView.dockManager.findNode(this._sequenceSpaceViewer.root);setTimeout(()=>{this.analysisView.dockManager.dock(e,d.DOCK_TYPE.FILL,t)})}u.unsubscribe()}}catch(t){console.error(t)}}),c=JSON.stringify({cols:[r].map(t=>t.name),metrics:[s.distanceF],weights:[1],aggregationMethod:H.MANHATTAN,preprocessingFuncs:["macromoleculePreprocessingFunction"],preprocessingFuncArgs:[{gapOpen:s.gapOpen,gapExtend:s.gapExtend,fingerprintType:s.fingerprintType}],threshold:s.threshold,maxIterations:s.maxIterations,useWebGPU:s.useWebGPU,inflate:s.inflation,minClusterSize:s.minClusterSize}),f=null!==(i=this.analysisView)&&void 0!==i?i:h.shell.getTableView(this.df.name);if(f){const t=d.Func.find({package:"EDA",name:"markovClusteringViewer"})[0];if(!t)throw new Error("Markov clustering function is not found");if(yield t.apply(),f.addViewer(Y.MCL,{mclProps:c}),yield d.delay(500),this._mclViewer=this.findViewer(Y.MCL),yield this._mclViewer.initPromise,this._mclViewer=this.findViewer(Y.MCL),!this._mclViewer||!this._mclViewer.isDetached)return null==u||u.unsubscribe(),void(null==l||l.unsubscribe());const e=this.findViewer(Y.LOGO_SUMMARY_TABLE);e&&(e._clusterStats=null,e._clusterSelection=null,e._viewerGrid=null,e._logoSummaryTable=null,e.render())}})}addSequenceSpace(){return W(this,arguments,void 0,function*(t={}){var e,n,i,o;if(null!==this._sequenceSpaceViewer)try{null===(e=this._sequenceSpaceViewer)||void 0===e||e.detach(),null===(n=this._sequenceSpaceViewer)||void 0===n||n.close()}catch(t){}0!==this._sequenceSpaceCols.length&&this._sequenceSpaceCols.forEach(t=>this.df.columns.remove(t)),this._sequenceSpaceCols=[];let r=this.df.getCol(this.settings.sequenceColumnName);const s=j.Z.getSeqHelper().getSeqHandler(r);if(s.isHelm())try{h.shell.warning("Column is in HELM notation. Sequences space will linearize sequences from position 0 prior to analysis");const t=s.convert(f.Hi.SEPARATOR,"/"),e=this.df.columns.getUnusedName(`Separator(${r.name})`);t.name=e,this.df.columns.add(t,!0),this.analysisView.grid.col(e).visible=!1,r=t}catch(t){return h.shell.error("Error on converting HELM notation to linear notation"),void h.shell.error(t)}const a=!t.clusterCol&&!!t.clusterEmbeddings,l=null!==(o=null===(i=this.settings)||void 0===i?void 0:i.sequenceSpaceParams)&&void 0!==o?o:new N.GI(a);l.clusterEmbeddings=a;const u={table:this.df,molecules:r,methodName:_.UMAP,similarityMetric:l.distanceF,plotEmbeddings:!0,options:{bypassLargeDataWarning:!0,dbScanEpsilon:l.epsilon,dbScanMinPts:l.minPts,randomSeed:"1",preprocessingFuncArgs:{gapOpen:l.gapOpen,gapExtend:l.gapExtend,fingerprintType:l.fingerprintType}},clusterEmbeddings:l.clusterEmbeddings};let c=0;const m=l.clusterEmbeddings?3:2,p=this.df.onColumnsAdded.subscribe(t=>{for(const e of t.columns)if(e.name.toLowerCase().startsWith("embed_")||l.clusterEmbeddings&&e.name.toLowerCase().startsWith("cluster")){const t=this.analysisView.grid.col(e.name);if(null==t||this._sequenceSpaceCols.includes(e.name))continue;t.visible=!1,this._sequenceSpaceCols.push(e.name),c++}c===m&&p.unsubscribe()}),g=h.events.onViewerAdded.subscribe(t=>{try{const e=t.args.viewer;if(e.type===d.VIEWER.SCATTER_PLOT){if(this._mclViewer&&this.analysisView.dockManager.findNode(this._mclViewer.root)){const t=this.analysisView.dockManager.findNode(this._mclViewer.root);setTimeout(()=>{this.analysisView.dockManager.dock(e,d.DOCK_TYPE.FILL,t)})}g.unsubscribe()}}catch(t){console.error(t)}}),v=yield h.functions.call("Bio:sequenceSpaceTopMenu",u);g.unsubscribe(),v instanceof d.ScatterPlotViewer&&(l.clusterEmbeddings||t.clusterCol||(v.props.colorColumnName=this.getScaledActivityColumn().name),v.props.showXSelector=!1,v.props.showYSelector=!1,t.clusterCol&&(v.props.colorColumnName=t.clusterCol.name),this._sequenceSpaceViewer=v,v.onContextMenu.subscribe(t=>{try{t.item("Modify Sequence space parameters",()=>{(0,R.OH)(this)})}catch(t){}}))})}}z.modelName="peptidesModel"},3262(t,e,n){"use strict";n.r(e),n.d(e,{PackageFunctions:()=>Ct,Peptides:()=>z,_package:()=>mt,clusterMaxActivity:()=>it,getMonomerWorksInstance:()=>pt,getTreeHelperInstance:()=>gt,initPeptides:()=>W,logoSummaryTable:()=>et,lstPiechartCellRenderer:()=>at,macromoleculeSarFastaDemo:()=>st,manualAlignment:()=>rt,monomerPosition:()=>Q,mostPotentResidues:()=>J,mutationCliffs:()=>tt,peptideGeneration:()=>ot,peptidesDialog:()=>K,peptidesPanel:()=>X,sequencePositionStatistics:()=>nt,testInitFunctionPeptides:()=>Z});var i=n(4328),o=n(7389),r=n(6082),s=n(440),a=n(7233),l=n.n(a),u=(n(4788),n(3743)),c=n(726),h=n(3541),d=n(5480);n(854);class f{constructor(t){this.monomerLib=t}getCappedRotatedMonomer(t,e){const n=this.monomerLib.getMonomer(t,e);return n?n.molfile:null}}var m=n(4139),p=n(8608),g=n(2003),v=n(115),C=n(5072),y=n.n(C),b=n(7825),_=n.n(b),w=n(7659),A=n.n(w),S=n(5056),T=n.n(S),E=n(540),N=n.n(E),x=n(1113),M=n.n(x),I=n(6677),O={};O.styleTagTransform=M(),O.setAttributes=T(),O.insert=A().bind(null,"head"),O.domAPI=_(),O.insertStyleElement=N(),y()(I.A,O),I.A&&I.A.locals&&I.A.locals;var P;!function(t){let e,n;!function(t){t.vert=function(t,e){return r._options(o.divV(t.map(t=>o.render(t)),{classes:"u2-panel"}),e)},t.horz=function(t,e){return r._options(o.divH(t.map(t=>o.render(t)),{classes:"u2-panel"}),e)}}(e=t.panels||(t.panels={})),t.appHeader=function(t){const n=o.iconImage("",t.iconPath);l()(n).addClass("ui-app-header-icon").css("margin-right","20px"),t.iconSize&&(n.style.width=`${t.iconSize}px`,n.style.height=`${t.iconSize}px`);const i=e.horz([],{classes:"ui-app-header"});if(t.appTitle){i.classList.add("u2-app-header-with-name");const e=o.divV([o.divText(t.appTitle,"u2-app-header-app-name-div")],"u2-app-header-app-name-and-slogan-div");t.appSubTitle&&e.append(o.divText(t.appSubTitle));const r=o.div(n);i.append(o.divH([r,e]))}else i.append(n);const r=e.vert([o.markdown(t.description),t.learnMoreUrl?o.link("Learn more",t.learnMoreUrl,void 0,{style:{marginLeft:"15px"}}):null]);return r.classList.add("u2-app-header-description"),i.append(r),t.bottomLine&&i.classList.add("u2-app-header-bottom-line"),i},function(t){t.runAsync=function(t,e){return n=this,r=void 0,a=function*(){o.setUpdateIndicator(t,!0);try{return yield e()}catch(t){i.log.error(t)}finally{o.setUpdateIndicator(t,!1)}},new((s=void 0)||(s=Promise))(function(t,e){function i(t){try{l(a.next(t))}catch(t){e(t)}}function o(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s(function(t){t(n)})).then(i,o)}l((a=a.apply(n,r||[])).next())});var n,r,s,a}}(n=t.tools||(t.tools={}))}(P||(P={}));var L=n(144),R=n.n(L);const k=rxjs.operators;class F extends r.JsViewer{get scViewer(){return this._scViewer||(this._scViewer=this.createSCViewer()),this._scViewer}constructor(){super(),this._titleHost=o.divText(u.q.CLUSTER_MAX_ACTIVITY,{id:"pep-viewer-title",style:{marginRight:"auto"}}),this._selsectIcon=o.div(),this.activityTarget=m.wf.HIGH,this.viewerError="",this.renderTimeout=null,this.renderDebounceTime=500,this.scFilterQuery=`\${${F.maxActivityInClusterColName}} == 1`,this.selectionSubscription=null,this.linesDrawSubscription=null,this.clusterColumnName=this.column("cluster",{nullable:!1}),this.activityColumnName=this.column("activity",{nullable:!1}),this.colorColumnName=this.column("color",{nullable:!0,defaultValue:null}),this.activityTarget=this.string("activityTarget",m.wf.HIGH,{choices:[m.wf.HIGH,m.wf.LOW]}),this.clusterSizeThreshold=this.int("clusterSizeThreshold",20),this.activityThreshold=this.float("activityThreshold",1e3,{step:.1}),this.connectivityColumnName=this.column("connectivity",{nullable:!0})}get model(){return u.i.getInstance(this.dataFrame)}createSCViewer(){var t;const e={showXAxis:!0,showYAxis:!0,showXSelector:!1,showYSelector:!1,showColorSelector:!1,xAxisType:r.AxisType.logarithmic,yAxisType:r.AxisType.logarithmic,invertYAxis:this.activityTarget===m.wf.LOW,xColumnName:F.clusterSizeColName,markerType:"circle",markerDefaultSize:10,showSizeSelector:!1};if(null==this.clusterColumnName||null==this.activityColumnName||!this.dataFrame.columns.contains(this.clusterColumnName)||!this.dataFrame.columns.contains(this.activityColumnName))return this.viewerError="Please set valid cluster and activity columns",null;const n=this.dataFrame.columns.byName(this.activityColumnName),i=this.dataFrame.columns.byName(this.clusterColumnName),s=null!=this.connectivityColumnName?this.dataFrame.columns.byName(this.connectivityColumnName):null;if(![r.COLUMN_TYPE.FLOAT,r.COLUMN_TYPE.INT,r.COLUMN_TYPE.BIG_INT,r.COLUMN_TYPE.QNUM].includes(n.type))return this.viewerError="Activity column should be numeric",null;const a=this.dataFrame.columns.getOrCreate(F.clusterSizeColName,r.TYPE.INT),l={};for(let e=0;e<this.dataFrame.rowCount;e++){const n=i.get(e);null!=n&&"-1"!=n&&(l[n]=(null!==(t=l[n])&&void 0!==t?t:0)+1)}a.init(t=>{var e;return i.isNone(t)?null:null!==(e=l[i.get(t)])&&void 0!==e?e:null}),n.stats.min<=0&&(e.yAxisType=r.AxisType.linear);const u={},c={};for(let t=0;t<this.dataFrame.rowCount;t++){const e=i.get(t);if(null==e||i.isNone(t)||n.isNone(t))continue;const o=n.get(t),r=u[e];if((null==r||null==r||o>n.get(r)&&this.activityTarget===m.wf.HIGH||o<n.get(r)&&this.activityTarget===m.wf.LOW)&&(u[e]=t),s){const n=s.get(t),i=c[e];(null==i||null==i||n>s.get(i))&&(c[e]=t)}}const h=this.dataFrame.columns.getOrCreate(F.maxActivityInClusterColName,r.COLUMN_TYPE.INT);h.init(t=>i.isNone(t)?0:t===u[i.get(t)]?1:0),this.dataFrame.columns.getOrCreate(F.maxConnectivityInClusterColName,r.COLUMN_TYPE.INT).init(t=>i.isNone(t)?0:t===c[i.get(t)]?1:0),this.dataFrame.columns.getOrCreate(F.synSelectionColName,r.TYPE.STRING).init(t=>{if(i.isNone(t))return null;let e=null;return t===u[i.get(t)]&&(e=F.maxActivityLabel),s&&t===c[i.get(t)]&&(e=e?`${e}, ${F.maxConnectivityLabel}`:F.maxConnectivityLabel),e}),e.xColumnName=F.clusterSizeColName,e.yColumnName=this.activityColumnName,e.filter=this.scFilterQuery,this.viewerError="";const d=r.Viewer.scatterPlot(this.dataFrame,e);this.selectionSubscription&&this.selectionSubscription.unsubscribe(),this.selectionSubscription=d.onDataEvent.pipe((0,k.filter)(t=>"d4-select"==t.type)).subscribe(t=>{var e,n;const o=null!==(n=null===(e=t.bitset)||void 0===e?void 0:e.getSelectedIndexes())&&void 0!==n?n:[],s=this.dataFrame.selection,a=r.BitSet.create(this.dataFrame.rowCount,t=>1==h.get(t));a.and(s);for(let t=0;t<o.length;t++){const e=o[t],n=i.get(e);i.isNone(e)||(a.set(e,!0),null!=c[n]&&a.set(c[n],!0))}a.fireChanged();const l=a.getSelectedIndexes();for(const t of l){const e=i.get(t);null!=e&&null!=c[e]&&a.set(c[e],!0)}setTimeout(()=>{this.dataFrame.selection.copyFrom(a,!0),setTimeout(()=>{this.model&&this.model.createAccordion()},200)},200)});const f=()=>{const t=r.BitSet.create(this.dataFrame.rowCount);Object.entries(u).forEach(([e,i])=>{var o;if(null==e||null==i)return;const r=parseInt(e),s=n.get(i),a=null!==(o=l[r])&&void 0!==o?o:l[e];s<this.activityThreshold&&a<this.clusterSizeThreshold||(t.set(i,!0,!1),null!=c[r]&&t.set(c[r],!0,!1))}),t.fireChanged(),this.dataFrame.selection.copyFrom(t,!0)};return this._selsectIcon=o.iconSvg("select-all",()=>{f()},"Select 3 Active quadrants"),this._selsectIcon.style.cursor="pointer",this._selsectIcon.style.marginRight="5px",f(),this.linesDrawSubscription&&this.linesDrawSubscription.unsubscribe(),this.linesDrawSubscription=d.onBeforeDrawScene.subscribe(()=>{const t=d.getInfo().canvas.getContext("2d"),e=d.viewport,n=d.worldToScreen(e.x,this.activityThreshold),i=d.worldToScreen(this.clusterSizeThreshold,e.y),o=d.worldToScreen(e.x+e.width,this.activityThreshold),r=d.worldToScreen(this.clusterSizeThreshold,e.y+e.height);t.beginPath(),t.strokeStyle="rgb(0,0,0)",t.lineWidth=1,t.moveTo(n.x,n.y),t.lineTo(o.x,o.y),t.moveTo(i.x,i.y),t.lineTo(r.x,r.y),t.stroke(),t.closePath()}),d}onTableAttached(){var t,e,n,i,o,r,s,a,l,u,c,h;super.onTableAttached();const d=null!==(e=null===(t=this.dataFrame)||void 0===t?void 0:t.col(m.$2.ACTIVITY))&&void 0!==e?e:null===(i=R()(null===(n=this.dataFrame)||void 0===n?void 0:n.columns.numerical).next())||void 0===i?void 0:i.value;null!=d&&(null===(o=this.getProperty(`activity${m.To}`))||void 0===o||o.set(this,d.name));const f=null===(s=R()(null===(r=this.dataFrame)||void 0===r?void 0:r.columns.categorical).next())||void 0===s?void 0:s.value;null!=f&&(null===(a=this.getProperty(`cluster${m.To}`))||void 0===a||a.set(this,f.name));const p=null===(u=R()(null===(l=this.dataFrame)||void 0===l?void 0:l.columns.numerical).next())||void 0===u?void 0:u.value;null!=p&&(null===(c=this.getProperty(`connectivity${m.To}`))||void 0===c||c.set(this,p.name)),this.render(),null===(h=this.dataFrame)||void 0===h||h.onDataChanged.subscribe(()=>{this.render()})}render(){this.renderTimeout&&clearTimeout(this.renderTimeout),this.renderTimeout=setTimeout(()=>{var t,e;if(!this.dataFrame)return;l()(this.root).empty();const n=this.scViewer;if(null==n)return void this.root.appendChild(o.divText(null!==(t=this.viewerError)&&void 0!==t?t:"Error creating scatter plot"));const i=o.div("Cluster Size",{style:{alignSelf:"center",color:"var(--grey-6)",marginBottom:"5px"}}),r=o.div(this.activityTarget===m.wf.HIGH?"Maximum Activity":"Minimum Activity",{style:{color:"var(--grey-6)",alignSelf:"center",textOrientation:"mixed",writingMode:"tb",transform:"rotate(180deg)",marginLeft:"5px"}});n.props.colorColumnName=null!==(e=this.colorColumnName)&&void 0!==e?e:null,this.root.appendChild(o.divH([r,o.divV([o.divH([this._titleHost,this._selsectIcon],{style:{alignSelf:"center",lineHeight:"normal",width:"100%"}}),n.root,i],{style:{flexGrow:"1"}})])),n.root.style.width="100%",setTimeout(()=>{n.props.filter=this.scFilterQuery,n.invalidateCanvas()},100)},this.renderDebounceTime)}onPropertyChanged(t){super.onPropertyChanged(t),(null==t?void 0:t.name)!==`color${m.To}`&&(this._scViewer=null),this.render()}}F.clusterSizeColName="~cluster.size",F.maxActivityInClusterColName="~max.activity.for.cluster",F.maxConnectivityInClusterColName="~max.connectivity.for.cluster",F.synSelectionColName="Syn Selection",F.maxActivityLabel="Max Activity",F.maxConnectivityLabel="Max Connectivity";var V=n(3163);class D extends r.JsViewer{constructor(){super(),this.showPositionInfo=!0,this.positions=this.string("positions","1",{description:"Comma-separated sequence positions (1-based) to analyze"}),this.sequenceColumnName=this.column("sequence",{semType:r.SEMTYPE.MACROMOLECULE,nullable:!1}),this.valueColumnName=this.column("value",{columnTypeFilter:"numerical",nullable:!1}),this.showPositionInfo=this.bool("showPositionInfo",!0,{nullable:!1,defaultValue:!0,description:"Show position selector in the viewer header"}),this.subs.push(i.events.onContextMenu.subscribe(t=>{var e;t.causedBy&&t.causedBy.target&&(null===(e=this._boxPlotViewer)||void 0===e?void 0:e.root.contains(t.causedBy.target))&&(t.causedBy.preventDefault(),t.causedBy.stopPropagation(),t.causedBy.stopImmediatePropagation())}))}getPositionFromColumn(){var t;const e=this.dataFrame.col(this.sequenceColumnName);if(null==e)return 1;const n=null!==(t=e.getTag(g.gp.selectedPosition))&&void 0!==t?t:"1",i=parseInt(n);return Number.isNaN(i)?1:Math.max(1,i)}parsePositions(){if(!this.positions)return[1];const t=this.positions.split(",").map(t=>parseInt(t.trim())).filter(t=>!Number.isNaN(t)&&t>=1);return[...new Set(t)].sort((t,e)=>t-e)}_setPositions(t){const e=[...new Set(t)].sort((t,e)=>t-e);this.getProperty("positions").set(this,e.join(", "))}onTableAttached(){if(super.onTableAttached(),null==this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE))throw i.shell.error("No sequence column found"),new Error("No sequence column found");const t=this.dataFrame.columns.getUnusedName("~sequence_position_monomers");this._positionColumn=this.dataFrame.columns.addNewString(t),this._positionColumn.semType="Monomer",this._positionColumn.setTag("cell.renderer","Monomer"),this.getProperty("sequenceColumnName").set(this,this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE).name),this.getProperty("valueColumnName").set(this,R()(this.dataFrame.columns.numerical).next().value.name),this.getProperty("positions").set(this,String(this.getPositionFromColumn())),this.subs.push(r.debounce(this.dataFrame.onMetadataChanged,200).subscribe(t=>{const e=this.getPositionFromColumn();this.parsePositions().includes(e)||this._setPositions([e])}))}render(){var t;const e=this.parsePositions();if(!(null!=this.dataFrame&&this.sequenceColumnName&&e.length&&this._positionColumn&&this.valueColumnName))return;l()(this.root).empty(),null===(t=this._boxPlotViewer)||void 0===t||t.detach();const n=c.Z.getSeqHelper(),i=this.dataFrame.col(this.sequenceColumnName),o=n.getSeqHandler(i),s=o.maxLength,a=e.map(t=>o.getMonomersAtPosition(t-1,!1));if(this._positionColumn.init(t=>a.map(e=>e[t]).join(g.ot)),this._boxPlotViewer=this.dataFrame.plot.box({categoryColumnNames:[this._positionColumn.name],plotStyle:"violin",valueColumnName:this.valueColumnName,colorColumnName:this._positionColumn.name,showColorSelector:!1,showSizeSelector:!1,showCategorySelector:!1,legendVisibility:r.VisibilityMode.Never,markerColorColumnName:this._positionColumn.name,title:"Sequence Position Statistics",autoLayout:!1,labelOrientation:"Vert"}),this.showPositionInfo){const t=this._renderPositionSelector(e,s);this.root.appendChild(t)}this._boxPlotViewer.props.statistics=["min","max","avg","med","count"],this._boxPlotViewer.root.style.width="100%",this._boxPlotViewer.root.style.height="100%",this.root.appendChild(this._boxPlotViewer.root),this._boxPlotViewer.sub(this._boxPlotViewer.onPropertyValueChanged.subscribe(t=>{var e,n,i,o;if((null===(n=null===(e=this._boxPlotViewer)||void 0===e?void 0:e.props)||void 0===n?void 0:n.valueColumnName)&&(null===(o=null===(i=this._boxPlotViewer)||void 0===i?void 0:i.props)||void 0===o?void 0:o.valueColumnName)!==this.valueColumnName){const t=this._boxPlotViewer.props.valueColumnName;setTimeout(()=>this.getProperty("valueColumnName").set(this,t),10)}}))}_renderPositionSelector(t,e){const n=o.divH([],{style:{alignItems:"center",justifyContent:"center",gap:"4px",flexWrap:"wrap",padding:"4px 8px",width:"100%"}}),i=o.label(`${this.sequenceColumnName}:`);i.style.fontWeight="bold",i.style.marginRight="4px",n.appendChild(i);for(const i of t)n.appendChild(this._createChip(i,t,e));return n.appendChild(this._createAddButton(n,t,e)),n}_createChip(t,e,n){const i=1===e.length,r=document.createElement("span");r.textContent=String(t),r.style.marginRight="3px";const s=i?o.iconFA("pencil",()=>this._showInlineEdit(a,t,n),"Edit position"):o.iconFA("times",()=>this._setPositions(e.filter(e=>e!==t)),"Remove position");s.style.cursor="pointer",s.style.fontSize="10px",s.style.opacity="0.6";const a=o.divH([r,s],{style:{display:"inline-flex",alignItems:"center",background:"#f0f0f0",borderRadius:"12px",padding:"2px 8px",fontSize:"12px",cursor:"default",border:"1px solid #d0d0d0"}});return a}_showInlineEdit(t,e,n){var i;const o=document.createElement("input");o.type="number",o.min="1",o.max=String(n),o.value=String(e),o.style.cssText="width:45px;height:22px;font-size:12px;text-align:center;border-radius:12px;border:1px solid #aaa;outline:none;padding:0 4px;";let r=!1;const s=()=>{if(r)return;r=!0;const i=parseInt(o.value),s=this.parsePositions();!Number.isNaN(i)&&i>=1&&i<=n&&i!==e?this._setPositions(s.map(t=>t===e?i:t)):o.replaceWith(t)};o.addEventListener("keydown",e=>{var n;"Enter"===e.key&&s(),"Escape"===e.key&&(r=!0,null===(n=t.parentElement)||void 0===n||n.replaceChild(t,o))}),o.addEventListener("blur",s),null===(i=t.parentElement)||void 0===i||i.replaceChild(o,t),o.focus(),o.select()}_createAddButton(t,e,n){const i=o.iconFA("plus-circle",()=>{if(t.querySelector(".position-add-input"))return;const o=document.createElement("input");o.type="number",o.min="1",o.max=String(n),o.className="position-add-input",o.style.cssText="width:45px;height:22px;font-size:12px;text-align:center;border-radius:12px;border:1px solid #aaa;outline:none;padding:0 4px;";let r=!1;const s=()=>{if(r)return;r=!0;const t=parseInt(o.value);!Number.isNaN(t)&&t>=1&&t<=n&&!e.includes(t)?this._setPositions([...e,t]):o.remove()};o.addEventListener("keydown",t=>{"Enter"===t.key&&s(),"Escape"===t.key&&(r=!0,o.remove())}),o.addEventListener("blur",s),t.insertBefore(o,i),o.focus()},"Add position");return i.style.cursor="pointer",i.style.fontSize="14px",i.style.color="#2083d5",i}onPropertyChanged(t){null!=this.dataFrame&&this.sequenceColumnName&&this.render()}}var G=n(7471),B=n(4025),U=n(439),q=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};class H extends r.JsViewer{constructor(){super(),this.position=1,this.currentRowMutationsOnly=!1,this.yAxisType="Linear",this._mutationCliffsData=null,this._dfSubs=[],this._positionColumns=null,this._innerDf=null,this._lineChart=null,this._debounceTimer=null,this.sequenceColumnName=this.column("sequence",{semType:r.SEMTYPE.MACROMOLECULE,nullable:!1}),this.seriesColumnName=this.column("series",{columnTypeFilter:"categorical",nullable:!1}),this.activityColumnName=this.column("activity",{columnTypeFilter:"numerical",nullable:!1}),this.position=this.int("position",1,{nullable:!1,showSlider:!1,min:1,max:100,showPlusMinus:!0,description:"Position in the sequence to analyze (1 Based).",category:"Data"}),this.yAxisType=this.string("yAxisType","Linear",{choices:["Linear","Logarithmic"],description:"Y-Axis scale type.",nullable:!1,category:"Data"}),this.currentRowMutationsOnly=this.bool("currentRowMutationsOnly",!1,{nullable:!1,defaultValue:!1,description:"When enabled, the viewer will show mutations related to the peptide in current row in the dataframe and selected position.",category:"Data"}),this.root.classList.add("peptides-viewer-show-title")}onTableAttached(){var t,e;super.onTableAttached();const n=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE);n&&this.getProperty("sequenceColumnName").set(this,n.name),this.getProperty("activityColumnName").set(this,R()(this.dataFrame.columns.numerical).next().value.name);const o=null===(e=null===(t=R()(this.dataFrame.columns.categorical))||void 0===t?void 0:t.filter(t=>{var e;return t.name!==this.sequenceColumnName&&(null===(e=t.name)||void 0===e?void 0:e.toLowerCase().includes("series"))}).next())||void 0===e?void 0:e.value;o&&this.getProperty("seriesColumnName").set(this,o.name),this.subs.push(r.debounce(this.dataFrame.onFilterChanged,200).subscribe(()=>{this.clearCache(),this.debouncedRender()})),this.debouncedRender(),this.subs.push(i.events.onContextMenu.subscribe(t=>{var e;t.causedBy&&t.causedBy.target&&(null===(e=this._lineChart)||void 0===e?void 0:e.root.contains(t.causedBy.target))&&(t.causedBy.preventDefault(),t.causedBy.stopPropagation(),t.causedBy.stopImmediatePropagation())}))}get mutationCliffsData(){if(this._mutationCliffsData)return this._mutationCliffsData;if(!this.activityColumnName||!this.sequenceColumnName||!this.position)throw new Error("Activity column or Sequence column is not set, or position is invalid");return this._mutationCliffsData=new Promise((t,e)=>q(this,void 0,void 0,function*(){try{const e=this.dataFrame.col(this.activityColumnName).getRawData(),n=this.positionColumns,i=n[this.position-1].toList(),o=n.map(p.eY),r=yield(new G.a).calc(e,o,{maxMutations:1,minActivityDelta:0,filter:this.dataFrame.filter.anyFalse?new Uint32Array(this.dataFrame.filter.getBuffer().buffer):void 0,singlePosition:{position:this.position-1}});t({cliffs:r,monomers:i})}catch(t){e(t)}})),this._mutationCliffsData}calculateDf(){return q(this,void 0,void 0,function*(){if(!(this.dataFrame&&this.activityColumnName&&this.sequenceColumnName&&this.position))throw new Error("Activity column or Sequence column is not set, or position is invalid");const t=yield this.mutationCliffsData,e=new Set;t.cliffs.forEach(t=>{t.forEach(t=>{Array.from(t.entries()).forEach(([t,n])=>{const i=Number(t);this.currentRowMutationsOnly&&this.dataFrame.currentRowIdx!==i||(e.add(i),n.forEach(t=>e.add(Number(t))))})})});const n=Array.from(e.values()).sort((t,e)=>t-e),i=new Map;n.forEach((t,e)=>{i.set(t,e)});const o=n.map(e=>t.monomers[e]),s=this.dataFrame.col(this.activityColumnName).getRawData(),a=n.map(t=>s[t]),l=[r.Column.fromList("string",`Position ${this.position}`,o),r.Column.fromList("double",this.activityColumnName,a)];if(this.seriesColumnName){const t=this.dataFrame.col(this.seriesColumnName).getRawData(),e=this.dataFrame.col(this.seriesColumnName).categories,i=n.map(n=>e[t[n]]),o=r.Column.fromList("string",this.seriesColumnName,i);l.push(o)}const u=r.DataFrame.fromColumns(l);Array.from(this.dataFrame.columns.numerical).filter(t=>t.name!==this.activityColumnName&&t.name!==this.seriesColumnName).forEach(t=>{u.columns.addNew(t.name,t.type)}),this._dfSubs.push(u.onMouseOverRowChanged.subscribe(t=>{if(u.mouseOverRowIdx>=0){const t=n[u.mouseOverRowIdx];this.dataFrame.mouseOverRowIdx=t}})),this._dfSubs.push(this.dataFrame.onMouseOverRowChanged.subscribe(t=>{if(this.dataFrame.mouseOverRowIdx>=0){const t=i.get(this.dataFrame.mouseOverRowIdx);u.mouseOverRowIdx=null!=t?t:-1}}));let c=!1;this._dfSubs.push(u.onCurrentRowChanged.subscribe(t=>{if(u.currentRowIdx>=0){c=!0;const t=n[u.currentRowIdx];this.dataFrame.currentRowIdx=t}})),this.currentRowMutationsOnly&&this._dfSubs.push(this.dataFrame.onCurrentRowChanged.subscribe(t=>{c?c=!1:(this.clearCache(!1),this.debouncedRender())}));let h=!1,d=!1;return this._dfSubs.push(r.debounce(u.onSelectionChanged,100).subscribe(t=>{const e=u.selection;if(h)h=!1;else if(d=!0,this.dataFrame.selection.setAll(!1,!1),e.anyTrue){for(let t=-1;-1!==(t=e.findNext(t,!0));){const e=n[t];this.dataFrame.selection.set(e,!0,!1)}this.dataFrame.selection.fireChanged()}else this.dataFrame.selection.fireChanged()})),this._dfSubs.push(r.debounce(this.dataFrame.onSelectionChanged,100).subscribe(t=>{const e=this.dataFrame.selection;if(d)d=!1;else if(h=!0,u.selection.setAll(!1,!1),e.anyTrue){for(let t=-1;-1!==(t=e.findNext(t,!0));){const e=i.get(t);null!=e&&u.selection.set(e,!0,!1)}u.selection.fireChanged()}else u.selection.fireChanged()})),u})}get positionColumns(){var t,e;if(this._positionColumns)return this._positionColumns;if(!this.dataFrame)return[];const n=u.i.getInstance(this.dataFrame),i=null==n?void 0:n.positionColumns;if(i&&i.length>0)return this._positionColumns=i,this._positionColumns;const o=this.dataFrame.col(this.sequenceColumnName),s=c.Z.getSeqHelper().getSeqHandler(o),a=s.maxLength,l=[],h=null!==(t=o.temp[B.j.notationProvider])&&void 0!==t?t:null,d=null!==(e=null==h?void 0:h.monomerCanonicalizerFuncName)&&void 0!==e?e:null;for(let t=0;t<a;t++){const e=s.getMonomersAtPosition(t,!1),n=r.Column.fromList("string",`Position ${t+1}`,e);d&&n.setTag(U.jz,d),l.push(n)}return this._positionColumns=l,this._positionColumns}get innerDf(){return this._innerDf?Promise.resolve(this._innerDf):(this._innerDf=this.calculateDf(),this._innerDf)}render(){return q(this,void 0,void 0,function*(){if(l()(this.root).empty(),!(this.dataFrame&&this.activityColumnName&&this.sequenceColumnName&&this.position))return o.setUpdateIndicator(this.root,!1),void this.root.appendChild($("Please set Activity column, Sequence column and Position properties."));if(this._lineChart){try{this._lineChart.detach()}catch(t){console.error("Error detaching previous line chart:",t)}this._lineChart=null}o.setUpdateIndicator(this.root,!0),this.root.style.display="flex",this.root.style.flexDirection="column";const t=yield this.innerDf;o.setUpdateIndicator(this.root,!1),0===t.rowCount?this.currentRowMutationsOnly?this.dataFrame.currentRowIdx>=0?this.root.appendChild($("No mutations cliffs found for the current peptide at the selected position.")):this.root.appendChild($("Please select a row in the main table to see mutation cliffs for the corresponding peptide at the selected position.")):this.root.appendChild($("No mutation cliffs found for the selected position.")):(this._lineChart=t.plot.line({xColumnName:`Position ${this.position}`,yColumnNames:[this.activityColumnName],splitColumnNames:this.seriesColumnName?[this.seriesColumnName]:[],legendVisibility:this.seriesColumnName?"Always":"Never",legendPosition:"Right",showXSelector:!1,showYSelector:!0,showSplitSelector:!1,packCategories:!1,xAxisLabelOrientation:"Auto",axisFont:'normal normal 14px "Roboto"',controlsFont:'normal normal 14px "Roboto"'}),this._lineChart.sub(this._lineChart.onPropertyValueChanged.subscribe(t=>{var e,n,i,o,r,s,a,l;if((null===(n=null===(e=this._lineChart)||void 0===e?void 0:e.props)||void 0===n?void 0:n.yColumnNames)&&(null===(r=null===(o=null===(i=this._lineChart)||void 0===i?void 0:i.props)||void 0===o?void 0:o.yColumnNames)||void 0===r?void 0:r[0])!==this.activityColumnName){const t=null===(l=null===(a=null===(s=this._lineChart)||void 0===s?void 0:s.props)||void 0===a?void 0:a.yColumnNames)||void 0===l?void 0:l[0];setTimeout(()=>this.getProperty("activityColumnName").set(this,t),1)}})),this.root.appendChild(this._lineChart.root));const e=this.positionColumns.length+1,n=new Array(e-1).fill(0).map((t,e)=>e+1).map(t=>t.toString()),i=o.input.choice("Position",{value:this.position.toString(),items:n,nullable:!1,onValueChanged:t=>{if(!t)return;const e=parseInt(t);this.getProperty("position").set(this,e)}});if(i.input.style.width="40px",this.root.appendChild(o.divH([i.root],{style:{justifyContent:"center",marginTop:"4px",width:"100%",font:'normal normal 14px "Roboto"'}})),t.rowCount>0){const t=o.input.column("Series",{table:this.dataFrame,filter:t=>t.isCategorical&&t.name!==this.sequenceColumnName,tooltipText:"Select column for series splitting.",onValueChanged:t=>{const e=t?t.name:void 0;this.getProperty("seriesColumnName").set(this,e)},value:this.seriesColumnName?this.dataFrame.col(this.seriesColumnName):void 0});this.root.prepend(o.divH([t.root],{style:{justifyContent:"flex-end",paddingBottom:"4px",padding:"8px",width:"100%",font:'normal normal 14px "Roboto"'}}))}})}debouncedRender(){o.setUpdateIndicator(this.root,!0),this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>this.render(),300)}clearCache(t=!0){t&&(this._mutationCliffsData=null),this._innerDf=null,this._dfSubs.forEach(t=>t.unsubscribe()),this._dfSubs=[]}detach(){super.detach(),this._dfSubs.forEach(t=>t.unsubscribe()),this._dfSubs=[],clearTimeout(this._debounceTimer)}onPropertyChanged(t){if(super.onPropertyChanged(t),"activityColumnName"===(null==t?void 0:t.name)||"sequenceColumnName"===(null==t?void 0:t.name)||"position"===(null==t?void 0:t.name)||"seriesColumnName"===(null==t?void 0:t.name)){const e="seriesColumnName"===(null==t?void 0:t.name)||"activityColumnName"===(null==t?void 0:t.name);this.clearCache(!e),"sequenceColumnName"===(null==t?void 0:t.name)&&(this._positionColumns=null),this.debouncedRender()}else"yAxisType"===(null==t?void 0:t.name)?this._lineChart&&(this._lineChart.props.yAxisType=this.yAxisType.toLowerCase()):"currentRowMutationsOnly"===(null==t?void 0:t.name)&&(this.clearCache(!1),this.debouncedRender())}}function $(t){const e=o.divText(t);return e.style.fontSize="14px",e.style.marginTop="10px",e.style.textAlign="center",e}var Y=n(3615),j=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};function W(){return j(this,void 0,void 0,function*(){yield Ct.initPeptides()})}function z(){return Ct.Peptides()}function K(){return j(this,void 0,void 0,function*(){return yield Ct.peptidesDialog()})}function Z(t){return j(this,void 0,void 0,function*(){yield Ct.testInitFunctionPeptides(t)})}function X(t){return j(this,void 0,void 0,function*(){return yield Ct.peptidesPanel(t)})}function Q(){return Ct.monomerPosition()}function J(){return Ct.mostPotentResidues()}function tt(){return Ct.mutationCliffs()}function et(){return Ct.logoSummaryTable()}function nt(){return Ct.sequencePositionStatistics()}function it(){return Ct.clusterMaxActivity()}function ot(){return Ct.peptideGeneration()}function rt(t){return Ct.manualAlignment(t)}function st(){return j(this,void 0,void 0,function*(){yield Ct.macromoleculeSarFastaDemo()})}function at(){return Ct.lstPiechartCellRenderer()}var lt=function(t,e,n,i){var o,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s},ut=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},ct=function(t,e){return function(n,i){e(n,i,t)}},ht=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};let dt,ft=null;const mt=new r.Package;function pt(){return ft}function gt(){return dt}function vt(t){return ht(this,void 0,void 0,function*(){const e=r.TaskBarProgressIndicator.create("Loading Peptides"),n=mt.webRoot+"files/"+t,o=yield i.data.loadTable(n);o.name="Peptides",i.shell.addTableView(o).name="PeptidesView",i.shell.windows.showProperties=!0,e.close()})}i.decorators||(i.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach(t=>{i.decorators[t]||(i.decorators[t]=function(t){return function(t,e,n){}})});class Ct{static initPeptides(){return ht(this,void 0,void 0,function*(){try{null!=ft||(ft=new f(yield i.functions.call("Bio:getBioLib"))),null!=dt||(dt=yield async function(){const t="Dendrogram",e=r.Func.find({package:t,name:"getTreeHelper"});if(0===e.length)throw new Error(`Package "${t}" must be installed for TreeHelper.`);return(await e[0].prepare().call()).getOutputParamValue()}()),yield c.Z.loadComponents()}catch(t){i.log.error(t)}})}static Peptides(){const t=P.appHeader({iconPath:mt.getIconUrl(),learnMoreUrl:"https://github.com/datagrok-ai/public/blob/master/help/domains/bio/peptides.md",description:"- Automatically recognizes peptides in your data\n- Invariant map and mutation cliffs\n- Logo plots to explore sequence composition\n- Hierarchical clustering\n- Sequence space to analyze clustering and activity cliffs\n- Finds statistically significant changes in activity for monomer/positions\n"}),e=i.shell.windows;e.showToolbox=!1,e.showHelp=!1,e.showProperties=!1;const n=r.View.create();return n.name="Peptides",o.appendAll(n.root,[t,o.divH([o.button("Simple demo",()=>vt("aligned.csv"),""),o.button("Complex demo",()=>vt("aligned_2.csv"),""),o.button("HELM demo",()=>vt("aligned_3.csv"),"")])]),n}static peptidesDialog(){return ht(this,void 0,void 0,function*(){var t;if(!i.shell.t||!(null===(t=i.shell.t.columns.bySemType("Macromolecule"))||void 0===t?void 0:t.length))return i.shell.warning("SAR Analysis requires an active table with Macromolecule column"),null;if(!r.Utils.firstOrNull(i.shell.t.columns.numerical))return i.shell.warning("SAR Analysis requires an active table with at least one numerical column for activity"),null;const e=yield(0,s.v)(i.shell.t),n=o.dialog("Analyze Peptides").add(e.host).onOK(()=>ht(this,void 0,void 0,function*(){e.callback()||n.show()}));return n.show()})}static testInitFunctionPeptides(t){return ht(this,void 0,void 0,function*(){i.shell.info("Test init function for Peptides package"),i.shell.info("Viewer name: "+t.dataFrame.name),yield new Promise(t=>setTimeout(t,1e3))})}static peptidesPanel(t){return ht(this,void 0,void 0,function*(){if(!t.dataFrame||!r.Utils.firstOrNull(t.dataFrame.columns.numerical))return new r.Widget(o.divText("SAR Analysis requires an active table with at least one numerical column for activity"));const e=yield(0,s.v)(t.dataFrame,t);return new r.Widget(e.host)})}static monomerPosition(){return new h.J}static mostPotentResidues(){return new h.UJ}static mutationCliffs(){return new H}static logoSummaryTable(){return new d.s}static sequencePositionStatistics(){return new D}static clusterMaxActivity(){return new F}static peptideGeneration(){return new Y.Y_}static manualAlignment(t){const e=i.shell.t,n=null==e?void 0:e.temp[u.i.modelName];return n?function(t,e){const n=o.input.textArea("",{value:t.get(e.currentRowIdx)});l()(n.root).addClass("pep-textinput");const s=o.button("Apply",()=>{return o=this,r=void 0,a=function*(){const o=c.Z.getSeqHelper().getSeqHandler(t),r=n.value,s=o.splitter(r),a=e.currentRowIdx;t.set(a,r);for(let t=0;t<s.length;t++){const n=s.getOriginal(t);null!==e.col(t.toString())&&e.set(t.toString(),a,n)}const l=i.shell.o;i.shell.o=null,u.i.getInstance(e).updateGrid(),setTimeout(()=>{i.shell.o=l},100)},new((s=void 0)||(s=Promise))(function(t,e){function n(t){try{l(a.next(t))}catch(t){e(t)}}function i(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var o;e.done?t(e.value):(o=e.value,o instanceof s?o:new s(function(t){t(o)})).then(n,i)}l((a=a.apply(o,r||[])).next())});var o,r,s,a},"Apply changes"),a=o.button(o.iconFA("redo"),()=>n.value=t.get(e.currentRowIdx),"Reset");return l()(a).addClass("pep-snippet-editor-icon pep-reset-icon"),new r.Widget(o.divV([a,n.root,s],"pep-textarea-box"))}(e.getCol(n.settings.sequenceColumnName),e):new r.Widget(o.divText("Manual alignment works with peptides analysis"))}static macromoleculeSarFastaDemo(){return ht(this,void 0,void 0,function*(){return yield function(){return t=this,e=void 0,o=function*(){i.shell.windows.showContextPanel=!0;const t=r.DataFrame.fromCsv(yield mt.files.readAsText("aligned.csv"));t.name="Simple peptides",t.id||(t.id=`Simple-peptides-analysis-table-id-${Math.random()}-${Date.now()}`);const e=i.shell.addTableView(t);yield r.delay(50);const n=e.grid;yield new Promise(t=>{var e;let i=null;const o=null===(e=null==n?void 0:n.onAfterDrawContent)||void 0===e?void 0:e.subscribe(()=>{i&&clearTimeout(i),o.unsubscribe(),t(void 0)});i=setTimeout(()=>{o.unsubscribe(),t(void 0)},3e3)});const o=t.getCol("IC50"),a=t.getCol("AlignedSequence");a.semType=r.SEMTYPE.MACROMOLECULE,a.setTag(m.gp.ALPHABET,g.YI.PT),a.meta.units=g.Hi.FASTA,a.setTag(g.gp.aligned,"SEQ.MSA");const l=(0,p.Y1)(o,m.rg.MINUS_LG),u=new v.av;u.threshold=94,yield(0,s.n)(o,a,null,t,l,m.rg.MINUS_LG,{addMCL:!0,useEmbeddingsClusters:!0,mclSettings:u})},new((n=void 0)||(n=Promise))(function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((o=o.apply(t,e||[])).next())});var t,e,n,o}()})}static lstPiechartCellRenderer(){return new V.DX}}lt([i.decorators.init({tags:["init"]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",Promise)],Ct,"initPeptides",null),lt([i.decorators.func(),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.View)],Ct,"Peptides",null),lt([i.decorators.func({"top-menu":"Bio | Analyze | SAR...",name:"Bio Peptides",outputs:[]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",Promise)],Ct,"peptidesDialog",null),lt([i.decorators.func(),ct(0,i.decorators.param({type:"viewer"})),ut("design:type",Function),ut("design:paramtypes",[r.Viewer]),ut("design:returntype",Promise)],Ct,"testInitFunctionPeptides",null),lt([i.decorators.panel({name:"Peptides",meta:{role:"widgets"},tags:["widgets","panel"]}),ct(0,i.decorators.param({options:{semType:"Macromolecule"}})),ut("design:type",Function),ut("design:paramtypes",[r.Column]),ut("design:returntype",Promise)],Ct,"peptidesPanel",null),lt([i.decorators.func({meta:{icon:"files/icons/peptide-sar-viewer.svg",role:"viewer"},name:"Sequence Variability Map",tags:["viewer"],description:"Peptides Sequence Variability Map Viewer",outputs:[{type:"viewer",name:"result"}]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.Viewer)],Ct,"monomerPosition",null),lt([i.decorators.func({meta:{icon:"files/icons/peptide-sar-vertical-viewer.svg",role:"viewer"},name:"Most Potent Residues",tags:["viewer"],description:"Peptides Most Potent Residues Viewer",outputs:[{type:"viewer",name:"result"}]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.Viewer)],Ct,"mostPotentResidues",null),lt([i.decorators.func({meta:{icon:"files/icons/sequence-statistics-viewer.svg",role:"viewer"},name:"Sequence Mutation Cliffs",description:"Mutation Cliffs Line Chart",tags:["viewer"],outputs:[{type:"viewer",name:"result"}]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.Viewer)],Ct,"mutationCliffs",null),lt([i.decorators.func({meta:{icon:"files/icons/logo-summary-viewer.svg",role:"viewer"},name:"Logo Summary Table",tags:["viewer"],outputs:[{type:"viewer",name:"result"}]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.Viewer)],Ct,"logoSummaryTable",null),lt([i.decorators.func({meta:{icon:"files/icons/sequence-statistics-viewer.svg",role:"viewer"},name:"Sequence Position Statistics",outputs:[{type:"viewer",name:"result"}],tags:["viewer"]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.Viewer)],Ct,"sequencePositionStatistics",null),lt([i.decorators.func({name:"Active peptide selection",outputs:[{type:"viewer",name:"result"}],meta:{role:"viewer"},tags:["viewer"]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.Viewer)],Ct,"clusterMaxActivity",null),lt([i.decorators.func({name:"Peptide Generation",description:"Generates new candidate peptides from monomer-position statistics, ranked by predicted activity",outputs:[{type:"viewer",name:"result"}],meta:{role:"viewer",icon:"files/icons/peptide-sar-vertical-viewer.svg"},tags:["viewer"]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.Viewer)],Ct,"peptideGeneration",null),lt([i.decorators.panel({name:"Manual Alignment",meta:{role:"widgets"},tags:["widgets","panel"]}),ct(0,i.decorators.param({options:{semType:"Monomer"}})),ut("design:type",Function),ut("design:paramtypes",[String]),ut("design:returntype",r.Widget)],Ct,"manualAlignment",null),lt([i.decorators.func({meta:{demoPath:"Bioinformatics | Peptide SAR",isDemoDashboard:"true"},name:"Peptide SAR",description:"Peptide SAR Analysis demo on peptide sequences in FASTA format"}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",Promise)],Ct,"macromoleculeSarFastaDemo",null),lt([i.decorators.func({meta:{cellType:"lst-pie-chart",gridChart:"true",role:"cellRenderer"},tags:["cellRenderer"],name:"LST Pie Chart",outputs:[{type:"grid_cell_renderer",name:"result"}]}),ut("design:type",Function),ut("design:paramtypes",[]),ut("design:returntype",r.GridCellRenderer)],Ct,"lstPiechartCellRenderer",null)},726(t,e,n){"use strict";n.d(e,{Z:()=>s});var i=n(4971),o=n(6082),r=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};class s{static getMonomerLib(){if(!this._monomerLibHelper)throw new Error("MonomerLib is not initialized");return this._monomerLibHelper.getMonomerLib()}static getSeqHelper(){if(!this._secHelper)throw new Error("SeqHelper is not initialized");return this._secHelper}static loadSeqHelper(){return r(this,void 0,void 0,function*(){var t;null!==(t=this._secHelper)&&void 0!==t||(this._secHelper=yield async function(){const t=o.Func.find({package:"Bio",name:"getSeqHelper"});if(0===t.length)throw new Error("Package 'Bio' must be installed for SeqHelper.");return(await t[0].prepare().call()).getOutputParamValue()}())})}static loadComponents(){return r(this,void 0,void 0,function*(){yield this.loadSeqHelper(),yield this.loadMonomerLib()})}static loadMonomerLib(){return r(this,void 0,void 0,function*(){var t;null!==(t=this._monomerLibHelper)&&void 0!==t||(this._monomerLibHelper=yield(0,i.pj)()),yield this._monomerLibHelper.awaitLoaded()})}}},1458(t,e,n){"use strict";n.d(e,{Ej:()=>c,Lw:()=>u,eW:()=>d,uz:()=>l});var i=n(4139),o=n(7471),r=n(5480),s=n(8774),a=n(5070);function l(t,e){return n=this,r=arguments,a=function*(t,e,n={}){var r,s;if(0===e.length)throw new Error(`PepAlgorithmError: Couldn't find any column of semType '${i.uF.MONOMER}'`);null!==(r=n.minActivityDelta)&&void 0!==r||(n.minActivityDelta=0),null!==(s=n.maxMutations)&&void 0!==s||(n.maxMutations=1);const a=new o.a,l=yield a.calc(t,e,n);return a.terminate(),l},new((s=void 0)||(s=Promise))(function(t,e){function i(t){try{l(a.next(t))}catch(t){e(t)}}function o(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s(function(t){t(n)})).then(i,o)}l((a=a.apply(n,r||[])).next())});var n,r,s,a}function u(t,e){const n=new Map;let i=999999,o=-999999,r=2,l=2;for(const u of t.keys()){const c=new Map;n.set(u,c);const h=t.get(u);for(const t of h.keys()){const n=h.get(t);if(0===n.size)continue;const u=new s.A(e.length,!1),d=new s.A(e.length,!1);for(const t of n.keys())u.setFast(t,!0),n.get(t).forEach(t=>u.setFast(t,!0)),d.setFast(t,!0);const f=(0,a.GT)(e,d,u);f.mask=u,i=Math.min(i,f.meanDifference),o=Math.max(o,f.meanDifference),r=Math.min(r,f.count),l=Math.max(l,f.count),c.set(t,f)}}return{stats:n,minDiff:i,maxDiff:o,minCount:r,maxCount:l}}function c(t,e,n,i={}){var o,r;null!==(o=i.isFiltered)&&void 0!==o||(i.isFiltered=!1);const l={general:{}},u=t.getRawData(),c=t.length;null!==(r=i.columns)&&void 0!==r||(i.columns=n.map(t=>t.name));const d=i.isFiltered?(0,a.pY)(e):void 0;for(const t of n){if(!i.columns.includes(t.name))continue;const n=t.getRawData(),o=t.categories,r={general:{}};for(let t=0;t<o.length;++t){const l=o[t];if(""===l)continue;const f=new Array(c).fill(!1);for(let o=0;o<c;++o)n[o]!==t||i.isFiltered&&!e.get(o)||(f[o]=!0);const m=s.A.fromValues(f);if(m.allFalse)continue;const p=(0,a.GT)(u,m,d,i.aggValue);r[l]=p,h(r.general,p)}l[t.name]=r,h(l.general,null,r.general)}return l}function h(t,e=null,n=null){var i,o,r,s,a,l,u,c,h,d,f,m,p,g,v,C,y;if(null===e&&null===n)throw new Error("MonomerPositionStatsError: either stats or summaryStats must be present");const b=null!==(i=null==e?void 0:e.count)&&void 0!==i?i:n.maxCount;null!==(o=t.maxCount)&&void 0!==o||(t.maxCount=b),t.maxCount<b&&(t.maxCount=b);const _=null!==(r=null==e?void 0:e.count)&&void 0!==r?r:n.minCount;null!==(s=t.minCount)&&void 0!==s||(t.minCount=_),t.minCount>_&&(t.minCount=_);const w=null!==(a=null==e?void 0:e.meanDifference)&&void 0!==a?a:n.maxMeanDifference;null!==(l=t.maxMeanDifference)&&void 0!==l||(t.maxMeanDifference=w),t.maxMeanDifference<w&&(t.maxMeanDifference=w);const A=null!==(u=null==e?void 0:e.meanDifference)&&void 0!==u?u:n.minMeanDifference;if(null!==(c=t.minMeanDifference)&&void 0!==c||(t.minMeanDifference=A),t.minMeanDifference>A&&(t.minMeanDifference=A),!isNaN(null!==(h=null==e?void 0:e.pValue)&&void 0!==h?h:NaN)){const i=null!==(d=null==e?void 0:e.pValue)&&void 0!==d?d:n.maxPValue;null!==(f=t.maxPValue)&&void 0!==f||(t.maxPValue=i),t.maxPValue<i&&(t.maxPValue=i);const o=null!==(m=null==e?void 0:e.pValue)&&void 0!==m?m:n.minPValue;null!==(p=t.minPValue)&&void 0!==p||(t.minPValue=o),t.minPValue>o&&(t.minPValue=o)}const S=null!==(g=null==e?void 0:e.ratio)&&void 0!==g?g:n.maxRatio;null!==(v=t.maxRatio)&&void 0!==v||(t.maxRatio=S),t.maxRatio<S&&(t.maxRatio=S);const T=null!==(C=null==e?void 0:e.ratio)&&void 0!==C?C:n.minRatio;null!==(y=t.minRatio)&&void 0!==y||(t.minRatio=T),t.minRatio>T&&(t.minRatio=T)}function d(t,e,n,i){const o=t.rowCount,l=t.getCol(e),u=l.getRawData(),c=l.categories,h=Array.from({length:c.length},()=>new s.A(o,!1));for(let t=0;t<o;++t)h[u[t]].setTrue(t);const d=n.map(t=>s.A.fromUint32Array(o,t.getRawData())),f=n.map(t=>t.name),m=i.getRawData(),p={},g={},v=t.filter.anyFalse?(0,a.pY)(t.filter):void 0;for(const t of Object.values(r.W)){const e=t===r.W.ORIGINAL?h:d,n=t===r.W.ORIGINAL?c:f,o=t===r.W.ORIGINAL?p:g;for(let t=0;t<e.length;++t){const r=e[t];o[n[t]]=r.allTrue||r.allFalse?{count:r.length,meanDifference:0,ratio:1,pValue:null,mask:r,mean:i.stats.avg}:(0,a.GT)(m,r,v)}}const C={};return C[r.W.ORIGINAL]=p,C[r.W.CUSTOM]=g,C}},3163(t,e,n){"use strict";n.d(e,{DX:()=>A,X5:()=>v,rW:()=>b,k8:()=>_,Yd:()=>y,rI:()=>C,FZ:()=>w});var i=n(7389),o=n(6082),r=n(4139),s=n(2003),a=n(1458);const l=rxjs;var u=n(912),c=n(5480),h=n(3541);n(7194);var d,f,m;!function(t){t.maxMonomerLength=".mm.cellRenderer.maxMonomerLength"}(d||(d={})),function(t){t.applyToBackground=".m.cellRenderer.applyToBackground"}(f||(f={})),function(t){t.MSA="MSA",t.classic="classic"}(m||(m={})),new class{constructor(){this.color="rgb(100,100,100)",this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=m.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0}};var p=n(726),g=n(854);function v(t,e){t.strokeStyle=o.Color.toHtml(o.Color.selectedRows),t.lineWidth=3,t.strokeRect(e.x+1,e.y+1,e.width-1,e.height-1)}function C(t,e,n){t.semType=r.uF.MONOMER,t.setTag(o.TAGS.CELL_RENDERER,r.uF.MONOMER),t.setTag(r.gp.ALPHABET,e),n&&t.setTag(f.applyToBackground,"true")}function y(t,e,n,i,r){var s,a,l,u,c,d,f,m,p,g;const C=r.width/2,y=Math.ceil(r.x+1+C),b=Math.ceil(r.y+1+r.height/2),_=Math.min(.9*C/2,.9*r.height/2);if(i instanceof h.UJ){const r=i.monomerPositionStats[n],s=r[e].pValue,a=r[e].meanDifference,l=1-r.general.maxPValue,u=1-r.general.minPValue,c=Math.min(l,u),h=l-c,d=u-c,f=Math.max(h,d),m=null===s?0:1-s-c,p=a>=0?m:-m,g=o.Color.toHtml(null===s?o.Color.lightLightGray:o.Color.scaleColor(p,-f,f,255)),v=Math.max(Math.abs(i.monomerPositionStats.general.minMeanDifference),i.monomerPositionStats.general.maxMeanDifference),w=Math.abs(a)/v,A=Math.floor(_*w);t.beginPath(),t.fillStyle=g,t.arc(y-C/2,b,A<3||null===s?3:A,0,2*Math.PI,!0),t.closePath(),t.fill()}else if(i instanceof h.J&&i.mutationCliffs&&i.cliffStats){const r=i.cliffStats.maxCount,u=i.cliffStats.minDiff,c=i.cliffStats.maxDiff,h=null===(l=null===(a=null===(s=i.cliffStats)||void 0===s?void 0:s.stats)||void 0===a?void 0:a.get(e))||void 0===l?void 0:l.get(n);if(h){const e=h.count,n=h.meanDifference,i=Math.floor(Math.abs(e/Math.max(r,2))*_),s=Math.max(Math.abs(u),Math.abs(c)),a=o.Color.toHtml(null===n?o.Color.lightLightGray:o.Color.scaleColor(n,-s,s,255));t.beginPath(),t.fillStyle=a,t.arc(y-C/2,b,i<3||0==e?3:i,0,2*Math.PI,!0),t.closePath(),t.fill()}}if(t.textBaseline="middle",t.textAlign="end",t.fillStyle="#606060",t.font="13px Roboto, Roboto Local, sans-serif",t.shadowBlur=5,t.shadowColor=o.Color.toHtml(o.Color.white),i instanceof h.J){let o=0;const r=null!==(f=null===(d=null===(c=null===(u=i.mutationCliffs)||void 0===u?void 0:u.get(e))||void 0===c?void 0:c.get(n))||void 0===d?void 0:d.entries())&&void 0!==f?f:null;if(null!==r)for(const[t,e]of r)o+=null!==(m=e.length)&&void 0!==m?m:0;0!==o&&t.fillText(o.toString(),y+C-5,b,C-5)}else if(i instanceof h.UJ){const o=i.monomerPositionStats,r=null===(g=null===(p=null==o?void 0:o[n])||void 0===p?void 0:p[e])||void 0===g?void 0:g.count;r&&t.fillText(r.toString(),y+C-5,b,C-5)}if(i instanceof h.J){const o=i.mutationCliffsSelection[n];o&&o.includes(e)&&v(t,r)}else if(i instanceof h.UJ){const o=i.invariantMapSelection[n];o&&o.includes(e)&&v(t,r)}}function b(t,e,n,i,r,s,a){a=o.Color.fromHtml(o.Color.toHtml(function(t){return(16777215&t|255<<24)>>>0}(a)));let l=r.toFixed(2);l.endsWith(".00")&&(l=r.toFixed(0)),l.endsWith("0")&&l.includes(".")&&(l=r.toFixed(1));const u=Math.min(13,Math.floor(s.width/40/l.length*6*13));t.fillStyle=o.Color.toHtml(a),t.fillRect(s.x,s.y,s.width,s.height),t.font=`${u}px Roboto, Roboto Local, sans-serif`,t.textAlign="center",t.textBaseline="middle",t.fillStyle=o.Color.toHtml(o.Color.getContrastColor(a)),t.fillText(l,s.x+s.width/2,s.y+s.height/2,s.width);const c=i[n];c&&c.includes(e)&&v(t,s)}function _(t,e,n,i){t.font="13px Roboto, Roboto Local, sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillStyle="#000",t.fillText(e.toString(),i.x+i.width/2,i.y+i.height/2,i.width),(n[c.W.CUSTOM].includes(e)||n[c.W.ORIGINAL].includes(e))&&v(t,i)}function w(t,e,n,c,h,d={x:0,y:0,mpStats:{},monomerPosition:{}}){var f;if(null!==(f=h.isSelectionTable)&&void 0!==f||(h.isSelectionTable=!1),0==Object.keys(d.mpStats).length&&(d.mpStats=e),h.isSelectionTable&&(!h.webLogoBounds||!h.cachedWebLogoTooltip))throw new Error("Peptides: Cannot set WebLogo renderer for selection table without `headerSelectedMonomers`, `webLogoBounds` and `cachedWebLogoTooltip` options.");const m=t.dataFrame;t.setOptions({colHeaderHeight:130});t.onCellRender.subscribe(t=>(t=>{var i,l,u,d;if(!(null===(i=t.cell)||void 0===i?void 0:i.isColHeader))return;const f=t.g,v=t.bounds,C=t.cell.tableColumn;f.save();try{if(f.beginPath(),f.clearRect(v.x,v.y,v.width,v.height),f.rect(v.x,v.y,v.width,v.height),f.clip(),(null==C?void 0:C.semType)===r.uF.MONOMER){let i;if(m.filter.anyFalse){null!==(l=(d=m).jsOnlyTemp)&&void 0!==l||(d.jsOnlyTemp={});const t=null!==(u=m.jsOnlyTemp[r.gp.M_P_STATS_CACHE])&&void 0!==u?u:{},e=null==t?void 0:t[C.name];if(t&&e&&e.filterLength===m.filter.length&&e.filterVersion===m.filter.version)i=e.stats[C.name];else{const e=(0,a.Ej)(c,m.filter,n,{isFiltered:!0,columns:[C.name]});i=e[C.name],t[C.name]={filterVersion:m.filter.version,stats:e,filterLength:m.selection.length}}m.jsOnlyTemp[r.gp.M_P_STATS_CACHE]=t}else i=h.isSelectionTable?(0,a.Ej)(c,m.filter,n,{isFiltered:!0,columns:[C.name]})[C.name]:e[C.name];if(!i)return;const y=Object.keys(i).sort((t,e)=>""===t||"-"===t?1:""===e||"-"===e?-1:0).filter(t=>"general"!==t);h.webLogoBounds()[C.name]=function(t,e,n,i,r,a,l,u={},c={}){var h,d,f,m,v,C,y,b,_;const w=window.devicePixelRatio;null!==(h=c.symbolStyle)&&void 0!==h||(c.symbolStyle="16px Roboto, Roboto Local, sans-serif"),null!==(d=c.upperLetterHeight)&&void 0!==d||(c.upperLetterHeight=12.2),null!==(f=c.upperLetterAscent)&&void 0!==f||(c.upperLetterAscent=.25),null!==(m=c.marginVertical)&&void 0!==m||(c.marginVertical=1),null!==(v=c.marginHorizontal)&&void 0!==v||(c.marginHorizontal=1),null!==(C=c.selectionWidth)&&void 0!==C||(c.selectionWidth=2),null!==(y=c.textHeight)&&void 0!==y||(c.textHeight=13),null!==(b=c.headerStyle)&&void 0!==b||(c.headerStyle=`bold ${c.textHeight*w}px Roboto, Roboto Local, sans-serif`);const A=(r.length-1)*c.upperLetterAscent;let S=(e.y+c.marginVertical)*w;const T=(e.height-2*c.marginVertical-A-1.25*c.textHeight)*w,E=(e.x+c.marginHorizontal)*w,N=Math.max(c.selectionWidth*w,.05*e.width*w),x=2*c.marginHorizontal+c.selectionWidth,M=(e.width-(x+c.marginHorizontal))*w,I=(e.x+x)*w,O=p.Z.getMonomerLib(),P={};for(const e of r){const i=T*(n[e].count/a),r=T*((null!==(_=u[e])&&void 0!==_?_:0)/a);if(P[e]=new o.Rect(I/w,S/w,M/w,i/w),t.resetTransform(),"-"!==e&&""!==e){const n=(0,s.zS)(e,5),a=t.measureText(n);r>0&&(t.lineWidth=N,t.line(E,S,E,S+r,o.Color.rowSelection));const l=O.getMonomerTextColor(g.oE.AA,e);t.fillStyle=l,t.textAlign="left",t.textBaseline="top",t.font=c.symbolStyle;const u=M/a.width,h=i/c.upperLetterHeight;t.setTransform(u,0,0,h,I,S),t.fillText(n,0,0,a.width)}S+=i+c.upperLetterAscent*w}return t.resetTransform(),t.fillStyle=o.Color.toHtml(o.Color.black),t.textAlign="center",t.textBaseline="top",t.font=c.headerStyle,t.fillText(i,(e.x+e.width/2)*w,(e.y+e.height-c.textHeight)*w),P}(f,v,i,C.name,y,m.filter.trueCount,h.colorPalette(),h.headerSelectedMonomers?h.headerSelectedMonomers()[C.name]:{}),t.preventDefault()}}catch(t){console.warn(`PeptidesHeaderLogoError: couldn't render WebLogo for column \`${C.name}\`. See original error below.`),console.warn(t)}finally{f.restore()}})(t));const v=n=>{var o;const s=t.hitTest(n.offsetX,n.offsetY);if((null==s?void 0:s.isColHeader)&&(null===(o=s.tableColumn)||void 0===o?void 0:o.semType)===r.uF.MONOMER){const t=function(t,e,n){const i=n[t.tableColumn.name];if(!i)return null;for(const[n,o]of Object.entries(i)){const i=e.offsetX>=o.x&&e.offsetX<=o.x+o.width,r=e.offsetY>=o.y&&e.offsetY<=o.y+o.height;if(i&&r)return{monomerOrCluster:n,positionOrClusterType:t.tableColumn.name}}return null}(s,n,h.webLogoBounds());if(null===t)return void(h.isSelectionTable||null==h.unhighlightCallback||h.unhighlightCallback());d.monomerPosition=t;const o=m.filter.anyFalse?m.clone(m.filter):m,r=o.getCol(c.name);!function(t,e,n,o,r,s){if("click"!==t.type||r.isSelectionTable||null==r.selectionCallback){const a=`${e.positionOrClusterType} = ${e.monomerOrCluster}`;r.cachedWebLogoTooltip().bar===a?i.tooltip.show(r.cachedWebLogoTooltip().tooltip,t.clientX,t.clientY):(r.cachedWebLogoTooltip().bar=a,s.x=t.clientX,s.y=t.clientY,s.monomerPosition=e,r.cachedWebLogoTooltip().tooltip=(0,u.Y)(n,o,[],s))}else r.selectionCallback(e,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey})}(n,t,o,r,h,d),h.isSelectionTable||null==h.highlightCallback||h.highlightCallback(t,m,e)}else null!=h.unhighlightCallback&&h.unhighlightCallback()};l.fromEvent(t.overlay,"mousemove").subscribe(t=>v(t)),l.fromEvent(t.overlay,"click").subscribe(t=>v(t)),l.fromEvent(t.overlay,"mouseleave").subscribe(()=>{null!=h.unhighlightCallback&&h.unhighlightCallback()})}class A extends o.GridCellRenderer{constructor(){super(...arguments),this.colorCacheKey="lst-pie-chart-color-cache",this.HoverTempKey="lst-pie-chart-hovered-sector",this.hoverSeparator=",,,,,"}get name(){return"LST Pie Chart"}get cellType(){return"lst-pie-chart"}get defaultWidth(){return 80}get defaultHeight(){return 80}categoryNumberCache(t){return t.temp[this.colorCacheKey]||(t.temp[this.colorCacheKey]={}),t.temp[this.colorCacheKey]}getPrevHoveredSector(t){return t.temp[this.HoverTempKey]}onMouseMove(t,e){const n=this.getPrevHoveredSector(t.cell.column),o=()=>{t.cell.column.temp[this.HoverTempKey]=null,i.tooltip.hide(),null!==n&&t.grid.invalidate()},r=t.cell.value;if(!r)return void o();const s=e.offsetX-t.bounds.midX,a=e.offsetY-t.bounds.midY,l=Math.sqrt(s*s+a*a),u=Math.atan2(a,s),c=u<0?u+2*Math.PI:u;if(l>Math.min(t.bounds.width,t.bounds.height)/2-2)return void o();let h;try{h=JSON.parse(r)}catch(e){return void o()}const d=new Float64Array(Object.keys(h).length+1),f=Object.values(h).reduce((t,e)=>t+e,0);d[Object.keys(h).length]=2*Math.PI;let m=0,p=0;for(const t of Object.values(h))d[p++]=m,m+=2*Math.PI*t/f;let g=-1;for(let t=0;t<d.length-1;t++)if(c>=d[t]&&c<d[t+1]){g=t;break}if(-1===g)return void o();const v=Object.keys(h)[g],C=h[v],y=(C/f*100).toFixed(2);i.tooltip.show(i.h1(`${v}: ${C} (${y}%)`),e.x+16,e.y+16);const b=t.cell.rowIndex.toString()+this.hoverSeparator+v;t.cell.column.temp[this.HoverTempKey]=b,n!==b&&t.grid.invalidate()}render(t,e,n,i,r,s,a){const l=s.cell.dataFrame,u=new o.Rect(e,n,i,r).fitSquare().inflate(-2,-2);if(i<5||r<5||!l)return;const c=s.cell.value;if(t.clearRect(e,n,i,r),!c)return;let h;try{h=JSON.parse(c)}catch(t){return}const d=Object.values(h).reduce((t,e)=>t+e,0);let f=0;const m=Object.fromEntries(Object.keys(h).map(t=>[t,255])),p=s.cell.column.temp[this.HoverTempKey];if(p&&2===p.split(this.hoverSeparator).length){const[t,e]=p.split(this.hoverSeparator);if(t===s.cell.rowIndex.toString()){for(const[t,e]of Object.entries(h))m[t]=100;m[e]=255}}const g=Math.min(i,r)/2.2;for(const[e,n]of Object.entries(h)){const i=2*Math.PI*n/d;t.beginPath(),t.moveTo(u.midX,u.midY),t.arc(u.midX,u.midY,g,f,f+i),f+=i;const r=this.categoryNumberCache(s.cell.column);r[e]||(r[e]=Object.keys(r).length,s.cell.column.temp[this.colorCacheKey]=r),t.fillStyle=o.Color.toHtml(o.Color.setAlpha(o.Color.getCategoricalColor(r[e]),m[e])),t.fill(),t.strokeStyle=o.Color.toRgb(o.Color.lightGray),t.stroke();const a=e;t.fillStyle=o.Color.toRgb(o.Color.white),t.font="9px Arial";const l=t.measureText(a).width,c=f-i/2;for(let e=.8;e>=.4;e-=.05){const n=g*e,o=u.midX+Math.cos(c)*n,r=u.midY+Math.sin(c)*n;if([[o-l/2-2,r],[o+l/2+2,r]].every(t=>{const e=Math.sqrt(Math.pow(t[0]-u.midX,2)+Math.pow(t[1]-u.midY,2)),n=Math.atan2(t[1]-u.midY,t[0]-u.midX),o=n<0?n+2*Math.PI:n;return e<g-2&&o>f-i&&o<f})){t.fillText(a,o,r);break}}}}}},4139(t,e,n){"use strict";n.d(e,{$2:()=>i,gp:()=>r,i6:()=>o,rg:()=>a,uF:()=>s,wf:()=>l});var i,o,r,s,a,l,u,c=n(6082);!function(t){t.SPLIT_COL="~split",t.ACTIVITY="Activity",t.ACTIVITY_SCALED="Scaled activity",t.MONOMER="AAR",t.POSITION="Pos",t.P_VALUE="pValue",t.MEAN_DIFFERENCE="Mean difference",t.COUNT="Count",t.RATIO="Ratio",t.MEAN="Mean",t.TOTAL_COUNT="∑"}(i||(i={})),function(t){t.MEMBERS="Members",t.WEB_LOGO="WebLogo",t.DISTRIBUTION="Distribution",t.MEAN_DIFFERENCE="Mean difference",t.P_VALUE="P-Value",t.RATIO="Ratio",t.CLUSTER="Cluster"}(o||(o={})),function(t){t.MONOMER="monomer",t.POSITION="pos",t.SEPARATOR="separator",t.ALPHABET="alphabet",t.FILTER="filter",t.SAR_MODE="sarMode",t.VISIBLE="visible",t.SETTINGS="settings",t.CUSTOM_CLUSTER="customCluster",t.MONOMER_POSITION_MODE="monomerPositionMode",t.MULTIPLE_VIEWS="isMultipleViews",t.IDENTITY_TEMPLATE="Identity template",t.SIMILARITY_TEMPLATE="Similarity template",t.ANALYSIS_COL="isAnalysisCol",t.POSITION_COL="isPositionCol",t.M_P_STATS_CACHE=".MPStatsCache",t.INVARIANT_MAP_COLOR_CACHE=".InvariantMapColorCache",t.INVARIANT_MAP_COLOR_MAX_CACHE=".InvariantMapColorMaxCache",t.INVARIANT_MAP_COLOR_MIN_CACHE=".InvariantMapColorMinCache"}(r||(r={})),function(t){t.MONOMER="Monomer",t.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference"}(s||(s={})),function(t){t.NONE="none",t.LG="lg",t.MINUS_LG="-lg"}(a||(a={})),function(t){t.HIGH="High",t.LOW="Low"}(l||(l={})),function(t){t.LST="lst-",t.MP="mp-",t.MPR="mpr-",t.WL="wl-"}(u||(u={}));const h=Object.values(c.AGG).filter(t=>![c.AGG.FIRST,c.AGG.KEY,c.AGG.PIVOT,c.AGG.SELECTED_ROWS_COUNT].includes(t)),d={[c.AGG.TOTAL_COUNT]:"totalCount",[c.AGG.VALUE_COUNT]:"valueCount",[c.AGG.UNIQUE_COUNT]:"uniqueCount",[c.AGG.MISSING_VALUE_COUNT]:"missingValueCount",[c.AGG.MIN]:"min",[c.AGG.MAX]:"max",[c.AGG.SUM]:"sum",[c.AGG.MED]:"med",[c.AGG.AVG]:"avg",[c.AGG.STDEV]:"stdev",[c.AGG.VARIANCE]:"variance",[c.AGG.SKEW]:"skew",[c.AGG.KURT]:"kurt",[c.AGG.Q1]:"q1",[c.AGG.Q2]:"q2",[c.AGG.Q3]:"q3"};n.d(e,["To",0,"ColumnName","V5",0,h,"zW",0,d])},8608(t,e,n){"use strict";n.d(e,{$s:()=>T,AN:()=>i,AY:()=>h,B2:()=>N,BE:()=>y,BX:()=>I,CD:()=>_,F2:()=>p,FZ:()=>g,Lv:()=>M,Y1:()=>d,Z7:()=>v,ZR:()=>S,dl:()=>A,eY:()=>m,qx:()=>f,sg:()=>x,vW:()=>w,vY:()=>b,zm:()=>E,zz:()=>C});var i,o=n(7389),r=n(6082),s=n(4328),a=n(4139),l=n(8774),u=n(144),c=n.n(u);function h(t){var e;return null!==(e=t.getTag(a.gp.SEPARATOR))&&void 0!==e?e:""}function d(t,e=a.rg.NONE){let n=t=>t;switch(e){case a.rg.NONE:break;case a.rg.LG:n=t=>Math.log10(t);break;case a.rg.MINUS_LG:n=t=>-Math.log10(t);break;default:throw new Error(`ScalingError: method \`${e}\` is not available.`)}const i=t.getRawData(),o=r.Column.float(a.$2.ACTIVITY,t.length).init(t=>{const e=i[t];return e===r.FLOAT_NULL||e===r.INT_NULL?e:n(e)});return o.setTag(a.gp.ANALYSIS_COL,"true"),o.setTag(r.TAGS.FORMULA,e),o}function f(t){var e,n,i,o;const r=t.columns.bySemTypeAll(a.uF.MONOMER),s={},l=t.filter.clone().and(t.selection).getSelectedIndexes();for(const t of l)for(const a of r){const r=a.get(t);r&&(null!==(e=s[i=a.name])&&void 0!==e||(s[i]={}),null!==(n=(o=s[a.name])[r])&&void 0!==n||(o[r]=0),s[a.name][r]+=1)}return s}function m(t){return{name:t.name,cat:t.categories,rawData:t.getRawData()}}function p(t,e,n={}){var i;const s=[],l=t.dataFrame.getCol(a.$2.SPLIT_COL).categories;for(let t=0;t<l.length;++t){if(!l[t])continue;const e=r.Color.toHtml(r.Color.categoricalPalette[t%r.Color.categoricalPalette.length]),a=o.label(null!==(i=n[l[t]])&&void 0!==i?i:l[t],{style:{color:e}});s.push(a)}const u=o.divV([o.divV(s),t.root,o.tableFromMap(e)]);return t.root.style.maxHeight="75px",u}function g(t,e,n){const o=n.filter,s=e.clone().and(o),l=t.length,u=t.getRawData(),c=o.trueCount,h=new Float32Array(c+s.trueCount),d=new Array(h.length);for(let t=0,e=0,n=0;t<l;++t){if(!o.get(t))continue;const r=s.get(t);h[e]=u[t],d[e]=r?i.SELECTION:i.ALL,e++,r&&(h[c+n]=u[t],d[c+n]=i.ALL,++n)}const f=r.Column.fromStrings(a.$2.SPLIT_COL,d),m=[i.ALL,i.SELECTION];return f.setCategoryOrder(m),f.meta.colors.setCategorical(),r.DataFrame.fromColumns([r.Column.fromFloat32Array(a.$2.ACTIVITY,h),f])}function v(t,e,n){t.dataFrame||r.DataFrame.fromColumns([t]);const i=t.dataFrame.filter,o=t.getRawData(),s=Array.from(new Set(e.keys())).map(t=>Number(t)).filter(t=>i.get(t)),l=new Set;for(const t of e.values())for(const e of t)l.add(e);const u=Array.from(l).filter(t=>i.get(t)),c=s.length+u.length,h=new Array(c),d=new Float32Array(c);for(let t=0;t<s.length;++t){const e=s[t];d[t]=o[e],h[t]=n}for(let t=0;t<u.length;++t){const e=u[t];d[s.length+t]=o[e],h[s.length+t]="Mutated"}const f=r.Column.fromStrings(a.$2.SPLIT_COL,h),m=[n,"Mutated"];return f.setCategoryOrder(m),f.meta.colors.setCategorical(),r.DataFrame.fromColumns([r.Column.fromFloat32Array(a.$2.ACTIVITY,d),f])}function C(t){const e=o.iconFA("expand-alt",()=>{const e=t.dataFrame.plot.grid();b(e,!1),e.root.style.height="100%";const n=o.dialog(t.dataFrame.name);n.add(e.root),n.showModal(!0),e.invalidate()},"Full screen");t.root.appendChild(e),e.style.position="absolute",e.style.right="0px",e.style.top="0px",e.style.visibility="hidden",t.root.addEventListener("mouseenter",t=>{e.style.visibility="visible"}),t.root.addEventListener("mouseleave",t=>{e.style.visibility="hidden"})}function y(t,e,n,i){const r=o.iconFA("expand-alt",()=>{const e=i(),n=o.dialog(t);n.add(e),n.show({resizable:!0,modal:!0,width:window.innerWidth-60,x:30,y:30,height:window.innerHeight-60})},"Expand to full screen");r.style.marginLeft="auto",r.style.marginRight="15px",n.addEventListener("mouseenter",()=>{r.style.visibility="visible"}),n.addEventListener("mouseleave",()=>{r.style.visibility="hidden"}),e.appendChild(r)}function b(t,e=!0){t.props.allowEdit=!1,t.props.showReadOnlyNotifications=!1,t.props.allowRowSelection=!1,t.props.allowBlockSelection=!1,t.props.allowColSelection=!1,t.props.showRowHeader=!1,t.props.showCurrentRowIndicator=!1,t.root.style.width="100%",t.root.style.maxWidth="100%",e&&t.autoSize(1e3,175,0,0,!0)}function _(t){for(const e of Object.values(t))if(0!==e.length)return!1;return!0}function w(t,e,n){const i=t[e.positionOrClusterType],o=i.indexOf(e.monomerOrCluster);if(n.shiftPressed&&n.ctrlPressed)-1!==o&&i.splice(o,1);else if(n.ctrlPressed)-1===o?i.push(e.monomerOrCluster):i.splice(o,1);else if(n.shiftPressed)-1===o&&i.push(e.monomerOrCluster);else{const n=Object.keys(t);t={};for(const i of n)t[i]=[],i===e.positionOrClusterType&&t[i].push(e.monomerOrCluster)}return t}function A(t,e,n){if(!e)return;const i=new l.A(e.rowCount);if(t.positionOrClusterType===a.$2.MONOMER){const e=Object.values(n);for(const n of e){const e=n[t.monomerOrCluster];void 0!==e&&i.or(e.mask)}}else{const e=n[t.positionOrClusterType];if(void 0!==e){const n=e[t.monomerOrCluster];void 0!==n&&i.or(n.mask)}}e.rows.highlight(t=>i.getBit(t))}function S(t){const e={};for(const n of t)e[n.name]=[];return e}function T(t,e){return t.sequenceColumnName===e.sequenceColumnName&&t.activityColumnName===e.activityColumnName&&t.activityScaling===e.activityScaling}function E(t,e,n,i){const o=Object.entries(n),r=i?Object.entries(i).filter(t=>!e.includes(t[0])||n[t[0]]!==t[1]):[];return o.concat(r).filter(e=>t.columns.contains(e[0])&&t.col(e[0]).matches("numerical"))}function N(t,e=2){return t.columns.bySemTypeAll(r.SEMTYPE.MACROMOLECULE).length>0&&c()(t.columns.numerical).toArray().length>0&&t.rowCount>=e}function x(t,e=500){let n;return(...i)=>{return o=this,r=void 0,a=function*(){return new Promise(o=>{clearTimeout(n),n=setTimeout(()=>o(t(...i)),e)})},new((s=void 0)||(s=Promise))(function(t,e){function n(t){try{l(a.next(t))}catch(t){e(t)}}function i(t){try{l(a.throw(t))}catch(t){e(t)}}function l(e){var o;e.done?t(e.value):(o=e.value,o instanceof s?o:new s(function(t){t(o)})).then(n,i)}l((a=a.apply(o,r||[])).next())});var o,r,s,a}}function M(){return"isInDemo"in s.shell&&!!s.shell.isInDemo}function I(t){return{set:function(e,n){return t[e]=n,this}}}!function(t){t.SELECTION="Selection",t.ALL="All",t.PEPTIDES_SELECTION="Peptides selection"}(i||(i={}))},7471(t,e,n){"use strict";n.d(e,{a:()=>i});class i{constructor(){const t=navigator.hardwareConcurrency;this._workerCount=Math.max(t-2,1),this._workers=new Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u(216),n.b)))}calc(t,e){return n=this,i=arguments,r=function*(t,e,n={}){const i=new Map;try{const o=t.length,r=new Array(this._workerCount),s=o*(o-1)/2;this._workerCount=Math.min(this._workerCount,s);const a=s/this._workerCount;e.forEach(t=>{var e;t.cat=null===(e=t.cat)||void 0===e?void 0:e.slice()});for(let i=0;i<this._workerCount;i++)r[i]=new Promise((o,r)=>{const l=Math.floor(i*a),u=i===this._workerCount-1?s:Math.floor((i+1)*a);this._workers[i].postMessage({startIdx:l,endIdx:u,activityArray:t,monomerInfoArray:e,settings:n}),this._workers[i].onmessage=({data:{pos:t,seq1Idxs:e,seq2Idxs:n,error:s}})=>{var a;s?(null===(a=this._workers[i])||void 0===a||a.terminate(),r(s)):(this._workers[i].terminate(),o({pos:t,seq1Idxs:e,seq2Idxs:n}))}});const l=yield Promise.all(r),u=new Map;e.forEach((t,e)=>{u.set(t.name,e)}),l.filter(Boolean).forEach(t=>{for(let n=0;n<t.pos.length;n++){const o=u.get(t.pos[n]),r=e[o].rawData[t.seq1Idxs[n]],s=e[o].cat[r],a=e[o].rawData[t.seq2Idxs[n]],l=e[o].cat[a];i.has(s)||i.set(s,new Map),i.has(l)||i.set(l,new Map);const c=i.get(s),h=i.get(l);c.has(t.pos[n])||c.set(t.pos[n],new Map),h.has(t.pos[n])||h.set(t.pos[n],new Map);const d=c.get(t.pos[n]),f=h.get(t.pos[n]);d.has(t.seq1Idxs[n])||d.set(t.seq1Idxs[n],[]),f.has(t.seq2Idxs[n])||f.set(t.seq2Idxs[n],[]);const m=d.get(t.seq1Idxs[n]),p=f.get(t.seq2Idxs[n]);m.push(t.seq2Idxs[n]),p.push(t.seq1Idxs[n])}})}catch(t){this.terminate(),console.error(t)}return i},new((o=void 0)||(o=Promise))(function(t,e){function s(t){try{l(r.next(t))}catch(t){e(t)}}function a(t){try{l(r.throw(t))}catch(t){e(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o(function(t){t(n)})).then(s,a)}l((r=r.apply(n,i||[])).next())});var n,i,o,r}terminate(){var t;null===(t=this._workers)||void 0===t||t.forEach(t=>{try{null==t||t.terminate()}catch(t){console.error(t)}})}}},5070(t,e,n){"use strict";n.d(e,{pY:()=>l,hX:()=>a,I_:()=>h,m2:()=>d,lh:()=>c,GT:()=>u,J1:()=>f});var i=n(6082),o=n(6572),r=n(8774),s=n(4139);const a=(t,e)=>`${t}(${e})`;function l(t){return r.A.fromUint32Array(t.length,new Uint32Array(t.getBuffer().buffer))}function u(t,e,n,r){var s;if(t.length!==e.length&&16!==t.length||n&&t.length!==n.length&&16!==t.length)throw new Error("PeptidesError: Data and bit array have different lengths");n&&n.allTrue&&(n=void 0);const a=n?e.clone().and(n):e,l=new Float32Array(a.trueCount()),u=new Float32Array(n?n.trueCount()-a.trueCount():a.falseCount());let c;if(r)try{c=null===(s=i.DataFrame.fromColumns([r.col]).clone(function(t){return i.BitSet.fromBytes(t.buffer.buffer,t.length)}(a)).col(r.col.name))||void 0===s?void 0:s.aggregate(r.type)}catch(t){console.error(t)}let h=0,d=0;for(let i=0;i<e.length;++i)n&&!n.getBit(i)||(e.getBit(i)?l[h++]=t[i]:u[d++]=t[i]);const f=l.length+u.length,m=l.reduce((t,e)=>t+e,0)/Math.max(l.length,1);if(l.length<2||u.length<2){const t=u.reduce((t,e)=>t+e,0)/Math.max(u.length,1);return{count:l.length,pValue:null,mean:m,meanDifference:m-t,ratio:l.length/f,mask:a,aggValue:c}}const p=function(t,e,n=!1,i=!1){if(t.length<=1||e.length<=1)throw new Error(`StatisticsError: Wrong sample size; expected at least 2, got ${Math.min(t.length,e.length)})`);const r=o.mean(t),s=o.mean(e),a=o.variance(t),l=o.variance(e),u=t.length,c=e.length;let h,d,f;if(n){const t=a/u,e=l/c,n=(r-s)/Math.sqrt(t+e);d=o.normal.pdf(n,0,1),h=1-d,f=2*(d<h?d:h)}else if(i){const t=u+c-2,e=(a*(u-1)+l*(c-1))/t,n=Math.sqrt(u*c/(u+c))*(r-s)/e;h=1-o.studentt.cdf(n,t),d=o.studentt.cdf(n,t),f=2*(d<h?d:h)}else{const t=a/u,e=l/c,n=(r-s)/Math.sqrt(t+e),i=Math.pow(t+e,2)/(Math.pow(t,2)/(u-1)+Math.pow(e,2)/(c-1));d=o.studentt.cdf(n,i),h=1-d,f=2*(d<h?d:h)}return{"p-value":f,"Mean difference":r-s,"p-value more":h,"p-value less":d}}(l,u),g=p["Mean difference"];return{count:l.length,pValue:p[g>=0?"p-value more":"p-value less"],mean:m,meanDifference:g,ratio:l.length/f,mask:a,aggValue:c}}function c(t,e,n){const o=s.zW[e],r=i.Stats.fromColumn(t,n);if(!(o in r))throw new Error(`Aggregation type ${o} is not supported`);return r[o]}function h(t,e,n={}){var i,o;null!==(i=n.filterDf)&&void 0!==i||(n.filterDf=!1),null!==(o=n.fractionDigits)&&void 0!==o||(n.fractionDigits=3);const r=!n.filterDf||!t.filter.anyFalse||n.mask&&n.mask.length!==t.filter.trueCount?t:t.clone(t.filter),s={};for(const[t,i]of e){const e=a(i,t),o=c(r.getCol(t),i,n.mask);s[e]=o.toFixed(n.fractionDigits)}return s}function d(t,e,n,i){var o;null!==(o=i.fractionDigits)&&void 0!==o||(i.fractionDigits=3);const r={};for(const[o,s]of n){const n=a(s,o),l=t.get(n,e);r[n]=l.toFixed(i.fractionDigits)}return r}function f(t,e,n){var o;const r=t.col(e.substring(5,e.length-1));if(!r||!r.matches("categorical"))return"{}";null!=n||(n=i.BitSet.create(t.rowCount,()=>!0));const s=r.getRawData(),a=new Map;for(let t=-1;-1!==(t=n.findNext(t,!0));)a.set(s[t],(null!==(o=a.get(s[t]))&&void 0!==o?o:0)+1);const l={};for(const[t,e]of a)l[r.categories[t]]=e;return JSON.stringify(l)}},912(t,e,n){"use strict";n.d(e,{D:()=>u,Y:()=>c});var i=n(7389),o=n(6082),r=n(4139),s=n(7654),a=n(8608),l=n(5070);function u(t,e,n,i){var o,s,a;return null!==(o=i.fromViewer)&&void 0!==o||(i.fromViewer=!1),null!==(s=i.isMutationCliffs)&&void 0!==s||(i.isMutationCliffs=!1),null!==(a=i.isMostPotentResidues)&&void 0!==a||(i.isMostPotentResidues=!1),i.monomerPosition.positionOrClusterType!==r.$2.MONOMER&&c(t,e,n,i),!0}function c(t,e,n,r){var u,c,h,d,f,m,p,g,v;if(null!==(u=r.fromViewer)&&void 0!==u||(r.fromViewer=!1),null!==(c=r.isMutationCliffs)&&void 0!==c||(r.isMutationCliffs=!1),null!==(h=r.isMostPotentResidues)&&void 0!==h||(r.isMostPotentResidues=!1),null!==(d=r.additionalStats)&&void 0!==d||(r.additionalStats={}),r.cliffStats&&r.isMutationCliffs&&r.cliffIndexes){const u=null===(g=null===(p=r.cliffStats)||void 0===p?void 0:p.get(r.monomerPosition.monomerOrCluster))||void 0===g?void 0:g.get(r.monomerPosition.positionOrClusterType);if(!u)return null;const c=o.BitSet.fromBytes(u.mask.buffer.buffer,e.length);c.and(t.filter);const h=(0,s.M1)((0,a.Z7)(e,r.cliffIndexes,r.monomerPosition.monomerOrCluster),!0),d="MP in cliffs count",f=(0,s.QD)(u,{countName:d});r.fromViewer&&(f["Mean difference"]=`${f["Mean difference"]} (Color)`,f[d]&&(f[d]=`${f[d]} (Size)`),r.additionalStats["Unique count"]=c.trueCount.toString());const m=null!==(v=r.aggrColValues)&&void 0!==v?v:(0,l.I_)(t,n,{mask:c}),C=Object.assign(Object.assign(Object.assign({},r.additionalStats),f),m),y=(0,a.F2)(h,C);return i.tooltip.show(y,r.x,r.y),y}{const u=r.mpStats[r.monomerPosition.positionOrClusterType][r.monomerPosition.monomerOrCluster];if(!(null==u?void 0:u.count))return null;const c=o.BitSet.fromBytes(u.mask.buffer.buffer,e.length);c.and(t.filter);const h=(0,s.M1)((0,a.FZ)(e,c,t),!0),d=(0,s.QD)(u);r.fromViewer&&(d["Mean difference"]=`${d["Mean difference"]}${r.isMostPotentResidues?" (size)":""}`,d["p-value"]&&(d["p-value"]=`${d["p-value"]}${r.isMostPotentResidues?" (color)":""}`));const p=null!==(f=r.aggrColValues)&&void 0!==f?f:(0,l.I_)(t,n,{mask:c}),g=Object.assign(Object.assign(Object.assign({},r.additionalStats),d),p);for(const[t,e]of Object.entries(null!==(m=r.postfixes)&&void 0!==m?m:{}))g[t]&&(g[t]=`${g[t]}${e}`);const v=(0,a.F2)(h,g);return i.tooltip.show(v,r.x,r.y),r.fromViewer||setTimeout(()=>h.props.legendVisibility="Never",100),v}}},115(t,e,n){"use strict";n.d(e,{GI:()=>a,av:()=>s});var i=n(1199),o=n(4329);const r="WebGPU is not supported on this device";class s{constructor(){this.maxIterations=16,this.inflation=1.4,this.threshold=70,this.distanceF=i.Z.NEEDLEMANN_WUNSCH,this.gapOpen=1.5,this.gapExtend=.2,this.fingerprintType="Morgan",this.useWebGPU=!1,this.minClusterSize=5,this.webGPUDescription=r,this.webGPUDescriptionPromise=(0,o._)().then(t=>{t&&(this.webGPUDescription=t)})}}class a{constructor(t){this.distanceF=i.Z.NEEDLEMANN_WUNSCH,this.gapOpen=1.5,this.gapExtend=.2,this.clusterEmbeddings=!0,this.epsilon=.01,this.minPts=4,this.fingerprintType="Morgan",this.clusterEmbeddings=!!t}}n.d(e,["Ku",0,r])},5480(t,e,n){"use strict";n.d(e,{W:()=>A,s:()=>T});var i=n(7389),o=n(4328),r=n(6082),s=n(7233),a=n.n(s),l=n(3743),u=n(4139),c=n(3163),h=n(4326),d=n(5070),f=n(144),m=n.n(f),p=n(7654),g=n(8608),v=n(8774),C=n(3262),y=n(1458),b=n(3077),_=n(726);const w=(t,e)=>`${t}(${e})`;var A,S;!function(t){t.ORIGINAL="original",t.CUSTOM="custom"}(A||(A={})),function(t){t.GENERAL="General",t.STYLE="WebLogo",t.AGGREGATION="Aggregation"}(S||(S={}));class T extends r.JsViewer{constructor(){super(),this.bitsets=[],this.keyPress=!1,this.currentRowIndex=null,this._scaledActivityColumn=null,this._webLogoCacheGeneration=0,this._viewerGrid=null,this._clusterStats=null,this._clusterSelection=null,this._logoSummaryTable=null,this._positionColumns=null,this.root.classList.add("peptides-viewer-show-title"),this.sequenceColumnName=this.column("sequence",{category:S.GENERAL,nullable:!1}),this.clustersColumnName=this.column("clusters",{category:S.GENERAL,nullable:!1,columnTypeFilter:r.TYPE.CATEGORICAL}),this.activityColumnName=this.column("activity",{category:S.GENERAL,nullable:!1,columnTypeFilter:r.TYPE.NUMERICAL}),this.activityScaling=this.string("activityScaling",u.rg.NONE,{category:S.GENERAL,choices:Object.values(u.rg)}),this.webLogoMode=this.string("webLogoMode",h.fH.Entropy,{choices:[h.fH.full,h.fH.Entropy],category:S.STYLE}),this.membersRatioThreshold=this.float("membersRatioThreshold",.1,{min:0,max:1,category:S.STYLE});const t=[r.AGG.KEY,r.AGG.PIVOT,r.AGG.MISSING_VALUE_COUNT,r.AGG.SKEW,r.AGG.KURT,r.AGG.SELECTED_ROWS_COUNT],e=Object.values(r.AGG).filter(e=>!t.includes(e));this.webLogoAggregationType=this.string("webLogoAggregationType",r.AGG.TOTAL_COUNT,{category:S.STYLE,choices:e,description:"Aggregation method for WebLogo position heights"}),this.webLogoAggregationColumnName=this.column("webLogoAggregationColumnName",{defaultValue:null,category:S.STYLE,nullable:!0,columnTypeFilter:r.TYPE.NUMERICAL,description:`Column with values to aggregate for WebLogo position heights.\n Used if aggregation type is not '${r.AGG.TOTAL_COUNT}'.`}),this.columns=this.columnList("columns",[],{category:S.AGGREGATION}),this.aggregation=this.string("aggregation",r.AGG.AVG,{category:S.AGGREGATION,choices:u.V5})}get model(){return l.i.getInstance(this.dataFrame)}get viewerGrid(){var t;return null!==(t=this._viewerGrid)&&void 0!==t||(this._viewerGrid=this.createLogoSummaryTableGrid()),this._viewerGrid}get clusterStats(){var t;return null!==(t=this._clusterStats)&&void 0!==t||(this._clusterStats=(0,y.eW)(this.dataFrame,this.clustersColumnName,this.customClusters.toArray(),this.getScaledActivityColumn())),this._clusterStats}get clusterSelection(){var t;return null!==(t=this._clusterSelection)&&void 0!==t||(this._clusterSelection=this.initClusterSelection({notify:!1})),this._clusterSelection}set clusterSelection(t){this._clusterSelection=t,this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),this.model.analysisView.grid.invalidate()}get logoSummaryTable(){var t;return null!==(t=this._logoSummaryTable)&&void 0!==t||(this._logoSummaryTable=this.createLogoSummaryTable()),this._logoSummaryTable}set logoSummaryTable(t){this._logoSummaryTable=t}get positionColumns(){var t,e,n,i;if(null!=this._positionColumns)return this._positionColumns;const o=t=>{const e=this.model.findViewer(t);return this.sequenceColumnName===(null==e?void 0:e.sequenceColumnName)?e._positionColumns:null};return null!=this.model.positionColumns&&this.sequenceColumnName===(null===(t=this.model.settings)||void 0===t?void 0:t.sequenceColumnName)&&(this._positionColumns=this.model.positionColumns),null!==(e=this._positionColumns)&&void 0!==e||(this._positionColumns=null!==(i=null!==(n=o(l.q.SEQUENCE_VARIABILITY_MAP))&&void 0!==n?n:o(l.q.MOST_POTENT_RESIDUES))&&void 0!==i?i:(0,b.R)(this.dataFrame.getCol(this.sequenceColumnName),_.Z.getSeqHelper()).columns.toList()),this._positionColumns}get isClusterSelectionEmpty(){return 0===this.clusterSelection[A.ORIGINAL].length+this.clusterSelection[A.CUSTOM].length}get customClusters(){const t={};return t[u.gp.CUSTOM_CLUSTER]="1",m()(this.dataFrame.columns.byTags(t))}getScaledActivityColumn(t=!1){var e,n,i;return(null===(e=this.model.settings)||void 0===e?void 0:e.activityColumnName)===this.activityColumnName&&(null===(n=this.model.settings)||void 0===n?void 0:n.activityScaling)===this.activityScaling&&(this._scaledActivityColumn=this.model.getScaledActivityColumn(t)),null!==(i=this._scaledActivityColumn)&&void 0!==i||(this._scaledActivityColumn=(0,g.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling)),t?r.DataFrame.fromColumns([this._scaledActivityColumn]).clone(this.dataFrame.rowCount===this._scaledActivityColumn.length?this.dataFrame.filter:null).getCol(this._scaledActivityColumn.name):this._scaledActivityColumn}getAggregationColumns(){return Object.fromEntries(this.columns.map(t=>[t,this.aggregation]).filter(([t,e])=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("numerical")))}onTableAttached(){var t,e,n,i,s,a,l,c,h,d,f,p,v;if(super.onTableAttached(),(0,g.B2)(this.dataFrame)){const o=null===(t=m()(this.dataFrame.columns.numerical).filter(t=>{var e;return null===(e=t.name)||void 0===e?void 0:e.includes("activ")}).take(1).toArray()[0])||void 0===t?void 0:t.name,g=null!=o?o:null===(n=null===(e=m()(this.dataFrame.columns.numerical).take(1).toArray())||void 0===e?void 0:e[0])||void 0===n?void 0:n.name,C=this.dataFrame.columns.bySemType(r.SEMTYPE.MACROMOLECULE);C&&(null===(i=this.getProperty(`sequence${u.To}`))||void 0===i||i.set(this,C.name)),g&&(null===(s=this.getProperty(`activity${u.To}`))||void 0===s||s.set(this,g),null===(a=this.getProperty("webLogoAggregationColumnName"))||void 0===a||a.set(this,g));const y=null===(h=null===(c=null===(l=m()(this.dataFrame.columns).filter(t=>{var e;return t.isCategorical&&(null===(e=t.name)||void 0===e?void 0:e.toLowerCase().includes("cluster"))&&t.name!=(null==C?void 0:C.name)&&t.type!==r.COLUMN_TYPE.BOOL}))||void 0===l?void 0:l.take(1))||void 0===c?void 0:c.toArray())||void 0===h?void 0:h[0],b=null!=y?y:null===(p=null===(f=null===(d=m()(this.dataFrame.columns.categorical).filter(t=>t.name!=(null==C?void 0:C.name)&&t.categories.length<=50&&t.type!==r.COLUMN_TYPE.BOOL))||void 0===d?void 0:d.take(1))||void 0===f?void 0:f.toArray())||void 0===p?void 0:p[0];b&&(null===(v=this.getProperty(`clusters${u.To}`))||void 0===v||v.set(this,b.name))}else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";o.log.error(t),o.shell.warning(t)}this.render()}detach(){this.subs.forEach(t=>t.unsubscribe())}render(){if(a()(this.root).empty(),null==this.clustersColumnName||null==this.sequenceColumnName||null==this.activityColumnName)return void this.root.appendChild(i.divText("Please, select a sequence, cluster and activity columns in the viewer properties"));if(!this.logoSummaryTable.filter.anyTrue){const t=i.divText("No clusters to satisfy the threshold. Please, lower the threshold in viewer proeperties to include clusters");return void this.root.appendChild(i.divV([t]))}const t=i.iconFA("expand-alt",()=>{const t=i.dialog("Logo Summary Table");t.add(this.viewerGrid.root),t.onCancel(()=>this.render()),t.showModal(!0),this.viewerGrid.invalidate()},"Show Logo Summary Table in full screen");a()(t).addClass("pep-help-icon"),this.viewerGrid.root.style.width="auto",this.viewerGrid.root.style.height="auto",this.viewerGrid.root.style.overflow="hidden",this.root.appendChild(i.divV([i.divH([t],{style:{alignSelf:"center",lineHeight:"normal"}}),this.viewerGrid.root])),this.viewerGrid.invalidate()}onPropertyChanged(t){super.onPropertyChanged(t);let e=!1;switch(t.name){case"membersRatioThreshold":this.logoSummaryTable.filter.anyTrue||(e=!0),this.updateFilter();break;case`sequence${u.To}`:this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case`clusters${u.To}`:this._clusterStats=null,this._clusterSelection=null,this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case`activity${u.To}`:this.webLogoAggregationColumnName=this.activityColumnName;case"activityScaling":case`webLogoAggregationColumnName${u.To}`:case"webLogoAggregationType":this._webLogoCacheGeneration++,this._scaledActivityColumn=null,this._viewerGrid=null,this._clusterStats=null,this._logoSummaryTable=null,e=!0;break;case"columns":case"aggregation":this._viewerGrid=null,this._logoSummaryTable=null,e=!0;break;case"webLogoMode":this.viewerGrid.invalidate()}e&&this.render()}initClusterSelection(t={}){var e;null!==(e=t.notify)&&void 0!==e||(t.notify=!0);const n={};return n[A.ORIGINAL]=[],n[A.CUSTOM]=[],t.notify?this.clusterSelection=n:this._clusterSelection=n,this.clusterSelection}getTotalViewerAggColumns(){var t,e;const n=this.getAggregationColumns();return(0,g.zm)(this.model.df,this.columns,n,null===(e=null===(t=this.model)||void 0===t?void 0:t.settings)||void 0===e?void 0:e.columns)}getStringAggregatedColumns(){return this.columns.filter(t=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("categorical")).map(t=>`dist(${t})`)}getNeededDfClone(){var t,e;const n=[this.clustersColumnName,this.sequenceColumnName,this.activityColumnName,...(null!==(t=this.getTotalViewerAggColumns())&&void 0!==t?t:[]).map(([t,e])=>t),...(null!==(e=this.getStringAggregatedColumns())&&void 0!==e?e:[]).map(t=>t.substring(5,t.length-1))];this.webLogoAggregationColumnName&&n.push(this.webLogoAggregationColumnName);const i=Array.from(new Set(n)).filter(t=>this.dataFrame.columns.contains(t));return this.dataFrame.clone(this.dataFrame.filter,i)}createLogoSummaryTable(){var t,e,n;const i=this.clustersColumnName,o=this.dataFrame.filter.anyFalse,s=o?this.getNeededDfClone():this.dataFrame,a=s.columns,l=s.rowCount,c=this.getScaledActivityColumn(o).getRawData(),h=s.getCol(i),f=h.getRawData(),p=h.categories,g={};g[u.gp.CUSTOM_CLUSTER]="1";const C=m()(a.byTags(g)).filter(t=>t.max>0).toArray(),y=r.DataFrame.create(C.length),b=y.columns,_=b.addNewString(u.i6.CLUSTER),S=b.addNewInt(u.i6.MEMBERS).getRawData(),T=b.addNewString(u.i6.WEB_LOGO),E=b.addNewString(u.i6.DISTRIBUTION),N=b.addNewFloat(u.i6.MEAN_DIFFERENCE).getRawData(),x=b.addNewFloat(u.i6.P_VALUE).getRawData(),M=b.addNewFloat(u.i6.RATIO).getRawData();let I=s.groupBy([i]);const O=this.getTotalViewerAggColumns(),P=this.getStringAggregatedColumns(),L=P.map(t=>b.addNewString(t)),R=O.map(([t,e])=>w(e,t)),k=new Array(R.length+P.length),F=O.map(([t,e])=>[s.getCol(t),e]);for(let t=0;t<O.length;++t){const[e,n]=O[t];I=I.add(n,e,R[t]);const i=b.addNewFloat(R[t]);k[t]=i.getRawData()}const V=new Array(C.length);for(let e=0;e<C.length;++e){const n=C[e];_.set(e,n.name);const i=v.A.fromUint32Array(l,n.getRawData());if(i.allFalse)continue;const a=r.BitSet.fromBytes(i.buffer.buffer,l),u=o?(0,d.GT)(c,i):this.clusterStats[A.CUSTOM][n.name];S[e]=u.count,V[e]=a,N[e]=u.meanDifference,x[e]=null!==(t=u.pValue)&&void 0!==t?t:r.FLOAT_NULL,M[e]=u.ratio;for(let t=0;t<R.length;++t){const[n,i]=F[t];k[t][e]=(0,d.lh)(n,i,a)}for(let t=R.length;t<k.length;++t){const n=P[t-R.length];L[t-R.length].set(e,(0,d.J1)(s,n,a))}}T.setTag(r.TAGS.CELL_RENDERER,"html"),E.setTag(r.TAGS.CELL_RENDERER,"html");const D=I.aggregate(),G=D.rowCount,B=D.columns;let U=D.getCol(i);U.name=u.i6.CLUSTER,U.type!==r.COLUMN_TYPE.STRING&&(D.columns.replace(U,U.convertTo(r.COLUMN_TYPE.STRING)),U=D.getCol(U.name));const q=U.categories,H=B.addNewInt(u.i6.MEMBERS).getRawData(),$=B.addNewString(u.i6.WEB_LOGO),Y=B.addNewString(u.i6.DISTRIBUTION),j=B.addNewFloat(u.i6.MEAN_DIFFERENCE).getRawData(),W=B.addNewFloat(u.i6.P_VALUE).getRawData(),z=B.addNewFloat(u.i6.RATIO).getRawData(),K=P.map(t=>B.addNewString(t)),Z=new Array(G),X=Array.from({length:G},()=>new v.A(l,!1));for(let t=0;t<l;++t){const n=p[f[t]];null===(e=X[q.indexOf(n)])||void 0===e||e.setTrue(t)}for(let t=0;t<G;++t){const e=X[t];if(e.allFalse)continue;const i=r.BitSet.fromBytes(e.buffer.buffer,l),a=o?(0,d.GT)(c,e):this.clusterStats[A.ORIGINAL][q[t]];for(let e=0;e<P.length;++e){const n=P[e];K[e].set(t,(0,d.J1)(s,n,i))}H[t]=a.count,Z[t]=i,j[t]=a.meanDifference,W[t]=null!==(n=a.pValue)&&void 0!==n?n:r.FLOAT_NULL,z[t]=a.ratio}$.setTag(r.TAGS.CELL_RENDERER,"html"),Y.setTag(r.TAGS.CELL_RENDERER,"html");const Q=D.append(y);return this.bitsets=Z.concat(V),P.forEach(t=>Q.col(t).semType="lst-pie-chart"),Q}createLogoSummaryTableGrid(){const t=this.dataFrame.filter.anyFalse,e=t?this.getNeededDfClone():this.dataFrame,n=this.getTotalViewerAggColumns().map(([t,e])=>w(e,t)),i=this.logoSummaryTable.plot.grid();i.sort([u.i6.MEMBERS],[!1]),this.updateFilter(),i.col(u.i6.CLUSTER).visible=!0,i.columns.setOrder([u.i6.CLUSTER,u.i6.MEMBERS,u.i6.WEB_LOGO,...this.getStringAggregatedColumns(),u.i6.DISTRIBUTION,u.i6.MEAN_DIFFERENCE,u.i6.P_VALUE,u.i6.RATIO,...n]),i.columns.rowHeader.visible=!1,i.props.rowHeight=55;const o=new r.LruCache,s=new Map;let d=null;const f=new r.LruCache,m=this.positionColumns.length,p=i.columns.byName(u.i6.WEB_LOGO);p.cellType="html",p.width=350;const v=this.getScaledActivityColumn(t),C=e.getCol(this.sequenceColumnName);i.onCellRender.subscribe(t=>{var e,n,l;const p=t.cell,y=p.tableRowIndex;if(!p.isTableCell||null==y||-1===y)return;const b=t.g,_=t.bounds;b.save(),b.beginPath(),b.rect(_.x,_.y,_.width,_.height),b.clip();try{const w=Math.max(p.bounds.height-2,0),A=this.bitsets[y];if((null===(e=p.tableColumn)||void 0===e?void 0:e.name)===u.i6.CLUSTER)c.k8(b,p.cell.value,this.clusterSelection,_),t.preventDefault();else if((null===(n=p.tableColumn)||void 0===n?void 0:n.name)===u.i6.WEB_LOGO){const e=`${y}_${this.webLogoAggregationColumnName||"count"}_${this.webLogoAggregationType}_${this._webLogoCacheGeneration}`,n=o.get(e);if(!0===s.get(e))return void t.preventDefault();const l=Math.floor((p.bounds.width-2-4*(m-1))/m);if(void 0!==n){const e=n.getProperties();for(const t of e)"positionHeight"===t.name&&t.get(n)!==this.webLogoMode?t.set(n,this.webLogoMode):"positionWidth"===t.name&&t.get(n)!==l?t.set(n,l):"minHeight"===t.name&&t.get(n)!==w&&t.set(n,w);a()(n.root).css("height",`${w}px`).children().first().css("overflow-y","hidden !important"),n.root.style.height=`${w}px`,p.element=n.root,t.preventDefault()}else{const n=[C];if(this.webLogoAggregationType!==r.AGG.TOTAL_COUNT&&this.webLogoAggregationColumnName){const t=this.dataFrame.columns.byName(this.webLogoAggregationColumnName);t&&n.push(t)}const a=r.DataFrame.fromColumns(n);a.filter.copyFrom(A),s.set(e,!0),a.plot.fromType("WebLogo",{valueColumnName:this.webLogoAggregationColumnName,valueAggrType:this.webLogoAggregationType,positionHeight:this.webLogoMode,horizontalAlignment:h.P4.LEFT,maxHeight:1e3,minHeight:w,positionWidth:l,showPositionLabels:!1}).then(t=>{o.set(e,t),s.delete(e),d&&clearTimeout(d),d=setTimeout(()=>i.invalidate(),200)}),t.preventDefault()}}else if((null===(l=p.tableColumn)||void 0===l?void 0:l.name)===u.i6.DISTRIBUTION){let e=f.get(y);void 0===e&&(v.dataFrame||r.DataFrame.fromColumns([v]),e=(0,g.FZ)(v,A,v.dataFrame).plot.histogram({filteringEnabled:!1,valueColumnName:v.name,splitColumnName:u.$2.SPLIT_COL,legendVisibility:"Never",showXAxis:!1,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1,backColor:r.Color.toHtml(r.Color.white),xAxisHeight:1,showSplitSelector:!1}),e.root.style.width="auto",f.set(y,e)),e.root.style.height=`${w}px`,p.element=e.root,t.preventDefault()}}finally{b.restore()}}),i.root.addEventListener("mouseleave",t=>this.model.unhighlight()),r.debounce(i.onCurrentCellChanged,500).subscribe(t=>{var e;if(!t.isTableCell||-1===t.gridRow)return this.initClusterSelection({notify:!1}),this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),void i.invalidate();try{if(!this.keyPress||(null===(e=t.tableColumn)||void 0===e?void 0:e.name)!==u.i6.CLUSTER)return;null!==this.currentRowIndex&&-1!==this.currentRowIndex&&this.modifyClusterSelection(this.getCluster(i.cell(u.i6.CLUSTER,this.currentRowIndex)),{shiftPressed:!0,ctrlPressed:!0},!1),this.modifyClusterSelection(this.getCluster(t),{shiftPressed:!0,ctrlPressed:!1}),i.invalidate()}finally{this.keyPress=!1,this.currentRowIndex=t.gridRow}}),i.root.addEventListener("keydown",t=>{if(this.keyPress=t.key.startsWith("Arrow"),!this.keyPress){if("Escape"===t.key||"KeyA"===t.code&&t.shiftKey&&t.ctrlKey)this.initClusterSelection({notify:!1});else if("KeyA"===t.code&&t.ctrlKey)for(let t=0;t<this.logoSummaryTable.rowCount;++t)this.modifyClusterSelection(this.getCluster(i.cell(u.i6.CLUSTER,t)),{shiftPressed:!0,ctrlPressed:!1},!1);this.model.fireBitsetChanged(l.q.LOGO_SUMMARY_TABLE),i.invalidate()}}),i.root.addEventListener("click",t=>{var e;const n=i.hitTest(t.offsetX,t.offsetY);if(!n||!n.isTableCell||(null===(e=n.tableColumn)||void 0===e?void 0:e.name)!==u.i6.CLUSTER)return;const o=this.getCluster(n);this.modifyClusterSelection(o,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey}),i.invalidate()}),i.onCellTooltip((t,e,n)=>{var i;if(!t.isTableCell)return this.model.unhighlight(),!0;const o=this.getCluster(t);return this.highlightCluster(o),(null===(i=t.tableColumn)||void 0===i?void 0:i.name)===u.i6.CLUSTER&&this.showTooltip(o,e,n),!0});const y=i.props;return y.allowEdit=!1,y.allowRowSelection=!1,y.allowBlockSelection=!1,y.allowColSelection=!1,y.showCurrentRowIndicator=!1,y.showReadOnlyNotifications=!1,i}highlightCluster(t){const e=this.clusterStats[t.positionOrClusterType][t.monomerOrCluster].mask;this.dataFrame.rows.highlight(t=>e.getBit(t)),this.model.isHighlighting=!0}getCluster(t){const e=this.logoSummaryTable.get(u.i6.CLUSTER,t.tableRowIndex);return{positionOrClusterType:this.dataFrame.getCol(this.clustersColumnName).categories.includes(e)?A.ORIGINAL:A.CUSTOM,monomerOrCluster:e}}updateFilter(){const t=this.logoSummaryTable.getCol(u.i6.MEMBERS),e=this.logoSummaryTable.getCol(u.i6.CLUSTER),n=e.getRawData(),i=e.categories,o=i.indexOf("-1"),r=t.getRawData();let s=0;r.forEach((t,e)=>{"-1"!==i[n[e]]&&(s=Math.max(s,r[e]))});const a=Math.ceil(s*this.membersRatioThreshold);this.logoSummaryTable.filter.init(t=>r[t]>a&&(-1===o||"-1"!==i[n[t]]))}clusterFromSelection(){const t=this.model.getVisibleSelection(),e=this.logoSummaryTable.columns,n=e.length,i=new Array(e.length),o=this.getScaledActivityColumn(),r=(0,d.pY)(t),s=(0,d.GT)(o.getRawData(),r,(0,d.pY)(this.dataFrame.filter));this.bitsets.push(t.clone());const a=this.dataFrame.columns.getUnusedName("New Cluster"),l={},c={},h=this.getTotalViewerAggColumns(),f=this.getStringAggregatedColumns();for(const[e,n]of h){const i=w(n,e),o=this.dataFrame.getCol(e);l[i]=(0,d.lh)(o,n,t)}for(const e of f)c[e]=(0,d.J1)(this.dataFrame,e,t);for(let o=0;o<n;++o){const n=e.byIndex(o);i[o]=n.name===u.i6.CLUSTER?a:n.name===u.i6.MEMBERS?t.trueCount:n.name===u.i6.WEB_LOGO||n.name===u.i6.DISTRIBUTION?null:n.name===u.i6.MEAN_DIFFERENCE?s.meanDifference:n.name===u.i6.P_VALUE?s.pValue:n.name===u.i6.RATIO?s.ratio:n.name in l?l[n.name]:n.name in c?c[n.name]:void 0,void 0===i[o]&&C._package.logger.warning(`PeptidesLSTWarn: value for column ${n.name} is undefined`)}this.logoSummaryTable.rows.addNew(i),this.clusterStats[A.CUSTOM][a]=s,this.addNewCluster(a)}removeCluster(){const t=this.clusterSelection[A.CUSTOM];if(0===t.length)return void o.shell.warning("No custom clusters selected to be removed");const e=this.logoSummaryTable.rows,n=this.logoSummaryTable.getCol(u.i6.CLUSTER),i=n.categories,r=this.dataFrame.columns;for(const n of t){t.splice(t.indexOf(n),1),r.remove(n),delete this.clusterStats[A.CUSTOM][n];const o=i.indexOf(n);e.removeAt(o),this.bitsets.splice(o,1)}n.compact(),this.clusterSelection[A.CUSTOM]=t,this.render()}addNewCluster(t){const e=r.Column.fromBitSet(t,this.model.getVisibleSelection());e.setTag(u.gp.CUSTOM_CLUSTER,"1"),e.setTag(u.gp.ANALYSIS_COL,"true"),this.dataFrame.columns.add(e),this.model.analysisView.grid.col(e.name).visible=!1}modifyClusterSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.clusterSelection=(0,g.vW)(this.clusterSelection,t,e):this._clusterSelection=(0,g.vW)(this.clusterSelection,t,e)}showTooltip(t,e,n){const o=this.dataFrame.filter,s=o.anyFalse?this.getNeededDfClone():this.dataFrame,a=s.rowCount,l=new v.A(a,!1),u=this.getScaledActivityColumn(o.anyFalse),c=u.getRawData();if(t.positionOrClusterType===A.ORIGINAL){const e=s.getCol(this.clustersColumnName),n=e.getRawData(),i=e.categories.indexOf(t.monomerOrCluster);for(let t=0;t<a;++t)n[t]===i&&l.setTrue(t);l.incrementVersion()}else{const e=s.getCol(t.monomerOrCluster);l.buffer=e.getRawData()}const h=o.anyFalse?(0,d.GT)(c,l):this.clusterStats[t.positionOrClusterType][t.monomerOrCluster];if(!h.count)return null;const f=r.BitSet.fromBytes(l.buffer.buffer,a);u.dataFrame||r.DataFrame.fromColumns([u]);const m=(0,g.FZ)(u,f,u.dataFrame),C=(0,p.M1)(m,!0),y=(0,p.QD)(h),b=(0,d.I_)(this.dataFrame,this.getTotalViewerAggColumns(),{filterDf:!0,mask:f}),_=Object.assign(Object.assign({},y),b),w=(0,g.F2)(C,_);return i.tooltip.show(w,e,n),w}createWebLogoDf(t,e){const n=r.DataFrame.fromColumns([t]);return n.filter.copyFrom(e),n}}},3615(t,e,n){"use strict";n.d(e,{Y_:()=>A});var i,o,r=n(4328),s=n(7389),a=n(6082),l=n(144),u=n.n(l),c=n(7233),h=n.n(c),d=n(4139),f=n(726),m=n(8608),p=n(1458),g=n(912),v=n(3077),C=n(7194),y=n(2003),b=n(439),_=n(854),w=n(3743);!function(t){t.SEQUENCE="sequence",t.ACTIVITY="activity",t.ACTIVITY_SCALING="activityScaling",t.ACTIVITY_TARGET="activityTarget",t.PEPTIDE_COUNT="peptideCount",t.CANDIDATES_PER_POSITION="candidatesPerPosition",t.BEAM_WIDTH="beamWidth",t.MIN_SUPPORT="minSupport",t.MAX_P_VALUE="maxPValue",t.SHRINKAGE="shrinkageStrength",t.EXCLUDE_EXISTING="excludeExisting",t.ONLY_SIGNIFICANT="onlySignificantPositions"}(i||(i={})),function(t){t.PEPTIDE="Peptide",t.PREDICTED="Predicted activity",t.CONFIDENCE="Confidence",t.MIN_SUPPORT="Min support",t.MEAN_P_VALUE="Mean p-value",t.SIGNIFICANT_POSITIONS="Significant positions",t.NOVEL="Novel",t.BASIS="Basis"}(o||(o={}));class A extends a.JsViewer{constructor(){super(),this._grid=null,this._positionColumns=null,this._monomerPositionStats=null,this._scaledActivityCol=null,this._basisByPosition={},this._basisPositionNames=[],this._basisPositionSet=new Set,this._rowMaxAbsContribution=[],this._monomerColorCache=new Map,this._biotype=_.oE.AA,this._propChangeTimer=null,this._currentCellSub=null,this.sequenceColumnName=this.column(i.SEQUENCE,{semType:a.SEMTYPE.MACROMOLECULE,nullable:!1}),this.activityColumnName=this.column(i.ACTIVITY,{columnTypeFilter:"numerical",nullable:!1}),this.activityScaling=this.string(i.ACTIVITY_SCALING,d.rg.NONE,{choices:Object.values(d.rg),nullable:!1,description:"Activity transformation applied before computing statistics"}),this.activityTarget=this.string(i.ACTIVITY_TARGET,d.wf.HIGH,{choices:Object.values(d.wf),nullable:!1,description:"Whether to design peptides that maximize (High) or minimize (Low) the scaled activity"}),this.peptideCount=this.int(i.PEPTIDE_COUNT,50,{min:1,max:1e3,description:"How many peptides to generate"}),this.candidatesPerPosition=this.int(i.CANDIDATES_PER_POSITION,3,{min:1,max:10,description:"Number of best-performing monomers considered at each position"}),this.beamWidth=this.int(i.BEAM_WIDTH,100,{min:1,max:2e3,description:"Beam search width. Larger values explore more combinations at higher cost"}),this.minSupport=this.int(i.MIN_SUPPORT,3,{min:1,max:1e3,description:"Minimum number of observed sequences backing a monomer for it to be trusted"}),this.maxPValue=this.float(i.MAX_P_VALUE,1,{min:0,max:1,description:"Only consider monomers with a t-test p-value at or below this value (1 = no filtering)"}),this.shrinkageStrength=this.float(i.SHRINKAGE,5,{min:0,max:100,description:"Shrinks each position's contribution towards zero by a factor of count/(count+k), damping poorly-supported monomers so they cannot inflate the predicted activity. 0 disables shrinkage (raw additive model, prone to over-prediction)"}),this.excludeExisting=this.bool(i.EXCLUDE_EXISTING,!0,{description:"Exclude generated peptides that already exist in the source data"}),this.onlySignificantPositions=this.bool(i.ONLY_SIGNIFICANT,!1,{description:"Vary only positions that have at least one statistically significant monomer; keep the most common monomer elsewhere"})}get name(){return"Peptide Generation"}onTableAttached(){var t,e,n,o;super.onTableAttached();const s=this.dataFrame.columns.bySemType(a.SEMTYPE.MACROMOLECULE);if(null==s)return void r.shell.warning("Peptide Generation: no Macromolecule column found");null===(t=this.getProperty(i.SEQUENCE+"ColumnName"))||void 0===t||t.set(this,s.name);const l=null!==(e=u()(this.dataFrame.columns.numerical).find(t=>t.name.toLowerCase().includes("activity")))&&void 0!==e?e:null===(n=u()(this.dataFrame.columns.numerical).next())||void 0===n?void 0:n.value;l&&(null===(o=this.getProperty(i.ACTIVITY+"ColumnName"))||void 0===o||o.set(this,l.name)),this.subs.push(a.debounce(this.dataFrame.onFilterChanged,500).subscribe(()=>{this._propChangeTimer&&clearTimeout(this._propChangeTimer),this._monomerPositionStats=null,this._grid=null,this.render()})),this.render()}onPropertyChanged(t){this.dataFrame&&this.sequenceColumnName&&this.activityColumnName&&(this._propChangeTimer&&clearTimeout(this._propChangeTimer),this._propChangeTimer=setTimeout(()=>{this._positionColumns=null,this._monomerPositionStats=null,this._grid=null,this.render()},500))}get existingModel(){var t,e,n;return null!==(n=null===(e=null===(t=this.dataFrame)||void 0===t?void 0:t.temp)||void 0===e?void 0:e[w.i.modelName])&&void 0!==n?n:null}get monomerPositionStats(){if(null!=this._monomerPositionStats)return this._monomerPositionStats;const t=this.dataFrame.filter.anyFalse,e=t=>null!=t&&this.sequenceColumnName===t.sequenceColumnName&&this.activityColumnName===t.activityColumnName&&this.activityScaling===t.activityScaling,n=this.existingModel;if(null!=n){for(const i of[w.q.SEQUENCE_VARIABILITY_MAP,w.q.MOST_POTENT_RESIDUES]){const o=n.findViewer(i);if(null!=(null==o?void 0:o._monomerPositionStats)&&e(o)&&(!t||"Filtered"===o.dataSource))return this._monomerPositionStats=o._monomerPositionStats}if(!t&&null!=n.monomerPositionStats&&e(n.settings))return this._monomerPositionStats=n.monomerPositionStats}const i=(0,m.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling);return this._monomerPositionStats=(0,p.Ej)(i,this.dataFrame.filter,this.getPositionColumns(),{isFiltered:t}),this._monomerPositionStats}detach(){var t;this.subs.forEach(t=>t.unsubscribe()),null===(t=this._currentCellSub)||void 0===t||t.unsubscribe()}getPositionColumns(){if(null!=this._positionColumns)return this._positionColumns;const t=u()(this.dataFrame.columns.toList()).filter(t=>"true"===t.getTag(d.gp.POSITION_COL)).toArray();return 0!==t.length?this._positionColumns=t:this._positionColumns=(0,v.R)(this.dataFrame.getCol(this.sequenceColumnName),f.Z.getSeqHelper()).columns.toList(),this._positionColumns}render(){var t,e;if(h()(this.root).empty(),!this.dataFrame||!this.sequenceColumnName||!this.activityColumnName)return void this.root.appendChild(s.divText("Please select a sequence and an activity column in the viewer properties"));try{null!==(t=this._grid)&&void 0!==t||(this._grid=this.createGrid())}catch(t){return r.log.error(t),void this.root.appendChild(s.divText(`Peptide Generation failed: ${null!==(e=null==t?void 0:t.message)&&void 0!==e?e:t}`))}const n=this.activityTarget===d.wf.HIGH?"highest":"lowest",i=s.divText(`${this._grid.table.rowCount} peptides generated for ${n} activity (additive positional model — treats positions as independent)`,{style:{color:"var(--grey-5)",fontSize:"12px"}}),o=s.iconFA("plus",()=>this.openAsTableView(),"Open the generated peptides as a new table");o.style.cursor="pointer",o.style.color="var(--blue-1)";const a=s.iconFA("info-circle");a.style.color="var(--blue-1)",a.style.cursor="help",s.tooltip.bind(a,()=>this.buildInfoTooltip());const l=s.divH([i,o,a],{style:{alignItems:"center",gap:"6px",padding:"4px 8px"}}),u=this._grid.root;u.style.width="100%",this.root.appendChild(s.divV([l,u],{style:{height:"100%"}})),this._grid.invalidate()}openAsTableView(){if(null==this._grid)return;const t=this._grid.table.clone();t.name="Generated Peptides";for(const e of this._basisPositionNames){const n=t.col(e),i=this._basisByPosition[e];null!=n&&null!=i&&n.init(t=>{const e=i[t];if(null==e||!e.monomer)return"";const n=null==e.pValue?"n/a":e.pValue<.001?e.pValue.toExponential(1):e.pValue.toFixed(3);return`${e.monomer}, ${this.formatContribution(e.contribution)}, ${n}`})}const e=r.shell.addTableView(t);setTimeout(()=>r.shell.v=e,50)}buildInfoTooltip(){return s.divV([s.h3("How Peptide Generation works"),s.divText("Additive positional (Free-Wilson) model",{style:{fontWeight:"bold"}}),s.divText("Predicted activity = global mean + Σ over positions of (chosen monomer's mean activity − global mean). Each per-position contribution is shrunk by count / (count + k) so that poorly-supported monomers cannot dominate the prediction."),s.divText("Generation",{style:{fontWeight:"bold",marginTop:"6px"}}),s.divText("At each position the best-scoring monomers toward the chosen High/Low target are kept, then a beam search combines them into whole peptides, ranked by predicted activity."),s.divText("Per-position basis columns",{style:{fontWeight:"bold",marginTop:"6px"}}),s.divText("The trailing columns (one per position) show the chosen monomer, an effect circle, and the signed contribution. In each circle:"),s.list(["Size = effect magnitude (|contribution|), normalized within the row: bigger = stronger effect on activity.","Color = direction and significance: red raises activity, blue lowers it, pale ≈ weak significance, grey = not enough data to test.","Hover a cell for the full activity distribution of that monomer-at-position versus the rest."],{processNode:t=>{t.style.maxWidth="470px",t.style.display="block"}}),s.divText("Keep in mind",{style:{fontWeight:"bold",marginTop:"6px"}}),s.list(["Predicted activity is a ranking score / optimistic estimate, NOT a calibrated measurement.","Because contributions add across positions, it can extrapolate well beyond the observed activity range — a peptide combining the best residue at every position may not exist or behave additively (epistasis is invisible to this model).","Judge reliability with the Confidence, Min support, Significant positions and Basis columns.",'Raise "Shrinkage strength" or enable "Only significant positions" for more conservative magnitudes. On data with no real signal, few or no significant peptides should appear.'],{processNode:t=>{t.style.maxWidth="470px",t.style.display="block"}})],{style:{maxWidth:"480px",fontSize:"12px"}})}createGrid(){var t,e;const n=this.generatePeptides().plot.grid();n.props.allowEdit=!1,n.props.showReadOnlyNotifications=!1,null===(t=this._currentCellSub)||void 0===t||t.unsubscribe(),this._currentCellSub=n.onCurrentCellChanged.subscribe(t=>{var e,n;t&&t.dart&&t.cell.dart&&(null!==(e=t.tableRowIndex)&&void 0!==e?e:-1)>-1&&(null===(n=t.cell.column)||void 0===n?void 0:n.name)===o.PEPTIDE&&(r.shell.o=a.SemanticValue.fromGridCell(t))});const i=n.col(o.PREDICTED);i&&(i.format="#.000");const s=n.col(o.MEAN_P_VALUE);s&&(s.format="#.000");const l=n.col(o.CONFIDENCE);l&&(l.format="0.##%");const u=n.col(o.BASIS);u&&(u.visible=!1);const c=null!==(e=this.dataFrame.getCol(this.sequenceColumnName).getTag(y.gp.alphabet))&&void 0!==e?e:y.YI.UN;this._biotype=c===y.YI.RNA||c===y.YI.DNA?_.oE.NUCLEOTIDE:_.oE.AA,this._monomerColorCache.clear(),n.props.rowHeight=22;for(const t of this._basisPositionNames){const e=n.col(t);e&&(e.width=85)}return n.onCellRender.subscribe(t=>this.renderBasisCell(t)),n.onCellTooltip((t,e,n)=>this.showBasisTooltip(t,e,n)),n.root.addEventListener("mouseleave",()=>{var t,e;return null===(e=null===(t=this.dataFrame)||void 0===t?void 0:t.rows)||void 0===e?void 0:e.highlight(()=>!1)}),n.sort([o.PREDICTED],[this.activityTarget!==d.wf.HIGH]),n}renderBasisCell(t){var e,n,i;const o=t.cell,r=null===(e=o.tableColumn)||void 0===e?void 0:e.name;if(!o.isTableCell||null==r||!this._basisPositionSet.has(r))return;const s=t.g,a=t.bounds;s.save(),s.beginPath(),s.rect(a.x,a.y,a.width,a.height),s.clip();const l=o.tableRowIndex,u=null==l?null:null!==(i=null===(n=this._basisByPosition[r])||void 0===n?void 0:n[l])&&void 0!==i?i:null;if(null==u||!u.monomer)return t.preventDefault(),void s.restore();const c=a.y+a.height/2,h=.36*a.width,d=.4*a.width,f=a.x+3+h,m=Math.max(6,a.width-h-d-6);s.textBaseline="middle",s.font="11px Roboto, Roboto Local, sans-serif",s.textAlign="left",s.fillStyle=this.monomerTextColor(u.monomer),s.fillText(this.fitText(s,u.monomer,h-3),a.x+3,c);const p=this._rowMaxAbsContribution[l]||0,g=p>0?Math.min(1,Math.abs(u.contribution)/p):0,v=Math.min(m,a.height)/2*.9,C=Math.max(2,v*g);s.beginPath(),s.fillStyle=this.contributionColor(u.contribution,u.pValue),s.arc(f+m/2,c,C,0,2*Math.PI),s.fill(),s.lineWidth=.5,s.strokeStyle="rgba(0,0,0,0.18)",s.stroke(),s.textAlign="right",s.fillStyle="#606060",s.fillText(this.fitText(s,this.formatContribution(u.contribution),d-3),a.x+a.width-3,c),t.preventDefault(),s.restore()}contributionColor(t,e){if(null==e)return"rgb(200, 200, 200)";const[n,i,o]=t>=0?[198,40,40]:[21,101,192],r=Math.min(1,Math.max(0,-Math.log10(Math.max(e,1e-12))/3)),s=t=>Math.round(255+(t-255)*r);return`rgb(${s(n)}, ${s(i)}, ${s(o)})`}monomerTextColor(t){const e=this._monomerColorCache.get(t);if(null!=e)return e;let n="#333333";try{const e=f.Z.getMonomerLib().getMonomerColors(this._biotype,t);(null==e?void 0:e.backgroundcolor)&&(n=e.backgroundcolor)}catch(t){}return this._monomerColorCache.set(t,n),n}formatContribution(t){const e=Math.abs(t)>=10?t.toFixed(1):t.toFixed(2);return`${t>=0?"+":""}${e}`}fitText(t,e,n){if(n<=0||t.measureText(e).width<=n)return e;let i=e;for(;i.length>1&&t.measureText(`${i}…`).width>n;)i=i.slice(0,-1);return i.length>1?`${i}…`:i}showBasisTooltip(t,e,n){var i,o,r;const s=null===(i=t.tableColumn)||void 0===i?void 0:i.name;if(!t.isTableCell||null==s||!this._basisPositionSet.has(s)||null==t.tableRowIndex)return!1;const a=null!==(r=null===(o=this._basisByPosition[s])||void 0===o?void 0:o[t.tableRowIndex])&&void 0!==r?r:null;if(null==a||!a.monomer||null==this._scaledActivityCol)return!1;const l={monomerOrCluster:a.monomer,positionOrClusterType:s};(0,m.dl)(l,this.dataFrame,this.monomerPositionStats);const u=a.contribution>=0?"raises":"lowers",c={Monomer:t.cell.valueString,"Circle size":`effect magnitude |Δ| = ${Math.abs(a.contribution).toFixed(2)}`,"Circle color":null==a.pValue?`${u} activity (significance: n/a — too few samples)`:`${u} activity, significance p = ${a.pValue<.001?a.pValue.toExponential(1):a.pValue.toFixed(3)}`};return(0,g.D)(this.dataFrame,this._scaledActivityCol,[],{monomerPosition:l,x:e,y:n,mpStats:this.monomerPositionStats,fromViewer:!0,additionalStats:c})}generatePeptides(){const t=this.dataFrame.getCol(this.sequenceColumnName),e=(0,m.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling);this._scaledActivityCol=e;const n=this.dataFrame.filter.anyFalse?a.Stats.fromColumn(e,this.dataFrame.filter).avg:e.stats.avg,i=this.getPositionColumns(),o=this.monomerPositionStats,r=this.activityTarget===d.wf.HIGH,s=[];for(const t of i){const e=t.name,i=o[e];if(!i)continue;const a=[];let l=null,u=!1;for(const t of Object.keys(i)){if("general"===t)continue;const o=i[t],r=o.count/(o.count+this.shrinkageStrength),s=(o.mean-n)*r,c=null!=o.pValue&&o.pValue<=.05;u||(u=c);const h={position:e,monomer:t,contribution:s,count:o.count,pValue:o.pValue,significant:c,supported:o.count>=this.minSupport};(null===l||h.count>l.count)&&(l=h);const d=o.count>=this.minSupport,f=this.maxPValue>=1||null!=o.pValue&&o.pValue<=this.maxPValue;d&&f&&a.push(h)}0!==a.length?!this.onlySignificantPositions||u?(a.sort((t,e)=>r?e.contribution-t.contribution:t.contribution-e.contribution),s.push(a.slice(0,this.candidatesPerPosition))):s.push([null!=l?l:a[0]]):null!==l&&s.push([l])}const l=this.beamSearch(s,r),u=s.map(t=>t[0].position);return this.buildResultDataFrame(l,t,n,u)}beamSearch(t,e){const n=Math.max(this.beamWidth,this.peptideCount*(this.excludeExisting?2:1)),i=(t,n)=>e?n-t:t-n;let o=[{monomers:[],candidates:[],cumContribution:0}];for(const e of t){const t=[];for(const n of o)for(const i of e)t.push({monomers:[...n.monomers,i.monomer],candidates:[...n.candidates,i],cumContribution:n.cumContribution+i.contribution});t.sort((t,e)=>i(t.cumContribution,e.cumContribution)),o=t.slice(0,n)}return o}buildResultDataFrame(t,e,n,i){var r;const s=f.Z.getSeqHelper().getSeqHandler(e),l=null!==(r=b.b9[s.notation])&&void 0!==r?r:"",u=s.joiner,c=new Set(s.isHelm()?e.categories.map(t=>(null==t?void 0:t.endsWith("V2.0"))||(null==t?void 0:t.endsWith("V1.0"))?t.substring(0,t.length-4):t):e.categories),h=[],d=[],m=[],p=[],g=[],v=[],y=[],_=[],w=[];for(const e of t){const t=u(new C.Mu(e.monomers,l)),i=!c.has(t);if(this.excludeExisting&&!i)continue;if(h.length>=this.peptideCount)break;const o=e.candidates.filter(t=>t.supported||t.significant),r=Math.max(o.length,1);let s=0,f=0,b=Number.POSITIVE_INFINITY,A=0,S=0;for(const t of e.candidates)t.significant&&++s,t.supported&&++f,b=Math.min(b,t.count),null!=t.pValue&&(A+=t.pValue,++S);const T=[...e.candidates].sort((t,e)=>Math.abs(e.contribution)-Math.abs(t.contribution)).slice(0,5).map(t=>`${t.position}:${t.monomer}(${t.contribution>=0?"+":""}${t.contribution.toFixed(2)})`).join(", ");h.push(t),d.push(n+e.cumContribution),m.push(0===f?0:s/r),p.push(b===Number.POSITIVE_INFINITY?0:b),g.push(0===S?a.FLOAT_NULL:A/S),v.push(s),y.push(i),_.push(T),w.push(e.candidates)}const A=[s.getNewColumnFromList(o.PEPTIDE,h),a.Column.fromList(a.COLUMN_TYPE.FLOAT,o.PREDICTED,d),a.Column.fromList(a.COLUMN_TYPE.FLOAT,o.CONFIDENCE,m),a.Column.fromList(a.COLUMN_TYPE.INT,o.MIN_SUPPORT,p),a.Column.fromList(a.COLUMN_TYPE.FLOAT,o.MEAN_P_VALUE,g),a.Column.fromList(a.COLUMN_TYPE.INT,o.SIGNIFICANT_POSITIONS,v),a.Column.fromList(a.COLUMN_TYPE.BOOL,o.NOVEL,y),a.Column.fromList(a.COLUMN_TYPE.STRING,o.BASIS,_)];this._basisByPosition={},this._basisPositionNames=[],this._rowMaxAbsContribution=w.map(t=>t.reduce((t,e)=>Math.max(t,Math.abs(e.contribution)),0));const S=new Set(A.map(t=>t.name));for(let t=0;t<i.length;++t){let e=i[t];for(;S.has(e);)e=`${e} `;S.add(e);const n=w.map(e=>{var n;return null!==(n=e[t])&&void 0!==n?n:null});A.push(a.Column.fromStrings(e,n.map(t=>{var e;return null!==(e=null==t?void 0:t.monomer)&&void 0!==e?e:""}))),this._basisByPosition[e]=n,this._basisPositionNames.push(e)}this._basisPositionSet=new Set(this._basisPositionNames);const T=a.DataFrame.fromColumns(A);return T.name="Generated Peptides",T}}},3541(t,e,n){"use strict";n.d(e,{J:()=>I,UJ:()=>O});var i,o,r,s,a=n(4328),l=n(7389),u=n(6082),c=n(7233),h=n.n(c),d=n(4139),f=n(3163),m=n(3743),p=n(144),g=n.n(p),v=n(5070),C=n(912),y=n(1458),b=n(8608),_=n(3077),w=n(439),A=n(2003),S=n(4971),T=n(854),E=n(726),N=n(4025),x=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};!function(t){t.MUTATION_CLIFFS="Mutation Cliffs",t.INVARIANT_MAP="Invariant Map"}(i||(i={})),function(t){t.SEQUENCE="sequence",t.ACTIVITY="activity",t.ACTIVITY_SCALING="activityScaling",t.TARGET="target",t.TARGET_CATEGORY="targetCategory",t.MIN_ACTIVITY_DELTA="minActivityDelta",t.MAX_MUTATIONS="maxMutations",t.COLUMNS="columns",t.AGGREGATION="aggregation",t.ACTIVITY_TARGET="activityTarget",t.VALUE_INVARIANT_MAP="value",t.AGGREGATION_INVARIANT_MAP_VALUE="valueAggregation",t.DATA_SOURCE="dataSource"}(o||(o={})),function(t){t.COLOR="color",t.COLOR_AGGREGATION="colorAggregation",t.CUSTOM_COLOR_RANGE="customColorRange",t.MIN_COLOR_VALUE="minColorValue",t.MAX_COLOR_VALUE="maxColorValue",t.LOWER_BOUND_COLOR="lowerBoundColor",t.MIDDLE_COLOR="middleColor",t.UPPER_BOUND_COLOR="upperBoundColor",t.LOG_SCALE_COLOR="logScaleColor",t.SHOW_FILTER_CONTROLS="showFilterControls",t.SHOW_TOTAL_COUNT_COLUMN="showTotalCountColumn"}(r||(r={})),function(t){t.GENERAL="General",t.INVARIANT_MAP="Invariant Map",t.MUTATION_CLIFFS="Mutation Cliffs",t.AGGREGATION="Aggregation"}(s||(s={}));class M extends u.JsViewer{constructor(){super(),this.keyPressed=!1,this._scaledActivityColumn=null,this.doRender=!0,this.dataSource="Filtered",this._viewerGrid=null,this._positionColumns=null,this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._invariantMapSelection=null,this._mutationCliffsSelection=null,this._monomerMetaColumns=new Set,this.sequenceColumnName=this.column(o.SEQUENCE,{category:s.GENERAL,semType:u.SEMTYPE.MACROMOLECULE,nullable:!1}),this.dataSource=this.string(o.DATA_SOURCE,"Filtered",{category:s.GENERAL,choices:["All","Filtered"],nullable:!1,description:"Data source for calculations and rendering. Can be set to whole data set or filtered data only."}),this.activityColumnName=this.column(o.ACTIVITY,{category:s.GENERAL,nullable:!1,columnTypeFilter:"numerical"}),this.activityScaling=this.string(o.ACTIVITY_SCALING,d.rg.NONE,{category:s.GENERAL,choices:Object.values(d.rg),nullable:!1}),this.activityTarget=this.string(o.ACTIVITY_TARGET,d.wf.HIGH,{category:s.GENERAL,choices:Object.values(d.wf),nullable:!1}),this.targetColumnName=this.column(o.TARGET,{category:s.GENERAL,nullable:!0,columnTypeFilter:"categorical",userEditable:!1}),this.minActivityDelta=this.float(o.MIN_ACTIVITY_DELTA,0,{category:s.MUTATION_CLIFFS,min:0,max:100}),this.maxMutations=this.int(o.MAX_MUTATIONS,1,{category:s.MUTATION_CLIFFS,min:1,max:20}),this.columns=this.columnList(o.COLUMNS,[],{category:s.AGGREGATION}),this.aggregation=this.string(o.AGGREGATION,u.AGG.AVG,{category:s.AGGREGATION,choices:d.V5}),this.valueColumnName=this.column(o.VALUE_INVARIANT_MAP,{category:s.INVARIANT_MAP,userEditable:!0,nullable:!1,columnTypeFilter:"numerical"}),this.valueAggregation=this.string(o.AGGREGATION_INVARIANT_MAP_VALUE,u.AGG.TOTAL_COUNT,{category:s.INVARIANT_MAP,choices:d.V5,userEditable:!0,nullable:!1}),this.mutationCliffsDebouncer=(0,b.sg)((t,e,n)=>x(this,void 0,void 0,function*(){return yield(0,y.uz)(t,e,n)})),this.root.classList.add("peptides-viewer-show-title")}get viewerGrid(){var t;return null!==(t=this._viewerGrid)&&void 0!==t||(this._viewerGrid=this.createViewerGrid()),this._viewerGrid}render(){}get alphabet(){var t;return null!==(t=this.dataFrame.getCol(this.sequenceColumnName).getTag(w.gp.alphabet))&&void 0!==t?t:A.YI.UN}get model(){return m.i.getInstance(this.dataFrame)}get positionColumns(){var t,e,n;if(null!=this._positionColumns)return this._positionColumns;const i=t=>{const e=this.model.findViewer(t);return this.sequenceColumnName===(null==e?void 0:e.sequenceColumnName)?e._positionColumns:null};return null!=this.model.positionColumns&&this.sequenceColumnName===(null===(t=this.model.settings)||void 0===t?void 0:t.sequenceColumnName)?this._positionColumns=this.model.positionColumns:this instanceof I?this._positionColumns=i(m.q.MOST_POTENT_RESIDUES):this instanceof O&&(this._positionColumns=i(m.q.SEQUENCE_VARIABILITY_MAP)),null!==(e=this._positionColumns)&&void 0!==e||(this._positionColumns=null!==(n=i(m.q.LOGO_SUMMARY_TABLE))&&void 0!==n?n:(0,_.R)(this.dataFrame.getCol(this.sequenceColumnName),E.Z.getSeqHelper()).columns.toList()),this._positionColumns}propagateCanonicalizerTag(t){var e,n,i;const o=null===(e=this.dataFrame)||void 0===e?void 0:e.col(this.sequenceColumnName);if(!o)return;const r=null!==(n=o.temp[N.j.notationProvider])&&void 0!==n?n:null,s=null!==(i=null==r?void 0:r.monomerCanonicalizerFuncName)&&void 0!==i?i:null;s&&t.setTag(w.jz,s)}get monomerPositionStats(){var t;if(null!=this._monomerPositionStats)return this._monomerPositionStats;const e=t=>this.sequenceColumnName===(null==t?void 0:t.sequenceColumnName)&&this.activityColumnName===(null==t?void 0:t.activityColumnName)&&this.activityScaling===(null==t?void 0:t.activityScaling)&&t instanceof M&&t.dataSource===this.dataSource&&(t instanceof M&&this.valueColumnName==(null==t?void 0:t.valueColumnName)&&this.valueAggregation==(null==t?void 0:t.valueAggregation)||!(t instanceof M)&&(!this.valueColumnName||!this.valueAggregation||this.valueAggregation==u.AGG.VALUE_COUNT||this.valueAggregation==u.AGG.TOTAL_COUNT)),n=t=>{const n=this.model.findViewer(t);return e(n)?n._monomerPositionStats:null};null!==this.model.monomerPositionStats&&e(this.model.settings)?this._monomerPositionStats=this.model.monomerPositionStats:this instanceof I?this._monomerPositionStats=n(m.q.MOST_POTENT_RESIDUES):this instanceof O&&(this._monomerPositionStats=n(m.q.SEQUENCE_VARIABILITY_MAP));const i=this.dataFrame.col(this.valueColumnName),o=this.valueAggregation;return null!==(t=this._monomerPositionStats)&&void 0!==t||(this._monomerPositionStats=(0,y.Ej)(this.getScaledActivityColumn(),this.dataFrame.filter,this.positionColumns,{isFiltered:"Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse,aggValue:o&&i?{col:i,type:o}:void 0})),this._monomerPositionStats}get mutationCliffs(){if(null!=this._mutationCliffs)return this._mutationCliffs;const t=t=>{const e=this.model.findViewer(t);return i=e,(n=this).sequenceColumnName===(null==i?void 0:i.sequenceColumnName)&&n.activityColumnName===(null==i?void 0:i.activityColumnName)&&n.activityScaling===(null==i?void 0:i.activityScaling)&&n.minActivityDelta===(null==i?void 0:i.minActivityDelta)&&n.maxMutations===(null==i?void 0:i.maxMutations)&&(null==n?void 0:n.dataSource)===(null==i?void 0:i.dataSource)?e._mutationCliffs:null;var n,i};return this instanceof I?this._mutationCliffs=t(m.q.MOST_POTENT_RESIDUES):this instanceof O&&(this._mutationCliffs=t(m.q.SEQUENCE_VARIABILITY_MAP)),this._mutationCliffs}set mutationCliffs(t){this._mutationCliffs=t,this.viewerGrid.invalidate()}get cliffStats(){if(!this._mutationCliffStats&&this.mutationCliffs&&this.activityColumnName&&this.sequenceColumnName&&this.dataFrame.col(this.activityColumnName)){const t=this.dataFrame.col(this.activityColumnName).getRawData();this._mutationCliffStats=(0,y.Lw)(this.mutationCliffs,t)}return this._mutationCliffStats}set cliffStats(t){this._mutationCliffStats=t,this.viewerGrid.invalidate()}get mutationCliffsSelection(){var t;return null!==(t=this._mutationCliffsSelection)&&void 0!==t||(this._mutationCliffsSelection=(0,b.ZR)(this.positionColumns)),this._mutationCliffsSelection}set mutationCliffsSelection(t){var e,n;this._mutationCliffsSelection=t,this.model.fireBitsetChanged(this instanceof I?m.q.SEQUENCE_VARIABILITY_MAP:m.q.MOST_POTENT_RESIDUES);const i=this.model.findViewer(m.q.SEQUENCE_VARIABILITY_MAP);null===(e=null==i?void 0:i.viewerGrid)||void 0===e||e.invalidate();const o=this.model.findViewer(m.q.MOST_POTENT_RESIDUES);null===(n=null==o?void 0:o.viewerGrid)||void 0===n||n.invalidate(),this.model.analysisView.grid.invalidate()}getScaledActivityColumn(t=!1){var e,n,i;return(null===(e=this.model.settings)||void 0===e?void 0:e.activityColumnName)===this.activityColumnName&&(null===(n=this.model.settings)||void 0===n?void 0:n.activityScaling)===this.activityScaling&&(this._scaledActivityColumn=this.model.getScaledActivityColumn(t)),null!==(i=this._scaledActivityColumn)&&void 0!==i||(this._scaledActivityColumn=(0,b.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling)),t?u.DataFrame.fromColumns([this._scaledActivityColumn]).clone(this.dataFrame.filter).getCol(this._scaledActivityColumn.name):this._scaledActivityColumn}modifyMutationCliffsSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.mutationCliffsSelection=(0,b.vW)(this.mutationCliffsSelection,t,e):this._mutationCliffsSelection=(0,b.vW)(this.mutationCliffsSelection,t,e)}modifyInvariantMapSelection(t,e={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.invariantMapSelection=(0,b.vW)(this.invariantMapSelection,t,e):this._invariantMapSelection=(0,b.vW)(this.invariantMapSelection,t,e)}get invariantMapSelection(){var t;return null!==(t=this._invariantMapSelection)&&void 0!==t||(this._invariantMapSelection=(0,b.ZR)(this.positionColumns)),this._invariantMapSelection}set invariantMapSelection(t){this._invariantMapSelection=t,this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),this.model.analysisView.grid.invalidate()}onPropertyChanged(t){if(super.onPropertyChanged(t),this.dataFrame){switch(this.doRender=!0,t.name){case`${o.SEQUENCE}${d.To}`:this._positionColumns=null,this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._viewerGrid=null;break;case`${o.ACTIVITY}${d.To}`:case o.ACTIVITY_SCALING:this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._viewerGrid=null,this._scaledActivityColumn=null;break;case`${o.VALUE_INVARIANT_MAP}${d.To}`:case o.AGGREGATION_INVARIANT_MAP_VALUE:this._monomerPositionStats=null,this._viewerGrid=null,this._invariantMapSelection=null;break;case o.MIN_ACTIVITY_DELTA:case o.MAX_MUTATIONS:this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this.doRender=!1;break;case o.COLUMNS:case o.AGGREGATION:this instanceof O&&(this._viewerGrid=null);break;case o.ACTIVITY_TARGET:(this instanceof O||this instanceof I)&&(this._viewerGrid=null);break;case o.DATA_SOURCE:this.onFilterChanged(!1,!1),this.doRender=!0}null===this._mutationCliffs&&this.sequenceColumnName&&this.activityColumnName&&this.dataFrame&&this.calculateMutationCliffs().then(t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats})}}getAggregationColumns(){return Object.fromEntries(this.columns.map(t=>[t,this.aggregation]).filter(([t,e])=>this.model.df.columns.contains(t)&&this.model.df.col(t).matches("numerical")))}getTotalViewerAggColumns(){var t,e;const n=this.getAggregationColumns();return(0,b.zm)(this.model.df,this.columns,n,null===(e=null===(t=this.model)||void 0===t?void 0:t.settings)||void 0===e?void 0:e.columns)}createViewerGrid(){throw new Error("Not implemented")}exportMutationCliffs(){if(!this.mutationCliffs)return void a.shell.warning("Mutation cliffs have not been calculated yet.");const t=this.dataFrame.columns.toList().filter(t=>t.name!==this.activityColumnName&&t.name!==this.sequenceColumnName&&!this.positionColumns.some(e=>e.name===t.name)).map(t=>t.name),e=l.input.columns("Extra columns",{table:this.dataFrame,value:[],available:t,nullable:!0});l.dialog("Export Mutation Cliffs").add(e.root).onOK(()=>{var t;return this._doExportMutationCliffs(null!==(t=e.value)&&void 0!==t?t:[])}).show()}_doExportMutationCliffs(t){var e;const n=this.mutationCliffs,i=this.dataFrame.getCol(this.sequenceColumnName),o=i.categories,r=i.getRawData(),s=this.dataFrame.getCol(this.activityColumnName),l=s.getRawData(),c=[],h=[],f=[],m=[],p=[],g=[],v=t.map(()=>[]),C=t.map(()=>[]),y=new Set;for(const[e,i]of n.entries())for(const[e,n]of i.entries())for(const[e,i]of n.entries())for(const n of i){const i=e<n?`${e}-${n}`:`${n}-${e}`;if(y.has(i))continue;y.add(i);const a=o[r[e]],u=o[r[n]];c.push(a),h.push(u),f.push(`${a}#${u}`);const d=s.isNone(e)?null:l[e],b=s.isNone(n)?null:l[n];m.push(d),p.push(b),g.push(null==d||null==b?null:d-b);for(let i=0;i<t.length;i++){const o=t[i];v[i].push(o.isNone(e)?null:o.get(e)),C[i].push(o.isNone(n)?null:o.get(n))}}if(0===c.length)return void a.shell.warning("No mutation cliffs found to export.");const _=u.Column.fromStrings("Seq 1",c),w=u.Column.fromStrings("Seq 2",h),A=u.Column.fromStrings("Mutation",f);for(const t of[_,w]){for(const e of i.tags.keys())".notationProvider"!==e&&t.setTag(e,i.getTag(e));t.semType=i.semType}A.semType=d.uF.MACROMOLECULE_DIFFERENCE,A.setTag(d.gp.SEPARATOR,(0,b.AY)(i)),A.setTag(u.TAGS.UNITS,null!==(e=i.getTag(u.TAGS.UNITS))&&void 0!==e?e:""),A.setTag(u.TAGS.CELL_RENDERER,"MacromoleculeDifference"),A.temp[N.j.notationProvider]=i.temp[N.j.notationProvider];const S=[_,w,A,u.Column.fromList(u.COLUMN_TYPE.FLOAT,`Seq 1 ${this.activityColumnName}`,m),u.Column.fromList(u.COLUMN_TYPE.FLOAT,`Seq 2 ${this.activityColumnName}`,p),u.Column.fromList(u.COLUMN_TYPE.FLOAT,"Delta",g)];for(let e=0;e<t.length;e++){const n=t[e].name,i=t[e].type;S.push(u.Column.fromList(i,`Seq 1 ${n}`,v[e])),S.push(u.Column.fromList(i,`Seq 2 ${n}`,C[e]))}const T=u.DataFrame.fromColumns(S);T.name="Mutation Cliffs",a.shell.addTableView(T)}exportInvariantMap(){const t=this.monomerPositionStats,e=new Set,n=[];for(const i of Object.keys(t)){if("general"===i)continue;n.push(i);const o=t[i];for(const t of Object.keys(o))"general"!==t&&e.add(t)}const i=Array.from(e).sort(),o=[u.Column.fromStrings(d.$2.MONOMER,i)];for(const e of n){const n=t[e],r=i.map(t=>{var e,i;return null!==(i=null===(e=n[t])||void 0===e?void 0:e.count)&&void 0!==i?i:0});o.push(u.Column.fromList(u.COLUMN_TYPE.INT,e,r))}const r=u.DataFrame.fromColumns(o);r.name="Invariant Map",a.shell.addTableView(r)}detach(){this.subs.forEach(t=>t.unsubscribe())}onTableAttached(){var t,e,n,i;if(super.onTableAttached(),(0,b.B2)(this.dataFrame)){null===(t=this.getProperty(`${o.SEQUENCE}${d.To}`))||void 0===t||t.set(this,this.dataFrame.columns.bySemType(u.SEMTYPE.MACROMOLECULE).name);const r=null===(e=g()(this.dataFrame.columns.numerical).find(t=>t.name.toLowerCase().includes("activity")))||void 0===e?void 0:e.name;null===(n=this.getProperty(`${o.ACTIVITY}${d.To}`))||void 0===n||n.set(this,null!=r?r:g()(this.dataFrame.columns.numerical).next().value.name),null===(i=this.getProperty(`${o.VALUE_INVARIANT_MAP}${d.To}`))||void 0===i||i.set(this,null!=r?r:g()(this.dataFrame.columns.numerical).next().value.name),null===this.mutationCliffs&&this.sequenceColumnName&&this.activityColumnName&&this.calculateMutationCliffs().then(t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats}),this.subs.push(a.events.onContextMenu.subscribe(t=>{if(!(t&&t.causedBy&&t.args&&t.args.menu&&t.causedBy.target&&t.causedBy.target instanceof HTMLElement&&this.root.contains(t.causedBy.target)))return;const e=t.args.menu,n=e.group("Export");n.item("Export Mutation Cliffs...",()=>this.exportMutationCliffs()),n.item("Export Invariant Map",()=>this.exportInvariantMap()),(0,S.pj)().then(t=>{const n=t.getMonomerLib(),i=n.getMonomerSymbolsByType(T.kC.PEPTIDE).map(t=>n.getMonomer(T.kC.PEPTIDE,t)).filter(Boolean).map(t=>{var e;return null!==(e=t.meta)&&void 0!==e?e:{}}),o=new Set;i.forEach(t=>Object.keys(t).forEach(t=>o.add(t))),o.delete("colors"),e.group("Monomer Meta").items(Array.from(o),t=>{this._monomerMetaColumns.has(t)?this._monomerMetaColumns.delete(t):this._monomerMetaColumns.add(t),this._viewerGrid=null,this.render()},{isChecked:t=>this._monomerMetaColumns.has(t)})})})),this.subs.push(u.debounce(this.dataFrame.onFilterChanged,300).subscribe(()=>{"Filtered"===this.dataSource&&this.onFilterChanged(!0,!1)}))}else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";a.log.error(t),a.shell.warning(t)}}onFilterChanged(t,e=!1){if(this._monomerPositionStats=null,this._invariantMapSelection=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._mutationCliffs=null,e)return;this._viewerGrid=null;const n=this.model.findViewer(m.q.MOST_POTENT_RESIDUES);!n||this instanceof O||"Filtered"!==n.dataSource||n.onFilterChanged(!1,!0),t&&this.render(),this.sequenceColumnName&&this.activityColumnName&&this.calculateMutationCliffs().then(t=>{this.mutationCliffs=t.cliffs,this.cliffStats=t.cliffStats})}calculateMutationCliffs(){return x(this,void 0,void 0,function*(){var t;const e=this.dataFrame.getCol(this.activityColumnName),n=this.positionColumns.map(b.eY),i="Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse?this.dataFrame.filter:null,o={maxMutations:this.maxMutations,minActivityDelta:this.minActivityDelta,filter:null!==(t=null==i?void 0:i.getBuffer())&&void 0!==t?t:void 0},r=e.getRawData(),s=yield this.mutationCliffsDebouncer(r,n,o);return{cliffs:s,cliffStats:(0,y.Lw)(s,r)}})}}class I extends M{constructor(){super(),this.currentGridCell=null,this.customColorRange=!1,this.minColorValue=0,this.maxColorValue=0,this.logScaleColor=!1,this.showFilterControls=!0,this.showTotalCountColumn=!1,this._showSearchInput=!1,this.colorColumnName=this.column(r.COLOR,{category:s.INVARIANT_MAP,nullable:!1,columnTypeFilter:"numerical"}),this.colorAggregation=this.string(r.COLOR_AGGREGATION,u.AGG.AVG,{category:s.INVARIANT_MAP,choices:d.V5}),this.lowerBoundColor=this.int(r.LOWER_BOUND_COLOR,4278190335,{category:s.INVARIANT_MAP,editor:"color"}),this.middleColor=this.int(r.MIDDLE_COLOR,4294967295,{category:s.INVARIANT_MAP,editor:"color"}),this.upperBoundColor=this.int(r.UPPER_BOUND_COLOR,4294901760,{category:s.INVARIANT_MAP,editor:"color"}),this.showTotalCountColumn=this.bool(r.SHOW_TOTAL_COUNT_COLUMN,!1,{category:s.GENERAL,description:"Show total monomer count column"}),this.logScaleColor=this.bool(r.LOG_SCALE_COLOR,!1,{category:s.INVARIANT_MAP}),this.customColorRange=this.bool(r.CUSTOM_COLOR_RANGE,!1,{category:s.INVARIANT_MAP}),this.minColorValue=this.float(r.MIN_COLOR_VALUE,0,{category:s.INVARIANT_MAP}),this.maxColorValue=this.float(r.MAX_COLOR_VALUE,0,{category:s.INVARIANT_MAP}),this.showFilterControls=this.bool(r.SHOW_FILTER_CONTROLS,!0,{category:s.GENERAL,description:"Show monomer search and target controls",userEditable:!1}),this.monomerSearchInput=l.input.string("Search",{value:"",nullable:!0,placeholder:"Search monomer",tooltipText:"Search for monomer by symbol. For multiple monomers use comma as a separator.",onValueChanged:()=>{var t,e,n;const i=()=>{var t,e,n;return null===(n=null===(e=null===(t=this._viewerGrid)||void 0===t?void 0:t.dataFrame)||void 0===e?void 0:e.filter)||void 0===n?void 0:n.setAll(!0)},o=null!==(n=null===(e=null===(t=this.monomerSearchInput.value)||void 0===t?void 0:t.trim())||void 0===e?void 0:e.toLowerCase())&&void 0!==n?n:"";if(!o||null==this._viewerGrid||null==this._viewerGrid.dataFrame)return void i();const r=this._viewerGrid.dataFrame.col(d.$2.MONOMER);if(null==r)return void i();const s=o.split(",").map(t=>t.trim()).filter(t=>!!t),a=r.toList();this._viewerGrid.dataFrame.filter.init(t=>s.some(e=>a[t].toLowerCase().includes(e)))}})}get name(){return m.q.SEQUENCE_VARIABILITY_MAP}get mode(){var t;return null!==(t=this.dataFrame.getTag(d.gp.MONOMER_POSITION_MODE))&&void 0!==t?t:i.MUTATION_CLIFFS}set mode(t){this.dataFrame.setTag(d.gp.MONOMER_POSITION_MODE,t),this.viewerGrid.invalidate()}onTableAttached(){var t;if(super.onTableAttached(),(0,b.B2)(this.dataFrame))null===(t=this.getProperty(`${r.COLOR}${d.To}`))||void 0===t||t.set(this,this.activityColumnName);else{const t="PeptidesError: dataframe is missing Macromolecule or numeric columns";a.log.error(t),a.shell.warning(t)}this.render()}onPropertyChanged(t){var e;if(super.onPropertyChanged(t),this.dataFrame){switch(t.name){case o.SEQUENCE:this._invariantMapSelection=null;break;case r.SHOW_TOTAL_COUNT_COLUMN:this._viewerGrid&&this._viewerGrid.columns.byName(d.$2.TOTAL_COUNT)&&(this._viewerGrid.columns.byName(d.$2.TOTAL_COUNT).visible=this.showTotalCountColumn,this.doRender=!1)}null===(e=this.positionColumns)||void 0===e||e.forEach(t=>{t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=null}),this.doRender?this.render():this.viewerGrid.invalidate()}}createMonomerPositionDf(){const t=new Set,e=this.positionColumns;for(const e of Object.keys(this.monomerPositionStats)){if("general"===e)continue;const n=this.monomerPositionStats[e];for(const e of Object.keys(n))"general"!==e&&t.add(e)}const n=Array.from(t),i=u.Column.fromStrings(d.$2.MONOMER,n),o=u.DataFrame.fromColumns([i]),r=(0,S.pj)().then(t=>{const e=t.getMonomerLib();return e?n.map(t=>{var n,i;return null!==(i=null===(n=e.getMonomer(T.kC.PEPTIDE,t))||void 0===n?void 0:n.meta)&&void 0!==i?i:{}}):n.map(t=>({}))}),s=o.columns.addNewInt(d.$2.TOTAL_COUNT),a={},l=this.monomerPositionStats;for(const t of Object.keys(l)){if("general"===t)continue;const e=l[t];for(const t of Object.keys(e))"general"!==t&&(a[t]||(a[t]=0),a[t]+=e[t].count)}s.init(t=>{var e;return null!==(e=a[i.get(t)])&&void 0!==e?e:0}),this._monomerMetaColumns.forEach(t=>{const e=o.columns.addNewString(t);r.then(n=>{e.init(e=>{var i,o;return null!==(o=null===(i=n[e][t])||void 0===i?void 0:i.toString())&&void 0!==o?o:""})})}),o.name="SAR";for(const t of e)o.columns.addNewBool(t.name);return o}cacheInvariantMapColors(){if(this.colorColumnName&&this.dataFrame.col(this.colorColumnName)){const t=this.dataFrame.getCol(this.colorColumnName).getRawData();let e=9999999,n=-9999999;const i="Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse?this.dataFrame.filter:null,o=null==i?t=>!0:t=>i.get(t);for(const i of this.positionColumns){i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]={};const r=i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE],s=i.name,a=i.getRawData(),l=i.categories;if(!this.monomerPositionStats[s])continue;const c=this.monomerPositionStats[s];for(const s of Object.keys(c)){if("general"===s)continue;const c=[];for(let t=0;t<i.length;++t)l[a[t]]===s&&o(t)&&c.push(t);const h=u.Column.float("color",c.length).init(e=>t[c[e]]).aggregate(this.colorAggregation);r[s]=h,e=Math.min(e,h),n=Math.max(n,h)}i.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=r}const r=this.customColorRange&&null!=this.minColorValue&&null!=this.maxColorValue;let s=r?this.minColorValue:e,a=r?this.maxColorValue:n;const l=this.logScaleColor&&s>1e-30&&a>1e-30&&e>1e-30&&n>1e-30;l&&(s=Math.log(s),a=Math.log(a));for(const t of this.positionColumns){const i=t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE];if(i){for(const t of Object.keys(i))this.activityTarget===d.wf.LOW&&(i[t]=a-i[t]+s),i[t]=u.Color.scaleColor(l?Math.log(i[t]):i[t],s,a,void 0,[this.lowerBoundColor,this.middleColor,this.upperBoundColor]);t.temp[d.gp.INVARIANT_MAP_COLOR_CACHE]=i,t.temp[d.gp.INVARIANT_MAP_COLOR_MIN_CACHE]=e,t.temp[d.gp.INVARIANT_MAP_COLOR_MAX_CACHE]=n}}}}createViewerGrid(){const t=this.createMonomerPositionDf(),e=t.plot.grid();e.sort([d.$2.MONOMER]);const n=this.positionColumns.map(t=>t.name);e.columns.setOrder([d.$2.TOTAL_COUNT,d.$2.MONOMER,...this._monomerMetaColumns,...n]);const o=e.columns.byName(d.$2.TOTAL_COUNT);this.showTotalCountColumn&&null!=o?o.visible=!0:null!=o&&(o.visible=!1);const r=t.getCol(d.$2.MONOMER);f.rI(r,this.alphabet,!0),this.propagateCanonicalizerTag(r),this.cacheInvariantMapColors(),e.onCellRender.subscribe(t=>P(t,this,this.mode===i.INVARIANT_MAP,this.dataFrame.getCol(this.colorColumnName),this.colorAggregation)),e.onCellTooltip((t,e,n)=>{var o,r,s,a,l,c,h;if(!t.isTableCell||!(null===(o=null==t?void 0:t.cell.column)||void 0===o?void 0:o.name)||this._monomerMetaColumns.has(t.cell.column.name)||t.cell.column.name===d.$2.TOTAL_COUNT)return this.model.unhighlight(),!0;const f=this.getMonomerPosition(t);(0,b.dl)(f,this.dataFrame,this.monomerPositionStats),this.model.isHighlighting=!0;const m=this.getTotalViewerAggColumns(),p={},g={};if(this.mode===i.INVARIANT_MAP)this.colorColumnName&&this.colorAggregation&&this.colorColumnName!==this.valueColumnName?(m.unshift([this.colorColumnName,this.colorAggregation]),p[`${this.colorAggregation}(${this.colorColumnName})`]=" (color)"):this.colorColumnName&&this.colorAggregation&&this.colorColumnName===this.valueColumnName&&(p["Mean activity"]=" (color)"),this.valueColumnName&&this.valueAggregation&&this.valueAggregation!==u.AGG.VALUE_COUNT&&this.valueAggregation!==u.AGG.TOTAL_COUNT&&m.unshift([this.valueColumnName,this.valueAggregation]);else{const t=null===(s=null===(r=this.mutationCliffs)||void 0===r?void 0:r.get(f.monomerOrCluster))||void 0===s?void 0:s.get(f.positionOrClusterType);if(t){let e=0;for(const n of t.values())e+=n.length;g["Pairs count"]=e.toString()}}return(0,C.D)(this.model.df,this.getScaledActivityColumn(),m,{fromViewer:!0,isMutationCliffs:this.mode===i.MUTATION_CLIFFS,monomerPosition:f,x:e,y:n,mpStats:this.monomerPositionStats,cliffStats:null!==(l=null===(a=this.cliffStats)||void 0===a?void 0:a.stats)&&void 0!==l?l:void 0,postfixes:p,additionalStats:g,cliffIndexes:null===(h=null===(c=this.mutationCliffs)||void 0===c?void 0:c.get(f.monomerOrCluster))||void 0===h?void 0:h.get(f.positionOrClusterType)})}),e.root.addEventListener("mouseleave",t=>this.model.unhighlight()),u.debounce(e.onCurrentCellChanged,500).subscribe(t=>{var n,o,r,s,a,l,c,h,f,p,g,v,C;try{if(!t||!t.dart||!(null===(o=null===(n=null==t?void 0:t.cell)||void 0===n?void 0:n.column)||void 0===o?void 0:o.name)||this._monomerMetaColumns.has(t.cell.column.name)||t.cell.column.name==d.$2.TOTAL_COUNT||!t.isTableCell)return;if(-1===t.gridRow&&(this.mode===i.INVARIANT_MAP?this._invariantMapSelection=(0,b.ZR)(this.positionColumns):this._mutationCliffsSelection=(0,b.ZR)(this.positionColumns),this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),e.invalidate()),!this.keyPressed||t.cell.column.name===d.$2.MONOMER)return;if(null!==this.currentGridCell){const t=this.getMonomerPosition(this.currentGridCell);this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1):(null===(a=null===(s=null===(r=this.mutationCliffs)||void 0===r?void 0:r.get(t.monomerOrCluster))||void 0===s?void 0:s.get(t.positionOrClusterType))||void 0===a?void 0:a.size)&&this.modifyMutationCliffsSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1)}const u=this.getMonomerPosition(t);this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(u,{shiftPressed:!0,ctrlPressed:!1},!0):(null===(h=null===(c=null===(l=this.mutationCliffs)||void 0===l?void 0:l.get(u.monomerOrCluster))||void 0===c?void 0:c.get(u.positionOrClusterType))||void 0===h?void 0:h.size)&&this.modifyMutationCliffsSelection(u,{shiftPressed:!0,ctrlPressed:!1},!0),e.invalidate(),setTimeout(()=>null==e?void 0:e.invalidate(),300)}catch(t){console.error(t)}finally{this.keyPressed=!1,(null===(f=t.tableColumn)||void 0===f?void 0:f.name)&&t.grid&&t.isTableCell&&(null===(p=null==t?void 0:t.cell)||void 0===p?void 0:p.column.name)!=d.$2.MONOMER&&!this._monomerMetaColumns.has(null===(v=null===(g=t.cell)||void 0===g?void 0:g.column)||void 0===v?void 0:v.name)&&(null===(C=t.cell)||void 0===C?void 0:C.column.name)!==d.$2.TOTAL_COUNT?this.currentGridCell=u.GridCell.fromColumnRow(t.grid,t.tableColumn.name,t.gridRow):this.currentGridCell=null}}),e.root.addEventListener("keydown",t=>{if(this.keyPressed=t.key.startsWith("Arrow"),!this.keyPressed){if("Escape"===t.key||"KeyA"===t.code&&t.ctrlKey&&t.shiftKey)this.mode===i.INVARIANT_MAP?this._invariantMapSelection=(0,b.ZR)(this.positionColumns):this._mutationCliffsSelection=(0,b.ZR)(this.positionColumns);else{if("KeyA"!==t.code||!t.ctrlKey)return;{const t=Object.keys(this.monomerPositionStats).filter(t=>"general"!==t);for(const e of t){const t=Object.keys(this.monomerPositionStats[e]).filter(t=>"general"!==t);for(const n of t){const t={monomerOrCluster:n,positionOrClusterType:e};this.mode===i.INVARIANT_MAP?this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1):this.modifyMutationCliffsSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1)}}}}this.model.fireBitsetChanged(m.q.SEQUENCE_VARIABILITY_MAP),e.invalidate()}}),e.root.addEventListener("click",n=>{var o,r,s,a,l,u;const c=e.hitTest(n.offsetX,n.offsetY);if(!(null==c?void 0:c.isTableCell)||(null===(o=null==c?void 0:c.tableColumn)||void 0===o?void 0:o.name)===d.$2.MONOMER||(null===(r=null==c?void 0:c.tableColumn)||void 0===r?void 0:r.name)&&this._monomerMetaColumns.has(c.tableColumn.name)||(null===(s=null==c?void 0:c.tableColumn)||void 0===s?void 0:s.name)===d.$2.TOTAL_COUNT)return;const h=this.getMonomerPosition(c);this.mode===i.INVARIANT_MAP?(this.modifyInvariantMapSelection(h,{shiftPressed:n.shiftKey,ctrlPressed:n.ctrlKey}),(0,b.CD)(this.invariantMapSelection)&&(t.currentRowIdx=-1)):(null===(u=null===(l=null===(a=this.mutationCliffs)||void 0===a?void 0:a.get(h.monomerOrCluster))||void 0===l?void 0:l.get(h.positionOrClusterType))||void 0===u?void 0:u.size)&&this.modifyMutationCliffsSelection(h,{shiftPressed:n.shiftKey,ctrlPressed:n.ctrlKey}),e.invalidate()}),L(e),e.props.showRowHeader=!0;const s=e.onAfterDrawContent.subscribe(()=>{const t=e.col(d.$2.MONOMER);if(40!==t.width){t.width=40;for(const t of n)e.col(t).width=40}else s.unsubscribe()});return e}getMonomerPosition(t){return{monomerOrCluster:t.cell.dataFrame.get(d.$2.MONOMER,t.tableRowIndex),positionOrClusterType:t.tableColumn.name}}render(){var t;if(h()(this.root).empty(),!this.dataFrame||!this.activityColumnName||!this.sequenceColumnName)return void this.root.appendChild(l.divText("Please, select a sequence and activity columns in the viewer properties"));const e=this.getProperty(r.COLOR);e&&(e.choices=g()(a.shell.t.columns.numerical).toArray().map(t=>t.name),e.get(this)===d.$2.ACTIVITY_SCALED&&e.set(this,d.$2.ACTIVITY)),h()(this.root).empty();let n=l.divText(m.q.MOST_POTENT_RESIDUES,{id:"pep-viewer-title"});if(this.name===m.q.SEQUENCE_VARIABILITY_MAP){const t=l.input.bool(i.MUTATION_CLIFFS,{value:this.mode===i.MUTATION_CLIFFS});t.root.addEventListener("click",()=>{e.value=!1,t.value=!0,this.mode=i.MUTATION_CLIFFS}),t.setTooltip("Statistically significant changes in activity");const e=l.input.bool(i.INVARIANT_MAP,{value:this.mode===i.INVARIANT_MAP});e.root.addEventListener("click",()=>{t.value=!1,e.value=!0,this.mode=i.INVARIANT_MAP}),e.setTooltip("Number of sequences having monomer-position");const o=t=>{h()(t.root).find(".ui-input-editor").css("margin","0px").attr("type","radio"),h()(t.root).find(".ui-input-description").css("padding","0px").css("padding-right","16px"),h()(t.captionLabel).addClass("ui-label-right")};o(t),o(e),n=l.divH([t.root,e.root],{id:"pep-viewer-title"}),h()(n).css("width","auto").css("align-self","center")}const o=this.viewerGrid.root;o.style.width="auto";const s=l.icons.search(()=>{this._showSearchInput=!this._showSearchInput,this.monomerSearchInput.input.style.display=this._showSearchInput?"block":"none"},"Toggle monomer search input visibility");this.monomerSearchInput.input.style.display=this._showSearchInput?"block":"none",h()(s).addClass("pep-help-icon"),(0,b.BX)(s.style).set("top","3px").set("fontSize","14px");const u=l.divH([this.monomerSearchInput.input],{style:{alignSelf:"center",justifyContent:"center",width:"100%",flexWrap:"wrap"}}),c=l.divH([s,n,u],{style:{alignSelf:"center",lineHeight:"normal",flexDirection:"column",width:"100%"}});this.root.appendChild(l.divV([c,o])),null===(t=this.viewerGrid)||void 0===t||t.invalidate(),this.monomerSearchInput.fireChanged()}}class O extends M{constructor(){super(),this.currentGridRowIdx=null}get name(){return m.q.MOST_POTENT_RESIDUES}onTableAttached(){super.onTableAttached(),this.render()}onPropertyChanged(t){super.onPropertyChanged(t),this.doRender&&this.render()}onFilterChanged(t,e=!1){if(this._monomerPositionStats=null,this._invariantMapSelection=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._mutationCliffs=null,e)return;this._viewerGrid=null;const n=this.model.findViewer(m.q.SEQUENCE_VARIABILITY_MAP);"Filtered"===(null==n?void 0:n.dataSource)&&n.onFilterChanged(!1,!0),t&&this.render()}createMostPotentResiduesDf(){var t;const e=Object.entries(this.monomerPositionStats),n=new Array(e.length-1),i=new Array(n.length),o=new Array(n.length),r=new Array(n.length),s=new Array(n.length),a=new Array(n.length),l=new Array(n.length),c=this.getTotalViewerAggColumns(),h=c.map(([t,e])=>(0,v.hX)(e,t)),f=new Array(h.length);h.forEach((t,e)=>f[e]=new Array(n.length));let m=0;for(const[p,g]of e){const e=g.general;if(!e)continue;if(1===Object.entries(g).length)continue;const C=[];for(const[n,i]of Object.entries(g))"general"!==n&&(i.count>1&&(null==i.pValue||(null!==(t=i.pValue)&&void 0!==t?t:1)<=.05)&&C.push([n,i]),i.pValue===e.minPValue&&C.push([n,i]));let y=null;0===C.length&&(y=Object.entries(g).find(([t,e])=>"general"!=t));for(const[t,e]of C)(null===y||this.activityTarget===d.wf.HIGH&&y[1].meanDifference<e.meanDifference||this.activityTarget===d.wf.LOW&&y[1].meanDifference>e.meanDifference)&&(y=[t,e]);if(null===y)continue;n[m]=parseInt(p),i[m]=y[0],o[m]=y[1].meanDifference,r[m]=y[1].pValue,s[m]=y[1].count,a[m]=y[1].ratio,l[m]=y[1].mean;const b=this.monomerPositionStats[p][y[0]],_=u.BitSet.fromBytes(b.mask.buffer.buffer,this.model.df.col(this.activityColumnName).length);for(let t=0;t<h.length;t++){const[e,n]=c[t];f[t][m]=(0,v.lh)(this.model.df.getCol(e),n,_)}++m}n.length=m,i.length=m,o.length=m,r.length=m,s.length=m,a.length=m,l.length=m;const p=u.DataFrame.create(m),g=p.columns;return g.add(u.Column.fromList(u.TYPE.INT,d.$2.POSITION,n)),g.add(u.Column.fromList(u.TYPE.STRING,d.$2.MONOMER,i)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.MEAN_DIFFERENCE,o)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.MEAN,l)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.P_VALUE,r)),g.add(u.Column.fromList(u.TYPE.INT,d.$2.COUNT,s)),g.add(u.Column.fromList(u.TYPE.FLOAT,d.$2.RATIO,a)),h.forEach((t,e)=>g.add(u.Column.fromList(u.TYPE.FLOAT,t,f[e]))),p}createViewerGrid(){const t=this.createMostPotentResiduesDf(),e=t.plot.grid();e.sort([d.$2.POSITION]);const n=e.col(d.$2.P_VALUE);n.format="#.000",n.name="P-value";const i=t.getCol(d.$2.MONOMER);f.rI(i,this.alphabet,!0),this.propagateCanonicalizerTag(i),e.onCellRender.subscribe(t=>P(t,this,!1)),e.onCellTooltip((t,e,n)=>{var i,o;if(!t.isTableCell)return this.model.unhighlight(),!0;const r=this.getMonomerPosition(t);if((0,b.dl)(r,this.dataFrame,this.monomerPositionStats),this.model.isHighlighting=!0,(null===(i=t.tableColumn)||void 0===i?void 0:i.name)===d.$2.MONOMER)r.positionOrClusterType=d.$2.MONOMER;else if((null===(o=t.tableColumn)||void 0===o?void 0:o.name)!==d.$2.MEAN_DIFFERENCE)return!1;const s=this.getTotalViewerAggColumns(),a=null==t.tableRowIndex?void 0:(0,v.m2)(t.grid.dataFrame,t.tableRowIndex,s,{});return(0,C.D)(this.model.df,this.getScaledActivityColumn(),s,{fromViewer:!0,isMostPotentResidues:!0,monomerPosition:r,x:e,y:n,mpStats:this.monomerPositionStats,aggrColValues:a})}),u.debounce(e.onCurrentCellChanged,500).subscribe(n=>{var i,o,r;try{if(-1===n.gridRow)return this._mutationCliffsSelection=(0,b.ZR)(this.positionColumns),this._invariantMapSelection=(0,b.ZR)(this.positionColumns),this.model.fireBitsetChanged(m.q.MOST_POTENT_RESIDUES),void e.invalidate();if(this.keyPressed&&t.currentCol.name!==d.$2.MEAN_DIFFERENCE||!this.keyPressed)return;const s=this.getMonomerPosition(n);if(null!==this.currentGridRowIdx){const t=this.getMonomerPosition(e.cell("Diff",this.currentGridRowIdx));this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!0},!1)}(null===(r=null===(o=null===(i=this.mutationCliffs)||void 0===i?void 0:i.get(s.monomerOrCluster))||void 0===o?void 0:o.get(s.positionOrClusterType))||void 0===r?void 0:r.size)&&this.modifyInvariantMapSelection(s,{shiftPressed:!0,ctrlPressed:!1}),e.invalidate()}finally{this.keyPressed=!1,this.currentGridRowIdx=n.gridRow}}),e.root.addEventListener("keydown",n=>{if(this.keyPressed=n.key.startsWith("Arrow"),!this.keyPressed){if("Escape"===n.key||"KeyA"===n.code&&n.ctrlKey&&n.shiftKey)this._mutationCliffsSelection=(0,b.ZR)(this.positionColumns);else{if("KeyA"!==n.code||!n.ctrlKey)return;for(let n=0;n<t.rowCount;++n){const t=this.getMonomerPosition(e.cell("Diff",n));this.modifyInvariantMapSelection(t,{shiftPressed:!0,ctrlPressed:!1},!1)}}this.model.fireBitsetChanged(m.q.MOST_POTENT_RESIDUES),e.invalidate()}}),e.root.addEventListener("mouseleave",t=>this.model.unhighlight()),e.root.addEventListener("click",t=>{var n,i,o;const r=e.hitTest(t.offsetX,t.offsetY);if(!(null==r?void 0:r.isTableCell)||r.tableColumn.name!==d.$2.MEAN_DIFFERENCE)return;const s=this.getMonomerPosition(r);(null===(o=null===(i=null===(n=this.monomerPositionStats)||void 0===n?void 0:n[s.positionOrClusterType])||void 0===i?void 0:i[s.monomerOrCluster])||void 0===o?void 0:o.count)&&(this.modifyInvariantMapSelection(s,{shiftPressed:t.shiftKey,ctrlPressed:t.ctrlKey}),e.invalidate())}),L(e);const o=e.col(d.$2.MEAN_DIFFERENCE);o.name="Diff";const r=e.onAfterDrawContent.subscribe(()=>{const t=e.col(d.$2.MONOMER);if(40===t.width)return o.width=40,void r.unsubscribe();t.width=40,o.width=40});return e}getMonomerPosition(t){return{monomerOrCluster:t.cell.dataFrame.get(d.$2.MONOMER,t.tableRowIndex),positionOrClusterType:`${t.cell.dataFrame.get(d.$2.POSITION,t.tableRowIndex)}`}}render(){var t;if(h()(this.root).empty(),!this.dataFrame||!this.activityColumnName||!this.sequenceColumnName)return void this.root.appendChild(l.divText("Please, select a sequence and activity columns in the viewer properties"));const e=this.viewerGrid.root;e.style.width="auto",this.root.appendChild(l.divV([e])),null===(t=this.viewerGrid)||void 0===t||t.invalidate()}}function P(t,e,n,i,o){var r,s,a,l,c;const h=[...e.positionColumns.map(t=>t.name),d.$2.MEAN_DIFFERENCE],m=t.g,p=t.bounds;m.save(),m.beginPath(),m.rect(p.x,p.y,p.width,p.height),m.clip();const g=t.cell,v=null===(r=g.tableColumn)||void 0===r?void 0:r.name,C=g.tableRowIndex;if(!g.isTableCell||-1===h.indexOf(v))return void m.restore();const y=g.grid.table,b=y.get(d.$2.MONOMER,C),_=v!==d.$2.MEAN_DIFFERENCE?v:y.get(d.$2.POSITION,C).toFixed(),w=e.monomerPositionStats[_];if(!w[b])return t.preventDefault(),void m.restore();if(n){const t=null!==(s=w[b].aggValue)&&void 0!==s?s:w[b].count,n=e.positionColumns.find(t=>t.name===_),i=null!==(a=n.temp[d.gp.INVARIANT_MAP_COLOR_CACHE])&&void 0!==a?a:{};let o=u.Color.white;null!=i[b]?o=i[b]:e instanceof I&&(e.cacheInvariantMapColors(),o=null!==(c=(null!==(l=n.temp[d.gp.INVARIANT_MAP_COLOR_CACHE])&&void 0!==l?l:{})[b])&&void 0!==c?c:u.Color.white),f.rW(m,b,_,e.invariantMapSelection,t,p,o)}else f.Yd(m,b,_,e,p);t.preventDefault(),m.restore()}function L(t){const e=t.props;e.allowEdit=!1,e.allowRowSelection=!1,e.allowBlockSelection=!1,e.allowColSelection=!1,e.showRowHeader=!1,e.showCurrentRowIndicator=!1,e.showReadOnlyNotifications=!1,e.rowHeight=20}},7654(t,e,n){"use strict";n.d(e,{HV:()=>m,M1:()=>p,QD:()=>g});var i,o=n(7389),r=n(6082),s=n(7233),a=n.n(s),l=n(4139),u=n(5070),c=n(8608),h=n(5480),d=n(8774);!function(t){t.SEPARATE_MONOMERS="separateMonomers",t.SEPARATE_POSITIONS="separatePositions",t.SEPARATE_CLUSTERS="separateClusters"}(i||(i={}));const f="general";function m(t,e){if(!t.selection.anyTrue)return o.divText("No distribution");const n=()=>{const n=[C(f,t,e)];for(const o of Object.values(i))"true"!==t.getTag(o)||o===i.SEPARATE_CLUSTERS&&!e.clusterColName||n.push(C(o,t,e));return 1===n.length?n[0]:o.div(n)},r=o.div(n()),s=Object.values(i),l=new Array(s.length);for(let u=0;u<s.length;u++){const c=s[u].substring(8);l[u]=o.input.bool(c,{value:"true"===t.getTag(s[u]),onValueChanged:e=>{t.setTag(s[u],`${e}`),a()(r).empty(),r.append(n())}}),a()(l[u].captionLabel).addClass("ui-label-right").css("text-align","left"),a()(l[u].root).find(".ui-input-editor").css("margin","0px"),a()(l[u].root).find(".ui-input-description").css("margin","0px"),l[u].setTooltip(`Show distribution for each ${c}`),c===i.SEPARATE_CLUSTERS?l[u].enabled=!(!e.clusterColName||!e.clusterSelection[h.W.ORIGINAL]):c!==i.SEPARATE_MONOMERS&&c!==i.SEPARATE_POSITIONS||(l[u].enabled=0!==Object.entries(e.monomerPositionSelection).length)}const u=o.form(l,{style:{flexDirection:"row"}});return o.divV([u,r])}function p(t,e=!1){const n=t.plot.histogram({filteringEnabled:!1,valueColumnName:l.$2.ACTIVITY,splitColumnName:l.$2.SPLIT_COL,legendVisibility:"Never",showXAxis:!0,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1,backColor:e?"#fdffe5":"#fffff"});return n.root.style.width="auto",n}function g(t,e={}){var n,i;null!==(n=e.fractionDigits)&&void 0!==n||(e.fractionDigits=3);const o={[null!==(i=null==e?void 0:e.countName)&&void 0!==i?i:"Count"]:`${t.count} (${(100*t.ratio).toFixed(e.fractionDigits)}%)`,"Mean difference":t.meanDifference.toFixed(e.fractionDigits),"Mean activity":t.mean.toFixed(e.fractionDigits)};return null!=t.pValue&&(o["p-value"]=t.pValue<.01?"<0.01":t.pValue.toFixed(e.fractionDigits)),o}function v(t,e,n,i={}){const o=p((0,c.FZ)(n.activityCol,t.selection,t)),s=(0,u.I_)(t,Object.entries(n.columns),{filterDf:!0,mask:r.BitSet.fromBytes(e.mask.buffer.buffer,e.mask.length)}),l=g(e),h=Object.assign(Object.assign({},l),s),d=(0,c.F2)(o,h,i);return a()(d).addClass("d4-flex-col"),d}function C(t,e,n){let r=o.divText("No distribution");const s=e.selection.clone().and(e.filter),a=d.A.fromUint32Array(s.length,new Uint32Array(s.getBuffer().buffer));switch(t){case f:r=v(e,e.selection.anyTrue&&e.selection.anyFalse?(0,u.GT)(n.activityCol.getRawData(),a,(0,u.pY)(e.filter)):{count:n.activityCol.length,pValue:null,meanDifference:0,ratio:1,mask:a,mean:n.activityCol.stats.avg},n);break;case i.SEPARATE_CLUSTERS:r=function(t,e,n){const i=t.rowCount,r=[],s=e.activityCol.getRawData(),a=t.getCol(e.clusterColName),l=a.categories,f=a.getRawData(),m=(0,u.pY)(t.filter),p=n[h.W.ORIGINAL].map(t=>l.indexOf(t)),g=new Array(p.length).fill(new d.A(i));for(let t=0;t<i;t++){const e=f[t],n=p.indexOf(e);-1!==n&&g[n].setTrue(t)}for(let n=0;n<p.length;n++){const i=p[n],o=(0,u.GT)(s,g[n],m);r.push(v(t,o,e,{[c.AN.SELECTION]:l[i]}))}const C=n[h.W.CUSTOM];for(const n of C){const o=t.getCol(n),a=d.A.fromUint32Array(i,o.getRawData()),l=(0,u.GT)(s,a,m);r.push(v(t,l,e,{[c.AN.SELECTION]:n}))}return o.div(r,"d4-flex-wrap")}(e,n,n.clusterSelection);break;case i.SEPARATE_MONOMERS:r=function(t,e,n){var i,r,s;const a=Object.keys(n),l=t.rowCount,h=[],f=[],m=[],p=[],g=e.activityCol.getRawData(),C=(0,u.pY)(t.filter);for(const o of a){const a=n[o],y=new d.A(l);for(let e=0;e<a.length;e++){const n=a[e];null!==(i=f[e])&&void 0!==i||(f[e]=t.getCol(n)),null!==(r=m[e])&&void 0!==r||(m[e]=f[e].categories),null!==(s=p[e])&&void 0!==s||(p[e]=f[e].getRawData());const u=m[e].indexOf(o);for(let t=0;t<l;t++)p[e][t]===u&&y.setTrue(t)}const b=(0,u.GT)(g,y,C);h.push(v(t,b,e,{[c.AN.SELECTION]:o}))}return o.div(h,"d4-flex-wrap")}(e,n,function(t){const e={},n=Object.keys(t);for(const i of n)for(const n of t[i])e.hasOwnProperty(n)?e[n].includes(i)||e[n].push(i):e[n]=[i];return e}(n.monomerPositionSelection));break;case i.SEPARATE_POSITIONS:r=function(t,e,n){var i,r,s;const a=Object.keys(n),l=t.rowCount,h=[],f=e.activityCol.getRawData(),m=[],p=[],g=[],C=(0,u.pY)(t.filter);for(let o=0;o<a.length;o++){const y=a[o],b=n[y];if(0===b.length)continue;null!==(i=m[o])&&void 0!==i||(m[o]=t.getCol(y)),null!==(r=p[o])&&void 0!==r||(p[o]=m[o].categories),null!==(s=g[o])&&void 0!==s||(g[o]=m[o].getRawData());const _=new d.A(t.rowCount);for(let t=0;t<b.length;t++){const e=b[t],n=p[o].indexOf(e);for(let t=0;t<l;t++)g[o][t]===n&&_.setTrue(t)}const w=(0,u.GT)(f,_,C);h.push(v(t,w,e,{[c.AN.SELECTION]:y}))}return o.div(h,"d4-flex-wrap")}(e,n,n.monomerPositionSelection)}return o.divV([o.h1((l=t,l===f?"General":l.substring(8))),r]);var l}},7923(t,e,n){"use strict";n.d(e,{F:()=>c});var i=n(7389),o=n(6082),r=n(4139),s=n(8608),a=n(3163),l=n(4025),u=n(7654);function c(t,e,n=!0){var r,a,l,c,d;const f=h(t,e);if(!f)return new o.Widget(i.label("No mutations table generated"));const{pairsGrid:m,uniqueSequencesGrid:p,aminoToInput:g}=f,v=[m,p],C=i.divV([g.root,...v.map(t=>t.root)],{style:{width:"100%"}});if(1===Object.values(e.mutationCliffsSelection).filter(t=>t.length>0).length){const t=Object.keys(e.mutationCliffsSelection).find(t=>e.mutationCliffsSelection[t].length>0),n=e.mutationCliffsSelection[t];if(1===n.length){const i=n[0],o=null===(a=null===(r=e.mutationCliffs)||void 0===r?void 0:r.get(i))||void 0===a?void 0:a.get(t);if(o&&o.size>0){const n=(0,s.Z7)(e.activityCol,o,i),r=(0,u.M1)(n,!1),a=null===(d=null===(c=null===(l=e.mutationCliffStats)||void 0===l?void 0:l.stats)||void 0===c?void 0:c.get(i))||void 0===d?void 0:d.get(t),h={};let f=0;for(const t of o.values())f+=t.length;h["Pairs count"]=f.toString(),a&&(h["Unique Count"]=a.mask.trueCount().toString(),Object.assign(h,(0,u.QD)(a,{countName:"MP in cliffs count"})));const m=(0,s.F2)(r,h);r.root.style.maxHeight="100px",m.style.marginTop="10px",C.appendChild(m)}}}return n&&(0,s.BE)("Mutation Cliffs pairs",g.root,C,()=>{const n=h(t,e),o=i.splitH([i.divV([n.aminoToInput.root,n.pairsGrid.root],{style:{marginRight:"10px"}}),i.divV([n.uniqueSequencesGrid.root],{style:{marginLeft:"10px"}})],{style:{width:"100%",height:"100%"}},!0);return setTimeout(()=>{var t,i;if(document.contains(o)){const r=o.offsetWidth,s=null===(t=n.pairsGrid.canvas)||void 0===t?void 0:t.parentElement;n.pairsGrid.props.showRowHeader=!0,n.uniqueSequencesGrid.props.showRowHeader=!0;const a=null===(i=n.uniqueSequencesGrid.canvas)||void 0===i?void 0:i.parentElement;if(s&&a&&(s.style.height="100%",a.style.height="calc(100% - 20px)",a.style.marginTop="20px",r>400)){const t=Math.max(.33*r,200),i=n.pairsGrid.columns.byName("Mutation");i&&(i.width=t);const o=n.uniqueSequencesGrid.columns.byName(e.sequenceColumnName);o&&(o.width=t)}}},500),o}),new o.Widget(C)}function h(t,e){var n,u;const c=t.filter.getSelectedIndexes(),h=Object.keys(e.mutationCliffsSelection);if(!h.length||null===e.mutationCliffs)return null;const d=[],f=[],m=[],p=[],g=[],v=[],C=t.getCol(e.sequenceColumnName),y=C.categories,b=C.getRawData(),_=e.activityCol.getRawData(),w=new Map,A=o.BitSet.create(t.rowCount),S={},T=Object.fromEntries(e.positionColumns.map(t=>[t.name,t]));for(const t of h){const i=T[t],o=i.categories,r=i.getRawData();for(const i of e.mutationCliffsSelection[t]){const s=null===(n=e.mutationCliffs.get(i))||void 0===n?void 0:n.get(t);if(void 0!==s)for(const[t,n]of s.entries()){if(!c.includes(t))continue;S[t]||(S[t]=Object.keys(S).length+1);const i=S[t],s=null!==(u=w.get(t))&&void 0!==u?u:[],a=y[b[t]],l=_[t],h=e.activityCol.isNone(t)?null:l;for(const l of n){if(s.includes(l)||!c.includes(l))continue;w.has(l)||w.set(l,[]);const n=y[b[l]],u=e.activityCol.isNone(l)?null:_[l],C=null==h||null==u?null:h-u;w.get(l).push(t),d.push(`${a}#${n}`),p.push(`${i}`),f.push(C),m.push(o[r[l]]),g.push(t),v.push(l),A.set(t,!0),A.set(l,!0)}}}}if(0===d.length)return null;const E=o.Column.fromStrings("Mutation",d),N=o.Column.fromList("double","Delta",f),x=o.Column.fromStrings("Group",p),M=o.Column.fromStrings("~to",m),I=o.Column.fromList(o.COLUMN_TYPE.INT,"~toIdx",v),O=o.Column.fromList(o.COLUMN_TYPE.INT,"~fromIdx",g),P=o.DataFrame.fromColumns([E,N,x,M,I,O]);P.name="Mutation Cliff pairs";const L=i.input.string("Mutated to:",{value:"",onValueChanged:t=>{const e=t;""!==e?P.filter.init(t=>M.get(t)===e):P.filter.setAll(!0)}});L.setTooltip("Filter the rows by the monomer that the mutation was substituted to");const R=P.plot.grid();(0,s.vY)(R,!0),E.semType=r.uF.MACROMOLECULE_DIFFERENCE,E.tags[r.gp.SEPARATOR]=(0,s.AY)(C),E.tags[o.TAGS.UNITS]=C.tags[o.TAGS.UNITS],E.tags[o.TAGS.CELL_RENDERER]="MacromoleculeDifference",E.temp[l.j.notationProvider]=C.temp[l.j.notationProvider];let k=!1,F=null;const V=[];R.onCurrentCellChanged.subscribe(t=>{try{if(!t||!t.dart)return V.length=0,void Y();const e=t.tableRowIndex;if(!k)return;if(null===e)return V.length=0,void Y();null!==F&&V.splice(V.indexOf(F),1),V.includes(e)||(V.push(e),R.invalidate()),Y()}finally{k=!1,F=t&&t.dart?t.tableRowIndex:null}}),R.root.addEventListener("keydown",t=>{k=t.key.startsWith("Arrow")}),R.root.addEventListener("click",t=>{const e=R.hitTest(t.offsetX,t.offsetY);if(!e||null===e.tableRowIndex)return;const n=e.tableRowIndex;if(t.shiftKey){const t=V.indexOf(n);-1===t?V.push(n):V.splice(t,1)}else V.length=0,V.push(n);Y(),R.invalidate(),$.invalidate()}),R.onCellPrepare(t=>{var e,n,i,r;if((null==t?void 0:t.isTableCell)&&"delta"==(null===(n=null===(e=null==t?void 0:t.gridColumn)||void 0===e?void 0:e.name)||void 0===n?void 0:n.toLowerCase())&&(null==(null===(i=null==t?void 0:t.cell)||void 0===i?void 0:i.value)||(null===(r=null==t?void 0:t.cell)||void 0===r?void 0:r.value)==o.FLOAT_NULL))try{t.customText="N/A"}catch(t){}}),R.onCellRender.subscribe(t=>{var e;(null===(e=t.cell.tableColumn)||void 0===e?void 0:e.name)===E.name&&V.includes(t.cell.tableRowIndex)&&(0,a.X5)(t.g,t.bounds)});const D=e.gridColumns.length,G=[];for(let t=1;t<D;t++){const n=e.gridColumns.byIndex(t);((null==n?void 0:n.name)===e.sequenceColumnName||!0===(null==n?void 0:n.visible)&&!Object.hasOwn(T,n.name))&&G.push(n.name)}const B=t.clone(A,G);B.name="Unique sequences that form Mutation Cliffs pairs";const U=B.columns.addNewInt("~seqIdx"),q=U.getRawData();B.col(e.sequenceColumnName)&&(B.col(e.sequenceColumnName).temp[l.j.notationProvider]=C.temp[l.j.notationProvider]);const H=A.getSelectedIndexes();U.init(t=>H[t]);const $=B.plot.grid();function Y(){const t=[];for(const e of V)t.push(O.get(e)),t.push(I.get(e));B.filter.init(e=>0===V.length||t.includes(q[e]),!0),R.invalidate(),$.invalidate()}return(0,s.vY)($,!0),$.props.rowHeight=20,R.root.style.width="100% !important",$.root.style.width="100% !important",setTimeout(()=>{R.autoSize(window.innerWidth,250,void 0,void 0,!1),$.autoSize(window.innerWidth,250,void 0,void 0,!1),R.root.style.removeProperty("width"),R.root.style.setProperty("width","100%"),$.root.style.removeProperty("width"),$.root.style.setProperty("width","100%"),R.root.style.minHeight="70px",$.root.style.minHeight="100px",R.root.style.height="unset",$.root.style.height="unset"},200),{pairsGrid:R,uniqueSequencesGrid:$,aminoToInput:L}}},440(t,e,n){"use strict";n.d(e,{v:()=>g,n:()=>v});var i=n(4328),o=n(7389),r=n(6082),s=n(4139),a=n(115),l=n(3743),u=n(7233),c=n.n(u),h=n(8608),d=n(1199),f=n(5429);class m{constructor(t){this._inputBase=t}get root(){return this._inputBase.root}get value(){return this._inputBase.value}set value(t){this._inputBase.value=t}get inputBase(){return this._inputBase}}n(4788);var p=function(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}l((i=i.apply(t,e||[])).next())})};function g(t,e){return p(this,void 0,void 0,function*(){const n=new a.av,l=o.div();let u=null;if(void 0===e){const e=r.Utils.firstOrNull(t.columns.toList().filter(t=>t.semType===r.SEMTYPE.MACROMOLECULE));if(null===e)throw new Error("Peptides Error: table doesn't contain sequence columns");0!==e.stats.missingValueCount&&i.shell.info("Sequences column contains missing values. They will be ignored during analysis"),u=yield async function(t,e){const n=r.Func.find({package:"Bio",name:"sequenceColumnInput"})[0];return n?await n.apply({name:t,options:e}):new m(o.input.column(t,e))}("Sequence",{table:t,value:e,onValueChanged:e=>{c()(l).empty().append(o.wait(()=>p(this,void 0,void 0,function*(){const n=yield t.plot.fromType("WebLogo",{sequenceColumnName:e.name});return n.root.style.setProperty("height","130px"),n.root}))),0!==e.stats.missingValueCount&&i.shell.info("Sequences column contains missing values. They will be ignored during analysis")},filter:t=>t.semType===r.SEMTYPE.MACROMOLECULE,nullable:!1}),u.inputBase.setTooltip("Macromolecule column in FASTA, HELM or separated format")}let g,C=r.Func.find({package:"Bio",name:"webLogoViewer"});if(0===C.length)return{host:o.label("Bio package is missing or out of date. Please install the latest version."),callback:()=>p(this,void 0,void 0,function*(){return!1})};if(C=r.Func.find({package:"Bio",name:"getBioLib"}),0===C.length)return{host:o.label("Bio package is missing or out of date. Please install the latest version."),callback:()=>p(this,void 0,void 0,function*(){return!1})};const y=t.col("activity")||t.col("IC50")||r.Utils.firstOrNull(t.columns.numerical),b=o.div([],{id:"pep-hist-host"}),_=o.input.choice("Scaling",{value:s.rg.NONE,items:Object.values(s.rg),onValueChanged:t=>p(this,void 0,void 0,function*(){var e;g=(0,h.Y1)(A.value,t);const n=r.DataFrame.fromColumns([g]).plot.histogram({filteringEnabled:!1,valueColumnName:s.$2.ACTIVITY,legendVisibility:"Never",showXAxis:!0,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1});null===(e=b.lastChild)||void 0===e||e.remove(),b.appendChild(n.root)})});_.setTooltip("Activity column transformation method");const w=()=>{var t;_.enabled=null!==(t=A.value)&&void 0!==t&&t&&A.value.stats.min>0,_.value=s.rg.NONE,0!==A.value.stats.missingValueCount&&i.shell.info("Activity column contains missing values. They will be ignored during analysis")},A=o.input.column("Activity",{table:t,value:y,nullable:!1,onValueChanged:w,filter:t=>t.type===r.TYPE.INT||t.type===r.TYPE.FLOAT||t.type===r.TYPE.QNUM});A.setTooltip("Numerical activity column");const S=o.input.column("Clusters",{table:t,onValueChanged:t=>{t&&(T.value=!1,T.fireChanged())}});S.setTooltip("Optional. Clusters column is used to create Logo Summary Table"),S.nullable=!0;const T=o.input.bool("Generate clusters",{value:!0,onValueChanged:t=>{t&&(S.value=null,S.fireChanged())}});T.setTooltip("Generate clusters column based on MCL embeddings for Logo Summary Table"),A.fireChanged(),_.fireChanged(),T.fireChanged();const E=[A,_,S,T];null!==u&&E.splice(0,0,u.inputBase);const N=o.input.float(f.t_.THRESHOLD,{value:n.threshold,nullable:!1,onValueChanged:t=>n.threshold=null!=t?t:n.threshold});N.setTooltip("Threshold for similarity between two sequences to create edges");const x=o.input.float(f.t_.INFLATION,{value:n.inflation,nullable:!1,onValueChanged:t=>n.inflation=null!=t?t:n.inflation});x.setTooltip("Inflation value for MCL algorithm");const M=o.input.int(f.t_.MAX_ITERATIONS,{value:n.maxIterations,nullable:!1,onValueChanged:t=>n.maxIterations=null!=t?t:n.maxIterations});M.setTooltip("Maximum iterations for MCL algorithm");const I=o.input.bool(f.t_.USE_WEBGPU,{value:n.useWebGPU,onValueChanged:t=>n.useWebGPU=t});I.enabled=!1,n.webGPUDescriptionPromise.then(()=>{n.webGPUDescription!==a.Ku?(I.setTooltip(`Use WebGPU for MCL algorithm (${n.webGPUDescription})`),I.enabled=!0):(I.setTooltip(a.Ku),I.enabled=!1,I.value=!1)});const O=o.input.int(f.t_.MIN_CLUSTER_SIZE,{value:n.minClusterSize,nullable:!1,onValueChanged:t=>n.minClusterSize=null!=t?t:n.minClusterSize});O.setTooltip("Minimum cluster size for MCL algorithm");const P=o.input.choice(f.t_.DISTANCE_FUNCTION,{value:n.distanceF,items:[d.Z.NEEDLEMANN_WUNSCH,d.Z.MONOMER_CHEMICAL_DISTANCE,d.Z.HAMMING,d.Z.LEVENSHTEIN],nullable:!1,onValueChanged:t=>n.distanceF=t}),L=o.input.float(f.t_.GAP_OPEN,{value:n.gapOpen,onValueChanged:t=>n.gapOpen=null!=t?t:n.gapOpen}),R=o.input.float(f.t_.GAP_EXTEND,{value:n.gapExtend,onValueChanged:t=>n.gapExtend=null!=t?t:n.gapExtend}),k=[N,x,M,O,P,o.input.choice(f.t_.FINGERPRINT_TYPE,{value:n.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],nullable:!1,onValueChanged:t=>n.fingerprintType=t}),L,R,I],F=o.form(k);F.style.display="none";const V=o.icons.settings(()=>{F.style.display="none"===F.style.display?"flex":"none",F.classList.remove("ui-form-condensed")},"Adjust clustering parameters");V.style.fontSize="16px",T.root.appendChild(V);const D=t.filter.onChanged.subscribe(()=>w()),G=()=>p(this,void 0,void 0,function*(){var i,o;const r=null!=e?e:u.value;return D.unsubscribe(),!!r&&null!==(yield v(A.value,r,S.value,t,g,null!==(i=_.value)&&void 0!==i?i:s.rg.NONE,{addSequenceSpace:!1,addMCL:T.value,useEmbeddingsClusters:null!==(o=T.value)&&void 0!==o&&o,mclSettings:n}))});let B="auto";const U=[o.divV(E)];if(c()(U[0]).find("label").css("width","unset"),void 0!==e){const t=o.button("Launch SAR",G,"");t.style.alignSelf="center",U.push(t),B="215px"}return c()(l).empty().append(o.wait(()=>p(this,void 0,void 0,function*(){var n;const i=yield t.plot.fromType("WebLogo",{sequenceColumnName:null!==(n=null==e?void 0:e.name)&&void 0!==n?n:u.value.name});return i.root.style.setProperty("height","130px"),i.root}))),{host:o.divV([l,o.splitH([o.splitV(U,{style:{flex:"0 1 auto"}}),b],{style:{height:B,minWidth:"600px",maxWidth:"750px"}}),F]),callback:G}})}function v(t,e,n,o,u,c){return p(this,arguments,void 0,function*(t,e,n,o,u,c,h={}){var d,f,m,p,g;let v=null;if(t.type!==r.COLUMN_TYPE.FLOAT&&t.type!==r.COLUMN_TYPE.INT&&t.type!==r.COLUMN_TYPE.QNUM)return i.shell.error("The activity column must be of numeric type!"),v;const C=r.TaskBarProgressIndicator.create("Loading SAR...");o.tags.delete&&o.tags.delete(".script");const y=o.columns,b=o.col(u.name);b&&(b.name=y.getUnusedName(b.name));const _=u.getRawData();o.columns.addNew(u.name,u.type).init(t=>_[t]),y.setOrder([u.name,e.name,...y.names().filter(t=>t!==e.name&&t!==u.name)]);const w={sequenceColumnName:e.name,activityColumnName:t.name,activityScaling:c,columns:{},showDendrogram:!1,showSequenceSpace:!1,sequenceSpaceParams:new a.GI(!!h.useEmbeddingsClusters&&!n),mclSettings:null!==(d=h.mclSettings)&&void 0!==d?d:new a.av};if(n){const t=o.getCol(n.name);t.type!==r.COLUMN_TYPE.STRING&&y.replace(t,t.convertTo(r.COLUMN_TYPE.STRING))}if(o.setTag(s.gp.SETTINGS,JSON.stringify(w)),v=l.i.getInstance(o),v.init(w),n){const i={clustersColumnName:n.name,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i)}if(yield v.addMonomerPosition(),yield v.addMostPotentResidues(),null!==(f=h.addSequenceSpace)&&void 0!==f&&f){if(yield v.addSequenceSpace({clusterCol:n,clusterEmbeddings:h.useEmbeddingsClusters}),!n&&null!==(m=h.useEmbeddingsClusters)&&void 0!==m&&m){const n=v._sequenceSpaceCols.find(t=>{var e;return v.df.col(t)&&(null===(e=v.df.col(t))||void 0===e?void 0:e.type)===r.COLUMN_TYPE.STRING});if(n){const i={clustersColumnName:n,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i),setTimeout(()=>{var t,e;v&&(null===(t=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===t?void 0:t.render)&&(null===(e=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===e||e.render())},100)}}}else if(null!==(p=h.addMCL)&&void 0!==p&&p&&(yield v.addMCLClusters(),!n&&null!==(g=h.useEmbeddingsClusters)&&void 0!==g&&g)){const n=v._mclCols.find(t=>(null==v?void 0:v.df.col(t))&&t.toLowerCase().startsWith("cluster")&&!t.toLowerCase().includes("size"));if(n){const i={clustersColumnName:n,sequenceColumnName:e.name,activityScaling:c,activityColumnName:t.name};yield v.addLogoSummaryTable(i),setTimeout(()=>{var t,e;v&&(null===(t=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===t?void 0:t.render)&&(null===(e=null==v?void 0:v.findViewer(l.q.LOGO_SUMMARY_TABLE))||void 0===e||e.render())},100)}}const A=v.df.plot.grid({rowSource:r.RowSet.Selected,selectedRowsColor:r.Color.fromHtml("#ffffff"),title:"Selection"}),S=null==v?void 0:v.findViewerNode(l.q.LOGO_SUMMARY_TABLE);return S&&v.analysisView.dockManager.dock(A,r.DOCK_TYPE.DOWN,S,"Selection",.4),C.close(),v})}},5429(t,e,n){"use strict";n.d(e,{OH:()=>_,t_:()=>l});var i,o,r,s,a,l,u=n(7389),c=n(4328),h=n(6082),d=n(115),f=n(4139),m=n(3743),p=n(7233),g=n.n(p),v=n(144),C=n.n(v),y=n(3262),b=n(1199);function _(t){var e,n,r,p,v,_,w,A,S,T;null==t.settings&&c.log.error("PeptidesError: Settings are not initialized");const E=u.accordion(),N=t.settings,x=null!==(e=null==N?void 0:N.activityScaling)&&void 0!==e?e:f.rg.NONE,M=null!==(n=null==N?void 0:N.columns)&&void 0!==n?n:{},I={},O={},P=null!==(r=null==N?void 0:N.sequenceSpaceParams)&&void 0!==r?r:new d.GI,L=null!==(p=null==N?void 0:N.mclSettings)&&void 0!==p?p:new d.av,R=u.input.column(o.ACTIVITY,{table:t.df,value:t.df.getCol(t.settings.activityColumnName),onValueChanged:t=>{I.activityColumnName=t.name},filter:t=>(t.type===h.TYPE.FLOAT||t.type===h.TYPE.INT)&&t.name!==f.$2.ACTIVITY&&0===t.stats.missingValueCount});R.setTooltip("Numeric activity column");const k=u.input.choice(o.ACTIVITY_SCALING,{value:x,items:Object.values(f.rg),onValueChanged:t=>I.activityScaling=t});k.setTooltip("Activity column transformation method"),E.addPane(i.GENERAL,()=>u.inputs([R,k]),!0),O[i.GENERAL]=[R,k];const F=C()(t.analysisView.viewers).some(t=>t.type===m.q.DENDROGRAM),V=u.input.bool(m.q.DENDROGRAM,{value:null!=F&&F,onValueChanged:t=>I.showDendrogram=t}),D=u.input.bool(m.q.CLUSTER_MAX_ACTIVITY,{value:!!(null==N?void 0:N.showClusterMaxActivity),onValueChanged:t=>{I.showClusterMaxActivity=null!=t?t:void 0}}),G=u.input.bool("Sequence space",{value:!!(null==N?void 0:N.showSequenceSpace),onValueChanged:t=>{I.showSequenceSpace=null!=t?t:void 0,t?(ft.root.style.display="flex",(null==N?void 0:N.showSequenceSpace)||(I.sequenceSpaceParams=P)):(ft.root.style.display="none",delete I.sequenceSpaceParams),I.showSequenceSpace===(null==N?void 0:N.showSequenceSpace)&&delete I.showSequenceSpace}});D.setTooltip("Show cluster max activity viewer"),V.setTooltip("Show dendrogram viewer"),V.enabled=null!==(0,y.getTreeHelperInstance)(),E.addPane(i.VIEWERS,()=>u.inputs([V,G,D]),!0),O[i.VIEWERS]=[V,G,D];const B=[],U=[];for(const e of t.df.columns.numerical){const t=e.name;if(t===N.activityColumnName||t===f.$2.ACTIVITY)continue;const n=u.input.bool(s.IS_INCLUDED,{value:void 0!==M[t],onValueChanged:e=>{var n;null!==(n=I.columns)&&void 0!==n||(I.columns={}),e?I.columns[t]=i.value:(delete I.columns[t],Object.keys(I.columns).length===Object.keys(M).length&&delete I.columns)}});n.setTooltip("Include aggregated column value in tooltips, Logo Summary Table and Distribution panel");const i=u.input.choice(s.AGGREGATION,{value:null!==(v=M[t])&&void 0!==v?v:h.AGG.AVG,items:Object.values(h.STATS),onValueChanged:i=>{var o;null!==(o=I.columns)&&void 0!==o||(I.columns={}),n.value?I.columns[t]=i:(delete I.columns[e.name],Object.keys(I.columns).length===Object.keys(M).length&&delete I.columns)}});i.setTooltip("Aggregation method"),g()(i.root).find("label").css("width","auto");const o=u.inputsRow(e.name,[n,i]);U.push(n,i),g()(o).find("div.ui-div").css("display","inline-flex"),B.push(o)}0!==B.length&&(E.addPane(i.COLUMNS,()=>u.divV(B),!1),O[i.COLUMNS]=U);const q={};function H(t,e){if(Q(),null==e||""===e)return;q[t]=e;let n=!0;for(const[t,e]of Object.entries(q))if(e!==P[t]){n=!1;break}n?delete I.sequenceSpaceParams:I.sequenceSpaceParams=Object.assign(Object.assign({},P),q)}function $(t,e){t.forEach(t=>{t.root.style.display=e?"flex":"none"})}const Y=u.input.choice(a.DISTANCE_FUNCTION,{value:P.distanceF,items:[b.Z.NEEDLEMANN_WUNSCH,b.Z.HAMMING,b.Z.LEVENSHTEIN,b.Z.MONOMER_CHEMICAL_DISTANCE],onValueChanged:t=>H("distanceF",t)});Y.setTooltip("Distance function for sequences");const j=u.input.float(a.GAP_OPEN,{value:P.gapOpen,onValueChanged:t=>H("gapOpen",t)}),W=u.input.float(a.GAP_EXTEND,{value:P.gapExtend,onValueChanged:t=>H("gapExtend",t)}),z=u.input.bool(a.CLUSTER_EMBEDDINGS,{value:null!==(_=P.clusterEmbeddings)&&void 0!==_&&_,onValueChanged:t=>H("clusterEmbeddings",t)});z.setTooltip("Cluster embeddings using DBSCAN algorithm");const K=u.input.float(a.EPSILON,{value:P.epsilon,onValueChanged:t=>H("epsilon",t)});K.setTooltip("Epsilon parameter for DBSCAN. Minimum distance between two points to be considered as a cluster");const Z=u.input.int(a.MIN_PTS,{value:P.minPts,onValueChanged:t=>H("minPts",t)});Z.setTooltip("Minimum number of points in a cluster");const X=u.input.choice(a.FINGERPRINT_TYPE,{value:P.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],onValueChanged:t=>H("fingerprintType",t)});function Q(){$([j,W],Y.value===b.Z.NEEDLEMANN_WUNSCH),$([K,Z],!0===z.value),$([X],Y.value===b.Z.MONOMER_CHEMICAL_DISTANCE||Y.value===b.Z.NEEDLEMANN_WUNSCH)}Q();const J={};function tt(t,e){if(et(),null==e||""===e)return;J[t]=e;let n=!0;for(const[t,e]of Object.entries(J))if(e!==L[t]){n=!1;break}n?delete I.mclSettings:I.mclSettings=Object.assign(Object.assign({},L),J)}function et(){$([it,ot],nt.value===b.Z.NEEDLEMANN_WUNSCH),$([rt],nt.value===b.Z.MONOMER_CHEMICAL_DISTANCE||nt.value===b.Z.NEEDLEMANN_WUNSCH)}const nt=u.input.choice(l.DISTANCE_FUNCTION,{value:L.distanceF,items:[b.Z.NEEDLEMANN_WUNSCH,b.Z.MONOMER_CHEMICAL_DISTANCE,b.Z.HAMMING,b.Z.LEVENSHTEIN],onValueChanged:t=>tt("distanceF",t)}),it=u.input.float(l.GAP_OPEN,{value:L.gapOpen,onValueChanged:t=>tt("gapOpen",t)}),ot=u.input.float(l.GAP_EXTEND,{value:L.gapExtend,onValueChanged:t=>tt("gapExtend",t)}),rt=u.input.choice(l.FINGERPRINT_TYPE,{value:L.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],onValueChanged:t=>tt("fingerprintType",t)}),st=u.input.int(l.THRESHOLD,{value:null!==(w=L.threshold)&&void 0!==w?w:80,onValueChanged:t=>tt("threshold",t)}),at=u.input.int(l.MAX_ITERATIONS,{value:null!==(A=L.maxIterations)&&void 0!==A?A:5,onValueChanged:t=>tt("maxIterations",t)}),lt=u.input.float(l.INFLATION,{value:null!==(S=L.inflation)&&void 0!==S?S:1.4,onValueChanged:t=>{tt("inflation",t)}}),ut=u.input.bool(l.USE_WEBGPU,{value:L.useWebGPU,onValueChanged:t=>tt("useWebGPU",t)});ut.enabled=!1,L.webGPUDescriptionPromise.then(()=>{L.webGPUDescription!==d.Ku?(ut.setTooltip(`Use WebGPU for MCL algorithm (${L.webGPUDescription})`),ut.enabled=!0):(ut.setTooltip(d.Ku),ut.enabled=!1,ut.value=!1)});const ct=u.input.int(l.MIN_CLUSTER_SIZE,{value:null!==(T=L.minClusterSize)&&void 0!==T?T:5,onValueChanged:t=>tt("minClusterSize",t)});et();const ht=[st,nt,rt,it,ot,lt,at,ct,ut];E.addPane(i.MCL,()=>u.inputs(ht),!0),O[i.MCL]=ht;const dt=[Y,X,j,W,z,K,Z],ft=E.addPane(i.SEQUENCE_SPACE,()=>u.inputs(dt),!0);O[i.SEQUENCE_SPACE]=dt,G.fireChanged();const mt=u.dialog("Peptides settings").add(E);return mt.root.style.width="400px",mt.onOK(()=>{t.settings=I}),mt.show(),{dialog:mt,accordion:E,inputs:O}}!function(t){t.GENERAL="General",t.VIEWERS="Viewers",t.COLUMNS="Columns",t.SEQUENCE_SPACE="Sequence space",t.MCL="MCL"}(i||(i={})),function(t){t.ACTIVITY="Activity",t.ACTIVITY_SCALING="Activity scaling"}(o||(o={})),function(t){t.DENDROGRAM="Dendrogram"}(r||(r={})),function(t){t.IS_INCLUDED="",t.AGGREGATION="Aggregation"}(s||(s={})),function(t){t.DISTANCE_FUNCTION="Distance Function",t.GAP_OPEN="Gap Open Penalty",t.GAP_EXTEND="Gap Extend Penalty",t.CLUSTER_EMBEDDINGS="Cluster Embeddings",t.EPSILON="Epsilon",t.MIN_PTS="Minimum Points",t.FINGERPRINT_TYPE="Fingerprint Type"}(a||(a={})),function(t){t.DISTANCE_FUNCTION="Distance Function",t.GAP_OPEN="Gap Open Penalty",t.GAP_EXTEND="Gap Extend Penalty",t.FINGERPRINT_TYPE="Fingerprint Type",t.THRESHOLD="Similarity Threshold",t.INFLATION="Inflation Factor",t.MAX_ITERATIONS="Max Iterations",t.USE_WEBGPU="Use WebGPU",t.MIN_CLUSTER_SIZE="Min Cluster Size"}(l||(l={})),i.GENERAL,i.VIEWERS,i.COLUMNS,i.SEQUENCE_SPACE,i.MCL},144(t){var e;e=function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={exports:{},id:i,loaded:!1};return t[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}return n.m=t,n.c=e,n.p="",n(0)}([function(t,e,n){"use strict";var i=n(1).default,o=n(39).default,r=n(52).default,s=n(40).default,a=n(54).default,l=n(80).default,u=n(84).default,c=n(65).default,h=t.exports=function(t){if(!m(t))throw new Error("wu: `"+t+"` is not iterable!");return new d(t)};function d(t){var e=p(t);this.next=e.next.bind(e)}h.prototype=d.prototype,h.prototype[r]=function(){return this};var f={},m=function(t){return t&&"function"==typeof t[r]},p=function(t){if(m(t))return s(t);throw new TypeError("Not iterable: "+t)},g=function(t,e){e.prototype=d.prototype,h[t]=e},v=function(t,e){var n=arguments.length<=2||void 0===arguments[2]?e.length:arguments[2];return e.prototype=d.prototype,d.prototype[t]=e,n+=1,void(h[t]=h.curryable(function(){for(var e,n=arguments.length,i=Array(n),o=0;o<n;o++)i[o]=arguments[o];var r=i.pop();return(e=h(r))[t].apply(e,i)},n))},C=function(t){return function(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return h(t.call.apply(t,[this].concat(n)))}},y=function(t,e){return g(t,C(e))},b=function(t,e,n){return v(t,C(e),n)};g("curryable",function(t){var e=arguments.length<=1||void 0===arguments[1]?t.length:arguments[1];return function n(){for(var o=arguments.length,r=Array(o),s=0;s<o;s++)r[s]=arguments[s];return r.length>=e?t.apply(this,r):function(t,e){return function(){for(var n=arguments.length,o=Array(n),r=0;r<n;r++)o[r]=arguments[r];return t.call.apply(t,[this].concat(i(e),o))}}(n,r)}}),y("entries",a.mark(function t(e){var n,i,o,r,u,c;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(l(e));case 5:if(n=(u=r.next()).done){t.next=12;break}return c=u.value,t.next=9,[c,e[c]];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}},t,this,[[3,14,18,26],[19,,21,25]])})),y("keys",a.mark(function t(e){return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(l(e),"t0",1);case 1:case"end":return t.stop()}},t,this)})),y("values",a.mark(function t(e){var n,i,o,r,u,c;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(l(e));case 5:if(n=(u=r.next()).done){t.next=12;break}return c=u.value,t.next=9,e[c];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}},t,this,[[3,14,18,26],[19,,21,25]])})),b("cycle",a.mark(function t(){var e,n,i,o,r,l,u;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=[],n=!0,i=!1,o=void 0,t.prev=4,r=s(this);case 6:if(n=(l=r.next()).done){t.next=14;break}return u=l.value,t.next=10,u;case 10:e.push(u);case 11:n=!0,t.next=6;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(4),i=!0,o=t.t0;case 20:t.prev=20,t.prev=21,!n&&r.return&&r.return();case 23:if(t.prev=23,!i){t.next=26;break}throw o;case 26:return t.finish(23);case 27:return t.finish(20);case 28:if(!e){t.next=32;break}return t.delegateYield(e,"t1",30);case 30:t.next=28;break;case 32:case"end":return t.stop()}},t,this,[[4,16,20,28],[21,,23,27]])})),y("count",a.mark(function t(){var e,n=arguments.length<=0||void 0===arguments[0]?0:arguments[0],i=arguments.length<=1||void 0===arguments[1]?1:arguments[1];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=n;case 1:return t.next=4,e;case 4:e+=i,t.next=1;break;case 7:case"end":return t.stop()}},t,this)})),y("repeat",a.mark(function t(e){var n,i=arguments.length<=1||void 0===arguments[1]?1/0:arguments[1];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(i!==1/0){t.next=8;break}case 1:return t.next=4,e;case 4:t.next=1;break;case 6:t.next=15;break;case 8:n=0;case 9:if(!(n<i)){t.next=15;break}return t.next=12,e;case 12:n++,t.next=9;break;case 15:case"end":return t.stop()}},t,this)})),y("chain",a.mark(function t(){var e,n,i,o,r,l,u,c,h,d=arguments;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(e=!0,n=!1,i=void 0,t.prev=3,o=d.length,r=Array(o),l=0;l<o;l++)r[l]=d[l];u=s(r);case 6:if(e=(c=u.next()).done){t.next=12;break}return h=c.value,t.delegateYield(h,"t0",9);case 9:e=!0,t.next=6;break;case 12:t.next=18;break;case 14:t.prev=14,t.t1=t.catch(3),n=!0,i=t.t1;case 18:t.prev=18,t.prev=19,!e&&u.return&&u.return();case 21:if(t.prev=21,!n){t.next=24;break}throw i;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}},t,this,[[3,14,18,26],[19,,21,25]])})),b("chunk",a.mark(function t(){var e,n,i,o,r,l,u,c,h=arguments.length<=0||void 0===arguments[0]?2:arguments[0];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=[],n=0,i=!0,o=!1,r=void 0,t.prev=5,l=s(this);case 7:if(i=(u=l.next()).done){t.next=18;break}if(c=u.value,e[n++]=c,n!==h){t.next=15;break}return t.next=13,e;case 13:e=[],n=0;case 15:i=!0,t.next=7;break;case 18:t.next=24;break;case 20:t.prev=20,t.t0=t.catch(5),o=!0,r=t.t0;case 24:t.prev=24,t.prev=25,!i&&l.return&&l.return();case 27:if(t.prev=27,!o){t.next=30;break}throw r;case 30:return t.finish(27);case 31:return t.finish(24);case 32:if(!n){t.next=35;break}return t.next=35,e;case 35:case"end":return t.stop()}},t,this,[[5,20,24,32],[25,,27,31]])}),1),b("concatMap",a.mark(function t(e){var n,i,o,r,l,u;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=11;break}return u=l.value,t.delegateYield(e(u),"t0",8);case 8:n=!0,t.next=5;break;case 11:t.next=17;break;case 13:t.prev=13,t.t1=t.catch(3),i=!0,o=t.t1;case 17:t.prev=17,t.prev=18,!n&&r.return&&r.return();case 20:if(t.prev=20,!i){t.next=23;break}throw o;case 23:return t.finish(20);case 24:return t.finish(17);case 25:case"end":return t.stop()}},t,this,[[3,13,17,25],[18,,20,24]])})),b("drop",a.mark(function t(e){var n,i,o,r,l,u,c;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=0,i=!0,o=!1,r=void 0,t.prev=4,l=s(this);case 6:if(i=(u=l.next()).done){t.next=16;break}if(c=u.value,!(n++<e)){t.next=10;break}return t.abrupt("continue",13);case 10:return t.next=12,c;case 12:return t.abrupt("break",16);case 13:i=!0,t.next=6;break;case 16:t.next=22;break;case 18:t.prev=18,t.t0=t.catch(4),o=!0,r=t.t0;case 22:t.prev=22,t.prev=23,!i&&l.return&&l.return();case 25:if(t.prev=25,!o){t.next=28;break}throw r;case 28:return t.finish(25);case 29:return t.finish(22);case 30:return t.delegateYield(this,"t1",31);case 31:case"end":return t.stop()}},t,this,[[4,18,22,30],[23,,25,29]])})),b("dropWhile",a.mark(function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=15;break}if(l=r.value,!u(l)){t.next=9;break}return t.abrupt("continue",12);case 9:return t.next=11,l;case 11:return t.abrupt("break",15);case 12:e=!0,t.next=5;break;case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(3),n=!0,i=t.t0;case 21:t.prev=21,t.prev=22,!e&&o.return&&o.return();case 24:if(t.prev=24,!n){t.next=27;break}throw i;case 27:return t.finish(24);case 28:return t.finish(21);case 29:return t.delegateYield(this,"t1",30);case 30:case"end":return t.stop()}},t,this,[[3,17,21,29],[22,,24,28]])}),1),b("enumerate",a.mark(function t(){return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(_([this,h.count()]),"t0",1);case 1:case"end":return t.stop()}},t,this)})),b("filter",a.mark(function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}if(l=r.value,!u(l)){t.next=10;break}return t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}},t,this,[[3,15,19,27],[20,,22,26]])}),1),b("flatten",a.mark(function t(){var e,n,i,o,r,l,u=!(arguments.length<=0||void 0===arguments[0])&&arguments[0];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=16;break}if("string"==typeof(l=r.value)||!m(l)){t.next=11;break}return t.delegateYield(u?l:h(l).flatten(),"t0",9);case 9:t.next=13;break;case 11:return t.next=13,l;case 13:e=!0,t.next=5;break;case 16:t.next=22;break;case 18:t.prev=18,t.t1=t.catch(3),n=!0,i=t.t1;case 22:t.prev=22,t.prev=23,!e&&o.return&&o.return();case 25:if(t.prev=25,!n){t.next=28;break}throw i;case 28:return t.finish(25);case 29:return t.finish(22);case 30:case"end":return t.stop()}},t,this,[[3,18,22,30],[23,,25,29]])}),1),b("invoke",a.mark(function t(e){var n,i,o,r,l,u,c,h,d,f=arguments;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:for(n=!0,i=!1,o=void 0,t.prev=3,r=f.length,l=Array(r>1?r-1:0),u=1;u<r;u++)l[u-1]=f[u];c=s(this);case 6:if(n=(h=c.next()).done){t.next=13;break}return d=h.value,t.next=10,d[e].apply(d,l);case 10:n=!0,t.next=6;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),i=!0,o=t.t0;case 19:t.prev=19,t.prev=20,!n&&c.return&&c.return();case 22:if(t.prev=22,!i){t.next=25;break}throw o;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}},t,this,[[3,15,19,27],[20,,22,26]])})),b("map",a.mark(function t(e){var n,i,o,r,l,u;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=12;break}return u=l.value,t.next=9,e(u);case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}},t,this,[[3,14,18,26],[19,,21,25]])})),b("pluck",a.mark(function t(e){var n,i,o,r,l,u;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,i=!1,o=void 0,t.prev=3,r=s(this);case 5:if(n=(l=r.next()).done){t.next=12;break}return u=l.value,t.next=9,u[e];case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),i=!0,o=t.t0;case 18:t.prev=18,t.prev=19,!n&&r.return&&r.return();case 21:if(t.prev=21,!i){t.next=24;break}throw o;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}},t,this,[[3,14,18,26],[19,,21,25]])})),b("reductions",a.mark(function t(e){var n,i,o,r,l,u,c,h,d,f,m,p,g=arguments.length<=1||void 0===arguments[1]?void 0:arguments[1];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==(n=g)){t.next=28;break}i=!0,o=!1,r=void 0,t.prev=5,l=s(this);case 7:if(i=(u=l.next()).done){t.next=14;break}return c=u.value,n=c,t.abrupt("break",14);case 11:i=!0,t.next=7;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(5),o=!0,r=t.t0;case 20:t.prev=20,t.prev=21,!i&&l.return&&l.return();case 23:if(t.prev=23,!o){t.next=26;break}throw r;case 26:return t.finish(23);case 27:return t.finish(20);case 28:return t.next=30,n;case 30:h=!0,d=!1,f=void 0,t.prev=33,m=s(this);case 35:if(h=(p=m.next()).done){t.next=42;break}return c=p.value,t.next=39,n=e(n,c);case 39:h=!0,t.next=35;break;case 42:t.next=48;break;case 44:t.prev=44,t.t1=t.catch(33),d=!0,f=t.t1;case 48:t.prev=48,t.prev=49,!h&&m.return&&m.return();case 51:if(t.prev=51,!d){t.next=54;break}throw f;case 54:return t.finish(51);case 55:return t.finish(48);case 56:return t.abrupt("return",n);case 57:case"end":return t.stop()}},t,this,[[5,16,20,28],[21,,23,27],[33,44,48,56],[49,,51,55]])}),2),b("reject",a.mark(function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}if(l=r.value,u(l)){t.next=10;break}return t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}},t,this,[[3,15,19,27],[20,,22,26]])}),1),b("slice",a.mark(function t(){var e,n,i,r,l,u,c,h,d=arguments.length<=0||void 0===arguments[0]?0:arguments[0],f=arguments.length<=1||void 0===arguments[1]?1/0:arguments[1];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(f<d)){t.next=2;break}throw new RangeError("parameter `stop` (= "+f+") must be >= `start` (= "+d+")");case 2:e=!0,n=!1,i=void 0,t.prev=5,r=s(this.enumerate());case 7:if(e=(l=r.next()).done){t.next=20;break}if(u=o(l.value,2),c=u[0],!((h=u[1])<d)){t.next=13;break}return t.abrupt("continue",17);case 13:if(!(h>=f)){t.next=15;break}return t.abrupt("break",20);case 15:return t.next=17,c;case 17:e=!0,t.next=7;break;case 20:t.next=26;break;case 22:t.prev=22,t.t0=t.catch(5),n=!0,i=t.t0;case 26:t.prev=26,t.prev=27,!e&&r.return&&r.return();case 29:if(t.prev=29,!n){t.next=32;break}throw i;case 32:return t.finish(29);case 33:return t.finish(26);case 34:case"end":return t.stop()}},t,this,[[5,22,26,34],[27,,29,33]])}),2),b("spreadMap",a.mark(function t(e){var n,o,r,l,u,c;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=!0,o=!1,r=void 0,t.prev=3,l=s(this);case 5:if(n=(u=l.next()).done){t.next=12;break}return c=u.value,t.next=9,e.apply(void 0,i(c));case 9:n=!0,t.next=5;break;case 12:t.next=18;break;case 14:t.prev=14,t.t0=t.catch(3),o=!0,r=t.t0;case 18:t.prev=18,t.prev=19,!n&&l.return&&l.return();case 21:if(t.prev=21,!o){t.next=24;break}throw r;case 24:return t.finish(21);case 25:return t.finish(18);case 26:case"end":return t.stop()}},t,this,[[3,14,18,26],[19,,21,25]])})),b("take",a.mark(function t(e){var n,i,o,r,l,u,c;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<1)){t.next=2;break}return t.abrupt("return");case 2:n=0,i=!0,o=!1,r=void 0,t.prev=6,l=s(this);case 8:if(i=(u=l.next()).done){t.next=17;break}return c=u.value,t.next=12,c;case 12:if(!(++n>=e)){t.next=14;break}return t.abrupt("break",17);case 14:i=!0,t.next=8;break;case 17:t.next=23;break;case 19:t.prev=19,t.t0=t.catch(6),o=!0,r=t.t0;case 23:t.prev=23,t.prev=24,!i&&l.return&&l.return();case 26:if(t.prev=26,!o){t.next=29;break}throw r;case 29:return t.finish(26);case 30:return t.finish(23);case 31:case"end":return t.stop()}},t,this,[[6,19,23,31],[24,,26,30]])})),b("takeWhile",a.mark(function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=14;break}if(l=r.value,u(l)){t.next=9;break}return t.abrupt("break",14);case 9:return t.next=11,l;case 11:e=!0,t.next=5;break;case 14:t.next=20;break;case 16:t.prev=16,t.t0=t.catch(3),n=!0,i=t.t0;case 20:t.prev=20,t.prev=21,!e&&o.return&&o.return();case 23:if(t.prev=23,!n){t.next=26;break}throw i;case 26:return t.finish(23);case 27:return t.finish(20);case 28:case"end":return t.stop()}},t,this,[[3,16,20,28],[21,,23,27]])}),1),b("tap",a.mark(function t(){var e,n,i,o,r,l,u=arguments.length<=0||void 0===arguments[0]?console.log.bind(console):arguments[0];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=!0,n=!1,i=void 0,t.prev=3,o=s(this);case 5:if(e=(r=o.next()).done){t.next=13;break}return l=r.value,u(l),t.next=10,l;case 10:e=!0,t.next=5;break;case 13:t.next=19;break;case 15:t.prev=15,t.t0=t.catch(3),n=!0,i=t.t0;case 19:t.prev=19,t.prev=20,!e&&o.return&&o.return();case 22:if(t.prev=22,!n){t.next=25;break}throw i;case 25:return t.finish(22);case 26:return t.finish(19);case 27:case"end":return t.stop()}},t,this,[[3,15,19,27],[20,,22,26]])}),1),b("unique",a.mark(function t(){var e,n,i,o,r,l,c;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:e=new u,n=!0,i=!1,o=void 0,t.prev=4,r=s(this);case 6:if(n=(l=r.next()).done){t.next=15;break}if(c=l.value,e.has(c)){t.next=12;break}return t.next=11,c;case 11:e.add(c);case 12:n=!0,t.next=6;break;case 15:t.next=21;break;case 17:t.prev=17,t.t0=t.catch(4),i=!0,o=t.t0;case 21:t.prev=21,t.prev=22,!n&&r.return&&r.return();case 24:if(t.prev=24,!i){t.next=27;break}throw o;case 27:return t.finish(24);case 28:return t.finish(21);case 29:e.clear();case 30:case"end":return t.stop()}},t,this,[[4,17,21,29],[22,,24,28]])}));var _=C(a.mark(function t(e){var n,i,o,r,l,u,c,h,d,f,m,g,v,C=!(arguments.length<=1||void 0===arguments[1])&&arguments[1];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e.length){t.next=2;break}return t.abrupt("return");case 2:n=e.map(p),i=e.length,o=0,r=!1;case 6:if(r){t.next=44;break}l=[],u=!0,c=!1,h=void 0,t.prev=11,d=s(n);case 13:if(u=(f=d.next()).done){t.next=26;break}if(m=f.value,g=m.next(),v=g.value,!g.done){t.next=22;break}if(C){t.next=21;break}return t.abrupt("return");case 21:++o==i&&(r=!0);case 22:void 0===v?l.length++:l.push(v);case 23:u=!0,t.next=13;break;case 26:t.next=32;break;case 28:t.prev=28,t.t0=t.catch(11),c=!0,h=t.t0;case 32:t.prev=32,t.prev=33,!u&&d.return&&d.return();case 35:if(t.prev=35,!c){t.next=38;break}throw h;case 38:return t.finish(35);case 39:return t.finish(32);case 40:return t.next=42,l;case 42:t.next=6;break;case 44:case"end":return t.stop()}},t,this,[[11,28,32,40],[33,,35,39]])}));y("zip",a.mark(function t(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(_(n),"t0",1);case 1:case"end":return t.stop()}},t,this)})),y("zipLongest",a.mark(function t(){for(var e=arguments.length,n=Array(e),i=0;i<e;i++)n[i]=arguments[i];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(_(n,!0),"t0",1);case 1:case"end":return t.stop()}},t,this)})),y("zipWith",a.mark(function t(e){for(var n=arguments.length,i=Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.delegateYield(_(i).spreadMap(e),"t0",1);case 1:case"end":return t.stop()}},t,this)})),h.MAX_BLOCK=15,h.TIMEOUT=1,v("asyncEach",function(t){var e=arguments.length<=1||void 0===arguments[1]?h.MAX_BLOCK:arguments[1],n=arguments.length<=2||void 0===arguments[2]?h.TIMEOUT:arguments[2],i=p(this);return new c(function(o,r){!function a(){var l=Date.now(),u=!0,c=!1,h=void 0;try{for(var d,f=s(i);!(u=(d=f.next()).done);u=!0){var m=d.value;try{t(m)}catch(t){return void r(t)}if(Date.now()-l>e)return void setTimeout(a,n)}}catch(t){c=!0,h=t}finally{try{!u&&f.return&&f.return()}finally{if(c)throw h}}o()}()})},3),v("every",function(){var t=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0],e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)if(!t(o.value))return!1}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}return!0},1),v("find",function(t){var e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0){var a=o.value;if(t(a))return a}}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}}),v("forEach",function(t){var e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)t(o.value)}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}}),v("has",function(t){return this.some(function(e){return e===t})}),v("reduce",function(t){var e=arguments.length<=1||void 0===arguments[1]?void 0:arguments[1];if(void 0===e){var n=!0,i=!1,o=void 0;try{for(var r,a=s(this);!(n=(r=a.next()).done);n=!0){e=r.value;break}}catch(t){i=!0,o=t}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}}var l=!0,u=!1,c=void 0;try{for(var h,d=s(this);!(l=(h=d.next()).done);l=!0)e=t(e,h.value)}catch(t){u=!0,c=t}finally{try{!l&&d.return&&d.return()}finally{if(u)throw c}}return e},2),v("some",function(){var t=arguments.length<=0||void 0===arguments[0]?Boolean:arguments[0],e=!0,n=!1,i=void 0;try{for(var o,r=s(this);!(e=(o=r.next()).done);e=!0)if(t(o.value))return!0}catch(t){n=!0,i=t}finally{try{!e&&r.return&&r.return()}finally{if(n)throw i}}return!1},1),v("toArray",function(){return[].concat(i(this))});var w=C(a.mark(function t(e,n){var i,o,r,s,l;return a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:i=n.items,o=0;case 2:if(o!==i.length){t.next=14;break}if(r=e.next(),s=r.done,l=r.value,!s){t.next=10;break}return n.returned===f&&(n.returned=l),t.abrupt("break",25);case 10:return t.next=12,i[o++]=l;case 12:t.next=23;break;case 14:if(o!==n.tail){t.next=21;break}return l=i[o],500===o?(i=n.items=i.slice(o),o=0,n.tail=0):(i[o]=void 0,n.tail=++o),t.next=19,l;case 19:t.next=23;break;case 21:return t.next=23,i[o++];case 23:t.next=2;break;case 25:return n.tail===o&&(i.length=0),t.abrupt("return",n.returned);case 27:case"end":return t.stop()}},t,this)}));w.prototype=d.prototype,v("tee",function(){for(var t=arguments.length<=0||void 0===arguments[0]?2:arguments[0],e=new Array(t),n={tail:0,items:[],returned:f};t--;)e[t]=w(this,n);return e},1),v("unzip",function(){var t=arguments.length<=0||void 0===arguments[0]?2:arguments[0];return this.tee(t).map(function(t,e){return t.pluck(e)})},1),h.tang={clan:36}},function(t,e,n){"use strict";var i=n(2).default;e.default=function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return i(t)},e.__esModule=!0},function(t,e,n){t.exports={default:n(3),__esModule:!0}},function(t,e,n){n(4),n(26),t.exports=n(12).Array.from},function(t,e,n){"use strict";var i=n(5)(!0);n(8)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=i(e,n),this._i+=t.length,{value:t,done:!1})})},function(t,e,n){var i=n(6),o=n(7);t.exports=function(t){return function(e,n){var r,s,a=String(o(e)),l=i(n),u=a.length;return l<0||l>=u?t?"":void 0:(r=a.charCodeAt(l))<55296||r>56319||l+1===u||(s=a.charCodeAt(l+1))<56320||s>57343?t?a.charAt(l):r:t?a.slice(l,l+2):s-56320+(r-55296<<10)+65536}}},function(t,e){var n=Math.ceil,i=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?i:n)(t)}},function(t,e){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){"use strict";var i=n(9),o=n(10),r=n(13),s=n(14),a=n(19),l=n(20)("iterator"),u=n(23),c=!([].keys&&"next"in[].keys()),h="@@iterator",d="keys",f="values",m=function(){return this};t.exports=function(t,e,p,g,v,C,y){n(24)(p,e,g);var b,_,w=function(t){switch(t){case d:case f:return function(){return new p(this,t)}}return function(){return new p(this,t)}},A=e+" Iterator",S=t.prototype,T=S[l]||S[h]||v&&S[v],E=T||w(v);if(T){var N=n(15).getProto(E.call(new t));n(25)(N,A,!0),!i&&a(S,h)&&s(N,l,m)}if(i&&!y||s(S,l,E),u[e]=E,u[A]=m,v)if(b={keys:C?E:w(d),values:v==f?E:w(f),entries:v!=f?E:w("entries")},y)for(_ in b)_ in S||r(S,_,b[_]);else o(o.P+o.F*c,e,b)}},function(t,e){t.exports=!0},function(t,e,n){var i=n(11),o=n(12),r="prototype",s=function(t,e){return function(){return t.apply(e,arguments)}},a=function(t,e,n){var l,u,c,h,d=t&a.G,f=t&a.P,m=d?i:t&a.S?i[e]:(i[e]||{})[r],p=d?o:o[e]||(o[e]={});for(l in d&&(n=e),n)(u=!(t&a.F)&&m&&l in m)&&l in p||(c=u?m[l]:n[l],d&&"function"!=typeof m[l]?h=n[l]:t&a.B&&u?h=s(c,i):t&a.W&&m[l]==c?function(t){(h=function(e){return this instanceof t?new t(e):t(e)})[r]=t[r]}(c):h=f&&"function"==typeof c?s(Function.call,c):c,p[l]=h,f&&((p[r]||(p[r]={}))[l]=c))};a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,t.exports=a},function(t,e){var n="undefined",i=t.exports=typeof window!=n&&window.Math==Math?window:typeof self!=n&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(t,e){var n=t.exports={version:"1.2.0"};"number"==typeof __e&&(__e=n)},function(t,e,n){t.exports=n(14)},function(t,e,n){var i=n(15),o=n(16);t.exports=n(17)?function(t,e,n){return i.setDesc(t,e,o(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e){var n=Object;t.exports={create:n.create,getProto:n.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:n.getOwnPropertyDescriptor,setDesc:n.defineProperty,setDescs:n.defineProperties,getKeys:n.keys,getNames:n.getOwnPropertyNames,getSymbols:n.getOwnPropertySymbols,each:[].forEach}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){t.exports=!n(18)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){var i=n(21)("wks"),o=n(11).Symbol;t.exports=function(t){return i[t]||(i[t]=o&&o[t]||(o||n(22))("Symbol."+t))}},function(t,e,n){var i=n(11),o="__core-js_shared__",r=i[o]||(i[o]={});t.exports=function(t){return r[t]||(r[t]={})}},function(t,e){var n=0,i=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++n+i).toString(36))}},function(t,e){t.exports={}},function(t,e,n){"use strict";var i=n(15),o={};n(14)(o,n(20)("iterator"),function(){return this}),t.exports=function(t,e,r){t.prototype=i.create(o,{next:n(16)(1,r)}),n(25)(t,e+" Iterator")}},function(t,e,n){var i=n(19),o=n(14),r=n(20)("toStringTag");t.exports=function(t,e,n){t&&!i(t=n?t:t.prototype,r)&&o(t,r,e)}},function(t,e,n){"use strict";var i=n(27),o=n(10),r=n(29),s=n(30),a=n(33),l=n(34),u=n(35);o(o.S+o.F*!n(38)(function(t){Array.from(t)}),"Array",{from:function(t){var e,n,o,c,h=r(t),d="function"==typeof this?this:Array,f=arguments[1],m=void 0!==f,p=0,g=u(h);if(m&&(f=i(f,arguments[2],2)),null==g||d==Array&&a(g))for(n=new d(e=l(h.length));e>p;p++)n[p]=m?f(h[p],p):h[p];else for(c=g.call(h),n=new d;!(o=c.next()).done;p++)n[p]=m?s(c,f,[o.value,p],!0):o.value;return n.length=p,n}})},function(t,e,n){var i=n(28);t.exports=function(t,e,n){if(i(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,o){return t.call(e,n,i,o)}}return function(){return t.apply(e,arguments)}}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,n){var i=n(7);t.exports=function(t){return Object(i(t))}},function(t,e,n){var i=n(31);t.exports=function(t,e,n,o){try{return o?e(i(n)[0],n[1]):e(n)}catch(e){var r=t.return;throw void 0!==r&&i(r.call(t)),e}}},function(t,e,n){var i=n(32);t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){var i=n(23),o=n(20)("iterator");t.exports=function(t){return(i.Array||Array.prototype[o])===t}},function(t,e,n){var i=n(6),o=Math.min;t.exports=function(t){return t>0?o(i(t),9007199254740991):0}},function(t,e,n){var i=n(36),o=n(20)("iterator"),r=n(23);t.exports=n(12).getIteratorMethod=function(t){if(null!=t)return t[o]||t["@@iterator"]||r[i(t)]}},function(t,e,n){var i=n(37),o=n(20)("toStringTag"),r="Arguments"==i(function(){return arguments}());t.exports=function(t){var e,n,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=(e=Object(t))[o])?n:r?i(e):"Object"==(s=i(e))&&"function"==typeof e.callee?"Arguments":s}},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var i=n(20)("iterator"),o=!1;try{var r=[7][i]();r.return=function(){o=!0},Array.from(r,function(){throw 2})}catch(t){}t.exports=function(t){if(!o)return!1;var e=!1;try{var n=[7],r=n[i]();r.next=function(){e=!0},n[i]=function(){return r},t(n)}catch(t){}return e}},function(t,e,n){"use strict";var i=n(40).default,o=n(49).default;e.default=function(t,e){if(Array.isArray(t))return t;if(o(Object(t)))return function(t,e){var n=[],o=!0,r=!1,s=void 0;try{for(var a,l=i(t);!(o=(a=l.next()).done)&&(n.push(a.value),!e||n.length!==e);o=!0);}catch(t){r=!0,s=t}finally{try{!o&&l.return&&l.return()}finally{if(r)throw s}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},e.__esModule=!0},function(t,e,n){t.exports={default:n(41),__esModule:!0}},function(t,e,n){n(42),n(4),t.exports=n(48)},function(t,e,n){n(43);var i=n(23);i.NodeList=i.HTMLCollection=i.Array},function(t,e,n){"use strict";var i=n(44),o=n(45),r=n(23),s=n(46);n(8)(Array,"Array",function(t,e){this._t=s(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,n=this._i++;return!t||n>=t.length?(this._t=void 0,o(1)):o(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]])},"values"),r.Arguments=r.Array,i("keys"),i("values"),i("entries")},function(t,e){t.exports=function(){}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e,n){var i=n(47),o=n(7);t.exports=function(t){return i(o(t))}},function(t,e,n){var i=n(37);t.exports=0 in Object("z")?Object:function(t){return"String"==i(t)?t.split(""):Object(t)}},function(t,e,n){var i=n(31),o=n(35);t.exports=n(12).getIterator=function(t){var e=o(t);if("function"!=typeof e)throw TypeError(t+" is not iterable!");return i(e.call(t))}},function(t,e,n){t.exports={default:n(50),__esModule:!0}},function(t,e,n){n(42),n(4),t.exports=n(51)},function(t,e,n){var i=n(36),o=n(20)("iterator"),r=n(23);t.exports=n(12).isIterable=function(t){var e=Object(t);return o in e||"@@iterator"in e||r.hasOwnProperty(i(e))}},function(t,e,n){t.exports={default:n(53),__esModule:!0}},function(t,e,n){n(4),n(42),t.exports=n(20)("iterator")},function(t,e,n){(function(e){var i="object"==typeof e?e:"object"==typeof window?window:"object"==typeof self?self:this,o=i.regeneratorRuntime&&Object.getOwnPropertyNames(i).indexOf("regeneratorRuntime")>=0,r=o&&i.regeneratorRuntime;if(i.regeneratorRuntime=void 0,t.exports=n(55),o)i.regeneratorRuntime=r;else try{delete i.regeneratorRuntime}catch(t){i.regeneratorRuntime=void 0}t.exports={default:t.exports,__esModule:!0}}).call(e,function(){return this}())},function(t,e,n){(function(e,i){"use strict";var o=n(57).default,r=n(52).default,s=n(63).default,a=n(65).default;!function(e){var n,l=Object.prototype.hasOwnProperty,u="function"==typeof o&&r||"@@iterator",c="object"==typeof t,h=e.regeneratorRuntime;if(h)c&&(t.exports=h);else{(h=e.regeneratorRuntime=c?t.exports:{}).wrap=C;var d="suspendedStart",f="suspendedYield",m="executing",p="completed",g={},v=w.prototype=b.prototype;_.prototype=v.constructor=w,w.constructor=_,_.displayName="GeneratorFunction",h.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},h.mark=function(t){return t.__proto__=w,t.prototype=s(v),t},h.awrap=function(t){return new S(t)},A(T.prototype),h.async=function(t,e,n,i){var o=new T(C(t,e,n,i));return h.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},A(v),v[u]=function(){return this},v.toString=function(){return"[object Generator]"},h.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var i=e.pop();if(i in t)return n.value=i,n.done=!1,n}return n.done=!0,n}},h.values=M,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=n,this.done=!1,this.delegate=null,this.tryEntries.forEach(N),!t)for(var e in this)"t"===e.charAt(0)&&l.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,i){return r.type="throw",r.arg=t,e.next=n,!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],r=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=l.call(o,"catchLoc"),a=l.call(o,"finallyLoc");if(s&&a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&l.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var r=o?o.completion:{};return r.type=t,r.arg=e,o?this.next=o.finallyLoc:this.complete(r),g},complete:function(t,e){if("throw"===t.type)throw t.arg;"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=t.arg,this.next="end"):"normal"===t.type&&e&&(this.next=e)},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),N(n),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var o=i.arg;N(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:M(t),resultName:e,nextLoc:n},g}}}function C(t,e,i,o){var r=s((e||b).prototype);return r._invoke=function(t,e,i){var o=d;return function(r,s){if(o===m)throw new Error("Generator is already running");if(o===p){if("throw"===r)throw s;return I()}for(;;){var a=i.delegate;if(a){if("return"===r||"throw"===r&&a.iterator[r]===n){i.delegate=null;var l=a.iterator.return;if(l&&"throw"===(u=y(l,a.iterator,s)).type){r="throw",s=u.arg;continue}if("return"===r)continue}var u;if("throw"===(u=y(a.iterator[r],a.iterator,s)).type){i.delegate=null,r="throw",s=u.arg;continue}if(r="next",s=n,!(c=u.arg).done)return o=f,c;i[a.resultName]=c.value,i.next=a.nextLoc,i.delegate=null}if("next"===r)i.sent=o===f?s:n;else if("throw"===r){if(o===d)throw o=p,s;i.dispatchException(s)&&(r="next",s=n)}else"return"===r&&i.abrupt("return",s);if(o=m,"normal"===(u=y(t,e,i)).type){o=i.done?p:f;var c={value:u.arg,done:i.done};if(u.arg!==g)return c;i.delegate&&"next"===r&&(s=n)}else"throw"===u.type&&(o=p,r="throw",s=u.arg)}}}(t,i||null,new x(o||[])),r}function y(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}function b(){}function _(){}function w(){}function A(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function S(t){this.arg=t}function T(t){function e(e,n){var i=t[e](n),s=i.value;return s instanceof S?a.resolve(s.arg).then(o,r):a.resolve(s).then(function(t){return i.value=t,i})}"object"==typeof i&&i.domain&&(e=i.domain.bind(e));var n,o=e.bind(t,"next"),r=e.bind(t,"throw");e.bind(t,"return"),this._invoke=function(t,i){var o=n?n.then(function(){return e(t,i)}):new a(function(n){n(e(t,i))});return n=o.catch(function(t){}),o}}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function M(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(l.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}return{next:I}}function I(){return{value:n,done:!0}}}("object"==typeof e?e:"object"==typeof window?window:"object"==typeof self?self:void 0)}).call(e,function(){return this}(),n(56))},function(t,e){var n,i=t.exports={},o=[],r=!1,s=-1;function a(){r=!1,n.length?o=n.concat(o):s=-1,o.length&&l()}function l(){if(!r){var t=setTimeout(a);r=!0;for(var e=o.length;e;){for(n=o,o=[];++s<e;)n&&n[s].run();s=-1,e=o.length}n=null,r=!1,clearTimeout(t)}}function u(t,e){this.fun=t,this.array=e}function c(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];o.push(new u(t,e)),1!==o.length||r||setTimeout(l,0)},u.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=c,i.addListener=c,i.once=c,i.off=c,i.removeListener=c,i.removeAllListeners=c,i.emit=c,i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,n){t.exports={default:n(58),__esModule:!0}},function(t,e,n){n(59),t.exports=n(12).Symbol},function(t,e,n){"use strict";var i=n(15),o=n(11),r=n(19),s=n(17),a=n(10),l=n(13),u=n(18),c=n(21),h=n(25),d=n(22),f=n(20),m=n(60),p=n(61),g=n(62),v=n(32),C=n(31),y=n(46),b=n(16),_=i.getDesc,w=i.setDesc,A=i.create,S=p.get,T=o.Symbol,E=!1,N=f("_hidden"),x=i.isEnum,M=c("symbol-registry"),I=c("symbols"),O="function"==typeof T,P=Object.prototype,L=s&&u(function(){return 7!=A(w({},"a",{get:function(){return w(this,"a",{value:7}).a}})).a})?function(t,e,n){var i=_(P,e);i&&delete P[e],w(t,e,n),i&&t!==P&&w(P,e,i)}:w,R=function(t){var e=I[t]=A(T.prototype);return e._k=t,s&&E&&L(P,t,{configurable:!0,set:function(e){r(this,N)&&r(this[N],t)&&(this[N][t]=!1),L(this,t,b(1,e))}}),e},k=function(t,e,n){return n&&r(I,e)?(n.enumerable?(r(t,N)&&t[N][e]&&(t[N][e]=!1),n=A(n,{enumerable:b(0,!1)})):(r(t,N)||w(t,N,b(1,{})),t[N][e]=!0),L(t,e,n)):w(t,e,n)},F=function(t,e){C(t);for(var n,i=g(e=y(e)),o=0,r=i.length;r>o;)k(t,n=i[o++],e[n]);return t},V=function(t,e){return void 0===e?A(t):F(A(t),e)},D=function(t){var e=x.call(this,t);return!(e||!r(this,t)||!r(I,t)||r(this,N)&&this[N][t])||e},G=function(t,e){var n=_(t=y(t),e);return!n||!r(I,e)||r(t,N)&&t[N][e]||(n.enumerable=!0),n},B=function(t){for(var e,n=S(y(t)),i=[],o=0;n.length>o;)r(I,e=n[o++])||e==N||i.push(e);return i},U=function(t){for(var e,n=S(y(t)),i=[],o=0;n.length>o;)r(I,e=n[o++])&&i.push(I[e]);return i};O||(T=function(){if(this instanceof T)throw TypeError("Symbol is not a constructor");return R(d(arguments[0]))},l(T.prototype,"toString",function(){return this._k}),i.create=V,i.isEnum=D,i.getDesc=G,i.setDesc=k,i.setDescs=F,i.getNames=p.get=B,i.getSymbols=U,s&&!n(9)&&l(P,"propertyIsEnumerable",D,!0)),O&&!u(function(){return"[null]"!=JSON.stringify([T()])})||l(T.prototype,"toJSON",function(){if(O&&v(this))return this});var q={for:function(t){return r(M,t+="")?M[t]:M[t]=T(t)},keyFor:function(t){return m(M,t)},useSetter:function(){E=!0},useSimple:function(){E=!1}};i.each.call("hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),function(t){var e=f(t);q[t]=O?e:R(e)}),E=!0,a(a.G+a.W,{Symbol:T}),a(a.S,"Symbol",q),a(a.S+a.F*!O,"Object",{create:V,defineProperty:k,defineProperties:F,getOwnPropertyDescriptor:G,getOwnPropertyNames:B,getOwnPropertySymbols:U}),h(T,"Symbol"),h(Math,"Math",!0),h(o.JSON,"JSON",!0)},function(t,e,n){var i=n(15),o=n(46);t.exports=function(t,e){for(var n,r=o(t),s=i.getKeys(r),a=s.length,l=0;a>l;)if(r[n=s[l++]]===e)return n}},function(t,e,n){var i={}.toString,o=n(46),r=n(15).getNames,s="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.get=function(t){return s&&"[object Window]"==i.call(t)?function(t){try{return r(t)}catch(t){return s.slice()}}(t):r(o(t))}},function(t,e,n){var i=n(15);t.exports=function(t){var e=i.getKeys(t),n=i.getSymbols;if(n)for(var o,r=n(t),s=i.isEnum,a=0;r.length>a;)s.call(t,o=r[a++])&&e.push(o);return e}},function(t,e,n){t.exports={default:n(64),__esModule:!0}},function(t,e,n){var i=n(15);t.exports=function(t,e){return i.create(t,e)}},function(t,e,n){t.exports={default:n(66),__esModule:!0}},function(t,e,n){n(67),n(4),n(42),n(68),t.exports=n(12).Promise},function(t,e){},function(t,e,n){"use strict";var i,o=n(15),r=n(9),s=n(11),a=n(27),l=n(36),u=n(10),c=n(32),h=n(31),d=n(28),f=n(69),m=n(70),p=n(71).set,g=n(72),v=n(73),C=n(20)("species"),y=n(22)("record"),b=n(74),_="Promise",w=s.process,A="process"==l(w),S=s[_],T=function(t){var e=new S(function(){});return t&&(e.constructor=Object),S.resolve(e)===e},E=function(){var t=!1;function e(t){var n=new S(t);return p(n,e.prototype),n}try{if(t=S&&S.resolve&&T(),p(e,S),e.prototype=o.create(S.prototype,{constructor:{value:e}}),e.resolve(5).then(function(){})instanceof e||(t=!1),t&&n(17)){var i=!1;S.resolve(o.setDesc({},"then",{get:function(){i=!0}})),t=i}}catch(e){t=!1}return t}(),N=function(t){var e=h(t)[C];return null!=e?e:t},x=function(t){var e;return!(!c(t)||"function"!=typeof(e=t.then))&&e},M=function(t,e){if(!t.n){t.n=!0;var n=t.c;b(function(){for(var i=t.v,o=1==t.s,r=0,a=function(e){var n,r,s=o?e.ok:e.fail;try{s?(o||(t.h=!0),(n=!0===s?i:s(i))===e.P?e.rej(TypeError("Promise-chain cycle")):(r=x(n))?r.call(n,e.res,e.rej):e.res(n)):e.rej(i)}catch(t){e.rej(t)}};n.length>r;)a(n[r++]);n.length=0,t.n=!1,e&&setTimeout(function(){var e,n,o=t.p;I(o)&&(A?w.emit("unhandledRejection",i,o):(e=s.onunhandledrejection)?e({promise:o,reason:i}):(n=s.console)&&n.error&&n.error("Unhandled promise rejection",i)),t.a=void 0},1)})}},I=function(t){var e,n=t[y],i=n.a||n.c,o=0;if(n.h)return!1;for(;i.length>o;)if((e=i[o++]).fail||!I(e.P))return!1;return!0},O=function(t){var e=this;e.d||(e.d=!0,(e=e.r||e).v=t,e.s=2,e.a=e.c.slice(),M(e,!0))},P=function(t){var e,n=this;if(!n.d){n.d=!0,n=n.r||n;try{(e=x(t))?b(function(){var i={r:n,d:!1};try{e.call(t,a(P,i,1),a(O,i,1))}catch(t){O.call(i,t)}}):(n.v=t,n.s=1,M(n,!1))}catch(t){O.call({r:n,d:!1},t)}}};E||(S=function(t){d(t);var e={p:f(this,S,_),c:[],a:void 0,s:0,d:!1,v:void 0,h:!1,n:!1};this[y]=e;try{t(a(P,e,1),a(O,e,1))}catch(t){O.call(e,t)}},n(79)(S.prototype,{then:function(t,e){var n=h(h(this).constructor)[C],i={ok:"function"!=typeof t||t,fail:"function"==typeof e&&e},o=i.P=new(null!=n?n:S)(function(t,e){i.res=t,i.rej=e});d(i.res),d(i.rej);var r=this[y];return r.c.push(i),r.a&&r.a.push(i),r.s&&M(r,!1),o},catch:function(t){return this.then(void 0,t)}})),u(u.G+u.W+u.F*!E,{Promise:S}),n(25)(S,_),v(S),v(i=n(12)[_]),u(u.S+u.F*!E,_,{reject:function(t){return new this(function(e,n){n(t)})}}),u(u.S+u.F*(!E||T(!0)),_,{resolve:function(t){return c(n=t)&&(E?"Promise"==l(n):y in n)&&(e=t.constructor,r&&e===S&&this===i||g(e,this))?t:new this(function(e){e(t)});var e,n}}),u(u.S+u.F*!(E&&n(38)(function(t){S.all(t).catch(function(){})})),_,{all:function(t){var e=N(this),n=[];return new e(function(i,r){m(t,!1,n.push,n);var s=n.length,a=Array(s);s?o.each.call(n,function(t,n){e.resolve(t).then(function(t){a[n]=t,--s||i(a)},r)}):i(a)})},race:function(t){var e=N(this);return new e(function(n,i){m(t,!1,function(t){e.resolve(t).then(n,i)})})}})},function(t,e){t.exports=function(t,e,n){if(!(t instanceof e))throw TypeError(n+": use the 'new' operator!");return t}},function(t,e,n){var i=n(27),o=n(30),r=n(33),s=n(31),a=n(34),l=n(35);t.exports=function(t,e,n,u){var c,h,d,f=l(t),m=i(n,u,e?2:1),p=0;if("function"!=typeof f)throw TypeError(t+" is not iterable!");if(r(f))for(c=a(t.length);c>p;p++)e?m(s(h=t[p])[0],h[1]):m(t[p]);else for(d=f.call(t);!(h=d.next()).done;)o(d,m,h.value,e)}},function(t,e,n){var i=n(15).getDesc,o=n(32),r=n(31),s=function(t,e){if(r(t),!o(e)&&null!==e)throw TypeError(e+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,o){try{(o=n(27)(Function.call,i(Object.prototype,"__proto__").set,2))(t,[]),e=!(t instanceof Array)}catch(t){e=!0}return function(t,n){return s(t,n),e?t.__proto__=n:o(t,n),t}}({},!1):void 0),check:s}},function(t,e){t.exports=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}},function(t,e,n){"use strict";var i=n(15),o=n(20)("species");t.exports=function(t){n(17)&&!(o in t)&&i.setDesc(t,o,{configurable:!0,get:function(){return this}})}},function(t,e,n){var i,o,r,s=n(11),a=n(75).set,l=s.MutationObserver||s.WebKitMutationObserver,u=s.process,c="process"==n(37)(u),h=function(){var t,e;for(c&&(t=u.domain)&&(u.domain=null,t.exit());i;)(e=i.domain)&&e.enter(),i.fn.call(),e&&e.exit(),i=i.next;o=void 0,t&&t.enter()};if(c)r=function(){u.nextTick(h)};else if(l){var d=1,f=document.createTextNode("");new l(h).observe(f,{characterData:!0}),r=function(){f.data=d=-d}}else r=function(){a.call(s,h)};t.exports=function(t){var e={fn:t,next:void 0,domain:c&&u.domain};o&&(o.next=e),i||(i=e,r()),o=e}},function(t,e,n){"use strict";var i,o,r,s=n(27),a=n(76),l=n(77),u=n(78),c=n(11),h=c.process,d=c.setImmediate,f=c.clearImmediate,m=c.MessageChannel,p=0,g={},v="onreadystatechange",C=function(){var t=+this;if(g.hasOwnProperty(t)){var e=g[t];delete g[t],e()}},y=function(t){C.call(t.data)};d&&f||(d=function(t){for(var e=[],n=1;arguments.length>n;)e.push(arguments[n++]);return g[++p]=function(){a("function"==typeof t?t:Function(t),e)},i(p),p},f=function(t){delete g[t]},"process"==n(37)(h)?i=function(t){h.nextTick(s(C,t,1))}:m?(r=(o=new m).port2,o.port1.onmessage=y,i=s(r.postMessage,r,1)):c.addEventListener&&"function"==typeof postMessage&&!c.importScript?(i=function(t){c.postMessage(t+"","*")},c.addEventListener("message",y,!1)):i=v in u("script")?function(t){l.appendChild(u("script"))[v]=function(){l.removeChild(this),C.call(t)}}:function(t){setTimeout(s(C,t,1),0)}),t.exports={set:d,clear:f}},function(t,e){t.exports=function(t,e,n){var i=void 0===n;switch(e.length){case 0:return i?t():t.call(n);case 1:return i?t(e[0]):t.call(n,e[0]);case 2:return i?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return i?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return i?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3])}return t.apply(n,e)}},function(t,e,n){t.exports=n(11).document&&document.documentElement},function(t,e,n){var i=n(32),o=n(11).document,r=i(o)&&i(o.createElement);t.exports=function(t){return r?o.createElement(t):{}}},function(t,e,n){var i=n(13);t.exports=function(t,e){for(var n in e)i(t,n,e[n]);return t}},function(t,e,n){t.exports={default:n(81),__esModule:!0}},function(t,e,n){n(82),t.exports=n(12).Object.keys},function(t,e,n){var i=n(29);n(83)("keys",function(t){return function(e){return t(i(e))}})},function(t,e,n){t.exports=function(t,e){var i=n(10),o=(n(12).Object||{})[t]||Object[t],r={};r[t]=e(o),i(i.S+i.F*n(18)(function(){o(1)}),"Object",r)}},function(t,e,n){t.exports={default:n(85),__esModule:!0}},function(t,e,n){n(67),n(4),n(42),n(86),n(89),t.exports=n(12).Set},function(t,e,n){"use strict";var i=n(87);n(88)("Set",function(t){return function(){return t(this,arguments[0])}},{add:function(t){return i.def(this,t=0===t?0:t,t)}},i)},function(t,e,n){"use strict";var i=n(15),o=n(14),r=n(27),s=n(73),a=n(69),l=n(7),u=n(70),c=n(45),h=n(22)("id"),d=n(19),f=n(32),m=Object.isExtensible||f,p=n(17),g=p?"_s":"size",v=0,C=function(t,e){if(!f(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!d(t,h)){if(!m(t))return"F";if(!e)return"E";o(t,h,++v)}return"O"+t[h]},y=function(t,e){var n,i=C(e);if("F"!==i)return t._i[i];for(n=t._f;n;n=n.n)if(n.k==e)return n};t.exports={getConstructor:function(t,e,o,s){var c=t(function(t,n){a(t,c,e),t._i=i.create(null),t._f=void 0,t._l=void 0,t[g]=0,null!=n&&u(n,o,t[s],t)});return n(79)(c.prototype,{clear:function(){for(var t=this,e=t._i,n=t._f;n;n=n.n)n.r=!0,n.p&&(n.p=n.p.n=void 0),delete e[n.i];t._f=t._l=void 0,t[g]=0},delete:function(t){var e=this,n=y(e,t);if(n){var i=n.n,o=n.p;delete e._i[n.i],n.r=!0,o&&(o.n=i),i&&(i.p=o),e._f==n&&(e._f=i),e._l==n&&(e._l=o),e[g]--}return!!n},forEach:function(t){for(var e,n=r(t,arguments[1],3);e=e?e.n:this._f;)for(n(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!y(this,t)}}),p&&i.setDesc(c.prototype,"size",{get:function(){return l(this[g])}}),c},def:function(t,e,n){var i,o,r=y(t,e);return r?r.v=n:(t._l=r={i:o=C(e,!0),k:e,v:n,p:i=t._l,n:void 0,r:!1},t._f||(t._f=r),i&&(i.n=r),t[g]++,"F"!==o&&(t._i[o]=r)),t},getEntry:y,setStrong:function(t,e,i){n(8)(t,e,function(t,e){this._t=t,this._k=e,this._l=void 0},function(){for(var t=this,e=t._k,n=t._l;n&&n.r;)n=n.p;return t._t&&(t._l=n=n?n.n:t._t._f)?c(0,"keys"==e?n.k:"values"==e?n.v:[n.k,n.v]):(t._t=void 0,c(1))},i?"entries":"values",!i,!0),s(t),s(n(12)[e])}}},function(t,e,n){"use strict";var i=n(15),o=n(10),r=n(14),s=n(70),a=n(69);t.exports=function(t,e,l,u,c,h){var d=n(11)[t],f=d,m=c?"set":"add",p=f&&f.prototype,g={};return n(17)&&"function"==typeof f&&(h||p.forEach&&!n(18)(function(){(new f).entries().next()}))?(f=e(function(e,n){a(e,f,t),e._c=new d,null!=n&&s(n,c,e[m],e)}),i.each.call("add,clear,delete,forEach,get,has,set,keys,values,entries".split(","),function(t){var e="add"==t||"set"==t;!(t in p)||h&&"clear"==t||r(f.prototype,t,function(n,i){var o=this._c[t](0===n?0:n,i);return e?this:o})}),"size"in p&&i.setDesc(f.prototype,"size",{get:function(){return this._c.size}})):(f=u.getConstructor(e,t,c,m),n(79)(f.prototype,l)),n(25)(f,t),g[t]=f,o(o.G+o.W+o.F,g),h||u.setStrong(f,t,c),f}},function(t,e,n){var i=n(10);i(i.P,"Set",{toJSON:n(90)("Set")})},function(t,e,n){var i=n(70),o=n(36);t.exports=function(t){return function(){if(o(this)!=t)throw TypeError(t+"#toJSON isn't generic");var e=[];return i(this,!1,e.push,e),e}}}])},t.exports=e()},6082(t){"use strict";t.exports=DG},4328(t){"use strict";t.exports=grok},7389(t){"use strict";t.exports=ui}};const e={};function n(i){const o=e[i];if(void 0!==o)return o.exports;const r=e[i]={id:i,loaded:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.loaded=!0,r.exports}n.m=t,n.amdO={},n.n=t=>{const e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var o=e[i++],r=e[i++];n.o(t,o)?0===r&&i++:0===r?Object.defineProperty(t,o,{enumerable:!0,value:e[i++]}):Object.defineProperty(t,o,{enumerable:!0,get:r})}else for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.u=t=>t+".js",n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.hmd=t=>((t=Object.create(t)).children||(t.children=[]),Object.defineProperty(t,"exports",{enumerable:!0,set(){throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+t.id)}}),t),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{let t;n.g.importScripts&&(t=n.g.location+"");const e=n.g.document;if(!t&&e&&("SCRIPT"===e.currentScript?.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){const n=e.getElementsByTagName("script");if(n.length){let e=n.length-1;for(;e>-1&&(!t||!/^http(s?):/.test(t));)t=n[e--].src}}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),n.b="undefined"!=typeof document&&document.baseURI||self.location.href,n.nc=void 0;let i=n(3262);peptides=i})();
|
|
1
|
+
var peptides;(()=>{var e={5825(e,t,n){"use strict";n.d(t,{A:()=>a});var i=n(7126),r=n.n(i),o=n(5454),s=n.n(o)()(r());s.push([e.id,`.pep-textarea-box {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.pep-textarea-box:hover .pep-snippet-editor-icon {
|
|
6
|
+
visibility: visible;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.pep-snippet-editor-icon {
|
|
10
|
+
position: absolute;
|
|
11
|
+
top: 5px;
|
|
12
|
+
visibility: hidden;
|
|
13
|
+
margin: 5px;
|
|
14
|
+
z-index: 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.pep-reset-icon {
|
|
18
|
+
right: 10px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.pep-snippet-editor-icon i {
|
|
22
|
+
font-size: 13px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.pep-snippet-editor-icon:hover {
|
|
26
|
+
background-color: var(--steel-1);
|
|
27
|
+
border-radius: 2px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.pep-snippet-inline-icon i {
|
|
31
|
+
font-size: 13px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.pep-textinput {
|
|
35
|
+
height: 50px;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#pep-hist-host #center {
|
|
40
|
+
height: 131px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#pep-hist-host > #root {
|
|
44
|
+
height: unset;
|
|
45
|
+
width: 100%;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#pep-viewer-title {
|
|
49
|
+
height: 23px;
|
|
50
|
+
font-size: 1.2rem;
|
|
51
|
+
font-family: 'Roboto', 'Roboto Local', sans-serif;
|
|
52
|
+
color: #4D5261;
|
|
53
|
+
text-align: center;
|
|
54
|
+
width: 100%;
|
|
55
|
+
align-self: end;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.pep-help-icon {
|
|
59
|
+
position: absolute;
|
|
60
|
+
left: 5px;
|
|
61
|
+
top: 1px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.panel-base:has(.peptides-viewer-show-title:only-child) > .panel-titlebar > .panel-titlebar-text {
|
|
65
|
+
visibility: visible;
|
|
66
|
+
display: block;
|
|
67
|
+
text-align: center;
|
|
68
|
+
margin-left: 36px;
|
|
69
|
+
padding: 0;
|
|
70
|
+
width: 100%;
|
|
71
|
+
font-size: 14px !important;
|
|
72
|
+
color: #4d5261 !important;
|
|
73
|
+
}`,"",{version:3,sources:["webpack://./src/styles.css"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;;AAEA;EACE,mBAAmB;AACrB;;AAEA;EACE,kBAAkB;EAClB,QAAQ;EACR,kBAAkB;EAClB,WAAW;EACX,UAAU;AACZ;;AAEA;EACE,WAAW;AACb;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,gCAAgC;EAChC,kBAAkB;AACpB;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,YAAY;EACZ,gBAAgB;AAClB;;AAEA;EACE,aAAa;AACf;;AAEA;EACE,aAAa;EACb,WAAW;AACb;;AAEA;EACE,YAAY;EACZ,iBAAiB;EACjB,iDAAiD;EACjD,cAAc;EACd,kBAAkB;EAClB,WAAW;EACX,eAAe;AACjB;;AAEA;EACE,kBAAkB;EAClB,SAAS;EACT,QAAQ;AACV;;AAEA;IACI,mBAAmB;IACnB,cAAc;IACd,kBAAkB;IAClB,iBAAiB;IACjB,UAAU;IACV,WAAW;IACX,0BAA0B;IAC1B,yBAAyB;AAC7B",sourcesContent:[".pep-textarea-box {\n position: relative;\n}\n\n.pep-textarea-box:hover .pep-snippet-editor-icon {\n visibility: visible;\n}\n\n.pep-snippet-editor-icon {\n position: absolute;\n top: 5px;\n visibility: hidden;\n margin: 5px;\n z-index: 1;\n}\n\n.pep-reset-icon {\n right: 10px;\n}\n\n.pep-snippet-editor-icon i {\n font-size: 13px;\n}\n\n.pep-snippet-editor-icon:hover {\n background-color: var(--steel-1);\n border-radius: 2px;\n}\n\n.pep-snippet-inline-icon i {\n font-size: 13px;\n}\n\n.pep-textinput {\n height: 50px;\n overflow: hidden;\n}\n\n#pep-hist-host #center {\n height: 131px;\n}\n\n#pep-hist-host > #root {\n height: unset;\n width: 100%;\n}\n\n#pep-viewer-title {\n height: 23px;\n font-size: 1.2rem;\n font-family: 'Roboto', 'Roboto Local', sans-serif;\n color: #4D5261;\n text-align: center;\n width: 100%;\n align-self: end;\n}\n\n.pep-help-icon {\n position: absolute;\n left: 5px;\n top: 1px;\n}\n\n.panel-base:has(.peptides-viewer-show-title:only-child) > .panel-titlebar > .panel-titlebar-text {\n visibility: visible;\n display: block;\n text-align: center;\n margin-left: 36px;\n padding: 0;\n width: 100%;\n font-size: 14px !important;\n color: #4d5261 !important;\n}"],sourceRoot:""}]);let a=s},5454(e){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n="",i=void 0!==t[5];return t[4]&&(n+="@supports (".concat(t[4],") {")),t[2]&&(n+="@media ".concat(t[2]," {")),i&&(n+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),n+=e(t),i&&(n+="}"),t[2]&&(n+="}"),t[4]&&(n+="}"),n}).join("")},t.i=function(e,n,i,r,o){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(i)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var u=0;u<e.length;u++){var d=[].concat(e[u]);i&&s[d[0]]||(void 0!==o&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=o),n&&(d[2]&&(d[1]="@media ".concat(d[2]," {").concat(d[1],"}")),d[2]=n),r&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=r):d[4]="".concat(r)),t.push(d))}},t}},7126(e){"use strict";e.exports=function(e){var t=e[1],n=e[3];if(!n)return t;if("function"==typeof btoa){var i=btoa(unescape(encodeURIComponent(JSON.stringify(n))));return[t].concat(["/*# ".concat("sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i)," */")]).join("\n")}return[t].join("\n")}},8353(e){e.exports=function(){var e=function(e){var t=Array.prototype.concat,n=Array.prototype.slice,i=Object.prototype.toString;function r(t,n){var i=t>n?t:n;return e.pow(10,17-~~(e.log(i>0?i:-i)*e.LOG10E))}var o=Array.isArray||function(e){return"[object Array]"===i.call(e)};function s(e){return"[object Function]"===i.call(e)}function a(e){return"number"==typeof e&&e-e==0}function l(){return new l._init(arguments)}function u(){return 0}function d(){return 1}function c(e,t){return+(e===t)}l.fn=l.prototype,l._init=function(e){if(o(e[0]))if(o(e[0][0])){s(e[1])&&(e[0]=l.map(e[0],e[1]));for(var t=0;t<e[0].length;t++)this[t]=e[0][t];this.length=e[0].length}else this[0]=s(e[1])?l.map(e[0],e[1]):e[0],this.length=1;else if(a(e[0]))this[0]=l.seq.apply(null,e),this.length=1;else{if(e[0]instanceof l)return l(e[0].toArray());this[0]=[],this.length=1}return this},l._init.prototype=l.prototype,l._init.constructor=l,l.utils={calcRdx:r,isArray:o,isFunction:s,isNumber:a,toVector:function(e){return t.apply([],e)}},l._random_fn=e.random,l.setRandom=function(e){if("function"!=typeof e)throw TypeError("fn is not a function");l._random_fn=e},l.extend=function(e){var t,n;if(1==arguments.length){for(n in e)l[n]=e[n];return this}for(t=1;t<arguments.length;t++)for(n in arguments[t])e[n]=arguments[t][n];return e},l.rows=function(e){return e.length||1},l.cols=function(e){return e[0].length||1},l.dimensions=function(e){return{rows:l.rows(e),cols:l.cols(e)}},l.row=function(e,t){return o(t)?t.map(function(t){return l.row(e,t)}):e[t]},l.rowa=function(e,t){return l.row(e,t)},l.col=function(e,t){if(o(t)){var n=l.arange(e.length).map(function(){return Array(t.length)});return t.forEach(function(t,i){l.arange(e.length).forEach(function(r){n[r][i]=e[r][t]})}),n}for(var i=Array(e.length),r=0;r<e.length;r++)i[r]=[e[r][t]];return i},l.cola=function(e,t){return l.col(e,t).map(function(e){return e[0]})},l.diag=function(e){for(var t=l.rows(e),n=Array(t),i=0;i<t;i++)n[i]=[e[i][i]];return n},l.antidiag=function(e){for(var t=l.rows(e)-1,n=Array(t),i=0;t>=0;t--,i++)n[i]=[e[i][t]];return n},l.transpose=function(e){var t,n,i,r,s,a=[];for(o(e[0])||(e=[e]),n=e.length,i=e[0].length,s=0;s<i;s++){for(r=0,t=Array(n);r<n;r++)t[r]=e[r][s];a.push(t)}return 1===a.length?a[0]:a},l.map=function(e,t,n){var i,r,s,a,l;for(o(e[0])||(e=[e]),r=e.length,s=e[0].length,a=n?e:Array(r),i=0;i<r;i++)for(a[i]||(a[i]=Array(s)),l=0;l<s;l++)a[i][l]=t(e[i][l],i,l);return 1===a.length?a[0]:a},l.cumreduce=function(e,t,n){var i,r,s,a,l;for(o(e[0])||(e=[e]),r=e.length,s=e[0].length,a=n?e:Array(r),i=0;i<r;i++)for(a[i]||(a[i]=Array(s)),s>0&&(a[i][0]=e[i][0]),l=1;l<s;l++)a[i][l]=t(a[i][l-1],e[i][l]);return 1===a.length?a[0]:a},l.alter=function(e,t){return l.map(e,t,!0)},l.create=function(e,t,n){var i,r,o=Array(e);for(s(t)&&(n=t,t=e),i=0;i<e;i++)for(r=0,o[i]=Array(t);r<t;r++)o[i][r]=n(i,r);return o},l.zeros=function(e,t){return a(t)||(t=e),l.create(e,t,u)},l.ones=function(e,t){return a(t)||(t=e),l.create(e,t,d)},l.rand=function(e,t){return a(t)||(t=e),l.create(e,t,l._random_fn)},l.identity=function(e,t){return a(t)||(t=e),l.create(e,t,c)},l.symmetric=function(e){var t,n,i=e.length;if(e.length!==e[0].length)return!1;for(t=0;t<i;t++)for(n=0;n<i;n++)if(e[n][t]!==e[t][n])return!1;return!0},l.clear=function(e){return l.alter(e,u)},l.seq=function(e,t,n,i){s(i)||(i=!1);var o,a=[],l=r(e,t),u=(t*l-e*l)/((n-1)*l),d=e;for(o=0;d<=t&&o<n;d=(e*l+u*l*++o)/l)a.push(i?i(d,o):d);return a},l.arange=function(e,t,n){var i,r=[];if(n=n||1,void 0===t&&(t=e,e=0),e===t||0===n||e<t&&n<0||e>t&&n>0)return[];if(n>0)for(i=e;i<t;i+=n)r.push(i);else for(i=e;i>t;i+=n)r.push(i);return r},l.slice=function(){function e(e,t,n,i){var r,o=[],s=e.length;if(void 0===t&&void 0===n&&void 0===i)return l.copy(e);if(t=t||0,n=n||e.length,i=i||1,(t=t>=0?t:s+t)===(n=n>=0?n:s+n)||0===i||t<n&&i<0||t>n&&i>0)return[];if(i>0)for(r=t;r<n;r+=i)o.push(e[r]);else for(r=t;r>n;r+=i)o.push(e[r]);return o}return function(t,n){if(a((n=n||{}).row)){var i,r;if(a(n.col))return t[n.row][n.col];return e(l.rowa(t,n.row),(i=n.col||{}).start,i.end,i.step)}return a(n.col)?e(l.cola(t,n.col),(r=n.row||{}).start,r.end,r.step):(r=n.row||{},i=n.col||{},e(t,r.start,r.end,r.step).map(function(t){return e(t,i.start,i.end,i.step)}))}}(),l.sliceAssign=function(t,n,i){var r,o;if(a(n.row)){if(a(n.col))return t[n.row][n.col]=i;n.col=n.col||{},n.col.start=n.col.start||0,n.col.end=n.col.end||t[0].length,n.col.step=n.col.step||1,r=l.arange(n.col.start,e.min(t.length,n.col.end),n.col.step);var s=n.row;return r.forEach(function(e,n){t[s][e]=i[n]}),t}if(a(n.col)){n.row=n.row||{},n.row.start=n.row.start||0,n.row.end=n.row.end||t.length,n.row.step=n.row.step||1,o=l.arange(n.row.start,e.min(t[0].length,n.row.end),n.row.step);var u=n.col;return o.forEach(function(e,n){t[e][u]=i[n]}),t}return void 0===i[0].length&&(i=[i]),n.row.start=n.row.start||0,n.row.end=n.row.end||t.length,n.row.step=n.row.step||1,n.col.start=n.col.start||0,n.col.end=n.col.end||t[0].length,n.col.step=n.col.step||1,o=l.arange(n.row.start,e.min(t.length,n.row.end),n.row.step),r=l.arange(n.col.start,e.min(t[0].length,n.col.end),n.col.step),o.forEach(function(e,n){r.forEach(function(r,o){t[e][r]=i[n][o]})}),t},l.diagonal=function(e){var t=l.zeros(e.length,e.length);return e.forEach(function(e,n){t[n][n]=e}),t},l.copy=function(e){return e.map(function(e){return a(e)?e:e.map(function(e){return e})})};var h=l.prototype;h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?n.call(this):n.call(this)[0]},h.map=function(e,t){return l(l.map(this,e,t))},h.cumreduce=function(e,t){return l(l.cumreduce(this,e,t))},h.alter=function(e){return l.alter(this,e),this};for(var p="transpose clear symmetric rows cols dimensions diag antidiag".split(" "),f=0;f<p.length;f++)!function(e){h[e]=function(t){var n,i=this;return t?(setTimeout(function(){t.call(i,h[e].call(i))}),this):o(n=l[e](this))?l(n):n}}(p[f]);for(var m="row col".split(" "),g=0;g<m.length;g++)!function(e){h[e]=function(t,n){var i=this;return n?(setTimeout(function(){n.call(i,h[e].call(i,t))}),this):l(l[e](this,t))}}(m[g]);for(var v="create zeros ones rand identity".split(" "),b=0;b<v.length;b++)!function(e){h[e]=function(){return l(l[e].apply(null,arguments))}}(v[b]);return l}(Math);!function(e,t){var n=e.utils.isFunction;function i(e,t){return e-t}function r(e,n,i){return t.max(n,t.min(e,i))}e.sum=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.sumsqrd=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n]*e[n];return t},e.sumsqerr=function(t){for(var n,i=e.mean(t),r=0,o=t.length;--o>=0;)r+=(n=t[o]-i)*n;return r},e.sumrow=function(e){for(var t=0,n=e.length;--n>=0;)t+=e[n];return t},e.product=function(e){for(var t=1,n=e.length;--n>=0;)t*=e[n];return t},e.min=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]<t&&(t=e[n]);return t},e.max=function(e){for(var t=e[0],n=0;++n<e.length;)e[n]>t&&(t=e[n]);return t},e.unique=function(e){for(var t={},n=[],i=0;i<e.length;i++)t[e[i]]||(t[e[i]]=!0,n.push(e[i]));return n},e.mean=function(t){return e.sum(t)/t.length},e.meansqerr=function(t){return e.sumsqerr(t)/t.length},e.geomean=function(n){var i=n.map(t.log),r=e.mean(i);return t.exp(r)},e.median=function(e){var t=e.length,n=e.slice().sort(i);return 1&t?n[t/2|0]:(n[t/2-1]+n[t/2])/2},e.cumsum=function(t){return e.cumreduce(t,function(e,t){return e+t})},e.cumprod=function(t){return e.cumreduce(t,function(e,t){return e*t})},e.diff=function(e){var t,n=[],i=e.length;for(t=1;t<i;t++)n.push(e[t]-e[t-1]);return n},e.rank=function(e){var t,n=[],r={};for(t=0;t<e.length;t++){var o=e[t];r[o]?r[o]++:(r[o]=1,n.push(o))}var s=n.sort(i),a={},l=1;for(t=0;t<s.length;t++){var o=s[t],u=r[o],d=(l+(l+u-1))/2;a[o]=d,l+=u}return e.map(function(e){return a[e]})},e.mode=function(e){var t,n=e.length,r=e.slice().sort(i),o=1,s=0,a=0,l=[];for(t=0;t<n;t++)r[t]===r[t+1]?o++:(o>s?(l=[r[t]],s=o,a=0):o===s&&(l.push(r[t]),a++),o=1);return 0===a?l[0]:l},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,n){return e.sumsqerr(t)/(t.length-!!n)},e.pooledvariance=function(t){return t.reduce(function(t,n){return t+e.sumsqerr(n)},0)/(t.reduce(function(e,t){return e+t.length},0)-t.length)},e.deviation=function(t){for(var n=e.mean(t),i=t.length,r=Array(i),o=0;o<i;o++)r[o]=t[o]-n;return r},e.stdev=function(n,i){return t.sqrt(e.variance(n,i))},e.pooledstdev=function(n){return t.sqrt(e.pooledvariance(n))},e.meandev=function(n){for(var i=e.mean(n),r=[],o=n.length-1;o>=0;o--)r.push(t.abs(n[o]-i));return e.mean(r)},e.meddev=function(n){for(var i=e.median(n),r=[],o=n.length-1;o>=0;o--)r.push(t.abs(n[o]-i));return e.median(r)},e.coeffvar=function(t){return e.stdev(t)/e.mean(t)},e.quartiles=function(e){var n=e.length,r=e.slice().sort(i);return[r[t.round(n/4)-1],r[t.round(n/2)-1],r[t.round(3*n/4)-1]]},e.quantiles=function(e,n,o,s){var a,l,u,d,c,h,p=e.slice().sort(i),f=[n.length],m=e.length;for(void 0===o&&(o=3/8),void 0===s&&(s=3/8),a=0;a<n.length;a++)u=o+(l=n[a])*(1-o-s),d=m*l+u,c=t.floor(r(d,1,m-1)),h=r(d-c,0,1),f[a]=(1-h)*p[c-1]+h*p[c];return f},e.percentile=function(e,t,n){var r=e.slice().sort(i),o=t*(r.length+(n?1:-1))+ +!n,s=parseInt(o);return s+1<r.length?r[s-1]+(o-s)*(r[s]-r[s-1]):r[s-1]},e.percentileOfScore=function(e,t,n){var i,r,o=0,s=e.length,a=!1;for("strict"===n&&(a=!0),r=0;r<s;r++)i=e[r],(a&&i<t||!a&&i<=t)&&o++;return o/s},e.histogram=function(n,i){i=i||4;var r,o=e.min(n),s=(e.max(n)-o)/i,a=n.length,l=[];for(r=0;r<i;r++)l[r]=0;for(r=0;r<a;r++)l[t.min(t.floor((n[r]-o)/s),i-1)]+=1;return l},e.covariance=function(t,n){var i,r=e.mean(t),o=e.mean(n),s=t.length,a=Array(s);for(i=0;i<s;i++)a[i]=(t[i]-r)*(n[i]-o);return e.sum(a)/(s-1)},e.corrcoeff=function(t,n){return e.covariance(t,n)/e.stdev(t,1)/e.stdev(n,1)},e.spearmancoeff=function(t,n){return t=e.rank(t),n=e.rank(n),e.corrcoeff(t,n)},e.stanMoment=function(n,i){for(var r=e.mean(n),o=e.stdev(n),s=n.length,a=0,l=0;l<s;l++)a+=t.pow((n[l]-r)/o,i);return a/n.length},e.skewness=function(t){return e.stanMoment(t,3)},e.kurtosis=function(t){return e.stanMoment(t,4)-3};for(var o=e.prototype,s="cumsum cumprod".split(" "),a=0;a<s.length;a++)!function(t){o[t]=function(i,r){var s=[],a=0,l=this;if(n(i)&&(r=i,i=!1),r)return setTimeout(function(){r.call(l,o[t].call(l,i))}),this;if(this.length>1){for(l=!0===i?this:this.transpose();a<l.length;a++)s[a]=e[t](l[a]);return s}return e[t](this[0],i)}}(s[a]);for(var l="sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" "),u=0;u<l.length;u++)!function(t){o[t]=function(i,r){var s=[],a=0,l=this;if(n(i)&&(r=i,i=!1),r)return setTimeout(function(){r.call(l,o[t].call(l,i))}),this;if(this.length>1){for("sumrow"!==t&&(l=!0===i?this:this.transpose());a<l.length;a++)s[a]=e[t](l[a]);return!0===i?e[t](e.utils.toVector(s)):s}return e[t](this[0],i)}}(l[u]);for(var d="quantiles percentileOfScore".split(" "),c=0;c<d.length;c++)!function(t){o[t]=function(){var i,r=[],s=0,a=this,l=Array.prototype.slice.call(arguments);if(n(l[l.length-1])){i=l[l.length-1];var u=l.slice(0,l.length-1);return setTimeout(function(){i.call(a,o[t].apply(a,u))}),this}i=void 0;var d=function(n){return e[t].apply(a,[n].concat(l))};if(this.length>1){for(a=a.transpose();s<a.length;s++)r[s]=d(a[s]);return r}return d(this[0])}}(d[c])}(e,Math);var t=Math;e.gammaln=function(e){var n,i,r=0,o=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],s=1.000000000190015;for(i=(n=e)+5.5,i-=(e+.5)*t.log(i);r<6;r++)s+=o[r]/++n;return t.log(2.5066282746310007*s/e)-i},e.loggam=function(e){var n,i,r,o,s,a,l,u=[.08333333333333333,-.002777777777777778,7936507936507937e-19,-5952380952380952e-19,8417508417508418e-19,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(n=e,l=0,1==e||2==e)return 0;for(e<=7&&(l=t.floor(7-e),n=e+l),i=1/(n*n),r=2*t.PI,s=u[9],a=8;a>=0;a--)s*=i,s+=u[a];if(o=s/n+.5*t.log(r)+(n-.5)*t.log(n)-n,e<=7)for(a=1;a<=l;a++)o-=t.log(n-1),n-=1;return o},e.gammafn=function(e){var n,i,r,o,s=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],l=!1,u=0,d=0,c=0,h=e;if(e>171.6243769536076)return 1/0;if(h<=0){if(!(o=h%1+36e-17))return 1/0;l=(1&h?-1:1)*t.PI/t.sin(t.PI*o),h=1-h}for(n=0,r=h,i=h<1?h++:(h-=u=(0|h)-1)-1;n<8;++n)c=(c+s[n])*i,d=d*i+a[n];if(o=c/d+1,r<h)o/=r;else if(r>h)for(n=0;n<u;++n)o*=h,h++;return l&&(o=l/o),o},e.gammap=function(t,n){return e.lowRegGamma(t,n)*e.gammafn(t)},e.lowRegGamma=function(n,i){var r,o=e.gammaln(n),s=n,a=1/n,l=a,u=i+1-n,d=1/1e-30,c=1/u,h=c,p=1,f=-~(8.5*t.log(n>=1?n:1/n)+.4*n+17);if(i<0||n<=0)return NaN;if(i<n+1){for(;p<=f;p++)a+=l*=i/++s;return a*t.exp(-i+n*t.log(i)-o)}for(;p<=f;p++)u+=2,h*=(c=1/(c=(r=-p*(p-n))*c+u))*(d=u+r/d);return 1-h*t.exp(-i+n*t.log(i)-o)},e.factorialln=function(t){return t<0?NaN:e.gammaln(t+1)},e.factorial=function(t){return t<0?NaN:e.gammafn(t+1)},e.combination=function(n,i){return n>170||i>170?t.exp(e.combinationln(n,i)):e.factorial(n)/e.factorial(i)/e.factorial(n-i)},e.combinationln=function(t,n){return e.factorialln(t)-e.factorialln(n)-e.factorialln(t-n)},e.permutation=function(t,n){return e.factorial(t)/e.factorial(t-n)},e.betafn=function(n,i){if(!(n<=0)&&!(i<=0))return n+i>170?t.exp(e.betaln(n,i)):e.gammafn(n)*e.gammafn(i)/e.gammafn(n+i)},e.betaln=function(t,n){return e.gammaln(t)+e.gammaln(n)-e.gammaln(t+n)},e.betacf=function(e,n,i){var r,o,s,a,l=1,u=n+i,d=n+1,c=n-1,h=1,p=1-u*e/d;for(1e-30>t.abs(p)&&(p=1e-30),a=p=1/p;l<=100&&(r=2*l,p=1+(o=l*(i-l)*e/((c+r)*(n+r)))*p,1e-30>t.abs(p)&&(p=1e-30),h=1+o/h,1e-30>t.abs(h)&&(h=1e-30),a*=(p=1/p)*h,p=1+(o=-(n+l)*(u+l)*e/((n+r)*(d+r)))*p,1e-30>t.abs(p)&&(p=1e-30),h=1+o/h,1e-30>t.abs(h)&&(h=1e-30),a*=s=(p=1/p)*h,!(3e-7>t.abs(s-1)));l++);return a},e.gammapinv=function(n,i){var r,o,s,a,l,u=0,d=i-1,c=e.gammaln(i);if(n>=1)return t.max(100,i+100*t.sqrt(i));if(n<=0)return 0;for(i>1?(a=t.log(d),l=t.exp(d*(a-1)-c),r=(2.30753+.27061*(o=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+o*(.99229+.04481*o))-o,n<.5&&(r=-r),r=t.max(.001,i*t.pow(1-1/(9*i)-r/(3*t.sqrt(i)),3))):r=n<(o=1-i*(.253+.12*i))?t.pow(n/o,1/i):1-t.log(1-(n-o)/(1-o));u<12;u++){if(r<=0)return 0;if(s=(e.lowRegGamma(i,r)-n)/(o=i>1?l*t.exp(-(r-d)+d*(t.log(r)-a)):t.exp(-r+d*t.log(r)-c)),(r-=o=s/(1-.5*t.min(1,s*((i-1)/r-1))))<=0&&(r=.5*(r+o)),t.abs(o)<1e-8*r)break}return r},e.erf=function(e){var n,i,r,o,s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-946595344482036e-18,366839497852761e-18,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=s.length-1,l=!1,u=0,d=0;for(e<0&&(e=-e,l=!0),i=4*(n=2/(2+e))-2;a>0;a--)r=u,u=i*u-d+s[a],d=r;return o=n*t.exp(-e*e+.5*(s[0]+i*u)-d),l?o-1:1-o},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(n){var i,r,o,s,a=0;if(n>=2)return -100;if(n<=0)return 100;for(s=n<1?n:2-n,i=-.70711*((2.30753+.27061*(o=t.sqrt(-2*t.log(s/2))))/(1+o*(.99229+.04481*o))-o);a<2;a++)r=e.erfc(i)-s,i+=r/(1.1283791670955126*t.exp(-i*i)-i*r);return n<1?i:-i},e.ibetainv=function(n,i,r){var o,s,a,l,u,d,c,h,p,f=i-1,m=r-1,g=0;if(n<=0)return 0;if(n>=1)return 1;for(i>=1&&r>=1?(u=(2.30753+.27061*(a=t.sqrt(-2*t.log(n<.5?n:1-n))))/(1+a*(.99229+.04481*a))-a,n<.5&&(u=-u),d=(u*u-3)/6,c=2/(1/(2*i-1)+1/(2*r-1)),h=u*t.sqrt(d+c)/c-(1/(2*r-1)-1/(2*i-1))*(d+5/6-2/(3*c)),u=i/(i+r*t.exp(2*h))):(o=t.log(i/(i+r)),s=t.log(r/(i+r)),h=(a=t.exp(i*o)/i)+(l=t.exp(r*s)/r),u=n<a/h?t.pow(i*h*n,1/i):1-t.pow(r*h*(1-n),1/r)),p=-e.gammaln(i)-e.gammaln(r)+e.gammaln(i+r);g<10&&0!==u&&1!==u&&(l=(e.ibeta(u,i,r)-n)/(a=t.exp(f*t.log(u)+m*t.log(1-u)+p)),(u-=a=l/(1-.5*t.min(1,l*(f/u-m/(1-u)))))<=0&&(u=.5*(u+a)),u>=1&&(u=.5*(u+a+1)),!(t.abs(a)<1e-8*u)||!(g>0));g++);return u},e.ibeta=function(n,i,r){var o=0===n||1===n?0:t.exp(e.gammaln(i+r)-e.gammaln(i)-e.gammaln(r)+i*t.log(n)+r*t.log(1-n));return!(n<0)&&!(n>1)&&(n<(i+1)/(i+r+2)?o*e.betacf(n,i,r)/i:1-o*e.betacf(1-n,r,i)/r)},e.randn=function(n,i){var r,o,s,a,l;if(i||(i=n),n)return e.create(n,i,function(){return e.randn()});do r=e._random_fn(),o=1.7156*(e._random_fn()-.5),l=(s=r-.449871)*s+(a=t.abs(o)+.386595)*(.196*a-.25472*s);while(l>.27597&&(l>.27846||o*o>-4*t.log(r)*r*r));return o/r},e.randg=function(n,i,r){var o,s,a,l,u,d,c=n;if(r||(r=i),n||(n=1),i)return(d=e.zeros(i,r)).alter(function(){return e.randg(n)}),d;n<1&&(n+=1),o=n-1/3,s=1/t.sqrt(9*o);do{do l=1+s*(u=e.randn());while(l<=0);l=l*l*l,a=e._random_fn()}while(a>1-.331*t.pow(u,4)&&t.log(a)>.5*u*u+o*(1-l+t.log(l)));if(n==c)return o*l;do a=e._random_fn();while(0===a);return t.pow(a,1/c)*o*l};for(var n="gammaln gammafn factorial factorialln".split(" "),i=0;i<n.length;i++)!function(t){e.fn[t]=function(){return e(e.map(this,function(n){return e[t](n)}))}}(n[i]);for(var r="randn".split(" "),o=0;o<r.length;o++)!function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}}(r[o]);for(var s=Math,a="beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" "),l=0;l<a.length;l++)!function(t){e[t]=function e(t,n,i){return this instanceof e?(this._a=t,this._b=n,this._c=i,this):new e(t,n,i)},e.fn[t]=function(n,i,r){var o=e[t](n,i,r);return o.data=this,o},e[t].prototype.sample=function(n){var i=this._a,r=this._b,o=this._c;return n?e.alter(n,function(){return e[t].sample(i,r,o)}):e[t].sample(i,r,o)};for(var n="pdf cdf inv".split(" "),i=0;i<n.length;i++)!function(n){e[t].prototype[n]=function(i){var r=this._a,o=this._b,s=this._c;return(i||0===i||(i=this.data),"number"!=typeof i)?e.fn.map.call(i,function(i){return e[t][n](i,r,o,s)}):e[t][n](i,r,o,s)}}(n[i]);for(var r="mean median mode variance".split(" "),o=0;o<r.length;o++)!function(n){e[t].prototype[n]=function(){return e[t][n](this._a,this._b,this._c)}}(r[o])}(a[l]);function u(e,t,n,i){for(var r,o=0,a=1,l=1,u=1,d=0,c=0;s.abs((l-c)/l)>i;)c=l,o=l+(r=-(t+d)*(t+n+d)*e/(t+2*d)/(t+2*d+1))*o,a=u+r*a,d+=1,l=o+(r=d*(n-d)*e/(t+2*d-1)/(t+2*d))*l,o/=u=a+r*u,a/=u,l/=u,u=1;return l/t}function d(t,n,i){var r=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],o=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*t;if(a>=8)return 1;var l=2*e.normal.cdf(a,0,1,1,0)-1;l=l>=s.exp(-50/i)?s.pow(l,i):0;for(var u=a,d=(8-a)/(y=t>3?2:3),c=u+d,h=0,p=i-1,f=1;f<=y;f++){for(var m=0,g=.5*(c+u),v=.5*(c-u),b=1;b<=12;b++){var y,_,w=g+v*(6<b?r[(_=12-b+1)-1]:-r[(_=b)-1]),x=w*w;if(x>60)break;var k=.5*(2*e.normal.cdf(w,0,1,1,0))-.5*(2*e.normal.cdf(w,t,1,1,0));k>=s.exp(-30/p)&&(m+=k=o[_-1]*s.exp(-(.5*x))*s.pow(k,p))}m*=2*v*i/s.sqrt(2*s.PI),h+=m,u=c,c+=d}return(l+=h)<=s.exp(-30/n)?0:(l=s.pow(l,n))>=1?1:l}e.extend(e.beta,{pdf:function(t,n,i){return t>1||t<0?0:1==n&&1==i?1:n<512&&i<512?s.pow(t,n-1)*s.pow(1-t,i-1)/e.betafn(n,i):s.exp((n-1)*s.log(t)+(i-1)*s.log(1-t)-e.betaln(n,i))},cdf:function(t,n,i){return t>1||t<0?(t>1)*1:e.ibeta(t,n,i)},inv:function(t,n,i){return e.ibetainv(t,n,i)},mean:function(e,t){return e/(e+t)},median:function(t,n){return e.ibetainv(.5,t,n)},mode:function(e,t){return(e-1)/(e+t-2)},sample:function(t,n){var i=e.randg(t);return i/(i+e.randg(n))},variance:function(e,t){return e*t/(s.pow(e+t,2)*(e+t+1))}}),e.extend(e.centralF,{pdf:function(t,n,i){var r;return t<0?0:n<=2?0===t&&n<2?1/0:0===t&&2===n?1:1/e.betafn(n/2,i/2)*s.pow(n/i,n/2)*s.pow(t,n/2-1)*s.pow(1+n/i*t,-(n+i)/2):(r=i/(i+t*n),n*r/2*e.binomial.pdf((n-2)/2,(n+i-2)/2,n*t/(i+t*n)))},cdf:function(t,n,i){return t<0?0:e.ibeta(n*t/(n*t+i),n/2,i/2)},inv:function(t,n,i){return i/(n*(1/e.ibetainv(t,n/2,i/2)-1))},mean:function(e,t){return t>2?t/(t-2):void 0},mode:function(e,t){return e>2?t*(e-2)/(e*(t+2)):void 0},sample:function(t,n){return 2*e.randg(t/2)/t/(2*e.randg(n/2)/n)},variance:function(e,t){if(!(t<=4))return 2*t*t*(e+t-2)/(e*(t-2)*(t-2)*(t-4))}}),e.extend(e.cauchy,{pdf:function(e,t,n){return n<0?0:n/(s.pow(e-t,2)+s.pow(n,2))/s.PI},cdf:function(e,t,n){return s.atan((e-t)/n)/s.PI+.5},inv:function(e,t,n){return t+n*s.tan(s.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(t,n){return e.randn()*s.sqrt(1/(2*e.randg(.5)))*n+t}}),e.extend(e.chisquare,{pdf:function(t,n){return t<0?0:0===t&&2===n?.5:s.exp((n/2-1)*s.log(t)-t/2-n/2*s.log(2)-e.gammaln(n/2))},cdf:function(t,n){return t<0?0:e.lowRegGamma(n/2,t/2)},inv:function(t,n){return 2*e.gammapinv(t,.5*n)},mean:function(e){return e},median:function(e){return e*s.pow(1-2/(9*e),3)},mode:function(e){return e-2>0?e-2:0},sample:function(t){return 2*e.randg(t/2)},variance:function(e){return 2*e}}),e.extend(e.exponential,{pdf:function(e,t){return e<0?0:t*s.exp(-t*e)},cdf:function(e,t){return e<0?0:1-s.exp(-t*e)},inv:function(e,t){return-s.log(1-e)/t},mean:function(e){return 1/e},median:function(e){return 1/e*s.log(2)},mode:function(){return 0},sample:function(t){return -1/t*s.log(e._random_fn())},variance:function(e){return s.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(t,n,i){return t<0?0:0===t&&1===n?1/i:s.exp((n-1)*s.log(t)-t/i-e.gammaln(n)-n*s.log(i))},cdf:function(t,n,i){return t<0?0:e.lowRegGamma(n,t/i)},inv:function(t,n,i){return e.gammapinv(t,n)*i},mean:function(e,t){return e*t},mode:function(e,t){if(e>1)return(e-1)*t},sample:function(t,n){return e.randg(t)*n},variance:function(e,t){return e*t*t}}),e.extend(e.invgamma,{pdf:function(t,n,i){return t<=0?0:s.exp(-(n+1)*s.log(t)-i/t-e.gammaln(n)+n*s.log(i))},cdf:function(t,n,i){return t<=0?0:1-e.lowRegGamma(n,i/t)},inv:function(t,n,i){return i/e.gammapinv(1-t,n)},mean:function(e,t){return e>1?t/(e-1):void 0},mode:function(e,t){return t/(e+1)},sample:function(t,n){return n/e.randg(t)},variance:function(e,t){if(!(e<=2))return t*t/((e-1)*(e-1)*(e-2))}}),e.extend(e.kumaraswamy,{pdf:function(e,t,n){return 0===e&&1===t?n:1===e&&1===n?t:s.exp(s.log(t)+s.log(n)+(t-1)*s.log(e)+(n-1)*s.log(1-s.pow(e,t)))},cdf:function(e,t,n){return e<0?0:e>1?1:1-s.pow(1-s.pow(e,t),n)},inv:function(e,t,n){return s.pow(1-s.pow(1-e,1/n),1/t)},mean:function(t,n){return n*e.gammafn(1+1/t)*e.gammafn(n)/e.gammafn(1+1/t+n)},median:function(e,t){return s.pow(1-s.pow(2,-1/t),1/e)},mode:function(e,t){if(e>=1&&t>=1&&1!==e&&1!==t)return s.pow((e-1)/(e*t-1),1/e)},variance:function(){throw Error("variance not yet implemented")}}),e.extend(e.lognormal,{pdf:function(e,t,n){return e<=0?0:s.exp(-s.log(e)-.5*s.log(2*s.PI)-s.log(n)-s.pow(s.log(e)-t,2)/(2*n*n))},cdf:function(t,n,i){return t<0?0:.5+.5*e.erf((s.log(t)-n)/s.sqrt(2*i*i))},inv:function(t,n,i){return s.exp(-1.4142135623730951*i*e.erfcinv(2*t)+n)},mean:function(e,t){return s.exp(e+t*t/2)},median:function(e){return s.exp(e)},mode:function(e,t){return s.exp(e-t*t)},sample:function(t,n){return s.exp(e.randn()*n+t)},variance:function(e,t){return(s.exp(t*t)-1)*s.exp(2*e+t*t)}}),e.extend(e.noncentralt,{pdf:function(t,n,i){return 1e-14>s.abs(i)?e.studentt.pdf(t,n):1e-14>s.abs(t)?s.exp(e.gammaln((n+1)/2)-i*i/2-.5*s.log(s.PI*n)-e.gammaln(n/2)):n/t*(e.noncentralt.cdf(t*s.sqrt(1+2/n),n+2,i)-e.noncentralt.cdf(t,n,i))},cdf:function(t,n,i){if(1e-14>s.abs(i))return e.studentt.cdf(t,n);var r=!1;t<0&&(r=!0,i=-i);for(var o=e.normal.cdf(-i,0,1),a=1e-14+1,l=1e-14+1,u=t*t/(t*t+n),d=0,c=s.exp(-i*i/2),h=s.exp(-i*i/2-.5*s.log(2)-e.gammaln(1.5))*i;d<200||l>1e-14||a>1e-14;)l=a,d>0&&(c*=i*i/(2*d),h*=i*i/(2*(d+.5))),o+=.5*(a=c*e.beta.cdf(u,d+.5,n/2)+h*e.beta.cdf(u,d+1,n/2)),d++;return r?1-o:o}}),e.extend(e.normal,{pdf:function(e,t,n){return s.exp(-.5*s.log(2*s.PI)-s.log(n)-s.pow(e-t,2)/(2*n*n))},cdf:function(t,n,i){return .5*(1+e.erf((t-n)/s.sqrt(2*i*i)))},inv:function(t,n,i){return -1.4142135623730951*i*e.erfcinv(2*t)+n},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},sample:function(t,n){return e.randn()*n+t},variance:function(e,t){return t*t}}),e.extend(e.pareto,{pdf:function(e,t,n){return e<t?0:n*s.pow(t,n)/s.pow(e,n+1)},cdf:function(e,t,n){return e<t?0:1-s.pow(t/e,n)},inv:function(e,t,n){return t/s.pow(1-e,1/n)},mean:function(e,t){if(!(t<=1))return t*s.pow(e,t)/(t-1)},median:function(e,t){return e*(t*s.SQRT2)},mode:function(e){return e},variance:function(e,t){if(!(t<=2))return e*e*t/(s.pow(t-1,2)*(t-2))}}),e.extend(e.studentt,{pdf:function(t,n){return n=n>1e100?1e100:n,1/(s.sqrt(n)*e.betafn(.5,n/2))*s.pow(1+t*t/n,-((n+1)/2))},cdf:function(t,n){var i=n/2;return e.ibeta((t+s.sqrt(t*t+n))/(2*s.sqrt(t*t+n)),i,i)},inv:function(t,n){var i=e.ibetainv(2*s.min(t,1-t),.5*n,.5);return i=s.sqrt(n*(1-i)/i),t>.5?i:-i},mean:function(e){return e>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(t){return e.randn()*s.sqrt(t/(2*e.randg(t/2)))},variance:function(e){return e>2?e/(e-2):e>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(e,t,n){return e<0||t<0||n<0?0:n/t*s.pow(e/t,n-1)*s.exp(-s.pow(e/t,n))},cdf:function(e,t,n){return e<0?0:1-s.exp(-s.pow(e/t,n))},inv:function(e,t,n){return t*s.pow(-s.log(1-e),1/n)},mean:function(t,n){return t*e.gammafn(1+1/n)},median:function(e,t){return e*s.pow(s.log(2),1/t)},mode:function(e,t){return t<=1?0:e*s.pow((t-1)/t,1/t)},sample:function(t,n){return t*s.pow(-s.log(e._random_fn()),1/n)},variance:function(t,n){return t*t*e.gammafn(1+2/n)-s.pow(e.weibull.mean(t,n),2)}}),e.extend(e.uniform,{pdf:function(e,t,n){return e<t||e>n?0:1/(n-t)},cdf:function(e,t,n){return e<t?0:e<n?(e-t)/(n-t):1},inv:function(e,t,n){return t+e*(n-t)},mean:function(e,t){return .5*(e+t)},median:function(t,n){return e.mean(t,n)},mode:function(){throw Error("mode is not yet implemented")},sample:function(t,n){return t/2+n/2+(n/2-t/2)*(2*e._random_fn()-1)},variance:function(e,t){return s.pow(t-e,2)/12}}),e.extend(e.binomial,{pdf:function(t,n,i){return 0===i||1===i?+(n*i===t):e.combination(n,t)*s.pow(i,t)*s.pow(1-i,n-t)},cdf:function(t,n,i){if(t<0)return 0;if(t>=n)return 1;if(i<0||i>1||n<=0)return NaN;var r,o=(t=s.floor(t))+1,a=n-t,l=o+a,d=s.exp(e.gammaln(l)-e.gammaln(a)-e.gammaln(o)+o*s.log(i)+a*s.log(1-i));return r=i<(o+1)/(l+2)?d*u(i,o,a,1e-10):1-d*u(1-i,a,o,1e-10),s.round(1e10*(1-r))/1e10}}),e.extend(e.negbin,{pdf:function(t,n,i){return t===t>>>0&&(t<0?0:e.combination(t+n-1,n-1)*s.pow(1-i,t)*s.pow(i,n))},cdf:function(t,n,i){var r=0,o=0;if(t<0)return 0;for(;o<=t;o++)r+=e.negbin.pdf(o,n,i);return r}}),e.extend(e.hypgeom,{pdf:function(t,n,i,r){if(t!=t|0)return!1;if(t<0||t<i-(n-r))return 0;if(t>r||t>i)return 0;if(2*i>n)if(2*r>n)return e.hypgeom.pdf(n-i-r+t,n,n-i,n-r);else return e.hypgeom.pdf(r-t,n,n-i,r);if(2*r>n)return e.hypgeom.pdf(i-t,n,i,n-r);if(i<r)return e.hypgeom.pdf(t,n,r,i);for(var o=1,a=0,l=0;l<t;l++){for(;o>1&&a<r;)o*=1-i/(n-a),a++;o*=(r-l)*(i-l)/((l+1)*(n-i-r+l+1))}for(;a<r;a++)o*=1-i/(n-a);return s.min(1,s.max(0,o))},cdf:function(t,n,i,r){if(t<0||t<i-(n-r))return 0;if(t>=r||t>=i)return 1;if(2*i>n)if(2*r>n)return e.hypgeom.cdf(n-i-r+t,n,n-i,n-r);else return 1-e.hypgeom.cdf(r-t-1,n,n-i,r);if(2*r>n)return 1-e.hypgeom.cdf(i-t-1,n,i,n-r);if(i<r)return e.hypgeom.cdf(t,n,r,i);for(var o=1,a=1,l=0,u=0;u<t;u++){for(;o>1&&l<r;){var d=1-i/(n-l);a*=d,o*=d,l++}a*=(r-u)*(i-u)/((u+1)*(n-i-r+u+1)),o+=a}for(;l<r;l++)o*=1-i/(n-l);return s.min(1,s.max(0,o))}}),e.extend(e.poisson,{pdf:function(t,n){return n<0||t%1!=0||t<0?0:s.pow(n,t)*s.exp(-n)/e.factorial(t)},cdf:function(t,n){var i=[],r=0;if(t<0)return 0;for(;r<=t;r++)i.push(e.poisson.pdf(r,n));return e.sum(i)},mean:function(e){return e},variance:function(e){return e},sampleSmall:function(t){var n=1,i=0,r=s.exp(-t);do i++,n*=e._random_fn();while(n>r);return i-1},sampleLarge:function(t){var n,i,r,o,a,l,u,d,c,h;for(o=s.sqrt(t),a=s.log(t),l=-.059+.02483*(u=.931+2.53*o),d=1.1239+1.1328/(u-3.4),c=.9277-3.6224/(u-2);;){if(i=s.random()-.5,r=s.random(),h=.5-s.abs(i),n=s.floor((2*l/h+u)*i+t+.43),h>=.07&&r<=c)return n;if(!(n<0)&&(!(h<.013)||!(r>h))&&s.log(r)+s.log(d)-s.log(l/(h*h)+u)<=-t+n*a-e.loggam(n+1))return n}},sample:function(e){return e<10?this.sampleSmall(e):this.sampleLarge(e)}}),e.extend(e.triangular,{pdf:function(e,t,n,i){return n<=t||i<t||i>n?NaN:e<t||e>n?0:e<i?2*(e-t)/((n-t)*(i-t)):e===i?2/(n-t):2*(n-e)/((n-t)*(n-i))},cdf:function(e,t,n,i){return n<=t||i<t||i>n?NaN:e<=t?0:e>=n?1:e<=i?s.pow(e-t,2)/((n-t)*(i-t)):1-s.pow(n-e,2)/((n-t)*(n-i))},inv:function(e,t,n,i){return n<=t||i<t||i>n?NaN:e<=(i-t)/(n-t)?t+(n-t)*s.sqrt((i-t)/(n-t)*e):t+(n-t)*(1-s.sqrt((1-e)*(1-(i-t)/(n-t))))},mean:function(e,t,n){return(e+t+n)/3},median:function(e,t,n){return n<=(e+t)/2?t-s.sqrt((t-e)*(t-n))/s.sqrt(2):n>(e+t)/2?e+s.sqrt((t-e)*(n-e))/s.sqrt(2):void 0},mode:function(e,t,n){return n},sample:function(t,n,i){var r=e._random_fn();return r<(i-t)/(n-t)?t+s.sqrt(r*(n-t)*(i-t)):n-s.sqrt((1-r)*(n-t)*(n-i))},variance:function(e,t,n){return(e*e+t*t+n*n-e*t-e*n-t*n)/18}}),e.extend(e.arcsine,{pdf:function(e,t,n){return n<=t?NaN:e<=t||e>=n?0:2/s.PI*s.pow(s.pow(n-t,2)-s.pow(2*e-t-n,2),-.5)},cdf:function(e,t,n){return e<t?0:e<n?2/s.PI*s.asin(s.sqrt((e-t)/(n-t))):1},inv:function(e,t,n){return t+(.5-.5*s.cos(s.PI*e))*(n-t)},mean:function(e,t){return t<=e?NaN:(e+t)/2},median:function(e,t){return t<=e?NaN:(e+t)/2},mode:function(){throw Error("mode is not yet implemented")},sample:function(t,n){return(t+n)/2+(n-t)/2*s.sin(2*s.PI*e.uniform.sample(0,1))},variance:function(e,t){return t<=e?NaN:s.pow(t-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,t,n){return n<=0?0:s.exp(-s.abs(e-t)/n)/(2*n)},cdf:function(e,t,n){return n<=0?0:e<t?.5*s.exp((e-t)/n):1-.5*s.exp(-(e-t)/n)},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},variance:function(e,t){return 2*t*t},sample:function(t,n){var i=e._random_fn()-.5;return t-n*(i/s.abs(i))*s.log(1-2*s.abs(i))}}),e.extend(e.tukey,{cdf:function(t,n,i){var r=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],o=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(t<=0)return 0;if(i<2||n<2)return NaN;if(!Number.isFinite(t))return 1;if(i>25e3)return d(t,1,n);var a=.5*i,l=a*s.log(i)-i*s.log(2)-e.gammaln(a),u=a-1,c=.25*i;f=i<=100?1:i<=800?.5:i<=5e3?.25:.125,l+=s.log(f);for(var h=0,p=1;p<=50;p++){for(var f,m,g,v=0,b=(2*p-1)*f,y=1;y<=16;y++)if(8<y?(m=y-8-1,g=l+u*s.log(b+r[m]*f)-(r[m]*f+b)*c):(m=y-1,g=l+u*s.log(b-r[m]*f)+(r[m]*f-b)*c),g>=-30){v+=d(8<y?t*s.sqrt((r[m]*f+b)*.5):t*s.sqrt((-(r[m]*f)+b)*.5),1,n)*o[m]*s.exp(g)}if(p*f>=1&&v<=1e-14)break;h+=v}if(v>1e-14)throw Error("tukey.cdf failed to converge");return h>1&&(h=1),h},inv:function(t,n,i){if(i<2||n<2||t<0||t>1)return NaN;if(0===t)return 0;if(1===t)return 1/0;var r,o,a,l,u,d,c=(a=.5-.5*t,u=(l=s.sqrt(s.log(1/(a*a))))+((((-453642210148e-16*l+-.204231210125)*l+-.342242088547)*l+-1)*l+.322232421088)/((((.0038560700634*l+.10353775285)*l+.531103462366)*l+.588581570495)*l+.099348462606),i<120&&(u+=(u*u*u+u)/i/4),d=.8832-.2368*u,i<120&&(d+=-1.214/i+1.208*u/i),u*(d*s.log(n-1)+1.4142)),h=e.tukey.cdf(c,n,i)-t;r=h>0?s.max(0,c-1):c+1;for(var p=e.tukey.cdf(r,n,i)-t,f=1;f<50;f++)if(o=r-p*(r-c)/(p-h),h=p,c=r,o<0&&(o=0,p=-t),p=e.tukey.cdf(o,n,i)-t,r=o,1e-4>s.abs(r-c))return o;throw Error("tukey.inv failed to converge")}}),function(e,t){var n,i,r=Array.prototype.push,o=e.utils.isArray;function s(t){return o(t)||t instanceof e}e.extend({add:function(t,n){return s(n)?(s(n[0])||(n=[n]),e.map(t,function(e,t,i){return e+n[t][i]})):e.map(t,function(e){return e+n})},subtract:function(t,n){return s(n)?(s(n[0])||(n=[n]),e.map(t,function(e,t,i){return e-n[t][i]||0})):e.map(t,function(e){return e-n})},divide:function(t,n){return s(n)?(s(n[0])||(n=[n]),e.multiply(t,e.inv(n))):e.map(t,function(e){return e/n})},multiply:function(t,n){var i,r,o,a,l,u,d,c;if(void 0===t.length&&void 0===n.length)return t*n;if(l=t.length,u=t[0].length,d=e.zeros(l,o=s(n)?n[0].length:u),c=0,s(n)){for(;c<o;c++)for(i=0;i<l;i++){for(r=0,a=0;r<u;r++)a+=t[i][r]*n[r][c];d[i][c]=a}return 1===l&&1===c?d[0][0]:d}return e.map(t,function(e){return e*n})},outer:function(t,n){return e.multiply(t.map(function(e){return[e]}),[n])},dot:function(t,n){s(t[0])||(t=[t]),s(n[0])||(n=[n]);for(var i,r,o=1===t[0].length&&1!==t.length?e.transpose(t):t,a=1===n[0].length&&1!==n.length?e.transpose(n):n,l=[],u=0,d=o.length,c=o[0].length;u<d;u++){for(r=0,l[u]=[],i=0;r<c;r++)i+=o[u][r]*a[u][r];l[u]=i}return 1===l.length?l[0]:l},pow:function(n,i){return e.map(n,function(e){return t.pow(e,i)})},exp:function(n){return e.map(n,function(e){return t.exp(e)})},log:function(n){return e.map(n,function(e){return t.log(e)})},abs:function(n){return e.map(n,function(e){return t.abs(e)})},norm:function(e,n){var i=0,r=0;for(isNaN(n)&&(n=2),s(e[0])&&(e=e[0]);r<e.length;r++)i+=t.pow(t.abs(e[r]),n);return t.pow(i,1/n)},angle:function(n,i){return t.acos(e.dot(n,i)/(e.norm(n)*e.norm(i)))},aug:function(e,t){var n,i=[];for(n=0;n<e.length;n++)i.push(e[n].slice());for(n=0;n<i.length;n++)r.apply(i[n],t[n]);return i},inv:function(t){for(var n,i=t.length,r=t[0].length,o=e.identity(i,r),s=e.gauss_jordan(t,o),a=[],l=0;l<i;l++)for(a[l]=[],n=r;n<s[0].length;n++)a[l][n-r]=s[l][n];return a},det:function e(t){if(2===t.length)return t[0][0]*t[1][1]-t[0][1]*t[1][0];for(var n=0,i=0;i<t.length;i++){for(var r=[],o=1;o<t.length;o++){r[o-1]=[];for(var s=0;s<t.length;s++)s<i?r[o-1][s]=t[o][s]:s>i&&(r[o-1][s-1]=t[o][s])}var a=i%2?-1:1;n+=e(r)*t[0][i]*a}return n},gauss_elimination:function(n,i){var r,o,s,a,l=0,u=0,d=n.length,c=n[0].length,h=1,p=0,f=[];for(l=0,r=(n=e.aug(n,i))[0].length;l<d;l++){for(o=n[l][l],u=l,a=l+1;a<c;a++)o<t.abs(n[a][l])&&(o=n[a][l],u=a);if(u!=l)for(a=0;a<r;a++)s=n[l][a],n[l][a]=n[u][a],n[u][a]=s;for(u=l+1;u<d;u++)for(h=n[u][l]/n[l][l],a=l;a<r;a++)n[u][a]=n[u][a]-h*n[l][a]}for(l=d-1;l>=0;l--){for(p=0,u=l+1;u<=d-1;u++)p+=f[u]*n[l][u];f[l]=(n[l][r-1]-p)/n[l][l]}return f},gauss_jordan:function(n,i){var r,o,s,a=e.aug(n,i),l=a.length,u=a[0].length,d=0;for(o=0;o<l;o++){var c=o;for(s=o+1;s<l;s++)t.abs(a[s][o])>t.abs(a[c][o])&&(c=s);var h=a[o];for(a[o]=a[c],a[c]=h,s=o+1;s<l;s++)for(d=a[s][o]/a[o][o],r=o;r<u;r++)a[s][r]-=a[o][r]*d}for(o=l-1;o>=0;o--){for(s=0,d=a[o][o];s<o;s++)for(r=u-1;r>o-1;r--)a[s][r]-=a[o][r]*a[s][o]/d;for(a[o][o]/=d,r=l;r<u;r++)a[o][r]/=d}return a},triaUpSolve:function(t,n){var i,r=t[0].length,o=e.zeros(1,r)[0],s=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),s=!0),e.arange(r-1,-1,-1).forEach(function(s){i=e.arange(s+1,r).map(function(e){return o[e]*t[s][e]}),o[s]=(n[s]-e.sum(i))/t[s][s]}),s)?o.map(function(e){return[e]}):o},triaLowSolve:function(t,n){var i,r=t[0].length,o=e.zeros(1,r)[0],s=!1;return(void 0!=n[0].length&&(n=n.map(function(e){return e[0]}),s=!0),e.arange(r).forEach(function(r){i=e.arange(r).map(function(e){return t[r][e]*o[e]}),o[r]=(n[r]-e.sum(i))/t[r][r]}),s)?o.map(function(e){return[e]}):o},lu:function(t){var n,i=t.length,r=e.identity(i),o=e.zeros(t.length,t[0].length);return e.arange(i).forEach(function(e){o[0][e]=t[0][e]}),e.arange(1,i).forEach(function(s){e.arange(s).forEach(function(i){n=e.arange(i).map(function(e){return r[s][e]*o[e][i]}),r[s][i]=(t[s][i]-e.sum(n))/o[i][i]}),e.arange(s,i).forEach(function(i){n=e.arange(s).map(function(e){return r[s][e]*o[e][i]}),o[s][i]=t[n.length][i]-e.sum(n)})}),[r,o]},cholesky:function(n){var i,r=n.length,o=e.zeros(n.length,n[0].length);return e.arange(r).forEach(function(s){i=e.arange(s).map(function(e){return t.pow(o[s][e],2)}),o[s][s]=t.sqrt(n[s][s]-e.sum(i)),e.arange(s+1,r).forEach(function(t){i=e.arange(s).map(function(e){return o[s][e]*o[t][e]}),o[t][s]=(n[s][t]-e.sum(i))/o[s][s]})}),o},gauss_jacobi:function(n,i,r,o){for(var s,a,l,u,d=0,c=0,h=n.length,p=[],f=[],m=[];d<h;d++)for(c=0,p[d]=[],f[d]=[],m[d]=[];c<h;c++)d>c?(p[d][c]=n[d][c],f[d][c]=m[d][c]=0):d<c?(f[d][c]=n[d][c],p[d][c]=m[d][c]=0):(m[d][c]=n[d][c],p[d][c]=f[d][c]=0);for(l=e.multiply(e.multiply(e.inv(m),e.add(p,f)),-1),a=e.multiply(e.inv(m),i),s=r,u=e.add(e.multiply(l,r),a),d=2;t.abs(e.norm(e.subtract(u,s)))>o;)s=u,u=e.add(e.multiply(l,s),a),d++;return u},gauss_seidel:function(n,i,r,o){for(var s,a,l,u,d,c=0,h=n.length,p=[],f=[],m=[];c<h;c++)for(s=0,p[c]=[],f[c]=[],m[c]=[];s<h;s++)c>s?(p[c][s]=n[c][s],f[c][s]=m[c][s]=0):c<s?(f[c][s]=n[c][s],p[c][s]=m[c][s]=0):(m[c][s]=n[c][s],p[c][s]=f[c][s]=0);for(u=e.multiply(e.multiply(e.inv(e.add(m,p)),f),-1),l=e.multiply(e.inv(e.add(m,p)),i),a=r,d=e.add(e.multiply(u,r),l),c=2;t.abs(e.norm(e.subtract(d,a)))>o;)a=d,d=e.add(e.multiply(u,a),l),c+=1;return d},SOR:function(n,i,r,o,s){for(var a,l,u,d,c,h=0,p=n.length,f=[],m=[],g=[];h<p;h++)for(a=0,f[h]=[],m[h]=[],g[h]=[];a<p;a++)h>a?(f[h][a]=n[h][a],m[h][a]=g[h][a]=0):h<a?(m[h][a]=n[h][a],f[h][a]=g[h][a]=0):(g[h][a]=n[h][a],f[h][a]=m[h][a]=0);for(d=e.multiply(e.inv(e.add(g,e.multiply(f,s))),e.subtract(e.multiply(g,1-s),e.multiply(m,s))),u=e.multiply(e.multiply(e.inv(e.add(g,e.multiply(f,s))),i),s),l=r,c=e.add(e.multiply(d,r),u),h=2;t.abs(e.norm(e.subtract(c,l)))>o;)l=c,c=e.add(e.multiply(d,l),u),h++;return c},householder:function(n){for(var i,r,o,s,a=n.length,l=n[0].length,u=0,d=[],c=[];u<a-1;u++){for(i=0,s=u+1;s<l;s++)i+=n[s][u]*n[s][u];for(i=(n[u+1][u]>0?-1:1)*t.sqrt(i),r=t.sqrt((i*i-n[u+1][u]*i)/2),(d=e.zeros(a,1))[u+1][0]=(n[u+1][u]-i)/(2*r),o=u+2;o<a;o++)d[o][0]=n[o][u]/(2*r);c=e.subtract(e.identity(a,l),e.multiply(e.multiply(d,e.transpose(d)),2)),n=e.multiply(c,e.multiply(n,c))}return n},QR:(n=e.sum,i=e.arange,function(r){var o,s,a,l=r.length,u=r[0].length,d=e.zeros(u,u);for(s=0,r=e.copy(r);s<u;s++){for(o=0,d[s][s]=t.sqrt(n(i(l).map(function(e){return r[e][s]*r[e][s]})));o<l;o++)r[o][s]=r[o][s]/d[s][s];for(a=s+1;a<u;a++)for(o=0,d[s][a]=n(i(l).map(function(e){return r[e][s]*r[e][a]}));o<l;o++)r[o][a]=r[o][a]-r[o][s]*d[s][a]}return[r,d]}),lstsq:function(t,n){var i,r,o,s=!1;void 0===n[0].length&&(n=n.map(function(e){return[e]}),s=!0);var a=e.QR(t),l=a[0],u=a[1],d=t[0].length,c=e.slice(l,{col:{end:d}}),h=(i=e.slice(u,{row:{end:d}}),r=(i=e.copy(i)).length,o=e.identity(r),e.arange(r-1,-1,-1).forEach(function(t){e.sliceAssign(o,{row:t},e.divide(e.slice(o,{row:t}),i[t][t])),e.sliceAssign(i,{row:t},e.divide(e.slice(i,{row:t}),i[t][t])),e.arange(t).forEach(function(n){var r=e.multiply(i[n][t],-1),s=e.slice(i,{row:n}),a=e.multiply(e.slice(i,{row:t}),r);e.sliceAssign(i,{row:n},e.add(s,a));var l=e.slice(o,{row:n}),u=e.multiply(e.slice(o,{row:t}),r);e.sliceAssign(o,{row:n},e.add(l,u))})}),o),p=e.transpose(c);void 0===p[0].length&&(p=[p]);var f=e.multiply(e.multiply(h,p),n);return(void 0===f.length&&(f=[[f]]),s)?f.map(function(e){return e[0]}):f},jacobi:function(n){for(var i,r,o,s,a,l,u,d=1,c=n.length,h=e.identity(c,c),p=[];1===d;){for(i=0,a=n[0][1],o=0,s=1;i<c;i++)for(r=0;r<c;r++)i!=r&&a<t.abs(n[i][r])&&(a=t.abs(n[i][r]),o=i,s=r);for(i=1,l=n[o][o]===n[s][s]?n[o][s]>0?t.PI/4:-t.PI/4:t.atan(2*n[o][s]/(n[o][o]-n[s][s]))/2,(u=e.identity(c,c))[o][o]=t.cos(l),u[o][s]=-t.sin(l),u[s][o]=t.sin(l),u[s][s]=t.cos(l),h=e.multiply(h,u),n=e.multiply(e.multiply(e.inv(u),n),u),d=0;i<c;i++)for(r=1;r<c;r++)i!=r&&t.abs(n[i][r])>.001&&(d=1)}for(i=0;i<c;i++)p.push(n[i][i]);return[h,p]},rungekutta:function(e,t,n,i,r,o){var s,a,l,u;if(2===o)for(;i<=n;)s=t*e(i,r),a=t*e(i+t,r+s),r+=(s+a)/2,i+=t;if(4===o)for(;i<=n;)s=t*e(i,r),a=t*e(i+t/2,r+s/2),l=t*e(i+t/2,r+a/2),u=t*e(i+t,r+l),r+=(s+2*a+2*l+u)/6,i+=t;return r},romberg:function(e,n,i,r){for(var o,s,a,l,u,d=0,c=(i-n)/2,h=[],p=[],f=[];d<r/2;){for(u=e(n),a=n,l=0;a<=i;a+=c,l++)h[l]=a;for(a=1,o=h.length;a<o-1;a++)u+=(a%2!=0?4:2)*e(h[a]);u=c/3*(u+e(i)),f[d]=u,c/=2,d++}for(s=f.length,o=1;1!==s;){for(a=0;a<s-1;a++)p[a]=(t.pow(4,o)*f[a+1]-f[a])/(t.pow(4,o)-1);s=p.length,f=p,p=[],o++}return f},richardson:function(e,n,i,r){function o(e,t){for(var n,i=0,r=e.length;i<r;i++)e[i]===t&&(n=i);return n}for(var s,a,l,u,d,c=t.abs(i-e[o(e,i)+1]),h=0,p=[],f=[];r>=c;)s=o(e,i+r),a=o(e,i),p[h]=(n[s]-2*n[a]+n[2*a-s])/(r*r),r/=2,h++;for(u=p.length,l=1;1!=u;){for(d=0;d<u-1;d++)f[d]=(t.pow(4,l)*p[d+1]-p[d])/(t.pow(4,l)-1);u=f.length,p=f,f=[],l++}return p},simpson:function(e,t,n,i){for(var r,o=(n-t)/i,s=e(t),a=[],l=t,u=0,d=1;l<=n;l+=o,u++)a[u]=l;for(r=a.length;d<r-1;d++)s+=(d%2!=0?4:2)*e(a[d]);return o/3*(s+e(n))},hermite:function(e,t,n,i){for(var r,o=e.length,s=0,a=0,l=[],u=[],d=[],c=[];a<o;a++){for(r=0,l[a]=1;r<o;r++)a!=r&&(l[a]*=(i-e[r])/(e[a]-e[r]));for(r=0,u[a]=0;r<o;r++)a!=r&&(u[a]+=1/(e[a]-e[r]));d[a]=(1-2*(i-e[a])*u[a])*(l[a]*l[a]),c[a]=(i-e[a])*(l[a]*l[a]),s+=d[a]*t[a]+c[a]*n[a]}return s},lagrange:function(e,t,n){for(var i,r,o=0,s=0,a=e.length;s<a;s++){for(i=0,r=t[s];i<a;i++)s!=i&&(r*=(n-e[i])/(e[s]-e[i]));o+=r}return o},cubic_spline:function(t,n,i){for(var r,o=t.length,s=0,a=[],l=[],u=[],d=[],c=[],h=[],p=[];s<o-1;s++)c[s]=t[s+1]-t[s];for(s=1,u[0]=0;s<o-1;s++)u[s]=3/c[s]*(n[s+1]-n[s])-3/c[s-1]*(n[s]-n[s-1]);for(s=1;s<o-1;s++)a[s]=[],l[s]=[],a[s][s-1]=c[s-1],a[s][s]=2*(c[s-1]+c[s]),a[s][s+1]=c[s],l[s][0]=u[s];for(r=0,d=e.multiply(e.inv(a),l);r<o-1;r++)h[r]=(n[r+1]-n[r])/c[r]-c[r]*(d[r+1][0]+2*d[r][0])/3,p[r]=(d[r+1][0]-d[r][0])/(3*c[r]);for(r=0;r<o&&!(t[r]>i);r++);return n[r-=1]+(i-t[r])*h[r]+e.sq(i-t[r])*d[r]+(i-t[r])*e.sq(i-t[r])*p[r]},gauss_quadrature:function(){throw Error("gauss_quadrature not yet implemented")},PCA:function(t){var n,i,r=t.length,o=t[0].length,s=0,a=[],l=[],u=[],d=[],c=[],h=[],p=[],f=[],m=[],g=[];for(s=0;s<r;s++)a[s]=e.sum(t[s])/o;for(s=0;s<o;s++)for(n=0,p[s]=[];n<r;n++)p[s][n]=t[n][s]-a[n];for(s=0,p=e.transpose(p);s<r;s++)for(n=0,f[s]=[];n<r;n++)f[s][n]=e.dot([p[s]],[p[n]])/(o-1);for(s=0,m=(u=e.jacobi(f))[0],l=u[1],g=e.transpose(m);s<l.length;s++)for(n=s;n<l.length;n++)l[s]<l[n]&&(i=l[s],l[s]=l[n],l[n]=i,d=g[s],g[s]=g[n],g[n]=d);for(s=0,h=e.transpose(p);s<r;s++)for(n=0,c[s]=[];n<h.length;n++)c[s][n]=e.dot([g[s]],[h[n]]);return[t,l,g,c]}});for(var a="add divide multiply subtract dot pow exp log abs norm angle".split(" "),l=0;l<a.length;l++)!function(t){e.fn[t]=function(n,i){var r=this;return i?(setTimeout(function(){i.call(r,e.fn[t].call(r,n))},15),this):"number"==typeof e[t](this,n)?e[t](this,n):e(e[t](this,n))}}(a[l])}(e,Math);var c=Math,h=[].slice,p=e.utils.isNumber,f=e.utils.isArray;function m(e,t,n,i){if(e>1||n>1||e<=0||n<=0)throw Error("Proportions should be greater than 0 and less than 1");var r=(e*t+n*i)/(t+i);return(e-n)/c.sqrt(r*(1-r)*(1/t+1/i))}return e.extend({zscore:function(){var t=h.call(arguments);return p(t[1])?(t[0]-t[1])/t[2]:(t[0]-e.mean(t[1]))/e.stdev(t[1],t[2])},ztest:function(){var t,n=h.call(arguments);return f(n[1])?(t=e.zscore(n[0],n[1],n[3]),1===n[2]?e.normal.cdf(-c.abs(t),0,1):2*e.normal.cdf(-c.abs(t),0,1)):n.length>2?(t=e.zscore(n[0],n[1],n[2]),1===n[3]?e.normal.cdf(-c.abs(t),0,1):2*e.normal.cdf(-c.abs(t),0,1)):(t=n[0],1===n[1]?e.normal.cdf(-c.abs(t),0,1):2*e.normal.cdf(-c.abs(t),0,1))}}),e.extend(e.fn,{zscore:function(e,t){return(e-this.mean())/this.stdev(t)},ztest:function(t,n,i){var r=c.abs(this.zscore(t,i));return 1===n?e.normal.cdf(-r,0,1):2*e.normal.cdf(-r,0,1)}}),e.extend({tscore:function(){var t=h.call(arguments);return 4===t.length?(t[0]-t[1])/(t[2]/c.sqrt(t[3])):(t[0]-e.mean(t[1]))/(e.stdev(t[1],!0)/c.sqrt(t[1].length))},ttest:function(){var t,n=h.call(arguments);return 5===n.length?(t=c.abs(e.tscore(n[0],n[1],n[2],n[3])),1===n[4]?e.studentt.cdf(-t,n[3]-1):2*e.studentt.cdf(-t,n[3]-1)):p(n[1])?(t=c.abs(n[0]),1==n[2]?e.studentt.cdf(-t,n[1]-1):2*e.studentt.cdf(-t,n[1]-1)):(t=c.abs(e.tscore(n[0],n[1])),1==n[2]?e.studentt.cdf(-t,n[1].length-1):2*e.studentt.cdf(-t,n[1].length-1))}}),e.extend(e.fn,{tscore:function(e){return(e-this.mean())/(this.stdev(!0)/c.sqrt(this.cols()))},ttest:function(t,n){return 1===n?1-e.studentt.cdf(c.abs(this.tscore(t)),this.cols()-1):2*e.studentt.cdf(-c.abs(this.tscore(t)),this.cols()-1)}}),e.extend({anovafscore:function(){var t,n,i,r,o,s,a,l,u=h.call(arguments);if(1===u.length){for(a=0,o=Array(u[0].length);a<u[0].length;a++)o[a]=u[0][a];u=o}for(a=0,n=[];a<u.length;a++)n=n.concat(u[a]);for(a=0,i=e.mean(n),t=0;a<u.length;a++)t+=u[a].length*c.pow(e.mean(u[a])-i,2);for(t/=u.length-1,s=0,a=0;a<u.length;a++)for(l=0,r=e.mean(u[a]);l<u[a].length;l++)s+=c.pow(u[a][l]-r,2);return t/(s/=n.length-u.length)},anovaftest:function(){var t,n,i,r,o=h.call(arguments);if(p(o[0]))return 1-e.centralF.cdf(o[0],o[1],o[2]);var s=e.anovafscore(o);for(r=0,t=o.length-1,i=0;r<o.length;r++)i+=o[r].length;return n=i-t-1,1-e.centralF.cdf(s,t,n)},ftest:function(t,n,i){return 1-e.centralF.cdf(t,n,i)}}),e.extend(e.fn,{anovafscore:function(){return e.anovafscore(this.toArray())},anovaftes:function(){var t,n=0;for(t=0;t<this.length;t++)n+=this[t].length;return e.ftest(this.anovafscore(),this.length-1,n-this.length)}}),e.extend({qscore:function(){var t,n,i,r,o,s=h.call(arguments);return p(s[0])?(t=s[0],n=s[1],i=s[2],r=s[3],o=s[4]):(t=e.mean(s[0]),n=e.mean(s[1]),i=s[0].length,r=s[1].length,o=s[2]),c.abs(t-n)/(o*c.sqrt((1/i+1/r)/2))},qtest:function(){var t,n=h.call(arguments);3===n.length?(t=n[0],n=n.slice(1)):7===n.length?(t=e.qscore(n[0],n[1],n[2],n[3],n[4]),n=n.slice(5)):(t=e.qscore(n[0],n[1],n[2]),n=n.slice(3));var i=n[0],r=n[1];return 1-e.tukey.cdf(t,r,i-r)},tukeyhsd:function(t){for(var n=e.pooledstdev(t),i=t.map(function(t){return e.mean(t)}),r=t.reduce(function(e,t){return e+t.length},0),o=[],s=0;s<t.length;++s)for(var a=s+1;a<t.length;++a){var l=e.qtest(i[s],i[a],t[s].length,t[a].length,n,r,t.length);o.push([[s,a],l])}return o}}),e.extend({normalci:function(){var t,n=h.call(arguments),i=[,,];return t=4===n.length?c.abs(e.normal.inv(n[1]/2,0,1)*n[2]/c.sqrt(n[3])):c.abs(e.normal.inv(n[1]/2,0,1)*e.stdev(n[2])/c.sqrt(n[2].length)),i[0]=n[0]-t,i[1]=n[0]+t,i},tci:function(){var t,n=h.call(arguments),i=[,,];return t=4===n.length?c.abs(e.studentt.inv(n[1]/2,n[3]-1)*n[2]/c.sqrt(n[3])):c.abs(e.studentt.inv(n[1]/2,n[2].length-1)*e.stdev(n[2],!0)/c.sqrt(n[2].length)),i[0]=n[0]-t,i[1]=n[0]+t,i},significant:function(e,t){return e<t}}),e.extend(e.fn,{normalci:function(t,n){return e.normalci(t,n,this.toArray())},tci:function(t,n){return e.tci(t,n,this.toArray())}}),e.extend(e.fn,{oneSidedDifferenceOfProportions:function(t,n,i,r){var o=m(t,n,i,r);return e.ztest(o,1)},twoSidedDifferenceOfProportions:function(t,n,i,r){var o=m(t,n,i,r);return e.ztest(o,2)}}),e.models=function(){function t(t,n){var i=t.length,r=n[0].length-1,o=e.lstsq(n,t),s=e.multiply(n,o.map(function(e){return[e]})).map(function(e){return e[0]}),a=e.subtract(t,s),l=e.mean(t),u=e.sum(s.map(function(e){return Math.pow(e-l,2)})),d=e.sum(t.map(function(e,t){return Math.pow(e-s[t],2)})),c=u+d;return{exog:n,endog:t,nobs:i,df_model:r,df_resid:i-r-1,coef:o,predict:s,resid:a,ybar:l,SST:c,SSE:u,SSR:d,R2:u/c}}return{ols:function(n,i){var r,o,s,a,l,u,d,c,h,p,f,m,g,v,b=t(n,i),y=(o=(r=b.exog)[0].length,s=e.arange(o).map(function(n){var i=e.arange(o).filter(function(e){return e!==n});return t(e.col(r,n).map(function(e){return e[0]}),e.col(r,i))}),a=Math.sqrt(b.SSR/b.df_resid),l=s.map(function(e){return a/Math.sqrt(e.SST*(1-e.R2))}),d=(u=b.coef.map(function(e,t){return(e-0)/l[t]})).map(function(t){var n=e.studentt.cdf(t,b.df_resid);return(n>.5?1-n:n)*2}),c=e.studentt.inv(.975,b.df_resid),h=b.coef.map(function(e,t){var n=c*l[t];return[e-n,e+n]}),{se:l,t:u,p:d,sigmaHat:a,interval95:h}),_=(v=1-(f=p=b.R2/b.df_model/((1-b.R2)/b.df_resid),m=b.df_model,g=b.df_resid,e.beta.cdf(f/(g/m+f),m/2,g/2)),{F_statistic:p,pvalue:v}),w=1-(1-b.R2)*((b.nobs-1)/b.df_resid);return b.t=y,b.f=_,b.adjust_R2=w,b}}}(),e.extend({buildxmatrix:function(){for(var t=Array(arguments.length),n=0;n<arguments.length;n++){var i=[1];t[n]=i.concat(arguments[n])}return e(t)},builddxmatrix:function(){for(var t=Array(arguments[0].length),n=0;n<arguments[0].length;n++){var i=[1];t[n]=i.concat(arguments[0][n])}return e(t)},buildjxmatrix:function(t){for(var n=Array(t.length),i=0;i<t.length;i++)n[i]=t[i];return e.builddxmatrix(n)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(t,n){var i,r,o,s,a;if(t.cols()==n.rows()){if(n.rows()>1){for(i=0,s=[];i<t.rows();i++)for(r=0,s[i]=[];r<n.cols();r++){for(o=0,a=0;o<t.cols();o++)a+=t.toArray()[i][o]*n.toArray()[o][r];s[i][r]=a}return e(s)}for(i=0,s=[];i<t.rows();i++)for(r=0,s[i]=[];r<n.cols();r++){for(o=0,a=0;o<t.cols();o++)a+=t.toArray()[i][o]*n.toArray()[r];s[i][r]=a}return e(s)}},regress:function(t,n){var i=e.xtranspxinv(t),r=t.transpose(),o=e.matrixmult(e(i),r);return e.matrixmult(o,n)},regresst:function(t,n,i){var r,o,s,a=e.regress(t,n),l={};l.anova={};var u=e.jMatYBar(t,a);l.yBar=u;var d=n.mean();l.anova.residuals=e.residuals(n,u),l.anova.ssr=e.ssr(u,d),l.anova.msr=l.anova.ssr/(t[0].length-1),l.anova.sse=e.sse(n,u),l.anova.mse=l.anova.sse/(n.length-(t[0].length-1)-1),l.anova.sst=e.sst(n,d),l.anova.mst=l.anova.sst/(n.length-1),l.anova.r2=1-l.anova.sse/l.anova.sst,l.anova.r2<0&&(l.anova.r2=0),l.anova.fratio=l.anova.msr/l.anova.mse,l.anova.pvalue=e.anovaftest(l.anova.fratio,t[0].length-1,n.length-(t[0].length-1)-1),l.anova.rmse=Math.sqrt(l.anova.mse),l.anova.r2adj=1-l.anova.mse/l.anova.mst,l.anova.r2adj<0&&(l.anova.r2adj=0),l.stats=Array(t[0].length);for(var c=e.xtranspxinv(t),h=0;h<a.length;h++)r=Math.sqrt(l.anova.mse*Math.abs(c[h][h])),o=Math.abs(a[h]/r),s=e.ttest(o,n.length-t[0].length-1,i),l.stats[h]=[a[h],r,o,s];return l.regress=a,l},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var n=e.matrixmult(t.transpose(),t);return e.inv(n)},jMatYBar:function(t,n){var i=e.matrixmult(t,n);return new e(i)},residuals:function(t,n){return e.matrixsubtract(t,n)},ssr:function(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(e[i]-t,2);return n},sse:function(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(e[i]-t[i],2);return n},sst:function(e,t){for(var n=0,i=0;i<e.length;i++)n+=Math.pow(e[i]-t,2);return n},matrixsubtract:function(t,n){for(var i=Array(t.length),r=0;r<t.length;r++){i[r]=Array(t[r].length);for(var o=0;o<t[r].length;o++)i[r][o]=t[r][o]-n[r][o]}return e(i)}}),e.jStat=e,e}()},2620(e,t,n){"use strict";var i=n(6002),r=n.n(i),o=n(2611),s=n.n(o),a=n(6129),l=n.n(a),u=n(8986),d=n.n(u),c=n(838),h=n.n(c),p=n(3515),f=n.n(p),m=n(5825),g={};g.styleTagTransform=f(),g.setAttributes=d(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=h(),r()(m.A,g),m.A&&m.A.locals&&m.A.locals},6002(e){"use strict";var t=[];function n(e){for(var n=-1,i=0;i<t.length;i++)if(t[i].identifier===e){n=i;break}return n}function i(e,i){for(var r={},o=[],s=0;s<e.length;s++){var a=e[s],l=i.base?a[0]+i.base:a[0],u=r[l]||0,d="".concat(l," ").concat(u);r[l]=u+1;var c=n(d),h={css:a[1],media:a[2],sourceMap:a[3],supports:a[4],layer:a[5]};if(-1!==c)t[c].references++,t[c].updater(h);else{var p=function(e,t){var n=t.domAPI(t);return n.update(e),function(t){t?(t.css!==e.css||t.media!==e.media||t.sourceMap!==e.sourceMap||t.supports!==e.supports||t.layer!==e.layer)&&n.update(e=t):n.remove()}}(h,i);i.byIndex=s,t.splice(s,0,{identifier:d,updater:p,references:1})}o.push(d)}return o}e.exports=function(e,r){var o=i(e=e||[],r=r||{});return function(e){e=e||[];for(var s=0;s<o.length;s++){var a=n(o[s]);t[a].references--}for(var l=i(e,r),u=0;u<o.length;u++){var d=n(o[u]);0===t[d].references&&(t[d].updater(),t.splice(d,1))}o=l}}},6129(e){"use strict";var t={};e.exports=function(e,n){var i=function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}t[e]=n}return t[e]}(e);if(!i)throw Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");i.appendChild(n)}},838(e){"use strict";e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},8986(e,t,n){"use strict";e.exports=function(e){var t=n.nc;t&&e.setAttribute("nonce",t)}},2611(e){"use strict";e.exports=function(e){if("u"<typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(n){var i,r,o;i="",n.supports&&(i+="@supports (".concat(n.supports,") {")),n.media&&(i+="@media ".concat(n.media," {")),(r=void 0!==n.layer)&&(i+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),i+=n.css,r&&(i+="}"),n.media&&(i+="}"),n.supports&&(i+="}"),(o=n.sourceMap)&&"u">typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(o))))," */")),e.styleTagTransform(i,t,e.options)},remove:function(){var e;null===(e=t).parentNode||e.parentNode.removeChild(e)}}}},3515(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))}}},8285(e,t,n){"use strict";n.d(t,{q:()=>eo.qS,i:()=>ex});var i,r,o,s,a,l,u,d,c,h,p,f,m,g,v,b,y,_,w,x,k,S,C,A,O,E,T,P,N,I,M,L,R,j,D,F,z,q=n(7389),B=n(4328),G=n(6082),V=n(8621);(i=_||(_={})).Levenshtein="Levenshtein",i.JaroWinkler="Jaro-Winkler",i.Manhattan="Manhattan String",i.Onehot="One-Hot",(r=w||(w={})).Euclidean="Euclidean",r.Manhattan="Manhattan",r.Cosine="Vector Cosine",(o=x||(x={})).Tanimoto="Tanimoto",o.Dice="Dice",o.Asymmetric="Asymmetric",o.BraunBlanquet="Braun-Blanquet",o.Cosine="Cosine",o.Kulczynski="Kulczynski",o.McConnaughey="Mc-Connaughey",o.RogotGoldberg="Rogot-Goldberg",o.Russel="Russel",o.Sokal="Sokal",o.Hamming="Hamming",o.Euclidean="Euclidean BitArray",(k||(k={})).TanimotoIntArray="TanimotoIntArray",(s=S||(S={})).Vector="Vector",s.String="String",s.BitArray="BitArray",s.MacroMolecule="MacroMolecule",s.Number="Number",s.IntArray="IntArray",s.NumberArray="NumberArray",(C||(C={})).Difference="Difference",(A||(A={})).CommonItems="Common Items";var U=n(4386);x.Tanimoto,x.Dice,x.Asymmetric,x.BraunBlanquet,x.Cosine,x.Kulczynski,x.McConnaughey,x.RogotGoldberg,x.Russel,x.Sokal,x.Hamming,x.Euclidean,x.Tanimoto,x.Dice,x.Asymmetric,x.BraunBlanquet,x.Cosine,x.Kulczynski,x.McConnaughey,x.RogotGoldberg,x.Russel,x.Sokal,x.Hamming,x.Euclidean,x.Tanimoto,x.Dice,x.Cosine,x.Tanimoto,x.Asymmetric,x.Cosine,x.Sokal,U.Z.HAMMING,U.Z.LEVENSHTEIN,U.Z.MONOMER_CHEMICAL_DISTANCE,U.Z.NEEDLEMANN_WUNSCH;n(8509),(a=O||(O={})).SYMBOL="symbol",a.NAME="name",a.MOLFILE="molfile",a.AUTHOR="author",a.ID="id",a.RGROUPS="rgroups",a.SMILES="smiles",a.POLYMER_TYPE="polymerType",a.MONOMER_TYPE="monomerType",a.CREATE_DATE="createDate",(l=E||(E={})).CAP_GROUP_SMILES="capGroupSmiles",l.CAP_GROUP_SMILES_UPPERCASE="capGroupSMILES",l.ALTERNATE_ID="alternateId",l.CAP_GROUP_NAME="capGroupName",l.LABEL="label",(u=T||(T={})).NATURAL_ANALOG="naturalAnalog",u.META="meta",(d=P||(P={})).MONOMER_TYPE="monomerType",d.SMILES="smiles",d.NAME="name",d.AUTHOR="author",d.MOLFILE="molfile",d.NATURAL_ANALOG="naturalAnalog",d.RGROUPS="rgroups",d.CREATE_DATE="createDate",d.ID="id",d.POLYMER_TYPE="polymerType",d.SYMBOL="symbol",RegExp("[rd]\\((\\w)\\)p?","g");var H=n(7351),W=n(1381),Y=n(7461);function K(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function X(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function Z(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){X(o,i,r,s,a,"next",e)}function a(e){X(o,i,r,s,a,"throw",e)}s(void 0)})}}function Q(e,t,n,i,r){return Z(function*(){var o,s,a;let l=(0,H.R)(t,r),u=r.getSeqHandler(t).getNewColumnFromList("ref",[n]),d=r.getSeqHandler(u).getSplitted(0),c=i===N.IDENTITY?function(e,t){let n=t.columns.length,i=Array(n),r=Array(n),o=Array(n);for(let s=0;s<n;++s){let n=t.columns.byIndex(s);i[s]=n.getRawData(),r[s]=n.categories.indexOf("");let a=s<e.length?e.getOriginal(s):W._S;o[s]=n.categories.indexOf(a)}let s=G.Column.float("Identity",t.rowCount),a=s.getRawData();for(let n=0;n<t.rowCount;++n){a[n]=0;for(let t=0;t<e.length;++t)(i[t]?i[t][n]:0)===o[t]&&++a[n];a[n]/=e.length}return s}(d,l):i===N.SIMILARITY?yield(o=d,s=l,a=r,Z(function*(){var e,t;let n=s.columns.toList();return yield(e=n,(t=function*(){e instanceof G.Column&&(e=(0,H.R)(e,a).columns.toList());let t=(yield(0,Y.pj)()).getMonomerLib(),n=e[0].length,i=new Float32Array(n);for(let a=0;a<Math.min(e.length,o.length);++a){var r,s;let l=o.getCanonical(a),u=null!=(r=null==(s=t.getMonomer("PEPTIDE",l))?void 0:s.smiles)?r:"",d=e[a],c=d.getRawData(),h=d.categories,p=h.indexOf("");if(void 0===l)continue;let f=G.Column.fromStrings("smiles",h.map(e=>{var n,i;return null!=(n=null==(i=t.getMonomer("PEPTIDE",e))?void 0:i.smiles)?n:""}));G.DataFrame.fromColumns([f]);let m=yield B.chem.getSimilarities(f,u),g=m?m.getRawData():null;for(let e=0;e<n;++e){let t=c[e];l!==W._S&&t!==p?i[e]+=g[t]:l===W._S&&t===p&&(i[e]+=1)}}for(let e=0;e<i.length;++e)i[e]/=o.length;return G.Column.fromFloat32Array("Similarity",i)},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){K(o,i,r,s,a,"next",e)}function a(e){K(o,i,r,s,a,"throw",e)}s(void 0)})})())})()):null;if(null==c)throw Error(`In bio library: Unknown sequence scoring method: ${i}`);return c.name=e.columns.getUnusedName(c.name),e.columns.add(c),c})()}(c=N||(N={})).IDENTITY="identity",c.SIMILARITY="similarity";var J=n(9222),ee=n(1991),et=n.n(ee),en=n(1858),ei=n(1757),er=n.n(ei),eo=n(3629),es=n(4345),ea=n(8750),el=n(2747),eu=n(8154),ed=n(5789),ec=n(9336),eh=n(3286),ep=n(4323),ef=n(4332),em=n(5408),eg=n(7563);function ev(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}(h=I||(I={})).UMAP="UMAP",h.T_SNE="t-SNE",n(4084),(p=M||(M={})).EUCLIDEAN="EUCLIDEAN",p.MANHATTAN="MANHATTAN",M.EUCLIDEAN,M.MANHATTAN,(f=L||(L={})).HAMMING="Hamming",f.EUCLIDEAN="Euclidean",f.VECTOR_COSINE="Vector Cosine",f.MANHATTAN="Manhattan",f.TANIMOTO="Tanimoto",f.LEVENSTEIN="Levenshtein",f.NEEDLEMAN_WUNSCH="Needlemann-Wunsch",f.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",f.SOKAL="Sokal",f.COSINE="Cosine",f.ASYMMETRIC="Asymmetric",f.Difference="Difference",f.OneHot="One-Hot",L.HAMMING,L.EUCLIDEAN,L.MANHATTAN,L.VECTOR_COSINE,L.TANIMOTO,L.LEVENSTEIN,L.NEEDLEMAN_WUNSCH,L.MONOMER_CHEMICAL_DISTANCE,L.SOKAL,L.COSINE,L.ASYMMETRIC,L.Difference,L.OneHot,L.HAMMING,L.EUCLIDEAN,L.MANHATTAN,L.TANIMOTO,L.SOKAL,L.COSINE,L.ASYMMETRIC,L.LEVENSTEIN,L.NEEDLEMAN_WUNSCH,L.MONOMER_CHEMICAL_DISTANCE,L.Difference,L.OneHot,L.VECTOR_COSINE,(m=R||(R={})).STRING="STRING",m.UINT32ARRAY="UINT32ARRAY",m.INT32ARRAY="INT32ARRAY",m.FLOAT32ARRAY="FLOAT32ARRAY",m.NUMBER="NUMBER",m.BITARRAY="BITARRAY",L.HAMMING,L.LEVENSTEIN,L.NEEDLEMAN_WUNSCH,L.MONOMER_CHEMICAL_DISTANCE,L.OneHot,L.HAMMING,L.EUCLIDEAN,L.MANHATTAN,L.MONOMER_CHEMICAL_DISTANCE,L.LEVENSTEIN,L.NEEDLEMAN_WUNSCH,L.TANIMOTO,L.COSINE,L.VECTOR_COSINE,L.SOKAL,L.ASYMMETRIC,L.OneHot,L.Difference,L.EUCLIDEAN,L.MANHATTAN,L.OneHot,L.Difference,L.VECTOR_COSINE,L.EUCLIDEAN,L.MANHATTAN,L.Difference,L.VECTOR_COSINE,L.EUCLIDEAN,L.MANHATTAN,L.Difference,L.TANIMOTO,L.COSINE,L.SOKAL,L.ASYMMETRIC,(g=j||(j={})).ADD="ADD",g.SUB="SUB",g.MULT="MULT",(v=D||(D={})).SQUARE="SQUARE",v.INVERSE="INVERSE",v.TRANSPOSE="TRANSPOSE",v.NORM="NORM",v.COLUMN_NORM="COLUMN_NORM",(b=F||(F={})).SCALARMULT="SCALARMULT",b.SCALARADD="SCALARADD",b.SCALARPOW="SCALARPOW",Object.prototype.toString,(y=z||(z={})).EUCLIDEAN="EUCLIDEAN",y.MANHATTAN="MANHATTAN";var eb=n(5013),ey=n(9417);function e_(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function ew(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){e_(o,i,r,s,a,"next",e)}function a(e){e_(o,i,r,s,a,"throw",e)}s(void 0)})}}class ex{get monomerPositionStats(){if(null!==this._monomerPositionStats)return this._monomerPositionStats;let e=this.getScaledActivityColumn();return null===this.positionColumns||null===e?null:(null!=this._monomerPositionStats||(this._monomerPositionStats=(0,em.Ej)(e,this.df.filter,this.positionColumns)),this._monomerPositionStats)}get analysisView(){if(void 0===this._analysisView){var e,t,n;this._analysisView=this.id?et()(B.shell.tableViews).find(({dataFrame:e})=>(null==e?void 0:e.getTag(G.TAGS.ID))===this.id):void 0,!this._analysisView&&(null==(e=B.shell.v)?void 0:e.preview)instanceof G.TableView&&(null==(n=B.shell.v)||null==(t=n.preview)?void 0:t.dataFrame)===this.df&&(this._analysisView=B.shell.v.preview),this._analysisView||(this._analysisView=B.shell.addTableView(this.df))}return"1"===this.df.getTag(eo.gp.MULTIPLE_VIEWS)||this._layoutEventInitialized||(0,ea.Lv)()||(B.shell.v=this._analysisView),this._analysisView.grid.invalidate(),this._analysisView}get settings(){var e;let t=this.df.getTag(eo.gp.SETTINGS);return t?(null!=this._settings||(this._settings=JSON.parse(t)),null==(e=this._settings)||!e.mclSettings||this._settings.mclSettings.webGPUDescriptionPromise instanceof Promise||(this._settings.mclSettings.webGPUDescriptionPromise=(0,ey._U)()),this._settings):null}set settings(e){this.applySettings(e).catch(e=>B.shell.error(String(e)))}applySettings(e){return ew(function*(){var t,n,i,r,o;let s=Object.entries(e),a=Object.assign({},null!=(t=null==(n=this.settings)?void 0:n.sequenceSpaceParams)?t:{}),l=new Set;for(let[e,t]of s)switch(this.settings[e]=t,e){case"activityColumnName":case"activityScaling":l.add("activity"),l.add("stats");break;case"showDendrogram":l.add("dendrogram");break;case"showClusterMaxActivity":l.add("clusterMaxActivity");break;case"showSequenceSpace":l.add("sequenceSpace");break;case"showLogoSummaryTable":l.add("logoSummaryTable");break;case"showMonomerPosition":l.add("monomerPosition");break;case"showMostPotentResidues":l.add("mostPotentResidues");break;case"columns":l.add("columns");break;case"sequenceSpaceParams":l.add("sequenceSpaceParams");break;case"mclSettings":l.add("mclSettings")}if(this.df.setTag("settings",JSON.stringify(this._settings)),this.isInitialized){for(let e of(l.has("sequenceSpace")?l.delete("sequenceSpaceParams"):l.has("sequenceSpaceParams")&&!Object.entries(this.settings.sequenceSpaceParams).some(([e,t])=>a[e]!==t&&"epsilon"!==e&&"minPts"!==e&&"clusterEmbeddings"!==e)&&(l.delete("sequenceSpaceParams"),this.settings.sequenceSpaceParams.clusterEmbeddings&&l.add("clusterParams")),l))switch(e){case"activity":this.createScaledCol();break;case"stats":this.webLogoSelection=(0,ea.ZR)(this.positionColumns),this.webLogoBounds={},this.cachedWebLogoTooltip={bar:"",tooltip:null},this._monomerPositionStats=null;break;case"dendrogram":this.settings.showDendrogram?yield this.addDendrogram():null==(i=this.dendrogramCloseButton)||i.click();break;case"clusterMaxActivity":this.settings.showClusterMaxActivity?yield this.addClusterMaxActivityViewer():this.closeViewer(eo.qS.CLUSTER_MAX_ACTIVITY);break;case"logoSummaryTable":this.settings.showLogoSummaryTable?yield this.addLogoSummaryTable():this.closeViewer(eo.qS.LOGO_SUMMARY_TABLE);break;case"monomerPosition":this.settings.showMonomerPosition?yield this.addMonomerPosition():this.closeViewer(eo.qS.SEQUENCE_VARIABILITY_MAP);break;case"mostPotentResidues":this.settings.showMostPotentResidues?yield this.addMostPotentResidues():this.closeViewer(eo.qS.MOST_POTENT_RESIDUES);break;case"columns":let t=this.findViewer(eo.qS.LOGO_SUMMARY_TABLE);t._viewerGrid=null,t._logoSummaryTable=null,t.render();let n=this.findViewer(eo.qS.MOST_POTENT_RESIDUES);n._viewerGrid=null,n.render();break;case"sequenceSpace":this.settings.showSequenceSpace?yield this.addSequenceSpace({clusterEmbeddings:null==(r=this.settings.sequenceSpaceParams)?void 0:r.clusterEmbeddings}):this.closeSequenceSpace();break;case"sequenceSpaceParams":this.settings.showSequenceSpace&&(yield this.addSequenceSpace({clusterEmbeddings:null==(o=this.settings.sequenceSpaceParams)?void 0:o.clusterEmbeddings}));break;case"clusterParams":yield this.clusterEmbeddings();break;case"mclSettings":yield this.addMCLClusters()}B.events.fireCustomEvent("peptides-sar-ready",{table:this.df.name})}}).call(this)}get webLogoSelection(){var e;return null!=this._webLogoSelection||(this._webLogoSelection=(0,ea.ZR)(null!=(e=this.positionColumns)?e:[])),this._webLogoSelection}set webLogoSelection(e){this._webLogoSelection=e,this.fireBitsetChanged(null),this.analysisView.grid.invalidate()}get positionColumns(){let e=et()(this.df.columns.byTags({[eo.gp.POSITION_COL]:"true"})).toArray();return 0===e.length?null:e}get id(){return this.df.getTag(G.TAGS.ID)}get alphabet(){return this.df.getCol(this.settings.sequenceColumnName).getTag(V.gp.alphabet)}static getInstance(e){if(e.columns.contains(eo.$2.ACTIVITY_SCALED)&&!e.columns.contains(eo.$2.ACTIVITY)&&(e.getCol(eo.$2.ACTIVITY_SCALED).name=eo.$2.ACTIVITY),!e.temp[ex.modelName]){let t=e.temp[ex.modelName]=new ex(e),n=t.settings;n&&t.init(n);let i=!0;t.subs.push(G.debounce(e.onSelectionChanged,10).subscribe(n=>{var r,o,s;if(i||e.selection.anyTrue||!t._analysisView||!document.contains(t._analysisView.root)||t._analysisView.dataFrame!==e){i=!(null==e||null==(r=e.selection)?void 0:r.anyTrue);return}t.positionColumns&&(t.webLogoSelection=(0,ea.ZR)(t.positionColumns));let a=t.findViewer(eo.qS.SEQUENCE_VARIABILITY_MAP);if(null!=a){let e=null!=(o=t.positionColumns)?o:a.positionColumns;e&&(a.invariantMapSelection=(0,ea.ZR)(e),a.mutationCliffsSelection=(0,ea.ZR)(e))}let l=t.findViewer(eo.qS.MOST_POTENT_RESIDUES);if(null!=l){let e=null!=(s=t.positionColumns)?s:l.positionColumns;e&&(l.mutationCliffsSelection=(0,ea.ZR)(e),l.invariantMapSelection=(0,ea.ZR)(e))}let u=t.findViewer(eo.qS.LOGO_SUMMARY_TABLE);null!=u&&(u.initClusterSelection({notify:!0}),u.render()),i=!0}))}return e.temp[ex.modelName]}modifyWebLogoSelection(e,t={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.webLogoSelection=(0,ea.vW)(this.webLogoSelection,e,t):this._webLogoSelection=(0,ea.vW)(this.webLogoSelection,e,t)}getVisibleSelection(){return this.df.selection.clone().and(this.df.filter)}createAccordion(){var e,t,n,i,r,o,s,a,l;let u=null==(s=this.df)?void 0:s.temp[ex.modelName];if(!u)return null;let d=q.accordion("Peptides analysis panel");d.root.style.width="100%";let c=u.getVisibleSelection(),h=u.df.filter.anyFalse?` among ${u.df.filter.trueCount} filtered`:"",p=e=>{let t=[];for(let[n,i]of Object.entries(e))for(let e of i)t.push(`${n}:${e}`);return t.join(", ")},f=u.findViewer(eo.qS.LOGO_SUMMARY_TABLE),m=[],g=(null===f?[]:(null!=(e=null==(a=f.clusterSelection)?void 0:a[eh.WR.ORIGINAL])?e:[]).concat(null!=(t=null==(l=f.clusterSelection)?void 0:l[eh.WR.CUSTOM])?t:[])).join(", "),v=e=>{let t=q.divText(e);return t.innerHTML=e,t};0!==g.length&&m.push(v(`<b>Logo Summary Table</b> clusters: ${g}`));let b=u.findViewer(eo.qS.SEQUENCE_VARIABILITY_MAP),y=p(null!=(n=null==b?void 0:b.invariantMapSelection)?n:{}),_=p(null!=(i=null==b?void 0:b.mutationCliffsSelection)?i:{});0!==y.length&&m.push(v(`<b>Invariant map</b>: ${y}`)),0!==_.length&&m.push(v(`<b>Mutation cliffs</b>: ${_}`));let w=u.findViewer(eo.qS.MOST_POTENT_RESIDUES),x=p(null!=(r=null==w?void 0:w.invariantMapSelection)?r:{});0!==x.length&&m.push(v(`<b>Most potent residues</b>: ${x}`));let k=p(u.webLogoSelection);0!==k.length&&m.push(v(`<b>WebLogo</b>: ${k}`)),0!==m.length&&m.unshift(q.h1("Selection Sources"));let S=q.div(q.divV(m));d.addTitle(q.divV([q.h1(`${c.trueCount} selected rows${h}`),S],"css-gap-small"));let C=u.settings,A=[b,w,f].filter(e=>null!==e&&(e.type!==this.accordionSource||(C=e,!1)));if(null===C)throw Error("PeptidesError: Model is the source of accordion but is not initialized");C!==u.settings&&A.push(u.settings),A.filter(e=>null!==e&&(0,ea.$s)(C,e)&&(e!==u.settings||u.isInitialized)).push(C);let O=C;C===u.settings||O instanceof eh.sI||null==O.mutationCliffs||d.addPane("Mutation Cliffs pairs",()=>(0,ed.F)(u.df,{mutationCliffs:O.mutationCliffs,mutationCliffsSelection:O.mutationCliffsSelection,gridColumns:u.analysisView.grid.columns,sequenceColumnName:O.sequenceColumnName,positionColumns:O.positionColumns,activityCol:O.getScaledActivityColumn(),mutationCliffStats:O.cliffStats}).root,!0);let E=C===u.settings,T=E?this.webLogoSelection:C instanceof el.J?C.invariantMapSelection:{},P=C instanceof eh.sI?C.clusterSelection:null!=(o=null==f?void 0:f.clusterSelection)?o:{};return d.addPane("Distribution",()=>{try{var e;return(0,ec.HV)(u.df,{columns:E?null!=(e=u.settings.columns)?e:{}:C.getAggregationColumns(),activityCol:E?u.getScaledActivityColumn():C.getScaledActivityColumn(),monomerPositionSelection:T,clusterSelection:P,clusterColName:null==f?void 0:f.clustersColumnName})}catch(t){let e=q.divText("Error in Distribution");return q.tooltip.bind(e,String(t)),e}},!0),d.addPane("Selection",()=>{try{var e;return function(e,t){var n,i,r;if(0===t.tableSelection.trueCount)return q.divText("No compounds selected");let o=G.DataFrame.create(e.rowCount);o.name="Selected compounds",o.filter.copyFrom(t.tableSelection);let s=null;for(let e=1;e<t.gridColumns.length;e++){let n=t.gridColumns.byIndex(e);if(!n.visible)continue;let a=n.column;if(a.type===G.COLUMN_TYPE.BOOL)continue;null===s&&n.grid&&(null==(i=n.grid.sortByColumns)?void 0:i.length)>0&&(null==(r=n.grid.sortTypes)?void 0:r.length)===n.grid.sortByColumns.length&&(s={cols:n.grid.sortByColumns,types:n.grid.sortTypes});let l=null,u=null;try{l=a.getRawData(),u=a.categories}catch(e){}let d=l&&u?a.isNumerical?e=>l[e]:e=>u[l[e]]:e=>a.get(e),c=e=>a.isNone(e)?null:d(e),h=a.name===t.activityColumn.name?o.columns.addNewFloat(n.name).init(e=>c(e)):o.columns.addNewVirtual(n.name,e=>c(e),a.type);for(let[e,t]of a.tags)h.setTag(e,t)}let a=o.plot.grid();a.props.showRowHeader=!1,a.root.style.maxWidth="100%",G.debounce(q.onSizeChanged(a.root),50).subscribe(e=>{var t;let n=a.root.parentElement;(null==n||null==(t=n.parentElement)?void 0:t.classList.contains("panel-content"))&&(a.root.style.height="calc(100% - 20px)",a.root.style.width="calc(100% - 20px)",a.root.style.position="absolute",a.root.style.right="10px",a.root.style.top="10px")}),(0,ea.zz)(a);let l=q.box(a.root);l.style.marginLeft="0px",setTimeout(()=>{null!==s&&a.sort(s.cols,s.types);for(let e=1;e<t.gridColumns.length;e++){let n=t.gridColumns.byIndex(e);n.visible&&a.col(n.name)&&(a.col(n.name).width=n.width)}},500);let u=(0,em.Ej)(t.activityColumn,o.filter,t.positionColumns,{isFiltered:!0});return t.isAnalysis&&(0,eu.FZ)(a,()=>u,t.positionColumns,t.activityColumn,{isSelectionTable:!0,cachedWebLogoTooltip:()=>({bar:"",tooltip:null}),webLogoBounds:()=>({}),colorPalette:()=>t.colorPalette},{x:0,y:0,monomerPosition:{},mpStats:u}),(null!=(n=e.columns.bySemTypeAll(G.SEMTYPE.MACROMOLECULE))?n:[]).forEach(e=>{o.col(e.name)&&(o.col(e.name).temp[eg.j.notationProvider]=e.temp[eg.j.notationProvider])}),l}(u.df,{positionColumns:E?u.positionColumns:C.positionColumns,columns:E?null!=(e=u.settings.columns)?e:{}:C.getAggregationColumns(),activityColumn:E?u.getScaledActivityColumn():C.getScaledActivityColumn(),gridColumns:u.analysisView.grid.columns,colorPalette:(0,V.SM)(u.df.getCol(E?u.settings.sequenceColumnName:C.sequenceColumnName),eb.Z.getSeqHelper()),tableSelection:u.getCombinedSelection(),isAnalysis:null!==u.settings&&(E||((e,t)=>{if(null==e||null==t)return!1;for(let[n,i]of Object.entries(e))if(i!==t[n])return!1;return!0})(u.settings.columns,C.getAggregationColumns()))})}catch(t){let e=q.divText("Error in Selection");return q.tooltip.bind(e,String(t)),e}},!0),d}getScaledActivityColumn(e=!1){let t=this.df.col(eo.$2.ACTIVITY);return e&&null!==t?G.DataFrame.fromColumns([t]).clone(this.df.filter).getCol(t.name):t}updateGrid(){var e;if(this.joinDataFrames(),this.createScaledCol(),this.webLogoBounds={},this.analysisView.grid.removeStatusProvider("peptides-weblogo"),null==(e=this.webLogoFrameSubscription)||e.unsubscribe(),this.webLogoFrameSubscription=this.analysisView.grid.onBeforeDrawContent.subscribe(()=>{this.webLogoBounds={}}),this.analysisView.grid.addStatusProvider("peptides-weblogo",()=>{let e={},t=this.analysisView.grid,n=t.canvas.clientWidth,i=t.props.colHeaderHeight;for(let[t,r]of Object.entries(this.webLogoBounds))for(let[o,s]of Object.entries(r)){let r=Math.max(0,s.x),a=Math.min(n,s.x+s.width),l=Math.max(0,s.y),u=Math.min(i,s.y+s.height);a>r&&u>l&&(e[`${o} at ${t}`]={x:r,y:l,width:a-r,height:u-l})}return{hitAreas:e,values:{"highlighted rows":this.highlightedRowCount}}}),this.subs.push(this.webLogoFrameSubscription),null===this.monomerPositionStats||null===this.positionColumns)throw Error("PeptidesError: Could not updage grid: monomerPositionStats or positionColumns are null");eu.FZ(this.analysisView.grid,()=>this.monomerPositionStats,this.positionColumns,this.getScaledActivityColumn(),{selectionCallback:(e,t)=>this.modifyWebLogoSelection(e,t),unhighlightCallback:()=>this.unhighlight(),colorPalette:()=>(0,V.SM)(this.df.getCol(this.settings.sequenceColumnName),eb.Z.getSeqHelper()),webLogoBounds:()=>this.webLogoBounds,cachedWebLogoTooltip:()=>this.cachedWebLogoTooltip,highlightCallback:(e,t,n)=>{this.highlight(e,n)},isSelectionTable:!1,headerSelectedMonomers:()=>this.webLogoSelectedMonomers}),this._layoutEventInitialized||(B.events.onViewLayoutApplied.subscribe(e=>{e.view.id===this.analysisView.id&&this.updateGrid()}),this._layoutEventInitialized=!0),this.setTooltips(),this.setBitsetCallback(),this.setGridProperties()}joinDataFrames(e=!1){let t=this.df.name,n=this.df.columns,i=(0,H.R)(this.df.getCol(this.settings.sequenceColumnName),eb.Z.getSeqHelper());for(let t of i.columns){let i=this.df.col(t.name),r=e||null===i;if(null!=i||(i=n.addNew(t.name,t.type)),r)for(let e=0;e<this.df.rowCount;e++)i.set(e,t.get(e),!1);i.setTag(eo.gp.ANALYSIS_COL,"true"),i.setTag(eo.gp.POSITION_COL,"true");let o=t.getTag(W.jz);o&&i.setTag(W.jz,o),eu.rI(i,this.alphabet)}if(e){var r;for(let e of null!=(r=this.positionColumns)?r:[])i.columns.contains(e.name)||n.remove(e.name)}this.df.name=t}updateSequence(e,t){return ew(function*(e,t,n=(()=>{var e;return null==(e=this.df.currentCol)?void 0:e.name})()){let i=this.analysisView,r=B.shell.o;this.updatingSequence=!0;try{var o,s,a;let l=this.df.getCol(this.settings.sequenceColumnName);for(let n of(eb.Z.getSeqHelper().getSeqHandler(l).splitter(t),l.set(e,t,!1),this.joinDataFrames(!0),this._monomerPositionStats=null,this._dm=null,this.cachedWebLogoTooltip={bar:"",tooltip:null},this.unhighlight(),null!=(o=this.positionColumns)?o:[]))n.temp[eo.gp.INVARIANT_MAP_COLOR_CACHE]=null;let u=Array.from(this.analysisView.viewers).filter(e=>{var t;return e instanceof G.JsViewer&&(null==(t=e.getProperty("sequenceColumnName"))?void 0:t.get(e))===l.name});for(let e of u)e instanceof el.xN?(e._positionColumns=null,e.onFilterChanged(!1,!0),e._viewerGrid=null):e instanceof eh.sI&&(e._positionColumns=null,e._clusterStats=null);for(let e of(this.df.fireValuesChanged(),this.updateGrid(),u))if(e instanceof el.xN){if(!e.mutationCliffs){let t=yield e.calculateMutationCliffs();e.mutationCliffs=t.cliffs,e.cliffStats=t.cliffStats}e.render()}else e instanceof eh.sI&&(e._clusterStats=null),e.onPropertyChanged(e.getProperty("sequenceColumnName"));let d=this.findViewer(eo.qS.CLUSTER_MAX_ACTIVITY);null==d||d.onPropertyChanged(null),this.fireBitsetChanged(null);let c=B.shell.o,h=c instanceof G.SemanticValue&&(null==(s=c.cell)?void 0:s.dataFrame.id)===this.df.id&&c.cell.column.name===n&&c.cell.rowIndex===e,p=c instanceof G.DataFrame&&c.id===this.df.id;if(n&&this.df.col(n)&&i.root.isConnected&&(null==(a=B.shell.v)?void 0:a.root)===i.root&&(c===r||p||h)){let t=this.df.cell(e,n);this.df.currentCell=t;let r=i.grid.tableRowToGrid(e);r>=0&&i.grid.scrollToCell(n,r),B.shell.setCurrentObject(r>=0?G.SemanticValue.fromGridCell(i.grid.cell(n,r)):G.SemanticValue.fromTableCell(t),!1,!0)}}finally{this.updatingSequence=!1}B.events.fireCustomEvent("peptides-sar-ready",{table:this.df.name})}).apply(this,arguments)}createScaledCol(){let e=this.analysisView.grid,t=(0,ea.Y1)(this.df.getCol(this.settings.activityColumnName),this.settings.activityScaling);this.df.columns.replace(eo.$2.ACTIVITY,t),e.columns.setOrder([t.name])}highlight(e,t){this.highlightedRowCount=(0,ea.dl)(e,this.df,t),this.isHighlighting=!0}unhighlight(){this.isHighlighting&&(this.df.rows.highlight(null),this.highlightedRowCount=0,this.isHighlighting=!1)}setTooltips(){this.analysisView.grid.onCellTooltip((e,t,n)=>{var i,r;return!!e.isColHeader&&(null==(i=e.tableColumn)?void 0:i.semType)===eo.uF.MONOMER||!!(e.isTableCell&&(null==(r=e.tableColumn)?void 0:r.semType)===eo.uF.MONOMER)})}getCombinedSelection(){var e,t,n,i,r,o,s,a;let l=new J.A(this.df.rowCount,!1),u=(e,t)=>{for(let[n,i]of Object.entries(e))for(let e of i){let i=null==t?void 0:t[n];if(void 0===i)continue;let r=i[e];void 0!==r&&l.or(r.mask)}};u(this.webLogoSelection,this.monomerPositionStats);let d=this.findViewer(eo.qS.SEQUENCE_VARIABILITY_MAP);u(null!=(e=null==d?void 0:d.invariantMapSelection)?e:{},null!=(t=null==d?void 0:d.monomerPositionStats)?t:null),((e,t)=>{for(let[r,o]of Object.entries(e))for(let e of o){var n,i;let o=null!=(n=null==t||null==(i=t.get(e))?void 0:i.get(r))?n:null;if(null!==o)for(let[e,t]of o.entries())for(let n of(l.setTrue(e),t))l.setTrue(n)}})(null!=(n=null==d?void 0:d.mutationCliffsSelection)?n:{},null!=(i=null==d?void 0:d.mutationCliffs)?i:null);let c=this.findViewer(eo.qS.MOST_POTENT_RESIDUES);u(null!=(r=null==c?void 0:c.invariantMapSelection)?r:{},null!=(o=null==c?void 0:c.monomerPositionStats)?o:null);let h=this.findViewer(eo.qS.LOGO_SUMMARY_TABLE);for(let e of Object.keys(null!=(s=null==h?void 0:h.clusterSelection)?s:{}))for(let t of null!=(a=h.clusterSelection[e])?a:[]){let n=h.clusterStats[e][t];l.or(n.mask)}let p=G.BitSet.fromBytes(l.buffer.buffer,l.length);return this.df.filter.anyFalse?p.and(this.df.filter):p}setBitsetCallback(){if(this.isBitsetChangedInitialized)return;let e=this.df.selection,t=this.df.filter,n=()=>{var e,t;if(!this.updatingSequence&&(null==(e=B.shell.v)?void 0:e.root)===(null==(t=this._analysisView)?void 0:t.root))try{let e=this.createAccordion();if(null===e)return;B.shell.setCurrentObject(e.root,!1,!0)}catch(e){console.error(e)}};this.subs.push(e.onChanged.subscribe(()=>{if(this.controlFire){this.controlFire=!1;return}try{this.isUserChangedSelection||e.copyFrom(this.getCombinedSelection(),!1)}catch(e){ef._package.logger.debug("Peptides: Error on selection changed"),ef._package.logger.debug(e)}finally{n()}})),this.subs.push(t.onChanged.subscribe(()=>{try{if(this.controlFire){this.controlFire=!1;return}let n=this.findViewer(eo.qS.LOGO_SUMMARY_TABLE);if(null!==n&&void 0!==n.model){var e,t;n._logoSummaryTable=null!=(e=n.createLogoSummaryTable())?e:n._logoSummaryTable,n._viewerGrid=null!=(t=n.createLogoSummaryTableGrid())?t:n._viewerGrid,n.render()}}catch(e){ef._package.logger.debug("Peptides: Error on filter changed"),ef._package.logger.debug(e)}finally{n()}}));let i=()=>{let e=B.shell.o,t=e instanceof G.RowGroup?e.dataFrame:e instanceof G.DataFrame?e:null;return(null==t?void 0:t.id)===this.df.id};this.subs.push(B.events.onCurrentObjectChanged.subscribe(()=>{i()&&Promise.resolve().then(()=>i()&&n())})),this.isBitsetChangedInitialized=!0}fireBitsetChanged(e,t=!1){this.accordionSource=e,this.isBitsetChangedInitialized||this.setBitsetCallback(),this.isUserChangedSelection=!1,this.df.selection.fireChanged(),t&&this.df.filter.fireChanged(),this.controlFire=!0,this.df.selection.fireChanged(),t&&this.df.filter.fireChanged(),this.isUserChangedSelection=!0,this.webLogoSelectedMonomers=(0,ea.qx)(this.df)}setGridProperties(e){var t,n,i,r;let o=this.analysisView.grid,s=o.props;s.allowColSelection=null!=(t=null==e?void 0:e.allowColSelection)&&t,s.allowEdit=null!=(n=null==e?void 0:e.allowEdit)&&n,s.showReadOnlyNotifications=null!=(i=null==e?void 0:e.showReadOnlyNotifications)&&i,s.showCurrentRowIndicator=null!=(r=null==e?void 0:e.showCurrentRowIndicator)&&r;let a=this.positionColumns;if(null===a)throw Error("PeptidesError: Could not set grid properties: positionColumns are null");let l=10,u=o.canvas.getContext("2d");if(null===u)throw Error("PeptidesError: Could not set grid properties: canvas context is null");for(let e of a){let t=(0,V.zS)(e.categories.reduce((e,t)=>e.length>t.length?e:t),6);l=Math.max(l,Math.ceil(u.measureText(t).width))}let d=a.map(e=>e.name);for(let e=1;e<this.analysisView.grid.columns.length;++e){let t=this.analysisView.grid.columns.byIndex(e);if(null===t)throw Error(`PeptidesError: Could not get analysis view: grid column with index '${e}' is null`);if(null===t.column)throw Error(`PeptidesError: Could not get analysis view: grid column with index '${e}' has null column`);t.visible=d.includes(t.column.name)||t.column.name===eo.$2.ACTIVITY}for(let e of a){let t=o.col(e.name);if(null===t)throw Error(`PeptidesError: Could not set column width: grid column '${e.name}' is null`);t.width=l+15}}closeViewer(e){let t=this.findViewer(e);null==t||t.detach(),null==t||t.close()}get dendrogramCloseButton(){var e,t;return null!=(e=null==(t=this.analysisView)?void 0:t.root.querySelector(".dendrogram-close-bttn"))?e:null}findViewerNode(e){for(let t of this.analysisView.dockManager.rootNode.children)if(t.container.containerElement.innerHTML.includes(e))return t;return null}addDendrogram(){return ew(function*(){let e=G.TaskBarProgressIndicator.create("Calculating distance matrix...");try{let e=G.Func.find({package:"Dendrogram",name:"hierarchicalClustering"})[0];if(!e||4!==e.inputs.length)throw Error("Correct dendrogram function is not found");yield e.apply({df:this.df,colNameList:[this.settings.sequenceColumnName],distance:"euclidean",linkage:"complete"})}catch(e){ef._package.logger.error(e)}finally{e.close()}}).call(this)}init(e){if(!this.isInitialized){if(this.settings=e,this.isInitialized=!0,!this.isRibbonSet&&"1"!==this.df.getTag(eo.gp.MULTIPLE_VIEWS)){let e=q.iconFA("wrench",()=>(0,ep.OH)(this),"Peptides analysis settings");this.analysisView.setRibbonPanels([[e]],!1),this.isRibbonSet=!0,this.updateGrid()}this.subs.push(en.merge(this.df.onRowsRemoved,this.df.onRowsAdded).subscribe(()=>{this._monomerPositionStats=null,this.cachedWebLogoTooltip={bar:"",tooltip:null}})),this.subs.push(B.events.onAccordionConstructed.subscribe(e=>{if(!(B.shell.o instanceof G.SemanticValue||B.shell.o instanceof G.Column&&this.df.columns.toList().includes(B.shell.o)))return;let t=e.getPane("Actions"),n=er()(t.root).find(".d4-flex-col"),i=q.label("Calculate identity");i.classList.add("d4-link-action"),q.tooltip.bind(i,"Adds a column with fractions of matching monomers against sequence in the current row"),i.onclick=()=>{let e=this.df.getCol(this.settings.sequenceColumnName);Q(this.df,e,e.get(this.df.currentRowIdx),N.IDENTITY,eb.Z.getSeqHelper()).then(t=>t.setTag(eo.gp.IDENTITY_TEMPLATE,e.get(this.df.currentRowIdx))).catch(e=>ef._package.logger.debug(e))},n.append(q.span([i],"d4-markdown-row"));let r=q.label("Calculate similarity");r.classList.add("d4-link-action"),q.tooltip.bind(r,"Adds a column with sequence similarity scores against sequence in the current row"),r.onclick=()=>{let e=this.df.getCol(this.settings.sequenceColumnName);Q(this.df,e,e.get(this.df.currentRowIdx),N.SIMILARITY,eb.Z.getSeqHelper()).then(t=>t.setTag(eo.gp.SIMILARITY_TEMPLATE,e.get(this.df.currentRowIdx))).catch(e=>ef._package.logger.debug(e))},n.append(q.span([r],"d4-markdown-row"))})),this.subs.push(B.events.onViewRemoved.subscribe(e=>{e.id===this.analysisView.id&&this.subs.forEach(e=>e.unsubscribe()),B.log.debug(`Peptides: view ${e.name} removed`)})),this.subs.push(B.events.onTableRemoved.subscribe(e=>{e.id===this.df.id&&this.subs.forEach(e=>e.unsubscribe()),B.log.debug(`Peptides: table ${e.name} removed`)})),this.subs.push(B.events.onProjectClosed.subscribe(e=>{e.id===B.shell.project.id&&this.subs.forEach(e=>e.unsubscribe()),B.log.debug(`Peptides: project ${e.name} closed`)})),this.fireBitsetChanged(null,!0),this.analysisView.grid.invalidate()}}findViewer(e){return et()(this.analysisView.viewers).find(t=>t.type===e)||null}addLogoSummaryTable(e){return ew(function*(){null!=e||(e={sequenceColumnName:this.settings.sequenceColumnName,clustersColumnName:et()(this.df.columns.categorical).next().value,activityColumnName:this.settings.activityColumnName,activityScaling:this.settings.activityScaling});let t=yield this.df.plot.fromType(eo.qS.LOGO_SUMMARY_TABLE,e);(0,ea.Lv)()&&this.analysisView.addViewer(t),this.analysisView.dockManager.dock(t,G.DOCK_TYPE.RIGHT,null,eo.qS.LOGO_SUMMARY_TABLE),t.viewerGrid.invalidate()}).call(this)}addClusterMaxActivityViewer(e){return ew(function*(){var t,n,i,r,o,s,a,l,u;let d=null!=(t=null!=(n=null==(s=this._mclCols)?void 0:s.find(e=>e.toLowerCase().startsWith("cluster (mcl)")))?n:null==(a=this.findViewer(eo.qS.LOGO_SUMMARY_TABLE))?void 0:a.clustersColumnName)?t:null==(l=this._sequenceSpaceCols)?void 0:l.find(e=>e.toLowerCase().startsWith("cluster"));null!=e||(e={activityColumnName:this.settings.activityColumnName,clusterColumnName:null!=d?d:null==(u=et()(this.df.columns.categorical).next().value)?void 0:u.name,activityTarget:eo.wf.HIGH,connectivityColumnName:null!=(i=null!=(r=this._mclCols.find(e=>e.toLowerCase().startsWith("connectivity")))?r:this.df.columns.names().find(e=>{var t;return e.toLowerCase().includes("connectivity")&&(null==(t=this.df.col(e))?void 0:t.isNumerical)}))?i:"",clusterSizeThreshold:20,activityThreshold:1e3});let c=yield this.df.plot.fromType(eo.qS.CLUSTER_MAX_ACTIVITY,e),h=null!=(o=this.findViewerNode(eo.qS.LOGO_SUMMARY_TABLE))?o:null;this.analysisView.dockManager.dock(c,h?G.DOCK_TYPE.DOWN:G.DOCK_TYPE.RIGHT,h,eo.qS.CLUSTER_MAX_ACTIVITY)}).call(this)}addMonomerPosition(e){return ew(function*(){null!=e||(e={maxMutations:1,activityScaling:this.settings.activityScaling,activityColumnName:this.settings.activityColumnName,sequenceColumnName:this.settings.sequenceColumnName,minActivityDelta:0,activityTarget:eo.wf.HIGH});let t=yield this.df.plot.fromType(eo.qS.SEQUENCE_VARIABILITY_MAP,e);(0,ea.Lv)()&&this.analysisView.addViewer(t);let n=this.findViewer(eo.qS.MOST_POTENT_RESIDUES),i=this.analysisView.dockManager,[r,o,s]=null===n?[G.DOCK_TYPE.DOWN,null,void 0]:[G.DOCK_TYPE.LEFT,this.findViewerNode(eo.qS.MOST_POTENT_RESIDUES),.7];i.dock(t,r,o,eo.qS.SEQUENCE_VARIABILITY_MAP,s)}).call(this)}addMostPotentResidues(e){return ew(function*(){null!=e||(e={activityScaling:this.settings.activityScaling,activityColumnName:this.settings.activityColumnName,sequenceColumnName:this.settings.sequenceColumnName,minActivityDelta:0,maxMutations:1,activityTarget:eo.wf.HIGH});let t=yield this.df.plot.fromType(eo.qS.MOST_POTENT_RESIDUES,e);(0,ea.Lv)()&&this.analysisView.addViewer(t);let n=this.findViewer(eo.qS.SEQUENCE_VARIABILITY_MAP),i=this.analysisView.dockManager,[r,o,s]=null===n?[G.DOCK_TYPE.DOWN,null,void 0]:[G.DOCK_TYPE.RIGHT,this.findViewerNode(eo.qS.SEQUENCE_VARIABILITY_MAP),.3];i.dock(t,r,o,eo.qS.MOST_POTENT_RESIDUES,s)}).call(this)}createNewView(){let e=this.getVisibleSelection(),t=this.df.clone(e);for(let[e,n]of t.tags)t.setTag(e,e===eo.gp.SETTINGS?n:"");t.name="Peptides Multiple Views",t.setTag(eo.gp.MULTIPLE_VIEWS,"1");let n=B.shell.addTableView(t),i=this.findViewer(eo.qS.LOGO_SUMMARY_TABLE);return null!=i&&n.addViewer(eo.qS.LOGO_SUMMARY_TABLE,{[`${eh.Ko.SEQUENCE}${eo.To}`]:i.sequenceColumnName,[`${eh.Ko.ACTIVITY}${eo.To}`]:i.activityColumnName,[eh.Ko.ACTIVITY_SCALING]:i.activityScaling,[eh.Ko.WEB_LOGO_MODE]:i.webLogoMode,[eh.Ko.MEMBERS_RATIO_THRESHOLD]:i.membersRatioThreshold,[`${eh.Ko.CLUSTERS}${eo.To}`]:i.clustersColumnName}),t.getTag(G.TAGS.ID)}clusterEmbeddings(){return ew(function*(){var e,t,i;if(!this._sequenceSpaceCols||0===this._sequenceSpaceCols.length)return void B.shell.warning("Embeddings columns are not initialized");let r=this._sequenceSpaceCols.filter(e=>e.toLowerCase().startsWith("embed_"));if(2!==r.length)return void B.shell.warning(`Found ${r.length} embeddings columns, expected 2`);let o=this._sequenceSpaceCols.filter(e=>e.toLowerCase().startsWith("cluster"));o.length>0&&this.df.columns.remove(o[0]);let s=this.df.getCol(r[0]).getRawData(),a=this.df.getCol(r[1]).getRawData(),l=null!=(e=this.settings.sequenceSpaceParams.epsilon)?e:.01,u=null!=(t=this.settings.sequenceSpaceParams.minPts)?t:4,d=yield(i=function*(){return new Promise(function(e,t){let i=new Worker(new URL(n.p+n.u("659"),n.b));i.postMessage({embedX:s,embedY:a,minPts:u,epsilon:l}),i.onmessage=n=>{let r=n.data,o=r.error,s=r.clusters;i.terminate(),o?t(o):e(s)}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=i.apply(e,t);function s(e){ev(o,n,r,s,a,"next",e)}function a(e){ev(o,n,r,s,a,"throw",e)}s(void 0)})})(),c=this.df.columns.getUnusedName("Cluster (DBSCAN)"),h=this.df.columns.addNewString(c);h.init(e=>d[e].toString()),null!==this._sequenceSpaceViewer&&(this._sequenceSpaceViewer.props.colorColumnName=h.name),this._sequenceSpaceCols=[r[0],r[1],h.name];let p=this.analysisView.grid.col(h.name);p&&(p.visible=!1)}).call(this)}addMCLClusters(){return ew(function*(){var e,t,n,i;if(null!==this._mclViewer)try{null==(t=this._mclViewer)||t.detach(),null==(n=this._mclViewer)||n.close()}catch(e){}0!==this._mclCols.length&&this._mclCols.forEach(e=>this.df.columns.remove(e)),this._mclCols=[];let r=this.df.getCol(this.settings.sequenceColumnName);null!=(e=this.settings).mclSettings||(e.mclSettings=new es.av);let o=this.settings.mclSettings,s=0,a=this.df.onColumnsAdded.subscribe(e=>{for(let t of e.columns)if((t.name.toLowerCase().startsWith("embed")||t.name.toLowerCase().startsWith("cluster")||t.name.toLowerCase().startsWith("connectivity"))&&t.name.toLowerCase().includes("mcl")){let e=this.analysisView.grid.col(t.name);if(null==e||this._mclCols.includes(t.name))continue;e.visible=!1,this._mclCols.push(t.name),s++}5===s&&a.unsubscribe()}),l=B.events.onViewerAdded.subscribe(e=>{try{let t=e.args.viewer;if(t.type===G.VIEWER.SCATTER_PLOT){if(this._sequenceSpaceViewer&&this.analysisView.dockManager.findNode(this._sequenceSpaceViewer.root)){let e=this.analysisView.dockManager.findNode(this._sequenceSpaceViewer.root);setTimeout(()=>{this.analysisView.dockManager.dock(t,G.DOCK_TYPE.FILL,e)})}l.unsubscribe()}}catch(e){console.error(e)}});try{let e=JSON.stringify({cols:[r].map(e=>e.name),metrics:[o.distanceF],weights:[1],aggregationMethod:z.MANHATTAN,preprocessingFuncs:["macromoleculePreprocessingFunction"],preprocessingFuncArgs:[{gapOpen:o.gapOpen,gapExtend:o.gapExtend,fingerprintType:o.fingerprintType}],threshold:o.threshold,maxIterations:o.maxIterations,useWebGPU:o.useWebGPU,inflate:o.inflation,minClusterSize:o.minClusterSize}),t=null!=(i=this.analysisView)?i:B.shell.tableView(this.df.name);if(t){let n=G.Func.find({package:"EDA",name:"markovClusteringViewer"})[0];if(!n)throw Error("Markov clustering function is not found");if(yield n.apply(),this._mclViewer=yield this.df.plot.fromType(eo.qS.MCL,{mclProps:e}),t.addViewer(this._mclViewer),yield this._mclViewer.initPromise,this._mclViewer=this.findViewer(eo.qS.MCL),!this._mclViewer||this._mclViewer.isDetached){null==l||l.unsubscribe(),null==a||a.unsubscribe();return}let i=this.findViewer(eo.qS.LOGO_SUMMARY_TABLE);i&&(i._clusterStats=null,i._clusterSelection=null,i._viewerGrid=null,i._logoSummaryTable=null,i.render())}}finally{l.unsubscribe(),a.unsubscribe()}}).call(this)}closeSequenceSpace(){if(null!==this._sequenceSpaceViewer){try{this._sequenceSpaceViewer.detach(),this._sequenceSpaceViewer.close()}catch(e){}this._sequenceSpaceViewer=null}for(let e of this._sequenceSpaceCols)this.df.columns.remove(e);this._sequenceSpaceCols=[]}addSequenceSpace(){return ew(function*(e={}){var t,n;this.closeSequenceSpace();let i=this.df.getCol(this.settings.sequenceColumnName),r=eb.Z.getSeqHelper().getSeqHandler(i);if(r.isHelm())try{B.shell.warning("Column is in HELM notation. Sequences space will linearize sequences from position 0 prior to analysis");let e=r.convert(V.Hi.SEPARATOR,"/"),t=this.df.columns.getUnusedName(`Separator(${i.name})`);e.name=t,this.df.columns.add(e,!0),this.analysisView.grid.col(t).visible=!1,i=e}catch(e){B.shell.error("Error on converting HELM notation to linear notation"),B.shell.error(e);return}let o=!e.clusterCol&&!!e.clusterEmbeddings,s=null!=(t=null==(n=this.settings)?void 0:n.sequenceSpaceParams)?t:new es.GI(o);s.clusterEmbeddings=o;let a={table:this.df,molecules:i,methodName:I.UMAP,similarityMetric:s.distanceF,plotEmbeddings:!0,options:{bypassLargeDataWarning:!0,dbScanEpsilon:s.epsilon,dbScanMinPts:s.minPts,randomSeed:"1",preprocessingFuncArgs:{gapOpen:s.gapOpen,gapExtend:s.gapExtend,fingerprintType:s.fingerprintType}},clusterEmbeddings:s.clusterEmbeddings},l=0,u=s.clusterEmbeddings?3:2,d=this.df.onColumnsAdded.subscribe(e=>{for(let t of e.columns)if(t.name.toLowerCase().startsWith("embed_")||s.clusterEmbeddings&&t.name.toLowerCase().startsWith("cluster")){let e=this.analysisView.grid.col(t.name);if(null==e||this._sequenceSpaceCols.includes(t.name))continue;e.visible=!1,this._sequenceSpaceCols.push(t.name),l++}l===u&&d.unsubscribe()}),c=B.events.onViewerAdded.subscribe(e=>{try{let t=e.args.viewer;if(t.type===G.VIEWER.SCATTER_PLOT){if(this._mclViewer&&this.analysisView.dockManager.findNode(this._mclViewer.root)){let e=this.analysisView.dockManager.findNode(this._mclViewer.root);setTimeout(()=>{this.analysisView.dockManager.dock(t,G.DOCK_TYPE.FILL,e)})}c.unsubscribe()}}catch(e){console.error(e)}}),h=yield B.functions.call("Bio:sequenceSpaceTopMenu",a);c.unsubscribe(),h instanceof G.ScatterPlotViewer&&(s.clusterEmbeddings||e.clusterCol||(h.props.colorColumnName=this.getScaledActivityColumn().name),h.props.showXSelector=!1,h.props.showYSelector=!1,e.clusterCol&&(h.props.colorColumnName=e.clusterCol.name),this._sequenceSpaceViewer=h,h.onContextMenu.subscribe(e=>{try{e.item("Modify Sequence space parameters",()=>{(0,ep.OH)(this)})}catch(e){}}))}).apply(this,arguments)}constructor(e){this.isBitsetChangedInitialized=!1,this.isUserChangedSelection=!0,this._dm=null,this.isInitialized=!1,this.isRibbonSet=!1,this.webLogoSelectedMonomers={},this.webLogoBounds={},this.highlightedRowCount=0,this.updatingSequence=!1,this.cachedWebLogoTooltip={bar:"",tooltip:null},this._layoutEventInitialized=!1,this.subs=[],this.isHighlighting=!1,this.controlFire=!1,this.accordionSource=null,this._sequenceSpaceViewer=null,this._mclViewer=null,this._monomerPositionStats=null,this._settings=null,this._sequenceSpaceCols=[],this._mclCols=[],this._webLogoSelection=null,this.df=e}}ex.modelName="peptidesModel"},4332(e,t,n){"use strict";let i,r,o,s,a;n.r(t),n.d(t,{getTreeHelperInstance:()=>dY,initPeptides:()=>dO,logoSummaryTable:()=>dR,clusterMaxActivity:()=>dD,sequencePositionStatistics:()=>dj,testInitFunctionPeptides:()=>dP,macromoleculeSarFastaDemo:()=>dz,peptidesPanel:()=>dN,mutationCliffs:()=>dL,monomerPosition:()=>dI,peptideGeneration:()=>d$,Peptides:()=>dE,manualAlignment:()=>dF,lstPiechartCellRenderer:()=>dq,peptidesDialog:()=>dT,mostPotentResidues:()=>dM,_package:()=>dW,PackageFunctions:()=>dX});var l,u,d,c,h,p,f=n(4328),m=n(7389),g=n(6082),v=n(5065),b=n(1757),y=n.n(b);n(2620);var _=n(8285);function w(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}var x=n(2747);function k(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}var S=n(3286),C=n(3629),A=n(8750),O=n(8621),E=n(4345);function T(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}let P=DG.U2,N=globalThis.DG;if((null==N||null==(u=N.U2)?void 0:u.Signal)!==void 0&&N.U2.Signal!==P.Signal)throw Error("u2: a second copy of the signal engine is bundled — build with @datagrok/build-config (it externalizes datagrok-api/u2core as DG.U2)");let I="3069a2ac22e9",M="style[data-u2-styles]",L=!1,R=!1;class j{static install(e,t,n){let i=void 0===t?65:t,r=void 0===n?I:n,o=globalThis.document;if((null==o?void 0:o.head)===void 0||null===o.head||null!==o.querySelector('meta[name="u2-styles"][content="linked"]'))return null;!R&&j.legacyCopies(o)>0&&(R=!0,console.warn(`u2: a package built before stylesheet revisions injects its own copy of the u2 CSS, which overrides revision ${i}; republish the packages that bundle u2.`));let s=o.head.querySelector(M);if(null===s)(s=o.createElement("style")).setAttribute("data-u2-styles",""),o.head.insertBefore(s,j._packageZone(o.head));else{let e=Number(s.getAttribute("data-revision"));if(e>i||e===i&&s.getAttribute("data-hash")===r)return j.installed();if(e===i)return L||console.warn(`u2: two copies of stylesheet revision ${i} differ (${s.getAttribute("data-hash")} vs ${r}) — a package was built from uncommitted u2 CSS; rebuild it.`),L=!0,j.installed()}return s.textContent=void 0===e?":root {\n--dg-steel-1: var(--steel-1, #ECEFF2);\n--dg-steel-2: var(--steel-2, #D7DFE7);\n--dg-steel-3: var(--steel-3, #B3BFCC);\n--dg-steel-4: var(--steel-4, #7990A5);\n--dg-steel-5: var(--steel-5, #40607F);\n--dg-grey-1: var(--grey-1, #F2F2F5);\n--dg-grey-2: var(--grey-2, #DBDCDF);\n--dg-grey-3: var(--grey-3, #B8BAC0);\n--dg-grey-4: var(--grey-4, #9497A0);\n--dg-grey-5: var(--grey-5, #717581);\n--dg-grey-6: var(--grey-6, #4D5261);\n--dg-warm-grey-1: var(--warm-grey-1, #F7F6F4);\n--dg-warm-grey-2: var(--warm-grey-2, #DEDDDC);\n--dg-warm-grey-3: var(--warm-grey-3, #949492);\n--dg-warm-grey-4: var(--warm-grey-4, #4A4A49);\n--dg-red-1: var(--red-1, #FBE1E1);\n--dg-red-3: var(--red-3, #EB6767);\n--dg-red-4: var(--red-4, #763434);\n--dg-green-1: var(--green-1, #DCF3E7);\n--dg-green-2: var(--green-2, #3CB173);\n--dg-green-3: var(--green-3, #286344);\n--dg-orange-1: var(--orange-1, #FFECDB);\n--dg-orange-2: var(--orange-2, #FFA24A);\n--dg-orange-3: var(--orange-3, #805125);\n--dg-beige-1: var(--beige-1, #FDFFE5);\n--dg-beige-2: var(--beige-2, #E4E6CE);\n--dg-blue-1: var(--blue-1, #2083D5);\n--dg-blue-2: var(--blue-2, #50A9C5);\n--dg-white: var(--white, #FFFFFF);\n--dg-text-color: var(--text-color, var(--dg-grey-6));\n--dg-text-color-light: var(--text-color-light, var(--dg-grey-4));\n--dg-text-color-disabled: var(--dg-grey-3);\n--dg-bg: var(--dg-white);\n--dg-bg-secondary: var(--dg-grey-1);\n--dg-accent: var(--dg-blue-1);\n--dg-accent-secondary: var(--dg-blue-2);\n--dg-success: var(--success, #006400);\n--dg-failure: var(--failure, #8B0000);\n--dg-error: var(--dg-red-3);\n--dg-hover: var(--dg-steel-1);\n--dg-hover-subtle: var(--dg-grey-1);\n--dg-selection-bg: #DCEAF8;\n--dg-selection-text: var(--dg-accent);\n--dg-grid-current-row: rgba(0, 255, 0, 0.196);\n--dg-grid-selected-row: rgba(220, 220, 80, 0.196);\n--dg-grid-mouse-over-row: rgba(184, 211, 237, 0.196);\n--dg-grid-mouse-over-stripe: #48A6F2;\n--u2-row-base-bg: var(--dg-bg);\n--u2-row-hover-bg: var(--dg-grid-mouse-over-row);\n--u2-row-hover-stripe: var(--dg-grid-mouse-over-stripe);\n--u2-row-current-bg: var(--dg-grid-current-row);\n--u2-row-selected-bg: var(--dg-selection-bg);\n--u2-section-header-bg: var(--dg-bg-secondary);\n--dg-border: var(--dg-grey-2);\n--dg-border-subtle: var(--dg-grey-1);\n--dg-focus: var(--dg-blue-1);\n--dg-focus-ring-width: 2px;\n--dg-focus-ring: var(--dg-focus-ring-width) solid var(--dg-focus);\n--dg-font-family: 'Roboto', 'Roboto Local', sans-serif;\n--dg-font-family-mono: 'Roboto Mono', 'Roboto Mono Local', monospace;\n--dg-font-size: 13px;\n--dg-font-size-small: 12px;\n--dg-font-size-xs: 10px;\n--dg-font-size-h1: 16px;\n--dg-font-size-h2: 14px;\n--dg-font-size-h3: 13px;\n--dg-font-weight-light: var(--font-weight-light, 300);\n--dg-font-weight-regular: var(--font-weight-regular, 400);\n--dg-font-weight-medium: var(--font-weight-medium, 500);\n--dg-font-weight-bold: var(--font-weight-bold, 700);\n--dg-line-height: 1.4;\n--dg-space-xs: 2px;\n--dg-space-s: 4px;\n--dg-space-m: 8px;\n--dg-space-l: 12px;\n--dg-space-xl: 16px;\n--dg-space-xxl: 24px;\n--dg-control-height: 28px;\n--dg-form-min-editor-width: 150px;\n--dg-button-height: 24px;\n--dg-inline-control-height: 22px;\n--dg-border-width: 1px;\n--dg-radius: 4px;\n--dg-radius-l: 6px;\n--dg-input-border: var(--dg-border-width) solid var(--dg-border);\n--dg-input-border-focus: var(--dg-border-width) solid var(--dg-focus);\n--dg-backdrop: color-mix(in srgb, var(--dg-steel-5) 80%, transparent);\n--dg-tour-dim: rgba(0, 0, 0, 0.6);\n--dg-shadow-1: 0 2px 8px rgba(0, 0, 0, 0.14);\n--dg-shadow-2: 0 4px 14px rgba(0, 0, 0, 0.16), 0 0 2px rgba(0, 0, 0, 0.10);\n--dg-shadow-3: 0 0 5px var(--dg-grey-6);\n--dg-overlay-border: var(--dg-border-width) solid var(--dg-border);\n--dg-z-dialog: 3000;\n--dg-z-overlay: 6000;\n}\n[data-dg-density='compact'] {\n--dg-control-height: 24px;\n--dg-button-height: 22px;\n--dg-inline-control-height: 20px;\n--dg-space-m: 6px;\n--dg-space-l: 8px;\n--dg-space-xl: 12px;\n}\n.u2-component[hidden] {\ndisplay: none !important;\n}\n.u2-icon {\ncolor: currentColor;\n}\n.u2-icon-small {\nfont-size: 12px;\n}\n.u2-icon-medium {\nfont-size: 16px;\n}\n.u2-icon-large {\nfont-size: 20px;\n}\n.u2-icon-action {\ncolor: var(--dg-text-color-light);\ncursor: pointer;\n}\n.u2-icon-action:hover {\ncolor: var(--dg-accent);\n}\n.u2-div-v {\ndisplay: flex;\nflex-direction: column;\n}\n.u2-div-h {\ndisplay: flex;\nflex-direction: row;\nalign-items: center;\n}\n.d4-ribbon-panel.u2-ribbon-pinned.u2-ribbon-overflow::before,\n.u2-catalog-overflow .u2-table .u2-table-pin-end::before {\ncontent: '';\nposition: absolute;\ntop: 0;\nbottom: 0;\nleft: -10px;\nwidth: 10px;\npointer-events: none;\nbackground: linear-gradient(to left, color-mix(in srgb, var(--dg-steel-4) 40%, transparent), transparent);\n}\n.u2-gap-xs {\ngap: var(--dg-space-xs);\n}\n.u2-gap-s {\ngap: var(--dg-space-s);\n}\n.u2-gap-m {\ngap: var(--dg-space-m);\n}\n.u2-gap-l {\ngap: var(--dg-space-l);\n}\n.u2-gap-xl {\ngap: var(--dg-space-xl);\n}\n.u2-gap-xxl {\ngap: var(--dg-space-xxl);\n}\n.u2-region-off {\nopacity: 0.5;\n}\n.u2-panel {\nbox-sizing: border-box;\npadding: var(--dg-space-l);\n}\n.u2-btn {\nbox-sizing: border-box;\ndisplay: inline-flex;\nalign-items: center;\njustify-content: center;\nflex-shrink: 0;\ngap: var(--dg-space-s);\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-m);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nfont-weight: var(--dg-font-weight-bold);\ntext-transform: uppercase;\nwhite-space: nowrap;\ncolor: var(--dg-accent);\nbackground: transparent;\nborder: none;\nborder-radius: var(--dg-radius);\ncursor: pointer;\nuser-select: none;\n}\n.u2-btn:hover:not(:disabled, [aria-disabled='true']) {\nbackground: var(--dg-hover-subtle);\n}\n.u2-btn:active:not(:disabled, [aria-disabled='true']) {\nbackground: var(--dg-hover);\n}\n.u2-btn:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: 1px;\n}\n.u2-btn:is(:disabled, [aria-disabled='true']) {\ncolor: var(--dg-text-color-disabled);\ncursor: default;\npointer-events: auto;\n}\n.u2-btn-primary {\nfont-weight: var(--dg-font-weight-regular);\ncolor: var(--dg-white);\nbackground: var(--dg-accent);\n}\n.u2-btn-primary:hover:not(:disabled, [aria-disabled='true']) {\ncolor: var(--dg-white);\nbackground: var(--dg-accent);\nfilter: contrast(90%) brightness(110%);\n}\n.u2-btn-primary:active:not(:disabled, [aria-disabled='true']) {\ncolor: var(--dg-white);\nbackground: var(--dg-accent);\nfilter: brightness(85%);\n}\n.u2-btn-primary:is(:disabled, [aria-disabled='true']) {\ncolor: var(--dg-grey-4);\nbackground: var(--dg-steel-2);\n}\n.u2-link {\ncolor: var(--dg-accent);\ntext-decoration: none;\ncursor: pointer;\n}\n.u2-link:hover {\ntext-decoration: underline;\n}\n.u2-link:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: var(--dg-space-xs);\n}\n.u2-timestamp {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\nwhite-space: nowrap;\n}\n.u2-input-root {\nposition: relative;\nbox-sizing: border-box;\ndisplay: flex;\nflex-direction: row;\nflex-wrap: wrap;\nalign-items: flex-start;\nflex-shrink: 0;\npadding: var(--dg-space-s) 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\n}\n.u2-input-label {\nbox-sizing: border-box;\ndisplay: inline-flex;\nflex-direction: column;\njustify-content: center;\nflex-shrink: 0;\nmin-width: 100px;\nheight: var(--dg-control-height);\nmargin-right: var(--dg-space-m);\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-input-required > .u2-input-label {\nflex-direction: row;\nalign-items: center;\n}\n.u2-input-required > .u2-input-label::after {\ncontent: '*';\nmargin-left: var(--dg-space-xs);\ncolor: var(--dg-error);\n}\n.u2-form:not(.u2-form-captions-left):not(.u2-form-tall) .u2-input-required > .u2-input-label,\n.u2-dialog-content > .u2-input-required > .u2-input-label {\nposition: relative;\njustify-content: flex-end;\noverflow: visible;\n}\n.u2-form:not(.u2-form-captions-left):not(.u2-form-tall) .u2-input-required > .u2-input-label::after,\n.u2-dialog-content > .u2-input-required > .u2-input-label::after {\nposition: absolute;\nleft: 100%;\nmargin-left: 1px;\n}\n.u2-input-editor {\nbox-sizing: border-box;\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-s);\nfont-family: inherit;\nfont-size: inherit;\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: none;\nborder-radius: 0;\noutline: none;\n}\ninput.u2-input-editor,\ntextarea.u2-input-editor,\n.u2-input-editor.u2-input-search {\nborder-bottom: var(--dg-input-border);\n}\n.u2-input-inline[data-u2='text-input'] > .u2-input-box > input.u2-input-editor,\n.u2-input-inline[data-u2='text-input'] > .u2-input-box > .u2-input-editor.u2-input-password,\n.u2-input-inline[data-u2='suggest-input'] > .u2-input-box > input.u2-input-editor {\nwidth: 100px;\nmin-width: 0;\n}\n.u2-input-root:not(.u2-input-inline)[data-u2='text-input'] > .u2-input-box,\n.u2-input-root:not(.u2-input-inline)[data-u2='suggest-input'] > .u2-input-box,\n.u2-input-root:not(.u2-input-inline)[data-u2='text-area'] > .u2-input-box {\nflex-grow: 1;\nmin-width: 60px;\nmax-width: none;\n}\n.u2-input-root:not(.u2-input-inline)[data-u2='text-area'] > .u2-input-box > textarea.u2-input-editor {\nflex-grow: 1;\nmin-width: 0;\n}\n.u2-input-root:not(.u2-input-inline)[data-u2='text-input'] > .u2-input-box > .u2-input-editor,\n.u2-input-root:not(.u2-input-inline)[data-u2='suggest-input'] > .u2-input-box > .u2-input-editor {\nflex-grow: 1;\nmin-width: 0;\n}\n.u2-input-root[data-u2='bigint-input'] > .u2-input-box > input.u2-input-editor,\n.u2-input-root[data-u2='qnum-input'] > .u2-input-box > input.u2-input-editor {\nwidth: 140px;\nmax-width: 150px;\nmin-width: 0;\n}\n.u2-input-root.u2-input-fill > .u2-input-box {\nflex-grow: 1;\nmin-width: 0;\nmax-width: none;\n}\n.u2-input-root.u2-input-fill > .u2-input-box > .u2-input-editor,\n.u2-input-root.u2-input-fill > .u2-input-box > input.u2-input-editor {\nflex-grow: 1;\nwidth: auto;\nmax-width: none;\nmin-width: 0;\n}\n.u2-input-readonly .u2-input-options > .u2-input-edit-option,\n.u2-input-readonly .u2-input-clear {\npointer-events: none;\n}\n.u2-input-caption-after > .u2-input-label {\norder: 1;\nmin-width: 0;\nmargin-right: 0;\ncursor: pointer;\n}\n.u2-input-caption-after > .u2-input-error {\norder: 2;\n}\ninput.u2-input-editor:focus,\ntextarea.u2-input-editor:focus,\n.u2-input-editor.u2-input-search:focus-within {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-input-editor::placeholder,\n.u2-input-search > input::placeholder {\ncolor: var(--dg-text-color-light);\n}\ntextarea.u2-input-editor {\nheight: auto;\nmin-height: calc(var(--dg-control-height) * 2);\nmax-height: calc(var(--dg-control-height) * 12);\npadding: var(--dg-space-xs) var(--dg-space-s);\nline-height: var(--dg-line-height);\nresize: vertical;\n}\n.u2-input-disabled textarea,\n.u2-input-readonly textarea {\nresize: none;\n}\n.u2-input-editor.u2-invalid,\n.u2-input-editor.u2-invalid:focus,\n.u2-input-editor.u2-invalid:focus-within,\n.u2-input-editor.u2-list.u2-invalid,\n.u2-input-editor.u2-list.u2-invalid:focus-within,\n.u2-input-editor.u2-input-password.u2-invalid,\n.u2-input-editor.u2-input-password.u2-invalid:focus-within,\n.u2-input-editor.u2-columns.u2-invalid,\n.u2-input-editor.u2-columns.u2-invalid:focus {\nborder-bottom: var(--dg-border-width) solid var(--dg-error);\n}\n.u2-input-editor.u2-radio.u2-invalid,\n.u2-input-editor.u2-multi-choice.u2-invalid {\nborder-bottom: none;\n}\n.u2-input-root[data-u2='dart-input'] .u2-input-editor.d4-input-molecule-canvas {\nflex: none;\nwidth: 100px;\nheight: 70px;\npadding: 0;\n}\n.u2-input-root[data-u2='dart-input'] > .u2-input-box {\nflex: 0 1 auto;\n}\n.u2-input-root.u2-input-fill[data-u2='dart-input'] > .u2-input-box,\n.u2-input-root.u2-input-fill[data-u2='dart-input'] > .u2-input-box > .ui-input-root {\nflex: 1 1 auto;\nmin-width: 0;\n}\n.u2-input-required[data-u2='dart-input'] .ui-input-label::after {\ncontent: '*';\nmargin-left: var(--dg-space-xs);\ncolor: var(--dg-error);\n}\n.u2-form:not(.u2-form-captions-left):not(.u2-form-tall) .u2-input-required[data-u2='dart-input'] .ui-input-label {\nposition: relative;\noverflow: visible;\n}\n.u2-form:not(.u2-form-captions-left):not(.u2-form-tall) .u2-input-required[data-u2='dart-input'] .ui-input-label::after {\nposition: absolute;\nleft: 100%;\nmargin-left: 1px;\n}\n.u2-input-root[data-u2='dart-input'] .d4-input-molecule-canvas-hint {\ncolor: var(--dg-text-color-light);\n}\n.u2-input-error {\nbox-sizing: border-box;\nflex: 1 0 100%;\nmin-width: 0;\ndisplay: -webkit-box;\n-webkit-box-orient: vertical;\n-webkit-line-clamp: 3;\noverflow: hidden;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-error);\n}\n.u2-input-error:empty {\ndisplay: none;\n}\n:where(.u2-input-root:not(.u2-input-caption-after):not(.u2-input-inline) > .u2-input-label:not(:empty)) ~ .u2-input-error {\npadding-left: calc(100px + var(--dg-space-m));\n}\n.u2-input-box {\ndisplay: inline-flex;\nalign-items: center;\nmin-width: 0;\n}\n.u2-input-loading {\ndisplay: inline-flex;\nflex-shrink: 0;\nmargin-left: var(--dg-space-s);\n}\n.u2-input-loading[hidden] {\ndisplay: none;\n}\n:where(.u2-input-root:not(.u2-input-caption-after):not([data-u2='filter-builder']):not([data-u2='filter-query-input']) > .u2-input-label) + .u2-input-box {\nflex: 1 1 0;\nmin-width: 60px;\nmax-width: max-content;\n}\n.u2-input-options {\nbox-sizing: border-box;\ndisplay: flex;\nalign-items: center;\nalign-self: flex-end;\nheight: var(--dg-control-height);\nfont-size: calc(var(--dg-font-size) / 1.2);\ncolor: var(--dg-accent);\ncursor: pointer;\n}\n.u2-input-options > * {\nmargin-left: var(--dg-space-m);\n}\n.u2-input-options > .u2-btn.u2-icon-btn {\nflex-shrink: 0;\nwidth: 16px;\nmin-width: 16px;\nheight: var(--dg-control-height);\ncolor: var(--dg-accent);\nborder-radius: 0;\n}\n.u2-input-options .u2-btn .u2-icon,\n.u2-input-eye > .u2-icon {\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nwidth: 16px;\nmin-width: 16px;\nheight: var(--dg-control-height);\nmargin: 0;\nfont-size: inherit;\n}\n.u2-input-box > .u2-input-editor + .u2-input-options {\nborder-bottom: var(--dg-input-border);\n}\n.u2-input-box:focus-within > .u2-input-editor + .u2-input-options {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-input-box > .u2-input-editor.u2-invalid + .u2-input-options {\nborder-bottom: var(--dg-border-width) solid var(--dg-error);\n}\n.u2-input-root[data-u2='bool-input'] .u2-input-options,\n.u2-input-root[data-u2='radio-input'] .u2-input-options,\n.u2-input-root[data-u2='multi-choice-input'] .u2-input-options,\n.u2-input-root[data-u2='slider-input'] .u2-input-options,\n.u2-input-root[data-u2='tags-input'] .u2-input-options,\n.u2-input-root[data-u2='multi-select'] .u2-input-options {\nalign-self: center;\nborder-bottom: none;\n}\n.u2-input-root[data-u2='bool-input'] .u2-input-postfix {\npadding-left: var(--dg-space-s);\n}\n.u2-input-postfix {\noverflow: hidden;\norder: -1;\ncolor: var(--dg-text-color-light);\nline-height: normal;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-input-inline {\npadding: 0;\n}\n.u2-input-inline .u2-input-editor {\nheight: var(--dg-inline-control-height);\n}\n.u2-input-disabled,\n.u2-input-disabled .u2-input-editor {\ncolor: var(--dg-text-color-light);\n}\n.u2-input-disabled input.u2-input-editor,\n.u2-input-disabled select.u2-input-editor,\n.u2-input-disabled textarea.u2-input-editor,\n.u2-input-disabled .u2-input-editor.u2-columns {\nbackground-color: color-mix(in srgb, var(--dg-grey-1) 40%, var(--dg-bg));\n}\n.u2-input-disabled > * {\npointer-events: none;\n}\n.u2-input-disabled .u2-input-switch {\nfilter: grayscale(1);\n}\n.u2-input-disabled .u2-input-options,\n.u2-input-disabled .u2-input-options > .u2-btn.u2-icon-btn {\ncolor: var(--dg-text-color-light);\n}\n.u2-input-editor.u2-input-search {\nposition: relative;\ndisplay: inline-flex;\nalign-items: center;\ngap: var(--dg-space-xs);\npadding: 0 var(--dg-space-xs);\n}\n.u2-input-search::before {\ncontent: '';\nflex-shrink: 0;\nwidth: 12px;\nheight: 12px;\nbackground-color: var(--dg-text-color-light);\n-webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='6.8' cy='6.8' r='4.6'/%3E%3Cpath d='M10.2 10.2 14 14'/%3E%3C/svg%3E\") no-repeat center / 12px;\nmask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='6.8' cy='6.8' r='4.6'/%3E%3Cpath d='M10.2 10.2 14 14'/%3E%3C/svg%3E\") no-repeat center / 12px;\n}\n.u2-input-search > input {\nflex: 1;\nmin-width: 0;\nheight: 100%;\npadding: 0 18px 0 var(--dg-space-xs);\nfont: inherit;\ncolor: inherit;\nbackground: none;\nborder: none;\noutline: none;\n}\n.u2-input-clear {\nposition: absolute;\nright: 2px;\nflex-shrink: 0;\nwidth: 16px;\nheight: 16px;\npadding: 0;\nfont-size: var(--dg-font-size-xs);\nline-height: 1;\ncolor: var(--dg-accent);\nvisibility: hidden;\nbackground: none;\nborder: none;\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-input-root:not(.u2-input-disabled):hover .u2-input-clear,\n:not(.u2-input-disabled) > .u2-input-box:hover .u2-input-clear {\nvisibility: visible;\n}\n.u2-input-clear:hover {\ncolor: var(--dg-accent-secondary);\n}\n.u2-input-clear[hidden] {\ndisplay: none;\n}\n.u2-input-box > .u2-input-editor.u2-input-bool {\ndisplay: inline-flex;\nalign-items: center;\nflex: none;\npadding: 0 var(--dg-space-s);\n}\n.u2-input-checkbox {\nwidth: 13px;\nheight: 13px;\nmargin: 0;\nborder: none;\naccent-color: var(--dg-accent);\ncursor: pointer;\n}\n.u2-input-switch {\ndisplay: inline-flex;\nalign-items: center;\nwidth: 22px;\nheight: 4px;\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: 9px;\noutline: none;\ncursor: pointer;\n}\n.u2-input-switch:hover {\nborder-color: var(--dg-grey-3);\n}\n.u2-input-switch:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: var(--dg-space-s);\n}\n.u2-input-switch-thumb {\nposition: relative;\nleft: -4px;\nwidth: 12px;\nheight: 12px;\nmargin: 2px;\nbackground: var(--dg-grey-2);\nborder: var(--dg-border-width) solid var(--dg-grey-2);\nborder-radius: 50%;\ntransition: left 0.2s;\n}\n.u2-input-switch:hover .u2-input-switch-thumb {\nborder-color: var(--dg-grey-3);\n}\n.u2-input-switch-on {\nbackground: var(--dg-steel-2);\nborder-color: var(--dg-steel-2);\n}\n.u2-input-switch-on .u2-input-switch-thumb {\nleft: 8px;\nbackground: var(--dg-accent);\nborder-color: var(--dg-accent);\n}\n.u2-input-editor.u2-list {\nposition: static;\ndisplay: inline-flex;\nalign-items: flex-start;\nheight: auto;\npadding: 0;\noverflow: visible;\nborder: none;\nborder-bottom: var(--dg-input-border);\n}\n.u2-input-editor.u2-list:focus-within {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-list-text {\nflex: 1 1 auto;\nmin-width: 0;\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-s);\nfont: inherit;\ncolor: inherit;\ntext-overflow: ellipsis;\nbackground: none;\nborder: none;\noutline: none;\n}\n.u2-list-text[hidden] {\ndisplay: none;\n}\ntextarea.u2-list-area {\nmin-height: calc(var(--dg-control-height) * 3);\npadding: var(--dg-space-xs);\nline-height: var(--dg-line-height);\nresize: vertical;\n}\n.u2-input-editor.u2-map {\ndisplay: flex;\nflex: 1;\nflex-direction: column;\nmin-width: 0;\nheight: auto;\npadding: 0;\n}\n.u2-input-root:not(.u2-input-inline)[data-u2='map-input'] > .u2-input-box {\nflex: 1 1 0;\nmin-width: var(--dg-form-min-editor-width);\nmax-width: none;\n}\n.u2-input-root:not(.u2-input-inline)[data-u2='map-input'] .u2-map-key,\n.u2-input-root:not(.u2-input-inline)[data-u2='map-input'] .u2-map-value {\nwidth: 0;\n}\n.u2-map-row {\ndisplay: flex;\nalign-items: center;\nheight: var(--dg-control-height);\ngap: var(--dg-space-m);\n}\n.u2-map-actions {\ndisplay: flex;\nalign-items: center;\nflex-shrink: 0;\n}\n.u2-map-key,\n.u2-map-value {\nbox-sizing: border-box;\nflex: 1 1 0;\nmin-width: 0;\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-s);\nfont: inherit;\ncolor: inherit;\nbackground: none;\nborder: none;\nborder-bottom: var(--dg-input-border);\noutline: none;\n}\n.u2-map-key:focus,\n.u2-map-value:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-map-key.u2-invalid {\nborder-bottom: var(--dg-border-width) solid var(--dg-error);\n}\n.u2-map-btn {\ndisplay: inline-flex;\nalign-items: center;\njustify-content: center;\nflex-shrink: 0;\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-m);\nfont-size: var(--dg-font-size);\nline-height: 1;\ncolor: var(--dg-accent);\nbackground: none;\nborder: none;\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-map-btn > .u2-icon {\nmin-width: 16px;\n}\n.u2-map-btn:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-input-editor.u2-dynamic {\ndisplay: flex;\nalign-items: center;\nheight: auto;\nmin-height: var(--dg-control-height);\npadding: 0 var(--dg-space-s);\n}\n.u2-input-null {\ncolor: var(--dg-text-color-light);\n}\n.u2-input-editor.u2-input-password {\nposition: relative;\ndisplay: inline-flex;\nalign-items: center;\npadding: 0;\nborder-bottom: var(--dg-input-border);\n}\n.u2-input-editor.u2-input-password:focus-within {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-input-password > input {\nflex: 1;\nmin-width: 0;\nheight: 100%;\npadding: 0 calc(18px + var(--dg-space-xs)) 0 var(--dg-space-s);\nfont: inherit;\ncolor: inherit;\nbackground: none;\nborder: none;\noutline: none;\n}\n.u2-input-eye {\nposition: absolute;\nright: 2px;\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nflex-shrink: 0;\nwidth: 16px;\nheight: var(--dg-control-height);\npadding: 0;\ncolor: var(--dg-text-color);\nbackground: none;\nborder: none;\ncursor: pointer;\n}\n.u2-input-measure {\nposition: absolute;\nvisibility: hidden;\nfont: inherit;\nwhite-space: pre;\n}\n.u2-input-root[data-u2='image-input'] > .u2-input-box {\nflex: 1 1 0;\nmin-width: 0;\n}\n.u2-input-editor.u2-image {\nposition: relative;\ndisplay: inline-flex;\nalign-items: center;\nmax-width: 100%;\nheight: auto;\npadding: 0;\n}\n.u2-form-wide .u2-input-root[data-u2='image-input'] .u2-input-editor.u2-image {\nflex: 0 1 auto;\n}\n.u2-image-preview {\nwidth: 300px;\nmax-width: 100%;\nheight: auto;\naspect-ratio: 3 / 2;\n}\n.u2-image-preview[hidden] {\ndisplay: none;\n}\n.u2-input-disabled .u2-image-preview {\nopacity: 0.5;\n}\n.u2-image-remove {\nposition: absolute;\ntop: 10px;\nright: 10px;\npadding: 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-accent);\nvisibility: hidden;\nbackground: none;\nborder: none;\ncursor: pointer;\n}\n.u2-image:hover .u2-image-remove {\nvisibility: visible;\n}\n.u2-image-remove:hover {\ntext-decoration: underline;\n}\n.u2-image-remove[hidden] {\ndisplay: none;\n}\n.u2-column-row {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nmin-width: 0;\n}\n.u2-column-glyph {\nflex-shrink: 0;\ncolor: var(--dg-text-color-light);\n}\n.u2-column-name {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-column-semtype {\nmargin-left: auto;\npadding-left: var(--dg-space-m);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-input-editor.u2-columns {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nmin-width: 100px;\nborder-bottom: var(--dg-input-border);\ncursor: pointer;\n}\n.u2-input-editor.u2-columns:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-columns-summary {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-columns-chevron {\nflex-shrink: 0;\nalign-self: stretch;\nwidth: 16px;\nheight: auto;\nmargin: 0 calc(-1 * var(--dg-space-s)) 0 auto;\nborder: none;\nbackground-image:\nlinear-gradient(to top right, transparent calc(50% - 0.8px), currentColor calc(50% - 0.8px),\ncurrentColor calc(50% + 0.8px), transparent calc(50% + 0.8px)),\nlinear-gradient(to bottom right, transparent calc(50% - 0.8px), currentColor calc(50% - 0.8px),\ncurrentColor calc(50% + 0.8px), transparent calc(50% + 0.8px));\nbackground-repeat: no-repeat;\nbackground-position: right 8px top 55%, right 3.5px top 55%;\nbackground-size: 4.5px 4.5px, 4.5px 4.5px;\n}\n.u2-input-editor.u2-columns[aria-disabled='true'] {\ncursor: default;\n}\n.u2-columns[aria-disabled='true'] .u2-columns-summary,\n.u2-columns[aria-disabled='true'] .u2-columns-chevron {\ncolor: var(--dg-text-color-disabled);\n}\n.u2-columns.u2-invalid .u2-columns-summary,\n.u2-columns.u2-invalid .u2-columns-chevron {\ncolor: var(--dg-error);\n}\n.u2-columns-popup {\nbox-sizing: border-box;\npadding: var(--dg-space-xs) var(--dg-space-m);\noverflow: hidden;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-columns-buttons {\nflex-shrink: 0;\njustify-content: flex-end;\ngap: var(--dg-space-s);\npadding-top: var(--dg-space-xs);\n}\n.u2-columns-popup > .d4-column-grid {\nflex: 0 1 auto;\nmin-height: 0;\noverflow: hidden;\n}\n.u2-columns-actions {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\npadding: var(--dg-space-xs) 0;\n}\n.u2-columns-count {\nmargin-left: auto;\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-columns-list {\nflex: 0 1 auto;\nmin-width: 240px;\nmin-height: 0;\nheight: 192px;\n}\n.u2-columns-option {\npadding: 0 var(--dg-space-s);\n}\n.u2-list-row.u2-columns-picked {\nbackground: var(--dg-selection-bg);\ncolor: var(--dg-selection-text);\n}\n.u2-column-combo-host {\noverflow: hidden;\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-column-combo-none {\nflex: 1;\nmin-height: 100%;\n}\n.u2-input-editor.u2-columns-map,\n.u2-input-editor.u2-aggregations {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-xs);\nheight: auto;\npadding: 0 var(--dg-space-s);\n}\n.u2-columns-map > .u2-input-root:first-child {\npadding-top: 0;\n}\n.u2-input-editor.u2-columns-map .u2-input-label {\nmin-width: 0;\n}\n.u2-aggregations-row {\ndisplay: flex;\nflex-wrap: wrap;\nalign-items: center;\ngap: var(--dg-space-s);\n}\n.u2-aggregations-row > .u2-input-root {\nflex: 1 1 96px;\nmin-width: 0;\n}\n.u2-aggregations-row > .u2-input-root:nth-child(2) {\nflex: 0 0 72px;\n}\n.u2-property-editor {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-s);\n}\n.u2-property-editor-typed:has(.u2-input-root) {\npadding-top: var(--dg-space-s);\nborder-top: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-input-root[hidden] {\ndisplay: none;\n}\n.u2-suggest-popup {\nbox-sizing: border-box;\noverflow-y: auto;\npadding: var(--dg-space-xs) 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-suggest-option {\npadding: var(--dg-space-xs) var(--dg-space-m);\ncursor: pointer;\n}\n.u2-suggest-option:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-suggest-option-active {\nbackground: var(--dg-selection-bg);\n}\n.u2-suggest-option-current {\nfont-weight: var(--dg-font-weight-bold);\n}\n.u2-suggest-loading,\n.u2-suggest-empty,\n.u2-suggest-error,\n.u2-suggest-hint {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\npadding: var(--dg-space-xs) var(--dg-space-m);\ncolor: var(--dg-text-color-light);\n}\n.u2-suggest-footer {\nposition: sticky;\nbottom: 0;\npadding: var(--dg-space-xs) var(--dg-space-m);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\nbackground: var(--dg-bg);\nborder-top: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-suggest-footer[hidden] {\ndisplay: none;\n}\n.u2-suggest-retry {\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-m);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg-secondary);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-suggest-retry:hover {\nbackground: var(--dg-hover);\n}\n.u2-quiet {\n--dg-input-border: var(--dg-border-width) solid transparent;\n}\n.u2-quiet :is(.u2-input-editor, .u2-map-key, .u2-map-value) {\nbackground-color: transparent;\n}\n.u2-quiet :is(input.u2-input-editor, .u2-map-key, .u2-map-value):not(:focus) {\ntext-overflow: ellipsis;\n}\n.u2-quiet .u2-input-root:not([data-u2='map-input']):hover,\n.u2-quiet .u2-input-root.u2-input-empty,\n.u2-quiet .u2-map-row:hover,\n.u2-quiet :is(input, textarea):placeholder-shown {\n--dg-input-border: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-quiet .u2-map-row:not(:hover):not(:focus-within):not(:last-child) > .u2-map-actions {\nvisibility: hidden;\n}\n.u2-input-editor.u2-number {\nposition: relative;\ndisplay: flex;\nflex-direction: column;\nwidth: 140px;\nmax-width: 150px;\nmin-width: 0;\npadding: 0;\n}\n.u2-input-editor.u2-number,\n.u2-input-editor.u2-number.u2-invalid {\nborder-bottom: none;\n}\n.u2-number-box {\nposition: relative;\ndisplay: inline-flex;\nalign-items: center;\nheight: 100%;\nborder-bottom: var(--dg-input-border);\n}\n.u2-number-box:focus-within {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-number.u2-invalid .u2-number-box,\n.u2-number.u2-invalid .u2-number-box:focus-within {\nborder-bottom: var(--dg-border-width) solid var(--dg-error);\n}\n.u2-number-box > input {\nflex: 1;\nmin-width: 0;\nheight: 100%;\npadding: 0 var(--dg-space-s);\nfont: inherit;\ncolor: inherit;\nbackground: none;\nborder: none;\noutline: none;\n}\n.u2-number-box > input::placeholder {\ncolor: var(--dg-text-color-light);\n}\n.u2-number-box:has(> .u2-number-spinner) > input {\npadding-right: var(--dg-space-xl);\n}\n.u2-number-spinner {\nposition: absolute;\ntop: 0;\nright: var(--dg-space-xs);\nbottom: 0;\ndisplay: flex;\nflex-direction: column;\njustify-content: center;\nvisibility: hidden;\n}\n.u2-number-box:hover .u2-number-spinner,\n.u2-number-box:focus-within .u2-number-spinner {\nvisibility: visible;\n}\n.u2-number-spin {\ndisplay: block;\nwidth: 12px;\nheight: 9px;\npadding: 0;\nfont-size: var(--dg-font-size-xs);\nline-height: 9px;\ncolor: var(--dg-text-color-light);\nbackground: none;\nborder: none;\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-number-spin:hover {\ncolor: var(--dg-accent);\nbackground: var(--dg-hover-subtle);\n}\n.u2-number-click > .u2-icon {\nwidth: 100%;\nmin-width: 100%;\nheight: 100%;\nmargin: 0;\nfont-size: inherit;\n}\n.u2-number-click {\nflex-shrink: 0;\ndisplay: flex;\nalign-items: center;\njustify-content: center;\norder: -2;\nwidth: 20px;\nheight: 20px;\npadding: 0;\nfont-size: var(--dg-font-size-small);\nline-height: 1;\ncolor: var(--dg-accent);\nvisibility: hidden;\nbackground: none;\nborder: none;\nborder-radius: 2px;\ncursor: pointer;\n}\n.u2-number-click:hover {\nbackground: var(--dg-selection-bg);\n}\n.u2-number-click:active {\nfilter: brightness(90%) contrast(90%);\n}\n.u2-input-box:has(> .u2-input-editor.u2-number > .u2-number-slider) {\npadding-bottom: 9px;\n}\n.u2-number-slider {\nposition: absolute;\nright: 0;\nbottom: -9px;\nwidth: 100%;\nheight: 18px;\nmargin: 0;\nz-index: 2;\nvisibility: hidden;\naccent-color: var(--dg-accent);\noutline: none;\ncursor: pointer;\n}\n.u2-input-root:not(.u2-input-disabled):hover .u2-number-slider,\n.u2-input-root:not(.u2-input-disabled):hover .u2-number-click,\n:not(.u2-input-disabled) > .u2-input-box:hover .u2-number-slider,\n:not(.u2-input-disabled) > .u2-input-box:hover .u2-number-click {\nvisibility: visible;\n}\n.u2-number-slider:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: var(--dg-space-s);\n}\n.u2-input-editor.u2-slider {\ndisplay: inline-flex;\nalign-items: center;\nmax-width: 300px;\npadding: 0;\nborder: none;\n}\n.u2-slider-track {\nflex: 1;\nmin-width: 0;\nheight: var(--dg-space-s);\nmargin: 0;\npadding: 0;\naccent-color: var(--dg-accent);\nbackground: var(--dg-border);\nborder: none;\nborder-radius: var(--dg-radius);\noutline: none;\ncursor: pointer;\n}\n.u2-slider-track:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: var(--dg-space-s);\n}\n.u2-range-slider {\nposition: relative;\nwidth: calc(100% - 12px);\nmin-width: 60px;\nheight: 16px;\nmargin: 0 6px;\ntouch-action: none;\ncursor: pointer;\n}\n.u2-range-slider-vertical {\nwidth: 16px;\nheight: calc(100% - 12px);\nmin-height: 60px;\nmargin: 6px 0;\n}\n.u2-range-track {\nposition: absolute;\nleft: 0;\nright: 0;\ntop: 50%;\nheight: var(--dg-space-s);\ntransform: translateY(-50%);\nbackground: var(--dg-border);\nborder-radius: var(--dg-radius);\n}\n.u2-range-band {\nposition: absolute;\ntop: 50%;\nheight: var(--dg-space-s);\ntransform: translateY(-50%);\nbackground: var(--dg-accent);\nborder-radius: var(--dg-radius);\ncursor: grab;\n}\n.u2-range-handle {\nposition: absolute;\ntop: 50%;\nwidth: 12px;\nheight: 12px;\ntransform: translate(-50%, -50%);\nbackground: var(--dg-white);\nborder: var(--dg-border-width) solid var(--dg-accent);\nborder-radius: 50%;\nbox-shadow: var(--dg-shadow-1);\ncursor: ew-resize;\n}\n.u2-range-handle:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: var(--dg-space-xs);\n}\n.u2-range-slider-vertical .u2-range-track {\nleft: 50%;\nright: auto;\ntop: 0;\nbottom: 0;\nheight: auto;\nwidth: var(--dg-space-s);\ntransform: translateX(-50%);\n}\n.u2-range-slider-vertical .u2-range-band {\nleft: 50%;\ntop: auto;\nheight: auto;\nwidth: var(--dg-space-s);\ntransform: translateX(-50%);\n}\n.u2-range-slider-vertical .u2-range-handle {\nleft: 50%;\ntop: auto;\ntransform: translate(-50%, 50%);\ncursor: ns-resize;\n}\n.u2-input-editor.u2-radio {\ndisplay: inline-flex;\nflex-direction: column;\nalign-items: flex-start;\nheight: auto;\nmin-height: var(--dg-control-height);\npadding: 0;\n}\n.u2-radio-item {\ndisplay: inline-flex;\nalign-items: center;\nheight: 20px;\nmargin-right: var(--dg-space-m);\ncursor: pointer;\n}\n.u2-radio-item > .u2-input-radio {\nmargin: 0 var(--dg-space-m) 0 var(--dg-space-s);\n}\n.u2-input-radio {\nwidth: 13px;\nheight: 13px;\nmargin: 0;\nborder: none;\naccent-color: var(--dg-accent);\ncursor: pointer;\n}\n.u2-radio-buttons,\n.u2-input-editor.u2-radio.u2-radio-buttons {\nflex-direction: row;\nalign-items: center;\npadding: var(--dg-space-xs) 0;\n}\n.u2-radio-buttons .u2-radio-item {\nheight: var(--dg-button-height);\nmargin: 0 var(--dg-space-s);\npadding: 0 var(--dg-space-m);\ncolor: var(--dg-accent-secondary);\nbackground: var(--dg-bg-secondary);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\n}\n.u2-radio-buttons .u2-radio-item:hover {\nbackground: var(--dg-hover);\n}\n.u2-radio-buttons .u2-input-radio {\nposition: absolute;\nwidth: 1px;\nheight: 1px;\nmargin: -1px;\noverflow: hidden;\nclip-path: inset(50%);\n}\n.u2-radio-buttons .u2-radio-pressed {\ncolor: var(--dg-white);\nbackground: var(--dg-accent);\nborder-color: var(--dg-accent);\n}\n.u2-radio-buttons .u2-radio-item:focus-within {\noutline: var(--dg-focus-ring);\noutline-offset: var(--dg-space-xs);\n}\ninput.u2-input-editor.u2-color-text {\nwidth: 100px;\nmax-width: 100px;\nmin-width: 0;\npadding: 0 var(--dg-space-s);\nmargin-right: -18px;\ntext-transform: lowercase;\n}\n.u2-color-text[hidden] {\ndisplay: none;\n}\n.u2-input-options > .u2-color-box {\nmargin-left: 0;\n}\n.u2-color-box {\nposition: relative;\ndisplay: inline-flex;\nalign-items: center;\njustify-content: center;\nmin-width: 18px;\n}\n.u2-color-swatch {\nbox-sizing: content-box;\nflex-shrink: 0;\nwidth: 12px;\nheight: 12px;\npadding: 0;\ncolor: inherit;\nborder: var(--dg-border-width) solid var(--dg-grey-2);\nborder-radius: 0;\ncursor: pointer;\n}\n.u2-color-swatch:hover {\nborder-color: var(--dg-grey-3);\n}\n.u2-color-swatch:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: var(--dg-space-xs);\n}\n.u2-color-picker {\nposition: absolute;\nright: 0;\nwidth: 14px;\nheight: 14px;\npadding: 0;\nborder: none;\nopacity: 0;\npointer-events: none;\n}\n.u2-color-box-only .u2-input-box > .u2-input-editor + .u2-input-options {\nmargin-left: var(--dg-space-s);\nborder-bottom: none;\n}\n.u2-color-box-only .u2-color-swatch {\nwidth: 24px;\nheight: 18px;\n}\n.u2-input-editor.u2-date {\nposition: relative;\ndisplay: inline-flex;\nalign-items: center;\nwidth: 140px;\nmax-width: 140px;\nmin-width: 0;\npadding: 0;\n}\n.u2-input-editor.u2-date:not(.u2-invalid) {\nborder-bottom: var(--dg-input-border);\n}\n.u2-input-editor.u2-date:not(.u2-invalid):focus-within,\n.u2-input-editor.u2-date:not(.u2-invalid).u2-date-open {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-date > input {\nflex: 1;\nmin-width: 110px;\nheight: 100%;\npadding: 0 var(--dg-space-s);\nfont: inherit;\ncolor: inherit;\nbackground: none;\nborder: none;\noutline: none;\n}\n.u2-date > input::placeholder {\ncolor: var(--dg-text-color-light);\n}\n.u2-input-root[data-u2='date-input'] .u2-input-box > .u2-input-editor + .u2-input-options,\n.u2-input-root[data-u2='datetime-input'] .u2-input-box > .u2-input-editor + .u2-input-options {\nalign-self: flex-start;\nborder-bottom: none;\n}\n.u2-date-popup {\nbox-sizing: border-box;\ndisplay: flex;\nflex-direction: column;\npadding: var(--dg-space-s);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\noutline: none;\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-date-header {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-xs);\npadding-bottom: var(--dg-space-s);\n}\n.u2-date-title {\nflex: 1;\ntext-align: center;\nwhite-space: nowrap;\nfont-weight: var(--dg-font-weight-medium);\n}\n.u2-date-header .u2-btn:not(.u2-icon-btn) {\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-m);\n}\n.u2-date-weekdays,\n.u2-date-week {\ndisplay: flex;\n}\n.u2-date-weekday {\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nwidth: var(--dg-inline-control-height);\nheight: var(--dg-inline-control-height);\nfont-size: var(--dg-font-size-xs);\ncolor: var(--dg-text-color-light);\n}\n.u2-date-day {\nbox-sizing: border-box;\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nwidth: var(--dg-inline-control-height);\nheight: var(--dg-inline-control-height);\nborder: var(--dg-border-width) solid transparent;\nborder-radius: var(--dg-radius);\noutline: none;\ncursor: pointer;\n}\n.u2-date-day:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-date-day:focus-visible {\nborder-color: var(--dg-focus);\n}\n.u2-date-adjacent {\ncolor: var(--dg-text-color-disabled);\n}\n.u2-date-today {\nborder-color: var(--dg-accent);\n}\n.u2-date-selected {\ncolor: var(--dg-selection-text);\nbackground: var(--dg-selection-bg);\nfont-weight: var(--dg-font-weight-medium);\n}\n.u2-date-day-disabled,\n.u2-date-day-disabled:hover {\ncolor: var(--dg-text-color-disabled);\nbackground: none;\ncursor: default;\n}\n.u2-date-time {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-xs);\nmargin-top: var(--dg-space-s);\npadding-top: var(--dg-space-s);\nborder-top: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-date-time-label {\nflex: 1;\ncolor: var(--dg-text-color-light);\n}\n.u2-date-time-sep {\ncolor: var(--dg-text-color-light);\n}\n.u2-date-time-seg {\nbox-sizing: border-box;\nwidth: 26px;\nheight: var(--dg-inline-control-height);\npadding: 0;\nfont-family: inherit;\nfont-size: inherit;\ntext-align: center;\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: none;\nborder-bottom: var(--dg-input-border);\nborder-radius: 0;\noutline: none;\n}\n.u2-date-time-seg:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-input-editor.u2-font {\ndisplay: inline-flex;\nalign-items: center;\npadding: 0;\nfont-size: 11px;\n}\n.u2-font-size {\nbox-sizing: border-box;\nwidth: 27px;\nheight: 16px;\npadding: 0 3px;\nfont-family: inherit;\nfont-size: inherit;\ncolor: inherit;\nline-height: 14px;\ntext-align: left;\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid transparent;\nborder-radius: 2px;\noutline: none;\n}\n.u2-font-size:focus {\nborder-color: var(--dg-steel-4);\n}\n.u2-font-step {\ndisplay: inline-flex;\nalign-items: center;\njustify-content: center;\nflex-shrink: 0;\nwidth: 16px;\nheight: 16px;\nmargin-left: var(--dg-space-xs);\npadding: 0;\nfont-size: inherit;\ncolor: var(--dg-accent);\nbackground: none;\nborder: none;\nborder-radius: 2px;\ncursor: pointer;\n}\n.u2-font-step > .u2-icon {\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nwidth: 16px;\nmin-width: 16px;\nheight: 16px;\nmargin: 0;\nfont-size: inherit;\n}\n.u2-font-step:hover {\nbackground: var(--dg-steel-1);\n}\n.u2-font-family {\nbox-sizing: border-box;\nwidth: 80px;\nmin-width: 0;\nheight: 18px;\nmargin-left: var(--dg-space-s);\npadding: 0 12px 0 3px;\nfont-family: inherit;\nfont-size: inherit;\ncolor: inherit;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n-webkit-appearance: none;\n-moz-appearance: none;\nappearance: none;\nbackground-color: var(--dg-bg);\nbackground-image:\nlinear-gradient(45deg, transparent 50%, var(--dg-steel-5) 50%),\nlinear-gradient(135deg, var(--dg-steel-5) 50%, transparent 50%);\nbackground-repeat: no-repeat;\nbackground-position: right 6px center, right 2px center;\nbackground-size: 4px 4px, 4px 4px;\nborder: var(--dg-border-width) solid transparent;\nborder-radius: 2px;\noutline: none;\n}\n.u2-font-family:focus {\nborder-color: var(--dg-steel-4);\n}\n.u2-font-toggle {\nflex-shrink: 0;\nwidth: 14px;\nheight: 14px;\nmargin-left: var(--dg-space-s);\npadding: 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: 14px;\ncolor: var(--dg-text-color);\nbackground: none;\nborder: var(--dg-border-width) solid transparent;\nborder-radius: 2px;\ncursor: pointer;\n}\n.u2-font-bold {\nfont-weight: var(--dg-font-weight-bold);\n}\n.u2-font-italic {\nfont-family: 'Times New Roman', Georgia, serif;\nfont-weight: 600;\nfont-style: italic;\n}\n.u2-font-toggle:hover:not(.u2-font-toggle-active) {\nbackground: var(--dg-grey-1);\nborder-color: var(--dg-steel-4);\n}\n.u2-font-toggle-active {\nbackground: var(--dg-grey-2);\nborder-color: var(--dg-grey-2);\nbox-shadow: var(--dg-shadow-1);\n}\n.u2-font-toggle:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: var(--dg-space-xs);\n}\n.u2-font-sizes {\nbox-sizing: border-box;\noverflow-y: auto;\npadding: var(--dg-space-xs) 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\ntext-align: right;\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-font-size-option {\npadding: var(--dg-space-xs) var(--dg-space-m);\ncursor: pointer;\n}\n.u2-font-size-option:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-input-editor.u2-tags {\ndisplay: flex;\nflex-wrap: wrap;\nalign-items: center;\ngap: var(--dg-space-s);\nheight: auto;\nmin-height: var(--dg-control-height);\npadding: var(--dg-space-xs) var(--dg-space-s);\nborder-bottom: var(--dg-input-border);\ncursor: text;\n}\n.u2-input-editor.u2-tags:focus-within {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-tags-chips {\ndisplay: flex;\nflex-wrap: wrap;\ngap: var(--dg-space-s);\n}\n.u2-tags-chips:empty {\ndisplay: none;\n}\n.u2-tags-input {\nflex: 1;\nmin-width: 80px;\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-xs);\nfont: inherit;\ncolor: inherit;\nbackground: none;\nborder: none;\noutline: none;\n}\n.u2-tags-input::placeholder {\ncolor: var(--dg-text-color-light);\n}\n.u2-tags-option-active .u2-tags-text {\ncolor: var(--dg-accent);\n}\n.u2-tags-text {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-input-editor.u2-chips {\ndisplay: flex;\nflex-wrap: wrap;\ngap: var(--dg-space-s);\nmin-height: var(--dg-control-height);\nalign-items: center;\n}\n.u2-chips-chip {\ndisplay: inline-flex;\nbox-sizing: border-box;\nalign-items: center;\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-m);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size-small);\nline-height: 1;\ncolor: var(--dg-text-color);\nwhite-space: nowrap;\nbackground: var(--dg-bg-secondary);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: 11px;\ncursor: pointer;\n}\n.u2-chips-chip:hover {\nbackground: var(--dg-hover);\n}\n.u2-chips-chip:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: 1px;\n}\n.u2-chips-chip-on {\ncolor: var(--dg-white);\nbackground: var(--dg-accent);\nborder-color: var(--dg-accent);\n}\n.u2-chips-chip-on:hover {\nbackground: var(--dg-accent);\n}\n.u2-chips-chip:disabled {\ncolor: var(--dg-text-color-disabled);\ncursor: default;\n}\n.u2-chips-empty {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\nselect.u2-input-editor {\n-webkit-appearance: none;\n-moz-appearance: none;\nappearance: none;\nwidth: 200px;\nmin-width: 0;\npadding: 0 20px 0 0;\nborder-bottom: var(--dg-input-border);\ncursor: pointer;\nbackground-image:\nlinear-gradient(to top right, transparent calc(50% - 0.8px), var(--dg-text-color) calc(50% - 0.8px),\nvar(--dg-text-color) calc(50% + 0.8px), transparent calc(50% + 0.8px)),\nlinear-gradient(to bottom right, transparent calc(50% - 0.8px), var(--dg-text-color) calc(50% - 0.8px),\nvar(--dg-text-color) calc(50% + 0.8px), transparent calc(50% + 0.8px));\nbackground-repeat: no-repeat;\nbackground-position: right 8px top 55%, right 3.5px top 55%;\nbackground-size: 4.5px 4.5px, 4.5px 4.5px;\n}\n.u2-form select.u2-input-editor,\n.u2-dialog-content > .u2-input-root select.u2-input-editor {\npadding-left: var(--dg-space-s);\n}\n:where([data-u2='choice-input'] > .u2-input-box) > select.u2-input-editor {\nwidth: var(--u2-choice-width, 200px);\n}\nselect.u2-input-editor:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\nselect.u2-input-editor.u2-invalid,\nselect.u2-input-editor.u2-invalid:focus {\nborder-bottom: var(--dg-border-width) solid var(--dg-error);\n}\n.u2-input-disabled select.u2-input-editor,\n.u2-input-readonly select.u2-input-editor {\nbackground-image: none;\ncursor: default;\n}\ndiv.u2-input-editor.u2-multi-choice {\ndisplay: flex;\nflex-direction: column;\nmin-width: 150px;\nheight: auto;\npadding: var(--dg-space-s) 0;\nborder: none;\n}\n.u2-multi-choice-item {\ndisplay: flex;\nalign-items: center;\nheight: 20px;\npadding: 0;\nwhite-space: nowrap;\ncursor: pointer;\n}\n.u2-multi-choice-item > .u2-input-checkbox,\n.u2-multi-choice-summary > .u2-input-checkbox {\nmargin: 0 var(--dg-space-m) 0 var(--dg-space-s);\n}\n.u2-multi-choice-summary {\ndisplay: flex;\nalign-items: center;\nheight: 20px;\nwhite-space: nowrap;\n}\n.u2-multi-choice-summary:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-multi-choice-summary-toggle {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\ncursor: pointer;\nuser-select: none;\n}\n.u2-multi-choice-summary-toggle:focus-visible {\noutline: var(--dg-focus-ring);\n}\n.u2-multi-choice-chevron {\ndisplay: flex;\nalign-items: center;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\ntransition: transform 100ms ease;\n}\n.u2-multi-choice-summary-toggle[aria-expanded='false'] .u2-multi-choice-chevron {\ntransform: rotate(-90deg);\n}\n.u2-multi-choice-item:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-multi-choice-empty {\ndisplay: flex;\nalign-items: center;\nheight: 20px;\npadding: 0 var(--dg-space-s);\ncolor: var(--dg-text-color-light);\nwhite-space: nowrap;\n}\n.u2-choice-chip {\ndisplay: inline-flex;\nalign-items: center;\ngap: 5px;\nbox-sizing: border-box;\nmin-width: 64px;\nheight: var(--dg-button-height);\npadding: 0 8px 0 10px;\nfont: inherit;\ncolor: var(--dg-grey-6);\nbackground: var(--dg-grey-1);\nborder: var(--dg-border-width) solid transparent;\nborder-radius: 12px;\ncursor: pointer;\n}\n.u2-choice-chip:hover {\nbackground: var(--dg-grey-2);\n}\n.u2-choice-chip:focus-visible {\noutline: var(--dg-border-width) solid var(--dg-blue-1);\n}\n.u2-choice-chip[aria-expanded='true'],\n.u2-choice-chip-active {\nbackground: var(--dg-bg);\nborder-color: var(--dg-blue-1);\n}\n.u2-choice-chip-label {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-grey-4);\n}\n.u2-choice-chip-value {\nfont-weight: var(--dg-font-weight-medium);\n}\n.u2-choice-chip > .u2-choice-chip-caret {\nmargin-left: auto;\nfont-size: 9px;\ncolor: var(--dg-grey-4);\ntransition: transform 100ms ease;\n}\n.u2-choice-chip[aria-expanded='true'] > .u2-choice-chip-caret {\ntransform: rotate(180deg);\n}\n.u2-choice-chip-invalid,\n.u2-choice-chip-invalid:hover {\nbackground: var(--dg-red-1);\n}\n.u2-choice-chip-invalid[aria-expanded='true'],\n.u2-choice-chip-invalid.u2-choice-chip-active {\nborder-color: var(--dg-red-3);\n}\n.u2-choice-chip-invalid > .u2-choice-chip-value {\ncolor: var(--dg-red-3);\n}\n.u2-choice-chip[aria-disabled='true'],\n.u2-choice-chip[aria-disabled='true']:hover {\ncolor: var(--dg-text-color-disabled);\nbackground: var(--dg-grey-1);\ncursor: default;\n}\n.u2-input-root[data-u2='multi-select'] {\nalign-items: flex-start;\n}\ndiv.u2-input-editor.u2-multi-select-field {\ndisplay: flex;\nalign-items: center;\nmin-width: 160px;\nheight: auto;\nmin-height: var(--dg-control-height);\npadding: 0 var(--dg-space-s);\nborder-bottom: var(--dg-input-border);\noutline: none;\ncursor: pointer;\n}\n.u2-input-inline div.u2-input-editor.u2-multi-select-field {\nmin-height: var(--dg-inline-control-height);\n}\ndiv.u2-input-editor.u2-multi-select-field:focus,\ndiv.u2-input-editor.u2-multi-select-field.u2-multi-select-open {\nborder-bottom: var(--dg-input-border-focus);\n}\ndiv.u2-input-editor.u2-multi-select-field.u2-invalid {\nborder-bottom-color: var(--dg-error);\n}\n.u2-multi-select-tags {\ndisplay: flex;\nflex: 1;\nflex-wrap: wrap;\nalign-items: center;\ngap: var(--dg-space-s);\nmin-width: 0;\npadding: var(--dg-space-xs) 0;\n}\n.u2-multi-select-placeholder {\ncolor: var(--dg-text-color-light);\n}\n.u2-multi-select-chevron {\nflex-shrink: 0;\nwidth: 0;\nheight: 0;\nmargin-left: var(--dg-space-s);\nborder-right: 4px solid transparent;\nborder-left: 4px solid transparent;\nborder-top: 5px solid var(--dg-text-color-light);\n}\n.u2-multi-select-open .u2-multi-select-chevron {\ntransform: rotate(180deg);\n}\n.u2-multi-select-tags .u2-tag {\nmax-width: 160px;\n}\n.u2-multi-select-tags .u2-tag-text {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-multi-select-more {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-multi-select-popup {\nbox-sizing: border-box;\ndisplay: flex;\nflex-direction: column;\nmin-width: 180px;\npadding: var(--dg-space-xs) 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\noutline: none;\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-multi-select-filter {\npadding: var(--dg-space-xs) var(--dg-space-m);\n}\n.u2-multi-select-filter-input {\nbox-sizing: border-box;\nwidth: 100%;\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-xs);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: none;\nborder-bottom: var(--dg-input-border);\nborder-radius: 0;\noutline: none;\n}\n.u2-multi-select-filter-input:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-multi-select-filter-input::placeholder {\ncolor: var(--dg-text-color-light);\n}\n.u2-multi-select-options {\nflex: 1;\nmin-height: 0;\noverflow-y: auto;\n}\n.u2-multi-select-all,\n.u2-multi-select-option {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\npadding: var(--dg-space-xs) var(--dg-space-m);\ncursor: pointer;\n}\n.u2-multi-select-all {\nmargin-bottom: var(--dg-space-xs);\npadding-bottom: var(--dg-space-s);\ncolor: var(--dg-text-color-light);\nborder-bottom: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-multi-select-all:hover,\n.u2-multi-select-option:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-multi-select-option-active {\nbackground: var(--dg-selection-bg);\n}\n.u2-multi-select-check {\nposition: relative;\nbox-sizing: border-box;\nflex-shrink: 0;\nwidth: 13px;\nheight: 13px;\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid var(--dg-grey-3);\nborder-radius: var(--dg-radius);\n}\n.u2-multi-select-selected > .u2-multi-select-check {\nbackground: var(--dg-accent);\nborder-color: var(--dg-accent);\n}\n.u2-multi-select-selected > .u2-multi-select-check::after {\ncontent: '';\nposition: absolute;\ntop: 0;\nleft: 3px;\nwidth: 4px;\nheight: 8px;\nborder: solid var(--dg-white);\nborder-width: 0 2px 2px 0;\ntransform: rotate(45deg);\n}\n.u2-multi-select-text {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-multi-select-empty {\npadding: var(--dg-space-xs) var(--dg-space-m);\ncolor: var(--dg-text-color-light);\n}\n.u2-combobox {\ndisplay: inline-block;\n}\n.u2-combobox-input {\nbox-sizing: border-box;\nwidth: 100%;\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-xs);\nfont: inherit;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: none;\nborder-bottom: var(--dg-input-border);\nborder-radius: 0;\noutline: none;\n}\n.u2-combobox-input:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-combobox-input::placeholder {\ncolor: var(--dg-text-color-light);\n}\n.u2-combobox-popup {\nbox-sizing: border-box;\noverflow-y: auto;\npadding: var(--dg-space-xs) 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-combobox-option {\npadding: var(--dg-space-xs) var(--dg-space-m);\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\ncursor: pointer;\n}\n.u2-combobox-option:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-combobox-option-active {\ncolor: var(--dg-selection-text);\nbackground: var(--dg-selection-bg);\n}\n.u2-combobox-loading,\n.u2-combobox-empty,\n.u2-combobox-error {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\npadding: var(--dg-space-xs) var(--dg-space-m);\ncolor: var(--dg-text-color-light);\n}\n.u2-combobox-retry {\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-m);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg-secondary);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-combobox-retry:hover {\nbackground: var(--dg-hover);\n}\n.u2-list {\nposition: relative;\noverflow-y: auto;\nborder: var(--dg-border-width) solid var(--dg-border);\nbackground: var(--dg-bg);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\noutline: none;\n}\n.u2-list:focus-visible:not(:has(.u2-list-row-current)) {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-list:focus-visible .u2-list-row-current {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-list.u2-list-no-ring:focus-visible,\n.u2-list.u2-list-no-ring:focus-visible .u2-list-row-current {\noutline: none;\n}\n.u2-list-frame {\nborder: var(--dg-border-width) solid var(--dg-border);\nbackground: var(--dg-bg);\n}\n.u2-list-content {\nposition: relative;\n}\n.u2-list-row {\nposition: absolute;\nleft: 0;\nright: 0;\ndisplay: flex;\nalign-items: center;\nbox-sizing: border-box;\npadding: 0 var(--dg-space-m);\nwhite-space: nowrap;\noverflow: hidden;\ntext-overflow: ellipsis;\ncursor: pointer;\n--u2-list-row-base: var(--dg-bg);\n--u2-list-row-state: transparent;\n--u2-list-row-current: transparent;\n--u2-list-row-over: transparent;\n--u2-list-row-stripe: transparent;\n--u2-list-row-selected: transparent;\n--u2-row-bg: linear-gradient(var(--u2-list-row-state), var(--u2-list-row-state)),\nlinear-gradient(var(--u2-list-row-selected), var(--u2-list-row-selected)),\nlinear-gradient(var(--u2-list-row-over), var(--u2-list-row-over)),\nlinear-gradient(var(--u2-list-row-current), var(--u2-list-row-current)), var(--u2-list-row-base);\nbackground: linear-gradient(var(--u2-list-row-state), var(--u2-list-row-state)),\nlinear-gradient(var(--u2-list-row-selected), var(--u2-list-row-selected)),\nlinear-gradient(to right, var(--u2-list-row-stripe) 4px, transparent 4px),\nlinear-gradient(var(--u2-list-row-over), var(--u2-list-row-over)),\nlinear-gradient(var(--u2-list-row-current), var(--u2-list-row-current)), var(--u2-list-row-base);\n}\n.u2-list-row-current {\n--u2-list-row-current: var(--dg-grid-current-row);\n}\n.u2-list-row:hover {\n--u2-list-row-over: var(--dg-grid-mouse-over-row);\n--u2-list-row-stripe: var(--dg-grid-mouse-over-stripe);\n}\n.u2-list-row-selected {\n--u2-list-row-selected: var(--dg-grid-selected-row);\n}\n.u2-list-seeded .u2-list-row-selected {\n--u2-list-row-selected: transparent;\n}\n.u2-list-seeded .u2-list-row-current {\n--u2-list-row-current: transparent;\n}\n.u2-row-actions {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nmargin-left: auto;\nopacity: 0;\npointer-events: none;\n}\n.u2-list-row .u2-row-actions {\nposition: absolute;\ntop: 0;\nright: 0;\nbottom: 0;\npadding: 0 var(--dg-space-m) 0 var(--dg-space-s);\nbackground: var(--u2-row-bg, var(--dg-hover-subtle));\n}\n.u2-row-actions .u2-btn.u2-icon-btn.u2-row-action-destructive {\ncolor: var(--dg-error);\n}\n.u2-list-row:hover .u2-row-actions,\n.u2-row:hover .u2-row-actions,\n.u2-row-actions:focus-within {\nopacity: 1;\npointer-events: auto;\n}\n.u2-functions-browser {\ndisplay: flex;\nflex-direction: column;\nmin-height: 0;\nbackground: var(--dg-bg);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\n}\n.u2-functions-browser [hidden] {\ndisplay: none !important;\n}\n.u2-fb-search {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\npadding: var(--dg-space-s) var(--dg-space-m);\n}\n.u2-fb-search .u2-input-root {\nflex: 1 1 auto;\n}\n.u2-fb-search .u2-input-box {\nwidth: 100%;\n}\n.u2-fb-search .u2-input-editor.u2-input-search {\nwidth: 100%;\n}\n.u2-fb-body {\ndisplay: flex;\nflex: 1 1 auto;\nmin-height: 0;\nalign-items: stretch;\n}\n.u2-fb-panes {\nflex: none;\nwidth: 170px;\nmax-width: 45%;\nmin-width: 0;\nbox-sizing: border-box;\noverflow-y: auto;\noverflow-x: hidden;\npadding: var(--dg-space-s) var(--dg-space-m);\nborder-right: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-fb-pane {\nmargin-bottom: var(--dg-space-l);\n}\n.u2-fb-pane-header {\nmargin-bottom: var(--dg-space-xs);\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\nfont-weight: bold;\n}\n.u2-fb-pane-row {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\npadding: var(--dg-space-xs) 0;\ncursor: pointer;\n}\n.u2-fb-pane-label {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\ncursor: pointer;\n}\n.u2-fb-count {\nmargin-left: auto;\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-fb-main {\ndisplay: flex;\nflex-direction: column;\nflex: 1 1 auto;\nmin-width: 120px;\nmin-height: 0;\n}\n.u2-fb-main .u2-list {\nflex: 1 1 auto;\nmin-height: 0;\n}\n.u2-fb-empty {\nflex: 1 1 auto;\nalign-items: center;\ngap: var(--dg-space-m);\n}\n.u2-fb-status {\nflex: none;\npadding: var(--dg-space-xs) var(--dg-space-m);\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-fb-row {\ndisplay: flex;\nalign-items: center;\nheight: 100%;\nmin-width: 0;\ngap: var(--dg-space-s);\noverflow: hidden;\n}\n.u2-fb-run {\nflex: none;\n}\n.u2-fb-run .grok-icon {\ncolor: var(--dg-success);\n}\n.u2-fb-icon {\ndisplay: flex;\nflex: none;\nalign-items: center;\njustify-content: center;\nwidth: 16px;\nheight: 16px;\noverflow: hidden;\n}\n.u2-fb-icon img,\n.u2-fb-icon svg,\n.u2-fb-icon i {\nmax-width: 16px;\nmax-height: 16px;\nfont-size: var(--dg-font-size-small);\n}\n.u2-fb-label {\nflex: 0 1 auto;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-fb-sig {\nflex: 1 1 auto;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-fb-no-signature .u2-fb-sig {\ndisplay: none;\n}\n.u2-fb-no-run .u2-fb-run {\ndisplay: none;\n}\n.u2-grid {\nposition: relative;\noverflow-x: hidden;\noverflow-y: auto;\nborder: var(--dg-border-width) solid var(--dg-border);\nbackground: var(--dg-bg);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\noutline: none;\n}\n.u2-grid:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-grid-content {\nposition: relative;\n}\n.u2-grid-cell {\nposition: absolute;\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nbox-sizing: border-box;\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-grid-cell:hover {\nbackground: var(--dg-hover);\n}\n.u2-grid-cell-selected,\n.u2-grid-cell-selected:hover {\nbackground: var(--dg-selection-bg);\ncolor: var(--dg-selection-text);\n}\n.u2-data-table {\nposition: relative;\noverflow-y: auto;\nborder: var(--dg-border-width) solid var(--dg-border);\nbackground: var(--dg-bg);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\noutline: none;\nscroll-snap-type: y proximity;\nscroll-padding-top: var(--u2-data-table-header-height, 0px);\n}\n.u2-data-table:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-data-table:focus-visible .u2-data-table-row-selected {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-data-table-header {\nposition: sticky;\ntop: 0;\nz-index: 1;\ndisplay: grid;\nalign-items: center;\nbox-sizing: border-box;\nbackground: var(--dg-bg);\nborder-bottom: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-data-table-head {\nposition: relative;\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-xs);\nheight: 100%;\ncolor: var(--dg-text-color);\nfont-weight: var(--dg-font-weight-bold);\n}\n.u2-data-table-head.u2-data-table-align-right {\nflex-direction: row-reverse;\n}\n.u2-data-table-head.u2-data-table-align-center {\njustify-content: center;\n}\n.u2-data-table-head-label {\nmin-width: 0;\noverflow: hidden;\ntext-overflow: ellipsis;\n}\n.u2-data-table-sortable > .u2-data-table-head {\ncursor: pointer;\n}\n.u2-data-table-sort {\nflex: none;\ncolor: var(--dg-accent);\n}\n.u2-data-table-resize {\nposition: absolute;\ntop: 0;\nright: 0;\nbottom: 0;\nwidth: var(--dg-space-s);\ncursor: col-resize;\n}\n.u2-data-table-resize:hover {\nborder-right: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-data-table-content {\nposition: relative;\n}\n.u2-data-table-row {\nscroll-snap-align: start;\nposition: absolute;\nleft: 0;\nright: 0;\ndisplay: grid;\nalign-items: center;\nbox-sizing: border-box;\nborder-bottom: var(--dg-border-width) solid var(--dg-border-subtle);\ncursor: pointer;\n}\n.u2-data-table-cell {\nbox-sizing: border-box;\npadding: 0 var(--dg-space-m);\nwhite-space: nowrap;\noverflow: hidden;\ntext-overflow: ellipsis;\n}\n.u2-data-table-align-right {\ntext-align: right;\n}\n.u2-data-table-align-center {\ntext-align: center;\n}\n.u2-data-table-align-left {\ntext-align: left;\n}\n.u2-data-table-row:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-data-table-row-selected,\n.u2-data-table-row-selected:hover {\nbackground: var(--dg-selection-bg);\ncolor: var(--dg-selection-text);\n}\n.u2-data-table-row .u2-cell-changed {\nbackground: var(--dg-orange-1);\n}\n.u2-data-table-row .u2-cell-error {\nbackground: var(--dg-red-1);\ncolor: var(--dg-error);\n}\n.u2-data-table-row .u2-timestamp {\ncolor: inherit;\n}\n.u2-data-table-row .u2-cell-readonly {\ncolor: var(--dg-text-color-light);\n}\n.u2-data-table-row .u2-data-table-cell > .u2-input-root {\nflex: 1 1 auto;\nwidth: 100%;\nmin-width: 0;\n}\n.u2-data-table-row .u2-data-table-cell > .u2-input-root > .u2-input-box {\nflex: 1 1 auto;\nmin-width: 0;\n}\n.u2-data-table-row .u2-data-table-cell > .u2-input-root .u2-input-editor {\nwidth: 100%;\n}\n.u2-data-table-cell > .u2-input-root > .u2-input-error {\ndisplay: none;\n}\n.u2-input-editor.u2-icon-input {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nborder-bottom: var(--dg-input-border);\ncursor: pointer;\n}\n.u2-input-editor.u2-icon-input:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-icon-input-preview {\ndisplay: inline-flex;\nwidth: var(--dg-space-xl);\njustify-content: center;\nflex-shrink: 0;\n}\n.u2-icon-input-name {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-icon-input-popup {\nbox-sizing: border-box;\nwidth: 296px;\npadding: var(--dg-space-s);\ngap: var(--dg-space-s);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbackground: var(--dg-bg);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-icon-input-popup .u2-grid {\nheight: 224px;\nborder: none;\n}\n.u2-icon-input-popup .u2-grid-cell {\nfont-size: var(--dg-font-size-h1);\n}\n.u2-input-editor.u2-function-input {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nborder-bottom: var(--dg-input-border);\ncursor: pointer;\n}\n.u2-input-editor.u2-function-input:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-function-input-icon {\ndisplay: inline-flex;\nwidth: var(--dg-space-xl);\njustify-content: center;\nflex-shrink: 0;\n}\n.u2-function-input-name {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-function-input-name.u2-function-input-empty {\ncolor: var(--dg-text-color-light);\n}\n.u2-function-input-popup {\ndisplay: flex;\nbox-sizing: border-box;\nwidth: 420px;\nheight: 320px;\npadding: var(--dg-space-s);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbackground: var(--dg-bg);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-function-input-popup .u2-functions-browser {\nflex: 1;\nmin-width: 0;\n}\n.u2-fch {\ndisplay: flex;\nflex-direction: column;\nmin-height: 0;\nbackground: var(--dg-bg);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\n}\n.u2-fch [hidden] {\ndisplay: none !important;\n}\n.u2-fch-main {\ndisplay: flex;\nflex-direction: column;\nflex: 1 1 auto;\nalign-items: stretch;\nmin-height: 0;\n}\n.u2-fch-main .u2-list {\nflex: 1 1 auto;\nmin-height: 0;\n}\n.u2-fch-state {\nflex: 1 1 auto;\nalign-items: center;\ngap: var(--dg-space-m);\n}\n.u2-fch-row {\ndisplay: flex;\nalign-items: center;\nheight: 100%;\nmin-width: 0;\npadding: 0 var(--dg-space-m);\ngap: var(--dg-space-s);\noverflow: hidden;\n}\n.u2-fch-row .grok-funccall-list-item {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-input-editor.u2-func-call-input {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nborder-bottom: var(--dg-input-border);\ncursor: pointer;\n}\n.u2-input-editor.u2-func-call-input:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-input-editor.u2-func-call-input.u2-invalid,\n.u2-input-editor.u2-func-call-input.u2-invalid:focus {\nborder-bottom: var(--dg-border-width) solid var(--dg-error);\n}\n.u2-func-call-input-name {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-func-call-input-name.u2-func-call-input-empty {\ncolor: var(--dg-text-color-light);\n}\n.u2-func-call-input-popup {\ndisplay: flex;\nbox-sizing: border-box;\nwidth: 420px;\nheight: 320px;\npadding: var(--dg-space-s);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbackground: var(--dg-bg);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-func-call-input-popup .u2-fch {\nflex: 1;\nmin-width: 0;\n}\n.u2-msg {\ndisplay: flex;\nbox-sizing: border-box;\nflex-direction: column;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\n}\n.u2-msg:focus-within {\nborder-color: var(--dg-accent-secondary);\n}\n.u2-msg-editor {\nmin-height: calc(2 * var(--dg-line-height) * var(--dg-font-size));\npadding: var(--dg-space-m);\noverflow-y: auto;\nline-height: var(--dg-line-height);\nwhite-space: pre-wrap;\noverflow-wrap: break-word;\noutline: none;\n}\n.u2-msg-editor:empty::before,\n.u2-msg-editor-empty::before {\ncontent: attr(data-placeholder);\ncolor: var(--dg-text-color-light);\npointer-events: none;\n}\n.u2-msg-chip {\ndisplay: inline-flex;\nalign-items: center;\npadding: 0 var(--dg-space-s);\ncolor: var(--dg-selection-text);\nwhite-space: nowrap;\nbackground: var(--dg-bg-secondary);\nborder-radius: var(--dg-radius);\nuser-select: none;\n}\n.u2-msg-query {\ncolor: var(--dg-accent-secondary);\n}\n.u2-msg-toolbar {\ndisplay: flex;\nalign-items: center;\njustify-content: space-between;\ngap: var(--dg-space-m);\npadding: var(--dg-space-s);\nborder-top: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-msg-tools {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-xs);\n}\n.u2-msg-send:is(:disabled, [aria-disabled='true']) {\ncursor: default;\nopacity: 0.5;\n}\n.u2-msg-popup {\nmin-width: 240px;\n}\n.u2-msg-text {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-input-editor.u2-file {\ndisplay: inline-flex;\nalign-items: center;\ngap: var(--dg-space-s);\npadding: 0;\nborder-bottom: var(--dg-input-border);\n}\n.u2-input-editor.u2-file:focus-within {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-input-editor.u2-file.u2-invalid,\n.u2-input-editor.u2-file.u2-invalid:focus-within {\nborder-bottom: var(--dg-border-width) solid var(--dg-error);\n}\n.u2-file-path {\nflex: 1;\nmin-width: 0;\nheight: 100%;\npadding: 0 var(--dg-space-s);\nfont: inherit;\ncolor: inherit;\nbackground: none;\nborder: none;\noutline: none;\n}\n.u2-input-root[data-u2='files-input'] .u2-input-box > .u2-input-editor + .u2-input-options {\nalign-self: flex-start;\nborder-bottom: none;\n}\n.u2-rsa-upload > .u2-btn > .u2-icon {\ncolor: var(--dg-accent);\n}\n.u2-file-dropping {\nbackground: var(--dg-selection-bg);\noutline: var(--dg-focus-ring);\n}\n.u2-input-editor.u2-files,\n.u2-input-editor.u2-rsa {\ndisplay: flex;\nflex-direction: column;\nalign-items: flex-start;\ngap: var(--dg-space-s);\nheight: auto;\nmin-height: var(--dg-control-height);\npadding: var(--dg-space-xs) var(--dg-space-s);\n}\n.u2-files-summary {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-files-list {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-xs);\nwidth: 100%;\n}\n.u2-files-row {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\n}\n.u2-files-name {\nflex: 1;\nmin-width: 0;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-files-status {\nflex-shrink: 0;\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-files-failed .u2-files-name,\n.u2-files-failed .u2-files-status {\ncolor: var(--dg-failure);\n}\n.u2-rsa-upload,\n.u2-rsa-masked {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\nwidth: 100%;\n}\n.u2-rsa-hint {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-rsa-masked .u2-input-root {\nflex: 1;\nmin-width: 0;\npadding: 0;\n}\n.u2-space-box {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nbox-sizing: border-box;\nflex: 1 1 auto;\nmin-width: 0;\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-xs);\nborder-bottom: var(--dg-input-border);\ncolor: var(--dg-text-color);\ncursor: pointer;\noutline: none;\n}\n.u2-space-box:focus-visible,\n.u2-space-open {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-space-text {\nflex: 1 1 auto;\nmin-width: 0;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-space-empty .u2-space-text {\ncolor: var(--dg-text-color-light);\n}\n.u2-space-icon,\n.u2-space-node-icon,\n.u2-space-caret,\n.u2-space-clear,\n.u2-space-add {\nflex: none;\nwidth: 16px;\ntext-align: center;\ncolor: var(--dg-text-color-light);\n}\n.u2-space-box:hover .u2-space-caret,\n.u2-space-open .u2-space-caret,\n.u2-space-clear:hover,\n.u2-space-add:hover {\ncolor: var(--dg-text-color);\n}\n.u2-space-clear,\n.u2-space-add {\ncursor: pointer;\n}\n.u2-space-add {\nmargin-left: auto;\nvisibility: hidden;\n}\n.u2-list-row:hover .u2-space-add,\n.u2-list-row[aria-selected=\"true\"] .u2-space-add {\nvisibility: visible;\n}\n.u2-space-popup {\ndisplay: flex;\nflex-direction: column;\nbox-sizing: border-box;\nwidth: 320px;\noverflow: hidden;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-space-popup [hidden],\n.u2-space-browser [hidden] {\ndisplay: none !important;\n}\n.u2-space-search {\npadding: var(--dg-space-s) var(--dg-space-m) var(--dg-space-xs);\n}\n.u2-space-search.u2-input-inline > .u2-input-box,\n.u2-space-search.u2-input-inline > .u2-input-box > .u2-input-editor {\nwidth: 100%;\n}\n.u2-space-head {\nalign-items: center;\njustify-content: space-between;\npadding: var(--dg-space-s) var(--dg-space-m) 2px;\nfont-size: var(--dg-font-size-small);\nletter-spacing: .06em;\ntext-transform: uppercase;\ncolor: var(--dg-text-color-light);\n}\n.u2-space-recent {\nalign-items: center;\ngap: var(--dg-space-s);\npadding: 3px var(--dg-space-m);\nwhite-space: nowrap;\ncursor: pointer;\n}\n.u2-space-recent:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-space-dim {\noverflow: hidden;\nmargin-left: auto;\nfont-size: var(--dg-font-size-small);\nwhite-space: nowrap;\ntext-overflow: ellipsis;\ncolor: var(--dg-text-color-light);\n}\n.u2-space-tree {\nflex: none;\nheight: 200px;\n}\n.u2-space-node {\nflex: 1 1 auto;\nalign-items: center;\ngap: var(--dg-space-s);\nmin-width: 0;\n}\n.u2-space-status {\npadding: var(--dg-space-m);\ncolor: var(--dg-text-color-light);\n}\n.u2-space-failed {\npadding: var(--dg-space-xs) var(--dg-space-m);\ncolor: var(--dg-error);\n}\n.u2-space-failed:empty,\n.u2-space-clash:empty {\ndisplay: none;\n}\n.u2-space-clash {\ncolor: var(--dg-error);\n}\n.u2-space-browser {\ndisplay: flex;\nheight: 100%;\nmin-height: 0;\nborder: 1px solid var(--dg-border-subtle);\n}\n.u2-space-browser-left {\ndisplay: flex;\nflex: none;\nwidth: 220px;\nborder-right: 1px solid var(--dg-border-subtle);\n}\n.u2-space-browser-tree {\nflex: 1 1 auto;\nmin-height: 0;\n}\n.u2-space-browser-middle {\ndisplay: flex;\nflex: 1 1 auto;\nflex-direction: column;\nmin-width: 0;\n}\n.u2-space-browser-middle .u2-space-search {\npadding: var(--dg-space-s) var(--dg-space-m);\nborder-bottom: 1px solid var(--dg-border-subtle);\n}\n.u2-space-items {\nflex: 1 1 auto;\nmin-height: 0;\n}\n.u2-space-item {\nalign-items: center;\ngap: var(--dg-space-s);\nbox-sizing: border-box;\nwidth: 100%;\nmin-width: 0;\npadding: 0 var(--dg-space-m);\n}\n.u2-space-item-icon {\nflex: none;\nwidth: 20px;\n}\n.u2-space-item-text {\ndisplay: flex;\nflex: 1 1 auto;\nflex-direction: column;\nmin-width: 0;\n}\n.u2-space-item-text .u2-space-dim {\nmargin-left: 0;\n}\n.u2-space-item-name {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-space-item-title {\nalign-items: center;\ngap: var(--dg-space-xs);\nmin-width: 0;\n}\n.u2-space-item-link {\nflex: none;\ncolor: var(--text-color-light);\n}\n.u2-space-preview-details {\npadding: var(--dg-space-s);\nborder: 1px solid var(--dg-border-subtle);\nborder-radius: var(--dg-radius);\n}\n.u2-space-empty-state {\npadding: 24px var(--dg-space-m);\ntext-align: center;\ncolor: var(--dg-text-color-light);\n}\n.u2-space-preview {\ndisplay: flex;\nflex: none;\nflex-direction: column;\nwidth: 240px;\npadding: var(--dg-space-m);\noverflow: auto;\nborder-left: 1px solid var(--dg-border-subtle);\n}\n.u2-progress {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-xs);\nfont-family: var(--dg-font-family);\n}\n.u2-progress-row {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\n}\n.u2-progress-track {\nflex: 1;\nmin-width: 0;\nheight: 4px;\noverflow: hidden;\nbackground: var(--dg-grey-2);\nborder-radius: var(--dg-radius);\n}\n.u2-progress-fill {\nwidth: 0;\nheight: 100%;\nbackground: var(--dg-accent);\nborder-radius: inherit;\ntransition: width 0.15s linear;\n}\n.u2-progress-percent {\nflex-shrink: 0;\nmin-width: 34px;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\ntext-align: right;\n}\n.u2-progress-description {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-progress-indeterminate .u2-progress-fill {\nwidth: 40%;\ntransition: none;\nanimation: u2-progress-slide 1.2s ease-in-out infinite;\n}\n@keyframes u2-progress-slide {\nfrom {\ntransform: translateX(-100%);\n}\nto {\ntransform: translateX(250%);\n}\n}\n@media (prefers-reduced-motion: reduce) {\n.u2-progress-fill {\ntransition: none;\n}\n.u2-progress-indeterminate .u2-progress-fill {\nwidth: 100%;\nanimation: u2-progress-pulse 1.6s ease-in-out infinite;\n}\n@keyframes u2-progress-pulse {\n50% {\nopacity: 0.35;\n}\n}\n}\n.u2-spec-error {\nbackground: var(--dg-red-1);\ncolor: var(--dg-red-4);\nborder-radius: var(--dg-radius);\npadding: var(--dg-space-s) var(--dg-space-m);\nfont-size: var(--dg-font-size-small);\n}\n.u2-wizard {\nbox-sizing: border-box;\ndisplay: flex;\nflex-direction: column;\nmin-height: 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\n}\n.u2-dialog-content > .u2-wizard {\nheight: 100%;\n}\n.u2-dialog-content:has(> .u2-wizard) {\npadding: 0;\n}\n.u2-wizard-steps {\ndisplay: flex;\nalign-items: center;\nflex-shrink: 0;\nmargin: 0;\npadding: var(--dg-space-l) var(--dg-space-l) 0;\nlist-style: none;\n}\n.u2-wizard-step {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nmargin: 0;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\noutline: none;\nuser-select: none;\n}\n.u2-wizard-step + .u2-wizard-step {\nflex: 1;\n}\n.u2-wizard-step + .u2-wizard-step::before {\ncontent: '';\nflex: 1;\nmin-width: var(--dg-space-l);\nheight: var(--dg-border-width);\nmargin: 0 var(--dg-space-s);\nbackground: var(--dg-border);\n}\n.u2-wizard-step:focus-visible .u2-wizard-marker {\noutline: var(--dg-focus-ring);\noutline-offset: 0;\n}\n.u2-wizard-marker {\nbox-sizing: border-box;\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nflex-shrink: 0;\nwidth: 20px;\nheight: 20px;\nfont-size: var(--dg-font-size-xs);\ncolor: var(--dg-text-color-light);\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: 50%;\n}\n.u2-wizard-title {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-wizard-step-done {\ncolor: var(--dg-text-color);\ncursor: pointer;\n}\n.u2-wizard-step-done[aria-disabled='true'] {\ncursor: default;\n}\n.u2-wizard-step-done .u2-wizard-marker {\ncolor: var(--dg-accent);\nbackground: var(--dg-bg);\nborder-color: var(--dg-accent);\n}\n.u2-wizard-step-current {\ncolor: var(--dg-text-color);\nfont-weight: var(--dg-font-weight-medium);\n}\n.u2-wizard-step-current .u2-wizard-marker {\ncolor: var(--dg-white);\nbackground: var(--dg-accent);\nborder-color: var(--dg-accent);\n}\n.u2-wizard-step-failed .u2-wizard-marker {\ncolor: var(--dg-white);\nbackground: var(--dg-error);\nborder-color: var(--dg-error);\n}\n.u2-wizard-busy .u2-wizard-steps {\npointer-events: none;\ncolor: var(--dg-text-color-disabled);\n}\n.u2-wizard-content {\nflex: 1 1 auto;\nmin-height: 0;\noverflow: auto;\npadding: var(--dg-space-l);\noverflow-wrap: anywhere;\n}\n.u2-wizard-buttons {\ndisplay: flex;\nalign-items: center;\njustify-content: flex-end;\nflex-shrink: 0;\ngap: var(--dg-space-m);\npadding: var(--dg-space-m) var(--dg-space-l);\nborder-top: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-wizard-cancel {\nmargin-right: var(--dg-space-l);\n}\n.u2-wizard-left {\ndisplay: flex;\nflex: 1 1 auto;\nalign-items: center;\njustify-content: center;\ngap: var(--dg-space-m);\nmin-width: 0;\ntext-align: center;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-wizard-status {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nmin-width: 0;\n}\n.u2-wizard-status-error,\n.u2-wizard-error {\ncolor: var(--dg-error);\n}\n.u2-wizard-reason:not(.u2-status-line-problem),\n.u2-wizard-status:empty {\ndisplay: none;\n}\n.u2-tree {\ndisplay: flex;\nflex-direction: column;\n}\n.u2-tree > .u2-list {\nflex: 1 1 auto;\nmin-height: 0;\n}\n.u2-tree-row {\ndisplay: flex;\nalign-items: center;\nflex: 1 1 auto;\nmin-width: 0;\nheight: 100%;\nbox-sizing: border-box;\npadding-left: var(--u2-tree-indent, 0px);\nbackground-image: repeating-linear-gradient(to right,\nvar(--dg-border-subtle) 0 var(--dg-border-width), transparent var(--dg-border-width) 20px);\nbackground-size: var(--u2-tree-indent, 0px) 100%;\nbackground-repeat: no-repeat;\n}\n.u2-tree-row > .u2-tree-twistie {\ndisplay: inline-flex;\nflex: 0 0 auto;\nalign-items: center;\njustify-content: center;\nwidth: 20px;\ncolor: var(--dg-text-color-light);\ncursor: pointer;\nuser-select: none;\n}\n.u2-tree-twistie-hidden {\nvisibility: hidden;\ncursor: default;\n}\n.u2-tree-label,\n.u2-tree-loading,\n.u2-tree-error {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-tree-loading {\ncolor: var(--dg-text-color-light);\nfont-style: italic;\n}\n.u2-tree-error {\ncolor: var(--dg-error);\n}\n.u2-tree-rename {\nflex: 1 1 auto;\nmin-width: 0;\nfont: inherit;\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: none;\nborder-bottom: var(--dg-input-border-focus);\nborder-radius: 0;\noutline: none;\npadding: 0;\n}\n.u2-tree-check {\nflex: 0 0 auto;\nwidth: 13px;\nheight: 13px;\nmargin: 0 var(--dg-space-s) 0 0;\naccent-color: var(--dg-accent);\ncursor: pointer;\n}\n.u2-tree-check:disabled {\ncursor: default;\nopacity: 0.5;\n}\n.u2-tree-check[aria-disabled='true'] {\ncursor: default;\n}\n.u2-tree-row-disabled .u2-tree-label {\ncolor: var(--dg-text-color-light);\n}\n.u2-tree .u2-list-row:hover,\n.u2-tree .u2-list-row-current {\n--u2-list-row-over: var(--dg-hover-subtle);\n--u2-list-row-stripe: transparent;\n--u2-list-row-current: var(--dg-hover-subtle);\n}\n.u2-tree .u2-list-row-selected,\n.u2-tree .u2-list-row-selected:hover {\nbackground: var(--dg-grey-1);\ncolor: var(--dg-text-color);\n}\n.u2-tabs {\ndisplay: flex;\nflex-direction: column;\nmin-height: 0;\n}\n.u2-tabs-header {\nposition: relative;\ndisplay: flex;\nbox-sizing: border-box;\nflex-shrink: 0;\nalign-items: stretch;\nheight: var(--dg-button-height);\nbackground: var(--dg-bg);\nbox-shadow: inset 0 calc(-1 * var(--dg-border-width)) 0 var(--dg-border);\n}\n.u2-tabs-scroller {\ndisplay: flex;\nflex: 1;\nmin-width: 0;\noverflow-x: auto;\noverflow-y: hidden;\nscrollbar-width: none;\n}\n.u2-tabs-scroller::-webkit-scrollbar {\ndisplay: none;\n}\n.u2-tabs-tab {\ndisplay: flex;\nbox-sizing: border-box;\nflex-shrink: 0;\nalign-items: center;\ngap: var(--dg-space-s);\nmax-width: 180px;\npadding: 0 var(--dg-space-m);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-accent);\nborder-bottom: 2px solid transparent;\ncursor: pointer;\noutline: none;\nuser-select: none;\n}\n.u2-tabs-tab-active {\nborder-bottom-color: var(--dg-accent);\ncursor: default;\n}\n.u2-tabs:not(.u2-tabs-document):not(.u2-tabs-vertical) > .u2-tabs-header {\nheight: 34px;\nbox-shadow: none;\n}\n.u2-tabs:not(.u2-tabs-document):not(.u2-tabs-vertical) > .u2-tabs-header .u2-tabs-tab {\npadding: var(--dg-space-m) var(--dg-space-xl);\n}\n.u2-tabs:not(.u2-tabs-document):not(.u2-tabs-vertical) > .u2-tabs-header .u2-tabs-tab-active {\nmargin-bottom: 7px;\npadding-bottom: 1px;\n}\n.u2-tabs-tab:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width) - var(--dg-border-width));\n}\n.u2-tabs-icon {\ndisplay: flex;\nflex-shrink: 0;\nalign-items: center;\njustify-content: center;\n}\n.u2-tabs-label {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-tabs-label:empty {\ndisplay: none;\n}\n.u2-tabs-close,\n.u2-tabs-mark {\ndisplay: flex;\nflex-shrink: 0;\nalign-items: center;\njustify-content: center;\nwidth: 14px;\nheight: 14px;\nfont-size: var(--dg-font-size-xs);\ncolor: var(--dg-text-color-light);\nborder-radius: var(--dg-radius);\n}\n.u2-tabs-mark:not(.u2-tabs-dirty) {\ndisplay: none;\n}\n.u2-tabs-close::before {\ncontent: '✕';\nvisibility: hidden;\n}\n.u2-tabs-tab:hover .u2-tabs-close::before,\n.u2-tabs-tab-active .u2-tabs-close::before {\nvisibility: visible;\n}\n.u2-tabs-close:hover {\ncolor: var(--dg-text-color);\nbackground: var(--dg-hover);\n}\n.u2-tabs-close.u2-tabs-dirty::before,\n.u2-tabs-mark.u2-tabs-dirty::before {\ncontent: '●';\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-accent);\nvisibility: visible;\n}\n.u2-tabs-tab.u2-tabs-invalid,\n.u2-tabs-tab.u2-tabs-invalid:hover {\ncolor: var(--dg-error);\n}\n.u2-tabs-tab.u2-tabs-invalid .u2-tabs-mark:not(.u2-tabs-dirty) {\ndisplay: inline-flex;\n}\n.u2-tabs-tab.u2-tabs-invalid .u2-tabs-mark:not(.u2-tabs-dirty)::before {\ncontent: '●';\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-error);\n}\n.u2-tabs-tab:hover .u2-tabs-close.u2-tabs-dirty::before {\ncontent: '✕';\nfont-size: var(--dg-font-size-xs);\ncolor: var(--dg-text-color-light);\n}\n.u2-tabs-overflow {\ndisplay: none;\nbox-sizing: border-box;\nflex-shrink: 0;\nalign-items: center;\njustify-content: center;\nwidth: var(--dg-button-height);\npadding: 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color-light);\nbackground: var(--dg-bg);\nborder: none;\ncursor: pointer;\n}\n.u2-tabs-overflow-visible {\ndisplay: flex;\n}\n.u2-tabs-overflow:hover {\ncolor: var(--dg-text-color);\nbackground: var(--dg-hover);\n}\n.u2-tabs-overflow-menu {\nposition: absolute;\ntop: 100%;\nright: 0;\nz-index: var(--dg-z-overlay);\ndisplay: none;\nbox-sizing: border-box;\nmin-width: 160px;\nmax-height: 320px;\noverflow-y: auto;\npadding: var(--dg-space-xs) 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-tabs-overflow-menu-open {\ndisplay: block;\n}\n.u2-tabs-overflow-item {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\npadding: var(--dg-space-xs) var(--dg-space-m);\nwhite-space: nowrap;\ncursor: pointer;\n}\n.u2-tabs-overflow-item:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-tabs-overflow-item-active {\ncolor: var(--dg-selection-text);\nbackground: var(--dg-selection-bg);\n}\n.u2-tabs-content {\nflex: 1;\nmin-width: 0;\nmin-height: 0;\noverflow: auto;\npadding: var(--dg-space-m);\nbackground: var(--dg-bg);\n}\n.u2-tabs-document .u2-tabs-header,\n.u2-tabs-document .u2-tabs-overflow {\nbackground: var(--dg-bg-secondary);\n}\n.u2-tabs-document .u2-tabs-tab {\ncolor: var(--dg-text-color-light);\nbackground: var(--dg-bg-secondary);\nborder-top: 2px solid transparent;\nborder-right: var(--dg-border-width) solid var(--dg-border);\nborder-bottom: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-tabs-document .u2-tabs-tab:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-tabs-document .u2-tabs-tab-active {\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder-top-color: var(--dg-accent);\nborder-bottom-color: var(--dg-bg);\n}\n.u2-tabs-document .u2-tabs-overflow {\nborder-left: var(--dg-border-width) solid var(--dg-border);\nborder-bottom: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-tabs-vertical {\nflex-direction: row;\n}\n.u2-tabs-vertical .u2-tabs-header {\nflex-direction: column;\nheight: auto;\nbox-shadow: inset calc(-1 * var(--dg-border-width)) 0 0 var(--dg-border);\n}\n.u2-tabs-vertical .u2-tabs-scroller {\nflex-direction: column;\nmin-height: 0;\noverflow-x: hidden;\noverflow-y: auto;\n}\n.u2-tabs-vertical .u2-tabs-tab {\njustify-content: flex-end;\nmin-height: var(--dg-button-height);\npadding: var(--dg-space-m);\ntext-align: right;\nborder-right: 4px solid transparent;\nborder-bottom: none;\n}\n.u2-tabs-vertical .u2-tabs-tab-active {\ncolor: var(--dg-text-color);\nborder-right-color: var(--dg-accent);\n}\n.u2-tabs-vertical .u2-tabs-overflow {\nwidth: auto;\nheight: var(--dg-button-height);\n}\n.u2-tabs-vertical .u2-tabs-overflow-menu {\nright: auto;\nleft: 0;\n}\n.u2-tabs.u2-tabs-flush:not(.u2-tabs-vertical) > .u2-tabs-header .u2-tabs-tab:first-child {\npadding-left: 0;\n}\n.u2-tabs-flush > .u2-tabs-content {\npadding-left: 0;\npadding-right: 0;\n}\n.u2-tabs-flush > .u2-tabs-content > .u2-tabs-panel {\nheight: 100%;\n}\n.u2-splitter {\nposition: relative;\ndisplay: flex;\nwidth: 100%;\nheight: 100%;\noverflow: hidden;\n}\n.u2-splitter-horizontal {\nflex-direction: row;\n}\n.u2-splitter-vertical {\nflex-direction: column;\n}\n.u2-splitter-panel {\nposition: relative;\nflex-grow: 0;\nflex-shrink: 0;\nmin-width: 0;\nmin-height: 0;\noverflow: hidden;\n}\n.u2-sash {\nposition: absolute;\nz-index: 1;\noutline: none;\ntouch-action: none;\n}\n.u2-sash::before {\ncontent: '';\nposition: absolute;\nbackground: var(--dg-border);\n}\n.u2-splitter-horizontal > .u2-sash {\ntop: 0;\nbottom: 0;\nwidth: 4px;\ncursor: col-resize;\n}\n.u2-splitter-horizontal > .u2-sash::before {\ntop: 0;\nbottom: 0;\nleft: 50%;\nwidth: var(--dg-border-width);\ntransform: translateX(-50%);\n}\n.u2-splitter-vertical > .u2-sash {\nleft: 0;\nright: 0;\nheight: 4px;\ncursor: row-resize;\n}\n.u2-splitter-vertical > .u2-sash::before {\nleft: 0;\nright: 0;\ntop: 50%;\nheight: var(--dg-border-width);\ntransform: translateY(-50%);\n}\n.u2-sash-hover::before,\n.u2-sash-active::before,\n.u2-sash:focus-visible::before {\nbackground: var(--dg-accent);\n}\n.u2-sash:focus-visible {\noutline: var(--dg-focus-ring);\n}\n.u2-splitter-dragging {\nuser-select: none;\n}\n.u2-splitter-horizontal.u2-splitter-dragging {\ncursor: col-resize;\n}\n.u2-splitter-vertical.u2-splitter-dragging {\ncursor: row-resize;\n}\n.u2-accordion {\ndisplay: flex;\nflex-direction: column;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\n}\n.u2-accordion-header {\nposition: relative;\ndisplay: flex;\nbox-sizing: border-box;\nalign-items: center;\ngap: var(--dg-space-s);\nheight: var(--dg-control-height);\npadding: 0 0 0 var(--dg-space-xxl);\ncursor: pointer;\noutline: none;\nuser-select: none;\n}\n.u2-accordion-header:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-accordion-header:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width) - var(--dg-border-width));\n}\n.u2-accordion-chevron {\nposition: absolute;\ntop: 0;\nbottom: 0;\nleft: 3px;\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nwidth: var(--dg-space-xl);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\ntransform: rotate(-90deg);\ntransition: transform 100ms ease;\n}\n.u2-accordion-header[aria-expanded='true'] .u2-accordion-chevron {\ntransform: rotate(0);\n}\n.u2-accordion-icon {\ndisplay: flex;\nflex-shrink: 0;\nalign-items: center;\njustify-content: center;\ncolor: var(--dg-text-color-light);\n}\n.u2-accordion-title {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-accordion-content {\npadding: 2px 0 10px 20px;\ncolor: var(--dg-grey-5);\n}\n.u2-accordion-hint {\nflex-shrink: 100;\nmin-width: 0;\nmargin-left: var(--dg-space-s);\noverflow: hidden;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-accordion-hint > [hidden] {\ndisplay: none !important;\n}\n.u2-accordion-hint:empty,\n.u2-accordion-header[aria-expanded='true'] > .u2-accordion-hint {\ndisplay: none;\n}\n.u2-accordion-pane-invalid > .u2-accordion-header > .u2-accordion-title,\n.u2-accordion-pane-invalid > .u2-accordion-header > .u2-accordion-hint {\ncolor: var(--dg-error);\n}\n.u2-accordion-flush > .u2-accordion-pane > .u2-accordion-header {\npadding: 0 var(--dg-space-xxl) 0 0;\n}\n.u2-accordion-flush > .u2-accordion-pane > .u2-accordion-header > .u2-accordion-chevron {\nleft: auto;\nright: 3px;\ntransform: none;\n}\n.u2-accordion-flush > .u2-accordion-pane > .u2-accordion-header[aria-expanded='true'] > .u2-accordion-chevron {\ntransform: rotate(180deg);\n}\n.u2-accordion-flush > .u2-accordion-pane > .u2-accordion-content {\npadding: 0 0 var(--dg-space-m);\ncolor: inherit;\n}\n.u2-breadcrumbs {\ndisplay: flex;\nbox-sizing: border-box;\nalign-items: center;\nmin-width: 0;\nmin-height: var(--dg-inline-control-height);\noverflow: hidden;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\nwhite-space: nowrap;\n}\n.u2-breadcrumbs-item,\n.u2-breadcrumbs-current {\nbox-sizing: border-box;\nflex-shrink: 0;\nmax-width: 220px;\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-xs);\noverflow: hidden;\nfont: inherit;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-breadcrumbs-item {\ncolor: var(--dg-accent);\nbackground: none;\nborder: none;\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-breadcrumbs-item:hover {\ntext-decoration: underline;\n}\n.u2-breadcrumbs-item:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-breadcrumbs-ellipsis {\ncolor: var(--dg-text-color-light);\n}\n.u2-breadcrumbs-current {\ndisplay: inline-flex;\nalign-items: center;\ncolor: var(--dg-text-color);\n}\n.u2-breadcrumbs-sep {\nflex-shrink: 0;\npadding: 0 var(--dg-space-s);\ncolor: var(--dg-text-color-light);\n}\n.u2-toolbar {\n--u2-toolbar-height: calc(var(--dg-button-height) + 2 * var(--dg-space-xs));\nbox-sizing: border-box;\ndisplay: flex;\nflex: 1 1 0;\nflex-wrap: nowrap;\nalign-items: center;\ngap: var(--dg-space-xs);\nmin-width: 0;\nheight: var(--u2-toolbar-height);\nmin-height: var(--u2-toolbar-height);\nmax-height: var(--u2-toolbar-height);\npadding: var(--dg-space-xs) var(--dg-space-s);\noverflow: hidden;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\n}\n.u2-toolbar > .u2-toolbar-hidden {\ndisplay: none;\n}\n.u2-toolbar-btn {\ndisplay: inline-flex;\nbox-sizing: border-box;\nflex-shrink: 0;\nalign-items: center;\ngap: var(--dg-space-s);\nheight: var(--dg-button-height);\npadding: 0 var(--dg-space-s);\nfont: inherit;\ncolor: var(--dg-text-color);\nwhite-space: nowrap;\nbackground: none;\nborder: var(--dg-border-width) solid transparent;\nborder-radius: var(--dg-radius);\ncursor: pointer;\noutline: none;\nuser-select: none;\n}\n.u2-toolbar-btn:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-toolbar-btn:active,\n.u2-toolbar-btn-pressed {\ncolor: var(--dg-text-color);\nbackground: var(--dg-steel-1);\nborder-color: var(--dg-border);\n}\n.u2-toolbar-btn:focus-visible {\nborder-color: var(--dg-focus);\n}\n.u2-toolbar-icon {\nfont-size: var(--dg-font-size-small);\n}\n.u2-toolbar-arrow {\nfont-size: var(--dg-font-size-xs);\ncolor: var(--dg-text-color-light);\n}\n.u2-toolbar-btn-menu .u2-toolbar-arrow {\nmargin-left: calc(-1 * var(--dg-space-xs));\n}\n.u2-toolbar-sep {\nflex-shrink: 0;\nwidth: var(--dg-border-width);\nheight: calc(var(--dg-button-height) - 2 * var(--dg-space-xs));\nmargin: 0 var(--dg-space-xs);\nbackground: var(--dg-border);\n}\n.u2-toolbar-slot {\ndisplay: flex;\nflex-shrink: 0;\nalign-items: center;\nmin-width: 0;\n}\n.u2-toolbar-overflow {\nmargin-left: auto;\npadding: 0 var(--dg-space-xs);\ncolor: var(--dg-text-color-light);\n}\n.u2-menu {\nbox-sizing: border-box;\nmin-width: 160px;\npadding: 5px 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-steel-5);\nbackground: var(--dg-steel-1);\nborder: none;\nborder-radius: 0;\nbox-shadow: 0 0 2px var(--dg-steel-5);\noutline: none;\n}\n.u2-menu-item {\ndisplay: grid;\ngrid-template-columns: 16px 1fr auto;\nalign-items: center;\ngap: var(--dg-space-s);\nheight: 24px;\npadding: 0 var(--dg-space-m) 0 6px;\ncursor: pointer;\nuser-select: none;\n}\n.u2-menu-item-active,\n.u2-menu-item-open {\ncolor: var(--dg-steel-5);\nbackground: var(--dg-steel-2);\n}\n.u2-menu-item[aria-disabled='true'],\n.u2-menu-item[aria-disabled='true'] .u2-menu-shortcut {\ncolor: var(--dg-text-color-disabled);\ncursor: default;\n}\n.u2-menu-item[aria-disabled='true'].u2-menu-item-active {\nbackground: none;\n}\n.u2-menu-icon {\nfont-size: var(--dg-font-size-small);\ntext-align: center;\n}\n.u2-menu-label {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-menu-shortcut {\ncolor: var(--dg-steel-4);\nfont-size: var(--dg-font-size);\ntext-align: right;\n}\n.u2-menu-shortcut:not(:empty) {\nmargin-left: var(--dg-space-xl);\n}\n.u2-menu-arrow::after {\ncontent: '';\ndisplay: block;\nwidth: 5px;\nheight: 5px;\nmargin-right: var(--dg-space-xs);\nborder: solid var(--dg-steel-4);\nborder-width: 0 var(--dg-border-width) var(--dg-border-width) 0;\ntransform: rotate(-45deg);\n}\n.u2-menu-separator {\nheight: var(--dg-border-width);\nmargin: 5px 0;\nbackground: var(--dg-steel-3);\n}\n.u2-menu.u2-menu-detailed {\ndisplay: grid;\ngrid-template-columns: 16px auto minmax(0, 1fr) auto;\ncolumn-gap: var(--dg-space-s);\n}\n.u2-menu-detailed > .u2-menu-item {\ngrid-column: 1 / -1;\ngrid-template-columns: subgrid;\n}\n.u2-menu-detailed > .u2-menu-separator {\ngrid-column: 1 / -1;\n}\n.u2-menu-detailed .u2-menu-label-wide {\ngrid-column: 2 / 4;\n}\n.u2-menu-detail {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-menu-detail:not(:empty) {\npadding-left: var(--dg-space-m);\n}\n.u2-menu-bar {\ndisplay: flex;\nflex-wrap: nowrap;\nalign-items: center;\nmin-width: 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: none;\n}\n.u2-menu-bar-item {\ndisplay: inline-flex;\nbox-sizing: border-box;\nflex-shrink: 0;\nalign-items: center;\nheight: var(--dg-button-height);\npadding: 0 var(--dg-space-m);\nfont: inherit;\ncolor: inherit;\nwhite-space: nowrap;\nbackground: none;\nborder: var(--dg-border-width) solid transparent;\nborder-radius: var(--dg-radius);\ncursor: pointer;\noutline: none;\nuser-select: none;\n}\n.u2-menu-bar-item:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-menu-bar-item-open {\ncolor: var(--dg-selection-text);\nbackground: var(--dg-selection-bg);\n}\n.u2-menu-bar-item:focus-visible {\nborder-color: var(--dg-focus);\n}\n.u2-menu-bar-item[aria-disabled='true'] {\ncolor: var(--dg-text-color-disabled);\ncursor: default;\n}\n.u2-menu-bar-item[aria-disabled='true']:hover {\nbackground: none;\n}\n.u2-dialog {\nbox-sizing: border-box;\nposition: fixed;\ndisplay: flex;\nflex-direction: column;\nmax-width: 100vw;\nmax-height: 100vh;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid var(--dg-border-subtle);\nborder-radius: 0;\nbox-shadow: var(--dg-shadow-3);\noutline: none;\n}\n.u2-dialog-backdrop {\nposition: fixed;\ninset: 0;\nbackground: var(--dg-backdrop);\n}\n.u2-dialog[hidden],\n.u2-dialog-backdrop[hidden] {\ndisplay: none;\n}\n.u2-dialog-resizable {\nmin-width: 240px;\nmin-height: 160px;\noverflow: hidden;\nresize: both;\n}\n.u2-dialog-title {\ndisplay: flex;\nalign-items: center;\nflex-shrink: 0;\ngap: 0;\nheight: 34px;\npadding: 0 10px;\nfont-size: 18px;\nfont-weight: var(--dg-font-weight-regular);\nwhite-space: nowrap;\noverflow: hidden;\ncursor: move;\nuser-select: none;\n}\n.u2-dialog-title:hover {\nbackground: var(--dg-steel-1);\n}\n.u2-dialog-title-text {\nmargin-right: auto;\npadding-right: var(--dg-space-m);\noverflow: hidden;\ntext-overflow: ellipsis;\n}\n.u2-dialog-help,\n.u2-dialog-close {\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nflex-shrink: 0;\nwidth: 18px;\nheight: 18px;\npadding: 0;\nfont-size: 16px;\ncolor: var(--dg-grey-3);\nbackground: transparent;\nborder: none;\nopacity: 0;\ncursor: pointer;\n}\n.u2-dialog:hover .u2-dialog-help,\n.u2-dialog:hover .u2-dialog-close,\n.u2-dialog-help:focus-visible,\n.u2-dialog-close:focus-visible {\nopacity: 1;\n}\n.u2-dialog-help:hover,\n.u2-dialog-close:hover {\ncolor: var(--dg-text-color);\n}\n.u2-dialog-content {\nflex: 1 1 auto;\nmin-height: 0;\nmax-height: 80vh;\npadding: var(--dg-space-l);\noverflow: auto;\n}\n.u2-dialog-sized > .u2-dialog-content {\nmax-height: none;\n}\n.u2-dialog-content > .u2-input-root > .u2-input-label {\ndisplay: block;\nwidth: var(--u2-dialog-label-width, 140px);\nmin-width: 0;\nmax-width: 200px;\nline-height: var(--dg-control-height);\ncolor: var(--dg-text-color-light);\ntext-align: right;\n}\n.u2-dialog-content > .u2-input-required > .u2-input-label {\njustify-content: flex-end;\n}\n.u2-dialog-content > .u2-input-root:not(.u2-input-inline) > .u2-input-error {\npadding-left: calc(var(--u2-dialog-label-width, 140px) + var(--dg-space-m));\n}\n.u2-dialog-error {\nflex-shrink: 0;\ncontain: inline-size;\nmax-height: 25vh;\nmargin: 0 var(--dg-space-l) var(--dg-space-m);\noverflow: auto;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-error);\nwhite-space: pre-wrap;\n}\n.u2-dialog-error[hidden] {\ndisplay: none;\n}\n.u2-dialog-buttons {\ndisplay: flex;\nalign-items: center;\njustify-content: flex-end;\nflex-shrink: 0;\ngap: var(--dg-space-m);\npadding: var(--dg-space-m) var(--dg-space-l);\nborder-top: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-dialog-buttons:empty {\ndisplay: none;\n}\n.u2-dialog-reason {\nflex: 1 1 auto;\njustify-content: center;\ntext-align: center;\n}\n.u2-dialog-reason:not(.u2-status-line-problem):not(.u2-dialog-status) {\ndisplay: none;\n}\n.u2-dialog-reason.u2-dialog-status {\njustify-content: flex-start;\ntext-align: left;\n}\n.u2-dialog-start + :not(.u2-dialog-start):not(.u2-dialog-reason) {\nmargin-left: auto;\n}\n.u2-dialog-busy {\nbox-sizing: border-box;\ndisplay: inline-block;\nflex-shrink: 0;\nwidth: 12px;\nheight: 12px;\nmargin-left: var(--dg-space-s);\nborder: 2px solid currentColor;\nborder-top-color: transparent;\nborder-radius: 50%;\nvertical-align: middle;\nanimation: u2-dialog-spin 0.8s linear infinite;\n}\n@keyframes u2-dialog-spin {\nto {\ntransform: rotate(360deg);\n}\n}\n.u2-confirm {\ndisplay: flex;\ngap: 14px;\nmax-width: 440px;\n}\n.u2-confirm-icon {\nflex-shrink: 0;\nfont-size: 22px;\ncolor: var(--dg-error);\n}\n.u2-confirm-text {\ndisplay: flex;\nflex-direction: column;\ngap: 6px;\n}\n.u2-confirm-detail {\ncolor: var(--dg-text-color-light);\n}\n.u2-tooltip {\nbox-sizing: border-box;\nmax-width: 600px;\npadding: 5px;\nfont-family: var(--dg-font-family);\nfont-size: calc(var(--dg-font-size) * 0.9);\nline-height: var(--dg-line-height);\ncolor: var(--dg-warm-grey-4);\nbackground: color-mix(in srgb, var(--dg-beige-1) 88%, transparent);\nborder: var(--dg-border-width) solid var(--dg-beige-2);\nborder-radius: 2px;\nbox-shadow: 0 0 5px var(--dg-beige-2);\n}\n.u2-notify-container {\nposition: fixed;\ntop: 60px;\nright: 10px;\nwidth: 300px;\nmax-height: calc(100vh - 80px);\noverflow-y: auto;\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-m);\npointer-events: none;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\n}\n.u2-notify {\npointer-events: auto;\nposition: relative;\ndisplay: flex;\nalign-items: flex-start;\ngap: var(--dg-space-m);\npadding: var(--dg-space-l) 52px var(--dg-space-l) var(--dg-space-l);\nborder-radius: var(--dg-radius);\nborder: var(--dg-border-width) solid;\nbox-shadow: var(--dg-shadow-2);\nwhite-space: pre-wrap;\n}\n.u2-notify-info {\ncolor: var(--dg-green-3);\nborder-color: var(--dg-green-2);\nbackground: var(--dg-green-1);\n}\n.u2-notify-warning {\ncolor: var(--dg-orange-3);\nborder-color: var(--dg-orange-2);\nbackground: var(--dg-orange-1);\n}\n.u2-notify-error {\ncolor: var(--dg-red-4);\nborder-color: var(--dg-red-3);\nbackground: var(--dg-red-1);\n}\n.u2-notify-type-icon {\nflex-shrink: 0;\nfont-size: var(--dg-font-size-h1);\n}\n.u2-notify-info .u2-notify-type-icon { color: var(--dg-green-2); }\n.u2-notify-warning .u2-notify-type-icon { color: var(--dg-orange-2); }\n.u2-notify-error .u2-notify-type-icon { color: var(--dg-red-3); }\n.u2-notify-content {\nflex: 1;\nmin-width: 0;\noverflow-wrap: anywhere;\n}\n.u2-notify-icons {\nposition: absolute;\ntop: var(--dg-space-m);\nright: var(--dg-space-m);\ndisplay: flex;\ngap: var(--dg-space-xs);\nopacity: 0;\n}\n.u2-notify:hover .u2-notify-icons,\n.u2-notify-icons:focus-within {\nopacity: 1;\n}\n.u2-notify-icons .u2-icon-btn {\ncolor: inherit;\n}\n.u2-notify-timer {\nposition: absolute;\nleft: 0;\nbottom: 0;\nheight: 2px;\nwidth: 100%;\nbackground: currentColor;\nanimation: u2-notify-countdown linear forwards;\n}\n.u2-notify:hover .u2-notify-timer {\nanimation-play-state: paused;\n}\n@keyframes u2-notify-countdown {\n0% { width: 100%; }\n100% { width: 0; }\n}\n.u2-tour-overlay {\nposition: fixed;\ninset: 0;\npointer-events: none;\n}\n.u2-tour-overlay svg {\nwidth: 100%;\nheight: 100%;\n}\n.u2-tour-popup {\nbox-sizing: border-box;\nposition: fixed;\nleft: 0;\ntop: 0;\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-m);\nmax-width: 360px;\npadding: var(--dg-space-l);\npointer-events: auto;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\nbox-shadow: var(--dg-shadow-2);\noutline: none;\n}\n.u2-tour-content {\noverflow-wrap: anywhere;\n}\n.u2-tour-footer {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\n}\n.u2-tour-counter {\nmargin-left: auto;\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-form {\nbox-sizing: border-box;\ndisplay: flex;\nflex-direction: column;\nmax-width: var(--u2-form-max-width, 700px);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\n}\n.u2-form-rows {\ndisplay: flex;\nflex-direction: column;\ngap: 0;\n}\n.u2-form .u2-input-label,\n.u2-form .ui-input-label {\nmin-width: var(--u2-form-label-width, 100px);\ncolor: var(--dg-text-color-light);\ntext-align: right;\n}\n.u2-form.u2-form-measuring .u2-input-label,\n.u2-form.u2-form-measuring .ui-input-label {\nflex-basis: auto !important;\nwidth: max-content !important;\nmin-width: 0 !important;\n}\n.u2-form-captions-left .u2-input-label,\n.u2-form-captions-left .ui-input-label {\ntext-align: left;\n}\n.u2-form-rows > .u2-section + .u2-section {\nmargin-top: var(--u2-form-section-gap, 0);\n}\n.u2-form-rows > :not(.u2-input-root):not(.u2-section) {\npadding: var(--dg-space-s) 0;\n}\n.u2-form-readonly {\ndisplay: flex;\nflex-wrap: wrap;\nalign-items: center;\n}\n.u2-form-readonly-value {\ndisplay: flex;\nalign-items: center;\nmin-height: var(--dg-control-height);\npadding: 0 var(--dg-space-s);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nwhite-space: pre-wrap;\n}\n.u2-form-readonly-empty {\ncolor: var(--dg-text-color-light);\n}\n.u2-form:not(.u2-form-tall) .u2-input-error {\npadding-left: calc(var(--u2-form-label-width, 100px) + var(--dg-space-m));\n}\n.u2-form-tall .u2-input-error {\npadding-left: 0;\n}\n.u2-form:not(.u2-form-tall) .u2-form-note {\npadding-left: calc(var(--u2-form-label-width, 100px) + var(--dg-space-m));\n}\n.u2-form-note {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-form input.u2-input-editor,\n.u2-form textarea.u2-input-editor,\n.u2-form .u2-input-editor.u2-input-search,\n.ui-form .ui-input-root > .u2-input-box > input.u2-input-editor,\n.ui-form .ui-input-root > .u2-input-box > textarea.u2-input-editor,\n.ui-form .ui-input-root > .u2-input-box > .u2-input-editor.u2-input-search {\nflex: 1;\nmin-width: 0;\n}\n.u2-form .u2-input-box:has(> input.u2-input-editor),\n.u2-form .u2-input-box:has(> textarea.u2-input-editor),\n.u2-form .u2-input-box:has(> .u2-input-editor.u2-input-search),\n.ui-form .ui-input-root > .u2-input-box:has(> input.u2-input-editor),\n.ui-form .ui-input-root > .u2-input-box:has(> textarea.u2-input-editor),\n.ui-form .ui-input-root > .u2-input-box:has(> .u2-input-editor.u2-input-search) {\nflex: 1;\nmin-width: 0;\nmax-width: none;\n}\n.u2-form .u2-input-box:has(> div.u2-input-editor:not(.u2-multi-choice):not(.u2-radio):not(.u2-image)),\n.u2-dialog-content > .u2-input-root > .u2-input-box:has(> div.u2-input-editor:not(.u2-multi-choice):not(.u2-radio):not(.u2-image)) {\nflex-grow: 1;\nmax-width: none;\n}\n.u2-form .u2-input-box > div.u2-input-editor:not(.u2-multi-choice):not(.u2-radio):not(.u2-image),\n.u2-dialog-content > .u2-input-root > .u2-input-box > div.u2-input-editor:not(.u2-multi-choice):not(.u2-radio):not(.u2-image) {\nflex-grow: 1;\n}\n.u2-form-category {\nmargin-top: var(--dg-space-m);\nfont-size: var(--dg-font-size);\nfont-weight: var(--dg-font-weight-bold);\ncolor: var(--dg-text-color);\n}\n.u2-form-rows > .u2-section:first-child .u2-form-category {\nmargin-top: 0;\n}\n.u2-form-wide {\nmax-width: var(--u2-form-max-width, none);\n}\n.u2-form-wide .u2-input-box {\nflex: 1;\nmin-width: 0;\nmax-width: none;\n}\n.u2-form-wide .u2-input-editor {\nflex: 1;\nwidth: auto;\nmax-width: none;\nmin-width: 0;\n}\n.u2-form:not(.u2-form-wide):not(.u2-form-tall) .u2-input-root:not(.u2-input-fill)[data-u2='choice-input'] select.u2-input-editor,\n.u2-form-auto.u2-form-wide .u2-input-root:not(.u2-input-fill)[data-u2='choice-input'] select.u2-input-editor {\nflex: 0 1 auto;\nwidth: var(--u2-choice-width, 200px);\nmax-width: none;\n}\n.u2-form:not(.u2-form-wide):not(.u2-form-tall) .u2-input-root:not(.u2-input-fill) .u2-input-editor.u2-number,\n.u2-form-auto.u2-form-wide .u2-input-root:not(.u2-input-fill) .u2-input-editor.u2-number {\nflex: 0 1 auto;\nwidth: 150px;\nmax-width: 150px;\n}\n.u2-form:not(.u2-form-wide):not(.u2-form-tall) .u2-input-root:not(.u2-input-fill) .u2-input-editor.u2-date,\n.u2-form-auto.u2-form-wide .u2-input-root:not(.u2-input-fill) .u2-input-editor.u2-date {\nflex: 0 1 auto;\nwidth: 140px;\nmax-width: 140px;\n}\n.u2-form:not(.u2-form-wide):not(.u2-form-tall) .u2-input-root:not(.u2-input-fill)[data-u2='datetime-input'] .u2-input-editor.u2-date,\n.u2-form-auto.u2-form-wide .u2-input-root:not(.u2-input-fill)[data-u2='datetime-input'] .u2-input-editor.u2-date {\nwidth: 170px;\nmax-width: 170px;\n}\n.u2-form-auto.u2-form-wide .u2-input-root:not(.u2-input-fill)[data-u2='bigint-input'] > .u2-input-box > input.u2-input-editor,\n.u2-form-auto.u2-form-wide .u2-input-root:not(.u2-input-fill)[data-u2='qnum-input'] > .u2-input-box > input.u2-input-editor {\nmax-width: 150px;\n}\n.u2-form-fill .u2-form-auto.u2-form-wide .u2-input-root .u2-input-box:has(> .u2-input-editor:is(.u2-number, .u2-date)),\n.u2-form-fill .u2-form-auto.u2-form-wide .u2-input-root[data-u2='choice-input'] .u2-input-box {\nflex: 1;\nmax-width: none;\n}\n.u2-form-fill .u2-form-auto.u2-form-wide .u2-input-root:not(.u2-input-fill)[data-u2] .u2-input-editor:is(.u2-number, .u2-date),\n.u2-form-fill .u2-form-auto.u2-form-wide .u2-input-root:not(.u2-input-fill)[data-u2='choice-input'] select.u2-input-editor {\nflex: 1;\nwidth: auto;\nmax-width: none;\n}\n.u2-form .u2-input-caption-after > .u2-input-label {\nmin-width: 0;\n}\n.u2-form-wide .u2-input-root[data-u2='bool-input'] .u2-input-editor,\n.u2-form-wide .u2-input-root[data-u2='radio-input'] .u2-input-editor,\n.u2-form-wide .u2-input-root[data-u2='multi-choice-input'] .u2-input-editor {\nflex: none;\nwidth: auto;\n}\n.u2-form-wide .u2-input-root[data-u2='bigint-input'] > .u2-input-box > input.u2-input-editor,\n.u2-form-wide .u2-input-root[data-u2='qnum-input'] > .u2-input-box > input.u2-input-editor,\n.u2-form-tall .u2-input-root[data-u2='bigint-input'] > .u2-input-box > input.u2-input-editor,\n.u2-form-tall .u2-input-root[data-u2='qnum-input'] > .u2-input-box > input.u2-input-editor {\nmax-width: none;\n}\n.u2-form-tall .u2-input-root {\nflex-wrap: wrap;\npadding-top: var(--dg-space-m);\n}\n.u2-form-tall .u2-input-label {\nflex-basis: 100%;\nmin-width: 0;\nmax-width: none;\nheight: auto;\nmargin: 0;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\ntext-align: left;\n}\n.u2-form.u2-form-tall .u2-input-root .u2-input-box {\nflex: 1 1 100%;\nwidth: auto;\nmax-width: none;\nmin-width: 0;\n}\n.u2-form-tall .u2-input-editor {\nflex: 1;\nwidth: auto;\nmax-width: none;\nmin-width: 0;\n}\n.u2-form-tall .u2-input-root[data-u2='bool-input'] {\nflex-wrap: nowrap;\n}\n.u2-form-tall .u2-input-root[data-u2='bool-input'] > .u2-input-label {\nflex-basis: auto;\nfont-size: var(--dg-font-size);\nmargin-right: var(--dg-space-m);\n}\n.u2-form.u2-form-tall .u2-input-root[data-u2='bool-input'] .u2-input-box,\n.u2-form.u2-form-tall .u2-input-root[data-u2='bool-input'] .u2-input-editor {\nflex: none;\nwidth: auto;\n}\n.u2-form-group {\ndisplay: flex;\nalign-items: flex-start;\n}\n.u2-form-group > .u2-form-group-label {\nflex: none;\n}\n.u2-form-group-items {\ndisplay: flex;\nflex: 1;\nflex-wrap: wrap;\nalign-items: center;\ncolumn-gap: var(--dg-space-xl);\nmin-width: 0;\n}\n.u2-form .u2-form-group-items > .u2-input-root {\nflex: none;\npadding: 0;\n}\n.u2-form .u2-form-group-items .u2-input-label {\nmin-width: 0;\n}\n.u2-form .u2-form-group-items > .u2-input-caption-after > .u2-input-label {\nmargin-left: var(--dg-space-s);\ncolor: var(--dg-text-color);\ntext-align: left;\n}\n.u2-form .u2-form-group-items .u2-input-error {\npadding-left: 0;\n}\n.u2-form-tall .u2-form-group {\nflex-wrap: wrap;\npadding-top: var(--dg-space-m);\n}\n.u2-form.u2-form-tall .u2-form-group-items .u2-input-root {\nflex-wrap: nowrap;\npadding-top: 0;\n}\n.u2-form.u2-form-tall .u2-form-group-items .u2-input-label {\nflex-basis: auto;\nfont-size: var(--dg-font-size);\n}\n.u2-form.u2-form-tall .u2-form-group-items .u2-input-root .u2-input-box {\nflex: none;\n}\n.u2-form-buttons {\ndisplay: flex;\njustify-content: flex-end;\nalign-items: center;\ngap: var(--dg-space-m);\nmargin-top: var(--dg-space-l);\n}\n.u2-form-buttons.u2-form-buttons-start {\njustify-content: flex-start;\n}\n.u2-form-buttons.u2-form-buttons-editors {\njustify-content: flex-start;\npadding-left: calc(var(--u2-form-label-width, 100px) + var(--dg-space-m));\n}\n.u2-form-tall .u2-form-buttons.u2-form-buttons-editors {\npadding-left: 0;\n}\n.u2-form .u2-btn-primary:not(:disabled, [aria-disabled='true']),\n.u2-form .u2-btn-primary:hover:not(:disabled, [aria-disabled='true']),\n.u2-form .u2-btn-primary:active:not(:disabled, [aria-disabled='true']),\n.u2-form-buttons .u2-btn-primary:not(:disabled, [aria-disabled='true']),\n.u2-form-buttons .u2-btn-primary:hover:not(:disabled, [aria-disabled='true']),\n.u2-form-buttons .u2-btn-primary:active:not(:disabled, [aria-disabled='true']) {\nbackground: var(--dg-blue-2);\n}\n.u2-form .u2-btn-primary,\n.u2-form-buttons .u2-btn-primary {\npadding: 0 12px;\n}\n.u2-param-source {\ndisplay: inline-flex;\nalign-items: center;\ngap: var(--dg-space-s);\nfont-size: var(--dg-font-size-small);\n}\n.u2-param-source[hidden] {\ndisplay: none;\n}\n.u2-input-disabled .u2-param-source {\npointer-events: auto;\n}\n.u2-param-source-error {\ncolor: var(--dg-error);\nmax-width: 260px;\n}\n.u2-param-source-notice {\ncolor: var(--dg-text-color-light);\nmax-width: 260px;\n}\n.u2-input-box:has(> .u2-param-source-error),\n.u2-input-box:has(> .u2-param-source-notice) {\nflex-wrap: wrap;\n}\n.u2-input-box > .u2-param-source-error,\n.u2-input-box > .u2-param-source-notice {\nflex: 1 0 100%;\nmax-width: none;\n}\n.u2-param-source-error .u2-param-source-message,\n.u2-param-source-notice .u2-param-source-message {\nmin-width: 0;\ndisplay: -webkit-box;\n-webkit-box-orient: vertical;\n-webkit-line-clamp: 3;\noverflow: hidden;\n}\n.u2-param-auto {\nalign-self: center;\nmargin-left: var(--dg-space-s);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\nuser-select: none;\n}\n.u2-form-category.u2-form-category-l1 {\nfont-size: var(--dg-font-size-h1);\n}\n.u2-form-category.u2-form-category-l3 {\nmargin-left: var(--dg-space-m);\nfont-size: var(--dg-font-size-small);\nfont-weight: var(--dg-font-weight-regular);\ncolor: var(--dg-text-color-light);\n}\n.u2-form-buttons > [data-u2='ff-history-icon'] {\nmargin-right: auto;\n}\n.u2-form-buttons > [data-u2='ff-history-icon'][hidden] {\ndisplay: none;\n}\n.u2-func-form-history-popup {\ndisplay: flex;\nbox-sizing: border-box;\nwidth: 420px;\nheight: 320px;\npadding: var(--dg-space-s);\nborder: var(--dg-overlay-border);\nborder-radius: var(--dg-radius-l);\nbackground: var(--dg-bg);\nbox-shadow: var(--dg-shadow-2);\n}\n.u2-func-form-history-popup .u2-fch {\nflex: 1;\nmin-width: 0;\n}\n.u2-form-columns {\n--u2-form-column-gap: var(--dg-space-xxl);\ndisplay: grid;\ngrid-template-columns: repeat(auto-fill, minmax(min(100%, max(var(--u2-form-column-min, 200px),\n(100% - (var(--u2-form-columns, 2) - 1) * var(--u2-form-column-gap)) / var(--u2-form-columns, 2))), 1fr));\ncolumn-gap: var(--u2-form-column-gap);\nalign-items: start;\n}\n.u2-form-rows > .u2-form-columns {\npadding: 0;\n}\n.u2-form-columns > .u2-input-root {\nmin-width: 0;\n}\n.u2-form.u2-form .u2-form-columns[data-u2-part='columns'] > .u2-input-root:not(.u2-input-fill) > .u2-input-box {\nflex: 1 1 0;\nmin-width: 0;\nmax-width: none;\n}\n.u2-form.u2-form .u2-form-columns[data-u2-part='columns'] > .u2-input-root:not(.u2-input-fill):is([data-u2='text-input'],\n[data-u2='choice-input'], [data-u2='number-input'], [data-u2='date-input'], [data-u2='suggest-input']) > .u2-input-box > .u2-input-editor {\nflex: 1 1 auto;\nwidth: auto;\nmin-width: 0;\nmax-width: none;\n}\n.u2-section {\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\n}\n.u2-section-header {\nposition: relative;\ndisplay: flex;\nalign-items: center;\nfont-weight: var(--dg-font-weight-bold);\noutline: none;\n}\n.u2-section-header[hidden] {\ndisplay: none;\n}\n.u2-section-header[role='button'] {\ncursor: pointer;\nuser-select: none;\n}\n.u2-section-header:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-section-chevron {\nposition: absolute;\ntop: 0;\nbottom: 0;\nleft: calc(-1 * var(--dg-space-xl));\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nwidth: var(--dg-space-xl);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\nopacity: 0;\ntransition: transform 100ms ease, opacity 100ms ease;\n}\n.u2-section-header:hover .u2-section-chevron,\n.u2-section-header:focus-visible .u2-section-chevron {\nopacity: 1;\n}\n.u2-section-header[aria-expanded='false'] .u2-section-chevron {\nopacity: 1;\ntransform: rotate(-90deg);\n}\n.u2-section-title {\nflex: none;\nmax-width: 100%;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-section-hint {\nmin-width: 0;\nmargin-left: var(--dg-space-m);\noverflow: hidden;\nfont-weight: var(--dg-font-weight-regular);\ncolor: var(--dg-text-color-light);\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-section-hint:empty {\ndisplay: none;\n}\n.u2-section-header[aria-expanded='true'] > .u2-section-hint {\ndisplay: none;\n}\n.u2-section-invalid > .u2-section-header > .u2-section-title,\n.u2-section-invalid > .u2-section-header > .u2-section-hint,\n.u2-section-header[aria-invalid='true'] > .u2-section-title,\n.u2-section-header[aria-invalid='true'] > .u2-section-hint {\ncolor: var(--dg-error);\n}\n.u2-section-hint > [hidden] {\ndisplay: none !important;\n}\n.u2-section-actions {\ndisplay: inline-flex;\nflex: none;\nalign-items: center;\ngap: var(--dg-space-xs);\nmargin-left: var(--dg-space-m);\nfont-weight: var(--dg-font-weight-regular);\n}\n.u2-section-reason {\nmin-width: 0;\nmargin-left: var(--dg-space-m);\noverflow: hidden;\nfont-weight: var(--dg-font-weight-regular);\ncolor: var(--dg-text-color-light);\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-section-reason:empty {\ndisplay: none;\n}\n.u2-section-header.u2-section-chevron-end > .u2-section-chevron {\nposition: static;\nflex: none;\nwidth: auto;\nmargin-left: var(--dg-space-s);\nopacity: 1;\ntransform: none;\n}\n.u2-section-header.u2-section-chevron-end[aria-expanded='true'] > .u2-section-chevron {\ntransform: rotate(180deg);\n}\n.u2-section-body {\ndisplay: flex;\nflex-direction: column;\n}\n.u2-splitter-panel:has(> .u2-section) {\ndisplay: flex;\nflex-direction: column;\n}\n.u2-splitter-panel > .u2-section {\ndisplay: flex;\nflex: 1;\nflex-direction: column;\nmin-height: 0;\n}\n.u2-splitter-panel > .u2-section > .u2-section-body {\nflex: 1;\nmin-height: 0;\n}\n.u2-page {\ndisplay: flex;\nflex-direction: column;\nbox-sizing: border-box;\nheight: 100%;\nmin-height: 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\n}\n.u2-page-header {\nflex: none;\npadding: var(--u2-page-padding-y, var(--dg-space-l)) var(--u2-page-padding-x, var(--dg-space-xxl)) 0;\n}\n.u2-page-body {\n--u2-form-max-width: var(--u2-page-max-width, 700px);\ndisplay: flex;\nflex: 1 1 auto;\nflex-direction: column;\ngap: var(--u2-page-gap, var(--dg-space-xxl));\nbox-sizing: border-box;\nmin-height: 0;\npadding: var(--u2-page-padding-y, var(--dg-space-l)) var(--u2-page-padding-x, var(--dg-space-xxl));\noverflow: auto;\n}\n.u2-page-body > * {\nflex: none;\nmax-width: var(--u2-page-max-width, none);\n}\n.u2-page-section {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-m);\nmin-width: 0;\n}\n.u2-page-section-header {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-xs);\nmin-width: 0;\n}\n.u2-page-section-title {\nmargin: 0 6px 0 0;\n}\n.u2-page-section-content {\nmin-width: 0;\npadding-left: var(--u2-page-section-indent, 0);\n}\n.u2-page-footer {\ndisplay: flex;\nflex: none;\nalign-items: center;\njustify-content: flex-end;\ngap: var(--dg-space-m);\npadding: var(--dg-space-l) var(--u2-page-padding-x, var(--dg-space-xxl));\nborder-top: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-page-footer:empty {\ndisplay: none;\n}\n.u2-page-footer > .u2-status-line {\nflex: 1 1 auto;\nmin-width: 0;\n}\n.u2-page-footer > .u2-form-buttons {\nflex: 1 1 auto;\nmargin-top: 0;\n}\n.u2-page-footer > .u2-form-buttons > .u2-status-line {\nflex: 1 1 auto;\nmin-width: 0;\n}\n.u2-master-detail {\nbox-sizing: border-box;\nheight: var(--u2-master-detail-height, 100%);\nmin-height: 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\noverflow: hidden;\n}\n.u2-master-detail-list {\nbox-sizing: border-box;\nheight: 100%;\npadding: var(--dg-space-s) 0;\noverflow-y: auto;\noutline: none;\n}\n.u2-master-detail-list:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-master-detail-row {\ndisplay: flex;\nalign-items: center;\ngap: 6px;\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-m);\ncursor: pointer;\n}\n.u2-master-detail-row:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-master-detail-row-current,\n.u2-master-detail-row-current:hover {\nbackground: var(--u2-row-selected-bg);\n}\n.u2-master-detail-check {\nflex: none;\nmargin: 0;\n}\n.u2-master-detail-label {\nflex: 1;\nmin-width: 0;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-master-detail-hint,\n.u2-master-detail-reason,\n.u2-master-detail-empty {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-grey-4);\n}\n.u2-master-detail-detail {\nbox-sizing: border-box;\nheight: 100%;\nmin-width: 0;\noverflow: hidden;\n}\n.u2-master-detail-empty {\ndisplay: block;\npadding: var(--dg-space-m) var(--dg-space-l);\n}\n.u2-master-detail-pane {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-s);\nbox-sizing: border-box;\nheight: 100%;\npadding: var(--dg-space-s) var(--dg-space-l);\noverflow-y: auto;\n}\n.u2-master-detail-pane[hidden],\n.u2-master-detail-reason[hidden],\n.u2-master-detail-empty[hidden] {\ndisplay: none;\n}\n.u2-master-detail-content {\ndisplay: flex;\nflex: 1 1 auto;\nflex-direction: column;\ngap: var(--dg-space-s);\nmin-height: 0;\n}\n.u2-master-detail-content > :is(.u2-div-v, .u2-list, .u2-tree, .u2-data-table),\n.u2-master-detail-content > .u2-div-v > :is(.u2-list, .u2-tree, .u2-data-table) {\nflex: 1 1 auto;\nmin-height: 0;\n}\n.u2-card {\ndisplay: flex;\nbox-sizing: border-box;\nflex-direction: column;\ngap: var(--dg-space-m);\npadding: var(--dg-space-l);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius-l);\n}\n.u2-card-header {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\n}\n.u2-card-icon {\nflex-shrink: 0;\ncolor: var(--dg-text-color-light);\n}\n.u2-card-titles {\ndisplay: flex;\nmin-width: 0;\nflex-direction: column;\ngap: var(--dg-space-xs);\n}\n.u2-card-title {\noverflow: hidden;\nfont-size: var(--dg-font-size-h2);\nfont-weight: var(--dg-font-weight-medium);\ntext-overflow: ellipsis;\nwhite-space: nowrap;\n}\n.u2-card-subtitle {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-card-actions {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nmargin-left: auto;\n}\n.u2-card-media {\noverflow: hidden;\nborder-radius: var(--dg-radius);\n}\n.u2-card-media-img {\ndisplay: block;\nwidth: 100%;\nobject-fit: cover;\n}\n.u2-card-body {\nmin-width: 0;\noverflow-wrap: break-word;\n}\n.u2-card-footer {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\npadding-top: var(--dg-space-m);\nborder-top: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-card-clickable {\ncursor: pointer;\n}\n.u2-card-clickable:hover {\nbackground: var(--dg-hover);\n}\n.u2-card-clickable:focus-visible,\n.u2-card-selectable:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-card-selectable {\ncursor: pointer;\n}\n.u2-card-selected {\noutline: 2px solid var(--dg-accent-secondary);\noutline-offset: calc(-1 * var(--dg-border-width));\n}\n.u2-card-compact {\ngap: var(--dg-space-s);\npadding: var(--dg-space-m);\n}\n.u2-card-compact .u2-card-title {\nfont-size: var(--dg-font-size);\n}\n.u2-stat-card {\nposition: relative;\ngap: var(--dg-space-xs);\n}\n.u2-stat-value {\nfont-size: calc(var(--dg-font-size-h1) * 1.75);\nfont-weight: var(--dg-font-weight-medium);\nline-height: 1.2;\ncolor: var(--dg-text-color);\noverflow-wrap: anywhere;\n}\n.u2-stat-card:has(> .u2-stat-icon) .u2-stat-value {\npadding-right: calc(var(--dg-font-size) + var(--dg-space-m));\n}\n.u2-stat-value .u2-skeleton {\npadding: 0;\n}\n.u2-stat-value .u2-skeleton-line {\nheight: var(--dg-space-xl);\n}\n.u2-stat-label {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-stat-delta {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-xs);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-stat-delta-up {\ncolor: var(--dg-success);\n}\n.u2-stat-delta-down {\ncolor: var(--dg-failure);\n}\n.u2-stat-icon {\nposition: absolute;\ntop: var(--dg-space-l);\nright: var(--dg-space-l);\ncolor: var(--dg-text-color-light);\n}\n.u2-stat-error {\nfont-size: var(--dg-font-size-small);\nline-height: var(--dg-line-height);\ncolor: var(--dg-error);\n}\n.u2-app-header {\ndisplay: flex;\nbox-sizing: border-box;\ngap: 30px;\npadding: var(--dg-space-l);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\n}\n.u2-app-header-named {\ngap: 60px;\n}\n.u2-app-header-rule {\nborder-bottom: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-app-header-lead {\ndisplay: flex;\nmin-width: 0;\nalign-items: flex-start;\ngap: 20px;\n}\n.u2-app-header-icon {\n--u2-app-header-icon: var(--u2-app-header-icon-size);\ndisplay: block;\nmin-width: 0;\nwidth: var(--u2-app-header-icon);\nheight: var(--u2-app-header-icon);\nobject-fit: contain;\nbackground-repeat: no-repeat;\nbackground-position: center;\nbackground-size: contain;\n}\ni.u2-app-header-icon {\nfont-size: calc(var(--u2-app-header-icon) * 0.8);\nline-height: var(--u2-app-header-icon);\ntext-align: center;\n}\n.u2-app-header-names {\ndisplay: flex;\nflex-direction: column;\ngap: 10px;\nmargin-top: 10px;\n}\n.u2-app-header-title {\nfont-size: 20px;\nfont-weight: var(--dg-font-weight-bold);\n}\n.u2-app-header-body {\ndisplay: flex;\nmin-width: 0;\nflex-direction: column;\ngap: 10px;\nmargin: 10px 0;\npadding: var(--dg-space-l);\n}\n.u2-app-header-items {\nmargin: 0;\npadding-left: 15px;\nlist-style: disc;\n}\n.u2-app-header-item + .u2-app-header-item {\nmargin-top: 6px;\n}\n.u2-app-header-learn-more {\nalign-self: flex-start;\nmargin-left: 15px;\n}\n.u2-app-header-body:not(:has(> .u2-app-header-learn-more))::after {\ncontent: '';\n}\n.u2-app-header-external {\nmargin: 0 0.2em;\nfont-size: 0.8em;\n}\n.u2-app-header-compact .u2-app-header-icon {\n--u2-app-header-icon: min(var(--u2-app-header-icon-size), 96px);\n}\n.u2-app-header.u2-app-header-narrow {\nflex-direction: column;\ngap: var(--dg-space-m);\npadding-left: 0;\n}\n.u2-app-header-narrow .u2-app-header-icon {\n--u2-app-header-icon: min(var(--u2-app-header-icon-size), 64px);\n}\n.u2-propgrid {\ndisplay: flex;\nflex-direction: column;\nbox-sizing: border-box;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\n}\n.u2-propgrid-row {\ndisplay: grid;\ngrid-template-columns: minmax(80px, 40%) 1fr;\nalign-items: center;\nbox-sizing: border-box;\nmin-height: var(--dg-inline-control-height);\ncolumn-gap: var(--dg-space-m);\npadding: 0 var(--dg-space-m);\n}\n.u2-propgrid-row:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-propgrid-name {\noverflow: hidden;\ncolor: var(--dg-text-color-light);\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-propgrid-editor {\nmin-width: 0;\n}\n.u2-propgrid-value {\ndisplay: block;\noverflow: hidden;\npadding: 0 var(--dg-space-s);\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-propgrid-editor > .u2-input-root {\nwidth: 100%;\n}\n.u2-propgrid-editor input.u2-input-editor,\n.u2-propgrid-editor select.u2-input-editor,\n.u2-propgrid-editor .u2-input-editor.u2-number {\nflex: 1;\nmin-width: 0;\n}\n.u2-propgrid-editor .u2-input-editor.u2-number {\nmax-width: none;\n}\n.u2-propgrid-editor > .u2-input-root > .u2-input-box {\nflex: 1 1 0;\nmin-width: 60px;\nmax-width: none;\n}\n.u2-propgrid-category {\ndisplay: flex;\nbox-sizing: border-box;\nalign-items: center;\ngap: var(--dg-space-s);\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-s);\nfont-weight: var(--dg-font-weight-bold);\nbackground: var(--dg-bg-secondary);\nborder-top: var(--dg-border-width) solid var(--dg-border-subtle);\ncursor: pointer;\noutline: none;\nuser-select: none;\n}\n.u2-propgrid-category:hover {\nbackground: var(--dg-hover);\n}\n.u2-propgrid-category:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width) - var(--dg-border-width));\n}\n.u2-propgrid-chevron {\ndisplay: flex;\nflex-shrink: 0;\nalign-items: center;\njustify-content: center;\nwidth: 12px;\nfont-size: var(--dg-font-size-xs);\ncolor: var(--dg-text-color-light);\ntransition: transform 100ms ease;\n}\n.u2-propgrid-category[aria-expanded='true'] .u2-propgrid-chevron {\ntransform: rotate(90deg);\n}\n.u2-propgrid-category-title {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-input-editor.u2-access-grid {\nwidth: 100%;\nborder-collapse: collapse;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\n}\n.u2-access-grid th {\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-m);\nfont-size: var(--dg-font-size-small);\nfont-weight: var(--dg-font-weight-regular);\ncolor: var(--dg-text-color-light);\ntext-align: left;\nwhite-space: nowrap;\nborder-bottom: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-access-grid td {\nheight: var(--dg-control-height);\npadding: var(--dg-space-xs) var(--dg-space-m);\nborder-bottom: var(--dg-border-width) solid var(--dg-border-subtle);\n}\n.u2-access-grid th.u2-access-grid-cap,\n.u2-access-grid td.u2-access-grid-cap {\nwidth: 56px;\ntext-align: center;\n}\n.u2-access-grid th.u2-access-grid-action,\n.u2-access-grid td.u2-access-grid-action {\nwidth: var(--dg-inline-control-height);\npadding: 0;\ntext-align: center;\n}\n.u2-access-grid-icon {\ndisplay: inline-flex;\nmargin-right: var(--dg-space-m);\nvertical-align: middle;\n}\n.u2-access-grid-principal {\nvertical-align: middle;\n}\n.u2-access-grid-inherited .u2-access-grid-principal {\ncolor: var(--dg-text-color-light);\n}\n.u2-access-grid-from {\nmargin-left: var(--dg-space-s);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-access-grid-remove {\nwidth: var(--dg-inline-control-height);\nheight: var(--dg-inline-control-height);\npadding: 0;\nfont: inherit;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\nbackground: none;\nborder: none;\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-access-grid-remove:hover {\ncolor: var(--dg-text-color);\nbackground: var(--dg-hover);\n}\n.u2-access-grid tfoot td {\npadding-top: var(--dg-space-s);\nborder-bottom: none;\n}\n.u2-access-grid-add {\nwidth: 100%;\nheight: var(--dg-inline-control-height);\nfont: inherit;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-accent);\nbackground: none;\nborder: none;\ncursor: pointer;\n}\n.u2-input-editor.u2-records {\ndisplay: flex;\nflex: 1;\nflex-direction: column;\nmin-width: 0;\nheight: auto;\npadding: 0;\n}\n.u2-input-root:not(.u2-input-inline)[data-u2='records-input'] > .u2-input-box {\nflex: 1 1 0;\nmin-width: var(--dg-form-min-editor-width);\nmax-width: none;\n}\n.u2-records-row {\ndisplay: grid;\ngrid-template-columns: var(--u2-records-tracks);\nalign-items: center;\ncolumn-gap: var(--dg-space-m);\nmin-height: var(--dg-control-height);\n}\n.u2-records-head {\nmin-height: 20px;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-records-head[hidden] {\ndisplay: none;\n}\n.u2-records-header {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-records-cell {\nmin-width: 0;\n}\n.u2-records-cell > .u2-input-box {\nwidth: 100%;\n}\n.u2-records-row .u2-records-cell .u2-input-editor {\nwidth: 100%;\nmin-width: 0;\n}\n.u2-records-cell > .u2-input-error {\ndisplay: none;\n}\n.u2-input-editor.u2-records.u2-invalid,\n.u2-input-editor.u2-records.u2-invalid:focus-within {\nborder-bottom: none;\n}\n.u2-records-add {\ndisplay: inline-flex;\nalign-items: center;\nalign-self: flex-start;\ngap: var(--dg-space-s);\nheight: var(--dg-control-height);\n}\n.u2-records-add-icon {\nfont-size: 11px;\n}\n.u2-input-disabled .u2-records-add,\n.u2-input-readonly .u2-records-add,\n.u2-input-disabled .u2-records-remove,\n.u2-input-readonly .u2-records-remove {\nvisibility: hidden;\n}\ndiv.u2-input-editor.u2-checklist {\ndisplay: flex;\nflex-direction: column;\nmin-width: 150px;\nheight: auto;\npadding: var(--dg-space-s) 0;\nborder: none;\n}\ndiv.u2-input-editor.u2-checklist.u2-invalid,\ndiv.u2-input-editor.u2-checklist.u2-invalid:focus-within {\nborder-bottom: none;\n}\n.u2-checklist-item {\ndisplay: flex;\nalign-items: center;\nmin-height: 20px;\nwhite-space: nowrap;\n}\n.u2-checklist-label {\ndisplay: flex;\nflex: 1 1 auto;\nalign-items: center;\nmin-width: 0;\ncursor: pointer;\n}\n.u2-checklist-label > .u2-input-checkbox {\nmargin: 0 var(--dg-space-m) 0 var(--dg-space-s);\n}\n.u2-checklist-empty {\ndisplay: flex;\nalign-items: center;\nheight: 20px;\npadding: 0 var(--dg-space-s);\ncolor: var(--dg-text-color-light);\nwhite-space: nowrap;\n}\n.u2-reorder-grip {\nflex-shrink: 0;\ncolor: var(--dg-grey-3);\ncursor: grab;\ntouch-action: none;\n}\n.u2-input-disabled .u2-reorder-grip,\n.u2-input-readonly .u2-reorder-grip {\nvisibility: hidden;\n}\n.u2-reorder-dragging {\nbackground: var(--dg-hover-subtle);\n}\n.u2-loader {\ndisplay: inline-flex;\nalign-items: center;\ngap: var(--dg-space-m);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color-light);\n}\n.u2-loader-spinner {\nbox-sizing: border-box;\nflex-shrink: 0;\nwidth: 16px;\nheight: 16px;\nborder: 2px solid var(--dg-border);\nborder-top-color: var(--dg-accent);\nborder-radius: 50%;\nanimation: u2-loader-spin 0.8s linear infinite;\n}\n@keyframes u2-loader-spin {\nto {\ntransform: rotate(360deg);\n}\n}\n.u2-skeleton {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-m);\npadding: var(--dg-space-m) 0;\n}\n.u2-skeleton-line {\nheight: var(--dg-space-l);\nbackground: var(--dg-bg-secondary);\nborder-radius: var(--dg-radius);\nanimation: u2-skeleton-pulse 1.4s ease-in-out infinite;\n}\n.u2-skeleton-line:last-child {\nwidth: 60%;\n}\n@keyframes u2-skeleton-pulse {\n50% {\nbackground: var(--dg-border);\n}\n}\n.u2-async-stale > * {\nopacity: 0.6;\n}\n.u2-async-empty {\npadding: var(--dg-space-xl);\ntext-align: center;\ncolor: var(--dg-text-color-light);\n}\n.u2-empty-state {\ndisplay: flex;\nflex-direction: column;\nalign-items: center;\njustify-content: center;\ngap: var(--dg-space-m);\npadding: var(--dg-space-xl);\ntext-align: center;\nfont-family: var(--dg-font-family);\n}\n.u2-empty-state-icon {\nfont-size: 24px;\ncolor: var(--dg-grey-3);\n}\n.u2-empty-state-text {\nmax-width: 480px;\nfont-size: var(--dg-font-size-h2);\ncolor: var(--dg-text-color);\n}\n.u2-empty-state-error .u2-empty-state-icon,\n.u2-empty-state-error .u2-empty-state-text {\ncolor: var(--dg-error);\n}\n.u2-empty-state-actions {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\n}\n.u2-async-error {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\npadding: var(--dg-space-m) 0;\n}\n.u2-async-error-message {\ncolor: var(--dg-error);\n}\n.u2-async-quiet .u2-async-error {\npadding: var(--dg-space-s) 0;\n}\n.u2-async-quiet .u2-async-error-message {\ncolor: var(--dg-text-color-light);\n}\n@media (prefers-reduced-motion: reduce) {\n.u2-loader-spinner {\nwidth: auto;\nheight: auto;\nborder: none;\nborder-radius: 0;\ncolor: var(--dg-accent);\nanimation: none;\n}\n.u2-loader-spinner::after {\ncontent: '•••';\n}\n.u2-skeleton-line {\nanimation: none;\n}\n}\n.u2-typeahead {\ndisplay: inline-block;\n}\n.u2-typeahead-input {\nbox-sizing: border-box;\nwidth: 100%;\nheight: var(--dg-control-height);\npadding: 0 var(--dg-space-xs);\nfont: inherit;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\nbackground: var(--dg-bg);\nborder: none;\nborder-bottom: var(--dg-input-border);\nborder-radius: 0;\noutline: none;\n}\n.u2-typeahead-input:focus {\nborder-bottom: var(--dg-input-border-focus);\n}\n.u2-typeahead-input::placeholder {\ncolor: var(--dg-text-color-light);\n}\n.u2-typeahead-popup {\nmin-width: 240px;\nmax-width: 480px;\n}\n.u2-input-root:has(.u2-typeahead-input[aria-expanded='true']) > .u2-input-error {\nvisibility: hidden;\n}\n.u2-typeahead-option-active .u2-typeahead-text,\n.u2-typeahead-option-active .u2-typeahead-user-name {\ncolor: var(--dg-accent);\n}\n.u2-typeahead-text {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-typeahead-user {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\nmin-width: 0;\n}\n.u2-typeahead-user-text {\nmin-width: 0;\n}\n.u2-typeahead-user-name,\n.u2-typeahead-user-secondary {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-typeahead-user-secondary {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-typeahead-user-secondary:empty::before {\ncontent: '\\00a0';\n}\n.u2-avatar {\nbox-sizing: border-box;\ndisplay: flex;\nflex-shrink: 0;\nalign-items: center;\njustify-content: center;\nwidth: 20px;\nheight: 20px;\noverflow: hidden;\nfont-size: var(--dg-font-size-xs);\nfont-weight: var(--dg-font-weight-medium);\nline-height: 1;\ncolor: var(--dg-white);\nborder-radius: 50%;\n}\n.u2-avatar-picture > * {\nwidth: 100%;\nheight: 100%;\n}\n.u2-avatar-group {\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color-light);\n}\n.u2-avatar-1 { background: var(--dg-steel-4); }\n.u2-avatar-2 { background: var(--dg-blue-1); }\n.u2-avatar-3 { background: var(--dg-green-2); }\n.u2-avatar-4 { background: var(--dg-orange-3); }\n.u2-avatar-5 { background: var(--dg-steel-5); }\n.u2-avatar-6 { background: var(--dg-grey-5); }\n.u2-pick-box {\nposition: relative;\ndisplay: flex;\nalign-items: center;\nflex: 1;\nmin-width: 0;\n}\n.u2-pick-box.u2-input-editor {\npadding: 0;\n}\n.u2-pick-box.u2-input-editor.u2-invalid {\nborder-bottom: none;\n}\n.u2-pick-box.u2-invalid .u2-typeahead-input {\nborder-bottom-color: var(--dg-error);\n}\n.u2-pick-box::before {\ncontent: '';\nposition: absolute;\nright: var(--dg-space-s);\nvisibility: hidden;\nwidth: 12px;\nheight: 12px;\npointer-events: none;\nbackground-color: var(--dg-text-color-light);\n-webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='6.8' cy='6.8' r='4.6'/%3E%3Cpath d='M10.2 10.2 14 14'/%3E%3C/svg%3E\") no-repeat center / 12px;\nmask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='6.8' cy='6.8' r='4.6'/%3E%3Cpath d='M10.2 10.2 14 14'/%3E%3C/svg%3E\") no-repeat center / 12px;\n}\n.u2-pick-box > .u2-typeahead {\nflex: 1;\nmin-width: 0;\n}\n.u2-input-root:not(.u2-input-disabled) .u2-pick-box:is(:hover, :focus-within):has(> .u2-input-clear[hidden])::before {\nvisibility: visible;\n}\n.u2-pick-box .u2-typeahead-input {\npadding: 0 20px 0 var(--dg-space-s);\n}\n.u2-pick-box-open .u2-typeahead-input {\npadding-right: 40px;\n}\n.u2-btn.u2-icon-btn.u2-pick-open {\nposition: absolute;\nright: 20px;\nwidth: 16px;\nmin-width: 16px;\nheight: 16px;\nfont-size: var(--dg-font-size-xs);\nvisibility: hidden;\n}\n.u2-input-root:not(.u2-input-disabled):hover .u2-pick-open,\n.u2-pick-box:focus-within .u2-pick-open {\nvisibility: visible;\n}\n.u2-pick-open[hidden] {\ndisplay: none;\n}\n.u2-pick-hint {\nflex: 1 0 100%;\nmin-width: 0;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-pick-dropdown .u2-typeahead-input {\ncursor: pointer;\n}\n.u2-pick-dropdown .u2-pick-box::before {\nvisibility: visible;\n-webkit-mask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E\") no-repeat center / 12px;\nmask: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E\") no-repeat center / 12px;\n}\n.u2-pick-dropdown:hover .u2-pick-box:has(> .u2-input-clear:not([hidden]))::before {\nvisibility: hidden;\n}\n.u2-chip {\ndisplay: inline-flex;\ngap: var(--dg-space-xs);\nalign-items: center;\nmax-width: 100%;\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-s);\noverflow: hidden;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\ncolor: var(--dg-text-color);\nwhite-space: nowrap;\ntext-overflow: ellipsis;\nvertical-align: middle;\ncursor: pointer;\nbackground: var(--dg-bg-secondary);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\n}\n.u2-chip:hover {\nbackground: var(--dg-hover);\n}\n.u2-chip:has(canvas, img) {\nheight: auto;\npadding: var(--dg-space-xs);\n}\n.u2-chip > span {\ndisplay: inline-flex;\nalign-items: center;\ngap: var(--dg-space-xs);\nmin-width: 0;\n}\n.u2-entity-card {\ndisplay: inline-block;\ncursor: pointer;\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\noverflow: hidden;\n}\n.u2-entity-card:hover {\nborder-color: var(--dg-accent);\n}\n.u2-badge {\ndisplay: inline-flex;\nbox-sizing: border-box;\nalign-items: center;\nheight: 16px;\npadding: 0 var(--dg-space-s);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size-xs);\nfont-weight: var(--dg-font-weight-medium);\nline-height: 1;\ncolor: var(--dg-grey-6);\nwhite-space: nowrap;\nbackground: var(--dg-grey-1);\nborder-radius: var(--dg-radius);\n}\n.u2-badge-accent {\ncolor: var(--dg-white);\nbackground: var(--dg-blue-1);\n}\n.u2-badge-success {\ncolor: var(--dg-green-3);\nbackground: var(--dg-green-1);\n}\n.u2-badge-warning {\ncolor: var(--dg-orange-3);\nbackground: var(--dg-orange-1);\n}\n.u2-badge-error {\ncolor: var(--dg-red-4);\nbackground: var(--dg-red-1);\n}\n.u2-count-badge {\ndisplay: inline-flex;\nbox-sizing: border-box;\nalign-items: center;\njustify-content: center;\nmin-width: 16px;\nheight: 16px;\npadding: 0 var(--dg-space-s);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size-xs);\nfont-weight: var(--dg-font-weight-medium);\nline-height: 1;\ncolor: var(--dg-white);\nbackground: var(--dg-accent);\nborder-radius: 8px;\n}\n.u2-dot {\ndisplay: inline-block;\nflex-shrink: 0;\nwidth: 8px;\nheight: 8px;\nbackground: var(--dg-grey-4);\nborder-radius: 50%;\n}\n.u2-dot-accent {\nbackground: var(--dg-blue-1);\n}\n.u2-dot-success {\nbackground: var(--dg-green-2);\n}\n.u2-dot-warning {\nbackground: var(--dg-orange-2);\n}\n.u2-dot-error {\nbackground: var(--dg-red-3);\n}\n.u2-tag {\ndisplay: inline-flex;\nbox-sizing: border-box;\nalign-items: center;\ngap: var(--dg-space-xs);\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-s);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color);\nwhite-space: nowrap;\nbackground: var(--dg-bg-secondary);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\n}\n.u2-tag-remove {\ndisplay: inline-flex;\nbox-sizing: border-box;\nalign-items: center;\njustify-content: center;\nwidth: 14px;\nheight: 14px;\npadding: 0;\nfont: inherit;\nfont-size: var(--dg-font-size-xs);\nline-height: 1;\ncolor: var(--dg-text-color-light);\nbackground: none;\nborder: none;\nborder-radius: var(--dg-radius);\ncursor: pointer;\n}\n.u2-tag-remove:hover {\ncolor: var(--dg-text-color);\nbackground: var(--dg-hover);\n}\n.u2-tag-remove:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-status-line {\ndisplay: flex;\nalign-items: baseline;\ngap: var(--dg-space-s);\nmin-width: 0;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size-small);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color-light);\n}\n.u2-status-line-text {\nmin-width: 0;\ndisplay: -webkit-box;\n-webkit-box-orient: vertical;\n-webkit-line-clamp: 2;\noverflow: hidden;\noverflow-wrap: anywhere;\n}\n.u2-status-line-problem {\ncolor: var(--dg-error);\n}\n.u2-status-line-warning.u2-status-line-problem {\ncolor: var(--dg-orange-3);\n}\n.u2-status-line-mark {\nflex: none;\n}\n.u2-status-line-mark[hidden] {\ndisplay: none;\n}\n.u2-table {\nborder-collapse: collapse;\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size);\nline-height: var(--dg-line-height);\ncolor: var(--dg-text-color);\noutline: none;\n}\n.u2-table:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-table-fixed {\ntable-layout: fixed;\nwidth: 100%;\n}\n.u2-table th,\n.u2-table td {\nheight: var(--dg-inline-control-height);\npadding: 0 0 0 var(--dg-space-l);\nborder-bottom: none;\ntext-align: left;\nvertical-align: middle;\nwhite-space: nowrap;\noverflow: hidden;\ntext-overflow: ellipsis;\n}\n.u2-table th {\ncolor: var(--dg-text-color);\nfont-size: var(--dg-font-size);\nfont-weight: var(--dg-font-weight-bold);\n}\n.u2-table thead th {\nposition: sticky;\ntop: 0;\nz-index: 1;\nbackground: var(--dg-bg);\n}\n.u2-table .u2-table-align-right {\ntext-align: right;\n}\n.u2-table .u2-table-align-center {\ntext-align: center;\n}\n.u2-table .u2-table-align-left {\ntext-align: left;\n}\n.u2-table-interactive .u2-table-row {\ncursor: pointer;\n}\n.u2-table-row:hover,\n.u2-table-row:hover > .u2-table-pin-start,\n.u2-table-row:hover > .u2-table-pin-end {\nbackground: linear-gradient(var(--u2-row-hover-bg), var(--u2-row-hover-bg)), var(--u2-row-base-bg);\n}\n.u2-table-row:hover > :first-child {\nbox-shadow: inset 4px 0 0 var(--u2-row-hover-stripe);\n}\n.u2-table-row-selected,\n.u2-table-row-selected:hover {\nbackground: var(--u2-row-selected-bg);\ncolor: var(--dg-selection-text);\n}\n.u2-table-control th,\n.u2-table-control td {\nheight: var(--dg-control-height);\n}\n.u2-table th.u2-table-sortable {\ncursor: pointer;\nuser-select: none;\n}\n.u2-table th.u2-table-sortable:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-table th.u2-table-sorted {\ncolor: var(--dg-accent);\n}\n.u2-table .u2-table-sort {\nmargin-left: var(--dg-space-s);\nfont-size: var(--dg-font-size-xs);\n}\n.u2-table .u2-table-pin-start,\n.u2-table .u2-table-pin-end {\nposition: sticky;\nz-index: 1;\nbackground: var(--u2-row-base-bg);\n}\n.u2-table .u2-table-pin-start {\nleft: 0;\n}\n.u2-table .u2-table-pin-end {\nright: 0;\n}\n.u2-table thead .u2-table-pin-start,\n.u2-table thead .u2-table-pin-end {\nz-index: 2;\n}\n.u2-table-row-selected > .u2-table-pin-start,\n.u2-table-row-selected > .u2-table-pin-end,\n.u2-table-row-selected:hover > .u2-table-pin-start,\n.u2-table-row-selected:hover > .u2-table-pin-end {\nbackground: var(--u2-row-selected-bg);\n}\n.u2-table .u2-table-section th {\ncolor: var(--dg-text-color);\nfont-weight: var(--dg-font-weight-bold);\nbackground: var(--u2-section-header-bg);\n}\n.u2-table .u2-table-section-foldable th {\ncursor: pointer;\nuser-select: none;\n}\n.u2-table .u2-table-section-foldable th:focus-visible {\noutline: var(--dg-focus-ring);\noutline-offset: calc(-1 * var(--dg-focus-ring-width));\n}\n.u2-table .u2-table-chevron {\nwidth: 10px;\nmargin-right: var(--dg-space-m);\ncolor: var(--dg-grey-5);\nfont-size: var(--dg-font-size-xs);\n}\n.u2-table .u2-table-section .u2-badge {\nmargin-left: var(--dg-space-m);\n}\n.u2-table-map td {\nborder-bottom: none;\nvertical-align: top;\n}\n.u2-table-map td:not(.u2-table-key) {\nheight: auto;\noverflow: visible;\nwhite-space: normal;\noverflow-wrap: anywhere;\n}\n.u2-table-map .u2-table-row:hover {\nbackground: none;\n}\n.u2-table-map .u2-table-key {\npadding-right: var(--dg-space-l);\ncolor: var(--dg-text-color-light);\n}\n.u2-catalog {\ndisplay: flex;\nflex-direction: column;\nalign-items: flex-start;\nmin-width: 0;\nmax-width: 100%;\n}\n.u2-catalog-body {\nmax-width: 100%;\n}\n.u2-catalog-scroll {\nmax-width: 100%;\noverflow-x: auto;\n}\n.u2-catalog .u2-skeleton {\nwidth: 860px;\nmax-width: 100%;\n}\n.u2-catalog .u2-empty-state {\nmax-width: 720px;\n}\n.u2-catalog-footer {\npadding-top: var(--dg-space-s);\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-catalog-actions .u2-row-actions {\ngap: 0;\nmargin-left: 0;\n}\n.u2-catalog .u2-table .u2-table-pin-end {\npadding-left: var(--dg-space-m);\n}\n.u2-catalog-actions-pending {\nvisibility: hidden;\n}\n.u2-catalog-view-only {\nwidth: var(--dg-button-height);\ncolor: var(--dg-grey-3);\ntext-align: center;\n}\n.u2-catalog-actions-always .u2-row-actions {\nopacity: 1;\npointer-events: auto;\n}\n.u2-catalog-actions-always .u2-row-actions .u2-btn.u2-icon-btn {\ncolor: var(--dg-grey-4);\n}\n.u2-catalog-actions-always .u2-table-row:hover .u2-row-actions .u2-btn.u2-icon-btn {\ncolor: var(--dg-accent);\n}\n.u2-catalog-actions-always .u2-row-actions .u2-btn.u2-icon-btn.u2-row-action-destructive:hover {\ncolor: var(--dg-error);\n}\n.u2-catalog-overflow .u2-table .u2-table-pin-end {\noverflow: visible;\n}\n.u2-catalog-refreshing .u2-icon {\nanimation: u2-catalog-spin 0.8s linear infinite;\n}\n@keyframes u2-catalog-spin {\nto {\ntransform: rotate(360deg);\n}\n}\n@media (prefers-reduced-motion: reduce) {\n.u2-catalog-refreshing .u2-icon {\nanimation: none;\n}\n}\n.u2-adaptive {\ncontainer-type: inline-size;\n}\n@container (max-width: 420px) {\n.u2-p2 {\ndisplay: none;\n}\n}\n@container (max-width: 340px) {\n.u2-p1 {\ndisplay: none;\n}\n}\n.u2-btn .u2-icon {\nflex-shrink: 0;\nwidth: 12px;\nheight: 12px;\nfont-size: 12px;\nline-height: 1;\ntext-align: center;\n}\n.u2-btn .u2-btn-label {\nline-height: 1;\n}\n.u2-btn.u2-icon-btn {\nwidth: var(--dg-button-height);\nmin-width: var(--dg-button-height);\nheight: var(--dg-button-height);\npadding: 0;\ncolor: var(--dg-accent);\nbackground: none;\nborder: var(--dg-border-width) solid transparent;\n}\n.u2-btn.u2-icon-btn:hover:not(:disabled, [aria-disabled='true']),\n.u2-btn.u2-icon-btn:active:not(:disabled, [aria-disabled='true']) {\nbackground: none;\nfilter: contrast(80%) brightness(120%);\n}\n.u2-btn.u2-icon-btn:is(:disabled, [aria-disabled='true']) {\ncolor: var(--dg-text-color-disabled);\n}\n.u2-btn.u2-icon-btn-pressed {\ncolor: var(--dg-accent);\nbackground: var(--dg-steel-1);\nborder-color: var(--dg-border);\n}\n.u2-btn.u2-icon-btn:focus-visible {\nborder-color: var(--dg-focus);\noutline: none;\n}\n.u2-toolbar .u2-btn {\nheight: var(--dg-button-height);\n}\n.u2-toolbar .u2-btn.u2-icon-btn {\nwidth: var(--dg-inline-control-height);\nmin-width: var(--dg-inline-control-height);\nheight: var(--dg-inline-control-height);\n}\n.d4-ribbon-item .u2-btn.u2-btn-primary {\nheight: var(--dg-inline-control-height);\npadding: 0 10px;\nfont-size: var(--dg-font-size-xs);\nletter-spacing: 1px;\n}\n.d4-ribbon-item .u2-btn.u2-btn-primary:not(:disabled, [aria-disabled='true']) {\nbackground: var(--dg-accent-secondary);\n}\n.d4-ribbon-item > .u2-btn:is(:disabled, [aria-disabled='true']):hover {\ncursor: default;\ncolor: var(--dg-text-color-disabled);\nbackground-color: transparent;\n}\n.d4-ribbon-item > .u2-btn.u2-btn-primary:is(:disabled, [aria-disabled='true']):hover {\ncolor: var(--dg-grey-4);\nbackground-color: var(--dg-steel-2);\n}\n.d4-toolbox .u2-btn:not(.u2-icon-btn) {\nheight: var(--dg-button-height);\npadding: 0 11px;\nfont-size: var(--dg-font-size-xs);\nfont-weight: 600;\nletter-spacing: 0.04em;\n}\n.d4-toolbox .u2-btn.u2-btn-primary {\nfont-weight: var(--dg-font-weight-regular);\n}\n.d4-toolbox .u2-btn.u2-btn-primary:not(:disabled, [aria-disabled='true']) {\nbackground: var(--dg-accent-secondary);\n}\n.u2-btn-group {\ndisplay: inline-flex;\nbox-sizing: border-box;\nflex-shrink: 0;\nalign-items: center;\n}\n.u2-btn-group-item {\ndisplay: inline-flex;\nbox-sizing: border-box;\nflex-shrink: 0;\nalign-items: center;\njustify-content: center;\ngap: var(--dg-space-s);\nheight: var(--dg-button-height);\nmargin: 0;\npadding: 0 var(--dg-space-m);\nfont-family: var(--dg-font-family);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color);\nwhite-space: nowrap;\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: 0;\ncursor: pointer;\noutline: none;\nuser-select: none;\n}\n.u2-btn-group-item .u2-icon {\nflex-shrink: 0;\nwidth: 12px;\nheight: 12px;\nfont-size: 12px;\nline-height: 1;\ntext-align: center;\n}\n.u2-btn-group-item + .u2-btn-group-item {\nmargin-left: calc(-1 * var(--dg-border-width));\n}\n.u2-btn-group-item:first-child {\nborder-top-left-radius: var(--dg-radius);\nborder-bottom-left-radius: var(--dg-radius);\n}\n.u2-btn-group-item:last-child {\nborder-top-right-radius: var(--dg-radius);\nborder-bottom-right-radius: var(--dg-radius);\n}\n.u2-btn-group-item:hover:not(:disabled, [aria-disabled='true']) {\nbackground: var(--dg-hover-subtle);\n}\n.u2-btn-group-item:active:not(:disabled, [aria-disabled='true']) {\nbackground: var(--dg-steel-1);\n}\n.u2-btn-group-item.u2-btn-group-selected {\nposition: relative;\nz-index: 1;\ncolor: var(--dg-selection-text);\nbackground: var(--dg-selection-bg);\nborder-color: var(--dg-steel-3);\n}\n.u2-btn-group-item:focus-visible {\nposition: relative;\nz-index: 2;\nborder-color: var(--dg-focus);\n}\n.u2-btn-group-item:is(:disabled, [aria-disabled='true']) {\ncolor: var(--dg-text-color-disabled);\nbackground: var(--dg-bg);\ncursor: default;\n}\n.u2-btn-group-icons .u2-btn-group-item {\nwidth: var(--dg-button-height);\npadding: 0;\n}\n.u2-btn-group-toolbar .u2-btn-group-item,\n.u2-btn-group-ribbon .u2-btn-group-item {\nheight: var(--dg-inline-control-height);\nbackground: none;\nborder-color: transparent;\n}\n.u2-btn-group-toolbar .u2-btn-group-item + .u2-btn-group-item,\n.u2-btn-group-ribbon .u2-btn-group-item + .u2-btn-group-item {\nborder-left-color: var(--dg-border-subtle);\n}\n.u2-btn-group-toolbar:hover .u2-btn-group-item,\n.u2-btn-group-ribbon:hover .u2-btn-group-item {\nborder-color: var(--dg-border);\n}\n.u2-btn-group-toolbar.u2-btn-group-icons .u2-btn-group-item,\n.u2-btn-group-ribbon.u2-btn-group-icons .u2-btn-group-item {\nwidth: var(--dg-inline-control-height);\n}\n.u2-btn-group-toolbar .u2-btn-group-item.u2-btn-group-selected,\n.u2-btn-group-ribbon .u2-btn-group-item.u2-btn-group-selected {\nbackground: var(--dg-selection-bg);\nborder-color: var(--dg-border);\n}\n.u2-btn-group-ribbon .u2-btn-group-item {\ngap: var(--dg-space-xs);\npadding: 0 var(--dg-space-s);\n}\n.u2-btn .u2-dropdown-chevron {\nwidth: 10px;\nheight: 10px;\nfont-size: 10px;\ncolor: var(--dg-text-color-light);\n}\n.u2-btn-primary .u2-dropdown-chevron {\ncolor: inherit;\n}\n.u2-dropdown-split {\ndisplay: inline-flex;\nbox-sizing: border-box;\nflex-shrink: 0;\nalign-items: center;\n}\n.u2-dropdown-split .u2-btn {\nborder-radius: 0;\n}\n.u2-dropdown-split .u2-btn:first-child {\nborder-top-left-radius: var(--dg-radius);\nborder-bottom-left-radius: var(--dg-radius);\n}\n.u2-dropdown-split .u2-btn:last-child {\nborder-top-right-radius: var(--dg-radius);\nborder-bottom-right-radius: var(--dg-radius);\n}\n.u2-dropdown-arrow {\npadding: 0 var(--dg-space-s);\nborder-left: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-dropdown-arrow.u2-btn-primary {\nborder-left-color: var(--dg-accent);\n}\n.u2-ribbon-group {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-s);\nheight: 100%;\n}\n.d4-ribbon-panel.u2-ribbon-pinned {\nposition: sticky;\nright: 0;\nz-index: 2;\nbackground: var(--dg-bg);\n}\n.u2-ribbon-rule {\nflex-shrink: 0;\nwidth: 1px;\nheight: 18px;\nbackground: var(--dg-grey-2);\n}\n.u2-ribbon-icons {\ndisplay: flex;\nalign-items: center;\n}\n.u2-ribbon-icons[hidden],\n.u2-ribbon-group > .u2-btn[hidden],\n.u2-ribbon-icons > .u2-btn[hidden] {\ndisplay: none;\n}\n.d4-ribbon-item .u2-ribbon-group .u2-btn.u2-icon-btn {\nwidth: 24px;\nmin-width: 24px;\nheight: 24px;\ncolor: var(--dg-steel-5);\n}\n.d4-ribbon-item .u2-ribbon-group .u2-btn.u2-icon-btn .u2-icon {\nwidth: 16px;\nheight: 16px;\nfont-size: 16px;\n}\n.d4-ribbon-item:hover .u2-ribbon-group .u2-icon-btn .u2-icon {\ncolor: inherit;\n}\n.u2-ribbon-more {\nposition: relative;\n}\n.u2-ribbon-hint-dot {\nposition: absolute;\ntop: 1px;\nright: 1px;\nwidth: 7px;\nheight: 7px;\nborder-radius: 50%;\nbackground: var(--dg-orange-2);\n}\n.u2-ribbon-hint-dot[hidden] {\ndisplay: none;\n}\n.u2-designer {\nposition: relative;\ndisplay: flex;\nflex-direction: column;\nheight: 100%;\noverflow: auto;\n}\n.u2-designer-surface {\ndisplay: flex;\nflex: 1 0 auto;\nflex-direction: column;\nbox-sizing: border-box;\npadding: var(--dg-space-m);\n}\n.u2-designer-surface > .u2-spec {\ndisplay: flex;\nflex: 1 0 auto;\nflex-direction: column;\n}\n.u2-designer-surface > .u2-spec > .u2-designer-root {\nflex: 1 0 auto;\n}\n.u2-designer-pane {\nposition: absolute;\ninset: 0;\nz-index: 2;\ncursor: default;\n}\n.u2-designer-selected,\n.u2-designer-hover {\nposition: absolute;\ndisplay: none;\nz-index: 3;\nbox-sizing: border-box;\npointer-events: none;\n}\n.u2-designer-selected {\noutline: 2px solid var(--dg-accent);\noutline-offset: 1px;\n}\n.u2-designer-hover {\noutline: var(--dg-border-width) dashed var(--dg-accent-secondary);\noutline-offset: 1px;\n}\n.u2-designer-drop-into,\n.u2-designer-drop-line {\nposition: absolute;\ndisplay: none;\nz-index: 4;\nbox-sizing: border-box;\npointer-events: none;\n}\n.u2-designer-drop-into {\noutline: 2px dashed var(--dg-accent);\noutline-offset: -1px;\nbackground: var(--dg-selection-bg);\n}\n.u2-designer-drop-line {\nbackground: var(--dg-accent);\n}\n.u2-designer-drag-ghost {\nposition: absolute;\nz-index: 5;\npointer-events: none;\npadding: var(--dg-space-xs) var(--dg-space-s);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\nbackground: var(--dg-bg);\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\nbox-shadow: var(--dg-shadow-1);\n}\n.u2-designer:not(.u2-designer-running) .u2-designer-root {\noutline: 1px solid var(--dg-border);\noutline-offset: -1px;\n}\n.u2-designer.u2-designer-outlines:not(.u2-designer-running) .u2-designer-node:not(.u2-designer-root) {\noutline: 1px dashed var(--dg-border);\n}\n.u2-designer:not(.u2-designer-running) .u2-designer-empty {\nmin-height: 64px;\nborder: var(--dg-border-width) dashed var(--dg-border);\nborder-radius: var(--dg-radius);\n}\n.u2-designer:not(.u2-designer-running) .u2-designer-empty::after {\ncontent: 'Drop here';\ndisplay: block;\npadding: var(--dg-space-xs) var(--dg-space-s);\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-designer-tray {\nposition: sticky;\nbottom: 0;\nz-index: 6;\ndisplay: flex;\nflex: none;\nflex-wrap: wrap;\nalign-items: center;\ngap: var(--dg-space-xs);\npadding: var(--dg-space-xs) var(--dg-space-s);\nborder-top: var(--dg-border-width) solid var(--dg-border);\nbackground: var(--dg-bg-secondary);\n}\n.u2-designer.u2-designer-running .u2-designer-tray {\ndisplay: none;\n}\n.u2-designer-tray-drop {\noutline: 2px dashed var(--dg-accent);\noutline-offset: -2px;\nbackground: var(--dg-selection-bg);\n}\n.u2-designer-tray-hint {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-designer-tray-add {\nflex: none;\n}\n.u2-designer-chip {\npadding: var(--dg-space-xs) var(--dg-space-s);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\nbackground: var(--dg-bg);\nfont-size: var(--dg-font-size-small);\ncursor: pointer;\nuser-select: none;\n}\n.u2-designer-chip-selected {\nborder-color: var(--dg-accent);\nbackground: var(--dg-selection-bg);\ncolor: var(--dg-selection-text);\n}\n.u2-designer-chip-broken,\n.u2-designer-chip-error {\nborder-color: var(--dg-red-3);\nbackground: var(--dg-red-1);\ncolor: var(--dg-red-4);\n}\n.u2-designer-chip-loading {\nborder-style: dashed;\ncolor: var(--dg-text-color-light);\n}\n.u2-designer-toolbox {\ndisplay: flex;\nflex-direction: column;\nbox-sizing: border-box;\nheight: 100%;\nmin-height: 200px;\npadding: var(--dg-space-m);\ngap: var(--dg-space-s);\n}\n.u2-designer-toolbox > .u2-tree {\nflex: 1 1 auto;\nmin-height: 0;\n}\n.u2-designer-toolbox > .u2-palette {\nflex: 0 0 auto;\nmax-height: 40%;\n}\n.u2-palette {\ndisplay: flex;\nflex-direction: column;\nmin-height: 0;\ngap: var(--dg-space-s);\n}\n.u2-palette-list {\noverflow: auto;\n}\n.u2-palette-list.u2-accordion {\nbackground: none;\n}\n.u2-palette .u2-accordion-header {\nheight: auto;\npadding: var(--dg-space-xs) var(--dg-space-s) var(--dg-space-xs) var(--dg-space-xxl);\n}\n.u2-palette .u2-accordion-chevron {\nfont-size: var(--dg-font-size-xs);\n}\n.u2-palette .u2-accordion-title {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-xs);\nfont-weight: var(--dg-font-weight-medium);\ntext-transform: uppercase;\n}\n.u2-palette .u2-accordion-content {\npadding: 0 0 var(--dg-space-xs);\n}\n.u2-palette-item {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-xs);\npadding: var(--dg-space-xs) var(--dg-space-s);\nborder-radius: var(--dg-radius);\ncursor: grab;\nuser-select: none;\n}\n.u2-palette-item-icon {\ndisplay: flex;\nflex: none;\nalign-items: center;\njustify-content: center;\nwidth: 16px;\nheight: 16px;\noverflow: hidden;\n}\n.u2-palette-item-icon img,\n.u2-palette-item-icon svg,\n.u2-palette-item-icon i {\nmax-width: 16px;\nmax-height: 16px;\nfont-size: var(--dg-font-size-small);\n}\n.u2-palette-item-label {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-palette-item:hover {\nbackground: var(--dg-hover);\n}\n.u2-designer-properties {\ngap: var(--dg-space-s);\npadding: var(--dg-space-m);\n}\n.u2-designer-caption {\nfont-family: var(--dg-font-family-mono);\nfont-size: var(--dg-font-size-small);\n}\n.u2-designer-hint {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-designer-properties > .u2-designer-caption {\nfont-size: var(--dg-font-size-h2);\nfont-weight: var(--dg-font-weight-medium);\ncolor: var(--dg-text-color);\n}\n.u2-designer-spec-editor textarea {\nwidth: 520px;\nheight: 320px;\nfont-family: var(--dg-font-family-mono);\nfont-size: var(--dg-font-size-small);\n}\n.u2-bind-picker-body {\ngap: var(--dg-space-s);\nmin-width: 380px;\n}\n.u2-bind-picker .u2-tree {\nheight: 280px;\nborder: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-bind-picker-hint {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-func-picker-body {\ngap: var(--dg-space-s);\nmin-width: 420px;\n}\n.u2-func-picker .u2-list {\nheight: 240px;\nborder: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-func-picker-params {\nmax-height: 240px;\noverflow-y: auto;\n}\n.u2-func-picker-hint {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\n}\n.u2-func-row {\ndisplay: flex;\nalign-items: center;\nbox-sizing: border-box;\nheight: 100%;\npadding: 0 var(--dg-space-xs);\noverflow: hidden;\ngap: var(--dg-space-s);\nline-height: normal;\n}\n.u2-func-row-icon {\ndisplay: flex;\nflex: none;\nalign-items: center;\njustify-content: center;\nwidth: 16px;\nheight: 16px;\noverflow: hidden;\n}\n.u2-func-row-icon img,\n.u2-func-row-icon svg,\n.u2-func-row-icon i {\nmax-width: 16px;\nmax-height: 16px;\nfont-size: var(--dg-font-size-small);\n}\n.u2-func-row-label {\nflex: 0 1 auto;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-func-row-name,\n.u2-func-row-desc {\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\nwhite-space: nowrap;\n}\n.u2-func-row-name {\nflex: none;\nfont-family: var(--dg-font-family-mono);\n}\n.u2-func-row-desc {\nflex: 1 1 auto;\noverflow: hidden;\ntext-overflow: ellipsis;\n}\n.u2-picker-empty {\ndisplay: flex;\nalign-items: center;\njustify-content: center;\nbox-sizing: border-box;\npadding: var(--dg-space-m);\nborder: var(--dg-border-width) solid var(--dg-border);\ncolor: var(--dg-text-color-light);\nfont-size: var(--dg-font-size-small);\ntext-align: center;\n}\n.u2-bind-picker .u2-picker-empty {\nheight: 280px;\n}\n.u2-func-picker .u2-picker-empty {\nheight: 240px;\n}\n.u2-designer-look {\nwidth: 100%;\n}\n.u2-designer-look .property-grid-category td {\nfont-size: var(--dg-font-size);\nfont-weight: var(--dg-font-weight-medium);\n}\n.u2-designer-look .property-grid td:first-child {\nwidth: 55%;\n}\n.u2-designer-look-set td:first-child {\nfont-weight: var(--dg-font-weight-medium);\n}\n.u2-designer-look tr[data-prop-name]:focus {\noutline: none;\n}\n.u2-designer-verbs {\nflex-wrap: wrap;\ngap: var(--dg-space-xs);\n}\n.u2-bind-chip {\ndisplay: inline-flex;\nalign-items: center;\ngap: var(--dg-space-xs);\nmax-width: 100%;\npadding: 0 var(--dg-space-xs);\nfont-size: var(--dg-font-size-small);\nborder: var(--dg-border-width) solid var(--dg-border);\nborder-radius: var(--dg-radius);\nbackground: var(--dg-bg-secondary);\ncursor: pointer;\n}\n.u2-bind-chip:hover {\nbackground: var(--dg-hover);\n}\n.u2-bind-chip-path {\noverflow: hidden;\ntext-overflow: ellipsis;\nwhite-space: nowrap;\nfont-family: var(--dg-font-family-mono);\ncolor: var(--dg-accent);\n}\n.u2-bind-chip-two-way {\ncolor: var(--dg-text-color-light);\n}\n.u2-bind-chip-clear {\nmargin-left: auto;\n}\n.u2-viewer {\nbox-sizing: border-box;\nwidth: 100%;\nheight: 100%;\nmin-height: var(--u2-viewer-min-height, 200px);\n}\n.u2-input-root[data-u2='filter-builder'] {\nalign-items: flex-start;\n}\n.u2-input-root[data-u2='filter-builder'] > .u2-input-box {\nflex: 1 1 0;\nmin-width: var(--dg-form-min-editor-width);\n}\n.u2-input-editor.u2-fb {\nposition: relative;\ndisplay: flex;\nflex: 1 1 auto;\nflex-direction: column;\ngap: var(--dg-space-s);\nmin-width: 0;\nheight: auto;\npadding: 0;\n}\n.u2-input-root[data-u2='filter-builder'].u2-input-inline > .u2-input-box > .u2-input-editor {\nheight: auto;\n}\n.u2-input-root[data-u2='filter-builder']:not(.u2-fb-blank) > .u2-input-error {\ndisplay: none;\n}\n.u2-input-root[data-u2='filter-builder'].u2-fb-blank > .u2-input-error:not(:empty) {\ndisplay: -webkit-box;\n}\n.u2-input-disabled .u2-fb .u2-btn.u2-icon-btn,\n.u2-input-disabled .u2-fb .u2-fb-mode,\n.u2-input-disabled .u2-fb .u2-fb-none-add {\ncolor: var(--dg-text-color-light);\n}\n.u2-input-root[data-u2='filter-builder'].u2-input-readonly .u2-fb-add,\n.u2-input-root[data-u2='filter-builder'].u2-input-readonly .u2-fb-add-group,\n.u2-input-root[data-u2='filter-builder'].u2-input-readonly .u2-fb-remove,\n.u2-input-root[data-u2='filter-builder'].u2-input-readonly .u2-fb-handle,\n.u2-input-root[data-u2='filter-builder'].u2-input-readonly .u2-fb-mode,\n.u2-input-root[data-u2='filter-builder'].u2-input-readonly .u2-fb-none-add {\ndisplay: none;\n}\n.u2-input-editor.u2-fb.u2-invalid {\nborder-bottom: none;\n}\n.u2-fb [hidden] {\ndisplay: none !important;\n}\n.u2-fb-root,\n.u2-fb-group {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-s);\nmin-width: 0;\n}\n.u2-fb-header,\n.u2-fb-group-header {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\n}\n.u2-fb-mode {\nmargin-left: auto;\nfont-size: var(--dg-font-size-small);\n}\n.u2-fb-group {\npadding-left: var(--dg-space-m);\nborder-left: 2px solid var(--dg-border);\n}\n.u2-fb-group-header {\nmin-height: var(--dg-control-height);\n}\n.u2-fb-group-rows {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-xs);\nmin-width: 0;\n}\n.u2-fb-group.u2-fb-negated {\nborder-left-color: var(--dg-accent);\n}\n.u2-btn.u2-fb-not {\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-m);\nfont-size: var(--dg-font-size-small);\nfont-weight: var(--dg-font-weight-medium);\nletter-spacing: 0.04em;\ntext-transform: uppercase;\ncolor: var(--dg-text-color);\n}\n.u2-btn.u2-fb-not-on {\ncolor: var(--dg-selection-text);\nbackground: var(--dg-selection-bg);\nborder-color: var(--dg-selection-bg);\n}\n.u2-fb-handle {\ndisplay: inline-flex;\nalign-items: center;\nalign-self: stretch;\npadding: 0 var(--dg-space-xs);\ncolor: var(--dg-text-color-light);\ncursor: grab;\ntouch-action: none;\nuser-select: none;\n}\n.u2-fb-handle:hover {\ncolor: var(--dg-text-color);\n}\n.u2-fb-dragging {\nopacity: 0.5;\n}\n.u2-fb-drop {\nposition: absolute;\nz-index: 1;\nbox-sizing: border-box;\npointer-events: none;\n}\n.u2-fb-drop-line {\nbackground: var(--dg-accent);\n}\n.u2-fb-drop-into {\noutline: 2px dashed var(--dg-accent);\noutline-offset: -1px;\nbackground: var(--dg-selection-bg);\nopacity: 0.5;\n}\n.u2-fb-connector .u2-btn-group-item {\npadding: 0 var(--dg-space-m);\nfont-size: var(--dg-font-size-small);\nfont-weight: var(--dg-font-weight-medium);\nletter-spacing: 0.04em;\ntext-transform: uppercase;\n}\n.u2-fb-rows {\ndisplay: flex;\nflex-direction: column;\ngap: var(--dg-space-l);\nmin-width: 0;\n}\n.u2-fb-cond {\ndisplay: flex;\nflex-wrap: wrap;\nalign-items: center;\ngap: var(--dg-space-xs) var(--dg-space-m);\nmin-height: var(--dg-control-height);\npadding: 0 var(--dg-space-s);\nborder-radius: var(--dg-radius);\n}\n.u2-fb-cond:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-fb-cond .u2-input-root {\nflex-wrap: nowrap;\npadding: 0;\n}\n.u2-fb-cond .u2-input-error {\ndisplay: none;\n}\n.u2-fb-cond > .u2-fb-prop,\n.u2-fb-cond > .u2-fb-op {\nflex: 0 1 120px;\nmin-width: 60px;\n}\n.u2-fb-cond > .u2-fb-op {\nflex-shrink: 3;\n}\n.u2-fb-cond > .u2-fb-prop > .u2-input-box,\n.u2-fb-cond > .u2-fb-op > .u2-input-box {\nflex: 1 1 auto;\nmin-width: 0;\n}\n.u2-fb-prop select.u2-input-editor,\n.u2-fb-op select.u2-input-editor {\nwidth: 100%;\nmin-width: 0;\n}\n.u2-fb-prop-text,\n.u2-fb-op-text {\nwhite-space: nowrap;\n}\n.u2-fb-op-text {\ncolor: var(--dg-text-color-light);\n}\n.u2-fb-values {\ndisplay: flex;\nflex: 1 1 auto;\nflex-wrap: wrap;\nalign-items: center;\ngap: var(--dg-space-xs) var(--dg-space-s);\nmin-width: 0;\n}\n.u2-fb-values > * {\nflex-shrink: 1;\nmin-width: 0;\n}\n.u2-fb-values > .u2-input-root {\nflex: 1 1 auto;\n}\n.u2-fb-values .u2-input-box {\nflex: 1 1 auto;\nmin-width: 0;\n}\n.u2-fb-values .u2-input-editor {\nmin-width: 0;\nmax-width: 100%;\n}\n.u2-fb-cond .u2-fb-values .u2-input-root[data-u2='text-input'] > .u2-input-box > input.u2-input-editor,\n.u2-fb-cond .u2-fb-values .u2-input-root[data-u2='suggest-input'] > .u2-input-box > input.u2-input-editor {\nflex: 1 1 auto;\nwidth: auto;\n}\n.u2-fb-cond > .u2-fb-remove {\nmargin-left: auto;\n}\n.u2-fb-problem {\nflex: 1 0 100%;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-error);\n}\n.u2-fb-and {\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-fb-invalid {\nbox-shadow: inset 2px 0 0 var(--dg-error);\n}\n.u2-fb-missing .u2-fb-values .u2-input-editor {\nborder-bottom-color: var(--dg-error);\n}\n.u2-fb-nested-text {\nfont-family: var(--dg-font-family-mono);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-fb-none {\ngap: var(--dg-space-m);\npadding: 0 var(--dg-space-s);\nfont-size: var(--dg-font-size-small);\nline-height: var(--dg-control-height);\ncolor: var(--dg-text-color-light);\n}\n.u2-fb-hint {\ndisplay: flex;\ngap: var(--dg-space-s);\npadding: var(--dg-space-xs) var(--dg-space-s);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\n}\n.u2-fb-query {\npadding: var(--dg-space-xs) var(--dg-space-s);\nfont-family: var(--dg-font-family-mono);\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\nwhite-space: pre-wrap;\nword-break: break-word;\n}\n.u2-fb-advanced .u2-fb-rows,\n.u2-fb-advanced .u2-fb-group-rows {\ngap: 0;\n}\n.u2-fb-advanced .u2-fb-cond,\n.u2-fb-advanced .u2-fb-group {\npadding-top: calc(var(--dg-space-xs) / 2);\npadding-bottom: calc(var(--dg-space-xs) / 2);\n}\n.u2-fb-horizontal .u2-fb-rows {\nflex-direction: row;\nflex-wrap: wrap;\nalign-items: center;\ngap: var(--dg-space-s);\n}\n.u2-fb-horizontal .u2-fb-cond {\nflex-wrap: nowrap;\ngap: var(--dg-space-s);\nmax-width: 100%;\nmin-width: 0;\nbackground: var(--dg-bg);\nborder: var(--dg-border-width) solid var(--dg-border);\n}\n.u2-fb-horizontal .u2-fb-cond > .u2-fb-prop,\n.u2-fb-horizontal .u2-fb-cond > .u2-fb-op {\nflex-basis: auto;\n}\n.u2-fb-horizontal .u2-fb-problem {\nflex: 0 1 auto;\nmin-width: 0;\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-fb-horizontal .u2-fb-cond:hover {\nbackground: var(--dg-hover-subtle);\n}\n.u2-btn.u2-fb-join {\nheight: var(--dg-inline-control-height);\npadding: 0 var(--dg-space-m);\nfont-weight: var(--dg-font-weight-medium);\ncolor: var(--dg-selection-text);\nbackground: var(--dg-selection-bg);\nborder-radius: 999px;\n}\n.u2-btn.u2-fb-join:hover:not(:disabled, [aria-disabled='true']) {\nbackground: var(--dg-hover);\n}\n.u2-fb-narrow .u2-fb-rows,\n.u2-fb-narrow .u2-fb-group-rows {\ngap: 0;\n}\n.u2-fb-narrow .u2-fb-cond:not(.u2-fb-nested) {\ndisplay: grid;\ngrid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;\ngrid-template-areas: 'prop op remove' 'value value value';\nalign-items: center;\ngap: var(--dg-space-xs) var(--dg-space-s);\npadding: var(--dg-space-s);\nbackground: var(--dg-bg-secondary);\nbackground-clip: padding-box;\nborder-bottom: var(--dg-space-s) solid transparent;\n}\n.u2-fb-narrow .u2-fb-advanced .u2-fb-cond:not(.u2-fb-nested) {\ngrid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;\ngrid-template-areas: 'handle prop op remove' 'handle value value value';\n}\n.u2-fb-narrow .u2-fb-group {\nbackground-clip: padding-box;\nborder-bottom: var(--dg-space-s) solid transparent;\n}\n.u2-fb-narrow .u2-fb-group .u2-fb-cond:not(.u2-fb-nested) {\nbackground: var(--dg-bg);\n}\n.u2-fb-narrow .u2-fb-group .u2-fb-group .u2-fb-cond:not(.u2-fb-nested) {\nbackground: var(--dg-bg-secondary);\n}\n.u2-fb-narrow .u2-fb-cond > .u2-fb-handle {\ngrid-area: handle;\n}\n.u2-fb-narrow .u2-fb-cond > .u2-fb-prop,\n.u2-fb-narrow .u2-fb-cond > .u2-fb-prop-text {\ngrid-area: prop;\n}\n.u2-fb-narrow .u2-fb-cond > .u2-fb-op,\n.u2-fb-narrow .u2-fb-cond > .u2-fb-op-text {\ngrid-area: op;\n}\n.u2-fb-narrow .u2-fb-cond > .u2-fb-values {\ngrid-area: value;\n}\n.u2-fb-narrow .u2-fb-cond > .u2-fb-remove {\ngrid-area: remove;\n}\n.u2-input-root[data-u2='filter-query-input'] > .u2-input-box {\nflex: 1 1 auto;\nmin-width: 120px;\n}\n.u2-input-root[data-u2='filter-query-input'] > .u2-input-box > .u2-input-editor {\nflex: 1 1 auto;\nwidth: 100%;\nmin-width: 0;\n}\n.u2-fq-search::before {\n-webkit-mask-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M2 3h12l-4.6 5.4V13l-2.8 1.2V8.4z'/%3E%3C/svg%3E\");\nmask-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M2 3h12l-4.6 5.4V13l-2.8 1.2V8.4z'/%3E%3C/svg%3E\");\n}\n.u2-fq-option-active .u2-fq-text,\n.u2-fq-option-active .u2-fq-code {\ncolor: var(--dg-accent);\n}\n.u2-fq-row {\ndisplay: flex;\nalign-items: center;\ngap: var(--dg-space-m);\nmin-width: 0;\n}\n.u2-fq-icon {\nflex-shrink: 0;\nwidth: 1em;\ncolor: var(--dg-text-color-light);\ntext-align: center;\n}\n.u2-fq-text,\n.u2-fq-code {\noverflow: hidden;\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n.u2-suggest-popup.u2-fq-popup {\nmin-width: 160px;\nmax-width: 320px;\nborder-radius: 0;\nbox-shadow: var(--dg-shadow-1);\n}\n.u2-fq-info {\ncolor: var(--dg-text-color-light);\n}\n.u2-fq-secondary {\nmargin-left: auto;\noverflow: hidden;\nfont-size: var(--dg-font-size-small);\ncolor: var(--dg-text-color-light);\nwhite-space: nowrap;\ntext-overflow: ellipsis;\n}\n@media (prefers-reduced-motion: reduce) {\n.u2-dialog-busy {\nanimation: none;\n}\n.u2-notify-timer {\ndisplay: none;\n}\n.u2-section-chevron,\n.u2-accordion-chevron,\n.u2-multi-choice-chevron,\n.u2-choice-chip > .u2-choice-chip-caret,\n.u2-propgrid-chevron,\n.u2-input-switch-thumb {\ntransition: none;\n}\n}":e,s.setAttribute("data-revision",String(i)),s.setAttribute("data-hash",r),j.installed()}static _packageZone(e){var t;let n=Array.from(e.children),i=n.findIndex(e=>"LINK"===e.tagName&&"stylesheet"===e.getAttribute("rel"));return i<0?null:null!=(t=n.slice(i+1).find(e=>"STYLE"===e.tagName))?t:null}static legacyCopies(e){return Array.from((void 0===e?globalThis.document:e).head.querySelectorAll("style")).filter(e=>{var t;return!e.hasAttribute("data-u2-styles")&&/(^|}|\*\/)\s*\.u2-input-root\s*\{/.test(null!=(t=e.textContent)?t:"")}).length}static installed(){var e,t,n,i;let r=null!=(e=null==(i=globalThis.document)||null==(n=i.head)?void 0:n.querySelector(M))?e:null;return null===r?null:{revision:Number(r.getAttribute("data-revision")),hash:null!=(t=r.getAttribute("data-hash"))?t:"",element:r}}}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}j.revision=65,j.hash=I,j.install();let F=P.version,z=function(e){if(Array.isArray(e))return e}(l=(null!=F?F:"").split(".").map(Number))||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(l)||function(e){if(e){if("string"==typeof e)return D(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return D(e,2)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),q=z[0],B=z[1],G=q>1||1===q&&B>=2?void 0:`u2 needs the u2 engine 1.2+; this platform has ${null!=F?F:"an older one"}: update the platform`,V=()=>{throw Error(G)},U=void 0===G?P.Component:class extends P.Component{constructor(e){V(),super(e)}},H=void 0===G?P.Control:class extends P.Control{static build(){return V()}constructor(e,t){V(),super(e,t)}},W=void 0===G?P.component:V;function Y(e){return"string"==typeof e?"string":"number"==typeof e?Number.isInteger(e)?"int":"double":"boolean"==typeof e?"bool":Array.isArray(e)&&e.every(e=>"string"==typeof e)?"string_list":"object"}class K{static scopeOf(e,t){let n=K._resolve(e);return void 0===n&&P.Usage.fail("owner-missing",`${t} needs an owner — pass one, or call it under \`owner.build(…)\` or \`component((self) => …)\`; after an \`await\`, inside \`owner.task(async (t) => … t.build(…))\``),n}static adopt(e,t){let n=K._resolve(e);return void 0===n?(P.Usage.report("owner-missing","built with no `owner` while nothing was building, so nothing will dispose it — pass `owner`, or build it under `owner.build(…)` or `component((self) => …)`; after an `await`, inside `owner.task(async (t) => … t.build(…))`; a new root on purpose, under `Scope.root('<what>')`"),()=>{}):(n.own(t),()=>n.disown(t))}static _resolve(e){return void 0===e?P.Scope.ambient:e instanceof P.Scope?e:e.scope}}let X={};class Z{static isDateOnly(e){let t=e instanceof Date?e.getTime():new Date(e).getTime();return Number.isFinite(t)&&t%(Z.MICROSECONDS_PER_DAY/1e3)==0}static isDateOnlyMicros(e){return!Number.isFinite(e)||!Number.isInteger(e)||e%Z.MICROSECONDS_PER_DAY==0}static utcParts(e){return{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hours:e.getUTCHours(),minutes:e.getUTCMinutes()}}static fromUtcParts(e){var t,n;return new Date(Date.UTC(e.year,e.month-1,e.day,null!=(t=e.hours)?t:0,null!=(n=e.minutes)?n:0))}static firstDayOfWeek(e){var t,n;let i=void 0===e?null!=(t=null==(n=globalThis.navigator)?void 0:n.language)?t:"en-US":e,r=Z._firstDays.get(i);return void 0===r&&Z._firstDays.set(i,r=Z._weekStart(i)),r}static _weekStart(e){try{var t,n,i;let r=new Intl.Locale(e),o=null!=(t=null==(i=r.getWeekInfo)?void 0:i.call(r))?t:r.weekInfo;if(void 0!==o)return o.firstDay%7;return+!Z._SUNDAY_REGIONS.includes(null!=(n=r.maximize().region)?n:"")}catch(e){return 1}}}Z.MICROSECONDS_PER_DAY=864e8,Z._SUNDAY_REGIONS=["US","CA","MX","BR","JP","KR","TW","HK","IL","IN","PH","ZA"],Z._firstDays=new Map;let Q=["January","February","March","April","May","June","July","August","September","October","November","December"],J=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ee=(e,t)=>String(e).padStart(void 0===t?2:t,"0"),et=e=>e.hours%12||12,en={d:e=>String(e.day),dd:e=>ee(e.day),ddd:e=>J[e.weekday].slice(0,3),dddd:e=>J[e.weekday],h:e=>String(et(e)),hh:e=>ee(et(e)),H:e=>String(e.hours),HH:e=>ee(e.hours),m:e=>String(e.minutes),mm:e=>ee(e.minutes),M:e=>String(e.month),MM:e=>ee(e.month),MMM:e=>Q[e.month-1].slice(0,3),MMMM:e=>Q[e.month-1],s:e=>String(e.seconds),ss:e=>ee(e.seconds),f:e=>String(Math.floor(e.ms/100)),ff:e=>ee(Math.floor(e.ms/10)),fff:e=>ee(e.ms,3),tt:e=>e.hours>=12?"PM":"AM",yy:e=>ee(e.year%100),yyyy:e=>String(e.year)};class ei{static value(e,t){var n,i;let r=void 0===t?{}:t;if(null==e||"number"==typeof e&&isNaN(e))return"";if("string"==typeof e)return e;if("number"==typeof e)return r.format&&null!=(n=null==(i=X.format)?void 0:i.number(e,r.format))?n:String(e);if(e instanceof Date)return ei.date(e,r);if(Array.isArray(e))return e.map(e=>ei.value(e,r)).filter(e=>""!==e).join(", ");if("object"==typeof e){if("function"==typeof e.toDate)return ei.date(e.toDate(),r);let t=Object.getPrototypeOf(e);if(t===Object.prototype||null===t)return""}return String(e)}static date(e,t){let n=void 0===t?{}:t;if(isNaN(e.getTime()))return"";let i=ei._parts(e,!0===n.utcDates&&Z.isDateOnly(e));return(n.format||ei._pattern(i)).replace(/(.)\1*/g,e=>{var t,n;return null!=(t=null==(n=en[e])?void 0:n.call(en,i))?t:e})}static count(e){return e.toLocaleString()}static spelled(e,t){let n=void 0===t?{}:t;return e.toLocaleString(void 0,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({month:"short",day:"numeric",year:"numeric"},n.time?{hour:"2-digit",minute:"2-digit"}:{},n.utc?{timeZone:"UTC"}:{}))}static _pattern(e){var t;let n=(null==(t=X.format)?void 0:t.dateFormat())||ei.DATE;return 0!==e.ms?`${n} HH:mm:ss.fff`:0!==e.seconds?`${n} HH:mm:ss`:0!==e.hours||0!==e.minutes?`${n} HH:mm`:n}static _parts(e,t){return t?{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),weekday:e.getUTCDay(),hours:e.getUTCHours(),minutes:e.getUTCMinutes(),seconds:e.getUTCSeconds(),ms:e.getUTCMilliseconds()}:{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),weekday:e.getDay(),hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds(),ms:e.getMilliseconds()}}}function er(e){return null==e?"":String(e)}ei.DATE="M/d/yyyy";let eo="Value can't be empty";function es(e){return null==e||""===e}let ea=new Set(["and","or","than","if","but","so","as","that"]);function el(e){var t;return e===e.toUpperCase()||e.includes(" ")?e:(null!=(t=e.match(/[A-Z]+(?![a-z])|[A-Z]?[^A-Z]+/g))?t:[e]).map((e,t)=>{let n=ea.has(e.toLowerCase())?e.toLowerCase():e;return 0===t?n.charAt(0).toUpperCase()+n.slice(1):n}).join(" ")}function eu(e,t){var n,r,o;return(null!=i||(i=null!=(n=null==(r=(o=document.createElement("canvas")).getContext)?void 0:r.call(o,"2d"))?n:null),null===i)?0:(i.font=t,i.measureText(e).width)}function ed(e,t,n){var i;let r=K.scopeOf(null==n?void 0:n.owner,"bindValue()"),o=null!=(i=null==n?void 0:n.commitOn)?i:"input",s=!1;r.effect(()=>{var n;let i=null!=(n=t.value)?n:"";s?s=!1:e.value=i}),r.listen(e,o,()=>{let n=t.peek();t.value=e.value,s=!Object.is(t.peek(),n)})}function ec(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}class eh{query(e){this._query=e,this._cancel(),this._disposed||(this._state.value={kind:"loading"},this._timer=setTimeout(()=>this._run(),this._debounceMs))}retry(){this.query(this._query)}dispose(){var e;this._disposed=!0,this._cancel(),null==(e=this._release)||e.call(this)}_cancel(){clearTimeout(this._timer),this._timer=void 0,this._abort&&this._abort.abort(),this._abort=void 0}_run(){var e;return(e=function*(){let e=new AbortController;this._abort=e;try{let t=yield this._fetch(this._query,e.signal);if(e.signal.aborted||this._disposed)return;this._state.value=t.length>0?{kind:"ready",items:t}:{kind:"empty"}}catch(t){if(e.signal.aborted||this._disposed)return;this._state.value={kind:"error",message:t instanceof Error?t.message:String(t)}}},function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){ec(o,i,r,s,a,"next",e)}function a(e){ec(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}constructor(e,t){var n;this._query="",this._disposed=!1,this._fetch=e,this._debounceMs=null!=(n=null==t?void 0:t.debounceMs)?n:150,this._state=(0,P.signal)({kind:"idle"}),this.state=this._state,this._release=K.adopt(null==t?void 0:t.owner,()=>this.dispose())}}function ep(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function ef(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){ep(o,i,r,s,a,"next",e)}function a(e){ep(o,i,r,s,a,"throw",e)}s(void 0)})}}class em{loadMore(){let e=this._state.peek();this._disposed||"loading"===e||"done"===e||((0,P.batch)(()=>{this._state.value="loading",this._error.value=null}),this._load(this._abortSignal()))}reset(){this._cancel(),this._disposed||(this._page=0,(0,P.batch)(()=>{this._items.value=[],this._total.value=null,this._state.value="idle",this._error.value=null}),this._count&&this._recount(this._abortSignal()),this.loadMore())}dispose(){var e;this._disposed=!0,this._cancel(),null==(e=this._release)||e.call(this)}_abortSignal(){return this._abort||(this._abort=new AbortController),this._abort.signal}_cancel(){this._abort&&this._abort.abort(),this._abort=void 0}_load(e){return ef(function*(){try{let t=yield this._fetchPage(this._page,e);if(e.aborted||this._disposed)return;this._page++,(0,P.batch)(()=>{this._items.value=this._items.peek().concat(t);let e=t.length<this._pageSize;this._state.value=e?"done":"idle",e&&null===this._total.peek()&&(this._total.value=this._items.peek().length)})}catch(t){if(e.aborted||this._disposed)return;(0,P.batch)(()=>{this._error.value=t instanceof Error?t.message:String(t),this._state.value="error"})}}).call(this)}_recount(e){return ef(function*(){try{let t=yield this._count(e);e.aborted||this._disposed||(this._total.value=t)}catch(e){}}).call(this)}constructor(e){var t;this._error=(0,P.signal)(null),this._page=0,this._disposed=!1,this._fetchPage=e.fetchPage,this._count=e.count,this._pageSize=null!=(t=e.pageSize)?t:20,this._items=(0,P.signal)([]),this._state=(0,P.signal)("idle"),this._total=(0,P.signal)(null),this.items=this._items,this.state=this._state,this.total=this._total,this.error=this._error,this._release=K.adopt(e.owner,()=>this.dispose())}}let eg=Math.min,ev=Math.max,eb=Math.round,ey=Math.floor,e_=e=>({x:e,y:e}),ew={left:"right",right:"left",bottom:"top",top:"bottom"};function ex(e,t){return"function"==typeof e?e(t):e}function ek(e){return e.split("-")[0]}function eS(e){return e.split("-")[1]}function eC(e){return"x"===e?"y":"x"}function eA(e){return"y"===e?"height":"width"}function eO(e){let t=e[0];return"t"===t||"b"===t?"y":"x"}function eE(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}let eT=["left","right"],eP=["right","left"],eN=["top","bottom"],eI=["bottom","top"];function eM(e){let t=ek(e);return ew[t]+e.slice(t.length)}function eL(e){let{x:t,y:n,width:i,height:r}=e;return{width:i,height:r,top:n,left:t,right:t+i,bottom:n+r,x:t,y:n}}function eR(e,t,n){let i,{reference:r,floating:o}=e,s=eO(t),a=eC(eO(t)),l=eA(a),u=ek(t),d=r.x+r.width/2-o.width/2,c=r.y+r.height/2-o.height/2,h=r[l]/2-o[l]/2;switch(u){case"top":i={x:d,y:r.y-o.height};break;case"bottom":i={x:d,y:r.y+r.height};break;case"right":i={x:r.x+r.width,y:c};break;case"left":i={x:r.x-o.width,y:c};break;default:i={x:r.x,y:r.y}}let p=eS(t);return p&&(i[a]+=h*("end"===p?1:-1)*(n&&"y"===s?-1:1)),i}async function ej(e,t){var n,i,r,o,s;void 0===t&&(t={});let{x:a,y:l,platform:u,rects:d,elements:c,strategy:h}=e,{boundary:p="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:v=0}=ex(t,e),b="number"!=typeof v?{top:null!=(i=v.top)?i:0,right:null!=(r=v.right)?r:0,bottom:null!=(o=v.bottom)?o:0,left:null!=(s=v.left)?s:0}:{top:v,right:v,bottom:v,left:v},y=c[g?"floating"===m?"reference":"floating":m],_=eL(await u.getClippingRect({element:null==(n=await (null==u.isElement?void 0:u.isElement(y)))||n?y:y.contextElement||await (null==u.getDocumentElement?void 0:u.getDocumentElement(c.floating)),boundary:p,rootBoundary:f,strategy:h})),w="floating"===m?{x:a,y:l,width:d.floating.width,height:d.floating.height}:d.reference,x=await (null==u.getOffsetParent?void 0:u.getOffsetParent(c.floating)),k=await (null==u.isElement?void 0:u.isElement(x))&&await (null==u.getScale?void 0:u.getScale(x))||{x:1,y:1},S=eL(u.convertOffsetParentRelativeRectToViewportRelativeRect?await u.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:x,strategy:h}):w);return{top:(_.top-S.top+b.top)/k.y,bottom:(S.bottom-_.bottom+b.bottom)/k.y,left:(_.left-S.left+b.left)/k.x,right:(S.right-_.right+b.right)/k.x}}let eD=async(e,t,n)=>{let{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:s}=n,a=s.detectOverflow?s:{...s,detectOverflow:ej},l=await (null==s.isRTL?void 0:s.isRTL(t)),u=await s.getElementRects({reference:e,floating:t,strategy:r}),{x:d,y:c}=eR(u,i,l),h=i,p=0,f={};for(let n=0;n<o.length;n++){let m=o[n];if(!m)continue;let{name:g,fn:v}=m,{x:b,y:y,data:_,reset:w}=await v({x:d,y:c,initialPlacement:i,placement:h,strategy:r,middlewareData:f,rects:u,platform:a,elements:{reference:e,floating:t}});d=null!=b?b:d,c=null!=y?y:c,f[g]={...f[g],..._},w&&p<50&&(p++,"object"==typeof w&&(w.placement&&(h=w.placement),w.rects&&(u=!0===w.rects?await s.getElementRects({reference:e,floating:t,strategy:r}):w.rects),{x:d,y:c}=eR(u,h,l)),n=-1)}return{x:d,y:c,placement:h,strategy:r,middlewareData:f}},e$=new Set(["left","top"]);async function eF(e,t){let{placement:n,platform:i,elements:r}=e,o=await (null==i.isRTL?void 0:i.isRTL(r.floating)),s=ek(n),a=eS(n),l="y"===eO(n),u=e$.has(s)?-1:1,d=o&&l?-1:1,c=ex(t,e),{mainAxis:h,crossAxis:p,alignmentAxis:f}="number"==typeof c?{mainAxis:c,crossAxis:0,alignmentAxis:null}:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return a&&"number"==typeof f&&(p="end"===a?-1*f:f),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}function ez(){return"u">typeof window}function eq(e){return eV(e)?(e.nodeName||"").toLowerCase():"#document"}function eB(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function eG(e){var t;return null==(t=(eV(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function eV(e){return!!ez()&&(e instanceof Node||e instanceof eB(e).Node)}function eU(e){return!!ez()&&(e instanceof Element||e instanceof eB(e).Element)}function eH(e){return!!ez()&&(e instanceof HTMLElement||e instanceof eB(e).HTMLElement)}function eW(e){return!(!ez()||"u"<typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof eB(e).ShadowRoot)}function eY(e){let{overflow:t,overflowX:n,overflowY:i,display:r}=e1(e);return/auto|scroll|overlay|hidden|clip/.test(t+i+n)&&"inline"!==r&&"contents"!==r}function eK(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}let eX=/transform|translate|scale|rotate|perspective|filter/,eZ=/paint|layout|strict|content/,eQ=e=>!!e&&"none"!==e;function eJ(e){let t=eU(e)?e1(e):e;return eQ(t.transform)||eQ(t.translate)||eQ(t.scale)||eQ(t.rotate)||eQ(t.perspective)||!e0()&&(eQ(t.backdropFilter)||eQ(t.filter))||eX.test(t.willChange||"")||eZ.test(t.contain||"")}function e0(){return null==r&&(r="u">typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),r}function e2(e){return/^(html|body|#document)$/.test(eq(e))}function e1(e){return eB(e).getComputedStyle(e)}function e3(e){return eU(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function e5(e){if("html"===eq(e))return e;let t=e.assignedSlot||e.parentNode||eW(e)&&e.host||eG(e);return eW(t)?t.host:t}function e4(e,t,n){var i;void 0===t&&(t=[]),void 0===n&&(n=!0);let r=function e(t){let n=e5(t);return e2(n)?(t.ownerDocument||t).body:eH(n)&&eY(n)?n:e(n)}(e),o=r===(null==(i=e.ownerDocument)?void 0:i.body),s=eB(r);if(!o)return t.concat(r,e4(r,[],n));{let e=e6(s);return t.concat(s,s.visualViewport||[],eY(r)?r:[],e&&n?e4(e):[])}}function e6(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function e8(e){let t=e1(e),n=parseFloat(t.width)||0,i=parseFloat(t.height)||0,r=eH(e),o=r?e.offsetWidth:n,s=r?e.offsetHeight:i,a=eb(n)!==o||eb(i)!==s;return a&&(n=o,i=s),{width:n,height:i,$:a}}function e9(e){return eU(e)?e:e.contextElement}function e7(e){let t=e9(e);if(!eH(t))return e_(1);let n=t.getBoundingClientRect(),{width:i,height:r,$:o}=e8(t),s=(o?eb(n.width):n.width)/i,a=(o?eb(n.height):n.height)/r;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}let te=e_(0);function tt(e){let t=eB(e);return e0()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:te}function tn(e,t,n,i){var r;void 0===t&&(t=!1),void 0===n&&(n=!1);let o=e.getBoundingClientRect(),s=e9(e),a=e_(1);t&&(i?eU(i)&&(a=e7(i)):a=e7(e));let l=(void 0===(r=n)&&(r=!1),i&&r&&i===eB(s))?tt(s):e_(0),u=(o.left+l.x)/a.x,d=(o.top+l.y)/a.y,c=o.width/a.x,h=o.height/a.y;if(s&&i){let e=eB(s),t=eU(i)?eB(i):i,n=e,r=e6(n);for(;r&&t!==n;){let e=e7(r),t=r.getBoundingClientRect(),i=e1(r),o=t.left+(r.clientLeft+parseFloat(i.paddingLeft))*e.x,s=t.top+(r.clientTop+parseFloat(i.paddingTop))*e.y;u*=e.x,d*=e.y,c*=e.x,h*=e.y,u+=o,d+=s,r=e6(n=eB(r))}}return eL({width:c,height:h,x:u,y:d})}function ti(e,t){let n=e3(e).scrollLeft;return t?t.left+n:tn(eG(e)).left+n}function tr(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-ti(e,n),y:n.top+t.scrollTop}}function to(e,t,n){var i;let r;if("viewport"===t||"layoutViewport"===t)r=function(e,t,n){void 0===n&&(n="viewport");let i="layoutViewport"===n,r=eB(e),o=eG(e),s=r.visualViewport,a=o.clientWidth,l=o.clientHeight,u=0,d=0;if(s){let e=!e0()||"fixed"===t;i?e||(u=-s.offsetLeft,d=-s.offsetTop):(a=s.width,l=s.height,e&&(u=s.offsetLeft,d=s.offsetTop))}if(0>=ti(o)){let e=o.ownerDocument,t=e.body,n=getComputedStyle(t),i="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,r=Math.abs(o.clientWidth-t.clientWidth-i),s="stable both-edges"===getComputedStyle(o).scrollbarGutter?r/2:r;s<=25&&(a-=s)}return{width:a,height:l,x:u,y:d}}(e,n,t);else if("document"===t){let t,n,o,s,a,l;t=e3(i=eG(e)),n=i.ownerDocument.body,o=ev(i.scrollWidth,i.clientWidth,n.scrollWidth,n.clientWidth),s=ev(i.scrollHeight,i.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+ti(i),l=-t.scrollTop,"rtl"===e1(n).direction&&(a+=ev(i.clientWidth,n.clientWidth)-o),r={width:o,height:s,x:a,y:l}}else if(eU(t)){let e,i,o,s,a,l;i=(e=tn(t,!0,"fixed"===n)).top+t.clientTop,o=e.left+t.clientLeft,s=e7(t),a=t.clientWidth*s.x,l=t.clientHeight*s.y,r={width:a,height:l,x:o*s.x,y:i*s.y}}else{let n=tt(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return eL(r)}function ts(e){return"static"===e1(e).position}function ta(e,t){if(!eH(e)||"fixed"===e1(e).position)return null;if(t)return t(e);let n=e.offsetParent;return eG(e)===n&&(n=n.ownerDocument.body),n}function tl(e,t){var n;let i=eB(e);if(eK(e))return i;if(!eH(e)){let t=e5(e);for(;t&&!e2(t);){if(eU(t)&&!ts(t))return t;t=e5(t)}return i}let r=ta(e,t);for(;r&&(n=r,/^(table|td|th)$/.test(eq(n)))&&ts(r);)r=ta(r,t);return r&&e2(r)&&ts(r)&&!eJ(r)?i:r||function(e){let t=e5(e);for(;eH(t)&&!e2(t);){if(eJ(t))return t;if(eK(t))break;t=e5(t)}return null}(e)||i}let tu=async function(e){let t=this.getOffsetParent||tl,n=this.getDimensions,i=await n(e.floating);return{reference:function(e,t,n){let i=eH(t),r=eG(t),o="fixed"===n,s=tn(e,!0,o,t),a={scrollLeft:0,scrollTop:0},l=e_(0);if((i||!o)&&(("body"!==eq(t)||eY(r))&&(a=e3(t)),i)){let e=tn(t,!0,o,t);l.x=e.x+t.clientLeft,l.y=e.y+t.clientTop}!i&&r&&(l.x=ti(r));let u=!r||i||o?e_(0):tr(r,a);return{x:s.left+a.scrollLeft-l.x-u.x,y:s.top+a.scrollTop-l.y-u.y,width:s.width,height:s.height}}(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}},td={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:i,strategy:r}=e,o="fixed"===r,s=eG(i),a=!!t&&eK(t.floating);if(i===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},u=e_(1),d=e_(0),c=eH(i);if((c||!o)&&(("body"!==eq(i)||eY(s))&&(l=e3(i)),c)){let e=tn(i);u=e7(i),d.x=e.x+i.clientLeft,d.y=e.y+i.clientTop}let h=!s||c||o?e_(0):tr(s,l);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}},getDocumentElement:eG,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:i,strategy:r}=e,o=[..."clippingAncestors"===n?eK(t)?[]:function(e,t){let n=t.get(e);if(n)return n;let i=e4(e,[],!1).filter(e=>eU(e)&&"body"!==eq(e)),r=null,o="fixed"===e1(e).position,s=o?e5(e):e;for(;eU(s)&&!e2(s);){let e=e1(s),t=eJ(s),n=r?r.position:o?"fixed":"";t||"fixed"!==n&&("absolute"!==n||"static"!==e.position)?r=e:i=i.filter(e=>e!==s),s=e5(s)}return t.set(e,i),i}(t,this._c):[].concat(n),i],s=to(t,o[0],r),a=s.top,l=s.right,u=s.bottom,d=s.left;for(let e=1;e<o.length;e++){let n=to(t,o[e],r);a=ev(n.top,a),l=eg(n.right,l),u=eg(n.bottom,u),d=ev(n.left,d)}return{width:l-d,height:u-a,x:d,y:a}},getOffsetParent:tl,getElementRects:tu,getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){let{width:t,height:n}=e8(e);return{width:t,height:n}},getScale:e7,isElement:eU,isRTL:function(e){return"rtl"===e1(e).direction}};function tc(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function th(e,t,n,i){let r;void 0===i&&(i={});let{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:u=!1}=i,d=e9(e),c=o||s?[...d?e4(d):[],...t?e4(t):[]]:[];c.forEach(e=>{o&&e.addEventListener("scroll",n),s&&e.addEventListener("resize",n)});let h=d&&l?function(e,t,n){let i,r=null,o=eG(e);function s(){var e;clearTimeout(i),null==(e=r)||e.disconnect(),r=null}function a(n,l){void 0===n&&(n=!1),void 0===l&&(l=1),s();let u=e.getBoundingClientRect(),{left:d,top:c,width:h,height:p}=u;if(n||t(),!h||!p)return;let f={rootMargin:-ey(c)+"px "+-ey(o.clientWidth-(d+h))+"px "+-ey(o.clientHeight-(c+p))+"px "+-ey(d)+"px",threshold:ev(0,eg(1,l))||1},m=!0;function g(t){let n=t[0].intersectionRatio;if(!tc(u,e.getBoundingClientRect()))return a();if(n!==l){if(!m)return a();n?a(!1,n):i=setTimeout(()=>{a(!1,1e-7)},1e3)}m=!1}try{r=new IntersectionObserver(g,{...f,root:o.ownerDocument})}catch(e){r=new IntersectionObserver(g,f)}r.observe(e)}let l=eB(e),u=()=>a(n);return l.addEventListener("resize",u),a(!0),()=>{l.removeEventListener("resize",u),s()}}(d,n,s):null,p=-1,f=null;a&&(f=new ResizeObserver(e=>{let[i]=e;i&&i.target===d&&f&&t&&(f.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=f)||e.observe(t)})),n()}),d&&!u&&f.observe(d),t&&f.observe(t));let m=u?tn(e):null;return u&&function t(){let i=tn(e);m&&!tc(m,i)&&n(),m=i,r=requestAnimationFrame(t)}(),n(),()=>{var e;c.forEach(e=>{o&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==h||h(),null==(e=f)||e.disconnect(),f=null,u&&cancelAnimationFrame(r)}}let tp=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,i;let{x:r,y:o,placement:s,middlewareData:a}=t,l=await eF(t,e);return s===(null==(n=a.offset)?void 0:n.placement)&&null!=(i=a.arrow)&&i.alignmentOffset?{}:{x:r+l.x,y:o+l.y,data:{...l,placement:s}}}}},tf=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:i,placement:r,platform:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:l={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...u}=ex(e,t),d={x:n,y:i},c=await o.detectOverflow(t,u),h=eO(r),p=eC(h),f=d[p],m=d[h],g=(e,t)=>ev(t+c["y"===e?"top":"left"],eg(t,t-c["y"===e?"bottom":"right"]));s&&(f=g(p,f)),a&&(m=g(h,m));let v=l.fn({...t,[p]:f,[h]:m});return{...v,data:{x:v.x-n,y:v.y-i,enabled:{[p]:s,[h]:a}}}}}},tm=function(e){return void 0===e&&(e={}),{name:"flip",options:e,async fn(t){var n,i,r,o,s,a,l,u;let d,c,h,{placement:p,middlewareData:f,rects:m,initialPlacement:g,platform:v,elements:b}=t,{mainAxis:y=!0,crossAxis:_=!0,fallbackPlacements:w,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:k="none",flipAlignment:S=!0,...C}=ex(e,t);if(null!=(n=f.arrow)&&n.alignmentOffset)return{};let A=ek(p),O=eO(g),E=ek(g)===g,T=await (null==v.isRTL?void 0:v.isRTL(b.floating)),P=w||(E||!S?[eM(g)]:(d=eM(g),[eE(g),d,eE(d)])),N="none"!==k;!w&&N&&P.push(...(c=eS(g),h=function(e,t,n){switch(e){case"top":case"bottom":if(n)return t?eP:eT;return t?eT:eP;case"left":case"right":return t?eN:eI;default:return[]}}(ek(g),"start"===k,T),c&&(h=h.map(e=>e+"-"+c),S&&(h=h.concat(h.map(eE)))),h));let I=[g,...P],M=await v.detectOverflow(t,C),L=[],R=(null==(i=f.flip)?void 0:i.overflows)||[];if(y&&L.push(M[A]),_){let e,t,n,i,r=(a=p,l=m,void 0===(u=T)&&(u=!1),e=eS(a),n=eA(t=eC(eO(a))),i="x"===t?e===(u?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[n]>l.floating[n]&&(i=eM(i)),[i,eM(i)]);L.push(M[r[0]],M[r[1]])}if(R=[...R,{placement:p,overflows:L}],!L.every(e=>e<=0)){let e=((null==(r=f.flip)?void 0:r.index)||0)+1,t=I[e];if(t&&("alignment"!==_||O===eO(t)||R.every(e=>eO(e.placement)!==O||e.overflows[0]>0)))return{data:{index:e,overflows:R},reset:{placement:t}};let n=null==(o=R.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:o.placement;if(!n)switch(x){case"bestFit":{let e=null==(s=R.filter(e=>{if(N){let t=eO(e.placement);return t===O||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:s[0];e&&(n=e);break}case"initialPlacement":n=g}if(p!==n)return{reset:{placement:n}}}return{}}}},tg=(e,t,n)=>{let i=new Map,r=null!=n?n:{},o={...td,...r.platform,_c:i};return eD(e,t,{...r,platform:o})};function tv(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}let tb="u2-overlay-close",ty='input, textarea, select, button, [role="combobox"], [tabindex]:not([tabindex="-1"])',t_=["listbox","menu","tree","grid","dialog"],tw=null!=(d=(c=globalThis)[h=Symbol.for("u2.ids")])?d:c[h]={next:0};class tx{static nextLayer(){return++tx._layer}static nextDialogZ(){let e=2999;var t=!0,n=!1,i=void 0;try{for(var r,o=document.querySelectorAll(".d4-dialog, .d4-dialog-center-wrapper, .u2-dialog, .u2-dialog-backdrop")[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value,n=parseInt(t.style.zIndex,10);n>e&&(e=n)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return e+1}static get host(){if(!tx._host||!tx._host.isConnected){let e=document.createElement("div");e.className="u2-overlay",e.style.cssText="position: fixed; left: 0; top: 0; width: 0; height: 0; z-index: var(--dg-z-overlay);",document.body.append(e),new MutationObserver(()=>{e.isConnected&&0===e.childNodes.length&&e.remove()}).observe(e,{childList:!0}),tx._host=e}return tx._host}static show(e,t,n){var i;let r=void 0===n?{}:n,o=K.scopeOf(r.owner,"Overlay.show()");if(!e.isConnected)return()=>{};let s=e.closest("[data-u2-name]");(null==s?void 0:s.dataset.u2Name)!==void 0?t.dataset.u2Owner=s.dataset.u2Name:delete t.dataset.u2Owner;let a=H.forElement(e);void 0!==a?t.dataset.u2OwnerId=a.rootId:delete t.dataset.u2OwnerId,t.id||(t.id=`u2-${++tw.next}-popup`),t.dataset.u2Part="popup";let l=tx._focusTarget(e),u=l.getAttribute("aria-controls");l.setAttribute("aria-controls",t.id),l.setAttribute("aria-expanded","true"),l.hasAttribute("aria-haspopup")||l.setAttribute("aria-haspopup",null!=(i=t_.find(e=>t.getAttribute("role")===e))?i:"true"),t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.zIndex=String(tx.nextLayer()),tx.host.append(t);let d=!1,c=()=>{},h=()=>{d||(d=!0,c(),tx._remove(p),l.setAttribute("aria-expanded","false"),null===u?l.removeAttribute("aria-controls"):l.setAttribute("aria-controls",u),t.remove(),o.disown(h),t.dispatchEvent(new CustomEvent(tb)))},p={content:t,close:h,anchor:e,focus:l};return tx._push(p),c=th(e,t,()=>{var n;e.isConnected?tg(e,t,{strategy:"fixed",placement:"bottom-start",middleware:[tp(1),tm({padding:4}),{name:"size",options:n={padding:4,apply:e=>{let t=e.rects,n=e.availableHeight,i=e.elements;!1!==r.matchWidth&&(i.floating.style.minWidth=`${t.reference.width}px`);let o=`${Math.max(n,64)}px`,s=r.maxHeight;i.floating.style.maxHeight=void 0===s?o:`min(${o}, ${"number"==typeof s?`${s}px`:s})`}},async fn(e){let t,i,{placement:r,rects:o,platform:s,elements:a}=e,{apply:l=()=>{},...u}=ex(n,e),d=await s.detectOverflow(e,u),c=ek(r),h=eS(r),p="y"===eO(r),{width:f,height:m}=o.floating;"top"===c||"bottom"===c?(t=c,i=h===(await (null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(i=c,t="end"===h?"top":"bottom");let g=m-d.top-d.bottom,v=f-d.left-d.right,b=eg(m-d[t],g),y=eg(f-d[i],v),_=e.middlewareData.shift,w=!_,x=b,k=y;null!=_&&_.enabled.x&&(k=v),null!=_&&_.enabled.y&&(x=g),w&&!h&&(p?k=f-2*ev(d.left,d.right):x=m-2*ev(d.top,d.bottom)),await l({...e,availableWidth:k,availableHeight:x});let S=await s.getDimensions(a.floating);return f!==S.width||m!==S.height?{reset:{rects:!0}}:{}}}]}).then(e=>{let n=e.x,i=e.y;t.style.left=`${n}px`,t.style.top=`${i}px`}):h()}),o.own(h),h}static pushDialog(e){let t={content:e.root,close:()=>e.close(),dialog:e};return tx._push(t),()=>tx._remove(t)}static raiseDialog(e){var t;let n=tx._stack,i=n.findIndex(t=>t.dialog===e);if(i<0)return;let r=(function(e){if(Array.isArray(e))return e}(t=n.splice(i,1))||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),1!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(t)||function(e){if(e){if("string"==typeof e)return tv(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return tv(e,1)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],o=n.length-1;for(;o>=0&&void 0===n[o].dialog;)o--;n.splice(o+1,0,r)}static platformDialogAbove(e){let t=parseInt(e.style.zIndex,10)||0;return[...document.querySelectorAll(".d4-dialog")].some(e=>(parseInt(e.style.zIndex,10)||0)>t)}static _push(e){if(tx._stack.push(e),void 0!==tx._listeners)return;let t=tx._listeners=new P.Scope(void 0,{label:"overlay"});P.debug.markSingleton(t),t.listen(document,"keydown",e=>P.Scope.runWith(void 0,()=>tx._onKeyDown(e)),{capture:!0}),t.listen(document,"pointerdown",e=>P.Scope.runWith(void 0,()=>tx._onPointerDown(e)),{capture:!0}),t.listen(window,"resize",()=>P.Scope.runWith(void 0,()=>tx._closePopups()));let n=new MutationObserver(()=>tx._sweep());n.observe(document.body,{childList:!0,subtree:!0}),t.own(()=>n.disconnect())}static _remove(e){let t=tx._stack,n=t.indexOf(e);if(n<0)return;t.splice(n,1);let i=tx._listeners;0===t.length&&void 0!==i&&(tx._listeners=void 0,i.dispose())}static _onKeyDown(e){if("Escape"!==e.key||e.defaultPrevented)return;let t=tx._stack[tx._stack.length-1];if(void 0===t)return;let n=e.target instanceof Node?e.target:null,i=tx._focusLost(n);if(void 0===t.dialog){if(!(null!==n&&(t.content.contains(n)||t.anchor.contains(n)))&&!i&&n instanceof Element&&null!==n.closest(".d4-dialog"))return;e.preventDefault(),e.stopPropagation();let r=document.activeElement,o=null!==r&&t.content.contains(r);t.close(),o&&t.focus.isConnected&&t.focus.focus();return}i&&t.dialog.modal&&!tx.platformDialogAbove(t.dialog.root)&&(e.preventDefault(),e.stopPropagation(),t.dialog.cancelByKey())}static _onPointerDown(e){let t=e.target;var n=!0,i=!1,r=void 0;try{for(var o,s,a=[...tx._stack].reverse()[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){let e=s.value;if(e.content.contains(t)||(null==(o=e.anchor)?void 0:o.contains(t)))return;void 0===e.dialog&&e.close()}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}}static _closePopups(){var e=!0,t=!1,n=void 0;try{for(var i,r=[...tx._stack].reverse()[Symbol.iterator]();!(e=(i=r.next()).done);e=!0){let e=i.value;void 0===e.dialog&&e.close()}}catch(e){t=!0,n=e}finally{try{e||null==r.return||r.return()}finally{if(t)throw n}}}static _sweep(){for(let e=0,t=[...tx._stack];e<t.length;e++){let n=t[e];n.content.isConnected&&(void 0===n.anchor||n.anchor.isConnected)||n.close()}}static _focusLost(e){return null===e||e===document.body||e===document.documentElement||e===document}static _focusTarget(e){var t,n;return e.hasAttribute("aria-haspopup")||e.matches(ty)?e:null!=(t=null!=(n=e.querySelector("[aria-haspopup]"))?n:e.querySelector(ty))?t:e}}tx._layer=0,tx._stack=[];let tk=Symbol.for("u2.tooltip");class tS{static get root(){if(!tS._root||!tS._root.isConnected){let e=document.createElement("div");e.className="u2-tooltip",e.dataset.u2="tooltip",e.id="u2-tooltip",e.setAttribute("role","tooltip"),e.style.cssText="position: fixed; left: 0; top: 0; display: none; pointer-events: none;",tx.host.append(e),tS._root=e}return tS._root}static get isVisible(){return void 0!==tS._anchor}static titleIfCut(e){let t=tS._cutTitles.has(e);if(e.scrollWidth>e.clientWidth){var n;if(!t&&""!==e.title)return;e.title=(null!=(n=e.textContent)?n:"").trim(),tS._cutTitles.add(e)}else t&&(e.removeAttribute("title"),tS._cutTitles.delete(e))}static bind(e,t,n){let i=K.scopeOf(null==n?void 0:n.owner,"Tooltip.bind()"),r=()=>{let n=()=>tS.show("function"==typeof t?t():t,e);tS.isVisible||Date.now()-tS._hiddenAt<100||tS.delay<=0?n():(window.clearTimeout(tS._timer),tS._pending=e,tS._timer=window.setTimeout(n,tS.delay))},o=()=>tS.hide(),s=e=>{tS._keyboardFocus(e.target)&&r()};e.addEventListener("pointerenter",r),e.addEventListener("pointerleave",o),e.addEventListener("pointerdown",o),e.addEventListener("focusin",s),e.addEventListener("focusout",o),e[tk]=t,i.own(()=>{e[tk]===t&&delete e[tk],e.removeEventListener("pointerenter",r),e.removeEventListener("pointerleave",o),e.removeEventListener("pointerdown",o),e.removeEventListener("focusin",s),e.removeEventListener("focusout",o),(tS._anchor===e||tS._pending===e)&&tS.hide()})}static show(e,t){if(window.clearTimeout(tS._timer),tS._pending=void 0,!t.isConnected||""===e)return;let n=tS.root;n.textContent="","string"==typeof e?n.textContent=e:n.append(e),n.style.display="block",void 0!==tS._anchor&&tS._anchor!==t&&tS._describe(tS._anchor,!1),tS._anchor=t,tS._describe(t,!0),document.addEventListener("pointerdown",tS._onPointerDown,!0),document.addEventListener("keydown",tS._onKeyDown),document.addEventListener("scroll",tS._onScroll,!0),tg(t,n,{strategy:"fixed",placement:"bottom-start",middleware:[tp(12),tm({padding:4}),tf({padding:4})]}).then(e=>{let i=e.x,r=e.y;tS._anchor===t&&(n.style.left=`${i}px`,n.style.top=`${r}px`)})}static hide(){if(window.clearTimeout(tS._timer),tS._pending=void 0,!tS.isVisible)return;tS._describe(tS._anchor,!1),tS._anchor=void 0,tS._hiddenAt=Date.now(),document.removeEventListener("pointerdown",tS._onPointerDown,!0),document.removeEventListener("keydown",tS._onKeyDown),document.removeEventListener("scroll",tS._onScroll,!0);let e=tS.root;e.style.display="none",e.textContent=""}static _describe(e,t){var n;let i=(null!=(n=e.getAttribute("aria-describedby"))?n:"").split(/\s+/).filter(e=>""!==e&&"u2-tooltip"!==e);t&&i.push("u2-tooltip"),i.length>0?e.setAttribute("aria-describedby",i.join(" ")):e.removeAttribute("aria-describedby")}static _keyboardFocus(e){try{var t;return null!=(t=null==e?void 0:e.matches(":focus-visible"))&&t}catch(e){return!1}}}tS._timer=0,tS._hiddenAt=0,tS.delay=300,tS._cutTitles=new WeakSet,tS._onPointerDown=()=>tS.hide(),tS._onScroll=()=>tS.hide(),tS._onKeyDown=e=>{"Escape"===e.key&&tS.hide()};let tC=e=>(!0===e&&P.Usage.report("reason-boolean","`disabled: true` says nothing to the user — pass the reason instead (`disabled: 'Pick a source file first'`), `null` while it is on."),!0===e?"Unavailable":!1===e||void 0===e||""===e?null:e),tA={now:e=>tC(e instanceof P.Signal?e.peek():e),read:e=>tC(e instanceof P.Signal?e.value:e),follow(e,t,n){void 0!==e&&(e instanceof P.Signal?K.scopeOf(n,"a live `disabled` reason").effect(()=>t(tC(e.value))):t(tC(e)))},apply(e,t){t?(e.setAttribute("aria-disabled","true"),e.setAttribute("aria-description",t)):(e.removeAttribute("aria-disabled"),e.removeAttribute("aria-description"))},region(e,t){let n=tC(t);e.classList.toggle("u2-region-off",null!==n),null===n?(e.removeAttribute("inert"),e.removeAttribute("aria-description")):(e.setAttribute("inert",""),e.setAttribute("aria-description",n))},of:e=>"true"===e.getAttribute("aria-disabled")?tC(e.getAttribute("aria-description")):null,focusable:e=>(Object.defineProperty(e,"disabled",{configurable:!0,get:()=>"true"===e.getAttribute("aria-disabled")||e.hasAttribute("disabled"),set:t=>{t&&null===e.getAttribute("aria-description")&&P.Usage.report("reason-missing","`button.disabled = true` turns a u2 button off without saying why — `Reason.apply(button, '<why>')`, or build it with `{disabled: '<why>'}`."),t?e.setAttribute("aria-disabled","true"):e.removeAttribute("aria-disabled")}}),e.addEventListener("click",t=>{"true"===e.getAttribute("aria-disabled")&&(t.preventDefault(),t.stopImmediatePropagation())},!0),e)};function tO(e){return e instanceof P.Signal}function tE(){let e=P.Scope.ambient;return e||P.Usage.fail("owner-missing","a signal binding needs an owner — build under `owner.build(…)` or `component((self) => …)`; after an `await`, inside `owner.task(async (t) => … t.build(…))`"),e}function tT(e,...t){let n=document.createElement(e),i=t.filter(e=>e).join(" ");return i&&(n.className=i),n}function tP(e,t){if(tO(t)){var n;n={owner:tE()},K.scopeOf(null==n?void 0:n.owner,"bindText()").effect(()=>{e.textContent=er(t.value)})}else e.textContent=t;return e}function tN(e,t){var n=!0,i=!1,r=void 0;try{for(var o,s=(null!=t?t:[])[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let t=o.value;e.append(tO(t)?tP(tT("span"),t):H.is(t)?t.root:t)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return e}let tI=new P.Scope(void 0,{label:"unowned",lazy:!0});function tM(e,t,n){let i=P.Scope.ambient;i?i.listen(e,t,n):e.addEventListener(t,e=>{try{(0,P.batch)(()=>n(e))}catch(e){tI.reportError(e)}})}function tL(e){return"object"!=typeof e?[e]:[void 0===e.gap?void 0:`u2-gap-${e.gap}`,e.cls]}function tR(e,t){return tN(tT("div","u2-div",...tL(t)),e)}function tj(e,t){return tN(tT("div","u2-div","u2-div-v",...tL(t)),e)}function tD(e,t){return tN(tT("div","u2-div","u2-div-h",...tL(t)),e)}function t$(e,t){return tP(tT("span",t),e)}function tF(e){return tP(tT("h3"),e)}function tz(e,t){let n=tP(tT("a","u2-link"),e);return"string"==typeof t?(n.classList.add("u2-link-external"),n.href=t,n.target="_blank"):(n.tabIndex=0,tM(n,"click",e=>t(e)),tM(n,"keydown",e=>{"Enter"===e.key&&t(e)})),n}function tq(e){tE().effect(e)}function tB(e,t,n){let i=tA.focusable(tT("button","u2-btn",(null==n?void 0:n.primary)?"u2-btn-primary":void 0));i.type="button",i.dataset.u2="button",e instanceof HTMLElement?i.append(e):tP(i,e),tM(i,"click",e=>t(e));let r=null==n?void 0:n.disabled;if(tO(r)?tE().effect(()=>tA.apply(i,tA.read(r))):tA.apply(i,tA.now(r)),void 0!==r||(null==n?void 0:n.tooltip)!==void 0){let e=()=>{var e,t;let i;return null!=(e=tA.now(r))?e:null==(i=tO(t=null==n?void 0:n.tooltip)?t.peek():t)?"":String(i)},t=P.Scope.ambient;void 0===t?i.title=e():tS.bind(i,e,{owner:t})}return i}let tG=`
|
|
74
|
+
abacus acorn ad address-book address-card adjust air-conditioner air-freshener alarm-clock
|
|
75
|
+
alarm-exclamation alarm-plus alarm-snooze album album-collection alicorn alien alien-monster
|
|
76
|
+
align-center align-justify align-left align-right align-slash allergies ambulance
|
|
77
|
+
american-sign-language-interpreting amp-guitar analytics anchor angel angle-double-down
|
|
78
|
+
angle-double-left angle-double-right angle-double-up angle-down angle-left angle-right angle-up
|
|
79
|
+
angry ankh apple-alt apple-crate archive archway arrow-alt-circle-down arrow-alt-circle-left
|
|
80
|
+
arrow-alt-circle-right arrow-alt-circle-up arrow-alt-down arrow-alt-from-bottom
|
|
81
|
+
arrow-alt-from-left arrow-alt-from-right arrow-alt-from-top arrow-alt-left arrow-alt-right
|
|
82
|
+
arrow-alt-square-down arrow-alt-square-left arrow-alt-square-right arrow-alt-square-up
|
|
83
|
+
arrow-alt-to-bottom arrow-alt-to-left arrow-alt-to-right arrow-alt-to-top arrow-alt-up
|
|
84
|
+
arrow-circle-down arrow-circle-left arrow-circle-right arrow-circle-up arrow-down
|
|
85
|
+
arrow-from-bottom arrow-from-left arrow-from-right arrow-from-top arrow-left arrow-right
|
|
86
|
+
arrow-square-down arrow-square-left arrow-square-right arrow-square-up arrow-to-bottom
|
|
87
|
+
arrow-to-left arrow-to-right arrow-to-top arrow-up arrows arrows-alt arrows-alt-h arrows-alt-v
|
|
88
|
+
arrows-h arrows-v assistive-listening-systems asterisk at atlas atom atom-alt audio-description
|
|
89
|
+
award axe axe-battle baby baby-carriage backpack backspace backward bacon bacteria bacterium
|
|
90
|
+
badge badge-check badge-dollar badge-percent badge-sheriff badger-honey bags-shopping bahai
|
|
91
|
+
balance-scale balance-scale-left balance-scale-right ball-pile ballot ballot-check ban band-aid
|
|
92
|
+
banjo barcode barcode-alt barcode-read barcode-scan bars baseball baseball-ball basketball-ball
|
|
93
|
+
basketball-hoop bat bath battery-bolt battery-empty battery-full battery-half battery-quarter
|
|
94
|
+
battery-slash battery-three-quarters bed bed-alt bed-bunk bed-empty beer bell bell-exclamation
|
|
95
|
+
bell-on bell-plus bell-school bell-school-slash bell-slash bells betamax bezier-curve bible
|
|
96
|
+
bicycle biking biking-mountain binoculars biohazard birthday-cake blanket blender blender-phone
|
|
97
|
+
blind blinds blinds-open blinds-raised blog bold bolt bomb bone bone-break bong book book-alt
|
|
98
|
+
book-dead book-heart book-medical book-open book-reader book-spells book-user bookmark books
|
|
99
|
+
books-medical boombox boot booth-curtain border-all border-bottom border-center-h
|
|
100
|
+
border-center-v border-inner border-left border-none border-outer border-right border-style
|
|
101
|
+
border-style-alt border-top bow-arrow bowling-ball bowling-pins box box-alt box-ballot box-check
|
|
102
|
+
box-fragile box-full box-heart box-open box-tissue box-up box-usd boxes boxes-alt boxing-glove
|
|
103
|
+
brackets brackets-curly braille brain bread-loaf bread-slice briefcase briefcase-medical
|
|
104
|
+
bring-forward bring-front broadcast-tower broom browser brush bug building bullhorn bullseye
|
|
105
|
+
bullseye-arrow bullseye-pointer burger-soda burn burrito bus bus-alt bus-school business-time
|
|
106
|
+
cabinet-filing cactus calculator calculator-alt calendar calendar-alt calendar-check
|
|
107
|
+
calendar-day calendar-edit calendar-exclamation calendar-minus calendar-plus calendar-star
|
|
108
|
+
calendar-times calendar-week camcorder camera camera-alt camera-home camera-movie
|
|
109
|
+
camera-polaroid camera-retro campfire campground candle-holder candy-cane candy-corn cannabis
|
|
110
|
+
capsules car car-alt car-battery car-building car-bump car-bus car-crash car-garage car-mechanic
|
|
111
|
+
car-side car-tilt car-wash caravan caravan-alt caret-circle-down caret-circle-left
|
|
112
|
+
caret-circle-right caret-circle-up caret-down caret-left caret-right caret-square-down
|
|
113
|
+
caret-square-left caret-square-right caret-square-up caret-up carrot cars cart-arrow-down
|
|
114
|
+
cart-plus cash-register cassette-tape cat cat-space cauldron cctv certificate chair chair-office
|
|
115
|
+
chalkboard chalkboard-teacher charging-station chart-area chart-bar chart-line chart-line-down
|
|
116
|
+
chart-network chart-pie chart-pie-alt chart-scatter check check-circle check-double check-square
|
|
117
|
+
cheese cheese-swiss cheeseburger chess chess-bishop chess-bishop-alt chess-board chess-clock
|
|
118
|
+
chess-clock-alt chess-king chess-king-alt chess-knight chess-knight-alt chess-pawn
|
|
119
|
+
chess-pawn-alt chess-queen chess-queen-alt chess-rook chess-rook-alt chevron-circle-down
|
|
120
|
+
chevron-circle-left chevron-circle-right chevron-circle-up chevron-double-down
|
|
121
|
+
chevron-double-left chevron-double-right chevron-double-up chevron-down chevron-left
|
|
122
|
+
chevron-right chevron-square-down chevron-square-left chevron-square-right chevron-square-up
|
|
123
|
+
chevron-up child chimney church circle circle-notch city clarinet claw-marks clinic-medical
|
|
124
|
+
clipboard clipboard-check clipboard-list clipboard-list-check clipboard-prescription
|
|
125
|
+
clipboard-user clock clone closed-captioning cloud cloud-download cloud-download-alt
|
|
126
|
+
cloud-drizzle cloud-hail cloud-hail-mixed cloud-meatball cloud-moon cloud-moon-rain cloud-music
|
|
127
|
+
cloud-rain cloud-rainbow cloud-showers cloud-showers-heavy cloud-sleet cloud-snow cloud-sun
|
|
128
|
+
cloud-sun-rain cloud-upload cloud-upload-alt clouds clouds-moon clouds-sun club cocktail code
|
|
129
|
+
code-branch code-commit code-merge coffee coffee-pot coffee-togo coffin coffin-cross cog cogs
|
|
130
|
+
coin coins columns comet comment comment-alt comment-alt-check comment-alt-dollar
|
|
131
|
+
comment-alt-dots comment-alt-edit comment-alt-exclamation comment-alt-lines comment-alt-medical
|
|
132
|
+
comment-alt-minus comment-alt-music comment-alt-plus comment-alt-slash comment-alt-smile
|
|
133
|
+
comment-alt-times comment-check comment-dollar comment-dots comment-edit comment-exclamation
|
|
134
|
+
comment-lines comment-medical comment-minus comment-music comment-plus comment-slash
|
|
135
|
+
comment-smile comment-times comments comments-alt comments-alt-dollar comments-dollar
|
|
136
|
+
compact-disc compass compass-slash compress compress-alt compress-arrows-alt compress-wide
|
|
137
|
+
computer-classic computer-speaker concierge-bell construction container-storage conveyor-belt
|
|
138
|
+
conveyor-belt-alt cookie cookie-bite copy copyright corn couch cow cowbell cowbell-more
|
|
139
|
+
credit-card credit-card-blank credit-card-front cricket croissant crop crop-alt cross crosshairs
|
|
140
|
+
crow crown crutch crutches cube cubes curling cut dagger database deaf debug deer deer-rudolph
|
|
141
|
+
democrat desktop desktop-alt dewpoint dharmachakra diagnoses diamond dice dice-d10 dice-d12
|
|
142
|
+
dice-d20 dice-d4 dice-d6 dice-d8 dice-five dice-four dice-one dice-six dice-three dice-two
|
|
143
|
+
digging digital-tachograph diploma directions disc-drive disease divide dizzy dna do-not-enter
|
|
144
|
+
dog dog-leashed dollar-sign dolly dolly-empty dolly-flatbed dolly-flatbed-alt
|
|
145
|
+
dolly-flatbed-empty donate door-closed door-open dot-circle dove download drafting-compass
|
|
146
|
+
dragon draw-circle draw-polygon draw-square dreidel drone drone-alt drum drum-steelpan drumstick
|
|
147
|
+
drumstick-bite dryer dryer-alt duck dumbbell dumpster dumpster-fire dungeon ear ear-muffs
|
|
148
|
+
eclipse eclipse-alt edit egg egg-fried eject elephant ellipsis-h ellipsis-h-alt ellipsis-v
|
|
149
|
+
ellipsis-v-alt empty-set engine-warning envelope envelope-open envelope-open-dollar
|
|
150
|
+
envelope-open-text envelope-square equals eraser ethernet euro-sign exchange exchange-alt
|
|
151
|
+
exclamation exclamation-circle exclamation-square exclamation-triangle expand expand-alt
|
|
152
|
+
expand-arrows expand-arrows-alt expand-wide external-link external-link-alt external-link-square
|
|
153
|
+
external-link-square-alt eye eye-dropper eye-evil eye-slash fan fan-table farm fast-backward
|
|
154
|
+
fast-forward faucet faucet-drip fax feather feather-alt female field-hockey fighter-jet file
|
|
155
|
+
file-alt file-archive file-audio file-certificate file-chart-line file-chart-pie file-check
|
|
156
|
+
file-code file-contract file-csv file-download file-edit file-excel file-exclamation file-export
|
|
157
|
+
file-image file-import file-invoice file-invoice-dollar file-medical file-medical-alt file-minus
|
|
158
|
+
file-music file-pdf file-plus file-powerpoint file-prescription file-search file-signature
|
|
159
|
+
file-spreadsheet file-times file-upload file-user file-video file-word files-medical fill
|
|
160
|
+
fill-drip film film-alt film-canister filter fingerprint fire fire-alt fire-extinguisher
|
|
161
|
+
fire-smoke fireplace first-aid fish fish-cooked fist-raised flag flag-alt flag-checkered
|
|
162
|
+
flag-usa flame flashlight flask flask-poison flask-potion flower flower-daffodil flower-tulip
|
|
163
|
+
flushed flute flux-capacitor fog folder folder-download folder-minus folder-open folder-plus
|
|
164
|
+
folder-times folder-tree folder-upload folders font font-awesome-logo-full font-case
|
|
165
|
+
football-ball football-helmet forklift forward fragile french-fries frog frosty-head frown
|
|
166
|
+
frown-open function funnel-dollar futbol galaxy game-board game-board-alt game-console-handheld
|
|
167
|
+
gamepad gamepad-alt garage garage-car garage-open gas-pump gas-pump-slash gavel gem genderless
|
|
168
|
+
ghost gift gift-card gifts gingerbread-man glass glass-champagne glass-cheers glass-citrus
|
|
169
|
+
glass-martini glass-martini-alt glass-whiskey glass-whiskey-rocks glasses glasses-alt globe
|
|
170
|
+
globe-africa globe-americas globe-asia globe-europe globe-snow globe-stand golf-ball golf-club
|
|
171
|
+
gopuram graduation-cap gramophone greater-than greater-than-equal grimace grin grin-alt
|
|
172
|
+
grin-beam grin-beam-sweat grin-hearts grin-squint grin-squint-tears grin-stars grin-tears
|
|
173
|
+
grin-tongue grin-tongue-squint grin-tongue-wink grin-wink grip-horizontal grip-lines
|
|
174
|
+
grip-lines-vertical grip-vertical guitar guitar-electric guitars h-square h1 h2 h3 h4 hamburger
|
|
175
|
+
hammer hammer-war hamsa hand-heart hand-holding hand-holding-box hand-holding-heart
|
|
176
|
+
hand-holding-magic hand-holding-medical hand-holding-seedling hand-holding-usd
|
|
177
|
+
hand-holding-water hand-lizard hand-middle-finger hand-paper hand-peace hand-point-down
|
|
178
|
+
hand-point-left hand-point-right hand-point-up hand-pointer hand-receiving hand-rock
|
|
179
|
+
hand-scissors hand-sparkles hand-spock hands hands-heart hands-helping hands-usd hands-wash
|
|
180
|
+
handshake handshake-alt handshake-alt-slash handshake-slash hanukiah hard-hat hashtag hat-chef
|
|
181
|
+
hat-cowboy hat-cowboy-side hat-santa hat-winter hat-witch hat-wizard hdd head-side
|
|
182
|
+
head-side-brain head-side-cough head-side-cough-slash head-side-headphones head-side-mask
|
|
183
|
+
head-side-medical head-side-virus head-vr heading headphones headphones-alt headset heart
|
|
184
|
+
heart-broken heart-circle heart-rate heart-square heartbeat heat helicopter helmet-battle
|
|
185
|
+
hexagon highlighter hiking hippo history hockey-mask hockey-puck hockey-sticks holly-berry home
|
|
186
|
+
home-alt home-heart home-lg home-lg-alt hood-cloak horizontal-rule horse horse-head horse-saddle
|
|
187
|
+
hospital hospital-alt hospital-symbol hospital-user hospitals hot-tub hotdog hotel hourglass
|
|
188
|
+
hourglass-end hourglass-half hourglass-start house house-damage house-day house-flood
|
|
189
|
+
house-leave house-night house-return house-signal house-user hryvnia humidity hurricane i-cursor
|
|
190
|
+
ice-cream ice-skate icicles icons icons-alt id-badge id-card id-card-alt igloo image
|
|
191
|
+
image-polaroid images inbox inbox-in inbox-out indent industry industry-alt infinity info
|
|
192
|
+
info-circle info-square inhaler integral intersection inventory island-tropical italic
|
|
193
|
+
jack-o-lantern jedi joint journal-whills joystick jug kaaba kazoo kerning key key-skeleton
|
|
194
|
+
keyboard keynote khanda kidneys kiss kiss-beam kiss-wink-heart kite kiwi-bird knife-kitchen
|
|
195
|
+
lambda lamp lamp-desk lamp-floor landmark landmark-alt language laptop laptop-code laptop-house
|
|
196
|
+
laptop-medical lasso laugh laugh-beam laugh-squint laugh-wink layer-group layer-minus layer-plus
|
|
197
|
+
leaf leaf-heart leaf-maple leaf-oak lemon less-than less-than-equal level-down level-down-alt
|
|
198
|
+
level-up level-up-alt life-ring light-ceiling light-switch light-switch-off light-switch-on
|
|
199
|
+
lightbulb lightbulb-dollar lightbulb-exclamation lightbulb-on lightbulb-slash lights-holiday
|
|
200
|
+
line-columns line-height link lips lira-sign list list-alt list-music list-ol list-ul location
|
|
201
|
+
location-arrow location-circle location-slash lock lock-alt lock-open lock-open-alt
|
|
202
|
+
long-arrow-alt-down long-arrow-alt-left long-arrow-alt-right long-arrow-alt-up long-arrow-down
|
|
203
|
+
long-arrow-left long-arrow-right long-arrow-up loveseat low-vision luchador luggage-cart lungs
|
|
204
|
+
lungs-virus mace magic magnet mail-bulk mailbox male mandolin map map-marked map-marked-alt
|
|
205
|
+
map-marker map-marker-alt map-marker-alt-slash map-marker-check map-marker-edit
|
|
206
|
+
map-marker-exclamation map-marker-minus map-marker-plus map-marker-question map-marker-slash
|
|
207
|
+
map-marker-smile map-marker-times map-pin map-signs marker mars mars-double mars-stroke
|
|
208
|
+
mars-stroke-h mars-stroke-v mask meat medal medkit megaphone meh meh-blank meh-rolling-eyes
|
|
209
|
+
memory menorah mercury meteor microchip microphone microphone-alt microphone-alt-slash
|
|
210
|
+
microphone-slash microphone-stand microscope microwave mind-share minus minus-circle
|
|
211
|
+
minus-hexagon minus-octagon minus-square mistletoe mitten mobile mobile-alt mobile-android
|
|
212
|
+
mobile-android-alt money-bill money-bill-alt money-bill-wave money-bill-wave-alt money-check
|
|
213
|
+
money-check-alt money-check-edit money-check-edit-alt monitor-heart-rate monkey monument moon
|
|
214
|
+
moon-cloud moon-stars mortar-pestle mosque motorcycle mountain mountains mouse mouse-alt
|
|
215
|
+
mouse-pointer mp3-player mug mug-hot mug-marshmallows mug-tea music music-alt music-alt-slash
|
|
216
|
+
music-slash narwhal network-wired neuter newspaper not-equal notes-medical object-group
|
|
217
|
+
object-ungroup octagon oil-can oil-temp om omega ornament otter outdent outlet oven overline
|
|
218
|
+
page-break pager paint-brush paint-brush-alt paint-roller palette pallet pallet-alt paper-plane
|
|
219
|
+
paperclip parachute-box paragraph paragraph-rtl parking parking-circle parking-circle-slash
|
|
220
|
+
parking-slash passport pastafarianism paste pause pause-circle paw paw-alt paw-claws peace
|
|
221
|
+
pegasus pen pen-alt pen-fancy pen-nib pen-square pencil pencil-alt pencil-paintbrush
|
|
222
|
+
pencil-ruler pennant people-arrows people-carry pepper-hot percent percentage person-booth
|
|
223
|
+
person-carry person-dolly person-dolly-empty person-sign phone phone-alt phone-laptop
|
|
224
|
+
phone-office phone-plus phone-rotary phone-slash phone-square phone-square-alt phone-volume
|
|
225
|
+
photo-video pi piano piano-keyboard pie pig piggy-bank pills pizza pizza-slice place-of-worship
|
|
226
|
+
plane plane-alt plane-arrival plane-departure plane-slash planet-moon planet-ringed play
|
|
227
|
+
play-circle plug plus plus-circle plus-hexagon plus-octagon plus-square podcast podium
|
|
228
|
+
podium-star police-box poll poll-h poll-people poo poo-storm poop popcorn portal-enter
|
|
229
|
+
portal-exit portrait pound-sign power-off pray praying-hands prescription prescription-bottle
|
|
230
|
+
prescription-bottle-alt presentation print print-search print-slash procedures project-diagram
|
|
231
|
+
projector pump-medical pump-soap pumpkin puzzle-piece qrcode question question-circle
|
|
232
|
+
question-square quidditch quote-left quote-right quran rabbit rabbit-fast racquet radar
|
|
233
|
+
radiation radiation-alt radio radio-alt rainbow raindrops ram ramp-loading random raygun receipt
|
|
234
|
+
record-vinyl rectangle-landscape rectangle-portrait rectangle-wide recycle redo redo-alt
|
|
235
|
+
refrigerator registered remove-format repeat repeat-1 repeat-1-alt repeat-alt reply reply-all
|
|
236
|
+
republican restroom retweet retweet-alt ribbon ring rings-wedding road robot rocket
|
|
237
|
+
rocket-launch route route-highway route-interstate router rss rss-square ruble-sign ruler
|
|
238
|
+
ruler-combined ruler-horizontal ruler-triangle ruler-vertical running rupee-sign rv sack
|
|
239
|
+
sack-dollar sad-cry sad-tear salad sandwich satellite satellite-dish sausage save sax-hot
|
|
240
|
+
saxophone scalpel scalpel-path scanner scanner-image scanner-keyboard scanner-touchscreen
|
|
241
|
+
scarecrow scarf school screwdriver scroll scroll-old scrubber scythe sd-card search
|
|
242
|
+
search-dollar search-location search-minus search-plus seedling send-back send-backward sensor
|
|
243
|
+
sensor-alert sensor-fire sensor-on sensor-smoke server shapes share share-all share-alt
|
|
244
|
+
share-alt-square share-square sheep shekel-sign shield shield-alt shield-check shield-cross
|
|
245
|
+
shield-virus ship shipping-fast shipping-timed shish-kebab shoe-prints shopping-bag
|
|
246
|
+
shopping-basket shopping-cart shovel shovel-snow shower shredder shuttle-van shuttlecock sickle
|
|
247
|
+
sigma sign sign-in sign-in-alt sign-language sign-out sign-out-alt signal signal-1 signal-2
|
|
248
|
+
signal-3 signal-4 signal-alt signal-alt-1 signal-alt-2 signal-alt-3 signal-alt-slash
|
|
249
|
+
signal-slash signal-stream signature sim-card sink siren siren-on sitemap skating skeleton
|
|
250
|
+
ski-jump ski-lift skiing skiing-nordic skull skull-cow skull-crossbones slash sledding sleigh
|
|
251
|
+
sliders-h sliders-h-square sliders-v sliders-v-square smile smile-beam smile-plus smile-wink
|
|
252
|
+
smog smoke smoking smoking-ban sms snake snooze snow-blowing snowboarding snowflake snowflakes
|
|
253
|
+
snowman snowmobile snowplow soap socks solar-panel solar-system sort sort-alpha-down
|
|
254
|
+
sort-alpha-down-alt sort-alpha-up sort-alpha-up-alt sort-alt sort-amount-down
|
|
255
|
+
sort-amount-down-alt sort-amount-up sort-amount-up-alt sort-circle sort-circle-down
|
|
256
|
+
sort-circle-up sort-down sort-numeric-down sort-numeric-down-alt sort-numeric-up
|
|
257
|
+
sort-numeric-up-alt sort-shapes-down sort-shapes-down-alt sort-shapes-up sort-shapes-up-alt
|
|
258
|
+
sort-size-down sort-size-down-alt sort-size-up sort-size-up-alt sort-up soup spa space-shuttle
|
|
259
|
+
space-station-moon space-station-moon-alt spade sparkles speaker speakers spell-check spider
|
|
260
|
+
spider-black-widow spider-web spinner spinner-third splotch spray-can sprinkler square
|
|
261
|
+
square-full square-root square-root-alt squirrel staff stamp star star-and-crescent
|
|
262
|
+
star-christmas star-exclamation star-half star-half-alt star-of-david star-of-life star-shooting
|
|
263
|
+
starfighter starfighter-alt stars starship starship-freighter steak steering-wheel step-backward
|
|
264
|
+
step-forward stethoscope sticky-note stocking stomach stop stop-circle stopwatch stopwatch-20
|
|
265
|
+
store store-alt store-alt-slash store-slash stream street-view stretcher strikethrough
|
|
266
|
+
stroopwafel subscript subway suitcase suitcase-rolling sun sun-cloud sun-dust sun-haze
|
|
267
|
+
sunglasses sunrise sunset superscript surprise swatchbook swimmer swimming-pool sword
|
|
268
|
+
sword-laser sword-laser-alt swords swords-laser synagogue sync sync-alt syringe table
|
|
269
|
+
table-tennis tablet tablet-alt tablet-android tablet-android-alt tablet-rugged tablets
|
|
270
|
+
tachometer tachometer-alt tachometer-alt-average tachometer-alt-fast tachometer-alt-fastest
|
|
271
|
+
tachometer-alt-slow tachometer-alt-slowest tachometer-average tachometer-fast tachometer-fastest
|
|
272
|
+
tachometer-slow tachometer-slowest taco tag tags tally tanakh tape tasks tasks-alt taxi teeth
|
|
273
|
+
teeth-open telescope temperature-down temperature-frigid temperature-high temperature-hot
|
|
274
|
+
temperature-low temperature-up tenge tennis-ball terminal text text-height text-size text-width
|
|
275
|
+
th th-large th-list theater-masks thermometer thermometer-empty thermometer-full
|
|
276
|
+
thermometer-half thermometer-quarter thermometer-three-quarters theta thumbs-down thumbs-up
|
|
277
|
+
thumbtack thunderstorm thunderstorm-moon thunderstorm-sun ticket ticket-alt tilde times
|
|
278
|
+
times-circle times-hexagon times-octagon times-square tint tint-slash tire tire-flat
|
|
279
|
+
tire-pressure-warning tire-rugged tired toggle-off toggle-on toilet toilet-paper
|
|
280
|
+
toilet-paper-alt toilet-paper-slash tombstone tombstone-alt toolbox tools tooth toothbrush torah
|
|
281
|
+
torii-gate tornado tractor trademark traffic-cone traffic-light traffic-light-go
|
|
282
|
+
traffic-light-slow traffic-light-stop trailer train tram transgender transgender-alt transporter
|
|
283
|
+
transporter-1 transporter-2 transporter-3 transporter-empty trash trash-alt trash-restore
|
|
284
|
+
trash-restore-alt trash-undo trash-undo-alt treasure-chest tree tree-alt tree-christmas
|
|
285
|
+
tree-decorated tree-large tree-palm trees triangle triangle-music trophy trophy-alt truck
|
|
286
|
+
truck-container truck-couch truck-loading truck-monster truck-moving truck-pickup truck-plow
|
|
287
|
+
truck-ramp trumpet tshirt tty turkey turntable turtle tv tv-alt tv-music tv-retro typewriter ufo
|
|
288
|
+
ufo-beam umbrella umbrella-beach underline undo undo-alt unicorn union universal-access
|
|
289
|
+
university unlink unlock unlock-alt upload usb-drive usd-circle usd-square user user-alien
|
|
290
|
+
user-alt user-alt-slash user-astronaut user-chart user-check user-circle user-clock user-cog
|
|
291
|
+
user-cowboy user-crown user-edit user-friends user-graduate user-hard-hat user-headset
|
|
292
|
+
user-injured user-lock user-md user-md-chat user-minus user-music user-ninja user-nurse
|
|
293
|
+
user-plus user-robot user-secret user-shield user-slash user-tag user-tie user-times user-unlock
|
|
294
|
+
user-visor users users-class users-cog users-crown users-medical users-slash utensil-fork
|
|
295
|
+
utensil-knife utensil-spoon utensils utensils-alt vacuum vacuum-robot value-absolute
|
|
296
|
+
vector-square venus venus-double venus-mars vest vest-patches vhs vial vials video video-plus
|
|
297
|
+
video-slash vihara violin virus virus-slash viruses voicemail volcano volleyball-ball volume
|
|
298
|
+
volume-down volume-mute volume-off volume-slash volume-up vote-nay vote-yea vr-cardboard
|
|
299
|
+
wagon-covered walker walkie-talkie walking wallet wand wand-magic warehouse warehouse-alt washer
|
|
300
|
+
watch watch-calculator watch-fitness water water-lower water-rise wave-sine wave-square
|
|
301
|
+
wave-triangle waveform waveform-path webcam webcam-slash weight weight-hanging whale wheat
|
|
302
|
+
wheelchair whistle wifi wifi-1 wifi-2 wifi-slash wind wind-turbine wind-warning window
|
|
303
|
+
window-alt window-close window-frame window-frame-open window-maximize window-minimize
|
|
304
|
+
window-restore windsock wine-bottle wine-glass wine-glass-alt won-sign wreath wrench x-ray
|
|
305
|
+
yen-sign yin-yang
|
|
306
|
+
`.trim().split(/\s+/),tV=`
|
|
307
|
+
500px accessible-icon accusoft acquisitions-incorporated adn adversal affiliatetheme airbnb
|
|
308
|
+
algolia alipay amazon amazon-pay amilia android angellist angrycreative angular app-store
|
|
309
|
+
app-store-ios apper apple apple-pay artstation asymmetrik atlassian audible autoprefixer avianex
|
|
310
|
+
aviato aws bandcamp battle-net behance behance-square bimobject bitbucket bitcoin bity black-tie
|
|
311
|
+
blackberry blogger blogger-b bluetooth bluetooth-b bootstrap btc buffer buromobelexperte
|
|
312
|
+
buy-n-large buysellads canadian-maple-leaf cc-amazon-pay cc-amex cc-apple-pay cc-diners-club
|
|
313
|
+
cc-discover cc-jcb cc-mastercard cc-paypal cc-stripe cc-visa centercode centos chrome chromecast
|
|
314
|
+
cloudflare cloudscale cloudsmith cloudversify codepen codiepie confluence connectdevelop contao
|
|
315
|
+
cotton-bureau cpanel creative-commons creative-commons-by creative-commons-nc
|
|
316
|
+
creative-commons-nc-eu creative-commons-nc-jp creative-commons-nd creative-commons-pd
|
|
317
|
+
creative-commons-pd-alt creative-commons-remix creative-commons-sa creative-commons-sampling
|
|
318
|
+
creative-commons-sampling-plus creative-commons-share creative-commons-zero critical-role css3
|
|
319
|
+
css3-alt cuttlefish d-and-d d-and-d-beyond dailymotion dashcube deezer delicious deploydog
|
|
320
|
+
deskpro dev deviantart dhl diaspora digg digital-ocean discord discourse dochub docker
|
|
321
|
+
draft2digital dribbble dribbble-square dropbox drupal dyalog earlybirds ebay edge edge-legacy
|
|
322
|
+
elementor ello ember empire envira erlang ethereum etsy evernote expeditedssl facebook
|
|
323
|
+
facebook-f facebook-messenger facebook-square fantasy-flight-games fedex fedora figma firefox
|
|
324
|
+
firefox-browser first-order first-order-alt firstdraft flickr flipboard fly font-awesome
|
|
325
|
+
font-awesome-alt font-awesome-flag fonticons fonticons-fi fort-awesome fort-awesome-alt forumbee
|
|
326
|
+
foursquare free-code-camp freebsd fulcrum galactic-republic galactic-senate get-pocket gg
|
|
327
|
+
gg-circle git git-alt git-square github github-alt github-square gitkraken gitlab gitter glide
|
|
328
|
+
glide-g gofore goodreads goodreads-g google google-drive google-pay google-play google-plus
|
|
329
|
+
google-plus-g google-plus-square google-wallet gratipay grav gripfire grunt guilded gulp
|
|
330
|
+
hacker-news hacker-news-square hackerrank hips hire-a-helper hive hooli hornbill hotjar houzz
|
|
331
|
+
html5 hubspot ideal imdb innosoft instagram instagram-square instalod intercom internet-explorer
|
|
332
|
+
invision ioxhost itch-io itunes itunes-note java jedi-order jenkins jira joget joomla js
|
|
333
|
+
js-square jsfiddle kaggle keybase keycdn kickstarter kickstarter-k korvue laravel lastfm
|
|
334
|
+
lastfm-square leanpub less line linkedin linkedin-in linode linux lyft magento mailchimp
|
|
335
|
+
mandalorian markdown mastodon maxcdn mdb medapps medium medium-m medrt meetup megaport mendeley
|
|
336
|
+
microblog microsoft mix mixcloud mixer mizuni modx monero napster neos nimblr node node-js npm
|
|
337
|
+
ns8 nutritionix octopus-deploy odnoklassniki odnoklassniki-square old-republic opencart openid
|
|
338
|
+
opera optin-monster orcid osi page4 pagelines palfed patreon paypal penny-arcade perbyte
|
|
339
|
+
periscope phabricator phoenix-framework phoenix-squadron php pied-piper pied-piper-alt
|
|
340
|
+
pied-piper-hat pied-piper-pp pied-piper-square pinterest pinterest-p pinterest-square
|
|
341
|
+
playstation product-hunt pushed python qq quinscape quora r-project raspberry-pi ravelry react
|
|
342
|
+
reacteurope readme rebel red-river reddit reddit-alien reddit-square redhat renren replyd
|
|
343
|
+
researchgate resolving rev rocketchat rockrms rust safari salesforce sass schlix scribd
|
|
344
|
+
searchengin sellcast sellsy servicestack shirtsinbulk shopify shopware simplybuilt sistrix sith
|
|
345
|
+
sketch skyatlas skype slack slack-hash slideshare snapchat snapchat-ghost snapchat-square
|
|
346
|
+
soundcloud sourcetree speakap speaker-deck spotify squarespace stack-exchange stack-overflow
|
|
347
|
+
stackpath staylinked steam steam-square steam-symbol sticker-mule strava stripe stripe-s
|
|
348
|
+
studiovinari stumbleupon stumbleupon-circle superpowers supple suse swift symfony teamspeak
|
|
349
|
+
telegram telegram-plane tencent-weibo the-red-yeti themeco themeisle think-peaks tiktok
|
|
350
|
+
trade-federation trello tumblr tumblr-square twitch twitter twitter-square typo3 uber ubuntu
|
|
351
|
+
uikit umbraco uncharted uniregistry unity unsplash untappd ups usb usps ussunnah vaadin viacoin
|
|
352
|
+
viadeo viadeo-square viber vimeo vimeo-square vimeo-v vine vk vnv vuejs watchman-monitoring waze
|
|
353
|
+
weebly weibo weixin whatsapp whatsapp-square whmcs wikipedia-w windows wix wizards-of-the-coast
|
|
354
|
+
wodu wolf-pack-battalion wordpress wordpress-simple wpbeginner wpexplorer wpforms wpressr xbox
|
|
355
|
+
xing xing-square y-combinator yahoo yammer yandex yandex-international yarn yelp yoast youtube
|
|
356
|
+
youtube-square zhihu
|
|
357
|
+
`.trim().split(/\s+/),tU=['300 12px "Font Awesome 5 Pro Light"','400 12px "Font Awesome 5 Pro Regular"','900 12px "Font Awesome 5 Pro Solid"','400 12px "Font Awesome 5 Brands U2"'],tH=!1,tW={light:"fal",regular:"far",solid:"fas",brands:"fab"},tY=new Set(tV);function tK(e,t){var n;!function(){if(!tH&&document.fonts&&document.documentElement.classList.contains("u2-standalone")){tH=!0;var e=!0,t=!1,n=void 0;try{for(var i,r=tU[Symbol.iterator]();!(e=(i=r.next()).done);e=!0){let e=i.value;document.fonts.load(e).catch(()=>void 0)}}catch(e){t=!0,n=e}finally{try{e||null==r.return||r.return()}finally{if(t)throw n}}}}();let i=document.createElement("i"),r=null!=(n=null==t?void 0:t.variant)?n:tY.has(e)?"brands":"light";i.className=["grok-icon","u2-icon",...e.startsWith("svg-")?["svg-icon",e]:[tW[r],`fa-${e}`],(null==t?void 0:t.size)?`u2-icon-${t.size}`:void 0,null==t?void 0:t.cls].filter(e=>e).join(" "),i.dataset.u2="icon";let o=null==t?void 0:t.tooltip;if(o){i.setAttribute("aria-label",o);let e=P.Scope.ambient;e?tS.bind(i,o,{owner:e}):i.title=o}return i}function tX(e){return"string"==typeof e?tK(e):e}function tZ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function tQ(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class tJ extends H{get ambientAdoption(){return!1}getState(){return tQ(tZ({},super.getState()),{open:!0})}getItems(){let e=this._level,t=e.entries.filter(e=>"separator"!==e.node.kind).map((t,n)=>{var i,r;return tQ(tZ({key:t.path,label:t.node.label,index:n,disabled:null!==tA.now(null==(i=t.node.options)?void 0:i.disabled)},(null==(r=t.node.options)?void 0:r.check)===void 0?{}:{checked:t.node.options.check},"group"===t.node.kind?{expanded:e.entries[e.openIndex]===t}:{}),{rendered:!0})});return{count:t.length,list:t,truncated:!1}}constructor(e){super(e.panel,e.scope),this._level=e}}class t0{static popup(){return new t0}item(e,t,n){return this._current.push({kind:"item",label:e,onClick:t0._owned(t),options:n}),this}separator(){return this._current.push({kind:"separator",label:""}),this}group(e){let t=[];return this._current.push({kind:"group",label:e,children:t}),this._stack.push(t),this}endGroup(){return this._stack.length>1&&this._stack.pop(),this}show(e){this.close();let t=document.activeElement;this._returnFocus=t instanceof HTMLElement?t:void 0;let n=new P.Scope(void 0,{label:"menu"});this._scope=n;let i=this._buildLevel(this._nodes,0,"");this._levels.push(i),this._open.value=!0,this._machine.value="open";let r="anchor"in e?e.anchor:t0._point(i.panel,e.x,e.y,n);tx.show(r,i.panel,{owner:n}),i.scope.listen(i.panel,tb,()=>this.close()),i.panel.focus({preventScroll:!0})}close(){let e=this._scope;if(!e)return;for(this._scope=void 0,this._hoverCancel=void 0;this._levels.length>0;)t0._disposeLevel(this._levels.pop());e.dispose(),this._open.value=!1,this._machine.value="closed";let t=this._returnFocus;this._returnFocus=void 0,t&&t.isConnected&&t.focus()}bindContext(e,t){let n,i=K.scopeOf(null==t?void 0:t.owner,"Menu.bindContext()");i.listen(e,"contextmenu",e=>{e.preventDefault(),this.show({x:e.clientX,y:e.clientY}),n=this._scope}),i.own(()=>{void 0!==n&&this._scope===n&&this.close()})}get _current(){return this._stack[this._stack.length-1]}static _point(e,t,n,i){e.style.position="fixed",e.style.visibility="hidden",tx.host.append(e);let r=e.offsetWidth;e.style.visibility="";let o=document.createElement("div");o.className="u2-menu-point";let s=t+r>window.innerWidth-4?Math.max(4,t-r):t;return o.style.cssText=`position: fixed; left: ${s}px; top: ${n}px; width: 0; height: 0;`,tx.host.append(o),i.own(()=>o.remove()),o}_buildLevel(e,t,n){let i=document.createElement("div");i.className="u2-menu",i.dataset.u2="menu",i.tabIndex=-1,i.setAttribute("role","menu");let r={depth:t,panel:i,entries:[],active:-1,openIndex:-1,scope:this._scope.child("menu-level")},o=e.some(e=>{var t;return(null==(t=e.options)?void 0:t.detail)!==void 0});i.classList.toggle("u2-menu-detailed",o);var s=!0,a=!1,l=void 0;try{for(var u,d=e[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){let e=u.value,s=""===n?e.label:`${n} > ${e.label}`,a=this._renderNode(e,t,r.entries.length,s,o,r.scope);r.entries.push({node:e,el:a,path:s}),i.append(a)}}catch(e){a=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(a)throw l}}new tJ(r);let c=r.scope;return c.listen(i,"keydown",e=>this._onKeyDown(r,e)),c.listen(i,"pointerover",e=>this._onPointerOver(r,e)),c.listen(i,"pointerdown",e=>e.preventDefault()),c.listen(i,"click",e=>this._onClick(r,e)),r}_renderNode(e,t,n,i,r,o){var s,a;if("separator"===e.kind){let e=document.createElement("div");return e.className="u2-menu-separator",e.setAttribute("role","separator"),e}let l=null!=(s=e.options)?s:{},u="group"===e.kind,d=document.createElement("div");d.className=u?"u2-menu-item u2-menu-item-sub":"u2-menu-item",d.id=`${this._id}-${t}-${n}`,d.dataset.index=String(n),d.dataset.u2Item=i,d.setAttribute("role",void 0===l.check?"menuitem":"menuitemcheckbox");let c=tA.now(l.disabled);tA.apply(d,c),null===c?d.setAttribute("aria-disabled","false"):tS.bind(d,c,{owner:o}),void 0!==l.check&&d.setAttribute("aria-checked",String(l.check)),u&&(d.setAttribute("aria-haspopup","menu"),d.setAttribute("aria-expanded","false"));let h=document.createElement("span");h.className="u2-menu-icon",h.setAttribute("aria-hidden","true"),l.check?h.textContent="✓":l.icon&&h.append(tK(l.icon));let p=document.createElement("span");p.className="u2-menu-label",p.dataset.u2Part="item-label",p.textContent=e.label,p.id=`${d.id}-label`,d.setAttribute("aria-labelledby",p.id);let f=document.createElement("span");if(f.className=u?"u2-menu-arrow":"u2-menu-shortcut",f.textContent=u?"":null!=(a=l.shortcut)?a:"",d.append(h,p),p.classList.toggle("u2-menu-label-wide",r&&void 0===l.detail),void 0!==l.detail){let e=document.createElement("span");e.className="u2-menu-detail",e.dataset.u2Part="item-detail",e.textContent=l.detail,e.id=`${d.id}-detail`,null===c&&d.setAttribute("aria-describedby",e.id),d.append(e)}return d.append(f),d}_openSubmenu(e,t,n){let i=e.entries[t];if(!i||"group"!==i.node.kind)return;if(e.openIndex!==t){this._closeFrom(e.depth+1);let n=this._buildLevel(i.node.children,e.depth+1,i.path);this._levels.push(n),e.openIndex=t,i.el.setAttribute("aria-expanded","true"),i.el.classList.add("u2-menu-item-open"),n.panel.style.position="fixed",n.panel.style.left="0",n.panel.style.top="0",i.el.append(n.panel),n.scope.own(th(i.el,n.panel,()=>{tg(i.el,n.panel,{strategy:"fixed",placement:"right-start",middleware:[tp({mainAxis:-1,crossAxis:-3}),tm({fallbackPlacements:["left-start"]}),tf({padding:4})]}).then(e=>{let t=e.x,i=e.y;n.panel.style.left=`${t}px`,n.panel.style.top=`${i}px`})}))}let r=this._levels[e.depth+1];this._machine.value="submenu-open",n&&(r.panel.focus({preventScroll:!0}),r.active<0&&t0._setActive(r,t0._step(r,1)))}_closeFrom(e){for(;this._levels.length>e;)t0._disposeLevel(this._levels.pop());let t=this._levels[this._levels.length-1];if(t&&t.openIndex>=0){let e=t.entries[t.openIndex].el;e.setAttribute("aria-expanded","false"),e.classList.remove("u2-menu-item-open"),t.openIndex=-1}this._machine.value=this._levels.length>1?"submenu-open":"open"}_activate(e,t){let n=e.entries[t];if(!n||!t0._navigable(n.node))return;if("group"===n.node.kind)return void this._openSubmenu(e,t,!0);let i=n.node.onClick,r=n.node.options;if(null==r?void 0:r.keepOpen){void 0!==r.check&&t0._check(n.el,r,!r.check),null==i||i();return}this.close(),i&&i()}static _check(e,t,n){t.check=n,e.setAttribute("aria-checked",String(n));let i=e.querySelector(".u2-menu-icon");i.textContent=n?"✓":"",!n&&t.icon&&i.append(tK(t.icon))}_onClick(e,t){let n=t0._indexAt(e,t);n>=0&&this._activate(e,n)}_onPointerOver(e,t){var n,i;let r=t0._indexAt(e,t);if(r<0)return;t.stopPropagation();let o=e.entries[r],s="group"===o.node.kind;t0._navigable(o.node)&&t0._setActive(e,r),null==(n=this._hoverCancel)||n.call(this),this._hoverCancel=void 0,(s?e.openIndex===r:e.openIndex<0)||(this._hoverCancel=null==(i=this._scope)?void 0:i.setTimeout(()=>{this._hoverCancel=void 0,s?this._openSubmenu(e,r,!1):this._closeFrom(e.depth+1)},200))}_onKeyDown(e,t){if(t.target===e.panel)switch(t.key){case"ArrowDown":t.preventDefault(),t0._setActive(e,t0._step(e,1));break;case"ArrowUp":t.preventDefault(),t0._setActive(e,t0._step(e,-1));break;case"Home":t.preventDefault(),t0._setActive(e,t0._edge(e,1));break;case"End":t.preventDefault(),t0._setActive(e,t0._edge(e,-1));break;case"ArrowRight":e.entries[e.active]&&"group"===e.entries[e.active].node.kind&&(t.preventDefault(),this._openSubmenu(e,e.active,!0));break;case"ArrowLeft":if(e.depth>0){t.preventDefault();let n=this._levels[e.depth-1];this._closeFrom(e.depth),n.panel.focus({preventScroll:!0})}break;case"Enter":t.preventDefault(),this._activate(e,e.active);break;case"Escape":t.preventDefault(),this.close();break;default:if(1===t.key.length&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=t0._jump(e,t.key.toLowerCase());n>=0&&(t.preventDefault(),t0._setActive(e,n))}}}static _owned(e){let t=P.Scope.ambient;return()=>void 0===t||t.isDisposed?(0,P.batch)(()=>P.Scope.runWith(void 0,e)):t.run(e)}static _disposeLevel(e){e.scope.dispose(),e.panel.remove()}static _navigable(e){var t;return"separator"!==e.kind&&null===tA.now(null==(t=e.options)?void 0:t.disabled)}static _indexAt(e,t){let n=t.target.closest(".u2-menu-item");return n&&n.parentElement===e.panel?Number(n.dataset.index):-1}static _setActive(e,t){e.active=t;for(let n=0;n<e.entries.length;n++)e.entries[n].el.classList.toggle("u2-menu-item-active",n===t);t<0?e.panel.removeAttribute("aria-activedescendant"):e.panel.setAttribute("aria-activedescendant",e.entries[t].el.id)}static _step(e,t){let n=e.entries.length;if(0===n)return -1;let i=e.active>=0?e.active:t>0?-1:0;for(let r=1;r<=n;r++){let o=((i+t*r)%n+n)%n;if(t0._navigable(e.entries[o].node))return o}return -1}static _edge(e,t){let n=e.entries.length;for(let i=t>0?0:n-1;i>=0&&i<n;i+=t)if(t0._navigable(e.entries[i].node))return i;return -1}static _jump(e,t){let n=e.entries.length;for(let i=1;i<=n;i++){let r=(e.active+i+n)%n,o=e.entries[r].node;if(t0._navigable(o)&&o.label.toLowerCase().startsWith(t))return r}return -1}constructor(){this._id=`u2-menu-${++t0._seq}`,this._nodes=[],this._stack=[],this._levels=[],this._open=(0,P.signal)(!1),this._machine=(0,P.signal)("closed"),this.isOpen=this._open,this.machineState=this._machine,this._stack.push(this._nodes)}}t0._seq=0;let t2="u2: signal binding needs an owner — build under `owner.build(…)` or `component((self) => …)`; after an `await`, inside `owner.task(async (t) => … t.build(…))`",t1=new Set;function t3(e,t){let n=P.Scope.ambient,i=void 0===n?void 0:new P.Scope(n,{label:e,lazy:!0});return P.Scope.runWith(i,()=>t(i))}function t5(e,t){if("string"==typeof t)return void e.setAttribute("aria-label",t);let n=P.Scope.ambient;if(!n)throw Error(t2);n.effect(()=>{var n;return e.setAttribute("aria-label",String(null!=(n=t.value)?n:""))})}function t4(e,t){t5(e,t);let n=()=>{var e;return"string"==typeof t?t:String(null!=(e=t.peek())?e:"")},i=P.Scope.ambient;i?tS.bind(e,n,{owner:i}):e.title=n()}function t6(e,t,n){let i,r=null==n?void 0:n.toggle,o=null==n?void 0:n.disabled,s=tB(tK(e,{variant:null==n?void 0:n.variant}),e=>{if(r&&(r.value=!r.peek()),(null==n?void 0:n.menu)!==void 0){let e=(null==i?void 0:i.isOpen.peek())===!0;null==i||i.close(),null==(i=e?void 0:n.menu())||i.show({anchor:s})}return t(e)},void 0===o?void 0:{disabled:o,tooltip:null==n?void 0:n.tooltip});s.classList.add("u2-icon-btn"),s.dataset.u2="icon-button";let a=null==n?void 0:n.tooltip;if(a&&void 0!==o?t5(s,a):a?t4(s,a):P.debug.enabled&&!t1.has(e)&&(t1.add(e),console.warn(`u2: iconButton("${e}") has no tooltip — an icon-only button needs one for its accessible name`)),!r)return s;let l=P.Scope.ambient;if(!l)throw Error(t2);return l.effect(()=>{let e=r.value;s.classList.toggle("u2-icon-btn-pressed",e),s.setAttribute("aria-pressed",String(e))}),s}function t8(e,t,n,i){let r=null==i?void 0:i.disabled,o=tB(tK(t),n,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({primary:null==i?void 0:i.primary},void 0===r?{}:{disabled:r,tooltip:null==i?void 0:i.tooltip})),s=t$(e,"u2-btn-label");return(null==i?void 0:i.iconRight)?o.prepend(s):o.append(s),o.dataset.u2="button",(null==i?void 0:i.tooltip)&&void 0!==r?o.setAttribute("aria-label",i.tooltip):(null==i?void 0:i.tooltip)&&t4(o,i.tooltip),o}class t9{static caption(e){return`${t9.CAPTION_PREFIX}${e}`}static isService(e){return e.startsWith("~")}static isDraft(e){return("string"==typeof e?e:e.id).startsWith(t9.DRAFT_PREFIX)}static isDeleted(e){return!0===e[t9.DELETED]}static draftId(){return`${t9.DRAFT_PREFIX}${(0,P.uuid4)()}`}static real(e,t){return"string"==typeof t&&Object.hasOwn(e,t)?e[t]:void 0}static unkeyed(e){return`~row:${e}`}}function t7(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function ne(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function nt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return t7(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t7(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}t9.STATE="~state",t9.DRAFT_PREFIX="~new:",t9.DELETED="~is_deleted",t9.CAPTION_PREFIX="~caption_";class nn{static from(e){return new nn(ne({},e.can),ne({},e.fields),!1,"hidden")}can(e){var t;return!1!==this._bound[e]&&(null!=(t=this._can[e])?t:this._unlistedCan)}narrow(e){let t={};var n=!0,i=!1,r=void 0;try{for(var o,s=Object.entries(e)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=nt(o.value,2),n=e[0],i=e[1];!1===i&&(t[n]=!1)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return new nn(ne({},this._can,t),this._fields,this._unlistedCan,this._unlistedField,this._writes,ne({},this._bound,t))}columnPolicy(){return new nn({},this._fields,!0,this._unlistedField,this._writes)}field(e){var t;let n=null!=(t=this._fields[e])?t:this._unlistedField,i="immutable"===n?this.isDraft?"editable":"readonly":n;return"editable"!==i||this.can(this._writes)?i:"readonly"}get isDraft(){return"insert"===this._writes}forDraft(){return this.isDraft?this:new nn(this._can,this._fields,this._unlistedCan,this._unlistedField,"insert",this._bound)}row(e){let t;if(null==e)return this;if("new"===e[t9.STATE])return this.forDraft();let n=new Set([...Object.keys(this._can),...nn.ROW_COLUMNS.map(e=>nt(e,2)[1])]);var i=!0,r=!1,o=void 0;try{for(var s,a=n[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let n=s.value,i=e[`${nn.ROW_PREFIX}${n}`];"boolean"==typeof i&&(null!=t||(t=ne({},this._can)),t[n]=i)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}return void 0===t?this:new nn(t,this._fields,this._unlistedCan,this._unlistedField,this._writes,this._bound)}constructor(e,t,n,i,r,o){this._can=e,this._fields=t,this._unlistedCan=n,this._unlistedField=i,this._writes=void 0===r?"edit":r,this._bound=void 0===o?{}:o}}function ni(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function nr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function no(e,t){let n=null!=(u=null==t?void 0:t.access)?u:nn.full,i=(null==t?void 0:t.row)===void 0?n:n.row(t.row),r=[],o=!1;var s=!0,a=!1,l=void 0;try{for(var u,d,c=e[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let e=d.value;if(void 0!==e.requires&&!i.can(e.requires)){o||(o=!0===e.separator);continue}r.push(o&&!e.separator?function(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}(nr({},e),{separator:!0}):e),o=!1}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}return r}function ns(e,t){var n=!0,i=!1,r=void 0;try{for(var o,s,a=t.entries()[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){let n=(o=s.value,function(e){if(Array.isArray(e))return e}(o)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(o)||function(e){if(e){if("string"==typeof e)return ni(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ni(e,2)}}(o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=n[0],r=n[1],a=t[i-1];void 0!==a&&(r.separator||r.destructive&&!a.destructive)&&e.separator(),e.item(r.text,r.run,{disabled:r.disabled,shortcut:r.shortcut,detail:r.detail,check:r.check})}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}}function na(e,t){let n=new t0,i=no(e,t);ns(n,i);let r=i.length>0;var o=!0,s=!1,a=void 0;try{for(var l,u,d=(null!=(l=null==t?void 0:t.groups)?l:[])[Symbol.iterator]();!(o=(u=d.next()).done);o=!0){let e=u.value,i=no(e.actions,t);0!==i.length&&(r&&n.separator(),r=!0,n.group(e.text),ns(n,i),n.endGroup())}}catch(e){s=!0,a=e}finally{try{o||null==d.return||d.return()}finally{if(s)throw a}}return n}function nl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function nu(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function nd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function nc(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function nh(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return nl(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nl(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function np(e,t){let n;if(e.end<=e.start)return[];let i={start:n=Math.max(e.start,t.start),end:Math.max(n,Math.min(e.end,t.end))};if(i.end<=i.start)return[e];let r=[];return e.start<i.start&&r.push({start:e.start,end:i.start}),i.end<e.end&&r.push({start:i.end,end:e.end}),r}nn.ROW_COLUMNS=[["~can_edit","edit"],["~can_delete","delete"],["~can_share","share"]],nn.ROW_PREFIX="~can_",nn.full=Object.freeze(new nn({},{},!0,"editable")),nn.readOnly=Object.freeze(new nn({view:!0},{},!1,"readonly"));let nf=0,nm=new Set,ng=new Set(["ArrowDown","ArrowUp","Home","End","PageDown","PageUp","Enter"," "]);class nv extends H{selectKeys(e){let t=this.keyOf;if(void 0===t)return;let n=new Set(e),i=new Set;var r=!0,o=!1,s=void 0;try{for(var a,l=this.items.entries()[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){let e=nh(a.value,2),r=e[0],o=e[1];n.has(t(o))&&i.add(r)}}catch(e){o=!0,s=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw s}}let u=this.selectedIndex.peek();this._write(i,0===i.size?-1:i.has(u)?u:[...i][0])}selectedKeys(){let e=this.keyOf;return void 0===e?[]:[...this._selected.peek()].map(e=>this.items[e]).filter(e=>void 0!==e).map(e)}focusRows(){this.root.focus(),0>this.selectedIndex.peek()&&this.items.length>0&&(this.selectedIndex.value=0)}setItems(e){this._source.value=Array.isArray(e)?(0,P.signal)(e):e}scrollToIndex(e){let t=e*this.itemHeight,n=t+this.itemHeight-this.viewport;t<this.root.scrollTop?this.root.scrollTop=t:n>this.root.scrollTop&&(this.root.scrollTop=n),this._renderVisible()}get renderedCount(){return this._rows.size}rowAt(e){var t,n;return null!=(t=null==(n=this._rows.get(e))?void 0:n.el)?t:null}refresh(e){var t=!0,n=!1,i=void 0;try{for(var r,o=this._rows[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=nh(r.value,2),n=t[0],i=t[1];(void 0===e||i.key===e)&&this._rerender(i,n)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}}getItems(e){let t=this.items.length,n=(null==e?void 0:e.all)?t:Math.min(t,P.ITEMS_CAP),i=this._selected.peek(),r=[];for(let e=0;e<n;e++){let t=this.rowAt(e);r.push({key:this.keyAt(e),label:this._label(e),index:e,selected:i.has(e),disabled:(null==t?void 0:t.getAttribute("aria-disabled"))==="true",rendered:null!==t})}return{count:t,list:r,truncated:n<t}}revealItem(e){var t;return(t=function*(){let t=this._find(e);return t<0?null:(this.scrollToIndex(t),yield new Promise(e=>{setTimeout(e,100),"function"==typeof requestAnimationFrame&&requestAnimationFrame(()=>e())}),this._rows.has(t)||this._renderVisible(),this.rowAt(t))},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){nu(o,i,r,s,a,"next",e)}function a(e){nu(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}getState(){return nc(nd({},super.getState()),{selection:[...this._selected.peek()].map(e=>this.keyAt(e))})}keyAt(e){var t;return null!=(t=this._identity(this.items[e]))?t:`#${e}`}patchRow(e,t){return!1}placeRow(e,t){return!1}setSelected(e,t){e.classList.toggle(`${this._chrome.host}-row-selected`,t),e.setAttribute("aria-selected",String(t))}get viewport(){return this.root.clientHeight}indexOf(e){let t=e.target.closest(`.${this._chrome.host}-row`);return null===t?-1:Number(t.dataset.index)}static capture(e,t){if(!(t.size>0)){var n=!0,i=!1,r=void 0;try{for(var o,s=e.getAttributeNames()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=o.value;t.set(n,e.getAttribute(n))}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}}}static restore(e,t){var n=!0,i=!1,r=void 0;try{for(var o,s=e.getAttributeNames()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=o.value;t.has(n)||e.removeAttribute(n)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}var a=!0,l=!1,u=void 0;try{for(var d,c=t[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){let t=nh(d.value,2),n=t[0],i=t[1];e.setAttribute(n,i)}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}}_single(e){this._anchor=e,this._write(new Set([e]),e)}_toggle(e){let t=new Set(this._selected.peek());if(t.has(e)){if(1===t.size)return;t.delete(e);let n=this.selectedIndex.peek();this._write(t,n===e?[...t][t.size-1]:n)}else t.add(e),this._write(t,e)}_range(e){let t=this.selectedIndex.peek(),n=Math.max(0,Math.min(this.items.length-1,this._anchor>=0?this._anchor:t>=0?t:e)),i=e>=n?1:-1,r=new Set;for(let t=n;t!==e+i;t+=i)r.add(t);this._write(r,e)}_write(e,t){this._multiWrite=t,(0,P.batch)(()=>{this.selectedIndex.value=t,this._selected.value=e})}_onKeyDown(e){let t,n=this.items.length-1;if(n<0||e.target!==this.root)return;let i=this._seeded&&ng.has(e.key);i&&this._unseed();let r=this.selectedIndex.value;if(r>=0&&this.rowKey(e,r))return;let o=Math.max(1,Math.floor(this.viewport/this.itemHeight)-1);switch(e.key){case"ArrowDown":t=i?r:r+1;break;case"ArrowUp":t=r<0?n:r-1;break;case"PageDown":t=r+o;break;case"PageUp":t=r<0?n:r-o;break;case"Home":t=0;break;case"End":t=n;break;default:return}e.preventDefault(),this.selectedIndex.value=Math.max(0,Math.min(n,t)),this.scrollToIndex(this.selectedIndex.value)}_apply(e){let t,n,i=this.items,r=this.selectedIndex.peek(),o=r>=0&&r<i.length?this._identity(i[r]):void 0,s=[],a=r<0||void 0!==o;var l,u=!0,d=!1,c=void 0;try{for(var h,p=this._selected.peek()[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){let e=h.value,t=a&&e<i.length?this._identity(i[e]):void 0;if(void 0===t){a=!1;break}s.push(t)}}catch(e){d=!0,c=e}finally{try{u||null==p.return||p.return()}finally{if(d)throw c}}if(this.items=e,this.content.style.height=`${e.length*this.itemHeight}px`,a&&s.length>0){let e=this._indicesOf(new Set(s));t=new Set(s.map(t=>e.get(t)).filter(e=>void 0!==e)),(n=void 0===o?-1:null!=(l=e.get(o))?l:-1)<0&&t.size>0&&(n=[...t][0])}else t=(n=r<e.length?r:-1)<0?new Set:new Set([n]);this._anchor=n,this._write(t,n),this._reconcile()}_indicesOf(e){let t=new Map;for(let n=0;n<this.items.length&&t.size<e.size;n++){let i=this._identity(this.items[n]);void 0!==i&&e.has(i)&&!t.has(i)&&t.set(i,n)}return t}_reconcile(){let e=new Map;var t=!0,n=!1,i=void 0;try{for(var r,o=this._rows.values()[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;e.has(t.key)?this._release(t):e.set(t.key,t)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}this._rows.clear();let s=this._window();for(let t=s.start;t<s.end;t++){let n=e.get(this.keyAt(t));void 0!==n&&(e.delete(n.key),this._rows.set(t,n),this._keep(n,t))}var a=!0,l=!1,u=void 0;try{for(var d,c=e.values()[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){let e=d.value;this._release(e)}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}for(let e=s.start;e<s.end;e++)this._rows.has(e)||this._insertRow(e);this._rendered=s,this._order()}_order(){let e=this.content.firstChild;for(let n=this._rendered.start;n<this._rendered.end;n++){var t;let i=null==(t=this._rows.get(n))?void 0:t.el;void 0!==i&&(i===e?e=i.nextSibling:this.content.insertBefore(i,e))}}_keep(e,t){let n=!this._live&&this.items[t]===e.item;e.item=this.items[t],this._place(e.el,t),this._hook(e,()=>this.placeRow(e.el,t))&&(n||!this._live&&this._hook(e,()=>this.patchRow(e.el,t)))?this._mark(e.el,t):this._rerender(e,t)}_hook(e,t){return!0===(0,P.untracked)(()=>e.scope.run(t))}_renderVisible(){let e=this._window();var t=!0,n=!1,i=void 0;try{for(var r,o=np(this._rendered,e)[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value;for(let t=e.start;t<e.end;t++)this._releaseRow(t)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}let s=this._rendered;var a=!0,l=!1,u=void 0;try{for(var d,c=np(e,s)[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){let e=d.value;for(let t=e.start;t<e.end;t++)this._insertRow(t)}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}this._rendered=e,e.start<s.start&&s.end>s.start&&this._order()}_window(){let e=this.items.length,t=this.viewport;t<=0&&e>0&&!this._retried?(this._retried=!0,this._later()):t>0&&(this._retried=!1);let n=Math.floor(this.root.scrollTop/this.itemHeight),i=Math.ceil(t/this.itemHeight),r=t=>Math.max(0,Math.min(e,t));return{start:r(n-3),end:r(n+i+3)}}_identity(e){if(void 0!==this.keyOf)return this.keyOf(e);if("string"==typeof e||"number"==typeof e)return String(e);if(null===e||"object"!=typeof e)return;let t=e.name,n=e.id;return"string"==typeof t?t:"string"==typeof n?n:void 0}_label(e){var t;if(void 0!==this._labelOf)return this._labelOf(this.items[e]);let n=this.rowAt(e);return null===n?this.keyAt(e):H.text(null!=(t=n.querySelector('[data-u2-part="item-label"]'))?t:n)}_find(e){var t;let n=this.items.length;for(let t=0;t<n;t++)if(this.keyAt(t)===e)return t;let i=e.trim().toLowerCase(),r=[];for(let e=0;e<n;e++)this._label(e).toLowerCase()===i&&r.push(e);if(r.length>1)throw Error(`u2: ${r.length} items match "${e}": `+r.map(e=>this.keyAt(e)).join(", "));return null!=(t=r[0])?t:-1}_later(){0===this._retry&&"function"==typeof requestAnimationFrame&&(this._retry=requestAnimationFrame(()=>{this._retry=0,this.scope.isDisposed||this._renderVisible()}))}_insertRow(e){let t=this._pool.pop();void 0===t?(t=this.createRow(),nv.capture(t,this._baseline)):nv.restore(t,this._baseline);let n={el:t,key:this.keyAt(e),item:this.items[e],scope:this._rowScope()};this._rows.set(e,n),this._fill(n,e),this.content.append(t)}_rerender(e,t){e.scope.dispose(),e.scope=this._rowScope(),e.item=this.items[t],nv.restore(e.el,this._baseline),this._fill(e,t)}_fill(e,t){this._place(e.el,t),e.el.dataset.u2Item=e.key,(0,P.untracked)(()=>e.scope.run(()=>this.fillRow(e.el,t))),this._mark(e.el,t)}seed(e){this.selectedIndex.value=e,this._seeded=!0,this.root.classList.add(`${this._chrome.host}-seeded`)}_unseed(){this._seeded=!1,this.root.classList.remove(`${this._chrome.host}-seeded`)}_mark(e,t,n,i){let r=void 0===n?this._selected.peek():n,o=void 0===i?this.selectedIndex.peek():i;this.setSelected(e,r.has(t)),e.classList.toggle(`${this._chrome.host}-row-current`,t===o)}_place(e,t){e.style.top=`${t*this.itemHeight}px`,e.id=this._idPrefix+t,e.dataset.index=String(t)}_rowScope(){return new P.Scope(this.scope,{label:"row",lazy:!0})}_releaseRow(e){let t=this._rows.get(e);this._rows.delete(e),this._release(t)}_release(e){e.scope.dispose(),e.el.remove(),this._pool.push(e.el)}constructor(e,t){var n,i;super(),this.selectedIndex=(0,P.signal)(-1),this.content=document.createElement("div"),this.items=[],this._selected=(0,P.signal)(nm),this._seeded=!1,this._source=(0,P.signal)((0,P.signal)([])),this._rows=new Map,this._pool=[],this._baseline=new Map,this._anchor=-1,this._rendered={start:0,end:0},this._retry=0,this._retried=!1,this.selectedIndices=this._selected,this._chrome=t,this.itemHeight=null!=(n=e.itemHeight)?n:22,this.keyOf=e.keyOf,this._labelOf=e.labelOf,this._live=null==(i=e.liveItems)||i,this._idPrefix=`${t.host}-${++nf}-row-`,this.root.classList.add(t.host),this.root.tabIndex=0,this.root.setAttribute("data-u2",t.u2),this.root.setAttribute("role",t.role),this.content.className=`${t.host}-content`,this.root.append(this.content);const r=this.scope;r.listen(this.root,"scroll",()=>this._renderVisible()),r.listen(this.root,"keydown",e=>this._onKeyDown(e)),r.listen(this.content,"click",e=>{let t=this.indexOf(e);t<0||(this._unseed(),e.ctrlKey||e.metaKey?this._toggle(t):e.shiftKey?this._range(t):this._single(t))}),r.listen(this.content,"mouseover",e=>{for(let t=e.target;null!==t&&t!==this.content;t=t.parentElement)if(t.scrollWidth>t.clientWidth)return void tS.titleIfCut(t)}),r.listen(this.content,"dblclick",e=>{let t=this.indexOf(e);t>=0&&this.activate(t)});const o=e.contextActions;o&&r.listen(this.content,"contextmenu",t=>{var n,i,r;let s=this.indexOf(t);if(s<0)return;this._selected.peek().has(s)?this._write(this._selected.peek(),s):this._single(s);let a=o(this.items[s],s),l=null==(r=e.contextGroups)?void 0:r.call(e,this.items[s],s);(0!==a.length||0!==(null!=l?l:[]).length)&&(t.preventDefault(),t.stopPropagation(),na(a,{groups:l}).show({x:null!=(n=t.clientX)?n:0,y:null!=(i=t.clientY)?i:0}))});const s=new ResizeObserver(()=>this._renderVisible());s.observe(this.root),this.own(()=>{s.disconnect(),0!==this._retry&&cancelAnimationFrame(this._retry)}),this.effect(()=>{let e=this._source.value.value;(0,P.untracked)(()=>this._apply(e))}),this.effect(()=>{let e=this.selectedIndex.value,t=this._multiWrite;this._multiWrite=void 0,t!==e&&(this._anchor=e,this._selected.value=e<0?nm:new Set([e]))}),this.effect(()=>{let e=this.selectedIndex.value,t=this._selected.value;e<0?this.root.removeAttribute("aria-activedescendant"):this.root.setAttribute("aria-activedescendant",this._idPrefix+e);var n=!0,i=!1,r=void 0;try{for(var o,s=this._rows[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=nh(o.value,2),i=n[0],r=n[1];this._mark(r.el,i,t,e)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}})}}class nb extends nv{createRow(){let e=document.createElement("div");return e.className="u2-list-row",e.setAttribute("role",this._rowRole),e.style.height=`${this.itemHeight}px`,e}fillRow(e,t){this.placeRow(e,t),e.replaceChildren(this._renderItem(this.items[t],t,e))}placeRow(e,t){return e.setAttribute("aria-posinset",String(t+1)),e.setAttribute("aria-setsize",String(this.items.length)),!0}patchRow(e,t){let n=e.children[0];return void 0!==this._update&&void 0!==n&&!1!==this._update(this.items[t],t,e,n)}rowKey(e,t){if("Enter"!==e.key&&"Delete"!==e.key)return!1;let n="Enter"===e.key?this._onEnter:this._onDelete;return n&&e.preventDefault(),null==n||n(this.items[t],t),!0}activate(e){var t;null==(t=this._onEnter)||t.call(this,this.items[e],e)}setSelected(e,t){super.setSelected(e,t);var n=!0,i=!1,r=void 0;try{for(var o,s=Array.from(e.querySelectorAll(".u2-row-actions button"))[Symbol.iterator]();!(n=(o=s.next()).done);n=!0)o.value.tabIndex=t?0:-1}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}}constructor(e){var t,n;super(nc(nd({},e),{liveItems:null!=(t=e.liveItems)&&t}),{host:"u2-list",u2:"list",role:"listbox"}),this._rowRole=null!=(n=e.rowRole)?n:"option",this._renderItem=e.render,this._update=e.update,this._onEnter=e.onEnter,this._onDelete=e.onDelete}}function ny(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function n_(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function nw(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let nx="u2-input-edit-option",nk="u2-input-root";function nS(e){return"string"==typeof e?e:void 0}class nC extends H{static isEmpty(e){if(es(e)||Array.isArray(e)&&0===e.length)return!0;if("object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return(t===Object.prototype||null===t)&&0===Object.keys(e).length}static bindOwned(e,t){let n=P.Scope.ambient,i=t.owner,r=i.bind(e);if(void 0===n||n===i)return r;let o=n.bind(e);return(...e)=>n.isDisposed?r(...e):o(...e)}static itemsState(e,t){let n=!t&&e.length>P.ITEMS_CAP;return{count:e.length,list:n?e.slice(0,P.ITEMS_CAP):e,truncated:n}}static specValue(e,t){return e instanceof P.Signal?{bind:e,readOnly:null!=t?t:!(0,P.isWritableSignal)(e)||void 0}:{value:e,readOnly:t}}_watchChanges(){if(this._watching)return;this._watching=!0;let e=!0;this.effect(()=>{let t=this.value,n=this._followed,i=this._system;if(this._followed=void 0,this._system=void 0,e)e=!1;else if(void 0===n||!Object.is(n.value,t)){let e=(void 0===i||!Object.is(i.value,t))&&this._byUser();(0,P.untracked)(()=>{var n,i;null==(n=this._onChanged)||n.call(this,t,this),e&&(null==(i=this._onUserInput)||i.call(this,t,this)),this.fireEvent("change",t),e&&this.fireEvent("userInput",t)})}})}_byUser(){let e=globalThis.event;if(nC.isSystemWrite||void 0===e||!(e.target instanceof Element))return!1;for(let n=e.target;null!==n;){var t;if(this.root.contains(n)||this._inputBox.contains(n))return!0;let e=null==(t=n.closest("[data-u2-owner-id]"))?void 0:t.dataset.u2OwnerId;if(void 0===e)break;if(e===this.root.id)return!0;n=document.getElementById(e)}return!1}onEvent(e){let t=void 0===e?null:e;return(null===t||"change"===t||"userInput"===t)&&this._watchChanges(),super.onEvent(t)}follow(e){return this.effect(()=>{let t=e();Object.is(t,this.peek())||(this._followed={value:t},nC.system(()=>this.value=t))})}static system(e){nC._systemWrites++;try{return e()}finally{nC._systemWrites--}}systemWrite(e){this._system={value:e},nC.system(()=>this.value=e)}static get isSystemWrite(){return nC._systemWrites>0}get value(){return this.signal.value}set value(e){this.signal.value=e}peek(){return this.signal.peek()}get unreadable(){return!1}get nullable(){var e;return null==(e=this.options.nullable)||e}get label(){var e,t,n;return null!=(e=null!=(t=null==(n=this._labelEl)?void 0:n.textContent)?t:nS(this.options.label))?e:""}set label(e){if(this._labelEl)this._labelEl.textContent=e;else if(this.options.inline)this.focusTarget.setAttribute("aria-label",e);else{this._labelEl=tP(tT("label","u2-label","u2-input-label"),e),this._labelEl.dataset.u2Part="label",this._labelEl.id=`${this.rootId}-label`;let t=this.focusTarget;t.matches("input, textarea, select, button")?this._labelEl.setAttribute("for",t.id):t.setAttribute("aria-labelledby",this._labelEl.id),this.root.prepend(this._labelEl),this._bindTooltip()}}get focusTarget(){var e;let t=this._editor;return t.matches("input, textarea, select")||t.hasAttribute("role")?t:null!=(e=t.querySelector('input, textarea, select, [role="combobox"], [role="listbox"], [role="slider"], [role="spinbutton"], [role="switch"], [contenteditable="true"], [tabindex]:not([tabindex="-1"])'))?e:t}getState(){var e;let t=this._validity.peek(),n=this._placeholder();return n_(nw(n_({},super.getState()),{value:null!=(e=H.jsonValue(this.peek()))?e:null,text:this.displayText(),valid:null===t,error:this._error.textContent||null,readOnly:this._readOnly,required:!0===this._required.peek()}),n?{placeholder:n}:{})}get visible(){return super.visible}set visible(e){super.visible=e,this._shown.value=e}get validates(){return nC._layoutVersion(),this._shown.value&&null===this._offReason.value&&null===this.root.closest("[hidden], [inert]")}static _layoutVersion(){if(void 0===nC._layout){let e=nC._layout=(0,P.signal)(0);"u">typeof MutationObserver&&"u">typeof document&&new MutationObserver(t=>{t.some(e=>nC._holdsInput(e.target))&&e.value++}).observe(document,{attributes:!0,attributeFilter:["hidden","inert"],subtree:!0})}return nC._layout.value}static _holdsInput(e){var t,n;return(null==(t=e.classList)?void 0:t.contains(nk))===!0||(null==(n=e.querySelector)?void 0:n.call(e,`.${nk}`))!=null}get loading(){return this._loading}set loading(e){var t;if(e!==this._loading){if(this._loading=e,null==(t=this._spinnerSoon)||t.call(this),this._spinnerSoon=void 0,!e){this.root.removeAttribute("aria-busy"),void 0!==this._spinner&&(this._spinner.hidden=!0);return}this.root.setAttribute("aria-busy","true"),this._spinnerSoon=this.scope.setTimeout(()=>{this._spinnerSoon=void 0,void 0===this._spinner&&(this._spinner=t$("","u2-input-loading"),this._spinner.append(t$("","u2-loader-spinner")),this._inputBox.append(this._spinner)),this._spinner.hidden=!1},nC.loadingGraceMs)}}get readOnly(){return this._readOnly}set readOnly(e){this._readOnly=e,this.root.classList.toggle("u2-input-readonly",e),e?this.focusTarget.setAttribute("aria-readonly","true"):this.focusTarget.removeAttribute("aria-readonly");var t=!0,n=!1,i=void 0;try{for(var r,o=this._optionsRail.querySelectorAll(`:scope > .${nx}`)[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;nC._offWhileReadOnly(t,e)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}var s=!0,a=!1,l=void 0;try{for(var u,d=this.root.querySelectorAll("input, textarea")[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){let t=u.value;nC._typed(t)&&(t.readOnly=e)}}catch(e){a=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(a)throw l}}if(e&&!this._guarded){this._guarded=!0;for(let e=0,t=["keydown","mousedown","click","input","change"];e<t.length;e++){let n=t[e];this.scope.listen(this.root,n,e=>this._guard(e),{capture:!0})}this.scope.listen(this.root,"wheel",e=>this._guard(e),{capture:!0,passive:!0})}}get required(){return!0===this._required.peek()}set required(e){this._required.value=e,this.root.classList.toggle("u2-input-required",e),e?this.focusTarget.setAttribute("aria-required","true"):this.focusTarget.removeAttribute("aria-required"),e&&this._wireTouch()}_wireTouch(){if(this._touchWired)return;this._touchWired=!0;for(let e=0,t=["input","change"];e<t.length;e++){let n=t[e];this.scope.listen(this.root,n,()=>this._touched.value=!0)}let e=!0;this.effect(()=>{this.value,e?e=!1:this._byUser()&&(this._touched.value=!0)});for(let e=0,t=["keydown","pointerdown"];e<t.length;e++){let n=t[e];this.scope.listen(this.root,n,()=>this._engaged=!0,{capture:!0})}this.scope.listen(this.root,"focusout",e=>{this._engaged&&this._touchLeavingFor(e.relatedTarget)})}_touchLeavingFor(e){let t=e instanceof Element?e.closest("button"):null;if(null===t){this._touched.value=!0;return}let n=()=>{t.removeEventListener("click",n),t.removeEventListener("blur",n),this._touched.value=!0};t.addEventListener("click",n),t.addEventListener("blur",n)}reset(e){this._touched.value=!1,this._engaged=!1,Object.is(e,this.peek())||(this._followed={value:e},nC.system(()=>this.value=e)),this.resetEditor()}resetEditor(){}touch(){this._touched.value=!0}focus(e){var t;let n=this.focusTarget,i=n.matches(nC._FOCUSABLE)?n:null!=(t=n.querySelector(nC._FOCUSABLE))?t:n;i.focus(),(null==e?void 0:e.select)&&nC._typed(i)&&i.select()}static _offWhileReadOnly(e,t){for(let n=0,i=[e,...e.querySelectorAll("button")];n<i.length;n++){let e=i[n];tA.of(e)===(t?null:nC.READ_ONLY)&&tA.apply(e,t?nC.READ_ONLY:null)}}static _typed(e){let t=null==e?void 0:e.tagName;return"TEXTAREA"===t||"INPUT"===t&&!nC._UNTYPED.includes(e.type)}_guard(e){if(!this._readOnly||this._freeOption(e.target))return;let t=nC._typed(e.target),n=e.key;("keydown"===e.type?"Tab"===n||"Escape"===n||"Enter"===n||t&&("ArrowUp"!==n&&"ArrowDown"!==n||"TEXTAREA"===e.target.tagName):t&&"wheel"!==e.type)||("wheel"!==e.type&&e.preventDefault(),e.stopImmediatePropagation())}_freeOption(e){var t;let n=null==e||null==(t=e.closest)?void 0:t.call(e,".u2-input-options > *");return null!=n&&n.parentElement.parentElement===this._inputBox&&!n.classList.contains(nx)}displayText(){var e;let t=this.focusTarget;if("SELECT"===t.tagName){let e=[...t.querySelectorAll("option")].find(e=>e.value===t.value);return void 0===e?"":H.text(e)}return"INPUT"===t.tagName&&["checkbox","radio"].includes(t.type)?String(t.checked):"INPUT"===t.tagName||"TEXTAREA"===t.tagName?t.value:null!=(e=t.getAttribute("aria-checked"))?e:H.text(this._editor)}accessibleLabel(){return(void 0===this._labelEl?"":H.text(this._labelEl))||H.labelOf(this.focusTarget)||super.accessibleLabel()||this._placeholder()}_placeholder(){let e=this.focusTarget;return e.placeholder||e.getAttribute("placeholder")||void 0}getWidgetStatus(){let e=super.getWidgetStatus();return e.parts={editor:this._editor,error:this._error},this._labelEl&&(e.parts.label=this._labelEl),null!==this._optionsRail.parentElement&&(e.parts.options=this._optionsRail),e}get tooltipText(){return this._tooltip}set tooltipText(e){this._tooltip=null!=e?e:"",this._tooltip?this.focusTarget.setAttribute("aria-description",this._tooltip):this.focusTarget.removeAttribute("aria-description"),this._bindTooltip()}_bindTooltip(){var e;this._tooltip&&this._tip(null!=(e=this._labelEl)?e:this.root)}_tip(e){this._tooltipOn.has(e)||(this._tooltipOn.add(e),tS.bind(e,()=>{var t;return null!=(t=this._offReason.peek())?t:e===this.root&&this._labelEl?"":this._tooltip},{owner:this.scope}))}get disabled(){return this._offReason.peek()}set disabled(e){let t=tA.now(e);this._offReason.value=t,this.root.classList.toggle("u2-input-disabled",null!==t),tA.apply(this.root,t),null!==t&&this._tip(this.root);let n=this.root.querySelectorAll("input, textarea, button, select");for(let e=0;e<n.length;e++)null===t?n[e].removeAttribute("disabled"):n[e].setAttribute("disabled","")}addValidator(e){this._validators.push(e),this._wireTouch(),(0,P.untracked)(()=>{this._validate(this.peek()),this._validatorCount.value++})}revalidate(){(0,P.untracked)(()=>this._validate(this.peek()))}get box(){return this._inputBox}liveOption(e,t,n){var i;if(void 0!==t){if(!(t instanceof P.Signal))return void n(t);(null!=(i=this._liveBinds)?i:this._liveBinds=new Map).set(e,t),this.effect(()=>{let e=t.value;void 0!==e&&n(e)})}}bindStep(e){var t,n;return""===e||"value"===e?this.signal:null!=(t=null==(n=this._liveBinds)?void 0:n.get(e))?t:super.bindStep(e)}bindProps(){let e=super.bindProps(),t=null!=(a=null==(u=this.componentMeta)?void 0:u.props)?a:[],n=t.findIndex(e=>"value"===e.name);if(n>=0&&!e.some(e=>"value"===e.name)){let i=new Set(t.slice(n+1).map(e=>e.name)),r=e.findIndex(e=>i.has(e.name));e.splice(r<0?e.length:r,0,nw(n_({},t[n]),{writable:(0,P.isWritableSignal)(this.signal),default:!0}))}var i=!0,r=!1,o=void 0;try{for(var s,a,l,u,d,c=(null!=(l=this._liveBinds)?l:[])[Symbol.iterator]();!(i=(d=c.next()).done);i=!0){let t=(s=d.value,function(e){if(Array.isArray(e))return e}(s)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(s)||function(e){if(e){if("string"==typeof e)return ny(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ny(e,2)}}(s)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),n=t[0],i=t[1];e.some(e=>e.name===n)||e.push({name:n,type:Y(i.peek()),writable:!1})}}catch(e){r=!0,o=e}finally{try{i||null==c.return||c.return()}finally{if(r)throw o}}return e}createClearButton(e,t){let n=document.createElement("button");return n.type="button",n.className="u2-input-clear",n.textContent="✕",n.setAttribute("aria-label",void 0===t?"Clear":t),this.scope.listen(n,"click",e),n}isEmptyValue(e){return!this.unreadable&&nC.isEmpty(e)}get emptyMessage(){return eo}addOptions(e,t){this.addRail(e,t)}addRail(e,t){(null==t?void 0:t.edits)&&(e.classList.add(nx),this._readOnly&&nC._offWhileReadOnly(e,!0)),this._optionsRail.append(e),null===this._optionsRail.parentElement&&this._inputBox.append(this._optionsRail)}refreshDisabled(){let e=this._offReason.peek();null!==e&&(this.disabled=e),this._readOnly&&(this.readOnly=!0)}_validate(e){let t=this.isEmptyValue(e);if(this.root.classList.toggle("u2-input-empty",t),t&&(null!=(s=this._required.value)?s:!1===this.options.nullable)){this._validity.value=this.emptyMessage;return}let n=null;var i=!0,r=!1,o=void 0;try{for(var s,a,l=this._validators[Symbol.iterator]();!(i=(a=l.next()).done)&&!(n=(0,a.value)(e));i=!0);}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}this._validity.value=n||null}_showValidity(e){this._editor.classList.toggle("u2-invalid",null!==e),this._error.textContent=null!=e?e:"";let t=this.focusTarget;null===e?(this._editor.removeAttribute("title"),t.removeAttribute("aria-invalid"),t.removeAttribute("aria-describedby")):(this._editor.title=e,t.setAttribute("aria-invalid","true"),t.setAttribute("aria-describedby",this._error.id))}constructor(e,t){var n,i;super(),this._validators=[],this._validatorCount=(0,P.signal)(0),this._validity=(0,P.signal)(null),this._error=t$("","u2-input-error"),this._tooltip="",this._tooltipOn=new Set,this._offReason=(0,P.signal)(null),this._shown=(0,P.signal)(!0),this._required=(0,P.signal)(void 0),this._touched=(0,P.signal)(!1),this._readOnly=!1,this._loading=!1,this._guarded=!1,this._touchWired=!1,this._engaged=!1,this._watching=!1,this.options=e,this.signal=null!=(n=e.bind)?n:(0,P.signal)(null!=(i=e.value)?i:t),this.validity=this._validity,this.touched=this._touched,this.error=(0,P.computed)(()=>this._touched.value?this._validity.value:null),void 0!==e.name?this.name=e.name:this.deriveName(nS(e.label)),this.root.classList.add(nk),e.inline&&this.root.classList.add("u2-input-inline"),e.fill&&this.root.classList.add("u2-input-fill"),this._inputBox=tR([],"u2-input-box"),this._optionsRail=tR([],"u2-input-options"),this._optionsRail.dataset.u2Part="options",this._error.dataset.u2Part="error",this._editor=this.build(()=>this.createEditor()),this._editor.classList.add("u2-input-editor"),this._editor.dataset.u2Part="editor",void 0!==e.width&&(this._editor.style.width="number"==typeof e.width?`${e.width}px`:e.width,this._editor.style.flex="0 1 auto",this._editor.style.minWidth="0",this._editor.style.maxWidth="none"),this._inputBox.prepend(this._editor),this.root.append(this._inputBox,this._error);const r=this.focusTarget;r.id||(r.id=`${this.rootId}-editor`),this._error.id=`${this.rootId}-error`,e.inline&&void 0!==e.name&&r.setAttribute("aria-label",e.name),this.liveOption("label",e.label,e=>this.label=e),this.liveOption("tooltipText",e.tooltipText,e=>this.tooltipText=e),this.liveOption("postfix",e.postfix,e=>{if(!this._postfixEl){if(!e)return;this.addRail(this._postfixEl=t$("","u2-input-postfix"))}this._postfixEl.textContent=e}),this.liveOption("disabled",e.disabled,e=>{let t=tA.now(e);(null!==t||null!==this._offReason.peek())&&(this.disabled=t)}),this.liveOption("visible",e.visible,e=>this.visible=e),this.liveOption("readOnly",e.readOnly,e=>this.readOnly=e),void 0!==e.readOnly||(0,P.isWritableSignal)(this.signal)||(P.Usage.report("bind-readonly",`${this.constructor.name} is bound to a signal it cannot write (a computed): every edit would fail. Bind a \`signal\` or a \`lens(…)\` to edit it; to show the value, pass \`readOnly: true\`.`),this.readOnly=!0),this.liveOption("required",e.required,e=>this.required=e),this.liveOption("loading",e.loading,e=>this.loading=e),!1===e.nullable&&this._wireTouch(),this.effect(()=>{this._validatorCount.value,this._validate(this.value)}),this.effect(()=>this._showValidity(this.error.value)),e.onChanged&&(this._onChanged=nC.bindOwned(e.onChanged,{owner:this.scope})),e.onInput&&(this._onUserInput=nC.bindOwned(e.onInput,{owner:this.scope})),(e.onChanged||e.onInput)&&this._watchChanges();const o=e.onEnter,s=e.onEscape;if(o||s){const e={Enter:o&&nC.bindOwned(o,{owner:this.scope}),Escape:s&&nC.bindOwned(s,{owner:this.scope})};this.scope.listen(r,"keydown",t=>{let n=e[t.key];void 0===n||t.isComposing||!1===n(t,this)||(t.preventDefault(),t.stopPropagation())})}}}function nA(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function nO(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function nE(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return nA(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nA(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}nC._systemWrites=0,nC.loadingGraceMs=150,nC._FOCUSABLE="input, textarea, select, button, [tabindex]",nC.READ_ONLY="Read-only",nC._UNTYPED=["checkbox","radio","range","button","submit","reset","color","file","image"];let nT=0;class nP extends H{setItems(e){this._source.value=Array.isArray(e)?(0,P.signal)(e):e}scrollToIndex(e){let t=Math.floor(e/this.columns.peek())*this._options.cellHeight,n=t+this._options.cellHeight-this.root.clientHeight;t<this.root.scrollTop?this.root.scrollTop=t:n>this.root.scrollTop&&(this.root.scrollTop=n),this._renderVisible()}get renderedCount(){return this._cells.size}cellAt(e){var t,n;return null!=(t=null==(n=this._cells.get(e))?void 0:n.el)?t:null}refresh(e){var t=!0,n=!1,i=void 0;try{for(var r,o=this._cells[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=nE(r.value,2),n=t[0],i=t[1];(void 0===e||i.key===e)&&this._fill(i,n)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}}getItems(e){let t=this.selectedIndex.peek();return nC.itemsState(this._items.map((e,n)=>({key:this._keyAt(n),label:this._label(n),index:n,selected:n===t,rendered:this._cells.has(n)})),null==e?void 0:e.all)}revealItem(e){var t;return(t=function*(){let t=this._find(e);return t<0?null:(this.scrollToIndex(t),yield new Promise(e=>{setTimeout(e,100),"function"==typeof requestAnimationFrame&&requestAnimationFrame(()=>e())}),this._cells.has(t)||this._renderVisible(),this.cellAt(t))},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){nO(o,i,r,s,a,"next",e)}function a(e){nO(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}onKeyDown(e){let t,n=this._items.length-1;if(n<0)return;let i=this.columns.peek(),r=Math.max(1,Math.floor(this.root.clientHeight/this._options.cellHeight)-1)*i,o=this.selectedIndex.peek();switch(e.key){case"ArrowRight":t=o+1;break;case"ArrowLeft":t=o<0?n:o-1;break;case"ArrowDown":t=o+i;break;case"ArrowUp":t=o<0?n:o-i;break;case"PageDown":t=o+r;break;case"PageUp":t=o<0?n:o-r;break;case"Home":t=0;break;case"End":t=n;break;case"Enter":case" ":if(o<0)return;e.preventDefault(),this._activate(o);return;default:return}e.preventDefault(),this.selectedIndex.value=Math.max(0,Math.min(n,t)),this.scrollToIndex(this.selectedIndex.value)}_measure(){this._width.value=this.root.clientWidth}_activate(e){var t,n;this.selectedIndex.value=e,null==(t=(n=this._options).onActivate)||t.call(n,this._items[e],e)}_layout(e){let t=Math.ceil(this._items.length/e);this._content.style.height=`${t*this._options.cellHeight}px`,this.selectedIndex.peek()>=this._items.length&&(this.selectedIndex.value=-1);let n=new Map;var i=!0,r=!1,o=void 0;try{for(var s,a=this._cells.values()[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;n.has(e.key)?this._release(e):n.set(e.key,e)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}this._cells.clear();let l=this._window();for(let e=l.start;e<l.end;e++){let t=n.get(this._keyAt(e));void 0!==t&&(n.delete(t.key),this._cells.set(e,t),t.item===this._items[e]?this._place(t.el,e):this._fill(t,e))}var u=!0,d=!1,c=void 0;try{for(var h,p=n.values()[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){let e=h.value;this._release(e)}}catch(e){d=!0,c=e}finally{try{u||null==p.return||p.return()}finally{if(d)throw c}}for(let e=l.start;e<l.end;e++)this._cells.has(e)||this._insertCell(e);this._rendered=l}_renderVisible(){let e=this._window();var t=!0,n=!1,i=void 0;try{for(var r,o=np(this._rendered,e)[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value;for(let t=e.start;t<e.end;t++)this._releaseCell(t)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}var s=!0,a=!1,l=void 0;try{for(var u,d=np(e,this._rendered)[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){let e=u.value;for(let t=e.start;t<e.end;t++)this._insertCell(t)}}catch(e){a=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(a)throw l}}this._rendered=e}_window(){if(0===this.root.clientWidth)return{start:0,end:0};let e=this._options.cellHeight,t=this.columns.peek(),n=this._items.length,i=Math.floor(this.root.scrollTop/e),r=Math.ceil(this.root.clientHeight/e),o=e=>Math.max(0,Math.min(n,e));return{start:o((i-2)*t),end:o((i+r+2)*t)}}_identity(e){if(void 0!==this._options.keyOf)return this._options.keyOf(e);if("string"==typeof e||"number"==typeof e)return String(e);if(null===e||"object"!=typeof e)return;let t=e.name,n=e.id;return"string"==typeof t?t:"string"==typeof n?n:void 0}_keyAt(e){var t;return null!=(t=this._identity(this._items[e]))?t:`#${e}`}_label(e){if(void 0!==this._options.labelOf)return this._options.labelOf(this._items[e]);let t=this.cellAt(e);return(null===t?"":H.text(t)||t.title)||this._keyAt(e)}_find(e){var t;let n=this._items.length;for(let t=0;t<n;t++)if(this._keyAt(t)===e)return t;let i=e.trim().toLowerCase(),r=[];for(let e=0;e<n;e++)this._label(e).toLowerCase()===i&&r.push(e);if(r.length>1)throw Error(`u2: ${r.length} items match "${e}": `+r.map(e=>this._keyAt(e)).join(", "));return null!=(t=r[0])?t:-1}_insertCell(e){var t;let n={el:null!=(t=this._pool.pop())?t:this._createCell(),key:"",item:this._items[e],scope:this._cellScope()};this._cells.set(e,n),this._render(n,e),this._content.append(n.el)}_fill(e,t){e.scope.dispose(),e.scope=this._cellScope(),this._render(e,t)}_render(e,t){e.item=this._items[t],e.key=this._keyAt(t);let n=e.el;n.className="u2-grid-cell",n.removeAttribute("title"),n.dataset.u2Item=e.key,this._place(n,t);let i=(0,P.untracked)(()=>e.scope.run(()=>this._options.render(e.item,t,n)));n.replaceChildren(...void 0===i?[]:[i])}_place(e,t){let n=this.columns.peek();e.style.left=`${t%n*100/n}%`,e.style.width=`${100/n}%`,e.style.top=`${Math.floor(t/n)*this._options.cellHeight}px`,e.id=this._idPrefix+t,e.dataset.index=String(t),e.setAttribute("aria-posinset",String(t+1)),e.setAttribute("aria-setsize",String(this._items.length)),this._setSelected(e,this.selectedIndex.peek()===t)}_cellScope(){return new P.Scope(this.scope,{label:"row",lazy:!0})}_releaseCell(e){let t=this._cells.get(e);this._cells.delete(e),this._release(t)}_release(e){e.scope.dispose(),e.el.remove(),this._pool.push(e.el)}_createCell(){let e=document.createElement("div");return e.setAttribute("role","option"),e.style.height=`${this._options.cellHeight}px`,e}_setSelected(e,t){e.classList.toggle("u2-grid-cell-selected",t),e.setAttribute("aria-selected",String(t))}constructor(e){super(),this.selectedIndex=(0,P.signal)(-1),this._width=(0,P.signal)(0),this._content=document.createElement("div"),this._source=(0,P.signal)((0,P.signal)([])),this._cells=new Map,this._pool=[],this._idPrefix=`u2-grid-${++nT}-cell-`,this._items=[],this._rendered={start:0,end:0},this._options=e,this.columns=(0,P.computed)(()=>Math.max(1,Math.floor(this._width.value/e.cellWidth))),this.root.classList.add("u2-grid"),this.root.tabIndex=0,this.root.setAttribute("data-u2","grid"),this.root.setAttribute("role","listbox"),this._content.className="u2-grid-content",this.root.append(this._content),this.scope.listen(this.root,"scroll",()=>{this._measure(),this._renderVisible()}),this.scope.listen(this.root,"keydown",e=>this.onKeyDown(e)),this.scope.listen(this._content,"click",e=>{let t=e.target.closest(".u2-grid-cell");t&&this._activate(Number(t.dataset.index))});const t=new ResizeObserver(()=>{this._measure(),this._renderVisible()});t.observe(this.root),this.own(()=>t.disconnect()),this._measure(),this.effect(()=>{let e=this._source.value.value,t=this.columns.value;(0,P.untracked)(()=>{let n=this.selectedIndex.peek(),i=n>=0&&n<this._items.length?this._identity(this._items[n]):void 0;this._items=e,this._layout(t),void 0!==i&&(this.selectedIndex.value=this._items.findIndex(e=>this._identity(e)===i))})}),this.effect(()=>{let e=this.selectedIndex.value;e<0?this.root.removeAttribute("aria-activedescendant"):this.root.setAttribute("aria-activedescendant",this._idPrefix+e);var t=!0,n=!1,i=void 0;try{for(var r,o=this._cells[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=nE(r.value,2),n=t[0],i=t[1];this._setSelected(i.el,n===e)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}})}}function nN(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function nI(e,t,n,i){let r=new P.Scope(e,{label:t,lazy:!0});return{el:r.build(i),scope:r,item:n}}function nM(e){e.scope.dispose(),e.el.remove()}function nL(e,t,n,i,r){let o,s=void 0===r?{}:r,a=function(e){let t=P.Scope.ambient;if(!t)throw Error(`u2: ${e}() needs an owner — build under \`owner.build(…)\` or \`component((self) => …)\`; after an \`await\`, inside \`owner.task(async (t) => … t.build(…))\``);return t}("each"),l=t instanceof P.Signal?()=>t.value:t,u=new Map,d=new Set;a.effect(()=>{let t=l();(0,P.untracked)(()=>(t=>{let r=new Map;for(let e=0;e<t.length;e++){let o=t[e],l=n(o,e);if(r.has(l)){d.has(l)||(d.add(l),console.warn(`u2: each(): duplicate key "${l}"`));let e=2;for(;r.has(`${l}#${e}`);)e++;l=`${l}#${e}`}let c=u.get(l);if(void 0!==c&&c.item!==o){let t=c;void 0!==s.update&&!1!==t.scope.build(()=>s.update(t.el,o,e))?t.item=o:(nM(t),c=void 0)}void 0===c&&void 0===(c=nI(a,"item",o,()=>i(o,e))).el.dataset.u2Item&&(c.el.dataset.u2Item=l),r.set(l,c)}var l=!0,c=!1,h=void 0;try{for(var p,f,m=u[Symbol.iterator]();!(l=(f=m.next()).done);l=!0){let e=(p=f.value,function(e){if(Array.isArray(e))return e}(p)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(p)||function(e){if(e){if("string"==typeof e)return nN(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nN(e,2)}}(p)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),t=e[0],n=e[1];r.get(t)!==n&&nM(n)}}catch(e){c=!0,h=e}finally{try{l||null==m.return||m.return()}finally{if(c)throw h}}u=r,t.length>0&&void 0!==o&&(nM(o),o=void 0);let g=document.activeElement,v=e.firstChild;var b=!0,y=!1,_=void 0;try{for(var w,x=r.values()[Symbol.iterator]();!(b=(w=x.next()).done);b=!0){let t=w.value.el;if(t===v)v=v.nextSibling;else if(t.parentNode===e&&t.contains(g)){let n=t.nextSibling;for(;v!==t;){let t=v;v=t.nextSibling,e.insertBefore(t,n)}v=t.nextSibling}else e.insertBefore(t,v)}}catch(e){y=!0,_=e}finally{try{b||null==x.return||x.return()}finally{if(y)throw _}}0===t.length&&void 0===o&&void 0!==s.empty&&(o=nI(a,"empty",void 0,s.empty),e.append(o.el))})(t))})}function nR(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function nj(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}class nD extends H{get value(){return this.signal.value}set value(e){this.signal.value=e}peek(){return this.signal.peek()}bindStep(e){return""===e?this.signal:super.bindStep(e)}focus(){this._input.focus()}getState(){var e,t;let n=this._input.placeholder;return nj((e=nj({},super.getState()),t=t={value:this.peek(),text:this._input.value,open:this._open.peek(),busy:"loading"===this._view.peek().kind},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e),n?{placeholder:n}:{})}getItems(e){let t="function"==typeof this._options.items?this._lastItems():this._options.items,n=new Set(this._shown.peek());return nC.itemsState(t.map((e,t)=>({key:e,label:e,index:t,selected:e===this.peek(),rendered:n.has(e)})),null==e?void 0:e.all)}revealItem(e){var t,n=this,i=()=>super.revealItem;return(t=function*(){this._all.value=!0,this._source&&this._source.query(""),this._openPopup();for(let e=0;e<50&&"loading"===this._view.peek().kind;e++)yield new Promise(e=>setTimeout(e,20));return i().call(n,e)},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){nR(o,i,r,s,a,"next",e)}function a(e){nR(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}accessibleLabel(){var e,t;return null!=(e=null!=(t=super.accessibleLabel())?t:H.labelOf(this._input))?e:this._input.placeholder||void 0}_lastItems(){let e=this._view.peek();return"ready"===e.kind?e.items:[]}_send(e){let t=this._machine.peek();switch(e.type){case"focus":"idle"===t&&(this._machine.value="focused");break;case"blur":this._dismiss(),this._machine.value="idle";break;case"input":this._activeIndex.value=-1,this._all.value=!1,this._refresh(),this._openPopup();break;case"arrowDown":if("open"===t){this._move(1);break}this._refresh(),this._openPopup();break;case"arrowUp":"open"===t&&this._move(-1);break;case"enter":"open"===t&&this._commit(this._activeIndex.peek());break;case"escape":"open"===t?this._dismiss():this.value="";break;case"tab":case"dismiss":this._dismiss();break;case"select":this._commit(e.index)}}_openPopup(){this._open.peek()||(this._machine.value="open",this._open.value=!0,this._closeOverlay=tx.show(this._input,this._popup,{owner:this.scope}))}_dismiss(){if(!this._open.peek())return;this._open.value=!1,this._all.value=!1,this._activeIndex.value=-1,"open"===this._machine.peek()&&(this._machine.value="focused");let e=this._closeOverlay;this._closeOverlay=void 0,e&&e()}_refresh(){this._source&&this._source.query(this.peek())}_move(e){let t=this._shown.peek().length;0!==t&&(this._activeIndex.value=Math.min(Math.max(this._activeIndex.peek()+e,0),t-1))}_commit(e){let t=this._shown.peek();e<0||e>=t.length||(this.value=t[e],this._dismiss(),this._input.focus())}_onKeyDown(e){let t=this._open.peek(),n="Enter"===e.key?this._options.onEnter:"Escape"===e.key?this._options.onEscape:void 0;if(void 0!==n&&!t&&!e.isComposing){e.preventDefault(),e.stopPropagation(),n(e,this);return}switch(e.key){case"ArrowDown":e.preventDefault(),this._send({type:"arrowDown"});break;case"ArrowUp":e.preventDefault(),this._send({type:"arrowUp"});break;case"Enter":t&&e.preventDefault(),this._send({type:"enter"});break;case"Escape":this._send({type:"escape"});break;case"Tab":this._send({type:"tab"})}}_onPopupPointerDown(e){let t=e.target,n=t.closest(".u2-combobox-option");if(n){e.preventDefault(),this._send({type:"select",index:[...this._list.children].indexOf(n)});return}t.closest(".u2-combobox-retry")&&(e.preventDefault(),this._source&&this._source.retry())}_renderStatus(){let e=this._status,t=this._view.value;if(e.textContent="",e.className="u2-combobox-status",e.hidden=!this._open.value||"ready"===t.kind,e.hidden)return;if("error"===t.kind){e.className="u2-combobox-error",e.textContent=t.message;let n=document.createElement("button");n.className="u2-combobox-retry",n.type="button",n.textContent="Retry",e.append(n);return}let n="empty"===t.kind;e.className=n?"u2-combobox-empty":"u2-combobox-loading",e.textContent=n?"No matches":"Loading…"}_applyActive(){let e=this._shown.value.length,t=this._activeIndex.value,n=this._list.children;for(let i=0;i<e;i++)n[i].classList.toggle("u2-combobox-option-active",i===t),n[i].setAttribute("aria-selected",i===t?"true":"false");let i=t>=0&&t<e?n[t]:void 0;i?(this._input.setAttribute("aria-activedescendant",i.id),i.scrollIntoView({block:"nearest"})):this._input.removeAttribute("aria-activedescendant")}_option(e){let t=document.createElement("div");t.className="u2-combobox-option",t.id=`${this._id}-opt-${++this._optionSeq}`,t.setAttribute("role","option"),t.setAttribute("aria-selected","false");let n=document.createElement("span");return n.dataset.u2Part="item-label",n.textContent=e,t.append(n),t}constructor(e){var t;super(),this.signal=(0,P.signal)(""),this._id=`u2-combobox-${++nD._seq}`,this._input=document.createElement("input"),this._popup=document.createElement("div"),this._list=document.createElement("div"),this._status=document.createElement("div"),this._open=(0,P.signal)(!1),this._all=(0,P.signal)(!1),this._machine=(0,P.signal)("idle"),this._activeIndex=(0,P.signal)(-1),this._optionSeq=0,this._options=e,this.isOpen=this._open,this.machineState=this._machine,this.root.classList.add("u2-combobox"),this.root.dataset.u2="combobox";const n=this._input;if(n.className="u2-combobox-input",n.type="text",n.autocomplete="off",n.placeholder=null!=(t=e.placeholder)?t:"",n.id=`${this._id}-input`,n.setAttribute("role","combobox"),n.setAttribute("aria-autocomplete","list"),n.setAttribute("aria-haspopup","listbox"),n.setAttribute("aria-controls",`${this._id}-listbox`),e.label&&n.setAttribute("aria-label",e.label),this.root.append(n),this._popup.className="u2-combobox-popup",this._popup.id=`${this._id}-listbox`,this._popup.setAttribute("role","listbox"),this._list.className="u2-combobox-options",this._popup.append(this._list,this._status),"function"==typeof e.items){const t=new eh(e.items);this._source=t,this._view=t.state,this.own(()=>t.dispose()),this.effect(()=>{"loading"===t.state.value.kind?this.root.setAttribute("aria-busy","true"):this.root.removeAttribute("aria-busy")})}else{const t=e.items;this._view=(0,P.computed)(()=>{let e=this._all.value?"":this.value.toLowerCase(),n=e?t.filter(t=>t.toLowerCase().includes(e)):t;return n.length>0?{kind:"ready",items:n}:{kind:"empty"}})}this._shown=(0,P.computed)(()=>{let e=this._view.value;return this._open.value&&"ready"===e.kind?e.items:[]}),ed(n,this.signal,{owner:this.scope}),this.scope.listen(n,"input",()=>this._send({type:"input"})),this.scope.listen(n,"focus",()=>this._send({type:"focus"})),this.scope.listen(n,"blur",()=>this._send({type:"blur"})),this.scope.listen(n,"keydown",e=>this._onKeyDown(e)),this.scope.listen(this._popup,"pointerdown",e=>this._onPopupPointerDown(e)),this.scope.listen(this._popup,tb,()=>this._send({type:"dismiss"})),this.effect(()=>n.setAttribute("aria-expanded",String(this._open.value))),this.build(()=>nL(this._list,this._shown,e=>e,e=>this._option(e))),this.effect(()=>this._renderStatus()),this.effect(()=>this._applyActive());let i=!0;this.effect(()=>{let e=this.value;i?i=!1:(0,P.untracked)(()=>this.fireEvent("change",e))})}}nD._seq=0;let n$=e=>nC.isEmpty(e)||"string"==typeof e&&""===e.trim();class nF extends nC{get placeholder(){return this._input.placeholder}set placeholder(e){var t;this._input.placeholder=e,null==(t=this._remeasure)||t.call(this)}isEmptyValue(e){return n$(e)}createEditor(){let e=document.createElement("input");if(this._input=e,e.type=this.options.password?"password":"text",e.autocomplete="off",ed(e,this.signal,{owner:this.scope,commitOn:this.options.commitOn}),this.options.autoResize&&this._autoResize(),this.options.password)return this._passwordEditor();if(!this.options.search)return e;let t=document.createElement("div");t.className="u2-input-search";let n=this.createClearButton(()=>{this.value="",e.focus()});return this.effect(()=>n.hidden=""===this.value),t.append(e,n),t}_passwordEditor(){let e=document.createElement("div");e.className="u2-input-password";let t=document.createElement("button");t.type="button",t.className="u2-input-eye",t.setAttribute("aria-label","Show password");let n=tK("eye");return t.append(n),this.scope.listen(t,"click",()=>{let e="password"===this._input.type;this._input.type=e?"text":"password",n.classList.toggle("fa-eye",!e),n.classList.toggle("fa-eye-slash",e),t.setAttribute("aria-label",e?"Hide password":"Show password")}),e.append(this._input,t),e}_autoResize(){let e=document.createElement("span");e.className="u2-input-measure",e.setAttribute("aria-hidden","true"),this.root.append(e),this._remeasure=()=>{var t,n;let i=this.peek();e.textContent=""===i?this._input.placeholder:i;let r=null!=(t=this.options.minWidth)?t:100,o=null!=(n=this.options.maxWidth)?n:300;this._input.style.width=`${Math.min(Math.max(e.offsetWidth+10,r),o)}px`},this.effect(()=>{this.value,this._remeasure()})}constructor(e){let t=void 0===e?{}:e;super(t,""),this.root.dataset.u2="text-input",this.liveOption("placeholder",t.placeholder,e=>this.placeholder=e)}}class nz extends nC{get placeholder(){return this._area.placeholder}set placeholder(e){this._area.placeholder=e}isEmptyValue(e){return n$(e)}get rows(){return this._area.rows}set rows(e){null==e?this._area.removeAttribute("rows"):this._area.rows=e}createEditor(){let e=document.createElement("textarea");return this._area=e,void 0!==this.options.rows&&(e.rows=this.options.rows),ed(e,this.signal,{owner:this.scope,commitOn:this.options.commitOn}),this.options.autoGrow&&this.effect(()=>this._grow(this.value)),e}_grow(e){let t=this._area;t.isConnected&&(t.style.height="auto",t.style.height=e?`${t.scrollHeight}px`:"")}constructor(e){let t=void 0===e?{}:e;super(t,""),this.root.dataset.u2="text-area",this.liveOption("placeholder",t.placeholder,e=>this.placeholder=e)}}class nq extends nC{getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={checked:!0===this.peek()},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}createEditor(){let e=document.createElement("span");return e.className="u2-input-bool",e.append(this.options.switch?this._createSwitch():this._createCheckbox()),e}_createCheckbox(){let e=document.createElement("input");return e.type="checkbox",e.className="u2-input-checkbox",this.effect(()=>e.checked=!0===this.value),this.scope.listen(e,"change",()=>this.value=e.checked),e}_createSwitch(){let e=document.createElement("span");e.className="u2-input-switch",e.tabIndex=0,e.setAttribute("role","switch");let t=document.createElement("span");return t.className="u2-input-switch-thumb",e.append(t),this.effect(()=>{let t=!0===this.value;e.classList.toggle("u2-input-switch-on",t),e.setAttribute("aria-checked",String(t))}),this.scope.listen(e,"click",()=>this._toggle()),this.scope.listen(e,"keydown",e=>{let t=e.key;(" "===t||"Enter"===t)&&(e.preventDefault(),this._toggle())}),e}_toggle(){null!==this.disabled||this.readOnly||(this.value=!this.peek())}constructor(e){let t=void 0===e?{}:e;super(t,!1),this.root.dataset.u2="bool-input",t.captionAfter&&this.root.classList.add("u2-input-caption-after"),t.switch&&this.scope.listen(this.root,"click",e=>{null!==e.target.closest('[data-u2-part="label"]')&&this._toggle()})}}function nB(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function nG(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let nV=0;class nU extends H{addTab(e){var t;let n=document.createElement("div");n.className="u2-tabs-tab",n.id=`${this._idPrefix}-tab-${e.id}`,n.dataset.id=e.id,n.dataset.u2Item=e.id,n.tabIndex=-1,n.title=null!=(t=e.tooltip)?t:e.title,n.setAttribute("role","tab"),n.setAttribute("aria-selected","false"),n.setAttribute("aria-controls",`${this._idPrefix}-panel-${e.id}`);let i=document.createElement("span");i.className="u2-tabs-label",i.dataset.u2Part="item-label",i.textContent=e.title;let r=document.createElement("span");r.className=e.closable?"u2-tabs-close":"u2-tabs-mark",e.closable&&(r.title="Close",r.dataset.u2Part="close"),void 0!==e.icon&&n.append(nU._icon(e.icon)),n.append(i,r);let o=document.createElement("div");o.className="u2-tabs-panel",o.id=`${this._idPrefix}-panel-${e.id}`,o.style.display="none",o.setAttribute("role","tabpanel"),o.setAttribute("aria-labelledby",n.id),this._scroller.append(n),this._content.append(o);let s=this._eager&&"function"!=typeof e.content,a={options:e,header:n,panel:o,mark:r,built:s,scope:this.scope.child("tab-validity")};s&&o.append(e.content instanceof H?e.content.root:e.content),this._tabs.value=[...this._tabs.peek(),a],void 0!==e.validity?this._watchValidity(a,e.validity):"function"!=typeof e.content&&this._watchContent(a,e.content),null===this.activeTab.peek()&&(this.activeTab.value=e.id),this._updateOverflow()}_watchValidity(e,t){e.scope.effect(()=>{let n=t.value;(0,P.untracked)(()=>this.setInvalid(e.options.id,n))})}_watchContent(e,t){let n=t.shownProblem instanceof P.Signal?t.shownProblem:t.error;t instanceof H&&n instanceof P.Signal&&this._watchValidity(e,n)}closeTab(e){let t=this._tabs.peek(),n=t.findIndex(t=>t.options.id===e);if(n<0)return;t[n].header.remove(),t[n].panel.remove(),t[n].scope.dispose();let i=t.slice();i.splice(n,1),this._tabs.value=i,this.activeTab.peek()===e&&(this.activeTab.value=i.length>0?i[Math.min(n,i.length-1)].options.id:null),this._updateOverflow(),this.fireEvent("tabClosed",e)}getState(){let e=this.activeTab.peek();return nB({},super.getState(),null===e?{}:{current:e})}getItems(){let e=this.activeTab.peek(),t=this._tabs.peek().map((t,n)=>{let i=t.options,r=i.id,o=i.title,s=i.tooltip;return nG(nB({key:r,label:o||s||r,index:n,selected:r===e,current:r===e},t.invalid?{invalid:!0}:{}),{rendered:!0})});return{count:t.length,list:t,truncated:!1}}setDirty(e,t){let n=this._find(e);n&&n.mark.classList.toggle("u2-tabs-dirty",t)}setInvalid(e,t){var n;let i=this._find(e);void 0!==i&&(i.invalid=t,i.header.classList.toggle("u2-tabs-invalid",null!==t),null===t?i.header.removeAttribute("aria-invalid"):i.header.setAttribute("aria-invalid","true"),i.header.title=null!=(n=null!=t?t:i.options.tooltip)?n:i.options.title)}static _icon(e){let t=document.createElement("span");return t.className="u2-tabs-icon",t.append(tX(e)),t}setTabTitle(e,t){let n=this._find(e);void 0!==n&&(n.options=nG(nB({},n.options),{title:t}),n.header.querySelector(".u2-tabs-label").textContent=t,void 0!==n.options.tooltip||n.invalid||(n.header.title=t),this._tabs.value=[...this._tabs.peek()])}_find(e){return this._tabs.peek().find(t=>t.options.id===e)}_applyActive(){let e=this.activeTab.value;var t=!0,n=!1,i=void 0;try{for(var r,o=this._tabs.value[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value,n=t.options.id===e;if(t.header.classList.toggle("u2-tabs-tab-active",n),t.header.setAttribute("aria-selected",String(n)),t.header.tabIndex=n?0:-1,t.panel.style.display=n?"":"none",n){if(!t.built){t.built=!0;let e=t.options.content;this.scope.child("tab").build(()=>(0,P.untracked)(()=>{let n="function"==typeof e?e():e;t.panel.append(n instanceof H?n.root:n),"function"==typeof e&&void 0===t.options.validity&&this._watchContent(t,n)}))}this._reveal(t)}}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}}_reveal(e){let t=this._scroller.getBoundingClientRect(),n=e.header.getBoundingClientRect();this._scroller.scrollLeft+=Math.min(0,n.left-t.left)+Math.max(0,n.right-t.right),this._scroller.scrollTop+=Math.min(0,n.top-t.top)+Math.max(0,n.bottom-t.bottom)}_focus(e){var t=!0,n=!1,i=void 0;try{for(var r,o=this._tabs.peek()[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.header.tabIndex=t===e?0:-1}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}e.header.focus(),e.header.scrollIntoView({block:"nearest",inline:"nearest"})}_onPointerDown(e){let t=e.target,n=t.closest(".u2-tabs-tab");if(!n)return;let i=this._find(n.dataset.id);if(i){if(1===e.button){e.preventDefault(),i.options.closable&&this.closeTab(i.options.id);return}if(0===e.button){if(t.closest(".u2-tabs-close")){e.preventDefault(),this.closeTab(i.options.id);return}this.activeTab.value=i.options.id}}}_onKeyDown(e){let t,n=this._tabs.peek(),i=n.findIndex(e=>e.header===document.activeElement);if(i<0)return;let r=n.length-1,o=0===i?r:i-1,s=i===r?0:i+1,a="vertical"===this.orientation;switch(e.key){case"ArrowLeft":t=o;break;case"ArrowRight":t=s;break;case"ArrowUp":if(!a)return;t=o;break;case"ArrowDown":if(!a)return;t=s;break;case"Home":t=0;break;case"End":t=r;break;case"Enter":case" ":e.preventDefault(),this.activeTab.value=n[i].options.id;return;case"Delete":{if(!n[i].options.closable)return;e.preventDefault(),this.closeTab(n[i].options.id);let t=this._tabs.peek();t.length>0&&this._focus(t[Math.min(i,t.length-1)]);return}default:return}e.preventDefault(),this._focus(n[t])}_onMenuClick(e){let t=e.target.closest(".u2-tabs-overflow-item");if(!t)return;let n=this._find(t.dataset.id);this._menuOpen.value=!1,n&&(this.activeTab.value=n.options.id,n.header.scrollIntoView({block:"nearest",inline:"nearest"}))}_onDocumentPointerDown(e){let t=e.target;this._menu.contains(t)||this._overflow.contains(t)||(this._menuOpen.value=!1)}_onDocumentKeyDown(e){"Escape"===e.key&&(this._menuOpen.value=!1,this._overflow.focus())}_renderMenu(){let e=this._menuOpen.value;if(this._menu.classList.toggle("u2-tabs-overflow-menu-open",e),!e){this._menu.textContent="";return}let t=P.Scope.ambient;t.listen(document,"pointerdown",e=>this._onDocumentPointerDown(e)),t.listen(document,"keydown",e=>this._onDocumentKeyDown(e));let n=this.activeTab.value;this._menu.replaceChildren(...this._tabs.value.map(e=>{let t=e.options,i=t.id,r=t.title,o=t.icon,s=t.tooltip,a=document.createElement("div");return a.className="u2-tabs-overflow-item",a.dataset.id=i,a.setAttribute("role","menuitem"),a.classList.toggle("u2-tabs-overflow-item-active",i===n),void 0!==o&&a.append(nU._icon("string"==typeof o?o:o.cloneNode(!0))),a.append(r||s||i),a}))}_updateOverflow(){let e="vertical"===this.orientation?this._scroller.scrollHeight>this._scroller.clientHeight+1:this._scroller.scrollWidth>this._scroller.clientWidth+1;this._overflow.classList.toggle("u2-tabs-overflow-visible",e),this._overflow.tabIndex=e?0:-1,e||(this._menuOpen.value=!1)}constructor(e){super(),this.activeTab=(0,P.signal)(null),this._idPrefix=`u2-tabs-${++nV}`,this._header=document.createElement("div"),this._scroller=document.createElement("div"),this._overflow=document.createElement("button"),this._menu=document.createElement("div"),this._content=document.createElement("div"),this._tabs=(0,P.signal)([]),this._menuOpen=(0,P.signal)(!1),this.orientation=null!=(a=null==e?void 0:e.orientation)?a:"horizontal",this._eager=(null==e?void 0:e.eager)===!0,this.root.classList.add("u2-tabs"),this.root.classList.toggle("u2-tabs-vertical","vertical"===this.orientation),this.root.classList.toggle("u2-tabs-document",(null==e?void 0:e.variant)==="document"),this.root.dataset.u2="tabs",this._header.className="u2-tabs-header",this._header.setAttribute("role","tablist"),this._header.setAttribute("aria-orientation",this.orientation),this._scroller.className="u2-tabs-scroller",this._scroller.setAttribute("role","presentation"),this._overflow.className="u2-tabs-overflow",this._overflow.type="button",this._overflow.tabIndex=-1,this._overflow.textContent="⌄",this._overflow.title="Show all tabs",this._overflow.setAttribute("aria-haspopup","menu"),this._menu.className="u2-tabs-overflow-menu",this._menu.setAttribute("role","menu"),this._header.append(this._scroller,this._overflow,this._menu),this._content.className="u2-tabs-content",this.root.append(this._header,this._content);const t=this.scope;t.listen(this._scroller,"pointerdown",e=>this._onPointerDown(e)),t.listen(this._scroller,"keydown",e=>this._onKeyDown(e)),t.listen(this._overflow,"click",()=>this._menuOpen.value=!this._menuOpen.peek()),t.listen(this._menu,"click",e=>this._onMenuClick(e));const n=null==e?void 0:e.onTabClosed;n&&this.on("tabClosed",(e,t)=>n(e,t));const i=new ResizeObserver(()=>this._updateOverflow());i.observe(this._header),this.own(()=>i.disconnect()),this.effect(()=>this._applyActive()),this.effect(()=>this._renderMenu());var r=!0,o=!1,s=void 0;try{for(var a,l,u,d=(null!=(l=null==e?void 0:e.tabs)?l:[])[Symbol.iterator]();!(r=(u=d.next()).done);r=!0){const e=u.value;this.addTab(e)}}catch(e){o=!0,s=e}finally{try{r||null==d.return||d.return()}finally{if(o)throw s}}}}function nH(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function nW(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function nY(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){nW(o,i,r,s,a,"next",e)}function a(e){nW(o,i,r,s,a,"throw",e)}s(void 0)})}}function nK(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return nH(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nH(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}class nX extends nb{getItems(e){return this._tree.getItems(e)}revealItem(e){return this._tree.revealItem(e)}revealRow(e){return super.revealItem(e)}getState(){return this._tree.getState()}constructor(e,t){super(e),this._tree=t}}class nZ extends H{setRoots(e){this._roots.value=[...e],this._prune()}refresh(e){this._list.refresh(e)}focusRows(){this._list.focusRows()}clearSelection(){this._list.selectedIndex.value=-1}nodeForRow(e){let t=this._flat.peek()[nZ._rowIndex(e)];return t&&"node"===t.kind?t.node:null}expandPath(e){return nY(function*(){if(0===e.length)return;let t=this._roots.peek();for(let n=0;n<e.length-1;n++){let i=t.find(t=>t.id===e[n]);if(!i)return;t=yield this._childrenOf(i)}let n=this.expanded.peek(),i=new Set([...n,...e.slice(0,-1)]);i.size!==n.size&&(this.expanded.value=i);let r=e[e.length-1],o=this._flat.peek().findIndex(e=>"node"===e.kind&&e.node.id===r);o>=0&&this._select(o)}).call(this)}getItems(e){let t=this._flat.peek(),n=this._list.selectedIndices.peek(),i=[],r=0;var o=!0,s=!1,a=void 0;try{for(var l,u=t.entries()[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){let t=nK(l.value,2),o=t[0],s=t[1];"node"===s.kind&&(((null==e?void 0:e.all)||r<P.ITEMS_CAP)&&i.push({key:s.node.id,label:s.label,index:r,level:s.depth+1,expanded:s.branch?s.open:void 0,checked:s.checked,selected:n.has(o),disabled:!!s.disabled,rendered:null!==this._list.rowAt(o)}),r++)}}catch(e){s=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(s)throw a}}return{count:r,list:i,truncated:i.length<r}}getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={selection:this.selectedNodes.peek().map(e=>e.id)},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}rename(e){return nY(function*(){if(!this._rename||(yield new Promise(e=>(0,P.afterFlush)(e)),(yield this.revealItem(e))===null))return!1;let t=this._flat.peek().findIndex(t=>"node"===t.kind&&t.node.id===e);return this._select(t),this._startRename(t),!0}).call(this)}revealItem(e){return nY(function*(){let t=this._pathTo(e);if(null===t)return null;let n=this.expanded.peek(),i=new Set([...n,...t.slice(0,-1)]);i.size!==n.size&&(this.expanded.value=i);let r=t[t.length-1];return this._flat.peek().some(e=>"node"===e.kind&&e.node.id===r)?this._list.revealRow(r):null}).call(this)}_pathTo(e){var t;let n=e.trim().toLowerCase(),i=[],r=[],o=(t,s)=>{var a=!0,l=!1,u=void 0;try{for(var d,c,h=t[Symbol.iterator]();!(a=(c=h.next()).done);a=!0){let t=c.value,a=[...s,t.id];t.id===e?i.push(a):t.label.trim().toLowerCase()===n&&r.push(a);let l=Array.isArray(t.children)?t.children:null==(d=this._loads.get(t.id))?void 0:d.children;l&&o(l,a)}}catch(e){l=!0,u=e}finally{try{a||null==h.return||h.return()}finally{if(l)throw u}}};if(o(this._roots.peek(),[]),i.length>0)return i[0];if(r.length>1)throw Error(`u2: ${r.length} items match "${e}": `+r.map(e=>e[e.length-1]).join(", "));return null!=(t=r[0])?t:null}_rebuild(){let e=[],t=[];this._loaded.value,this._flatten(this._roots.value,0,e,t);let n=new Map,i=e.map(e=>{let t=nZ._key(e),i=this._shown.get(t),r=void 0!==i&&nZ._same(i,e)?i:e;return n.set(t,r),r});this._shown=n,this._flat.value=i,(0,P.untracked)(()=>{var e=!0,n=!1,i=void 0;try{for(var r,o=t[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let e=r.value;this._load(e)}}catch(e){n=!0,i=e}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}})}_flatten(e,t,n,i){let r=this.expanded.value;var o=!0,s=!1,a=void 0;try{for(var l,u,d=e[Symbol.iterator]();!(o=(u=d.next()).done);o=!0){let e=u.value,o="function"==typeof e.children?this._loads.get(e.id):void 0,s=void 0!==o&&o.loader===e.children,a=nZ._isBranch(e)&&!(s&&(null==(l=o.children)?void 0:l.length)===0),d=a&&r.has(e.id);if(n.push({node:e,depth:t,kind:"node",branch:a,open:d,label:e.label,tooltip:e.tooltip,checked:e.checked,locked:e.locked,disabled:e.disabled}),r.has(e.id)){if(Array.isArray(e.children)){this._flatten(e.children,t+1,n,i);continue}"function"==typeof e.children&&(s||i.push(e),(null==o?void 0:o.children)!==void 0?this._flatten(o.children,t+1,n,i):s&&void 0!==o.error?n.push(nZ._status(e,t+1,"error",o.error)):n.push(nZ._status(e,t+1,"loading")))}}}catch(e){s=!0,a=e}finally{try{o||null==d.return||d.return()}finally{if(s)throw a}}}_childrenOf(e){return Array.isArray(e.children)?Promise.resolve(e.children):"function"!=typeof e.children?Promise.resolve([]):this._load(e)}_load(e){let t,n=e.children,i=this._loads.get(e.id);if(void 0!==i&&i.loader===n&&void 0===i.error)return i.promise;null==i||i.scope.dispose();let r=this.scope.child("tree-load"),o={loader:n,scope:r,promise:Promise.resolve([]),children:null==i?void 0:i.children};this._loads.set(e.id,o);try{t=r.build(()=>(0,P.untracked)(n))}catch(e){t=Promise.reject(e)}let s=(t,n)=>{if(this._loads.get(e.id)!==o)return;let i=void 0!==o.children;o.children=t,o.error=n,i&&this._prune(),this._loaded.value++};return o.promise=t.then(e=>(s(e),e),e=>(s(void 0,e instanceof Error?e.message:String(e)),[])),o.promise}_prune(){if(0===this._loads.size)return;let e=new Set,t=n=>{var i=!0,r=!1,o=void 0;try{for(var s,a,l=n[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let n=a.value;if(e.has(n.id))continue;e.add(n.id);let i=Array.isArray(n.children)?n.children:null==(s=this._loads.get(n.id))?void 0:s.children;i&&t(i)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}};t(this._roots.peek());var n=!0,i=!1,r=void 0;try{for(var o,s=this._loads[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let t=nK(o.value,2),n=t[0],i=t[1];e.has(n)||(i.scope.dispose(),this._loads.delete(n))}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}}_renderRow(e,t){var n,i;t.setAttribute("aria-level",String(e.depth+1));let r=document.createElement("div");if(r.className="u2-tree-row",r.style.setProperty("--u2-tree-indent",`${20*e.depth}px`),"node"!==e.kind)return t.removeAttribute("data-u2-item"),r.append(nZ._twistie(!1,!1),nZ._span(`u2-tree-${e.kind}`,"loading"===e.kind?"Loading…":null!=(i=e.message)?i:"")),r;e.branch&&t.setAttribute("aria-expanded",String(e.open)),void 0!==e.checked&&t.setAttribute("aria-checked",String(e.checked));let o=void 0===this._render?nZ._span("u2-tree-label",e.label):this._render(e.node);return o.classList.add("u2-tree-label"),o.dataset.u2Part="item-label",r.append(nZ._twistie(e.branch,e.open)),void 0!==e.checked&&r.append(this._checkbox(e)),r.append(o),e.disabled&&(r.classList.add("u2-tree-row-disabled"),tA.apply(t,e.disabled)),r.title=e.disabled||(null!=(n=e.tooltip)?n:e.label),r}_onClick(e){let t=e.target;if(!t)return;let n=this._flat.peek()[nZ._rowIndex(t)];n&&"node"===n.kind&&(t.closest(".u2-tree-check")?(e.stopPropagation(),e.preventDefault(),this._toggleCheck(n.node)):t.closest(".u2-tree-twistie")&&(e.stopPropagation(),this._setExpanded(n.node.id,!this.expanded.peek().has(n.node.id))))}_toggleCheck(e){void 0!==this._check&&void 0!==e.checked&&!0!==e.locked&&this._check(e,!e.checked)}_onKeyDown(e){let t=this._flat.peek(),n=this._list.selectedIndex.peek(),i=t[n];if(i)switch(e.key){case"ArrowRight":e.preventDefault(),"node"===i.kind&&nZ._isBranch(i.node)&&!this.expanded.peek().has(i.node.id)?this._setExpanded(i.node.id,!0):n+1<t.length&&t[n+1].depth>i.depth&&this._select(n+1);break;case"ArrowLeft":if(e.preventDefault(),"node"===i.kind&&this.expanded.peek().has(i.node.id)){this._setExpanded(i.node.id,!1);break}for(let e=n-1;e>=0;e--)if(t[e].depth<i.depth){this._select(e);break}break;case"Enter":e.preventDefault(),this._select(n);break;case"F2":e.preventDefault(),this._startRename(n);break;case" ":if("node"!==i.kind||void 0===i.node.checked)break;e.preventDefault(),this._toggleCheck(i.node)}}_startRename(e){var t,n;let i=this._rename,r=this._flat.peek()[e];if(!i||!r||"node"!==r.kind)return;null==(t=this._endRename)||t.call(this);let o=null==(n=this._list.rowAt(e))?void 0:n.querySelector(".u2-tree-label");if(!o)return;let s=document.createElement("input");s.className="u2-tree-rename",s.setAttribute("aria-label",`Rename ${r.node.label}`),s.value=r.node.label,o.replaceWith(s),s.focus(),s.select();let a=!0,l=e=>{a&&(a=!1,e&&e!==r.node.label&&(o.textContent=e,i(r.node,e)),s.isConnected&&s.replaceWith(o))};this._endRename=l,s.addEventListener("blur",()=>l()),s.addEventListener("keydown",e=>{e.stopPropagation(),("Enter"===e.key||"Escape"===e.key)&&(l("Enter"===e.key?s.value.trim():void 0),this._list.root.focus())})}_setExpanded(e,t){let n=new Set(this.expanded.peek());if(t)n.add(e);else{n.delete(e);let t=this._loads.get(e);(null==t?void 0:t.error)!==void 0&&(t.scope.dispose(),this._loads.delete(e))}this.expanded.value=n}_select(e){this._list.selectedIndex.value=e,this._list.scrollToIndex(e)}_checkbox(e){var t,n;let i=document.createElement("input");return i.type="checkbox",i.className="u2-tree-check",i.checked=!0===e.checked,i.disabled=void 0===this._check||!0===e.locked&&!0!==e.checked,!0===e.locked&&!0===e.checked&&i.setAttribute("aria-disabled","true"),i.tabIndex=-1,i.setAttribute("aria-label",null!=(t=null==(n=this._checkLabel)?void 0:n.call(this,e.node))?t:e.label),i}static _key(e){return"node"===e.kind?e.node.id:`${e.kind}:${e.node.id}`}static _same(e,t){return e.node===t.node&&e.depth===t.depth&&e.kind===t.kind&&e.message===t.message&&e.branch===t.branch&&e.open===t.open&&e.label===t.label&&e.tooltip===t.tooltip&&e.checked===t.checked&&e.locked===t.locked&&e.disabled===t.disabled}static _status(e,t,n,i){return{node:e,depth:t,kind:n,message:i,branch:!1,open:!1,label:e.label}}static _isBranch(e){return void 0!==e.children}static _rowIndex(e){let t=e instanceof Element?e.closest(".u2-list-row"):null;return t?Number(t.dataset.index):-1}static _twistie(e,t){let n=tK(t?"chevron-down":"chevron-right",{cls:"u2-tree-twistie"});return e||n.classList.add("u2-tree-twistie-hidden"),n}static _span(e,t){let n=document.createElement("span");return n.className=e,n.textContent=t,n}constructor(e){let t=void 0===e?{}:e;super(),this.expanded=(0,P.signal)(new Set),this._roots=(0,P.signal)([]),this._flat=(0,P.signal)([]),this._loads=new Map,this._loaded=(0,P.signal)(0),this._shown=new Map,this._rename=t.onRename,this._render=t.render,this._check=t.onCheck,this._checkLabel=t.checkLabel;const n=t.contextActions;this._list=this.build(()=>{var e;return new nX({itemHeight:null!=(e=t.itemHeight)?e:20,rowRole:"treeitem",keyOf:nZ._key,labelOf:e=>e.node.label,render:(e,t,n)=>this._renderRow(e,n),contextActions:n?e=>"node"===e.kind?n(e.node):[]:void 0},this)}),this.own(()=>{var e;return null==(e=this._endRename)?void 0:e.call(this)}),this.root.classList.add("u2-tree"),this.root.dataset.u2="tree",this._list.root.setAttribute("role","tree"),this._list.setItems(this._flat),this.root.append(this._list.root),this.selectedNode=(0,P.computed)(()=>{let e=this._flat.value[this._list.selectedIndex.value];return e&&"node"===e.kind?e.node:null}),this.selectedNodes=(0,P.computed)(()=>{let e=this._flat.value,t=[];var n=!0,i=!1,r=void 0;try{for(var o,s=this._list.selectedIndices.value[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=e[o.value];n&&"node"===n.kind&&t.push(n.node)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}),this.scope.listen(this._list.root,"click",e=>this._onClick(e),{capture:!0}),this.scope.listen(this._list.root,"dblclick",e=>{let t=e.target;t&&!t.closest(".u2-tree-twistie")&&this._startRename(nZ._rowIndex(t))}),this.scope.listen(this._list.root,"keydown",e=>this._onKeyDown(e)),this.effect(()=>this._rebuild())}}function nQ(e){return"string"==typeof e?e:e.value}function nJ(e){return"string"==typeof e?e:e.label}function n0(e){return e.every(e=>null!=e)?e:(P.Usage.report("item-null","a choice list holds a null item, which is skipped: pass strings or {value, label} items (for open tables, `Platform.tableNames()`)"),e.filter(e=>null!=e))}class n2 extends nC{get items(){return this._items}set items(e){this.setItems(e)}setItems(e){var t;this._items=n0(e),this._fill();let n=this.peek();this.systemWrite(null!==n&&this._items.some(e=>nQ(e)===n)?n:null),this._select.value=null!=(t=this.peek())?t:""}getItems(e){let t=this.peek();return nC.itemsState(this._items.map((e,n)=>({key:nQ(e),label:nJ(e),index:n,selected:nQ(e)===t,rendered:!0})),null==e?void 0:e.all)}createEditor(){let e=document.createElement("select");this._select=e;let t=this.options.items;return this._items=n0(t instanceof P.Signal?t.peek():t),this._fill(),this.scope.listen(e,"change",()=>this.value=""===e.value?null:e.value),this.effect(()=>{var t;return e.value=null!=(t=this.value)?t:""}),e}_fill(){let e,t=this._select;if(t.textContent="",0===this._items.length&&void 0!==this.options.emptyText){let e=new Option(this.options.emptyText,"");e.disabled=!0,e.selected=!0,t.append(e);return}this.nullable&&t.append(new Option("",""));let n=t;var i=!0,r=!1,o=void 0;try{for(var s,a=this._items[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let i=s.value,r="string"==typeof i?void 0:i.group;r!==e&&(e=r,(n=void 0===r?t:Object.assign(document.createElement("optgroup"),{label:r}))!==t&&t.append(n)),n.append(new Option(nJ(i),nQ(i)))}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}}constructor(e){super(e,null),this.root.dataset.u2="choice-input";const t=e.items;if(t instanceof P.Signal){let e=!0;this.effect(()=>{let n=t.value;e||(0,P.untracked)(()=>this.setItems(n)),e=!1})}}}let n1=0;class n3 extends nC{get emptyText(){var e;return null!=(e=this.options.emptyText)?e:"No items"}set emptyText(e){this.options.emptyText=null!=e?e:void 0;let t=this._itemsHost.querySelector(".u2-multi-choice-empty");null!==t&&(t.textContent=this.emptyText)}get disabled(){return super.disabled}set disabled(e){super.disabled=e,void 0!==this._summaryToggle&&(this._summaryToggle.tabIndex=null===this.disabled?0:-1)}get items(){return this._items}set items(e){this.setItems(e)}getItems(e){var t;let n=new Set(null!=(t=this.peek())?t:[]);return nC.itemsState(this._items.map((e,t)=>{let i=n.has(nQ(e));return{key:nQ(e),label:nJ(e),index:t,checked:i,selected:i,rendered:!0}}),null==e?void 0:e.all)}displayText(){var e;let t=new Set(null!=(e=this.peek())?e:[]);return this._items.filter(e=>t.has(nQ(e))).map(nJ).join(", ")}get expanded(){return this._expanded}setItems(e){var t;this._fill(e);let n=new Set(null!=(t=this.peek())?t:[]),i=this._items.filter(e=>n.has(nQ(e))).map(nQ);i.length!==n.size&&this.systemWrite(i)}createEditor(){let e=document.createElement("div");return e.className="u2-multi-choice",e.setAttribute("role","group"),this._itemsHost=e,this.options.showSummaryCheckbox&&this._buildSummary(e),this._fill(this.options.items),this.scope.listen(e,"change",e=>{this._summaryBox&&e.target===this._summaryBox?0===this._items.length?this._updateSummary():this.value=this._summaryBox.checked?this._items.map(nQ):[]:this.value=this._boxes.filter(e=>e.checked).map(e=>e.value)}),this.effect(()=>{let e=new Set(null!=(r=this.value)?r:[]);var t=!0,n=!1,i=void 0;try{for(var r,o,s=this._boxes[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){let t=o.value;t.checked=e.has(t.value)}}catch(e){n=!0,i=e}finally{try{t||null==s.return||s.return()}finally{if(n)throw i}}this._updateSummary()}),e}_buildSummary(e){let t=document.createElement("div");t.className="u2-multi-choice-summary";let n=document.createElement("input");n.type="checkbox",n.className="u2-input-checkbox",this._summaryBox=n;let i=document.createElement("span");i.className="u2-multi-choice-summary-text",i.id=`u2-multi-choice-summary-${++n1}`,n.setAttribute("aria-labelledby",i.id),this._summaryText=i;let r=document.createElement("span");r.className="u2-multi-choice-chevron",r.append(tX("chevron-down"));let o=document.createElement("span");o.className="u2-multi-choice-summary-toggle",o.tabIndex=0,o.setAttribute("role","button"),o.setAttribute("aria-label","Collapse list"),o.append(i,r),t.append(n,o);let s=document.createElement("div");s.className="u2-multi-choice-items",e.append(t,s),this._itemsHost=s,this._summaryToggle=o;let a=(0,P.signal)(!0);this._expanded=a;let l=()=>{null===this.disabled&&(a.value=!a.peek())};this.scope.listen(o,"click",l),this.scope.listen(o,"keydown",e=>{let t=e.key;("Enter"===t||" "===t)&&(e.preventDefault(),l())}),this.effect(()=>{let e=a.value;o.setAttribute("aria-expanded",String(e)),s.style.display=e?"":"none"})}_updateSummary(){let e=this._summaryBox;if(!e)return;let t=this._items.length,n=this._boxes.filter(e=>e.checked).length;e.checked=n===t&&t>0,e.indeterminate=n>0&&n<t,this._summaryText.textContent=`${n} of ${t}`}_fill(e){let t=n0(e);this._items=t;let n=new Set(null!=(s=this.peek())?s:[]);if(this._itemsHost.textContent="",this._boxes=[],0===t.length){let e=document.createElement("div");e.className="u2-multi-choice-empty",e.textContent=null!=(a=this.options.emptyText)?a:"No items",this._itemsHost.append(e),this._updateSummary();return}var i=!0,r=!1,o=void 0;try{for(var s,a,l,u=t[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){let e=l.value,t=document.createElement("label");t.className="u2-multi-choice-item",t.dataset.u2Item=nQ(e),t.dataset.value=nQ(e);let i=document.createElement("input");i.type="checkbox",i.className="u2-input-checkbox",i.value=nQ(e),i.checked=n.has(i.value);let r=document.createElement("span");r.dataset.u2Part="item-label",r.textContent=nJ(e),t.append(i,r),this._itemsHost.append(t),this._boxes.push(i)}}catch(e){r=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(r)throw o}}this._updateSummary(),this.refreshDisabled()}constructor(e){super(e,[]),this.root.dataset.u2="multi-choice-input"}}let n5=/^-?\d+$/,n4=/^-?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/;class n6 extends nC{get min(){return this.options.min}set min(e){this._setBound("min",e)}get max(){return this.options.max}set max(e){this._setBound("max",e)}get step(){return this.options.step}set step(e){this._setBound("step",e)}_setBound(e,t){this.options[e]=null!=t?t:void 0;let n=this.options,i=n.min,r=n.max,o=n.step;null!==this._slider&&void 0!==i&&void 0!==r&&(this._slider.min=String(i),this._slider.max=String(r),this._slider.step=String(null!=o?o:this._int?1:(r-i)/100),this._syncSlider()),this.revalidate()}createEditor(){this._bad=(0,P.signal)(null),this._slider=null;let e=document.createElement("input");this._input=e,e.type="text",e.autocomplete="off",e.inputMode=this._int?"numeric":"decimal";let t=!1;this.effect(()=>{let n=this.value;t?t=!1:n6._sameFloat32(this._parse(e.value),n)||(e.value=this._format(n)),this._syncSlider()}),this.scope.listen(e,"input",()=>{let n=this._parse(e.value);if(this._bad.value=void 0!==n?null:this._int&&n4.test(e.value.trim())?"Must be a whole number":"Not a number",void 0===n||"change"===this.options.commitOn)return;let i=this.peek();this.value=n,t=!Object.is(this.peek(),i)}),this.scope.listen(e,"blur",()=>this._commit()),this.scope.listen(e,"keydown",e=>this._onKeyDown(e)),this.scope.listen(e,"wheel",t=>{document.activeElement===e&&(t.preventDefault(),this._step(t.deltaY<0?1:-1))},{passive:!1});let n=document.createElement("span");n.className="u2-number-box",n.append(e),this.options.spinner&&n.append(this._createSpinner());let i=document.createElement("div");i.className="u2-number",i.append(n),this.options.clicker&&(this.addRail(this._createClicker("minus",-1,"Decrease"),{edits:!0}),this.addRail(this._createClicker("plus",1,"Increase"),{edits:!0}));let r=this._createSlider();return null!==r&&i.append(r),this.addValidator(()=>this._bad.value),this.addValidator(e=>this._outOfRange(e)),i}get _int(){return"int"===this.options.mode}_createSpinner(){let e=document.createElement("span");return e.className="u2-number-spinner",e.append(this._createStep("▴",1,"Increase"),this._createStep("▾",-1,"Decrease")),this.scope.listen(e,"mousedown",e=>e.preventDefault()),e}_createStep(e,t,n){let i=document.createElement("button");return i.type="button",i.className="u2-number-spin",i.textContent=e,i.setAttribute("aria-label",n),this.scope.listen(i,"click",()=>this._step(t)),i}_createClicker(e,t,n){let i=this._createStep("",t,n);return i.className="u2-number-click",i.append(tK(e)),i}_createSlider(){let e=this.options,t=e.min,n=e.max,i=e.step;if(!0!==this.options.slider||void 0===t||void 0===n||n<=t)return null;let r=document.createElement("input");return r.type="range",r.className="u2-number-slider",r.min=String(t),r.max=String(n),r.step=String(null!=i?i:this._int?1:(n-t)/100),this.scope.listen(r,"input",()=>{let e=Number(r.value);this._set(this._int?Math.round(e):e)}),this._slider=r,this._syncSlider(),r}_syncSlider(){if(null===this._slider)return;let e=this.peek();this._slider.value=null==e?"":String(e)}_onKeyDown(e){if("Enter"===e.key)return void this._commit();let t="ArrowUp"===e.key?1:"ArrowDown"===e.key?-1:0;t&&(e.preventDefault(),this._step(t*(e.shiftKey?10:1)))}_step(e){var t;let n=this.peek();if(null==n||this.readOnly)return;let i=n+e*(null!=(t=this.options.step)?t:1),r=this._int?Math.round(i):Number(i.toPrecision(12));this._set(null===this._outOfRange(n)?this._clamp(r):r)}resetEditor(){this._bad.value=null,this._input.value=this._format(this.peek()),this._syncSlider()}get unreadable(){return null!==this._bad.value}_commit(){let e=this._parse(this._input.value);void 0!==e&&this._set(e)}_set(e){this._bad.value=null,this.value=e,this._input.value=this._format(this.peek()),this._syncSlider()}_parse(e){let t=e.trim();return t?(this._int?n5:n4).test(t)?Number(t):void 0:null}_clamp(e){let t=this.options,n=t.min,i=t.max;return void 0!==n&&e<n?n:void 0!==i&&e>i?i:e}_outOfRange(e){let t=this.options,n=t.min,i=t.max;return null==e?null:void 0!==n&&e<n?`Value must be at least ${n}`:void 0!==i&&e>i?`Value must be at most ${i}`:null}_format(e){if(null==e)return"";let t=this.options.format;if(void 0!==t)return t(e);if(this._int)return String(e);e=n6._shortest(e);let n=this._decimals(e);if(n>0)return e.toFixed(n);let i=Number(e.toFixed(6));return String(0===i&&0!==e?e:i)}static _shortest(e){if(Math.fround(e)!==e)return e;for(let t=1;t<=9;t++){let n=Number(e.toPrecision(t));if(Math.fround(n)===e)return n}return e}static _sameFloat32(e,t){return null!=e&&null!=t&&Math.fround(e)===Math.fround(t)}_decimals(e){let t=this.options,n=t.min,i=t.max,r=t.step,o=n6._decimalsOf(e);for(let e=0,t=[n,i,r];e<t.length;e++){let n=t[e];o=Math.max(o,n6._decimalsOf(n))}return o}static _decimalsOf(e){if(null==e)return 0;let t=String(e);if(t.includes("e")||t.includes("E"))return 0;let n=t.lastIndexOf(".");return n<0?0:t.length-n-1}constructor(e){let t=void 0===e?{}:e;super(t,null),this.root.dataset.u2="number-input",this.liveOption("placeholder",t.placeholder,e=>this._input.placeholder=e)}}function n8(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function n9(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let n7={STRING:P.TYPE.STRING,INT:P.TYPE.INT,FLOAT:"float",BIG_INT:P.TYPE.BIG_INT,DATE_TIME:P.TYPE.DATE_TIME,BOOL:P.TYPE.BOOL,STRING_LIST:P.TYPE.STRING_LIST,REF:"ref"};class ie extends Error{constructor(e,t){super(e),this.problems=void 0===t?[]:t,this.name="FilterError"}}let it=Math.random().toString(36).slice(2,6),ii=0;function ir(){return`f${it}${++ii}`}function io(e,t,n){let i={id:ir(),op:void 0===e?"and":e,nodes:void 0===t?[]:t};return(null==n?void 0:n.not)!==void 0&&(i.not=n.not),(null==n?void 0:n.lock)!==void 0&&(i.lock=n.lock),i}function is(e,t,n,i){let r={id:ir(),property:e,operator:t};return void 0!==n&&(r.value=n),(null==i?void 0:i.options)!==void 0&&(r.options=i.options),(null==i?void 0:i.lock)!==void 0&&(r.lock=i.lock),r}function ia(e){return"nodes"in e}function il(e,t){if(e.id===t)return e;var n=!0,i=!1,r=void 0;try{for(var o,s=e.nodes[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value,n=e.id===t?e:ia(e)?il(e,t):null;if(n)return n}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return null}function iu(e,t){var n=!0,i=!1,r=void 0;try{for(var o,s=e.nodes[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=o.value;if(n.id===t)return e;let i=ia(n)?iu(n,t):null;if(i)return i}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return null}function id(e,t){t(e,null,-1),function e(t,n){t.nodes.forEach((i,r)=>{n(i,t,r),ia(i)&&e(i,n)})}(e,t)}function ic(e){let t=0;return id(e,e=>{!ia(e)&&t++}),t}function ih(e){return!0!==e.not&&e.nodes.every(e=>!ia(e))}function ip(e,t,n,i){let r=e=>{let t=e.nodes.slice();return t.splice(Math.min(Math.max(n,0),t.length),0,i),n9(n8({},e),{nodes:t})};return e.id===t?r(e):ik(e,t,e=>ia(e)?r(e):e)}function im(e,t){return ik(e,t,()=>null)}function ig(e){if(ih(e))return e;if(!0===e.not)return null;let t=[],n=i=>{var r=!0,o=!1,s=void 0;try{for(var a,l=i.nodes[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){let i=a.value;if(ia(i)){if(!0===i.not||i.op!==e.op&&i.nodes.length>1||!n(i))return!1}else t.push(i)}}catch(e){o=!0,s=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw s}}return!0};return n(e)?n9(n8({},e),{nodes:t}):null}function iv(e,t){return function e(t,n){if(t===n)return!0;if("object"!=typeof t||"object"!=typeof n||null===t||null===n)return!1;if(Array.isArray(t)||Array.isArray(n))return Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((t,i)=>e(t,n[i]));let i=Object.keys(t);return i.length===Object.keys(n).length&&i.every(i=>e(t[i],n[i]))}(null!=e?e:{},null!=t?t:{})}function ib(e,t){return Array.isArray(e)||Array.isArray(t)?Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>ib(e,t[n])):e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():iy(e)||iy(t)?iy(e)&&iy(t)&&e.type===t.type&&e.id===t.id:i_(e)||i_(t)?i_(e)&&i_(t)&&e.span===t.span:iw(e)||iw(t)?iw(e)&&iw(t)&&e.column===t.column:ix(e)||ix(t)?ix(e)&&ix(t)&&e.param===t.param:e===t}function iy(e){return"object"==typeof e&&null!==e&&"string"==typeof e.id&&"string"==typeof e.type}function i_(e){return"object"==typeof e&&null!==e&&"string"==typeof e.span}function iw(e){return"object"==typeof e&&null!==e&&"string"==typeof e.column}function ix(e){return"object"==typeof e&&null!==e&&"string"==typeof e.param}function ik(e,t,n){let i=e.nodes;for(let r=0;r<i.length;r++){let o=i[r],s=o.id===t?n(o):ia(o)?ik(o,t,n):o;if(s===o)continue;let a=i.slice();return null===s?a.splice(r,1):a[r]=s,n9(n8({},e),{nodes:a})}return e}let iS=/^(-?\d+)([hdwmy])$/,iC={h:36e5,d:864e5,w:6048e5,m:26784e5,y:31536e6};function iA(e){return"now"===e||iS.test(e)}function iO(e,t){if("now"===e)return new Date(t.getTime());let n=iS.exec(e);if(!n)throw new ie(`Bad time span "${e}"`);return new Date(t.getTime()+Number(n[1])*iC[n[2]])}function iE(e,t){return Object.defineProperty(e,"span",{value:t,enumerable:!1,configurable:!0}),e}function iT(e){return e.span}let iP=["January","February","March","April","May","June","July","August","September","October","November","December"],iN=["Su","Mo","Tu","We","Th","Fr","Sa"],iI=/^(\d{4})-(\d{1,2})-(\d{1,2})$/,iM=/^(\d{4})-(\d{1,2})-(\d{1,2})[ T](\d{1,2}):(\d{1,2})$/;function iL(e){return e<10?`0${e}`:String(e)}function iR(e,t){return t?Z.utcParts(e):{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()}}function ij(e,t){let n=iR(e,void 0!==t&&t);return new Date(n.year,n.month-1,n.day)}function iD(e){return new Date(e.getFullYear(),e.getMonth(),1)}function i$(e,t){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+t)}function iF(e,t){let n=new Date(e.getFullYear(),e.getMonth()+t,1),i=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return new Date(n.getFullYear(),n.getMonth(),Math.min(e.getDate(),i))}function iz(e,t){let n=iR(e,void 0!==t&&t);return`${n.year}-${iL(n.month)}-${iL(n.day)}`}class iq extends nC{get unreadable(){return this._bad.value}getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={open:this._open.peek()},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}createEditor(){var e;this._id=`u2-date-${++iq._seq}`,this._bad=(0,P.signal)(!1),this._open=(0,P.signal)(!1),this._machine=(0,P.signal)("idle"),this._month=(0,P.signal)(iD(new Date)),this._active=(0,P.signal)(ij(new Date)),this._time=(0,P.signal)(0),this._dayEls=(0,P.signal)([]);let t=document.createElement("input");this._input=t,t.type="text",t.autocomplete="off",t.placeholder=this._pattern,t.setAttribute("aria-label",null!=(e=nS(this.options.label))?e:this._pattern);let n=!1;this.effect(()=>{let e=this.value,i=this._parse(t.value);n?n=!1:(void 0===i||(null==i?void 0:i.getTime())!==(null==e?void 0:e.getTime()))&&(t.value=this._format(e))}),this.scope.listen(t,"input",()=>{let e=this._parse(t.value);this._bad.value=void 0===e,void 0!==e&&e!==this.peek()&&(n=!0,this.value=e)}),this.scope.listen(t,"blur",()=>{this._commit(),this._send({type:"blur"})}),this.scope.listen(t,"focus",()=>this._send({type:"focus"})),this.scope.listen(t,"keydown",e=>this._onFieldKeyDown(e)),this._toggle=t6("calendar-alt",()=>this._send({type:"toggleOpen"}),{tooltip:"Pick a date"}),this._toggle.classList.add("u2-date-toggle"),this._toggle.setAttribute("aria-haspopup","dialog"),this.addOptions(this._toggle,{edits:!0});let i=document.createElement("div");return this._field=i,i.className="u2-date",i.append(t),this._popup=this._buildPopup(),this.effect(()=>{let e=this._open.value;this._toggle.setAttribute("aria-expanded",String(e)),i.classList.toggle("u2-date-open",e)}),this.effect(()=>this._renderCalendar()),this.effect(()=>this._applyDays()),this.addValidator(()=>this._bad.value?`Not a ${this.withTime?"date-time":"date"}`:null),i}get _pattern(){let e=this.withTime?"yyyy-MM-dd HH:mm":"yyyy-MM-dd";return this.options.relative?`${e} or -1w`:e}get _utc(){return!0===this.options.utcDates}get _firstDay(){var e;return null!=(e=this.options.firstDayOfWeek)?e:Z.firstDayOfWeek()}_buildPopup(){let e=iq._el("div","u2-date-popup");e.setAttribute("role","dialog"),e.setAttribute("aria-label",this.withTime?"Choose date and time":"Choose date"),this._title=iq._el("div","u2-date-title"),this._title.id=`${this._id}-title`;let t=iq._el("div","u2-date-header");t.append(t6("chevron-left",()=>this._shiftMonth(-1),{tooltip:"Previous month"}),this._title,t6("chevron-right",()=>this._shiftMonth(1),{tooltip:"Next month"}),tB("Today",()=>this._send({type:"today"})));let n=iq._el("div","u2-date-grid");n.setAttribute("role","grid"),n.setAttribute("aria-labelledby",this._title.id);let i=iq._el("div","u2-date-weekdays");i.setAttribute("role","row");for(let e=0;e<7;e++){let t=iq._el("div","u2-date-weekday",iN[(this._firstDay+e)%7]);t.setAttribute("role","columnheader"),i.append(t)}return this._weeks=iq._el("div","u2-date-weeks"),this._weeks.setAttribute("role","rowgroup"),n.append(i,this._weeks),e.append(t,n),this.withTime&&e.append(this._buildTime()),this.scope.listen(n,"keydown",e=>this._onGridKeyDown(e)),this.scope.listen(n,"click",e=>this._onGridClick(e)),this.scope.listen(e,"keydown",e=>this._onPopupKeyDown(e)),this.scope.listen(e,tb,()=>this._send({type:"dismiss"})),e}_buildTime(){let e=iq._el("div","u2-date-time");return this._hours=this._segment("Hours"),this._minutes=this._segment("Minutes"),e.append(iq._el("span","u2-date-time-label","Time"),this._hours,iq._el("span","u2-date-time-sep",":"),this._minutes),e}_segment(e){let t=document.createElement("input");return t.className="u2-date-time-seg",t.type="text",t.inputMode="numeric",t.autocomplete="off",t.maxLength=2,t.setAttribute("aria-label",e),this.scope.listen(t,"input",()=>this._onTimeInput(t)),this.scope.listen(t,"keydown",e=>this._onTimeKeyDown(e,t)),this.scope.listen(t,"blur",()=>this._syncTime()),t}_send(e){let t=this._machine.peek();switch(e.type){case"focus":"idle"===t&&(this._machine.value="focused");break;case"blur":"open"!==t&&(this._machine.value="idle");break;case"open":this._openPopup();break;case"toggleOpen":"open"===t?this._dismiss(!0):this._openPopup();break;case"escape":this._dismiss(!0);break;case"dismiss":this._dismiss(!1);break;case"today":this._today();break;case"select":this._select(e.date)}}_openPopup(){if(this._open.peek())return;let e=this.peek(),t=null===e?this._defaultDay():ij(e,this._utc);this._month.value=iD(t),this._active.value=t;let n=null===e?{hours:0,minutes:0}:this._utc?Z.utcParts(e):{hours:e.getHours(),minutes:e.getMinutes()};this._time.value=60*n.hours+n.minutes,this._machine.value="open",this._closeOverlay=tx.show(this._field,this._popup,{owner:this.scope,matchWidth:!1}),this._open.value=!0,this._syncTime(),this._focusActive()}_dismiss(e){if(!this._open.peek())return;this._open.value=!1,this._machine.value=e?"focused":"idle";let t=this._closeOverlay;this._closeOverlay=void 0,t&&t(),e&&this._input.focus()}_defaultDay(){let e=ij(new Date),t=this.options,n=t.min,i=t.max;return void 0!==n&&e<ij(n,this._utc)?ij(n,this._utc):void 0!==i&&e>ij(i,this._utc)?ij(i,this._utc):e}_shiftMonth(e){this._goto(iF(this._active.peek(),e),!1)}_today(){let e=ij(new Date);this._disabled(e)?this._goto(e,!0):this._select(e)}_goto(e,t){(e.getFullYear()!==this._month.peek().getFullYear()||e.getMonth()!==this._month.peek().getMonth())&&(this._month.value=iD(e)),this._active.value=e,t&&this._focusActive()}_select(e){this._disabled(e)||(this._set(this._combine(e)),this._dismiss(!0))}_combine(e){let t=this.withTime?this._time.peek():0,n=Math.floor(t/60),i=t%60;return this._utc?Z.fromUtcParts({year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hours:n,minutes:i}):this.withTime?new Date(e.getFullYear(),e.getMonth(),e.getDate(),n,i):ij(e)}_focusActive(){queueMicrotask(this.scope.bind(()=>{if(!this._open.peek())return;let e=iz(this._active.peek());var t=!0,n=!1,i=void 0;try{for(var r,o=this._dayEls.peek()[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.dataset.date===e&&t.focus()}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}}))}_onFieldKeyDown(e){"Enter"===e.key?this._commit():"ArrowDown"===e.key&&(e.preventDefault(),this._send({type:"open"}))}_onPopupKeyDown(e){"Escape"===e.key&&this._send({type:"escape"})}_onGridKeyDown(e){let t,n=this._active.peek();switch(e.key){case"ArrowLeft":t=i$(n,-1);break;case"ArrowRight":t=i$(n,1);break;case"ArrowUp":t=i$(n,-7);break;case"ArrowDown":t=i$(n,7);break;case"PageUp":t=iF(n,e.shiftKey?-12:-1);break;case"PageDown":t=iF(n,e.shiftKey?12:1);break;case"Home":t=i$(n,-this._weekOffset(n));break;case"End":t=i$(n,6-this._weekOffset(n));break;case"Enter":case" ":e.preventDefault(),this._send({type:"select",date:n});return;default:return}e.preventDefault(),this._goto(t,!0)}_onGridClick(e){let t,n=e.target.closest(".u2-date-day");n&&this._send({type:"select",date:new Date((t=n.dataset.date.split("-").map(Number))[0],t[1]-1,t[2])})}_onTimeInput(e){let t=e.value.replace(/\D/g,"").slice(0,2);t!==e.value&&(e.value=t),this._readTime(),2===t.length&&e===this._hours&&this._minutes.focus()}_onTimeKeyDown(e,t){if("Enter"===e.key){e.preventDefault(),this._send({type:"select",date:this._active.peek()});return}let n="ArrowUp"===e.key?1:"ArrowDown"===e.key?-1:0;if(0===n)return;e.preventDefault();let i=t===this._hours?24:60;t.value=iL(((Number(t.value)||0)+n+i)%i),this._readTime()}_readTime(){let e=Math.min(Number(this._hours.value)||0,23),t=Math.min(Number(this._minutes.value)||0,59);this._time.value=60*e+t;let n=this.peek();null!==n&&this._set(this._combine(ij(n,this._utc)))}_syncTime(){if(!this._hours||!this._minutes)return;let e=this._time.peek();this._hours.value=iL(Math.floor(e/60)),this._minutes.value=iL(e%60)}_weekOffset(e){return(e.getDay()-this._firstDay+7)%7}_renderCalendar(){if(!this._open.value){this._dayEls.value=[];return}let e=this._month.value;this._title.textContent=`${iP[e.getMonth()]} ${e.getFullYear()}`;let t=i$(e,-this._weekOffset(e)),n=iz(new Date),i=[];this._weeks.textContent="";for(let r=0;r<6;r++){let o=iq._el("div","u2-date-week");o.setAttribute("role","row");for(let s=0;s<7;s++){let a=i$(t,7*r+s),l=this._dayCell(a,e,n);o.append(l),i.push(l)}this._weeks.append(o)}this._dayEls.value=i}_dayCell(e,t,n){let i=iq._el("div","u2-date-day",String(e.getDate())),r=iz(e);return i.dataset.date=r,i.tabIndex=-1,i.setAttribute("role","gridcell"),i.setAttribute("aria-label",`${iP[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`),e.getMonth()!==t.getMonth()&&i.classList.add("u2-date-adjacent"),r===n&&(i.classList.add("u2-date-today"),i.setAttribute("aria-current","date")),this._disabled(e)&&(i.classList.add("u2-date-day-disabled"),i.setAttribute("aria-disabled","true")),i}_applyDays(){let e=this.value,t=null===e?null:iz(e,this._utc),n=iz(this._active.value);var i=!0,r=!1,o=void 0;try{for(var s,a=this._dayEls.value[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value,i=e.dataset.date===t;e.setAttribute("aria-selected",String(i)),e.classList.toggle("u2-date-selected",i),e.tabIndex=e.dataset.date===n?0:-1}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}}_commit(){let e=this._parse(this._input.value);void 0!==e&&this._set(e)}_set(e){this._bad.value=!1,this.value=null===e?null:this._clamp(e),this._input.value=this._format(this.peek())}_disabled(e){let t=this.options,n=t.min,i=t.max,r=ij(e).getTime();return void 0!==n&&r<ij(n,this._utc).getTime()||void 0!==i&&r>ij(i,this._utc).getTime()}_clamp(e){let t=this.options,n=t.min,i=t.max;return void 0!==n&&e<n?this._normalize(n):void 0!==i&&e>i?this._normalize(i):e}_normalize(e){if(this._utc){let t=Z.utcParts(e);return this.withTime?Z.fromUtcParts(t):Z.fromUtcParts({year:t.year,month:t.month,day:t.day})}return this.withTime?new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()):ij(e)}_format(e){if(null===e)return"";let t=iT(e);if(void 0!==t)return t;let n=iz(e,this._utc);if(!this.withTime)return n;let i=this._utc?Z.utcParts(e):{hours:e.getHours(),minutes:e.getMinutes()},r=i.hours,o=i.minutes;return`${n} ${iL(r)}:${iL(o)}`}_parse(e){let t=e.trim();if(!t)return null;if(this.options.relative&&iA(t))return iE(iO(t,new Date),t);let n=(this.withTime?iM:iI).exec(t);if(!n)return;let i=Number(n[2]),r=Number(n[3]),o=void 0===n[4]?0:Number(n[4]),s=void 0===n[5]?0:Number(n[5]);if(i<1||i>12||r<1||o>23||s>59)return;let a=Number(n[1]),l=this._utc?Z.fromUtcParts({year:a,month:i,day:r,hours:o,minutes:s}):new Date(a,i-1,r,o,s),u=iR(l,this._utc);return u.month===i&&u.day===r?l:void 0}static _el(e,t,n){let i=document.createElement(e);return i.className=t,void 0!==n&&(i.textContent=n),i}constructor(e){super(e,null),this.isOpen=this._open,this.machineState=this._machine}}iq._seq=0;class iB extends iq{get withTime(){return!1}constructor(e){super(void 0===e?{}:e),this.root.dataset.u2="date-input"}}class iG extends iq{get withTime(){return!0}constructor(e){super(void 0===e?{}:e),this.root.dataset.u2="datetime-input"}}function iV(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function iU(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class iH{static share(e,t){iH._shared.set(e,t)}static around(e){for(let t=e.parentElement;null!==t;t=t.parentElement){let e=iH._shared.get(t);if(void 0!==e)return e}}report(e,t){this._members.set(e,t),this._update()}leave(e){this._members.delete(e),this._update()}_update(){let e=0;var t=!0,n=!1,i=void 0;try{for(var r,o=this._members.values()[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;e=Math.max(e,t)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}this._width.value=e}constructor(){this._width=(0,P.signal)(0),this._members=new Map,this.width=this._width}}iH._shared=new WeakMap;let iW=new Set;class iY extends H{get inputs(){return this._inputs}add(e,t){var n,i;if(void 0===e.name){let t=null!=(i=e.root.dataset.u2)?i:"input";iW.has(t)||(iW.add(t),console.warn(`u2: a ${t} with neither name nor label was added to a form — it has no form key and no automation id; give it a name`))}this._inputs.push(e),e.own(()=>this.remove(e)),(null!=t?t:this._rows).append(e.root);let r="choice-input"===e.root.dataset.u2?e.root.querySelector("select"):null;return null!==r&&"u">typeof MutationObserver&&(null!=(n=this._choices)?n:this._choices=new MutationObserver(()=>this._scheduleFrame())).observe(r,{childList:!0}),this._rebuildValidity(),this._scheduleAlign(),this}remove(e){let t=this._inputs.indexOf(e);return t<0||(this._inputs.splice(t,1),e.root.remove(),this.scope.isDisposed||(this._rebuildValidity(),this._scheduleAlign())),this}addAll(e){var t=!0,n=!1,i=void 0;try{for(var r,o=e[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value;this.add(e)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return this}addGroup(e,t,n){let i=document.createElement("span");i.className="u2-input-label u2-form-group-label",i.id=`${this.rootId}-group-${++iY._groups}`,i.textContent=e;let r=document.createElement("div");r.className="u2-form-group-items";let o=document.createElement("div");o.className="u2-form-group",o.setAttribute("role","group"),o.setAttribute("aria-labelledby",i.id),o.append(i,r),(null!=(u=null==n?void 0:n.host)?u:this._rows).append(o);var s=!0,a=!1,l=void 0;try{for(var u,d,c=t[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let e=d.value;e.root.classList.add("u2-input-in-group"),e.root.classList.toggle("u2-input-caption-after",(null==n?void 0:n.captionsAfter)===!0),this.add(e,r)}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}return this}addColumns(e,t){let n=document.createElement("div");n.className="u2-form-columns",n.dataset.u2Part="columns",(null==t?void 0:t.minWidth)!==void 0&&n.style.setProperty("--u2-form-column-min",`${t.minWidth}px`),(null==t?void 0:t.columns)!==void 0&&n.style.setProperty("--u2-form-columns",String(t.columns)),(null!=(s=null==t?void 0:t.host)?s:this._rows).append(n);var i=!0,r=!1,o=void 0;try{for(var s,a,l=e[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let e=a.value;this.add(e,n)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}return this}addElement(e){return this._rows.append(e),this}addButtons(e,t){if(!this._buttons){var n;this._buttons=document.createElement("div"),this._buttons.className="u2-form-buttons",(null!=(n=null==t?void 0:t.host)?n:this.root).append(this._buttons)}return(null==t?void 0:t.align)!==void 0&&(this._buttons.classList.toggle("u2-form-buttons-editors","editors"===t.align),this._buttons.classList.toggle("u2-form-buttons-start","start"===t.align)),e(this._buttons),this}focusFirst(e){var t;let n=null!=(t=void 0===e?void 0:this._inputs.find(e))?t:this._inputs[0];null==n||n.focus()}validate(){let e;var t=!0,n=!1,i=void 0;try{for(var r,o=this._inputs[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.validates&&(t.touch(),void 0===e&&null!==t.validity.peek()&&(e=t))}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return null==e||e.focus(),void 0===e}getState(){let e=this.validity.peek();return iU(iV({},super.getState()),{valid:null===e,error:e})}getItems(e){let t=this._inputs.map((e,t)=>{var n;return iU(iV({key:null!=(n=e.name)?n:`#${t}`,label:e.label,index:t},null!==e.validity.peek()?{invalid:!0}:{},null===e.disabled?{}:{disabled:!0}),{rendered:e.root.isConnected})});return nC.itemsState(t,null==e?void 0:e.all)}getValues(){let e={};var t=!0,n=!1,i=void 0;try{for(var r,o=this._inputs[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.name&&(e[t.name]=t.peek())}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return e}setValues(e){(0,P.batch)(()=>{var t=!0,n=!1,i=void 0;try{for(var r,o=this._inputs[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.name&&t.name in e&&(t.value=e[t.name])}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}})}_rebuildValidity(){let e=this._inputs.slice(),t=t=>(0,P.computed)(()=>{var n=!0,i=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value,n=e.validates?t(e):null;if(n)return n}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return null}),n=(e,t)=>null!==t&&e.label?`${e.label}: ${t}`:t;(0,P.batch)(()=>{this._first.value=t(e=>e.validity.value),this._firstShown.value=t(e=>e.error.value),this._firstNamed.value=t(e=>n(e,e.validity.value)),this._firstShownNamed.value=t(e=>n(e,e.error.value))})}_onKeyDown(e){if("Enter"!==e.key||e.defaultPrevented||e.target instanceof HTMLTextAreaElement)return;let t=e.target,n=this._inputs.findIndex(e=>e.root.contains(t));n<0||n===this._inputs.length-1||(e.preventDefault(),this._inputs[n+1].focus())}_scheduleAlign(){this._queued||(this._queued=!0,queueMicrotask(()=>{this._queued=!1,this._alignLabels()}))}_scheduleFrame(){this._frame||(this._frame=requestAnimationFrame(()=>{this._frame=0,this._alignLabels()}))}layoutNow(){this._alignLabels()}_join(e){this._column=e,this.own(()=>e.leave(this)),this.effect(()=>{let t=e.width.value;t>0&&(0,P.untracked)(()=>this._applyLabelWidth(t))})}_alignLabels(){var e,t,n;if("tall"===this._layout||this.scope.isDisposed)return;if(void 0!==this._labelWidth)return void this._applyLabelWidth(this._labelWidth);if(this._joins&&void 0===this._column){let e=iH.around(this.root);void 0!==e&&this._join(e)}let i=this._measureLabels();null==(t=this._column)||t.report(this,i),this._applyLabelWidth(null!=(e=null==(n=this._column)?void 0:n.width.peek())?e:i)}_measureLabels(){this._tallBeforeMeasure||(this._tallBeforeMeasure=this.root.classList.contains("u2-form-tall")),this.root.classList.remove("u2-form-tall"),this.root.style.setProperty("--u2-form-label-width","0px"),this.root.classList.add("u2-form-measuring");let e=[...this.root.querySelectorAll(".u2-form-group-label")];var t=!0,n=!1,i=void 0;try{for(var r,o=this._inputs[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.root.classList.contains("u2-input-caption-after")||t.root.classList.contains("u2-input-in-group")||e.push(...t.root.querySelectorAll(".u2-input-label, .ui-input-label"))}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}let s=0;var a=!0,l=!1,u=void 0;try{for(var d,c,h=e[Symbol.iterator]();!(a=(c=h.next()).done);a=!0){let e=c.value,t=Math.max(e.offsetWidth,Math.ceil(e.getBoundingClientRect().width));t?this._labelMemo.set(e,t):t=null!=(d=this._labelMemo.get(e))?d:iY._textWidth(e),s=Math.max(s,t)}}catch(e){l=!0,u=e}finally{try{a||null==h.return||h.return()}finally{if(l)throw u}}return this.root.classList.remove("u2-form-measuring"),s}_applyLabelWidth(e){var t;if(this.scope.isDisposed)return;let n=this.root.classList.contains("u2-form-tall")||this._tallBeforeMeasure;if(this._tallBeforeMeasure=!1,this.root.classList.remove("u2-form-tall"),e?this.root.style.setProperty("--u2-form-label-width",`${e}px`):this.root.style.removeProperty("--u2-form-label-width"),iY.fitChoices(this.root,this._inputs.map(e=>e.root)),"auto"!==this._layout)return;if(null!==this.root.closest(".u2-dialog")||(null==(t=this.root.parentElement)?void 0:t.closest(".u2-form"))!=null)return void this.root.classList.remove("u2-form-wide");let i=iY._pickLayout(this.root.clientWidth,e,this._minEditorWidth(),n?"tall":this.root.classList.contains("u2-form-wide")?"wide":"normal");this.root.classList.toggle("u2-form-tall","tall"===i),this.root.classList.toggle("u2-form-wide","wide"===i)}static _textWidth(e){var t,n;let i=null!=(t=e.textContent)?t:"";if(""===i||!e.isConnected)return 0;let r=getComputedStyle(e),o=r.font||`${r.fontSize} ${r.fontFamily}`,s=eu(i,o);if(0===s)return 0;let a=s+(parseFloat(r.paddingLeft)||0)+(parseFloat(r.paddingRight)||0);return(null==(n=e.parentElement)?void 0:n.classList.contains("u2-input-required"))&&(a+=eu("*",o)+(parseFloat(getComputedStyle(e,"::after").marginLeft)||0)),Math.ceil(a)}static _pickLayout(e,t,n,i){return e<=0?i:e-t<n?"tall":e-t>n+10?"wide":i}_minEditorWidth(){if(void 0===this._minEditor){let e=parseFloat(getComputedStyle(this.root).getPropertyValue("--dg-form-min-editor-width"));if(!Number.isFinite(e))return 150;this._minEditor=e}return this._minEditor}static fitChoices(e,t){if(!e.isConnected)return;let n=document.createElement("span");n.style.cssText="position: absolute; visibility: hidden; white-space: pre; padding: 0; margin: 0;",e.append(n);var i=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;if("choice-input"!==e.dataset.u2)continue;let t=40;var l=!0,u=!1,d=void 0;try{for(var c,h=e.querySelectorAll("option")[Symbol.iterator]();!(l=(c=h.next()).done);l=!0)n.textContent=c.value.textContent,t=Math.max(t,Math.ceil(n.getBoundingClientRect().width))}catch(e){u=!0,d=e}finally{try{l||null==h.return||h.return()}finally{if(u)throw d}}e.style.setProperty("--u2-choice-width",`${Math.min(t+30,.8*innerWidth)}px`)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}n.remove()}constructor(e){var t;let n=void 0===e?{}:e;super(),this._rows=document.createElement("div"),this._inputs=[],this._first=(0,P.signal)((0,P.computed)(()=>null)),this._firstShown=(0,P.signal)((0,P.computed)(()=>null)),this._firstNamed=(0,P.signal)((0,P.computed)(()=>null)),this._firstShownNamed=(0,P.signal)((0,P.computed)(()=>null)),this._frame=0,this._queued=!1,this._tallBeforeMeasure=!1,this._labelMemo=new WeakMap,this.validity=(0,P.computed)(()=>this._first.value.value),this.error=(0,P.computed)(()=>this._firstShown.value.value),this.problem=(0,P.computed)(()=>this._firstNamed.value.value),this.shownProblem=(0,P.computed)(()=>this._firstShownNamed.value.value),this.root.classList.add("u2-form"),this.root.dataset.u2="form",this._layout=null!=(t=n.layout)?t:"auto",this._labelWidth=n.labelWidth,void 0!==this._labelWidth&&this.root.style.setProperty("--u2-form-label-width",`${this._labelWidth}px`),this._joins=void 0===n.labelColumn,n.labelColumn&&this._join(n.labelColumn),void 0!==n.maxWidth&&this.root.style.setProperty("--u2-form-max-width",`${n.maxWidth}px`),"compact"===n.density&&(this.root.dataset.dgDensity="compact"),"auto"===this._layout&&this.root.classList.add("u2-form-auto"),"wide"===this._layout&&this.root.classList.add("u2-form-wide"),"tall"===this._layout&&this.root.classList.add("u2-form-tall"),n.quiet&&this.root.classList.add("u2-quiet");const i=n.captionAlign;i instanceof P.Signal?this.effect(()=>this.root.classList.toggle("u2-form-captions-left","left"===i.value)):"left"===i&&this.root.classList.add("u2-form-captions-left"),this._rows.className="u2-form-rows",this.root.append(this._rows);const r=e=>this._onKeyDown(e);if(this.root.addEventListener("keydown",r),this.own(()=>this.root.removeEventListener("keydown",r)),this.own(()=>{var e;this._frame&&cancelAnimationFrame(this._frame),null==(e=this._choices)||e.disconnect()}),"tall"!==this._layout&&"u">typeof ResizeObserver){const e=new ResizeObserver(()=>this._scheduleFrame());e.observe(this.root),this.own(()=>e.disconnect())}}}function iK(e,t){let n=t$("","u2-tag");n.dataset.u2="tag",n.append(t$(e,"u2-tag-text"));let i=null==t?void 0:t.onRemove;if(i){let t=document.createElement("button");t.type="button",t.className="u2-tag-remove",t.textContent="✕",t.setAttribute("aria-label",`Remove ${e}`),t.addEventListener("click",()=>i()),n.append(t)}return n}function iX(e,t){let n=t$("","u2-status-line-text"),i=tK("exclamation-triangle",{cls:"u2-status-line-mark"});i.setAttribute("aria-hidden","true");let r=t$("","u2-status-line");return r.dataset.u2="status-line",r.setAttribute("role","status"),r.append(i,n),tq(()=>{var o;let s=e.value,a=void 0===t?"":"string"==typeof t?t:String(null!=(o=t.value)?o:"");r.classList.toggle("u2-status-line-problem",null!==s),i.hidden=null===s,n.textContent=null!=s?s:a,r.title=n.textContent}),r}function iZ(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}iY._groups=0;class iQ extends H{static create(e,t){return new iQ(e,t)}get modal(){return this._modal&&!this.root.hidden}add(e){let t="function"==typeof e?this.build(e):e,n=H.is(t)?t.root:t;return"string"!=typeof n&&this._adopt(n),this._content.append(n),this}addButton(e,t,n){var i;let r=iQ._owned(t),o=this._button(e,e=>r(e,this),null==n?void 0:n.primary,null==n?void 0:n.disabled);return(null==n?void 0:n.start)===!0?(o.classList.add("u2-dialog-start"),this._buttons.insertBefore(o,iQ._firstAction(this._buttons,!0))):this._buttons.insertBefore(o,null!=(i=this._okBtn)?i:null),this._cancelButton(),this}onHelp(e){return this._onHelp=iQ._owned(e),this._helpBtn||(this._helpBtn=iQ._titleButton("u2-dialog-help","help","question","Help"),this.scope.listen(this._helpBtn,"click",()=>{var e;return null==(e=this._onHelp)?void 0:e.call(this)}),this._bar.insertBefore(this._helpBtn,this._closeBtn)),this}getButton(e){let t=e.trim().toLowerCase();return[...this._buttons.querySelectorAll("button"),...this._bar.querySelectorAll("button")].find(e=>{var n,i;return(null!=(n=e.textContent)?n:"").trim().toLowerCase()===t||(null==(i=e.getAttribute("aria-label"))?void 0:i.toLowerCase())===t})}onOK(e,t){this._onOK=iQ._owned(e);let n=this._okButton(null==t?void 0:t.text);return(null==t?void 0:t.primary)!==void 0&&n.classList.toggle("u2-btn-primary",t.primary),this}okDisabled(e,t){return this._okButton(),this._okOff.value=e,(null==t?void 0:t.footer)===!0&&this._footerLine(),this}status(e){return this._quiet.value=e,this._footerLine().classList.add("u2-dialog-status"),this}_footerLine(){if(void 0===this._reasonLine){let e=(0,P.computed)(()=>{let e=this._quiet.value;return null===e||"string"==typeof e?e:e.value}),t=this._reasonLine=this.build(()=>iX((0,P.computed)(()=>this._okReason.value||null),e));t.classList.add("u2-dialog-reason","u2-status-line-warning"),t.dataset.u2Part="reason",this._buttons.insertBefore(t,iQ._firstAction(this._buttons,!1))}return this._reasonLine}static _firstAction(e,t){var n;return null!=(n=Array.from(e.children).find(e=>!e.classList.contains("u2-dialog-start")&&(t||!e.classList.contains("u2-dialog-reason"))))?n:null}closeGuard(e){return this._closeGuard=e,this}onCancel(e){return this._closeOnly&&P.Usage.report("close-only-cancel","onCancel() on a close-only dialog: it has no CANCEL, and CLOSE, ✕ and Escape close it as OK does — put the work in onOK, or in onClose to run on every close."),this._onCancel=iQ._owned(e),this._cancelButton(),this}_cancelButton(){this._cancelBtn||this._closeOnly||(this._cancelBtn=this._button("CANCEL",()=>this._dismiss()),this._buttons.insertBefore(this._cancelBtn,iQ._firstAction(this._buttons,!1)))}onClose(e){return this._onClose.push(iQ._owned(e)),this}show(e){var t,n;let i=void 0===e?{}:e;if(void 0!==this._unstack)return this;if(this.scope.isDisposed)return console.warn(`u2: dialog "${this._title.textContent}" was disposed when it closed — create it with {keepAlive: true} to show it again`),this;let r=this._u2.adopter;void 0===r||this._keepAlive||(this._u2.adopter=void 0,r.scope.disown(r.release)),this._restore=null!=(t=document.activeElement)?t:void 0,this._error.value=null,void 0!==i.width&&(this.root.style.width=`${i.width}px`),void 0!==i.height&&(this.root.style.height=`${i.height}px`),this.root.classList.toggle("u2-dialog-sized",void 0!==i.height||!0===i.resizable),this.root.classList.toggle("u2-dialog-resizable",!0===i.resizable),this._modal=!0===i.modal;let o=tx.nextDialogZ();if(this._modal?(this._backdrop.style.zIndex=String(o),this.root.style.zIndex=String(o+1),this.root.setAttribute("aria-modal","true"),document.body.append(this._backdrop)):(this.root.style.zIndex=String(o),this.root.removeAttribute("aria-modal")),document.body.append(this.root),this._unstack=tx.pushDialog(this),this._open.value=!0,this._form.value=iQ._formOf(this._content),this._alignLabels(),this._at={x:i.x,y:i.y},this._place(i.x,i.y),!0===i.resizable){let e=this.root.getBoundingClientRect();this._at={x:e.left,y:e.top}}let s=iQ._focusable(this._content).find(e=>!iQ._readOnly(e));return(null!=(n=null!=s?s:this._okBtn)?n:this.root).focus(),(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&s.select(),this._pin(i.visible,i.owner),this}_pin(e,t){if(void 0===e&&void 0===t)return;let n=this._showing=this.scope.child("dialog-showing");void 0!==e&&n.effect(()=>this._hide(!e.value)),void 0!==t&&n.own(K.adopt(t,()=>this.close()))}_hide(e){this.root.hidden!==e&&(this.root.hidden=e,this._backdrop.hidden=e,e||this._place(this._at.x,this._at.y))}static _readOnly(e){return!0===e.readOnly||"true"===e.getAttribute("aria-readonly")||null!==e.closest(".u2-input-readonly")}close(e){let t=this._unstack;if(void 0===t)return;this._unstack=void 0,t(),null==(u=this._pending)||u.abort(),this._setBusy(void 0),this._drag=void 0,null==(d=this._showing)||d.dispose(),this._showing=void 0,this._hide(!1),this._backdrop.remove(),this.root.remove(),this._open.value=!1;let n=this._restore;this._restore=void 0;let i=iQ._topmost();void 0===i||(null==n?void 0:n.isConnected)&&i.contains(n)?(null==n?void 0:n.isConnected)&&n.focus():i.focus();let r=null!=(l=this._closing)?l:void 0===e?"code":e;var o=!0,s=!1,a=void 0;try{for(var l,u,d,c,h=this._onClose[Symbol.iterator]();!(o=(c=h.next()).done);o=!0){let e=c.value;try{e(r)}catch(e){this.scope.reportError(e)}}}catch(e){s=!0,a=e}finally{try{o||null==h.return||h.return()}finally{if(s)throw a}}this.fireEvent("close",r),this._keepAlive||this.dispose()}dispose(){this.close(),super.dispose()}cancelByKey(){var e;void 0!==this._pending?this._pending.abort():this._closeOnly&&(null==(e=this._okBtn)?void 0:e.disabled)!==!0?this._accept():this._dismiss()}getState(){var e,t,n,i;return n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),i=i={open:this._open.peek(),busy:this._busy.peek(),error:this._error.peek(),valid:(null==(t=iQ._formOf(this._content))||null==(e=t.validity)?void 0:e.peek())==null},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}),n}static _formOf(e){let t=e.querySelector(".u2-form"),n=null===t?void 0:H.forElement(t);return n instanceof iY?n:void 0}accessibleLabel(){return H.text(this._title)||void 0}_okButton(e){if(this._okBtn)void 0!==e&&(this._okBtn.textContent=e);else{let t=this._okBtn=this._button(null!=e?e:"OK",()=>this._accept());tS.bind(t,()=>{var e;return null!=(e=tA.of(t))?e:""},{owner:this.scope}),this._buttons.append(t),this._cancelButton(),this.effect(()=>{let e=this._okReason.value;this._busy.peek()||tA.apply(t,e)})}return this._okBtn}_button(e,t,n,i){return this.build(()=>tB(e,t,{primary:n,disabled:i}))}_accept(){var e,t;let n;if(void 0!==this._pending||(null==(e=this._closeGuard)?void 0:e.call(this))===!1)return;this._error.value=null;let i=new AbortController;this._closing="ok";try{n=null==(t=this._onOK)?void 0:t.call(this,{signal:i.signal})}catch(e){this._fail(e);return}finally{this._closing=void 0}if(void 0===this._unstack)return;let r=P.Scope.thenable(n);void 0!==r?this._await(r,i):!1!==n&&this.close("ok")}_await(e,t){var n;return(n=function*(){let n;this._setBusy(t);try{n=yield e}catch(e){this._pending===t&&(this._setBusy(void 0),this._fail(e));return}this._pending===t&&(this._setBusy(void 0),!1!==n&&this.close("ok"))},function(){var e=this,t=arguments;return new Promise(function(i,r){var o=n.apply(e,t);function s(e){iZ(o,i,r,s,a,"next",e)}function a(e){iZ(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}_dismiss(){var e,t;let n;if((null==(e=this._closeGuard)?void 0:e.call(this))!==!1){this._closing="cancel";try{n=null==(t=this._onCancel)?void 0:t.call(this)}catch(e){this.scope.reportError(e)}finally{this._closing=void 0}!1!==n&&this.close("cancel")}}_fail(e){(null==e?void 0:e.name)!=="AbortError"&&(this._error.value=e instanceof Error?e.message:String(e))}_setBusy(e){this._pending=e;let t=void 0!==e;if(this._busy.peek()===t)return;this._busy.value=t;let n=this._okBtn;if(t){this._buttons.contains(document.activeElement)&&this.root.focus(),this._held=[...this._buttons.querySelectorAll("button")].filter(e=>!e.disabled);var i=!0,r=!1,o=void 0;try{for(var s,a=this._held[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;tA.apply(e,iQ.WAITING)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}this.root.setAttribute("aria-busy","true"),null==n||n.setAttribute("aria-busy","true"),null==n||n.append(this._spinner);return}var l=!0,u=!1,d=void 0;try{for(var c,h=this._held[Symbol.iterator]();!(l=(c=h.next()).done);l=!0){let e=c.value;tA.of(e)===iQ.WAITING&&tA.apply(e,null)}}catch(e){u=!0,d=e}finally{try{l||null==h.return||h.return()}finally{if(u)throw d}}this._held=[],void 0!==n&&tA.apply(n,this._okReason.peek()),this.root.removeAttribute("aria-busy"),null==n||n.removeAttribute("aria-busy"),this._spinner.remove()}_adopt(e){let t=P.Scope.ambient;if(t!==this.scope)for(let n=0,i=[e,...e.querySelectorAll(".u2-component")];n<i.length;n++){let e=i[n],r=H.forElement(e);if(void 0===r||r.root!==e||r===this)continue;let o=r._u2,s=o.adopter;if(!(void 0===s&&void 0===t&&r.ambientAdoption)&&(void 0===s||s.scope!==t))continue;void 0!==s&&s.scope.disown(s.release);let a=()=>r.dispose();o.adopter={scope:this.scope,release:a},this.scope.own(a)}}_raise(){if(void 0===this._unstack)return;let e=tx.nextDialogZ();parseInt(this.root.style.zIndex,10)<e-1&&(this.root.style.zIndex=String(e)),tx.raiseDialog(this)}_place(e,t){this.root.style.left="0px";let n=this.root.getBoundingClientRect(),i=null!=e?e:(window.innerWidth-n.width)/2,r=null!=t?t:(window.innerHeight-n.height)/2;this.root.style.left=`${Math.max(0,Math.min(i,window.innerWidth-n.width))}px`,this.root.style.top=`${Math.max(0,Math.min(r,window.innerHeight-n.height))}px`}_onPointerDown(e){if(0!==e.button||e.target.closest("button"))return;e.preventDefault();let t=this.root.getBoundingClientRect();this._drag={dx:e.clientX-t.left,dy:e.clientY-t.top},this._bar.setPointerCapture(e.pointerId)}_onPointerMove(e){this._drag&&(this._at={x:e.clientX-this._drag.dx,y:e.clientY-this._drag.dy},this._place(this._at.x,this._at.y))}_alignLabels(){let e=Array.from(this._content.children).filter(e=>e.classList.contains("u2-input-root"));iY.fitChoices(this._content,e);let t=e.map(e=>e.querySelector(".u2-input-label")).filter(e=>null!==e);if(0===t.length)return;this._content.style.setProperty("--u2-dialog-label-width","auto");let n=0;var i=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;n=Math.max(n,Math.ceil(e.getBoundingClientRect().width))}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}this._content.style.setProperty("--u2-dialog-label-width",`${n}px`);var l=!0,u=!1,d=void 0;try{for(var c,h=t[Symbol.iterator]();!(l=(c=h.next()).done);l=!0){let e=c.value;tS.titleIfCut(e)}}catch(e){u=!0,d=e}finally{try{l||null==h.return||h.return()}finally{if(u)throw d}}}_endDrag(){this._drag=void 0}_onKeyDown(e){if("Escape"===e.key)e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),this.cancelByKey());else if(this._okBtn&&iQ.entersDefault(e)){var t;e.preventDefault(),this._okBtn.disabled?this._busy.peek()||(null==(t=this._form.peek())?void 0:t.validate())===!1||this._okBtn.focus():this._accept()}else"Tab"===e.key&&this._trapTab(e)}_trapTab(e){let t=iQ._focusable(this.root);if(0===t.length)return;let n=document.activeElement;e.shiftKey&&n===t[0]?(e.preventDefault(),t[t.length-1].focus()):e.shiftKey||n!==t[t.length-1]||(e.preventDefault(),t[0].focus())}static _topmost(){let e;var t=!0,n=!1,i=void 0;try{for(var r,o=Array.from(document.querySelectorAll(".u2-dialog"))[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.isConnected&&!t.hidden&&(void 0===e||Number(t.style.zIndex||0)>=Number(e.style.zIndex||0))&&(e=t)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return e}static entersDefault(e){if("Enter"!==e.key||e.defaultPrevented)return!1;let t=e.target;return!(t instanceof Element)||null===t.closest('button, a, input[type="checkbox"], input[type="radio"], select, textarea, .u2-chip, .u2-chips-chip, [role="button"], [role="checkbox"], [role="option"]')}static _owned(e){let t=P.Scope.ambient;return(...n)=>(0,P.batch)(()=>P.Scope.runWith((null==t?void 0:t.isDisposed)?void 0:t,()=>e(...n)))}static _titleButton(e,t,n,i){let r=document.createElement("button");return r.type="button",r.className=e,r.dataset.u2Part=t,r.setAttribute("aria-label",i),r.append(tK(n)),r}static _focusable(e){return Array.from(e.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent)}constructor(e,t){let n=void 0===t?{}:t;super(),this._open=(0,P.signal)(!1),this._busy=(0,P.signal)(!1),this._error=(0,P.signal)(null),this._title=document.createElement("div"),this._bar=document.createElement("div"),this._closeBtn=iQ._titleButton("u2-dialog-close","close","times","Close"),this._content=document.createElement("div"),this._errorRow=document.createElement("div"),this._buttons=document.createElement("div"),this._backdrop=document.createElement("div"),this._spinner=document.createElement("span"),this._onClose=[],this._quiet=(0,P.signal)(null),this._okOff=(0,P.signal)(void 0),this._form=(0,P.signal)(void 0),this._okReason=(0,P.computed)(()=>{var e,t;return null!=(e=null==(t=this._form.value)?void 0:t.problem.value)?e:tA.read(this._okOff.value)}),this._held=[],this._at={},this._modal=!1,this.isOpen=this._open,this.busy=this._busy,this.error=this._error,this._keepAlive=!0===n.keepAlive,this._closeOnly=!0===n.closeOnly,void 0!==n.name&&(this.name=n.name),this.root.classList.add("u2-dialog"),this.root.dataset.u2="dialog",this.root.tabIndex=-1,this.root.setAttribute("role","dialog");const i=`u2-dialog-${++iQ._seq}-title`;this._title.className="u2-dialog-title-text",this._title.id=i,this._title.dataset.u2Part="title",this._title.textContent=e,this.root.setAttribute("aria-labelledby",i);const r=this._closeBtn;this._bar.className="u2-dialog-title",this._bar.append(this._title,r),this._content.className="u2-dialog-content",this._content.dataset.u2Part="body",this._errorRow.className="u2-dialog-error",this._errorRow.dataset.u2Part="error-row",this._errorRow.setAttribute("role","alert"),this._errorRow.hidden=!0,this._buttons.className="u2-dialog-buttons",this._buttons.dataset.u2Part="footer",this._backdrop.className="u2-dialog-backdrop",this._spinner.className="u2-dialog-busy",this._spinner.dataset.u2Part="busy",this._spinner.setAttribute("aria-hidden","true"),this.root.append(this._bar,this._content,this._errorRow,this._buttons);const o=this.scope;o.listen(r,"click",()=>this.cancelByKey()),o.listen(this._bar,"pointerdown",e=>this._onPointerDown(e)),o.listen(this._bar,"pointermove",e=>this._onPointerMove(e)),o.listen(this._bar,"pointerup",()=>this._endDrag()),o.listen(this._bar,"pointercancel",()=>this._endDrag()),o.listen(this._backdrop,"pointerdown",e=>e.preventDefault()),o.listen(this.root,"pointerdown",()=>this._raise()),o.listen(this.root,"keydown",e=>this._onKeyDown(e)),o.listen(this._content,"input",()=>this._error.value=null),o.listen(this._content,"change",()=>this._error.value=null);const s=()=>{void 0!==this._unstack&&this._place(this._at.x,this._at.y)};o.listen(window,"resize",s);const a=new ResizeObserver(s);a.observe(this.root),this.own(()=>a.disconnect()),this.effect(()=>{let e=this._error.value;this._errorRow.textContent=null!=e?e:"",this._errorRow.hidden=null===e}),this._closeOnly&&this._okButton("CLOSE")}}iQ.isRoot=!0,iQ.WAITING="Wait for OK to finish",iQ._seq=0;class iJ{static stored(e,t){if(void 0===t)return null;try{var n;let i=null==(n=globalThis.localStorage)?void 0:n.getItem(`u2.${e}.${t}`);return"true"===i||"false"!==i&&null}catch(e){return null}}static store(e,t,n){if(void 0!==t)try{var i;null==(i=globalThis.localStorage)||i.setItem(`u2.${e}.${t}`,String(n))}catch(e){}}static bindHint(e,t){let n=t.root,i=t.header,r=t.hint,o=t.cls,s=t.text,a=t.validity,l=t.folded,u=r;s instanceof HTMLElement&&((u=document.createElement("span")).className=`${o}-message`,r.append(s,u)),e.effect(()=>{var e,d,c,h;let p=null!=(e=null==a?void 0:a.value)?e:null,f=null!==p&&l();n.classList.toggle(`${o}-invalid`,null!==p),null===p?i.removeAttribute("aria-invalid"):i.setAttribute("aria-invalid","true"),void 0!==a&&(i.title=null!=(d=null!=p?p:null==(h=t.tooltip)?void 0:h.call(t))?d:""),s instanceof HTMLElement?(s.hidden=f,u.textContent=f?p:""):r.textContent=f?p:s instanceof P.Signal?String(null!=(c=s.value)?c:""):null!=s?s:""})}}let i0=0;class i2 extends H{addPane(e,t,n,i){let r="object"==typeof n?n:{expanded:n,icon:i};i=r.icon;let o=iJ.stored("accordion",r.persistKey),s=null!=o?o:!0===r.expanded,a=`${this._idPrefix}-${this._nextPaneId++}`,l=document.createElement("div");l.className="u2-accordion-pane";let u=document.createElement("div");u.className="u2-accordion-header",u.id=`${a}-header`,u.tabIndex=0===this._panes.length?0:-1,u.title=e,u.dataset.u2Item=e,u.setAttribute("role","button"),u.setAttribute("aria-controls",`${a}-content`);let d=document.createElement("span");d.className="u2-accordion-chevron",d.append(tX("chevron-down")),u.append(d);let c=void 0===i?void 0:tX(i);if(c){let e=document.createElement("span");e.className="u2-accordion-icon",e.append(c),u.append(e)}let h=document.createElement("span");h.className="u2-accordion-title",h.dataset.u2Part="item-label",h.textContent=e,u.append(h);let p=void 0===r.hint&&void 0===r.validity?void 0:document.createElement("span");void 0!==p&&(p.className="u2-accordion-hint",p.dataset.u2Part="pane-hint",u.append(p));let f=document.createElement("div");f.className="u2-accordion-content",f.id=`${a}-content`,f.setAttribute("role","region"),f.setAttribute("aria-labelledby",u.id),l.append(u,f),this.root.append(l);let m=this.scope.child("accordion-pane"),g={title:e,icon:c,root:l,header:u,content:f,scope:m,expanded:(0,P.signal)(s),persistKey:r.persistKey,validity:r.validity,userSet:null!==o,builder:"function"==typeof t?t:void 0};return g.builder||f.append(t),this._panes.push(g),m.effect(()=>this._apply(g)),void 0!==p&&iJ.bindHint(m,{root:l,header:u,hint:p,cls:"u2-accordion-pane",text:r.hint,validity:r.validity,folded:()=>!g.expanded.value,tooltip:()=>g.title}),g}getPane(e){return this._panes.find(t=>t.title===e)}setPaneTitle(e,t){let n=this._panes[e];void 0!==n&&(n.title=t,n.header.title=t,n.header.dataset.u2Item=t,n.header.querySelector(".u2-accordion-title").textContent=t)}paneAt(e){return this._panes[e]}removePane(e){let t=this._panes.findIndex(t=>t.title===e);if(t<0)return;let n=this._panes[t];n.scope.dispose(),n.root.remove(),this._panes.splice(t,1),this._panes.length>0&&!this._panes.some(e=>0===e.header.tabIndex)&&(this._panes[0].header.tabIndex=0)}getItems(){let e=this._panes.map((e,t)=>{var n,i,r;return i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({key:e.title,label:e.title,index:t,expanded:e.expanded.peek()},(null==(n=e.validity)?void 0:n.peek())!=null?{invalid:!0}:{}),r=r={rendered:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(r,e))}),i});return{count:e.length,list:e,truncated:!1}}_apply(e){let t=e.expanded.value;if(e.header.setAttribute("aria-expanded",String(t)),e.content.style.display=t?"":"none",!t||!e.builder)return;let n=e.builder;e.builder=void 0,(0,P.untracked)(()=>e.content.append(e.scope.build(n)))}_toggle(e){let t=this._panes[e];t.expanded.value=!t.expanded.peek(),t.userSet=!0,iJ.store("accordion",t.persistKey,t.expanded.peek())}_focus(e){for(let t=0;t<this._panes.length;t++)this._panes[t].header.tabIndex=t===e?0:-1;this._panes[e].header.focus()}_onClick(e){let t=e.target.closest(".u2-accordion-header");if(!t)return;let n=this._panes.findIndex(e=>e.header===t);n<0||(this._focus(n),this._toggle(n))}_onKeyDown(e){let t,n=this._panes.findIndex(e=>e.header===document.activeElement);if(n<0)return;let i=this._panes.length-1;switch(e.key){case"ArrowUp":t=0===n?i:n-1;break;case"ArrowDown":t=n===i?0:n+1;break;case"Home":t=0;break;case"End":t=i;break;case"Enter":case" ":e.preventDefault(),this._toggle(n);return;default:return}e.preventDefault(),this._focus(t)}constructor(e){super(),this._idPrefix=`u2-accordion-${++i0}`,this._panes=[],this._nextPaneId=0,this.root.classList.add("u2-accordion"),this.root.classList.toggle("u2-accordion-flush",(null==e?void 0:e.flush)===!0),this.root.dataset.u2="accordion",this.scope.listen(this.root,"click",e=>this._onClick(e)),this.scope.listen(this.root,"keydown",e=>this._onKeyDown(e))}}let i1="u2-toolbar-hidden";class i3 extends H{addButton(e,t,n){let i=this._button(e,n);return this.scope.listen(i,"click",()=>t()),this._add({kind:"button",el:i,label:e,hidden:!1,onClick:t})}addToggle(e,t,n){let i=this._button(e,n);return i.setAttribute("aria-pressed","false"),this.scope.listen(i,"click",()=>t.value=!t.peek()),this.effect(()=>{let e=t.value;i.classList.toggle("u2-toolbar-btn-pressed",e),i.setAttribute("aria-pressed",String(e))}),this._add({kind:"toggle",el:i,label:e,hidden:!1,bind:t})}addMenu(e,t){let n=this._button(e);n.classList.add("u2-toolbar-btn-menu"),n.setAttribute("aria-haspopup","menu"),n.setAttribute("aria-expanded","false");let i=document.createElement("span");return i.className="u2-toolbar-arrow",i.textContent="▾",n.append(i),this.scope.listen(n,"click",()=>this._toggleMenu(n,t)),this._add({kind:"menu",el:n,label:e,hidden:!1,build:t})}addSeparator(){let e=document.createElement("div");return e.className="u2-toolbar-sep",e.setAttribute("role","separator"),e.setAttribute("aria-orientation","vertical"),this._add({kind:"separator",el:e,label:"",hidden:!1})}add(e){let t=document.createElement("div");return t.className="u2-toolbar-slot",t.append(e),this._add({kind:"slot",el:t,label:"",hidden:!1})}getItems(){let e=this._items.filter(e=>"separator"!==e.kind&&"slot"!==e.kind).map((e,t)=>{var n,i;return n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({key:e.label,label:e.label,index:t,disabled:e.el.disabled},void 0===e.bind?{}:{selected:e.bind.peek()}),i=i={rendered:!e.hidden},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}),n});return{count:e.length,list:e,truncated:!1}}_button(e,t){let n=document.createElement("button");n.type="button",n.className="u2-toolbar-btn",n.dataset.u2Item=e,n.tabIndex=-1,t&&t.icon&&n.append(tK(t.icon,{cls:"u2-toolbar-icon"}));let i=document.createElement("span");return i.className="u2-toolbar-label",i.dataset.u2Part="item-label",i.textContent=e,n.append(i),t&&t.tooltip&&tS.bind(n,t.tooltip,{owner:this.scope}),n}_add(e){return this._items.push(e),this.root.insertBefore(e.el,this._chevron),this._width=-1,this._layout(),this}_layout(){let e=this.root.clientWidth;if(e===this._width)return;this._width=e;var t=!0,n=!1,i=void 0;try{for(var r,o=this._items[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value;i3._setHidden(e,!1)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}if(this._chevron.classList.add(i1),0===e||0===this._items.length)return void this._roving();let s=getComputedStyle(this.root),a=parseFloat(s.columnGap)||0,l=e-(parseFloat(s.paddingLeft)||0)-(parseFloat(s.paddingRight)||0),u=this._items.map(e=>e.el.offsetWidth),d=u.reduce((e,t)=>e+t,0)+a*(u.length-1);if(d<=l)return void this._roving();this._chevron.classList.remove(i1);let c=l-this._chevron.offsetWidth-a,h=u.length;for(;h>0&&d>c;)d-=u[h-1]+a,h--;for(;h>0&&"separator"===this._items[h-1].kind;)h--;for(let e=h;e<this._items.length;e++)i3._setHidden(this._items[e],!0);this._roving()}_roving(){let e=this._stops();this._active>=e.length&&(this._active=e.length-1),this._active<0&&(this._active=0);var t=!0,n=!1,i=void 0;try{for(var r,o=this._items[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value,t=i3._target(e);t&&(t.tabIndex=-1)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}this._chevron.tabIndex=-1,e.length>0&&(e[this._active].tabIndex=0)}_stops(){let e=[];var t=!0,n=!1,i=void 0;try{for(var r,o=this._items[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value,n=t.hidden?null:i3._target(t);n&&e.push(n)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return this._chevron.classList.contains(i1)||e.push(this._chevron),e}_onFocusIn(e){let t=this._stops().findIndex(t=>t===e.target||t.contains(e.target));t<0||(this._active=t,this._roving())}_onKeyDown(e){if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key||e.target.matches("input:not([type=button]):not([type=checkbox]):not([type=radio]), textarea"))return;let t=this._stops();0!==t.length&&(e.preventDefault(),this._active=(this._active+("ArrowRight"===e.key?1:-1)+t.length)%t.length,this._roving(),t[this._active].focus())}_toggleMenu(e,t){let n=this._menuOwner!==e;if(this._closeMenu(),!n)return;let i=new t0;t(i),this._menu=i,this._menuOwner=e,i.show({anchor:e});let r=new P.Scope;r.effect(()=>{let t=i.isOpen.value;e.setAttribute("aria-expanded",String(t)),t||this._menu!==i||(this._menuOwner=void 0)}),this._menuWatch=r}_closeMenu(){this._menu&&this._menu.close(),this._menuWatch&&this._menuWatch.dispose(),this._menu=void 0,this._menuWatch=void 0,this._menuOwner=void 0}_buildOverflow(e){let t=[];var n=!0,i=!1,r=void 0;try{for(var o,s=this._items[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;e.hidden&&"slot"!==e.kind&&("separator"!==e.kind||0!==t.length&&"separator"!==t[t.length-1].kind)&&t.push(e)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}for(;t.length>0&&"separator"===t[t.length-1].kind;)t.pop();var a=!0,l=!1,u=void 0;try{for(var d,c=t[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){let t=d.value;"separator"===t.kind?e.separator():"button"===t.kind?e.item(t.label,t.onClick):"toggle"===t.kind?e.item(t.label,()=>t.bind.value=!t.bind.peek(),{check:t.bind.peek()}):(e.group(t.label),t.build(e),e.endGroup())}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}}static _setHidden(e,t){e.hidden=t,e.el.classList.toggle(i1,t)}static _target(e){return"separator"===e.kind?null:"slot"===e.kind?e.el.querySelector("input, button, select, textarea, a[href], [tabindex]"):e.el}constructor(e){super(),this._items=[],this._chevron=document.createElement("button"),this._active=0,this._width=-1,this.root.classList.add("u2-toolbar"),this.root.dataset.u2="toolbar",this.root.setAttribute("role","toolbar"),e&&e.ariaLabel&&this.root.setAttribute("aria-label",e.ariaLabel),this._chevron.type="button",this._chevron.className=`u2-toolbar-btn u2-toolbar-overflow ${i1}`,this._chevron.append(tK(i3.OVERFLOW_ICON,{cls:"u2-toolbar-icon"})),this._chevron.tabIndex=-1,this._chevron.setAttribute("aria-label",i3.OVERFLOW_LABEL),this._chevron.setAttribute("aria-haspopup","menu"),this._chevron.setAttribute("aria-expanded","false"),this.root.append(this._chevron),this.scope.listen(this._chevron,"click",()=>this._toggleMenu(this._chevron,e=>this._buildOverflow(e))),this.scope.listen(this.root,"keydown",e=>this._onKeyDown(e)),this.scope.listen(this.root,"focusin",e=>this._onFocusIn(e));const t=new ResizeObserver(()=>this._layout());t.observe(this.root),this.own(()=>t.disconnect()),this.own(()=>this._closeMenu())}}i3.OVERFLOW_ICON="ellipsis-h",i3.OVERFLOW_LABEL="More actions";let i5=/,(?=(?:[^"]*"[^"]*")*(?![^"]*"))/;class i4 extends nC{static parse(e){let t=e.replace(/[\r\n]/g,"");return""===t?[]:t.split(i5).map(e=>{let t=e.trim();return t.startsWith('"')?t.substring(1,t.length-1):t})}static join(e){return e.map(e=>`${e}`.includes(",")?`"${e}"`:`${e}`).join(",")}getItems(e){return nC.itemsState(this.peek().map((e,t)=>({key:e,label:e,index:t,rendered:!1})),null==e?void 0:e.all)}get expanded(){return this._expanded}set expanded(e){this._expanded=e,this._field.hidden=e,this._area.hidden=!e,this._glyph.classList.toggle("fa-expand",!e),this._glyph.classList.toggle("fa-compress",e),this._toggle.setAttribute("aria-label",e?"Collapse":"Expand")}createEditor(){this._expanded=!1;let e=document.createElement("input");this._field=e,e.type="text",e.autocomplete="off",e.className="u2-list-text";let t=document.createElement("textarea");this._area=t,t.className="u2-list-text u2-list-area",t.hidden=!0;let n=!1;this.effect(()=>{let i=this.value;if(n){n=!1;return}let r=i4.join(i);e.value=r,t.value=r});let i=i=>{let r=i.value;n=!0,this.value=i4.parse(r),(i===e?t:e).value=r};this.scope.listen(e,"input",()=>i(e)),this.scope.listen(t,"input",()=>i(t)),this._glyph=tK("expand"),this._toggle=tB(this._glyph,()=>this.expanded=!this._expanded),this._toggle.classList.add("u2-icon-btn","u2-list-toggle"),this._toggle.setAttribute("aria-label","Expand");let r=document.createElement("div");return r.className="u2-list",r.append(e,t),this.addOptions(this._toggle),r}constructor(e){var t;let n=void 0===e?{}:e;super(n,[]),this.root.dataset.u2="list-input",this.liveOption("placeholder",null!=(t=n.placeholder)?t:"Comma-separated values",e=>{this._field.placeholder=e,this._area.placeholder=e})}}function i6(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function i8(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function i9(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function i7(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return i6(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i6(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let re=0;class rt extends H{get properties(){return this._groups.peek().flatMap(e=>i7(e,2)[1])}set properties(e){this.setProperties(null!=e?e:[],this.values.peek())}setProperties(e,t){(0,P.batch)(()=>{this.values.value=i8({},t),this._groups.value=rt._group(e)})}getItems(e){let t=new Set;var n=!0,i=!1,r=void 0;try{for(var o,s=this.root.querySelectorAll(".u2-propgrid-row")[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;t.add(e.dataset.u2Item)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}let a=this._groups.peek().flatMap(e=>i7(e,2)[1]).map((e,n)=>i9(i8({key:e.name,label:el(e.name),index:n},e.readonly?{disabled:!0}:{}),{rendered:t.has(e.name)}));return nC.itemsState(a,null==e?void 0:e.all)}_group(e){let t=document.createElement("div");t.className="u2-propgrid-section",t.setAttribute("role","rowgroup");let n=document.createElement("div");return n.className="u2-propgrid-group",e&&(n.id=`${this._idPrefix}-${this._groupId++}`,t.append(this._createHeader(e,n,P.Scope.ambient))),t.append(n),nL(n,(0,P.computed)(()=>{var t,n;return null!=(t=null==(n=this._groups.value.find(t=>i7(t,1)[0]===e))?void 0:n[1])?t:[]}),e=>e.name,e=>this._createRow(e,P.Scope.ambient),{update:(e,t)=>{let n=rt._sameRow(this._shown.get(e),t);return n&&this._shown.set(e,t),n}}),t}_createHeader(e,t,n){let i=this._collapsed.get(e);i||(i=(0,P.signal)(!1),this._collapsed.set(e,i));let r=i,o=document.createElement("div");o.className="u2-propgrid-category",o.dataset.u2Part="category",o.tabIndex=0,o.title=e,o.setAttribute("role","button"),o.setAttribute("aria-controls",t.id);let s=document.createElement("span");s.className="u2-propgrid-chevron",s.textContent="▸";let a=document.createElement("span");a.className="u2-propgrid-category-title",a.textContent=e,o.append(s,a),n.effect(()=>{let e=r.value;o.setAttribute("aria-expanded",String(!e)),t.style.display=e?"none":""});let l=()=>r.value=!r.peek();return n.listen(o,"click",l),n.listen(o,"keydown",e=>{let t=e.key;("Enter"===t||" "===t)&&(e.preventDefault(),l())}),o}_createRow(e,t){let n=document.createElement("div");this._shown.set(n,e),n.className="u2-propgrid-row",n.setAttribute("role","row"),n.dataset.u2Name=e.name;let i=document.createElement("div");i.className="u2-propgrid-name",i.setAttribute("role","rowheader"),i.dataset.u2Part="item-label",i.textContent=el(e.name),e.description&&(i.title=e.description);let r=document.createElement("div");r.className="u2-propgrid-editor",r.setAttribute("role","gridcell"),n.append(i,r);let o=(0,P.computed)(()=>this.values.value[e.name]);if(e.readonly){n.classList.add("u2-propgrid-row-readonly"),n.setAttribute("aria-readonly","true");let e=document.createElement("span");return e.className="u2-propgrid-value",r.append(e),t.effect(()=>e.textContent=er(o.value)),n}let s=this._createInput(e);return r.append(s.root),this._bridge(e,s,o,t),n}_createInput(e){switch(e.type){case"bool":return new nq({inline:!0});case"choice":var t;return new n2({inline:!0,items:null!=(t=e.choices)?t:[]});case"int":case"double":return new n6({inline:!0,mode:"int"===e.type?"int":"float",min:e.min,max:e.max});case"string_list":return new i4({inline:!0,placeholder:e.description});default:return new nF({inline:!0})}}_bridge(e,t,n,i){i.effect(()=>t.value=rt._coerce(e,n.value)),i.effect(()=>{let n=t.value,i=this.values.peek();if(rt.same(e,rt._coerce(e,i[e.name]),n))return;this.values.value=i9(i8({},i),{[e.name]:n});let r={name:e.name,value:n};(0,P.untracked)(()=>{var e;null==(e=this._onChange)||e.call(this,r,this),this.fireEvent("change",r)})})}static _sameRow(e,t){var n,i;return e===t||void 0!==e&&e.type===t.type&&!!e.readonly==!!t.readonly&&e.min===t.min&&e.max===t.max&&e.description===t.description&&(null!=(n=e.choices)?n:[]).join("\n")===(null!=(i=t.choices)?i:[]).join("\n")}static _group(e){let t=new Map;t.set("",[]);var n=!0,i=!1,r=void 0;try{for(var o,s,a=e[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){let e=s.value,n=null!=(o=e.category)?o:"",i=t.get(n);i||(i=[],t.set(n,i)),i.push(e)}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}return[...t].filter(e=>i7(e,2)[1].length>0)}static _coerce(e,t){switch(e.type){case"bool":return!0===t;case"int":case"double":{if("number"==typeof t)return t;let e=null==t||""===t?NaN:Number(t);return isFinite(e)?e:null}case"choice":return null==t?null:String(t);case"string_list":return Array.isArray(t)&&t.every(e=>"string"==typeof e)?t:[];default:return er(t)}}static same(e,t,n){return"string_list"===e.type&&Array.isArray(t)&&Array.isArray(n)?t.length===n.length&&t.every((e,t)=>e===n[t]):t===n}constructor(e){let t=void 0===e?{}:e;super(),this.values=(0,P.signal)({}),this._idPrefix=`u2-propgrid-${++re}`,this._collapsed=new Map,this._groups=(0,P.signal)([]),this._shown=new WeakMap,this._groupId=0,this._onChange=t.onChanged&&nC.bindOwned(t.onChanged,{owner:this.scope}),this.root.classList.add("u2-propgrid"),this.root.dataset.u2="property-grid",this.root.setAttribute("role","grid"),this.build(()=>nL(this.root,this._groups,e=>{let t=i7(e,1)[0];return`category:${t}`},e=>{let t=i7(e,1)[0];return this._group(t)},{update:()=>!0}))}}class rn{get rowCount(){return this._shown.peek().length}open(){this._open.peek()||(this._open.value=!0,this._closeOverlay=tx.show(this._options.anchor,this.popup,{owner:this._options.scope,maxHeight:this._options.maxHeight,matchWidth:this._options.matchWidth}))}dismiss(){if(!this._open.peek())return;this._open.value=!1,this._active.value=-1;let e=this._closeOverlay;this._closeOverlay=void 0,e&&e()}clearActive(){this._active.value=-1}move(e){this.jump(this._active.peek()+e)}jump(e){let t=this._shown.peek().length;t>0&&(this._active.value=Math.min(Math.max(e,0),t-1))}static keyOf(e,t){if("string"==typeof e||"number"==typeof e)return String(e);for(let t=0,n=[null==e?void 0:e.text,null==e?void 0:e.name,null==e?void 0:e.id];t<n.length;t++){let e=n[t];if("string"==typeof e)return e}return`#${t}`}static row(e,t){let n=document.createElement("div");return n.className=e,n.textContent=t,n}_row(e,t){return rn.row(`u2-suggest-${e} ${this._options.prefix}-${e}`,t)}_onPointerDown(e){let t=e.target,n=t.closest(`.${this._options.prefix}-option`);if(n){e.preventDefault(),this._options.onPick([...this._list.children].indexOf(n));return}t.closest(`.${this._options.prefix}-retry`)&&(e.preventDefault(),this._options.onRetry())}_renderStatus(){let e=this._status,t=this._options,n=t.view.value,i=t.text.value.length<t.minChars;if(e.textContent="",e.className="u2-suggest-status",e.hidden=!this._open.value||!i&&"ready"===n.kind&&t.items.value.length>0,e.hidden)return;let r=i?"hint":"error"===n.kind?"error":"loading"===n.kind||"idle"===n.kind?"loading":"empty";if(e.className=`u2-suggest-${r} ${t.prefix}-${r}`,"error"===r&&"error"===n.kind){e.textContent=n.message;let i=document.createElement("button");i.className=`u2-suggest-retry ${t.prefix}-retry`,i.type="button",i.textContent="Retry",e.append(i);return}let o=t.emptyText;e.textContent="hint"===r?`Type ${t.minChars} or more characters`:"loading"===r?"Loading…":"function"==typeof o?o(t.text.peek()):null!=o?o:"No matches"}_highlight(){let e=this._shown.value,t=this._options.text.value.length>0,n=this._options.autoHighlight;n&&e.length>0&&(this._active.value="always"===n||t?0:-1)}_option(e){var t;let n=document.createElement("div");n.className=`u2-suggest-option ${this._options.prefix}-option`,n.id=`${this._id}-opt-${++this._rowSeq}`,n.setAttribute("role","option"),n.setAttribute("aria-selected","false");let i=this._options.render(e);return null===i.querySelector('[data-u2-part="item-label"]')&&(null!=(t=i.dataset).u2Part||(t.u2Part="item-label")),n.append(i),n}_applyActive(){var e,t,n;let i=this._options.anchor,r=this._shown.value.length,o=this._list.children,s=this._active.value,a=this._shown.value,l=null!=(e=null==(t=(n=this._options).currentKey)?void 0:t.call(n))?e:null,u=this._options.keyOf;for(let e=0;e<r;e++)o[e].classList.toggle("u2-suggest-option-current",null!==l&&(null==u?void 0:u(a[e]))===l),o[e].classList.toggle("u2-suggest-option-active",e===s),o[e].classList.toggle(`${this._options.prefix}-option-active`,e===s),o[e].setAttribute("aria-selected",e===s?"true":"false");let d=s>=0&&s<r?o[s]:void 0;d?(i.setAttribute("aria-activedescendant",d.id),d.scrollIntoView({block:"nearest"})):i.removeAttribute("aria-activedescendant")}constructor(e){this.popup=document.createElement("div"),this._open=(0,P.signal)(!1),this._active=(0,P.signal)(-1),this._list=document.createElement("div"),this._status=document.createElement("div"),this._footer=document.createElement("div"),this._rowSeq=0,this._options=e,this.isOpen=this._open,this.activeIndex=this._active,this._id=`${e.prefix}-${++rn._seq}`,this.popup.className=`u2-suggest-popup ${e.prefix}-popup`,this.popup.id=`${this._id}-listbox`,this.popup.setAttribute("role","listbox"),e.anchor.setAttribute("aria-controls",this.popup.id),this._list.className="u2-suggest-options",this._footer.className=`u2-suggest-footer ${e.prefix}-footer`,this._footer.hidden=!0,this.popup.append(this._list,this._status,this._footer),this._shown=(0,P.computed)(()=>{let t=e.view.value;return this._open.value&&e.text.value.length>=e.minChars&&"ready"===t.kind?e.items.value:[]}),e.scope.listen(this.popup,"pointerdown",e=>this._onPointerDown(e)),e.scope.listen(this.popup,tb,()=>e.onDismiss());const t=e.keyOf;e.scope.build(()=>nL(this._list,this._shown,(e,n)=>t?t(e):rn.keyOf(e,n),e=>this._option(e))),e.scope.effect(()=>this._renderStatus()),e.scope.effect(()=>{var t,n;let i=this._shown.value.length>0&&null!=(t=null==(n=e.footer)?void 0:n.call(e))?t:null;this._footer.textContent=null!=i?i:"",this._footer.hidden=null===i}),e.scope.effect(()=>this._highlight()),e.scope.effect(()=>this._applyActive())}}function ri(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function rr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}rn._seq=0;class ro extends H{focus(){this._input.focus()}getState(){var e,t,n;let i=this._input.placeholder;return rr((t=rr({},super.getState()),n=n={value:null!=(e=H.jsonValue(this.selected.peek()))?e:null,text:this._input.value,open:this._list.isOpen.peek(),busy:"loading"===this._view.peek().kind},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t),i?{placeholder:i}:{})}getItems(e){var t;let n=this._options.source,i="function"==typeof n?this._lastItems():n,r=new Set(this._list.isOpen.peek()?this._items.peek():[]),o=null!=(t=this._options.keyOf)?t:this._itemText;return nC.itemsState(i.map((e,t)=>({key:o(e),label:this._itemText(e),index:t,rendered:r.has(e)})),null==e?void 0:e.all)}revealItem(e){var t,n=this,i=()=>super.revealItem;return(t=function*(){this._all.value=!0,this._source&&this._source.query(""),this._openPopup();for(let e=0;e<50&&"loading"===this._view.peek().kind;e++)yield new Promise(e=>setTimeout(e,20));return i().call(n,e)},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){ri(o,i,r,s,a,"next",e)}function a(e){ri(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}accessibleLabel(){var e,t;return null!=(e=null!=(t=super.accessibleLabel())?t:H.labelOf(this._input))?e:this._input.placeholder||void 0}_lastItems(){let e=this._view.peek();return"ready"===e.kind?e.items:[]}_send(e){let t=this._machine.peek();switch(e.type){case"focus":"idle"===t&&(this._machine.value="focused"),this._openOnFocus&&(this._source&&null!==this.selected.peek()?this._source.query(""):this._refresh(),this._openPopup());break;case"blur":this._dismiss(),this._machine.value="idle",queueMicrotask(()=>{this.scope.isDisposed||this._pendingPick||null!==this.selected.peek()||""===this._text.peek()||this.resync()});break;case"input":this._refresh(),this._openPopup();break;case"arrowDown":if("open"===t){this._list.move(1);break}this._refresh(),this._openPopup();break;case"arrowUp":"open"===t&&this._list.move(-1);break;case"enter":if("open"!==t)break;null!==this.selected.peek()&&0>this._list.activeIndex.peek()?this._dismiss():"ready"===this._view.peek().kind?this._commit(this._list.activeIndex.peek()):this._pendingPick=!0;break;case"escape":"open"===t?this._dismiss():this._clear();break;case"tab":case"dismiss":this._dismiss();break;case"select":this._commit(e.index)}}open(){this._source&&null!==this.selected.peek()?this._source.query(""):this._refresh(),this._openPopup()}close(){this._send({type:"dismiss"})}get isPickPending(){return this._pendingPick}_onInput(){this._pendingPick=!1,this._all.value=!1,null!==this.selected.peek()&&(this._echo=!0,this.selected.value=null),this._send({type:"input"})}resync(){this._text.value=null===this.selected.peek()?"":this._itemText(this.selected.peek())}_syncText(){let e=this.selected.value;if(this._echo){this._echo=!1;return}this._text.value=null===e?"":this._itemText(e)}_clear(){this.selected.value=null,this._text.value=""}_openPopup(){this._list.isOpen.peek()||(this._machine.value="open",this._list.open())}_dismiss(){this._list.isOpen.peek()&&(this._all.value=!1,"open"===this._machine.peek()&&(this._machine.value="focused"),this._list.dismiss())}_refresh(){this._source&&this._text.peek().length>=this._minChars&&this._source.query(this._text.peek())}_commit(e,t){let n=this._items.peek()[e];void 0!==n&&(this.selected.value=n,this._dismiss(),(void 0===t||t)&&this._input.focus())}_onKeyDown(e){let t="Enter"===e.key?this._options.onEnter:"Escape"===e.key?this._options.onEscape:void 0;if(void 0!==t&&!this._list.isOpen.peek()&&!e.isComposing){e.preventDefault(),e.stopPropagation(),t(e,this);return}switch(e.key){case"ArrowDown":e.preventDefault(),this._send({type:"arrowDown"});break;case"ArrowUp":e.preventDefault(),this._send({type:"arrowUp"});break;case"Enter":this._list.isOpen.peek()&&e.preventDefault(),this._send({type:"enter"});break;case"Escape":this._send({type:"escape"});break;case"Tab":this._send({type:"tab"})}}constructor(e){var t,n,i,r,o,s,a,l,u;super(),this.selected=(0,P.signal)(null),this._input=document.createElement("input"),this._pendingPick=!1,this._text=(0,P.signal)(""),this._machine=(0,P.signal)("idle"),this._all=(0,P.signal)(!1),this._echo=!1,this._options=e,this.text=this._text,this.machineState=this._machine;const d=e.renderer,c=null!=(t=e.itemText)?t:e=>d.caption(e);this._itemText=c;const h=null!=(n=null==d||null==(l=d.listItem)?void 0:l.bind(d))?n:null==d||null==(u=d.markup)?void 0:u.bind(d),p=null!=(i=null!=(r=e.render)?r:h)?i:e=>rn.row("u2-typeahead-text",c(e));this._minChars=null!=(o=e.minChars)?o:0,this._openOnFocus=!0===e.openOnFocus,this.root.classList.add("u2-typeahead"),this.root.dataset.u2="typeahead";const f=this._input;if(f.className="u2-typeahead-input",f.type="text",f.autocomplete="off",f.spellcheck=!1,f.placeholder=null!=(s=e.placeholder)?s:"",f.setAttribute("role","combobox"),f.setAttribute("aria-autocomplete","list"),f.setAttribute("aria-haspopup","listbox"),e.label&&f.setAttribute("aria-label",e.label),this.root.append(f),"function"==typeof e.source){const t=new eh(e.source,{debounceMs:e.debounceMs});this._source=t,this._view=t.state,this.own(()=>t.dispose()),this.effect(()=>{"loading"===t.state.value.kind?this.root.setAttribute("aria-busy","true"):this.root.removeAttribute("aria-busy")})}else{const t=e.source;this._view=(0,P.computed)(()=>{let e=this._all.value?"":this._text.value.toLowerCase(),n=e?t.filter(t=>c(t).toLowerCase().includes(e)):t;return n.length>0?{kind:"ready",items:n}:{kind:"empty"}})}this._items=(0,P.computed)(()=>{let e=this._view.value;return"ready"===e.kind?e.items:[]});const m=this._minChars,g=this._all,v=this.selected,b=this._openOnFocus;this._list=new rn({prefix:"u2-typeahead",anchor:f,scope:this.scope,items:this._items,view:this._view,text:this._text,get minChars(){return g.value?0:m},render:p,keyOf:null!=(a=e.keyOf)?a:c,get autoHighlight(){return null===v.value&&(!b||"always")},onPick:e=>this._send({type:"select",index:e}),onDismiss:()=>this._send({type:"dismiss"}),onRetry:()=>{var e;return null==(e=this._source)?void 0:e.retry()},emptyText:e.emptyText,maxHeight:e.maxHeight,matchWidth:e.matchWidth,footer:e.footer,currentKey:()=>{var t;return null===v.value?null:(null!=(t=e.keyOf)?t:c)(v.value)}}),this.isOpen=this._list.isOpen,this.effect(()=>{let e=this._view.value;if(!this._pendingPick||"loading"===e.kind||"idle"===e.kind||(this._pendingPick=!1,"ready"!==e.kind))return;let t=this._text.peek().trim().toLowerCase(),n=e.items.findIndex(e=>c(e).toLowerCase()===t);this._commit(n>=0?n:0,document.activeElement===f)}),ed(f,this._text,{owner:this.scope}),this.scope.listen(f,"input",()=>this._onInput()),this.scope.listen(f,"focus",()=>this._send({type:"focus"})),this.scope.listen(f,"blur",()=>this._send({type:"blur"})),this.scope.listen(f,"keydown",e=>this._onKeyDown(e)),this.effect(()=>f.setAttribute("aria-expanded",String(this._list.isOpen.value))),this.effect(()=>this._syncText());let y=!0;this.effect(()=>{let e=this.selected.value;y?y=!1:(0,P.untracked)(()=>this.fireEvent("change",e))})}}let rs={info:"info-circle",warning:"exclamation-triangle",error:"times-circle"};class ra{static get host(){if(!ra._container||!ra._container.isConnected){let e=tR([],"u2-notify-container");e.dataset.u2="notify",tx.host.append(e),ra._container=e}return ra._container}static info(e,t){return ra.show(e,"info",void 0===t?{}:t)}static warning(e,t){return ra.show(e,"warning",void 0===t?{}:t)}static error(e,t){return ra.show(e,"error",void 0===t?{}:t)}static show(e,t,n){var i,r,o,s,a,l;let u,d=void 0===t?"info":t,c=void 0===n?{}:n,h=c.oneTimeKey,p=c.singleKey;if(void 0!==p&&ra._singleKeys.has(p)||void 0!==h&&!ra._claimOneTime(h))return null;void 0!==p&&ra._singleKeys.add(p);let f=P.Scope.ambient,m=new P.Scope(void 0,{label:"notify",lazy:!0}),g="function"==typeof e?m.build(e):e,v=!1,b=()=>{if(v)return;v=!0,m.dispose();let e=c.onClose;void 0!==e&&(0,P.batch)(()=>P.Scope.runWith((null==f?void 0:f.isDisposed)?void 0:f,e))},y=!1,_=null!=(i=c.autoHide)?i:"error"!==d,w=null!=(r=c.timeout)?r:1e4,x=null==(s=ra.presenter)?void 0:s.call(ra,g,d,(a=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},c),l=l={autoHide:_,timeout:w},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(l)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(l)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(l,e))}),a),()=>{y=!0,void 0!==u&&ra._open.delete(u),void 0!==p&&ra._singleKeys.delete(p),b()});if(void 0!==x)return u=x.close,y||ra._open.add(x.close),x;let k=tR([],"u2-notify-content");"string"==typeof g?k.textContent=g:k.append(g);let S=P.Scope.runWith(void 0,()=>tR([tK(rs[d],{cls:"u2-notify-type-icon"}),k],`u2-notify u2-notify-${d}`));S.setAttribute("role","info"===d?"status":"alert");let C=!1,A=()=>{C||(C=!0,window.clearTimeout(E),S.remove(),ra._open.delete(A),void 0!==p&&ra._singleKeys.delete(p),b())};ra._open.add(A);let O=P.Scope.runWith(void 0,()=>t6("copy",()=>{var e,t;let n=void 0===c.copyText?null!=(e=S.textContent)?e:"":`${S.textContent}
|
|
358
|
+
|
|
359
|
+
${c.copyText}`;try{null==(t=navigator.clipboard)||t.writeText(n)}catch(e){}},{tooltip:"Copy to clipboard"}));O.addEventListener("click",e=>e.stopPropagation()),S.append(tR([O,P.Scope.runWith(void 0,()=>t6("times",A,{tooltip:"Close"}))],"u2-notify-icons")),(null==(o=c.closeOnClick)||o)&&S.addEventListener("click",A);let E=0;if(_){let e=tR([],"u2-notify-timer");e.style.animationDuration=`${w}ms`,S.append(e);let t=Date.now(),n=w;E=window.setTimeout(A,n),S.addEventListener("pointerenter",()=>{window.clearTimeout(E),n-=Date.now()-t}),S.addEventListener("pointerleave",()=>{t=Date.now(),E=window.setTimeout(A,Math.max(n,0))})}return ra.host.append(S),{root:S,close:A}}static closeAll(){for(let e=0,t=[...ra._open];e<t.length;e++)(0,t[e])()}static _claimOneTime(e){try{let t=`u2-notify-${e}`;if(null!==window.localStorage.getItem(t))return!1;return window.localStorage.setItem(t,new Date().toISOString()),!0}catch(e){return!0}}}function rl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function ru(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}ra._singleKeys=new Set,ra._open=new Set;let rd=0;class rc extends H{next(){if(this._recheck.value=this._recheck.peek()+1,null!==this._blockReason.peek())return;let e=this._index.peek();if(e===this._steps.length-1)return void this._finish();let t=this._steps[e].options.commit,n=n=>{!1===n||this.scope.isDisposed||this._index.peek()!==e||(t&&(this._committed=e),this._index.value=e+1)};t?this._run(t,n):n(void 0)}back(){let e=this._index.peek();e-1>this._committed&&!this._busy.peek()&&(this._index.value=e-1)}goTo(e){let t=this._steps.findIndex(t=>t.options.id===e),n=this._index.peek();t<0||t===n||t<=this._committed||this._busy.peek()||(this._visited.has(e)&&(t<n||this._steps.slice(n,t).every(e=>!e.options.commit&&null===rc._gate(e.options.canProceed)))?this._index.value=t:t===n+1&&this.next())}setStepTitle(e,t){let n=this._steps[e];void 0!==n&&(n.options=ru(rl({},n.options),{title:t}),n.marker.querySelector(".u2-wizard-title").textContent=t)}resumeFrom(e){var t=!0,n=!1,i=void 0;try{for(var r,o=e._visited[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value;this._steps.some(t=>t.options.id===e)&&this._visited.add(e)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}let s=this._steps.findIndex(t=>t.options.id===e.currentStep.peek());s>=0&&(this._index.value=s)}setStepFailed(e,t){let n=new Set(this._failed.peek());t?n.add(e):n.delete(e),this._failed.value=n}openInDialog(e,t){let n=void 0===t?{}:t;if(!this._dialog){let t=this.build(()=>iQ.create(e,{keepAlive:!0}).add(this).closeGuard(()=>this._guard()).onClose(()=>{this._completed.peek()||(!0===this._steps[this._index.peek()].options.done?this._finish():this._cancelled())}));this._dialog=t,this._cancel=this._button("CANCEL",()=>{this._guard()&&t.close()}),this._cancel.classList.add("u2-wizard-cancel"),this._footer.insertBefore(this._cancel,this._back)}return this._dialog.show({modal:!0,width:n.width,height:n.height})}getState(){let e=this._blockReason.peek(),t=this._error.peek();return ru(rl({},super.getState()),{current:this.currentStep.peek(),busy:this._busy.peek(),valid:null===e&&null===t,error:null!=t?t:this._busy.peek()?null:e})}getItems(){let e=this._index.peek(),t=this._steps.map((t,n)=>({key:t.options.id,label:t.options.title,index:n,current:n===e,completed:n<e&&this._visited.has(t.options.id),disabled:"true"===t.marker.getAttribute("aria-disabled"),rendered:!0}));return{count:t.length,list:t,truncated:!1}}_addStep(e){var t;let n=this._steps.length,i=document.createElement("li");i.className="u2-wizard-step",i.id=`${this._idPrefix}-step-${n}`,i.dataset.id=e.id,i.dataset.u2Item=e.id,i.tabIndex=0===n?0:-1;let r=document.createElement("span");r.className="u2-wizard-marker",r.textContent=String(n+1);let o=document.createElement("span");o.className="u2-wizard-title",o.dataset.u2Part="item-label",o.textContent=e.title,i.append(r,o),tS.bind(i,()=>{var e;return null!=(e=tA.of(i))?e:""},{owner:this.scope}),this._rail.append(i);let s=document.createElement("div");s.className="u2-wizard-panel",s.style.display="none",s.setAttribute("role","group"),s.setAttribute("aria-labelledby",i.id),this._content.append(s);let a=this.scope.child("wizard-step"),l="function"==typeof e.content?e.content:void 0;l||s.append(e.content);let u=(null!=(t=e.actions)?t:[]).map(e=>{let t=this._button(e.text,()=>this._run(e.run));return tS.bind(t,()=>{var e;return null!=(e=tA.of(t))?e:""},{owner:this.scope}),this.effect(()=>{var i;return t.style.display=this._index.value===n&&(null==(i=e.visible)?void 0:i.value)!==!1?"":"none"}),this._footer.insertBefore(t,this._next),t});this._steps.push({options:e,marker:i,circle:r,panel:s,scope:a,actions:u,builder:l})}_run(e,t){let n;if(this._busy.peek())return;this._error.value=null;let i=new AbortController;try{n=this._call(()=>e({signal:i.signal}))}catch(e){this._fail(e);return}let r=P.Scope.thenable(n);if(void 0===r){null==t||t(n);return}this._pending=i,this._busy.value=!0;let o=e=>{this._pending!==i||this.scope.isDisposed||(this._pending=void 0,clearTimeout(this._abandon),this._abandon=void 0,(0,P.batch)(()=>{this._busy.value=!1,e()}))};r.then(e=>o(()=>null==t?void 0:t(e)),e=>o(()=>this._fail(e)))}_call(e){let t=this._owner;return(0,P.batch)(()=>P.Scope.runWith((null==t?void 0:t.isDisposed)?void 0:t,e))}_fail(e){(null==e?void 0:e.name)!=="AbortError"&&(this._error.value=e instanceof Error?e.message:String(e))}_guard(){let e=this._pending;void 0!==e&&(e.abort(),null!=this._abandon||(this._abandon=setTimeout(()=>{var t;this._abandon=void 0,this._pending!==e||this.scope.isDisposed||(this._pending=void 0,this._busy.value=!1,ra.warning(`${this._steps[this._index.peek()].options.title}: the step did not stop when cancelled and was abandoned`),null==(t=this._dialog)||t.close())},2e3)));return!this._busy.peek()}_applyStep(){let e=this._index.value,t=this._steps[e],n=this._failed.value;this._visited.add(t.options.id);for(let t=0;t<this._steps.length;t++){let i=this._steps[t],r=t===e,o=!r&&this._visited.has(i.options.id),s=o&&t<e;i.marker.classList.toggle("u2-wizard-step-current",r),i.marker.classList.toggle("u2-wizard-step-done",s),i.marker.classList.toggle("u2-wizard-step-failed",n.has(i.options.id));let a=r?null:o?t<=this._committed?rc.COMMITTED:null:rc.NOT_REACHED;tA.apply(i.marker,a),null===a&&i.marker.setAttribute("aria-disabled","false"),i.marker.tabIndex=r?0:-1,i.circle.textContent=n.has(i.options.id)?"!":s?"✓":String(t+1),i.panel.style.display=r?"":"none",r?i.marker.setAttribute("aria-current","step"):i.marker.removeAttribute("aria-current")}let i=!0===t.options.done,r=document.activeElement;i&&(r===this._next||null===r||r===document.body)&&t.marker.focus(),this._back.style.display=0===e||i?"none":"",void 0!==this._cancel&&(this._cancel.style.display=i?"none":""),(0,P.untracked)(()=>{this._error.value=null;let e=t.builder;e&&(t.builder=void 0,t.panel.append(t.scope.build(e)));let n=t.options.onActivate;if(n){var i;null==(i=t.visit)||i.dispose(),(t.visit=t.scope.child("wizard-visit")).run(()=>n(t.options))}this.fireEvent("step",t.options.id)})}_applyNextText(){var e,t;let n=this._index.value,i=this._steps[n].options,r="string"==typeof i.nextText?i.nextText:null==(t=i.nextText)?void 0:t.value,o=n===this._steps.length-1;this._next.textContent=o?!0===i.done?"CLOSE":null!=(e=i.finishText)?e:"FINISH":null!=r?r:"NEXT",this._next.classList.toggle("u2-btn-primary",!0!==i.done&&(o||void 0!==i.commit||void 0!==i.nextText))}_applyGate(){let e=this._blockReason.value,t=this._busy.value,n=this._steps[this._index.value],i=t?rc.WAITING:null;tA.apply(this._next,e),tA.apply(this._back,i),this.root.classList.toggle("u2-wizard-busy",t),this.root.setAttribute("aria-busy",String(t)),n.actions.forEach((e,t)=>tA.apply(e,null!=i?i:tA.read(n.options.actions[t].disabled)))}_finish(){let e=this._options.onFinish;void 0===e?this._complete():this._run(e,e=>!1!==e&&this._complete())}_complete(){this._completed.value=!0,this.fireEvent("finish"),this._dialog&&this._dialog.close()}_cancelled(){try{this._call(()=>{var e,t;return null==(e=(t=this._options).onCancel)?void 0:e.call(t)})}catch(e){this.scope.reportError(e)}this.fireEvent("cancel")}_button(e,t,n){return this.build(()=>tB(e,()=>t(),{primary:n}))}_focusStep(e){for(let t=0;t<this._steps.length;t++)this._steps[t].marker.tabIndex=t===e?0:-1;this._steps[e].marker.focus()}_onRailClick(e){let t=e.target.closest(".u2-wizard-step");t&&this.goTo(t.dataset.id)}_onRailKeyDown(e){let t,n=this._steps.findIndex(e=>e.marker===document.activeElement);if(n<0)return;let i=this._steps.length-1;switch(e.key){case"ArrowLeft":t=0===n?i:n-1;break;case"ArrowRight":t=n===i?0:n+1;break;case"Enter":case" ":e.preventDefault(),this.goTo(this._steps[n].options.id);return;default:return}e.preventDefault(),this._focusStep(t)}_onContentKeyDown(e){if("Enter"!==e.key||e.defaultPrevented)return;let t=this._steps[this._index.peek()],n=t===this._steps[this._steps.length-1];if(e.ctrlKey||e.metaKey){if(!n)return}else if(!iQ.entersDefault(e)||!0===t.options.done)return;e.preventDefault(),this.next()}static _gate(e){return"function"==typeof e?e()||null:tA.read(e)}constructor(e){super(),this.status=document.createElement("span"),this._idPrefix=`u2-wizard-${++rd}`,this._steps=[],this._visited=new Set,this._rail=document.createElement("ol"),this._content=document.createElement("div"),this._footer=document.createElement("div"),this._errorRow=document.createElement("span"),this._index=(0,P.signal)(0),this._completed=(0,P.signal)(!1),this._recheck=(0,P.signal)(0),this._busy=(0,P.signal)(!1),this._error=(0,P.signal)(null),this._failed=(0,P.signal)(new Set),this._committed=-1,this._options=e,this._owner=P.Scope.ambient,this.currentStep=(0,P.computed)(()=>this._steps[this._index.value].options.id),this.completed=this._completed,this.busy=this._busy,this.error=this._error,this._blockReason=(0,P.computed)(()=>(this._recheck.value,this._busy.value?rc.WAITING:rc._gate(this._steps[this._index.value].options.canProceed))),this.root.classList.add("u2-wizard"),this.root.dataset.u2="wizard",this._rail.className="u2-wizard-steps",this._rail.dataset.u2Part="steps",this._content.className="u2-wizard-content",this._content.dataset.u2Part="body",this._footer.className="u2-wizard-buttons",this._footer.dataset.u2Part="footer",this._errorRow.className="u2-wizard-error",this._errorRow.dataset.u2Part="error-row",this._errorRow.setAttribute("role","alert"),this._errorRow.hidden=!0,this.status.className="u2-wizard-status",this.status.dataset.u2Part="status";const t=document.createElement("span");t.className="u2-wizard-left",this._back=this._button("BACK",()=>this.back()),this._next=this._button("NEXT",()=>this.next()),tS.bind(this._next,()=>{var e;return null!=(e=this._blockReason.peek())?e:""},{owner:this.scope}),tS.bind(this._back,()=>{var e;return null!=(e=tA.of(this._back))?e:""},{owner:this.scope}),this._footer.append(t,this._back,this._next),this.root.append(this._rail,this._content,this._footer);const n=this.scope;n.listen(this._rail,"click",e=>this._onRailClick(e)),n.listen(this._rail,"keydown",e=>this._onRailKeyDown(e)),n.listen(this._content,"keydown",e=>this._onContentKeyDown(e));var i=!0,r=!1,o=void 0;try{for(var s,a=e.steps[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){const e=s.value;this._addStep(e)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}const l=void 0===e.start?0:e.steps.findIndex(t=>t.id===e.start);if(l<0)throw Error(`Wizard: no step "${e.start}" to start on`);var u=!0,d=!1,c=void 0;try{for(var h,p=e.steps.slice(0,l)[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){const e=h.value;this._visited.add(e.id)}}catch(e){d=!0,c=e}finally{try{u||null==p.return||p.return()}finally{if(d)throw c}}this._index.value=l,this._reason=this.build(()=>iX((0,P.computed)(()=>this._busy.value?null:this._blockReason.value))),this._reason.classList.add("u2-wizard-reason","u2-status-line-warning"),this._reason.dataset.u2Part="reason",t.append(this.status,this._reason,this._errorRow),this.effect(()=>this._applyStep()),this.effect(()=>this._applyNextText()),this.effect(()=>this._applyGate()),this.own(()=>clearTimeout(this._abandon)),this.effect(()=>{let e=this._error.value;this._errorRow.textContent=null!=e?e:"",this._errorRow.hidden=null===e})}}rc.WAITING="Wait for the running step to finish",rc.NOT_REACHED="Not reached yet: get there with NEXT",rc.COMMITTED="Already saved: it cannot be changed now";function rh(e){let t=document.createElement("table");t.className="u2-table u2-table-map",t.dataset.u2="table";let n=document.createElement("tbody");var i=!0,r=!1,o=void 0;try{for(var s,a=Object.keys(e)[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let t=s.value,i=document.createElement("tr");i.className="u2-table-row",i.dataset.u2Item=t;let r=document.createElement("td");r.className="u2-table-key",r.dataset.u2Part="item-label",r.textContent=t;let o=document.createElement("td"),a=e[t];a instanceof HTMLElement?o.append(a):o.textContent=ei.value(a),i.append(r,o),n.append(i)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}return t.append(n),t}new Intl.Collator(void 0,{numeric:!0});function rp(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function rf(e){return"string"==typeof e?e:e.value}function rm(e){return"string"==typeof e?e:e.label}class rg extends nC{setItems(e){this._items.value=e;let t=new Set(this.peek()),n=e.filter(e=>t.has(rf(e))).map(rf);n.length!==t.size&&(this.value=n)}getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={open:this._open.peek()},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}getItems(e){let t=new Set(this.peek()),n=new Set(this._rows.peek().map(rf));return nC.itemsState(this._items.peek().map((e,i)=>({key:rf(e),label:rm(e),index:i,selected:t.has(rf(e)),rendered:n.has(rf(e))})),null==e?void 0:e.all)}revealItem(e){var t,n=this,i=()=>super.revealItem;return(t=function*(){return this._openPopup(),this._filter.value="",i().call(n,e)},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){rp(o,i,r,s,a,"next",e)}function a(e){rp(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}displayText(){let e=new Map(this._items.peek().map(e=>[rf(e),rm(e)]));return this.peek().map(t=>{var n;return null!=(n=e.get(t))?n:t}).join(", ")}createEditor(){var e,t;this._id=`u2-multi-select-${++rg._seq}`,this._items=(0,P.signal)(this.options.items),this._filter=(0,P.signal)(""),this._open=(0,P.signal)(!1),this._machine=(0,P.signal)("idle"),this._activeIndex=(0,P.signal)(-1),this._optionSeq=0,this._visible=(0,P.computed)(()=>{let e=this._filter.value.trim().toLowerCase(),t=this._items.value;return e?t.filter(t=>rm(t).toLowerCase().includes(e)):t}),this._rows=(0,P.computed)(()=>this._open.value?this._visible.value:[]);let n=document.createElement("div");this._field=n,n.className="u2-multi-select-field",n.tabIndex=0,n.setAttribute("role","combobox"),n.setAttribute("aria-haspopup","listbox"),n.setAttribute("aria-controls",`${this._id}-listbox`),this._tagsBox=rg._row("u2-multi-select-tags","");let i=rg._row("u2-multi-select-chevron","");return n.append(this._tagsBox,i),this._popup=document.createElement("div"),this._popup.className="u2-multi-select-popup",this._popup.tabIndex=-1,this._focusEl=this._popup,(null!=(e=this.options.filterable)?e:!0===this.options.allowCustom||this.options.items.length>8)&&this._popup.append(this._buildFilter()),(null==(t=this.options.selectAll)||t)&&this._popup.append(this._buildSelectAll()),this._rowsBox=rg._row("u2-multi-select-options",""),this._rowsBox.id=`${this._id}-listbox`,this._rowsBox.setAttribute("role","listbox"),this._rowsBox.setAttribute("aria-multiselectable","true"),this._popup.append(this._rowsBox),this.scope.listen(n,"click",e=>this._onFieldClick(e)),this.scope.listen(n,"keydown",e=>this._onFieldKeyDown(e)),this.scope.listen(n,"focus",()=>this._send({type:"focus"})),this.scope.listen(n,"blur",()=>this._send({type:"blur"})),this.scope.listen(this._popup,"keydown",e=>this._onPopupKeyDown(e)),this.scope.listen(this._popup,"pointerdown",e=>this._onPopupPointerDown(e)),this.scope.listen(this._popup,tb,()=>this._send({type:"dismiss"})),this.effect(()=>{let e=this._open.value;n.setAttribute("aria-expanded",String(e)),n.classList.toggle("u2-multi-select-open",e)}),this.effect(()=>this._renderTags()),nL(this._rowsBox,this._rows,rf,e=>this._option(e),{empty:()=>rg._row("u2-multi-select-empty","No matches")}),this.effect(()=>this._applySelection()),this.effect(()=>this._applyActive()),n}_buildFilter(){let e=rg._row("u2-multi-select-filter",""),t=document.createElement("input");return this._filterEl=t,this._focusEl=t,t.className="u2-multi-select-filter-input",t.type="text",t.autocomplete="off",t.placeholder=this.options.allowCustom?"Filter or add…":"Filter…",t.setAttribute("aria-label","Filter options"),t.setAttribute("aria-controls",`${this._id}-listbox`),ed(t,this._filter,{owner:this.scope}),this.scope.listen(t,"input",()=>this._activeIndex.value=-1),e.append(t),e}_buildSelectAll(){let e=rg._row("u2-multi-select-all","");return e.setAttribute("role","button"),this._allRow=e,this._allLabel=rg._row("u2-multi-select-text","Select all"),e.append(rg._row("u2-multi-select-check",""),this._allLabel),e}_send(e){let t=this._machine.peek();switch(e.type){case"focus":"idle"===t&&(this._machine.value="focused");break;case"blur":"open"!==t&&(this._machine.value="idle");break;case"open":this._openPopup();break;case"toggleOpen":"open"===t?this._dismiss(!0):this._openPopup();break;case"arrowDown":"open"===t?this._move(1):this._openPopup();break;case"arrowUp":"open"===t&&this._move(-1);break;case"space":this._toggleAt(this._activeIndex.peek());break;case"enter":this.options.allowCustom&&this._addCustom()||this._dismiss(!0);break;case"escape":case"tab":this._dismiss(!0);break;case"dismiss":this._dismiss(!1);break;case"toggle":this._toggleAt(e.index);break;case"toggleAll":this._toggleAll()}}_openPopup(){this._open.peek()||(this._filter.value="",this._activeIndex.value=-1,this._machine.value="open",this._open.value=!0,this._closeOverlay=tx.show(this._field,this._popup,{owner:this.scope}),this._focusEl.focus())}_dismiss(e){if(!this._open.peek())return;this._open.value=!1,this._activeIndex.value=-1,this._machine.value=e?"focused":"idle";let t=this._closeOverlay;this._closeOverlay=void 0,t&&t(),e&&this._field.focus()}_move(e){let t=this._rows.peek().length;0!==t&&(this._activeIndex.value=Math.min(Math.max(this._activeIndex.peek()+e,0),t-1))}_toggleAt(e){let t=this._visible.peek();if(e<0||e>=t.length)return;let n=new Set(this.peek()),i=rf(t[e]);n.delete(i)||n.add(i),this._commit(n)}_toggleAll(){let e=this._visible.peek(),t=new Set(this.peek()),n=e.length>0&&e.every(e=>t.has(rf(e)));var i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;n?t.delete(rf(e)):t.add(rf(e))}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}this._commit(t)}_addCustom(){let e=this._filter.peek().trim();if(""===e)return!1;let t=this._items.peek(),n=e.toLowerCase(),i=t.find(e=>rf(e).toLowerCase()===n||rm(e).toLowerCase()===n);i||(this._items.value=[...t,e]);let r=new Set(this.peek());return r.add(i?rf(i):e),this._commit(r),this._filter.value="",!0}_commit(e){this.value=this._items.peek().filter(t=>e.has(rf(t))).map(rf)}_onFieldClick(e){e.target.closest(".u2-tag-remove")||this._send({type:"toggleOpen"})}_remove(e){let t=new Set(this.peek());t.delete(e),this._commit(t)}_onFieldKeyDown(e){switch(e.key){case"ArrowDown":case"Enter":case" ":e.preventDefault(),this._send({type:"open"});break;case"Escape":this._send({type:"escape"})}}_onPopupKeyDown(e){switch(e.key){case"ArrowDown":e.preventDefault(),this._send({type:"arrowDown"});break;case"ArrowUp":e.preventDefault(),this._send({type:"arrowUp"});break;case" ":if(0>this._activeIndex.peek()&&this._filterEl)break;e.preventDefault(),this._send({type:"space"});break;case"Enter":e.preventDefault(),this._send({type:"enter"});break;case"Escape":this._send({type:"escape"});break;case"Tab":this._send({type:"tab"})}}_onPopupPointerDown(e){let t=e.target,n=t.closest(".u2-multi-select-option");if(n){e.preventDefault(),this._send({type:"toggle",index:[...this._rowsBox.children].indexOf(n)});return}t.closest(".u2-multi-select-all")&&(e.preventDefault(),this._send({type:"toggleAll"}))}_renderTags(){let e=this.value,t=new Map(this._items.value.map(e=>[rf(e),rm(e)])),n=this._tagsBox;if(n.textContent="",0===e.length){let e=this.options.placeholder;e&&n.append(rg._row("u2-multi-select-placeholder",e));return}let i=null!=(a=this.options.maxTags)?a:3;var r=!0,o=!1,s=void 0;try{for(var a,l,u,d=e.slice(0,i)[Symbol.iterator]();!(r=(u=d.next()).done);r=!0){let e=u.value;n.append(iK(null!=(l=t.get(e))?l:e,{onRemove:()=>this._remove(e)}))}}catch(e){o=!0,s=e}finally{try{r||null==d.return||d.return()}finally{if(o)throw s}}e.length>i&&n.append(rg._row("u2-multi-select-more",`+${e.length-i} more`))}_option(e){let t=rg._row("u2-multi-select-option","");t.id=`${this._id}-opt-${++this._optionSeq}`,t.dataset.value=rf(e),t.setAttribute("role","option"),t.setAttribute("aria-selected","false");let n=rg._row("u2-multi-select-text",rm(e));return n.dataset.u2Part="item-label",t.append(rg._row("u2-multi-select-check",""),n),t}_applySelection(){let e=new Set(this.value),t=this._rows.value,n=this._rowsBox.children;for(let i=0;i<t.length;i++){let r=e.has(rf(t[i]));n[i].setAttribute("aria-selected",String(r)),n[i].classList.toggle("u2-multi-select-selected",r)}if(!this._allRow||!this._allLabel)return;let i=t.length>0&&t.every(t=>e.has(rf(t)));this._allRow.classList.toggle("u2-multi-select-selected",i),this._allLabel.textContent=i?"Select none":"Select all"}_applyActive(){let e=this._rows.value.length,t=this._rowsBox.children,n=this._activeIndex.value;for(let i=0;i<e;i++)t[i].classList.toggle("u2-multi-select-option-active",i===n);let i=n>=0&&n<e?t[n]:void 0;i?(this._focusEl.setAttribute("aria-activedescendant",i.id),i.scrollIntoView({block:"nearest"})):this._focusEl.removeAttribute("aria-activedescendant")}static _row(e,t){let n=document.createElement("div");return n.className=e,t&&(n.textContent=t),n}constructor(e){super(e,[]),this.isOpen=this._open,this.machineState=this._machine,this.root.dataset.u2="multi-select"}}rg._seq=0;class rv extends nC{get min(){return this.options.min}set min(e){this.options.min=null!=e?e:void 0,this._bounds()}get max(){return this.options.max}set max(e){this.options.max=null!=e?e:void 0,this._bounds()}get step(){return this.options.step}set step(e){this.options.step=null!=e?e:void 0,this._bounds()}createEditor(){let e=document.createElement("input");this._range=e,e.type="range",e.className="u2-slider-track",this._bounds();let t=!1;this.effect(()=>{var n;let i=this.value;t?t=!1:e.value=String(null!=(n=null!=i?i:this.options.min)?n:0)});let n=()=>{let n=this.peek();this.value=Number(e.value),t=!Object.is(this.peek(),n)};this.scope.listen(e,"input",()=>{"change"!==this.options.commitOn&&n(),tS.show(this._format(Number(e.value)),e)}),"change"===this.options.commitOn&&this.scope.listen(e,"change",n),tS.bind(e,()=>this.text,{owner:this.scope});let i=document.createElement("div");return i.className="u2-slider",i.append(e),i}_bounds(){var e,t,n,i;let r=null!=(e=this.options.min)?e:0,o=null!=(t=this.options.max)?t:100,s=this._range;s.min=String(r),s.max=String(o),s.step=String(null!=(n=this.options.step)?n:o>r?(o-r)/100:1),s.value=String(null!=(i=this.peek())?i:r)}get text(){let e=this.peek();return null==e?"":this._format(e)}_format(e){let t=this.options.format;return t?t(e):String(Math.round(100*e)/100)}constructor(e){super(void 0===e?{}:e,null),this.root.dataset.u2="slider-input"}}class rb extends nC{get items(){return this._items}set items(e){this.setItems(null!=e?e:[])}get itemTooltips(){return this.options.itemTooltips}set itemTooltips(e){this.options.itemTooltips=null!=e?e:void 0,this._fill(),this._apply(this.peek())}setItems(e){this._items=e,this._fill();let t=this.peek();this.value=null!=t&&e.includes(t)?t:null,this._apply(this.peek())}getItems(e){let t=this.peek();return nC.itemsState(this._items.map((e,n)=>({key:e,label:e,index:n,checked:e===t,rendered:!0})),null==e?void 0:e.all)}displayText(){var e;return null!=(e=this.peek())?e:""}createEditor(){this._name=`u2-radio-${++rb._seq}`,this._items=this.options.items;let e=document.createElement("div");return this._group=e,e.className="u2-radio",e.setAttribute("role","radiogroup"),this.options.buttons&&e.classList.add("u2-radio-buttons"),this._fill(),this.scope.listen(e,"change",()=>{let e=this._radios.find(e=>e.checked);this.value=e?e.value:null}),this.effect(()=>this._apply(this.value)),e}_fill(){let e=this.options.itemTooltips;this._group.textContent="",this._radios=[];var t=!0,n=!1,i=void 0;try{for(var r,o=this._items[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value,n=document.createElement("label");n.className="u2-radio-item",n.dataset.u2Item=t;let i=document.createElement("input");i.type="radio",i.name=this._name,i.value=t,i.dataset.value=t,i.className="u2-input-radio";let o=document.createElement("span");o.dataset.u2Part="item-label",o.textContent=t,n.append(i,o);let s=e?e[t]:void 0;s&&(n.title=s),this._group.append(n),this._radios.push(i)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}this.refreshDisabled()}_apply(e){var t=!0,n=!1,i=void 0;try{for(var r,o=this._radios[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.checked=t.value===e,t.parentElement.classList.toggle("u2-radio-pressed",t.checked)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}}constructor(e){super(e,null),this.root.dataset.u2="radio-input"}}rb._seq=0;let ry=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i;class r_ extends nC{createEditor(){this._bad=(0,P.signal)(!1);let e=document.createElement("input");this._text=e,e.type="text",e.autocomplete="off",e.spellcheck=!1,e.className="u2-color-text",e.placeholder="#rrggbb";let t=document.createElement("button");this._swatch=t,t.type="button",t.className="u2-color-swatch",t.setAttribute("aria-label","string"==typeof this.options.label?`Pick ${this.options.label}`:"Pick a color");let n=document.createElement("input");this._picker=n,n.type="color",n.className="u2-color-picker",n.tabIndex=-1,n.setAttribute("aria-hidden","true");let i=!1;this.effect(()=>{let t=this.value;i?i=!1:(e.value=t,this._bad.value=!1),this._paint(t)}),this.scope.listen(e,"input",()=>{let t=e.value.trim();this._bad.value=!ry.test(t),this._bad.peek()||t===this.peek()||(i=!0,this.value=t)}),this.scope.listen(n,"input",()=>{this._bad.value=!1,this.value=n.value}),this.scope.listen(t,"click",()=>n.click());let r=document.createElement("span");return r.className="u2-color-box",r.append(t,n),this.addRail(r,{edits:!0}),this.options.swatchOnly&&(this.root.classList.add("u2-color-box-only"),e.hidden=!0),this.addValidator(()=>this._bad.value?"Not a color":null),e}resetEditor(){this._bad.value=!1,this._text.value=this.peek(),this._paint(this.peek())}get unreadable(){return this._bad.value}_paint(e){this._swatch.style.background=e,this._picker.value=r_.toHex6(e)}static toHex6(e){let t=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);return t?`#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}`.toLowerCase():e.toLowerCase()}constructor(e){super(void 0===e?{}:e,"#000000"),this.root.dataset.u2="color-input"}}function rw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}let rx=[...tG,...tV],rk=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","PageUp","PageDown","Enter"]);class rS extends nC{getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={open:void 0!==this._popup},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}createEditor(){let e=t$("","u2-icon-input-preview"),t=t$("","u2-icon-input-name"),n=this._control=tR([e,t],"u2-icon-input");n.tabIndex=0;for(let e=0,t=[["role","button"],["aria-haspopup","listbox"],["aria-expanded","false"]];e<t.length;e++){var i;let r=function(e){if(Array.isArray(e))return e}(i=t[e])||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(i)||function(e){if(e){if("string"==typeof e)return rw(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return rw(e,2)}}(i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=r[0],s=r[1];n.setAttribute(o,s)}return this.effect(()=>{let n=this.value;e.replaceChildren(...n?[tK(n)]:[]),t.textContent=n||"—"}),this.scope.listen(n,"click",()=>this._toggle()),this.scope.listen(n,"keydown",e=>{let t=e.key;if(("Backspace"===t||"Delete"===t)&&this.nullable)this.value="";else{if("Enter"!==t&&" "!==t)return;this._toggle()}e.preventDefault()}),this.own(()=>this._close()),n}_toggle(){if(null!==this.disabled)return;if(this._popup)return this._close();let e=this._popup=new P.Scope;e.build(()=>{var t,n;let i=null!=(t=this.options.names)?t:rx,r=new nF({placeholder:"Search…",search:!0,inline:!0}),o=new nP({cellWidth:28,cellHeight:28,render:(e,t,n)=>(n.title=e,tK(e)),onActivate:e=>{this.value=e,this._close()}});e.effect(()=>{let e=r.value.trim().toLowerCase().replace(/\s+/g,"-");o.setItems(e?i.filter(t=>t.includes(e)):i)});let s=tj([r,o],"u2-icon-input-popup");e.listen(s,"keydown",e=>{rk.has(e.key)&&!o.root.contains(e.target)&&o.onKeyDown(e)}),e.listen(s,tb,()=>this._close()),tx.show(this._control,s,{owner:e}),this._control.setAttribute("aria-expanded","true"),null==(n=r.root.querySelector("input"))||n.focus()})}_close(){var e;null==(e=this._popup)||e.dispose(),this._popup=void 0,this._control.setAttribute("aria-expanded","false")}constructor(e){super(void 0===e?{}:e,""),this.root.dataset.u2="icon-input"}}function rC(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function rA(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return rC(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rC(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}class rO extends nC{getItems(e){return nC.itemsState(this._rows.map((e,t)=>{let n=rA(e,1)[0];return{key:rO._key(n,t),label:n,index:t,rendered:!0}}),null==e?void 0:e.all)}createEditor(){this._dup=(0,P.signal)(!1),this._keyless=(0,P.signal)(!1);let e=document.createElement("div");return this._body=e,e.className="u2-map",e.setAttribute("role","grid"),this.effect(()=>{let e=this.value;void 0!==this._rows&&rO._same(e,this._value())||this._load(e)}),this.scope.listen(e,"input",e=>this._onInput(e.target)),this.scope.listen(e,"click",e=>this._onClick(e.target)),this.addValidator(()=>this._dup.value?"Duplicate keys are not allowed":this._keyless.value?"A value needs its key":null),e}resetEditor(){this._load(this.peek())}_load(e){this._rows=Object.keys(e).map(t=>[t,e[t]]),0===this._rows.length&&this._rows.push(["",""]),this._render()}_render(){this._body.textContent="";for(let e=0;e<this._rows.length;e++)this._body.append(this._row(e));this._mark(),this.refreshDisabled()}_row(e){let t=document.createElement("div");t.className="u2-map-row",t.setAttribute("role","row"),t.dataset.u2Item=rO._key(this._rows[e][0],e);let n=document.createElement("div");return n.className="u2-map-actions",n.append(this._button(e,"add","plus","Add row"),this._button(e,"remove","minus","Remove row")),t.append(this._cell(e,0,"Key"),this._cell(e,1,"Value"),n),t}_cell(e,t,n){let i=document.createElement("input");return i.type="text",i.autocomplete="off",i.className=0===t?"u2-map-key":"u2-map-value",i.placeholder=n,i.setAttribute("aria-label",n),i.value=this._rows[e][t],i.dataset.row=String(e),i.dataset.part=String(t),i}_button(e,t,n,i){let r=document.createElement("button");return r.type="button",r.className="u2-map-btn",r.append(tK(n)),r.dataset.row=String(e),r.dataset.act=t,r.setAttribute("aria-label",i),r.title=i,r}_onInput(e){let t=e.dataset.part;if(void 0===t)return;let n=Number(e.dataset.row);this._rows[n][Number(t)]=e.value,"0"===t&&(e.closest(".u2-map-row").dataset.u2Item=rO._key(this._rows[n][0],n)),this._commit()}_onClick(e){let t=e.closest(".u2-map-btn");if(!t)return;let n=Number(t.dataset.row);"add"===t.dataset.act?this._rows.splice(n+1,0,["",""]):this._rows.splice(n,1),0===this._rows.length&&this._rows.push(["",""]),this._render(),this._commit()}_commit(){let e=this._value();this._mark(),this._dup.peek()||rO._same(this.peek(),e)||(this.value=e)}_value(){let e={};var t=!0,n=!1,i=void 0;try{for(var r,o=this._rows[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=rA(r.value,2),n=t[0],i=t[1];""!==n&&(e[n]=i)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return e}static _key(e,t){return""===e?`#${t}`:e}_mark(){let e=new Set,t=new Set;var n=!0,i=!1,r=void 0;try{for(var o,s=this._rows[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=rA(o.value,1)[0];""!==n&&(e.has(n)?t.add(n):e.add(n))}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}let a=t.size>0,l=this._rows.map(e=>{let t=rA(e,2),n=t[0],i=t[1];return""===n&&""!==i});this._dup.peek()!==a&&(this._dup.value=a),this._keyless.peek()!==l.includes(!0)&&(this._keyless.value=l.includes(!0));let u=this._body.querySelectorAll(".u2-map-key");for(let e=0;e<u.length;e++)u[e].classList.toggle("u2-invalid",t.has(this._rows[e][0])||l[e])}static _same(e,t){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;var i=!0,r=!1,o=void 0;try{for(var s,a=n[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let n=s.value;if(e[n]!==t[n])return!1}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}return!0}constructor(e){super(void 0===e?{}:e,{}),this.root.dataset.u2="map-input"}}function rE(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function rT(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function rP(e){return"string"==typeof e?e:e.value}function rN(e){return"string"==typeof e?e:e.label}let rI=["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"];class rM extends nC{get principals(){return this._principals.peek()}set principals(e){this.setPrincipals(e)}get principalLabel(){var e;return null!=(e=this.options.principalLabel)?e:"Group"}set principalLabel(e){this.options.principalLabel=null!=e?e:void 0,this.root.querySelector(".u2-access-grid th").textContent=this.principalLabel}get addText(){var e;return null!=(e=this.options.addText)?e:"+ add group or user…"}set addText(e){this.options.addText=null!=e?e:void 0;let t=this.root.querySelector(".u2-access-grid-add");null!==t&&(t.setAttribute("aria-label",this.addText),t.options.length>0&&(t.options[0].text=this.addText))}setPrincipals(e){this._principals.value=e}get disabled(){return super.disabled}set disabled(e){super.disabled=e,this._sweeps.value=this._sweeps.peek()+1}getItems(e){return nC.itemsState((0,P.untracked)(()=>this._rows()).map((e,t)=>rE({key:e.key,label:e.label,index:t,rendered:!0},null===e.from?{}:{disabled:!0})),null==e?void 0:e.all)}displayText(){return(0,P.untracked)(()=>this._rows()).filter(e=>null===e.from).map(e=>e.label).join(", ")}createEditor(){let e=this.options,t=e.principals,n=e.inherited,i=e.locked;this._capabilities=this.options.capabilities.map(e=>"string"==typeof e?{name:e,label:e.charAt(0).toUpperCase()+e.slice(1)}:e),this._principals=(0,P.signal)(Array.isArray(t)?t:[]),this._inherited=(0,P.signal)(Array.isArray(n)?n:[]),this._locked=(0,P.signal)(Array.isArray(i)?i:[]),this._sweeps=(0,P.signal)(0),this._keyNav=!1;let r=document.createElement("table");r.className="u2-access-grid",r.setAttribute("role","grid");let o=document.createElement("tr");o.append(rM._cell("th",null!=(u=this.options.principalLabel)?u:"Group"));var s=!0,a=!1,l=void 0;try{for(var u,d,c=this._capabilities[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let e=d.value;o.append(rM._cell("th",e.label,"u2-access-grid-cap"))}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}o.append(rM._cell("th","","u2-access-grid-action"));let h=document.createElement("thead");h.append(o),this._body=document.createElement("tbody");let p=rM._cell("td","");p.colSpan=this._capabilities.length+2;let f=document.createElement("tr");f.append(p);let m=document.createElement("tfoot");m.append(f),r.append(h,this._body,m);let g=this.options.picker;if(void 0!==g)p.append(g(e=>this._add(e.value,e.label)));else{let e=this._select();p.append(e),this.effect(()=>this._fillPicker(e))}return this.scope.listen(this._body,"change",e=>this._onChange(e.target)),this.scope.listen(this._body,"click",e=>this._onClick(e.target)),nL(this._body,()=>this._rows(),e=>e.key,e=>this._row(e),{update:(e,t)=>this._patch(e,t)}),r}_rows(){var e;this._sweeps.value;let t=this.disabled,n=this._locked.value,i=this._principals.value,r=e=>{let t=i.find(t=>rP(t)===e);return void 0===t?e:rN(t)};return[...this._inherited.value.map(e=>({key:`inherited:${e.principal}`,row:e,label:r(e.principal),from:e.from,off:t,locked:n})),...(null!=(e=this.value)?e:[]).map(e=>({key:e.principal,row:e,label:r(e.principal),from:null,off:t,locked:n}))]}_row(e){let t=document.createElement("tr");t.className=null===e.from?"u2-access-grid-row":"u2-access-grid-row u2-access-grid-inherited",t.setAttribute("role","row"),t.dataset.u2Key=e.row.principal;let n=rM._cell("td",""),i=null==(u=null!=(l=this.options.icon)?l:X.principalIcon)?void 0:u(e.row.principal);if(i){let e=t$("","u2-access-grid-icon");e.append(i),n.append(e)}let r=t$(e.label,"u2-access-grid-principal");r.dataset.u2Part="item-label",n.append(r),null!==e.from&&""!==e.from&&n.append(t$(e.from,"u2-access-grid-from")),t.append(n);var o=!0,s=!1,a=void 0;try{for(var l,u,d,c=this._capabilities[Symbol.iterator]();!(o=(d=c.next()).done);o=!0){let e=d.value,n=document.createElement("input");n.type="checkbox",n.className="u2-input-checkbox u2-access-grid-check",n.dataset.u2Key=e.name;let i=rM._cell("td","","u2-access-grid-cap");i.append(n),t.append(i)}}catch(e){s=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(s)throw a}}let h=rM._cell("td","","u2-access-grid-action");if(t.append(h),null===e.from){let e=document.createElement("button");e.type="button",e.className="u2-access-grid-remove",e.dataset.u2Key="remove",e.textContent="✕",h.append(e)}return this._patch(t,e),t}_patch(e,t){if((null!=(o=null==(a=e.querySelector(".u2-access-grid-from"))?void 0:a.textContent)?o:"")!==(null!=(s=t.from)?s:""))return!1;e.querySelector(".u2-access-grid-principal").textContent=t.label;var n=!0,i=!1,r=void 0;try{for(var o,s,a,l,u=e.querySelectorAll(".u2-access-grid-check")[Symbol.iterator]();!(n=(l=u.next()).done);n=!0){let e=l.value,n=this._capabilities.find(t=>t.name===e.dataset.u2Key),i=t.locked.includes(n.name);e.checked=!0===t.row.can[n.name]&&!i,e.disabled=null!==t.off||null!==t.from||i,tA.apply(e,null!==t.off?null:null!==t.from?rM.INHERITED:i?rM.LOCKED:null),e.setAttribute("aria-label",`${n.label} for ${t.label}`)}}catch(e){i=!0,r=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw r}}let d=e.querySelector(".u2-access-grid-remove");return null!==d&&(d.disabled=null!==t.off,d.setAttribute("aria-label",`Remove ${t.label}`)),!0}_select(){var e;let t=document.createElement("select");t.className="u2-access-grid-add",t.setAttribute("aria-label",null!=(e=this.options.addText)?e:"+ add group or user…");let n=()=>{this._keyNav=!1,this._add(t.value)};return this.scope.listen(t,"keydown",e=>{let i=e.key;"Enter"===i&&""!==t.value?(e.preventDefault(),e.stopPropagation(),n()):(rI.includes(i)||1===i.length)&&!e.altKey&&(this._keyNav=!0,this.scope.setTimeout(()=>this._keyNav=!1,0))}),this.scope.listen(t,"change",()=>{this._keyNav||n()}),this.scope.listen(t,"blur",()=>{this._keyNav=!1,t.value=""}),t}_fillPicker(e){let t=new Set([...null!=(s=this.value)?s:[],...this._inherited.value].map(e=>e.principal)),n=this._principals.value;e.textContent="",e.append(new Option(null!=(a=this.options.addText)?a:"+ add group or user…",""));var i=!0,r=!1,o=void 0;try{for(var s,a,l,u=n[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){let n=l.value;t.has(rP(n))||e.append(new Option(rN(n),rP(n)))}}catch(e){r=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(r)throw o}}e.value=""}_add(e,t){let n=null!=(u=this.peek())?u:[];if(""===e||null!==this.disabled||n.some(t=>t.principal===e))return;let i=this._locked.peek(),r=this._capabilities.find(e=>!i.includes(e.name)),o={};var s=!0,a=!1,l=void 0;try{for(var u,d,c=this._capabilities[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let e=d.value;o[e.name]=e===r}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}(0,P.batch)(()=>{void 0===t||this._principals.peek().some(t=>rP(t)===e)||(this._principals.value=[...this._principals.peek(),{value:e,label:t}]),this.value=[...n,{principal:e,can:o}]})}_onChange(e){var t;let n=e.dataset.u2Key,i=e.closest("tr"),r=null==i?void 0:i.dataset.u2Key;if(void 0===n||void 0===r)return;let o=i.classList.contains("u2-access-grid-inherited")||this._locked.peek().includes(n);if(null!==this.disabled||o){e.checked=!e.checked;return}this.value=(null!=(t=this.peek())?t:[]).map(t=>t.principal===r?rT(rE({},t),{can:rT(rE({},t.can),{[n]:e.checked})}):t)}_onClick(e){var t,n,i,r;let o=e.closest(".u2-access-grid-remove");if(null===o||null!==this.disabled)return;let s=o.closest("tr");if(s.contains(document.activeElement)){let e=[...this._body.querySelectorAll(".u2-access-grid-remove")],t=e.indexOf(o),s=this._body.parentElement.querySelector("tfoot").querySelector("input, select, button, [tabindex]");null==(r=null!=(n=null!=(i=e[t+1])?i:e[t-1])?n:s)||r.focus()}this.value=(null!=(t=this.peek())?t:[]).filter(e=>e.principal!==s.dataset.u2Key)}static _cell(e,t,n){let i=document.createElement(e);return i.textContent=t,void 0!==n&&(i.className=n),i}constructor(e){super(e,[]),this.root.dataset.u2="access-grid",this.liveOption("principals",e.principals,e=>this.setPrincipals(null!=e?e:[])),this.liveOption("inherited",e.inherited,e=>this._inherited.value=e),this.liveOption("locked",e.locked,e=>this._locked.value=e)}}function rL(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function rR(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}rM.INHERITED="Inherited: change it where it is granted",rM.LOCKED="This capability cannot be changed here";class rj extends H{setDisabled(e,t){let n=this._buttons.get(e);n&&tA.apply(n,t||null)}getState(){var e;let t=this.selected.peek();return rL(rR(rL({},super.getState()),{value:"single"===this._toggle?null!=(e=t[0])?e:null:t}),0===t.length?{}:{current:t[0]})}getItems(){let e=this.selected.peek(),t=this._items.map((t,n)=>{var i,r;return rR(rL({key:t.id,label:null!=(i=null!=(r=t.text)?r:t.tooltip)?i:t.id,index:n},"none"===this._toggle?{}:{selected:e.includes(t.id)}),{disabled:this._buttons.get(t.id).disabled,rendered:!0})});return{count:t.length,list:t,truncated:!1}}_build(e,t){var n;let i=tA.focusable(document.createElement("button"));if(i.type="button",i.className="u2-btn-group-item",i.dataset.id=e.id,i.dataset.u2Item=e.id,i.tabIndex=-1,e.icon&&i.append(tK(e.icon)),e.text&&!t){let t=document.createElement("span");t.className="u2-btn-group-label",t.dataset.u2Part="item-label",t.textContent=e.text,i.append(t)}let r=null!=(n=e.tooltip)?n:t?e.text:void 0;return tS.bind(i,()=>{var e,t;return null!=(e=null!=(t=tA.of(i))?t:r)?e:""},{owner:this.scope}),r&&t&&i.setAttribute("aria-label",r),"single"===this._toggle?(i.setAttribute("role","radio"),i.setAttribute("aria-checked","false")):"multi"===this._toggle&&i.setAttribute("aria-pressed","false"),tA.apply(i,e.disabled||null),this.scope.listen(i,"click",t=>this._activate(e,t)),this._buttons.set(e.id,i),i}_activate(e,t){if("single"===this._toggle)this.selected.value=[e.id];else if("multi"===this._toggle){let t=this.selected.peek();this.selected.value=t.includes(e.id)?t.filter(t=>t!==e.id):t.concat([e.id])}e.onClick&&e.onClick(t,this)}_applySelection(){let e=new Set(this.selected.value);var t=!0,n=!1,i=void 0;try{for(var r,o=this._items[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value,n=this._buttons.get(t.id),i=e.has(t.id);n.classList.toggle("u2-btn-group-selected",i),"single"===this._toggle?n.setAttribute("aria-checked",String(i)):"multi"===this._toggle&&n.setAttribute("aria-pressed",String(i))}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}}_stops(){return this._items.map(e=>this._buttons.get(e.id))}_roving(){let e=this._stops();var t=!0,n=!1,i=void 0;try{for(var r,o,s=this._buttons.values()[Symbol.iterator]();!(t=(o=s.next()).done);t=!0)o.value.tabIndex=-1}catch(e){n=!0,i=e}finally{try{t||null==s.return||s.return()}finally{if(n)throw i}}if(0===e.length)return;let a=null!=(r=e.find(e=>e.dataset.id===this._active))?r:e[0];this._active=a.dataset.id,a.tabIndex=0}_onFocusIn(e){let t=e.target;t.dataset&&this._buttons.has(t.dataset.id)&&(this._active=t.dataset.id,this._roving())}_onKeyDown(e){if("ArrowLeft"!==e.key&&"ArrowRight"!==e.key)return;let t=this._stops();if(0===t.length)return;e.preventDefault();let n=Math.max(t.findIndex(e=>e.dataset.id===this._active),0),i=t[(n+("ArrowRight"===e.key?1:-1)+t.length)%t.length];this._active=i.dataset.id,this._roving(),i.focus()}constructor(e){super(),this.selected=(0,P.signal)([]),this._buttons=new Map,this._items=e.items,this._toggle=null!=(o=e.toggle)?o:"none";const t=!0===e.iconOnly;this.root.classList.add("u2-btn-group",`u2-btn-group-${null!=(s=e.density)?s:"form"}`),t&&this.root.classList.add("u2-btn-group-icons"),this.root.dataset.u2="button-group",this.root.setAttribute("role","single"===this._toggle?"radiogroup":"group");var n=!0,i=!1,r=void 0;try{for(var o,s,a,l=this._items[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){const e=a.value;this.root.append(this._build(e,t))}}catch(e){i=!0,r=e}finally{try{n||null==l.return||l.return()}finally{if(i)throw r}}this.scope.listen(this.root,"keydown",e=>this._onKeyDown(e)),this.scope.listen(this.root,"focusin",e=>this._onFocusIn(e)),this.effect(()=>this._applySelection()),this._roving()}}let rD=new DataView(new ArrayBuffer(8)),r$=/^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/;class rF{static create(e,t){let n=void 0===t?rF.EXACT:t;return rD.setFloat64(0,e),rD.setUint8(7,252&rD.getUint8(7)|n),rD.getFloat64(0)}static less(e){return rF.create(e,rF.LESS)}static greater(e){return rF.create(e,rF.GREATER)}static getQ(e){return rD.setFloat64(0,e),3&rD.getUint8(7)}static getValue(e){return rD.setFloat64(0,e),rD.setUint8(7,252&rD.getUint8(7)),rD.getFloat64(0)}static qualifier(e){if(0===e||e===rF.EXACT)return"";if(e===rF.LESS)return"<";if(e===rF.GREATER)return">";throw Error(`Unknown qualifier type: ${e}`)}static parse(e){let t=e.replace(/^ +/,"");if(""===t)return null;let n=t[0],i="<"===n?rF.LESS:">"===n?rF.GREATER:rF.EXACT,r=(i===rF.EXACT?t:t.substring(1)).trim();return r$.test(r)?rF.create(Number(r),i):null}static format(e,t){if(null===e)return"";let n=rF.getValue(e);return rF.qualifier(rF.getQ(e))+(void 0===t?String(Number(n.toPrecision(15))):t(n))}}rF.LESS=1,rF.EXACT=2,rF.GREATER=3;class rz extends nC{createEditor(){this._bad=(0,P.signal)(!1);let e=document.createElement("input");this._input=e,e.type="text",e.autocomplete="off";let t=!1;return this.effect(()=>{let n=this.value;t?t=!1:e.value=rF.format(null!=n?n:null,this.options.format)}),this.scope.listen(e,"input",()=>{let e=this._parse();if(void 0===e||"change"===this.options.commitOn)return;let n=this.peek();this.value=e,t=!Object.is(this.peek(),n)}),this.scope.listen(e,"blur",()=>this._commit()),this.scope.listen(e,"keydown",e=>{"Enter"===e.key&&this._commit()}),this.addValidator(()=>this._bad.value?"Not a qualified number":null),e}get unreadable(){return this._bad.value}_commit(){var e;let t=this._parse();void 0!==t&&(this.value=t,this._input.value=rF.format(null!=(e=this.peek())?e:null,this.options.format))}_parse(){let e=this._input.value.trim(),t=""===e?null:rF.parse(e);return this._bad.value=""!==e&&null===t,this._bad.peek()?void 0:t}constructor(e){let t=void 0===e?{}:e;super(t,null),this.root.dataset.u2="qnum-input",this.liveOption("placeholder",t.placeholder,e=>this._input.placeholder=e)}}let rq=/^[+-]?\d+$/;class rB extends nC{static parse(e){let t=e.trim();return""===t?null:rq.test(t)?BigInt(t):void 0}createEditor(){var e;this._bad=(0,P.signal)(!1);let t=document.createElement("input");this._input=t,t.type="text",t.autocomplete="off",t.inputMode="numeric",t.placeholder=null!=(e=this.options.placeholder)?e:"";let n=!1;return this.effect(()=>{let e=this.value;n?n=!1:t.value=er(e)}),this.scope.listen(t,"input",()=>{let e=rB.parse(t.value);if(this._bad.value=void 0===e,void 0===e||"change"===this.options.commitOn)return;let i=this.peek();this.value=e,n=!Object.is(this.peek(),i)}),this.scope.listen(t,"blur",()=>this._commit()),this.scope.listen(t,"keydown",e=>{"Enter"===e.key&&this._commit()}),this.addValidator(()=>this._bad.value?"Not an integer":null),t}get unreadable(){return this._bad.value}_commit(){let e=rB.parse(this._input.value);void 0!==e&&(this.value=e,this._input.value=er(this.peek()))}constructor(e){super(void 0===e?{}:e,null),this.root.dataset.u2="bigint-input"}}let rG=["monospace","serif","sans-serif","cursive","fantasy","system-ui"],rV=["monospace","serif","cursive"],rU=[8,9,10,11,12,14,18,24,36,48,72,96],rH=["Monospace","Arial","Open Sans","Roboto"],rW="Roboto",rY=/^-?\d+$/;class rK extends nC{static parse(e){let t,n;if(!e)return null;let i=e.trim(),r=i.indexOf('"'),o=i.lastIndexOf('"');if(r>=0&&o>r){if(n=i.substring(r+1,o),3!==(t=i.substring(0,r).trim().split(" ").filter(e=>e)).length)return null}else if(4!==(t=i.split(" ").filter(e=>e)).length||(n=t[3].toLowerCase(),!rV.includes(n)))return null;let s=t[0].toLowerCase(),a=t[1].toLowerCase(),l=t[2].toLowerCase();if("bold"!==s&&"normal"!==s||"italic"!==a&&"normal"!==a||!l.endsWith("px"))return null;let u=l.substring(0,l.length-2);return rY.test(u)?{bold:"bold"===s,italic:"italic"===a,size:Number(u),family:n}:null}static compose(e){let t=e.bold?"bold":"normal",n=e.italic?"italic":"normal",i=""===e.family?rW:e.family,r=`${e.size}px`;return rG.includes(i.toLowerCase())?`${t} ${n} ${r} ${i.toLowerCase()}`:`${t} ${n} ${r} "${i}"`}createEditor(){this._id=`u2-font-${++rK._seq}`,this._font={bold:!1,italic:!1,size:10,family:rW};let e=document.createElement("input");this._size=e,e.type="text",e.autocomplete="off",e.className="u2-font-size",e.setAttribute("aria-label","Font size"),e.setAttribute("aria-controls",`${this._id}-sizes`);let t=this._step(-1,"Decrease font size"),n=this._step(1,"Increase font size");this._bold=this._toggle("B","Bold","u2-font-bold"),this._italic=this._toggle("I","Italic","u2-font-italic");let i=document.createElement("select");this._family=i,i.className="u2-font-family",i.setAttribute("aria-label","Font family");var r=!0,o=!1,s=void 0;try{for(var a,l,u,d=(null!=(a=this.options.families)?a:rH)[Symbol.iterator]();!(r=(u=d.next()).done);r=!0){let e=u.value;i.append(new Option(e,e))}}catch(e){o=!0,s=e}finally{try{r||null==d.return||d.return()}finally{if(o)throw s}}this._popup=document.createElement("div"),this._popup.className="u2-font-sizes",this._popup.id=`${this._id}-sizes`,this._popup.setAttribute("role","listbox");var c=!0,h=!1,p=void 0;try{for(var f,m=(null!=(l=this.options.sizes)?l:rU)[Symbol.iterator]();!(c=(f=m.next()).done);c=!0){let e=f.value,t=document.createElement("div");t.className="u2-font-size-option",t.dataset.size=String(e),t.dataset.u2Item=String(e),t.setAttribute("role","option"),t.textContent=String(e),this._popup.append(t)}}catch(e){h=!0,p=e}finally{try{c||null==m.return||m.return()}finally{if(h)throw p}}let g=!1;this.effect(()=>{let e=this.value;g?g=!1:this._apply(e)});let v=()=>{let e=rK.compose(this._font);e!==this.peek()&&(g=!0,this.value=e)};this.scope.listen(e,"input",()=>{let t=e.value.trim();this._font.size=rY.test(t)?Number(t):10,v()}),this.scope.listen(e,"mousedown",()=>this._toggleSizes()),this.scope.listen(e,"blur",()=>this._closeSizes()),this.scope.listen(i,"change",()=>{this._font.family=i.value,v()});let b=e=>{let t=this._font.size+e;t<0||(this._font.size=t,this._size.value=String(t),v())};this.scope.listen(t,"click",()=>b(-1)),this.scope.listen(n,"click",()=>b(1)),this.scope.listen(this._bold,"click",()=>{this._font.bold=!this._font.bold,this._paint(),v()}),this.scope.listen(this._italic,"click",()=>{this._font.italic=!this._font.italic,this._paint(),v()}),this.scope.listen(this._popup,"pointerdown",e=>{let t=e.target.closest(".u2-font-size-option");t&&(e.preventDefault(),this._font.size=Number(t.dataset.size),this._size.value=t.dataset.size,this._closeSizes(),v())}),this.scope.listen(this._popup,tb,()=>this._closeOverlay=void 0);let y=document.createElement("div");return y.className="u2-font",y.append(e,t,n,this._bold,this._italic,i),y}_step(e,t){let n=document.createElement("button");return n.type="button",n.className="u2-font-step",n.append(tK(e<0?"minus":"plus")),n.setAttribute("aria-label",t),n.title=t,n}_toggle(e,t,n){let i=document.createElement("button");return i.type="button",i.className=`u2-font-toggle ${n}`,i.textContent=e,i.setAttribute("aria-label",t),i.setAttribute("aria-pressed","false"),i}_apply(e){var t,n,i;let r=rK.parse(e);this._font={bold:null!=(t=null==r?void 0:r.bold)&&t,italic:null!=(n=null==r?void 0:r.italic)&&n,size:null!=(i=null==r?void 0:r.size)?i:10,family:r&&""!==r.family?r.family:rW},this._size.value=null===r?"":String(r.size),this._selectFamily(this._font.family),this._paint()}_selectFamily(e){if(!Array.from(this._family.querySelectorAll("option")).some(t=>t.value===e)){let t=new Option(e,e);t.hidden=!0,this._family.append(t)}this._family.value=e}_paint(){this._paintToggle(this._bold,this._font.bold),this._paintToggle(this._italic,this._font.italic)}_paintToggle(e,t){e.classList.toggle("u2-font-toggle-active",t),e.setAttribute("aria-pressed",String(t))}getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={open:void 0!==this._closeOverlay},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}getItems(e){var t;let n=void 0!==this._closeOverlay;return nC.itemsState((null!=(t=this.options.sizes)?t:rU).map((e,t)=>({key:String(e),label:String(e),index:t,selected:e===this._font.size,rendered:n})),null==e?void 0:e.all)}revealItem(e){return void 0===this._closeOverlay&&this._toggleSizes(),super.revealItem(e)}displayText(){return this.peek()}_toggleSizes(){this._closeOverlay?this._closeSizes():this._closeOverlay=tx.show(this._size,this._popup,{owner:this.scope})}_closeSizes(){let e=this._closeOverlay;this._closeOverlay=void 0,e&&e()}constructor(e){super(void 0===e?{}:e,rK.compose({bold:!1,italic:!1,size:10,family:rW})),this.root.dataset.u2="font-input"}}rK._seq=0;class rX extends nC{get alt(){var e;return null!=(e=this.options.alt)?e:""}set alt(e){this.options.alt=null!=e?e:void 0,this.root.querySelector(".u2-image-preview").alt=this.alt}createEditor(){var e;let t=document.createElement("img");t.className="u2-image-preview",t.alt=null!=(e=this.options.alt)?e:"";let n=document.createElement("button");n.type="button",n.className="u2-image-remove",n.textContent="REMOVE",this.scope.listen(n,"click",()=>this.value=""),this.effect(()=>{let e=this.value;t.src=e,t.hidden=""===e,n.hidden=""===e});let i=document.createElement("div");return i.className="u2-image",i.append(t,n),i}constructor(e){super(void 0===e?{}:e,""),this.root.dataset.u2="image-input"}}function rZ(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}class rQ extends nC{getState(){var e,t;return rZ((e=rZ({},super.getState()),t=t={open:this._list.isOpen.peek()},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e),this._source?{busy:"loading"===this._source.state.peek().kind}:{})}getItems(e){return nC.itemsState(this.peek().map((e,t)=>{let n=this._itemText(e);return{key:n,label:n,index:t,rendered:!0}}),null==e?void 0:e.all)}createEditor(){var e,t,n,i,r,o,s,a;let l=this.options.renderer;this._itemText=null!=(e=this.options.itemText)?e:l?e=>l.caption(e):e=>String(e),this._markup=null==l||null==(s=l.markup)?void 0:s.bind(l);let u=null!=(t=null==l||null==(a=l.listItem)?void 0:a.bind(l))?t:this._markup;this._renderItem=null!=(n=null!=(i=this.options.renderItem)?i:u)?n:e=>rn.row("u2-tags-text",this._itemText(e)),this._text=(0,P.signal)(""),this._buildView(),this._available=(0,P.computed)(()=>{let e=this._view.value;if("ready"!==e.kind)return[];let t=new Set(this.value.map(e=>this._itemText(e)));return e.items.filter(e=>!t.has(this._itemText(e)))});let d=document.createElement("div");d.className="u2-tags",this._chips=document.createElement("div"),this._chips.className="u2-tags-chips",this._chips.setAttribute("role","list");let c=document.createElement("input");return this._input=c,c.type="text",c.autocomplete="off",c.className="u2-tags-input",c.placeholder=null!=(r=this.options.placeholder)?r:"",c.setAttribute("role","combobox"),c.setAttribute("aria-autocomplete","list"),d.append(this._chips,c),this._list=new rn({prefix:"u2-tags",anchor:c,scope:this.scope,items:this._available,view:this._view,text:this._text,minChars:null!=(o=this.options.minChars)?o:0,render:e=>this._renderItem(e),keyOf:e=>this._itemText(e),onPick:e=>{this._accept(e),c.focus()},onDismiss:()=>this._list.dismiss(),onRetry:()=>{var e;return null==(e=this._source)?void 0:e.retry()}}),ed(c,this._text,{owner:this.scope}),this.scope.listen(c,"input",()=>this._onInput()),this.scope.listen(c,"keydown",e=>this._onKeyDown(e)),this.scope.listen(c,"blur",()=>this._list.dismiss()),this.scope.listen(d,"click",e=>{e.target.closest(".u2-tag-remove")||c.focus()}),this.effect(()=>c.setAttribute("aria-expanded",String(this._list.isOpen.value))),nL(this._chips,this.signal,e=>this._itemText(e),e=>this._chip(e)),d}_buildView(){var e;let t=this.options.source;if(t){let e=new eh(t,{debounceMs:this.options.debounceMs});this._source=e,this._view=e.state,this.own(()=>e.dispose()),this.effect(()=>{"loading"===e.state.value.kind?this.root.setAttribute("aria-busy","true"):this.root.removeAttribute("aria-busy")});return}let n=null!=(e=this.options.items)?e:[];this._view=(0,P.computed)(()=>{let e=this._text.value.trim().toLowerCase(),t=e?n.filter(t=>this._itemText(t).toLowerCase().includes(e)):n;return t.length>0?{kind:"ready",items:t}:{kind:"empty"}})}_onInput(){this._list.clearActive(),this._refresh(),this._list.open()}_refresh(){var e;this._source&&this._text.peek().length>=(null!=(e=this.options.minChars)?e:0)&&this._source.query(this._text.peek())}add(e){let t=this._itemText(e),n=this.peek();n.some(e=>this._itemText(e)===t)||(this.value=[...n,e]),this._text.value="",this._list.dismiss()}remove(e){let t=this._itemText(e);this.value=this.peek().filter(e=>this._itemText(e)!==t)}_accept(e){let t=this._available.peek()[e];return void 0!==t&&(this.add(t),!0)}_createFromText(){var e;let t=this._text.peek().trim();if(!this.options.allowNew||""===t)return!1;let n=null!=(e=this.options.createItem)?e:e=>e;return this.add(n(t)),!0}_removeLast(){let e=this.peek(),t=e[e.length-1];void 0!==t&&this._deletable(t)&&(this.value=e.slice(0,e.length-1))}_deletable(e){let t=this.options.deletable;return void 0===t||t(e)}_onKeyDown(e){switch(e.key){case"ArrowDown":e.preventDefault(),this._list.isOpen.peek()?this._list.move(1):(this._refresh(),this._list.open());break;case"ArrowUp":this._list.isOpen.peek()&&(e.preventDefault(),this._list.move(-1));break;case"Home":case"End":this._list.isOpen.peek()&&(e.preventDefault(),this._list.jump("Home"===e.key?0:this._list.rowCount-1));break;case"Enter":!e.ctrlKey&&!e.metaKey&&(this._accept(this._list.activeIndex.peek())||this._createFromText())&&(e.preventDefault(),e.stopPropagation());break;case"Escape":this._list.isOpen.peek()&&(e.stopPropagation(),this._list.dismiss());break;case"Tab":this._list.dismiss();break;case"Backspace":case"Delete":""===this._text.peek()&&this._removeLast()}}_chip(e){let t=iK(this._itemText(e),this._deletable(e)?{onRemove:()=>this.remove(e)}:void 0);t.classList.add("u2-tags-chip"),t.setAttribute("role","listitem");let n=t.querySelector(".u2-tag-text"),i=this._markup?this._markup(e):n;return i!==n&&n.replaceWith(i),i.dataset.u2Part="item-label",t}constructor(e){super(void 0===e?{}:e,[]),this.isOpen=this._list.isOpen,this.root.dataset.u2="tags-input"}}function rJ(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}class r0{static measure(e,t){var n;return(n=function*(){let n=performance.now(),i=t(),r=performance.now()-n,o=0;if(!r0._headless){let e=performance.now();document.body.append(i.root),yield new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),o=performance.now()-e,i.root.remove()}i.dispose();let s={label:e,construct:r,paint:o,total:r+o};return r0._entries.push(s),s},function(){var e=this,t=arguments;return new Promise(function(i,r){var o=n.apply(e,t);function s(e){rJ(o,i,r,s,a,"next",e)}function a(e){rJ(o,i,r,s,a,"throw",e)}s(void 0)})})()}static report(){return r0._entries.slice()}static get _headless(){var e,t;return(null==(t=globalThis.process)||null==(e=t.versions)?void 0:e.node)!==void 0}}r0._entries=[];let r2="Appearance",r1=[{name:"color",type:"string",inputType:"Color",description:"Text color; inherits down the subtree."},{name:"backgroundColor",type:"string",inputType:"Color",description:"Background color."},{name:"font",type:"string",inputType:"Font",description:'CSS font shorthand ("bold 14px Roboto").'},{name:"opacity",type:"double",min:0,max:1,step:.05,description:"0 transparent to 1 opaque."},{name:"cursor",type:"string",nullable:!0,choices:["default","pointer","not-allowed","wait","help","text","move","grab"],description:"Mouse cursor over the node."},{name:"textAlign",type:"string",nullable:!0,choices:["left","center","right"],description:"Horizontal text alignment."},{name:"padding",type:"string",description:'CSS padding ("8px 12px").'},{name:"margin",type:"string",description:"CSS margin."},{name:"border",type:"string",description:'CSS border ("1px solid var(--dg-border)").'},{name:"borderRadius",type:"string",description:'Corner radius ("4px").'},{name:"width",type:"string",description:'CSS width ("200px", "50%").'},{name:"height",type:"string",description:"CSS height."},{name:"pointerEvents",type:"string",nullable:!0,choices:["auto","none"],description:'"none" makes the node click-through.'}].map(e=>{var t,n;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},e),n=n={category:r2,bindable:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t});function r3(e,t,n,i){let r=H.is(e)?e:void 0,o=(null!=(u=null==r?void 0:r.root)?u:e).style;var s=!0,a=!1,l=void 0;try{for(var u,d,c=n[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let n=d.value.name,s=t[n];if(void 0!==s)if(s instanceof P.Signal){if(void 0===r){void 0!==i&&i.effect(()=>r5(e.style,n,s.value));continue}n in r||(r[n]=s),r.effect(()=>r5(r.root.style,n,s.value))}else r5(o,n,s)}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}}function r5(e,t,n){e[t]=null==n||""===n?"":String(n)}let r4="dg-ui/1",r6={name:"visible",type:"bool",description:"false hides the node; true by default."},r8={"u2-domain-":"@datagrok-libraries/ems — call installEms()","u2-manifest-":"@datagrok-libraries/ems — call installEms()"};class r9{use(e){let t=this._plugins.find(t=>t.plugin.name===e.name);if(void 0!==t)return t.plugin!==e&&console.warn(`u2 registry: "${e.name}" is installed already, from another copy — that one stays`),t.uninstall;let n=new Set(this._metas.keys());e.register(this);let i=[...this._metas.keys()].filter(e=>!n.has(e)),r={plugin:e,uninstall:()=>{let e=this._plugins.indexOf(r);if(!(e<0)){this._plugins.splice(e,1);var t=!0,n=!1,o=void 0;try{for(var s,a=i[Symbol.iterator]();!(t=(s=a.next()).done);t=!0){let e=s.value;this._metas.delete(e)}}catch(e){n=!0,o=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw o}}}}};return this._plugins.push(r),r.uninstall}plugins(){return this._plugins.map(e=>e.plugin)}missingTagHint(e){let t=this._plugins.find(t=>{var n;return null==(n=t.plugin.tagPrefixes)?void 0:n.some(t=>e.startsWith(t))});if(void 0!==t)return`${t.plugin.name} is installed and registers no such tag`;let n=Object.keys(r8).find(t=>e.startsWith(t));return void 0!==n?`it comes with ${r8[n]}`:e.startsWith("u2-")&&!this.builtins?"u2's components are not registered in this registry — call registerAll() first":null}register(e){var t,n,i;if(this._metas.has(e.tag))throw Error(`u2 registry: "${e.tag}" is already registered`);let r=e.create,o=e.createWithChildren,s=e.createComponent;if(!1===e.visual?void 0===s:void 0===r&&void 0===o)throw Error(`u2 registry: "${e.tag}" needs ${!1===e.visual?"createComponent":"create or createWithChildren"}`);let a=!1!==e.visual&&!1!==e.appearance,l=a?(t=e.props,r1.filter(e=>!t.some(t=>t.name===e.name))):[],u=a&&!e.props.some(e=>e.name===r6.name)?[r6]:[],d=(e,t)=>(r9._stamp(e,c,t),r3(e,t,l),u.length>0&&"boolean"==typeof t.visible&&(e.visible=t.visible),e),c=(n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},e),i=i={props:[...e.props,...u,...l],create:r?e=>d(r(e),e):void 0,createWithChildren:o?(e,t,n)=>d(o(e,t,n),e):void 0,createComponent:s?(e,t)=>r9._stamp(s(e,t),c,e):void 0},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}),n);this._metas.set(e.tag,c)}get(e){return this._metas.get(e)}metas(){return[...this._metas.values()]}manifest(){let e=[];var t=!0,n=!1,i=void 0;try{for(var r,o=this._metas.values()[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;t.create,t.createWithChildren,t.createComponent,t.adopt,t.carry,t.setChildProp,t.designerActions,t.icon;let n=function(e,t){if(null==e)return{};var n,i,r,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=0,n=Reflect.ownKeys(Object(e));r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i]);return o}if(o=function(e,t){if(null==e)return{};var n,i,r={},o=Object.getOwnPropertyNames(e);for(i=0;i<o.length;i++)n=o[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);return r}(e,t),Object.getOwnPropertySymbols)for(r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i]);return o}(t,["create","createWithChildren","createComponent","adopt","carry","setChildProp","designerActions","icon"]);n.props=n.props.filter(e=>!r1.includes(e)),e.push(n)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return{schema:r4,recipes:"docs/recipes/",binding:'Every declared prop accepts a "bind" entry and follows it live, except props marked structural, which read a bind once. A bind on an undeclared prop is an error.',appearance:r1,components:e}}static _stamp(e,t,n){return e.componentMeta=t,e.specProps=n,e}constructor(){this._metas=new Map,this._plugins=[],this.builtins=!1}}let r7=new r9;function oe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}let ot=/^[A-Za-z_$][A-Za-z0-9_$]*$/,on=/[A-Za-z0-9_$]/;function oi(e){if(!e.startsWith("$."))return null;let t=[],n=2,i=()=>{let i=n;for(;i<e.length&&on.test(e[i]);)i++;return i!==n&&!!ot.test(e.slice(n,i))&&(t.push(e.slice(n,i)),n=i,!0)};if(!i())return null;for(;n<e.length;)if("."===e[n]){if(n++,!i())return null}else{if("["!==e[n]||"'"!==e[n+1])return null;n+=2;let i="";for(;;){if(n>=e.length)return null;let t=e[n];if("\\"===t){let t=e[n+1];if("'"!==t&&"\\"!==t)return null;i+=t,n+=2}else if("'"===t){n++;break}else i+=t,n++}if("]"!==e[n])return null;n++,t.push(i)}return t}function or(e){let t=`$.${e[0]}`;var n=!0,i=!1,r=void 0;try{for(var o,s=e.slice(1)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;t+=ot.test(e)?`.${e}`:`['${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}']`}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}function oo(e,t){let n=`$.${t}`;if(!e.startsWith(n))return!1;let i=e.slice(n.length);return""===i||"."===i[0]||"["===i[0]}function os(e){return Array.isArray(e.children)?e.children.filter(e=>null!==e&&"object"==typeof e):[]}function oa(e,t){let n=[],i=e=>{(function(e,t){var n=!0,i=!1,r=void 0;try{for(var o,s,a,l=Object.values(null!=(o=e.bind)?o:{})[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){let e=a.value;if("string"==typeof e&&oo(e,t))return!0}}catch(e){i=!0,r=e}finally{try{n||null==l.return||l.return()}finally{if(i)throw r}}var u=!0,d=!1,c=void 0;try{for(var h,p=Object.values(null!=(s=e.on)?s:{})[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){let e=h.value,n="string"==typeof e?e:null==e?void 0:e.cmd;if("string"==typeof n&&n.startsWith(`cmd:${t}.`))return!0;if("string"!=typeof e){var f=!0,m=!1,g=void 0;try{for(var v,b,y=Object.values(null!=(v=null==e?void 0:e.args)?v:{})[Symbol.iterator]();!(f=(b=y.next()).done);f=!0){let e=b.value;if("string"==typeof e&&oo(e,t))return!0}}catch(e){m=!0,g=e}finally{try{f||null==y.return||y.return()}finally{if(m)throw g}}}}}catch(e){d=!0,c=e}finally{try{u||null==p.return||p.return()}finally{if(d)throw c}}return!1})(e,t)&&n.push(e);var r=!0,o=!1,s=void 0;try{for(var a,l=os(e)[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){let e=a.value;i(e)}}catch(e){o=!0,s=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw s}}};i(e.root);var r=!0,o=!1,s=void 0;try{for(var a,l,u=(null!=(a=e.components)?a:[])[Symbol.iterator]();!(r=(l=u.next()).done);r=!0){let e=l.value;i(e)}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}return n}function ol(e){let t=new Map,n=e=>{void 0===e.name||t.has(e.name)||t.set(e.name,e);var i=!0,r=!1,o=void 0;try{for(var s,a=os(e)[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;n(e)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}};n(e.root);var i=!0,r=!1,o=void 0;try{for(var s,a,l=(null!=(s=e.components)?s:[])[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let e=a.value;n(e)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}let u=new Map;var d=!0,c=!1,h=void 0;try{for(var p,f=t[Symbol.iterator]();!(d=(p=f.next()).done);d=!0){let e=(b=p.value,function(e){if(Array.isArray(e))return e}(b)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(b)||function(e){if(e){if("string"==typeof e)return oe(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return oe(e,2)}}(b)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),n=e[0],i=e[1],r=[];var m=!0,g=!1,v=void 0;try{for(var b,y,_,w,x=Object.values(null!=(y=i.bind)?y:{})[Symbol.iterator]();!(m=(w=x.next()).done);m=!0){let e=w.value,n="string"==typeof e?null==(_=oi(e))?void 0:_[0]:void 0;void 0!==n&&t.has(n)&&!r.includes(n)&&r.push(n)}}catch(e){g=!0,v=e}finally{try{m||null==x.return||x.return()}finally{if(g)throw v}}u.set(n,r)}}catch(e){c=!0,h=e}finally{try{d||null==f.return||f.return()}finally{if(c)throw h}}let k=new Map,S=[],C=e=>{k.set(e,"visiting"),S.push(e);var t=!0,n=!1,i=void 0;try{for(var r,o,s=(null!=(r=u.get(e))?r:[])[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){let e=o.value;if("visiting"===k.get(e))return[...S.slice(S.indexOf(e)),e];if(!k.has(e)){let t=C(e);if(t)return t}}}catch(e){n=!0,i=e}finally{try{t||null==s.return||s.return()}finally{if(n)throw i}}return S.pop(),k.set(e,"done"),null};var A=!0,O=!1,E=void 0;try{for(var T,P=t.keys()[Symbol.iterator]();!(A=(T=P.next()).done);A=!0){let e=T.value;if(!k.has(e)){let t=C(e);if(t)return t}}}catch(e){O=!0,E=e}finally{try{A||null==P.return||P.return()}finally{if(O)throw E}}return null}function ou(e){return"function"==typeof(null==e?void 0:e.bindStep)&&"function"==typeof(null==e?void 0:e.bindProps)}function od(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function oc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function oh(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return od(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return od(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let op=new WeakMap,of=new Set(["div","span","p","h1","h2","h3","a","img"]),om=new Set(["text","cls","href","src"]),og=new Set(["object","string","number","boolean"]);class ov{bindProps(){return Object.entries(this.data).map(e=>{let t=oh(e,2),n=t[0],i=t[1];return i instanceof P.Signal?{name:n,type:Y(i.peek()),writable:(0,P.isWritableSignal)(i)}:{name:n,walkable:!0}})}constructor(e){let t=void 0===e?{}:e;this.data={};const n=null!=(s=t.data)?s:{};var i=!0,r=!1,o=void 0;try{for(var s,a,l,u=Object.keys(n)[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){const e=l.value,t=n[e];this.data[e]=t instanceof P.Signal||ou(t)?t:(0,P.signal)(t)}}catch(e){r=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(r)throw o}}this.commands=null!=(a=t.commands)?a:{},this.callFunction=t.callFunction}}class ob extends H{_ambient(e){let t=e,n=this._registry.plugins();for(let e=n.length-1;e>=0;e--){let i=n[e].specAmbient;if(void 0!==i){let e=t;t=()=>i(this,e)}}return t()}dispose(){super.dispose(),this._nodes.clear(),this._named.clear(),this._elements.clear(),this._mounts.clear(),this._deferred.length=0}get spec(){return this._spec}get registry(){return this._registry}setDesignTime(e){var t;e!==this._designTime&&(this._designTime=e,this.rerenderAll(null!=(t=this._spec.components)?t:[]))}get designTime(){return this._designTime}dump(){var e;let t=null!=(e=this._spec.components)?e:[],n={$schema:r4};return t.length>0&&(n.components=t.map(e=>this._dump(e))),n.root=this._dump(this._spec.root),n}nodes(){return this._nodes}node(e){return this._named.get(e)}static elementOf(e){return H.is(e)?e.root:U.is(e)?void 0:e}nodeAt(e){for(let t=e;t;t=t.parentElement){let e=this._elements.get(t);if(e)return e}return null}parentOf(e){return e===this._spec.root?null:ob._parentOf(this._spec.root,e)}static contains(e,t){return null!==ob._parentOf(e,t)}resolveBinding(e){let t=oi(e);if(null===t)throw Error(`"${e}" is not a valid bind path`);let n=this._firstStep(t[0],e);var i=!0,r=!1,o=void 0;try{for(var s,a=t.slice(1)[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let t=s.value;if(n instanceof P.Signal)throw Error(`"${e}": cannot walk into "${t}" — the path continues past a signal`);let i=n.bindStep(t);if(null===i)throw Error(`"${e}": no binding step "${t}"`);n=i}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}for(let t=3;!(n instanceof P.Signal);t--){let i=n,r=t>0?i.bindStep(""):null;if(null===r){let t=i.bindProps().map(e=>e.name).join(", ");throw Error(`"${e}" needs one more step — one of: ${t}`)}n=r}return{signal:n,writable:(0,P.isWritableSignal)(n)}}_firstStep(e,t){var n;let i=null==(n=this._spec.components)?void 0:n.find(t=>t.name===e);if(i){let t=this._nodes.get(i);if(void 0!==t&&ou(t))return t;throw Error(`component "${e}" is not built`)}let r=this._named.get(e);if(void 0!==r){if(ou(r))return r;if(ob._isPlaceholder(r))throw Error(`component "${e}" is declared but not built`);throw Error(`"${e}" is not a bind source`)}let o=this.ctx.data[e];if(void 0!==o)return o;if(ob._declared(this._spec.root,e))throw Error(`component "${e}" is declared but not built`);throw Error(`nothing bound at "${t}"`)}static _eachName(e,t){void 0!==e.name&&t(e.name);var n=!0,i=!1,r=void 0;try{for(var o,s=os(e)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;ob._eachName(e,t)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}}static _declared(e,t){return e.name===t||os(e).some(e=>ob._declared(e,t))}_forwardRef(e){var t,n;let i=null==(n=oi(e))?void 0:n[0];return void 0!==i&&!this._named.has(i)&&void 0===this.ctx.data[i]&&!(null!=(t=this._spec.components)?t:[]).some(e=>e.name===i)&&ob._declared(this._spec.root,i)}_flushLinks(){var e=!0,t=!1,n=void 0;try{for(var i,r=this._deferred.splice(0)[Symbol.iterator]();!(e=(i=r.next()).done);e=!0){let e=i.value,t=this._mounts.get(e.node);if(void 0!==t&&!t.scope.isDisposed&&this._nodes.get(e.node)===e.built)try{let n=this.resolveBinding(e.path),i=n.signal,r=n.writable;if("apply"===e.kind){t.scope.build(()=>e.apply(i));continue}e.twoWay&&!r&&this._warn(`bind "${e.path}" is read-only — edits will not flow back`),t.scope.build(()=>ob._link(e.built,e.name,e.proxy,i,e.twoWay&&r))}catch(t){this._warn(`${e.node.tag}: ${t instanceof Error?t.message:String(t)}`)}}}catch(e){t=!0,n=e}finally{try{e||null==r.return||r.return()}finally{if(t)throw n}}}static _link(e,t,n,i,r){if(e.bindStep(t)instanceof P.Signal)return void e.link(t,i,r);let o=P.Scope.ambient;o.effect(()=>{let e=i.value;U.sameValue(n.peek(),e)||(n.value=e)}),r&&o.effect(()=>{let e=n.value;U.sameValue(i.peek(),e)||(i.value=e)})}rerender(e){let t=this._nodes.get(e);if(void 0===t)throw Error("u2 spec: rerender of a node that is not rendered");if(this._cycle=ol(this._spec),this._isComponent(e)){this._unmount(e),this._mountComponent(e),this._pending.includes(e)||this._pending.push(e),this._batching||this._flushStarts();return}let n=ob.elementOf(t),i=this.parentOf(e),r=this._carried(e);this._unmount(e);let o=i?this._mounts.get(i).scope:this.scope,s=i?this._registry.get(i.tag):void 0,a=o.build(()=>this._render(e,s));var l=!0,u=!1,d=void 0;try{for(var c,h=r[Symbol.iterator]();!(l=(c=h.next()).done);l=!0){let e=oh(c.value,3),t=e[0],n=e[1],i=e[2],r=this._nodes.get(t);void 0!==r&&n(t,i,r)}}catch(e){u=!0,d=e}finally{try{l||null==h.return||h.return()}finally{if(u)throw d}}n.replaceWith(ob._element(a)),this._batching||this._flushStarts()}_carried(e){let t=[],n=e=>{let i=null==(l=this._registry.get(e.tag))?void 0:l.carry,r=this._nodes.get(e);void 0!==i&&void 0!==r&&t.push([e,i,r]);var o=!0,s=!1,a=void 0;try{for(var l,u,d=os(e)[Symbol.iterator]();!(o=(u=d.next()).done);o=!0){let e=u.value;n(e)}}catch(e){s=!0,a=e}finally{try{o||null==d.return||d.return()}finally{if(s)throw a}}};return n(e),t}rerenderAll(e){let t=[],n=e=>{if(!this._nodes.has(e))return;let n=this.renderRootOf(e);t.includes(n)||t.push(n)};var i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;n(e)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}let l=new Set;for(let e=0;e<t.length;e++)ob._eachName(t[e],e=>{if(!l.has(e)){l.add(e);var t=!0,i=!1,r=void 0;try{for(var o,s=oa(this._spec,e)[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){let e=o.value;n(e)}}catch(e){i=!0,r=e}finally{try{t||null==s.return||s.return()}finally{if(i)throw r}}}});this._batching=!0;try{let e=t.filter((e,n)=>!t.some((t,i)=>i!==n&&ob.contains(t,e)));var u=!0,d=!1,c=void 0;try{for(var h,p=e.sort((e,t)=>Number(this._isComponent(t))-Number(this._isComponent(e)))[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){let e=h.value;this.rerender(e)}}catch(e){d=!0,c=e}finally{try{u||null==p.return||p.return()}finally{if(d)throw c}}}finally{this._batching=!1}this._flushStarts()}renderRootOf(e){let t=e;for(;;){let e=this.parentOf(t),n=e?this._registry.get(e.tag):void 0;if(!e||!n||void 0===n.adopt&&void 0===n.createWithChildren)return t;t=e}}mountComponent(e){this._cycle=ol(this._spec),this._mountComponent(e),this._pending.push(e)}unmountComponent(e){this._unmount(e)}_isComponent(e){var t;return(null==(t=this._spec.components)?void 0:t.includes(e))===!0}_mountComponent(e){this._mount(e,this.scope).build(()=>this._ambient(()=>{let t=this._buildComponent(e);this._nodes.set(e,t),void 0===e.name?this._warn(`${e.tag}: a component without a name cannot be bound to`):this._name(e,t)}))}_flushStarts(){this._flushLinks();let e=this._pending.splice(0);var t=!0,n=!1,i=void 0;try{for(var r,o=e[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value;this._nodes.has(e)&&this._start(e)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}}_start(e){let t=this._nodes.get(e);if("function"==typeof(null==t?void 0:t.start))try{t.start()}catch(t){this._warn(`${e.tag}: ${t instanceof Error?t.message:String(t)}`)}}_buildComponent(e){try{let l=this._registry.get(e.tag);if(void 0===l){let t=this._unknownTag(e.tag,"is not a registered component");throw this._warn(`${e.tag}: ${t}`),Error(t)}if(!l.createComponent)throw Error("is a visual component — it belongs in the form");ob._shape(e),this._children(e,l,!1),this._noCycle(e);let u=this._props(e,l),d=[],c=[];var t=!0,n=!1,i=void 0;try{for(var r,o,s,a=Object.entries(null!=(r=e.bind)?r:{})[Symbol.iterator]();!(t=(s=a.next()).done);t=!0){let t=oh(s.value,2),n=t[0],i=t[1],r=n.indexOf(".");if(r>=0){if(!(null==(o=ob._prop(l,n.slice(0,r)))?void 0:o.subBindable))throw Error(`prop "${n.slice(0,r)}" does not take sub-binds`);continue}let a=ob._prop(l,n);if(!a)throw Error(`has no prop "${n}" to bind`);a.bindable||a.subBindable||this._bindOnce(e,a,i,u,d,c)}}catch(e){n=!0,i=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw i}}let h=l.createComponent(u,{designTime:this._designTime,subBinds:oc({},e.bind),resolve:t=>{try{return this.resolveBinding(t).signal}catch(t){return this._warn(`${e.tag}: ${t instanceof Error?t.message:String(t)}`),null}}});return this._followProps(e,h,this._mounts.get(e).scope,d,c),h}catch(t){return ob._placeholder(`${e.tag}: ${t instanceof Error?t.message:String(t)}`)}}_unknownTag(e,t){let n=this._registry.missingTagHint(e);return null===n?t:`${t}; ${n}`}_render(e,t){return this._mount(e).build(()=>{let n=this._build(e,t),i=ob._element(n);return this._nodes.set(e,n),this._elements.set(i,e),void 0!==e.name&&(i.dataset.u2Name=e.name,this._name(e,n)),n})}_mount(e,t){let n=void 0===t?null!=(p=P.Scope.ambient)?p:this.scope:t,i=new P.Scope,r=()=>i.dispose();return n.own(r),this._mounts.set(e,{scope:i,release:()=>{i.dispose(),n.disown(r)}}),i}_name(e,t){this._named.has(e.name)?this._warn(`${e.tag}: duplicate name "${e.name}"`):this._named.set(e.name,t)}_unmount(e){this._mounts.get(e).release();let t=new Set;var n=!0,i=!1,r=void 0;try{for(var o,s=Array.from(this._mounts)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=oh(o.value,2),n=e[0];if(!e[1].scope.isDisposed)continue;let i=this._nodes.get(n);if(void 0!==i){t.add(i),this._nodes.delete(n);let e=ob.elementOf(i);e&&this._elements.delete(e)}this._mounts.delete(n)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}var a=!0,l=!1,u=void 0;try{for(var d,c=Array.from(this._named)[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){let e=oh(d.value,2),n=e[0],i=e[1];t.has(i)&&this._named.delete(n)}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}}_build(e,t){try{ob._shape(e);let a=ob._commands(e),l=this._registry.get(e.tag),u=l?this._component(e,l,t):this._html(e,t);var n=!0,i=!1,r=void 0;try{for(var o,s=a[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let t=oh(o.value,2),n=t[0],i=t[1];this._listen(e,u,n,i)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return u}catch(t){return ob._placeholder(`${e.tag}: ${t instanceof Error?t.message:String(t)}`)}}_component(e,t,n){if(!1===t.visual)throw Error("is a data source — it belongs on the components tray");this._noCycle(e);let i=this._props(e,t,n);op.delete(e);let r=[],o=[],s=[],a=[];var l=!0,u=!1,d=void 0;try{for(var c,h,p,f,m=Object.entries(null!=(c=e.bind)?c:{})[Symbol.iterator]();!(l=(f=m.next()).done);l=!0){let l=oh(f.value,2),u=l[0],d=l[1],c=u.indexOf(".");if(c>=0&&(null==(p=ob._prop(t,u.slice(0,c)))?void 0:p.subBindable))continue;let h=ob._prop(t,u,n);if(!h)throw Error(`has no prop "${u}" to bind`);if(h.bindable){if(this._forwardRef(d)){let e=(0,P.signal)(void 0);i[u]=e,o.push([u,d,!0===h.twoWay,e]);continue}let e=this.resolveBinding(d),t=e.signal,n=e.writable;i[u]=t,h.twoWay&&(n||this._warn(`bind "${d}" is read-only — edits will not flow back`),r.push([u,t,n]))}else ob._childProp(n,u)===h?this._childBind(e,h,d):this._bindOnce(e,h,d,i,s,a)}}catch(e){u=!0,d=e}finally{try{l||null==m.return||m.return()}finally{if(u)throw d}}let g=t.createWithChildren?t.createWithChildren(i,this._children(e,t,!0),null!=(h=e.children)?h:[]):this._adopt(e,t,t.create(i));var v=!0,b=!1,y=void 0;try{for(var _,w=r[Symbol.iterator]();!(v=(_=w.next()).done);v=!0){let e=oh(_.value,3),t=e[0],n=e[1],i=e[2];g.link(t,n,i)}}catch(e){b=!0,y=e}finally{try{v||null==w.return||w.return()}finally{if(b)throw y}}var x=!0,k=!1,S=void 0;try{for(var C,A=o[Symbol.iterator]();!(x=(C=A.next()).done);x=!0){let t=oh(C.value,4),n=t[0],i=t[1],r=t[2],o=t[3];this._deferred.push({node:e,built:g,kind:"link",name:n,path:i,twoWay:r,proxy:o})}}catch(e){k=!0,S=e}finally{try{x||null==A.return||A.return()}finally{if(k)throw S}}let O=P.Scope.ambient;return this._followProps(e,g,O,s,a),this._followChildren(e,t,g,O),g}_bindOnce(e,t,n,i,r,o){let s=t.name;if(this._forwardRef(n))return void(t.structural?this._warn(`${e.tag}.${s} is structural — "${n}" names a node declared later, so it is not read`):o.push([s,n]));let a=this.resolveBinding(n).signal;i[s]=a.peek(),t.structural?this._warn(`${e.tag}.${s} is structural — a bind is read once`):r.push([s,a])}_followProps(e,t,n,i,r){var o=!0,s=!1,a=void 0;try{for(var l,u=i[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){let i=oh(l.value,2),r=i[0],o=i[1],s=this._setter(e,t,r);null!==s&&ob._follow(n,o,s,!1)}}catch(e){s=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(s)throw a}}var d=!0,c=!1,h=void 0;try{for(var p,f=r[Symbol.iterator]();!(d=(p=f.next()).done);d=!0){let i=oh(p.value,2),r=i[0],o=i[1],s=this._setter(e,t,r);null!==s&&this._deferred.push({node:e,built:t,kind:"apply",name:r,path:o,twoWay:!1,apply:e=>ob._follow(n,e,s,!0)})}}catch(e){c=!0,h=e}finally{try{d||null==f.return||f.return()}finally{if(c)throw h}}}_setter(e,t,n){var i;let r=null==(i=t.getProperties().find(e=>e.name===n))?void 0:i.set;return null==r?(this._warn(`${e.tag}.${n} has no live setter — a bind is read once`),null):e=>r(t.propertyTarget,e)}static _follow(e,t,n,i){let r=!i;e.effect(()=>{let e=t.value;if(r){r=!1;return}(0,P.untracked)(()=>n(e))})}_childBind(e,t,n){var i,r,o,s;let a={},l=[],u=[];this._bindOnce(e,t,n,a,l,u);let d={value:a[t.name],source:null==(i=l[0])?void 0:i[1],path:null==(r=u[0])?void 0:r[1]};op.set(e,(o=oc({},op.get(e)),s=s={[t.name]:d},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(s)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(s)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(s,e))}),o))}_followChildren(e,t,n,i){var r=!0,o=!1,s=void 0;try{for(var a,l,u=(null!=(a=e.children)?a:[]).entries()[Symbol.iterator]();!(r=(l=u.next()).done);r=!0){let r=oh(l.value,2),o=r[0],s=r[1];var d=!0,c=!1,h=void 0;try{for(var p,f,m=Object.entries(null!=(p=op.get(s))?p:{})[Symbol.iterator]();!(d=(f=m.next()).done);d=!0){let r=oh(f.value,2),s=r[0],a=r[1];if(void 0===a.source&&void 0===a.path)continue;let l=t.setChildProp;if(void 0===l){this._warn(`${t.tag}: child prop "${s}" has no live setter — a bind is read once`);continue}let u=e=>l(n,o,s,e);void 0!==a.source?ob._follow(i,a.source,u,!1):this._deferred.push({node:e,built:n,kind:"apply",name:s,path:a.path,twoWay:!1,apply:e=>ob._follow(i,e,u,!0)})}}catch(e){c=!0,h=e}finally{try{d||null==m.return||m.return()}finally{if(c)throw h}}}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}}_props(e,t,n){let i={};var r=!0,o=!1,s=void 0;try{for(var a,l,u=Object.entries(null!=(a=e.props)?a:{})[Symbol.iterator]();!(r=(l=u.next()).done);r=!0){let r=oh(l.value,2),o=r[0],s=r[1],a=ob._prop(t,o,n);a||this._warn(`${e.tag}: unknown prop "${o}"`),i[o]=a?ob._checked(a,s):s}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}return i}_noCycle(e){if(void 0!==e.name&&null!==this._cycle&&this._cycle.includes(e.name))throw Error(`binding cycle: ${this._cycle.join(" → ")}`)}static _shape(e){var t=!0,n=!1,i=void 0;try{for(var r,o,s=Object.entries(null!=(r=e.bind)?r:{})[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){let e=oh(o.value,2),t=e[0],n=e[1];if("string"!=typeof n)throw Error(`bind "${t}" must be a "$." path string`)}}catch(e){n=!0,i=e}finally{try{t||null==s.return||s.return()}finally{if(n)throw i}}let a=e.children;if(void 0!==a){if(!Array.isArray(a))throw Error('"children" must be an array of nodes');var l=!0,u=!1,d=void 0;try{for(var c,h=a.entries()[Symbol.iterator]();!(l=(c=h.next()).done);l=!0){let e=oh(c.value,2),t=e[0],n=e[1];if(null===n||"object"!=typeof n||"string"!=typeof n.tag)throw Error(`children[${t}] is not a node with a "tag"`)}}catch(e){u=!0,d=e}finally{try{l||null==h.return||h.return()}finally{if(u)throw d}}}}_html(e,t){if(!of.has(e.tag))throw Error(this._unknownTag(e.tag,"neither a registered component nor a supported HTML tag"));let n=document.createElement(e.tag),i=[],r=(e,t)=>{"text"===e?n.textContent=null==t?"":String(t):"cls"===e?(n.classList.remove(...i),i=String(null!=t?t:"").split(/\s+/).filter(e=>e),n.classList.add(...i)):null==t||""===t?n.removeAttribute(e):n.setAttribute(e,String(t))},o={};var s=!0,a=!1,l=void 0;try{for(var u,d,c,h=Object.entries(null!=(u=e.props)?u:{})[Symbol.iterator]();!(s=(c=h.next()).done);s=!0){let n=oh(c.value,2),i=n[0],s=n[1];if(!om.has(i)){let n=r1.find(e=>e.name===i);if(n){o[i]=ob._checked(n,s);continue}ob._childProp(t,i)||this._warn(`${e.tag}: unknown prop "${i}"`);continue}if("string"!=typeof s)throw Error(`prop "${i}" expects string`);r(i,s)}}catch(e){a=!0,l=e}finally{try{s||null==h.return||h.return()}finally{if(a)throw l}}op.delete(e);let p=P.Scope.ambient;r3(n,o,r1,p);let f=ow(e.tag),m=(e,t)=>{r1.some(t=>t.name===e)?r3(n,{[e]:t},r1,p):p.effect(()=>r(e,t.value))};var g=!0,v=!1,b=void 0;try{for(var y,_=Object.entries(null!=(d=e.bind)?d:{})[Symbol.iterator]();!(g=(y=_.next()).done);g=!0){let i=oh(y.value,2),r=i[0],o=i[1],s=f.some(e=>e.name===r),a=ob._childProp(t,r);if(!s&&!a)throw Error(`has no prop "${r}" to bind`);if(!s){this._childBind(e,a,o);continue}if(this._forwardRef(o)){this._deferred.push({node:e,built:n,kind:"apply",name:r,path:o,twoWay:!1,apply:e=>m(r,e)});continue}m(r,this.resolveBinding(o).signal)}}catch(e){v=!0,b=e}finally{try{g||null==_.return||_.return()}finally{if(v)throw b}}var w=!0,x=!1,k=void 0;try{for(var S,C=this._children(e,void 0,!0)[Symbol.iterator]();!(w=(S=C.next()).done);w=!0){let e=S.value;n.append(ob._element(e))}}catch(e){x=!0,k=e}finally{try{w||null==C.return||C.return()}finally{if(x)throw k}}return n}_adopt(e,t,n){let i=!0===t.acceptsChildren||void 0!==t.adopt,r=this._children(e,t,i);for(let e=0;e<r.length;e++)t.adopt?t.adopt(n,r[e],e):n.root.append(ob._element(r[e]));return n}_children(e,t,n){var i;let r=null!=(i=e.children)?i:[];return r.length>0&&!n?(this._warn(`${e.tag}: takes no children — ${r.length} dropped`),[]):r.map(e=>this._render(e,t))}_listen(e,t,n,i){var r;let o=()=>this._fire(e,i),s=null!=(r=P.Scope.ambient)?r:this.scope;if(H.is(t)){let e=t.onEvent(n).subscribe(o);s.own(()=>e.unsubscribe());return}s.listen(t,n,o)}_fire(e,t){let n,i=("string"==typeof t?t:t.cmd).slice(4);try{n="string"==typeof t?{}:this._args(t.args)}catch(t){this._warn(`${e.tag}: ${t instanceof Error?t.message:String(t)}`);return}if(i.startsWith("#"))return void this._warn(`${e.tag}: "cmd:${i}" is reserved — code-behind commands arrive with dg-form`);if(i.includes(":"))return void(this.ctx.callFunction?this.ctx.callFunction(i,n):this._warn(`${e.tag}: no function runner for "${i}"`));if(i.includes(".")){let t=i.indexOf("."),r=i.slice(0,t),o=i.slice(t+1),s=this._named.get(r),a=U.is(s)?s.getFunctions().find(e=>e.name===o):void 0;a?a.apply(n):this._warn(`${e.tag}: no function "${o}" on "${r}"`);return}let r=this.ctx.commands[i];"function"==typeof r?r():this.ctx.callFunction?this.ctx.callFunction(i,n):this._warn(`${e.tag}: no command "${i}"`)}_args(e){let t={};var n=!0,i=!1,r=void 0;try{for(var o,s=Object.entries(null!=e?e:{})[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=oh(o.value,2),n=e[0],i=e[1];t[n]="string"!=typeof i?i:i.startsWith("$.")?this.resolveBinding(i).signal.peek():i.startsWith("$$.")?i.slice(1):i}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}_dump(e){let t={tag:e.tag};return void 0!==e.name&&(t.name=e.name),e.props&&(t.props=ob._copy(e.props)),e.bind&&(t.bind=ob._copy(e.bind)),e.on&&(t.on=ob._copy(e.on)),e.children&&(t.children=Array.isArray(e.children)?e.children.map(e=>null!==e&&"object"==typeof e?this._dump(e):e):e.children),t}static _copy(e,t){let n=void 0===t?new Map:t;if(null===e||"object"!=typeof e)return e;let i=Object.getPrototypeOf(e);if(!Array.isArray(e)&&i!==Object.prototype&&null!==i)return e;if(n.has(e))return n.get(e);let r=Array.isArray(e)?[]:{};n.set(e,r);var o=!0,s=!1,a=void 0;try{for(var l,u=Object.entries(e)[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){let e=oh(l.value,2),t=e[0],i=e[1];r[t]=ob._copy(i,n)}}catch(e){s=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(s)throw a}}return r}_warn(e){this._warned.has(e)||(this._warned.add(e),console.warn(`u2 spec: ${e}`))}static _commands(e){let t=[];var n=!0,i=!1,r=void 0;try{for(var o,s,a=Object.entries(null!=(o=e.on)?o:{})[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){let e=oh(s.value,2),n=e[0],i=e[1],r="string"==typeof i?i:null==i?void 0:i.cmd;if("string"!=typeof r||!r.startsWith("cmd:"))throw Error(`on.${n} must be 'cmd:' followed by a command name — a spec never carries code`);t.push([n,i])}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}return t}static _prop(e,t,n){var i;return null!=(i=e.props.find(e=>e.name===t))?i:ob._childProp(n,t)}static _childProp(e,t){var n;return null==e||null==(n=e.childProps)?void 0:n.find(e=>e.name===t)}static _element(e){return H.is(e)?e.root:e}static _checked(e,t){let n=oy(e,t);if(n)throw Error(n);return t}static _parentOf(e,t){var n=!0,i=!1,r=void 0;try{for(var o,s=os(e)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=o.value;if(n===t)return e;let i=ob._parentOf(n,t);if(i)return i}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return null}static _placeholder(e){let t=document.createElement("div");return t.className="u2-spec-error",t.textContent=e,t}static _isPlaceholder(e){return!U.is(e)&&e.classList.contains("u2-spec-error")}constructor(e,t,n,i){var r;let o=void 0===n?r7:n;super(),this._nodes=new Map,this._named=new Map,this._elements=new Map,this._mounts=new Map,this._warned=new Set,this._pending=[],this._deferred=[],this._batching=!1,this._spec=e,this.ctx=t,this._registry=o,this._designTime=null!=(r=(void 0===i?{}:i).designTime)&&r,this._cycle=ol(e),this.root.classList.add("u2-spec"),this.build(()=>{var t=!0,n=!1,i=void 0;try{for(var r,o,s,a=(null!=(r=e.components)?r:[])[Symbol.iterator]();!(t=(s=a.next()).done);t=!0){let e=s.value;this._mountComponent(e)}}catch(e){n=!0,i=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw i}}this.root.append(ob._element(this._render(e.root))),this._flushLinks();var l=!0,u=!1,d=void 0;try{for(var c,h=(null!=(o=e.components)?o:[])[Symbol.iterator]();!(l=(c=h.next()).done);l=!0){let e=c.value;this._start(e)}}catch(e){u=!0,d=e}finally{try{l||null==h.return||h.return()}finally{if(u)throw d}}})}}function oy(e,t){var n;let i=null!=(n=e.propertyType)?n:e.type;if(!function(e,t){switch(e){case"string":return"string"==typeof t;case"int":return"number"==typeof t&&Number.isInteger(t);case"double":return"number"==typeof t&&isFinite(t);case"bool":return"boolean"==typeof t;case"string_list":return Array.isArray(t)&&t.every(e=>"string"==typeof e);case"object":var n=t;if(!og.has(typeof n))return!1;try{return JSON.stringify(n,(e,t)=>{if(void 0===t||"function"==typeof t)throw Error("not JSON");return t}),!0}catch(e){return!1}default:return!1}}(i,t))return`prop "${e.name}" expects ${i}`;let r=e.choices;return r&&r.length>0&&"string_list"!==i&&"object"!==i&&!r.includes(t)?`prop "${e.name}" must be one of ${r.map(e=>`"${e}"`).join(", ")}`:null}function o_(e){return of.has(e)}function ow(e){let t=[{name:"text",type:"string",bindable:!0,description:"Text content"},{name:"cls",type:"string",bindable:!0,description:"Space-separated CSS classes"}];return"a"===e&&t.push({name:"href",type:"string",bindable:!0,description:"Link target"}),"img"===e&&t.push({name:"src",type:"string",bindable:!0,description:"Image source"}),t.push(...r1),t}function ox(e){var t;let n="string"==typeof e?JSON.parse(e):e;if(!n||"object"!=typeof n)throw Error("u2 spec: expected a spec object or a JSON string");if(n.$schema!==r4)throw Error(`u2 spec: $schema must be "${r4}", got ${JSON.stringify(n.$schema)}`);if(!n.root||"object"!=typeof n.root||"string"!=typeof n.root.tag)throw Error('u2 spec: "root" must be a node with a "tag"');if(void 0!==n.components){if(!Array.isArray(n.components))throw Error('u2 spec: "components" must be an array of nodes');var i=!0,r=!1,o=void 0;try{for(var s,a=n.components[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;if(!e||"object"!=typeof e||"string"!=typeof e.tag)throw Error('u2 spec: every entry of "components" must be a node with a "tag"')}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}}let l=e=>{var t=!0,n=!1,i=void 0;try{for(var r,o,s,a=Object.entries(ok)[Symbol.iterator]();!(t=(s=a.next()).done);t=!0){let t=oh(s.value,2),n=t[0],i=t[1];if((null==(r=e.props)?void 0:r[n])!==void 0||(null==(o=e.bind)?void 0:o[n])!==void 0)throw Error(`u2 spec: ${e.tag}${e.name?` "${e.name}"`:""}: prop "${n}" is now ${i}`)}}catch(e){n=!0,i=e}finally{try{t||null==a.return||a.return()}finally{if(n)throw i}}var u=!0,d=!1,c=void 0;try{for(var h,p=os(e)[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){let e=h.value;l(e)}}catch(e){d=!0,c=e}finally{try{u||null==p.return||p.return()}finally{if(d)throw c}}};for(let e=0,i=[n.root,...null!=(t=n.components)?t:[]];e<i.length;e++)l(i[e]);return n}let ok={enabled:'"disabled": the reason the user reads while the input is off, empty while it is on'};function oS(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}let oC=/\[([^\]]+)\]\(([^)\s]+)\)/g,oA=/^[a-z0-9-]+$/;class oO extends H{_fit(){let e=this.root.clientWidth;0!==e&&(this.root.classList.toggle("u2-app-header-compact",e<480),this.root.classList.toggle("u2-app-header-narrow",e<400))}getState(){let e=this._learnMore;return oS({},super.getState(),void 0===e?{}:{extra:oS({learnMore:e.text},void 0===e.href?{}:{learnMoreHref:e.href})})}getItems(e){return nC.itemsState(this._items.map((e,t)=>({key:String(t),label:H.text(e),index:t,rendered:!0})),null==e?void 0:e.all)}accessibleLabel(){var e;let t=void 0===this._title?"":H.text(this._title);return null!=(e=H.labelOf(this.root))?e:t||void 0}_lead(e){let t=tR([oO._part(oO._icon(e.icon),"icon")],"u2-app-header-lead");if(void 0===e.title)return t;this._title=oO._part(t$(e.title),"title");let n=tR([this._title],"u2-app-header-names");return void 0!==e.subtitle&&n.append(oO._part(t$(e.subtitle),"subtitle")),t.append(n),t}_body(e){var t,n;let i=document.createElement("ul");i.className="u2-app-header-items";for(let r=0,o=[...null!=(t=e.items)?t:[],...oO._bullets(null!=(n=e.description)?n:"")];r<o.length;r++){let e=o[r],t=oO._part(document.createElement("li"),"item");t.dataset.u2Item=String(this._items.length),t.append(oO._content(e)),this._items.push(t),i.append(t)}let r=tR([i],"u2-app-header-body"),o=this._learnMore;if(void 0===o)return r;let s=oO._part(oO._link(o),"learn-more");if(void 0!==o.href){let e=tK("external-link-square",{cls:"u2-app-header-external"});e.setAttribute("aria-hidden","true"),s.append(e)}return r.append(s),r}static _content(e){return"string"==typeof e||e instanceof HTMLElement?e:H.is(e)?e.root:oO._isLink(e)?oO._link(e):t$(e)}static _isLink(e){return"string"==typeof e.text}static _link(e){var t;let n=e.onClick;return tz(e.text,null!=(t=e.href)?t:e=>null==n?void 0:n(e))}static _bullets(e){return e.split("\n").map(e=>e.trim().replace(/^[-*+]\s+/,"")).filter(e=>""!==e).map(e=>{let t=t$(""),n=0;var i=!0,r=!1,o=void 0;try{for(var s,a=e.matchAll(oC)[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let i=s.value;t.append(e.slice(n,i.index),tz(i[1],i[2])),n=i.index+i[0].length}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}return t.append(e.slice(n)),t})}static _icon(e){if("string"!=typeof e)return e;if(oA.test(e))return tK(e);let t=tR([]);return t.style.backgroundImage=`url(${JSON.stringify(e)})`,t}static _part(e,t){return e.classList.add(`u2-app-header-${t}`),e.dataset.u2Part=t,e}constructor(e){var t,n;super(),this._items=[],this.root.classList.add("u2-app-header"),this.root.classList.toggle("u2-app-header-named",void 0!==e.title),this.root.classList.toggle("u2-app-header-rule",!0===e.bottomLine),this.root.dataset.u2="app-header",this.root.style.setProperty("--u2-app-header-icon-size",`${null!=(t=e.iconSize)?t:void 0!==e.title?90:150}px`);const i="string"==typeof e.learnMore?{href:e.learnMore}:e.learnMore;this._learnMore=void 0===i?void 0:function(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}(oS({},i),{text:null!=(n=i.text)?n:"Learn more"}),this.build(()=>this.root.append(this._lead(e),this._body(e))),void 0!==e.name&&(this.name=e.name);let r=0;const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>this._fit())});o.observe(this.root),this.own(()=>{o.disconnect(),cancelAnimationFrame(r)})}}function oE(e){var t;if(e.kind)return e.kind;if(e.ref)return n7.REF;switch(null!=(t=e.propertyType)?t:e.type){case P.TYPE.INT:return n7.INT;case P.TYPE.BIG_INT:return n7.BIG_INT;case P.TYPE.FLOAT:case n7.FLOAT:case P.TYPE.NUM:case P.TYPE.QNUM:return n7.FLOAT;case P.TYPE.BOOL:return n7.BOOL;case P.TYPE.DATE_TIME:return n7.DATE_TIME;case P.TYPE.LIST:case P.TYPE.STRING_LIST:return n7.STRING_LIST;default:return n7.STRING}}function oT(e,t){return e instanceof Date?e.toISOString():i_(e)?iO(e.span,t).toISOString():iy(e)?e.id:iw(e)?{$column:e.column}:ix(e)?{$param:e.param}:e}function oP(e,t){return Array.isArray(e)?e.map(e=>oT(e,t.now)):oT(e,t.now)}let oN=Math.fround(26789344063684636e-50);new AbortController().signal;let oI=e=>26789344063684636e-50===e||e===oN||Number.isNaN(e),oM=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),oL={"=":(e,t)=>e===t,"!=":(e,t)=>e!==t,"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t};class oR{static kindOf(e){return oE({name:e.name,type:e.type})}static nulls(e){var t;let n=oR.kindOf(e);if(n===n7.BOOL)return new P.BitArray(e.length);if(n===n7.BIG_INT||n===n7.STRING_LIST)return P.BitArray.create(e.length,t=>null==e.get(t));let i=e.getRawData();if(n===n7.INT)return P.BitArray.create(e.length,e=>-0x80000000===i[e]);if(n===n7.FLOAT||n===n7.DATE_TIME)return P.BitArray.create(e.length,e=>oI(i[e]));let r=null!=(t=e.categories)?t:[];return P.BitArray.create(e.length,e=>{var t;return(null!=(t=r[i[e]])?t:"")===""})}static where(e,t,n,i){let r=oR.kindOf(e),o=r===n7.BIG_INT||r===n7.STRING_LIST?null:e.getRawData(),s=o instanceof Float32Array,a=e=>oR._cell(e,r,n,s),l=Array.isArray(t.value)?t.value.map(a):a(t.value);switch(r){case n7.BOOL:{let t=[i(!1,l),i(!0,l)];return P.BitArray.create(e.length,e=>t[o[e>>>5]>>>(31&e)&1])}case n7.BIG_INT:return P.BitArray.create(e.length,t=>{let n=e.get(t);return null!=n&&i(BigInt(n),l)});case n7.STRING_LIST:return P.BitArray.create(e.length,t=>{let n=e.get(t);return Array.isArray(n)&&i(n.join("\n"),l)});case n7.INT:return P.BitArray.create(e.length,e=>-0x80000000!==o[e]&&i(o[e],l));case n7.FLOAT:case n7.DATE_TIME:return P.BitArray.create(e.length,e=>!oI(o[e])&&i(o[e],l));default:{var u;let t=(null!=(u=e.categories)?u:[]).map(e=>""!==e&&i(e,l));return P.BitArray.create(e.length,e=>!0===t[o[e]])}}}static compare(e,t,n){let i=oL[n];if(void 0===i)throw new ie(`Operator "${n}" does not accept a column`);let r=oR.cells(e),o=oR.cells(t);return P.BitArray.create(e.length,e=>{let t=r(e),n=o(e);return null!==t&&null!==n&&i(t,n)})}static cells(e){let t=oR.kindOf(e);if(t===n7.BIG_INT)return t=>{let n=e.get(t);return null==n?null:BigInt(n)};if(t===n7.STRING_LIST)return t=>{let n=e.get(t);return Array.isArray(n)?n.join("\n"):null};let n=e.getRawData();switch(t){case n7.BOOL:return e=>(n[e>>>5]>>>(31&e)&1)==1;case n7.INT:return e=>-0x80000000===n[e]?null:n[e];case n7.FLOAT:case n7.DATE_TIME:return e=>oI(n[e])?null:n[e];default:{var i;let t=null!=(i=e.categories)?i:[];return e=>{var i;let r=null!=(i=t[n[e]])?i:"";return""===r?null:r}}}}static likeRegExp(e){let t="";for(let n=0;n<e.length;n++){let i=e[n];"\\"===i&&n+1<e.length?t+=oM(e[++n]):t+="%"===i?"[^]*":"_"===i?"[^]":oM(i)}return RegExp(`^${t}$`,"i")}static _cell(e,t,n,i){switch(t){case n7.INT:case n7.FLOAT:{let t="number"==typeof e?e:Number(e);return i?Math.fround(t):t}case n7.DATE_TIME:return 1e3*(e instanceof Date?e.getTime():i_(e)?iO(e.span,n.now).getTime():"number"==typeof e?e:Date.parse(String(e)));case n7.BIG_INT:return BigInt(e);case n7.BOOL:return!0===e||"true"===e;default:return String(oP(e,n))}}}function oj(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function oD(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function o$(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return oj(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return oj(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}class oF{register(e){let t=Array.isArray(e)?e:[e];var n=!0,i=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value,t=this._ops.findIndex(t=>t.id===e.id&&t.semType===e.semType);t>=0?this._ops[t]=e:this._ops.push(e)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return()=>{var e=!0,n=!1,i=void 0;try{for(var r,o=t[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let e=r.value,t=this._ops.indexOf(e);t>=0&&this._ops.splice(t,1)}}catch(e){n=!0,i=e}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}}}registerSet(e){let t=oF.checkSet(e);if(t.length>0)throw new ie(`Bad operator set: ${t.join("; ")}`);return this.register(e.operators.map(t=>{var n,i;return{id:t.id,label:t.label,arity:t.arity,kinds:null!=(n=t.kinds)?n:[n7.STRING],semType:e.semType,exclusive:!0===e.exclusive,editor:null!=(i=t.editor)?i:"default",bitset:(n,i,r)=>{var o;return(o=function*(){let o=yield t.bitset(n,i,r);try{return P.BitArray.fromBytes(o.bits,o.length)}catch(r){let n=`${e.semType} operator "${t.id}" returned a bad bitset: ${r.message}`;throw new ie(n,[{nodeId:i.id,code:"evaluation",message:n}])}},function(){var e=this,t=arguments;return new Promise(function(n,i){var r=o.apply(e,t);function s(e){oD(r,n,i,s,a,"next",e)}function a(e){oD(r,n,i,s,a,"throw",e)}s(void 0)})})()}}}))}static checkSet(e){if("object"!=typeof e||null===e)return["not an object"];let t=[];if(("string"!=typeof e.semType||""===e.semType)&&t.push("semType must be a non-empty string"),void 0!==e.exclusive&&"boolean"!=typeof e.exclusive&&t.push("exclusive must be a boolean"),!Array.isArray(e.operators)||0===e.operators.length)return[...t,"operators must be a non-empty array"];var n=!0,i=!1,r=void 0;try{for(var o,s=e.operators.entries()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o$(o.value,2),n=e[0],i=e[1],r=`operators[${n}]`;if("object"!=typeof i||null===i){t.push(`${r}: not an object`);continue}("string"!=typeof i.id||""===i.id)&&t.push(`${r}: id must be a non-empty string`),"string"!=typeof i.label&&t.push(`${r}: label must be a string`),oG.includes(i.arity)||t.push(`${r}: arity must be 0, 1, 2 or 'n'`),void 0===i.kinds||Array.isArray(i.kinds)&&i.kinds.every(e=>oB.includes(e))||t.push(`${r}: kinds must list ${oB.join(", ")}`),void 0===i.editor||oV.includes(i.editor)||t.push(`${r}: editor must be ${oV.join(", ")}`),"function"!=typeof i.bitset&&t.push(`${r}: bitset must be a function`)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}for(e){let t=oE(e),n=e.semType?this._ops.filter(n=>n.semType===e.semType&&n.kinds.includes(t)):[],i=n.some(e=>!0===e.exclusive);return[...n,...this._ops.filter(e=>void 0===e.semType&&e.kinds.includes(t)&&(!i||oz.includes(e.id)))]}hosted(){return this._ops.filter(e=>!0===e.host).sort((e,t)=>t.id.length-e.id.length)}get(e,t){var n;return t?this.for(t).find(t=>t.id===e):null!=(n=this._ops.find(t=>t.id===e&&void 0===t.semType))?n:this._ops.find(t=>t.id===e)}all(){return this._ops.slice()}constructor(){this._ops=[]}}let oz=["is null","is not null"],oq=[n7.STRING,n7.INT,n7.FLOAT,n7.BIG_INT,n7.DATE_TIME,n7.BOOL,n7.REF],oB=[...oq,n7.STRING_LIST],oG=[0,1,2,"n"],oV=["default","range","list","none"],oU=[n7.INT,n7.FLOAT,n7.BIG_INT,n7.DATE_TIME],oH=[n7.STRING,n7.INT,n7.FLOAT,n7.BIG_INT,n7.REF],oW=[n7.STRING,n7.STRING_LIST],oY=[n7.REF,n7.STRING];function oK(e){return e.replace(/\\/g,"\\\\").replace(/%/g,"\\%").replace(/_/g,"\\_")}function oX(e,t){return iw(e.value)?{$column:e.value.column}:ix(e.value)?{$param:e.value.param}:t()}function oZ(e,t){return oX(e,()=>{var n,i;return(null==(i=e.options)?void 0:i.raw)===!0?String(e.value):t(oK(String(null!=(n=e.value)?n:"")))})}let oQ=(e,t,n)=>void 0===n?{property:e,operator:t}:{property:e,operator:t,value:n},oJ=e=>(t,n,i)=>oR.where(t,n,i,e),o0=(e,t)=>{let n=void 0!==t&&t;return(t,i,r)=>{var o,s;let a=(null==(s=i.options)?void 0:s.raw)===!0?oR.likeRegExp(String(i.value)):null,l=String(null!=(o=i.value)?o:"").toLowerCase();return oR.where(t,i,r,t=>(a?a.test(String(t)):e(String(t).toLowerCase(),l))!==n)}};function o2(e){try{return RegExp(e,"i")}catch(e){var t;return null!=(t=e.message.split(": ").pop())?t:String(e)}}let o1=e=>(t,n,i)=>{let r=o2(String(n.value));return oR.where(t,n,i,t=>"string"!=typeof r&&r.test(String(t))!==e)},o3=e=>{let t="string"==typeof e?o2(e):null;return"string"==typeof t?`"${e}" is not a regular expression: ${t}`:null},o5=(e,t)=>({id:e,label:t,arity:1,kinds:oU,editor:"default",domain:(t,n,i)=>oQ(t.property,e,oP(t.value,i)),mask:oJ(">"===e?(e,t)=>e>t:">="===e?(e,t)=>e>=t:"<"===e?(e,t)=>e<t:(e,t)=>e<=t)}),o4=(e,t,n,i,r,o)=>({id:e,label:t,arity:1,kinds:n,editor:"default",domain:e=>oQ(e.property,i,oZ(e,r)),mask:o0(o)}),o6=[{id:"=",label:"equals",arity:1,kinds:oq,editor:"default",domain:(e,t,n)=>oQ(e.property,"=",oP(e.value,n)),mask:oJ((e,t)=>e===t)},{id:"!=",label:"not equals",arity:1,kinds:oq,editor:"default",domain:(e,t,n)=>oQ(e.property,"!=",oP(e.value,n)),mask:oJ((e,t)=>e!==t)},o5(">","greater than"),o5(">=","at least"),o5("<","less than"),o5("<=","at most"),{id:"between",label:"between",arity:2,kinds:oU,editor:"range",domain:(e,t,n)=>{let i=o$(oP(e.value,n),2),r=i[0],o=i[1];return[oQ(e.property,">=",r),"and",oQ(e.property,"<=",o)]},mask:oJ((e,t)=>{let n=o$(t,2),i=n[0],r=n[1];return e>=i&&e<=r})},{id:"in",label:"is one of",arity:"n",kinds:oH,editor:"list",domain:(e,t,n)=>oQ(e.property,"=",oP(e.value,n)),mask:oJ((e,t)=>t.includes(e))},{id:"not in",label:"is not one of",arity:"n",kinds:oH,editor:"list",domain:(e,t,n)=>oQ(e.property,"!=",oP(e.value,n)),mask:oJ((e,t)=>!t.includes(e))},{id:"under",label:"is under",arity:1,kinds:oY,editor:"default",domain:(e,t,n)=>oQ(e.property,"under",oP(e.value,n))},o4("like","contains",oW,"like",e=>`%${e}%`,(e,t)=>e.includes(t)),{id:"!like",label:"does not contain",arity:1,kinds:oW,editor:"default",domain:e=>oQ(e.property,"not like",oZ(e,e=>`%${e}%`)),mask:o0((e,t)=>e.includes(t),!0)},o4("starts","starts with",[n7.STRING],"like",e=>`${e}%`,(e,t)=>e.startsWith(t)),o4("ends","ends with",[n7.STRING],"like",e=>`%${e}`,(e,t)=>e.endsWith(t)),{id:"matches",label:"matches regex",arity:1,kinds:[n7.STRING],editor:"default",domain:e=>oQ(e.property,"~*",oX(e,()=>String(e.value))),mask:o1(!1),check:o3},{id:"!matches",label:"does not match",arity:1,kinds:[n7.STRING],editor:"default",domain:e=>oQ(e.property,"!~*",oX(e,()=>String(e.value))),mask:o1(!0),check:o3},{id:"fuzzy",label:"is similar to",arity:1,kinds:[n7.STRING],editor:"default",domain:e=>{var t;let n=oX(e,()=>String(e.value)),i="number"==typeof(null==(t=e.options)?void 0:t.threshold)?e.options.threshold:null;return[{property:e.property,operator:"fuzzy",threshold:i,value:n},"or",oQ(e.property,"like",oX(e,()=>`%${String(e.value)}%`))]}},{id:"is null",label:"is empty",arity:0,kinds:[...oq,n7.STRING_LIST],editor:"none",domain:e=>oQ(e.property,"=",null),mask:e=>oR.nulls(e)},{id:"is not null",label:"is not empty",arity:0,kinds:[...oq,n7.STRING_LIST],editor:"none",domain:e=>oQ(e.property,"!=",null),mask:e=>oR.nulls(e).invert()}],o8=new oF;function o9(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function o7(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return o9(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o9(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}o8.register(o6);let se={none:0,value:1,all:2};function st(e,t){let n=t.split(".")[0],i=e.properties.find(e=>e.name===n);if(i)return i;let r=n.toLowerCase(),o=e.properties.filter(e=>e.name.toLowerCase()===r);return 1===o.length?o[0]:null}function sn(e){let t=new Map;return id(e,(e,n,i)=>t.set(e.id,{node:e,parent:n,index:i})),t}function si(e,t){let n="none",i=e=>{var t;e&&se[null!=(t=e.lock)?t:"none"]>se[n]&&(n=e.lock)};i(il(e,t));let r=new Set;for(let n=iu(e,t);n&&!r.has(n);n=iu(e,n.id))r.add(n),i(n);return n}let sr=/^-?\d+$/,so=["=","!=","<","<=",">",">="],ss=[n7.INT,n7.FLOAT,n7.BIG_INT];function sa(e,t,n,i){let r=[];return id(e,e=>{ia(e)||function(e,t,n,i){let r=(t,n)=>i.push({nodeId:e.id,code:t,message:n}),o=st(t,e.property);if(!o){let n=st(t,`${e.property.split(".")[0]}_id`);r("unknown-property",n&&n.ref?`Unknown property "${e.property}" — did you mean \`${n.name}.name\`?`:`Unknown property "${e.property}"`);return}if(e.property.includes("."))return;let s=o8.for(o).find(t=>t.id===e.operator);if(!s)return r("operator-not-applicable",`Operator "${e.operator}" is not applicable to "${e.property}"`);let a=e.value,l=null==a||""===a;if(1===s.arity&&l||2===s.arity&&!(Array.isArray(a)&&2===a.length)||"n"===s.arity&&!(Array.isArray(a)&&a.length>0)){var u;let t=null!=(u=o.friendlyName)?u:e.property;r("missing-value",2===s.arity?`"${t}" needs two bounds`:"n"===s.arity?`"${t}" needs at least one value`:`"${t}" needs a value`);return}if(0!==s.arity){let e=oE(o);var d=!0,c=!1,h=void 0;try{for(var p,f=(Array.isArray(a)?a:[a])[Symbol.iterator]();!(d=(p=f.next()).done);d=!0){let n=p.value,i=function(e,t,n,i,r){var o,s,a;let l=e=>`Expected ${e} for "${n.name}"`;if(ix(e))return null;if(iw(e)){let o=st(r,e.column);if(!o||e.column.includes(".")){let r=`Unknown column "${e.column}"`;return e.column.includes(".")?r:"under"===i.id?`${r} — under takes a ${null!=(a=n.ref)?a:"row"} — pick one from the list`:n.ref?`${r} — did you mean \`${n.name}.name ${i.id} "${e.column}"\`?`:t===n7.STRING||t===n7.STRING_LIST||void 0!==n.choices?`${r} — quote a text value`:r}return so.includes(i.id)?oE(o)===t||ss.includes(t)&&ss.includes(oE(o))?null:`Cannot compare "${n.name}" with "${o.name}"`:`Operator "${i.id}" does not accept a column`}switch(t){case n7.INT:if("number"!=typeof e||!Number.isInteger(e))return l("an integer");break;case n7.FLOAT:if("number"!=typeof e||!Number.isFinite(e))return l("a number");break;case n7.BIG_INT:if(!("number"==typeof e&&Number.isInteger(e))&&!("string"==typeof e&&sr.test(e)))return l("an integer");break;case n7.DATE_TIME:if(e instanceof Date?Number.isNaN(e.getTime()):i_(e)?!iA(e.span):"string"!=typeof e||Number.isNaN(Date.parse(e)))return l("a date or a time span");break;case n7.BOOL:if("boolean"!=typeof e)return l("true or false");break;case n7.REF:if(!iy(e)&&"string"!=typeof e)return l("a reference");break;default:if("string"!=typeof e&&"number"!=typeof e)return l("a string")}if("number"==typeof e){if(void 0!==n.min&&e<n.min)return`"${n.name}" is at least ${n.min}`;if(void 0!==n.max&&e>n.max)return`"${n.name}" is at most ${n.max}`}return n.choices&&("="===i.id||"in"===i.id)&&!n.choices.includes(String(e))?`"${e}" is not one of the choices of "${n.name}"`:null!=(o=null==(s=i.check)?void 0:s.call(i,e))?o:null}(n,e,o,s,t);if(i)return void r("invalid-value",i)}}catch(e){c=!0,h=e}finally{try{d||null==f.return||f.return()}finally{if(c)throw h}}}("domain"===n?void 0!==s.domain||!0===s.host:"dataframe"!==n||void 0!==s.mask||void 0!==s.bitset)||r("not-expressible",`"${e.property} ${e.operator}" cannot be expressed for ${n}`)}(e,t,n,r)}),i&&r.push(...function(e,t){let n=[],i=(e,t)=>n.push({nodeId:e,code:"locked",message:t}),r=t=>{var n;if(ia(t))return null;let i=t.property.split(".")[0];if(e.allowedProperties&&!e.allowedProperties.includes(i))return`Property "${t.property}" is not offered here`;let r=null==(n=e.allowedOperators)?void 0:n[i];return r&&!r.includes(t.operator)?`Operator "${t.operator}" is not offered for "${t.property}"`:null},o=function(e,t){let n=sn(e),i=sn(t),r={changed:[],added:[],removed:[],moved:[]},o=(e,t)=>e.nodes.filter(n=>{var i,r;return(null==(r=t.get(n.id))||null==(i=r.parent)?void 0:i.id)===e.id}).map(e=>e.id);var s=!0,a=!1,l=void 0;try{for(var u,d,c=i[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let e=o7(d.value,2),t=e[0],s=e[1],a=s.node,l=s.parent,c=s.index,h=n.get(t);if(!h){l&&n.has(l.id)&&r.added.push({parentId:l.id,index:c,node:a});continue}if(l&&h.parent&&(l.id!==h.parent.id||o(l,n).indexOf(t)!==o(h.parent,i).indexOf(t))&&r.moved.push({id:t,from:{parentId:h.parent.id,index:h.index},to:{parentId:l.id,index:c}}),ia(a)||ia(h.node))continue;let p={id:t};a.property!==h.node.property&&(p.property=a.property),a.operator!==h.node.operator&&(p.operator=a.operator),ib(a.value,h.node.value)||(p.value=a.value),iv(a.options,h.node.options)||(p.options=null!=(u=a.options)?u:{}),Object.keys(p).length>1&&r.changed.push(p)}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}var h=!0,p=!1,f=void 0;try{for(var m,g=n[Symbol.iterator]();!(h=(m=g.next()).done);h=!0){let e=o7(m.value,2),t=e[0],n=e[1].parent;!i.has(t)&&n&&i.has(n.id)&&r.removed.push(t)}}catch(e){p=!0,f=e}finally{try{h||null==g.return||g.return()}finally{if(p)throw f}}return r}(e.root,t),s=o.changed,a=o.added,l=o.removed,u=o.moved;var d=!0,c=!1,h=void 0;try{for(var p,f=s[Symbol.iterator]();!(d=(p=f.next()).done);d=!0){let n=p.value,o=si(e.root,n.id);if("all"===o||"value"===o&&(void 0!==n.property||void 0!==n.operator||void 0!==n.options))i(n.id,"all"===o?"This condition is locked":"Only the value of this condition may change");else{let e=r(il(t,n.id));e&&i(n.id,e)}}}catch(e){c=!0,h=e}finally{try{d||null==f.return||f.return()}finally{if(c)throw h}}var m=!0,g=!1,v=void 0;try{for(var b,y=a[Symbol.iterator]();!(m=(b=y.next()).done);m=!0){let t=b.value,n=t.parentId,o=t.node;if(!1===e.allowAdd||"none"!==si(e.root,n))i(o.id,"Conditions cannot be added here");else{let e=r(o);e&&i(o.id,e)}}}catch(e){g=!0,v=e}finally{try{m||null==y.return||y.return()}finally{if(g)throw v}}var _=!0,w=!1,x=void 0;try{for(var k,S=l[Symbol.iterator]();!(_=(k=S.next()).done);_=!0){let t=k.value;"none"!==si(e.root,t)&&i(t,"This condition cannot be removed")}}catch(e){w=!0,x=e}finally{try{_||null==S.return||S.return()}finally{if(w)throw x}}var C=!0,A=!1,O=void 0;try{for(var E,T=u[Symbol.iterator]();!(C=(E=T.next()).done);C=!0){let t=E.value,n=t.id,r=t.from,o=t.to;(!1===e.allowAdd&&r.parentId!==o.parentId||"none"!==si(e.root,n)||"none"!==si(e.root,o.parentId))&&i(n,"This condition cannot be moved")}}catch(e){A=!0,O=e}finally{try{C||null==T.return||T.return()}finally{if(A)throw O}}return id(t,t=>{let n=il(e.root,t.id);n&&ia(t)&&ia(n)&&"none"!==si(e.root,t.id)&&(t.op!==n.op||!0===t.not!=(!0===n.not))&&i(t.id,"This group is locked")}),!1!==e.allowAdvanced||ih(t)||i(t.id,"Groups are not allowed here"),n}(i,e)),r}function sl(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function su(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return sl(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return sl(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let sd=/^[A-Za-z]\w*(\.[A-Za-z]\w*)*$/,sc={"\\":"\\\\",'"':'\\"',"'":"\\'","\n":"\\n","\r":"\\r"," ":"\\t","\b":"\\b","\f":"\\f"};function sh(e,t){let n=0;for(let i=t-1;i>=0&&"\\"===e[i];i--)n++;return n%2==0}function sp(e){return`"${e.replace(/[\\"'\n\r\t\b\f]|[\x00-\x1f]/g,e=>{var t;return null!=(t=sc[e])?t:`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`})}"`}function sf(e){return sd.test(e)?e:`[${e.replace(/[\\\]]|[\x00-\x1f]/g,e=>"\\"===e||"]"===e?`\\${e}`:`\\u${e.charCodeAt(0).toString(16).padStart(4,"0")}`)}]`}function sm(e){var t;return void 0===e?"":Array.isArray(e)?`(${e.map(sm).join(", ")})`:null===e||"boolean"==typeof e||"number"==typeof e?String(e):e instanceof Date?null!=(t=iT(e))?t:sp(e.toISOString()):i_(e)?e.span:iy(e)?sp(e.id):iw(e)?sf(e.column):ix(e)?`$${e.param}`:"@current"===e?e:sp(e)}function sg(e){var t,n,i;let r=sf(e.property);if(function e(t){return Array.isArray(t)?t.some(e):iw(t)||ix(t)}(e.value)&&"between"!==e.operator)return`${r} ${e.operator} ${sm(e.value)}`;switch(e.operator){case"is null":return`${r} = null`;case"is not null":return`${r} != null`;case"between":{let t=su(Array.isArray(e.value)?e.value:[],2),n=t[0],i=t[1];return`${r} between ${sm(n)} and ${sm(i)}`}case"fuzzy":{let n=null==(t=e.options)?void 0:t.threshold;return`${r} fuzzy${"number"==typeof n?`(${n})`:""} ${sm(e.value)}`}case"like":case"!like":case"starts":case"ends":{let t=String(null!=(n=e.value)?n:"");if((null==(i=e.options)?void 0:i.raw)!==!0)return`${r} ${e.operator} ${sp(oK(t))}`;let o=("like"===e.operator||"!like"===e.operator)&&t.length>1&&t.startsWith("%")&&t.endsWith("%")&&sh(t,t.length-1);return`${r} ${e.operator} ${sp(o?t.slice(1,-1):t)}`}default:return`${r} ${e.operator} ${sm(e.value)}`.trimEnd()}}function sv(e){return ia(e)?function e(t,n){let i=function(t){let n=[];var i=!0,r=!1,o=void 0;try{for(var s,a=t.nodes[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let t=s.value,i=ia(t)?e(t,!0):sg(t);""!==i&&n.push(i)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}return n}(t);if(0===i.length)return"";let r=1===i.length?i[0]:i.join(` ${t.op} `);return!0===t.not?`not (${1===i.length&&r.startsWith("(")?r.slice(1,-1):r})`:n&&(i.length>1||!r.startsWith("("))?`(${r})`:r}(e,!1):sg(e)}function sb(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}class sy extends nC{getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={open:this._list.isOpen.peek(),busy:"loading"===this._source.state.peek().kind},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}getItems(e){let t=this._list.isOpen.peek();return nC.itemsState(this._items.peek().map((e,n)=>({key:e,label:e,index:n,rendered:t})),null==e?void 0:e.all)}revealItem(e){var t,n=this,i=()=>super.revealItem;return(t=function*(){this._list.clearActive(),this._source.query(""),this._list.open();for(let e=0;e<50&&"loading"===this._source.state.peek().kind;e++)yield new Promise(e=>setTimeout(e,20));return i().call(n,e)},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){sb(o,i,r,s,a,"next",e)}function a(e){sb(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}createEditor(){var e,t;let n=document.createElement("input");n.type="text",n.autocomplete="off",n.placeholder=null!=(e=this.options.placeholder)?e:"",n.setAttribute("role","combobox"),n.setAttribute("aria-autocomplete","list");let i=new eh(this.options.source,{debounceMs:this.options.debounceMs});return this._source=i,this.own(()=>i.dispose()),this.effect(()=>{"loading"===i.state.value.kind?this.root.setAttribute("aria-busy","true"):this.root.removeAttribute("aria-busy")}),this._items=(0,P.computed)(()=>{let e=i.state.value;return"ready"===e.kind?e.items:[]}),this._list=new rn({prefix:"u2-typeahead",anchor:n,scope:this.scope,items:this._items,view:i.state,text:this.signal,minChars:null!=(t=this.options.minChars)?t:0,render:e=>{var t,n,i;return null!=(t=null==(n=(i=this.options).renderItem)?void 0:n.call(i,e))?t:rn.row("u2-typeahead-text",e)},onPick:e=>{this._accept(e),n.focus()},onDismiss:()=>this._list.dismiss(),onRetry:()=>i.retry()}),this.scope.listen(n,"input",()=>this._typing=!0),ed(n,this.signal,{owner:this.scope}),this.scope.listen(n,"focus",()=>this._anchorValue=this.peek()),this.scope.listen(n,"input",()=>this._onInput()),this.effect(()=>{let e=this.value;this._typing||(this._anchorValue=e)}),this.scope.listen(n,"keydown",e=>this._onKeyDown(e)),this.scope.listen(n,"blur",()=>this._list.dismiss()),this.options.openOnFocus&&(this.scope.listen(n,"focus",()=>this._showAll()),this.scope.listen(n,"click",()=>this._showAll())),this.effect(()=>n.setAttribute("aria-expanded",String(this._list.isOpen.value))),n}_onInput(){this._typing=!1,this._list.clearActive(),this._refresh(),this._list.open()}_showAll(){this._list.isOpen.peek()||(this._list.clearActive(),this._source.query(""),this._list.open())}_refresh(){var e;this.peek().length>=(null!=(e=this.options.minChars)?e:0)&&this._source.query(this.peek())}_accept(e){let t=this._items.peek()[e];return void 0!==t&&(this.value=t,this._anchorValue=t,this._list.dismiss(),!0)}_onKeyDown(e){switch(e.key){case"ArrowDown":e.preventDefault(),this._list.isOpen.peek()?this._list.move(1):(this._refresh(),this._list.open());break;case"ArrowUp":this._list.isOpen.peek()&&(e.preventDefault(),this._list.move(-1));break;case"Home":case"End":this._list.isOpen.peek()&&(e.preventDefault(),this._list.jump("Home"===e.key?0:this._list.rowCount-1));break;case"Enter":!e.ctrlKey&&!e.metaKey&&this._list.isOpen.peek()&&(e.preventDefault(),e.stopPropagation(),this._accept(this._list.activeIndex.peek())||this._list.dismiss());break;case" ":this.options.openOnFocus&&""===this.peek()&&(e.preventDefault(),this._showAll());break;case"Escape":this._list.isOpen.peek()?(e.stopPropagation(),this._list.dismiss()):this.peek()!==this._anchorValue&&(e.stopPropagation(),this.value=this._anchorValue);break;case"Tab":this._list.dismiss()}}constructor(e){super(e,""),this._typing=!1,this.isOpen=this._list.isOpen,this.root.classList.add("u2-suggest-input"),this.root.dataset.u2="suggest-input"}}class s_ extends nC{createEditor(){var e;let t=this.options,n=t.prop,i=t.schema,r=null==(e=i.renderer)?void 0:e.call(i,n),o=e=>{var t;return null===e?null:{value:e,label:null!=(t=e.name)?t:e.id}},s=new ro({source:(e,t)=>i.values(n,e,t,{operator:this.options.operator}),itemText:e=>{var t,n;return null!=(t=null!=(n=e.label)?n:null==r?void 0:r.caption(e.value))?t:String(e.value)},render:(null==r?void 0:r.listItem)?e=>r.listItem(e.value):void 0,placeholder:this.options.placeholder,debounceMs:this.options.debounceMs});return s.selected.value=o(this.peek()),this.effect(()=>{var e;let t=s.selected.value,n=null===t?null:t.value;ib(null!=n?n:void 0,null!=(e=this.peek())?e:void 0)||(this.value=n)}),this.effect(()=>{var e;let t=this.value;ib(null!=t?t:void 0,null==(e=s.selected.peek())?void 0:e.value)||(s.selected.value=o(t))}),s.root}constructor(e){super(e,null),this.root.dataset.u2="ref-input"}}function sw(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function sx(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function sk(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){sx(o,i,r,s,a,"next",e)}function a(e){sx(o,i,r,s,a,"throw",e)}s(void 0)})}}function sS(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function sC(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function sA(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return sw(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return sw(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sO(e){var t;return iy(e)?null!=(t=e.name)?t:e.id:i_(e)?e.span:ei.value(e)}function sE(e,t){return(t===n7.INT||t===n7.FLOAT)&&""!==e.trim()&&Number.isFinite(Number(e))?Number(e):e}function sT(e,t){return{root:e.root,set:e=>t(Array.isArray(e)?void 0:e),setDisabled:t=>e.disabled=t}}function sP(e,t){return{root:e.root,setDisabled:t=>e.disabled=t,set:n=>{let i=t(n);ib(e.peek(),i)||(e.value=i)}}}function sN(e,t){let n=t6("times",e,{tooltip:`Remove ${void 0===t?"condition":t}`});return n.classList.add("u2-fb-remove"),n.dataset.u2Part="remove",n}function sI(){let e=tR([tK("grip-vertical")],"u2-fb-handle");return e.dataset.u2Part="handle",e.title="Drag to move",e.setAttribute("role","button"),e.setAttribute("aria-label","Drag to move"),e}function sM(e,t){let n=t$("",e);return n.dataset.u2Part=t,n.hidden=!0,n}function sL(e,t,n,i){let r=void 0!==i&&i;e.classList.toggle("u2-fb-invalid",null!==n&&!r),e.classList.toggle("u2-fb-missing",null!==n&&r),t.textContent=null!=n?n:"",t.hidden=null===n,null===n?e.removeAttribute("title"):e.title=n}class sR extends H{update(e){var t,n;this._cond=e,this._prop.setItems(sR._items(this._host.properties().map(e=>{var t;return{value:e.name,label:null!=(t=e.friendlyName)?t:e.name}}),e.property)),this._prop.value=e.property;let i=st(this._host.schema,e.property),r=i?this._host.operators(i):[];this._op.setItems(sR._items(r.map(e=>({value:e.id,label:e.label})),e.operator)),this._op.value=e.operator;let o=r.find(t=>t.id===e.operator);this._propText.textContent=null!=(t=null==i?void 0:i.friendlyName)?t:e.property,this._opText.textContent=null!=(n=null==o?void 0:o.label)?n:e.operator;let s=`${e.property} ${null==o?void 0:o.editor}/${null==o?void 0:o.arity}`;s!==this._editorKey?(this._editorKey=s,this._buildEditors(e,i,o)):this._syncEditors(e),this.applyLock()}setProblem(e,t){sL(this.root,this._problem,e,void 0!==t&&t)}focus(){var e;null==(e=this._prop.root.querySelector("select"))||e.focus()}_build(e){this._handle=sI(),this._prop=new n2({inline:!0,nullable:!1,items:[],value:e.property,onChanged:e=>this._onProperty(e)}),this._prop.root.classList.add("u2-fb-prop"),this._prop.root.dataset.u2Part="prop",this._op=new n2({inline:!0,nullable:!1,items:[],value:e.operator,onChanged:e=>this._onOperator(e)}),this._op.root.classList.add("u2-fb-op"),this._op.root.dataset.u2Part="op",this._propText=sM("u2-fb-prop-text","prop-text"),this._opText=sM("u2-fb-op-text","op-text"),this._valueHost=tR([],"u2-fb-values"),this._remove=sN(()=>this._host.remove(this.id)),this._problem=sM("u2-fb-problem","problem"),this._valueHost.append(this._problem),this.root.append(this._handle,this._prop.root,this._propText,this._op.root,this._opText,this._valueHost,this._remove),this.own(()=>this._releaseEditors())}static _items(e,t){return e.some(e=>e.value===t)?e:[...e,{value:t,label:t}]}_onProperty(e){var t,n;if(null===e||e===this._cond.property)return;let i=st(this._host.schema,e),r=i?this._host.operators(i):[],o=r.some(e=>e.id===this._cond.operator)?this._cond.operator:null!=(t=null==(n=r[0])?void 0:n.id)?t:this._cond.operator;this._host.change(this.id,{property:e,operator:o,value:void 0})}_onOperator(e){if(null===e||e===this._cond.operator)return;let t=sA([this._cond.operator,e].map(e=>o8.get(e)),2),n=t[0],i=t[1],r=void 0!==i&&(null==n?void 0:n.arity)===i.arity&&(null==n?void 0:n.editor)===i.editor;this._host.change(this.id,r?{operator:e}:{operator:e,value:void 0})}_change(e){ib(e,this._cond.value)||this._host.change(this.id,{value:e})}applyLock(){let e=this._host.lockOf(this.id),t="none"!==e,n=this._host.disabled();this.root.classList.toggle("u2-fb-locked",t),this._remove.hidden=t,this._handle.hidden=t||!this._host.advanced(),this._prop.root.hidden=t,this._op.root.hidden=t,this._propText.hidden=!t,this._opText.hidden=!t,tA.apply(this._remove,n);for(let e=0,t=[this._prop,this._op];e<t.length;e++){let i=t[e];i.disabled!==n&&(i.disabled=n)}var i=!0,r=!1,o=void 0;try{for(var s,a=this._editors[Symbol.iterator]();!(i=(s=a.next()).done);i=!0)s.value.setDisabled(null!=n?n:"all"===e?sR.LOCKED:null)}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}}_releaseEditors(){var e;null==(e=this._editorScope)||e.dispose(),this._editorScope=void 0,this._editors=[],this._valueHost.textContent="",this._valueHost.append(this._problem)}_buildEditors(e,t,n){if(this._releaseEditors(),!t||!n||"none"===n.editor||0===n.arity)return;let i=new P.Scope;this._editorScope=i,i.build(()=>{if("list"===n.editor)this._mount(this._listEditor(e,t),"value");else if("range"===n.editor){let n=sA(sR._bounds(e),2),i=n[0],r=n[1];this._mount(this._scalarEditor(t,i,e=>this._writeBound(0,e)),"value"),this._valueHost.insertBefore(t$("and","u2-fb-and"),this._problem),this._mount(this._scalarEditor(t,r,e=>this._writeBound(1,e)),"value2")}else this._mount(this._singleEditor(e,t),"value")})}_mount(e,t){e.root.classList.add(`u2-fb-${t}`),e.root.dataset.u2Part=t,this._valueHost.insertBefore(e.root,this._problem),this._editors.push(e)}_syncEditors(e){let t=2===this._editors.length?sR._bounds(e):[e.value];for(let e=0;e<this._editors.length;e++)this._editors[e].set(t[e])}static _bounds(e){return Array.isArray(e.value)?[e.value[0],e.value[1]]:[void 0,void 0]}_writeBound(e,t){var n,i;let r=sR._bounds(this._cond);r[e]=t,this._change(r.every(e=>void 0===e)?void 0:[null!=(n=r[0])?n:null,null!=(i=r[1])?i:null])}_singleEditor(e,t){var n,i;let r=null==(n=(i=this._host).editors)?void 0:n.call(i,t,{inline:!0,value:e.value,onChanged:e=>this._change(e)});return r?sP(r,e=>e):this._scalarEditor(t,Array.isArray(e.value)?void 0:e.value,e=>this._change(e),e.operator)}_listEditor(e,t){var n;let i=oE(t),r=this._host.schema.values,o=e=>Array.isArray(e)?e:[];return sP(new rQ(sC(sS({inline:!0,value:o(e.value),itemText:sO,allowNew:!0,createItem:e=>sE(e,i),placeholder:"Type a value…"},r?{source:(e,n)=>sk(function*(){return(yield r(t,e,n)).map(e=>iy(e.value)&&e.label?sC(sS({},e.value),{name:e.label}):e.value)})()}:{items:null!=(n=t.choices)?n:[]}),{onChanged:e=>this._change(0===e.length?void 0:e)})),o)}_scalarEditor(e,t,n,i){let r=oE(e);if(e.choices){let i=e=>null==e?null:String(e),o=new n2({inline:!0,items:e.choices,value:i(t),onChanged:e=>n(null===e?void 0:sE(e,r))});return sT(o,e=>o.value=i(e))}let o=this._host.schema.values;if(r===n7.REF&&o){let r=new s_({inline:!0,prop:e,schema:this._host.schema,operator:i,value:iy(t)?t:null,onChanged:e=>n(null!=e?e:void 0)});return sT(r,e=>r.value=iy(e)?e:null)}switch(r){case n7.INT:case n7.FLOAT:{let i=new n6({inline:!0,mode:r,min:e.min,max:e.max,value:"number"==typeof t?t:null,onChanged:e=>n(null===e?void 0:e)});return sT(i,e=>i.value="number"==typeof e?e:null)}case n7.BIG_INT:{let e=e=>"number"==typeof e||"string"==typeof e&&/^-?\d+$/.test(e)?BigInt(e):null,i=new rB({inline:!0,value:e(t),onChanged:e=>n(null===e?void 0:e.toString())});return sT(i,t=>i.value=e(t))}case n7.BOOL:{let e=e=>!0===e?"true":!1===e?"false":null,i=new n2({inline:!0,items:["true","false"],value:e(t),onChanged:e=>n(null===e?void 0:"true"===e)});return sT(i,t=>i.value=e(t))}case n7.DATE_TIME:{let e=e=>i_(e)?iE(iO(e.span,new Date),e.span):e instanceof Date?e:null,i=new iG({inline:!0,relative:!0,value:e(t),onChanged:e=>n(null===e?void 0:void 0===iT(e)?e:{span:iT(e)})});return sT(i,t=>{var n,r,o,s;(n=i.peek())!==(r=e(t))&&(null===n||null===r||(null!=(o=iT(n))?o:n.getTime())!==(null!=(s=iT(r))?s:r.getTime()))&&(i.value=e(t))})}default:{let i=e=>null==e?"":sO(e),s={inline:!0,value:i(t),onChanged:e=>n(""===e?void 0:e)},a=o&&r===n7.STRING?new sy(sC(sS({},s),{openOnFocus:!0,source:(t,n)=>sk(function*(){return(yield o(e,t,n)).map(e=>sO(e.value))})()})):new nF(s);return sT(a,e=>a.value=i(e))}}}constructor(e,t){super(),this._editorKey="",this._editors=[],this.id=e.id,this._host=t,this._cond=e,this.root.classList.add("u2-fb-cond"),this.root.dataset.u2="filter-row",this.root.dataset.u2Node=e.id,this.build(()=>this._build(e)),this.update(e)}}sR.LOCKED="Locked by the template",sR.NOTHING_TO_ADD="The schema has no property to filter by";class sj extends H{update(e){this._text.textContent=`(${sv(e)||"…"})`,this.applyLock()}applyLock(){let e=this._host.lockOf(this.id);this.root.classList.toggle("u2-fb-locked","none"!==e),this._remove.hidden="none"!==e,tA.apply(this._remove,this._host.disabled())}setProblem(e){sL(this.root,this._problem,e)}constructor(e,t){super(),this.id=e.id,this._host=t,this.root.classList.add("u2-fb-cond","u2-fb-nested"),this.root.dataset.u2="filter-row",this.root.dataset.u2Node=e.id,this._text=t$("","u2-fb-nested-text"),this._text.dataset.u2Part="value",this._remove=this.build(()=>sN(()=>this._host.remove(this.id))),this._problem=sM("u2-fb-problem","problem"),this.root.append(this._text,this._remove,this._problem),this.update(e)}}class sD extends H{get id(){return this._group.id}update(e){this._group=e,this.connector.selected.peek()[0]!==e.op&&(this.connector.selected.value=[e.op]),this.root.classList.toggle("u2-fb-negated",!0===e.not),this.not.classList.toggle("u2-fb-not-on",!0===e.not),this.not.setAttribute("aria-pressed",String(!0===e.not)),this.applyLock()}applyLock(){let e=this._host.advanced(),t="none"!==this._host.lockOf(this.id),n=this._host.disabled();this.root.classList.toggle("u2-fb-locked",t),this.not.hidden=!e;let i=null!=n?n:t?sR.LOCKED:null;tA.apply(this.not,i),this.not.title=null!=i?i:"Negate the group",this.connector.setDisabled("and",i),this.connector.setDisabled("or",i),this.add.hidden=t||!this._host.allowAdd,tA.apply(this.add,null!=n?n:0===this._host.properties().length?sR.NOTHING_TO_ADD:null),this.addGroup.hidden=!e||t||!this._host.allowAdd,tA.apply(this.addGroup,n),this.remove&&(this.remove.hidden=t,tA.apply(this.remove,n)),this.handle&&(this.handle.hidden=t)}setProblem(e){this.root.classList.toggle("u2-fb-invalid",null!==e),null===e?this.header.removeAttribute("title"):this.header.title=e}constructor(e,t,n){let i=void 0!==n&&n;super(),this._host=t,this._group=e,this.root.classList.add(i?"u2-fb-root":"u2-fb-group"),i||(this.root.dataset.u2="filter-group",this.root.dataset.u2Node=e.id),this.connector=this.build(()=>new rj({toggle:"single",density:"toolbar",items:[{id:"and",text:"and"},{id:"or",text:"or"}]})),this.connector.root.classList.add("u2-fb-connector"),this.connector.root.dataset.u2Part="connector",this.not=tB("not",()=>this._host.change(this.id,{not:!0!==this._group.not||void 0})),this.not.classList.add("u2-fb-not"),this.not.dataset.u2Part="not",this.not.title="Negate the group",this.add=this.build(()=>t6("plus",()=>this._host.add(this.id,"condition"),{tooltip:"Add condition"})),this.add.classList.add("u2-fb-add"),this.add.dataset.u2Part="add",this.addGroup=this.build(()=>t6("folder-plus",()=>this._host.add(this.id,"group"),{tooltip:"Add group"})),this.addGroup.classList.add("u2-fb-add-group"),this.addGroup.dataset.u2Part="add-group";const r=[this.connector.root,this.not,this.add,this.addGroup];i||(this.handle=sI(),this.remove=this.build(()=>sN(()=>this._host.remove(this.id),"group")),r.unshift(this.handle),r.push(this.remove)),this.header=tR(r,i?"u2-fb-header":"u2-fb-group-header"),this.rows=tR([],i?"u2-fb-rows":"u2-fb-group-rows"),this.rows.dataset.u2Part="rows",this.root.append(this.header,this.rows),this.effect(()=>{let e=this.connector.selected.value[0];void 0!==e&&e!==this._group.op&&this._host.change(this.id,{op:e})}),this.update(e)}}function s$(e,t,n,i,r){var o;if((null==(o=e.parent)?void 0:o.id)!==t)return{parentId:t,index:n,kind:i,rect:r};let s=n>e.index?n-1:n;return s===e.index?null:{parentId:t,index:s,kind:i,rect:r}}class sF{dispose(){this._end(!1),this._host.root.removeEventListener("pointerdown",this._onDown),this.indicator.remove()}_down(e){if(0!==e.button||this._drag)return;let t=e.target.closest('[data-u2-part="handle"]'),n=null==t?void 0:t.closest("[data-u2-node]");t&&n&&(e.preventDefault(),this._drag={id:n.dataset.u2Node,row:n,x:e.clientX,y:e.clientY,active:!1,hits:[],target:null},t.setPointerCapture(e.pointerId),document.addEventListener("pointermove",this._onMove),document.addEventListener("pointerup",this._onUp),document.addEventListener("pointercancel",this._onCancel),document.addEventListener("keydown",this._onKey))}_move(e){let t=this._drag;if(!t)return;if(!t.active){if(4>Math.abs(e.clientX-t.x)&&4>Math.abs(e.clientY-t.y))return;t.active=!0,t.hits=this._host.hits(),t.row.classList.add("u2-fb-dragging")}let n=function(e,t,n,i,r){let o,s=new Map;id(e,(e,t,n)=>s.set(e.id,{parent:t,index:n,depth:t?s.get(t.id).depth+1:0}));let a=s.get(r);if(!a)return null;var l=!0,u=!1,d=void 0;try{for(var c,h,p=t[Symbol.iterator]();!(l=(h=p.next()).done);l=!0){let e=h.value;s.has(e.id)&&(c=e.rect,n>=c.x&&n<=c.x+c.width&&i>=c.y&&i<=c.y+c.height)&&(!o||s.get(e.id).depth>=s.get(o.id).depth)&&(o=e)}}catch(e){u=!0,d=e}finally{try{l||null==p.return||p.return()}finally{if(u)throw d}}if(!o||o.id===r)return null;let f=il(e,r);if(ia(f)&&il(f,o.id))return null;let m=il(e,o.id);if(ia(m))return s$(a,m.id,m.nodes.length,"into",o.rect);let g=s.get(m.id),v=g.parent,b=g.index,y=i>o.rect.y+o.rect.height/2,_={x:o.rect.x,y:y?o.rect.y+o.rect.height:o.rect.y,width:o.rect.width,height:2};return s$(a,v.id,b+ +!!y,"line",_)}(this._host.tree(),t.hits,e.clientX,e.clientY,t.id);t.target=n&&this._host.accepts(t.id,n.parentId)?n:null,this._show(t.target)}_end(e){let t=this._drag;!t||(this._drag=void 0,document.removeEventListener("pointermove",this._onMove),document.removeEventListener("pointerup",this._onUp),document.removeEventListener("pointercancel",this._onCancel),document.removeEventListener("keydown",this._onKey),t.active&&(t.row.classList.remove("u2-fb-dragging"),this._show(null),e&&t.target&&this._host.drop(t.id,t.target)))}_show(e){let t=this.indicator;if(t.hidden=null===e,!e)return;let n=this._host.root,i=n.getBoundingClientRect();t.classList.toggle("u2-fb-drop-into","into"===e.kind),t.classList.toggle("u2-fb-drop-line","line"===e.kind),t.style.left=`${e.rect.x-i.left+n.scrollLeft}px`,t.style.top=`${e.rect.y-i.top+n.scrollTop}px`,t.style.width=`${e.rect.width}px`,t.style.height=`${e.rect.height}px`}constructor(e){this._host=e,this._onDown=e=>this._down(e),this._onMove=e=>this._move(e),this._onUp=()=>this._end(!0),this._onCancel=()=>this._end(!1),this._onKey=e=>{"Escape"===e.key&&this._end(!1)},this.indicator=tR([],"u2-fb-drop"),this.indicator.hidden=!0,e.root.append(this.indicator),e.root.addEventListener("pointerdown",this._onDown)}}class sz extends nC{addCondition(e,t){var n,i,r;let o=this.peek(),s=this._host.properties()[0];if(!s)return"";let a=is(s.name,null!=(n=null==(i=this._host.operators(s)[0])?void 0:i.id)?n:"=");return this._append(o,a,e,t),null==(r=this._rows.get(a.id))||r.focus(),a.id}addGroup(e,t){let n=this.peek(),i=e&&il(n,e)||n,r=io(ia(i)&&"and"===i.op?"or":"and");return this._append(n,r,e,t),r.id}get disabled(){return super.disabled}set disabled(e){super.disabled=e,null==(a=this._rootRow)||a.applyLock();var t=!0,n=!1,i=void 0;try{for(var r,o,s,a,l,u,d,c=(null!=(r=null==(l=this._rows)?void 0:l.values())?r:[])[Symbol.iterator]();!(t=(d=c.next()).done);t=!0)d.value.applyLock()}catch(e){n=!0,i=e}finally{try{t||null==c.return||c.return()}finally{if(n)throw i}}for(let e=0,t=[...null!=(o=this._links)?o:[],...null!=(s=null==(u=this._joins)?void 0:u.values())?s:[]];e<t.length;e++){let n=t[e];tA.apply(n,this.disabled)}}touch(){super.touch(),this._revealed.value=!0}removeNode(e){this.value=im(this.peek(),e)}setMode(e){var t;return"simple"!==e||ih(this.peek())?"advanced"===e&&(null==(t=this.options.template)?void 0:t.allowAdvanced)===!1?(this._showHint(null),!1):(this._mode.value=e,!0):(this._showHint(this.peek()),!1)}getWidgetStatus(){let e=super.getWidgetStatus();return e.parts.rows=this._rootRow.rows,e.parts.add=this._rootRow.add,e.parts.connector=this._rootRow.connector.root,e.parts.mode=this._modeLink,this._queryEl&&(e.parts.query=this._queryEl),e.tree=this.peek(),e.query=this._query.peek(),e.problems=this._problems.peek(),e.mode=this._advanced()?"advanced":"simple",e}static withIds(e){var t,n;let i,r;if(!e||!Array.isArray(e.nodes))return io("and");let o=!0;return id(e,e=>{"string"!=typeof e.id&&(o=!1)}),o?e:(t=e,i=(n=!0,n),(r=e=>{let t=i?ir():e.id;if(ia(e))return n9(n8({},e),{id:t,nodes:e.nodes.map(r)});let n=n9(n8({},e),{id:t});return Array.isArray(e.value)&&(n.value=e.value.slice()),void 0!==e.options&&(n.options=n8({},e.options)),n})(t))}isEmptyValue(e){return nC.isEmpty(e)||0===ic(e)}createEditor(){var e,t,n,i;let r=this.options;this._mode=r.mode instanceof P.Signal?r.mode:(0,P.signal)(null!=(e=r.mode)?e:"simple"),this._query=(0,P.computed)(()=>sv(this.value)),this._problems=(0,P.computed)(()=>sa(this.value,r.schema,r.target,r.template)),this._rows=new Map,this._scopes=new Map,this._joins=new Map,this._horizontal="horizontal"===r.orientation,this._warned=!1,this._touchedRows=(0,P.signal)(new Set),this._revealed=(0,P.signal)(!1),this._host={schema:r.schema,editors:null!=(t=r.editors)?t:sz.defaultEditors,allowAdd:(null==(n=r.template)?void 0:n.allowAdd)!==!1,properties:()=>this._properties(),operators:e=>this._operators(e),lockOf:e=>this._lockOf(e),disabled:()=>this.disabled,advanced:()=>this._advanced(),change:(e,t)=>this._change(e,t),add:(e,t)=>"group"===t?this.addGroup(e):this.addCondition(e),remove:e=>this.removeNode(e)},this._rootRow=new sD(sz.withIds(this.peek()),this._host,!0),this._links=[];let o=(e,t)=>{let n=tz(e,()=>{null===this.disabled&&t()});return this._links.push(n),n};this._modeLink=o((0,P.computed)(()=>"simple"===this._mode.value?"Advanced":"Simple"),()=>this.setMode("simple"===this._mode.peek()?"advanced":"simple")),this._modeLink.classList.add("u2-fb-mode"),this._modeLink.dataset.u2Part="mode",this._modeLink.hidden=(null==(i=r.template)?void 0:i.allowAdvanced)===!1,this._rootRow.header.append(this._modeLink);let s=[t$("No conditions")];if(this._host.allowAdd){let e=o("Add condition",()=>this.addCondition());e.classList.add("u2-fb-none-add"),e.dataset.u2Part="none-add",s.push(e)}return this._none=tD(s,"u2-fb-none"),this._none.dataset.u2Part="none",this._hintText=t$("","u2-fb-hint-text"),this._flatten=o("Flatten",()=>{let e=ig(this.peek());e&&(this.value=e,this._mode.value="simple")}),this._flatten.dataset.u2Part="flatten",this._hintMode=o("Advanced",()=>this.setMode("advanced")),this._hintMode.dataset.u2Part="hint-mode",this._hint=tR([this._hintText,this._flatten,this._hintMode],"u2-fb-hint"),this._hint.dataset.u2Part="hint",this._hint.setAttribute("role","status"),this._hint.hidden=!0,this._panel=tR([this._rootRow,this._hint],"u2-fb"),r.showQuery&&(this._queryEl=t$(this._query,"u2-fb-query"),this._queryEl.dataset.u2Part="query",this._panel.append(this._queryEl)),this._drag=new sF({root:this._panel,tree:()=>this.peek(),hits:()=>this._hits(),accepts:(e,t)=>this._accepts(e,t),drop:(e,t)=>this.value=function(e,t,n,i){let r=il(e,t),o=iu(e,t);if(!r||!o||t===n||ia(r)&&il(r,n))return e;let s=im(e,t),a=il(s,n);if(!a||!ia(a))return e;let l=Math.min(Math.max(i,0),a.nodes.length);return o.id===n&&o.nodes.indexOf(r)===l?e:ip(s,n,l,r)}(this.peek(),e,t.parentId,t.index)}),this.own(()=>this._drag.dispose()),this.scope.listen(this._panel,"focusout",e=>{var t,n;let i=e.target,r=(null==(t=i.closest)?void 0:t.call(i,".u2-fb-values"))?null==(n=i.closest("[data-u2-node]"))?void 0:n.dataset.u2Node:void 0;void 0!==r&&this._touchRow(r)}),this.addValidator(()=>{var e,t;return null!=(e=null==(t=this._problems.value[0])?void 0:t.message)?e:null}),this.effect(()=>this._render()),this._panel}_advanced(){var e;return"advanced"===this._mode.value&&(null==(e=this.options.template)?void 0:e.allowAdvanced)!==!1}_touchRow(e){this._touchedRows.peek().has(e)||(this._touchedRows.value=new Set([...this._touchedRows.peek(),e]))}_change(e,t){"value"in t&&this._touchRow(e);let n=this.peek(),i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},il(n,e),t);var r=!0,o=!1,s=void 0;try{for(var a,l=Object.keys(t)[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){let e=a.value;void 0===i[e]&&delete i[e]}}catch(e){o=!0,s=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw s}}this.value=n.id===e?ia(i)?i:n:ik(n,e,()=>i)}_accepts(e,t){var n;return"none"===this._lockOf(e)&&"none"===this._lockOf(t)&&(this._host.allowAdd||(null==(n=iu(this.peek(),e))?void 0:n.id)===t)}_append(e,t,n,i){let r=n&&il(e,n)||e,o=ia(r)?r:e;this.value=ip(e,o.id,null!=i?i:o.nodes.length,t)}_properties(){var e;let t=null==(e=this.options.template)?void 0:e.allowedProperties,n=this.options.schema.properties;return t?n.filter(e=>t.includes(e.name)):n}_operators(e){var t,n,i,r,o;let s=o8.for(e),a=null!=(t=null==(n=(i=this.options.schema).operators)?void 0:n.call(i,e,s))?t:s,l=null==(o=this.options.template)||null==(r=o.allowedOperators)?void 0:r[e.name];return l?a.filter(e=>l.includes(e.id)):a}_lockOf(e){var t;let n=si(this.peek(),e),i=null==(t=this.options.template)?void 0:t.root,r=i?si(i,e):"none";return"all"===n||"all"===r?"all":"value"===n||"value"===r?"value":"none"}_hits(){let e=Array.from(this._panel.querySelectorAll("[data-u2-node]")).map(e=>({id:e.dataset.u2Node,rect:e.getBoundingClientRect()}));return e.push({id:this.peek().id,rect:this._rootRow.rows.getBoundingClientRect()}),e}_showHint(e){var t;let n=null!==e&&null!==ig(e),i=null!==e&&!this._advanced()&&(null==(t=this.options.template)?void 0:t.allowAdvanced)!==!1;this._hintText.textContent=null===e?"This filter cannot use advanced mode.":n?"This filter has nested groups. ":"This filter has nested groups that cannot be flattened. ",this._flatten.hidden=!n,this._hintMode.hidden=!i,this._hint.hidden=!1}_render(){let e=this.value,t=sz.withIds(e);if(t!==e)return void this.systemWrite(t);let n=this._advanced(),i=this._horizontal&&!n;n&&this._horizontal&&!this._warned&&(this._warned=!0,console.warn("u2: FilterBuilder ignores orientation in advanced mode")),n||ih(t)?this._hint.hidden=!0:this._showHint(t),this._panel.classList.toggle("u2-fb-horizontal",i),this.root.classList.toggle("u2-fb-blank",0===ic(t)),this._panel.classList.toggle("u2-fb-advanced",n),this._rootRow.header.hidden=i,this._rootRow.update(t),i||this._rootRow.add.parentElement===this._rootRow.header||this._rootRow.header.insertBefore(this._rootRow.add,this._rootRow.addGroup);let r=new Set,o=this._revealed.value?this._problems.value:this._problems.value.filter(e=>"missing-value"!==e.code||null==e.nodeId||this._touchedRows.value.has(e.nodeId));this._renderChildren(t,this._rootRow,n,i,o,r);var s=!0,a=!1,l=void 0;try{for(var u,d=this._rows.keys()[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){let e=u.value;r.has(e)||this._releaseRow(e)}}catch(e){a=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(a)throw l}}var c=!0,h=!1,p=void 0;try{for(var f,m=this._joins.values()[Symbol.iterator]();!(c=(f=m.next()).done);c=!0)f.value.textContent=t.op}catch(e){h=!0,p=e}finally{try{c||null==m.return||m.return()}finally{if(h)throw p}}this.refreshDisabled()}_renderChildren(e,t,n,i,r,o){let s=[];var a=!0,l=!1,u=void 0;try{for(var d,c,h=e.nodes[Symbol.iterator]();!(a=(c=h.next()).done);a=!0){let e=c.value,t=ia(e)?n?"group":"nested":"cond",a=this._rows.get(e.id);a&&sz._kindOf(a)!==t&&(this._releaseRow(e.id),a=void 0),a?a.update(e):a=this._mountRow(t,e);let l=r.find(t=>t.nodeId===e.id);a.setProblem(null!=(d=null==l?void 0:l.message)?d:null,(null==l?void 0:l.code)==="missing-value"),o.add(e.id),i&&s.length>0&&s.push(this._join(e.id)),s.push(a.root),a instanceof sD&&this._renderChildren(e,a,n,!1,r,o)}}catch(e){l=!0,u=e}finally{try{a||null==h.return||h.return()}finally{if(l)throw u}}0===s.length&&t===this._rootRow&&s.push(this._none),i&&!this._rootRow.add.hidden&&s.push(this._rootRow.add),sz._place(t.rows,s)}_mountRow(e,t){let n=new P.Scope,i=()=>n.dispose();this.scope.own(i),n.own(()=>this.scope.disown(i)),this._scopes.set(t.id,n);let r=n.build(()=>"cond"===e?new sR(t,this._host):"group"===e?new sD(t,this._host):new sj(t,this._host));return this._rows.set(t.id,r),r}_releaseRow(e){var t;null==(t=this._scopes.get(e))||t.dispose(),this._scopes.delete(e),this._rows.delete(e),this._joins.delete(e)}static _kindOf(e){return e instanceof sR?"cond":e instanceof sD?"group":"nested"}static _place(e,t){for(let i=0;i<t.length;i++){var n;let r=t[i];e.children[i]!==r&&e.insertBefore(r,null!=(n=e.children[i])?n:null)}for(;e.children.length>t.length;)e.children[e.children.length-1].remove()}_join(e){let t=this._joins.get(e);if(!t){let n=this._scopes.get(e);(t=n.build(()=>tB("",()=>{var e,t;let n=this.peek();this.value=(e=n.id,t={op:"and"===n.op?"or":"and"},n.id===e?n8({},n,t):ik(n,e,e=>n8({},e,t)))}))).classList.add("u2-fb-join"),t.setAttribute("aria-label","Switch and/or"),tS.bind(t,"Switch and/or",{owner:n}),this._joins.set(e,t)}return t}constructor(e){super(e,io("and")),this.query=this._query,this.problems=this._problems,this.mode=this._mode,this.modeSwitch=this._modeLink,this.root.classList.add("u2-filter-builder"),this.root.dataset.u2="filter-builder"}}sz.defaultEditors=null;n7.STRING,n7.INT,n7.FLOAT,n7.BIG_INT,n7.DATE_TIME,n7.BOOL,n7.STRING_LIST,n7.REF,n7.BOOL,n7.DATE_TIME,n7.REF;function sq(e){return e.replace(/["\\]/g,"").trim()}let sB=["users","groups","projects","queries","connections","scripts","spaces"];function sG(e,...t){return[{name:"label",type:"string",bindable:!0},{name:"name",type:"string",description:"Stable key for forms and dumps; defaults to the label."},{name:"value",type:e,bindable:!0,twoWay:!0},{name:"inline",type:"bool",structural:!0,description:"Compact one-row variant without a label."},{name:"postfix",type:"string",bindable:!0,description:"Units or a short suffix shown after the editor."},{name:"tooltipText",type:"string",bindable:!0},{name:"disabled",type:"string",bindable:!0,description:"Why the input is off — greyed out, edits blocked, the reason as its tooltip; empty while on."},{name:"readOnly",type:"bool",bindable:!0,description:"Shows the value, selectable, but blocks edits."},{name:"required",type:"bool",bindable:!0,description:"An empty value is invalid once the input was edited, left or its form validated."},...t]}class sV extends H{get cls(){var e;return(null!=(e=this._cls)?e:[]).join(" ")}set cls(e){var t;this.root.classList.remove(...null!=(t=this._cls)?t:[]),this._cls=String(null!=e?e:"").split(/\s+/).filter(e=>e),this.root.classList.add(...this._cls)}get gap(){var e;return null!=(e=this._gap)?e:""}set gap(e){this._gap&&this.root.classList.remove(`u2-gap-${this._gap}`),this._gap=null!=e?e:"",this._gap&&this.root.classList.add(`u2-gap-${this._gap}`)}}function sU(e,t,n){return{tag:e,category:"Containers",create:e=>{var n,i;let r=new sV(t());return r.cls=null!=(n=e.cls)?n:"",r.gap=null!=(i=e.gap)?i:"",r},description:n,props:[{name:"cls",type:"string",description:"Extra layout class."},{name:"gap",type:"string",choices:["xs","s","m","l","xl","xxl"],description:"Space between the children on the token scale: 2, 4, 8, 12, 16 or 24px."}],acceptsChildren:!0,example:{tag:e,children:[{tag:"u2-text-input",props:{label:"Name"}}]}}}function sH(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function sW(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return sH(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return sH(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}sG("string",{name:"placeholder",type:"string",bindable:!0},{name:"search",type:"bool",structural:!0,description:"Magnifier affordance plus a clear button."},{name:"password",type:"bool",structural:!0,description:"Masked field with an eye toggle."},{name:"autoResize",type:"bool",structural:!0,description:"Width follows the text between 100 and 300px."}),sG("string",{name:"placeholder",type:"string",bindable:!0},{name:"autoGrow",type:"bool",structural:!0,description:"Grows with the text instead of scrolling."},{name:"rows",type:"int",description:"Visible text lines."}),sG("bool",{name:"switch",type:"bool",structural:!0,description:"Compact toggle instead of a checkbox."},{name:"captionAfter",type:"bool",structural:!0,description:"Checklist row: the box, then its caption."}),sG("double",{name:"mode",type:"string",choices:["int","float"],structural:!0,description:'"int" or "float" (default).'},{name:"min",type:"double"},{name:"max",type:"double"},{name:"step",type:"double",description:"Spinner, clicker and arrow-key increment; 1 by default."},{name:"slider",type:"bool",structural:!0,description:"Range control under the box, revealed on hover; needs both bounds."},{name:"clicker",type:"bool",structural:!0,description:"− / + buttons on the options rail, revealed on hover."},{name:"spinner",type:"bool",structural:!0,description:"Hover spinner inside the field."},{name:"placeholder",type:"string",bindable:!0}),sG("string",{name:"items",type:"string_list",bindable:!0},{name:"nullable",type:"bool",structural:!0,description:"Offers an empty option; true by default."}),sG("string_list",{name:"items",type:"string_list",bindable:!0},{name:"emptyText",type:"string",description:"Stands in for an empty list; 'No items' by default."},{name:"showSummaryCheckbox",type:"bool",structural:!0,description:'Tri-state "<N> of <M>" summary row that toggles all/none; the list collapses on click.'}),sU("u2-panel",()=>{let e=tN(tT("div","u2-div","u2-panel"),void 0);return e.dataset.u2="panel",e},"Padded vertical container."),sU("u2-div-v",()=>{let e=tj();return e.dataset.u2="div-v",e},"Vertical stack."),sU("u2-div-h",()=>{let e=tD();return e.dataset.u2="div-h",e},"Horizontal row."),sG("double",{name:"min",type:"double"},{name:"max",type:"double"},{name:"step",type:"double",description:"(max - min) / 100 by default."}),sG("string",{name:"items",type:"string_list"},{name:"buttons",type:"bool",structural:!0,description:"Raised-button variant instead of radio dots."},{name:"itemTooltips",type:"object",description:"Hover text per item."}),sG("string",{name:"swatchOnly",type:"bool",structural:!0,description:"Swatch alone, no hex field."}),sG("string").map(e=>{var t,n;return"value"===e.name?(t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},e),n=(n={inputType:"Icon"},n),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t):e}),sG("string_list",{name:"placeholder",type:"string",bindable:!0}),sG("object"),sG("object",{name:"fields",type:"string_list",structural:!0,description:"The columns: text fields, in order."},{name:"addText",type:"string",structural:!0,description:"The add link's text; Add by default."},{name:"orderable",type:"bool",structural:!0,description:"Rows move by a handle or Alt+↑/↓."}),sG("string_list",{name:"items",type:"string_list",bindable:!0},{name:"orderable",type:"bool",structural:!0,description:"Rows move by a handle or Alt+↑/↓."}),sG("string_list",{name:"items",type:"string_list",bindable:!0},{name:"emptyText",type:"string",description:"Stands in for an empty list; 'No items' by default."}),sG("object",{name:"capabilities",type:"string_list",structural:!0,description:"The columns, in order."},{name:"principals",type:"string_list",bindable:!0,description:"What the add picker offers."},{name:"principalLabel",type:"string",description:"The first column's header; Group by default."},{name:"addText",type:"string",description:"The picker's placeholder."}),sG("double",{name:"placeholder",type:"string",bindable:!0}),rF.less(5.2),sG("string",{name:"families",type:"string_list",structural:!0,description:"Families on offer; four defaults otherwise."},{name:"sizes",type:"object",structural:!0,description:"Sizes in the popup under the size box."}),sG("string",{name:"alt",type:"string",description:"Alternative text."}),sG("object",{name:"schema",type:"object",structural:!0,description:"`{properties: IProperty[], values?: {<name>: scalar[]}}` — what can be filtered on."},{name:"mode",type:"string",choices:["simple","advanced"],bindable:!0,twoWay:!0,description:"simple: one flat and/or group; advanced: nested groups, not, drag handles."},{name:"orientation",type:"string",choices:["vertical","horizontal"],structural:!0,description:"horizontal lays the rows out inline with a connector chip between them."},{name:"template",type:"object",structural:!0,description:"`{root, allowedProperties?, allowedOperators?, allowAdvanced?, allowAdd?}` — locks and limits: `allowAdvanced: false` keeps the builder simple, `allowAdd: false` fixes the rows."},{name:"showQuery",type:"bool",structural:!0,description:"Footer line with the canonical query string; off by default."},{name:"target",type:"string",choices:["domain","dataframe"],structural:!0,description:"What the tree must be expressible for; validation only."},{name:"query",type:"string",bindable:!0,description:"The canonical query string (read-only)."}),sG("object",{name:"schema",type:"object",structural:!0,description:"`{properties: IProperty[], values?: {<name>: scalar[]}}` — what can be filtered on."},{name:"placeholder",type:"string"},{name:"target",type:"string",choices:["domain","dataframe"],structural:!0,description:"What the tree must be expressible for; validation only."},{name:"query",type:"string",bindable:!0,description:"The draft text (per keystroke, may be unparsable; read-only)."});let sY=/^[A-Za-z_$][A-Za-z0-9_$]*$/;class sK{markClean(){this._mark=this._topSerial(),this._version.value++}_topSerial(){return this._undo.length>0?this._undo[this._undo.length-1].serial:0}canApply(e){var t,n,i;switch(e.op){case"add":{let n=this.instance.registry.get(e.node.tag);if((null==n?void 0:n.visual)===!1)return`${e.node.tag} is a data source — it belongs on the components tray`;return null!=(t=this._checkParent(e.parent))?t:this._checkIndex(e.parent,e.index,!1)}case"add-component":{let t=this._components();if(t.includes(e.node))return`"${s0(e.node)}" is already on the tray`;let n=this.instance.registry.get(e.node.tag);if(n&&!1!==n.visual)return`${e.node.tag} is a visual component — it belongs in the form`;return Number.isInteger(e.index)&&e.index>=0&&e.index<=t.length?null:`index ${e.index} is out of range for the tray (0..${t.length})`}case"remove-component":return this._components().includes(e.node)?null:`"${s0(e.node)}" is not on the tray`;case"remove":return this._checkStructural(e.node);case"move":{let t=null!=(n=null!=(i=this._checkStructural(e.node))?i:this._checkParent(e.parent))?n:this._checkIndex(e.parent,e.index,this.instance.parentOf(e.node)===e.parent);if(t)return t;return e.node===e.parent||ob.contains(e.node,e.parent)?`"${s0(e.node)}" cannot move into itself`:null}case"set-prop":{let t=this._prop(e.node,e.name);if(!t)return`${e.node.tag} has no prop "${e.name}"`;if(!this._rendered(t.own?e.node:this.instance.parentOf(e.node)))return`"${s0(e.node)}" is not rendered`;return void 0===e.value?null:oy(t.prop,e.value)}case"set-bind":{if(!this._rendered(e.node))return`"${s0(e.node)}" is not rendered`;if(void 0===e.path)return null;let t=e.name.indexOf(".");if(t>=0){let n=e.name.slice(0,t),i=this._prop(e.node,n);if(!i)return`${e.node.tag} has no prop "${n}"`;if(!i.prop.subBindable)return`prop "${n}" does not take sub-binds`}else{let t=this._prop(e.node,e.name);if(!t)return`${e.node.tag} has no prop "${e.name}"`;if(t.prop.subBindable&&!t.prop.bindable)return`prop "${e.name}" takes sub-binds only`}if(!e.path.startsWith("$."))return`a bind path must start with "$." — got "${e.path}"`;if(null===oi(e.path))return`"${e.path}" is not a valid bind path`;return this._checkCycle(e.node,e.name,e.path)}case"set-event":if(!this._rendered(e.node))return`"${s0(e.node)}" is not rendered`;return void 0===e.command?null:sK._checkEvent(e.command);case"rename":{if(!this._rendered(e.node))return`"${s0(e.node)}" is not rendered`;if(void 0===e.name)return null;if(!sY.test(e.name))return`"${e.name}" is not a valid name: letters, digits, _ and $, not starting with a digit`;let t=this._named().get(e.name);if(void 0!==t&&t!==e.node)return`"${e.name}" is already taken`;return sK._inContext(this.instance,e.name)?`"${e.name}" is already a context data key or command`:null}}}apply(e){let t=this.canApply(e);if(t)throw Error(`u2 editor: ${t}`);let n=this._inverse(e),i=this._undo[this._undo.length-1];i&&"apply"===i.origin&&1===i.patches.length&&sK._mergeable(i.patches[0],e)?(i.patches=[e],i.serial=++this._serial):(this._undo.push({patches:[e],inverses:[n],origin:"apply",serial:++this._serial}),this._undo.length>200&&this._undo.shift()),this._redo.length=0,this._execute(e),this._publish([e],"apply")}applyAll(e){if(0===e.length)return;let t=[],n=[];var i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value,i=this.canApply(e);if(i)throw this._unwind(n),Error(`u2 editor: ${i}`);n.push(this._inverse(e));try{this._execute(e)}catch(e){throw this._unwind(n),e}t.push(e)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}this._undo.push({patches:t,inverses:n,origin:"apply",serial:++this._serial}),this._undo.length>200&&this._undo.shift(),this._redo.length=0,this._publish(t,"apply")}_unwind(e){for(let t=e.length-1;t>=0;t--)this._execute(e[t])}undo(){let e=this._undo.pop();if(void 0===e)return!1;let t=[];for(let n=e.inverses.length-1;n>=0;n--)this._execute(e.inverses[n]),t.push(e.inverses[n]);return this._redo.push(e),this._publish(t,"undo"),!0}redo(){let e=this._redo.pop();if(void 0===e)return!1;var t,n,i=!0,r=!1,o=void 0;try{for(var s,a=e.patches[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;this._execute(e)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}return this._undo.push((t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},e),n=n={origin:"redo"},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t)),this._publish(e.patches,"redo"),!0}nodePath(e){let t=[],n=i=>{var r;if(i===e)return!0;let o=null!=(r=i.children)?r:[];for(let e=0;e<o.length;e++){if(t.push(e),n(o[e]))return!0;t.pop()}return!1};return n(this.instance.spec.root)?t:null}nodeAt(e){let t=this.instance.spec.root;var n=!0,i=!1,r=void 0;try{for(var o,s,a=e[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){let e=s.value,n=null==(o=t.children)?void 0:o[e];if(void 0===n)return null;t=n}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}return t}uniqueName(e){return this.uniqueNames()(e)}uniqueNames(){let e=new Set(this._named().keys());return t=>{let n=sK._free(t,e);return e.add(n),n}}duplicate(e){let t=JSON.parse(JSON.stringify(e)),n=this._named(),i=e=>{void 0!==e.name&&(e.name=sK._free(e.name.replace(/\d+$/,""),n),n.set(e.name,e));var t=!0,r=!1,o=void 0;try{for(var s,a,l=(null!=(s=e.children)?s:[])[Symbol.iterator]();!(t=(a=l.next()).done);t=!0){let e=a.value;i(e)}}catch(e){r=!0,o=e}finally{try{t||null==l.return||l.return()}finally{if(r)throw o}}};return i(t),t}_execute(e){let t=this._targets(e);t.push(...this._mutate(e)),void 0!==e.node.name&&t.push(...oa(this.instance.spec,e.node.name)),this.instance.rerenderAll(t)}_components(){var e;return null!=(e=this.instance.spec.components)?e:[]}_targets(e){switch(e.op){case"add":return[e.parent];case"add-component":case"remove-component":return[];case"remove":return[this.instance.parentOf(e.node)];case"move":return[this.instance.parentOf(e.node),e.parent];case"set-prop":return[this._prop(e.node,e.name).own?e.node:this.instance.parentOf(e.node)];default:return[e.node]}}_publish(e,t){this._version.value++,this._lastApplied.value={patches:e,origin:t,structural:e.some(e=>"set-prop"!==e.op&&"set-bind"!==e.op&&"set-event"!==e.op)}}_inverse(e){var t,n,i,r;switch(e.op){case"add":return{op:"remove",node:e.node};case"add-component":return{op:"remove-component",node:e.node};case"remove-component":return{op:"add-component",index:this._components().indexOf(e.node),node:e.node};case"remove":case"move":{let n=this.instance.parentOf(e.node),i=(null!=(t=n.children)?t:[]).indexOf(e.node);return"remove"===e.op?{op:"add",parent:n,index:i,node:e.node}:{op:"move",node:e.node,parent:n,index:i}}case"set-prop":return{op:"set-prop",node:e.node,name:e.name,value:null==(n=e.node.props)?void 0:n[e.name]};case"set-bind":return{op:"set-bind",node:e.node,name:e.name,path:null==(i=e.node.bind)?void 0:i[e.name]};case"set-event":return{op:"set-event",node:e.node,event:e.event,command:null==(r=e.node.on)?void 0:r[e.event]};case"rename":return{op:"rename",node:e.node,name:e.node.name}}}_checkCycle(e,t,n){var i,r;if(void 0===e.name)return null;let o=Object.prototype.hasOwnProperty.call(null!=(i=e.bind)?i:{},t),s=null==(r=e.bind)?void 0:r[t];sK._entry(e,"bind",t,n);let a=ol(this.instance.spec);return sK._entry(e,"bind",t,o?s:void 0),null!==a&&a.includes(e.name)?`binding "${n}" would create a cycle: ${a.join(" → ")}`:null}static _checkEvent(e){let t="string"==typeof e?e:null==e?void 0:e.cmd;return"string"==typeof t&&t.startsWith("cmd:")?"string"!=typeof e&&void 0!==e.args&&("object"!=typeof e.args||null===e.args||Array.isArray(e.args))?"event args must be a plain object of argument values":null:`an event must name a command as 'cmd:' followed by the command name — got '${"string"==typeof t?t:JSON.stringify(e)}'`}_checkStructural(e){if(e===this.instance.spec.root)return"the root node cannot be removed or moved";if(this._components().includes(e))return`"${s0(e)}" is a component — the tray has its own add and remove`;let t=this.instance.parentOf(e);return null===t?`"${s0(e)}" is not in the spec`:this._rendered(t)?null:`"${s0(t)}" is not rendered`}_checkParent(e){let t=this.instance.registry.get(e.tag);return(t?!0===t.acceptsChildren||void 0!==t.adopt||void 0!==t.createWithChildren:o_(e.tag))?this._rendered(e)?null:`"${s0(e)}" is not rendered`:`${e.tag} takes no children`}_checkIndex(e,t,n){var i;let r=(null!=(i=e.children)?i:[]).length-!!n;return Number.isInteger(t)&&t>=0&&t<=r?null:`index ${t} is out of range for ${e.tag} (0..${r})`}_prop(e,t){var n,i;let r=this.instance.registry.get(e.tag),o=r?r.props.find(e=>e.name===t):o_(e.tag)?ow(e.tag).find(e=>e.name===t):void 0;if(o)return{prop:o,own:!0};let s=this.instance.parentOf(e),a=s?null==(i=this.instance.registry.get(s.tag))||null==(n=i.childProps)?void 0:n.find(e=>e.name===t):void 0;return a?{prop:a,own:!1}:null}_rendered(e){return this.instance.nodes().has(e)}static _inContext(e,t){let n=Object.prototype.hasOwnProperty;return n.call(e.ctx.data,t)||n.call(e.ctx.commands,t)}_named(){let e=new Map,t=n=>{void 0===n.name||e.has(n.name)||e.set(n.name,n);var i=!0,r=!1,o=void 0;try{for(var s,a,l=(null!=(s=n.children)?s:[])[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let e=a.value;t(e)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}};t(this.instance.spec.root);var n=!0,i=!1,r=void 0;try{for(var o,s=this._components()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;t(e)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return e}static _free(e,t){for(let n=1;;n++){let i=`${e}${n}`;if(!t.has(i))return i}}_mutate(e){switch(e.op){case"add":return sK._insert(e.parent,e.index,e.node),[];case"add-component":{let t=this.instance.spec;return t.components?t.components.splice(e.index,0,e.node):t.components=[e.node],this.instance.mountComponent(e.node),[]}case"remove-component":{let t=this.instance.spec.components;return this.instance.unmountComponent(e.node),t.splice(t.indexOf(e.node),1),0===t.length&&delete this.instance.spec.components,[]}case"remove":return sK._detach(this.instance.parentOf(e.node),e.node),[];case"move":return sK._detach(this.instance.parentOf(e.node),e.node),sK._insert(e.parent,e.index,e.node),[];case"set-prop":return sK._entry(e.node,"props",e.name,e.value),[];case"set-bind":return sK._entry(e.node,"bind",e.name,e.path),[];case"set-event":return sK._entry(e.node,"on",e.event,e.command),[];case"rename":{let a=e.node.name,l=[];if(void 0!==a&&void 0!==e.name){l.push(...sQ(this.instance.spec.root,a,e.name));var t=!0,n=!1,i=void 0;try{for(var r,o,s=(null!=(r=this.instance.spec.components)?r:[])[Symbol.iterator]();!(t=(o=s.next()).done);t=!0){let t=o.value;l.push(...sQ(t,a,e.name))}}catch(e){n=!0,i=e}finally{try{t||null==s.return||s.return()}finally{if(n)throw i}}}return void 0===e.name?delete e.node.name:e.node.name=e.name,l.filter(e=>this._rendered(e))}}}static _insert(e,t,n){e.children?e.children.splice(t,0,n):e.children=[n]}static _detach(e,t){let n=e.children;n.splice(n.indexOf(t),1),0===n.length&&delete e.children}static _entry(e,t,n,i){let r=e[t];void 0!==i?r?r[n]=i:e[t]={[n]:i}:r&&(delete r[n],0===Object.keys(r).length&&delete e[t])}static _mergeable(e,t){return e.op===t.op&&e.node===t.node&&("set-prop"===e.op&&"set-prop"===t.op||"set-bind"===e.op&&"set-bind"===t.op?e.name===t.name:"set-event"===e.op&&"set-event"===t.op&&e.event===t.event)}constructor(e){this.instance=e,this._undo=[],this._redo=[],this._version=(0,P.signal)(0),this._lastApplied=(0,P.signal)(null),this._serial=0,this._mark=0,this.canUndo=(0,P.computed)(()=>this._version.value>=0&&this._undo.length>0),this.canRedo=(0,P.computed)(()=>this._version.value>=0&&this._redo.length>0),this.dirty=(0,P.computed)(()=>this._version.value>=0&&this._topSerial()!==this._mark),this.onDidApply=this._lastApplied}}function sX(e){let t=e.startsWith("u2-")?e.slice(3).split("-"):[e];return t[0]+t.slice(1).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}function sZ(e,t,n,i){let r,o={tag:t,name:n},s=(null==e?void 0:e.defaults)?JSON.parse(JSON.stringify(e.defaults)):{};return(null==e?void 0:e.props.some(e=>"label"===e.name))&&void 0===s.label&&(s.label=(r=n.replace(/([A-Z])/g," $1").replace(/(\d+)$/," $1").toLowerCase()).charAt(0).toUpperCase()+r.slice(1)),Object.keys(s).length>0&&(o.props=s),(null==e?void 0:e.defaultChildren)&&i&&(o.children=e.defaultChildren.map(e=>(function e(t,n){t.name=n(sX(t.tag));var i=!0,r=!1,o=void 0;try{for(var s,a,l=(null!=(s=t.children)?s:[])[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let t=a.value;e(t,n)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}return t})(JSON.parse(JSON.stringify(e)),i))),o}function sQ(e,t,n){let i=[],r=e=>e.startsWith(`cmd:${t}.`)?`cmd:${n}.${e.slice(t.length+5)}`:null,o=e=>{let s=!1;var a=!0,l=!1,u=void 0;try{for(var d,c,h,p,f=Object.entries(null!=(d=e.bind)?d:{})[Symbol.iterator]();!(a=(p=f.next()).done);a=!0){let i=sW(p.value,2),r=i[0],o=i[1],a=sJ(o,t,n);null!==a&&(e.bind[r]=a,s=!0)}}catch(e){l=!0,u=e}finally{try{a||null==f.return||f.return()}finally{if(l)throw u}}var m=!0,g=!1,v=void 0;try{for(var b,y=Object.entries(null!=(c=e.on)?c:{})[Symbol.iterator]();!(m=(b=y.next()).done);m=!0){let i=sW(b.value,2),o=i[0],a=i[1];if("string"==typeof a){let t=r(a);null!==t&&(e.on[o]=t,s=!0);continue}let l=r(a.cmd);null!==l&&(a.cmd=l,s=!0);var _=!0,w=!1,x=void 0;try{for(var k,S,C=Object.entries(null!=(k=a.args)?k:{})[Symbol.iterator]();!(_=(S=C.next()).done);_=!0){let e=sW(S.value,2),i=e[0],r=e[1],o="string"==typeof r?sJ(r,t,n):null;null!==o&&(a.args[i]=o,s=!0)}}catch(e){w=!0,x=e}finally{try{_||null==C.return||C.return()}finally{if(w)throw x}}}}catch(e){g=!0,v=e}finally{try{m||null==y.return||y.return()}finally{if(g)throw v}}s&&i.push(e);var A=!0,O=!1,E=void 0;try{for(var T,P=(null!=(h=e.children)?h:[])[Symbol.iterator]();!(A=(T=P.next()).done);A=!0){let e=T.value;o(e)}}catch(e){O=!0,E=e}finally{try{A||null==P.return||P.return()}finally{if(O)throw E}}};return o(e),i}function sJ(e,t,n){return oo(e,t)?`$.${n}${e.slice(t.length+2)}`:null}function s0(e){var t;return null!=(t=e.name)?t:e.tag}function s2(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}class s1{static run(e){let t=new s1(e);return t._start(),t}next(){this._active.value&&this._show(this._step.value+1)}skip(){this.finish("skipped")}finish(e){var t,n,i,r;this._active.value&&(this._active.value=!1,s1._current===this&&(s1._current=void 0),null==(t=this._stepScope)||t.dispose(),this._stepScope=void 0,this._scope.dispose(),this.overlay.remove(),this.popup.remove(),(null==(n=this._restore)?void 0:n.isConnected)&&this._restore.focus(),null==(i=(r=this._options).onFinish)||i.call(r,void 0===e?"done":e))}_start(){var e,t;null==(t=s1._current)||t.finish("skipped"),s1._current=this,this._restore=null!=(e=document.activeElement)?e:void 0,this.overlay.style.zIndex=String(tx.nextLayer()),this.popup.style.zIndex=String(tx.nextLayer()),tx.host.append(this.overlay,this.popup),this._active.value=!0,this._scope.listen(document,"keydown",e=>this._onKeyDown(e),{capture:!0}),this._scope.own(()=>this._stopAutoUpdate()),this._show(0)}_show(e){var t,n;null==(n=this._stepScope)||n.dispose(),this._stepScope=void 0,this._stopAutoUpdate(),this._stopAutoUpdate=()=>{};let i=e;for(;i<this._steps.length&&!this._enterStep(i);)i++;if(i>=this._steps.length)return void this.finish("done");let r=this._steps[i],o=new P.Scope(void 0,{label:"tour-step"});this._stepScope=o,this._step.value=i,this._content.replaceChildren(),"string"==typeof r.content?this._content.textContent=r.content:this._content.append("function"==typeof r.content?o.build(r.content):r.content);let s=this._steps.map((e,t)=>t===i||s1._renderable(this._element(e.target))),a=s.slice(0,i+1).filter(Boolean).length,l=s.filter(Boolean).length;this._counter.textContent=`${a} / ${l}`,this._next.textContent=a===l?this._doneLabel:this._nextLabel;let u=null!=(t=r.position)?t:"bottom";this._place(u),this._stopAutoUpdate=th(this._target,this.popup,()=>this._place(u),{animationFrame:!0});let d=r.advanceOn;d instanceof Promise?d.then(()=>this._advance(o)):d&&o.effect(()=>{d.value&&this._advance(o)}),this._next.focus()}_advance(e){this._stepScope===e&&this.next()}_enterStep(e){let t=this._steps[e],n=this._element(t.target);if(!s1._renderable(n)){let n="string"==typeof t.target?t.target:`step ${e+1}`;return this._warned.has(n)||(this._warned.add(n),console.warn(`u2: tour target "${n}" not found — step skipped`)),!1}return this._target=n,this._extra=void 0===t.extra?null:this._element(t.extra),!0}_element(e){var t;return"function"==typeof e?e():"string"!=typeof e?e:(null!=(t=this._options.root)?t:document).querySelector(`[data-u2-name="${e}"]`)}_place(e){let t=this._target;t&&t.isConnected?(s1._setHole(this._hole,t),s1._setHole(this._extraHole,this._extra),tg(t,this.popup,{strategy:"fixed",placement:e,middleware:[tp(8),tm({padding:4}),tf({padding:4})]}).then(e=>{let t=e.x,n=e.y;this.popup.style.left=`${t}px`,this.popup.style.top=`${n}px`})):this.next()}_onKeyDown(e){let t=e.target;"Escape"===e.key?(e.preventDefault(),this.skip()):"Enter"!==e.key||s1._isTextEntry(t)?"Tab"===e.key&&t&&this.popup.contains(t)&&this._trapTab(e):(e.preventDefault(),this.next())}_trapTab(e){let t=s1._focusable(this.popup);if(0===t.length)return;let n=document.activeElement;e.shiftKey&&n===t[0]?(e.preventDefault(),t[t.length-1].focus()):e.shiftKey||n!==t[t.length-1]||(e.preventDefault(),t[0].focus())}static _focusable(e){return Array.from(e.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent)}static _isTextEntry(e){return!!e&&(/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)||e.isContentEditable)}static _renderable(e){if(!e||!e.isConnected)return!1;let t=e.getBoundingClientRect();return t.width>0&&t.height>0}static _setHole(e,t){let n=t?t.getBoundingClientRect():new DOMRect,i=4*!!t;e.setAttribute("x",String(n.left-i)),e.setAttribute("y",String(n.top-i)),e.setAttribute("width",String(n.width+2*i)),e.setAttribute("height",String(n.height+2*i))}static _svg(e,t){let n=document.createElementNS("http://www.w3.org/2000/svg",e);for(let e in t)n.setAttribute(e,t[e]);return n}constructor(e){var t,n,i;this._scope=new P.Scope,this._step=(0,P.signal)(0),this._active=(0,P.signal)(!1),this._content=tR([],"u2-tour-content"),this._counter=t$("","u2-tour-counter"),this._warned=new Set,this._target=null,this._extra=null,this._stopAutoUpdate=()=>{},this._options=e,this._steps=e.steps,this.step=this._step,this.active=this._active;const r=`u2-tour-mask-${++s1._seq}`;this._hole=s1._svg("rect",{class:"u2-tour-hole",fill:"black",rx:String(4)}),this._extraHole=s1._svg("rect",{class:"u2-tour-hole",fill:"black",rx:String(4)});const o=s1._svg("mask",{id:r});o.append(s1._svg("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:"white"}),this._hole,this._extraHole);const s=s1._svg("defs",{});s.append(o);const a=s1._svg("rect",{x:"0",y:"0",width:"100%",height:"100%",mask:`url(#${r})`});a.style.fill="var(--dg-tour-dim, rgba(0, 0, 0, 0.6))";const l=s1._svg("svg",{});l.append(s,a),this.overlay=tR([],"u2-tour-overlay"),this.overlay.dataset.u2="tour",this.overlay.append(l);const u=null!=(t=e.buttons)?t:{};this._nextLabel=null!=(n=u.next)?n:"NEXT",this._doneLabel=null!=(i=u.done)?i:"DONE";const d=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(e)||function(e){if(e){if("string"==typeof e)return s2(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return s2(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(this._scope.build(()=>{var e;return[tB(null!=(e=u.skip)?e:"SKIP",()=>this.skip()),tB(this._nextLabel,()=>this.next(),{primary:!0})]})),c=d[0],h=d[1];c.classList.add("u2-tour-skip"),h.classList.add("u2-tour-next"),this._next=h,this.popup=tR([this._content,tR([c,this._counter,h],"u2-tour-footer")],"u2-tour-popup"),this.popup.setAttribute("role","dialog"),this.popup.tabIndex=-1}}function s3(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function s5(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return s3(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s3(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}s1._seq=0;let s4=["res","converters","internal"];function s6(e){let t=[],n=[],i=[];var r=!0,o=!1,s=void 0;try{for(var a,l=e.split(" ")[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){let e=a.value;if(""!==e)if(e.startsWith("#")||e.startsWith("@")){let t=e.slice(1).toLowerCase();""!==t&&(e.startsWith("#")?n:i).push(t)}else t.push(e.toLowerCase())}}catch(e){o=!0,s=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw s}}return{terms:t,tags:n,roles:i}}function s8(e,t){return!e.tags.includes("internal")&&t.every(t=>e.search.includes(t))}function s9(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function s7(e,t){let n=s6(t).terms,i=new Map;var r=!0,o=!1,s=void 0;try{for(var a,l=e[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){let e=a.value,t=s8(e,n);var u=!0,d=!1,c=void 0;try{for(var h,p,f=e.tags[Symbol.iterator]();!(u=(p=f.next()).done);u=!0){let e=p.value;i.set(e,(null!=(h=i.get(e))?h:0)+ +!!t)}}catch(e){d=!0,c=e}finally{try{u||null==f.return||f.return()}finally{if(d)throw c}}}}catch(e){o=!0,s=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw s}}return i}class ae extends H{setItems(e){this._source.value=Array.isArray(e)?(0,P.signal)(e):e}getItems(e){return this._list.getItems(e)}revealItem(e){return this._list.revealItem(e)}bindStep(e){if("search"===e)return this.query;if("selected"===e)return null!=this._selectedName||(this._selectedName=(0,P.computed)(()=>{var e,t;return null!=(e=null==(t=this.selected.value)?void 0:t.name)?e:null})),this._selectedName;return super.bindStep(e)}bindProps(){let e=super.bindProps();return e.push({name:"search",type:"string",writable:!0}),e.some(e=>"selected"===e.name)||e.push({name:"selected",type:"string",writable:!1}),e}_live(e,t){var n;if(!(e instanceof P.Signal))return(0,P.signal)(null!=e?e:t);let i=(0,P.signal)(null!=(n=e.peek())?n:t);return this.effect(()=>{let t=e.value;void 0!==t&&(i.value=t)}),i}_activate(e){var t,n;void 0!==e&&(null==(t=(n=this.options).onActivate)||t.call(n,e),this.fireEvent("activate",e))}_renderRow(e,t){var n,i;t.setAttribute("data-u2-func",e.name),t.setAttribute("aria-label",void 0!==e.signature&&this.showSignature.peek()?`${e.label} — ${e.signature}`:e.label),e.description&&(t.title=e.description);let r=this.options.render;if(r)return r(e,t);let o=[],s=this.options.runAction;if(s){let t=document.createElement("button");t.type="button",t.className="u2-btn u2-icon-btn u2-fb-run",t.title="Run",t.setAttribute("aria-label","Run"),t.append(tK("play",{variant:"solid"})),t.addEventListener("click",()=>s(e)),o.push(t)}let a=null==(n=(i=this.options).icon)?void 0:n.call(i,e);return a&&o.push(tR([a],"u2-fb-icon")),o.push(t$(e.label,"u2-fb-label")),void 0!==e.signature&&o.push(t$(e.signature,"u2-fb-sig")),tR(o,"u2-fb-row")}_rebuildTagRows(e){var t,n;let i=this._source.value.value,r=new Set((null!=(t=this.options.ignoreTags)?t:s4).map(e=>e.toLowerCase())),o=new Set((null!=(n=this.options.visibleTags)?n:[]).map(e=>e.toLowerCase())),s=[...new Set(i.flatMap(e=>e.tags))].filter(e=>!r.has(e)&&(0===o.size||o.has(e))).sort();if(s.length===this._tagList.length&&s.every((e,t)=>e===this._tagList[t]))return;this._tagList=s,this._tagRows.clear();let a=s.map(e=>{let t=this._paneRow("fb-tag",this.checkedTags,e,e,e,!0);return this._tagRows.set(e,t),t.row});e.replaceChildren(tR(["Tags"],"u2-fb-pane-header"),...a),this._applyPaneState(s7(i,this.query.peek()),this.checkedTags.peek(),this.checkedRoles.peek())}_applyPaneState(e,t,n){var i=!0,r=!1,o=void 0;try{for(var s,a,l=this._tagRows[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let n=s5(a.value,2),i=n[0],r=n[1];r.box.checked=t.has(i),r.count.textContent=String(null!=(s=e.get(i))?s:0)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}var u=!0,d=!1,c=void 0;try{for(var h,p=this._roleRows[Symbol.iterator]();!(u=(h=p.next()).done);u=!0){let e=s5(h.value,2),t=e[0];e[1].box.checked=n.has(t)}}catch(e){d=!0,c=e}finally{try{u||null==p.return||p.return()}finally{if(d)throw c}}}_paneRow(e,t,n,i,r,o){let s=document.createElement("input");s.type="checkbox",s.className="u2-input-checkbox",s.setAttribute("aria-label",i),s.addEventListener("change",()=>{let e=new Set(t.peek());s.checked?e.add(n):e.delete(n),t.value=e});let a=t$(i,"u2-fb-pane-label");a.title=r||i,a.addEventListener("click",()=>{let e=t.peek();t.value=e.has(n)&&1===e.size?new Set:new Set([n])});let l=o?t$("","u2-fb-count"):null,u=tR(l?[s,a,l]:[s,a],"u2-fb-pane-row");return u.dataset.u2=e,u.dataset.value=n,{row:u,box:s,count:l}}_listen(e,t,n){e.addEventListener(t,n),this.own(()=>e.removeEventListener(t,n))}constructor(e){var t,n,i;let r=void 0===e?{}:e;super(),this._source=(0,P.signal)((0,P.signal)([])),this._selected=(0,P.signal)(null),this._tagRows=new Map,this._roleRows=new Map,this._tagList=[],this._lastShown=[],this._scrollPending=!1,this.options=r,this.root.classList.add("u2-functions-browser"),this.root.dataset.u2="functions-browser";let o=null!=(t=r.search)?t:"";const s=s6(o).tags,a=(null!=(n=r.tags)?n:[]).map(e=>e.toLowerCase()).filter(e=>!s.includes(e));a.length>0&&(o=[o.trim(),...a.map(e=>`#${e}`)].filter(e=>""!==e).join(" "));const l=s6(o);this.query=(0,P.signal)(o),this.checkedTags=(0,P.signal)(new Set(l.tags)),this.checkedRoles=(0,P.signal)(new Set(l.roles)),this.showSearch=this._live(r.showSearch,!0),this.showTags=this._live(r.showTags,!0),this.showSignature=this._live(r.showSignature,!0),this.showRunButton=this._live(r.showRunButton,!0),void 0!==r.items&&this.setItems(r.items),this._shown=(0,P.computed)(()=>{var e,t,n,i;let r,o,s;return e=this._source.value.value,t=this.query.value,n=this.checkedTags.value,i=this.checkedRoles.value,o=new Set([...(r=s6(t)).tags,...n]),s=new Set([...r.roles,...i]),e.filter(e=>{var t;return s8(e,r.terms)&&(0===o.size||e.tags.some(e=>o.has(e)))&&(0===s.size||(null!=(t=e.roles)?t:[]).some(e=>s.has(e)))})});const u=this.build(()=>new nF({search:!0,inline:!0,placeholder:"Search by name, #tag, or @role",bind:this.query})),d=tD([u,this.build(()=>t6("filter",()=>{},{tooltip:"Toggle filter panel",toggle:this.showTags}))],"u2-fb-search");d.dataset.u2="fb-search",this._listen(u.root,"keydown",e=>{"ArrowDown"===e.key&&(e.preventDefault(),this._list.focusRows())});const c=void 0===r.roles?null:tR([],"u2-fb-pane");if(c){c.dataset.u2="fb-roles";const e=(null!=(i=r.roles)?i:[]).map(e=>{let t=e.role.toLowerCase(),n=this._paneRow("fb-role",this.checkedRoles,t,e.role,e.description,!1);return this._roleRows.set(t,n),n.row});c.replaceChildren(tR(["Roles"],"u2-fb-pane-header"),...e)}const h=tR([],"u2-fb-pane");h.dataset.u2="fb-tags";const p=tj(c?[c,h]:[h],"u2-fb-panes");p.dataset.u2="fb-panes";const f=r.contextActions;this._list=this.build(()=>{var e;return new nb({itemHeight:null!=(e=r.itemHeight)?e:28,keyOf:e=>e.name,labelOf:e=>e.label,render:(e,t,n)=>this._renderRow(e,n),contextActions:f?e=>f(e):void 0})}),this._list.root.setAttribute("data-u2","fb-list"),this._list.setItems(this._shown);const m=t$("","u2-fb-empty-message"),g=this.build(()=>tB("Clear search",()=>this.query.value=""));g.classList.add("u2-fb-clear"),g.dataset.u2="fb-clear";const v=tj([m,g],"u2-async-empty u2-fb-empty");v.dataset.u2="fb-empty";const b=t$("","u2-fb-status");b.dataset.u2="fb-status";const y=tj([this._list,v,b],"u2-fb-main");this.root.append(d,tD([p,y],"u2-fb-body")),this.selected=this._selected,this.effect(()=>{var e,t,n,i;let r=this._shown.value,o=this._list.selectedIndex.value,s=null!=(e=r[o])?e:null,a=null!=(t=null==s?void 0:s.name)?t:null,l=null!=(n=null==(i=this._selected.peek())?void 0:i.name)?n:null,u=r!==this._lastShown;if(this._lastShown=r,u&&a!==l){if(null!==l&&r.some(e=>e.name===l)){this._scrollPending=!0;return}this._selected.value=null,this._scrollPending=!1;return}this._selected.value=s,(u||this._scrollPending)&&o>=0&&this._list.scrollToIndex(o),this._scrollPending=!1}),this.effect(()=>{let e=s6(this.query.value);(0,P.batch)(()=>{s9(new Set(e.tags),this.checkedTags.peek())||(this.checkedTags.value=new Set(e.tags)),s9(new Set(e.roles),this.checkedRoles.peek())||(this.checkedRoles.value=new Set(e.roles))})}),this.effect(()=>{let e=this.checkedTags.value,t=this.checkedRoles.value,n=s6(this.query.peek());s9(new Set(n.tags),e)&&s9(new Set(n.roles),t)||(this.query.value=[...n.terms,...[...e].map(e=>`#${e}`),...[...t].map(e=>`@${e}`)].join(" "))}),this.effect(()=>this._rebuildTagRows(h)),this.effect(()=>this._applyPaneState(s7(this._source.value.value,this.query.value),this.checkedTags.value,this.checkedRoles.value)),this.effect(()=>d.hidden=!1===this.showSearch.value),this.effect(()=>p.hidden=!1===this.showTags.value),this.effect(()=>this.root.classList.toggle("u2-fb-no-signature",!1===this.showSignature.value)),this.effect(()=>this.root.classList.toggle("u2-fb-no-run",!1===this.showRunButton.value)),this.effect(()=>{let e=this._source.value.value.filter(e=>!e.tags.includes("internal")).length,t=this._shown.value,n=t.length>0;b.textContent=`${t.length} of ${e}`,m.textContent=n?"":0===e?"No functions.":`No functions match "${this.query.value.trim()}".`,g.hidden=n||0===e,v.hidden=n,this._list.root.hidden=!n});let _=!0;this.effect(()=>{var e,t;let n=this.selected.value;if(_){_=!1;return}null==(e=(t=this.options).onChanged)||e.call(t,n),this.fireEvent("change",n)}),this._listen(this._list.root,"dblclick",e=>{let t=e.target,n=null==t?void 0:t.closest(".u2-list-row");n&&this._activate(this._shown.peek()[Number(n.dataset.index)])}),this._listen(this._list.root,"keydown",e=>{var t;"Enter"===e.key&&this._activate(null!=(t=this.selected.peek())?t:void 0)})}}function at(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function an(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let ai={label:'[data-u2-part="label"]',editor:'[data-u2-part="editor"]',options:'[data-u2-part="options"]',error:'[data-u2-part="error"]'},ar={input:["label","aria","placeholder"],action:["text","aria","title"],container:["title","aria"],collection:["aria"],navigation:["aria"],display:["text","aria"],overlay:["title","aria"],composite:["aria"]};function ao(e,t,n,i){return at({kind:t,noun:n,family:e,nameFrom:ar[e],parts:{},state:[],gestures:[]},void 0===i?{}:i)}function as(e,t,n,i,r,o){return ao("input",e,t,at({focusRole:n,parts:ai,state:["label",...i],gestures:r},void 0===o?{}:o))}function aa(e,t,n,i){return{kind:e,noun:t,family:i,nameFrom:[],parts:{},state:[],gestures:[],partOf:n}}let al={role:"option",noun:"item",gestures:["pick"]},au=["value","text","placeholder","valid","error","readOnly","required"],ad=["value","text","valid","error","readOnly","required"],ac=["value","text","valid","error","readOnly","required"],ah=[...ac,"open"],ap=["value","text","open","placeholder"],af={"--u2-row-base-bg":"a row at rest","--u2-row-hover-bg":"the tint over the row under the pointer","--u2-row-hover-stripe":"the stripe at the start of the row under the pointer","--u2-row-selected-bg":"a selected row","--u2-section-header-bg":"a group's header row"};as("text-input","text input","textbox",au,["type","clear"],{aliases:["text field","textbox"]}),as("text-area","text area","textbox",au,["type","clear"],{aliases:["textarea","multiline input"]}),as("number-input","number input","spinbutton",ad,["type","clear"],{aliases:["numeric input","number field"]}),as("bigint-input","number input","spinbutton",ad,["type","clear"]),as("qnum-input","number input","textbox",ad,["type","clear"]),as("slider-input","slider","slider",ac,["drag"],{aliases:["slider input"]}),as("range-slider","range slider","slider",["value","text"],["drag"],{aliases:["range input"]}),as("bool-input","checkbox","checkbox",[...ac,"checked"],["toggle"],{aliases:["bool input","switch","toggle"]}),as("choice-input","choice input","combobox",[...ac,"items","selection"],["open","pick"],{aliases:["dropdown","choice","select"],items:al}),as("radio-input","radio input","radiogroup",[...ac,"items"],["pick"],{aliases:["radio group","radio"],items:{role:"radio",noun:"radio",gestures:["pick"]}}),as("multi-choice-input","multi choice input","group",[...ac,"items","selection"],["toggle"],{aliases:["multi choice"],items:{role:"checkbox",noun:"checkbox",gestures:["toggle"],multi:!0}}),as("chips-input","chips input","group",[...ac,"items","selection"],["toggle"],{items:{role:"button",noun:"chip",gestures:["toggle"],multi:!0}}),as("tags-input","tags input","textbox",[...ah,"items"],["type","add","remove"],{aliases:["tags field"],items:{role:"listitem",noun:"tag",gestures:["remove"]}}),as("list-input","list input","textbox",[...ac,"items"],["type","add","remove"],{items:{role:"listitem",noun:"tag",gestures:["remove"]}}),as("map-input","map input","grid",[...ac,"items"],["add","remove","type"],{aliases:["key value input"],items:{role:"row",noun:"item",gestures:["remove"]}}),as("records-input","records input","grid",[...ac,"items"],["add","remove","type","drag"],{aliases:["records editor","editable list"],parts:an(at({},ai),{add:'[data-u2-part="add"]',handle:'[data-u2-part="handle"]'}),items:{role:"row",noun:"item",gestures:["remove","drag"]}}),as("checklist-input","checklist","list",[...ac,"items","selection"],["toggle","drag"],{aliases:["checklist input","orderable checklist"],parts:an(at({},ai),{handle:'[data-u2-part="handle"]'}),items:{role:"listitem",noun:"item",gestures:["toggle","drag"],multi:!0}}),as("color-input","color input","textbox",ac,["type","pick"],{aliases:["color picker"]}),as("icon-input","icon input","button",ah,["open","pick"],{aliases:["icon picker"]}),as("font-input","font input","textbox",[...ah,"items","selection"],["open","pick"],{aliases:["font picker"],items:{role:"option",noun:"size",gestures:["pick"]}}),as("image-input","image input",void 0,ac,["clear"],{aliases:["image picker"]}),as("date-input","date input","textbox",ah,["type","open","pick"],{aliases:["date field","datetime input","date picker"]}),as("datetime-input","date input","textbox",ah,["type","open","pick"]),as("combobox","combobox","combobox",[...ap,"busy","items"],["type","open","pick"],{aliases:["combo box","editable choice"],items:al}),as("typeahead","suggest input","combobox",[...ap,"busy","items"],["type","open","pick"],{aliases:["autocomplete","typeahead"],items:al}),as("pick-input","pick input","combobox",["value","text","valid","error","open","placeholder"],["type","open","pick"],{items:al}),as("suggest-input","suggest input","combobox",[...ah,"placeholder","busy","items"],["type","open","pick"],{items:al}),as("multi-select","multi select","combobox",[...ah,"items","selection"],["open","toggle"],{aliases:["multi select input"],items:{role:"option",noun:"item",gestures:["toggle"],multi:!0}}),as("access-grid","access grid","grid",[...ac,"items"],["add","toggle","remove"],{items:{role:"row",noun:"table row",gestures:["toggle","remove"]}}),as("message-input","message input","textbox",["value","text","open","placeholder"],["type"],{aliases:["prompt input","chat input"]}),as("filter-builder","filter builder","group",["value","valid","error"],["add","remove","type"],{parts:an(at({},ai),{mode:'[data-u2-part="mode"]',none:'[data-u2-part="none"]',flatten:'[data-u2-part="flatten"]',"hint mode":'[data-u2-part="hint-mode"]',hint:'[data-u2-part="hint"]',query:'[data-u2-part="query"]'}),items:{role:"row",noun:"filter row",gestures:["remove"]}}),as("filter-query-input","filter query","textbox",["value","valid","error"],["type"],{aliases:["filter query input"]}),as("ref-input","ref input","combobox",ap,["type","open","pick"],{items:al}),as("column-combo","column input","combobox",[...ah,"items","selection"],["open","pick"],{aliases:["column picker","column selector","column combobox"],items:al}),as("column-picker","column input","combobox",[...ah,"items"],["open","pick"],{items:al}),as("columns-input","columns input","button",[...ah,"items","selection"],["open","toggle"],{aliases:["columns picker"],items:{role:"option",noun:"item",gestures:["toggle"],multi:!0}}),as("columns-map-input","columns input","group",ac,["open","toggle"]),as("aggregated-columns-input","columns input","group",ac,["open","toggle"]),as("file-input","file input","group",[...ac,"busy"],["pick"],{aliases:["file field","files input"]}),as("files-input","file input","group",ac,["pick"]),as("function-input","function input","button",[...ah,"placeholder"],["open","pick"],{aliases:["func input"]}),as("func-call-input","function input","button",ah,["open","pick"]),as("rsa-input","rsa input","textbox",ac,["type"],{aliases:["key input"]}),as("space-input","space input","combobox",ah,["open","pick"],{aliases:["space picker"]}),as("dynamic-input","dynamic input",void 0,ac,["type","pick"]),as("dart-input","dart input",void 0,ac,["type"],{aliases:["bridged input"]}),ao("input","readonly-field","read-only field",{nameFrom:["label"],parts:{label:".u2-input-label",value:'[data-u2-part="readonly-value"]'},state:["label","value","text","readOnly"]}),ao("action","button","button",{role:"button",state:["label","busy","pressed"],gestures:["press"]}),ao("action","icon-button","icon button",{role:"button",nameFrom:["aria","title"],state:["label","pressed"],gestures:["press"]}),ao("action","dropdown-button","dropdown button",{aliases:["menu button","split button"],role:"button",state:["label","open"],gestures:["press","open","pick"]}),ao("action","choice-chip","choice chip",{role:"button",nameFrom:["label","aria","text"],parts:{label:'[data-u2-part="label"]',value:'[data-u2-part="value"]'},state:["label","value","text","valid","error","open","items","selection"],items:{role:"menuitemcheckbox",noun:"menu item",gestures:["pick"]},gestures:["open","pick"]}),ao("action","button-group","button group",{aliases:["segmented control"],role:"group",nameFrom:["aria"],state:["value","current","items"],items:{role:"button",noun:"button",gestures:["press"]},gestures:["pick"]}),ao("action","row-actions","row actions",{aliases:["actions"],role:"toolbar",nameFrom:["aria"],state:["items"],items:{role:"button",noun:"button",gestures:["press"]},gestures:["press"]}),ao("container","section","section",{aliases:["pane","accordion pane"],role:"group",parts:{title:':scope > [data-u2-part="header"] > [data-u2-part="title"]',header:':scope > [data-u2-part="header"]',body:':scope > [data-u2-part="body"]'},state:["label","expanded"],gestures:["expand","collapse"]}),ao("container","accordion","accordion",{nameFrom:["aria"],state:["items"],items:{role:"button",noun:"accordion header",gestures:["expand","collapse"]},gestures:["expand","collapse"]}),ao("container","tabs","tabs",{aliases:["tab strip","tab control"],nameFrom:["aria"],parts:{"close button":'[data-u2-part="close"]'},state:["current","items","selection"],items:{role:"tab",noun:"tab",gestures:["select"]},gestures:["select"]}),ao("container","wizard","wizard",{nameFrom:["aria"],parts:{steps:':scope > [data-u2-part="steps"]',body:':scope > [data-u2-part="body"]',footer:':scope > [data-u2-part="footer"]',status:':scope > [data-u2-part="footer"] > * > [data-u2-part="status"]',reason:':scope > [data-u2-part="footer"] > * > [data-u2-part="reason"]',"error row":':scope > [data-u2-part="footer"] > * > [data-u2-part="error-row"]'},state:["current","busy","valid","error","items"],items:{role:"listitem",noun:"wizard step",gestures:["select"]},gestures:["select"]}),ao("container","splitter","splitter",{aliases:["split panel"],nameFrom:["aria"],parts:{sash:'[data-u2-part="sash"]'},state:["extra"],gestures:["drag","resize"]}),ao("container","card","card",{nameFrom:["title","text"],parts:{title:':scope > [data-u2-part="header"] > * > [data-u2-part="title"]',subtitle:':scope > [data-u2-part="header"] > * > [data-u2-part="subtitle"]',header:':scope > [data-u2-part="header"]',media:':scope > [data-u2-part="media"]',body:':scope > [data-u2-part="body"]',footer:':scope > [data-u2-part="footer"]',actions:':scope > [data-u2-part="header"] > [data-u2-part="actions"]'},state:["label","selected"],gestures:["press"]}),ao("container","page","page",{nameFrom:["aria"],parts:{header:':scope > [data-u2-part="header"]',body:':scope > [data-u2-part="body"]',footer:':scope > [data-u2-part="footer"]',"section title":':scope > [data-u2-part="body"] > [data-u2-part="section"] > [data-u2-part="section-header"] > [data-u2-part="section-title"]'},styling:{"--u2-page-max-width":"the body's widest (a CSS length); its forms go as wide","--u2-page-padding-x":"the space left and right of the header, the body and the action row; 24px","--u2-page-padding-y":"the space above the header and the body; 12px","--u2-page-gap":"the space between the sections; 24px","--u2-page-section-indent":"how far a section's content sits in from its heading; 0"}}),ao("container","form","form",{role:"form",nameFrom:["aria"],state:["valid","error","items"],styling:{"--u2-form-max-width":"the widest a form gets (a CSS length); 700px, or as wide as the page in a Page","--u2-form-section-gap":"the space between two sections of the form; 0"}}),ao("container","object-form","object form",{role:"form",nameFrom:["aria"],state:["valid","error","items"]}),ao("container","func-form","function form",{aliases:["func form"],role:"form",nameFrom:["aria"],state:["valid","error","busy","items"]}),ao("container","panel","layout panel",{nameFrom:["aria"]}),ao("container","div-v","vertical stack",{nameFrom:["aria"]}),ao("container","div-h","horizontal stack",{nameFrom:["aria"]}),ao("container","async-view","async view",{aliases:["loading view"],nameFrom:["aria"],state:["busy","error"]}),ao("collection","list","list",{role:"listbox",state:["label","items","selection"],items:{role:"option",noun:"item",gestures:["select"]},gestures:["select","scroll"]}),ao("collection","tree","tree",{role:"tree",state:["items","selection"],parts:{"item-label":'[data-u2-part="item-label"]'},items:{role:"treeitem",noun:"tree node",gestures:["select","expand","collapse","toggle"]},gestures:["select","expand","collapse"]}),ao("collection","table","table",{role:"table",state:["items","selection"],parts:{"item-label":'[data-u2-part="item-label"]',section:'[data-u2-part="section"]'},items:{role:"row",noun:"table row",gestures:["select"]},gestures:["select","scroll"],styling:af}),ao("collection","data-table","table",{role:"grid",state:["items","selection"],parts:{"item-label":'[data-u2-part="item-label"]'},items:{role:"row",noun:"table row",gestures:["select"]},gestures:["select","scroll"]}),ao("collection","catalog-table","catalog table",{aliases:["records table"],nameFrom:["aria"],parts:{"item-label":'[data-u2-part="item-label"]',section:'[data-u2-part="section"]',footer:':scope > [data-u2-part="footer"]'},state:["items","busy","extra"],items:{role:"row",noun:"table row",gestures:["expand","collapse"]},gestures:["scroll"],styling:af}),ao("collection","master-detail","master detail",{aliases:["list with details"],nameFrom:["aria"],parts:{list:'[data-u2-part="list"]',detail:'[data-u2-part="detail"]',reason:'[data-u2-part="reason"]'},state:["current","items","selection"],items:{role:"option",noun:"item",gestures:["select","toggle"]},gestures:["select","toggle"],styling:{"--u2-master-detail-height":"its height (a CSS length); it fills its host by default","--u2-row-selected-bg":"the current row"}}),ao("collection","column-header","column header",{role:"columnheader",nameFrom:["text","aria"],gestures:["press"]}),ao("collection","grid","grid",{aliases:["virtual grid","cell grid"],role:"listbox",state:["items","selection"],items:{role:"option",noun:"cell",gestures:["select","pick"]},gestures:["select","scroll"]}),ao("collection","property-grid","property grid",{aliases:["property editor"],role:"grid",state:["items"],parts:{"item-label":'[data-u2-part="item-label"]',category:'[data-u2-part="category"]'},items:{role:"row",noun:"property",gestures:["type"]},gestures:["type"]}),ao("collection","property-editor","property grid",{state:["items"],gestures:["type"]}),ao("collection","functions-browser","functions browser",{state:["items","selection"],items:{role:"option",noun:"item",gestures:["select"]},gestures:["type","select"]}),ao("collection","func-call-history-browser","history browser",{aliases:["func call history browser","run history"],state:["items","busy","error"],items:{role:"option",noun:"item",gestures:["select"]},gestures:["select"]}),ao("collection","space-browser","space browser",{aliases:["open from space"],state:["items","selection"],items:{role:"option",noun:"item",gestures:["select"]},gestures:["type","select"]}),ao("navigation","breadcrumbs","breadcrumbs",{aliases:["breadcrumb bar"],role:"navigation",state:["current","items"],items:{role:"listitem",noun:"breadcrumb",gestures:["press"]},gestures:["press"]}),ao("navigation","menu","menu",{role:"menu",state:["open","items"],items:{role:"menuitem",noun:"menu item",gestures:["pick","hover"]},gestures:["pick","hover"]}),ao("navigation","menu-bar","menu bar",{role:"menubar",state:["items"],items:{role:"menuitem",noun:"menu item",gestures:["open","pick"]},gestures:["open","pick"]}),ao("navigation","toolbar","toolbar",{role:"toolbar",state:["items"],items:{role:"button",noun:"button",gestures:["press"]},gestures:["press"]}),ao("navigation","ribbon-group","ribbon group",{aliases:["package ribbon"],role:"toolbar",parts:{"more button":'[data-u2-part="more"]'},state:["items","extra"],items:{role:"button",noun:"ribbon button",gestures:["press"]},gestures:["press"]}),ao("overlay","dialog","dialog",{role:"dialog",parts:{title:':scope > .u2-dialog-title > [data-u2-part="title"]',"close button":':scope > .u2-dialog-title > [data-u2-part="close"]',body:':scope > [data-u2-part="body"]',footer:':scope > [data-u2-part="footer"]',"error row":':scope > [data-u2-part="error-row"]',spinner:':scope > [data-u2-part="footer"] > * > [data-u2-part="busy"]'},state:["label","open","busy","error","valid"],gestures:["close"]}),ao("overlay","tooltip","tooltip",{role:"tooltip",nameFrom:["text"],state:["text"],gestures:["hover"]}),ao("overlay","notify","notification",{aliases:["balloon","toast","message"],role:"status",nameFrom:["text"],state:["text","extra"],gestures:["close"]}),ao("overlay","tour","tour",{role:"dialog",nameFrom:["title"],state:["current","items"],gestures:["press"]}),ao("display","icon","icon",{nameFrom:["aria"],state:["label","extra"]}),ao("display","badge","badge",{state:["text"]}),ao("display","count-badge","badge",{state:["text"]}),ao("display","dot","badge",{state:["text"]}),ao("display","status-line","status line",{role:"status",nameFrom:["text"],state:["text"]}),ao("display","empty-state","empty state",{role:"status",nameFrom:["text"],state:["text"]}),ao("display","tag","tag",{nameFrom:["text"],state:["text","selected","pressed"]}),ao("display","chip","chip",{nameFrom:["text"],state:["text","selected","pressed"]}),ao("display","bind-chip","chip",{nameFrom:["text"],state:["text","selected","pressed"]}),ao("display","msg-chip","chip",{nameFrom:["text"],state:["text","selected","pressed"]}),ao("display","stat-card","stat card",{aliases:["stat"],nameFrom:["label","text"],parts:{label:'[data-u2-part="label"]',value:'[data-u2-part="value"]',delta:'[data-u2-part="delta"]'},state:["label","value","text","extra"]}),ao("display","app-header","app header",{aliases:["app hero"],nameFrom:["label","aria"],parts:{icon:'[data-u2-part="icon"]',title:'[data-u2-part="title"]',subtitle:'[data-u2-part="subtitle"]',"learn more":'[data-u2-part="learn-more"]'},state:["label","items","extra"],items:{role:"listitem",noun:"header item",gestures:[]}}),ao("display","progress-bar","progress bar",{aliases:["progress"],role:"progressbar",nameFrom:["label","aria"],parts:{label:'[data-u2-part="label"]',track:'[data-u2-part="track"]',percent:'[data-u2-part="percent"]'},state:["value","text","busy"]}),ao("display","entity-card","entity card",{aliases:["entity"],nameFrom:["title","text"],parts:{title:'[data-u2-part="title"]'},state:["label"]}),ao("composite","designer","designer",{state:["busy"]}),ao("composite","palette","palette"),ao("composite","tray","tray"),ao("composite","filter-group","filter group",{parts:{connector:'[data-u2-part="connector"]',not:'[data-u2-part="not"]',add:'[data-u2-part="add"]',"add group":'[data-u2-part="add-group"]',rows:'[data-u2-part="rows"]',handle:'[data-u2-part="handle"]'},gestures:["add","remove","drag"]}),ao("composite","filter-row","filter row",{parts:{property:'[data-u2-part="prop"]',operator:'[data-u2-part="op"]',value:'[data-u2-part="value"]',remove:'[data-u2-part="remove"]',handle:'[data-u2-part="handle"]'},gestures:["type","pick","remove","drag"]}),aa("fb-search","search","functions-browser","collection"),aa("fb-list","list","functions-browser","collection"),aa("fb-status","status","functions-browser","collection"),aa("fb-clear","clear button","functions-browser","collection"),aa("fb-roles","roles","functions-browser","collection"),aa("fb-tags","tags","functions-browser","collection"),aa("fb-empty","empty message","functions-browser","collection"),aa("fb-panes","panes","functions-browser","collection"),aa("fb-role","role","functions-browser","collection"),aa("fb-tag","tag","functions-browser","collection"),aa("fch-list","list","func-call-history-browser","collection"),aa("fch-retry","retry button","func-call-history-browser","collection"),aa("fch-state","state","func-call-history-browser","collection"),aa("ff-run","run button","func-form","container"),aa("ff-history-icon","history icon","func-form","container");class am extends nC{get dgInput(){return this.options.dgInput}get disabled(){return super.disabled}set disabled(e){super.disabled=e;let t=this.options.dgInput;void 0!==t.enabled&&t.enabled!==(super.disabled===null)&&(t.enabled=super.disabled===null)}_followPlatform(){let e=this.options.dgInput.root.classList.contains("ui-input-disabled");e&&null===this.disabled?this.disabled=am.NOT_HERE:e||this.disabled!==am.NOT_HERE||(this.disabled=null)}get label(){return super.label||this.options.dgInput.caption}set label(e){super.label=e}createEditor(){return this._messages=(0,P.signal)(null),this.addValidator(()=>this._messages.value),this.options.dgInput.root}static _makeTabbable(e,t){if(t.tabIndex>=0||null!==t.querySelector("input, textarea, select, button, [tabindex]"))return;t.tabIndex=0;let n=e=>{let n=e.key;("Enter"===n||" "===n)&&(e.preventDefault(),t.click())};t.addEventListener("keydown",n),e.own(()=>t.removeEventListener("keydown",n))}static _same(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;if("dart"in e||"dart"in t)return e.dart===t.dart;let n=e.valueOf(),i=t.valueOf();if(n!==e||i!==t)return Object.is(n,i);if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>am._same(e,t[n]));let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(n=>am._same(e[n],t[n]))}static _join(e){return null!=e&&e.length>0?e.join("\n"):null}constructor(e,t,n){super(function(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},void 0===n?{}:n),{dgInput:e,name:null!=t?t:e.caption}),e.value),this.root.dataset.u2="dart-input";const i=new MutationObserver(()=>this._followPlatform());i.observe(e.root,{attributes:!0,attributeFilter:["class"]}),this.own(()=>i.disconnect()),this._followPlatform();const r=e.root.querySelector(".ui-input-editor");r&&(e.root.classList.remove("u2-input-editor"),r.classList.add("u2-input-editor"),am._makeTabbable(this,r));const o=e.onChanged.subscribe(e=>this.value=e);this.own(()=>o.unsubscribe()),this.effect(()=>{let t=this.value;am._same(t,e.value)||(e.value=t)});const s=globalThis,a=s.grok_InputBase_Get_ValidationMessages,l=s.grok_InputBase_OnValidated;if(null==e.dart||"function"!=typeof a||"function"!=typeof l)return;this._messages.value=am._join(a(e.dart));const u=l(e.dart).subscribe(e=>this._messages.value=am._join(e));this.own(()=>u.unsubscribe());const d=this.root.querySelector(".u2-input-error");this.effect(()=>d.hidden=null!==this._messages.value)}}function ag(e,t,n){let i=e.u2;return i instanceof nC?i:new am(e,t,n)}function av(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}am.NOT_HERE="Not available here";let ab={"text-input":g.TYPE.STRING,"text-area":g.TYPE.STRING,"choice-input":g.TYPE.STRING,"number-input":g.TYPE.FLOAT,"slider-input":g.TYPE.FLOAT,"qnum-input":g.TYPE.QNUM,"bigint-input":g.TYPE.BIG_INT,"bool-input":g.TYPE.BOOL,"color-input":g.TYPE.STRING,"radio-input":g.TYPE.STRING,"multi-choice-input":g.TYPE.OBJECT,"list-input":g.TYPE.OBJECT,"map-input":g.TYPE.OBJECT,"file-input":g.TYPE.FILE,"files-input":"files","rsa-input":g.TYPE.STRING,"column-picker":g.TYPE.STRING,"columns-input":g.TYPE.OBJECT,"columns-map-input":g.TYPE.OBJECT,"aggregated-columns-input":g.TYPE.OBJECT};class ay extends g.JsInputBase{get inputType(){return`u2-${this._id}`}setTooltip(e,t){return this._tip=e||null,super.setTooltip(e,void 0===t?null:t)}get dataType(){var e,t;return null!=(e=null!=(t=this._options.dataType)?t:ab[this._id])?e:this._inferDataType()}get u2(){return this._input}getInput(){if(this._syncValidator(),null===this._editor){let e=this._boundProperty();this._attach(this._scope.build(()=>this._build(e))),ay._dropPostfix(this._editor,e)}return this._mounted||(this._mounted=!0,g.Widget.registerCleanup(this._editor,()=>this.detach())),this._syncNullable(),this._editor}getValue(){return null!==this._input?this._input.peek():null===this._pending?null:this._pending[0]}setValue(e){if(null===this._input){this._pending=[e];return}this._programmatic=!0;try{this._input.value=e}finally{this._programmatic=!1}}getStringValue(){let e=this.getValue();return null==e?"":"object"==typeof e?JSON.stringify(e):String(e)}setStringValue(e){let t;try{t=this._parse(e)}catch(e){this._unparsed||console.warn(`u2 ${this._id}: ignored a string value that does not parse — ${e.message}`),this._unparsed=!0;return}this.setValue(t)}detach(){this._scope.dispose()}get _id(){var e,t;return null!=(e=null==(t=this._input)?void 0:t.root.dataset.u2)?e:"input"}_attach(e){this._input=e,this._editor=e.box,this.root.dataset.u2=this._id;let t=()=>{var t;return tA.apply(e.box,this.root.classList.contains("ui-input-disabled")?null!=(t=this._tip)?t:ay.NOT_HERE:null)},n=new MutationObserver(t);if(n.observe(this.root,{attributes:!0,attributeFilter:["class"]}),this._scope.own(()=>n.disconnect()),t(),null!==this._pending){var i;let e=(function(e){if(Array.isArray(e))return e}(i=this._pending)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),1!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(i)||function(e){if(e){if("string"==typeof e)return av(e,1);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return av(e,1)}}(i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];this._pending=null,this.setValue(e)}let r=!0;this._scope.effect(()=>{if(e.value,r){r=!1;return}this._notify(!this._programmatic&&!nC.isSystemWrite)});let o=!1;this._scope.effect(()=>{e.validity.value,o&&this._notify(!1),o=!0}),this._scope.listen(e.box,"keydown",e=>{"Enter"!==e.key||e.isComposing||e.target instanceof HTMLTextAreaElement||null===e.target.closest(".d4-dialog")||e.preventDefault()}),e.own(()=>this._scope.dispose())}_syncNullable(){null!==this._input&&(this.nullable=""!==this.getStringValue()||null===this._input.validity.peek())}_notify(e){this._userEdit=this._userEdit||e,this._queued||(this._queued=!0,queueMicrotask(()=>{this._queued=!1;let e=this._userEdit;this._userEdit=!1,this._scope.isDisposed||(this._syncNullable(),e&&this.fireInput(),this.fireChanged())}))}_syncValidator(){let e=this.dart;e!==this._validated&&(this._validated=e,this.addValidator(()=>{var e,t;return null!=(e=null==(t=this._input)?void 0:t.validity.peek())?e:null}))}_boundProperty(){try{var e;return null!=(e=this.property)?e:null}catch(e){return null}}static _dropPostfix(e,t){if(!t||!t.units)return;let n=e.querySelector(".u2-input-postfix");if(null===n)return;let i=n.parentElement;n.remove(),0===i.children.length&&i.remove()}_inferDataType(){if(null===this._input)return g.TYPE.OBJECT;let e=this._input.peek();return"string"==typeof e?g.TYPE.STRING:"number"==typeof e?g.TYPE.FLOAT:"boolean"==typeof e?g.TYPE.BOOL:g.TYPE.OBJECT}_parse(e){var t;let n=this.dataType;if(n===g.TYPE.STRING)return e;let i=e.trim();if(n===g.TYPE.BOOL)return"true"===i.toLowerCase();if(""===i)return null;if(n===g.TYPE.BIG_INT)return null!=(t=rB.parse(i))?t:null;if(n===g.TYPE.FLOAT||n===g.TYPE.INT||n===g.TYPE.QNUM){let e=Number(i);return isNaN(e)?null:e}return n===g.TYPE.OBJECT?JSON.parse(i):e}constructor(e,t){if(super(),this._scope=new P.Scope(void 0,{label:"dart-input",lazy:!0}),this._input=null,this._editor=null,this._mounted=!1,this._pending=null,this._programmatic=!1,this._validated=null,this._queued=!1,this._userEdit=!1,this._unparsed=!1,this._tip=null,this._options=void 0===t?{}:t,this._build="function"==typeof e?e:null,this._syncValidator(),null===this._build){var n,i;this.caption=null!=(n=null==(i=e.root.querySelector(".u2-input-label"))?void 0:i.textContent)?n:"",this._attach(e)}}}ay.NOT_HERE="Not available here",g.COLUMN_TYPE.STRING,g.COLUMN_TYPE.INT,g.COLUMN_TYPE.FLOAT,g.COLUMN_TYPE.BIG_INT,g.COLUMN_TYPE.QNUM,g.COLUMN_TYPE.BOOL,g.COLUMN_TYPE.DATE_TIME,g.COLUMN_TYPE.DATA_FRAME;class a_{static tableNames(){return[...new Set(f.shell.tableNames.filter(e=>a_._named(e)))]}static sameTable(e,t){return e===t||null!=e&&null!=t&&(null!=e.dart&&null!=t.dart?e.dart===t.dart:e.name===t.name)}static isOpen(e){var t;return(null!=(t=f.shell.tables)?t:[]).some(t=>a_.sameTable(t,e))}static listedColumns(e,t){return e.columns.toList().filter(e=>a_._named(e.name)&&!e.name.startsWith("~")&&(void 0===t||t(e)))}static _named(e){return"string"==typeof e&&""!==e}}class aw{static register(e){return aw._rules.push(e),()=>{let t=aw._rules.indexOf(e);t>=0&&aw._rules.splice(t,1)}}static resolve(e,t){var n=!0,i=!1,r=void 0;try{for(var o,s,a,l=aw._rules[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){let n=a.value;if(n.match(e))return n.create(e,t)}}catch(e){i=!0,r=e}finally{try{n||null==l.return||l.return()}finally{if(i)throw r}}return null!=(o=null==(s=aw.byHint)?void 0:s.call(aw,e,t))?o:null}}function ax(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function ak(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function aS(e,t){if(null==e)return{};var n,i,r,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=0,n=Reflect.ownKeys(Object(e));r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i]);return o}if(o=function(e,t){if(null==e)return{};var n,i,r={},o=Object.getOwnPropertyNames(e);for(i=0;i<o.length;i++)n=o[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);return r}(e,t),Object.getOwnPropertySymbols)for(r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i]);return o}aw._rules=[],aw.byHint=null;class aC{static register(e,t){return aC._factories[e]=t,()=>{aC._factories[e]===t&&delete aC._factories[e]}}static create(e,t,n){let i=aC._factories[e];return i?i(t,n):null}}aC._factories={};let aA={Text:(e,t)=>new nF(t),Search:(e,t)=>new nF(ak(ax({},t),{search:!0})),TextArea:(e,t)=>new nz(t),Int:(e,t)=>new n6(ax({},t,aj(e,"int",t))),Float:(e,t)=>new n6(ax({},t,aj(e,"float",t))),BigInt:(e,t)=>new rB(t),QNum:(e,t)=>new rz(ak(ax({},t),{format:aL(e)})),Slider:(e,t)=>aP(e,t),Bool:(e,t)=>new nq(t),Switch:(e,t)=>new nq(ak(ax({},t),{switch:!0})),Date:(e,t)=>new iG(t),Color:(e,t)=>new r_(t),Font:(e,t)=>new rK(t),Image:(e,t)=>new rX(t),Icon:(e,t)=>new rS(t),Radio:(e,t)=>{var n;return new rb(ak(ax({},t),{items:null!=(n=e.choices)?n:[]}))},Choice:(e,t)=>{var n;return new n2(ak(ax({},t),{items:null!=(n=e.choices)?n:[]}))},MultiChoice:(e,t)=>{var n;return new n3(ak(ax({},t),{items:null!=(n=e.choices)?n:[]}))},Tags:(e,t)=>{var n;return new rQ(ak(ax({},t),{items:null!=(n=e.choices)?n:void 0,allowNew:!0}))},List:(e,t)=>new i4(t),Map:(e,t)=>new rO(t),File:(e,t)=>aN(e,t)},aO={textarea:(e,t)=>new nz(t),password:(e,t)=>new nF(ak(ax({},t),{password:!0})),switch:(e,t)=>new nq(ak(ax({},t),{switch:!0})),slider:(e,t)=>aP(e,t)},aE={textarea:e=>"string"===e,password:e=>"string"===e,switch:e=>"bool"===e,slider:e=>"bool"!==e};function aT(e,t){var n;if(!e.set&&!(void 0!==t&&t))return"readonly";let i=null!=(n=e.propertyType)?n:e.type;if("list"===i||"string_list"===i)return"list";if("map"===i)return"map";if("file"===i||"blob"===i)return"file";if(null!=e.choices&&e.choices.length>0)return"choice";switch(i){case"string":return"string";case"datetime":return"datetime";case"int":return"int";case"bigint":return"bigint";case"qnum":return"qnum";case"double":case"float":case"num":return"float";case"bool":return"bool";default:return"readonly"}}function aP(e,t){var n,i;return new rv(ak(ax({},t),{min:null!=(n=aM(e.min))?n:0,max:null!=(i=aM(e.max))?i:100,step:aM(e.step)}))}function aN(e,t){var n;return null!=(n=aC.create("file",e,t))?n:aI(t)}function aI(e){let t=new nF(e);return t.disabled="A file is picked with the platform's file input, which is not here",t}function aM(e){return"number"==typeof e&&isFinite(e)?e:void 0}function aL(e){var t;let n=e.format,i=null==(t=globalThis.DG)?void 0:t.format;if(null!=n&&""!==n&&"function"==typeof i)return e=>i(e,n)}function aR(e){var t;let n=e.format;return(null!=(t=e.propertyType)?t:e.type)==="datetime"&&null!=n&&""!==n&&!/[Hhms]/.test(n)}function aj(e,t,n){var i,r,o;let s=aM(e.min),a=aM(e.max);return{mode:"int"===t?"int":"float",min:s,max:a,step:aM(e.step),slider:!0===e.showSlider||"float"===t,clicker:null!=(i=e.showPlusMinus)?i:"int"===t&&void 0!==s&&void 0!==a,format:aL(e),postfix:null!=(r=null!=(o=n.postfix)?o:e.units)?r:void 0}}aw.byHint=function(e,t){var n,i,r;let o=e.inputType?aA[e.inputType]:void 0;if(o)return o(e,t);let s=null==(r=e.editor)?void 0:r.toLowerCase(),a=s?aO[s]:void 0;return a&&aE[s](null!=(n=e.propertyType)?n:e.type)?a(e,t):s||"description"!==e.name||(null!=(i=e.propertyType)?i:e.type)!=="string"?null:new nz(t)};class aD extends iY{get properties(){return this._fields.map(e=>e.prop)}input(e){var t,n;return null!=(t=null==(n=this._fields.find(t=>t.prop.name===e))?void 0:n.input)?t:void 0}refresh(){this._reread(!1)}reset(){this._reread(!0)}_reread(e){this._refreshing=!0;try{(0,P.batch)(()=>{var t=!0,n=!1,i=void 0;try{for(var r,o=this._fields[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;if(null===t.input){this._showText(t);continue}let n=this._read(t.prop,t.kind);!e&&null!==t.kind&&null!==t.input.validity.peek()&&aD.same(n,t.synced)||(e?t.input.reset(n):t.input.value=n,t.synced=n)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}this._synced.value=this._synced.peek()+1})}finally{this._refreshing=!1}}getWidgetStatus(){return ak(ax({},super.getWidgetStatus()),{inputs:this._fields.map(e=>{var t,n,i,r,o,s,a;let l=e.input,u=null!=(t=null==l?void 0:l.validity.peek())?t:void 0;return{name:e.prop.name,caption:null!=(n=null==l?void 0:l.label)?n:aD._caption(e.prop),type:null!=(i=null!=(r=e.prop.propertyType)?r:e.prop.type)?i:"string",semType:null!=(o=e.prop.semType)?o:void 0,value:null!==l?l.peek():this._read(e.prop,"readonly"),choices:null!=(s=e.prop.choices)?s:void 0,required:!1===e.prop.nullable,valid:null==u,error:null!=u?u:void 0,description:null!=(a=e.prop.description)?a:void 0,access:e.access}})})}_addField(e,t){var n,i,r,o,s;let a=this._access.field(e.name);if("readonly"===a){let n=aD.readonlyField(null!=(o=nS(t.label))?o:aD._caption(e),e.name,""),i=n.row,r=n.value,l=null!=(s=nS(t.tooltipText))?s:e.description;l&&(i.title=l),this.addElement(i);let u={prop:e,kind:"readonly",input:null,access:a,text:r,emptyText:t.emptyText};this._showText(u),this._fields.push(u);return}let l=aT(e),u=t.input,d=aS(t,["input"]),c=ax({name:e.name,label:aD._caption(e),tooltipText:null!=(n=e.description)?n:void 0,nullable:e.nullable},d),h=u?null:this.build(()=>aw.resolve(e,c)),p=(null!=u?u:h)!=null?null:aD.platformInput(this,e,this.target,this._auto),f=null!=(i=null!=(r=null!=u?u:h)?r:p)?i:this.build(()=>(function(e,t){var n,i;let r=void 0===t?{}:t,o=r.assumeWritable,s=aS(r,["assumeWritable"]);if(null==e)return new nF(s);let a=aT(e,o),l=ax({nullable:e.nullable,tooltipText:null!=(n=e.description)?n:void 0},s);if("readonly"===a)return aI(l);let u=aw.resolve(e,l);if(null!=u)return u;switch(a){case"bool":return new nq(l);case"choice":return new n2(ak(ax({},l),{items:null!=(i=e.choices)?i:[]}));case"int":case"float":return new n6(ax({},l,aj(e,a,l)));case"bigint":return new rB(l);case"qnum":return new rz(ak(ax({},l),{format:aL(e)}));case"datetime":return aR(e)?new iB(ak(ax({},l),{utcDates:!0})):new iG(l);case"list":return null!=e.choices&&e.choices.length>0?new n3(ak(ax({},l),{items:e.choices})):new i4(l);case"map":return new rO(l);case"file":return aN(e,l);default:return new nF(l)}})(e,c)),m=f===p,g={prop:e,kind:m?null:l,input:f,access:a};if(m||(f.value=g.synced=this._read(e,l),!1===e.nullable&&f.addValidator(e=>es(e)?eo:null)),this.add(f),this._fields.push(g),m){let t=!0;this.effect(()=>{var n;let i=f.value;t?t=!1:this._refreshing||null==(n=this._onChanged)||n.call(this,e.name,i)});return}let v=e.set;"readonly"!==l&&v&&this.effect(()=>{var t;let n=f.value;null!==f.validity.value||aD.same(n,this._read(e,l))||(v(this.target,n),g.synced=this._read(e,l),this._synced.value=this._synced.peek()+1,null==(t=this._onChanged)||t.call(this,e.name,n))})}_showText(e){var t;let n=aD._display(e.prop,this._read(e.prop,null));e.text.textContent=n||(null!=(t=e.emptyText)?t:""),e.text.classList.toggle("u2-form-readonly-empty",""===n&&void 0!==e.emptyText)}static _display(e,t){if(null==t||""===t)return"";let n=aL(e);if("number"==typeof t&&void 0!==n)return n(t);if(aR(e)){let n=aD.coerce("datetime",t);if(null!==n){let t=Z.utcParts(n),i=t.year,r=t.month,o=t.day;return ei.date(new Date(Date.UTC(i,r-1,o)),{format:e.format,utcDates:!0})}}return er(t)}static readonlyField(e,t,n){let i=t$("","u2-form-readonly-value");i.dataset.u2Part="readonly-value",i.append(n);let r=tR([t$(e,"u2-input-label"),i],"u2-form-readonly");return r.dataset.u2="readonly-field",r.dataset.u2Name=t,{row:r,value:i}}static platformInput(e,t,n,i){let r=globalThis.DG;if(!i||null==r||null==t.dart)return null;try{let i=r.InputBase.forProperty(t,n);return null==i?null:e.build(()=>ag(i,t.name))}catch(e){return null}}_read(e,t){let n=e.get?e.get(this.target):void 0;return null===t?n:aD.coerce(t,n)}static _select(e,t,n){let i=e;if(t.include){let n=new Map(e.map(e=>[e.name,e]));i=t.include.map(e=>n.get(e)).filter(e=>void 0!==e)}let r=t.exclude;return r&&(i=i.filter(e=>!r.includes(e.name))),i.filter(e=>"hidden"!==n.field(e.name))}static _caption(e){var t,n,i;return null!=(t=null!=(n=null!=(i=e.caption)?i:e.friendlyName)?n:e.name)?t:""}static coerce(e,t){switch(e){case"bool":return!0===t;case"int":case"float":case"qnum":{if("number"==typeof t)return t;let e=null==t||""===t?NaN:Number(t);return isFinite(e)?e:null}case"bigint":var n;return"bigint"==typeof t?t:null==t?null:null!=(n=rB.parse(String(t)))?n:null;case"choice":return null==t?null:String(t);case"datetime":{if(null==t||""===t)return null;if(t instanceof Date)return t;let e="function"==typeof t.toDate?t.toDate():new Date(t);return isNaN(e.getTime())?null:e}case"list":return Array.isArray(t)?t:null==t||""===t?[]:i4.parse(String(t));case"map":return"object"!=typeof t||null===t||Array.isArray(t)?{}:t;case"file":return null!=t?t:null;default:return er(t)}}static same(e,t){if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]));if(aD._isRecord(e)&&aD._isRecord(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.is(e[n],t[n]))}return Object.is(e,t)}static _isRecord(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&!(e instanceof Date)}static isEmpty(e){return es(e)}constructor(e,t,n){let i=void 0===n?{}:n;super({layout:null!=(a=i.layout)?a:i.condensed?"tall":void 0,labelColumn:i.labelColumn}),this._fields=[],this._refreshing=!1,this._synced=(0,P.signal)(0),this.target=t,this.unwrittenValues=(0,P.computed)(()=>{this._synced.value;let e={};var t=!0,n=!1,i=void 0;try{for(var r,o=this._fields[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;null!==t.input&&null!==t.kind&&(t.input.unreadable||!aD.same(t.input.value,t.synced))&&(e[t.prop.name]=t.input.value)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return e}),this.unwritten=(0,P.computed)(()=>Object.keys(this.unwrittenValues.value).length),this._onChanged=i.onChanged,this._auto="auto"===i.editors,this._access=null!=(l=i.access)?l:nn.full,this.root.dataset.u2="object-form";var r=!0,o=!1,s=void 0;try{for(var a,l,u,d,c,h=aD._select(e,i,this._access)[Symbol.iterator]();!(r=(c=h.next()).done);r=!0){const e=c.value;this._addField(e,null!=(u=null==(d=i.overrides)?void 0:d[e.name])?u:{})}}catch(e){o=!0,s=e}finally{try{r||null==h.return||h.return()}finally{if(o)throw s}}}}function a$(e,t){let n=document.createElement("div");return n.className=e,void 0!==t&&(n.textContent=t),n}class aF{handlerFor(e){return void 0===this._handler&&(this._handler=g.ObjectHandler.forEntity(e)),this._handler}caption(e){try{let t=this.handlerFor(e);return t?t.getCaption(e):String(e)}catch(t){return String(e)}}icon(e){return this._render(e,t=>t.renderIcon(e))}listItem(e){return this._render(e,t=>t.renderListItem(e))}markup(e){return this._render(e,t=>t.renderMarkup(e))}tooltip(e){return this._render(e,t=>t.renderTooltip(e))}card(e){return this._render(e,t=>t.renderCard(e))}_render(e,t){try{let n=this.handlerFor(e);if(n)return t(n)}catch(e){}let n=document.createElement("span");return n.textContent=this.caption(e),n}}function az(){return new aF}let aq=new Set(["int","float","double","num","qnum","bigint","bool","string","datetime","dynamic"]);function aB(e){let t=e.outputs;return 1===t.length&&aq.has(t[0].propertyType)}function aG(e){var t,n;let i,r,o=e.nqName,s=e.friendlyName||e.name,a=null!=(t=e.description)?t:"",l=(null!=(n=e.tags)?n:[]).map(e=>e.toLowerCase()),u=e.options.role,d=u?[...l,...u.split(",").map(e=>e.trim().toLowerCase()).filter(e=>""!==e)]:l;return{name:o,label:s,tags:l,roles:d,description:a,signature:(i=e.inputs.map(e=>e.name).join(", "),r=e.outputs.map(e=>e.propertyType).join(", "),`(${i}) : ${""===r?"void":r}`),search:`${o} ${s} ${a}`.toLowerCase(),data:e}}function aV(e){try{var t;let n=g.ObjectHandler.forEntity(e),i=n?n.renderIcon(e):null;return null!==i&&""===(null!=(t=i.textContent)?t:"").trim()?i:null}catch(e){return null}}class aU extends H{refresh(){this._pager.reset()}call(e){return this._pager.items.peek().find(t=>t.id===e)}bindStep(e){if("functionName"===e)return this.functionName;if("selected"===e)return null!=this._selectedId||(this._selectedId=(0,P.computed)(()=>{var e,t;return null!=(e=null==(t=this.selected.value)?void 0:t.id)?e:null})),this._selectedId;return super.bindStep(e)}bindProps(){let e=super.bindProps();return e.some(e=>"functionName"===e.name)||e.push({name:"functionName",type:"string",writable:!0}),e.push({name:"selected",type:"string",writable:!1}),e}static popup(e,t,n,i){let r=new P.Scope,o=e=>{void 0!==e&&(r.dispose(),i(e))};return r.build(()=>{var i,s;let a=new aU((i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({setCurrentObject:!1},n),s=s={onActivate:o},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(s)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(s)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(s,e))}),i)),l=tR([a.root],t);l.addEventListener("click",e=>{var t,n;let i=null==(n=e.target)||null==(t=n.closest("[data-u2-funccall]"))?void 0:t.getAttribute("data-u2-funccall");i&&o(a.call(i))}),l.addEventListener(tb,()=>r.dispose()),tx.show(e,l,{owner:r})}),r}_fetchPage(e,t){var n;let i=this.functionName.peek();if(""===i)return Promise.resolve([]);let r=sq(null!=(n=i.split(":").pop())?n:i);return f.dapi.functions.calls.allPackageVersions().filter(`func.name="${r}"`).include("session.user,func.package,func.params,inputs,options").order("started",!0).list({pageSize:t,pageNumber:e})}_live(e,t){var n;if(!(e instanceof P.Signal))return(0,P.signal)(null!=e?e:t);let i=(0,P.signal)(null!=(n=e.peek())?n:t);return this.effect(()=>{let t=e.value;void 0!==t&&(i.value=t)}),i}_activate(e){var t,n;void 0!==e&&(null==(t=(n=this.options).onActivate)||t.call(n,e),this.fireEvent("activate",e))}_renderRow(e,t){t.setAttribute("data-u2-funccall",e.id),t.setAttribute("aria-label",this._renderer.caption(e));let n=this.options.render;return n?n(e,t):tR([this._renderer.listItem(e)],"u2-fch-row")}constructor(e){var t,n;let i=void 0===e?{}:e;super(),this._renderer=az(),this._selected=(0,P.signal)(null),this._lastItems=[],this._scrollPending=!1,this.options=i,this.root.classList.add("u2-fch"),this.root.dataset.u2="func-call-history-browser",this.functionName=this._live(i.functionName,"");const r=null!=(t=i.pageSize)?t:20;this._pager=new em({pageSize:r,fetchPage:e=>this._fetchPage(e,r)}),this.own(()=>this._pager.dispose());const o=null!=(n=i.itemHeight)?n:36;this._list=this.build(()=>new nb({itemHeight:o,keyOf:e=>e.id,render:(e,t,n)=>this._renderRow(e,n)})),this._list.root.setAttribute("data-u2","fch-list"),this._list.setItems(this._pager.items);const s=()=>{let e=this._list.root;e.scrollTop+e.clientHeight>e.scrollHeight-5*o&&this._pager.loadMore()};this._list.root.addEventListener("scroll",s),this.own(()=>this._list.root.removeEventListener("scroll",s));const a=t$("","u2-fch-empty-message"),l=this.build(()=>tB("Retry",()=>this._pager.loadMore()));l.dataset.u2="fch-retry";const u=tj([a,l],"u2-async-empty u2-fch-state");u.dataset.u2="fch-state",this.root.append(tj([this._list,u],"u2-fch-main")),this.effect(()=>{let e=this._pager.state.value,t=0===this._pager.items.value.length,n=this.functionName.value;l.hidden="error"!==e,a.textContent="error"===e?"Could not load the runs.":t&&"loading"===e?"Loading runs…":t&&""===n?"Pick a function to see its runs.":t&&"done"===e?"No saved runs.":"",u.hidden=!(t||"error"===e),this._list.root.hidden=t}),this.selected=this._selected,this.effect(()=>{var e,t,n,i;let r=this._pager.items.value,o=this._list.selectedIndex.value,s=null!=(e=r[o])?e:null,a=null!=(t=null==s?void 0:s.id)?t:null,l=null!=(n=null==(i=this._selected.peek())?void 0:i.id)?n:null,u=r!==this._lastItems;if(this._lastItems=r,u&&a!==l){if(null!==l&&r.some(e=>e.id===l)){this._scrollPending=!0;return}this._selected.value=null,this._scrollPending=!1;return}this._selected.value=s,(u||this._scrollPending)&&o>=0&&this._list.scrollToIndex(o),this._scrollPending=!1}),this.effect(()=>{this.functionName.value,this._pager.reset()});let d=!0;this.effect(()=>{var e,t;let n=this.selected.value;if(d){d=!1;return}null!==n&&!1!==this.options.setCurrentObject&&(f.shell.o=n),null==(e=(t=this.options).onChanged)||e.call(t,n),this.fireEvent("change",n)}),this.scope.listen(this._list.root,"dblclick",e=>{let t=e.target,n=null==t?void 0:t.closest(".u2-list-row");n&&this._activate(this._pager.items.peek()[Number(n.dataset.index)])}),this.scope.listen(this._list.root,"keydown",e=>{var t;"Enter"===e.key&&this._activate(null!=(t=this.selected.peek())?t:void 0)})}}function aH(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}aw.register({match:e=>"Molecule"===e.semType,create:(e,t)=>{var n,i;let r,o,s,a;return i=t.inline?"":null!=(n=nS(t.label))?n:e.name,o=(r={name:t.name,value:t.value,onChanged:t.onChanged,nullable:t.nullable,required:t.required}).name,s=r.value,a=function(e,t){if(null==e)return{};var n,i,r,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=0,n=Reflect.ownKeys(Object(e));r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i]);return o}if(o=function(e,t){if(null==e)return{};var n,i,r={},o=Object.getOwnPropertyNames(e);for(i=0;i<o.length;i++)n=o[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);return r}(e,t),Object.getOwnPropertySymbols)for(r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i]);return o}(r,["name","value"]),ag(m.input.molecule(i,{value:null!=s?s:""}),o,a)}});class aW extends nC{getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={open:void 0!==this._popup,placeholder:this._prompt},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}displayText(){var e;return""===this.peek()?"":null!=(e=this._name.textContent)?e:""}get _prompt(){var e;return null!=(e=this.options.placeholder)?e:"Pick a function…"}createEditor(){let e=t$("","u2-function-input-icon"),t=this._name=t$("","u2-function-input-name"),n=this._control=tR([e,t],"u2-function-input");n.tabIndex=0;for(let e=0,t=[["role","button"],["aria-haspopup","listbox"],["aria-expanded","false"]];e<t.length;e++){var i;let r=function(e){if(Array.isArray(e))return e}(i=t[e])||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(i)||function(e){if(e){if("string"==typeof e)return aH(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return aH(e,2)}}(i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=r[0],s=r[1];n.setAttribute(o,s)}return this.effect(()=>{let n=this.value,i=""===n?void 0:g.Func.find({}).find(e=>e.nqName===n),r=i?aV(i):null;e.replaceChildren(...r?[r]:[]),e.hidden=null===r,t.textContent=""===n?this._prompt:(null==i?void 0:i.friendlyName)||n,t.classList.toggle("u2-function-input-empty",""===n),t.title=n}),this.scope.listen(n,"click",()=>this._toggle()),this.scope.listen(n,"keydown",e=>{let t=e.key;if(("Backspace"===t||"Delete"===t)&&this.nullable)this.value="";else{if("Enter"!==t&&" "!==t)return;this._toggle()}e.preventDefault()}),this.own(()=>this._close()),n}_toggle(){if(null!==this.disabled)return;if(this._popup)return this._close();let e=this._popup=new P.Scope;e.build(()=>{var t,n,i,r;let o,s,a,l,u,d,c,h=e=>{this.value=e,this._close()},p=(o={showTags:!1,showRunButton:!1,showSignature:!0,setCurrentObject:!1,filter:this.options.filter,scalarOnly:this.options.scalarOnly,ignorePackages:this.options.ignorePackages,onActivate:e=>h(e.name)},s=g.Func.find({}),(a=o.filter)&&(s=s.filter(a)),(l=null!=(n=o.ignorePackages)?n:[]).length>0&&(s=s.filter(e=>!l.some(t=>e.nqName.startsWith(`${t}:`)))),o.scalarOnly&&(s=s.filter(aB)),u=s.map(aG),d=new Intl.Collator("en",{ignorePunctuation:!0,numeric:!0}),u.sort((e,t)=>d.compare(e.label,t.label)),c=o.onChanged,new ae((i=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},o),r=r={items:u,roles:g.functionRoles.map(e=>({role:e.role,description:e.description})),runAction:e=>e.data.prepare().edit(),icon:e=>aV(e.data),onChanged:e=>{null!==e&&!1!==o.setCurrentObject&&(f.shell.o=e.data),null==c||c(e)}},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(r,e))}),i))),m=tR([p.root],"u2-function-input-popup");e.listen(m,"click",e=>{var t,n;let i=null==(n=e.target)||null==(t=n.closest("[data-u2-func]"))?void 0:t.getAttribute("data-u2-func");i&&h(i)}),e.listen(m,tb,()=>this._close()),tx.show(this._control,m,{owner:e}),this._control.setAttribute("aria-expanded","true"),null==(t=p.root.querySelector("input"))||t.focus()})}_close(){var e;null==(e=this._popup)||e.dispose(),this._popup=void 0,this._control.setAttribute("aria-expanded","false")}constructor(e){super(void 0===e?{}:e,""),this.root.dataset.u2="function-input"}}function aY(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function aK(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function aX(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}aw.register({match:e=>"FunctionName"===e.semType,create:(e,t)=>new aW(t)});class aZ extends nC{getState(){return aX(aK({},super.getState()),{open:void 0!==this._popup})}createEditor(){this._picked=(0,P.signal)(void 0),this._resolveGen=0;let e=t$("","u2-func-call-input-name"),t=this._control=tR([e],"u2-func-call-input");t.tabIndex=0;for(let e=0,i=[["role","button"],["aria-haspopup","listbox"],["aria-expanded","false"]];e<i.length;e++){var n;let r=function(e){if(Array.isArray(e))return e}(n=i[e])||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(n)||function(e){if(e){if("string"==typeof e)return aY(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return aY(e,2)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),o=r[0],s=r[1];t.setAttribute(o,s)}return this.effect(()=>{var t,n,i,r;let o,s,a=this.value,l=this._picked.value;""!==a&&(null==l?void 0:l.id)!==a&&this._resolve(a),e.textContent=""===a?null!=(t=this.options.placeholder)?t:"Pick a run…":(null==l?void 0:l.id)===a?(o=(null==(n=l.func)?void 0:n.friendlyName)||(null==(i=l.func)?void 0:i.name)||"Function call",""===(s=(null==(r=l.started)?void 0:r.isValid())?l.started.format("MMM D, YYYY HH:mm"):"")?o:`${o} — ${s}`):a,e.classList.toggle("u2-func-call-input-empty",""===a),e.title=a}),t.addEventListener("click",()=>this._toggle()),t.addEventListener("keydown",e=>{if(("Backspace"===e.key||"Delete"===e.key)&&this.nullable)this.value="";else{if("Enter"!==e.key&&" "!==e.key)return;this._toggle()}e.preventDefault()}),this.own(()=>this._close()),t}_toggle(){if(null===this.disabled){if(this._popup)return this._close();(this._popup=aU.popup(this._control,"u2-func-call-input-popup",{functionName:this.functionName},e=>{this._picked.value=e,this.value=e.id})).own(()=>{this._popup=void 0,this._control.setAttribute("aria-expanded","false")}),this._control.setAttribute("aria-expanded","true")}}_close(){var e;null==(e=this._popup)||e.dispose()}_resolve(e){let t=++this._resolveGen;f.dapi.functions.calls.allPackageVersions().include("func.package,func.params,inputs").find(e).then(n=>{null!=n&&t===this._resolveGen&&this.peek()===e&&(this._picked.value=n)}).catch(()=>{})}_followName(e){var t;let n=(0,P.signal)(null!=(t=e.peek())?t:"");return this.effect(()=>{let t=e.value;void 0!==t&&(n.value=t)}),n}constructor(e){let t=void 0===e?{}:e;super(t,""),this.root.dataset.u2="func-call-input";const n=t.functionName;this.functionName=n instanceof P.Signal?this._followName(n):(0,P.signal)(null!=n?n:"")}}function aQ(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function aJ(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){aQ(o,i,r,s,a,"next",e)}function a(e){aQ(o,i,r,s,a,"throw",e)}s(void 0)})}}aw.register({match:e=>"FuncCall"===e.semType,create:(e,t)=>{var n,i;return new aZ(aX(aK({},t),{functionName:null!=(n=null==(i=e.options)?void 0:i.funcName)?n:""}))}});class a0 extends nC{static qualify(e,t){if(""===e)return null;let n=e.endsWith("/")?e.substring(0,e.lastIndexOf("/")):e;return void 0===t||n.startsWith(t)||(n=`${t}${n.startsWith("/")?n:`/${n}`}`),n}getState(){var e,t;return e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},super.getState()),t=t={busy:this._busy.peek()},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}createEditor(){var e;this._turn=0,this._queried=0,this._echo=!1,this._text=(0,P.signal)(""),this._busy=(0,P.signal)(!1),this.effect(()=>{this._busy.value?this.root.setAttribute("aria-busy","true"):this.root.removeAttribute("aria-busy")}),this._problem=(0,P.signal)(null),this._source=new eh(e=>this._resolve(e),{debounceMs:250}),this.own(()=>this._source.dispose()),this.own(()=>this._turn++);let t=document.createElement("input");this._field=t,t.type="text",t.autocomplete="off",t.className="u2-file-path",t.placeholder=null!=(e=this.options.placeholder)?e:"",this.effect(()=>this._show(this.value)),this.scope.listen(t,"input",()=>this._query(t.value));let n=document.createElement("div");n.className="u2-file",n.append(t);let i=this.options.connection;return void 0===i&&"folder"!==this.options.mode&&this._addPicker(n),"function"==typeof m.pickFileFromFiles&&this.addOptions(t6("folder-tree",()=>this._pickFromFiles().catch(e=>f.shell.error(String(e))),{tooltip:void 0===i?"Add file from Files":"Choose directory or file"}),{edits:!0}),this.own(a2(n,e=>this._drop(e))),this.effect(()=>this._onState(this._source.state.value)),this.addValidator(()=>this._check()),n}get _noun(){return"folder"===this.options.mode?"Folder":"File"}isEmptyValue(){return""===this._text.value}get emptyMessage(){return"Can't be empty."}_check(){let e=this._text.value;return""===e?null:this._busy.value?`${this._noun} ${e} is loading.`:this._problem.value}_onState(e){if("idle"===e.kind)return;if("loading"===e.kind){this._busy.value=!0;return}if(this._queried!==this._turn)return;if(this._busy.value=!1,"error"===e.kind){this._problem.value=e.message;return}if("empty"===e.kind){this._problem.value=`${this._noun} does not exist.`;return}this._problem.value=null;let t=e.items[0];null!==t&&this._publish(t)}_show(e){var t;let n=null===e?"":void 0!==this.options.connection?e.path?e.path:"/":null!=(t=e.fullPath)?t:e.fileName;this._field.value=n,this._text.value=n,this._echo||(this._turn++,this._busy.value=!1,this._problem.value=null)}_publish(e){this._echo=!0;try{this.value=e}finally{this._echo=!1}}_resolve(e){return aJ(function*(){var t;let n=a0.qualify(e,null==(t=this.options.connection)?void 0:t.nqName);if(null===n||!(yield f.dapi.files.exists(n)))return[];let i=yield this._find(n);return null===i?this._isConnectionRoot(n)?[null]:[]:this._fits(i)?[i]:[]}).call(this)}_fits(e){var t;let n=null!=(t=this.options.mode)?t:"file";return!("file"===n&&!e.isFile||"folder"===n&&!e.isDirectory)}_query(e){this._queried=++this._turn,this._field.value!==e&&(this._field.value=e),this._text.value=e,""===e?this.value=null:this._source.query(e)}_pickFromFiles(){return aJ(function*(){var e;let t=this.options.connection,n=null!=(e=this.options.mode)?e:"file",i=yield m.pickFileFromFiles({connection:t,mode:"any"===n?"all":n});null==i||this.scope.isDisposed||(this._fits(i)?this.value=i:this._query(void 0===t?i.fullPath:i.path||"/"))}).call(this)}_isConnectionRoot(e){var t;let n=null==(t=this.options.connection)?void 0:t.nqName;return void 0!==n&&e.length===n.length+1}_find(e){return aJ(function*(){var t,n;let i=e.lastIndexOf("/"),r=e.lastIndexOf("."),o=(null!=(t=this.options.mode)?t:"file")==="file"&&r>i?e.substring(r+1):null;return null!=(n=(yield f.dapi.files.list(i<0?"":e.substring(0,i+1),!1,o)).find(t=>t.fullPath===e))?n:null}).call(this)}_addPicker(e){let t=document.createElement("input");t.type="file",t.hidden=!0,this.scope.listen(t,"change",()=>{var e;let n=null==(e=t.files)?void 0:e[0];n&&this._accept(n)}),e.append(t),this.addOptions(t6("folder-open",()=>t.click(),{tooltip:"Open file"}),{edits:!0})}_drop(e){e.length>1?f.shell.error("Multiple files are not supported."):this._accept(e[0])}_accept(e){return aJ(function*(){let t=++this._turn;this._busy.value=!0,this._field.value=e.name,this._text.value=e.name;try{let n=new Uint8Array((yield e.arrayBuffer()));if(t!==this._turn)return;this._problem.value=null,this._publish(g.FileInfo.fromBytes(e.name,n))}catch(n){t===this._turn&&(this._problem.value=`${this._noun} ${e.name} could not be read.`)}finally{t===this._turn&&(this._busy.value=!1)}}).call(this)}constructor(e){super(void 0===e?{}:e,null),this.root.dataset.u2="file-input"}}function a2(e,t){let n=(t,n)=>{t.preventDefault(),t.stopPropagation(),e.classList.toggle("u2-file-dropping",n)},i={dragenter:e=>n(e,!0),dragover:e=>n(e,!0),dragleave:e=>n(e,!1),drop:e=>{var i;n(e,!1);let r=null==(i=e.dataTransfer)?void 0:i.files;r&&r.length>0&&t(r)}};for(let t in i)e.addEventListener(t,i[t]);return()=>{for(let t in i)e.removeEventListener(t,i[t])}}function a1(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function a3(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){a1(o,i,r,s,a,"next",e)}function a(e){a1(o,i,r,s,a,"throw",e)}s(void 0)})}}class a5 extends nC{static content(e){let t=new TextDecoder().decode(e).trim();return t.startsWith(a5.PEM)?t:a5.base64(e)}static base64(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode.apply(null,[...e.subarray(n,n+32768)]);return btoa(t)}createEditor(){let e=document.createElement("input");this._picker=e,e.type="file",e.accept=this._accept,e.hidden=!0,this.scope.listen(e,"change",()=>{var t;let n=null==(t=e.files)?void 0:t[0];n&&this.accept(n)});let t=document.createElement("div");t.className="u2-rsa-upload",t.append(e,t8("Upload","paperclip",()=>e.click()),t$(`or drop a ${this._accept} file`,"u2-rsa-hint"));let n=new nF({password:!0,value:a5.PLACEHOLDER,inline:!0});n.root.querySelector("input").readOnly=!0;let i=document.createElement("div");i.className="u2-rsa-masked",i.append(n.root,tB("Change",()=>this._change()));let r=document.createElement("div");return r.className="u2-rsa",r.append(t,i),this.own(a2(r,e=>this._drop(e))),this._makeDroppable(r),this.effect(()=>{var e;let n=(null!=(e=this.value)?e:"")!=="";t.hidden=n,i.hidden=!n}),r}get emptyMessage(){return"Can't be empty."}accept(e){return a3(function*(){if(!this._accepts(e.name))return void f.shell.error(`Expected a ${this._accept} file.`);let t=a5.content(new Uint8Array((yield e.arrayBuffer())));this.scope.isDisposed||(this.value=t)}).call(this)}_drop(e){e.length>1?f.shell.error("Multiple files are not supported."):this.accept(e[0])}get _accept(){var e;return null!=(e=this.options.accept)?e:".pem,.der"}_accepts(e){return this._accept.split(",").some(t=>e.toLowerCase().endsWith(t.trim().toLowerCase()))}_change(){this.value=null,this._picker.value="",this._picker.click()}_makeDroppable(e){m.makeDroppable(e,{acceptDrop:e=>this._isKeyFile(e),doDrop:e=>a3(function*(){let t=a5.dragged(e);if(!this._isKeyFile(t))return;let n=yield f.dapi.files.readAsText(t).catch(()=>null);this.scope.isDisposed||(null===n?f.shell.error("Could not read the key file."):n.startsWith(a5.PEM)?this.value=n:f.shell.error("Invalid key file"))}).call(this)})}static dragged(e){return null!==e&&"object"==typeof e&&"dragObject"in e?e.dragObject:e}_isKeyFile(e){return e instanceof g.FileInfo&&e.isFile&&a5._connected(e)&&this._accepts(e.fileName)}static _connected(e){try{return null!=e.connection}catch(e){return!0}}constructor(e){super(void 0===e?{}:e,null),this.root.dataset.u2="rsa-input"}}a5.PLACEHOLDER="_____________",a5.PEM="-----BEGIN";let a4=[g.AGG.TOTAL_COUNT,g.AGG.VALUE_COUNT,g.AGG.UNIQUE_COUNT,g.AGG.MISSING_VALUE_COUNT];function a6(e){let t=e.root;return t.setAttribute("data-kill-on-close","true"),g.Widget.registerCleanup(t,()=>e.dispose()),t}function a8(e,t){return null!=e&&null!=t&&e.dart===t.dart}function a9(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function a7(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}[g.AGG.FIRST,...a4,g.AGG.MIN,g.AGG.MAX,g.AGG.SUM,g.AGG.MED,g.AGG.AVG,g.AGG.STDEV,g.AGG.VARIANCE,g.AGG.SKEW,g.AGG.KURT,g.AGG.Q1,g.AGG.Q2,g.AGG.Q3],g.COLUMN_TYPE.INT,g.COLUMN_TYPE.FLOAT,g.COLUMN_TYPE.BIG_INT,g.COLUMN_TYPE.QNUM,g.COLUMN_TYPE.STRING,g.COLUMN_TYPE.BOOL,g.COLUMN_TYPE.DATE_TIME,[...a4];class le extends H{refit(){var e;this._attach();let t=this._ribbon,n=null!=(e=this._options.fold)?e:"auto",i=this._actions.some(e=>e.shown.peek());"auto"!==n||void 0===t||0===t.clientWidth?this._setFolded("always"===n&&i):(this._setFolded(!1),this._setFolded(i&&t.scrollWidth>t.clientWidth+1),void 0!==this._panel&&!1!==this._options.pin&&this._panel.classList.toggle("u2-ribbon-overflow",t.scrollWidth>t.clientWidth+1))}getItems(e){let t=this._folded.peek(),n=[...this._actions.filter(e=>e.shown.peek()).map(e=>({key:le._key(e.spec.name,e.spec.tooltip),label:e.spec.tooltip,rendered:!t})),...this._buttons.filter(e=>e.shown.peek()).map(e=>a9({key:le._key(e.spec.name,e.spec.text),label:e.spec.text,rendered:!0},e.el.disabled?{disabled:!0}:{}))].map((e,t)=>a7(a9({},e),{index:t}));return nC.itemsState(n,null==e?void 0:e.all)}getState(){return a7(a9({},super.getState()),{extra:{folded:this._folded.peek()}})}_build(){let e=this._options,t=t$("","u2-ribbon-rule");t.setAttribute("aria-hidden","true");var n=!0,i=!1,r=void 0;try{for(var o,s,a,l=(null!=(o=e.actions)?o:[])[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){let e=a.value,t=e.hint,n=t6(e.icon,()=>e.run(),{tooltip:void 0===t?e.tooltip:(0,P.computed)(()=>{var n;return null!=(n=t.value)?n:e.tooltip})});n.dataset.u2Item=le._key(e.name,e.tooltip),void 0!==e.name&&(n.dataset.u2Name=e.name);let i={spec:e,el:n,shown:(0,P.signal)(!0)};this._live(e.visible,e=>{n.hidden=!e,i.shown.value=e}),void 0!==t&&this.effect(()=>{let e=t.value;if(n.classList.toggle("u2-ribbon-hinted",null!==e),null===e||this._folded.peek()||!n.isConnected)return;let i=m.hints.addHintIndicator(n,!0,1e4);return()=>m.hints.remove(i)}),this._icons.append(n),this._actions.push(i)}}catch(e){i=!0,r=e}finally{try{n||null==l.return||l.return()}finally{if(i)throw r}}let u=()=>this._actions.find(e=>{var t;return e.shown.value&&(null==(t=e.spec.hint)?void 0:t.value)!=null});this._more=t6(i3.OVERFLOW_ICON,()=>{},{tooltip:(0,P.computed)(()=>{var e;let t=u();return void 0===t?i3.OVERFLOW_LABEL:`${i3.OVERFLOW_LABEL} — ${null!=(e=t.spec.hintDetail)?e:t.spec.hint.peek()}`}),menu:()=>{let e=t0.popup();var t=!0,n=!1,i=void 0;try{for(var r,o,s,a,l,u=this._actions.filter(e=>e.shown.peek())[Symbol.iterator]();!(t=(l=u.next()).done);t=!0){let t=l.value,n=null!=(r=null==(a=t.spec.hint)?void 0:a.peek())?r:null;e.item(null!=(o=t.spec.text)?o:t.spec.tooltip,()=>t.spec.run(),a9({icon:t.spec.icon},null===n?{}:{detail:null!=(s=t.spec.hintDetail)?s:n}))}}catch(e){n=!0,i=e}finally{try{t||null==u.return||u.return()}finally{if(n)throw i}}return e}}),this._more.classList.add("u2-ribbon-more"),this._more.dataset.u2Part="more",this._more.hidden=!0;let d=t$("","u2-ribbon-hint-dot");this._more.append(d),this.effect(()=>{d.hidden=void 0===u()}),this.root.append(t,this._icons,this._more);var c=!0,h=!1,p=void 0;try{for(var f,g,v=(null!=(s=e.buttons)?s:[])[Symbol.iterator]();!(c=(g=v.next()).done);c=!0){let e=g.value,t=tB(e.text,()=>e.run(),{primary:null==(f=e.primary)||f,disabled:e.disabled});t.dataset.u2Item=le._key(e.name,e.text),void 0!==e.name&&(t.dataset.u2Name=e.name),void 0!==e.cls&&t.classList.add(e.cls);let n={spec:e,el:t,shown:(0,P.signal)(!0)};this._live(e.visible,e=>{t.hidden=!e,n.shown.value=e}),this.root.append(t),this._buttons.push(n)}}catch(e){h=!0,p=e}finally{try{c||null==v.return||v.return()}finally{if(h)throw p}}let b=e.status;void 0!==b&&(this._status=tR([b],"u2-ribbon-status"))}_place(){var e;let t=this.view;this._found={showSaveButton:t.showSaveButton,parentView:t.parentView,showParentCrumb:t.showParentCrumb},!0===this._options.hideSave&&(t.showSaveButton=!1),t.setRibbonPanels([[this.root]],!1);let n=this._options.breadcrumbs;void 0!==n&&(t.parentView=n.parent,t.showParentCrumb=!0),void 0!==this._status&&(t.statusBarPanels=[...null!=(e=t.statusBarPanels)?e:[],this._status]),this._queueRefit()}_remove(){var e;let t=this.view;if(![...f.shell.views].some(e=>a8(e,t)))return;let n=this.root,i=t.getRibbonPanels();i.some(e=>e.some(e=>e===n||e.contains(n)))&&t.setRibbonPanels(i.filter(e=>!e.some(e=>e===n||e.contains(n))));let r=this._found;void 0!==r&&!0===this._options.hideSave&&(t.showSaveButton=r.showSaveButton),void 0!==r&&void 0!==this._options.breadcrumbs&&(t.parentView=r.parentView,t.showParentCrumb=r.showParentCrumb),void 0!==this._status&&(t.statusBarPanels=(null!=(e=t.statusBarPanels)?e:[]).filter(e=>e!==this._status))}_queueRefit(){this._queued||this.scope.isDisposed||(this._queued=!0,this.scope.requestFrame(()=>{this._queued=!1,this.refit()}))}_attach(){var e,t,n,i;let r=null!=(e=this.root.closest(".d4-ribbon"))?e:void 0,o=e=>{var t,n;return null!=(t=null==e||null==(n=e.parentElement)?void 0:n.closest(".d4-ribbon"))?t:void 0};for(let e=o(r);void 0!==e;e=o(e))r=e;if(r!==this._ribbon&&(this._ribbonResize.disconnect(),this._ribbonTree.disconnect(),null==(n=this._unlistenCrumb)||n.call(this),this._ribbon=r,void 0!==r)){this._ribbonResize.observe(r),this._ribbonTree.observe(r,{childList:!0,subtree:!0});let e=null==(i=this._options.breadcrumbs)?void 0:i.onClick;if(void 0!==e){let t=!1,n=this.scope.listen(r,"click",e=>{var n,i;t=(null==(i=e.target)||null==(n=i.closest)?void 0:n.call(i,le.PARENT_CRUMB))!=null},{capture:!0}),i=this.scope.listen(r,"click",()=>{t&&(t=!1,queueMicrotask(()=>{try{e()}catch(e){this.scope.reportError(e)}}))});this._unlistenCrumb=()=>{n(),i()}}}let s=null!=(t=this.root.closest(".d4-ribbon-panel"))?t:void 0;void 0!==s&&s!==this._panel&&!1!==this._options.pin&&(s.classList.add("u2-ribbon-pinned"),this._panel=s)}_setFolded(e){this._icons.hidden=e,this._more.hidden=!e,this._folded.peek()!==e&&(this._folded.value=e)}_live(e,t){e instanceof P.Signal?this.effect(()=>{t(e.value),this._queueRefit()}):void 0!==e&&t(e)}static _key(e,t){return null!=e?e:t}constructor(e,t){var n;let i=void 0===t?{}:t;super(document.createElement("div")),this._folded=(0,P.signal)(!1),this._icons=t$("","u2-ribbon-icons"),this._actions=[],this._buttons=[],this._queued=!1,this._ribbonResize=new ResizeObserver(()=>this._queueRefit()),this._ribbonTree=new MutationObserver(()=>{this._attach(),this._queueRefit()});const r=this.view=e.view;this._options=i,this.folded=this._folded;const o=this.root;o.className="u2-ribbon-group d4-ribbon-wrapper",o.dataset.u2="ribbon-group",o.setAttribute("role","toolbar"),o.setAttribute("aria-label",null!=(n=i.label)?n:"Actions"),void 0!==i.name&&(this.name=i.name),this.build(()=>this._build());const s=new ResizeObserver(()=>this._queueRefit());s.observe(o),this.own(()=>{s.disconnect(),this._ribbonResize.disconnect(),this._ribbonTree.disconnect()}),this.own(K.adopt(e,()=>this.dispose())),this.subscribe(f.events.onCurrentViewChanged,()=>{a8(f.shell.v,r)&&this._queueRefit()}),this.own(()=>this._remove()),this._place()}}le.PARENT_CRUMB=".d4-view-ribbon > .d4-ribbon-name:not(.grok-ns-entity-name)";class lt extends U{static of(e){var t;return null!=(t=lt._hosts.get(lt._key(e)))?t:new lt()._attach(e)}static create(e){let t,n=new lt;try{t=n.build(()=>e.content(n))}catch(e){throw n.dispose(),e}let i=lt._isContent(t)?t:{root:t},r=i.root,o=H.is(r)?r:n.build(()=>W(()=>r));n.own(()=>o.dispose()),o.own(()=>n.dispose()),void 0===o.name&&(o.name=e.name);let s=g.View.fromRoot(a6(o));return s.name=e.name,n._attach(s),n._chrome(s,i),n}get view(){var e;return null!=(e=this._view)?e:P.Usage.fail("view-not-ready","ViewHost.create() makes the view from its content once the content is built: use the host's view, ribbon, signals, show and dock after create() answers — in a handler or a `host.task`")}get signals(){var e;return null!=(e=this._signals)?e:this._signals=function(e,t){var n,i;let r="dataFrame"in e?e:null,o=(0,P.signal)(a8(f.shell.v,e)),s=(0,P.signal)(null!=(n=null==r?void 0:r.grid)?n:null),a=(0,P.signal)(null!=(i=null==r?void 0:r.dataFrame)?i:null);t.subscribe(f.events.onCurrentViewChanged,()=>o.value=a8(f.shell.v,e)),t.subscribe(f.events.onViewLayoutApplied,t=>{var n,i,o,l,u,d;null!==r&&a8(null==t?void 0:t.view,e)&&((null==(o=r.grid)?void 0:o.dart)!==(null==(l=s.peek())?void 0:l.dart)&&(s.value=null!=(n=r.grid)?n:null),(null==(u=r.dataFrame)?void 0:u.dart)!==(null==(d=a.peek())?void 0:d.dart)&&(a.value=null!=(i=r.dataFrame)?i:null))});let l=(0,P.computed)(()=>{var e;return null!=(e=a.value)?e:void 0}),u=(0,P.dfBindings)(l,t);return{isCurrent:o,grid:s,dataFrame:a,currentRowIdx:u.bindStep("currentRowIdx"),selection:u.bindStep("selection"),filter:u.bindStep("filter"),columns:u.bindStep("columns"),rowCount:u.bindStep("rowCount")}}(this.view,this.scope.child("view-signals"))}ribbon(e){return new le(this,void 0===e?{}:e)}show(e,t){var n,i;if(e.isOpen.peek())return e;let r=this.view,o=this.scope.child("view-pin"),s=(0,P.signal)(a8(f.shell.v,r));o.subscribe(f.events.onCurrentViewChanged,()=>s.value=a8(f.shell.v,r));let a=e.build(()=>e.on("close",()=>{a(),o.dispose()}));return e.show((n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},void 0===t?{}:t),i=i={visible:s,owner:o},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}),n)),e.isOpen.peek()||(a(),o.dispose()),e}dock(e,t,n){var i;let r=void 0===n?{}:n,o=this.view,s="dockManager"in o?o.dockManager:f.shell.dockManager,a=a6(e),l=e=>e===a||e.contains(a);e.own(K.adopt(this,()=>e.dispose())),e.subscribe(s.onClosed,t=>{l(t)&&e.dispose()}),e.subscribe(s.onPanelHidden,t=>{l(t)&&null==s.findNode(a)&&e.dispose()}),e.own(()=>{null!=s.findNode(a)&&s.close(a)}),s.dock(a,t,null,r.title,null!=(i=r.ratio)?i:.5)}get ambientAdoption(){return!1}_attach(e){let t=lt._key(e);return this._view=e,lt._hosts.set(t,this),this.own(()=>{lt._hosts.get(t)===this&<._hosts.delete(t)}),this.subscribe(f.events.onViewRemoved,t=>{a8(t,e)&&this.dispose()}),this}_chrome(e,t){let n=e=>H.is(e)?(this.own(()=>e.dispose()),e.root):e;if(t.ribbon){let l=t.ribbon.map(e=>e.map(n));e.setRibbonPanels(l);let u=()=>{var e=!0,t=!1,n=void 0;try{for(var i,r,o=l[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let e=r.value,t=null==(i=e[0])?void 0:i.closest(".d4-ribbon-panel");if(null==t)continue;t.style.display=e.every(e=>e.hidden)?"none":"";let n=t.previousElementSibling;n instanceof HTMLElement&&n.classList.contains("d4-ribbon-separator")&&(n.style.display=t.style.display)}}catch(e){t=!0,n=e}finally{try{e||null==o.return||o.return()}finally{if(t)throw n}}},d=new MutationObserver(u);var i=!0,r=!1,o=void 0;try{for(var s,a=l.flat()[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value;d.observe(e,{attributes:!0,attributeFilter:["hidden"]})}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}this.own(()=>d.disconnect()),u()}t.toolbox&&(e.toolbox=n(t.toolbox));let l=t.status;if(l instanceof P.Signal){let t=document.createElement("div");this.effect(()=>{t.textContent=l.value}),e.statusBarPanels=[t]}else null!=l&&(e.statusBarPanels=(Array.isArray(l)?l:[l]).map(e=>{let t=n(e);if(t instanceof HTMLDivElement)return t;let i=document.createElement("div");return i.append(t),i}));let u=t.path;"string"==typeof u?e.path=u:null!=u&&this.effect(()=>{e.path=u.value})}static _key(e){var t;return null!=(t=e.dart)?t:e}static _isContent(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&!(e instanceof HTMLElement)&&!H.is(e)&&"root"in e}constructor(){super()}}lt.isRoot=!0,lt._hosts=new WeakMap;let ln="u2-spec-error";class li{parent(){return this.instance.parentOf(this.node)}built(){return this.instance.nodes().get(this.node)}element(){let e=this.built();return void 0===e?void 0:ob.elementOf(e)}meta(){var e;let t=this.built();return null!=(e=U.is(t)?t.componentMeta:void 0)?e:this.instance.registry.get(this.node.tag)}error(){let e=this.built();return void 0===e||U.is(e)||!e.classList.contains(ln)?null:e.textContent}path(){let e=function(e){let t=new Map;var n=!0,i=!1,r=void 0;try{for(var o,s=e.nodes().keys()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=o.value;var a=!0,l=!1,u=void 0;try{for(var d,c=la(e,n)[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){let e=d.value;t.set(e,n)}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}(this.instance),t=[];for(let n=this.node;n;n=e.get(n))t.unshift(lo(n));return t.join(" › ")}constructor(e,t,n,i){this.instance=e,this.node=t,this.editor=n,this.actions=i}}class lr{constructor(e){this.refs=e}}function lo(e){var t;return null!=(t=e.name)?t:e.tag}function ls(e){var t,n;let i,r=new Map,o=(t,n)=>{r.set(t,n);let i=la(e,t).map((e,t)=>o(e,`${n}.${t}`));return{id:n,label:lo(t),data:t,children:i.length>0?i:void 0}};return{roots:[(i=(t=e).spec).root,...null!=(n=i.components)?n:[]].filter(e=>t.nodes().has(e)).map((e,t)=>o(e,String(t))),ids:r}}function la(e,t){var n;let i=e.nodes();return(null!=(n=t.children)?n:[]).filter(e=>i.has(e))}function ll(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}let lu="loading";function ld(e){if(!ou(e))return null;let t=lh(e,"state"),n=lh(e,"rowCount"),i=lh(e,"total"),r=lh(e,"error");return void 0===t&&void 0===n&&void 0===i?null:{state:null==t?"":String(t),count:"number"==typeof n?n:"number"==typeof i?i:null,counts:"number"==typeof n?"rows":"entities",error:null==r?null:String(r)}}function lc(e){if(null!==e.error)return e.error;if("idle"===e.state)return"not run yet — use Refresh";let t=null===e.count?"":`${e.count} ${e.counts}`;return""===e.state||""===t?""===e.state?t:e.state:`${e.state} \xb7 ${t}`}function lh(e,t){let n=e.bindStep(t);return null===n||ou(n)?void 0:n.value}function lp(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function lf(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function lm(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function lg(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let lv=["Delete","Move Up","Move Down","Duplicate"];var lb=function(e){if(Array.isArray(e))return e}(lv)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),4!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(lv)||function(e){if(e){if("string"==typeof e)return lp(e,4);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return lp(e,4)}}(lv)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();let ly=lb[0],l_=lb[1],lw=lb[2],lx=lb[3],lk={[ly]:"trash-alt",[l_]:"arrow-up",[lw]:"arrow-down",[lx]:"clone"};class lS{actions(){var e,t,n,i;let r=this._host.selected(),o=this._host.editor.peek(),s=this._host.instance();if(!r||!o||!s)return[];if(this._host.multi().length>1){let e=this.cover();return[{text:ly,icon:lk[ly],disabled:null!=(i=e.map(e=>o.canApply({op:"remove",node:e})).find(e=>null!==e))?i:null,run:()=>this._deleteMulti(e)},{text:l_,icon:lk[l_],disabled:lS.ONE_AT_A_TIME,run:()=>{}},{text:lw,icon:lk[lw],disabled:lS.ONE_AT_A_TIME,run:()=>{}},{text:lx,icon:lk[lx],disabled:lS.ONE_AT_A_TIME,run:()=>{}}]}let a=s.parentOf(r),l=null!=(e=null==a?void 0:a.children)?e:[],u=l.indexOf(r);return[{text:ly,icon:lk[ly],disabled:o.canApply(this._removalOf(r)),run:()=>this._delete(r)},{text:l_,icon:lk[l_],disabled:null===a?lS.NO_PARENT:u>0?null:"Already the first",run:()=>void this._host.apply({op:"move",node:r,parent:a,index:u-1})},{text:lw,icon:lk[lw],disabled:null===a?lS.NO_PARENT:u<l.length-1?null:"Already the last",run:()=>void this._host.apply({op:"move",node:r,parent:a,index:u+1})},{text:lx,icon:lk[lx],disabled:null===a?lS.NO_PARENT:null,run:()=>this._duplicate(r)},...this._refreshAction(r),...(null!=(t=null==(n=s.registry.get(r.tag))?void 0:n.designerActions)?t:[]).map(e=>{let t={text:e.text,icon:e.icon,run:()=>void this._designerAction(r,e)};return this._deferred.add(t),t})]}_refreshAction(e){return void 0===this._source(e)?[]:[{text:"Refresh",icon:"sync",run:()=>this.refresh(e)}]}refresh(e){var t,n,i;let r=this._source(e);r&&(n=null!=(t=e.name)?t:e.tag,(i=function*(){var e;let t,i=r.getFunctions().find(e=>"refresh"===e.name);if(void 0===i)return;yield i.apply({});let o=yield null===(t=ld(e=r))||t.state!==lu?Promise.resolve(t):new Promise(t=>{let n=new P.Scope;n.effect(()=>{let i=ld(e);(null===i||i.state!==lu)&&(t(i),n.dispose())})});null===o?f.shell.info(`${n}: refreshed`):null!==o.error?f.shell.error(`${n}: ${o.error}`):f.shell.info(`${n}: ${lc(o)}`)},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=i.apply(e,t);function s(e){ll(o,n,r,s,a,"next",e)}function a(e){ll(o,n,r,s,a,"throw",e)}s(void 0)})})())}_source(e){var t;let n=null==(t=this._host.instance())?void 0:t.nodes().get(e);return this._isComponent(e)&&U.is(n)&&n.getFunctions().some(e=>"refresh"===e.name)?n:void 0}_isComponent(e){var t,n;return(null==(n=this._host.instance())||null==(t=n.spec.components)?void 0:t.includes(e))===!0}_removalOf(e){return this._isComponent(e)?{op:"remove-component",node:e}:{op:"remove",node:e}}_designerAction(e,t){var n;return(n=function*(){let n=this._host.instance();if(n)try{var i;let r=yield t.produce(e,n.nodes().get(e)),o=this._host.editor.peek();if(null===r||!o)return;if("set-prop"===r.op)return void this._host.apply({op:"set-prop",node:e,name:r.name,value:r.value});let s=o.uniqueNames(),a=r.node.tag,l=sZ(n.registry.get(a),a,s(sX(a)),s),u=lg(lm({},l,r.node),{name:l.name}),d=lm({},l.props,r.node.props);Object.keys(d).length>0&&(u.props=d),this._host.pending(u),this._host.apply({op:"add",parent:e,index:(null!=(i=e.children)?i:[]).length,node:u})}catch(e){f.shell.warning(`${t.text}: ${e instanceof Error?e.message:String(e)}`)}finally{this._host.refocus()}},function(){var e=this,t=arguments;return new Promise(function(i,r){var o=n.apply(e,t);function s(e){lf(o,i,r,s,a,"next",e)}function a(e){lf(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}run(e){let t=this.actions().find(t=>t.text===e);t&&null===tA.now(t.disabled)&&(t.run(),this._deferred.has(t)||this._host.refocus())}handBack(e){return e.map(e=>this._deferred.has(e)?e:lg(lm({},e),{run:()=>{e.run(),this._host.refocus()}}))}_delete(e){let t=this._host.instance();this._host.pending(this._isComponent(e)?t.spec.root:t.parentOf(e)),this._host.apply(this._removalOf(e))}cover(){let e=this._host.multi();return e.filter(t=>!e.some(e=>e!==t&&ob.contains(e,t)))}_deleteMulti(e){let t=this._host.editor.peek(),n=this._host.instance();if(!t||!n)return;var i=!0,r=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(i=(s=a.next()).done);i=!0){let e=s.value,n=t.canApply({op:"remove",node:e});if(n)return void f.shell.warning(n)}}catch(e){r=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(r)throw o}}let l=this._host.selected(),u=e.find(e=>e===l||ob.contains(e,l));this._host.pending(n.parentOf(u)),t.applyAll(e.map(e=>({op:"remove",node:e})))}_duplicate(e){var t;let n=this._host.instance().parentOf(e),i=this._host.editor.peek().duplicate(e),r=(null!=(t=n.children)?t:[]).indexOf(e)+1;this._host.pending(i),this._host.apply({op:"add",parent:n,index:r,node:i})}rowActions(e){let t=this._host.multi();return e.data&&!(t.length>1&&t.includes(e.data))&&this._host.select(e.data),this.handBack(this.actions())}onContextMenu(e,t){e.preventDefault(),e.stopPropagation();let n=this._host.multi();t&&!(n.length>1&&n.includes(t))&&this._host.select(t);let i=this.actions();0!==i.length&&na(this.handBack(i)).show({x:e.clientX,y:e.clientY})}constructor(e){this._host=e,this._deferred=new WeakSet}}lS.ONE_AT_A_TIME="Select one component for this",lS.NO_PARENT="It has no parent to move or copy it within";let lC=/^(INPUT|TEXTAREA|SELECT)$/;function lA(e,t){let n=e.target;if(n&&(lC.test(n.tagName)||n.isContentEditable))return;let i=t.editor.peek();if(!i)return;let r=e.ctrlKey||e.metaKey,o=lO(e,i);if(void 0!==o||"Delete"!==e.key||r){if(void 0===o&&"Escape"===e.key&&!t.inDrag())if(t.multi().length>1)o=()=>t.collapse();else{var s;let e=t.selected(),n=e?null==(s=t.instance())?void 0:s.parentOf(e):null;n&&(o=()=>t.select(n))}}else o=()=>t.run(ly);o&&(e.preventDefault(),e.stopPropagation(),o())}function lO(e,t){let n=e.ctrlKey||e.metaKey,i=e.key.toLowerCase();return n&&"z"===i&&!e.shiftKey?()=>t.undo():n&&("y"===i||"z"===i&&e.shiftKey)?()=>t.redo():void 0}function lE(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function lT(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function lP(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return lE(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lE(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let lN=[r2,"Misc","Description","Events"],lI=new Set(["string","int","double","bool","string_list"]),lM="dataframe",lL="table",lR="Bind `table` to a data source (Bindings › table)";function lj(e,t){let n=void 0!==t&&t,i=e.node,r=e.meta(),o=r?r.props:o_(i.tag)?ow(i.tag):[],s=new Map;var a=!0,l=!1,u=void 0;try{for(var d,c,h,p=o[Symbol.iterator]();!(a=(h=p.next()).done);a=!0){let e=h.value;if(lz(e)===lM)continue;let t=null!=(c=e.category)?c:"Properties",n=s.get(t);n?n.push(e):s.set(t,[e])}}catch(e){l=!0,u=e}finally{try{a||null==p.return||p.return()}finally{if(l)throw u}}let f=e.parent(),m=f?null==(d=e.instance.registry.get(f.tag))?void 0:d.childProps:void 0;void 0!==m&&m.length>0&&s.set(`Parent (${f.tag})`,m);let g=[];var v=!0,b=!1,y=void 0;try{for(var _,w=[...s].sort((e,t)=>lD(e[0])-lD(t[0]))[Symbol.iterator]();!(v=(_=w.next()).done);v=!0){let t=lP(_.value,2),r=t[0],o=t[1],s=()=>{let t=function(e){let t=e.built(),n={};if(U.is(t)){var i=!0,r=!1,o=void 0;try{for(var s,a,l=t.getProperties()[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let e=a.value;n[e.name]=null==(s=e.get)?void 0:s.call(e,t.propertyTarget)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}}return n}(e),r={};var s=!0,a=!1,l=void 0;try{for(var u,d,c,h,p,f=o[Symbol.iterator]();!(s=(p=f.next()).done);s=!0){let e=p.value,o=e.name,s=n?null==(c=i.bind)?void 0:c[o]:void 0;if(void 0!==s){r[o]=s;continue}let a=null!=(d=t[o])?d:null==(h=i.props)?void 0:h[o];r[o]=lI.has(lz(e))?a:(u=a,void 0===u?"":JSON.stringify(u))}}catch(e){a=!0,l=e}finally{try{s||null==f.return||f.return()}finally{if(a)throw l}}return r};g.push({title:r,props:o.map(e=>(function(e,t){var n,i,r;let o=e.name,s=lz(e);return i=lT({},e),r=r={propertyType:void 0,type:"string_list"===s?"list":s,get:e=>e[o],set:(null==(n=t.bind)?void 0:n[o])===void 0&&lI.has(s)?(e,t)=>e[o]=t:void 0},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(r,e))}),i})(e,i)),values:s(),read:s})}}catch(e){b=!0,y=e}finally{try{v||null==w.return||w.return()}finally{if(b)throw y}}return g}let lD=e=>lN.indexOf(e)+1;function l$(e){let t=e.meta();return new Set(r1.filter(e=>void 0===t||t.props.includes(e)).map(e=>e.name))}function lF(e){var t,n,i;return(null==(t=e.error())?void 0:t.includes("needs a table"))===!0||(null==(n=e.node.bind)?void 0:n[lL])===void 0&&(null==(i=e.meta())?void 0:i.props.some(e=>e.name===lL&&lz(e)===lM))===!0}function lz(e){var t,n;return null!=(t=null!=(n=e.propertyType)?n:e.type)?t:"string"}function lq(e,t){return Object.keys(e).map(e=>({name:e,type:"string",description:t,get:t=>t[e],set:(t,n)=>t[e]=n}))}function lB(e){let t={};var n=!0,i=!1,r=void 0;try{for(var o,s=Object.keys(e)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0)t[o.value]={commitOn:"change"}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}function lG(e){var t,n,i;let r=null==(t=e.instance.registry.get(e.node.tag))?void 0:t.props.find(e=>e.subBindable),o=null==(n=e.node.props)?void 0:n.func;if(void 0===r||"string"!=typeof o||""===o)return null;let s=null==(i=X.funcRunner)?void 0:i.find(o);return s&&s.inputs.length>0?{prop:r.name,inputs:s.inputs}:null}function lV(e,t){var n;return lT({},null==(n=e.props)?void 0:n[t])}function lU(e){return lT({},e.node.bind)}function lH(e){var t,n,i,r,o;let s=null!=(t=null==(i=e.instance.registry.get(e.node.tag))?void 0:i.props)?t:o_(e.node.tag)?ow(e.node.tag):[],a=e.parent(),l=a&&null!=(n=null==(r=e.instance.registry.get(a.tag))?void 0:r.childProps)?n:[],u=[];for(let t=0,n=[...s,...l];t<n.length;t++){let i=n[t];!0===i.subBindable||(null==(o=e.node.bind)?void 0:o[i.name])!==void 0||u.includes(i.name)||u.push(i.name)}return u}function lW(e){let t=null!=(s=e.node.on)?s:{},n={};var i=!0,r=!1,o=void 0;try{for(var s,a,l,u,d=(null!=(a=null==(l=e.meta())?void 0:l.events)?a:[])[Symbol.iterator]();!(i=(u=d.next()).done);i=!0){let e=u.value;n[e]=lY(t[e])}}catch(e){r=!0,o=e}finally{try{i||null==d.return||d.return()}finally{if(r)throw o}}var c=!0,h=!1,p=void 0;try{for(var f,m=Object.keys(t)[Symbol.iterator]();!(c=(f=m.next()).done);c=!0){let e=f.value;n[e]=lY(t[e])}}catch(e){h=!0,p=e}finally{try{c||null==m.return||m.return()}finally{if(h)throw p}}return n}function lY(e){return void 0===e?"":"string"==typeof e?e:e.cmd}function lK(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function lX(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return lK(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return lK(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let lZ=new WeakSet;function lQ(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}let lJ=globalThis,l0=["input","select",".d4-column-selector"],l2={"u2-viewer-filters":new Set(["columnNames"])};function l1(){var e=!0,t=!1,n=void 0;try{for(var i,r=Array.from(document.body.querySelectorAll(".property-grid-item-editor-color-picker-host"))[Symbol.iterator]();!(e=(i=r.next()).done);e=!0)i.value.remove()}catch(e){t=!0,n=e}finally{try{e||null==r.return||r.return()}finally{if(t)throw n}}}function l3(e,t){let n=e.nodes().get(t);return void 0!==t.name&&U.is(n)&&ou(n)?n:void 0}function l5(e,t,n,i){let r=or([t]);return void 0===n?{label:e,path:r,name:t,prop:i}:{label:e,path:n.bindProps().some(e=>!0===e.default)?r:null,name:t,prop:i,children:()=>(function e(t,n){let i=t.bindProps().map(i=>{let r=[...n,i.name];return!0!==i.walkable?{label:l6(i),path:or(r),prop:i}:{label:l6(i),path:null,prop:i,children:()=>{let n=t.bindStep(i.name);return ou(n)?e(n,r):[]}}});return i.length>0?i:[{label:"nothing here yet — Refresh the source, or set designData to sample",path:null}]})(n,[t])}}function l4(e){let t=void 0===e.name?[]:[e];var n=!0,i=!1,r=void 0;try{for(var o,s,a=(null!=(o=e.children)?o:[])[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){let e=s.value;t.push(...l4(e))}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}return t}function l6(e){var t;let n=null!=(t=e.propertyType)?t:e.type,i=e.name;return null!=n&&""!==n&&(i+=` : ${n}`),null!=e.semType&&""!==e.semType&&(i+=` \xb7 ${e.semType}`),!0===e.writable?`${i} ⇄`:i}function l8(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function l9(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return l8(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l8(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let l7="App data",ue="Data sources",ut="Viewers",un="Form controls",ur="Pick a value — a group has nothing to bind to on its own";function uo(e,t,n){let i=void 0===n?{}:n,r=new iQ(void 0===i.prop?"Bind to":`${i.prop} — bind to`);r.root.classList.add("u2-bind-picker");let o=function(e,t){let n=new Set;var i=!0,r=!1,o=void 0;try{for(var s,a,l=(null!=(s=e.spec.components)?s:[])[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let e=a.value;void 0!==e.name&&n.add(e.name)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}let u=new Set;var d=!0,c=!1,h=void 0;try{for(var p,f,m=l4(e.spec.root)[Symbol.iterator]();!(d=(f=m.next()).done);d=!0){let t=f.value;(null==(p=e.registry.get(t.tag))?void 0:p.category)===ut&&u.add(t.name)}}catch(e){c=!0,h=e}finally{try{d||null==m.return||m.return()}finally{if(c)throw h}}let g=new Set(Object.keys(e.ctx.data)),v=new Map([[l7,[]],[ue,[]],[ut,[]],[un,[]]]);var b=!0,y=!1,_=void 0;try{for(var w,x,k=t[Symbol.iterator]();!(b=(x=k.next()).done);b=!0){let e=x.value,t=null!=(w=e.name)?w:"";v.get(n.has(t)?ue:g.has(t)?l7:u.has(t)?ut:un).push(e)}}catch(e){y=!0,_=e}finally{try{b||null==k.return||k.return()}finally{if(y)throw _}}return[...v].filter(e=>l9(e,2)[1].length>0).map(e=>{let t=l9(e,2);return{title:t[0],nodes:t[1]}})}(e,function(e){let t=[];var n=!0,i=!1,r=void 0;try{for(var o,s,a=e.ctx.bindProps()[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){let n=s.value,i=e.ctx.data[n.name];t.push(l5(l6(n),n.name,ou(i)?i:void 0,n))}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}var l=!0,u=!1,d=void 0;try{for(var c,h=(null!=(o=e.spec.components)?o:[])[Symbol.iterator]();!(l=(c=h.next()).done);l=!0){let n=c.value,i=l3(e,n);void 0!==i&&t.push(l5(`${n.name} (${n.tag})`,n.name,i))}}catch(e){u=!0,d=e}finally{try{l||null==h.return||h.return()}finally{if(u)throw d}}var p=!0,f=!1,m=void 0;try{for(var g,v=l4(e.spec.root)[Symbol.iterator]();!(p=(g=v.next()).done);p=!0){let n=g.value,i=l3(e,n);void 0!==i&&i.bindProps().length>0&&t.push(l5(`${n.name} (${n.tag})`,n.name,i))}}catch(e){f=!0,m=e}finally{try{p||null==v.return||v.return()}finally{if(f)throw m}}return t}(e)),s=r.build(()=>new nF({search:!0,inline:!0,placeholder:"Search bindings"})),a=r.build(()=>new nZ),l=t$("","u2-picker-empty");return a.expanded.value=new Set(o.map(e=>e.title)),r.effect(()=>{let e=s.value,t=[],n=[];var i=!0,r=!1,u=void 0;try{for(var d,c=o[Symbol.iterator]();!(i=(d=c.next()).done);i=!0){let i=d.value,r=function e(t,n,i,r){let o=void 0===i?"":i,s=void 0===r?3:r,a=n.trim().toLowerCase(),l=[],u=[];var d=!0,c=!1,h=void 0;try{for(var p,f=t[Symbol.iterator]();!(d=(p=f.next()).done);d=!0){let t=p.value,n=`${o}${t.label}`,i=t.children;if(""===a||t.label.toLowerCase().includes(a)){l.push({id:n,label:t.label,data:t,children:void 0===i?void 0:()=>Promise.resolve(e(i(),"",`${n}/`).rows)});continue}let r=s>0&&void 0!==i?e(i(),a,`${n}/`,s-1):void 0;void 0!==r&&0!==r.rows.length&&(u.push(n,...r.expand),l.push({id:n,label:t.label,data:t,children:r.rows}))}}catch(e){c=!0,h=e}finally{try{d||null==f.return||f.return()}finally{if(c)throw h}}return{rows:l,expand:u}}(i.nodes,e,`${i.title}/`);0!==r.rows.length&&(t.push({id:i.title,label:i.title,data:{label:i.title,path:null},children:r.rows}),n.push(...r.expand))}}catch(e){r=!0,u=e}finally{try{i||null==c.return||c.return()}finally{if(r)throw u}}a.setRoots(t),n.length>0&&(a.expanded.value=new Set([...a.expanded.peek(),...n]));let h=t.length>0;l.textContent=h?"":""===e.trim()?"Nothing to bind to yet — add a data source, or name a control.":`No bindings match "${e.trim()}".`,a.root.style.display=h?"":"none",l.style.display=h?"none":""}),r.add(tj([s.root,a.root,l,t$(`${ur}. App data comes from the app that opened the designer.`,"u2-bind-picker-hint")],"u2-bind-picker-body")),void 0!==i.current&&a.expandPath(function(e,t){let n=oi(t);if(null===n)return[];let i=e.find(e=>e.nodes.some(e=>e.name===n[0]));if(void 0===i)return[];let r=i.nodes.find(e=>e.name===n[0]),o=[i.title,`${i.title}/${r.label}`];var s=!0,a=!1,l=void 0;try{for(var u,d,c=n.slice(1)[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let e=d.value,t=null==(u=r.children)?void 0:u.call(r).find(t=>{var n;return(null==(n=t.prop)?void 0:n.name)===e});if(void 0===t)break;o.push(`${o[o.length-1]}/${t.label}`),r=t}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}return o}(o,i.current)),r.onCancel(()=>r.dispose()),r.onOK(()=>{var e;let n=null==(e=a.selectedNode.peek())?void 0:e.data;return(null==n?void 0:n.path)==null?(f.shell.warning(ur),!1):!1!==t(n.path)&&void r.dispose()}),r.show({modal:!0,width:460})}function us(e,t,n,i){let r=t6("ellipsis-h",n,{tooltip:void 0===i?"Pick a binding":i});r.dataset.u2BindPick=t,e.addOptions(r,{edits:!0})}class ua extends nC{get clearButton(){return this._clear}createEditor(){let e=document.createElement("div");e.className="u2-bind-chip";let t=t$("","u2-bind-chip-path");e.append(t),this.options.twoWay&&e.append(t$("⇄","u2-bind-chip-two-way")),this._clear=t6("times",this.options.onClear,{tooltip:"Remove binding"}),this._clear.classList.add("u2-bind-chip-clear"),e.append(this._clear);let n=e=>{this._clear.contains(e.target)||this.options.onPick()};return e.addEventListener("click",n),this.own(()=>e.removeEventListener("click",n)),this.effect(()=>{var e;return this.root.title=t.textContent=null!=(e=this.value)?e:""}),e}constructor(e){super(function(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},e),{value:e.path}),""),this.root.dataset.u2="bind-chip"}}function ul(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function uu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function ud(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ul(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ul(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}let uc=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function uh(e,t,n){let i=void 0===n?{}:n;return e.map(e=>{var t,n,r,o;let s=e.name,a=null!=(t=null!=(n=e.caption)?n:e.friendlyName)?t:s,l=i[s];if(void 0!==l)return{name:s,caption:a,type:"string",description:`Bound to ${l}`,get:()=>l};let u=null!=(r=null!=(o=e.propertyType)?o:e.type)?r:"string";return{name:s,caption:a,type:"string_list"===u?"list":u,description:e.description,choices:e.choices,nullable:e.nullable,get:e=>e[s],set:(e,t)=>e[s]=t}})}function up(e){let t={};var n=!0,i=!1,r=void 0;try{for(var o,s=Object.entries(e)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=ud(o.value,2),n=e[0],i=e[1];null!=i&&""!==i&&(t[n]=i)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}function uf(e){var t,n,i;let r,o=new iQ(null!=(t=e.title)?t:"Pick a function");o.root.classList.add("u2-func-picker");let s=function(e){let t=e.filter(e=>uc.test(e.name)),n=new Map;var i=!0,r=!1,o=void 0;try{for(var s,a,l=t[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let e=a.value;n.set(e.name,(null!=(s=n.get(e.name))?s:0)+1)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}let u=t.map(e=>{var t,i,r,o;let s=null==(o=e.package)?void 0:o.name,a=s&&(null!=(t=n.get(e.name))?t:0)>1?`${s}:${e.name}`:e.name,l=null!=(i=e.friendlyName)?i:e.name,u=null!=(r=e.description)?r:"";return{name:a,label:l,description:u,search:`${a} ${l} ${u}`.toLowerCase(),func:e}});return u.sort((e,t)=>e.label.localeCompare(t.label)),u}(g.Func.find({})),a=az(),l=o.build(()=>new nF({search:!0,inline:!0,placeholder:"Search functions"})),u=t$("","u2-picker-empty"),d=tR([],"u2-func-picker-params"),c=uu({},null==(n=e.pick)?void 0:n.args),h=uu({},null==(i=e.pick)?void 0:i.binds),p=s,f=new P.Scope;o.own(()=>f.dispose());let m=()=>{if(f.dispose(),f=new P.Scope,d.textContent="",void 0===r)return void d.append(t$("Pick a function to set its arguments.","u2-func-picker-hint"));let t=null!=(l=r.func.inputs)?l:[],n=new Set(t.map(e=>e.name));var i=!0,s=!1,a=void 0;try{for(var l,u,p=Object.keys(c)[Symbol.iterator]();!(i=(u=p.next()).done);i=!0){let e=u.value;n.has(e)||delete c[e]}}catch(e){s=!0,a=e}finally{try{i||null==p.return||p.return()}finally{if(s)throw a}}var g=!0,v=!1,b=void 0;try{for(var y,_=Object.keys(h)[Symbol.iterator]();!(g=(y=_.next()).done);g=!0){let e=y.value;n.has(e)||delete h[e]}}catch(e){v=!0,b=e}finally{try{g||null==_.return||_.return()}finally{if(v)throw b}}if(0===t.length)return void d.append(t$(`${r.label} takes no arguments.`,"u2-func-picker-hint"));let w=f.build(()=>new aD(uh(t,c,h),c,{condensed:!0}));var x=!0,k=!1,S=void 0;try{for(var C,A=t[Symbol.iterator]();!(x=(C=A.next()).done);x=!0){let t=C.value.name,n=w.input(t);void 0!==n&&(n.root.setAttribute("data-u2-prop",t),us(n,t,()=>o.build(()=>uo(e.instance,e=>{h[t]=e,m()}))))}}catch(e){k=!0,S=e}finally{try{x||null==A.return||A.return()}finally{if(k)throw S}}d.append(w.root)},v=o.build(()=>new nb({itemHeight:28,keyOf:e=>e.name,render:(e,t,n)=>{var i,r;let o,s;return n.dataset.u2Func=e.name,i=e,o=[],""===(null!=(r=(s=a.icon(i.func)).textContent)?r:"").trim()&&o.push(tR([s],"u2-func-row-icon")),o.push(t$(i.label,"u2-func-row-label")),i.name!==i.label&&o.push(t$(i.name,"u2-func-row-name")),""!==i.description&&o.push(t$(i.description,"u2-func-row-desc")),tR(o,"u2-func-row")}}));o.effect(()=>{let e,t=l.value;p=""===(e=t.trim().toLowerCase())?s:s.filter(t=>t.search.includes(e)),v.setItems(p);let n=p.length>0;u.textContent=n?"":""===t.trim()?"No functions are registered.":`No functions match "${t.trim()}".`,v.root.style.display=n?"":"none",u.style.display=n?"none":""}),o.effect(()=>{let e=p[v.selectedIndex.value];e!==r&&(r=e,m())});let b=void 0===e.pick?-1:p.findIndex(t=>t.name===e.pick.name);return b>=0&&(v.selectedIndex.value=b),o.add(tj([l.root,v.root,u,d],"u2-func-picker-body")),o.onCancel(()=>o.dispose()),o.onOK(()=>{void 0!==r&&e.onPick({name:r.name,args:uu({},c),binds:uu({},h)}),o.dispose()}),o.show({modal:!0,width:560})}function um(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function ug(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let uv={name:"",type:"string_list"},ub="add-binding",uy=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase());function u_(e,t,n,i){let r=t.patch(n,i);return null===r||ux(e,r)}function uw(e,t,n){return!!ux(e,t)&&(uS(n),!0)}function ux(e,t){let n=e.canApply(t);return null===n?(e.apply(t),"set-event"===t.op&&void 0===t.command?f.shell.info(`${t.event}: command removed`):"set-bind"===t.op&&void 0===t.path&&f.shell.info(`${t.name}: binding removed`),!0):(f.shell.warning(n),!1)}function uk(){null==o||o.dispose(),o=void 0,s=void 0}function uS(e){(null==s?void 0:s.node)===e.node&&s.refresh(e)}class uC extends g.ObjectHandler{get type(){return"u2-spec-node"}isApplicable(e){return e instanceof li}getCaption(e){let t=e.node.name?`${e.node.name} (${e.node.tag})`:e.node.tag;return null===e.error()?t:`${t} — broken`}renderMarkup(e){return t$(this.getCaption(e),"u2-designer-caption")}renderProperties(e){let t,n;uk();let i=e.editor,r=void 0===i?void 0:new P.Scope;o=r,null==r||r.own(()=>null==t?void 0:t.dispose());let a=e=>(null==t||t.dispose(),t=void 0===r?void 0:new P.Scope,[...uC._hint(e),...uC._status(e,t)]),l=this.renderMarkup(e),u=uC._identity(e),d=a(e),c=[l,tF("Node"),u,...d,...uC._verbs(e)],h=lW(e);void 0===i?c.push(...uC._tables(lj(e),h,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},e.node.bind),l$(e))):(n=r.build(()=>(function(e,t,n,i){let r,o,s,a,l,u,d,c,h=e.node,p=P.Scope.ambient,m=[],v=[],b=(e,n,i,r,o)=>{let s={values:n,read:i,patch:r};s.form=new aD(e,n,{condensed:!0,overrides:o,onChanged:(e,n)=>u_(t,s,e,n)});var a=!0,l=!1,u=void 0;try{for(var d,c,h=e[Symbol.iterator]();!(a=(c=h.next()).done);a=!0){let e=c.value;null==(d=s.form.input(e.name))||d.root.setAttribute("data-u2-prop",e.name)}}catch(e){l=!0,u=e}finally{try{a||null==h.return||h.return()}finally{if(l)throw u}}return m.push(s),s},y=(e,t,n)=>void 0===n?void v.push(tF(e),t):(void 0===r&&(r=new i2,v.push(r.root)),r.addPane(e,t,n)),_=(c=e.built(),U.is(c)&&c.propertyTier);_&&(s=function(e,t,n){let i,r,o;if(void 0===lJ.grok_PropertyGrid_Update||void 0===lJ.grok_Viewer_Get_Look)return{root:t$("The platform property grid is not available on this client","u2-designer-hint"),refresh:()=>{}};let s=new g.PropertyGrid;s.root.classList.add("u2-designer-look");let a=()=>{let t=e.built();if(t===i)return;null==r||r.dispose(),l1(),i=t;let a=s.root.querySelector(".property-grid-wrapper"),l=null!=(p=null==a?void 0:a.scrollTop)?p:0,u=s.root.contains(document.activeElement)?null==(f=document.activeElement.closest("tr[data-prop-name]"))?void 0:f.dataset.propName:document.activeElement===document.body?o:void 0;o=void 0,void 0===(r=t instanceof g.Viewer&&U.is(t)?function(e,t,n,i,r){var o,s,a,l;let u,d,c,h=new P.Scope,p=(u=l2[t.node.tag],d=new Set((null!=(o=null==(s=t.meta())?void 0:s.props)?o:[]).filter(e=>lz(e)!==lM&&(null==u?void 0:u.has(e.name))!==!0).map(e=>e.name)),n.getProperties().filter(e=>d.has(e.name)));c=lJ.grok_Viewer_Get_Look(n.dart),lJ.grok_PropertyGrid_Update(e.dart,c,p.map(e=>g.toDart(e)),null!=(a=null==(l=n.dataFrame)?void 0:l.dart)?a:null);let f=lJ.grok_Viewer_Get_Look(n.dart),m=new Map(p.map(e=>[e.name,e.get(f)])),v=new Map(n.getProperties().map(e=>[e.name,e])),b=new Map,y=n.onPropertyValueChanged.subscribe(e=>{var o,s,a;let l=null==e||null==(s=e.args)||null==(o=s.property)?void 0:o.name;if(void 0===l||lZ.has(n)||!t.instance.designTime)return;r(l);let u=0===b.size;b.set(l,null==(a=v.get(l))?void 0:a.get(lJ.grok_Viewer_Get_Look(n.dart))),u&&queueMicrotask(()=>i(function(e,t,n){let i=e.node,r=[],o=e.meta();var s=!0,a=!1,l=void 0;try{for(var u,d,c,h,p=t[Symbol.iterator]();!(s=(h=p.next()).done);s=!0){let e=(u=h.value,function(e){if(Array.isArray(e))return e}(u)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(u)||function(e){if(e){if("string"==typeof e)return lQ(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return lQ(e,2)}}(u)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),t=e[0],s=e[1],a=null==o?void 0:o.props.find(e=>e.name===t);if(!a||!lI.has(lz(a))||(null==(d=i.bind)?void 0:d[t])!==void 0||n.has(t)&&U.sameValue(s,n.get(t)))continue;let l=null===s?void 0:s,p=null==(c=i.props)?void 0:c[t];U.sameValue(p,l)||void 0===p&&""===l||r.push({op:"set-prop",node:i,name:t,value:l})}}catch(e){a=!0,l=e}finally{try{s||null==p.return||p.return()}finally{if(a)throw l}}return t.clear(),r}(t,b,m)))});return h.own(()=>y.unsubscribe()),h}(s,e,t,n,e=>o=e):void 0)&&s.update({},[]),a&&(a.scrollTop=l);var d=!0,c=!1,h=void 0;try{for(var p,f,m,v,b=Array.from(s.root.querySelectorAll("tr[data-prop-name]"))[Symbol.iterator]();!(d=(v=b.next()).done);d=!0){let t=v.value;t.classList.toggle("u2-designer-look-set",(null==(m=e.node.props)?void 0:m[t.dataset.propName])!==void 0)}}catch(e){c=!0,h=e}finally{try{d||null==b.return||b.return()}finally{if(c)throw h}}void 0!==u&&function(e){if(null===e)return;let t=e.querySelector(l0.join(", "));null===t&&(e.tabIndex=-1),(null!=t?t:e).focus()}(s.root.querySelector(`tr[data-prop-name="${u}"]`))},l=t=>{let n=void 0===e.editor?void 0:lO(t,e.editor);void 0!==n&&(t.preventDefault(),t.stopPropagation(),n())};return s.root.addEventListener("keydown",l),t.own(()=>{var e;s.root.removeEventListener("keydown",l),null==r||r.dispose(),l1(),s.update({},[]),null==(e=lJ.grok_Widget_Kill)||e.call(lJ,s.root)}),a(),{root:s.root,refresh:a}}(e,i,e=>{try{let a=[];var n=!0,i=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value,n=t.canApply(e);null===n?a.push(e):f.shell.warning(n)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}t.applyAll(a)}catch(e){f.shell.error(e instanceof Error?e.message:String(e))}}),e.instance.designTime?v.push(tF("Properties"),s.root):v.push(tF("Properties (live)"),t$("Edits here change the running view only and are not saved to the form — switch to Design to edit the form.","u2-designer-hint"),s.root));let w=(n,i)=>{let r=void 0===i?n:i;return()=>p.build(()=>{var i;return uo(e.instance,i=>uw(t,{op:"set-bind",node:h,name:n,path:i},e),{prop:r,current:null==(i=h.bind)?void 0:i[n]})})},x=n=>{let i;var r=!0,o=!1,s=void 0;try{for(var a,l,u,d,c=n[Symbol.iterator]();!(r=(d=c.next()).done);r=!0){let n=d.value,r=n.name,o=null==(u=h.bind)?void 0:u[r];if(void 0===o)continue;let s=new ua({path:o,label:null!=(a=null!=(l=n.caption)?l:n.friendlyName)?a:r,twoWay:!0===n.twoWay,onPick:w(r),onClear:()=>uw(t,{op:"set-bind",node:h,name:r,path:void 0},e)});s.clearButton.dataset.u2Unbind=r,(null!=i?i:i={})[r]={input:s}}}catch(e){o=!0,s=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw s}}return i},k=(e,t)=>{var n=!0,i=!1,r=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let t=o.value;if(!0===t.subBindable&&!0!==t.bindable)continue;let n=e.form.input(t.name);void 0!==n&&us(n,t.name,w(t.name))}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}},S=l$(e),C=[];i.own(()=>null==a?void 0:a.dispose());let A=new Map;if(!_){var O=!0,E=!1,T=void 0;try{for(var N,I=lj(e,!0)[Symbol.iterator]();!(O=(N=I.next()).done);O=!0){let e=N.value,t=tR([],"u2-designer-rows");if(A.set(e.title,t),e.title!==r2){y(e.title,t);continue}let n=e.props,i=()=>n.filter(e=>{var t,n;return S.has(e.name)&&((null==(t=h.props)?void 0:t[e.name])!==void 0||(null==(n=h.bind)?void 0:n[e.name])!==void 0)}).length,r=n.some(e=>!S.has(e.name)),s=y(e.title,t,i()>0||r);if(void 0!==s){let e=s.root.querySelector(".u2-accordion-title");(o=()=>{let t=i();e.textContent=t>0?`${r2} (${t})`:r2})()}}}catch(e){E=!0,T=e}finally{try{O||null==I.return||I.return()}finally{if(E)throw T}}}null!==lG(e)&&y("Parameters",l=tR([],"u2-designer-rows"));let M=()=>{var t=!0,n=!1,i=void 0;try{for(var r,o=C[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value;m.splice(m.indexOf(e),1)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}C=[],null==a||a.dispose(),(a=new P.Scope).build(()=>{if(!_){var t=!0,n=!1,i=void 0;try{for(var r,o=lj(e,!0)[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let e=r.value,t=(e,t)=>{var n,i;if((null==(n=h.bind)?void 0:n[e])!==void 0)return null;let r=null==(i=h.props)?void 0:i[e];return S.has(e)&&(""===t||null===t)?void 0===r?null:{op:"set-prop",node:h,name:e,value:void 0}:rt.same(uv,r,t)||""===t&&void 0===r?null:{op:"set-prop",node:h,name:e,value:t}},n=b(e.props,e.values,e.read,t,x(e.props));C.push(n),k(n,e.props),A.get(e.title).replaceChildren(n.form.root)}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}}let s=lG(e);if(null!==s){let e=lV(h,s.prop),t=b(uh(s.inputs,e,function(e,t){let n={};var i=!0,r=!1,o=void 0;try{for(var s,a,l=Object.entries(null!=(s=e.bind)?s:{})[Symbol.iterator]();!(i=(a=l.next()).done);i=!0){let e=lP(a.value,2),i=e[0],r=e[1];i.startsWith(`${t}.`)&&(n[i.slice(t.length+1)]=r)}}catch(e){r=!0,o=e}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}return n}(h,s.prop)),e,()=>lV(h,s.prop),(e,t)=>{let n=lV(h,s.prop);return rt.same(uv,n[e],t)||""===t&&void 0===n[e]?null:{op:"set-prop",node:h,name:s.prop,value:ug(um({},n),{[e]:t})}});C.push(t);var a=!0,u=!1,d=void 0;try{for(var c,p=s.inputs[Symbol.iterator]();!(a=(c=p.next()).done);a=!0){let e=c.value,n=t.form.input(e.name),i=`${s.prop}.${e.name}`;void 0!==n&&us(n,i,w(i,e.name))}}catch(e){u=!0,d=e}finally{try{a||null==p.return||p.return()}finally{if(u)throw d}}null==l||l.replaceChildren(t.form.root)}})};M();let L=()=>{let n=lU(e),i=Object.keys(n),r=lH(e),o=b(lq(n,"Bound context path").map(e=>{var t;let n;return ug(um({},e),{caption:(n=(t=e.name).indexOf("."))<0?uy(t):`${uy(t.slice(0,n))} › ${t.slice(n+1)}`})}),n,()=>{let t=lU(e),n={};var r=!0,o=!1,s=void 0;try{for(var a,l,u=i[Symbol.iterator]();!(r=(l=u.next()).done);r=!0){let e=l.value;n[e]=null!=(a=t[e])?a:""}}catch(e){o=!0,s=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw s}}return n},(e,t)=>{var n,i;return t===(null!=(n=null==(i=h.bind)?void 0:i[e])?n:"")?null:{op:"set-bind",node:h,name:e,path:""===t?void 0:t}},lB(n));var s=!0,a=!1,l=void 0;try{for(var u,d=i[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){let n=u.value,i=o.form.input(n);void 0!==i&&us(i,n,()=>p.build(()=>{var i;return uo(e.instance,e=>u_(t,o,n,e),{prop:n,current:null==(i=h.bind)?void 0:i[n]})}))}}catch(e){a=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(a)throw l}}if(_||r.length>0){let e=new n2({label:"Add binding…",nullable:!0,items:r.map(e=>({value:e,label:uy(e)})),tooltipText:"The property to bind; … picks what it follows"});e.root.setAttribute("data-u2-prop",ub),o.form.add(e),us(e,ub,()=>{let t=e.peek();null===t?f.shell.warning("Add binding: pick the property first"):w(t)()})}return o};i.own(()=>null==u?void 0:u.dispose());let R=tR([],"u2-designer-bindings"),j=()=>{void 0!==d&&m.splice(m.indexOf(d),1),null==u||u.dispose(),d=(u=new P.Scope).build(L),R.replaceChildren(d.form.root)},D=Object.keys(lU(e)).length>0;if((D||_||null!==lG(e)||lH(e).length>0)&&(j(),y("Bindings",R,D||lF(e))),Object.keys(n).length>0){let i=b(lq(n,"The function this event calls — pick one with the … button, or type cmd: plus its name"),n,()=>lW(e),(e,t)=>{var n;return t===lY(null==(n=h.on)?void 0:n[e])?null:{op:"set-event",node:h,event:e,command:""===t?void 0:t}},lB(n));y("Events",i.form.root,!0);var F=!0,z=!1,q=void 0;try{for(var B,G=Object.keys(n)[Symbol.iterator]();!(F=(B=G.next()).done);F=!0){let n=B.value,r=i.form.input(n);void 0!==r&&us(r,n,()=>p.build(()=>{var i;return uf({title:`${n}: pick a function`,instance:e.instance,pick:function(e){let t=void 0===e?"":"string"==typeof e?e:e.cmd;if(!t.startsWith("cmd:"))return;let n=t.slice(4);if(""===n||n.startsWith("#")||n.includes(".")&&!n.includes(":"))return;let i={name:n,args:{},binds:{}},r="object"==typeof e&&null!=(l=e.args)?l:{};var o=!0,s=!1,a=void 0;try{for(var l,u,d=Object.entries(r)[Symbol.iterator]();!(o=(u=d.next()).done);o=!0){let e=ud(u.value,2),t=e[0],n=e[1];"string"==typeof n&&n.startsWith("$.")?i.binds[t]=n:i.args[t]="string"==typeof n&&n.startsWith("$$.")?n.slice(1):n}}catch(e){s=!0,a=e}finally{try{o||null==d.return||d.return()}finally{if(s)throw a}}return i}(null==(i=h.on)?void 0:i[n]),onPick:e=>ux(t,{op:"set-event",node:h,event:n,command:function(e){let t=up(e.args);var n=!0,i=!1,r=void 0;try{for(var o,s=Object.entries(t)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=ud(o.value,2),n=e[0],i=e[1];"string"==typeof i&&i.startsWith("$.")&&(t[n]=`$${i}`)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return Object.assign(t,e.binds),0===Object.keys(t).length?`cmd:${e.name}`:{cmd:`cmd:${e.name}`,args:t}}(e)})})}),"Pick a function")}}catch(e){z=!0,q=e}finally{try{F||null==G.return||G.return()}finally{if(z)throw q}}}return i.effect(()=>{let n=t.onDidApply.value;if(null==s||s.refresh(),n&&!n.structural&&n.patches.some(t=>t.node===e.node)){n.patches.some(t=>t.node===e.node&&"set-bind"===t.op)&&M();var i=!0,r=!1,a=void 0;try{for(var l,u=m[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){let e=l.value;Object.assign(e.values,e.read()),e.form.refresh()}}catch(e){r=!0,a=e}finally{try{i||null==u.return||u.return()}finally{if(r)throw a}}null==o||o()}}),{sections:v,refresh:()=>{M(),j(),null==s||s.refresh()}}})(e,i,h,r)),c.push(...n.sections));let p=e=>{l.textContent=this.getCaption(e);let t=uC._identity(e);u.replaceWith(t),u=t;var n=!0,i=!1,r=void 0;try{for(var o,s=d[Symbol.iterator]();!(n=(o=s.next()).done);n=!0)o.value.remove()}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}d=a(e);let c=u.nextSibling;var h=!0,p=!1,f=void 0;try{for(var m,g=d[Symbol.iterator]();!(h=(m=g.next()).done);h=!0){let e=m.value;u.parentElement.insertBefore(e,c)}}catch(e){p=!0,f=e}finally{try{h||null==g.return||g.return()}finally{if(p)throw f}}};if(s={node:e.node,refresh:e=>{null==n||n.refresh(),p(e)}},void 0!==i){let t=i.onDidApply.peek();r.effect(()=>{let n=i.onDidApply.value;n!==t&&(null==n?void 0:n.patches.some(t=>t.node===e.node))&&null!==u.parentElement&&p(e)})}return tj(c,"u2-designer-properties")}static _identity(e){var t;let n={Tag:e.node.tag,Name:null!=(t=e.node.name)?t:"",Path:e.path()},i=e.error();return null!==i&&(n.Error=lF(e)?tj([t$(i),t$(lR,"u2-designer-hint")]):i),rh(n)}static _hint(e){return null===e.error()&&lF(e)?[t$(lR,"u2-designer-hint")]:[]}static _verbs(e){var t,n,i,r;let o=new Set((null!=(t=null==(i=e.instance.registry.get(e.node.tag))?void 0:i.designerActions)?t:[]).map(e=>e.text)),s=(null!=(n=null==(r=e.actions)?void 0:r.call(e))?n:[]).filter(e=>o.has(e.text));return 0===s.length?[]:[tD(s.map(e=>tB(e.text,e.run)),"u2-designer-verbs")]}static _status(e,t){var n;let i=e.built();if(!U.is(i)||null===ld(i))return[];let r=(null==(n=e.meta())?void 0:n.props.some(e=>"designData"===e.name))===!0?null:"always live — this source has no design-time policy",o=tj([],"u2-designer-status"),s=()=>{let e=ld(i),t={};""!==e.state&&(t.State="idle"===e.state?"idle — not run yet; use Refresh":e.state),null!==e.count&&(t["rows"===e.counts?"Rows":"Entities"]=e.count),null!==e.error&&(t.Error=e.error),null!==r&&(t["Design data"]=r),o.textContent="",o.append(rh(t))};return void 0===t?s():t.effect(s),[tF("Status"),o]}static _tables(e,t,n,i){let r=[];var o=!0,s=!1,a=void 0;try{for(var l,u=e[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){let e=l.value,t={};var d=!0,c=!1,h=void 0;try{for(var p,f=e.props[Symbol.iterator]();!(d=(p=f.next()).done);d=!0){let n=p.value,r=e.values[n.name];i.has(n.name)&&(void 0===r||""===r)||(t[n.name]=er(r))}}catch(e){c=!0,h=e}finally{try{d||null==f.return||f.return()}finally{if(c)throw h}}Object.keys(t).length>0&&r.push(tF(e.title),rh(t))}}catch(e){s=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(s)throw a}}return Object.keys(t).length>0&&r.push(tF("Events"),rh(t)),Object.keys(n).length>0&&r.push(tF("Bindings"),rh(n)),r}}function uA(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}g.ObjectHandler;let uO=["Containers","Viewers","Inputs","Actions","Display","Data"],uE=new Map;class uT extends H{_apply(e){let t=""!==e;var n=!0,i=!1,r=void 0;try{for(var o,s=this._groups[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let n=o.value,i=0;var a=!0,l=!1,u=void 0;try{for(var d,c,h=n.items[Symbol.iterator]();!(a=(c=h.next()).done);a=!0){let n=c.value,r=t&&!n.text.includes(e);n.el.hidden=r,!r&&i++}}catch(e){l=!0,u=e}finally{try{a||null==h.return||h.return()}finally{if(l)throw u}}n.pane.root.hidden=t&&0===i,t&&i>0?n.pane.expanded.value=!0:t||(n.pane.expanded.value=null==(d=uE.get(n.category))||d)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}}static _grouped(e){let t=new Map;var n=!0,i=!1,r=void 0;try{for(var o,s,a,l=e.metas()[Symbol.iterator]();!(n=(a=l.next()).done);n=!0){let e=a.value,n=null!=(s=e.category)?s:"Other",i=t.get(n);i?i.push(e):t.set(n,[e])}}catch(e){i=!0,r=e}finally{try{n||null==l.return||l.return()}finally{if(i)throw r}}let u=e=>{let t=uO.indexOf(e);return -1===t?uO.length:t},d=new Map([...t].sort((e,t)=>u(e[0])-u(t[0])));return null==(o=d.get("Viewers"))||o.sort((e,t)=>uT._label(e).localeCompare(uT._label(t))),d}static _label(e){var t;return null!=(t=e.label)?t:e.tag.startsWith("u2-")?e.tag.slice(3):e.tag}static _item(e){var t,n;let i=tR([],"u2-palette-item"),r=null==(n=e.icon)?void 0:n.call(e);return r&&i.append(tR([r],"u2-palette-item-icon")),i.append(t$(uT._label(e),"u2-palette-item-label")),i.title=null!=(t=e.usage)?t:e.description,i.dataset.u2Tag=e.tag,i}constructor(e){super(),this._groups=[],this.root.classList.add("u2-palette"),this.root.dataset.u2="palette",this.filter=this.build(()=>new nF({search:!0,inline:!0,placeholder:"Filter"}));const t=this.build(()=>new i2);t.root.classList.add("u2-palette-list"),this.root.append(this.filter.root,t.root);var n=!0,i=!1,r=void 0;try{for(var o,s,a=uT._grouped(e)[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){const e=function(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(e)||function(e){if(e){if("string"==typeof e)return uA(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return uA(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(s.value),n=e[0],i=e[1].map(e=>{var t;return{el:uT._item(e),text:`${e.tag} ${uT._label(e)} ${e.description} ${null!=(t=e.usage)?t:""}`.toLowerCase()}}),r=t.addPane(n,tR(i.map(e=>e.el)),null==(o=uE.get(n))||o);this._groups.push({category:n,pane:r,items:i}),this.effect(()=>{let e=r.expanded.value;""===this.filter.peek().trim()&&uE.set(n,e)})}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}this.effect(()=>this._apply(this.filter.value.trim().toLowerCase()))}}function uP(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}let uN="u2-func-source",uI="u2-table-source",uM="u2-entity-source",uL="u2-state";function uR(e,t,n,i,r){let o=sZ(e,t,n),s=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},o.props,i);return Object.keys(s).length>0&&(o.props=s),void 0!==r&&Object.keys(r).length>0&&(o.bind=r),o}class uj extends H{update(e,t){this._instance=e,this._chips.clear(),null==(l=this._pulse)||l.dispose(),this._pulse=void 0,this.root.textContent="",this.root.append(this._plus);let n=null!=(a=null==e?void 0:e.spec.components)?a:[];if(0===n.length)return void this.root.append(tR(["Data sources"],"u2-designer-tray-hint"));let i=new P.Scope;this._pulse=i;var r=!0,o=!1,s=void 0;try{for(var a,l,u,d,c=n[Symbol.iterator]();!(r=(d=c.next()).done);r=!0){let n=d.value,r=tR([],"u2-designer-chip"),o=new li(e,n);r.textContent=lo(n),r.title=null!=(u=o.error())?u:n.tag,void 0!==n.name&&(r.dataset.u2Name=n.name),r.classList.toggle("u2-designer-chip-broken",null!==o.error()),r.classList.toggle("u2-designer-chip-selected",n===t),this._chips.set(r,n),this.root.append(r),uj._pulseOf(i,r,o)}}catch(e){o=!0,s=e}finally{try{r||null==c.return||c.return()}finally{if(o)throw s}}}static _pulseOf(e,t,n){var i;let r=n.built();if(!U.is(r))return;let o=null!=(i=n.error())?i:n.node.tag;e.effect(()=>{let e=ld(r);t.classList.toggle("u2-designer-chip-loading",(null==e?void 0:e.state)==="loading"),t.classList.toggle("u2-designer-chip-error",(null==e?void 0:e.error)!=null),t.title=null===e?o:`${o} — ${lc(e)}`})}setDropTarget(e){this.root.classList.toggle("u2-designer-tray-drop",e)}_menu(){let e=this._instance;if(void 0===e)return;let t=new t0,n=null!=(s=null==(a=X.workspace)?void 0:a.tableNames())?s:[];t.group("Open tables"),0===n.length&&t.item("No open tables",()=>{},{disabled:"Open a table in Datagrok to add it here"});var i=!0,r=!1,o=void 0;try{for(var s,a,l,u=n[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){let n=l.value;t.item(n,()=>this._addTable(e,n))}}catch(e){r=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(r)throw o}}t.endGroup(),t.item("Function or query…",()=>this._addFunc(e)),t.item("Entity collection…",()=>this._addEntities(e)),t.item("State variable",()=>this._insert(e,uL,sX(uL),{})),t.show({anchor:this._plus})}_addTable(e,t){this._insert(e,uI,uD(t,sX(uI)),{table:t}),f.shell.info(`${t} references the open table by name; prefer a query or project table for a durable form.`)}_addFunc(e){this.build(()=>uf({title:"Data source: function or query",instance:e,onPick:t=>this._options.onAdd(sX(uN),n=>(function(e,t,n){let i={func:n.name},r=up(n.args);Object.keys(r).length>0&&(i.params=r);let o={};var s=!0,a=!1,l=void 0;try{for(var u,d,c=Object.entries(n.binds)[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let e=(u=d.value,function(e){if(Array.isArray(e))return e}(u)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(u)||function(e){if(e){if("string"==typeof e)return uP(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return uP(e,2)}}(u)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),t=e[0],n=e[1];o[`params.${t}`]=n}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}return uR(e,uN,t,i,o)})(e.registry.get(uN),n,t))}))}_addEntities(e){this.build(()=>{let t=new n2({label:"Collection",items:sB,value:sB["0"]}),n=new nF({label:"Filter",placeholder:"A smart-search filter"}),i=new n6({label:"Page size",mode:"int",value:20}),r=new iQ("Data source: entity collection");r.add(t).add(n).add(i).onOK(()=>{var o,s;let a={entity:null!=(o=t.peek())?o:sB["0"],pageSize:null!=(s=i.peek())?s:20},l=n.peek().trim();""!==l&&(a.filter=l),r.dispose(),this._insert(e,uM,sX(uM),a)}).onCancel(()=>r.dispose()).show({modal:!0,width:360})})}_insert(e,t,n,i){this._options.onAdd(n,n=>uR(e.registry.get(t),t,n,i))}constructor(e){super(),this._options=e,this._chips=new Map,this.own(()=>{var e;return null==(e=this._pulse)?void 0:e.dispose()}),this.root.classList.add("u2-designer-tray"),this.root.dataset.u2="tray",this._plus=t6("plus",()=>this._menu(),{tooltip:"Add a data source"}),this._plus.classList.add("u2-designer-tray-add");const t=e=>this._chips.get(e.target.closest(".u2-designer-chip"));this.scope.listen(this.root,"click",n=>{let i=t(n);i&&e.onSelect(i)}),this.scope.listen(this.root,"contextmenu",n=>{n.preventDefault(),n.stopPropagation();let i=t(n);i&&e.onContext(i,n.clientX,n.clientY)})}}function uD(e,t){let n=e.split(/[^A-Za-z0-9_$]+/).filter(e=>""!==e).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return""===n||/^\d/.test(n)?t:n}function u$(e,t,n){if(!n){t.style.display="none";return}let i=e.getBoundingClientRect();t.style.display="block",t.style.left=`${n.x-i.left+e.scrollLeft}px`,t.style.top=`${n.y-i.top+e.scrollTop}px`,t.style.width=`${n.width}px`,t.style.height=`${n.height}px`}function uF(e,t){let n=e.get(t.tag);return n?!0===n.acceptsChildren||void 0!==n.adopt||void 0!==n.createWithChildren:o_(t.tag)}function uz(e,t,n,i,r,o){var s;if(!o||e.parentOf(o)!==t)return{parent:t,index:n,kind:i,rect:r};let a=(null!=(s=t.children)?s:[]).indexOf(o),l=n>a?n-1:n;return l===a?null:{parent:t,index:l,kind:i,rect:r}}function uq(e,t){let n=new li(e,t).element();if(!n)return null;let i=n.getBoundingClientRect();return{x:i.left,y:i.top,width:i.width,height:i.height}}let uB="u2-func-source",uG=["csv","tsv","txt","d42"];function uV(e){let t,n=[],i=[];var r=!0,o=!1,s=void 0;try{for(var a,l=(Array.isArray(e)?e:[e])[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){let e=a.value;if(e instanceof g.FileInfo){null!=t||(t=function(){let e=new Set(uG);var t=!0,n=!1,i=void 0;try{for(var r,o=g.Func.find({meta:{role:"file-handler"}})[Symbol.iterator]();!(t=(r=o.next()).done);t=!0){let t=r.value;var s=!0,a=!1,l=void 0;try{for(var u,d,c=String(null!=(u=t.options.ext)?u:"").split(",")[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let t=d.value.trim().toLowerCase();""!==t&&e.add(t)}}catch(e){a=!0,l=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw l}}}}catch(e){n=!0,i=e}finally{try{t||null==o.return||o.return()}finally{if(n)throw i}}return e}());let r=function(e,t){let n=e.fileName;if(e.isDirectory)return`${n}: a folder is not a table — drop a file`;let i=e.extension.toLowerCase();return""===i?`${n}: nothing opens a file with no extension as a table`:t.has(i)?null:`${n}: nothing opens .${i} files as a table`}(e,t);null===r?n.push(function(e){let t=e.fileName,n=e.extension,i=""===n?t.length:t.length-n.length-1;return{kind:"file",ref:"OpenFile",params:{fullPath:e.fullPath},label:t.slice(0,i),runs:!0}}(e)):i.push(r)}else e instanceof g.Func&&n.push(function(e){var t;return{kind:"func",ref:g.Func.find({name:e.name}).length>1?e.nqName:e.name,params:{},label:null!=(t=e.friendlyName)?t:e.name,runs:!1}}(e))}}catch(e){o=!0,s=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw s}}return{items:n,refused:i}}class uU{get dragging(){return void 0!==this.drag||this.platformDrag}onPaneDown(e){if(0!==e.button)return;this.dragged=!1,this._host.refocus();let t=this._host.hit(e),n=this._host.instance();t&&n&&t!==n.spec.root&&(this.drag={node:t,label:lo(t),x:e.clientX,y:e.clientY,active:!1,target:null})}onPaletteDown(e){var t,n,i;if(0!==e.button)return;let r=e.target.closest(".u2-palette-item");if(!r)return;e.preventDefault();let o=r.dataset.u2Tag;this.drag={tag:o,label:null!=(t=r.textContent)?t:"",x:e.clientX,y:e.clientY,active:!1,target:null,tray:void 0!==o&&(null==(i=this._host.instance())||null==(n=i.registry.get(o))?void 0:n.visual)===!1}}onMove(e){let t=this.drag,n=this._host.instance();if(!t||!n)return;let i=this._host.root;if(!t.active){if(4>Math.abs(e.clientX-t.x)&&4>Math.abs(e.clientY-t.y))return;t.active=!0,this._ghost.textContent=t.label,i.append(this._ghost)}let r=i.getBoundingClientRect();if(this._ghost.style.left=`${e.clientX-r.left+i.scrollLeft+12}px`,this._ghost.style.top=`${e.clientY-r.top+i.scrollTop+12}px`,t.tray){let n=i.getBoundingClientRect();t.over=e.clientX>=n.left&&e.clientX<=n.right&&e.clientY>=n.top&&e.clientY<=n.bottom,this._host.tray.setDropTarget(t.over);return}let o=this._host.hit(e);t.target=null!==o||this._overPane(e)?function(e,t,n,i,r){var o,s,a,l;let u=e.registry;if(!t){let t=e.spec.root;if(!uF(u,t))return null;let n=uq(e,t);return n?uz(e,t,(null!=(a=t.children)?a:[]).length,"into",n,r):null}if(r&&(r===t||ob.contains(r,t)))return null;if(uF(u,t)){let n=uq(e,t);return n?uz(e,t,(null!=(l=t.children)?l:[]).length,"into",n,r):null}let d=e.parentOf(t);if(!d||!uF(u,d))return null;let c=uq(e,t),h=new li(e,d).element();if(!c||!h)return null;let p=(null!=(o=getComputedStyle(h).flexDirection)?o:"").startsWith("row"),f=p?n>c.x+c.width/2:i>c.y+c.height/2,m=(null!=(s=d.children)?s:[]).indexOf(t)+ +!!f;return uz(e,d,m,"line",p?{x:f?c.x+c.width:c.x,y:c.y,width:2,height:c.height}:{x:c.x,y:f?c.y+c.height:c.y,width:c.width,height:2},r)}(n,o,e.clientX,e.clientY,t.node):null,this.showDrop(t.target)}end(e){let t=this.drag;this.drag=void 0,!t||!t.active||(this._ghost.remove(),this.showDrop(null),this._host.tray.setDropTarget(!1),this.dragged=!0,this._host.refocus(),e&&(t.tray?this._dropComponent(t):t.target&&this.drop(t,t.target)))}_dropComponent(e){if(!0!==e.over)return;let t=e.tag;this.addComponent(sX(t),(e,n)=>{var i;return sZ(null==(i=this._host.instance())?void 0:i.registry.get(t),t,e,n)})}addComponent(e,t){var n;let i=this._host.editor.peek(),r=this._host.instance();if(!i||!r)return;let o=i.uniqueNames(),s=t(o(e),o);this._host.pending(s),this._host.apply({op:"add-component",index:(null!=(n=r.spec.components)?n:[]).length,node:s})}dropSources(e){var t;e.refused.length>0&&f.shell.warning(e.refused.join("; "));let n=this._host.editor.peek(),i=this._host.instance();if(!n||!i||0===e.items.length)return;let r=n.uniqueNames(),o=e.items.map(e=>{var t;let n;return t=i.registry,n={func:e.ref},Object.keys(e.params).length>0&&(n.params=e.params),uR(t.get(uB),uB,r(uD(e.label,sX(uB))),n)}),s=(null!=(t=i.spec.components)?t:[]).length,a=o.map((e,t)=>({op:"add-component",index:s+t,node:e})),l=n.canApply(a[0]);if(l)return void f.shell.warning(l);this._host.pending(o[0]),n.applyAll(a);for(let t=0;t<o.length;t++)e.items[t].runs&&this._host.refresh(o[t])}drop(e,t){var n,i,r,o,s;let a,l,u=this._host.editor.peek();if(!u)return;if(e.node){this._host.pending(e.node),this._host.apply({op:"move",node:e.node,parent:t.parent,index:t.index});return}let d=e.tag,c=this._host.instance(),h=u.uniqueNames(),p=sZ(null==c?void 0:c.registry.get(d),d,h(sX(d)),h),f=(void 0===c||(a=(null==(n=c.registry.get(p.tag))?void 0:n.props.some(e=>"table"===e.name&&lz(e)===lM))===!0,l=(null!=(r=c.spec.components)?r:[]).filter(e=>{var t;return(null==(t=l3(c,e))?void 0:t.bindProps().some(e=>{var t;return!0===e.default&&(null!=(t=e.propertyType)?t:e.type)==="dataframe"}))===!0}),a&&1===l.length&&(null==(i=p.bind)?void 0:i.table)===void 0&&(o=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},p.bind),s=s={table:or([l[0].name])},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(s)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(s)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(s,e))}),p.bind=o)),p);this._host.pending(f),this._host.apply({op:"add",parent:t.parent,index:t.index,node:f})}showDrop(e){u$(this._host.root,this.into,e&&"into"===e.kind?e.rect:null),u$(this._host.root,this.line,e&&"line"===e.kind?e.rect:null)}_overPane(e){return this._host.pane.isConnected&&document.elementsFromPoint(e.clientX,e.clientY).includes(this._host.pane)}constructor(e){this._host=e,this.into=tR([],"u2-designer-drop-into"),this.line=tR([],"u2-designer-drop-line"),this._ghost=tR([],"u2-designer-drag-ghost"),this.platformDrag=!1,this.dragged=!1}}class uH{hit(e){let t=this._host.instance();if(!t)return null;var n=!0,i=!1,r=void 0;try{for(var o,s=document.elementsFromPoint(e.clientX,e.clientY)[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;if(!this._host.surface.contains(e))continue;let n=t.nodeAt(e);if(n)return n}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return null}onCanvasClick(e){if(this._host.dragged())return;if(e.ctrlKey||e.metaKey){let t=this.hit(e);t&&this.toggleMulti(t);return}if(this._forwardHeader(e))return;let t=this.hit(e);t&&this.select(t)}toggleMulti(e){let t=this.multi.filter(t=>t!==e);if(t.length===this.multi.length)t.push(e);else if(0===t.length)return;1===t.length?this.select(t[0]):this.selectMulti(t,t.includes(e)?e:t[t.length-1])}_forwardHeader(e){var t,n,i;let r=this._host.instance();if(!r)return!1;let o=document.elementsFromPoint(e.clientX,e.clientY).find(e=>this._host.surface.contains(e));if(!o)return!1;let s=o.closest(".u2-tabs-tab"),a=null!=s?s:o.closest(".u2-accordion-header");if(!a)return!1;let l=r.nodeAt(a),u=l?r.nodes().get(l):void 0;if(s&&u instanceof nU&&void 0!==s.dataset.id){u.activeTab.value=s.dataset.id;let e=null==(t=l.children)?void 0:t[Number(s.dataset.id.slice(4))];return this.select(null!=e?e:l),!0}if(!s&&u instanceof i2){let e=Array.prototype.indexOf.call(u.root.children,a.parentElement),t=u.paneAt(e);return!!t&&(t.expanded.value=!t.expanded.peek(),t.expanded.peek()&&this.select(null!=(n=null==(i=l.children)?void 0:i[e])?n:l),!0)}return!1}select(e,t){var n;let i,r=this._host.instance();if(!r)return;this.selected=e,this.multi=[e],this._reveal(e),this.reposition(),this._host.tray.update(r,e),this._host.report(),this._host.touch(),f.shell.windows.showContextPanel=!0,this._issue(r,e);let o=null==(n=this._host.model())?void 0:n.ids.get(e);(void 0===t||t)&&void 0!==o&&this._host.tree.expandPath((i=o.split(".")).map((e,t)=>i.slice(0,t+1).join(".")))}_issue(e,t){let n=new li(e,t,this._host.editor.peek(),()=>this._host.actions());this._shownBroken=null!==n.error(),f.shell.o=n}_issueMulti(e,t){f.shell.o=new lr(t.map(t=>new li(e,t,this._host.editor.peek())))}reassert(){let e=this._host.instance();if(e&&this.selected){if(this.multi.length>1)return void this._issueMulti(e,this.multi);uS(new li(e,this.selected)),this._issue(e,this.selected)}}followRerender(){let e=this._host.instance();e&&this.selected&&!(this.multi.length>1)&&null!==new li(e,this.selected).error()!==this._shownBroken&&this.reassert()}onTreeSelection(e){e&&(e!==this.selected?this.select(e,!1):this.multi.length>1&&queueMicrotask(()=>{this.multi.length>1&&e===this.selected&&this._host.tree.selectedNodes.peek().length<=1&&this.select(e)}))}selectMulti(e,t){let n=this._host.instance();n&&!(e.length<2)&&(this.selected=t&&e.includes(t)?t:e[e.length-1],this.multi=e,this._reveal(this.selected),this.reposition(),this._host.tray.update(n,this.selected),this._host.report(),this._host.touch(),f.shell.windows.showContextPanel=!0,this._issueMulti(n,e))}collapse(){let e=this.selected;this.multi=[e],this._host.tree.clearSelection(),this.select(e)}_reveal(e){let t=this._host.instance();for(let i=e,r=t.parentOf(i);r;i=r,r=t.parentOf(i)){var n;let e=t.nodes().get(r),o=(null!=(n=r.children)?n:[]).indexOf(i);if(e instanceof nU)e.activeTab.value=`tab-${o}`;else if(e instanceof i2){let t=e.paneAt(o);t&&(t.expanded.value=!0)}}}setHovered(e){e!==this.hovered&&(this.hovered=e,this.reposition())}reposition(){var e;let t=this._host.pane.isConnected,n=t&&this.selected?this.multi:[];for(;this._adorners.length<n.length;){let e=tR([],"u2-designer-selected");this._adorners.push(e),this._host.root.append(e)}for(let t=0;t<this._adorners.length;t++)this._outline(this._adorners[t],null!=(e=n[t])?e:null);this._outline(this.hover,t&&this.hovered&&!n.includes(this.hovered)?this.hovered:null),this._observe(n.length>0?this._elementOf(n[0]):null)}_observe(e){e!==this._observed&&(this._observed&&this._resize.unobserve(this._observed),this._observed=e,e&&this._resize.observe(e))}_elementOf(e){var t;let n=this._host.instance();return null!=(t=e&&n?new li(n,e).element():void 0)?t:null}_outline(e,t){let n=this._elementOf(t);u$(this._host.root,e,n&&n.isConnected?n.getBoundingClientRect():null)}constructor(e){this._host=e,this.box=tR([],"u2-designer-selected"),this._adorners=[this.box],this.hover=tR([],"u2-designer-hover"),this.selected=null,this.multi=[],this.hovered=null,this._shownBroken=!1,this._resize=new ResizeObserver(()=>this.reposition()),this._observed=null,e.own(()=>this._resize.disconnect())}}let uW=[{name:"Master–detail (grid + filters)",spec:{$schema:r4,components:[{tag:"u2-func-source",name:"orders",props:{func:"demoOrders",params:{days:30},designData:"sample",debounce:50,sample:[{orderId:1001,customer:"Aspirin Labs",city:"Kyiv",total:1240},{orderId:1002,customer:"Bayer",city:"Lviv",total:380},{orderId:1003,customer:"Roche",city:"Basel",total:2150}]}}],root:{tag:"u2-splitter",name:"masterDetail",props:{sizes:[.25,.45,.3]},children:[{tag:"u2-viewer-filters",name:"filters",bind:{table:"$.orders"},props:{columnNames:["city","total"]}},{tag:"u2-viewer-grid",name:"grid",bind:{table:"$.orders"},props:{allowEdit:!1}},{tag:"u2-panel",name:"detailPane",children:[{tag:"u2-viewer-form",name:"form",bind:{table:"$.orders"}},{tag:"u2-form",name:"detailForm",children:[{tag:"u2-text-input",name:"customerField",props:{label:"Customer"},bind:{value:"$.orders.currentRow.customer"}},{tag:"u2-number-input",name:"rowIdx",props:{label:"Row",mode:"int"},bind:{value:"$.orders.currentRowIdx"}}]}]}]}}}],uY="u2.designer.gallery";function uK(){try{var e;return null!=(e=globalThis.localStorage)?e:null}catch(e){return null}}function uX(){try{var e;let t=null==(e=uK())?void 0:e.getItem(uY);if(!t)return{};let n=JSON.parse(t);return null===n||"object"!=typeof n||Array.isArray(n)?{}:n}catch(e){return{}}}let uZ=[{name:"Blank",spec:{$schema:r4,root:{tag:"u2-form",name:"form1"}}},{name:"Data entry",spec:{$schema:r4,root:{tag:"u2-panel",name:"dataEntry",children:[{tag:"u2-form",name:"entryForm",children:[{tag:"u2-text-input",name:"nameInput",props:{label:"Name"}},{tag:"u2-number-input",name:"amountInput",props:{label:"Amount",value:1,min:0,max:100}},{tag:"u2-choice-input",name:"categoryInput",props:{label:"Category",items:["Reagent","Solvent","Catalyst"]}},{tag:"u2-bool-input",name:"activeInput",props:{label:"Active",value:!0}},{tag:"u2-text-area",name:"notesInput",props:{label:"Notes"}}]},{tag:"u2-div-h",name:"entryButtons",children:[{tag:"u2-button",name:"saveButton",props:{text:"Save",primary:!0}},{tag:"u2-button",name:"cancelButton",props:{text:"Cancel"}}]}]}}},{name:"Master–detail",spec:{$schema:r4,root:{tag:"u2-splitter",name:"masterDetail",props:{sizes:[.3,.7]},children:[{tag:"u2-panel",name:"masterPane",children:[{tag:"u2-text-input",name:"searchInput",props:{label:"Search",search:!0,inline:!0}},{tag:"u2-multi-choice-input",name:"itemList",props:{label:"Items",items:["Aspirin","Ibuprofen","Paracetamol","Naproxen"]}}]},{tag:"u2-panel",name:"detailPane",children:[{tag:"h2",name:"detailTitle",props:{text:"Details"}},{tag:"u2-form",name:"detailForm",children:[{tag:"u2-text-input",name:"detailName",props:{label:"Name",value:"Aspirin"}},{tag:"u2-text-area",name:"detailNotes",props:{label:"Notes"}}]}]}]}}},{name:"Settings",spec:{$schema:r4,root:{tag:"u2-tabs",name:"settingsTabs",children:[{tag:"u2-panel",name:"generalPane",props:{title:"General"},children:[{tag:"u2-form",name:"generalForm",children:[{tag:"u2-text-input",name:"titleInput",props:{label:"Title",value:"My dashboard"}},{tag:"u2-bool-input",name:"autoSaveInput",props:{label:"Auto-save",value:!0}}]}]},{tag:"u2-panel",name:"appearancePane",props:{title:"Appearance"},children:[{tag:"u2-form",name:"appearanceForm",children:[{tag:"u2-color-input",name:"accentInput",props:{label:"Accent",value:"#1f77b4"}},{tag:"u2-slider-input",name:"opacityInput",props:{label:"Opacity",value:80,min:0,max:100}}]}]},{tag:"u2-panel",name:"advancedPane",props:{title:"Advanced"},children:[{tag:"u2-form",name:"advancedForm",children:[{tag:"u2-number-input",name:"cacheInput",props:{label:"Cache size",value:100,min:0,max:1e3}},{tag:"u2-choice-input",name:"logLevelInput",props:{label:"Log level",items:["error","warning","info","debug"],value:"info"}}]}]}]}}},{name:"Dashboard",spec:{$schema:r4,root:{tag:"u2-panel",name:"dashboard",children:[{tag:"u2-breadcrumbs",name:"crumbs",props:{items:["Home","Projects","Demo"]}},{tag:"h2",name:"dashboardTitle",props:{text:"Overview"}},{tag:"u2-div-h",name:"dashboardRow",children:[{tag:"u2-panel",name:"settingsCard",children:[{tag:"u2-property-grid",name:"settingsGrid",props:{properties:[{name:"Title",type:"string"},{name:"Rows",type:"int",min:0}],values:{Title:"Demo",Rows:20}}}]},{tag:"u2-panel",name:"logoCard",children:[{tag:"u2-image-input",name:"logoInput",props:{label:"Logo"}}]},{tag:"u2-panel",name:"summaryCard",children:[{tag:"u2-form",name:"summaryForm",children:[{tag:"u2-text-input",name:"ownerInput",props:{label:"Owner",value:"admin"}},{tag:"u2-number-input",name:"countInput",props:{label:"Items",value:3}}]}]}]}]}}}];class uQ{build(){var e,t;let n=this._host,i=t6("undo",()=>{var e;null==(e=n.editor.peek())||e.undo(),n.refocus()},{tooltip:"Undo"}),r=t6("redo",()=>{var e;null==(e=n.editor.peek())||e.redo(),n.refocus()},{tooltip:"Redo"});n.effect(()=>{var e;return tA.apply(i,(null==(e=n.editor.value)?void 0:e.canUndo.value)===!0?null:"Nothing to undo")}),n.effect(()=>{var e;return tA.apply(r,(null==(e=n.editor.value)?void 0:e.canRedo.value)===!0?null:"Nothing to redo")});let o=lv.map(e=>t6(lk[e],()=>n.run(e),{tooltip:e}));return n.effect(()=>{let e=n.revision()>=0?n.actions():[];for(let t=0;t<o.length;t++)tA.apply(o[t],void 0===e[t]?"Select a component first":tA.now(e[t].disabled))}),[n.mode,t6("file",()=>this.newForm(),{tooltip:"New form"}),(e=e=>this._openMenu(e),t={icon:"folder-open",tooltip:"Open"},t3("dropdown-button",n=>{let i,r,o,s=null==t?void 0:t.split,a=null==t?void 0:t.primary,l=()=>!!o&&(o.close(),!0),u=()=>{if(l())return;let t=t0.popup();e(t),o=t,t.show({anchor:i});let n=new P.Scope(void 0,{label:"dropdown-menu"});n.effect(()=>{let e=t.isOpen.value;r.setAttribute("aria-expanded",String(e)),e||(o===t&&(o=void 0),n.dispose())})},d=s?e=>{l(),s(e)}:u,c=(null==t?void 0:t.icon)?t8("",t.icon,d,{primary:a}):tB(t$("","u2-btn-label"),d,{primary:a});if((null==t?void 0:t.tooltip)&&t4(c,t.tooltip),s){let e=tB(tK("chevron-down",{cls:"u2-dropdown-chevron"}),u,{primary:a});e.classList.add("u2-dropdown-arrow"),e.setAttribute("aria-label","More"),i=tR([c,e],"u2-dropdown-split"),r=e}else c.append(tK("chevron-down",{cls:"u2-dropdown-chevron"})),c.classList.add("u2-dropdown-btn"),i=c,r=c;i.dataset.u2="dropdown-button",r.setAttribute("aria-haspopup","menu"),r.setAttribute("aria-expanded","false");let h=e=>{"ArrowDown"!==e.key||o||(e.preventDefault(),u())};return n?(n.listen(i,"keydown",h),n.own(l)):i.addEventListener("keydown",h),i})),t6("copy",()=>{this._copy(),n.refocus()},{tooltip:"Copy spec"}),i,r,...o,t6("border-all",()=>n.refocus(),{toggle:n.outlines,tooltip:"Control bounds"})]}_load(e){var t;let n=()=>{this._host.open(e),this._host.refocus()};if((null==(t=this._host.editor.peek())?void 0:t.dirty.peek())!==!0)return void n();let i=new P.Scope;i.build(()=>new iQ("Discard changes?")).add("The form has been modified. Discard the changes?").onOK(()=>{i.dispose(),n()}).onCancel(()=>{i.dispose(),this._host.refocus()}).show({modal:!0})}newForm(){this._load(uZ["0"].spec)}_openMenu(e){e.group("Samples");for(let t=0,n=[...uZ,...(null==(a=null==(s=this._host.instance())?void 0:s.registry)?void 0:a.get("u2-viewer-grid"))!==void 0?uW:[]];t<n.length;t++){let i=n[t];e.item(i.name,()=>this._load(i.spec))}e.endGroup();let t=uX(),n=Object.keys(t);if(n.length>0){e.group("Gallery");var i=!0,r=!1,o=void 0;try{for(var s,a,l,u=n[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){let n=l.value;e.item(n,()=>this._load(t[n]))}}catch(e){r=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(r)throw o}}e.endGroup()}e.separator(),e.item("Open spec…",()=>this._openDialog()),e.item("Save to gallery…",()=>this.saveToGallery())}saveToGallery(){let e=this._host.dump();if(!e){f.shell.info("Nothing to save — the canvas is empty."),this._host.refocus();return}let t=new P.Scope,n=t.build(()=>new nF({label:"Name",placeholder:"My form"}));t.build(()=>new iQ("Save to gallery")).add(n).add("An entry that already carries this name is overwritten.").onOK(()=>{let i=n.peek().trim();if(t.dispose(),""===i){f.shell.warning("A gallery entry needs a name."),this._host.refocus();return}if(function(e,t){let n=uK();if(!n)return!1;let i=uX();i[e]=t;try{return n.setItem(uY,JSON.stringify(i)),!0}catch(e){return!1}}(i,e)){var r;f.shell.info(`Saved to the gallery as "${i}".`),null==(r=this._host.editor.peek())||r.markClean(),this._host.report()}else f.shell.warning(`Could not save "${i}" — storage is unavailable or full.`);this._host.refocus()}).onCancel(()=>{t.dispose(),this._host.refocus()}).show({modal:!0,width:360})}_openDialog(){let e=new P.Scope,t=this._host.dump(),n=e.build(()=>new nz({label:"Spec",value:t?JSON.stringify(t,null,2):"",placeholder:"Paste a dg-ui/1 spec"}));n.root.classList.add("u2-designer-spec-editor"),e.build(()=>new iQ("Open spec")).add(n).onOK(()=>{this._host.open(n.peek()),e.dispose(),this._host.refocus()}).onCancel(()=>{e.dispose(),this._host.refocus()}).show({modal:!0,width:560})}_copy(){let e=this._host.dump();e?navigator.clipboard.writeText(JSON.stringify(e,null,2)).then(()=>f.shell.info("Spec copied to the clipboard."),e=>f.shell.error(`Could not copy: ${e instanceof Error?e.message:String(e)}`)):f.shell.info("Nothing to copy — the canvas is empty.")}constructor(e){this._host=e}}function uJ(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}class u0 extends H{ribbon(){return this.build(()=>this._ribbon.build())}open(e){var t,n;let i;try{i=ox(e),"string"!=typeof e&&(i=JSON.parse(JSON.stringify(i)))}catch(e){f.shell.error(e instanceof Error?e.message:String(e));return}null==(t=this._instance)||t.dispose(),this._surface.textContent="",this._selection.selected=null,this._selection.multi=[],this._hovered=null,this._pendingSelect=null,this._instance=this.build(()=>{var e,t,n,r;return e=i,t=this._ctx,n=this._registry,r={designTime:"run"!==this._mode.selected.peek()[0]},new ob(ox(e),null!=t?t:new ov,n,r)}),this._surface.append(this._instance.root),this._editor.value=new sK(this._instance),this._model=ls(this._instance),this._tree.clearSelection(),this._tree.setRoots(this._model.roots),this._stampDesign(),this._tray.update(this._instance,null),this._report();let r=null==(n=this._model.roots[0])?void 0:n.data;r?this._select(r):this._selection.reposition()}dump(){return this._instance?this._instance.dump():null}get _drag(){return this._dragLayer.drag}set _drag(e){this._dragLayer.drag=e}get _dragging(){return this._dragLayer.dragging}get _selected(){return this._selection.selected}get _multi(){return this._selection.multi}get _hovered(){return this._selection.hovered}set _hovered(e){this._selection.hovered=e}_select(e){this._selection.select(e)}_endDrag(e){this._dragLayer.end(e)}_actions(){return this._verbs.actions()}_run(e){this._verbs.run(e)}_rowActions(e){return this._verbs.rowActions(e)}_afterPatch(e){e.structural?this._rebuildTree():this._selection.followRerender(),this._selection.reposition(),this._tray.update(this._instance,this._selected),this._report(),this._stampDesign(),this._touch()}_rebuildTree(){let e=this._instance;if(!e)return;this._model=ls(e),this._tree.clearSelection(),this._tree.setRoots(this._model.roots);let t=this._survivor(e);this._pendingSelect=null,t&&this._select(t)}_survivor(e){let t=e.nodes();return this._pendingSelect&&t.has(this._pendingSelect)?this._pendingSelect:this._selected&&t.has(this._selected)?this._selected:t.has(e.spec.root)?e.spec.root:null}_stampDesign(){let e=this._instance;if(e){var t=!0,n=!1,i=void 0;try{for(var r,o,s,a,l=e.nodes()[Symbol.iterator]();!(t=(a=l.next()).done);t=!0){let t=(r=a.value,function(e){if(Array.isArray(e))return e}(r)||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(r)||function(e){if(e){if("string"==typeof e)return uJ(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return uJ(e,2)}}(r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),n=t[0],i=t[1],l=ob.elementOf(i);l&&(l.classList.add("u2-designer-node"),l.classList.toggle("u2-designer-root",n===e.spec.root),l.classList.toggle("u2-designer-empty",(null!=(o=null==(s=n.children)?void 0:s.length)?o:0)===0&&uF(e.registry,n)))}}catch(e){n=!0,i=e}finally{try{t||null==l.return||l.return()}finally{if(n)throw i}}}}_touch(){this._revision.value=this._revision.peek()+1}_refocus(){this.root.focus({preventScroll:!0})}_apply(e){let t=this._editor.peek();if(!t)return!1;let n=t.canApply(e);return n?(this._pendingSelect=null,f.shell.warning(n),!1):(t.apply(e),!0)}_rename(e,t){e.data&&(this._apply({op:"rename",node:e.data,name:t})||this._rebuildTree())}_setDesign(e){var t;e?this.root.append(this._pane):(this._pane.remove(),this._hovered=null),tA.apply(this._surface,e?u0.DESIGNING:null),this.root.classList.toggle("u2-designer-running",!e);let n=void 0!==this._instance&&this._instance.designTime!==e;null==(t=this._instance)||t.setDesignTime(e),this._stampDesign(),this._tray.update(this._instance,this._selected),this._selection.reposition(),n&&this._selection.reassert()}_report(){var e;if(!this._instance){this._status.value="Nothing rendered";return}let t=this._instance.nodes().size,n=[this._multi.length>1?`${this._multi.length} selected`:this._selected?new li(this._instance,this._selected).path():"No selection",`${t} node${1===t?"":"s"}`],i=function(e){let t=0;var n=!0,i=!1,r=void 0;try{for(var o,s=e.nodes().values()[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;!U.is(e)&&e.classList.contains(ln)&&t++}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}(this._instance);i>0&&n.push(`${i} broken`),(null==(e=this._editor.peek())?void 0:e.dirty.peek())&&n.push("modified"),this._status.value=n.join(" \xb7 ")}constructor(e,t,n){super(),this._surface=tR([],"u2-designer-surface"),this._pane=tR([],"u2-designer-pane"),this._status=(0,P.signal)(""),this._outlines=(0,P.signal)(!0),this._editor=(0,P.signal)(void 0),this._revision=(0,P.signal)(0),this._pendingSelect=null,this.status=this._status,this._ctx=null!=t?t:new ov,this._registry=null!=n?n:r7,this.root.classList.add("u2-designer"),this.root.dataset.u2="designer",this.root.tabIndex=0,this._tray=this.build(()=>new uj({onSelect:e=>this._select(e),onContext:(e,t,n)=>{this._select(e),na(this._verbs.handBack(this._actions())).show({x:t,y:n})},onAdd:(e,t)=>this._dragLayer.addComponent(e,t)})),this._tree=this.build(()=>new nZ({onRename:(e,t)=>this._rename(e,t),contextActions:e=>this._rowActions(e)})),this._mode=this.build(()=>new rj({items:[{id:"design",text:"Design"},{id:"run",text:"Run"}],toggle:"single",density:"ribbon"})),this._mode.selected.value=["design"];const i={root:this.root,surface:this._surface,pane:this._pane,tree:this._tree,tray:this._tray,mode:this._mode.root,outlines:this._outlines,editor:this._editor,instance:()=>this._instance,model:()=>this._model,selected:()=>this._selected,multi:()=>this._multi,revision:()=>this._revision.value,inDrag:()=>void 0!==this._drag,dragged:()=>this._dragLayer.dragged,hit:e=>this._selection.hit(e),select:e=>this._select(e),collapse:()=>this._selection.collapse(),endDrag:e=>this._endDrag(e),actions:()=>this._actions(),run:e=>this._run(e),pending:e=>this._pendingSelect=e,apply:e=>this._apply(e),refresh:e=>this._verbs.refresh(e),open:e=>this.open(e),dump:()=>this.dump(),effect:e=>this.effect(e),own:e=>this.own(e),report:()=>this._report(),touch:()=>this._touch(),refocus:()=>this._refocus()};this._selection=new uH(i),this._dragLayer=new uU(i),this._verbs=new lS(i),this._ribbon=new uQ(i),this.root.append(this._surface,this._tray.root,this._selection.box,this._selection.hover,this._dragLayer.into,this._dragLayer.line),function(e){m.makeDroppable(e.element,{dropIndication:!1,acceptDrag:t=>{var n;return e.active()&&((n=uV(t.dragObject)).items.length>0||n.refused.length>0)},onBeginDrag:()=>e.onDragActive(!0),onEndDrag:()=>e.onDragActive(!1),doDrop:t=>{e.onDragActive(!1),e.active()&&(t.handled=!0,e.onDrop(uV(t.dragObject)))}})}({element:this.root,active:()=>!this.scope.isDisposed&&this._pane.isConnected&&void 0===this._drag,onDragActive:e=>{this._dragLayer.platformDrag=e,this._tray.setDropTarget(e),e&&this._selection.setHovered(null)},onDrop:e=>this._dragLayer.dropSources(e)}),this.scope.listen(this._tree.root,"click",e=>{var t;if(e.ctrlKey||e.metaKey||e.shiftKey)return;let n=null==(t=this._tree.selectedNode.peek())?void 0:t.data;n&&this._select(n)}),this.scope.listen(this._pane,"click",e=>this._selection.onCanvasClick(e)),this.scope.listen(this._pane,"mousedown",e=>this._dragLayer.onPaneDown(e)),this.scope.listen(this._pane,"contextmenu",e=>this._verbs.onContextMenu(e,this._selection.hit(e))),this.scope.listen(this._pane,"mousemove",e=>this._selection.setHovered(this._dragging?null:this._selection.hit(e))),this.scope.listen(this._pane,"mouseleave",()=>this._selection.setHovered(null)),this.scope.listen(this._tree.root,"mouseover",e=>{var t,n;return this._selection.setHovered(this._dragging?null:null!=(t=null==(n=this._tree.nodeForRow(e.target))?void 0:n.data)?t:null)}),this.scope.listen(this._tree.root,"mouseleave",()=>this._selection.setHovered(null)),this.scope.listen(this.root,"contextmenu",e=>{this._pane.isConnected&&(e.preventDefault(),e.stopPropagation())}),this.scope.listen(this._surface,"scroll",()=>this._selection.reposition(),{capture:!0}),this.scope.listen(window,"resize",()=>this._selection.reposition()),this.scope.listen(document,"mousemove",e=>this._dragLayer.onMove(e)),this.scope.listen(document,"mouseup",()=>this._endDrag(!0)),this.scope.listen(document,"keydown",e=>{i.inDrag()&&"Escape"===e.key&&i.endDrag(!1)}),this.open(e),this._palette=this.build(()=>{var e,t;return new uT(null!=(e=null==(t=this._instance)?void 0:t.registry)?e:this._registry)}),this.toolbox=tj([tF("Palette"),this._palette.root,tF("Structure"),this._tree.root],"u2-designer-toolbox"),this.scope.listen(this._palette.root,"mousedown",e=>this._dragLayer.onPaletteDown(e)),this.scope.listen(this.toolbox,"contextmenu",e=>{e.preventDefault(),e.stopPropagation()}),this.scope.listen(this._mode.root,"click",()=>this._refocus()),this.scope.listen(this.root,"keydown",e=>lA(e,i)),this.scope.listen(this.toolbox,"keydown",e=>lA(e,i)),this.effect(()=>{var e,t;let n=this._tree.selectedNodes.value,i=null!=(e=null==(t=this._tree.selectedNode.value)?void 0:t.data)?e:null;n.length>1?this._selection.selectMulti(n.map(e=>e.data),i):this._selection.onTreeSelection(i)}),this.effect(()=>this._setDesign("run"!==this._mode.selected.value[0])),this.effect(()=>this.root.classList.toggle("u2-designer-outlines",this._outlines.value)),this.effect(()=>{var e;let t=null==(e=this._editor.value)?void 0:e.onDidApply.value;t&&this._afterPatch(t)}),this.own(uk)}}function u2(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function u1(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){u2(o,i,r,s,a,"next",e)}function a(e){u2(o,i,r,s,a,"throw",e)}s(void 0)})}}u0.DESIGNING="Switch to Run to use the controls",sz.defaultEditors=(e,t)=>aw.resolve(e,t);let u3={users:()=>f.dapi.users,groups:()=>f.dapi.groups,projects:()=>f.dapi.projects,queries:()=>f.dapi.queries,connections:()=>f.dapi.connections,scripts:()=>f.dapi.scripts,spaces:()=>f.dapi.spaces};function u5(e){let t=e.indexOf(":"),n=t<0?g.Func.find({name:e}):g.Func.find({package:e.slice(0,t),name:e.slice(t+1)});return n.length>0?n[0]:null}let u4=new Map;X.funcRunner={find:e=>{let t=u5(e);return null===t?null:{name:e,kind:t instanceof g.TableQuery?"table-query":t instanceof g.DataQuery?"query":t instanceof g.Script?"script":"function",inputs:t.inputs,outputs:t.outputs}},run:(e,t,n,i)=>u1(function*(){let n=u5(e);if(null===n)throw Error(`"${e}" is not a known function`);let r=yield(u=null==i?void 0:i.maxRows,d=()=>n.prepare(t).call(),u1(function*(){if(void 0===u||!(n instanceof g.TableQuery))return d();let e=n.dart,t=u4.get(e);void 0===t&&(t={previous:n.limit,runs:0},u4.set(e,t)),t.runs++,n.limit=u;try{return yield d()}finally{0==--t.runs&&(u4.delete(e),n.limit=t.previous)}})()),o={};var s=!0,a=!1,l=void 0;try{for(var u,d,c,h=n.outputs[Symbol.iterator]();!(s=(c=h.next()).done);s=!0){let e=c.value;o[e.name]=r.outputs[e.name]}}catch(e){a=!0,l=e}finally{try{s||null==h.return||h.return()}finally{if(a)throw l}}return o})()},X.dapi=e=>{let t=u3[e];return void 0===t?null:t()},X.dapiFind=(e,t)=>u1(function*(){let n=u3[e];return void 0===n?null:n().find(t)})(),X.workspace={table:e=>{var t;return null!=(t=f.shell.table(e))?t:null},tableNames:()=>a_.tableNames(),onTablesChanged:{subscribe:e=>{let t=[f.events.onTableAdded,f.events.onTableRemoved].map(t=>t.subscribe(e));return{unsubscribe:()=>{var e=!0,n=!1,i=void 0;try{for(var r,o=t[Symbol.iterator]();!(e=(r=o.next()).done);e=!0)r.value.unsubscribe()}catch(e){n=!0,i=e}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}}}}}},X.tableFromRows=e=>{var t;return null!=(t=g.DataFrame.fromObjects(e))?t:g.DataFrame.create(0)};let u6=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,u8=new Map;X.principalIcon=e=>{if(""===e||e.includes('"'))return null;let t=u8.get(e);void 0===t&&u8.set(e,t=u1(function*(){var t;let n=u6.test(e)?"id":"friendlyName";return null!=(t=yield f.dapi.groups.filter(`${n} = "${e}"`).first())?t:null})().catch(()=>null));let n=document.createElement("div");return n.className="u2-avatar",t.then(e=>{null!==e&&n.replaceWith(function(e){let t;if(e.personal){let t,o;var n,i,r=e.user;let s=r.picture;if(s instanceof HTMLElement){let e=a$("u2-avatar u2-avatar-picture");return e.append(s),e}return a$(`u2-avatar u2-avatar-${function(e){let t=0;for(let n=0;n<e.length;n++)t=(31*t+e.charCodeAt(n))%9973;return t%6+1}(r.login)}`,(o=(t=(i=r.friendlyName).includes("@")?i.substring(0,i.indexOf("@")):i).match(/[A-Z]/g))?o.slice(0,2).join(""):t.substring(0,2).toUpperCase())}let o=(n="u2-avatar u2-avatar-group",(t=document.createElement("div")).className=n,t.textContent="",t);return o.append(tK("user-friends")),o}(e))}),n},X.format={dateFormat:()=>f.shell.settings.dateFormat,number:(e,t)=>g.format(e,t)};let u9=".d4-balloon-container";class u7{static get available(){return"function"==typeof globalThis.grok_Balloon}static show(e,t,n,i){var r,o;if(!u7.available)return;let s=null!=(r=null==(o=document.querySelector(u9))?void 0:o.lastElementChild)?r:null,a="string"==typeof e&&"error"!==t?u7._text(e):e,l={autoHide:n.autoHide,copyText:n.copyText,timeout:Math.max(1,Math.round(n.timeout/1e3))};"error"===t?f.shell.error(a,l):"warning"===t?f.shell.warning(a,l):f.shell.info(a,l);let u=document.querySelector(u9),d=null==u?void 0:u.lastElementChild;if(null===u||!(d instanceof HTMLElement)||d===s)return i(),{root:document.createElement("div"),close:()=>{}};let c=new MutationObserver(()=>{d.isConnected||(c.disconnect(),i())});return c.observe(u,{childList:!0}),{root:d,close:()=>d.remove()}}static _text(e){let t=document.createElement("span");return t.textContent=e,t}}ra.presenter=(e,t,n,i)=>u7.show(e,t,n,i),n(1858);let de=e=>(t,n)=>(function(e,t,n){let i={},r={},o=[];var s=!0,a=!1,l=void 0;try{for(var u,d=Object.entries(null!=n?n:{})[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){let e=lX(u.value,2),t=e[0],n=e[1];i[t]=n instanceof P.Signal?n.peek():n,n instanceof P.Signal?o.push([t,n]):r[t]=n}}catch(e){a=!0,l=e}finally{try{s||null==d.return||d.return()}finally{if(a)throw l}}return function(e,t,n,i,r){var o;let s,a=t instanceof P.Signal?t:(0,P.signal)(t),l=a.peek();n.filters;let u=function(e,t){if(null==e)return{};var n,i,r,o={};if("u">typeof Reflect&&Reflect.ownKeys){for(r=0,n=Reflect.ownKeys(Object(e));r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i]);return o}if(o=function(e,t){if(null==e)return{};var n,i,r={},o=Object.getOwnPropertyNames(e);for(i=0;i<o.length;i++)n=o[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n]);return r}(e,t),Object.getOwnPropertySymbols)for(r=0,n=Object.getOwnPropertySymbols(e);r<n.length;r++)i=n[r],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(o[i]=e[i]);return o}(n,["filters"]);try{s=e(null!=l?l:g.DataFrame.create(0),null==l?u:n)}catch(e){if(null!=l)throw e;throw Error("This viewer needs a table — bind `table` to a data source",{cause:e})}let d=s;return null==(o=P.Scope.ambient)||o.own(()=>d.dispose()),d.root.classList.add("u2-viewer"),d.effect(()=>{var e;let t=a.value;if(null!=t&&(null==(e=d.dataFrame)?void 0:e.dart)!==t.dart){lZ.add(d);try{d.dataFrame=t,d.setOptions(i)}finally{lZ.delete(d)}}}),d.build(()=>{var e=!0,t=!1,n=void 0;try{for(var i,o=r[Symbol.iterator]();!(e=(i=o.next()).done);e=!0){let e=lX(i.value,2),t=e[0],n=e[1];!function(e,t,n){let i,r=()=>e.getProperties().some(e=>e.name===t),o=()=>e.build(()=>e.link(t,n,(0,P.isWritableSignal)(n)));if(r())return o();let s=0,a=()=>{i=void 0,r()||++s>=40?o():i=setTimeout(a,25)};i=setTimeout(a,0),e.own(()=>clearTimeout(i))}(d,t,n)}}catch(e){t=!0,n=e}finally{try{e||null==o.return||o.return()}finally{if(t)throw n}}}),d}(e,t,i,r,o)})((t,n)=>g.Viewer.fromType(e,t,n),t,n);de("Grid"),de("Histogram"),de("Bar chart"),de("Confusion matrix"),de("Roc curve"),de("Heat map"),de("Box plot"),de("Filters"),de("Scatter plot"),de("Line chart"),de("Network diagram"),de("Calendar"),de("Correlation plot"),de("Density plot"),de("Form"),de("Markup"),de("Matrix plot"),de("PC Plot"),de("Pie chart"),de("3d scatter plot"),de("Statistics"),de("Tile Viewer"),de("Tree map"),de("Trellis plot"),de("Pivot table"),g.StringUtils,new WeakSet,az();function dt(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}g.ObjectHandler,g.ObjectHandler;class dn{get restoring(){return 0!==this._restoring}restore(e){var t;return(t=function*(){this._restoring++;try{return yield e()}finally{this._restoring--}},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){dt(o,i,r,s,a,"next",e)}function a(e){dt(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}static _typed(e,t){return e.page===t.page&&e.entity===t.entity&&e.mode===t.mode}_moved(e,t){return e.page!==t.page||e.query!==t.query||e.search!==t.search||e.mode!==t.mode||e.entity!==t.entity&&e.entity!==this._host.draftEntity}_restoreFromUrl(){this._host.isCurrentView()&&this._host.owns(location.pathname)&&this._host.open(`${location.pathname}${location.search}`)}_arm(){this._disarm(),this._typing=setTimeout(()=>this._typing=void 0,dn.SETTLE_MS)}_disarm(){void 0!==this._typing&&clearTimeout(this._typing),this._typing=void 0}constructor(e,t){this._host=e,this._restoring=0;const n=t.owner,i=()=>this._restoreFromUrl();window.addEventListener("popstate",i),n.own(()=>window.removeEventListener("popstate",i));let r=e.state();n.effect(()=>{let t=e.path.value,n=r;if(r=e.state(),0===this._restoring&&"u">typeof history&&this._moved(n,r)){if(dn._typed(n,r)){void 0===this._typing?history.pushState(null,"",t):history.replaceState(null,"",t),this._arm();return}this._disarm(),history.pushState(null,"",t)}}),n.own(()=>this._disarm())}}dn.SETTLE_MS=600,aC.register("file",(e,t)=>new a0(t));var di=n(1991),dr=n.n(di),ds=n(9713),da=n(7579);function dl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function du(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class dd extends g.JsViewer{get isRenderPending(){return this.renderState.isPending}get onRendered(){return this.renderState.rendered.asObservable()}get immediateRendering(){return this.renderState.immediateRendering}set immediateRendering(e){this.renderState.immediateRendering=e}getWidgetStatus(){var e,t,n,i,r,o;let s=null!=(e=null==(i=this._scViewer)?void 0:i.getWidgetStatus())?e:{};return du(dl({},s),{values:du(dl({},s.values),{"cluster size threshold":null!=(t=null==(r=this.drawnThresholds)?void 0:r.clusterSize)?t:"","activity threshold":null!=(n=null==(o=this.drawnThresholds)?void 0:o.activity)?n:"","activity target":this._scViewer?this._scViewer.props.invertYAxis?C.wf.LOW:C.wf.HIGH:"",message:this.viewerError})})}detach(){var e,t;null==(e=this.selectionSubscription)||e.unsubscribe(),null==(t=this.linesDrawSubscription)||t.unsubscribe(),this.renderState.dispose(),this._scViewer=null,super.detach()}get scViewer(){return this._scViewer||(this._scViewer=this.createSCViewer()),this._scViewer}get model(){return _.i.getInstance(this.dataFrame)}createSCViewer(){let e={showXAxis:!0,showYAxis:!0,showXSelector:!1,showYSelector:!1,showColorSelector:!1,xAxisType:g.AxisType.logarithmic,yAxisType:g.AxisType.logarithmic,invertYAxis:this.activityTarget===C.wf.LOW,xColumnName:dd.clusterSizeColName,markerType:"circle",markerDefaultSize:10,showSizeSelector:!1};if(null==this.clusterColumnName||null==this.activityColumnName||!this.dataFrame.columns.contains(this.clusterColumnName)||!this.dataFrame.columns.contains(this.activityColumnName))return this.viewerError="Please set valid cluster and activity columns",null;let t=this.dataFrame.columns.byName(this.activityColumnName),n=this.dataFrame.columns.byName(this.clusterColumnName),i=null!=this.connectivityColumnName?this.dataFrame.columns.byName(this.connectivityColumnName):null;if(![g.COLUMN_TYPE.FLOAT,g.COLUMN_TYPE.INT,g.COLUMN_TYPE.BIG_INT,g.COLUMN_TYPE.QNUM].includes(t.type))return this.viewerError="Activity column should be numeric",null;let r=this.dataFrame.columns.getOrCreate(dd.clusterSizeColName,g.TYPE.INT),o={};for(let e=0;e<this.dataFrame.rowCount;e++){var s;let t=n.get(e);null!=t&&"-1"!=t&&(o[t]=(null!=(s=o[t])?s:0)+1)}r.init(e=>{var t;return n.isNone(e)?null:null!=(t=o[n.get(e)])?t:null}),t.stats.min<=0&&(e.yAxisType=g.AxisType.linear);let a={},l={};for(let e=0;e<this.dataFrame.rowCount;e++){let r=n.get(e);if(null==r||n.isNone(e)||t.isNone(e))continue;let o=t.get(e),s=a[r];if(null==s||void 0==s||o>t.get(s)&&this.activityTarget===C.wf.HIGH?a[r]=e:o<t.get(s)&&this.activityTarget===C.wf.LOW&&(a[r]=e),i){let t=i.get(e),n=l[r];null==n||void 0==n?l[r]=e:t>i.get(n)&&(l[r]=e)}}let u=this.dataFrame.columns.getOrCreate(dd.maxActivityInClusterColName,g.COLUMN_TYPE.INT);u.init(e=>n.isNone(e)?0:+(e===a[n.get(e)])),this.dataFrame.columns.getOrCreate(dd.maxConnectivityInClusterColName,g.COLUMN_TYPE.INT).init(e=>n.isNone(e)?0:+(e===l[n.get(e)])),this.dataFrame.columns.getOrCreate(dd.synSelectionColName,g.TYPE.STRING).init(e=>{if(n.isNone(e))return null;let t=null;return e===a[n.get(e)]&&(t=dd.maxActivityLabel),i&&e===l[n.get(e)]&&(t=t?`${t}, ${dd.maxConnectivityLabel}`:dd.maxConnectivityLabel),t}),e.xColumnName=dd.clusterSizeColName,e.yColumnName=this.activityColumnName,e.filter=this.scFilterQuery,this.viewerError="";let d=g.Viewer.scatterPlot(this.dataFrame,e);this.renderState.add(d),this.selectionSubscription&&this.selectionSubscription.unsubscribe(),this.selectionSubscription=d.onDataEvent.pipe((0,ds.filter)(e=>"d4-select"==e.type)).subscribe(e=>{var t,i;let r=null!=(t=null==(i=e.bitset)?void 0:i.getSelectedIndexes())?t:[],o=this.dataFrame.selection,s=g.BitSet.create(this.dataFrame.rowCount,e=>1==u.get(e));s.and(o);for(let e=0;e<r.length;e++){let t=r[e],i=n.get(t);n.isNone(t)||(s.set(t,!0),null!=l[i]&&s.set(l[i],!0))}for(let e of(s.fireChanged(),s.getSelectedIndexes())){let t=n.get(e);null!=t&&null!=l[t]&&s.set(l[t],!0)}this.renderState.defer("selection",()=>{this.dataFrame.selection.copyFrom(s,!0),this.renderState.defer("accordion",()=>{this.model&&this.model.createAccordion()},200)},200)});let c=()=>{let e=g.BitSet.create(this.dataFrame.rowCount);Object.entries(a).forEach(([n,i])=>{var r;if(null==n||null==i)return;let s=parseInt(n),a=t.get(i),u=null!=(r=o[s])?r:o[n];a<this.activityThreshold&&u<this.clusterSizeThreshold||(e.set(i,!0,!1),null!=l[s]&&e.set(l[s],!0,!1))}),e.fireChanged(),this.dataFrame.selection.copyFrom(e,!0)};return this._selsectIcon=m.iconSvg("select-all",()=>{c()},"Select 3 Active quadrants"),this._selsectIcon.style.cursor="pointer",this._selsectIcon.style.marginRight="5px",c(),this.linesDrawSubscription&&this.linesDrawSubscription.unsubscribe(),this.linesDrawSubscription=d.onBeforeDrawScene.subscribe(()=>{let e=d.getInfo().canvas.getContext("2d"),t=d.viewport,n=d.worldToScreen(t.x,this.activityThreshold),i=d.worldToScreen(this.clusterSizeThreshold,t.y),r=d.worldToScreen(t.x+t.width,this.activityThreshold),o=d.worldToScreen(this.clusterSizeThreshold,t.y+t.height);e.beginPath(),e.strokeStyle="rgb(0,0,0)",e.lineWidth=1,e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.moveTo(i.x,i.y),e.lineTo(o.x,o.y),e.stroke(),e.closePath(),this.drawnThresholds={clusterSize:this.clusterSizeThreshold,activity:this.activityThreshold}}),d}onTableAttached(){var e,t,n,i,r,o,s,a,l,u,d;super.onTableAttached();let c=null!=(e=null==(t=this.dataFrame)?void 0:t.col(C.$2.ACTIVITY))?e:null==(n=dr()(null==(i=this.dataFrame)?void 0:i.columns.numerical).next())?void 0:n.value;null!=c&&(null==(r=this.getProperty(`activity${C.To}`))||r.set(this,c.name));let h=null==(o=dr()(null==(s=this.dataFrame)?void 0:s.columns.categorical).next())?void 0:o.value;null!=h&&(null==(a=this.getProperty(`cluster${C.To}`))||a.set(this,h.name));let p=null==(l=dr()(null==(u=this.dataFrame)?void 0:u.columns.numerical).next())?void 0:l.value;null!=p&&(null==(d=this.getProperty(`connectivity${C.To}`))||d.set(this,p.name)),this.render(),this.subs.push(this.dataFrame.onDataChanged.subscribe(()=>{this.render()}))}render(){this.renderState.defer("render",()=>{var e,t;if(!this.dataFrame)return;y()(this.root).empty();let n=this.scViewer;if(null==n)return void this.root.appendChild(m.divText(null!=(t=this.viewerError)?t:"Error creating scatter plot"));let i=m.div("Cluster Size",{style:{alignSelf:"center",color:"var(--grey-6)",marginBottom:"5px"}}),r=m.div(this.activityTarget===C.wf.HIGH?"Maximum Activity":"Minimum Activity",{style:{color:"var(--grey-6)",alignSelf:"center",textOrientation:"mixed",writingMode:"tb",transform:"rotate(180deg)",marginLeft:"5px"}});n.props.colorColumnName=null!=(e=this.colorColumnName)?e:null,this.root.appendChild(m.divH([r,m.divV([m.divH([this._titleHost,this._selsectIcon],{style:{alignSelf:"center",lineHeight:"normal",width:"100%"}}),n.root,i],{style:{flexGrow:"1"}})])),n.root.style.width="100%",this.renderState.defer("invalidate",()=>{n.props.filter=this.scFilterQuery,n.invalidateCanvas()},100)},this.renderDebounceTime)}onPropertyChanged(e){if(super.onPropertyChanged(e),(null==e?void 0:e.name)!==`color${C.To}`){var t,n;this.renderState.cancel("selection"),this.renderState.cancel("accordion"),this.renderState.cancel("invalidate"),null==(t=this.selectionSubscription)||t.unsubscribe(),null==(n=this.linesDrawSubscription)||n.unsubscribe(),this._scViewer&&this.renderState.remove(this._scViewer),this._scViewer=null,this.drawnThresholds=null}this.render()}constructor(){super(),this._titleHost=m.divText(_.q.CLUSTER_MAX_ACTIVITY,{id:"pep-viewer-title",style:{marginRight:"auto"}}),this._selsectIcon=m.div(),this.activityTarget=C.wf.HIGH,this.viewerError="",this.renderDebounceTime=500,this.renderState=new da.Y,this.drawnThresholds=null,this.scFilterQuery=`$\{${dd.maxActivityInClusterColName}} == 1`,this.selectionSubscription=null,this.linesDrawSubscription=null,this.clusterColumnName=this.column("cluster",{nullable:!1}),this.activityColumnName=this.column("activity",{nullable:!1}),this.colorColumnName=this.column("color",{nullable:!0,defaultValue:null}),this.activityTarget=this.string("activityTarget",C.wf.HIGH,{choices:[C.wf.HIGH,C.wf.LOW]}),this.clusterSizeThreshold=this.int("clusterSizeThreshold",20),this.activityThreshold=this.float("activityThreshold",1e3,{step:.1}),this.connectivityColumnName=this.column("connectivity",{nullable:!0})}}dd.clusterSizeColName="~cluster.size",dd.maxActivityInClusterColName="~max.activity.for.cluster",dd.maxConnectivityInClusterColName="~max.connectivity.for.cluster",dd.synSelectionColName="Syn Selection",dd.maxActivityLabel="Max Activity",dd.maxConnectivityLabel="Max Connectivity";var dc=n(8154),dh=n(5013);function dp(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function df(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class dm extends g.JsViewer{get isRenderPending(){return this.renderState.isPending}get onRendered(){return this.renderState.rendered.asObservable()}get immediateRendering(){return this.renderState.immediateRendering}set immediateRendering(e){this.renderState.immediateRendering=e}getWidgetStatus(){var e,t;let n=null!=(e=null==(t=this._boxPlotViewer)?void 0:t.getWidgetStatus())?e:{};return df(dp({},n),{values:df(dp({},n.values),{positions:this.renderedPositions.join(", ")})})}detach(){this.renderState.dispose(),this._boxPlotViewer=void 0,super.detach()}getPositionFromColumn(){var e;let t=this.dataFrame.col(this.sequenceColumnName);if(null==t)return 1;let n=parseInt(null!=(e=t.getTag(O.gp.selectedPosition))?e:"1");return Number.isNaN(n)?1:Math.max(1,n)}parsePositions(){return this.positions?[...new Set(this.positions.split(",").map(e=>parseInt(e.trim())).filter(e=>!Number.isNaN(e)&&e>=1))].sort((e,t)=>e-t):[1]}_setPositions(e){let t=[...new Set(e)].sort((e,t)=>e-t);this.getProperty("positions").set(this,t.join(", "))}onTableAttached(){if(super.onTableAttached(),null==this.dataFrame.columns.bySemType(g.SEMTYPE.MACROMOLECULE))throw f.shell.error("No sequence column found"),Error("No sequence column found");let e=this.dataFrame.columns.getUnusedName("~sequence_position_monomers");this._positionColumn=this.dataFrame.columns.addNewString(e),this._positionColumn.semType="Monomer",this._positionColumn.setTag("cell.renderer","Monomer"),this.getProperty("sequenceColumnName").set(this,this.dataFrame.columns.bySemType(g.SEMTYPE.MACROMOLECULE).name),this.getProperty("valueColumnName").set(this,dr()(this.dataFrame.columns.numerical).next().value.name),this.getProperty("positions").set(this,String(this.getPositionFromColumn())),this.subs.push(this.dataFrame.onMetadataChanged.subscribe(()=>this.renderState.defer("metadata",()=>{let e=this.getPositionFromColumn();this.parsePositions().includes(e)||this._setPositions([e])},200)))}render(){let e=this.parsePositions();if(null==this.dataFrame||!this.sequenceColumnName||!e.length||!this._positionColumn||!this.valueColumnName)return;y()(this.root).empty(),this._boxPlotViewer&&this.renderState.remove(this._boxPlotViewer);let t=dh.Z.getSeqHelper(),n=this.dataFrame.col(this.sequenceColumnName),i=t.getSeqHandler(n),r=i.maxLength,o=e.map(e=>i.getMonomersAtPosition(e-1,!1));if(this._positionColumn.init(e=>o.map(t=>t[e]).join(O.ot)),this._boxPlotViewer=this.dataFrame.plot.box({categoryColumnNames:[this._positionColumn.name],plotStyle:"violin",valueColumnName:this.valueColumnName,colorColumnName:this._positionColumn.name,showColorSelector:!1,showSizeSelector:!1,showCategorySelector:!1,legendVisibility:g.VisibilityMode.Never,markerColorColumnName:this._positionColumn.name,title:"Sequence Position Statistics",autoLayout:!1,labelOrientation:"Vert"}),this.renderedPositions=e,this.renderState.add(this._boxPlotViewer),this.showPositionInfo){let t=this._renderPositionSelector(e,r);this.root.appendChild(t)}this._boxPlotViewer.props.statistics=["min","max","avg","med","count"],this._boxPlotViewer.root.style.width="100%",this._boxPlotViewer.root.style.height="100%",this.root.appendChild(this._boxPlotViewer.root),this._boxPlotViewer.sub(this._boxPlotViewer.onPropertyValueChanged.subscribe(e=>{var t,n,i,r;if((null==(n=this._boxPlotViewer)||null==(t=n.props)?void 0:t.valueColumnName)&&(null==(r=this._boxPlotViewer)||null==(i=r.props)?void 0:i.valueColumnName)!==this.valueColumnName){let e=this._boxPlotViewer.props.valueColumnName;this.renderState.defer("value column",()=>this.getProperty("valueColumnName").set(this,e),10)}}))}_renderPositionSelector(e,t){let n=m.divH([],{style:{alignItems:"center",justifyContent:"center",gap:"4px",flexWrap:"wrap",padding:"4px 8px",width:"100%"}}),i=m.label(`${this.sequenceColumnName}:`);for(let r of(i.style.fontWeight="bold",i.style.marginRight="4px",n.appendChild(i),e))n.appendChild(this._createChip(r,e,t));return n.appendChild(this._createAddButton(n,e,t)),n}_createChip(e,t,n){let i=1===t.length,r=document.createElement("span");r.textContent=String(e),r.style.marginRight="3px";let o=i?m.iconFA("pencil",()=>this._showInlineEdit(s,e,n),"Edit position"):m.iconFA("times",()=>this._setPositions(t.filter(t=>t!==e)),"Remove position");o.style.cursor="pointer",o.style.fontSize="10px",o.style.opacity="0.6";let s=m.divH([r,o],{style:{display:"inline-flex",alignItems:"center",background:"#f0f0f0",borderRadius:"12px",padding:"2px 8px",fontSize:"12px",cursor:"default",border:"1px solid #d0d0d0"}});return s}_showInlineEdit(e,t,n){var i;let r=document.createElement("input");r.type="number",r.min="1",r.max=String(n),r.value=String(t),r.style.cssText="width:45px;height:22px;font-size:12px;text-align:center;border-radius:12px;border:1px solid #aaa;outline:none;padding:0 4px;";let o=!1,s=()=>{if(o)return;o=!0;let i=parseInt(r.value),s=this.parsePositions();!Number.isNaN(i)&&i>=1&&i<=n&&i!==t?this._setPositions(s.map(e=>e===t?i:e)):r.replaceWith(e)};r.addEventListener("keydown",t=>{if("Enter"===t.key&&s(),"Escape"===t.key){var n;o=!0,null==(n=e.parentElement)||n.replaceChild(e,r)}}),r.addEventListener("blur",s),null==(i=e.parentElement)||i.replaceChild(r,e),r.focus(),r.select()}_createAddButton(e,t,n){let i=m.iconFA("plus-circle",()=>{if(e.querySelector(".position-add-input"))return;let r=document.createElement("input");r.type="number",r.min="1",r.max=String(n),r.className="position-add-input",r.style.cssText="width:45px;height:22px;font-size:12px;text-align:center;border-radius:12px;border:1px solid #aaa;outline:none;padding:0 4px;";let o=!1,s=()=>{if(o)return;o=!0;let e=parseInt(r.value);!Number.isNaN(e)&&e>=1&&e<=n&&!t.includes(e)?this._setPositions([...t,e]):r.remove()};r.addEventListener("keydown",e=>{"Enter"===e.key&&s(),"Escape"===e.key&&(o=!0,r.remove())}),r.addEventListener("blur",s),e.insertBefore(r,i),r.focus()},"Add position");return i.style.cursor="pointer",i.style.fontSize="14px",i.style.color="#2083d5",i}onPropertyChanged(e){null!=this.dataFrame&&this.sequenceColumnName&&this.render()}constructor(){super(),this.showPositionInfo=!0,this.renderState=new da.Y,this.renderedPositions=[],this.positions=this.string("positions","1",{description:"Comma-separated sequence positions (1-based) to analyze"}),this.sequenceColumnName=this.column("sequence",{semType:g.SEMTYPE.MACROMOLECULE,nullable:!1}),this.valueColumnName=this.column("value",{columnTypeFilter:"numerical",nullable:!1}),this.showPositionInfo=this.bool("showPositionInfo",!0,{nullable:!1,defaultValue:!0,description:"Show position selector in the viewer header"}),this.subs.push(f.events.onContextMenu.subscribe(e=>{var t;e.causedBy&&e.causedBy.target&&(null==(t=this._boxPlotViewer)?void 0:t.root.contains(e.causedBy.target))&&(e.causedBy.preventDefault(),e.causedBy.stopPropagation(),e.causedBy.stopImmediatePropagation())}))}}var dg=n(7153),dv=n(7563),db=n(1381);function dy(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function d_(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){dy(o,i,r,s,a,"next",e)}function a(e){dy(o,i,r,s,a,"throw",e)}s(void 0)})}}function dw(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function dx(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}class dk extends g.JsViewer{get isRenderPending(){return this.renderState.isPending}get onRendered(){return this.renderState.rendered.asObservable()}get immediateRendering(){return this.renderState.immediateRendering}set immediateRendering(e){this.renderState.immediateRendering=e}getWidgetStatus(){var e,t,n;let i=null!=(e=null==(n=this._lineChart)?void 0:n.getWidgetStatus())?e:{};return dx(dw({},i),{values:dx(dw({},i.values),{position:null!=(t=this.renderedPosition)?t:"","cliff rows":this.cliffRows,message:this.message})})}onTableAttached(){var e,t;super.onTableAttached();let n=this.dataFrame.columns.bySemType(g.SEMTYPE.MACROMOLECULE);n&&this.getProperty("sequenceColumnName").set(this,n.name),this.getProperty("activityColumnName").set(this,dr()(this.dataFrame.columns.numerical).next().value.name);let i=null==(t=dr()(this.dataFrame.columns.categorical))||null==(e=t.filter(e=>{var t;return e.name!==this.sequenceColumnName&&(null==(t=e.name)?void 0:t.toLowerCase().includes("series"))}).next())?void 0:e.value;i&&this.getProperty("seriesColumnName").set(this,i.name),this.subs.push(this.dataFrame.onFilterChanged.subscribe(()=>this.renderState.defer("filter",()=>{this.clearCache(),this.debouncedRender()},200))),this.debouncedRender(),this.subs.push(f.events.onContextMenu.subscribe(e=>{var t;e.causedBy&&e.causedBy.target&&(null==(t=this._lineChart)?void 0:t.root.contains(e.causedBy.target))&&(e.causedBy.preventDefault(),e.causedBy.stopPropagation(),e.causedBy.stopImmediatePropagation())}))}get mutationCliffsData(){if(this._mutationCliffsData)return this._mutationCliffsData;if(!this.activityColumnName||!this.sequenceColumnName||!this.position)throw Error("Activity column or Sequence column is not set, or position is invalid");return this._mutationCliffsData=new Promise((e,t)=>d_(function*(){try{let t=this.dataFrame.col(this.activityColumnName).getRawData(),n=this.positionColumns,i=n[this.position-1].toList(),r=n.map(A.eY),o=yield new dg.a().calc(t,r,{maxMutations:1,minActivityDelta:0,filter:this.dataFrame.filter.anyFalse?new Uint32Array(this.dataFrame.filter.getBuffer().buffer):void 0,singlePosition:{position:this.position-1}});e({cliffs:o,monomers:i})}catch(e){t(e)}}).call(this)),this._mutationCliffsData}calculateDf(){return d_(function*(){let e=this.renderGeneration;if(!this.dataFrame||!this.activityColumnName||!this.sequenceColumnName||!this.position)throw Error("Activity column or Sequence column is not set, or position is invalid");let t=yield this.mutationCliffsData;if(e!==this.renderGeneration)return g.DataFrame.create();let n=new Set;t.cliffs.forEach(e=>{e.forEach(e=>{Array.from(e.entries()).forEach(([e,t])=>{let i=Number(e);this.currentRowMutationsOnly&&this.dataFrame.currentRowIdx!==i||(n.add(i),t.forEach(e=>n.add(Number(e))))})})});let i=Array.from(n.values()).sort((e,t)=>e-t),r=new Map;i.forEach((e,t)=>{r.set(e,t)});let o=i.map(e=>t.monomers[e]),s=this.dataFrame.col(this.activityColumnName).getRawData(),a=i.map(e=>s[e]),l=[g.Column.fromList("string",`Position ${this.position}`,o),g.Column.fromList("double",this.activityColumnName,a)];if(this.seriesColumnName){let e=this.dataFrame.col(this.seriesColumnName).getRawData(),t=this.dataFrame.col(this.seriesColumnName).categories,n=i.map(n=>t[e[n]]),r=g.Column.fromList("string",this.seriesColumnName,n);l.push(r)}let u=g.DataFrame.fromColumns(l);Array.from(this.dataFrame.columns.numerical).filter(e=>e.name!==this.activityColumnName&&e.name!==this.seriesColumnName).forEach(e=>{u.columns.addNew(e.name,e.type)}),this._dfSubs.push(u.onMouseOverRowChanged.subscribe(e=>{if(u.mouseOverRowIdx>=0){let e=i[u.mouseOverRowIdx];this.dataFrame.mouseOverRowIdx=e}})),this._dfSubs.push(this.dataFrame.onMouseOverRowChanged.subscribe(e=>{if(this.dataFrame.mouseOverRowIdx>=0){let e=r.get(this.dataFrame.mouseOverRowIdx);void 0!=e?u.mouseOverRowIdx=e:u.mouseOverRowIdx=-1}}));let d=!1;this._dfSubs.push(u.onCurrentRowChanged.subscribe(e=>{if(u.currentRowIdx>=0){d=!0;let e=i[u.currentRowIdx];this.dataFrame.currentRowIdx=e}})),this.currentRowMutationsOnly&&this._dfSubs.push(this.dataFrame.onCurrentRowChanged.subscribe(e=>{if(d){d=!1;return}this.clearCache(!1),this.debouncedRender()}));let c=!1,h=!1;return this._dfSubs.push(u.onSelectionChanged.subscribe(()=>this.renderState.defer("chart selection",()=>{let e=u.selection;if(c){c=!1;return}if(h=!0,this.dataFrame.selection.setAll(!1,!1),!e.anyTrue)return void this.dataFrame.selection.fireChanged();for(let t=-1;-1!==(t=e.findNext(t,!0));){let e=i[t];this.dataFrame.selection.set(e,!0,!1)}this.dataFrame.selection.fireChanged()},100))),this._dfSubs.push(this.dataFrame.onSelectionChanged.subscribe(()=>this.renderState.defer("table selection",()=>{let e=this.dataFrame.selection;if(h){h=!1;return}if(c=!0,u.selection.setAll(!1,!1),!e.anyTrue)return void u.selection.fireChanged();for(let t=-1;-1!==(t=e.findNext(t,!0));){let e=r.get(t);void 0!=e&&u.selection.set(e,!0,!1)}u.selection.fireChanged()},100))),u}).call(this)}get positionColumns(){var e,t;if(this._positionColumns)return this._positionColumns;if(!this.dataFrame)return[];let n=_.i.getInstance(this.dataFrame),i=null==n?void 0:n.positionColumns;if(i&&i.length>0)return this._positionColumns=i,this._positionColumns;let r=this.dataFrame.col(this.sequenceColumnName),o=dh.Z.getSeqHelper().getSeqHandler(r),s=o.maxLength,a=[],l=null!=(e=r.temp[dv.j.notationProvider])?e:null,u=null!=(t=null==l?void 0:l.monomerCanonicalizerFuncName)?t:null;for(let e=0;e<s;e++){let t=o.getMonomersAtPosition(e,!1),n=g.Column.fromList("string",`Position ${e+1}`,t);u&&n.setTag(db.jz,u),a.push(n)}return this._positionColumns=a,this._positionColumns}get innerDf(){return this._innerDf?Promise.resolve(this._innerDf):(this._innerDf=this.calculateDf(),this._innerDf)}render(){return d_(function*(){let e=this.renderGeneration;if(y()(this.root).empty(),this.message="",this.cliffRows=0,this.renderedPosition=null,this._lineChart&&(this.renderState.remove(this._lineChart),this._lineChart=null),!this.dataFrame||!this.activityColumnName||!this.sequenceColumnName||!this.position){m.setUpdateIndicator(this.root,!1),this.showMessage("Please set Activity column, Sequence column and Position properties.");return}m.setUpdateIndicator(this.root,!0),this.root.style.display="flex",this.root.style.flexDirection="column";let t=yield this.innerDf;if(e!==this.renderGeneration)return;this.cliffRows=t.rowCount,this.renderedPosition=this.position,m.setUpdateIndicator(this.root,!1),0===t.rowCount?this.currentRowMutationsOnly?this.dataFrame.currentRowIdx>=0?this.showMessage("No mutations cliffs found for the current peptide at the selected position."):this.showMessage("Please select a row in the main table to see mutation cliffs for the corresponding peptide at the selected position."):this.showMessage("No mutation cliffs found for the selected position."):(this._lineChart=t.plot.line({xColumnName:`Position ${this.position}`,yColumnNames:[this.activityColumnName],splitColumnNames:this.seriesColumnName?[this.seriesColumnName]:[],legendVisibility:this.seriesColumnName?"Always":"Never",legendPosition:"Right",showXSelector:!1,showYSelector:!0,showSplitSelector:!1,packCategories:!1,xAxisLabelOrientation:"Auto",axisFont:'normal normal 14px "Roboto"',controlsFont:'normal normal 14px "Roboto"'}),this.renderState.add(this._lineChart),this._lineChart.sub(this._lineChart.onPropertyValueChanged.subscribe(e=>{var t,n,i,r,o,s,a,l;if((null==(n=this._lineChart)||null==(t=n.props)?void 0:t.yColumnNames)&&(null==(o=this._lineChart)||null==(r=o.props)||null==(i=r.yColumnNames)?void 0:i[0])!==this.activityColumnName){let e=null==(l=this._lineChart)||null==(a=l.props)||null==(s=a.yColumnNames)?void 0:s[0];this.renderState.defer("activity column",()=>this.getProperty("activityColumnName").set(this,e),1)}})),this.root.appendChild(this._lineChart.root));let n=Array(this.positionColumns.length+1-1).fill(0).map((e,t)=>t+1).map(e=>e.toString()),i=m.input.choice("Position",{value:this.position.toString(),items:n,nullable:!1,onValueChanged:e=>{if(!e)return;let t=parseInt(e);this.getProperty("position").set(this,t)}});if(i.input.style.width="40px",this.root.appendChild(m.divH([i.root],{style:{justifyContent:"center",marginTop:"4px",width:"100%",font:'normal normal 14px "Roboto"'}})),t.rowCount>0){let e=m.input.column("Series",{table:this.dataFrame,filter:e=>e.isCategorical&&e.name!==this.sequenceColumnName,tooltipText:"Select column for series splitting.",onValueChanged:e=>{let t=e?e.name:void 0;this.getProperty("seriesColumnName").set(this,t)},value:this.seriesColumnName?this.dataFrame.col(this.seriesColumnName):void 0});this.root.prepend(m.divH([e.root],{style:{justifyContent:"flex-end",paddingBottom:"4px",padding:"8px",width:"100%",font:'normal normal 14px "Roboto"'}}))}}).call(this)}showMessage(e){var t;let n;this.message=e,this.root.appendChild((t=e,(n=m.divText(t)).style.fontSize="14px",n.style.marginTop="10px",n.style.textAlign="center",n))}debouncedRender(){m.setUpdateIndicator(this.root,!0),this.renderState.defer("render",()=>this.render(),300)}clearCache(e=!0){this.renderGeneration++,this.renderState.cancel("chart selection"),this.renderState.cancel("table selection"),e&&(this._mutationCliffsData=null),this._innerDf=null,this._dfSubs.forEach(e=>e.unsubscribe()),this._dfSubs=[]}detach(){this.clearCache(),this.renderState.dispose(),this._lineChart=null,super.detach()}onPropertyChanged(e){if(super.onPropertyChanged(e),(null==e?void 0:e.name)==="activityColumnName"||(null==e?void 0:e.name)==="sequenceColumnName"||(null==e?void 0:e.name)==="position"||(null==e?void 0:e.name)==="seriesColumnName"){let t=(null==e?void 0:e.name)==="seriesColumnName"||(null==e?void 0:e.name)==="activityColumnName";this.clearCache(!t),(null==e?void 0:e.name)==="sequenceColumnName"&&(this._positionColumns=null),this.debouncedRender()}else(null==e?void 0:e.name)==="yAxisType"?this._lineChart&&(this._lineChart.props.yAxisType=this.yAxisType.toLowerCase()):(null==e?void 0:e.name)==="currentRowMutationsOnly"&&(this.clearCache(!1),this.debouncedRender())}constructor(){super(),this.position=1,this.currentRowMutationsOnly=!1,this.yAxisType="Linear",this.renderState=new da.Y,this.renderGeneration=0,this.message="",this.cliffRows=0,this.renderedPosition=null,this._mutationCliffsData=null,this._dfSubs=[],this._positionColumns=null,this._innerDf=null,this._lineChart=null,this.sequenceColumnName=this.column("sequence",{semType:g.SEMTYPE.MACROMOLECULE,nullable:!1}),this.seriesColumnName=this.column("series",{columnTypeFilter:"categorical",nullable:!1}),this.activityColumnName=this.column("activity",{columnTypeFilter:"numerical",nullable:!1}),this.position=this.int("position",1,{nullable:!1,showSlider:!1,min:1,max:100,showPlusMinus:!0,description:"Position in the sequence to analyze (1 Based).",category:"Data"}),this.yAxisType=this.string("yAxisType","Linear",{choices:["Linear","Logarithmic"],description:"Y-Axis scale type.",nullable:!1,category:"Data"}),this.currentRowMutationsOnly=this.bool("currentRowMutationsOnly",!1,{nullable:!1,defaultValue:!1,description:"When enabled, the viewer will show mutations related to the peptide in current row in the dataframe and selected position.",category:"Data"}),this.root.classList.add("peptides-viewer-show-title")}}var dS=n(4725);function dC(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function dA(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){dC(o,i,r,s,a,"next",e)}function a(e){dC(o,i,r,s,a,"throw",e)}s(void 0)})}}function dO(){return dA(function*(){yield dX.initPeptides()})()}function dE(){return dX.Peptides()}function dT(){return dA(function*(){return yield dX.peptidesDialog()})()}function dP(e){return dA(function*(){yield dX.testInitFunctionPeptides(e)})()}function dN(e){return dA(function*(){return yield dX.peptidesPanel(e)})()}function dI(){return dX.monomerPosition()}function dM(){return dX.mostPotentResidues()}function dL(){return dX.mutationCliffs()}function dR(){return dX.logoSummaryTable()}function dj(){return dX.sequencePositionStatistics()}function dD(){return dX.clusterMaxActivity()}function d$(){return dX.peptideGeneration()}function dF(e){return dX.manualAlignment(e)}function dz(){return dA(function*(){yield dX.macromoleculeSarFastaDemo()})()}function dq(){return dX.lstPiechartCellRenderer()}function dB(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function dG(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){dB(o,i,r,s,a,"next",e)}function a(e){dB(o,i,r,s,a,"throw",e)}s(void 0)})}}function dV(e,t,n,i){var r,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(o<3?r(s):o>3?r(t,n,s):r(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}function dU(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function dH(e,t){return function(n,i){t(n,i,e)}}let dW=new g.Package;function dY(){return a}function dK(e){return dG(function*(){let t=g.TaskBarProgressIndicator.create("Loading Peptides"),n=dW.webRoot+"files/"+e,i=yield f.data.loadTable(n);i.name="Peptides",f.shell.addTableView(i).name="PeptidesView",f.shell.windows.showContextPanel=!0,t.close()})()}f.decorators||(f.decorators={}),["func","init","param","panel","editor","demo","app","appTreeBrowser","fileHandler","fileExporter","model","viewer","filter","cellRenderer","autostart","dashboard","folderViewer","semTypeDetector","packageSettingsEditor","functionAnalysis","converter","fileViewer","model","treeBrowser","polyfill"].forEach(e=>{f.decorators[e]||(f.decorators[e]=function(e){return function(e,t,n){}})});class dX{static initPeptides(){return dG(function*(){try{var e;null!=a||(a=yield(e=function*(){let e="Dendrogram",t=g.Func.find({package:e,name:"getTreeHelper"});if(0===t.length)throw Error(`Package "${e}" must be installed for TreeHelper.`);return(yield t[0].prepare().call()).getOutputParamValue()},function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){k(o,i,r,s,a,"next",e)}function a(e){k(o,i,r,s,a,"throw",e)}s(void 0)})})()),yield dh.Z.loadComponents()}catch(e){f.log.error(e)}})()}static Peptides(){let e=g.View.create();e.name="Peptides";let t=lt.of(e).build(()=>new oO({icon:dW.getIconUrl(),learnMore:"https://github.com/datagrok-ai/help/blob/master/datagrok/solutions/domains/bio/peptides-sar.md",items:["Automatically recognizes peptides in your data","Invariant map and mutation cliffs","Logo plots to explore sequence composition","Hierarchical clustering","Sequence space to analyze clustering and activity cliffs","Finds statistically significant changes in activity for monomer/positions"]})).root,n=f.shell.windows;return n.showToolbox=!1,n.showHelp=!1,n.showContextPanel=!1,m.appendAll(e.root,[t,m.divH([m.button("Simple demo",()=>dK("aligned.csv"),""),m.button("Complex demo",()=>dK("aligned_2.csv"),""),m.button("HELM demo",()=>dK("aligned_3.csv"),"")])]),e}static peptidesDialog(){return dG(function*(){var e;if(!f.shell.t||!(null==(e=f.shell.t.columns.bySemType("Macromolecule"))?void 0:e.length))return f.shell.warning("SAR Analysis requires an active table with Macromolecule column"),null;if(!g.Utils.firstOrNull(f.shell.t.columns.numerical))return f.shell.warning("SAR Analysis requires an active table with at least one numerical column for activity"),null;let t=yield(0,v.v)(f.shell.t),n=m.dialog("Analyze Peptides").add(t.host).onOK(()=>dG(function*(){t.callback()||n.show()})());return n.show()})()}static testInitFunctionPeptides(e){return dG(function*(){f.shell.info("Test init function for Peptides package"),f.shell.info("Viewer name: "+e.dataFrame.name),yield new Promise(e=>setTimeout(e,1e3))})()}static peptidesPanel(e){return dG(function*(){if(!e.dataFrame||!g.Utils.firstOrNull(e.dataFrame.columns.numerical))return new g.Widget(m.divText("SAR Analysis requires an active table with at least one numerical column for activity"));let t=yield(0,v.v)(e.dataFrame,e);return new g.Widget(t.host)})()}static monomerPosition(){return new x.J}static mostPotentResidues(){return new x.UJ}static mutationCliffs(){return new dk}static logoSummaryTable(){return new S.sI}static sequencePositionStatistics(){return new dm}static clusterMaxActivity(){return new dd}static peptideGeneration(){return new dS.Y_}static manualAlignment(e){var t,n;let i,r,o,s,a,l=f.shell.t,u=null==l?void 0:l.temp[_.i.modelName];return u?(t=l.getCol(u.settings.sequenceColumnName),i=l.currentRowIdx,r=null==(n=l.currentCol)?void 0:n.name,o=m.input.textArea("Sequence",{value:t.get(i)}),y()(o.root).addClass("pep-textinput"),s=m.button("Apply",()=>{var e;return(e=function*(){s.disabled=!0;try{yield _.i.getInstance(l).updateSequence(i,o.value,r)}finally{s.disabled=!1}},function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){w(o,i,r,s,a,"next",e)}function a(e){w(o,i,r,s,a,"throw",e)}s(void 0)})})()},"Apply changes"),a=m.button(m.iconFA("redo"),()=>o.value=t.get(i),"Reset"),y()(a).addClass("pep-snippet-editor-icon pep-reset-icon"),new g.Widget(m.divV([a,o.root,s],"pep-textarea-box"))):new g.Widget(m.divText("Manual alignment works with peptides analysis"))}static macromoleculeSarFastaDemo(){return dG(function*(){var e;return yield(e=function*(){f.shell.windows.showContextPanel=!0;let e=g.DataFrame.fromCsv((yield dW.files.readAsText("aligned.csv")));e.name="Simple peptides",e.id||(e.id=`Simple-peptides-analysis-table-id-${Math.random()}-${Date.now()}`);let t=f.shell.addTableView(e).grid;yield new Promise(e=>{var n;let i=null,r=null==t||null==(n=t.onAfterDrawContent)?void 0:n.subscribe(()=>{i&&clearTimeout(i),r.unsubscribe(),e(void 0)});i=setTimeout(()=>{r.unsubscribe(),e(void 0)},3e3)});let n=e.getCol("IC50"),i=e.getCol("AlignedSequence");i.semType=g.SEMTYPE.MACROMOLECULE,i.setTag(C.gp.ALPHABET,O.YI.PT),i.meta.units=O.Hi.FASTA,i.setTag(O.gp.aligned,O.AO.SEQ_MSA);let r=(0,A.Y1)(n,C.rg.MINUS_LG),o=new E.av;o.threshold=94,yield(0,v.n)(n,i,null,e,r,C.rg.MINUS_LG,{addMCL:!0,useEmbeddingsClusters:!0,mclSettings:o})},function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){T(o,i,r,s,a,"next",e)}function a(e){T(o,i,r,s,a,"throw",e)}s(void 0)})})()})()}static lstPiechartCellRenderer(){return new dc.DX}}dV([f.decorators.init({tags:["init"]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",Promise)],dX,"initPeptides",null),dV([f.decorators.func(),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.View?Object:g.View)],dX,"Peptides",null),dV([f.decorators.func({"top-menu":"Bio | Analyze | SAR...",requiresSemType:"Macromolecule",name:"Bio Peptides",outputs:[]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",Promise)],dX,"peptidesDialog",null),dV([f.decorators.func(),dH(0,f.decorators.param({type:"viewer"})),dU("design:type",Function),dU("design:paramtypes",[void 0===g||void 0===g.Viewer?Object:g.Viewer]),dU("design:returntype",Promise)],dX,"testInitFunctionPeptides",null),dV([f.decorators.panel({name:"Peptides",meta:{role:"widgets"},tags:["widgets","panel"]}),dH(0,f.decorators.param({options:{semType:"Macromolecule"}})),dU("design:type",Function),dU("design:paramtypes",[void 0===g||void 0===g.Column?Object:g.Column]),dU("design:returntype",Promise)],dX,"peptidesPanel",null),dV([f.decorators.func({meta:{icon:"files/icons/peptide-sar-viewer.svg",role:"viewer"},name:"Sequence Variability Map",tags:["viewer"],description:"Peptides Sequence Variability Map Viewer",outputs:[{type:"viewer",name:"result"}]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.Viewer?Object:g.Viewer)],dX,"monomerPosition",null),dV([f.decorators.func({meta:{icon:"files/icons/peptide-sar-vertical-viewer.svg",role:"viewer"},name:"Most Potent Residues",tags:["viewer"],description:"Peptides Most Potent Residues Viewer",outputs:[{type:"viewer",name:"result"}]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.Viewer?Object:g.Viewer)],dX,"mostPotentResidues",null),dV([f.decorators.func({meta:{icon:"files/icons/sequence-statistics-viewer.svg",role:"viewer"},name:"Sequence Mutation Cliffs",description:"Mutation Cliffs Line Chart",tags:["viewer"],outputs:[{type:"viewer",name:"result"}]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.Viewer?Object:g.Viewer)],dX,"mutationCliffs",null),dV([f.decorators.func({meta:{icon:"files/icons/logo-summary-viewer.svg",role:"viewer"},name:"Logo Summary Table",tags:["viewer"],outputs:[{type:"viewer",name:"result"}]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.Viewer?Object:g.Viewer)],dX,"logoSummaryTable",null),dV([f.decorators.func({meta:{icon:"files/icons/sequence-statistics-viewer.svg",role:"viewer"},name:"Sequence Position Statistics",outputs:[{type:"viewer",name:"result"}],tags:["viewer"]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.Viewer?Object:g.Viewer)],dX,"sequencePositionStatistics",null),dV([f.decorators.func({name:"Active peptide selection",outputs:[{type:"viewer",name:"result"}],meta:{role:"viewer"},tags:["viewer"]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.Viewer?Object:g.Viewer)],dX,"clusterMaxActivity",null),dV([f.decorators.func({name:"Peptide Generation",description:"Generates new candidate peptides from monomer-position statistics, ranked by predicted activity",outputs:[{type:"viewer",name:"result"}],meta:{role:"viewer",icon:"files/icons/peptide-sar-vertical-viewer.svg"},tags:["viewer"]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.Viewer?Object:g.Viewer)],dX,"peptideGeneration",null),dV([f.decorators.panel({name:"Manual Alignment",meta:{role:"widgets"},tags:["widgets","panel"]}),dH(0,f.decorators.param({options:{semType:"Monomer"}})),dU("design:type",Function),dU("design:paramtypes",[String]),dU("design:returntype",void 0===g||void 0===g.Widget?Object:g.Widget)],dX,"manualAlignment",null),dV([f.decorators.func({meta:{demoPath:"Bioinformatics | Peptide SAR",isDemoDashboard:"true"},name:"Peptide SAR",description:"Peptide SAR Analysis demo on peptide sequences in FASTA format"}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",Promise)],dX,"macromoleculeSarFastaDemo",null),dV([f.decorators.func({meta:{cellType:"lst-pie-chart",gridChart:"true",role:"cellRenderer"},tags:["cellRenderer"],name:"LST Pie Chart",outputs:[{type:"grid_cell_renderer",name:"result"}]}),dU("design:type",Function),dU("design:paramtypes",[]),dU("design:returntype",void 0===g||void 0===g.GridCellRenderer?Object:g.GridCellRenderer)],dX,"lstPiechartCellRenderer",null)},5013(e,t,n){"use strict";n.d(t,{Z:()=>l});var i=n(7461),r=n(6082);function o(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function s(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function a(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function a(e){s(o,i,r,a,l,"next",e)}function l(e){s(o,i,r,a,l,"throw",e)}a(void 0)})}}class l{static getMonomerLib(){if(!this._monomerLibHelper)throw Error("MonomerLib is not initialized");return this._monomerLibHelper.getMonomerLib()}static getSeqHelper(){if(!this._secHelper)throw Error("SeqHelper is not initialized");return this._secHelper}static loadSeqHelper(){return a(function*(){var e;null!=this._secHelper||(this._secHelper=yield(e=function*(){let e=r.Func.find({package:"Bio",name:"getSeqHelper"});if(0===e.length)throw Error("Package 'Bio' must be installed for SeqHelper.");return(yield e[0].prepare().call()).getOutputParamValue()},function(){var t=this,n=arguments;return new Promise(function(i,r){var s=e.apply(t,n);function a(e){o(s,i,r,a,l,"next",e)}function l(e){o(s,i,r,a,l,"throw",e)}a(void 0)})})())}).call(this)}static loadComponents(){return a(function*(){yield this.loadSeqHelper(),yield this.loadMonomerLib()}).call(this)}static loadMonomerLib(){return a(function*(){null!=this._monomerLibHelper||(this._monomerLibHelper=yield(0,i.pj)()),yield this._monomerLibHelper.awaitLoaded()}).call(this)}}},5408(e,t,n){"use strict";n.d(t,{Ej:()=>c,Lw:()=>d,eW:()=>p,uz:()=>u});var i=n(3629),r=n(7153),o=n(3286),s=n(9222),a=n(7545);function l(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function u(e,t){var n;return(n=function*(e,t,n={}){if(0===t.length)throw Error(`PepAlgorithmError: Couldn't find any column of semType '${i.uF.MONOMER}'`);null!=n.minActivityDelta||(n.minActivityDelta=0),null!=n.maxMutations||(n.maxMutations=1);let o=new r.a,s=yield o.calc(e,t,n);return o.terminate(),s},function(){var e=this,t=arguments;return new Promise(function(i,r){var o=n.apply(e,t);function s(e){l(o,i,r,s,a,"next",e)}function a(e){l(o,i,r,s,a,"throw",e)}s(void 0)})}).apply(this,arguments)}function d(e,t){let n=new Map,i=999999,r=-999999,o=2,l=2;for(let u of e.keys()){let d=new Map;n.set(u,d);let c=e.get(u);for(let e of c.keys()){let n=c.get(e);if(0===n.size)continue;let u=new s.A(t.length,!1),h=new s.A(t.length,!1);for(let e of n.keys())u.setFast(e,!0),n.get(e).forEach(e=>u.setFast(e,!0)),h.setFast(e,!0);let p=(0,a.GT)(t,h,u);p.mask=u,i=Math.min(i,p.meanDifference),r=Math.max(r,p.meanDifference),o=Math.min(o,p.count),l=Math.max(l,p.count),d.set(e,p)}}return{stats:n,minDiff:i,maxDiff:r,minCount:o,maxCount:l}}function c(e,t,n,i={}){null!=i.isFiltered||(i.isFiltered=!1);let r={general:{}},o=e.getRawData(),l=e.length;null!=i.columns||(i.columns=n.map(e=>e.name));let u=i.isFiltered?(0,a.pY)(t):void 0;for(let e of n){if(!i.columns.includes(e.name))continue;let n=e.getRawData(),d=e.categories,c={general:{}};for(let e=0;e<d.length;++e){let r=d[e];if(""===r)continue;let p=Array(l).fill(!1);for(let r=0;r<l;++r)n[r]===e&&(!i.isFiltered||t.get(r))&&(p[r]=!0);let f=s.A.fromValues(p);if(f.allFalse)continue;let m=(0,a.GT)(o,f,u,i.aggValue);c[r]=m,h(c.general,m)}r[e.name]=c,h(r.general,null,c.general)}return r}function h(e,t=null,n=null){var i,r,o,s,a,l,u,d,c;if(null===t&&null===n)throw Error("MonomerPositionStatsError: either stats or summaryStats must be present");let p=null!=(i=null==t?void 0:t.count)?i:n.maxCount;null!=e.maxCount||(e.maxCount=p),e.maxCount<p&&(e.maxCount=p);let f=null!=(r=null==t?void 0:t.count)?r:n.minCount;null!=e.minCount||(e.minCount=f),e.minCount>f&&(e.minCount=f);let m=null!=(o=null==t?void 0:t.meanDifference)?o:n.maxMeanDifference;null!=e.maxMeanDifference||(e.maxMeanDifference=m),e.maxMeanDifference<m&&(e.maxMeanDifference=m);let g=null!=(s=null==t?void 0:t.meanDifference)?s:n.minMeanDifference;if(null!=e.minMeanDifference||(e.minMeanDifference=g),e.minMeanDifference>g&&(e.minMeanDifference=g),!isNaN(null!=(a=null==t?void 0:t.pValue)?a:NaN)){let i=null!=(d=null==t?void 0:t.pValue)?d:n.maxPValue;null!=e.maxPValue||(e.maxPValue=i),e.maxPValue<i&&(e.maxPValue=i);let r=null!=(c=null==t?void 0:t.pValue)?c:n.minPValue;null!=e.minPValue||(e.minPValue=r),e.minPValue>r&&(e.minPValue=r)}let v=null!=(l=null==t?void 0:t.ratio)?l:n.maxRatio;null!=e.maxRatio||(e.maxRatio=v),e.maxRatio<v&&(e.maxRatio=v);let b=null!=(u=null==t?void 0:t.ratio)?u:n.minRatio;null!=e.minRatio||(e.minRatio=b),e.minRatio>b&&(e.minRatio=b)}function p(e,t,n,i){let r=e.rowCount,l=e.getCol(t),u=l.getRawData(),d=l.categories,c=Array.from({length:d.length},()=>new s.A(r,!1));for(let e=0;e<r;++e)c[u[e]].setTrue(e);let h=n.map(e=>s.A.fromUint32Array(r,e.getRawData())),p=n.map(e=>e.name),f=i.getRawData(),m={},g={},v=e.filter.anyFalse?(0,a.pY)(e.filter):void 0;for(let e of Object.values(o.WR)){let t=e===o.WR.ORIGINAL?c:h,n=e===o.WR.ORIGINAL?d:p,r=e===o.WR.ORIGINAL?m:g;for(let e=0;e<t.length;++e){let o=t[e];r[n[e]]=o.allTrue||o.allFalse?{count:o.length,meanDifference:0,ratio:1,pValue:null,mask:o,mean:i.stats.avg}:(0,a.GT)(f,o,v)}}let b={};return b[o.WR.ORIGINAL]=m,b[o.WR.CUSTOM]=g,b}},8154(e,t,n){"use strict";n.d(t,{DX:()=>C,X5:()=>y,rW:()=>x,k8:()=>k,Yd:()=>w,rI:()=>_,FZ:()=>S});var i,r,o,s,a,l=n(7389),u=n(6082),d=n(3629),c=n(8621),h=n(5408),p=n(1858),f=n(586),m=n(3286),g=n(2747);n(1004),(i=o||(o={})).maxMonomerLength=".mm.cellRenderer.maxMonomerLength",i.showConnections=".mm.cellRenderer.showConnections",(s||(s={})).applyToBackground=".m.cellRenderer.applyToBackground",(r=a||(a={})).MSA="MSA",r.classic="classic",new class{constructor(){this.color="rgb(100,100,100)",this.pivot=0,this.left=!1,this.transparencyRate=0,this.separator="",this.last=!1,this.drawStyle=a.classic,this.maxWord=[],this.wordIdx=0,this.gridCell=null,this.referenceSequence=null,this.maxLengthOfMonomer=null,this.monomerTextSizeMap={},this.logger=void 0,this.selectedPosition=void 0,this.isMultiLineContext=!1,this.lineNumber=0,this.columnTemps=void 0}};var v=n(5013),b=n(8509);function y(e,t){e.strokeStyle=u.Color.toHtml(u.Color.selectedRows),e.lineWidth=3,e.strokeRect(t.x+1,t.y+1,t.width-1,t.height-1)}function _(e,t,n){e.semType=d.uF.MONOMER,e.setTag(u.TAGS.CELL_RENDERER,d.uF.MONOMER),e.setTag(d.gp.ALPHABET,t),n&&e.setTag(s.applyToBackground,"true")}function w(e,t,n,i,r){var o,s,a,l,d,c,h,p,f,m;let v=r.width/2,b=Math.ceil(r.x+1+v),_=Math.ceil(r.y+1+r.height/2),w=Math.min(.9*v/2,.9*r.height/2);if(i instanceof g.UJ){let r=i.monomerPositionStats[n],o=r[t].pValue,s=r[t].meanDifference,a=1-r.general.maxPValue,l=1-r.general.minPValue,d=Math.min(a,l),c=Math.max(a-d,l-d),h=null===o?0:1-o-d,p=u.Color.toHtml(null===o?u.Color.lightLightGray:u.Color.scaleColor(s>=0?h:-h,-c,c,255)),f=Math.floor(w*(Math.abs(s)/Math.max(Math.abs(i.monomerPositionStats.general.minMeanDifference),i.monomerPositionStats.general.maxMeanDifference)));e.beginPath(),e.fillStyle=p,e.arc(b-v/2,_,f<3||null===o?3:f,0,2*Math.PI,!0),e.closePath(),e.fill()}else if(i instanceof g.J&&i.mutationCliffs&&i.cliffStats){let r=i.cliffStats.maxCount,l=i.cliffStats.minDiff,d=i.cliffStats.maxDiff,c=null==(a=i.cliffStats)||null==(s=a.stats)||null==(o=s.get(t))?void 0:o.get(n);if(c){let t=c.count,n=c.meanDifference,i=Math.floor(Math.abs(t/Math.max(r,2))*w),o=Math.max(Math.abs(l),Math.abs(d)),s=u.Color.toHtml(null===n?u.Color.lightLightGray:u.Color.scaleColor(n,-o,o,255));e.beginPath(),e.fillStyle=s,e.arc(b-v/2,_,i<3||0==t?3:i,0,2*Math.PI,!0),e.closePath(),e.fill()}}if(e.textBaseline="middle",e.textAlign="end",e.fillStyle="#606060",e.font="13px Roboto, Roboto Local, sans-serif",e.shadowBlur=5,e.shadowColor=u.Color.toHtml(u.Color.white),i instanceof g.J){let r=0,o=null!=(l=null==(h=i.mutationCliffs)||null==(c=h.get(t))||null==(d=c.get(n))?void 0:d.entries())?l:null;if(null!==o)for(let[e,t]of o)r+=null!=(p=t.length)?p:0;0!==r&&e.fillText(r.toString(),b+v-5,_,v-5)}else if(i instanceof g.UJ){let r=i.monomerPositionStats,o=null==r||null==(m=r[n])||null==(f=m[t])?void 0:f.count;o&&e.fillText(o.toString(),b+v-5,_,v-5)}if(i instanceof g.J){let o=i.mutationCliffsSelection[n];o&&o.includes(t)&&y(e,r)}else if(i instanceof g.UJ){let o=i.invariantMapSelection[n];o&&o.includes(t)&&y(e,r)}}function x(e,t,n,i,r,o,s){s=u.Color.fromHtml(u.Color.toHtml((0xffffff&s|-0x1000000)>>>0));let a=r.toFixed(2);a.endsWith(".00")&&(a=r.toFixed(0)),a.endsWith("0")&&a.includes(".")&&(a=r.toFixed(1));let l=Math.min(13,Math.floor(o.width/40/a.length*78));e.fillStyle=u.Color.toHtml(s),e.fillRect(o.x,o.y,o.width,o.height),e.font=`${l}px Roboto, Roboto Local, sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillStyle=u.Color.toHtml(u.Color.getContrastColor(s)),e.fillText(a,o.x+o.width/2,o.y+o.height/2,o.width);let d=i[n];d&&d.includes(t)&&y(e,o)}function k(e,t,n,i){e.font="13px Roboto, Roboto Local, sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillStyle="#000",e.fillText(t.toString(),i.x+i.width/2,i.y+i.height/2,i.width),(n[m.WR.CUSTOM].includes(t)||n[m.WR.ORIGINAL].includes(t))&&y(e,i)}function S(e,t,n,i,r,o={x:0,y:0,mpStats:{},monomerPosition:{}}){if(null!=r.isSelectionTable||(r.isSelectionTable=!1),0==Object.keys(o.mpStats).length&&(o.mpStats=t()),r.isSelectionTable&&(!r.webLogoBounds||!r.cachedWebLogoTooltip))throw Error("Peptides: Cannot set WebLogo renderer for selection table without `headerSelectedMonomers`, `webLogoBounds` and `cachedWebLogoTooltip` options.");let s=e.dataFrame;e.setOptions({colHeaderHeight:130}),e.onCellRender.subscribe(e=>(e=>{var o,a;if(!(null==(o=e.cell)?void 0:o.isColHeader))return;let l=e.g,p=e.bounds,f=e.cell.tableColumn;l.save();try{if(l.beginPath(),l.clearRect(p.x,p.y,p.width,p.height),l.rect(p.x,p.y,p.width,p.height),l.clip(),(null==f?void 0:f.semType)===d.uF.MONOMER){let o;if(s.filter.anyFalse){null!=s.jsOnlyTemp||(s.jsOnlyTemp={});let e=null!=(a=s.jsOnlyTemp[d.gp.M_P_STATS_CACHE])?a:{},t=null==e?void 0:e[f.name];if(e&&t&&t.filterLength===s.filter.length&&t.filterVersion===s.filter.version)o=t.stats[f.name];else{let t=(0,h.Ej)(i,s.filter,n,{isFiltered:!0,columns:[f.name]});o=t[f.name],e[f.name]={filterVersion:s.filter.version,stats:t,filterLength:s.selection.length}}s.jsOnlyTemp[d.gp.M_P_STATS_CACHE]=e}else o=r.isSelectionTable?(0,h.Ej)(i,s.filter,n,{isFiltered:!0,columns:[f.name]})[f.name]:t()[f.name];if(!o)return;let m=Object.keys(o).sort((e,t)=>""===e||"-"===e?1:""===t||"-"===t?-1:0).filter(e=>"general"!==e);r.webLogoBounds()[f.name]=function(e,t,n,i,r,o,s,a={},l={}){var d;let h=window.devicePixelRatio;null!=l.symbolStyle||(l.symbolStyle="16px Roboto, Roboto Local, sans-serif"),null!=l.upperLetterHeight||(l.upperLetterHeight=12.2),null!=l.upperLetterAscent||(l.upperLetterAscent=.25),null!=l.marginVertical||(l.marginVertical=1),null!=l.marginHorizontal||(l.marginHorizontal=1),null!=l.selectionWidth||(l.selectionWidth=2),null!=l.textHeight||(l.textHeight=13),null!=l.headerStyle||(l.headerStyle=`bold ${l.textHeight*h}px Roboto, Roboto Local, sans-serif`);let p=(r.length-1)*l.upperLetterAscent,f=(t.y+l.marginVertical)*h,m=(t.height-2*l.marginVertical-p-1.25*l.textHeight)*h,g=(t.x+l.marginHorizontal)*h,y=Math.max(l.selectionWidth*h,.05*t.width*h),_=2*l.marginHorizontal+l.selectionWidth,w=(t.width-(_+l.marginHorizontal))*h,x=(t.x+_)*h,k=v.Z.getMonomerLib(),S={};for(let t of r){let i=m*(n[t].count/o),r=m*((null!=(d=a[t])?d:0)/o);if(S[t]=new u.Rect(x/h,f/h,w/h,i/h),e.resetTransform(),"-"!==t&&""!==t){let n=(0,c.zS)(t,5),o=e.measureText(n);r>0&&(e.lineWidth=y,e.line(g,f,g,f+r,u.Color.rowSelection)),e.fillStyle=k.getMonomerTextColor(b.oE.AA,t),e.textAlign="left",e.textBaseline="top",e.font=l.symbolStyle;let s=w/o.width,a=i/l.upperLetterHeight;e.setTransform(s,0,0,a,x,f),e.fillText(n,0,0,o.width)}f+=i+l.upperLetterAscent*h}return e.resetTransform(),e.fillStyle=u.Color.toHtml(u.Color.black),e.textAlign="center",e.textBaseline="top",e.font=l.headerStyle,e.fillText(i,(t.x+t.width/2)*h,(t.y+t.height-l.textHeight)*h),S}(l,p,o,f.name,m,s.filter.trueCount,r.colorPalette(),r.headerSelectedMonomers?r.headerSelectedMonomers()[f.name]:{}),e.preventDefault()}}catch(e){console.warn(`PeptidesHeaderLogoError: couldn't render WebLogo for column \`${f.name}\`. See original error below.`),console.warn(e)}finally{l.restore()}})(e));let a=n=>{var a;let u=e.hitTest(n.offsetX,n.offsetY);if((null==u?void 0:u.isColHeader)&&(null==(a=u.tableColumn)?void 0:a.semType)===d.uF.MONOMER){let e=function(e,t,n){let i=n[e.tableColumn.name];if(!i)return null;for(let[n,r]of Object.entries(i)){let i=t.offsetX>=r.x&&t.offsetX<=r.x+r.width,o=t.offsetY>=r.y&&t.offsetY<=r.y+r.height;if(i&&o)return{monomerOrCluster:n,positionOrClusterType:e.tableColumn.name}}return null}(u,n,r.webLogoBounds());if(null===e){r.isSelectionTable||null==r.unhighlightCallback||r.unhighlightCallback();return}o.monomerPosition=e,o.mpStats=t();let a=s.filter.anyFalse?s.clone(s.filter):s,d=a.getCol(i.name);(function(e,t,n,i,r,o){if("click"!==e.type||r.isSelectionTable||null==r.selectionCallback){let s=`${t.positionOrClusterType} = ${t.monomerOrCluster}`;r.cachedWebLogoTooltip().bar===s?l.tooltip.show(r.cachedWebLogoTooltip().tooltip,e.clientX,e.clientY):(r.cachedWebLogoTooltip().bar=s,o.x=e.clientX,o.y=e.clientY,o.monomerPosition=t,r.cachedWebLogoTooltip().tooltip=(0,f.Y)(n,i,[],o))}else r.selectionCallback(t,{shiftPressed:e.shiftKey,ctrlPressed:e.ctrlKey||e.metaKey})})(n,e,a,d,r,o),r.isSelectionTable||null==r.highlightCallback||r.highlightCallback(e,s,t())}else null!=r.unhighlightCallback&&r.unhighlightCallback()};p.fromEvent(e.overlay,"mousemove").subscribe(e=>a(e)),p.fromEvent(e.overlay,"click").subscribe(e=>a(e)),p.fromEvent(e.overlay,"mouseleave").subscribe(()=>{null!=r.unhighlightCallback&&r.unhighlightCallback()})}class C extends u.GridCellRenderer{get name(){return"LST Pie Chart"}get cellType(){return"lst-pie-chart"}get defaultWidth(){return 80}get defaultHeight(){return 80}categoryNumberCache(e){return e.temp[this.colorCacheKey]||(e.temp[this.colorCacheKey]={}),e.temp[this.colorCacheKey]}getPrevHoveredSector(e){return e.temp[this.HoverTempKey]}onMouseMove(e,t){let n,i=this.getPrevHoveredSector(e.cell.column),r=()=>{e.cell.column.temp[this.HoverTempKey]=null,l.tooltip.hide(),null!==i&&e.grid.invalidate()},o=e.cell.value;if(!o)return void r();let s=t.offsetX-e.bounds.midX,a=t.offsetY-e.bounds.midY,u=Math.sqrt(s*s+a*a),d=Math.atan2(a,s),c=d<0?d+2*Math.PI:d;if(u>Math.min(e.bounds.width,e.bounds.height)/2-2)return void r();try{n=JSON.parse(o)}catch(e){r();return}let h=new Float64Array(Object.keys(n).length+1),p=Object.values(n).reduce((e,t)=>e+t,0);h[Object.keys(n).length]=2*Math.PI;let f=0,m=0;for(let e of Object.values(n))h[m++]=f,f+=2*Math.PI*e/p;let g=-1;for(let e=0;e<h.length-1;e++)if(c>=h[e]&&c<h[e+1]){g=e;break}if(-1===g)return void r();let v=Object.keys(n)[g],b=n[v],y=(b/p*100).toFixed(2);l.tooltip.show(l.h1(`${v}: ${b} (${y}%)`),t.x+16,t.y+16);let _=e.cell.rowIndex.toString()+this.hoverSeparator+v;e.cell.column.temp[this.HoverTempKey]=_,i!==_&&e.grid.invalidate()}render(e,t,n,i,r,o,s){let a,l=o.cell.dataFrame,d=new u.Rect(t,n,i,r).fitSquare().inflate(-2,-2);if(i<5||r<5||!l)return;let c=o.cell.value;if(e.clearRect(t,n,i,r),!c)return;try{a=JSON.parse(c)}catch(e){return}let h=Object.values(a).reduce((e,t)=>e+t,0),p=0,f=Object.fromEntries(Object.keys(a).map(e=>[e,255])),m=o.cell.column.temp[this.HoverTempKey];if(m&&2===m.split(this.hoverSeparator).length){let[e,t]=m.split(this.hoverSeparator);if(e===o.cell.rowIndex.toString()){for(let[e,t]of Object.entries(a))f[e]=100;f[t]=255}}let g=Math.min(i,r)/2.2;for(let[t,n]of Object.entries(a)){let i=2*Math.PI*n/h;e.beginPath(),e.moveTo(d.midX,d.midY),e.arc(d.midX,d.midY,g,p,p+i),p+=i;let r=this.categoryNumberCache(o.cell.column);r[t]||(r[t]=Object.keys(r).length,o.cell.column.temp[this.colorCacheKey]=r),e.fillStyle=u.Color.toHtml(u.Color.setAlpha(u.Color.getCategoricalColor(r[t]),f[t])),e.fill(),e.strokeStyle=u.Color.toRgb(u.Color.lightGray),e.stroke(),e.fillStyle=u.Color.toRgb(u.Color.white),e.font="9px Arial";let s=e.measureText(t).width,a=p-i/2;for(let n=.8;n>=.4;n-=.05){let r=g*n,o=d.midX+Math.cos(a)*r,l=d.midY+Math.sin(a)*r;if([[o-s/2-2,l],[o+s/2+2,l]].every(e=>{let t=Math.sqrt(Math.pow(e[0]-d.midX,2)+Math.pow(e[1]-d.midY,2)),n=Math.atan2(e[1]-d.midY,e[0]-d.midX),r=n<0?n+2*Math.PI:n;return t<g-2&&r>p-i&&r<p})){e.fillText(t,o,l);break}}}}constructor(...e){super(...e),this.colorCacheKey="lst-pie-chart-color-cache",this.HoverTempKey="lst-pie-chart-hovered-sector",this.hoverSeparator=",,,,,"}}},3629(e,t,n){"use strict";n.d(t,{$2:()=>h,To:()=>g,V5:()=>y,gp:()=>f,i6:()=>p,qS:()=>c,rg:()=>v,uF:()=>m,wf:()=>b,zW:()=>_});var i,r,o,s,a,l,u,d=n(6082),c=((i={}).SEQUENCE_VARIABILITY_MAP="Sequence Variability Map",i.MOST_POTENT_RESIDUES="Most Potent Residues",i.LOGO_SUMMARY_TABLE="Logo Summary Table",i.DENDROGRAM="Dendrogram",i.CLUSTER_MAX_ACTIVITY="Active peptide selection",i.MCL="MCL",i.SEQUENCE_MUTATION_CLIFFS="Sequence Mutation Cliffs",i),h=((r={}).SPLIT_COL="~split",r.ACTIVITY="Activity",r.ACTIVITY_SCALED="Scaled activity",r.MONOMER="AAR",r.POSITION="Pos",r.P_VALUE="pValue",r.MEAN_DIFFERENCE="Mean difference",r.COUNT="Count",r.RATIO="Ratio",r.MEAN="Mean",r.TOTAL_COUNT="∑",r),p=((o={}).MEMBERS="Members",o.WEB_LOGO="WebLogo",o.DISTRIBUTION="Distribution",o.MEAN_DIFFERENCE="Mean difference",o.P_VALUE="P-Value",o.RATIO="Ratio",o.CLUSTER="Cluster",o),f=((s={}).MONOMER="monomer",s.POSITION="pos",s.SEPARATOR="separator",s.ALPHABET="alphabet",s.FILTER="filter",s.SAR_MODE="sarMode",s.VISIBLE="visible",s.SETTINGS="settings",s.CUSTOM_CLUSTER="customCluster",s.MONOMER_POSITION_MODE="monomerPositionMode",s.MULTIPLE_VIEWS="isMultipleViews",s.IDENTITY_TEMPLATE="Identity template",s.SIMILARITY_TEMPLATE="Similarity template",s.ANALYSIS_COL="isAnalysisCol",s.POSITION_COL="isPositionCol",s.M_P_STATS_CACHE=".MPStatsCache",s.INVARIANT_MAP_COLOR_CACHE=".InvariantMapColorCache",s.INVARIANT_MAP_COLOR_MAX_CACHE=".InvariantMapColorMaxCache",s.INVARIANT_MAP_COLOR_MIN_CACHE=".InvariantMapColorMinCache",s),m=((a={}).MONOMER="Monomer",a.MACROMOLECULE_DIFFERENCE="MacromoleculeDifference",a);let g="ColumnName";var v=((l={}).NONE="none",l.LG="lg",l.MINUS_LG="-lg",l),b=((u={}).HIGH="High",u.LOW="Low",u);let y=Object.values(d.AGG).filter(e=>![d.AGG.FIRST,d.AGG.KEY,d.AGG.PIVOT,d.AGG.SELECTED_ROWS_COUNT].includes(e)),_={[d.AGG.TOTAL_COUNT]:"totalCount",[d.AGG.VALUE_COUNT]:"valueCount",[d.AGG.UNIQUE_COUNT]:"uniqueCount",[d.AGG.MISSING_VALUE_COUNT]:"missingValueCount",[d.AGG.MIN]:"min",[d.AGG.MAX]:"max",[d.AGG.SUM]:"sum",[d.AGG.MED]:"med",[d.AGG.AVG]:"avg",[d.AGG.STDEV]:"stdev",[d.AGG.VARIANCE]:"variance",[d.AGG.SKEW]:"skew",[d.AGG.KURT]:"kurt",[d.AGG.Q1]:"q1",[d.AGG.Q2]:"q2",[d.AGG.Q3]:"q3"}},8750(e,t,n){"use strict";n.d(t,{$s:()=>O,AN:()=>g,AY:()=>h,B2:()=>T,BE:()=>w,BX:()=>I,CD:()=>k,F2:()=>v,FZ:()=>b,Lv:()=>N,Y1:()=>p,Z7:()=>y,ZR:()=>A,dl:()=>C,eY:()=>m,qx:()=>f,sg:()=>P,vW:()=>S,vY:()=>x,zm:()=>E,zz:()=>_});var i,r=n(7389),o=n(6082),s=n(4328),a=n(3629),l=n(9222),u=n(1991),d=n.n(u);function c(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function h(e){var t;return null!=(t=e.getTag(a.gp.SEPARATOR))?t:""}function p(e,t=a.rg.NONE){let n=e=>e;switch(t){case a.rg.NONE:break;case a.rg.LG:n=e=>Math.log10(e);break;case a.rg.MINUS_LG:n=e=>-Math.log10(e);break;default:throw Error(`ScalingError: method \`${t}\` is not available.`)}let i=e.getRawData(),r=o.Column.float(a.$2.ACTIVITY,e.length).init(e=>{let t=i[e];return t===o.FLOAT_NULL||t===o.INT_NULL?t:n(t)});return r.setTag(a.gp.ANALYSIS_COL,"true"),r.setTag(o.TAGS.FORMULA,t),r}function f(e){let t=e.columns.bySemTypeAll(a.uF.MONOMER),n={};for(let o of e.filter.clone().and(e.selection).getSelectedIndexes())for(let e of t){var i,r;let t=e.get(o);t&&(null!=n[i=e.name]||(n[i]={}),null!=(r=n[e.name])[t]||(r[t]=0),n[e.name][t]+=1)}return n}function m(e){return{name:e.name,cat:e.categories,rawData:e.getRawData()}}var g=((i={}).SELECTION="Selection",i.ALL="All",i.PEPTIDES_SELECTION="Peptides selection",i);function v(e,t,n={}){let i=e.dataFrame.getCol(a.$2.SPLIT_COL),s=[],l=i.categories;for(let e=0;e<l.length;++e){var u;if(!l[e])continue;let t=o.Color.toHtml(o.Color.categoricalPalette[e%o.Color.categoricalPalette.length]),i=r.label(null!=(u=n[l[e]])?u:l[e],{style:{color:t}});s.push(i)}let d=r.divV([r.divV(s),e.root,r.tableFromMap(t)]);return e.root.style.maxHeight="75px",d}function b(e,t,n){let i=n.filter,r=t.clone().and(i),s=e.length,l=e.getRawData(),u=i.trueCount,d=new Float32Array(u+r.trueCount),c=Array(d.length);for(let e=0,t=0,n=0;e<s;++e){if(!i.get(e))continue;let o=r.get(e);d[t]=l[e],c[t]=o?"Selection":"All",t++,o&&(d[u+n]=l[e],c[u+n]="All",++n)}let h=o.Column.fromStrings(a.$2.SPLIT_COL,c);return h.setCategoryOrder(["All","Selection"]),h.meta.colors.setCategorical(),o.DataFrame.fromColumns([o.Column.fromFloat32Array(a.$2.ACTIVITY,d),h])}function y(e,t,n){e.dataFrame||o.DataFrame.fromColumns([e]);let i=e.dataFrame.filter,r=e.getRawData(),s=Array.from(new Set(t.keys())).map(e=>Number(e)).filter(e=>i.get(e)),l=new Set;for(let e of t.values())for(let t of e)l.add(t);let u=Array.from(l).filter(e=>i.get(e)),d=s.length+u.length,c=Array(d),h=new Float32Array(d);for(let e=0;e<s.length;++e){let t=s[e];h[e]=r[t],c[e]=n}for(let e=0;e<u.length;++e){let t=u[e];h[s.length+e]=r[t],c[s.length+e]="Mutated"}let p=o.Column.fromStrings(a.$2.SPLIT_COL,c),f=[n,"Mutated"];return p.setCategoryOrder(f),p.meta.colors.setCategorical(),o.DataFrame.fromColumns([o.Column.fromFloat32Array(a.$2.ACTIVITY,h),p])}function _(e){let t=r.iconFA("expand-alt",()=>{let t=e.dataFrame.plot.grid();x(t,!1),t.root.style.height="100%";let n=r.dialog(e.dataFrame.name);n.add(t.root),n.showModal(!0),t.invalidate()},"Full screen");e.root.appendChild(t),t.style.position="absolute",t.style.right="0px",t.style.top="0px",t.style.visibility="hidden",e.root.addEventListener("mouseenter",e=>{t.style.visibility="visible"}),e.root.addEventListener("mouseleave",e=>{t.style.visibility="hidden"})}function w(e,t,n,i){let o=r.iconFA("expand-alt",()=>{let t=i(),n=r.dialog(e);n.add(t),n.show({resizable:!0,modal:!0,width:window.innerWidth-60,x:30,y:30,height:window.innerHeight-60})},"Expand to full screen");o.style.marginLeft="auto",o.style.marginRight="15px",n.addEventListener("mouseenter",()=>{o.style.visibility="visible"}),n.addEventListener("mouseleave",()=>{o.style.visibility="hidden"}),t.appendChild(o)}function x(e,t=!0){e.props.allowEdit=!1,e.props.showReadOnlyNotifications=!1,e.props.allowRowSelection=!1,e.props.allowBlockSelection=!1,e.props.allowColSelection=!1,e.props.showRowHeader=!1,e.props.showCurrentRowIndicator=!1,e.root.style.width="100%",e.root.style.maxWidth="100%",t&&e.autoSize(1e3,175,0,0,!0)}function k(e){for(let t of Object.values(e))if(0!==t.length)return!1;return!0}function S(e,t,n){let i=e[t.positionOrClusterType],r=i.indexOf(t.monomerOrCluster);if(n.shiftPressed&&n.ctrlPressed)-1!==r&&i.splice(r,1);else if(n.ctrlPressed)-1===r?i.push(t.monomerOrCluster):i.splice(r,1);else if(n.shiftPressed)-1===r&&i.push(t.monomerOrCluster);else{let n=Object.keys(e);for(let i of(e={},n))e[i]=[],i===t.positionOrClusterType&&e[i].push(t.monomerOrCluster)}return e}function C(e,t,n){if(!t)return 0;let i=new l.A(t.rowCount);if(e.positionOrClusterType===a.$2.MONOMER)for(let t of Object.values(n)){let n=t[e.monomerOrCluster];void 0!==n&&i.or(n.mask)}else{let t=n[e.positionOrClusterType];if(void 0!==t){let n=t[e.monomerOrCluster];void 0!==n&&i.or(n.mask)}}return t.rows.highlight(e=>i.getBit(e)),i.trueCount()}function A(e){let t={};for(let n of e)t[n.name]=[];return t}function O(e,t){return e.sequenceColumnName===t.sequenceColumnName&&e.activityColumnName===t.activityColumnName&&e.activityScaling===t.activityScaling}function E(e,t,n,i){let r=Object.entries(n),o=i?Object.entries(i).filter(e=>!t.includes(e[0])||n[e[0]]!==e[1]):[];return r.concat(o).filter(t=>e.columns.contains(t[0])&&e.col(t[0]).matches("numerical"))}function T(e,t=2){return e.columns.bySemTypeAll(o.SEMTYPE.MACROMOLECULE).length>0&&d()(e.columns.numerical).toArray().length>0&&e.rowCount>=t}function P(e,t=500){let n;return(...i)=>{var r;return(r=function*(){return new Promise(r=>{clearTimeout(n),n=setTimeout(()=>r(e(...i)),t)})},function(){var e=this,t=arguments;return new Promise(function(n,i){var o=r.apply(e,t);function s(e){c(o,n,i,s,a,"next",e)}function a(e){c(o,n,i,s,a,"throw",e)}s(void 0)})})()}}function N(){return"isInDemo"in s.shell&&!!s.shell.isInDemo}function I(e){return{set:function(t,n){return e[t]=n,this}}}},7153(e,t,n){"use strict";function i(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}n.d(t,{a:()=>r});class r{calc(e,t){var n;return(n=function*(e,t,n={}){let i=new Map;try{let r=e.length,o=Array(this._workerCount),s=r*(r-1)/2;this._workerCount=Math.min(this._workerCount,s);let a=s/this._workerCount;t.forEach(e=>{var t;e.cat=null==(t=e.cat)?void 0:t.slice()});for(let i=0;i<this._workerCount;i++)o[i]=new Promise((r,o)=>{let l=Math.floor(i*a),u=i===this._workerCount-1?s:Math.floor((i+1)*a);this._workers[i].postMessage({startIdx:l,endIdx:u,activityArray:e,monomerInfoArray:t,settings:n}),this._workers[i].onmessage=({data:{pos:e,seq1Idxs:t,seq2Idxs:n,error:s}})=>{if(s){var a;null==(a=this._workers[i])||a.terminate(),o(s)}else this._workers[i].terminate(),r({pos:e,seq1Idxs:t,seq2Idxs:n})}});let l=yield Promise.all(o),u=new Map;t.forEach((e,t)=>{u.set(e.name,t)}),l.filter(Boolean).forEach(e=>{for(let n=0;n<e.pos.length;n++){let r=u.get(e.pos[n]),o=t[r].rawData[e.seq1Idxs[n]],s=t[r].cat[o],a=t[r].rawData[e.seq2Idxs[n]],l=t[r].cat[a];i.has(s)||i.set(s,new Map),i.has(l)||i.set(l,new Map);let d=i.get(s),c=i.get(l);d.has(e.pos[n])||d.set(e.pos[n],new Map),c.has(e.pos[n])||c.set(e.pos[n],new Map);let h=d.get(e.pos[n]),p=c.get(e.pos[n]);h.has(e.seq1Idxs[n])||h.set(e.seq1Idxs[n],[]),p.has(e.seq2Idxs[n])||p.set(e.seq2Idxs[n],[]);let f=h.get(e.seq1Idxs[n]),m=p.get(e.seq2Idxs[n]);f.push(e.seq2Idxs[n]),m.push(e.seq1Idxs[n])}})}catch(e){this.terminate(),console.error(e)}return i},function(){var e=this,t=arguments;return new Promise(function(r,o){var s=n.apply(e,t);function a(e){i(s,r,o,a,l,"next",e)}function l(e){i(s,r,o,a,l,"throw",e)}a(void 0)})}).apply(this,arguments)}terminate(){var e;null==(e=this._workers)||e.forEach(e=>{try{null==e||e.terminate()}catch(e){console.error(e)}})}constructor(){const e=navigator.hardwareConcurrency;this._workerCount=Math.max(e-2,1),this._workers=Array(this._workerCount).fill(null).map(()=>new Worker(new URL(n.p+n.u("806"),n.b)))}}},7545(e,t,n){"use strict";n.d(t,{I_:()=>c,J1:()=>p,hX:()=>a,pY:()=>l,m2:()=>h,GT:()=>u,lh:()=>d});var i=n(6082),r=n(8353),o=n(9222),s=n(3629);let a=(e,t)=>`${e}(${t})`;function l(e){return o.A.fromUint32Array(e.length,new Uint32Array(e.getBuffer().buffer))}function u(e,t,n,o){let s;if(e.length<t.length||n&&e.length<n.length)throw Error("PeptidesError: Data and bit array have different lengths");n&&n.allTrue&&(n=void 0);let a=n?t.clone().and(n):t,l=new Float32Array(a.trueCount()),u=new Float32Array(n?n.trueCount()-a.trueCount():a.falseCount());if(o)try{var d;s=null==(d=i.DataFrame.fromColumns([o.col]).clone(i.BitSet.fromBytes(a.buffer.buffer,a.length)).col(o.col.name))?void 0:d.aggregate(o.type)}catch(e){console.error(e)}let c=0,h=0;for(let i=0;i<t.length;++i)(!n||n.getBit(i))&&(t.getBit(i)?l[c++]=e[i]:u[h++]=e[i]);let p=l.length+u.length,f=l.reduce((e,t)=>e+t,0)/Math.max(l.length,1);if(l.length<2||u.length<2){let e=u.reduce((e,t)=>e+t,0)/Math.max(u.length,1);return{count:l.length,pValue:null,mean:f,meanDifference:f-e,ratio:l.length/p,mask:a,aggValue:s}}let m=function(e,t){let n,i,o;if(e.length<=1||t.length<=1)throw Error(`StatisticsError: Wrong sample size; expected at least 2, got ${Math.min(e.length,t.length)})`);let s=r.mean(e),a=r.mean(t),l=r.variance(e,!0),u=r.variance(t,!0),d=e.length,c=t.length;1;{let e=l/d,t=u/c,h=(s-a)/Math.sqrt(e+t),p=Math.pow(e+t,2)/(Math.pow(e,2)/(d-1)+Math.pow(t,2)/(c-1));n=1-(i=r.studentt.cdf(h,p)),o=2*(i<n?i:n)}return{"p-value":o,"Mean difference":s-a,"p-value more":n,"p-value less":i}}(l,u),g=m["Mean difference"];return{count:l.length,pValue:m[g>=0?"p-value more":"p-value less"],mean:f,meanDifference:g,ratio:l.length/p,mask:a,aggValue:s}}function d(e,t,n){let r=s.zW[t],o=i.Stats.fromColumn(e,n);if(!(r in o))throw Error(`Aggregation type ${r} is not supported`);return o[r]}function c(e,t,n={}){null!=n.filterDf||(n.filterDf=!1),null!=n.fractionDigits||(n.fractionDigits=3);let i=n.filterDf&&e.filter.anyFalse&&(!n.mask||n.mask.length===e.filter.trueCount)?e.clone(e.filter):e,r={};for(let[e,o]of t){let t=a(o,e),s=d(i.getCol(e),o,n.mask);r[t]=s.toFixed(n.fractionDigits)}return r}function h(e,t,n,i){null!=i.fractionDigits||(i.fractionDigits=3);let r={};for(let[o,s]of n){let n=a(s,o),l=e.get(n,t);r[n]=l.toFixed(i.fractionDigits)}return r}function p(e,t,n){var r;let o=e.col(t.substring(5,t.length-1));if(!o||!o.matches("categorical"))return"{}";null!=n||(n=i.BitSet.create(e.rowCount,()=>!0));let s=o.getRawData(),a=new Map;for(let e=-1;-1!==(e=n.findNext(e,!0));)a.set(s[e],(null!=(r=a.get(s[e]))?r:0)+1);let l={};for(let[e,t]of a)l[o.categories[e]]=t;return JSON.stringify(l)}},586(e,t,n){"use strict";n.d(t,{D:()=>d,Y:()=>c});var i=n(7389),r=n(6082),o=n(3629),s=n(9336),a=n(8750),l=n(7545);function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}function d(e,t,n,i){return null!=i.fromViewer||(i.fromViewer=!1),null!=i.isMutationCliffs||(i.isMutationCliffs=!1),null!=i.isMostPotentResidues||(i.isMostPotentResidues=!1),i.monomerPosition.positionOrClusterType!==o.$2.MONOMER&&c(e,t,n,i),!0}function c(e,t,n,o){var d,c,h,p,f;if(null!=o.fromViewer||(o.fromViewer=!1),null!=o.isMutationCliffs||(o.isMutationCliffs=!1),null!=o.isMostPotentResidues||(o.isMostPotentResidues=!1),null!=o.additionalStats||(o.additionalStats={}),o.cliffStats&&o.isMutationCliffs&&o.cliffIndexes){let d=null==(f=o.cliffStats)||null==(p=f.get(o.monomerPosition.monomerOrCluster))?void 0:p.get(o.monomerPosition.positionOrClusterType);if(!d)return null;let c=r.BitSet.fromBytes(d.mask.buffer.buffer,t.length);c.and(e.filter);let m=(0,s.M1)((0,a.Z7)(t,o.cliffIndexes,o.monomerPosition.monomerOrCluster),!0),g="MP in cliffs count",v=(0,s.QD)(d,{countName:g});o.fromViewer&&(v["Mean difference"]=`${v["Mean difference"]} (Color)`,v[g]&&(v[g]=`${v[g]} (Size)`),o.additionalStats["Unique count"]=c.trueCount.toString());let b=null!=(h=o.aggrColValues)?h:(0,l.I_)(e,n,{mask:c}),y=u({},o.additionalStats,v,b),_=(0,a.F2)(m,y);return i.tooltip.show(_,o.x,o.y),_}{let h=o.mpStats[o.monomerPosition.positionOrClusterType][o.monomerPosition.monomerOrCluster];if(!(null==h?void 0:h.count))return null;let p=r.BitSet.fromBytes(h.mask.buffer.buffer,t.length);p.and(e.filter);let f=(0,s.M1)((0,a.FZ)(t,p,e),!0),m=(0,s.QD)(h);o.fromViewer&&(m["Mean difference"]=`${m["Mean difference"]}${o.isMostPotentResidues?" (size)":""}`,m["p-value"]&&(m["p-value"]=`${m["p-value"]}${o.isMostPotentResidues?" (color)":""}`));let g=null!=(d=o.aggrColValues)?d:(0,l.I_)(e,n,{mask:p}),v=u({},o.additionalStats,m,g);for(let[e,t]of Object.entries(null!=(c=o.postfixes)?c:{}))v[e]&&(v[e]=`${v[e]}${t}`);let b=(0,a.F2)(f,v);return i.tooltip.show(b,o.x,o.y),o.fromViewer||setTimeout(()=>f.props.legendVisibility="Never",100),b}}},4345(e,t,n){"use strict";n.d(t,{GI:()=>a,Ku:()=>o,av:()=>s});var i=n(4386),r=n(9417);let o="WebGPU is not supported on this device";class s{constructor(){this.maxIterations=16,this.inflation=1.4,this.threshold=70,this.distanceF=i.Z.NEEDLEMANN_WUNSCH,this.gapOpen=1.5,this.gapExtend=.2,this.fingerprintType="Morgan",this.useWebGPU=!1,this.minClusterSize=5,this.webGPUDescription=o,this.webGPUDescriptionPromise=(0,r._U)().then(e=>{e&&(this.webGPUDescription=e)})}}class a{constructor(e){this.distanceF=i.Z.NEEDLEMANN_WUNSCH,this.gapOpen=1.5,this.gapExtend=.2,this.clusterEmbeddings=!0,this.epsilon=.01,this.minPts=4,this.fingerprintType="Morgan",this.clusterEmbeddings=!!e}}},3286(e,t,n){"use strict";n.d(t,{Ko:()=>T,WR:()=>E,sI:()=>P});var i,r,o=n(7389),s=n(4328),a=n(6082),l=n(1757),u=n.n(l),d=n(8285),c=n(3629),h=n(8154),p=n(3712),f=n(7545),m=n(1991),g=n.n(m),v=n(9336),b=n(8750),y=n(9222),_=n(4332),w=n(5408),x=n(7351),k=n(5013),S=n(7579);function C(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function A(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}let O=(e,t)=>`${e}(${t})`;var E=((i={}).ORIGINAL="original",i.CUSTOM="custom",i),T=((r={}).WEB_LOGO_MODE="webLogoMode",r.MEMBERS_RATIO_THRESHOLD="membersRatioThreshold",r.SEQUENCE="sequence",r.CLUSTERS="clusters",r.COLUMNS="columns",r.AGGREGATION="aggregation",r.ACTIVITY_SCALING="activityScaling",r.ACTIVITY="activity",r.WEB_LOGO_AGGREGATION_COLUMN_NAME="webLogoAggregationColumnName",r.WEB_LOGO_AGGREGATION_TYPE="webLogoAggregationType",r);class P extends a.JsViewer{get isRenderPending(){return this.renderState.isPending}get onRendered(){return this.renderState.rendered.asObservable()}get immediateRendering(){return this.renderState.immediateRendering}set immediateRendering(e){this.renderState.immediateRendering=e}getWidgetStatus(){var e,t,n,i,r,o,s,a,l;let u=this._viewerGrid&&this.root.contains(this._viewerGrid.root)?this._viewerGrid.getWidgetStatus():{},d=A({},u.hitAreas),h=this._logoSummaryTable,p={clusters:null!=(e=null==h?void 0:h.rowCount)?e:0,"clusters shown":null!=(t=null==h?void 0:h.filter.trueCount)?t:0,"members total":null!=(n=null==h||null==(o=h.col(c.i6.MEMBERS))?void 0:o.stats.sum)?n:0,"clusters column":null!=(i=this.clustersColumnName)?i:"","selected clusters":Object.values(null!=(r=this._clusterSelection)?r:{}).flat().join(", "),message:this.message};if(h){for(let e=0;e<h.rowCount;e++){let t=h.get(c.i6.CLUSTER,e);for(let n of[c.i6.MEMBERS,c.i6.MEAN_DIFFERENCE,c.i6.P_VALUE]){let i=h.getCol(n);p[`${n} of cluster ${t}`]=i.isNone(e)?"":i.get(e)}}for(let[e,t]of Object.entries(null!=(s=u.hitAreas)?s:{})){let n=/^cell (\d+) of (.+)$/.exec(e);if(!n)continue;let i=h.get(c.i6.CLUSTER,Number(n[1])-1);n[2]===c.i6.CLUSTER?d[`cluster ${i}`]=t:n[2]===c.i6.WEB_LOGO?d[`weblogo of cluster ${i}`]=t:n[2]===c.i6.DISTRIBUTION&&(d[`distribution of cluster ${i}`]=t)}}return a=A({},u),l=l={hitAreas:d,values:p},Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(l)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(l)).forEach(function(e){Object.defineProperty(a,e,Object.getOwnPropertyDescriptor(l,e))}),a}clearGrid(){var e;null==(e=this.clearGridResources)||e.call(this),this.clearGridResources=null,this._viewerGrid=null}get model(){return d.i.getInstance(this.dataFrame)}get viewerGrid(){return null!=this._viewerGrid||(this._viewerGrid=this.createLogoSummaryTableGrid()),this._viewerGrid}get clusterStats(){return null!=this._clusterStats||(this._clusterStats=(0,w.eW)(this.dataFrame,this.clustersColumnName,this.customClusters.toArray(),this.getScaledActivityColumn())),this._clusterStats}get clusterSelection(){return null!=this._clusterSelection||(this._clusterSelection=this.initClusterSelection({notify:!1})),this._clusterSelection}set clusterSelection(e){this._clusterSelection=e,this.model.fireBitsetChanged(d.q.LOGO_SUMMARY_TABLE),this.model.analysisView.grid.invalidate()}get logoSummaryTable(){return null!=this._logoSummaryTable||(this._logoSummaryTable=this.createLogoSummaryTable()),this._logoSummaryTable}set logoSummaryTable(e){this._logoSummaryTable=e}get positionColumns(){var e,t,n;if(null!=this._positionColumns)return this._positionColumns;let i=e=>{let t=this.model.findViewer(e);return this.sequenceColumnName===(null==t?void 0:t.sequenceColumnName)?t._positionColumns:null};return null!=this.model.positionColumns&&this.sequenceColumnName===(null==(n=this.model.settings)?void 0:n.sequenceColumnName)&&(this._positionColumns=this.model.positionColumns),null!=this._positionColumns||(this._positionColumns=null!=(e=null!=(t=i(d.q.SEQUENCE_VARIABILITY_MAP))?t:i(d.q.MOST_POTENT_RESIDUES))?e:(0,x.R)(this.dataFrame.getCol(this.sequenceColumnName),k.Z.getSeqHelper()).columns.toList()),this._positionColumns}get isClusterSelectionEmpty(){return 0===this.clusterSelection.original.length+this.clusterSelection.custom.length}get customClusters(){let e={};return e[c.gp.CUSTOM_CLUSTER]="1",g()(this.dataFrame.columns.byTags(e))}getScaledActivityColumn(e=!1){var t,n;return((null==(t=this.model.settings)?void 0:t.activityColumnName)===this.activityColumnName&&(null==(n=this.model.settings)?void 0:n.activityScaling)===this.activityScaling&&(this._scaledActivityColumn=this.model.getScaledActivityColumn(e)),null!=this._scaledActivityColumn||(this._scaledActivityColumn=(0,b.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling)),e)?a.DataFrame.fromColumns([this._scaledActivityColumn]).clone(this.dataFrame.rowCount===this._scaledActivityColumn.length?this.dataFrame.filter:null).getCol(this._scaledActivityColumn.name):this._scaledActivityColumn}getAggregationColumns(){return Object.fromEntries(this.columns.map(e=>[e,this.aggregation]).filter(([e,t])=>this.model.df.columns.contains(e)&&this.model.df.col(e).matches("numerical")))}onTableAttached(){if(super.onTableAttached(),(0,b.B2)(this.dataFrame)){var e,t,n,i,r,o,l,u,d,h,p,f,m;let s=null==(e=g()(this.dataFrame.columns.numerical).filter(e=>{var t;return null==(t=e.name)?void 0:t.includes("activ")}).take(1).toArray()[0])?void 0:e.name,v=null!=s?s:null==(n=g()(this.dataFrame.columns.numerical).take(1).toArray())||null==(t=n[0])?void 0:t.name,b=this.dataFrame.columns.bySemType(a.SEMTYPE.MACROMOLECULE);b&&(null==(h=this.getProperty(`sequence${c.To}`))||h.set(this,b.name)),v&&(null==(p=this.getProperty(`activity${c.To}`))||p.set(this,v),null==(f=this.getProperty("webLogoAggregationColumnName"))||f.set(this,v));let y=null==(o=g()(this.dataFrame.columns).filter(e=>{var t;return e.isCategorical&&(null==(t=e.name)?void 0:t.toLowerCase().includes("cluster"))&&e.name!=(null==b?void 0:b.name)&&e.type!==a.COLUMN_TYPE.BOOL}))||null==(r=o.take(1))||null==(i=r.toArray())?void 0:i[0],_=null!=y?y:null==(d=g()(this.dataFrame.columns.categorical).filter(e=>e.name!=(null==b?void 0:b.name)&&e.categories.length<=50&&e.type!==a.COLUMN_TYPE.BOOL))||null==(u=d.take(1))||null==(l=u.toArray())?void 0:l[0];_&&(null==(m=this.getProperty(`clusters${c.To}`))||m.set(this,_.name))}else{let e="PeptidesError: dataframe is missing Macromolecule or numeric columns";s.log.error(e),s.shell.warning(e)}this.render()}detach(){this.clearGrid(),this.renderState.dispose(),super.detach()}render(){if(u()(this.root).empty(),this.message="",!this.dataFrame||null==this.clustersColumnName||null==this.sequenceColumnName||null==this.activityColumnName){this.message="Please, select a sequence, cluster and activity columns in the viewer properties",this.root.appendChild(o.divText(this.message)),this.renderState.rendered.next();return}if(!this.logoSummaryTable.filter.anyTrue){this.message="No clusters to satisfy the threshold. Please, lower the threshold in viewer proeperties to include clusters";let e=o.divText(this.message);this.root.appendChild(o.divV([e])),this.renderState.rendered.next();return}let e=o.iconFA("expand-alt",()=>{let e=o.dialog("Logo Summary Table");e.add(this.viewerGrid.root),e.onCancel(()=>this.render()),e.showModal(!0),this.viewerGrid.invalidate()},"Show Logo Summary Table in full screen");u()(e).addClass("pep-help-icon"),this.viewerGrid.root.style.width="auto",this.viewerGrid.root.style.height="auto",this.viewerGrid.root.style.overflow="hidden",this.root.appendChild(o.divV([o.divH([e],{style:{alignSelf:"center",lineHeight:"normal"}}),this.viewerGrid.root])),this.viewerGrid.invalidate()}onPropertyChanged(e){if(super.onPropertyChanged(e),!this.dataFrame)return;let t=!1;switch(e.name){case"membersRatioThreshold":this.logoSummaryTable.filter.anyTrue||(t=!0),this.updateFilter();break;case`sequence${c.To}`:this.clearGrid(),this._logoSummaryTable=null,t=!0;break;case`clusters${c.To}`:this._clusterStats=null,this._clusterSelection=null,this.clearGrid(),this._logoSummaryTable=null,t=!0;break;case`activity${c.To}`:this.webLogoAggregationColumnName=this.activityColumnName;case"activityScaling":case`webLogoAggregationColumnName${c.To}`:case"webLogoAggregationType":this._webLogoCacheGeneration++,this._scaledActivityColumn=null,this.clearGrid(),this._clusterStats=null,this._logoSummaryTable=null,t=!0;break;case"columns":case"aggregation":this.clearGrid(),this._logoSummaryTable=null,t=!0;break;case"webLogoMode":this.viewerGrid.invalidate()}t&&this.render()}initClusterSelection(e={}){null!=e.notify||(e.notify=!0);let t={};return t.original=[],t.custom=[],e.notify?this.clusterSelection=t:this._clusterSelection=t,this.clusterSelection}getTotalViewerAggColumns(){var e,t;let n=this.getAggregationColumns();return(0,b.zm)(this.model.df,this.columns,n,null==(t=this.model)||null==(e=t.settings)?void 0:e.columns)}getStringAggregatedColumns(){return this.columns.filter(e=>this.model.df.columns.contains(e)&&this.model.df.col(e).matches("categorical")).map(e=>`dist(${e})`)}getNeededDfClone(){var e,t;let n=[this.clustersColumnName,this.sequenceColumnName,this.activityColumnName,...(null!=(e=this.getTotalViewerAggColumns())?e:[]).map(([e,t])=>e),...(null!=(t=this.getStringAggregatedColumns())?t:[]).map(e=>e.substring(5,e.length-1))];this.webLogoAggregationColumnName&&n.push(this.webLogoAggregationColumnName);let i=Array.from(new Set(n)).filter(e=>this.dataFrame.columns.contains(e));return this.dataFrame.clone(this.dataFrame.filter,i)}createLogoSummaryTable(){var e,t,n;let i=this.clustersColumnName,r=this.dataFrame.filter.anyFalse,o=r?this.getNeededDfClone():this.dataFrame,s=o.columns,l=o.rowCount,u=this.getScaledActivityColumn(r).getRawData(),d=o.getCol(i),h=d.getRawData(),p=d.categories,m={};m[c.gp.CUSTOM_CLUSTER]="1";let v=g()(s.byTags(m)).filter(e=>e.max>0).toArray(),b=a.DataFrame.create(v.length),_=b.columns,w=_.addNewString(c.i6.CLUSTER),x=_.addNewInt(c.i6.MEMBERS).getRawData(),k=_.addNewString(c.i6.WEB_LOGO),S=_.addNewString(c.i6.DISTRIBUTION),C=_.addNewFloat(c.i6.MEAN_DIFFERENCE).getRawData(),A=_.addNewFloat(c.i6.P_VALUE).getRawData(),E=_.addNewFloat(c.i6.RATIO).getRawData(),T=o.groupBy([i]),P=this.getTotalViewerAggColumns(),N=this.getStringAggregatedColumns(),I=N.map(e=>_.addNewString(e)),M=P.map(([e,t])=>O(t,e)),L=Array(M.length+N.length),R=P.map(([e,t])=>[o.getCol(e),t]);for(let e=0;e<P.length;++e){let[t,n]=P[e];T=T.add(n,t,M[e]);let i=_.addNewFloat(M[e]);L[e]=i.getRawData()}let j=Array(v.length);for(let t=0;t<v.length;++t){let n=v[t];w.set(t,n.name);let i=y.A.fromUint32Array(l,n.getRawData());if(i.allFalse)continue;let s=a.BitSet.fromBytes(i.buffer.buffer,l),d=r?(0,f.GT)(u,i):this.clusterStats.custom[n.name];x[t]=d.count,j[t]=s,C[t]=d.meanDifference,A[t]=null!=(e=d.pValue)?e:a.FLOAT_NULL,E[t]=d.ratio;for(let e=0;e<M.length;++e){let[n,i]=R[e];L[e][t]=(0,f.lh)(n,i,s)}for(let e=M.length;e<L.length;++e){let n=N[e-M.length];I[e-M.length].set(t,(0,f.J1)(o,n,s))}}k.setTag(a.TAGS.CELL_RENDERER,"html"),S.setTag(a.TAGS.CELL_RENDERER,"html");let D=T.aggregate(),F=D.rowCount,z=D.columns,q=D.getCol(i);q.name=c.i6.CLUSTER,q.type!==a.COLUMN_TYPE.STRING&&(D.columns.replace(q,q.convertTo(a.COLUMN_TYPE.STRING)),q=D.getCol(q.name));let B=q.categories,G=z.addNewInt(c.i6.MEMBERS).getRawData(),V=z.addNewString(c.i6.WEB_LOGO),U=z.addNewString(c.i6.DISTRIBUTION),H=z.addNewFloat(c.i6.MEAN_DIFFERENCE).getRawData(),W=z.addNewFloat(c.i6.P_VALUE).getRawData(),Y=z.addNewFloat(c.i6.RATIO).getRawData(),K=N.map(e=>z.addNewString(e)),X=Array(F),Z=Array.from({length:F},()=>new y.A(l,!1));for(let e=0;e<l;++e){let n=p[h[e]];null==(t=Z[B.indexOf(n)])||t.setTrue(e)}for(let e=0;e<F;++e){let t=Z[e];if(t.allFalse)continue;let i=a.BitSet.fromBytes(t.buffer.buffer,l),s=r?(0,f.GT)(u,t):this.clusterStats.original[B[e]];for(let t=0;t<N.length;++t){let n=N[t];K[t].set(e,(0,f.J1)(o,n,i))}G[e]=s.count,X[e]=i,H[e]=s.meanDifference,W[e]=null!=(n=s.pValue)?n:a.FLOAT_NULL,Y[e]=s.ratio}V.setTag(a.TAGS.CELL_RENDERER,"html"),U.setTag(a.TAGS.CELL_RENDERER,"html");let Q=D.append(b);return this.bitsets=X.concat(j),N.forEach(e=>Q.col(e).semType="lst-pie-chart"),Q}createLogoSummaryTableGrid(){let e=this.dataFrame.filter.anyFalse,t=e?this.getNeededDfClone():this.dataFrame,n=this.getTotalViewerAggColumns().map(([e,t])=>O(t,e)),i=this.logoSummaryTable.plot.grid();i.root.setAttribute("name","Logo-Summary-Table-grid"),this.renderState.add(i,i.onAfterDrawContent),i.sort([c.i6.MEMBERS],[!1]),this.updateFilter(),i.col(c.i6.CLUSTER).visible=!0,i.columns.setOrder([c.i6.CLUSTER,c.i6.MEMBERS,c.i6.WEB_LOGO,...this.getStringAggregatedColumns(),c.i6.DISTRIBUTION,c.i6.MEAN_DIFFERENCE,c.i6.P_VALUE,c.i6.RATIO,...n]),i.columns.rowHeader.visible=!1,i.props.rowHeight=55;let r=new a.LruCache,o=new Map,s=()=>{this.renderState.defer("invalidate",()=>i.invalidate(),200)},l=new a.LruCache,f=!1,m=new Set,g=e=>{m.delete(e),this.renderState.remove(e)};r.onItemEvicted=g,l.onItemEvicted=g,this.clearGridResources=()=>{for(let e of(f=!0,this.renderState.cancel("invalidate"),this.renderState.cancel("current cell"),x.cancel(),m))g(e);this.renderState.remove(i)};let v=this.positionColumns.length,y=i.columns.byName(c.i6.WEB_LOGO);y.cellType="html",y.width=350;let _=this.getScaledActivityColumn(e),w=t.getCol(this.sequenceColumnName);i.sub(i.onCellRender.subscribe(e=>{let n=e.cell,i=n.tableRowIndex;if(!n.isTableCell||null==i||-1===i)return;let d=e.g,g=e.bounds;d.save(),d.beginPath(),d.rect(g.x,g.y,g.width,g.height),d.clip();try{var y,x,k;let S=Math.max(n.bounds.height-2,0),A=this.bitsets[i];if((null==(y=n.tableColumn)?void 0:y.name)===c.i6.CLUSTER)h.k8(d,n.cell.value,this.clusterSelection,g),e.preventDefault();else if((null==(x=n.tableColumn)?void 0:x.name)===c.i6.WEB_LOGO){let l=`${i}_${this.webLogoAggregationColumnName||"count"}_${this.webLogoAggregationType}_${this._webLogoCacheGeneration}`,d=r.get(l);if(!0===o.get(l))return void e.preventDefault();let c=Math.floor((n.bounds.width-2-4*(v-1))/v);if(void 0!==d){for(let e of d.getProperties())"positionHeight"===e.name&&e.get(d)!==this.webLogoMode?e.set(d,this.webLogoMode):"positionWidth"===e.name&&e.get(d)!==c?e.set(d,c):"minHeight"===e.name&&e.get(d)!==S&&e.set(d,S);u()(d.root).css("height",`${S}px`).children().first().css("overflow-y","hidden !important"),d.root.style.height=`${S}px`,n.element=d.root,e.preventDefault()}else{let n=[w];if(this.webLogoAggregationType!==a.AGG.TOTAL_COUNT&&this.webLogoAggregationColumnName){let e=t.columns.byName(this.webLogoAggregationColumnName);e&&n.push(e)}let i=a.DataFrame.fromColumns(n);i.filter.copyFrom(A),o.set(l,!0),this.renderState.run(()=>{var e;return(e=function*(){try{let e=yield i.plot.fromType("WebLogo",{valueColumnName:this.webLogoAggregationColumnName,valueAggrType:this.webLogoAggregationType,positionHeight:this.webLogoMode,horizontalAlignment:p.P4.LEFT,maxHeight:1e3,minHeight:S,positionWidth:c,showPositionLabels:!1});if(f)return void e.detach();m.add(e),this.renderState.add(e,e.onRendered),r.set(l,e),s()}finally{o.delete(l)}},function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){C(o,i,r,s,a,"next",e)}function a(e){C(o,i,r,s,a,"throw",e)}s(void 0)})}).call(this)}),e.preventDefault()}}else if((null==(k=n.tableColumn)?void 0:k.name)===c.i6.DISTRIBUTION){let t=l.get(i);void 0===t&&(_.dataFrame||a.DataFrame.fromColumns([_]),(t=(0,b.FZ)(_,A,_.dataFrame).plot.histogram({filteringEnabled:!1,valueColumnName:_.name,splitColumnName:c.$2.SPLIT_COL,legendVisibility:"Never",showXAxis:!1,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1,backColor:a.Color.white,xAxisHeight:1,showSplitSelector:!1})).root.style.width="auto",m.add(t),this.renderState.add(t),l.set(i,t)),t.root.style.height=`${S}px`,n.element=t.root,e.preventDefault()}}finally{d.restore()}})),i.root.addEventListener("mouseleave",e=>this.model.unhighlight()),i.sub(i.onCurrentCellChanged.subscribe(e=>this.renderState.defer("current cell",()=>{if(!e.isTableCell||-1===e.gridRow){this.initClusterSelection({notify:!1}),this.model.fireBitsetChanged(d.q.LOGO_SUMMARY_TABLE),i.invalidate();return}try{var t;if(!this.keyPress||(null==(t=e.tableColumn)?void 0:t.name)!==c.i6.CLUSTER)return;null!==this.currentRowIndex&&-1!==this.currentRowIndex&&this.modifyClusterSelection(this.getCluster(i.cell(c.i6.CLUSTER,this.currentRowIndex)),{shiftPressed:!0,ctrlPressed:!0},!1),this.modifyClusterSelection(this.getCluster(e),{shiftPressed:!0,ctrlPressed:!1}),i.invalidate()}finally{this.keyPress=!1,this.currentRowIndex=e.gridRow}},500))),i.root.addEventListener("keydown",e=>{if(this.keyPress=e.key.startsWith("Arrow"),!this.keyPress){if("Escape"===e.key||"KeyA"===e.code&&e.shiftKey&&(e.ctrlKey||e.metaKey))this.initClusterSelection({notify:!1});else if("KeyA"===e.code&&(e.ctrlKey||e.metaKey))for(let e=0;e<this.logoSummaryTable.rowCount;++e)this.modifyClusterSelection(this.getCluster(i.cell(c.i6.CLUSTER,e)),{shiftPressed:!0,ctrlPressed:!1},!1);this.model.fireBitsetChanged(d.q.LOGO_SUMMARY_TABLE),i.invalidate()}}),i.root.addEventListener("click",e=>{var t;let n=i.hitTest(e.offsetX,e.offsetY);if(!n||!n.isTableCell||(null==(t=n.tableColumn)?void 0:t.name)!==c.i6.CLUSTER)return;let r=this.getCluster(n);this.modifyClusterSelection(r,{shiftPressed:e.shiftKey,ctrlPressed:e.ctrlKey||e.metaKey}),i.invalidate()});let x=i.onCellTooltip((e,t,n)=>{var i;if(!e.isTableCell)return this.model.unhighlight(),!0;let r=this.getCluster(e);return this.highlightCluster(r),(null==(i=e.tableColumn)?void 0:i.name)===c.i6.CLUSTER&&this.showTooltip(r,t,n),!0}),k=i.props;return k.allowEdit=!1,k.allowRowSelection=!1,k.allowBlockSelection=!1,k.allowColSelection=!1,k.showCurrentRowIndicator=!1,k.showReadOnlyNotifications=!1,i}highlightCluster(e){let t=this.clusterStats[e.positionOrClusterType][e.monomerOrCluster].mask;this.dataFrame.rows.highlight(e=>t.getBit(e)),this.model.isHighlighting=!0}getCluster(e){let t=this.logoSummaryTable.get(c.i6.CLUSTER,e.tableRowIndex);return{positionOrClusterType:this.dataFrame.getCol(this.clustersColumnName).categories.includes(t)?"original":"custom",monomerOrCluster:t}}updateFilter(){let e=this.logoSummaryTable.getCol(c.i6.MEMBERS),t=this.logoSummaryTable.getCol(c.i6.CLUSTER),n=t.getRawData(),i=t.categories,r=i.indexOf("-1"),o=e.getRawData(),s=0;o.forEach((e,t)=>{"-1"!==i[n[t]]&&(s=Math.max(s,o[t]))});let a=Math.ceil(s*this.membersRatioThreshold);this.logoSummaryTable.filter.init(e=>o[e]>a&&(-1===r||"-1"!==i[n[e]]))}clusterFromSelection(){let e=this.model.getVisibleSelection(),t=this.logoSummaryTable.columns,n=t.length,i=Array(t.length),r=this.getScaledActivityColumn(),o=(0,f.pY)(e),s=(0,f.GT)(r.getRawData(),o,(0,f.pY)(this.dataFrame.filter));this.bitsets.push(e.clone());let a=this.dataFrame.columns.getUnusedName("New Cluster"),l={},u={},d=this.getTotalViewerAggColumns(),h=this.getStringAggregatedColumns();for(let[t,n]of d){let i=O(n,t),r=this.dataFrame.getCol(t);l[i]=(0,f.lh)(r,n,e)}for(let t of h)u[t]=(0,f.J1)(this.dataFrame,t,e);for(let r=0;r<n;++r){let n=t.byIndex(r);i[r]=n.name===c.i6.CLUSTER?a:n.name===c.i6.MEMBERS?e.trueCount:n.name===c.i6.WEB_LOGO||n.name===c.i6.DISTRIBUTION?null:n.name===c.i6.MEAN_DIFFERENCE?s.meanDifference:n.name===c.i6.P_VALUE?s.pValue:n.name===c.i6.RATIO?s.ratio:n.name in l?l[n.name]:n.name in u?u[n.name]:void 0,void 0===i[r]&&_._package.logger.warning(`PeptidesLSTWarn: value for column ${n.name} is undefined`)}this.logoSummaryTable.rows.addNew(i),this.clusterStats.custom[a]=s,this.addNewCluster(a)}removeCluster(){let e=this.clusterSelection.custom;if(0===e.length)return void s.shell.warning("No custom clusters selected to be removed");let t=this.logoSummaryTable.rows,n=this.logoSummaryTable.getCol(c.i6.CLUSTER),i=n.categories,r=this.dataFrame.columns;for(let n of e){e.splice(e.indexOf(n),1),r.remove(n),delete this.clusterStats.custom[n];let o=i.indexOf(n);t.removeAt(o),this.bitsets.splice(o,1)}n.compact(),this.clusterSelection.custom=e,this.render()}addNewCluster(e){let t=a.Column.fromBitSet(e,this.model.getVisibleSelection());t.setTag(c.gp.CUSTOM_CLUSTER,"1"),t.setTag(c.gp.ANALYSIS_COL,"true"),this.dataFrame.columns.add(t),this.model.analysisView.grid.col(t.name).visible=!1}modifyClusterSelection(e,t={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.clusterSelection=(0,b.vW)(this.clusterSelection,e,t):this._clusterSelection=(0,b.vW)(this.clusterSelection,e,t)}showTooltip(e,t,n){let i=this.dataFrame.filter,r=i.anyFalse?this.getNeededDfClone():this.dataFrame,s=r.rowCount,l=new y.A(s,!1),u=this.getScaledActivityColumn(i.anyFalse),d=u.getRawData();if("original"===e.positionOrClusterType){let t=r.getCol(this.clustersColumnName),n=t.getRawData(),i=t.categories.indexOf(e.monomerOrCluster);for(let e=0;e<s;++e)n[e]===i&&l.setTrue(e);l.incrementVersion()}else l.buffer=r.getCol(e.monomerOrCluster).getRawData();let c=i.anyFalse?(0,f.GT)(d,l):this.clusterStats[e.positionOrClusterType][e.monomerOrCluster];if(!c.count)return null;let h=a.BitSet.fromBytes(l.buffer.buffer,s);u.dataFrame||a.DataFrame.fromColumns([u]);let p=(0,b.FZ)(u,h,u.dataFrame),m=(0,v.M1)(p,!0),g=A({},(0,v.QD)(c),(0,f.I_)(this.dataFrame,this.getTotalViewerAggColumns(),{filterDf:!0,mask:h})),_=(0,b.F2)(m,g);return o.tooltip.show(_,t,n),_}createWebLogoDf(e,t){let n=a.DataFrame.fromColumns([e]);return n.filter.copyFrom(t),n}constructor(){super(),this.bitsets=[],this.keyPress=!1,this.currentRowIndex=null,this._scaledActivityColumn=null,this._webLogoCacheGeneration=0,this.renderState=new S.Y,this.clearGridResources=null,this.message="",this._viewerGrid=null,this._clusterStats=null,this._clusterSelection=null,this._logoSummaryTable=null,this._positionColumns=null,this.root.classList.add("peptides-viewer-show-title"),this.sequenceColumnName=this.column("sequence",{category:"General",nullable:!1}),this.clustersColumnName=this.column("clusters",{category:"General",nullable:!1,columnTypeFilter:a.TYPE.CATEGORICAL}),this.activityColumnName=this.column("activity",{category:"General",nullable:!1,columnTypeFilter:a.TYPE.NUMERICAL}),this.activityScaling=this.string("activityScaling",c.rg.NONE,{category:"General",choices:Object.values(c.rg)}),this.webLogoMode=this.string("webLogoMode",p.fH.Entropy,{choices:[p.fH.full,p.fH.Entropy],category:"WebLogo"}),this.membersRatioThreshold=this.float("membersRatioThreshold",.1,{min:0,max:1,category:"WebLogo"});const e=[a.AGG.KEY,a.AGG.PIVOT,a.AGG.MISSING_VALUE_COUNT,a.AGG.SKEW,a.AGG.KURT,a.AGG.SELECTED_ROWS_COUNT],t=Object.values(a.AGG).filter(t=>!e.includes(t));this.webLogoAggregationType=this.string("webLogoAggregationType",a.AGG.TOTAL_COUNT,{category:"WebLogo",choices:t,description:"Aggregation method for WebLogo position heights"}),this.webLogoAggregationColumnName=this.column("webLogoAggregationColumnName",{defaultValue:null,category:"WebLogo",nullable:!0,columnTypeFilter:a.TYPE.NUMERICAL,description:`Column with values to aggregate for WebLogo position heights.
|
|
360
|
+
Used if aggregation type is not '${a.AGG.TOTAL_COUNT}'.`}),this.columns=this.columnList("columns",[],{category:"Aggregation"}),this.aggregation=this.string("aggregation",a.AGG.AVG,{category:"Aggregation",choices:c.V5})}}},4725(e,t,n){"use strict";n.d(t,{Y_:()=>x});var i=n(4328),r=n(7389),o=n(6082),s=n(1991),a=n.n(s),l=n(1757),u=n.n(l),d=n(1858),c=n(3629),h=n(5013),p=n(8750),f=n(5408),m=n(586),g=n(7351),v=n(1004),b=n(8621),y=n(1381),_=n(8509),w=n(8285);class x extends o.JsViewer{get name(){return"Peptide Generation"}onTableAttached(){var e,t,n,r;super.onTableAttached();let s=this.dataFrame.columns.bySemType(o.SEMTYPE.MACROMOLECULE);if(null==s)return void i.shell.warning("Peptide Generation: no Macromolecule column found");null==(t=this.getProperty("sequenceColumnName"))||t.set(this,s.name);let l=null!=(e=a()(this.dataFrame.columns.numerical).find(e=>e.name.toLowerCase().includes("activity")))?e:null==(n=a()(this.dataFrame.columns.numerical).next())?void 0:n.value;l&&(null==(r=this.getProperty("activityColumnName"))||r.set(this,l.name)),this.subs.push(o.debounce(this.dataFrame.onFilterChanged,500).subscribe(()=>{this._propChangeTimer&&clearTimeout(this._propChangeTimer),this._monomerPositionStats=null,this._grid=null,this.render()})),this.subs.push(d.merge(this.dataFrame.onRowsRemoved,this.dataFrame.onRowsAdded).subscribe(()=>{this._propChangeTimer&&clearTimeout(this._propChangeTimer),this._monomerPositionStats=null,this._grid=null,this.render()})),this.render()}onPropertyChanged(e){this.dataFrame&&this.sequenceColumnName&&this.activityColumnName&&(this._propChangeTimer&&clearTimeout(this._propChangeTimer),this._propChangeTimer=setTimeout(()=>{this._positionColumns=null,this._monomerPositionStats=null,this._grid=null,this.render()},500))}get existingModel(){var e,t,n;return null!=(e=null==(n=this.dataFrame)||null==(t=n.temp)?void 0:t[w.i.modelName])?e:null}get monomerPositionStats(){if(null!=this._monomerPositionStats)return this._monomerPositionStats;let e=this.dataFrame.filter.anyFalse,t=e=>null!=e&&this.sequenceColumnName===e.sequenceColumnName&&this.activityColumnName===e.activityColumnName&&this.activityScaling===e.activityScaling,n=this.existingModel;if(null!=n){for(let i of[w.q.SEQUENCE_VARIABILITY_MAP,w.q.MOST_POTENT_RESIDUES]){let r=n.findViewer(i);if((null==r?void 0:r._monomerPositionStats)!=null&&t(r)&&(!e||"Filtered"===r.dataSource))return this._monomerPositionStats=r._monomerPositionStats}if(!e&&null!=n.monomerPositionStats&&t(n.settings))return this._monomerPositionStats=n.monomerPositionStats}let i=(0,p.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling);return this._monomerPositionStats=(0,f.Ej)(i,this.dataFrame.filter,this.getPositionColumns(),{isFiltered:e}),this._monomerPositionStats}detach(){var e;this.subs.forEach(e=>e.unsubscribe()),null==(e=this._currentCellSub)||e.unsubscribe()}getPositionColumns(){if(null!=this._positionColumns)return this._positionColumns;let e=a()(this.dataFrame.columns.toList()).filter(e=>"true"===e.getTag(c.gp.POSITION_COL)).toArray();return 0!==e.length?this._positionColumns=e:this._positionColumns=(0,g.R)(this.dataFrame.getCol(this.sequenceColumnName),h.Z.getSeqHelper()).columns.toList(),this._positionColumns}render(){var e;if(u()(this.root).empty(),!this.dataFrame||!this.sequenceColumnName||!this.activityColumnName)return void this.root.appendChild(r.divText("Please select a sequence and an activity column in the viewer properties"));try{null!=this._grid||(this._grid=this.createGrid())}catch(t){i.log.error(t),this.root.appendChild(r.divText(`Peptide Generation failed: ${null!=(e=null==t?void 0:t.message)?e:t}`));return}let t=this.activityTarget===c.wf.HIGH?"highest":"lowest",n=r.divText(`${this._grid.table.rowCount} peptides generated for ${t} activity (additive positional model — treats positions as independent)`,{style:{color:"var(--grey-5)",fontSize:"12px"}}),o=r.iconFA("plus",()=>this.openAsTableView(),"Open the generated peptides as a new table");o.style.cursor="pointer",o.style.color="var(--blue-1)";let s=r.iconFA("info-circle");s.style.color="var(--blue-1)",s.style.cursor="help",r.tooltip.bind(s,()=>this.buildInfoTooltip());let a=r.divH([n,o,s],{style:{alignItems:"center",gap:"6px",padding:"4px 8px"}}),l=this._grid.root;l.style.width="100%",this.root.appendChild(r.divV([a,l],{style:{height:"100%"}})),this._grid.invalidate()}openAsTableView(){if(null==this._grid)return;let e=this._grid.table.clone();for(let t of(e.name="Generated Peptides",this._basisPositionNames)){let n=e.col(t),i=this._basisByPosition[t];null!=n&&null!=i&&n.init(e=>{let t=i[e];if(null==t||!t.monomer)return"";let n=null==t.pValue?"n/a":t.pValue<.001?t.pValue.toExponential(1):t.pValue.toFixed(3);return`${t.monomer}, ${this.formatContribution(t.contribution)}, ${n}`})}let t=i.shell.addTableView(e);setTimeout(()=>i.shell.v=t,50)}buildInfoTooltip(){return r.divV([r.h3("How Peptide Generation works"),r.divText("Additive positional (Free-Wilson) model",{style:{fontWeight:"bold"}}),r.divText("Predicted activity = global mean + Σ over positions of (chosen monomer's mean activity − global mean). Each per-position contribution is shrunk by count / (count + k) so that poorly-supported monomers cannot dominate the prediction."),r.divText("Generation",{style:{fontWeight:"bold",marginTop:"6px"}}),r.divText("At each position the best-scoring monomers toward the chosen High/Low target are kept, then a beam search combines them into whole peptides, ranked by predicted activity."),r.divText("Per-position basis columns",{style:{fontWeight:"bold",marginTop:"6px"}}),r.divText("The trailing columns (one per position) show the chosen monomer, an effect circle, and the signed contribution. In each circle:"),r.list(["Size = effect magnitude (|contribution|), normalized within the row: bigger = stronger effect on activity.","Color = direction and significance: red raises activity, blue lowers it, pale ≈ weak significance, grey = not enough data to test.","Hover a cell for the full activity distribution of that monomer-at-position versus the rest."],{processNode:e=>{e.style.maxWidth="470px",e.style.display="block"}}),r.divText("Keep in mind",{style:{fontWeight:"bold",marginTop:"6px"}}),r.list(["Predicted activity is a ranking score / optimistic estimate, NOT a calibrated measurement.","Because contributions add across positions, it can extrapolate well beyond the observed activity range — a peptide combining the best residue at every position may not exist or behave additively (epistasis is invisible to this model).","Judge reliability with the Confidence, Min support, Significant positions and Basis columns.",'Raise "Shrinkage strength" or enable "Only significant positions" for more conservative magnitudes. On data with no real signal, few or no significant peptides should appear.'],{processNode:e=>{e.style.maxWidth="470px",e.style.display="block"}})],{style:{maxWidth:"480px",fontSize:"12px"}})}createGrid(){var e,t;let n=this.generatePeptides().plot.grid();n.props.allowEdit=!1,n.props.showReadOnlyNotifications=!1,null==(t=this._currentCellSub)||t.unsubscribe(),this._currentCellSub=n.onCurrentCellChanged.subscribe(e=>{var t,n;e&&e.dart&&e.cell.dart&&(null!=(t=e.tableRowIndex)?t:-1)>-1&&(null==(n=e.cell.column)?void 0:n.name)==="Peptide"&&(i.shell.o=o.SemanticValue.fromGridCell(e))});let r=n.col("Predicted activity");r&&(r.format="#.000");let s=n.col("Mean p-value");s&&(s.format="#.000");let a=n.col("Confidence");a&&(a.format="0.##%");let l=n.col("Basis");l&&(l.visible=!1);let u=null!=(e=this.dataFrame.getCol(this.sequenceColumnName).getTag(b.gp.alphabet))?e:b.YI.UN;for(let e of(this._biotype=u===b.YI.RNA||u===b.YI.DNA?_.oE.NUCLEOTIDE:_.oE.AA,this._monomerColorCache.clear(),n.props.rowHeight=22,this._basisPositionNames)){let t=n.col(e);t&&(t.width=85)}return n.onCellRender.subscribe(e=>this.renderBasisCell(e)),n.onCellTooltip((e,t,n)=>this.showBasisTooltip(e,t,n)),n.root.addEventListener("mouseleave",()=>{var e,t;return null==(t=this.dataFrame)||null==(e=t.rows)?void 0:e.highlight(()=>!1)}),n.sort(["Predicted activity"],[this.activityTarget!==c.wf.HIGH]),n}renderBasisCell(e){var t,n,i;let r=e.cell,o=null==(n=r.tableColumn)?void 0:n.name;if(!r.isTableCell||null==o||!this._basisPositionSet.has(o))return;let s=e.g,a=e.bounds;s.save(),s.beginPath(),s.rect(a.x,a.y,a.width,a.height),s.clip();let l=r.tableRowIndex,u=null==l?null:null!=(t=null==(i=this._basisByPosition[o])?void 0:i[l])?t:null;if(null==u||!u.monomer){e.preventDefault(),s.restore();return}let d=a.y+a.height/2,c=.36*a.width,h=.4*a.width,p=a.x+3+c,f=Math.max(6,a.width-c-h-6);s.textBaseline="middle",s.font="11px Roboto, Roboto Local, sans-serif",s.textAlign="left",s.fillStyle=this.monomerTextColor(u.monomer),s.fillText(this.fitText(s,u.monomer,c-3),a.x+3,d);let m=this._rowMaxAbsContribution[l]||0,g=m>0?Math.min(1,Math.abs(u.contribution)/m):0,v=Math.max(2,Math.min(f,a.height)/2*.9*g);s.beginPath(),s.fillStyle=this.contributionColor(u.contribution,u.pValue),s.arc(p+f/2,d,v,0,2*Math.PI),s.fill(),s.lineWidth=.5,s.strokeStyle="rgba(0,0,0,0.18)",s.stroke(),s.textAlign="right",s.fillStyle="#606060",s.fillText(this.fitText(s,this.formatContribution(u.contribution),h-3),a.x+a.width-3,d),e.preventDefault(),s.restore()}contributionColor(e,t){if(null==t)return"rgb(200, 200, 200)";let[n,i,r]=e>=0?[198,40,40]:[21,101,192],o=Math.min(1,Math.max(0,-Math.log10(Math.max(t,1e-12))/3)),s=e=>Math.round(255+(e-255)*o);return`rgb(${s(n)}, ${s(i)}, ${s(r)})`}monomerTextColor(e){let t=this._monomerColorCache.get(e);if(null!=t)return t;let n="#333333";try{let t=h.Z.getMonomerLib().getMonomerColors(this._biotype,e);(null==t?void 0:t.backgroundcolor)&&(n=t.backgroundcolor)}catch(e){}return this._monomerColorCache.set(e,n),n}formatContribution(e){let t=Math.abs(e)>=10?e.toFixed(1):e.toFixed(2);return`${e>=0?"+":""}${t}`}fitText(e,t,n){if(n<=0||e.measureText(t).width<=n)return t;let i=t;for(;i.length>1&&e.measureText(`${i}…`).width>n;)i=i.slice(0,-1);return i.length>1?`${i}…`:i}showBasisTooltip(e,t,n){var i,r,o;let s=null==(r=e.tableColumn)?void 0:r.name;if(!e.isTableCell||null==s||!this._basisPositionSet.has(s)||null==e.tableRowIndex)return!1;let a=null!=(i=null==(o=this._basisByPosition[s])?void 0:o[e.tableRowIndex])?i:null;if(null==a||!a.monomer||null==this._scaledActivityCol)return!1;let l={monomerOrCluster:a.monomer,positionOrClusterType:s};(0,p.dl)(l,this.dataFrame,this.monomerPositionStats);let u=a.contribution>=0?"raises":"lowers",d={Monomer:e.cell.valueString,"Circle size":`effect magnitude |Δ| = ${Math.abs(a.contribution).toFixed(2)}`,"Circle color":null==a.pValue?`${u} activity (significance: n/a — too few samples)`:`${u} activity, significance p = ${a.pValue<.001?a.pValue.toExponential(1):a.pValue.toFixed(3)}`};return(0,m.D)(this.dataFrame,this._scaledActivityCol,[],{monomerPosition:l,x:t,y:n,mpStats:this.monomerPositionStats,fromViewer:!0,additionalStats:d})}generatePeptides(){let e=this.dataFrame.getCol(this.sequenceColumnName),t=(0,p.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling);this._scaledActivityCol=t;let n=this.dataFrame.filter.anyFalse?o.Stats.fromColumn(t,this.dataFrame.filter).avg:t.stats.avg,i=this.getPositionColumns(),r=this.monomerPositionStats,s=this.activityTarget===c.wf.HIGH,a=[];for(let e of i){let t=e.name,i=r[t];if(!i)continue;let o=[],l=null,u=!1;for(let e of Object.keys(i)){if("general"===e)continue;let r=i[e],s=r.count/(r.count+this.shrinkageStrength),a=(r.mean-n)*s,d=null!=r.pValue&&r.pValue<=.05;u||(u=d);let c={position:t,monomer:e,contribution:a,count:r.count,pValue:r.pValue,significant:d,supported:r.count>=this.minSupport};(null===l||c.count>l.count)&&(l=c);let h=r.count>=this.minSupport,p=this.maxPValue>=1||null!=r.pValue&&r.pValue<=this.maxPValue;h&&p&&o.push(c)}if(0===o.length){null!==l&&a.push([l]);continue}if(this.onlySignificantPositions&&!u){a.push([null!=l?l:o[0]]);continue}o.sort((e,t)=>s?t.contribution-e.contribution:e.contribution-t.contribution),a.push(o.slice(0,this.candidatesPerPosition))}let l=this.beamSearch(a,s),u=a.map(e=>e[0].position);return this.buildResultDataFrame(l,e,n,u)}beamSearch(e,t){let n=Math.max(this.beamWidth,this.peptideCount*(this.excludeExisting?2:1)),i=(e,n)=>t?n-e:e-n,r=[{monomers:[],candidates:[],cumContribution:0}];for(let t of e){let e=[];for(let n of r)for(let i of t)e.push({monomers:[...n.monomers,i.monomer],candidates:[...n.candidates,i],cumContribution:n.cumContribution+i.contribution});e.sort((e,t)=>i(e.cumContribution,t.cumContribution)),r=e.slice(0,n)}return r}buildResultDataFrame(e,t,n,i){var r;let s=h.Z.getSeqHelper().getSeqHandler(t),a=null!=(r=y.b9[s.notation])?r:y._S,l=s.joiner,u=new Set(s.isHelm()?t.categories.map(e=>(null==e?void 0:e.endsWith("V2.0"))||(null==e?void 0:e.endsWith("V1.0"))?e.substring(0,e.length-4):e):t.categories),d=[],c=[],p=[],f=[],m=[],g=[],b=[],_=[],w=[];for(let t of e){let e=l(new v.Mu(t.monomers,a)),i=!u.has(e);if(this.excludeExisting&&!i)continue;if(d.length>=this.peptideCount)break;let r=Math.max(t.candidates.filter(e=>e.supported||e.significant).length,1),s=0,h=0,y=1/0,x=0,k=0;for(let e of t.candidates)e.significant&&++s,e.supported&&++h,y=Math.min(y,e.count),null!=e.pValue&&(x+=e.pValue,++k);let S=[...t.candidates].sort((e,t)=>Math.abs(t.contribution)-Math.abs(e.contribution)).slice(0,5).map(e=>`${e.position}:${e.monomer}(${e.contribution>=0?"+":""}${e.contribution.toFixed(2)})`).join(", ");d.push(e),c.push(n+t.cumContribution),p.push(0===h?0:s/r),f.push(y===1/0?0:y),m.push(0===k?o.FLOAT_NULL:x/k),g.push(s),b.push(i),_.push(S),w.push(t.candidates)}let x=[s.getNewColumnFromList("Peptide",d),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"Predicted activity",c),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"Confidence",p),o.Column.fromList(o.COLUMN_TYPE.INT,"Min support",f),o.Column.fromList(o.COLUMN_TYPE.FLOAT,"Mean p-value",m),o.Column.fromList(o.COLUMN_TYPE.INT,"Significant positions",g),o.Column.fromList(o.COLUMN_TYPE.BOOL,"Novel",b),o.Column.fromList(o.COLUMN_TYPE.STRING,"Basis",_)];this._basisByPosition={},this._basisPositionNames=[],this._rowMaxAbsContribution=w.map(e=>e.reduce((e,t)=>Math.max(e,Math.abs(t.contribution)),0));let k=new Set(x.map(e=>e.name));for(let e=0;e<i.length;++e){let t=i[e];for(;k.has(t);)t=`${t} `;k.add(t);let n=w.map(t=>{var n;return null!=(n=t[e])?n:null});x.push(o.Column.fromStrings(t,n.map(e=>{var t;return null!=(t=null==e?void 0:e.monomer)?t:""}))),this._basisByPosition[t]=n,this._basisPositionNames.push(t)}this._basisPositionSet=new Set(this._basisPositionNames);let S=o.DataFrame.fromColumns(x);return S.name="Generated Peptides",S}constructor(){super(),this._grid=null,this._positionColumns=null,this._monomerPositionStats=null,this._scaledActivityCol=null,this._basisByPosition={},this._basisPositionNames=[],this._basisPositionSet=new Set,this._rowMaxAbsContribution=[],this._monomerColorCache=new Map,this._biotype=_.oE.AA,this._propChangeTimer=null,this._currentCellSub=null,this.sequenceColumnName=this.column("sequence",{semType:o.SEMTYPE.MACROMOLECULE,nullable:!1}),this.activityColumnName=this.column("activity",{columnTypeFilter:"numerical",nullable:!1}),this.activityScaling=this.string("activityScaling",c.rg.NONE,{choices:Object.values(c.rg),nullable:!1,description:"Activity transformation applied before computing statistics"}),this.activityTarget=this.string("activityTarget",c.wf.HIGH,{choices:Object.values(c.wf),nullable:!1,description:"Whether to design peptides that maximize (High) or minimize (Low) the scaled activity"}),this.peptideCount=this.int("peptideCount",50,{min:1,max:1e3,description:"How many peptides to generate"}),this.candidatesPerPosition=this.int("candidatesPerPosition",3,{min:1,max:10,description:"Number of best-performing monomers considered at each position"}),this.beamWidth=this.int("beamWidth",100,{min:1,max:2e3,description:"Beam search width. Larger values explore more combinations at higher cost"}),this.minSupport=this.int("minSupport",3,{min:1,max:1e3,description:"Minimum number of observed sequences backing a monomer for it to be trusted"}),this.maxPValue=this.float("maxPValue",1,{min:0,max:1,description:"Only consider monomers with a t-test p-value at or below this value (1 = no filtering)"}),this.shrinkageStrength=this.float("shrinkageStrength",5,{min:0,max:100,description:"Shrinks each position's contribution towards zero by a factor of count/(count+k), damping poorly-supported monomers so they cannot inflate the predicted activity. 0 disables shrinkage (raw additive model, prone to over-prediction)"}),this.excludeExisting=this.bool("excludeExisting",!0,{description:"Exclude generated peptides that already exist in the source data"}),this.onlySignificantPositions=this.bool("onlySignificantPositions",!1,{description:"Vary only positions that have at least one statistically significant monomer; keep the most common monomer elsewhere"})}}},2747(e,t,n){"use strict";n.d(t,{UJ:()=>I,ds:()=>T,J:()=>N,xN:()=>P});var i,r=n(4328),o=n(7389),s=n(6082),a=n(1757),l=n.n(a),u=n(1858),d=n(9713),c=n(3629),h=n(8154),p=n(8285),f=n(1991),m=n.n(f),g=n(7545),v=n(586),b=n(5408),y=n(8750),_=n(7351),w=n(1381),x=n(8621),k=n(7461),S=n(8509),C=n(5013),A=n(7563);function O(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function E(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){O(o,i,r,s,a,"next",e)}function a(e){O(o,i,r,s,a,"throw",e)}s(void 0)})}}var T=((i={}).MUTATION_CLIFFS="Mutation Cliffs",i.INVARIANT_MAP="Invariant Map",i);class P extends s.JsViewer{get onRendered(){return this._onRendered}get isRenderPending(){var e,t;return this._cliffsPending||this._cliffsRunning>0||this._filterPending||this._cellPending||null!==this._repaintTimer||null!=(e=null==(t=this._viewerGrid)?void 0:t.isRenderPending)&&e}get immediateRendering(){return super.immediateRendering}set immediateRendering(e){super.immediateRendering=e,this._viewerGrid&&(this._viewerGrid.immediateRendering=e)}getWidgetStatus(){return function(e){var t,n,i,r,o,a,l;let u=e._viewerGrid,d=u&&e.root.contains(u.root)&&u.canvas.getBoundingClientRect().width>0&&u.canvas.getBoundingClientRect().height>0?u.getWidgetStatus():null,h={},p={"activity scaling":e.activityScaling,"data source":e.dataSource},f={parts:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({root:e.root},null==d?void 0:d.parts),hitAreas:h,values:p,shortcuts:{},events:[],description:null,error:(null==(t=e.root.textContent)?void 0:t.includes("Please, select a sequence and activity columns"))?"Please, select a sequence and activity columns in the viewer properties":null};e.dataFrame&&(p["rows shown"]="All"===e.dataSource?e.dataFrame.rowCount:e.dataFrame.filter.trueCount),e._positionColumns&&(p.positions=e._positionColumns.length);let m=e._monomerPositionStats;if(m){let e=0,t=new Set;for(let[n,i]of Object.entries(m))if("general"!==n)for(let[n,r]of Object.entries(i))"general"!==n&&"count"in r&&!(r.count<=0)&&(e++,t.add(n));p["cells with stats"]=e,p.monomers=t.size}let g=e._mutationCliffs;if(g){let e=0,t=0,n=new Set;for(let i of g.values())for(let r of i.values())for(let[i,o]of(r.size>0&&e++,r))for(let e of(t+=o.length,o))n.add(i<e?`${i}-${e}`:`${e}-${i}`);p["cliff cells"]=e,p["cliff pairs"]=t,p["unique cliff pairs"]=n.size}let v=e instanceof N&&e.dataFrame?e.mode:T.INVARIANT_MAP;e instanceof N&&(p.mode=v);let b=v===T.MUTATION_CLIFFS?e._mutationCliffsSelection:e._invariantMapSelection;if(p["selected monomer-positions"]=Object.entries(null!=b?b:{}).flatMap(([e,t])=>t.map(t=>`${e}:${t}`)).join(", "),!d||!u)return f;let y=u.canvas.getBoundingClientRect();for(let[t,b]of(h.view={x:0,y:0,width:y.width,height:y.height},f.shortcuts.ContextMenu="view",Object.entries(d.hitAreas))){(t.startsWith("header ")||t.includes("scroll "))&&(h[t]=b);let d=/^cell (\d+) of (.+)$/.exec(t);if(!d)continue;let f=Number(d[1])-1,y=d[2],_=u.dataFrame.get(c.$2.MONOMER,f);if(e instanceof N){y===c.$2.MONOMER&&(h[`monomer ${_}`]=b);let t=null==m||null==(r=m[y])?void 0:r[_];if(!(null==(o=e._positionColumns)?void 0:o.some(e=>e.name===y))||!(null==t?void 0:t.count))continue;let u=`cell ${_} at ${y}`;if(h[u]=b,p[`count of ${u}`]=t.count,p[`mean difference of ${u}`]=t.meanDifference,p[`p-value of ${u}`]=null!=(n=t.pValue)?n:"",p[`value of ${u}`]=null!=(i=t.aggValue)?i:t.count,g){let e=null==(a=g.get(_))?void 0:a.get(y);p[`cliffs of ${u}`]=e?Array.from(e.values()).reduce((e,t)=>e+t.length,0):0}if(v===T.INVARIANT_MAP){let t=null==(l=e._positionColumns.find(e=>e.name===y).temp[c.gp.INVARIANT_MAP_COLOR_CACHE])?void 0:l[_];void 0!==t&&(p[`color of ${u}`]=s.Color.toHtml(t))}}else if(e instanceof I){let e=u.dataFrame.get(c.$2.POSITION,f);"Diff"===y?h[`position ${e}`]=b:y===c.$2.MONOMER&&(h[`monomer of position ${e}`]=b)}}if(e instanceof N&&e.monomerSearchInput.input.getBoundingClientRect().width>0){let t=e.monomerSearchInput.input.getBoundingClientRect();h.search={x:t.left-y.left,y:t.top-y.top,width:t.width,height:t.height}}if(e instanceof I){let e=u.dataFrame;p.positions=e.rowCount,p["rows shown"]=e.filter.trueCount;let t={monomer:c.$2.MONOMER,"mean difference":c.$2.MEAN_DIFFERENCE,"p-value":c.$2.P_VALUE,count:c.$2.COUNT,ratio:c.$2.RATIO};for(let n=0;n<e.rowCount;n++){let i=e.get(c.$2.POSITION,n);for(let[r,o]of Object.entries(t)){let t=e.getCol(o);p[`${r} at ${i}`]=t.isNone(n)?"":t.get(n)}}}return f}(this)}onCurrentGridCellChanged(e,t){this._gridSubscriptions.push(e.onCurrentCellChanged.pipe((0,d.tap)(()=>this._cellPending=!0),(0,d.debounce)(()=>u.timer(500*!this.immediateRendering))).subscribe(e=>{try{t(e)}finally{this._cellPending=!1}}))}repaintGridLater(e){null!==this._repaintTimer&&clearTimeout(this._repaintTimer),this._repaintTimer=setTimeout(()=>{this._repaintTimer=null,e.invalidate()},300*!this.immediateRendering)}get viewerGrid(){if(!this._viewerGrid){for(let e of this._gridSubscriptions)e.unsubscribe();this._gridSubscriptions=[],this._cellPending=!1,null!==this._repaintTimer&&clearTimeout(this._repaintTimer),this._repaintTimer=null,this._viewerGrid=this.createViewerGrid(),this._viewerGrid.root.setAttribute("name",`${this.name.replace(/ /g,"-")}-grid`),this._viewerGrid.immediateRendering=this.immediateRendering,this._gridSubscriptions.push(this._viewerGrid.onAfterDrawContent.subscribe(()=>this._onRendered.next()))}return this._viewerGrid}render(){}get alphabet(){var e;return null!=(e=this.dataFrame.getCol(this.sequenceColumnName).getTag(w.gp.alphabet))?e:x.YI.UN}get model(){return p.i.getInstance(this.dataFrame)}get positionColumns(){var e,t;if(null!=this._positionColumns)return this._positionColumns;let n=e=>{let t=this.model.findViewer(e);return this.sequenceColumnName===(null==t?void 0:t.sequenceColumnName)?t._positionColumns:null};return null!=this.model.positionColumns&&this.sequenceColumnName===(null==(t=this.model.settings)?void 0:t.sequenceColumnName)?this._positionColumns=this.model.positionColumns:this instanceof N?this._positionColumns=n(p.q.MOST_POTENT_RESIDUES):this instanceof I&&(this._positionColumns=n(p.q.SEQUENCE_VARIABILITY_MAP)),null!=this._positionColumns||(this._positionColumns=null!=(e=n(p.q.LOGO_SUMMARY_TABLE))?e:(0,_.R)(this.dataFrame.getCol(this.sequenceColumnName),C.Z.getSeqHelper()).columns.toList()),this._positionColumns}propagateCanonicalizerTag(e){var t,n,i;let r=null==(i=this.dataFrame)?void 0:i.col(this.sequenceColumnName);if(!r)return;let o=null!=(t=r.temp[A.j.notationProvider])?t:null,s=null!=(n=null==o?void 0:o.monomerCanonicalizerFuncName)?n:null;s&&e.setTag(w.jz,s)}get monomerPositionStats(){if(null!=this._monomerPositionStats)return this._monomerPositionStats;let e=e=>this.sequenceColumnName===(null==e?void 0:e.sequenceColumnName)&&this.activityColumnName===(null==e?void 0:e.activityColumnName)&&this.activityScaling===(null==e?void 0:e.activityScaling)&&e instanceof P&&e.dataSource===this.dataSource&&(e instanceof P&&this.valueColumnName==(null==e?void 0:e.valueColumnName)&&this.valueAggregation==(null==e?void 0:e.valueAggregation)||!(e instanceof P)&&(!this.valueColumnName||!this.valueAggregation||this.valueAggregation==s.AGG.VALUE_COUNT||this.valueAggregation==s.AGG.TOTAL_COUNT)),t=t=>{let n=this.model.findViewer(t);return e(n)?n._monomerPositionStats:null};null!==this.model.monomerPositionStats&&e(this.model.settings)?this._monomerPositionStats=this.model.monomerPositionStats:this instanceof N?this._monomerPositionStats=t(p.q.MOST_POTENT_RESIDUES):this instanceof I&&(this._monomerPositionStats=t(p.q.SEQUENCE_VARIABILITY_MAP));let n=this.dataFrame.col(this.valueColumnName),i=this.valueAggregation;return null!=this._monomerPositionStats||(this._monomerPositionStats=(0,b.Ej)(this.getScaledActivityColumn(),this.dataFrame.filter,this.positionColumns,{isFiltered:"Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse,aggValue:i&&n?{col:n,type:i}:void 0})),this._monomerPositionStats}get mutationCliffs(){if(null!=this._mutationCliffs)return this._mutationCliffs;let e=e=>{let t=this.model.findViewer(e);return this.sequenceColumnName===(null==t?void 0:t.sequenceColumnName)&&this.activityColumnName===(null==t?void 0:t.activityColumnName)&&this.activityScaling===(null==t?void 0:t.activityScaling)&&this.minActivityDelta===(null==t?void 0:t.minActivityDelta)&&this.maxMutations===(null==t?void 0:t.maxMutations)&&(null==this?void 0:this.dataSource)===(null==t?void 0:t.dataSource)?t._mutationCliffs:null};return this instanceof N?this._mutationCliffs=e(p.q.MOST_POTENT_RESIDUES):this instanceof I&&(this._mutationCliffs=e(p.q.SEQUENCE_VARIABILITY_MAP)),this._mutationCliffs}set mutationCliffs(e){this._mutationCliffs=e,this.isDetached||this.viewerGrid.invalidate()}get cliffStats(){return!this._mutationCliffStats&&this.mutationCliffs&&this.activityColumnName&&this.sequenceColumnName&&this.dataFrame.col(this.activityColumnName)&&(this._mutationCliffStats=(0,b.Lw)(this.mutationCliffs,this.getScaledActivityColumn().getRawData())),this._mutationCliffStats}set cliffStats(e){this._mutationCliffStats=e,this.isDetached||this.viewerGrid.invalidate()}get mutationCliffsSelection(){return null!=this._mutationCliffsSelection||(this._mutationCliffsSelection=(0,y.ZR)(this.positionColumns)),this._mutationCliffsSelection}set mutationCliffsSelection(e){var t,n;this._mutationCliffsSelection=e,this.model.fireBitsetChanged(this instanceof N?p.q.SEQUENCE_VARIABILITY_MAP:p.q.MOST_POTENT_RESIDUES);let i=this.model.findViewer(p.q.SEQUENCE_VARIABILITY_MAP);null==i||null==(t=i.viewerGrid)||t.invalidate();let r=this.model.findViewer(p.q.MOST_POTENT_RESIDUES);null==r||null==(n=r.viewerGrid)||n.invalidate(),this.model.analysisView.grid.invalidate()}getScaledActivityColumn(e=!1){var t,n;return((null==(t=this.model.settings)?void 0:t.activityColumnName)===this.activityColumnName&&(null==(n=this.model.settings)?void 0:n.activityScaling)===this.activityScaling&&(this._scaledActivityColumn=this.model.getScaledActivityColumn(e)),null!=this._scaledActivityColumn||(this._scaledActivityColumn=(0,y.Y1)(this.dataFrame.getCol(this.activityColumnName),this.activityScaling)),e)?s.DataFrame.fromColumns([this._scaledActivityColumn]).clone(this.dataFrame.filter).getCol(this._scaledActivityColumn.name):this._scaledActivityColumn}modifyMutationCliffsSelection(e,t={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.mutationCliffsSelection=(0,y.vW)(this.mutationCliffsSelection,e,t):this._mutationCliffsSelection=(0,y.vW)(this.mutationCliffsSelection,e,t)}modifyInvariantMapSelection(e,t={shiftPressed:!1,ctrlPressed:!1},n=!0){n?this.invariantMapSelection=(0,y.vW)(this.invariantMapSelection,e,t):this._invariantMapSelection=(0,y.vW)(this.invariantMapSelection,e,t)}get invariantMapSelection(){return null!=this._invariantMapSelection||(this._invariantMapSelection=(0,y.ZR)(this.positionColumns)),this._invariantMapSelection}set invariantMapSelection(e){this._invariantMapSelection=e,this.model.fireBitsetChanged(p.q.SEQUENCE_VARIABILITY_MAP),this.model.analysisView.grid.invalidate()}onPropertyChanged(e){if(super.onPropertyChanged(e),this.dataFrame){switch(this.doRender=!0,e.name){case`sequence${c.To}`:this._positionColumns=null,this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._viewerGrid=null;break;case`activity${c.To}`:case"activityScaling":this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._viewerGrid=null,this._scaledActivityColumn=null;break;case`value${c.To}`:case"valueAggregation":this._monomerPositionStats=null,this._viewerGrid=null,this._invariantMapSelection=null;break;case"minActivityDelta":case"maxMutations":this._mutationCliffs=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this.doRender=!1;break;case"columns":case"aggregation":this instanceof I&&(this._viewerGrid=null);break;case"activityTarget":(this instanceof I||this instanceof N)&&(this._viewerGrid=null);break;case"dataSource":this.onFilterChanged(!1,!1),this.doRender=!0}null===this._mutationCliffs&&this.sequenceColumnName&&this.activityColumnName&&this.dataFrame&&this.calculateMutationCliffs().then(e=>{this.mutationCliffs=e.cliffs,this.cliffStats=e.cliffStats})}}getAggregationColumns(){return Object.fromEntries(this.columns.map(e=>[e,this.aggregation]).filter(([e,t])=>this.model.df.columns.contains(e)&&this.model.df.col(e).matches("numerical")))}getTotalViewerAggColumns(){var e,t;let n=this.getAggregationColumns();return(0,y.zm)(this.model.df,this.columns,n,null==(t=this.model)||null==(e=t.settings)?void 0:e.columns)}createViewerGrid(){throw Error("Not implemented")}exportMutationCliffs(){if(!this.mutationCliffs)return void r.shell.warning("Mutation cliffs have not been calculated yet.");let e=this.dataFrame.columns.toList().filter(e=>e.name!==this.activityColumnName&&e.name!==this.sequenceColumnName&&!this.positionColumns.some(t=>t.name===e.name)).map(e=>e.name),t=o.input.columns("Extra columns",{table:this.dataFrame,value:[],available:e,nullable:!0});o.dialog("Export Mutation Cliffs").add(t.root).onOK(()=>{var e;return this._doExportMutationCliffs(null!=(e=t.value)?e:[])}).show()}_doExportMutationCliffs(e){var t;let n=this.mutationCliffs,i=this.dataFrame.getCol(this.sequenceColumnName),o=i.categories,a=i.getRawData(),l=this.dataFrame.getCol(this.activityColumnName),u=l.getRawData(),d=[],h=[],p=[],f=[],m=[],g=[],v=e.map(()=>[]),b=e.map(()=>[]),_=new Set;for(let[t,i]of n.entries())for(let[t,n]of i.entries())for(let[t,i]of n.entries())for(let n of i){let i=t<n?`${t}-${n}`:`${n}-${t}`;if(_.has(i))continue;_.add(i);let r=o[a[t]],s=o[a[n]];d.push(r),h.push(s),p.push(`${r}#${s}`);let c=l.isNone(t)?null:u[t],y=l.isNone(n)?null:u[n];f.push(c),m.push(y),g.push(null==c||null==y?null:c-y);for(let i=0;i<e.length;i++){let r=e[i];v[i].push(r.isNone(t)?null:r.get(t)),b[i].push(r.isNone(n)?null:r.get(n))}}if(0===d.length)return void r.shell.warning("No mutation cliffs found to export.");let w=s.Column.fromStrings("Seq 1",d),x=s.Column.fromStrings("Seq 2",h),k=s.Column.fromStrings("Mutation",p);for(let e of[w,x]){for(let t of i.tags.keys())".notationProvider"!==t&&e.setTag(t,i.getTag(t));e.semType=i.semType}k.semType=c.uF.MACROMOLECULE_DIFFERENCE,k.setTag(c.gp.SEPARATOR,(0,y.AY)(i)),k.setTag(s.TAGS.UNITS,null!=(t=i.getTag(s.TAGS.UNITS))?t:""),k.setTag(s.TAGS.CELL_RENDERER,"MacromoleculeDifference"),k.temp[A.j.notationProvider]=i.temp[A.j.notationProvider];let S=e=>Float64Array.from(e,e=>null!=e?e:s.FLOAT_NULL),C=[w,x,k,s.Column.fromFloat64Array(`Seq 1 ${this.activityColumnName}`,S(f)),s.Column.fromFloat64Array(`Seq 2 ${this.activityColumnName}`,S(m)),s.Column.fromFloat64Array("Delta",S(g))];for(let t=0;t<e.length;t++){let n=e[t].name,i=e[t].type;C.push(s.Column.fromList(i,`Seq 1 ${n}`,v[t])),C.push(s.Column.fromList(i,`Seq 2 ${n}`,b[t]))}let O=s.DataFrame.fromColumns(C);O.name="Mutation Cliffs",r.shell.addTableView(O)}exportInvariantMap(){let e=this.monomerPositionStats,t=new Set,n=[];for(let i of Object.keys(e))if("general"!==i)for(let r of(n.push(i),Object.keys(e[i])))"general"!==r&&t.add(r);let i=Array.from(t).sort(),o=[s.Column.fromStrings(c.$2.MONOMER,i)];for(let t of n){let n=e[t],r=i.map(e=>{var t,i;return null!=(t=null==(i=n[e])?void 0:i.count)?t:0});o.push(s.Column.fromList(s.COLUMN_TYPE.INT,t,r))}let a=s.DataFrame.fromColumns(o);a.name="Invariant Map",r.shell.addTableView(a)}detach(){for(let e of(this.subs.forEach(e=>e.unsubscribe()),this._gridSubscriptions))e.unsubscribe();null!==this._repaintTimer&&clearTimeout(this._repaintTimer),this._onRendered.complete(),super.detach()}onTableAttached(){if(super.onTableAttached(),(0,y.B2)(this.dataFrame)){var e,t,n,i;null==(e=this.getProperty(`sequence${c.To}`))||e.set(this,this.dataFrame.columns.bySemType(s.SEMTYPE.MACROMOLECULE).name);let o=null==(t=m()(this.dataFrame.columns.numerical).find(e=>e.name.toLowerCase().includes("activity")))?void 0:t.name;null==(n=this.getProperty(`activity${c.To}`))||n.set(this,null!=o?o:m()(this.dataFrame.columns.numerical).next().value.name),null==(i=this.getProperty(`value${c.To}`))||i.set(this,null!=o?o:m()(this.dataFrame.columns.numerical).next().value.name),null===this.mutationCliffs&&this.sequenceColumnName&&this.activityColumnName&&this.calculateMutationCliffs().then(e=>{this.mutationCliffs=e.cliffs,this.cliffStats=e.cliffStats}),this.subs.push(r.events.onContextMenu.subscribe(e=>{if(!e||!e.causedBy||!e.args||!e.args.menu||!e.causedBy.target||!(e.causedBy.target instanceof HTMLElement)||!this.root.contains(e.causedBy.target))return;let t=e.args.menu,n=t.group("Export");n.item("Export Mutation Cliffs...",()=>this.exportMutationCliffs()),n.item("Export Invariant Map",()=>this.exportInvariantMap()),(0,k.pj)().then(e=>{let n=e.getMonomerLib(),i=n.getMonomerSymbolsByType(S.kC.PEPTIDE).map(e=>n.getMonomer(S.kC.PEPTIDE,e)).filter(Boolean).map(e=>{var t;return null!=(t=e.meta)?t:{}}),r=new Set;i.forEach(e=>Object.keys(e).forEach(e=>r.add(e))),r.delete("colors"),t.group("Monomer Meta").items(Array.from(r),e=>{this._monomerMetaColumns.has(e)?this._monomerMetaColumns.delete(e):this._monomerMetaColumns.add(e),this._viewerGrid=null,this.render()},{isChecked:e=>this._monomerMetaColumns.has(e)})})})),this.subs.push(this.dataFrame.onFilterChanged.pipe((0,d.tap)(()=>this._filterPending=!0),(0,d.debounce)(()=>u.timer(300*!this.immediateRendering))).subscribe(()=>{this._filterPending=!1,"Filtered"===this.dataSource&&this.onFilterChanged(!0,!1)})),this.subs.push(u.merge(this.dataFrame.onRowsRemoved,this.dataFrame.onRowsAdded).subscribe(()=>this.onFilterChanged(!0,!1)))}else{let e="PeptidesError: dataframe is missing Macromolecule or numeric columns";r.log.error(e),r.shell.warning(e)}}onFilterChanged(e,t=!1){if(this._monomerPositionStats=null,this._invariantMapSelection=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._mutationCliffs=null,this._scaledActivityColumn=null,t)return;this._viewerGrid=null;let n=this.model.findViewer(p.q.MOST_POTENT_RESIDUES);!n||this instanceof I||"Filtered"!==n.dataSource||n.onFilterChanged(!1,!0),e&&this.render(),this.sequenceColumnName&&this.activityColumnName&&this.calculateMutationCliffs().then(e=>{this.mutationCliffs=e.cliffs,this.cliffStats=e.cliffStats})}calculateMutationCliffs(){return E(function*(){let e=++this._cliffsGeneration;this._cliffsPending=!0;try{var t;let e=this.getScaledActivityColumn(),n=this.positionColumns.map(y.eY),i="Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse?this.dataFrame.filter:null,r={maxMutations:this.maxMutations,minActivityDelta:this.minActivityDelta,filter:null!=(t=null==i?void 0:i.getBuffer())?t:void 0},o=e.getRawData(),s=yield this.mutationCliffsDebouncer(o,n,r),a=(0,b.Lw)(s,o);return{cliffs:s,cliffStats:a}}finally{e===this._cliffsGeneration&&(this._cliffsPending=!1)}}).call(this)}constructor(){var e;super(),e=this,this.keyPressed=!1,this._scaledActivityColumn=null,this.doRender=!0,this.dataSource="Filtered",this._viewerGrid=null,this._gridSubscriptions=[],this._onRendered=new u.Subject,this._cliffsGeneration=0,this._cliffsPending=!1,this._cliffsRunning=0,this._filterPending=!1,this._cellPending=!1,this._repaintTimer=null,this._positionColumns=null,this._monomerPositionStats=null,this._mutationCliffs=null,this._mutationCliffStats=null,this._invariantMapSelection=null,this._mutationCliffsSelection=null,this._monomerMetaColumns=new Set,this.sequenceColumnName=this.column("sequence",{category:"General",semType:s.SEMTYPE.MACROMOLECULE,nullable:!1}),this.dataSource=this.string("dataSource","Filtered",{category:"General",choices:["All","Filtered"],nullable:!1,description:"Data source for calculations and rendering. Can be set to whole data set or filtered data only."}),this.activityColumnName=this.column("activity",{category:"General",nullable:!1,columnTypeFilter:"numerical"}),this.activityScaling=this.string("activityScaling",c.rg.NONE,{category:"General",choices:Object.values(c.rg),nullable:!1}),this.activityTarget=this.string("activityTarget",c.wf.HIGH,{category:"General",choices:Object.values(c.wf),nullable:!1}),this.targetColumnName=this.column("target",{category:"General",nullable:!0,columnTypeFilter:"categorical",userEditable:!1}),this.minActivityDelta=this.float("minActivityDelta",0,{category:"Mutation Cliffs",min:0,max:100}),this.maxMutations=this.int("maxMutations",1,{category:"Mutation Cliffs",min:1,max:20}),this.columns=this.columnList("columns",[],{category:"Aggregation"}),this.aggregation=this.string("aggregation",s.AGG.AVG,{category:"Aggregation",choices:c.V5}),this.valueColumnName=this.column("value",{category:"Invariant Map",userEditable:!0,nullable:!1,columnTypeFilter:"numerical"}),this.valueAggregation=this.string("valueAggregation",s.AGG.TOTAL_COUNT,{category:"Invariant Map",choices:c.V5,userEditable:!0,nullable:!1}),this.mutationCliffsDebouncer=(0,y.sg)((t,n,i)=>E(function*(){e._cliffsRunning++;try{return yield(0,b.uz)(t,n,i)}finally{e._cliffsRunning--}})()),this.root.classList.add("peptides-viewer-show-title")}}class N extends P{get name(){return p.q.SEQUENCE_VARIABILITY_MAP}get mode(){var e;return null!=(e=this.dataFrame.getTag(c.gp.MONOMER_POSITION_MODE))?e:"Mutation Cliffs"}set mode(e){this.dataFrame.setTag(c.gp.MONOMER_POSITION_MODE,e),this.viewerGrid.invalidate()}onTableAttached(){if(super.onTableAttached(),(0,y.B2)(this.dataFrame)){var e;null==(e=this.getProperty(`color${c.To}`))||e.set(this,this.activityColumnName)}else{let e="PeptidesError: dataframe is missing Macromolecule or numeric columns";r.log.error(e),r.shell.warning(e)}this.render()}onPropertyChanged(e){var t;if(super.onPropertyChanged(e),this.dataFrame){switch(e.name){case"sequence":this._invariantMapSelection=null;break;case"showTotalCountColumn":this._viewerGrid&&this._viewerGrid.columns.byName(c.$2.TOTAL_COUNT)&&(this._viewerGrid.columns.byName(c.$2.TOTAL_COUNT).visible=this.showTotalCountColumn,this.doRender=!1)}null==(t=this.positionColumns)||t.forEach(e=>{e.temp[c.gp.INVARIANT_MAP_COLOR_CACHE]=null}),this.doRender?this.render():this.viewerGrid.invalidate()}}createMonomerPositionDf(){let e=new Set,t=this.positionColumns;for(let t of Object.keys(this.monomerPositionStats))if("general"!==t)for(let n of Object.keys(this.monomerPositionStats[t]))"general"!==n&&e.add(n);let n=Array.from(e),i=s.Column.fromStrings(c.$2.MONOMER,n),r=s.DataFrame.fromColumns([i]),o=(0,k.pj)().then(e=>{let t=e.getMonomerLib();return t?n.map(e=>{var n,i;return null!=(n=null==(i=t.getMonomer(S.kC.PEPTIDE,e))?void 0:i.meta)?n:{}}):n.map(e=>({}))}),a=r.columns.addNewInt(c.$2.TOTAL_COUNT),l={},u=this.monomerPositionStats;for(let e of Object.keys(u)){if("general"===e)continue;let t=u[e];for(let e of Object.keys(t))"general"!==e&&(l[e]||(l[e]=0),l[e]+=t[e].count)}for(let e of(a.init(e=>{var t;return null!=(t=l[i.get(e)])?t:0}),this._monomerMetaColumns.forEach(e=>{let t=r.columns.addNewString(e);o.then(n=>{t.init(t=>{var i,r;return null!=(i=null==(r=n[t][e])?void 0:r.toString())?i:""})})}),r.name="SAR",t))r.columns.addNewBool(e.name);return r}cacheInvariantMapColors(){if(this.colorColumnName&&this.dataFrame.col(this.colorColumnName)){let e=this.dataFrame.getCol(this.colorColumnName).getRawData(),t=9999999,n=-9999999,i="Filtered"===this.dataSource&&this.dataFrame.filter.anyFalse?this.dataFrame.filter:null,r=null==i?e=>!0:e=>i.get(e);for(let i of this.positionColumns){i.temp[c.gp.INVARIANT_MAP_COLOR_CACHE]={};let o=i.temp[c.gp.INVARIANT_MAP_COLOR_CACHE],a=i.name,l=i.getRawData(),u=i.categories;if(this.monomerPositionStats[a]){for(let d of Object.keys(this.monomerPositionStats[a])){if("general"===d)continue;let a=[];for(let e=0;e<i.length;++e)u[l[e]]===d&&r(e)&&a.push(e);let c=s.Column.float("color",a.length).init(t=>e[a[t]]).aggregate(this.colorAggregation);o[d]=c,t=Math.min(t,c),n=Math.max(n,c)}i.temp[c.gp.INVARIANT_MAP_COLOR_CACHE]=o}}let o=this.customColorRange&&null!=this.minColorValue&&null!=this.maxColorValue,a=o?this.minColorValue:t,l=o?this.maxColorValue:n,u=this.logScaleColor&&a>1e-30&&l>1e-30&&t>1e-30&&n>1e-30;for(let e of(u&&(a=Math.log(a),l=Math.log(l)),this.positionColumns)){let i=e.temp[c.gp.INVARIANT_MAP_COLOR_CACHE];if(i){for(let e of Object.keys(i))this.activityTarget===c.wf.LOW&&(i[e]=l-i[e]+a),i[e]=s.Color.scaleColor(u?Math.log(i[e]):i[e],a,l,void 0,[this.lowerBoundColor,this.middleColor,this.upperBoundColor]);e.temp[c.gp.INVARIANT_MAP_COLOR_CACHE]=i,e.temp[c.gp.INVARIANT_MAP_COLOR_MIN_CACHE]=t,e.temp[c.gp.INVARIANT_MAP_COLOR_MAX_CACHE]=n}}}}createViewerGrid(){let e=this.createMonomerPositionDf(),t=e.plot.grid();t.sort([c.$2.MONOMER]);let n=this.positionColumns.map(e=>e.name);t.columns.setOrder([c.$2.TOTAL_COUNT,c.$2.MONOMER,...this._monomerMetaColumns,...n]);let i=t.columns.byName(c.$2.TOTAL_COUNT);this.showTotalCountColumn&&null!=i?i.visible=!0:null!=i&&(i.visible=!1);let r=e.getCol(c.$2.MONOMER);h.rI(r,this.alphabet,!0),this.propagateCanonicalizerTag(r),this.cacheInvariantMapColors(),t.onCellRender.subscribe(e=>M(e,this,"Invariant Map"===this.mode,this.dataFrame.getCol(this.colorColumnName),this.colorAggregation)),t.onCellTooltip((e,t,n)=>{var i,r,o,a,l,u,d;if(!e.isTableCell||!(null==e||null==(r=e.cell.column)?void 0:r.name)||this._monomerMetaColumns.has(e.cell.column.name)||e.cell.column.name===c.$2.TOTAL_COUNT)return this.model.unhighlight(),!0;let h=this.getMonomerPosition(e);this.model.highlight(h,this.monomerPositionStats);let p=this.getTotalViewerAggColumns(),f={},m={};if("Invariant Map"===this.mode)this.colorColumnName&&this.colorAggregation&&this.colorColumnName!==this.valueColumnName?(p.unshift([this.colorColumnName,this.colorAggregation]),f[`${this.colorAggregation}(${this.colorColumnName})`]=" (color)"):this.colorColumnName&&this.colorAggregation&&this.colorColumnName===this.valueColumnName&&(f["Mean activity"]=" (color)"),this.valueColumnName&&this.valueAggregation&&this.valueAggregation!==s.AGG.VALUE_COUNT&&this.valueAggregation!==s.AGG.TOTAL_COUNT&&p.unshift([this.valueColumnName,this.valueAggregation]);else{let e=null==(d=this.mutationCliffs)||null==(u=d.get(h.monomerOrCluster))?void 0:u.get(h.positionOrClusterType);if(e){let t=0;for(let n of e.values())t+=n.length;m["Pairs count"]=t.toString()}}return(0,v.D)(this.model.df,this.getScaledActivityColumn(),p,{fromViewer:!0,isMutationCliffs:"Mutation Cliffs"===this.mode,monomerPosition:h,x:t,y:n,mpStats:this.monomerPositionStats,cliffStats:null!=(i=null==(o=this.cliffStats)?void 0:o.stats)?i:void 0,postfixes:f,additionalStats:m,cliffIndexes:null==(l=this.mutationCliffs)||null==(a=l.get(h.monomerOrCluster))?void 0:a.get(h.positionOrClusterType)})}),t.root.addEventListener("mouseleave",e=>this.model.unhighlight()),this.onCurrentGridCellChanged(t,e=>{var n,i,r,o,a,l,u,d,h,f,m,g,v;try{if(!e||!e.dart||!(null==e||null==(i=e.cell)||null==(n=i.column)?void 0:n.name)||this._monomerMetaColumns.has(e.cell.column.name)||e.cell.column.name==c.$2.TOTAL_COUNT||!e.isTableCell||(-1===e.gridRow&&("Invariant Map"===this.mode?this._invariantMapSelection=(0,y.ZR)(this.positionColumns):this._mutationCliffsSelection=(0,y.ZR)(this.positionColumns),this.model.fireBitsetChanged(p.q.SEQUENCE_VARIABILITY_MAP),t.invalidate()),!this.keyPressed||e.cell.column.name===c.$2.MONOMER))return;if(null!==this.currentGridCell){let e=this.getMonomerPosition(this.currentGridCell);"Invariant Map"===this.mode?this.modifyInvariantMapSelection(e,{shiftPressed:!0,ctrlPressed:!0},!1):(null==(a=this.mutationCliffs)||null==(o=a.get(e.monomerOrCluster))||null==(r=o.get(e.positionOrClusterType))?void 0:r.size)&&this.modifyMutationCliffsSelection(e,{shiftPressed:!0,ctrlPressed:!0},!1)}let s=this.getMonomerPosition(e);"Invariant Map"===this.mode?this.modifyInvariantMapSelection(s,{shiftPressed:!0,ctrlPressed:!1},!0):(null==(d=this.mutationCliffs)||null==(u=d.get(s.monomerOrCluster))||null==(l=u.get(s.positionOrClusterType))?void 0:l.size)&&this.modifyMutationCliffsSelection(s,{shiftPressed:!0,ctrlPressed:!1},!0),t.invalidate(),this.repaintGridLater(t)}catch(e){console.error(e)}finally{this.keyPressed=!1,(null==(h=e.tableColumn)?void 0:h.name)&&e.grid&&e.isTableCell&&(null==e||null==(f=e.cell)?void 0:f.column.name)!=c.$2.MONOMER&&!this._monomerMetaColumns.has(null==(g=e.cell)||null==(m=g.column)?void 0:m.name)&&(null==(v=e.cell)?void 0:v.column.name)!==c.$2.TOTAL_COUNT?this.currentGridCell=s.GridCell.fromColumnRow(e.grid,e.tableColumn.name,e.gridRow):this.currentGridCell=null}}),t.root.addEventListener("keydown",e=>{if(this.keyPressed=e.key.startsWith("Arrow"),!this.keyPressed){if("Escape"===e.key||"KeyA"===e.code&&(e.ctrlKey||e.metaKey)&&e.shiftKey)"Invariant Map"===this.mode?this._invariantMapSelection=(0,y.ZR)(this.positionColumns):this._mutationCliffsSelection=(0,y.ZR)(this.positionColumns);else if("KeyA"!==e.code||!e.ctrlKey&&!e.metaKey)return;else for(let e of Object.keys(this.monomerPositionStats).filter(e=>"general"!==e))for(let t of Object.keys(this.monomerPositionStats[e]).filter(e=>"general"!==e)){let n={monomerOrCluster:t,positionOrClusterType:e};"Invariant Map"===this.mode?this.modifyInvariantMapSelection(n,{shiftPressed:!0,ctrlPressed:!1},!1):this.modifyMutationCliffsSelection(n,{shiftPressed:!0,ctrlPressed:!1},!1)}this.model.fireBitsetChanged(p.q.SEQUENCE_VARIABILITY_MAP),t.invalidate()}}),t.root.addEventListener("click",n=>{var i,r,o,s,a,l;let u=t.hitTest(n.offsetX,n.offsetY);if(!(null==u?void 0:u.isTableCell)||(null==u||null==(i=u.tableColumn)?void 0:i.name)===c.$2.MONOMER||(null==u||null==(r=u.tableColumn)?void 0:r.name)&&this._monomerMetaColumns.has(u.tableColumn.name)||(null==u||null==(o=u.tableColumn)?void 0:o.name)===c.$2.TOTAL_COUNT)return;let d=this.getMonomerPosition(u);"Invariant Map"===this.mode?(this.modifyInvariantMapSelection(d,{shiftPressed:n.shiftKey,ctrlPressed:n.ctrlKey||n.metaKey}),(0,y.CD)(this.invariantMapSelection)&&(e.currentRowIdx=-1)):(null==(l=this.mutationCliffs)||null==(a=l.get(d.monomerOrCluster))||null==(s=a.get(d.positionOrClusterType))?void 0:s.size)&&this.modifyMutationCliffsSelection(d,{shiftPressed:n.shiftKey,ctrlPressed:n.ctrlKey||n.metaKey}),t.invalidate()}),L(t),t.props.showRowHeader=!0;let o=t.onAfterDrawContent.subscribe(()=>{let e=t.col(c.$2.MONOMER);if(40===e.width)return void o.unsubscribe();for(let i of(e.width=40,n))t.col(i).width=40});return t}getMonomerPosition(e){return{monomerOrCluster:e.cell.dataFrame.get(c.$2.MONOMER,e.tableRowIndex),positionOrClusterType:e.tableColumn.name}}render(){var e;if(l()(this.root).empty(),!this.dataFrame||!this.activityColumnName||!this.sequenceColumnName){this.root.appendChild(o.divText("Please, select a sequence and activity columns in the viewer properties")),this._onRendered.next();return}let t=this.getProperty("color");t&&(t.choices=m()(r.shell.t.columns.numerical).toArray().map(e=>e.name),t.get(this)===c.$2.ACTIVITY_SCALED&&t.set(this,c.$2.ACTIVITY)),l()(this.root).empty();let n=o.divText(p.q.MOST_POTENT_RESIDUES,{id:"pep-viewer-title"});if(this.name===p.q.SEQUENCE_VARIABILITY_MAP){let e=o.input.bool("Mutation Cliffs",{value:"Mutation Cliffs"===this.mode});e.root.addEventListener("click",()=>{t.value=!1,e.value=!0,this.mode="Mutation Cliffs"}),e.setTooltip("Statistically significant changes in activity");let t=o.input.bool("Invariant Map",{value:"Invariant Map"===this.mode});t.root.addEventListener("click",()=>{e.value=!1,t.value=!0,this.mode="Invariant Map"}),t.setTooltip("Number of sequences having monomer-position");let i=e=>{l()(e.root).find(".ui-input-editor").css("margin","0px").attr("type","radio"),l()(e.root).find(".ui-input-description").css("padding","0px").css("padding-right","16px"),l()(e.captionLabel).addClass("ui-label-right")};i(e),i(t),n=o.divH([e.root,t.root],{id:"pep-viewer-title"}),l()(n).css("width","auto").css("align-self","center").css("max-width","100%").css("flex-wrap","wrap").css("height","auto").css("justify-content","center")}let i=this.viewerGrid.root;i.style.width="auto";let s=o.icons.search(()=>{this._showSearchInput=!this._showSearchInput,this.monomerSearchInput.input.style.display=this._showSearchInput?"block":"none"},"Toggle monomer search input visibility");this.monomerSearchInput.input.style.display=this._showSearchInput?"block":"none",l()(s).addClass("pep-help-icon"),(0,y.BX)(s.style).set("top","3px").set("fontSize","14px");let a=o.divH([this.monomerSearchInput.input],{style:{alignSelf:"center",justifyContent:"center",width:"100%",flexWrap:"wrap"}}),u=o.divH([s,n,a],{style:{alignSelf:"center",lineHeight:"normal",flexDirection:"column",width:"100%"}});this.root.appendChild(o.divV([u,i])),null==(e=this.viewerGrid)||e.invalidate(),this.monomerSearchInput.fireChanged()}constructor(){super(),this.currentGridCell=null,this.customColorRange=!1,this.minColorValue=0,this.maxColorValue=0,this.logScaleColor=!1,this.showFilterControls=!0,this.showTotalCountColumn=!1,this._showSearchInput=!1,this.colorColumnName=this.column("color",{category:"Invariant Map",nullable:!1,columnTypeFilter:"numerical"}),this.colorAggregation=this.string("colorAggregation",s.AGG.AVG,{category:"Invariant Map",choices:c.V5}),this.lowerBoundColor=this.int("lowerBoundColor",0xff0000ff,{category:"Invariant Map",editor:"color"}),this.middleColor=this.int("middleColor",0xffffffff,{category:"Invariant Map",editor:"color"}),this.upperBoundColor=this.int("upperBoundColor",0xffff0000,{category:"Invariant Map",editor:"color"}),this.showTotalCountColumn=this.bool("showTotalCountColumn",!1,{category:"General",description:"Show total monomer count column"}),this.logScaleColor=this.bool("logScaleColor",!1,{category:"Invariant Map"}),this.customColorRange=this.bool("customColorRange",!1,{category:"Invariant Map"}),this.minColorValue=this.float("minColorValue",0,{category:"Invariant Map"}),this.maxColorValue=this.float("maxColorValue",0,{category:"Invariant Map"}),this.showFilterControls=this.bool("showFilterControls",!0,{category:"General",description:"Show monomer search and target controls",userEditable:!1}),this.monomerSearchInput=o.input.string("Search",{value:"",nullable:!0,placeholder:"Search monomer",tooltipText:"Search for monomer by symbol. For multiple monomers use comma as a separator.",onValueChanged:()=>{var e,t,n;let i=()=>{var e,t,n;return null==(n=this._viewerGrid)||null==(t=n.dataFrame)||null==(e=t.filter)?void 0:e.setAll(!0)},r=null!=(e=null==(n=this.monomerSearchInput.value)||null==(t=n.trim())?void 0:t.toLowerCase())?e:"";if(!r||null==this._viewerGrid||null==this._viewerGrid.dataFrame)return void i();let o=this._viewerGrid.dataFrame.col(c.$2.MONOMER);if(null==o)return void i();let s=r.split(",").map(e=>e.trim()).filter(e=>!!e),a=o.toList();this._viewerGrid.dataFrame.filter.init(e=>s.some(t=>a[e].toLowerCase().includes(t)))}})}}class I extends P{get name(){return p.q.MOST_POTENT_RESIDUES}onTableAttached(){super.onTableAttached(),this.render()}onPropertyChanged(e){super.onPropertyChanged(e),this.doRender&&this.render()}onFilterChanged(e,t=!1){if(this._monomerPositionStats=null,this._invariantMapSelection=null,this._mutationCliffStats=null,this._mutationCliffsSelection=null,this._mutationCliffs=null,this._scaledActivityColumn=null,t)return;this._viewerGrid=null;let n=this.model.findViewer(p.q.SEQUENCE_VARIABILITY_MAP);(null==n?void 0:n.dataSource)==="Filtered"&&n.onFilterChanged(!1,!0),e&&this.render()}createMostPotentResiduesDf(){let e=Object.entries(this.monomerPositionStats),t=Array(e.length-1),n=Array(t.length),i=Array(t.length),r=Array(t.length),o=Array(t.length),a=Array(t.length),l=Array(t.length),u=this.getTotalViewerAggColumns(),d=u.map(([e,t])=>(0,g.hX)(t,e)),h=Array(d.length);d.forEach((e,n)=>h[n]=Array(t.length));let p=0;for(let[m,v]of e){let e=v.general;if(!e||1===Object.entries(v).length)continue;let b=[];for(let[t,n]of Object.entries(v)){var f;"general"!==t&&(n.count>1&&(null==n.pValue||(null!=(f=n.pValue)?f:1)<=.05)&&b.push([t,n]),n.pValue===e.minPValue&&b.push([t,n]))}let y=null;for(let[e,t]of(0===b.length&&(y=Object.entries(v).find(([e,t])=>"general"!=e)),b))(null===y||this.activityTarget===c.wf.HIGH&&y[1].meanDifference<t.meanDifference||this.activityTarget===c.wf.LOW&&y[1].meanDifference>t.meanDifference)&&(y=[e,t]);if(null===y)continue;t[p]=parseInt(m),n[p]=y[0],i[p]=y[1].meanDifference,r[p]=y[1].pValue,o[p]=y[1].count,a[p]=y[1].ratio,l[p]=y[1].mean;let _=this.monomerPositionStats[m][y[0]],w=s.BitSet.fromBytes(_.mask.buffer.buffer,this.model.df.col(this.activityColumnName).length);for(let e=0;e<d.length;e++){let[t,n]=u[e];h[e][p]=(0,g.lh)(this.model.df.getCol(t),n,w)}++p}t.length=p,n.length=p,i.length=p,r.length=p,o.length=p,a.length=p,l.length=p;let m=s.DataFrame.create(p),v=m.columns;return v.add(s.Column.fromList(s.TYPE.INT,c.$2.POSITION,t)),v.add(s.Column.fromList(s.TYPE.STRING,c.$2.MONOMER,n)),v.add(s.Column.fromList(s.TYPE.FLOAT,c.$2.MEAN_DIFFERENCE,i)),v.add(s.Column.fromList(s.TYPE.FLOAT,c.$2.MEAN,l)),v.add(s.Column.fromList(s.TYPE.FLOAT,c.$2.P_VALUE,r)),v.add(s.Column.fromList(s.TYPE.INT,c.$2.COUNT,o)),v.add(s.Column.fromList(s.TYPE.FLOAT,c.$2.RATIO,a)),d.forEach((e,t)=>v.add(s.Column.fromList(s.TYPE.FLOAT,e,h[t]))),m}createViewerGrid(){let e=this.createMostPotentResiduesDf(),t=e.plot.grid();t.sort([c.$2.POSITION]);let n=t.col(c.$2.P_VALUE);n.format="#.000",n.name="P-value";let i=e.getCol(c.$2.MONOMER);h.rI(i,this.alphabet,!0),this.propagateCanonicalizerTag(i),t.onCellRender.subscribe(e=>M(e,this,!1,void 0,void 0)),t.onCellTooltip((e,t,n)=>{var i,r;if(!e.isTableCell)return this.model.unhighlight(),!0;let o=this.getMonomerPosition(e);if(this.model.highlight(o,this.monomerPositionStats),(null==(i=e.tableColumn)?void 0:i.name)===c.$2.MONOMER)o.positionOrClusterType=c.$2.MONOMER;else if((null==(r=e.tableColumn)?void 0:r.name)!==c.$2.MEAN_DIFFERENCE)return!1;let s=this.getTotalViewerAggColumns(),a=null==e.tableRowIndex?void 0:(0,g.m2)(e.grid.dataFrame,e.tableRowIndex,s,{});return(0,v.D)(this.model.df,this.getScaledActivityColumn(),s,{fromViewer:!0,isMostPotentResidues:!0,monomerPosition:o,x:t,y:n,mpStats:this.monomerPositionStats,aggrColValues:a})}),this.onCurrentGridCellChanged(t,n=>{try{var i,r,o;if(-1===n.gridRow){this._mutationCliffsSelection=(0,y.ZR)(this.positionColumns),this._invariantMapSelection=(0,y.ZR)(this.positionColumns),this.model.fireBitsetChanged(p.q.MOST_POTENT_RESIDUES),t.invalidate();return}if(this.keyPressed&&e.currentCol.name!==c.$2.MEAN_DIFFERENCE||!this.keyPressed)return;let s=this.getMonomerPosition(n);if(null!==this.currentGridRowIdx){let e=this.getMonomerPosition(t.cell("Diff",this.currentGridRowIdx));this.modifyInvariantMapSelection(e,{shiftPressed:!0,ctrlPressed:!0},!1)}(null==(o=this.mutationCliffs)||null==(r=o.get(s.monomerOrCluster))||null==(i=r.get(s.positionOrClusterType))?void 0:i.size)&&this.modifyInvariantMapSelection(s,{shiftPressed:!0,ctrlPressed:!1}),t.invalidate()}finally{this.keyPressed=!1,this.currentGridRowIdx=n.gridRow}}),t.root.addEventListener("keydown",n=>{if(this.keyPressed=n.key.startsWith("Arrow"),!this.keyPressed){if("Escape"===n.key||"KeyA"===n.code&&(n.ctrlKey||n.metaKey)&&n.shiftKey)this._mutationCliffsSelection=(0,y.ZR)(this.positionColumns);else if("KeyA"!==n.code||!n.ctrlKey&&!n.metaKey)return;else for(let n=0;n<e.rowCount;++n){let e=this.getMonomerPosition(t.cell("Diff",n));this.modifyInvariantMapSelection(e,{shiftPressed:!0,ctrlPressed:!1},!1)}this.model.fireBitsetChanged(p.q.MOST_POTENT_RESIDUES),t.invalidate()}}),t.root.addEventListener("mouseleave",e=>this.model.unhighlight()),t.root.addEventListener("click",e=>{var n,i,r;let o=t.hitTest(e.offsetX,e.offsetY);if(!(null==o?void 0:o.isTableCell)||o.tableColumn.name!==c.$2.MEAN_DIFFERENCE)return;let s=this.getMonomerPosition(o);(null==(r=this.monomerPositionStats)||null==(i=r[s.positionOrClusterType])||null==(n=i[s.monomerOrCluster])?void 0:n.count)&&(this.modifyInvariantMapSelection(s,{shiftPressed:e.shiftKey,ctrlPressed:e.ctrlKey||e.metaKey}),t.invalidate())}),L(t);let r=t.col(c.$2.MEAN_DIFFERENCE);r.name="Diff";let o=t.onAfterDrawContent.subscribe(()=>{let e=t.col(c.$2.MONOMER);if(40===e.width){r.width=40,o.unsubscribe();return}e.width=40,r.width=40});return t}getMonomerPosition(e){return{monomerOrCluster:e.cell.dataFrame.get(c.$2.MONOMER,e.tableRowIndex),positionOrClusterType:`${e.cell.dataFrame.get(c.$2.POSITION,e.tableRowIndex)}`}}render(){var e;if(l()(this.root).empty(),!this.dataFrame||!this.activityColumnName||!this.sequenceColumnName){this.root.appendChild(o.divText("Please, select a sequence and activity columns in the viewer properties")),this._onRendered.next();return}let t=this.viewerGrid.root;t.style.width="auto",this.root.appendChild(o.divV([t])),null==(e=this.viewerGrid)||e.invalidate()}constructor(){super(),this.currentGridRowIdx=null}}function M(e,t,n,i,r){var o,a,l,u,d;let p=[...t.positionColumns.map(e=>e.name),c.$2.MEAN_DIFFERENCE],f=e.g,m=e.bounds;f.save(),f.beginPath(),f.rect(m.x,m.y,m.width,m.height),f.clip();let g=e.cell,v=null==(o=g.tableColumn)?void 0:o.name,b=g.tableRowIndex;if(!g.isTableCell||-1===p.indexOf(v))return void f.restore();let y=g.grid.table,_=y.get(c.$2.MONOMER,b),w=v!==c.$2.MEAN_DIFFERENCE?v:y.get(c.$2.POSITION,b).toFixed(),x=t.monomerPositionStats[w];if(!x[_]){e.preventDefault(),f.restore();return}if(n){let e=null!=(a=x[_].aggValue)?a:x[_].count,n=t.positionColumns.find(e=>e.name===w),i=null!=(l=n.temp[c.gp.INVARIANT_MAP_COLOR_CACHE])?l:{},r=s.Color.white;null!=i[_]?r=i[_]:t instanceof N&&(t.cacheInvariantMapColors(),r=null!=(u=(null!=(d=n.temp[c.gp.INVARIANT_MAP_COLOR_CACHE])?d:{})[_])?u:s.Color.white),h.rW(f,_,w,t.invariantMapSelection,e,m,r)}else h.Yd(f,_,w,t,m);e.preventDefault(),f.restore()}function L(e){let t=e.props;t.allowEdit=!1,t.allowRowSelection=!1,t.allowBlockSelection=!1,t.allowColSelection=!1,t.showRowHeader=!1,t.showCurrentRowIndicator=!1,t.showReadOnlyNotifications=!1,t.rowHeight=20}},7579(e,t,n){"use strict";n.d(t,{Y:()=>o});var i=n(1858);function r(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}class o{get isPending(){return this.timers.size>0||this.running>0||Array.from(this.children.keys()).some(e=>e.root.isConnected&&e.isRenderPending)}get immediateRendering(){return this.immediate}set immediateRendering(e){for(let t of(this.immediate=e,this.children.keys()))t.immediateRendering=e}add(e,t=e.onAfterDrawScene){e.immediateRendering=this.immediate,this.children.set(e,t.subscribe(()=>this.rendered.next()))}remove(e){var t;null==(t=this.children.get(e))||t.unsubscribe(),this.children.delete(e),e.detach()}defer(e,t,n){this.cancel(e),this.disposed||this.timers.set(e,setTimeout(()=>{this.timers.delete(e),this.run(t)},this.immediate?0:n))}cancel(e){clearTimeout(this.timers.get(e)),this.timers.delete(e)}run(e){var t;return(t=function*(){this.running++;try{yield e()}finally{this.running--,this.rendered.next()}},function(){var e=this,n=arguments;return new Promise(function(i,o){var s=t.apply(e,n);function a(e){r(s,i,o,a,l,"next",e)}function l(e){r(s,i,o,a,l,"throw",e)}a(void 0)})}).call(this)}dispose(){for(let e of(this.disposed=!0,this.timers.keys()))this.cancel(e);for(let e of this.children.keys())this.remove(e);this.rendered.complete()}constructor(){this.rendered=new i.Subject,this.children=new Map,this.timers=new Map,this.running=0,this.immediate=!1,this.disposed=!1}}},9336(e,t,n){"use strict";n.d(t,{HV:()=>m,M1:()=>g,QD:()=>v});var i,r=n(7389),o=n(6082),s=n(1757),a=n.n(s),l=n(3629),u=n(7545),d=n(8750),c=n(3286),h=n(9222),p=((i={}).SEPARATE_MONOMERS="separateMonomers",i.SEPARATE_POSITIONS="separatePositions",i.SEPARATE_CLUSTERS="separateClusters",i);let f="general";function m(e,t){if(!e.selection.anyTrue)return r.divText("No distribution");let n=()=>{let n=[y(f,e,t)];for(let i of Object.values(p))"true"===e.getTag(i)&&("separateClusters"!==i||t.clusterColName)&&n.push(y(i,e,t));return 1===n.length?n[0]:r.div(n)},i=r.div(n()),o=Object.values(p),s=Array(o.length);for(let l=0;l<o.length;l++){let u=o[l].substring(8);s[l]=r.input.bool(u,{value:"true"===e.getTag(o[l]),onValueChanged:t=>{e.setTag(o[l],`${t}`),a()(i).empty(),i.append(n())}}),a()(s[l].captionLabel).addClass("ui-label-right").css("text-align","left"),a()(s[l].root).find(".ui-input-editor").css("margin","0px"),a()(s[l].root).find(".ui-input-description").css("margin","0px"),s[l].setTooltip(`Show distribution for each ${u}`),"separateClusters"===u?s[l].enabled=!!(t.clusterColName&&t.clusterSelection[c.WR.ORIGINAL]):("separateMonomers"===u||"separatePositions"===u)&&(s[l].enabled=0!==Object.entries(t.monomerPositionSelection).length)}let l=r.form(s,{style:{flexDirection:"row"}});return r.divV([l,i])}function g(e,t=!1){let n=e.plot.histogram({filteringEnabled:!1,valueColumnName:l.$2.ACTIVITY,splitColumnName:l.$2.SPLIT_COL,legendVisibility:"Never",showXAxis:!0,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1,backColor:t?o.Color.fromHtml("#fdffe5"):o.Color.white});return n.root.style.width="auto",n}function v(e,t={}){var n;null!=t.fractionDigits||(t.fractionDigits=3);let i={[null!=(n=null==t?void 0:t.countName)?n:"Count"]:`${e.count} (${(100*e.ratio).toFixed(t.fractionDigits)}%)`,"Mean difference":e.meanDifference.toFixed(t.fractionDigits),"Mean activity":e.mean.toFixed(t.fractionDigits)};return null!=e.pValue&&(i["p-value"]=e.pValue<.01?"<0.01":e.pValue.toFixed(t.fractionDigits)),i}function b(e,t,n,i={}){let r=g((0,d.FZ)(n.activityCol,e.selection,e)),s=(0,u.I_)(e,Object.entries(n.columns),{filterDf:!0,mask:o.BitSet.fromBytes(t.mask.buffer.buffer,t.mask.length)}),l=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}({},v(t),s),c=(0,d.F2)(r,l,i);return a()(c).addClass("d4-flex-col"),c}function y(e,t,n){let i=r.divText("No distribution"),o=t.selection.clone().and(t.filter),s=h.A.fromUint32Array(o.length,new Uint32Array(o.getBuffer().buffer));switch(e){case f:let a=t.selection.anyTrue&&t.selection.anyFalse?(0,u.GT)(n.activityCol.getRawData(),s,(0,u.pY)(t.filter)):{count:n.activityCol.length,pValue:null,meanDifference:0,ratio:1,mask:s,mean:n.activityCol.stats.avg};i=b(t,a,n);break;case"separateClusters":i=function(e,t,n){let i=e.rowCount,o=[],s=t.activityCol.getRawData(),a=e.getCol(t.clusterColName),l=a.categories,p=a.getRawData(),f=(0,u.pY)(e.filter),m=n[c.WR.ORIGINAL].map(e=>l.indexOf(e)),g=Array(m.length).fill(new h.A(i));for(let e=0;e<i;e++){let t=p[e],n=m.indexOf(t);-1!==n&&g[n].setTrue(e)}for(let n=0;n<m.length;n++){let i=m[n],r=(0,u.GT)(s,g[n],f);o.push(b(e,r,t,{[d.AN.SELECTION]:l[i]}))}for(let r of n[c.WR.CUSTOM]){let n=e.getCol(r),a=h.A.fromUint32Array(i,n.getRawData()),l=(0,u.GT)(s,a,f);o.push(b(e,l,t,{[d.AN.SELECTION]:r}))}return r.div(o,"d4-flex-wrap")}(t,n,n.clusterSelection);break;case"separateMonomers":let l=function(e){let t={};for(let n of Object.keys(e))for(let i of e[n]){if(!t.hasOwnProperty(i)){t[i]=[n];continue}t[i].includes(n)||t[i].push(n)}return t}(n.monomerPositionSelection);i=function(e,t,n){let i=Object.keys(n),o=e.rowCount,s=[],a=[],l=[],c=[],p=t.activityCol.getRawData(),f=(0,u.pY)(e.filter);for(let r of i){let i=n[r],y=new h.A(o);for(let t=0;t<i.length;t++){var m,g,v;let n=i[t];null!=a[m=t]||(a[m]=e.getCol(n)),null!=l[g=t]||(l[g]=a[t].categories),null!=c[v=t]||(c[v]=a[t].getRawData());let s=l[t].indexOf(r);for(let e=0;e<o;e++)c[t][e]===s&&y.setTrue(e)}let _=(0,u.GT)(p,y,f);s.push(b(e,_,t,{[d.AN.SELECTION]:r}))}return r.div(s,"d4-flex-wrap")}(t,n,l);break;case"separatePositions":i=function(e,t,n){let i=Object.keys(n),o=e.rowCount,s=[],a=t.activityCol.getRawData(),l=[],c=[],p=[],f=(0,u.pY)(e.filter);for(let r=0;r<i.length;r++){var m,g,v;let y=i[r],_=n[y];if(0===_.length)continue;null!=l[m=r]||(l[m]=e.getCol(y)),null!=c[g=r]||(c[g]=l[r].categories),null!=p[v=r]||(p[v]=l[r].getRawData());let w=new h.A(e.rowCount);for(let e=0;e<_.length;e++){let t=_[e],n=c[r].indexOf(t);for(let e=0;e<o;e++)p[r][e]===n&&w.setTrue(e)}let x=(0,u.GT)(a,w,f);s.push(b(e,x,t,{[d.AN.SELECTION]:y}))}return r.div(s,"d4-flex-wrap")}(t,n,n.monomerPositionSelection)}return r.divV([r.h1(e===f?"General":e.substring(8)),i])}},5789(e,t,n){"use strict";n.d(t,{F:()=>d});var i=n(7389),r=n(6082),o=n(3629),s=n(8750),a=n(8154),l=n(7563),u=n(9336);function d(e,t,n=!0){let o=c(e,t);if(!o)return new r.Widget(i.label("No mutations table generated"));let{pairsGrid:a,uniqueSequencesGrid:l,aminoToInput:h}=o,p=i.divV([h.root,...[a,l].map(e=>e.root)],{style:{width:"100%"}});if(1===Object.values(t.mutationCliffsSelection).filter(e=>e.length>0).length){let e=Object.keys(t.mutationCliffsSelection).find(e=>t.mutationCliffsSelection[e].length>0),n=t.mutationCliffsSelection[e];if(1===n.length){var f,m,g,v,b;let i=n[0],r=null==(m=t.mutationCliffs)||null==(f=m.get(i))?void 0:f.get(e);if(r&&r.size>0){let n=(0,s.Z7)(t.activityCol,r,i),o=(0,u.M1)(n,!1),a=null==(b=t.mutationCliffStats)||null==(v=b.stats)||null==(g=v.get(i))?void 0:g.get(e),l={},d=0;for(let e of r.values())d+=e.length;l["Pairs count"]=d.toString(),a&&(l["Unique Count"]=a.mask.trueCount().toString(),Object.assign(l,(0,u.QD)(a,{countName:"MP in cliffs count"})));let c=(0,s.F2)(o,l);o.root.style.maxHeight="100px",c.style.marginTop="10px",p.appendChild(c)}}}return n&&(0,s.BE)("Mutation Cliffs pairs",h.root,p,()=>{let n=c(e,t),r=i.splitH([i.divV([n.aminoToInput.root,n.pairsGrid.root],{style:{marginRight:"10px"}}),i.divV([n.uniqueSequencesGrid.root],{style:{marginLeft:"10px"}})],{style:{width:"100%",height:"100%"}},!0);return setTimeout(()=>{if(document.contains(r)){var e,i;let o=r.offsetWidth,s=null==(e=n.pairsGrid.canvas)?void 0:e.parentElement;n.pairsGrid.props.showRowHeader=!0,n.uniqueSequencesGrid.props.showRowHeader=!0;let a=null==(i=n.uniqueSequencesGrid.canvas)?void 0:i.parentElement;if(s&&a&&(s.style.height="100%",a.style.height="calc(100% - 20px)",a.style.marginTop="20px",o>400)){let e=Math.max(.33*o,200),i=n.pairsGrid.columns.byName("Mutation");i&&(i.width=e);let r=n.uniqueSequencesGrid.columns.byName(t.sequenceColumnName);r&&(r.width=e)}}},500),r}),new r.Widget(p)}function c(e,t){let n=e.filter.getSelectedIndexes(),u=Object.keys(t.mutationCliffsSelection);if(!u.length||null===t.mutationCliffs)return null;let d=[],c=[],h=[],p=[],f=[],m=[],g=e.getCol(t.sequenceColumnName),v=g.categories,b=g.getRawData(),y=t.activityCol.getRawData(),_=new Map,w=r.BitSet.create(e.rowCount),x={},k=Object.fromEntries(t.positionColumns.map(e=>[e.name,e]));for(let e of u){let i=k[e],r=i.categories,o=i.getRawData();for(let i of t.mutationCliffsSelection[e]){var S,C;let s=null==(S=t.mutationCliffs.get(i))?void 0:S.get(e);if(void 0!==s)for(let[e,i]of s.entries()){if(!n.includes(e))continue;x[e]||(x[e]=Object.keys(x).length+1);let s=x[e],a=null!=(C=_.get(e))?C:[],l=v[b[e]],u=y[e],g=t.activityCol.isNone(e)?null:u;for(let u of i){if(a.includes(u)||!n.includes(u))continue;_.has(u)||_.set(u,[]);let i=v[b[u]],x=t.activityCol.isNone(u)?null:y[u],k=null==g||null==x?null:g-x;_.get(u).push(e),d.push(`${l}#${i}`),p.push(`${s}`),c.push(k),h.push(r[o[u]]),f.push(e),m.push(u),w.set(e,!0),w.set(u,!0)}}}}if(0===d.length)return null;let A=r.Column.fromStrings("Mutation",d),O=r.Column.fromList("double","Delta",c),E=r.Column.fromStrings("Group",p),T=r.Column.fromStrings("~to",h),P=r.Column.fromList(r.COLUMN_TYPE.INT,"~toIdx",m),N=r.Column.fromList(r.COLUMN_TYPE.INT,"~fromIdx",f),I=r.DataFrame.fromColumns([A,O,E,T,P,N]);I.name="Mutation Cliff pairs";let M=i.input.string("Mutated to:",{value:"",onValueChanged:e=>{""!==e?I.filter.init(t=>T.get(t)===e):I.filter.setAll(!0)}});M.setTooltip("Filter the rows by the monomer that the mutation was substituted to");let L=I.plot.grid();(0,s.vY)(L,!0),A.semType=o.uF.MACROMOLECULE_DIFFERENCE,A.tags[o.gp.SEPARATOR]=(0,s.AY)(g),A.tags[r.TAGS.UNITS]=g.tags[r.TAGS.UNITS],A.tags[r.TAGS.CELL_RENDERER]="MacromoleculeDifference",A.temp[l.j.notationProvider]=g.temp[l.j.notationProvider];let R=!1,j=null,D=[];L.onCurrentCellChanged.subscribe(e=>{try{if(!e||!e.dart){D.length=0,H();return}let t=e.tableRowIndex;if(!R)return;if(null===t){D.length=0,H();return}null!==j&&D.splice(D.indexOf(j),1),D.includes(t)||(D.push(t),L.invalidate()),H()}finally{R=!1,j=e&&e.dart?e.tableRowIndex:null}}),L.root.addEventListener("keydown",e=>{R=e.key.startsWith("Arrow")}),L.root.addEventListener("click",e=>{let t=L.hitTest(e.offsetX,e.offsetY);if(!t||null===t.tableRowIndex)return;let n=t.tableRowIndex;if(e.shiftKey){let e=D.indexOf(n);-1===e?D.push(n):D.splice(e,1)}else D.length=0,D.push(n);H(),L.invalidate(),U.invalidate()}),L.onCellPrepare(e=>{var t,n,i,o;if((null==e?void 0:e.isTableCell)&&(null==e||null==(n=e.gridColumn)||null==(t=n.name)?void 0:t.toLowerCase())=="delta"&&((null==e||null==(i=e.cell)?void 0:i.value)==null||(null==e||null==(o=e.cell)?void 0:o.value)==r.FLOAT_NULL))try{e.customText="N/A"}catch(e){}}),L.onCellRender.subscribe(e=>{var t;(null==(t=e.cell.tableColumn)?void 0:t.name)===A.name&&D.includes(e.cell.tableRowIndex)&&(0,a.X5)(e.g,e.bounds)});let F=t.gridColumns.length,z=[];for(let e=1;e<F;e++){let n=t.gridColumns.byIndex(e);(null==n?void 0:n.name)!==t.sequenceColumnName&&((null==n?void 0:n.visible)!==!0||Object.hasOwn(k,n.name))||z.push(n.name)}let q=e.clone(w,z);q.name="Unique sequences that form Mutation Cliffs pairs";let B=q.columns.addNewInt("~seqIdx"),G=B.getRawData();q.col(t.sequenceColumnName)&&(q.col(t.sequenceColumnName).temp[l.j.notationProvider]=g.temp[l.j.notationProvider]);let V=w.getSelectedIndexes();B.init(e=>V[e]);let U=q.plot.grid();function H(){let e=[];for(let t of D)e.push(N.get(t)),e.push(P.get(t));q.filter.init(t=>0===D.length||e.includes(G[t]),!0),L.invalidate(),U.invalidate()}return(0,s.vY)(U,!0),U.props.rowHeight=20,L.root.style.width="100% !important",U.root.style.width="100% !important",setTimeout(()=>{L.autoSize(window.innerWidth,250,void 0,void 0,!1),U.autoSize(window.innerWidth,250,void 0,void 0,!1),L.root.style.removeProperty("width"),L.root.style.setProperty("width","100%"),U.root.style.removeProperty("width"),U.root.style.setProperty("width","100%"),L.root.style.minHeight="70px",U.root.style.minHeight="100px",L.root.style.height="unset",U.root.style.height="unset"},200),{pairsGrid:L,uniqueSequencesGrid:U,aminoToInput:M}}},5065(e,t,n){"use strict";n.d(t,{n:()=>y,v:()=>b});var i=n(4328),r=n(7389),o=n(6082),s=n(3629),a=n(4345),l=n(8285),u=n(1757),d=n.n(u),c=n(8750),h=n(4386),p=n(4323);function f(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}class m{get root(){return this._inputBase.root}get value(){return this._inputBase.value}set value(e){this._inputBase.value=e}get inputBase(){return this._inputBase}constructor(e){this._inputBase=e}}function g(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function v(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){g(o,i,r,s,a,"next",e)}function a(e){g(o,i,r,s,a,"throw",e)}s(void 0)})}}function b(e,t){return v(function*(){let n,l=new a.av,u=r.div(),g=null;if(void 0===t){var b,_,w;let t=o.Utils.firstOrNull(e.columns.toList().filter(e=>e.semType===o.SEMTYPE.MACROMOLECULE));if(null===t)throw Error("Peptides Error: table doesn't contain sequence columns");0!==t.stats.missingValueCount&&i.shell.info("Sequences column contains missing values. They will be ignored during analysis"),(g=yield(b="Sequence",_={table:e,value:t,onValueChanged:t=>{d()(u).empty().append(r.wait(()=>v(function*(){let n=yield e.plot.fromType("WebLogo",{sequenceColumnName:t.name});return n.root.setAttribute("name","viewer-WebLogo"),n.root.style.setProperty("height","130px"),n.root})())),0!==t.stats.missingValueCount&&i.shell.info("Sequences column contains missing values. They will be ignored during analysis")},filter:e=>e.semType===o.SEMTYPE.MACROMOLECULE,nullable:!1},(w=function*(){let e=o.Func.find({package:"Bio",name:"sequenceColumnInput"})[0];return e?yield e.apply({name:b,options:_}):new m(r.input.column(b,_))},function(){var e=this,t=arguments;return new Promise(function(n,i){var r=w.apply(e,t);function o(e){f(r,n,i,o,s,"next",e)}function s(e){f(r,n,i,o,s,"throw",e)}o(void 0)})})())).inputBase.setTooltip("Macromolecule column in FASTA, HELM or separated format")}let x=o.Func.find({package:"Bio",name:"webLogoViewer"});if(0===x.length||0===(x=o.Func.find({package:"Bio",name:"getBioLib"})).length)return{host:r.label("Bio package is missing or out of date. Please install the latest version."),callback:()=>v(function*(){return!1})()};let k=e.col("activity")||e.col("IC50")||o.Utils.firstOrNull(e.columns.numerical),S=r.div([],{id:"pep-hist-host"}),C=r.input.choice("Scaling",{value:s.rg.NONE,items:Object.values(s.rg),onValueChanged:e=>v(function*(){var t;n=(0,c.Y1)(O.value,e);let i=o.DataFrame.fromColumns([n]).plot.histogram({filteringEnabled:!1,valueColumnName:s.$2.ACTIVITY,legendVisibility:"Never",showXAxis:!0,showColumnSelector:!1,showRangeSlider:!1,showBinSelector:!1});null==(t=S.lastChild)||t.remove(),S.appendChild(i.root)})()});C.setTooltip("Activity column transformation method");let A=()=>{var e;C.enabled=null!=(e=O.value)&&e&&O.value.stats.min>0,C.value=s.rg.NONE,0!==O.value.stats.missingValueCount&&i.shell.info("Activity column contains missing values. They will be ignored during analysis")},O=r.input.column("Activity",{table:e,value:k,nullable:!1,onValueChanged:A,filter:e=>e.type===o.TYPE.INT||e.type===o.TYPE.FLOAT||e.type===o.TYPE.QNUM});O.setTooltip("Numerical activity column");let E=r.input.column("Clusters",{table:e,onValueChanged:e=>{e&&(T.value=!1,T.fireChanged())}});E.setTooltip("Optional. Clusters column is used to create Logo Summary Table"),E.nullable=!0;let T=r.input.bool("Generate clusters",{value:!0,onValueChanged:e=>{e&&(E.value=null,E.fireChanged())}});T.setTooltip("Generate clusters column based on MCL embeddings for Logo Summary Table"),O.fireChanged(),C.fireChanged(),T.fireChanged();let P=[O,C,E,T];null!==g&&P.splice(0,0,g.inputBase);let N=r.input.float(p.t_.THRESHOLD,{value:l.threshold,nullable:!1,onValueChanged:e=>l.threshold=null!=e?e:l.threshold});N.setTooltip("Threshold for similarity between two sequences to create edges");let I=r.input.float(p.t_.INFLATION,{value:l.inflation,nullable:!1,onValueChanged:e=>l.inflation=null!=e?e:l.inflation});I.setTooltip("Inflation value for MCL algorithm");let M=r.input.int(p.t_.MAX_ITERATIONS,{value:l.maxIterations,nullable:!1,onValueChanged:e=>l.maxIterations=null!=e?e:l.maxIterations});M.setTooltip("Maximum iterations for MCL algorithm");let L=r.input.bool(p.t_.USE_WEBGPU,{value:l.useWebGPU,onValueChanged:e=>l.useWebGPU=e});L.enabled=!1,l.webGPUDescriptionPromise.then(()=>{l.webGPUDescription!==a.Ku?(L.setTooltip(`Use WebGPU for MCL algorithm (${l.webGPUDescription})`),L.enabled=!0):(L.setTooltip(a.Ku),L.enabled=!1,L.value=!1)});let R=r.input.int(p.t_.MIN_CLUSTER_SIZE,{value:l.minClusterSize,nullable:!1,onValueChanged:e=>l.minClusterSize=null!=e?e:l.minClusterSize});R.setTooltip("Minimum cluster size for MCL algorithm");let j=r.input.choice(p.t_.DISTANCE_FUNCTION,{value:l.distanceF,items:[h.Z.NEEDLEMANN_WUNSCH,h.Z.MONOMER_CHEMICAL_DISTANCE,h.Z.HAMMING,h.Z.LEVENSHTEIN],nullable:!1,onValueChanged:e=>l.distanceF=e}),D=r.input.float(p.t_.GAP_OPEN,{value:l.gapOpen,onValueChanged:e=>l.gapOpen=null!=e?e:l.gapOpen}),F=r.input.float(p.t_.GAP_EXTEND,{value:l.gapExtend,onValueChanged:e=>l.gapExtend=null!=e?e:l.gapExtend}),z=[N,I,M,R,j,r.input.choice(p.t_.FINGERPRINT_TYPE,{value:l.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],nullable:!1,onValueChanged:e=>l.fingerprintType=e}),D,F,L],q=r.form(z);q.style.display="none";let B=r.icons.settings(()=>{q.style.display="none"===q.style.display?"flex":"none",q.classList.remove("ui-form-condensed")},"Adjust clustering parameters");B.style.fontSize="16px",T.root.appendChild(B);let G=e.filter.onChanged.subscribe(()=>A()),V=()=>v(function*(){let i=null!=t?t:g.value;if(G.unsubscribe(),i){var r,o;return null!==(yield y(O.value,i,E.value,e,n,null!=(r=C.value)?r:s.rg.NONE,{addSequenceSpace:!1,addMCL:T.value,useEmbeddingsClusters:null!=(o=T.value)&&o,mclSettings:l}))}return!1})(),U="auto",H=[r.divV(P)];if(d()(H[0]).find("label").css("width","unset"),void 0!==t){let e=r.button("Launch SAR",V,"");e.style.alignSelf="center",H.push(e),U="215px"}return d()(u).empty().append(r.wait(()=>v(function*(){var n;let i=yield e.plot.fromType("WebLogo",{sequenceColumnName:null!=(n=null==t?void 0:t.name)?n:g.value.name});return i.root.setAttribute("name","viewer-WebLogo"),i.root.style.setProperty("height","130px"),i.root})())),{host:r.divV([u,r.splitH([r.splitV(H,{style:{flex:"0 1 auto"}}),S],{style:{height:U,minWidth:"600px",maxWidth:"750px"}}),q]),callback:V}})()}function y(e,t,n,r,u,d){return v(function*(e,t,n,r,u,d,c={}){let h=null;if(e.type!==o.COLUMN_TYPE.FLOAT&&e.type!==o.COLUMN_TYPE.INT&&e.type!==o.COLUMN_TYPE.QNUM)return i.shell.error("The activity column must be of numeric type!"),h;let p=o.TaskBarProgressIndicator.create("Loading SAR...");try{var f,m,g,v,b;r.tags.delete&&r.tags.delete(".script");let p=r.columns,y=r.col(u.name);y&&(y.name=p.getUnusedName(y.name));let _=u.getRawData();r.columns.addNew(u.name,u.type).init(e=>_[e]),p.setOrder([u.name,t.name,...p.names().filter(e=>e!==t.name&&e!==u.name)]);let w={sequenceColumnName:t.name,activityColumnName:e.name,activityScaling:d,columns:{},showDendrogram:!1,showSequenceSpace:!1,sequenceSpaceParams:new a.GI(!!c.useEmbeddingsClusters&&!n),mclSettings:null!=(f=c.mclSettings)?f:new a.av};if(n){let e=r.getCol(n.name);e.type!==o.COLUMN_TYPE.STRING&&p.replace(e,e.convertTo(o.COLUMN_TYPE.STRING))}if(r.setTag(s.gp.SETTINGS,JSON.stringify(w)),(h=l.i.getInstance(r)).init(w),n){let i={clustersColumnName:n.name,sequenceColumnName:t.name,activityScaling:d,activityColumnName:e.name};yield h.addLogoSummaryTable(i)}if(yield h.addMonomerPosition(),yield h.addMostPotentResidues(),null!=(m=c.addSequenceSpace)&&m){if(yield h.addSequenceSpace({clusterCol:n,clusterEmbeddings:c.useEmbeddingsClusters}),!n&&null!=(v=c.useEmbeddingsClusters)&&v){let n=h._sequenceSpaceCols.find(e=>{var t;return h.df.col(e)&&(null==(t=h.df.col(e))?void 0:t.type)===o.COLUMN_TYPE.STRING});if(n){let i={clustersColumnName:n,sequenceColumnName:t.name,activityScaling:d,activityColumnName:e.name};yield h.addLogoSummaryTable(i)}}}else if(null!=(g=c.addMCL)&&g&&(yield h.addMCLClusters(),!n&&null!=(b=c.useEmbeddingsClusters)&&b)){let n=h._mclCols.find(e=>(null==h?void 0:h.df.col(e))&&e.toLowerCase().startsWith("cluster")&&!e.toLowerCase().includes("size"));if(n){let i={clustersColumnName:n,sequenceColumnName:t.name,activityScaling:d,activityColumnName:e.name};yield h.addLogoSummaryTable(i)}}let x=h.df.plot.grid({rowSource:o.RowSet.Selected,selectedRowsColor:o.Color.fromHtml("#ffffff"),title:"Selection"}),k=null==h?void 0:h.findViewerNode(l.q.LOGO_SUMMARY_TABLE);return x.root.setAttribute("name","viewer-Selection"),k&&h.analysisView.dockManager.dock(x,o.DOCK_TYPE.DOWN,k,"Selection",.4),h.analysisView.grid.scrollToCell(s.$2.ACTIVITY,0),i.events.fireCustomEvent("peptides-sar-ready",{table:h.df.name}),h}finally{p.close()}}).apply(this,arguments)}n(2620)},4323(e,t,n){"use strict";n.d(t,{OH:()=>g,t_:()=>m});var i,r=n(7389),o=n(4328),s=n(6082),a=n(4345),l=n(3629),u=n(1757),d=n.n(u),c=n(4332),h=n(4386);function p(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},i=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),i.forEach(function(t){var i;i=n[t],t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i})}return e}l.qS.DENDROGRAM;var m=((i={}).DISTANCE_FUNCTION="Distance Function",i.GAP_OPEN="Gap Open Penalty",i.GAP_EXTEND="Gap Extend Penalty",i.FINGERPRINT_TYPE="Fingerprint Type",i.THRESHOLD="Similarity Threshold",i.INFLATION="Inflation Factor",i.MAX_ITERATIONS="Max Iterations",i.USE_WEBGPU="Use WebGPU",i.MIN_CLUSTER_SIZE="Min Cluster Size",i);function g(e){var t,n,i,u,m,g,v,b,y,_;null==e.settings&&o.log.error("PeptidesError: Settings are not initialized");let w=r.accordion(),x=e.settings,k=null!=(t=null==x?void 0:x.activityScaling)?t:l.rg.NONE,S=null!=(n=null==x?void 0:x.columns)?n:{},C={},A={},O=null!=(i=null==x?void 0:x.sequenceSpaceParams)?i:new a.GI,E=null!=(u=null==x?void 0:x.mclSettings)?u:new a.av,T=r.input.column("Activity",{table:e.df,value:e.df.getCol(e.settings.activityColumnName),onValueChanged:e=>{C.activityColumnName=e.name},filter:e=>(e.type===s.TYPE.FLOAT||e.type===s.TYPE.INT)&&e.name!==l.$2.ACTIVITY&&0===e.stats.missingValueCount});T.setTooltip("Numeric activity column");let P=r.input.choice("Activity scaling",{value:k,items:Object.values(l.rg),onValueChanged:e=>C.activityScaling=e});P.setTooltip("Activity column transformation method"),w.addPane("General",()=>r.inputs([T,P]),!0),A.General=[T,P];let N=null!==e.dendrogramCloseButton,I=r.input.bool(l.qS.DENDROGRAM,{value:N,onValueChanged:e=>C.showDendrogram=e}),M=r.input.bool(l.qS.CLUSTER_MAX_ACTIVITY,{value:!!(null==x?void 0:x.showClusterMaxActivity),onValueChanged:e=>{C.showClusterMaxActivity=null!=e?e:void 0}}),L=r.input.bool("Sequence space",{value:!!(null==x?void 0:x.showSequenceSpace),onValueChanged:e=>{C.showSequenceSpace=null!=e?e:void 0,e?(eu.root.style.display="flex",(null==x?void 0:x.showSequenceSpace)||(C.sequenceSpaceParams=O)):(eu.root.style.display="none",delete C.sequenceSpaceParams),C.showSequenceSpace===(null==x?void 0:x.showSequenceSpace)&&delete C.showSequenceSpace}});M.setTooltip("Show cluster max activity viewer"),I.setTooltip("Show dendrogram viewer"),I.enabled=null!==(0,c.getTreeHelperInstance)(),w.addPane("Viewers",()=>r.inputs([I,L,M]),!0),A.Viewers=[I,L,M];let R=[],j=[];for(let t of e.df.columns.numerical){let e=t.name;if(e===x.activityColumnName||e===l.$2.ACTIVITY)continue;let n=r.input.bool("",{value:void 0!==S[e],onValueChanged:t=>{null!=C.columns||(C.columns={}),t?C.columns[e]=i.value:(delete C.columns[e],Object.keys(C.columns).length===Object.keys(S).length&&delete C.columns)}});n.setTooltip("Include aggregated column value in tooltips, Logo Summary Table and Distribution panel");let i=r.input.choice("Aggregation",{value:null!=(_=S[e])?_:s.AGG.AVG,items:Object.values(s.STATS),onValueChanged:i=>{null!=C.columns||(C.columns={}),n.value?C.columns[e]=i:(delete C.columns[t.name],Object.keys(C.columns).length===Object.keys(S).length&&delete C.columns)}});i.setTooltip("Aggregation method"),d()(i.root).find("label").css("width","auto");let o=r.inputsRow(t.name,[n,i]);j.push(n,i),d()(o).find("div.ui-div").css("display","inline-flex"),R.push(o)}0!==R.length&&(w.addPane("Columns",()=>r.divV(R),!1),A.Columns=j);let D={};function F(e,t){if(Y(),null==t||""===t)return;D[e]=t;let n=!0;for(let[e,t]of Object.entries(D))if(t!==O[e]){n=!1;break}n?delete C.sequenceSpaceParams:C.sequenceSpaceParams=f({},O,D)}function z(e,t){e.forEach(e=>{t?e.root.style.display="flex":e.root.style.display="none"})}let q=r.input.choice("Distance Function",{value:O.distanceF,items:[h.Z.NEEDLEMANN_WUNSCH,h.Z.HAMMING,h.Z.LEVENSHTEIN,h.Z.MONOMER_CHEMICAL_DISTANCE],onValueChanged:e=>F("distanceF",e)});q.setTooltip("Distance function for sequences");let B=r.input.float("Gap Open Penalty",{value:O.gapOpen,onValueChanged:e=>F("gapOpen",e)}),G=r.input.float("Gap Extend Penalty",{value:O.gapExtend,onValueChanged:e=>F("gapExtend",e)}),V=r.input.bool("Cluster Embeddings",{value:null!=(m=O.clusterEmbeddings)&&m,onValueChanged:e=>F("clusterEmbeddings",e)});V.setTooltip("Cluster embeddings using DBSCAN algorithm");let U=r.input.float("Epsilon",{value:O.epsilon,onValueChanged:e=>F("epsilon",e)});U.setTooltip("Epsilon parameter for DBSCAN. Minimum distance between two points to be considered as a cluster");let H=r.input.int("Minimum Points",{value:O.minPts,onValueChanged:e=>F("minPts",e)});H.setTooltip("Minimum number of points in a cluster");let W=r.input.choice("Fingerprint Type",{value:O.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],onValueChanged:e=>F("fingerprintType",e)});function Y(){z([B,G],q.value===h.Z.NEEDLEMANN_WUNSCH),z([U,H],!0===V.value),z([W],q.value===h.Z.MONOMER_CHEMICAL_DISTANCE||q.value===h.Z.NEEDLEMANN_WUNSCH)}Y();let K={};function X(e,t){if(Z(),null==t||""===t)return;K[e]=t;let n=!0;for(let[e,t]of Object.entries(K))if(t!==E[e]){n=!1;break}n?delete C.mclSettings:C.mclSettings=f({},E,K)}function Z(){z([J,ee],Q.value===h.Z.NEEDLEMANN_WUNSCH),z([et],Q.value===h.Z.MONOMER_CHEMICAL_DISTANCE||Q.value===h.Z.NEEDLEMANN_WUNSCH)}let Q=r.input.choice("Distance Function",{value:E.distanceF,items:[h.Z.NEEDLEMANN_WUNSCH,h.Z.MONOMER_CHEMICAL_DISTANCE,h.Z.HAMMING,h.Z.LEVENSHTEIN],onValueChanged:e=>X("distanceF",e)}),J=r.input.float("Gap Open Penalty",{value:E.gapOpen,onValueChanged:e=>X("gapOpen",e)}),ee=r.input.float("Gap Extend Penalty",{value:E.gapExtend,onValueChanged:e=>X("gapExtend",e)}),et=r.input.choice("Fingerprint Type",{value:E.fingerprintType,items:["Morgan","RDKit","Pattern","AtomPair","MACCS","TopologicalTorsion"],onValueChanged:e=>X("fingerprintType",e)}),en=r.input.int("Similarity Threshold",{value:null!=(g=E.threshold)?g:80,onValueChanged:e=>X("threshold",e)}),ei=r.input.int("Max Iterations",{value:null!=(v=E.maxIterations)?v:5,onValueChanged:e=>X("maxIterations",e)}),er=r.input.float("Inflation Factor",{value:null!=(b=E.inflation)?b:1.4,onValueChanged:e=>{X("inflation",e)}}),eo=r.input.bool("Use WebGPU",{value:E.useWebGPU,onValueChanged:e=>X("useWebGPU",e)});eo.enabled=!1,E.webGPUDescriptionPromise.then(()=>{E.webGPUDescription!==a.Ku?(eo.setTooltip(`Use WebGPU for MCL algorithm (${E.webGPUDescription})`),eo.enabled=!0):(eo.setTooltip(a.Ku),eo.enabled=!1,eo.value=!1)});let es=r.input.int("Min Cluster Size",{value:null!=(y=E.minClusterSize)?y:5,onValueChanged:e=>X("minClusterSize",e)});Z();let ea=[en,Q,et,J,ee,er,ei,es,eo];w.addPane("MCL",()=>r.inputs(ea),!0),A.MCL=ea;let el=[q,W,B,G,V,U,H],eu=w.addPane("Sequence space",()=>r.inputs(el),!0);A["Sequence space"]=el,L.fireChanged();let ed=r.dialog("Peptides settings").add(w);return ed.root.style.width="400px",ed.onOK(()=>{var t;return(t=function*(){try{yield e.applySettings(C)}catch(e){o.shell.error(String(e))}},function(){var e=this,n=arguments;return new Promise(function(i,r){var o=t.apply(e,n);function s(e){p(o,i,r,s,a,"next",e)}function a(e){p(o,i,r,s,a,"throw",e)}s(void 0)})})()}),ed.show(),{dialog:ed,accordion:w,inputs:A}}},8509(e,t,n){"use strict";n.d(t,{kC:()=>o.kC,oE:()=>o.oE});var i,r,o=n(9991);(i=r||(r={}))[i.default=0]="default",i[i.continuous=1]="continuous"},7461(e,t,n){"use strict";n.d(t,{pj:()=>o});var i=n(6082);function r(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function o(){var e;return(e=function*(){let e=i.Func.find({package:"Bio",name:"getMonomerLibHelper"});if(0===e.length)throw Error('Package "Bio" must be installed for MonomerLibHelper.');return(yield e[0].prepare().call()).getOutputParamValue()},function(){var t=this,n=arguments;return new Promise(function(i,o){var s=e.apply(t,n);function a(e){r(s,i,o,a,l,"next",e)}function l(e){r(s,i,o,a,l,"throw",e)}a(void 0)})})()}},1381(e,t,n){"use strict";n.d(t,{AO:()=>l,B5:()=>h,Hi:()=>a,YI:()=>u,_S:()=>m,b9:()=>g,gp:()=>d,jz:()=>b,ot:()=>v,q7:()=>f});var i,r,o,s,a,l,u,d,c=n(4980);(i=a||(a={})).FASTA="fasta",i.SEPARATOR="separator",i.HELM="helm",i.CUSTOM="custom",i.BILN="biln",(r=l||(l={})).SEQ_MSA="SEQ.MSA",r.SEQ="SEQ",(o=u||(u={})).DNA="DNA",o.RNA="RNA",o.PT="PT",o.UN="UN",(s=d||(d={})).aligned="aligned",s.alphabet="alphabet",s.alphabetSize=".alphabetSize",s.alphabetIsMultichar=".alphabetIsMultichar",s.separator="separator",s.isHelmCompatible=".isHelmCompatible",s.positionNames=".positionNames",s.positionLabels=".positionLabels",s.regions=".regions",s.positionShift=".positionShift",s.selectedPosition=".selectedPosition",s.polymerTypeColumnName=".polymerTypeColumnName",s.annotations=".annotations",s.numberingScheme=".numberingScheme",s.annotationColumnName=".annotationColumnName";let h=/(?:\[([A-Za-z0-9_\-,()]+)\])|([A-Za-z\-])/g,p=new class{constructor(){this.fasta={peptide:new Set(["G","L","Y","S","E","Q","D","N","F","A","K","R","H","C","V","P","W","I","M","T"]),dna:new Set(["A","C","G","T"]),rna:new Set(["A","C","G","U"])}}},f=[new c.aD(u.PT,p.fasta.peptide,.5),new c.aD(u.DNA,p.fasta.dna,.55),new c.aD(u.RNA,p.fasta.rna,.55)],m="",g={[a.FASTA]:"-",[a.SEPARATOR]:"",[a.HELM]:"*",[a.BILN]:""},v=" , ",b=".%monomer-canonicalizer-func"},8621(e,t,n){"use strict";n.d(t,{AO:()=>i.AO,Hi:()=>i.Hi,SM:()=>r.SM,YI:()=>i.YI,gp:()=>i.gp,ot:()=>i.ot,zS:()=>r.zS});var i=n(1381),r=n(1004)},7563(e,t,n){"use strict";n.d(t,{j:()=>r});var i=n(6082);n(1381),n(1004);let r=new class{constructor(){this.seqHandler="seq-handler",this.notationProvider="seq-handler.notation-provider"}};i.SemanticValue},4980(e,t,n){"use strict";n.d(t,{XN:()=>r,aD:()=>i});class i{constructor(e,t,n){this.name=e,this.alphabet=t,this.cutoff=n}}class r extends i{constructor(e,t,n){super(e.name,e.alphabet,e.cutoff),this.freq=t,this.similarity=n}}},1004(e,t,n){"use strict";n.d(t,{zS:()=>z,SM:()=>q,Mu:()=>O,qp:()=>D});var i=n(6082),r=n(1991),o=n.n(r);class s extends Float32Array{}function a(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*e[n];return Math.sqrt(t)}var l=n(9991),u=n(4980),d=n(1381);class c{static makePalette(e,t,n){let i=void 0!==t&&t,r=void 0===n?c:n,o={};return e.forEach(e=>{let t=e[0],n=e[1];t.forEach((e,t)=>{o[e]=this.colourPalette[n][i?0:t]})}),new r(o)}get(e,t){return this._palette[e]}constructor(e){this._palette=e}}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}c.undefinedColor="rgb(100,100,100)",c.colourPalette={orange:["rgb(255,187,120)","rgb(245,167,100)","rgb(235,137,70)","rgb(205, 111, 71)"],all_green:["rgb(44,160,44)","rgb(74,160,74)","rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)","rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],all_blue:["rgb(31,119,180)","rgb(23,190,207)","rgb(122, 102, 189)","rgb(158,218,229)","rgb(141, 124, 217)","rgb(31, 120, 150)"],magenta:["rgb(162,106,192)","rgb(197,165,224)","rgb(208,113,218)"],red:["rgb(214,39,40)","rgb(255,152,150)"],st_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(31,119,180)"],dark_blue:["rgb(31,119,180)","rgb(31, 120, 150)"],light_blue:["rgb(23,190,207)","rgb(158,218,229)","rgb(108, 218, 229)","rgb(23,190,227)"],lilac_blue:["rgb(124,102,211)","rgb(149,134,217)","rgb(97, 81, 150)"],dark_green:["rgb(23,103,57)","rgb(30,110,96)","rgb(60,131,95)","rgb(24,110,79)"],green:["rgb(44,160,44)","rgb(74,160,74)"],light_green:["rgb(152,223,138)","rgb(182, 223, 138)","rgb(152, 193, 138)"],st_green:["rgb(44,160,44)","rgb(152,223,138)","rgb(39, 174, 96)","rgb(74,160,74)"],pink:["rgb(247,182,210)"],brown:["rgb(140,86,75)","rgb(102, 62, 54)"],gray:["rgb(127,127,127)","rgb(199,199,199)","rgb(196,156,148)","rgb(222, 222, 180)"],yellow:["rgb(188,189,34)"],white:["rgb(230,230,230)"]};class p extends c{static get Lesk(){return void 0===this.lesk&&(this.lesk=this.makePalette([[["G","A","S","T"],"orange"],[["C","V","I","L","P","F","Y","M","W"],"all_green"],[["N","Q","H"],"magenta"],[["D","E"],"red"],[["K","R"],"all_blue"]],!1,p)),this.lesk}static get GrokGroups(){return void 0===this.grokGroups&&(this.grokGroups=this.makePalette([[["C","U"],"yellow"],[["G","P"],"red"],[["A","V","I","L","M","F","Y","W"],"all_green"],[["R","H","K"],"light_blue"],[["D","E"],"dark_blue"],[["S","T","N","Q"],"orange"]],!1,p)),this.grokGroups}static get RasMol(){return void 0===this.rasMol&&(this.rasMol=new p({D:"#E60A0A",E:"#E60A0A",C:"#E6E600",M:"#E6E600",K:"#145AFF",R:"#145AFF",S:"#FA9600",T:"#FA9600",F:"#3232AA",Y:"#3232AA",N:"#00DCDC",Q:"#00DCDC",G:"#EBEBEB",L:"#0F820F",V:"#0F820F",I:"#0F820F",A:"#C8C8C8",W:"#B45AB4",H:"#8282D2",P:"#DC9682",others:"#BEA06E"})),this.rasMol}get(e){let t=e in p.aaSynonyms?p.aaSynonyms[e]:e;return super.get(t)}}p.aaSynonyms={MeNle:"L",MeA:"A",MeG:"G",MeF:"F"};class f{static getPalette(e){let t=void 0===e?"grok":e;switch(t){case"grok":return p.GrokGroups;case"lesk":return p.Lesk;default:throw Error(`ChemPalette: scheme \`${t}\` does not exist`)}}static getInnerOuter(e){let t=0,n="",i="";var r=!0,o=!1,s=void 0;try{for(var a,l=e[Symbol.iterator]();!(r=(a=l.next()).done);r=!0){let e=a.value;"("==e?t++:")"==e?t--:t?n+=e:i+=e}}catch(e){o=!0,s=e}finally{try{r||null==l.return||l.return()}finally{if(o)throw s}}return isNaN(parseInt(n))?[i,n]:[i,""]}static getColorAAPivot(e,t){var n,i,r,o;let s=void 0===e?"":e,a=this.getPalette(void 0===t?"grok":t),l=function(e){if(Array.isArray(e))return e}(o=this.getInnerOuter(s))||function(e){var t,n,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var r=[],o=!0,s=!1;try{for(i=i.call(e);!(o=(t=i.next()).done)&&(r.push(t.value),2!==r.length);o=!0);}catch(e){s=!0,n=e}finally{try{o||null==i.return||i.return()}finally{if(s)throw n}}return r}}(o)||function(e){if(e){if("string"==typeof e)return h(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return h(e,2)}}(o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=l[0],d=l[1];if(u=u.length>6?`${u.slice(0,3)}...`:u,d=d.length>6?`${d.slice(0,3)}...`:d,1==s.length||"("==s[1]){let e=null==(i=s[0])?void 0:i.toUpperCase();return e in a?[a.get(e),e,d,1]:[this.undefinedColor,u,d,1]}if("d"==s[0]&&s[1]in a&&(2==s.length||"("==s[2])){let e=null==(r=s[1])?void 0:r.toUpperCase();return e in a?[a.get(e),e,d,2]:[this.undefinedColor,u,d,2]}if(s.substring(0,3)in this.AAFullNames&&(3==s.length||"("==s[3])){let e=this.AAFullNames[s.substring(0,3)];return e in a?[a.get(e),e,d,3]:[this.undefinedColor,u,d,3]}if((null==(n=s[0])?void 0:n.toLowerCase())==s[0]&&s.substring(1,3)in this.AAFullNames&&(4==s.length||"("==s[4])){let e=this.AAFullNames[s.substring(1,3)];return e in a?[a.get(e),e,d,4]:[this.undefinedColor,u,d,4]}return[this.undefinedColor,u,d,0]}}f.SemType="Aminoacids",f.SemTypeMultipleAlignment="AminoacidsMultipleAlignment",f.undefinedColor="rgb(100,100,100)",f.Names={G:"Glycine",L:"Leucine",Y:"Tyrosine",S:"Serine",E:"Glutamic acid",Q:"Glutamine",D:"Aspartic acid",N:"Asparagine",F:"Phenylalanine",A:"Alanine",K:"Lysine",R:"Arginine",H:"Histidine",C:"Cysteine",V:"Valine",P:"Proline",W:"Tryptophan",I:"Isoleucine",M:"Methionine",T:"Threonine"},f.AASmiles={G:"NCC(=O)O",L:"N[C@H](CC(C)C)C(=O)O",Y:"NC(CC1=CC=C(O)C=C1)C(=O)O",S:"NC(CO)C(=O)O",E:"N[C@@H](CCC(O)=O)C(=O)O",Q:"N[C@@H](CCC(N)=O)C(=O)O",D:"N[C@@H](CC(O)=O)C(=O)O",N:"N[C@@H](CC(N)=O)C(=O)O",F:"NC(CC1=CC=CC=C1)C(=O)O",A:"N[C@H](C)C(=O)O",K:"NC(CCCCN)C(=O)O",R:"N[C@H](CCCNC(=N)C)C(=O)O",H:"NC(CC1=CN=C[N]1)C(=O)O",C:"N[C@@H](CS)C(=O)O",V:"NC(C(C)C)C(=O)O",P:"N(CCC1)C1C(=O)O",W:"N[C@@H](Cc1c2ccccc2n([H])c1)C(=O)O",I:"N[C@H]([C@H](C)CC)C(=O)O",M:"NC(CCSC)C(=O)O",T:"NC(C(O)C)C(=O)O"},f.AASmilesTruncated={G:"*C*",L:"CC(C)C[C@H](*)*",Y:"C1=CC(=CC=C1CC(*)*)O",S:"OCC(*)C*",E:"*[C@@H](CCC(O)=O)*",Q:"*N[C@@H](CCC(N)=O)*",D:"*[C@@H](CC(O)=O)*",N:"*[C@@H](CC(N)=O)*",F:"C1=CC=C(C=C1)CC(*)*",A:"C[C@H](*)*",K:"C(CCN)CC(*)*",R:"*[C@H](CCCNC(=N)C)*",H:"C1=C(NC=N1)CC(*)*",C:"C([C@@H](*)*)S",V:"CC(C)C(*)*",P:"C1CCN(*)C1*",W:"*[C@@H](Cc1c2ccccc2n([H])c1)*",I:"CC[C@H](C)[C@H](*)*",M:"CSCCC(*)*",T:"CC(O)C(*)*"},f.AAFullNames={Ala:"A",Arg:"R",Asn:"N",Asp:"D",Cys:"C",Gln:"Q",Glu:"E",Gly:"G",His:"H",Ile:"I",Leu:"L",Lys:"K",Met:"M",Phe:"F",Pro:"P",Ser:"S",Thr:"T",Trp:"W",Tyr:"Y",Val:"V"};class m extends c{static get Chromatogram(){return void 0===this.chromatogram&&(this.chromatogram=new m({A:"green",C:"blue",G:"black",T:"red",U:"red",others:"gray"})),this.chromatogram}}class g{}g.SemType="Nucleotides",g.SemTypeMultipleAlignment="NucleotidesMultipleAlignment",g.Names={A:"Adenine",C:"Cytosine",G:"Guanine",T:"Thymine",U:"Uracil"};var v=n(7461),b=n(8509);function y(e,t){if(null==e)return"rgb(100,100,100)";let n=i.Color.fromHtml(e);if(void 0===t||t){let e=i.Color.g(n),t=i.Color.r(n),r=i.Color.b(n),o=Math.sqrt(Math.pow(0-t,2)+Math.pow(0-e,2)+Math.pow(0-r,2));if(o>210)return`rgb(${t/o*210},${e/o*210},${r/o*210})`}return i.Color.toRgb(n)}class _{static hashCode(e){let t=0;if(0===e.length)return t;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}}class w{}class x extends w{get(e,t){return"#666666"}}class k extends w{static get palette(){return k._pallete||(k._pallete=k.buildPalette()),k._pallete}static buildPalette(){return(0,v.pj)().then(e=>{e.awaitLoaded(1/0).then(()=>{let t=e.getMonomerLib();t.onChanged.subscribe(()=>{k.customMonomerColors={},k.polymerTypes=t.getPolymerTypes();var e=!0,n=!1,i=void 0;try{for(var r,o=this.polymerTypes[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){let e=r.value,n=t.getMonomerSymbolsByType(e);var s=!0,a=!1,l=void 0;try{for(var u,d,c,h,p=n[Symbol.iterator]();!(s=(h=p.next()).done);s=!0){let n=h.value,i=t.getMonomer(e,n);(null==i||null==(c=i.meta)||null==(d=c.colors)||null==(u=d.default)?void 0:u.background)&&(this.customMonomerColors[n]||(this.customMonomerColors[n]={}),this.customMonomerColors[n][e]=y(i.meta.colors.default.background))}}catch(e){a=!0,l=e}finally{try{s||null==p.return||p.return()}finally{if(a)throw l}}}}catch(e){n=!0,i=e}finally{try{e||null==o.return||o.return()}finally{if(n)throw i}}})})}),[].concat(...Object.values(c.colourPalette))}get(e,t){let n=k.palette.length,i=k.customMonomerColors[e],r=null!=t?t:b.kC.PEPTIDE;if(i&&i[r])return i[r];let o=_.hashCode(e);return y(k.palette[o%n])}}k._pallete=null,k.customMonomerColors={},k.polymerTypes=[];class S extends c{static get Gray(){return void 0===this.gray&&(this.gray=new x),this.gray}static get Color(){return void 0===this.color&&(this.color=new k),this.color}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function A(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,i,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{s||null==r.return||r.return()}finally{if(a)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return C(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return C(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}class O{get length(){return this.mList.length}get graphInfo(){}isGap(e){return this.getOriginal(e)===this.gapOriginalMonomer}getCanonical(e){if(this.length<=e)throw Error("Index out of bounds");let t=this.mList[e];return t!==this.gapOriginalMonomer?t:d._S}getOriginal(e){if(this.length<=e)throw Error("Index out of bounds");return this.mList[e]}getCanonicalRegion(e,t){let n=Math.min(Math.max(0,e),this.length),i=Math.max(Math.min(this.length,t),0),r=this.gapOriginalMonomer;return Array(i-n).fill(null).map((e,t)=>{let i=this.mList[t+n];return i===r?d._S:i})}getOriginalRegion(e,t){let n=Math.min(Math.max(0,e),this.length);return Array(Math.max(Math.min(this.length,t),0)-n).fill(null).map((e,t)=>this.mList[t+n])}get gapOriginal(){return this.gapOriginalMonomer}constructor(e,t){this.mList=e,this.gapOriginalMonomer=t}}class E extends O{get graphInfo(){return null!=this._graphInfo||(this._graphInfo=this.parseConnections()),this._graphInfo}constructor(){super(...arguments),this._graphInfo=void 0}}let T=e=>{let t=[];var n=!0,i=!1,r=void 0;try{for(var o,s,a=e.toString().matchAll(d.B5)[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){let e=s.value;t.push(null!=(o=e[2])?o:e[1])}}catch(e){i=!0,r=e}finally{try{n||null==a.return||a.return()}finally{if(i)throw r}}return new O(t,d.b9[d.Hi.FASTA])};class P extends E{parseConnections(){let e=this.row,t=e.chainStarts,n={connections:[],disjointSeqStarts:t,polymerTypes:e.monomerPolymerTypes},i=e=>{let n=t.length-1;for(;n>0&&t[n]>e;)--n;return n},r=void 0!==e.unmapped?[e.unmapped]:[];e.ambiguities&&r.push(...e.ambiguities);let o=[];var s=!0,a=!1,u=void 0;try{for(var d,c=e.links[Symbol.iterator]();!(s=(d=c.next()).done);s=!0){let s=d.value;if(void 0!==s.ambiguous){r.push(`ambiguous connection '${s.ambiguous}' is not supported`);continue}let a=i(s.a1),l=i(s.a2);if("hbond"===s.kind){o.push({seq1Type:n.polymerTypes[s.a1],seq2Type:n.polymerTypes[s.a2],seqIndex1:a,seqIndex2:l,monomerIndex1:s.a1-t[a],monomerIndex2:s.a2-t[l],rGroup1:0,rGroup2:0,kind:"hbond"});continue}if("cross-polymer"!==s.kind||"numeric"!==s.r1.kind||"numeric"!==s.r2.kind){let n=`${e.chainIds[a]},${e.chainIds[l]},${s.a1-t[a]+1}-${s.a2-t[l]+1}`;r.push(`connection ${n} with R-groups '${R(s.r1)}', '${R(s.r2)}' is not supported`);continue}n.connections.push({seq1Type:n.polymerTypes[s.a1],seq2Type:n.polymerTypes[s.a2],seqIndex1:a,seqIndex2:l,monomerIndex1:s.a1-t[a],monomerIndex2:s.a2-t[l],rGroup1:s.r1.r,rGroup2:s.r2.r,kind:"covalent"})}}catch(e){a=!0,u=e}finally{try{s||null==c.return||c.return()}finally{if(a)throw u}}var h=!0,p=!1,f=void 0;try{for(var m,g=e.chainIds[Symbol.iterator]();!(h=(m=g.next()).done);h=!0){let e=m.value;e.startsWith("DNA")&&r.push(`polymer type 'DNA' is not supported (${e})`)}}catch(e){p=!0,f=e}finally{try{h||null==g.return||g.return()}finally{if(p)throw f}}let v=void 0!==e.unmapped||e.diagnostics.some(L),b=e.diagnostics.some(e=>"bracket-repeat-too-large"===e.code);return r.push(...function(e){let t=[];var n=!0,i=!1,r=void 0;try{for(var o,s=e[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;(L(e)||M.has(e.code))&&t.push(`HELM ${e.code}: ${e.message}`)}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return t}(e.diagnostics)),n.hbonds=o,n.chainIds=e.chainIds,e.biotypesKnown&&(n.biotypes=e.biotypes),n.repeats=e.repeatMol&&!b?function(e,t,n){let i=new Map;var r=!0,o=!1,s=void 0;try{for(var a,u,d=e.atoms[Symbol.iterator]();!(r=(u=d.next()).done);r=!0){let e=u.value;i.set(e.id,e)}}catch(e){o=!0,s=e}finally{try{r||null==d.return||d.return()}finally{if(o)throw s}}let c=e=>{let n=t,r=0;var o=!0,s=!1,a=void 0;try{for(var l,u,d,c=e.members[Symbol.iterator]();!(o=(d=c.next()).done);o=!0){let e=d.value,t=i.get(parseInt(e.target,10));void 0!==t&&(n=Math.min(n,t.bio.continuousId-1),r=Math.max(r,t.bio.continuousId,null!=(l=null==(u=t.branchAtom)?void 0:u.bio.continuousId)?l:0))}}catch(e){s=!0,a=e}finally{try{o||null==c.return||c.return()}finally{if(s)throw a}}return{start:n,end:r}},h=(0,l.pj)(e),p=h.mol,f=h.unexpanded,m=[];var g=!0,v=!1,b=void 0;try{for(var y,_=e.groups[Symbol.iterator]();!(g=(y=_.next()).done);g=!0){let e=y.value;if("bracket"!==e.kind||void 0===e.repeat)continue;let t=c(e),i=t.start,r=t.end,o=r>i?` at position ${i+1}`:"";f.includes(e)?n.push(e.repeat.min!==e.repeat.max?`repeat range ${j(e.repeat)}${o} is not supported`:`repeat ${j(e.repeat)}${o} is not supported`):e.repeat.min>=1?r>i&&m.push({start:i,end:r,min:e.repeat.min,max:e.repeat.max}):n.push(`repeat ${j(e.repeat)}${o} is not supported`)}}catch(e){v=!0,b=e}finally{try{g||null==_.return||_.return()}finally{if(v)throw b}}m.sort((e,t)=>e.start-t.start);for(let e=1;e<m.length;++e)if(m[e].start<m[e-1].end)return n.push(`nested repeats at position ${m[e-1].start+1} are not supported`),m;let w=[];for(let e=0,n=0;e<t;){let t=n<m.length&&m[n].start===e?m[n++]:null;if(null===t){w.push(e++);continue}for(let e=0;e<t.min;++e)for(let e=t.start;e<t.end;++e)w.push(e);e=t.end}let x=Array(p.atoms.length);var k=!0,S=!1,C=void 0;try{for(var A,O=p.atoms[Symbol.iterator]();!(k=(A=O.next()).done);k=!0){let e=A.value;x[e.bio.continuousId-1]=(null!=(a=e.bio.sourceContinuousId)?a:e.bio.continuousId)-1}}catch(e){S=!0,C=e}finally{try{k||null==O.return||O.return()}finally{if(S)throw C}}return(x.length!==w.length||x.some((e,t)=>e!==w[t]))&&n.push(`repeats at positions ${m.map(e=>e.start+1).join(", ")} expand differently in hwe`),m}(e.repeatMol,this.length,r):[],n.errors=r,v&&(n.recovered=!0),n}constructor(e,t){super(e,d.b9[d.Hi.HELM]),this.row=t}}function N(e,t){return new P([],{monomerPolymerTypes:[],chainStarts:[],chainIds:[],links:[],biotypes:[],biotypesKnown:!1,repeatMol:null,diagnostics:t,ambiguities:null,unmapped:e})}let I=new Set(["missing-section-separator"]),M=new Set(["repeat-zero-count","bracket-repeat-too-large","duplicate-polymer-id"]);function L(e){return"error"===e.severity&&!I.has(e.code)}function R(e){switch(e.kind){case"numeric":return`R${e.r}`;case"positional":return`${e.position}:R${e.r}`;case"unspecified":return"?";case"wildcard":return"*";case"pair":return"pair"}}let j=e=>e.min===e.max?`'${e.min}'`:`'${e.min}-${e.max}'`,D=e=>{let t=(0,l.UV)(e,null,{mode:"lenient"}),n=t.mol,i=t.diagnostics,r=n.atoms,o=n.chains,s=o.length,a=r.length,u=Array(a),d=Array(a),c=Array(a),h=Array(s),p=Array(s),f=0;for(let e=0;e<s;++e){h[e]=o[e].id,p[e]=f;var m=!0,g=!1,v=void 0;try{for(var y,_=o[e].backboneAtoms[Symbol.iterator]();!(m=(y=_.next()).done);m=!0){let e=y.value;f+=void 0===e.branchAtom?1:2}}catch(e){g=!0,v=e}finally{try{m||null==_.return||_.return()}finally{if(g)throw v}}}if(f!==a)return N("HELM parse: hwe chain sizes do not add up to its monomers",i);let w=!0,x=null,k=!0,S=-1,C="",O=b.kC.PEPTIDE;for(let e=0;e<a;++e){let t=r[e],n=t.bio;for(n.continuousId!==e+1&&(k=!1);S+1<s&&p[S+1]<=e;)C=h[++S],O=o[S].polymerType;n.chainId!==C&&(k=!1),u[e]=t.symbol,d[e]=O,c[e]=t.biotype,t.biotype===b.oE.SUGAR&&void 0===t.branchAtom&&(w=!1),void 0!==n.ambiguity&&(null!=x?x:x=[]).push(`ambiguous monomer '${n.ambiguity}' at position ${e+1} is not supported`)}if(!k)return N("HELM parse: hwe chains out of order",i);let E=[];var T=!0,I=!1,M=void 0;try{for(var L,j=n.bonds[Symbol.iterator]();!(T=(L=j.next()).done);T=!0){let e=L.value;if("backbone"===e.kind||"branch"===e.kind)continue;let t={a1:e.a1.bio.continuousId-1,a2:e.a2.bio.continuousId-1,r1:e.r1,r2:e.r2,kind:e.kind};void 0!==e.endpoints&&(0,l.I6)(e)&&!function(e,t){var n=!0,i=!1,r=void 0;try{for(var o,s=e.endpoints[Symbol.iterator]();!(n=(o=s.next()).done);n=!0){let e=o.value;if(e.isGroup)return!1;let n=e.position;if("index"===n.kind)continue;if("symbol"!==n.kind)return!1;let i=0;var a=!0,l=!1,u=void 0;try{for(var d,c=t[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){let t=d.value;t.symbol===n.value&&t.bio.chainId===e.polymerId&&++i}}catch(e){l=!0,u=e}finally{try{a||null==c.return||c.return()}finally{if(l)throw u}}if(1!==i)return!1}}catch(e){i=!0,r=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw r}}return!0}(e,r)&&(t.ambiguous=function(e){let t=A(e.endpoints,2),n=t[0],i=t[1];return`${n.polymerId},${i.polymerId},${(0,l.nX)(n.position)}:${R(e.r1)}-${(0,l.nX)(i.position)}:${R(e.r2)}`}(e)),E.push(t)}}catch(e){I=!0,M=e}finally{try{T||null==j.return||j.return()}finally{if(I)throw M}}return new P(u,{monomerPolymerTypes:d,chainStarts:p,chainIds:h,links:E,biotypes:c,biotypesKnown:w,repeatMol:n.groups.some(e=>"bracket"===e.kind&&void 0!==e.repeat)?n:null,diagnostics:i,ambiguities:x})},F=/([^\W_]+)/g;function z(e,t){var n,i;if(e.length<=t)return e;let r=e.match(F),o=e.length>t||(null!=(n=null==r?void 0:r.length)?n:0)>1,s=null!=(i=null==r?void 0:r[0])?i:" ";return o?s.substring(0,t-1)+"…":s}function q(e,t,n){let r;if(e.semType==i.SEMTYPE.MACROMOLECULE)r=t.getSeqHandler(e).alphabet;else{var l,c,h;let t,i,p;c=(l=void 0===n?5:n,t=e.categories,function(e,t){let n={},i=!0,r=null;var o=!0,s=!1,a=void 0;try{for(var l,u=e[Symbol.iterator]();!(o=(l=u.next()).done);o=!0){let e=l.value;if(null==r?r=e.length:e.length!==r&&(i=!1),e.length>=t)for(let t=0;t<e.length;++t){let i=e.getCanonical(t);i in n||(n[i]=0),n[i]+=1}}}catch(e){s=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(s)throw a}}return{freq:n,sameLength:i}}(o().enumerate(e.getRawData()).map(e=>{let n=A(e,2),i=n[0];return n[1],T(t[i])}),l)).freq,h=d.q7,r=(p=Math.max(...(i=h.map(e=>{let t=function(e,t){let n=new Set([...new Set(Object.keys(e)),...t]);n.delete("-");let i=[],r=[];var o=!0,l=!1,u=void 0;try{for(var d,c=n[Symbol.iterator]();!(o=(d=c.next()).done);o=!0){let n=d.value;i.push(n in e?e[n]:0),r.push(+!!t.has(n))}}catch(e){l=!0,u=e}finally{try{o||null==c.return||c.return()}finally{if(l)throw u}}let h=new s(i),p=new s(r);return function(e,t){if(e.length!=t.length)throw Error("The dimensionality of the vectors must match");let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n}(h,p)/(a(h)*a(p))}(c,e.alphabet);return new u.XN(e,c,t)})).map(e=>e.similarity>e.cutoff?e.similarity:-1)))>0?i.find(e=>e.similarity===p).name:d.YI.UN}var f=r;switch(f){case d.YI.PT:return p.GrokGroups;case d.YI.DNA:case d.YI.RNA:return m.Chromatogram;default:return S.Color}}},7351(e,t,n){"use strict";n.d(t,{R:()=>s});var i=n(6082),r=n(7563),o=n(1381);function s(e,t){let n=e=>{var t;return null!=(t=a[e])?t:null},s=e=>{let t=u.columns.addNewString((e+1).toString());return a.push(t),t},a=[],l=e.length,u=i.DataFrame.create(l),d=t.getSeqHandler(e);for(let e=0;e<l;++e){let t=d.getSplitted(e);for(let i=0;i<t.length;++i){let r=t.getOriginal(i);(n(i)||s(i)).set(e,r,!1)}}let c=null!=(g=e.temp[r.j.notationProvider])?g:null,h=null==c?void 0:c.monomerCanonicalizerFuncName;var p=!0,f=!1,m=void 0;if(h)try{for(var g,v,b=a[Symbol.iterator]();!(p=(v=b.next()).done);p=!0)v.value.setTag(o.jz,h)}catch(e){f=!0,m=e}finally{try{p||null==b.return||b.return()}finally{if(f)throw m}}return u}},3712(e,t,n){"use strict";n.d(t,{P4:()=>c,fH:()=>u});var i,r,o,s,a,l,u,d,c,h,p,f=n(6082);(l||(l={})).tooltipWebLogo=".tooltipWebLogo",(i=u||(u={})).Entropy="Entropy",i.full="100%",(r=d||(d={})).TOP="top",r.MIDDLE="middle",r.BOTTOM="bottom",(o=c||(c={})).LEFT="left",o.CENTER="center",o.RIGHT="right",(s=h||(h={})).AUTO="auto",s.ON="on",s.OFF="off",(a=p||(p={})).Filtered="Filtered",a.Selected="Selected",new class{constructor(){this.sequenceColumnName=null,this.profile=null,this.valueAggrType=f.AGG.TOTAL_COUNT,this.valueColumnName="Activity",this.startPositionName=null,this.endPositionName=null,this.skipEmptySequences=!0,this.skipEmptyPositions=!1,this.shrinkEmptyTail=!0,this.backgroundColor=0xffffffff,this.positionHeight=u.Entropy,this.positionWidth=20,this.verticalAlignment=d.MIDDLE,this.horizontalAlignment=c.CENTER,this.fixWidth=!1,this.fitArea=!0,this.minHeight=25,this.maxHeight=300,this.maxMonomerLetters=5,this.showPositionLabels=!0,this.positionMarginState=h.AUTO,this.positionMargin=0,this.filterSource=p.Filtered}}},4084(e,t,n){"use strict";e=n.hmd(e);var i,r=(i="u">typeof document&&document.currentScript?document.currentScript.src:void 0,function(e){let t=void 0===e?{}:e;var n,r,o,s,a,l,u,d,c,h,p,f=void 0!==t?t:{};f.ready=new Promise(function(e,t){r=e,o=t});var m=Object.assign({},f),g="object"==typeof window,v="function"==typeof importScripts;"object"==typeof process&&"object"==typeof process.versions&&process.versions.node;var b="";(g||v)&&(v?b=self.location.href:"u">typeof document&&document.currentScript&&(b=document.currentScript.src),i&&(b=i),b=0!==b.indexOf("blob:")?b.substr(0,b.replace(/[?#].*/,"").lastIndexOf("/")+1):"",v&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)})),f.print||console.log.bind(console);var y=f.printErr||console.warn.bind(console);Object.assign(f,m),m=null,f.arguments&&f.arguments,f.thisProgram&&f.thisProgram,f.quit&&f.quit,f.wasmBinary&&(a=f.wasmBinary),f.noExitRuntime,"object"!=typeof WebAssembly&&E("no native wasm support detected");var _=!1;function w(){var e=l.buffer;f.HEAP8=u=new Int8Array(e),f.HEAP16=new Int16Array(e),f.HEAP32=new Int32Array(e),f.HEAPU8=d=new Uint8Array(e),f.HEAPU16=new Uint16Array(e),f.HEAPU32=c=new Uint32Array(e),f.HEAPF32=new Float32Array(e),f.HEAPF64=new Float64Array(e)}var x=[],k=[],S=[],C=0,A=null,O=null;function E(e){f.onAbort&&f.onAbort(e),y(e="Aborted("+e+")"),_=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw o(t),t}function T(e){return e.startsWith("data:application/octet-stream;base64,")}function P(e){try{if(e==h&&a)return new Uint8Array(a);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}catch(e){E(e)}}function N(e,t,n){return(!a&&(g||v)&&"function"==typeof fetch?fetch(e,{credentials:"same-origin"}).then(function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()}).catch(function(){return P(e)}):Promise.resolve().then(function(){return P(e)})).then(function(e){return WebAssembly.instantiate(e,t)}).then(function(e){return e}).then(n,function(e){y("failed to asynchronously prepare wasm: "+e),E(e)})}function I(e){for(;e.length>0;)e.shift()(f)}function M(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){c[this.ptr+4>>2]=e},this.get_type=function(){return c[this.ptr+4>>2]},this.set_destructor=function(e){c[this.ptr+8>>2]=e},this.get_destructor=function(){return c[this.ptr+8>>2]},this.set_caught=function(e){e=+!!e,u[this.ptr+12|0]=e},this.get_caught=function(){return 0!=u[this.ptr+12|0]},this.set_rethrown=function(e){e=+!!e,u[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=u[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){c[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return c[this.ptr+16>>2]},this.get_exception_ptr=function(){if(G(this.get_type()))return c[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}T(h="wasmDbscan.wasm")||(n=h,h=f.locateFile?f.locateFile(n,b):b+n);var L=0,R=0,j="u">typeof TextDecoder?new TextDecoder("utf8"):void 0;function D(e,t,n,i,r){var o={string:e=>{var t,n,i=0;return null!=e&&0!==e&&(t=function(e){for(var t=0,n=0;n<e.length;++n){var i=e.charCodeAt(n);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++n):t+=3}return t}(e)+1,function(e,t,n){var i=d,r=t;if(n>0){for(var o=r+n-1,s=0;s<e.length;++s){var a=e.charCodeAt(s);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++s)),a<=127){if(r>=o)break;i[r++]=a}else if(a<=2047){if(r+1>=o)break;i[r++]=192|a>>6,i[r++]=128|63&a}else if(a<=65535){if(r+2>=o)break;i[r++]=224|a>>12,i[r++]=128|a>>6&63,i[r++]=128|63&a}else{if(r+3>=o)break;i[r++]=240|a>>18,i[r++]=128|a>>12&63,i[r++]=128|a>>6&63,i[r++]=128|63&a}}i[r]=0}}(e,n=B(t),t),i=n),i},array:e=>{var t=B(e.length);return u.set(e,t),t}},s=f["_"+e],a=[],l=0;if(i)for(var c=0;c<i.length;c++){var h=o[n[c]];h?(0===l&&(l=z()),a[c]=h(i[c])):a[c]=i[c]}var p=s.apply(null,a);return function(e){return(0!==l&&q(l),"string"===t)?e?function(e,t,n){for(var i=t+n,r=t;e[r]&&!(r>=i);)++r;if(r-t>16&&e.buffer&&j)return j.decode(e.subarray(t,r));for(var o="";t<r;){var s=e[t++];if(!(128&s)){o+=String.fromCharCode(s);continue}var a=63&e[t++];if((224&s)==192){o+=String.fromCharCode((31&s)<<6|a);continue}var l=63&e[t++];if((s=(240&s)==224?(15&s)<<12|a<<6|l:(7&s)<<18|a<<12|l<<6|63&e[t++])<65536)o+=String.fromCharCode(s);else{var u=s-65536;o+=String.fromCharCode(55296|u>>10,56320|1023&u)}}return o}(d,e,void 0):"":"boolean"===t?!!e:e}(p)}var F={__cxa_throw:function(e,t,n){throw new M(e).init(t,n),L=e,R++,L},abort:function(){E("")},emscripten_memcpy_big:function(e,t,n){d.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t=d.length;if((e>>>=0)>0x80000000)return!1;let n=(e,t)=>e+(t-e%t)%t;for(var i=1;i<=4;i*=2){var r=t*(1+.2/i);if(r=Math.min(r,e+0x6000000),function(e){var t=l.buffer;try{return l.grow(e-t.byteLength+65535>>>16),w(),1}catch(e){}}(Math.min(0x80000000,n(Math.max(e,r),65536))))return!0}return!1}};!function(){var e,t,n,i={env:F,wasi_snapshot_preview1:F};function r(e,t){var n,i=e.exports;if(f.asm=i,l=f.asm.memory,w(),f.asm.__indirect_function_table,n=f.asm.__wasm_call_ctors,k.unshift(n),C--,f.monitorRunDependencies&&f.monitorRunDependencies(C),0==C&&(null!==A&&(clearInterval(A),A=null),O)){var r=O;O=null,r()}return i}if(C++,f.monitorRunDependencies&&f.monitorRunDependencies(C),f.instantiateWasm)try{return f.instantiateWasm(i,r)}catch(e){y("Module.instantiateWasm callback failed with error: "+e),o(e)}(e=a,t=h,n=function(e){r(e.instance)},!e&&"function"==typeof WebAssembly.instantiateStreaming&&!T(t)&&"function"==typeof fetch?fetch(t,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,i).then(n,function(e){return y("wasm streaming compile failed: "+e),y("falling back to ArrayBuffer instantiation"),N(t,i,n)})}):N(t,i,n)).catch(o)}(),f._dbscan=function(){return(f._dbscan=f.asm.dbscan).apply(null,arguments)},f._malloc=function(){return(f._malloc=f.asm.malloc).apply(null,arguments)},f._free=function(){return(f._free=f.asm.free).apply(null,arguments)};var z=function(){return(z=f.asm.stackSave).apply(null,arguments)},q=function(){return(q=f.asm.stackRestore).apply(null,arguments)},B=function(){return(B=f.asm.stackAlloc).apply(null,arguments)},G=function(){return(G=f.asm.__cxa_is_pointer_type).apply(null,arguments)};function V(){if(!(C>0)){if(f.preRun)for("function"==typeof f.preRun&&(f.preRun=[f.preRun]);f.preRun.length;){var e;e=f.preRun.shift(),x.unshift(e)}I(x),C>0||(f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("")},1),t()},1)):t())}function t(){if(!p&&(p=!0,f.calledRun=!0,!_)){if(I(k),r(f),f.onRuntimeInitialized&&f.onRuntimeInitialized(),f.postRun)for("function"==typeof f.postRun&&(f.postRun=[f.postRun]);f.postRun.length;){var e;e=f.postRun.shift(),S.unshift(e)}I(S)}}}if(f.ccall=D,f.cwrap=function(e,t,n,i){var r=!n||n.every(e=>"number"===e||"boolean"===e);return"string"!==t&&r&&!i?f["_"+e]:function(){return D(e,t,n,arguments,i)}},O=function e(){p||V(),p||(O=e)},f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.pop()();return V(),t.ready});"object"==typeof exports?e.exports=r:"function"==typeof define&&define.amd?define([],function(){return r}):"object"==typeof exports&&(exports.exportCppDbscanLib=r)},9417(e,t,n){"use strict";function i(e,t,n,i,r,o,s){try{var a=e[o](s),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(i,r)}function r(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var s=e.apply(t,n);function a(e){i(s,r,o,a,l,"next",e)}function l(e){i(s,r,o,a,l,"throw",e)}a(void 0)})}}n.d(t,{_U:()=>a});let o=null,s=null;function a(){return r(function*(){var e,t,n;if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!o&&!(yield r(function*(){if(!navigator.gpu)return console.error("WebGPU is not supported in this browser"),null;if(!o&&null==(o=yield navigator.gpu.requestAdapter({powerPreference:"high-performance"})))return null;if(!s){let e=o.limits,t=e.maxBufferSize,n=e.maxStorageBufferBindingSize;try{s=yield o.requestDevice({requiredLimits:{maxBufferSize:Math.min(t,1e9),maxStorageBufferBindingSize:Math.min(n,1e9)}})}catch(e){console.error("Failed to create device with required limits",e),s=yield o.requestDevice()}let i=s;i.lost.then(()=>{s===i&&(s=null,o=null)})}return s})()))return null;let i=null;return("info"in o&&(i=o.info),i)?(t=i.description,n=(e=i.vendor)&&""!=e?e:"No GPU description available",t&&""!=t?t:n):"No GPU description available"})()}},4386(e,t,n){"use strict";var i,r;n.d(t,{Z:()=>i});new Uint32Array(65536);(r=i||(i={})).HAMMING="Hamming",r.LEVENSHTEIN="Levenshtein",r.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",r.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance",i.HAMMING,i.LEVENSHTEIN,i.NEEDLEMANN_WUNSCH,i.MONOMER_CHEMICAL_DISTANCE},9222(e,t,n){"use strict";n.d(t,{A:()=>r});var i=n(7660);class r{static _wrap(e){return new r(e.getBuffer(),e.length)}_sync(){this._data=this._core.getBuffer(),this._length=this._core.length,this._version++}static fromValues(e){return r.fromSeq(e.length,t=>e[t])}static fromSeq(e,t){return r._wrap(i.P.create(e,t))}static fromString(e){return r._wrap(i.P.fromString(e))}static fromUint32Array(e,t){return new r(t,e)}static fromBytes(e){return r._wrap(i.P.fromBytes(e))}getRawData(){return this._data}get buffer(){return this._data}set buffer(e){let t=new Uint32Array(this._core.lengthInInts);t.set(e.subarray(0,t.length)),this._core=new i.P(t,this._length),this._sync()}get version(){return this._version}set version(e){this._version=e}incrementVersion(e){this._version++}get length(){return this._length}get lengthInInts(){return this._core.lengthInInts}setLength(e){this._core.setLength(e),this._sync()}removeAt(e,t){this._core.removeAt(e,void 0===t?1:t),this._sync()}clear(){this.setLength(0)}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(e){return this._core.equals(e._core)}clone(){let e=r._wrap(this._core.clone());return e._version=this._version,e}copyFrom(e){this._core.copyFrom(e._core),this._version++}init(e,t){return this._core.init(e),this._version++,this}invert(e){this._core.invert(),this._version++}setAll(e,t){this._core.setAll(e),this._version++}getRange(e,t){return r._wrap(this._core.getRange(e,t))}getRangeAsList(e,t){let n=[];for(let i=e;i<t;i++)n.push(this._core.get(i));return n}setRange(e,t,n,i){return this._core.setRange(Math.min(e,t),Math.max(e,t)+1,n),this._version++,this}and(e,t){return this._core.and(e._core),this._version++,this}or(e,t){return this._core.or(e._core),this._version++,this}xor(e,t){return this._core.xor(e._core),this._version++,this}andNot(e,t){return this._core.andNot(e._core),this._version++,this}not(e){return this._core.invert(),this._version++,this}getBit(e){return this._core.get(e)}setBit(e,t,n){this._core.set(e,t),this._version++}setFast(e,t){this._core.set(e,t),this._version++}setTrue(e){this.setFast(e,!0)}setFalse(e){this.setFast(e,!1)}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(e){return e?this._core.trueCount:this._core.falseCount}andWithCountBits(e,t){return this._core.andWithCountBits(e._core,t)}contains(e){return this._core.findNext(-1,e)>=0}get allTrue(){return this._core.allTrue}get allFalse(){return this._core.allFalse}get anyTrue(){return this._core.anyTrue}get anyFalse(){return this._core.anyFalse}findNext(e,t){return this._core.findNext(e,void 0===t||t)}findPrev(e,t){return this._core.findPrev(e,void 0===t||t)}constructor(e,t){this._version=0,this._core=new i.P(e,void 0!==t&&t),this._data=this._core.getBuffer(),this._length=this._core.length}}},1757(e){"use strict";e.exports=$},6082(e){"use strict";e.exports=DG},4328(e){"use strict";e.exports=grok},1858(e){"use strict";e.exports=rxjs},9713(e){"use strict";e.exports=rxjs.operators},7389(e){"use strict";e.exports=ui},1991(e){"use strict";e.exports=wu},7660(e,t,n){"use strict";n.d(t,{P:()=>i});class i{constructor(e,t=!1){if("number"==typeof e)this._length=e,this._data=new Uint32Array(i._wordCount(e)),t&&this._data.fill(0xffffffff);else{if(this._length=t,e.length<i._wordCount(this._length))throw RangeError(`${e.length} words cannot hold ${this._length} bits`);this._data=e}this._trim()}static _wordCount(e){if(!(Number.isInteger(e)&&e>=0))throw RangeError(`Invalid length ${e}`);return e+31>>>5}_trim(){let e=31&this._length;return 0!==e&&(this._data[this._length>>>5]&=(1<<e)-1),this}_checkRange(e,t){if(e<0||t>this._length||e>t)throw RangeError(`Range [${e}, ${t}) is outside [0, ${this._length})`)}_checkLength(e){if(e._length!==this._length)throw RangeError(`Lengths differ (${this._length} != ${e._length})`)}static _popcount(e,t){let n=0;for(let i=0;i<t;i++){let t=e[i];t-=t>>>1&0x55555555,n+=Math.imul((t=(0x33333333&t)+(t>>>2&0x33333333))+(t>>>4)&0xf0f0f0f,0x1010101)>>>24}return n}static create(e,t){let n=new i(e);return null==t?n:n.init(t)}static fromString(e){return i.create(e.length,t=>49===e.charCodeAt(t))}static fromBytes(e,t){let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=t??8*n.length;if(r>8*n.length)throw RangeError(`${n.length} bytes cannot hold ${r} bits`);let o=new i(r),s=o._data,a=new DataView(n.buffer,n.byteOffset,n.byteLength),l=Math.min(s.length,n.length>>>2);for(let e=0;e<l;e++)s[e]=a.getUint32(4*e,!0);for(let e=4*l,t=Math.min(n.length,4*s.length);e<t;e++)s[e>>>2]|=n[e]<<(3&e)*8;return o._trim()}static fromUint32Array(e,t){return new i(t,e)}get length(){return this._length}get lengthInInts(){return i._wordCount(this._length)}getBuffer(){return this._data}get(e){return(this._data[e>>>5]&1<<(31&e))!=0}set(e,t){t?this._data[e>>>5]|=1<<(31&e):this._data[e>>>5]&=~(1<<(31&e))}get trueCount(){return i._popcount(this._data,this.lengthInInts)}get falseCount(){return this._length-this.trueCount}get anyTrue(){return -1!==this.findNext(-1,!0)}get anyFalse(){return -1!==this.findNext(-1,!1)}get allTrue(){return!this.anyFalse}get allFalse(){return!this.anyTrue}clone(){return new i(this._data.slice(0,this.lengthInInts),this._length)}copyFrom(e){return this._checkLength(e),this._data.set(e._data.subarray(0,this.lengthInInts)),this}equals(e){if(e===this)return!0;if(null==e||e._length!==this._length)return!1;for(let t=0,n=this.lengthInInts;t<n;t++)if(this._data[t]!==e._data[t])return!1;return!0}init(e){this._data.fill(0,0,this.lengthInInts);for(let t=0;t<this._length;t++)e(t)&&(this._data[t>>>5]|=1<<(31&t));return this}setAll(e){return this._data.fill(0xffffffff*!!e,0,this.lengthInInts),this._trim()}invert(){for(let e=0,t=this.lengthInInts;e<t;e++)this._data[e]=~this._data[e];return this._trim()}and(e){this._checkLength(e);for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]&=e._data[t];return this}or(e){this._checkLength(e);for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]|=e._data[t];return this}xor(e){this._checkLength(e);for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]^=e._data[t];return this}andNot(e){this._checkLength(e);for(let t=0,n=this.lengthInInts;t<n;t++)this._data[t]&=~e._data[t];return this}andWithCountBits(e,t=!0){this._checkLength(e);let n=0;for(let t=0,i=this.lengthInInts;t<i;t++){let i=this._data[t]&e._data[t];i-=i>>>1&0x55555555,n+=Math.imul((i=(0x33333333&i)+(i>>>2&0x33333333))+(i>>>4)&0xf0f0f0f,0x1010101)>>>24}return t?n:this._length-n}findNext(e,t=!0){let n=Math.max(e+1,0);if(n>=this._length)return -1;let i=n>>>5;for(let e=i,r=this.lengthInInts;e<r;e++){let r=t?this._data[e]:~this._data[e];if(e===i&&(r&=-1<<(31&n)),0!==r){let t=(e<<5)+31-Math.clz32(r&-r);return t<this._length?t:-1}}return -1}findPrev(e,t=!0){let n=e<0?this._length-1:Math.min(e,this._length)-1;if(n<0)return -1;let i=n>>>5;for(let e=i;e>=0;e--){let r=t?this._data[e]:~this._data[e];if(e===i&&(31&n)!=31&&(r&=(1<<(31&n)+1)-1),0!==r)return(e<<5)+31-Math.clz32(r)}return -1}getSelectedIndexes(){let e=new Int32Array(this.trueCount),t=0;for(let n=0,i=this.lengthInInts;n<i;n++)for(let i=this._data[n];0!==i;i&=i-1)e[t++]=(n<<5)+31-Math.clz32(i&-i);return e}*trueIndexes(){for(let e=0,t=this.lengthInInts;e<t;e++)for(let t=this._data[e];0!==t;t&=t-1)yield(e<<5)+31-Math.clz32(t&-t)}setLength(e){let t=i._wordCount(e);if(t!==this._data.length){let e=new Uint32Array(t);e.set(this._data.subarray(0,Math.min(t,this.lengthInInts))),this._data=e}else this._data.fill(0,this.lengthInInts,t);this._length=e,this._trim()}removeAt(e,t=1){if(t<0)throw RangeError(`Invalid count ${t}`);this._checkRange(e,e+t);for(let n=e,i=this._length-t;n<i;n++)this.set(n,this.get(n+t));this.setLength(this._length-t)}setRange(e,t,n){if(this._checkRange(e,t),e===t)return this;let i=e>>>5,r=t-1>>>5,o=-1<<(31&e),s=(31&t)==0?-1:(1<<(31&t))-1,a=this._data;return i===r?n?a[i]|=o&s:a[i]&=~(o&s):n?(a[i]|=o,a.fill(0xffffffff,i+1,r),a[r]|=s):(a[i]&=~o,a.fill(0,i+1,r),a[r]&=~s),this}getRange(e,t){this._checkRange(e,t);let n=new i(t-e),r=31&e,o=this._data,s=n._data;for(let t=0,n=e>>>5,i=this.lengthInInts;t<s.length;t++,n++){let e=o[n]>>>r;0!==r&&n+1<i&&(e|=o[n+1]<<32-r),s[t]=e}return n._trim()}toString(){let e="";for(let t=0;t<this._length;t++)e+=this.get(t)?"1":"0";return e}toBinaryString(){return this.toString()}}},9991(e,t,n){"use strict";n.d(t,{nX:()=>x,I6:()=>k,UV:()=>es,oE:()=>A,kC:()=>O,pj:()=>eh});let i="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,r=new Set,o="object"==typeof process&&process?process:{},s=(e,t,n,i)=>{"function"==typeof o.emitWarning?o.emitWarning(e,t,n,i):console.error(`[${n}] ${t}: ${e}`)},a=globalThis.AbortController,l=globalThis.AbortSignal;if(void 0===a){l=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},a=class{constructor(){t()}signal=new l;abort(e){if(!this.signal.aborted){for(let t of(this.signal.reason=e,this.signal.aborted=!0,this.signal._onabort))t(e);this.signal.onabort?.(e)}}};let e=o.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,s("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}Symbol("type");let u=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),d=e=>u(e)?e<=256?Uint8Array:e<=65536?Uint16Array:e<=0x100000000?Uint32Array:e<=Number.MAX_SAFE_INTEGER?c:null:null;class c extends Array{constructor(e){super(e),this.fill(0)}}class h{heap;length;static #e=!1;static create(e){let t=d(e);if(!t)return[];h.#e=!0;let n=new h(e,t);return h.#e=!1,n}constructor(e,t){if(!h.#e)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}}class p{#t;#n;#i;#r;#o;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#l;#u;#d;#c;#h;#p;#f;#m;#g;#v;#b;#y;#_;#w;#x;#k;static unsafeExposeInternals(e){return{starts:e.#y,ttls:e.#_,sizes:e.#b,keyMap:e.#u,keyList:e.#d,valList:e.#c,next:e.#h,prev:e.#p,get head(){return e.#f},get tail(){return e.#m},free:e.#g,isBackgroundFetch:t=>e.#S(t),backgroundFetch:(t,n,i,r)=>e.#C(t,n,i,r),moveToTail:t=>e.#A(t),indexes:t=>e.#O(t),rindexes:t=>e.#E(t),isStale:t=>e.#T(t)}}get max(){return this.#t}get maxSize(){return this.#n}get calculatedSize(){return this.#l}get size(){return this.#a}get fetchMethod(){return this.#o}get memoMethod(){return this.#s}get dispose(){return this.#i}get disposeAfter(){return this.#r}constructor(e){const{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:c,dispose:f,disposeAfter:m,noDisposeOnSet:g,noUpdateTTL:v,maxSize:b=0,maxEntrySize:y=0,sizeCalculation:_,fetchMethod:w,memoMethod:x,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:A,ignoreFetchAbort:O}=e;if(0!==t&&!u(t))throw TypeError("max option must be a nonnegative integer");const E=t?d(t):Array;if(!E)throw Error("invalid max value: "+t);if(this.#t=t,this.#n=b,this.maxEntrySize=y||this.#n,this.sizeCalculation=_,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw TypeError("sizeCalculation set to non-function")}if(void 0!==x&&"function"!=typeof x)throw TypeError("memoMethod must be a function if defined");if(this.#s=x,void 0!==w&&"function"!=typeof w)throw TypeError("fetchMethod must be a function if specified");if(this.#o=w,this.#x=!!w,this.#u=new Map,this.#d=Array(t).fill(void 0),this.#c=Array(t).fill(void 0),this.#h=new E(t),this.#p=new E(t),this.#f=0,this.#m=0,this.#g=h.create(t),this.#a=0,this.#l=0,"function"==typeof f&&(this.#i=f),"function"==typeof m?(this.#r=m,this.#v=[]):(this.#r=void 0,this.#v=void 0),this.#w=!!this.#i,this.#k=!!this.#r,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!v,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#n&&!u(this.#n))throw TypeError("maxSize must be a positive integer if specified");if(!u(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#P()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=u(i)||0===i?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!u(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#N()}if(0===this.#t&&0===this.ttl&&0===this.#n)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#n){const e="LRU_CACHE_UNBOUNDED";(e=>!r.has(e))(e)&&(r.add(e),s("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,p))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#N(){let e=new c(this.#t),t=new c(this.#t);this.#_=e,this.#y=t,this.#I=(n,r,o=i.now())=>{if(t[n]=0!==r?o:0,e[n]=r,0!==r&&this.ttlAutopurge){let e=setTimeout(()=>{this.#T(n)&&this.#M(this.#d[n],"expire")},r+1);e.unref&&e.unref()}},this.#L=n=>{t[n]=0!==e[n]?i.now():0},this.#R=(i,o)=>{if(e[o]){let s=e[o],a=t[o];if(!s||!a)return;i.ttl=s,i.start=a,i.now=n||r();let l=i.now-a;i.remainingTTL=s-l}};let n=0,r=()=>{let e=i.now();if(this.ttlResolution>0){n=e;let t=setTimeout(()=>n=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=i=>{let o=this.#u.get(i);if(void 0===o)return 0;let s=e[o],a=t[o];return s&&a?s-((n||r())-a):1/0},this.#T=i=>{let o=t[i],s=e[i];return!!s&&!!o&&(n||r())-o>s}}#L=()=>{};#R=()=>{};#I=()=>{};#T=()=>!1;#P(){let e=new c(this.#t);this.#l=0,this.#b=e,this.#j=t=>{this.#l-=e[t],e[t]=0},this.#D=(e,t,n,i)=>{if(this.#S(t))return 0;if(!u(n))if(i){if("function"!=typeof i)throw TypeError("sizeCalculation must be a function");if(!u(n=i(t,e)))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n},this.#$=(t,n,i)=>{if(e[t]=n,this.#n){let n=this.#n-e[t];for(;this.#l>n;)this.#F(!0)}this.#l+=e[t],i&&(i.entrySize=n,i.totalCalculatedSize=this.#l)}}#j=e=>{};#$=(e,t,n)=>{};#D=(e,t,n,i)=>{if(n||i)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#m;this.#z(t)&&((e||!this.#T(t))&&(yield t),t!==this.#f);)t=this.#p[t]}*#E({allowStale:e=this.allowStale}={}){if(this.#a)for(let t=this.#f;this.#z(t)&&((e||!this.#T(t))&&(yield t),t!==this.#m);)t=this.#h[t]}#z(e){return void 0!==e&&this.#u.get(this.#d[e])===e}*entries(){for(let e of this.#O())void 0===this.#c[e]||void 0===this.#d[e]||this.#S(this.#c[e])||(yield[this.#d[e],this.#c[e]])}*rentries(){for(let e of this.#E())void 0===this.#c[e]||void 0===this.#d[e]||this.#S(this.#c[e])||(yield[this.#d[e],this.#c[e]])}*keys(){for(let e of this.#O()){let t=this.#d[e];void 0===t||this.#S(this.#c[e])||(yield t)}}*rkeys(){for(let e of this.#E()){let t=this.#d[e];void 0===t||this.#S(this.#c[e])||(yield t)}}*values(){for(let e of this.#O())void 0===this.#c[e]||this.#S(this.#c[e])||(yield this.#c[e])}*rvalues(){for(let e of this.#E())void 0===this.#c[e]||this.#S(this.#c[e])||(yield this.#c[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let n of this.#O()){let i=this.#c[n],r=this.#S(i)?i.__staleWhileFetching:i;if(void 0!==r&&e(r,this.#d[n],this))return this.get(this.#d[n],t)}}forEach(e,t=this){for(let n of this.#O()){let i=this.#c[n],r=this.#S(i)?i.__staleWhileFetching:i;void 0!==r&&e.call(t,r,this.#d[n],this)}}rforEach(e,t=this){for(let n of this.#E()){let i=this.#c[n],r=this.#S(i)?i.__staleWhileFetching:i;void 0!==r&&e.call(t,r,this.#d[n],this)}}purgeStale(){let e=!1;for(let t of this.#E({allowStale:!0}))this.#T(t)&&(this.#M(this.#d[t],"expire"),e=!0);return e}info(e){let t=this.#u.get(e);if(void 0===t)return;let n=this.#c[t],r=this.#S(n)?n.__staleWhileFetching:n;if(void 0===r)return;let o={value:r};if(this.#_&&this.#y){let e=this.#_[t],n=this.#y[t];e&&n&&(o.ttl=e-(i.now()-n),o.start=Date.now())}return this.#b&&(o.size=this.#b[t]),o}dump(){let e=[];for(let t of this.#O({allowStale:!0})){let n=this.#d[t],r=this.#c[t],o=this.#S(r)?r.__staleWhileFetching:r;if(void 0===o||void 0===n)continue;let s={value:o};if(this.#_&&this.#y){s.ttl=this.#_[t];let e=i.now()-this.#y[t];s.start=Math.floor(Date.now()-e)}this.#b&&(s.size=this.#b[t]),e.unshift([n,s])}return e}load(e){for(let[t,n]of(this.clear(),e)){if(n.start){let e=Date.now()-n.start;n.start=i.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(void 0===t)return this.delete(e),this;let{ttl:i=this.ttl,start:r,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n,{noUpdateTTL:l=this.noUpdateTTL}=n,u=this.#D(e,t,n.size||0,s);if(this.maxEntrySize&&u>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#M(e,"set"),this;let d=0===this.#a?void 0:this.#u.get(e);if(void 0===d)d=0===this.#a?this.#m:0!==this.#g.length?this.#g.pop():this.#a===this.#t?this.#F(!1):this.#a,this.#d[d]=e,this.#c[d]=t,this.#u.set(e,d),this.#h[this.#m]=d,this.#p[d]=this.#m,this.#m=d,this.#a++,this.#$(d,u,a),a&&(a.set="add"),l=!1;else{this.#A(d);let n=this.#c[d];if(t!==n){if(this.#x&&this.#S(n)){n.__abortController.abort(Error("replaced"));let{__staleWhileFetching:t}=n;void 0!==t&&!o&&(this.#w&&this.#i?.(t,e,"set"),this.#k&&this.#v?.push([t,e,"set"]))}else!o&&(this.#w&&this.#i?.(n,e,"set"),this.#k&&this.#v?.push([n,e,"set"]));if(this.#j(d),this.#$(d,u,a),this.#c[d]=t,a){a.set="replace";let e=n&&this.#S(n)?n.__staleWhileFetching:n;void 0!==e&&(a.oldValue=e)}}else a&&(a.set="update")}if(0===i||this.#_||this.#N(),this.#_&&(l||this.#I(d,i,r),a&&this.#R(a,d)),!o&&this.#k&&this.#v){let e,t=this.#v;for(;e=t?.shift();)this.#r?.(...e)}return this}pop(){try{for(;this.#a;){let e=this.#c[this.#f];if(this.#F(!0),this.#S(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(void 0!==e)return e}}finally{if(this.#k&&this.#v){let e,t=this.#v;for(;e=t?.shift();)this.#r?.(...e)}}}#F(e){let t=this.#f,n=this.#d[t],i=this.#c[t];return this.#x&&this.#S(i)?i.__abortController.abort(Error("evicted")):(this.#w||this.#k)&&(this.#w&&this.#i?.(i,n,"evict"),this.#k&&this.#v?.push([i,n,"evict"])),this.#j(t),e&&(this.#d[t]=void 0,this.#c[t]=void 0,this.#g.push(t)),1===this.#a?(this.#f=this.#m=0,this.#g.length=0):this.#f=this.#h[t],this.#u.delete(n),this.#a--,t}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,r=this.#u.get(e);if(void 0!==r){let e=this.#c[r];if(this.#S(e)&&void 0===e.__staleWhileFetching)return!1;if(!this.#T(r))return n&&this.#L(r),i&&(i.has="hit",this.#R(i,r)),!0;i&&(i.has="stale",this.#R(i,r))}else i&&(i.has="miss");return!1}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=this.#u.get(e);if(void 0===i||!n&&this.#T(i))return;let r=this.#c[i];return this.#S(r)?r.__staleWhileFetching:r}#C(e,t,n,i){let r=void 0===t?void 0:this.#c[t];if(this.#S(r))return r;let o=new a,{signal:s}=n;s?.addEventListener("abort",()=>o.abort(s.reason),{signal:o.signal});let l={signal:o.signal,options:n,context:i},u=(i,r=!1)=>{let{aborted:s}=o.signal,a=n.ignoreFetchAbort&&void 0!==i;return(n.status&&(s&&!r?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,a&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),!s||a||r)?(this.#c[t]===h&&(void 0===i?h.__staleWhileFetching?this.#c[t]=h.__staleWhileFetching:this.#M(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,i,l.options))),i):d(o.signal.reason)},d=i=>{let{aborted:r}=o.signal,s=r&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,l=a||n.noDeleteOnFetchRejection;if(this.#c[t]===h&&(l&&void 0!==h.__staleWhileFetching?s||(this.#c[t]=h.__staleWhileFetching):this.#M(e,"fetch")),a)return n.status&&void 0!==h.__staleWhileFetching&&(n.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw i},c=(t,i)=>{let s=this.#o?.(e,r,l);s&&s instanceof Promise&&s.then(e=>t(void 0===e?void 0:e),i),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>u(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let h=new Promise(c).then(u,e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),d(e))),p=Object.assign(h,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return void 0===t?(this.set(e,p,{...l.options,status:void 0}),t=this.#u.get(e)):this.#c[t]=p,p}#S(e){return!!this.#x&&!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:c=this.allowStaleOnFetchRejection,ignoreFetchAbort:h=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:f,forceRefresh:m=!1,status:g,signal:v}=t;if(!this.#x)return g&&(g.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:g});let b={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:s,size:a,sizeCalculation:l,noUpdateTTL:u,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:p,ignoreFetchAbort:h,status:g,signal:v},y=this.#u.get(e);if(void 0===y){g&&(g.fetch="miss");let t=this.#C(e,y,b,f);return t.__returned=t}{let t=this.#c[y];if(this.#S(t)){let e=n&&void 0!==t.__staleWhileFetching;return g&&(g.fetch="inflight",e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let r=this.#T(y);if(!m&&!r)return g&&(g.fetch="hit"),this.#A(y),i&&this.#L(y),g&&this.#R(g,y),t;let o=this.#C(e,y,b,f),s=void 0!==o.__staleWhileFetching&&n;return g&&(g.fetch=r?"stale":"refresh",s&&r&&(g.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(void 0===n)throw Error("fetch() returned undefined");return n}memo(e,t={}){let n=this.#s;if(!n)throw Error("no memoMethod provided to constructor");let{context:i,forceRefresh:r,...o}=t,s=this.get(e,o);if(!r&&void 0!==s)return s;let a=n(e,s,{options:o,context:i});return this.set(e,a,o),a}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=t,s=this.#u.get(e);if(void 0!==s){let t=this.#c[s],a=this.#S(t);return(o&&this.#R(o,s),this.#T(s))?(o&&(o.get="stale"),a)?(o&&n&&void 0!==t.__staleWhileFetching&&(o.returnedStale=!0),n?t.__staleWhileFetching:void 0):(r||this.#M(e,"expire"),o&&n&&(o.returnedStale=!0),n?t:void 0):(o&&(o.get="hit"),a)?t.__staleWhileFetching:(this.#A(s),i&&this.#L(s),t)}o&&(o.get="miss")}#q(e,t){this.#p[t]=e,this.#h[e]=t}#A(e){e!==this.#m&&(e===this.#f?this.#f=this.#h[e]:this.#q(this.#p[e],this.#h[e]),this.#q(this.#m,e),this.#m=e)}delete(e){return this.#M(e,"delete")}#M(e,t){let n=!1;if(0!==this.#a){let i=this.#u.get(e);if(void 0!==i)if(n=!0,1===this.#a)this.#B(t);else{this.#j(i);let n=this.#c[i];if(this.#S(n)?n.__abortController.abort(Error("deleted")):(this.#w||this.#k)&&(this.#w&&this.#i?.(n,e,t),this.#k&&this.#v?.push([n,e,t])),this.#u.delete(e),this.#d[i]=void 0,this.#c[i]=void 0,i===this.#m)this.#m=this.#p[i];else if(i===this.#f)this.#f=this.#h[i];else{let e=this.#p[i];this.#h[e]=this.#h[i];let t=this.#h[i];this.#p[t]=this.#p[i]}this.#a--,this.#g.push(i)}}if(this.#k&&this.#v?.length){let e,t=this.#v;for(;e=t?.shift();)this.#r?.(...e)}return n}clear(){return this.#B("delete")}#B(e){for(let t of this.#E({allowStale:!0})){let n=this.#c[t];if(this.#S(n))n.__abortController.abort(Error("deleted"));else{let i=this.#d[t];this.#w&&this.#i?.(n,i,e),this.#k&&this.#v?.push([n,i,e])}}if(this.#u.clear(),this.#c.fill(void 0),this.#d.fill(void 0),this.#_&&this.#y&&(this.#_.fill(0),this.#y.fill(0)),this.#b&&this.#b.fill(0),this.#f=0,this.#m=0,this.#g.length=0,this.#l=0,this.#a=0,this.#k&&this.#v){let e,t=this.#v;for(;e=t?.shift();)this.#r?.(...e)}}}var f=class extends Error{constructor(e,t,n){super(t),this.name="HwError",this.code=e,void 0!==n&&(this.context=Object.freeze({...n})),Object.setPrototypeOf(this,new.target.prototype),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,new.target)}},m=class extends f{constructor(e,t,n){super(e,t,n?.context),this.name="HelmParseError",n?.span!==void 0&&(this.span={...n.span}),Object.setPrototypeOf(this,new.target.prototype)}};function g(e){return e>=65&&e<=90||e>=97&&e<=122}function v(e){return e>=48&&e<=57}function b(e){return 32===e||9===e||10===e||13===e}var y=class{constructor(e){this.src=e,this.len=e.length,this.pos=0,this.tokens=[],this.whitespace=[]}tokenize(){for(;this.pos<this.len;){let e=this.pos,t=this.src.charCodeAt(this.pos);if(b(t)){let t=e+1;for(;t<this.len&&b(this.src.charCodeAt(t));)t+=1;this.whitespace.push({start:e,end:t}),this.pos=t;continue}if(91===t){this.scanBracket(e);continue}if(34===t){this.scanQuote(e);continue}if(g(t)){this.scanIdentifier(e);continue}if(v(t)){this.scanNumber(e);continue}let n=t<128?w[t]:void 0;if(void 0!==n){this.pos+=1,this.push(n,this.src.charAt(e),e,this.pos);continue}throw new m("unexpected-char",`Unexpected character ${JSON.stringify(this.src.charAt(e))} at offset ${e}`,{span:{start:e,end:e+1}})}return this.push("eof","",this.len,this.len),{tokens:this.tokens,source:this.src,whitespace:this.whitespace}}scanBracket(e){let t=1,n=!1,i=!1,r=e+1;for(;r<this.len;){let o=this.src.charCodeAt(r);if(n){if(92===o&&r+1<this.len){r+=2;continue}if(34===o){n=!1,r+=1;continue}if(10===o||13===o)throw new m("unexpected-newline",`Newline inside bracket at offset ${r}`,{span:{start:r,end:r+1}});r+=1;continue}if(i){if(36===o&&r+1<this.len){let e=this.src.charCodeAt(r+1);if(124===e){i=!1,r+=2;continue}if(93===e){i=!1,r+=1;continue}}if(10===o||13===o)throw new m("unexpected-newline",`Newline inside bracket at offset ${r}`,{span:{start:r,end:r+1}});r+=1;continue}if(10===o||13===o)throw new m("unexpected-newline",`Newline inside bracket at offset ${r}`,{span:{start:r,end:r+1}});if(34===o){n=!0,r+=1;continue}if(124===o&&r+1<this.len&&36===this.src.charCodeAt(r+1)){i=!0,r+=2;continue}if(91===o){t+=1,r+=1;continue}if(93===o){if(0==(t-=1)){let t=r+1,n=this.src.slice(e+1,r);this.pos=t,this.push("inline-smiles",n,e,t);return}r+=1;continue}r+=1}throw new m("unterminated-bracket",`Unterminated '[' starting at offset ${e}`,{span:{start:e,end:this.len}})}scanQuote(e){let t=[],n=e+1;for(;n<this.len;){let i=this.src.charCodeAt(n);if(34===i){let i=n+1;this.pos=i,this.push("quote-string",t.join(""),e,i);return}if(92===i&&n+1<this.len){let e=this.src.charCodeAt(n+1);34===e?t.push('"'):92===e?t.push("\\"):110===e?t.push(`
|
|
361
|
+
`):114===e?t.push("\r"):116===e?t.push(" "):(t.push("\\"),t.push(this.src.charAt(n+1))),n+=2;continue}if(10===i||13===i)throw new m("unexpected-newline",`Newline inside quote at offset ${n}`,{span:{start:n,end:n+1}});t.push(this.src.charAt(n)),n+=1}throw new m("unterminated-quote",`Unterminated '"' starting at offset ${e}`,{span:{start:e,end:this.len}})}scanIdentifier(e){let t=e+1;for(;t<this.len;){let e=this.src.charCodeAt(t);if(g(e)||v(e)||95===e){t+=1;continue}if(45===e&&t+1<this.len&&g(this.src.charCodeAt(t+1))){t+=2;continue}break}let n=this.src.slice(e,t);this.pos=t,this.push("identifier",n,e,t)}scanNumber(e){let t=e+1;for(;t<this.len&&v(this.src.charCodeAt(t));)t+=1;if(t+1<this.len&&46===this.src.charCodeAt(t)&&v(this.src.charCodeAt(t+1))){for(t+=2;t<this.len&&v(this.src.charCodeAt(t));)t+=1;let n=this.src.slice(e,t);this.pos=t,this.push("decimal",n,e,t);return}let n=this.src.slice(e,t);this.pos=t,this.push("integer",n,e,t)}push(e,t,n,i){this.tokens.push({kind:e,value:t,span:{start:n,end:i}})}},_=new Map([[123,"lbrace"],[125,"rbrace"],[40,"lparen"],[41,"rparen"],[93,"rbracket"],[124,"pipe"],[46,"dot"],[44,"comma"],[43,"plus"],[58,"colon"],[45,"dash"],[36,"dollar"],[62,"gt"],[63,"question"],[42,"asterisk"],[95,"underscore"],[39,"apos"]]),w=(()=>{let e=Array(128).fill(void 0);for(let[t,n]of _)e[t]=n;return e})();function x(e){switch(e.kind){case"index":return String(e.value);case"any":return"?";case"symbol":return e.value;case"range":return`${e.min}-${e.max}`;case"list":return`(${e.sites.map(e=>"index"===e.kind?String(e.value):`${e.min}-${e.max}`).join("and"===e.op?"+":",")})`}}function k(e){let t=e.endpoints;return void 0!==t&&t.some(e=>e.isGroup||"index"!==e.position.kind)}var S={perPolymer:new Map,version:""};function C(){return{atoms:[],bonds:[],chains:[],groups:[],annotations:S}}var A={AA:"HELM_AA",SUGAR:"HELM_SUGAR",BASE:"HELM_BASE",LINKER:"HELM_LINKER",CHEM:"HELM_CHEM",BLOB:"HELM_BLOB",NUCLEOTIDE:"HELM_NUCLEOTIDE"},O={PEPTIDE:"PEPTIDE",RNA:"RNA",CHEM:"CHEM",BLOB:"BLOB",G:"G"},E=class{constructor(){this._counter=0}next(){return this._counter+=1,this._counter}reset(){this._counter=0}get current(){return this._counter}};function T(e){let t=e.trim();if(/^\[[a-zA-Z_][a-zA-Z0-9_]*\]$/.test(t))return!1;for(let e=0;e<t.length;e++){let n=t.charCodeAt(e);if(40===n||91===n||61===n||47===n||92===n||42===n)return!0}return!1}var P=class{constructor(){this._listeners=new Set,this._completed=!1}subscribe(e){return this._completed?()=>{}:(this._listeners.add(e),()=>{this._listeners.delete(e)})}next(e){if(!this._completed)for(let t of[...this._listeners])t(e)}complete(){this._completed=!0,this._listeners.clear()}get observerCount(){return this._listeners.size}};function N(e){return{line:"#202020",text:"#000000",background:e}}function I(e){let t=/^#([0-9a-fA-F]{6})$/.exec(e),n=/^#([0-9a-fA-F]{3})$/.exec(e);if(null!==t){let e=t[1];return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}if(null!==n){let e=n[1];return[parseInt(e[0]+e[0],16),parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16)]}return null}function M(e){return e.toString(16).padStart(2,"0")}function L(e,t,n){return`#${M(e)}${M(t)}${M(n)}`}function R(e,t,n){let i=e/255,r=t/255,o=n/255,s=Math.max(i,r,o),a=Math.min(i,r,o),l=(s+a)/2;if(s===a)return[0,0,l];let u=s-a;return[s===i?((r-o)/u+6*(r<o))*60:s===r?((o-i)/u+2)*60:((i-r)/u+4)*60,l>.5?u/(2-s-a):u/(s+a),l]}function j(e,t,n){let i=n;return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<.5?t:i<2/3?e+(t-e)*(2/3-i)*6:e}function D(e,t,n){if(0===t){let e=Math.round(255*n);return[e,e,e]}let i=n<.5?n*(1+t):n+t-n*t,r=2*n-i,o=e/360;return[Math.round(255*j(r,i,o+1/3)),Math.round(255*j(r,i,o)),Math.round(255*j(r,i,o-1/3))]}function F(e,t=.3,n=.1){let i=I(e);if(null===i)return e;let[r,o,s]=R(i[0],i[1],i[2]),[a,l,u]=D(r,Math.max(0,Math.min(1,o*(1-t))),Math.max(0,Math.min(.95,s+n*(1-s))));return L(a,l,u)}function z(e){let t=I(e);if(null===t)return 0;let n=e=>{let t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}function q(e){let t=I(e);if(null===t)return"#1f2937";let[n,i,r]=R(t[0],t[1],t[2]);return r>.85||i<.15&&r>.7?"#1f2937":function(e){let[t,n,i]=D((e.h%360+360)%360,Math.max(0,Math.min(1,e.s)),Math.max(0,Math.min(1,e.l)));return L(t,n,i)}({h:n,s:Math.min(1,i+.1),l:Math.max(.08,r-.3)})}function B(e){let t,n=null===(t=I(e))?null:{r:t[0]/255,g:t[1]/255,b:t[2]/255};if(null===n)return"#1f2937";let i=e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4),r=.2126*i(n.r)+.7152*i(n.g)+.0722*i(n.b);return 1.05/(r+.05)>(r+.05)/.05?"#ffffff":"#1f2937"}function G(e,t){let n=I(e);if(null===n)return e;let i=1-t;return L(Math.max(0,Math.min(255,Math.round(n[0]*i))),Math.max(0,Math.min(255,Math.round(n[1]*i))),Math.max(0,Math.min(255,Math.round(n[2]*i))))}var V={A:N("#A0A0FF"),G:N("#FF7070"),T:N("#A0FFA0"),C:N("#FF8C4B"),U:N("#FF8080")},U={R:N("#7a85c1"),r:N("#7a85c1")},H={P:N("#9aa5e1"),p:N("#9aa5e1")},W={A:N("#C8C8C8"),R:N("#145AFF"),N:N("#00DCDC"),D:N("#E60A0A"),C:N("#E6E600"),E:N("#00DCDC"),Q:N("#E60A0A"),G:N("#EBEBEB"),H:N("#8282D2"),I:N("#0F820F"),L:N("#0F820F"),K:N("#145AFF"),M:N("#E6E600"),F:N("#3232AA"),P:N("#DC9682"),S:N("#FA9600"),T:N("#FA9600"),W:N("#B45AB4"),Y:N("#3232AA"),V:N("#0F820F")},Y={R:N("#eeeeee")},K={B:N("#999999"),G:N("#e2e2e2")},X={P:N("#9aa5e1")},Z={name:"light",fallback:{line:"#202020",text:"#000000",background:"#eeeeee"},errorTriple:{line:"#cc0000",text:"#000000",background:"#FFFF00"},palette:{[A.BASE]:V,[A.SUGAR]:U,[A.LINKER]:H,[A.AA]:W,[A.CHEM]:Y,[A.BLOB]:K,[A.NUCLEOTIDE]:X}};function Q(e){let t={};for(let[n,i]of Object.entries(e))t[n]={line:"#e0e0e0",text:"#ffffff",background:G(i.background,.25)};return t}var J={name:"dark",fallback:{line:"#e0e0e0",text:"#ffffff",background:G("#eeeeee",.5)},errorTriple:{line:"#ff5050",text:"#ffffff",background:G("#FFFF00",.4)},palette:{[A.BASE]:Q(V),[A.SUGAR]:Q(U),[A.LINKER]:Q(H),[A.AA]:Q(W),[A.CHEM]:Q(Y),[A.BLOB]:Q(K),[A.NUCLEOTIDE]:Q(X)}};function ee(e,t,n=Z){if(null===e)return{...n.errorTriple};let i=e.meta?.colors;if(void 0!==i){let e="light"===n.name?i.light:"dark"===n.name?i.dark:void 0;if(void 0!==e)return{...e,line:q(e.background)};if(void 0!==i.default)return{...i.default,line:q(i.default.background)}}let r=e.naturalAnalog;if(void 0!==r&&""!==r){let e=n.palette[t];if(void 0!==e){let t=e[r];if(void 0!==t)return{...t,line:q(t.background),text:B(t.background)}}}return{...n.fallback,line:q(n.fallback.background),text:B(n.fallback.background)}}function et(e){switch(e.polymerType){case O.PEPTIDE:return A.AA;case O.CHEM:return A.CHEM;case O.BLOB:return A.BLOB;case O.RNA:if("Branch"===e.monomerType)return A.BASE;if("Backbone"===e.monomerType){let t=e.naturalAnalog;return"P"===t||"p"===t?A.LINKER:A.SUGAR}return null;default:return null}}function en(e,t,n){return new eo(e,t,n??{}).run()}var ei=new Set(["?","*","_","X","N"]),er=/^R([1-9][0-9]*)$/,eo=class{constructor(e,t,n){this.diagnostics=[],this.oldToNew=new Map,this.placeholderCache=new Map,this.mol=e,this.lib=t,this.options=n}run(){let e=new Map;for(let t of this.mol.chains)e.set(t.id,t.polymerType);for(let t of this.mol.atoms){let n=e.get(t.bio.chainId)??null,i=this.resolveAtom(t,n);this.oldToNew.set(t.id,i)}for(let e of this.mol.atoms){let t=this.oldToNew.get(e.id);if(void 0===t||void 0===e.branchAtom)continue;let n=this.oldToNew.get(e.branchAtom.id);void 0!==n&&(t.branchAtom=n)}let t=[];for(let e of this.mol.bonds){let n=this.oldToNew.get(e.a1.id),i=this.oldToNew.get(e.a2.id);void 0===n||void 0===i||t.push({...e,a1:n,a2:i})}let n=new Map;for(let e of t)n.set(e.id,e);let i=[];for(let e of this.mol.chains){let t=[];for(let n of e.backboneAtoms){let e=this.oldToNew.get(n.id);void 0!==e&&t.push(e)}let r=[];for(let t of e.bonds){let e=n.get(t.id);void 0!==e&&r.push(e)}i.push({id:e.id,polymerType:e.polymerType,backboneAtoms:t,bonds:r,...void 0!==e.annotation?{annotation:e.annotation}:{},...void 0!==e.strandType?{strandType:e.strandType}:{}})}return{mol:{atoms:this.mol.atoms.map(e=>this.oldToNew.get(e.id)),bonds:t,chains:i,groups:this.mol.groups,annotations:this.mol.annotations},diagnostics:this.diagnostics}}resolveAtom(e,t){let n=null,i=e.biotype;if(null!==t){let r=this.lib.getMonomer(t,e.symbol);if(null!==r)n=this.toResolved(r),i=et(r)??e.biotype;else if(this.isAmbiguitySymbol(e))n=this.synthesizeAmbiguity(t,e),this.emit("info","ambiguous-monomer",`Ambiguous monomer '${e.symbol}' on chain '${e.bio.chainId}'`,e);else if(T(e.symbol))n=this.registerInlineSmilesFallback(t,e);else if(!0===this.options.legacyCaseFallback&&"RNA"===t){let r=this.findCaseInsensitiveMatch(t,e.symbol);null!==r&&(n=this.toResolved(r),i=et(r)??e.biotype,this.emit("info","case-mismatch",`Symbol '${e.symbol}' matched library entry '${r.symbol}' only after case fold`,e))}null===n&&(n=this.synthesizeMissing(t,e),this.emit("warning","unresolved-monomer",`Monomer '${e.symbol}' not found in library for ${t}`,e))}return{...e,monomer:n,biotype:i}}toResolved(e){let t=this.lib.getResolved?.(e);if(void 0!==t)return t;let n=new Map;for(let t of e.rgroups){let e=er.exec(t.label);null!==e&&n.set(parseInt(e[1],10),t)}return Object.assign({},e,{rs:e.rgroups.length,rgroupMap:n})}isAmbiguitySymbol(e){return!!(ei.has(e.symbol)||void 0!==e.bio.ambiguity)}synthesizeAmbiguity(e,t){let n=`ambig:${e}:${t.symbol}`,i=this.placeholderCache.get(n);return void 0===i&&(i={symbol:t.symbol,polymerType:e,monomerType:"Undefined",molfile:"",rgroups:[{label:"R1",capGroupName:"H",capGroupSMILES:""},{label:"R2",capGroupName:"H",capGroupSMILES:""}],meta:{ambiguous:!0}},this.placeholderCache.set(n,i)),this.toResolved(i)}synthesizeMissing(e,t){let n=`missing:${e}:${t.symbol}`,i=this.placeholderCache.get(n);return void 0===i&&(i={symbol:t.symbol,polymerType:e,monomerType:"Undefined",molfile:"",rgroups:[{label:"R1",capGroupName:"H",capGroupSMILES:""},{label:"R2",capGroupName:"H",capGroupSMILES:""}],meta:{missing:!0}},this.placeholderCache.set(n,i)),this.toResolved(i)}registerInlineSmilesFallback(e,t){if("function"==typeof this.lib.registerInlineSmilesMonomer)try{let n=this.lib.registerInlineSmilesMonomer(e,t.symbol);return this.toResolved(n)}catch{var n;this.emit("warning","inline-smiles-without-r-groups",`Inline SMILES '${(n=t.symbol).length<=40?n:n.slice(0,39)+"…"}' has no detectable R-groups`,t)}else this.emit("warning","inline-smiles-without-r-groups","Inline SMILES seen but lib has no registerInlineSmilesMonomer",t);return this.synthesizeMissing(e,t)}findCaseInsensitiveMatch(e,t){let n=t.toLowerCase();for(let i of this.lib.getMonomerSymbolsByType(e))if(i.toLowerCase()===n&&i!==t){let t=this.lib.getMonomer(e,i);if(null!==t)return t}return null}emit(e,t,n,i){let r={chainId:i.bio.chainId,atomId:i.id,symbol:i.symbol};this.diagnostics.push({severity:e,code:t,message:n,context:r})}};function es(e,t,n){let i=n?.mode??"lenient",r;try{let t;t=new y(e).tokenize(),function(e){let t=null;for(let n of e.tokens)if("apos"===n.kind)t=null===t?n.span:null;else if("eof"===n.kind&&null!==t)throw new m("unterminated-apostrophe",`Unterminated apostrophe block starting at offset ${t.start}`,{span:{start:t.start,end:e.source.length}})}(t),r=t}catch(e){if(e instanceof m){if("strict"===i)throw e;let t={severity:"error",code:e.code,message:e.message,...void 0!==e.span?{span:{start:e.span.start,end:e.span.end}}:{}};return{mol:C(),diagnostics:[t]}}throw e}var o=r,s=t,a=n;let l=new ec(o,s,a?.mode??"lenient").parseDocument();if(null===s||a?.resolveMonomers===!1)return l;let u=en(l.mol,s,{mode:a?.mode??"lenient",...a?.legacyCaseFallback===!0?{legacyCaseFallback:!0}:{}});return{mol:u.mol,diagnostics:[...l.diagnostics,...u.diagnostics]}}function ea(e){switch(e.kind){case"index":return e.value;case"range":return e.min;case"list":{let t=e.sites[0];return void 0===t?null:"index"===t.kind?t.value:t.min}default:return null}}var el=class{constructor(e){this.tokens=e.tokens,this.len=e.tokens.length,this.eof=e.tokens[e.tokens.length-1],this.idx=0}peek(e=0){let t=this.idx+e;return t>=this.len?this.eof:this.tokens[t]}advance(){let e=this.idx<this.len?this.tokens[this.idx]:this.eof;return"eof"!==e.kind&&(this.idx+=1),e}optional(e){let t=this.idx<this.len?this.tokens[this.idx]:this.eof;return t.kind===e?("eof"!==t.kind&&(this.idx+=1),t):null}at(e){return(this.idx<this.len?this.tokens[this.idx]:this.eof).kind===e}at2(e,t){let n=(this.idx<this.len?this.tokens[this.idx]:this.eof).kind;return n===e||n===t}at3(e,t,n){let i=(this.idx<this.len?this.tokens[this.idx]:this.eof).kind;return i===e||i===t||i===n}currentSpan(){return(this.idx<this.len?this.tokens[this.idx]:this.eof).span}position(){return this.idx}setPosition(e){this.idx=e}isAtEnd(){return"eof"===(this.idx<this.len?this.tokens[this.idx]:this.eof).kind}},eu=/^(PEPTIDE|RNA|DNA|CHEM|BLOB|G)([0-9]+)$/;function ed(e){let t=eu.exec(e);if(null===t)return null;let n=t[1],i=parseInt(t[2],10);switch(n){case"PEPTIDE":return{rawTypeName:"PEPTIDE",polymerType:O.PEPTIDE,number:i,isDnaShim:!1,isGroup:!1};case"RNA":return{rawTypeName:"RNA",polymerType:O.RNA,number:i,isDnaShim:!1,isGroup:!1};case"DNA":return{rawTypeName:"DNA",polymerType:O.RNA,number:i,isDnaShim:!0,isGroup:!1};case"CHEM":return{rawTypeName:"CHEM",polymerType:O.CHEM,number:i,isDnaShim:!1,isGroup:!1};case"BLOB":return{rawTypeName:"BLOB",polymerType:O.BLOB,number:i,isDnaShim:!1,isGroup:!1};case"G":return{rawTypeName:"G",polymerType:O.PEPTIDE,number:i,isDnaShim:!1,isGroup:!0};default:return null}}var ec=class{constructor(e,t,n){this.diagnostics=[],this.chains=[],this.chainById=new Map,this.pendingBonds=[],this.groups=[],this.atomIds=new E,this.bondIds=new E,this.whitespaceAllowed=[],this.sourceOrderCache=new Map,this.cursor=new el(e),this.source=e.source,this.whitespace=e.whitespace??[],this.lib=t,this.mode=n,this.annotations={perPolymer:new Map,version:""}}parseDocument(){if(this.cursor.isAtEnd())return this.emit("warning","empty-helm","Empty HELM string"),{mol:C(),diagnostics:this.diagnostics};let e=this.parseSections();return this.reportStrayWhitespace(),{mol:e,diagnostics:this.diagnostics}}reportStrayWhitespace(){let e=this.whitespace.filter(e=>!this.whitespaceAllowed.some(t=>e.start>=t.start&&e.end<=t.end)),t=e[0];void 0!==t&&this.emit("warning","unexpected-whitespace",`Ignored whitespace at offset ${t.start}`+(e.length>1?` (and ${e.length-1} more run${e.length>2?"s":""})`:""),t)}parseSections(){if(this.parseSimplePolymers(),this.expectDollarSeparator(1),this.parseConnections(),this.expectDollarSeparator(2),this.parseGroupsSection(),this.expectDollarSeparator(3),this.parseAnnotationsSection(),this.cursor.at("dollar")&&(this.cursor.advance(),this.parseVersionTrailer()),!this.cursor.isAtEnd())for(this.emit("warning","extra-section-separator","Unexpected trailing tokens after HELM document",this.cursor.currentSpan());!this.cursor.isAtEnd();)this.cursor.advance();return this.finalize()}expectDollarSeparator(e){this.cursor.at("dollar")?this.cursor.advance():this.emit("error","missing-section-separator",`Expected '$' separator before section ${e+1}`,this.cursor.currentSpan())}parseSimplePolymers(){if(!(this.cursor.at("dollar")||this.cursor.isAtEnd()))for(this.parsePolymer();this.cursor.at("pipe");){if(this.cursor.advance(),this.cursor.at("dollar")||this.cursor.isAtEnd())return void this.emit("warning","empty-polymer-body","Empty polymer after '|'",this.cursor.currentSpan());this.parsePolymer()}}parsePolymer(){let e=this.cursor.currentSpan(),t=this.cursor.optional("identifier");if(null===t){this.emit("error","unexpected-token",`Expected polymer id, got '${this.cursor.peek().value}'`,this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}let n=ed(t.value);if(null===n){this.emit("error","unknown-polymer-type",`Unknown polymer type '${t.value}'`,t.span),this.skipUntil(["pipe","dollar","eof"]);return}if(this.chainById.has(t.value)&&this.emit("warning","duplicate-polymer-id",`Duplicate polymer id '${t.value}'`,t.span),null===this.cursor.optional("lbrace"))return void this.emit("error","unexpected-token",`Expected '{' after polymer id '${t.value}'`,this.cursor.currentSpan());let i={id:t.value,polymerType:n.polymerType,rawTypeName:n.rawTypeName,rawNumber:n.number,backboneAtoms:[],allAtoms:[],bonds:[],span:{start:e.start,end:e.end}};if(this.chains.push(i),this.chainById.set(i.id,i),this.cursor.at("rbrace"))this.emit("warning","empty-polymer-body",`Empty body for polymer '${i.id}'`,this.cursor.currentSpan());else if(n.isGroup)this.parseGroupBody(i);else switch(n.polymerType){case O.PEPTIDE:this.parsePeptideBody(i);break;case O.RNA:this.parseRnaBody(i,n.isDnaShim),n.isDnaShim&&this.emit("info","dna-emitted-as-rna",`DNA polymer '${i.id}' will be emitted as RNA on canonicalize`,t.span);break;case O.CHEM:this.parseChemBody(i);break;case O.BLOB:this.parseBlobBody(i)}if(null===this.cursor.optional("rbrace")){this.emit("error","unterminated-brace",`Expected '}' to close polymer '${i.id}'`,this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}let r=this.cursor.optional("quote-string");null!==r&&(i.annotation=r.value)}warnTrailingSeparator(e,t){this.emit("warning","trailing-monomer-separator",`Trailing '.' before '}' in polymer '${e.id}'`,t)}parsePeptideBody(e){for(this.parsePeptideItem(e);this.cursor.at("dot");){let t=this.cursor.currentSpan();if(this.cursor.advance(),this.cursor.at("rbrace")){this.warnTrailingSeparator(e,t);break}if(this.cursor.at("gt"))break;this.parsePeptideItem(e)}if(this.cursor.at("gt")){let t=this.cursor.currentSpan();this.cursor.advance(),this.emit("warning","peptide-cyclic-without-closure",`Peptide '${e.id}' marked cyclic with '>' \u2014 no explicit closure connection emitted`,t)}}parsePeptideItem(e){if(this.cursor.at("lparen"))this.parsePeptideAlternation(e);else{let t=this.parsePeptideAtom(e);this.cursor.at("apos")&&this.maybeRepeatBracket(e,[t])}this.maybeAttachAnnotation(e)}parsePeptideAtom(e){let t=this.consumePlainIdentifier();if(null!==t){let n=this.makeAtom(e,A.AA,t);this.addToChain(e,n,!0);let i=e.backboneAtoms[e.backboneAtoms.length-2];return void 0!==i&&this.addBond(e,i,n,"backbone",{kind:"numeric",r:2},{kind:"numeric",r:1}),n}let{symbol:n,annotation:i,ambiguity:r,ambiguityKind:o,isInlineSmiles:s,rawPayload:a,inlineSource:l,span:u}=this.consumeMonomerSymbol(!1),d=this.makeAtom(e,A.AA,n);void 0!==i&&(d.tag=i),void 0!==r&&(d.bio.ambiguity=r),void 0!==o&&(d.bio.ambiguityKind=o),void 0!==l&&(d.inlineSource=l),s&&this.registerInlineSmiles(a,u,O.PEPTIDE),this.addToChain(e,d,!0);let c=e.backboneAtoms[e.backboneAtoms.length-2];return void 0!==c&&this.addBond(e,c,d,"backbone",{kind:"numeric",r:2},{kind:"numeric",r:1}),d}parsePeptideAlternation(e){let t=this.cursor.currentSpan();if(this.cursor.advance(),this.peptideContentIsSubsequence()){let t=e.backboneAtoms.length;for(this.parsePeptideItem(e);this.cursor.at("dot")&&(this.cursor.advance(),!(this.cursor.at("rparen")||this.cursor.isAtEnd()));)this.parsePeptideItem(e);null===this.cursor.optional("rparen")&&this.emit("error","unterminated-paren","Expected ')' to close repeat sub-sequence",this.cursor.currentSpan());let n=e.backboneAtoms.slice(t);this.maybeRepeatBracket(e,n),this.maybeAttachAnnotation(e);return}let n=[],i=null;for(;!this.cursor.at("rparen")&&!this.cursor.isAtEnd();){let e=this.parseAlternationCandidate(O.PEPTIDE);if(n.push(e),this.cursor.at("comma"))"and"===i&&this.emit("warning","mixed-separator-in-alternation","Mixed ',' and '+' separators in alternation",this.cursor.currentSpan()),i="or",this.cursor.advance();else if(this.cursor.at("plus"))"or"===i&&this.emit("warning","mixed-separator-in-alternation","Mixed ',' and '+' separators in alternation",this.cursor.currentSpan()),i="and",this.cursor.advance();else break}null===this.cursor.optional("rparen")&&this.emit("error","unterminated-paren","Expected ')' to close alternation",this.cursor.currentSpan());let r="and"===i?"+":",",o=`(${n.map(e=>e.text+(void 0!==e.ratio?`:${String(e.ratio)}`:"")).join(r)})`,s=this.makeAtom(e,A.AA,"?");s.bio.ambiguity=o,s.bio.ambiguityKind="and"===i?"and":"or",this.addToChain(e,s,!0);let a=e.backboneAtoms[e.backboneAtoms.length-2];if(void 0!==a&&this.addBond(e,a,s,"backbone",{kind:"numeric",r:2},{kind:"numeric",r:1}),"and"===i)for(let e of n)"number"==typeof e.ratio&&e.ratio<0&&this.emit("error","ratio-and-negative",`Negative ratio ${e.ratio} in AND mixture`,t);this.maybeRepeatBracket(e,[s]),this.maybeAttachAnnotation(e)}peptideContentIsSubsequence(){let e=1,t=0;for(;;){let n=this.cursor.peek(t);if("eof"===n.kind)return!1;if("lparen"===n.kind){e+=1,t+=1;continue}if("rparen"===n.kind){if(0==(e-=1))return!0;t+=1;continue}if(1===e){if("dot"===n.kind)return!0;if("comma"===n.kind||"plus"===n.kind||"colon"===n.kind)return!1}if((t+=1)>1024)return!1}}parseAlternationCandidate(e){let t,{symbol:n,isInlineSmiles:i,rawPayload:r,inlineSource:o,span:s}=this.consumeMonomerSymbol(!0),a=void 0!==o?`[${o}]`:n;if(i&&this.registerInlineSmiles(r,s,e),null!==this.cursor.optional("colon")){let e=this.cursor.peek();"integer"===e.kind||"decimal"===e.kind?(this.cursor.advance(),t=parseFloat(e.value)):"question"===e.kind?(this.cursor.advance(),t="?"):this.emit("error","unexpected-token","Expected ratio after ':' in alternation",e.span)}return void 0===t?{symbol:n,text:a}:{symbol:n,text:a,ratio:t}}parseRnaBody(e,t){let n=this.cursor.at("lparen");for(this.parseRnaItem(e,t);;){if(this.cursor.at("dot")){let i=this.cursor.currentSpan();if(this.cursor.advance(),this.cursor.at("rbrace")&&this.warnTrailingSeparator(e,i),this.cursor.at("rbrace")||this.cursor.at("dollar")||this.cursor.isAtEnd())break;n=this.cursor.at("lparen"),this.parseRnaItem(e,t);continue}if(!n&&this.canStartRnaLinker()){this.parseRnaItem(e,t);continue}break}}parseRnaItem(e,t){let n,i;if(this.cursor.at("lparen"))return void this.parseRnaAlternation(e,t);if(this.cursor.at("asterisk")){this.cursor.currentSpan(),this.cursor.advance();let t=this.makeAtom(e,A.NUCLEOTIDE,"*");this.addToChain(e,t,!0);let n=e.backboneAtoms[e.backboneAtoms.length-2];void 0!==n&&this.addBond(e,n,t,"backbone",{kind:"numeric",r:2},{kind:"numeric",r:1}),this.maybeRepeatBracket(e,[t]),this.maybeAttachAnnotation(e);return}let r=this.parseRnaSugar(e,t);this.maybeAttachAnnotation(e),this.cursor.at("lparen")&&(this.cursor.advance(),this.cursor.at("rparen")||(n=this.parseRnaBaseSymbol(e),this.maybeAttachAnnotationTo(n)),null===this.cursor.optional("rparen")&&this.emit("error","unterminated-paren","Expected ')' after RNA base",this.cursor.currentSpan()),void 0!==n&&(this.addBond(e,r,n,"branch",{kind:"numeric",r:3},{kind:"numeric",r:1}),r.branchAtom=n)),this.canStartRnaLinker()&&"lparen"!==this.cursor.peek(1).kind&&(i=this.parseRnaLinker(e),this.maybeAttachAnnotationTo(i)),void 0!==i&&this.addBond(e,r,i,"backbone",{kind:"numeric",r:2},{kind:"numeric",r:1});let o=r.bio.positionInChain-1;if(o>0){let t=e.backboneAtoms[o-1];this.addBond(e,t,r,"backbone",{kind:"numeric",r:2},{kind:"numeric",r:1})}if(!this.cursor.at("apos"))return;let s=[r];void 0!==n&&s.push(n),void 0!==i&&s.push(i),this.maybeRepeatBracket(e,s)}canStartRnaLinker(){let e=this.cursor.peek().kind;return"identifier"===e||"inline-smiles"===e||"asterisk"===e}parseRnaSugar(e,t){let n=this.consumePlainIdentifier();if(null!==n){let t=this.makeAtom(e,A.SUGAR,n);return this.addToChain(e,t,!0),t}let{symbol:i,isInlineSmiles:r,rawPayload:o,inlineSource:s,span:a}=this.consumeMonomerSymbol(!1),l=this.makeAtom(e,A.SUGAR,i);return void 0!==s&&(l.inlineSource=s),r&&this.registerInlineSmiles(o,a,O.RNA),this.addToChain(e,l,!0),l}parseRnaBaseSymbol(e){let t=this.consumePlainIdentifier();if(null!==t){let n=this.makeAtom(e,A.BASE,t);return this.addToChain(e,n,!1),n}let{symbol:n,isInlineSmiles:i,rawPayload:r,inlineSource:o,span:s}=this.consumeMonomerSymbol(!1),a=this.makeAtom(e,A.BASE,n);return void 0!==o&&(a.inlineSource=o),i&&this.registerInlineSmiles(r,s,O.RNA),this.addToChain(e,a,!1),a}parseRnaLinker(e){if(this.cursor.at("asterisk")){this.cursor.currentSpan(),this.cursor.advance();let t=this.makeAtom(e,A.LINKER,"*");return this.addToChain(e,t,!0),t}let t=this.consumePlainIdentifier();if(null!==t){let n=this.makeAtom(e,A.LINKER,t);return this.addToChain(e,n,!0),n}let{symbol:n,isInlineSmiles:i,rawPayload:r,inlineSource:o,span:s}=this.consumeMonomerSymbol(!1),a=this.makeAtom(e,A.LINKER,n);return void 0!==o&&(a.inlineSource=o),i&&this.registerInlineSmiles(r,s,O.RNA),this.addToChain(e,a,!0),a}parseRnaAlternation(e,t){let n=e.backboneAtoms.length;if(this.cursor.advance(),this.looksLikeFlatAlternation()){let t=[],n=null;for(;!this.cursor.at("rparen")&&!this.cursor.isAtEnd();)if(t.push(this.parseAlternationCandidate(O.RNA)),this.cursor.at("comma"))n="or",this.cursor.advance();else if(this.cursor.at("plus"))n="and",this.cursor.advance();else break;null===this.cursor.optional("rparen")&&this.emit("error","unterminated-paren","Expected ')' in RNA alternation",this.cursor.currentSpan());let i="and"===n?"+":",",r=`(${t.map(e=>e.text+(void 0!==e.ratio?`:${String(e.ratio)}`:"")).join(i)})`,o=this.makeAtom(e,A.BASE,"?");o.bio.ambiguity=r,o.bio.ambiguityKind="and"===n?"and":"or",this.addToChain(e,o,!0);let s=e.backboneAtoms[e.backboneAtoms.length-2];void 0!==s&&this.addBond(e,s,o,"backbone",{kind:"numeric",r:2},{kind:"numeric",r:1}),this.maybeRepeatBracket(e,[o]),this.maybeAttachAnnotation(e);return}for(this.parseRnaItem(e,t);this.cursor.at("dot")&&(this.cursor.advance(),!(this.cursor.at("rparen")||this.cursor.isAtEnd()));)this.parseRnaItem(e,t);null===this.cursor.optional("rparen")&&this.emit("error","unterminated-paren","Expected ')' in RNA repeat",this.cursor.currentSpan());let i=e.backboneAtoms.slice(n);this.maybeRepeatBracket(e,i),this.maybeAttachAnnotation(e)}looksLikeFlatAlternation(){let e=1,t=0,n=!1;for(;;){let i=this.cursor.peek(t);if("eof"===i.kind)return n;if("rparen"===i.kind){if(0==(e-=1))return n}else{if("lparen"===i.kind||"dot"===i.kind)return!1;1===e&&("comma"===i.kind||"plus"===i.kind)&&(n=!0)}if((t+=1)>256)return n}}parseChemBody(e){let t;if(this.cursor.at("asterisk"))this.cursor.advance(),t=this.makeAtom(e,A.CHEM,"*"),this.addToChain(e,t,!0);else{let{symbol:n,isInlineSmiles:i,rawPayload:r,inlineSource:o,span:s}=this.consumeMonomerSymbol(!1);t=this.makeAtom(e,A.CHEM,n),void 0!==o&&(t.inlineSource=o),i&&this.registerInlineSmiles(r,s,O.CHEM),this.addToChain(e,t,!0)}this.maybeAttachAnnotation(e),this.cursor.at("apos")&&this.maybeRepeatBracket(e,[t]),this.cursor.at("rbrace")||(this.emit("error","chem-multiple-monomers",`CHEM polymer '${e.id}' must contain exactly one monomer`,this.cursor.currentSpan()),this.skipUntil(["rbrace","eof"]))}parseBlobBody(e){let t,n,i=!1,r="",o,s=this.cursor.currentSpan();if(this.cursor.at("inline-smiles")){let e=this.cursor.advance();i=T(e.value),r=e.value,t=e.value,n=e.value,o=e.value,s=e.span}else if(this.cursor.at("identifier")){let e=this.cursor.advance(),i=e.span.end;for(;;){let e=this.cursor.peek();if("identifier"!==e.kind&&"integer"!==e.kind&&"decimal"!==e.kind&&"dash"!==e.kind&&"underscore"!==e.kind||""!==this.source.slice(i,e.span.start).trim())break;this.cursor.advance(),i=e.span.end}n=t=this.source.slice(e.span.start,i),s={start:e.span.start,end:i},i!==e.span.end&&this.whitespaceAllowed.push(s)}else this.emit("error","unknown-blobtype","Expected BLOB identifier",this.cursor.currentSpan()),t="?",n="?";let a=this.makeAtom(e,A.BLOB,t);a.bio.blobtype=n,void 0!==o&&(a.inlineSource=o),i&&this.registerInlineSmiles(r,s,O.BLOB),this.addToChain(e,a,!0),this.maybeAttachAnnotation(e)}parseGroupBody(e){let t=0;for(;;){let e=this.cursor.peek();if("eof"===e.kind||0===t&&"rbrace"===e.kind)break;"lbrace"===e.kind&&(t+=1),"rbrace"===e.kind&&(t-=1),this.cursor.advance()}}parseConnections(){if(!(this.cursor.at("dollar")||this.cursor.isAtEnd()))for(this.parseConnection();this.cursor.at("pipe")&&(this.cursor.advance(),!(this.cursor.at("dollar")||this.cursor.isAtEnd()));)this.parseConnection()}parseConnection(){let e=this.cursor.currentSpan(),t=this.cursor.optional("identifier");if(null===t){this.emit("error","unexpected-token","Expected chain id in connection",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}if(null===this.cursor.optional("comma")){this.emit("error","unexpected-token","Expected ',' in connection",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}let n=this.cursor.optional("identifier");if(null===n){this.emit("error","unexpected-token","Expected second chain id in connection",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}if(null===this.cursor.optional("comma")){this.emit("error","unexpected-token","Expected ',' before connection position",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}let i=this.parsePosition();if(null===this.cursor.optional("colon")){this.emit("error","unexpected-token","Expected ':' between position and R-group",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}let r=this.parseRGroupSpec();if(null===this.cursor.optional("dash")){this.emit("error","unexpected-token","Expected '-' between connection endpoints",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}let o=this.parsePosition();if(null===this.cursor.optional("colon")){this.emit("error","unexpected-token","Expected ':' before second R-group",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}let s=this.parseRGroupSpec(),a=this.cursor.optional("quote-string"),l="pair"===r.kind&&"pair"===s.kind?"hbond":"cross-polymer",u={chain1:t.value,pos1:i,r1:r,chain2:n.value,pos2:o,r2:s,kind:l,span:{start:e.start,end:a?.span.end??this.cursor.peek().span.start},...null!==a?{tag:a.value}:{}};this.pendingBonds.push(u)}parsePosition(){let e=this.cursor.peek();if("integer"===e.kind){this.cursor.advance();let t=parseInt(e.value,10);if(this.cursor.at("dash")&&"integer"===this.cursor.peek(1).kind&&"colon"===this.cursor.peek(2).kind){this.cursor.advance();let n=parseInt(this.cursor.advance().value,10);return this.checkedRange(t,n,e.span)}return{kind:"index",value:t}}return"lparen"===e.kind?this.parsePositionList():"question"===e.kind?(this.cursor.advance(),{kind:"any"}):"identifier"===e.kind?(this.cursor.advance(),this.emit("info","symbol-position-reference",`Connection position uses monomer symbol '${e.value}' as chain-level ambiguity`,e.span),{kind:"symbol",value:e.value}):(this.emit("error","invalid-position",`Expected position (integer, '?', or symbol), got '${e.value}'`,e.span),{kind:"any"})}checkedRange(e,t,n){return t<e?(this.emit("error","invalid-position",`Connection position range ${e}-${t} is inverted`,n),{kind:"index",value:e}):{kind:"range",min:e,max:t}}parsePositionList(){let e=this.cursor.advance(),t=[],n=null;for(;;){let e=this.cursor.peek();if("integer"!==e.kind)break;this.cursor.advance();let i=parseInt(e.value,10);if(this.cursor.at("dash")&&"integer"===this.cursor.peek(1).kind){this.cursor.advance();let n=parseInt(this.cursor.advance().value,10);n<i?(this.emit("error","invalid-position",`Connection position range ${i}-${n} is inverted`,e.span),t.push({kind:"index",value:i})):t.push({kind:"range",min:i,max:n})}else t.push({kind:"index",value:i});let r=this.cursor.peek();if("comma"!==r.kind&&"plus"!==r.kind)break;let o="comma"===r.kind?"or":"and";null!==n&&n!==o&&this.emit("error","invalid-position","Connection position list mixes ',' and '+'",r.span),n??(n=o),this.cursor.advance()}if(null===this.cursor.optional("rparen")||0===t.length){for(this.emit("error","invalid-position","Expected a position list like (1,3) or (1+3)",{start:e.span.start,end:this.cursor.currentSpan().start});!this.cursor.isAtEnd()&&!this.cursor.at3("colon","pipe","dollar");)this.cursor.advance();let n=t[0];return void 0===n?{kind:"any"}:"index"===n.kind?n:{kind:"range",min:n.min,max:n.max}}let i=t[0];return 1===t.length&&void 0!==i?"index"===i.kind?i:{kind:"range",min:i.min,max:i.max}:{kind:"list",op:n??"or",sites:t}}parseRGroupSpec(){let e=this.cursor.peek();if("question"===e.kind)return this.cursor.advance(),{kind:"unspecified"};if("asterisk"===e.kind)return this.cursor.advance(),{kind:"wildcard"};if("identifier"===e.kind){if(this.cursor.advance(),"pair"===e.value)return{kind:"pair"};let t=/^R([1-9][0-9]*)$/.exec(e.value);return null===t?(this.emit("error","invalid-rgroup",`Expected R-group label, got '${e.value}'`,e.span),{kind:"unspecified"}):{kind:"numeric",r:parseInt(t[1],10)}}return this.emit("error","invalid-rgroup",`Expected R-group label, got '${e.value}'`,e.span),{kind:"unspecified"}}parseGroupsSection(){if(!(this.cursor.at("dollar")||this.cursor.isAtEnd()))for(this.parseGroupOrBondRatio();this.cursor.at("pipe")&&(this.cursor.advance(),!(this.cursor.at("dollar")||this.cursor.isAtEnd()));)this.parseGroupOrBondRatio()}parseGroupOrBondRatio(){let e=this.cursor.optional("identifier");if(null===e){this.emit("error","unexpected-token","Expected group or bond-ratio identifier",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}this.cursor.at("lparen")?this.parseGroupAfterId(e):this.cursor.at("plus")?this.parseBondRatioAfterId(e):(this.emit("warning","unexpected-token",`Expected '(' or '+' after id '${e.value}' in section 3`,this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]))}parseGroupAfterId(e){let t=ed(e.value);null!==t&&t.isGroup||this.emit("error","unknown-group-reference",`Group id must be 'G<n>', got '${e.value}'`,e.span),this.cursor.advance();let n=[],i="or",r=null;for(;!this.cursor.at("rparen")&&!this.cursor.isAtEnd();){let e=this.parseGroupMember();if(null!==e&&n.push(e),this.cursor.at("comma"))null===r&&(r="or",i="or"),this.cursor.advance();else if(this.cursor.at("plus"))null===r&&(r="and",i="and"),this.cursor.advance();else break}null===this.cursor.optional("rparen")&&this.emit("error","unterminated-paren","Expected ')' to close group",this.cursor.currentSpan()),this.groups.push({id:e.value,kind:i,members:n})}parseGroupMember(){let e,t=this.cursor.optional("identifier");return null===t?(this.emit("error","unexpected-token","Expected group member id",this.cursor.currentSpan()),null):(null!==this.cursor.optional("colon")&&(e=this.parseRatio()),void 0===e?{target:t.value}:{target:t.value,ratio:e})}parseRatio(){let e=this.cursor.peek();if("integer"===e.kind||"decimal"===e.kind){this.cursor.advance();let t=parseFloat(e.value);if(this.cursor.at("dash")&&(this.cursor.peek(),"integer"===this.cursor.peek(1).kind)){this.cursor.advance();let t=this.cursor.advance();this.emit("info","ratio-range",`Ratio range ${e.value}-${t.value}; using lower bound`,{start:e.span.start,end:t.span.end})}return t}return"question"===e.kind?(this.cursor.advance(),"?"):(this.emit("error","unexpected-token",`Expected ratio after ':', got '${e.value}'`,e.span),0)}parseBondRatioAfterId(e){let t;this.cursor.advance();let n=this.cursor.optional("identifier");if(null===n)return void this.emit("error","unexpected-token","Expected second chain id in bond-ratio",this.cursor.currentSpan());if(null!==this.cursor.optional("colon")){let e=this.parseRatio();"number"==typeof e&&(t=e)}let i=this.pendingBonds.find(t=>t.chain1===e.value&&t.chain2===n.value||t.chain1===n.value&&t.chain2===e.value);void 0===i?this.emit("warning","bond-ratio-no-matching-bond",`Bond-ratio for ${e.value}+${n.value} has no matching cross-polymer bond`,e.span):void 0!==t&&(i.ratio={numerator:t})}parseAnnotationsSection(){if(!(this.cursor.at("dollar")||this.cursor.isAtEnd())){if(this.cursor.position(),this.cursor.at("lbrace")){this.parseAnnotation20(),this.cursor.at("pipe")&&(this.emit("info","annotation-mixed-versions","Mixed HELM 2.0 JSON and HELM 1.0 pipe annotations",this.cursor.currentSpan()),this.cursor.advance(),this.parseAnnotation10Entries());return}this.parseAnnotation10Entries()}}parseAnnotation20(){let e=this.cursor.currentSpan(),t=0,n=e.end;for(;!this.cursor.isAtEnd();){let e=this.cursor.peek();if("lbrace"===e.kind)t+=1;else if("rbrace"===e.kind&&0==(t-=1)){n=e.span.end,this.cursor.advance();break}this.cursor.advance()}let i=this.source.slice(e.start,n);this.whitespaceAllowed.push({start:e.start,end:n});let r=null;try{r=JSON.parse(i)}catch{this.emit("warning","annotation-malformed-json","Annotation block is not valid JSON",{start:e.start,end:n}),this.annotations={perPolymer:this.annotations.perPolymer,version:this.annotations.version,raw:i};return}if(null===r||"object"!=typeof r||Array.isArray(r))this.emit("warning","annotation-malformed-json","Annotation block parsed but is not an object",{start:e.start,end:n}),this.annotations={perPolymer:this.annotations.perPolymer,version:this.annotations.version,raw:i};else{let t=new Map(this.annotations.perPolymer),n=[...this.annotations.scalarKeys??[]];for(let[i,o]of Object.entries(r))null===o||"object"!=typeof o||Array.isArray(o)?(t.set(i,{value:o}),n.push(i)):(t.set(i,{...o}),this.chainById.has(i)||this.emit("warning","annotation-unknown-polymer",`Annotation references unknown polymer '${i}'`,e));this.annotations={perPolymer:t,version:this.annotations.version,...n.length>0?{scalarKeys:n}:{}}}}parseAnnotation10Entries(){for(this.parseAnnotation10One();this.cursor.at("pipe")&&(this.cursor.advance(),!(this.cursor.at("dollar")||this.cursor.isAtEnd()));)this.parseAnnotation10One()}parseAnnotation10One(){let e=this.cursor.optional("identifier");if(null===e){this.emit("warning","annotation-malformed-json","Expected polymer-id in HELM 1.0 annotation",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}if(null===this.cursor.optional("lbrace")){this.emit("warning","annotation-malformed-json","Expected '{' after polymer-id",this.cursor.currentSpan()),this.skipUntil(["pipe","dollar","eof"]);return}let t=[];for(;!this.cursor.at("rbrace")&&!this.cursor.isAtEnd();)t.push(this.cursor.advance().value);if(null===this.cursor.optional("rbrace"))return void this.emit("error","unterminated-brace","Expected '}' to close annotation",this.cursor.currentSpan());let n=t.join("").trim(),i=new Map(this.annotations.perPolymer),r=i.get(e.value)??{};"ss"===n||"as"===n?i.set(e.value,{...r,strandtype:n}):i.set(e.value,{...r,[n]:!0}),this.chainById.has(e.value)||this.emit("warning","annotation-unknown-polymer",`Annotation references unknown polymer '${e.value}'`,e.span),this.annotations={perPolymer:i,version:this.annotations.version}}parseVersionTrailer(){let e=this.cursor.optional("identifier");if(null===e){this.annotations={...this.annotations,version:""};return}let t=e.value;if(this.cursor.at("dot")&&"integer"===this.cursor.peek(1).kind){this.cursor.advance();let n=this.cursor.advance();t=`${e.value}.${n.value}`}this.annotations={...this.annotations,version:t}}skipUntil(e){for(;!this.cursor.isAtEnd();){if(e.includes(this.cursor.peek().kind))return;this.cursor.advance()}}consumePlainIdentifier(){let e=this.cursor.peek();return"identifier"!==e.kind||"dash"===this.cursor.peek(1).kind?null:(this.cursor.advance(),e.value)}consumeMonomerSymbol(e){let t=this.cursor.peek();if("inline-smiles"===t.kind){this.cursor.advance();let e=T(t.value);return{symbol:t.value,isInlineSmiles:e,rawPayload:t.value,inlineSource:t.value,span:t.span}}if("identifier"===t.kind){this.cursor.advance();let e=t.value,n=t.span;for(;"dash"===this.cursor.peek().kind&&"integer"===this.cursor.peek(1).kind&&("identifier"===this.cursor.peek(2).kind||"dash"===this.cursor.peek(2).kind);){this.cursor.advance();let t=this.cursor.advance();if(e=`${e}-${t.value}`,n=t.span,"identifier"===this.cursor.peek().kind){let t=this.cursor.advance();e=`${e}${t.value}`,n=t.span}}return{symbol:e,isInlineSmiles:!1,rawPayload:e,span:{start:t.span.start,end:n.end}}}if("asterisk"===t.kind||"underscore"===t.kind||"question"===t.kind)return this.cursor.advance(),{symbol:t.value,isInlineSmiles:!1,rawPayload:t.value,span:t.span};if("integer"===t.kind&&"identifier"===this.cursor.peek(1).kind){let e=this.cursor.advance(),t=this.cursor.advance(),n=`${e.value}${t.value}`;return{symbol:n,isInlineSmiles:!1,rawPayload:n,span:{start:e.span.start,end:t.span.end}}}return this.emit("error","unexpected-token",`Expected monomer symbol, got '${t.value}'`,t.span),{symbol:"?",isInlineSmiles:!1,rawPayload:"",span:t.span}}maybeRepeatBracket(e,t){if(!this.cursor.at("apos"))return;let n=this.cursor.currentSpan();this.cursor.advance();let i=this.cursor.optional("integer");if(null===i){this.emit("error","unexpected-token","Expected integer in repeat bracket",this.cursor.currentSpan()),this.cursor.optional("apos");return}let r=parseInt(i.value,10),o=r;if(this.cursor.at("dash")){this.cursor.advance();let e=this.cursor.optional("integer");null===e?this.emit("error","unexpected-token","Expected integer after '-' in repeat bracket",this.cursor.currentSpan()):o=parseInt(e.value,10)}if(null===this.cursor.optional("apos")&&this.emit("error","unterminated-apostrophe","Expected closing apostrophe",this.cursor.currentSpan()),0===t.length)return void this.emit("warning","repeat-on-empty-bracket","Repeat bracket applied to empty content",n);if(o<r){this.emit("warning","repeat-range-inverted",`Repeat range ${r}-${o} has max < min; swapping`,n);let e=r;r=o,o=e}0===r&&0===o?this.emit("warning","repeat-zero-count","Repeat bracket with zero count",n):(o>1e4&&this.emit("warning","bracket-repeat-too-large",`Repeat range upper bound ${o} > 10000`,n),e.polymerType===O.CHEM&&this.emit("error","repeat-on-non-iterable-polymer",`Repeat bracket not allowed on CHEM polymer '${e.id}'`,n),this.groups.push({id:`${e.id}/bracket@${t[0]?.id??0}`,kind:"bracket",members:t.map(e=>({target:String(e.id)})),repeat:{min:r,max:o}}))}maybeAttachAnnotation(e){let t=e.backboneAtoms[e.backboneAtoms.length-1];void 0!==t&&this.maybeAttachAnnotationTo(t)}maybeAttachAnnotationTo(e){if(void 0===e)return;let t=this.cursor.optional("quote-string");null!==t&&(e.tag=t.value)}registerInlineSmiles(e,t,n){if(T(e)){if(null===this.lib)return void this.emit("info","inline-smiles-no-lib","Inline SMILES seen but no monomer library available for registration",t);try{this.lib.addMonomer;let t=this.lib.registerInlineSmilesMonomer;"function"==typeof t&&t.call(this.lib,n,e)}catch(n){let e=n instanceof Error?n.message:String(n);this.emit("warning","inline-smiles-without-r-groups",`Inline SMILES registration failed: ${e}`,t)}}}makeAtom(e,t,n){return{id:this.atomIds.next(),p:{x:0,y:0},biotype:t,symbol:n,monomer:null,bio:{chainId:e.id,positionInChain:0,continuousId:0},hidden:!1,selected:!1,highlighted:!1}}addToChain(e,t,n){e.allAtoms.push(t),n&&(e.backboneAtoms.push(t),t.bio.positionInChain=e.backboneAtoms.length)}addBond(e,t,n,i,r,o){let s=this.bondIds.next();e.bonds.push({id:s,a1:t,a2:n,kind:i,r1:r,r2:o})}finalize(){let e=[];for(let t of this.pendingBonds){let n=this.chainById.has(t.chain1)?void 0:this.groupEndpointChain(t.chain1,t.pos1),i=this.chainById.has(t.chain2)?void 0:this.groupEndpointChain(t.chain2,t.pos2),r=n??this.chainById.get(t.chain1),o=i??this.chainById.get(t.chain2);if(void 0===r){this.emit("error","unknown-chain-reference",`Connection references unknown chain '${t.chain1}'`,t.span);continue}if(void 0===o){this.emit("error","unknown-chain-reference",`Connection references unknown chain '${t.chain2}'`,t.span);continue}let s=this.resolveAtomByPosition(r,t.pos1,t.span),a=this.resolveAtomByPosition(o,t.pos2,t.span);if(null===s||null===a)continue;for(let[e,r]of[[t.chain1,n],[t.chain2,i]])void 0!==r&&this.emit("info","group-connection-endpoint",`Connection endpoint '${e}' is a group; the bond is drawn to its member '${r.id}' and bond.endpoints keeps '${e}'`,t.span);for(let[e,n]of[[t.pos1,r],[t.pos2,o]])"list"!==e.kind&&"range"!==e.kind||this.emit("warning","multi-site-connection",`Connection position '${x(e)}' on '${n.id}' names several sites; the bond is drawn at the first one and bond.endpoints keeps them all`,t.span);let l=void 0!==n||void 0!==i||"index"!==t.pos1.kind||"index"!==t.pos2.kind?[{polymerId:t.chain1,isGroup:void 0!==n,position:t.pos1},{polymerId:t.chain2,isGroup:void 0!==i,position:t.pos2}]:void 0;"pair"===t.r1.kind&&void 0!==s.branchAtom&&(s=s.branchAtom),"pair"===t.r2.kind&&void 0!==a.branchAtom&&(a=a.branchAtom);let u={id:this.bondIds.next(),a1:s,a2:a,kind:t.kind,r1:t.r1,r2:t.r2,...void 0!==t.tag?{tag:t.tag}:{},...void 0!==t.ratio?{ratio:t.ratio}:{},...void 0!==l?{endpoints:l}:{}};e.push(u)}let t=1===this.chains.length?this.chains[0]:void 0,n=void 0!==t?t.allAtoms.slice():[],i=void 0!==t?t.bonds.slice():[],r=[];for(let e of this.chains){if(void 0===t){for(let t of e.allAtoms)n.push(t);for(let t of e.bonds)i.push(t)}let o=this.annotations.perPolymer.get(e.id),s=void 0===o?void 0:o.strandtype,a="ss"===s||"as"===s?s:void 0;r.push({id:e.id,polymerType:e.polymerType,backboneAtoms:e.backboneAtoms,bonds:e.bonds,...void 0!==e.annotation?{annotation:e.annotation}:{},...void 0!==a?{strandType:a}:{}})}for(let t of e)i.push(t);let o=0;for(let e of this.chains)for(let t of e.backboneAtoms)o+=1,t.bio.continuousId=o,void 0!==t.branchAtom&&(o+=1,t.branchAtom.bio.continuousId=o);let s=[];for(let e of this.groups)s.push({id:e.id,kind:e.kind,members:e.members,...void 0!==e.repeat?{repeat:e.repeat}:{}});return{atoms:n,bonds:i,chains:r,groups:s,annotations:this.annotations}}sourceOrderAtoms(e){let t=this.sourceOrderCache.get(e);if(void 0!==t)return t;for(let n of(t=[],e.backboneAtoms))t.push(n),void 0!==n.branchAtom&&t.push(n.branchAtom);return this.sourceOrderCache.set(e,t),t}groupEndpointChain(e,t){if(!this.groups.some(t=>t.id===e&&"bracket"!==t.kind))return;let n=[],i=new Set,r=e=>{if(i.has(e))return;i.add(e);let t=this.groups.find(t=>t.id===e&&"bracket"!==t.kind);if(void 0!==t)for(let e of t.members){let t=this.chainById.get(e.target);void 0!==t?n.push(t):r(e.target)}};r(e);let o=e=>{if("symbol"===t.kind)return e.allAtoms.some(e=>e.symbol===t.value);let n=ea(t);return null===n||n>=1&&n<=this.sourceOrderAtoms(e).length};return n.find(o)??n[0]}resolveAtomByPosition(e,t,n){if("range"===t.kind||"list"===t.kind)return this.resolveAtomByPosition(e,{kind:"index",value:ea(t)??1},n);if("any"===t.kind)return e.backboneAtoms[0]??null;if("symbol"===t.kind){let i=e.backboneAtoms.find(e=>e.symbol===t.value);if(void 0===i){let i=e.allAtoms.find(e=>e.symbol===t.value);return void 0===i?(this.emit("warning","position-out-of-range",`Chain '${e.id}' has no monomer with symbol '${t.value}'`,n),e.backboneAtoms[0]??null):i}return i}let i=this.sourceOrderAtoms(e),r=t.value;return r<1||r>i.length?(this.emit("error","position-out-of-range",`Position ${r} out of range for chain '${e.id}' (length ${i.length})`,n),e.backboneAtoms[0]??null):i[r-1]}emit(e,t,n,i){let r={severity:e,code:t,message:n,...void 0!==i?{span:{start:i.start,end:i.end}}:{}};if(this.diagnostics.push(r),"strict"===this.mode&&"error"===e)throw new m(t,n,{...void 0!==i?{span:{start:i.start,end:i.end}}:{}})}};function eh(e){let t=[],n=[],i=e.groups.filter(e=>"bracket"===e.kind);if(0===i.length)return{mol:e,expanded:0,unexpanded:n,diagnostics:t};let r=new Map;for(let t of e.chains)for(let e of t.backboneAtoms)r.set(e.id,t),void 0!==e.branchAtom&&r.set(e.branchAtom.id,t);let o=1+Math.max(0,...e.atoms.map(e=>e.id)),s=1+Math.max(0,...e.bonds.map(e=>e.id)),a=new Map,l=e=>{let t={src:e,id:e.id};return a.set(e.id,t),t},u=new Map;for(let t of e.chains)u.set(t.id,t.backboneAtoms.map(e=>{let t=l(e);return void 0!==e.branchAtom&&(t.branch=l(e.branchAtom)),t}));let d=[];for(let t of e.bonds){let e=a.get(t.a1.id),n=a.get(t.a2.id);void 0===e||void 0===n||d.push({src:t,id:t.id,a1:e,a2:n,kind:t.kind,r1:t.r1,r2:t.r2})}let c=i.slice().sort((e,t)=>e.members.length-t.members.length),h=0;for(let e of c){let i=e.members.map(e=>parseInt(e.target,10)).filter(e=>Number.isFinite(e)),a=i.length>0?r.get(i[0]):void 0,l=void 0===a?void 0:u.get(a.id),c=e.repeat??{min:1,max:1},p=`${a?.id??"?"} '${c.min===c.max?c.min:`${c.min}-${c.max}`}'`;if(void 0===a||void 0===l){n.push(e),t.push({severity:"warning",code:"repeat-not-expanded",message:`Repeat ${e.id} has no atoms in a chain; left as is`});continue}if(c.min!==c.max){n.push(e),t.push({severity:"warning",code:"repeat-range-not-expanded",message:`Repeat range ${p} has no fixed count; left unexpanded`,context:{groupId:e.id,min:c.min,max:c.max}});continue}if(a.polymerType===O.CHEM){n.push(e),t.push({severity:"warning",code:"repeat-not-expanded",message:`Repeat on CHEM ${p} is not allowed; left as is`});continue}let f=new Set(i),m=-1,g=-1;if(l.forEach((e,t)=>{f.has(e.src.id)&&void 0===e.copy&&(m<0&&(m=t),g=t)}),m<0){n.push(e),t.push({severity:"warning",code:"repeat-not-expanded",message:`Repeat ${e.id} has no backbone atoms; left as is`});continue}let v=c.min;if(h+=1,v<=1)continue;let b=l.slice(m,g+1),y=new Set;for(let e of b)y.add(e),void 0!==e.branch&&y.add(e.branch);let _=b[b.length-1],w=l[g+1],x=void 0===w?void 0:d.find(e=>"backbone"===e.kind&&(e.a1===_&&e.a2===w||e.a2===_&&e.a1===w)),k=d.filter(e=>y.has(e.a1)&&y.has(e.a2));for(let n of d)"cross-polymer"!==n.kind&&"hbond"!==n.kind||y.has(n.a1)!==y.has(n.a2)&&t.push({severity:"info",code:"repeat-crosslink-first-copy",message:`A connection onto repeat ${p} stays on its first copy`,context:{groupId:e.id,bondId:n.id}});let S=[],C=_;for(let e=2;e<=v;e++){let t=new Map,n=n=>{let i={src:n.src,id:o++,copy:e};return t.set(n,i),i},i=b.map(e=>{let t=n(e);return void 0!==e.branch&&(t.branch=n(e.branch)),t});for(let e of k)d.push({src:e.src,id:s++,a1:t.get(e.a1),a2:t.get(e.a2),kind:e.kind,r1:e.r1,r2:e.r2});let r=void 0!==x&&x.a1===_;d.push({src:void 0,id:s++,a1:C,a2:i[0],kind:"backbone",r1:void 0===x?{kind:"numeric",r:2}:r?x.r1:x.r2,r2:void 0===x?{kind:"numeric",r:1}:r?x.r2:x.r1}),C=i[i.length-1],S.push(...i)}void 0!==x&&(x.a1===_?x.a1=C:x.a2=C),l.splice(g+1,0,...S)}if(0===h)return{mol:e,expanded:h,unexpanded:n,diagnostics:t};let p=new Set;for(let e of u.values())for(let t of e)void 0!==t.copy&&(p.add(t.src.id),void 0!==t.branch&&p.add(t.branch.src.id));let f=new Map,m=new Map,g=[],v=0,b=(e,t,n)=>{v+=1;let i=e.copy??(p.has(e.src.id)?1:e.src.bio.repeatCopy),r={...e.src.bio,positionInChain:t,continuousId:v,sourceContinuousId:e.src.bio.sourceContinuousId??e.src.bio.continuousId,...void 0!==i?{repeatCopy:i}:{}},{branchAtom:o,...s}=e.src;return{...s,id:e.id,bio:r,...void 0!==n?{branchAtom:n}:{}}},y=[];for(let t of e.chains){let e=u.get(t.id),n=[];e.forEach((e,i)=>{let r;m.set(e,t.id);let o=v;v+=1,void 0!==e.branch&&(m.set(e.branch,t.id),r=b(e.branch,e.branch.src.bio.positionInChain,void 0),f.set(e.branch,r));let s=v;v=o;let a=b(e,i+1,r);v=s,f.set(e,a),g.push(a),void 0!==r&&g.push(r),n.push(a)}),y.push({...t,backboneAtoms:n,bonds:[]})}for(let t of e.atoms)a.has(t.id)||g.push(t);let _=new Map,w=[];for(let e of d){let t=function(e,t){let n=t.get(e.a1),i=t.get(e.a2),r=e.src?.tag,o=e.src?.ratio,s=e.src?.endpoints;return{id:e.id,a1:n,a2:i,kind:e.kind,r1:e.r1,r2:e.r2,...void 0!==r?{tag:r}:{},...void 0!==o?{ratio:o}:{},...void 0!==s?{endpoints:s}:{}}}(e,f);if(w.push(t),"cross-polymer"===e.kind||"hbond"===e.kind)continue;let n=m.get(e.a1);if(void 0===n)continue;let i=_.get(n)??[];i.push(t),_.set(n,i)}return{mol:{atoms:g,bonds:w,chains:y.map(e=>({...e,bonds:_.get(e.id)??[]})),groups:e.groups.filter(e=>"bracket"!==e.kind||n.includes(e)),annotations:e.annotations},expanded:h,unexpanded:n,diagnostics:t}}var ep=Object.freeze({monomersPerRow:20,adaptive:!0}),ef=Symbol.for("@datagrok-libraries/hwe.wrapSettings");function em(e){if(Number.isInteger(e))return 0===e?"0":e.toString();if(!Number.isFinite(e)||Object.is(e,-0))return"0";let t=Math.round(1e3*e)/1e3;return 0===t?"0":t.toString()}function eg(e){if(0===e.length)return"";let t=e[0],n=`M ${em(t.x)} ${em(t.y)}`;for(let t=1;t<e.length;t++){let i=e[t];n+=` L ${em(i.x)} ${em(i.y)}`}return n+` L ${em(t.x)} ${em(t.y)} Z`}function ev(e,t,n,i){let r=[],o=360/t;for(let s=0;s<t;s++){let t=(i+s*o)*Math.PI/180;r.push({x:e.x+n*Math.cos(t),y:e.y+n*Math.sin(t)})}return r}function eb(e,t,n,i){let r=Math.abs(t)/2,o=Math.abs(n)/2,s=Math.max(0,Math.min(i,r,o)),a=e.x-r,l=e.y-o,u=a+2*r,d=l+2*o;return`M ${em(a+s)} ${em(l)} L ${em(u-s)} ${em(l)} A ${em(s)} ${em(s)} 0 0 1 ${em(u)} ${em(l+s)} L ${em(u)} ${em(d-s)} A ${em(s)} ${em(s)} 0 0 1 ${em(u-s)} ${em(d)} L ${em(a+s)} ${em(d)} A ${em(s)} ${em(s)} 0 0 1 ${em(a)} ${em(d-s)} L ${em(a)} ${em(l+s)} A ${em(s)} ${em(s)} 0 0 1 ${em(a+s)} ${em(l)} Z`}function ey(e,t,n,i){switch(e){case"hexagon":{let e=n*Math.sqrt(3)/2;return{x:t.x-e,y:t.y-n,width:2*e,height:2*n}}case"diamond":return{x:t.x-n,y:t.y-n,width:2*n,height:2*n};case"pentagon":{let e=Math.cos(18*Math.PI/180)*n,i=-n,r=Math.sin(54*Math.PI/180)*n;return{x:t.x-e,y:t.y+i,width:2*e,height:r-i}}case"rounded-rect":case"blob":{let e=Math.abs(n)/2,r=Math.abs(i??n)/2;return{x:t.x-e,y:t.y-r,width:2*e,height:2*r}}case"ellipse":{let e=Math.abs(n),r=Math.abs(i??n);return{x:t.x-e,y:t.y-r,width:2*e,height:2*r}}case"circle":{let e=Math.abs(n);return{x:t.x-e,y:t.y-e,width:2*e,height:2*e}}}}ep.monomersPerRow,ep.monomersPerRow;var e_='"Helvetica Neue", Helvetica, Arial, sans-serif';function ew(e){return{aa:{size:.72*e,strokeWidth:5},sugar:{size:1.39*e,strokeWidth:5,cornerRadius:.3*e},base:{size:.88*e,strokeWidth:5},linker:{size:.63*e,strokeWidth:5},chem:{size:1.49*e,strokeWidth:5,cornerRadius:.5*e},blob:{size:1.64*e,strokeWidth:5,cornerRadius:.8*e},nucleotide:{size:.98*e,strokeWidth:5}}}var ex={name:"light",background:"#ffffff",defaultStroke:"#202020",defaultFill:"#ffffff",selectionColor:"#FFC107",highlightColor:"#A4E2DC",errorColor:"#cc0000",fontSize:14,fontFamily:e_,bondLength:28,textColor:"#000000",idColor:"#00aa00",annotationColor:"#FFA500",tagDotColor:"#dd2222",hbondColor:"#888888",nonCanonicalHbondColor:"#cc8800",crossPolymerBondColor:"#1f5fcd",colorTheme:Z,palette:{softenCanvas:!1},shapes:ew(14)},ek={name:"dark",background:"#1a1d23",defaultStroke:"#e0e0e0",defaultFill:"#2b2f37",selectionColor:"#FFD54F",highlightColor:"#7DD8CC",errorColor:"#ff5050",fontSize:14,fontFamily:e_,bondLength:28,textColor:"#ffffff",idColor:"#33ff33",annotationColor:"#FFB84D",tagDotColor:"#ff6464",hbondColor:"#aaaaaa",nonCanonicalHbondColor:"#ffaa44",crossPolymerBondColor:"#6699ff",colorTheme:J,palette:{softenCanvas:!1},shapes:ew(14)};function eS(e,t){switch(t){case A.AA:return e.shapes.aa;case A.SUGAR:return e.shapes.sugar;case A.BASE:return e.shapes.base;case A.LINKER:return e.shapes.linker;case A.CHEM:return e.shapes.chem;case A.BLOB:return e.shapes.blob;case A.NUCLEOTIDE:return e.shapes.nucleotide}}function eC(e){switch(e){case A.AA:return"hexagon";case A.SUGAR:return"rounded-rect";case A.BASE:return"diamond";case A.LINKER:return"circle";case A.CHEM:return"rounded-rect";case A.BLOB:return"blob";case A.NUCLEOTIDE:return"pentagon"}}function eA(e,t,n=0){var i,r,o,s,a,l,u;let d=eS(t,e.biotype);switch(eC(e.biotype)){case"hexagon":{let t=0===n?0:n/Math.cos(Math.PI/6);return function(e,t,n=-30){return eg(ev(e,6,t,n))}(e.p,d.size+t)}case"diamond":{let t=0===n?0:n/Math.cos(Math.PI/4);return i=e.p,r=d.size+t,eg([{x:i.x,y:i.y-r},{x:i.x+r,y:i.y},{x:i.x,y:i.y+r},{x:i.x-r,y:i.y}])}case"pentagon":{let t=0===n?0:n/Math.cos(Math.PI/5);return function(e,t,n=-90){return eg(ev(e,5,t,n))}(e.p,d.size+t)}case"rounded-rect":return eb(e.p,d.size+2*n,d.size+2*n,(d.cornerRadius??0)+n);case"blob":return o=e.p,s=d.size+2*n,eb(o,s,d.size+2*n,(d.cornerRadius??0)+n);case"circle":let c,h;return a=e.p,l=d.size+n,u=d.size+n,c=Math.abs(l),h=Math.abs(u),`M ${em(a.x-c)} ${em(a.y)} A ${em(c)} ${em(h)} 0 1 0 ${em(a.x+c)} ${em(a.y)} A ${em(c)} ${em(h)} 0 1 0 ${em(a.x-c)} ${em(a.y)} Z`}}function eO(e,t){let n=eS(t,e.biotype),i=eC(e.biotype),r;switch(i){case"hexagon":case"diamond":case"pentagon":case"circle":r=ey(i,e.p,n.size);break;case"rounded-rect":case"blob":r=ey(i,e.p,n.size,n.size)}let o=n.strokeWidth/2;return{x:r.x-o,y:r.y-o,width:r.width+2*o,height:r.height+2*o}}function eE(e,t){return eS(t,e.biotype)}var eT=/[&"'<>]/;function eP(e,t,n){let i=`<${e}`;if(void 0!==t)for(let e in t){let n=t[e];if(void 0!==n&&!1!==n){if(!0===n){i+=` ${e}`;continue}"number"==typeof n?i+=` ${e}="${function(e){if(Number.isInteger(e))return 0===e?"0":e.toString();if(!Number.isFinite(e)||Object.is(e,-0))return"0";let t=Math.round(1e3*e)/1e3;return 0===t?"0":t.toString()}(n)}"`:i+=` ${e}="${eT.test(n)?n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):n}"`}}return void 0===n?`${i}/>`:"string"==typeof n?`${i}>${n}</${e}>`:`${i}>${n.join("")}</${e}>`}new WeakMap;var eN=class{constructor(e,t){this.atoms=e,this.bonds=t,this.isEmpty=0===e.size&&0===t.size,Object.freeze(this)}},eI=new eN(new Set,new Set);function eM(e){let t=e.ownerDocument;if(null!=t)return t;let n=globalThis;if(void 0!==n.document)return n.document;throw Error("EditorView: no Document available (host.ownerDocument is null).")}function eL(e,t,n,i){let r=e.createElement(t);if(void 0!==n)for(let e of Object.keys(n)){let t=n[e];!1===t||void 0===t||r.setAttribute(e,!0===t?"":String(t))}if(void 0!==i)for(let t of i)"string"==typeof t?r.appendChild(e.createTextNode(t)):r.appendChild(t);return r}function eR(e,t,n=220,i=140){if(null==e||""===t)return null;try{let r=e.get_mol(t);if(null===r)return null;let o=r.get_svg(n,i);return r.delete(),o}catch{return null}}function ej(e,t,n){let i="data-testid";for(let n=0;n<e.body.children.length;n++){let r=e.body.children[n];if(void 0!==r&&r.getAttribute(i)===t)return r}let r=eL(e,"div",{class:n,[i]:t});return r.style.display="none",e.body.appendChild(r),r}function eD(e,t,n){for(;null!==t.firstChild;)t.removeChild(t.firstChild);if(t.appendChild(eL(e,"div",{class:"hw-tooltip__symbol"},[n.symbol])),void 0!==n.name&&""!==n.name&&n.name!==n.symbol&&t.appendChild(eL(e,"div",{class:"hw-tooltip__name"},[n.name])),void 0!==n.rdkitSvg&&null!==n.rdkitSvg&&""!==n.rdkitSvg){let i={class:"hw-tooltip__rdkit"};void 0!==n.rdkitTestid&&(i["data-testid"]=n.rdkitTestid);let r=eL(e,"div",i);r.innerHTML=n.rdkitSvg,t.appendChild(r)}void 0!==n.hint&&""!==n.hint&&t.appendChild(eL(e,"div",{class:"hw-tooltip__hint"},[n.hint]))}function e$(e,t,n){let i=e.style;i.display="block",i.left=`${t+12}px`,i.top=`${n+12}px`}function eF(e){null!==e&&(e.style.display="none")}function ez(e){let t=e.body;if(null!=t)for(let e=0;e<t.children.length;e++){let n=t.children[e];if(void 0===n)continue;let i=void 0===n.getAttribute?null:n.getAttribute("data-testid");null!=i&&i.endsWith("-tooltip")&&eF(n)}}var eq=class e{constructor(e,t,n){this._baseTransform="",this._viewport={scale:1,offset:{x:0,y:0}},this._pinnedBbox=null,this._tooltip=null,this._bondTooltip=null,this._rdkitSvgCache=new Map,this._unsubs=[],this._destroyed=!1,this.host=e,this._editor=t,this._doc=n?.documentImpl??eM(e),this._width=n?.width??400,this._height=n?.height??200,function(e){let t=eM(e);if(null!==t.querySelector("style[data-hw-editor-view-styles]"))return;let n=t.createElement("style");n.setAttribute("data-hw-editor-view-styles",""),n.textContent=".hw-editor-view{position:relative;display:block;overflow:hidden;outline:none;}.hw-editor-view svg{display:block;user-select:none;}.hw-editor-view.hw-view-only{cursor:default;}";let i=t.head??t.documentElement;null!==i&&i.appendChild(n)}(e);let i=this._doc.createElement("div");i.setAttribute("class","hw-editor-view"),e.appendChild(i),this._tooltip=ej(this._doc,"atom-tooltip","hw-atom-tooltip"),this._bondTooltip=ej(this._doc,"bond-tooltip","hw-bond-tooltip"),this._svgRoot=this._renderFresh(),this._unsubs.push(t.on("mol:changed",e=>{this._hideTooltip(),this._hideBondTooltip(),("setHelm"===e.reason||"cleanLayout"===e.reason||"initial"===e.reason)&&(this._pinnedBbox=null),this._renderFresh()})),this._unsubs.push(t.on("selection:change",e=>{this._refreshOverlays(e)})),this._unsubs.push(t.on("highlight:change",e=>{this._refreshOverlays(e)})),this._unsubs.push(t.on("theme:change",()=>{this._renderFresh()})),this._unsubs.push(t.on("view:resize",e=>{this._applyResize(e.width,e.height)})),this._unsubs.push(t.on("view:viewport-change",e=>{this._viewport=e.viewport,this._applyViewport(e.viewport)})),this._unsubs.push(t.on("view:fit-to-content",()=>{this._pinnedBbox=null,this._renderFresh()})),this._unsubs.push(t.on("monomer:hover",e=>{this._showTooltip(e.atom,e.clientX,e.clientY)})),this._unsubs.push(t.on("monomer:hover-end",()=>{this._hideTooltip()})),this._unsubs.push(t.on("bond:hover",e=>{this._showBondTooltip(e.bond,e.clientX,e.clientY)})),this._unsubs.push(t.on("bond:hover-end",()=>{this._hideBondTooltip()})),this._unsubs.push(t.on("bond:preview",e=>{this._paintBondPreview(e.start.p,e.cursor,null!==e.candidate)})),this._unsubs.push(t.on("bond:preview-end",()=>{this._clearBondPreview()})),this._unsubs.push(t.on("bond:cancel",()=>{this._clearBondPreview()})),this._unsubs.push(t.on("selection:rectangle-start",e=>{this._paintSelectionRect(e.origin,e.origin)})),this._unsubs.push(t.on("selection:rectangle-update",e=>{this._paintSelectionRectFromRect(e.rect)})),this._unsubs.push(t.on("selection:rectangle-end",()=>{this._clearSelectionRect()}))}get svgRoot(){return this._svgRoot}get width(){return this._width}get height(){return this._height}resize(e,t){this._destroyed||(this._width=e,this._height=t,this._renderFresh())}redraw(){this._destroyed||this._renderFresh()}destroy(){if(this._destroyed)return;for(let e of(this._destroyed=!0,this._unsubs))e();this._unsubs.length=0;let e=this.host.querySelector(".hw-editor-view");null!==e&&null!==e.parentNode&&e.parentNode.removeChild(e),eF(this._tooltip),eF(this._bondTooltip),this._tooltip=null,this._bondTooltip=null}_renderFresh(){let e=this._editor.getService(),t=this._currentTheme(),n=this._editor.getMol();null===this._pinnedBbox&&(this._pinnedBbox=function(e,t=ex){if(0===e.atoms.length)return{x:0,y:0,width:0,height:0};let n=eO(e.atoms[0],t);for(let i=1;i<e.atoms.length;i++)n=function(e,t){let n=Math.min(e.x,t.x),i=Math.min(e.y,t.y);return{x:n,y:i,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-i}}(n,eO(e.atoms[i],t));return n}(n,t));let i=e.renderMol(n,{width:this._width,height:this._height,theme:t,fixedModelBbox:this._pinnedBbox});this._svgRoot=function(e,t){let n=eM(e),i=e.querySelector(".hw-editor-view");if(null===i)throw Error("EditorView.replaceSvg: missing .hw-editor-view wrapper.");let r=n.createElement("div");r.innerHTML=t;let o=r.querySelector("svg");if(null===o)throw Error("EditorView.replaceSvg: rendered output contained no <svg>.");for(;null!==i.firstChild;)i.removeChild(i.firstChild);return i.appendChild(o),o}(this.host,i);let r=this._svgRoot.querySelector(".hw-content");return this._baseTransform=null!==r?r.getAttribute("transform")??"":"",this._svgRoot.setAttribute("data-testid","editor-svg"),this._applyOverlaysToCurrent(),(1!==this._viewport.scale||0!==this._viewport.offset.x||0!==this._viewport.offset.y)&&this._applyViewport(this._viewport),this._svgRoot}_refreshOverlays(e){this._applyOverlaysToCurrent()}_applyOverlaysToCurrent(){let e=this._editor.getMol(),t=this._editor.getSelection(),n=function(e,t={}){let n=t.theme??ex,i=t.selectedAtomIds??new Set;return{highlightLayer:function(e,t,n){if(0===n.size)return eP("g",{class:"hw-layer hw-highlights"},"");let i=[];for(let r of e.atoms){if(!n.has(r.id))continue;let e=(eE(r,t).strokeWidth+3)/2,o=eA(r,t,e);i.push(eP("path",{d:o,class:"hw-highlight",fill:"none",stroke:t.highlightColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":r.symbol,"data-ring-atom-id":r.id,"data-testid":`highlight-ring-${r.id}`}))}return eP("g",{class:"hw-layer hw-highlights"},i.join(""))}(e,n,t.highlightedAtomIds??new Set),selectionLayer:function(e,t,n){if(0===n.size)return eP("g",{class:"hw-layer hw-selections"},"");let i=[];for(let r of e.atoms){if(!n.has(r.id))continue;let e=(eE(r,t).strokeWidth+3)/2,o=eA(r,t,e);i.push(eP("path",{d:o,class:"hw-selection",fill:"none",stroke:t.selectionColor,"stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round","data-symbol":r.symbol,"data-ring-atom-id":r.id,"data-testid":`selection-ring-${r.id}`}))}return eP("g",{class:"hw-layer hw-selections"},i.join(""))}(e,n,i)}}(e,{theme:this._currentTheme(),selectedAtomIds:t.atoms,highlightedAtomIds:this._editorHighlights()});this._spliceLayer("hw-highlights",n.highlightLayer),this._spliceLayer("hw-selections",n.selectionLayer)}_spliceLayer(e,t){let n=this._svgRoot.querySelector(`.${e}`);if(null===n||null===n.parentNode)return;let i=this._doc.createElementNS("http://www.w3.org/2000/svg","svg");i.innerHTML=t;let r=i.querySelector(`.${e}`);null!==r&&n.parentNode.replaceChild(r,n)}_editorHighlights(){let e=this._editor;return"function"==typeof e._currentHighlights?e._currentHighlights():new Set}_currentTheme(){let e=this._editor;return"function"==typeof e._currentTheme?e._currentTheme():this._editor.getService().theme}_applyResize(e,t){this._width=e,this._height=t,this._pinnedBbox=null,this._renderFresh()}_applyViewport(e){let t=this._svgRoot.querySelector(".hw-content");if(null===t)return;let n=`translate(${e.offset.x} ${e.offset.y}) scale(${e.scale})`,i=""===this._baseTransform?n:`${n} ${this._baseTransform}`;t.setAttribute("transform",i)}_showTooltip(e,t,n){let i=this._tooltip;if(null===i)return;let r=""===e.symbol?"?":e.symbol,o=e.monomer?.name??"",s=e.bio.positionInChain,a=""===e.bio.chainId?"?":e.bio.chainId,l=""!==o&&o!==r?`${o} @ ${a}:${s}`:`${r} @ ${a}:${s}`,u=this._renderRdkitTooltipSvg(e);eD(this._doc,i,{symbol:r,name:l,rdkitSvg:u,rdkitTestid:"atom-tooltip-rdkit-svg"});let d=""!==o&&o!==r?`${r} \u2014 ${o} @ ${a}:${s}`:`${r} @ ${a}:${s}`,c=this._doc.createElement("div");c.setAttribute("class","hw-atom-tooltip__text"),c.style.display="none",c.appendChild(this._doc.createTextNode(d)),i.appendChild(c),e$(i,t,n)}_renderRdkitTooltipSvg(t){let n=this._editor.getService().options.rdkitModule;if(null==n)return null;let i=t.monomer;if(null===i)return null;let r=i.smiles;if(void 0===r||""===r)return null;let o=`${i.polymerType}:${i.symbol}`;if(this._rdkitSvgCache.has(o))return this._rdkitSvgCache.get(o)??null;let s=eR(n,r,220,140);if(this._rdkitSvgCache.size>=e._RDKIT_CACHE_LIMIT){let e=this._rdkitSvgCache.keys().next().value;void 0!==e&&this._rdkitSvgCache.delete(e)}return this._rdkitSvgCache.set(o,s),s}_hideTooltip(){eF(this._tooltip)}_showBondTooltip(e,t,n){let i=this._bondTooltip;if(null===i)return;let r=eB(e.r1),o=eB(e.r2),s=`${e.a1.symbol}@${e.a1.bio.chainId}:${e.a1.bio.positionInChain}`,a=`${e.a2.symbol}@${e.a2.bio.chainId}:${e.a2.bio.positionInChain}`;eD(this._doc,i,{symbol:`${r}-${o} (${e.kind})`,name:`${s} \u2194 ${a}`}),e$(i,t,n)}_hideBondTooltip(){eF(this._bondTooltip)}_paintBondPreview(e,t,n){let i=this._svgRoot.querySelector(".hw-content");if(null===i)return;let r=i.querySelector(".hw-bond-preview");null===r&&((r=this._doc.createElementNS("http://www.w3.org/2000/svg","line")).setAttribute("class","hw-bond-preview"),r.setAttribute("data-testid","bond-preview"),r.setAttribute("stroke-dasharray","6 4"),r.setAttribute("stroke-width","2"),r.setAttribute("fill","none"),r.setAttribute("pointer-events","none"),i.appendChild(r)),r.setAttribute("x1",String(e.x)),r.setAttribute("y1",String(e.y)),r.setAttribute("x2",String(t.x)),r.setAttribute("y2",String(t.y)),r.setAttribute("stroke",n?"#1f5fcd":"#999999")}_clearBondPreview(){let e=this._svgRoot.querySelector(".hw-bond-preview");null!==e&&null!==e.parentNode&&e.parentNode.removeChild(e)}_paintSelectionRect(e,t){let n=Math.min(e.x,t.x),i=Math.min(e.y,t.y),r=Math.abs(e.x-t.x),o=Math.abs(e.y-t.y);this._paintSelectionRectAt(n,i,r,o)}_paintSelectionRectFromRect(e){this._paintSelectionRectAt(e.x,e.y,e.width,e.height)}_paintSelectionRectAt(e,t,n,i){let r=this._svgRoot.querySelector(".hw-content");if(null===r)return;let o=r.querySelector(".hw-selection-rect");null===o&&((o=this._doc.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("class","hw-selection-rect"),o.setAttribute("data-testid","selection-rect"),o.setAttribute("fill","rgba(31, 95, 205, 0.08)"),o.setAttribute("stroke","#1f5fcd"),o.setAttribute("stroke-width","1"),o.setAttribute("stroke-dasharray","4 3"),o.setAttribute("pointer-events","none"),r.appendChild(o)),o.setAttribute("x",String(e)),o.setAttribute("y",String(t)),o.setAttribute("width",String(n)),o.setAttribute("height",String(i))}_clearSelectionRect(){let e=this._svgRoot.querySelector(".hw-selection-rect");null!==e&&null!==e.parentNode&&e.parentNode.removeChild(e)}};function eB(e){switch(e.kind){case"numeric":return`R${e.r}`;case"unspecified":return"?";case"wildcard":return"*";case"pair":return"pair";case"positional":return`${e.position}pos:R${e.r}`}}eq._RDKIT_CACHE_LIMIT=256;var eG=class e{constructor(e,t){this._onClose=null,this._primaryAction=null,this._host=e,this._doc=t.documentImpl??eM(e);let n=this._doc,i={class:"hw-modal-backdrop",role:"presentation"};void 0!==t.testId&&(i["data-testid"]=`dialog-${t.testId}`);let r=eL(n,"div",i),o={class:"hw-modal",role:"dialog","aria-modal":"true","aria-label":t.title};void 0!==t.testId&&(o["data-testid"]=`dialog-${t.testId}-frame`);let s=eL(n,"div",o),a=eL(n,"div",{class:"hw-modal__header"},[t.title]),l=eL(n,"div",{class:"hw-modal__body"});s.appendChild(a),s.appendChild(l),r.appendChild(s);let u=e=>{e.stopPropagation()};for(let e of["mousedown","mousemove","mouseup","mouseover","mouseenter","mouseleave","wheel","contextmenu","dblclick","keydown","keyup","keypress"])r.addEventListener(e,u);s.addEventListener("keydown",e=>{if("Enter"!==e.key||e.target?.tagName==="TEXTAREA")return;let t=this._primaryAction;null!==t&&(e.preventDefault?.(),e.stopImmediatePropagation?.(),t())}),r.addEventListener("click",e=>{e.target===r?this.close():e.stopPropagation()}),this.root=r,this.body=l}static anyOpen(){return e._openStack.length>0}static closeTopmost(){let t=e._openStack[e._openStack.length-1];return void 0!==t&&(t.close(),!0)}open(t){this._onClose=t??null,null===this.root.parentNode&&this._host.appendChild(this.root),e._openStack.includes(this)||e._openStack.push(this),ez(this._doc)}close(){let t=e._openStack.indexOf(this);t>=0&&e._openStack.splice(t,1),null!==this.root.parentNode&&this.root.parentNode.removeChild(this.root);let n=this._onClose;this._onClose=null,null!==n&&n()}setPrimaryAction(e){this._primaryAction=e}get isOpen(){return null!==this.root.parentNode}};function eV(e,t,n,i){let r=`hw-input-${Math.random().toString(36).slice(2,9)}`,o=eL(e,"label",{for:r,class:"hw-modal__label"},[t]),s=e.createElement("input");return s.setAttribute("id",r),s.setAttribute("type","text"),s.setAttribute("class","hw-modal__input"),void 0!==i&&s.setAttribute("data-testid",i),s.value=n,{row:eL(e,"div",{class:"hw-modal__row"},[o,s]),input:s}}eG._openStack=[];Object.freeze(new Set);function eU(e){return e.startsWith("[")&&e.endsWith("]")||1===e.length&&/^[A-Za-z]$/.test(e)?e:`[${e}]`}function eH(e,t,n){return`${eU(e)}(${eU(t)})${eU(n)}`}var eW="http://www.w3.org/2000/svg",eY={sugar:A.SUGAR,base:A.BASE,linker:A.LINKER},eK={sugar:["r","R"],base:["A"],linker:["p","P"]},eX={x:70,y:60},eZ={x:140,y:60},eQ={x:70,y:130},eJ=class e{constructor(e,t,n){this.onValueSet=new P,this.onPickModeChange=new P,this._slots=new Map,this._favStar=null,this._pickMode=null,this._destroyed=!1,this._builderRdkitCache=new Map,this._editor=t,this._doc=n?.documentImpl??eM(e),this._hooks=n?.paletteHooks??null,this._favHooks=n?.favoriteHooks??null,this.element=eL(this._doc,"div",{class:"hw-rna-builder","data-testid":"rna-builder"});let i=eL(this._doc,"div",{class:"hw-rna-builder__header"});if(i.appendChild(eL(this._doc,"div",{class:"hw-rna-builder__title"},["RNA builder"])),null!==this._favHooks){let e=eL(this._doc,"span",{class:"hw-rna-builder__fav hw-rna-builder__fav--disabled",role:"button",tabindex:"0","data-testid":"rna-builder-fav-star",title:"Favorite this triplet","aria-pressed":"false","aria-disabled":"true"},["☆"]),t=e=>{e.stopPropagation();let t=this.getSelection();""===t.preview||null===this._favHooks||this._favHooks.toggleFavoriteTriplet(t.sugar,t.base,t.linker)};e.addEventListener("click",t),e.addEventListener("keydown",e=>{("Enter"===e.key||" "===e.key)&&t(e)}),this._favStar=e,i.appendChild(e)}this.element.appendChild(i),this._hintEl=eL(this._doc,"div",{class:"hw-rna-builder__hint","data-testid":"rna-builder-hint",hidden:!0}),this.element.appendChild(this._hintEl);let r=this._buildSvg();this.element.appendChild(r),this._preview=eL(this._doc,"div",{class:"hw-rna-builder__preview","data-testid":"rna-builder-preview"}),this.element.appendChild(this._preview),this._addBtn=eL(this._doc,"button",{class:"hw-rna-builder__add",type:"button","data-testid":"rna-builder-add-btn"},["Add triplet"]),this._addBtn.addEventListener("click",()=>this._onAddClicked()),this.element.appendChild(this._addBtn),e.appendChild(this.element);let o=t.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),s=t.on("theme:change",()=>{this._destroyed||this._repaintSlotColors()});this._libUnsub=()=>{try{o()}catch{}try{s()}catch{}},this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}refresh(){this._populateDefaults(),this._updatePreview(),this._repaintSlotColors()}getSelection(){let e=this._slots.get("sugar")?.value??"",t=this._slots.get("base")?.value??"",n=this._slots.get("linker")?.value??"",i=""!==e&&""!==t&&""!==n?eH(e,t,n):"";return{sugar:e,base:t,linker:n,preview:i}}setField(e,t){let n=this._slots.get(e);void 0!==n&&(n.value=t,this._setLabelText(n.labelEl,t),this._repaintSlot(n),this._updatePreview(),this.onValueSet.next({field:e,symbol:t}))}startPickMode(e){this._pickMode===e?this.cancelPickMode():(null!==this._pickMode&&this._setSlotPressed(this._pickMode,!1),this._pickMode=e,this._setSlotPressed(e,!0),this._setHintActive(e),this.onPickModeChange.next({field:e}),null!==this._hooks&&this._hooks.beginBiotypeFilter(eY[e],t=>{this.setField(e,t),this._exitPickMode()},()=>{this._exitPickMode()}))}cancelPickMode(){null!==this._pickMode&&(null!==this._hooks&&this._hooks.endBiotypeFilter(),this._exitPickMode())}getPickMode(){return this._pickMode}triggerAdd(){this._onAddClicked()}destroy(){this._destroyed||(this._destroyed=!0,null!==this._pickMode&&null!==this._hooks&&this._hooks.endBiotypeFilter(),this._libUnsub(),this.onValueSet.complete(),this.onPickModeChange.complete(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}_buildSvg(){let e=this._doc.createElementNS(eW,"svg");e.setAttribute("class","hw-rna-builder__triplet"),e.setAttribute("viewBox","0 0 200 180"),e.setAttribute("data-testid","rna-builder-triplet-svg"),e.setAttribute("role","group"),e.setAttribute("aria-label","Triplet preview");let t=this._doc.createElementNS(eW,"line");t.setAttribute("class","hw-rna-builder__bond"),t.setAttribute("x1",String(eX.x+18)),t.setAttribute("y1",String(eX.y)),t.setAttribute("x2",String(eZ.x-18)),t.setAttribute("y2",String(eZ.y)),e.appendChild(t);let n=this._doc.createElementNS(eW,"line");n.setAttribute("class","hw-rna-builder__bond"),n.setAttribute("x1",String(eX.x)),n.setAttribute("y1",String(eX.y+18)),n.setAttribute("x2",String(eQ.x)),n.setAttribute("y2",String(eQ.y-22)),e.appendChild(n);let i=this._doc.createElementNS(eW,"rect");i.setAttribute("class","hw-rna-builder__slot-shape"),i.setAttribute("x",String(-18)),i.setAttribute("y",String(-18)),i.setAttribute("width",String(36)),i.setAttribute("height",String(36)),i.setAttribute("rx","8"),i.setAttribute("ry","8");let r=this._buildSlot("sugar","Pick sugar (backbone)",eX,i),o=this._doc.createElementNS(eW,"circle");o.setAttribute("class","hw-rna-builder__slot-shape"),o.setAttribute("cx","0"),o.setAttribute("cy","0"),o.setAttribute("r",String(18));let s=this._buildSlot("linker","Pick linker",eZ,o),a=this._doc.createElementNS(eW,"path");a.setAttribute("class","hw-rna-builder__slot-shape"),a.setAttribute("d","M -22 0 L 0 -22 L 22 0 L 0 22 Z");let l=this._buildSlot("base","Pick base",eQ,a);return e.appendChild(s.groupEl),e.appendChild(r.groupEl),e.appendChild(l.groupEl),this._slots.set("sugar",r),this._slots.set("linker",s),this._slots.set("base",l),e}_buildSlot(e,t,n,i){let r=this._doc.createElementNS(eW,"g");r.setAttribute("class","hw-rna-builder__slot"),r.setAttribute("data-slot",e),r.setAttribute("data-testid",`rna-builder-slot-${e}`),r.setAttribute("role","button"),r.setAttribute("tabindex","0"),r.setAttribute("aria-label",t),r.setAttribute("aria-pressed","false"),r.setAttribute("transform",`translate(${n.x} ${n.y})`),r.appendChild(i);let o=this._doc.createElementNS(eW,"text");o.setAttribute("class","hw-rna-builder__slot-label"),o.setAttribute("data-testid",`rna-builder-${e}-value`),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("text-anchor","middle"),o.setAttribute("dominant-baseline","central"),r.appendChild(o);let s=t=>{t.stopPropagation(),this.startPickMode(e)};return r.addEventListener("click",s),r.addEventListener("keydown",e=>{("Enter"===e.key||" "===e.key)&&s(e)}),r.addEventListener("mouseenter",t=>this._showSlotTooltip(e,t)),r.addEventListener("mouseleave",()=>this._hideSlotTooltip()),r.addEventListener("focus",()=>this._showSlotTooltip(e,null)),r.addEventListener("blur",()=>this._hideSlotTooltip()),{id:e,biotype:eY[e],groupEl:r,shapeEl:i,labelEl:o,value:""}}_setLabelText(e,t){let n,i=[];for(let t=e.firstChild;null!==t;t=t.nextSibling)"title"===t.nodeName||"TITLE"===t.nodeName||i.push(t);for(let t of i)e.removeChild(t);let r=(n=t.length)<=2?16:n<=4?11:n<=7?8:n<=10?6:5;e.setAttribute("font-size",String(r)),e.setAttribute("text-anchor","middle"),e.setAttribute("dominant-baseline","central");let o=t.length>10?`${t.slice(0,9)}\u2026`:t;e.appendChild(this._doc.createTextNode(o));let s=e.parentNode;if(null!==s){let e=null;for(let t=s.firstChild;null!==t;t=t.nextSibling)if("title"===t.nodeName||"TITLE"===t.nodeName){e=t;break}for(null===e&&(e=this._doc.createElementNS(eW,"title"),s.insertBefore(e,s.firstChild));null!==e.firstChild;)e.removeChild(e.firstChild);e.appendChild(this._doc.createTextNode(t))}}_repaintSlotColors(){for(let e of this._slots.values())this._repaintSlot(e)}_repaintSlot(e){var t,n,i;let r=this._editor.getService().monomerLib,o=this._theme(),s=ee(""===e.value?null:(t=r,n=e.biotype,i=e.value,t.getMonomerSet(n).get(i)??null),e.biotype,o.colorTheme);e.shapeEl.style.fill=s.background,e.shapeEl.style.stroke=s.line,e.labelEl.style.fill=s.text}_populateDefaults(){let e=this._editor.getService().monomerLib;for(let[t,n]of this._slots.entries()){let i=function(e,t){let n=e.getMonomerSet(t),i=[];for(let e of n.values())i.push(e);return i.sort((e,t)=>e.symbol.localeCompare(t.symbol)),i}(e,n.biotype),r=function(e,t){let n=new Set;for(let t of e)n.add(t.symbol);for(let e of t)if(n.has(e))return e;return null}(i,eK[t]),o=""!==n.value&&i.some(e=>e.symbol===n.value)?n.value:r??i[0]?.symbol??"";n.value=o,this._setLabelText(n.labelEl,o)}}_updatePreview(){let e=this.getSelection();for(;null!==this._preview.firstChild;)this._preview.removeChild(this._preview.firstChild);this._preview.appendChild(this._doc.createTextNode(""===e.preview?"-":e.preview)),this._updateFavStar(e)}_updateFavStar(e){if(null===this._favStar||null===this._favHooks)return;let t=""!==e.preview,n=t&&this._favHooks.isFavoriteTriplet(e.sugar,e.base,e.linker);for(;null!==this._favStar.firstChild;)this._favStar.removeChild(this._favStar.firstChild);this._favStar.appendChild(this._doc.createTextNode(n?"★":"☆")),this._favStar.setAttribute("aria-pressed",n?"true":"false"),t?this._favStar.removeAttribute("aria-disabled"):this._favStar.setAttribute("aria-disabled","true"),this._favStar.setAttribute("class","hw-rna-builder__fav"+(n?" hw-rna-builder__fav--active":"")+(t?"":" hw-rna-builder__fav--disabled"))}_onAddClicked(){let e=this.getSelection();""!==e.preview&&this._editor.placeRnaTriplet(e.sugar,e.base,e.linker)}_exitPickMode(){if(null===this._pickMode)return;let e=this._pickMode;this._setSlotPressed(e,!1),this._pickMode=null,this._setHintActive(null),this.onPickModeChange.next({field:null})}_setHintActive(e){let t=this._hintEl;for(;null!==t.firstChild;)t.removeChild(t.firstChild);null===e?t.setAttribute("hidden",""):(t.removeAttribute("hidden"),t.appendChild(this._doc.createTextNode(`Pick ${"sugar"===e?"sugar":"base"===e?"base":"linker"} from palette`)))}_setSlotPressed(e,t){let n=this._slots.get(e);if(void 0===n)return;n.groupEl.setAttribute("aria-pressed",t?"true":"false");let i=(n.groupEl.getAttribute("class")??"").split(/\s+/).filter(e=>"hw-rna-builder__slot--active"!==e).join(" ");n.groupEl.setAttribute("class",t?`${i} hw-rna-builder__slot--active`:i)}_theme(){let e=this._editor;return"function"==typeof e._currentTheme?e._currentTheme():this._editor.getService().theme}_rdkit(){return this._editor.getService().options?.rdkitModule??null}_builderRdkitSvgFor(t){if(null===t)return null;let n=t.smiles;if(void 0===n||""===n)return null;let i=this._rdkit();if(null===i)return null;let r=`${t.polymerType}:${t.symbol}`;if(this._builderRdkitCache.has(r))return this._builderRdkitCache.get(r)??null;let o=eR(i,n,220,140);if(this._builderRdkitCache.size>=e._BUILDER_RDKIT_CACHE_LIMIT){let e=this._builderRdkitCache.keys().next().value;void 0!==e&&this._builderRdkitCache.delete(e)}return this._builderRdkitCache.set(r,o),o}_slotHint(e){switch(e){case"sugar":return"Click to choose a different sugar";case"base":return"Click to choose a different base";case"linker":return"Click to choose a different linker"}}_slotTitle(e,t){let n=""===t?"?":t;switch(e){case"sugar":return`Sugar: ${n}`;case"base":return`Base: ${n}`;case"linker":return`Linker: ${n}`}}_showSlotTooltip(e,t){let n=this._slots.get(e);if(void 0===n)return;let i=this._editor.getService().monomerLib.getMonomerSet(n.biotype),r=""===n.value?null:i.get(n.value)??null,o=ej(this._doc,"builder-tooltip","hw-builder-tooltip");if(eD(this._doc,o,{symbol:this._slotTitle(e,n.value),name:r?.name??"",rdkitSvg:this._builderRdkitSvgFor(r),rdkitTestid:"builder-tooltip-rdkit-svg",hint:this._slotHint(e)}),null!==t&&"number"==typeof t.clientX&&"number"==typeof t.clientY)e$(o,t.clientX,t.clientY);else{let e=n.groupEl,t="function"==typeof e.getBoundingClientRect?e.getBoundingClientRect():null;null!==t?e$(o,t.left+t.width/2,t.top+t.height/2):e$(o,0,0)}}_hideSlotTooltip(){eF(this._doc.body.querySelector('[data-testid="builder-tooltip"]'))}};eJ._BUILDER_RDKIT_CACHE_LIMIT=256;var e0="Favorites",e2={[e0]:"★ Favorites",[O.PEPTIDE]:"Peptides",[O.RNA]:"RNA",[O.CHEM]:"CHEM",[O.BLOB]:"BLOB",G:"G"},e1=[e0,O.PEPTIDE,O.RNA,O.CHEM,O.BLOB,"G"],e3="hwe:palette:favorites",e5="hwe:palette:active-tab";function e4(e){return`${e.sugar}|${e.base}|${e.linker}`}var e6=class e{constructor(e,t,n){this.favoritesChanged=new P,this._nextAddUnsub=()=>{},this._favorites=new Set,this._favoriteTriplets=[],this._pendingRnaSelection=null,this._visibleTabs=[e0],this._activeTab=e0,this._searchInput=null,this._filter="",this._destroyed=!1,this._rnaBuilder=null,this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,this._pickEscapeListener=null,this._pickOutsideClickListener=null,this._paletteRdkitCache=new Map,this._editor=t,this._doc=n?.documentImpl??eM(e),this._opts={documentImpl:this._doc,groupByNaturalAnalog:n?.groupByNaturalAnalog??!0,allowFavorites:n?.allowFavorites??!0},this._loadFavorites(),this._activeTab=this._resolveInitialTab(n?.initialTab),this.element=eL(this._doc,"div",{class:"hw-palette","data-testid":"palette"}),e.appendChild(this.element),this._render(),this._libUnsub=t.getService().monomerLib.onChanged.subscribe(()=>{this._destroyed||this.refresh()}),this._themeUnsub=t.on("theme:change",()=>{this._destroyed||this.refresh()}),this._nextAddUnsub=t.on("option:change",e=>{this._destroyed||"nextAdd"===e.key&&this._updatePrimedClasses()})}refresh(){this._render()}setFilter(e){this._filter=e.trim().toLowerCase(),null!==this._searchInput&&this._searchInput.value!==e&&(this._searchInput.value=e),this._applyFilter()}setActiveTab(e){this._visibleTabs.includes(e)&&(this._activeTab=e,this._persistActiveTab(),this._applyActiveTabClasses(),this._applyFilter())}getActiveTab(){return this._activeTab}getFavorites(){let e=this._editor.getService().monomerLib,t=[];for(let n of this._favorites)null!==this._findMonomer(e,n)&&t.push(n);return t}setFavorite(e,t){t!==this._favorites.has(e)&&(t?this._favorites.add(e):this._favorites.delete(e),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}clearFavorites(){0===this._favorites.size&&0===this._favoriteTriplets.length||(this._favorites.clear(),this._favoriteTriplets.length=0,this._saveFavorites(),this._render(),this._emitFavoritesChanged())}getFavoriteTriplets(){return this._favoriteTriplets.map(e=>({...e}))}isFavoriteTriplet(e,t,n){let i=e4({sugar:e,base:t,linker:n});return this._favoriteTriplets.some(e=>e4(e)===i)}setFavoriteTriplet(e,t,n,i){let r=e4({sugar:e,base:t,linker:n}),o=this._favoriteTriplets.findIndex(e=>e4(e)===r);i!==o>=0&&(i?this._favoriteTriplets.push({sugar:e,base:t,linker:n}):this._favoriteTriplets.splice(o,1),this._saveFavorites(),this._hidePaletteTooltips(),this._render(),this._emitFavoritesChanged())}_hidePaletteTooltips(){let e=this._doc.body;eF(e.querySelector('[data-testid="palette-tooltip"]')),eF(e.querySelector('[data-testid="palette-triplet-tooltip"]'))}_emitFavoritesChanged(){this.favoritesChanged.next({favorites:this.getFavorites(),triplets:this.getFavoriteTriplets()})}destroy(){this._destroyed||(this._destroyed=!0,null!==this._rnaBuilder&&(this._rnaBuilder.destroy(),this._rnaBuilder=null),this._libUnsub(),this._themeUnsub(),this._nextAddUnsub(),null!==this.element.parentNode&&this.element.parentNode.removeChild(this.element))}getRnaBuilder(){return this._rnaBuilder}hasActiveBiotypeFilter(){return null!==this._activeBiotypeFilter}getActiveBiotypeFilter(){return this._activeBiotypeFilter}cancelBiotypeFilter(){if(null===this._activeBiotypeFilter)return;let e=this._pickCanceller;this._teardownPickMode(),e?.()}_buildPaletteFilterHooks(){return{beginBiotypeFilter:(e,t,n)=>{null!==this._activeBiotypeFilter&&this._teardownPickMode(),this._activeBiotypeFilter=e,this._pickResolver=t,this._pickCanceller=n,this._applyFilter();let i=e=>{"Escape"===e.key&&this.cancelBiotypeFilter()};this._pickEscapeListener=i,this._doc.defaultView?.addEventListener("keydown",i);let r=e=>{if(null===this._activeBiotypeFilter)return;let t=e.target;if(null==t)return;let n=this._activeBiotypeFilter,i=t;for(;null!==i;){let e=void 0===i.getAttribute?null:i.getAttribute("class");if(null!==e){let t=e.split(/\s+/);if(t.includes("hw-palette__tile")){if((i.getAttribute("data-biotype")??"")===n)return;break}if(t.includes("hw-rna-builder__slot")){if(this._isInsideOwnPalette(i))return;break}}i=i.parentElement}this.cancelBiotypeFilter()};this._pickOutsideClickListener=r,this._doc.addEventListener("mousedown",r,!0)},endBiotypeFilter:()=>this._teardownPickMode()}}_scrollActivePaneToTop(){let e=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`);if(null!==e){try{if("function"==typeof e.scrollTo)return void e.scrollTo({top:0,behavior:"smooth"})}catch{}"number"==typeof e.scrollTop&&(e.scrollTop=0)}}_isInsideOwnPalette(e){let t=e;for(;null!==t;){if(t===this.element)return!0;t=t.parentElement}return!1}_teardownPickMode(){null!==this._activeBiotypeFilter&&(this._activeBiotypeFilter=null,this._pickResolver=null,this._pickCanceller=null,null!==this._pickEscapeListener&&(this._doc.defaultView?.removeEventListener("keydown",this._pickEscapeListener),this._pickEscapeListener=null),null!==this._pickOutsideClickListener&&(this._doc.removeEventListener("mousedown",this._pickOutsideClickListener,!0),this._pickOutsideClickListener=null),this._applyFilter())}_render(){for(null!==this._rnaBuilder&&(this._pendingRnaSelection=this._rnaBuilder.getSelection(),this._rnaBuilder.destroy(),this._rnaBuilder=null);null!==this.element.firstChild;)this.element.removeChild(this.element.firstChild);let e=this._doc.createElement("input");e.setAttribute("type","search"),e.setAttribute("class","hw-palette__search"),e.setAttribute("placeholder","Search monomers..."),e.setAttribute("data-testid","palette-search"),""!==this._filter&&(e.value=this._filter),e.addEventListener("input",()=>this.setFilter(e.value)),this._searchInput=e,this.element.appendChild(e),this._visibleTabs=this._computeVisibleTabs(),this._visibleTabs.includes(this._activeTab)||(this._activeTab=e0);let t=eL(this._doc,"div",{class:"hw-palette__tabs",role:"tablist","data-testid":"palette-tabs"});for(let e of this._visibleTabs){let n=e===this._activeTab,i=eL(this._doc,"button",{class:"hw-palette__tab",type:"button",role:"tab","aria-controls":`hw-palette-pane-${e}`,"aria-selected":n?"true":"false","data-testid":`palette-tab-${e}`,"data-tab":e,title:e2[e]},[e2[e]]);i.addEventListener("click",()=>this.setActiveTab(e)),t.appendChild(i)}this.element.appendChild(t);let n=eL(this._doc,"div",{class:"hw-palette__panes"}),i=this._theme(),r=this._editor.getService().monomerLib;for(let e of this._visibleTabs){let t=e===this._activeTab,o=eL(this._doc,"div",{class:"hw-palette__pane",id:`hw-palette-pane-${e}`,role:"tabpanel","data-testid":`palette-pane-${e}`,"data-tab":e,hidden:!t});e===e0?this._buildFavoritesPane(o,r,i):this._buildPolymerPane(o,e,r,i),n.appendChild(o)}this.element.appendChild(n),this._applyFilter()}_computeVisibleTabs(){let e=this._editor.getService().monomerLib,t=new Set;for(let n of e.getPolymerTypes())t.add(n);let n=[];for(let e of(n.push(e0),e1))e!==e0&&t.has(e)&&n.push(e);return n}_buildFavoritesPane(e,t,n){let i=this._resolveFavoriteMonomers(t),r=this._favoriteTriplets;if(0===i.length&&0===r.length){let t=eL(this._doc,"div",{class:"hw-palette__placeholder","data-testid":"palette-favorites-empty"},["No favorites yet — click the ☆ on any tile to add one."]);e.appendChild(t);return}for(let[t,n]of this._groupByPolymerAndType(i))e.appendChild(this._renderGroup(t,n));r.length>0&&e.appendChild(this._renderTripletGroup("RNA \xb7 Triplets",r,t))}_groupByPolymerAndType(e){let t=new Map;for(let n of e){let e=n.polymerType,i=n.monomerType??"Undefined",r=`${e}|${i}`,o=t.get(r);void 0===o&&(o={pt:e,mt:i,list:[]},t.set(r,o)),o.list.push(n)}let n=e=>{let t=e1.indexOf(e);return t<0?99:t},i={Backbone:0,Branch:1,Terminal:2,Undefined:3};return Array.from(t.values()).sort((e,t)=>n(e.pt)-n(t.pt)||(i[e.mt]??9)-(i[t.mt]??9)||e.mt.localeCompare(t.mt)).map(e=>[`${this._polymerLabel(e.pt)} \xb7 ${e.mt}`,e.list])}_polymerLabel(e){return e2[e]??e}_renderTripletGroup(e,t,n){let i=eL(this._doc,"div",{class:"hw-palette__group","data-natural-analog":e}),r=eL(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${e}`},[e]),o=eL(this._doc,"div",{class:"hw-triplet-chips","data-testid":"palette-triplet-favorites"});for(let e of t)o.appendChild(this._renderTripletChip(e,n));return i.appendChild(r),i.appendChild(o),i}_renderTripletChip(e,t){var n,i;let r,o,s,a,l=eH(e.sugar,e.base,e.linker),u=t.getMonomerSet(A.BASE).get(e.base)??null,d=ee(u,A.BASE,this._theme().colorTheme),c=this.isFavoriteTriplet(e.sugar,e.base,e.linker),h=u?.name!==void 0&&""!==u.name?`${l} \u2014 ${u.name}`:l,{root:p}=(n=this._doc,r=!1!==(i={sugar:e.sugar,base:e.base,linker:e.linker,label:l,title:h,background:F(d.background),textColor:d.text,favorite:c,showStar:this._opts.allowFavorites}).showStar,o=eL(n,"span",{class:"hw-triplet-chip__star"},[i.favorite?"★":"☆"]),s=eL(n,"span",{class:"hw-triplet-chip__label"},[i.label]),a=["hw-triplet-chip"],i.favorite&&a.push("hw-triplet-chip--favorite"),{root:eL(n,"div",{class:a.join(" "),role:"button",tabindex:"0","aria-label":i.title,"data-sugar":i.sugar,"data-base":i.base,"data-linker":i.linker,"data-triplet":i.label,"data-testid":`palette-triplet-${i.label}`,title:i.title,style:`background:${i.background};color:${i.textColor};`},r?[o,s]:[s]),star:o});return this._wireTripletChip(p,e),p}_wireTripletChip(e,t){e.addEventListener("mouseenter",e=>{let n=ej(this._doc,"palette-triplet-tooltip","hw-palette-tooltip hw-triplet-tooltip");(function(e,t,n){for(;null!==t.firstChild;)t.removeChild(t.firstChild);t.appendChild(eL(e,"div",{class:"hw-tooltip__symbol"},[n.title]));let i=eL(e,"div",{class:"hw-tooltip__triplet"});for(let t of n.parts){let r=eL(e,"div",{class:"hw-tooltip__triplet-part"});if(r.appendChild(eL(e,"div",{class:"hw-tooltip__triplet-role"},[`${t.role}: ${t.symbol}`])),void 0!==t.name&&""!==t.name&&t.name!==t.symbol&&r.appendChild(eL(e,"div",{class:"hw-tooltip__name"},[t.name])),void 0!==t.rdkitSvg&&null!==t.rdkitSvg&&""!==t.rdkitSvg){let i={class:"hw-tooltip__rdkit"};void 0!==n.rdkitTestid&&(i["data-testid"]=n.rdkitTestid);let o=eL(e,"div",i);o.innerHTML=t.rdkitSvg,r.appendChild(o)}i.appendChild(r)}t.appendChild(i),void 0!==n.hint&&""!==n.hint&&t.appendChild(eL(e,"div",{class:"hw-tooltip__hint"},[n.hint]))})(this._doc,n,{title:eH(t.sugar,t.base,t.linker),parts:this._tripletTooltipParts(t),hint:"Click to add this triplet",rdkitTestid:"palette-triplet-tooltip-rdkit-svg"}),e$(n,"number"==typeof e.clientX?e.clientX:0,"number"==typeof e.clientY?e.clientY:0)}),e.addEventListener("mouseleave",()=>{eF(this._doc.body.querySelector('[data-testid="palette-triplet-tooltip"]'))}),e.addEventListener("click",e=>{let n=e.target;if(this._opts.allowFavorites&&n?.classList?.contains("hw-triplet-chip__star")===!0){this.setFavoriteTriplet(t.sugar,t.base,t.linker,!this.isFavoriteTriplet(t.sugar,t.base,t.linker)),e.stopPropagation();return}this._editor.placeRnaTriplet(t.sugar,t.base,t.linker)}),e.addEventListener("keydown",e=>{("Enter"===e.key||" "===e.key)&&this._editor.placeRnaTriplet(t.sugar,t.base,t.linker)})}_buildRnaDefaultChips(t){let n=this._pickSymbol(t.getMonomerSet(A.SUGAR),["r","R"]),i=this._pickSymbol(t.getMonomerSet(A.LINKER),["p","P"]),r=t.getMonomerSet(A.BASE);if(null===n||null===i)return null;let o=e._DEFAULT_TRIPLET_BASES.filter(e=>r.has(e));if(0===o.length)return null;let s=eL(this._doc,"div",{class:"hw-triplet-chips hw-triplet-chips--defaults","data-testid":"rna-default-triplets"});for(let e of o)s.appendChild(this._renderTripletChip({sugar:n,base:e,linker:i},t));return s}_tripletTooltipParts(e){let t=this._editor.getService().monomerLib,n=(e,n,i)=>{let r=t.getMonomerSet(n).get(i)??null;return{role:e,symbol:i,...r?.name!==void 0?{name:r.name}:{},rdkitSvg:null===r?null:this._paletteRdkitSvg(r)}};return[n("Sugar",A.SUGAR,e.sugar),n("Base",A.BASE,e.base),n("Linker",A.LINKER,e.linker)]}_pickSymbol(e,t){for(let n of t)if(e.has(n))return n;let n=e.keys().next();return!0===n.done?null:n.value}_restoreRnaSelection(){let e=this._pendingRnaSelection;if(this._pendingRnaSelection=null,null===e||null===this._rnaBuilder)return;let t=this._editor.getService().monomerLib;""!==e.sugar&&t.getMonomerSet(A.SUGAR).has(e.sugar)&&this._rnaBuilder.setField("sugar",e.sugar),""!==e.base&&t.getMonomerSet(A.BASE).has(e.base)&&this._rnaBuilder.setField("base",e.base),""!==e.linker&&t.getMonomerSet(A.LINKER).has(e.linker)&&this._rnaBuilder.setField("linker",e.linker)}_resolveFavoriteMonomers(e){let t=[];for(let n of this._favorites){let i=this._findMonomer(e,n);null!==i&&t.push(i)}return t}_findMonomer(e,t){for(let n of e.getPolymerTypes()){let i=e.getMonomer(n,t);if(null!==i)return i}return null}_buildPolymerPane(e,t,n,i){let r=this._monomersForPolymer(t,n);if(0===r.length)return;if(t===O.RNA){this._rnaBuilder=new eJ(e,this._editor,{documentImpl:this._doc,paletteHooks:this._buildPaletteFilterHooks(),favoriteHooks:this._opts.allowFavorites?{isFavoriteTriplet:(e,t,n)=>this.isFavoriteTriplet(e,t,n),toggleFavoriteTriplet:(e,t,n)=>this.setFavoriteTriplet(e,t,n,!this.isFavoriteTriplet(e,t,n))}:null}),this._restoreRnaSelection();let t=this._buildRnaDefaultChips(n);for(let[n,i]of(null!==t&&e.appendChild(t),this._groupRna(r)))0!==i.length&&e.appendChild(this._renderGroup(n,i));return}if(t===O.PEPTIDE&&this._opts.groupByNaturalAnalog){for(let[t,n]of this._groupByAnalog(r)){let i=""===t?"Other":t;e.appendChild(this._renderGroup(i,n))}return}let o=eL(this._doc,"div",{class:"hw-palette__group-tiles"}),s=this._editor.getNextAddSymbol();for(let e of this._sortByColor(r)){let n=this._biotype(e,t);o.appendChild(this._renderTile(e,n,s))}e.appendChild(o)}_renderGroup(e,t){let n=eL(this._doc,"div",{class:"hw-palette__group","data-natural-analog":e}),i=eL(this._doc,"div",{class:"hw-palette__group-header","data-testid":`palette-group-${e}`},[e]),r=eL(this._doc,"div",{class:"hw-palette__group-tiles"}),o=this._editor.getNextAddSymbol();for(let e of this._sortByColor(t)){let t=this._biotype(e,e.polymerType);r.appendChild(this._renderTile(e,t,o))}return n.appendChild(i),n.appendChild(r),n}_sortByColor(e){let t=this._theme(),n=e.map((e,n)=>{let i=this._biotype(e,e.polymerType),r=function(e){let t=I(e);if(null===t)return{h:0,s:0,l:0};let[n,i,r]=R(t[0],t[1],t[2]);return{h:n,s:i,l:r}}(ee(e,i,t.colorTheme).background),o=+(0===r.s);return{m:e,idx:n,h:r.h,s:r.s,l:r.l,isGrey:o}});return n.sort((e,t)=>e.isGrey!==t.isGrey?e.isGrey-t.isGrey:e.h!==t.h?e.h-t.h:e.s!==t.s?e.s-t.s:e.l!==t.l?e.l-t.l:e.idx-t.idx),n.map(e=>e.m)}_monomersForPolymer(e,t){let n=t.getMonomerSymbolsByType(e),i=[];for(let r of n){let n=t.getMonomer(e,r);null!==n&&i.push(n)}return i.sort((e,t)=>e.symbol.localeCompare(t.symbol)),i}_groupByAnalog(e){let t=new Map;for(let n of e){let e=n.naturalAnalog??"",i=t.get(e);void 0===i&&(i=[],t.set(e,i)),i.push(n)}let n=[];for(let e of Array.from(t.keys()).sort((e,t)=>""===e&&""!==t?1:""===t&&""!==e?-1:e.localeCompare(t)))n.push([e,t.get(e)]);return new Map(n)}_groupRna(e){let t=[],n=[],i=[],r=[];for(let o of e){let e=et(o);e===A.SUGAR?t.push(o):e===A.BASE?n.push(o):e===A.LINKER?i.push(o):r.push(o)}let o=new Map;return o.set("Backbones",t),o.set("Bases",n),o.set("Linkers",i),r.length>0&&o.set("Other",r),o}_renderTile(e,t,n){var i,r,o,s;let a,l,u,d,c,h,p,f,m,g,v,b,y,_,w,x=this._favorites.has(e.symbol),k=null!==n&&n.symbol===e.symbol&&n.biotype===t,{root:S,star:C}=(i=this._doc,d=F((u=ee((r={monomer:e,biotype:t,theme:this._theme(),favorite:x,primed:k}).monomer,r.biotype,r.theme.colorTheme)).background),o=c=u.text,h=(Math.max(a=z(o),l=z(d))+.05)/(Math.min(a,l)+.05)<5,f=(s=(p=r.monomer.symbol).length)<=3?14:s<=6?11:s<=9?9:8,m=p.length>=10?"line-height:1.1;letter-spacing:-0.02em;":"",g=`font-size:${f}px;${m}white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:80px;display:inline-block;`,v=eL(i,"span",{class:"hw-palette__star"},[r.favorite?"★":"☆"]),b=eL(i,"span",{class:"hw-palette__label",style:g},[p]),y=["hw-palette__tile"],r.primed&&y.push("hw-palette__tile--primed"),r.favorite&&y.push("hw-palette__tile--favorite"),h&&y.push("hw-palette__tile--low-contrast"),_=void 0!==r.monomer.name?`${p} \u2014 ${r.monomer.name}`:p,w=`background:${d};color:${c};width:100%;min-width:48px;padding:4px 6px;height:40px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;`,{root:eL(i,"div",{class:y.join(" "),draggable:"true",role:"button","aria-pressed":r.primed?"true":"false","aria-label":_,"data-symbol":p,"data-biotype":r.biotype,"data-bg":d,"data-raw-bg":u.background,"data-testid":`palette-tile-${p}`,title:_,style:w},[v,b]),star:v});return this._wireTile(S,C,e,t),S}_rdkit(){return this._editor.getService().options?.rdkitModule??null}_paletteRdkitSvg(t){let n=t.smiles;if(void 0===n||""===n)return null;let i=this._rdkit();if(null===i)return null;let r=`${t.polymerType}:${t.symbol}`;if(this._paletteRdkitCache.has(r))return this._paletteRdkitCache.get(r)??null;let o=eR(i,n,220,140);if(this._paletteRdkitCache.size>=e._PALETTE_RDKIT_CACHE_LIMIT){let e=this._paletteRdkitCache.keys().next().value;void 0!==e&&this._paletteRdkitCache.delete(e)}return this._paletteRdkitCache.set(r,o),o}_wireTile(e,t,n,i){e.addEventListener("mouseenter",e=>{let t=ej(this._doc,"palette-tooltip","hw-palette-tooltip");eD(this._doc,t,{symbol:n.symbol,name:n.name??"",rdkitSvg:this._paletteRdkitSvg(n),rdkitTestid:"palette-tooltip-rdkit-svg"}),e$(t,"number"==typeof e.clientX?e.clientX:0,"number"==typeof e.clientY?e.clientY:0)}),e.addEventListener("mouseleave",()=>{eF(this._doc.body.querySelector('[data-testid="palette-tooltip"]'))}),e.addEventListener("click",e=>{let t=e.target;if(this._opts.allowFavorites&&void 0!==t&&t?.classList?.contains("hw-palette__star")===!0){this.setFavorite(n.symbol,!this._favorites.has(n.symbol)),e.stopPropagation();return}if(null!==this._activeBiotypeFilter&&this._activeBiotypeFilter===i){let t=this._pickResolver;this._teardownPickMode(),t?.(n.symbol),this._scrollActivePaneToTop(),e.stopPropagation();return}let r=this._editor.getSelection();if(r.atoms.size>0){let t=this._editor.getMol(),o=[];for(let e of r.atoms){let n=t.atoms.find(t=>t.id===e);void 0!==n&&o.push(n)}if(o.length>0&&o.every(e=>e.biotype===i)){this._editor.replaceMonomers(o,n.symbol),e.stopPropagation();return}this._editor.fire("editor:status",{message:`Cannot bulk-replace ${o.length} selected atom(s) with ${n.symbol}: selection contains incompatible biotypes for ${i}.`,severity:"warn",durationMs:3e3}),e.stopPropagation();return}let o=this._editor.getNextAddSymbol();if(null!==o&&o.symbol===n.symbol&&o.biotype===i){this._editor.setNextAddSymbol(null),this._updatePrimedClasses();return}this._editor.setNextAddSymbol(n.symbol,i),this._updatePrimedClasses()}),e.addEventListener("dragstart",e=>{let t=e.dataTransfer;if(null!=t)try{t.setData("application/x-hwe-monomer",JSON.stringify({symbol:n.symbol,biotype:i})),t.effectAllowed="copy"}catch{}eF(this._doc.body.querySelector('[data-testid="palette-tooltip"]')),this._editor.startPaletteDrag(n.symbol,i)})}_biotype(e,t){let n=et(e);if(null!==n)return n;switch(t){case O.PEPTIDE:return A.AA;case O.RNA:return A.SUGAR;case O.CHEM:return A.CHEM;case O.BLOB:return A.BLOB;default:return A.CHEM}}_theme(){let e=this._editor;return"function"==typeof e._currentTheme?e._currentTheme():this._editor.getService().theme}_applyFilter(){let e=this._filter,t=this._activeBiotypeFilter,n=this.element.querySelector(`.hw-palette__pane[data-tab="${this._activeTab}"]`),i=(n??this.element).querySelectorAll(".hw-palette__tile");for(let n=0;n<i.length;n++){let r=i[n],o=(r.getAttribute("data-symbol")??"").toLowerCase(),s=(r.getAttribute("title")??"").toLowerCase(),a=r.getAttribute("data-biotype")??"",l=(""===e||o.indexOf(e)>=0||s.indexOf(e)>=0)&&(null===t||a===t);r.style.display=l?"":"none"}let r=(n??this.element).querySelectorAll(".hw-triplet-chip");for(let n=0;n<r.length;n++){let i=r[n],o=[i.getAttribute("data-triplet")??"",i.getAttribute("data-sugar")??"",i.getAttribute("data-base")??"",i.getAttribute("data-linker")??""].join(" ").toLowerCase(),s=(""===e||o.indexOf(e)>=0)&&null===t;i.style.display=s?"":"none"}let o=(n??this.element).querySelectorAll(".hw-palette__group");for(let e=0;e<o.length;e++){let t=o[e],n=t.querySelectorAll(".hw-palette__tile, .hw-triplet-chip"),i=!1;for(let e=0;e<n.length;e++)if("none"!==n[e].style.display){i=!0;break}i?(t.removeAttribute("hidden"),t.removeAttribute("data-section-empty")):(t.setAttribute("hidden",""),t.setAttribute("data-section-empty","true"))}}_updatePrimedClasses(){let e=this._editor.getNextAddSymbol(),t=this.element.querySelectorAll(".hw-palette__tile");for(let n=0;n<t.length;n++){let i=t[n],r=i.getAttribute("data-symbol")??"",o=i.getAttribute("data-biotype")??"",s=null!==e&&e.symbol===r&&e.biotype===o,a=(i.getAttribute("class")??"").split(/\s+/).filter(e=>"hw-palette__tile--primed"!==e).join(" ");i.setAttribute("class",s?`${a} hw-palette__tile--primed`:a),i.setAttribute("aria-pressed",s?"true":"false")}}_applyActiveTabClasses(){let e=this.element.querySelectorAll(".hw-palette__tab");for(let t=0;t<e.length;t++){let n=e[t],i=n.getAttribute("data-tab")??"";n.setAttribute("aria-selected",i===this._activeTab?"true":"false")}let t=this.element.querySelectorAll(".hw-palette__pane");for(let e=0;e<t.length;e++){let n=t[e];(n.getAttribute("data-tab")??"")===this._activeTab?n.removeAttribute("hidden"):n.setAttribute("hidden","")}}_localStorage(){if(!this._opts.allowFavorites)return null;let e=this._doc.defaultView;if(null==e)return null;try{return e.localStorage??null}catch{return null}}_resolveInitialTab(e){if(void 0!==e&&e1.includes(e))return e;let t=this._localStorage();if(null!==t)try{let e=t.getItem(e5);if(null!==e&&e1.includes(e))return e}catch{}return e0}_persistActiveTab(){let e=this._localStorage();if(null!==e)try{e.setItem(e5,this._activeTab)}catch{}}_loadFavorites(){let e=this._localStorage();if(null!==e){try{let t=e.getItem(e3);if(null!==t&&""!==t){let e=JSON.parse(t);for(let t of this._extractSymbols(e))this._favorites.add(t);for(let t of this._extractTriplets(e))this._favoriteTriplets.push(t);return}}catch{}try{let t=e.getItem("hwe.palette.favorites");if(null===t||""===t)return;let n=JSON.parse(t);if(Array.isArray(n)){for(let e of n){if("string"!=typeof e)continue;let t=e.indexOf("|"),n=t>=0?e.slice(t+1):e;""!==n&&this._favorites.add(n)}this._saveFavorites()}}catch{}}}_extractSymbols(e){if(Array.isArray(e)){let t=[];for(let n of e)"string"==typeof n&&t.push(n);return t}if(null!==e&&"object"==typeof e&&Array.isArray(e.symbols)){let t=[];for(let n of e.symbols)"string"==typeof n&&t.push(n);return t}return[]}_extractTriplets(e){if(null===e||"object"!=typeof e||!Array.isArray(e.triplets))return[];let t=[];for(let n of e.triplets)null!==n&&"object"==typeof n&&"string"==typeof n.sugar&&"string"==typeof n.base&&"string"==typeof n.linker&&t.push({sugar:n.sugar,base:n.base,linker:n.linker});return t}_saveFavorites(){let e=this._localStorage();if(null!==e)try{let t={symbols:Array.from(this._favorites)};this._favoriteTriplets.length>0&&(t.triplets=this._favoriteTriplets.map(e=>({...e}))),e.setItem(e3,JSON.stringify(t))}catch{}}};e6._DEFAULT_TRIPLET_BASES=["A","C","G","U","T"],e6._PALETTE_RDKIT_CACHE_LIMIT=256;var e8='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">',e9={new:`${e8}<path d="M13 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9z"/><path d="M13 3v6h6"/><line x1="12" y1="12.5" x2="12" y2="17.5"/><line x1="9.5" y1="15" x2="14.5" y2="15"/></svg>`,open:`${e8}<path d="m6 14 1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2"/></svg>`,save:`${e8}<rect x="8" y="2" width="8" height="4" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/><path d="m9 14 2 2 4-4"/></svg>`,undo:`${e8}<path d="M3 12a9 9 0 1 0 9-9 9.7 9.7 0 0 0-6.7 2.8L3 8"/><path d="M3 3v5h5"/></svg>`,redo:`${e8}<path d="M21 12a9 9 0 1 1-9-9 9.7 9.7 0 0 1 6.7 2.8L21 8"/><path d="M21 3v5h-5"/></svg>`,eraser:`${e8}<path d="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg>`,select:`${e8}<path d="m4 4 7.07 17 2.51-7.39L21 11.07z"/></svg>`,hbond:`${e8}<path d="M9 17H7A5 5 0 0 1 7 7h2"/><path d="M15 7h2a5 5 0 1 1 0 10h-2"/><line x1="8" y1="12" x2="16" y2="12"/></svg>`,"zoom-in":`${e8}<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="11" y1="8" x2="11" y2="14"/><line x1="8" y1="11" x2="14" y2="11"/></svg>`,"zoom-out":`${e8}<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/><line x1="8" y1="11" x2="14" y2="11"/></svg>`,fit:`${e8}<polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>`,move:`${e8}<polyline points="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" y1="12" x2="22" y2="12"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,clean:`${e8}<path d="m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72Z"/><path d="m14 7 3 3"/><path d="M5 6v4"/><path d="M19 14v4"/><path d="M10 2v2"/><path d="M7 8H3"/><path d="M21 16h-4"/><path d="M11 3H9"/></svg>`,find:`${e8}<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>`,theme:`${e8}<circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 1 0 18z" fill="currentColor" stroke="none"/></svg>`},e7=[{id:"new",label:"New",icon:"New"},{id:"open",label:"Open",icon:"Open"},{id:"save",label:"Save",icon:"Save"},{id:"undo",label:"Undo",icon:"↺",shortcut:"Ctrl+Z",separator:!0},{id:"redo",label:"Redo",icon:"↻",shortcut:"Ctrl+Y"},{id:"eraser",label:"Eraser",icon:"Eraser",separator:!0},{id:"select",label:"Select",icon:"Select"},{id:"hbond",label:"H-Bond",icon:"H-Bond"},{id:"zoom-in",label:"Zoom In",icon:"+",shortcut:"Ctrl++",separator:!0},{id:"zoom-out",label:"Zoom Out",icon:"−",shortcut:"Ctrl+−"},{id:"fit",label:"Fit",icon:"Fit",shortcut:"0"},{id:"move",label:"Move",icon:"Move"},{id:"clean",label:"Clean",icon:"Clean",separator:!0},{id:"find",label:"Find",icon:"Find",shortcut:"Ctrl+F"},{id:"theme",label:"Theme",icon:"Theme",separator:!0}];O.PEPTIDE,O.RNA,O.CHEM,O.BLOB}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.m=e,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),n.u=e=>""+e+".js",n.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nc=void 0,n.g.importScripts&&(i=n.g.location+"");var i,r=n.g.document;if(!i&&r&&(r.currentScript&&"SCRIPT"===r.currentScript.tagName.toUpperCase()&&(i=r.currentScript.src),!i)){var o=r.getElementsByTagName("script");if(o.length)for(var s=o.length-1;s>-1&&(!i||!/^http(s?):/.test(i));)i=o[s--].src}if(!i)throw Error("Automatic publicPath is not supported in this browser");n.p=i=i.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.b=document.baseURI||self.location.href,peptides=n(4332)})();
|
|
2
362
|
//# sourceMappingURL=package.js.map
|