@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
@@ -1,550 +0,0 @@
1
- import { t as e } from "./PkEditorRadioButtons-Bw576DPQ.js";
2
- import { t } from "./VvButtonLocalized-C-vx25u4.js";
3
- import { VvAlert as n, VvButtonGroup as r, VvDialog as i, VvIcon as a } from "@volverjs/ui-vue/components";
4
- import { Fragment as o, computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createTextVNode as f, createVNode as p, defineComponent as m, mergeModels as h, nextTick as g, normalizeClass as _, normalizeStyle as v, onBeforeUnmount as y, onMounted as b, openBlock as x, ref as S, shallowRef as C, toDisplayString as w, unref as T, useId as E, useModel as D, useTemplateRef as O, watch as k, withCtx as A } from "vue";
5
- import { useI18n as ee } from "vue-i18n";
6
- import { useMediaQuery as j, useResizeObserver as M } from "@vueuse/core";
7
- // ../../packages/components/src/chat/imageEdits.ts
8
- var N = 16777216, P = .92, F = 12, I = 32, L = {
9
- "image/jpeg": "jpg",
10
- "image/png": "png",
11
- "image/webp": "webp"
12
- };
13
- function te(e, t = N) {
14
- let n = e.width * e.height;
15
- if (n <= t) return {
16
- width: e.width,
17
- height: e.height
18
- };
19
- let r = Math.sqrt(t / n);
20
- return {
21
- width: Math.max(1, Math.floor(e.width * r)),
22
- height: Math.max(1, Math.floor(e.height * r))
23
- };
24
- }
25
- function ne(e, t) {
26
- let { width: n, height: r } = e;
27
- for (let e of t) e.kind === "rotate" ? [n, r] = [r, n] : e.kind === "crop" && ({width: n, height: r} = e.rect);
28
- return {
29
- width: n,
30
- height: r
31
- };
32
- }
33
- function R(e) {
34
- return Math.max(F, Math.round(Math.min(e.width, e.height) / I));
35
- }
36
- function re(e, t, n, r) {
37
- let i = q(e.x, 0, n.width), a = q(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);
38
- if (r) {
39
- let e = Math.max(Math.abs(o), Math.abs(s) * r);
40
- u = Math.min(e, c, l * r), d = u / r;
41
- }
42
- let f = Math.round(o < 0 ? i - u : i), p = Math.round(s < 0 ? a - d : a);
43
- return {
44
- x: f,
45
- y: p,
46
- width: Math.min(Math.round(u), n.width - f),
47
- height: Math.min(Math.round(d), n.height - p)
48
- };
49
- }
50
- function z(e, t, n, r) {
51
- let i = (e, t) => e + 2 * r > t ? t : e + r;
52
- for (let r = 0; r < n; r = i(r, n)) {
53
- let a = i(r, n);
54
- for (let n = 0; n < t; n = i(n, t)) {
55
- let o = i(n, t), s = 0, c = 0, l = 0, u = 0;
56
- for (let i = r; i < a; i++) for (let r = n; r < o; r++) {
57
- let n = (i * t + r) * 4, a = e[n + 3];
58
- s += e[n] * a, c += e[n + 1] * a, l += e[n + 2] * a, u += a;
59
- }
60
- let d = (a - r) * (o - n), f = u > 0 ? [
61
- s / u,
62
- c / u,
63
- l / u,
64
- u / d
65
- ] : [
66
- 0,
67
- 0,
68
- 0,
69
- 0
70
- ];
71
- for (let i = r; i < a; i++) for (let r = n; r < o; r++) e.set(f, (i * t + r) * 4);
72
- }
73
- }
74
- }
75
- function B(e, t, n) {
76
- let r = L[n];
77
- if (n === t || !r) return e;
78
- let i = e.lastIndexOf(".");
79
- return `${i > 0 ? e.slice(0, i) : e}.${r}`;
80
- }
81
- async function ie(e) {
82
- let t = await createImageBitmap(e, { imageOrientation: "from-image" });
83
- try {
84
- let e = {
85
- width: t.width,
86
- height: t.height
87
- }, n = H(te(e)), r = U(n);
88
- return r.imageSmoothingQuality = "high", r.drawImage(t, 0, 0, n.width, n.height), {
89
- image: n,
90
- original: e
91
- };
92
- } finally {
93
- t.close();
94
- }
95
- }
96
- function ae(e, t) {
97
- let n = H(e);
98
- U(n).drawImage(e, 0, 0);
99
- for (let e of t) {
100
- if (e.kind === "cover") {
101
- K(n, e.rect, e.style);
102
- continue;
103
- }
104
- let t = e.kind === "rotate" ? W(n, e.turn) : G(n, e.rect);
105
- V(n), n = t;
106
- }
107
- return n;
108
- }
109
- function oe(e, t) {
110
- return new Promise((n, r) => {
111
- e.toBlob((e) => e ? n(e) : r(/* @__PURE__ */ Error("The image could not be written")), t, P);
112
- });
113
- }
114
- function V(e) {
115
- e.width = 0, e.height = 0;
116
- }
117
- function H(e) {
118
- let t = document.createElement("canvas");
119
- return t.width = e.width, t.height = e.height, t;
120
- }
121
- function U(e) {
122
- let t = e.getContext("2d");
123
- if (!t) throw Error("No 2D canvas in this browser");
124
- return t;
125
- }
126
- function W(e, t) {
127
- let n = H({
128
- width: e.height,
129
- height: e.width
130
- }), r = U(n);
131
- return r.translate(n.width / 2, n.height / 2), r.rotate(t * Math.PI / 2), r.drawImage(e, -e.width / 2, -e.height / 2), n;
132
- }
133
- function G(e, t) {
134
- let n = H(t);
135
- return U(n).drawImage(e, t.x, t.y, t.width, t.height, 0, 0, t.width, t.height), n;
136
- }
137
- function K(e, t, n) {
138
- let r = U(e);
139
- if (n === "solid") {
140
- r.fillStyle = "#000000", r.fillRect(t.x, t.y, t.width, t.height);
141
- return;
142
- }
143
- let i = r.getImageData(t.x, t.y, t.width, t.height);
144
- z(i.data, t.width, t.height, R(e)), r.putImageData(i, t.x, t.y);
145
- }
146
- function q(e, t, n) {
147
- return Math.min(n, Math.max(t, e));
148
- }
149
- // ../../packages/components/src/chat/PkImageEditor.vue?vue&type=script&setup=true&lang.ts
150
- var se = { class: "pk-image-editor" }, ce = { class: "pk-image-editor__toolbar" }, le = { class: "pk-image-editor__options" }, ue = ["id"], de = { class: "pk-image-editor__hint" }, fe = { class: "pk-image-editor__hint" }, pe = 6, J = /* @__PURE__ */ m({
151
- __name: "PkImageEditor",
152
- props: /*@__PURE__*/ h({ image: {} }, {
153
- edits: { required: !0 },
154
- editsModifiers: {}
155
- }),
156
- emits: /*@__PURE__*/ h(["error"], ["update:edits"]),
157
- setup(n, { expose: i, emit: c }) {
158
- let m = n, h = c, g = D(n, "edits"), { t: C } = ee({ useScope: "global" }), j = {
159
- free: void 0,
160
- "1:1": 1,
161
- "4:3": 4 / 3,
162
- "16:9": 16 / 9
163
- }, N = S("crop"), P = S("free"), F = S("solid"), I = s(() => [{
164
- value: "crop",
165
- label: C("imageEditor.crop")
166
- }, {
167
- value: "cover",
168
- label: C("imageEditor.cover")
169
- }]), L = s(() => [
170
- {
171
- value: "free",
172
- label: C("imageEditor.aspectFree")
173
- },
174
- {
175
- value: "1:1",
176
- label: "1:1"
177
- },
178
- {
179
- value: "4:3",
180
- label: "4:3"
181
- },
182
- {
183
- value: "16:9",
184
- label: "16:9"
185
- }
186
- ]), te = s(() => [{
187
- value: "solid",
188
- label: C("imageEditor.coverSolid")
189
- }, {
190
- value: "pixelate",
191
- label: C("imageEditor.coverPixelate")
192
- }]), R = E(), z = S([]);
193
- function B(e) {
194
- g.value = [...g.value, e], z.value = [];
195
- }
196
- function ie() {
197
- Z.value = void 0;
198
- let e = g.value[g.value.length - 1];
199
- e && (g.value = g.value.slice(0, -1), z.value = [...z.value, e]);
200
- }
201
- function oe() {
202
- Z.value = void 0;
203
- let e = z.value[z.value.length - 1];
204
- e && (g.value = [...g.value, e], z.value = z.value.slice(0, -1));
205
- }
206
- function H(e) {
207
- Z.value = void 0, B({
208
- kind: "rotate",
209
- turn: e
210
- });
211
- }
212
- let U = s(() => ne(m.image, g.value)), W = O("stageEl"), G;
213
- function K() {
214
- if (!W.value) return;
215
- let e;
216
- try {
217
- e = ae(m.image, g.value);
218
- } catch {
219
- h("error");
220
- return;
221
- }
222
- e.setAttribute("role", "img"), e.setAttribute("aria-label", C("imageEditor.canvasLabel")), W.value.replaceChildren(e), G && V(G), G = e;
223
- }
224
- b(K), k([() => m.image, g], K, { flush: "post" }), y(() => {
225
- G && V(G);
226
- });
227
- let q = O("areaEl"), J = S({
228
- width: 0,
229
- height: 0
230
- });
231
- M(q, ([e]) => {
232
- e && (J.value = {
233
- width: e.contentRect.width,
234
- height: e.contentRect.height
235
- });
236
- });
237
- let Y = s(() => Math.min(1, J.value.width / U.value.width, J.value.height / U.value.height)), me = s(() => ({
238
- width: `${Math.max(1, Math.floor(U.value.width * Y.value))}px`,
239
- height: `${Math.max(1, Math.floor(U.value.height * Y.value))}px`
240
- })), X = O("frameEl"), Z = S(), Q = S();
241
- function he(e) {
242
- let t = X.value?.getBoundingClientRect();
243
- return !t?.width || !t.height ? {
244
- x: 0,
245
- y: 0
246
- } : {
247
- x: (e.clientX - t.left) / t.width * U.value.width,
248
- y: (e.clientY - t.top) / t.height * U.value.height
249
- };
250
- }
251
- function ge(e) {
252
- e.button === 0 && (X.value?.setPointerCapture(e.pointerId), Q.value = he(e), Z.value = void 0);
253
- }
254
- function _e(e) {
255
- Q.value && (Z.value = re(Q.value, he(e), U.value, N.value === "crop" ? j[P.value] : void 0));
256
- }
257
- function ve() {
258
- if (!Q.value) return;
259
- Q.value = void 0;
260
- let e = Z.value;
261
- !e || e.width * Y.value < pe || e.height * Y.value < pe ? Z.value = void 0 : N.value === "cover" && (Z.value = void 0, B({
262
- kind: "cover",
263
- rect: e,
264
- style: F.value
265
- }));
266
- }
267
- function ye() {
268
- Q.value = void 0, Z.value = void 0;
269
- }
270
- let $ = s(() => N.value === "crop" && !Q.value && !!Z.value);
271
- function be() {
272
- let e = Z.value;
273
- $.value && e && (Z.value = void 0, (e.width !== U.value.width || e.height !== U.value.height) && B({
274
- kind: "crop",
275
- rect: e
276
- }));
277
- }
278
- k(N, () => {
279
- Z.value = void 0;
280
- }), k(P, (e) => {
281
- let t = Z.value;
282
- t && N.value === "crop" && (Z.value = re(t, {
283
- x: t.x + t.width,
284
- y: t.y + t.height
285
- }, U.value, j[e]));
286
- });
287
- let xe = s(() => {
288
- let e = Z.value;
289
- if (e) return {
290
- left: `${e.x / U.value.width * 100}%`,
291
- top: `${e.y / U.value.height * 100}%`,
292
- width: `${e.width / U.value.width * 100}%`,
293
- height: `${e.height / U.value.height * 100}%`
294
- };
295
- });
296
- return i({
297
- pendingCrop: $,
298
- applyCrop: be,
299
- shownCanvas: () => G
300
- }), (n, i) => {
301
- let s = a, c = t, m = r;
302
- return x(), u("div", se, [
303
- d("div", ce, [
304
- p(e, {
305
- modelValue: N.value,
306
- "onUpdate:modelValue": i[0] ||= (e) => N.value = e,
307
- name: "pk-image-editor-tool",
308
- segmented: "",
309
- class: "mb-0",
310
- "aria-label": T(C)("imageEditor.tool"),
311
- options: I.value
312
- }, {
313
- crop: A(({ option: e }) => [p(s, {
314
- name: "ri:crop-line",
315
- class: "w-16 h-16"
316
- }), f(" " + w(e.label), 1)]),
317
- cover: A(({ option: e }) => [p(s, {
318
- name: "ri:eye-off-line",
319
- class: "w-16 h-16"
320
- }), f(" " + w(e.label), 1)]),
321
- _: 1
322
- }, 8, [
323
- "modelValue",
324
- "aria-label",
325
- "options"
326
- ]),
327
- p(m, { modifiers: "compact" }, {
328
- default: A(() => [p(c, {
329
- modifiers: "action-quiet",
330
- icon: "ri:anticlockwise-line",
331
- title: T(C)("imageEditor.rotateLeft"),
332
- "aria-label": T(C)("imageEditor.rotateLeft"),
333
- onClick: i[1] ||= (e) => H(-1)
334
- }, null, 8, ["title", "aria-label"]), p(c, {
335
- modifiers: "action-quiet",
336
- icon: "ri:clockwise-line",
337
- title: T(C)("imageEditor.rotateRight"),
338
- "aria-label": T(C)("imageEditor.rotateRight"),
339
- onClick: i[2] ||= (e) => H(1)
340
- }, null, 8, ["title", "aria-label"])]),
341
- _: 1
342
- }),
343
- p(m, {
344
- modifiers: "compact",
345
- class: "ml-auto"
346
- }, {
347
- default: A(() => [p(c, {
348
- modifiers: "action-quiet",
349
- icon: "ri:arrow-go-back-line",
350
- title: T(C)("imageEditor.undo"),
351
- "aria-label": T(C)("imageEditor.undo"),
352
- disabled: !g.value.length,
353
- onClick: ie
354
- }, null, 8, [
355
- "title",
356
- "aria-label",
357
- "disabled"
358
- ]), p(c, {
359
- modifiers: "action-quiet",
360
- icon: "ri:arrow-go-forward-line",
361
- title: T(C)("imageEditor.redo"),
362
- "aria-label": T(C)("imageEditor.redo"),
363
- disabled: !z.value.length,
364
- onClick: oe
365
- }, null, 8, [
366
- "title",
367
- "aria-label",
368
- "disabled"
369
- ])]),
370
- _: 1
371
- })
372
- ]),
373
- d("div", le, [N.value === "crop" ? (x(), u(o, { key: 0 }, [
374
- d("span", {
375
- id: T(R),
376
- class: "pk-image-editor__label"
377
- }, w(T(C)("imageEditor.aspect")), 9, ue),
378
- p(e, {
379
- modelValue: P.value,
380
- "onUpdate:modelValue": i[3] ||= (e) => P.value = e,
381
- name: "pk-image-editor-aspect",
382
- segmented: "",
383
- class: "mb-0",
384
- "aria-labelledby": T(R),
385
- options: L.value
386
- }, null, 8, [
387
- "modelValue",
388
- "aria-labelledby",
389
- "options"
390
- ]),
391
- d("span", de, w(T(C)("imageEditor.cropHint")), 1),
392
- p(c, {
393
- class: "ml-auto",
394
- modifiers: "secondary",
395
- label: T(C)("action.apply"),
396
- disabled: !$.value,
397
- onClick: be
398
- }, null, 8, ["label", "disabled"])
399
- ], 64)) : (x(), u(o, { key: 1 }, [p(e, {
400
- modelValue: F.value,
401
- "onUpdate:modelValue": i[4] ||= (e) => F.value = e,
402
- name: "pk-image-editor-cover",
403
- segmented: "",
404
- class: "mb-0",
405
- "aria-label": T(C)("imageEditor.coverStyle"),
406
- options: te.value
407
- }, null, 8, [
408
- "modelValue",
409
- "aria-label",
410
- "options"
411
- ]), d("span", fe, w(T(C)("imageEditor.coverHint")), 1)], 64))]),
412
- d("div", {
413
- ref_key: "areaEl",
414
- ref: q,
415
- class: "pk-image-editor__area"
416
- }, [d("div", {
417
- ref_key: "frameEl",
418
- ref: X,
419
- class: "pk-image-editor__frame",
420
- style: v(me.value),
421
- onPointerdown: ge,
422
- onPointermove: _e,
423
- onPointerup: ve,
424
- onPointercancel: ye
425
- }, [d("div", {
426
- ref_key: "stageEl",
427
- ref: W,
428
- class: "pk-image-editor__stage"
429
- }, null, 512), Z.value ? (x(), u("div", {
430
- key: 0,
431
- class: _(["pk-image-editor__selection", `pk-image-editor__selection--${N.value}`]),
432
- style: v(xe.value)
433
- }, null, 6)) : l("", !0)], 36)], 512)
434
- ]);
435
- };
436
- }
437
- }), Y = ["aria-label"], me = {
438
- key: 3,
439
- class: "pk-image-editor-dialog__size"
440
- }, X = /* @__PURE__ */ m({
441
- __name: "PkImageEditorDialog",
442
- props: { file: {} },
443
- emits: ["close", "apply"],
444
- setup(e, { emit: o }) {
445
- let d = e, f = o, { t: m } = ee({ useScope: "global" }), h = j("(max-width: 575.98px)"), _ = C(), v = S(), E = S([]), D = S(!1), k = O("editorEl");
446
- b(async () => {
447
- try {
448
- _.value = await ie(d.file);
449
- } catch {
450
- v.value = "load";
451
- }
452
- }), y(() => {
453
- _.value && V(_.value.image);
454
- });
455
- let M = s(() => _.value && ne(_.value.image, E.value)), N = s(() => !!_.value && _.value.image.width < _.value.original.width), P = s(() => E.value.length > 0 || !!k.value?.pendingCrop);
456
- async function F() {
457
- let e = k.value;
458
- if (e) {
459
- if (e.applyCrop(), !E.value.length) f("close");
460
- else {
461
- v.value = void 0, D.value = !0;
462
- try {
463
- await g();
464
- let t = e.shownCanvas();
465
- if (v.value === "draw") return;
466
- if (!t) throw Error("No image drawn");
467
- let n = await oe(t, d.file.type);
468
- f("apply", new File([n], B(d.file.name, d.file.type, n.type), {
469
- type: n.type,
470
- lastModified: Date.now()
471
- }));
472
- } catch {
473
- v.value = "export";
474
- } finally {
475
- D.value = !1;
476
- }
477
- }
478
- }
479
- }
480
- let I = s(() => {
481
- switch (v.value) {
482
- case "export": return m("imageEditor.exportFailed");
483
- case "draw": return m("imageEditor.drawFailed");
484
- default: return m("imageEditor.loadFailed");
485
- }
486
- });
487
- return (e, o) => {
488
- let s = n, d = a, g = t, y = r, b = i;
489
- return x(), c(b, {
490
- "model-value": !0,
491
- title: T(m)("imageEditor.title"),
492
- modifiers: T(h) ? "fullscreen" : void 0,
493
- "keep-open": "",
494
- class: "pk-image-editor-dialog",
495
- "onUpdate:modelValue": o[3] ||= (e) => !e && f("close")
496
- }, {
497
- footer: A(() => [p(y, null, {
498
- default: A(() => [p(g, {
499
- modifiers: "secondary",
500
- label: T(m)("action.cancel"),
501
- onClick: o[2] ||= (e) => f("close")
502
- }, null, 8, ["label"]), p(g, {
503
- label: T(m)("imageEditor.use"),
504
- loading: D.value,
505
- disabled: D.value || !P.value || v.value === "draw",
506
- onClick: F
507
- }, null, 8, [
508
- "label",
509
- "loading",
510
- "disabled"
511
- ])]),
512
- _: 1
513
- })]),
514
- default: A(() => [
515
- v.value ? (x(), c(s, {
516
- key: 0,
517
- modifiers: "danger",
518
- class: "m-md",
519
- content: I.value
520
- }, null, 8, ["content"])) : l("", !0),
521
- _.value && v.value !== "draw" ? (x(), c(J, {
522
- key: 1,
523
- ref_key: "editorEl",
524
- ref: k,
525
- edits: E.value,
526
- "onUpdate:edits": o[0] ||= (e) => E.value = e,
527
- image: _.value.image,
528
- onError: o[1] ||= (e) => v.value = "draw"
529
- }, null, 8, ["edits", "image"])) : v.value ? l("", !0) : (x(), u("div", {
530
- key: 2,
531
- class: "pk-image-editor-dialog__loading",
532
- role: "status",
533
- "aria-label": T(m)("imageEditor.loading")
534
- }, [p(d, { name: "loading-loop" })], 8, Y)),
535
- M.value ? (x(), u("p", me, w(N.value ? T(m)("imageEditor.sizeScaledDown", {
536
- width: M.value.width,
537
- height: M.value.height
538
- }) : T(m)("imageEditor.size", {
539
- width: M.value.width,
540
- height: M.value.height
541
- })), 1)) : l("", !0)
542
- ]),
543
- _: 1
544
- }, 8, ["title", "modifiers"]);
545
- };
546
- }
547
- });
548
- export { X as default };
549
-
550
- //# sourceMappingURL=PkImageEditorDialog-BLUyILVi.js.map