"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[6310,9870],{6310:(e,t,a)=>{a.r(t),a.d(t,{parseBedBuffer:()=>l,parseBedPEBuffer:()=>m,removeBedHeaders:()=>c});var r=a(59870);const n="browser ".split("").map((e=>e.charCodeAt(0))),s="track ".split("").map((e=>e.charCodeAt(0))),o="#".split("").map((e=>e.charCodeAt(0)));function d(e,t,a){let r=0;for(;r<a.length;r+=1)if(t[e+r]!==a[r])return!1;return!0}function c(e){let t=0;for(;t<e.length&&(d(t,e,n)||d(t,e,s)||d(t,e,o));t+=1)do{t+=1}while(10!==e[t]);return t?e.subarray(t):e}async function l(e,t){const a=c(e),n=await(0,r.parseTsvBuffer)(a),s=[{name:"chrom",dataType:{type:"LocRef"}},{name:"chromStart",dataType:{type:"LocStart"}},{name:"chromEnd",dataType:{type:"LocEnd"}},{name:"name",dataType:{type:"Text"}},{name:"score",dataType:{type:"Number"}},{name:"strand",dataType:{type:"Text"}}];return n.columns.forEach(((e,t)=>{const a=s[t];a&&(e.name=a.name,e.dataType=a.dataType)})),n.hasColumnNames=!0,n.assemblyName=t.selectedAssemblyName,n.columnDisplayOrder.push(n.columnDisplayOrder.length),n.columns.unshift({name:"Location",dataType:{type:"LocString"},isDerived:!0,derivationFunctionText:"jexl:{text:row.cells[0].text+':'+row.cells[1].text+'..'+row.cells[2].text,\n\n    extendedData: {refName: row.cells.ref.text, start: parseInt(row.cells.start.text,10), end: parseInt(row.cells.end.text,10)}}"}),n}async function m(e,t){const a=c(e),n=await(0,r.parseTsvBuffer)(a),s=[{name:"chrom1",dataType:{type:"Text"},featureField:["refName"]},{name:"start1",dataType:{type:"Number"},featureField:["start"]},{name:"end1",dataType:{type:"Number"},featureField:["end"]},{name:"chrom2",dataType:{type:"Text"},featureField:["mate","refName"]},{name:"start2",dataType:{type:"Number"},featureField:["mate","start"]},{name:"end2",dataType:{type:"Number"},featureField:["mate","end"]},{name:"name",dataType:{type:"Text"},featureField:["name"]},{name:"score",dataType:{type:"Number"},featureField:["score"]},{name:"strand1",dataType:{type:"Text"},featureField:["strand"]},{name:"strand2",dataType:{type:"Text"},featureField:["mate","strand"]}];return n.columns.forEach(((e,t)=>{const a=s[t];a&&(e.name=a.name,e.dataType=a.dataType)})),n.hasColumnNames=!0,n.rowSet.rows.forEach(((e,t)=>{const a={};e.cells.forEach((({text:e},t)=>{const r=s[t],n=r&&"Number"===r.dataType.type&&e?Number.parseFloat(e):e;r?2===r.featureField.length?(a[r.featureField[0]]||(a[r.featureField[0]]={}),a[r.featureField[0]][r.featureField[1]]=n):a[r.featureField[0]]=n:a[`column${t+1}`]=n})),a.uniqueId=`bedpe-${t}`,e.extendedData={feature:a}})),n.assemblyName=t.selectedAssemblyName,n}},59870:(e,t,a)=>{a.r(t),a.d(t,{bufferToString:()=>n,parseCsvBuffer:()=>c,parseTsvBuffer:()=>l});var r=a(99546);function n(e){return new TextDecoder("utf8",{fatal:!0}).decode(e)}async function s(e,t={}){return(await a.e(2847).then(a.t.bind(a,82847,23)).then((e=>e.default)))({noheader:!0,output:"csv",...t}).fromString(n(e))}function o(e,t,a){const n=e.rows[0].cells[t].text||"";let s,o="Text";try{s=(0,r.parseLocString)(n,a)}catch(e){}return s?.refName&&"number"==typeof s.start?o="LocString":/^\d+(\.\d+)?$/.test(n)&&(o="Number"),o}function d(e,t={}){const{hasColumnNameLine:a=!1,columnNameLineNumber:n=1,isValidRefName:s=()=>!1,selectedAssemblyName:d}=t;let c=0;const l={isLoaded:!0,rows:e.map(((e,t)=>{const r=t+(a?0:1);return e.length>c&&(c=e.length),{id:String(r),cells:e.map(((e,t)=>({columnNumber:t,text:e})))}}))},m={};if(a&&void 0!==n){const[e]=l.rows.splice(n-1,1);e&&e.cells.forEach(((e,t)=>{m[t]=e.text||""}))}const u=[],p=[];for(let e=0;e<c;e+=1){p.push(e);const t=o(l,e,s);if("LocString"===t)for(const t of l.rows){const a=t.cells[e];a.extendedData=(0,r.parseLocString)(a.text,s)}u[e]={name:m[e],dataType:{type:t}}}return{rowSet:l,columnDisplayOrder:p,hasColumnNames:!!a,columns:u,assemblyName:d}}async function c(e,t){return d(await s(e),t)}async function l(e,t){return d(await s(e,{delimiter:"\t"}),t)}}}]);
//# sourceMappingURL=6310.ae82dc58.chunk.js.map