@pop-ui/core 2.2.4 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/core.js +58 -3110
  3. package/dist/core.umd.cjs +16 -16
  4. package/dist/esm/components/Button/index.js +75 -0
  5. package/dist/esm/components/Button/style.js +9 -0
  6. package/dist/esm/components/Button/styles.module.scss.js +28 -0
  7. package/dist/esm/components/CalendarDatePicker/index.js +119 -0
  8. package/dist/esm/components/CalendarDatePicker/styles.module.scss.js +34 -0
  9. package/dist/esm/components/CalendarDatePicker/utils.js +82 -0
  10. package/dist/esm/components/Checkbox/index.js +32 -0
  11. package/dist/esm/components/Checkbox/styles.module.scss.js +9 -0
  12. package/dist/esm/components/DatePicker/index.js +203 -0
  13. package/dist/esm/components/DatePicker/styles.module.scss.js +57 -0
  14. package/dist/esm/components/Dropdown/index.js +61 -0
  15. package/dist/esm/components/Dropdown/styles.module.scss.js +21 -0
  16. package/dist/esm/components/ImageInput/ImageInputCropModal.js +91 -0
  17. package/dist/esm/components/ImageInput/helpers.js +46 -0
  18. package/dist/esm/components/ImageInput/index.js +379 -0
  19. package/dist/esm/components/ImageInput/styles.module.scss.js +30 -0
  20. package/dist/esm/components/LottieInput/helpers.js +48 -0
  21. package/dist/esm/components/LottieInput/index.js +233 -0
  22. package/dist/esm/components/LottieInput/styles.module.scss.js +14 -0
  23. package/dist/esm/components/Map/Map.js +48 -0
  24. package/dist/esm/components/Map/NaverMapContext.js +78 -0
  25. package/dist/esm/components/Map/markerClustering.js +305 -0
  26. package/dist/esm/components/Map/markerStyles.js +351 -0
  27. package/dist/esm/components/Map/useLocation.js +40 -0
  28. package/dist/esm/components/Map/useMap.js +95 -0
  29. package/dist/esm/components/MapInfo/index.js +120 -0
  30. package/dist/esm/components/MapInfo/styles.module.scss.js +24 -0
  31. package/dist/esm/components/Modal/index.js +52 -0
  32. package/dist/esm/components/Pagination/index.js +45 -0
  33. package/dist/esm/components/Pagination/style.module.scss.js +13 -0
  34. package/dist/esm/components/Radio/index.js +29 -0
  35. package/dist/esm/components/Radio/styles.module.scss.js +9 -0
  36. package/dist/esm/components/SearchBar/index.js +60 -0
  37. package/dist/esm/components/SearchBar/styles.module.scss.js +25 -0
  38. package/dist/esm/components/SegmentButton/index.js +25 -0
  39. package/dist/esm/components/SegmentButton/styles.module.scss.js +9 -0
  40. package/dist/esm/components/Tab/index.js +14 -0
  41. package/dist/esm/components/Tab/styles.module.scss.js +10 -0
  42. package/dist/esm/components/TextField/index.js +99 -0
  43. package/dist/esm/components/TextField/styles.module.scss.js +28 -0
  44. package/dist/esm/components/TimePicker/index.js +33 -0
  45. package/dist/esm/components/TimePicker/styles.module.scss.js +9 -0
  46. package/dist/esm/components/Toast/index.js +35 -0
  47. package/dist/esm/components/Toast/styles.module.scss.js +14 -0
  48. package/dist/esm/components/Toggle/index.js +48 -0
  49. package/dist/esm/components/Toggle/styles.module.scss.js +9 -0
  50. package/dist/esm/components/Tooltip/index.js +25 -0
  51. package/dist/esm/components/Tooltip/styles.module.scss.js +12 -0
  52. package/dist/esm/components/shared/MultiItemInput/Dropzone.js +30 -0
  53. package/dist/esm/components/shared/MultiItemInput/SortableEmptySlot.js +29 -0
  54. package/dist/esm/components/shared/MultiItemInput/TileShell.js +113 -0
  55. package/dist/esm/components/shared/MultiItemInput/helpers.js +23 -0
  56. package/dist/esm/components/shared/MultiItemInput/styles.module.scss.js +30 -0
  57. package/dist/esm/components/shared/MultiItemInput/usePositionGrid.js +49 -0
  58. package/dist/esm/components/shared/MultiItemInput/useSortableGrid.js +20 -0
  59. package/dist/esm/theme/ThemeProvider.js +46 -0
  60. package/dist/esm/theme/cssVariables.js +29 -0
  61. package/dist/esm/theme/mantineTheme.js +36 -0
  62. package/package.json +2 -2
@@ -0,0 +1,233 @@
1
+ "use client";
2
+ import { jsxs as $, jsx as o, Fragment as W } from "react/jsx-runtime";
3
+ import { DndContext as X, closestCenter as Y } from "@dnd-kit/core";
4
+ import { SortableContext as Z, rectSortingStrategy as w } from "@dnd-kit/sortable";
5
+ import { Input as tt } from "@mantine/core";
6
+ import { IconPhoto as _, ColorRed700 as F, ColorAqua700 as R } from "@pop-ui/foundation";
7
+ import { useState as et, useEffect as ot, Suspense as nt, lazy as rt } from "react";
8
+ import { parseLottieFile as v, isValidLottieJSON as lt, deleteItem as st, addItemAtPosition as it, addItems as at } from "./helpers.js";
9
+ import x from "./styles.module.scss.js";
10
+ import { PlaceholderDropzone as M } from "../shared/MultiItemInput/Dropzone.js";
11
+ import { SortableEmptySlot as ct } from "../shared/MultiItemInput/SortableEmptySlot.js";
12
+ import { TileShell as dt } from "../shared/MultiItemInput/TileShell.js";
13
+ import { usePositionGrid as ft } from "../shared/MultiItemInput/usePositionGrid.js";
14
+ import { toast as O } from "../Toast/index.js";
15
+ const ut = rt(
16
+ () => (
17
+ // Node 네이티브 ESM 로더는 CommonJS 인 lottie-react 의 exports 객체 전체를 default 로 넘긴다.
18
+ import("lottie-react").then((t) => {
19
+ const i = t.default;
20
+ return { default: typeof i == "function" ? i : i.default };
21
+ })
22
+ )
23
+ ), q = { "application/json": [".json"] };
24
+ function G({
25
+ item: t,
26
+ sortableId: i,
27
+ totalCount: y,
28
+ width: f,
29
+ height: a,
30
+ readOnly: D,
31
+ isLoading: I,
32
+ canDelete: L,
33
+ hasLink: E,
34
+ onLinkClick: P,
35
+ onDelete: g
36
+ }) {
37
+ const l = !t.animationData && !!(t.file || t.url) ? `${t.id}|${t.file ? `${t.file.name}:${t.file.size}` : t.url ?? ""}` : "", [s, S] = et({ key: "", data: null }), h = t.animationData ?? (s.key === l ? s.data : null), C = !!l && s.key !== l;
38
+ return ot(() => {
39
+ if (!l) return;
40
+ let u = !1;
41
+ return (t.file ? v(t.file) : fetch(t.url).then((m) => m.json()).then(
42
+ (m) => lt(m) ? m : null
43
+ )).then((m) => {
44
+ u || S({ key: l, data: m });
45
+ }).catch(() => {
46
+ u || S({ key: l, data: null });
47
+ }), () => {
48
+ u = !0;
49
+ };
50
+ }, [l, t.file, t.url]), /* @__PURE__ */ o(
51
+ dt,
52
+ {
53
+ id: i ?? t.id,
54
+ totalCount: y,
55
+ width: f,
56
+ height: a,
57
+ readOnly: D,
58
+ isLoading: I,
59
+ itemIsLoading: t.isLoading || C,
60
+ canDelete: L,
61
+ hasLink: E,
62
+ linkUrl: t.url,
63
+ onLinkClick: P ? () => P(t) : void 0,
64
+ onDelete: () => g(t.id),
65
+ deleteAriaLabel: "Lottie 삭제",
66
+ children: h ? /* @__PURE__ */ o(nt, { fallback: /* @__PURE__ */ o("div", { style: { width: f, height: a, display: "block" } }), children: /* @__PURE__ */ o(
67
+ ut,
68
+ {
69
+ animationData: h,
70
+ loop: !0,
71
+ autoplay: !0,
72
+ style: { width: f, height: a, display: "block" }
73
+ }
74
+ ) }) : /* @__PURE__ */ o("div", { className: x.Empty, style: { width: f, height: a } })
75
+ }
76
+ );
77
+ }
78
+ const At = ({
79
+ value: t = [],
80
+ onChange: i,
81
+ width: y = 160,
82
+ height: f = 200,
83
+ placeholder: a = "Lottie JSON 파일을 넣어주세요",
84
+ hasIcon: D = !0,
85
+ hasLink: I = !1,
86
+ onLinkClick: L,
87
+ length: E,
88
+ minLength: P,
89
+ maxLength: g,
90
+ errorMsg: A,
91
+ isLoading: l,
92
+ readOnly: s,
93
+ gap: S = 8,
94
+ canDelete: h = !0
95
+ }) => {
96
+ const {
97
+ isPositionMode: C,
98
+ resolvedMaxLength: u,
99
+ placeholderCount: k,
100
+ slotIds: m,
101
+ sortableItems: K,
102
+ sensors: U,
103
+ handleDragEnd: V,
104
+ getMetaIndex: B
105
+ } = ft({ value: t, length: E, minLength: P, maxLength: g, onChange: i }), p = !!A, H = async (n) => {
106
+ if (s) return;
107
+ const e = [...n].sort((j, b) => j.name.localeCompare(b.name)), r = await Promise.all(e.map(v));
108
+ let c = 0;
109
+ const d = e.filter((j, b) => r[b] !== null ? !0 : (c++, !1));
110
+ if (c > 0 && O({
111
+ id: "invalid-lottie-files",
112
+ message: c === 1 ? "유효하지 않은 Lottie JSON 파일입니다" : `${c}개의 파일이 유효하지 않은 Lottie JSON입니다`
113
+ }), d.length === 0) return;
114
+ const N = t.length, T = at(t, d, u);
115
+ T.length !== N && i?.(T, {
116
+ action: "create",
117
+ itemId: T[N].id,
118
+ index: N
119
+ });
120
+ }, Q = async (n, e) => {
121
+ if (s) return;
122
+ const r = e[0];
123
+ if (!r) return;
124
+ if (!await v(r)) {
125
+ O({
126
+ id: "invalid-lottie-files",
127
+ message: "유효하지 않은 Lottie JSON 파일입니다"
128
+ });
129
+ return;
130
+ }
131
+ const d = it(t, r, n);
132
+ i?.(d, {
133
+ action: "create",
134
+ itemId: d[d.length - 1].id,
135
+ index: n
136
+ });
137
+ }, z = (n) => {
138
+ if (s) return;
139
+ const e = B(n), r = st(t, n);
140
+ i?.(r, { action: "delete", itemId: n, index: e });
141
+ }, J = (n) => {
142
+ const e = typeof a == "function" ? a(n) : a;
143
+ return typeof e != "string" ? e : e.split(`
144
+ `).map((r, c) => /* @__PURE__ */ o("span", { children: r }, c));
145
+ };
146
+ return /* @__PURE__ */ $("div", { children: [
147
+ /* @__PURE__ */ o(X, { sensors: U, collisionDetection: Y, onDragEnd: V, children: /* @__PURE__ */ o(Z, { items: K, strategy: w, children: /* @__PURE__ */ o("div", { className: x.Container, style: { gap: S }, children: C ? Array.from({ length: u }, (n, e) => {
148
+ const r = m[e], c = t.find((d) => d.position === e);
149
+ return c ? /* @__PURE__ */ o(
150
+ G,
151
+ {
152
+ item: c,
153
+ sortableId: r,
154
+ totalCount: u,
155
+ width: y,
156
+ height: f,
157
+ readOnly: s ?? !1,
158
+ isLoading: l,
159
+ canDelete: h,
160
+ hasLink: I,
161
+ onLinkClick: L,
162
+ onDelete: z
163
+ },
164
+ r
165
+ ) : !s && /* @__PURE__ */ o(ct, { id: r, children: /* @__PURE__ */ $(
166
+ M,
167
+ {
168
+ onDrop: (d) => Q(e, d),
169
+ accept: q,
170
+ multiple: !1,
171
+ isLoading: l,
172
+ isError: p,
173
+ width: y,
174
+ height: f,
175
+ children: [
176
+ D && /* @__PURE__ */ o(_, { size: 36, color: p ? F : R }),
177
+ a && /* @__PURE__ */ o(
178
+ "div",
179
+ {
180
+ className: `${x.PlaceholderText}${p ? ` ${x.PlaceholderTextError}` : ""}`,
181
+ children: J(e)
182
+ }
183
+ )
184
+ ]
185
+ }
186
+ ) }, r);
187
+ }) : /* @__PURE__ */ $(W, { children: [
188
+ t.map((n) => /* @__PURE__ */ o(
189
+ G,
190
+ {
191
+ item: n,
192
+ totalCount: t.length,
193
+ width: y,
194
+ height: f,
195
+ readOnly: s ?? !1,
196
+ isLoading: l,
197
+ canDelete: h,
198
+ hasLink: I,
199
+ onLinkClick: L,
200
+ onDelete: z
201
+ },
202
+ n.id
203
+ )),
204
+ !s && Array.from({ length: k }, (n, e) => /* @__PURE__ */ $(
205
+ M,
206
+ {
207
+ onDrop: H,
208
+ accept: q,
209
+ multiple: u !== 1,
210
+ isLoading: l,
211
+ isError: p,
212
+ width: y,
213
+ height: f,
214
+ children: [
215
+ D && /* @__PURE__ */ o(_, { size: 36, color: p ? F : R }),
216
+ a && /* @__PURE__ */ o(
217
+ "div",
218
+ {
219
+ className: `${x.PlaceholderText}${p ? ` ${x.PlaceholderTextError}` : ""}`,
220
+ children: J(e)
221
+ }
222
+ )
223
+ ]
224
+ },
225
+ `placeholder-${e}`
226
+ ))
227
+ ] }) }) }) }),
228
+ p && /* @__PURE__ */ o(tt.Error, { mt: 8, children: A })
229
+ ] });
230
+ };
231
+ export {
232
+ At as LottieInput
233
+ };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ const e = "styles-module__Container___cJqG-", t = "styles-module__Empty___gexrS", l = "styles-module__PlaceholderText___x2ya0", o = "styles-module__PlaceholderTextError___i8VXv", r = {
3
+ Container: e,
4
+ Empty: t,
5
+ PlaceholderText: l,
6
+ PlaceholderTextError: o
7
+ };
8
+ export {
9
+ e as Container,
10
+ t as Empty,
11
+ l as PlaceholderText,
12
+ o as PlaceholderTextError,
13
+ r as default
14
+ };
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ import { jsx as M } from "react/jsx-runtime";
3
+ import { useRef as y, useState as I, useMemo as g, useEffect as o } from "react";
4
+ import { markerStyles as C } from "./markerStyles.js";
5
+ import { useNaverMap as S } from "./NaverMapContext.js";
6
+ import { useMap as N } from "./useMap.js";
7
+ const k = ({ options: h, onLoad: s }) => {
8
+ const r = y(null), v = y(null), { createMap: u } = S(), [n, a] = I(null), p = N(n), { width: i = "100%", height: l = "100%", ...c } = h || {}, m = g(() => c, [JSON.stringify(c)]);
9
+ return o(() => {
10
+ if (typeof document > "u" || document.getElementById("pop-ui-map-marker-styles")) return;
11
+ const e = document.createElement("style");
12
+ return e.id = "pop-ui-map-marker-styles", e.textContent = C, document.head.appendChild(e), v.current = e, () => {
13
+ };
14
+ }, []), o(() => {
15
+ let t = null, e = null;
16
+ if (n && (n.destroy(), a(null)), r.current && r.current.isConnected) {
17
+ const f = () => r.current && r.current.isConnected && (t = u(r, m), t) ? (a(t), !0) : !1;
18
+ if (!f()) {
19
+ let d = 0;
20
+ const x = 50;
21
+ e = setInterval(() => {
22
+ d++, (f() || d >= x) && e && (clearInterval(e), e = null);
23
+ }, 100);
24
+ }
25
+ return () => {
26
+ e && clearInterval(e), t && (t.destroy(), t = null);
27
+ };
28
+ }
29
+ return () => {
30
+ e && clearInterval(e), t && (t.destroy(), t = null);
31
+ };
32
+ }, [u, m]), o(() => {
33
+ n && s && s({ map: n, ...p });
34
+ }, [n, s, p]), /* @__PURE__ */ M(
35
+ "div",
36
+ {
37
+ ref: r,
38
+ style: {
39
+ width: typeof i == "number" ? `${i}px` : i,
40
+ height: typeof l == "number" ? `${l}px` : l
41
+ }
42
+ }
43
+ );
44
+ };
45
+ k.displayName = "Map";
46
+ export {
47
+ k as Map
48
+ };
@@ -0,0 +1,78 @@
1
+ "use client";
2
+ import { jsx as h } from "react/jsx-runtime";
3
+ import { useState as l, useEffect as x, useCallback as y, createContext as P, useContext as g } from "react";
4
+ const f = P(null), m = "naver-map-script", A = (r, s) => new Promise((o, n) => {
5
+ if (typeof window < "u" && window.naver?.maps) {
6
+ o();
7
+ return;
8
+ }
9
+ const t = document.getElementById(m);
10
+ if (t) {
11
+ t.addEventListener("load", () => o()), t.addEventListener(
12
+ "error",
13
+ () => n(new Error("Failed to load Naver Map script"))
14
+ );
15
+ return;
16
+ }
17
+ const e = document.createElement("script");
18
+ e.id = m, e.src = `https://oapi.map.naver.com/openapi/v3/maps.js?ncpKeyId=${r}&language=${s}`, e.async = !0, e.onload = () => {
19
+ o();
20
+ }, e.onerror = () => {
21
+ n(new Error("Failed to load Naver Map script"));
22
+ }, document.head.appendChild(e);
23
+ }), S = ({
24
+ clientId: r,
25
+ language: s = "ko",
26
+ children: o
27
+ }) => {
28
+ const [n, t] = l(null), [e, v] = l({}), [d, w] = l(null);
29
+ x(() => {
30
+ typeof window > "u" || A(r, s).then(() => {
31
+ window.naver && t(window.naver);
32
+ }).catch((a) => {
33
+ console.error("Naver Map script loading failed:", a), w(a);
34
+ });
35
+ }, [r, s]);
36
+ const M = y(
37
+ (a, C) => {
38
+ const i = n || (typeof window < "u" ? window.naver : null);
39
+ if (!i || (!n && window.naver && t(window.naver), !a.current))
40
+ return null;
41
+ const c = a.current;
42
+ if (!c.isConnected)
43
+ return null;
44
+ try {
45
+ const p = {
46
+ center: new i.maps.LatLng(37.5665, 126.978),
47
+ // 서울 시청 기본 좌표
48
+ zoom: 11,
49
+ maxZoom: 20,
50
+ minZoom: 11,
51
+ mapTypeControl: !1,
52
+ scaleControl: !1,
53
+ logoControl: !1,
54
+ mapDataControl: !1,
55
+ zoomControl: !1,
56
+ ...C
57
+ }, u = new i.maps.Map(c, p);
58
+ return v((N) => {
59
+ const E = c.getAttribute("id") || "default";
60
+ return { ...N, [E]: u };
61
+ }), u;
62
+ } catch (p) {
63
+ return console.error("Map creation error:", p), null;
64
+ }
65
+ },
66
+ [n]
67
+ );
68
+ return d && console.error("NaverMapProvider error:", d), /* @__PURE__ */ h(f.Provider, { value: { naver: n, createMap: M, maps: e }, children: o });
69
+ }, b = () => {
70
+ const r = g(f);
71
+ if (!r)
72
+ throw new Error("useNaverMap must be used within NaverMapProvider");
73
+ return r;
74
+ };
75
+ export {
76
+ S as NaverMapProvider,
77
+ b as useNaverMap
78
+ };
@@ -0,0 +1,305 @@
1
+ "use client";
2
+ function M(i) {
3
+ const m = function(t) {
4
+ this.DEFAULT_OPTIONS = {
5
+ map: null,
6
+ markers: [],
7
+ disableClickZoom: !0,
8
+ minClusterSize: 2,
9
+ maxZoom: 13,
10
+ gridSize: 100,
11
+ icons: [],
12
+ indexGenerator: [10, 100, 200, 500, 1e3],
13
+ averageCenter: !1,
14
+ stylingFunction: function() {
15
+ }
16
+ }, this._clusters = [], this._mapRelations = null, this._markerRelations = [], this.setOptions(i.maps.Util.extend({}, this.DEFAULT_OPTIONS, t), !0), this.setMap(t.map || null);
17
+ };
18
+ i.maps.Util.ClassExtend(m, i.maps.OverlayView, {
19
+ onAdd: function() {
20
+ const t = this.getMap();
21
+ this._mapRelations = i.maps.Event.addListener(
22
+ t,
23
+ "idle",
24
+ i.maps.Util.bind(this._onIdle, this)
25
+ ), this.getMarkers().length > 0 && (this._createClusters(), this._updateClusters());
26
+ },
27
+ draw: i.maps.Util.noop,
28
+ onRemove: function() {
29
+ i.maps.Event.removeListener(this._mapRelation), this._clearClusters(), this._geoTree = null, this._mapRelation = null;
30
+ },
31
+ setOptions: function(t) {
32
+ const e = this;
33
+ if (typeof t == "string") {
34
+ const s = t, n = arguments[1];
35
+ e.set(s, n);
36
+ } else {
37
+ const s = arguments[1];
38
+ i.maps.Util.forEach(t, function(n, r) {
39
+ r !== "map" && e.set(r, n);
40
+ }), t.map && !s && e.setMap(t.map);
41
+ }
42
+ },
43
+ getOptions: function(t) {
44
+ const e = this, s = {};
45
+ return t !== void 0 ? e.get(t) : (i.maps.Util.forEach(e.DEFAULT_OPTIONS, function(n, r) {
46
+ s[r] = e.get(r);
47
+ }), s);
48
+ },
49
+ getMinClusterSize: function() {
50
+ return this.getOptions("minClusterSize");
51
+ },
52
+ setMinClusterSize: function(t) {
53
+ this.setOptions("minClusterSize", t);
54
+ },
55
+ getMaxZoom: function() {
56
+ return this.getOptions("maxZoom");
57
+ },
58
+ setMaxZoom: function(t) {
59
+ this.setOptions("maxZoom", t);
60
+ },
61
+ getGridSize: function() {
62
+ return this.getOptions("gridSize");
63
+ },
64
+ setGridSize: function(t) {
65
+ this.setOptions("gridSize", t);
66
+ },
67
+ getIndexGenerator: function() {
68
+ return this.getOptions("indexGenerator");
69
+ },
70
+ setIndexGenerator: function(t) {
71
+ this.setOptions("indexGenerator", t);
72
+ },
73
+ getMarkers: function() {
74
+ return this.getOptions("markers");
75
+ },
76
+ setMarkers: function(t) {
77
+ this.setOptions("markers", t);
78
+ },
79
+ getIcons: function() {
80
+ return this.getOptions("icons");
81
+ },
82
+ setIcons: function(t) {
83
+ this.setOptions("icons", t);
84
+ },
85
+ getStylingFunction: function() {
86
+ return this.getOptions("stylingFunction");
87
+ },
88
+ setStylingFunction: function(t) {
89
+ this.setOptions("stylingFunction", t);
90
+ },
91
+ getDisableClickZoom: function() {
92
+ return this.getOptions("disableClickZoom");
93
+ },
94
+ setDisableClickZoom: function(t) {
95
+ this.setOptions("disableClickZoom", t);
96
+ },
97
+ getAverageCenter: function() {
98
+ return this.getOptions("averageCenter");
99
+ },
100
+ setAverageCenter: function(t) {
101
+ this.setOptions("averageCenter", t);
102
+ },
103
+ changed: function(t, e) {
104
+ if (this.getMap())
105
+ switch (t) {
106
+ case "marker":
107
+ case "minClusterSize":
108
+ case "gridSize":
109
+ case "averageCenter":
110
+ this._redraw();
111
+ break;
112
+ case "indexGenerator":
113
+ case "icons":
114
+ this._clusters.forEach(function(n) {
115
+ n.updateIcon();
116
+ });
117
+ break;
118
+ case "maxZoom":
119
+ this._clusters.forEach(function(n) {
120
+ n.getCount() > 1 && n.checkByZoomAndMinClusterSize();
121
+ });
122
+ break;
123
+ case "stylingFunction":
124
+ this._clusters.forEach(function(n) {
125
+ n.updateCount();
126
+ });
127
+ break;
128
+ case "disableClickZoom":
129
+ let s = "enableClickZoom";
130
+ e && (s = "disableClickZoom"), this._clusters.forEach(function(n) {
131
+ n[s]();
132
+ });
133
+ break;
134
+ }
135
+ },
136
+ _createClusters: function() {
137
+ const t = this.getMap();
138
+ if (!t) return;
139
+ const e = t.getBounds(), s = this.getMarkers();
140
+ for (let n = 0, r = s.length; n < r; n++) {
141
+ const o = s[n], c = o.getPosition();
142
+ if (!e.hasLatLng(c)) continue;
143
+ this._getClosestCluster(c).addMarker(o), this._markerRelations.push(
144
+ i.maps.Event.addListener(
145
+ o,
146
+ "dragend",
147
+ i.maps.Util.bind(this._onDragEnd, this)
148
+ )
149
+ );
150
+ }
151
+ },
152
+ _updateClusters: function() {
153
+ const t = this._clusters;
154
+ for (let e = 0, s = t.length; e < s; e++)
155
+ t[e].updateCluster();
156
+ },
157
+ _clearClusters: function() {
158
+ const t = this._clusters;
159
+ for (let e = 0, s = t.length; e < s; e++)
160
+ t[e].destroy();
161
+ i.maps.Event.removeListener(this._markerRelations), this._markerRelations = [], this._clusters = [];
162
+ },
163
+ _redraw: function() {
164
+ this._clearClusters(), this._createClusters(), this._updateClusters();
165
+ },
166
+ _getClosestCluster: function(t) {
167
+ const e = this.getProjection(), s = this._clusters;
168
+ let n = null, r = 1 / 0;
169
+ for (let o = 0, c = s.length; o < c; o++) {
170
+ const u = s[o], a = u.getCenter();
171
+ if (u.isInBounds(t)) {
172
+ const l = e.getDistance(a, t);
173
+ l < r && (r = l, n = u);
174
+ }
175
+ }
176
+ return n || (n = new h(this), this._clusters.push(n)), n;
177
+ },
178
+ _onIdle: function() {
179
+ this._redraw();
180
+ },
181
+ _onDragEnd: function() {
182
+ this._redraw();
183
+ }
184
+ });
185
+ const h = function(t) {
186
+ this._clusterCenter = null, this._clusterBounds = null, this._clusterMarker = null, this._relation = null, this._clusterMember = [], this._markerClusters = t;
187
+ };
188
+ return h.prototype = {
189
+ constructor: h,
190
+ addMarker: function(t) {
191
+ if (!this._isMember(t)) {
192
+ if (!this._clusterCenter) {
193
+ const e = t.getPosition();
194
+ this._clusterCenter = e, this._clusterBounds = this._calcBounds(e);
195
+ }
196
+ this._clusterMember.push(t);
197
+ }
198
+ },
199
+ destroy: function() {
200
+ i.maps.Event.removeListener(this._relation);
201
+ const t = this._clusterMember;
202
+ for (let e = 0, s = t.length; e < s; e++)
203
+ t[e].setMap(null);
204
+ this._clusterMarker.setMap(null), this._clusterMarker = null, this._clusterCenter = null, this._clusterBounds = null, this._relation = null, this._clusterMember = [];
205
+ },
206
+ getCenter: function() {
207
+ return this._clusterCenter;
208
+ },
209
+ getBounds: function() {
210
+ return this._clusterBounds;
211
+ },
212
+ getCount: function() {
213
+ return this._clusterMember.length;
214
+ },
215
+ getClusterMember: function() {
216
+ return this._clusterMember;
217
+ },
218
+ isInBounds: function(t) {
219
+ return this._clusterBounds && this._clusterBounds.hasLatLng(t);
220
+ },
221
+ enableClickZoom: function() {
222
+ if (this._relation) return;
223
+ const t = this._markerClusters.getMap();
224
+ this._relation = i.maps.Event.addListener(
225
+ this._clusterMarker,
226
+ "click",
227
+ i.maps.Util.bind(function(e) {
228
+ t.morph(e.coord, t.getZoom() + 1);
229
+ }, this)
230
+ );
231
+ },
232
+ disableClickZoom: function() {
233
+ this._relation && (i.maps.Event.removeListener(this._relation), this._relation = null);
234
+ },
235
+ updateCluster: function() {
236
+ if (!this._clusterMarker) {
237
+ let t;
238
+ this._markerClusters.getAverageCenter() ? t = this._calcAverageCenter(this._clusterMember) : t = this._clusterCenter, this._clusterMarker = new i.maps.Marker({
239
+ position: t,
240
+ map: this._markerClusters.getMap()
241
+ }), this._markerClusters.getDisableClickZoom() || this.enableClickZoom();
242
+ }
243
+ this.updateIcon(), this.updateCount(), this.checkByZoomAndMinClusterSize();
244
+ },
245
+ checkByZoomAndMinClusterSize: function() {
246
+ const t = this._markerClusters, e = t.getMinClusterSize(), s = t.getMaxZoom(), n = t.getMap().getZoom();
247
+ this.getCount() < e ? this._showMember() : (this._hideMember(), s <= n && this._showMember());
248
+ },
249
+ updateCount: function() {
250
+ const t = this._markerClusters.getStylingFunction();
251
+ t && t(this._clusterMarker, this.getCount());
252
+ },
253
+ updateIcon: function() {
254
+ const t = this.getCount();
255
+ let e = this._getIndex(t);
256
+ const s = this._markerClusters.getIcons();
257
+ e = Math.max(e, 0), e = Math.min(e, s.length - 1), this._clusterMarker.setIcon(s[e]);
258
+ },
259
+ _showMember: function() {
260
+ const t = this._markerClusters.getMap(), e = this._clusterMarker, s = this._clusterMember;
261
+ for (let n = 0, r = s.length; n < r; n++)
262
+ s[n].setMap(t);
263
+ e && e.setMap(null);
264
+ },
265
+ _hideMember: function() {
266
+ const t = this._markerClusters.getMap(), e = this._clusterMarker, s = this._clusterMember;
267
+ for (let n = 0, r = s.length; n < r; n++)
268
+ s[n].setMap(null);
269
+ e && !e.getMap() && e.setMap(t);
270
+ },
271
+ _calcBounds: function(t) {
272
+ const e = this._markerClusters.getMap(), s = new i.maps.LatLngBounds(t.clone(), t.clone()), n = e.getBounds(), r = e.getProjection(), o = r.fromCoordToOffset(n.getNE()), c = r.fromCoordToOffset(n.getSW()), u = r.fromCoordToOffset(s.getNE()), a = r.fromCoordToOffset(s.getSW()), l = this._markerClusters.getGridSize() / 2;
273
+ u.add(l, -l), a.add(-l, l);
274
+ const f = Math.min(o.x, u.x), _ = Math.max(o.y, u.y), g = Math.max(c.x, a.x), p = Math.min(c.y, a.y), d = r.fromOffsetToCoord(new i.maps.Point(f, _)), C = r.fromOffsetToCoord(new i.maps.Point(g, p));
275
+ return new i.maps.LatLngBounds(C, d);
276
+ },
277
+ _getIndex: function(t) {
278
+ const e = this._markerClusters.getIndexGenerator();
279
+ if (i.maps.Util.isFunction(e))
280
+ return e(t);
281
+ if (i.maps.Util.isArray(e)) {
282
+ let s = 0;
283
+ for (let n = 0, r = e.length; n < r; n++) {
284
+ const o = e[n];
285
+ if (t < o) break;
286
+ s++;
287
+ }
288
+ return s;
289
+ }
290
+ return 0;
291
+ },
292
+ _isMember: function(t) {
293
+ return this._clusterMember.indexOf(t) !== -1;
294
+ },
295
+ _calcAverageCenter: function(t) {
296
+ const e = t.length, s = [0, 0];
297
+ for (let n = 0; n < e; n++)
298
+ s[0] += t[n].position.x, s[1] += t[n].position.y;
299
+ return s[0] /= e, s[1] /= e, new i.maps.Point(s[0], s[1]);
300
+ }
301
+ }, m;
302
+ }
303
+ export {
304
+ M as makeMarkerClustering
305
+ };