@enyxs/wikex-components 0.11.10 → 0.11.14

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.
package/dist/fees.mjs ADDED
@@ -0,0 +1,1687 @@
1
+ "use client";
2
+
3
+ // src/wikex/fees-manager.tsx
4
+ import { Alert, Box, Button as Button2, Card, Chip, Divider, MenuItem as MenuItem2, Stack, TextField as TextField2, ToggleButton, ToggleButtonGroup, Typography } from "@mui/material";
5
+
6
+ // src/wikex/fees-table.tsx
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ import { useId, useLayoutEffect, useRef, useState } from "react";
9
+ import styled6, { ThemeProvider } from "styled-components";
10
+ import TextField from "@mui/material/TextField";
11
+ import Dialog from "@mui/material/Dialog";
12
+ import DialogTitle from "@mui/material/DialogTitle";
13
+ import DialogContent from "@mui/material/DialogContent";
14
+ import DialogContentText from "@mui/material/DialogContentText";
15
+ import DialogActions from "@mui/material/DialogActions";
16
+ import Button from "@mui/material/Button";
17
+ import Select from "@mui/material/Select";
18
+ import MenuItem from "@mui/material/MenuItem";
19
+ import Checkbox from "@mui/material/Checkbox";
20
+
21
+ // src/commodity-original/styles/colors.ts
22
+ var lightColors = {
23
+ background: {
24
+ canvas: "#ffffff",
25
+ card: "#ffffff",
26
+ deep: "#ffffff",
27
+ hover: "#f5f5f5",
28
+ input: "#f3f4f6",
29
+ warm: "#fffbf3",
30
+ popup: "#f9fafb"
31
+ },
32
+ text: {
33
+ primary: "#171717",
34
+ secondary: "#707580",
35
+ placeholder: "#9ea3ad",
36
+ content: "#4E5560"
37
+ },
38
+ action: {
39
+ primaryBackground: "#171717",
40
+ primaryForeground: "#ffffff",
41
+ primaryHover: "#383838"
42
+ },
43
+ accent: {
44
+ primary: "#f9bb3a",
45
+ foreground: "#05080f",
46
+ deep: "#c78806"
47
+ },
48
+ border: {
49
+ subtle: "#D2D5DA",
50
+ line: "#E6E7EA"
51
+ },
52
+ informationHero: {
53
+ start: "#e55f2a",
54
+ middle: "#e87a2f",
55
+ foreground: "#ffffff",
56
+ placeholder: "rgb(116 116 116 / 50%)"
57
+ },
58
+ datePicker: {
59
+ selected: "#4f39f6",
60
+ range: "#eef2ff",
61
+ rangeForeground: "#312c85"
62
+ },
63
+ effect: {
64
+ popupShadow: "rgb(5 8 16 / 5%)"
65
+ }
66
+ };
67
+ var cssVariableColors = {
68
+ background: {
69
+ canvas: "var(--color-background-canvas)",
70
+ card: "var(--color-background-card)",
71
+ deep: "var(--color-background-deep)",
72
+ hover: "var(--color-background-hover)",
73
+ input: "var(--color-background-input)",
74
+ warm: "var(--color-background-warm)",
75
+ popup: "var(--color-background-popup)"
76
+ },
77
+ text: {
78
+ primary: "var(--color-text-primary)",
79
+ secondary: "var(--color-text-secondary)",
80
+ placeholder: "var(--color-text-placeholder)",
81
+ content: "var(--color-text-content)"
82
+ },
83
+ action: {
84
+ primaryBackground: "var(--color-action-primary-background)",
85
+ primaryForeground: "var(--color-action-primary-foreground)",
86
+ primaryHover: "var(--color-action-primary-hover)"
87
+ },
88
+ accent: {
89
+ primary: "var(--color-accent-primary)",
90
+ foreground: "var(--color-accent-foreground)",
91
+ deep: "var(--color-accent-deep)"
92
+ },
93
+ border: {
94
+ subtle: "var(--color-border-subtle)",
95
+ line: "var(--color-border-line)"
96
+ },
97
+ informationHero: {
98
+ start: "var(--color-information-hero-start)",
99
+ middle: "var(--color-information-hero-middle)",
100
+ foreground: "var(--color-information-hero-foreground)",
101
+ placeholder: "var(--color-information-hero-placeholder)"
102
+ },
103
+ datePicker: {
104
+ selected: "var(--color-date-picker-selected)",
105
+ range: "var(--color-date-picker-range)",
106
+ rangeForeground: "var(--color-date-picker-range-foreground)"
107
+ },
108
+ effect: {
109
+ popupShadow: "var(--color-effect-popup-shadow)"
110
+ }
111
+ };
112
+
113
+ // src/commodity-original/styles/theme.ts
114
+ var appTheme = {
115
+ colors: cssVariableColors
116
+ };
117
+
118
+ // src/commodity-original/components/Table/index.tsx
119
+ import { Fragment } from "react";
120
+
121
+ // src/commodity-original/components/Table/style.ts
122
+ import styled from "styled-components";
123
+ var TableScrollContainer = styled.div.withConfig({
124
+ componentId: "sc-b3eceaf0-0"
125
+ })([
126
+ `min-width:0;width:100%;max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain;`
127
+ ]);
128
+ var TableRoot = styled.table.withConfig({
129
+ componentId: "sc-b3eceaf0-1"
130
+ })([
131
+ `width:100%;min-width:`,
132
+ `;border-spacing:0;border-collapse:separate;border-radius:12px 12px 0 0;color:`,
133
+ `;font-family:var(--font-manrope),Arial,Helvetica,sans-serif;text-align:left;`
134
+ ], ({ $minWidth }) => $minWidth ?? "100%", ({ theme }) => theme.colors.text.primary);
135
+ var TableHeaderRow = styled.tr.withConfig({
136
+ componentId: "sc-b3eceaf0-2"
137
+ })([
138
+ `background:`,
139
+ `;`
140
+ ], ({ theme }) => theme.colors.background.input);
141
+ var TableHeaderCell = styled.th.withConfig({
142
+ componentId: "sc-b3eceaf0-3"
143
+ })([
144
+ ``,
145
+ ` padding:11.5px 8px 11.5px 16px;border-bottom:1px solid `,
146
+ `;color:`,
147
+ `;font-size:10px;font-weight:600;line-height:14px;vertical-align:middle;&:first-child{padding-left:16px;border-top-left-radius:12px;}&:last-child{border-top-right-radius:12px;}`,
148
+ `[data-size="sm"] &{padding:12px 8px 12px 16px;font-size:var(--Size-Overline-M,8px);font-weight:600;line-height:var(--Line-height-Overline-M,10px);}`
149
+ ], ({ $fixed, $fixedOffset, $width, theme }) => `
150
+ ${$width ? `width: ${$width}; min-width: ${$width};` : ""}
151
+ ${$fixed && $fixedOffset ? `
152
+ position: sticky;
153
+ ${$fixed}: ${$fixedOffset};
154
+ z-index: 3;
155
+ background: ${theme.colors.background.input};
156
+ ` : ""}
157
+ `, ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.text.primary, TableRoot);
158
+ var TableRow = styled.tr.withConfig({
159
+ componentId: "sc-b3eceaf0-4"
160
+ })([
161
+ `background:`,
162
+ `;`
163
+ ], ({ theme }) => theme.colors.background.deep);
164
+ var TableCell = styled.td.withConfig({
165
+ componentId: "sc-b3eceaf0-5"
166
+ })([
167
+ ``,
168
+ ` padding:7.5px 8px 7.5px 16px;border-bottom:1px solid `,
169
+ `;color:`,
170
+ `;font-size:12px;font-weight:500;line-height:16px;vertical-align:middle;&:first-child{padding-left:16px;}`,
171
+ `[data-size="sm"] &{padding:8px 8px 8px 16px;font-size:var(--Size-Caption-S,10px);font-weight:500;line-height:var(--Line-height-Caption-S,14px);}`
172
+ ], ({ $fixed, $fixedOffset, $width, theme }) => `
173
+ ${$width ? `width: ${$width}; min-width: ${$width};` : ""}
174
+ ${$fixed && $fixedOffset ? `
175
+ position: sticky;
176
+ ${$fixed}: ${$fixedOffset};
177
+ z-index: 2;
178
+ background: ${theme.colors.background.deep};
179
+ ` : ""}
180
+ `, ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.text.primary, TableRoot);
181
+ var TableSortButton = styled.button.withConfig({
182
+ componentId: "sc-b3eceaf0-6"
183
+ })([
184
+ `display:inline-flex;max-width:100%;margin:0;padding:0;align-items:center;border:0;color:inherit;background:transparent;cursor:pointer;font:inherit;line-height:inherit;text-align:left;&:focus-visible{outline:2px solid `,
185
+ `;outline-offset:3px;}`
186
+ ], ({ theme }) => theme.colors.accent.primary);
187
+ var TableSelectionInput = styled.input.withConfig({
188
+ componentId: "sc-b3eceaf0-7"
189
+ })([
190
+ `width:16px;height:16px;margin:0;accent-color:`,
191
+ `;cursor:pointer;&:disabled{cursor:not-allowed;}`
192
+ ], ({ theme }) => theme.colors.accent.primary);
193
+ var TableExpandButton = styled.button.withConfig({
194
+ componentId: "sc-b3eceaf0-8"
195
+ })([
196
+ `margin:0;padding:0;border:0;color:`,
197
+ `;background:transparent;cursor:pointer;font:inherit;line-height:inherit;&:focus-visible{outline:2px solid `,
198
+ `;outline-offset:3px;}`
199
+ ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
200
+ var TableExpandedCell = styled(TableCell).withConfig({
201
+ componentId: "sc-b3eceaf0-9"
202
+ })([
203
+ `background:`,
204
+ `;`
205
+ ], ({ theme }) => theme.colors.background.hover);
206
+
207
+ // src/commodity-original/components/Table/utils.ts
208
+ function getTableRowKey(record, rowKey) {
209
+ if (typeof rowKey === "function") {
210
+ return rowKey(record);
211
+ }
212
+ return String(record[rowKey]);
213
+ }
214
+ function getTableColumnSize(value) {
215
+ return typeof value === "number" ? `${value}px` : value;
216
+ }
217
+ function getTableFixedColumnOffset(columns, columnIndex) {
218
+ const column = columns[columnIndex];
219
+ if (!column?.fixed) {
220
+ return void 0;
221
+ }
222
+ const precedingColumns = column.fixed === "left" ? columns.slice(0, columnIndex) : columns.slice(columnIndex + 1);
223
+ const fixedColumnSizes = precedingColumns.filter((item) => item.fixed === column.fixed).map(
224
+ (item) => item.width === void 0 ? void 0 : getTableColumnSize(item.width)
225
+ );
226
+ if (fixedColumnSizes.some((size) => size === void 0)) {
227
+ return void 0;
228
+ }
229
+ const sizes = fixedColumnSizes.filter(
230
+ (size) => size !== void 0
231
+ );
232
+ return sizes.length === 0 ? "0px" : `calc(${sizes.join(" + ")})`;
233
+ }
234
+
235
+ // src/commodity-original/components/Table/index.tsx
236
+ import { jsx, jsxs } from "react/jsx-runtime";
237
+ function getCellValue(column, record) {
238
+ return column.dataIndex === void 0 ? void 0 : record[column.dataIndex];
239
+ }
240
+ function getNextSort(sort, field) {
241
+ if (sort?.field === field && sort.order === "asc") {
242
+ return { field, order: "desc" };
243
+ }
244
+ return { field, order: "asc" };
245
+ }
246
+ function getSelectedRows(dataSource, selectedRowKeys, getRowKey) {
247
+ const selectedKeySet = new Set(selectedRowKeys);
248
+ return dataSource.filter((record) => selectedKeySet.has(getRowKey(record)));
249
+ }
250
+ function getSelectionType(rowSelection) {
251
+ return rowSelection.type ?? "checkbox";
252
+ }
253
+ function Table({
254
+ ariaLabel,
255
+ className,
256
+ columns,
257
+ dataSource,
258
+ empty = null,
259
+ expandable,
260
+ loading = false,
261
+ loadingContent = null,
262
+ onSortChange,
263
+ rowKey,
264
+ rowSelection,
265
+ scroll,
266
+ size = "md",
267
+ sort
268
+ }) {
269
+ const getRowKey = (record) => getTableRowKey(record, rowKey);
270
+ const selectedRowKeys = rowSelection?.selectedRowKeys ?? [];
271
+ const selectedRowKeySet = new Set(selectedRowKeys);
272
+ const expandedRowKeySet = new Set(expandable?.expandedRowKeys ?? []);
273
+ const selectionType = rowSelection ? getSelectionType(rowSelection) : void 0;
274
+ const selectableRecords = rowSelection ? dataSource.filter(
275
+ (record) => !rowSelection.getCheckboxProps?.(record).disabled
276
+ ) : [];
277
+ const selectableRowKeys = selectableRecords.map(getRowKey);
278
+ const isAllSelected = selectionType === "checkbox" && selectableRowKeys.length > 0 && selectableRowKeys.every((key) => selectedRowKeySet.has(key));
279
+ const columnCount = columns.length + (rowSelection ? 1 : 0) + (expandable ? 1 : 0);
280
+ const emitSelectionChange = (nextSelectedRowKeys) => {
281
+ rowSelection?.onChange?.(
282
+ nextSelectedRowKeys,
283
+ getSelectedRows(dataSource, nextSelectedRowKeys, getRowKey)
284
+ );
285
+ };
286
+ const handleSelectAll = (event) => {
287
+ if (!rowSelection || selectionType !== "checkbox") {
288
+ return;
289
+ }
290
+ const selectableKeySet = new Set(selectableRowKeys);
291
+ const preservedRowKeys = selectedRowKeys.filter(
292
+ (key) => !selectableKeySet.has(key)
293
+ );
294
+ const nextSelectedRowKeys = event.target.checked ? [...preservedRowKeys, ...selectableRowKeys] : preservedRowKeys;
295
+ emitSelectionChange(nextSelectedRowKeys);
296
+ };
297
+ const handleRowSelectionChange = (event, record) => {
298
+ if (!rowSelection) {
299
+ return;
300
+ }
301
+ const recordKey = getRowKey(record);
302
+ if (selectionType === "radio") {
303
+ emitSelectionChange(event.target.checked ? [recordKey] : []);
304
+ return;
305
+ }
306
+ const nextSelectedRowKeys = event.target.checked ? [...selectedRowKeys, recordKey] : selectedRowKeys.filter((key) => key !== recordKey);
307
+ emitSelectionChange(nextSelectedRowKeys);
308
+ };
309
+ return /* @__PURE__ */ jsx(TableScrollContainer, { children: /* @__PURE__ */ jsxs(
310
+ TableRoot,
311
+ {
312
+ $minWidth: scroll?.x === void 0 ? void 0 : getTableColumnSize(scroll.x),
313
+ "aria-busy": loading || void 0,
314
+ "aria-label": ariaLabel,
315
+ className,
316
+ "data-size": size,
317
+ children: [
318
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs(TableHeaderRow, { children: [
319
+ rowSelection ? /* @__PURE__ */ jsx(TableHeaderCell, { scope: "col", children: selectionType === "checkbox" ? /* @__PURE__ */ jsx(
320
+ TableSelectionInput,
321
+ {
322
+ checked: isAllSelected,
323
+ disabled: selectableRowKeys.length === 0,
324
+ onChange: handleSelectAll,
325
+ type: "checkbox"
326
+ }
327
+ ) : null }) : null,
328
+ expandable ? /* @__PURE__ */ jsx(TableHeaderCell, { scope: "col" }) : null,
329
+ columns.map((column, columnIndex) => /* @__PURE__ */ jsx(
330
+ TableHeaderCell,
331
+ {
332
+ $fixed: column.fixed,
333
+ $fixedOffset: getTableFixedColumnOffset(columns, columnIndex),
334
+ $width: column.width === void 0 ? void 0 : getTableColumnSize(column.width),
335
+ "data-column-key": column.key,
336
+ scope: "col",
337
+ children: column.sortable ? /* @__PURE__ */ jsx(
338
+ TableSortButton,
339
+ {
340
+ "aria-pressed": sort?.field === column.key,
341
+ onClick: () => onSortChange?.(getNextSort(sort, column.key)),
342
+ type: "button",
343
+ children: column.title
344
+ }
345
+ ) : column.title
346
+ },
347
+ column.key
348
+ ))
349
+ ] }) }),
350
+ /* @__PURE__ */ jsx("tbody", { children: loading ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, children: loadingContent }) }) : dataSource.length === 0 ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: columnCount, children: empty }) }) : dataSource.map((record, index) => {
351
+ const recordKey = getRowKey(record);
352
+ const selectionProps = rowSelection?.getCheckboxProps?.(record);
353
+ const isExpanded = expandedRowKeySet.has(recordKey);
354
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
355
+ /* @__PURE__ */ jsxs(TableRow, { "data-row-key": recordKey, children: [
356
+ rowSelection ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
357
+ TableSelectionInput,
358
+ {
359
+ checked: selectedRowKeySet.has(recordKey),
360
+ disabled: selectionProps?.disabled,
361
+ name: selectionType === "radio" ? "table-row-selection" : void 0,
362
+ onChange: (event) => handleRowSelectionChange(event, record),
363
+ type: selectionType
364
+ }
365
+ ) }) : null,
366
+ expandable ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(
367
+ TableExpandButton,
368
+ {
369
+ "aria-expanded": isExpanded,
370
+ onClick: () => expandable.onExpand?.(!isExpanded, record),
371
+ type: "button",
372
+ children: isExpanded ? "Collapse" : "Expand"
373
+ }
374
+ ) }) : null,
375
+ columns.map((column, columnIndex) => {
376
+ const value = getCellValue(column, record);
377
+ return /* @__PURE__ */ jsx(
378
+ TableCell,
379
+ {
380
+ $fixed: column.fixed,
381
+ $fixedOffset: getTableFixedColumnOffset(columns, columnIndex),
382
+ $width: column.width === void 0 ? void 0 : getTableColumnSize(column.width),
383
+ children: column.render ? column.render(value, record, index) : value === void 0 || value === null ? null : String(value)
384
+ },
385
+ column.key
386
+ );
387
+ })
388
+ ] }),
389
+ expandable?.render && isExpanded ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableExpandedCell, { colSpan: columnCount, children: expandable.render(record) }) }) : null
390
+ ] }, recordKey);
391
+ }) })
392
+ ]
393
+ }
394
+ ) });
395
+ }
396
+
397
+ // src/commodity-original/components/Pagination/index.tsx
398
+ import { useTranslation } from "react-i18next";
399
+
400
+ // src/wikex/assets/products/chevron-right.svg
401
+ var chevron_right_default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNCIgaGVpZ2h0PSIxNCIgdmlld0JveD0iMCAwIDE0IDE0IiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNNS4yNSAzLjVMOC43NSA3TDUuMjUgMTAuNSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMS4xNjY2NyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPgo=";
402
+
403
+ // src/commodity-original/components/Pagination/style.ts
404
+ import { styled as styled2 } from "styled-components";
405
+ var PaginationNav = styled2.nav.withConfig({
406
+ componentId: "sc-522a1750-0"
407
+ })([
408
+ `display:flex;justify-content:center;`
409
+ ]);
410
+ var PaginationList = styled2.ul.withConfig({
411
+ componentId: "sc-522a1750-1"
412
+ })([
413
+ `display:flex;margin:0;padding:0;align-items:center;gap:8px;list-style:none;`
414
+ ]);
415
+ var PaginationItem = styled2.li.withConfig({
416
+ componentId: "sc-522a1750-2"
417
+ })([
418
+ `display:flex;`
419
+ ]);
420
+ var PaginationButton = styled2.button.withConfig({
421
+ componentId: "sc-522a1750-3"
422
+ })([
423
+ `display:inline-flex;width:28px;height:28px;align-items:center;justify-content:center;border:1px solid `,
424
+ `;border-radius:4px;padding:4px;color:`,
425
+ `;background:`,
426
+ `;font-family:var(--font-manrope),Arial,Helvetica,sans-serif;font-size:14px;font-weight:500;line-height:18px;cursor:pointer;transition:color 160ms ease,background-color 160ms ease,border-color 160ms ease;&[data-control]{border-color:transparent;background:transparent;}&[data-active]{border-color:`,
427
+ `;color:`,
428
+ `;background:`,
429
+ `;}&:not(:disabled):hover{color:`,
430
+ `;background:`,
431
+ `;}&[data-active]:not(:disabled):hover{background:`,
432
+ `;}&:disabled{cursor:not-allowed;}&:focus-visible{outline:2px solid `,
433
+ `;outline-offset:2px;}`
434
+ ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.text.secondary, ({ theme }) => theme.colors.background.canvas, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.foreground, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.primary);
435
+ var PaginationArrow = styled2.span.withConfig({
436
+ componentId: "sc-522a1750-4"
437
+ })([
438
+ `width:16px;height:16px;background:currentColor;mask:url("`,
439
+ `") center / contain no-repeat;-webkit-mask:url("`,
440
+ `") center / contain no-repeat;&[data-direction="previous"]{transform:scaleX(-1);}`
441
+ ], chevron_right_default, chevron_right_default);
442
+
443
+ // src/commodity-original/components/Pagination/index.tsx
444
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
445
+ function getPaginationItems(page, pageCount, siblingCount) {
446
+ const maxVisibleItems = siblingCount * 2 + 5;
447
+ if (pageCount <= maxVisibleItems) {
448
+ return Array.from({ length: pageCount }, (_, index) => index + 1);
449
+ }
450
+ const leftSibling = Math.max(page - siblingCount, 2);
451
+ const rightSibling = Math.min(page + siblingCount, pageCount - 1);
452
+ const items = [1];
453
+ if (leftSibling > 2) {
454
+ items.push("ellipsis");
455
+ }
456
+ for (let value = leftSibling; value <= rightSibling; value += 1) {
457
+ items.push(value);
458
+ }
459
+ if (rightSibling < pageCount - 1) {
460
+ items.push("ellipsis");
461
+ }
462
+ items.push(pageCount);
463
+ return items;
464
+ }
465
+ function Pagination({
466
+ page,
467
+ pageCount,
468
+ onPageChange,
469
+ siblingCount = 1,
470
+ ariaLabel,
471
+ labels,
472
+ className
473
+ }) {
474
+ const { t } = useTranslation();
475
+ const safePageCount = Math.max(1, Math.floor(pageCount));
476
+ const currentPage = Math.min(Math.max(1, Math.floor(page)), safePageCount);
477
+ const items = getPaginationItems(currentPage, safePageCount, siblingCount);
478
+ const hasPreviousPage = currentPage > 1;
479
+ const hasNextPage = currentPage < safePageCount;
480
+ return /* @__PURE__ */ jsx2(
481
+ PaginationNav,
482
+ {
483
+ "aria-label": ariaLabel ?? t("pagination.navigation"),
484
+ className,
485
+ children: /* @__PURE__ */ jsxs2(PaginationList, { children: [
486
+ /* @__PURE__ */ jsx2(PaginationItem, { children: /* @__PURE__ */ jsx2(
487
+ PaginationButton,
488
+ {
489
+ "aria-label": labels?.previous ?? t("pagination.previous"),
490
+ "data-control": "previous",
491
+ disabled: !hasPreviousPage,
492
+ onClick: () => onPageChange(currentPage - 1),
493
+ type: "button",
494
+ children: /* @__PURE__ */ jsx2(PaginationArrow, { "data-direction": "previous" })
495
+ }
496
+ ) }),
497
+ items.map((item, index) => /* @__PURE__ */ jsx2(PaginationItem, { children: item === "ellipsis" ? /* @__PURE__ */ jsx2(PaginationButton, { "aria-hidden": "true", disabled: true, tabIndex: -1, type: "button", children: "\u2026" }) : /* @__PURE__ */ jsx2(
498
+ PaginationButton,
499
+ {
500
+ "aria-current": item === currentPage ? "page" : void 0,
501
+ "aria-label": item === currentPage ? labels?.current(item) ?? t("pagination.current", { page: item }) : labels?.page(item) ?? t("pagination.page", { page: item }),
502
+ "data-active": item === currentPage || void 0,
503
+ onClick: () => onPageChange(item),
504
+ type: "button",
505
+ children: item
506
+ }
507
+ ) }, `${item}-${index}`)),
508
+ /* @__PURE__ */ jsx2(PaginationItem, { children: /* @__PURE__ */ jsx2(
509
+ PaginationButton,
510
+ {
511
+ "aria-label": labels?.next ?? t("pagination.next"),
512
+ "data-control": "next",
513
+ disabled: !hasNextPage,
514
+ onClick: () => onPageChange(currentPage + 1),
515
+ type: "button",
516
+ children: /* @__PURE__ */ jsx2(PaginationArrow, { "data-direction": "next" })
517
+ }
518
+ ) })
519
+ ] })
520
+ }
521
+ );
522
+ }
523
+
524
+ // src/commodity-original/components/InputCommon/style.ts
525
+ import styled3 from "styled-components";
526
+ var InputCommonRoot = styled3.div.withConfig({
527
+ componentId: "sc-5ccafcdd-0"
528
+ })([
529
+ `display:flex;width:100%;min-width:0;gap:6px;padding:10px 12px;align-items:center;border:1px solid transparent;border-radius:6px;background:`,
530
+ `;transition:border-color 160ms ease,background-color 160ms ease;&[data-size="sm"]{gap:4px;padding:8px 12px;}&[data-size="lg"]{gap:8px;padding:14px 16px;}&:focus-within{border-color:`,
531
+ `;background:`,
532
+ `;}&[data-disabled]{cursor:not-allowed;opacity:0.6;}&[data-error]{border-color:#dc2626;}> button{border:0;background:transparent;cursor:pointer;font-size:18px;}> [role="alert"]{position:absolute;margin-top:52px;color:#dc2626;font-size:12px;}`
533
+ ], ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.background.canvas);
534
+ var InputCommonField = styled3.input.withConfig({
535
+ componentId: "sc-5ccafcdd-1"
536
+ })([
537
+ `width:100%;min-width:0;border:0;outline:0;color:`,
538
+ `;background:transparent;font-family:var(--font-manrope),Arial,Helvetica,sans-serif;font-size:14px;font-weight:500;line-height:18px;`,
539
+ `[data-size="sm"] &{font-size:12px;line-height:16px;}`,
540
+ `[data-size="lg"] &{font-size:16px;line-height:22px;}&::placeholder{color:#9ea3ad;opacity:1;}&:disabled{cursor:not-allowed;}`
541
+ ], ({ theme }) => theme.colors.text.primary, InputCommonRoot, InputCommonRoot);
542
+ var InputAdornment = styled3.span.withConfig({
543
+ componentId: "sc-5ccafcdd-2"
544
+ })([
545
+ `display:inline-flex;width:16px;height:16px;flex:0 0 16px;align-items:center;justify-content:center;color:`,
546
+ `;> svg,> img{width:100%;height:100%;}`,
547
+ `[data-size="sm"] &{width:14px;height:14px;flex-basis:14px;}`,
548
+ `[data-size="lg"] &{width:20px;height:20px;flex-basis:20px;}`
549
+ ], ({ theme }) => theme.colors.text.secondary, InputCommonRoot, InputCommonRoot);
550
+
551
+ // src/commodity-original/components/InputCommon/index.tsx
552
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
553
+ function InputCommon({
554
+ leftIcon,
555
+ rightIcon,
556
+ size = "md",
557
+ error = false,
558
+ errorMessage,
559
+ clearable = false,
560
+ onClear,
561
+ ...inputProps
562
+ }) {
563
+ return /* @__PURE__ */ jsxs3(InputCommonRoot, { "data-disabled": inputProps.disabled || void 0, "data-error": error || void 0, "data-size": size, children: [
564
+ leftIcon ? /* @__PURE__ */ jsx3(InputAdornment, { "aria-hidden": "true", children: leftIcon }) : null,
565
+ /* @__PURE__ */ jsx3(InputCommonField, { ...inputProps }),
566
+ clearable && inputProps.value ? /* @__PURE__ */ jsx3("button", { "aria-label": "X\xF3a n\u1ED9i dung", onClick: onClear, type: "button", children: "\xD7" }) : rightIcon ? /* @__PURE__ */ jsx3(InputAdornment, { "aria-hidden": "true", children: rightIcon }) : null,
567
+ errorMessage ? /* @__PURE__ */ jsx3("span", { role: "alert", children: errorMessage }) : null
568
+ ] });
569
+ }
570
+
571
+ // src/commodity-original/components/TabCommon/style.ts
572
+ import styled4 from "styled-components";
573
+ var TabCommonList = styled4.div.withConfig({
574
+ componentId: "sc-370a48e5-0"
575
+ })([
576
+ `display:flex;gap:16px;align-items:center;overflow-x:auto;&[data-size="sm"]{gap:12px;}&[data-size="lg"]{gap:20px;}`
577
+ ]);
578
+ var TabButton = styled4.button.withConfig({
579
+ componentId: "sc-370a48e5-1"
580
+ })([
581
+ `position:relative;display:inline-flex;padding:8px 0;align-items:center;border:0;color:`,
582
+ `;background:transparent;font-family:var(--font-manrope),Arial,Helvetica,sans-serif;font-size:16px;font-weight:700;line-height:22px;white-space:nowrap;cursor:pointer;transition:color 160ms ease;`,
583
+ `[data-size="sm"] &{padding-block:4px;font-size:14px;line-height:18px;}`,
584
+ `[data-size="lg"] &{padding-block:12px;font-size:18px;line-height:26px;}&[data-active]{color:`,
585
+ `;}&:not(:disabled):hover{color:`,
586
+ `;}&:not(:disabled):hover > span,&[data-active] > span{transform:translateX(-50%) scaleX(1);}&:disabled{cursor:not-allowed;opacity:0.5;}&:focus-visible{outline:2px solid `,
587
+ `;outline-offset:2px;}`
588
+ ], ({ theme }) => theme.colors.text.secondary, TabCommonList, TabCommonList, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
589
+ var TabLine = styled4.span.withConfig({
590
+ componentId: "sc-370a48e5-2"
591
+ })([
592
+ `position:absolute;bottom:0;left:50%;width:107px;max-width:100%;height:2px;color:`,
593
+ `;background:currentColor;mask:url("/icons/tab-active-line.svg") center / 100% 2px no-repeat;-webkit-mask:url("/icons/tab-active-line.svg") center / 100% 2px no-repeat;transform:translateX(-50%) scaleX(0);transform-origin:center;transition:transform 200ms ease-out;`,
594
+ `[data-size="sm"] &{width:89px;}`,
595
+ `[data-size="lg"] &{width:125px;}`
596
+ ], ({ theme }) => theme.colors.accent.primary, TabCommonList, TabCommonList);
597
+
598
+ // src/commodity-original/components/TabCommon/index.tsx
599
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
600
+ function TabCommon({
601
+ items,
602
+ value,
603
+ onValueChange,
604
+ ariaLabel,
605
+ className,
606
+ size = "md"
607
+ }) {
608
+ return /* @__PURE__ */ jsx4(
609
+ TabCommonList,
610
+ {
611
+ "aria-label": ariaLabel,
612
+ className,
613
+ "data-size": size,
614
+ role: "tablist",
615
+ children: items.map((item) => {
616
+ const isActive = item.id === value;
617
+ return /* @__PURE__ */ jsxs4(
618
+ TabButton,
619
+ {
620
+ "aria-selected": isActive,
621
+ "data-active": isActive || void 0,
622
+ disabled: item.disabled,
623
+ onClick: () => onValueChange(item.id),
624
+ role: "tab",
625
+ type: "button",
626
+ children: [
627
+ item.label,
628
+ /* @__PURE__ */ jsx4(TabLine, { "aria-hidden": "true" })
629
+ ]
630
+ },
631
+ item.id
632
+ );
633
+ })
634
+ }
635
+ );
636
+ }
637
+
638
+ // src/commodity-original/app/bang-phi-ky-quy/style.ts
639
+ import styled5 from "styled-components";
640
+ var FeesAndMarginMain = styled5.main.withConfig({
641
+ componentId: "sc-a2e40b03-0"
642
+ })([
643
+ `min-height:calc(100vh - var(--header-height));background:`,
644
+ `;`
645
+ ], ({ theme }) => theme.colors.background.warm);
646
+ var FeesAndMarginPageContent = styled5.div.withConfig({
647
+ componentId: "sc-a2e40b03-1"
648
+ })([
649
+ `width:min(1920px,100%);margin:0 auto;padding:58px 16px 80px;@media (max-width:767px){padding:32px 16px 48px;}`
650
+ ]);
651
+ var FeesAndMarginHeader = styled5.header.withConfig({
652
+ componentId: "sc-a2e40b03-2"
653
+ })([
654
+ `h1{margin:0;color:`,
655
+ `;font-family:var(--Font-Landingpage,Inter);font-size:40px;font-weight:700;line-height:50px;}p{margin:16px 0 0;color:`,
656
+ `;font-family:var(--Font-Landingpage,Inter);font-size:var(--Size-Body-M,16px);font-style:normal;font-weight:600;line-height:var(--Line-height-Body-M,22px);}@media (max-width:767px){h1{font-size:24px;line-height:36px;}p{font-size:14px;line-height:18px;}}`
657
+ ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.text.primary);
658
+ var FeesAndMarginToolbar = styled5.section.withConfig({
659
+ componentId: "sc-a2e40b03-3"
660
+ })([
661
+ `margin-top:32px;`
662
+ ]);
663
+ var FeesAndMarginToolbarInner = styled5.div.withConfig({
664
+ componentId: "sc-a2e40b03-4"
665
+ })([
666
+ `display:flex;gap:16px;align-items:center;justify-content:space-between;@media (max-width:767px){align-items:stretch;flex-direction:column;}`
667
+ ]);
668
+ var FeesAndMarginSearch = styled5.div.withConfig({
669
+ componentId: "sc-a2e40b03-5"
670
+ })([
671
+ `width:220px;@media (max-width:767px){order:-1;width:100%;}`
672
+ ]);
673
+ var FeesSearchIcon = styled5.span.withConfig({
674
+ componentId: "sc-a2e40b03-6"
675
+ })([
676
+ `display:block;width:14px;height:14px;background:currentColor;mask:url("/icons/search.svg") center / contain no-repeat;-webkit-mask:url("/icons/search.svg") center / contain no-repeat;`
677
+ ]);
678
+ var FeesAndMarginTable = styled5.section.withConfig({
679
+ componentId: "sc-a2e40b03-7"
680
+ })([
681
+ `margin-top:24px;td{white-space:pre-line;}`
682
+ ]);
683
+ var FeesAndMarginPagination = styled5.div.withConfig({
684
+ componentId: "sc-a2e40b03-8"
685
+ })([
686
+ `display:flex;margin-top:32px;justify-content:center;`
687
+ ]);
688
+ var FeesMonthNavigation = styled5.nav.withConfig({
689
+ componentId: "sc-a2e40b03-9"
690
+ })([
691
+ `margin-top:32px;@media (max-width:767px){display:none;}`
692
+ ]);
693
+ var FeesMonthTitle = styled5.p.withConfig({
694
+ componentId: "sc-a2e40b03-10"
695
+ })([
696
+ `margin:0;color:`,
697
+ `;font-family:var(--Font-Main,Manrope);font-size:var(--Size-Title-S,14px);font-style:normal;font-weight:700;line-height:var(--Line-height-Title-S,18px);text-align:center;`
698
+ ], ({ theme }) => theme.colors.text.primary);
699
+ var FeesMonthList = styled5.ul.withConfig({
700
+ componentId: "sc-a2e40b03-11"
701
+ })([
702
+ `display:flex;margin:8px 0 0;padding:0;justify-content:center;gap:16px;list-style:none;@media (max-width:767px){justify-content:flex-start;overflow-x:auto;padding-bottom:4px;}`
703
+ ]);
704
+ var FeesMonthButton = styled5.button.withConfig({
705
+ componentId: "sc-a2e40b03-12"
706
+ })([
707
+ `display:inline-flex;gap:4px;padding:0;border:0;background:transparent;cursor:pointer;white-space:nowrap;&:focus-visible{outline:2px solid `,
708
+ `;outline-offset:2px;}`
709
+ ], ({ theme }) => theme.colors.accent.primary);
710
+ var FeesMonthName = styled5.span.withConfig({
711
+ componentId: "sc-a2e40b03-13"
712
+ })([
713
+ `color:`,
714
+ `;font-family:var(--Font-Main,Manrope);font-size:var(--Size-Title-S,14px);font-style:normal;font-weight:700;line-height:var(--Line-height-Title-S,18px);`
715
+ ], ({ theme }) => theme.colors.text.secondary);
716
+ var FeesMonthCode = styled5.span.withConfig({
717
+ componentId: "sc-a2e40b03-14"
718
+ })([
719
+ `color:`,
720
+ `;font-family:var(--Font-Main,Manrope);font-size:var(--Size-Title-S,14px);font-style:normal;font-weight:500;line-height:var(--Line-height-Body-S,18px);`
721
+ ], ({ theme }) => theme.colors.text.primary);
722
+
723
+ // src/wikex/fees-table-model.ts
724
+ var FEES_PAGE_SIZE = 25;
725
+ function normalizeFeesSearch(value) {
726
+ return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/đ/g, "d").replace(/Đ/g, "D").toLowerCase().trim();
727
+ }
728
+ function filterFeesRows(data, search, tag) {
729
+ const query = normalizeFeesSearch(search);
730
+ return data.rows.filter((row) => (!tag || row.tags.includes(tag)) && (!query || Object.values(row.cells).some((cell) => normalizeFeesSearch(cell).includes(query))));
731
+ }
732
+ function paginateFeesRows(rows, requestedPage, pageSize = FEES_PAGE_SIZE) {
733
+ const size = pageSize === -1 ? Math.max(1, rows.length) : Number.isInteger(pageSize) && pageSize > 0 ? pageSize : FEES_PAGE_SIZE;
734
+ const pageCount = Math.max(1, Math.ceil(rows.length / size));
735
+ const page = Math.min(pageCount, Math.max(1, Number.isFinite(requestedPage) ? Math.floor(requestedPage) : 1));
736
+ return { page, pageCount, rows: rows.slice((page - 1) * size, page * size) };
737
+ }
738
+ function moveFeesItem(items, from, to) {
739
+ if (!Number.isInteger(from) || !Number.isInteger(to) || from < 0 || from >= items.length || to < 0 || to >= items.length || from === to) return items;
740
+ const next = [...items];
741
+ const [item] = next.splice(from, 1);
742
+ next.splice(to, 0, item);
743
+ return next;
744
+ }
745
+
746
+ // src/wikex/fees-table.tsx
747
+ var fallbackColors = lightColors;
748
+ var feesTheme = {
749
+ colors: Object.fromEntries(Object.entries(appTheme.colors).map(([group, tokens]) => [
750
+ group,
751
+ Object.fromEntries(Object.entries(tokens).map(([name, variable]) => [
752
+ name,
753
+ variable.replace(/\)$/, `, ${fallbackColors[group][name]})`)
754
+ ]))
755
+ ]))
756
+ };
757
+ var EditorActions = styled6.div.withConfig({
758
+ componentId: "sc-a6ff7adc-0"
759
+ })([
760
+ `display:flex;flex-wrap:wrap;gap:8px;margin-top:16px;`
761
+ ]);
762
+ var EditGroup = styled6.div.withConfig({
763
+ componentId: "sc-a6ff7adc-1"
764
+ })([
765
+ `display:flex;flex-direction:column;gap:6px;`
766
+ ]);
767
+ var HeaderGroup = styled6(EditGroup).withConfig({
768
+ componentId: "sc-a6ff7adc-2"
769
+ })([
770
+ `gap:8px;`
771
+ ]);
772
+ var HeaderTitle = styled6.div.withConfig({
773
+ componentId: "sc-a6ff7adc-3"
774
+ })([
775
+ `display:flex;align-items:flex-start;min-height:var(--fees-header-title-height,36px);`
776
+ ]);
777
+ var HeaderActions = styled6.div.withConfig({
778
+ componentId: "sc-a6ff7adc-4"
779
+ })([
780
+ `display:flex;align-items:center;min-height:24px;`
781
+ ]);
782
+ var AlignedFeesTable = styled6(FeesAndMarginTable).withConfig({
783
+ componentId: "sc-a6ff7adc-5"
784
+ })([
785
+ `&[data-editable] th{vertical-align:top;}`
786
+ ]);
787
+ var EditorButton = styled6.button.withConfig({
788
+ componentId: "sc-a6ff7adc-6"
789
+ })([
790
+ `padding:7px 12px;border:1px solid `,
791
+ `;border-radius:6px;background:`,
792
+ `;color:`,
793
+ `;font:inherit;font-size:13px;cursor:pointer;&:hover,&:focus-visible{border-color:`,
794
+ `;}&:disabled{cursor:default;opacity:.4;}`
795
+ ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
796
+ var OrderActions = styled6.div.withConfig({
797
+ componentId: "sc-a6ff7adc-7"
798
+ })([
799
+ `display:flex;gap:6px;align-items:center;flex-wrap:wrap;`
800
+ ]);
801
+ var PositionLabel = styled6.label.withConfig({
802
+ componentId: "sc-a6ff7adc-8"
803
+ })([
804
+ `display:inline-flex;align-items:center;gap:6px;font-size:12px;`
805
+ ]);
806
+ var PositionInput = styled6.input.withConfig({
807
+ componentId: "sc-a6ff7adc-9"
808
+ })([
809
+ `width:56px;padding:5px;border:1px solid `,
810
+ `;border-radius:4px;background:`,
811
+ `;color:`,
812
+ `;font:inherit;&:focus{outline:1px solid `,
813
+ `;}`
814
+ ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
815
+ var ColumnRow = styled6.div.withConfig({
816
+ componentId: "sc-a6ff7adc-10"
817
+ })([
818
+ `display:flex;gap:12px;align-items:center;margin:16px 0;> textarea{flex:1;min-width:120px;}@media (max-width:600px){align-items:stretch;flex-direction:column;}`
819
+ ]);
820
+ var PaginationControls = styled6(FeesAndMarginPagination).withConfig({
821
+ componentId: "sc-a6ff7adc-11"
822
+ })([
823
+ `align-items:center;flex-wrap:wrap;gap:16px 24px;`
824
+ ]);
825
+ var PageSizeLabel = styled6.div.withConfig({
826
+ componentId: "sc-a6ff7adc-12"
827
+ })([
828
+ `display:inline-flex;align-items:center;gap:8px;color:`,
829
+ `;font:inherit;font-size:13px;`
830
+ ], ({ theme }) => theme.colors.text.primary);
831
+ function Position({ value, max, label, onMove }) {
832
+ return /* @__PURE__ */ _jsxs(PositionLabel, {
833
+ children: [
834
+ "V\u1ECB tr\xED",
835
+ /* @__PURE__ */ _jsx(PositionInput, {
836
+ "aria-label": label,
837
+ type: "number",
838
+ min: 1,
839
+ max,
840
+ defaultValue: value + 1,
841
+ onKeyDown: (event) => {
842
+ if (event.key === "Enter") event.currentTarget.blur();
843
+ },
844
+ onBlur: (event) => {
845
+ const next = Number(event.currentTarget.value);
846
+ if (Number.isInteger(next) && next >= 1 && next <= max) onMove(next - 1);
847
+ else event.currentTarget.value = String(value + 1);
848
+ }
849
+ }, value)
850
+ ]
851
+ });
852
+ }
853
+ var DeleteButton = styled6(EditorButton).withConfig({
854
+ componentId: "sc-a6ff7adc-13"
855
+ })([
856
+ `align-self:flex-start;padding:4px 8px;border:0;border-radius:4px;background:#d32f2f;color:#fff;font-size:11px;font-weight:600;line-height:16px;white-space:nowrap;text-decoration:none;&:hover{background:#b71c1c;}&:focus-visible{outline:2px solid #d32f2f;outline-offset:2px;}`
857
+ ]);
858
+ var CellEditorInput = styled6.textarea.withConfig({
859
+ componentId: "sc-a6ff7adc-14"
860
+ })([
861
+ `display:block;box-sizing:border-box;width:100%;min-width:0;padding:3px;border:1px solid transparent;border-radius:3px;color:inherit;background:transparent;font:inherit;line-height:inherit;resize:none;overflow:hidden;&:hover{border-color:`,
862
+ `;}&:focus{outline:1px solid `,
863
+ `;}`
864
+ ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.accent.primary);
865
+ function CellEditor({ onInput, ...props }) {
866
+ const ref = useRef(null);
867
+ const fit = () => {
868
+ const element = ref.current;
869
+ if (!element) return;
870
+ element.style.height = "0px";
871
+ const style = element.ownerDocument.defaultView.getComputedStyle(element);
872
+ const border = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
873
+ element.style.height = `${element.scrollHeight + border}px`;
874
+ };
875
+ useLayoutEffect(fit, [
876
+ props.value,
877
+ props.defaultValue
878
+ ]);
879
+ useLayoutEffect(() => {
880
+ const element = ref.current;
881
+ if (!element) return;
882
+ let width = element.getBoundingClientRect().width;
883
+ const observer = new ResizeObserver(() => {
884
+ const nextWidth = element.getBoundingClientRect().width;
885
+ if (nextWidth !== width) {
886
+ width = nextWidth;
887
+ fit();
888
+ }
889
+ });
890
+ observer.observe(element);
891
+ let active = true;
892
+ void element.ownerDocument.fonts.ready.then(() => {
893
+ if (active) fit();
894
+ });
895
+ return () => {
896
+ active = false;
897
+ observer.disconnect();
898
+ };
899
+ }, []);
900
+ return /* @__PURE__ */ _jsx(CellEditorInput, {
901
+ ...props,
902
+ ref,
903
+ rows: 1,
904
+ onInput: (event) => {
905
+ fit();
906
+ onInput?.(event);
907
+ }
908
+ });
909
+ }
910
+ function RowTagSelect({ selected, options, onChange }) {
911
+ const selectRoot = useRef(null);
912
+ return /* @__PURE__ */ _jsx(EditGroup, {
913
+ children: /* @__PURE__ */ _jsx("div", {
914
+ ref: selectRoot,
915
+ children: /* @__PURE__ */ _jsxs(Select, {
916
+ multiple: true,
917
+ fullWidth: true,
918
+ size: "small",
919
+ displayEmpty: true,
920
+ value: selected,
921
+ inputProps: {
922
+ "aria-label": "Ch\u1ECDn tag"
923
+ },
924
+ renderValue: (value) => value.length ? `\u0110\xE3 ch\u1ECDn ${value.length} tag` : "Ch\u1ECDn tag\u2026",
925
+ MenuProps: {
926
+ container: () => selectRoot.current?.ownerDocument.body ?? document.body
927
+ },
928
+ onChange: (event) => {
929
+ const value = event.target.value;
930
+ onChange(typeof value === "string" ? value.split(",") : value);
931
+ },
932
+ sx: {
933
+ fontSize: 13
934
+ },
935
+ children: [
936
+ options.map((item) => /* @__PURE__ */ _jsxs(MenuItem, {
937
+ value: item,
938
+ children: [
939
+ /* @__PURE__ */ _jsx(Checkbox, {
940
+ size: "small",
941
+ checked: selected.includes(item),
942
+ tabIndex: -1,
943
+ disableRipple: true
944
+ }),
945
+ item
946
+ ]
947
+ }, item)),
948
+ !options.length && /* @__PURE__ */ _jsx(MenuItem, {
949
+ disabled: true,
950
+ children: "Ch\u01B0a c\xF3 tag \u2014 d\xF9ng n\xFAt Th\xEAm tag ph\xEDa tr\xEAn"
951
+ })
952
+ ]
953
+ })
954
+ })
955
+ });
956
+ }
957
+ var columnWidths = {
958
+ name: 100,
959
+ code: 96,
960
+ exchange: 94,
961
+ initialMargin: 126,
962
+ tradingFee: 100,
963
+ tickSize: 92,
964
+ margin: 100,
965
+ priceUnit: 112,
966
+ contractSize: 150,
967
+ settlement: 126,
968
+ deliveryDay: 154,
969
+ tradingHours: 160,
970
+ priceRange: 112
971
+ };
972
+ function FeesTable({ value, editable = false, onChange, labels, size = "md", tagOrder = [], language = "vi" }) {
973
+ const [search, setSearch] = useState("");
974
+ const [tag, setTag] = useState("");
975
+ const [page, setPage] = useState(1);
976
+ const [pageSize, setPageSize] = useState(FEES_PAGE_SIZE);
977
+ const [columnsOpen, setColumnsOpen] = useState(false);
978
+ const english = language === "en";
979
+ const canEdit = editable && Boolean(onChange);
980
+ const tableRoot = useRef(null);
981
+ useLayoutEffect(() => {
982
+ const root = tableRoot.current;
983
+ if (!root || !canEdit) return;
984
+ const editors = [
985
+ ...root.querySelectorAll("thead textarea")
986
+ ];
987
+ const align = () => {
988
+ const height = Math.max(36, ...editors.map((editor) => editor.getBoundingClientRect().height));
989
+ root.style.setProperty("--fees-header-title-height", `${height}px`);
990
+ };
991
+ const observer = new ResizeObserver(align);
992
+ editors.forEach((editor) => observer.observe(editor));
993
+ align();
994
+ return () => observer.disconnect();
995
+ }, [
996
+ canEdit,
997
+ value.columns
998
+ ]);
999
+ const dialogId = useId();
1000
+ const [createTagOpen, setCreateTagOpen] = useState(false);
1001
+ const [tagDraft, setTagDraft] = useState("");
1002
+ const [deleteTarget, setDeleteTarget] = useState(null);
1003
+ const confirmDelete = () => {
1004
+ if (!deleteTarget || !canEdit) return;
1005
+ if (deleteTarget.kind === "row") {
1006
+ onChange?.({
1007
+ ...value,
1008
+ rows: value.rows.filter((row) => row.id !== deleteTarget.id)
1009
+ });
1010
+ } else if (deleteTarget.id !== "name") {
1011
+ onChange?.({
1012
+ ...value,
1013
+ columns: value.columns.filter((column) => column.key !== deleteTarget.id),
1014
+ rows: value.rows.map((row) => ({
1015
+ ...row,
1016
+ cells: Object.fromEntries(Object.entries(row.cells).filter(([key]) => key !== deleteTarget.id))
1017
+ }))
1018
+ });
1019
+ }
1020
+ setDeleteTarget(null);
1021
+ };
1022
+ const rowTags = [
1023
+ .../* @__PURE__ */ new Set([
1024
+ ...value.tags ?? [],
1025
+ ...value.rows.flatMap((row) => row.tags)
1026
+ ])
1027
+ ].filter(Boolean);
1028
+ const tags = [
1029
+ ...tagOrder.filter((item) => rowTags.includes(item)),
1030
+ ...rowTags.filter((item) => !tagOrder.includes(item))
1031
+ ];
1032
+ const newTagName = tagDraft.trim().replace(/\s+/g, " ");
1033
+ const duplicateTag = tags.some((item) => item.toLocaleLowerCase("vi") === newTagName.toLocaleLowerCase("vi"));
1034
+ const createTag = () => {
1035
+ if (!canEdit || !newTagName || duplicateTag) return;
1036
+ onChange?.({
1037
+ ...value,
1038
+ tags: [
1039
+ ...tags,
1040
+ newTagName
1041
+ ]
1042
+ });
1043
+ setCreateTagOpen(false);
1044
+ setTagDraft("");
1045
+ };
1046
+ const activeTag = tags.includes(tag) ? tag : "";
1047
+ const filtered = filterFeesRows(value, search, activeTag);
1048
+ const pagination = paginateFeesRows(filtered, page, pageSize);
1049
+ const moveColumn = (from, to) => onChange?.({
1050
+ ...value,
1051
+ columns: moveFeesItem(value.columns, from, to)
1052
+ });
1053
+ const moveRow = (id, to) => {
1054
+ const rows = moveFeesItem(value.rows, value.rows.findIndex((row) => row.id === id), to);
1055
+ onChange?.({
1056
+ ...value,
1057
+ rows
1058
+ });
1059
+ const filteredIds = new Set(filtered.map((row) => row.id));
1060
+ const index = rows.filter((row) => filteredIds.has(row.id)).findIndex((row) => row.id === id);
1061
+ setPage(pageSize === -1 ? 1 : Math.floor(Math.max(0, index) / pageSize) + 1);
1062
+ };
1063
+ const addColumn = () => {
1064
+ const key = `column-${crypto.randomUUID()}`;
1065
+ onChange?.({
1066
+ ...value,
1067
+ columns: [
1068
+ ...value.columns,
1069
+ {
1070
+ key,
1071
+ title: "C\u1ED9t m\u1EDBi"
1072
+ }
1073
+ ],
1074
+ rows: value.rows.map((row) => ({
1075
+ ...row,
1076
+ cells: {
1077
+ ...row.cells,
1078
+ [key]: ""
1079
+ }
1080
+ }))
1081
+ });
1082
+ };
1083
+ const changeRow = (id, patch) => onChange?.({
1084
+ ...value,
1085
+ rows: value.rows.map((row) => row.id === id ? {
1086
+ ...row,
1087
+ ...patch
1088
+ } : row)
1089
+ });
1090
+ const columns = value.columns.map((column, index) => ({
1091
+ key: column.key,
1092
+ width: columnWidths[column.key] ?? 140,
1093
+ fixed: index === 0 ? "left" : void 0,
1094
+ title: canEdit ? /* @__PURE__ */ _jsxs(HeaderGroup, {
1095
+ children: [
1096
+ /* @__PURE__ */ _jsx(HeaderTitle, {
1097
+ children: /* @__PURE__ */ _jsx(CellEditor, {
1098
+ rows: 2,
1099
+ value: column.title,
1100
+ "aria-label": `Ti\xEAu \u0111\u1EC1 c\u1ED9t ${index + 1}`,
1101
+ onChange: (event) => onChange?.({
1102
+ ...value,
1103
+ columns: value.columns.map((item) => item.key === column.key ? {
1104
+ ...item,
1105
+ title: event.target.value
1106
+ } : item)
1107
+ })
1108
+ })
1109
+ }),
1110
+ /* @__PURE__ */ _jsx(HeaderActions, {
1111
+ children: column.key !== "name" && /* @__PURE__ */ _jsx(DeleteButton, {
1112
+ type: "button",
1113
+ onClick: () => {
1114
+ setDeleteTarget({
1115
+ kind: "column",
1116
+ id: column.key,
1117
+ label: column.title
1118
+ });
1119
+ },
1120
+ children: "X\xF3a c\u1ED9t"
1121
+ })
1122
+ })
1123
+ ]
1124
+ }) : column.title,
1125
+ render: (_unused, row) => canEdit ? /* @__PURE__ */ _jsx(CellEditor, {
1126
+ rows: Math.max(2, (row.cells[column.key] ?? "").split("\n").length),
1127
+ value: row.cells[column.key] ?? "",
1128
+ "aria-label": `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}`,
1129
+ onChange: (event) => changeRow(row.id, {
1130
+ cells: {
1131
+ ...row.cells,
1132
+ [column.key]: event.target.value
1133
+ }
1134
+ })
1135
+ }) : row.cells[column.key] ?? ""
1136
+ }));
1137
+ if (canEdit) columns.push({
1138
+ key: "__tags",
1139
+ title: /* @__PURE__ */ _jsxs(HeaderGroup, {
1140
+ children: [
1141
+ /* @__PURE__ */ _jsx(HeaderTitle, {
1142
+ children: "Tag & th\u1EE9 t\u1EF1 d\xF2ng"
1143
+ }),
1144
+ /* @__PURE__ */ _jsx(HeaderActions, {})
1145
+ ]
1146
+ }),
1147
+ width: 300,
1148
+ render: (_unused, row) => /* @__PURE__ */ _jsxs(EditGroup, {
1149
+ children: [
1150
+ /* @__PURE__ */ _jsx(RowTagSelect, {
1151
+ selected: row.tags,
1152
+ options: tags,
1153
+ onChange: (next) => changeRow(row.id, {
1154
+ tags: next
1155
+ })
1156
+ }),
1157
+ /* @__PURE__ */ _jsxs(OrderActions, {
1158
+ children: [
1159
+ /* @__PURE__ */ _jsx(Position, {
1160
+ value: value.rows.findIndex((item) => item.id === row.id),
1161
+ max: value.rows.length,
1162
+ label: `V\u1ECB tr\xED d\xF2ng ${row.cells.name}`,
1163
+ onMove: (to) => moveRow(row.id, to)
1164
+ }),
1165
+ /* @__PURE__ */ _jsx(EditorButton, {
1166
+ type: "button",
1167
+ "aria-label": `\u0110\u01B0a d\xF2ng ${row.cells.name} l\xEAn`,
1168
+ disabled: value.rows[0]?.id === row.id,
1169
+ onClick: () => moveRow(row.id, value.rows.findIndex((item) => item.id === row.id) - 1),
1170
+ children: "\u2191"
1171
+ }),
1172
+ /* @__PURE__ */ _jsx(EditorButton, {
1173
+ type: "button",
1174
+ "aria-label": `\u0110\u01B0a d\xF2ng ${row.cells.name} xu\u1ED1ng`,
1175
+ disabled: value.rows[value.rows.length - 1]?.id === row.id,
1176
+ onClick: () => moveRow(row.id, value.rows.findIndex((item) => item.id === row.id) + 1),
1177
+ children: "\u2193"
1178
+ })
1179
+ ]
1180
+ }),
1181
+ /* @__PURE__ */ _jsx(DeleteButton, {
1182
+ type: "button",
1183
+ onClick: () => {
1184
+ setDeleteTarget({
1185
+ kind: "row",
1186
+ id: row.id,
1187
+ label: row.cells.name || "H\xE0ng m\u1EDBi"
1188
+ });
1189
+ },
1190
+ children: "X\xF3a h\xE0ng"
1191
+ })
1192
+ ]
1193
+ })
1194
+ });
1195
+ return /* @__PURE__ */ _jsx(ThemeProvider, {
1196
+ theme: feesTheme,
1197
+ children: /* @__PURE__ */ _jsxs("div", {
1198
+ ref: tableRoot,
1199
+ "data-cms-table-editor": true,
1200
+ onClick: (event) => {
1201
+ if (canEdit) event.stopPropagation();
1202
+ },
1203
+ children: [
1204
+ /* @__PURE__ */ _jsx(FeesAndMarginToolbar, {
1205
+ "aria-label": "L\u1ECDc b\u1EA3ng ph\xED v\xE0 k\xFD qu\u1EF9",
1206
+ children: /* @__PURE__ */ _jsxs(FeesAndMarginToolbarInner, {
1207
+ children: [
1208
+ /* @__PURE__ */ _jsx("div", {
1209
+ style: {
1210
+ minWidth: 0
1211
+ },
1212
+ children: /* @__PURE__ */ _jsx(TabCommon, {
1213
+ ariaLabel: "L\u1ECDc theo tag",
1214
+ size,
1215
+ items: [
1216
+ {
1217
+ id: "",
1218
+ label: labels?.all ?? "T\u1EA5t c\u1EA3"
1219
+ },
1220
+ ...tags.map((item) => ({
1221
+ id: item,
1222
+ label: item
1223
+ }))
1224
+ ],
1225
+ value: activeTag,
1226
+ onValueChange: (next) => {
1227
+ setTag(next);
1228
+ setPage(1);
1229
+ }
1230
+ })
1231
+ }),
1232
+ /* @__PURE__ */ _jsx(FeesAndMarginSearch, {
1233
+ children: /* @__PURE__ */ _jsx(InputCommon, {
1234
+ leftIcon: /* @__PURE__ */ _jsx(FeesSearchIcon, {}),
1235
+ size: "sm",
1236
+ "aria-label": labels?.search ?? "T\xECm t\xEAn h\xE0ng h\xF3a ho\u1EB7c m\xE3",
1237
+ placeholder: labels?.search ?? "T\xECm t\xEAn h\xE0ng h\xF3a ho\u1EB7c m\xE3",
1238
+ value: search,
1239
+ onChange: (event) => {
1240
+ setSearch(event.target.value);
1241
+ setPage(1);
1242
+ }
1243
+ })
1244
+ })
1245
+ ]
1246
+ })
1247
+ }),
1248
+ canEdit && /* @__PURE__ */ _jsxs(EditorActions, {
1249
+ children: [
1250
+ /* @__PURE__ */ _jsx(EditorButton, {
1251
+ type: "button",
1252
+ onClick: () => {
1253
+ const row = {
1254
+ id: crypto.randomUUID(),
1255
+ cells: Object.fromEntries(value.columns.map((column) => [
1256
+ column.key,
1257
+ column.key === "name" ? "H\xE0ng h\xF3a m\u1EDBi" : ""
1258
+ ])),
1259
+ tags: []
1260
+ };
1261
+ onChange?.({
1262
+ ...value,
1263
+ rows: [
1264
+ ...value.rows,
1265
+ row
1266
+ ]
1267
+ });
1268
+ setSearch("");
1269
+ setTag("");
1270
+ setPage(pageSize === -1 ? 1 : Math.ceil((value.rows.length + 1) / pageSize));
1271
+ },
1272
+ children: "+ Th\xEAm h\xE0ng"
1273
+ }),
1274
+ /* @__PURE__ */ _jsx(EditorButton, {
1275
+ type: "button",
1276
+ onClick: addColumn,
1277
+ children: "+ Th\xEAm c\u1ED9t"
1278
+ }),
1279
+ /* @__PURE__ */ _jsxs(EditorButton, {
1280
+ type: "button",
1281
+ onClick: () => setColumnsOpen(true),
1282
+ children: [
1283
+ "Qu\u1EA3n l\xFD c\u1ED9t (",
1284
+ value.columns.length,
1285
+ ")"
1286
+ ]
1287
+ }),
1288
+ /* @__PURE__ */ _jsx(EditorButton, {
1289
+ type: "button",
1290
+ onClick: () => {
1291
+ setTagDraft("");
1292
+ setCreateTagOpen(true);
1293
+ },
1294
+ children: "+ Th\xEAm tag"
1295
+ })
1296
+ ]
1297
+ }),
1298
+ /* @__PURE__ */ _jsx(AlignedFeesTable, {
1299
+ "data-editable": canEdit || void 0,
1300
+ children: /* @__PURE__ */ _jsx(Table, {
1301
+ ariaLabel: english ? "Fees and margin table" : "B\u1EA3ng ph\xED v\xE0 k\xFD qu\u1EF9",
1302
+ columns,
1303
+ dataSource: pagination.rows,
1304
+ rowKey: "id",
1305
+ size,
1306
+ empty: labels?.empty ?? "Kh\xF4ng t\xECm th\u1EA5y h\xE0ng h\xF3a",
1307
+ scroll: {
1308
+ x: Math.max(1440, value.columns.reduce((sum, column) => sum + (columnWidths[column.key] ?? 140), 0) + (canEdit ? 300 : 0))
1309
+ }
1310
+ })
1311
+ }),
1312
+ /* @__PURE__ */ _jsxs(PaginationControls, {
1313
+ children: [
1314
+ /* @__PURE__ */ _jsxs(PageSizeLabel, {
1315
+ children: [
1316
+ /* @__PURE__ */ _jsx("span", {
1317
+ id: `${dialogId}-page-size-label`,
1318
+ children: english ? "Rows per page:" : "S\u1ED1 d\xF2ng m\u1ED7i trang:"
1319
+ }),
1320
+ /* @__PURE__ */ _jsxs(Select, {
1321
+ size: "small",
1322
+ value: pageSize,
1323
+ labelId: `${dialogId}-page-size-label`,
1324
+ inputProps: {
1325
+ "aria-label": english ? "Rows per page" : "S\u1ED1 d\xF2ng m\u1ED7i trang"
1326
+ },
1327
+ MenuProps: {
1328
+ container: () => tableRoot.current?.ownerDocument.body ?? document.body
1329
+ },
1330
+ sx: {
1331
+ minWidth: 80,
1332
+ fontSize: 13,
1333
+ fontFamily: "inherit"
1334
+ },
1335
+ onChange: (event) => {
1336
+ setPageSize(Number(event.target.value));
1337
+ setPage(1);
1338
+ },
1339
+ children: [
1340
+ [
1341
+ 5,
1342
+ 10,
1343
+ 25,
1344
+ 50,
1345
+ 100
1346
+ ].map((size2) => /* @__PURE__ */ _jsx(MenuItem, {
1347
+ value: size2,
1348
+ children: size2
1349
+ }, size2)),
1350
+ /* @__PURE__ */ _jsx(MenuItem, {
1351
+ value: -1,
1352
+ children: english ? "All" : "T\u1EA5t c\u1EA3"
1353
+ })
1354
+ ]
1355
+ })
1356
+ ]
1357
+ }),
1358
+ /* @__PURE__ */ _jsxs("span", {
1359
+ "aria-live": "polite",
1360
+ style: {
1361
+ fontSize: 13
1362
+ },
1363
+ children: [
1364
+ filtered.length ? pageSize === -1 ? 1 : (pagination.page - 1) * pageSize + 1 : 0,
1365
+ "\u2013",
1366
+ pageSize === -1 ? filtered.length : Math.min(pagination.page * pageSize, filtered.length),
1367
+ " / ",
1368
+ filtered.length
1369
+ ]
1370
+ }),
1371
+ /* @__PURE__ */ _jsx(Pagination, {
1372
+ page: pagination.page,
1373
+ pageCount: pagination.pageCount,
1374
+ onPageChange: setPage,
1375
+ ariaLabel: english ? "Fees pagination" : "Ph\xE2n trang b\u1EA3ng ph\xED",
1376
+ labels: {
1377
+ previous: english ? "Previous page" : "Trang tr\u01B0\u1EDBc",
1378
+ next: english ? "Next page" : "Trang sau",
1379
+ page: (number) => `${english ? "Go to page" : "\u0110i t\u1EDBi trang"} ${number}`,
1380
+ current: (number) => `${english ? "Current page" : "Trang hi\u1EC7n t\u1EA1i"}, ${number}`
1381
+ }
1382
+ })
1383
+ ]
1384
+ }),
1385
+ /* @__PURE__ */ _jsxs(Dialog, {
1386
+ open: columnsOpen && canEdit,
1387
+ onClose: () => setColumnsOpen(false),
1388
+ container: () => tableRoot.current?.ownerDocument.body ?? document.body,
1389
+ "aria-labelledby": `${dialogId}-columns-title`,
1390
+ fullWidth: true,
1391
+ maxWidth: "md",
1392
+ children: [
1393
+ /* @__PURE__ */ _jsx(DialogTitle, {
1394
+ id: `${dialogId}-columns-title`,
1395
+ children: "Qu\u1EA3n l\xFD c\u1ED9t"
1396
+ }),
1397
+ /* @__PURE__ */ _jsxs(DialogContent, {
1398
+ children: [
1399
+ /* @__PURE__ */ _jsx(DialogContentText, {
1400
+ children: "\u0110\u1ED5i ti\xEAu \u0111\u1EC1 v\xE0 v\u1ECB tr\xED c\u1ED9t. V\u1ECB tr\xED d\xF2ng/c\u1ED9t \u0111\u01B0\u1EE3c t\xEDnh trong to\xE0n b\u1EA3ng, k\u1EC3 c\u1EA3 c\xE1c d\xF2ng \u0111ang \u1EA9n b\u1EDFi b\u1ED9 l\u1ECDc."
1401
+ }),
1402
+ value.columns.map((column, index) => /* @__PURE__ */ _jsxs(ColumnRow, {
1403
+ children: [
1404
+ /* @__PURE__ */ _jsx(CellEditor, {
1405
+ "aria-label": `Ti\xEAu \u0111\u1EC1 c\u1ED9t ${index + 1}`,
1406
+ value: column.title,
1407
+ onChange: (event) => onChange?.({
1408
+ ...value,
1409
+ columns: value.columns.map((item) => item.key === column.key ? {
1410
+ ...item,
1411
+ title: event.target.value
1412
+ } : item)
1413
+ })
1414
+ }),
1415
+ /* @__PURE__ */ _jsxs(OrderActions, {
1416
+ children: [
1417
+ /* @__PURE__ */ _jsx(Position, {
1418
+ value: index,
1419
+ max: value.columns.length,
1420
+ label: `V\u1ECB tr\xED c\u1ED9t ${column.title}`,
1421
+ onMove: (to) => moveColumn(index, to)
1422
+ }),
1423
+ /* @__PURE__ */ _jsx(EditorButton, {
1424
+ type: "button",
1425
+ "aria-label": `\u0110\u01B0a c\u1ED9t ${column.title} l\xEAn`,
1426
+ disabled: index === 0,
1427
+ onClick: () => moveColumn(index, index - 1),
1428
+ children: "\u2191"
1429
+ }),
1430
+ /* @__PURE__ */ _jsx(EditorButton, {
1431
+ type: "button",
1432
+ "aria-label": `\u0110\u01B0a c\u1ED9t ${column.title} xu\u1ED1ng`,
1433
+ disabled: index === value.columns.length - 1,
1434
+ onClick: () => moveColumn(index, index + 1),
1435
+ children: "\u2193"
1436
+ }),
1437
+ /* @__PURE__ */ _jsx(DeleteButton, {
1438
+ type: "button",
1439
+ disabled: column.key === "name",
1440
+ onClick: () => setDeleteTarget({
1441
+ kind: "column",
1442
+ id: column.key,
1443
+ label: column.title
1444
+ }),
1445
+ children: "X\xF3a c\u1ED9t"
1446
+ })
1447
+ ]
1448
+ })
1449
+ ]
1450
+ }, column.key)),
1451
+ /* @__PURE__ */ _jsx(EditorButton, {
1452
+ type: "button",
1453
+ onClick: addColumn,
1454
+ children: "+ Th\xEAm c\u1ED9t"
1455
+ })
1456
+ ]
1457
+ }),
1458
+ /* @__PURE__ */ _jsx(DialogActions, {
1459
+ children: /* @__PURE__ */ _jsx(Button, {
1460
+ variant: "contained",
1461
+ onClick: () => setColumnsOpen(false),
1462
+ children: "Xong"
1463
+ })
1464
+ })
1465
+ ]
1466
+ }),
1467
+ /* @__PURE__ */ _jsxs(Dialog, {
1468
+ open: createTagOpen && canEdit,
1469
+ onClose: () => setCreateTagOpen(false),
1470
+ container: () => tableRoot.current?.ownerDocument.body ?? document.body,
1471
+ "aria-labelledby": `${dialogId}-create-tag-title`,
1472
+ fullWidth: true,
1473
+ maxWidth: "xs",
1474
+ children: [
1475
+ /* @__PURE__ */ _jsx(DialogTitle, {
1476
+ id: `${dialogId}-create-tag-title`,
1477
+ children: "T\u1EA1o tag m\u1EDBi"
1478
+ }),
1479
+ /* @__PURE__ */ _jsx(DialogContent, {
1480
+ children: /* @__PURE__ */ _jsx(TextField, {
1481
+ autoFocus: true,
1482
+ fullWidth: true,
1483
+ margin: "dense",
1484
+ label: "T\xEAn tag",
1485
+ value: tagDraft,
1486
+ onChange: (event) => setTagDraft(event.target.value),
1487
+ error: duplicateTag,
1488
+ helperText: duplicateTag ? "Tag n\xE0y \u0111\xE3 t\u1ED3n t\u1EA1i." : "Tag m\u1EDBi s\u1EBD c\xF3 trong danh s\xE1ch ch\u1ECDn c\u1EE7a t\u1EA5t c\u1EA3 h\xE0ng.",
1489
+ onKeyDown: (event) => {
1490
+ if (event.key === "Enter") {
1491
+ event.preventDefault();
1492
+ createTag();
1493
+ }
1494
+ }
1495
+ })
1496
+ }),
1497
+ /* @__PURE__ */ _jsxs(DialogActions, {
1498
+ children: [
1499
+ /* @__PURE__ */ _jsx(Button, {
1500
+ onClick: () => setCreateTagOpen(false),
1501
+ children: "H\u1EE7y"
1502
+ }),
1503
+ /* @__PURE__ */ _jsx(Button, {
1504
+ variant: "contained",
1505
+ disabled: !newTagName || duplicateTag,
1506
+ onClick: createTag,
1507
+ children: "T\u1EA1o tag"
1508
+ })
1509
+ ]
1510
+ })
1511
+ ]
1512
+ }),
1513
+ /* @__PURE__ */ _jsxs(Dialog, {
1514
+ open: Boolean(deleteTarget) && canEdit,
1515
+ onClose: () => setDeleteTarget(null),
1516
+ container: () => tableRoot.current?.ownerDocument.body ?? document.body,
1517
+ "aria-labelledby": `${dialogId}-title`,
1518
+ "aria-describedby": `${dialogId}-description`,
1519
+ fullWidth: true,
1520
+ maxWidth: "xs",
1521
+ children: [
1522
+ /* @__PURE__ */ _jsxs(DialogTitle, {
1523
+ id: `${dialogId}-title`,
1524
+ children: [
1525
+ "X\xF3a ",
1526
+ deleteTarget?.kind === "column" ? "c\u1ED9t" : "h\xE0ng",
1527
+ "?"
1528
+ ]
1529
+ }),
1530
+ /* @__PURE__ */ _jsx(DialogContent, {
1531
+ children: /* @__PURE__ */ _jsx(DialogContentText, {
1532
+ id: `${dialogId}-description`,
1533
+ children: deleteTarget?.kind === "column" ? `B\u1EA1n c\xF3 mu\u1ED1n x\xF3a c\u1ED9t \u201C${deleteTarget.label}\u201D v\xE0 to\xE0n b\u1ED9 n\u1ED9i dung trong c\u1ED9t n\xE0y?` : `B\u1EA1n c\xF3 mu\u1ED1n x\xF3a h\xE0ng \u201C${deleteTarget?.label ?? ""}\u201D?`
1534
+ })
1535
+ }),
1536
+ /* @__PURE__ */ _jsxs(DialogActions, {
1537
+ children: [
1538
+ /* @__PURE__ */ _jsx(Button, {
1539
+ autoFocus: true,
1540
+ onClick: () => setDeleteTarget(null),
1541
+ children: "H\u1EE7y"
1542
+ }),
1543
+ /* @__PURE__ */ _jsxs(Button, {
1544
+ color: "error",
1545
+ variant: "contained",
1546
+ onClick: confirmDelete,
1547
+ children: [
1548
+ "X\xF3a ",
1549
+ deleteTarget?.kind === "column" ? "c\u1ED9t" : "h\xE0ng"
1550
+ ]
1551
+ })
1552
+ ]
1553
+ })
1554
+ ]
1555
+ })
1556
+ ]
1557
+ })
1558
+ });
1559
+ }
1560
+
1561
+ // src/wikex/fees-manager.tsx
1562
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1563
+ function FeesManager({
1564
+ entries,
1565
+ selectedId,
1566
+ language,
1567
+ table,
1568
+ dirtyKeys,
1569
+ canWrite,
1570
+ saving = false,
1571
+ notice,
1572
+ parseError,
1573
+ statusChipVariant = "filled",
1574
+ onSelectEntry,
1575
+ onSelectLanguage,
1576
+ onChange,
1577
+ onSave,
1578
+ onDismissNotice
1579
+ }) {
1580
+ const entry = entries.find((item) => item.id === selectedId);
1581
+ const key = `${selectedId}:${language}`;
1582
+ return /* @__PURE__ */ jsxs5(Stack, { spacing: 3, sx: { minWidth: 0, width: 1, maxWidth: 1800, mx: "auto" }, children: [
1583
+ /* @__PURE__ */ jsxs5(Stack, { direction: { xs: "column", md: "row" }, justifyContent: "space-between", alignItems: { md: "center" }, gap: 2.5, children: [
1584
+ /* @__PURE__ */ jsxs5(Stack, { spacing: 1, sx: { minWidth: 0, maxWidth: 720 }, children: [
1585
+ /* @__PURE__ */ jsx5(Typography, { variant: "h4", children: "Ph\xED & k\xFD qu\u1EF9" }),
1586
+ /* @__PURE__ */ jsx5(Typography, { variant: "body2", color: "text.secondary", children: "Qu\u1EA3n l\xFD d\u1EEF li\u1EC7u, tag v\xE0 th\u1EE9 t\u1EF1 hi\u1EC3n th\u1ECB. B\u1ED1 c\u1EE5c v\xE0 n\u1ED9i dung gi\u1EDBi thi\u1EC7u \u0111\u01B0\u1EE3c ch\u1EC9nh trong Layout trang t\u0129nh." })
1587
+ ] }),
1588
+ /* @__PURE__ */ jsxs5(Stack, { direction: "row", spacing: 1.5, alignItems: "center", flexShrink: 0, children: [
1589
+ dirtyKeys.includes(key) && /* @__PURE__ */ jsx5(Chip, { size: "small", color: "warning", label: "Ch\u01B0a l\u01B0u" }),
1590
+ /* @__PURE__ */ jsx5(
1591
+ Button2,
1592
+ {
1593
+ variant: "contained",
1594
+ loading: saving,
1595
+ disabled: !canWrite || !dirtyKeys.includes(key) || saving,
1596
+ onClick: onSave,
1597
+ sx: { minHeight: 44, px: 3, flex: { xs: 1, md: "initial" }, minWidth: { md: 156 } },
1598
+ children: "L\u01B0u b\u1EA3ng ph\xED"
1599
+ }
1600
+ )
1601
+ ] })
1602
+ ] }),
1603
+ !canWrite && /* @__PURE__ */ jsx5(Alert, { severity: "info", children: "B\u1EA1n c\xF3 quy\u1EC1n xem b\u1EA3ng ph\xED. C\u1EA7n quy\u1EC1n s\u1EEDa n\u1ED9i dung \u0111\u1EC3 thay \u0111\u1ED5i d\u1EEF li\u1EC7u." }),
1604
+ notice && /* @__PURE__ */ jsx5(Alert, { severity: notice.severity, onClose: onDismissNotice, children: notice.message }),
1605
+ !entries.length ? /* @__PURE__ */ jsx5(Alert, { severity: "info", children: "Ch\u01B0a c\xF3 b\u1EA3ng ph\xED. Th\xEAm component B\u1EA3ng ph\xED & K\xFD qu\u1EF9 v\xE0o m\u1ED9t trang trong Layout trang t\u0129nh \u0111\u1EC3 b\u1EAFt \u0111\u1EA7u." }) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
1606
+ /* @__PURE__ */ jsx5(Card, { variant: "outlined", sx: { p: { xs: 2.5, md: 3 }, boxShadow: "none" }, children: /* @__PURE__ */ jsxs5(Stack, { spacing: 2.5, children: [
1607
+ /* @__PURE__ */ jsxs5(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 1.5, flexWrap: "wrap", children: [
1608
+ /* @__PURE__ */ jsx5(Typography, { variant: "subtitle1", children: "B\u1EA3ng \u0111ang qu\u1EA3n l\xFD" }),
1609
+ /* @__PURE__ */ jsx5(Chip, { size: "small", variant: statusChipVariant, label: entry?.status === "published" ? "Trang \u0111\xE3 xu\u1EA5t b\u1EA3n" : "Trang b\u1EA3n nh\xE1p", color: entry?.status === "published" ? "success" : "default" })
1610
+ ] }),
1611
+ /* @__PURE__ */ jsxs5(Stack, { direction: { xs: "column", md: "row" }, spacing: 2.5, alignItems: { md: "flex-end" }, children: [
1612
+ /* @__PURE__ */ jsx5(
1613
+ TextField2,
1614
+ {
1615
+ select: true,
1616
+ size: "small",
1617
+ label: "B\u1EA3ng tr\xEAn trang",
1618
+ value: selectedId,
1619
+ disabled: saving,
1620
+ fullWidth: true,
1621
+ sx: { flex: 1, minWidth: 0 },
1622
+ onChange: (event) => onSelectEntry(event.target.value),
1623
+ children: entries.map((item, index) => /* @__PURE__ */ jsxs5(MenuItem2, { value: item.id, children: [
1624
+ item.pageTitle,
1625
+ " \xB7 /",
1626
+ item.slug,
1627
+ " \xB7 #",
1628
+ index + 1,
1629
+ dirtyKeys.some((draft) => draft.startsWith(`${item.id}:`)) ? " (ch\u01B0a l\u01B0u)" : ""
1630
+ ] }, item.id))
1631
+ }
1632
+ ),
1633
+ /* @__PURE__ */ jsxs5(Stack, { spacing: 1, sx: { width: { xs: 1, md: 240 }, flexShrink: 0 }, children: [
1634
+ /* @__PURE__ */ jsx5(Typography, { variant: "caption", color: "text.secondary", children: "Ng\xF4n ng\u1EEF n\u1ED9i dung" }),
1635
+ /* @__PURE__ */ jsxs5(
1636
+ ToggleButtonGroup,
1637
+ {
1638
+ size: "small",
1639
+ exclusive: true,
1640
+ value: language,
1641
+ disabled: saving,
1642
+ "aria-label": "Ng\xF4n ng\u1EEF b\u1EA3ng ph\xED",
1643
+ sx: { minHeight: 40, "& .MuiToggleButton-root": { flex: 1, px: 2 } },
1644
+ onChange: (_, next) => {
1645
+ if (next === "vi" || next === "en") onSelectLanguage(next);
1646
+ },
1647
+ children: [
1648
+ /* @__PURE__ */ jsxs5(ToggleButton, { value: "vi", children: [
1649
+ "Ti\u1EBFng Vi\u1EC7t",
1650
+ dirtyKeys.includes(`${selectedId}:vi`) ? " \u2022" : ""
1651
+ ] }),
1652
+ /* @__PURE__ */ jsxs5(ToggleButton, { value: "en", children: [
1653
+ "English",
1654
+ dirtyKeys.includes(`${selectedId}:en`) ? " \u2022" : ""
1655
+ ] })
1656
+ ]
1657
+ }
1658
+ )
1659
+ ] })
1660
+ ] })
1661
+ ] }) }),
1662
+ parseError && /* @__PURE__ */ jsx5(Alert, { severity: "error", children: parseError }),
1663
+ table && /* @__PURE__ */ jsxs5(Card, { inert: saving, "aria-busy": saving, sx: { minWidth: 0, opacity: saving ? 0.65 : 1 }, children: [
1664
+ /* @__PURE__ */ jsxs5(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, justifyContent: "space-between", alignItems: { sm: "center" }, sx: { px: { xs: 2.5, md: 3 }, py: 2.5 }, children: [
1665
+ /* @__PURE__ */ jsxs5(Stack, { spacing: 0.5, children: [
1666
+ /* @__PURE__ */ jsx5(Typography, { variant: "subtitle1", children: "D\u1EEF li\u1EC7u ph\xED & k\xFD qu\u1EF9" }),
1667
+ /* @__PURE__ */ jsx5(Typography, { variant: "body2", color: "text.secondary", children: canWrite ? "S\u1EEDa tr\u1EF1c ti\u1EBFp trong \xF4. D\xF9ng Qu\u1EA3n l\xFD c\u1ED9t ho\u1EB7c V\u1ECB tr\xED \u0111\u1EC3 \u0111\u1ED5i th\u1EE9 t\u1EF1." : "Tra c\u1EE9u d\u1EEF li\u1EC7u v\xE0 l\u1ECDc theo nh\xF3m h\xE0ng h\xF3a." })
1668
+ ] }),
1669
+ /* @__PURE__ */ jsxs5(Stack, { direction: "row", spacing: 1, flexShrink: 0, children: [
1670
+ /* @__PURE__ */ jsx5(Chip, { size: "small", variant: "outlined", label: `${table.rows.length} d\xF2ng` }),
1671
+ /* @__PURE__ */ jsx5(Chip, { size: "small", variant: "outlined", label: `${table.columns.length} c\u1ED9t` })
1672
+ ] })
1673
+ ] }),
1674
+ /* @__PURE__ */ jsx5(Divider, {}),
1675
+ /* @__PURE__ */ jsxs5(Box, { sx: { p: { xs: 2.5, md: 3 }, minWidth: 0 }, children: [
1676
+ /* @__PURE__ */ jsx5(Typography, { variant: "caption", color: "text.secondary", sx: { display: { xs: "block", md: "none" }, mb: 2 }, children: "Vu\u1ED1t ngang trong b\u1EA3ng \u0111\u1EC3 xem th\xEAm c\xE1c c\u1ED9t." }),
1677
+ /* @__PURE__ */ jsx5(FeesTable, { value: table, language, editable: canWrite, onChange: canWrite && !saving ? onChange : void 0 }, key)
1678
+ ] })
1679
+ ] })
1680
+ ] })
1681
+ ] });
1682
+ }
1683
+ export {
1684
+ FeesManager,
1685
+ FeesTable
1686
+ };
1687
+ //# sourceMappingURL=fees.mjs.map