@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.
Files changed (232) hide show
  1. package/dist/{2dmaf-f240211f.js → 2dmaf-dbeff225.js} +1 -1
  2. package/dist/{AppHeader-c9432a24.js → AppHeader-1fc7f7bd.js} +1 -1
  3. package/dist/{ColorScale-b991fc9e.js → ColorScale-23c17654.js} +1 -1
  4. package/dist/{DEanalysis-bbfad00d.js → DEanalysis-a3cf1900.js} +1 -1
  5. package/dist/{Disco-b7c9bf72.js → Disco-b26a0556.js} +1 -1
  6. package/dist/{Disco.UI-a5296c36.js → Disco.UI-891c4c35.js} +1 -1
  7. package/dist/{DragControls-ca3fa0cf.js → DragControls-2fabac26.js} +1 -1
  8. package/dist/{DziViewer-28915c11.js → DziViewer-5b830c31.js} +1 -1
  9. package/dist/FilterRxComp-fb608459.js +1 -0
  10. package/dist/FilterStateless-fc4e4e1b.js +1 -0
  11. package/dist/{HicApp-e713aa40.js → HicApp-5ed85d49.js} +1 -1
  12. package/dist/{OrbitControls-2466d420.js → OrbitControls-604f40af.js} +1 -1
  13. package/dist/{WSIViewer-957695a8.js → WSIViewer-dcce2a10.js} +1 -1
  14. package/dist/{adSandbox-27d93bc0.js → adSandbox-5fa90964.js} +1 -1
  15. package/dist/app-0de0ae35.js +1 -0
  16. package/dist/{app-d215327f.js → app-7f695ce7.js} +1 -1
  17. package/dist/app-977b083f.js +1 -0
  18. package/dist/app.js +1 -1
  19. package/dist/{bam-d67e5315.js → bam-06a5a6a2.js} +1 -1
  20. package/dist/{barchart-2898d229.js → barchart-978fb21a.js} +1 -1
  21. package/dist/{barchart.events-426d737a.js → barchart.events-9b482604.js} +1 -1
  22. package/dist/{bars.renderer-71935d34.js → bars.renderer-d7461d5d.js} +1 -1
  23. package/dist/{block-75d4ff92.js → block-3db9c74c.js} +1 -1
  24. package/dist/block.lazyload-19a55cac.js +1 -0
  25. package/dist/{block.legend-93d85a6e.js → block.legend-97401467.js} +1 -1
  26. package/dist/{block.mds-84b9d1c1.js → block.mds-dc409568.js} +1 -1
  27. package/dist/{block.mds.cnv-a991ed79.js → block.mds.cnv-cdabd3f6.js} +1 -1
  28. package/dist/{block.mds.expressionrank-33b858de.js → block.mds.expressionrank-d768640f.js} +1 -1
  29. package/dist/{block.mds.expressionstat-3093599f.js → block.mds.expressionstat-7e40426f.js} +1 -1
  30. package/dist/{block.mds.geneboxplot-b8391d18.js → block.mds.geneboxplot-dae9cfa3.js} +1 -1
  31. package/dist/{block.mds.junction-69708c7f.js → block.mds.junction-3bc8baea.js} +1 -1
  32. package/dist/{block.mds.svcnv-322baea6.js → block.mds.svcnv-456dc845.js} +1 -1
  33. package/dist/{block.mds.svcnv.share-c5c38237.js → block.mds.svcnv.share-4776459b.js} +1 -1
  34. package/dist/{block.mds2-de4811dd.js → block.mds2-cc586d9d.js} +1 -1
  35. package/dist/{block.svg-ac9fec2d.js → block.svg-adf47e3a.js} +1 -1
  36. package/dist/{block.tk.aicheck-ac4b8d4d.js → block.tk.aicheck-f284f080.js} +1 -1
  37. package/dist/{block.tk.ase-6dc0f9f1.js → block.tk.ase-0477c9f4.js} +1 -1
  38. package/dist/{block.tk.bam-8f68b41d.js → block.tk.bam-d4c998d4.js} +1 -1
  39. package/dist/{block.tk.bedgraphdot-d8878860.js → block.tk.bedgraphdot-0177d836.js} +1 -1
  40. package/dist/{block.tk.bigwig.ui-f6ed051c.js → block.tk.bigwig.ui-95531269.js} +1 -1
  41. package/dist/{block.tk.hicstraw-725bdc8a.js → block.tk.hicstraw-06e97317.js} +1 -1
  42. package/dist/{block.tk.junction-f8b0b51d.js → block.tk.junction-18b6b825.js} +1 -1
  43. package/dist/{block.tk.junction.textmatrixui-252e7d7e.js → block.tk.junction.textmatrixui-ffdbdf81.js} +1 -1
  44. package/dist/{block.tk.ld-11acf730.js → block.tk.ld-2b56500f.js} +1 -1
  45. package/dist/{block.tk.menu-5e04436d.js → block.tk.menu-707a4226.js} +1 -1
  46. package/dist/{block.tk.pgv-fef17dc4.js → block.tk.pgv-63c956c4.js} +1 -1
  47. package/dist/{boxplot-4c9a5479.js → boxplot-1f229616.js} +1 -1
  48. package/dist/{brainImaging-7716bc66.js → brainImaging-a0c72fad.js} +1 -1
  49. package/dist/{brush-9faa7ae7.js → brush-4c775f74.js} +1 -1
  50. package/dist/{categorical-1dea48ba.js → categorical-25b06bc5.js} +1 -1
  51. package/dist/{condition-ebac4f75.js → condition-70084a85.js} +1 -1
  52. package/dist/{controls-268e40e6.js → controls-1f3ac9d0.js} +1 -1
  53. package/dist/controls.btns-5b44e5d0.js +1 -0
  54. package/dist/{controls.config-2f0fa061.js → controls.config-b0339f96.js} +1 -1
  55. package/dist/{cuminc-8dffb765.js → cuminc-6d1de932.js} +1 -1
  56. package/dist/{customdata.inputui-b229d3a0.js → customdata.inputui-5ad0f25c.js} +1 -1
  57. package/dist/{dataDownload-452ae3cd.js → dataDownload-a60d80e4.js} +1 -1
  58. package/dist/databrowser.ui-a5c8194c.js +1 -0
  59. package/dist/{density-09feb0c9.js → density-30dbad8b.js} +1 -1
  60. package/dist/{dictionary-a132a3cc.js → dictionary-d8435ddc.js} +1 -1
  61. package/dist/{drag-2e9c80bb.js → drag-ad04f964.js} +1 -1
  62. package/dist/{e2pca-4f1648e3.js → e2pca-02adebbd.js} +1 -1
  63. package/dist/{ep-1d4c58b4.js → ep-b2e464fe.js} +1 -1
  64. package/dist/{facet-fa4fe49c.js → facet-e7612200.js} +1 -1
  65. package/dist/{filter-b3d3964e.js → filter-67d51c09.js} +1 -1
  66. package/dist/{fusion.parse-7dfd6988.js → fusion.parse-68670e99.js} +1 -1
  67. package/dist/{geneExpClustering-ed9121b8.js → geneExpClustering-d96c27ef.js} +1 -1
  68. package/dist/geneExpression-072e0be1.js +1 -0
  69. package/dist/{geneExpression-394672ff.js → geneExpression-4901955e.js} +1 -1
  70. package/dist/{geneExpression-66208299.js → geneExpression-65346c08.js} +1 -1
  71. package/dist/{geneORA-9456872c.js → geneORA-e3d6619e.js} +1 -1
  72. package/dist/geneVariant-9fc29f37.js +1 -0
  73. package/dist/{geneVariant-beaf9adb.js → geneVariant-f6bbc247.js} +1 -1
  74. package/dist/{genefusion.ui-9238ec7f.js → genefusion.ui-a5a08183.js} +1 -1
  75. package/dist/{genesearch-ffd88bf2.js → genesearch-5fa13afa.js} +1 -1
  76. package/dist/{geneset-0315daf8.js → geneset-c36036bd.js} +1 -1
  77. package/dist/genomeBrowser-d4515002.js +1 -0
  78. package/dist/{genomeBrowser.controls-2601cab5.js → genomeBrowser.controls-b89629b0.js} +1 -1
  79. package/dist/{groupsetting-e3a4ecd5.js → groupsetting-a3de9ec7.js} +1 -1
  80. package/dist/{gsea-0c0cf8de.js → gsea-af1a7cec.js} +1 -1
  81. package/dist/{hierCluster-7ab62ca5.js → hierCluster-8aa2265a.js} +1 -1
  82. package/dist/hierCluster.config-11a176e2.js +1 -0
  83. package/dist/{hierCluster.interactivity-7f475259.js → hierCluster.interactivity-103b2f0f.js} +1 -1
  84. package/dist/{hierCluster.renderers-19b79639.js → hierCluster.renderers-48bdf7a6.js} +1 -1
  85. package/dist/{html.legend-80b2b3ec.js → html.legend-455f7881.js} +1 -1
  86. package/dist/{imagePlot-1ef24562.js → imagePlot-862c7baf.js} +1 -1
  87. package/dist/{lasso-1a02a545.js → lasso-e12204af.js} +1 -1
  88. package/dist/launch.adhoc-b8af0ace.js +1 -0
  89. package/dist/leftlabel.sample-784c5aeb.js +1 -0
  90. package/dist/{legacyDataset-fbaa5ebb.js → legacyDataset-501a0298.js} +1 -1
  91. package/dist/{log-c26b6cfd.js → log-d560d2a5.js} +1 -1
  92. package/dist/{lollipop-3aebe5d3.js → lollipop-aa25084e.js} +1 -1
  93. package/dist/{maf-c439c851.js → maf-13befc91.js} +1 -1
  94. package/dist/{maftimeline-0da64e54.js → maftimeline-f9ee156e.js} +1 -1
  95. package/dist/{matrix-38cd47c3.js → matrix-971b44da.js} +1 -1
  96. package/dist/{matrix.cells-a018d731.js → matrix.cells-92037b17.js} +1 -1
  97. package/dist/{matrix.cluster-a6e713e8.js → matrix.cluster-0bca59fd.js} +1 -1
  98. package/dist/{matrix.config-2c550b5d.js → matrix.config-b8d8faef.js} +1 -1
  99. package/dist/matrix.controls-07c6128c.js +1 -0
  100. package/dist/{matrix.data-2b814c9f.js → matrix.data-1090f6c7.js} +1 -1
  101. package/dist/{matrix.dom-1e0da5b3.js → matrix.dom-1154156c.js} +1 -1
  102. package/dist/{matrix.groups-824a7244.js → matrix.groups-f10a8c05.js} +1 -1
  103. package/dist/{matrix.interactivity-1cb56534.js → matrix.interactivity-99de0399.js} +1 -1
  104. package/dist/{matrix.layout-47e44357.js → matrix.layout-405db70f.js} +1 -1
  105. package/dist/{matrix.legend-9af0c757.js → matrix.legend-d06de359.js} +1 -1
  106. package/dist/{matrix.renderers-337ce240.js → matrix.renderers-2211c4b2.js} +1 -1
  107. package/dist/{matrix.serieses-7b7184c9.js → matrix.serieses-f0803a76.js} +1 -1
  108. package/dist/{matrix.sort-1ac05842.js → matrix.sort-3d376f1a.js} +1 -1
  109. package/dist/{matrix.sorterUi-1c60c145.js → matrix.sorterUi-469ed804.js} +1 -1
  110. package/dist/{mavb-da8d1a0a.js → mavb-e5cbd894.js} +1 -1
  111. package/dist/{mds.fimo-8604c3f8.js → mds.fimo-f9215ef6.js} +1 -1
  112. package/dist/{mds.samplescatterplot-3f09ae0e.js → mds.samplescatterplot-6fce6594.js} +1 -1
  113. package/dist/{mds.survivalplot-1d8f2b7e.js → mds.survivalplot-16e9e8c5.js} +1 -1
  114. package/dist/{metaboliteIntensity-bbb23c76.js → metaboliteIntensity-b47fb792.js} +1 -1
  115. package/dist/{niceNumLabels-29a7c6ca.js → niceNumLabels-1bd7a93b.js} +1 -1
  116. package/dist/{nodrag-b2737073.js → nodrag-0fa60f70.js} +1 -1
  117. package/dist/{notify-0cb8904f.js → notify-42149e65.js} +1 -1
  118. package/dist/{numeric-24dacbee.js → numeric-5b626171.js} +1 -1
  119. package/dist/{numeric.binary-f382cc98.js → numeric.binary-07e15211.js} +1 -1
  120. package/dist/numeric.continuous-76dd29ba.js +1 -0
  121. package/dist/numeric.discrete-6d697c68.js +1 -0
  122. package/dist/{numeric.spline-a35cfbf0.js → numeric.spline-cf331bad.js} +1 -1
  123. package/dist/{numeric.toggle-2f98d6e5.js → numeric.toggle-332c2578.js} +1 -1
  124. package/dist/oncomatrix-7c84c94b.js +1 -0
  125. package/dist/{parseData-292648dd.js → parseData-05ab5f81.js} +1 -1
  126. package/dist/{plot.2dvaf-6ae22dc1.js → plot.2dvaf-1debbf12.js} +1 -1
  127. package/dist/plot.app-0b02df66.js +1 -0
  128. package/dist/{plot.barplot-34841e70.js → plot.barplot-45b57df9.js} +1 -1
  129. package/dist/{plot.boxplot-87ac2ce9.js → plot.boxplot-06cef6e2.js} +1 -1
  130. package/dist/{plot.brainImaging-32a484b6.js → plot.brainImaging-07795744.js} +1 -1
  131. package/dist/{plot.disco-1fdfee3c.js → plot.disco-9c631d77.js} +1 -1
  132. package/dist/{plot.dzi-e3d0f610.js → plot.dzi-a9a81de5.js} +1 -1
  133. package/dist/{plot.ssgq-d33113d5.js → plot.ssgq-02ffde06.js} +1 -1
  134. package/dist/{plot.vaf2cov-9f4f1776.js → plot.vaf2cov-c111c5fb.js} +1 -1
  135. package/dist/{plot.wsi-dea124a7.js → plot.wsi-6ccc7bb2.js} +1 -1
  136. package/dist/{profileBarchart-58f0a8c0.js → profileBarchart-0c97e8c9.js} +1 -1
  137. package/dist/{profileHome-7f404152.js → profileHome-2255d66d.js} +1 -1
  138. package/dist/profilePlot-ba7e03ab.js +1 -0
  139. package/dist/{profilePolar-50b8e40e.js → profilePolar-d38d502f.js} +1 -1
  140. package/dist/{profileRadar-fff0b004.js → profileRadar-f95cfa87.js} +1 -1
  141. package/dist/{profileRadarFacility-d6d34c15.js → profileRadarFacility-7e200a91.js} +1 -1
  142. package/dist/profileSummary-8c41a731.js +1 -0
  143. package/dist/{recover-299ffdb3.js → recover-6f2f3379.js} +1 -1
  144. package/dist/{regression.inputs-14df7c31.js → regression.inputs-b515101d.js} +1 -1
  145. package/dist/{regression.inputs.values.table-d79efa9e.js → regression.inputs.values.table-f8a0cad9.js} +1 -1
  146. package/dist/{regression.results-4767144e.js → regression.results-91a486f0.js} +1 -1
  147. package/dist/{renderPvalueTable-002cc8ff.js → renderPvalueTable-d4d2624c.js} +1 -1
  148. package/dist/sampleScatter-7c2773de.js +1 -0
  149. package/dist/{sampleScatter.rendererThree-ef289434.js → sampleScatter.rendererThree-b6db5a09.js} +2 -2
  150. package/dist/{sampleView-1dff3fca.js → sampleView-8885e86b.js} +1 -1
  151. package/dist/{samplelst-d2db0f24.js → samplelst-83e593da.js} +1 -1
  152. package/dist/{samplematrix-0841387f.js → samplematrix-a8b3f845.js} +1 -1
  153. package/dist/{scatter-f8285107.js → scatter-34d52e2d.js} +1 -1
  154. package/dist/{select2Terms-d48d037e.js → select2Terms-d9320d21.js} +1 -1
  155. package/dist/{selectGenomeWithTklst-9af86d31.js → selectGenomeWithTklst-fed6a2ea.js} +1 -1
  156. package/dist/shapes-21ebfec4.js +1 -0
  157. package/dist/singleCellCellType-e6848f45.js +1 -0
  158. package/dist/{singleCellGeneExpression-537f1157.js → singleCellGeneExpression-d3a5394e.js} +1 -1
  159. package/dist/singleCellPlot-3cad6bd8.js +1 -0
  160. package/dist/{singlecell-38336cbc.js → singlecell-0754aab0.js} +1 -1
  161. package/dist/{singlecell-87b4b9a9.js → singlecell-7c57cd77.js} +1 -1
  162. package/dist/{snp-b81ef740.js → snp-6b23e7a6.js} +1 -1
  163. package/dist/snp-a0cdd2a5.js +1 -0
  164. package/dist/snplocus-c60eab56.js +1 -0
  165. package/dist/{spliceevent.a53ss.diagram-5f8352eb.js → spliceevent.a53ss.diagram-8714f740.js} +1 -1
  166. package/dist/{spliceevent.exonskip.diagram-0d30a735.js → spliceevent.exonskip.diagram-40c1e363.js} +1 -1
  167. package/dist/spliceevent.exonskip.getdefault-4bb6f19f.js +1 -0
  168. package/dist/{spliceevent.noeventdiagram-df9ce4bc.js → spliceevent.noeventdiagram-41a56db9.js} +1 -1
  169. package/dist/{spliceevent.phrase-a8401d53.js → spliceevent.phrase-7f34e3b1.js} +1 -1
  170. package/dist/{stattable-46cde32c.js → stattable-78dc5c34.js} +1 -1
  171. package/dist/{style.gdc-72d730f2.js → style.gdc-cd49882c.js} +1 -1
  172. package/dist/summary-45c56298.js +1 -0
  173. package/dist/{sunburst-fe95832e.js → sunburst-2140e468.js} +1 -1
  174. package/dist/{survival-57ff3c03.js → survival-db972025.js} +1 -1
  175. package/dist/{survival-52714cd3.js → survival-ed4bdad2.js} +1 -1
  176. package/dist/{svg.download-f4aa48e4.js → svg.download-a5e20a92.js} +1 -1
  177. package/dist/{svg.legend-749348e0.js → svg.legend-8d21872d.js} +1 -1
  178. package/dist/{svgraph-b46f1f92.js → svgraph-f6a28b78.js} +1 -1
  179. package/dist/{svmr-9a76c6d4.js → svmr-8b4b4c59.js} +1 -1
  180. package/dist/{table-bf40249b.js → table-1cbe3a36.js} +1 -1
  181. package/dist/{table-0daf2b89.js → table-e2a307e6.js} +1 -1
  182. package/dist/{termInfo-491b10af.js → termInfo-5477ba96.js} +1 -1
  183. package/dist/termdb.bins-7ecc48db.js +1 -0
  184. package/dist/{termsetting-492eefa7.js → termsetting-2e75e729.js} +1 -1
  185. package/dist/tk-a8a4481a.js +1 -0
  186. package/dist/{toggleButtons-c4d6f260.js → toggleButtons-7ce58d97.js} +1 -1
  187. package/dist/{tp.ui-0a476325.js → tp.ui-be14f635.js} +1 -1
  188. package/dist/{tvs.density-034b506d.js → tvs.density-8b953cef.js} +1 -1
  189. package/dist/{tvs.geneVariant-c59c8b54.js → tvs.geneVariant-ecad287d.js} +1 -1
  190. package/dist/{tvs.numeric-aa1f892f.js → tvs.numeric-b56a5aba.js} +1 -1
  191. package/dist/{tvs.samplelst-515f27b9.js → tvs.samplelst-3150e0b7.js} +1 -1
  192. package/dist/{uiUtils-ea7dfea2.js → uiUtils-71cc22de.js} +1 -1
  193. package/dist/{variantBrowser-14d5c3f6.js → variantBrowser-df2f9c22.js} +1 -1
  194. package/dist/{vcf-d357ce08.js → vcf-3e370c9b.js} +1 -1
  195. package/dist/{violin-74d26b75.js → violin-4595cef4.js} +1 -1
  196. package/dist/{violin.interactivity-bf40ddde.js → violin.interactivity-8b63e000.js} +1 -1
  197. package/dist/{violin.renderer-469fa0ff.js → violin.renderer-0b7431a2.js} +1 -1
  198. package/dist/{violinRenderer-14fa200d.js → violinRenderer-7b0a4e98.js} +1 -1
  199. package/dist/{viridis-cc59f478.js → viridis-725f66e0.js} +1 -1
  200. package/dist/{y-59cbff5e.js → y-300bac24.js} +1 -1
  201. package/dist/{zoom-f445cfef.js → zoom-d3d38b3b.js} +1 -1
  202. package/package.json +2 -4
  203. package/dist/FilterRxComp-02e68f1b.js +0 -1
  204. package/dist/FilterStateless-16a33070.js +0 -1
  205. package/dist/app-42f69951.js +0 -1
  206. package/dist/app-6fb77603.js +0 -1
  207. package/dist/block.lazyload-d2951c91.js +0 -1
  208. package/dist/controls.btns-5bf9e7d7.js +0 -1
  209. package/dist/databrowser.ui-2197fc73.js +0 -1
  210. package/dist/downloadTextfile-5723af95.js +0 -1
  211. package/dist/geneExpression-c61e8f1c.js +0 -1
  212. package/dist/geneVariant-f17cda85.js +0 -1
  213. package/dist/genomeBrowser-608b924e.js +0 -1
  214. package/dist/hierCluster.config-f4daaf92.js +0 -1
  215. package/dist/launch.adhoc-e124c993.js +0 -1
  216. package/dist/leftlabel.sample-59f99ef5.js +0 -1
  217. package/dist/matrix.controls-42ad4912.js +0 -1
  218. package/dist/numeric.continuous-6feb34a7.js +0 -1
  219. package/dist/numeric.discrete-ed10bbc1.js +0 -1
  220. package/dist/oncomatrix-c0b2d635.js +0 -1
  221. package/dist/plot.app-2a805759.js +0 -1
  222. package/dist/profilePlot-4db8ca78.js +0 -1
  223. package/dist/profileSummary-04b8b15b.js +0 -1
  224. package/dist/sampleScatter-55d9eb74.js +0 -1
  225. package/dist/singleCellCellType-fd1606b8.js +0 -1
  226. package/dist/singleCellPlot-eff5760b.js +0 -1
  227. package/dist/snp-f6123244.js +0 -1
  228. package/dist/snplocus-acafb1ba.js +0 -1
  229. package/dist/spliceevent.exonskip.getdefault-237c481c.js +0 -1
  230. package/dist/summary-a6c15c9e.js +0 -1
  231. package/dist/termdb.bins-39d11f24.js +0 -1
  232. package/dist/tk-ac524564.js +0 -1
@@ -1 +1 @@
1
- import{i as t,P as e}from"./app-6fb77603.js";const i={isVisible:false,term:null};class s{constructor(t){this.vocabApi=t.vocabApi||t.app&&t.app.vocabApi;this.state=Object.assign({},i,t.state?t.state:{});this.api=this;l(this);n(this);this.initUI(t)}async main(t={}){e(this.state,t);this.dom.content_holder.style("display",this.state.isVisible?"block":"none");this.dom.icon_holder.style("background-color",this.state.isVisible?"darkgray":"transparent").style("color",this.state.isVisible?"white":"#797a7a");if(!this.state.isVisible)return;const i=await this.vocabApi.getTermInfo(this.state.term.id);this.render(i)}}const o=t(s);function n(t){t.initUI=function(e){t.dom={content_holder:e.content_holder.style("margin-left","25px").attr("class","term_info_div").style("display",t.state.isVisible?"block":"none").style("white-space","normal").style("padding-bottom","20px"),details:e.content_holder.append("div"),tbody:e.content_holder.append("table").append("tbody"),icon_holder:e.icon_holder.style("margin","1px 0px 1px 5px").style("padding","2px 5px").style("font-family","Times New Roman").style("font-size","14px").style("font-weight","bold").style("cursor","pointer").style("background-color","transparent").style("color","#797a7a").style("align-items","center").style("justify-content","center").style("border","none").style("border-radius","3px").attr("aria-label","Term Information").html("&#9432;").on("mouseenter",(()=>{if(t.state.isVisible==true)return;t.dom.icon_holder.style("color","blue")})).on("mouseleave",(()=>{if(t.state.isVisible==true)return;t.dom.icon_holder.style("color","#797a7a")})).on("click",t.toggleDescription)}};t.render=function(e){t.dom.tbody.selectAll("*").remove();if(e.terminfo.src){for(let i of e.terminfo.src){const e=t.dom.tbody.append("tr").append("td").style("padding","5px 0");e.append("div").style("font-weight","bold").text("Source");e.append("div").style("margin-left","20px").text(i.pub);e.append("div").style("margin-left","20px").html(i.title+":&nbsp;<i>"+i.section+"</i>")}}if(e.terminfo.rubric){const i=t.dom.tbody.append("tr").append("td").style("padding","5px 0").append("div").style("font-weight","bold").text("Grading Rubric").append("ol").style("margin","0px");for(let t of e.terminfo.rubric){i.append("li").style("font-weight","normal").text(t)}}t.dom.details.selectAll("*").remove();if(e.terminfo.description){t.dom.details.append("div").style("padding-top","20px").style("padding-bottom","10px").style("font-weight","bold").text("Description");for(const i of e.terminfo.description){t.renderDetail(i,t.dom.details.append("div").style("padding-bottom","3px"))}}};t.renderDetail=function(e,i){if(Array.isArray(e.value)){i.append("span").html("<i>"+e.label+"</i>");const s=i.append("div").style("padding-left","20px");for(const i of e.value){i.label="- "+i.label;t.renderDetail(i,s.append("div"))}}else{i.html("<i>"+e.label+":"+"</i>"+"&nbsp;"+e.value)}}}function l(t){t.toggleDescription=function(){t.state.isVisible=!t.state.isVisible;t.main({isVisible:t.state.isVisible})}}export{o as termInfoInit};
1
+ import{i as t,P as e}from"./app-0de0ae35.js";const i={isVisible:false,term:null};class s{constructor(t){this.vocabApi=t.vocabApi||t.app&&t.app.vocabApi;this.state=Object.assign({},i,t.state?t.state:{});this.api=this;l(this);n(this);this.initUI(t)}async main(t={}){e(this.state,t);this.dom.content_holder.style("display",this.state.isVisible?"block":"none");this.dom.icon_holder.style("background-color",this.state.isVisible?"darkgray":"transparent").style("color",this.state.isVisible?"white":"#797a7a");if(!this.state.isVisible)return;const i=await this.vocabApi.getTermInfo(this.state.term.id);this.render(i)}}const o=t(s);function n(t){t.initUI=function(e){t.dom={content_holder:e.content_holder.style("margin-left","25px").attr("class","term_info_div").style("display",t.state.isVisible?"block":"none").style("white-space","normal").style("padding-bottom","20px"),details:e.content_holder.append("div"),tbody:e.content_holder.append("table").append("tbody"),icon_holder:e.icon_holder.style("margin","1px 0px 1px 5px").style("padding","2px 5px").style("font-family","Times New Roman").style("font-size","14px").style("font-weight","bold").style("cursor","pointer").style("background-color","transparent").style("color","#797a7a").style("align-items","center").style("justify-content","center").style("border","none").style("border-radius","3px").attr("aria-label","Term Information").html("&#9432;").on("mouseenter",(()=>{if(t.state.isVisible==true)return;t.dom.icon_holder.style("color","blue")})).on("mouseleave",(()=>{if(t.state.isVisible==true)return;t.dom.icon_holder.style("color","#797a7a")})).on("click",t.toggleDescription)}};t.render=function(e){t.dom.tbody.selectAll("*").remove();if(e.terminfo.src){for(let i of e.terminfo.src){const e=t.dom.tbody.append("tr").append("td").style("padding","5px 0");e.append("div").style("font-weight","bold").text("Source");e.append("div").style("margin-left","20px").text(i.pub);e.append("div").style("margin-left","20px").html(i.title+":&nbsp;<i>"+i.section+"</i>")}}if(e.terminfo.rubric){const i=t.dom.tbody.append("tr").append("td").style("padding","5px 0").append("div").style("font-weight","bold").text("Grading Rubric").append("ol").style("margin","0px");for(let t of e.terminfo.rubric){i.append("li").style("font-weight","normal").text(t)}}t.dom.details.selectAll("*").remove();if(e.terminfo.description){t.dom.details.append("div").style("padding-top","20px").style("padding-bottom","10px").style("font-weight","bold").text("Description");for(const i of e.terminfo.description){t.renderDetail(i,t.dom.details.append("div").style("padding-bottom","3px"))}}};t.renderDetail=function(e,i){if(Array.isArray(e.value)){i.append("span").html("<i>"+e.label+"</i>");const s=i.append("div").style("padding-left","20px");for(const i of e.value){i.label="- "+i.label;t.renderDetail(i,s.append("div"))}}else{i.html("<i>"+e.label+":"+"</i>"+"&nbsp;"+e.value)}}}function l(t){t.toggleDescription=function(){t.state.isVisible=!t.state.isVisible;t.main({isVisible:t.state.isVisible})}}export{o as termInfoInit};
@@ -0,0 +1 @@
1
+ import{V as t,C as e,H as s,W as n}from"./app-0de0ae35.js";function i(t){const e=t;if(!e||typeof e!=="object")throw"bin schema must be an object";if(!("type"in e))e.type="regular-bin";if(e.type=="custom-bin"){if(!Array.isArray(e.lst))throw"binconfig.lst must be an array";if(!e.lst.length)throw"binconfig.lst must have entries";const t=e.lst[0];const n=e.lst[e.lst.length-1];for(const i of e.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(!s(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(!s(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(!s(i.start))throw"bin.start must be numeric for a non-first bin";if(!s(i.stop))throw"bin.stop must be numeric for a non-last bin"}}}else if(e.type=="regular-bin"){if(!Number.isFinite(e.bin_size))throw"non-numeric bin_size";if(e.bin_size<=0)throw"bin_size must be greater than 0";if(!e.startinclusive&&!e.stopinclusive){e.startinclusive=1;e.stopinclusive=0}if(!e.first_bin)throw"first_bin{} missing";if(typeof e.first_bin!="object")throw"first_bin{} is not an object";if(!Object.keys(e.first_bin).length)throw"first_bin is an empty object";{const t=e.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(e.last_bin){const t=e.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="${e.type}"`}}function o(t,n,o){const l=t;i(l);if(l.lst){const t=e(l.lst.length);for(const e of l.lst)e.color=t(e.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]:s(l.last_bin.stop)&&l.last_bin.stop<=c.max?l.last_bin.stop:p;m=s(l.last_bin.start_percentile)?c["p"+l.last_bin.start_percentile]:s(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]:s(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=s(d);const g=s(m);const w=s(h);if(!v&&!g)return[];const y=[];let F={startunbounded:l.first_bin.startunbounded,start:l.first_bin.startunbounded?undefined:_,stop:s(l.first_bin.stop_percentile)?+c["p"+l.first_bin.stop_percentile]:s(l.first_bin.stop)?+l.first_bin.stop:_+l.bin_size,startinclusive:l.startinclusive,stopinclusive:l.stopinclusive};if(!s(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 e=F.stop;F={startinclusive:l.startinclusive,stopinclusive:l.stopinclusive,start:e,stop:w&&(e==m||t>h)?h:g&&t>m&&e!=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=e(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(e,s,n){const i=s;if(!i.binLabelFormatter)i.binLabelFormatter=r(i);if(!e.startunbounded&&!e.stopunbounded&&!("startinclusive"in e)&&!("stopinclusive"in e)){if(i.startinclusive)e.startinclusive=true;else if(i.stopinclusive)e.stopinclusive=true}const o=i.use_as=="bins"||e.start;const a=i.use_as=="bins"||e.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(e.startunbounded){const s=e.stopinclusive?"≤":"<";const o=n?t(a,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(a);return s+o}if(e.stopunbounded||o===a){const s=e.startinclusive?"≥":">";const r=n?t(o,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(o);return s+r}if(l&&e.startinclusive&&!e.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 e=n?t(o,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(o);const s=n?t(a-l,n.fromUnit,n.toUnit,n.scaleFactor,true):i.binLabelFormatter(a-l);return+e>=+s?e.toString():e+" to "+s}}else{const s=e.startinclusive?"":">";const r=e.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=e.startinclusive?"≥":">";return t+l}else{return s+l+" to "+r+u}}}function l(t,e){const s='<span style="font-family:Times;font-style:italic;">x</span>';let n;const i=a(t,e);if(t.startunbounded||t.stopunbounded){n=s+"&nbsp;"+i}else if(t.startinclusive){n=i.replace("to <","≤ "+s+" <")}else if(t.stopinclusive){n=i.replace(">","").replace("to","< "+s+" ≤")}return n}function u(t){const e=[];const n=t.first_bin;if(n&&s(n.start_percentile))e.push(n.start_percentile);if(n&&s(n.stop_percentile))e.push(n.stop_percentile);const i=t.last_bin;if(i&&s(i.start_percentile))e.push(i.start_percentile);if(i&&s(i.stop_percentile))e.push(i.stop_percentile);return e}export{l as a,o as c,a as g};
@@ -1 +1 @@
1
- import{a as e,b as t,_ as i}from"./tslib.es6-c3c2d88f.js";import{R as n,S as r,T as s,P as o,H as a,i as l,M as d,F as p,d as u}from"./app-6fb77603.js";import c from"path";const f=1;const h={continuous:"continuous",discrete:"discrete"};const m={GENE_VARIANT:"geneVariant",GENE_EXPRESSION:"geneExpression",CATEGORICAL:"categorical",INTEGER:"integer",FLOAT:"float",SNP:"snp",SNP_LIST:"snplst",SNP_LOCUS:"snplocus",CONDITION:"condition",SURVIVAL:"survival",SAMPLELST:"samplelst",METABOLITE_INTENSITY:"metaboliteIntensity",SINGLECELL_GENE_EXPRESSION:"singleCellGeneExpression",SINGLECELL_CELLTYPE:"singleCellCellType"};const y={[m.GENE_EXPRESSION]:n,[m.METABOLITE_INTENSITY]:r};const g={[m.CATEGORICAL]:s.DICTIONARY_VARIABLES,[m.CONDITION]:s.DICTIONARY_VARIABLES,[m.FLOAT]:s.DICTIONARY_VARIABLES,[m.INTEGER]:s.DICTIONARY_VARIABLES,[m.SAMPLELST]:s.DICTIONARY_VARIABLES,[m.SURVIVAL]:s.DICTIONARY_VARIABLES,[m.GENE_VARIANT]:s.MUTATION_CNV_FUSION,[m.SNP]:s.SNP,[m.SNP_LIST]:s.SNP_LIST,[m.SNP_LOCUS]:s.SNP_LOCUS,[m.GENE_EXPRESSION]:s.GENE_EXPRESSION,[m.METABOLITE_INTENSITY]:s.METABOLITE_INTENSITY};const v=new Set([m.SNP,m.SNP_LIST,m.SNP_LOCUS,m.GENE_EXPRESSION,m.GENE_VARIANT,m.METABOLITE_INTENSITY,m.SINGLECELL_GENE_EXPRESSION,m.SINGLECELL_CELLTYPE]);const b=new Set([m.INTEGER,m.FLOAT,m.GENE_EXPRESSION,m.METABOLITE_INTENSITY,m.SINGLECELL_GENE_EXPRESSION]);const w=new Set([m.CATEGORICAL,m.SNP]);function q(e){if(!e)return false;return b.has(e.type)}function T(e){if(!e)return false;return w.has(e.type)}function x(e){return!E(e)}function E(e){if(!e)throw new Error("Type is not defined");return v.has(e)}function S(e,t){if(!e)throw new Error("First term is not defined ");if(!t)throw new Error("Second term is not defined ");if(e.type!==t.type)return false;if(x(e.type)&&x(t.type)&&e.type!=m.SAMPLELST)return e.id===t.id;switch(e.type){case m.GENE_EXPRESSION:return e.gene==t.gene;case m.METABOLITE_INTENSITY:return e.name==t.name;case m.GENE_VARIANT:return e.gene==t.gene||e.chr==t.chr&&e.start==t.start&&e.stop==t.stop;default:return false}}var _=function(e,t){var i=[];for(var n=0;n<e.length;n++){var r=t(e[n],n);if(N(r))i.push.apply(i,r);else i.push(r)}return i};var N=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};var A=I;function I(e,t,i){if(e instanceof RegExp)e=C(e,i);if(t instanceof RegExp)t=C(t,i);var n=O(e,t,i);return n&&{start:n[0],end:n[1],pre:i.slice(0,n[0]),body:i.slice(n[0]+e.length,n[1]),post:i.slice(n[1]+t.length)}}function C(e,t){var i=t.match(e);return i?i[0]:null}I.range=O;function O(e,t,i){var n,r,s,o,a;var l=i.indexOf(e);var d=i.indexOf(t,l+1);var p=l;if(l>=0&&d>0){if(e===t){return[l,d]}n=[];s=i.length;while(p>=0&&!a){if(p==l){n.push(p);l=i.indexOf(e,p+1)}else if(n.length==1){a=[n.pop(),d]}else{r=n.pop();if(r<s){s=r;o=d}d=i.indexOf(t,p+1)}p=l<d&&l>=0?l:d}if(n.length){a=[s,o]}}return a}var j=V;var k="\0SLASH"+Math.random()+"\0";var P="\0OPEN"+Math.random()+"\0";var $="\0CLOSE"+Math.random()+"\0";var M="\0COMMA"+Math.random()+"\0";var L="\0PERIOD"+Math.random()+"\0";function R(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function W(e){return e.split("\\\\").join(k).split("\\{").join(P).split("\\}").join($).split("\\,").join(M).split("\\.").join(L)}function B(e){return e.split(k).join("\\").split(P).join("{").split($).join("}").split(M).join(",").split(L).join(".")}function G(e){if(!e)return[""];var t=[];var i=A("{","}",e);if(!i)return e.split(",");var n=i.pre;var r=i.body;var s=i.post;var o=n.split(",");o[o.length-1]+="{"+r+"}";var a=G(s);if(s.length){o[o.length-1]+=a.shift();o.push.apply(o,a)}t.push.apply(t,o);return t}function V(e){if(!e)return[];if(e.substr(0,2)==="{}"){e="\\{\\}"+e.substr(2)}return H(W(e),true).map(B)}function D(e){return"{"+e+"}"}function Q(e){return/^-?0\d/.test(e)}function Y(e,t){return e<=t}function U(e,t){return e>=t}function H(e,t){var i=[];var n=A("{","}",e);if(!n||/\$$/.test(n.pre))return[e];var r=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body);var s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body);var o=r||s;var a=n.body.indexOf(",")>=0;if(!o&&!a){if(n.post.match(/,.*\}/)){e=n.pre+"{"+n.body+$+n.post;return H(e)}return[e]}var l;if(o){l=n.body.split(/\.\./)}else{l=G(n.body);if(l.length===1){l=H(l[0],false).map(D);if(l.length===1){var d=n.post.length?H(n.post,false):[""];return d.map((function(e){return n.pre+l[0]+e}))}}}var p=n.pre;var d=n.post.length?H(n.post,false):[""];var u;if(o){var c=R(l[0]);var f=R(l[1]);var h=Math.max(l[0].length,l[1].length);var m=l.length==3?Math.abs(R(l[2])):1;var y=Y;var g=f<c;if(g){m*=-1;y=U}var v=l.some(Q);u=[];for(var b=c;y(b,f);b+=m){var w;if(s){w=String.fromCharCode(b);if(w==="\\")w=""}else{w=String(b);if(v){var q=h-w.length;if(q>0){var T=new Array(q+1).join("0");if(b<0)w="-"+T+w.slice(1);else w=T+w}}}u.push(w)}}else{u=_(l,(function(e){return H(e,false)}))}for(var x=0;x<u.length;x++){for(var E=0;E<d.length;E++){var S=p+u[x]+d[E];if(!t||o||S)i.push(S)}}return i}var X=ae;ae.Minimatch=le;var F=function(){try{return c}catch(e){}}()||{sep:"/"};ae.sep=F.sep;var z=ae.GLOBSTAR=le.GLOBSTAR={};var J={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}};var Z="[^/]";var K=Z+"*?";var ee="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";var te="(?:(?!(?:\\/|^)\\.).)*?";var ie=ne("().*{}+?[]^$\\!");function ne(e){return e.split("").reduce((function(e,t){e[t]=true;return e}),{})}var re=/\/+/;ae.filter=se;function se(e,t){t=t||{};return function(i,n,r){return ae(i,e,t)}}function oe(e,t){t=t||{};var i={};Object.keys(e).forEach((function(t){i[t]=e[t]}));Object.keys(t).forEach((function(e){i[e]=t[e]}));return i}ae.defaults=function(e){if(!e||typeof e!=="object"||!Object.keys(e).length){return ae}var t=ae;var i=function i(n,r,s){return t(n,r,oe(e,s))};i.Minimatch=function i(n,r){return new t.Minimatch(n,oe(e,r))};i.Minimatch.defaults=function i(n){return t.defaults(oe(e,n)).Minimatch};i.filter=function i(n,r){return t.filter(n,oe(e,r))};i.defaults=function i(n){return t.defaults(oe(e,n))};i.makeRe=function i(n,r){return t.makeRe(n,oe(e,r))};i.braceExpand=function i(n,r){return t.braceExpand(n,oe(e,r))};i.match=function(i,n,r){return t.match(i,n,oe(e,r))};return i};le.defaults=function(e){return ae.defaults(e).Minimatch};function ae(e,t,i){fe(t);if(!i)i={};if(!i.nocomment&&t.charAt(0)==="#"){return false}return new le(t,i).match(e)}function le(e,t){if(!(this instanceof le)){return new le(e,t)}fe(e);if(!t)t={};e=e.trim();if(!t.allowWindowsEscape&&F.sep!=="/"){e=e.split(F.sep).join("/")}this.options=t;this.set=[];this.pattern=e;this.regexp=null;this.negate=false;this.comment=false;this.empty=false;this.partial=!!t.partial;this.make()}le.prototype.debug=function(){};le.prototype.make=de;function de(){var e=this.pattern;var t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate();var i=this.globSet=this.braceExpand();if(t.debug)this.debug=function e(){console.error.apply(console,arguments)};this.debug(this.pattern,i);i=this.globParts=i.map((function(e){return e.split(re)}));this.debug(this.pattern,i);i=i.map((function(e,t,i){return e.map(this.parse,this)}),this);this.debug(this.pattern,i);i=i.filter((function(e){return e.indexOf(false)===-1}));this.debug(this.pattern,i);this.set=i}le.prototype.parseNegate=pe;function pe(){var e=this.pattern;var t=false;var i=this.options;var n=0;if(i.nonegate)return;for(var r=0,s=e.length;r<s&&e.charAt(r)==="!";r++){t=!t;n++}if(n)this.pattern=e.substr(n);this.negate=t}ae.braceExpand=function(e,t){return ue(e,t)};le.prototype.braceExpand=ue;function ue(e,t){if(!t){if(this instanceof le){t=this.options}else{t={}}}e=typeof e==="undefined"?this.pattern:e;fe(e);if(t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)){return[e]}return j(e)}var ce=1024*64;var fe=function(e){if(typeof e!=="string"){throw new TypeError("invalid pattern")}if(e.length>ce){throw new TypeError("pattern is too long")}};le.prototype.parse=me;var he={};function me(e,t){fe(e);var i=this.options;if(e==="**"){if(!i.noglobstar)return z;else e="*"}if(e==="")return"";var n="";var r=!!i.nocase;var s=false;var o=[];var a=[];var l;var d=false;var p=-1;var u=-1;var c=e.charAt(0)==="."?"":i.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)";var f=this;function h(){if(l){switch(l){case"*":n+=K;r=true;break;case"?":n+=Z;r=true;break;default:n+="\\"+l;break}f.debug("clearStateChar %j %j",l,n);l=false}}for(var m=0,y=e.length,g;m<y&&(g=e.charAt(m));m++){this.debug("%s\t%s %s %j",e,m,n,g);if(s&&ie[g]){n+="\\"+g;s=false;continue}switch(g){case"/":{return false}case"\\":h();s=true;continue;case"?":case"*":case"+":case"@":case"!":this.debug("%s\t%s %s %j <-- stateChar",e,m,n,g);if(d){this.debug(" in class");if(g==="!"&&m===u+1)g="^";n+=g;continue}f.debug("call clearStateChar %j",l);h();l=g;if(i.noext)h();continue;case"(":if(d){n+="(";continue}if(!l){n+="\\(";continue}o.push({type:l,start:m-1,reStart:n.length,open:J[l].open,close:J[l].close});n+=l==="!"?"(?:(?!(?:":"(?:";this.debug("plType %j %j",l,n);l=false;continue;case")":if(d||!o.length){n+="\\)";continue}h();r=true;var v=o.pop();n+=v.close;if(v.type==="!"){a.push(v)}v.reEnd=n.length;continue;case"|":if(d||!o.length||s){n+="\\|";s=false;continue}h();n+="|";continue;case"[":h();if(d){n+="\\"+g;continue}d=true;u=m;p=n.length;n+=g;continue;case"]":if(m===u+1||!d){n+="\\"+g;s=false;continue}var b=e.substring(u+1,m);try{RegExp("["+b+"]")}catch(e){var w=this.parse(b,he);n=n.substr(0,p)+"\\["+w[0]+"\\]";r=r||w[1];d=false;continue}r=true;d=false;n+=g;continue;default:h();if(s){s=false}else if(ie[g]&&!(g==="^"&&d)){n+="\\"}n+=g}}if(d){b=e.substr(u+1);w=this.parse(b,he);n=n.substr(0,p)+"\\["+w[0];r=r||w[1]}for(v=o.pop();v;v=o.pop()){var q=n.slice(v.reStart+v.open.length);this.debug("setting tail",n,v);q=q.replace(/((?:\\{2}){0,64})(\\?)\|/g,(function(e,t,i){if(!i){i="\\"}return t+t+i+"|"}));this.debug("tail=%j\n %s",q,q,v,n);var T=v.type==="*"?K:v.type==="?"?Z:"\\"+v.type;r=true;n=n.slice(0,v.reStart)+T+"\\("+q}h();if(s){n+="\\\\"}var x=false;switch(n.charAt(0)){case"[":case".":case"(":x=true}for(var E=a.length-1;E>-1;E--){var S=a[E];var _=n.slice(0,S.reStart);var N=n.slice(S.reStart,S.reEnd-8);var A=n.slice(S.reEnd-8,S.reEnd);var I=n.slice(S.reEnd);A+=I;var C=_.split("(").length-1;var O=I;for(m=0;m<C;m++){O=O.replace(/\)[+*?]?/,"")}I=O;var j="";if(I===""&&t!==he){j="$"}var k=_+N+I+j+A;n=k}if(n!==""&&r){n="(?=.)"+n}if(x){n=c+n}if(t===he){return[n,r]}if(!r){return ge(e)}var P=i.nocase?"i":"";try{var $=new RegExp("^"+n+"$",P)}catch(e){return new RegExp("$.")}$._glob=e;$._src=n;return $}ae.makeRe=function(e,t){return new le(e,t||{}).makeRe()};le.prototype.makeRe=ye;function ye(){if(this.regexp||this.regexp===false)return this.regexp;var e=this.set;if(!e.length){this.regexp=false;return this.regexp}var t=this.options;var i=t.noglobstar?K:t.dot?ee:te;var n=t.nocase?"i":"";var r=e.map((function(e){return e.map((function(e){return e===z?i:typeof e==="string"?ve(e):e._src})).join("\\/")})).join("|");r="^(?:"+r+")$";if(this.negate)r="^(?!"+r+").*$";try{this.regexp=new RegExp(r,n)}catch(e){this.regexp=false}return this.regexp}ae.match=function(e,t,i){i=i||{};var n=new le(t,i);e=e.filter((function(e){return n.match(e)}));if(n.options.nonull&&!e.length){e.push(t)}return e};le.prototype.match=function e(t,i){if(typeof i==="undefined")i=this.partial;this.debug("match",t,this.pattern);if(this.comment)return false;if(this.empty)return t==="";if(t==="/"&&i)return true;var n=this.options;if(F.sep!=="/"){t=t.split(F.sep).join("/")}t=t.split(re);this.debug(this.pattern,"split",t);var r=this.set;this.debug(this.pattern,"set",r);var s;var o;for(o=t.length-1;o>=0;o--){s=t[o];if(s)break}for(o=0;o<r.length;o++){var a=r[o];var l=t;if(n.matchBase&&a.length===1){l=[s]}var d=this.matchOne(l,a,i);if(d){if(n.flipNegate)return true;return!this.negate}}if(n.flipNegate)return false;return this.negate};le.prototype.matchOne=function(e,t,i){var n=this.options;this.debug("matchOne",{this:this,file:e,pattern:t});this.debug("matchOne",e.length,t.length);for(var r=0,s=0,o=e.length,a=t.length;r<o&&s<a;r++,s++){this.debug("matchOne loop");var l=t[s];var d=e[r];this.debug(t,l,d);if(l===false)return false;if(l===z){this.debug("GLOBSTAR",[t,l,d]);var p=r;var u=s+1;if(u===a){this.debug("** at the end");for(;r<o;r++){if(e[r]==="."||e[r]===".."||!n.dot&&e[r].charAt(0)===".")return false}return true}while(p<o){var c=e[p];this.debug("\nglobstar while",e,p,t,u,c);if(this.matchOne(e.slice(p),t.slice(u),i)){this.debug("globstar found match!",p,o,c);return true}else{if(c==="."||c===".."||!n.dot&&c.charAt(0)==="."){this.debug("dot detected!",e,p,t,u);break}this.debug("globstar swallow a segment, and continue");p++}}if(i){this.debug("\n>>> no match, partial?",e,p,t,u);if(p===o)return true}return false}var f;if(typeof l==="string"){f=d===l;this.debug("string match",l,d,f)}else{f=d.match(l);this.debug("pattern match",l,d,f)}if(!f)return false}if(r===o&&s===a){return true}else if(r===o){return i}else if(s===a){return r===o-1&&e[r]===""}throw new Error("wtf?")};function ge(e){return e.replace(/\\(.)/g,"$1")}function ve(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}class be{constructor(e,t){var i;this.isAtomic=true;this.type=e.type;this.isAtomic=true;if(e.$id)this.$id=e.$id;if((i=t.addons)===null||i===void 0?void 0:i[this.type]){Object.defineProperties(this,t.addons[this.type])}}static setHiddenValues(e,t){if(e.hiddenValues)return;e.hiddenValues={};if(t.values){for(const i in t.values){if(t.values[i].uncomputable)e.hiddenValues[i]=1}}}render(e){console.log(e);throw`should implement this method in subclass code, as needed`}}var we,qe,Te,xe,Ee,Se;class _e extends be{constructor(e,t){super(e,t);this.term=e.term}static fill(e,t={}){var i;if(!e.term)throw`missing tw.term, must already be filled in`;if(e.term.type!="categorical")throw`incorrect term.type='${(i=e.term)===null||i===void 0?void 0:i.type}', expecting 'categorical'`;if(t.defaultQ!=null){t.defaultQ.isAtomic=true;o(e.q,t.defaultQ)}if(!e.q.mode)e.q.mode="discrete";if(!e.q)e.q={type:"values",isAtomic:true};if(!e.type)e.type=!e.q.type||e.q.type=="values"?"CatTWValues":e.q.type=="predefined-groupset"?"CatTWPredefinedGS":e.q.type=="custom-groupset"?"CatTWCustomGS":undefined;switch(e.type){case"CatTWValues":return Ne.fill(e);case"CatTWPredefinedGS":return Ae.fill(e);case"CatTWCustomGS":return Ie.fill(e);default:throw`tw.type='${e.type} (q.mode:q.type=${e.q.mode}:${e.q.type}' is not supported by CategoricalBase.fill()`}}}class Ne extends _e{constructor(t,i={}){super(t,i);we.set(this,void 0);qe.set(this,void 0);this.q=t.q;e(this,we,t,"f");e(this,qe,i,"f")}getTw(){return t(this,we,"f")}static fill(e){if(!e.type)e.type="CatTWValues";else if(e.type!="CatTWValues")throw`expecting tw.type='CatTWValues', got '${e.type}'`;if(e.term.type!="categorical")throw`expecting tw.term.type='categorical', got '${e.term.type}'`;const{term:t,q:i}=e;if(!i.type)i.type="values";else if(i.type!="values")throw`expecting tw.q.type='values', got ${e.q.type}`;if(!t.values)t.values={};if(i.mode=="binary"){if(Object.keys(e.term.values).length!=2)throw"term.values must have exactly two keys"}vt(i,t);return e}}we=new WeakMap,qe=new WeakMap;class Ae extends _e{constructor(i,n={}){super(i,n);Te.set(this,void 0);xe.set(this,void 0);this.q=i.q;e(this,Te,i,"f");Object.defineProperty(this,"groupset",{value:this.term.groupsetting[t(this,Te,"f").q.predefined_groupset_idx]});e(this,xe,n,"f")}getTw(){return t(this,Te,"f")}static fill(e){var t,i;if(!e.type)e.type="CatTWPredefinedGS";else if(e.type!="CatTWPredefinedGS")throw`expecting tw.type='CatTWPredefinedGS', got '${e.type}'`;if(e.term.type!="categorical")throw`expecting tw.term.type='categorical', got '${e.term.type}'`;if(e.q.type!="predefined-groupset")throw`expecting tw.q.type='predefined-groupset', got '${e.q.type}'`;const{term:n,q:r}=e;const s=r.predefined_groupset_idx;if(s!==undefined&&!Number.isInteger(s))throw`missing or invalid tw.q.predefined_groupset_idx='${s}'`;r.predefined_groupset_idx=s||0;const o=e.term.groupsetting;if(!o)throw"no term.groupsetting";if(!((t=o.lst)===null||t===void 0?void 0:t.length))throw"term.groupsetting.lst is empty";const a=(i=o.lst)===null||i===void 0?void 0:i[r.predefined_groupset_idx];if(!a)throw`no groupset entry for groupsetting.lst?.[predefined_groupset_idx=${s}]`;if(r.mode=="binary"){if(a.groups.length!=2)throw"there must be exactly two groups"}vt(r,n);return e}}Te=new WeakMap,xe=new WeakMap;class Ie extends _e{constructor(t,i={}){super(t,i);Ee.set(this,void 0);Se.set(this,void 0);this.q=t.q;Object.defineProperty(this,"groupset",{value:this.q.customset});e(this,Ee,t,"f");e(this,Se,i,"f")}getTw(){return t(this,Ee,"f")}static fill(e){if(!e.type)e.type="CatTWCustomGS";else if(e.type!="CatTWCustomGS")throw`expecting tw.type='CatTWCustomGS', got '${e.type}'`;if(e.term.type!="categorical")throw`expecting tw.term.type='categorical', got '${e.term.type}'`;if(e.q.type!="custom-groupset")throw`expecting tw.q.type='custom-groupset', got '${e.q.type}'`;const{term:t,q:i}=e;if(!i.customset)throw`missing tw.q.customset`;if(i.mode=="binary"){if(i.customset.groups.length!=2)throw"there must be exactly two groups"}vt(i,t);return e}}Ee=new WeakMap,Se=new WeakMap;function Ce(e,t){const i=Number(e);if(Number.isInteger(i))return i;if(Math.abs(i)<1)return Number(i.toPrecision(t));return Number(i.toFixed(t))}function Oe(e){const t=je(e);let i=Math.abs(e)>1?2:t>0?t+1:2;return Ce(e,i)}function je(e){const t=e.toString();const i=t.indexOf(".");if(i===-1||i===t.length-1){return 0}let n=0;for(let e=i+1;e<t.length;e++){if(t[e]==="0"){n++}else if(t[e]>="1"&&t[e]<="9"){break}}return n}var ke,Pe,$e,Me,Le,Re,We,Be;class Ge extends be{constructor(e,t){super(e,t);this.term=e.term}static fill(e,t={}){return i(this,void 0,void 0,(function*(){if(!e.term)throw`missing tw.term, must already be filled in`;if(!Ge.termTypes.has(e.term.type))throw`non-numeric term.type='${e.term.type}'`;if(t.defaultQ){t.defaultQ.isAtomic=true;e.q.isAtomic=true;if(t.defaultQ.preferredBins=="median"){if(!t.defaultQ.type)t.defaultQ.type="custom-bin";else if(t.defaultQ.type!="custom-bin")throw".type must be custom-bin when .preferredBins=median"}o(e.q,t.defaultQ)}if(!e.q.mode)e.q.mode="discrete";if(!e.q.type){if(e.q.mode=="binary")e.q.type="custom-bin";else if(e.q.mode=="discrete")He(e)}e.type=e.q.type=="regular-bin"?"NumTWRegularBin":e.q.type=="custom-bin"||e.q.mode=="binary"?"NumTWCustomBin":e.q.mode=="continuous"?"NumTWCont":e.q.mode=="spline"?"NumTWSpline":e.type;switch(e.type){case"NumTWRegularBin":return yield Ve.fill(e);case"NumTWCustomBin":return yield De.fill(e,t);case"NumTWCont":return yield Qe.fill(e);case"NumTWSpline":return yield Ye.fill(e);default:throw`tw.type='${e.type} (q.mode:q.type=${e.q.mode}:${e.q.type}' is not supported by NumericBase.fill()`}}))}}Ge.termTypes=new Set(["integer","float","geneExpression","metaboliteIntensity"]);class Ve extends Ge{constructor(t,i={}){super(t,i);ke.set(this,void 0);Pe.set(this,void 0);this.q=t.q;e(this,ke,t,"f");e(this,Pe,i,"f")}getTw(){return t(this,ke,"f")}static fill(e){var t;return i(this,void 0,void 0,(function*(){if(!e.type)e.type="NumTWRegularBin";else if(e.type!="NumTWRegularBin")throw`expecting tw.type='NumTWRegularBin', got '${e.type}'`;if(!e.q.mode)e.q.mode="discrete";else if(e.q.mode!="discrete"&&e.q.mode!="binary"&&e.q.mode!="continuous")throw`expecting tw.q.mode='discrete'|'binary'|'continous', got '${e.q.mode}'`;if(e.q.type&&e.q.type!="regular-bin")throw`expecting tw.q.type='regular-bin', got '${e.q.type}'`;if(!e.q.first_bin||!a(e.q.bin_size))He(e);if(!a(e.q.bin_size))throw`tw.q.bin_size=${e.q.bin_size} is not numeric`;if(!e.q.first_bin)throw`missing tw.q.first_bin`;if(!a((t=e.q.first_bin)===null||t===void 0?void 0:t.stop))throw`tw.q.first_bin.stop is not numeric`;be.setHiddenValues(e.q,e.term);return e}))}}ke=new WeakMap,Pe=new WeakMap;class De extends Ge{constructor(t,i={}){super(t,i);$e.set(this,void 0);Me.set(this,void 0);this.q=t.q;e(this,$e,t,"f");e(this,Me,i,"f")}getTw(){return t(this,$e,"f")}static fill(e,t={}){return i(this,void 0,void 0,(function*(){if(!e.type)e.type="NumTWCustomBin";else if(e.type!="NumTWCustomBin")throw`expecting tw.type='NumTWCustomBin', got '${e.type}'`;if(!e.q.mode)e.q.mode="discrete";else if(e.q.mode!="discrete"&&e.q.mode!="binary"&&e.q.mode!="continuous")throw`expecting tw.q.mode='discrete'|binary|continuous', got '${e.q.mode}'`;if(e.q.mode=="binary"&&!e.q.preferredBins)e.q.preferredBins="median";if(e.q.preferredBins=="median"){const i=yield t.vocabApi.getPercentile(e.term.id,[50]);if(!i.values)throw".values[] missing from vocab.getPercentile()";const n=Oe(i.values[0]);if(!a(n))throw"median value not a number";e.q.type="custom-bin";e.q.lst=[{startunbounded:true,stop:n,stopinclusive:false,label:"<"+n},{start:n,startinclusive:true,stopunbounded:true,label:"≥"+n}];delete e.q.preferredBins}else if(e.q.type!="custom-bin")throw`expecting tw.q.type='custom-bin', got '${e.q.type}'`;if(!Array.isArray(e.q.lst))He(e);if(!e.q.lst||!e.q.lst.length)throw`missing or empty q.lst[] for custom-bin`;if(e.q.mode=="binary"&&e.q.lst.length!=2)throw`numeric q.mode='binary' requires exactly 2 bins`;be.setHiddenValues(e.q,e.term);e.type="NumTWCustomBin";return e}))}}$e=new WeakMap,Me=new WeakMap;class Qe extends Ge{constructor(t,i={}){super(t,i);Le.set(this,void 0);Re.set(this,void 0);this.q=t.q;e(this,Le,t,"f");e(this,Re,i,"f")}getTw(){return t(this,Le,"f")}static fill(e){return i(this,void 0,void 0,(function*(){if(!e.type)e.type="NumTWCont";else if(e.type!="NumTWCont")throw`expecting tw.type='NumTWCont', got '${e.type}'`;if(e.q.mode!="continuous")throw`tw.q.mode='${e.q.mode}', expecting 'continuous'`;be.setHiddenValues(e.q,e.term);e.type="NumTWCont";return e}))}}Le=new WeakMap,Re=new WeakMap;class Ye extends Ge{constructor(t,i={}){super(t,i);We.set(this,void 0);Be.set(this,void 0);this.q=t.q;e(this,We,t,"f");e(this,Be,i,"f")}static fill(e){return i(this,void 0,void 0,(function*(){if(!e.type)e.type="NumTWSpline";else if(e.type!="NumTWSpline")throw`expecting tw.type='NumTWSpline', got '${e.type}'`;if(e.q.mode!="spline")throw`tw.q.mode='${e.q.mode}', expecting 'spline'`;if(!e.q.knots)throw`missing tw.q.knots`;if(!e.q.knots.length)throw`empty tw.q.knots[]`;be.setHiddenValues(e.q,e.term);e.type="NumTWSpline";return e}))}}We=new WeakMap,Be=new WeakMap;const Ue=new Set(["default","less","median"]);function He(e){if(!e.term.bins)throw`missing tw.term.bins`;const t=e.q.preferredBins||"default";if(!Ue.has(t))throw`invalid preferredBins='${t}'`;if(t!="median"){if(!Object.keys(e.term.bins).includes(t));const i=e.term.bins[t];if(e.q.type&&e.q.type!=i.type)throw`mismatched tw.q.type and term.bins[preferredBins].type`;const n=Object.keys(e.q);for(const[t,r]of Object.entries(i)){if(!n.includes(t))e.q[t]=r}delete e.q.preferredBins}}class Xe{constructor(e){this.opts=e}static init(e,t={}){switch(e.type){case"CatTWValues":return new Ne(e,t);case"CatTWPredefinedGS":return new Ae(e,t);case"CatTWCustomGS":return new Ie(e,t);case"NumTWRegularBin":return new Ve(e,t);case"NumTWCustomBin":return new De(e,t);case"NumTWCont":return new Qe(e,t);default:throw`unable to init(tw)`}}static initRaw(e,t={}){return i(this,void 0,void 0,(function*(){const i=yield Xe.fill(e,t);return Xe.init(i,t)}))}static fill(e,t={}){var n,r;return i(this,void 0,void 0,(function*(){yield Xe.preprocess(e,t===null||t===void 0?void 0:t.vocabApi);const i=e.term.type=="float"||e.term.type=="integer"?"numeric":e.term.type;t.defaultQ=((n=t.defaultQByTsHandler)===null||n===void 0?void 0:n[i])||null;switch(e.term.type){case"categorical":{return yield _e.fill(e,t)}case"integer":case"float":return yield Ge.fill(e,t);default:throw`unrecognized tw.term?.type='${(r=e.term)===null||r===void 0?void 0:r.type}'`}}))}static preprocess(e,t){return i(this,void 0,void 0,(function*(){const i=Object.keys(e);if(!i.length)throw`empty tw object`;if(e.id&&!e.term){yield ct([e],t);delete e.id}if(!e.q)e.q={};e.q.isAtomic=true;Xe.reshapeLegacyTw(e)}))}static reshapeLegacyTw(e){if(Object.keys(e.q).includes("groupsetting")){if(!e.q.groupsetting.inuse){e.q.type="values"}else if(e.q.type=="predefined-groupset"){e.q.predefined_groupset_idx=e.q.groupsetting.predefined_groupset_idx}else if(e.q.type=="custom-groupset"){e.q.customset=e.q.groupsetting.customset}else{throw"invalid q.type"}delete e.q["groupsetting"]}}}function Fe(e){switch(e){case"./handlers/categorical.ts":return import("./categorical-1dea48ba.js");case"./handlers/condition.ts":return import("./condition-ebac4f75.js");case"./handlers/density.ts":return import("./density-09feb0c9.js");case"./handlers/geneExpression.ts":return import("./geneExpression-394672ff.js");case"./handlers/geneVariant.ts":return import("./geneVariant-beaf9adb.js");case"./handlers/groupsetting.ts":return import("./groupsetting-e3a4ecd5.js");case"./handlers/metaboliteIntensity.ts":return import("./metaboliteIntensity-bbb23c76.js");case"./handlers/numeric.binary.ts":return import("./numeric.binary-f382cc98.js");case"./handlers/numeric.continuous.ts":return import("./numeric.continuous-6feb34a7.js");case"./handlers/numeric.discrete.ts":return import("./numeric.discrete-ed10bbc1.js");case"./handlers/numeric.spline.ts":return import("./numeric.spline-a35cfbf0.js");case"./handlers/numeric.toggle.ts":return import("./numeric.toggle-2f98d6e5.js");case"./handlers/numeric.ts":return import("./numeric-24dacbee.js");case"./handlers/samplelst.ts":return import("./samplelst-d2db0f24.js");case"./handlers/singleCellCellType.ts":return import("./singleCellCellType-fd1606b8.js");case"./handlers/singleCellGeneExpression.ts":return import("./singleCellGeneExpression-537f1157.js");case"./handlers/snp.ts":return import("./snp-b81ef740.js");case"./handlers/snplocus.ts":return import("./snplocus-acafb1ba.js");case"./handlers/snplst.sampleSum.ts":return import("./snplst.sampleSum-e47d05f0.js");case"./handlers/snplst.ts":return import("./snplst-6865d7c7.js");case"./handlers/survival.ts":return import("./survival-57ff3c03.js");default:return new Promise((function(t,i){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}function ze(e){switch(e){case"./handlers/categorical.ts":return import("./categorical-1dea48ba.js");case"./handlers/condition.ts":return import("./condition-ebac4f75.js");case"./handlers/density.ts":return import("./density-09feb0c9.js");case"./handlers/geneExpression.ts":return import("./geneExpression-394672ff.js");case"./handlers/geneVariant.ts":return import("./geneVariant-beaf9adb.js");case"./handlers/groupsetting.ts":return import("./groupsetting-e3a4ecd5.js");case"./handlers/metaboliteIntensity.ts":return import("./metaboliteIntensity-bbb23c76.js");case"./handlers/numeric.binary.ts":return import("./numeric.binary-f382cc98.js");case"./handlers/numeric.continuous.ts":return import("./numeric.continuous-6feb34a7.js");case"./handlers/numeric.discrete.ts":return import("./numeric.discrete-ed10bbc1.js");case"./handlers/numeric.spline.ts":return import("./numeric.spline-a35cfbf0.js");case"./handlers/numeric.toggle.ts":return import("./numeric.toggle-2f98d6e5.js");case"./handlers/numeric.ts":return import("./numeric-24dacbee.js");case"./handlers/samplelst.ts":return import("./samplelst-d2db0f24.js");case"./handlers/singleCellCellType.ts":return import("./singleCellCellType-fd1606b8.js");case"./handlers/singleCellGeneExpression.ts":return import("./singleCellGeneExpression-537f1157.js");case"./handlers/snp.ts":return import("./snp-b81ef740.js");case"./handlers/snplocus.ts":return import("./snplocus-acafb1ba.js");case"./handlers/snplst.sampleSum.ts":return import("./snplst.sampleSum-e47d05f0.js");case"./handlers/snplst.ts":return import("./snplst-6865d7c7.js");case"./handlers/survival.ts":return import("./survival-57ff3c03.js");default:return new Promise((function(t,i){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}const Je=`_ts_${(+new Date).toString().slice(-8)}`;let Ze=0;function Ke(e){return i(this,void 0,void 0,(function*(){if(!e)return`${Ze++}${Je}`;delete e.$id;return yield tt(JSON.stringify(e))}))}const et=new TextEncoder;function tt(e){return i(this,void 0,void 0,(function*(){const t=et.encode(e);const i=yield crypto.subtle.digest("SHA-1",t);const n=Array.from(new Uint8Array(i));const r=n.map((e=>e.toString(16).padStart(2,"0"))).join("");return it(r).replace("=","-")}))}function it(e){return btoa([...e].reduce(((t,i,n)=>t+=!(n-1&1)?String.fromCharCode(parseInt(e.substring(n-1,n+1),16)):""),""))}const nt={menuOptions:"edit",menuLayout:"vertical"};class rt{constructor(e){this.opts=this.validateOpts(e);this.vocabApi=e.vocabApi;this.activeCohort=e.activeCohort;this.placeholder=e.placeholder;this.durations={exit:0};this.disable_terms=e.disable_terms;this.usecase=e.usecase;this.abbrCutoff=e.abbrCutoff;this.numqByTermIdModeType={};this.dom={holder:e.holder,tip:e.tip||new d({padding:"0px",parent_menu:this.opts.holder&&this.opts.holder.node()&&this.opts.holder.node().closest(".sja_menu_div")})};this.dom.tip2=new d({padding:"0px",parent_menu:this.dom.tip.d.node()});at(this);ot(this);this.initUI();const t=dt(this);this.handlerByType={default:t};this.handler=t;this.hasError=false;this.api={main:this.main.bind(this),runCallback:this.runCallback.bind(this),showTree:this.showTree,showMenu:this.showMenu.bind(this),showGeneSearch:this.showGeneSearch,hasError:()=>this.hasError,validateQ:e=>{if(!this.handler||!this.handler.validateQ)return;try{this.handler.validateQ(e)}catch(e){this.hasError=true;throw e}}}}runCallback(e=null){var t,i;const n=this.term?{term:this.term,q:this.q,isAtomic:true}:{};if("$id"in this)n.$id=this.$id;if(((t=n.q)===null||t===void 0?void 0:t.reuseId)&&n.q.reuseId===((i=this.data.q)===null||i===void 0?void 0:i.reuseId)){if(!p(n.q,this.data.q)){delete n.q.reuseId;delete n.q.name}}const r=e?JSON.parse(JSON.stringify(e)):{};if(this.opts.callback)this.opts.callback(e?o(JSON.stringify(n),r):n)}validateOpts(e){const t=Object.assign({},nt,e);if(!t.holder&&t.renderAs!="none")throw".holder missing";if(typeof t.callback!="function")throw".callback() is not a function";if(!t.vocabApi)throw".vocabApi missing";if(typeof t.vocabApi!="object");if("placeholder"in t&&!t.placeholder&&"placeholderIcon"in t&&!t.placeholderIcon)throw"must specify a non-empty opts.placeholder and/or .placeholderIcon";if(!("placeholder"in t))t.placeholder="Select term&nbsp;";if(!("placeholderIcon"in t))t.placeholderIcon="+";if(!Number.isInteger(t.abbrCutoff))t.abbrCutoff=18;this.validateMenuOptions(t);if(!t.numericEditMenuVersion)t.numericEditMenuVersion=["discrete"];this.mayValidate_noTermPromptOptions(t);return t}main(e={}){return i(this,void 0,void 0,(function*(){try{if(this.doNotHideTipInMain){delete this.doNotHideTipInMain}else{this.dom.tip.hide()}this.hasError=false;delete this.error;this.validateMainData(e);this.data=e;this.term=e.term;this.q=JSON.parse(JSON.stringify(e.q));if("$id"in e)this.$id=e.$id;if("disable_terms"in e)this.disable_terms=e.disable_terms;if("filter"in e)this.filter=e.filter;if("activeCohort"in e)this.activeCohort=e.activeCohort;if("sampleCounts"in e)this.sampleCounts=e.sampleCounts;if("menuOptions"in e)this.opts.menuOptions=e.menuOptions;yield this.setHandler(this.term?this.term.type:null);if(e.term&&this.handler&&this.handler.validateQ)this.handler.validateQ(e);if(this.handler.postMain)yield this.handler.postMain();if(this.opts.renderAs!="none")this.updateUI()}catch(e){this.hasError=true;throw e}}))}validateMainData(e){if(e.term){if(!e.term.type)throw"data.term.type missing";if(x(e.term.type)){if(!e.term.id&&e.term.type!=m.SAMPLELST)throw"data.term.id missing";if(!e.term.name)throw"data.term.name missing"}}if(!e.q)e.q={};if(typeof e.q!="object")throw"data.q{} is not object";if(e.disable_terms){if(!Array.isArray(e.disable_terms))throw"data.disable_terms[] is not array"}this.mayValidate_noTermPromptOptions(e)}validateMenuOptions(e){if(!e.menuOptions)e.menuOptions=nt.menuOptions;if(e.menuOptions=="all")e.menuOptions="*";for(const t of["edit","replace","remove"]){if(X(t,e.menuOptions))return}throw`no matches found for termsetting opts.menuOptions='${e.menuOptions}'`}mayValidate_noTermPromptOptions(e){if(!e.noTermPromptOptions)return;if(!Array.isArray(e.noTermPromptOptions))throw"noTermPromptOptions[] is not array";for(const t of e.noTermPromptOptions){if(t.isDictionary);else{if(!t.termtype)throw"element of noTermPromptOptions[] missing both isDictionary=true and .termtype"}if(!t.text&&!t.html)throw"element of noTermPromptOptions[] missing both .text and .html";if(t.q&&typeof t.q!="object")throw"type.q{} is not object"}this.noTermPromptOptions=e.noTermPromptOptions}setHandler(e){return i(this,void 0,void 0,(function*(){if(!e){this.handler=this.handlerByType.default;return}const t=e=="integer"||e=="float"?"numeric":e;if(!this.handlerByType[t]){try{const e=yield ze(`./handlers/${t}.ts`);this.handlerByType[t]=yield e.getHandler(this)}catch(e){throw`error with handler='./handlers/${t}.ts': ${e}`}}this.handler=this.handlerByType[t]}))}}const st=l(rt);function ot(e){e.initUI=()=>{if(e.opts.$id){e.dom.tip.d.attr("id",e.opts.$id+"-ts-tip")}if(!e.dom.holder)return;e.dom.nopilldiv=e.dom.holder.append("div").style("cursor","pointer").on("click",e.clickNoPillDiv).on(`keyup.sjpp-termdb`,(t=>{if(t.key=="Enter")e.showTree(t)}));e.dom.pilldiv=e.dom.holder.append("div");if(e.opts.placeholder){e.dom.nopilldiv.append("div").html(e.placeholder).attr("class","sja_clbtext2").style("padding","3px 6px 3px 6px").style("display","inline-block")}if(e.opts.placeholderIcon){e.dom.nopilldiv.append("div").attr("class","sja_filter_tag_btn add_term_btn").style("padding","3px 6px 3px 6px").style("display","inline-block").style("border-radius","6px").style("background-color","#4888BF").text(e.opts.placeholderIcon)}e.dom.btnDiv=e.dom.holder.append("div");e.dom.content_holder=u(e.dom.holder.node().parentNode).append("div")};e.updateUI=()=>i(this,void 0,void 0,(function*(){e.dom.btnDiv.selectAll("*").remove();e.dom.content_holder.selectAll("*").remove();if(!e.term){e.dom.nopilldiv.style("display","block");e.dom.pilldiv.style("display","none");e.dom.btnDiv.style("display","none");return}if(e.term.hashtmldetail){if(e.opts.buttons&&!e.opts.buttons.includes("info"))e.opts.buttons.unshift("info");else e.opts.buttons=["info"]}else{e.opts.buttons=[]}if(e.opts.buttons.length){e.dom.btnDiv.selectAll("div").data(e.opts.buttons).enter().append("div").style("display","inline-block").style("padding","0px 5px").style("cursor","pointer").style("color","#999").style("font-size",".8em").html((e=>e.toUpperCase())).on("click",((t,i)=>{if(i=="delete")e.removeTerm();else if(i=="replace"){e.showTree(t.target)}else throw"unknown button"}));if(e.term.hashtmldetail){const t=e.dom.btnDiv.selectAll("div").filter((function(){return u(this).text()==="INFO"}));const i=yield import("./termInfo-491b10af.js");i.termInfoInit({vocabApi:e.opts.vocabApi,icon_holder:t,content_holder:e.dom.content_holder,id:e.term.id,state:{term:e.term}})}}e.dom.nopilldiv.style("display","none");e.dom.pilldiv.style("display",e.opts.buttons?"inline-block":"block");e.dom.btnDiv.style("display",e.opts.buttons?"inline-block":"none");const t=e.dom.pilldiv.selectAll(".ts_pill").data([e.term],(e=>e.id));t.exit().each(e.exitPill);t.transition().duration(200).each(e.updatePill);t.enter().append("div").attr("class","ts_pill").style("display","grid").style("grid-template-columns","auto").style("grid-template-areas",'"left right"').style("cursor","pointer").style("margin","2px").on("click",e.showMenu).transition().duration(200).each(e.enterPill)}));e.enterPill=function(){return i(this,void 0,void 0,(function*(){const t=u(this);e.dom.pill_termname=t.append("div").attr("class","term_name_btn sja_filter_tag_btn").attr("tabindex",0).style("display","flex").style("grid-area","left").style("position","relative").style("align-items","center").style("padding","3px 6px 3px 6px").style("border-radius","6px").html(e.handler.getPillName).on(`keyup.sjpp-termdb`,(e=>{if(e.key=="Enter")e.target.click()}));e.updatePill.call(this)}))};e.updatePill=function(){return i(this,void 0,void 0,(function*(){const t=u(this);const i=e.handler.getPillStatus()||{};e.dom.pill_termname.style("border-radius",i.text?"6px 0 0 6px":"6px").html(e.handler.getPillName);const n=t.selectAll(".ts_summary_btn").data(i.text?[{txt:i.text}]:[],(e=>e.txt));n.exit().remove();const r=n.enter().append("div").attr("class","ts_summary_btn sja_filter_tag_btn").style("display","flex").style("grid-area","right").style("position","relative").style("align-items","center").style("padding","3px 6px 3px 6px").style("border-radius","0 6px 6px 0").style("font-style","italic").html((e=>e.txt)).style("opacity",0).transition().duration(200).style("opacity",1);if(i.bgcolor){r.transition().duration(200).style("background-color",i.bgcolor)}}))};e.exitPill=function(){u(this).style("opacity",1).transition().duration(e.durations.exit).style("opacity",0).remove()}}function at(e){e.removeTerm=()=>{e.opts.callback(null)};e.cancelGroupsetting=()=>{e.opts.callback({id:e.term.id,term:e.term,q:{mode:"discrete",type:"values",isAtomic:true}})};e.clickNoPillDiv=()=>i(this,void 0,void 0,(function*(){if(!e.noTermPromptOptions||e.noTermPromptOptions.length==0){yield e.showTree(e.dom.nopilldiv.node());return}e.dom.tip.clear().showunder(e.dom.nopilldiv.node());for(const t of e.noTermPromptOptions){const n=e.dom.tip.d.append("div").attr("class","sja_menuoption sja_sharp_border").on("click",(()=>i(this,void 0,void 0,(function*(){e.dom.tip.clear();if(t.isDictionary){yield e.showTree(e.dom.tip.d.node())}else if(t.termtype){if(t.q)e.q=structuredClone(t.q);yield e.setHandler(t.termtype);if(q(e.term)&&!e.term.bins&&e.term.type!="survival"){yield e.vocabApi.setTermBins({term:e.term,q:e.q})}e.handler.showEditMenu(e.dom.tip.d)}else{throw"termtype missing"}}))));if(t.text)n.text(t.text);else if(t.html)n.html(t.html)}}));e.showTree=function(t,n){return i(this,void 0,void 0,(function*(){e.dom.tip.clear();if(t)e.dom.tip.showunder(t instanceof Element?t:this instanceof Element?this:e.dom.holder.node());else e.dom.tip.show(n.clientX,n.clientY);if(!e.usecase)e.usecase={target:"default"};const r=yield import("./app-d215327f.js");r.appInit({holder:e.dom.tip.d,vocabApi:e.vocabApi,state:{activeCohort:e.activeCohort,tree:{usecase:e.usecase}},tree:{disable_terms:e.disable_terms,click_term:t=>i(this,void 0,void 0,(function*(){e.dom.tip.hide();let i;if(t.term)i=t;else{const e=t;i={term:e,q:{isAtomic:true},isAtomic:true}}if(e.opts.customFillTw)e.opts.customFillTw(i);yield yt(i,e.vocabApi,e.opts.defaultQ4fillTW);e.opts.callback(i)}))}})}))};e.showMenu=(t,n=null,r=null)=>{var s,o,a;const l=e.dom.tip;l.clear();if(e.opts.renderAs=="none"&&n)e.dom.holder=u(n);if(e.dom.holder){const i=(s=e.dom.holder)===null||s===void 0?void 0:s.node();if(i)l.showunder(i);else l.show(t.clientX,t.clientY)}const d=[];if(e.q.type=="predefined-groupset"||e.q.type=="custom-groupset"){if(e.q.mode!="binary"&&e.term.type!="geneVariant"){d.push({label:"Cancel grouping",callback:e.cancelGroupsetting})}}if(e.q&&!((o=e.term.groupsetting)===null||o===void 0?void 0:o.disabled)&&X("edit",e.opts.menuOptions)){d.push({label:"Edit",callback:t=>i(this,void 0,void 0,(function*(){if(e.term&&q(e.term)&&!e.term.bins&&e.term.type!="survival"){yield e.vocabApi.setTermBins({term:e.term,q:e.q})}e.handler.showEditMenu(t)}))})}if(X("replace",e.opts.menuOptions)){d.push({label:"Replace",callback:e.showTree})}if(X("remove",e.opts.menuOptions)){d.push({label:"Remove",callback:e.removeTerm})}if(e.opts.customMenuOptions)d.push(...e.opts.customMenuOptions);e.openMenu=r||l.d;e.openMenu.selectAll("div").data(d).enter().append("div").attr("class","sja_menuoption sja_sharp_border").attr("tabindex",((e,t)=>t+1)).style("display",e.opts.menuLayout=="horizontal"?"inline-block":"block").text((e=>e.label)).on("click",((t,i)=>{e.dom.tip.clear();i.callback(e.dom.tip.d)})).on("keyup",(e=>{if(e.key=="Enter")e.target.click()}));(a=e.openMenu.select(".sja_menuoption").node())===null||a===void 0?void 0:a.focus()};e.showReuseMenu=function(t){return i(this,void 0,void 0,(function*(){const n=t.append("div");n.style("display","block").style("padding","10px").append("span").style("color","#aaa").html("Save current setting as ");const r=e.vocabApi.getCustomTermQLst(e.term);const s=n.append("input").attr("type","text").attr("placeholder",r.nextReuseId).attr("value",e.q.reuseId||r.nextReuseId);n.append("button").style("margin-left","5px").html("Save").on("click",(()=>{const t=s.property("value").trim()||r.nextReuseId;e.q.reuseId=t;e.vocabApi.cacheTermQ(e.term,e.q);e.runCallback();e.dom.tip.hide()}));const o=t.append("div").style("margin","10px");const a={term:e.term,q:{}};yield ht(a,e.vocabApi);a.q.reuseId="Default";r.push(a.q);if(r.length>1){o.append("div").style("color","#aaa").html("Previously saved settings")}o.append("table").selectAll("tr").data(r).enter().append("tr").style("margin","2px 5px").each((function(t){const n=u(this);const r=lt(e.q,t);const s=t.name||t.reuseId;n.append("td").style("min-width","180px").style("text-align","center").html(s);const o=n.append("td").style("text-align","center");if(r){o.html(`In use <span style='color:#5a5;font-weight:600'>&check;</span>`)}else{o.append("button").style("min-width","80px").html("Use").on("click",(()=>{if(t.reuseId==="Default"){delete t.reuseId;delete t.name}e.q=t;e.dom.tip.hide();e.runCallback()}))}const a=n.append("td").style("text-align","center");if(!r&&t.reuseId!="Default"){a.append("button").style("min-width","80px").html("Delete").on("click",(()=>i(this,void 0,void 0,(function*(){yield e.vocabApi.uncacheTermQ(e.term,t);e.dom.tip.hide();e.runCallback()}))))}}));t.append("div").style("margin","20px 5px 5px 5px").style("padding","5px").style("font-size","0.8em").style("color","#aaa").html(`Saving the setting will allow it to be reused at another chart.<br/>`+`The setting will be reusable in your current or saved session.`)}))};e.showGeneSearch=function(t,n){e.dom.tip.clear();if(t)e.dom.tip.showunder(t instanceof Element?t:this instanceof Element?this:e.dom.holder.node());else e.dom.tip.show(n.clientX,n.clientY);const r=new Set;const s=e.dom.tip.d.append("div").style("padding","5px");const o=s.append("label");o.append("span").text("Search: ");const a=o.append("input").attr("type","text").on("input",(()=>i(this,void 0,void 0,(function*(){const t=a.property("value");try{const i=!t?{lst:[]}:yield e.vocabApi.findTerm(t,e.activeCohort,e.usecase,"gene");l.selectAll("*").remove();l.selectAll("div").data(i.lst.filter((e=>!r.has(e)))).enter().append("div").attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term").style("display","block").style("margin","2px 3px").style("width","fit-content").text((e=>e.name)).on("click",(t=>{e.dom.tip.hide();e.runCallback({term:{name:t.name,type:"geneVariant"},q:{exclude:[]}})}))}catch(e){alert("Search error: "+e)}}))));const l=e.dom.tip.d.append("div").style("margin","5px").style("padding-left","5px").style("border-left","2px solid #ccc")}}function lt(e,t){const i=[e,t].map((e=>JSON.parse(JSON.stringify(e))));for(const e of i){delete e.binLabelFormatter;if(e.reuseId==="Default")delete e.reuseId;if(e.mode==="continuous")delete e.mode;if(e.mode==="discrete"&&e.type=="custom-bin"&&e.lst){for(const t of e.lst){delete t.range}}}return p(...i)}function dt(e){return{showEditMenu(){},getPillStatus(){},getPillName(t){return pt(e,t)}}}function pt(e,t){if(!e.opts.abbrCutoff)return t.name;return t.name.length<=e.opts.abbrCutoff+2?t.name:'<label title="'+t.name+'">'+t.name.substring(0,e.opts.abbrCutoff)+"..."+"</label>"}function ut(e,t,n){return i(this,void 0,void 0,(function*(){yield ct(e,t);const i=[];for(const r of e){i.push(ht(r,t,n))}yield Promise.all(i)}))}function ct(e,t){return i(this,void 0,void 0,(function*(){const i=[];for(const t of e){if(t.term)continue;if(t.id===undefined||t.id==="")throw".id is required";i.push(t.id)}const n=i.length?yield t.getTerms(i):{};for(const t of i){if(!n[t])throw`missing dictionary term for id=${t}`;for(const t of e){if(t.id&&t.id in n)t.term=n[t.id]}}}))}const ft=new Set(["categorical","integer","float"]);function ht(e,t,n){var r;return i(this,void 0,void 0,(function*(){e.isAtomic=true;if(!e.term&&e.id){yield ct([e],t)}if(ft.has((r=e.term)===null||r===void 0?void 0:r.type)){const i=yield Xe.fill(e,{vocabApi:t,defaultQByTsHandler:n});Object.assign(e,i);gt(e);if(!e.$id)e.$id=yield Ke(t.getTwMinCopy(e));if(e.q)e.q.isAtomic=true;return e}delete e.id;if(!e.q)e.q={};e.q.isAtomic=true;mt(e);yield yt(e,t,n);gt(e);if(!e.$id)e.$id=yield Ke(t.getTwMinCopy(e));return e}))}function mt(e){if(Object.keys(e.q).includes("groupsetting")){if(e.q["groupsetting"]["inuse"]){if(e.q.type=="predefined-groupset"){e.q["predefined_groupset_idx"]=e.q["groupsetting"]["predefined_groupset_idx"]}else if(e.q.type=="custom-groupset"){e.q["customset"]=e.q["groupsetting"]["customset"]}else{throw"invalid q.type"}}else{e.q.type="values"}delete e.q["groupsetting"]}}function yt(e,t,n){return i(this,void 0,void 0,(function*(){if(!e.$id)e.$id=yield Ke(t.getTwMinCopy(e));const i=e.term.type;const r=i=="float"||i=="integer"?"numeric":i;let s;if(e.term.type){try{s=yield Fe(`./handlers/${r}.ts`)}catch(e){throw`Type ${r} does not exist`}}else throw`Type not defined for ${JSON.stringify(e)}`;yield s.fillTW(e,t,n?n[r]:null)}))}function gt(e){if(!("mode"in e.q)){return}if(typeof e.q.mode!="string")throw"q.mode not string"}function vt(e,t){if(!e.hiddenValues){e.hiddenValues={};if(t.values){for(const i in t.values){if(t.values[i].uncomputable)e.hiddenValues[i]=1}}}}export{h as N,f as R,m as T,T as a,x as b,Oe as c,E as d,S as e,ht as f,Ke as g,st as h,q as i,je as j,y as k,Xe as l,ut as m,b as n,pt as o,Ce as r,vt as s,g as t};
1
+ import{a as e,b as t,_ as i}from"./tslib.es6-c3c2d88f.js";import{R as n,S as r,T as s,P as o,H as a,i as l,M as d,F as p,d as u}from"./app-0de0ae35.js";import c from"path";const f=1;const h={continuous:"continuous",discrete:"discrete"};const m={GENE_VARIANT:"geneVariant",GENE_EXPRESSION:"geneExpression",CATEGORICAL:"categorical",INTEGER:"integer",FLOAT:"float",SNP:"snp",SNP_LIST:"snplst",SNP_LOCUS:"snplocus",CONDITION:"condition",SURVIVAL:"survival",SAMPLELST:"samplelst",METABOLITE_INTENSITY:"metaboliteIntensity",SINGLECELL_GENE_EXPRESSION:"singleCellGeneExpression",SINGLECELL_CELLTYPE:"singleCellCellType"};const y={[m.GENE_EXPRESSION]:n,[m.METABOLITE_INTENSITY]:r};const g={[m.CATEGORICAL]:s.DICTIONARY_VARIABLES,[m.CONDITION]:s.DICTIONARY_VARIABLES,[m.FLOAT]:s.DICTIONARY_VARIABLES,[m.INTEGER]:s.DICTIONARY_VARIABLES,[m.SAMPLELST]:s.DICTIONARY_VARIABLES,[m.SURVIVAL]:s.DICTIONARY_VARIABLES,[m.GENE_VARIANT]:s.MUTATION_CNV_FUSION,[m.SNP]:s.SNP,[m.SNP_LIST]:s.SNP_LIST,[m.SNP_LOCUS]:s.SNP_LOCUS,[m.GENE_EXPRESSION]:s.GENE_EXPRESSION,[m.METABOLITE_INTENSITY]:s.METABOLITE_INTENSITY};const v=new Set([m.SNP,m.SNP_LIST,m.SNP_LOCUS,m.GENE_EXPRESSION,m.GENE_VARIANT,m.METABOLITE_INTENSITY,m.SINGLECELL_GENE_EXPRESSION,m.SINGLECELL_CELLTYPE]);const b=new Set([m.INTEGER,m.FLOAT,m.GENE_EXPRESSION,m.METABOLITE_INTENSITY,m.SINGLECELL_GENE_EXPRESSION]);const w=new Set([m.CATEGORICAL,m.SNP]);function q(e){if(!e)return false;return b.has(e.type)}function T(e){if(!e)return false;return w.has(e.type)}function x(e){return!E(e)}function E(e){if(!e)throw new Error("Type is not defined");return v.has(e)}function S(e,t){if(!e)throw new Error("First term is not defined ");if(!t)throw new Error("Second term is not defined ");if(e.type!==t.type)return false;if(x(e.type)&&x(t.type)&&e.type!=m.SAMPLELST)return e.id===t.id;switch(e.type){case m.GENE_EXPRESSION:return e.gene==t.gene;case m.METABOLITE_INTENSITY:return e.name==t.name;case m.GENE_VARIANT:return e.gene==t.gene||e.chr==t.chr&&e.start==t.start&&e.stop==t.stop;default:return false}}var _=function(e,t){var i=[];for(var n=0;n<e.length;n++){var r=t(e[n],n);if(N(r))i.push.apply(i,r);else i.push(r)}return i};var N=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};var A=I;function I(e,t,i){if(e instanceof RegExp)e=C(e,i);if(t instanceof RegExp)t=C(t,i);var n=O(e,t,i);return n&&{start:n[0],end:n[1],pre:i.slice(0,n[0]),body:i.slice(n[0]+e.length,n[1]),post:i.slice(n[1]+t.length)}}function C(e,t){var i=t.match(e);return i?i[0]:null}I.range=O;function O(e,t,i){var n,r,s,o,a;var l=i.indexOf(e);var d=i.indexOf(t,l+1);var p=l;if(l>=0&&d>0){if(e===t){return[l,d]}n=[];s=i.length;while(p>=0&&!a){if(p==l){n.push(p);l=i.indexOf(e,p+1)}else if(n.length==1){a=[n.pop(),d]}else{r=n.pop();if(r<s){s=r;o=d}d=i.indexOf(t,p+1)}p=l<d&&l>=0?l:d}if(n.length){a=[s,o]}}return a}var j=V;var k="\0SLASH"+Math.random()+"\0";var P="\0OPEN"+Math.random()+"\0";var $="\0CLOSE"+Math.random()+"\0";var M="\0COMMA"+Math.random()+"\0";var L="\0PERIOD"+Math.random()+"\0";function R(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function W(e){return e.split("\\\\").join(k).split("\\{").join(P).split("\\}").join($).split("\\,").join(M).split("\\.").join(L)}function B(e){return e.split(k).join("\\").split(P).join("{").split($).join("}").split(M).join(",").split(L).join(".")}function G(e){if(!e)return[""];var t=[];var i=A("{","}",e);if(!i)return e.split(",");var n=i.pre;var r=i.body;var s=i.post;var o=n.split(",");o[o.length-1]+="{"+r+"}";var a=G(s);if(s.length){o[o.length-1]+=a.shift();o.push.apply(o,a)}t.push.apply(t,o);return t}function V(e){if(!e)return[];if(e.substr(0,2)==="{}"){e="\\{\\}"+e.substr(2)}return H(W(e),true).map(B)}function D(e){return"{"+e+"}"}function Q(e){return/^-?0\d/.test(e)}function Y(e,t){return e<=t}function U(e,t){return e>=t}function H(e,t){var i=[];var n=A("{","}",e);if(!n||/\$$/.test(n.pre))return[e];var r=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body);var s=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body);var o=r||s;var a=n.body.indexOf(",")>=0;if(!o&&!a){if(n.post.match(/,.*\}/)){e=n.pre+"{"+n.body+$+n.post;return H(e)}return[e]}var l;if(o){l=n.body.split(/\.\./)}else{l=G(n.body);if(l.length===1){l=H(l[0],false).map(D);if(l.length===1){var d=n.post.length?H(n.post,false):[""];return d.map((function(e){return n.pre+l[0]+e}))}}}var p=n.pre;var d=n.post.length?H(n.post,false):[""];var u;if(o){var c=R(l[0]);var f=R(l[1]);var h=Math.max(l[0].length,l[1].length);var m=l.length==3?Math.abs(R(l[2])):1;var y=Y;var g=f<c;if(g){m*=-1;y=U}var v=l.some(Q);u=[];for(var b=c;y(b,f);b+=m){var w;if(s){w=String.fromCharCode(b);if(w==="\\")w=""}else{w=String(b);if(v){var q=h-w.length;if(q>0){var T=new Array(q+1).join("0");if(b<0)w="-"+T+w.slice(1);else w=T+w}}}u.push(w)}}else{u=_(l,(function(e){return H(e,false)}))}for(var x=0;x<u.length;x++){for(var E=0;E<d.length;E++){var S=p+u[x]+d[E];if(!t||o||S)i.push(S)}}return i}var X=ae;ae.Minimatch=le;var F=function(){try{return c}catch(e){}}()||{sep:"/"};ae.sep=F.sep;var z=ae.GLOBSTAR=le.GLOBSTAR={};var J={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}};var Z="[^/]";var K=Z+"*?";var ee="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";var te="(?:(?!(?:\\/|^)\\.).)*?";var ie=ne("().*{}+?[]^$\\!");function ne(e){return e.split("").reduce((function(e,t){e[t]=true;return e}),{})}var re=/\/+/;ae.filter=se;function se(e,t){t=t||{};return function(i,n,r){return ae(i,e,t)}}function oe(e,t){t=t||{};var i={};Object.keys(e).forEach((function(t){i[t]=e[t]}));Object.keys(t).forEach((function(e){i[e]=t[e]}));return i}ae.defaults=function(e){if(!e||typeof e!=="object"||!Object.keys(e).length){return ae}var t=ae;var i=function i(n,r,s){return t(n,r,oe(e,s))};i.Minimatch=function i(n,r){return new t.Minimatch(n,oe(e,r))};i.Minimatch.defaults=function i(n){return t.defaults(oe(e,n)).Minimatch};i.filter=function i(n,r){return t.filter(n,oe(e,r))};i.defaults=function i(n){return t.defaults(oe(e,n))};i.makeRe=function i(n,r){return t.makeRe(n,oe(e,r))};i.braceExpand=function i(n,r){return t.braceExpand(n,oe(e,r))};i.match=function(i,n,r){return t.match(i,n,oe(e,r))};return i};le.defaults=function(e){return ae.defaults(e).Minimatch};function ae(e,t,i){fe(t);if(!i)i={};if(!i.nocomment&&t.charAt(0)==="#"){return false}return new le(t,i).match(e)}function le(e,t){if(!(this instanceof le)){return new le(e,t)}fe(e);if(!t)t={};e=e.trim();if(!t.allowWindowsEscape&&F.sep!=="/"){e=e.split(F.sep).join("/")}this.options=t;this.set=[];this.pattern=e;this.regexp=null;this.negate=false;this.comment=false;this.empty=false;this.partial=!!t.partial;this.make()}le.prototype.debug=function(){};le.prototype.make=de;function de(){var e=this.pattern;var t=this.options;if(!t.nocomment&&e.charAt(0)==="#"){this.comment=true;return}if(!e){this.empty=true;return}this.parseNegate();var i=this.globSet=this.braceExpand();if(t.debug)this.debug=function e(){console.error.apply(console,arguments)};this.debug(this.pattern,i);i=this.globParts=i.map((function(e){return e.split(re)}));this.debug(this.pattern,i);i=i.map((function(e,t,i){return e.map(this.parse,this)}),this);this.debug(this.pattern,i);i=i.filter((function(e){return e.indexOf(false)===-1}));this.debug(this.pattern,i);this.set=i}le.prototype.parseNegate=pe;function pe(){var e=this.pattern;var t=false;var i=this.options;var n=0;if(i.nonegate)return;for(var r=0,s=e.length;r<s&&e.charAt(r)==="!";r++){t=!t;n++}if(n)this.pattern=e.substr(n);this.negate=t}ae.braceExpand=function(e,t){return ue(e,t)};le.prototype.braceExpand=ue;function ue(e,t){if(!t){if(this instanceof le){t=this.options}else{t={}}}e=typeof e==="undefined"?this.pattern:e;fe(e);if(t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)){return[e]}return j(e)}var ce=1024*64;var fe=function(e){if(typeof e!=="string"){throw new TypeError("invalid pattern")}if(e.length>ce){throw new TypeError("pattern is too long")}};le.prototype.parse=me;var he={};function me(e,t){fe(e);var i=this.options;if(e==="**"){if(!i.noglobstar)return z;else e="*"}if(e==="")return"";var n="";var r=!!i.nocase;var s=false;var o=[];var a=[];var l;var d=false;var p=-1;var u=-1;var c=e.charAt(0)==="."?"":i.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)";var f=this;function h(){if(l){switch(l){case"*":n+=K;r=true;break;case"?":n+=Z;r=true;break;default:n+="\\"+l;break}f.debug("clearStateChar %j %j",l,n);l=false}}for(var m=0,y=e.length,g;m<y&&(g=e.charAt(m));m++){this.debug("%s\t%s %s %j",e,m,n,g);if(s&&ie[g]){n+="\\"+g;s=false;continue}switch(g){case"/":{return false}case"\\":h();s=true;continue;case"?":case"*":case"+":case"@":case"!":this.debug("%s\t%s %s %j <-- stateChar",e,m,n,g);if(d){this.debug(" in class");if(g==="!"&&m===u+1)g="^";n+=g;continue}f.debug("call clearStateChar %j",l);h();l=g;if(i.noext)h();continue;case"(":if(d){n+="(";continue}if(!l){n+="\\(";continue}o.push({type:l,start:m-1,reStart:n.length,open:J[l].open,close:J[l].close});n+=l==="!"?"(?:(?!(?:":"(?:";this.debug("plType %j %j",l,n);l=false;continue;case")":if(d||!o.length){n+="\\)";continue}h();r=true;var v=o.pop();n+=v.close;if(v.type==="!"){a.push(v)}v.reEnd=n.length;continue;case"|":if(d||!o.length||s){n+="\\|";s=false;continue}h();n+="|";continue;case"[":h();if(d){n+="\\"+g;continue}d=true;u=m;p=n.length;n+=g;continue;case"]":if(m===u+1||!d){n+="\\"+g;s=false;continue}var b=e.substring(u+1,m);try{RegExp("["+b+"]")}catch(e){var w=this.parse(b,he);n=n.substr(0,p)+"\\["+w[0]+"\\]";r=r||w[1];d=false;continue}r=true;d=false;n+=g;continue;default:h();if(s){s=false}else if(ie[g]&&!(g==="^"&&d)){n+="\\"}n+=g}}if(d){b=e.substr(u+1);w=this.parse(b,he);n=n.substr(0,p)+"\\["+w[0];r=r||w[1]}for(v=o.pop();v;v=o.pop()){var q=n.slice(v.reStart+v.open.length);this.debug("setting tail",n,v);q=q.replace(/((?:\\{2}){0,64})(\\?)\|/g,(function(e,t,i){if(!i){i="\\"}return t+t+i+"|"}));this.debug("tail=%j\n %s",q,q,v,n);var T=v.type==="*"?K:v.type==="?"?Z:"\\"+v.type;r=true;n=n.slice(0,v.reStart)+T+"\\("+q}h();if(s){n+="\\\\"}var x=false;switch(n.charAt(0)){case"[":case".":case"(":x=true}for(var E=a.length-1;E>-1;E--){var S=a[E];var _=n.slice(0,S.reStart);var N=n.slice(S.reStart,S.reEnd-8);var A=n.slice(S.reEnd-8,S.reEnd);var I=n.slice(S.reEnd);A+=I;var C=_.split("(").length-1;var O=I;for(m=0;m<C;m++){O=O.replace(/\)[+*?]?/,"")}I=O;var j="";if(I===""&&t!==he){j="$"}var k=_+N+I+j+A;n=k}if(n!==""&&r){n="(?=.)"+n}if(x){n=c+n}if(t===he){return[n,r]}if(!r){return ge(e)}var P=i.nocase?"i":"";try{var $=new RegExp("^"+n+"$",P)}catch(e){return new RegExp("$.")}$._glob=e;$._src=n;return $}ae.makeRe=function(e,t){return new le(e,t||{}).makeRe()};le.prototype.makeRe=ye;function ye(){if(this.regexp||this.regexp===false)return this.regexp;var e=this.set;if(!e.length){this.regexp=false;return this.regexp}var t=this.options;var i=t.noglobstar?K:t.dot?ee:te;var n=t.nocase?"i":"";var r=e.map((function(e){return e.map((function(e){return e===z?i:typeof e==="string"?ve(e):e._src})).join("\\/")})).join("|");r="^(?:"+r+")$";if(this.negate)r="^(?!"+r+").*$";try{this.regexp=new RegExp(r,n)}catch(e){this.regexp=false}return this.regexp}ae.match=function(e,t,i){i=i||{};var n=new le(t,i);e=e.filter((function(e){return n.match(e)}));if(n.options.nonull&&!e.length){e.push(t)}return e};le.prototype.match=function e(t,i){if(typeof i==="undefined")i=this.partial;this.debug("match",t,this.pattern);if(this.comment)return false;if(this.empty)return t==="";if(t==="/"&&i)return true;var n=this.options;if(F.sep!=="/"){t=t.split(F.sep).join("/")}t=t.split(re);this.debug(this.pattern,"split",t);var r=this.set;this.debug(this.pattern,"set",r);var s;var o;for(o=t.length-1;o>=0;o--){s=t[o];if(s)break}for(o=0;o<r.length;o++){var a=r[o];var l=t;if(n.matchBase&&a.length===1){l=[s]}var d=this.matchOne(l,a,i);if(d){if(n.flipNegate)return true;return!this.negate}}if(n.flipNegate)return false;return this.negate};le.prototype.matchOne=function(e,t,i){var n=this.options;this.debug("matchOne",{this:this,file:e,pattern:t});this.debug("matchOne",e.length,t.length);for(var r=0,s=0,o=e.length,a=t.length;r<o&&s<a;r++,s++){this.debug("matchOne loop");var l=t[s];var d=e[r];this.debug(t,l,d);if(l===false)return false;if(l===z){this.debug("GLOBSTAR",[t,l,d]);var p=r;var u=s+1;if(u===a){this.debug("** at the end");for(;r<o;r++){if(e[r]==="."||e[r]===".."||!n.dot&&e[r].charAt(0)===".")return false}return true}while(p<o){var c=e[p];this.debug("\nglobstar while",e,p,t,u,c);if(this.matchOne(e.slice(p),t.slice(u),i)){this.debug("globstar found match!",p,o,c);return true}else{if(c==="."||c===".."||!n.dot&&c.charAt(0)==="."){this.debug("dot detected!",e,p,t,u);break}this.debug("globstar swallow a segment, and continue");p++}}if(i){this.debug("\n>>> no match, partial?",e,p,t,u);if(p===o)return true}return false}var f;if(typeof l==="string"){f=d===l;this.debug("string match",l,d,f)}else{f=d.match(l);this.debug("pattern match",l,d,f)}if(!f)return false}if(r===o&&s===a){return true}else if(r===o){return i}else if(s===a){return r===o-1&&e[r]===""}throw new Error("wtf?")};function ge(e){return e.replace(/\\(.)/g,"$1")}function ve(e){return e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}class be{constructor(e,t){var i;this.isAtomic=true;this.type=e.type;this.isAtomic=true;if(e.$id)this.$id=e.$id;if((i=t.addons)===null||i===void 0?void 0:i[this.type]){Object.defineProperties(this,t.addons[this.type])}}static setHiddenValues(e,t){if(e.hiddenValues)return;e.hiddenValues={};if(t.values){for(const i in t.values){if(t.values[i].uncomputable)e.hiddenValues[i]=1}}}render(e){console.log(e);throw`should implement this method in subclass code, as needed`}}var we,qe,Te,xe,Ee,Se;class _e extends be{constructor(e,t){super(e,t);this.term=e.term}static fill(e,t={}){var i;if(!e.term)throw`missing tw.term, must already be filled in`;if(e.term.type!="categorical")throw`incorrect term.type='${(i=e.term)===null||i===void 0?void 0:i.type}', expecting 'categorical'`;if(t.defaultQ!=null){t.defaultQ.isAtomic=true;o(e.q,t.defaultQ)}if(!e.q.mode)e.q.mode="discrete";if(!e.q)e.q={type:"values",isAtomic:true};if(!e.type)e.type=!e.q.type||e.q.type=="values"?"CatTWValues":e.q.type=="predefined-groupset"?"CatTWPredefinedGS":e.q.type=="custom-groupset"?"CatTWCustomGS":undefined;switch(e.type){case"CatTWValues":return Ne.fill(e);case"CatTWPredefinedGS":return Ae.fill(e);case"CatTWCustomGS":return Ie.fill(e);default:throw`tw.type='${e.type} (q.mode:q.type=${e.q.mode}:${e.q.type}' is not supported by CategoricalBase.fill()`}}}class Ne extends _e{constructor(t,i={}){super(t,i);we.set(this,void 0);qe.set(this,void 0);this.q=t.q;e(this,we,t,"f");e(this,qe,i,"f")}getTw(){return t(this,we,"f")}static fill(e){if(!e.type)e.type="CatTWValues";else if(e.type!="CatTWValues")throw`expecting tw.type='CatTWValues', got '${e.type}'`;if(e.term.type!="categorical")throw`expecting tw.term.type='categorical', got '${e.term.type}'`;const{term:t,q:i}=e;if(!i.type)i.type="values";else if(i.type!="values")throw`expecting tw.q.type='values', got ${e.q.type}`;if(!t.values)t.values={};if(i.mode=="binary"){if(Object.keys(e.term.values).length!=2)throw"term.values must have exactly two keys"}vt(i,t);return e}}we=new WeakMap,qe=new WeakMap;class Ae extends _e{constructor(i,n={}){super(i,n);Te.set(this,void 0);xe.set(this,void 0);this.q=i.q;e(this,Te,i,"f");Object.defineProperty(this,"groupset",{value:this.term.groupsetting[t(this,Te,"f").q.predefined_groupset_idx]});e(this,xe,n,"f")}getTw(){return t(this,Te,"f")}static fill(e){var t,i;if(!e.type)e.type="CatTWPredefinedGS";else if(e.type!="CatTWPredefinedGS")throw`expecting tw.type='CatTWPredefinedGS', got '${e.type}'`;if(e.term.type!="categorical")throw`expecting tw.term.type='categorical', got '${e.term.type}'`;if(e.q.type!="predefined-groupset")throw`expecting tw.q.type='predefined-groupset', got '${e.q.type}'`;const{term:n,q:r}=e;const s=r.predefined_groupset_idx;if(s!==undefined&&!Number.isInteger(s))throw`missing or invalid tw.q.predefined_groupset_idx='${s}'`;r.predefined_groupset_idx=s||0;const o=e.term.groupsetting;if(!o)throw"no term.groupsetting";if(!((t=o.lst)===null||t===void 0?void 0:t.length))throw"term.groupsetting.lst is empty";const a=(i=o.lst)===null||i===void 0?void 0:i[r.predefined_groupset_idx];if(!a)throw`no groupset entry for groupsetting.lst?.[predefined_groupset_idx=${s}]`;if(r.mode=="binary"){if(a.groups.length!=2)throw"there must be exactly two groups"}vt(r,n);return e}}Te=new WeakMap,xe=new WeakMap;class Ie extends _e{constructor(t,i={}){super(t,i);Ee.set(this,void 0);Se.set(this,void 0);this.q=t.q;Object.defineProperty(this,"groupset",{value:this.q.customset});e(this,Ee,t,"f");e(this,Se,i,"f")}getTw(){return t(this,Ee,"f")}static fill(e){if(!e.type)e.type="CatTWCustomGS";else if(e.type!="CatTWCustomGS")throw`expecting tw.type='CatTWCustomGS', got '${e.type}'`;if(e.term.type!="categorical")throw`expecting tw.term.type='categorical', got '${e.term.type}'`;if(e.q.type!="custom-groupset")throw`expecting tw.q.type='custom-groupset', got '${e.q.type}'`;const{term:t,q:i}=e;if(!i.customset)throw`missing tw.q.customset`;if(i.mode=="binary"){if(i.customset.groups.length!=2)throw"there must be exactly two groups"}vt(i,t);return e}}Ee=new WeakMap,Se=new WeakMap;function Ce(e,t){const i=Number(e);if(Number.isInteger(i))return i;if(Math.abs(i)<1)return Number(i.toPrecision(t));return Number(i.toFixed(t))}function Oe(e){const t=je(e);let i=Math.abs(e)>1?2:t>0?t+1:2;return Ce(e,i)}function je(e){const t=e.toString();const i=t.indexOf(".");if(i===-1||i===t.length-1){return 0}let n=0;for(let e=i+1;e<t.length;e++){if(t[e]==="0"){n++}else if(t[e]>="1"&&t[e]<="9"){break}}return n}var ke,Pe,$e,Me,Le,Re,We,Be;class Ge extends be{constructor(e,t){super(e,t);this.term=e.term}static fill(e,t={}){return i(this,void 0,void 0,(function*(){if(!e.term)throw`missing tw.term, must already be filled in`;if(!Ge.termTypes.has(e.term.type))throw`non-numeric term.type='${e.term.type}'`;if(t.defaultQ){t.defaultQ.isAtomic=true;e.q.isAtomic=true;if(t.defaultQ.preferredBins=="median"){if(!t.defaultQ.type)t.defaultQ.type="custom-bin";else if(t.defaultQ.type!="custom-bin")throw".type must be custom-bin when .preferredBins=median"}o(e.q,t.defaultQ)}if(!e.q.mode)e.q.mode="discrete";if(!e.q.type){if(e.q.mode=="binary")e.q.type="custom-bin";else if(e.q.mode=="discrete")He(e)}e.type=e.q.type=="regular-bin"?"NumTWRegularBin":e.q.type=="custom-bin"||e.q.mode=="binary"?"NumTWCustomBin":e.q.mode=="continuous"?"NumTWCont":e.q.mode=="spline"?"NumTWSpline":e.type;switch(e.type){case"NumTWRegularBin":return yield Ve.fill(e);case"NumTWCustomBin":return yield De.fill(e,t);case"NumTWCont":return yield Qe.fill(e);case"NumTWSpline":return yield Ye.fill(e);default:throw`tw.type='${e.type} (q.mode:q.type=${e.q.mode}:${e.q.type}' is not supported by NumericBase.fill()`}}))}}Ge.termTypes=new Set(["integer","float","geneExpression","metaboliteIntensity"]);class Ve extends Ge{constructor(t,i={}){super(t,i);ke.set(this,void 0);Pe.set(this,void 0);this.q=t.q;e(this,ke,t,"f");e(this,Pe,i,"f")}getTw(){return t(this,ke,"f")}static fill(e){var t;return i(this,void 0,void 0,(function*(){if(!e.type)e.type="NumTWRegularBin";else if(e.type!="NumTWRegularBin")throw`expecting tw.type='NumTWRegularBin', got '${e.type}'`;if(!e.q.mode)e.q.mode="discrete";else if(e.q.mode!="discrete"&&e.q.mode!="binary"&&e.q.mode!="continuous")throw`expecting tw.q.mode='discrete'|'binary'|'continous', got '${e.q.mode}'`;if(e.q.type&&e.q.type!="regular-bin")throw`expecting tw.q.type='regular-bin', got '${e.q.type}'`;if(!e.q.first_bin||!a(e.q.bin_size))He(e);if(!a(e.q.bin_size))throw`tw.q.bin_size=${e.q.bin_size} is not numeric`;if(!e.q.first_bin)throw`missing tw.q.first_bin`;if(!a((t=e.q.first_bin)===null||t===void 0?void 0:t.stop))throw`tw.q.first_bin.stop is not numeric`;be.setHiddenValues(e.q,e.term);return e}))}}ke=new WeakMap,Pe=new WeakMap;class De extends Ge{constructor(t,i={}){super(t,i);$e.set(this,void 0);Me.set(this,void 0);this.q=t.q;e(this,$e,t,"f");e(this,Me,i,"f")}getTw(){return t(this,$e,"f")}static fill(e,t={}){return i(this,void 0,void 0,(function*(){if(!e.type)e.type="NumTWCustomBin";else if(e.type!="NumTWCustomBin")throw`expecting tw.type='NumTWCustomBin', got '${e.type}'`;if(!e.q.mode)e.q.mode="discrete";else if(e.q.mode!="discrete"&&e.q.mode!="binary"&&e.q.mode!="continuous")throw`expecting tw.q.mode='discrete'|binary|continuous', got '${e.q.mode}'`;if(e.q.mode=="binary"&&!e.q.preferredBins)e.q.preferredBins="median";if(e.q.preferredBins=="median"){const i=yield t.vocabApi.getPercentile(e.term.id,[50]);if(!i.values)throw".values[] missing from vocab.getPercentile()";const n=Oe(i.values[0]);if(!a(n))throw"median value not a number";e.q.type="custom-bin";e.q.lst=[{startunbounded:true,stop:n,stopinclusive:false,label:"<"+n},{start:n,startinclusive:true,stopunbounded:true,label:"≥"+n}];delete e.q.preferredBins}else if(e.q.type!="custom-bin")throw`expecting tw.q.type='custom-bin', got '${e.q.type}'`;if(!Array.isArray(e.q.lst))He(e);if(!e.q.lst||!e.q.lst.length)throw`missing or empty q.lst[] for custom-bin`;if(e.q.mode=="binary"&&e.q.lst.length!=2)throw`numeric q.mode='binary' requires exactly 2 bins`;be.setHiddenValues(e.q,e.term);e.type="NumTWCustomBin";return e}))}}$e=new WeakMap,Me=new WeakMap;class Qe extends Ge{constructor(t,i={}){super(t,i);Le.set(this,void 0);Re.set(this,void 0);this.q=t.q;e(this,Le,t,"f");e(this,Re,i,"f")}getTw(){return t(this,Le,"f")}static fill(e){return i(this,void 0,void 0,(function*(){if(!e.type)e.type="NumTWCont";else if(e.type!="NumTWCont")throw`expecting tw.type='NumTWCont', got '${e.type}'`;if(e.q.mode!="continuous")throw`tw.q.mode='${e.q.mode}', expecting 'continuous'`;be.setHiddenValues(e.q,e.term);e.type="NumTWCont";return e}))}}Le=new WeakMap,Re=new WeakMap;class Ye extends Ge{constructor(t,i={}){super(t,i);We.set(this,void 0);Be.set(this,void 0);this.q=t.q;e(this,We,t,"f");e(this,Be,i,"f")}static fill(e){return i(this,void 0,void 0,(function*(){if(!e.type)e.type="NumTWSpline";else if(e.type!="NumTWSpline")throw`expecting tw.type='NumTWSpline', got '${e.type}'`;if(e.q.mode!="spline")throw`tw.q.mode='${e.q.mode}', expecting 'spline'`;if(!e.q.knots)throw`missing tw.q.knots`;if(!e.q.knots.length)throw`empty tw.q.knots[]`;be.setHiddenValues(e.q,e.term);e.type="NumTWSpline";return e}))}}We=new WeakMap,Be=new WeakMap;const Ue=new Set(["default","less","median"]);function He(e){if(!e.term.bins)throw`missing tw.term.bins`;const t=e.q.preferredBins||"default";if(!Ue.has(t))throw`invalid preferredBins='${t}'`;if(t!="median"){if(!Object.keys(e.term.bins).includes(t));const i=e.term.bins[t];if(e.q.type&&e.q.type!=i.type)throw`mismatched tw.q.type and term.bins[preferredBins].type`;const n=Object.keys(e.q);for(const[t,r]of Object.entries(i)){if(!n.includes(t))e.q[t]=r}delete e.q.preferredBins}}class Xe{constructor(e){this.opts=e}static init(e,t={}){switch(e.type){case"CatTWValues":return new Ne(e,t);case"CatTWPredefinedGS":return new Ae(e,t);case"CatTWCustomGS":return new Ie(e,t);case"NumTWRegularBin":return new Ve(e,t);case"NumTWCustomBin":return new De(e,t);case"NumTWCont":return new Qe(e,t);default:throw`unable to init(tw)`}}static initRaw(e,t={}){return i(this,void 0,void 0,(function*(){const i=yield Xe.fill(e,t);return Xe.init(i,t)}))}static fill(e,t={}){var n,r;return i(this,void 0,void 0,(function*(){yield Xe.preprocess(e,t===null||t===void 0?void 0:t.vocabApi);const i=e.term.type=="float"||e.term.type=="integer"?"numeric":e.term.type;t.defaultQ=((n=t.defaultQByTsHandler)===null||n===void 0?void 0:n[i])||null;switch(e.term.type){case"categorical":{return yield _e.fill(e,t)}case"integer":case"float":return yield Ge.fill(e,t);default:throw`unrecognized tw.term?.type='${(r=e.term)===null||r===void 0?void 0:r.type}'`}}))}static preprocess(e,t){return i(this,void 0,void 0,(function*(){const i=Object.keys(e);if(!i.length)throw`empty tw object`;if(e.id&&!e.term){yield ct([e],t);delete e.id}if(!e.q)e.q={};e.q.isAtomic=true;Xe.reshapeLegacyTw(e)}))}static reshapeLegacyTw(e){if(Object.keys(e.q).includes("groupsetting")){if(!e.q.groupsetting.inuse){e.q.type="values"}else if(e.q.type=="predefined-groupset"){e.q.predefined_groupset_idx=e.q.groupsetting.predefined_groupset_idx}else if(e.q.type=="custom-groupset"){e.q.customset=e.q.groupsetting.customset}else{throw"invalid q.type"}delete e.q["groupsetting"]}}}function Fe(e){switch(e){case"./handlers/categorical.ts":return import("./categorical-25b06bc5.js");case"./handlers/condition.ts":return import("./condition-70084a85.js");case"./handlers/density.ts":return import("./density-30dbad8b.js");case"./handlers/geneExpression.ts":return import("./geneExpression-4901955e.js");case"./handlers/geneVariant.ts":return import("./geneVariant-f6bbc247.js");case"./handlers/groupsetting.ts":return import("./groupsetting-a3de9ec7.js");case"./handlers/metaboliteIntensity.ts":return import("./metaboliteIntensity-b47fb792.js");case"./handlers/numeric.binary.ts":return import("./numeric.binary-07e15211.js");case"./handlers/numeric.continuous.ts":return import("./numeric.continuous-76dd29ba.js");case"./handlers/numeric.discrete.ts":return import("./numeric.discrete-6d697c68.js");case"./handlers/numeric.spline.ts":return import("./numeric.spline-cf331bad.js");case"./handlers/numeric.toggle.ts":return import("./numeric.toggle-332c2578.js");case"./handlers/numeric.ts":return import("./numeric-5b626171.js");case"./handlers/samplelst.ts":return import("./samplelst-83e593da.js");case"./handlers/singleCellCellType.ts":return import("./singleCellCellType-e6848f45.js");case"./handlers/singleCellGeneExpression.ts":return import("./singleCellGeneExpression-d3a5394e.js");case"./handlers/snp.ts":return import("./snp-6b23e7a6.js");case"./handlers/snplocus.ts":return import("./snplocus-c60eab56.js");case"./handlers/snplst.sampleSum.ts":return import("./snplst.sampleSum-e47d05f0.js");case"./handlers/snplst.ts":return import("./snplst-6865d7c7.js");case"./handlers/survival.ts":return import("./survival-db972025.js");default:return new Promise((function(t,i){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}function ze(e){switch(e){case"./handlers/categorical.ts":return import("./categorical-25b06bc5.js");case"./handlers/condition.ts":return import("./condition-70084a85.js");case"./handlers/density.ts":return import("./density-30dbad8b.js");case"./handlers/geneExpression.ts":return import("./geneExpression-4901955e.js");case"./handlers/geneVariant.ts":return import("./geneVariant-f6bbc247.js");case"./handlers/groupsetting.ts":return import("./groupsetting-a3de9ec7.js");case"./handlers/metaboliteIntensity.ts":return import("./metaboliteIntensity-b47fb792.js");case"./handlers/numeric.binary.ts":return import("./numeric.binary-07e15211.js");case"./handlers/numeric.continuous.ts":return import("./numeric.continuous-76dd29ba.js");case"./handlers/numeric.discrete.ts":return import("./numeric.discrete-6d697c68.js");case"./handlers/numeric.spline.ts":return import("./numeric.spline-cf331bad.js");case"./handlers/numeric.toggle.ts":return import("./numeric.toggle-332c2578.js");case"./handlers/numeric.ts":return import("./numeric-5b626171.js");case"./handlers/samplelst.ts":return import("./samplelst-83e593da.js");case"./handlers/singleCellCellType.ts":return import("./singleCellCellType-e6848f45.js");case"./handlers/singleCellGeneExpression.ts":return import("./singleCellGeneExpression-d3a5394e.js");case"./handlers/snp.ts":return import("./snp-6b23e7a6.js");case"./handlers/snplocus.ts":return import("./snplocus-c60eab56.js");case"./handlers/snplst.sampleSum.ts":return import("./snplst.sampleSum-e47d05f0.js");case"./handlers/snplst.ts":return import("./snplst-6865d7c7.js");case"./handlers/survival.ts":return import("./survival-db972025.js");default:return new Promise((function(t,i){(typeof queueMicrotask==="function"?queueMicrotask:setTimeout)(i.bind(null,new Error("Unknown variable dynamic import: "+e)))}))}}const Je=`_ts_${(+new Date).toString().slice(-8)}`;let Ze=0;function Ke(e){return i(this,void 0,void 0,(function*(){if(!e)return`${Ze++}${Je}`;delete e.$id;return yield tt(JSON.stringify(e))}))}const et=new TextEncoder;function tt(e){return i(this,void 0,void 0,(function*(){const t=et.encode(e);const i=yield crypto.subtle.digest("SHA-1",t);const n=Array.from(new Uint8Array(i));const r=n.map((e=>e.toString(16).padStart(2,"0"))).join("");return it(r).replace("=","-")}))}function it(e){return btoa([...e].reduce(((t,i,n)=>t+=!(n-1&1)?String.fromCharCode(parseInt(e.substring(n-1,n+1),16)):""),""))}const nt={menuOptions:"edit",menuLayout:"vertical"};class rt{constructor(e){this.opts=this.validateOpts(e);this.vocabApi=e.vocabApi;this.activeCohort=e.activeCohort;this.placeholder=e.placeholder;this.durations={exit:0};this.disable_terms=e.disable_terms;this.usecase=e.usecase;this.abbrCutoff=e.abbrCutoff;this.numqByTermIdModeType={};this.dom={holder:e.holder,tip:e.tip||new d({padding:"0px",parent_menu:this.opts.holder&&this.opts.holder.node()&&this.opts.holder.node().closest(".sja_menu_div")})};this.dom.tip2=new d({padding:"0px",parent_menu:this.dom.tip.d.node()});at(this);ot(this);this.initUI();const t=dt(this);this.handlerByType={default:t};this.handler=t;this.hasError=false;this.api={main:this.main.bind(this),runCallback:this.runCallback.bind(this),showTree:this.showTree,showMenu:this.showMenu.bind(this),showGeneSearch:this.showGeneSearch,hasError:()=>this.hasError,validateQ:e=>{if(!this.handler||!this.handler.validateQ)return;try{this.handler.validateQ(e)}catch(e){this.hasError=true;throw e}}}}runCallback(e=null){var t,i;const n=this.term?{term:this.term,q:this.q,isAtomic:true}:{};if("$id"in this)n.$id=this.$id;if(((t=n.q)===null||t===void 0?void 0:t.reuseId)&&n.q.reuseId===((i=this.data.q)===null||i===void 0?void 0:i.reuseId)){if(!p(n.q,this.data.q)){delete n.q.reuseId;delete n.q.name}}const r=e?JSON.parse(JSON.stringify(e)):{};if(this.opts.callback)this.opts.callback(e?o(JSON.stringify(n),r):n)}validateOpts(e){const t=Object.assign({},nt,e);if(!t.holder&&t.renderAs!="none")throw".holder missing";if(typeof t.callback!="function")throw".callback() is not a function";if(!t.vocabApi)throw".vocabApi missing";if(typeof t.vocabApi!="object");if("placeholder"in t&&!t.placeholder&&"placeholderIcon"in t&&!t.placeholderIcon)throw"must specify a non-empty opts.placeholder and/or .placeholderIcon";if(!("placeholder"in t))t.placeholder="Select term&nbsp;";if(!("placeholderIcon"in t))t.placeholderIcon="+";if(!Number.isInteger(t.abbrCutoff))t.abbrCutoff=18;this.validateMenuOptions(t);if(!t.numericEditMenuVersion)t.numericEditMenuVersion=["discrete"];this.mayValidate_noTermPromptOptions(t);return t}main(e={}){return i(this,void 0,void 0,(function*(){try{if(this.doNotHideTipInMain){delete this.doNotHideTipInMain}else{this.dom.tip.hide()}this.hasError=false;delete this.error;this.validateMainData(e);this.data=e;this.term=e.term;this.q=JSON.parse(JSON.stringify(e.q));if("$id"in e)this.$id=e.$id;if("disable_terms"in e)this.disable_terms=e.disable_terms;if("filter"in e)this.filter=e.filter;if("activeCohort"in e)this.activeCohort=e.activeCohort;if("sampleCounts"in e)this.sampleCounts=e.sampleCounts;if("menuOptions"in e)this.opts.menuOptions=e.menuOptions;yield this.setHandler(this.term?this.term.type:null);if(e.term&&this.handler&&this.handler.validateQ)this.handler.validateQ(e);if(this.handler.postMain)yield this.handler.postMain();if(this.opts.renderAs!="none")this.updateUI()}catch(e){this.hasError=true;throw e}}))}validateMainData(e){if(e.term){if(!e.term.type)throw"data.term.type missing";if(x(e.term.type)){if(!e.term.id&&e.term.type!=m.SAMPLELST)throw"data.term.id missing";if(!e.term.name)throw"data.term.name missing"}}if(!e.q)e.q={};if(typeof e.q!="object")throw"data.q{} is not object";if(e.disable_terms){if(!Array.isArray(e.disable_terms))throw"data.disable_terms[] is not array"}this.mayValidate_noTermPromptOptions(e)}validateMenuOptions(e){if(!e.menuOptions)e.menuOptions=nt.menuOptions;if(e.menuOptions=="all")e.menuOptions="*";for(const t of["edit","replace","remove"]){if(X(t,e.menuOptions))return}throw`no matches found for termsetting opts.menuOptions='${e.menuOptions}'`}mayValidate_noTermPromptOptions(e){if(!e.noTermPromptOptions)return;if(!Array.isArray(e.noTermPromptOptions))throw"noTermPromptOptions[] is not array";for(const t of e.noTermPromptOptions){if(t.isDictionary);else{if(!t.termtype)throw"element of noTermPromptOptions[] missing both isDictionary=true and .termtype"}if(!t.text&&!t.html)throw"element of noTermPromptOptions[] missing both .text and .html";if(t.q&&typeof t.q!="object")throw"type.q{} is not object"}this.noTermPromptOptions=e.noTermPromptOptions}setHandler(e){return i(this,void 0,void 0,(function*(){if(!e){this.handler=this.handlerByType.default;return}const t=e=="integer"||e=="float"?"numeric":e;if(!this.handlerByType[t]){try{const e=yield ze(`./handlers/${t}.ts`);this.handlerByType[t]=yield e.getHandler(this)}catch(e){throw`error with handler='./handlers/${t}.ts': ${e}`}}this.handler=this.handlerByType[t]}))}}const st=l(rt);function ot(e){e.initUI=()=>{if(e.opts.$id){e.dom.tip.d.attr("id",e.opts.$id+"-ts-tip")}if(!e.dom.holder)return;e.dom.nopilldiv=e.dom.holder.append("div").style("cursor","pointer").on("click",e.clickNoPillDiv).on(`keyup.sjpp-termdb`,(t=>{if(t.key=="Enter")e.showTree(t)}));e.dom.pilldiv=e.dom.holder.append("div");if(e.opts.placeholder){e.dom.nopilldiv.append("div").html(e.placeholder).attr("class","sja_clbtext2").style("padding","3px 6px 3px 6px").style("display","inline-block")}if(e.opts.placeholderIcon){e.dom.nopilldiv.append("div").attr("class","sja_filter_tag_btn add_term_btn").style("padding","3px 6px 3px 6px").style("display","inline-block").style("border-radius","6px").style("background-color","#4888BF").text(e.opts.placeholderIcon)}e.dom.btnDiv=e.dom.holder.append("div");e.dom.content_holder=u(e.dom.holder.node().parentNode).append("div")};e.updateUI=()=>i(this,void 0,void 0,(function*(){e.dom.btnDiv.selectAll("*").remove();e.dom.content_holder.selectAll("*").remove();if(!e.term){e.dom.nopilldiv.style("display","block");e.dom.pilldiv.style("display","none");e.dom.btnDiv.style("display","none");return}if(e.term.hashtmldetail){if(e.opts.buttons&&!e.opts.buttons.includes("info"))e.opts.buttons.unshift("info");else e.opts.buttons=["info"]}else{e.opts.buttons=[]}if(e.opts.buttons.length){e.dom.btnDiv.selectAll("div").data(e.opts.buttons).enter().append("div").style("display","inline-block").style("padding","0px 5px").style("cursor","pointer").style("color","#999").style("font-size",".8em").html((e=>e.toUpperCase())).on("click",((t,i)=>{if(i=="delete")e.removeTerm();else if(i=="replace"){e.showTree(t.target)}else throw"unknown button"}));if(e.term.hashtmldetail){const t=e.dom.btnDiv.selectAll("div").filter((function(){return u(this).text()==="INFO"}));const i=yield import("./termInfo-5477ba96.js");i.termInfoInit({vocabApi:e.opts.vocabApi,icon_holder:t,content_holder:e.dom.content_holder,id:e.term.id,state:{term:e.term}})}}e.dom.nopilldiv.style("display","none");e.dom.pilldiv.style("display",e.opts.buttons?"inline-block":"block");e.dom.btnDiv.style("display",e.opts.buttons?"inline-block":"none");const t=e.dom.pilldiv.selectAll(".ts_pill").data([e.term],(e=>e.id));t.exit().each(e.exitPill);t.transition().duration(200).each(e.updatePill);t.enter().append("div").attr("class","ts_pill").style("display","grid").style("grid-template-columns","auto").style("grid-template-areas",'"left right"').style("cursor","pointer").style("margin","2px").on("click",e.showMenu).transition().duration(200).each(e.enterPill)}));e.enterPill=function(){return i(this,void 0,void 0,(function*(){const t=u(this);e.dom.pill_termname=t.append("div").attr("class","term_name_btn sja_filter_tag_btn").attr("tabindex",0).style("display","flex").style("grid-area","left").style("position","relative").style("align-items","center").style("padding","3px 6px 3px 6px").style("border-radius","6px").html(e.handler.getPillName).on(`keyup.sjpp-termdb`,(e=>{if(e.key=="Enter")e.target.click()}));e.updatePill.call(this)}))};e.updatePill=function(){return i(this,void 0,void 0,(function*(){const t=u(this);const i=e.handler.getPillStatus()||{};e.dom.pill_termname.style("border-radius",i.text?"6px 0 0 6px":"6px").html(e.handler.getPillName);const n=t.selectAll(".ts_summary_btn").data(i.text?[{txt:i.text}]:[],(e=>e.txt));n.exit().remove();const r=n.enter().append("div").attr("class","ts_summary_btn sja_filter_tag_btn").style("display","flex").style("grid-area","right").style("position","relative").style("align-items","center").style("padding","3px 6px 3px 6px").style("border-radius","0 6px 6px 0").style("font-style","italic").html((e=>e.txt)).style("opacity",0).transition().duration(200).style("opacity",1);if(i.bgcolor){r.transition().duration(200).style("background-color",i.bgcolor)}}))};e.exitPill=function(){u(this).style("opacity",1).transition().duration(e.durations.exit).style("opacity",0).remove()}}function at(e){e.removeTerm=()=>{e.opts.callback(null)};e.cancelGroupsetting=()=>{e.opts.callback({id:e.term.id,term:e.term,q:{mode:"discrete",type:"values",isAtomic:true}})};e.clickNoPillDiv=()=>i(this,void 0,void 0,(function*(){if(!e.noTermPromptOptions||e.noTermPromptOptions.length==0){yield e.showTree(e.dom.nopilldiv.node());return}e.dom.tip.clear().showunder(e.dom.nopilldiv.node());for(const t of e.noTermPromptOptions){const n=e.dom.tip.d.append("div").attr("class","sja_menuoption sja_sharp_border").on("click",(()=>i(this,void 0,void 0,(function*(){e.dom.tip.clear();if(t.isDictionary){yield e.showTree(e.dom.tip.d.node())}else if(t.termtype){if(t.q)e.q=structuredClone(t.q);yield e.setHandler(t.termtype);if(q(e.term)&&!e.term.bins&&e.term.type!="survival"){yield e.vocabApi.setTermBins({term:e.term,q:e.q})}e.handler.showEditMenu(e.dom.tip.d)}else{throw"termtype missing"}}))));if(t.text)n.text(t.text);else if(t.html)n.html(t.html)}}));e.showTree=function(t,n){return i(this,void 0,void 0,(function*(){e.dom.tip.clear();if(t)e.dom.tip.showunder(t instanceof Element?t:this instanceof Element?this:e.dom.holder.node());else e.dom.tip.show(n.clientX,n.clientY);if(!e.usecase)e.usecase={target:"default"};const r=yield import("./app-7f695ce7.js");r.appInit({holder:e.dom.tip.d,vocabApi:e.vocabApi,state:{activeCohort:e.activeCohort,tree:{usecase:e.usecase}},tree:{disable_terms:e.disable_terms,click_term:t=>i(this,void 0,void 0,(function*(){e.dom.tip.hide();let i;if(t.term)i=t;else{const e=t;i={term:e,q:{isAtomic:true},isAtomic:true}}if(e.opts.customFillTw)e.opts.customFillTw(i);yield yt(i,e.vocabApi,e.opts.defaultQ4fillTW);e.opts.callback(i)}))}})}))};e.showMenu=(t,n=null,r=null)=>{var s,o,a;const l=e.dom.tip;l.clear();if(e.opts.renderAs=="none"&&n)e.dom.holder=u(n);if(e.dom.holder){const i=(s=e.dom.holder)===null||s===void 0?void 0:s.node();if(i)l.showunder(i);else l.show(t.clientX,t.clientY)}const d=[];if(e.q.type=="predefined-groupset"||e.q.type=="custom-groupset"){if(e.q.mode!="binary"&&e.term.type!="geneVariant"){d.push({label:"Cancel grouping",callback:e.cancelGroupsetting})}}if(e.q&&!((o=e.term.groupsetting)===null||o===void 0?void 0:o.disabled)&&X("edit",e.opts.menuOptions)){d.push({label:"Edit",callback:t=>i(this,void 0,void 0,(function*(){if(e.term&&q(e.term)&&!e.term.bins&&e.term.type!="survival"){yield e.vocabApi.setTermBins({term:e.term,q:e.q})}e.handler.showEditMenu(t)}))})}if(X("replace",e.opts.menuOptions)){d.push({label:"Replace",callback:e.showTree})}if(X("remove",e.opts.menuOptions)){d.push({label:"Remove",callback:e.removeTerm})}if(e.opts.customMenuOptions)d.push(...e.opts.customMenuOptions);e.openMenu=r||l.d;e.openMenu.selectAll("div").data(d).enter().append("div").attr("class","sja_menuoption sja_sharp_border").attr("tabindex",((e,t)=>t+1)).style("display",e.opts.menuLayout=="horizontal"?"inline-block":"block").text((e=>e.label)).on("click",((t,i)=>{e.dom.tip.clear();i.callback(e.dom.tip.d)})).on("keyup",(e=>{if(e.key=="Enter")e.target.click()}));(a=e.openMenu.select(".sja_menuoption").node())===null||a===void 0?void 0:a.focus()};e.showReuseMenu=function(t){return i(this,void 0,void 0,(function*(){const n=t.append("div");n.style("display","block").style("padding","10px").append("span").style("color","#aaa").html("Save current setting as ");const r=e.vocabApi.getCustomTermQLst(e.term);const s=n.append("input").attr("type","text").attr("placeholder",r.nextReuseId).attr("value",e.q.reuseId||r.nextReuseId);n.append("button").style("margin-left","5px").html("Save").on("click",(()=>{const t=s.property("value").trim()||r.nextReuseId;e.q.reuseId=t;e.vocabApi.cacheTermQ(e.term,e.q);e.runCallback();e.dom.tip.hide()}));const o=t.append("div").style("margin","10px");const a={term:e.term,q:{}};yield ht(a,e.vocabApi);a.q.reuseId="Default";r.push(a.q);if(r.length>1){o.append("div").style("color","#aaa").html("Previously saved settings")}o.append("table").selectAll("tr").data(r).enter().append("tr").style("margin","2px 5px").each((function(t){const n=u(this);const r=lt(e.q,t);const s=t.name||t.reuseId;n.append("td").style("min-width","180px").style("text-align","center").html(s);const o=n.append("td").style("text-align","center");if(r){o.html(`In use <span style='color:#5a5;font-weight:600'>&check;</span>`)}else{o.append("button").style("min-width","80px").html("Use").on("click",(()=>{if(t.reuseId==="Default"){delete t.reuseId;delete t.name}e.q=t;e.dom.tip.hide();e.runCallback()}))}const a=n.append("td").style("text-align","center");if(!r&&t.reuseId!="Default"){a.append("button").style("min-width","80px").html("Delete").on("click",(()=>i(this,void 0,void 0,(function*(){yield e.vocabApi.uncacheTermQ(e.term,t);e.dom.tip.hide();e.runCallback()}))))}}));t.append("div").style("margin","20px 5px 5px 5px").style("padding","5px").style("font-size","0.8em").style("color","#aaa").html(`Saving the setting will allow it to be reused at another chart.<br/>`+`The setting will be reusable in your current or saved session.`)}))};e.showGeneSearch=function(t,n){e.dom.tip.clear();if(t)e.dom.tip.showunder(t instanceof Element?t:this instanceof Element?this:e.dom.holder.node());else e.dom.tip.show(n.clientX,n.clientY);const r=new Set;const s=e.dom.tip.d.append("div").style("padding","5px");const o=s.append("label");o.append("span").text("Search: ");const a=o.append("input").attr("type","text").on("input",(()=>i(this,void 0,void 0,(function*(){const t=a.property("value");try{const i=!t?{lst:[]}:yield e.vocabApi.findTerm(t,e.activeCohort,e.usecase,"gene");l.selectAll("*").remove();l.selectAll("div").data(i.lst.filter((e=>!r.has(e)))).enter().append("div").attr("class","ts_pill sja_filter_tag_btn sja_tree_click_term").style("display","block").style("margin","2px 3px").style("width","fit-content").text((e=>e.name)).on("click",(t=>{e.dom.tip.hide();e.runCallback({term:{name:t.name,type:"geneVariant"},q:{exclude:[]}})}))}catch(e){alert("Search error: "+e)}}))));const l=e.dom.tip.d.append("div").style("margin","5px").style("padding-left","5px").style("border-left","2px solid #ccc")}}function lt(e,t){const i=[e,t].map((e=>JSON.parse(JSON.stringify(e))));for(const e of i){delete e.binLabelFormatter;if(e.reuseId==="Default")delete e.reuseId;if(e.mode==="continuous")delete e.mode;if(e.mode==="discrete"&&e.type=="custom-bin"&&e.lst){for(const t of e.lst){delete t.range}}}return p(...i)}function dt(e){return{showEditMenu(){},getPillStatus(){},getPillName(t){return pt(e,t)}}}function pt(e,t){if(!e.opts.abbrCutoff)return t.name;return t.name.length<=e.opts.abbrCutoff+2?t.name:'<label title="'+t.name+'">'+t.name.substring(0,e.opts.abbrCutoff)+"..."+"</label>"}function ut(e,t,n){return i(this,void 0,void 0,(function*(){yield ct(e,t);const i=[];for(const r of e){i.push(ht(r,t,n))}yield Promise.all(i)}))}function ct(e,t){return i(this,void 0,void 0,(function*(){const i=[];for(const t of e){if(t.term)continue;if(t.id===undefined||t.id==="")throw".id is required";i.push(t.id)}const n=i.length?yield t.getTerms(i):{};for(const t of i){if(!n[t])throw`missing dictionary term for id=${t}`;for(const t of e){if(t.id&&t.id in n)t.term=n[t.id]}}}))}const ft=new Set(["categorical","integer","float"]);function ht(e,t,n){var r;return i(this,void 0,void 0,(function*(){e.isAtomic=true;if(!e.term&&e.id){yield ct([e],t)}if(ft.has((r=e.term)===null||r===void 0?void 0:r.type)){const i=yield Xe.fill(e,{vocabApi:t,defaultQByTsHandler:n});Object.assign(e,i);gt(e);if(!e.$id)e.$id=yield Ke(t.getTwMinCopy(e));if(e.q)e.q.isAtomic=true;return e}delete e.id;if(!e.q)e.q={};e.q.isAtomic=true;mt(e);yield yt(e,t,n);gt(e);if(!e.$id)e.$id=yield Ke(t.getTwMinCopy(e));return e}))}function mt(e){if(Object.keys(e.q).includes("groupsetting")){if(e.q["groupsetting"]["inuse"]){if(e.q.type=="predefined-groupset"){e.q["predefined_groupset_idx"]=e.q["groupsetting"]["predefined_groupset_idx"]}else if(e.q.type=="custom-groupset"){e.q["customset"]=e.q["groupsetting"]["customset"]}else{throw"invalid q.type"}}else{e.q.type="values"}delete e.q["groupsetting"]}}function yt(e,t,n){return i(this,void 0,void 0,(function*(){if(!e.$id)e.$id=yield Ke(t.getTwMinCopy(e));const i=e.term.type;const r=i=="float"||i=="integer"?"numeric":i;let s;if(e.term.type){try{s=yield Fe(`./handlers/${r}.ts`)}catch(e){throw`Type ${r} does not exist`}}else throw`Type not defined for ${JSON.stringify(e)}`;yield s.fillTW(e,t,n?n[r]:null)}))}function gt(e){if(!("mode"in e.q)){return}if(typeof e.q.mode!="string")throw"q.mode not string"}function vt(e,t){if(!e.hiddenValues){e.hiddenValues={};if(t.values){for(const i in t.values){if(t.values[i].uncomputable)e.hiddenValues[i]=1}}}}export{h as N,f as R,m as T,T as a,x as b,Oe as c,E as d,S as e,ht as f,Ke as g,st as h,q as i,je as j,y as k,Xe as l,ut as m,b as n,pt as o,Ce as r,vt as s,g as t};
@@ -0,0 +1 @@
1
+ import{M as t,B as e,ap as s,aq as a,ar as n,z as i,an as r,as as o,at as l,bL as c,I as d,V as f,u as m,b as p,ak as u,D as h,n as g,r as w,aN as b,d as k,be as x,aG as y,W as v,aQ as _,aR as j,aP as A,bE as M,bD as S}from"./app-0de0ae35.js";import{l as C}from"./block.legend-97401467.js";import{s as q,m as z}from"./regression.results-91a486f0.js";import{a as $}from"./axisstyle-fac7f76b.js";import{c as L,b as N}from"./axis-747c801e.js";import{r as R}from"./table-e2a307e6.js";import{d as O}from"./arc-3d6751aa.js";import{m as I}from"./block-3db9c74c.js";import{a as T,t as D}from"./shapes-21ebfec4.js";import{T as F}from"./toggleButtons-7ce58d97.js";import{m as B}from"./radiobutton-09bff425.js";import{v as U}from"./vcf-3e370c9b.js";import{n as P}from"./niceNumLabels-1bd7a93b.js";import{f as G}from"./termsetting-2e75e729.js";import{r as V}from"./rehydrateFilter-12d118cb.js";const E="white",H="black";const W="Unannotated";function K(e,s){if(!e.legend)e.legend={};e.legend.tip=new t({padding:"0px"});const[a,n,i]=C(s,e.name);e.legend.headTd=i;e.tr_legend=a;const r=n.append("table").style("border-spacing","5px").style("border-collapse","separate");e.legend.table=r;Q(e,s);X(e);J(e);Y(e);it(e);ct(e);ft(e)}function Q(t,e){if(!t.legend.mclass)t.legend.mclass={};if(!t.legend.mclass.hiddenvalues)t.legend.mclass.hiddenvalues=new Set;t.legend.mclass.row=t.legend.table.append("tr");t.legend.mclass.row.append("td").style("text-align","right").style("opacity",.7).text(e.mclassOverride?e.mclassOverride.className||"Mutation":"Mutation");t.legend.mclass.holder=t.legend.mclass.row.append("td")}function X(t){if(!t.variantShapeName)return;const e=t.legend.table.append("tr").append("td").attr("colspan",2);const s=t.legend.variantShapeName={};{const a=e.append("div");a.append("span").html(`<svg style="display:inline-block" width=12 height=12>\n\t\t\t<circle cx=6 cy=6 r=6 fill=gray></circle></svg> n=`);s.dotCount=a.append("span");if(t.variantShapeName.dot)a.append("span").text(", "+t.variantShapeName.dot);s.dotDiv=a}{const a=e.append("div");a.append("span").html(`<svg style="display:inline-block" width=12 height=12>\n\t\t\t<path d="M 6 0 L 0 12 h 12 Z" fill=gray></path></svg> n=`);s.triangleCount=a.append("span");if(t.variantShapeName.triangle)a.append("span").text(", "+t.variantShapeName.triangle);s.triangleDiv=a}{const a=e.append("div");a.append("span").html(`<svg style="display:inline-block" width=13 height=13>\n\t\t\t<circle cx=6.5 cy=6.5 r=6 stroke=gray fill=none></circle></svg> n=`);s.circleCount=a.append("span");if(t.variantShapeName.circle)a.append("span").text(", "+t.variantShapeName.circle);s.circleDiv=a}}function J(t){if(!t.mds.bcf?.info)return;const e=[];for(const s in t.mds.bcf.info){const a=t.mds.bcf.info[s];if(a.categories){e.push(s)}}if(!e.length)return;if(!t.legend.bcfInfo)t.legend.bcfInfo={};for(const s of e){const e=t.legend.table.append("tr");e.append("td").style("text-align","right").style("opacity",.7).text(t.mds.bcf.info[s].name||s);t.legend.bcfInfo[s]={hiddenvalues:new Set,row:e,holder:e.append("td")}}}function Y(t){if(!t.mds.bcf?.format)return;const e=[];for(const s in t.mds.bcf.format){if(t.mds.bcf.format[s].isFilter)e.push(s)}if(!e.length)return;if(!t.legend.formatFilter)t.legend.formatFilter={};for(const s of e){const e=t.legend.table.append("tr");e.append("td").style("text-align","right").style("opacity",.7).text(t.mds.bcf.format[s].Description);t.legend.formatFilter[s]={hiddenvalues:new Set,row:e,holder:e.append("td")}}}function Z(t,e){if(!e.legend.formatFilter)return;if(!t.skewer){console.log("data.skewer[] is not present and cannot show INFO legend");return}for(const s in e.legend.formatFilter){e.legend.formatFilter[s].holder.selectAll("*").remove();const a=new Map;let n=0;for(const e of t.skewer){if(!e.formatK2count?.[s])continue;for(const t in e.formatK2count[s].v2c){a.set(t,e.formatK2count[s].v2c[t]+(a.get(t)||0))}n+=e.formatK2count[s].unannotatedCount||0}const i=[...a];i.sort(((t,e)=>e[1]-t[1]));if(n){i.push([W,n])}for(const[t,a]of i){const n=e.legend.formatFilter[s].holder.append("div").attr("class","sja_clb").style("display","inline-block").on("click",(()=>{e.legend.tip.clear().showunder(n.node()).d.append("div").attr("class","sja_menuoption").text("Hide").on("click",(()=>{e.legend.formatFilter[s].hiddenvalues.add(t);tt(e)}));e.legend.tip.d.append("div").attr("class","sja_menuoption").text("Show only").on("click",(()=>{for(const t of i){e.legend.formatFilter[s].hiddenvalues.add(t[0])}e.legend.formatFilter[s].hiddenvalues.delete(t);tt(e)}));if(e.legend.formatFilter[s].hiddenvalues.size){e.legend.tip.d.append("div").attr("class","sja_menuoption").text("Show all").on("click",(()=>{e.legend.formatFilter[s].hiddenvalues.clear();tt(e)}))}}));n.append("div").style("display","inline-block").attr("class","sja_mcdot").style("background","#aaa").style("margin-right","5px").html(a>1?a:"&nbsp;");n.append("div").style("display","inline-block").text(t)}for(const t of e.legend.formatFilter[s].hiddenvalues){let a=false;e.legend.formatFilter[s].holder.append("div").style("display","inline-block").attr("class","sja_clb").style("text-decoration","line-through").style("opacity",.7).text(t).on("click",(async()=>{if(a)return;a=true;e.legend.formatFilter[s].hiddenvalues.delete(t);tt(e)}))}}}function tt(t){t.legend.tip.hide();t.load()}function et(t,e,s){if(!e.legend){return}e.legend.mclass.currentData=t.mclass2variantcount;nt(e);st(t,e);at(t,e);Z(t,e);ot(t,e);dt(e);mt(e)}function st(t,e){if(!e.variantShapeName)return;let s=0,a=0,n=0;for(const e of t.skewer){if(e.shapeTriangle)a++;else if(e.shapeCircle)n++;else s++}const i=e.legend.variantShapeName;i.dotDiv.style("display",s?"block":"none");i.triangleDiv.style("display",a?"block":"none");i.circleDiv.style("display",n?"block":"none");i.dotCount.text(s);i.triangleCount.text(a);i.circleCount.text(n)}function at(t,e){if(!e.legend.bcfInfo)return;if(!t.skewer){console.log("data.skewer[] is not present and cannot show INFO legend");return}for(const s in e.legend.bcfInfo){e.legend.bcfInfo[s].holder.selectAll("*").remove();if(e.mds.bcf.info[s].Type=="String"){const a=new Map;for(const e of t.skewer){const t=s in e.info?e.info[s]:W;if(Array.isArray(t)){for(const e of t){a.set(e,1+(a.get(e)||0))}}else{a.set(t,1+(a.get(t)||0))}}const n=[...a].sort(((t,e)=>e[1]-t[1]));for(const[t,a]of n){const i=e.legend.bcfInfo[s].holder.append("div").attr("class","sja_clb").style("display","inline-block").on("click",(()=>{e.legend.tip.clear().showunder(i.node()).d.append("div").attr("class","sja_menuoption").text("Hide").on("click",(()=>{e.legend.bcfInfo[s].hiddenvalues.add(t);tt(e)}));e.legend.tip.d.append("div").attr("class","sja_menuoption").text("Show only").on("click",(()=>{for(const t of n){e.legend.bcfInfo[s].hiddenvalues.add(t[0])}e.legend.bcfInfo[s].hiddenvalues.delete(t);tt(e)}));if(e.legend.bcfInfo[s].hiddenvalues.size){e.legend.tip.d.append("div").attr("class","sja_menuoption").text("Show all").on("click",(()=>{e.legend.bcfInfo[s].hiddenvalues.clear();tt(e)}))}const a=e.mds.bcf.info[s].categories?.[t]?.desc;if(a){e.legend.tip.d.append("div").style("padding","10px").style("font-size",".8em").style("width","150px").html(a)}}));i.append("div").style("display","inline-block").attr("class","sja_mcdot").style("background",e.mds.bcf.info[s].categories?.[t]?.color||E).html(a>1?a:"&nbsp;");i.append("div").style("display","inline-block").style("color",e.mds.bcf.info[s].categories?.[t]?.color||H).style("padding-left","5px").text(e.mds.bcf.info[s].categories?.[t]?.label||t)}for(const t of e.legend.bcfInfo[s].hiddenvalues){let a=false;e.legend.bcfInfo[s].holder.append("div").style("display","inline-block").attr("class","sja_clb").style("text-decoration","line-through").text(t).on("click",(async()=>{if(a)return;a=true;e.legend.bcfInfo[s].hiddenvalues.delete(t);tt(e)}))}}}}function nt(t){if(!t.legend.mclass.currentData||t.legend.mclass.currentData.length==0)return;t.legend.mclass.holder.selectAll("*").remove();const c=[],d=[];for(const[e,s]of t.legend.mclass.currentData){const a={k:e,count:s};if(t.legend.mclass.hiddenvalues.has(e)){d.push(a)}else{c.push(a)}}c.sort(((t,e)=>e.count-t.count));d.sort(((t,e)=>e.count-t.count));for(const e of t.legend.mclass.hiddenvalues){if(!d.find((t=>t.k==e))){d.push({k:e})}}for(const f of c){let m,p,u="#858585";if(Number.isInteger(f.k)){m=e[f.k];if(f.k==s){p="Copy number variation."}else if(f.k==a){p="Loss of heterozygosity."}else if(f.k==n){u=i[r].color;p="Internal tandem duplication."}else if(f.k==o){p="Structural variation of DNA."}else if(f.k==l){p="Fusion gene from RNA-seq."}}else{m=i[f.k].label;u=i[f.k].color;p=i[f.k].desc}const h=t.legend.mclass.holder.append("div").attr("class","sja_clb").style("display","inline-block").on("click",(e=>{t.legend.tip.clear().showunder(e.target).d.append("div").attr("class","sja_menuoption").text("Hide").on("click",(()=>{t.legend.mclass.hiddenvalues.add(f.k);tt(t)}));t.legend.tip.d.append("div").attr("class","sja_menuoption").text("Show only").on("click",(()=>{for(const e of c){t.legend.mclass.hiddenvalues.add(e.k)}t.legend.mclass.hiddenvalues.delete(f.k);tt(t)}));if(d.length){t.legend.tip.d.append("div").attr("class","sja_menuoption").text("Show all").on("click",(()=>{t.legend.mclass.hiddenvalues.clear();tt(t)}))}t.legend.tip.d.append("div").style("padding","10px").style("font-size",".8em").style("width","150px").html(p)}));h.append("div").style("display","inline-block").attr("class","sja_mcdot").style("background",u).html(f.count>1?f.count:"&nbsp;");h.append("div").style("display","inline-block").style("color",u).html("&nbsp;"+m)}for(const s of d){let a=false;t.legend.mclass.holder.append("div").style("display","inline-block").attr("class","sja_clb").style("text-decoration","line-through").style("opacity",.7).text((s.count?"("+s.count+") ":"")+(Number.isInteger(s.k)?e[s.k]:i[s.k].label)).on("click",(async e=>{if(a)return;a=true;t.legend.mclass.hiddenvalues.delete(s.k);e.target.innerHTML="Updating...";await t.load()}))}}function it(t,e){if(!t.mds.queries?.snvindel?.skewerRim)return;const s=t.legend.skewerRim={};if(!t.mds.queries.snvindel.skewerRim.hiddenvaluelst)t.mds.queries.snvindel.skewerRim.hiddenvaluelst=[];s.row=t.legend.table.append("tr");s.headerTd=s.row.append("td").style("text-align","right").style("opacity",.7);s.holder=s.row.append("td")}function rt(t){const e=t.mds.queries.snvindel.skewerRim;if(e.type=="format"){if(!e.formatKey)throw"skewerRim.formatKey missing";return t.mds.bcf?.format?.[e.formatKey]?.Description||e.formatKey}return"unknown skewerRim.type"}function ot(t,e){const s=e.mds.queries?.snvindel?.skewerRim;if(!s)return;let a=0,n=0;for(const e of t.skewer){const t=e.rim1count||0;a+=t;n+=e.occurrence-t}const i=e.legend.skewerRim;i.headerTd.text(rt(e));i.holder.selectAll("*").remove();if(a>0){i.holder.append("div").attr("class","sja_clb").style("display","inline-block").html(`${lt(1)}${s.rim1value}, n=${a}`).on("click",(t=>{e.legend.tip.clear().showunder(t.target).d.append("div").attr("class","sja_menuoption").text("Hide").on("click",(()=>{s.hiddenvaluelst.push(s.rim1value);tt(e)}))}))}if(n>0){i.holder.append("div").attr("class","sja_clb").style("display","inline-block").html(`${lt()}${s.noRimValue}, n=${n}`).on("click",(t=>{e.legend.tip.clear().showunder(t.target).d.append("div").attr("class","sja_menuoption").text("Hide").on("click",(()=>{s.hiddenvaluelst.push(s.noRimValue);tt(e)}))}))}for(const t of s.hiddenvaluelst){let a=false;i.holder.append("div").style("display","inline-block").attr("class","sja_clb").style("text-decoration","line-through").style("opacity",.7).text(t).on("click",(async n=>{if(a)return;a=true;s.hiddenvaluelst.splice(s.hiddenvaluelst.indexOf(t),1);n.target.innerHTML="Updating...";await e.load()}))}}function lt(t){return'<svg width="19" height="19" style="margin-right: 5px;">'+'<circle cx="7" cy="12" r="7" fill="#b1b1b1"></circle>'+(t==1?'<path d="M6.735557395310443e-16,-11A11,11 0 0,1 11,0L9,0A9,9 0 0,0 5.51091059616309e-16,-9Z" transform="translate(7,12)" fill="#858585" stroke="none"></path>':t==2?"":"")+"</svg>"}function ct(t,e){if(!t.mds.queries?.ld)return;t.mds.queries.ld.colorScale=c(t.mds.queries.ld.overlay.color_0,t.mds.queries.ld.overlay.color_1);const s=t.legend.ld={};s.row=t.legend.table.append("tr");s.headerTd=s.row.append("td").style("text-align","right").style("opacity",.7);s.holder=s.row.append("td");s.showHolder=s.holder.append("div").style("display","none");q(s.showHolder,t.mds.queries.ld.colorScale);s.showHolder.append("span").text("Cancel overlay").style("font-size",".7em").attr("class","sja_clbtext").on("click",(()=>{delete t.mds.queries.ld.mOverlay;if(t.skewer?.hlssmid)delete t.skewer.hlssmid;t.load()}))}function dt(t){if(!t.mds.queries?.ld?.mOverlay){if(t.legend.ld){t.legend.ld.headerTd.html("");t.legend.ld.showHolder.style("display","none")}return}t.legend.ld.headerTd.html(t.mds.queries.ld.mOverlay.ldtkname+" LD r<sup>2</sup>");t.legend.ld.showHolder.style("display","block")}function ft(t,e){if(!t.cnv)return;const s=t.legend.cnv={};s.row=t.legend.table.append("tr");s.headerTd=s.row.append("td").style("text-align","right").style("opacity",.7).text("CNV");s.holder=s.row.append("td");s.showHolder=s.holder.append("div").style("display","none")}function mt(t){if(!t.cnv)return;t.legend.cnv.holder.selectAll("*").remove();const e=t.legend.cnv.holder.append("svg");const s=20;const a=15;const n=10;const i=150;$({axis:e.append("g").attr("transform","translate("+n+","+s+")").call(L().scale(d().domain([-t.cnv.absoluteMax,t.cnv.absoluteMax]).range([0,i])).ticks(4)),fontsize:12});const r="grad"+Math.random();const o=e.append("defs").append("linearGradient").attr("id",r);o.append("stop").attr("offset","0%").attr("stop-color",t.cnv.lossColor);o.append("stop").attr("offset","50%").attr("stop-color","white");o.append("stop").attr("offset","100%").attr("stop-color",t.cnv.gainColor);e.append("rect").attr("x",n).attr("y",s).attr("width",i).attr("height",a).attr("fill",`url(#${r})`);e.attr("width",n*2+i).attr("height",s+a)}function pt(t){if(t.lst.length==0){return"No filter"}if(t.lst.length==1&&t.lst[0].type=="tvs"){const e=t.lst[0].tvs;if(!e)throw"f.lst[0].tvs{} missing";const s=e?.term?.type;if(s=="categorical"){if(!Array.isArray(e.values))throw"f.lst[0].tvs.values not array";const t=e.values[0]?.key;if(t==undefined)throw"f.lst[0].tvs.values[0].key missing";const s=e.term.values?.[t]?.label||t;if(e.values.length==1){if((e.term.name+s).length<20){return e.term.name+(e.isnot?"!=":": ")+s}return(e.isnot?"!":"")+(s.length<15?s:s.substring(0,13)+"...")}return`${e.isnot?"!":""}${s.length<12?s:s.substring(0,10)+"..."} (${e.values.length})`}if(s=="integer"||s=="float"||s=="geneExpression"||s=="metaboliteIntensity"){return ut(e)}throw"unknown tvs term type"}return"Filter ("+t.lst.length+")"}function ut(t){if(!Array.isArray(t.ranges))throw"tvs.ranges not array";if(!t.ranges[0])throw"tvs.ranges[] blank array";const e=t.ranges[0];let s,a;const n=t.term.valueConversion;if(n){if("start"in e)s=f(e.start,n.fromUnit,n.toUnit,n.scaleFactor,true);if("stop"in e)a=f(e.stop,n.fromUnit,n.toUnit,n.scaleFactor,true)}else{if(t.term.type=="integer"){if("start"in e)s=Math.round(e.start);if("stop"in e)a=Math.round(e.stop)}else{if("start"in e)s=e.start;if("stop"in e)a=e.stop;if("start"in e&&"stop"in e){[s,a]=P([s,a])}}}let i;if(t.isnot){if(e.startunbounded)i=`x ${e.stopinclusive?">":">="} ${a}`;else if(e.stopunbounded)i=`x ${e.startinclusive?"<":"<="} ${s}`;else i=`!(${s} ${a})`}else{if(e.startunbounded)i=`x ${e.stopinclusive?"<=":"<"} ${a}`;else if(e.stopunbounded)i=`x ${e.startinclusive?">=":">"} ${s}`;else i=`${s}${e.startinclusive?"<=":"<"}x${e.stopinclusive?"<=":"<"}${a}`}if(t.ranges.length>1)i+="...";return i}async function ht(e,s){e.subtk2height={};e.leftlabels={g:e.gleft.append("g"),doms:{},laby:0,xoff:0,maxwidth:0};e._finish=gt(e,s);e.cache={};e.itemtip=new t;e.menutip=new t({padding:""});e.load=zt(e,s);e.mnamegetter=t=>{if(e.mds.queries?.snvindel?.vcfid4skewerName&&t.vcf_id)return t.vcf_id;const s=t.mname;if(!s)return"";if(s.length>25){return s.substr(0,20)+"..."}return s};await vt(e,s);await jt(e,s);await St(e,s);At(e,s);Mt(e,s);bt(e);kt(e);if(e.filterObj)await Promise.all(V(e.filterObj,e.mds.termdb.vocabApi));e.tklabel.text(e.mds.label||e.name);e.clear=()=>{if(e.skewer)e.skewer.g.selectAll("*").remove()};K(e,s);yt(e);e.color4disc=t=>{if(e.mutationColorBy){if(e.mutationColorBy=="hardcode"){if(t.color)return t.color}}if(e.mds.queries?.ld?.mOverlay?.data){const s=e.mds.queries.ld.mOverlay.m;if(t.chr==s.chr&&t.pos==s.pos&&t.ref==s.ref&&t.alt==s.alt){return e.mds.queries.ld.overlay.color_1}for(const s of e.mds.queries.ld.mOverlay.data){if(s.pos==t.pos&&s.alleles==t.ref+"."+t.alt){return e.mds.queries.ld.colorScale(s.r2)}}return e.mds.queries.ld.overlay.color_0}if(e.vcfinfofilter&&e.vcfinfofilter.setidx4mclass!=undefined){const s=e.vcfinfofilter.lst[e.vcfinfofilter.setidx4mclass];const[a,n]=$t(s,t);if(a||n==undefined)return"black";for(const t of n){if(s.categories[t]){return s.categories[t].color}else{return"black"}}}if(i[t.class]){return i[t.class].color}return"black"};wt(e);if(e.hlssmid){e.skewer.hlssmid=new Set(e.hlssmid.split(","));delete e.hlssmid}try{Tt(e)}catch(t){console.error(t)}}function gt(t,e){return s=>{t.legend?.headTd.text(t.name+(t.filterObj?" - "+pt(t.filterObj):""));if(t.cnv){t.cnv.g.transition().attr("transform",`translate(0,${t.subtk2height.skewer||0})`)}if(s){if(s.error){t.subtk2height.skewer=40}else{let a=0;if(s.skewer)a=s.skewer.length;if(s.cnv)a+=s.cnv.length;if(a==0){let s="view range";if(e.usegm&&e.gmmode!="genomic")s=e.usegm.name||e.usegm.isoform;t.skewer.g.append("text").text("No mutation in "+s).attr("y",25).attr("x",e.width/2).attr("text-anchor","middle").attr("dominant-baseline","center");t.subtk2height.skewer=40}}}t.height_main=Math.max(t.subtk2height.leftlabels||0,t.subtk2height.skewer+(t.subtk2height.cnv||0))+t.toppad+t.bottompad;if(s){et(s,t)}t.leftLabelMaxwidth=Math.max(t.leftlabels.maxwidth+t.leftlabels.xoff,Number.isFinite(t.skewer?.maxwidth)?t.skewer.maxwidth:0);e.tkcloakoff(t,{error:s?s.error:null});e.block_setheight();e.setllabel();if(typeof t.callbackOnRender=="function"){t.callbackOnRender(t,e)}}}function wt(t){const e=m();if(t.skewer){if(e.has("hlaachange")){t.hlaachange=e.get("hlaachange")}if(e.has("hlssmid")){t.hlssmid=e.get("hlssmid").split(",")}}}function bt(t){if(!t.mds.has_skewer)return;t.skewer={g:t.glider.append("g"),hlBoxColor:t.mds.hlBoxColor||"red",hideDotLabels:false,pointup:true};xt(t)}function kt(t){let e=t.mds.termdbConfig?.queries?.cnv;if(!e){if(t.mds.has_cnv){e={}}}if(!e)return;t.cnv={g:t.glider.append("g"),cnvMaxLength:e.cnvMaxLength,cnvGainCutoff:e.cnvGainCutoff,cnvLossCutoff:e.cnvLossCutoff,absoluteValueRenderMax:e.absoluteValueRenderMax||5,gainColor:e.gainColor||"#D6683C",lossColor:e.lossColor||"#67a9cf"}}function xt(t){t.skewer.viewModes=t.skewerModes;delete t.skewerModes;if(!t.skewer.viewModes)t.skewer.viewModes=[];const e=t.skewer.viewModes;if(!Array.isArray(e))throw"skewerModes[] is not array";if(t.mds.skewerModes){for(const s of t.mds.skewerModes)e.push(s)}if(!e.find((t=>t.type=="skewer")))e.push({type:"skewer"});for(const t of e){if(typeof t!="object")throw"one of skewerModes[] is not object";if(t.type=="skewer"){if(!t.label)t.label="lollipops"}else if(t.type=="numeric"){if(t.byAttribute){if(!t.label)t.label=t.byAttribute}else if(t.byInfo);else{throw"unknown data method for a type=numeric mode"}}else{throw"unknown type from a skewerModes[]"}}if(!e.find((t=>t.inuse)))e[0].inuse=true}function yt(t){if(t.mds.hiddenmclass){for(const e of t.mds.hiddenmclass)t.legend.mclass.hiddenvalues.add(e)}}async function vt(t,e){if(t.dslabel){const s=await p("getDataset",{body:{genome:e.genome.name,dsname:t.dslabel}});if(s.error)throw"Error: "+s.error;if(!s.ds)throw"data.ds{} missing";t.mds=s.ds;t.name=s.ds.label;return}if(!t.name)t.name="Custom data";t.mds={};if(t.bcf){if(!t.bcf.file&&!t.bcf.url)throw"file or url missing for tk.bcf{}";t.mds.has_skewer=true;await It(t,e.genome)}else if(t.custom_variants){Lt(t,e);Ot(t)}else{throw"unknown data source for custom track"}_t(t)}function _t(t){if(!t.sampleAnnotation)return;if(!Array.isArray(t.sampleAnnotation.terms))throw"sampleAnnotation.terms is not array";if(!t.mds.termdb)t.mds.termdb={};t.mds.termdb.terms=t.sampleAnnotation.terms;t.mds.termdb.annotations=t.sampleAnnotation.annotations}async function jt(t,e){const s=t.mds.termdb;if(!s)return;{const a={};if(t.mds.label){a.vocab={genome:e.genome.name,dslabel:t.mds.label}}else if(s.terms){a.vocab={terms:s.terms,sampleannotation:s.annotations}}else{throw"do not know how to init vocab"}const n=await import("./FilterRxComp-fb608459.js").then((function(t){return t.k}));s.vocabApi=n.vocabInit(a);if(!s.vocabApi.app){s.vocabApi.app={opts:{genome:e.genome}}}}t.mds.termdbConfig=await s.vocabApi.getTermdbConfig();if(t.mds.termdb.allowCaseDetails){t.mds.termdb.allowCaseDetails.get=async t=>{}}}function At(t,e){if(!t.mds.queries?.snvindel?.m2csq)return;t.mds.queries.snvindel.m2csq.get=async s=>{const a={genome:e.genome.name,dslabel:t.mds.label,m2csq:1};if(t.mds.queries.snvindel.m2csq.by=="ssm_id"){a.ssm_id=s.ssm_id}else{return{error:"unknown query method"}}const n={"Content-Type":"application/json",Accept:"application/json"};if(t.token)n["X-Auth-Token"]=t.token;return await p("mds3",{body:a,headers:n},{serverData:t.cache})}}function Mt(t,e){if(!t.mds.queries?.singleSampleMutation)return;t.mds.queries.singleSampleMutation.get=async s=>{const a={genome:e.genome.name,dslabel:t.mds.label,sample:s};const n={"Content-Type":"application/json",Accept:"application/json"};if(t.token)n["X-Auth-Token"]=t.token;const i=await p("termdb/singleSampleMutation",{body:a,headers:n});if(i.error)throw i.error;if(!Array.isArray(i.mlst))throw"data.mlst is not array";return i.mlst}}async function St(t,e){if(!t.mds.variant2samples)return;if(t.custom_variants){Ct(t)}else{qt(t,e)}if(t.mds.variant2samples.twLst){if(!Array.isArray(t.mds.variant2samples.twLst))throw"v2s.twLst[] not array";if(!t.mds.termdb?.vocabApi)throw"mds.termdb.vocabApi should be present for initiating v2s.twLst";for(const e of t.mds.variant2samples.twLst)await G(e,t.mds.termdb.vocabApi)}}function Ct(t,e){t.mds.variant2samples.get=e=>{if(e.querytype==t.mds.variant2samples.type_samples){const t=[];for(const s of e.mlst){if(!s.samples)continue;for(const e of s.samples){const a=JSON.parse(JSON.stringify(e));a.ssm_id=s.ssm_id;t.push(a)}}return{samples:t}}if(e.querytype==t.mds.variant2samples.type_summary){throw"todo: summary"}if(e.querytype==t.mds.variant2samples.type_sunburst){throw"todo: sunburst"}throw"unknown querytype"};t.mds.getSamples=()=>{const e=new Map;for(const s of t.custom_variants){if(!s.samples)continue;for(const t of s.samples){if(e.has(t.sample_id)){e.get(t.sample_id).ssm_id_lst.push(s.ssm_id)}else{const a=JSON.parse(JSON.stringify(t));a.ssm_id_lst=[s.ssm_id];e.set(t.sample_id,a)}}}return{samples:[...e.values()]}}}function qt(t,e){t.mds.variant2samples.get=async s=>{const a={genome:e.genome.name,variant2samples:1,get:s.querytype};if(t.mds.label){a.dslabel=t.mds.label}else if(t.bcf){if(t.bcf.file)a.bcffile=t.bcf.file;else if(t.bcf.url)a.bcfurl=t.bcf.url;else throw"tk.bcf{}: file/url missing"}else{throw"no dslabel or tk.bcf"}if(s.groupSsmBySample){a.groupSsmBySample=1}if(s.mlst){if(t.mds.variant2samples.variantkey=="ssm_id"){a.ssm_id_lst=s.mlst.map((t=>t.ssm_id)).join(",")}else{throw"unknown variantkey for variant2samples"}}if(s.isoform){a.isoform=s.isoform}if(s.rglst){a.rglst=s.rglst}const n={"Content-Type":"application/json",Accept:"application/json"};if(t.set_id)a.set_id=t.set_id;if(t.token)n["X-Auth-Token"]=t.token;if(t.filter0)a.filter0=t.filter0;if(t.filterObj)a.filterObj=t.filterObj;if(s.tid2value)a.tid2value=s.tid2value;if(s.querytype==t.mds.variant2samples.type_sunburst){if(t.mds.variant2samples.sunburst_twLst){a.twLst=t.mds.variant2samples.sunburst_twLst}}else if(s.querytype==t.mds.variant2samples.type_samples){if(t.mds.variant2samples.twLst)a.twLst=t.mds.variant2samples.twLst}else if(s.querytype==t.mds.variant2samples.type_summary){if(t.mds.variant2samples.twLst)a.twLst=t.mds.variant2samples.twLst}else{throw"unknown querytype"}a.skewerRim=t.mds.queries.snvindel?.skewerRim;if(t.legend.formatFilter){const e={};for(const s in t.legend.formatFilter){if(t.legend.formatFilter[s].hiddenvalues.size){e[s]=[...t.legend.formatFilter[s].hiddenvalues]}}if(Object.keys(e).length){a.formatFilter=e}}if(t.legend.mclass?.hiddenvalues?.size){a.hiddenmclasslst=[...t.legend.mclass.hiddenvalues].join(",")}const i=await p("mds3",{body:a,headers:n},{serverData:t.cache});if(i.error)throw i.error;const r=i.variant2samples;if(!r)throw"result error";if(s.querytype==t.mds.variant2samples.type_sunburst){if(!Array.isArray(r.nodes))throw"nodes[] not array from return"}else if(s.querytype==t.mds.variant2samples.type_samples){if(!Array.isArray(r.samples))throw"samples[] not array from return"}else if(s.querytype==t.mds.variant2samples.type_summary){if(!Array.isArray(r.summary))throw"summary[] not array from return"}else{throw"unknown querytype"}return r};t.mds.getSamples=async(s={})=>{if(s.isSummary){s.querytype=t.mds.variant2samples.type_summary}else{s.querytype=t.mds.variant2samples.type_samples;s.groupSsmBySample=1}Rs(t,e,s);return await t.mds.variant2samples.get(s)}}function zt(t,e){return async()=>await $s(t,e)}function $t(t,e){if(t.altalleleinfo){if(!e.altinfo)return["no .altinfo"];const s=e.altinfo[t.altalleleinfo.key];if(s==undefined){if(t.numericfilter){return[null,[0]]}return[null,undefined]}let a=Array.isArray(s)?s:[s];if(t.altalleleinfo.separator){a=a[0].split(t.altalleleinfo.separator)}return[null,a]}if(t.locusinfo){if(!e.info)return["no .info"];const s=e.info[t.locusinfo.key];if(s==undefined){if(t.numericfilter){return[null,[0]]}return[null,undefined]}let a=Array.isArray(s)?s:[s];if(t.locusinfo.separator){a=a[0].split(t.locusinfo.separator)}return[null,a]}return["no trigger"]}function Lt(t,e){for(const a of t.custom_variants){if(a.dt==u){t.mds.has_skewer=true;Nt(a);continue}if(a.dt==l||a.dt==o){t.mds.has_skewer=true;Rt(a,e);continue}if(a.dt==s){t.mds.has_cnv=true;a.ssm_id=a.chr+"."+a.start+"."+a.stop+"."+a.class;continue}throw"unknown dt for a custom variant"}}function Nt(t){if(!t.chr)throw".chr missing for custom snvindel";if(!Number.isInteger(t.pos))throw".pos not integer for custom snvindel";if(!t.ssm_id){t.ssm_id=t.chr+"."+t.pos+"."+(t.ref&&t.alt?t.ref+"."+t.alt:t.mname)}}function Rt(t,e){if(t.pairlst);else{if(!t.chr1)throw".chr1 missing for custom sv/fusion";if(!Number.isInteger(t.pos1))throw".pos1 not integer for custom svfusion";if(t.strand1!="+"&&t.strand1!="-")throw".strand1 not +/- for custom svfusion";if(!t.chr2)throw".chr1 missing for custom sv/fusion";if(!Number.isInteger(t.pos2))throw".pos1 not integer for custom svfusion";if(t.strand2!="+"&&t.strand2!="-")throw".strand1 not +/- for custom svfusion";t.pairlst=[{a:{chr:t.chr1,pos:t.pos1,strand:t.strand1,name:t.gene1||""},b:{chr:t.chr2,pos:t.pos2,strand:t.strand2,name:t.gene2||""}}];delete t.chr1;delete t.pos1;delete t.strand1;delete t.gene1;delete t.chr2;delete t.pos2;delete t.strand2;delete t.gene2}const s=[t.dt];const a=e.seekcoord(t.pairlst[0].a.chr,t.pairlst[0].a.pos);if(a.length&&a[0].x>0&&a[0].x<e.width){s.push(...[t.pairlst[0].a.chr,t.pairlst[0].a.pos,t.pairlst[0].a.strand,0,t.pairlst[0].a.name]);t.mname=t.pairlst[0].b.name||"";t.chr=t.pairlst[0].a.chr;t.pos=t.pairlst[0].a.pos;t.pairlstIdx=0}else{const a=e.seekcoord(t.pairlst[0].b.chr,t.pairlst[0].b.pos);if(a.length&&a[0].x>0&&a[0].x<e.width){s.push(...[t.pairlst[0].b.chr,t.pairlst[0].b.pos,t.pairlst[0].b.strand,1,t.pairlst[0].b.name]);t.mname=t.pairlst[0].a.name||"";t.chr=t.pairlst[0].b.chr;t.pos=t.pairlst[0].b.pos;t.pairlstIdx=1}}t.ssm_id=s.join(".")}function Ot(t){if(t.custom_variants.find((t=>t.occurrence!=undefined))){return}for(const e of t.custom_variants){if(e.sample){e.sample_id=e.sample;delete e.sample}}if(!t.custom_variants.find((t=>t.sample_id))){return}const e=[];const s=new Map;for(const a of t.custom_variants){if(a.dt!=u){a.occurrence=1;a.samples=[{sample_id:a.sample_id}];delete a.sample_id;e.push(a);continue}const t=a.mname+"."+a.chr+"."+a.pos+"."+a.ref+"."+a.alt;const n=s.get(t);if(n){n.occurrence++;n.samples.push({sample_id:a.sample_id})}else{a.occurrence=1;a.samples=[{sample_id:a.sample_id}];delete a.sample_id;s.set(t,a)}}t.custom_variants=e;for(const e of s.values())t.custom_variants.push(e);if(!t.mds.variant2samples)t.mds.variant2samples={};const a=t.mds.variant2samples;a.type_samples="samples";a.type_summary="summary";a.type_sunburst="sunburst"}async function It(t,e){const s={genome:e.name};if(t.bcf.file){s.file=t.bcf.file}else{s.url=t.bcf.url;if(t.bcf.indexURL)s.indexURL=t.bcf.indexURL}const a=await p("vcfheader",{body:s});if(a.error)throw a.error;const[n,i,r,o]=U(a.metastr.split("\n"));if(o)throw"Error parsing VCF meta lines: "+o.join("; ");t.mds.bcf={info:n,format:i};if(r?.length){t.mds.bcf.samples=r;t.mds.variant2samples={type_samples:"samples",variantkey:"ssm_id"}}if(!t.mds.queries)t.mds.queries={};t.mds.queries.snvindel={forTrack:true}}function Tt(t){const e=t.allow2selectSamples;if(!e)return;if(!e.buttonText)e.buttonText="Select samples";if(typeof e.buttonText!="string")throw"allow2selectSamples.buttonText value is not string";if(!e.attributes)e.attributes=[{from:"sample_id",to:"sample_id"}];if(!Array.isArray(e.attributes))throw"allow2selectSamples.attributes[] is not array";if(e.attributes.length==0)throw"allow2selectSamples.attributes[] blank array";for(const t of e.attributes){if(typeof t.from!="string"||!t.from)throw"allow2selectSamples.attributes.from is not string";if(typeof t.to!="string"||!t.to)throw"allow2selectSamples.attributes.to is not string"}if(typeof e.callback!="function")throw"allow2selectSamples.callback() is not function";e._cart=[]}async function Dt(t){for(const e of t.mlst){if(e.dt!=u&&e.dt!=l&&e.dt!=o&&e.dt!=s)throw"mlst[] contains unknown dt"}if(t.mlst.length==1){await Bt(t)}else{await Ut(t)}Ft(t)}function Ft(t){if(!t.tipDiv){return}const e=[];for(const s of t.div.selectAll("div").selectAll("table")){if(s)e.push(s)}if(!e.length)return;let s=0;for(const t of e){const e=t.firstChild;if(e.tagName!="THEAD")continue;const a=e.firstChild;if(a.tagName!="TR")continue;s=Math.max(s,a.childNodes?.length)}if(s>5){t.tipDiv.style("left","50px")}}async function Bt(t){const e=h({holder:t.div});const a=t.mlst[0];if(a.dt==u){Pt(t,e)}else if(a.dt==o||a.dt==l){await Kt(t,e)}else if(a.dt==s){Qt(t,e)}else{throw"oneItem: unknown dt"}t.singleSampleDiv=e;if(t.tk.mds.variant2samples){if(a.occurrence){await te(t)}}}async function Ut(t){const e=t.div.append("div").style("margin-bottom","10px").style("display","none");e.append("span").html("&#8810; Back to list").attr("class","sja_clbtext").on("click",(()=>{m.style("display","");e.style("display","none");a.style("display","none")}));const a=t.div.append("div").style("display","none");const n=[{label:"Click a variant to see details"}];const r=t.mlst.some((t=>t.occurrence));if(r){n.push({label:"Occurrence"})}let c=null;if(t.tk.mds.bcf?.info){c=[];for(const e in t.tk.mds.bcf.info){if(t.tk.mds.bcf.info[e].categories){c.push(e);n.push({label:t.tk.mds.bcf.info[e].name||e})}}if(c.length==0)c=null}let d;if(t.tk.skewer){d=t.tk.skewer.viewModes.find((t=>t.inuse&&t.type=="numeric"&&t.byAttribute!="occurrence"));if(d){n.push({label:d.label})}}t.mlst.sort(((t,e)=>t.__x-e.__x));const f=[];for(const e of t.mlst){const s=[{}];if(r){s.push({value:"occurrence"in e?e.occurrence:""})}if(c){for(const a of c){const n=e.info[a];if(n==undefined){s.push({})}else{const e=t.tk.mds.bcf.info[a].categories[n];if(e?.color){s.push({html:`<span style="background:${e.color}">&nbsp;&nbsp;</span> ${e.label||n}`})}else{s.push({value:n})}}}}if(d){s.push({value:e[d.byAttribute]})}f.push(s)}const m=t.div.append("div");R({div:m,columns:n,rows:f,striped:false,resize:true});for(const[n,r]of t.mlst.entries()){const c=f[n][0].__td.append("div").attr("class","sja_menuoption").on("click",(()=>{m.style("display","none");e.style("display","");a.style("display","").selectAll("*").remove();const s=Object.assign({},t);s.mlst=[r];s.div=a;Dt(s)}));if(r.dt==u){c.append("span").text(t.tk.mnamegetter(r));c.append("span").text(i[r.class].label).style("font-size",".8em").style("margin-left","10px").style("color",i[r.class].color);c.append("span").text(`${r.chr}:${r.pos+1}${r.ref?", "+r.ref+">"+r.alt:""}`).style("font-size",".8em").style("margin-left","10px")}else if(r.dt==o||r.dt==l){c.append("span").text(i[r.class].label).style("font-size",".7em").style("margin-right","8px");Xt(r.pairlst[0],c)}else if(r.dt==s){c.append("span").style("background",t.tk.cnv.colorScale(r.value)).text(r.value).style("font-size",".8em").style("padding","0px 3px");c.append("span").style("margin-left","10px").text(`${r.chr}:${r.start}-${r.stop}`)}else{c.text("error: unknown m.dt")}}if(!t.doNotListSample4multim&&t.tk.mds.variant2samples){const e=t.mlst.reduce(((t,e)=>t+(e.occurrence||0)),0);if(e){t.div.append("div").style("margin-top","10px").append("span").attr("class","sja_clbtext").text("List all samples").on("click",(async e=>{e.target.remove();m.remove();await te(t);Ft(t)}))}}}function Pt({mlst:t,tk:e,block:s},a){const n=t[0];{const[t,e]=a.addRow();t.text(s.mclassOverride?s.mclassOverride.className:"Consequence");Ht(e,n)}{const[t,i]=a.addRow();t.text(n.ref&&n.alt?"Mutation":"Position");Wt(i,n,e,s)}if(n.occurrence>1){const[t,e]=a.addRow();t.text("Occurrence");e.text(n.occurrence)}Gt(n,e,a);Vt(n,e,a);Zt(n,e,a);if(n.info){for(const t in n.info){if(t=="CSQ"){continue}const[s,i]=a.addRow();s.text(t);const r=n.info[t];const o=e.mds?.bcf?.info?.[t];if(Array.isArray(r)){for(const t of r){Et(n,o,t,i)}}else{Et(n,o,r,i)}if(o?.Description){i.append("span").style("margin-left","10px").style("font-size",".8em").style("opacity",.6).text(o.Description)}}}}function Gt(t,e,s){const a=e.skewer.viewModes.find((t=>t.inuse));if(a.type!="numeric"||a.byAttribute=="occurrence")return;if(a.tooltipPrintValue){const e=a.tooltipPrintValue(t);if(Array.isArray(e)){for(const t of e){const[e,a]=s.addRow();e.text(t.k);a.text(t.v)}}else{console.log("unknown return value")}return}const[n,i]=s.addRow();n.text(a.label);i.text(t.__value_missing?"NA":t.__value_use)}function Vt(t,e,s){if(!t.htmlSections)return;if(!Array.isArray(t.htmlSections))throw"htmlSections[] is not array";for(const e of t.htmlSections){const[t,a]=s.addRow();if(e.key&&e.html){t.text(e.key);a.html(e.html)}}}function Et(t,e,s,a,n){if(!e){a.append("span").text(s);return}if(e.urlBase){a.append("a").text(s).attr("href",e.urlBase+s).attr("target","_blank");return}const i=a.append("span").text(s);if(e&&e.categories){const t=e.categories[s];if(t){i.style("padding","1px 4px").style("background",t.color);if(t.textcolor){i.style("color",t.textcolor)}}}}function Ht(t,e){t.append("span").text(e.mname);t.append("span").style("margin-left","5px").style("color",i[e.class].color).style("font-size",".8em").text(i[e.class].label.toUpperCase())}function Wt(t,e,s,a){const n=t.append("span").text(`${e.chr}:${e.pos+1} ${e.ref&&e.alt?e.ref+">"+e.alt:""}`);const i=s.mds.termdbConfig?.urlTemplates?.ssm||s.mds.queries?.snvindel?.ssmUrl;if(i){const s=z(i,e,n,a.genome.name);if(s?.length){t.append("span").style("margin-left","10px").html(s.join(" "))}}}async function Kt(t,e){await Jt(t.mlst[0],e.scrollDiv.insert("div",":first-child"),t.block);{const[s,a]=e.addRow();s.text("Data type");a.text(i[t.mlst[0].class].label)}{const[s,a]=e.addRow();s.text("Break points");for(const e of t.mlst[0].pairlst){Xt(e,a.append("div"))}}}function Qt(t,e){const s=t.mlst[0];{const[a,n]=e.addRow();a.text("Copy number change");n.html(`<span style="background:${t.tk.cnv.colorScale(s.value)}">&nbsp;&nbsp;</span> ${s.value}`)}{const[t,a]=e.addRow();t.text("Position");a.text(s.chr+":"+s.start+"-"+s.stop)}if(s.samples){const[t,a]=e.addRow();t.text("Sample");for(const t of s.samples){a.append("div").text(t.sample_id)}}}function Xt(t,e){if(t.a.name)e.append("span").text(t.a.name).style("font-weight","bold").style("margin-right","5px");e.append("span").text(`${t.a.chr}:${t.a.pos} ${t.a.strand=="+"?"forward":"reverse"} > ${t.b.chr}:${t.b.pos} ${t.b.strand=="+"?"forward":"reverse"}`);if(t.b.name)e.append("span").text(t.b.name).style("font-weight","bold").style("margin-left","5px")}async function Jt(t,e,s){const a=e.append("div").text("Loading...");try{if(!t.pairlst)throw".pairlst[] missing";const n={a:{chr:t.pairlst[0].a.chr,position:t.pairlst[0].a.pos,strand:t.pairlst[0].a.strand},b:{chr:t.pairlst[0].b.chr,position:t.pairlst[0].b.pos,strand:t.pairlst[0].b.strand}};await Yt(n.a,s);await Yt(n.b,s);a.remove();const i=await import("./svgraph-f6a28b78.js");i.default({pairlst:[n],genome:s.genome,holder:e})}catch(t){a.text(t.message||t)}}async function Yt(t,e){const s=await p("isoformbycoord",{body:{genome:e.genome.name,chr:t.chr,pos:t.position}});if(s.error)throw s.error;const a=s.lst.find((t=>t.isdefault))||s.lst[0];if(a){t.name=a.name;t.gm={isoform:a.isoform}}}function Zt(t,e,s){if(!e.mds.queries?.ld)return;const[a,n]=s.addRow();a.text("LD overlay");const i=e.mds.queries.ld.mOverlay?.m;if(i){const s=n.append("div").style("margin-bottom","5px");if(t.ssm_id==i.ssm_id){s.html(e.mds.queries.ld.mOverlay.ldtkname+" r<sup>2</sup> values against this variant are displayed on all the other variants.")}else{let a=null;for(const s of e.mds.queries.ld.mOverlay.data||[]){if(s.pos==t.pos&&s.alleles==t.ref+"."+t.alt){a=s.r2;break}}if(a==null){s.html("No r<sup>2</sup> value is found.")}else{s.html(e.mds.queries.ld.mOverlay.ldtkname+" r<sup>2</sup> = "+a)}}}n.append("div").html("Click a button to overlay LD r<sup>2</sup> values against this variant:").style("font-size",".8em").style("opacity",.5);for(const s of e.mds.queries.ld.tracks){const a=n.append("button").text(s.name);if(i&&i.ssm_id==t.ssm_id){if(s.name==e.mds.queries.ld.mOverlay.ldtkname){a.property("disabled",true);continue}}a.on("click",(()=>{e.itemtip.hide();e.mds.queries.ld.mOverlay={ldtkname:s.name,m:{chr:t.chr,pos:t.pos,ref:t.ref,alt:t.alt,ssm_id:t.ssm_id}};e.load()}))}}async function te(t){const e=t.div.append("div").text("Loading...").style("padding","10px").style("color","#8AB1D4").style("font-size","1.25em").style("font-weight","bold");t.tid2value_orig=new Set;if(t.tid2value)Object.keys(t.tid2value).forEach(t.tid2value_orig.add,t.tid2value_orig);try{t.querytype=t.tk.mds.variant2samples.type_samples;const s=await t.tk.mds.variant2samples.get(t);await ee(s.samples,t);e.remove()}catch(t){e.text("Error: "+(t.message||t));if(t.stack)console.log(t.stack)}}async function ee(t,e){if(t.length==1){return await ae(t[0],e)}const[s,a]=await oe(t,e.tk);const n={rows:a,columns:s,div:e.div,resize:a.length>10,dataTestId:"sjpp_mds3tk_sampletable"};n.columnButtons=[];if(e.tk.mds.queries?.singleSampleMutation){const s={text:"Disco",dataTestId:"sja_sample_table_disco_button",callback:async(s,a)=>{e.tk.itemtip.hide();e.tk.menutip.hide();let n;if(t[a].ssm_id_lst?.[0]){n=(e.tk.skewer.rawmlst||e.tk.custom_variants).find((e=>e.ssm_id==t[a].ssm_id_lst[0]))}await re(e.tk,e.block,t[a],n)}};n.columnButtons.push(s)}if(e.tk.mds.queries?.singleSampleGenomeQuantification){for(const s in e.tk.mds.queries.singleSampleGenomeQuantification){const a={text:s,dataTestId:`${s}_button`,callback:async(a,n)=>{const i=g(e.tk.newChartHolder||e.block.holder0);i.header.text(t[n].sample_id);await(await import("./plot.ssgq-02ffde06.js")).plotSingleSampleGenomeQuantification(e.tk.mds,e.tk.mds.label,s,t[n],i.body.append("div").style("margin","20px"),e.block.genome,e.block.usegm?.name)}};n.columnButtons.push(a)}}if(e.tk.allow2selectSamples){n.buttons=[{text:e.tk.allow2selectSamples.buttonText,class:e.tk.allow2selectSamples.class,callback:s=>{se(e.tk,e.block,t,s);e.tk.itemtip.hide();e.tk.menutip.hide()}}]}return R(n)}async function se(t,e,s,a){const n=[...s];const i=a.map((t=>n[t]));t.allow2selectSamples.callback({samples:await t.mds.termdb.vocabApi.convertSampleId(i,t.allow2selectSamples.attributes),source:"Samples with "+ce(e)})}async function ae(t,e){const s=e.singleSampleDiv||h({holder:e.div});if(t.sample_id){const[a,n]=s.addRow();a.text(e.tk.mds.termdbConfig?.lollipop?.sample||"Sample");let i;if(t.ssm_id_lst?.[0]){i=e.tk.skewer.rawmlst.find((e=>e.ssm_id==t.ssm_id_lst[0]))}ie(t,e.tk,n,e.block,i)}if("caseIsOpenAccess"in t){const[e,a]=s.addRow();e.text("Access");a.text(t.caseIsOpenAccess?"Open":"Controlled")}if(e.tk.mds.variant2samples.twLst){for(const a of e.tk.mds.variant2samples.twLst){const[e,n]=s.addRow();e.text(a.term.name).style("text-overflow","ellipsis");n.style("text-overflow","ellipsis");if(a.term.id in t){if(Array.isArray(t[a.term.id])){if(a.baseURL){n.html(t[a.term.id].map((t=>`<a href=${a.baseURL+t} target=_blank>${t}</a>`)).join("<br>"))}else{n.html(t[a.term.id].join("<br>"))}}else{const e=ne(t,a);if(a.baseURL){n.html(`<a href=${a.baseURL+e} target=_blank>${e}</a>`)}else{n.text(e)}}}}}if(t.ssmid2format){for(const a of t.ssm_id_lst){if(t.ssm_id_lst.length>1){const[t,n]=s.addRow();n.style("padding-top","20px");const i=e.tk.skewer.rawmlst.find((t=>t.ssm_id==a));if(i){if(i.dt==u){Wt(n,i,e.tk,e.block)}else if(i.dt==o||i.dt==l){Xt(i.pairlst[0],n)}else{n.text(a)}}else{n.text(a)}}for(const n in t.ssmid2format[a]){const i=t.ssmid2format[a][n];const[r,o]=s.addRow();const l=e.tk.mds?.bcf?.format?.[n];r.text(l&&l.Description||n);o.html(le(l,i))}}}}function ne(t,e){if(!(e.term.id in t))return"";const s=t[e.term.id];if(e.term.values?.[s]?.label)return e.term.values[s].label;const a=e.term.valueConversion;if(a)return f(s,a.fromUnit,a.toUnit,a.scaleFactor);return s}function ie(t,e,s,a,n){const i=e.mds.termdbConfig?.urlTemplates?.sample;if(i){const e=s.append("a");e.attr("href",i.base+(t[i.namekey]||t.sample_id));e.attr("target","_blank");e.text(t.sample_id);e.style("word-break","break-word")}else{s.append("span").attr("class","pp_mds3_singleSampleNameSpan").text(t.sample_id)}const r=s.append("div");if(e.allow2selectSamples){const s=e.allow2selectSamples.buttonText;const n=r.append("button").style("margin-right","10px").text(s.endsWith("s")?s.substring(0,s.length-1):s).on("click",(()=>{se(e,a,[t],[0]);e.itemtip.hide();e.menutip.hide()}));if(e.allow2selectSamples.class)n.attr("class",e.allow2selectSamples.class)}if(e.mds.queries?.singleSampleMutation){r.append("button").style("margin-right","10px").text("Disco plot").attr("data-testid","proteinpaint_disc_table_disco_button").on("click",(async()=>{e.itemtip.hide();await re(e,a,t,n)}))}if(e.mds.queries?.singleSampleGenomeQuantification){for(const s in e.mds.queries.singleSampleGenomeQuantification){r.append("button").text(s).on("click",(async()=>{const n=g(e.newChartHolder||a.holder0);n.header.text(t.sample_id);await(await import("./plot.ssgq-02ffde06.js")).plotSingleSampleGenomeQuantification(e.mds,e.mds.label,s,t,n.body.append("div").style("margin","20px"),a.genome,a.usegm?.name)}))}}}async function re(t,e,s,a){const n=g(t.newChartHolder||e.holder0);const i=[s.sample_id];if(a){i.push(", with ");if(e.usegm){i.push(e.usegm.name)}else{i.push(a.isoform)}i.push(" "+a.mname)}n.header.text(i.join(""));try{(await import("./plot.disco-9c631d77.js")).default(t.mds,t.mds.label,s,n.body,e.genome,{downloadImgName:i.join("")+" Disco",Disco:{prioritizeGeneLabelsByGeneSets:true}})}catch(t){n.body.append("div").text("Error: "+(t.message||t));if(t.stack)console.log(t.stack)}}async function oe(t,e){const s=t.some((t=>"caseIsOpenAccess"in t)),a=t.some((t=>t.ssm_id))||t.some((t=>t.ssm_id_lst)),n=t.some((t=>t.ssmid2format))&&e.mds?.bcf?.format;const r=new Set;const c=[{label:e.mds.termdbConfig?.lollipop?.sample||"Sample"}],d=[];if(s){c.push({label:"Access"})}if(e.mds.variant2samples.twLst){for(const t of e.mds.variant2samples.twLst){const e={label:t.term.name};c.push(e)}}if(a){c.push({label:"Mutations",isSsm:true})}if(n){for(const e of t){if(!e.ssmid2format)continue;for(const t in e.ssmid2format){for(const s in e.ssmid2format[t])r.add(s)}}for(const t in e.mds.bcf.format){if(!r.has(t))continue;const s=e.mds.bcf.format[t];c.push({label:s.Description||t})}}for(const c of t){const t=[{value:c.sample_id}];let f=c.ssm_id_lst;if(!f&&c.ssm_id)f=[c.ssm_id];{const s=e.mds.termdbConfig?.urlTemplates?.sample;if(s){t[0].url=s.base+(c[s.namekey]||c.sample_id)}}if(s){t.push({value:c.caseIsOpenAccess?"Open":"Controlled"})}if(e.mds.variant2samples.twLst){for(const s of e.mds.variant2samples.twLst){const e=ne(c,s);if(s.baseURL){t.push({html:`<a href=${s.baseURL+e} target=_blank>${e}</a>`})}else{t.push({value:e})}}}if(a){if(f){const s=[];for(const t of f){const a=[];const n=(e.skewer.rawmlst||e.custom_variants).find((e=>e.ssm_id==t));if(n){if(n.dt==u){if(e.mds.queries&&e.mds.queries.snvindel&&e.mds.queries.snvindel.url){a.push(`<a href=${e.mds.queries.snvindel.url.base+n.ssm_id} target=_blank>${n.mname}</a>`)}else{a.push(n.mname)}}else if(n.dt==o||n.dt==l){const t=n.pairlst[0];a.push(`${t.a.name||""} ${t.a.chr}:${t.a.pos} ${t.a.strand=="+"?"forward":"reverse"} > ${t.b.name||""} ${t.b.chr}:${t.b.pos} ${t.b.strand=="+"?"forward":"reverse"}`)}else{throw"unknown dt"}a.push(`<span style="color:${w(i[n.class].color).darker()};font-size:0.8em;">${i[n.class].label}</span>`);s.push(a.join(" "))}else{s.push(t)}}t.push({html:s.join("<br>")})}else{t.push({value:""})}}if(n){if(!f)throw"ssm_id_lst missing, cannot show format";for(const s in e.mds.bcf.format){if(!r.has(s))continue;if(!c.ssmid2format){t.push({value:""});continue}const a=e.mds.bcf.format[s];const n=[];for(const t of f){const e=c.ssmid2format?.[t]?.[s];n.push(le(a,e))}t.push({html:n.join("<br>")})}}d.push(t)}return[c,d]}function le(t,e){if(t&&e&&t.Number=="R"&&t.Type=="Integer"){const t=e.split(",").map(Number);if(t.length==2){const[e,s]=t;if(e>=0&&s>=0&&e+s>0){return`${b(null,{f:s/(s+e)})} <span style="font-size:.8em">${s}/${s+e}</span>`}}}return e}function ce(t){if(t.gmmode=="genomic"){const e=t.rglst[0];return"mutations from "+e.chr+":"+e.start+"-"+e.stop}if(t.usegm)return"mutations in "+t.usegm.name;return"mutations"}const de=10;async function fe(t,e,s,a,n){try{if(e.click_snvindel){e.skewer.hlssmid=new Set(t.mlst.map((t=>t.ssm_id)));Ne(e);e.click_snvindel(t.mlst[0]);return}if("occurrence"in t&&t.occurrence>=de&&e.mds.variant2samples&&e.mds.variant2samples.sunburst_twLst){await me(t,e,s,a);return}await pe({mlst:t.mlst,tk:e,block:s,tippos:a})}catch(t){s.error(t.message||t);if(t.stack)console.log(t.stack)}}async function me(t,e,s,a){e.glider.style("cursor","wait");const n=await e.mds.variant2samples.get({mlst:t.mlst,querytype:e.mds.variant2samples.type_sunburst});e.glider.style("cursor","auto");const i={nodes:n.nodes,occurrence:t.occurrence,boxyoff:e.yoff,boxheight:Math.min(800,e.height),boxwidth:s.width,svgheight:Number.parseFloat(s.svg.attr("height")),g:e.skewer.g.append("g"),pica:e.pica,click_listbutton:(n,i)=>{pe({mlst:t.mlst,tk:e,block:s,tippos:a})},click_ring:async(a,n)=>{e.itemtip.clear();const i={mlst:t.mlst,tk:e,block:s,div:e.itemtip.d,tid2value:{}};i.tid2value[n.data.id0]=n.data.v0;if(n.data.id1)i.tid2value[n.data.id1]=n.data.v1;if(n.data.id2)i.tid2value[n.data.id2]=n.data.v2;i.mlst=t.mlst.map((t=>{if(e.mds.variant2samples.variantkey=="ssm_id"){return{ssm_id:t.ssm_id,occurrence:0}}throw"unknown variant2samples.variantkey"}));i.mlst[0].occurrence=n.value;const r=a.clientX;const o=a.clientY;await te(i);e.itemtip.show2(r,o)}};if(t.aa){i.cx=t.aa.x;i.cy=Ae(t,e)+t.yoffset*(e.skewer.pointup?-1:1)}else{i.cx=t.x;i.cy=t.y+(e.skewer.pointup?1:-1)*e.skewer.stem1/2}if(t.mlst.length==1){i.chartlabel=t.mlst[0].mname}else{const e=new Set(t.mlst.map((t=>t.mname)));if(e.size==1){i.chartlabel=[...e][0]}else{i.chartlabel=t.mlst.reduce(((t,e)=>e.occurrence>t.occurrence?e:t)).mname+" etc"}}const r=await import("./sunburst-2140e468.js");r.default(i)}async function pe(t){t.tk.itemtip.clear().show(t.tippos.left-10,t.tippos.top-10);t.div=t.tk.itemtip.d;t.tipDiv=t.tk.itemtip.d;await Dt(t)}function ue(t,e,s){s.append("path").attr("d",(t=>e.shape[1].calculatePath(ge(e.shape[0],t.radius,e)))).attr("fill",e.shape[1].isFilled?e=>t.color4disc(e.mlst[0]):"white").attr("stroke",e.shape[1].isFilled?"white":e=>t.color4disc(e.mlst[0]))}function he(t,e){const s=e.append("path").attr("d",(e=>{const s=e.radius*1.01||e.maxradius+2;return t.shape[1].calculatePath(ge(t.shape[0],s,t))})).attr("stroke-width",1.75);return s}function ge(t,e,s){switch(t){case"emptyCircle":return{radius:e};case"filledVerticalRectangle":return{width:e*1.5,height:e*2.1};case"emptyVerticalRectangle":return{width:e*1.4,height:e*2};case"filledTriangle":return{width:e*2.1,height:e*2.1,isUp:s.pointup};case"emptyTriangle":return{width:e*2,height:e*2,isUp:s.pointup};case"filledSquare":return{width:e*1.7,height:e*1.7};case"emptySquare":return{width:e*1.7,height:e*1.7};default:throw"Invalid shape key. Add shape [getPathDimensions() skewer.render.shapes.ts]"}}function we(t,e){if(t.includes("Triangle")){if(e)return"central";else return`text-after-edge`}else return""}const be=0;const ke=1;const xe=.3;const ye=1;const ve=.6;const _e="Arial";function je(t,e){const s=t.skewer;for(const t of s.data){t.x0=t.x;if(t.xoffset!=undefined){t.x=t.x0+t.xoffset}for(const e of t.groups){e.aa=t}}const a=Math.max(14,e.width/110);let n=0;for(const t of s.data){for(const e of t.groups){n=Math.max(n,e.occurrence)}}let i=0;const r=Math.pow(a/2,2)*Math.PI;if(n<=10)i=r*n*.9;else if(n<=100)i=r*10;else if(n<=1e3)i=r*14;else i=r*20;const c=d().domain([1,n*.5,n*.6,n*.7,n*.8,n]).range([r,r+(i-r)*.8,r+(i-r)*.85,r+(i-r)*.9,r+(i-r)*.95,i]);let f=a/2;s.maxheight=0;for(const t of s.data){if(t.showmode==undefined)t.showmode=be;if(t.slabelrotate==undefined)t.slabelrotate=false;t.maxradius=0;t.maxrimwidth=0;t.width=0;t.slabelwidth=0;for(const e of t.groups){if(e.occurrence<=1){e.radius=a/2}else{const t=e.occurrence.toString().length;e.radius=Math.max(Math.sqrt(c(e.occurrence)/Math.PI),t*5)}t.maxradius=Math.max(t.maxradius,e.radius);f=Math.max(f,e.radius);e.rimwidth=e.rim1count+e.rim2count==0?0:Math.max(2,e.radius/6);t.maxrimwidth=Math.max(t.maxrimwidth,e.rimwidth)}let e=0;for(const s of t.groups){s.yoffset=e+s.radius+s.rimwidth;e+=(s.radius+s.rimwidth)*2}s.maxheight=Math.max(s.maxheight,e)}s.selection=s.g.selectAll().data(s.data).enter().append("g").attr("class","sja_skg").each((function(t){t.skewer=this}));const m=s.selection.selectAll().data((t=>t.groups)).enter().append("g").attr("transform",(e=>"translate(0,"+(e.aa.showmode==be?0:e.yoffset*(t.skewer.pointup?-1:1))+")")).attr("class","sja_aa_discg").each((function(t){t.g=this}));const p=t.skewer?.shape?.[1]?.isFilled==false;if(t.skewer.shape&&!t.skewer?.shape?.[0].includes("Circle")){ue(t,s,m)}else{const e=m.append("circle");e.filter((t=>t.dt==u||t.dt==o||t.dt==l)).attr("fill",p?"white":e=>t.color4disc(e.mlst[0])).attr("stroke",p?e=>t.color4disc(e.mlst[0]):"white").attr("r",(t=>t.radius-.5));m.filter((t=>t.dt==l||t.dt==o)).append("path").attr("fill",p?"black":"white").attr("stroke","none").attr("d",(t=>O()({innerRadius:0,outerRadius:t.radius-2,startAngle:t.useNterm?0:Math.PI,endAngle:t.useNterm?Math.PI:Math.PI*2})))}const h=m.filter((t=>t.occurrence>1)).append("text").text((t=>t.occurrence)).attr("font-family",_e).attr("class","sja_aa_discnum").attr("fill-opacity",(t=>t.aa.showmode==be?0:1)).attr("stroke-opacity",(t=>t.aa.showmode==be?0:1)).attr("dominant-baseline",t.skewer.shape?we(t.skewer.shape[0],t.skewer.pointup):"").attr("text-anchor","middle").each((t=>{const e=t.radius*1.5;t.discnumfontsize=Math.min(e/(t.occurrence.toString().length*ve),e)})).attr("font-size",(t=>t.discnumfontsize)).attr("y",(t=>t.discnumfontsize*xe));h.filter((t=>t.dt==u)).attr("fill",p?"black":"white");h.filter((t=>t.dt==o||t.dt==l)).attr("stroke",(e=>t.color4disc(e.mlst[0]))).attr("stroke-width",.8).attr("font-weight","bold").attr("fill",p?"black":"white");m.append("text").text((e=>e.mnameCompact||t.mnamegetter(e.mlst[0]))).attr("font-size",(t=>{t._labfontsize=Math.max(12,t.radius*1.2);return t._labfontsize})).each((function(t){const e=this.getBBox().width;t._label_width=e;if(t.aa.groups.length==1){t.aa.slabelrotate=true;t.aa.slabelwidth=e;s.maxheight=Math.max(s.maxheight,(t.radius+t.rimwidth)*2+2+e)}})).attr("fill",(e=>t.color4disc(e.mlst[0]))).attr("x",(t=>t.radius+t.rimwidth+1)).attr("y",(t=>t._labfontsize*xe)).attr("font-family",_e).classed("sja_aa_disclabel",true).attr("fill-opacity",(t=>t.aa.showmode==be?0:1)).attr("transform","scale(1) rotate(0)").on("mousedown",(t=>{t.stopPropagation()})).on("click",((s,a)=>{Le([a.aa],t);qe(t,e)}));s.hlBoxG=m.append("g");for(const t of s.data){let e=0,s=0;for(const a of t.groups){e=Math.max(e,a.radius+a.rimwidth);s=Math.max(s,a.radius+a.rimwidth+ye+a._label_width)}t.width=e+s}let g;if(t.skewer.shape&&t.skewer.shape[0]!=="filledCircle"){g=he(s,m)}else{g=m.append("circle").attr("r",(t=>t.radius-.5))}g.attr("stroke",(e=>t.color4disc(e.mlst[0]))).classed("sja_aa_disckick",true).attr("fill","white").attr("fill-opacity",0).attr("stroke-opacity",0).on("mousedown",(t=>{t.stopPropagation()})).on("mouseover",((e,s)=>{if(t.disc_mouseover){t.disc_mouseover(s,e.target)}})).on("mouseout",((e,s)=>{if(t.disc_mouseout){t.disc_mouseout(s)}})).on("click",(async(s,a)=>{fe(a,t,e,s.target.getBoundingClientRect(),s.target)}));const w=O().innerRadius((t=>t.radius)).outerRadius((t=>t.radius+t.rimwidth)).startAngle(0).endAngle((t=>{t.rim1_startangle=Math.PI*2*t.rim1count/t.occurrence;return t.rim1_startangle}));m.filter((t=>t.rim1count>0)).append("path").attr("d",w).attr("fill",(e=>t.color4disc(e.mlst[0]))).attr("class","sja_aa_discrim").attr("fill-opacity",0);const b=O().innerRadius((t=>t.radius+.5)).outerRadius((t=>t.radius+.5+t.rimwidth)).startAngle((t=>t.rim1_startangle)).endAngle((t=>t.rim1_startangle+Math.PI*2*t.rim2count/t.occurrence));m.filter((t=>t.rim2count>0)).append("path").attr("d",b).attr("stroke",(e=>t.color4disc(e.mlst[0]))).attr("fill","none").attr("class","sja_aa_discrim").attr("stroke-opacity",0);{let t=0;let e=0;for(const a of s.data){if(a.x-a.maxradius-a.maxrimwidth<e){t++}e=Math.max(e,a.x+a.width-a.maxradius-a.maxrimwidth)}s.stem1=t==0?0:a;s.stem2=d().domain([0,1,s.data.length]).range([0,a,a*3])(t)}const x=a*.7;let y=0;for(const t of s.data){for(const e of t.groups){y=Math.max(y,e.occurrence)}}s.stem3=Math.max(2,x+a*Math.min(5,y));let v;if(t.skewer.shape&&!t.skewer.shape[0].includes("Circle")){v=he(s,s.selection);v.attr("transform",(e=>`translate(0, ${(t.skewer.pointup?-1:1)*e.maxradius})`))}else{v=s.selection.append("circle").attr("r",(t=>t.maxradius+1)).attr("cy",(e=>(t.skewer.pointup?-1:1)*e.maxradius)).attr("transform",(t=>`scale(${t.showmode==be?"1,1":"0.01,0.01"})`))}v.attr("class","sja_aa_skkick").attr("fill","white").attr("fill-opacity",0).attr("stroke","none").on("mouseover",((e,s)=>{let a=0;let n=0;const i=5;const r=t.skewer.pointup?7:14;for(const e of s.groups){e.pica_fontsize=Math.max(11,e.radius);a+=e.pica_fontsize+1;t.pica.g.append("text").text((e.mnameCompact||e.mlst[0].mname)+(e.occurrence>1?" x"+e.occurrence:"")).attr("font-size",e.pica_fontsize).each((function(){n=Math.max(n,this.getBBox().width)})).remove()}n+=i*2;const o=a+5;t.pica.g.append("rect").attr("y",t.skewer.pointup?-o:0).attr("width",n).attr("height",o).attr("fill","white").attr("fill-opacity",.8).attr("stroke","#ccc").attr("shape-rendering","crispEdges");a=0;const l=t.pica.g.selectAll().data(s.groups).enter().append("g").attr("transform",((e,s)=>{a+=e.pica_fontsize+1;return"translate("+i+","+a*(t.skewer.pointup?-1:1)+")"}));l.append("text").text((t=>t.mnameCompact||t.mlst[0].mname)).attr("font-size",(t=>t.pica_fontsize)).each((function(t){t.pica_mlabelwidth=this.getBBox().width})).attr("fill",(e=>t.color4disc(e.mlst[0]))).attr("dominant-baseline",t.skewer.pointup?"hanging":"auto");const c=s.groups[0].pica_mlabelwidth;t.pica.x=s.x-i-c/2;t.pica.y=s.y+(t.skewer.pointup?-1:1)*(s.maxradius*2+r+2);t.pica.g.attr("transform","translate("+t.pica.x+","+t.pica.y+")");l.filter((t=>t.occurrence>1)).append("text").text((t=>"x"+t.occurrence)).attr("x",(t=>t.pica_mlabelwidth+5)).attr("font-size",(t=>t.pica_fontsize)).attr("dominant-baseline",t.skewer.pointup?"hanging":"auto").attr("fill","#9e9e9e");const d=t.pica.g.append("g").attr("transform","translate("+(i+c/2)+","+(t.skewer.pointup?1:-1)+")");d.append("line").attr("y2",(t.skewer.pointup?1:-1)*r).attr("stroke","#858585").attr("shape-rendering","crispEdges");d.append("line").attr("x1",-1).attr("x2",-1).attr("y2",(t.skewer.pointup?1:-1)*r).attr("stroke","white").attr("shape-rendering","crispEdges");d.append("line").attr("x1",1).attr("x2",1).attr("y2",(t.skewer.pointup?1:-1)*r).attr("stroke","white").attr("shape-rendering","crispEdges")})).on("mouseout",((e,s)=>{t.pica.g.selectAll("*").remove()})).on("click",((s,a)=>{t.pica.g.selectAll("*").remove();Ce([a],t,e)}));let _=0;for(const t of s.data){_=Math.max(_,t.occurrence)}const j=d().domain([1,_]).range([x,s.stem3-f]);s.selection.attr("transform",(e=>{e.foldyoffset=j(e.occurrence);e.y=Ae(e,t);return"translate("+e.x+","+e.y+")"}));s.selection.append("path").attr("class","sja_aa_stem").attr("d",(e=>Me(e,t))).attr("stroke",(e=>t.color4disc(e.groups[0].mlst[0]))).attr("fill","none");const A=s.selection.filter((t=>t.groups.length>1));A.append("rect").attr("class","sja_aa_ssk_bg").attr("shape-rendering","crispEdges").attr("fill-opacity",0).attr("height",s.stem1).attr("fill",(e=>t.color4disc(e.groups[0].mlst[0]))).attr("width",(t=>{t.ssk_width=Math.max(t.occurrence.toString().length*8+6,2*(t.maxradius+t.maxrimwidth));return t.ssk_width})).attr("x",(t=>-t.ssk_width/2));A.append("text").attr("class","sja_aa_ssk_text").attr("fill","white").attr("fill-opacity",0).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","central").text((t=>t.occurrence)).each((t=>{t.ssk_fontsize=Math.min(s.stem1,t.ssk_width/(t.occurrence.toString().length*ve))})).attr("font-size",(t=>t.ssk_fontsize));A.append("rect").attr("class","sja_aa_ssk_kick").attr("fill","white").attr("fill-opacity",0).attr("stroke","none").attr("height",s.stem1).attr("x",(t=>-t.ssk_width/2)).attr("width",(t=>t.ssk_width)).on("mouseover",((t,e)=>{const s=k(t.target.parentNode);s.selectAll(".sja_aa_disckick").transition().attr("stroke-opacity",1);s.select(".sja_aa_ssk_bg").transition().attr("fill-opacity",1).attr("stroke-opacity",1);s.select(".sja_aa_ssk_text").transition().attr("fill-opacity",1)})).on("mouseout",(function(t,e){const s=k(t.target.parentNode);s.selectAll(".sja_aa_disckick").transition().attr("stroke-opacity",0);s.select(".sja_aa_ssk_bg").transition().attr("fill-opacity",0).attr("stroke-opacity",0);s.select(".sja_aa_ssk_text").transition().attr("fill-opacity",0)})).on("click",(async(s,a)=>{fe(a,t,e,s.target.getBoundingClientRect(),null,s.target)}))}function Ae(t,e){if(e.skewer.pointup){if(t.showmode==be){return e.skewer.maxheight+e.skewer.stem1+e.skewer.stem2+e.skewer.stem3-t.foldyoffset}return e.skewer.maxheight}if(t.showmode==be)return t.foldyoffset;return e.skewer.stem1+e.skewer.stem2+e.skewer.stem3}function Me(t,e){if(e.skewer.pointup){if(t.showmode==be){return"M0,0v0l0,0v"+t.foldyoffset}return"M0,0v"+e.skewer.stem1+"l"+(t.x0-t.x)+","+e.skewer.stem2+"v"+e.skewer.stem3}if(t.showmode==be){return"M0,0v0l0,0v-"+t.foldyoffset}return"M0,0v-"+e.skewer.stem1+"l"+(t.x0-t.x)+",-"+e.skewer.stem2+"v-"+e.skewer.stem3}function Se(t,e){if(t.skewer.data.length==0)return;const s=0;const a=e.width;let n=0;const i=[];const r=[];for(const e of t.skewer.data){if(e.x0<s||e.x0>a){delete e.xoffset;r.push(e)}else{n+=e.slabelrotate?(e.groups[0].radius+e.groups[0].rimwidth)*2:e.width;i.push(e)}}Le(r,t);let o=[];const l=[];if(n<a-s){o=i}else{i.sort(((t,e)=>{if(e.occurrence==t.occurrence){if(e.groups.length==t.groups.length){return Math.abs(t.x0*2-s-a)-Math.abs(e.x0*2-s-a)}else{return e.groups.length-t.groups.length}}return e.occurrence-t.occurrence}));let t=0;let e=(a-s)*.8;let n=false;for(const s of i){if(n){delete s.xoffset;l.push(s);s.showmode=be}else{if(t+s.width<e){o.push(s);t+=s.width}else{n=true;delete s.xoffset;l.push(s);s.showmode=be}}}}Le(l,t);Ce(o,t,e)}function Ce(t,e,s){const a=1e3;const n=new Set;const i=new Set;let r=false;for(const s of t){if(s.showmode==ke){n.add(s.x0)}else{s.showmode=ke;i.add(s.x0);r=true;s.y=Ae(s,e)}}if(r){const t=e.skewer.selection.filter((t=>i.has(t.x0)));t.transition().duration(a).attr("transform",(t=>"translate("+t.x+","+t.y+")"));t.selectAll(".sja_aa_discg").transition().duration(a).attr("transform",(t=>{t.y=t.yoffset*(e.skewer.pointup?-1:1);return"translate(0,"+t.y+")"}));t.selectAll(".sja_aa_disckick").transition().duration(a).attr("transform","scale(1)").on("end",(()=>{t.selectAll(".sja_aa_disckick").classed("sjpp-active",true)}));t.selectAll(".sja_aa_discnum").transition().duration(a).attr("fill-opacity",1).attr("stroke-opacity",1);t.filter((t=>t.groups.length>1)).selectAll(".sja_aa_disclabel").transition().duration(a).attr("fill-opacity",1).attr("transform","scale(1)");t.selectAll(".sja_aa_discrim").transition().duration(a).attr("fill-opacity",1).attr("stroke-opacity",1);t.selectAll(".sja_aa_ssk_kick").attr("transform","scale(1)").attr("y",e.skewer.pointup?0:-e.skewer.stem1);t.selectAll(".sja_aa_ssk_bg").attr("transform","scale(1)").attr("y",e.skewer.pointup?0:-e.skewer.stem1);t.selectAll(".sja_aa_ssk_text").attr("transform","scale(1)").attr("y",(e.skewer.pointup?1:-1)*e.skewer.stem1/2);t.selectAll(".sja_aa_skkick").transition().duration(0).attr("transform",(t=>`${e.skewer.shape&&!e.skewer.shape[0].includes("Circle")?`translate(0, ${(e.skewer.pointup?-1:1)*t.maxradius})`:""} scale(0.01, 0.01)`)).on("end",(()=>{t.selectAll(".sja_aa_skkick").classed("sjpp-active",false)}));let n=0;t.selectAll(".sja_aa_stem").transition().duration(a).attr("d",(t=>Me(t,e))).each((()=>++n)).on("end",(()=>{if(! --n){qe(e,s)}}))}else{qe(e,s)}}function qe(t,e){const s=1e3;const a=[];const n=new Set;const i=0;const r=e.width;for(const e of t.skewer.data){if(e.x0<i||e.x0>r)continue;if(e.showmode==ke){e.x=e.x0;a.push(e);n.add(e.x0)}}if(a.length==0){return}ze(a,t,e);for(const t of a){t.xoffset=t.x-t.x0}for(let e=0;e<a.length;e++){const s=a[e];if(s.groups.length>1)continue;const n=s.groups[0];if(t.slabel_forcerotate){s.slabelrotate=true}else{const t=a[e+1];const i=t?t.x-t.maxradius-t.maxrimwidth:r;s.slabelrotate=i-s.x-n.radius-n.rimwidth-1<s.slabelwidth}s.width=(n.radius+n.rimwidth)*2+(s.slabelrotate?0:2+s.slabelwidth)}const o=t.skewer.selection.filter((t=>n.has(t.x0)));o.transition().duration(s).attr("transform",(t=>"translate("+t.x+","+t.y+")"));o.selectAll(".sja_aa_stem").transition().duration(s).attr("d",(e=>Me(e,t)));o.filter((t=>t.groups.length==1)).selectAll(".sja_aa_disclabel").transition().duration(s).attr("fill-opacity",1).attr("transform",(e=>"scale(1) rotate("+(e.aa.slabelrotate?(t.skewer.pointup?"-":"")+"90":"0")+")"));t.slabel_forcerotate=false}function ze(t,e,s){const a=0;const n=s.width;let i=a;let r=false;for(const e of t){if(e.x0<a||e.x0>n)continue;if(e.groups.length==1){e.slabelrotate=true;const t=e.groups[0];e.width=(t.radius+t.rimwidth)*2}const t=e.x-e.maxradius-e.maxrimwidth;if(t<i){r=true}if(t+e.width>n){r=true}i=Math.max(i,t+e.width)}if(!r){return false}i=a;for(const e of t){if(e.x0<a||e.x0>n)continue;e.x=i+e.maxradius+e.maxrimwidth;i+=e.width}$e(t,s.width)}function $e(t,e){for(let s=0;s<t.length;s++){if(t[s].x0<0)continue;if(t[s].x0>e)break;while(1){let a=0,n=0;for(let i=s;i<t.length;i++){const s=t[i];if(s.x0>e){return}a+=Math.abs(s.x-s.x0);s.x++;n+=Math.abs(s.x-s.x0)}if(t[s].x>=t[s].x0){for(let e=s;e<t.length;e++){t[e].x--}break}const i=t[t.length-1];if(i.x+i.width/2>=e){return}if(n<=a);else{for(let a=s;a<t.length;a++){if(t[a].x0>e){break}t[a].x--}break}}}}function Le(t,e){if(t.length==0)return;const s=1e3;const a=new Set;for(const s of t){s.x=s.x0;a.add(s.x0);s.showmode=be;s.y=Ae(s,e)}const n=e.skewer.selection.filter((t=>a.has(t.x0)));n.transition().duration(s).attr("transform",(t=>"translate("+t.x+","+t.y+")"));n.selectAll(".sja_aa_stem").transition().duration(s).attr("d",(t=>Me(t,e)));n.selectAll(".sja_aa_discg").transition().duration(s).attr("transform",(t=>"translate(0,"+(e.skewer.pointup?"-":"")+t.aa.maxradius+")"));n.selectAll(".sja_aa_disckick").transition().duration(0).attr("transform","scale(0)").on("end",(()=>{n.selectAll(".sja_aa_disckick").classed("sjpp-active",false)}));n.selectAll(".sja_aa_discnum").transition().duration(s).attr("fill-opacity",0).attr("stroke-opacity",0);n.selectAll(".sja_aa_disclabel").transition().duration(s).attr("fill-opacity",0).attr("transform","scale(0)");n.selectAll(".sja_aa_discrim").transition().duration(s).attr("fill-opacity",0).attr("stroke-opacity",0);n.selectAll(".sja_aa_ssk_kick").attr("transform","scale(0)");n.selectAll(".sja_aa_ssk_bg").attr("transform","scale(0)");n.selectAll(".sja_aa_ssk_text").attr("transform","scale(0)");n.selectAll(".sja_aa_skkick").transition().duration(s).attr("transform",(t=>`${e.skewer.shape&&!e.skewer.shape[0].includes("Circle")?`translate(0, ${(e.skewer.pointup?-1:1)*t.maxradius})`:""} scale(1)`)).on("end",(()=>{n.selectAll(".sja_aa_skkick").classed("sjpp-active",true)}))}function Ne(t){t.skewer.hlBoxG.selectAll("*").remove();if(!t.skewer.hlssmid)return;t.skewer.hlBoxG.filter((e=>{if(e.mlst){return e.mlst.find((e=>t.skewer.hlssmid.has(e.ssm_id)))}return t.skewer.hlssmid.has(e.ssm_id)})).append("rect").attr("x",(t=>-t.radius)).attr("y",(t=>-t.radius)).attr("width",(t=>t.radius*2)).attr("height",(t=>t.radius*2)).attr("stroke",t.skewer.hlBoxColor).attr("stroke-width",(t=>t.radius>10?1.5:1)).attr("fill","none").attr("class","sja_mds3_skewer_ssmhlbox")}const Re=4;function Oe(t,e,s){Ie(e,t,s);const a=new Map;for(const t of e){if(t.__x==undefined)continue;if(!a.has(t.__x)){a.set(t.__x,[])}a.get(t.__x).push(t)}const n=[];if(s.exonsf>=Re){for(const[t,e]of a){n.push({chr:e[0].chr,pos:e[0].pos,mlst:e,x:t})}}else{if(s.usegm&&s.usegm.coding&&s.gmmode!=x.genomic){const t=new Map;for(const[e,n]of a){if(n[0].chr!=s.usegm.chr){continue}let i=undefined;for(const t of n){if(Number.isFinite(t.aapos))i=t.aapos}if(i==undefined){i=y(n[0].pos,s.usegm).aapos}if(i==undefined){console.error("data item cannot map to aaposition");console.log(n[0]);continue}a.delete(e);if(!t.has(i)){t.set(i,[])}let r=true;for(const e of t.get(i)){if(Math.abs(e[0].__x-n[0].__x)<=s.exonsf*3){for(const t of n){e.push(t)}r=false;break}}if(r){t.get(i).push(n)}}for(const e of t.values()){for(const t of e){let e=null;for(const s of t){if(Number.isFinite(s.rnapos))e=s}if(e==null){console.log("trying to map mlst to codon, but no rnapos found");for(const e of t){console.log(e)}continue}n.push({chr:t[0].chr,pos:e.pos,mlst:t,x:t[0].__x})}}}const t=[];const e=2;for(const[s,n]of a){const a=Math.floor(s/e);if(!t[a]){t[a]=[]}t[a]=[...t[a],...n]}for(const e of t){if(!e)continue;const t=e.reduce(((t,e)=>t+e.__x),0);n.push({isbin:true,chr:e[0].chr,pos:e[0].pos,mlst:e,x:t/e.length})}}n.sort(((t,e)=>t.x-e.x));return n}function Ie(t,e,s){let a=0,n=0;const i=[];const r=[];for(const e of t){delete e.__x;if(s.gmmode==x.protein&&s.usegm.codingstart&&s.usegm.codingstop){if(e.pos<s.usegm.codingstart||e.pos>s.usegm.codingstop){continue}}if(!e.chr){n++;continue}if(!Number.isInteger(e.pos)){a++;continue}const t=s.seekcoord(e.chr,e.pos);if(t.length==0){i.push(e);continue}if(t.length==1){e.__x=t[0].x}else{e.__x=t[0].x}if(e.__x<-1||e.__x>s.width+1){continue}r.push(e)}if(a+n>0){s.tkerror(e,a+n+" items have no chromosome or genomic position")}if(i.length){console.error(i.length+" items not mapped to any region");for(const t of i)console.log(t)}Te(r,e,s)}function Te(t,e,s){for(const e of t){if(s.usegm){const t=y(e.pos,s.usegm);e.rnapos=t.rnapos;e.aapos=t.aapos}if(e.dt==u){continue}if(e.dt==o||e.dt==l){if(e.pairlstIdx==0){e.useNterm=true}else{e.useNterm=false}continue}throw"unknown dt: "+e.dt}}function De(t,e,s,a){if(!e.skewer&&!e.cnv)return;if(!e.leftlabels.doms.variants){e.leftlabels.doms.variants=Qe(e,s,a);e.leftlabels.doms.variants.attr("data-testid","sja_variants_label")}let n,i;if(e.custom_variants){n=e.custom_variants.length}else{n=e.skewer.rawmlst.length+(t.cnv?.length||0)}if(n==0){e.leftlabels.doms.variants.text("No variants").attr("class","").style("opacity",.5).on("click",null);return}i=0;if(e.skewer){const t=e.skewer.viewModes.find((t=>t.inuse));if(t.type=="skewer"){i=e.skewer.data.filter((t=>t.x>=0&&t.x<=s.width)).reduce(((t,e)=>t+e.mlst.length),0)}else if(t.type=="numeric"){i=t.data.filter((t=>t.x>=0&&t.x<=s.width)).reduce(((t,e)=>t+e.mlst.length),0)}else{throw"unknown mode type"}}if(t.cnv)i+=t.cnv.length;if(i==0){e.leftlabels.doms.variants.text("0 out of "+n+" variant"+(n>1?"s":"")).attr("class","").style("opacity",.5).on("click",null);return}e.leftlabels.doms.variants.style("opacity",1).attr("class","sja_clbtext2").text(i<n?i+" of "+n+" variants":i+" variant"+(i>1?"s":"")).on("click",(t=>{e.menutip.clear().showunder(t.target);Fe(e,s)}));return}function Fe(t,e){t.menutip.d.append("div").text("List").attr("class","sja_menuoption").attr("data-testid","sja_list_menuoption").style("border-radius","0px").on("click",(()=>{Be(t,e)}));if(t.skewer){if(t.skewer.hlssmid){t.menutip.d.append("div").text("Cancel highlight").style("border-radius","0px").attr("class","sja_menuoption").on("click",(()=>{delete t.skewer.hlssmid;t.skewer.hlBoxG.selectAll("*").remove();const s=t.skewer.viewModes.find((t=>t.inuse));if(s.type=="skewer"){Se(t,e)}else if(s.type=="numeric");else{throw"unknown mode type"}t.menutip.hide()}))}const s=t.skewer.viewModes.find((t=>t.inuse));if(s.type=="skewer"){const a=t.skewer.data.reduce(((t,e)=>t+e.showmode),0);if(a>0){t.menutip.d.append("div").text("Collapse").attr("class","sja_menuoption").attr("data-testid","sja_collapse_menuoption").style("border-radius","0px").on("click",(()=>{Le(t.skewer.data,t);t.menutip.hide()}))}else if(a==0){t.menutip.d.append("div").text("Expand").attr("class","sja_menuoption").attr("data-testid","sja_expand_menuoption").style("border-radius","0px").on("click",(()=>{Se(t,e);t.menutip.hide()}))}t.menutip.d.append("div").text(t.skewer.pointup?"Point down":"Point up").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{t.skewer.pointup=!t.skewer.pointup;t.load();t.menutip.hide()}));if(t.filterObj){let r=false;const o=t.menutip.d.append("div").text("Change variant shape").style("vertical-align","middle").attr("class","sja_menuoption").on("click",(()=>{if(r==false){r=true;n({holder:o.append("div").style("margin-top","10px"),callbacks:{onShapeClick:i},tk:t})}}))}function n(t){const e={filledCircle:T.filledCircle,emptyCircle:T.emptyCircle,filledVerticalRectangle:T.filledVerticalRectangle,emptyVerticalRectangle:T.emptyVerticalRectangle,filledTriangle:T.filledTriangle,emptyTriangle:T.emptyTriangle,filledSquare:T.filledSquare,emptySquare:T.emptySquare};const{holder:s,callbacks:a,tk:n}=t;if(!n.skewer.shape)n.skewer.shape=Object.entries(e)[0];delete e[n.skewer?.shape?.[0]];const i=s.append("div");i.append("div").style("display","flex").style("flex-direction","row").style("align-items","center").style("justify-content","center").style("border","none").style("width","100%").style("font-size","20px").style("margin-top","5px");const r=i.append("div").style("display","flex").style("flex-wrap","wrap").style("width","max-content");for(const t of Object.entries(e)){const e=r.append("div").style("padding","0px 2px");const s=18;const i=18;const o=e.append("svg").attr("width",s).attr("height",i).attr("viewBox",`0 0 ${s} ${i}`).style("cursor","pointer").on("click",(()=>{if(a&&typeof a.onShapeClick==="function"){a.onShapeClick(t,n)}}));o.append("path").attr("d",t[1].path).attr("fill",t[1].isFilled?"black":"none").attr("stroke","black")}}function i(t,e){e.skewer.shape=t;e.load();e.menutip.hide()}}else if(s.type=="numeric"){t.menutip.d.append("div").text(t.skewer.hideDotLabels?"Show all variant labels":"Hide all variant labels").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{t.skewer.hideDotLabels=!t.skewer.hideDotLabels;t.load();t.menutip.hide()}))}}if(!t.custom_variants){t.menutip.d.append("div").text("Download").attr("class","sja_menuoption").attr("data-testid","sjpp_mds3tk_variantdownload_menuoption").style("border-radius","0px").on("click",(()=>{Ge(t,e);t.menutip.hide()}))}Ue(t,e)}async function Be(t,a){t.menutip.clear();const n=new Map;if(t.skewer){const e=t.skewer.viewModes.find((t=>t.inuse));let s;if(e.type=="skewer"){s=t.skewer.data.filter((t=>t.x>=0&&t.x<=a.width))}else if(e.type=="numeric"){s=e.data}else{throw"unknown mode type"}for(const t of s){for(const e of t.mlst){if(!n.has(e.dt))n.set(e.dt,[]);n.get(e.dt).push(e)}}}if(t.cnv?.cnvLst){n.set(s,t.cnv.cnvLst)}if(n.size==1){const e=t.menutip.d.append("div").style("margin","10px");await Dt({div:e,mlst:n.get([...n.keys()][0]),tk:t,block:a,doNotListSample4multim:true});return}const i=[];for(const[t,s]of n){i.push({label:s.length+" "+e[t]})}new F({holder:t.menutip.d.append("div").attr("class","sja_pp_vlb_dttabdiv").style("margin","10px"),tabs:i}).main();let r=0;for(const[e,s]of n){Dt({div:i[r++].contentHolder.append("div").style("margin-left","10px"),mlst:s,tk:t,block:a,doNotListSample4multim:true})}}function Ue(t,e){if(!t.skewer)return;if(t.skewer.viewModes.length<=1){return}const s=[];for(const[e,a]of t.skewer.viewModes.entries()){const t={label:Pe(a),value:e};if(a.inuse)t.checked=true;s.push(t)}B({holder:t.menutip.d.append("div").attr("class","sja_pp_vlb_viewmoderadiodiv").style("margin","10px"),options:s,callback:async s=>{for(const e of t.skewer.viewModes)e.inuse=false;t.skewer.viewModes[s].inuse=true;bs({skewer:t.skewer.rawmlst},t,e);Ke(t,e);t._finish()}})}function Pe(t){if(!t)return"MISSING!!";if(t.type=="skewer")return"As lollipops";if(t.type=="numeric")return t.label+" as Y axis";return"unknown mode"}async function Ge(t,e){if(!t.mds.variant2samples){console.log("TODO: variant-only");return}const s={querytype:"samples"};Rs(t,e,s);const a=(await t.mds.variant2samples.get(s)).samples;const[n,r]=await oe(a,t);const c=[];for(const t of n){if(t.isSsm){c.push("AAchange");c.push("Consequence");c.push("Mutation");continue}if(t.isMaf){c.push("Alternative allele depth in tumor");c.push("Total depth in tumor");continue}c.push(t.label)}const d=[];for(const[e,s]of a.entries()){let a;if(Array.isArray(s.ssm_id_lst)){a=s.ssm_id_lst}else if(s.ssm_id){a=[s.ssm_id]}else{console.log("sample obj lacks ssm_id and ssm_id_lst");continue}for(const s of a){const a=t.skewer.rawmlst.find((t=>t.ssm_id==s));if(!a){console.log("ssm not found by id: "+s);continue}const c=[];for(const[t,d]of n.entries()){if(d.isSsm){if(a.dt==u){c.push(a.mname);c.push(i[a.class].label);c.push(a.chr+":"+(a.pos+1)+" "+a.ref+">"+a.alt)}else if(a.dt==o||a.dt==l){c.push("");c.push(i[a.class].label);c.push(a.pairlst[0].a.chr+":"+a.pairlst[0].a.pos+">"+a.pairlst[0].b.chr+":"+a.pairlst[0].b.pos)}continue}const n=r[e][t];if(n.bySsmid){if(s in n.bySsmid){const t=n.bySsmid[s];if(d.isMaf){c.push(t.altTumor);c.push(t.totalTumor)}else{c.push(t)}}else{c.push("")}continue}if(d.isMaf){c.push(n.altTumor);c.push(n.totalTumor);continue}c.push(n.value)}d.push(c.join("\t"))}}D(ce(e)+" "+(new Date).toLocaleDateString()+".txt",c.join("\t")+"\n"+d.join("\n"))}const Ve=5;const Ee="Arial";async function He(t,e,s){let a=0;De(t,e,s,a);if(e.leftlabels.doms.variants){a+=Ve+s.labelfontsize}if("sampleTotalNumber"in t||e.leftlabels.doms.samples){const n=await import("./leftlabel.sample-784c5aeb.js");n.makeSampleLabel(t,e,s,a);a+=Ve+s.labelfontsize;if(e.filterObj){n.makeSampleFilterLabel(t,e,s,a)}if(e.leftlabels.doms.filterObj){a+=Ve+s.labelfontsize}}if(e.showCloseLeftlabel){if(!e.leftlabels.doms.close){e.leftlabels.doms.close=Qe(e,s,a).text("Close").on("click",(()=>{for(const[t,a]of s.tklst.entries()){if(a.tkid==e.tkid){s.tk_remove(t)}}}))}a+=Ve+s.labelfontsize}e.leftlabels.laby=a;Ke(e,s);We(e);e.subtk2height.leftlabels=a+20}function We(t){t.leftlabels.maxwidth=t.tklabel.node().getBBox().width;for(const e in t.leftlabels.doms){t.leftlabels.maxwidth=Math.max(t.leftlabels.maxwidth,t.leftlabels.doms[e].node().getBBox().width)}}function Ke(t,e){if(t.leftlabels.laby==0){return}t.leftlabels.xoff=0;if(t.skewer){const s=t.skewer.viewModes.find((t=>t.inuse));if(s.type=="numeric"){const a=t.leftlabels.laby+Ve+e.labelfontsize;if(a>s.toplabelheight+5){t.leftlabels.xoff=s.axisWidth}}}t.leftlabels.g.transition().attr("transform",`translate(-${t.leftlabels.xoff},${Ve+e.labelfontsize})`)}function Qe(t,e,s){return t.leftlabels.g.append("text").attr("font-size",e.labelfontsize).attr("font-family",Ee).attr("y",e.labelfontsize/2+s).attr("text-anchor","end").attr("dominant-baseline","central").attr("class","sja_clbtext2").attr("fill","black").attr("x",e.tkleftlabel_xshift)}const Xe="Arial";const Je=1;const Ye=.3;const Ze=5;const ts=7;const es=100;const ss="#ededed";const as="Numeric value";function ns(t,e,s,a){const n=Oe(s,e.skewer||s.skewer.rawmlst,a).filter((t=>t.x>=0&&t.x<=a.width));t.data=n;if(!t.axisg)t.axisg=s.gleft.append("g");if(!t.axisheight)t.axisheight=150;is(s);rs(t,s,a);gs(s);return t.toplabelheight+t.maxradius+t.axisheight+t.maxradius+t.stem1+t.stem2+t.stem3+t.bottomlabelheight}function is(t){t.skewer.g.selectAll("*").remove();if(t.skewer.nmg)t.skewer.nmg.selectAll("*").remove()}function rs(t,e,s){if(!t.axisSetting){t.axisSetting={auto:1}}const a=t.data;for(const t of a){t.x0=t.x;if(t.xoffset!=undefined){t.x=t.x0+t.xoffset}}const n=Math.max(14,s.width/110);t.dotwidth=n;t.maxradius=0;for(const e of a){for(const s of e.mlst){s.radius=n/2;t.maxradius=Math.max(s.radius,t.maxradius);s.rimwidth=0;s.aa=e}}const i=os(a,t,e,s);ps(a,t);const r=d().domain([t.minvalue,t.maxvalue]).range([0,t.axisheight]);for(const e of a){for(const s of e.mlst){if(s.__value_missing){s._y=0}else{if(s.__value_use<t.minvalue){s._y=0}else if(s.__value_use>t.maxvalue){s._y=t.axisheight}else{s._y=r(s.__value_use)}}}}if(i){t.stem1=5;t.stem2=20;t.stem3=10}else{t.stem1=0;t.stem2=0;t.stem3=0}for(const t of a){for(const s of t.mlst){e.glider.append("text").text(e.mnamegetter(s)).attr("font-family",Xe).attr("font-size",s.radius*2-2).each((function(){s.labwidth=this.getBBox().width})).remove()}}for(const t of a){for(const e of t.mlst){delete e.labattop;delete e.labatbottom}}if(!e.skewer.hideDotLabels){if(i){for(const t of a){if(t.mlst.length==1){const e=t.mlst[0];e.labattop=true}else{if((t.width-t.fixedgew)/(t.mlst.length-1)<ts);else{for(const e of t.mlst){e.labattop=true}}}}}else{cs(a)}}t.toplabelheight=0;t.bottomlabelheight=0;if(t.showsamplebar||t.showgenotypebyvalue){for(const e of a){for(const s of e.mlst){t.toplabelheight=Math.max(t.toplabelheight,s.labwidth)}}}else{for(const e of a){for(const s of e.mlst){if(s.labattop){t.toplabelheight=Math.max(t.toplabelheight,s._y+s.labwidth-t.axisheight)}else if(s.labatbottom){t.bottomlabelheight=Math.max(t.bottomlabelheight,s.labwidth-s._y)}}}}{let a=s.labelfontsize+Ze+s.labelfontsize;if(e.label_stratify){a+=e.label_stratify.length*(Ze+s.labelfontsize)}t.toplabelheight=Math.max(t.toplabelheight,a)}us(e,t,s);e.skewer.g.append("line").attr("y1",t.toplabelheight+t.maxradius).attr("y2",t.toplabelheight+t.maxradius).attr("x2",s.width).attr("stroke",ss).attr("shape-rendering","crispEdges");e.skewer.g.append("line").attr("y1",t.toplabelheight+t.maxradius+t.axisheight).attr("y2",t.toplabelheight+t.maxradius+t.axisheight).attr("x2",s.width).attr("stroke",ss).attr("shape-rendering","crispEdges");e.skewer.nmg=e.skewer.g.selectAll().data(a).enter().append("g").attr("class","sja_skg2").each((function(t){t.g=this}));e.skewer.nmg.attr("transform",(e=>"translate("+e.x+","+(t.toplabelheight+Je+t.maxradius+t.axisheight+t.maxradius)+")"));if(i){e.skewer.nmg.append("path").attr("class","sja_aa_stem").attr("d",(e=>ds(e,t))).attr("stroke",(t=>e.color4disc(t.mlst[0]))).attr("fill",(t=>t.mlst.length==1?"none":ss))}const o=e.skewer.nmg.selectAll().data((t=>t.mlst)).enter().append("g").attr("class","sja_aa_discg").each((function(t){t.g=this}));o.attr("transform",(e=>"translate("+e.xoff+","+(e._y+t.maxradius)*-1+")"));o.filter((t=>t.shapeTriangle)).append("path").attr("d",(t=>hs(t.radius))).attr("fill",(t=>e.color4disc(t))).attr("stroke","white").attr("class","sja_aa_disk_fill");o.filter((t=>t.shapeCircle)).append("circle").attr("stroke",(t=>e.color4disc(t))).attr("fill","none").attr("r",(t=>t.radius-.5)).attr("class","sja_aa_disk_fill");o.filter((t=>!t.shapeTriangle&&!t.shapeCircle)).append("circle").attr("fill",(t=>e.color4disc(t))).attr("stroke","white").attr("r",(t=>t.radius-.5)).attr("class","sja_aa_disk_fill");e.skewer.hlBoxG=o.append("g");o.filter((t=>t.shapeTriangle)).append("path").attr("d",(t=>hs(t.radius))).attr("stroke",(t=>e.color4disc(t))).attr("fill","white").attr("class","sja_aa_disckick").attr("fill-opacity",0).attr("stroke-opacity",0).on("mousedown",(t=>{t.preventDefault()})).on("mouseover",((s,a)=>{fs(a,t,e)})).on("mouseout",((t,s)=>{ms(s,e)})).on("click",((t,a)=>{fe({mlst:[a]},e,s,t.target.getBoundingClientRect(),t.target)}));o.filter((t=>!t.shapeTriangle)).append("circle").attr("r",(t=>t.radius-.5)).attr("stroke",(t=>e.color4disc(t))).attr("class","sja_aa_disckick").attr("fill","white").attr("fill-opacity",0).attr("stroke-opacity",0).on("mousedown",(t=>{t.preventDefault()})).on("mouseover",((s,a)=>{fs(a,t,e)})).on("mouseout",((t,s)=>{ms(s,e)})).on("click",((t,a)=>{fe({mlst:[a]},e,s,t.target.getBoundingClientRect(),t.target)}));o.filter((t=>t.labattop||t.labatbottom)).append("text").each((function(t){t.__svg_textlabel=this})).text((t=>e.mnamegetter(t))).attr("font-family",Xe).attr("font-size",(t=>{t._labfontsize=Math.max(12,t.radius*1.2);return t._labfontsize})).attr("fill",(t=>e.color4disc(t))).attr("x",(e=>t.showsamplebar||t.showgenotypebyvalue?t.axisheight+t.maxradius+4:e.radius+e.rimwidth+Je)).attr("y",(t=>t._labfontsize*Ye)).attr("class","sja_aa_disclabel").attr("transform",(t=>"rotate("+(t.labattop?"-":"")+"90)")).on("mousedown",(t=>{t.preventDefault()})).on("mouseover",((s,a)=>fs(a,t,e))).on("mouseout",((t,s)=>ms(s,e))).on("click",((t,a)=>{fe({mlst:[a]},e,s,t.target.getBoundingClientRect(),t.target.previousSibling)}))}function os(t,e,s,a){let n=0;for(const e of t){let t=0;for(const s of e.mlst){t+=2*(s.radius+s.rimwidth)}if(e.mlst.length==1){e.width=t}else{e.width=Math.min(es,t);const s=e.mlst[0];const a=e.mlst[e.mlst.length-1];e.fixedgew=s.radius+s.rimwidth+a.radius+a.rimwidth}n+=e.width}if(n<=a.width){let e=0;for(const s of t){s.x=e+s.mlst[0].radius+s.mlst[0].rimwidth;e+=s.width;if(s.mlst.length==1){s.stemw=0}else{s.stemw=s.width-s.fixedgew}}ls(t,a.width);for(const e of t){e.xoffset=e.x-e.x0;if(e.mlst.length==1){e.mlst[0].xoff=0;e.stemw=0}else{e.stemw=e.width-e.fixedgew;const t=e.stemw/(e.mlst.length-1);for(let s=0;s<e.mlst.length;s++){e.mlst[s].xoff=t*s}}}return true}for(const e of t){e.x=e.x0;e.xoffset=0;for(const t of e.mlst){t.xoff=0}}return false}function ls(t,e){for(let s=0;s<t.length;s++){if(t[s].x0<0)continue;if(t[s].x0>e)break;while(1){let a=0,n=0;for(let i=s;i<t.length;i++){const s=t[i];if(s.x0>e){return}a+=Math.abs(s.x-s.x0-s.stemw/2);s.x++;n+=Math.abs(s.x-s.x0-s.stemw/2)}if(t[s].x>t[s].x0-t[s].stemw/2){for(let e=s;e<t.length;e++){t[e].x--}break}const i=t[t.length-1];if(i.x+i.width/2>=e){return}if(n<=a);else{for(let a=s;a<t.length;a++){if(t[a].x0>e){break}t[a].x--}break}}}}function cs(t){const e=[];for(const s of t){for(const t of s.mlst){e.push({m:t,w:2*(t.radius+t.rimwidth),x:s.x0,y:t._y})}}e.sort(((t,e)=>e.y-t.y));for(let t=0;t<e.length;t++){const s=e[t];let a=false;for(let n=0;n<t;n++){const t=e[n];if(Math.abs(s.x-t.x)<(s.w+t.w)/2-2){a=true;break}}if(!a){s.m.labattop=true}}for(let t=e.length-1;t>=0;t--){const s=e[t];if(s.m.labattop)continue;let a=false;for(let n=e.length-1;n>t;n--){const t=e[n];if(t.m.labatbottom&&Math.abs(t.x-s.x)<(t.w+s.w)/2-2){a=true;break}}if(!a){s.m.labatbottom=true}}}function ds(t,e){if(t.mlst.length==1){return"M0,0v"+e.stem1+"l"+-t.xoffset+","+e.stem2+"v"+e.stem3}return"M0,0"+"v"+e.stem1+"l"+-t.xoffset+","+e.stem2+"v"+e.stem3+"v-"+e.stem3+"l"+(t.stemw+t.xoffset-1)+",-"+e.stem2+"v-"+e.stem1}function fs(t,e,s){if(t.__svg_textlabel){k(t.__svg_textlabel).attr("font-size",t._labfontsize*1.1)}s.pica.g.attr("transform","translate("+(t.aa.x+t.xoff)+","+(e.toplabelheight+e.maxradius+e.axisheight-t._y)+")");const a=10;const n=4;const i=t._labfontsize||13;const r=s.color4disc(t);const o=[];if(e.tooltipPrintValue){const s=e.tooltipPrintValue(t);if(Array.isArray(s)){o.push(...s.map((t=>`${t.k} = ${t.v}`)))}}else{o.push(e.label+" = "+(t.__value_missing?"NA":t.__value_use))}if(s.mds.queries?.ld?.mOverlay?.data){if(t.ssm_id==s.mds.queries.ld.mOverlay.m.ssm_id);else{let e="?";for(const a of s.mds.queries.ld.mOverlay.data){if(a.pos==t.pos&&a.alleles==t.ref+"."+t.alt){e=a.r2;break}}o.push("r2 = "+e)}}if(!t.labattop&&!t.labatbottom){o.push(s.mnamegetter(t))}let l=0;for(const t of o){s.pica.g.append("text").attr("font-size",i).attr("font-family",Xe).text(t).each((function(){l=Math.max(l,this.getBBox().width)})).remove()}const c=n*2+l;let d,f,m=true;if(c+a>t.aa.x+t.xoff){m=false;f=t.radius+t.rimwidth;d=f+a}else{f=-t.radius-t.rimwidth-a;d=f-c}const p=i*o.length;s.pica.g.append("rect").attr("x",d-2).attr("y",-2-n-p/2).attr("width",4+c).attr("height",4+n*2+p).attr("fill","white");s.pica.g.append("line").attr("x1",f).attr("x2",f+a).attr("stroke","white").attr("stroke-width",3).attr("shape-rendering","crispEdges");s.pica.g.append("line").attr("x1",f).attr("x2",f+a).attr("stroke",r).attr("shape-rendering","crispEdges");s.pica.g.append("rect").attr("x",d).attr("y",-n-p/2).attr("width",c).attr("height",n*2+p).attr("fill","none").attr("stroke",r).attr("shape-rendering","crispEdges");let u=(i-p)/2;for(const t of o){s.pica.g.append("text").text(t).attr("text-anchor",m?"end":"start").attr("font-size",i).attr("font-family",Xe).attr("x",m?f-n:d+n).attr("y",u).attr("fill",r).attr("dominant-baseline","central");u+=i}}function ms(t,e){if(t.__svg_textlabel){k(t.__svg_textlabel).attr("font-size",t._labfontsize)}e.pica.g.selectAll("*").remove()}function ps(t,e,s){for(const e of t){for(const t of e.mlst){delete t.__value_use;delete t.__value_missing}}if(e.byAttribute){for(const s of t){for(const t of s.mlst){const s=t[e.byAttribute];if(Number.isFinite(s)){t.__value_use=s}else{t.__value_missing=true}}}}else if(e.byInfo){for(const s of t){for(const t of s.mlst){const s=t?.info?.[e.byInfo];if(Number.isFinite(s)){t.__value_use=s}else{t.__value_missing=true}}}}else{throw"unknown method of getting value"}if(e.axisSetting.auto){e.minvalue=null;e.maxvalue=null;for(const s of t){for(const t of s.mlst){if("__value_use"in t){if(e.minvalue==null){e.minvalue=t.__value_use;e.maxvalue=t.__value_use}else{e.minvalue=Math.min(e.minvalue,t.__value_use);e.maxvalue=Math.max(e.maxvalue,t.__value_use)}}}}}else if(e.axisSetting.fixed){e.minvalue=e.axisSetting.fixed.min;e.maxvalue=e.axisSetting.fixed.max}else{throw"unknown axisSetting"}}function us(t,e,s){e.axisg.attr("transform","translate(0,"+(e.toplabelheight+e.maxradius)+")").selectAll("*").remove();const a=d().domain([e.minvalue,e.maxvalue]).range([e.axisheight,0]);const n=N().scale(a).ticks(4);if(e.isinteger){n.tickFormat(v("d"));if(e.maxvalue-e.minvalue<3){n.ticks(e.maxvalue-e.minvalue)}}$({axis:e.axisg.call(n),showline:true,fontsize:e.dotwidth});e.axisWidth=0;e.axisg.selectAll("text").each((function(){e.axisWidth=Math.max(e.axisWidth,this.getBBox().width)}));e.axisWidth+=15;let i;e.axisg.append("text").attr("fill","black").attr("font-size",e.dotwidth).attr("dominant-baseline","central").attr("text-anchor","end").attr("class","sjpp-mds3-nm-axislabel sja_clbtext2").attr("y",e.axisheight/2).attr("x",-e.axisWidth).text(e.label||as).each((function(){i=this.getBBox().width})).on("click",(a=>{t.menutip.clear().showunder(a.target).d.append("div").text("Cancel").attr("class","sja_menuoption").style("border-radius","0px").on("click",(()=>{t.menutip.hide();e.inuse=false;t.skewer.viewModes.find((t=>t.type=="skewer")).inuse=true;bs({skewer:t.skewer.rawmlst},t,s);Ke(t,s);t._finish()}));I({holder:t.menutip.d.append("div").style("margin","10px"),noPercentile:true,callback:a=>{e.axisSetting=a;is(t);rs(e,t,s)},setting:e.axisSetting})}));t.skewer.maxwidth=e.axisWidth+i}function hs(t){return`M 0 -${t} L ${t} ${t*.7} h -${t*2} Z`}function gs(t){const e=t.mds.queries?.ld?.mOverlay?.m;if(!e)return;t.skewer.hlssmid=new Set([e.ssm_id]);Ne(t)}const ws=10;function bs(t,e,s){if(!e.skewer){e.subtk2height.skewer=0;return}e.skewer.maxwidth=0;_s(e,t.skewer);ks(e,t.skewer);const a=e.skewer.viewModes.find((t=>t.inuse));if(!a)throw"no mode!!";if(t.skewer){e.skewer.rawmlst=t.skewer}if(a.type=="numeric"){e.subtk2height.skewer=ns(a,t,e,s);Ne(e);return}if(a.type!="skewer")throw'mode.type is not "skewer"';if(t&&!t.skewer&&s.usegm&&s.gmmode!="genomic"&&s.pannedpx!=undefined){xs(e,s);e.skewer.selection.attr("transform",(t=>"translate("+t.x+","+t.y+")"));Se(e,s)}else{e.skewer.g.selectAll("*").remove();e.skewer.data=ys(e,s);je(e,s)}if(!e.skewer.data||e.skewer.data.length==0){e.subtk2height.skewer=0;e.skewer.g.selectAll("*").remove();return}if(e.skewer.hlssmid){const t=[];const a=[];for(const s of e.skewer.data){let n=false;for(const t of s.groups){for(const s of t.mlst){if(e.skewer.hlssmid.has(s.ssm_id)){n=true;break}}}if(n){a.push(s)}else{t.push(s)}}Le(t,e);Ce(a,e,s);Ne(e)}else{Se(e,s)}e.subtk2height.skewer=e.skewer.maxheight+e.skewer.stem1+e.skewer.stem2+e.skewer.stem3}function ks(t,e){if(!t.hlaachange||!e)return;const s=new Set(t.hlaachange.split(","));delete t.hlaachange;t.skewer.hlssmid=new Set;for(const a of e){if(s.has(a.mname))t.skewer.hlssmid.add(a.ssm_id)}}function xs(t,e){for(const s of t.skewer.data){if(s.isbin){let t=0;for(const a of s.mlst){const s=e.seekcoord(a.chr,a.pos);if(a.usehitidx!=undefined&&s[a.usehitidx]){t+=s[a.usehitidx].x}else if(s.length==1){t+=s[0].x}else{console.log("cannot map item");console.log(a)}}s.x0=t/s.mlst.length;s.x=s.x0+(s.xoffset!=undefined?s.xoffset:0)}else{const t=e.seekcoord(s.chr,s.pos);if(t.length>0){s.x0=t[0].x;s.x=s.x0+(s.xoffset!=undefined?s.xoffset:0)}else{console.log("cannot map group of item");console.log(s)}}}}function ys(t,e){const s=Oe(t,t.skewer.rawmlst,e);for(const t of s){t.groups=vs(t.mlst)}if(t.skewer.data&&e.pannedpx!=undefined){const e={};for(const s of t.skewer.data){e[s.chr+"."+s.pos]={mode:s.showmode,xoffset:s.xoffset,slabelrotate:s.slabelrotate}}for(const t of s){const s=t.chr+"."+t.pos;if(e[s]){t.showmode=e[s].mode;t.xoffset=e[s].xoffset;t.slabelrotate=e[s].slabelrotate}}}for(const t of s){t.occurrence=t.groups.reduce(((t,e)=>t+e.occurrence),0)}return s}function vs(t,e){const s=new Map;for(const e of t){if(!Number.isInteger(e.dt))continue;if(!s.has(e.dt))s.set(e.dt,new Map);switch(e.dt){case u:if(!s.get(e.dt).has(e.class))s.get(e.dt).set(e.class,new Map);const t=e.mname||"";if(!s.get(e.dt).get(e.class).has(t)){s.get(e.dt).get(e.class).set(t,[])}s.get(e.dt).get(e.class).get(t).push(e);break;case o:case l:if(!s.get(e.dt).has(e.class)){s.get(e.dt).set(e.class,{use5:new Map,use3:new Map})}if(e.useNterm){if(!s.get(e.dt).get(e.class).use5.has(e.mname)){s.get(e.dt).get(e.class).use5.set(e.mname,[])}s.get(e.dt).get(e.class).use5.get(e.mname).push(e)}else{if(!s.get(e.dt).get(e.class).use3.has(e.mname)){s.get(e.dt).get(e.class).use3.set(e.mname,[])}s.get(e.dt).get(e.class).use3.get(e.mname).push(e)}break;case n:case A:case j:case _:if(!s.has(e.dt)){s.set(e.dt,[])}s.get(e.dt).push(e);break;default:console.log("unknown datatype: "+e.dt);console.log(e);return}}const a=[];for(const[t,e]of s){switch(t){case u:for(const[s,n]of e){if(n.size>ws){const e=[];for(const t of n.values())e.push(...t);a.push({dt:t,mlst:e,mnameCompact:i[s].label})}else{for(const e of n.values()){a.push({dt:t,mlst:e})}}}break;case o:case l:for(const s of e.values()){if(s.use5.size>ws){const e=[];for(const t of s.use5.values())e.push(...t);a.push({dt:t,mlst:e,useNterm:true,mnameCompact:t==o?"SV":"fusion"})}else{for(const e of s.use5.values()){a.push({dt:t,mlst:e,useNterm:true})}}if(s.use3.size>ws){const e=[];for(const t of s.use3.values())e.push(...t);a.push({dt:t,mlst:e,useNterm:false,mnameCompact:t==o?"SV":"fusion"})}else{for(const e of s.use3.values()){a.push({dt:t,mlst:e,useNterm:false})}}}break;case n:case A:case j:case _:a.push({dt:t,mlst:e})}}for(const t of a){let e=0,s=0;for(const a of t.mlst){e+=a.rim1count||0;s+=a.rim2count||0}t.rim1count=e;t.rim2count=s}if(t.some((t=>Number.isFinite(t.occurrence)))){for(const t of a)t.occurrence=t.mlst.reduce(((t,e)=>t+e.occurrence),0)}else{for(const t of a)t.occurrence=t.mlst.length}a.sort(((t,e)=>e.occurrence-t.occurrence));return a}function _s(t,e){js(t,e);for(const e of t.skewer.viewModes){if(e.type=="numeric"&&!e.inuse&&e.axisg){e.axisg.remove();delete e.axisg}}}function js(t,e){if(e&&e.find((t=>Number.isFinite(t.occurrence)))){if(!t.skewer.viewModes.find((t=>t.type=="numeric"&&t.byAttribute=="occurrence"))){t.skewer.viewModes.push({type:"numeric",byAttribute:"occurrence",label:"Occurrence",isinteger:true})}}}function As(t,e,s){e.cnv?.g.selectAll("*").remove();if(!t.cnv){delete e.subtk2height.cnv;return}const[a,n,i]=Ms(t,e,s);e.cnv.cnvLst=n;e.cnv.absoluteMax=i;e.cnv.colorScale=d([-i,0,i],[e.cnv.lossColor,"white",e.cnv.gainColor]).clamp(true);const[r,o]=Cs(a||n);if(a){for(const t of a){for(const a of t.cnvs){qs(a,t.y*(r+o),r,e,s,t)}}}else{for(const t of n){qs(t,t.y*(r+o),r,e,s)}}const l=(a||n).length;e.subtk2height.cnv=l*r+(l-1)*o}function Ms(t,e,s){let a=0;const n=new Map;const i=[];for(const e of t.cnv){if(!e.chr)continue;if(!Number.isFinite(e.value)){if(typeof e.class=="string"){if(e.class==M){e.value=1}else if(e.class==S){e.value=-1}else{continue}}else{continue}}if(!Number.isInteger(e.start)||!Number.isInteger(e.stop))continue;const t=s.seekcoord(e.chr,e.start)[0];if(!t)continue;const r=s.seekcoord(e.chr,e.stop)[0];if(!r)continue;const o=structuredClone(e);if(t.x>r.x){o.x1=r.x;o.x2=t.x}else{o.x1=t.x;o.x2=r.x}a=Math.max(a,Math.abs(e.value));i.push(o);if(Array.isArray(e.samples)){for(const t of e.samples){if(!n.has(t.sample_id))n.set(t.sample_id,[]);n.get(t.sample_id).push(structuredClone(o))}}}let r;if(n.size){r=[];for(const[t,e]of n){e.sort(((t,e)=>t.x1-e.x1));r.push({sample_id:t,cnvs:e,x1:Math.min(...e.map((t=>t.x1))),x2:Math.max(...e.map((t=>t.x2)))})}r.sort(((t,e)=>t.x1-e.x1));for(let t=0;t<r.length;t++)r[t].y=t}else{i.sort(((t,e)=>t.x1-e.x1));zs(i,0)}return[r,i,Math.min(e.cnv.absoluteValueRenderMax,a)]}const Ss=d([40,120],[10,1]);function Cs(t){if(t.length>120)return[1,0];if(t.length<40)return[10,1];return[Math.ceil(Ss(t.length)),1]}function qs(t,e,s,a,n,i){const r=Math.max(0,t.x1),o=Math.min(t.x2,n.width);a.cnv.g.append("rect").attr("x",r).attr("y",e).attr("width",o-r).attr("height",s).attr("fill",a.cnv.colorScale(t.value)).on("mouseover",(e=>{e.target.setAttribute("stroke","black");a.itemtip.clear().show(e.clientX,e.clientY);const s=h({holder:a.itemtip.d});const n=structuredClone(t);if(i){n.samples=[{sample_id:i.sample_id}]}Qt({mlst:[n],tk:a},s)})).on("mouseout",(t=>{t.target.setAttribute("stroke","");a.itemtip.hide()}))}function zs(t,e){const s=[];for(const a of t){for(let t=0;t<s.length;t++){if(s[t]+e<a.x1){s[t]=a.x2;a.y=t;break}}if(!("y"in a)){a.y=s.length;s.push(a.x2)}}}async function $s(t,e){e.tkcloakon(t);e.block_setheight();try{if(!t.mds||t.uninitialized){await ht(t,e)}const s=await Ns(t,e);if(t.uninitialized){t.clear();delete t.uninitialized}bs(s,t,e);As(s,t,e);await He(s,t,e);t._finish(s)}catch(e){if(t.clear)t.clear();if(t.subtk2height)t.subtk2height.skewer=50;if(t._finish)t._finish({error:e.message||e});if(e.stack)console.log(e.stack);return}}function Ls(t,e){const s={genome:e.genome.name,forTrack:1,skewerRim:t.mds.queries?.snvindel?.skewerRim};const a={"Content-Type":"application/json",Accept:"application/json"};if(t.mds.has_skewer){s.skewer=1}if(t.set_id){s.set_id=t.set_id}if(t.filter0){s.filter0=t.filter0}if(t.filterObj){if(t.filterObj?.lst.length){s.filterObj=t.filterObj}}if(t.token){a["X-Auth-Token"]=t.token}if(t.mds.label){s.dslabel=t.mds.label}else{if(t.bcf){if(t.bcf.file){s.bcffile=t.bcf.file}else if(t.bcf.url){s.bcfurl=t.bcf.url;if(t.bcf.indexURL)s.bcfindexURL=t.bcf.indexURL}else{throw".file and .url missing for tk.bcf{}"}}}Rs(t,e,s);if(t.legend.mclass.hiddenvalues.size){s.hiddenmclasslst=[...t.legend.mclass.hiddenvalues].join(",")}if(t.legend.bcfInfo){const e={};for(const s in t.legend.bcfInfo){if(t.legend.bcfInfo[s].hiddenvalues.size){e[s]=[...t.legend.bcfInfo[s].hiddenvalues]}}if(Object.keys(e).length){s.infoFilter=e}}if(t.legend.formatFilter){const e={};for(const s in t.legend.formatFilter){if(t.legend.formatFilter[s].hiddenvalues.size){e[s]=[...t.legend.formatFilter[s].hiddenvalues]}}if(Object.keys(e).length){s.formatFilter=e}}if(t.cnv){if(t.cnv.cnvMaxLength)s.cnvMaxLength=t.cnv.cnvMaxLength;if(t.cnv.cnvGainCutoff)s.cnvGainCutoff=t.cnv.cnvGainCutoff;if(t.cnv.cnvLossCutoff)s.cnvLossCutoff=t.cnv.cnvLossCutoff}return[s,a]}async function Ns(t,e){let s;if(t.custom_variants){s=await Os(t,e)}else{const[a,n]=Ls(t,e);s=await p("mds3",{body:a,headers:n})}if(s.error)throw s.error;return s}function Rs(t,e,s){if(typeof s!="object")throw"par{} is not object";let a=[];if(e.usegm){const t={chr:e.rglst[0].chr,reverse:e.rglst[0].reverse,width:0,start:null,stop:null};for(let s=e.startidx;s<=e.stopidx;s++){const a=e.rglst[s];t.width+=a.width+e.regionspace;t.start=t.start==null?a.start:Math.min(t.start,a.start);t.stop=t.stop==null?a.stop:Math.max(t.stop,a.stop)}a.push(t);if(e.gmmode=="genomic");else{s.isoform=e.usegm.isoform;s.gene=e.usegm.name}}else{a=e.tkarg_rglst(t)}let n=0;for(const t of a){t.xoff=0;n+=t.width+e.regionspace}if(e.subpanels.length==t.subpanels.length){for(const t of e.subpanels){a.push({chr:t.chr,start:t.start,stop:t.stop,width:t.width,exonsf:t.exonsf,xoff:n});n+=t.width+t.leftpad}}s.rglst=a}async function Os(t,e){const a={skewer:[],cnv:[]};let n=null,r;for(let t=e.startidx;t<=e.stopidx;t++){if(n==null){n=e.rglst[t].start;r=e.rglst[t].stop}else{n=Math.min(n,e.rglst[t].start);r=Math.max(r,e.rglst[t].stop)}}const c=new Map;for(const d of t.custom_variants){if(d.dt==s){if(d.chr!=e.rglst[0].chr)continue;if(Math.max(d.start,n)>Math.min(d.stop,r))continue;a.cnv.push(d)}else if(d.dt==u||d.dt==o||d.dt==l){if(d.chr!=e.rglst[0].chr)continue;if(d.pos<=n||d.pos>=r)continue;if(!d.class)d.class="X";if(!i[d.class])d.class="X";if(t.legend.mclass.hiddenvalues.has(d.class))continue;a.skewer.push(d)}else{throw"unknown custom data dt"}c.set(d.class,1+(c.get(d.class)||0))}if(a.cnv.length==0)delete a.cnv;const d=new Set;if(a.skewer?.some((t=>t.samples))){for(const t of a.skewer){if(t.samples){for(const e of t.samples)d.add(e.sample_id)}}}if(a.cnv?.some((t=>t.samples))){for(const t of a.cnv){if(t.samples){for(const e of t.samples)d.add(e.sample_id)}}}if(d.size)a.sampleTotalNumber=d.size;a.mclass2variantcount=[...c];await Is(t,a.skewer);return a}async function Is(t){if(!t.mds.queries?.ld?.mOverlay)return;if(!t.mds.termdb?.vocabApi)return;delete t.mds.queries.ld.mOverlay.data;const e=await t.mds.termdb.vocabApi.getLDdata(t.mds.queries.ld.mOverlay.ldtkname,t.mds.queries.ld.mOverlay.m);if(e.error||!Array.isArray(e.lst))return;t.mds.queries.ld.mOverlay.data=e.lst}var Ts=Object.freeze({__proto__:null,loadTk:$s,rangequery_rglst:Rs});export{ee as d,pt as g,Qe as m,Ts as t};