@8wave/ai-elements 0.125.0-beta.31 → 0.125.0-beta.33

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 (103) hide show
  1. package/dist/_chunks/{PkChatbotFilePreview-CqxtVySb.js → PkChatbotFilePreview-DsRAk1js.js} +2 -2
  2. package/dist/_chunks/{PkChatbotFilePreview-CqxtVySb.js.map → PkChatbotFilePreview-DsRAk1js.js.map} +1 -1
  3. package/dist/_chunks/PkImageEditorDialog-BQwM06kT.js +939 -0
  4. package/dist/_chunks/PkImageEditorDialog-BQwM06kT.js.map +1 -0
  5. package/dist/_chunks/{PkStreamingMarkdown-BqDooeUU.js → PkStreamingMarkdown-CjL7l_3E.js} +2 -2
  6. package/dist/_chunks/{PkStreamingMarkdown-BqDooeUU.js.map → PkStreamingMarkdown-CjL7l_3E.js.map} +1 -1
  7. package/dist/_chunks/{PkToolChatFile-DpStX3wS.js → PkToolChatFile-weptM8iA.js} +2 -2
  8. package/dist/_chunks/{PkToolChatFile-DpStX3wS.js.map → PkToolChatFile-weptM8iA.js.map} +1 -1
  9. package/dist/_chunks/{PkToolShareDocument-BvHklbzb.js → PkToolShareDocument-D5K3uJ2x.js} +2 -2
  10. package/dist/_chunks/{PkToolShareDocument-BvHklbzb.js.map → PkToolShareDocument-D5K3uJ2x.js.map} +1 -1
  11. package/dist/_chunks/{PkToolShowArtifact-YPwJLLlW.js → PkToolShowArtifact-Bm2zS5YS.js} +2 -2
  12. package/dist/_chunks/{PkToolShowArtifact-YPwJLLlW.js.map → PkToolShowArtifact-Bm2zS5YS.js.map} +1 -1
  13. package/dist/_chunks/{PkToolShowContactForm-CTc1mbA8.js → PkToolShowContactForm-BKJCv5To.js} +2 -2
  14. package/dist/_chunks/{PkToolShowContactForm-CTc1mbA8.js.map → PkToolShowContactForm-BKJCv5To.js.map} +1 -1
  15. package/dist/_chunks/{PkToolShowDiagram-COt1Z3q9.js → PkToolShowDiagram-jpaEAi2X.js} +2 -2
  16. package/dist/_chunks/{PkToolShowDiagram-COt1Z3q9.js.map → PkToolShowDiagram-jpaEAi2X.js.map} +1 -1
  17. package/dist/_chunks/{PkToolShowForm-DT5EyYVY.js → PkToolShowForm-DvAcJgDP.js} +2 -2
  18. package/dist/_chunks/{PkToolShowForm-DT5EyYVY.js.map → PkToolShowForm-DvAcJgDP.js.map} +1 -1
  19. package/dist/_chunks/{PkToolShowImageGallery-DKrCrrB5.js → PkToolShowImageGallery-D0htuXNL.js} +4 -4
  20. package/dist/_chunks/{PkToolShowImageGallery-DKrCrrB5.js.map → PkToolShowImageGallery-D0htuXNL.js.map} +1 -1
  21. package/dist/_chunks/{PkToolShowSources-CzSknPo6.js → PkToolShowSources-Cfj6iRGj.js} +2 -2
  22. package/dist/_chunks/{PkToolShowSources-CzSknPo6.js.map → PkToolShowSources-Cfj6iRGj.js.map} +1 -1
  23. package/dist/_chunks/{useLightbox-D2Zi-Fpe.js → useLightbox-C54BCSbU.js} +130 -89
  24. package/dist/_chunks/useLightbox-C54BCSbU.js.map +1 -0
  25. package/dist/ai-elements.es.js +2774 -2721
  26. package/dist/ai-elements.es.js.map +1 -1
  27. package/dist-vue/PkChatbot.js +1 -1
  28. package/dist-vue/PkChatbotEmptyState.js +1 -1
  29. package/dist-vue/PkChatbotFilePreview.js +1 -1
  30. package/dist-vue/PkChatbotInput.js +1 -1
  31. package/dist-vue/PkChatbotMessages.js +1 -1
  32. package/dist-vue/PkChatbotSteps.js +1 -1
  33. package/dist-vue/PkChatbotViewChat.js +1 -1
  34. package/dist-vue/_chunks/{PkChatbot-DLgPqMWd.js → PkChatbot-Bc2hlwFO.js} +3 -3
  35. package/dist-vue/_chunks/{PkChatbot-DLgPqMWd.js.map → PkChatbot-Bc2hlwFO.js.map} +1 -1
  36. package/dist-vue/_chunks/{PkChatbotEmptyState-DMPEj1Qa.js → PkChatbotEmptyState-NHarCaDm.js} +2 -2
  37. package/dist-vue/_chunks/{PkChatbotEmptyState-DMPEj1Qa.js.map → PkChatbotEmptyState-NHarCaDm.js.map} +1 -1
  38. package/dist-vue/_chunks/{PkChatbotFilePreview-j_8sDZUE.js → PkChatbotFilePreview-BIta8Yg-.js} +2 -2
  39. package/dist-vue/_chunks/{PkChatbotFilePreview-j_8sDZUE.js.map → PkChatbotFilePreview-BIta8Yg-.js.map} +1 -1
  40. package/dist-vue/_chunks/{PkChatbotInput-TamSYiA7.js → PkChatbotInput-BSzDRoDD.js} +192 -181
  41. package/dist-vue/_chunks/PkChatbotInput-BSzDRoDD.js.map +1 -0
  42. package/dist-vue/_chunks/{PkChatbotMessages-bPBOSAv7.js → PkChatbotMessages-DEMKZDCb.js} +17 -17
  43. package/dist-vue/_chunks/{PkChatbotMessages-bPBOSAv7.js.map → PkChatbotMessages-DEMKZDCb.js.map} +1 -1
  44. package/dist-vue/_chunks/{PkChatbotSteps-pibgqxus.js → PkChatbotSteps-DGQoYxJ9.js} +2 -2
  45. package/dist-vue/_chunks/{PkChatbotSteps-pibgqxus.js.map → PkChatbotSteps-DGQoYxJ9.js.map} +1 -1
  46. package/dist-vue/_chunks/{PkChatbotViewChat-y60IA9aQ.js → PkChatbotViewChat-aKi08vCz.js} +440 -431
  47. package/dist-vue/_chunks/PkChatbotViewChat-aKi08vCz.js.map +1 -0
  48. package/dist-vue/_chunks/{PkFilePreview-CPSYaOV7.js → PkFilePreview-D2HInDoA.js} +2 -2
  49. package/dist-vue/_chunks/{PkFilePreview-CPSYaOV7.js.map → PkFilePreview-D2HInDoA.js.map} +1 -1
  50. package/dist-vue/_chunks/{PkFilePreviewDialog-D6zFO_H_.js → PkFilePreviewDialog-jxcUSzPx.js} +2 -2
  51. package/dist-vue/_chunks/{PkFilePreviewDialog-D6zFO_H_.js.map → PkFilePreviewDialog-jxcUSzPx.js.map} +1 -1
  52. package/dist-vue/_chunks/PkImageEditorDialog-Dn3HV_ny.js +934 -0
  53. package/dist-vue/_chunks/PkImageEditorDialog-Dn3HV_ny.js.map +1 -0
  54. package/dist-vue/_chunks/{PkStreamingMarkdown-B3VWOaWb.js → PkStreamingMarkdown-DdOv86Eb.js} +11 -11
  55. package/dist-vue/_chunks/{PkStreamingMarkdown-B3VWOaWb.js.map → PkStreamingMarkdown-DdOv86Eb.js.map} +1 -1
  56. package/dist-vue/_chunks/{PkSvgViewer-BsdSOBpH.js → PkSvgViewer-vkd5Dluw.js} +2 -2
  57. package/dist-vue/_chunks/{PkSvgViewer-BsdSOBpH.js.map → PkSvgViewer-vkd5Dluw.js.map} +1 -1
  58. package/dist-vue/_chunks/{PkToolChatFile-PXpiJLZ6.js → PkToolChatFile-8nx166iM.js} +2 -2
  59. package/dist-vue/_chunks/{PkToolChatFile-PXpiJLZ6.js.map → PkToolChatFile-8nx166iM.js.map} +1 -1
  60. package/dist-vue/_chunks/{PkToolShareDocument-cMUqik6v.js → PkToolShareDocument-CspvFwRR.js} +2 -2
  61. package/dist-vue/_chunks/{PkToolShareDocument-cMUqik6v.js.map → PkToolShareDocument-CspvFwRR.js.map} +1 -1
  62. package/dist-vue/_chunks/{PkToolShowArtifact-DouCz_dZ.js → PkToolShowArtifact-BppP_xSN.js} +2 -2
  63. package/dist-vue/_chunks/{PkToolShowArtifact-DouCz_dZ.js.map → PkToolShowArtifact-BppP_xSN.js.map} +1 -1
  64. package/dist-vue/_chunks/{PkToolShowContactForm-BmiNlFfx.js → PkToolShowContactForm-Bm0icz24.js} +2 -2
  65. package/dist-vue/_chunks/{PkToolShowContactForm-BmiNlFfx.js.map → PkToolShowContactForm-Bm0icz24.js.map} +1 -1
  66. package/dist-vue/_chunks/{PkToolShowDiagram-D6mYTDU-.js → PkToolShowDiagram-CgukB1Ss.js} +2 -2
  67. package/dist-vue/_chunks/{PkToolShowDiagram-D6mYTDU-.js.map → PkToolShowDiagram-CgukB1Ss.js.map} +1 -1
  68. package/dist-vue/_chunks/{PkToolShowForm-CksTiimD.js → PkToolShowForm-CyyN7GQP.js} +2 -2
  69. package/dist-vue/_chunks/{PkToolShowForm-CksTiimD.js.map → PkToolShowForm-CyyN7GQP.js.map} +1 -1
  70. package/dist-vue/_chunks/{PkToolShowImageGallery-B-lVY0xH.js → PkToolShowImageGallery-zQF_lsxI.js} +5 -5
  71. package/dist-vue/_chunks/{PkToolShowImageGallery-B-lVY0xH.js.map → PkToolShowImageGallery-zQF_lsxI.js.map} +1 -1
  72. package/dist-vue/_chunks/{PkToolShowLocation-B8FE_Sqd.js → PkToolShowLocation-WdRqG8Wi.js} +2 -2
  73. package/dist-vue/_chunks/{PkToolShowLocation-B8FE_Sqd.js.map → PkToolShowLocation-WdRqG8Wi.js.map} +1 -1
  74. package/dist-vue/_chunks/{PkToolShowProductList-Dcq3Kdse.js → PkToolShowProductList-DW_P0gC2.js} +2 -2
  75. package/dist-vue/_chunks/{PkToolShowProductList-Dcq3Kdse.js.map → PkToolShowProductList-DW_P0gC2.js.map} +1 -1
  76. package/dist-vue/_chunks/{PkToolShowSources-DApWmwvk.js → PkToolShowSources-BugMybUx.js} +2 -2
  77. package/dist-vue/_chunks/{PkToolShowSources-DApWmwvk.js.map → PkToolShowSources-BugMybUx.js.map} +1 -1
  78. package/dist-vue/_chunks/{PkToolShowVideo-CjrYh9-q.js → PkToolShowVideo-BW7aRKs_.js} +2 -2
  79. package/dist-vue/_chunks/{PkToolShowVideo-CjrYh9-q.js.map → PkToolShowVideo-BW7aRKs_.js.map} +1 -1
  80. package/dist-vue/_chunks/{PkToolShowWebPages-DSIAizw-.js → PkToolShowWebPages-DxKimT-2.js} +2 -2
  81. package/dist-vue/_chunks/{PkToolShowWebPages-DSIAizw-.js.map → PkToolShowWebPages-DxKimT-2.js.map} +1 -1
  82. package/dist-vue/_chunks/{useLightbox-FDyQrPWe.js → useLightbox-Ctl9zaMX.js} +132 -91
  83. package/dist-vue/_chunks/useLightbox-Ctl9zaMX.js.map +1 -0
  84. package/dist-vue/composables.js +36 -2
  85. package/dist-vue/composables.js.map +1 -1
  86. package/dist-vue/index.js +22 -22
  87. package/dist-vue/index.js.map +1 -1
  88. package/dist-vue/locales.js +34 -0
  89. package/dist-vue/packages/components/src/chat/PkChatbotInput.d.ts +5 -0
  90. package/dist-vue/packages/components/src/chat/PkImageEditor.d.ts +11 -9
  91. package/dist-vue/packages/components/src/chat/PkImageEditorDialog.d.ts +12 -5
  92. package/dist-vue/packages/components/src/chat/imageEdits.d.ts +77 -1
  93. package/dist-vue/packages/components/src/composables/useLightbox.d.ts +26 -0
  94. package/dist-vue/style.css +1 -1
  95. package/package.json +1 -1
  96. package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js +0 -555
  97. package/dist/_chunks/PkImageEditorDialog-Cq8y_PtC.js.map +0 -1
  98. package/dist/_chunks/useLightbox-D2Zi-Fpe.js.map +0 -1
  99. package/dist-vue/_chunks/PkChatbotInput-TamSYiA7.js.map +0 -1
  100. package/dist-vue/_chunks/PkChatbotViewChat-y60IA9aQ.js.map +0 -1
  101. package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js +0 -550
  102. package/dist-vue/_chunks/PkImageEditorDialog-BLUyILVi.js.map +0 -1
  103. package/dist-vue/_chunks/useLightbox-FDyQrPWe.js.map +0 -1
@@ -0,0 +1,939 @@
1
+ import { Et as e, F as t, I as n, J as r, L as i, N as a, Ot as o, Q as s, S as c, Tt as l, V as u, X as d, _ as f, b as p, c as m, d as h, f as g, g as _, gt as v, h as y, k as b, kt as x, nt as S, ot as C, q as ee, r as w, tt as T, u as te, v as E, vt as ne, w as D, wt as O, y as k, z as A } from "./vue.runtime.esm-bundler-C2U5uTqB.js";
2
+ import { r as re } from "./vue-i18n-POtLvOl1.js";
3
+ import { h as ie, y as ae } from "./dist-D6oUr4J_.js";
4
+ import { a as oe, d as j, s as M, t as se } from "./index.es-D-aOuzzp.js";
5
+ import { t as ce } from "./VvButtonLocalized-B32dBwWJ.js";
6
+ import { t as N } from "./_plugin-vue_export-helper-Djzt4Yr7.js";
7
+ import { t as P } from "./PkEditorRadioButtons-ClUWPayk.js";
8
+ // ../../packages/components/src/chat/imageEdits.ts
9
+ var le = {
10
+ red: {
11
+ fill: "#ff3b30",
12
+ edge: "#ffffff"
13
+ },
14
+ yellow: {
15
+ fill: "#ffcc00",
16
+ edge: "#000000"
17
+ },
18
+ green: {
19
+ fill: "#34c759",
20
+ edge: "#000000"
21
+ },
22
+ blue: {
23
+ fill: "#007aff",
24
+ edge: "#ffffff"
25
+ },
26
+ white: {
27
+ fill: "#ffffff",
28
+ edge: "#000000"
29
+ },
30
+ black: {
31
+ fill: "#000000",
32
+ edge: "#ffffff"
33
+ }
34
+ }, ue = "system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif", F = 16777216, de = .92, fe = 12, pe = 32, me = 3, he = 160, ge = 16, _e = 28, I = 12, ve = 1.2, L = 4, ye = 2.2, be = .6, xe = {
35
+ "image/jpeg": "jpg",
36
+ "image/png": "png",
37
+ "image/webp": "webp"
38
+ };
39
+ function R(e, t = F) {
40
+ let n = e.width * e.height;
41
+ if (n <= t) return {
42
+ width: e.width,
43
+ height: e.height
44
+ };
45
+ let r = Math.sqrt(t / n);
46
+ return {
47
+ width: Math.max(1, Math.floor(e.width * r)),
48
+ height: Math.max(1, Math.floor(e.height * r))
49
+ };
50
+ }
51
+ function Se(e, t) {
52
+ let { width: n, height: r } = e;
53
+ for (let e of t) e.kind === "rotate" ? [n, r] = [r, n] : e.kind === "crop" && ({width: n, height: r} = e.rect);
54
+ return {
55
+ width: n,
56
+ height: r
57
+ };
58
+ }
59
+ function z(e) {
60
+ return Math.max(fe, Math.round(Math.min(e.width, e.height) / pe));
61
+ }
62
+ function Ce(e) {
63
+ return Math.max(me, Math.round(Math.min(e.width, e.height) / he));
64
+ }
65
+ function we(e) {
66
+ return Math.max(ge, Math.round(Math.min(e.width, e.height) / _e));
67
+ }
68
+ function B(e) {
69
+ return Math.max(1, Math.round(e / 3));
70
+ }
71
+ function Te(e, t, n) {
72
+ let r = [], i = "";
73
+ for (let a of e.split(/\s+/).filter(Boolean)) {
74
+ let e = i ? `${i} ${a}` : a;
75
+ if (n(e) <= t) {
76
+ i = e;
77
+ continue;
78
+ }
79
+ i && r.push(i);
80
+ let o = a;
81
+ for (; o.length > 1 && n(o) > t;) {
82
+ let e = o.length - 1;
83
+ for (; e > 1 && n(o.slice(0, e)) > t;) e--;
84
+ r.push(o.slice(0, e)), o = o.slice(e);
85
+ }
86
+ i = o;
87
+ }
88
+ return i && r.push(i), r;
89
+ }
90
+ function Ee(e, t, n) {
91
+ let r = t.x - e.x, i = t.y - e.y, a = Math.hypot(r, i);
92
+ if (!a) return {
93
+ lineEnd: t,
94
+ head: [
95
+ t,
96
+ t,
97
+ t
98
+ ]
99
+ };
100
+ let o = r / a, s = i / a, c = Math.min(n * L, a * be), l = c * ye / L, u = {
101
+ x: t.x - o * c,
102
+ y: t.y - s * c
103
+ };
104
+ return {
105
+ lineEnd: u,
106
+ head: [
107
+ {
108
+ x: t.x,
109
+ y: t.y
110
+ },
111
+ {
112
+ x: u.x - s * l,
113
+ y: u.y + o * l
114
+ },
115
+ {
116
+ x: u.x + s * l,
117
+ y: u.y - o * l
118
+ }
119
+ ]
120
+ };
121
+ }
122
+ function De(e, t, n, r) {
123
+ let i = Y(e.x, 0, n.width), a = Y(e.y, 0, n.height), o = t.x - i, s = t.y - a, c = o < 0 ? i : n.width - i, l = s < 0 ? a : n.height - a, u = Math.min(Math.abs(o), c), d = Math.min(Math.abs(s), l);
124
+ if (r) {
125
+ let e = Math.max(Math.abs(o), Math.abs(s) * r);
126
+ u = Math.min(e, c, l * r), d = u / r;
127
+ }
128
+ let f = Math.round(o < 0 ? i - u : i), p = Math.round(s < 0 ? a - d : a);
129
+ return {
130
+ x: f,
131
+ y: p,
132
+ width: Math.min(Math.round(u), n.width - f),
133
+ height: Math.min(Math.round(d), n.height - p)
134
+ };
135
+ }
136
+ function V(e, t, n, r) {
137
+ let i = (e, t) => e + 2 * r > t ? t : e + r;
138
+ for (let r = 0; r < n; r = i(r, n)) {
139
+ let a = i(r, n);
140
+ for (let n = 0; n < t; n = i(n, t)) {
141
+ let o = i(n, t), s = 0, c = 0, l = 0, u = 0;
142
+ for (let i = r; i < a; i++) for (let r = n; r < o; r++) {
143
+ let n = (i * t + r) * 4, a = e[n + 3];
144
+ s += e[n] * a, c += e[n + 1] * a, l += e[n + 2] * a, u += a;
145
+ }
146
+ let d = (a - r) * (o - n), f = u > 0 ? [
147
+ s / u,
148
+ c / u,
149
+ l / u,
150
+ u / d
151
+ ] : [
152
+ 0,
153
+ 0,
154
+ 0,
155
+ 0
156
+ ];
157
+ for (let i = r; i < a; i++) for (let r = n; r < o; r++) e.set(f, (i * t + r) * 4);
158
+ }
159
+ }
160
+ }
161
+ function H(e, t, n) {
162
+ let r = xe[n];
163
+ if (n === t || !r) return e;
164
+ let i = e.lastIndexOf(".");
165
+ return `${i > 0 ? e.slice(0, i) : e}.${r}`;
166
+ }
167
+ async function Oe(e) {
168
+ let t = await createImageBitmap(e, { imageOrientation: "from-image" });
169
+ try {
170
+ let e = {
171
+ width: t.width,
172
+ height: t.height
173
+ }, n = G(R(e)), r = K(n);
174
+ return r.imageSmoothingQuality = "high", r.drawImage(t, 0, 0, n.width, n.height), {
175
+ image: n,
176
+ original: e
177
+ };
178
+ } finally {
179
+ t.close();
180
+ }
181
+ }
182
+ function ke(e, t) {
183
+ let n = G(e);
184
+ K(n).drawImage(e, 0, 0);
185
+ for (let e of t) {
186
+ if (e.kind === "cover") {
187
+ je(n, e.rect, e.style);
188
+ continue;
189
+ }
190
+ if (e.kind !== "rotate" && e.kind !== "crop") {
191
+ Ae(K(n), e);
192
+ continue;
193
+ }
194
+ let t = e.kind === "rotate" ? q(n, e.turn) : J(n, e.rect);
195
+ W(n), n = t;
196
+ }
197
+ return n;
198
+ }
199
+ function Ae(e, t) {
200
+ let { fill: n, edge: r } = le[t.color];
201
+ if (e.save(), e.lineCap = "round", e.lineJoin = "round", t.kind === "text") {
202
+ let { at: i, size: a } = t;
203
+ e.font = `700 ${a}px ${ue}`, e.textBaseline = "top", e.lineWidth = Math.max(1, Math.round(a / I)) * 2, e.strokeStyle = r, e.fillStyle = n;
204
+ let o = Te(t.text, t.maxWidth, (t) => e.measureText(t).width), s = (e) => i.y + a * (e * ve + .19999999999999996 / 2);
205
+ o.forEach((t, n) => e.strokeText(t, i.x, s(n))), o.forEach((t, n) => e.fillText(t, i.x, s(n))), e.restore();
206
+ return;
207
+ }
208
+ let i = B(t.width);
209
+ for (let [a, o] of [[r, i * 2], [n, 0]]) if (e.strokeStyle = a, e.fillStyle = a, e.lineWidth = t.width + o, t.kind === "rect") {
210
+ let { x: n, y: r, width: i, height: a } = t.rect;
211
+ e.strokeRect(n, r, i, a);
212
+ } else if (t.kind === "path") Me(e, t.points), e.stroke();
213
+ else {
214
+ let { lineEnd: n, head: r } = Ee(t.from, t.to, t.width);
215
+ e.beginPath(), e.moveTo(t.from.x, t.from.y), e.lineTo(n.x, n.y), e.stroke(), e.beginPath(), e.moveTo(r[0].x, r[0].y), e.lineTo(r[1].x, r[1].y), e.lineTo(r[2].x, r[2].y), e.closePath(), e.fill(), o && (e.lineWidth = o, e.stroke());
216
+ }
217
+ e.restore();
218
+ }
219
+ function U(e, t) {
220
+ return new Promise((n, r) => {
221
+ e.toBlob((e) => e ? n(e) : r(/* @__PURE__ */ Error("The image could not be written")), t, de);
222
+ });
223
+ }
224
+ function W(e) {
225
+ e.width = 0, e.height = 0;
226
+ }
227
+ function G(e) {
228
+ let t = document.createElement("canvas");
229
+ return t.width = e.width, t.height = e.height, t;
230
+ }
231
+ function K(e) {
232
+ let t = e.getContext("2d");
233
+ if (!t) throw Error("No 2D canvas in this browser");
234
+ return t;
235
+ }
236
+ function q(e, t) {
237
+ let n = G({
238
+ width: e.height,
239
+ height: e.width
240
+ }), r = K(n);
241
+ return r.save(), r.translate(n.width / 2, n.height / 2), r.rotate(t * Math.PI / 2), r.drawImage(e, -e.width / 2, -e.height / 2), r.restore(), n;
242
+ }
243
+ function J(e, t) {
244
+ let n = G(t);
245
+ return K(n).drawImage(e, t.x, t.y, t.width, t.height, 0, 0, t.width, t.height), n;
246
+ }
247
+ function je(e, t, n) {
248
+ let r = K(e);
249
+ if (n === "solid") {
250
+ r.fillStyle = "#000000", r.fillRect(t.x, t.y, t.width, t.height);
251
+ return;
252
+ }
253
+ let i = r.getImageData(t.x, t.y, t.width, t.height);
254
+ V(i.data, t.width, t.height, z(e)), r.putImageData(i, t.x, t.y);
255
+ }
256
+ function Me(e, t) {
257
+ let [n, ...r] = t, i = r[r.length - 1];
258
+ if (e.beginPath(), !n) return;
259
+ e.moveTo(n.x, n.y);
260
+ for (let t = 0; t < r.length - 1; t++) {
261
+ let n = r[t], i = r[t + 1];
262
+ e.quadraticCurveTo(n.x, n.y, (n.x + i.x) / 2, (n.y + i.y) / 2);
263
+ }
264
+ let a = i ?? n;
265
+ e.lineTo(a.x, a.y);
266
+ }
267
+ function Ne(e, t) {
268
+ return {
269
+ x: Y(e.x, 0, t.width),
270
+ y: Y(e.y, 0, t.height)
271
+ };
272
+ }
273
+ function Y(e, t, n) {
274
+ return Math.min(n, Math.max(t, e));
275
+ }
276
+ // ../../packages/components/src/chat/PkImageEditor.vue?vue&type=script&setup=true&lang.ts
277
+ b(), C(), l(), w();
278
+ var Pe = { class: "pk-image-editor" }, Fe = { class: "pk-image-editor__toolbar" }, Ie = ["title"], Le = { class: "pk-image-editor__tool-label" }, Re = { class: "pk-image-editor__options" }, ze = ["id"], Be = { class: "pk-image-editor__hint" }, Ve = { class: "pk-image-editor__hint" }, He = ["id"], Ue = ["title"], We = { class: "u-visually-hidden" }, Ge = { class: "pk-image-editor__hint" }, Ke = ["aria-label"], qe = 6, Je = 2, Ye = 200, Xe = /*#__PURE__*/ N(/* @__PURE__ */ D({
279
+ __name: "PkImageEditor",
280
+ props: /*@__PURE__*/ a({
281
+ image: { type: null },
282
+ initialTool: { type: String }
283
+ }, {
284
+ edits: { required: !0 },
285
+ editsModifiers: {}
286
+ }),
287
+ emits: /*@__PURE__*/ a(["error"], ["update:edits"]),
288
+ setup(a, { expose: l, emit: f }) {
289
+ let b = a, C = f, w = r(a, "edits"), { t: D } = re({ useScope: "global" }), ie = {
290
+ free: void 0,
291
+ "1:1": 1,
292
+ "4:3": 4 / 3,
293
+ "16:9": 16 / 9
294
+ }, j = v(b.initialTool ?? "crop"), M = v("free"), N = v("solid"), F = v("red"), de = y(() => [
295
+ {
296
+ value: "crop",
297
+ label: D("imageEditor.crop"),
298
+ icon: "ri:crop-line"
299
+ },
300
+ {
301
+ value: "cover",
302
+ label: D("imageEditor.cover"),
303
+ icon: "ri:eye-off-line"
304
+ },
305
+ {
306
+ value: "arrow",
307
+ label: D("imageEditor.arrow"),
308
+ icon: "ri:arrow-right-up-line"
309
+ },
310
+ {
311
+ value: "rect",
312
+ label: D("imageEditor.rect"),
313
+ icon: "ri:checkbox-blank-line"
314
+ },
315
+ {
316
+ value: "path",
317
+ label: D("imageEditor.path"),
318
+ icon: "ri:pencil-line"
319
+ },
320
+ {
321
+ value: "text",
322
+ label: D("imageEditor.text"),
323
+ icon: "ri:text"
324
+ }
325
+ ]), fe = y(() => [
326
+ {
327
+ value: "free",
328
+ label: D("imageEditor.aspectFree")
329
+ },
330
+ {
331
+ value: "1:1",
332
+ label: "1:1"
333
+ },
334
+ {
335
+ value: "4:3",
336
+ label: "4:3"
337
+ },
338
+ {
339
+ value: "16:9",
340
+ label: "16:9"
341
+ }
342
+ ]), pe = y(() => [{
343
+ value: "solid",
344
+ label: D("imageEditor.coverSolid")
345
+ }, {
346
+ value: "pixelate",
347
+ label: D("imageEditor.coverPixelate")
348
+ }]), me = y(() => [
349
+ {
350
+ value: "red",
351
+ label: D("imageEditor.colorRed")
352
+ },
353
+ {
354
+ value: "yellow",
355
+ label: D("imageEditor.colorYellow")
356
+ },
357
+ {
358
+ value: "green",
359
+ label: D("imageEditor.colorGreen")
360
+ },
361
+ {
362
+ value: "blue",
363
+ label: D("imageEditor.colorBlue")
364
+ },
365
+ {
366
+ value: "white",
367
+ label: D("imageEditor.colorWhite")
368
+ },
369
+ {
370
+ value: "black",
371
+ label: D("imageEditor.colorBlack")
372
+ }
373
+ ]), he = y(() => {
374
+ switch (j.value) {
375
+ case "arrow": return D("imageEditor.arrowHint");
376
+ case "rect": return D("imageEditor.rectHint");
377
+ case "path": return D("imageEditor.pathHint");
378
+ default: return D("imageEditor.textHint");
379
+ }
380
+ }), ge = ee(), _e = ee(), I = v([]);
381
+ function L(e) {
382
+ w.value = [...w.value, e], I.value = [];
383
+ }
384
+ function ye() {
385
+ G.value = void 0;
386
+ let e = w.value[w.value.length - 1];
387
+ e && (w.value = w.value.slice(0, -1), I.value = [...I.value, e]);
388
+ }
389
+ function be() {
390
+ G.value = void 0;
391
+ let e = I.value[I.value.length - 1];
392
+ e && (w.value = [...w.value, e], I.value = I.value.slice(0, -1));
393
+ }
394
+ function xe(e) {
395
+ G.value = void 0, L({
396
+ kind: "rotate",
397
+ turn: e
398
+ });
399
+ }
400
+ let R = y(() => Se(b.image, w.value)), z = d("stageEl"), B;
401
+ function Te() {
402
+ if (!z.value) return;
403
+ let e;
404
+ try {
405
+ e = ke(b.image, w.value);
406
+ } catch {
407
+ C("error");
408
+ return;
409
+ }
410
+ e.setAttribute("role", "img"), e.setAttribute("aria-label", D("imageEditor.canvasLabel")), z.value.replaceChildren(e), B && W(B), B = e;
411
+ }
412
+ i(Te), s([() => b.image, w], Te, { flush: "post" }), n(() => {
413
+ B && W(B), Z.value && W(Z.value);
414
+ });
415
+ let Ee = d("areaEl"), V = v({
416
+ width: 0,
417
+ height: 0
418
+ });
419
+ ae(Ee, ([e]) => {
420
+ e && (V.value = {
421
+ width: e.contentRect.width,
422
+ height: e.contentRect.height
423
+ });
424
+ });
425
+ let H = y(() => Math.min(1, V.value.width / R.value.width, V.value.height / R.value.height)), Oe = y(() => ({
426
+ width: `${Math.max(1, Math.floor(R.value.width * H.value))}px`,
427
+ height: `${Math.max(1, Math.floor(R.value.height * H.value))}px`
428
+ })), U = d("frameEl"), G = v(), K = v(), q = ne(), J;
429
+ function je(e) {
430
+ let t = U.value?.getBoundingClientRect();
431
+ return !t?.width || !t.height ? {
432
+ x: 0,
433
+ y: 0
434
+ } : Ne({
435
+ x: (e.clientX - t.left) / t.width * R.value.width,
436
+ y: (e.clientY - t.top) / t.height * R.value.height
437
+ }, R.value);
438
+ }
439
+ function Me(e) {
440
+ if (e.button !== 0 || J !== void 0) return;
441
+ J = e.pointerId, U.value?.setPointerCapture(e.pointerId);
442
+ let t = je(e);
443
+ K.value = t, G.value = void 0, j.value === "path" && (q.value = {
444
+ kind: "path",
445
+ points: [t],
446
+ color: F.value,
447
+ width: Ce(R.value)
448
+ });
449
+ }
450
+ function Y(e) {
451
+ let t = K.value;
452
+ if (!t || e.pointerId !== J) return;
453
+ let n = je(e), r = Ce(R.value);
454
+ switch (j.value) {
455
+ case "crop":
456
+ case "cover":
457
+ G.value = De(t, n, R.value, j.value === "crop" ? ie[M.value] : void 0);
458
+ break;
459
+ case "rect":
460
+ q.value = {
461
+ kind: "rect",
462
+ rect: De(t, n, R.value),
463
+ color: F.value,
464
+ width: r
465
+ };
466
+ break;
467
+ case "arrow":
468
+ q.value = {
469
+ kind: "arrow",
470
+ from: t,
471
+ to: n,
472
+ color: F.value,
473
+ width: r
474
+ };
475
+ break;
476
+ case "path": {
477
+ let e = q.value, t = e?.kind === "path" ? e.points[e.points.length - 1] : void 0;
478
+ e?.kind === "path" && t && dt(t, n) * H.value >= Je && (q.value = {
479
+ ...e,
480
+ points: [...e.points, n]
481
+ });
482
+ break;
483
+ }
484
+ }
485
+ }
486
+ function Xe(e) {
487
+ let t = K.value;
488
+ if (!t || e.pointerId !== J) return;
489
+ if (J = void 0, K.value = void 0, j.value === "crop" || j.value === "cover") {
490
+ let e = G.value;
491
+ if (!e || !X(e.width) || !X(e.height)) {
492
+ G.value = void 0;
493
+ return;
494
+ }
495
+ j.value === "cover" && (G.value = void 0, L({
496
+ kind: "cover",
497
+ rect: e,
498
+ style: N.value
499
+ }));
500
+ return;
501
+ }
502
+ if (j.value === "text") {
503
+ it(t);
504
+ return;
505
+ }
506
+ let n = q.value;
507
+ q.value = void 0, n && Qe(n) && L(n);
508
+ }
509
+ function Ze(e) {
510
+ e.pointerId === J && (J = void 0, K.value = void 0, G.value = void 0, q.value = void 0);
511
+ }
512
+ function X(e) {
513
+ return e * H.value >= qe;
514
+ }
515
+ function Qe(e) {
516
+ switch (e.kind) {
517
+ case "arrow": return X(dt(e.from, e.to));
518
+ case "rect": return X(e.rect.width) && X(e.rect.height);
519
+ case "path": return e.points.length > 1;
520
+ default: return !0;
521
+ }
522
+ }
523
+ let Z = d("draftEl");
524
+ function $e() {
525
+ let e = Z.value, t = U.value;
526
+ if (!e || !t) return;
527
+ let n = q.value;
528
+ if (!n) {
529
+ W(e);
530
+ return;
531
+ }
532
+ let r = window.devicePixelRatio || 1;
533
+ e.width = Math.round(t.clientWidth * r), e.height = Math.round(t.clientHeight * r);
534
+ let i = e.getContext("2d");
535
+ if (!i) return;
536
+ let a = e.width / R.value.width;
537
+ i.setTransform(a, 0, 0, a, 0, 0), Ae(i, n);
538
+ }
539
+ s(q, $e, { flush: "post" });
540
+ let et = y(() => j.value === "crop" && !K.value && !!G.value);
541
+ function tt() {
542
+ let e = G.value;
543
+ et.value && e && (G.value = void 0, (e.width !== R.value.width || e.height !== R.value.height) && L({
544
+ kind: "crop",
545
+ rect: e
546
+ }));
547
+ }
548
+ s(M, (e) => {
549
+ let t = G.value;
550
+ t && j.value === "crop" && (G.value = De(t, {
551
+ x: t.x + t.width,
552
+ y: t.y + t.height
553
+ }, R.value, ie[e]));
554
+ });
555
+ let nt = y(() => {
556
+ let e = G.value;
557
+ if (e) return {
558
+ left: `${e.x / R.value.width * 100}%`,
559
+ top: `${e.y / R.value.height * 100}%`,
560
+ width: `${e.width / R.value.width * 100}%`,
561
+ height: `${e.height / R.value.height * 100}%`
562
+ };
563
+ }), Q = v(), rt = d("textEl");
564
+ async function it(e) {
565
+ $(), Q.value = {
566
+ at: e,
567
+ text: ""
568
+ }, await t(), ct(), rt.value?.focus();
569
+ }
570
+ function $() {
571
+ let e = Q.value;
572
+ Q.value = void 0;
573
+ let t = e?.text.trim();
574
+ e && t && L({
575
+ kind: "text",
576
+ at: e.at,
577
+ text: t,
578
+ color: F.value,
579
+ size: we(R.value),
580
+ maxWidth: R.value.width - e.at.x
581
+ });
582
+ }
583
+ let at = (e) => e.isComposing || e.keyCode === 229;
584
+ function ot(e) {
585
+ at(e) || (e.preventDefault(), $());
586
+ }
587
+ function st(e) {
588
+ at(e) || (e.preventDefault(), Q.value = void 0);
589
+ }
590
+ function ct() {
591
+ let e = rt.value;
592
+ e && (e.style.height = "auto", e.style.height = `${e.scrollHeight}px`);
593
+ }
594
+ let lt = y(() => !!Q.value?.text.trim()), ut = y(() => {
595
+ let e = Q.value;
596
+ if (!e) return;
597
+ let { fill: t, edge: n } = le[F.value];
598
+ return {
599
+ left: `${e.at.x / R.value.width * 100}%`,
600
+ top: `${e.at.y / R.value.height * 100}%`,
601
+ fontFamily: ue,
602
+ fontSize: `${we(R.value) * H.value}px`,
603
+ lineHeight: String(ve),
604
+ color: t,
605
+ "--pk-image-editor-text-edge": n
606
+ };
607
+ });
608
+ s(j, () => {
609
+ G.value = void 0, q.value = void 0, $();
610
+ }), l({
611
+ pending: y(() => et.value || lt.value),
612
+ applyPending: () => {
613
+ tt(), $();
614
+ },
615
+ shownCanvas: () => B
616
+ });
617
+ function dt(e, t) {
618
+ return Math.hypot(t.x - e.x, t.y - e.y);
619
+ }
620
+ return (t, n) => {
621
+ let r = se, i = ce, a = oe;
622
+ return A(), k("div", Pe, [
623
+ _("div", Fe, [
624
+ c(P, {
625
+ modelValue: j.value,
626
+ "onUpdate:modelValue": n[0] ||= (e) => j.value = e,
627
+ name: "pk-image-editor-tool",
628
+ segmented: "",
629
+ class: "mb-0",
630
+ "aria-label": O(D)("imageEditor.tool"),
631
+ options: de.value
632
+ }, p({ _: 2 }, [u(de.value, (e) => ({
633
+ name: e.value,
634
+ fn: T(() => [_("span", {
635
+ class: "pk-image-editor__tool",
636
+ title: e.label
637
+ }, [c(r, {
638
+ name: e.icon,
639
+ class: "w-16 h-16"
640
+ }, null, 8, ["name"]), _("span", Le, x(e.label), 1)], 8, Ie)])
641
+ }))]), 1032, [
642
+ "modelValue",
643
+ "aria-label",
644
+ "options"
645
+ ]),
646
+ c(a, { modifiers: "compact" }, {
647
+ default: T(() => [c(i, {
648
+ modifiers: "action-quiet",
649
+ icon: "ri:anticlockwise-line",
650
+ title: O(D)("imageEditor.rotateLeft"),
651
+ "aria-label": O(D)("imageEditor.rotateLeft"),
652
+ onClick: n[1] ||= (e) => xe(-1)
653
+ }, null, 8, ["title", "aria-label"]), c(i, {
654
+ modifiers: "action-quiet",
655
+ icon: "ri:clockwise-line",
656
+ title: O(D)("imageEditor.rotateRight"),
657
+ "aria-label": O(D)("imageEditor.rotateRight"),
658
+ onClick: n[2] ||= (e) => xe(1)
659
+ }, null, 8, ["title", "aria-label"])]),
660
+ _: 1
661
+ }),
662
+ c(a, {
663
+ modifiers: "compact",
664
+ class: "ml-auto"
665
+ }, {
666
+ default: T(() => [c(i, {
667
+ modifiers: "action-quiet",
668
+ icon: "ri:arrow-go-back-line",
669
+ title: O(D)("imageEditor.undo"),
670
+ "aria-label": O(D)("imageEditor.undo"),
671
+ disabled: !w.value.length,
672
+ onClick: ye
673
+ }, null, 8, [
674
+ "title",
675
+ "aria-label",
676
+ "disabled"
677
+ ]), c(i, {
678
+ modifiers: "action-quiet",
679
+ icon: "ri:arrow-go-forward-line",
680
+ title: O(D)("imageEditor.redo"),
681
+ "aria-label": O(D)("imageEditor.redo"),
682
+ disabled: !I.value.length,
683
+ onClick: be
684
+ }, null, 8, [
685
+ "title",
686
+ "aria-label",
687
+ "disabled"
688
+ ])]),
689
+ _: 1
690
+ })
691
+ ]),
692
+ _("div", Re, [j.value === "crop" ? (A(), k(g, { key: 0 }, [
693
+ _("span", {
694
+ id: O(ge),
695
+ class: "pk-image-editor__label"
696
+ }, x(O(D)("imageEditor.aspect")), 9, ze),
697
+ c(P, {
698
+ modelValue: M.value,
699
+ "onUpdate:modelValue": n[3] ||= (e) => M.value = e,
700
+ name: "pk-image-editor-aspect",
701
+ segmented: "",
702
+ class: "mb-0",
703
+ "aria-labelledby": O(ge),
704
+ options: fe.value
705
+ }, null, 8, [
706
+ "modelValue",
707
+ "aria-labelledby",
708
+ "options"
709
+ ]),
710
+ _("span", Be, x(O(D)("imageEditor.cropHint")), 1),
711
+ c(i, {
712
+ class: "ml-auto",
713
+ modifiers: "secondary",
714
+ label: O(D)("action.apply"),
715
+ disabled: !et.value,
716
+ onClick: tt
717
+ }, null, 8, ["label", "disabled"])
718
+ ], 64)) : j.value === "cover" ? (A(), k(g, { key: 1 }, [c(P, {
719
+ modelValue: N.value,
720
+ "onUpdate:modelValue": n[4] ||= (e) => N.value = e,
721
+ name: "pk-image-editor-cover",
722
+ segmented: "",
723
+ class: "mb-0",
724
+ "aria-label": O(D)("imageEditor.coverStyle"),
725
+ options: pe.value
726
+ }, null, 8, [
727
+ "modelValue",
728
+ "aria-label",
729
+ "options"
730
+ ]), _("span", Ve, x(O(D)("imageEditor.coverHint")), 1)], 64)) : (A(), k(g, { key: 2 }, [
731
+ _("span", {
732
+ id: O(_e),
733
+ class: "pk-image-editor__label"
734
+ }, x(O(D)("imageEditor.color")), 9, He),
735
+ c(P, {
736
+ modelValue: F.value,
737
+ "onUpdate:modelValue": n[5] ||= (e) => F.value = e,
738
+ name: "pk-image-editor-color",
739
+ segmented: "",
740
+ class: "mb-0",
741
+ "aria-labelledby": O(_e),
742
+ options: me.value
743
+ }, p({ _: 2 }, [u(me.value, (e) => ({
744
+ name: e.value,
745
+ fn: T(() => [_("span", {
746
+ class: "pk-image-editor__color",
747
+ title: e.label
748
+ }, [_("span", {
749
+ class: "pk-image-editor__swatch",
750
+ style: o({ backgroundColor: O(le)[e.value].fill })
751
+ }, null, 4), _("span", We, x(e.label), 1)], 8, Ue)])
752
+ }))]), 1032, [
753
+ "modelValue",
754
+ "aria-labelledby",
755
+ "options"
756
+ ]),
757
+ _("span", Ge, x(he.value), 1)
758
+ ], 64))]),
759
+ _("div", {
760
+ ref_key: "areaEl",
761
+ ref: Ee,
762
+ class: "pk-image-editor__area"
763
+ }, [_("div", {
764
+ ref_key: "frameEl",
765
+ ref: U,
766
+ class: e(["pk-image-editor__frame", { "pk-image-editor__frame--text": j.value === "text" }]),
767
+ style: o(Oe.value),
768
+ onPointerdown: Me,
769
+ onPointermove: Y,
770
+ onPointerup: Xe,
771
+ onPointercancel: Ze
772
+ }, [
773
+ _("div", {
774
+ ref_key: "stageEl",
775
+ ref: z,
776
+ class: "pk-image-editor__stage"
777
+ }, null, 512),
778
+ _("canvas", {
779
+ ref_key: "draftEl",
780
+ ref: Z,
781
+ class: "pk-image-editor__draft",
782
+ width: "0",
783
+ height: "0",
784
+ "aria-hidden": "true"
785
+ }, null, 512),
786
+ G.value ? (A(), k("div", {
787
+ key: 0,
788
+ class: e(["pk-image-editor__selection", `pk-image-editor__selection--${j.value}`]),
789
+ style: o(nt.value)
790
+ }, null, 6)) : E("", !0),
791
+ Q.value ? S((A(), k("textarea", {
792
+ key: 1,
793
+ ref_key: "textEl",
794
+ ref: rt,
795
+ "onUpdate:modelValue": n[6] ||= (e) => Q.value.text = e,
796
+ class: "pk-image-editor__text",
797
+ rows: "1",
798
+ maxlength: Ye,
799
+ "aria-label": O(D)("imageEditor.textLabel"),
800
+ style: o(ut.value),
801
+ onPointerdown: n[7] ||= h(() => {}, ["stop"]),
802
+ onInput: ct,
803
+ onKeydown: [te(ot, ["enter"]), te(st, ["esc"])],
804
+ onBlur: $
805
+ }, null, 44, Ke)), [[m, Q.value.text]]) : E("", !0)
806
+ ], 38)], 512)
807
+ ]);
808
+ };
809
+ }
810
+ }), [["styles", [".pk-image-editor{flex-direction:column;flex:1;min-height:0;display:flex;container:pk-image-editor/inline-size}.pk-image-editor__toolbar,.pk-image-editor__options{align-items:center;gap:var(--spacing-8);padding:var(--spacing-8) var(--spacing-md);border-bottom:1px solid var(--color-surface-3);flex-wrap:wrap;display:flex}.pk-image-editor__toolbar{background-color:var(--color-surface-1)}.pk-image-editor__toolbar>.vv-radio-group,.pk-image-editor__options>.vv-radio-group{flex:none;width:auto}.pk-image-editor__toolbar>.vv-radio-group .vv-radio,.pk-image-editor__options>.vv-radio-group .vv-radio{flex:none}.pk-image-editor__tool{align-items:center;gap:var(--spacing-4);display:inline-flex}.pk-image-editor__label{color:var(--color-word-2);font-size:var(--text-14)}.pk-image-editor__hint{color:var(--color-word-3);font-size:var(--text-12)}.pk-image-editor__color{display:inline-flex;position:relative}.pk-image-editor__swatch{width:var(--spacing-16);height:var(--spacing-16);box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--color-word) 40%, transparent);border-radius:50%;display:block}.pk-image-editor__area{min-height:12rem;padding:var(--spacing-md);background:repeating-conic-gradient(var(--color-surface-2) 0% 25%, var(--color-surface) 0% 50%) 50%/16px 16px;flex:1;justify-content:center;align-items:center;display:flex;overflow:hidden}.pk-image-editor__frame{box-shadow:var(--shadow-sm);cursor:crosshair;touch-action:none;-webkit-user-select:none;user-select:none;flex-shrink:0;position:relative;overflow:hidden}.pk-image-editor__frame--text{cursor:text}.pk-image-editor__stage,.pk-image-editor__stage>canvas{width:100%;height:100%;display:block}.pk-image-editor__draft{pointer-events:none;width:100%;height:100%;position:absolute;inset:0}.pk-image-editor__selection{pointer-events:none;border:2px solid var(--color-white);outline:1px solid color-mix(in srgb, var(--color-black) 50%, transparent);position:absolute}.pk-image-editor__selection--crop{box-shadow:0 0 0 100vmax color-mix(in srgb, var(--color-black) 55%, transparent)}.pk-image-editor__selection--cover{background-color:color-mix(in srgb, var(--color-black) 30%, transparent);border-style:dashed}.pk-image-editor__text{outline:1px dashed color-mix(in srgb, var(--color-white) 80%, transparent);white-space:pre-wrap;overflow-wrap:anywhere;resize:none;caret-color:currentColor;-webkit-user-select:text;user-select:text;text-shadow:0 0 1px var(--pk-image-editor-text-edge), 0 0 2px var(--pk-image-editor-text-edge), 0 0 3px var(--pk-image-editor-text-edge);background:0 0;border:0;margin:0;padding:0;font-weight:700;display:block;position:absolute;right:0;overflow:hidden}@media (pointer:coarse){.pk-image-editor .vv-radio--segment:after{content:\"\";width:max(100%, var(--spacing-40));height:max(100%, var(--spacing-40));position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}}@container pk-image-editor (width<=50rem){.pk-image-editor__tool-label{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}}"]]]);
811
+ // ../../packages/components/src/chat/PkImageEditorDialog.vue?vue&type=script&setup=true&lang.ts
812
+ b(), C(), l();
813
+ var Ze = ["aria-label"], X = {
814
+ key: 3,
815
+ class: "pk-image-editor-dialog__size"
816
+ }, Qe = /*#__PURE__*/ N(/* @__PURE__ */ D({
817
+ __name: "PkImageEditorDialog",
818
+ props: {
819
+ file: { type: null },
820
+ initialTool: { type: String }
821
+ },
822
+ emits: ["close", "apply"],
823
+ setup(e, { emit: r }) {
824
+ let a = e, o = r, { t: s } = re({ useScope: "global" }), l = ie("(max-width: 575.98px)"), u = ne(), p = ne(), m = v(), h = v([]), g = v(!1), _ = d("editorEl"), b = !1;
825
+ i(async () => {
826
+ try {
827
+ let e = await a.file, t = await Oe(e);
828
+ if (b) {
829
+ W(t.image);
830
+ return;
831
+ }
832
+ u.value = e, p.value = t;
833
+ } catch {
834
+ m.value = "load";
835
+ }
836
+ }), n(() => {
837
+ b = !0, p.value && W(p.value.image);
838
+ });
839
+ let S = y(() => p.value && Se(p.value.image, h.value)), C = y(() => !!p.value && p.value.image.width < p.value.original.width), ee = y(() => h.value.length > 0 || !!_.value?.pending);
840
+ async function w() {
841
+ let e = _.value, n = u.value;
842
+ if (e && n) {
843
+ if (e.applyPending(), !h.value.length) o("close");
844
+ else {
845
+ m.value = void 0, g.value = !0;
846
+ try {
847
+ await t();
848
+ let r = e.shownCanvas();
849
+ if (m.value === "draw") return;
850
+ if (!r) throw Error("No image drawn");
851
+ let i = await U(r, n.type);
852
+ o("apply", new File([i], H(n.name, n.type, i.type), {
853
+ type: i.type,
854
+ lastModified: Date.now()
855
+ }));
856
+ } catch {
857
+ m.value = "export";
858
+ } finally {
859
+ g.value = !1;
860
+ }
861
+ }
862
+ }
863
+ }
864
+ let te = y(() => {
865
+ switch (m.value) {
866
+ case "export": return s("imageEditor.exportFailed");
867
+ case "draw": return s("imageEditor.drawFailed");
868
+ default: return s("imageEditor.loadFailed");
869
+ }
870
+ });
871
+ return (t, n) => {
872
+ let r = M, i = se, a = ce, u = oe, d = j;
873
+ return A(), f(d, {
874
+ "model-value": !0,
875
+ title: O(s)("imageEditor.title"),
876
+ modifiers: O(l) ? "fullscreen" : void 0,
877
+ "keep-open": "",
878
+ class: "pk-image-editor-dialog",
879
+ "onUpdate:modelValue": n[3] ||= (e) => !e && o("close")
880
+ }, {
881
+ footer: T(() => [c(u, null, {
882
+ default: T(() => [c(a, {
883
+ modifiers: "secondary",
884
+ label: O(s)("action.cancel"),
885
+ onClick: n[2] ||= (e) => o("close")
886
+ }, null, 8, ["label"]), c(a, {
887
+ label: O(s)("imageEditor.use"),
888
+ loading: g.value,
889
+ disabled: g.value || !ee.value || m.value === "draw",
890
+ onClick: w
891
+ }, null, 8, [
892
+ "label",
893
+ "loading",
894
+ "disabled"
895
+ ])]),
896
+ _: 1
897
+ })]),
898
+ default: T(() => [
899
+ m.value ? (A(), f(r, {
900
+ key: 0,
901
+ modifiers: "danger",
902
+ class: "m-md",
903
+ content: te.value
904
+ }, null, 8, ["content"])) : E("", !0),
905
+ p.value && m.value !== "draw" ? (A(), f(Xe, {
906
+ key: 1,
907
+ ref_key: "editorEl",
908
+ ref: _,
909
+ edits: h.value,
910
+ "onUpdate:edits": n[0] ||= (e) => h.value = e,
911
+ image: p.value.image,
912
+ "initial-tool": e.initialTool,
913
+ onError: n[1] ||= (e) => m.value = "draw"
914
+ }, null, 8, [
915
+ "edits",
916
+ "image",
917
+ "initial-tool"
918
+ ])) : m.value ? E("", !0) : (A(), k("div", {
919
+ key: 2,
920
+ class: "pk-image-editor-dialog__loading",
921
+ role: "status",
922
+ "aria-label": O(s)("imageEditor.loading")
923
+ }, [c(i, { name: "loading-loop" })], 8, Ze)),
924
+ S.value ? (A(), k("p", X, x(C.value ? O(s)("imageEditor.sizeScaledDown", {
925
+ width: S.value.width,
926
+ height: S.value.height
927
+ }) : O(s)("imageEditor.size", {
928
+ width: S.value.width,
929
+ height: S.value.height
930
+ })), 1)) : E("", !0)
931
+ ]),
932
+ _: 1
933
+ }, 8, ["title", "modifiers"]);
934
+ };
935
+ }
936
+ }), [["styles", [".pk-image-editor-dialog:not(.vv-dialog--fullscreen)>article{width:min(64rem,94dvw);height:min(48rem,92dvh)}.pk-image-editor-dialog.vv-dialog--fullscreen>article{max-height:none}.pk-image-editor-dialog .vv-dialog__content{flex-direction:column;flex:1;min-height:0;padding:0;display:flex}.pk-image-editor-dialog__loading{color:var(--color-word-3);font-size:var(--text-24);flex:1;justify-content:center;align-items:center;display:flex}.pk-image-editor-dialog__size{padding:var(--spacing-8) var(--spacing-md);border-top:1px solid var(--color-surface-3);color:var(--color-word-3);font-size:var(--text-12);font-variant-numeric:tabular-nums;margin:0}"]]]);
937
+ export { Qe as default };
938
+
939
+ //# sourceMappingURL=PkImageEditorDialog-BQwM06kT.js.map