// packages/php-wasm/node-builds/7-4/src/index.ts
import { jspi } from "wasm-feature-detect";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
import { existsSync } from "node:fs";
var currentDirPath = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
var packageDir = existsSync(join(currentDirPath, "jspi")) ? currentDirPath : dirname(currentDirPath);
async function getPHPLoaderModule() {
  if (await jspi()) {
    return await import("./jspi/php_7_4.js");
  } else {
    return await import("./asyncify/php_7_4.js");
  }
}
async function getIntlExtensionPath() {
  if (await jspi()) {
    return join(packageDir, "jspi/extensions/intl/7_4/intl.so");
  } else {
    return join(packageDir, "asyncify/extensions/intl/7_4/intl.so");
  }
}
async function getXdebugExtensionPath() {
  if (await jspi()) {
    return join(packageDir, "jspi/extensions/xdebug/7_4/xdebug.so");
  } else {
    return join(packageDir, "asyncify/extensions/xdebug/7_4/xdebug.so");
  }
}
async function getRedisExtensionPath() {
  if (await jspi()) {
    return join(packageDir, "jspi/extensions/redis/7_4/redis.so");
  }
  throw new Error(
    "The Redis extension requires JSPI (JavaScript Promise Integration) support. Your current environment is using asyncify, which cannot properly handle exceptions during Redis network operations. Please use Node.js 23+ or a browser with JSPI support to use the Redis extension."
  );
}
async function getMemcachedExtensionPath() {
  if (await jspi()) {
    return join(packageDir, "jspi/extensions/memcached/7_4/memcached.so");
  }
  throw new Error(
    "The Memcached extension requires JSPI (JavaScript Promise Integration) support. Your current environment is using asyncify, which cannot properly handle exceptions during Memcached network operations. Please use Node.js 23+ or a browser with JSPI support to use the Memcached extension."
  );
}
export {
  getIntlExtensionPath,
  getMemcachedExtensionPath,
  getPHPLoaderModule,
  getRedisExtensionPath,
  getXdebugExtensionPath,
  jspi
};
