swerasty_editor 0.1.3 → 0.1.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.
- package/dist/swerasty-editor.js +141 -140
- package/dist/swerasty-editor.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/swerasty-editor.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as g, jsxs as
|
|
1
|
+
import { jsx as g, jsxs as R, Fragment as Qo } from "react/jsx-runtime";
|
|
2
2
|
import Zn, { useState as F, forwardRef as De, createElement as Je, useRef as ie, useCallback as Te, useEffect as Ae, useImperativeHandle as jn } from "react";
|
|
3
3
|
const Zo = ({ isOpen: t, onClose: e, onInsert: n }) => {
|
|
4
4
|
const [o, s] = F(3), [l, a] = F(3);
|
|
5
|
-
return t ? /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[60] flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm", onClick: e, children: /* @__PURE__ */
|
|
5
|
+
return t ? /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[60] flex items-center justify-center bg-black bg-opacity-50 backdrop-blur-sm", onClick: e, children: /* @__PURE__ */ R("div", { className: "bg-white rounded-lg shadow-xl p-6 w-full max-w-sm", onClick: (c) => c.stopPropagation(), children: [
|
|
6
6
|
/* @__PURE__ */ g("h3", { className: "text-lg font-semibold text-gray-800 mb-4", children: "Insert Table" }),
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */
|
|
7
|
+
/* @__PURE__ */ R("div", { className: "space-y-4", children: [
|
|
8
|
+
/* @__PURE__ */ R("div", { children: [
|
|
9
9
|
/* @__PURE__ */ g("label", { htmlFor: "rows", className: "block text-sm font-medium text-gray-700 mb-1", children: "Rows" }),
|
|
10
10
|
/* @__PURE__ */ g(
|
|
11
11
|
"input",
|
|
@@ -18,7 +18,7 @@ const Zo = ({ isOpen: t, onClose: e, onInsert: n }) => {
|
|
|
18
18
|
}
|
|
19
19
|
)
|
|
20
20
|
] }),
|
|
21
|
-
/* @__PURE__ */
|
|
21
|
+
/* @__PURE__ */ R("div", { children: [
|
|
22
22
|
/* @__PURE__ */ g("label", { htmlFor: "cols", className: "block text-sm font-medium text-gray-700 mb-1", children: "Columns" }),
|
|
23
23
|
/* @__PURE__ */ g(
|
|
24
24
|
"input",
|
|
@@ -32,7 +32,7 @@ const Zo = ({ isOpen: t, onClose: e, onInsert: n }) => {
|
|
|
32
32
|
)
|
|
33
33
|
] })
|
|
34
34
|
] }),
|
|
35
|
-
/* @__PURE__ */
|
|
35
|
+
/* @__PURE__ */ R("div", { className: "mt-6 flex justify-end space-x-3", children: [
|
|
36
36
|
/* @__PURE__ */ g("button", { onClick: e, className: "px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition", children: "Cancel" }),
|
|
37
37
|
/* @__PURE__ */ g("button", { onClick: () => {
|
|
38
38
|
o > 0 && l > 0 && n(o, l);
|
|
@@ -280,17 +280,17 @@ const Si = [
|
|
|
280
280
|
const Ai = [
|
|
281
281
|
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
|
|
282
282
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
283
|
-
],
|
|
283
|
+
], wi = V("rotate-ccw", Ai);
|
|
284
284
|
/**
|
|
285
285
|
* @license lucide-react v0.562.0 - ISC
|
|
286
286
|
*
|
|
287
287
|
* This source code is licensed under the ISC license.
|
|
288
288
|
* See the LICENSE file in the root directory of this source tree.
|
|
289
289
|
*/
|
|
290
|
-
const
|
|
290
|
+
const Ri = [
|
|
291
291
|
["path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8", key: "1p45f6" }],
|
|
292
292
|
["path", { d: "M21 3v5h-5", key: "1q7to0" }]
|
|
293
|
-
], Ni = V("rotate-cw",
|
|
293
|
+
], Ni = V("rotate-cw", Ri);
|
|
294
294
|
/**
|
|
295
295
|
* @license lucide-react v0.562.0 - ISC
|
|
296
296
|
*
|
|
@@ -419,14 +419,14 @@ const Bi = [
|
|
|
419
419
|
children: _
|
|
420
420
|
}
|
|
421
421
|
);
|
|
422
|
-
return /* @__PURE__ */
|
|
423
|
-
/* @__PURE__ */
|
|
424
|
-
/* @__PURE__ */
|
|
422
|
+
return /* @__PURE__ */ R(Qo, { children: [
|
|
423
|
+
/* @__PURE__ */ R("div", { className: "bg-white px-4 py-2 flex flex-wrap items-center gap-1 border-b border-slate-200 sticky top-0 z-20 shadow-sm", children: [
|
|
424
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-1 pr-2 border-r border-slate-200", children: [
|
|
425
425
|
/* @__PURE__ */ g(h, { onClick: n, disabled: !s, title: "Undo", children: /* @__PURE__ */ g(Hi, { size: 18 }) }),
|
|
426
426
|
/* @__PURE__ */ g(h, { onClick: o, disabled: !l, title: "Redo", children: /* @__PURE__ */ g(xi, { size: 18 }) })
|
|
427
427
|
] }),
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
/* @__PURE__ */
|
|
428
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-1 px-2 border-r border-slate-200", children: [
|
|
429
|
+
/* @__PURE__ */ R(
|
|
430
430
|
"select",
|
|
431
431
|
{
|
|
432
432
|
onChange: (p) => e("fontName", p.target.value),
|
|
@@ -449,27 +449,27 @@ const Bi = [
|
|
|
449
449
|
}
|
|
450
450
|
)
|
|
451
451
|
] }),
|
|
452
|
-
/* @__PURE__ */
|
|
452
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-0.5 px-2 border-r border-slate-200", children: [
|
|
453
453
|
/* @__PURE__ */ g(h, { onClick: () => e("bold"), title: "Bold", children: /* @__PURE__ */ g(si, { size: 18 }) }),
|
|
454
454
|
/* @__PURE__ */ g(h, { onClick: () => e("italic"), title: "Italic", children: /* @__PURE__ */ g(ci, { size: 18 }) }),
|
|
455
455
|
/* @__PURE__ */ g(h, { onClick: () => e("underline"), title: "Underline", children: /* @__PURE__ */ g(Vi, { size: 18 }) }),
|
|
456
456
|
/* @__PURE__ */ g(h, { onClick: () => e("strikeThrough"), title: "Strikethrough", children: /* @__PURE__ */ g(Di, { size: 18 }) })
|
|
457
457
|
] }),
|
|
458
|
-
/* @__PURE__ */
|
|
459
|
-
/* @__PURE__ */
|
|
458
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-1 px-2 border-r border-slate-200", children: [
|
|
459
|
+
/* @__PURE__ */ R("label", { className: "p-2 hover:bg-slate-100 rounded-md cursor-pointer relative group", title: "Text Color", children: [
|
|
460
460
|
/* @__PURE__ */ g(Ci, { size: 18, className: "text-slate-600" }),
|
|
461
461
|
/* @__PURE__ */ g("input", { type: "color", onChange: (p) => e("foreColor", p.target.value), className: "opacity-0 absolute inset-0 cursor-pointer w-full h-full" })
|
|
462
462
|
] }),
|
|
463
|
-
/* @__PURE__ */
|
|
463
|
+
/* @__PURE__ */ R("label", { className: "p-2 hover:bg-slate-100 rounded-md cursor-pointer relative group", title: "Highlight Color", children: [
|
|
464
464
|
/* @__PURE__ */ g(li, { size: 18, className: "text-slate-600" }),
|
|
465
465
|
/* @__PURE__ */ g("input", { type: "color", defaultValue: "#FFFF00", onChange: (p) => e("backColor", p.target.value), className: "opacity-0 absolute inset-0 cursor-pointer w-full h-full" })
|
|
466
466
|
] })
|
|
467
467
|
] }),
|
|
468
|
-
/* @__PURE__ */
|
|
468
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-0.5 px-2 border-r border-slate-200", children: [
|
|
469
469
|
/* @__PURE__ */ g(h, { onClick: () => e("insertOrderedList"), title: "Numbered List", children: /* @__PURE__ */ g(mi, { size: 18 }) }),
|
|
470
470
|
/* @__PURE__ */ g(h, { onClick: () => e("insertUnorderedList"), title: "Bullet List", children: /* @__PURE__ */ g(yi, { size: 18 }) })
|
|
471
471
|
] }),
|
|
472
|
-
/* @__PURE__ */
|
|
472
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-0.5 px-2", children: [
|
|
473
473
|
/* @__PURE__ */ g(h, { onClick: () => {
|
|
474
474
|
var p;
|
|
475
475
|
return (p = c.current) == null ? void 0 : p.click();
|
|
@@ -477,7 +477,7 @@ const Bi = [
|
|
|
477
477
|
/* @__PURE__ */ g("input", { type: "file", ref: c, onChange: d, accept: "image/*", className: "hidden" }),
|
|
478
478
|
/* @__PURE__ */ g(h, { onClick: () => u(!0), title: "Insert Table", children: /* @__PURE__ */ g(Li, { size: 18 }) })
|
|
479
479
|
] }),
|
|
480
|
-
/* @__PURE__ */ g("div", { className: "ml-auto flex items-center", children: /* @__PURE__ */
|
|
480
|
+
/* @__PURE__ */ g("div", { className: "ml-auto flex items-center", children: /* @__PURE__ */ R(
|
|
481
481
|
"button",
|
|
482
482
|
{
|
|
483
483
|
onClick: t,
|
|
@@ -504,16 +504,17 @@ const Bi = [
|
|
|
504
504
|
canRedo: h < d.length - 1
|
|
505
505
|
});
|
|
506
506
|
}, [d, h, t]), Ae(() => {
|
|
507
|
+
if (typeof window > "u") return;
|
|
507
508
|
const C = n.current, v = o.current;
|
|
508
509
|
if (!C || !v) return;
|
|
509
510
|
c.current = C.getContext("2d");
|
|
510
511
|
const I = new ResizeObserver((A) => {
|
|
511
512
|
var P;
|
|
512
|
-
const { width: N, height:
|
|
513
|
-
C.width = N, C.height =
|
|
513
|
+
const { width: N, height: w } = A[0].contentRect, U = (P = c.current) == null ? void 0 : P.getImageData(0, 0, C.width, C.height);
|
|
514
|
+
C.width = N, C.height = w;
|
|
514
515
|
const x = c.current;
|
|
515
516
|
if (x && (x.lineCap = "round", x.strokeStyle = "#000", x.lineWidth = 2, U && x.putImageData(U, 0, 0)), d.length === 0) {
|
|
516
|
-
const b = x == null ? void 0 : x.getImageData(0, 0, N,
|
|
517
|
+
const b = x == null ? void 0 : x.getImageData(0, 0, N, w);
|
|
517
518
|
b && (f([b]), p(0));
|
|
518
519
|
}
|
|
519
520
|
});
|
|
@@ -574,11 +575,11 @@ const Bi = [
|
|
|
574
575
|
getTrimmedImageData() {
|
|
575
576
|
const C = n.current, v = c.current;
|
|
576
577
|
if (!a || !C || !v) return null;
|
|
577
|
-
const I = C.width, A = C.height,
|
|
578
|
+
const I = C.width, A = C.height, w = v.getImageData(0, 0, I, A).data;
|
|
578
579
|
let U = I, x = A, P = 0, b = 0;
|
|
579
580
|
for (let z = 0; z < A; z++)
|
|
580
581
|
for (let he = 0; he < I; he++)
|
|
581
|
-
|
|
582
|
+
w[(I * z + he) * 4 + 3] > 0 && (U = Math.min(U, he), x = Math.min(x, z), P = Math.max(P, he), b = Math.max(b, z));
|
|
582
583
|
if (U === I)
|
|
583
584
|
return null;
|
|
584
585
|
const k = 15;
|
|
@@ -971,14 +972,14 @@ var At;
|
|
|
971
972
|
(function(t) {
|
|
972
973
|
t.HARM_BLOCK_METHOD_UNSPECIFIED = "HARM_BLOCK_METHOD_UNSPECIFIED", t.SEVERITY = "SEVERITY", t.PROBABILITY = "PROBABILITY";
|
|
973
974
|
})(At || (At = {}));
|
|
974
|
-
var
|
|
975
|
+
var wt;
|
|
975
976
|
(function(t) {
|
|
976
977
|
t.HARM_BLOCK_THRESHOLD_UNSPECIFIED = "HARM_BLOCK_THRESHOLD_UNSPECIFIED", t.BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE", t.BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE", t.BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH", t.BLOCK_NONE = "BLOCK_NONE", t.OFF = "OFF";
|
|
977
|
-
})(
|
|
978
|
-
var
|
|
978
|
+
})(wt || (wt = {}));
|
|
979
|
+
var Rt;
|
|
979
980
|
(function(t) {
|
|
980
981
|
t.FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED", t.STOP = "STOP", t.MAX_TOKENS = "MAX_TOKENS", t.SAFETY = "SAFETY", t.RECITATION = "RECITATION", t.LANGUAGE = "LANGUAGE", t.OTHER = "OTHER", t.BLOCKLIST = "BLOCKLIST", t.PROHIBITED_CONTENT = "PROHIBITED_CONTENT", t.SPII = "SPII", t.MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL", t.IMAGE_SAFETY = "IMAGE_SAFETY", t.UNEXPECTED_TOOL_CALL = "UNEXPECTED_TOOL_CALL", t.IMAGE_PROHIBITED_CONTENT = "IMAGE_PROHIBITED_CONTENT", t.NO_IMAGE = "NO_IMAGE", t.IMAGE_RECITATION = "IMAGE_RECITATION", t.IMAGE_OTHER = "IMAGE_OTHER";
|
|
981
|
-
})(
|
|
982
|
+
})(Rt || (Rt = {}));
|
|
982
983
|
var Nt;
|
|
983
984
|
(function(t) {
|
|
984
985
|
t.HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED", t.NEGLIGIBLE = "NEGLIGIBLE", t.LOW = "LOW", t.MEDIUM = "MEDIUM", t.HIGH = "HIGH";
|
|
@@ -999,10 +1000,10 @@ var Dt;
|
|
|
999
1000
|
(function(t) {
|
|
1000
1001
|
t.TRAFFIC_TYPE_UNSPECIFIED = "TRAFFIC_TYPE_UNSPECIFIED", t.ON_DEMAND = "ON_DEMAND", t.PROVISIONED_THROUGHPUT = "PROVISIONED_THROUGHPUT";
|
|
1001
1002
|
})(Dt || (Dt = {}));
|
|
1002
|
-
var
|
|
1003
|
+
var we;
|
|
1003
1004
|
(function(t) {
|
|
1004
1005
|
t.MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED", t.TEXT = "TEXT", t.IMAGE = "IMAGE", t.AUDIO = "AUDIO";
|
|
1005
|
-
})(
|
|
1006
|
+
})(we || (we = {}));
|
|
1006
1007
|
var Ut;
|
|
1007
1008
|
(function(t) {
|
|
1008
1009
|
t.MEDIA_RESOLUTION_UNSPECIFIED = "MEDIA_RESOLUTION_UNSPECIFIED", t.MEDIA_RESOLUTION_LOW = "MEDIA_RESOLUTION_LOW", t.MEDIA_RESOLUTION_MEDIUM = "MEDIA_RESOLUTION_MEDIUM", t.MEDIA_RESOLUTION_HIGH = "MEDIA_RESOLUTION_HIGH";
|
|
@@ -1361,13 +1362,13 @@ class _n {
|
|
|
1361
1362
|
}
|
|
1362
1363
|
class hs {
|
|
1363
1364
|
}
|
|
1364
|
-
class
|
|
1365
|
+
class Re {
|
|
1365
1366
|
/**
|
|
1366
1367
|
* Instantiates an Operation of the same type as the one being called with the fields set from the API response.
|
|
1367
1368
|
* @internal
|
|
1368
1369
|
*/
|
|
1369
1370
|
_fromAPIResponse({ apiResponse: e, _isVertexAI: n }) {
|
|
1370
|
-
const o = new
|
|
1371
|
+
const o = new Re();
|
|
1371
1372
|
let s;
|
|
1372
1373
|
const l = e;
|
|
1373
1374
|
return n ? s = Zi(l) : s = Qi(l), Object.assign(o, s), o;
|
|
@@ -1535,7 +1536,7 @@ function Ke(t) {
|
|
|
1535
1536
|
function An(t) {
|
|
1536
1537
|
return t != null && typeof t == "object" && "functionCall" in t;
|
|
1537
1538
|
}
|
|
1538
|
-
function
|
|
1539
|
+
function wn(t) {
|
|
1539
1540
|
return t != null && typeof t == "object" && "functionResponse" in t;
|
|
1540
1541
|
}
|
|
1541
1542
|
function B(t) {
|
|
@@ -1564,7 +1565,7 @@ function Y(t) {
|
|
|
1564
1565
|
if (t == null || Array.isArray(t) && t.length === 0)
|
|
1565
1566
|
throw new Error("contents are required");
|
|
1566
1567
|
if (!Array.isArray(t)) {
|
|
1567
|
-
if (An(t) ||
|
|
1568
|
+
if (An(t) || wn(t))
|
|
1568
1569
|
throw new Error("To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them");
|
|
1569
1570
|
return [B(t)];
|
|
1570
1571
|
}
|
|
@@ -1576,7 +1577,7 @@ function Y(t) {
|
|
|
1576
1577
|
if (l)
|
|
1577
1578
|
e.push(s);
|
|
1578
1579
|
else {
|
|
1579
|
-
if (An(s) ||
|
|
1580
|
+
if (An(s) || wn(s))
|
|
1580
1581
|
throw new Error("To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them");
|
|
1581
1582
|
n.push(s);
|
|
1582
1583
|
}
|
|
@@ -1703,13 +1704,13 @@ function xs(t) {
|
|
|
1703
1704
|
function As(t) {
|
|
1704
1705
|
return t != null && typeof t == "object" && "video" in t;
|
|
1705
1706
|
}
|
|
1706
|
-
function
|
|
1707
|
+
function ws(t) {
|
|
1707
1708
|
return t != null && typeof t == "object" && "uri" in t;
|
|
1708
1709
|
}
|
|
1709
1710
|
function uo(t) {
|
|
1710
1711
|
var e;
|
|
1711
1712
|
let n;
|
|
1712
|
-
if (xs(t) && (n = t.name), !(
|
|
1713
|
+
if (xs(t) && (n = t.name), !(ws(t) && (n = t.uri, n === void 0)) && !(As(t) && (n = (e = t.video) === null || e === void 0 ? void 0 : e.uri, n === void 0))) {
|
|
1713
1714
|
if (typeof t == "string" && (n = t), n === void 0)
|
|
1714
1715
|
throw new Error("Could not extract file name from the provided input.");
|
|
1715
1716
|
if (n.startsWith("https://")) {
|
|
@@ -1727,11 +1728,11 @@ function co(t, e) {
|
|
|
1727
1728
|
}
|
|
1728
1729
|
function fo(t) {
|
|
1729
1730
|
for (const e of ["models", "tunedModels", "publisherModels"])
|
|
1730
|
-
if (
|
|
1731
|
+
if (Rs(t, e))
|
|
1731
1732
|
return t[e];
|
|
1732
1733
|
return [];
|
|
1733
1734
|
}
|
|
1734
|
-
function
|
|
1735
|
+
function Rs(t, e) {
|
|
1735
1736
|
return t !== null && typeof t == "object" && e in t;
|
|
1736
1737
|
}
|
|
1737
1738
|
function Ns(t, e = {}) {
|
|
@@ -2078,7 +2079,7 @@ function $s(t, e) {
|
|
|
2078
2079
|
const s = i(t, ["dest"]);
|
|
2079
2080
|
return e !== void 0 && s != null && r(e, ["outputConfig"], Us(Ps(s))), n;
|
|
2080
2081
|
}
|
|
2081
|
-
function
|
|
2082
|
+
function Rn(t, e) {
|
|
2082
2083
|
const n = {}, o = i(e, ["model"]);
|
|
2083
2084
|
o != null && r(n, ["_url", "model"], L(t, o));
|
|
2084
2085
|
const s = i(e, ["src"]);
|
|
@@ -2273,10 +2274,10 @@ function ir(t, e, n) {
|
|
|
2273
2274
|
"cachedContent"
|
|
2274
2275
|
]);
|
|
2275
2276
|
n !== void 0 && N != null && r(n, ["cachedContent"], ee(t, N));
|
|
2276
|
-
const
|
|
2277
|
+
const w = i(e, [
|
|
2277
2278
|
"responseModalities"
|
|
2278
2279
|
]);
|
|
2279
|
-
|
|
2280
|
+
w != null && r(o, ["responseModalities"], w);
|
|
2280
2281
|
const U = i(e, [
|
|
2281
2282
|
"mediaResolution"
|
|
2282
2283
|
]);
|
|
@@ -2671,7 +2672,7 @@ class Ir extends j {
|
|
|
2671
2672
|
}
|
|
2672
2673
|
// Helper function to handle inlined generate content requests
|
|
2673
2674
|
createInlinedGenerateContentRequest(e) {
|
|
2674
|
-
const n =
|
|
2675
|
+
const n = Rn(
|
|
2675
2676
|
this.apiClient,
|
|
2676
2677
|
// Use instance apiClient
|
|
2677
2678
|
e
|
|
@@ -2737,7 +2738,7 @@ class Ir extends j {
|
|
|
2737
2738
|
abortSignal: (o = e.config) === null || o === void 0 ? void 0 : o.abortSignal
|
|
2738
2739
|
}).then((f) => f.json()), a.then((f) => ze(f));
|
|
2739
2740
|
} else {
|
|
2740
|
-
const d =
|
|
2741
|
+
const d = Rn(this.apiClient, e);
|
|
2741
2742
|
return u = S("{model}:batchGenerateContent", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
2742
2743
|
path: u,
|
|
2743
2744
|
queryParams: c,
|
|
@@ -3005,13 +3006,13 @@ function Ar(t, e) {
|
|
|
3005
3006
|
const f = i(t, ["kmsKeyName"]);
|
|
3006
3007
|
return e !== void 0 && f != null && r(e, ["encryption_spec", "kmsKeyName"], f), n;
|
|
3007
3008
|
}
|
|
3008
|
-
function
|
|
3009
|
+
function wr(t, e) {
|
|
3009
3010
|
const n = {}, o = i(e, ["model"]);
|
|
3010
3011
|
o != null && r(n, ["model"], oo(t, o));
|
|
3011
3012
|
const s = i(e, ["config"]);
|
|
3012
3013
|
return s != null && xr(s, n), n;
|
|
3013
3014
|
}
|
|
3014
|
-
function
|
|
3015
|
+
function Rr(t, e) {
|
|
3015
3016
|
const n = {}, o = i(e, ["model"]);
|
|
3016
3017
|
o != null && r(n, ["model"], oo(t, o));
|
|
3017
3018
|
const s = i(e, ["config"]);
|
|
@@ -3342,7 +3343,7 @@ class tl extends j {
|
|
|
3342
3343
|
var n, o, s, l;
|
|
3343
3344
|
let a, u = "", c = {};
|
|
3344
3345
|
if (this.apiClient.isVertexAI()) {
|
|
3345
|
-
const d =
|
|
3346
|
+
const d = Rr(this.apiClient, e);
|
|
3346
3347
|
return u = S("cachedContents", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
3347
3348
|
path: u,
|
|
3348
3349
|
queryParams: c,
|
|
@@ -3352,7 +3353,7 @@ class tl extends j {
|
|
|
3352
3353
|
abortSignal: (o = e.config) === null || o === void 0 ? void 0 : o.abortSignal
|
|
3353
3354
|
}).then((f) => f.json()), a.then((f) => f);
|
|
3354
3355
|
} else {
|
|
3355
|
-
const d =
|
|
3356
|
+
const d = wr(this.apiClient, e);
|
|
3356
3357
|
return u = S("cachedContents", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
3357
3358
|
path: u,
|
|
3358
3359
|
queryParams: c,
|
|
@@ -4227,8 +4228,8 @@ function _l(t) {
|
|
|
4227
4228
|
A != null && r(e, ["thinkingConfig"], A);
|
|
4228
4229
|
const N = i(t, ["topK"]);
|
|
4229
4230
|
N != null && r(e, ["topK"], N);
|
|
4230
|
-
const
|
|
4231
|
-
if (
|
|
4231
|
+
const w = i(t, ["topP"]);
|
|
4232
|
+
if (w != null && r(e, ["topP"], w), i(t, ["enableEnhancedCivicAnswers"]) !== void 0)
|
|
4232
4233
|
throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");
|
|
4233
4234
|
return e;
|
|
4234
4235
|
}
|
|
@@ -4292,7 +4293,7 @@ function vl(t, e) {
|
|
|
4292
4293
|
const _ = i(t, ["tools"]);
|
|
4293
4294
|
if (e !== void 0 && _ != null) {
|
|
4294
4295
|
let N = fe(_);
|
|
4295
|
-
Array.isArray(N) && (N = N.map((
|
|
4296
|
+
Array.isArray(N) && (N = N.map((w) => Dl(ce(w)))), r(e, ["setup", "tools"], N);
|
|
4296
4297
|
}
|
|
4297
4298
|
const T = i(t, [
|
|
4298
4299
|
"sessionResumption"
|
|
@@ -4360,8 +4361,8 @@ function Il(t, e) {
|
|
|
4360
4361
|
e !== void 0 && y != null && r(e, ["setup", "systemInstruction"], B(y));
|
|
4361
4362
|
const _ = i(t, ["tools"]);
|
|
4362
4363
|
if (e !== void 0 && _ != null) {
|
|
4363
|
-
let
|
|
4364
|
-
Array.isArray(
|
|
4364
|
+
let w = fe(_);
|
|
4365
|
+
Array.isArray(w) && (w = w.map((U) => Ul(ce(U)))), r(e, ["setup", "tools"], w);
|
|
4365
4366
|
}
|
|
4366
4367
|
const T = i(t, [
|
|
4367
4368
|
"sessionResumption"
|
|
@@ -4408,7 +4409,7 @@ function Al(t) {
|
|
|
4408
4409
|
]);
|
|
4409
4410
|
return n != null && r(e, ["musicGenerationConfig"], n), e;
|
|
4410
4411
|
}
|
|
4411
|
-
function
|
|
4412
|
+
function wl(t) {
|
|
4412
4413
|
const e = {}, n = i(t, [
|
|
4413
4414
|
"weightedPrompts"
|
|
4414
4415
|
]);
|
|
@@ -4418,7 +4419,7 @@ function Rl(t) {
|
|
|
4418
4419
|
}
|
|
4419
4420
|
return e;
|
|
4420
4421
|
}
|
|
4421
|
-
function
|
|
4422
|
+
function Rl(t) {
|
|
4422
4423
|
const e = {}, n = i(t, ["media"]);
|
|
4423
4424
|
if (n != null) {
|
|
4424
4425
|
let d = io(n);
|
|
@@ -5144,10 +5145,10 @@ function ha(t, e, n) {
|
|
|
5144
5145
|
"cachedContent"
|
|
5145
5146
|
]);
|
|
5146
5147
|
n !== void 0 && N != null && r(n, ["cachedContent"], ee(t, N));
|
|
5147
|
-
const
|
|
5148
|
+
const w = i(e, [
|
|
5148
5149
|
"responseModalities"
|
|
5149
5150
|
]);
|
|
5150
|
-
|
|
5151
|
+
w != null && r(o, ["responseModalities"], w);
|
|
5151
5152
|
const U = i(e, [
|
|
5152
5153
|
"mediaResolution"
|
|
5153
5154
|
]);
|
|
@@ -5237,8 +5238,8 @@ function ma(t, e, n) {
|
|
|
5237
5238
|
let H = fe(N);
|
|
5238
5239
|
Array.isArray(H) && (H = H.map((z) => Co(ce(z)))), r(n, ["tools"], H);
|
|
5239
5240
|
}
|
|
5240
|
-
const
|
|
5241
|
-
n !== void 0 &&
|
|
5241
|
+
const w = i(e, ["toolConfig"]);
|
|
5242
|
+
n !== void 0 && w != null && r(n, ["toolConfig"], w);
|
|
5242
5243
|
const U = i(e, ["labels"]);
|
|
5243
5244
|
n !== void 0 && U != null && r(n, ["labels"], U);
|
|
5244
5245
|
const x = i(e, [
|
|
@@ -5607,7 +5608,7 @@ function Sa(t) {
|
|
|
5607
5608
|
"response",
|
|
5608
5609
|
"generateVideoResponse"
|
|
5609
5610
|
]);
|
|
5610
|
-
return a != null && r(e, ["response"],
|
|
5611
|
+
return a != null && r(e, ["response"], Ra(a)), e;
|
|
5611
5612
|
}
|
|
5612
5613
|
function xa(t) {
|
|
5613
5614
|
const e = {}, n = i(t, ["name"]);
|
|
@@ -5635,7 +5636,7 @@ function Aa(t, e) {
|
|
|
5635
5636
|
const c = i(e, ["config"]);
|
|
5636
5637
|
return c != null && va(c, n), n;
|
|
5637
5638
|
}
|
|
5638
|
-
function
|
|
5639
|
+
function wa(t, e) {
|
|
5639
5640
|
const n = {}, o = i(e, ["model"]);
|
|
5640
5641
|
o != null && r(n, ["_url", "model"], L(t, o));
|
|
5641
5642
|
const s = i(e, ["prompt"]);
|
|
@@ -5649,7 +5650,7 @@ function Ra(t, e) {
|
|
|
5649
5650
|
const c = i(e, ["config"]);
|
|
5650
5651
|
return c != null && Ia(c, n), n;
|
|
5651
5652
|
}
|
|
5652
|
-
function
|
|
5653
|
+
function Ra(t) {
|
|
5653
5654
|
const e = {}, n = i(t, [
|
|
5654
5655
|
"generatedSamples"
|
|
5655
5656
|
]);
|
|
@@ -5812,8 +5813,8 @@ function ba(t) {
|
|
|
5812
5813
|
A != null && r(e, ["thinkingConfig"], A);
|
|
5813
5814
|
const N = i(t, ["topK"]);
|
|
5814
5815
|
N != null && r(e, ["topK"], N);
|
|
5815
|
-
const
|
|
5816
|
-
if (
|
|
5816
|
+
const w = i(t, ["topP"]);
|
|
5817
|
+
if (w != null && r(e, ["topP"], w), i(t, ["enableEnhancedCivicAnswers"]) !== void 0)
|
|
5817
5818
|
throw new Error("enableEnhancedCivicAnswers parameter is not supported in Vertex AI.");
|
|
5818
5819
|
return e;
|
|
5819
5820
|
}
|
|
@@ -6512,11 +6513,11 @@ function Au(t, e) {
|
|
|
6512
6513
|
const n = {}, o = i(t, ["displayName"]);
|
|
6513
6514
|
return e !== void 0 && o != null && r(e, ["displayName"], o), n;
|
|
6514
6515
|
}
|
|
6515
|
-
function
|
|
6516
|
+
function wu(t) {
|
|
6516
6517
|
const e = {}, n = i(t, ["config"]);
|
|
6517
6518
|
return n != null && Au(n, e), e;
|
|
6518
6519
|
}
|
|
6519
|
-
function
|
|
6520
|
+
function Ru(t, e) {
|
|
6520
6521
|
const n = {}, o = i(t, ["force"]);
|
|
6521
6522
|
return e !== void 0 && o != null && r(e, ["_query", "force"], o), n;
|
|
6522
6523
|
}
|
|
@@ -6524,7 +6525,7 @@ function Nu(t) {
|
|
|
6524
6525
|
const e = {}, n = i(t, ["name"]);
|
|
6525
6526
|
n != null && r(e, ["_url", "name"], n);
|
|
6526
6527
|
const o = i(t, ["config"]);
|
|
6527
|
-
return o != null &&
|
|
6528
|
+
return o != null && Ru(o, e), e;
|
|
6528
6529
|
}
|
|
6529
6530
|
function Mu(t) {
|
|
6530
6531
|
const e = {}, n = i(t, ["name"]);
|
|
@@ -7207,7 +7208,7 @@ class td {
|
|
|
7207
7208
|
async setWeightedPrompts(e) {
|
|
7208
7209
|
if (!e.weightedPrompts || Object.keys(e.weightedPrompts).length === 0)
|
|
7209
7210
|
throw new Error("Weighted prompts must be set and contain at least one entry.");
|
|
7210
|
-
const n =
|
|
7211
|
+
const n = wl(e);
|
|
7211
7212
|
this.conn.send(JSON.stringify({ clientContent: n }));
|
|
7212
7213
|
}
|
|
7213
7214
|
/**
|
|
@@ -7390,15 +7391,15 @@ class rd {
|
|
|
7390
7391
|
I = `projects/${x}/locations/${P}/` + I;
|
|
7391
7392
|
}
|
|
7392
7393
|
let A = {};
|
|
7393
|
-
this.apiClient.isVertexAI() && ((s = e.config) === null || s === void 0 ? void 0 : s.responseModalities) === void 0 && (e.config === void 0 ? e.config = { responseModalities: [
|
|
7394
|
-
const N = (u = (a = e.config) === null || a === void 0 ? void 0 : a.tools) !== null && u !== void 0 ? u : [],
|
|
7394
|
+
this.apiClient.isVertexAI() && ((s = e.config) === null || s === void 0 ? void 0 : s.responseModalities) === void 0 && (e.config === void 0 ? e.config = { responseModalities: [we.AUDIO] } : e.config.responseModalities = [we.AUDIO]), !((l = e.config) === null || l === void 0) && l.generationConfig && console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");
|
|
7395
|
+
const N = (u = (a = e.config) === null || a === void 0 ? void 0 : a.tools) !== null && u !== void 0 ? u : [], w = [];
|
|
7395
7396
|
for (const x of N)
|
|
7396
7397
|
if (this.isCallableTool(x)) {
|
|
7397
7398
|
const P = x;
|
|
7398
|
-
|
|
7399
|
+
w.push(await P.tool());
|
|
7399
7400
|
} else
|
|
7400
|
-
|
|
7401
|
-
|
|
7401
|
+
w.push(x);
|
|
7402
|
+
w.length > 0 && (e.config.tools = w);
|
|
7402
7403
|
const U = {
|
|
7403
7404
|
model: I,
|
|
7404
7405
|
config: e.config,
|
|
@@ -7531,7 +7532,7 @@ class ad {
|
|
|
7531
7532
|
this.apiClient.isVertexAI() ? n = {
|
|
7532
7533
|
realtimeInput: Nl(e)
|
|
7533
7534
|
} : n = {
|
|
7534
|
-
realtimeInput:
|
|
7535
|
+
realtimeInput: Rl(e)
|
|
7535
7536
|
}, this.conn.send(JSON.stringify(n));
|
|
7536
7537
|
}
|
|
7537
7538
|
/**
|
|
@@ -7804,7 +7805,7 @@ class fd extends j {
|
|
|
7804
7805
|
return O(this, arguments, function* () {
|
|
7805
7806
|
for (var p, m, y, _, T, E; u < l; ) {
|
|
7806
7807
|
a && (u++, a = !1);
|
|
7807
|
-
const A = yield M(d.processParamsMaybeAddMcpUsage(h)), N = yield M(d.generateContentStreamInternal(A)),
|
|
7808
|
+
const A = yield M(d.processParamsMaybeAddMcpUsage(h)), N = yield M(d.generateContentStreamInternal(A)), w = [], U = [];
|
|
7808
7809
|
try {
|
|
7809
7810
|
for (var C = !0, v = (m = void 0, X(N)), I; I = yield M(v.next()), p = I.done, !p; C = !0) {
|
|
7810
7811
|
_ = I.value, C = !1;
|
|
@@ -7817,7 +7818,7 @@ class fd extends j {
|
|
|
7817
7818
|
throw new Error("Function call name was not returned by the model.");
|
|
7818
7819
|
if (f.has(P.functionCall.name)) {
|
|
7819
7820
|
const b = yield M(f.get(P.functionCall.name).callTool([P.functionCall]));
|
|
7820
|
-
|
|
7821
|
+
w.push(...b);
|
|
7821
7822
|
} else
|
|
7822
7823
|
throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${f.keys()}, mising tool: ${P.functionCall.name}`);
|
|
7823
7824
|
}
|
|
@@ -7832,21 +7833,21 @@ class fd extends j {
|
|
|
7832
7833
|
if (m) throw m.error;
|
|
7833
7834
|
}
|
|
7834
7835
|
}
|
|
7835
|
-
if (
|
|
7836
|
+
if (w.length > 0) {
|
|
7836
7837
|
a = !0;
|
|
7837
7838
|
const x = new me();
|
|
7838
7839
|
x.candidates = [
|
|
7839
7840
|
{
|
|
7840
7841
|
content: {
|
|
7841
7842
|
role: "user",
|
|
7842
|
-
parts:
|
|
7843
|
+
parts: w
|
|
7843
7844
|
}
|
|
7844
7845
|
}
|
|
7845
7846
|
], yield yield M(x);
|
|
7846
7847
|
const P = [];
|
|
7847
7848
|
P.push(...U), P.push({
|
|
7848
7849
|
role: "user",
|
|
7849
|
-
parts:
|
|
7850
|
+
parts: w
|
|
7850
7851
|
});
|
|
7851
7852
|
const b = Y(h.contents).concat(P);
|
|
7852
7853
|
h.contents = b;
|
|
@@ -8498,7 +8499,7 @@ class fd extends j {
|
|
|
8498
8499
|
var n, o, s, l;
|
|
8499
8500
|
let a, u = "", c = {};
|
|
8500
8501
|
if (this.apiClient.isVertexAI()) {
|
|
8501
|
-
const d =
|
|
8502
|
+
const d = wa(this.apiClient, e);
|
|
8502
8503
|
return u = S("{model}:predictLongRunning", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
8503
8504
|
path: u,
|
|
8504
8505
|
queryParams: c,
|
|
@@ -8507,7 +8508,7 @@ class fd extends j {
|
|
|
8507
8508
|
httpOptions: (n = e.config) === null || n === void 0 ? void 0 : n.httpOptions,
|
|
8508
8509
|
abortSignal: (o = e.config) === null || o === void 0 ? void 0 : o.abortSignal
|
|
8509
8510
|
}).then((f) => f.json()), a.then((f) => {
|
|
8510
|
-
const h = xa(f), p = new
|
|
8511
|
+
const h = xa(f), p = new Re();
|
|
8511
8512
|
return Object.assign(p, h), p;
|
|
8512
8513
|
});
|
|
8513
8514
|
} else {
|
|
@@ -8520,7 +8521,7 @@ class fd extends j {
|
|
|
8520
8521
|
httpOptions: (s = e.config) === null || s === void 0 ? void 0 : s.httpOptions,
|
|
8521
8522
|
abortSignal: (l = e.config) === null || l === void 0 ? void 0 : l.abortSignal
|
|
8522
8523
|
}).then((f) => f.json()), a.then((f) => {
|
|
8523
|
-
const h = Sa(f), p = new
|
|
8524
|
+
const h = Sa(f), p = new Re();
|
|
8524
8525
|
return Object.assign(p, h), p;
|
|
8525
8526
|
});
|
|
8526
8527
|
}
|
|
@@ -8769,7 +8770,7 @@ function vd(t, e) {
|
|
|
8769
8770
|
const _ = i(t, ["tools"]);
|
|
8770
8771
|
if (e !== void 0 && _ != null) {
|
|
8771
8772
|
let N = fe(_);
|
|
8772
|
-
Array.isArray(N) && (N = N.map((
|
|
8773
|
+
Array.isArray(N) && (N = N.map((w) => Ad(ce(w)))), r(e, ["setup", "tools"], N);
|
|
8773
8774
|
}
|
|
8774
8775
|
const T = i(t, [
|
|
8775
8776
|
"sessionResumption"
|
|
@@ -8879,7 +8880,7 @@ function Ad(t) {
|
|
|
8879
8880
|
* Copyright 2025 Google LLC
|
|
8880
8881
|
* SPDX-License-Identifier: Apache-2.0
|
|
8881
8882
|
*/
|
|
8882
|
-
function
|
|
8883
|
+
function wd(t) {
|
|
8883
8884
|
const e = [];
|
|
8884
8885
|
for (const n in t)
|
|
8885
8886
|
if (Object.prototype.hasOwnProperty.call(t, n)) {
|
|
@@ -8892,7 +8893,7 @@ function Rd(t) {
|
|
|
8892
8893
|
}
|
|
8893
8894
|
return e.join(",");
|
|
8894
8895
|
}
|
|
8895
|
-
function
|
|
8896
|
+
function Rd(t, e) {
|
|
8896
8897
|
let n = null;
|
|
8897
8898
|
const o = t.bidiGenerateContentSetup;
|
|
8898
8899
|
if (typeof o == "object" && o !== null && "setup" in o) {
|
|
@@ -8901,7 +8902,7 @@ function wd(t, e) {
|
|
|
8901
8902
|
} else o !== void 0 && delete t.bidiGenerateContentSetup;
|
|
8902
8903
|
const s = t.fieldMask;
|
|
8903
8904
|
if (n) {
|
|
8904
|
-
const l =
|
|
8905
|
+
const l = wd(n);
|
|
8905
8906
|
if (Array.isArray(e == null ? void 0 : e.lockAdditionalFields) && (e == null ? void 0 : e.lockAdditionalFields.length) === 0)
|
|
8906
8907
|
l ? t.fieldMask = l : delete t.fieldMask;
|
|
8907
8908
|
else if (e != null && e.lockAdditionalFields && e.lockAdditionalFields.length > 0 && s !== null && Array.isArray(s) && s.length > 0) {
|
|
@@ -9019,7 +9020,7 @@ class Nd extends j {
|
|
|
9019
9020
|
{
|
|
9020
9021
|
const u = yd(this.apiClient, e);
|
|
9021
9022
|
l = S("auth_tokens", u._url), a = u._query, delete u.config, delete u._url, delete u._query;
|
|
9022
|
-
const c =
|
|
9023
|
+
const c = Rd(u, e.config);
|
|
9023
9024
|
return s = this.apiClient.request({
|
|
9024
9025
|
path: l,
|
|
9025
9026
|
queryParams: a,
|
|
@@ -9215,7 +9216,7 @@ class Fd extends j {
|
|
|
9215
9216
|
if (this.apiClient.isVertexAI())
|
|
9216
9217
|
throw new Error("This method is only supported by the Gemini Developer API.");
|
|
9217
9218
|
{
|
|
9218
|
-
const u =
|
|
9219
|
+
const u = wu(e);
|
|
9219
9220
|
return l = S("fileSearchStores", u._url), a = u._query, delete u._url, delete u._query, s = this.apiClient.request({
|
|
9220
9221
|
path: l,
|
|
9221
9222
|
queryParams: a,
|
|
@@ -9345,14 +9346,14 @@ class Fd extends j {
|
|
|
9345
9346
|
* Copyright 2025 Google LLC
|
|
9346
9347
|
* SPDX-License-Identifier: Apache-2.0
|
|
9347
9348
|
*/
|
|
9348
|
-
let
|
|
9349
|
+
let wo = function() {
|
|
9349
9350
|
const { crypto: t } = globalThis;
|
|
9350
9351
|
if (t != null && t.randomUUID)
|
|
9351
|
-
return
|
|
9352
|
+
return wo = t.randomUUID.bind(t), t.randomUUID();
|
|
9352
9353
|
const e = new Uint8Array(1), n = t ? () => t.getRandomValues(e)[0] : () => Math.random() * 255 & 255;
|
|
9353
9354
|
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (o) => (+o ^ n() & 15 >> +o / 4).toString(16));
|
|
9354
9355
|
};
|
|
9355
|
-
const Gd = () =>
|
|
9356
|
+
const Gd = () => wo();
|
|
9356
9357
|
/**
|
|
9357
9358
|
* @license
|
|
9358
9359
|
* Copyright 2025 Google LLC
|
|
@@ -9413,7 +9414,7 @@ class Ge extends $ {
|
|
|
9413
9414
|
super(void 0, void 0, e || "Connection error.", void 0), n && (this.cause = n);
|
|
9414
9415
|
}
|
|
9415
9416
|
}
|
|
9416
|
-
class
|
|
9417
|
+
class Ro extends Ge {
|
|
9417
9418
|
constructor({ message: e } = {}) {
|
|
9418
9419
|
super({ message: e ?? "Request timed out." });
|
|
9419
9420
|
}
|
|
@@ -10486,7 +10487,7 @@ class qe {
|
|
|
10486
10487
|
url: f,
|
|
10487
10488
|
durationMs: E - y,
|
|
10488
10489
|
message: T.message
|
|
10489
|
-
})), I ? new
|
|
10490
|
+
})), I ? new Ro() : new Ge({ cause: T });
|
|
10490
10491
|
}
|
|
10491
10492
|
const C = `[${p}${m}] ${d.method} ${f} ${T.ok ? "succeeded" : "failed"} with status ${T.status} in ${E - y}ms`;
|
|
10492
10493
|
if (!T.ok) {
|
|
@@ -10503,15 +10504,15 @@ class qe {
|
|
|
10503
10504
|
}
|
|
10504
10505
|
const I = v ? "error; no more retries left" : "error; not retryable";
|
|
10505
10506
|
J(this).info(`${C} - ${I}`);
|
|
10506
|
-
const A = await T.text().catch((x) => je(x).message), N = Yd(A),
|
|
10507
|
+
const A = await T.text().catch((x) => je(x).message), N = Yd(A), w = N ? void 0 : A;
|
|
10507
10508
|
throw J(this).debug(`[${p}] response error (${I})`, oe({
|
|
10508
10509
|
retryOfRequestLogID: o,
|
|
10509
10510
|
url: T.url,
|
|
10510
10511
|
status: T.status,
|
|
10511
10512
|
headers: T.headers,
|
|
10512
|
-
message:
|
|
10513
|
+
message: w,
|
|
10513
10514
|
durationMs: Date.now() - y
|
|
10514
|
-
})), this.makeStatusError(T.status, N,
|
|
10515
|
+
})), this.makeStatusError(T.status, N, w, T.headers);
|
|
10515
10516
|
}
|
|
10516
10517
|
return J(this).info(C), J(this).debug(`[${p}] response start`, oe({
|
|
10517
10518
|
retryOfRequestLogID: o,
|
|
@@ -10606,7 +10607,7 @@ q.GeminiNextGenAPIClient = Yo;
|
|
|
10606
10607
|
q.GeminiNextGenAPIClientError = K;
|
|
10607
10608
|
q.APIError = $;
|
|
10608
10609
|
q.APIConnectionError = Ge;
|
|
10609
|
-
q.APIConnectionTimeoutError =
|
|
10610
|
+
q.APIConnectionTimeoutError = Ro;
|
|
10610
10611
|
q.APIUserAbortError = et;
|
|
10611
10612
|
q.NotFoundError = ko;
|
|
10612
10613
|
q.ConflictError = Do;
|
|
@@ -10785,11 +10786,11 @@ function Ac(t, e) {
|
|
|
10785
10786
|
const a = i(t, ["config"]);
|
|
10786
10787
|
return a != null && Sc(a, n, e), n;
|
|
10787
10788
|
}
|
|
10788
|
-
function
|
|
10789
|
+
function wc(t, e) {
|
|
10789
10790
|
const n = {}, o = i(t, ["name"]);
|
|
10790
10791
|
return o != null && r(n, ["_url", "name"], o), n;
|
|
10791
10792
|
}
|
|
10792
|
-
function
|
|
10793
|
+
function Rc(t, e) {
|
|
10793
10794
|
const n = {}, o = i(t, ["name"]);
|
|
10794
10795
|
return o != null && r(n, ["_url", "name"], o), n;
|
|
10795
10796
|
}
|
|
@@ -10987,8 +10988,8 @@ function ot(t, e) {
|
|
|
10987
10988
|
A != null && r(n, ["experiment"], A);
|
|
10988
10989
|
const N = i(t, ["labels"]);
|
|
10989
10990
|
N != null && r(n, ["labels"], N);
|
|
10990
|
-
const
|
|
10991
|
-
|
|
10991
|
+
const w = i(t, ["outputUri"]);
|
|
10992
|
+
w != null && r(n, ["outputUri"], w);
|
|
10992
10993
|
const U = i(t, ["pipelineJob"]);
|
|
10993
10994
|
U != null && r(n, ["pipelineJob"], U);
|
|
10994
10995
|
const x = i(t, [
|
|
@@ -11061,7 +11062,7 @@ class Vc extends j {
|
|
|
11061
11062
|
var n, o, s, l;
|
|
11062
11063
|
let a, u = "", c = {};
|
|
11063
11064
|
if (this.apiClient.isVertexAI()) {
|
|
11064
|
-
const d =
|
|
11065
|
+
const d = Rc(e);
|
|
11065
11066
|
return u = S("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
11066
11067
|
path: u,
|
|
11067
11068
|
queryParams: c,
|
|
@@ -11076,7 +11077,7 @@ class Vc extends j {
|
|
|
11076
11077
|
}, p;
|
|
11077
11078
|
})), a.then((f) => ot(f));
|
|
11078
11079
|
} else {
|
|
11079
|
-
const d =
|
|
11080
|
+
const d = wc(e);
|
|
11080
11081
|
return u = S("{name}", d._url), c = d._query, delete d._url, delete d._query, a = this.apiClient.request({
|
|
11081
11082
|
path: u,
|
|
11082
11083
|
queryParams: c,
|
|
@@ -11437,14 +11438,14 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11437
11438
|
} catch (o) {
|
|
11438
11439
|
throw console.error("Error calling Gemini API:", o), o instanceof Error && (o.message.includes("API key not valid") || o.message.includes("400")) ? new Error("The API key is not valid. Please check your configuration.") : new Error("Failed to recognize handwriting. The model may be unavailable or the drawing is unclear.");
|
|
11439
11440
|
}
|
|
11440
|
-
}, Oo = () => /* @__PURE__ */
|
|
11441
|
+
}, Oo = () => /* @__PURE__ */ R("span", { className: "text-sm leading-tight flex flex-col items-center text-black -mt-0.5", children: [
|
|
11441
11442
|
/* @__PURE__ */ g("span", { children: "□" }),
|
|
11442
11443
|
/* @__PURE__ */ g("span", { className: "w-2 h-px bg-black my-[1px]" }),
|
|
11443
11444
|
/* @__PURE__ */ g("span", { children: "□" })
|
|
11444
|
-
] }), Xo = () => /* @__PURE__ */
|
|
11445
|
+
] }), Xo = () => /* @__PURE__ */ R("span", { className: "text-black text-lg", children: [
|
|
11445
11446
|
"√",
|
|
11446
11447
|
/* @__PURE__ */ g("span", { className: "border-t border-black -ml-1", children: "□" })
|
|
11447
|
-
] }), nf = () => /* @__PURE__ */
|
|
11448
|
+
] }), nf = () => /* @__PURE__ */ R("span", { className: "text-black text-lg", children: [
|
|
11448
11449
|
/* @__PURE__ */ g("sup", { className: "-mr-1", children: "□" }),
|
|
11449
11450
|
"√",
|
|
11450
11451
|
/* @__PURE__ */ g("span", { className: "border-t border-black -ml-1", children: "□" })
|
|
@@ -11465,7 +11466,7 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11465
11466
|
children: n
|
|
11466
11467
|
}
|
|
11467
11468
|
), rf = [
|
|
11468
|
-
{ key: "layout", display: /* @__PURE__ */
|
|
11469
|
+
{ key: "layout", display: /* @__PURE__ */ R("div", { className: "flex items-center gap-1", children: [
|
|
11469
11470
|
/* @__PURE__ */ g(Xo, {}),
|
|
11470
11471
|
" ",
|
|
11471
11472
|
/* @__PURE__ */ g(Oo, {})
|
|
@@ -11616,8 +11617,8 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11616
11617
|
products: []
|
|
11617
11618
|
}, lf = ({ onInsert: t }) => {
|
|
11618
11619
|
const [e, n] = F("layout");
|
|
11619
|
-
return /* @__PURE__ */
|
|
11620
|
-
/* @__PURE__ */
|
|
11620
|
+
return /* @__PURE__ */ R("div", { className: "bg-[#e9eff1] px-2 py-1 flex flex-col space-y-1 shrink-0 border-b border-gray-300", children: [
|
|
11621
|
+
/* @__PURE__ */ R("div", { className: "flex flex-wrap gap-1 items-center", children: [
|
|
11621
11622
|
rf.map((o) => /* @__PURE__ */ g(
|
|
11622
11623
|
sf,
|
|
11623
11624
|
{
|
|
@@ -11631,13 +11632,13 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11631
11632
|
/* @__PURE__ */ g("div", { className: "flex-grow" }),
|
|
11632
11633
|
/* @__PURE__ */ g("button", { title: "Help", className: "w-8 h-8 rounded-full bg-gray-400 hover:bg-gray-500 text-white flex items-center justify-center shadow-sm transition-all", children: /* @__PURE__ */ g("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) })
|
|
11633
11634
|
] }),
|
|
11634
|
-
/* @__PURE__ */
|
|
11635
|
-
/* @__PURE__ */ g("div", { className: "flex items-start", children: Xn[e].map((o, s) => /* @__PURE__ */
|
|
11635
|
+
/* @__PURE__ */ R("div", { className: "flex items-start bg-white rounded border border-gray-300 min-h-[5rem] shadow-inner p-1 overflow-x-auto", children: [
|
|
11636
|
+
/* @__PURE__ */ g("div", { className: "flex items-start", children: Xn[e].map((o, s) => /* @__PURE__ */ R(Zn.Fragment, { children: [
|
|
11636
11637
|
/* @__PURE__ */ g("div", { className: "flex flex-col", children: o.map((l, a) => /* @__PURE__ */ g("div", { className: "flex", children: l.map((u, c) => /* @__PURE__ */ g(of, { symbol: u, onInsert: t }, c)) }, a)) }),
|
|
11637
11638
|
s < Xn[e].length - 1 && /* @__PURE__ */ g("div", { className: "w-px bg-gray-300 mx-1 self-stretch" })
|
|
11638
11639
|
] }, s)) }),
|
|
11639
11640
|
/* @__PURE__ */ g("div", { className: "flex-grow" }),
|
|
11640
|
-
/* @__PURE__ */ g("div", { className: "flex items-center space-x-2 shrink-0 self-center pr-2", children: /* @__PURE__ */
|
|
11641
|
+
/* @__PURE__ */ g("div", { className: "flex items-center space-x-2 shrink-0 self-center pr-2", children: /* @__PURE__ */ R("div", { className: "flex flex-col space-y-1", children: [
|
|
11641
11642
|
/* @__PURE__ */ g("select", { disabled: !0, className: "text-sm border border-gray-300 rounded h-6 w-32 px-1 text-black opacity-50", children: /* @__PURE__ */ g("option", { children: "Font..." }) }),
|
|
11642
11643
|
/* @__PURE__ */ g("select", { disabled: !0, className: "text-sm border border-gray-300 rounded h-6 w-32 px-1 text-black opacity-50", children: /* @__PURE__ */ g("option", { children: "Size..." }) })
|
|
11643
11644
|
] }) })
|
|
@@ -11684,11 +11685,11 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11684
11685
|
[{ display: "↔", latex: "\\leftrightarrow " }]
|
|
11685
11686
|
],
|
|
11686
11687
|
[
|
|
11687
|
-
[{ display: /* @__PURE__ */
|
|
11688
|
+
[{ display: /* @__PURE__ */ R("span", { className: "text-lg", children: [
|
|
11688
11689
|
"→",
|
|
11689
11690
|
/* @__PURE__ */ g("sup", { className: "-top-1.5 text-[8px]", children: "□" })
|
|
11690
11691
|
] }), latex: "\\xrightarrow{}" }],
|
|
11691
|
-
[{ display: /* @__PURE__ */
|
|
11692
|
+
[{ display: /* @__PURE__ */ R("span", { className: "text-lg", children: [
|
|
11692
11693
|
"⇌",
|
|
11693
11694
|
/* @__PURE__ */ g("sup", { className: "-top-1.5 text-[8px]", children: "□" })
|
|
11694
11695
|
] }), latex: "\\xrightleftharpoons{}" }]
|
|
@@ -11768,8 +11769,8 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11768
11769
|
]
|
|
11769
11770
|
}, cf = ({ onInsert: t }) => {
|
|
11770
11771
|
const [e, n] = F("chem");
|
|
11771
|
-
return /* @__PURE__ */
|
|
11772
|
-
/* @__PURE__ */
|
|
11772
|
+
return /* @__PURE__ */ R("div", { className: "bg-[#e9eff1] px-2 py-1 flex flex-col space-y-1 shrink-0 border-b border-gray-300", children: [
|
|
11773
|
+
/* @__PURE__ */ R("div", { className: "flex flex-wrap gap-1 items-center", children: [
|
|
11773
11774
|
df.map((o) => /* @__PURE__ */ g(
|
|
11774
11775
|
uf,
|
|
11775
11776
|
{
|
|
@@ -11783,20 +11784,20 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11783
11784
|
/* @__PURE__ */ g("div", { className: "flex-grow" }),
|
|
11784
11785
|
/* @__PURE__ */ g("button", { title: "Help", className: "w-8 h-8 rounded-full bg-gray-400 hover:bg-gray-500 text-white flex items-center justify-center shadow-sm transition-all", children: /* @__PURE__ */ g("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ g("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }) })
|
|
11785
11786
|
] }),
|
|
11786
|
-
/* @__PURE__ */
|
|
11787
|
-
/* @__PURE__ */ g("div", { className: "flex items-start", children: Qn[e].map((o, s) => /* @__PURE__ */
|
|
11787
|
+
/* @__PURE__ */ R("div", { className: "flex items-start bg-white rounded border border-gray-300 min-h-[5rem] shadow-inner p-1 overflow-x-auto", children: [
|
|
11788
|
+
/* @__PURE__ */ g("div", { className: "flex items-start", children: Qn[e].map((o, s) => /* @__PURE__ */ R(Zn.Fragment, { children: [
|
|
11788
11789
|
/* @__PURE__ */ g("div", { className: "flex flex-col", children: o.map((l, a) => /* @__PURE__ */ g("div", { className: "flex", children: l.map((u, c) => /* @__PURE__ */ g(af, { symbol: u, onInsert: t }, c)) }, a)) }),
|
|
11789
11790
|
s < Qn[e].length - 1 && /* @__PURE__ */ g("div", { className: "w-px bg-gray-300 mx-1 self-stretch" })
|
|
11790
11791
|
] }, s)) }),
|
|
11791
11792
|
/* @__PURE__ */ g("div", { className: "flex-grow" }),
|
|
11792
|
-
/* @__PURE__ */ g("div", { className: "flex items-center space-x-2 shrink-0 self-center pr-2", children: /* @__PURE__ */
|
|
11793
|
+
/* @__PURE__ */ g("div", { className: "flex items-center space-x-2 shrink-0 self-center pr-2", children: /* @__PURE__ */ R("div", { className: "flex flex-col space-y-1", children: [
|
|
11793
11794
|
/* @__PURE__ */ g("select", { disabled: !0, className: "text-sm border border-gray-300 rounded h-6 w-32 px-1 text-black opacity-50", children: /* @__PURE__ */ g("option", { children: "Font..." }) }),
|
|
11794
11795
|
/* @__PURE__ */ g("select", { disabled: !0, className: "text-sm border border-gray-300 rounded h-6 w-32 px-1 text-black opacity-50", children: /* @__PURE__ */ g("option", { children: "Size..." }) })
|
|
11795
11796
|
] }) })
|
|
11796
11797
|
] })
|
|
11797
11798
|
] });
|
|
11798
11799
|
}, ff = ({ isOpen: t, onClose: e, onInsert: n, apiKey: o = "" }) => {
|
|
11799
|
-
const s = ie(null), l = ie(null), [a, u] = F(!1), [c, d] = F(null), [f, h] = F(""), [p, m] = F("keyboard"), [y, _] = F("math"), [T, E] = F(!1), [C, v] = F(!1), [I, A] = F(""), [N,
|
|
11800
|
+
const s = ie(null), l = ie(null), [a, u] = F(!1), [c, d] = F(null), [f, h] = F(""), [p, m] = F("keyboard"), [y, _] = F("math"), [T, E] = F(!1), [C, v] = F(!1), [I, A] = F(""), [N, w] = F(!1);
|
|
11800
11801
|
Ae(() => {
|
|
11801
11802
|
if (p === "keyboard" && f.trim() && window.katex)
|
|
11802
11803
|
try {
|
|
@@ -11805,12 +11806,12 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11805
11806
|
displayMode: !1,
|
|
11806
11807
|
output: "mathml"
|
|
11807
11808
|
});
|
|
11808
|
-
A(k),
|
|
11809
|
+
A(k), w(!0);
|
|
11809
11810
|
} catch {
|
|
11810
|
-
A('<span class="text-red-500 text-xs">Invalid formula syntax</span>'),
|
|
11811
|
+
A('<span class="text-red-500 text-xs">Invalid formula syntax</span>'), w(!1);
|
|
11811
11812
|
}
|
|
11812
11813
|
else
|
|
11813
|
-
A(""),
|
|
11814
|
+
A(""), w(!1);
|
|
11814
11815
|
}, [f, p]);
|
|
11815
11816
|
const U = (k) => {
|
|
11816
11817
|
_(k), k === "chem" && m("keyboard");
|
|
@@ -11848,25 +11849,25 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11848
11849
|
u(!1);
|
|
11849
11850
|
}
|
|
11850
11851
|
}, [o, P]);
|
|
11851
|
-
return t ? /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-md p-4 animate-in fade-in duration-200", children: /* @__PURE__ */
|
|
11852
|
-
/* @__PURE__ */
|
|
11853
|
-
/* @__PURE__ */
|
|
11852
|
+
return t ? /* @__PURE__ */ g("div", { className: "fixed inset-0 z-[100] flex items-center justify-center bg-slate-900/40 backdrop-blur-md p-4 animate-in fade-in duration-200", children: /* @__PURE__ */ R("div", { className: "bg-white rounded-2xl shadow-2xl flex flex-col w-full max-w-4xl h-[600px] border border-slate-200 overflow-hidden", onClick: (k) => k.stopPropagation(), children: [
|
|
11853
|
+
/* @__PURE__ */ R("header", { className: "px-6 py-4 border-b border-slate-100 flex items-center justify-between bg-slate-50/50", children: [
|
|
11854
|
+
/* @__PURE__ */ R("div", { className: "flex items-center gap-6", children: [
|
|
11854
11855
|
/* @__PURE__ */ g("h2", { className: "text-lg font-bold text-slate-900", children: "AI Formula Pad" }),
|
|
11855
|
-
/* @__PURE__ */
|
|
11856
|
+
/* @__PURE__ */ R("div", { className: "flex bg-slate-200 p-1 rounded-lg", children: [
|
|
11856
11857
|
/* @__PURE__ */ g("button", { onClick: () => U("math"), className: `px-4 py-1 text-xs font-semibold rounded-md transition-all ${y === "math" ? "bg-white shadow text-blue-600" : "text-slate-500"}`, children: "Math" }),
|
|
11857
11858
|
/* @__PURE__ */ g("button", { onClick: () => U("chem"), className: `px-4 py-1 text-xs font-semibold rounded-md transition-all ${y === "chem" ? "bg-white shadow text-blue-600" : "text-slate-500"}`, children: "Chemistry" })
|
|
11858
11859
|
] })
|
|
11859
11860
|
] }),
|
|
11860
11861
|
/* @__PURE__ */ g("button", { onClick: e, className: "p-2 hover:bg-slate-200 rounded-full text-slate-400 hover:text-slate-600 transition-colors", children: /* @__PURE__ */ g(Ji, { size: 20 }) })
|
|
11861
11862
|
] }),
|
|
11862
|
-
/* @__PURE__ */
|
|
11863
|
-
/* @__PURE__ */
|
|
11863
|
+
/* @__PURE__ */ R("div", { className: "flex-1 flex overflow-hidden", children: [
|
|
11864
|
+
/* @__PURE__ */ R("div", { className: "w-16 border-r border-slate-100 flex flex-col items-center py-6 gap-4 bg-slate-50/30", children: [
|
|
11864
11865
|
/* @__PURE__ */ g("button", { onClick: () => m("keyboard"), className: `p-3 rounded-xl transition-all ${p === "keyboard" ? "bg-blue-600 text-white shadow-lg" : "text-slate-400 hover:text-slate-600"}`, children: /* @__PURE__ */ g(pi, { size: 24 }) }),
|
|
11865
11866
|
y === "math" && /* @__PURE__ */ g("button", { onClick: () => m("handwriting"), className: `p-3 rounded-xl transition-all ${p === "handwriting" ? "bg-blue-600 text-white shadow-lg" : "text-slate-400 hover:text-slate-600"}`, children: /* @__PURE__ */ g(Ii, { size: 24 }) })
|
|
11866
11867
|
] }),
|
|
11867
|
-
/* @__PURE__ */
|
|
11868
|
+
/* @__PURE__ */ R("div", { className: "flex-1 flex flex-col overflow-hidden", children: [
|
|
11868
11869
|
/* @__PURE__ */ g("div", { className: "shrink-0", children: p === "keyboard" && (y === "math" ? /* @__PURE__ */ g(lf, { onInsert: P }) : /* @__PURE__ */ g(cf, { onInsert: P })) }),
|
|
11869
|
-
/* @__PURE__ */ g("div", { className: "flex-1 p-6 relative bg-slate-50/20", children: p === "keyboard" ? /* @__PURE__ */
|
|
11870
|
+
/* @__PURE__ */ g("div", { className: "flex-1 p-6 relative bg-slate-50/20", children: p === "keyboard" ? /* @__PURE__ */ R("div", { className: "h-full flex flex-col gap-4", children: [
|
|
11870
11871
|
/* @__PURE__ */ g(
|
|
11871
11872
|
"textarea",
|
|
11872
11873
|
{
|
|
@@ -11878,22 +11879,22 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11878
11879
|
}
|
|
11879
11880
|
),
|
|
11880
11881
|
/* @__PURE__ */ g("div", { className: "h-20 bg-white border border-slate-100 rounded-xl flex items-center justify-center p-4 shadow-sm overflow-auto", children: I ? /* @__PURE__ */ g("div", { dangerouslySetInnerHTML: { __html: I } }) : /* @__PURE__ */ g("span", { className: "text-slate-300 italic", children: "Preview will appear here" }) })
|
|
11881
|
-
] }) : /* @__PURE__ */
|
|
11882
|
+
] }) : /* @__PURE__ */ R("div", { className: "h-full border border-slate-200 bg-white rounded-2xl shadow-inner overflow-hidden relative", children: [
|
|
11882
11883
|
/* @__PURE__ */ g(to, { ref: s, onHistoryChange: (k) => {
|
|
11883
11884
|
E(k.canUndo), v(k.canRedo);
|
|
11884
11885
|
} }),
|
|
11885
|
-
/* @__PURE__ */
|
|
11886
|
+
/* @__PURE__ */ R("div", { className: "absolute top-4 right-4 flex flex-col gap-2", children: [
|
|
11886
11887
|
/* @__PURE__ */ g("button", { onClick: () => {
|
|
11887
11888
|
var k;
|
|
11888
11889
|
return (k = s.current) == null ? void 0 : k.undo();
|
|
11889
|
-
}, disabled: !T, className: "p-2 bg-white border border-slate-200 rounded-lg shadow-sm disabled:opacity-30 hover:bg-slate-50", children: /* @__PURE__ */ g(
|
|
11890
|
+
}, disabled: !T, className: "p-2 bg-white border border-slate-200 rounded-lg shadow-sm disabled:opacity-30 hover:bg-slate-50", children: /* @__PURE__ */ g(wi, { size: 18 }) }),
|
|
11890
11891
|
/* @__PURE__ */ g("button", { onClick: () => {
|
|
11891
11892
|
var k;
|
|
11892
11893
|
return (k = s.current) == null ? void 0 : k.redo();
|
|
11893
11894
|
}, disabled: !C, className: "p-2 bg-white border border-slate-200 rounded-lg shadow-sm disabled:opacity-30 hover:bg-slate-50", children: /* @__PURE__ */ g(Ni, { size: 18 }) }),
|
|
11894
11895
|
/* @__PURE__ */ g("button", { onClick: x, className: "p-2 bg-white border border-slate-200 rounded-lg shadow-sm text-red-500 hover:bg-red-50", children: /* @__PURE__ */ g(Fi, { size: 18 }) })
|
|
11895
11896
|
] }),
|
|
11896
|
-
/* @__PURE__ */ g("div", { className: "absolute bottom-6 left-1/2 -translate-x-1/2 flex gap-4", children: /* @__PURE__ */
|
|
11897
|
+
/* @__PURE__ */ g("div", { className: "absolute bottom-6 left-1/2 -translate-x-1/2 flex gap-4", children: /* @__PURE__ */ R(
|
|
11897
11898
|
"button",
|
|
11898
11899
|
{
|
|
11899
11900
|
onClick: b,
|
|
@@ -11908,9 +11909,9 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11908
11909
|
] }) })
|
|
11909
11910
|
] })
|
|
11910
11911
|
] }),
|
|
11911
|
-
/* @__PURE__ */
|
|
11912
|
+
/* @__PURE__ */ R("footer", { className: "px-6 py-4 border-t border-slate-100 flex justify-between items-center bg-slate-50/50", children: [
|
|
11912
11913
|
c && /* @__PURE__ */ g("span", { className: "text-sm font-medium text-red-500 animate-pulse", children: c }),
|
|
11913
|
-
/* @__PURE__ */
|
|
11914
|
+
/* @__PURE__ */ R("div", { className: "ml-auto flex gap-3", children: [
|
|
11914
11915
|
/* @__PURE__ */ g("button", { onClick: e, className: "px-6 py-2 text-slate-600 font-semibold hover:bg-slate-200 rounded-xl transition", children: "Cancel" }),
|
|
11915
11916
|
/* @__PURE__ */ g(
|
|
11916
11917
|
"button",
|
|
@@ -11942,7 +11943,7 @@ Example: For an image showing 'x squared', your literal output must be: x^2` },
|
|
|
11942
11943
|
}
|
|
11943
11944
|
})), Ae(() => {
|
|
11944
11945
|
s.current && t && !s.current.innerHTML && (s.current.innerHTML = t);
|
|
11945
|
-
}, [t]), /* @__PURE__ */
|
|
11946
|
+
}, [t]), /* @__PURE__ */ R("div", { className: "w-full max-w-5xl bg-white rounded-2xl shadow-xl border border-slate-200 overflow-hidden flex flex-col min-h-[700px] transition-all duration-300", children: [
|
|
11946
11947
|
/* @__PURE__ */ g(
|
|
11947
11948
|
$i,
|
|
11948
11949
|
{
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
*
|
|
119
119
|
* This source code is licensed under the ISC license.
|
|
120
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const gi=F("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ct={"12px":"1","14px":"2","16px":"3","18px":"4","24px":"5","32px":"6","48px":"7"},yi=({onOpenHandwritingModal:t,onApplyStyle:e,onUndo:n,onRedo:o,canUndo:s,canRedo:l})=>{const[a,u]=w.useState(!1),c=w.useRef(null),d=p=>{var y;const m=(y=p.target.files)==null?void 0:y[0];if(m){const _=new FileReader;_.onload=T=>{var C;const E=(C=T.target)==null?void 0:C.result;e("insertImage",E)},_.readAsDataURL(m)}p.target&&(p.target.value="")},f=(p,m)=>{let y='<table class="border-collapse w-full my-4 border border-slate-300">';for(let _=0;_<p;_++){y+="<tr>";for(let T=0;T<m;T++)y+='<td class="border border-slate-300 p-2 min-h-[40px]"><br></td>';y+="</tr>"}y+="</table><p><br></p>",e("insertHTML",y),u(!1)},h=({onClick:p,disabled:m,title:y,children:_,active:T})=>g.jsx("button",{onClick:p,disabled:m,onMouseDown:E=>E.preventDefault(),title:y,className:`p-2 rounded-md transition-colors flex items-center justify-center disabled:opacity-20 ${T?"bg-blue-100 text-blue-600":"hover:bg-slate-100 text-slate-600"}`,children:_});return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"bg-white px-4 py-2 flex flex-wrap items-center gap-1 border-b border-slate-200 sticky top-0 z-20 shadow-sm",children:[g.jsxs("div",{className:"flex items-center gap-1 pr-2 border-r border-slate-200",children:[g.jsx(h,{onClick:n,disabled:!s,title:"Undo",children:g.jsx(mi,{size:18})}),g.jsx(h,{onClick:o,disabled:!l,title:"Redo",children:g.jsx(li,{size:18})})]}),g.jsxs("div",{className:"flex items-center gap-1 px-2 border-r border-slate-200",children:[g.jsxs("select",{onChange:p=>e("fontName",p.target.value),className:"bg-slate-50 border-none rounded-md px-2 py-1 text-xs font-medium text-slate-600 focus:ring-1 focus:ring-blue-500 outline-none",children:[g.jsx("option",{value:"Inter",children:"Inter"}),g.jsx("option",{value:"Arial",children:"Arial"}),g.jsx("option",{value:"Georgia",children:"Georgia"}),g.jsx("option",{value:"Courier New",children:"Monospace"})]}),g.jsx("select",{onChange:p=>e("fontSize",ct[p.target.value]),defaultValue:"16px",className:"bg-slate-50 border-none rounded-md px-2 py-1 text-xs font-medium text-slate-600 focus:ring-1 focus:ring-blue-500 outline-none w-20",children:Object.keys(ct).map(p=>g.jsx("option",{value:p,children:p},p))})]}),g.jsxs("div",{className:"flex items-center gap-0.5 px-2 border-r border-slate-200",children:[g.jsx(h,{onClick:()=>e("bold"),title:"Bold",children:g.jsx(Qo,{size:18})}),g.jsx(h,{onClick:()=>e("italic"),title:"Italic",children:g.jsx(ei,{size:18})}),g.jsx(h,{onClick:()=>e("underline"),title:"Underline",children:g.jsx(hi,{size:18})}),g.jsx(h,{onClick:()=>e("strikeThrough"),title:"Strikethrough",children:g.jsx(ci,{size:18})})]}),g.jsxs("div",{className:"flex items-center gap-1 px-2 border-r border-slate-200",children:[g.jsxs("label",{className:"p-2 hover:bg-slate-100 rounded-md cursor-pointer relative group",title:"Text Color",children:[g.jsx(si,{size:18,className:"text-slate-600"}),g.jsx("input",{type:"color",onChange:p=>e("foreColor",p.target.value),className:"opacity-0 absolute inset-0 cursor-pointer w-full h-full"})]}),g.jsxs("label",{className:"p-2 hover:bg-slate-100 rounded-md cursor-pointer relative group",title:"Highlight Color",children:[g.jsx(Zo,{size:18,className:"text-slate-600"}),g.jsx("input",{type:"color",defaultValue:"#FFFF00",onChange:p=>e("backColor",p.target.value),className:"opacity-0 absolute inset-0 cursor-pointer w-full h-full"})]})]}),g.jsxs("div",{className:"flex items-center gap-0.5 px-2 border-r border-slate-200",children:[g.jsx(h,{onClick:()=>e("insertOrderedList"),title:"Numbered List",children:g.jsx(ni,{size:18})}),g.jsx(h,{onClick:()=>e("insertUnorderedList"),title:"Bullet List",children:g.jsx(oi,{size:18})})]}),g.jsxs("div",{className:"flex items-center gap-0.5 px-2",children:[g.jsx(h,{onClick:()=>{var p;return(p=c.current)==null?void 0:p.click()},title:"Insert Image",children:g.jsx(jo,{size:18})}),g.jsx("input",{type:"file",ref:c,onChange:d,accept:"image/*",className:"hidden"}),g.jsx(h,{onClick:()=>u(!0),title:"Insert Table",children:g.jsx(fi,{size:18})})]}),g.jsx("div",{className:"ml-auto flex items-center",children:g.jsxs("button",{onClick:t,className:"flex items-center gap-2 px-3 py-1.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-all shadow-sm font-semibold text-sm",children:[g.jsx(di,{size:16}),g.jsx("span",{className:"hidden sm:inline",children:"AI Math Pad"})]})})]}),g.jsx(Wo,{isOpen:a,onClose:()=>u(!1),onInsert:f})]})},ft=w.forwardRef(({onHistoryChange:t},e)=>{const n=w.useRef(null),o=w.useRef(null),[s,l]=w.useState(!1),[a,u]=w.useState(!1),c=w.useRef(null),[d,f]=w.useState([]),[h,p]=w.useState(-1),m=w.useCallback(()=>{const C=n.current,v=c.current;if(!C||!v)return;const I=v.getImageData(0,0,C.width,C.height),A=d.slice(0,h+1);f([...A,I]),p(A.length)},[d,h]);w.useEffect(()=>{t==null||t({canUndo:h>0,canRedo:h<d.length-1})},[d,h,t]),w.useEffect(()=>{const C=n.current,v=o.current;if(!C||!v)return;c.current=C.getContext("2d");const I=new ResizeObserver(A=>{var R;const{width:P,height:N}=A[0].contentRect,U=(R=c.current)==null?void 0:R.getImageData(0,0,C.width,C.height);C.width=P,C.height=N;const x=c.current;if(x&&(x.lineCap="round",x.strokeStyle="#000",x.lineWidth=2,U&&x.putImageData(U,0,0)),d.length===0){const b=x==null?void 0:x.getImageData(0,0,P,N);b&&(f([b]),p(0))}});return I.observe(v),()=>{I.disconnect()}},[]);const y=C=>{const v=n.current;if(!v)return{offsetX:0,offsetY:0};const I=v.getBoundingClientRect(),A="touches"in C?C.touches[0].clientX:C.clientX,P="touches"in C?C.touches[0].clientY:C.clientY;return{offsetX:A-I.left,offsetY:P-I.top}},_=C=>{C.preventDefault();const v=c.current;if(!v)return;const{offsetX:I,offsetY:A}=y(C);v.beginPath(),v.moveTo(I,A),l(!0),u(!0)},T=()=>{const C=c.current;!C||!s||(C.closePath(),l(!1),m())},E=C=>{if(!s||!c.current)return;C.preventDefault();const{offsetX:v,offsetY:I}=y(C);c.current.lineTo(v,I),c.current.stroke()};return w.useImperativeHandle(e,()=>({clear(){const C=c.current,v=n.current;if(C&&v){C.clearRect(0,0,v.width,v.height),u(!1);const I=C.getImageData(0,0,v.width,v.height);f([I]),p(0)}},undo(){var C;if(h>0){const v=h-1;p(v);const I=d[v];(C=c.current)==null||C.putImageData(I,0,0),u(v>0)}},redo(){var C;if(h<d.length-1){const v=h+1;p(v);const I=d[v];(C=c.current)==null||C.putImageData(I,0,0),u(!0)}},getTrimmedImageData(){const C=n.current,v=c.current;if(!a||!C||!v)return null;const I=C.width,A=C.height,N=v.getImageData(0,0,I,A).data;let U=I,x=A,R=0,b=0;for(let X=0;X<A;X++)for(let ge=0;ge<I;ge++)N[(I*X+ge)*4+3]>0&&(U=Math.min(U,ge),x=Math.min(x,X),R=Math.max(R,ge),b=Math.max(b,X));if(U===I)return null;const k=15;U=Math.max(0,U-k),x=Math.max(0,x-k),R=Math.min(I,R+k),b=Math.min(A,b+k);const D=R-U,G=b-x,$=document.createElement("canvas");$.width=D,$.height=G;const H=$.getContext("2d");return H?(H.drawImage(C,U,x,D,G,0,0,D,G),$.toDataURL("image/png")):null}})),g.jsx("div",{ref:o,className:"absolute inset-0 w-full h-full",children:g.jsx("canvas",{ref:n,onMouseDown:_,onMouseUp:T,onMouseMove:E,onMouseLeave:T,onTouchStart:_,onTouchEnd:T,onTouchMove:E,className:"w-full h-full",style:{cursor:"crosshair",touchAction:"none"}})})});ft.displayName="Canvas";/**
|
|
121
|
+
*/const gi=F("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ct={"12px":"1","14px":"2","16px":"3","18px":"4","24px":"5","32px":"6","48px":"7"},yi=({onOpenHandwritingModal:t,onApplyStyle:e,onUndo:n,onRedo:o,canUndo:s,canRedo:l})=>{const[a,u]=w.useState(!1),c=w.useRef(null),d=p=>{var y;const m=(y=p.target.files)==null?void 0:y[0];if(m){const _=new FileReader;_.onload=T=>{var C;const E=(C=T.target)==null?void 0:C.result;e("insertImage",E)},_.readAsDataURL(m)}p.target&&(p.target.value="")},f=(p,m)=>{let y='<table class="border-collapse w-full my-4 border border-slate-300">';for(let _=0;_<p;_++){y+="<tr>";for(let T=0;T<m;T++)y+='<td class="border border-slate-300 p-2 min-h-[40px]"><br></td>';y+="</tr>"}y+="</table><p><br></p>",e("insertHTML",y),u(!1)},h=({onClick:p,disabled:m,title:y,children:_,active:T})=>g.jsx("button",{onClick:p,disabled:m,onMouseDown:E=>E.preventDefault(),title:y,className:`p-2 rounded-md transition-colors flex items-center justify-center disabled:opacity-20 ${T?"bg-blue-100 text-blue-600":"hover:bg-slate-100 text-slate-600"}`,children:_});return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"bg-white px-4 py-2 flex flex-wrap items-center gap-1 border-b border-slate-200 sticky top-0 z-20 shadow-sm",children:[g.jsxs("div",{className:"flex items-center gap-1 pr-2 border-r border-slate-200",children:[g.jsx(h,{onClick:n,disabled:!s,title:"Undo",children:g.jsx(mi,{size:18})}),g.jsx(h,{onClick:o,disabled:!l,title:"Redo",children:g.jsx(li,{size:18})})]}),g.jsxs("div",{className:"flex items-center gap-1 px-2 border-r border-slate-200",children:[g.jsxs("select",{onChange:p=>e("fontName",p.target.value),className:"bg-slate-50 border-none rounded-md px-2 py-1 text-xs font-medium text-slate-600 focus:ring-1 focus:ring-blue-500 outline-none",children:[g.jsx("option",{value:"Inter",children:"Inter"}),g.jsx("option",{value:"Arial",children:"Arial"}),g.jsx("option",{value:"Georgia",children:"Georgia"}),g.jsx("option",{value:"Courier New",children:"Monospace"})]}),g.jsx("select",{onChange:p=>e("fontSize",ct[p.target.value]),defaultValue:"16px",className:"bg-slate-50 border-none rounded-md px-2 py-1 text-xs font-medium text-slate-600 focus:ring-1 focus:ring-blue-500 outline-none w-20",children:Object.keys(ct).map(p=>g.jsx("option",{value:p,children:p},p))})]}),g.jsxs("div",{className:"flex items-center gap-0.5 px-2 border-r border-slate-200",children:[g.jsx(h,{onClick:()=>e("bold"),title:"Bold",children:g.jsx(Qo,{size:18})}),g.jsx(h,{onClick:()=>e("italic"),title:"Italic",children:g.jsx(ei,{size:18})}),g.jsx(h,{onClick:()=>e("underline"),title:"Underline",children:g.jsx(hi,{size:18})}),g.jsx(h,{onClick:()=>e("strikeThrough"),title:"Strikethrough",children:g.jsx(ci,{size:18})})]}),g.jsxs("div",{className:"flex items-center gap-1 px-2 border-r border-slate-200",children:[g.jsxs("label",{className:"p-2 hover:bg-slate-100 rounded-md cursor-pointer relative group",title:"Text Color",children:[g.jsx(si,{size:18,className:"text-slate-600"}),g.jsx("input",{type:"color",onChange:p=>e("foreColor",p.target.value),className:"opacity-0 absolute inset-0 cursor-pointer w-full h-full"})]}),g.jsxs("label",{className:"p-2 hover:bg-slate-100 rounded-md cursor-pointer relative group",title:"Highlight Color",children:[g.jsx(Zo,{size:18,className:"text-slate-600"}),g.jsx("input",{type:"color",defaultValue:"#FFFF00",onChange:p=>e("backColor",p.target.value),className:"opacity-0 absolute inset-0 cursor-pointer w-full h-full"})]})]}),g.jsxs("div",{className:"flex items-center gap-0.5 px-2 border-r border-slate-200",children:[g.jsx(h,{onClick:()=>e("insertOrderedList"),title:"Numbered List",children:g.jsx(ni,{size:18})}),g.jsx(h,{onClick:()=>e("insertUnorderedList"),title:"Bullet List",children:g.jsx(oi,{size:18})})]}),g.jsxs("div",{className:"flex items-center gap-0.5 px-2",children:[g.jsx(h,{onClick:()=>{var p;return(p=c.current)==null?void 0:p.click()},title:"Insert Image",children:g.jsx(jo,{size:18})}),g.jsx("input",{type:"file",ref:c,onChange:d,accept:"image/*",className:"hidden"}),g.jsx(h,{onClick:()=>u(!0),title:"Insert Table",children:g.jsx(fi,{size:18})})]}),g.jsx("div",{className:"ml-auto flex items-center",children:g.jsxs("button",{onClick:t,className:"flex items-center gap-2 px-3 py-1.5 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-all shadow-sm font-semibold text-sm",children:[g.jsx(di,{size:16}),g.jsx("span",{className:"hidden sm:inline",children:"AI Math Pad"})]})})]}),g.jsx(Wo,{isOpen:a,onClose:()=>u(!1),onInsert:f})]})},ft=w.forwardRef(({onHistoryChange:t},e)=>{const n=w.useRef(null),o=w.useRef(null),[s,l]=w.useState(!1),[a,u]=w.useState(!1),c=w.useRef(null),[d,f]=w.useState([]),[h,p]=w.useState(-1),m=w.useCallback(()=>{const C=n.current,v=c.current;if(!C||!v)return;const I=v.getImageData(0,0,C.width,C.height),A=d.slice(0,h+1);f([...A,I]),p(A.length)},[d,h]);w.useEffect(()=>{t==null||t({canUndo:h>0,canRedo:h<d.length-1})},[d,h,t]),w.useEffect(()=>{if(typeof window>"u")return;const C=n.current,v=o.current;if(!C||!v)return;c.current=C.getContext("2d");const I=new ResizeObserver(A=>{var R;const{width:P,height:N}=A[0].contentRect,U=(R=c.current)==null?void 0:R.getImageData(0,0,C.width,C.height);C.width=P,C.height=N;const x=c.current;if(x&&(x.lineCap="round",x.strokeStyle="#000",x.lineWidth=2,U&&x.putImageData(U,0,0)),d.length===0){const b=x==null?void 0:x.getImageData(0,0,P,N);b&&(f([b]),p(0))}});return I.observe(v),()=>{I.disconnect()}},[]);const y=C=>{const v=n.current;if(!v)return{offsetX:0,offsetY:0};const I=v.getBoundingClientRect(),A="touches"in C?C.touches[0].clientX:C.clientX,P="touches"in C?C.touches[0].clientY:C.clientY;return{offsetX:A-I.left,offsetY:P-I.top}},_=C=>{C.preventDefault();const v=c.current;if(!v)return;const{offsetX:I,offsetY:A}=y(C);v.beginPath(),v.moveTo(I,A),l(!0),u(!0)},T=()=>{const C=c.current;!C||!s||(C.closePath(),l(!1),m())},E=C=>{if(!s||!c.current)return;C.preventDefault();const{offsetX:v,offsetY:I}=y(C);c.current.lineTo(v,I),c.current.stroke()};return w.useImperativeHandle(e,()=>({clear(){const C=c.current,v=n.current;if(C&&v){C.clearRect(0,0,v.width,v.height),u(!1);const I=C.getImageData(0,0,v.width,v.height);f([I]),p(0)}},undo(){var C;if(h>0){const v=h-1;p(v);const I=d[v];(C=c.current)==null||C.putImageData(I,0,0),u(v>0)}},redo(){var C;if(h<d.length-1){const v=h+1;p(v);const I=d[v];(C=c.current)==null||C.putImageData(I,0,0),u(!0)}},getTrimmedImageData(){const C=n.current,v=c.current;if(!a||!C||!v)return null;const I=C.width,A=C.height,N=v.getImageData(0,0,I,A).data;let U=I,x=A,R=0,b=0;for(let X=0;X<A;X++)for(let ge=0;ge<I;ge++)N[(I*X+ge)*4+3]>0&&(U=Math.min(U,ge),x=Math.min(x,X),R=Math.max(R,ge),b=Math.max(b,X));if(U===I)return null;const k=15;U=Math.max(0,U-k),x=Math.max(0,x-k),R=Math.min(I,R+k),b=Math.min(A,b+k);const D=R-U,G=b-x,$=document.createElement("canvas");$.width=D,$.height=G;const H=$.getContext("2d");return H?(H.drawImage(C,U,x,D,G,0,0,D,G),$.toDataURL("image/png")):null}})),g.jsx("div",{ref:o,className:"absolute inset-0 w-full h-full",children:g.jsx("canvas",{ref:n,onMouseDown:_,onMouseUp:T,onMouseMove:E,onMouseLeave:T,onTouchStart:_,onTouchEnd:T,onTouchMove:E,className:"w-full h-full",style:{cursor:"crosshair",touchAction:"none"}})})});ft.displayName="Canvas";/**
|
|
122
122
|
* @license
|
|
123
123
|
* Copyright 2025 Google LLC
|
|
124
124
|
* SPDX-License-Identifier: Apache-2.0
|