"use strict";(self.webpackChunk_jbrowse_web=self.webpackChunk_jbrowse_web||[]).push([[5696,3285],{5696:(e,t,a)=>{a.r(t),a.d(t,{parseBedBuffer:()=>d,parseBedPEBuffer:()=>m,removeBedHeaders:()=>l});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 l(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 d(e,t){const a=l(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=l(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(((e,t)=>{let{text:r}=e;const n=s[t],o=n&&"Number"===n.dataType.type&&r?parseFloat(r):r;n?2===n.featureField.length?(a[n.featureField[0]]||(a[n.featureField[0]]={}),a[n.featureField[0]][n.featureField[1]]=o):a[n.featureField[0]]=o:a["column".concat(t+1)]=o})),a.uniqueId="bedpe-".concat(t),e.extendedData={feature:a}})),n.assemblyName=t.selectedAssemblyName,n}},23285:(e,t,a)=>{a.r(t),a.d(t,{bufferToString:()=>n,parseCsvBuffer:()=>l,parseTsvBuffer:()=>d});var r=a(90872);function n(e){return new TextDecoder("utf8",{fatal:!0}).decode(e)}async function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(await a.e(6226).then(a.t.bind(a,16226,23)).then((e=>e.default)))({noheader:!0,output:"csv",...t}).fromString(n(e))}function o(e,t,a){var n;const s=e.rows[0].cells[t].text||"";let o,c="Text";try{o=(0,r.parseLocString)(s,a)}catch(l){}return null!==(n=o)&&void 0!==n&&n.refName&&"number"===typeof o.start?c="LocString":/^\d+(\.\d+)?$/.test(s)&&(c="Number"),c}function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{hasColumnNameLine:a=!1,columnNameLineNumber:n=1,isValidRefName:s=(()=>!1),selectedAssemblyName:c}=t;let l=0;const d={isLoaded:!0,rows:e.map(((e,t)=>{const r=t+(a?0:1);return e.length>l&&(l=e.length),{id:String(r),cells:e.map(((e,t)=>({columnNumber:t,text:e})))}}))},m={};if(a&&void 0!==n){const[e]=d.rows.splice(n-1,1);e&&e.cells.forEach(((e,t)=>{m[t]=e.text||""}))}const u=[],i=[];for(let p=0;p<l;p+=1){i.push(p);const e=o(d,p,s);if("LocString"===e)for(const t of d.rows){const e=t.cells[p];e.extendedData=(0,r.parseLocString)(e.text,s)}u[p]={name:m[p],dataType:{type:e}}}return{rowSet:d,columnDisplayOrder:i,hasColumnNames:!!a,columns:u,assemblyName:c}}async function l(e,t){return c(await s(e),t)}async function d(e,t){return c(await s(e,{delimiter:"\t"}),t)}}}]);
//# sourceMappingURL=5696.532714f3.chunk.js.map