import { o as i, n as t, E as o, aZ as y, ah as K, a_ as c, i as E, p as A, b as z, j as D, z as g, _ as p, a$ as I, b0 as v, b1 as w, b2 as B, b3 as T, b4 as G, J as k, b5 as L, b6 as S, b7 as M, v as f, b8 as R, b9 as j, ba as J } from "./index-DSGwv2Yx.js";
import { e as P } from "./axis_util-QWWgLjut.js";
import { m as d } from "./not_equal-CkQKkKZy.js";
import { r as b } from "./reshape-BIN71H3p.js";
import { s as h } from "./sum-D39FeU5h.js";
function U(s, r = null, e = !1) {
  const a = { x: t(s, "x", "min") }, u = { axis: r, keepDims: e };
  return o.runKernel(y, a, u);
}
const q = /* @__PURE__ */ i({ min_: U });
function Z(s, r = "euclidean", e = null, n = !1) {
  s = t(s, "x", "norm");
  const a = N(s, r, e);
  let u = a.shape;
  if (n) {
    const m = K(e, s.shape);
    u = P(a.shape, m);
  }
  return b(a, u);
}
function N(s, r, e = null) {
  if (s.rank === 0)
    return c(s);
  if (s.rank !== 1 && e === null)
    return N(b(s, [-1]), r, e);
  if (s.rank === 1 || typeof e == "number" || Array.isArray(e) && e.length === 1) {
    if (r === 1)
      return h(c(s), e);
    if (r === 1 / 0)
      return d(c(s), e);
    if (r === -1 / 0)
      return q(c(s), e);
    if (r === "euclidean" || r === 2)
      return E(h(A(c(s), z(2, "int32")), e));
    throw new Error(`Error in norm: invalid ord value: ${r}`);
  }
  if (Array.isArray(e) && e.length === 2) {
    if (r === 1)
      return d(h(c(s), e[0]), e[1] - 1);
    if (r === 1 / 0)
      return d(h(c(s), e[1]), e[0]);
    if (r === -1 / 0)
      return q(h(c(s), e[1]), e[0]);
    if (r === "fro" || r === "euclidean")
      return E(h(D(s), e));
    throw new Error(`Error in norm: invalid ord value: ${r}`);
  }
  throw new Error(`Error in norm: invalid axis: ${e}`);
}
const oe = /* @__PURE__ */ i({ norm_: Z });
function C(s, r) {
  let e = t(s, "a", "greater", "string_or_numeric"), n = t(r, "b", "greater", "string_or_numeric");
  [e, n] = g(e, n), p(e.shape, n.shape);
  const a = { a: e, b: n };
  return o.runKernel(I, a);
}
const ue = /* @__PURE__ */ i({ greater_: C });
function F(s, r) {
  let e = t(s, "a", "greaterEqual", "string_or_numeric"), n = t(r, "b", "greaterEqual", "string_or_numeric");
  [e, n] = g(e, n), p(e.shape, n.shape);
  const a = { a: e, b: n };
  return o.runKernel(v, a);
}
const le = /* @__PURE__ */ i({ greaterEqual_: F });
function H(s, r) {
  let e = t(s, "a", "less", "string_or_numeric"), n = t(r, "b", "less", "string_or_numeric");
  [e, n] = g(e, n), p(e.shape, n.shape);
  const a = { a: e, b: n };
  return o.runKernel(w, a);
}
const ce = /* @__PURE__ */ i({ less_: H });
function O(s, r) {
  let e = t(s, "a", "lessEqual", "string_or_numeric"), n = t(r, "b", "lessEqual", "string_or_numeric");
  [e, n] = g(e, n), p(e.shape, n.shape);
  const a = { a: e, b: n };
  return o.runKernel(B, a);
}
const fe = /* @__PURE__ */ i({ lessEqual_: O });
function Q(s) {
  const e = { x: t(s, "x", "log1p") };
  return o.runKernel(T, e);
}
const me = /* @__PURE__ */ i({ log1p_: Q });
function V(s, r) {
  const e = t(s, "a", "logicalAnd", "bool"), n = t(r, "b", "logicalAnd", "bool");
  p(e.shape, n.shape);
  const a = { a: e, b: n };
  return o.runKernel(G, a);
}
const pe = /* @__PURE__ */ i({ logicalAnd_: V });
function W(s, r) {
  let e = t(s, "a", "minimum"), n = t(r, "b", "minimum");
  [e, n] = g(e, n), e.dtype === "bool" && (e = k(e, "int32"), n = k(n, "int32")), p(e.shape, n.shape);
  const a = { a: e, b: n };
  return o.runKernel(L, a);
}
const he = /* @__PURE__ */ i({ minimum_: W });
function X(s) {
  const e = { x: t(s, "x", "round") };
  return o.runKernel(S, e);
}
const be = /* @__PURE__ */ i({ round_: X });
function Y(s, r) {
  let e = t(s, "a", "squaredDifference"), n = t(r, "b", "squaredDifference");
  [e, n] = g(e, n), p(e.shape, n.shape);
  const a = { a: e, b: n }, u = {};
  return o.runKernel(M, a, u);
}
const ge = /* @__PURE__ */ i({ squaredDifference_: Y });
function x(s, r = 0) {
  const e = t(s, "x", "unstack", "string_or_numeric");
  f(r >= -e.shape.length && r < e.shape.length, () => `Axis = ${r} is not in [-${e.shape.length}, ${e.shape.length})`);
  const n = { value: e }, a = { axis: r };
  return o.runKernel(R, n, a);
}
const _e = /* @__PURE__ */ i({ unstack_: x });
function ee(s, r, e = !1, n = !1) {
  const a = t(s, "images", "resizeBilinear");
  f(a.rank === 3 || a.rank === 4, () => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`), f(r.length === 2, () => `Error in resizeBilinear: new shape must 2D, but got shape ${r}.`), f(n === !1 || e === !1, () => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");
  let u = a, m = !1;
  a.rank === 3 && (m = !0, u = b(a, [1, a.shape[0], a.shape[1], a.shape[2]]));
  const _ = { images: u }, $ = { alignCorners: e, halfPixelCenters: n, size: r }, l = o.runKernel(j, _, $);
  return m ? b(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
}
const $e = /* @__PURE__ */ i({ resizeBilinear_: ee });
function re(s, r, e = !1, n = !1) {
  const a = t(s, "images", "resizeNearestNeighbor");
  f(a.rank === 3 || a.rank === 4, () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`), f(r.length === 2, () => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${r}.`), f(a.dtype === "float32" || a.dtype === "int32", () => "`images` must have `int32` or `float32` as dtype"), f(n === !1 || e === !1, () => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");
  let u = a, m = !1;
  a.rank === 3 && (m = !0, u = b(a, [1, a.shape[0], a.shape[1], a.shape[2]]));
  const _ = { images: u }, $ = { alignCorners: e, halfPixelCenters: n, size: r }, l = o.runKernel(J, _, $);
  return m ? b(l, [l.shape[1], l.shape[2], l.shape[3]]) : l;
}
const de = /* @__PURE__ */ i({ resizeNearestNeighbor_: re });
export {
  ce as a,
  pe as b,
  le as c,
  me as d,
  de as e,
  $e as f,
  ue as g,
  q as h,
  fe as l,
  he as m,
  oe as n,
  be as r,
  ge as s,
  _e as u
};
