seat-editor 3.4.7 → 3.5.0

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 (108) hide show
  1. package/dist/app/constant.d.ts +1 -1
  2. package/dist/app/graph-view/page.d.ts +1 -0
  3. package/dist/app/graph-view/page.js +343 -0
  4. package/dist/app/graph-view/page.jsx +445 -0
  5. package/dist/app/graph-view-new/constant.d.ts +581 -0
  6. package/dist/app/graph-view-new/constant.js +6973 -0
  7. package/dist/app/graph-view-new/page.d.ts +1 -0
  8. package/dist/app/graph-view-new/page.js +71 -0
  9. package/dist/app/graph-view-new/page.jsx +98 -0
  10. package/dist/app/new-board/page.js +43 -7
  11. package/dist/app/new-board/page.jsx +45 -12
  12. package/dist/components/button-tools/index.js +7 -5
  13. package/dist/components/button-tools/index.jsx +21 -9
  14. package/dist/components/form-tools/label.js +9 -20
  15. package/dist/components/form-tools/label.jsx +38 -28
  16. package/dist/components/form-tools/shape.js +5 -5
  17. package/dist/components/form-tools/shape.jsx +8 -8
  18. package/dist/components/layer-v3/index.js +44 -3
  19. package/dist/components/layer-v3/index.jsx +120 -3
  20. package/dist/components/layer-v4/index.js +3 -2
  21. package/dist/components/layer-v4/index.jsx +3 -2
  22. package/dist/components/layer-v5/constant.d.ts +60 -0
  23. package/dist/components/layer-v5/constant.js +93 -0
  24. package/dist/components/layer-v5/index.d.ts +24 -0
  25. package/dist/components/layer-v5/index.js +927 -0
  26. package/dist/components/layer-v5/index.jsx +1049 -0
  27. package/dist/features/board-v3/index.js +350 -72
  28. package/dist/features/board-v3/index.jsx +369 -75
  29. package/dist/features/board-v3/resize-element.js +5 -0
  30. package/dist/features/board-v3/utils.d.ts +8 -0
  31. package/dist/features/board-v3/utils.js +23 -7
  32. package/dist/features/package/index.d.ts +2 -0
  33. package/dist/features/package/index.js +1 -1
  34. package/dist/features/package/index.jsx +6 -1
  35. package/dist/features/panel/index.d.ts +8 -0
  36. package/dist/features/panel/index.js +160 -38
  37. package/dist/features/panel/index.jsx +173 -46
  38. package/dist/features/panel/polygon.d.ts +2 -0
  39. package/dist/features/panel/polygon.js +44 -0
  40. package/dist/features/panel/polygon.jsx +70 -0
  41. package/dist/features/panel/select-tool.js +3 -0
  42. package/dist/features/panel/select-tool.jsx +3 -0
  43. package/dist/features/panel/selected-group.js +24 -26
  44. package/dist/features/panel/selected-group.jsx +56 -51
  45. package/dist/features/panel/text-tool.js +17 -2
  46. package/dist/features/panel/text-tool.jsx +19 -2
  47. package/dist/features/panel/upload-tool.js +17 -3
  48. package/dist/features/panel/upload-tool.jsx +23 -4
  49. package/dist/features/side-tool/index.js +43 -6
  50. package/dist/features/side-tool/index.jsx +47 -10
  51. package/dist/features/view-only-4/connect-handle.d.ts +13 -0
  52. package/dist/features/view-only-4/connect-handle.js +23 -0
  53. package/dist/features/view-only-4/connect-handle.jsx +30 -0
  54. package/dist/features/view-only-4/connection-layer.d.ts +21 -0
  55. package/dist/features/view-only-4/connection-layer.js +219 -0
  56. package/dist/features/view-only-4/connection-layer.jsx +291 -0
  57. package/dist/features/view-only-4/index.d.ts +99 -0
  58. package/dist/features/view-only-4/index.js +684 -0
  59. package/dist/features/view-only-4/index.jsx +722 -0
  60. package/dist/features/view-only-4/integration-guide.d.ts +0 -0
  61. package/dist/features/view-only-4/integration-guide.js +0 -0
  62. package/dist/features/view-only-4/use-connection-graph.d.ts +41 -0
  63. package/dist/features/view-only-4/use-connection-graph.js +182 -0
  64. package/dist/features/view-only-4/utils.d.ts +74 -0
  65. package/dist/features/view-only-4/utils.js +106 -0
  66. package/dist/features/view-only-5/connect-handle.d.ts +30 -0
  67. package/dist/features/view-only-5/connect-handle.js +88 -0
  68. package/dist/features/view-only-5/connect-handle.jsx +96 -0
  69. package/dist/features/view-only-5/connection-layer.d.ts +34 -0
  70. package/dist/features/view-only-5/connection-layer.js +182 -0
  71. package/dist/features/view-only-5/connection-layer.jsx +265 -0
  72. package/dist/features/view-only-5/index.d.ts +102 -0
  73. package/dist/features/view-only-5/index.js +585 -0
  74. package/dist/features/view-only-5/index.jsx +614 -0
  75. package/dist/features/view-only-5/use-connection-graph.d.ts +57 -0
  76. package/dist/features/view-only-5/use-connection-graph.js +196 -0
  77. package/dist/features/view-only-5/utils.d.ts +52 -0
  78. package/dist/features/view-only-5/utils.js +80 -0
  79. package/dist/features/view-only-6/connect-handle.d.ts +13 -0
  80. package/dist/features/view-only-6/connect-handle.js +20 -0
  81. package/dist/features/view-only-6/connect-handle.jsx +21 -0
  82. package/dist/features/view-only-6/connection-layer.d.ts +22 -0
  83. package/dist/features/view-only-6/connection-layer.js +191 -0
  84. package/dist/features/view-only-6/connection-layer.jsx +244 -0
  85. package/dist/features/view-only-6/index.d.ts +99 -0
  86. package/dist/features/view-only-6/index.js +687 -0
  87. package/dist/features/view-only-6/index.jsx +724 -0
  88. package/dist/features/view-only-6/use-connection-graph.d.ts +26 -0
  89. package/dist/features/view-only-6/use-connection-graph.js +103 -0
  90. package/dist/features/view-only-6/utils.d.ts +66 -0
  91. package/dist/features/view-only-6/utils.js +96 -0
  92. package/dist/features/view-only-7/connect-handle.d.ts +13 -0
  93. package/dist/features/view-only-7/connect-handle.js +23 -0
  94. package/dist/features/view-only-7/connect-handle.jsx +30 -0
  95. package/dist/features/view-only-7/connection-layer.d.ts +22 -0
  96. package/dist/features/view-only-7/connection-layer.js +165 -0
  97. package/dist/features/view-only-7/connection-layer.jsx +217 -0
  98. package/dist/features/view-only-7/index.d.ts +99 -0
  99. package/dist/features/view-only-7/index.js +687 -0
  100. package/dist/features/view-only-7/index.jsx +724 -0
  101. package/dist/features/view-only-7/use-connection-graph.d.ts +26 -0
  102. package/dist/features/view-only-7/use-connection-graph.js +104 -0
  103. package/dist/features/view-only-7/utils.d.ts +69 -0
  104. package/dist/features/view-only-7/utils.js +144 -0
  105. package/dist/index.d.ts +2 -1
  106. package/dist/index.js +2 -1
  107. package/dist/seat-editor.css +1 -1
  108. package/package.json +1 -1
@@ -0,0 +1,927 @@
1
+ "use client";
2
+ import { createElement as _createElement } from "react";
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ import { isEmpty, omit } from "lodash";
5
+ import { arcByDirection, distributeWithSpacing } from "../layer-v3/utils";
6
+ import { PRIVILEGED_TAGS, tagsDummy } from "./constant";
7
+ import { useAppSelector } from "../../hooks/use-redux";
8
+ import { RsvpIcons } from "../../features/board-v3/icons";
9
+ const toKebabCase = (str) => str.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
10
+ const iconNames = [
11
+ "upcoming",
12
+ "late",
13
+ "overtime",
14
+ "overlapping",
15
+ "hold",
16
+ "reserved",
17
+ "armchair",
18
+ "cheque",
19
+ "people",
20
+ ];
21
+ const dummyIconTags = iconNames === null || iconNames === void 0 ? void 0 : iconNames.map((item) => {
22
+ const Icon = RsvpIcons === null || RsvpIcons === void 0 ? void 0 : RsvpIcons[item];
23
+ return {
24
+ key: item,
25
+ icon: _jsx(Icon, {}),
26
+ };
27
+ });
28
+ const getIconFromId = (data) => {
29
+ const id = String(data);
30
+ let hash = 0;
31
+ for (let i = 0; i < id.length; i++) {
32
+ hash += id.charCodeAt(i);
33
+ }
34
+ return iconNames[hash % iconNames.length];
35
+ };
36
+ const Layers = ({ components, selectedTable, iconTags, eventMatchTable, onHighlightGroup, onForceRestoreGroup, selectedTableColor, privilegedTags = [], }) => {
37
+ const { isShowTagType } = useAppSelector((state) => state.board);
38
+ const showLabels = !["type-1", "type-2"].includes(isShowTagType) && !iconTags;
39
+ const renderShape = (item) => {
40
+ var _a, _b, _c, _d, _e, _f, _g;
41
+ const { id, x, y, width, height, fill, opacity, rotate = 0, rotation, shape, text, stroke, strokeWidth, labels, fontSize, fontColor, seatFill, src, tags, gapTags, label, points, seatPositions, radius, } = item;
42
+ const fontSizeFromLabel = (_a = labels === null || labels === void 0 ? void 0 : labels[0]) === null || _a === void 0 ? void 0 : _a.fontSize;
43
+ const renderTags = (data) => {
44
+ var _a;
45
+ const tags = data !== null && data !== void 0 ? data : tagsDummy(((_a = labels === null || labels === void 0 ? void 0 : labels[0]) === null || _a === void 0 ? void 0 : _a.label) || "Table", getIconFromId(id));
46
+ const privileged = !isEmpty(privilegedTags)
47
+ ? privilegedTags
48
+ : isShowTagType === "type-1"
49
+ ? PRIVILEGED_TAGS["CURRENT_TIME"]
50
+ : isShowTagType === "type-2"
51
+ ? PRIVILEGED_TAGS["NEXT_3_RESERVATION"]
52
+ : undefined;
53
+ if (tags && (tags === null || tags === void 0 ? void 0 : tags.length) > 0) {
54
+ const scaleDefault = Number(fontSize || fontSizeFromLabel || 12) / 12;
55
+ const gapBetweenTags = Number(gapTags || 20) * scaleDefault;
56
+ const defaultFontSize = Number(fontSize || fontSizeFromLabel || 12);
57
+ // Hitung total tinggi semua grup tag (buat center vertikal)
58
+ const totalTagHeight = (tags === null || tags === void 0 ? void 0 : tags.filter((tag) => privileged === null || privileged === void 0 ? void 0 : privileged.find((p) => p.key === tag.key)).reduce((sum, tag) => {
59
+ var _a;
60
+ const items = tag.items || [];
61
+ const isColumn = (_a = tag.direction) === null || _a === void 0 ? void 0 : _a.includes("column");
62
+ const tagHeight = isColumn
63
+ ? items.length * defaultFontSize + 2 * (Number(tag.gap) || 2)
64
+ : defaultFontSize; // horizontal = 1 line
65
+ return sum + tagHeight + gapBetweenTags;
66
+ }, 0)) - gapBetweenTags;
67
+ const startY = Number(height) / 4 - totalTagHeight / 3; // titik awal supaya semua di tengah
68
+ let currentY = startY;
69
+ return tags
70
+ .filter((tag) => privileged === null || privileged === void 0 ? void 0 : privileged.find((p) => p.key === tag.key))
71
+ .map((tag, tagIndex) => {
72
+ var _a;
73
+ const itemsPriv = privileged[tagIndex].items;
74
+ const direction = ((_a = tag.direction) === null || _a === void 0 ? void 0 : _a.includes("column"))
75
+ ? "column"
76
+ : "flex";
77
+ const gap = Number(tag.gap || 2) * scaleDefault;
78
+ const items = tag.items || [];
79
+ const fontSize = Number(defaultFontSize);
80
+ const isColumn = direction === "column";
81
+ const groupHeight = isColumn
82
+ ? items.length * fontSize + 2 * gap
83
+ : fontSize;
84
+ const centerX = width / 2;
85
+ const centerY = currentY + groupHeight;
86
+ // naikkan posisi Y untuk grup berikutnya
87
+ currentY += groupHeight + gapBetweenTags;
88
+ const elements = items
89
+ .filter((item) => itemsPriv.includes(item.type))
90
+ .map((item, i) => {
91
+ var _a, _b;
92
+ const offsetY = isColumn
93
+ ? i * (fontSize + gap) - groupHeight / 2 + fontSize / 2
94
+ : 0;
95
+ const offsetX = !isColumn
96
+ ? i * (fontSize + gap) - (1 * (fontSize + gap)) / 2
97
+ : 0;
98
+ const posX = centerX + offsetX + Number((_a = tag.offsetX) !== null && _a !== void 0 ? _a : 0);
99
+ const posY = centerY + offsetY + Number((_b = tag.offsetY) !== null && _b !== void 0 ? _b : 0);
100
+ const renderSymbol = (symbol) => {
101
+ if (!symbol)
102
+ return null;
103
+ const { position = "right", size = (item === null || item === void 0 ? void 0 : item.fontSize) || Number(fontSize), gap: symbolGap = 0, } = symbol;
104
+ const sizeFont = (item === null || item === void 0 ? void 0 : item.fontSize) || Number(fontSize) / 3;
105
+ let offsetSymbolX = 0;
106
+ let offsetSymbolY = 0;
107
+ switch (position) {
108
+ case "right":
109
+ offsetSymbolX = size + symbolGap;
110
+ break;
111
+ case "left":
112
+ offsetSymbolX = -(size + symbolGap);
113
+ break;
114
+ case "top":
115
+ offsetSymbolY = -(size + symbolGap);
116
+ break;
117
+ case "bottom":
118
+ offsetSymbolY = size + symbolGap;
119
+ break;
120
+ case "right-top":
121
+ offsetSymbolX = size + symbolGap;
122
+ offsetSymbolY = -(size / 4);
123
+ break;
124
+ case "right-bottom":
125
+ offsetSymbolX = size + symbolGap;
126
+ offsetSymbolY = size / 4;
127
+ break;
128
+ case "left-top":
129
+ offsetSymbolX = -size - symbolGap;
130
+ offsetSymbolY = -(size / 4);
131
+ break;
132
+ case "left-bottom":
133
+ offsetSymbolX = -size - symbolGap;
134
+ offsetSymbolY = size / 4;
135
+ break;
136
+ }
137
+ return (_createElement("tspan", Object.assign({}, symbol, { key: `symbol-${tagIndex}-${i}`, x: posX + offsetSymbolX, y: posY + offsetSymbolY, textAnchor: "middle", dominantBaseline: "middle", fontSize: `${sizeFont}px` }), symbol.value));
138
+ };
139
+ if (item.type === "icon") {
140
+ const icons = iconTags !== null && iconTags !== void 0 ? iconTags : dummyIconTags;
141
+ const iconTag = icons === null || icons === void 0 ? void 0 : icons.find((icon) => icon.key === item.value);
142
+ if (!iconTag)
143
+ return null;
144
+ const scale = defaultFontSize / 12;
145
+ return (_createElement("g", Object.assign({}, item, { key: `icon-${tagIndex}-${i}`, transform: `translate(${posX - defaultFontSize}, ${posY - defaultFontSize / 2}) scale(${scale})` }), iconTag.icon));
146
+ }
147
+ if (item.type === "text") {
148
+ return (_createElement("text", Object.assign({}, item, { key: `text-${tagIndex}-${i}`, x: posX, y: posY, textAnchor: "middle", dominantBaseline: "middle", fontSize: defaultFontSize }),
149
+ item.value,
150
+ " ",
151
+ renderSymbol(item === null || item === void 0 ? void 0 : item.symbol)));
152
+ }
153
+ return null;
154
+ });
155
+ return (_jsx("g", { pointerEvents: "none", children: elements }, `group-${tagIndex}`));
156
+ });
157
+ }
158
+ };
159
+ let commonProps = {
160
+ fill,
161
+ opacity,
162
+ stroke,
163
+ strokeWidth,
164
+ };
165
+ const hasSelected = (selectedTable === null || selectedTable === void 0 ? void 0 : selectedTable.id) === id;
166
+ if (hasSelected) {
167
+ const eventSelectedStyles = eventMatchTable === null || eventMatchTable === void 0 ? void 0 : eventMatchTable.find((style) => style.event === "selected");
168
+ commonProps = Object.assign(Object.assign({}, commonProps), eventSelectedStyles === null || eventSelectedStyles === void 0 ? void 0 : eventSelectedStyles.properties);
169
+ }
170
+ // helper: highlight / unhighlight dengan enter-counter
171
+ let properties = {};
172
+ const highlightGroup = (group, eventType) => {
173
+ if (!group)
174
+ return;
175
+ onHighlightGroup === null || onHighlightGroup === void 0 ? void 0 : onHighlightGroup(group, eventType);
176
+ eventMatchTable === null || eventMatchTable === void 0 ? void 0 : eventMatchTable.forEach((styleConfig) => {
177
+ if (styleConfig.event === eventType) {
178
+ properties = omit(styleConfig.properties || {}, "points");
179
+ const hasStroke = (properties === null || properties === void 0 ? void 0 : properties.stroke) || (commonProps === null || commonProps === void 0 ? void 0 : commonProps.stroke);
180
+ const hasStrokeWidth = properties === null || properties === void 0 ? void 0 : properties.strokeWidth;
181
+ if (hasStrokeWidth && !hasStroke) {
182
+ properties.stroke = "#E1E3EA";
183
+ }
184
+ }
185
+ });
186
+ if (isEmpty(properties))
187
+ return;
188
+ // counter
189
+ const count = Number(group.dataset.dragEnterCount || "0") + 1;
190
+ group.dataset.dragEnterCount = String(count);
191
+ // selalu ubah warna, tapi simpan original hanya sekali
192
+ ["rect", "circle"].forEach((selector) => {
193
+ const el = group.querySelector(selector);
194
+ if (!el)
195
+ return;
196
+ Object.entries(properties).forEach(([key]) => {
197
+ el.dataset[key] = el.getAttribute(key) || "";
198
+ });
199
+ Object.entries(properties).forEach(([key, value]) => {
200
+ el.setAttribute(toKebabCase(key), value);
201
+ });
202
+ });
203
+ };
204
+ const unhighlightGroup = (group) => {
205
+ if (!group)
206
+ return;
207
+ const count = Math.max(0, Number(group.dataset.dragEnterCount || "0") - 1);
208
+ group.dataset.dragEnterCount = String(count);
209
+ // restore hanya saat counter = 0
210
+ if (count === 0) {
211
+ ["rect", "circle"].forEach((selector) => {
212
+ const el = group.querySelector(selector);
213
+ if (!el)
214
+ return;
215
+ // bersihkan data
216
+ const dataset = el.dataset;
217
+ Object.entries(dataset).forEach(([key, value]) => {
218
+ el.setAttribute(toKebabCase(key), value);
219
+ delete el.dataset[key];
220
+ properties = {};
221
+ });
222
+ });
223
+ delete group.dataset.dragEnterCount;
224
+ }
225
+ };
226
+ const forceRestoreGroup = (group, type) => {
227
+ // langsung restore (dipanggil pada drop)
228
+ onForceRestoreGroup === null || onForceRestoreGroup === void 0 ? void 0 : onForceRestoreGroup(group, type);
229
+ ["rect", "circle"].forEach((selector) => {
230
+ const el = group === null || group === void 0 ? void 0 : group.querySelector(selector);
231
+ if (!el)
232
+ return;
233
+ const dataset = el.dataset;
234
+ Object.entries(dataset).forEach(([key, value]) => {
235
+ el.setAttribute(toKebabCase(key), value);
236
+ delete el.dataset[key];
237
+ properties = {};
238
+ });
239
+ });
240
+ delete group.dataset.dragEnterCount;
241
+ };
242
+ const transformRotate = `rotate(${rotate} ${x + width / 2} ${y + height / 2})`;
243
+ switch (shape) {
244
+ case "square":
245
+ return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, style: { pointerEvents: "all" }, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
246
+ const group = e.currentTarget;
247
+ highlightGroup(group, "dragenter");
248
+ }, onDragOver: (e) => {
249
+ e.preventDefault(); // agar drop diterima
250
+ }, onDragLeave: (e) => {
251
+ const group = e.currentTarget;
252
+ unhighlightGroup(group);
253
+ }, onDrop: (e) => {
254
+ const group = e.currentTarget;
255
+ // restore langsung dan reset
256
+ forceRestoreGroup(group, "drop");
257
+ }, onPointerOver: (e) => {
258
+ // e.preventDefault(); // penting
259
+ const group = e.currentTarget;
260
+ highlightGroup(group, "pointerover");
261
+ }, onPointerOut: (e) => {
262
+ const group = e.currentTarget;
263
+ unhighlightGroup(group);
264
+ }, onPointerUp: (e) => {
265
+ const group = e.currentTarget;
266
+ // restore langsung dan reset
267
+ forceRestoreGroup(group, "pointerup");
268
+ }, onPointerDown: (e) => {
269
+ const group = e.currentTarget;
270
+ highlightGroup(group, "pointerdown");
271
+ },
272
+ // onPointerEnter={(e) => {
273
+ // const group = e.currentTarget as SVGGElement;
274
+ // highlightGroup(group, "pointerenter");
275
+ // }}
276
+ onPointerLeave: (e) => {
277
+ const group = e.currentTarget;
278
+ unhighlightGroup(group);
279
+ }, onMouseEnter: (e) => {
280
+ // e.preventDefault(); // penting
281
+ const group = e.currentTarget;
282
+ highlightGroup(group, "mouseenter");
283
+ }, onMouseLeave: (e) => {
284
+ const group = e.currentTarget;
285
+ unhighlightGroup(group);
286
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0,0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, fill: fill, rx: radius }, omit(item, ["x", "y", "label", "points", "tags", "seatCount"]), commonProps), `${id}-rect`), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, pointerEvents: "none", children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
287
+ var _a, _b, _c, _d, _e, _f, _g;
288
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
289
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
290
+ return (_createElement("text", Object.assign({ pointerEvents: "none" }, omit(commonProps, [
291
+ "opacity",
292
+ "stroke",
293
+ "strokeWidth",
294
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
295
+ }) }))] }) }, id));
296
+ case "polygon":
297
+ const finalPoint = points.map((p) => `${p.x},${p.y}`).join(" ");
298
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, children: _jsx("g", { transform: `rotate(${rotation}, 0, 0)`, children: _createElement("polygon", Object.assign({}, commonProps, { key: id, points: finalPoint, x: "0", y: "0" })) }) }, id));
299
+ case "circle":
300
+ return (_jsxs("g", { style: { pointerEvents: "all" }, "data-id": id, transform: `translate(${x}, ${y})`, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
301
+ e.preventDefault(); // penting
302
+ const group = e.currentTarget;
303
+ highlightGroup(group, "dragenter");
304
+ }, onDragOver: (e) => {
305
+ e.preventDefault(); // agar drop diterima
306
+ }, onDragLeave: (e) => {
307
+ const group = e.currentTarget;
308
+ unhighlightGroup(group);
309
+ }, onDrop: (e) => {
310
+ e.preventDefault();
311
+ const group = e.currentTarget;
312
+ // restore langsung dan reset
313
+ forceRestoreGroup(group);
314
+ }, onPointerOver: (e) => {
315
+ e.preventDefault(); // penting
316
+ const group = e.currentTarget;
317
+ highlightGroup(group, "pointerover");
318
+ }, onPointerOut: (e) => {
319
+ const group = e.currentTarget;
320
+ unhighlightGroup(group);
321
+ }, onPointerUp: (e) => {
322
+ e.preventDefault();
323
+ const group = e.currentTarget;
324
+ // restore langsung dan reset
325
+ forceRestoreGroup(group);
326
+ }, onMouseDown: (e) => {
327
+ e.preventDefault();
328
+ const group = e.currentTarget;
329
+ highlightGroup(group, "mousedown");
330
+ }, onMouseEnter: (e) => {
331
+ // e.preventDefault(); // penting
332
+ const group = e.currentTarget;
333
+ highlightGroup(group, "mouseenter");
334
+ }, onMouseLeave: (e) => {
335
+ const group = e.currentTarget;
336
+ unhighlightGroup(group);
337
+ }, children: [" ", _jsxs("g", { transform: `rotate(${-rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: Math.min(height, width) / 2, fill: fill }, commonProps, omit(item, ["x", "y", "label", "points", "tags", "seatCount"])), id), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
338
+ var _a, _b, _c, _d, _e, _f, _g;
339
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
340
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
341
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
342
+ "opacity",
343
+ "stroke",
344
+ "strokeWidth",
345
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
346
+ }) }))] })] }, id));
347
+ case "table-seat-circle": {
348
+ const seatCount = item.seatCount;
349
+ const openSpace = (_b = item.openSpace) !== null && _b !== void 0 ? _b : 0;
350
+ // LOCAL SPACE (tanpa x,y)
351
+ const centerX = width / 2;
352
+ const centerY = height / 2;
353
+ // meja
354
+ const tableRadius = Math.min(width, height) / 2;
355
+ // seat statis
356
+ const seatRadius = 10;
357
+ const fullAngle = Math.PI * 2;
358
+ const availableAngle = fullAngle * (1 - openSpace);
359
+ const angleStart = (fullAngle - availableAngle) / 2;
360
+ const angleStep = availableAngle / seatCount;
361
+ const seatCircles = Array.from({ length: seatCount }, (_, i) => {
362
+ const angle = angleStart + i * angleStep;
363
+ const cx = centerX + (tableRadius + seatRadius) * Math.cos(angle);
364
+ const cy = centerY + (tableRadius + seatRadius) * Math.sin(angle);
365
+ return { cx, cy };
366
+ });
367
+ return (_jsx("g", { style: { pointerEvents: "all" }, "data-id": id, id: `${id}`, transform: `translate(${x}, ${y})`, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
368
+ e.preventDefault(); // penting
369
+ const group = e.currentTarget;
370
+ highlightGroup(group, "dragenter");
371
+ }, onDragOver: (e) => {
372
+ e.preventDefault(); // agar drop diterima
373
+ }, onDragLeave: (e) => {
374
+ const group = e.currentTarget;
375
+ unhighlightGroup(group);
376
+ }, onDrop: (e) => {
377
+ e.preventDefault();
378
+ const group = e.currentTarget;
379
+ // restore langsung dan reset
380
+ forceRestoreGroup(group);
381
+ }, onPointerOver: (e) => {
382
+ e.preventDefault(); // penting
383
+ const group = e.currentTarget;
384
+ highlightGroup(group, "pointerover");
385
+ }, onPointerOut: (e) => {
386
+ const group = e.currentTarget;
387
+ unhighlightGroup(group);
388
+ }, onPointerUp: (e) => {
389
+ e.preventDefault();
390
+ const group = e.currentTarget;
391
+ // restore langsung dan reset
392
+ forceRestoreGroup(group);
393
+ }, onMouseDown: (e) => {
394
+ e.preventDefault();
395
+ const group = e.currentTarget;
396
+ highlightGroup(group, "mousedown");
397
+ }, onMouseEnter: (e) => {
398
+ // e.preventDefault(); // penting
399
+ const group = e.currentTarget;
400
+ highlightGroup(group, "mouseenter");
401
+ }, onMouseLeave: (e) => {
402
+ const group = e.currentTarget;
403
+ unhighlightGroup(group);
404
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: centerX, cy: centerY, r: tableRadius, fill: selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill }, omit(item, ["x", "y", "label", "points", "tags", "seatCount"]), commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seatCircles.map(({ cx, cy }, i) => (_jsx("circle", { cx: cx, cy: cy, r: seatRadius, fill: seatFill, className: item === null || item === void 0 ? void 0 : item.className }, `${id}-seat-${i}`))) }), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
405
+ var _a, _b, _c, _d;
406
+ return (_jsx("text", { x: width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: transformRotate, children: _ === null || _ === void 0 ? void 0 : _.label }, `${id}-label-${index}`));
407
+ }) }))] }) }, id));
408
+ }
409
+ case "table-seat-rect-circle": {
410
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
411
+ const base = clamp(Math.min(width, height) * 0.08, 12, 28);
412
+ const tableRadius = Math.min(width, height) / 2;
413
+ const seatSizeTB = {
414
+ w: base * 1.8, // lebih panjang
415
+ h: base * 0.9, // lebih tipis
416
+ };
417
+ const seatSizeLR = {
418
+ w: base * 0.9, // lebih tipis
419
+ h: base * 1.8, // lebih panjang
420
+ };
421
+ const openSpace = item.openSpace || 0;
422
+ const seatRadius = Math.min(width, height) * 0.2;
423
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
424
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
425
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
426
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
427
+ // split seats evenly on top and bottom
428
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
429
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
430
+ const availableWidth = width * (1 - openSpace);
431
+ const availableHeight = height * (1 - openSpace);
432
+ const spacingWidth = availableWidth / seatCountTopBottom;
433
+ const spacingHeight = availableHeight / seatCountLeftRight;
434
+ const topSeats = distributeWithSpacing({
435
+ start: 0,
436
+ length: width,
437
+ count: top,
438
+ radius: seatRadius,
439
+ spacing: spacingWidth,
440
+ }).map((cx) => ({
441
+ x: cx - seatSizeTB.w / 2,
442
+ y: -seatSizeTB.h,
443
+ width: seatSizeTB.w,
444
+ height: seatSizeTB.h,
445
+ id: "top",
446
+ }));
447
+ const bottomSeats = distributeWithSpacing({
448
+ start: 0,
449
+ length: width,
450
+ count: bottom,
451
+ radius: seatRadius,
452
+ spacing: spacingWidth,
453
+ }).map((cx) => ({
454
+ x: cx - seatSizeTB.w / 2,
455
+ y: height,
456
+ width: seatSizeTB.w,
457
+ height: seatSizeTB.h,
458
+ id: "bottom",
459
+ }));
460
+ const leftSeats = distributeWithSpacing({
461
+ start: 0,
462
+ length: height,
463
+ count: left,
464
+ radius: seatRadius,
465
+ spacing: spacingHeight,
466
+ }).map((cy) => ({
467
+ x: -seatSizeLR.w,
468
+ y: cy - seatSizeLR.h / 2,
469
+ width: seatSizeLR.w,
470
+ height: seatSizeLR.h,
471
+ id: "left",
472
+ }));
473
+ const rightSeats = distributeWithSpacing({
474
+ start: 0,
475
+ length: height,
476
+ count: right,
477
+ radius: seatRadius,
478
+ spacing: spacingHeight,
479
+ }).map((cy) => ({
480
+ x: width,
481
+ y: cy - seatSizeLR.h / 2,
482
+ width: seatSizeLR.w,
483
+ height: seatSizeLR.h,
484
+ id: "right",
485
+ }));
486
+ const seats = [
487
+ ...topSeats,
488
+ ...bottomSeats,
489
+ ...leftSeats,
490
+ ...rightSeats,
491
+ ];
492
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
493
+ e.preventDefault(); // penting
494
+ const group = e.currentTarget;
495
+ highlightGroup(group, "dragenter");
496
+ }, onDragOver: (e) => {
497
+ e.preventDefault(); // agar drop diterima
498
+ }, onDragLeave: (e) => {
499
+ const group = e.currentTarget;
500
+ unhighlightGroup(group);
501
+ }, onDrop: (e) => {
502
+ e.preventDefault();
503
+ const group = e.currentTarget;
504
+ // restore langsung dan reset
505
+ forceRestoreGroup(group);
506
+ }, onPointerOver: (e) => {
507
+ e.preventDefault(); // penting
508
+ const group = e.currentTarget;
509
+ highlightGroup(group, "pointerover");
510
+ }, onPointerOut: (e) => {
511
+ const group = e.currentTarget;
512
+ unhighlightGroup(group);
513
+ }, onPointerUp: (e) => {
514
+ e.preventDefault();
515
+ const group = e.currentTarget;
516
+ // restore langsung dan reset
517
+ forceRestoreGroup(group);
518
+ }, onMouseDown: (e) => {
519
+ e.preventDefault();
520
+ const group = e.currentTarget;
521
+ highlightGroup(group, "mousedown");
522
+ }, onMouseEnter: (e) => {
523
+ // e.preventDefault(); // penting
524
+ const group = e.currentTarget;
525
+ highlightGroup(group, "mouseenter");
526
+ }, onMouseLeave: (e) => {
527
+ const group = e.currentTarget;
528
+ unhighlightGroup(group);
529
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("circle", Object.assign({ cx: width / 2, cy: height / 2, r: tableRadius, fill: fill }, omit(item, ["x", "y", "label", "points", "tags", "seatCount"]), commonProps)), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill, className: item === null || item === void 0 ? void 0 : item.className }, `${id}-seat-${i}`))) }, `${id}-seats`), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
530
+ var _a, _b, _c, _d, _e, _f, _g;
531
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
532
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
533
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
534
+ "opacity",
535
+ "stroke",
536
+ "strokeWidth",
537
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
538
+ }) }))] }) }, id));
539
+ }
540
+ case "table-seat-square": {
541
+ const openSpace = item.openSpace || 0; // from 0 to 0.9
542
+ const r = 10;
543
+ const seatPositions = item.seatPositions;
544
+ const topCount = (_c = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) !== null && _c !== void 0 ? _c : 0;
545
+ const bottomCount = (_d = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) !== null && _d !== void 0 ? _d : 0;
546
+ const leftCount = (_e = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) !== null && _e !== void 0 ? _e : 0;
547
+ const rightCount = (_f = seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) !== null && _f !== void 0 ? _f : 0;
548
+ // split seats evenly on top and bottom
549
+ const seatCountTopBottom = Math.ceil(Math.max(topCount, bottomCount) / 2);
550
+ const seatCountLeftRight = Math.ceil(Math.max(leftCount, rightCount) / 2);
551
+ const availableWidth = width * (1 - openSpace);
552
+ const availableHeight = height * (1 - openSpace);
553
+ const spacingWidth = availableWidth / seatCountTopBottom;
554
+ const spacingHeight = availableHeight / seatCountLeftRight;
555
+ const topXs = distributeWithSpacing({
556
+ start: x,
557
+ length: width,
558
+ count: topCount,
559
+ radius: r,
560
+ spacing: spacingWidth,
561
+ });
562
+ const topSeats = topXs.map((cx) => ({ cx, cy: y - r, id: "top" }));
563
+ // TOP
564
+ const bottomSeats = distributeWithSpacing({
565
+ start: x,
566
+ length: width,
567
+ count: bottomCount,
568
+ radius: r,
569
+ spacing: spacingWidth,
570
+ }).map((cx) => ({
571
+ cx: cx,
572
+ cy: y + height + r,
573
+ id: "bottom",
574
+ }));
575
+ const leftYs = distributeWithSpacing({
576
+ start: y,
577
+ length: height,
578
+ count: leftCount,
579
+ radius: r,
580
+ spacing: spacingHeight,
581
+ });
582
+ const leftSeats = leftYs.map((cy) => ({ cx: x - r, cy, id: "left" }));
583
+ const rightSeats = distributeWithSpacing({
584
+ start: y,
585
+ length: height,
586
+ count: rightCount,
587
+ radius: r,
588
+ spacing: spacingHeight,
589
+ }).map((cy) => ({
590
+ cx: x + width + r,
591
+ cy,
592
+ id: "right",
593
+ }));
594
+ return (_jsx("g", { "data-id": id, transform: `translate(${x}, ${y})`, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
595
+ e.preventDefault(); // penting
596
+ const group = e.currentTarget;
597
+ highlightGroup(group, "dragenter");
598
+ }, onDragOver: (e) => {
599
+ e.preventDefault(); // agar drop diterima
600
+ }, onDragLeave: (e) => {
601
+ const group = e.currentTarget;
602
+ unhighlightGroup(group);
603
+ }, onDrop: (e) => {
604
+ e.preventDefault();
605
+ const group = e.currentTarget;
606
+ // restore langsung dan reset
607
+ forceRestoreGroup(group);
608
+ }, onPointerOver: (e) => {
609
+ e.preventDefault(); // penting
610
+ const group = e.currentTarget;
611
+ highlightGroup(group, "pointerover");
612
+ }, onPointerOut: (e) => {
613
+ const group = e.currentTarget;
614
+ unhighlightGroup(group);
615
+ }, onPointerUp: (e) => {
616
+ e.preventDefault();
617
+ const group = e.currentTarget;
618
+ // restore langsung dan reset
619
+ forceRestoreGroup(group);
620
+ }, onMouseDown: (e) => {
621
+ e.preventDefault();
622
+ const group = e.currentTarget;
623
+ highlightGroup(group, "mousedown");
624
+ }, onMouseEnter: (e) => {
625
+ // e.preventDefault(); // penting
626
+ const group = e.currentTarget;
627
+ highlightGroup(group, "mouseenter");
628
+ }, onMouseLeave: (e) => {
629
+ const group = e.currentTarget;
630
+ unhighlightGroup(group);
631
+ }, children: _jsxs("g", { transform: `rotate(${rotate}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height }, commonProps, { fill: selectedTableColor !== null && selectedTableColor !== void 0 ? selectedTableColor : fill }, omit(item, ["x", "y", "label", "points", "tags", "seatCount"]))), renderTags(tags), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: [...topSeats, ...bottomSeats, ...leftSeats, ...rightSeats].map(({ cx, cy, id }, i) => (_jsx("circle", { id: `seat-${id}`, cx: cx, cy: cy, r: r, fill: seatFill, className: item === null || item === void 0 ? void 0 : item.className }, `${id}-seat-${i}`))) }, `${id}-seats`), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
632
+ var _a, _b, _c, _d, _e, _f, _g;
633
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
634
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
635
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
636
+ "opacity",
637
+ "stroke",
638
+ "strokeWidth",
639
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
640
+ }) }))] }) }, id));
641
+ }
642
+ case "table-seat-half-square": {
643
+ const openSpace = item.openSpace || 0;
644
+ const seatRadius = Math.min(width, height) * 0.15;
645
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
646
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
647
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
648
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
649
+ // split seats evenly on top and bottom
650
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
651
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
652
+ const availableWidth = width * (1 - openSpace);
653
+ const availableHeight = height * (1 - openSpace);
654
+ const spacingWidth = availableWidth / seatCountTopBottom;
655
+ const spacingHeight = availableHeight / seatCountLeftRight;
656
+ const topSeats = distributeWithSpacing({
657
+ start: 0,
658
+ length: width,
659
+ count: top,
660
+ radius: seatRadius,
661
+ spacing: spacingWidth,
662
+ }).map((cx) => ({ cx, cy: seatRadius * 0.1, id: "top" }));
663
+ const bottomSeats = distributeWithSpacing({
664
+ start: 0,
665
+ length: width,
666
+ count: bottom,
667
+ radius: seatRadius,
668
+ spacing: spacingWidth,
669
+ }).map((cx) => ({
670
+ cx,
671
+ cy: height - seatRadius * 0.1,
672
+ id: "bottom",
673
+ }));
674
+ const leftSeats = distributeWithSpacing({
675
+ start: 0,
676
+ length: height,
677
+ count: left,
678
+ radius: seatRadius,
679
+ spacing: spacingHeight,
680
+ }).map((cy) => ({ cx: seatRadius * 0.1, cy, id: "left" }));
681
+ const rightSeats = distributeWithSpacing({
682
+ start: 0,
683
+ length: height,
684
+ count: right,
685
+ radius: seatRadius,
686
+ spacing: spacingHeight,
687
+ }).map((cy) => ({ cx: width - seatRadius * 0.1, cy, id: "right" }));
688
+ const seats = (_g = [
689
+ ...topSeats,
690
+ ...bottomSeats,
691
+ ...leftSeats,
692
+ ...rightSeats,
693
+ ]) === null || _g === void 0 ? void 0 : _g.map((seat) => (Object.assign(Object.assign({}, seat), { d: arcByDirection({
694
+ cx: seat.cx,
695
+ cy: seat.cy,
696
+ r: seatRadius,
697
+ direction: seat.id,
698
+ fraction: 0.4,
699
+ }) })));
700
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
701
+ e.preventDefault(); // penting
702
+ const group = e.currentTarget;
703
+ highlightGroup(group, "dragenter");
704
+ }, onDragOver: (e) => {
705
+ e.preventDefault(); // agar drop diterima
706
+ }, onDragLeave: (e) => {
707
+ const group = e.currentTarget;
708
+ unhighlightGroup(group);
709
+ }, onDrop: (e) => {
710
+ e.preventDefault();
711
+ const group = e.currentTarget;
712
+ // restore langsung dan reset
713
+ forceRestoreGroup(group);
714
+ }, onPointerOver: (e) => {
715
+ e.preventDefault(); // penting
716
+ const group = e.currentTarget;
717
+ highlightGroup(group, "pointerover");
718
+ }, onPointerOut: (e) => {
719
+ const group = e.currentTarget;
720
+ unhighlightGroup(group);
721
+ }, onPointerUp: (e) => {
722
+ e.preventDefault();
723
+ const group = e.currentTarget;
724
+ // restore langsung dan reset
725
+ forceRestoreGroup(group);
726
+ }, onMouseDown: (e) => {
727
+ e.preventDefault();
728
+ const group = e.currentTarget;
729
+ highlightGroup(group, "mousedown");
730
+ }, onMouseEnter: (e) => {
731
+ // e.preventDefault(); // penting
732
+ const group = e.currentTarget;
733
+ highlightGroup(group, "mouseenter");
734
+ }, onMouseLeave: (e) => {
735
+ const group = e.currentTarget;
736
+ unhighlightGroup(group);
737
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill }, omit(item, ["x", "y", "label", "points", "tags", "seatCount"]))), _jsx("g", { "data-seat": `${id}-seats`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ d, id }, i) => (_jsx("path", { id: `seat-${id}`, d: d, fill: seatFill, className: item === null || item === void 0 ? void 0 : item.className }, `${id}-seat-${i}`))) }, `${id}-seats`), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
738
+ var _a, _b, _c, _d, _e, _f, _g;
739
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
740
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
741
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
742
+ "opacity",
743
+ "stroke",
744
+ "strokeWidth",
745
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
746
+ }) }))] }) }, id));
747
+ }
748
+ case "table-seat-rect-square": {
749
+ const clamp = (v, min, max) => Math.max(min, Math.min(max, v));
750
+ const base = clamp(Math.min(width, height) * 0.08, 12, 28);
751
+ const seatSizeTB = {
752
+ w: base * 1.8, // lebih panjang
753
+ h: base * 0.9, // lebih tipis
754
+ };
755
+ const seatSizeLR = {
756
+ w: base * 0.9, // lebih tipis
757
+ h: base * 1.8, // lebih panjang
758
+ };
759
+ const openSpace = item.openSpace || 0;
760
+ const seatRadius = Math.min(width, height) * 0.2;
761
+ const top = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.top) || 0;
762
+ const right = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.right) || 0;
763
+ const bottom = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.bottom) || 0;
764
+ const left = (seatPositions === null || seatPositions === void 0 ? void 0 : seatPositions.left) || 0;
765
+ // split seats evenly on top and bottom
766
+ const seatCountTopBottom = Math.ceil(Math.max(top, bottom) / 2);
767
+ const seatCountLeftRight = Math.ceil(Math.max(left, left) / 2);
768
+ const availableWidth = width * (1 - openSpace);
769
+ const availableHeight = height * (1 - openSpace);
770
+ const spacingWidth = availableWidth / seatCountTopBottom;
771
+ const spacingHeight = availableHeight / seatCountLeftRight;
772
+ const topSeats = distributeWithSpacing({
773
+ start: x,
774
+ length: width,
775
+ count: top,
776
+ radius: seatRadius,
777
+ spacing: spacingWidth,
778
+ }).map((cx) => ({
779
+ x: cx - seatSizeTB.w / 2,
780
+ y: y - seatSizeTB.h,
781
+ width: seatSizeTB.w,
782
+ height: seatSizeTB.h,
783
+ id: "top",
784
+ }));
785
+ const bottomSeats = distributeWithSpacing({
786
+ start: x,
787
+ length: width,
788
+ count: bottom,
789
+ radius: seatRadius,
790
+ spacing: spacingWidth,
791
+ }).map((cx) => ({
792
+ x: cx - seatSizeTB.w / 2,
793
+ y: y + height,
794
+ width: seatSizeTB.w,
795
+ height: seatSizeTB.h,
796
+ id: "bottom",
797
+ }));
798
+ const leftSeats = distributeWithSpacing({
799
+ start: 0,
800
+ length: height,
801
+ count: left,
802
+ radius: seatRadius,
803
+ spacing: spacingHeight,
804
+ }).map((cy) => ({
805
+ x: x - seatSizeLR.w,
806
+ y: y + cy - seatSizeLR.h / 2,
807
+ width: seatSizeLR.w,
808
+ height: seatSizeLR.h,
809
+ id: "left",
810
+ }));
811
+ const rightSeats = distributeWithSpacing({
812
+ start: 0,
813
+ length: height,
814
+ count: right,
815
+ radius: seatRadius,
816
+ spacing: spacingHeight,
817
+ }).map((cy) => ({
818
+ x: x + width,
819
+ y: y + cy - seatSizeLR.h / 2,
820
+ width: seatSizeLR.w,
821
+ height: seatSizeLR.h,
822
+ id: "right",
823
+ }));
824
+ const seats = [
825
+ ...topSeats,
826
+ ...bottomSeats,
827
+ ...leftSeats,
828
+ ...rightSeats,
829
+ ];
830
+ return (_jsx("g", { transform: `translate(${x}, ${y})`, "data-id": id, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
831
+ e.preventDefault(); // penting
832
+ const group = e.currentTarget;
833
+ highlightGroup(group, "dragenter");
834
+ }, onDragOver: (e) => {
835
+ e.preventDefault(); // agar drop diterima
836
+ }, onDragLeave: (e) => {
837
+ const group = e.currentTarget;
838
+ unhighlightGroup(group);
839
+ }, onDrop: (e) => {
840
+ e.preventDefault();
841
+ const group = e.currentTarget;
842
+ // restore langsung dan reset
843
+ forceRestoreGroup(group);
844
+ }, onPointerOver: (e) => {
845
+ e.preventDefault(); // penting
846
+ const group = e.currentTarget;
847
+ highlightGroup(group, "pointerover");
848
+ }, onPointerOut: (e) => {
849
+ const group = e.currentTarget;
850
+ unhighlightGroup(group);
851
+ }, onPointerUp: (e) => {
852
+ e.preventDefault();
853
+ const group = e.currentTarget;
854
+ // restore langsung dan reset
855
+ forceRestoreGroup(group);
856
+ }, onMouseDown: (e) => {
857
+ e.preventDefault();
858
+ const group = e.currentTarget;
859
+ highlightGroup(group, "mousedown");
860
+ }, onMouseEnter: (e) => {
861
+ // e.preventDefault(); // penting
862
+ const group = e.currentTarget;
863
+ highlightGroup(group, "mouseenter");
864
+ }, onMouseLeave: (e) => {
865
+ const group = e.currentTarget;
866
+ unhighlightGroup(group);
867
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", Object.assign({ width: width, height: height, rx: radius }, commonProps, { fill: fill }, omit(item, ["x", "y", "label", "points", "tags", "seatCount"]))), _jsx("g", { "data-seat": `${id}-seats`, transform: `translate(${-x}, ${-y})`, children: seats === null || seats === void 0 ? void 0 : seats.map(({ height, width, x, y, id }, i) => (_jsx("rect", { x: x, y: y, id: `seat-${id}`, height: height, width: width, rx: radius / 4, fill: seatFill }, `${id}-seat-${i}`))) }, `${id}-seats`), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
868
+ var _a, _b, _c, _d, _e, _f, _g;
869
+ const cx = width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0);
870
+ const cy = height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0);
871
+ return (_createElement("text", Object.assign({}, omit(commonProps, [
872
+ "opacity",
873
+ "stroke",
874
+ "strokeWidth",
875
+ ]), { transform: `rotate(${(_c = _ === null || _ === void 0 ? void 0 : _.rotation) !== null && _c !== void 0 ? _c : 0}, ${cx},${cy})`, key: `${id}-label-${index}`, x: width / 2 + ((_d = _ === null || _ === void 0 ? void 0 : _.x) !== null && _d !== void 0 ? _d : 0), y: height / 2 + ((_e = _ === null || _ === void 0 ? void 0 : _.y) !== null && _e !== void 0 ? _e : 0), fill: (_f = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _f !== void 0 ? _f : "black", fontSize: `${(_g = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _g !== void 0 ? _g : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle" }), _ === null || _ === void 0 ? void 0 : _.label));
876
+ }) }))] }) }, id));
877
+ }
878
+ case "text":
879
+ return (_jsx("g", { onContextMenu: (e) => e.preventDefault(), "data-id": id, transform: `translate(${x}, ${y})`, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("rect", { width: width, height: height, fill: "transparent", opacity: opacity }), _jsx("text", Object.assign({ x: width / 2, y: height / 2, textAnchor: "middle", dominantBaseline: "middle", fill: fill !== null && fill !== void 0 ? fill : fontColor, fontSize: fontSize !== null && fontSize !== void 0 ? fontSize : height * 0.6, opacity: opacity }, omit(commonProps, ["fill", "opacity"]), { children: text }))] }) }, id));
880
+ case "image-table":
881
+ return (_jsx("g", { id: `${id}`, "data-id": id, transform: `translate(${x}, ${y})`, onContextMenu: (e) => e.preventDefault(), onDragEnter: (e) => {
882
+ e.preventDefault(); // penting
883
+ const group = e.currentTarget;
884
+ highlightGroup(group, "dragenter");
885
+ }, onDragOver: (e) => {
886
+ e.preventDefault(); // agar drop diterima
887
+ }, onDragLeave: (e) => {
888
+ const group = e.currentTarget;
889
+ unhighlightGroup(group);
890
+ }, onDrop: (e) => {
891
+ e.preventDefault();
892
+ const group = e.currentTarget;
893
+ // restore langsung dan reset
894
+ forceRestoreGroup(group);
895
+ }, onPointerOver: (e) => {
896
+ e.preventDefault(); // penting
897
+ const group = e.currentTarget;
898
+ highlightGroup(group, "pointerover");
899
+ }, onPointerOut: (e) => {
900
+ const group = e.currentTarget;
901
+ unhighlightGroup(group);
902
+ }, onPointerUp: (e) => {
903
+ e.preventDefault();
904
+ const group = e.currentTarget;
905
+ // restore langsung dan reset
906
+ forceRestoreGroup(group);
907
+ }, onMouseDown: (e) => {
908
+ e.preventDefault();
909
+ const group = e.currentTarget;
910
+ highlightGroup(group, "mousedown");
911
+ }, children: _jsxs("g", { transform: `rotate(${rotation}, 0, 0)`, children: [_jsx("image", Object.assign({ href: src, width: width, height: height, transform: transformRotate }, commonProps)), renderTags(tags), showLabels && (_jsx("g", { transform: `rotate(${-rotation}, ${width / 2}, ${height / 2})`, children: labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
912
+ var _a, _b, _c, _d;
913
+ return (_jsx("text", { x: x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: transformRotate, children: _ === null || _ === void 0 ? void 0 : _.label }, index));
914
+ }) }))] }) }, id));
915
+ case "background":
916
+ return (_jsxs("g", { onContextMenu: (e) => e.preventDefault(), children: [_jsx("image", Object.assign({ href: src, x: x, y: y, width: width, height: height, transform: transformRotate }, commonProps)), labels === null || labels === void 0 ? void 0 : labels.map((_, index) => {
917
+ var _a, _b, _c, _d;
918
+ return (_jsx("text", { x: x + width / 2 + ((_a = _ === null || _ === void 0 ? void 0 : _.x) !== null && _a !== void 0 ? _a : 0), y: y + height / 2 + ((_b = _ === null || _ === void 0 ? void 0 : _.y) !== null && _b !== void 0 ? _b : 0), fill: (_c = _ === null || _ === void 0 ? void 0 : _.fontColor) !== null && _c !== void 0 ? _c : "black", fontSize: `${(_d = _ === null || _ === void 0 ? void 0 : _.fontSize) !== null && _d !== void 0 ? _d : 10}px`, fontWeight: "bold", textAnchor: "middle", dominantBaseline: "middle", transform: transformRotate, children: _ === null || _ === void 0 ? void 0 : _.label }, index));
919
+ })] }, id));
920
+ default:
921
+ return _jsx("g", {}, id);
922
+ }
923
+ };
924
+ let date = new Date();
925
+ return _jsx("g", { children: components === null || components === void 0 ? void 0 : components.map(renderShape) }, `${date}`);
926
+ };
927
+ export default Layers;