@agile-team/mach-table 0.37.0 → 0.39.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 (45) hide show
  1. package/README.md +2 -2
  2. package/dist/adapter.cjs +1 -1
  3. package/dist/adapter.d.cts +10 -2
  4. package/dist/adapter.d.ts +10 -2
  5. package/dist/adapter.js +1 -1
  6. package/dist/analysis.cjs +1 -1
  7. package/dist/analysis.d.cts +2 -2
  8. package/dist/analysis.d.ts +2 -2
  9. package/dist/analysis.js +2 -2
  10. package/dist/{api-DH2BoJ9I.d.cts → api-ChEKWrvH.d.cts} +11 -1
  11. package/dist/{api-DH2BoJ9I.d.ts → api-ChEKWrvH.d.ts} +11 -1
  12. package/dist/{configuration-CDG7IuBP.d.ts → configuration-BPj5MIUw.d.ts} +1 -1
  13. package/dist/{configuration-DPbk9Afw.d.cts → configuration-CZm-aiTf.d.cts} +1 -1
  14. package/dist/import.cjs +1 -1
  15. package/dist/import.d.cts +1 -1
  16. package/dist/import.d.ts +1 -1
  17. package/dist/import.js +1 -1
  18. package/dist/index.cjs +6 -6
  19. package/dist/index.d.cts +5 -3
  20. package/dist/index.d.ts +5 -3
  21. package/dist/index.js +6 -6
  22. package/dist/mach-table.css +1 -1
  23. package/dist/multi-range.cjs +3 -3
  24. package/dist/multi-range.d.cts +1 -1
  25. package/dist/multi-range.d.ts +1 -1
  26. package/dist/multi-range.js +2 -2
  27. package/dist/ordering.cjs +1 -1
  28. package/dist/ordering.d.cts +1 -1
  29. package/dist/ordering.d.ts +1 -1
  30. package/dist/ordering.js +1 -1
  31. package/dist/preferences.d.cts +1 -1
  32. package/dist/preferences.d.ts +1 -1
  33. package/dist/server-side.d.cts +1 -1
  34. package/dist/server-side.d.ts +1 -1
  35. package/dist/{shared-C-HciMdN.d.cts → shared-BIBSfPcs.d.cts} +1 -1
  36. package/dist/{shared-CvUdCijb.d.ts → shared-Qnznvth3.d.ts} +1 -1
  37. package/dist/workbench.cjs +1 -1
  38. package/dist/workbench.d.cts +3 -3
  39. package/dist/workbench.d.ts +3 -3
  40. package/dist/workbench.js +1 -1
  41. package/dist/worker.cjs +1 -1
  42. package/dist/worker.d.cts +2 -2
  43. package/dist/worker.d.ts +2 -2
  44. package/dist/worker.js +1 -1
  45. package/package.json +2 -2
@@ -1 +1 @@
1
- .mach-root{--mach-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;--mach-font-size: 13px;--mach-font-size-sm: 12px;--mach-header-font-weight: 650;--mach-cell-padding: 9px;--mach-row-h: 36px;--mach-header-h: 40px;--mach-primary: #2563eb;--mach-primary-weak: #dbeafe;--mach-success: #16a34a;--mach-warning: #d97706;--mach-danger: #dc2626;--mach-info: #0284c7;--mach-border-color: #e6eaf0;--mach-row-border-color: #eef1f6;--mach-cell-border-color: transparent;--mach-border-width: 1px;--mach-header-border-width: 1px;--mach-header-accent-color: #d9e1eb;--mach-header-bg: #f4f7fb;--mach-header-group-bg: #edf2f8;--mach-header-fg: #344054;--mach-body-bg: #ffffff;--mach-body-fg: #26303f;--mach-row-hover-bg: #f6f8fa;--mach-row-selected-bg: #eff6ff;--mach-zebra-bg: #fafbfd;--mach-cell-focus-color: #2563eb;--mach-focus-width: 1.5px;--mach-scrollbar-thumb: #c9d2dd;--mach-radius-sm: 4px;--mach-radius: 6px;--mach-radius-lg: 8px;--mach-shadow-sm: 0 1px 4px rgba(15, 23, 42, .08);--mach-shadow: 0 6px 20px rgba(15, 23, 42, .12);--mach-transition: .15s ease;--mach-z-overlay: 10;--mach-z-loading: 15;--mach-z-popup: 1000;--mach-z-menu: 1001;position:relative;display:flex;flex-direction:column;width:100%;height:100%;min-height:120px;overflow:hidden;font-family:var(--mach-font-family);font-size:var(--mach-font-size);color:var(--mach-body-fg);background:var(--mach-body-bg);outline:none;box-sizing:border-box;border:1px solid var(--mach-border-color);color-scheme:light;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-variant-numeric:tabular-nums;contain:layout style}.mach-root.mach-dom-layout--auto-height{height:auto;min-height:0}.mach-root.mach-dom-layout--auto-height.mach-has-overlay{min-height:var(--mach-overlay-min-height, 180px)}.mach-root.mach-dom-layout--auto-height .mach-body{flex:none}.mach-root.mach-dom-layout--auto-height .mach-body-viewport--scroll{overflow-y:hidden}.mach-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:44px;padding:6px 8px;font:13px/1.4 var(--mach-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);color:var(--mach-body-fg, #26303f);background:var(--mach-body-bg, #fff);border:1px solid var(--mach-border-color, #e6eaf0);border-bottom:0;border-radius:var(--mach-radius-lg, 8px) var(--mach-radius-lg, 8px) 0 0}.mach-toolbar__main,.mach-toolbar__aside{display:flex;align-items:center;gap:6px;min-width:0}.mach-toolbar__search{display:flex;align-items:center;gap:6px;width:min(240px,32vw);height:32px;padding:0 9px;color:#64748b;background:var(--mach-header-bg, #fafbfd);border:1px solid var(--mach-border-color, #e6eaf0);border-radius:6px;transition:border-color var(--mach-transition, .15s ease),box-shadow var(--mach-transition, .15s ease)}.mach-toolbar__search:focus-within{border-color:var(--mach-primary, #2563eb);box-shadow:0 0 0 2px color-mix(in srgb,var(--mach-primary, #2563eb) 12%,transparent)}.mach-toolbar__search input{min-width:0;width:100%;color:inherit;background:transparent;border:0;outline:0}.mach-toolbar__button,.mach-toolbar__select-host,.mach-toolbar__selection{height:32px;padding:0 10px;color:inherit;background:var(--mach-body-bg, #fff);border:1px solid var(--mach-border-color, #e6eaf0);border-radius:6px;cursor:pointer;transition:color var(--mach-transition, .15s ease),border-color var(--mach-transition, .15s ease),background var(--mach-transition, .15s ease)}.mach-toolbar__button{min-width:32px;padding:0 8px;font-size:16px}.mach-toolbar__button:hover:not(:disabled),.mach-toolbar__select-host:hover{color:var(--mach-primary, #2563eb);border-color:var(--mach-primary, #2563eb)}.mach-toolbar__button:disabled{cursor:not-allowed;opacity:.45}.mach-toolbar__selection{color:var(--mach-primary, #2563eb);background:var(--mach-primary-weak, #dbeafe);border-color:transparent;font-size:12px}.mach-toolbar__select-host{width:82px;padding:0}.mach-toolbar__select-control,.mach-toolbar__select-control .mach-select-trigger{width:100%;height:100%}.mach-toolbar__select-control .mach-select-trigger{border:0;border-radius:5px;background:transparent;box-shadow:none}@media(max-width:640px){.mach-toolbar{align-items:stretch;flex-direction:column}.mach-toolbar__main,.mach-toolbar__aside{flex-wrap:wrap}.mach-toolbar__search{flex:1;width:auto}}.mach-size--compact{--mach-font-size: 12px;--mach-cell-padding: 6px}.mach-size--normal{--mach-font-size: 13px;--mach-cell-padding: 9px}.mach-size--large{--mach-font-size: 14px;--mach-cell-padding: 12px}.mach-root.mach-cell-borders{--mach-cell-border-color: var(--mach-border-color)}.mach-root.mach-theme-dark,.mach-root.mach-theme-dark.mach-size--compact,.mach-root.mach-theme-dark.mach-size--normal,.mach-root.mach-theme-dark.mach-size--large{--mach-border-color: #26324a;--mach-row-border-color: #1c2740;--mach-header-accent-color: #33415e;--mach-header-bg: #101a2e;--mach-header-group-bg: #16213a;--mach-header-fg: #c3cee0;--mach-body-bg: #0d1526;--mach-body-fg: #dbe4f0;--mach-row-hover-bg: #142138;--mach-row-selected-bg: #14304f;--mach-zebra-bg: #0f1a2e;--mach-cell-focus-color: #60a5fa;--mach-primary: #60a5fa;--mach-primary-weak: #1e3a5f;--mach-scrollbar-thumb: #33415e;--mach-success: #4ade80;--mach-warning: #fbbf24;--mach-danger: #f87171;--mach-info: #38bdf8;--mach-shadow-sm: 0 1px 4px rgba(0, 0, 0, .4);--mach-shadow: 0 6px 20px rgba(0, 0, 0, .5);color-scheme:dark}.mach-root *,.mach-root *:before,.mach-root *:after{box-sizing:border-box}.mach-portal,.mach-portal *,.mach-portal *:before,.mach-portal *:after{box-sizing:border-box}.mach-root:focus-visible{outline:2px solid var(--mach-primary);outline-offset:-2px}.mach-header{display:flex;flex-shrink:0;width:100%;height:var(--mach-header-h);background:var(--mach-header-bg);border-bottom:var(--mach-header-border-width) solid var(--mach-header-accent-color);box-shadow:0 1px 2px color-mix(in srgb,var(--mach-header-fg) 8%,transparent);overflow:hidden;position:relative;z-index:3;user-select:none}.mach-body{display:flex;flex:1;min-height:0;width:100%;position:relative;overflow:hidden}.mach-pane{position:relative;overflow:hidden;flex-shrink:0}.mach-pane--center{flex:1 1 auto;min-width:0}.mach-pane--hidden{display:none}.mach-header-viewport{width:100%;height:100%;overflow:hidden}.mach-header-rows{position:relative;height:100%;width:100%}.mach-header-row{position:absolute;left:0}.mach-header-row .mach-header-cell{position:absolute;top:0}.mach-header-cell--group{justify-content:center;border-bottom:var(--mach-border-width) solid var(--mach-border-color);font-weight:var(--mach-header-font-weight);background:var(--mach-header-group-bg)}.mach-header-label--custom{display:inline-flex;align-items:center;min-width:0;overflow:hidden}.mach-header-cell{display:flex;align-items:center;gap:4px;padding:0 var(--mach-cell-padding);border-right:var(--mach-border-width) solid transparent;color:var(--mach-header-fg);font-weight:var(--mach-header-font-weight);font-size:var(--mach-font-size);letter-spacing:.15px;cursor:default;overflow:hidden;white-space:nowrap;background:var(--mach-header-bg);transition:color var(--mach-transition),background-color var(--mach-transition)}.mach-header-cell--leaf:hover{background:color-mix(in srgb,var(--mach-primary) 4%,var(--mach-header-bg))}.mach-header-cell.mach-header-cell--sorted{color:var(--mach-primary);background:color-mix(in srgb,var(--mach-primary) 5%,var(--mach-header-bg))}.mach-root.mach-cell-borders .mach-header-cell{border-right-color:var(--mach-border-color)}.mach-header-label{flex:1;min-width:max-content;cursor:pointer}.mach-header-cell--selection{justify-content:center;gap:0;padding:0}.mach-header-cell--selection .mach-header-label:empty{display:none}.mach-sort-indicator{display:inline-flex;align-items:center;gap:3px;color:var(--mach-primary);flex-shrink:0}.mach-sort-indicator svg{width:10px;height:10px}.mach-sort-indicator:empty{display:none}.mach-sort-badge{font-size:9px;line-height:1;padding:1.5px 4px;border-radius:999px;background:var(--mach-primary-weak);color:var(--mach-primary);font-weight:600}.mach-filter-btn{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:none;border-radius:var(--mach-radius-sm);background:transparent;color:inherit;opacity:.36;cursor:pointer;flex-shrink:0;transition:opacity var(--mach-transition),color var(--mach-transition),background-color var(--mach-transition)}.mach-filter-btn svg{width:12px;height:12px;pointer-events:none}.mach-header-cell:hover .mach-filter-btn,.mach-header-cell:hover .mach-menu-btn{opacity:.62}.mach-filter-btn:hover{opacity:1;background:var(--mach-row-hover-bg)}.mach-filter-btn--active{opacity:1;color:var(--mach-primary)}.mach-filter-tag{display:inline-flex;align-items:center;max-width:96px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 6px;height:16px;line-height:16px;border-radius:999px;background:var(--mach-primary-weak);color:var(--mach-primary);font-size:10px;font-weight:500;flex-shrink:0}.mach-menu-btn{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:none;border-radius:var(--mach-radius-sm);background:transparent;color:inherit;opacity:.36;cursor:pointer;flex-shrink:0;font-size:12px;line-height:1;transition:opacity var(--mach-transition),color var(--mach-transition),background-color var(--mach-transition)}.mach-menu-btn:hover{opacity:1;background:var(--mach-row-hover-bg)}.mach-menu-btn svg{width:12px;height:12px;pointer-events:none}.mach-header-resize{position:absolute;top:0;right:0;width:8px;height:100%;cursor:col-resize;z-index:2;touch-action:none}.mach-header-resize:hover:after,.mach-header-resize--active:after{content:"";position:absolute;inset:0 3px;background:var(--mach-primary);opacity:.45;border-radius:1px}.mach-column-resize-guide{position:absolute;bottom:0;width:2px;pointer-events:none;background:var(--mach-primary);box-shadow:0 0 0 1px var(--mach-primary-weak);z-index:8}.mach-column-resize-label{position:absolute;top:6px;min-width:52px;padding:3px 7px;border-radius:var(--mach-radius-sm);color:#fff;background:var(--mach-primary);font:600 11px/1.5 var(--mach-font-family);text-align:center;white-space:nowrap;transform:translate(-50%);box-shadow:var(--mach-shadow-sm)}.mach-header-cell--dragging{opacity:.22}.mach-column-drag-ghost{position:fixed;top:0;left:0;z-index:calc(var(--mach-z-menu) + 1);display:flex;align-items:center;height:var(--mach-header-h);max-width:calc(100vw - 16px);padding:0 var(--mach-cell-padding);overflow:hidden;color:var(--mach-body-fg);font:var(--mach-header-font-weight) var(--mach-font-size)/1.3 var(--mach-font-family);text-overflow:ellipsis;white-space:nowrap;pointer-events:none;background:var(--mach-body-bg);border:1px solid var(--mach-primary);border-radius:var(--mach-radius);box-shadow:var(--mach-shadow);opacity:.96;will-change:transform}.mach-drop-indicator{position:absolute;top:3px;left:0;width:2px;height:calc(100% - 6px);border-radius:2px;background:var(--mach-primary);z-index:4;pointer-events:none;will-change:transform}.mach-root--dragging{cursor:grabbing}.mach-root--dragging .mach-header-cell,.mach-root--resizing .mach-header-cell{cursor:default}.mach-root--resizing{cursor:col-resize}.mach-body-viewport{position:relative;width:100%;height:100%;overflow:hidden;overflow:clip}.mach-body-viewport--scroll{overflow:auto;overscroll-behavior:contain;overflow-anchor:none}.mach-body-viewport--scroll{scrollbar-width:thin;scrollbar-color:var(--mach-scrollbar-thumb) transparent}.mach-body-viewport--scroll::-webkit-scrollbar{width:10px;height:10px}.mach-body-viewport--scroll::-webkit-scrollbar-track{background:transparent}.mach-body-viewport--scroll::-webkit-scrollbar-thumb{background:var(--mach-scrollbar-thumb);border-radius:999px;border:3px solid transparent;background-clip:padding-box;transition:background-color var(--mach-transition)}.mach-body-viewport--scroll::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,var(--mach-scrollbar-thumb) 60%,var(--mach-primary));background-clip:padding-box}.mach-body-viewport--scroll::-webkit-scrollbar-thumb:active{background:var(--mach-primary);background-clip:padding-box}.mach-body-viewport--scroll::-webkit-scrollbar-corner{background:transparent}.mach-row-container{position:relative;width:100%}.mach-row{position:absolute;top:0;left:0;display:flex;width:100%;background:var(--mach-body-bg);border-bottom:var(--mach-border-width) solid var(--mach-row-border-color);contain:layout style}.mach-row,.mach-row .mach-cell{transition:background-color var(--mach-transition)}.mach-root.mach-striped .mach-row--odd,.mach-root.mach-striped .mach-row--odd .mach-cell{background:var(--mach-zebra-bg)}.mach-cell{position:absolute;top:0;display:flex;align-items:center;height:100%;padding:0 var(--mach-cell-padding);border-right:1px solid var(--mach-cell-border-color);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:default;line-height:calc(var(--mach-row-h) - 2px)}.mach-cell--loading{pointer-events:none}.mach-cell-loading-bar{display:block;height:8px;max-width:132px;border-radius:999px;background:linear-gradient(90deg,var(--mach-row-hover-bg),var(--mach-border-color),var(--mach-row-hover-bg));background-size:200% 100%;animation:mach-cell-loading 1.25s ease-in-out infinite}@keyframes mach-cell-loading{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.mach-cell-loading-bar{animation:none}}.mach-cell--num{justify-content:flex-end}.mach-cell--selection{justify-content:center;padding:0}.mach-cell--editing{padding:0 3px}.mach-cell--focus{box-shadow:inset 0 0 0 var(--mach-focus-width) var(--mach-cell-focus-color);border-radius:var(--mach-radius-sm);z-index:1}.mach-cell--selection.mach-cell--focus{box-shadow:none;border-radius:0;z-index:auto}.mach-row--hover,.mach-row--hover .mach-cell{background:var(--mach-row-hover-bg)}.mach-row--selected,.mach-row--selected .mach-cell{background:var(--mach-row-selected-bg)}.mach-row--selected.mach-row--hover,.mach-row--selected.mach-row--hover .mach-cell{background:var(--mach-row-selected-bg);filter:brightness(.985)}input.mach-row-checkbox,input.mach-select-all{width:13px;height:13px;margin:0;accent-color:var(--mach-primary);cursor:pointer;flex-shrink:0}.mach-detail-row{background:var(--mach-zebra-bg);z-index:0}.mach-detail{height:100%;overflow:auto;padding:10px 12px}.mach-cell--detail-toggle{justify-content:center;padding:0;cursor:pointer}.mach-detail-toggle{display:inline-flex;align-items:center;justify-content:center;width:100%;font-size:10px;color:var(--mach-header-fg);transition:transform .15s ease}.mach-detail-toggle--open{transform:rotate(90deg)}.mach-detail-toggle--loading{animation:mach-tree-spin .8s linear infinite;color:var(--mach-primary)}.mach-detail-toggle--error{color:#dc2626}@keyframes mach-tree-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.mach-detail-toggle--loading{animation:none}}.mach-cell--group{cursor:pointer;background:var(--mach-header-bg)}.mach-row .mach-cell--group,.mach-row:has(.mach-cell--group){background:var(--mach-header-bg)}.mach-group-label{display:inline-flex;align-items:center;gap:5px;min-width:0;overflow:hidden}.mach-group-text{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mach-group-count{color:var(--mach-header-fg);font-size:10px;flex-shrink:0;opacity:.8}.mach-tree-cell{display:inline-flex;align-items:center;gap:4px;min-width:0;width:100%}.mach-tree-indent{flex-shrink:0}.mach-tree-toggle{display:inline-flex;align-items:center;justify-content:center;flex:0 0 20px;width:20px;height:22px;padding:0;border:0;border-radius:var(--mach-radius-sm);color:var(--mach-header-fg);background:transparent;cursor:pointer}.mach-tree-toggle:hover,.mach-tree-toggle:focus-visible{color:var(--mach-primary);background:var(--mach-primary-weak)}.mach-tree-toggle:focus-visible{outline:1px solid var(--mach-primary);outline-offset:-1px}.mach-tree-toggle>.mach-detail-toggle{width:10px;line-height:1;color:inherit;pointer-events:none}.mach-tree-toggle>.mach-detail-toggle--loading{color:var(--mach-primary)}.mach-tree-toggle>.mach-detail-toggle--error{color:var(--mach-danger)}.mach-tree-toggle-spacer{flex:0 0 20px;width:20px}.mach-tree-text{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mach-cell--drag{justify-content:center;padding:0;cursor:grab}.mach-row-drag-handle{display:grid;place-items:center;width:26px;height:26px;padding:0;border:1px solid transparent;border-radius:var(--mach-radius-sm);color:var(--mach-header-fg);background:transparent;opacity:.55;cursor:grab;user-select:none;touch-action:none;transition:color var(--mach-transition),background var(--mach-transition),opacity var(--mach-transition)}.mach-row-drag-handle:before{content:"";width:10px;height:14px;background:radial-gradient(circle,currentColor 1.3px,transparent 1.5px) 0 0 / 5px 5px}.mach-row-drag-handle:hover:not(:disabled),.mach-row-drag-handle:focus-visible{opacity:1;color:var(--mach-primary);background:var(--mach-primary-weak);border-color:color-mix(in srgb,var(--mach-primary) 28%,transparent);outline:none}.mach-row-drag-handle:disabled{opacity:.2;cursor:not-allowed}.mach-row-drop-indicator{position:absolute;top:0;left:0;width:100%;height:2px;background:var(--mach-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--mach-body-bg) 65%,transparent);z-index:5;pointer-events:none;will-change:transform}.mach-row-drop-indicator:before{content:"";position:absolute;left:1px;top:-2px;width:6px;height:6px;border-radius:50%;background:var(--mach-primary)}.mach-pane--center .mach-row-drop-indicator:before,.mach-pane--right .mach-row-drop-indicator:before{display:none}.mach-row-drag-preview{position:absolute;top:0;left:0;z-index:var(--mach-z-overlay);max-width:min(216px,calc(100% - 16px));padding:9px 14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:1px solid color-mix(in srgb,var(--mach-primary) 35%,var(--mach-border-color));border-radius:var(--mach-radius);background:var(--mach-body-bg);color:var(--mach-body-fg);box-shadow:var(--mach-shadow);font-weight:600;pointer-events:none}.mach-root--row-dragging,.mach-root--row-dragging .mach-cell,.mach-root--row-dragging .mach-row-drag-handle{cursor:grabbing;user-select:none}.mach-root .mach-row--drag-source{opacity:.45}.mach-cell--index{color:var(--mach-header-fg);font-size:calc(var(--mach-font-size) - 1px)}.mach-editor-input.mach-editor-invalid,.mach-editor-invalid .mach-editor-input,.mach-editor-invalid .mach-select-trigger,.mach-editor-invalid input,.mach-editor-invalid select:not([hidden]){border-color:#ef4444!important;box-shadow:0 0 0 1px #ef444459}.mach-editor-validating{cursor:progress;opacity:.72}.mach-footer{display:flex;flex-shrink:0;width:100%;overflow:hidden;background:var(--mach-header-bg);border-top:1px solid var(--mach-border-color);font-weight:600;color:var(--mach-header-fg);position:relative;z-index:3}.mach-footer-row{position:relative;overflow:hidden;flex-shrink:0}.mach-footer-row--center{flex:1 1 auto;min-width:0}.mach-footer-cell{position:absolute;top:0;display:flex;align-items:center;padding:0 var(--mach-cell-padding);border-right:1px solid transparent;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;height:100%;font-variant-numeric:tabular-nums}.mach-root.mach-cell-borders .mach-footer-cell{border-right-color:var(--mach-border-color)}.mach-cell--range{background:color-mix(in srgb,var(--mach-primary) 7%,transparent)!important}.mach-cell--range:after{content:"";position:absolute;inset:0;z-index:2;border:0 solid var(--mach-primary);pointer-events:none}.mach-cell--range.mach-cell--range-top:after{border-top-width:1.5px}.mach-cell--range.mach-cell--range-bottom:after{border-bottom-width:1.5px}.mach-cell--range.mach-cell--range-left:after{border-left-width:1.5px}.mach-cell--range.mach-cell--range-right:after{border-right-width:1.5px}.mach-cell--range.mach-cell--focus{box-shadow:inset 0 0 0 var(--mach-focus-width) var(--mach-cell-focus-color)}.mach-cell--range.mach-cell--focus:after{display:none}.mach-context-menu{position:fixed;z-index:var(--mach-z-menu);display:flex;flex-direction:column;min-width:140px;padding:5px;background:var(--mach-body-bg);color:var(--mach-body-fg);border:1px solid var(--mach-border-color);border-radius:var(--mach-radius-lg);box-shadow:var(--mach-shadow);font-family:var(--mach-font-family);font-size:var(--mach-font-size)}.mach-context-menu-item{text-align:left;padding:6px 10px;border:none;border-radius:var(--mach-radius);background:transparent;color:inherit;font:inherit;cursor:pointer;white-space:nowrap}.mach-context-menu-item:hover{background:var(--mach-row-hover-bg);color:var(--mach-primary)}.mach-fill-handle{position:absolute;width:8px;height:8px;border-radius:2px;background:var(--mach-primary);border:1.5px solid var(--mach-body-bg);cursor:crosshair;z-index:6;box-shadow:0 0 0 1px #2563eb59}.mach-root--filling,.mach-root--filling *{user-select:none!important;cursor:crosshair!important}.mach-infinite-loading{position:absolute;left:50%;bottom:14px;transform:translate(-50%);display:flex;align-items:center;gap:8px;padding:5px 14px;border-radius:999px;background:var(--mach-body-bg);border:1px solid var(--mach-border-color);box-shadow:var(--mach-shadow-sm);color:var(--mach-header-fg);font-size:12px;z-index:var(--mach-z-loading)}.mach-infinite-loading .mach-spinner{width:14px;height:14px;border-width:2px}.mach-statusbar{display:flex;align-items:center;gap:18px;flex-shrink:0;height:28px;padding:0 12px;background:var(--mach-header-bg);border-top:1px solid var(--mach-border-color);color:var(--mach-header-fg);font-size:11px;overflow:hidden;white-space:nowrap;font-variant-numeric:tabular-nums}.mach-statusbar-item--rangeAggregate{margin-left:auto}.mach-pinned-rows{display:flex;width:100%;overflow:hidden;background:var(--mach-header-bg);flex-shrink:0;border-bottom:1px solid var(--mach-border-color)}.mach-pinned-rows--bottom{border-bottom:none;border-top:1px solid var(--mach-border-color)}.mach-pinned-viewport{flex:1 1 auto;min-width:0;overflow:hidden}.mach-pinned-seg{position:relative;overflow:hidden;flex-shrink:0}.mach-pinned-seg--center{position:relative}.mach-pinned-row{position:relative;width:100%;border-bottom:1px solid var(--mach-row-border-color)}.mach-pinned-row .mach-cell{position:absolute;top:0;background:var(--mach-header-bg);font-weight:600;color:var(--mach-header-fg)}.mach-pinned-row:last-child{border-bottom:none}.mach-cell--wrap{white-space:normal;word-break:break-word;line-height:1.45;align-items:flex-start;padding-top:5px;padding-bottom:5px}.mach-editor-input,.mach-editor-select-control .mach-select-trigger{width:100%;height:calc(var(--mach-row-h) - 8px);padding:0 6px;border:1px solid var(--mach-primary);border-radius:var(--mach-radius-sm);font-family:inherit;font-size:var(--mach-font-size);color:inherit;background:var(--mach-body-bg);outline:none}.mach-select-control{position:relative;display:inline-flex;min-width:0;font-family:var(--mach-font-family, inherit);font-size:var(--mach-font-size, 14px)}.mach-select-native[hidden]{display:none!important}.mach-select-trigger{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0;height:34px;padding:0 10px;border:1px solid var(--mach-border-color, #e6eaf0);border-radius:var(--mach-radius, 6px);outline:none;color:var(--mach-body-fg, #1f2937);background:var(--mach-body-bg, #fff);font:inherit;line-height:1;text-align:left;cursor:pointer;transition:border-color var(--mach-transition, .15s ease),box-shadow var(--mach-transition, .15s ease),background-color var(--mach-transition, .15s ease)}.mach-select-trigger:hover{border-color:color-mix(in srgb,var(--mach-primary, #2563eb) 44%,var(--mach-border-color, #e6eaf0));background:color-mix(in srgb,var(--mach-primary, #2563eb) 3%,var(--mach-body-bg, #fff))}.mach-select-trigger:focus-visible,.mach-select-trigger[aria-expanded=true]{border-color:var(--mach-primary, #2563eb);box-shadow:0 0 0 3px color-mix(in srgb,var(--mach-primary, #2563eb) 12%,transparent)}.mach-select-value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mach-select-caret{width:8px;height:8px;flex:0 0 auto;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:translateY(-2px) rotate(45deg);transition:transform var(--mach-transition, .15s ease)}.mach-select-trigger[aria-expanded=true] .mach-select-caret{transform:translateY(2px) rotate(225deg)}.mach-select-listbox{position:fixed;z-index:var(--mach-z-menu, 1200);display:none;flex-direction:column;gap:2px;min-width:112px;max-width:min(320px,calc(100vw - 16px));max-height:min(244px,calc(100vh - 16px));padding:5px;overflow:auto;overscroll-behavior:contain;border:1px solid color-mix(in srgb,var(--mach-border-color, #e6eaf0) 88%,var(--mach-primary, #2563eb));border-radius:calc(var(--mach-radius-lg, 8px) + 1px);color:var(--mach-body-fg, #1f2937);background:var(--mach-body-bg, #fff);box-shadow:0 14px 36px color-mix(in srgb,var(--mach-body-fg, #1f2937) 18%,transparent),var(--mach-shadow-sm, 0 1px 3px rgba(15, 23, 42, .12));font-family:var(--mach-font-family, inherit);font-size:var(--mach-font-size, 14px);isolation:isolate}.mach-select-listbox--open{display:flex;animation:mach-select-listbox-in .12s ease-out}.mach-select-option{position:relative;display:flex;align-items:center;flex:0 0 auto;width:100%;min-height:32px;padding:0 30px 0 10px;border:0;border-radius:var(--mach-radius, 6px);outline:none;color:inherit;background:transparent;font:inherit;text-align:left;cursor:pointer;transition:color var(--mach-transition, .15s ease),background-color var(--mach-transition, .15s ease)}.mach-select-option:hover,.mach-select-option:focus-visible,.mach-select-option--active{color:var(--mach-primary, #2563eb);background:color-mix(in srgb,var(--mach-primary, #2563eb) 9%,var(--mach-body-bg, #fff))}.mach-select-option[aria-selected=true]{color:var(--mach-primary, #2563eb);background:color-mix(in srgb,var(--mach-primary, #2563eb) 13%,var(--mach-body-bg, #fff));font-weight:600}.mach-select-option[aria-selected=true]:after{content:"\2713";position:absolute;right:10px;font-size:12px;font-weight:700}.mach-select-option:disabled{opacity:.42;cursor:not-allowed}@keyframes mach-select-listbox-in{0%{transform:translateY(-3px) scale(.99)}to{transform:translateY(0) scale(1)}}.mach-select-listbox--above{transform-origin:bottom}.mach-filter-select-control{width:100%}.mach-filter-select-trigger{width:100%;background:color-mix(in srgb,var(--mach-header-bg) 62%,var(--mach-body-bg))}.mach-filter-listbox{width:auto}.mach-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--mach-body-bg);z-index:var(--mach-z-overlay)}.mach-overlay-text{color:var(--mach-header-fg);font-size:var(--mach-font-size)}.mach-overlay-content{max-width:min(100%,320px)}.mach-loading{display:grid;justify-items:center;gap:14px;min-width:172px;padding:20px 24px}.mach-loading__visual{position:relative;display:grid;gap:8px;width:132px;padding:14px 16px;overflow:hidden;background:color-mix(in srgb,var(--mach-header-bg) 82%,var(--mach-body-bg));border:1px solid var(--mach-border-color);border-radius:var(--mach-radius-lg);box-shadow:var(--mach-shadow-sm)}.mach-loading__visual:before{content:"";position:absolute;inset:0;transform:translate(-100%);background:linear-gradient(100deg,transparent 20%,color-mix(in srgb,var(--mach-primary) 11%,transparent) 50%,transparent 80%);animation:mach-loading-sweep 1.35s ease-in-out infinite}.mach-loading__row{height:7px;border-radius:999px;background:color-mix(in srgb,var(--mach-primary) 13%,var(--mach-border-color))}.mach-loading__row:nth-child(2){width:82%}.mach-loading__row:nth-child(3){width:92%}.mach-loading__row:nth-child(4){width:66%}.mach-loading__status{display:inline-flex;align-items:center;gap:8px;color:var(--mach-header-fg);font-size:var(--mach-font-size-sm)}.mach-loading__spinner{width:14px;height:14px}.mach-loading__label{line-height:1}.mach-spinner{width:22px;height:22px;border:2px solid var(--mach-border-color);border-top-color:var(--mach-primary);border-radius:50%;animation:mach-spin .8s linear infinite}@keyframes mach-spin{to{transform:rotate(360deg)}}@keyframes mach-loading-sweep{to{transform:translate(100%)}}.mach-filter-panel{position:fixed;z-index:var(--mach-z-popup);display:flex;flex-direction:column;gap:10px;width:224px;max-width:calc(100vw - 16px);padding:12px;background:var(--mach-body-bg);color:var(--mach-body-fg);border:1px solid color-mix(in srgb,var(--mach-border-color) 88%,var(--mach-primary));border-radius:calc(var(--mach-radius-lg) + 2px);box-shadow:0 14px 36px color-mix(in srgb,var(--mach-body-fg) 16%,transparent),var(--mach-shadow-sm);font-family:var(--mach-font-family);font-size:var(--mach-font-size);animation:mach-filter-panel-in .14s ease-out}.mach-filter-body{display:flex;flex-direction:column;gap:8px}.mach-filter-input{width:100%;height:34px;padding:0 10px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);font-family:inherit;font-size:var(--mach-font-size);color:inherit;background:var(--mach-body-bg);outline:none;transition:border-color var(--mach-transition),box-shadow var(--mach-transition)}.mach-filter-input:focus{border-color:var(--mach-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--mach-primary) 12%,transparent)}@keyframes mach-filter-panel-in{0%{opacity:0;transform:translateY(-3px) scale(.99)}}.mach-filter-set-list{max-height:220px;overflow:auto;display:flex;flex-direction:column;gap:1px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);padding:4px}.mach-filter-set-item{display:flex;align-items:center;gap:6px;padding:3px 5px;border-radius:var(--mach-radius-sm);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mach-filter-set-item:hover{background:var(--mach-row-hover-bg)}.mach-filter-set-item input{accent-color:var(--mach-primary);margin:0;width:13px;height:13px}.mach-filter-footer{display:flex;justify-content:flex-end;gap:6px}.mach-filter-footer button{padding:4px 12px;border-radius:var(--mach-radius);border:1px solid var(--mach-border-color);background:var(--mach-body-bg);color:inherit;font-family:inherit;font-size:var(--mach-font-size);cursor:pointer}.mach-filter-footer button:hover{border-color:var(--mach-primary);color:var(--mach-primary)}.mach-filter-btn-apply{background:var(--mach-primary)!important;border-color:var(--mach-primary)!important;color:#fff!important}.mach-filter-btn-apply:hover{opacity:.9;color:#fff!important}.mach-column-panel{min-width:220px;max-height:70vh;overflow:auto}.mach-column-panel[role=dialog]{width:min(440px,calc(100vw - 16px))}.mach-column-workbench-search{box-sizing:border-box;width:100%;height:30px;padding:0 9px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);background:var(--mach-body-bg);color:var(--mach-body-fg);font:inherit;outline:none}.mach-column-workbench-search:focus{border-color:var(--mach-primary);box-shadow:0 0 0 2px var(--mach-primary-weak)}.mach-column-panel-title{font-weight:600;color:var(--mach-header-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mach-column-panel-subtitle{font-size:11px;color:var(--mach-header-fg);margin-top:2px}.mach-column-panel-actions{display:flex;gap:6px;flex-wrap:wrap}.mach-column-panel-btn{flex:1;min-width:60px;padding:4px 8px;border-radius:var(--mach-radius);border:1px solid var(--mach-border-color);background:var(--mach-body-bg);color:inherit;font-family:inherit;font-size:12px;cursor:pointer;white-space:nowrap}.mach-column-panel-btn:hover{border-color:var(--mach-primary);color:var(--mach-primary)}.mach-column-panel-divider{height:1px;background:var(--mach-border-color);margin:4px 0}.mach-column-panel-list{max-height:280px;overflow:auto;display:flex;flex-direction:column;gap:1px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);padding:4px}.mach-column-workbench-item{display:grid;grid-template-columns:minmax(120px,1fr) 108px 26px 26px;align-items:center;gap:4px;min-height:32px;padding:2px 3px;border-radius:var(--mach-radius)}.mach-column-workbench-item:hover{background:var(--mach-row-hover-bg)}.mach-column-workbench-label{display:flex;min-width:0;align-items:center;gap:7px;cursor:pointer}.mach-column-workbench-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mach-column-workbench-pin-control,.mach-column-workbench-move{height:26px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);background:var(--mach-body-bg);color:inherit;font:inherit}.mach-column-workbench-pin-control{width:108px;border:0}.mach-column-workbench-pin-control .mach-select-trigger{width:100%;height:26px;padding:0 7px;border-radius:var(--mach-radius);font-size:12px;box-shadow:none}.mach-column-workbench-move{padding:0;cursor:pointer}.mach-column-workbench-move:disabled{cursor:not-allowed;opacity:.35}.mach-tag{display:inline-flex;align-items:center;gap:4px;padding:0 8px;height:20px;line-height:18px;border-radius:999px;font-size:var(--mach-font-size-sm);font-weight:500;white-space:nowrap}.mach-tag:before{content:"";width:5px;height:5px;border-radius:999px;background:currentColor}.mach-tag--success{color:var(--mach-success);background:color-mix(in srgb,var(--mach-success) 10%,transparent)}.mach-tag--warning{color:var(--mach-warning);background:color-mix(in srgb,var(--mach-warning) 12%,transparent)}.mach-tag--danger{color:var(--mach-danger);background:color-mix(in srgb,var(--mach-danger) 10%,transparent)}.mach-tag--info{color:var(--mach-info);background:color-mix(in srgb,var(--mach-info) 10%,transparent)}.mach-tag--neutral{color:var(--mach-header-fg);background:color-mix(in srgb,var(--mach-header-fg) 10%,transparent)}.mach-progress{display:flex;align-items:center;gap:6px;width:100%}.mach-progress__track{flex:1;min-width:0;height:6px;border-radius:999px;background:color-mix(in srgb,var(--mach-header-fg) 14%,transparent);overflow:hidden}.mach-progress__bar{height:100%;border-radius:999px;background:var(--mach-primary);transition:width var(--mach-transition)}.mach-progress__label{flex-shrink:0;font-size:var(--mach-font-size-sm);color:var(--mach-header-fg);font-variant-numeric:tabular-nums}.mach-link{color:var(--mach-primary);cursor:pointer}.mach-link:hover{text-decoration:underline}.mach-actions{display:inline-flex;align-items:center;gap:2px}.mach-sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}.mach-action-btn{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;padding:0 4px;border:none;border-radius:var(--mach-radius-sm);background:transparent;color:var(--mach-header-fg);font-size:var(--mach-font-size-sm);line-height:1;cursor:pointer;white-space:nowrap;transition:color var(--mach-transition),background-color var(--mach-transition),transform var(--mach-transition)}.mach-action-btn:hover{background:var(--mach-row-hover-bg);color:var(--mach-primary)}.mach-action-btn--danger:hover{background:color-mix(in srgb,var(--mach-danger) 10%,transparent);color:var(--mach-danger);transform:scale(1.06)}.mach-action-btn--success:hover{background:color-mix(in srgb,var(--mach-success) 12%,transparent);color:var(--mach-success);transform:scale(1.06)}.mach-action-btn--primary{color:var(--mach-primary)}.mach-action-btn--warning{color:var(--mach-warning)}.mach-action-btn--success,.mach-edit-control--confirm{color:var(--mach-success)}.mach-action-btn--danger{color:var(--mach-danger)}.mach-action-btn:focus-visible,.mach-edit-control:focus-visible,.mach-cell-edit-trigger:focus-visible,.mach-action-drawer__close:focus-visible{outline:2px solid color-mix(in srgb,var(--mach-primary) 65%,transparent);outline-offset:1px}.mach-action-btn:disabled{cursor:not-allowed;opacity:.4}.mach-action-btn--loading svg{animation:mach-spin .8s linear infinite}.mach-action-btn--icon{padding:0;width:24px}.mach-context-menu-item--danger{color:var(--mach-danger)}.mach-context-menu-item,.mach-action-drawer__item{display:flex;align-items:center;gap:9px}.mach-context-menu-item--primary,.mach-action-drawer__item--primary{color:var(--mach-primary)}.mach-context-menu-item--warning,.mach-action-drawer__item--warning{color:var(--mach-warning)}.mach-context-menu-item--success,.mach-action-drawer__item--success{color:var(--mach-success)}.mach-context-menu-item--danger,.mach-action-drawer__item--danger{color:var(--mach-danger)}.mach-action-drawer-backdrop{position:fixed;inset:0;z-index:calc(var(--mach-z-menu) + 2);background:#0f172a33;backdrop-filter:blur(1px)}.mach-action-drawer{position:absolute;top:0;right:0;display:flex;flex-direction:column;width:min(340px,calc(100vw - 24px));height:100%;background:var(--mach-body-bg);color:var(--mach-body-fg);border-left:1px solid var(--mach-border-color);box-shadow:-16px 0 40px #0f172a24;font-family:var(--mach-font-family);animation:mach-drawer-in .18s ease-out}.mach-action-drawer__header{display:flex;align-items:center;justify-content:space-between;min-height:56px;padding:0 16px 0 20px;border-bottom:1px solid var(--mach-border-color)}.mach-action-drawer__close{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:0;border-radius:var(--mach-radius);background:transparent;color:var(--mach-header-fg);cursor:pointer}.mach-action-drawer__close:hover{color:var(--mach-primary);background:var(--mach-row-hover-bg)}.mach-action-drawer__body{display:flex;flex-direction:column;gap:4px;padding:12px;overflow:auto}.mach-action-drawer__item{width:100%;min-height:40px;padding:0 12px;border:0;border-radius:var(--mach-radius);background:transparent;font:inherit;text-align:left;cursor:pointer}.mach-action-drawer__item:hover:not(:disabled){background:var(--mach-row-hover-bg)}.mach-action-drawer__item:disabled{opacity:.4;cursor:not-allowed}@keyframes mach-drawer-in{0%{transform:translate(18px);opacity:0}to{transform:translate(0);opacity:1}}@media(max-width:640px){.mach-action-drawer{top:auto;bottom:0;width:100%;height:auto;max-height:min(70vh,520px);border-top:1px solid var(--mach-border-color);border-left:0;border-radius:var(--mach-radius-lg) var(--mach-radius-lg) 0 0;animation-name:mach-drawer-up}}@keyframes mach-drawer-up{0%{transform:translateY(18px);opacity:0}to{transform:translateY(0);opacity:1}}.mach-cell:has(.mach-cell-edit-trigger){padding-right:29px}.mach-cell-edit-trigger{position:absolute;right:5px;top:50%;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;transform:translateY(-50%);border:0;border-radius:var(--mach-radius-sm);background:transparent;color:var(--mach-header-fg);cursor:pointer;opacity:0;transition:opacity var(--mach-transition),color var(--mach-transition),background-color var(--mach-transition)}.mach-cell-edit-trigger svg{width:13px;height:13px}.mach-cell:hover .mach-cell-edit-trigger--hover,.mach-cell:focus-within .mach-cell-edit-trigger--hover,.mach-cell-edit-trigger--always{opacity:.72}.mach-cell-edit-trigger:hover{opacity:1;color:var(--mach-primary);background:color-mix(in srgb,var(--mach-primary) 9%,transparent)}.mach-cell--editing{overflow:visible;z-index:4}.mach-cell-editor-shell,.mach-row-editor-shell{display:flex;align-items:center;width:100%;min-width:0;gap:5px}.mach-cell-editor-shell>.mach-editor-input,.mach-cell-editor-shell>.mach-editor-select-control,.mach-cell-editor-shell>:not(.mach-cell-editor-controls),.mach-row-editor-shell>*{flex:1 1 auto;min-width:0}.mach-cell-editor-controls{display:inline-flex;flex:0 0 auto;align-items:center;gap:2px;padding:2px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);background:var(--mach-body-bg);box-shadow:var(--mach-shadow-sm)}.mach-edit-control{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:var(--mach-radius-sm);background:transparent;color:var(--mach-header-fg);cursor:pointer;transition:color var(--mach-transition),background-color var(--mach-transition),transform var(--mach-transition)}.mach-edit-control svg{width:14px;height:14px}.mach-edit-control--confirm{color:var(--mach-success)}.mach-edit-control--confirm:hover{background:color-mix(in srgb,var(--mach-success) 12%,transparent);transform:scale(1.06)}.mach-edit-control--cancel{color:var(--mach-danger)}.mach-edit-control--cancel:hover{background:color-mix(in srgb,var(--mach-danger) 10%,transparent);transform:scale(1.06)}.mach-edit-control:disabled{opacity:.35;cursor:wait}.mach-row--editing,.mach-row--editing .mach-cell{background:color-mix(in srgb,var(--mach-primary) 3%,var(--mach-body-bg))}.mach-cell--row-editing .mach-editor-input,.mach-cell--row-editing .mach-editor-select-control .mach-select-trigger{border-color:color-mix(in srgb,var(--mach-primary) 45%,var(--mach-border-color));box-shadow:0 1px 2px #0f172a0a}.mach-cell--row-editing .mach-editor-input:focus,.mach-cell--row-editing .mach-editor-select-control .mach-select-trigger:focus-visible,.mach-cell--row-editing .mach-editor-select-control .mach-select-trigger[aria-expanded=true]{border-color:var(--mach-primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--mach-primary) 12%,transparent)}.mach-tooltip{position:fixed;z-index:var(--mach-z-menu);max-width:320px;padding:6px 10px;border-radius:var(--mach-radius);background:var(--mach-body-fg);color:var(--mach-body-bg);font-size:var(--mach-font-size-sm);line-height:1.5;box-shadow:var(--mach-shadow);pointer-events:none;word-break:break-word}.mach-cell--flash{animation:mach-flash .8s ease-out}@keyframes mach-flash{0%{background-color:color-mix(in srgb,var(--mach-primary) 35%,transparent)}to{background-color:transparent}}.mach-context-menu-separator{height:1px;margin:4px 6px;background:var(--mach-border-color)}.mach-context-menu-item:disabled{opacity:.45;cursor:not-allowed}.mach-pagination{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-shrink:0;height:40px;padding:0 12px;background:var(--mach-body-bg);border-top:var(--mach-border-width) solid var(--mach-border-color);color:var(--mach-body-fg);font-size:var(--mach-font-size-sm);user-select:none}.mach-pagination-total{color:var(--mach-header-fg);margin-right:8px;font-variant-numeric:tabular-nums}.mach-pagination-page{min-width:72px;text-align:center;color:var(--mach-body-fg);font-variant-numeric:tabular-nums}.mach-pagination-btn{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:var(--mach-border-width) solid var(--mach-border-color);border-radius:var(--mach-radius-sm);background:var(--mach-body-bg);color:var(--mach-header-fg);font-size:13px;line-height:1;cursor:pointer;transition:border-color var(--mach-transition),color var(--mach-transition),background-color var(--mach-transition)}.mach-pagination-btn:hover:not(:disabled){border-color:var(--mach-primary);color:var(--mach-primary)}.mach-pagination-btn:disabled{opacity:.35;cursor:not-allowed}.mach-pagination-size-control{height:24px;margin-left:6px;width:92px;font-size:var(--mach-font-size-sm)}.mach-pagination-size-control .mach-select-trigger{width:100%;height:24px;padding:0 6px;border-width:var(--mach-border-width);border-radius:var(--mach-radius-sm);color:var(--mach-header-fg);box-shadow:none}.mach-watermark{position:absolute;inset:0;z-index:6;pointer-events:none;background-repeat:repeat}.mach-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:32px 16px;min-height:160px;text-align:center;color:var(--mach-body-fg);font-size:12px;line-height:20px;overflow-wrap:anywhere}.mach-empty__icon{fill:var(--mach-body-bg);margin-bottom:6px;width:96px;height:84px;stroke:#8b98ff;stroke-linecap:round}.mach-empty__title{font-size:14px;line-height:22px;font-weight:500}.mach-empty__hint{opacity:.45}@media(prefers-reduced-motion:reduce){.mach-spinner,.mach-loading__visual:before{animation-duration:2.4s}}.mach-cell--center{justify-content:center}.mach-cell--right{justify-content:flex-end}.mach-header-cell--center .mach-header-label{text-align:center}.mach-header-cell--right .mach-header-label{text-align:right}@media(prefers-reduced-motion:reduce){.mach-root *,.mach-root *:before,.mach-root *:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.mach-action-drawer{animation:none!important}}.mach-root{--mach-row-warning-bg: color-mix(in srgb, var(--mach-warning) 11%, var(--mach-body-bg));--mach-row-danger-bg: color-mix(in srgb, var(--mach-danger) 9%, var(--mach-body-bg));--mach-row-success-bg: color-mix(in srgb, var(--mach-success) 10%, var(--mach-body-bg));--mach-row-info-bg: color-mix(in srgb, var(--mach-info) 10%, var(--mach-body-bg))}.mach-row--styled[data-row-tone=warning]{--mach-row-rule-bg: var(--mach-row-warning-bg)}.mach-row--styled[data-row-tone=danger]{--mach-row-rule-bg: var(--mach-row-danger-bg)}.mach-row--styled[data-row-tone=success]{--mach-row-rule-bg: var(--mach-row-success-bg)}.mach-row--styled[data-row-tone=info]{--mach-row-rule-bg: var(--mach-row-info-bg)}.mach-root :is(.mach-row,.mach-pinned-row).mach-row--styled,.mach-root :is(.mach-row,.mach-pinned-row).mach-row--styled .mach-cell{background-color:var(--mach-row-rule-bg, var(--mach-body-bg));color:var(--mach-row-rule-fg, var(--mach-body-fg))}.mach-root .mach-row--styled.mach-row--hover,.mach-root .mach-row--styled.mach-row--hover .mach-cell{background-color:color-mix(in srgb,var(--mach-primary) 4%,var(--mach-row-rule-bg, var(--mach-body-bg)))}.mach-root .mach-row--styled.mach-row--selected,.mach-root .mach-row--styled.mach-row--selected .mach-cell{background-color:color-mix(in srgb,var(--mach-primary) 12%,var(--mach-row-rule-bg, var(--mach-body-bg)))}
1
+ .mach-root{--mach-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;--mach-font-size: 13px;--mach-font-size-sm: 12px;--mach-header-font-weight: 650;--mach-cell-padding: 9px;--mach-row-h: 36px;--mach-header-h: 40px;--mach-primary: #2563eb;--mach-primary-weak: #dbeafe;--mach-success: #16a34a;--mach-warning: #d97706;--mach-danger: #dc2626;--mach-info: #0284c7;--mach-border-color: #e6eaf0;--mach-row-border-color: #eef1f6;--mach-cell-border-color: transparent;--mach-border-width: 1px;--mach-header-border-width: 1px;--mach-header-accent-color: #d9e1eb;--mach-header-bg: #f4f7fb;--mach-header-group-bg: #edf2f8;--mach-header-fg: #344054;--mach-body-bg: #ffffff;--mach-body-fg: #26303f;--mach-row-hover-bg: #f6f8fa;--mach-row-selected-bg: #eff6ff;--mach-zebra-bg: #fafbfd;--mach-cell-focus-color: #2563eb;--mach-focus-width: 1.5px;--mach-scrollbar-thumb: #c9d2dd;--mach-radius-sm: 4px;--mach-radius: 6px;--mach-radius-lg: 8px;--mach-shadow-sm: 0 1px 4px rgba(15, 23, 42, .08);--mach-shadow: 0 6px 20px rgba(15, 23, 42, .12);--mach-transition: .15s ease;--mach-z-overlay: 10;--mach-z-loading: 15;--mach-z-popup: 1000;--mach-z-menu: 1001;position:relative;display:flex;flex-direction:column;width:100%;height:100%;min-height:120px;overflow:hidden;font-family:var(--mach-font-family);font-size:var(--mach-font-size);color:var(--mach-body-fg);background:var(--mach-body-bg);outline:none;box-sizing:border-box;border:1px solid var(--mach-border-color);color-scheme:light;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-variant-numeric:tabular-nums;contain:layout style}.mach-root.mach-dom-layout--auto-height{height:auto;min-height:0}.mach-root.mach-dom-layout--auto-height.mach-has-overlay{min-height:var(--mach-overlay-min-height, 180px)}.mach-root.mach-dom-layout--auto-height .mach-body{flex:none}.mach-root.mach-dom-layout--auto-height .mach-body-viewport--scroll{overflow-y:hidden}.mach-toolbar{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:44px;padding:6px 8px;font:13px/1.4 var(--mach-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);color:var(--mach-body-fg, #26303f);background:var(--mach-body-bg, #fff);border:1px solid var(--mach-border-color, #e6eaf0);border-bottom:0;border-radius:var(--mach-radius-lg, 8px) var(--mach-radius-lg, 8px) 0 0}.mach-toolbar__main,.mach-toolbar__aside{display:flex;align-items:center;gap:6px;min-width:0}.mach-toolbar__search{display:flex;align-items:center;gap:6px;width:min(240px,32vw);height:32px;padding:0 9px;color:#64748b;background:var(--mach-header-bg, #fafbfd);border:1px solid var(--mach-border-color, #e6eaf0);border-radius:6px;transition:border-color var(--mach-transition, .15s ease),box-shadow var(--mach-transition, .15s ease)}.mach-toolbar__search:focus-within{border-color:var(--mach-primary, #2563eb);box-shadow:0 0 0 2px color-mix(in srgb,var(--mach-primary, #2563eb) 12%,transparent)}.mach-toolbar__search input{min-width:0;width:100%;color:inherit;background:transparent;border:0;outline:0}.mach-toolbar__button,.mach-toolbar__select-host,.mach-toolbar__selection{height:32px;padding:0 10px;color:inherit;background:var(--mach-body-bg, #fff);border:1px solid var(--mach-border-color, #e6eaf0);border-radius:6px;cursor:pointer;transition:color var(--mach-transition, .15s ease),border-color var(--mach-transition, .15s ease),background var(--mach-transition, .15s ease)}.mach-toolbar__button{min-width:32px;padding:0 8px;font-size:16px}.mach-toolbar__button:hover:not(:disabled),.mach-toolbar__select-host:hover{color:var(--mach-primary, #2563eb);border-color:var(--mach-primary, #2563eb)}.mach-toolbar__button:disabled{cursor:not-allowed;opacity:.45}.mach-toolbar__selection{color:var(--mach-primary, #2563eb);background:var(--mach-primary-weak, #dbeafe);border-color:transparent;font-size:12px}.mach-toolbar__select-host{width:82px;padding:0}.mach-toolbar__select-control,.mach-toolbar__select-control .mach-select-trigger{width:100%;height:100%}.mach-toolbar__select-control .mach-select-trigger{border:0;border-radius:5px;background:transparent;box-shadow:none}@media(max-width:640px){.mach-toolbar{align-items:stretch;flex-direction:column}.mach-toolbar__main,.mach-toolbar__aside{flex-wrap:wrap}.mach-toolbar__search{flex:1;width:auto}}.mach-size--compact{--mach-font-size: 12px;--mach-cell-padding: 6px}.mach-size--normal{--mach-font-size: 13px;--mach-cell-padding: 9px}.mach-size--large{--mach-font-size: 14px;--mach-cell-padding: 12px}.mach-root.mach-cell-borders{--mach-cell-border-color: var(--mach-border-color)}.mach-root.mach-theme-dark,.mach-root.mach-theme-dark.mach-size--compact,.mach-root.mach-theme-dark.mach-size--normal,.mach-root.mach-theme-dark.mach-size--large{--mach-border-color: #26324a;--mach-row-border-color: #1c2740;--mach-header-accent-color: #33415e;--mach-header-bg: #101a2e;--mach-header-group-bg: #16213a;--mach-header-fg: #c3cee0;--mach-body-bg: #0d1526;--mach-body-fg: #dbe4f0;--mach-row-hover-bg: #142138;--mach-row-selected-bg: #14304f;--mach-zebra-bg: #0f1a2e;--mach-cell-focus-color: #60a5fa;--mach-primary: #60a5fa;--mach-primary-weak: #1e3a5f;--mach-scrollbar-thumb: #33415e;--mach-success: #4ade80;--mach-warning: #fbbf24;--mach-danger: #f87171;--mach-info: #38bdf8;--mach-shadow-sm: 0 1px 4px rgba(0, 0, 0, .4);--mach-shadow: 0 6px 20px rgba(0, 0, 0, .5);color-scheme:dark}.mach-root *,.mach-root *:before,.mach-root *:after{box-sizing:border-box}.mach-portal,.mach-portal *,.mach-portal *:before,.mach-portal *:after{box-sizing:border-box}.mach-root:focus-visible{outline:2px solid var(--mach-primary);outline-offset:-2px}.mach-header{display:flex;flex-shrink:0;width:100%;height:var(--mach-header-h);background:var(--mach-header-bg);border-bottom:var(--mach-header-border-width) solid var(--mach-header-accent-color);box-shadow:0 1px 2px color-mix(in srgb,var(--mach-header-fg) 8%,transparent);overflow:hidden;position:relative;z-index:3;user-select:none}.mach-body{display:flex;flex:1;min-height:0;width:100%;position:relative;overflow:hidden}.mach-pane{position:relative;overflow:hidden;flex-shrink:0}.mach-pane--center{flex:1 1 auto;min-width:0}.mach-pane--hidden{display:none}.mach-header-viewport{width:100%;height:100%;overflow:hidden}.mach-header-rows{position:relative;height:100%;width:100%}.mach-header-row{position:absolute;left:0}.mach-header-row .mach-header-cell{position:absolute;top:0}.mach-header-cell--group{justify-content:center;border-bottom:var(--mach-border-width) solid var(--mach-border-color);font-weight:var(--mach-header-font-weight);background:var(--mach-header-group-bg)}.mach-header-label--custom{display:inline-flex;align-items:center;min-width:0;overflow:hidden}.mach-header-cell{display:flex;align-items:center;gap:4px;padding:0 var(--mach-cell-padding);border-right:var(--mach-border-width) solid transparent;color:var(--mach-header-fg);font-weight:var(--mach-header-font-weight);font-size:var(--mach-font-size);letter-spacing:.15px;cursor:default;overflow:hidden;white-space:nowrap;background:var(--mach-header-bg);transition:color var(--mach-transition),background-color var(--mach-transition)}.mach-header-cell--leaf:hover{background:color-mix(in srgb,var(--mach-primary) 4%,var(--mach-header-bg))}.mach-header-cell.mach-header-cell--sorted{color:var(--mach-primary);background:color-mix(in srgb,var(--mach-primary) 5%,var(--mach-header-bg))}.mach-root.mach-cell-borders .mach-header-cell{border-right-color:var(--mach-border-color)}.mach-header-label{flex:1;min-width:max-content;cursor:pointer}.mach-header-cell--selection{justify-content:center;gap:0;padding:0}.mach-header-cell--selection .mach-header-label:empty{display:none}.mach-sort-indicator{display:inline-flex;align-items:center;gap:3px;color:var(--mach-primary);flex-shrink:0}.mach-sort-indicator svg{width:10px;height:10px}.mach-sort-indicator:empty{display:none}.mach-sort-badge{font-size:9px;line-height:1;padding:1.5px 4px;border-radius:999px;background:var(--mach-primary-weak);color:var(--mach-primary);font-weight:600}.mach-filter-btn{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:none;border-radius:var(--mach-radius-sm);background:transparent;color:inherit;opacity:.36;cursor:pointer;flex-shrink:0;transition:opacity var(--mach-transition),color var(--mach-transition),background-color var(--mach-transition)}.mach-filter-btn svg{width:12px;height:12px;pointer-events:none}.mach-header-cell:hover .mach-filter-btn,.mach-header-cell:hover .mach-menu-btn{opacity:.62}.mach-filter-btn:hover{opacity:1;background:var(--mach-row-hover-bg)}.mach-filter-btn--active{opacity:1;color:var(--mach-primary)}.mach-filter-tag{display:inline-flex;align-items:center;max-width:96px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:0 6px;height:16px;line-height:16px;border-radius:999px;background:var(--mach-primary-weak);color:var(--mach-primary);font-size:10px;font-weight:500;flex-shrink:0}.mach-menu-btn{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:none;border-radius:var(--mach-radius-sm);background:transparent;color:inherit;opacity:.36;cursor:pointer;flex-shrink:0;font-size:12px;line-height:1;transition:opacity var(--mach-transition),color var(--mach-transition),background-color var(--mach-transition)}.mach-menu-btn:hover{opacity:1;background:var(--mach-row-hover-bg)}.mach-menu-btn svg{width:12px;height:12px;pointer-events:none}.mach-header-resize{position:absolute;top:0;right:0;width:8px;height:100%;cursor:col-resize;z-index:2;touch-action:none}.mach-header-resize:hover:after,.mach-header-resize--active:after{content:"";position:absolute;inset:0 3px;background:var(--mach-primary);opacity:.45;border-radius:1px}.mach-column-resize-guide{position:absolute;bottom:0;width:2px;pointer-events:none;background:var(--mach-primary);box-shadow:0 0 0 1px var(--mach-primary-weak);z-index:8}.mach-column-resize-label{position:absolute;top:6px;min-width:52px;padding:3px 7px;border-radius:var(--mach-radius-sm);color:#fff;background:var(--mach-primary);font:600 11px/1.5 var(--mach-font-family);text-align:center;white-space:nowrap;transform:translate(-50%);box-shadow:var(--mach-shadow-sm)}.mach-header-cell--dragging{opacity:.22}.mach-column-drag-ghost{position:fixed;top:0;left:0;z-index:calc(var(--mach-z-menu) + 1);display:flex;align-items:center;height:var(--mach-header-h);max-width:calc(100vw - 16px);padding:0 var(--mach-cell-padding);overflow:hidden;color:var(--mach-body-fg);font:var(--mach-header-font-weight) var(--mach-font-size)/1.3 var(--mach-font-family);text-overflow:ellipsis;white-space:nowrap;pointer-events:none;background:var(--mach-body-bg);border:1px solid var(--mach-primary);border-radius:var(--mach-radius);box-shadow:var(--mach-shadow);opacity:.96;will-change:transform}.mach-drop-indicator{position:absolute;top:3px;left:0;width:2px;height:calc(100% - 6px);border-radius:2px;background:var(--mach-primary);z-index:4;pointer-events:none;will-change:transform}.mach-root--dragging{cursor:grabbing}.mach-root--dragging .mach-header-cell,.mach-root--resizing .mach-header-cell{cursor:default}.mach-root--resizing{cursor:col-resize}.mach-body-viewport{position:relative;width:100%;height:100%;overflow:hidden;overflow:clip}.mach-body-viewport--scroll{overflow:auto;overscroll-behavior:contain;overflow-anchor:none}.mach-body-viewport--scroll{scrollbar-width:thin;scrollbar-color:var(--mach-scrollbar-thumb) transparent}.mach-body-viewport--scroll::-webkit-scrollbar{width:10px;height:10px}.mach-body-viewport--scroll::-webkit-scrollbar-track{background:transparent}.mach-body-viewport--scroll::-webkit-scrollbar-thumb{background:var(--mach-scrollbar-thumb);border-radius:999px;border:3px solid transparent;background-clip:padding-box;transition:background-color var(--mach-transition)}.mach-body-viewport--scroll::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,var(--mach-scrollbar-thumb) 60%,var(--mach-primary));background-clip:padding-box}.mach-body-viewport--scroll::-webkit-scrollbar-thumb:active{background:var(--mach-primary);background-clip:padding-box}.mach-body-viewport--scroll::-webkit-scrollbar-corner{background:transparent}.mach-row-container{position:relative;width:100%}.mach-row{position:absolute;top:0;left:0;display:flex;width:100%;background:var(--mach-body-bg);border-bottom:var(--mach-border-width) solid var(--mach-row-border-color);contain:layout style}.mach-row,.mach-row .mach-cell{transition:background-color var(--mach-transition)}.mach-root.mach-striped .mach-row--odd,.mach-root.mach-striped .mach-row--odd .mach-cell{background:var(--mach-zebra-bg)}.mach-cell{position:absolute;top:0;display:flex;align-items:center;height:100%;padding:0 var(--mach-cell-padding);border-right:1px solid var(--mach-cell-border-color);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:default;line-height:calc(var(--mach-row-h) - 2px)}.mach-cell--loading{pointer-events:none}.mach-cell-loading-bar{display:block;height:8px;max-width:132px;border-radius:999px;background:linear-gradient(90deg,var(--mach-row-hover-bg),var(--mach-border-color),var(--mach-row-hover-bg));background-size:200% 100%;animation:mach-cell-loading 1.25s ease-in-out infinite}@keyframes mach-cell-loading{0%{background-position:200% 0}to{background-position:-200% 0}}@media(prefers-reduced-motion:reduce){.mach-cell-loading-bar{animation:none}}.mach-cell--selection{justify-content:center;padding:0}.mach-cell--editing{padding:0 3px}.mach-cell--focus{box-shadow:inset 0 0 0 var(--mach-focus-width) var(--mach-cell-focus-color);border-radius:var(--mach-radius-sm);z-index:1}.mach-cell--selection.mach-cell--focus{box-shadow:none;border-radius:0;z-index:auto}.mach-row--hover,.mach-row--hover .mach-cell{background:var(--mach-row-hover-bg)}.mach-row--selected,.mach-row--selected .mach-cell{background:var(--mach-row-selected-bg)}.mach-row--selected.mach-row--hover,.mach-row--selected.mach-row--hover .mach-cell{background:var(--mach-row-selected-bg);filter:brightness(.985)}input.mach-row-checkbox,input.mach-select-all{width:13px;height:13px;margin:0;accent-color:var(--mach-primary);cursor:pointer;flex-shrink:0}.mach-detail-row{background:var(--mach-zebra-bg);z-index:0}.mach-detail{height:100%;overflow:auto;padding:10px 12px}.mach-cell--detail-toggle{justify-content:center;padding:0;cursor:pointer}.mach-detail-toggle{display:inline-flex;align-items:center;justify-content:center;width:100%;font-size:10px;color:var(--mach-header-fg);transition:transform .15s ease}.mach-detail-toggle--open{transform:rotate(90deg)}.mach-detail-toggle--loading{animation:mach-tree-spin .8s linear infinite;color:var(--mach-primary)}.mach-detail-toggle--error{color:#dc2626}@keyframes mach-tree-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.mach-detail-toggle--loading{animation:none}}.mach-cell--group{cursor:pointer;background:var(--mach-header-bg)}.mach-row .mach-cell--group,.mach-row:has(.mach-cell--group){background:var(--mach-header-bg)}.mach-group-label{display:inline-flex;align-items:center;gap:5px;min-width:0;overflow:hidden}.mach-group-text{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mach-group-count{color:var(--mach-header-fg);font-size:10px;flex-shrink:0;opacity:.8}.mach-tree-cell{display:inline-flex;align-items:center;gap:4px;min-width:0;width:100%}.mach-tree-indent{flex-shrink:0}.mach-tree-toggle{display:inline-flex;align-items:center;justify-content:center;flex:0 0 20px;width:20px;height:22px;padding:0;border:0;border-radius:var(--mach-radius-sm);color:var(--mach-header-fg);background:transparent;cursor:pointer}.mach-tree-toggle:hover,.mach-tree-toggle:focus-visible{color:var(--mach-primary);background:var(--mach-primary-weak)}.mach-tree-toggle:focus-visible{outline:1px solid var(--mach-primary);outline-offset:-1px}.mach-tree-toggle>.mach-detail-toggle{width:10px;line-height:1;color:inherit;pointer-events:none}.mach-tree-toggle>.mach-detail-toggle--loading{color:var(--mach-primary)}.mach-tree-toggle>.mach-detail-toggle--error{color:var(--mach-danger)}.mach-tree-toggle-spacer{flex:0 0 20px;width:20px}.mach-tree-text{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mach-cell--drag{justify-content:center;padding:0;cursor:grab}.mach-row-drag-handle{display:grid;place-items:center;width:26px;height:26px;padding:0;border:1px solid transparent;border-radius:var(--mach-radius-sm);color:var(--mach-header-fg);background:transparent;opacity:.55;cursor:grab;user-select:none;touch-action:none;transition:color var(--mach-transition),background var(--mach-transition),opacity var(--mach-transition)}.mach-row-drag-handle:before{content:"";width:10px;height:14px;background:radial-gradient(circle,currentColor 1.3px,transparent 1.5px) 0 0 / 5px 5px}.mach-row-drag-handle:hover:not(:disabled),.mach-row-drag-handle:focus-visible{opacity:1;color:var(--mach-primary);background:var(--mach-primary-weak);border-color:color-mix(in srgb,var(--mach-primary) 28%,transparent);outline:none}.mach-row-drag-handle:disabled{opacity:.2;cursor:not-allowed}.mach-row-drop-indicator{position:absolute;top:0;left:0;width:100%;height:2px;background:var(--mach-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--mach-body-bg) 65%,transparent);z-index:5;pointer-events:none;will-change:transform}.mach-row-drop-indicator:before{content:"";position:absolute;left:1px;top:-2px;width:6px;height:6px;border-radius:50%;background:var(--mach-primary)}.mach-pane--center .mach-row-drop-indicator:before,.mach-pane--right .mach-row-drop-indicator:before{display:none}.mach-row-drag-preview{position:absolute;top:0;left:0;z-index:var(--mach-z-overlay);max-width:min(216px,calc(100% - 16px));padding:9px 14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border:1px solid color-mix(in srgb,var(--mach-primary) 35%,var(--mach-border-color));border-radius:var(--mach-radius);background:var(--mach-body-bg);color:var(--mach-body-fg);box-shadow:var(--mach-shadow);font-weight:600;pointer-events:none}.mach-root--row-dragging,.mach-root--row-dragging .mach-cell,.mach-root--row-dragging .mach-row-drag-handle{cursor:grabbing;user-select:none}.mach-root .mach-row--drag-source{opacity:.45}.mach-cell--index{color:var(--mach-header-fg);font-size:calc(var(--mach-font-size) - 1px)}.mach-editor-input.mach-editor-invalid,.mach-editor-invalid .mach-editor-input,.mach-editor-invalid .mach-select-trigger,.mach-editor-invalid input,.mach-editor-invalid select:not([hidden]){border-color:#ef4444!important;box-shadow:0 0 0 1px #ef444459}.mach-editor-validating{cursor:progress;opacity:.72}.mach-footer{display:flex;flex-shrink:0;width:100%;overflow:hidden;background:var(--mach-header-bg);border-top:1px solid var(--mach-border-color);font-weight:600;color:var(--mach-header-fg);position:relative;z-index:3}.mach-footer-row{position:relative;overflow:hidden;flex-shrink:0}.mach-footer-row--center{flex:1 1 auto;min-width:0}.mach-footer-cell{position:absolute;top:0;display:flex;align-items:center;padding:0 var(--mach-cell-padding);border-right:1px solid transparent;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;height:100%;font-variant-numeric:tabular-nums}.mach-root.mach-cell-borders .mach-footer-cell{border-right-color:var(--mach-border-color)}.mach-cell--range{background:color-mix(in srgb,var(--mach-primary) 7%,transparent)!important}.mach-cell--range:after{content:"";position:absolute;inset:0;z-index:2;border:0 solid var(--mach-primary);pointer-events:none}.mach-cell--range.mach-cell--range-top:after{border-top-width:1.5px}.mach-cell--range.mach-cell--range-bottom:after{border-bottom-width:1.5px}.mach-cell--range.mach-cell--range-left:after{border-left-width:1.5px}.mach-cell--range.mach-cell--range-right:after{border-right-width:1.5px}.mach-cell--range.mach-cell--focus{box-shadow:inset 0 0 0 var(--mach-focus-width) var(--mach-cell-focus-color)}.mach-cell--range.mach-cell--focus:after{display:none}.mach-context-menu{position:fixed;z-index:var(--mach-z-menu);display:flex;flex-direction:column;min-width:140px;padding:5px;background:var(--mach-body-bg);color:var(--mach-body-fg);border:1px solid var(--mach-border-color);border-radius:var(--mach-radius-lg);box-shadow:var(--mach-shadow);font-family:var(--mach-font-family);font-size:var(--mach-font-size)}.mach-context-menu-item{text-align:left;padding:6px 10px;border:none;border-radius:var(--mach-radius);background:transparent;color:inherit;font:inherit;cursor:pointer;white-space:nowrap}.mach-context-menu-item:hover{background:var(--mach-row-hover-bg);color:var(--mach-primary)}.mach-fill-handle{position:absolute;width:8px;height:8px;border-radius:2px;background:var(--mach-primary);border:1.5px solid var(--mach-body-bg);cursor:crosshair;z-index:6;box-shadow:0 0 0 1px #2563eb59}.mach-root--filling,.mach-root--filling *{user-select:none!important;cursor:crosshair!important}.mach-infinite-loading{position:absolute;left:50%;bottom:14px;transform:translate(-50%);display:flex;align-items:center;gap:8px;padding:5px 14px;border-radius:999px;background:var(--mach-body-bg);border:1px solid var(--mach-border-color);box-shadow:var(--mach-shadow-sm);color:var(--mach-header-fg);font-size:12px;z-index:var(--mach-z-loading)}.mach-infinite-loading .mach-spinner{width:14px;height:14px;border-width:2px}.mach-statusbar{display:flex;align-items:center;gap:18px;flex-shrink:0;height:28px;padding:0 12px;background:var(--mach-header-bg);border-top:1px solid var(--mach-border-color);color:var(--mach-header-fg);font-size:11px;overflow:hidden;white-space:nowrap;font-variant-numeric:tabular-nums}.mach-statusbar-item--rangeAggregate{margin-left:auto}.mach-pinned-rows{display:flex;width:100%;overflow:hidden;background:var(--mach-header-bg);flex-shrink:0;border-bottom:1px solid var(--mach-border-color)}.mach-pinned-rows--bottom{border-bottom:none;border-top:1px solid var(--mach-border-color)}.mach-pinned-viewport{flex:1 1 auto;min-width:0;overflow:hidden}.mach-pinned-seg{position:relative;overflow:hidden;flex-shrink:0}.mach-pinned-seg--center{position:relative}.mach-pinned-row{position:relative;width:100%;border-bottom:1px solid var(--mach-row-border-color)}.mach-pinned-row .mach-cell{position:absolute;top:0;background:var(--mach-header-bg);font-weight:600;color:var(--mach-header-fg)}.mach-pinned-row:last-child{border-bottom:none}.mach-cell--wrap{white-space:normal;word-break:break-word;line-height:1.45;align-items:flex-start;padding-top:5px;padding-bottom:5px}.mach-editor-input,.mach-editor-select-control .mach-select-trigger{width:100%;height:calc(var(--mach-row-h) - 8px);padding:0 6px;border:1px solid var(--mach-primary);border-radius:var(--mach-radius-sm);font-family:inherit;font-size:var(--mach-font-size);color:inherit;background:var(--mach-body-bg);outline:none}.mach-select-control{position:relative;display:inline-flex;min-width:0;font-family:var(--mach-font-family, inherit);font-size:var(--mach-font-size, 14px)}.mach-select-native[hidden]{display:none!important}.mach-select-trigger{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0;height:34px;padding:0 10px;border:1px solid var(--mach-border-color, #e6eaf0);border-radius:var(--mach-radius, 6px);outline:none;color:var(--mach-body-fg, #1f2937);background:var(--mach-body-bg, #fff);font:inherit;line-height:1;text-align:left;cursor:pointer;transition:border-color var(--mach-transition, .15s ease),box-shadow var(--mach-transition, .15s ease),background-color var(--mach-transition, .15s ease)}.mach-select-trigger:hover{border-color:color-mix(in srgb,var(--mach-primary, #2563eb) 44%,var(--mach-border-color, #e6eaf0));background:color-mix(in srgb,var(--mach-primary, #2563eb) 3%,var(--mach-body-bg, #fff))}.mach-select-trigger:focus-visible,.mach-select-trigger[aria-expanded=true]{border-color:var(--mach-primary, #2563eb);box-shadow:0 0 0 3px color-mix(in srgb,var(--mach-primary, #2563eb) 12%,transparent)}.mach-select-value{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mach-select-caret{width:8px;height:8px;flex:0 0 auto;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:translateY(-2px) rotate(45deg);transition:transform var(--mach-transition, .15s ease)}.mach-select-trigger[aria-expanded=true] .mach-select-caret{transform:translateY(2px) rotate(225deg)}.mach-select-listbox{position:fixed;z-index:var(--mach-z-menu, 1200);display:none;flex-direction:column;gap:2px;min-width:112px;max-width:min(320px,calc(100vw - 16px));max-height:min(244px,calc(100vh - 16px));padding:5px;overflow:auto;overscroll-behavior:contain;border:1px solid color-mix(in srgb,var(--mach-border-color, #e6eaf0) 88%,var(--mach-primary, #2563eb));border-radius:calc(var(--mach-radius-lg, 8px) + 1px);color:var(--mach-body-fg, #1f2937);background:var(--mach-body-bg, #fff);box-shadow:0 14px 36px color-mix(in srgb,var(--mach-body-fg, #1f2937) 18%,transparent),var(--mach-shadow-sm, 0 1px 3px rgba(15, 23, 42, .12));font-family:var(--mach-font-family, inherit);font-size:var(--mach-font-size, 14px);isolation:isolate}.mach-select-listbox--open{display:flex;animation:mach-select-listbox-in .12s ease-out}.mach-select-option{position:relative;display:flex;align-items:center;flex:0 0 auto;width:100%;min-height:32px;padding:0 30px 0 10px;border:0;border-radius:var(--mach-radius, 6px);outline:none;color:inherit;background:transparent;font:inherit;text-align:left;cursor:pointer;transition:color var(--mach-transition, .15s ease),background-color var(--mach-transition, .15s ease)}.mach-select-option:hover,.mach-select-option:focus-visible,.mach-select-option--active{color:var(--mach-primary, #2563eb);background:color-mix(in srgb,var(--mach-primary, #2563eb) 9%,var(--mach-body-bg, #fff))}.mach-select-option[aria-selected=true]{color:var(--mach-primary, #2563eb);background:color-mix(in srgb,var(--mach-primary, #2563eb) 13%,var(--mach-body-bg, #fff));font-weight:600}.mach-select-option[aria-selected=true]:after{content:"\2713";position:absolute;right:10px;font-size:12px;font-weight:700}.mach-select-option:disabled{opacity:.42;cursor:not-allowed}@keyframes mach-select-listbox-in{0%{transform:translateY(-3px) scale(.99)}to{transform:translateY(0) scale(1)}}.mach-select-listbox--above{transform-origin:bottom}.mach-filter-select-control{width:100%}.mach-filter-select-trigger{width:100%;background:color-mix(in srgb,var(--mach-header-bg) 62%,var(--mach-body-bg))}.mach-filter-listbox{width:auto}.mach-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--mach-body-bg);z-index:var(--mach-z-overlay)}.mach-overlay-text{color:var(--mach-header-fg);font-size:var(--mach-font-size)}.mach-overlay-content{max-width:min(100%,320px)}.mach-loading{display:grid;justify-items:center;gap:14px;min-width:172px;padding:20px 24px}.mach-loading__visual{position:relative;display:grid;gap:8px;width:132px;padding:14px 16px;overflow:hidden;background:color-mix(in srgb,var(--mach-header-bg) 82%,var(--mach-body-bg));border:1px solid var(--mach-border-color);border-radius:var(--mach-radius-lg);box-shadow:var(--mach-shadow-sm)}.mach-loading__visual:before{content:"";position:absolute;inset:0;transform:translate(-100%);background:linear-gradient(100deg,transparent 20%,color-mix(in srgb,var(--mach-primary) 11%,transparent) 50%,transparent 80%);animation:mach-loading-sweep 1.35s ease-in-out infinite}.mach-loading__row{height:7px;border-radius:999px;background:color-mix(in srgb,var(--mach-primary) 13%,var(--mach-border-color))}.mach-loading__row:nth-child(2){width:82%}.mach-loading__row:nth-child(3){width:92%}.mach-loading__row:nth-child(4){width:66%}.mach-loading__status{display:inline-flex;align-items:center;gap:8px;color:var(--mach-header-fg);font-size:var(--mach-font-size-sm)}.mach-loading__spinner{width:14px;height:14px}.mach-loading__label{line-height:1}.mach-spinner{width:22px;height:22px;border:2px solid var(--mach-border-color);border-top-color:var(--mach-primary);border-radius:50%;animation:mach-spin .8s linear infinite}@keyframes mach-spin{to{transform:rotate(360deg)}}@keyframes mach-loading-sweep{to{transform:translate(100%)}}.mach-filter-panel{position:fixed;z-index:var(--mach-z-popup);display:flex;flex-direction:column;gap:10px;width:224px;max-width:calc(100vw - 16px);padding:12px;background:var(--mach-body-bg);color:var(--mach-body-fg);border:1px solid color-mix(in srgb,var(--mach-border-color) 88%,var(--mach-primary));border-radius:calc(var(--mach-radius-lg) + 2px);box-shadow:0 14px 36px color-mix(in srgb,var(--mach-body-fg) 16%,transparent),var(--mach-shadow-sm);font-family:var(--mach-font-family);font-size:var(--mach-font-size);animation:mach-filter-panel-in .14s ease-out}.mach-filter-body{display:flex;flex-direction:column;gap:8px}.mach-filter-input{width:100%;height:34px;padding:0 10px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);font-family:inherit;font-size:var(--mach-font-size);color:inherit;background:var(--mach-body-bg);outline:none;transition:border-color var(--mach-transition),box-shadow var(--mach-transition)}.mach-filter-input:focus{border-color:var(--mach-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--mach-primary) 12%,transparent)}@keyframes mach-filter-panel-in{0%{opacity:0;transform:translateY(-3px) scale(.99)}}.mach-filter-set-list{max-height:220px;overflow:auto;display:flex;flex-direction:column;gap:1px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);padding:4px}.mach-filter-set-item{display:flex;align-items:center;gap:6px;padding:3px 5px;border-radius:var(--mach-radius-sm);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mach-filter-set-item:hover{background:var(--mach-row-hover-bg)}.mach-filter-set-item input{accent-color:var(--mach-primary);margin:0;width:13px;height:13px}.mach-filter-footer{display:flex;justify-content:flex-end;gap:6px}.mach-filter-footer button{padding:4px 12px;border-radius:var(--mach-radius);border:1px solid var(--mach-border-color);background:var(--mach-body-bg);color:inherit;font-family:inherit;font-size:var(--mach-font-size);cursor:pointer}.mach-filter-footer button:hover{border-color:var(--mach-primary);color:var(--mach-primary)}.mach-filter-btn-apply{background:var(--mach-primary)!important;border-color:var(--mach-primary)!important;color:#fff!important}.mach-filter-btn-apply:hover{opacity:.9;color:#fff!important}.mach-column-panel{min-width:220px;max-height:70vh;overflow:auto}.mach-column-panel[role=dialog]{width:min(440px,calc(100vw - 16px))}.mach-column-workbench-search{box-sizing:border-box;width:100%;height:30px;padding:0 9px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);background:var(--mach-body-bg);color:var(--mach-body-fg);font:inherit;outline:none}.mach-column-workbench-search:focus{border-color:var(--mach-primary);box-shadow:0 0 0 2px var(--mach-primary-weak)}.mach-column-panel-title{font-weight:600;color:var(--mach-header-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mach-column-panel-subtitle{font-size:11px;color:var(--mach-header-fg);margin-top:2px}.mach-column-panel-actions{display:flex;gap:6px;flex-wrap:wrap}.mach-column-panel-btn{flex:1;min-width:60px;padding:4px 8px;border-radius:var(--mach-radius);border:1px solid var(--mach-border-color);background:var(--mach-body-bg);color:inherit;font-family:inherit;font-size:12px;cursor:pointer;white-space:nowrap}.mach-column-panel-btn:hover{border-color:var(--mach-primary);color:var(--mach-primary)}.mach-column-panel-divider{height:1px;background:var(--mach-border-color);margin:4px 0}.mach-column-panel-list{max-height:280px;overflow:auto;display:flex;flex-direction:column;gap:1px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);padding:4px}.mach-column-workbench-item{display:grid;grid-template-columns:minmax(120px,1fr) 108px 26px 26px;align-items:center;gap:4px;min-height:32px;padding:2px 3px;border-radius:var(--mach-radius)}.mach-column-workbench-item:hover{background:var(--mach-row-hover-bg)}.mach-column-workbench-label{display:flex;min-width:0;align-items:center;gap:7px;cursor:pointer}.mach-column-workbench-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mach-column-workbench-pin-control,.mach-column-workbench-move{height:26px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);background:var(--mach-body-bg);color:inherit;font:inherit}.mach-column-workbench-pin-control{width:108px;border:0}.mach-column-workbench-pin-control .mach-select-trigger{width:100%;height:26px;padding:0 7px;border-radius:var(--mach-radius);font-size:12px;box-shadow:none}.mach-column-workbench-move{padding:0;cursor:pointer}.mach-column-workbench-move:disabled{cursor:not-allowed;opacity:.35}.mach-tag{display:inline-flex;align-items:center;gap:4px;padding:0 8px;height:20px;line-height:18px;border-radius:999px;font-size:var(--mach-font-size-sm);font-weight:500;white-space:nowrap}.mach-tag:before{content:"";width:5px;height:5px;border-radius:999px;background:currentColor}.mach-tag--success{color:var(--mach-success);background:color-mix(in srgb,var(--mach-success) 10%,transparent)}.mach-tag--warning{color:var(--mach-warning);background:color-mix(in srgb,var(--mach-warning) 12%,transparent)}.mach-tag--danger{color:var(--mach-danger);background:color-mix(in srgb,var(--mach-danger) 10%,transparent)}.mach-tag--info{color:var(--mach-info);background:color-mix(in srgb,var(--mach-info) 10%,transparent)}.mach-tag--neutral{color:var(--mach-header-fg);background:color-mix(in srgb,var(--mach-header-fg) 10%,transparent)}.mach-progress{display:flex;align-items:center;gap:6px;width:100%}.mach-progress__track{flex:1;min-width:0;height:6px;border-radius:999px;background:color-mix(in srgb,var(--mach-header-fg) 14%,transparent);overflow:hidden}.mach-progress__bar{height:100%;border-radius:999px;background:var(--mach-primary);transition:width var(--mach-transition)}.mach-progress__label{flex-shrink:0;font-size:var(--mach-font-size-sm);color:var(--mach-header-fg);font-variant-numeric:tabular-nums}.mach-link{color:var(--mach-primary);cursor:pointer}.mach-link:hover{text-decoration:underline}.mach-actions{display:inline-flex;align-items:center;gap:2px}.mach-sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}.mach-action-btn{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;padding:0 4px;border:none;border-radius:var(--mach-radius-sm);background:transparent;color:var(--mach-header-fg);font-size:var(--mach-font-size-sm);line-height:1;cursor:pointer;white-space:nowrap;transition:color var(--mach-transition),background-color var(--mach-transition),transform var(--mach-transition)}.mach-action-btn:hover{background:var(--mach-row-hover-bg);color:var(--mach-primary)}.mach-action-btn--danger:hover{background:color-mix(in srgb,var(--mach-danger) 10%,transparent);color:var(--mach-danger);transform:scale(1.06)}.mach-action-btn--success:hover{background:color-mix(in srgb,var(--mach-success) 12%,transparent);color:var(--mach-success);transform:scale(1.06)}.mach-action-btn--primary{color:var(--mach-primary)}.mach-action-btn--warning{color:var(--mach-warning)}.mach-action-btn--success,.mach-edit-control--confirm{color:var(--mach-success)}.mach-action-btn--danger{color:var(--mach-danger)}.mach-action-btn:focus-visible,.mach-edit-control:focus-visible,.mach-cell-edit-trigger:focus-visible,.mach-action-drawer__close:focus-visible{outline:2px solid color-mix(in srgb,var(--mach-primary) 65%,transparent);outline-offset:1px}.mach-action-btn:disabled{cursor:not-allowed;opacity:.4}.mach-action-btn--loading svg{animation:mach-spin .8s linear infinite}.mach-action-btn--icon{padding:0;width:24px}.mach-context-menu-item--danger{color:var(--mach-danger)}.mach-context-menu-item,.mach-action-drawer__item{display:flex;align-items:center;gap:9px}.mach-context-menu-item--primary,.mach-action-drawer__item--primary{color:var(--mach-primary)}.mach-context-menu-item--warning,.mach-action-drawer__item--warning{color:var(--mach-warning)}.mach-context-menu-item--success,.mach-action-drawer__item--success{color:var(--mach-success)}.mach-context-menu-item--danger,.mach-action-drawer__item--danger{color:var(--mach-danger)}.mach-action-drawer-backdrop{position:fixed;inset:0;z-index:calc(var(--mach-z-menu) + 2);background:#0f172a33;backdrop-filter:blur(1px)}.mach-action-drawer{position:absolute;top:0;right:0;display:flex;flex-direction:column;width:min(340px,calc(100vw - 24px));height:100%;background:var(--mach-body-bg);color:var(--mach-body-fg);border-left:1px solid var(--mach-border-color);box-shadow:-16px 0 40px #0f172a24;font-family:var(--mach-font-family);animation:mach-drawer-in .18s ease-out}.mach-action-drawer__header{display:flex;align-items:center;justify-content:space-between;min-height:56px;padding:0 16px 0 20px;border-bottom:1px solid var(--mach-border-color)}.mach-action-drawer__close{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:0;border-radius:var(--mach-radius);background:transparent;color:var(--mach-header-fg);cursor:pointer}.mach-action-drawer__close:hover{color:var(--mach-primary);background:var(--mach-row-hover-bg)}.mach-action-drawer__body{display:flex;flex-direction:column;gap:4px;padding:12px;overflow:auto}.mach-action-drawer__item{width:100%;min-height:40px;padding:0 12px;border:0;border-radius:var(--mach-radius);background:transparent;font:inherit;text-align:left;cursor:pointer}.mach-action-drawer__item:hover:not(:disabled){background:var(--mach-row-hover-bg)}.mach-action-drawer__item:disabled{opacity:.4;cursor:not-allowed}@keyframes mach-drawer-in{0%{transform:translate(18px);opacity:0}to{transform:translate(0);opacity:1}}@media(max-width:640px){.mach-action-drawer{top:auto;bottom:0;width:100%;height:auto;max-height:min(70vh,520px);border-top:1px solid var(--mach-border-color);border-left:0;border-radius:var(--mach-radius-lg) var(--mach-radius-lg) 0 0;animation-name:mach-drawer-up}}@keyframes mach-drawer-up{0%{transform:translateY(18px);opacity:0}to{transform:translateY(0);opacity:1}}.mach-cell:has(.mach-cell-edit-trigger){padding-right:29px}.mach-cell-edit-trigger{position:absolute;right:5px;top:50%;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;transform:translateY(-50%);border:0;border-radius:var(--mach-radius-sm);background:transparent;color:var(--mach-header-fg);cursor:pointer;opacity:0;transition:opacity var(--mach-transition),color var(--mach-transition),background-color var(--mach-transition)}.mach-cell-edit-trigger svg{width:13px;height:13px}.mach-cell:hover .mach-cell-edit-trigger--hover,.mach-cell:focus-within .mach-cell-edit-trigger--hover,.mach-cell-edit-trigger--always{opacity:.72}.mach-cell-edit-trigger:hover{opacity:1;color:var(--mach-primary);background:color-mix(in srgb,var(--mach-primary) 9%,transparent)}.mach-cell--editing{overflow:visible;z-index:4}.mach-cell-editor-shell,.mach-row-editor-shell{display:flex;align-items:center;width:100%;min-width:0;gap:5px}.mach-cell-editor-shell>.mach-editor-input,.mach-cell-editor-shell>.mach-editor-select-control,.mach-cell-editor-shell>:not(.mach-cell-editor-controls),.mach-row-editor-shell>*{flex:1 1 auto;min-width:0}.mach-cell-editor-controls{display:inline-flex;flex:0 0 auto;align-items:center;gap:2px;padding:2px;border:1px solid var(--mach-border-color);border-radius:var(--mach-radius);background:var(--mach-body-bg);box-shadow:var(--mach-shadow-sm)}.mach-edit-control{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:var(--mach-radius-sm);background:transparent;color:var(--mach-header-fg);cursor:pointer;transition:color var(--mach-transition),background-color var(--mach-transition),transform var(--mach-transition)}.mach-edit-control svg{width:14px;height:14px}.mach-edit-control--confirm{color:var(--mach-success)}.mach-edit-control--confirm:hover{background:color-mix(in srgb,var(--mach-success) 12%,transparent);transform:scale(1.06)}.mach-edit-control--cancel{color:var(--mach-danger)}.mach-edit-control--cancel:hover{background:color-mix(in srgb,var(--mach-danger) 10%,transparent);transform:scale(1.06)}.mach-edit-control:disabled{opacity:.35;cursor:wait}.mach-row--editing,.mach-row--editing .mach-cell{background:color-mix(in srgb,var(--mach-primary) 3%,var(--mach-body-bg))}.mach-cell--row-editing .mach-editor-input,.mach-cell--row-editing .mach-editor-select-control .mach-select-trigger{border-color:color-mix(in srgb,var(--mach-primary) 45%,var(--mach-border-color));box-shadow:0 1px 2px #0f172a0a}.mach-cell--row-editing .mach-editor-input:focus,.mach-cell--row-editing .mach-editor-select-control .mach-select-trigger:focus-visible,.mach-cell--row-editing .mach-editor-select-control .mach-select-trigger[aria-expanded=true]{border-color:var(--mach-primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--mach-primary) 12%,transparent)}.mach-tooltip{position:fixed;z-index:var(--mach-z-menu);max-width:320px;padding:6px 10px;border-radius:var(--mach-radius);background:var(--mach-body-fg);color:var(--mach-body-bg);font-size:var(--mach-font-size-sm);line-height:1.5;box-shadow:var(--mach-shadow);pointer-events:none;word-break:break-word}.mach-cell--flash{animation:mach-flash .8s ease-out}@keyframes mach-flash{0%{background-color:color-mix(in srgb,var(--mach-primary) 35%,transparent)}to{background-color:transparent}}.mach-context-menu-separator{height:1px;margin:4px 6px;background:var(--mach-border-color)}.mach-context-menu-item:disabled{opacity:.45;cursor:not-allowed}.mach-pagination{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-shrink:0;height:40px;padding:0 12px;background:var(--mach-body-bg);border-top:var(--mach-border-width) solid var(--mach-border-color);color:var(--mach-body-fg);font-size:var(--mach-font-size-sm);user-select:none}.mach-pagination-total{color:var(--mach-header-fg);margin-right:8px;font-variant-numeric:tabular-nums}.mach-pagination-page{min-width:72px;text-align:center;color:var(--mach-body-fg);font-variant-numeric:tabular-nums}.mach-pagination-btn{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border:var(--mach-border-width) solid var(--mach-border-color);border-radius:var(--mach-radius-sm);background:var(--mach-body-bg);color:var(--mach-header-fg);font-size:13px;line-height:1;cursor:pointer;transition:border-color var(--mach-transition),color var(--mach-transition),background-color var(--mach-transition)}.mach-pagination-btn:hover:not(:disabled){border-color:var(--mach-primary);color:var(--mach-primary)}.mach-pagination-btn:disabled{opacity:.35;cursor:not-allowed}.mach-pagination-size-control{height:24px;margin-left:6px;width:92px;font-size:var(--mach-font-size-sm)}.mach-pagination-size-control .mach-select-trigger{width:100%;height:24px;padding:0 6px;border-width:var(--mach-border-width);border-radius:var(--mach-radius-sm);color:var(--mach-header-fg);box-shadow:none}.mach-watermark{position:absolute;inset:0;z-index:6;pointer-events:none;background-repeat:repeat}.mach-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:32px 16px;min-height:160px;text-align:center;color:var(--mach-body-fg);font-size:12px;line-height:20px;overflow-wrap:anywhere}.mach-empty__icon{fill:var(--mach-body-bg);margin-bottom:6px;width:96px;height:84px;stroke:#8b98ff;stroke-linecap:round}.mach-empty__title{font-size:14px;line-height:22px;font-weight:500}.mach-empty__hint{opacity:.45}@media(prefers-reduced-motion:reduce){.mach-spinner,.mach-loading__visual:before{animation-duration:2.4s}}.mach-cell--center{justify-content:center}.mach-cell--right{justify-content:flex-end}.mach-header-cell--center .mach-header-label{text-align:center}.mach-header-cell--right .mach-header-label{text-align:right}@media(prefers-reduced-motion:reduce){.mach-root *,.mach-root *:before,.mach-root *:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}.mach-action-drawer{animation:none!important}}.mach-root{--mach-row-warning-bg: color-mix(in srgb, var(--mach-warning) 11%, var(--mach-body-bg));--mach-row-danger-bg: color-mix(in srgb, var(--mach-danger) 9%, var(--mach-body-bg));--mach-row-success-bg: color-mix(in srgb, var(--mach-success) 10%, var(--mach-body-bg));--mach-row-info-bg: color-mix(in srgb, var(--mach-info) 10%, var(--mach-body-bg))}.mach-row--styled[data-row-tone=warning]{--mach-row-rule-bg: var(--mach-row-warning-bg)}.mach-row--styled[data-row-tone=danger]{--mach-row-rule-bg: var(--mach-row-danger-bg)}.mach-row--styled[data-row-tone=success]{--mach-row-rule-bg: var(--mach-row-success-bg)}.mach-row--styled[data-row-tone=info]{--mach-row-rule-bg: var(--mach-row-info-bg)}.mach-root :is(.mach-row,.mach-pinned-row).mach-row--styled,.mach-root :is(.mach-row,.mach-pinned-row).mach-row--styled .mach-cell{background-color:var(--mach-row-rule-bg, var(--mach-body-bg));color:var(--mach-row-rule-fg, var(--mach-body-fg))}.mach-root .mach-row--styled.mach-row--hover,.mach-root .mach-row--styled.mach-row--hover .mach-cell{background-color:color-mix(in srgb,var(--mach-primary) 4%,var(--mach-row-rule-bg, var(--mach-body-bg)))}.mach-root .mach-row--styled.mach-row--selected,.mach-root .mach-row--styled.mach-row--selected .mach-cell{background-color:color-mix(in srgb,var(--mach-primary) 12%,var(--mach-row-rule-bg, var(--mach-body-bg)))}
@@ -1,4 +1,4 @@
1
- "use strict";var u=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var G=(n,t)=>{for(var r in t)u(n,r,{get:t[r],enumerable:!0})},C=(n,t,r,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of A(t))!E.call(n,i)&&i!==r&&u(n,i,{get:()=>t[i],enumerable:!(e=D(t,i))||e.enumerable});return n};var I=n=>C(u({},"__esModule",{value:!0}),n);var L={};G(L,{createMultiRangeSelection:()=>T});module.exports=I(L);var m=Symbol.for("mach-table.adapter.lifecycle.v1");function y(n,t,r){return n.isDestroyed()?"":n[m]?.readCell(t,r)??""}function w(n,t){n.isDestroyed()||n[m]?.writeInput(t)}var v=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function x(n){return typeof n!="string"||n===""||v.test(n)?n:/^[\s\u0000-\u001f]*[=+\-@]/.test(n)?"'"+n:n}function M(n){return n==null?"":String(n)}function S(n,t){let r=t?x(n):n,e=M(r);return/["\t\n\r]/.test(e)?'"'+e.replace(/"/g,'""')+'"':e}function b(n,t=!0){return n.map(r=>r.map(e=>S(e,t)).join(" ")).join(`
2
- `)}var g=32,R=1e5;function d(n){let t=[...new Map(n.map(r=>[JSON.stringify(r.range),r])).values()];if(t.length>g)throw new RangeError("At most 32 ranges are supported.");if(t.reduce((r,e)=>r+e.rows.length*e.columns.length,0)>R)throw new RangeError("A multi-range operation may affect at most 100000 cells.");return t}function F(n){let t=n.columns.getWorkbenchItems().filter(r=>r.visible);return["left",null,"right"].flatMap(r=>t.filter(e=>e.pinned===r).map(e=>e.colId))}function T(){return new f}var f=class{constructor(){this.key="multi-range";this.context=null;this.saved=[];this.e=0;this.r=null}setup(t){if(this.context)throw new Error("Create a separate multi-range feature for each grid.");if(!t.api.getOption("enableRangeSelection"))throw new Error("Multi-range selection requires enableRangeSelection: true.");this.context=t;let r=null;t.onCleanup(()=>{cancelAnimationFrame(this.e),this.e=0;try{r?.disconnect()}finally{this.o(),this.saved=[],this.context===t&&(this.context=null)}});let{root:e}=t,i=(o,s)=>{t.addManagedDomListener(e,o,a=>{try{s(a)}catch(c){a.preventDefault(),a.stopImmediatePropagation(),t.reportError(c,"multi-range")}},!0)};i("mousedown",o=>this.s(o)),i("keydown",o=>this.a(o)),i("copy",o=>this.i(o)),i("cut",o=>this.i(o,!0)),t.addEventListener("rangeSelectionChanged",()=>this.t()),r=new MutationObserver(()=>this.t()),r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-id","data-col-id"]}),t.addEventListener("modelUpdated",()=>this.clear())}snapshot(t){let r=this.context?.api;if(!r)return null;let e=F(r),i=e.indexOf(t.colId1),o=e.indexOf(t.colId2),s=Math.max(0,Math.min(t.row1,t.row2)),a=Math.min(r.rows.getCount()-1,Math.max(t.row1,t.row2));if(i<0||o<0||!Number.isInteger(s)||!Number.isInteger(a)||a<s)return null;let c=e.slice(Math.min(i,o),Math.max(i,o)+1);if((a-s+1)*c.length>R)throw new RangeError("A range may contain at most 100000 cells.");let h=[];for(let p=s;p<=a;p++){let l=r.rows.getAt(p);l?.data&&!l.isGroup&&!l.isDetail&&!l.loading&&h.push(l.id)}return{range:{row1:s,row2:a,colId1:e[Math.min(i,o)],colId2:e[Math.max(i,o)]},rows:h,columns:c}}n(){let t=this.context?.api.selection.getRange(),r=t?this.snapshot(t):null,e=r?[...this.saved,r]:[...this.saved];return d(e)}getRanges(){return this.n().map(t=>({...t.range}))}setRanges(t){if(!this.context)throw new Error("Install the multi-range feature before setting ranges.");if(t.length>g)throw new RangeError("At most 32 ranges are supported.");let r=d(t.map(e=>this.snapshot(e)).filter(e=>e!==null));this.context.api.selection.clearRange(),this.saved=r,this.t()}clear(){this.saved=[],this.context?.api.selection.clearRange(),this.o(),this.t()}getText(){let t=this.context?.api;return t?this.n().map(r=>b(r.rows.map(e=>r.columns.map(i=>y(t,e,i))))).join(`
1
+ "use strict";var d=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var G=(n,t)=>{for(var r in t)d(n,r,{get:t[r],enumerable:!0})},C=(n,t,r,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of A(t))!E.call(n,i)&&i!==r&&d(n,i,{get:()=>t[i],enumerable:!(e=D(t,i))||e.enumerable});return n};var I=n=>C(d({},"__esModule",{value:!0}),n);var L={};G(L,{createMultiRangeSelection:()=>T});module.exports=I(L);var m=Symbol.for("mach-table.adapter.lifecycle.v1");function y(n,t,r){return n.isDestroyed()?"":n[m]?.readCell(t,r)??""}function w(n,t){n.isDestroyed()||n[m]?.writeInput(t)}var v=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function x(n){return typeof n!="string"||n===""||v.test(n)?n:/^[\s\u0000-\u001f]*[=+\-@]/.test(n)?"'"+n:n}function M(n){return n==null?"":String(n)}function S(n,t){let r=t?x(n):n,e=M(r);return/["\t\n\r]/.test(e)?'"'+e.replace(/"/g,'""')+'"':e}function b(n,t=!0){return n.map(r=>r.map(e=>S(e,t)).join(" ")).join(`
2
+ `)}var g=32,R=1e5;function u(n){let t=[...new Map(n.map(r=>[JSON.stringify(r.range),r])).values()];if(t.length>g)throw new RangeError("At most 32 ranges are supported.");if(t.reduce((r,e)=>r+e.rows.length*e.columns.length,0)>R)throw new RangeError("A multi-range operation may affect at most 100000 cells.");return t}function F(n){let t=n.columns.getWorkbenchItems().filter(r=>r.visible);return["left",null,"right"].flatMap(r=>t.filter(e=>e.pinned===r).map(e=>e.colId))}function T(){return new f}var f=class{constructor(){this.key="multi-range";this.context=null;this.saved=[];this.e=0;this.r=null}setup(t){if(this.context)throw new Error("Create a separate multi-range feature for each grid.");if(!t.api.getOption("enableRangeSelection"))throw new Error("Multi-range selection requires enableRangeSelection: true.");this.context=t;let r=null;t.onCleanup(()=>{cancelAnimationFrame(this.e),this.e=0;try{r?.disconnect()}finally{this.o(),this.saved=[],this.context===t&&(this.context=null)}});let{root:e}=t,i=(o,s)=>{t.addManagedDomListener(e,o,a=>{try{s(a)}catch(c){a.preventDefault(),a.stopImmediatePropagation(),t.reportError(c,"multi-range")}},!0)};i("mousedown",o=>this.s(o)),i("keydown",o=>this.a(o)),i("copy",o=>this.i(o)),i("cut",o=>this.i(o,!0)),t.addEventListener("rangeSelectionChanged",()=>this.t()),r=new MutationObserver(()=>this.t()),r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-id","data-col-id"]}),t.addEventListener("modelUpdated",()=>this.clear())}snapshot(t){let r=this.context?.api;if(!r)return null;let e=F(r),i=e.indexOf(t.colId1),o=e.indexOf(t.colId2),s=Math.max(0,Math.min(t.row1,t.row2)),a=Math.min(r.rows.getCount()-1,Math.max(t.row1,t.row2));if(i<0||o<0||!Number.isInteger(s)||!Number.isInteger(a)||a<s)return null;let c=e.slice(Math.min(i,o),Math.max(i,o)+1);if((a-s+1)*c.length>R)throw new RangeError("A range may contain at most 100000 cells.");let h=[];for(let p=s;p<=a;p++){let l=r.rows.getAt(p);l?.data&&!l.isGroup&&!l.isDetail&&!l.loading&&h.push(l.id)}return{range:{row1:s,row2:a,colId1:e[Math.min(i,o)],colId2:e[Math.max(i,o)]},rows:h,columns:c}}n(){let t=this.context?.api.selection.getRange(),r=t?this.snapshot(t):null,e=r?[...this.saved,r]:[...this.saved];return u(e)}getRanges(){return this.n().map(t=>({...t.range}))}setRanges(t){if(!this.context)throw new Error("Install the multi-range feature before setting ranges.");if(t.length>g)throw new RangeError("At most 32 ranges are supported.");let r=u(t.map(e=>this.snapshot(e)).filter(e=>e!==null));this.context.api.selection.clearRange(),this.saved=r,this.t()}clear(){this.saved=[],this.context?.api.selection.clearRange(),this.o(),this.t()}getText(){let t=this.context?.api;return t?this.n().map(r=>b(r.rows.map(e=>r.columns.map(i=>y(t,e,i))))).join(`
3
3
 
4
- `):""}clearValues(){let t=this.context?.api;if(!t)return;let r=new Map;for(let e of this.n())for(let i of e.rows)for(let o of e.columns)r.set(JSON.stringify([i,o]),{rowId:i,colId:o,value:null});w(t,[...r.values()])}s(t){if(!(!t.target.closest(".mach-cell")||t.button!==0)){if(t.ctrlKey||t.metaKey){let e=this.context?.api.selection.getRange(),i=e?this.snapshot(e):null,o=d(i?[...this.saved,i]:this.saved);if(o.length>=g)throw new RangeError("At most 32 ranges are supported.");this.saved=o}else t.shiftKey||(this.saved=[]);this.t()}}a(t){if(!t.target.closest("input,textarea,select,[contenteditable=true]")){if(t.key==="Escape"){this.clear();return}t.key!=="Delete"&&t.key!=="Backspace"||this.saved.length===0||this.n().length<2||(t.preventDefault(),t.stopImmediatePropagation(),this.clearValues())}}i(t,r=!1){t.target.closest("input,textarea,select,[contenteditable=true]")||this.saved.length===0||this.n().length<2||this.context?.api.getOption("suppressClipboard")||t.clipboardData&&(t.clipboardData.setData("text/plain",this.getText()),t.preventDefault(),t.stopImmediatePropagation(),r&&this.clearValues())}t(){!this.context||this.e||(this.e=requestAnimationFrame(()=>{this.e=0,this.l()}))}o(){this.r?.(),this.r=null}l(){if(this.o(),!this.context)return;let t=this.saved.map(e=>({rows:new Set(e.rows),columns:new Set(e.columns)})),r=[];for(let e of this.context.root.querySelectorAll(".mach-cell")){let i=e.closest(".mach-row");t.some(o=>o.rows.has(i?.dataset.id??"")&&o.columns.has(e.dataset.colId??""))&&(e.classList.add("mach-cell--multi-range"),r.push(e))}this.r=()=>r.forEach(e=>e.classList.remove("mach-cell--multi-range"))}};0&&(module.exports={createMultiRangeSelection});
4
+ `):""}clearValues(){let t=this.context?.api;if(!t)return;let r=new Map;for(let e of this.n())for(let i of e.rows)for(let o of e.columns)r.set(JSON.stringify([i,o]),{rowId:i,colId:o,value:null});w(t,[...r.values()])}s(t){if(!(!t.target.closest(".mach-cell")||t.button!==0)){if(t.ctrlKey||t.metaKey){let e=this.context?.api.selection.getRange(),i=e?this.snapshot(e):null,o=u(i?[...this.saved,i]:this.saved);if(o.length>=g)throw new RangeError("At most 32 ranges are supported.");this.saved=o}else t.shiftKey||(this.saved=[]);this.t()}}a(t){if(!t.target.closest("input,textarea,select,[contenteditable=true]")){if(t.key==="Escape"){this.clear();return}t.key!=="Delete"&&t.key!=="Backspace"||this.saved.length===0||this.n().length<2||(t.preventDefault(),t.stopImmediatePropagation(),this.clearValues())}}i(t,r=!1){t.target.closest("input,textarea,select,[contenteditable=true]")||this.saved.length===0||this.n().length<2||this.context?.api.getOption("suppressClipboard")||t.clipboardData&&(t.clipboardData.setData("text/plain",this.getText()),t.preventDefault(),t.stopImmediatePropagation(),r&&this.clearValues())}t(){!this.context||this.e||(this.e=requestAnimationFrame(()=>{this.e=0,this.l()}))}o(){this.r?.(),this.r=null}l(){if(this.o(),!this.context)return;let t=this.saved.map(e=>({rows:new Set(e.rows),columns:new Set(e.columns)})),r=[];for(let e of this.context.root.querySelectorAll(".mach-cell")){let i=e.closest(".mach-row");t.some(o=>o.rows.has(i?.dataset.id??"")&&o.columns.has(e.dataset.colId??""))&&(e.classList.add("mach-cell--multi-range"),r.push(e))}this.r=()=>r.forEach(e=>e.classList.remove("mach-cell--multi-range"))}};0&&(module.exports={createMultiRangeSelection});
@@ -1,4 +1,4 @@
1
- import { G as GridFeature, a as GridCellRange } from './api-DH2BoJ9I.cjs';
1
+ import { G as GridFeature, a as GridCellRange } from './api-ChEKWrvH.cjs';
2
2
 
3
3
  interface MultiRangeSelection extends GridFeature {
4
4
  getRanges(): GridCellRange[];
@@ -1,4 +1,4 @@
1
- import { G as GridFeature, a as GridCellRange } from './api-DH2BoJ9I.js';
1
+ import { G as GridFeature, a as GridCellRange } from './api-ChEKWrvH.js';
2
2
 
3
3
  interface MultiRangeSelection extends GridFeature {
4
4
  getRanges(): GridCellRange[];
@@ -1,4 +1,4 @@
1
1
  var h=Symbol.for("mach-table.adapter.lifecycle.v1");function m(n,t,r){return n.isDestroyed()?"":n[h]?.readCell(t,r)??""}function y(n,t){n.isDestroyed()||n[h]?.writeInput(t)}var w=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[eE][+-]?\d+)?$/;function v(n){return typeof n!="string"||n===""||w.test(n)?n:/^[\s\u0000-\u001f]*[=+\-@]/.test(n)?"'"+n:n}function R(n){return n==null?"":String(n)}function D(n,t){let r=t?v(n):n,e=R(r);return/["\t\n\r]/.test(e)?'"'+e.replace(/"/g,'""')+'"':e}function x(n,t=!0){return n.map(r=>r.map(e=>D(e,t)).join(" ")).join(`
2
- `)}var d=32,b=1e5;function u(n){let t=[...new Map(n.map(r=>[JSON.stringify(r.range),r])).values()];if(t.length>d)throw new RangeError("At most 32 ranges are supported.");if(t.reduce((r,e)=>r+e.rows.length*e.columns.length,0)>b)throw new RangeError("A multi-range operation may affect at most 100000 cells.");return t}function A(n){let t=n.columns.getWorkbenchItems().filter(r=>r.visible);return["left",null,"right"].flatMap(r=>t.filter(e=>e.pinned===r).map(e=>e.colId))}function L(){return new g}var g=class{constructor(){this.key="multi-range";this.context=null;this.saved=[];this.e=0;this.r=null}setup(t){if(this.context)throw new Error("Create a separate multi-range feature for each grid.");if(!t.api.getOption("enableRangeSelection"))throw new Error("Multi-range selection requires enableRangeSelection: true.");this.context=t;let r=null;t.onCleanup(()=>{cancelAnimationFrame(this.e),this.e=0;try{r?.disconnect()}finally{this.o(),this.saved=[],this.context===t&&(this.context=null)}});let{root:e}=t,o=(i,s)=>{t.addManagedDomListener(e,i,a=>{try{s(a)}catch(c){a.preventDefault(),a.stopImmediatePropagation(),t.reportError(c,"multi-range")}},!0)};o("mousedown",i=>this.s(i)),o("keydown",i=>this.a(i)),o("copy",i=>this.i(i)),o("cut",i=>this.i(i,!0)),t.addEventListener("rangeSelectionChanged",()=>this.t()),r=new MutationObserver(()=>this.t()),r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-id","data-col-id"]}),t.addEventListener("modelUpdated",()=>this.clear())}snapshot(t){let r=this.context?.api;if(!r)return null;let e=A(r),o=e.indexOf(t.colId1),i=e.indexOf(t.colId2),s=Math.max(0,Math.min(t.row1,t.row2)),a=Math.min(r.rows.getCount()-1,Math.max(t.row1,t.row2));if(o<0||i<0||!Number.isInteger(s)||!Number.isInteger(a)||a<s)return null;let c=e.slice(Math.min(o,i),Math.max(o,i)+1);if((a-s+1)*c.length>b)throw new RangeError("A range may contain at most 100000 cells.");let f=[];for(let p=s;p<=a;p++){let l=r.rows.getAt(p);l?.data&&!l.isGroup&&!l.isDetail&&!l.loading&&f.push(l.id)}return{range:{row1:s,row2:a,colId1:e[Math.min(o,i)],colId2:e[Math.max(o,i)]},rows:f,columns:c}}n(){let t=this.context?.api.selection.getRange(),r=t?this.snapshot(t):null,e=r?[...this.saved,r]:[...this.saved];return u(e)}getRanges(){return this.n().map(t=>({...t.range}))}setRanges(t){if(!this.context)throw new Error("Install the multi-range feature before setting ranges.");if(t.length>d)throw new RangeError("At most 32 ranges are supported.");let r=u(t.map(e=>this.snapshot(e)).filter(e=>e!==null));this.context.api.selection.clearRange(),this.saved=r,this.t()}clear(){this.saved=[],this.context?.api.selection.clearRange(),this.o(),this.t()}getText(){let t=this.context?.api;return t?this.n().map(r=>x(r.rows.map(e=>r.columns.map(o=>m(t,e,o))))).join(`
2
+ `)}var u=32,b=1e5;function d(n){let t=[...new Map(n.map(r=>[JSON.stringify(r.range),r])).values()];if(t.length>u)throw new RangeError("At most 32 ranges are supported.");if(t.reduce((r,e)=>r+e.rows.length*e.columns.length,0)>b)throw new RangeError("A multi-range operation may affect at most 100000 cells.");return t}function A(n){let t=n.columns.getWorkbenchItems().filter(r=>r.visible);return["left",null,"right"].flatMap(r=>t.filter(e=>e.pinned===r).map(e=>e.colId))}function L(){return new g}var g=class{constructor(){this.key="multi-range";this.context=null;this.saved=[];this.e=0;this.r=null}setup(t){if(this.context)throw new Error("Create a separate multi-range feature for each grid.");if(!t.api.getOption("enableRangeSelection"))throw new Error("Multi-range selection requires enableRangeSelection: true.");this.context=t;let r=null;t.onCleanup(()=>{cancelAnimationFrame(this.e),this.e=0;try{r?.disconnect()}finally{this.o(),this.saved=[],this.context===t&&(this.context=null)}});let{root:e}=t,o=(i,s)=>{t.addManagedDomListener(e,i,a=>{try{s(a)}catch(c){a.preventDefault(),a.stopImmediatePropagation(),t.reportError(c,"multi-range")}},!0)};o("mousedown",i=>this.s(i)),o("keydown",i=>this.a(i)),o("copy",i=>this.i(i)),o("cut",i=>this.i(i,!0)),t.addEventListener("rangeSelectionChanged",()=>this.t()),r=new MutationObserver(()=>this.t()),r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-id","data-col-id"]}),t.addEventListener("modelUpdated",()=>this.clear())}snapshot(t){let r=this.context?.api;if(!r)return null;let e=A(r),o=e.indexOf(t.colId1),i=e.indexOf(t.colId2),s=Math.max(0,Math.min(t.row1,t.row2)),a=Math.min(r.rows.getCount()-1,Math.max(t.row1,t.row2));if(o<0||i<0||!Number.isInteger(s)||!Number.isInteger(a)||a<s)return null;let c=e.slice(Math.min(o,i),Math.max(o,i)+1);if((a-s+1)*c.length>b)throw new RangeError("A range may contain at most 100000 cells.");let f=[];for(let p=s;p<=a;p++){let l=r.rows.getAt(p);l?.data&&!l.isGroup&&!l.isDetail&&!l.loading&&f.push(l.id)}return{range:{row1:s,row2:a,colId1:e[Math.min(o,i)],colId2:e[Math.max(o,i)]},rows:f,columns:c}}n(){let t=this.context?.api.selection.getRange(),r=t?this.snapshot(t):null,e=r?[...this.saved,r]:[...this.saved];return d(e)}getRanges(){return this.n().map(t=>({...t.range}))}setRanges(t){if(!this.context)throw new Error("Install the multi-range feature before setting ranges.");if(t.length>u)throw new RangeError("At most 32 ranges are supported.");let r=d(t.map(e=>this.snapshot(e)).filter(e=>e!==null));this.context.api.selection.clearRange(),this.saved=r,this.t()}clear(){this.saved=[],this.context?.api.selection.clearRange(),this.o(),this.t()}getText(){let t=this.context?.api;return t?this.n().map(r=>x(r.rows.map(e=>r.columns.map(o=>m(t,e,o))))).join(`
3
3
 
4
- `):""}clearValues(){let t=this.context?.api;if(!t)return;let r=new Map;for(let e of this.n())for(let o of e.rows)for(let i of e.columns)r.set(JSON.stringify([o,i]),{rowId:o,colId:i,value:null});y(t,[...r.values()])}s(t){if(!(!t.target.closest(".mach-cell")||t.button!==0)){if(t.ctrlKey||t.metaKey){let e=this.context?.api.selection.getRange(),o=e?this.snapshot(e):null,i=u(o?[...this.saved,o]:this.saved);if(i.length>=d)throw new RangeError("At most 32 ranges are supported.");this.saved=i}else t.shiftKey||(this.saved=[]);this.t()}}a(t){if(!t.target.closest("input,textarea,select,[contenteditable=true]")){if(t.key==="Escape"){this.clear();return}t.key!=="Delete"&&t.key!=="Backspace"||this.saved.length===0||this.n().length<2||(t.preventDefault(),t.stopImmediatePropagation(),this.clearValues())}}i(t,r=!1){t.target.closest("input,textarea,select,[contenteditable=true]")||this.saved.length===0||this.n().length<2||this.context?.api.getOption("suppressClipboard")||t.clipboardData&&(t.clipboardData.setData("text/plain",this.getText()),t.preventDefault(),t.stopImmediatePropagation(),r&&this.clearValues())}t(){!this.context||this.e||(this.e=requestAnimationFrame(()=>{this.e=0,this.l()}))}o(){this.r?.(),this.r=null}l(){if(this.o(),!this.context)return;let t=this.saved.map(e=>({rows:new Set(e.rows),columns:new Set(e.columns)})),r=[];for(let e of this.context.root.querySelectorAll(".mach-cell")){let o=e.closest(".mach-row");t.some(i=>i.rows.has(o?.dataset.id??"")&&i.columns.has(e.dataset.colId??""))&&(e.classList.add("mach-cell--multi-range"),r.push(e))}this.r=()=>r.forEach(e=>e.classList.remove("mach-cell--multi-range"))}};export{L as createMultiRangeSelection};
4
+ `):""}clearValues(){let t=this.context?.api;if(!t)return;let r=new Map;for(let e of this.n())for(let o of e.rows)for(let i of e.columns)r.set(JSON.stringify([o,i]),{rowId:o,colId:i,value:null});y(t,[...r.values()])}s(t){if(!(!t.target.closest(".mach-cell")||t.button!==0)){if(t.ctrlKey||t.metaKey){let e=this.context?.api.selection.getRange(),o=e?this.snapshot(e):null,i=d(o?[...this.saved,o]:this.saved);if(i.length>=u)throw new RangeError("At most 32 ranges are supported.");this.saved=i}else t.shiftKey||(this.saved=[]);this.t()}}a(t){if(!t.target.closest("input,textarea,select,[contenteditable=true]")){if(t.key==="Escape"){this.clear();return}t.key!=="Delete"&&t.key!=="Backspace"||this.saved.length===0||this.n().length<2||(t.preventDefault(),t.stopImmediatePropagation(),this.clearValues())}}i(t,r=!1){t.target.closest("input,textarea,select,[contenteditable=true]")||this.saved.length===0||this.n().length<2||this.context?.api.getOption("suppressClipboard")||t.clipboardData&&(t.clipboardData.setData("text/plain",this.getText()),t.preventDefault(),t.stopImmediatePropagation(),r&&this.clearValues())}t(){!this.context||this.e||(this.e=requestAnimationFrame(()=>{this.e=0,this.l()}))}o(){this.r?.(),this.r=null}l(){if(this.o(),!this.context)return;let t=this.saved.map(e=>({rows:new Set(e.rows),columns:new Set(e.columns)})),r=[];for(let e of this.context.root.querySelectorAll(".mach-cell")){let o=e.closest(".mach-row");t.some(i=>i.rows.has(o?.dataset.id??"")&&i.columns.has(e.dataset.colId??""))&&(e.classList.add("mach-cell--multi-range"),r.push(e))}this.r=()=>r.forEach(e=>e.classList.remove("mach-cell--multi-range"))}};export{L as createMultiRangeSelection};
package/dist/ordering.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var ae=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Be=(r,e)=>{for(var t in e)ae(r,t,{get:e[t],enumerable:!0})},Ke=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of He(e))!qe.call(r,o)&&o!==t&&ae(r,o,{get:()=>e[o],enumerable:!(n=Fe(e,o))||n.enumerable});return r};var Ue=r=>Ke(ae({},"__esModule",{value:!0}),r);var nt={};Be(nt,{RowOrderConflictError:()=>L,createRowOrderController:()=>Me,moveTreeNodes:()=>Q,reorderRows:()=>J});module.exports=Ue(nt);var Ye=new Set(["__proto__","prototype","constructor"]),Y=new Map;function _e(r){if(typeof r!="string"||r.length===0)return null;let e=Y.get(r);if(e!==void 0)return e;let t=r.split("."),n=t.every(o=>o.length>0&&!Ye.has(o))?t:null;return r.length<=1024&&(Y.size>=256&&Y.delete(Y.keys().next().value),Y.set(r,n)),n}function V(r,e){if(r==null)return;let t=_e(e);if(!t)return;let n=r;for(let o of t){if(n==null)return;n=n[o]}return n}function $e(r,e){let t=typeof e.rowKey=="function"?e.rowKey(r):V(r,e.rowKey);if(t==null||String(t).length===0)throw new Error("[MachTable] Row ordering requires a non-empty stable row key.");return String(t)}function We(r,e){let t=r[e];if(t==null)return[];if(!Array.isArray(t))throw new Error(`[MachTable] Tree ordering expects an array at "${e}".`);return t}function _(r,e,t,n){let o={entries:[],byId:new Map,byRow:new Map,children:new Map([[null,r]])},i=[...r].reverse().map(a=>({row:a,parentId:null,selectedAncestor:!1})),s=t.childrenKey??"children";for(;i.length;){let a=i.pop(),c=$e(a.row,t);if(o.byId.has(c))throw new Error(`[MachTable] Row ordering found duplicate or cyclic row key "${c}".`);let d=n?We(a.row,s):[],w={...a,id:c,children:d};o.entries.push(w),o.byId.set(c,w),o.byRow.set(w.row,w),o.children.set(c,d);for(let f=d.length-1;f>=0;f--)i.push({row:d[f],parentId:c,selectedAncestor:a.selectedAncestor||e.has(c)})}return o}function ze(r){if(!["before","after","inside"].includes(r.position))throw new Error("[MachTable] Unknown row ordering position.");let e=[...new Set(r.rowIds.map(String))];if(!e.length)throw new Error("[MachTable] Row ordering requires at least one source row.");return{...r,rowIds:e,targetId:String(r.targetId)}}function le(r,e){for(let n of e)if(!r.byId.has(n))throw new Error(`[MachTable] Ordering source "${n}" is unavailable.`);let t=new Set(e);return{selected:t,moved:r.entries.filter(n=>t.has(n.id)&&!n.selectedAncestor)}}function Re(r,e,t,n){let o=r.byId.get(t.targetId);if(!o)throw new Error(`[MachTable] Ordering target "${t.targetId}" is unavailable.`);if(e.selected.has(o.id)||o.selectedAncestor)throw new Error("[MachTable] A row cannot be moved into or relative to its own subtree.");let i=t.position==="inside"?o.id:o.parentId,s=i===null?null:r.byId.get(i).row;if(n.canMove)for(let a of e.moved){let c=a.parentId===null?null:r.byId.get(a.parentId).row,d=n.canMove({row:a.row,previousParent:c,parent:s,target:o.row,intent:t});if(d===!1||typeof d=="string")throw new Error(typeof d=="string"?d:"[MachTable] This row cannot be moved to the selected parent.")}return i}function Te(r,e,t,n){let o=[...new Set(e.map(String))];if(!o.length)throw new Error("[MachTable] Row ordering requires at least one source row.");let i=_(r,new Set(o),t,n),s=le(i,o);return a=>{if(!n&&a.position==="inside")throw new Error("[MachTable] Flat rows cannot have child destinations.");Re(i,s,a,t)}}function je(r,e,t,n){let o=new Set(e.map(d=>d.id)),i=new Map;for(let d of e)i.has(d.parentId)||i.set(d.parentId,r.children.get(d.parentId).filter(w=>!o.has(r.byRow.get(w).id)));let s=i.get(t)??r.children.get(t),a=s.findIndex(d=>d===r.byId.get(n.targetId).row),c=n.position==="inside"?s.length:a+ +(n.position==="after");return i.set(t,[...s.slice(0,c),...e.map(d=>d.row),...s.slice(c)]),i}function be(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}function Xe(r,e,t,n){let o=new Map,i=n.childrenKey??"children";for(let a=e.entries.length-1;a>=0;a--){let c=e.entries[a],w=(t.get(c.id)??c.children).map(f=>o.get(f)??f);be(c.children,w)||o.set(c.row,{...c.row,[i]:w})}let s=(t.get(null)??r).map(a=>o.get(a)??a);return be(r,s)?r:s}function Ve(r,e,t,n){let o=t.indexOf(e[0].row),i=o+e.length;return{...r,rowIds:e.map(s=>s.id),beforeId:o>0?n.byRow.get(t[o-1]).id:null,afterId:i<t.length?n.byRow.get(t[i]).id:null}}function Ie(r,e,t){let n=_(r.before,new Set(r.rowIds),e,t),o=new Map;for(let i of n.children.values())i.forEach((s,a)=>o.set(n.byRow.get(s).id,a));return le(n,r.rowIds).moved.reverse().map(i=>{let s=n.children.get(i.parentId),a=o.get(i.id),c=s[a+1];if(c)return{rowIds:[i.id],targetId:n.byRow.get(c).id,position:"before"};if(i.parentId!==null)return{rowIds:[i.id],targetId:i.parentId,position:"inside"};let d=s[a-1];if(!d)throw new Error("[MachTable] Row ordering cannot restore an isolated root.");return{rowIds:[i.id],targetId:n.byRow.get(d).id,position:"after"}})}function De(r,e,t,n,o){if(!n.canMove)return;let i=_(r,new Set,n,o),s=_(e,new Set,n,o);for(let a of t)for(let c of a.rowIds){let d=i.byId.get(c),w=s.byId.get(c),f=w.parentId===null?null:i.byId.get(w.parentId).row,O=d.parentId===null?null:i.byId.get(d.parentId).row,S=n.canMove({row:d.row,previousParent:O,parent:f,target:i.byId.get(a.targetId).row,intent:a});if(S===!1||typeof S=="string")throw new Error(typeof S=="string"?S:"[MachTable] This row cannot be restored to its previous parent.")}}function Oe(r,e,t,n){let o=ze(e);if(!n&&o.position==="inside")throw new Error("[MachTable] Flat rows cannot have child destinations.");let i=_(r,new Set(o.rowIds),t,n),{moved:s,selected:a}=le(i,o.rowIds),c=Re(i,{moved:s,selected:a},o,t),d=je(i,s,c,o),w=Xe(r,i,d,t),f=Ve(o,s,d.get(c),i);return{before:r,after:w,intent:f,rowIds:f.rowIds,changed:r!==w}}function J(r,e,t){return Oe(r,e,t,!1)}function Q(r,e,t){return Oe(r,e,t,!0)}function de(r,e,t){let n=document.createElement(r);if(e&&(n.className=e),t)for(let o of Object.keys(t))n.setAttribute(o,t[o]);return n}function C(r,e,t){return r<e?e:r>t?t:r}var ce=Symbol.for("mach-table.adapter.lifecycle.v1");function Z(r){return!r.isDestroyed()&&(r[ce]?.canReplaceData()??!1)}function ue(r,e){let t=r[ce]?.rowDrag;return t?.original===e&&t.policy===r.getOption("rowDragPolicy")}function pe(r,e){let t=r[ce];if(!t)return()=>{};t.rowDrag?.activeInteraction?.destroy();let n={original:e,policy:r.getOption("rowDragPolicy"),factory:o=>(n.activeInteraction=e(o),n.activeInteraction)};return t.rowDrag=n,()=>{n.activeInteraction?.destroy(),t.rowDrag===n&&(t.rowDrag=void 0)}}function Je(r,e){if(r instanceof Error)return r;let t=new Error(typeof r=="string"?r:e);return t.name="AbortError",t}var Qe=()=>Je(void 0,"[MachTable] Operation cancelled.");function xe(r,e,t=Qe){return e?new Promise((n,o)=>{let i=()=>{e.removeEventListener("abort",i),o(t())};if(r.then(n,o).finally(()=>e.removeEventListener("abort",i)),e.aborted){i();return}e.addEventListener("abort",i,{once:!0})}):r}function we(r,e,t){return r.replace("{a}",String(e)).replace("{b}",String(t))}function Ze(r,e,t){return r&&e>.25&&e<.75?"inside":t}function Ee(r,e){let t=0,n=r.length;for(;t<n;){let o=t+n>>>1;r[o]<e?t=o+1:n=o}return t}function et(r,e,t,n,o,i){let s=r.getOption("locale")??{},a=e>1?we(s.rowDragSelection??"\u5DF2\u9009 {a} \u884C \u2192 \u7B2C {b} \u884C",e,n+1):we(s.rowDragPosition??"\u7B2C {a} \u884C \u2192 \u7B2C {b} \u884C",t+1,n+1),c=o==="inside"?s.rowDragInside??"\u79FB\u5165":o==="before"?s.rowDragBefore??"\u4E4B\u524D":s.rowDragAfter??"\u4E4B\u540E";return{text:`${a} \xB7 ${c}`,indicatorStyle:o==="inside"?`height:${i}px;background:color-mix(in srgb,var(--mach-primary) 12%,transparent);box-shadow:inset 0 0 0 1px var(--mach-primary)`:void 0}}function tt(r,e,t){let n={parents:new Map,siblings:new Map([[null,[]]]),depths:new Map},o=[...r].reverse().map(s=>({row:s,parent:null,depth:0})),i=e.childrenKey??"children";for(;o.length;){let{row:s,parent:a,depth:c}=o.pop(),d=String(typeof e.rowKey=="function"?e.rowKey(s):V(s,e.rowKey));if(n.depths.has(d))throw new Error("[MachTable] Row ordering requires unique, acyclic row keys.");n.depths.set(d,c),n.siblings.get(a).push(d),n.siblings.set(d,[]),a!==null&&n.parents.set(d,a);let w=t?s[i]:void 0;if(w!=null&&!Array.isArray(w))throw new Error("[MachTable] Row ordering children must be an array.");for(let f=(w?.length??0)-1;f>=0;f--)o.push({row:w[f],parent:d,depth:c+1})}return n}function Se(r,e,t,n,o,i){let s=new Map;r.rows.forEach(u=>{!u.loading&&!u.isDetail&&!u.isGroup&&u.data!=null&&s.set(u.id,u)});let a=tt(t,n,o),c=new Set(e.selected?[...a.depths.keys()].filter(u=>s.get(u)?.selected):[e.id]),d=[...c],w=u=>{let g=u;for(;g!==void 0;){if(c.has(g))return!0;g=a.parents.get(g)}return!1},f=new Map,O=new Map;for(let[u,g]of a.siblings){let y=g.filter(m=>!c.has(m));f.set(u,y),y.forEach((m,T)=>O.set(m,T))}let S=new Map,A=new Set,x=[],E=[],q=0;r.rows.forEachDisplayed(u=>{A.add(u.id),w(u.id)&&x.push(u.rowIndex),q=u.rowIndex+1;let g=a.depths.get(u.id)??0;for(;E.length&&(a.depths.get(E[E.length-1].id)??0)>=g;)S.set(E.pop().id,u.rowIndex);a.siblings.get(u.id)?.length&&E.push(u)});for(let u of E)S.set(u.id,q);return{rowIds:d,isSource:w,validate:()=>{for(let u of d){let g=s.get(u);if(g.treeLoading)return!1;let y=r.getOption("rowDragPolicy")?.canDrag?.({node:g,api:r});if(y===!1||typeof y=="string")return y}return!0},resolve:({targetNode:u,position:g,fraction:y,height:m})=>{let T=Ze(o,y,g);if(w(u.id))return"Cannot target own subtree.";if(!o&&T==="inside")return!1;let k=T==="inside"?u.id:a.parents.get(u.id)??null,M=f.get(k)??[],B=T==="inside"?M.length:(O.get(u.id)??0)+ +(T==="after"),N=T==="before"?u.rowIndex:S.get(u.id)??u.rowIndex+1,z=N-Ee(x,N)+Ee(x,e.rowIndex);return{intent:{rowIds:d,targetId:u.id,position:T,beforeId:M[B-1]??null,afterId:M[B]??null,expectedRevision:i},indicatorIndex:T==="inside"?u.rowIndex:T==="after"?S.get(u.id):void 0,toIndex:N,targetIndex:z,...et(r,d.length,e.rowIndex,u.rowIndex,T,m)}},keyboardTarget:u=>{let g=e.id;for(;c.has(a.parents.get(g)??"");)g=a.parents.get(g);let y=a.siblings.get(a.parents.get(g)??null)??[],m=y.indexOf(g)+u;for(;m>=0&&m<y.length;){let T=y[m];if(!w(T)&&A.has(T)&&s.has(T))return s.get(T);m+=u}}}}var ee=class{constructor(e){this.host=e;this.e=null;this.n=0;this.o=0;this.l=e=>{let t=this.e;if(!(!t||e.pointerId!==t.pointerId)){if(t.clientX=e.clientX,t.clientY=e.clientY,!t.active){if(Math.abs(e.clientY-t.startY)<5)return;t.active=!0,this.host.root.classList.add("mach-root--row-dragging"),this.host.root.querySelectorAll(".mach-row").forEach(n=>n.classList.toggle("mach-row--drag-source",this.sourceContains(n.dataset.id??"")))}this.u()}};this.m=()=>{if(this.n=0,!!this.e?.active){if(!this.current()){this.destroy();return}this.p(),this.y()&&this.u()}};this.d=e=>{let t=this.e;if(!(!t||e.pointerId!==t.pointerId)){t.clientX=e.clientX,t.clientY=e.clientY,t.active&&this.current()&&this.p(),this.h();try{t.active&&t.drop?.valid&&this.s(e.clientX,e.clientY)&&this.current()&&this.commitDrop(t.drop)}finally{this.release()}}};this.c=e=>{e.key==="Escape"&&(e.preventDefault(),this.destroy())};this.i=e=>{e.type==="pointercancel"&&e.pointerId!==this.e?.pointerId||this.destroy()}}begin(e){let t=this.host.containers.map(o=>{let i=de("div","mach-row-drop-indicator");return i.hidden=!0,o.append(i),i}),n=de("div","mach-row-drag-preview");n.setAttribute("role","status"),n.hidden=!0,this.host.root.append(n),this.e={startY:e.clientY,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,indicators:t,preview:n,drop:null,active:!1},window.addEventListener("pointermove",this.l),window.addEventListener("pointerup",this.d),window.addEventListener("pointercancel",this.i),window.addEventListener("keydown",this.c),window.addEventListener("blur",this.i)}g(e){return this.e?.active===!0&&this.sourceContains(e)}f(e,t=()=>!0){this.o=requestAnimationFrame(()=>{this.o=0,t()&&[...this.host.root.querySelectorAll(".mach-row-drag-handle")].find(n=>n.closest(".mach-row")?.dataset.id===e)?.focus()})}u(){this.n||(this.n=requestAnimationFrame(this.m))}s(e,t,n=0){let o=this.host.body.getBoundingClientRect();return e>=o.left&&e<=o.right&&t>=o.top-n&&t<=o.bottom+n}y(){let e=this.e;if(!e||!this.s(e.clientX,e.clientY,28))return!1;let t=this.host.viewport,n=t.getBoundingClientRect(),o=Math.min(36,n.height/3);if(o<=0)return!1;let i=e.clientY<n.top+o?-Math.ceil(14*C((n.top+o-e.clientY)/o,0,1)):Math.ceil(14*C((e.clientY-n.bottom+o)/o,0,1));if(this.host.scrollBy)return this.host.scrollBy(i);let s=t.scrollTop;return t.scrollTop=C(s+i,0,Math.max(0,t.scrollHeight-t.clientHeight)),t.scrollTop!==s}p(){let e=this.e;if(!e?.active)return;let t=e.clientY-this.host.viewport.getBoundingClientRect().top+this.host.viewport.scrollTop,n=this.describe(t);e.drop=n;let o=this.s(e.clientX,e.clientY);for(let s of e.indicators){if(s.hidden=!o||!n?.valid,!n)continue;s.dataset.dropPosition=n.position??"",s.style.cssText=n.style??"";let a=parseFloat(s.parentElement.style.height),c=Math.min(this.host.getRowTop(n.boundary),Number.isFinite(a)?Math.max(0,a-2):1/0);s.style.transform=`translate3d(0, ${c}px, 0)`}let i=this.host.root.getBoundingClientRect();e.preview.hidden=!1,e.preview.textContent=o?n?.text??this.outsideText():this.outsideText(),e.preview.style.transform=`translate3d(${C(e.clientX-i.left+16,8,Math.max(8,i.width-224))}px, ${C(e.clientY-i.top+16,8,Math.max(8,i.height-48))}px, 0)`}h(){let e=this.e;this.e=null,window.removeEventListener("pointermove",this.l),window.removeEventListener("pointerup",this.d),window.removeEventListener("pointercancel",this.i),window.removeEventListener("keydown",this.c),window.removeEventListener("blur",this.i),cancelAnimationFrame(this.n),this.n=0,this.host.root?.classList.remove("mach-root--row-dragging"),this.host.root?.querySelectorAll(".mach-row--drag-source").forEach(t=>t.classList.remove("mach-row--drag-source")),e?.indicators.forEach(t=>t.remove()),e?.preview.remove()}destroy(){this.h(),this.release(),cancelAnimationFrame(this.o),this.o=0}};var te=class extends ee{constructor(t,n,o){super(t);this.t=t;this.prepare=n;this.v=o;this.scope=null;this.a=!1}r(t,n,o){try{return n()}catch(i){return this.scope&&(this.scope.failed=!0),this.t.report(i,t),o}}w(t){return this.r("prepare",()=>{let n=this.t.capture(t),o=this.prepare(t);return this.scope={node:t,from:t.rowIndex,guard:n,session:o,sourceDecision:!0,failed:!1},this.scope.sourceDecision=o.validate(),this.scope},null)}start(t,n){this.destroy(),this.w(n)&&this.current()&&this.begin(t)}moveWithKeyboard(t,n){this.destroy();let o=this.w(n);if(!(!o||!this.current())){this.a=!0;try{let i=t.key==="ArrowUp"?-1:1,s=this.r("keyboardTarget",()=>o.session.keyboardTarget(i),void 0);s&&this.commitDrop(this.destination(s,i<0?0:1))}finally{this.a=!1,this.release()}}}isSource(t){return this.g(t.id)}current(){return!!(this.scope&&!this.scope.failed&&this.scope.guard.current()&&this.t.api.rows.getById(this.scope.node.id)===this.scope.node)}sourceContains(t){return this.r("isSource",()=>this.scope?.session.isSource(t)??!1,!1)}release(){this.scope=null}outsideText(){return this.t.api.getOption("locale")?.rowDragOutside??"\u79FB\u56DE\u8868\u683C\u5185\u653E\u7F6E \xB7 Esc \u53D6\u6D88"}describe(t){let n=this.t.api,o=C(this.host.findRowAt(t),0,n.rows.getCount()-1),i=n.rows.getAt(o);if(i?.isDetail&&(i=n.rows.getById(i.masterId)),!i)return null;let s=this.host.getRowTop(i.rowIndex),a=this.host.getRowTop(i.rowIndex+1)-s;return this.destination(i,(t-s)/Math.max(1,a))}destination(t,n){let o=this.scope,i=n<.5?"before":"after",s=this.host.getRowTop(t.rowIndex+1)-this.host.getRowTop(t.rowIndex),a=this.r("resolve",()=>o.session.resolve({targetNode:t,position:i,fraction:n,height:s}),!1),c=typeof o.sourceDecision=="string"?o.sourceDecision:typeof a=="string"?a:"\u6B64\u4F4D\u7F6E\u4E0D\u53EF\u653E\u7F6E",d={node:t,fraction:n,boundary:t.rowIndex,valid:!1,text:c};if(!a||typeof a=="string"||o.sourceDecision!==!0||t.loading||t.treeLoading||t.isGroup)return d;d.intent=a.intent,d.position=a.intent.position,d.toIndex=a.toIndex,d.targetIndex=a.targetIndex,d.boundary=a.indicatorIndex??t.rowIndex+ +(a.intent.position==="after"),d.style=a.indicatorStyle,d.text=a.text??c;let w=this.r("canDrop",()=>this.t.api.getOption("rowDragPolicy")?.canDrop?.({node:o.node,api:this.t.api,targetNode:t,intent:a.intent})??!0,!1);return d.valid=w===!0,typeof w=="string"&&(d.text=w),d}commitDrop(t){let n=this.scope;if(!n||!this.current()||this.r("validate",()=>n.session.validate(),!1)!==!0||!this.current())return!1;let o=this.destination(t.node,t.fraction);return!o.valid||!o.intent||!this.current()?!1:(this.a&&this.v(o.intent,i=>this.f(n.node.id,i)),this.t.emit(n.node,n.from,o.toIndex,o.targetIndex,o.intent),!0)}};function $(r,e,t){let n=[],o=[...r].reverse().map(s=>({row:s,parent:null})),i=new Set;for(;o.length;){let s=o.pop();if(i.has(s.row))throw new Error("[MachTable] Installed order contains duplicate or cyclic rows.");i.add(s.row),n.push(s);let a=t?s.row[e]??[]:[];for(let c=a.length-1;c>=0;c--)o.push({row:a[c],parent:s.row})}return n}function H(r,e,t,n){try{let o=$(r,t,n);return o.length===e.length&&o.every((i,s)=>i.row===e[s].row&&i.parent===e[s].parent)}catch{return!1}}function he(r){let e=[];return r?.rows.forEach(t=>e.push({node:t,data:t.data})),e}function W(r,e){if(!r)return!0;if(r.isDestroyed())return!1;let t=0,n=!0;return r.rows.forEach(o=>{let i=e[t++];(i?.node!==o||i.data!==o.data)&&(n=!1)}),n&&t===e.length}var re=class{constructor(){this.entries=[];this.cursor=0}get canUndo(){return this.cursor>0}get canRedo(){return this.cursor<this.entries.length}peek(e){return this.entries[e==="undo"?this.cursor-1:this.cursor]}commit(e,t){e==="undo"?this.cursor--:e==="redo"?this.cursor++:(this.entries.splice(this.cursor),this.entries.push(t),this.entries.length>50&&this.entries.shift(),this.cursor=this.entries.length)}clear(){this.entries=[],this.cursor=0}};var L=class extends Error{constructor(t="The row order changed on the server. Reload before trying again.",n){super(t);this.serverRevision=n;this.name="RowOrderConflictError"}};function rt(r){if(r?.status==="conflict")throw new L(r.message,r.revision);return r?.revision}function Ae(r){if(r.targetId===null)throw new Error("[MachTable] Row ordering requires an existing destination.");return{...r,targetId:r.targetId}}function Me(r){let e={status:"idle",error:null,revision:r.getRevision?.(),plan:null,canUndo:!1,canRedo:!1},t=0,n=!1,o=null,i=null,s=null,a=()=>{},c=()=>{},d=0,w=null,f=new re,O=null,S=new Set,A=r.childrenKey??"children",x=null,E=()=>{f.clear(),O=null},q=()=>{if(!o)return!1;let l=o;return t++,o=null,i=null,l.abort(),!0},u=(l=e.status)=>({canUndo:!n&&l!=="saving"&&f.canUndo,canRedo:!n&&l!=="saving"&&f.canRedo}),g=l=>{e=Object.freeze({...l,...u(l.status)}),s&&!s.isDestroyed()&&s.view.refreshCells();let p=[h=>r.onStateChange?.(h),...S];for(let h of p)try{h?.(e)}catch(v){console.error("[MachTable] Row order state observer failed",v)}},y=()=>r.getRevision?.()??e.revision,m=(l=w)=>{l?.release(),w===l&&(w=null)},T=()=>{!i||i()||(q(),E(),m(),g({...e,status:"idle",plan:null,error:null}))},k=l=>new te(l,p=>Se(l.api,p,r.getRows(),r,r.treeData===!0,y()),(p,h)=>{m();let v=document.activeElement,R=G=>{G.target!==v&&G.target!==document.body&&m(b)},b={api:l.api,intent:p,restore:h,generation:t+1,release:()=>document.removeEventListener("focusin",R,!0)};w=b,document.addEventListener("focusin",R,!0)}),M=()=>{T(),!o&&O&&(O.api!==s||O.revision!==y()||!W(s,O.nodes)||!H(r.getRows(),O.rows,A,r.treeData===!0))&&E();let l=u();(e.canUndo!==l.canUndo||e.canRedo!==l.canRedo)&&(e=Object.freeze({...e,...l}))},B=l=>{if(l===s){T(),ue(l,k)||(c(),c=pe(l,k));return}let p=q();a(),c(),m(),E(),s=l,c=pe(l,k),a=l.on("cellValueChanged",()=>{d++;let h=f.canUndo||f.canRedo;E(),h&&g({...e,status:o?"saving":"idle",plan:o?e.plan:null,error:null})}),p&&g({...e,status:"idle",plan:null,error:null})},N=l=>{if(M(),n)throw new Error("[MachTable] The row order controller is disposed.");if(o)throw new Error("[MachTable] A row order save is already in progress.");let p=y();if(p!==void 0&&l.expectedRevision!==void 0&&l.expectedRevision!==p)throw new L;let h={...l,expectedRevision:l.expectedRevision??p};return(r.treeData?Q:J)(r.getRows(),h,r)},z=async(l,p,h,v,R)=>{if(!l.changed)return l;let b=s;if(b&&!Z(b))throw new Error("[MachTable] Save or discard edited rows before changing their order.");let G=++t;x=null;let j=new AbortController;o=j,i=null;let X=y(),ke=d,F=null,K=[],me=!1,ne=!1,oe=X,ve=I=>{if(!R)return;if(!I||R!==w||R.api!==s){m(R);return}let D=O;R.restore(()=>{let se=D!==null&&D===O&&D.revision===y()&&W(R.api,D.nodes)&&H(r.getRows(),D.rows,A,r.treeData===!0)&&w===R&&!n&&t===R.generation&&s===R.api&&ue(R.api,k);return m(R),se})},P=()=>!n&&t===G,ie=()=>P()&&(!b||s===b&&!b.isDestroyed())&&F!==null&&y()===X&&W(b,K)&&H(r.getRows(),F,A,r.treeData===!0),Ne=I=>{if(!ie()){P()&&!F&&g({...e,status:"error",error:I,plan:l});return}let D=!b||Z(b),U=D?I:Object.assign(new Error("[MachTable] Row order could not be saved. Automatic rollback was skipped to preserve new edits. Save or discard those edits, then reload the row order."),{cause:I});if(D){i=null;try{r.applyRows(l.before),ne=!0}catch(se){U=Object.assign(new Error("[MachTable] Row order could not be saved or restored. Reload the row order before trying again."),{cause:I,rollbackError:se})}}P()&&(ne||E(),g({...e,status:I instanceof L?"conflict":"error",error:U}))},Ge=()=>{if(!P()){ve(!1);return}let I=y(),D=!1;me&&P()&&(I===X||I===oe)&&W(b,K)&&H(r.getRows(),F,A,r.treeData===!0)?(O={rows:F,nodes:K,api:b,revision:I},D=!0):ne&&P()?(O={rows:$(r.getRows(),A,r.treeData===!0),nodes:he(b),api:b,revision:I},D=H(r.getRows(),$(l.before,A,r.treeData===!0),A,r.treeData===!0)):E(),o===j&&(o=null,i=null,s&&!s.isDestroyed()&&s.view.refreshCells()),P()&&e.status==="saving"&&g({...e,status:"idle",plan:null}),M(),ve(D)};try{r.applyRows(l.after),F=$(r.getRows(),A,r.treeData===!0),K=he(b);let I=r.getRows(),D=K[0]?.node;if(i=b&&D?()=>!b.isDestroyed()&&b.rows.getById(D.id)===D:()=>r.getRows()===I,g({...e,status:"saving",error:null,plan:l}),!ie())return l;let U=rt(await xe(Promise.resolve(r.save?.(l.intent,{signal:j.signal,plan:l,operation:p,operations:h})),j.signal));return ie()&&(me=!0,oe=U??X,d===ke?f.commit(p,v):E(),g({...e,status:"saved",revision:oe})),l}catch(I){throw Ne(I),I}finally{Ge()}},ge=async(l,p)=>{p!==w&&(p=void 0),w!==p&&m();let h=N(l);h.changed||m(p);let v=h.changed?Ie(h,r,r.treeData===!0):[];return z(h,"move",[h.intent],{plan:h,inverse:v},p)},Ce=l=>ge(l),fe=async l=>{if(m(),M(),n||o)throw new Error("[MachTable] Row ordering is unavailable while disposed or saving.");let p=f.peek(l);if(!p)throw new Error(`[MachTable] Nothing to ${l}.`);let h=(l==="undo"?p.inverse:[p.plan.intent]).map(G=>({...G,expectedRevision:y()})),v=r.getRows(),R=l==="undo"?p.plan.before:p.plan.after;De(v,R,h,r,r.treeData===!0);let b={before:v,after:R,intent:h[0],rowIds:p.plan.rowIds,changed:!0};return z(b,l,h,p)},Le=l=>{try{if(n||o)return!1;let p=r.getRows(),h=y();if(h!==void 0&&l.expectedRevision!==void 0&&l.expectedRevision!==h)return!1;let v=x?.rowIds===l.rowIds?x.sources:JSON.stringify(l.rowIds.map(String));return(!x||x.rows!==p||x.revision!==h||x.sources!==v)&&(x={rows:p,revision:h,sources:v,rowIds:l.rowIds,validate:Te(p,l.rowIds,r,r.treeData===!0)}),x.rowIds=l.rowIds,x.validate(l),!0}catch(p){return p instanceof Error?p.message:!1}},Pe=l=>{let p=l.intent;if(l.applied||!p)return;B(l.api);let h=t,v=w?.intent===p?w:void 0;Promise.resolve().then(()=>ge(Ae(p),v)).catch(R=>{v&&v.generation!==t&&m(v),!n&&t===h&&e.status!=="saving"&&g({...e,status:R instanceof L?"conflict":"error",error:R})})},ye=l=>n?!1:(B(l),o?"Wait for the current row order to finish saving.":Z(l)||"Save or discard edited rows before changing their order.");return{get state(){return M(),e},bindings:{applyRowDrag:!1,rowDragPolicy:{canDrag:({api:l})=>ye(l),canDrop:({intent:l,api:p})=>{let h=ye(p);if(h!==!0)return h;try{return Le(Ae(l))}catch(v){return v instanceof Error?v.message:!1}},getRevision:y},onRowDragEnd:Pe},preview:N,move:Ce,undo:()=>fe("undo"),redo:()=>fe("redo"),subscribe(l){return n?()=>{}:(S.add(l),()=>{S.delete(l)})},dispose(){n=!0,t++,o?.abort(),o=null,i=null,a(),c(),m(),E(),s&&!s.isDestroyed()&&s.view.refreshCells(),s=null,x=null,S.clear(),e=Object.freeze({...e,status:"idle",error:null,plan:null,canUndo:!1,canRedo:!1})}}}0&&(module.exports={RowOrderConflictError,createRowOrderController,moveTreeNodes,reorderRows});
1
+ "use strict";var ae=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Ke=(r,e)=>{for(var t in e)ae(r,t,{get:e[t],enumerable:!0})},Ue=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Be(e))!qe.call(r,o)&&o!==t&&ae(r,o,{get:()=>e[o],enumerable:!(n=He(e,o))||n.enumerable});return r};var Ye=r=>Ue(ae({},"__esModule",{value:!0}),r);var ot={};Ke(ot,{RowOrderConflictError:()=>P,createRowOrderController:()=>Ce,moveTreeNodes:()=>Q,reorderRows:()=>J});module.exports=Ye(ot);var _e=new Set(["__proto__","prototype","constructor"]),Y=new Map;function $e(r){if(typeof r!="string"||r.length===0)return null;let e=Y.get(r);if(e!==void 0)return e;let t=r.split("."),n=t.every(o=>o.length>0&&!_e.has(o))?t:null;return r.length<=1024&&(Y.size>=256&&Y.delete(Y.keys().next().value),Y.set(r,n)),n}function V(r,e){if(r==null)return;let t=$e(e);if(!t)return;let n=r;for(let o of t){if(n==null)return;n=n[o]}return n}function We(r,e){let t=typeof e.rowKey=="function"?e.rowKey(r):V(r,e.rowKey);if(t==null||String(t).length===0)throw new Error("[MachTable] Row ordering requires a non-empty stable row key.");return String(t)}function ze(r,e){let t=r[e];if(t==null)return[];if(!Array.isArray(t))throw new Error(`[MachTable] Tree ordering expects an array at "${e}".`);return t}function _(r,e,t,n){let o={entries:[],byId:new Map,byRow:new Map,children:new Map([[null,r]])},i=[...r].reverse().map(a=>({row:a,parentId:null,selectedAncestor:!1})),s=t.childrenKey??"children";for(;i.length;){let a=i.pop(),c=We(a.row,t);if(o.byId.has(c))throw new Error(`[MachTable] Row ordering found duplicate or cyclic row key "${c}".`);let d=n?ze(a.row,s):[],h={...a,id:c,children:d};o.entries.push(h),o.byId.set(c,h),o.byRow.set(h.row,h),o.children.set(c,d);for(let f=d.length-1;f>=0;f--)i.push({row:d[f],parentId:c,selectedAncestor:a.selectedAncestor||e.has(c)})}return o}function je(r){if(!["before","after","inside"].includes(r.position))throw new Error("[MachTable] Unknown row ordering position.");let e=[...new Set(r.rowIds.map(String))];if(!e.length)throw new Error("[MachTable] Row ordering requires at least one source row.");return{...r,rowIds:e,targetId:String(r.targetId)}}function le(r,e){for(let n of e)if(!r.byId.has(n))throw new Error(`[MachTable] Ordering source "${n}" is unavailable.`);let t=new Set(e);return{selected:t,moved:r.entries.filter(n=>t.has(n.id)&&!n.selectedAncestor)}}function Re(r,e,t,n){let o=r.byId.get(t.targetId);if(!o)throw new Error(`[MachTable] Ordering target "${t.targetId}" is unavailable.`);if(e.selected.has(o.id)||o.selectedAncestor)throw new Error("[MachTable] A row cannot be moved into or relative to its own subtree.");let i=t.position==="inside"?o.id:o.parentId,s=i===null?null:r.byId.get(i).row;if(n.canMove)for(let a of e.moved){let c=a.parentId===null?null:r.byId.get(a.parentId).row,d=n.canMove({row:a.row,previousParent:c,parent:s,target:o.row,intent:t});if(d===!1||typeof d=="string")throw new Error(typeof d=="string"?d:"[MachTable] This row cannot be moved to the selected parent.")}return i}function Te(r,e,t,n){let o=[...new Set(e.map(String))];if(!o.length)throw new Error("[MachTable] Row ordering requires at least one source row.");let i=_(r,new Set(o),t,n),s=le(i,o);return a=>{if(!n&&a.position==="inside")throw new Error("[MachTable] Flat rows cannot have child destinations.");Re(i,s,a,t)}}function Xe(r,e,t,n){let o=new Set(e.map(d=>d.id)),i=new Map;for(let d of e)i.has(d.parentId)||i.set(d.parentId,r.children.get(d.parentId).filter(h=>!o.has(r.byRow.get(h).id)));let s=i.get(t)??r.children.get(t),a=s.findIndex(d=>d===r.byId.get(n.targetId).row),c=n.position==="inside"?s.length:a+ +(n.position==="after");return i.set(t,[...s.slice(0,c),...e.map(d=>d.row),...s.slice(c)]),i}function be(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}function Ve(r,e,t,n){let o=new Map,i=n.childrenKey??"children";for(let a=e.entries.length-1;a>=0;a--){let c=e.entries[a],h=(t.get(c.id)??c.children).map(f=>o.get(f)??f);be(c.children,h)||o.set(c.row,{...c.row,[i]:h})}let s=(t.get(null)??r).map(a=>o.get(a)??a);return be(r,s)?r:s}function Je(r,e,t,n){let o=t.indexOf(e[0].row),i=o+e.length;return{...r,rowIds:e.map(s=>s.id),beforeId:o>0?n.byRow.get(t[o-1]).id:null,afterId:i<t.length?n.byRow.get(t[i]).id:null}}function Ie(r,e,t){let n=_(r.before,new Set(r.rowIds),e,t),o=new Map;for(let i of n.children.values())i.forEach((s,a)=>o.set(n.byRow.get(s).id,a));return le(n,r.rowIds).moved.reverse().map(i=>{let s=n.children.get(i.parentId),a=o.get(i.id),c=s[a+1];if(c)return{rowIds:[i.id],targetId:n.byRow.get(c).id,position:"before"};if(i.parentId!==null)return{rowIds:[i.id],targetId:i.parentId,position:"inside"};let d=s[a-1];if(!d)throw new Error("[MachTable] Row ordering cannot restore an isolated root.");return{rowIds:[i.id],targetId:n.byRow.get(d).id,position:"after"}})}function De(r,e,t,n,o){if(!n.canMove)return;let i=_(r,new Set,n,o),s=_(e,new Set,n,o);for(let a of t)for(let c of a.rowIds){let d=i.byId.get(c),h=s.byId.get(c),f=h.parentId===null?null:i.byId.get(h.parentId).row,O=d.parentId===null?null:i.byId.get(d.parentId).row,S=n.canMove({row:d.row,previousParent:O,parent:f,target:i.byId.get(a.targetId).row,intent:a});if(S===!1||typeof S=="string")throw new Error(typeof S=="string"?S:"[MachTable] This row cannot be restored to its previous parent.")}}function Oe(r,e,t,n){let o=je(e);if(!n&&o.position==="inside")throw new Error("[MachTable] Flat rows cannot have child destinations.");let i=_(r,new Set(o.rowIds),t,n),{moved:s,selected:a}=le(i,o.rowIds),c=Re(i,{moved:s,selected:a},o,t),d=Xe(i,s,c,o),h=Ve(r,i,d,t),f=Je(o,s,d.get(c),i);return{before:r,after:h,intent:f,rowIds:f.rowIds,changed:r!==h}}function J(r,e,t){return Oe(r,e,t,!1)}function Q(r,e,t){return Oe(r,e,t,!0)}function de(r,e,t){let n=document.createElement(r);if(e&&(n.className=e),t)for(let o of Object.keys(t))n.setAttribute(o,t[o]);return n}function xe(r,e,t,n=!1){let o=e?"addEventListener":"removeEventListener";for(let[i,s]of Object.entries(t))r[o](i,s,n)}function C(r,e,t){return r<e?e:r>t?t:r}var ce=Symbol.for("mach-table.adapter.lifecycle.v1");function Z(r){return!r.isDestroyed()&&(r[ce]?.canReplaceData()??!1)}function ue(r,e){let t=r[ce]?.rowDrag;return t?.original===e&&t.policy===r.getOption("rowDragPolicy")}function pe(r,e){let t=r[ce];if(!t)return()=>{};t.rowDrag?.activeInteraction?.destroy();let n={original:e,policy:r.getOption("rowDragPolicy"),factory:o=>(n.activeInteraction=e(o),n.activeInteraction)};return t.rowDrag=n,()=>{n.activeInteraction?.destroy(),t.rowDrag===n&&(t.rowDrag=void 0)}}function Qe(r,e){if(r instanceof Error)return r;let t=new Error(typeof r=="string"?r:e);return t.name="AbortError",t}var Ze=()=>Qe(void 0,"[MachTable] Operation cancelled.");function Ee(r,e,t=Ze){return e?new Promise((n,o)=>{let i=()=>{e.removeEventListener("abort",i),o(t())};if(r.then(n,o).finally(()=>e.removeEventListener("abort",i)),e.aborted){i();return}e.addEventListener("abort",i,{once:!0})}):r}function he(r,e,t){return r.replace("{a}",String(e)).replace("{b}",String(t))}function et(r,e,t){return r&&e>.25&&e<.75?"inside":t}function Se(r,e){let t=0,n=r.length;for(;t<n;){let o=t+n>>>1;r[o]<e?t=o+1:n=o}return t}function tt(r,e,t,n,o,i){let s=r.getOption("locale")??{},a=e>1?he(s.rowDragSelection??"\u5DF2\u9009 {a} \u884C \u2192 \u7B2C {b} \u884C",e,n+1):he(s.rowDragPosition??"\u7B2C {a} \u884C \u2192 \u7B2C {b} \u884C",t+1,n+1),c=o==="inside"?s.rowDragInside??"\u79FB\u5165":o==="before"?s.rowDragBefore??"\u4E4B\u524D":s.rowDragAfter??"\u4E4B\u540E";return{text:`${a} \xB7 ${c}`,indicatorStyle:o==="inside"?`height:${i}px;background:color-mix(in srgb,var(--mach-primary) 12%,transparent);box-shadow:inset 0 0 0 1px var(--mach-primary)`:void 0}}function rt(r,e,t){let n={parents:new Map,siblings:new Map([[null,[]]]),depths:new Map},o=[...r].reverse().map(s=>({row:s,parent:null,depth:0})),i=e.childrenKey??"children";for(;o.length;){let{row:s,parent:a,depth:c}=o.pop(),d=String(typeof e.rowKey=="function"?e.rowKey(s):V(s,e.rowKey));if(n.depths.has(d))throw new Error("[MachTable] Row ordering requires unique, acyclic row keys.");n.depths.set(d,c),n.siblings.get(a).push(d),n.siblings.set(d,[]),a!==null&&n.parents.set(d,a);let h=t?s[i]:void 0;if(h!=null&&!Array.isArray(h))throw new Error("[MachTable] Row ordering children must be an array.");for(let f=(h?.length??0)-1;f>=0;f--)o.push({row:h[f],parent:d,depth:c+1})}return n}function Ae(r,e,t,n,o,i){let s=new Map;r.rows.forEach(u=>{!u.loading&&!u.isDetail&&!u.isGroup&&u.data!=null&&s.set(u.id,u)});let a=rt(t,n,o),c=new Set(e.selected?[...a.depths.keys()].filter(u=>s.get(u)?.selected):[e.id]),d=[...c],h=u=>{let g=u;for(;g!==void 0;){if(c.has(g))return!0;g=a.parents.get(g)}return!1},f=new Map,O=new Map;for(let[u,g]of a.siblings){let y=g.filter(m=>!c.has(m));f.set(u,y),y.forEach((m,T)=>O.set(m,T))}let S=new Map,A=new Set,x=[],E=[],B=0;r.rows.forEachDisplayed(u=>{A.add(u.id),h(u.id)&&x.push(u.rowIndex),B=u.rowIndex+1;let g=a.depths.get(u.id)??0;for(;E.length&&(a.depths.get(E[E.length-1].id)??0)>=g;)S.set(E.pop().id,u.rowIndex);a.siblings.get(u.id)?.length&&E.push(u)});for(let u of E)S.set(u.id,B);return{rowIds:d,isSource:h,validate:()=>{for(let u of d){let g=s.get(u);if(g.treeLoading)return!1;let y=r.getOption("rowDragPolicy")?.canDrag?.({node:g,api:r});if(y===!1||typeof y=="string")return y}return!0},resolve:({targetNode:u,position:g,fraction:y,height:m})=>{let T=et(o,y,g);if(h(u.id))return"Cannot target own subtree.";if(!o&&T==="inside")return!1;let k=T==="inside"?u.id:a.parents.get(u.id)??null,M=f.get(k)??[],q=T==="inside"?M.length:(O.get(u.id)??0)+ +(T==="after"),N=T==="before"?u.rowIndex:S.get(u.id)??u.rowIndex+1,z=N-Se(x,N)+Se(x,e.rowIndex);return{intent:{rowIds:d,targetId:u.id,position:T,beforeId:M[q-1]??null,afterId:M[q]??null,expectedRevision:i},indicatorIndex:T==="inside"?u.rowIndex:T==="after"?S.get(u.id):void 0,toIndex:N,targetIndex:z,...tt(r,d.length,e.rowIndex,u.rowIndex,T,m)}},keyboardTarget:u=>{let g=e.id;for(;c.has(a.parents.get(g)??"");)g=a.parents.get(g);let y=a.siblings.get(a.parents.get(g)??null)??[],m=y.indexOf(g)+u;for(;m>=0&&m<y.length;){let T=y[m];if(!h(T)&&A.has(T)&&s.has(T))return s.get(T);m+=u}}}}var ee=class{constructor(e){this.host=e;this.e=null;this.n=0;this.o=0;this.h=e=>{let t=this.e;if(!(!t||e.pointerId!==t.pointerId)){if(t.clientX=e.clientX,t.clientY=e.clientY,!t.active){if(Math.abs(e.clientY-t.startY)<5)return;t.active=!0,this.host.root.classList.add("mach-root--row-dragging"),this.host.root.querySelectorAll(".mach-row").forEach(n=>n.classList.toggle("mach-row--drag-source",this.sourceContains(n.dataset.id??"")))}this.d()}};this.m=()=>{if(this.n=0,!!this.e?.active){if(!this.current()){this.destroy();return}this.c(),this.v()&&this.d()}};this.g=e=>{let t=this.e;if(!(!t||e.pointerId!==t.pointerId)){t.clientX=e.clientX,t.clientY=e.clientY,t.active&&this.current()&&this.c(),this.u();try{t.active&&t.drop?.valid&&this.i(e.clientX,e.clientY)&&this.current()&&this.commitDrop(t.drop)}finally{this.release()}}};this.w=e=>{e.key==="Escape"&&(e.preventDefault(),this.destroy())};this.l=e=>{e.type==="pointercancel"&&e.pointerId!==this.e?.pointerId||this.destroy()}}begin(e){let t=this.host.containers.map(o=>{let i=de("div","mach-row-drop-indicator");return i.hidden=!0,o.append(i),i}),n=de("div","mach-row-drag-preview");n.setAttribute("role","status"),n.hidden=!0,this.host.root.append(n),this.e={startY:e.clientY,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,indicators:t,preview:n,drop:null,active:!1},this.a(!0)}a(e){xe(window,e,{pointermove:this.h,pointerup:this.g,pointercancel:this.l,keydown:this.w,blur:this.l})}f(e){return this.e?.active===!0&&this.sourceContains(e)}y(e,t=()=>!0){this.o=requestAnimationFrame(()=>{this.o=0,t()&&[...this.host.root.querySelectorAll(".mach-row-drag-handle")].find(n=>n.closest(".mach-row")?.dataset.id===e)?.focus()})}d(){this.n||(this.n=requestAnimationFrame(this.m))}i(e,t,n=0){let o=this.host.body.getBoundingClientRect();return e>=o.left&&e<=o.right&&t>=o.top-n&&t<=o.bottom+n}v(){let e=this.e;if(!e||!this.i(e.clientX,e.clientY,28))return!1;let t=this.host.viewport,n=t.getBoundingClientRect(),o=Math.min(36,n.height/3);if(o<=0)return!1;let i=e.clientY<n.top+o?-Math.ceil(14*C((n.top+o-e.clientY)/o,0,1)):Math.ceil(14*C((e.clientY-n.bottom+o)/o,0,1));if(this.host.scrollBy)return this.host.scrollBy(i);let s=t.scrollTop;return t.scrollTop=C(s+i,0,Math.max(0,t.scrollHeight-t.clientHeight)),t.scrollTop!==s}c(){let e=this.e;if(!e?.active)return;let t=e.clientY-this.host.viewport.getBoundingClientRect().top+this.host.viewport.scrollTop,n=this.describe(t);e.drop=n;let o=this.i(e.clientX,e.clientY);for(let s of e.indicators){if(s.hidden=!o||!n?.valid,!n)continue;s.dataset.dropPosition=n.position??"",s.style.cssText=n.style??"";let a=parseFloat(s.parentElement.style.height),c=Math.min(this.host.getRowTop(n.boundary),Number.isFinite(a)?Math.max(0,a-2):1/0);s.style.transform=`translate3d(0, ${c}px, 0)`}let i=this.host.root.getBoundingClientRect();e.preview.hidden=!1,e.preview.textContent=o?n?.text??this.outsideText():this.outsideText(),e.preview.style.transform=`translate3d(${C(e.clientX-i.left+16,8,Math.max(8,i.width-224))}px, ${C(e.clientY-i.top+16,8,Math.max(8,i.height-48))}px, 0)`}u(){let e=this.e;this.e=null,this.a(!1),cancelAnimationFrame(this.n),this.n=0,this.host.root?.classList.remove("mach-root--row-dragging"),this.host.root?.querySelectorAll(".mach-row--drag-source").forEach(t=>t.classList.remove("mach-row--drag-source")),e?.indicators.forEach(t=>t.remove()),e?.preview.remove()}destroy(){this.u(),this.release(),cancelAnimationFrame(this.o),this.o=0}};var te=class extends ee{constructor(t,n,o){super(t);this.t=t;this.prepare=n;this.b=o;this.scope=null;this.s=!1}r(t,n,o){try{return n()}catch(i){return this.scope&&(this.scope.failed=!0),this.t.report(i,t),o}}p(t){return this.r("prepare",()=>{let n=this.t.capture(t),o=this.prepare(t);return this.scope={node:t,from:t.rowIndex,guard:n,session:o,sourceDecision:!0,failed:!1},this.scope.sourceDecision=o.validate(),this.scope},null)}start(t,n){this.destroy(),this.p(n)&&this.current()&&this.begin(t)}moveWithKeyboard(t,n){this.destroy();let o=this.p(n);if(!(!o||!this.current())){this.s=!0;try{let i=t.key==="ArrowUp"?-1:1,s=this.r("keyboardTarget",()=>o.session.keyboardTarget(i),void 0);s&&this.commitDrop(this.destination(s,i<0?0:1))}finally{this.s=!1,this.release()}}}isSource(t){return this.f(t.id)}current(){return!!(this.scope&&!this.scope.failed&&this.scope.guard.current()&&this.t.api.rows.getById(this.scope.node.id)===this.scope.node)}sourceContains(t){return this.r("isSource",()=>this.scope?.session.isSource(t)??!1,!1)}release(){this.scope=null}outsideText(){return this.t.api.getOption("locale")?.rowDragOutside??"\u79FB\u56DE\u8868\u683C\u5185\u653E\u7F6E \xB7 Esc \u53D6\u6D88"}describe(t){let n=this.t.api,o=C(this.host.findRowAt(t),0,n.rows.getCount()-1),i=n.rows.getAt(o);if(i?.isDetail&&(i=n.rows.getById(i.masterId)),!i)return null;let s=this.host.getRowTop(i.rowIndex),a=this.host.getRowTop(i.rowIndex+1)-s;return this.destination(i,(t-s)/Math.max(1,a))}destination(t,n){let o=this.scope,i=n<.5?"before":"after",s=this.host.getRowTop(t.rowIndex+1)-this.host.getRowTop(t.rowIndex),a=this.r("resolve",()=>o.session.resolve({targetNode:t,position:i,fraction:n,height:s}),!1),c=typeof o.sourceDecision=="string"?o.sourceDecision:typeof a=="string"?a:"\u6B64\u4F4D\u7F6E\u4E0D\u53EF\u653E\u7F6E",d={node:t,fraction:n,boundary:t.rowIndex,valid:!1,text:c};if(!a||typeof a=="string"||o.sourceDecision!==!0||t.loading||t.treeLoading||t.isGroup)return d;d.intent=a.intent,d.position=a.intent.position,d.toIndex=a.toIndex,d.targetIndex=a.targetIndex,d.boundary=a.indicatorIndex??t.rowIndex+ +(a.intent.position==="after"),d.style=a.indicatorStyle,d.text=a.text??c;let h=this.r("canDrop",()=>this.t.api.getOption("rowDragPolicy")?.canDrop?.({node:o.node,api:this.t.api,targetNode:t,intent:a.intent})??!0,!1);return d.valid=h===!0,typeof h=="string"&&(d.text=h),d}commitDrop(t){let n=this.scope;if(!n||!this.current()||this.r("validate",()=>n.session.validate(),!1)!==!0||!this.current())return!1;let o=this.destination(t.node,t.fraction);return!o.valid||!o.intent||!this.current()?!1:(this.s&&this.b(o.intent,i=>this.y(n.node.id,i)),this.t.emit(n.node,n.from,o.toIndex,o.targetIndex,o.intent),!0)}};function $(r,e,t){let n=[],o=[...r].reverse().map(s=>({row:s,parent:null})),i=new Set;for(;o.length;){let s=o.pop();if(i.has(s.row))throw new Error("[MachTable] Installed order contains duplicate or cyclic rows.");i.add(s.row),n.push(s);let a=t?s.row[e]??[]:[];for(let c=a.length-1;c>=0;c--)o.push({row:a[c],parent:s.row})}return n}function H(r,e,t,n){try{let o=$(r,t,n);return o.length===e.length&&o.every((i,s)=>i.row===e[s].row&&i.parent===e[s].parent)}catch{return!1}}function we(r){let e=[];return r?.rows.forEach(t=>e.push({node:t,data:t.data})),e}function W(r,e){if(!r)return!0;if(r.isDestroyed())return!1;let t=0,n=!0;return r.rows.forEach(o=>{let i=e[t++];(i?.node!==o||i.data!==o.data)&&(n=!1)}),n&&t===e.length}var re=class{constructor(){this.entries=[];this.cursor=0}get canUndo(){return this.cursor>0}get canRedo(){return this.cursor<this.entries.length}peek(e){return this.entries[e==="undo"?this.cursor-1:this.cursor]}commit(e,t){e==="undo"?this.cursor--:e==="redo"?this.cursor++:(this.entries.splice(this.cursor),this.entries.push(t),this.entries.length>50&&this.entries.shift(),this.cursor=this.entries.length)}clear(){this.entries=[],this.cursor=0}};var P=class extends Error{constructor(t="The row order changed on the server. Reload before trying again.",n){super(t);this.serverRevision=n;this.name="RowOrderConflictError"}};function nt(r){if(r?.status==="conflict")throw new P(r.message,r.revision);return r?.revision}function Me(r){if(r.targetId===null)throw new Error("[MachTable] Row ordering requires an existing destination.");return{...r,targetId:r.targetId}}function Ce(r){let e={status:"idle",error:null,revision:r.getRevision?.(),plan:null,canUndo:!1,canRedo:!1},t=0,n=!1,o=null,i=null,s=null,a=()=>{},c=()=>{},d=0,h=null,f=new re,O=null,S=new Set,A=r.childrenKey??"children",x=null,E=()=>{f.clear(),O=null},B=()=>{if(!o)return!1;let l=o;return t++,o=null,i=null,l.abort(),!0},u=(l=e.status)=>({canUndo:!n&&l!=="saving"&&f.canUndo,canRedo:!n&&l!=="saving"&&f.canRedo}),g=l=>{e=Object.freeze({...l,...u(l.status)}),s&&!s.isDestroyed()&&s.view.refreshCells();let p=[w=>r.onStateChange?.(w),...S];for(let w of p)try{w?.(e)}catch(v){console.error("[MachTable] Row order state observer failed",v)}},y=()=>r.getRevision?.()??e.revision,m=(l=h)=>{l?.release(),h===l&&(h=null)},T=()=>{!i||i()||(B(),E(),m(),g({...e,status:"idle",plan:null,error:null}))},k=l=>new te(l,p=>Ae(l.api,p,r.getRows(),r,r.treeData===!0,y()),(p,w)=>{m();let v=document.activeElement,R=G=>{G.target!==v&&G.target!==document.body&&m(b)},b={api:l.api,intent:p,restore:w,generation:t+1,release:()=>document.removeEventListener("focusin",R,!0)};h=b,document.addEventListener("focusin",R,!0)}),M=()=>{T(),!o&&O&&(O.api!==s||O.revision!==y()||!W(s,O.nodes)||!H(r.getRows(),O.rows,A,r.treeData===!0))&&E();let l=u();(e.canUndo!==l.canUndo||e.canRedo!==l.canRedo)&&(e=Object.freeze({...e,...l}))},q=l=>{if(l===s){T(),ue(l,k)||(c(),c=pe(l,k));return}let p=B();a(),c(),m(),E(),s=l,c=pe(l,k),a=l.on("cellValueChanged",()=>{d++;let w=f.canUndo||f.canRedo;E(),w&&g({...e,status:o?"saving":"idle",plan:o?e.plan:null,error:null})}),p&&g({...e,status:"idle",plan:null,error:null})},N=l=>{if(M(),n)throw new Error("[MachTable] The row order controller is disposed.");if(o)throw new Error("[MachTable] A row order save is already in progress.");let p=y();if(p!==void 0&&l.expectedRevision!==void 0&&l.expectedRevision!==p)throw new P;let w={...l,expectedRevision:l.expectedRevision??p};return(r.treeData?Q:J)(r.getRows(),w,r)},z=async(l,p,w,v,R)=>{if(!l.changed)return l;let b=s;if(b&&!Z(b))throw new Error("[MachTable] Save or discard edited rows before changing their order.");let G=++t;x=null;let j=new AbortController;o=j,i=null;let X=y(),Ne=d,F=null,K=[],me=!1,ne=!1,oe=X,ve=I=>{if(!R)return;if(!I||R!==h||R.api!==s){m(R);return}let D=O;R.restore(()=>{let se=D!==null&&D===O&&D.revision===y()&&W(R.api,D.nodes)&&H(r.getRows(),D.rows,A,r.treeData===!0)&&h===R&&!n&&t===R.generation&&s===R.api&&ue(R.api,k);return m(R),se})},L=()=>!n&&t===G,ie=()=>L()&&(!b||s===b&&!b.isDestroyed())&&F!==null&&y()===X&&W(b,K)&&H(r.getRows(),F,A,r.treeData===!0),Ge=I=>{if(!ie()){L()&&!F&&g({...e,status:"error",error:I,plan:l});return}let D=!b||Z(b),U=D?I:Object.assign(new Error("[MachTable] Row order could not be saved. Automatic rollback was skipped to preserve new edits. Save or discard those edits, then reload the row order."),{cause:I});if(D){i=null;try{r.applyRows(l.before),ne=!0}catch(se){U=Object.assign(new Error("[MachTable] Row order could not be saved or restored. Reload the row order before trying again."),{cause:I,rollbackError:se})}}L()&&(ne||E(),g({...e,status:I instanceof P?"conflict":"error",error:U}))},Fe=()=>{if(!L()){ve(!1);return}let I=y(),D=!1;me&&L()&&(I===X||I===oe)&&W(b,K)&&H(r.getRows(),F,A,r.treeData===!0)?(O={rows:F,nodes:K,api:b,revision:I},D=!0):ne&&L()?(O={rows:$(r.getRows(),A,r.treeData===!0),nodes:we(b),api:b,revision:I},D=H(r.getRows(),$(l.before,A,r.treeData===!0),A,r.treeData===!0)):E(),o===j&&(o=null,i=null,s&&!s.isDestroyed()&&s.view.refreshCells()),L()&&e.status==="saving"&&g({...e,status:"idle",plan:null}),M(),ve(D)};try{r.applyRows(l.after),F=$(r.getRows(),A,r.treeData===!0),K=we(b);let I=r.getRows(),D=K[0]?.node;if(i=b&&D?()=>!b.isDestroyed()&&b.rows.getById(D.id)===D:()=>r.getRows()===I,g({...e,status:"saving",error:null,plan:l}),!ie())return l;let U=nt(await Ee(Promise.resolve(r.save?.(l.intent,{signal:j.signal,plan:l,operation:p,operations:w})),j.signal));return ie()&&(me=!0,oe=U??X,d===Ne?f.commit(p,v):E(),g({...e,status:"saved",revision:oe})),l}catch(I){throw Ge(I),I}finally{Fe()}},ge=async(l,p)=>{p!==h&&(p=void 0),h!==p&&m();let w=N(l);w.changed||m(p);let v=w.changed?Ie(w,r,r.treeData===!0):[];return z(w,"move",[w.intent],{plan:w,inverse:v},p)},Pe=l=>ge(l),fe=async l=>{if(m(),M(),n||o)throw new Error("[MachTable] Row ordering is unavailable while disposed or saving.");let p=f.peek(l);if(!p)throw new Error(`[MachTable] Nothing to ${l}.`);let w=(l==="undo"?p.inverse:[p.plan.intent]).map(G=>({...G,expectedRevision:y()})),v=r.getRows(),R=l==="undo"?p.plan.before:p.plan.after;De(v,R,w,r,r.treeData===!0);let b={before:v,after:R,intent:w[0],rowIds:p.plan.rowIds,changed:!0};return z(b,l,w,p)},Le=l=>{try{if(n||o)return!1;let p=r.getRows(),w=y();if(w!==void 0&&l.expectedRevision!==void 0&&l.expectedRevision!==w)return!1;let v=x?.rowIds===l.rowIds?x.sources:JSON.stringify(l.rowIds.map(String));return(!x||x.rows!==p||x.revision!==w||x.sources!==v)&&(x={rows:p,revision:w,sources:v,rowIds:l.rowIds,validate:Te(p,l.rowIds,r,r.treeData===!0)}),x.rowIds=l.rowIds,x.validate(l),!0}catch(p){return p instanceof Error?p.message:!1}},ke=l=>{let p=l.intent;if(l.applied||!p)return;q(l.api);let w=t,v=h?.intent===p?h:void 0;Promise.resolve().then(()=>ge(Me(p),v)).catch(R=>{v&&v.generation!==t&&m(v),!n&&t===w&&e.status!=="saving"&&g({...e,status:R instanceof P?"conflict":"error",error:R})})},ye=l=>n?!1:(q(l),o?"Wait for the current row order to finish saving.":Z(l)||"Save or discard edited rows before changing their order.");return{get state(){return M(),e},bindings:{applyRowDrag:!1,rowDragPolicy:{canDrag:({api:l})=>ye(l),canDrop:({intent:l,api:p})=>{let w=ye(p);if(w!==!0)return w;try{return Le(Me(l))}catch(v){return v instanceof Error?v.message:!1}},getRevision:y},onRowDragEnd:ke},preview:N,move:Pe,undo:()=>fe("undo"),redo:()=>fe("redo"),subscribe(l){return n?()=>{}:(S.add(l),()=>{S.delete(l)})},dispose(){n=!0,t++,o?.abort(),o=null,i=null,a(),c(),m(),E(),s&&!s.isDestroyed()&&s.view.refreshCells(),s=null,x=null,S.clear(),e=Object.freeze({...e,status:"idle",error:null,plan:null,canUndo:!1,canRedo:!1})}}}0&&(module.exports={RowOrderConflictError,createRowOrderController,moveTreeNodes,reorderRows});
@@ -1,4 +1,4 @@
1
- import { c as GridOptions } from './api-DH2BoJ9I.cjs';
1
+ import { c as GridOptions } from './api-ChEKWrvH.cjs';
2
2
 
3
3
  /** Persist relative business IDs instead of viewport indexes or fractional ranks. */
4
4
  interface RowOrderIntent {
@@ -1,4 +1,4 @@
1
- import { c as GridOptions } from './api-DH2BoJ9I.js';
1
+ import { c as GridOptions } from './api-ChEKWrvH.js';
2
2
 
3
3
  /** Persist relative business IDs instead of viewport indexes or fractional ranks. */
4
4
  interface RowOrderIntent {
package/dist/ordering.js CHANGED
@@ -1 +1 @@
1
- var Ne=new Set(["__proto__","prototype","constructor"]),Y=new Map;function Ge(r){if(typeof r!="string"||r.length===0)return null;let t=Y.get(r);if(t!==void 0)return t;let e=r.split("."),n=e.every(o=>o.length>0&&!Ne.has(o))?e:null;return r.length<=1024&&(Y.size>=256&&Y.delete(Y.keys().next().value),Y.set(r,n)),n}function V(r,t){if(r==null)return;let e=Ge(t);if(!e)return;let n=r;for(let o of e){if(n==null)return;n=n[o]}return n}function Fe(r,t){let e=typeof t.rowKey=="function"?t.rowKey(r):V(r,t.rowKey);if(e==null||String(e).length===0)throw new Error("[MachTable] Row ordering requires a non-empty stable row key.");return String(e)}function He(r,t){let e=r[t];if(e==null)return[];if(!Array.isArray(e))throw new Error(`[MachTable] Tree ordering expects an array at "${t}".`);return e}function _(r,t,e,n){let o={entries:[],byId:new Map,byRow:new Map,children:new Map([[null,r]])},i=[...r].reverse().map(a=>({row:a,parentId:null,selectedAncestor:!1})),s=e.childrenKey??"children";for(;i.length;){let a=i.pop(),c=Fe(a.row,e);if(o.byId.has(c))throw new Error(`[MachTable] Row ordering found duplicate or cyclic row key "${c}".`);let d=n?He(a.row,s):[],w={...a,id:c,children:d};o.entries.push(w),o.byId.set(c,w),o.byRow.set(w.row,w),o.children.set(c,d);for(let f=d.length-1;f>=0;f--)i.push({row:d[f],parentId:c,selectedAncestor:a.selectedAncestor||t.has(c)})}return o}function qe(r){if(!["before","after","inside"].includes(r.position))throw new Error("[MachTable] Unknown row ordering position.");let t=[...new Set(r.rowIds.map(String))];if(!t.length)throw new Error("[MachTable] Row ordering requires at least one source row.");return{...r,rowIds:t,targetId:String(r.targetId)}}function ie(r,t){for(let n of t)if(!r.byId.has(n))throw new Error(`[MachTable] Ordering source "${n}" is unavailable.`);let e=new Set(t);return{selected:e,moved:r.entries.filter(n=>e.has(n.id)&&!n.selectedAncestor)}}function be(r,t,e,n){let o=r.byId.get(e.targetId);if(!o)throw new Error(`[MachTable] Ordering target "${e.targetId}" is unavailable.`);if(t.selected.has(o.id)||o.selectedAncestor)throw new Error("[MachTable] A row cannot be moved into or relative to its own subtree.");let i=e.position==="inside"?o.id:o.parentId,s=i===null?null:r.byId.get(i).row;if(n.canMove)for(let a of t.moved){let c=a.parentId===null?null:r.byId.get(a.parentId).row,d=n.canMove({row:a.row,previousParent:c,parent:s,target:o.row,intent:e});if(d===!1||typeof d=="string")throw new Error(typeof d=="string"?d:"[MachTable] This row cannot be moved to the selected parent.")}return i}function Re(r,t,e,n){let o=[...new Set(t.map(String))];if(!o.length)throw new Error("[MachTable] Row ordering requires at least one source row.");let i=_(r,new Set(o),e,n),s=ie(i,o);return a=>{if(!n&&a.position==="inside")throw new Error("[MachTable] Flat rows cannot have child destinations.");be(i,s,a,e)}}function Be(r,t,e,n){let o=new Set(t.map(d=>d.id)),i=new Map;for(let d of t)i.has(d.parentId)||i.set(d.parentId,r.children.get(d.parentId).filter(w=>!o.has(r.byRow.get(w).id)));let s=i.get(e)??r.children.get(e),a=s.findIndex(d=>d===r.byId.get(n.targetId).row),c=n.position==="inside"?s.length:a+ +(n.position==="after");return i.set(e,[...s.slice(0,c),...t.map(d=>d.row),...s.slice(c)]),i}function ve(r,t){return r.length===t.length&&r.every((e,n)=>e===t[n])}function Ke(r,t,e,n){let o=new Map,i=n.childrenKey??"children";for(let a=t.entries.length-1;a>=0;a--){let c=t.entries[a],w=(e.get(c.id)??c.children).map(f=>o.get(f)??f);ve(c.children,w)||o.set(c.row,{...c.row,[i]:w})}let s=(e.get(null)??r).map(a=>o.get(a)??a);return ve(r,s)?r:s}function Ue(r,t,e,n){let o=e.indexOf(t[0].row),i=o+t.length;return{...r,rowIds:t.map(s=>s.id),beforeId:o>0?n.byRow.get(e[o-1]).id:null,afterId:i<e.length?n.byRow.get(e[i]).id:null}}function Te(r,t,e){let n=_(r.before,new Set(r.rowIds),t,e),o=new Map;for(let i of n.children.values())i.forEach((s,a)=>o.set(n.byRow.get(s).id,a));return ie(n,r.rowIds).moved.reverse().map(i=>{let s=n.children.get(i.parentId),a=o.get(i.id),c=s[a+1];if(c)return{rowIds:[i.id],targetId:n.byRow.get(c).id,position:"before"};if(i.parentId!==null)return{rowIds:[i.id],targetId:i.parentId,position:"inside"};let d=s[a-1];if(!d)throw new Error("[MachTable] Row ordering cannot restore an isolated root.");return{rowIds:[i.id],targetId:n.byRow.get(d).id,position:"after"}})}function Ie(r,t,e,n,o){if(!n.canMove)return;let i=_(r,new Set,n,o),s=_(t,new Set,n,o);for(let a of e)for(let c of a.rowIds){let d=i.byId.get(c),w=s.byId.get(c),f=w.parentId===null?null:i.byId.get(w.parentId).row,O=d.parentId===null?null:i.byId.get(d.parentId).row,S=n.canMove({row:d.row,previousParent:O,parent:f,target:i.byId.get(a.targetId).row,intent:a});if(S===!1||typeof S=="string")throw new Error(typeof S=="string"?S:"[MachTable] This row cannot be restored to its previous parent.")}}function De(r,t,e,n){let o=qe(t);if(!n&&o.position==="inside")throw new Error("[MachTable] Flat rows cannot have child destinations.");let i=_(r,new Set(o.rowIds),e,n),{moved:s,selected:a}=ie(i,o.rowIds),c=be(i,{moved:s,selected:a},o,e),d=Be(i,s,c,o),w=Ke(r,i,d,e),f=Ue(o,s,d.get(c),i);return{before:r,after:w,intent:f,rowIds:f.rowIds,changed:r!==w}}function se(r,t,e){return De(r,t,e,!1)}function ae(r,t,e){return De(r,t,e,!0)}function le(r,t,e){let n=document.createElement(r);if(t&&(n.className=t),e)for(let o of Object.keys(e))n.setAttribute(o,e[o]);return n}function C(r,t,e){return r<t?t:r>e?e:r}var de=Symbol.for("mach-table.adapter.lifecycle.v1");function J(r){return!r.isDestroyed()&&(r[de]?.canReplaceData()??!1)}function ce(r,t){let e=r[de]?.rowDrag;return e?.original===t&&e.policy===r.getOption("rowDragPolicy")}function ue(r,t){let e=r[de];if(!e)return()=>{};e.rowDrag?.activeInteraction?.destroy();let n={original:t,policy:r.getOption("rowDragPolicy"),factory:o=>(n.activeInteraction=t(o),n.activeInteraction)};return e.rowDrag=n,()=>{n.activeInteraction?.destroy(),e.rowDrag===n&&(e.rowDrag=void 0)}}function Ye(r,t){if(r instanceof Error)return r;let e=new Error(typeof r=="string"?r:t);return e.name="AbortError",e}var _e=()=>Ye(void 0,"[MachTable] Operation cancelled.");function Oe(r,t,e=_e){return t?new Promise((n,o)=>{let i=()=>{t.removeEventListener("abort",i),o(e())};if(r.then(n,o).finally(()=>t.removeEventListener("abort",i)),t.aborted){i();return}t.addEventListener("abort",i,{once:!0})}):r}function pe(r,t,e){return r.replace("{a}",String(t)).replace("{b}",String(e))}function $e(r,t,e){return r&&t>.25&&t<.75?"inside":e}function xe(r,t){let e=0,n=r.length;for(;e<n;){let o=e+n>>>1;r[o]<t?e=o+1:n=o}return e}function We(r,t,e,n,o,i){let s=r.getOption("locale")??{},a=t>1?pe(s.rowDragSelection??"\u5DF2\u9009 {a} \u884C \u2192 \u7B2C {b} \u884C",t,n+1):pe(s.rowDragPosition??"\u7B2C {a} \u884C \u2192 \u7B2C {b} \u884C",e+1,n+1),c=o==="inside"?s.rowDragInside??"\u79FB\u5165":o==="before"?s.rowDragBefore??"\u4E4B\u524D":s.rowDragAfter??"\u4E4B\u540E";return{text:`${a} \xB7 ${c}`,indicatorStyle:o==="inside"?`height:${i}px;background:color-mix(in srgb,var(--mach-primary) 12%,transparent);box-shadow:inset 0 0 0 1px var(--mach-primary)`:void 0}}function ze(r,t,e){let n={parents:new Map,siblings:new Map([[null,[]]]),depths:new Map},o=[...r].reverse().map(s=>({row:s,parent:null,depth:0})),i=t.childrenKey??"children";for(;o.length;){let{row:s,parent:a,depth:c}=o.pop(),d=String(typeof t.rowKey=="function"?t.rowKey(s):V(s,t.rowKey));if(n.depths.has(d))throw new Error("[MachTable] Row ordering requires unique, acyclic row keys.");n.depths.set(d,c),n.siblings.get(a).push(d),n.siblings.set(d,[]),a!==null&&n.parents.set(d,a);let w=e?s[i]:void 0;if(w!=null&&!Array.isArray(w))throw new Error("[MachTable] Row ordering children must be an array.");for(let f=(w?.length??0)-1;f>=0;f--)o.push({row:w[f],parent:d,depth:c+1})}return n}function Ee(r,t,e,n,o,i){let s=new Map;r.rows.forEach(u=>{!u.loading&&!u.isDetail&&!u.isGroup&&u.data!=null&&s.set(u.id,u)});let a=ze(e,n,o),c=new Set(t.selected?[...a.depths.keys()].filter(u=>s.get(u)?.selected):[t.id]),d=[...c],w=u=>{let g=u;for(;g!==void 0;){if(c.has(g))return!0;g=a.parents.get(g)}return!1},f=new Map,O=new Map;for(let[u,g]of a.siblings){let y=g.filter(m=>!c.has(m));f.set(u,y),y.forEach((m,T)=>O.set(m,T))}let S=new Map,A=new Set,x=[],E=[],q=0;r.rows.forEachDisplayed(u=>{A.add(u.id),w(u.id)&&x.push(u.rowIndex),q=u.rowIndex+1;let g=a.depths.get(u.id)??0;for(;E.length&&(a.depths.get(E[E.length-1].id)??0)>=g;)S.set(E.pop().id,u.rowIndex);a.siblings.get(u.id)?.length&&E.push(u)});for(let u of E)S.set(u.id,q);return{rowIds:d,isSource:w,validate:()=>{for(let u of d){let g=s.get(u);if(g.treeLoading)return!1;let y=r.getOption("rowDragPolicy")?.canDrag?.({node:g,api:r});if(y===!1||typeof y=="string")return y}return!0},resolve:({targetNode:u,position:g,fraction:y,height:m})=>{let T=$e(o,y,g);if(w(u.id))return"Cannot target own subtree.";if(!o&&T==="inside")return!1;let k=T==="inside"?u.id:a.parents.get(u.id)??null,M=f.get(k)??[],B=T==="inside"?M.length:(O.get(u.id)??0)+ +(T==="after"),N=T==="before"?u.rowIndex:S.get(u.id)??u.rowIndex+1,z=N-xe(x,N)+xe(x,t.rowIndex);return{intent:{rowIds:d,targetId:u.id,position:T,beforeId:M[B-1]??null,afterId:M[B]??null,expectedRevision:i},indicatorIndex:T==="inside"?u.rowIndex:T==="after"?S.get(u.id):void 0,toIndex:N,targetIndex:z,...We(r,d.length,t.rowIndex,u.rowIndex,T,m)}},keyboardTarget:u=>{let g=t.id;for(;c.has(a.parents.get(g)??"");)g=a.parents.get(g);let y=a.siblings.get(a.parents.get(g)??null)??[],m=y.indexOf(g)+u;for(;m>=0&&m<y.length;){let T=y[m];if(!w(T)&&A.has(T)&&s.has(T))return s.get(T);m+=u}}}}var Q=class{constructor(t){this.host=t;this.e=null;this.n=0;this.o=0;this.l=t=>{let e=this.e;if(!(!e||t.pointerId!==e.pointerId)){if(e.clientX=t.clientX,e.clientY=t.clientY,!e.active){if(Math.abs(t.clientY-e.startY)<5)return;e.active=!0,this.host.root.classList.add("mach-root--row-dragging"),this.host.root.querySelectorAll(".mach-row").forEach(n=>n.classList.toggle("mach-row--drag-source",this.sourceContains(n.dataset.id??"")))}this.u()}};this.m=()=>{if(this.n=0,!!this.e?.active){if(!this.current()){this.destroy();return}this.p(),this.y()&&this.u()}};this.d=t=>{let e=this.e;if(!(!e||t.pointerId!==e.pointerId)){e.clientX=t.clientX,e.clientY=t.clientY,e.active&&this.current()&&this.p(),this.h();try{e.active&&e.drop?.valid&&this.s(t.clientX,t.clientY)&&this.current()&&this.commitDrop(e.drop)}finally{this.release()}}};this.c=t=>{t.key==="Escape"&&(t.preventDefault(),this.destroy())};this.i=t=>{t.type==="pointercancel"&&t.pointerId!==this.e?.pointerId||this.destroy()}}begin(t){let e=this.host.containers.map(o=>{let i=le("div","mach-row-drop-indicator");return i.hidden=!0,o.append(i),i}),n=le("div","mach-row-drag-preview");n.setAttribute("role","status"),n.hidden=!0,this.host.root.append(n),this.e={startY:t.clientY,clientX:t.clientX,clientY:t.clientY,pointerId:t.pointerId,indicators:e,preview:n,drop:null,active:!1},window.addEventListener("pointermove",this.l),window.addEventListener("pointerup",this.d),window.addEventListener("pointercancel",this.i),window.addEventListener("keydown",this.c),window.addEventListener("blur",this.i)}g(t){return this.e?.active===!0&&this.sourceContains(t)}f(t,e=()=>!0){this.o=requestAnimationFrame(()=>{this.o=0,e()&&[...this.host.root.querySelectorAll(".mach-row-drag-handle")].find(n=>n.closest(".mach-row")?.dataset.id===t)?.focus()})}u(){this.n||(this.n=requestAnimationFrame(this.m))}s(t,e,n=0){let o=this.host.body.getBoundingClientRect();return t>=o.left&&t<=o.right&&e>=o.top-n&&e<=o.bottom+n}y(){let t=this.e;if(!t||!this.s(t.clientX,t.clientY,28))return!1;let e=this.host.viewport,n=e.getBoundingClientRect(),o=Math.min(36,n.height/3);if(o<=0)return!1;let i=t.clientY<n.top+o?-Math.ceil(14*C((n.top+o-t.clientY)/o,0,1)):Math.ceil(14*C((t.clientY-n.bottom+o)/o,0,1));if(this.host.scrollBy)return this.host.scrollBy(i);let s=e.scrollTop;return e.scrollTop=C(s+i,0,Math.max(0,e.scrollHeight-e.clientHeight)),e.scrollTop!==s}p(){let t=this.e;if(!t?.active)return;let e=t.clientY-this.host.viewport.getBoundingClientRect().top+this.host.viewport.scrollTop,n=this.describe(e);t.drop=n;let o=this.s(t.clientX,t.clientY);for(let s of t.indicators){if(s.hidden=!o||!n?.valid,!n)continue;s.dataset.dropPosition=n.position??"",s.style.cssText=n.style??"";let a=parseFloat(s.parentElement.style.height),c=Math.min(this.host.getRowTop(n.boundary),Number.isFinite(a)?Math.max(0,a-2):1/0);s.style.transform=`translate3d(0, ${c}px, 0)`}let i=this.host.root.getBoundingClientRect();t.preview.hidden=!1,t.preview.textContent=o?n?.text??this.outsideText():this.outsideText(),t.preview.style.transform=`translate3d(${C(t.clientX-i.left+16,8,Math.max(8,i.width-224))}px, ${C(t.clientY-i.top+16,8,Math.max(8,i.height-48))}px, 0)`}h(){let t=this.e;this.e=null,window.removeEventListener("pointermove",this.l),window.removeEventListener("pointerup",this.d),window.removeEventListener("pointercancel",this.i),window.removeEventListener("keydown",this.c),window.removeEventListener("blur",this.i),cancelAnimationFrame(this.n),this.n=0,this.host.root?.classList.remove("mach-root--row-dragging"),this.host.root?.querySelectorAll(".mach-row--drag-source").forEach(e=>e.classList.remove("mach-row--drag-source")),t?.indicators.forEach(e=>e.remove()),t?.preview.remove()}destroy(){this.h(),this.release(),cancelAnimationFrame(this.o),this.o=0}};var Z=class extends Q{constructor(e,n,o){super(e);this.t=e;this.prepare=n;this.v=o;this.scope=null;this.a=!1}r(e,n,o){try{return n()}catch(i){return this.scope&&(this.scope.failed=!0),this.t.report(i,e),o}}w(e){return this.r("prepare",()=>{let n=this.t.capture(e),o=this.prepare(e);return this.scope={node:e,from:e.rowIndex,guard:n,session:o,sourceDecision:!0,failed:!1},this.scope.sourceDecision=o.validate(),this.scope},null)}start(e,n){this.destroy(),this.w(n)&&this.current()&&this.begin(e)}moveWithKeyboard(e,n){this.destroy();let o=this.w(n);if(!(!o||!this.current())){this.a=!0;try{let i=e.key==="ArrowUp"?-1:1,s=this.r("keyboardTarget",()=>o.session.keyboardTarget(i),void 0);s&&this.commitDrop(this.destination(s,i<0?0:1))}finally{this.a=!1,this.release()}}}isSource(e){return this.g(e.id)}current(){return!!(this.scope&&!this.scope.failed&&this.scope.guard.current()&&this.t.api.rows.getById(this.scope.node.id)===this.scope.node)}sourceContains(e){return this.r("isSource",()=>this.scope?.session.isSource(e)??!1,!1)}release(){this.scope=null}outsideText(){return this.t.api.getOption("locale")?.rowDragOutside??"\u79FB\u56DE\u8868\u683C\u5185\u653E\u7F6E \xB7 Esc \u53D6\u6D88"}describe(e){let n=this.t.api,o=C(this.host.findRowAt(e),0,n.rows.getCount()-1),i=n.rows.getAt(o);if(i?.isDetail&&(i=n.rows.getById(i.masterId)),!i)return null;let s=this.host.getRowTop(i.rowIndex),a=this.host.getRowTop(i.rowIndex+1)-s;return this.destination(i,(e-s)/Math.max(1,a))}destination(e,n){let o=this.scope,i=n<.5?"before":"after",s=this.host.getRowTop(e.rowIndex+1)-this.host.getRowTop(e.rowIndex),a=this.r("resolve",()=>o.session.resolve({targetNode:e,position:i,fraction:n,height:s}),!1),c=typeof o.sourceDecision=="string"?o.sourceDecision:typeof a=="string"?a:"\u6B64\u4F4D\u7F6E\u4E0D\u53EF\u653E\u7F6E",d={node:e,fraction:n,boundary:e.rowIndex,valid:!1,text:c};if(!a||typeof a=="string"||o.sourceDecision!==!0||e.loading||e.treeLoading||e.isGroup)return d;d.intent=a.intent,d.position=a.intent.position,d.toIndex=a.toIndex,d.targetIndex=a.targetIndex,d.boundary=a.indicatorIndex??e.rowIndex+ +(a.intent.position==="after"),d.style=a.indicatorStyle,d.text=a.text??c;let w=this.r("canDrop",()=>this.t.api.getOption("rowDragPolicy")?.canDrop?.({node:o.node,api:this.t.api,targetNode:e,intent:a.intent})??!0,!1);return d.valid=w===!0,typeof w=="string"&&(d.text=w),d}commitDrop(e){let n=this.scope;if(!n||!this.current()||this.r("validate",()=>n.session.validate(),!1)!==!0||!this.current())return!1;let o=this.destination(e.node,e.fraction);return!o.valid||!o.intent||!this.current()?!1:(this.a&&this.v(o.intent,i=>this.f(n.node.id,i)),this.t.emit(n.node,n.from,o.toIndex,o.targetIndex,o.intent),!0)}};function $(r,t,e){let n=[],o=[...r].reverse().map(s=>({row:s,parent:null})),i=new Set;for(;o.length;){let s=o.pop();if(i.has(s.row))throw new Error("[MachTable] Installed order contains duplicate or cyclic rows.");i.add(s.row),n.push(s);let a=e?s.row[t]??[]:[];for(let c=a.length-1;c>=0;c--)o.push({row:a[c],parent:s.row})}return n}function H(r,t,e,n){try{let o=$(r,e,n);return o.length===t.length&&o.every((i,s)=>i.row===t[s].row&&i.parent===t[s].parent)}catch{return!1}}function we(r){let t=[];return r?.rows.forEach(e=>t.push({node:e,data:e.data})),t}function W(r,t){if(!r)return!0;if(r.isDestroyed())return!1;let e=0,n=!0;return r.rows.forEach(o=>{let i=t[e++];(i?.node!==o||i.data!==o.data)&&(n=!1)}),n&&e===t.length}var ee=class{constructor(){this.entries=[];this.cursor=0}get canUndo(){return this.cursor>0}get canRedo(){return this.cursor<this.entries.length}peek(t){return this.entries[t==="undo"?this.cursor-1:this.cursor]}commit(t,e){t==="undo"?this.cursor--:t==="redo"?this.cursor++:(this.entries.splice(this.cursor),this.entries.push(e),this.entries.length>50&&this.entries.shift(),this.cursor=this.entries.length)}clear(){this.entries=[],this.cursor=0}};var P=class extends Error{constructor(e="The row order changed on the server. Reload before trying again.",n){super(e);this.serverRevision=n;this.name="RowOrderConflictError"}};function je(r){if(r?.status==="conflict")throw new P(r.message,r.revision);return r?.revision}function Se(r){if(r.targetId===null)throw new Error("[MachTable] Row ordering requires an existing destination.");return{...r,targetId:r.targetId}}function Xe(r){let t={status:"idle",error:null,revision:r.getRevision?.(),plan:null,canUndo:!1,canRedo:!1},e=0,n=!1,o=null,i=null,s=null,a=()=>{},c=()=>{},d=0,w=null,f=new ee,O=null,S=new Set,A=r.childrenKey??"children",x=null,E=()=>{f.clear(),O=null},q=()=>{if(!o)return!1;let l=o;return e++,o=null,i=null,l.abort(),!0},u=(l=t.status)=>({canUndo:!n&&l!=="saving"&&f.canUndo,canRedo:!n&&l!=="saving"&&f.canRedo}),g=l=>{t=Object.freeze({...l,...u(l.status)}),s&&!s.isDestroyed()&&s.view.refreshCells();let p=[h=>r.onStateChange?.(h),...S];for(let h of p)try{h?.(t)}catch(v){console.error("[MachTable] Row order state observer failed",v)}},y=()=>r.getRevision?.()??t.revision,m=(l=w)=>{l?.release(),w===l&&(w=null)},T=()=>{!i||i()||(q(),E(),m(),g({...t,status:"idle",plan:null,error:null}))},k=l=>new Z(l,p=>Ee(l.api,p,r.getRows(),r,r.treeData===!0,y()),(p,h)=>{m();let v=document.activeElement,R=G=>{G.target!==v&&G.target!==document.body&&m(b)},b={api:l.api,intent:p,restore:h,generation:e+1,release:()=>document.removeEventListener("focusin",R,!0)};w=b,document.addEventListener("focusin",R,!0)}),M=()=>{T(),!o&&O&&(O.api!==s||O.revision!==y()||!W(s,O.nodes)||!H(r.getRows(),O.rows,A,r.treeData===!0))&&E();let l=u();(t.canUndo!==l.canUndo||t.canRedo!==l.canRedo)&&(t=Object.freeze({...t,...l}))},B=l=>{if(l===s){T(),ce(l,k)||(c(),c=ue(l,k));return}let p=q();a(),c(),m(),E(),s=l,c=ue(l,k),a=l.on("cellValueChanged",()=>{d++;let h=f.canUndo||f.canRedo;E(),h&&g({...t,status:o?"saving":"idle",plan:o?t.plan:null,error:null})}),p&&g({...t,status:"idle",plan:null,error:null})},N=l=>{if(M(),n)throw new Error("[MachTable] The row order controller is disposed.");if(o)throw new Error("[MachTable] A row order save is already in progress.");let p=y();if(p!==void 0&&l.expectedRevision!==void 0&&l.expectedRevision!==p)throw new P;let h={...l,expectedRevision:l.expectedRevision??p};return(r.treeData?ae:se)(r.getRows(),h,r)},z=async(l,p,h,v,R)=>{if(!l.changed)return l;let b=s;if(b&&!J(b))throw new Error("[MachTable] Save or discard edited rows before changing their order.");let G=++e;x=null;let j=new AbortController;o=j,i=null;let X=y(),Le=d,F=null,K=[],ye=!1,te=!1,re=X,me=I=>{if(!R)return;if(!I||R!==w||R.api!==s){m(R);return}let D=O;R.restore(()=>{let oe=D!==null&&D===O&&D.revision===y()&&W(R.api,D.nodes)&&H(r.getRows(),D.rows,A,r.treeData===!0)&&w===R&&!n&&e===R.generation&&s===R.api&&ce(R.api,k);return m(R),oe})},L=()=>!n&&e===G,ne=()=>L()&&(!b||s===b&&!b.isDestroyed())&&F!==null&&y()===X&&W(b,K)&&H(r.getRows(),F,A,r.treeData===!0),Pe=I=>{if(!ne()){L()&&!F&&g({...t,status:"error",error:I,plan:l});return}let D=!b||J(b),U=D?I:Object.assign(new Error("[MachTable] Row order could not be saved. Automatic rollback was skipped to preserve new edits. Save or discard those edits, then reload the row order."),{cause:I});if(D){i=null;try{r.applyRows(l.before),te=!0}catch(oe){U=Object.assign(new Error("[MachTable] Row order could not be saved or restored. Reload the row order before trying again."),{cause:I,rollbackError:oe})}}L()&&(te||E(),g({...t,status:I instanceof P?"conflict":"error",error:U}))},ke=()=>{if(!L()){me(!1);return}let I=y(),D=!1;ye&&L()&&(I===X||I===re)&&W(b,K)&&H(r.getRows(),F,A,r.treeData===!0)?(O={rows:F,nodes:K,api:b,revision:I},D=!0):te&&L()?(O={rows:$(r.getRows(),A,r.treeData===!0),nodes:we(b),api:b,revision:I},D=H(r.getRows(),$(l.before,A,r.treeData===!0),A,r.treeData===!0)):E(),o===j&&(o=null,i=null,s&&!s.isDestroyed()&&s.view.refreshCells()),L()&&t.status==="saving"&&g({...t,status:"idle",plan:null}),M(),me(D)};try{r.applyRows(l.after),F=$(r.getRows(),A,r.treeData===!0),K=we(b);let I=r.getRows(),D=K[0]?.node;if(i=b&&D?()=>!b.isDestroyed()&&b.rows.getById(D.id)===D:()=>r.getRows()===I,g({...t,status:"saving",error:null,plan:l}),!ne())return l;let U=je(await Oe(Promise.resolve(r.save?.(l.intent,{signal:j.signal,plan:l,operation:p,operations:h})),j.signal));return ne()&&(ye=!0,re=U??X,d===Le?f.commit(p,v):E(),g({...t,status:"saved",revision:re})),l}catch(I){throw Pe(I),I}finally{ke()}},he=async(l,p)=>{p!==w&&(p=void 0),w!==p&&m();let h=N(l);h.changed||m(p);let v=h.changed?Te(h,r,r.treeData===!0):[];return z(h,"move",[h.intent],{plan:h,inverse:v},p)},Ae=l=>he(l),ge=async l=>{if(m(),M(),n||o)throw new Error("[MachTable] Row ordering is unavailable while disposed or saving.");let p=f.peek(l);if(!p)throw new Error(`[MachTable] Nothing to ${l}.`);let h=(l==="undo"?p.inverse:[p.plan.intent]).map(G=>({...G,expectedRevision:y()})),v=r.getRows(),R=l==="undo"?p.plan.before:p.plan.after;Ie(v,R,h,r,r.treeData===!0);let b={before:v,after:R,intent:h[0],rowIds:p.plan.rowIds,changed:!0};return z(b,l,h,p)},Me=l=>{try{if(n||o)return!1;let p=r.getRows(),h=y();if(h!==void 0&&l.expectedRevision!==void 0&&l.expectedRevision!==h)return!1;let v=x?.rowIds===l.rowIds?x.sources:JSON.stringify(l.rowIds.map(String));return(!x||x.rows!==p||x.revision!==h||x.sources!==v)&&(x={rows:p,revision:h,sources:v,rowIds:l.rowIds,validate:Re(p,l.rowIds,r,r.treeData===!0)}),x.rowIds=l.rowIds,x.validate(l),!0}catch(p){return p instanceof Error?p.message:!1}},Ce=l=>{let p=l.intent;if(l.applied||!p)return;B(l.api);let h=e,v=w?.intent===p?w:void 0;Promise.resolve().then(()=>he(Se(p),v)).catch(R=>{v&&v.generation!==e&&m(v),!n&&e===h&&t.status!=="saving"&&g({...t,status:R instanceof P?"conflict":"error",error:R})})},fe=l=>n?!1:(B(l),o?"Wait for the current row order to finish saving.":J(l)||"Save or discard edited rows before changing their order.");return{get state(){return M(),t},bindings:{applyRowDrag:!1,rowDragPolicy:{canDrag:({api:l})=>fe(l),canDrop:({intent:l,api:p})=>{let h=fe(p);if(h!==!0)return h;try{return Me(Se(l))}catch(v){return v instanceof Error?v.message:!1}},getRevision:y},onRowDragEnd:Ce},preview:N,move:Ae,undo:()=>ge("undo"),redo:()=>ge("redo"),subscribe(l){return n?()=>{}:(S.add(l),()=>{S.delete(l)})},dispose(){n=!0,e++,o?.abort(),o=null,i=null,a(),c(),m(),E(),s&&!s.isDestroyed()&&s.view.refreshCells(),s=null,x=null,S.clear(),t=Object.freeze({...t,status:"idle",error:null,plan:null,canUndo:!1,canRedo:!1})}}}export{P as RowOrderConflictError,Xe as createRowOrderController,ae as moveTreeNodes,se as reorderRows};
1
+ var Ge=new Set(["__proto__","prototype","constructor"]),Y=new Map;function Fe(r){if(typeof r!="string"||r.length===0)return null;let e=Y.get(r);if(e!==void 0)return e;let t=r.split("."),n=t.every(o=>o.length>0&&!Ge.has(o))?t:null;return r.length<=1024&&(Y.size>=256&&Y.delete(Y.keys().next().value),Y.set(r,n)),n}function V(r,e){if(r==null)return;let t=Fe(e);if(!t)return;let n=r;for(let o of t){if(n==null)return;n=n[o]}return n}function He(r,e){let t=typeof e.rowKey=="function"?e.rowKey(r):V(r,e.rowKey);if(t==null||String(t).length===0)throw new Error("[MachTable] Row ordering requires a non-empty stable row key.");return String(t)}function Be(r,e){let t=r[e];if(t==null)return[];if(!Array.isArray(t))throw new Error(`[MachTable] Tree ordering expects an array at "${e}".`);return t}function _(r,e,t,n){let o={entries:[],byId:new Map,byRow:new Map,children:new Map([[null,r]])},i=[...r].reverse().map(a=>({row:a,parentId:null,selectedAncestor:!1})),s=t.childrenKey??"children";for(;i.length;){let a=i.pop(),c=He(a.row,t);if(o.byId.has(c))throw new Error(`[MachTable] Row ordering found duplicate or cyclic row key "${c}".`);let d=n?Be(a.row,s):[],h={...a,id:c,children:d};o.entries.push(h),o.byId.set(c,h),o.byRow.set(h.row,h),o.children.set(c,d);for(let f=d.length-1;f>=0;f--)i.push({row:d[f],parentId:c,selectedAncestor:a.selectedAncestor||e.has(c)})}return o}function qe(r){if(!["before","after","inside"].includes(r.position))throw new Error("[MachTable] Unknown row ordering position.");let e=[...new Set(r.rowIds.map(String))];if(!e.length)throw new Error("[MachTable] Row ordering requires at least one source row.");return{...r,rowIds:e,targetId:String(r.targetId)}}function ie(r,e){for(let n of e)if(!r.byId.has(n))throw new Error(`[MachTable] Ordering source "${n}" is unavailable.`);let t=new Set(e);return{selected:t,moved:r.entries.filter(n=>t.has(n.id)&&!n.selectedAncestor)}}function be(r,e,t,n){let o=r.byId.get(t.targetId);if(!o)throw new Error(`[MachTable] Ordering target "${t.targetId}" is unavailable.`);if(e.selected.has(o.id)||o.selectedAncestor)throw new Error("[MachTable] A row cannot be moved into or relative to its own subtree.");let i=t.position==="inside"?o.id:o.parentId,s=i===null?null:r.byId.get(i).row;if(n.canMove)for(let a of e.moved){let c=a.parentId===null?null:r.byId.get(a.parentId).row,d=n.canMove({row:a.row,previousParent:c,parent:s,target:o.row,intent:t});if(d===!1||typeof d=="string")throw new Error(typeof d=="string"?d:"[MachTable] This row cannot be moved to the selected parent.")}return i}function Re(r,e,t,n){let o=[...new Set(e.map(String))];if(!o.length)throw new Error("[MachTable] Row ordering requires at least one source row.");let i=_(r,new Set(o),t,n),s=ie(i,o);return a=>{if(!n&&a.position==="inside")throw new Error("[MachTable] Flat rows cannot have child destinations.");be(i,s,a,t)}}function Ke(r,e,t,n){let o=new Set(e.map(d=>d.id)),i=new Map;for(let d of e)i.has(d.parentId)||i.set(d.parentId,r.children.get(d.parentId).filter(h=>!o.has(r.byRow.get(h).id)));let s=i.get(t)??r.children.get(t),a=s.findIndex(d=>d===r.byId.get(n.targetId).row),c=n.position==="inside"?s.length:a+ +(n.position==="after");return i.set(t,[...s.slice(0,c),...e.map(d=>d.row),...s.slice(c)]),i}function ve(r,e){return r.length===e.length&&r.every((t,n)=>t===e[n])}function Ue(r,e,t,n){let o=new Map,i=n.childrenKey??"children";for(let a=e.entries.length-1;a>=0;a--){let c=e.entries[a],h=(t.get(c.id)??c.children).map(f=>o.get(f)??f);ve(c.children,h)||o.set(c.row,{...c.row,[i]:h})}let s=(t.get(null)??r).map(a=>o.get(a)??a);return ve(r,s)?r:s}function Ye(r,e,t,n){let o=t.indexOf(e[0].row),i=o+e.length;return{...r,rowIds:e.map(s=>s.id),beforeId:o>0?n.byRow.get(t[o-1]).id:null,afterId:i<t.length?n.byRow.get(t[i]).id:null}}function Te(r,e,t){let n=_(r.before,new Set(r.rowIds),e,t),o=new Map;for(let i of n.children.values())i.forEach((s,a)=>o.set(n.byRow.get(s).id,a));return ie(n,r.rowIds).moved.reverse().map(i=>{let s=n.children.get(i.parentId),a=o.get(i.id),c=s[a+1];if(c)return{rowIds:[i.id],targetId:n.byRow.get(c).id,position:"before"};if(i.parentId!==null)return{rowIds:[i.id],targetId:i.parentId,position:"inside"};let d=s[a-1];if(!d)throw new Error("[MachTable] Row ordering cannot restore an isolated root.");return{rowIds:[i.id],targetId:n.byRow.get(d).id,position:"after"}})}function Ie(r,e,t,n,o){if(!n.canMove)return;let i=_(r,new Set,n,o),s=_(e,new Set,n,o);for(let a of t)for(let c of a.rowIds){let d=i.byId.get(c),h=s.byId.get(c),f=h.parentId===null?null:i.byId.get(h.parentId).row,O=d.parentId===null?null:i.byId.get(d.parentId).row,S=n.canMove({row:d.row,previousParent:O,parent:f,target:i.byId.get(a.targetId).row,intent:a});if(S===!1||typeof S=="string")throw new Error(typeof S=="string"?S:"[MachTable] This row cannot be restored to its previous parent.")}}function De(r,e,t,n){let o=qe(e);if(!n&&o.position==="inside")throw new Error("[MachTable] Flat rows cannot have child destinations.");let i=_(r,new Set(o.rowIds),t,n),{moved:s,selected:a}=ie(i,o.rowIds),c=be(i,{moved:s,selected:a},o,t),d=Ke(i,s,c,o),h=Ue(r,i,d,t),f=Ye(o,s,d.get(c),i);return{before:r,after:h,intent:f,rowIds:f.rowIds,changed:r!==h}}function se(r,e,t){return De(r,e,t,!1)}function ae(r,e,t){return De(r,e,t,!0)}function le(r,e,t){let n=document.createElement(r);if(e&&(n.className=e),t)for(let o of Object.keys(t))n.setAttribute(o,t[o]);return n}function Oe(r,e,t,n=!1){let o=e?"addEventListener":"removeEventListener";for(let[i,s]of Object.entries(t))r[o](i,s,n)}function C(r,e,t){return r<e?e:r>t?t:r}var de=Symbol.for("mach-table.adapter.lifecycle.v1");function J(r){return!r.isDestroyed()&&(r[de]?.canReplaceData()??!1)}function ce(r,e){let t=r[de]?.rowDrag;return t?.original===e&&t.policy===r.getOption("rowDragPolicy")}function ue(r,e){let t=r[de];if(!t)return()=>{};t.rowDrag?.activeInteraction?.destroy();let n={original:e,policy:r.getOption("rowDragPolicy"),factory:o=>(n.activeInteraction=e(o),n.activeInteraction)};return t.rowDrag=n,()=>{n.activeInteraction?.destroy(),t.rowDrag===n&&(t.rowDrag=void 0)}}function _e(r,e){if(r instanceof Error)return r;let t=new Error(typeof r=="string"?r:e);return t.name="AbortError",t}var $e=()=>_e(void 0,"[MachTable] Operation cancelled.");function xe(r,e,t=$e){return e?new Promise((n,o)=>{let i=()=>{e.removeEventListener("abort",i),o(t())};if(r.then(n,o).finally(()=>e.removeEventListener("abort",i)),e.aborted){i();return}e.addEventListener("abort",i,{once:!0})}):r}function pe(r,e,t){return r.replace("{a}",String(e)).replace("{b}",String(t))}function We(r,e,t){return r&&e>.25&&e<.75?"inside":t}function Ee(r,e){let t=0,n=r.length;for(;t<n;){let o=t+n>>>1;r[o]<e?t=o+1:n=o}return t}function ze(r,e,t,n,o,i){let s=r.getOption("locale")??{},a=e>1?pe(s.rowDragSelection??"\u5DF2\u9009 {a} \u884C \u2192 \u7B2C {b} \u884C",e,n+1):pe(s.rowDragPosition??"\u7B2C {a} \u884C \u2192 \u7B2C {b} \u884C",t+1,n+1),c=o==="inside"?s.rowDragInside??"\u79FB\u5165":o==="before"?s.rowDragBefore??"\u4E4B\u524D":s.rowDragAfter??"\u4E4B\u540E";return{text:`${a} \xB7 ${c}`,indicatorStyle:o==="inside"?`height:${i}px;background:color-mix(in srgb,var(--mach-primary) 12%,transparent);box-shadow:inset 0 0 0 1px var(--mach-primary)`:void 0}}function je(r,e,t){let n={parents:new Map,siblings:new Map([[null,[]]]),depths:new Map},o=[...r].reverse().map(s=>({row:s,parent:null,depth:0})),i=e.childrenKey??"children";for(;o.length;){let{row:s,parent:a,depth:c}=o.pop(),d=String(typeof e.rowKey=="function"?e.rowKey(s):V(s,e.rowKey));if(n.depths.has(d))throw new Error("[MachTable] Row ordering requires unique, acyclic row keys.");n.depths.set(d,c),n.siblings.get(a).push(d),n.siblings.set(d,[]),a!==null&&n.parents.set(d,a);let h=t?s[i]:void 0;if(h!=null&&!Array.isArray(h))throw new Error("[MachTable] Row ordering children must be an array.");for(let f=(h?.length??0)-1;f>=0;f--)o.push({row:h[f],parent:d,depth:c+1})}return n}function Se(r,e,t,n,o,i){let s=new Map;r.rows.forEach(u=>{!u.loading&&!u.isDetail&&!u.isGroup&&u.data!=null&&s.set(u.id,u)});let a=je(t,n,o),c=new Set(e.selected?[...a.depths.keys()].filter(u=>s.get(u)?.selected):[e.id]),d=[...c],h=u=>{let g=u;for(;g!==void 0;){if(c.has(g))return!0;g=a.parents.get(g)}return!1},f=new Map,O=new Map;for(let[u,g]of a.siblings){let y=g.filter(m=>!c.has(m));f.set(u,y),y.forEach((m,T)=>O.set(m,T))}let S=new Map,A=new Set,x=[],E=[],B=0;r.rows.forEachDisplayed(u=>{A.add(u.id),h(u.id)&&x.push(u.rowIndex),B=u.rowIndex+1;let g=a.depths.get(u.id)??0;for(;E.length&&(a.depths.get(E[E.length-1].id)??0)>=g;)S.set(E.pop().id,u.rowIndex);a.siblings.get(u.id)?.length&&E.push(u)});for(let u of E)S.set(u.id,B);return{rowIds:d,isSource:h,validate:()=>{for(let u of d){let g=s.get(u);if(g.treeLoading)return!1;let y=r.getOption("rowDragPolicy")?.canDrag?.({node:g,api:r});if(y===!1||typeof y=="string")return y}return!0},resolve:({targetNode:u,position:g,fraction:y,height:m})=>{let T=We(o,y,g);if(h(u.id))return"Cannot target own subtree.";if(!o&&T==="inside")return!1;let k=T==="inside"?u.id:a.parents.get(u.id)??null,M=f.get(k)??[],q=T==="inside"?M.length:(O.get(u.id)??0)+ +(T==="after"),N=T==="before"?u.rowIndex:S.get(u.id)??u.rowIndex+1,z=N-Ee(x,N)+Ee(x,e.rowIndex);return{intent:{rowIds:d,targetId:u.id,position:T,beforeId:M[q-1]??null,afterId:M[q]??null,expectedRevision:i},indicatorIndex:T==="inside"?u.rowIndex:T==="after"?S.get(u.id):void 0,toIndex:N,targetIndex:z,...ze(r,d.length,e.rowIndex,u.rowIndex,T,m)}},keyboardTarget:u=>{let g=e.id;for(;c.has(a.parents.get(g)??"");)g=a.parents.get(g);let y=a.siblings.get(a.parents.get(g)??null)??[],m=y.indexOf(g)+u;for(;m>=0&&m<y.length;){let T=y[m];if(!h(T)&&A.has(T)&&s.has(T))return s.get(T);m+=u}}}}var Q=class{constructor(e){this.host=e;this.e=null;this.n=0;this.o=0;this.h=e=>{let t=this.e;if(!(!t||e.pointerId!==t.pointerId)){if(t.clientX=e.clientX,t.clientY=e.clientY,!t.active){if(Math.abs(e.clientY-t.startY)<5)return;t.active=!0,this.host.root.classList.add("mach-root--row-dragging"),this.host.root.querySelectorAll(".mach-row").forEach(n=>n.classList.toggle("mach-row--drag-source",this.sourceContains(n.dataset.id??"")))}this.d()}};this.m=()=>{if(this.n=0,!!this.e?.active){if(!this.current()){this.destroy();return}this.c(),this.v()&&this.d()}};this.g=e=>{let t=this.e;if(!(!t||e.pointerId!==t.pointerId)){t.clientX=e.clientX,t.clientY=e.clientY,t.active&&this.current()&&this.c(),this.u();try{t.active&&t.drop?.valid&&this.i(e.clientX,e.clientY)&&this.current()&&this.commitDrop(t.drop)}finally{this.release()}}};this.w=e=>{e.key==="Escape"&&(e.preventDefault(),this.destroy())};this.l=e=>{e.type==="pointercancel"&&e.pointerId!==this.e?.pointerId||this.destroy()}}begin(e){let t=this.host.containers.map(o=>{let i=le("div","mach-row-drop-indicator");return i.hidden=!0,o.append(i),i}),n=le("div","mach-row-drag-preview");n.setAttribute("role","status"),n.hidden=!0,this.host.root.append(n),this.e={startY:e.clientY,clientX:e.clientX,clientY:e.clientY,pointerId:e.pointerId,indicators:t,preview:n,drop:null,active:!1},this.a(!0)}a(e){Oe(window,e,{pointermove:this.h,pointerup:this.g,pointercancel:this.l,keydown:this.w,blur:this.l})}f(e){return this.e?.active===!0&&this.sourceContains(e)}y(e,t=()=>!0){this.o=requestAnimationFrame(()=>{this.o=0,t()&&[...this.host.root.querySelectorAll(".mach-row-drag-handle")].find(n=>n.closest(".mach-row")?.dataset.id===e)?.focus()})}d(){this.n||(this.n=requestAnimationFrame(this.m))}i(e,t,n=0){let o=this.host.body.getBoundingClientRect();return e>=o.left&&e<=o.right&&t>=o.top-n&&t<=o.bottom+n}v(){let e=this.e;if(!e||!this.i(e.clientX,e.clientY,28))return!1;let t=this.host.viewport,n=t.getBoundingClientRect(),o=Math.min(36,n.height/3);if(o<=0)return!1;let i=e.clientY<n.top+o?-Math.ceil(14*C((n.top+o-e.clientY)/o,0,1)):Math.ceil(14*C((e.clientY-n.bottom+o)/o,0,1));if(this.host.scrollBy)return this.host.scrollBy(i);let s=t.scrollTop;return t.scrollTop=C(s+i,0,Math.max(0,t.scrollHeight-t.clientHeight)),t.scrollTop!==s}c(){let e=this.e;if(!e?.active)return;let t=e.clientY-this.host.viewport.getBoundingClientRect().top+this.host.viewport.scrollTop,n=this.describe(t);e.drop=n;let o=this.i(e.clientX,e.clientY);for(let s of e.indicators){if(s.hidden=!o||!n?.valid,!n)continue;s.dataset.dropPosition=n.position??"",s.style.cssText=n.style??"";let a=parseFloat(s.parentElement.style.height),c=Math.min(this.host.getRowTop(n.boundary),Number.isFinite(a)?Math.max(0,a-2):1/0);s.style.transform=`translate3d(0, ${c}px, 0)`}let i=this.host.root.getBoundingClientRect();e.preview.hidden=!1,e.preview.textContent=o?n?.text??this.outsideText():this.outsideText(),e.preview.style.transform=`translate3d(${C(e.clientX-i.left+16,8,Math.max(8,i.width-224))}px, ${C(e.clientY-i.top+16,8,Math.max(8,i.height-48))}px, 0)`}u(){let e=this.e;this.e=null,this.a(!1),cancelAnimationFrame(this.n),this.n=0,this.host.root?.classList.remove("mach-root--row-dragging"),this.host.root?.querySelectorAll(".mach-row--drag-source").forEach(t=>t.classList.remove("mach-row--drag-source")),e?.indicators.forEach(t=>t.remove()),e?.preview.remove()}destroy(){this.u(),this.release(),cancelAnimationFrame(this.o),this.o=0}};var Z=class extends Q{constructor(t,n,o){super(t);this.t=t;this.prepare=n;this.b=o;this.scope=null;this.s=!1}r(t,n,o){try{return n()}catch(i){return this.scope&&(this.scope.failed=!0),this.t.report(i,t),o}}p(t){return this.r("prepare",()=>{let n=this.t.capture(t),o=this.prepare(t);return this.scope={node:t,from:t.rowIndex,guard:n,session:o,sourceDecision:!0,failed:!1},this.scope.sourceDecision=o.validate(),this.scope},null)}start(t,n){this.destroy(),this.p(n)&&this.current()&&this.begin(t)}moveWithKeyboard(t,n){this.destroy();let o=this.p(n);if(!(!o||!this.current())){this.s=!0;try{let i=t.key==="ArrowUp"?-1:1,s=this.r("keyboardTarget",()=>o.session.keyboardTarget(i),void 0);s&&this.commitDrop(this.destination(s,i<0?0:1))}finally{this.s=!1,this.release()}}}isSource(t){return this.f(t.id)}current(){return!!(this.scope&&!this.scope.failed&&this.scope.guard.current()&&this.t.api.rows.getById(this.scope.node.id)===this.scope.node)}sourceContains(t){return this.r("isSource",()=>this.scope?.session.isSource(t)??!1,!1)}release(){this.scope=null}outsideText(){return this.t.api.getOption("locale")?.rowDragOutside??"\u79FB\u56DE\u8868\u683C\u5185\u653E\u7F6E \xB7 Esc \u53D6\u6D88"}describe(t){let n=this.t.api,o=C(this.host.findRowAt(t),0,n.rows.getCount()-1),i=n.rows.getAt(o);if(i?.isDetail&&(i=n.rows.getById(i.masterId)),!i)return null;let s=this.host.getRowTop(i.rowIndex),a=this.host.getRowTop(i.rowIndex+1)-s;return this.destination(i,(t-s)/Math.max(1,a))}destination(t,n){let o=this.scope,i=n<.5?"before":"after",s=this.host.getRowTop(t.rowIndex+1)-this.host.getRowTop(t.rowIndex),a=this.r("resolve",()=>o.session.resolve({targetNode:t,position:i,fraction:n,height:s}),!1),c=typeof o.sourceDecision=="string"?o.sourceDecision:typeof a=="string"?a:"\u6B64\u4F4D\u7F6E\u4E0D\u53EF\u653E\u7F6E",d={node:t,fraction:n,boundary:t.rowIndex,valid:!1,text:c};if(!a||typeof a=="string"||o.sourceDecision!==!0||t.loading||t.treeLoading||t.isGroup)return d;d.intent=a.intent,d.position=a.intent.position,d.toIndex=a.toIndex,d.targetIndex=a.targetIndex,d.boundary=a.indicatorIndex??t.rowIndex+ +(a.intent.position==="after"),d.style=a.indicatorStyle,d.text=a.text??c;let h=this.r("canDrop",()=>this.t.api.getOption("rowDragPolicy")?.canDrop?.({node:o.node,api:this.t.api,targetNode:t,intent:a.intent})??!0,!1);return d.valid=h===!0,typeof h=="string"&&(d.text=h),d}commitDrop(t){let n=this.scope;if(!n||!this.current()||this.r("validate",()=>n.session.validate(),!1)!==!0||!this.current())return!1;let o=this.destination(t.node,t.fraction);return!o.valid||!o.intent||!this.current()?!1:(this.s&&this.b(o.intent,i=>this.y(n.node.id,i)),this.t.emit(n.node,n.from,o.toIndex,o.targetIndex,o.intent),!0)}};function $(r,e,t){let n=[],o=[...r].reverse().map(s=>({row:s,parent:null})),i=new Set;for(;o.length;){let s=o.pop();if(i.has(s.row))throw new Error("[MachTable] Installed order contains duplicate or cyclic rows.");i.add(s.row),n.push(s);let a=t?s.row[e]??[]:[];for(let c=a.length-1;c>=0;c--)o.push({row:a[c],parent:s.row})}return n}function H(r,e,t,n){try{let o=$(r,t,n);return o.length===e.length&&o.every((i,s)=>i.row===e[s].row&&i.parent===e[s].parent)}catch{return!1}}function he(r){let e=[];return r?.rows.forEach(t=>e.push({node:t,data:t.data})),e}function W(r,e){if(!r)return!0;if(r.isDestroyed())return!1;let t=0,n=!0;return r.rows.forEach(o=>{let i=e[t++];(i?.node!==o||i.data!==o.data)&&(n=!1)}),n&&t===e.length}var ee=class{constructor(){this.entries=[];this.cursor=0}get canUndo(){return this.cursor>0}get canRedo(){return this.cursor<this.entries.length}peek(e){return this.entries[e==="undo"?this.cursor-1:this.cursor]}commit(e,t){e==="undo"?this.cursor--:e==="redo"?this.cursor++:(this.entries.splice(this.cursor),this.entries.push(t),this.entries.length>50&&this.entries.shift(),this.cursor=this.entries.length)}clear(){this.entries=[],this.cursor=0}};var L=class extends Error{constructor(t="The row order changed on the server. Reload before trying again.",n){super(t);this.serverRevision=n;this.name="RowOrderConflictError"}};function Xe(r){if(r?.status==="conflict")throw new L(r.message,r.revision);return r?.revision}function Ae(r){if(r.targetId===null)throw new Error("[MachTable] Row ordering requires an existing destination.");return{...r,targetId:r.targetId}}function Ve(r){let e={status:"idle",error:null,revision:r.getRevision?.(),plan:null,canUndo:!1,canRedo:!1},t=0,n=!1,o=null,i=null,s=null,a=()=>{},c=()=>{},d=0,h=null,f=new ee,O=null,S=new Set,A=r.childrenKey??"children",x=null,E=()=>{f.clear(),O=null},B=()=>{if(!o)return!1;let l=o;return t++,o=null,i=null,l.abort(),!0},u=(l=e.status)=>({canUndo:!n&&l!=="saving"&&f.canUndo,canRedo:!n&&l!=="saving"&&f.canRedo}),g=l=>{e=Object.freeze({...l,...u(l.status)}),s&&!s.isDestroyed()&&s.view.refreshCells();let p=[w=>r.onStateChange?.(w),...S];for(let w of p)try{w?.(e)}catch(v){console.error("[MachTable] Row order state observer failed",v)}},y=()=>r.getRevision?.()??e.revision,m=(l=h)=>{l?.release(),h===l&&(h=null)},T=()=>{!i||i()||(B(),E(),m(),g({...e,status:"idle",plan:null,error:null}))},k=l=>new Z(l,p=>Se(l.api,p,r.getRows(),r,r.treeData===!0,y()),(p,w)=>{m();let v=document.activeElement,R=G=>{G.target!==v&&G.target!==document.body&&m(b)},b={api:l.api,intent:p,restore:w,generation:t+1,release:()=>document.removeEventListener("focusin",R,!0)};h=b,document.addEventListener("focusin",R,!0)}),M=()=>{T(),!o&&O&&(O.api!==s||O.revision!==y()||!W(s,O.nodes)||!H(r.getRows(),O.rows,A,r.treeData===!0))&&E();let l=u();(e.canUndo!==l.canUndo||e.canRedo!==l.canRedo)&&(e=Object.freeze({...e,...l}))},q=l=>{if(l===s){T(),ce(l,k)||(c(),c=ue(l,k));return}let p=B();a(),c(),m(),E(),s=l,c=ue(l,k),a=l.on("cellValueChanged",()=>{d++;let w=f.canUndo||f.canRedo;E(),w&&g({...e,status:o?"saving":"idle",plan:o?e.plan:null,error:null})}),p&&g({...e,status:"idle",plan:null,error:null})},N=l=>{if(M(),n)throw new Error("[MachTable] The row order controller is disposed.");if(o)throw new Error("[MachTable] A row order save is already in progress.");let p=y();if(p!==void 0&&l.expectedRevision!==void 0&&l.expectedRevision!==p)throw new L;let w={...l,expectedRevision:l.expectedRevision??p};return(r.treeData?ae:se)(r.getRows(),w,r)},z=async(l,p,w,v,R)=>{if(!l.changed)return l;let b=s;if(b&&!J(b))throw new Error("[MachTable] Save or discard edited rows before changing their order.");let G=++t;x=null;let j=new AbortController;o=j,i=null;let X=y(),Le=d,F=null,K=[],ye=!1,te=!1,re=X,me=I=>{if(!R)return;if(!I||R!==h||R.api!==s){m(R);return}let D=O;R.restore(()=>{let oe=D!==null&&D===O&&D.revision===y()&&W(R.api,D.nodes)&&H(r.getRows(),D.rows,A,r.treeData===!0)&&h===R&&!n&&t===R.generation&&s===R.api&&ce(R.api,k);return m(R),oe})},P=()=>!n&&t===G,ne=()=>P()&&(!b||s===b&&!b.isDestroyed())&&F!==null&&y()===X&&W(b,K)&&H(r.getRows(),F,A,r.treeData===!0),ke=I=>{if(!ne()){P()&&!F&&g({...e,status:"error",error:I,plan:l});return}let D=!b||J(b),U=D?I:Object.assign(new Error("[MachTable] Row order could not be saved. Automatic rollback was skipped to preserve new edits. Save or discard those edits, then reload the row order."),{cause:I});if(D){i=null;try{r.applyRows(l.before),te=!0}catch(oe){U=Object.assign(new Error("[MachTable] Row order could not be saved or restored. Reload the row order before trying again."),{cause:I,rollbackError:oe})}}P()&&(te||E(),g({...e,status:I instanceof L?"conflict":"error",error:U}))},Ne=()=>{if(!P()){me(!1);return}let I=y(),D=!1;ye&&P()&&(I===X||I===re)&&W(b,K)&&H(r.getRows(),F,A,r.treeData===!0)?(O={rows:F,nodes:K,api:b,revision:I},D=!0):te&&P()?(O={rows:$(r.getRows(),A,r.treeData===!0),nodes:he(b),api:b,revision:I},D=H(r.getRows(),$(l.before,A,r.treeData===!0),A,r.treeData===!0)):E(),o===j&&(o=null,i=null,s&&!s.isDestroyed()&&s.view.refreshCells()),P()&&e.status==="saving"&&g({...e,status:"idle",plan:null}),M(),me(D)};try{r.applyRows(l.after),F=$(r.getRows(),A,r.treeData===!0),K=he(b);let I=r.getRows(),D=K[0]?.node;if(i=b&&D?()=>!b.isDestroyed()&&b.rows.getById(D.id)===D:()=>r.getRows()===I,g({...e,status:"saving",error:null,plan:l}),!ne())return l;let U=Xe(await xe(Promise.resolve(r.save?.(l.intent,{signal:j.signal,plan:l,operation:p,operations:w})),j.signal));return ne()&&(ye=!0,re=U??X,d===Le?f.commit(p,v):E(),g({...e,status:"saved",revision:re})),l}catch(I){throw ke(I),I}finally{Ne()}},we=async(l,p)=>{p!==h&&(p=void 0),h!==p&&m();let w=N(l);w.changed||m(p);let v=w.changed?Te(w,r,r.treeData===!0):[];return z(w,"move",[w.intent],{plan:w,inverse:v},p)},Me=l=>we(l),ge=async l=>{if(m(),M(),n||o)throw new Error("[MachTable] Row ordering is unavailable while disposed or saving.");let p=f.peek(l);if(!p)throw new Error(`[MachTable] Nothing to ${l}.`);let w=(l==="undo"?p.inverse:[p.plan.intent]).map(G=>({...G,expectedRevision:y()})),v=r.getRows(),R=l==="undo"?p.plan.before:p.plan.after;Ie(v,R,w,r,r.treeData===!0);let b={before:v,after:R,intent:w[0],rowIds:p.plan.rowIds,changed:!0};return z(b,l,w,p)},Ce=l=>{try{if(n||o)return!1;let p=r.getRows(),w=y();if(w!==void 0&&l.expectedRevision!==void 0&&l.expectedRevision!==w)return!1;let v=x?.rowIds===l.rowIds?x.sources:JSON.stringify(l.rowIds.map(String));return(!x||x.rows!==p||x.revision!==w||x.sources!==v)&&(x={rows:p,revision:w,sources:v,rowIds:l.rowIds,validate:Re(p,l.rowIds,r,r.treeData===!0)}),x.rowIds=l.rowIds,x.validate(l),!0}catch(p){return p instanceof Error?p.message:!1}},Pe=l=>{let p=l.intent;if(l.applied||!p)return;q(l.api);let w=t,v=h?.intent===p?h:void 0;Promise.resolve().then(()=>we(Ae(p),v)).catch(R=>{v&&v.generation!==t&&m(v),!n&&t===w&&e.status!=="saving"&&g({...e,status:R instanceof L?"conflict":"error",error:R})})},fe=l=>n?!1:(q(l),o?"Wait for the current row order to finish saving.":J(l)||"Save or discard edited rows before changing their order.");return{get state(){return M(),e},bindings:{applyRowDrag:!1,rowDragPolicy:{canDrag:({api:l})=>fe(l),canDrop:({intent:l,api:p})=>{let w=fe(p);if(w!==!0)return w;try{return Ce(Ae(l))}catch(v){return v instanceof Error?v.message:!1}},getRevision:y},onRowDragEnd:Pe},preview:N,move:Me,undo:()=>ge("undo"),redo:()=>ge("redo"),subscribe(l){return n?()=>{}:(S.add(l),()=>{S.delete(l)})},dispose(){n=!0,t++,o?.abort(),o=null,i=null,a(),c(),m(),E(),s&&!s.isDestroyed()&&s.view.refreshCells(),s=null,x=null,S.clear(),e=Object.freeze({...e,status:"idle",error:null,plan:null,canUndo:!1,canRedo:!1})}}}export{L as RowOrderConflictError,Ve as createRowOrderController,ae as moveTreeNodes,se as reorderRows};
@@ -1,4 +1,4 @@
1
- import { f as GridState, g as GridStateStore, F as FilterType } from './api-DH2BoJ9I.cjs';
1
+ import { f as GridState, g as GridStateStore, F as FilterType } from './api-ChEKWrvH.cjs';
2
2
 
3
3
  interface GridStateMigrationOptions {
4
4
  /** Current stable column IDs; removed IDs are not restored. */
@@ -1,4 +1,4 @@
1
- import { f as GridState, g as GridStateStore, F as FilterType } from './api-DH2BoJ9I.js';
1
+ import { f as GridState, g as GridStateStore, F as FilterType } from './api-ChEKWrvH.js';
2
2
 
3
3
  interface GridStateMigrationOptions {
4
4
  /** Current stable column IDs; removed IDs are not restored. */
@@ -1,4 +1,4 @@
1
- import { S as SortModel, h as FilterModel, A as AdvancedFilterModel, b as GridApi, C as ColDef, i as FieldPath } from './api-DH2BoJ9I.cjs';
1
+ import { S as SortModel, h as FilterModel, A as AdvancedFilterModel, b as GridApi, C as ColDef, i as FieldPath } from './api-ChEKWrvH.cjs';
2
2
 
3
3
  interface ServerSideGroupColumn {
4
4
  colId: string;
@@ -1,4 +1,4 @@
1
- import { S as SortModel, h as FilterModel, A as AdvancedFilterModel, b as GridApi, C as ColDef, i as FieldPath } from './api-DH2BoJ9I.js';
1
+ import { S as SortModel, h as FilterModel, A as AdvancedFilterModel, b as GridApi, C as ColDef, i as FieldPath } from './api-ChEKWrvH.js';
2
2
 
3
3
  interface ServerSideGroupColumn {
4
4
  colId: string;