@devalok/shilp-sutra 0.49.4 → 0.50.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.
- package/AGENTS.md +12 -4
- package/MIGRATION.md +6 -0
- package/dist/_chunks/badge-group.js +12 -11
- package/dist/_chunks/badge-group.js.map +1 -1
- package/dist/_chunks/block-shell.js +1 -1
- package/dist/_chunks/block-shell.js.map +1 -1
- package/dist/_chunks/chat.js +18 -18
- package/dist/_chunks/chat.js.map +1 -1
- package/dist/_chunks/document-preview.js +1 -1
- package/dist/_chunks/document-preview.js.map +1 -1
- package/dist/_chunks/emoji-suggestion.js +1 -1
- package/dist/_chunks/emoji-suggestion.js.map +1 -1
- package/dist/_chunks/grid-lines.js +2 -2
- package/dist/_chunks/grid-lines.js.map +1 -1
- package/dist/_chunks/image-preview.js +1 -1
- package/dist/_chunks/image-preview.js.map +1 -1
- package/dist/_chunks/mention-suggestion.js +2 -2
- package/dist/_chunks/mention-suggestion.js.map +1 -1
- package/dist/_chunks/oauth-button.js +8 -8
- package/dist/_chunks/oauth-button.js.map +1 -1
- package/dist/_chunks/shared.js +2 -2
- package/dist/_chunks/shared.js.map +1 -1
- package/dist/_chunks/success.js +5 -5
- package/dist/_chunks/success.js.map +1 -1
- package/dist/_chunks/tiptap.js +3956 -1796
- package/dist/_chunks/tiptap.js.map +1 -1
- package/dist/_chunks/tooltip.js +2 -2
- package/dist/_chunks/tooltip.js.map +1 -1
- package/dist/_chunks/tree-view.js +2 -2
- package/dist/_chunks/tree-view.js.map +1 -1
- package/dist/_chunks/use-calendar.js +3 -3
- package/dist/_chunks/use-calendar.js.map +1 -1
- package/dist/ai/block-renderer.js +1 -1
- package/dist/ai/block-renderer.js.map +1 -1
- package/dist/ai/blocks/error.js +1 -1
- package/dist/ai/blocks/error.js.map +1 -1
- package/dist/ai/command-bar.js +15 -15
- package/dist/ai/command-bar.js.map +1 -1
- package/dist/ai/conversation.js +6 -6
- package/dist/ai/conversation.js.map +1 -1
- package/dist/composed/activity-feed.js +4 -4
- package/dist/composed/activity-feed.js.map +1 -1
- package/dist/composed/avatar-group.js +6 -6
- package/dist/composed/avatar-group.js.map +1 -1
- package/dist/composed/bulk-action-bar.js +1 -1
- package/dist/composed/bulk-action-bar.js.map +1 -1
- package/dist/composed/command-palette.js +12 -12
- package/dist/composed/command-palette.js.map +1 -1
- package/dist/composed/content-card.js +1 -1
- package/dist/composed/content-card.js.map +1 -1
- package/dist/composed/date-picker/index.js +17 -17
- package/dist/composed/date-picker/index.js.map +1 -1
- package/dist/composed/deadline-indicator.js +2 -2
- package/dist/composed/deadline-indicator.js.map +1 -1
- package/dist/composed/diff.d.ts +108 -0
- package/dist/composed/diff.d.ts.map +1 -0
- package/dist/composed/diff.js +1004 -0
- package/dist/composed/diff.js.map +1 -0
- package/dist/composed/emoji-picker.js +6 -6
- package/dist/composed/emoji-picker.js.map +1 -1
- package/dist/composed/empty-state.js +2 -2
- package/dist/composed/empty-state.js.map +1 -1
- package/dist/composed/error-boundary.js +6 -6
- package/dist/composed/error-boundary.js.map +1 -1
- package/dist/composed/file-preview.js +5 -5
- package/dist/composed/file-preview.js.map +1 -1
- package/dist/composed/filter-bar.js +3 -3
- package/dist/composed/filter-bar.js.map +1 -1
- package/dist/composed/form-section.js +2 -2
- package/dist/composed/form-section.js.map +1 -1
- package/dist/composed/inline-edit.d.ts +1 -1
- package/dist/composed/inline-edit.d.ts.map +1 -1
- package/dist/composed/inline-edit.js.map +1 -1
- package/dist/composed/loading-skeleton.js +3 -3
- package/dist/composed/loading-skeleton.js.map +1 -1
- package/dist/composed/markdown-viewer.js +11 -11
- package/dist/composed/markdown-viewer.js.map +1 -1
- package/dist/composed/master-detail.js +1 -1
- package/dist/composed/master-detail.js.map +1 -1
- package/dist/composed/member-picker.js +2 -2
- package/dist/composed/member-picker.js.map +1 -1
- package/dist/composed/multi-select-popover.js +5 -5
- package/dist/composed/multi-select-popover.js.map +1 -1
- package/dist/composed/page-header.js +3 -3
- package/dist/composed/page-header.js.map +1 -1
- package/dist/composed/page-skeletons.js +4 -4
- package/dist/composed/page-skeletons.js.map +1 -1
- package/dist/composed/priority-indicator.js +1 -1
- package/dist/composed/priority-indicator.js.map +1 -1
- package/dist/composed/responsive-modal.js +2 -2
- package/dist/composed/responsive-modal.js.map +1 -1
- package/dist/composed/rich-chat-input.js +27 -27
- package/dist/composed/rich-chat-input.js.map +1 -1
- package/dist/composed/rich-text-editor.d.ts +81 -6
- package/dist/composed/rich-text-editor.d.ts.map +1 -1
- package/dist/composed/rich-text-editor.js +365 -210
- package/dist/composed/rich-text-editor.js.map +1 -1
- package/dist/composed/schedule-view.js +4 -4
- package/dist/composed/schedule-view.js.map +1 -1
- package/dist/shell/bottom-navbar.js +4 -4
- package/dist/shell/bottom-navbar.js.map +1 -1
- package/dist/shell/notification-center.js +13 -13
- package/dist/shell/notification-center.js.map +1 -1
- package/dist/shell/notification-preferences.js +10 -10
- package/dist/shell/notification-preferences.js.map +1 -1
- package/dist/shell/sidebar.js +9 -9
- package/dist/shell/sidebar.js.map +1 -1
- package/dist/shell/top-bar.js +8 -8
- package/dist/shell/top-bar.js.map +1 -1
- package/dist/tokens/semantic.css +6 -1
- package/dist/tokens/typography-semantic.css +6 -6
- package/dist/tokens/utilities.css +8 -0
- package/dist/ui/accordion.js +2 -2
- package/dist/ui/accordion.js.map +1 -1
- package/dist/ui/alert-dialog.js +4 -4
- package/dist/ui/alert-dialog.js.map +1 -1
- package/dist/ui/alert.js +1 -1
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/autocomplete.d.ts.map +1 -1
- package/dist/ui/autocomplete.js +11 -3
- package/dist/ui/autocomplete.js.map +1 -1
- package/dist/ui/avatar.js +5 -5
- package/dist/ui/avatar.js.map +1 -1
- package/dist/ui/badge-group.d.ts +2 -6
- package/dist/ui/badge-group.d.ts.map +1 -1
- package/dist/ui/badge-indicator.d.ts +2 -6
- package/dist/ui/badge-indicator.d.ts.map +1 -1
- package/dist/ui/badge-indicator.js +19 -18
- package/dist/ui/badge-indicator.js.map +1 -1
- package/dist/ui/badge.d.ts +2 -4
- package/dist/ui/badge.d.ts.map +1 -1
- package/dist/ui/banner.js +1 -1
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/breadcrumb.js +1 -1
- package/dist/ui/breadcrumb.js.map +1 -1
- package/dist/ui/button.js +7 -7
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/card.d.ts +1 -1
- package/dist/ui/card.js +1 -1
- package/dist/ui/card.js.map +1 -1
- package/dist/ui/charts/gauge-chart.js +2 -2
- package/dist/ui/charts/gauge-chart.js.map +1 -1
- package/dist/ui/charts/pie-chart.js +1 -1
- package/dist/ui/charts/pie-chart.js.map +1 -1
- package/dist/ui/charts/radar-chart.d.ts +19 -1
- package/dist/ui/charts/radar-chart.d.ts.map +1 -1
- package/dist/ui/charts/radar-chart.js +80 -42
- package/dist/ui/charts/radar-chart.js.map +1 -1
- package/dist/ui/code.js +2 -2
- package/dist/ui/code.js.map +1 -1
- package/dist/ui/color-input.d.ts.map +1 -1
- package/dist/ui/color-input.js +164 -157
- package/dist/ui/color-input.js.map +1 -1
- package/dist/ui/combobox.d.ts.map +1 -1
- package/dist/ui/combobox.js +143 -142
- package/dist/ui/combobox.js.map +1 -1
- package/dist/ui/context-menu.js +6 -6
- package/dist/ui/context-menu.js.map +1 -1
- package/dist/ui/data-table-body.js +1 -1
- package/dist/ui/data-table-body.js.map +1 -1
- package/dist/ui/data-table-bulk-actions.js +1 -1
- package/dist/ui/data-table-bulk-actions.js.map +1 -1
- package/dist/ui/data-table-card.js +1 -1
- package/dist/ui/data-table-card.js.map +1 -1
- package/dist/ui/data-table-header.js +1 -1
- package/dist/ui/data-table-header.js.map +1 -1
- package/dist/ui/data-table-pagination.js +3 -3
- package/dist/ui/data-table-pagination.js.map +1 -1
- package/dist/ui/data-table-toolbar.js +1 -1
- package/dist/ui/data-table-toolbar.js.map +1 -1
- package/dist/ui/data-table.js +1 -1
- package/dist/ui/data-table.js.map +1 -1
- package/dist/ui/dialog.js +2 -2
- package/dist/ui/dialog.js.map +1 -1
- package/dist/ui/dot.js +4 -4
- package/dist/ui/dot.js.map +1 -1
- package/dist/ui/dropdown-menu.js +6 -6
- package/dist/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/file-upload.js +5 -5
- package/dist/ui/file-upload.js.map +1 -1
- package/dist/ui/form.js +1 -1
- package/dist/ui/form.js.map +1 -1
- package/dist/ui/input-otp.d.ts.map +1 -1
- package/dist/ui/input-otp.js +3 -3
- package/dist/ui/input-otp.js.map +1 -1
- package/dist/ui/input.js +8 -8
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/label.js +1 -1
- package/dist/ui/label.js.map +1 -1
- package/dist/ui/lib/utils.d.ts.map +1 -1
- package/dist/ui/lib/utils.js +42 -13
- package/dist/ui/lib/utils.js.map +1 -1
- package/dist/ui/menubar.js +7 -7
- package/dist/ui/menubar.js.map +1 -1
- package/dist/ui/navigation-menu.js +1 -1
- package/dist/ui/navigation-menu.js.map +1 -1
- package/dist/ui/number-input.d.ts.map +1 -1
- package/dist/ui/number-input.js +6 -5
- package/dist/ui/number-input.js.map +1 -1
- package/dist/ui/pagination.js +1 -1
- package/dist/ui/pagination.js.map +1 -1
- package/dist/ui/progress-ring.js +3 -3
- package/dist/ui/progress-ring.js.map +1 -1
- package/dist/ui/progress.js +2 -2
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/segmented-control.js +3 -3
- package/dist/ui/segmented-control.js.map +1 -1
- package/dist/ui/select.d.ts.map +1 -1
- package/dist/ui/select.js +7 -6
- package/dist/ui/select.js.map +1 -1
- package/dist/ui/sheet.js +2 -2
- package/dist/ui/sheet.js.map +1 -1
- package/dist/ui/sidebar.js +7 -7
- package/dist/ui/sidebar.js.map +1 -1
- package/dist/ui/split-button.js +6 -6
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/stat-card.d.ts +1 -1
- package/dist/ui/stat-card.js +7 -7
- package/dist/ui/stat-card.js.map +1 -1
- package/dist/ui/stepper.js +3 -3
- package/dist/ui/stepper.js.map +1 -1
- package/dist/ui/table.js +3 -3
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/tabs.js +3 -3
- package/dist/ui/tabs.js.map +1 -1
- package/dist/ui/text.d.ts.map +1 -1
- package/dist/ui/text.js.map +1 -1
- package/dist/ui/textarea.d.ts.map +1 -1
- package/dist/ui/textarea.js +7 -6
- package/dist/ui/textarea.js.map +1 -1
- package/dist/ui/toast.js +11 -11
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/toggle.js +3 -3
- package/dist/ui/toggle.js.map +1 -1
- package/dist/ui/tooltip.js +1 -1
- package/dist/ui/tooltip.js.map +1 -1
- package/docs/components/composed/diff.md +50 -0
- package/docs/components/ui/data-table.md +2 -2
- package/llms.txt +2 -1
- package/mcp-manifest.json +147 -3
- package/package.json +8 -1
- package/skill/SKILL.md +1 -1
- package/skill/references/components.md +2 -1
|
@@ -0,0 +1,1004 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../ui/lib/utils.js";
|
|
3
|
+
import { Icon as t } from "../ui/icon.js";
|
|
4
|
+
import { Button as n } from "../ui/button.js";
|
|
5
|
+
import * as r from "react";
|
|
6
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
import { IconCheck as o, IconChevronDown as s, IconX as c } from "@tabler/icons-react";
|
|
8
|
+
import { motion as l, useReducedMotion as u } from "framer-motion";
|
|
9
|
+
//#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/base.js
|
|
10
|
+
var d = class {
|
|
11
|
+
diff(e, t, n = {}) {
|
|
12
|
+
let r;
|
|
13
|
+
typeof n == "function" ? (r = n, n = {}) : "callback" in n && (r = n.callback);
|
|
14
|
+
let i = this.castInput(e, n), a = this.castInput(t, n), o = this.removeEmpty(this.tokenize(i, n)), s = this.removeEmpty(this.tokenize(a, n));
|
|
15
|
+
return this.diffWithOptionsObj(o, s, n, r);
|
|
16
|
+
}
|
|
17
|
+
diffWithOptionsObj(e, t, n, r) {
|
|
18
|
+
let i = (e) => {
|
|
19
|
+
if (e = this.postProcess(e, n), r) {
|
|
20
|
+
setTimeout(function() {
|
|
21
|
+
r(e);
|
|
22
|
+
}, 0);
|
|
23
|
+
return;
|
|
24
|
+
} else return e;
|
|
25
|
+
}, a = t.length, o = e.length, s = 1, c = a + o;
|
|
26
|
+
n.maxEditLength != null && (c = Math.min(c, n.maxEditLength));
|
|
27
|
+
let l = n.timeout ?? Infinity, u = Date.now() + l, d = [{
|
|
28
|
+
oldPos: -1,
|
|
29
|
+
lastComponent: void 0
|
|
30
|
+
}], f = this.extractCommon(d[0], t, e, 0, n);
|
|
31
|
+
if (d[0].oldPos + 1 >= o && f + 1 >= a) return i(this.buildValues(d[0].lastComponent, t, e));
|
|
32
|
+
let p = -Infinity, m = Infinity, h = () => {
|
|
33
|
+
for (let r = Math.max(p, -s); r <= Math.min(m, s); r += 2) {
|
|
34
|
+
let s, c = d[r - 1], l = d[r + 1];
|
|
35
|
+
c && (d[r - 1] = void 0);
|
|
36
|
+
let u = !1;
|
|
37
|
+
if (l) {
|
|
38
|
+
let e = l.oldPos - r;
|
|
39
|
+
u = l && 0 <= e && e < a;
|
|
40
|
+
}
|
|
41
|
+
let h = c && c.oldPos + 1 < o;
|
|
42
|
+
if (!u && !h) {
|
|
43
|
+
d[r] = void 0;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (s = !h || u && c.oldPos < l.oldPos ? this.addToPath(l, !0, !1, 0, n) : this.addToPath(c, !1, !0, 1, n), f = this.extractCommon(s, t, e, r, n), s.oldPos + 1 >= o && f + 1 >= a) return i(this.buildValues(s.lastComponent, t, e)) || !0;
|
|
47
|
+
d[r] = s, s.oldPos + 1 >= o && (m = Math.min(m, r - 1)), f + 1 >= a && (p = Math.max(p, r + 1));
|
|
48
|
+
}
|
|
49
|
+
s++;
|
|
50
|
+
};
|
|
51
|
+
if (r) (function e() {
|
|
52
|
+
setTimeout(function() {
|
|
53
|
+
if (s > c || Date.now() > u) return r(void 0);
|
|
54
|
+
h() || e();
|
|
55
|
+
}, 0);
|
|
56
|
+
})();
|
|
57
|
+
else for (; s <= c && Date.now() <= u;) {
|
|
58
|
+
let e = h();
|
|
59
|
+
if (e) return e;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
addToPath(e, t, n, r, i) {
|
|
63
|
+
let a = e.lastComponent;
|
|
64
|
+
return a && !i.oneChangePerToken && a.added === t && a.removed === n ? {
|
|
65
|
+
oldPos: e.oldPos + r,
|
|
66
|
+
lastComponent: {
|
|
67
|
+
count: a.count + 1,
|
|
68
|
+
added: t,
|
|
69
|
+
removed: n,
|
|
70
|
+
previousComponent: a.previousComponent
|
|
71
|
+
}
|
|
72
|
+
} : {
|
|
73
|
+
oldPos: e.oldPos + r,
|
|
74
|
+
lastComponent: {
|
|
75
|
+
count: 1,
|
|
76
|
+
added: t,
|
|
77
|
+
removed: n,
|
|
78
|
+
previousComponent: a
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
extractCommon(e, t, n, r, i) {
|
|
83
|
+
let a = t.length, o = n.length, s = e.oldPos, c = s - r, l = 0;
|
|
84
|
+
for (; c + 1 < a && s + 1 < o && this.equals(n[s + 1], t[c + 1], i);) c++, s++, l++, i.oneChangePerToken && (e.lastComponent = {
|
|
85
|
+
count: 1,
|
|
86
|
+
previousComponent: e.lastComponent,
|
|
87
|
+
added: !1,
|
|
88
|
+
removed: !1
|
|
89
|
+
});
|
|
90
|
+
return l && !i.oneChangePerToken && (e.lastComponent = {
|
|
91
|
+
count: l,
|
|
92
|
+
previousComponent: e.lastComponent,
|
|
93
|
+
added: !1,
|
|
94
|
+
removed: !1
|
|
95
|
+
}), e.oldPos = s, c;
|
|
96
|
+
}
|
|
97
|
+
equals(e, t, n) {
|
|
98
|
+
return n.comparator ? n.comparator(e, t) : e === t || !!n.ignoreCase && e.toLowerCase() === t.toLowerCase();
|
|
99
|
+
}
|
|
100
|
+
removeEmpty(e) {
|
|
101
|
+
let t = [];
|
|
102
|
+
for (let n = 0; n < e.length; n++) e[n] && t.push(e[n]);
|
|
103
|
+
return t;
|
|
104
|
+
}
|
|
105
|
+
castInput(e, t) {
|
|
106
|
+
return e;
|
|
107
|
+
}
|
|
108
|
+
tokenize(e, t) {
|
|
109
|
+
return Array.from(e);
|
|
110
|
+
}
|
|
111
|
+
join(e) {
|
|
112
|
+
return e.join("");
|
|
113
|
+
}
|
|
114
|
+
postProcess(e, t) {
|
|
115
|
+
return e;
|
|
116
|
+
}
|
|
117
|
+
get useLongestToken() {
|
|
118
|
+
return !1;
|
|
119
|
+
}
|
|
120
|
+
buildValues(e, t, n) {
|
|
121
|
+
let r = [], i;
|
|
122
|
+
for (; e;) r.push(e), i = e.previousComponent, delete e.previousComponent, e = i;
|
|
123
|
+
r.reverse();
|
|
124
|
+
let a = r.length, o = 0, s = 0, c = 0;
|
|
125
|
+
for (; o < a; o++) {
|
|
126
|
+
let e = r[o];
|
|
127
|
+
if (e.removed) e.value = this.join(n.slice(c, c + e.count)), c += e.count;
|
|
128
|
+
else {
|
|
129
|
+
if (!e.added && this.useLongestToken) {
|
|
130
|
+
let r = t.slice(s, s + e.count);
|
|
131
|
+
r = r.map(function(e, t) {
|
|
132
|
+
let r = n[c + t];
|
|
133
|
+
return r.length > e.length ? r : e;
|
|
134
|
+
}), e.value = this.join(r);
|
|
135
|
+
} else e.value = this.join(t.slice(s, s + e.count));
|
|
136
|
+
s += e.count, e.added || (c += e.count);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return r;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
new class extends d {}();
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/util/string.js
|
|
145
|
+
function f(e, t) {
|
|
146
|
+
let n;
|
|
147
|
+
for (n = 0; n < e.length && n < t.length; n++) if (e[n] != t[n]) return e.slice(0, n);
|
|
148
|
+
return e.slice(0, n);
|
|
149
|
+
}
|
|
150
|
+
function p(e, t) {
|
|
151
|
+
let n;
|
|
152
|
+
if (!e || !t || e[e.length - 1] != t[t.length - 1]) return "";
|
|
153
|
+
for (n = 0; n < e.length && n < t.length; n++) if (e[e.length - (n + 1)] != t[t.length - (n + 1)]) return e.slice(-n);
|
|
154
|
+
return e.slice(-n);
|
|
155
|
+
}
|
|
156
|
+
function m(e, t, n) {
|
|
157
|
+
if (e.slice(0, t.length) != t) throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);
|
|
158
|
+
return n + e.slice(t.length);
|
|
159
|
+
}
|
|
160
|
+
function h(e, t, n) {
|
|
161
|
+
if (!t) return e + n;
|
|
162
|
+
if (e.slice(-t.length) != t) throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);
|
|
163
|
+
return e.slice(0, -t.length) + n;
|
|
164
|
+
}
|
|
165
|
+
function g(e, t) {
|
|
166
|
+
return m(e, t, "");
|
|
167
|
+
}
|
|
168
|
+
function _(e, t) {
|
|
169
|
+
return h(e, t, "");
|
|
170
|
+
}
|
|
171
|
+
function v(e, t) {
|
|
172
|
+
return t.slice(0, y(e, t));
|
|
173
|
+
}
|
|
174
|
+
function y(e, t) {
|
|
175
|
+
let n = 0;
|
|
176
|
+
e.length > t.length && (n = e.length - t.length);
|
|
177
|
+
let r = t.length;
|
|
178
|
+
e.length < t.length && (r = e.length);
|
|
179
|
+
let i = Array(r), a = 0;
|
|
180
|
+
i[0] = 0;
|
|
181
|
+
for (let e = 1; e < r; e++) {
|
|
182
|
+
for (t[e] == t[a] ? i[e] = i[a] : i[e] = a; a > 0 && t[e] != t[a];) a = i[a];
|
|
183
|
+
t[e] == t[a] && a++;
|
|
184
|
+
}
|
|
185
|
+
a = 0;
|
|
186
|
+
for (let r = n; r < e.length; r++) {
|
|
187
|
+
for (; a > 0 && e[r] != t[a];) a = i[a];
|
|
188
|
+
e[r] == t[a] && a++;
|
|
189
|
+
}
|
|
190
|
+
return a;
|
|
191
|
+
}
|
|
192
|
+
function b(e, t) {
|
|
193
|
+
let n = [];
|
|
194
|
+
for (let r of Array.from(t.segment(e))) {
|
|
195
|
+
let e = r.segment;
|
|
196
|
+
n.length && /\s/.test(n[n.length - 1]) && /\s/.test(e) ? n[n.length - 1] += e : n.push(e);
|
|
197
|
+
}
|
|
198
|
+
return n;
|
|
199
|
+
}
|
|
200
|
+
function x(e, t) {
|
|
201
|
+
if (t) return C(e, t)[1];
|
|
202
|
+
let n;
|
|
203
|
+
for (n = e.length - 1; n >= 0 && e[n].match(/\s/); n--);
|
|
204
|
+
return e.substring(n + 1);
|
|
205
|
+
}
|
|
206
|
+
function S(e, t) {
|
|
207
|
+
if (t) return C(e, t)[0];
|
|
208
|
+
let n = e.match(/^\s*/);
|
|
209
|
+
return n ? n[0] : "";
|
|
210
|
+
}
|
|
211
|
+
function C(e, t) {
|
|
212
|
+
if (!t) return [S(e), x(e)];
|
|
213
|
+
if (t.resolvedOptions().granularity != "word") throw Error("The segmenter passed must have a granularity of \"word\"");
|
|
214
|
+
let n = b(e, t), r = n[0], i = n[n.length - 1];
|
|
215
|
+
return [/\s/.test(r) ? r : "", /\s/.test(i) ? i : ""];
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/word.js
|
|
219
|
+
var w = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}", T = RegExp(`[${w}]+|\\s+|[^${w}]`, "ug");
|
|
220
|
+
new class extends d {
|
|
221
|
+
equals(e, t, n) {
|
|
222
|
+
return n.ignoreCase && (e = e.toLowerCase(), t = t.toLowerCase()), e.trim() === t.trim();
|
|
223
|
+
}
|
|
224
|
+
tokenize(e, t = {}) {
|
|
225
|
+
let n;
|
|
226
|
+
if (t.intlSegmenter) {
|
|
227
|
+
let r = t.intlSegmenter;
|
|
228
|
+
if (r.resolvedOptions().granularity != "word") throw Error("The segmenter passed must have a granularity of \"word\"");
|
|
229
|
+
n = b(e, r);
|
|
230
|
+
} else n = e.match(T) || [];
|
|
231
|
+
let r = [], i = null;
|
|
232
|
+
return n.forEach((e) => {
|
|
233
|
+
/\s/.test(e) ? i == null ? r.push(e) : r.push(r.pop() + e) : i != null && /\s/.test(i) ? r[r.length - 1] == i ? r.push(r.pop() + e) : r.push(i + e) : r.push(e), i = e;
|
|
234
|
+
}), r;
|
|
235
|
+
}
|
|
236
|
+
join(e) {
|
|
237
|
+
return e.map((e, t) => t == 0 ? e : e.replace(/^\s+/, "")).join("");
|
|
238
|
+
}
|
|
239
|
+
postProcess(e, t) {
|
|
240
|
+
if (!e || t.oneChangePerToken) return e;
|
|
241
|
+
let n = null, r = null, i = null;
|
|
242
|
+
return e.forEach((e) => {
|
|
243
|
+
e.added ? r = e : e.removed ? i = e : ((r || i) && E(n, i, r, e, t.intlSegmenter), n = e, r = null, i = null);
|
|
244
|
+
}), (r || i) && E(n, i, r, null, t.intlSegmenter), e;
|
|
245
|
+
}
|
|
246
|
+
}();
|
|
247
|
+
function E(e, t, n, r, i) {
|
|
248
|
+
if (t && n) {
|
|
249
|
+
let [a, o] = C(t.value, i), [s, c] = C(n.value, i);
|
|
250
|
+
if (e) {
|
|
251
|
+
let r = f(a, s);
|
|
252
|
+
e.value = h(e.value, s, r), t.value = g(t.value, r), n.value = g(n.value, r);
|
|
253
|
+
}
|
|
254
|
+
if (r) {
|
|
255
|
+
let e = p(o, c);
|
|
256
|
+
r.value = m(r.value, c, e), t.value = _(t.value, e), n.value = _(n.value, e);
|
|
257
|
+
}
|
|
258
|
+
} else if (n) {
|
|
259
|
+
if (e) {
|
|
260
|
+
let e = S(n.value, i);
|
|
261
|
+
n.value = n.value.substring(e.length);
|
|
262
|
+
}
|
|
263
|
+
if (r) {
|
|
264
|
+
let e = S(r.value, i);
|
|
265
|
+
r.value = r.value.substring(e.length);
|
|
266
|
+
}
|
|
267
|
+
} else if (e && r) {
|
|
268
|
+
let n = S(r.value, i), [a, o] = C(t.value, i), s = f(n, a);
|
|
269
|
+
t.value = g(t.value, s);
|
|
270
|
+
let c = p(g(n, s), o);
|
|
271
|
+
t.value = _(t.value, c), r.value = m(r.value, n, c), e.value = h(e.value, n, n.slice(0, n.length - c.length));
|
|
272
|
+
} else if (r) {
|
|
273
|
+
let e = S(r.value, i), n = v(x(t.value, i), e);
|
|
274
|
+
t.value = _(t.value, n);
|
|
275
|
+
} else if (e) {
|
|
276
|
+
let n = v(x(e.value, i), S(t.value, i));
|
|
277
|
+
t.value = g(t.value, n);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
var ee = new class extends d {
|
|
281
|
+
tokenize(e) {
|
|
282
|
+
let t = RegExp(`(\\r?\\n)|[${w}]+|[^\\S\\n\\r]+|[^${w}]`, "ug");
|
|
283
|
+
return e.match(t) || [];
|
|
284
|
+
}
|
|
285
|
+
}();
|
|
286
|
+
function D(e, t, n) {
|
|
287
|
+
return ee.diff(e, t, n);
|
|
288
|
+
}
|
|
289
|
+
var O = new class extends d {
|
|
290
|
+
constructor() {
|
|
291
|
+
super(...arguments), this.tokenize = A;
|
|
292
|
+
}
|
|
293
|
+
equals(e, t, n) {
|
|
294
|
+
return n.ignoreWhitespace ? ((!n.newlineIsToken || !e.includes("\n")) && (e = e.trim()), (!n.newlineIsToken || !t.includes("\n")) && (t = t.trim())) : n.ignoreNewlineAtEof && !n.newlineIsToken && (e.endsWith("\n") && (e = e.slice(0, -1)), t.endsWith("\n") && (t = t.slice(0, -1))), super.equals(e, t, n);
|
|
295
|
+
}
|
|
296
|
+
}();
|
|
297
|
+
function k(e, t, n) {
|
|
298
|
+
return O.diff(e, t, n);
|
|
299
|
+
}
|
|
300
|
+
function A(e, t) {
|
|
301
|
+
t.stripTrailingCr && (e = e.replace(/\r\n/g, "\n"));
|
|
302
|
+
let n = [], r = e.split(/(\n|\r\n)/);
|
|
303
|
+
r[r.length - 1] || r.pop();
|
|
304
|
+
for (let e = 0; e < r.length; e++) {
|
|
305
|
+
let i = r[e];
|
|
306
|
+
e % 2 && !t.newlineIsToken ? n[n.length - 1] += i : n.push(i);
|
|
307
|
+
}
|
|
308
|
+
return n;
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region ../../node_modules/.pnpm/diff@9.0.0/node_modules/diff/libesm/diff/sentence.js
|
|
312
|
+
function j(e) {
|
|
313
|
+
return e == "." || e == "!" || e == "?";
|
|
314
|
+
}
|
|
315
|
+
new class extends d {
|
|
316
|
+
tokenize(e) {
|
|
317
|
+
let t = [], n = 0;
|
|
318
|
+
for (let r = 0; r < e.length; r++) {
|
|
319
|
+
if (r == e.length - 1) {
|
|
320
|
+
t.push(e.slice(n));
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
if (j(e[r]) && e[r + 1].match(/\s/)) {
|
|
324
|
+
for (t.push(e.slice(n, r + 1)), r = n = r + 1; e[r + 1]?.match(/\s/);) r++;
|
|
325
|
+
t.push(e.slice(n, r + 1)), n = r + 1;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return t;
|
|
329
|
+
}
|
|
330
|
+
}(), new class extends d {
|
|
331
|
+
tokenize(e) {
|
|
332
|
+
return e.split(/([{}:;,]|\s+)/);
|
|
333
|
+
}
|
|
334
|
+
}(), new class extends d {
|
|
335
|
+
constructor() {
|
|
336
|
+
super(...arguments), this.tokenize = A;
|
|
337
|
+
}
|
|
338
|
+
get useLongestToken() {
|
|
339
|
+
return !0;
|
|
340
|
+
}
|
|
341
|
+
castInput(e, t) {
|
|
342
|
+
let { undefinedReplacement: n, stringifyReplacer: r = (e, t) => t === void 0 ? n : t } = t;
|
|
343
|
+
return typeof e == "string" ? e : JSON.stringify(M(e, null, null, r), null, " ");
|
|
344
|
+
}
|
|
345
|
+
equals(e, t, n) {
|
|
346
|
+
return super.equals(e.replace(/,([\r\n])/g, "$1"), t.replace(/,([\r\n])/g, "$1"), n);
|
|
347
|
+
}
|
|
348
|
+
}();
|
|
349
|
+
function M(e, t, n, r, i) {
|
|
350
|
+
t ||= [], n ||= [], r && (e = r(i === void 0 ? "" : i, e));
|
|
351
|
+
let a;
|
|
352
|
+
for (a = 0; a < t.length; a += 1) if (t[a] === e) return n[a];
|
|
353
|
+
let o;
|
|
354
|
+
if (Object.prototype.toString.call(e) === "[object Array]") {
|
|
355
|
+
for (t.push(e), o = Array(e.length), n.push(o), a = 0; a < e.length; a += 1) o[a] = M(e[a], t, n, r, String(a));
|
|
356
|
+
return t.pop(), n.pop(), o;
|
|
357
|
+
}
|
|
358
|
+
if (e && e.toJSON && (e = e.toJSON()), typeof e == "object" && e) {
|
|
359
|
+
t.push(e), o = {}, n.push(o);
|
|
360
|
+
let i = [], s;
|
|
361
|
+
for (s in e)
|
|
362
|
+
/* istanbul ignore else */
|
|
363
|
+
Object.prototype.hasOwnProperty.call(e, s) && i.push(s);
|
|
364
|
+
for (i.sort(), a = 0; a < i.length; a += 1) s = i[a], o[s] = M(e[s], t, n, r, s);
|
|
365
|
+
t.pop(), n.pop();
|
|
366
|
+
} else o = e;
|
|
367
|
+
return o;
|
|
368
|
+
}
|
|
369
|
+
new class extends d {
|
|
370
|
+
tokenize(e) {
|
|
371
|
+
return e.slice();
|
|
372
|
+
}
|
|
373
|
+
join(e) {
|
|
374
|
+
return e;
|
|
375
|
+
}
|
|
376
|
+
removeEmpty(e) {
|
|
377
|
+
return e;
|
|
378
|
+
}
|
|
379
|
+
}();
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/composed/diff.tsx
|
|
382
|
+
function N({ children: e }) {
|
|
383
|
+
return u() ? /* @__PURE__ */ i("div", { children: e }) : /* @__PURE__ */ i(l.div, {
|
|
384
|
+
initial: {
|
|
385
|
+
height: 0,
|
|
386
|
+
opacity: 0
|
|
387
|
+
},
|
|
388
|
+
animate: {
|
|
389
|
+
height: "auto",
|
|
390
|
+
opacity: 1
|
|
391
|
+
},
|
|
392
|
+
transition: {
|
|
393
|
+
duration: .2,
|
|
394
|
+
ease: "easeOut"
|
|
395
|
+
},
|
|
396
|
+
style: { overflow: "hidden" },
|
|
397
|
+
children: e
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
function P(e, t) {
|
|
401
|
+
let n = k(e, t), r = [], i = 1, a = 1;
|
|
402
|
+
for (let e of n) {
|
|
403
|
+
let t = e.value.split("\n");
|
|
404
|
+
t.length && t[t.length - 1] === "" && t.pop();
|
|
405
|
+
for (let n of t) e.added ? r.push({
|
|
406
|
+
kind: "add",
|
|
407
|
+
text: n,
|
|
408
|
+
newNo: a++
|
|
409
|
+
}) : e.removed ? r.push({
|
|
410
|
+
kind: "del",
|
|
411
|
+
text: n,
|
|
412
|
+
oldNo: i++
|
|
413
|
+
}) : r.push({
|
|
414
|
+
kind: "context",
|
|
415
|
+
text: n,
|
|
416
|
+
oldNo: i++,
|
|
417
|
+
newNo: a++
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
return r;
|
|
421
|
+
}
|
|
422
|
+
function F(e) {
|
|
423
|
+
let t = [], n = [], r = [], i = 0, a = () => {
|
|
424
|
+
(n.length || r.length) && (t.push({
|
|
425
|
+
t: "chg",
|
|
426
|
+
dels: n,
|
|
427
|
+
adds: r,
|
|
428
|
+
index: i++
|
|
429
|
+
}), n = [], r = []);
|
|
430
|
+
};
|
|
431
|
+
for (let i of e) i.kind === "context" ? (a(), t.push({
|
|
432
|
+
t: "ctx",
|
|
433
|
+
row: i
|
|
434
|
+
})) : i.kind === "del" ? n.push(i) : r.push(i);
|
|
435
|
+
return a(), t;
|
|
436
|
+
}
|
|
437
|
+
function I(e, t) {
|
|
438
|
+
let n = D(e, t), r = [], a = [];
|
|
439
|
+
return n.forEach((e, t) => {
|
|
440
|
+
e.added ? a.push(/* @__PURE__ */ i("mark", {
|
|
441
|
+
className: "rounded-xs bg-success-4 text-success-11",
|
|
442
|
+
children: e.value
|
|
443
|
+
}, t)) : e.removed ? r.push(/* @__PURE__ */ i("mark", {
|
|
444
|
+
className: "rounded-xs bg-error-4 text-error-11 line-through decoration-error-11/40",
|
|
445
|
+
children: e.value
|
|
446
|
+
}, t)) : (r.push(/* @__PURE__ */ i("span", { children: e.value }, t)), a.push(/* @__PURE__ */ i("span", { children: e.value }, t)));
|
|
447
|
+
}), {
|
|
448
|
+
left: r,
|
|
449
|
+
right: a
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
function L({ added: t, removed: n, changes: r, className: o }) {
|
|
453
|
+
return /* @__PURE__ */ a("div", {
|
|
454
|
+
className: e("flex items-center gap-ds-03 text-body-sm font-sans", o),
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ a("span", {
|
|
457
|
+
className: "font-mono tabular-nums text-success-11",
|
|
458
|
+
children: ["+", t]
|
|
459
|
+
}),
|
|
460
|
+
/* @__PURE__ */ a("span", {
|
|
461
|
+
className: "font-mono tabular-nums text-error-11",
|
|
462
|
+
children: ["−", n]
|
|
463
|
+
}),
|
|
464
|
+
/* @__PURE__ */ i("span", {
|
|
465
|
+
className: "text-surface-fg-subtle",
|
|
466
|
+
children: r === 0 ? "No changes" : `${r} ${r === 1 ? "change" : "changes"}`
|
|
467
|
+
})
|
|
468
|
+
]
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
function R({ seg: e, onAccept: r, onReject: s }) {
|
|
472
|
+
if (!r && !s) return null;
|
|
473
|
+
let l = {
|
|
474
|
+
index: e.index,
|
|
475
|
+
before: e.dels.map((e) => e.text).join("\n"),
|
|
476
|
+
after: e.adds.map((e) => e.text).join("\n")
|
|
477
|
+
};
|
|
478
|
+
return /* @__PURE__ */ a("div", {
|
|
479
|
+
className: "flex items-center gap-ds-01",
|
|
480
|
+
children: [s && /* @__PURE__ */ i(n, {
|
|
481
|
+
variant: "ghost",
|
|
482
|
+
size: "icon-xs",
|
|
483
|
+
"aria-label": `Reject change ${e.index + 1}`,
|
|
484
|
+
onClick: () => s(l),
|
|
485
|
+
children: /* @__PURE__ */ i(t, {
|
|
486
|
+
icon: c,
|
|
487
|
+
size: "xs"
|
|
488
|
+
})
|
|
489
|
+
}), r && /* @__PURE__ */ i(n, {
|
|
490
|
+
variant: "ghost",
|
|
491
|
+
size: "icon-xs",
|
|
492
|
+
"aria-label": `Accept change ${e.index + 1}`,
|
|
493
|
+
onClick: () => r(l),
|
|
494
|
+
children: /* @__PURE__ */ i(t, {
|
|
495
|
+
icon: o,
|
|
496
|
+
size: "xs"
|
|
497
|
+
})
|
|
498
|
+
})]
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
var z = "select-none pl-ds-03 pr-ds-03 text-right font-mono text-caption tabular-nums text-surface-fg-subtle", B = "whitespace-pre-wrap break-words px-ds-03 font-mono text-body-sm leading-ds-relaxed", V = "select-none pl-ds-02 pr-ds-01 font-mono text-body-sm";
|
|
502
|
+
function H({ segs: n, collapsibles: r, expanded: o, onExpand: c, onAcceptHunk: l, onRejectHunk: u }) {
|
|
503
|
+
let d = !!l || !!u;
|
|
504
|
+
return /* @__PURE__ */ i("div", {
|
|
505
|
+
className: "min-w-full py-ds-02",
|
|
506
|
+
children: n.map((n, f) => {
|
|
507
|
+
if (n.t === "gap") {
|
|
508
|
+
let e = r.get(n.key) ?? [];
|
|
509
|
+
return o.has(n.key) ? /* @__PURE__ */ i(N, { children: e.map((e) => /* @__PURE__ */ i(U, {
|
|
510
|
+
row: e,
|
|
511
|
+
split: !1
|
|
512
|
+
}, `${n.key}-${e.oldNo}`)) }, `reveal-${n.key}`) : /* @__PURE__ */ a("button", {
|
|
513
|
+
type: "button",
|
|
514
|
+
onClick: () => c(n.key),
|
|
515
|
+
className: "flex w-full items-center gap-ds-02 border-y border-surface-border-subtle/30 bg-surface-raised-hover px-ds-03 py-ds-01 text-caption text-surface-fg-subtle hover:bg-surface-raised-active",
|
|
516
|
+
children: [
|
|
517
|
+
/* @__PURE__ */ i(t, {
|
|
518
|
+
icon: s,
|
|
519
|
+
size: "xs"
|
|
520
|
+
}),
|
|
521
|
+
"Expand ",
|
|
522
|
+
e.length,
|
|
523
|
+
" unchanged ",
|
|
524
|
+
e.length === 1 ? "line" : "lines"
|
|
525
|
+
]
|
|
526
|
+
}, `gap-${f}`);
|
|
527
|
+
}
|
|
528
|
+
return n.t === "ctx" ? /* @__PURE__ */ i(U, {
|
|
529
|
+
row: n.row,
|
|
530
|
+
split: !1
|
|
531
|
+
}, `c-${f}`) : /* @__PURE__ */ a("div", {
|
|
532
|
+
className: "group relative",
|
|
533
|
+
children: [
|
|
534
|
+
n.dels.map((t, n) => /* @__PURE__ */ a("div", {
|
|
535
|
+
className: "flex bg-error-3",
|
|
536
|
+
children: [
|
|
537
|
+
/* @__PURE__ */ i("span", {
|
|
538
|
+
className: e(z, "min-w-[3.5ch]"),
|
|
539
|
+
children: t.oldNo
|
|
540
|
+
}),
|
|
541
|
+
/* @__PURE__ */ i("span", { className: e(z, "min-w-[3.5ch] text-error-11/60") }),
|
|
542
|
+
/* @__PURE__ */ i("span", {
|
|
543
|
+
className: e(V, "text-error-11"),
|
|
544
|
+
children: "−"
|
|
545
|
+
}),
|
|
546
|
+
/* @__PURE__ */ i("span", {
|
|
547
|
+
className: e(B, "flex-1 text-error-11"),
|
|
548
|
+
children: t.text || "\xA0"
|
|
549
|
+
})
|
|
550
|
+
]
|
|
551
|
+
}, `d-${n}`)),
|
|
552
|
+
n.adds.map((t, n) => /* @__PURE__ */ a("div", {
|
|
553
|
+
className: "flex bg-success-3",
|
|
554
|
+
children: [
|
|
555
|
+
/* @__PURE__ */ i("span", { className: e(z, "min-w-[3.5ch] text-success-11/60") }),
|
|
556
|
+
/* @__PURE__ */ i("span", {
|
|
557
|
+
className: e(z, "min-w-[3.5ch]"),
|
|
558
|
+
children: t.newNo
|
|
559
|
+
}),
|
|
560
|
+
/* @__PURE__ */ i("span", {
|
|
561
|
+
className: e(V, "text-success-11"),
|
|
562
|
+
children: "+"
|
|
563
|
+
}),
|
|
564
|
+
/* @__PURE__ */ i("span", {
|
|
565
|
+
className: e(B, "flex-1 text-success-11"),
|
|
566
|
+
children: t.text || "\xA0"
|
|
567
|
+
})
|
|
568
|
+
]
|
|
569
|
+
}, `a-${n}`)),
|
|
570
|
+
d && /* @__PURE__ */ i("div", {
|
|
571
|
+
className: "absolute right-ds-02 top-ds-01 opacity-0 transition-opacity group-hover:opacity-100",
|
|
572
|
+
children: /* @__PURE__ */ i(R, {
|
|
573
|
+
seg: n,
|
|
574
|
+
onAccept: l,
|
|
575
|
+
onReject: u
|
|
576
|
+
})
|
|
577
|
+
})
|
|
578
|
+
]
|
|
579
|
+
}, `h-${f}`);
|
|
580
|
+
})
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
function U({ row: t, split: n }) {
|
|
584
|
+
return /* @__PURE__ */ a("div", {
|
|
585
|
+
className: "flex bg-surface-raised",
|
|
586
|
+
children: [
|
|
587
|
+
/* @__PURE__ */ i("span", {
|
|
588
|
+
className: e(z, "min-w-[3.5ch]"),
|
|
589
|
+
children: t.oldNo
|
|
590
|
+
}),
|
|
591
|
+
!n && /* @__PURE__ */ i("span", {
|
|
592
|
+
className: e(z, "min-w-[3.5ch]"),
|
|
593
|
+
children: t.newNo
|
|
594
|
+
}),
|
|
595
|
+
/* @__PURE__ */ i("span", {
|
|
596
|
+
className: e(V, "text-surface-fg-subtle"),
|
|
597
|
+
children: "\xA0"
|
|
598
|
+
}),
|
|
599
|
+
/* @__PURE__ */ i("span", {
|
|
600
|
+
className: e(B, "flex-1 text-surface-fg-muted"),
|
|
601
|
+
children: t.text || "\xA0"
|
|
602
|
+
})
|
|
603
|
+
]
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
function W({ segs: n, collapsibles: r, expanded: o, onExpand: c, onAcceptHunk: l, onRejectHunk: u }) {
|
|
607
|
+
let d = !!l || !!u, f = (t, n, r, o) => /* @__PURE__ */ a("div", {
|
|
608
|
+
className: e("flex flex-1 min-w-0", r),
|
|
609
|
+
children: [
|
|
610
|
+
/* @__PURE__ */ i("span", {
|
|
611
|
+
className: e(z, "min-w-[3.5ch]"),
|
|
612
|
+
children: t ?? ""
|
|
613
|
+
}),
|
|
614
|
+
/* @__PURE__ */ i("span", {
|
|
615
|
+
className: e(V),
|
|
616
|
+
children: o
|
|
617
|
+
}),
|
|
618
|
+
/* @__PURE__ */ i("span", {
|
|
619
|
+
className: e(B, "flex-1"),
|
|
620
|
+
children: n
|
|
621
|
+
})
|
|
622
|
+
]
|
|
623
|
+
});
|
|
624
|
+
return /* @__PURE__ */ i("div", {
|
|
625
|
+
className: "min-w-full py-ds-02",
|
|
626
|
+
children: n.map((e, n) => {
|
|
627
|
+
if (e.t === "gap") {
|
|
628
|
+
let l = r.get(e.key) ?? [];
|
|
629
|
+
return o.has(e.key) ? /* @__PURE__ */ i(N, { children: l.map((t) => /* @__PURE__ */ a("div", {
|
|
630
|
+
className: "flex divide-x divide-surface-border-subtle/30",
|
|
631
|
+
children: [f(t.oldNo, t.text || "\xA0", "bg-surface-raised text-surface-fg-muted", "\xA0"), f(t.newNo, t.text || "\xA0", "bg-surface-raised text-surface-fg-muted", "\xA0")]
|
|
632
|
+
}, `${e.key}-${t.oldNo}`)) }, `reveal-${e.key}`) : /* @__PURE__ */ a("button", {
|
|
633
|
+
type: "button",
|
|
634
|
+
onClick: () => c(e.key),
|
|
635
|
+
className: "flex w-full items-center gap-ds-02 border-y border-surface-border-subtle/30 bg-surface-raised-hover px-ds-03 py-ds-01 text-caption text-surface-fg-subtle hover:bg-surface-raised-active",
|
|
636
|
+
children: [
|
|
637
|
+
/* @__PURE__ */ i(t, {
|
|
638
|
+
icon: s,
|
|
639
|
+
size: "xs"
|
|
640
|
+
}),
|
|
641
|
+
"Expand ",
|
|
642
|
+
l.length,
|
|
643
|
+
" unchanged ",
|
|
644
|
+
l.length === 1 ? "line" : "lines"
|
|
645
|
+
]
|
|
646
|
+
}, `gap-${n}`);
|
|
647
|
+
}
|
|
648
|
+
if (e.t === "ctx") {
|
|
649
|
+
let t = e.row;
|
|
650
|
+
return /* @__PURE__ */ a("div", {
|
|
651
|
+
className: "flex divide-x divide-surface-border-subtle/30",
|
|
652
|
+
children: [f(t.oldNo, t.text || "\xA0", "bg-surface-raised text-surface-fg-muted", "\xA0"), f(t.newNo, t.text || "\xA0", "bg-surface-raised text-surface-fg-muted", "\xA0")]
|
|
653
|
+
}, `c-${n}`);
|
|
654
|
+
}
|
|
655
|
+
let p = Math.max(e.dels.length, e.adds.length);
|
|
656
|
+
return /* @__PURE__ */ a("div", {
|
|
657
|
+
className: "group relative",
|
|
658
|
+
children: [Array.from({ length: p }, (t, n) => {
|
|
659
|
+
let r = e.dels[n], i = e.adds[n], o = r ? r.text || "\xA0" : "", s = i ? i.text || "\xA0" : "";
|
|
660
|
+
if (r && i) {
|
|
661
|
+
let e = I(r.text, i.text);
|
|
662
|
+
o = e.left, s = e.right;
|
|
663
|
+
}
|
|
664
|
+
return /* @__PURE__ */ a("div", {
|
|
665
|
+
className: "flex divide-x divide-surface-border-subtle/30",
|
|
666
|
+
children: [r ? f(r.oldNo, o, "bg-error-3 text-error-11", "−") : f(void 0, "", "bg-surface-raised-hover/40", "\xA0"), i ? f(i.newNo, s, "bg-success-3 text-success-11", "+") : f(void 0, "", "bg-surface-raised-hover/40", "\xA0")]
|
|
667
|
+
}, `r-${n}`);
|
|
668
|
+
}), d && /* @__PURE__ */ i("div", {
|
|
669
|
+
className: "absolute right-ds-02 top-ds-01 opacity-0 transition-opacity group-hover:opacity-100",
|
|
670
|
+
children: /* @__PURE__ */ i(R, {
|
|
671
|
+
seg: e,
|
|
672
|
+
onAccept: l,
|
|
673
|
+
onReject: u
|
|
674
|
+
})
|
|
675
|
+
})]
|
|
676
|
+
}, `h-${n}`);
|
|
677
|
+
})
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
function te(e, t, n, r) {
|
|
681
|
+
let i = /* @__PURE__ */ new Map();
|
|
682
|
+
if (!t) return {
|
|
683
|
+
items: e,
|
|
684
|
+
collapsibles: i
|
|
685
|
+
};
|
|
686
|
+
let a = [], o = 0, s = 0;
|
|
687
|
+
for (; s < e.length;) {
|
|
688
|
+
let t = e[s];
|
|
689
|
+
if (t.t !== "ctx") {
|
|
690
|
+
a.push(t), s++;
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
let c = s, l = [];
|
|
694
|
+
for (; c < e.length && e[c].t === "ctx";) l.push(e[c].row), c++;
|
|
695
|
+
let u = s === 0, d = c === e.length;
|
|
696
|
+
if (l.length > n) {
|
|
697
|
+
let e = u ? 0 : r, t = d ? 0 : r, n = l.slice(e, l.length - t);
|
|
698
|
+
if (l.slice(0, e).forEach((e) => a.push({
|
|
699
|
+
t: "ctx",
|
|
700
|
+
row: e
|
|
701
|
+
})), n.length > 0) {
|
|
702
|
+
let e = o++;
|
|
703
|
+
i.set(e, n), a.push({
|
|
704
|
+
t: "gap",
|
|
705
|
+
key: e
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
l.slice(l.length - t).forEach((e) => a.push({
|
|
709
|
+
t: "ctx",
|
|
710
|
+
row: e
|
|
711
|
+
}));
|
|
712
|
+
} else l.forEach((e) => a.push({
|
|
713
|
+
t: "ctx",
|
|
714
|
+
row: e
|
|
715
|
+
}));
|
|
716
|
+
s = c;
|
|
717
|
+
}
|
|
718
|
+
return {
|
|
719
|
+
items: a,
|
|
720
|
+
collapsibles: i
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
function ne({ before: e, after: t }) {
|
|
724
|
+
return /* @__PURE__ */ i("div", {
|
|
725
|
+
className: "whitespace-pre-wrap break-words px-ds-04 py-ds-03 font-sans text-body-md leading-ds-relaxed text-surface-fg bg-surface-raised",
|
|
726
|
+
children: D(e, t).map((e, t) => e.added ? /* @__PURE__ */ i("mark", {
|
|
727
|
+
className: "rounded-xs bg-success-4 text-success-11",
|
|
728
|
+
children: e.value
|
|
729
|
+
}, t) : e.removed ? /* @__PURE__ */ i("mark", {
|
|
730
|
+
className: "rounded-xs bg-error-4 text-error-11 line-through decoration-error-11/40",
|
|
731
|
+
children: e.value
|
|
732
|
+
}, t) : /* @__PURE__ */ i("span", { children: e.value }, t))
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
function G(e, t = "", n = {}) {
|
|
736
|
+
if (typeof e != "object" || !e) return n[t || "(root)"] = e === void 0 ? "" : JSON.stringify(e), n;
|
|
737
|
+
if (Array.isArray(e)) return e.forEach((e, r) => G(e, t ? `${t}[${r}]` : `[${r}]`, n)), n;
|
|
738
|
+
for (let [r, i] of Object.entries(e)) G(i, t ? `${t}.${r}` : r, n);
|
|
739
|
+
return n;
|
|
740
|
+
}
|
|
741
|
+
function K(e, t) {
|
|
742
|
+
let n, r;
|
|
743
|
+
try {
|
|
744
|
+
n = JSON.parse(e), r = JSON.parse(t);
|
|
745
|
+
} catch {
|
|
746
|
+
return {
|
|
747
|
+
changes: [],
|
|
748
|
+
error: "Fields mode needs valid JSON on both sides."
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
let i = G(n), a = G(r), o = Array.from(/* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(a)])).sort(), s = [];
|
|
752
|
+
for (let e of o) {
|
|
753
|
+
let t = e in i, n = e in a;
|
|
754
|
+
t && !n ? s.push({
|
|
755
|
+
path: e,
|
|
756
|
+
kind: "removed",
|
|
757
|
+
before: i[e]
|
|
758
|
+
}) : !t && n ? s.push({
|
|
759
|
+
path: e,
|
|
760
|
+
kind: "added",
|
|
761
|
+
after: a[e]
|
|
762
|
+
}) : i[e] !== a[e] && s.push({
|
|
763
|
+
path: e,
|
|
764
|
+
kind: "changed",
|
|
765
|
+
before: i[e],
|
|
766
|
+
after: a[e]
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
return {
|
|
770
|
+
changes: s,
|
|
771
|
+
error: null
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
function re({ before: t, after: n, onAcceptHunk: o, onRejectHunk: s }) {
|
|
775
|
+
let { changes: c, error: l } = r.useMemo(() => K(t, n), [t, n]), u = !!o || !!s;
|
|
776
|
+
if (l) return /* @__PURE__ */ i("div", {
|
|
777
|
+
className: "bg-surface-raised px-ds-04 py-ds-03 text-body-sm text-error-11",
|
|
778
|
+
children: l
|
|
779
|
+
});
|
|
780
|
+
if (c.length === 0) return /* @__PURE__ */ i("div", {
|
|
781
|
+
className: "bg-surface-raised px-ds-04 py-ds-03 text-body-sm text-surface-fg-subtle",
|
|
782
|
+
children: "No field changes."
|
|
783
|
+
});
|
|
784
|
+
let d = {
|
|
785
|
+
added: "text-success-11",
|
|
786
|
+
removed: "text-error-11",
|
|
787
|
+
changed: "text-surface-fg"
|
|
788
|
+
};
|
|
789
|
+
return /* @__PURE__ */ i("div", {
|
|
790
|
+
className: "divide-y divide-surface-border-subtle/30 bg-surface-raised",
|
|
791
|
+
children: c.map((t, n) => /* @__PURE__ */ a("div", {
|
|
792
|
+
className: "group flex items-start gap-ds-03 px-ds-04 py-ds-03",
|
|
793
|
+
children: [
|
|
794
|
+
/* @__PURE__ */ i("span", {
|
|
795
|
+
className: e("mt-[2px] shrink-0 text-body-xs font-medium", d[t.kind]),
|
|
796
|
+
children: t.kind === "added" ? "Added" : t.kind === "removed" ? "Removed" : "Changed"
|
|
797
|
+
}),
|
|
798
|
+
/* @__PURE__ */ a("div", {
|
|
799
|
+
className: "min-w-0 flex-1",
|
|
800
|
+
children: [/* @__PURE__ */ i("div", {
|
|
801
|
+
className: "font-mono text-body-sm font-medium text-surface-fg",
|
|
802
|
+
children: t.path
|
|
803
|
+
}), /* @__PURE__ */ a("div", {
|
|
804
|
+
className: "mt-ds-01 flex flex-col gap-ds-01 font-mono text-body-sm",
|
|
805
|
+
children: [t.before !== void 0 && /* @__PURE__ */ a("span", {
|
|
806
|
+
className: "text-error-11",
|
|
807
|
+
children: [/* @__PURE__ */ i("span", {
|
|
808
|
+
className: "select-none pr-ds-02",
|
|
809
|
+
children: "−"
|
|
810
|
+
}), t.before]
|
|
811
|
+
}), t.after !== void 0 && /* @__PURE__ */ a("span", {
|
|
812
|
+
className: "text-success-11",
|
|
813
|
+
children: [/* @__PURE__ */ i("span", {
|
|
814
|
+
className: "select-none pr-ds-02",
|
|
815
|
+
children: "+"
|
|
816
|
+
}), t.after]
|
|
817
|
+
})]
|
|
818
|
+
})]
|
|
819
|
+
}),
|
|
820
|
+
u && /* @__PURE__ */ i("div", {
|
|
821
|
+
className: "opacity-0 transition-opacity group-hover:opacity-100",
|
|
822
|
+
children: /* @__PURE__ */ i(R, {
|
|
823
|
+
seg: {
|
|
824
|
+
t: "chg",
|
|
825
|
+
index: n,
|
|
826
|
+
dels: t.before === void 0 ? [] : [{
|
|
827
|
+
kind: "del",
|
|
828
|
+
text: t.before
|
|
829
|
+
}],
|
|
830
|
+
adds: t.after === void 0 ? [] : [{
|
|
831
|
+
kind: "add",
|
|
832
|
+
text: t.after
|
|
833
|
+
}]
|
|
834
|
+
},
|
|
835
|
+
onAccept: o,
|
|
836
|
+
onReject: s
|
|
837
|
+
})
|
|
838
|
+
})
|
|
839
|
+
]
|
|
840
|
+
}, t.path))
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
var q = r.createContext(null);
|
|
844
|
+
function J() {
|
|
845
|
+
let e = r.useContext(q);
|
|
846
|
+
if (!e) throw Error("Diff compound components must be used within <Diff.Root>");
|
|
847
|
+
return e;
|
|
848
|
+
}
|
|
849
|
+
function Y({ before: e, after: t, mode: n = "inline", granularity: a = "line", collapseUnchanged: o = !0, collapseThreshold: s = 6, contextLines: c = 3, beforeLabel: l = "Committed", afterLabel: u = "Pending", onAcceptHunk: d, onRejectHunk: f, children: p }) {
|
|
850
|
+
let [m, h] = r.useState(() => /* @__PURE__ */ new Set()), g = r.useCallback((e) => {
|
|
851
|
+
h((t) => new Set(t).add(e));
|
|
852
|
+
}, []), _ = a === "word" && n !== "fields", v = r.useMemo(() => {
|
|
853
|
+
if (n === "fields") {
|
|
854
|
+
let { changes: n } = K(e, t);
|
|
855
|
+
return {
|
|
856
|
+
rows: [],
|
|
857
|
+
added: n.filter((e) => e.kind === "added").length,
|
|
858
|
+
removed: n.filter((e) => e.kind === "removed").length,
|
|
859
|
+
changeCount: n.length
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
if (_) {
|
|
863
|
+
let n = D(e, t), r = 0, i = 0, a = 0;
|
|
864
|
+
for (let e of n) {
|
|
865
|
+
if (!e.added && !e.removed) continue;
|
|
866
|
+
a += 1;
|
|
867
|
+
let t = e.value.trim() ? e.value.trim().split(/\s+/).length : 0;
|
|
868
|
+
e.added ? r += t : i += t;
|
|
869
|
+
}
|
|
870
|
+
return {
|
|
871
|
+
rows: [],
|
|
872
|
+
added: r,
|
|
873
|
+
removed: i,
|
|
874
|
+
changeCount: a
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
let r = P(e, t), i = F(r);
|
|
878
|
+
return {
|
|
879
|
+
rows: r,
|
|
880
|
+
added: r.filter((e) => e.kind === "add").length,
|
|
881
|
+
removed: r.filter((e) => e.kind === "del").length,
|
|
882
|
+
changeCount: i.filter((e) => e.t === "chg").length
|
|
883
|
+
};
|
|
884
|
+
}, [
|
|
885
|
+
e,
|
|
886
|
+
t,
|
|
887
|
+
n,
|
|
888
|
+
_
|
|
889
|
+
]), { items: y, collapsibles: b } = r.useMemo(() => te(v.rows.length ? F(v.rows) : [], o && !_, s, c), [
|
|
890
|
+
v.rows,
|
|
891
|
+
o,
|
|
892
|
+
_,
|
|
893
|
+
s,
|
|
894
|
+
c
|
|
895
|
+
]), x = {
|
|
896
|
+
mode: n,
|
|
897
|
+
granularity: a,
|
|
898
|
+
isWord: _,
|
|
899
|
+
before: e,
|
|
900
|
+
after: t,
|
|
901
|
+
beforeLabel: l,
|
|
902
|
+
afterLabel: u,
|
|
903
|
+
added: v.added,
|
|
904
|
+
removed: v.removed,
|
|
905
|
+
changeCount: v.changeCount,
|
|
906
|
+
items: y,
|
|
907
|
+
collapsibles: b,
|
|
908
|
+
expanded: m,
|
|
909
|
+
onExpand: g,
|
|
910
|
+
onAcceptHunk: d,
|
|
911
|
+
onRejectHunk: f
|
|
912
|
+
};
|
|
913
|
+
return /* @__PURE__ */ i(q.Provider, {
|
|
914
|
+
value: x,
|
|
915
|
+
children: p
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
function X({ className: e }) {
|
|
919
|
+
let { added: t, removed: n, changeCount: r } = J();
|
|
920
|
+
return /* @__PURE__ */ i(L, {
|
|
921
|
+
added: t,
|
|
922
|
+
removed: n,
|
|
923
|
+
changes: r,
|
|
924
|
+
className: e
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
function Z({ className: t }) {
|
|
928
|
+
let { mode: n, beforeLabel: r, afterLabel: o } = J();
|
|
929
|
+
return n === "split" ? /* @__PURE__ */ a("div", {
|
|
930
|
+
className: e("flex gap-ds-04 text-label-xs font-semibold uppercase tracking-wide text-surface-fg-subtle", t),
|
|
931
|
+
children: [/* @__PURE__ */ i("span", {
|
|
932
|
+
className: "flex-1",
|
|
933
|
+
children: r
|
|
934
|
+
}), /* @__PURE__ */ i("span", {
|
|
935
|
+
className: "flex-1",
|
|
936
|
+
children: o
|
|
937
|
+
})]
|
|
938
|
+
}) : null;
|
|
939
|
+
}
|
|
940
|
+
function Q({ className: t }) {
|
|
941
|
+
let n = J();
|
|
942
|
+
return /* @__PURE__ */ i("div", {
|
|
943
|
+
className: e("overflow-x-auto", t),
|
|
944
|
+
children: n.mode === "fields" ? /* @__PURE__ */ i(re, {
|
|
945
|
+
before: n.before,
|
|
946
|
+
after: n.after,
|
|
947
|
+
onAcceptHunk: n.onAcceptHunk,
|
|
948
|
+
onRejectHunk: n.onRejectHunk
|
|
949
|
+
}) : n.isWord ? /* @__PURE__ */ i(ne, {
|
|
950
|
+
before: n.before,
|
|
951
|
+
after: n.after
|
|
952
|
+
}) : n.mode === "split" ? /* @__PURE__ */ i(W, {
|
|
953
|
+
segs: n.items,
|
|
954
|
+
collapsibles: n.collapsibles,
|
|
955
|
+
expanded: n.expanded,
|
|
956
|
+
onExpand: n.onExpand,
|
|
957
|
+
onAcceptHunk: n.onAcceptHunk,
|
|
958
|
+
onRejectHunk: n.onRejectHunk
|
|
959
|
+
}) : /* @__PURE__ */ i(H, {
|
|
960
|
+
segs: n.items,
|
|
961
|
+
collapsibles: n.collapsibles,
|
|
962
|
+
expanded: n.expanded,
|
|
963
|
+
onExpand: n.onExpand,
|
|
964
|
+
onAcceptHunk: n.onAcceptHunk,
|
|
965
|
+
onRejectHunk: n.onRejectHunk
|
|
966
|
+
})
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
var $ = r.forwardRef(function({ before: t, after: n, mode: r = "inline", granularity: o = "line", collapseUnchanged: s = !0, collapseThreshold: c = 6, contextLines: l = 3, showSummary: u = !0, beforeLabel: d = "Committed", afterLabel: f = "Pending", onAcceptHunk: p, onRejectHunk: m, className: h, ...g }, _) {
|
|
970
|
+
return /* @__PURE__ */ i("div", {
|
|
971
|
+
ref: _,
|
|
972
|
+
className: e("overflow-hidden rounded-surface border border-card bg-surface-raised text-surface-fg", h),
|
|
973
|
+
...g,
|
|
974
|
+
children: /* @__PURE__ */ a(Y, {
|
|
975
|
+
before: t,
|
|
976
|
+
after: n,
|
|
977
|
+
mode: r,
|
|
978
|
+
granularity: o,
|
|
979
|
+
collapseUnchanged: s,
|
|
980
|
+
collapseThreshold: c,
|
|
981
|
+
contextLines: l,
|
|
982
|
+
beforeLabel: d,
|
|
983
|
+
afterLabel: f,
|
|
984
|
+
onAcceptHunk: p,
|
|
985
|
+
onRejectHunk: m,
|
|
986
|
+
children: [(u || r === "split") && /* @__PURE__ */ a("div", {
|
|
987
|
+
className: "flex items-center justify-between gap-ds-03 border-b border-surface-border-subtle/30 bg-surface-raised px-ds-04 py-ds-02",
|
|
988
|
+
children: [r === "split" ? /* @__PURE__ */ i(Z, { className: "flex-1" }) : /* @__PURE__ */ i("span", {
|
|
989
|
+
className: "text-body-sm font-medium text-surface-fg-subtle",
|
|
990
|
+
children: "Changes"
|
|
991
|
+
}), u && /* @__PURE__ */ i(X, {})]
|
|
992
|
+
}), /* @__PURE__ */ i(Q, {})]
|
|
993
|
+
})
|
|
994
|
+
});
|
|
995
|
+
});
|
|
996
|
+
$.displayName = "Diff";
|
|
997
|
+
var ie = Object.assign($, {
|
|
998
|
+
Root: Y,
|
|
999
|
+
Summary: X,
|
|
1000
|
+
Body: Q,
|
|
1001
|
+
ColumnLabels: Z
|
|
1002
|
+
});
|
|
1003
|
+
//#endregion
|
|
1004
|
+
export { ie as Diff, Q as DiffBody, Z as DiffColumnLabels, Y as DiffRoot, X as DiffSummary, J as useDiff };
|