"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[5696,3285],{5696:(e,t,a)=>{a.r(t),a.d(t,{parseBedBuffer:()=>l,parseBedPEBuffer:()=>m,removeBedHeaders:()=>d});var r=a(23285);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 c(e,t,a){let r=0;for(;r<a.length;r+=1)if(t[e+r]!==a[r])return!1;return!0}function d(e){let t=0;for(;t<e.length&&(c(t,e,n)||c(t,e,s)||c(t,e,o));t+=1)do{t+=1}while(10!==e[t]);return t?e.slice(t):e}async function l(e,t){const a=d(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=d(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?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}},23285:(e,t,a)=>{a.r(t),a.d(t,{bufferToString:()=>n,parseCsvBuffer:()=>d,parseTsvBuffer:()=>l});var r=a(90872);function n(e){return new TextDecoder("utf8",{fatal:!0}).decode(e)}async function s(e,t={}){return(await a.e(2460).then(a.t.bind(a,2460,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 c(e,t={}){const{hasColumnNameLine:a=!1,columnNameLineNumber:n=1,isValidRefName:s=(()=>!1),selectedAssemblyName:c}=t;let d=0;const l={isLoaded:!0,rows:e.map(((e,t)=>{const r=t+(a?0:1);return e.length>d&&(d=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<d;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:c}}async function d(e,t){return c(await s(e),t)}async function l(e,t){return c(await s(e,{delimiter:"\t"}),t)}}}]);
//# sourceMappingURL=5696.873cceae.chunk.js.map