@sjcrh/proteinpaint-client 2.76.2 → 2.77.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2dmaf-f240211f.js → 2dmaf-dbeff225.js} +1 -1
- package/dist/{AppHeader-c9432a24.js → AppHeader-1fc7f7bd.js} +1 -1
- package/dist/{ColorScale-b991fc9e.js → ColorScale-23c17654.js} +1 -1
- package/dist/{DEanalysis-bbfad00d.js → DEanalysis-a3cf1900.js} +1 -1
- package/dist/{Disco-b7c9bf72.js → Disco-b26a0556.js} +1 -1
- package/dist/{Disco.UI-a5296c36.js → Disco.UI-891c4c35.js} +1 -1
- package/dist/{DragControls-ca3fa0cf.js → DragControls-2fabac26.js} +1 -1
- package/dist/{DziViewer-28915c11.js → DziViewer-5b830c31.js} +1 -1
- package/dist/FilterRxComp-fb608459.js +1 -0
- package/dist/FilterStateless-fc4e4e1b.js +1 -0
- package/dist/{HicApp-e713aa40.js → HicApp-5ed85d49.js} +1 -1
- package/dist/{OrbitControls-2466d420.js → OrbitControls-604f40af.js} +1 -1
- package/dist/{WSIViewer-957695a8.js → WSIViewer-dcce2a10.js} +1 -1
- package/dist/{adSandbox-27d93bc0.js → adSandbox-5fa90964.js} +1 -1
- package/dist/app-0de0ae35.js +1 -0
- package/dist/{app-d215327f.js → app-7f695ce7.js} +1 -1
- package/dist/app-977b083f.js +1 -0
- package/dist/app.js +1 -1
- package/dist/{bam-d67e5315.js → bam-06a5a6a2.js} +1 -1
- package/dist/{barchart-2898d229.js → barchart-978fb21a.js} +1 -1
- package/dist/{barchart.events-426d737a.js → barchart.events-9b482604.js} +1 -1
- package/dist/{bars.renderer-71935d34.js → bars.renderer-d7461d5d.js} +1 -1
- package/dist/{block-75d4ff92.js → block-3db9c74c.js} +1 -1
- package/dist/block.lazyload-19a55cac.js +1 -0
- package/dist/{block.legend-93d85a6e.js → block.legend-97401467.js} +1 -1
- package/dist/{block.mds-84b9d1c1.js → block.mds-dc409568.js} +1 -1
- package/dist/{block.mds.cnv-a991ed79.js → block.mds.cnv-cdabd3f6.js} +1 -1
- package/dist/{block.mds.expressionrank-33b858de.js → block.mds.expressionrank-d768640f.js} +1 -1
- package/dist/{block.mds.expressionstat-3093599f.js → block.mds.expressionstat-7e40426f.js} +1 -1
- package/dist/{block.mds.geneboxplot-b8391d18.js → block.mds.geneboxplot-dae9cfa3.js} +1 -1
- package/dist/{block.mds.junction-69708c7f.js → block.mds.junction-3bc8baea.js} +1 -1
- package/dist/{block.mds.svcnv-322baea6.js → block.mds.svcnv-456dc845.js} +1 -1
- package/dist/{block.mds.svcnv.share-c5c38237.js → block.mds.svcnv.share-4776459b.js} +1 -1
- package/dist/{block.mds2-de4811dd.js → block.mds2-cc586d9d.js} +1 -1
- package/dist/{block.svg-ac9fec2d.js → block.svg-adf47e3a.js} +1 -1
- package/dist/{block.tk.aicheck-ac4b8d4d.js → block.tk.aicheck-f284f080.js} +1 -1
- package/dist/{block.tk.ase-6dc0f9f1.js → block.tk.ase-0477c9f4.js} +1 -1
- package/dist/{block.tk.bam-8f68b41d.js → block.tk.bam-d4c998d4.js} +1 -1
- package/dist/{block.tk.bedgraphdot-d8878860.js → block.tk.bedgraphdot-0177d836.js} +1 -1
- package/dist/{block.tk.bigwig.ui-f6ed051c.js → block.tk.bigwig.ui-95531269.js} +1 -1
- package/dist/{block.tk.hicstraw-725bdc8a.js → block.tk.hicstraw-06e97317.js} +1 -1
- package/dist/{block.tk.junction-f8b0b51d.js → block.tk.junction-18b6b825.js} +1 -1
- package/dist/{block.tk.junction.textmatrixui-252e7d7e.js → block.tk.junction.textmatrixui-ffdbdf81.js} +1 -1
- package/dist/{block.tk.ld-11acf730.js → block.tk.ld-2b56500f.js} +1 -1
- package/dist/{block.tk.menu-5e04436d.js → block.tk.menu-707a4226.js} +1 -1
- package/dist/{block.tk.pgv-fef17dc4.js → block.tk.pgv-63c956c4.js} +1 -1
- package/dist/{boxplot-4c9a5479.js → boxplot-1f229616.js} +1 -1
- package/dist/{brainImaging-7716bc66.js → brainImaging-a0c72fad.js} +1 -1
- package/dist/{brush-9faa7ae7.js → brush-4c775f74.js} +1 -1
- package/dist/{categorical-1dea48ba.js → categorical-25b06bc5.js} +1 -1
- package/dist/{condition-ebac4f75.js → condition-70084a85.js} +1 -1
- package/dist/{controls-268e40e6.js → controls-1f3ac9d0.js} +1 -1
- package/dist/controls.btns-5b44e5d0.js +1 -0
- package/dist/{controls.config-2f0fa061.js → controls.config-b0339f96.js} +1 -1
- package/dist/{cuminc-8dffb765.js → cuminc-6d1de932.js} +1 -1
- package/dist/{customdata.inputui-b229d3a0.js → customdata.inputui-5ad0f25c.js} +1 -1
- package/dist/{dataDownload-452ae3cd.js → dataDownload-a60d80e4.js} +1 -1
- package/dist/databrowser.ui-a5c8194c.js +1 -0
- package/dist/{density-09feb0c9.js → density-30dbad8b.js} +1 -1
- package/dist/{dictionary-a132a3cc.js → dictionary-d8435ddc.js} +1 -1
- package/dist/{drag-2e9c80bb.js → drag-ad04f964.js} +1 -1
- package/dist/{e2pca-4f1648e3.js → e2pca-02adebbd.js} +1 -1
- package/dist/{ep-1d4c58b4.js → ep-b2e464fe.js} +1 -1
- package/dist/{facet-fa4fe49c.js → facet-e7612200.js} +1 -1
- package/dist/{filter-b3d3964e.js → filter-67d51c09.js} +1 -1
- package/dist/{fusion.parse-7dfd6988.js → fusion.parse-68670e99.js} +1 -1
- package/dist/{geneExpClustering-ed9121b8.js → geneExpClustering-d96c27ef.js} +1 -1
- package/dist/geneExpression-072e0be1.js +1 -0
- package/dist/{geneExpression-394672ff.js → geneExpression-4901955e.js} +1 -1
- package/dist/{geneExpression-66208299.js → geneExpression-65346c08.js} +1 -1
- package/dist/{geneORA-9456872c.js → geneORA-e3d6619e.js} +1 -1
- package/dist/geneVariant-9fc29f37.js +1 -0
- package/dist/{geneVariant-beaf9adb.js → geneVariant-f6bbc247.js} +1 -1
- package/dist/{genefusion.ui-9238ec7f.js → genefusion.ui-a5a08183.js} +1 -1
- package/dist/{genesearch-ffd88bf2.js → genesearch-5fa13afa.js} +1 -1
- package/dist/{geneset-0315daf8.js → geneset-c36036bd.js} +1 -1
- package/dist/genomeBrowser-d4515002.js +1 -0
- package/dist/{genomeBrowser.controls-2601cab5.js → genomeBrowser.controls-b89629b0.js} +1 -1
- package/dist/{groupsetting-e3a4ecd5.js → groupsetting-a3de9ec7.js} +1 -1
- package/dist/{gsea-0c0cf8de.js → gsea-af1a7cec.js} +1 -1
- package/dist/{hierCluster-7ab62ca5.js → hierCluster-8aa2265a.js} +1 -1
- package/dist/hierCluster.config-11a176e2.js +1 -0
- package/dist/{hierCluster.interactivity-7f475259.js → hierCluster.interactivity-103b2f0f.js} +1 -1
- package/dist/{hierCluster.renderers-19b79639.js → hierCluster.renderers-48bdf7a6.js} +1 -1
- package/dist/{html.legend-80b2b3ec.js → html.legend-455f7881.js} +1 -1
- package/dist/{imagePlot-1ef24562.js → imagePlot-862c7baf.js} +1 -1
- package/dist/{lasso-1a02a545.js → lasso-e12204af.js} +1 -1
- package/dist/launch.adhoc-b8af0ace.js +1 -0
- package/dist/leftlabel.sample-784c5aeb.js +1 -0
- package/dist/{legacyDataset-fbaa5ebb.js → legacyDataset-501a0298.js} +1 -1
- package/dist/{log-c26b6cfd.js → log-d560d2a5.js} +1 -1
- package/dist/{lollipop-3aebe5d3.js → lollipop-aa25084e.js} +1 -1
- package/dist/{maf-c439c851.js → maf-13befc91.js} +1 -1
- package/dist/{maftimeline-0da64e54.js → maftimeline-f9ee156e.js} +1 -1
- package/dist/{matrix-38cd47c3.js → matrix-971b44da.js} +1 -1
- package/dist/{matrix.cells-a018d731.js → matrix.cells-92037b17.js} +1 -1
- package/dist/{matrix.cluster-a6e713e8.js → matrix.cluster-0bca59fd.js} +1 -1
- package/dist/{matrix.config-2c550b5d.js → matrix.config-b8d8faef.js} +1 -1
- package/dist/matrix.controls-07c6128c.js +1 -0
- package/dist/{matrix.data-2b814c9f.js → matrix.data-1090f6c7.js} +1 -1
- package/dist/{matrix.dom-1e0da5b3.js → matrix.dom-1154156c.js} +1 -1
- package/dist/{matrix.groups-824a7244.js → matrix.groups-f10a8c05.js} +1 -1
- package/dist/{matrix.interactivity-1cb56534.js → matrix.interactivity-99de0399.js} +1 -1
- package/dist/{matrix.layout-47e44357.js → matrix.layout-405db70f.js} +1 -1
- package/dist/{matrix.legend-9af0c757.js → matrix.legend-d06de359.js} +1 -1
- package/dist/{matrix.renderers-337ce240.js → matrix.renderers-2211c4b2.js} +1 -1
- package/dist/{matrix.serieses-7b7184c9.js → matrix.serieses-f0803a76.js} +1 -1
- package/dist/{matrix.sort-1ac05842.js → matrix.sort-3d376f1a.js} +1 -1
- package/dist/{matrix.sorterUi-1c60c145.js → matrix.sorterUi-469ed804.js} +1 -1
- package/dist/{mavb-da8d1a0a.js → mavb-e5cbd894.js} +1 -1
- package/dist/{mds.fimo-8604c3f8.js → mds.fimo-f9215ef6.js} +1 -1
- package/dist/{mds.samplescatterplot-3f09ae0e.js → mds.samplescatterplot-6fce6594.js} +1 -1
- package/dist/{mds.survivalplot-1d8f2b7e.js → mds.survivalplot-16e9e8c5.js} +1 -1
- package/dist/{metaboliteIntensity-bbb23c76.js → metaboliteIntensity-b47fb792.js} +1 -1
- package/dist/{niceNumLabels-29a7c6ca.js → niceNumLabels-1bd7a93b.js} +1 -1
- package/dist/{nodrag-b2737073.js → nodrag-0fa60f70.js} +1 -1
- package/dist/{notify-0cb8904f.js → notify-42149e65.js} +1 -1
- package/dist/{numeric-24dacbee.js → numeric-5b626171.js} +1 -1
- package/dist/{numeric.binary-f382cc98.js → numeric.binary-07e15211.js} +1 -1
- package/dist/numeric.continuous-76dd29ba.js +1 -0
- package/dist/numeric.discrete-6d697c68.js +1 -0
- package/dist/{numeric.spline-a35cfbf0.js → numeric.spline-cf331bad.js} +1 -1
- package/dist/{numeric.toggle-2f98d6e5.js → numeric.toggle-332c2578.js} +1 -1
- package/dist/oncomatrix-7c84c94b.js +1 -0
- package/dist/{parseData-292648dd.js → parseData-05ab5f81.js} +1 -1
- package/dist/{plot.2dvaf-6ae22dc1.js → plot.2dvaf-1debbf12.js} +1 -1
- package/dist/plot.app-0b02df66.js +1 -0
- package/dist/{plot.barplot-34841e70.js → plot.barplot-45b57df9.js} +1 -1
- package/dist/{plot.boxplot-87ac2ce9.js → plot.boxplot-06cef6e2.js} +1 -1
- package/dist/{plot.brainImaging-32a484b6.js → plot.brainImaging-07795744.js} +1 -1
- package/dist/{plot.disco-1fdfee3c.js → plot.disco-9c631d77.js} +1 -1
- package/dist/{plot.dzi-e3d0f610.js → plot.dzi-a9a81de5.js} +1 -1
- package/dist/{plot.ssgq-d33113d5.js → plot.ssgq-02ffde06.js} +1 -1
- package/dist/{plot.vaf2cov-9f4f1776.js → plot.vaf2cov-c111c5fb.js} +1 -1
- package/dist/{plot.wsi-dea124a7.js → plot.wsi-6ccc7bb2.js} +1 -1
- package/dist/{profileBarchart-58f0a8c0.js → profileBarchart-0c97e8c9.js} +1 -1
- package/dist/{profileHome-7f404152.js → profileHome-2255d66d.js} +1 -1
- package/dist/profilePlot-ba7e03ab.js +1 -0
- package/dist/{profilePolar-50b8e40e.js → profilePolar-d38d502f.js} +1 -1
- package/dist/{profileRadar-fff0b004.js → profileRadar-f95cfa87.js} +1 -1
- package/dist/{profileRadarFacility-d6d34c15.js → profileRadarFacility-7e200a91.js} +1 -1
- package/dist/profileSummary-8c41a731.js +1 -0
- package/dist/{recover-299ffdb3.js → recover-6f2f3379.js} +1 -1
- package/dist/{regression.inputs-14df7c31.js → regression.inputs-b515101d.js} +1 -1
- package/dist/{regression.inputs.values.table-d79efa9e.js → regression.inputs.values.table-f8a0cad9.js} +1 -1
- package/dist/{regression.results-4767144e.js → regression.results-91a486f0.js} +1 -1
- package/dist/{renderPvalueTable-002cc8ff.js → renderPvalueTable-d4d2624c.js} +1 -1
- package/dist/sampleScatter-7c2773de.js +1 -0
- package/dist/{sampleScatter.rendererThree-ef289434.js → sampleScatter.rendererThree-b6db5a09.js} +2 -2
- package/dist/{sampleView-1dff3fca.js → sampleView-8885e86b.js} +1 -1
- package/dist/{samplelst-d2db0f24.js → samplelst-83e593da.js} +1 -1
- package/dist/{samplematrix-0841387f.js → samplematrix-a8b3f845.js} +1 -1
- package/dist/{scatter-f8285107.js → scatter-34d52e2d.js} +1 -1
- package/dist/{select2Terms-d48d037e.js → select2Terms-d9320d21.js} +1 -1
- package/dist/{selectGenomeWithTklst-9af86d31.js → selectGenomeWithTklst-fed6a2ea.js} +1 -1
- package/dist/shapes-21ebfec4.js +1 -0
- package/dist/singleCellCellType-e6848f45.js +1 -0
- package/dist/{singleCellGeneExpression-537f1157.js → singleCellGeneExpression-d3a5394e.js} +1 -1
- package/dist/singleCellPlot-3cad6bd8.js +1 -0
- package/dist/{singlecell-38336cbc.js → singlecell-0754aab0.js} +1 -1
- package/dist/{singlecell-87b4b9a9.js → singlecell-7c57cd77.js} +1 -1
- package/dist/{snp-b81ef740.js → snp-6b23e7a6.js} +1 -1
- package/dist/snp-a0cdd2a5.js +1 -0
- package/dist/snplocus-c60eab56.js +1 -0
- package/dist/{spliceevent.a53ss.diagram-5f8352eb.js → spliceevent.a53ss.diagram-8714f740.js} +1 -1
- package/dist/{spliceevent.exonskip.diagram-0d30a735.js → spliceevent.exonskip.diagram-40c1e363.js} +1 -1
- package/dist/spliceevent.exonskip.getdefault-4bb6f19f.js +1 -0
- package/dist/{spliceevent.noeventdiagram-df9ce4bc.js → spliceevent.noeventdiagram-41a56db9.js} +1 -1
- package/dist/{spliceevent.phrase-a8401d53.js → spliceevent.phrase-7f34e3b1.js} +1 -1
- package/dist/{stattable-46cde32c.js → stattable-78dc5c34.js} +1 -1
- package/dist/{style.gdc-72d730f2.js → style.gdc-cd49882c.js} +1 -1
- package/dist/summary-45c56298.js +1 -0
- package/dist/{sunburst-fe95832e.js → sunburst-2140e468.js} +1 -1
- package/dist/{survival-57ff3c03.js → survival-db972025.js} +1 -1
- package/dist/{survival-52714cd3.js → survival-ed4bdad2.js} +1 -1
- package/dist/{svg.download-f4aa48e4.js → svg.download-a5e20a92.js} +1 -1
- package/dist/{svg.legend-749348e0.js → svg.legend-8d21872d.js} +1 -1
- package/dist/{svgraph-b46f1f92.js → svgraph-f6a28b78.js} +1 -1
- package/dist/{svmr-9a76c6d4.js → svmr-8b4b4c59.js} +1 -1
- package/dist/{table-bf40249b.js → table-1cbe3a36.js} +1 -1
- package/dist/{table-0daf2b89.js → table-e2a307e6.js} +1 -1
- package/dist/{termInfo-491b10af.js → termInfo-5477ba96.js} +1 -1
- package/dist/termdb.bins-7ecc48db.js +1 -0
- package/dist/{termsetting-492eefa7.js → termsetting-2e75e729.js} +1 -1
- package/dist/tk-a8a4481a.js +1 -0
- package/dist/{toggleButtons-c4d6f260.js → toggleButtons-7ce58d97.js} +1 -1
- package/dist/{tp.ui-0a476325.js → tp.ui-be14f635.js} +1 -1
- package/dist/{tvs.density-034b506d.js → tvs.density-8b953cef.js} +1 -1
- package/dist/{tvs.geneVariant-c59c8b54.js → tvs.geneVariant-ecad287d.js} +1 -1
- package/dist/{tvs.numeric-aa1f892f.js → tvs.numeric-b56a5aba.js} +1 -1
- package/dist/{tvs.samplelst-515f27b9.js → tvs.samplelst-3150e0b7.js} +1 -1
- package/dist/{uiUtils-ea7dfea2.js → uiUtils-71cc22de.js} +1 -1
- package/dist/{variantBrowser-14d5c3f6.js → variantBrowser-df2f9c22.js} +1 -1
- package/dist/{vcf-d357ce08.js → vcf-3e370c9b.js} +1 -1
- package/dist/{violin-74d26b75.js → violin-4595cef4.js} +1 -1
- package/dist/{violin.interactivity-bf40ddde.js → violin.interactivity-8b63e000.js} +1 -1
- package/dist/{violin.renderer-469fa0ff.js → violin.renderer-0b7431a2.js} +1 -1
- package/dist/{violinRenderer-14fa200d.js → violinRenderer-7b0a4e98.js} +1 -1
- package/dist/{viridis-cc59f478.js → viridis-725f66e0.js} +1 -1
- package/dist/{y-59cbff5e.js → y-300bac24.js} +1 -1
- package/dist/{zoom-f445cfef.js → zoom-d3d38b3b.js} +1 -1
- package/package.json +2 -4
- package/dist/FilterRxComp-02e68f1b.js +0 -1
- package/dist/FilterStateless-16a33070.js +0 -1
- package/dist/app-42f69951.js +0 -1
- package/dist/app-6fb77603.js +0 -1
- package/dist/block.lazyload-d2951c91.js +0 -1
- package/dist/controls.btns-5bf9e7d7.js +0 -1
- package/dist/databrowser.ui-2197fc73.js +0 -1
- package/dist/downloadTextfile-5723af95.js +0 -1
- package/dist/geneExpression-c61e8f1c.js +0 -1
- package/dist/geneVariant-f17cda85.js +0 -1
- package/dist/genomeBrowser-608b924e.js +0 -1
- package/dist/hierCluster.config-f4daaf92.js +0 -1
- package/dist/launch.adhoc-e124c993.js +0 -1
- package/dist/leftlabel.sample-59f99ef5.js +0 -1
- package/dist/matrix.controls-42ad4912.js +0 -1
- package/dist/numeric.continuous-6feb34a7.js +0 -1
- package/dist/numeric.discrete-ed10bbc1.js +0 -1
- package/dist/oncomatrix-c0b2d635.js +0 -1
- package/dist/plot.app-2a805759.js +0 -1
- package/dist/profilePlot-4db8ca78.js +0 -1
- package/dist/profileSummary-04b8b15b.js +0 -1
- package/dist/sampleScatter-55d9eb74.js +0 -1
- package/dist/singleCellCellType-fd1606b8.js +0 -1
- package/dist/singleCellPlot-eff5760b.js +0 -1
- package/dist/snp-f6123244.js +0 -1
- package/dist/snplocus-acafb1ba.js +0 -1
- package/dist/spliceevent.exonskip.getdefault-237c481c.js +0 -1
- package/dist/summary-a6c15c9e.js +0 -1
- package/dist/termdb.bins-39d11f24.js +0 -1
- package/dist/tk-ac524564.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as t,M as e,a as s,d as a,y as o,J as i,b as n,K as r,I as l,r as c,L as p,N as d,O as h,B as m,z as f,n as u,P as g,Q as y}from"./app-6fb77603.js";import{c as b,f as v}from"./termsetting-492eefa7.js";import{controlsInit as x}from"./controls-268e40e6.js";import{d as S}from"./zoom-f445cfef.js";import{d as w}from"./lasso-1a02a545.js";import{c as C,g as j,r as T,a as k,b as D,d as A,e as _,f as L,h as M,o as O,i as W,j as z}from"./recover-299ffdb3.js";import{t as $}from"./downloadTextfile-5723af95.js";import{r as I}from"./table-0daf2b89.js";import{a as N,b as G,c as R}from"./FilterRxComp-02e68f1b.js";import{searchSampleInput as q}from"./sampleView-1dff3fca.js";import{s as V}from"./select2Terms-d48d037e.js";import{d as E}from"./svg.download-f4aa48e4.js";import{s as P}from"./sampleScatter.rendererThree-ef289434.js";import{a as F,b as H,c as U}from"./axis-747c801e.js";import{l as B}from"./line-264f8f9e.js";class K{constructor(t){this.type="search";J(this);X(this)}async init(t){this.dom={holder:this.opts.holder,holderNode:this.opts.holder.node(),tip:new e({padding:"5px"})};this.initUI()}reactsTo(t){return t.type.startsWith("search")||t.type.startsWith("cohort")}getState(t){return{cohortStr:t.activeCohort==-1||!t.termdbConfig.selectCohort?"":t.termdbConfig.selectCohort.values[t.activeCohort].keys.slice().sort().join(","),search:t.search,nav:t.nav}}async main(){this.dom.holder.style("display",this.state.search.isVisible&&this.state.nav.header_mode!="only_buttons"?"inline-block":"none")}async doSearch(t){if(!t){this.clear({hide:true});this.bus.emit("postSearch",[]);return}const e=await this.app.vocabApi.findTerm(t,this.state.cohortStr,this.opts.usecase,this.opts.targetType);if(!e.lst||e.lst.length==0){this.noResult()}else{this.showTerms(e)}this.bus.emit("postSearch",e)}}const Y=t(K);function J(t){t.initUI=()=>{t.dom.holder.style("display",t.search&&t.search.isVisible==false?"none":"inline-block");t.dom.input=t.dom.holder.style("text-align","center").append("input").attr("type","search").attr("class","tree_search").attr("placeholder","Search").style("width","180px").style("display","block").on("input",s.debounce(t.onInput,300));t.dom.resultDiv=t.dom.tip.d.style("border-left",t.opts.resultsHolder?"":"solid 1px rgb(133,182,225)").style("padding-left","5px")};t.noResult=()=>{t.clear();t.dom.resultDiv.append("div").text("No match").style("padding","3px 3px 3px 0px").style("opacity",.5)};t.showTerms=e=>{if(t.opts.disable_terms)e.lst.forEach((e=>{if(e.disabled)t.opts.disable_terms.push(e)}));t.clear({hide:!e.lst.length});if(e.lst.length){t.dom.resultDiv.append("table").selectAll().data(e.lst).enter().append("tr").each(t.showTerm)}};t.showTerm=function(e){const s=a(this);const o=s.append("td").text(e.name);if(e.type){o.style("cursor","pointer").attr("class","sja_menuoption").on("click",(()=>{t.app.dispatch({type:"plot_create",config:{chartType:e.type=="survival"?"survival":"summary",term:{term:e}}});t.clear({hide:true})}))}else{o.style("padding","5px 10px").style("opacity",.5)}s.append("td").text((e.__ancestorNames||[]).join(" > ")).style("opacity",.5).style("font-size",".7em")};t.clear=(e={})=>{t.dom.tip.clear();if(e.hide)t.dom.tip.hide();else t.dom.tip.showunder(t.dom.holderNode)}}function X(t){t.onInput=async()=>{const e=t.dom.input.property("value");try{await t.doSearch(e)}catch(e){t.clear();o(t.dom.resultDiv,"Error: "+(e.message||e));if(e.stack)console.log(e.stack)}}}function Z(t){switch(t){case"../plots/DEanalysis.js":return import("./DEanalysis-bbfad00d.js");case"../plots/Disco.js":return import("./Disco-b7c9bf72.js");case"../plots/DziViewer.js":return import("./DziViewer-28915c11.js");case"../plots/WSIViewer.js":return import("./WSIViewer-957695a8.js");case"../plots/barchart.data.js":return import("./FilterRxComp-02e68f1b.js").then((function(t){return t.j}));case"../plots/barchart.events.js":return import("./barchart.events-426d737a.js");case"../plots/barchart.js":return import("./barchart-2898d229.js");case"../plots/bars.renderer.js":return import("./bars.renderer-71935d34.js");case"../plots/bars.settings.js":return import("./bars.settings-64bb4642.js");case"../plots/boxplot.js":return import("./boxplot-4c9a5479.js");case"../plots/brainImaging.js":return import("./brainImaging-7716bc66.js");case"../plots/controls.btns.js":return import("./controls.btns-5bf9e7d7.js");case"../plots/controls.config.js":return import("./controls.config-2f0fa061.js");case"../plots/controls.js":return import("./controls-268e40e6.js");case"../plots/cuminc.js":return import("./cuminc-8dffb765.js");case"../plots/dataDownload.js":return import("./dataDownload-452ae3cd.js");case"../plots/dictionary.js":return import("./dictionary-a132a3cc.js");case"../plots/facet.js":return import("./facet-fa4fe49c.js");case"../plots/geneExpression.js":return import("./geneExpression-66208299.js");case"../plots/geneORA.js":return import("./geneORA-9456872c.js");case"../plots/geneset.js":return import("./geneset-0315daf8.js");case"../plots/genomeBrowser.controls.js":return import("./genomeBrowser.controls-2601cab5.js");case"../plots/genomeBrowser.js":return import("./genomeBrowser-608b924e.js");case"../plots/gsea.js":return import("./gsea-0c0cf8de.js");case"../plots/hierCluster.config.js":return import("./hierCluster.config-f4daaf92.js");case"../plots/hierCluster.interactivity.js":return import("./hierCluster.interactivity-7f475259.js").then((function(t){return t.i}));case"../plots/hierCluster.js":return import("./hierCluster-7ab62ca5.js");case"../plots/hierCluster.renderers.js":return import("./hierCluster.renderers-19b79639.js").then((function(t){return t.r}));case"../plots/imagePlot.js":return import("./imagePlot-1ef24562.js");case"../plots/matrix.cells.js":return import("./matrix.cells-a018d731.js");case"../plots/matrix.cluster.js":return import("./matrix.cluster-a6e713e8.js");case"../plots/matrix.config.js":return import("./matrix.config-2c550b5d.js");case"../plots/matrix.controls.js":return import("./matrix.controls-42ad4912.js");case"../plots/matrix.data.js":return import("./matrix.data-2b814c9f.js").then((function(t){return t.m}));case"../plots/matrix.dom.js":return import("./matrix.dom-1e0da5b3.js");case"../plots/matrix.groups.js":return import("./matrix.groups-824a7244.js").then((function(t){return t.m}));case"../plots/matrix.interactivity.js":return import("./matrix.interactivity-1cb56534.js");case"../plots/matrix.js":return import("./matrix-38cd47c3.js");case"../plots/matrix.layout.js":return import("./matrix.layout-47e44357.js").then((function(t){return t.m}));case"../plots/matrix.legend.js":return import("./matrix.legend-9af0c757.js").then((function(t){return t.m}));case"../plots/matrix.renderers.js":return import("./matrix.renderers-337ce240.js");case"../plots/matrix.serieses.js":return import("./matrix.serieses-7b7184c9.js").then((function(t){return t.m}));case"../plots/matrix.sort.js":return import("./matrix.sort-1ac05842.js");case"../plots/matrix.sorterUi.js":return import("./matrix.sorterUi-1c60c145.js");case"../plots/plot.app.js":return import("./plot.app-2a805759.js");case"../plots/plot.brainImaging.js":return import("./plot.brainImaging-32a484b6.js");case"../plots/plot.disco.js":return import("./plot.disco-1fdfee3c.js");case"../plots/plot.ssgq.js":return import("./plot.ssgq-d33113d5.js");case"../plots/profileBarchart.js":return import("./profileBarchart-58f0a8c0.js");case"../plots/profilePlot.js":return import("./profilePlot-4db8ca78.js");case"../plots/profilePolar.js":return import("./profilePolar-50b8e40e.js");case"../plots/profileRadar.js":return import("./profileRadar-fff0b004.js");case"../plots/profileRadarFacility.js":return import("./profileRadarFacility-d6d34c15.js");case"../plots/profileSummary.js":return import("./profileSummary-04b8b15b.js");case"../plots/regression.inputs.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.b}));case"../plots/regression.inputs.term.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.a}));case"../plots/regression.inputs.values.table.js":return import("./regression.inputs.values.table-d79efa9e.js");case"../plots/regression.js":return import("./regression.inputs-14df7c31.js").then((function(t){return t.r}));case"../plots/regression.results.js":return import("./regression.results-4767144e.js").then((function(t){return t.r}));case"../plots/sampleScatter.interactivity.js":return Promise.resolve().then((function(){return It}));case"../plots/sampleScatter.js":return Promise.resolve().then((function(){return Xt}));case"../plots/sampleScatter.renderer.js":return Promise.resolve().then((function(){return Wt}));case"../plots/sampleScatter.rendererThree.js":return import("./sampleScatter.rendererThree-ef289434.js").then((function(t){return t.c}));case"../plots/sampleView.js":return import("./sampleView-1dff3fca.js");case"../plots/scatter.js":return import("./scatter-f8285107.js");case"../plots/singleCellPlot.js":return import("./singleCellPlot-eff5760b.js");case"../plots/stattable.js":return import("./stattable-46cde32c.js");case"../plots/summary.js":return import("./summary-a6c15c9e.js");case"../plots/survival.js":return import("./survival-52714cd3.js");case"../plots/table.js":return import("./table-bf40249b.js");case"../plots/variantBrowser.js":return import("./variantBrowser-14d5c3f6.js");case"../plots/violin.interactivity.js":return import("./violin.interactivity-bf40ddde.js");case"../plots/violin.js":return import("./violin-74d26b75.js");case"../plots/violin.renderer.js":return import("./violin.renderer-469fa0ff.js");default:return new Promise((function(e,s){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(s.bind(null,new Error("Unknown variable dynamic import: "+t)))}))}}class Q{constructor(){this.type="sessionBtn";this.route="termdb";this.embedderOrigin=window.location.origin;this.hostURL=sessionStorage.getItem("hostURL")||this.embedderOrigin}async init(t){const s=new e({padding:"0px"});this.dom={button:this.opts.button,tip:s};this.dom.button.on("click",(()=>{this.dom.tip.clear();this.showMenu()}));this.dslabel=t.vocab.dslabel;this.savedSessions=JSON.parse(localStorage.getItem("savedMassSessions")||`{}`);this.requiredAuth=t.termdbConfig?.requiredAuth?.find((t=>t.route==this.route&&t.type=="jwt"))}async showMenu(){this.dom.tip.clear().d.style("padding",0);const t=[{label:`Open`,title:"Recover a saved session",callback:this.open},{label:`Save`,title:"Save the current view",callback:this.save},{label:`Share`,title:"Create a URL link to share this view",callback:this.getSessionUrl}];if(!this.serverCachedSessions)await this.setServerCachedSessions();if(Object.keys(this.savedSessions).length||Object.keys(this.serverCachedSessions).length){t.push({label:`Delete`,title:"Delete a saved session",callback:this.delete})}this.dom.tip.clear().d.selectAll(".sja_menuoption sja_sharp_border").data(t).enter().append("div").attr("class","sja_menuoption sja_sharp_border").attr("aria-label",(t=>t.title)).html((t=>t.label)).on("click",((t,e)=>{this.dom.tip.clear().d.style("padding","10px");this.showBackBtn();e.callback.call(this)}));this.dom.tip.showunder(this.dom.button.node())}async open(){const t=`sjpp-session-open-radio-`+Math.random().toString().slice(-6);this.dom.tip.d.append("div").style("display","none").style("padding","3px 9px").html(`\n\t\t\t<b>Open in</b>\n\t\t\t<label>\n\t\t\t\t<input type='radio' name='${t}' value='new' style='margin-right: 0; vertical-align: bottom'/>\n\t\t\t\t<span>a new tab</span>\n\t\t\t</label>\n\t\t\t<label style='margin-left: 5px'>\n\t\t\t\t<input type='radio' name='${t}' value='current' checked=checked style='margin-right: 0; vertical-align: bottom'/>\n\t\t\t\t<span>current tab</span>\n\t\t\t</label>\n\t\t`);const e=await this.listSessions({trClickHandler:async(e,s)=>{const{loc:a,id:o}=s;if(!o)return;if(a.includes("browser")){this.sessionName=o;const e=this.savedSessions[o];await tt(e,this.app);const s=this.dom.tip.d.node().querySelector(`[name="${t}"]:checked`).value;if(s=="current"){this.app.dispatch({type:"app_refresh",state:e})}else if(window.location.origin==this.hostURL){window.open(`/?mass-session-id=${o}&src=browser`)}else{if(e.embedder)i({state:e});else{const{protocol:t,host:s,search:a,origin:o,href:n}=window.location;const r={protocol:t,host:s,search:a,origin:o,href:n};i({state:Object.assign({embedder:r},e)})}}this.dom.tip.hide()}else if(a=="server"){const e=this.app.vocabApi.mayGetAuthHeaders(this.route);const s={id:o,route:this.route,dslabel:this.dslabel,embedder:window.location.hostname};const a=await n(`/massSession?`,{headers:e,body:s});if(!a.state)throw a.error||"unable to get the cached session from the server";await tt(a.state,this.app);this.savedSessions[o]=a.state;const r=this.dom.tip.d.node().querySelector(`[name="${t}"]:checked`).value;if(r=="current"){this.app.dispatch({type:"app_refresh",state:a.state})}else if(window.location.origin==this.hostURL){window.open(`/?mass-session-id=${o}&src=cred&dslabel=${this.dslabel}&route=${this.route}`)}else{i(a)}this.dom.tip.hide()}}});e.headtr.select("th").html("Open from");const s=e.tbody.insert("tr","tr");s.append("td").style("text-align","center").style("padding","3px 9px").html("Local file");const a=s.append("td").style("text-align","left").append("label");a.append("span").style("padding","3px 9px").style("text-decoration","underline").style("cursor","pointer").html("Choose File");a.append("input").attr("type","file").attr("placeholder","file name").style("opacity",0).style("width","0.1px").style("height","0.1px").style("position","absolute").on("change",(async()=>{const e=event.target.files.item(0);const s=await e.text();let a=e.name;if(this.savedSessions[a]){a=prompt(`Leave as-is to overwrite a session with the same name, or enter a different session name.`,a)}this.sessionName=a;const o=JSON.parse(s);await tt(o,this.app);this.savedSessions[a]=o;localStorage.setItem("savedMassSessions",JSON.stringify(this.savedSessions));const n=this.dom.tip.d.node().querySelector(`[name="${t}"]:checked`).value;if(n=="current"){this.app.dispatch({type:"app_refresh",state:o})}else if(window.location.origin==this.hostURL){window.open(`/?mass-session-id=${a}&src=browser`)}else{if(o.embedder)i({state:o});else{const{protocol:t,host:e,search:s,origin:a,href:n}=window.location;const r={protocol:t,host:e,search:s,origin:a,href:n};i({state:Object.assign({embedder:r},o)})}}this.dom.tip.hide()}))}async listSessions(t={}){const e=this.dom.tip.d.append("table").attr("class","sjpp-controls-table");const s=e.append("thead").append("tr");s.selectAll("th").data(["Cache Location","Session ID"]).enter().append("th").style("text-align",((t,e)=>e===0?"center":"left")).style("padding","3px 9px").html((t=>t));const a=Object.keys(this.savedSessions).map((t=>({loc:"browser",id:t})));if(!this.serverCachedSessions)await this.setServerCachedSessions();a.push(...this.serverCachedSessions.map((t=>({loc:"server",id:t}))));const o=e.append("tbody");const i=o.selectAll("tr").data(a).enter().append("tr").on("click",t.trClickHandler||null);i.selectAll("td").data((t=>[t,t])).enter().append("td").style("text-align",((t,e)=>e===0?"center":"left")).style("padding","3px 9px").style("cursor","pointer").html(((t,e)=>e===0?t.loc:t.id));if(!this.serverCachedSessions.length&&this.requiredAuth&&!this.app.vocabApi.hasVerifiedToken()){e.append("tbody").append("tr").selectAll("td").data(["server","requires sign-in"]).enter().append("td").style("text-align",((t,e)=>e===0?"center":"left")).style("padding","3px 9px").html((t=>t))}return{table:e,headtr:s,tbody:o,trs:i}}async setServerCachedSessions(){const t=this.app.getState();this.requiredAuth=t.termdbConfig?.requiredAuth?.find((t=>t.route==this.route&&t.type=="jwt"));if(!this.requiredAuth){this.serverCachedSessions=[];return}const e=this.app.vocabApi.mayGetAuthHeaders(this.route);const s={route:this.route,dslabel:this.dslabel,embedder:window.location.hostname};const a=await n("/sessionIds",{headers:e,body:s});this.serverCachedSessions=a.sessionIds||[]}async save(t){const e=this.dom.tip.d;const s=e.append("div");s.append("span").html("Save as");const a=Object.keys(this.savedSessions);if(!this.serverCachedSessions)await this.setServerCachedSessions();a.push(...this.serverCachedSessions.filter((t=>!a.includes(t))));const o=this.sessionName||"unnamed-session";const i=s.append("input").attr("type","text").attr("placeholder",o).style("width","220px").on("input",(()=>{n.selectAll("*").remove();const t=i.property("value");const e=a.filter((e=>e===t));const s=a.filter((e=>e.startsWith(t)));const o=a.filter((e=>e.includes(t)&&e!==t&&!s.includes(e)));n.selectAll("div").data([...e,...s,...o]).enter().append("div").attr("class","sja_menuoption").html((t=>t)).on("click",((t,e)=>{i.property("value",e);n.selectAll("*").remove()}))}));const n=e.append("div");const r=e.append("div");r.append("span").html("Save to ");r.append("button").style("min-width","80px").html("Browser").attr("title",`Save the session in your current browser's cache. The session can be easily recovered, but not shared among your other devices`).on("click",(()=>{this.sessionName=i.property("value")||o;this.savedSessions[this.sessionName]=this.app.getState();localStorage.setItem("savedMassSessions",JSON.stringify(this.savedSessions));this.confirmAction(`Cached '<b>${this.sessionName}</b>' in browser`)}));r.append("button").style("min-width","80px").html("File").attr("title",`Save the session into a local file. The session can be easily recoved using the 'Open from local file' option.`).on("click",(()=>{const t=i.property("value")||o;this.savedSessions[t]=this.app.getState();this.download(t);this.confirmAction(`Downloaded '<b>${t}</b>'`)}));if(this.requiredAuth){const t=this.app.vocabApi.hasVerifiedToken()?"":"Requires sign-in. ";r.append("button").style("min-width","80px").html("Server").attr("title",`${t}Save the session into a remote server. The session can be easily shared across your different devices and recovered using the 'Open from server' option.`).property("disabled",!this.app.vocabApi.hasVerifiedToken()).on("click",(async()=>{if(!this.app.vocabApi.hasVerifiedToken()){alert("Requires sign-in");return}const t=i.property("value")||o;this.savedSessions[t]=this.app.getState();const e=await this.getSessionUrl(t);if(e.id!=t)throw`error saving ${t}`;this.confirmAction(`Saved '<b>${t}</b>' on the server`)}))}}download(t=""){const e=t||this.sessionName;const s=e?.endsWith(".txt")?"":".txt";const a=`${e}${s}`;$(a,JSON.stringify(this.savedSessions[e]))}async getSessionUrl(t=""){const e=this.app.vocabApi.mayGetAuthHeaders("termdb");const s=structuredClone(this.app.getState());const{protocol:a,host:o,search:r,origin:l,href:c}=window.location;s.embedder={protocol:a,host:o,search:r,origin:l,href:c};if(t){s.__sessionFor__={route:this.route,filename:t,dslabel:this.dslabel,embedder:window.location.hostname}}const p=await n("/massSession",{headers:e,method:"POST",body:JSON.stringify(s)});if(t){return p}else{const t=`${this.hostURL}/?mass-session-id=${p.id}&noheader=1`;this.dom.tip.showunder(this.dom.button.node());const e=this.dom.tip.d.append("div").style("margin","10px");e.append("div").style("margin-bottom","12px").html(`Click the link to recover this session. Bookmark or share this link.`);const a=e.append("a").attr("href",t).attr("target","_blank").html(p.id);if(this.hostURL!=window.location.origin){a.on("click",(t=>{t.preventDefault();i({state:s},window.location.origin);return false}))}e.append("div").html(`\n\t\t\t\t\t<br>\n\t\t\t\t\t<div style="max-width: 400px; font-size: 1em; opacity:.6">\n\t\t\t\t\t<span>NOTES</span>\n\t\t\t\t\t<ul>\n\t\t\t\t\t<li>A recovered session may hide data or views to users that are not authorized to access the saved datasets or features.</li>\n\t\t\t\t\t<li>This session will be saved for ${this.opts.massSessionDuration} days.</li>\n\t\t\t\t\t</ul>\n\t\t\t\t\t</div>`);setTimeout((()=>{this.dom.button.property("disabled",false)}),1e3)}}async delete(){const t=await this.listSessions({trClickHandler:function(s){const o=this.lastChild.querySelector("input");const i=s.target==o?o.checked:!o.checked;a(this).style("text-decoration",i?"line-through":"");if(s.target!=o)o.checked=i;const n=t.table.node().querySelectorAll("input:checked");e.property("disabled",n.length?false:true)}});t.headtr.append("th").html("Delete");t.trs.each((function(t){a(this).append("td").style("text-align","center").append("input").attr("type","checkbox").attr("value",t.id)}));const e=this.dom.tip.d.append("div").style("text-align","center").append("button").html("Delete selected sessions").property("disabled",true).on("click",(async()=>{const e=t.table.node().querySelectorAll("input");const s=[];for(const t of e){if(a(t).property("checked")){const e=t.parentNode.parentNode.__data__;if(e.loc=="browser"){delete this.savedSessions[t.value]}else if(e.loc=="server"){delete this.serverCachedSessions[t.value];s.push(t.value)}else throw`unknown cache location=${e.loc}`}}localStorage.setItem("savedMassSessions",JSON.stringify(this.savedSessions));try{const t=this.app.vocabApi.mayGetAuthHeaders("termdb");const e={ids:s,route:this.route,dslabel:this.dslabel,embedder:window.location.hostname};const a=n(`/massSession?`,{method:"DELETE",headers:t,body:e})}catch(t){throw t}this.dom.tip.hide()}))}showBackBtn(){this.dom.tip.d.append("div").attr("class","sja_clbtext2").style("margin-bottom","10px").style("cursor","pointer").html(`< Session Menu`).on("click",(()=>this.showMenu()))}confirmAction(t){this.dom.tip.clear().d.append("div").html(t).transition().delay(3e3).duration(1e3).style("opacity",0);setTimeout((()=>{this.dom.tip.hide()}),3500)}}async function tt(t,e){if(t.plots){const s=[];for(const a of t.plots){s.push((async()=>{const t=await Z(`../plots/${a.chartType}.js`);return await t.getPlotConfig(a,e)})())}try{await Promise.all(s)}catch(t){console.log(t);e.printError(t)}}}const et=t(Q);class st{constructor(t){this.type="about";this.app=t.app;this.holder=t.holder;this.features=t.features}init(){this.holder.append("div").style("padding","10px").html(this.features.html)}main(){const t=this.app.Inner.components.nav.Inner.tabs.findIndex((t=>t.subheader=="about"));const e=this.app.Inner.state.nav.activeTab==t;this.holder.style("display",e?"":"none")}}const at=t(st);let ot=0;const it="_MASS_AUTOID_"+Math.random().toString().slice(-6);let nt=(+new Date).toString().slice(-8);const rt=new e({padding:"0px",offsetX:0,offsetY:0});rt.d.style("z-index",5555);const lt={top:"CHARTS",mid:"NONE",btm:"",subheader:"charts"};const ct={top:"GROUPS",mid:"NONE",btm:"",subheader:"groups"};const pt={top:"FILTER",mid:"NONE",btm:"",subheader:"filter"};function dt(){return it+"_"+nt++}class ht{constructor(t){this.type="nav";this.instanceNum=ot++;this.activeTab=0;this.activeCohort=0;this.searching=false;this.samplecounts={};this.massSessionDuration=t.massSessionDuration;this.sessionDaysLeft=t.app.opts.sessionDaysLeft||null;this.sessionId=t.app.opts.sessionId||null;ut(this);ft(this)}async init(t){try{this.cohortFilter=N(t.termfilter.filter,"cohortFilter");this.initUI(t);this.initCohort(t);this.components=await r({search:Y({app:this.app,holder:this.dom.searchDiv,usecase:{target:"summary",detail:"term"},targetType:"Dictionary Variables"}),filter:G({app:this.app,vocabApi:this.app.vocabApi,holder:this.dom.subheader.filter.append("div"),hideLabel:this.opts.header_mode==="with_tabs",emptyLabel:"+Add new filter",callback:t=>{this.app.dispatch({type:"filter_replace",filter:t})}}),charts:C({app:this.app,holder:this.dom.subheader.charts,vocab:this.opts.vocab}),groups:j({app:this.app,holder:this.dom.subheader.groups,vocab:this.opts.vocab}),recover:T({app:this.app,holder:this.dom.recoverDiv,getState:t=>t,reactsTo:t=>t.type!="plot_edit",maxHistoryLen:5}),sessionBtn:et({app:this.app,button:this.dom.saveBtn,massSessionDuration:this.opts.massSessionDuration,sessionDaysLeft:this.app.opts.sessionDaysLeft||null}),about:t.termdbConfig.about?at({app:this.app,holder:this.dom.subheader.about,features:t.termdbConfig.about}):[]});this.mayShowMessage_sessionDaysLeft()}catch(t){throw t}}reactsTo(t){if(t.type.includes("cache_termq"))return true;if(t.type.startsWith("filter"))return true;if(t.type.startsWith("cohort"))return true;if(t.type.startsWith("tab"))return true;if(t.type=="plot_create")return true;if(t.type=="plot_delete")return true;if(t.type=="app_refresh")return true;if(t.type.endsWith("_customTerm"))return true;if(t.type.endsWith("_group"))return true}getState(t){return{searching:this.searching,nav:t.nav,activeCohort:t.activeCohort,termdbConfig:t.termdbConfig,filter:t.termfilter.filter,plots:t.plots,groups:t.groups}}async main(){if(this.state.termdbConfig.selectCohort&&this.state.termdbConfig.about){console.error("Cohort(s) and an About tab are defined. Only one can be used.");return}this.dom.tabDiv.style("display",this.state.nav.header_mode==="with_tabs"?"inline-block":"none");this.dom.tip.hide();this.activeTab=this.state.nav.activeTab;this.prevCohort=this.activeCohort;this.activeCohort=+this.state.activeCohort;this.filterUiRoot=N(this.state.filter,"filterUiRoot");this.cohortFilter=N(this.state.filter,"cohortFilter");if(this.cohortNames){this.activeCohortName=this.cohortNames[this.activeCohort];if(this.activeCohort!==-1)this.activeCohortLabel=this.state.termdbConfig.selectCohort.values[this.activeCohort].shortLabel}this.filterJSON=JSON.stringify(this.state.filter);this.cohortsData=await this.app.vocabApi.getCohortsData();if(this.state.termdbConfig.about)this.about=this.state.termdbConfig.about;if(this.state.nav.header_mode==="with_tabs"){if(!(this.activeCohortName in this.samplecounts)){const t=await this.app.vocabApi.getCohortSampleCount(this.activeCohortName);this.samplecounts[this.activeCohortName]=t}if(!(this.filterJSON in this.samplecounts)){if(!this.filterUiRoot||!this.filterUiRoot.lst.length){this.samplecounts[this.filterJSON]=this.samplecounts[this.activeCohortName]}else{const t=await this.app.vocabApi.getFilteredSampleCount(this.filterJSON);this.samplecounts[this.filterJSON]=t}}}this.updateUI()}}const mt=t(ht);function ft(t){t.initUI=s=>{const a=t.opts.holder.append("div").style("white-space","nowrap");let o=a.append("div").style("display","inline-block").style("float","right").style("font-size","1.1em").style("margin-top","50px").text(s.termdbConfig?.title?.text||"");const i=a.append("div").style("display","none").style("vertical-align","bottom");const n=a.append("div").style("vertical-align","top").style("margin","10px").style("display","inline-block");t.opts.holder.attr("class","sjpp-nav");t.dom={holder:t.opts.holder,header:a,tabDiv:i,controlsDiv:n,searchDiv:n.append("div").style("margin","10px"),sessionDiv:n.append("div").style("display","inline-block"),recoverDiv:n.append("div").style("display","inline-block"),helpDiv:n.append("div").style("display","none"),sessionElapsedMessageDiv:n.append("div").style("display","none"),subheaderDiv:t.opts.holder.append("div").style("display","block").style("padding-top","5px").style("border-bottom","1px solid #000"),messageDiv:t.opts.holder.append("div").style("margin","30px").style("display","none"),titleDiv:o,tip:new e({padding:"5px"})};if(s.nav.header_mode=="only_buttons"){t.dom.tabDiv.style("display","none");t.dom.recoverDiv.style("display","none");o.style("margin-top","95px").style("font-size","0.9em");if(s.termdbConfig.title?.link)o.on("click",(()=>window.open(s.termdbConfig.title.link,"_blank"))).on("mouseover",(()=>o.style("cursor","pointer")))}if(t.opts.header_mode==="with_cohortHtmlSelect"){t.dom.cohortStandaloneDiv=a.append("div").style("display","inline-block").style("margin","10px").style("vertical-align","top");t.dom.cohortStandaloneDiv.append("label").html("Cohort: ");t.dom.cohortSelect=t.dom.cohortStandaloneDiv.append("select").on("change",(function(){t.app.dispatch({type:"cohort_set",activeCohort:+this.value})}));t.dom.cohortSelect.selectAll("option").data(s.termdbConfig.selectCohort.values).enter().append("option").attr("value",((t,e)=>e)).property("selected",((t,e)=>e===s.activeCohort)).html((t=>t.shortLabel))}t.dom.subheader=Object.freeze({search:t.dom.subheaderDiv.append("div").style("display","none"),groups:t.dom.subheaderDiv.append("div").style("display","none"),charts:t.dom.subheaderDiv.append("div").style("display","none"),filter:t.dom.subheaderDiv.append("div").style("display","none"),cart:t.dom.subheaderDiv.append("div").style("display","none").html("<br/>Cart feature under construction - work in progress<br/> <br/>"),about:t.dom.subheaderDiv.append("div").style("display","none").attr("data-testid","sjpp-mass-about")});t.tabs=[lt,ct,pt];if(s.termdbConfig?.selectCohort||s.termdbConfig?.about){const e=s.termdbConfig?.about?.tab||{};const a=s.termdbConfig.selectCohort?"COHORT":e.topLabel||"";const o=e.midLabel||(e?"ABOUT":"");const i=e.btmLabel||"";const n={top:a.toUpperCase(),mid:o.toUpperCase(),btm:i,subheader:"about"};const r=s.termdbConfig?.selectCohort?0:e.order||0;t.tabs.splice(r,0,n)}const r=t.dom.tabDiv.append("table").style("border-collapse","collapse");r.selectAll("tr").data(["top","mid","btm"]).enter().append("tr").style("font-size",((t,e)=>e==1?"20px":"12px")).selectAll("td").data(((e,s)=>t.tabs.map(((t,a)=>({rowNum:s,key:e,colNum:a,label:t[e],subheader:t.subheader}))))).enter().append("td").style("display","none").style("width","100px").style("padding",(t=>t.rowNum===0?"12px 12px 3px 12px":"3px 12px")).style("text-align","center").style("border-left","1px solid #ccc").style("border-right","1px solid #ccc").style("color","#aaa").style("cursor","pointer").html((t=>t.label)).on("click",((e,s)=>{t.setTab(e,s)}));t.dom.trs=r.selectAll("tr");t.dom.tds=r.selectAll("td");t.subheaderKeys=t.tabs.map((t=>t.subheader));t.dom.saveBtn=t.dom.sessionDiv.append("button").style("margin","10px").text("Session ▼");if(t.sessionDaysLeft!=null){t.dom.fileBtn=t.dom.sessionDiv.append("button").style("margin","10px").text("Export Session").on("click",(e=>{t.getSessionFile(e)}))}const l=s.termdbConfig.helpPages;if(l){t.dom.helpBtn=t.dom.helpDiv.style("display","inline-block").append("button").style("margin","10px").html("Help ▼").on("click",(t=>{const e=t.target.getBoundingClientRect();const s=rt.clear().show(e.left-0,e.top+e.height+5).d.append("div");for(const t of l){s.append("div").style("margin","15px").append("a").attr("href",t.url).attr("target","_blank").text(t.label)}}))}};t.mayShowMessage_sessionDaysLeft=()=>{if(!Number.isFinite(t.sessionDaysLeft)){return}t.dom.sessionElapsedMessageDiv.style("display","block");t.dom.remainingDaysMessage=t.dom.sessionElapsedMessageDiv.append("div").style("display","block").style("opacity","0.65").html(`<u>${t.sessionDaysLeft} days</u> left until this session is removed. Click the "Save Session" button to create a new one.`)};t.updateUI=async(e=false)=>{if(!t.dom.subheaderDiv)return;if(t.activeTab&&t.state.termdbConfig.selectCohort&&t.activeCohort==-1){t.dom.subheaderDiv.style("display","none");t.dom.messageDiv.selectAll("text").remove();t.dom.messageDiv.style("display","").text('No cohort selected. Please select a cohort in the "COHORT" tab.')}else{let s="block";if(e){s=t.dom.subheaderDiv.style("display")=="none"?"block":"none"}if(t.dom.subheaderDiv)t.dom.subheaderDiv.style("display",s);if(t.dom.messageDiv)t.dom.messageDiv.style("display","none")}const s=t.state.termdbConfig.selectCohort;t.dom.searchDiv.style("display",s&&t.activeCohort==-1||t.state.nav.header_mode=="only_buttons"?"none":"inline-block");t.dom.header.style("border-bottom",t.state.nav.header_mode==="with_tabs"?"1px solid #000":"");t.dom.tds.style("display","").style("color",(e=>e.colNum==t.activeTab?"#000":"#aaa")).style("background-color",(e=>e.colNum==t.activeTab&&t.dom.subheaderDiv.style("display")!="none"?"#ececec":"transparent")).html((function(e,s){if(e.key=="top")return this.innerHTML;if(e.subheader=="groups"){if(e.key=="mid")return t.state.groups.length||"NONE";return""}if(e.subheader==="charts"){const s=t.state.plots.length;if(e.key=="mid")return!s?"NONE":s;else return""}else if(e.subheader==="about"){if(t.activeCohortName&&t.activeCohortName in t.samplecounts){const s={top:this.innerHTML,mid:t.activeCohortLabel,btm:t.samplecounts[t.activeCohortName]};return s[e.key]||""}else if(t.about){const s={top:t.about?.tab?.topLabel?t.about.tab.topLabel.toUpperCase():this.innerHTML,mid:t.about?.tab?.midLabel?t.about.tab.midLabel.toUpperCase():"ABOUT",btm:t.about?.tab?.btmLabel||this.innerHTML};return s[e.key]||""}else{return e.key==="mid"?"NONE":this.innerHTML}}else if(e.subheader==="filter"){const s=t.filterUiRoot?t.filterUiRoot:{lst:[]};if(s.lst.length===0){return e.key==="mid"?"NONE":t.samplecounts["undefined"]?`${t.samplecounts["undefined"]}`:""}else{const a=t.samplecounts[t.filterJSON]!=undefined?""+t.samplecounts[t.filterJSON]:"";return e.key==="mid"?s.lst.length:a}}else{return e.key==="mid"?this.innerHTML:" "}}));for(const e in t.dom.subheader){t.dom.subheader[e].style("display",t.tabs[t.activeTab].subheader===e?"block":"none")}t.renderCohortsTable();if(t.opts.header_mode==="with_cohort_select"){t.dom.cohortSelect.selectAll("option").property("value",appState.activeCohort)}};t.renderCohortsTable=()=>{if(!t.dom.cohortTable)return;t.dom.cohortTable.selectAll("*").remove();const e=[{label:"Feature"}];const s=[];const a=t.cohortsData;if("error"in a)throw a.error;for(const t of a.features)s.push([{value:t.name}]);for(const t of a.cohorts){e.push({label:t.cohort?`${t.name} (${t.cohort})`:t.name});for(const[e,o]of a.features.entries()){const i=a.cfeatures.find((e=>e.idfeature===o.idfeature&&e.cohort===t.cohort));if(i)s[e].push({value:i.value})}}I({rows:s,columns:e,div:t.dom.cohortTable,showLines:false,maxHeight:"60vh"});t.dom.cohortTable.select("table").style("border-collapse","collapse");t.dom.cohortTable.selectAll(`tbody > tr > td`).style("background-color","transparent");const o=t.state.termdbConfig.selectCohort;const i=o.values[t.activeCohort].keys;let n=`tbody > tr > td:nth-child(${t.activeCohort+2})`;const r=i.length>1;if(r){n="";for(const t of i){const e=a.cohorts.map((t=>t.cohort)).indexOf(t);if(n!=="")n+=",";n+=`tbody > tr > td:nth-child(${e+2})`}}const l=t.dom.cohortTable.selectAll(n);l.style("background-color","yellow");t.dom.cohortInputs.property("checked",((e,s)=>s===t.activeCohort))};t.initCohort=async e=>{const s=e.termdbConfig.selectCohort;if(!s)return;t.dom.tds.filter((t=>t.colNum===0)).style("display","");t.cohortNames=s.values.map((t=>t.keys.slice().sort().join(",")));if(s.title){t.dom.cohortTitle=t.dom.subheader.about.append("h2").style("margin-left","10px").text(s.title)}if(s.description){t.dom.cohortDescription=t.dom.subheader.about.append("div").style("margin-left","10px").html(s.description)}if(s.prompt){t.dom.cohortPrompt=t.dom.subheader.about.append("div").style("margin-left","10px").style("padding-top","30px").style("padding-bottom","10px").style("font-weight","bold").text(s.prompt)}t.dom.cohortOpts=t.dom.subheader.about.append("div").style("margin-bottom","30px").style("margin-left","10px");t.dom.cohortOpts.append("table").selectAll("tr").data(s.values).enter().append("tr").each((function(e,s){const o=a(this);const i=o.append("td");const n="sja-termdb-cohort-"+t.instanceNum;const r=n+"-"+s;i.append("input").attr("type","radio").attr("name",n).attr("id",r).attr("value",s).property("checked",s===t.activeCohort).style("margin-right","5px").style("margin-left","0px").on("click",(()=>{t.app.dispatch({type:"cohort_set",activeCohort:s})}));i.append("label").attr("for",r).attr("colspan",2).style("cursor","pointer").html((t=>t.label));o.selectAll("td").style("max-width","600px").style("padding-bottom","10px").style("padding-right","20px").style("vertical-align","top")}));t.dom.cohortInputs=t.dom.cohortOpts.selectAll("input");t.dom.cohortTable=t.dom.subheader.about.append("div");if(s.asterisk){t.dom.cohortAsterisk=t.dom.subheader.about.append("div").style("margin-left","10px").style("padding-top","20px").style("padding-bottom","20px").style("font-size","small").text(s.asterisk)}}}function ut(t){t.setTab=async(e,s)=>{if(s.colNum===t.activeTab&&!t.searching){t.prevCohort=t.activeCohort;await t.updateUI(true);if(t.bus)t.bus.emit("postRender");return}t.activeTab=s.colNum;t.searching=false;t.app.dispatch({type:"tab_set",activeTab:t.activeTab});const a=t.subheaderKeys.indexOf("charts");if(t.activeTab==a&&t.activeCohort!=-1&&!t.state.plots.length){t.app.dispatch({type:"plot_create",id:dt(),config:{chartType:"dictionary"}})}};t.getSessionFile=async e=>{const s=await n(`/massSession?id=${t.sessionId}`);const a=document.createElement("a");const o="data:application/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(s.state));a.setAttribute("href",o);a.download=`${t.sessionId}.json`;a.click();a.remove()}}function gt(t,e){return yt(t)||bt(t,e)||vt()}function yt(t){if(Array.isArray(t))return t}function bt(t,e){var s=[];var a=true;var o=false;var i=undefined;try{for(var n=t[Symbol.iterator](),r;!(a=(r=n.next()).done);a=true){s.push(r.value);if(e&&s.length===e)break}}catch(t){o=true;i=t}finally{try{if(!a&&n["return"]!=null)n["return"]()}finally{if(o)throw i}}return s}function vt(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function xt(t,e,s,a){t=t.filter((function(t,a){var o=e(t,a),i=s(t,a);return o!=null&&isFinite(o)&&i!=null&&isFinite(i)}));if(a){t.sort((function(t,s){return e(t)-e(s)}))}var o=t.length,i=new Float64Array(o),n=new Float64Array(o);var r=0,l=0,c,p,d;for(var h=0;h<o;){d=t[h];i[h]=c=+e(d,h,t);n[h]=p=+s(d,h,t);++h;r+=(c-r)/h;l+=(p-l)/h}for(var m=0;m<o;++m){i[m]-=r;n[m]-=l}return[i,n,r,l]}function St(t,e,s,a){var o=0;for(var i=0,n=t.length;i<n;i++){var r=t[i],l=+e(r,i,t),c=+s(r,i,t);if(l!=null&&isFinite(l)&&c!=null&&isFinite(c)){a(l,c,o++)}}}function wt(t,e,s,a,o){var i=0,n=0;St(t,e,s,(function(t,e){var s=e-o(t),r=e-a;i+=s*s;n+=r*r}));return 1-i/n}function Ct(t){return Math.atan2(t[1][1]-t[0][1],t[1][0]-t[0][0])*180/Math.PI}function jt(t){return[(t[0][0]+t[1][0])/2,(t[0][1]+t[1][1])/2]}function Tt(t,e,s){var a=Math.log(e-t)*Math.LOG10E+1|0;var o=1*Math.pow(10,-a/2-1),i=1e4;var n=[l(t),l(e)],r=0;while(c(n)&&r<i){}return n;function l(t){return[t,s(t)]}function c(t){r++;var e=t.length;var s=false;for(var a=0;a<e-1;a++){var i=t[a],n=t[a+1],c=jt([i,n]),p=l(c[0]),d=Ct([i,c]),h=Ct([i,p]),m=Math.abs(d-h);if(m>o){t.splice(a+1,0,p);s=true}}return s}}function kt(t,e,s,a){var o=a-t*t,i=Math.abs(o)<1e-24?0:(s-t*e)/o,n=e-i*t;return[n,i]}function Dt(){var t=function t(e){return e[0]},e=function t(e){return e[1]},s;function a(a){var o=0,i=0,n=0,r=0,l=0,c=s?+s[0]:Infinity,p=s?+s[1]:-Infinity;St(a,t,e,(function(t,e){++o;i+=(t-i)/o;n+=(e-n)/o;r+=(t*e-r)/o;l+=(t*t-l)/o;if(!s){if(t<c)c=t;if(t>p)p=t}}));var d=kt(i,n,r,l),h=gt(d,2),m=h[0],f=h[1],u=function t(e){return f*e+m},g=[[c,u(c)],[p,u(p)]];g.a=f;g.b=m;g.predict=u;g.rSquared=wt(a,t,e,n,u);return g}a.domain=function(t){return arguments.length?(s=t,a):s};a.x=function(e){return arguments.length?(t=e,a):t};a.y=function(t){return arguments.length?(e=t,a):e};return a}function At(){var t=function t(e){return e[0]},e=function t(e){return e[1]},s;function a(a){var o=xt(a,t,e),i=gt(o,4),n=i[0],r=i[1],l=i[2],c=i[3],p=n.length;var d=0,h=0,m=0,f=0,u=0,g,y,b,v;for(g=0;g<p;){y=n[g];b=r[g++];v=y*y;d+=(v-d)/g;h+=(v*y-h)/g;m+=(v*v-m)/g;f+=(y*b-f)/g;u+=(v*b-u)/g}var x=0,S=0,w=s?+s[0]:Infinity,C=s?+s[1]:-Infinity;St(a,t,e,(function(t,e){S++;x+=(e-x)/S;if(!s){if(t<w)w=t;if(t>C)C=t}}));var j=m-d*d,T=d*j-h*h,k=(u*d-f*h)/T,D=(f*j-u*h)/T,A=-k*d,_=function t(e){e=e-l;return k*e*e+D*e+A+c};var L=Tt(w,C,_);L.a=k;L.b=D-2*k*l;L.c=A-D*l+k*l*l+c;L.predict=_;L.rSquared=wt(a,t,e,x,_);return L}a.domain=function(t){return arguments.length?(s=t,a):s};a.x=function(e){return arguments.length?(t=e,a):t};a.y=function(t){return arguments.length?(e=t,a):e};return a}function _t(){var t=function t(e){return e[0]},e=function t(e){return e[1]},s=3,a;function o(o){if(s===1){var i=Dt().x(t).y(e).domain(a)(o);i.coefficients=[i.b,i.a];delete i.a;delete i.b;return i}if(s===2){var n=At().x(t).y(e).domain(a)(o);n.coefficients=[n.c,n.b,n.a];delete n.a;delete n.b;delete n.c;return n}var r=xt(o,t,e),l=gt(r,4),c=l[0],p=l[1],d=l[2],h=l[3],m=c.length,f=[],u=[],g=s+1;var y=0,b=0,v=a?+a[0]:Infinity,x=a?+a[1]:-Infinity;St(o,t,e,(function(t,e){++b;y+=(e-y)/b;if(!a){if(t<v)v=t;if(t>x)x=t}}));var S,w,C,j,T;for(S=0;S<g;++S){for(C=0,j=0;C<m;++C){j+=Math.pow(c[C],S)*p[C]}f.push(j);T=new Float64Array(g);for(w=0;w<g;++w){for(C=0,j=0;C<m;++C){j+=Math.pow(c[C],S+w)}T[w]=j}u.push(T)}u.push(f);var k=Mt(u),D=function t(e){e-=d;var s=h+k[0]+k[1]*e+k[2]*e*e;for(S=3;S<g;++S){s+=k[S]*Math.pow(e,S)}return s},A=Tt(v,x,D);A.coefficients=Lt(g,k,-d,h);A.predict=D;A.rSquared=wt(o,t,e,y,D);return A}o.domain=function(t){return arguments.length?(a=t,o):a};o.x=function(e){return arguments.length?(t=e,o):t};o.y=function(t){return arguments.length?(e=t,o):e};o.order=function(t){return arguments.length?(s=t,o):s};return o}function Lt(t,e,s,a){var o=Array(t);var i,n,r,l;for(i=0;i<t;++i){o[i]=0}for(i=t-1;i>=0;--i){r=e[i];l=1;o[i]+=r;for(n=1;n<=i;++n){l*=(i+1-n)/n;o[i-n]+=r*Math.pow(s,n)*l}}o[0]+=a;return o}function Mt(t){var e=t.length-1,s=[];var a,o,i,n,r;for(a=0;a<e;++a){n=a;for(o=a+1;o<e;++o){if(Math.abs(t[a][o])>Math.abs(t[a][n])){n=o}}for(i=a;i<e+1;++i){r=t[i][a];t[i][a]=t[i][n];t[i][n]=r}for(o=a+1;o<e;++o){for(i=e;i>=a;i--){t[i][o]-=t[i][a]*t[a][o]/t[a][a]}}}for(o=e-1;o>=0;--o){r=0;for(i=o+1;i<e;++i){r+=t[i][o]*s[i]}s[o]=(t[e][o]-r)/t[o][o]}return s}function Ot(t){P(t);t.render=function(){const e=t.mainDiv.selectAll(":scope > div").data(t.charts,(t=>t?.id));e.exit().remove();e.each(t.renderChart);e.enter().append("div").style("vertical-align","top").each(t.renderChart)};t.renderChart=function(e){e.chartDiv=a(this);const o=t.settings;e.chartDiv.style("opacity",0).style("display","inline-block");e.chartDiv.on("mouseover",(s=>{if(!t.onClick)t.showTooltip(s,e)}));e.chartDiv.on("click",(s=>t.showTooltip(s,e)));e.svg=e.chartDiv.select("svg").empty()?e.chartDiv.append("svg"):e.chartDiv.select("svg");s(e,o);e.chartDiv.transition().duration(o.duration).style("opacity",1)};t.initAxes=function(e){if(e.data.samples.length==0)return;e.xAxisScale=l().domain([e.xMin,e.xMax]).range([t.axisOffset.x,t.settings.svgw+t.axisOffset.x]);e.axisBottom=F(e.xAxisScale);e.yAxisScale=l().domain([e.yMax,e.yMin]).range([t.axisOffset.y,t.settings.svgh+t.axisOffset.y]);e.zAxisScale=l().domain([e.zMin,e.zMax]).range([0,t.settings.svgd]);e.xScaleMin=e.xAxisScale(e.xMin);e.xScaleMax=e.xAxisScale(e.xMax);e.yScaleMin=e.xAxisScale(e.yMin);e.yScaleMax=e.yAxisScale(e.yMax);e.zScaleMin=e.xAxisScale(e.zMin);e.zScaleMax=e.zAxisScale(e.zMax);e.axisLeft=H(e.yAxisScale);const s=t.config.settings.sampleScatter.defaultColor;if(!t.config.startColor)t.config.startColor=t.config.stopColor={};if(!t.config.startColor[e.id]){t.config.startColor[e.id]=c(s).brighter().brighter().toString()}if(!t.config.stopColor[e.id]){t.config.stopColor[e.id]=c(s).darker().toString()}if(t.config.colorTW?.q.mode==="continuous"){const[s,a]=e.cohortSamples.filter((e=>!t.config.colorTW.term.values||!(e.category in t.config.colorTW.term.values))).reduce(((t,e)=>[e.category<t[0]?e.category:t[0],e.category>t[1]?e.category:t[1]]),[e.cohortSamples[0].category,e.cohortSamples[0].category]);e.colorGenerator=l().domain([s,a]).range([t.config.startColor[e.id],t.config.stopColor[e.id]])}};function s(e,s){const a=e.svg;let n=Math.min(20*40/e.colorLegend.size,25);if(n<12)n=12;let r=e.colorLegend.size*n;if(e.colorLegend.get("Ref")?.sampleCount>0)r+=60;const l=t.config.scaleDotTW?200:100;t.legendHeight=Math.max(r,e.shapeLegend.size*30)+l;const c=t.charts.length==1?s.svgw+800:s.svgw+(t.config.shapeTW?600:350);a.transition().duration(s.duration).attr("width",c).attr("height",Math.max(s.svgh+100,t.legendHeight));o(e);if(t.is3D)t.render3DSerie(e);else if(t.is2DLarge)t.render2DSerieLarge(e);else{i(e,s.duration);t.renderLegend(e,n)}}function o(e){const s=e.svg;let a,o,i;if(s.select(".sjpcb-scatter-mainG").size()==0){e.mainG=s.append("g").attr("class","sjpcb-scatter-mainG");a=s.append("g").attr("class","sjpcb-scatter-axis");o=s.append("g").attr("class","sjpcb-scatter-labelsG");e.xAxis=a.append("g").attr("class","sjpcb-scatter-x-axis");e.yAxis=a.append("g").attr("class","sjpcb-scatter-y-axis").attr("transform",`translate(${t.axisOffset.x}, 0)`);e.mainG.append("rect").attr("class","zoom").attr("x",t.axisOffset.x).attr("y",t.axisOffset.y-t.settings.size).attr("width",t.settings.svgw).attr("height",t.settings.svgh).attr("fill","white");e.serie=e.mainG.append("g").attr("class","sjpcb-scatter-series");e.regressionG=e.mainG.append("g").attr("class","sjpcb-scatter-lowess");const n=`${Date.now()}`;const r=`sjpp_clip_${n}`;t.defs=s.append("defs");i=t.defs.append("clipPath").attr("id",r).append("rect");const l=t.defs.append("linearGradient").attr("id",`linear-gradient-${e.id}`).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");t.startGradient[e.id]=l.append("stop").attr("offset","0%").attr("stop-color",t.config.startColor[e.id]);t.stopGradient[e.id]=l.append("stop").attr("offset","100%").attr("stop-color",t.config.stopColor[e.id]);e.mainG.attr("clip-path",`url(#${r})`);e.legendG=s.append("g").attr("class","sjpcb-scatter-legend")}else{e.mainG=s.select(".sjpcb-scatter-mainG");e.serie=e.mainG.select(".sjpcb-scatter-series");e.regressionG=e.mainG.select(".sjpcb-scatter-lowess");a=s.select(".sjpcb-scatter-axis");o=s.select(".sjpcb-scatter-labelsG");e.xAxis=a.select(".sjpcb-scatter-x-axis");e.yAxis=a.select(".sjpcb-scatter-y-axis");e.legendG=s.select(".sjpcb-scatter-legend");i=s.select(`defs > clipPath > rect`)}e.xAxis.attr("transform",`translate(0, ${t.settings.svgh+t.axisOffset.y})`);e.legendG.attr("transform",`translate(${t.settings.svgw+t.axisOffset.x+50}, 20)`);if(e.axisBottom){e.xAxis.call(e.axisBottom);e.yAxis.call(e.axisLeft)}const n=Math.sqrt(t.settings.size);if(t.settings.showAxes&&!(t.is2DLarge||t.is3D)){i.attr("x",t.axisOffset.x).attr("y",0).attr("width",t.settings.svgw+2*n).attr("height",t.settings.svgh+t.axisOffset.y);a.style("opacity",1);if(t.config.term){let s=t.config.term.term.name;if(!t.config.colorTW&&!t.config.shapeTW&&!t.config.term0)s=`${s}, n=${e.cohortSamples.length}`;o.selectAll("*").remove();o.append("text").attr("transform",`translate(${t.axisOffset.x+t.settings.svgw/2}, ${t.settings.svgh+t.axisOffset.y+40})`).attr("text-anchor","middle").text(s);if(t.config.term0&&!t.config.colorTW&&!t.config.shapeTW){const s=`${e.id}, n=${e.cohortSamples.length}`;o.append("text").attr("transform",`translate(${t.axisOffset.x+t.settings.svgw/2}, ${t.settings.svgh+t.axisOffset.y+65})`).attr("text-anchor","middle").text(s)}o.append("text").attr("transform",`translate(${t.axisOffset.x-50}, ${t.settings.svgh/2+t.axisOffset.y}) rotate(-90)`).attr("text-anchor","middle").text(t.config.term2.term.name)}}else{a.style("opacity",0);i.attr("x",t.axisOffset.x-n).attr("y",0).attr("width",t.settings.svgw+2*n).attr("height",t.settings.svgh+t.axisOffset.y+n)}}function i(e,s){if(t.canvas)t.canvas.remove();const a=e.serie;const o=e.data;const i=a.selectAll('path[name="serie"]').data(o.samples);i.exit().remove();i.transition().duration(s).attr("name","serie").attr("transform",(s=>t.transform(e,s))).attr("d",(s=>t.getShape(e,s))).attr("fill",(s=>t.getColor(s,e))).attr("stroke",(s=>t.getColor(s,e))).attr("stroke-width",(e=>t.getStrokeWidth(e))).style("fill-opacity",(e=>t.getOpacity(e)));i.enter().append("path").attr("name","serie").attr("transform",(s=>t.transform(e,s))).attr("d",(s=>t.getShape(e,s))).attr("fill",(s=>t.getColor(s,e))).attr("stroke",(s=>t.getColor(s,e))).attr("stroke-width",(e=>t.getStrokeWidth(e))).style("fill-opacity",(e=>t.getOpacity(e))).transition().duration(s);t.mayRenderRegression()}t.getStrokeWidth=function(e){const s=t.getOpacity(e);if(s<=.2)return 0;if(s==1.2)return 2;return 1};t.processData=async function(){for(const e of t.charts){t.initAxes(e);const s=t.config.settings.sampleScatter.regression;if(!s||s=="None")continue;let a;const o=[];await e.cohortSamples.forEach((t=>{const s=e.xAxisScale(t.x);const a=e.yAxisScale(t.y);o.push({x:s,y:a})}));let i;if(s=="Polynomial"){a=_t().x((t=>t.x)).y((t=>t.y)).order(3);i=a(o)}else if(s=="Lowess"){const e=[],s=[];for(const t of o){e.push(t.x);s.push(t.y)}i=await t.app.vocabApi.getLowessCurve({coords:{X:e,Y:s}})}else{throw`unsupported regression type='${s}'`}e.regressionCurve=i}};t.mayRenderRegression=async function(){for(const e of t.charts){e.regressionG?.selectAll("*").remove();if(e.regressionCurve){const t=B().x((t=>t[0])).y((t=>t[1]));const s=e.regressionG.append("path");s.attr("d",t(e.regressionCurve)).attr("stroke","blue").attr("fill","none").style("stroke-width","2")}}};t.getColor=function(e,s){if(t.config.colorTW?.q.mode=="continuous"&&"sampleId"in e){const t=s.colorGenerator(e.category);return t}if(e.category=="Default")return t.config.settings.sampleScatter.defaultColor;const a=s.colorLegend.get(e.category);return a.color};t.getOpacity=function(e){if("sampleId"in e){if(t.filterSampleStr){if(!e.sample?.toLowerCase().includes(t.filterSampleStr.toLowerCase()))return.2;else return 1.2}const s=e.hidden?.["category"]||e.hidden?.["shape"]?0:t.settings.opacity;return s}const s=t.settings.showRef?t.settings.opacity:0;return s};t.getShape=function(t,e,s=1){const a=t.shapeLegend.get(e.shape).shape%Vt.length;return Vt[a]};t.transform=function(e,s,a=1){const o=e.xAxisScale(s.x);const i=e.yAxisScale(s.y);const n=!("sampleId"in s);let r;if(!t.config.scaleDotTW||n){r="sampleId"in s?t.settings.size:t.settings.refSize}else{const a=t.settings.maxShapeSize-t.settings.minShapeSize;if(t.settings.scaleDotOrder=="Ascending")r=t.settings.minShapeSize+(s.scale-e.scaleMin)/(e.scaleMax-e.scaleMin)*a;else r=t.settings.maxShapeSize-(s.scale-e.scaleMin)/(e.scaleMax-e.scaleMin)*a}const l=`translate(${o},${i}) scale(${t.zoom*r*a/3})`;return l};t.lassoReset=e=>{const s=e.chartDiv.select(".sjpcb-scatter-mainG");if(e.lasso)e.lasso.items(s.select(".sjpcb-scatter-series").selectAll('path[name="serie"]')).targetArea(s).on("start",a).on("draw",o).on("end",i);function a(s){if(t.lassoOn){e.lasso.items().attr("transform",(s=>t.transform(e,s,1/2))).style("fill-opacity",(e=>t.getOpacity(e)!=0?.5:0)).classed("not_possible",true).classed("selected",false)}}function o(s){if(t.lassoOn){e.lasso.possibleItems().attr("transform",(s=>t.transform(e,s,1.2))).style("fill-opacity",(e=>t.getOpacity(e))).classed("not_possible",false).classed("possible",true);e.lasso.notPossibleItems().attr("transform",(s=>t.transform(e,s,1/2))).style("fill-opacity",(e=>t.getOpacity(e)!=0?.5:0)).classed("not_possible",true).classed("possible",false)}}function i(s){if(t.lassoOn){e.lasso.items().classed("not_possible",false).classed("possible",false);e.lasso.selectedItems().attr("transform",(s=>t.transform(e,s,1.3)));e.lasso.items().style("fill-opacity",(e=>t.getOpacity(e)));t.selectedItems=[];for(const s of e.lasso.selectedItems()){const e=s.__data__;if("sampleId"in e&&!(e.hidden["category"]||e.hidden["shape"]))t.selectedItems.push(s)}e.lasso.notSelectedItems().attr("transform",(s=>t.transform(e,s)));n(s.sourceEvent)}}function n(e){const s=t.selectedItems.map((t=>t.__data__));t.dom.tip.clear().hide();if(t.selectedItems.length==0)return;t.dom.tip.show(e.clientX,e.clientY);const a=t.dom.tip.d.append("div");a.append("div").attr("class","sja_menuoption sja_sharp_border").text(`List ${t.selectedItems.length} samples`).on("click",(e=>{t.dom.tip.hide();t.showTable({name:"Group "+(t.config.groups.length+1),items:s},e.clientX,e.clientY,true)}));a.append("div").attr("class","sja_menuoption sja_sharp_border").text("Add to a group").on("click",(async()=>{const e={name:"Group",items:s};const a=k([e]);const o=D(a);A(t.app,o,t.state.groups)}));a.append("div").attr("class","sja_menuoption sja_sharp_border").text("Add to a group and filter").on("click",(()=>{const e={name:"Group",items:s};const a=k([e]);const o=D(a);A(t.app,o,t.state.groups);t.addToFilter(a)}));if("sample"in s[0])a.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show samples").on("click",(async e=>{const a=[];for(const t of s)a.push({sampleId:t.sampleId,sampleName:t.sample});t.app.dispatch({type:"plot_create",id:dt(),config:{chartType:"sampleView",samples:a}});t.dom.tip.hide()}))}if(t.lassoOn){s.on(".zoom",null);s.on("mousedown.drag",null);s.call(e.lasso)}};t.addGroup=async function(e){e.plotId=t.id;await t.app.vocabApi.addGroup(e);t.dom.tip.hide()};t.setTools=function(){if(!t.charts[0])return;const e=t.config.settings.controls.isOpen;const s=t.dom.toolsDiv.style("background-color","white");s.selectAll("*").remove();let a="block";if(e)a="inline-block";const o=s.insert("div").style("display",a).style("margin","20px").attr("name","sjpp-reset-btn");p["restart"](o,{handler:g,title:"Reset plot to defaults"});const i=s.insert("div").style("display",a).style("margin","20px").attr("name","sjpp-zoom-in-btn");p["zoomIn"](i,{handler:f,title:"Zoom in"});const n=s.insert("div").style("display",a).style("margin","20px").attr("name","sjpp-zoom-out-btn");p["zoomOut"](n,{handler:u,title:"Zoom out"});const r=s.insert("div").style("display",a).style("margin","20px");const l=s.insert("div").style("display",a).style("margin","20px");if(!(t.is2DLarge||t.is3D)){p["search"](r,{handler:e=>t.searchSample(e),title:"Search samples"});p["lasso"](l,{handler:y,enabled:t.lassoOn,title:"Select a group of samples"})}t.dom.groupDiv=s.insert("div").style("display",a).style("margin","20px");const c=t.charts[0].mainG;const h=S().scaleExtent([.5,t.config.scaleDotTW?4:10]).on("zoom",m).filter((t=>{if(t.type==="wheel")return t.ctrlKey;return true}));if(t.config.scaleDotTW&&t.zoom>4)g();c.call(h);for(const e of t.charts){e.lasso=w();t.lassoReset(e)}t.updateGroupsButton();t.settings;function m(e){for(const s of t.charts){const a=e.transform.rescaleX(s.xAxisScale);const o=e.transform.rescaleY(s.yAxisScale);s.xAxis.call(s.axisBottom.scale(a));s.yAxis.call(s.axisLeft.scale(o));s.serie.attr("transform",e.transform);t.zoom=e.transform.scale(1).k;const i=s.serie.selectAll('path[name="serie"');i.attr("transform",(e=>t.transform(s,e,1)));if(t.lassoOn)s.lasso.selectedItems().attr("transform",(e=>t.transform(s,e,1.2)));if(t.config.scaleDotTW)t.drawScaleDotLegend(s)}}function f(){for(const e of t.charts)if(t.is2DLarge)t.zoom=t.zoom+.25;else h.scaleBy(e.mainG.transition().duration(750),1.5)}function u(){for(const e of t.charts)if(t.is2DLarge)t.zoom=t.zoom-.25;else h.scaleBy(e.mainG.transition().duration(750),.5)}function g(){for(const e of t.charts)if(t.is2DLarge)t.zoom=1;else e.mainG.transition().duration(750).call(h.transform,d);t.render()}function y(){t.lassoOn=!t.lassoOn;for(const e of t.charts){if(t.lassoOn){e.mainG.on(".zoom",null);e.mainG.call(e.lasso)}else{e.mainG.on("mousedown.drag",null);e.lasso.items().classed("not_possible",false);e.lasso.items().classed("possible",false);e.lasso.items().attr("r",t.settings.size).style("fill-opacity",(e=>t.getOpacity(e)));e.mainG.call(h);t.selectedItems=null}}l.select("*").remove();p["lasso"](l,{handler:y,enabled:t.lassoOn})}};t.updateGroupsButton=function(){t.dom.groupDiv.selectAll("*").remove();t.dom.tip.hide();if(t.config.groups.length==0)return;t.dom.groupDiv.append("button").style("border","none").style("background","transparent").style("padding",0).append("div").style("font-size","1.1em").html(`Σ${t.config.groups.length+1};`).on("click",(e=>{if(t.config.groups.length==1)t.showGroupMenu(e,t.config.groups[0]);else t.showGroupsMenu(e)}))};t.renderLegend=function(e,s){const a=e.legendG;a.selectAll("*").remove();let o=0;let i=25;if(!t.config.colorTW&&!t.config.shapeTW&&!t.config.colorColumn){if(t.config.scaleDotTW){e.scaleG=a.append("g").attr("transform",`translate(${o+45},${t.legendHeight-150})`);t.drawScaleDotLegend(e)}return}let n;let r=Math.min(.8,20/e.colorLegend.size);if(r<.5)r=.5;const p=a.style("font-size",`${r}em`);let d=t.config.term0?`${e.id}, n=${e.cohortSamples.length}`:`${e.cohortSamples.length} ${t.config.sampleType?t.config.sampleType+"s":"samples"}`;if(t.filterSampleStr)d+=`, search = ${t.filterSampleStr}`;p.append("text").attr("x",0).attr("y",i).text(d).style("font-weight","bold");i+=s+10;if(t.config.colorTW||t.config.colorColumn){n=`${h(t.config.colorTW?.term?.name||t.config.colorColumn.name,t.config.shapeTW==undefined)}`;const r=e.colorLegend.get("Ref");if(t.config.colorTW?.term?.type=="geneVariant"&&t.config.colorTW?.q.type=="values")i=t.renderGeneVariantLegend(e,o,i,a,t.config.colorTW,"category",e.colorLegend);else{p.append("text").attr("id","legendTitle").attr("x",o).attr("y",i).text(n).style("font-weight","bold");i+=s;if(t.config.colorTW?.q?.mode==="continuous"){const a=150;const[o,n]=e.colorGenerator.domain();const r=l().domain([o,n]).range([0,a]);const c=(n-o)/4;const d=[o,o+c,o+2*c,o+3*c,n];const h=U(r).tickValues(d);p.append("g").attr("transform",`translate(0, 100)`).call(h);e.startRect=p.append("rect").attr("x",-25).attr("y",100).attr("width",20).attr("height",20).style("fill",t.config.startColor[e.id]).on("click",(s=>t.editColor(e,"startColor",e.startRect)));e.stopRect=p.append("rect").attr("x",a+5).attr("y",100).attr("width",20).attr("height",20).style("fill",t.config.stopColor[e.id]).on("click",(s=>t.editColor(e,"stopColor",e.stopRect)));p.append("rect").attr("x",0).attr("y",100).attr("width",a).attr("height",20).style("fill",`url(#linear-gradient-${e.id})`);i+=s}else{for(const[n,r]of e.colorLegend){if(n=="Ref")continue;const l=n;const c=t.config.colorTW?.q.hiddenValues?n in t.config.colorTW.q.hiddenValues:false;const[d,h]=m(p,r,l,o,i,c);if(!t.config.colorColumn){d.on("click",(s=>t.onLegendClick(e,a,"colorTW",n,s,r)));h.on("click",(s=>t.onLegendClick(e,a,"colorTW",n,s,r)))}i+=s}}}if(r?.sampleCount>0){i=i+s;const n=a.append("g");n.append("text").attr("x",o).attr("y",i).text("Reference").style("font-weight","bold");i=i+s;const l=a.append("g");l.append("path").attr("transform",(t=>`translate(${o-2}, ${i-5}) scale(0.5)`)).style("fill",r.color).attr("d",Vt[0]).style("stroke",c(r.color).darker());l.on("click",(s=>t.onLegendClick(e,a,"colorTW","Ref",s,r)));const p=a.append("g").append("text").attr("x",o+10).attr("y",i).text(`n=${r.sampleCount}`).style("text-decoration",!t.settings.showRef?"line-through":"none").attr("alignment-baseline","middle");p.on("click",(s=>t.onLegendClick(e,a,"colorTW","Ref",s,r)))}}if(t.config.scaleDotTW){e.scaleG=a.append("g").attr("transform",`translate(${o},${t.legendHeight-100})`);t.drawScaleDotLegend(e)}if(t.config.shapeTW){o=!t.config.colorTW?0:300;i=60;n=`${h(t.config.shapeTW.term.name)}`;if(t.config.shapeTW.term.type=="geneVariant"&&t.config.shapeTW.q.type=="values")t.renderGeneVariantLegend(e,o,i,a,t.config.shapeTW,"shape",e.shapeLegend);else{const r=a.append("g");r.append("text").attr("x",o).attr("y",i).text(n).style("font-weight","bold");i+=s;const l="gray";for(const[n,p]of e.shapeLegend){if(n=="Ref")continue;const d=p.shape%Vt.length;const h=Vt[d];const m=n;const f=p.sampleCount;const u=t.config.shapeTW.q.hiddenValues?n in t.config.shapeTW.q.hiddenValues:false;const g=r.append("g");g.append("path").attr("transform",(t=>`translate(${o}, ${i-5}) scale(0.5)`)).style("fill",l).attr("d",h).style("stroke",c(l).darker());g.append("text").attr("x",o+10).attr("y",i).text(`${m}, n=${f}`).style("text-decoration",u?"line-through":"none").attr("alignment-baseline","middle");i+=s;g.on("click",(s=>t.onLegendClick(e,a,"shapeTW",n,s,p)))}}}function h(t,e=false){if(t.length>25&&!e)t=t.slice(0,25)+"...";return t}function m(s,o,i,n,r,l=false){Math.min(5*40/e.colorLegend.size,5);const p=s.append("g");p.append("path").attr("d",Vt[0]).attr("transform",`translate(${n-2}, ${r-5}) scale(0.5)`).style("fill",o.color).style("stroke",c(o.color).darker());if(!t.config.colorColumn)p.on("click",(s=>t.onLegendClick(e,a,"colorTW",key,s,o)));const d=s.append("g");d.append("text").attr("name","sjpp-scatter-legend-label").attr("x",n+10).attr("y",r).text(`${i}, n=${o.sampleCount}`).style("text-decoration",l?"line-through":"none").attr("alignment-baseline","middle");return[p,d]}};t.drawScaleDotLegend=function(s){const o=s.scaleG;o.selectAll("*").remove();const i=70;const n=t.settings.minShapeSize/3;const r=t.settings.maxShapeSize/3;const l=t.settings.scaleDotOrder;const c=l=="Ascending";const p=o.append("g");p.append("text").text(t.config.scaleDotTW.term.name).style("font-weight","bold");const d=b(s.scaleMin).toString();const h=b(s.scaleMax).toString();const m=30;const f=40;const u=16;const g=u*n;const y=u*r;const v=g/2;const x=y/2;const S=o.append("g").attr("transform",`translate(${m},${f})`);const w=30;S.append("path").attr("d",Vt[0]).style("fill","#aaa").style("stroke","#aaa").attr("transform",`translate(${c?-v:-x}, ${c?-v:-x}) scale(${c?n:r})`);const C=o.append("g").attr("transform",`translate(${i+m},${f})`);C.append("path").attr("d",Vt[0]).style("fill","#aaa").style("stroke","#aaa").attr("transform",`translate(${c?-x:-v}, ${c?-x:-v}) scale(${c?r:n})`);S.append("text").attr("x",c?-v-w:-x-w).attr("y",5).style("font-size",".8em").attr("text-anchor","start").text(d);C.append("text").attr("x",c?y+5:g+5).attr("y",5).style("font-size",".8em").text(h);S.append("line").attr("x1",0).attr("y1",c?v:x).attr("x2",i).attr("y2",c?x:v).style("stroke","#aaa");S.append("line").attr("x1",0).attr("y1",c?-v:-x).attr("x2",i).attr("y2",c?-x:-v).style("stroke","#aaa");o.append("rect").attr("width",110*t.zoom).attr("height",50).attr("fill","transparent").on("click",(s=>{const o=new e({padding:"3px"});const i=o.d;i.append("label").text("Min:");const n=i.append("input").attr("type","number").attr("min","1").attr("max","100").style("width","50px").attr("value",t.settings.minShapeSize).on("change",(()=>{let e=parseFloat(n.node().value);if(e<Rt){e=Rt;n.node().value=Rt}t.config.settings.sampleScatter.minShapeSize=e;t.app.dispatch({type:"plot_edit",id:t.id,config:t.config})}));i.append("label").text("Max:");const r=i.append("input").attr("type","number").attr("min","1").attr("max","1000").style("width","50px").attr("value",t.settings.maxShapeSize).on("change",(()=>{let e=parseFloat(r.node().value);if(e>qt){e=qt;r.node().value=qt}t.config.settings.sampleScatter.maxShapeSize=e;t.app.dispatch({type:"plot_edit",id:t.id,config:t.config})}));const c=o.d.append("div");c.append("label").text("Order: ");const p=["Ascending","Descending"];c.selectAll("input").data(p).enter().append("div").style("display","inline-block").each(d);function d(e){const s=a(this);const o=s.append("input").attr("type","radio").attr("id",e).attr("value",e).property("checked",(t=>t==l));s.append("label").text(e).attr("for",e);o.on("change",(e=>{t.config.settings.sampleScatter.scaleDotOrder=e.target.value;c.selectAll("input").nodes().find((t=>t.value!=e.target.value)).checked=false;t.app.dispatch({type:"plot_edit",id:t.id,config:t.config})}))}o.showunder(s.target)}))};t.editColor=function(s,a,o){const i=t.config[a][s.id];const n=new e({padding:"3px"});const r=n.clear().d.append("Label").text("Color:").append("input").attr("type","color").attr("value",c(i).formatHex()).on("change",(()=>{const e=r.node().value;t.changeGradientColor(s,a,o,e);n.hide()}));n.showunder(o.node(),false)};t.changeGradientColor=function(e,s,a,o){const i=c(o).formatHex();t.config[s][e.id]=i;a.style("fill",i);e.colorGenerator=l().range([t.config.startColor[e.id],t.config.stopColor[e.id]]);t.startGradient[e.id].attr("stop-color",t.config.startColor[e.id]);t.stopGradient[e.id].attr("stop-color",t.config.stopColor[e.id]);t.app.dispatch({type:"plot_edit",id:t.id,config:t.config})};t.renderGeneVariantLegend=function(e,s,a,o,i,n,r){const l=125;const p=i.term.name.length>25?i.term.name.slice(0,25)+"...":i.term.name;let d=p;const f=o.append("g").style("font-size","0.9em");f.append("text").attr("id","legendTitle").attr("x",s).attr("y",a).text(d).style("font-weight","bold");s+=l;const u=e.cohortSamples[0]["cat_info"][n];for(const[p,d]of u.entries()){a+=25;const p=d.dt;const u=h[d.origin]?.label;const g=u?`${u[0]} ${m[p]}`:m[p];f.append("text").attr("x",s-l).attr("y",a).text(u?`${u} ${m[p]}`:m[p]).style("font-weight","bold");a+=25;for(const[p,d]of r){if(p=="Ref")continue;if(!p.includes(g))continue;const r=p.split(", ")[0];const h=f.append("g");if(n=="shape"){const t=d.shape%Vt.length;h.append("path").attr("transform",(t=>`translate(${s-l-2}, ${a-8}) scale(0.5)`)).style("fill","gray").attr("d",Vt[t]).style("stroke",c("gray").darker())}else{h.append("path").attr("d",Vt[0]).attr("transform",`translate(${-2}, ${a-8}) scale(0.5)`).style("fill",d.color).style("stroke",c(d.color).darker());h.on("click",(s=>t.onLegendClick(e,o,"colorTW",p,s,d)))}const m=i.q.hiddenValues?p in i.q.hiddenValues:false;f.append("g").append("text").attr("x",s-l+10).attr("y",a).attr("name","sjpp-scatter-legend-label").style("text-decoration",m?"line-through":"none").text(r+(p.includes(g)?`, n=${d.sampleCount}`:"")).on("click",(s=>t.onLegendClick(e,f,n=="shape"?"shapeTW":"colorTW",p,s,d)));a+=25}}return a}}var Wt=Object.freeze({__proto__:null,setRenderers:Ot});function zt(t){t.showTooltip=function(e,s){const a=e.type=="click";t.onClick=a;if(a)t.searchMenu?.hide();if(!(e.target.tagName=="path"&&e.target.getAttribute("name")=="serie")){if(t.onClick&&a){t.onClick=false;t.dom.tooltip.hide();return}if(!a){t.dom.tooltip.hide()}return}const o=e.target.__data__;const i="sample"in o;let n=10;n=n/t.zoom;const r=s.data.samples.filter((e=>{const a=$t(e.x,e.y,o.x,o.y,s);if(!("sampleId"in e)&&(!t.settings.showRef||t.settings.refSize==0))return false;return t.getOpacity(e)>0&&a<n}));r.sort(((e,s)=>{if(!("sampleId"in e))return 1;if(t.config.term){if(e.x<s.x)return-1;if(e.x>s.x)return 1;if(e.y<s.y)return-1;return 1}if(t.config.colorTW){if(t.config.colorTW.term.type=="categorical"){if(e.category.includes(f.WT.label)||e.category.includes(f.Blank.label))return 1}else{if(e.category<s.category)return-1;else if(e.category>s.category)return 1}}if(e.shape.includes(f.WT.label)||e.shape.includes(f.Blank.label))return 1;return-1}));if(r.length==0)return;const l=[];const p=t.config.term?true:false;const d=t=>`${t.x.toPrecision(2)},${t.y.toPrecision(2)}`;for(const t of r){const e=d(t);let s=l.find((t=>t.id==e));if(!s){s={id:e,parentId:null,samples:[t],level:1,category:null,children:[]};l.push(s);if(p){const a=j("x",t);const o={id:a,parentId:e,samples:[t],level:2,category:"X",children:[],value:a};l.push(o);s.children.push(o);const i=j("y",t);const n={id:`${i}${a}`,parent:o,parentId:a,samples:[t],level:3,category:"Y",children:[],value:i};o.children.push(n);l.push(n);s.xnode=o;s.ynode=n}}else{s.samples.push(t);if(p){s.xnode.samples.push(t);s.ynode.samples.push(t)}}}let h=p?4:2;let m=p?["y","x",""]:[""];if(t.config.colorTW)C("category",t.config.colorTW);if(t.config.shapeTW)C("shape",t.config.shapeTW,t.config.colorTW);if(t.config.scaleDotTW)C("scale",t.config.scaleDotTW,t.config.shapeTW);t.dom.tooltip.clear();const u=t.dom.tooltip.d.style("padding","5px");const g=t.state.termdbConfig.queries?.singleSampleGenomeQuantification;const y=t.state.termdbConfig.queries?.singleSampleMutation;if(r.length>1)u.append("div").style("color","#aaa").style("padding","3px").style("font-weight","bold").html(`${r.length} Samples`);const b=u.append("div").style("max-height","400px").style("overflow","scroll");if(r.length>3)b.attr("class","sjpp_show_scrollbar");const v=b.append("table").style("width","100%");const x=l.filter((t=>p?t.level==1:t.level==2));if(p)for(const t of x){if(r.length>1)v.append("tr").append("td").attr("colspan",3).style("border-top","1px solid #aaa");for(const e of t.children){w(e)}}else for(const t of x){if(r.length>1)v.append("tr").append("td").attr("colspan",3).style("border-top","1px solid #aaa");w(t)}t.dom.tooltip.show(e.clientX,e.clientY,true,false);function S(e){const s=e=="category"?t.config.colorTW:e=="shape"?t.config.shapeTW:e=="scale"?t.config.scaleDotTW:e=="X"&&t.config.term?t.config.term:e=="Y"&&t.config.term2?t.config.term2:null;return s}function w(e){const o=S(e.category);e.added=true;let n;const l=e.samples[0];if(l.category!="Ref"){let n=v.append("tr");const p=o!=null&&(o==t.config.colorTW||o==t.config.shapeTW);let d=o?o.term.name:e.category;if(r.length>1&&!i)d=d+` (${e.samples.length})`;n.append("td").style("color","#aaa").text(d);const h=n.append("td");if(p){const i=o==t.config.colorTW?t.getColor(l,s):t.config.colorTW?"gray":t.settings.defaultColor;const r=o==t.config.colorTW?s.shapeLegend.get("Ref").shape%Vt.length:s.shapeLegend.get(l.shape).shape%Vt.length;const p=Vt[r];let m="black";const u=c("white").toString();if(o?.term.type=="geneVariant"&&o.q.type=="values"){for(const t in f){const s=f[t];if(e.value.includes(s.label)){if(c(s.color).toString()!=u)m=s.color;break}}if(a){n.append("td").append("button").text("Lollipop").on("click",(async e=>{await t.openLollipop(d);t.dom.tip.hide()}))}}let g=e.value.toString().length;const y=g*9+60;const b=h.append("svg").attr("width",y).attr("height","25px");const v=b.append("g").attr("transform","translate(10, 14)");v.append("path").attr("d",p).attr("fill",i).attr("stroke","#aaa").attr("transform","translate(0, -2) scale(0.5)");const x=v.append("text").attr("x",12).attr("y",6).attr("font-size","0.9em");x.append("tspan").text(e.value).attr("fill",m)}else h.style("padding","2px").text(`${e.value}`)}for(const t of e.children)if(!t.added)w(t);if(e.children.length==0&&i){for(const s of e.samples){if("info"in s)for(const[t,e]of Object.entries(s.info)){n=v.append("tr");n.append("td").style("color","#aaa").text(t);n.append("td").text(e)}n=v.append("tr");n.append("td").style("color","#aaa").text("Sample");n.append("td").style("padding","2px").text(s.sample);if("sampleId"in s&&a){n.append("td").append("button").text("Sample view").on("click",(e=>t.openSampleView(s)));if(y)n.append("td").append("button").text("Disco").on("click",(async e=>t.openDiscoPlot(s)));if(g)n.append("td").append("button").text("Met Array").on("click",(async e=>t.openMetArray(s)))}}}}function C(t,e,s){for(const a of r){const o=j(t,a,e);let i="";for(const t of m)i+=j(t,a,s);const n=o+i;let r=l.find((t=>t.id==n&&t.parentId==i));let c=l.find((t=>t.id==i));if(!r){r={id:n,parentId:i,samples:[],level:h,category:t,children:[],value:o};l.push(r)}r.samples.push(a);if(c)c.children.push(r)}h++;m.unshift(t)}function j(t,e,s){if(t=="")return"";let a=e[t];if(s?.term.type=="geneVariant"&&s.q.type=="values"){const s=a.split(", ")[0];for(const o in f){const i=f[o];if(s==i.label){const s=e.cat_info[t].find((t=>t.class==i.key)).mname;if(s)a=`${s} ${a}`}}}if(typeof a=="number"&&a%1!=0)a=a.toPrecision(2);return a}};t.openSampleView=function(e){t.dom.tooltip.hide();t.onClick=false;t.app.dispatch({type:"plot_create",id:dt(),config:{chartType:"sampleView",sample:{sampleId:e.sampleId,sampleName:e.sample}}});t.dom.tip.hide()};t.openMetArray=async function(e){t.dom.tooltip.hide();t.onClick=false;e.sample_id=e.sample;for(const s in t.state.termdbConfig.queries.singleSampleGenomeQuantification){const a=u(t.opts.plotDiv);a.header.text(e.sample_id);const o=await import("./plot.ssgq-d33113d5.js");await o.plotSingleSampleGenomeQuantification(t.state.termdbConfig,t.state.vocab.dslabel,s,e,a.body.append("div").style("margin","20px"),t.app.opts.genome)}t.dom.tip.hide()};t.openDiscoPlot=async function(e){t.dom.tooltip.hide();t.onClick=false;e.sample_id=e.sample;const s=u(t.opts.plotDiv);s.header.text(e.sample_id);const a=await import("./plot.disco-1fdfee3c.js");a.default(t.state.termdbConfig,t.state.vocab.dslabel,e,s.body,t.app.opts.genome)};t.openLollipop=async function(e){t.dom.tooltip.hide();t.onClick=false;const s=u(t.opts.plotDiv||select(t.opts.holder.node().parentNode));s.header.text(e);const a={holder:s.body.append("div").style("margin","20px"),genome:t.app.opts.genome,nobox:true,query:e,tklst:[{type:"mds3",dslabel:t.app.opts.state.vocab.dslabel,filter0:t.state.termfilter.filter0,filterObj:structuredClone(t.state.termfilter.filter)}]};const o=await import("./app-6fb77603.js").then((function(t){return t.c3}));await o.default(a)};t.onLegendClick=function(s,a,o,i,n,r){const l=t.config[o];const p=l.q.hiddenValues?i in l.q.hiddenValues:false;const d=new e({padding:"0px"});const h=d.d.append("div");h.append("div").attr("class","sja_menuoption sja_sharp_border").text(p?"Show":"Hide").on("click",(()=>{t.hideCategory(a,l,i,!p);d.hide();const e={};e[o]=l;t.app.dispatch({type:"plot_edit",id:t.id,config:e})}));h.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show only").on("click",(()=>{const e=o=="colorTW"?s.colorLegend:s.shapeLegend;for(const s of e.keys())t.hideCategory(a,l,s,l.term.type=="geneVariant"&&l.q.type=="values"?!s.startsWith(i):s!=i);d.hide();const n={};n[o]=l;t.app.dispatch({type:"plot_edit",id:t.id,config:n})}));h.append("div").attr("class","sja_menuoption sja_sharp_border").text("Show all").on("click",(()=>{d.hide();const e=o=="colorTW"?s.colorLegend:s.shapeLegend;for(const s of e.keys())t.hideCategory(a,l,s,false);const i={};i[o]=l;t.app.dispatch({type:"plot_edit",id:t.id,config:i})}));if(r.color){const e=c(r.color).formatHex();const s=h.append("div").attr("class","sja_sharp_border").style("padding","0px 10px").text("Color:").append("input").attr("type","color").attr("value",e).on("change",(()=>{t.changeColor(i,s.node().value);d.hide()}))}d.showunder(n.target)};t.hideCategory=function(e,s,a,o){if(a=="Ref"){t.settings.showRef=!o;t.app.dispatch({type:"plot_edit",id:t.id,config:{settings:{sampleScatter:t.settings}}})}if(!s.q.hiddenValues)s.q.hiddenValues={};const i=!(s.term.type=="geneVariant"&&s.q.type=="values")&&s.term.values[a]?s.term.values[a]:{key:a,label:a};const n=e.selectAll(`text[name="sjpp-scatter-legend-label"]`).nodes();const r=n.find((t=>a.startsWith(t.innerHTML)))?.parentElement;if(r)r.style["text-decoration"]=o?"line-through":"none";if(!o)delete s.q.hiddenValues[a];else s.q.hiddenValues[a]=i};t.changeColor=async function(e,s){const a=t.config.colorTW;if(!(a.term.type=="geneVariant"&&a.q.type=="values")&&a.term.values[e])a.term.values[e].color=s;else{if(!a.term.values)a.term.values={};a.term.values[e]={key:e,label:e,color:s}}await t.app.dispatch({type:"plot_edit",id:t.id,config:{colorTW:a}})};t.searchSample=async function(s){if(!this.searchMenu){this.searchMenu=new e({padding:"3px"});this.samplesData=await this.app.vocabApi.getSamplesByName({filter:t.state.termfilter.filter});const s=t=>{};q(this.searchMenu.d,this.samplesData,s,(e=>t.filterSamples(e)))}this.searchMenu.show(s.clientX,s.clientY,false)};t.filterSamples=function(e){this.filterSampleStr=e;t.render()};t.getCategoryInfo=function(t,e){if(!(e in t))return"";return t[e]};t.addToFilter=function(e){const s=N(t.state.termfilter.filter,"filterUiRoot");const a=R([s,D(e)]);a.tag="filterUiRoot";t.app.dispatch({type:"filter_replace",filter:a})};t.showTable=function(e,s,a,o){let i=[];const n=[];const r=e.items[0];if("sample"in r)n.push(f("Sample","label"));if(t.config.colorTW)n.push(f(t.config.colorTW.term.name,"label"));if(t.config.shapeTW)n.push(f(t.config.shapeTW.term.name,"label"));let l=false;for(const s of e.items){const e=[];if("sample"in s)e.push(f(s.sample));if(t.config.colorTW)e.push(f(t.getCategoryInfo(s,"category")));if(t.config.shapeTW)e.push(f(t.getCategoryInfo(s,"shape")));if("info"in s){l=true;const t=[];for(const[e,a]of Object.entries(s.info))t.push(`${e}: ${a}`);e.push(f(t.join(", ")))}i.push(e)}if(l)n.push(f("Info","label"));t.dom.tip.clear();const c=t.dom.tip.d.append("div").style("padding","5px");const p=c.append("div").style("margin-top","5px");const d=p.append("div").html(" "+e.name).style("font-size","0.9rem").on("click",(()=>{const s=d.select("input").empty();if(!s)return;d.html("");const a=d.append("input").attr("value",e.name).on("change",(async()=>{const s=a.node().value;if(s)t.renameGroup(e,s);else a.node().value=e.name;d.html(" "+e.name)}));a.node().focus();a.node().select()}));const h=c.append("div");const m=[];if(o){const e={text:"Add to a group",callback:e=>{const s=[];for(const a of e)s.push(t.selectedItems[a].__data__);const a={name:`Group ${t.config.groups.length+1}`,items:s,index:t.config.groups.length};const o=D(k([a]));A(t.app,o,t.state.groups)}};m.push(e)}else{const i={text:"Delete samples",callback:i=>{e.items=e.items.filter(((t,e,s)=>!(e in i)));t.showTable(e,s,a,o)}};m.push(i)}I({rows:i,columns:n,div:h,showLines:true,maxWidth:n.length*"15"+"vw",maxHeight:"35vh",buttons:m,selectAll:true});t.dom.tip.show(s,a,false,false);function f(t,e="value"){let s={};s[e]=t;return s}};t.showGroupMenu=function(e,s){t.dom.tip.clear();t.dom.tip.show(e.clientX,e.clientY,false,true);const a=t.dom.tip.d.append("div");const o=t.config.name?t.config.name:"Summary scatter";const i=k([s],o+" groups");const n=a.append("div").attr("name","sjpp-group-input-div").html(" "+s.name).style("font-size","0.9rem").on("click",(()=>{const e=n.select("input").empty();if(!e)return;n.html("");const a=n.append("input").attr("value",s.name).on("change",(async()=>{const e=a.node().value;if(e)t.renameGroup(s,e);else a.node().value=s.name;n.html(" "+s.name)}));a.node().focus();a.node().select()}));a.append("div").attr("class","sja_menuoption sja_sharp_border").text(`Edit ${s.items.length} samples`).on("click",(a=>{t.dom.tip.hide();t.showTable(s,e.clientX,e.clientY,false)}));t.addCommonMenuItems(a,i);a.append("div").attr("class","sja_menuoption sja_sharp_border").text(`Delete group`).on("click",(async e=>{await t.app.vocabApi.deleteGroup(s.name);t.dom.tip.hide()}));a.append("div").attr("class","sja_menuoption sja_sharp_border").text("Add to filter").on("click",(()=>{t.addToFilter(i);t.app.dispatch({type:"plot_edit",id:t.id,config:{groups:t.config.groups}})}));a.append("div").attr("class","sja_menuoption sja_sharp_border").text(s.showOnly?"Show All":"Show Only").on("click",(()=>{s.showOnly=!s.showOnly;t.app.dispatch({type:"plot_edit",id:t.id,config:{groups:t.config.groups}})}))};t.renameGroup=async function(e,s){const a=t.config.groups.findIndex((t=>t.name==s));if(a!=-1)alert(`Group named ${s} already exists`);else await t.app.dispatch({type:"rename_group",index:e.index,newName:s})};t.addCommonMenuItems=function(e,s){_(t.dom.tip,e,s,t.app,t.id,t.state);if(t.state.supportedChartTypes.includes("survival"))L("survival",e,"Compare survival",t.dom.tip,s,t.id,this);if(t.state.supportedChartTypes.includes("cuminc"))L("cuminc",e,"Compare cumulative incidence",t.dom.tip,s,t.id,this);const a=e.append("div").attr("class","sja_menuoption sja_sharp_border").html("Summarize");a.insert("div").html("›").style("float","right");a.on("click",(async e=>{M(a,(e=>{O(e,s,t.app,t.id)}),t.app,t.dom.tip)}))};t.showGroupsMenu=function(e){t.dom.tip.clear();t.dom.tip.show(e.clientX,e.clientY,false,true);const s=t.dom.tip.d.append("div");const a=t.config.name?t.config.name:"Summary scatter";const o=k(t.config.groups,a+" groups");let i=s.append("div");for(const[a,o]of t.config.groups.entries()){i=s.append("div").attr("class","sja_menuoption sja_sharp_border");i.insert("div").style("display","inline-block").text(` ${o.name}: ${o.items.length} `);i.append("div").style("display","inline-block").style("float","right").html(" ›");i.on("click",(s=>{t.dom.tip.clear().hide();t.showGroupMenu(e,o)}))}t.addCommonMenuItems(s,o);i=s.append("div").attr("class","sja_menuoption sja_sharp_border").text("Delete groups").on("click",(async e=>{for(const e of t.config.groups)await t.app.vocabApi.deleteGroup(e.name);t.app.dispatch({type:"plot_edit",id:t.id,config:{groups:[]}})}))}}function $t(t,e,s,a,o){const i=o.xAxisScale(s)-o.xAxisScale(t);const n=o.yAxisScale(a)-o.yAxisScale(e);const r=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));return r}var It=Object.freeze({__proto__:null,setInteractivity:zt});const Nt={filledCircle:"M 8,8 m 8,0 a 8,8 0 1,0 -16,0 a 8,8 0 1,0 16,0",emptyVerticalRectangle:"M4 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm0 1h8a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1",emptyCircle:"M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16",emptyShield:"M5.338 1.59a61 61 0 0 0-2.837.856.48.48 0 0 0-.328.39c-.554 4.157.726 7.19 2.253 9.188a10.7 10.7 0 0 0 2.287 2.233c.346.244.652.42.893.533q.18.085.293.118a1 1 0 0 0 .101.025 1 1 0 0 0 .1-.025q.114-.034.294-.118c.24-.113.547-.29.893-.533a10.7 10.7 0 0 0 2.287-2.233c1.527-1.997 2.807-5.031 2.253-9.188a.48.48 0 0 0-.328-.39c-.651-.213-1.75-.56-2.837-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524zM5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.8 11.8 0 0 1-2.517 2.453 7 7 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7 7 0 0 1-1.048-.625 11.8 11.8 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 63 63 0 0 1 5.072.56",filledTriangle:"M7.022 1.566a1.13 1.13 0 0 1 1.96 0l6.857 11.667c.457.778-.092 1.767-.98 1.767H1.144c-.889 0-1.437-.99-.98-1.767z",emptyTriangle:"M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016.15.15 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.2.2 0 0 1-.054.06.1.1 0 0 1-.066.017H1.146a.1.1 0 0 1-.066-.017.2.2 0 0 1-.054-.06.18.18 0 0 1 .002-.183L7.884 2.073a.15.15 0 0 1 .054-.057m1.044-.45a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767z",filledShield:"M5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.8 11.8 0 0 1-2.517 2.453 7 7 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7 7 0 0 1-1.048-.625 11.8 11.8 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 63 63 0 0 1 5.072.56",filledDiamond:"M6.95.435c.58-.58 1.52-.58 2.1 0l6.515 6.516c.58.58.58 1.519 0 2.098L9.05 15.565c-.58.58-1.519.58-2.098 0L.435 9.05a1.48 1.48 0 0 1 0-2.098z",largeCross:"M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z",emptyDiamond:"M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z",plusIcon:"M8 2a.5.5 0 0 1 .5.5v5h5a.5.5 0 0 1 0 1h-5v5a.5.5 0 0 1-1 0v-5h-5a.5.5 0 0 1 0-1h5v-5A.5.5 0 0 1 8 2",filledEgg:"M14 10a6 6 0 0 1-12 0C2 5.686 5 0 8 0s6 5.686 6 10",filledPentagon:"M7.685.256a.5.5 0 0 1 .63 0l7.421 6.03a.5.5 0 0 1 .162.538l-2.788 8.827a.5.5 0 0 1-.476.349H3.366a.5.5 0 0 1-.476-.35L.102 6.825a.5.5 0 0 1 .162-.538l7.42-6.03Z",emptyEgg:"M8 15a5 5 0 0 1-5-5c0-1.956.69-4.286 1.742-6.12.524-.913 1.112-1.658 1.704-2.164C7.044 1.206 7.572 1 8 1s.956.206 1.554.716c.592.506 1.18 1.251 1.704 2.164C12.31 5.714 13 8.044 13 10a5 5 0 0 1-5 5m0 1a6 6 0 0 0 6-6c0-4.314-3-10-6-10S2 5.686 2 10a6 6 0 0 0 6 6",emptyPentagon:"M7.685 1.545a.5.5 0 0 1 .63 0l6.263 5.088a.5.5 0 0 1 .161.539l-2.362 7.479a.5.5 0 0 1-.476.349H4.099a.5.5 0 0 1-.476-.35L1.26 7.173a.5.5 0 0 1 .161-.54l6.263-5.087Zm8.213 5.28a.5.5 0 0 0-.162-.54L8.316.257a.5.5 0 0 0-.631 0L.264 6.286a.5.5 0 0 0-.162.538l2.788 8.827a.5.5 0 0 0 .476.349h9.268a.5.5 0 0 0 .476-.35l2.788-8.826Z",filledDiamondSuit:"M2.45 7.4 7.2 1.067a1 1 0 0 1 1.6 0L13.55 7.4a1 1 0 0 1 0 1.2L8.8 14.933a1 1 0 0 1-1.6 0L2.45 8.6a1 1 0 0 1 0-1.2",emptySquare:"M6.95.435c.58-.58 1.52-.58 2.1 0l6.515 6.516c.58.58.58 1.519 0 2.098L9.05 15.565c-.58.58-1.519.58-2.098 0L.435 9.05a1.48 1.48 0 0 1 0-2.098zm1.4.7a.495.495 0 0 0-.7 0L1.134 7.65a.495.495 0 0 0 0 .7l6.516 6.516a.495.495 0 0 0 .7 0l6.516-6.516a.495.495 0 0 0 0-.7L8.35 1.134z",emptyDiamondSuit:"M8.384 1.226a.463.463 0 0 0-.768 0l-4.56 6.468a.54.54 0 0 0 0 .612l4.56 6.469a.463.463 0 0 0 .768 0l4.56-6.469a.54.54 0 0 0 0-.612zM6.848.613a1.39 1.39 0 0 1 2.304 0l4.56 6.468a1.61 1.61 0 0 1 0 1.838l-4.56 6.468a1.39 1.39 0 0 1-2.304 0L2.288 8.92a1.61 1.61 0 0 1 0-1.838z",crossShape:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708",filledSquare:"M0 2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2z"};const Gt=Object.values(Nt);const Rt=.2;const qt=4;const Vt=Gt;class Et{constructor(){this.type="sampleScatter";this.lassoOn=false;this.zoom=1;this.startGradient={};this.stopGradient={}}async init(t){const s=this.opts.holder.insert("div").style("display","inline-block");const o=s.insert("div").style("display","inline-block").attr("class","pp-termdb-plot-controls");this.mainDiv=this.opts.holder.insert("div").style("display","inline-block").style("vertical-align","top");const i=80;this.axisOffset={x:i,y:30};this.dom={header:this.opts.header,loadingDiv:this.opts.holder.append("div").style("position","absolute").style("left","45%").style("top","60%"),tip:new e({padding:"0px"}),tooltip:new e({padding:"2px",offsetX:10,offsetY:0}),controlsHolder:o,toolsDiv:s.insert("div")};this.settings={};if(this.dom.header)this.dom.header.html("Scatter Plot");zt(this);Ot(this);document.addEventListener("scroll",(t=>this?.dom?.tooltip?.hide()));a(".sjpp-output-sandbox-content").on("scroll",(t=>this.dom.tooltip.hide()))}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}const s=W(t);return{config:e,termfilter:t.termfilter,supportedChartTypes:t.termdbConfig.supportedChartTypes[s],matrixplots:t.termdbConfig.matrixplots,vocab:t.vocab,termdbConfig:t.termdbConfig,groups:z(t)}}getDataRequestOpts(){const t=this.config;const e=[];if(t.term)e.push(t.term);if(t.term2)e.push(t.term2);const s={name:t.name,colorTW:t.colorTW,filter:this.getFilter(),coordTWs:e};if(this.state.termfilter.filter0)s.filter0=this.state.termfilter.filter0;if(t.colorColumn)s.colorColumn=t.colorColumn;if(t.shapeTW)s.shapeTW=t.shapeTW;if(t.scaleDotTW){if(!t.scaleDotTW.q)t.scaleDotTW.q={};t.scaleDotTW.q.mode="continuous";s.scaleDotTW=t.scaleDotTW}if(t.term0)s.divideByTW=t.term0;return s}async main(){this.config=structuredClone(this.state.config);if(this.config.settings.sampleScatter.regression!=="None"&&this.config.term0){if(this.charts)for(const t of this.charts)t.chartDiv.selectAll("*").remove();this.dom.loadingDiv.style("display","block").html("Processing data...")}if(this.dom.header)this.dom.header.html(this.config.name+` <span style="opacity:.6;font-size:.7em;margin-left:10px;">SCATTER PLOT</span>`);g(this.settings,this.config.settings.sampleScatter);const t=this.getDataRequestOpts();if(t.coordTWs.length==1)return;const e=await this.app.vocabApi.getScatterData(t);if(e.error)throw e.error;this.charts=[];let s=0;for(const[t,a]of Object.entries(e)){if(!Array.isArray(a.samples))throw"data.samples[] not array";if(a.isLast)this.createChart(t,a,s);else this.createChart(t,a,0)}this.initRanges();this.is3D=this.config.term&&this.config.term0?.q.mode=="continuous";if(!this.config.colorColumn)await this.setControls();await this.processData();this.render();this.dom.loadingDiv.style("display","none");if(!this.is3D)this.setTools();this.dom.tip.hide()}createChart(t,e,s){const a=e.samples.filter((t=>"sampleId"in t));if(a.length>1e4)this.is2DLarge=true;const o=new Map(e.colorLegend);const i=new Map(e.shapeLegend);this.charts.splice(s,0,{id:t,data:e,cohortSamples:a,colorLegend:o,shapeLegend:i})}initRanges(){if(this.charts.length>1){const t=[];for(const e of this.charts)t.push(...e.data.samples);const e=t[0];const[s,a,o,i,n,r,l,c]=t.reduce(((t,e)=>[e.x<t[0]?e.x:t[0],e.x>t[1]?e.x:t[1],e.y<t[2]?e.y:t[2],e.y>t[3]?e.y:t[3],e.z<t[4]?e.z:t[4],e.z>t[5]?e.z:t[5],"scale"in e?e.scale<t[6]?e.scale:t[6]:Number.POSITIVE_INFINITY,"scale"in e?e.scale>t[7]?e.scale:t[7]:Number.NEGATIVE_INFINITY]),[e.x,e.x,e.y,e.y,e.z,e.z,e.scale,e.scale]);for(const t of this.charts){t.xMin=s;t.xMax=a;t.yMin=o;t.yMax=i;t.zMin=n;t.zMax=r;t.scaleMin=l;t.scaleMax=c}}else for(const t of this.charts){if(t.data.samples.length==0)return;const e=t.data.samples[0];const[s,a,o,i,n,r,l,c]=t.data.samples.reduce(((t,e)=>[e.x<t[0]?e.x:t[0],e.x>t[1]?e.x:t[1],e.y<t[2]?e.y:t[2],e.y>t[3]?e.y:t[3],e.z<t[4]?e.z:t[4],e.z>t[5]?e.z:t[5],"scale"in e?e.scale<t[6]?e.scale:t[6]:Number.POSITIVE_INFINITY,"scale"in e?e.scale>t[7]?e.scale:t[7]:Number.NEGATIVE_INFINITY]),[e.x,e.x,e.y,e.y,e.z,e.z,e.scale,e.scale]);t.xMin=s;t.xMax=a;t.yMin=o;t.yMax=i;t.zMin=n;t.zMax=r;t.scaleMin=l;t.scaleMax=c}}async setControls(){this.dom.controlsHolder.selectAll("*").remove();const t=this.charts[0]?.data.samples.find((t=>!("sampleId"in t)))||false;const e={type:"term",configKey:"scaleDotTW",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"numeric"},title:"Scale sample by term value",label:"Scale by",vocabApi:this.app.vocabApi,numericEditMenuVersion:["continuous"]};const s={type:"term",configKey:"shapeTW",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"shapeTW"},title:"Categories to assign a shape",label:"Shape",vocabApi:this.app.vocabApi};const a={label:"Sample size",type:"number",chartType:"sampleScatter",settingsKey:"size",title:"Sample size, represents the factor used to scale the sample",min:0};const o=(qt-Rt)/10;const i={label:"Min size",type:"number",chartType:"sampleScatter",settingsKey:"minShapeSize",title:"Minimum sample size",min:Rt,max:qt,step:o};const n={label:"Max size",type:"number",chartType:"sampleScatter",settingsKey:"maxShapeSize",title:"Maximum sample size",min:Rt,max:qt,step:o};const r={label:"Scale order",type:"radio",chartType:"sampleScatter",settingsKey:"scaleDotOrder",options:[{label:"Ascending",value:"Ascending"},{label:"Descending",value:"Descending"}]};const l={label:"Reference size",type:"number",chartType:"sampleScatter",settingsKey:"refSize",title:"It represents the area of the reference symbol in square pixels",min:0};const c={boxLabel:"Visible",label:"Show axes",type:"checkbox",chartType:"sampleScatter",settingsKey:"showAxes",title:`Option to show/hide plot axes`};const p=[{type:"term",configKey:"colorTW",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"colorTW"},title:"Categories to color the samples",label:"Color",vocabApi:this.app.vocabApi,numericEditMenuVersion:["continuous","discrete"]},{label:"Opacity",type:"number",chartType:"sampleScatter",settingsKey:"opacity",title:"It represents the opacity of the elements",min:0,max:1,step:.1},{label:"Chart width",type:"number",chartType:"sampleScatter",settingsKey:"svgw"},{label:"Chart height",type:"number",chartType:"sampleScatter",settingsKey:"svgh"}];if(this.config.sampleCategory){const t=Object.values(this.config.sampleCategory.tw.term.values).map((t=>({label:t.label||t.key,value:t.key})));if(this.config.sampleCategory.order)t.sort(((t,e)=>{const s=this.config.sampleCategory.order.indexOf(t.value);const a=this.config.sampleCategory.order.indexOf(e.value);if(s<a)return-1;return 1}));if(!this.settings.sampleCategory)this.settings.sampleCategory=this.config.sampleCategory.defaultValue||"";t.push({label:"All",value:""});const e={label:"Sample type",type:"dropdown",chartType:"sampleScatter",settingsKey:"sampleCategory",options:t};p.push(e)}if(!this.is2DLarge){p.unshift({type:"term",configKey:"term0",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"term0"},title:"Categories to divide by",label:this.config.term0?.q?.mode=="continuous"?"Z":"Divide by",vocabApi:this.app.vocabApi,numericEditMenuVersion:this.app.hasWebGL?.()?["discrete","continuous"]:["discrete"],processInput:t=>{if(t?.term.type=="integer"||t?.term.type=="float")t.q={mode:"continuous"}}})}else{p.push({label:"Sample size",type:"number",chartType:"sampleScatter",settingsKey:"threeSize",title:"Sample size",min:0,max:1,step:.001}),p.push({label:"Field of Vision",type:"number",chartType:"sampleScatter",settingsKey:"threeFOV",title:"Field of Vision",min:50,max:90,step:1})}if(this.config.term){p.unshift(...[{type:"term",configKey:"term",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"numeric"},title:"X coordinate to plot the samples",label:"X",vocabApi:this.app.vocabApi,menuOptions:"!remove",numericEditMenuVersion:["continuous"]},{type:"term",configKey:"term2",chartType:"sampleScatter",usecase:{target:"sampleScatter",detail:"numeric"},title:"Y coordinate to plot the samples",label:"Y",vocabApi:this.app.vocabApi,menuOptions:"!remove",numericEditMenuVersion:["continuous"]}]);if(!this.is3D){p.splice(4,0,s);p.splice(5,0,e);if(this.config.scaleDotTW){p.splice(6,0,i);p.splice(7,0,n);p.splice(8,0,r);if(t)p.splice(9,0,l)}else{p.splice(6,0,a);if(t)p.splice(7,0,l)}p.push({label:"Show regression",type:"dropdown",chartType:"sampleScatter",settingsKey:"regression",options:[{label:"None",value:"None"},{label:"Lowess",value:"Lowess"},{label:"Polynomial",value:"Polynomial"}]})}else{p.push({label:"Chart depth",type:"number",chartType:"sampleScatter",settingsKey:"svgd"});p.push({label:"Field of vision",title:"Camera field of view, in degrees",type:"number",chartType:"sampleScatter",settingsKey:"fov"})}p.push(c);p.push({label:"Default color",type:"color",chartType:"sampleScatter",settingsKey:"defaultColor"})}else if(!this.is2DLarge){p.splice(2,0,s);p.splice(3,0,e);if(this.config.scaleDotTW){p.splice(4,0,i);p.splice(5,0,n);p.splice(6,0,r);if(t)p.splice(7,0,l)}else{p.splice(4,0,a);if(t)p.splice(5,0,l)}p.push(c)}this.components={controls:await x({app:this.app,id:this.id,holder:this.dom.controlsHolder,inputs:p})};this.components.controls.on("downloadClick.scatter",(()=>{if(this.is2DLarge||this.is3D){const t=this.canvas.toDataURL("image/png");Ft(t)}else for(const t of this.charts)E(t.svg,"scatter.svg",this.opts.holder.node())}))}getFilter(){const t={type:"tvslst",in:true,join:"and",lst:[]};const e="sampleCategory"in this.settings?this.settings.sampleCategory:this.config.sampleCategory?.defaultValue;if(e){const s=this.config.sampleCategory.tw;t.lst.push({type:"tvs",tvs:{term:s.term,values:[{key:e}]}})}const s=[this.state.termfilter.filter,t];if(this.config.filter)s.push(this.config.filter);const a=R(s);return a}}function Pt(t,e,s=null){let a={chartType:"sampleScatter",name:e.name,filter:s};if(e.sampleCategory)a.sampleCategory={tw:structuredClone(e.sampleCategory.tw),order:e.sampleCategory.order,defaultValue:e.sampleCategory.defaultValue};if(e.sampleType)a.sampleType=e.sampleType;if(e.colorTW)a.colorTW=structuredClone(e.colorTW);else if(e.colorColumn)a.colorColumn=structuredClone(e.colorColumn);if("shapeTW"in e)a.shapeTW=structuredClone(e.shapeTW);if(e.settings)a.settings=structuredClone(e.settings);t.dispatch({type:"plot_create",config:a})}function Ft(t){const e=document.createElement("a");e.setAttribute("download","image");document.body.appendChild(e);e.click();e.remove();e.href=t;e.click();e.remove()}async function Ht(t,e){try{if(t.colorTW)await v(t.colorTW,e.vocabApi);if(t.shapeTW)await v(t.shapeTW,e.vocabApi);if(t.term)await v(t.term,e.vocabApi);if(t.term2)await v(t.term2,e.vocabApi);if(t.term0)await v(t.term0,e.vocabApi);if(t.scaleDotTW)await v(t.scaleDotTW,e.vocabApi);if(t.sampleCategory)await v(t.sampleCategory.tw,e.vocabApi);let s=Yt();if(t.settings)g(s,t.settings);if(!t.term&&!t.term2)s.showAxes=false;const a={groups:[],settings:{controls:{isOpen:false},sampleScatter:s},startColor:{},stopColor:{}};const o=g(a,t);if(o.term0?.q?.mode=="continuous"&&!e.hasWebGL())throw"Can not load Z/Divide by term in continuous mode as WebGL is not supported";return o}catch(t){console.log(t);throw`${t} [sampleScatter getPlotConfig()]`}}const Ut=t(Et);const Bt=Ut;function Kt(t,e){const s=t.append("div");if(e.state.termdbConfig.scatterplots)for(const t of e.state.termdbConfig.scatterplots){s.append("div").attr("class","sja_menuoption sja_sharp_border").text(t.name).on("click",(()=>{Pt(e.app,t);e.dom.tip.hide()}))}s.append("div");if(!e.state.termdbConfig.hiddenChartTypes?.includes("dynamicScatter")){const t=(t,s)=>{e.app.dispatch({type:"plot_create",config:{chartType:"sampleScatter",term:{term:t,q:{mode:"continuous"}},term2:{term:s,q:{mode:"continuous"}},name:`${t.name} vs ${s.name}`}})};V(e.dom.tip,e.app,"sampleScatter","numeric",t)}}function Yt(){return{size:1,minShapeSize:.5,maxShapeSize:4,scaleDotOrder:"Ascending",refSize:.8,svgw:500,svgh:500,svgd:500,axisTitleFontSize:16,showAxes:true,showRef:true,opacity:.8,defaultColor:y,regression:"None",fov:50,threeSize:.002,threeFOV:70}}async function Jt(t,e,s){const a={holder:t,state:{vocab:e.vocab,plots:[{chartType:"sampleScatter",subfolder:"plots",name:s.name,colorTW:s.colorTW,sampleType:s.sampleType,sampleCategory:{tw:structuredClone(s.sampleCategory.tw),order:s.sampleCategory.order,defaultValue:s.sampleCategory.defaultValue}}]}};const o=await import("./plot.app-2a805759.js");await o.appInit(a)}var Xt=Object.freeze({__proto__:null,minShapeSize:Rt,maxShapeSize:qt,shapes:Vt,openScatterPlot:Pt,downloadImage:Ft,getPlotConfig:Ht,scatterInit:Ut,componentInit:Bt,makeChartBtnMenu:Kt,getDefaultScatterSettings:Yt,renderScatter:Jt});export{It as a,Xt as b,Yt as g,mt as n,Wt as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as t}from"./tslib.es6-c3c2d88f.js";import{s as e}from"./termsetting-492eefa7.js";import{getHandler as i}from"./categorical-1dea48ba.js";import{P as r}from"./app-6fb77603.js";import"path";import"./groupsetting-e3a4ecd5.js";function s(e){return t(this,void 0,void 0,(function*(){return i(e)}))}function o(t,i,s=null){var o,p;if(!((o=t.term)===null||o===void 0?void 0:o.sample))throw"missing term.sample";if(!((p=t.term)===null||p===void 0?void 0:p.plot))throw"missing term.plot";if(!Object.keys(t.q).includes("type"))t.q.type="values";if(!t.term.groupsetting)t.term.groupsetting={disabled:false};if(t.q.type=="predefined-groupset"){if(!Number.isInteger(t.q.predefined_groupset_idx))throw"predefined_groupset_idx is not an integer"}if(t.q.type=="custom-groupset"){if(!t.q.customset)throw"invalid customset"}if(s){s.isAtomic=true;r(t.q,s)}e(t.q,t.term)}export{o as fillTW,s as getHandler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as t,y as e,F as s,h as o,P as i,M as n,d as l,C as a,I as r,r as p,Q as c}from"./app-6fb77603.js";import{d}from"./zoom-f445cfef.js";import{r as h}from"./table-0daf2b89.js";import{controlsInit as g}from"./controls-268e40e6.js";import{d as m}from"./svg.download-f4aa48e4.js";import{a as f}from"./genesearch-ffd88bf2.js";import{T as y,c as u}from"./termsetting-492eefa7.js";import{a as b,b as v,c as x}from"./axis-747c801e.js";import"./pointer-c7475677.js";import"./nodrag-b2737073.js";import"./tslib.es6-c3c2d88f.js";import"./controls.btns-5bf9e7d7.js";import"./controls.config-2f0fa061.js";import"path";class C{constructor(){this.type="singleCellPlot";this.tip=new n({padding:"4px",offsetX:10,offsetY:0});this.tip.d.style("max-height","300px").style("overflow","scroll").style("font-size","0.9em");this.startGradient={};this.stopGradient={}}async init(e){const s=this.getState(e);const o=s.termdbConfig.queries;this.tableOnPlot=e.nav?.header_mode=="hidden";this.opts.holder.style("position","relative");this.showDivId=`${this.id}-sandbox`;const i=this.opts.holder.insert("div").style("display","inline-block").style("vertical-align","top");const a=i.append("div").style("padding","10px");const r=i.append("div");const p=a.append("div").attr("id",this.showDivId);const c=a.append("div").style("padding-top","10px").style("display","inline-block");if(this.tableOnPlot){p.append("input").attr("id",`showSamples`).attr("type","checkbox").property("checked",true).on("change",(t=>{this.app.dispatch({type:"plot_edit",id:this.id,config:{settings:{singleCellPlot:{showSamples:t.target.checked}}}})}));p.append("label").text("Show samples").attr("for",`showSamples`)}for(const t of s.config.plots){const e=t.name.replace(/\s+/g,"");p.append("input").attr("id",`show${e}`).attr("type","checkbox").property("checked",true).on("change",(t=>{this.app.dispatch({type:"plot_edit",id:this.id,config:{settings:{singleCellPlot:{[`show${e}`]:t.target.checked}}}})}));p.append("label").text(t.name).attr("for",`show${e}`)}if(o.singleCell?.geneExpression){c.append("label").html("Gene expression:");const t=f({tip:new n({padding:"0px"}),genome:this.app.opts.genome,row:c,searchOnly:"gene",placeholder:s.config.gene||"Gene",callback:()=>{o?.style("display","inline-block");e?.style("display","inline-block");const s=t.geneSymbol;this.app.dispatch({type:"plot_edit",id:this.id,config:{gene:s}})},emptyInputCallback:()=>{o.style("display","none");e.style("display","none");this.app.dispatch({type:"plot_edit",id:this.id,config:{gene:null}})},hideHelp:true,focusOff:true});const e=c.append("select").style("display",s.config.gene?"inline-block":"none");for(const t of s.termdbConfig?.queries.singleCell.data.plots){e.append("option").text(t.colorColumn)}e.on("change",(async()=>{const t=s.termdbConfig?.queries.singleCell.data.plots[0];const o=t.columnName;const i={sample:s.config.sample.sampleName,columnName:o,category:e.node().value};await this.app.vocabApi.getTopTermsByType(i)}));const o=c.append("button").text("Open violin").style("margin-left","2px").style("display",s.config.gene?"inline-block":"none");o.on("click",(()=>{const o=t.geneSymbol||s.config.gene;const i=this.state.config.plots.find((t=>t.colorColumn==e.node().value)).name;const n=this.plots.find((t=>t.name==i));const l={};for(const t of n.clusters){l[t]={key:t,value:t}}this.app.dispatch({type:"plot_create",config:{chartType:"violin",settings:{violin:{plotThickness:50}},term:{term:{type:y.SINGLECELL_GENE_EXPRESSION,id:o,gene:o,name:o,sample:s.config.sample}},term2:{term:{type:y.SINGLECELL_CELLTYPE,id:y.SINGLECELL_CELLTYPE,name:"Cell type",sample:s.config.sample,plot:n.name,values:l}}}})}))}const d=a.append("div").style("padding","10px").style("display","inline-block");const g=i.append("div").style("display","inline-block").attr("class","pp-termdb-plot-controls");const m=i.append("div").style("display","inline-block");const b=m.append("div").style("display","flex").style("flex-wrap","wrap").style("justify-content","flex-start").style("width","92vw");const v=this.opts.holder.append("div").style("position","absolute").style("top",0).style("left",0).style("width","100%").style("height","100%").style("background-color","rgba(255, 255, 255, 0.8)").style("text-align","center");v.append("div").attr("class","sjpp-spinner");this.dom={header:this.opts.header,mainDiv:i,loadingDiv:v,tip:new n({padding:"0px"}),tooltip:new n({padding:"2px",offsetX:10,offsetY:0}),controlsHolder:g,tableDiv:r,deDiv:d,plotsDiv:b,plotsDivParent:m};const x=80;this.axisOffset={x:x,y:30};if(o.singleCell?.DEgenes){this.dom.deDiv.append("label").html("View differentially expresed genes of a cluster vs rest of cells: ");this.dom.deselect=this.dom.deDiv.append("select");if(this.app.opts.genome.termdbs)this.dom.GSEAbt=this.dom.deDiv.append("button").style("margin-left","5px").property("disabled",true).text("Gene set enrichment analysis").on("click",(t=>{const e={genes:this.genes,fold_change:this.fold_changes,genome:this.app.vocabApi.opts.state.vocab.genome};const s={chartType:"gsea",gsea_params:e,insertBefore:this.app.opts?.app?.getPlotHolder&&this.showDivId};this.app.dispatch({type:"plot_create",config:s})}));const e=this.dom.deDiv.append("div");this.dom.DETableDiv=e;this.dom.deselect.append("option").text("");this.dom.deselect.on("change",(async o=>{e.selectAll("*").remove();const i=this.dom.deselect.node().value.split(" ")?.[1];if(this.dom.GSEAbt)this.dom.GSEAbt.property("disabled",!i);if(!i)return;const n=s.termdbConfig.queries.singleCell.DEgenes.columnName;const l=this.state.config.experimentID||this.state.config.sample||this.samples[0]?.experiments[0]?.experimentID;const a={genome:s.genome,dslabel:s.dslabel,categoryName:i,sample:l,columnName:n};const r=await t("termdb/singlecellDEgenes",{body:a});const p=[{label:"Gene"},{label:"Log2FC"},{label:"Adjusted P-value"}];const c=[];this.genes=[];this.fold_changes=[];r.genes.sort(((t,e)=>e.avg_log2FC-t.avg_log2FC));for(const t of r.genes){const e=[{value:t.name},{value:u(t.avg_log2FC)},{value:u(t.p_val_adj)}];c.push(e);this.genes.push(t.name);this.fold_changes.push(t.avg_log2FC)}h({rows:c,columns:p,resize:true,div:e})}))}this.settings={};document.addEventListener("scroll",(t=>this?.tip?.hide()));l(".sjpp-output-sandbox-content").on("scroll",(t=>this.tip.hide()));await this.setControls(s)}async setControls(t){const e=[{label:"Chart width",type:"number",chartType:"singleCellPlot",settingsKey:"svgw",min:300,max:1e3},{label:"Chart height",type:"number",chartType:"singleCellPlot",settingsKey:"svgh",min:300,max:1e3},{label:"Show borders",type:"checkbox",chartType:"singleCellPlot",settingsKey:"showBorders",boxLabel:""}];if(this.tableOnPlot)e.push({label:"Show samples",type:"checkbox",chartType:"singleCellPlot",settingsKey:"showSamples",boxLabel:""});this.components={controls:await g({app:this.app,id:this.id,holder:this.dom.controlsHolder,inputs:e})};this.components.controls.on("downloadClick.singleCellPlot",(()=>{for(const t of this.plots)m(t.svg,"plot.svg",this.opts.holder.node())}))}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}this.prevFilter0=this.state?.termfilter.filter0;return{config:e,dslabel:t.vocab.dslabel,genome:t.vocab.genome,termdbConfig:t.termdbConfig,termfilter:t.termfilter}}async main(){this.config=structuredClone(this.state.config);i(this.settings,this.config.settings.singleCellPlot);this.dom.tableDiv.style("display",this.settings.showSamples?"block":"none");if(this.tableOnPlot){await D(this.dom.tableDiv,this,this.state);if(!this.samples?.length){this.showNoMatchingDataMessage();return}}this.dom.loadingDiv.selectAll("*").remove();this.dom.loadingDiv.style("display","").append("div").attr("class","sjpp-spinner");this.dom.mainDiv.style("opacity",1).style("display","");this.legendRendered=false;const t=await this.getData();this.dom.plotsDivParent.style("display","inline-block");this.renderPlots(t);this.dom.loadingDiv.style("display","none");if(this.dom.header)this.dom.header.html(`Single Cell Data`)}async getData(){const s=[];for(const t of this.config.plots){const e=t.name.replace(/\s+/g,"");const o=this.settings[`show${e}`];if(o)s.push(t.name)}const o={genome:this.state.genome,dslabel:this.state.dslabel,plots:s,filter0:this.state.termfilter.filter0};if(this.state.config.sample){this.state.config.sample;o.sample=this.state.config.experimentID||this.state.config.sample}else{this.samples[0].sample;o.sample=this.samples[0].experiments?.[0]?.experimentID||this.samples[0].sample}if(this.state.config.gene)o.gene=this.state.config.gene;try{const e=await t("termdb/singlecellData",{body:o});if(e.error)throw e.error;this.refName=e.refName;return e}catch(t){if(t.stack)console.log(t.stack);e(this.dom.plotsDiv,t);return}}showNoMatchingDataMessage(){this.dom.mainDiv.style("opacity",.001).style("display","none");this.dom.loadingDiv.style("display","").html("");this.dom.loadingDiv.append("div").style("display","inline-block").style("text-align","center").style("position","relative").style("left","-150px").style("font-size","1.2em").style("margin","2em 1em").html("No matching cohort data.")}renderPlots(t){this.dom.plotsDiv.selectAll("*").remove();this.plots=[];for(const e of t.plots){e.id=e.name.replace(/\s+/g,"");this.renderPlot(e)}}renderPlot(t){const e={};let s=new Set(t.cells.map((t=>t.category)));t.clusters=Array.from(s).sort(((t,e)=>{const s=parseInt(t.split(" ")[1]);const o=parseInt(e.split(" ")[1]);return s-o}));if(this.dom.deselect&&!this.legendRendered){this.dom.deselect.selectAll("*").remove();this.dom.deselect.append("option").text("");for(const e of t.clusters)this.dom.deselect.append("option").text(e)}const o=a(t.clusters.length+2);for(const s of t.clusters)e[s]=s=="ref"||s=="No"?"#F2F2F2":t.colorMap?.[s]?t.colorMap[s]:o(s);t.colorMap=e;this.plots.push(t);this.initAxes(t);t.plotDiv=this.dom.plotsDiv.append("div").style("overflow","hidden").style("display","inline-block").style("padding","10px").style("flex-grow",1);if(this.state.config.settings.singleCellPlot.showBorders)t.plotDiv.style("border","1px solid #aaa");this.renderLegend(t);const i=t.plotDiv.append("svg").attr("width",this.settings.svgw).attr("height",this.settings.svgh+40).on("mouseover",(e=>{if(this.state.config.gene&&!this.onClick)this.showTooltip(e,t)})).on("click",(e=>this.showTooltip(e,t)));i.append("text").attr("transform",`translate(20, 30)`).style("font-weight","bold").text(`${t.name}`);t.svg=i;const n=d().scaleExtent([.5,5]).on("zoom",(e=>this.handleZoom(e,t))).filter((t=>{if(t.type==="wheel")return t.ctrlKey;return true}));i.call(n);const l=i.selectAll("g").data(t.cells);l.enter().append("g").attr("transform",(e=>`translate(${t.xAxisScale(e.x)}, ${t.yAxisScale(e.y)+40})`)).append("circle").attr("r",1.5).attr("fill",(e=>this.getColor(e,t))).style("fill-opacity",(t=>this.getOpacity(t)))}getOpacity(t){if(this.config.hiddenClusters.includes(t.category))return 0;return.7}getColor(t,e){const s="#FAFAFA";if(this.state.config.gene){if(!t.geneExp)return s;if(e.colorGenerator)return e.colorGenerator(t.geneExp);return s}return e.colorMap[t.category]}handleZoom(t,e){e.svg.attr("transform",t.transform);e.zoom=t.transform.scale(1).k}initAxes(t){if(!t.cells.length)return;const e=t.cells[0];const[s,o,i,n]=t.cells.reduce(((t,e)=>[e.x<t[0]?e.x:t[0],e.x>t[1]?e.x:t[1],e.y<t[2]?e.y:t[2],e.y>t[3]?e.y:t[3]]),[e.x,e.x,e.y,e.y]);const l=5;t.xAxisScale=r().domain([s,o]).range([0+l,this.settings.svgh+l]);t.axisBottom=b(t.xAxisScale);t.yAxisScale=r().domain([n,i]).range([0+l,this.settings.svgh+l]);t.axisLeft=v(t.yAxisScale);t.zoom=1}renderLegend(t){const e=t.colorMap;let s=t.legendSVG;if(!t.legendSVG){s=t.plotDiv.append("svg").attr("width",250).attr("height",this.settings.svgh).style("vertical-align","top");t.legendSVG=s}s.selectAll("*").remove();if(this.state.termdbConfig.queries.singleCell.data.sameLegend&&this.legendRendered)return;this.legendRendered=true;const o=s.append("g").attr("transform",`translate(25, 50)`).style("font-size","0.8em");if(this.state.config.gene){this.renderColorGradient(t,o);return}o.append("text").attr("transform",`translate(${0}, ${25})`).style("font-weight","bold").text(`${t.colorBy}`);const i=20;let n=50;let l=0;for(const s in e){const r=t.cells.filter((t=>t.category==s));const p=this.config.hiddenClusters.includes(s);const c=r.length;const d=e[s];const h=o.append("g").attr("transform",(t=>`translate(${l}, ${n})`));h.append("circle").attr("r",3).attr("fill",d);h.append("g").attr("transform",`translate(${l+10}, ${5})`).append("text").text(`${s=="ref"?this.state.termdbConfig.queries.singleCell.data.refName:s=="query"?this.state.config.sample:s} n=${c}`).style("text-decoration",p?"line-through":"none").on("click",(t=>a(this,t,s)));n+=i}function a(t,e,s,o){const i=e.target;const n=i.style["text-decoration"]=="line-through";i.style["text-decoration"]=n?"none":"line-through";let l=t.config.hiddenClusters;if(!n)l.push(s);else l.splice(l.indexOf(s),1);t.app.dispatch({type:"plot_edit",id:t.id,config:{hiddenClusters:l}})}}renderColorGradient(t,e){if(t.cells.length==0)return;const s=p(c);if(!this.config.startColor[t.name])this.config.startColor[t.name]=s.brighter(1).toString();if(!this.config.stopColor[t.name])this.config.stopColor[t.name]=s.darker(3).toString();const o=this.config.startColor[t.name];const i=this.config.stopColor[t.name];const n=e.append("defs").append("linearGradient").attr("id",`linear-gradient-${t.id}`).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");this.startGradient[t.name]=n.append("stop").attr("offset","0%").attr("stop-color",o);this.stopGradient[t.name]=n.append("stop").attr("offset","100%").attr("stop-color",i);let l,a;const d=t.cells[0]?.geneExp==undefined?[]:t.cells.map((t=>t.geneExp));if(d.length==0){t.colorGenerator=null;return}else[l,a]=d.reduce(((t,e)=>[e<t[0]?e:t[0],e>t[1]?e:t[1]]),[d[0],d[0]]);t.colorGenerator=r().domain([l,a]).range([o,i]);const h=100;const g=r().domain([l,a]).range([0,h]);const m=(a-l)/4;const f=[l,l+m,l+2*m,l+3*m,a];const y=x(g).tickValues(f);e.append("g").attr("transform",`translate(0, 100)`).call(y);t.startRect=e.append("rect").attr("x",-25).attr("y",100).attr("width",20).attr("height",20).style("fill",o).on("click",(e=>this.editColor(t,"startColor",t.startRect)));t.stopRect=e.append("rect").attr("x",h+5).attr("y",100).attr("width",20).attr("height",20).style("fill",i).on("click",(e=>this.editColor(t,"stopColor",t.stopRect)));e.append("rect").attr("x",0).attr("y",100).attr("width",h).attr("height",20).style("fill",`url(#linear-gradient-${t.id})`)}editColor(t,e,s){const o=this.config[e][t.name];const i=new n({padding:"3px"});const l=i.clear().d.append("Label").text("Color:").append("input").attr("type","color").attr("value",p(o).formatHex()).on("change",(()=>{const o=l.node().value;this.changeGradientColor(t,e,s,o);i.hide()}));i.showunder(s.node(),false)}changeGradientColor=function(t,e,s,o){this.config[e][t.name]=o;this.app.dispatch({type:"plot_edit",id:this.id,config:this.config})};distance(t,e,s,o,i){const n=i.xAxisScale(s)-i.xAxisScale(t);const l=i.yAxisScale(o)-i.yAxisScale(e);const a=Math.sqrt(Math.pow(n,2)+Math.pow(l,2));return a}showTooltip(t,e){if(this.onClick&&t.type=="click"){this.onClick=false;this.tip.hide();return}if(t.target.tagName=="circle"){this.onClick=t.type=="click";const s=t.target.__data__;const o=this.tip.clear();const i=o.d.append("table");let n=i.append("tr");n.append("td").style("color","#aaa").text(e.colorBy);const l=n.append("td");const a=l.append("svg").attr("width",150).attr("height",20);const r=10;const p=12;const c=a.append("g").attr("transform",`translate(${r}, ${p})`);c.append("circle").attr("fill",this.getColor(s,e)).attr("r",4);a.append("g").attr("transform",`translate(${r+15}, ${p+4})`).append("text").text(s.category);if("geneExp"in s){n=i.append("tr");n.append("td").style("color","#aaa").text("Gene expression");n.append("td").text(u(s.geneExp))}o.show(t.clientX,t.clientY,true,true)}else this.onMouseOut(t)}onMouseOut(t){this.tip.hide()}}async function w(t,e){const s=t.append("div").style("padding","5px");D(s,e,e.state)}async function D(o,i,n){const l={genome:n.genome,dslabel:n.dslabel,filter0:n.termfilter.filter0||null};let a;try{a=await t("termdb/singlecellSamples",{body:l});if(a.error)throw a.error}catch(t){e(o,t);return}const r=a.samples;i.samples=r;if(i.tableOnPlot){if(r.length==0){i.dom.plotsDiv.selectAll("*").remove();return}if(i.table&&s(i.state.termfilter.filter0,i.prevFilter0))return}o.selectAll("*").remove();r.sort(((t,e)=>{const s=t.primarySite?.localeCompare(e.primarySite);if(s==1||s==-1)return s;else return t.sample.localeCompare(e.sample)}));const[p,c]=await k(i,r,n);const d=[];let g="40vh";if(i.tableOnPlot){const t=i.config.sample;const e=i.samples.findIndex((e=>e.sample==t));const s=e==-1?0:e;d.push(s);g="30vh"}i.table=h({rows:p,columns:c,resize:true,singleMode:true,div:o,maxHeight:g,noButtonCallback:t=>{if(i.dom.DETableDiv){i.dom.deselect.node().value="";i.dom.DETableDiv.selectAll("*").remove();if(i.dom.GSEAbt)i.dom.GSEAbt.property("disabled",true)}const e=p[t][0].value;const s={chartType:"singleCellPlot",sample:e};if(p[t][0].__experimentID){s.experimentID=p[t][0].__experimentID}if(i.tableOnPlot){i.app.dispatch({type:"plot_edit",id:i.id,config:s})}else{i.dom.tip.hide();i.app.dispatch({type:"plot_create",config:s})}},selectedRows:d})}async function k(t,e,s){const o=[];for(const t of e){if(t.experiments)for(const e of t.experiments){const i=[{value:t.sample,__experimentID:e.experimentID}];for(const e of s.termdbConfig.queries.singleCell.samples.sampleColumns||[]){i.push({value:t[e.termid]})}for(const e of s.termdbConfig.queries.singleCell.samples.experimentColumns||[]){i.push({value:t[e.label]})}i.push({value:e.experimentID});o.push(i)}else{const e=[{value:t.sample}];for(const o of s.termdbConfig.queries.singleCell.samples.sampleColumns||[]){e.push({value:t[o.termid]})}o.push(e)}}const i=[{label:s.termdbConfig.queries.singleCell.samples.firstColumnName||"Sample"}];for(const e of s.termdbConfig.queries.singleCell.samples.sampleColumns||[]){i.push({label:(await t.app.vocabApi.getterm(e.termid)).name,width:"15vw"})}for(const t of s.termdbConfig.queries.singleCell.samples.experimentColumns||[]){i.push({label:t.label,width:"20vw"})}if(e.some((t=>t.experiments))){i.push({label:"Experiment"})}return[o,i]}const S=o(C);const A=S;async function _(t,e){try{const s=e.vocabApi.termdbConfig?.queries?.singleCell.data.plots;const o=E();for(const t of s){const e=t.name.replace(/\s+/g,"");const s=`show${e}`;o[s]=true}const n={hiddenClusters:[],settings:{singleCellPlot:o},startColor:{},stopColor:{},plots:s};const l=i(n,t);return l}catch(t){console.log(t);throw`${t} [singleCellPlot getPlotConfig()]`}}function E(){return{svgw:420,svgh:420,showBorders:false,showSamples:true}}export{A as componentInit,E as getDefaultSingleCellSettings,_ as getPlotConfig,w as makeChartBtnMenu,S as scatterInit};
|
package/dist/snp-f6123244.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as s}from"./tslib.es6-c3c2d88f.js";import{M as t}from"./app-6fb77603.js";import{a as o}from"./genesearch-ffd88bf2.js";class r{init(s){this.callback=s.callback;const r=o({tip:new t({padding:"0px"}),genome:s.genomeObj,row:s.holder,searchOnly:"snp",allowVariant:true,callback:()=>this.selectSnp(r)})}selectSnp(t){return s(this,void 0,void 0,(function*(){const{chr:s,ref:o,alt:r,fromWhat:a}=t;if(!s||!o||!r||!a)throw"missing chr, ref, alt, or fromWhat of snp";let e,i;if(!t.start&&!t.stop){if(t.pos){e=t.pos-1;i=t.pos}else{throw"missing coordinate of snp"}}else{e=t.start;i=t.stop}const n={id:a,chr:s,start:e,stop:i,name:a,ref:o,alt:typeof r=="string"?[r]:r,type:"snp"};this.callback(n)}))}}export{r as SearchHandler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as t}from"./tslib.es6-c3c2d88f.js";import{mayRestrictAncestry as e,makeSnpSelect as i}from"./snplst-6865d7c7.js";import{f as r}from"./FilterStateless-16a33070.js";import{g as n}from"./FilterRxComp-02e68f1b.js";import"./termsetting-492eefa7.js";import"./app-6fb77603.js";import{a as s}from"./genesearch-ffd88bf2.js";import"./snplst.sampleSum-e47d05f0.js";import"./table-0daf2b89.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-39d11f24.js";import"path";const a="Variants in a locus";function o(e){return{getPillName(){return e.term.name},getPillStatus(){if(!e.term||!e.q)return;if(!e.term.snps)throw`Missing term.snps [snplocs.ts getPillStatus()]`;let t=`${e.q.chr}:${e.q.start}-${e.q.stop}, ${e.term.snps.length} variant${e.term.snps.length>1?"s":""}`;if(e.term.reachedVariantLimit){t+='<span style="margin-left: 6px; background:#aaa; font-size:1em;font-style: normal; border-radius: 7px;color:white;padding:0px 5px;">⚠<span>'}return{text:t}},validateQ(t){d(t)},showEditMenu(i){return t(this,void 0,void 0,(function*(){yield l(e,i)}))}}}function l(r,o){var l;return t(this,void 0,void 0,(function*(){const d=o.append("div").style("margin","15px");const c=yield e(r,d);const u=s({genome:r.opts.genomeObj,tip:r.dom.tip2,row:d.append("div").style("margin-top","20px"),defaultCoord:r.q&&r.q.chr?{chr:r.q.chr,start:r.q.start,stop:r.q.stop}:undefined});d.select(".sja_genesearchinput").style("margin","0px");d.append("span").style("margin","5px 0px").style("display","inline-block").style("opacity",.4).style("font-size",".7em").html('"Gene": Gene name (e.g. AKT1)</br>"Position": chr:start-stop (e.g. chr1:5000-6000)</br>"dbSNP": dbSNP accession (e.g. rs1042522)');yield f(r,(l=r.q)===null||l===void 0?void 0:l.variant_filter,d);const[v,h,y]=i(d.append("div").attr("class","sjpp-snp-select").style("margin-top","15px"),r,"snplocus");if(r.usecase.target=="dataDownload")d.select(".sjpp-snp-select").style("display","none");const g=d.append("div").style("margin-top","15px");g.append("button").style("margin-top","15px").text("Submit").on("click",(e=>t(this,void 0,void 0,(function*(){if(!u.chr)return window.alert("Invalid coordinate");e.target.disabled=true;e.target.innerHTML="Validating input...";if(r.term);else{r.term={id:m()}}if(!r.q)r.q={};r.term.type="snplocus";r.q.chr=u.chr;r.q.start=u.start;r.q.stop=u.stop;r.term.name=a;delete r.term.snps;r.q.variant_filter=n(r.variantFilter.active);yield p(r);{const t=Number(v.property("value"));r.q.AFcutoff=t<0||t>=100?5:t}r.q.alleleType=h.property("selectedIndex");r.q.geneticModel=y.property("selectedIndex");if(c){r.q.restrictAncestry=c.node().options[c.property("selectedIndex")].__ancestry_obj}r.runCallback()}))));g.append("span").style("padding-left","15px").style("opacity",.8).style("font-size",".8em").text(r.usecase.target=="dataDownload"?"":"Variants will be treated individually in separate regression models")}))}function p(e){return t(this,void 0,void 0,(function*(){const t=yield e.vocabApi.validateSnps(e.q);if(t.error)throw t.error;e.q.cacheid=t.cacheid;e.term.snps=t.snps;e.term.reachedVariantLimit=t.reachedVariantLimit}))}function d(t){const e=t.q;if(!Number.isFinite(e.AFcutoff))throw"AFcutoff is not number";if(e.AFcutoff<0||e.AFcutoff>100)throw"AFcutoff is not within 0 to 100";if(![0,1].includes(e.alleleType))throw"alleleType value is not one of 0/1";if(![0,1,2,3].includes(e.geneticModel))throw"geneticModel value is not one of 0/1";if(!e.chr)throw"chr missing";if(!Number.isInteger(e.start))throw"start coordinate is not integer";if(!Number.isInteger(e.stop))throw"stop coordinate is not integer";if(e.start<0)throw"start < 0";if(e.stop<=e.start)throw"stop <= start"}function c(e,i){return t(this,void 0,void 0,(function*(){try{d(e)}catch(t){throw"snplocus validateQ(): "+t}if(!e.term.name)e.term.name=a;if(e.id==undefined||e.id==""){if(e.term.id==undefined||e.term.id==""){e.term.id=m()}e.id=e.term.id}else{if(e.term.id==undefined||e.term.id==""){e.term.id=e.id}}yield p({term:e.term,q:e.q,vocabApi:i})}))}function m(){return"snplocus"+Math.random()}function f(e,i,n,s){return t(this,void 0,void 0,(function*(){if(!e.variantFilter){e.variantFilter=yield e.vocabApi.get_variantFilter()}if(!e.variantFilter.terms){return}if(!e.variantFilter.opts)throw"variantFilter.opts{} missing";if(!e.variantFilter.filter)throw".filter missing from variantFilter{}";if(!Array.isArray(e.variantFilter.terms)||e.variantFilter.terms.length==0)throw"variantFilter.terms[] is not non-empty array";if(i){e.variantFilter.active=JSON.parse(JSON.stringify(i))}else{e.variantFilter.active=JSON.parse(JSON.stringify(e.variantFilter.filter))}const a=n.append("div").style("margin-top","15px");a.append("span").text("VARIANT FILTERS").style("font-size",".8em").style("opacity",.5);const o=a.append("div");r({joinWith:e.variantFilter.opts.joinWith,emptyLabel:"+Variant Filter",holder:o,vocab:{terms:e.variantFilter.terms},callback:i=>t(this,void 0,void 0,(function*(){e.variantFilter.active=i;if(s)yield s()}))}).main(e.variantFilter.active)}))}export{c as fillTW,o as getHandler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{bX as e,bV as n}from"./app-6fb77603.js";function o(o){let t=0;for(let f=1;f<o.length;f++){const i=o[f];const r=o[t];if(i.isskipexon&&r.isaltexon){t=f;continue}if(i.frame==e&&r.framenocheck){t=f;continue}if(i.frame==n&&r.frame!=n){t=f;continue}}return t}export{o as e};
|
package/dist/summary-a6c15c9e.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as t,P as e,M as i}from"./app-6fb77603.js";import{f as o,i as s}from"./termsetting-492eefa7.js";import{r}from"./recover-299ffdb3.js";import{getDefaultViolinSettings as a}from"./violin-74d26b75.js";import{getDefaultBarSettings as n}from"./barchart-2898d229.js";import{g as l}from"./sampleScatter-55d9eb74.js";import{T as p}from"./toggleButtons-c4d6f260.js";import"./tslib.es6-c3c2d88f.js";import"path";import"./FilterRxComp-02e68f1b.js";import"./table-0daf2b89.js";import"./partjson.esm-b3f1fc21.js";import"./termdb.bins-39d11f24.js";import"./FilterStateless-16a33070.js";import"./app-d215327f.js";import"./termInfo-491b10af.js";import"./genesearch-ffd88bf2.js";import"./checkbox-96437f4d.js";import"./rehydrateFilter-12d118cb.js";import"./controls-268e40e6.js";import"./controls.btns-5bf9e7d7.js";import"./controls.config-2f0fa061.js";import"./violin.renderer-469fa0ff.js";import"./brush-9faa7ae7.js";import"./pointer-c7475677.js";import"./nodrag-b2737073.js";import"./axis-747c801e.js";import"./line-264f8f9e.js";import"./constant-426a1483.js";import"./basis-3870f5ba.js";import"./log-c26b6cfd.js";import"./html.legend-80b2b3ec.js";import"./violin.interactivity-bf40ddde.js";import"./niceNumLabels-29a7c6ca.js";import"./bars.settings-64bb4642.js";import"./bars.renderer-71935d34.js";import"./svg.legend-749348e0.js";import"./barchart.events-426d737a.js";import"./zoom-f445cfef.js";import"./lasso-1a02a545.js";import"./drag-2e9c80bb.js";import"./downloadTextfile-5723af95.js";import"./sampleView-1dff3fca.js";import"./select2Terms-d48d037e.js";import"./svg.download-f4aa48e4.js";import"./sampleScatter.rendererThree-ef289434.js";class c{constructor(t){this.type="summary";this.components={recover:{},plots:{}};this.chartsByType={}}async init(t){const e=this.getState(t);const i=structuredClone(e.config);m(this);this.initUi(this.opts,i);this.components.recover=await r({app:this.app,holder:this.dom.localRecoverDiv,getState:t=>this.getState(t),reactsTo:t=>t.id==this.id&&t.type=="plot_edit"&&t._scope_!="none",plot_id:this.id,maxHistoryLen:10,margin:"5px 10px"})}reactsTo(t){if(t.type.includes("cache_termq"))return true;if(t.type.startsWith("plot_")){return t.id===this.id}if(t.type.startsWith("filter"))return true;if(t.type.startsWith("cohort"))return true;if(t.type=="app_refresh")return true}getState(t){const e=t.plots.find((t=>t.id===this.id));if(!e){throw`No plot with id='${this.id}' found. Did you set this.id before this.api = getComponentApi(this)?`}return{config:e,_scope_:t._scope_}}async main(){this.dom.errdiv.style("display","none");this.config=structuredClone(this.state.config);if(!this.components.plots[this.config.childType]){await this.setComponent(this.config)}for(const t in this.components.plots){this.components.plots[t]}this.render();const t=this.tabsData.findIndex((t=>t.childType==this.config.childType));this.chartToggles.update(t,this.config);const e=this.tabsData.filter((t=>t.isVisible())).length;if(e>1)this.dom.chartToggles.style("display","inline-block");else this.dom.chartToggles.style("display","none")}async setComponent(t){let e;if(t.childType=="barchart")e=await import("./barchart-2898d229.js");else if(t.childType=="violin")e=await import("./violin-74d26b75.js");else if(t.childType=="table")e=await import("./table-bf40249b.js");else if(t.childType=="boxplot")e=await import("./boxplot-4c9a5479.js");else if(t.childType=="sampleScatter")e=await import("./sampleScatter-55d9eb74.js").then((function(t){return t.b}));else throw`unsupported childType='${t.childType}'`;this.dom.plotDivs[t.childType]=this.dom.viz.append("div");this.components.plots[t.childType]=await e.componentInit({app:this.app,holder:this.dom.plotDivs[t.childType],id:this.id,parent:this.api})}destroy(){this.dom.holder.app_div.selectAll("*").remove();this.dom.holder.app_div.remove();for(const t in this.dom){delete this.dom[t]}}}const d=t(c);function m(t){t.initUi=function(e,o){const r=e.holder;try{t.dom={tip:new i({padding:"0px"}),holder:r,body:r.body.style("white-space","nowrap").style("overflow-x","auto"),errdiv:r.body.append("div").style("display","none").style("padding","5px").style("background-color","rgba(255,100,100,0.2)"),viz:r.body.append("div"),plotDivs:{}};r.header.style("padding",0);t.dom.paneTitleDiv=t.dom.holder.header.append("div").style("display","inline-block").style("color","#999").style("padding-left","7px");t.dom.paneTitleDiv.append("div").classed("sjpp-term-header",true).style("display","inline-block").style("vertical-align","sub").html(o.term.term.name);t.tabsData=[{childType:"barchart",label:"Barchart",isVisible:()=>true,disabled:t=>false,getConfig:async()=>{if(!t.config)return;const e={id:t.id,childType:"barchart"};const i=t.config?.term;const o=t.config?.term2;if(i){const o=s(i?.term)?"discrete":i?.q.mode||"discrete";e.term=await t.getWrappedTermCopy(i,o)}if(o){const i=s(o.term)?"discrete":o.q.mode||"discrete";e.term2=await t.getWrappedTermCopy(o,i)}return e},active:true,callback:t.tabClickCallback},{childType:"violin",label:"Violin",disabled:t=>false,isVisible:()=>s(t.config?.term?.term)||s(t.config?.term2?.term),getConfig:async()=>{const e=t.config?.term;const i=t.config.term2;let o,r;s(e?.term)?t.violinContTerm="term":t.violinContTerm="term2";if(t.violinContTerm&&t.violinContTerm==="term"||e.q?.mode=="continuous"){o=await t.getWrappedTermCopy(e,"continuous");r=await t.getWrappedTermCopy(i,"discrete");t.violinContTerm="term"}else if(t.violinContTerm&&t.violinContTerm==="term2"||i?.q?.mode=="continuous"){o=await t.getWrappedTermCopy(e,"discrete");r=await t.getWrappedTermCopy(i,"continuous");t.violinContTerm="term2"}else if(i?.q?.mode=="discrete"){o=await t.getWrappedTermCopy(e,"discrete");r=await t.getWrappedTermCopy(i,"continuous");t.violinContTerm="term2"}else{o=await t.getWrappedTermCopy(e,"continuous");r=await t.getWrappedTermCopy(i,"discrete");t.violinContTerm="term"}const a={childType:"violin",term:o,term2:r};return a},active:false,callback:t.tabClickCallback},{childType:"table",label:"Crosstab - in development",disabled:t=>true,isVisible:()=>false,active:false,callback:t.tabClickCallback},{childType:"boxplot",label:"Boxplot - TODO",disabled:t=>true,isVisible:()=>false,active:false,callback:t.tabClickCallback},{childType:"sampleScatter",label:"Scatter",disabled:t=>false,isVisible:()=>s(t.config?.term.term)&&s(t.config?.term2?.term),getConfig:async()=>{const e=await t.getWrappedTermCopy(t.config?.term,"continuous");const i=await t.getWrappedTermCopy(t.config?.term2,"continuous");let o={childType:"sampleScatter",term:e,term2:i,groups:[],term0:t.config.term0};return o},active:false,callback:t.tabClickCallback}];t.dom.chartToggles=t.dom.paneTitleDiv.append("div").style("display","inline-block").style("margin-left","10px");t.chartToggles=new p({holder:t.dom.chartToggles,tabs:t.tabsData,noContent:true});t.chartToggles.main();t.dom.localRecoverDiv=t.dom.paneTitleDiv.append("div").style("display","inline-block")}catch(t){throw t}};t.tabClickCallback=async(e,i)=>{if(!i||!i.getConfig)return;const o=await i.getConfig();if(o)t.app.dispatch({type:"plot_edit",id:t.id,config:o})};t.getWrappedTermCopy=async function(e,i){if(!e)return;const s=structuredClone(e);s.q.mode=i;await o(s,t.app.vocabApi);return s};t.render=function(){for(const e in t.components.plots){const i=t.components.plots[e];if(i.type!=t.config.childType){t.dom.plotDivs[i.type].style("display","none")}}t.dom.plotDivs[t.config.childType].style("display","")}}async function f(t,i){if(!t.term)throw"summary getPlotConfig: opts.term{} missing";try{await o(t.term,i.vocabApi);if(t.term2)await o(t.term2,i.vocabApi);if(t.term0)await o(t.term0,i.vocabApi)}catch(t){throw`${t} [summary getPlotConfig()]`}const s={chartType:"summary",childType:"barchart",term:t.term,groups:[],settings:{controls:{isOpen:false},common:{use_logscale:false,use_percentage:false,barheight:300,barwidth:20,barspace:2},barchart:n(i),violin:a(),sampleScatter:l()},mayAdjustConfig(t,e={}){if(!e.childType){if(t.term?.q?.mode=="continuous"&&t.term2?.q?.mode=="continuous"){t.childType="sampleScatter"}else if(t.term?.q?.mode=="continuous"||t.term2?.q?.mode=="continuous")t.childType="violin";else t.childType="barchart"}}};return e(s,t)}export{f as getPlotConfig,d as summaryInit};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{V as t,C as s,H as e,W as n}from"./app-6fb77603.js";function i(t){const s=t;if(!s||typeof s!=="object")throw"bin schema must be an object";if(!("type"in s))s.type="regular-bin";if(s.type=="custom-bin"){if(!Array.isArray(s.lst))throw"binconfig.lst must be an array";if(!s.lst.length)throw"binconfig.lst must have entries";const t=s.lst[0];const n=s.lst[s.lst.length-1];for(const i of s.lst){if(!("startinclusive"in i)&&!("stopinclusive"in i)){throw"custom bin.startinclusive and/or bin.stopinclusive must be defined"}if(i==t){if("startunbounded"in i&&!i.startunbounded){throw`a custom first bin must not set bin.startunbounded to false`}i.startunbounded=true;if("start"in i){throw"a custom first bin must not set a bin.start value"}if("start_percentile"in i){throw"the first bin must not set a bin.start_percentile value"}if(!("stop"in i)){throw`a custom first bin must define a bin.stop value`}if(!e(i.stop)){throw`a custom first bin.stop value should be numeric`}}else if(i==n){if(!("start"in i)){throw`a custom last bin must define a bin.start value`}if(!e(i.start)){throw`a custom last bin.start must be numeric`}if("stopunbounded"in i&&!i.stopunbounded){throw"a custom last bin must not set bin.stopunbounded to false"}i.stopunbounded=true;if("stop"in i){throw"a custom last bin must not set a bin.stop value"}}else{if(!e(i.start))throw"bin.start must be numeric for a non-first bin";if(!e(i.stop))throw"bin.stop must be numeric for a non-last bin"}}}else if(s.type=="regular-bin"){if(!Number.isFinite(s.bin_size))throw"non-numeric bin_size";if(s.bin_size<=0)throw"bin_size must be greater than 0";if(!s.startinclusive&&!s.stopinclusive){s.startinclusive=1;s.stopinclusive=0}if(!s.first_bin)throw"first_bin{} missing";if(typeof s.first_bin!="object")throw"first_bin{} is not an object";if(!Object.keys(s.first_bin).length)throw"first_bin is an empty object";{const t=s.first_bin;t.startunbounded=true;if(t.stop_percentile){if(!Number.isInteger(t.stop_percentile))throw"first_bin.stop_percentile should be integer";if(t.stop_percentile<=0||t.stop_percentile>=100)throw"first_bin.stop_percentile out of bound (0-100)"}else if(!Number.isFinite(t.stop)){throw"first_bin.stop not a number when stop_percentile is not set"}}if(s.last_bin){const t=s.last_bin;if(t.start_percentile){if(!Number.isInteger(t.start_percentile))throw"last_bin.start_percentile should be integer";if(t.start_percentile<=0||t.start_percentile>=100)throw"last_bin.start_percentile out of bound (0-100)"}else if(!Number.isFinite(t.start)){throw"last_bin.start not a number when start_percentile is not set"}t.stopunbounded=true;if("stop"in t){throw"a regular last bin must not set a bin.stop value"}}}else{throw`invalid binconfig.type="${s.type}"`}}function o(t,n,o){const l=t;i(l);if(l.lst){const t=s(l.lst.length);for(const s of l.lst)s.color=t(s.label)}if(l.type=="custom-bin")return JSON.parse(JSON.stringify(l.lst));if(typeof n!="function")throw"summaryfxn required for modules/termdb.bins.js compute_bins()";const b=u(l);const c=n(b);if(!c||typeof c!=="object")throw"invalid returned value by summaryfxn";l.results={summary:c};if(!l.binLabelFormatter)l.binLabelFormatter=r(l);const f=Math.floor(c.min*100)/100;const p=Math.ceil(c.max*100)/100;const _=l.first_bin.startunbounded?f:l.first_bin.start_percentile?c["p"+l.first_bin.start_percentile]:l.first_bin.start;let d=p,m,h;if(l.last_bin){d=l.last_bin.stopunbounded?p:l.last_bin.stop_percentile?c["p"+l.last_bin.stop_percentile]:e(l.last_bin.stop)&&l.last_bin.stop<=c.max?l.last_bin.stop:p;m=e(l.last_bin.start_percentile)?c["p"+l.last_bin.start_percentile]:e(l.last_bin.start)?l.last_bin.start:undefined;h=l.last_bin.stopunbounded?null:l.last_bin.stop_percentile?c["p"+l.last_bin.stop_percentile]:e(l.last_bin.stop)?l.last_bin.stop:null}else if(l.lst){const t=l.lst[l.lst.length-1];m=t.start;h="stop"in t&&!t.stopunbounded?t.stop:p;d=h}else{m=p;h=p}const v=e(d);const g=e(m);const w=e(h);if(!v&&!g)return[];const y=[];let F={startunbounded:l.first_bin.startunbounded,start:l.first_bin.startunbounded?undefined:_,stop:e(l.first_bin.stop_percentile)?+c["p"+l.first_bin.stop_percentile]:e(l.first_bin.stop)?+l.first_bin.stop:_+l.bin_size,startinclusive:l.startinclusive,stopinclusive:l.stopinclusive};if(!e(F.stop))throw"the computed first_bin.stop is non-numeric"+F.stop;const U=100;while(v&&F.stop<=d||F.startunbounded&&!y.length||F.stopunbounded){y.push(F);if(F.stop>=d){F.stopunbounded=true;if(y.length>1){delete F.stop}}F.label=a(F,l,o);if(F.stopunbounded)break;const t=F.stop+l.bin_size;const s=F.stop;F={startinclusive:l.startinclusive,stopinclusive:l.stopinclusive,start:s,stop:w&&(s==m||t>h)?h:g&&t>m&&s!=m?m:t};if(F.stop>=d){F.stop=d;if(l.last_bin&&l.last_bin.stopunbounded)F.stopunbounded=1;if(l.last_bin&&l.last_bin.stopinclusive)F.stopinclusive=1}if(g&&F.start==m){if(l.last_bin&&l.last_bin.stopunbounded)F.stopunbounded=1}if(F.start>F.stop){if(g&&F.stop==m&&l.last_bin&&l.last_bin.stopunbounded)F.stopunbounded=true;else break}if(y.length+1>=U){l.error="max_num_bins_reached";break}}delete l.binLabelFormatter;if(y.length>1){delete y[y.length-1].stop}const L=s(y.length);for(const t of y)t.color=L(t.label);return y}function r(t){return"rounding"in t?n(t.rounding):t=>t}function a(s,e,n){const i=e;if(!i.binLabelFormatter)i.binLabelFormatter=r(i);if(!s.startunbounded&&!s.stopunbounded&&!("startinclusive"in s)&&!("stopinclusive"in s)){if(i.startinclusive)s.startinclusive=true;else if(i.stopinclusive)s.stopinclusive=true}const o=i.use_as=="bins"||s.start;const a=i.use_as=="bins"||s.stop;let l=0;if("label_offset"in i){i.label_offset_ignored="bin_size"in i&&i.bin_size<i.label_offset;if(!i.label_offset_ignored)l=i.label_offset}else if(i.bin_size===1&&i.termtype=="integer"){l=1}if(s.startunbounded){const e=s.stopinclusive?"≤":"<";const o=n?t(a,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(a);return e+o}if(s.stopunbounded||o===a){const e=s.startinclusive?"≥":">";const r=n?t(o,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(o);return e+r}if(l&&s.startinclusive&&!s.stopinclusive){if(Number.isInteger(i.bin_size)&&Math.abs(o-a)===l){return""+(n?t(o,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(o))}else{const s=n?t(o,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(o);const e=n?t(a-l,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(a-l);return+s>=+e?s.toString():s+" to "+e}}else{const e=s.startinclusive?"":">";const r=s.stopinclusive?"":"<";const l=n?t(o,n.fromUnit,n.toUnit,n.scaleFactor,true):Number.isInteger(o)?o:i.binLabelFormatter(o);const u=n?t(a,n.fromUnit,n.toUnit,n.scaleFactor,true):Number.isInteger(a)?a:i.binLabelFormatter(a);if(+l>=+u){const t=s.startinclusive?"≥":">";return t+l}else{return e+l+" to "+r+u}}}function l(t,s){const e='<span style="font-family:Times;font-style:italic;">x</span>';let n;const i=a(t,s);if(t.startunbounded||t.stopunbounded){n=e+" "+i}else if(t.startinclusive){n=i.replace("to <","≤ "+e+" <")}else if(t.stopinclusive){n=i.replace(">","").replace("to","< "+e+" ≤")}return n}function u(t){const s=[];const n=t.first_bin;if(n&&e(n.start_percentile))s.push(n.start_percentile);if(n&&e(n.stop_percentile))s.push(n.stop_percentile);const i=t.last_bin;if(i&&e(i.start_percentile))s.push(i.start_percentile);if(i&&e(i.stop_percentile))s.push(i.stop_percentile);return s}export{l as a,o as c,a as g};
|