var __defProp = Object.defineProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
  __markAsModule(target);
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
__export(exports, {
  verify: () => verify
});
var _a, _b, _c, _d, _e;
let wasm;
{
  const module2 = new WebAssembly.Module(require('fs').readFileSync(require('path').join(__dirname, '../../src/ed25519/simd.wasm')));
  const instance = new WebAssembly.Instance(module2);
  wasm = instance.exports;
}
const u16_max = 2 ** 16;
const { memory, verify: v } = wasm;
let len = memory.buffer.byteLength;
let u8 = new Uint8Array(memory.buffer);
let k8 = new Uint8Array(memory.buffer, 16384, 32);
let s8 = new Uint8Array(memory.buffer, 32 + 16384, 64);
const encode_utf8 = (_e = (_d = (_b = (_a = globalThis.Deno) == null ? void 0 : _a.core) == null ? void 0 : _b.encode) != null ? _d : (_c = globalThis.Buffer) == null ? void 0 : _c.from.bind(globalThis.Buffer)) != null ? _e : TextEncoder.prototype.encode.bind(new TextEncoder());
function resize(size) {
  memory.grow(Math.ceil((size - len) / u16_max));
  len = memory.buffer.byteLength;
  u8 = new Uint8Array(memory.buffer);
  k8 = new Uint8Array(memory.buffer, 16384, 32);
  s8 = new Uint8Array(memory.buffer, 32 + 16384, 64);
}
;
function verify(key, sig, buf) {
  if (typeof buf === "string")
    buf = encode_utf8(buf);
  if (len < 16480 + buf.length)
    resize(16480 + buf.length);
  k8.set(key);
  s8.set(sig);
  u8.set(buf, 16480);
  return !!v(buf.length, 2 ** 14);
}
;
