import{t as e}from"./logger-B058WGzf.js";import{c as t,n,s as r,t as i}from"./manifest-BIDT_vSa.js";import{a}from"./stringUtils-1MyeFdQ_.js";import{a as o}from"./mission-yeigCtfF.js";function s(e){return e.split(/(?:\r\n|\r|\n)/g).map(e=>e.trim()).filter(Boolean).filter(e=>!e.startsWith(`;`)).map(e=>{let t=e.match(/^(.+)\s(\d+)$/);if(t){let e=parseInt(t[2],10);return{name:t[1],frameCount:e}}else return{name:e,frameCount:1}})}var c=256;function l(e){let t=new DataView(e),n=0,r=t.getUint8(n++),i=new Uint16Array(c*c),a=[],o=e=>{let r=``;for(let i=0;i0&&a.push(i)}let l=[];for(let e of a){let e=new Uint8Array(c*c);for(let r=0;r1?r.slice(0,-1).join(`/`)+`/`:``}${e}`),f)}function v(e,n=f){return p(t(`textures/${e}`),n??void 0)}function y(e){return p(`audio/${/\.\w+$/.test(e)?e:`${e}.wav`}`).replace(/\.wav$/i,`.m4a`)}async function b(e){let t=p(`textures/${e}`);return(await(await fetch(t)).text()).split(/(?:\r\n|\r|\n)/).map(e=>{if(e=e.trim(),!e.startsWith(`;`))return e}).filter(Boolean)}async function x(e){let t=n(e),r=await(await fetch(p(t.resourcePath))).arrayBuffer(),i;try{i=new TextDecoder(`utf-8`,{fatal:!0}).decode(r)}catch{i=new TextDecoder(`windows-1252`).decode(r)}return i=i.replaceAll(`�`,`'`),o(i)}async function S(e){let t=p(`terrains/${e}`);u.debug(`Fetching terrain: %s`,t);let n=await fetch(t);if(!n.ok)throw Error(`[loadTerrain] Failed to fetch ${t}: ${n.status} ${n.statusText}`);let r=await n.arrayBuffer();return u.debug(`Loaded terrain %s: %d bytes`,e,r.byteLength),l(r)}async function C(e){let t=p(e);return s(await(await fetch(t)).text())}export{_ as a,C as c,h as d,g as f,p as i,x as l,d as n,m as o,v as p,y as r,b as s,f as t,S as u};