@consilioweb/payload-support 0.6.2 → 0.6.4

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 (94) hide show
  1. package/dist/components/TicketConversation/components/AISummaryPanel.cjs +77 -0
  2. package/dist/components/TicketConversation/components/AISummaryPanel.js +76 -0
  3. package/dist/components/TicketConversation/components/ActionPanels.cjs +121 -0
  4. package/dist/components/TicketConversation/components/ActionPanels.js +118 -0
  5. package/dist/components/TicketConversation/components/ActivityLog.cjs +24 -0
  6. package/dist/components/TicketConversation/components/ActivityLog.js +23 -0
  7. package/dist/components/TicketConversation/components/ClientBar.cjs +43 -0
  8. package/dist/components/TicketConversation/components/ClientBar.js +42 -0
  9. package/dist/components/TicketConversation/components/ClientHistory.cjs +138 -0
  10. package/dist/components/TicketConversation/components/ClientHistory.js +137 -0
  11. package/dist/components/TicketConversation/components/CodeBlock.cjs +154 -0
  12. package/dist/components/TicketConversation/components/CodeBlock.js +152 -0
  13. package/dist/components/TicketConversation/components/CodeBlockInserter.cjs +156 -0
  14. package/dist/components/TicketConversation/components/CodeBlockInserter.js +155 -0
  15. package/dist/components/TicketConversation/components/QuickActions.cjs +66 -0
  16. package/dist/components/TicketConversation/components/QuickActions.js +65 -0
  17. package/dist/components/TicketConversation/components/TicketHeader.cjs +93 -0
  18. package/dist/components/TicketConversation/components/TicketHeader.js +92 -0
  19. package/dist/components/TicketConversation/components/TimeTrackingPanel.cjs +134 -0
  20. package/dist/components/TicketConversation/components/TimeTrackingPanel.js +133 -0
  21. package/dist/components/TicketConversation/config.cjs +44 -0
  22. package/dist/components/TicketConversation/config.js +41 -0
  23. package/dist/components/TicketConversation/constants.cjs +100 -0
  24. package/dist/components/TicketConversation/constants.js +96 -0
  25. package/dist/components/TicketConversation/context.cjs +13 -0
  26. package/dist/components/TicketConversation/context.js +11 -0
  27. package/dist/components/TicketConversation/hooks/useAI.cjs +177 -0
  28. package/dist/components/TicketConversation/hooks/useAI.js +176 -0
  29. package/dist/components/TicketConversation/hooks/useMessageActions.cjs +136 -0
  30. package/dist/components/TicketConversation/hooks/useMessageActions.js +135 -0
  31. package/dist/components/TicketConversation/hooks/useReply.cjs +188 -0
  32. package/dist/components/TicketConversation/hooks/useReply.js +187 -0
  33. package/dist/components/TicketConversation/hooks/useTicketActions.cjs +231 -0
  34. package/dist/components/TicketConversation/hooks/useTicketActions.js +230 -0
  35. package/dist/components/TicketConversation/hooks/useTimeTracking.cjs +123 -0
  36. package/dist/components/TicketConversation/hooks/useTimeTracking.js +122 -0
  37. package/dist/components/TicketConversation/hooks/useTranslation.cjs +78 -0
  38. package/dist/components/TicketConversation/hooks/useTranslation.js +70 -0
  39. package/dist/components/TicketConversation/index.cjs +1128 -0
  40. package/dist/components/TicketConversation/index.js +1123 -0
  41. package/dist/components/TicketConversation/locales/en.json +878 -0
  42. package/dist/components/TicketConversation/locales/fr.json +878 -0
  43. package/dist/components/TicketConversation/types.cjs +2 -0
  44. package/dist/components/TicketConversation/types.js +2 -0
  45. package/dist/components/TicketConversation/utils.cjs +27 -0
  46. package/dist/components/TicketConversation/utils.js +25 -0
  47. package/dist/styles/BillingView.module.scss +311 -0
  48. package/dist/styles/ChatView.module.scss +438 -0
  49. package/dist/styles/CommandPalette.module.scss +160 -0
  50. package/dist/styles/CrmView.module.scss +554 -0
  51. package/dist/styles/EmailTracking.module.scss +238 -0
  52. package/dist/styles/ImportConversation.module.scss +267 -0
  53. package/dist/styles/Layout.module.scss +55 -0
  54. package/dist/styles/Logs.module.scss +164 -0
  55. package/dist/styles/NewTicket.module.scss +143 -0
  56. package/dist/styles/PendingEmails.module.scss +629 -0
  57. package/dist/styles/SupportDashboard.module.scss +649 -0
  58. package/dist/styles/TicketDetail.module.scss +1050 -0
  59. package/dist/styles/TicketInbox.module.scss +296 -0
  60. package/dist/styles/TicketingSettings.module.scss +358 -0
  61. package/dist/styles/TimeDashboard.module.scss +287 -0
  62. package/dist/styles/_tokens.scss +78 -0
  63. package/dist/{components/TicketConversation.css → styles/theme.css} +326 -13
  64. package/dist/views/BillingView/client.js +1 -1
  65. package/dist/views/BillingView/index.js +2 -2
  66. package/dist/views/ChatView/client.js +1 -1
  67. package/dist/views/ChatView/index.js +2 -2
  68. package/dist/views/CrmView/client.js +1 -1
  69. package/dist/views/CrmView/index.js +2 -2
  70. package/dist/views/EmailTrackingView/client.js +1 -1
  71. package/dist/views/EmailTrackingView/index.js +2 -2
  72. package/dist/views/ImportConversationView/client.js +1 -1
  73. package/dist/views/ImportConversationView/index.js +2 -2
  74. package/dist/views/LogsView/client.js +1 -1
  75. package/dist/views/LogsView/index.js +2 -2
  76. package/dist/views/NewTicketView/client.js +1 -1
  77. package/dist/views/NewTicketView/index.js +2 -2
  78. package/dist/views/PendingEmailsView/client.js +1 -1
  79. package/dist/views/PendingEmailsView/index.js +2 -2
  80. package/dist/views/SupportDashboardView/client.js +1 -1
  81. package/dist/views/SupportDashboardView/index.js +2 -2
  82. package/dist/views/TicketDetailView/client.js +2 -2
  83. package/dist/views/TicketDetailView/index.js +2 -2
  84. package/dist/views/TicketInboxView/client.js +1 -1
  85. package/dist/views/TicketInboxView/index.js +2 -2
  86. package/dist/views/TicketingSettingsView/client.js +3 -3
  87. package/dist/views/TicketingSettingsView/index.js +2 -2
  88. package/dist/views/TimeDashboardView/client.js +1 -1
  89. package/dist/views/TimeDashboardView/index.js +2 -2
  90. package/dist/views/shared/AdminViewHeader.js +1 -1
  91. package/dist/views/shared/index.js +5 -5
  92. package/dist/views.js +13 -13
  93. package/package.json +2 -2
  94. package/dist/components/TicketConversation.js +0 -3004
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ var constants = require('../constants');
6
+
7
+ function ClientHistory({
8
+ client: _client,
9
+ clientTickets,
10
+ clientProjects,
11
+ clientNotes,
12
+ onNotesChange,
13
+ onNotesSave,
14
+ savingNotes,
15
+ notesSaved
16
+ }) {
17
+ const [showClientHistory, setShowClientHistory] = react.useState(false);
18
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: constants.s.section, children: [
19
+ /* @__PURE__ */ jsxRuntime.jsxs(
20
+ "button",
21
+ {
22
+ type: "button",
23
+ onClick: () => setShowClientHistory(!showClientHistory),
24
+ style: {
25
+ background: "none",
26
+ border: `1px dashed ${constants.C.border}`,
27
+ borderRadius: "6px",
28
+ padding: "8px 14px",
29
+ cursor: "pointer",
30
+ color: constants.C.textSecondary,
31
+ fontSize: "13px",
32
+ fontWeight: 600,
33
+ width: "100%",
34
+ textAlign: "left",
35
+ display: "flex",
36
+ alignItems: "center",
37
+ justifyContent: "space-between"
38
+ },
39
+ children: [
40
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
41
+ "Historique client (",
42
+ clientTickets.length,
43
+ " ticket",
44
+ clientTickets.length !== 1 ? "s" : "",
45
+ ", ",
46
+ clientProjects.length,
47
+ " projet",
48
+ clientProjects.length !== 1 ? "s" : "",
49
+ ")"
50
+ ] }),
51
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "12px", transition: "transform 0.2s", display: "inline-block", transform: showClientHistory ? "rotate(90deg)" : "none" }, children: "\u25B6" })
52
+ ]
53
+ }
54
+ ),
55
+ showClientHistory && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "10px", padding: "14px 18px", borderRadius: "8px", backgroundColor: constants.C.white, border: `1px solid ${constants.C.border}` }, children: [
56
+ /* @__PURE__ */ jsxRuntime.jsx("h5", { style: { fontSize: "12px", fontWeight: 600, color: constants.C.textSecondary, marginBottom: "8px" }, children: "Derniers tickets" }),
57
+ clientTickets.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "12px", color: constants.C.textMuted, fontStyle: "italic", marginBottom: "14px" }, children: "Aucun autre ticket" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexDirection: "column", gap: "4px", marginBottom: "14px" }, children: clientTickets.map((t) => {
58
+ const st = constants.statusLabels[t.status] || constants.statusLabels.open;
59
+ return /* @__PURE__ */ jsxRuntime.jsxs(
60
+ "a",
61
+ {
62
+ href: `/admin/support/ticket?id=${t.id}`,
63
+ style: {
64
+ display: "flex",
65
+ alignItems: "center",
66
+ gap: "8px",
67
+ padding: "6px 10px",
68
+ borderRadius: "6px",
69
+ border: `1px solid ${constants.C.border}`,
70
+ textDecoration: "none",
71
+ fontSize: "12px",
72
+ color: "#374151",
73
+ backgroundColor: "#fafafa"
74
+ },
75
+ children: [
76
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontFamily: "'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace", fontWeight: 600, color: constants.C.textMuted, fontSize: "11px", whiteSpace: "nowrap" }, children: t.ticketNumber }),
77
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: 600 }, children: t.subject }),
78
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: constants.s.badge(st.bg, st.color), children: st.label }),
79
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "10px", color: constants.C.textMuted, whiteSpace: "nowrap" }, children: new Date(t.createdAt).toLocaleDateString("fr-FR", { day: "numeric", month: "short" }) })
80
+ ]
81
+ },
82
+ t.id
83
+ );
84
+ }) }),
85
+ /* @__PURE__ */ jsxRuntime.jsx("h5", { style: { fontSize: "12px", fontWeight: 600, color: constants.C.textSecondary, marginBottom: "8px" }, children: "Projets" }),
86
+ clientProjects.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "12px", color: constants.C.textMuted, fontStyle: "italic", marginBottom: "14px" }, children: "Aucun projet" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap", marginBottom: "14px" }, children: clientProjects.map((p) => {
87
+ const ps = constants.projectStatusLabels[p.status] || constants.projectStatusLabels.active;
88
+ return /* @__PURE__ */ jsxRuntime.jsxs(
89
+ "a",
90
+ {
91
+ href: `/admin/collections/projects/${p.id}`,
92
+ style: {
93
+ display: "inline-flex",
94
+ alignItems: "center",
95
+ gap: "6px",
96
+ padding: "5px 10px",
97
+ borderRadius: "6px",
98
+ border: `1px solid ${constants.C.border}`,
99
+ textDecoration: "none",
100
+ fontSize: "12px",
101
+ fontWeight: 600,
102
+ color: "#374151",
103
+ backgroundColor: "#fafafa"
104
+ },
105
+ children: [
106
+ p.name,
107
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: constants.s.badge(ps.bg, ps.color), children: ps.label })
108
+ ]
109
+ },
110
+ p.id
111
+ );
112
+ }) }),
113
+ /* @__PURE__ */ jsxRuntime.jsx("h5", { style: { fontSize: "12px", fontWeight: 600, color: constants.C.textSecondary, marginBottom: "8px" }, children: "Notes internes" }),
114
+ /* @__PURE__ */ jsxRuntime.jsx(
115
+ "textarea",
116
+ {
117
+ value: clientNotes,
118
+ onChange: (e) => onNotesChange(e.target.value),
119
+ rows: 3,
120
+ style: { ...constants.s.input, width: "100%", resize: "vertical", fontSize: "12px", marginBottom: "8px" },
121
+ placeholder: "Notes sur ce client..."
122
+ }
123
+ ),
124
+ /* @__PURE__ */ jsxRuntime.jsx(
125
+ "button",
126
+ {
127
+ type: "button",
128
+ onClick: onNotesSave,
129
+ disabled: savingNotes,
130
+ style: { ...constants.s.btn(notesSaved ? "#16a34a" : constants.C.blue, savingNotes), fontSize: "11px", padding: "5px 12px" },
131
+ children: notesSaved ? "Sauvegarde OK" : savingNotes ? "Sauvegarde..." : "Sauvegarder les notes"
132
+ }
133
+ )
134
+ ] })
135
+ ] });
136
+ }
137
+
138
+ exports.ClientHistory = ClientHistory;
@@ -0,0 +1,137 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+ import { s, C, statusLabels, projectStatusLabels } from '../constants.js';
5
+
6
+ function ClientHistory({
7
+ client: _client,
8
+ clientTickets,
9
+ clientProjects,
10
+ clientNotes,
11
+ onNotesChange,
12
+ onNotesSave,
13
+ savingNotes,
14
+ notesSaved
15
+ }) {
16
+ const [showClientHistory, setShowClientHistory] = useState(false);
17
+ return /* @__PURE__ */ jsxs("div", { style: s.section, children: [
18
+ /* @__PURE__ */ jsxs(
19
+ "button",
20
+ {
21
+ type: "button",
22
+ onClick: () => setShowClientHistory(!showClientHistory),
23
+ style: {
24
+ background: "none",
25
+ border: `1px dashed ${C.border}`,
26
+ borderRadius: "6px",
27
+ padding: "8px 14px",
28
+ cursor: "pointer",
29
+ color: C.textSecondary,
30
+ fontSize: "13px",
31
+ fontWeight: 600,
32
+ width: "100%",
33
+ textAlign: "left",
34
+ display: "flex",
35
+ alignItems: "center",
36
+ justifyContent: "space-between"
37
+ },
38
+ children: [
39
+ /* @__PURE__ */ jsxs("span", { children: [
40
+ "Historique client (",
41
+ clientTickets.length,
42
+ " ticket",
43
+ clientTickets.length !== 1 ? "s" : "",
44
+ ", ",
45
+ clientProjects.length,
46
+ " projet",
47
+ clientProjects.length !== 1 ? "s" : "",
48
+ ")"
49
+ ] }),
50
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "12px", transition: "transform 0.2s", display: "inline-block", transform: showClientHistory ? "rotate(90deg)" : "none" }, children: "\u25B6" })
51
+ ]
52
+ }
53
+ ),
54
+ showClientHistory && /* @__PURE__ */ jsxs("div", { style: { marginTop: "10px", padding: "14px 18px", borderRadius: "8px", backgroundColor: C.white, border: `1px solid ${C.border}` }, children: [
55
+ /* @__PURE__ */ jsx("h5", { style: { fontSize: "12px", fontWeight: 600, color: C.textSecondary, marginBottom: "8px" }, children: "Derniers tickets" }),
56
+ clientTickets.length === 0 ? /* @__PURE__ */ jsx("p", { style: { fontSize: "12px", color: C.textMuted, fontStyle: "italic", marginBottom: "14px" }, children: "Aucun autre ticket" }) : /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: "4px", marginBottom: "14px" }, children: clientTickets.map((t) => {
57
+ const st = statusLabels[t.status] || statusLabels.open;
58
+ return /* @__PURE__ */ jsxs(
59
+ "a",
60
+ {
61
+ href: `/admin/support/ticket?id=${t.id}`,
62
+ style: {
63
+ display: "flex",
64
+ alignItems: "center",
65
+ gap: "8px",
66
+ padding: "6px 10px",
67
+ borderRadius: "6px",
68
+ border: `1px solid ${C.border}`,
69
+ textDecoration: "none",
70
+ fontSize: "12px",
71
+ color: "#374151",
72
+ backgroundColor: "#fafafa"
73
+ },
74
+ children: [
75
+ /* @__PURE__ */ jsx("span", { style: { fontFamily: "'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace", fontWeight: 600, color: C.textMuted, fontSize: "11px", whiteSpace: "nowrap" }, children: t.ticketNumber }),
76
+ /* @__PURE__ */ jsx("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: 600 }, children: t.subject }),
77
+ /* @__PURE__ */ jsx("span", { style: s.badge(st.bg, st.color), children: st.label }),
78
+ /* @__PURE__ */ jsx("span", { style: { fontSize: "10px", color: C.textMuted, whiteSpace: "nowrap" }, children: new Date(t.createdAt).toLocaleDateString("fr-FR", { day: "numeric", month: "short" }) })
79
+ ]
80
+ },
81
+ t.id
82
+ );
83
+ }) }),
84
+ /* @__PURE__ */ jsx("h5", { style: { fontSize: "12px", fontWeight: 600, color: C.textSecondary, marginBottom: "8px" }, children: "Projets" }),
85
+ clientProjects.length === 0 ? /* @__PURE__ */ jsx("p", { style: { fontSize: "12px", color: C.textMuted, fontStyle: "italic", marginBottom: "14px" }, children: "Aucun projet" }) : /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap", marginBottom: "14px" }, children: clientProjects.map((p) => {
86
+ const ps = projectStatusLabels[p.status] || projectStatusLabels.active;
87
+ return /* @__PURE__ */ jsxs(
88
+ "a",
89
+ {
90
+ href: `/admin/collections/projects/${p.id}`,
91
+ style: {
92
+ display: "inline-flex",
93
+ alignItems: "center",
94
+ gap: "6px",
95
+ padding: "5px 10px",
96
+ borderRadius: "6px",
97
+ border: `1px solid ${C.border}`,
98
+ textDecoration: "none",
99
+ fontSize: "12px",
100
+ fontWeight: 600,
101
+ color: "#374151",
102
+ backgroundColor: "#fafafa"
103
+ },
104
+ children: [
105
+ p.name,
106
+ /* @__PURE__ */ jsx("span", { style: s.badge(ps.bg, ps.color), children: ps.label })
107
+ ]
108
+ },
109
+ p.id
110
+ );
111
+ }) }),
112
+ /* @__PURE__ */ jsx("h5", { style: { fontSize: "12px", fontWeight: 600, color: C.textSecondary, marginBottom: "8px" }, children: "Notes internes" }),
113
+ /* @__PURE__ */ jsx(
114
+ "textarea",
115
+ {
116
+ value: clientNotes,
117
+ onChange: (e) => onNotesChange(e.target.value),
118
+ rows: 3,
119
+ style: { ...s.input, width: "100%", resize: "vertical", fontSize: "12px", marginBottom: "8px" },
120
+ placeholder: "Notes sur ce client..."
121
+ }
122
+ ),
123
+ /* @__PURE__ */ jsx(
124
+ "button",
125
+ {
126
+ type: "button",
127
+ onClick: onNotesSave,
128
+ disabled: savingNotes,
129
+ style: { ...s.btn(notesSaved ? "#16a34a" : C.blue, savingNotes), fontSize: "11px", padding: "5px 12px" },
130
+ children: notesSaved ? "Sauvegarde OK" : savingNotes ? "Sauvegarde..." : "Sauvegarder les notes"
131
+ }
132
+ )
133
+ ] })
134
+ ] });
135
+ }
136
+
137
+ export { ClientHistory };
@@ -0,0 +1,154 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+
6
+ const LANG_CONFIG = {
7
+ javascript: { label: "JavaScript", accent: "#f7df1e" },
8
+ js: { label: "JavaScript", accent: "#f7df1e" },
9
+ typescript: { label: "TypeScript", accent: "#3178c6" },
10
+ ts: { label: "TypeScript", accent: "#3178c6" },
11
+ tsx: { label: "TSX", accent: "#3178c6" },
12
+ jsx: { label: "JSX", accent: "#f7df1e" },
13
+ php: { label: "PHP", accent: "#777bb4" },
14
+ python: { label: "Python", accent: "#3776ab" },
15
+ py: { label: "Python", accent: "#3776ab" },
16
+ html: { label: "HTML", accent: "#e34f26" },
17
+ css: { label: "CSS", accent: "#1572b6" },
18
+ scss: { label: "SCSS", accent: "#cc6699" },
19
+ json: { label: "JSON", accent: "#292929" },
20
+ sql: { label: "SQL", accent: "#e48e00" },
21
+ bash: { label: "Bash", accent: "#4eaa25" },
22
+ sh: { label: "Shell", accent: "#4eaa25" },
23
+ yaml: { label: "YAML", accent: "#cb171e" },
24
+ yml: { label: "YAML", accent: "#cb171e" },
25
+ xml: { label: "XML", accent: "#f16529" },
26
+ markdown: { label: "Markdown", accent: "#083fa1" },
27
+ md: { label: "Markdown", accent: "#083fa1" },
28
+ diff: { label: "Diff", accent: "#41b883" },
29
+ go: { label: "Go", accent: "#00add8" },
30
+ rust: { label: "Rust", accent: "#dea584" },
31
+ java: { label: "Java", accent: "#ed8b00" },
32
+ c: { label: "C", accent: "#555555" },
33
+ cpp: { label: "C++", accent: "#00599c" },
34
+ ruby: { label: "Ruby", accent: "#cc342d" },
35
+ swift: { label: "Swift", accent: "#f05138" },
36
+ nginx: { label: "Nginx", accent: "#009639" },
37
+ docker: { label: "Docker", accent: "#2496ed" },
38
+ dockerfile: { label: "Dockerfile", accent: "#2496ed" },
39
+ env: { label: ".env", accent: "#ecd53f" }
40
+ };
41
+ const DEFAULT_CONFIG = { label: "Code", accent: "#6b7280" };
42
+ function SingleCodeBlock({ lang, code }) {
43
+ const [copied, setCopied] = react.useState(false);
44
+ const config = LANG_CONFIG[lang.toLowerCase()] || (lang ? { label: lang.toUpperCase(), accent: "#6b7280" } : DEFAULT_CONFIG);
45
+ const handleCopy = () => {
46
+ navigator.clipboard.writeText(code);
47
+ setCopied(true);
48
+ setTimeout(() => setCopied(false), 1500);
49
+ };
50
+ const lines = code.split("\n");
51
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
52
+ marginTop: 8,
53
+ marginBottom: 8,
54
+ borderRadius: 8,
55
+ overflow: "hidden",
56
+ border: "1px solid #334155",
57
+ backgroundColor: "#0f172a",
58
+ fontSize: 13
59
+ }, children: [
60
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
61
+ display: "flex",
62
+ alignItems: "center",
63
+ justifyContent: "space-between",
64
+ padding: "6px 12px",
65
+ backgroundColor: "#1e293b",
66
+ borderBottom: "1px solid #334155"
67
+ }, children: [
68
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
69
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
70
+ display: "inline-block",
71
+ width: 8,
72
+ height: 8,
73
+ borderRadius: "50%",
74
+ backgroundColor: config.accent,
75
+ flexShrink: 0
76
+ } }),
77
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
78
+ fontSize: 11,
79
+ fontWeight: 700,
80
+ color: "#e2e8f0",
81
+ letterSpacing: "0.02em"
82
+ }, children: config.label })
83
+ ] }),
84
+ /* @__PURE__ */ jsxRuntime.jsx(
85
+ "button",
86
+ {
87
+ onClick: handleCopy,
88
+ style: {
89
+ background: "none",
90
+ border: "1px solid #475569",
91
+ borderRadius: 4,
92
+ padding: "2px 10px",
93
+ fontSize: 11,
94
+ color: copied ? "#4ade80" : "#94a3b8",
95
+ cursor: "pointer",
96
+ fontWeight: 600,
97
+ transition: "color 150ms"
98
+ },
99
+ children: copied ? "Copi\xE9 !" : "Copier"
100
+ }
101
+ )
102
+ ] }),
103
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", overflowX: "auto" }, children: [
104
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
105
+ padding: "12px 0",
106
+ borderRight: "1px solid #334155",
107
+ userSelect: "none",
108
+ flexShrink: 0
109
+ }, children: lines.map((_, i) => /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
110
+ padding: "0 12px",
111
+ fontSize: 12,
112
+ lineHeight: "20px",
113
+ color: "#475569",
114
+ textAlign: "right",
115
+ fontFamily: '"SF Mono", "Fira Code", "JetBrains Mono", monospace'
116
+ }, children: i + 1 }, i)) }),
117
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { style: {
118
+ margin: 0,
119
+ padding: 12,
120
+ overflow: "auto",
121
+ flex: 1
122
+ }, children: /* @__PURE__ */ jsxRuntime.jsx("code", { style: {
123
+ fontSize: 12,
124
+ lineHeight: "20px",
125
+ fontFamily: '"SF Mono", "Fira Code", "JetBrains Mono", monospace',
126
+ color: "#e2e8f0",
127
+ whiteSpace: "pre"
128
+ }, children: code }) })
129
+ ] })
130
+ ] });
131
+ }
132
+ function CodeBlockRenderer({ text }) {
133
+ const parts = text.split(/(```[\s\S]*?```)/g);
134
+ const hasCodeBlock = parts.some((p) => p.startsWith("```"));
135
+ if (!hasCodeBlock) return null;
136
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: parts.map((part, i) => {
137
+ if (part.startsWith("```")) {
138
+ const match = part.match(/^```(\w*)\n?([\s\S]*?)```$/);
139
+ if (match) {
140
+ const lang = match[1] || "";
141
+ const code = match[2].replace(/\n$/, "");
142
+ return /* @__PURE__ */ jsxRuntime.jsx(SingleCodeBlock, { lang, code }, i);
143
+ }
144
+ }
145
+ return null;
146
+ }) });
147
+ }
148
+ function CodeBlockRendererHtml({ html }) {
149
+ const stripped = html.replace(/<[^>]+>/g, "");
150
+ return /* @__PURE__ */ jsxRuntime.jsx(CodeBlockRenderer, { text: stripped });
151
+ }
152
+
153
+ exports.CodeBlockRenderer = CodeBlockRenderer;
154
+ exports.CodeBlockRendererHtml = CodeBlockRendererHtml;
@@ -0,0 +1,152 @@
1
+ "use client";
2
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
+ import { useState } from 'react';
4
+
5
+ const LANG_CONFIG = {
6
+ javascript: { label: "JavaScript", accent: "#f7df1e" },
7
+ js: { label: "JavaScript", accent: "#f7df1e" },
8
+ typescript: { label: "TypeScript", accent: "#3178c6" },
9
+ ts: { label: "TypeScript", accent: "#3178c6" },
10
+ tsx: { label: "TSX", accent: "#3178c6" },
11
+ jsx: { label: "JSX", accent: "#f7df1e" },
12
+ php: { label: "PHP", accent: "#777bb4" },
13
+ python: { label: "Python", accent: "#3776ab" },
14
+ py: { label: "Python", accent: "#3776ab" },
15
+ html: { label: "HTML", accent: "#e34f26" },
16
+ css: { label: "CSS", accent: "#1572b6" },
17
+ scss: { label: "SCSS", accent: "#cc6699" },
18
+ json: { label: "JSON", accent: "#292929" },
19
+ sql: { label: "SQL", accent: "#e48e00" },
20
+ bash: { label: "Bash", accent: "#4eaa25" },
21
+ sh: { label: "Shell", accent: "#4eaa25" },
22
+ yaml: { label: "YAML", accent: "#cb171e" },
23
+ yml: { label: "YAML", accent: "#cb171e" },
24
+ xml: { label: "XML", accent: "#f16529" },
25
+ markdown: { label: "Markdown", accent: "#083fa1" },
26
+ md: { label: "Markdown", accent: "#083fa1" },
27
+ diff: { label: "Diff", accent: "#41b883" },
28
+ go: { label: "Go", accent: "#00add8" },
29
+ rust: { label: "Rust", accent: "#dea584" },
30
+ java: { label: "Java", accent: "#ed8b00" },
31
+ c: { label: "C", accent: "#555555" },
32
+ cpp: { label: "C++", accent: "#00599c" },
33
+ ruby: { label: "Ruby", accent: "#cc342d" },
34
+ swift: { label: "Swift", accent: "#f05138" },
35
+ nginx: { label: "Nginx", accent: "#009639" },
36
+ docker: { label: "Docker", accent: "#2496ed" },
37
+ dockerfile: { label: "Dockerfile", accent: "#2496ed" },
38
+ env: { label: ".env", accent: "#ecd53f" }
39
+ };
40
+ const DEFAULT_CONFIG = { label: "Code", accent: "#6b7280" };
41
+ function SingleCodeBlock({ lang, code }) {
42
+ const [copied, setCopied] = useState(false);
43
+ const config = LANG_CONFIG[lang.toLowerCase()] || (lang ? { label: lang.toUpperCase(), accent: "#6b7280" } : DEFAULT_CONFIG);
44
+ const handleCopy = () => {
45
+ navigator.clipboard.writeText(code);
46
+ setCopied(true);
47
+ setTimeout(() => setCopied(false), 1500);
48
+ };
49
+ const lines = code.split("\n");
50
+ return /* @__PURE__ */ jsxs("div", { style: {
51
+ marginTop: 8,
52
+ marginBottom: 8,
53
+ borderRadius: 8,
54
+ overflow: "hidden",
55
+ border: "1px solid #334155",
56
+ backgroundColor: "#0f172a",
57
+ fontSize: 13
58
+ }, children: [
59
+ /* @__PURE__ */ jsxs("div", { style: {
60
+ display: "flex",
61
+ alignItems: "center",
62
+ justifyContent: "space-between",
63
+ padding: "6px 12px",
64
+ backgroundColor: "#1e293b",
65
+ borderBottom: "1px solid #334155"
66
+ }, children: [
67
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
68
+ /* @__PURE__ */ jsx("span", { style: {
69
+ display: "inline-block",
70
+ width: 8,
71
+ height: 8,
72
+ borderRadius: "50%",
73
+ backgroundColor: config.accent,
74
+ flexShrink: 0
75
+ } }),
76
+ /* @__PURE__ */ jsx("span", { style: {
77
+ fontSize: 11,
78
+ fontWeight: 700,
79
+ color: "#e2e8f0",
80
+ letterSpacing: "0.02em"
81
+ }, children: config.label })
82
+ ] }),
83
+ /* @__PURE__ */ jsx(
84
+ "button",
85
+ {
86
+ onClick: handleCopy,
87
+ style: {
88
+ background: "none",
89
+ border: "1px solid #475569",
90
+ borderRadius: 4,
91
+ padding: "2px 10px",
92
+ fontSize: 11,
93
+ color: copied ? "#4ade80" : "#94a3b8",
94
+ cursor: "pointer",
95
+ fontWeight: 600,
96
+ transition: "color 150ms"
97
+ },
98
+ children: copied ? "Copi\xE9 !" : "Copier"
99
+ }
100
+ )
101
+ ] }),
102
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", overflowX: "auto" }, children: [
103
+ /* @__PURE__ */ jsx("div", { style: {
104
+ padding: "12px 0",
105
+ borderRight: "1px solid #334155",
106
+ userSelect: "none",
107
+ flexShrink: 0
108
+ }, children: lines.map((_, i) => /* @__PURE__ */ jsx("div", { style: {
109
+ padding: "0 12px",
110
+ fontSize: 12,
111
+ lineHeight: "20px",
112
+ color: "#475569",
113
+ textAlign: "right",
114
+ fontFamily: '"SF Mono", "Fira Code", "JetBrains Mono", monospace'
115
+ }, children: i + 1 }, i)) }),
116
+ /* @__PURE__ */ jsx("pre", { style: {
117
+ margin: 0,
118
+ padding: 12,
119
+ overflow: "auto",
120
+ flex: 1
121
+ }, children: /* @__PURE__ */ jsx("code", { style: {
122
+ fontSize: 12,
123
+ lineHeight: "20px",
124
+ fontFamily: '"SF Mono", "Fira Code", "JetBrains Mono", monospace',
125
+ color: "#e2e8f0",
126
+ whiteSpace: "pre"
127
+ }, children: code }) })
128
+ ] })
129
+ ] });
130
+ }
131
+ function CodeBlockRenderer({ text }) {
132
+ const parts = text.split(/(```[\s\S]*?```)/g);
133
+ const hasCodeBlock = parts.some((p) => p.startsWith("```"));
134
+ if (!hasCodeBlock) return null;
135
+ return /* @__PURE__ */ jsx(Fragment, { children: parts.map((part, i) => {
136
+ if (part.startsWith("```")) {
137
+ const match = part.match(/^```(\w*)\n?([\s\S]*?)```$/);
138
+ if (match) {
139
+ const lang = match[1] || "";
140
+ const code = match[2].replace(/\n$/, "");
141
+ return /* @__PURE__ */ jsx(SingleCodeBlock, { lang, code }, i);
142
+ }
143
+ }
144
+ return null;
145
+ }) });
146
+ }
147
+ function CodeBlockRendererHtml({ html }) {
148
+ const stripped = html.replace(/<[^>]+>/g, "");
149
+ return /* @__PURE__ */ jsx(CodeBlockRenderer, { text: stripped });
150
+ }
151
+
152
+ export { CodeBlockRenderer, CodeBlockRendererHtml };