"use strict";var S=Object.create;var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var n in e)o(t,n,{get:e[n],enumerable:!0})},p=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of y(e))!b.call(t,r)&&r!==n&&o(t,r,{get:()=>e[r],enumerable:!(i=h(e,r))||i.enumerable});return t};var d=(t,e,n)=>(n=t!=null?S(E(t)):{},p(e||!t||!t.__esModule?o(n,"default",{value:t,enumerable:!0}):n,t)),_=t=>p(o({},"__esModule",{value:!0}),t);var N={};w(N,{postgis:()=>D});module.exports=_(N);var R=()=>typeof document>"u"?new URL(`file:${__filename}`).href:document.currentScript&&document.currentScript.src||new URL("main.js",document.baseURI).href,u=R();var A=Object.defineProperty,I=(t,e)=>{for(var n in e)A(t,n,{get:e[n],enumerable:!0})},f={};I(f,{IN_NODE:()=>l,WASM_PREFIX:()=>L,getFsBundle:()=>U,instantiateWasm:()=>P,rmdirRecursive:()=>m,startArtifactDownload:()=>g,toPostgresName:()=>j,uuid:()=>T});var l=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",L="/pglite",a=new Map;async function g(t){l||a.has(t.toString())||a.set(t.toString(),fetch(t))}var s=new Map;async function P(t,e,n){if(n||s.has(e.toString())){let i=n||s.get(e.toString());return{instance:await WebAssembly.instantiate(i,t),module:i}}if(l){let i=await(await import("fs/promises")).readFile(e),{module:r,instance:c}=await WebAssembly.instantiate(i,t);return s.set(e.toString(),r),{instance:c,module:r}}else{a.has(e.toString())||g(e);let i=await a.get(e.toString()),{module:r,instance:c}=await WebAssembly.instantiateStreaming(i.clone(),t);return s.set(e.toString(),r),{instance:c,module:r}}}async function U(t){return l?(await(await import("fs/promises")).readFile(t)).buffer:(g(t),(await a.get(t.toString())).clone().arrayBuffer())}var T=()=>{if(globalThis.crypto?.randomUUID)return globalThis.crypto.randomUUID();let t=new Uint8Array(16);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(t);else for(let n=0;n<t.length;n++)t[n]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;let e=[];return t.forEach(n=>{e.push(n.toString(16).padStart(2,"0"))}),e.slice(0,4).join("")+"-"+e.slice(4,6).join("")+"-"+e.slice(6,8).join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10).join("")};function j(t){let e;return t.startsWith('"')&&t.endsWith('"')?e=t.substring(1,t.length-1):e=t.toLowerCase(),e}function m(t,e){try{let n=t.readdir(e).filter(i=>i!=="."&&i!=="..");for(let i of n){let r=e+"/"+i;try{t.readdir(r),m(t,r)}catch{t.unlink(r)}}t.rmdir(e)}catch{try{t.unlink(e)}catch{}}}var v=async(t,e)=>(e.PGLITE_ENV.POSTGIS_GDAL_ENABLED_DRIVERS="ENABLE_ALL",e.PGLITE_ENV.POSTGIS_ENABLE_OUTDB_RASTERS=1,e.PGLITE_ENV.PROJ_DATA=`${f.WASM_PREFIX}/share/proj`,{emscriptenOpts:e,bundlePath:new URL("./postgis.tar.gz",u)}),D={name:"postgis",setup:v};0&&(module.exports={postgis});
//# sourceMappingURL=index.cjs.map