import { __exports as c } from "../../../../../../../../_virtual/uniqueItems.js";
import { __require as N } from "../../compile/validate/dataType.js";
import { __require as U } from "../../compile/codegen/index.js";
import { __require as j } from "../../compile/util.js";
import { __require as D } from "../../runtime/equal.js";
var l;
function E() {
  if (l) return c;
  l = 1, Object.defineProperty(c, "__esModule", { value: !0 });
  const _ = N(), r = U(), p = j(), d = D(), q = {
    keyword: "uniqueItems",
    type: "array",
    schemaType: "boolean",
    $data: !0,
    error: {
      message: ({ params: { i: a, j: e } }) => (0, r.str)`must NOT have duplicate items (items ## ${e} and ${a} are identical)`,
      params: ({ params: { i: a, j: e } }) => (0, r._)`{i: ${a}, j: ${e}}`
    },
    code(a) {
      const { gen: e, data: n, $data: g, schema: y, parentSchema: f, schemaCode: h, it: b } = a;
      if (!g && !y)
        return;
      const i = e.let("valid"), u = f.items ? (0, _.getSchemaTypes)(f.items) : [];
      a.block$data(i, T, (0, r._)`${h} === false`), a.ok(i);
      function T() {
        const t = e.let("i", (0, r._)`${n}.length`), o = e.let("j");
        a.setParams({ i: t, j: o }), e.assign(i, !0), e.if((0, r._)`${t} > 1`, () => (k() ? v : I)(t, o));
      }
      function k() {
        return u.length > 0 && !u.some((t) => t === "object" || t === "array");
      }
      function v(t, o) {
        const s = e.name("item"), m = (0, _.checkDataTypes)(u, s, b.opts.strictNumbers, _.DataType.Wrong), $ = e.const("indices", (0, r._)`{}`);
        e.for((0, r._)`;${t}--;`, () => {
          e.let(s, (0, r._)`${n}[${t}]`), e.if(m, (0, r._)`continue`), u.length > 1 && e.if((0, r._)`typeof ${s} == "string"`, (0, r._)`${s} += "_"`), e.if((0, r._)`typeof ${$}[${s}] == "number"`, () => {
            e.assign(o, (0, r._)`${$}[${s}]`), a.error(), e.assign(i, !1).break();
          }).code((0, r._)`${$}[${s}] = ${t}`);
        });
      }
      function I(t, o) {
        const s = (0, p.useFunc)(e, d.default), m = e.name("outer");
        e.label(m).for((0, r._)`;${t}--;`, () => e.for((0, r._)`${o} = ${t}; ${o}--;`, () => e.if((0, r._)`${s}(${n}[${t}], ${n}[${o}])`, () => {
          a.error(), e.assign(i, !1).break(m);
        })));
      }
    }
  };
  return c.default = q, c;
}
export {
  E as __require
};
//# sourceMappingURL=uniqueItems.js.map
