UNPKG

1.63 kBJavaScriptView Raw
1import { i as a } from "./init-f9637058.js";
2class o extends Map {
3 constructor(n, t = g) {
4 if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: t } }), n != null)
5 for (const [r, s] of n)
6 this.set(r, s);
7 }
8 get(n) {
9 return super.get(c(this, n));
10 }
11 has(n) {
12 return super.has(c(this, n));
13 }
14 set(n, t) {
15 return super.set(l(this, n), t);
16 }
17 delete(n) {
18 return super.delete(p(this, n));
19 }
20}
21function c({ _intern: e, _key: n }, t) {
22 const r = n(t);
23 return e.has(r) ? e.get(r) : t;
24}
25function l({ _intern: e, _key: n }, t) {
26 const r = n(t);
27 return e.has(r) ? e.get(r) : (e.set(r, t), t);
28}
29function p({ _intern: e, _key: n }, t) {
30 const r = n(t);
31 return e.has(r) && (t = e.get(r), e.delete(r)), t;
32}
33function g(e) {
34 return e !== null && typeof e == "object" ? e.valueOf() : e;
35}
36const f = Symbol("implicit");
37function h() {
38 var e = new o(), n = [], t = [], r = f;
39 function s(u) {
40 let i = e.get(u);
41 if (i === void 0) {
42 if (r !== f)
43 return r;
44 e.set(u, i = n.push(u) - 1);
45 }
46 return t[i % t.length];
47 }
48 return s.domain = function(u) {
49 if (!arguments.length)
50 return n.slice();
51 n = [], e = new o();
52 for (const i of u)
53 e.has(i) || e.set(i, n.push(i) - 1);
54 return s;
55 }, s.range = function(u) {
56 return arguments.length ? (t = Array.from(u), s) : t.slice();
57 }, s.unknown = function(u) {
58 return arguments.length ? (r = u, s) : r;
59 }, s.copy = function() {
60 return h(n, t).unknown(r);
61 }, a.apply(s, arguments), s;
62}
63export {
64 h as o
65};