easy-email-pro-theme 1.57.13 → 1.58.1

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/lib/index.js CHANGED
@@ -58,7 +58,8 @@ import { classnames, useEditorActions, useDragNodePath, useStandaloneElementEdit
58
58
  import { useSlate, ReactEditor, useSlateStatic, useSelected } from "slate-react";
59
59
  import * as React$2 from "react";
60
60
  import React__default, { useRef, useState, useEffect, useCallback, useMemo, createContext, useContext, useLayoutEffect, memo, useReducer, cloneElement, forwardRef, createElement, Suspense, Component } from "react";
61
- import { NodeUtils, BlockManager, ElementType, EditorCore, t, ElementCategory, classnames as classnames$1, StandardType, PluginManager, EditorAuth, mjmlToJsonCore, ConditionOperator, ConditionOperatorSymbol, EmailRenderProvider, components, HtmlNodeAdapter, I18nManager } from "easy-email-pro-core";
61
+ import { NodeUtils, BlockManager, ElementType, EditorCore, t, ElementCategory, classnames as classnames$1, StandardType, PluginManager, EditorAuth, mjmlToJsonCore, ConditionOperator, ConditionOperatorSymbol, EmailRenderProvider, components, HtmlNodeAdapter, assertAiAgentFeatureEnabled, imageReplacementTarget, imageDecisionChoices, canAutoReplaceImageTarget, imageTargetAttributeKey, normalizeToolCallsPayload, freezeSelectedTargets, selectedTargetFromContext, resolveAiChatResult, choiceImageAttributeKey, I18nManager } from "easy-email-pro-core";
62
+ import { parseEasyEmailAiStream, resolveAiChatResult as resolveAiChatResult2 } from "easy-email-pro-core";
62
63
  import { cloneDeep, get, isEqual, set, omit as omit$2, merge as merge$1, debounce as debounce$2, isUndefined as isUndefined$1, uniqueId, isFunction as isFunction$5, isString as isString$2, isNumber as isNumber$1, upperFirst, sum, flatMap } from "lodash";
63
64
  import { Editor, Range, Node, Transforms, Path, Text as Text$4, createEditor } from "slate";
64
65
  import { nanoid } from "nanoid";
@@ -2296,6 +2297,474 @@ const useBlocksDrawer = () => {
2296
2297
  parentCategory: context.blocksDrawerParentCategory
2297
2298
  };
2298
2299
  };
2300
+ const MAX_TOOL_CALLS = 30;
2301
+ const MAX_REPLACE_CHILDREN_NODES = 160;
2302
+ function isObject$b(value) {
2303
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
2304
+ }
2305
+ function isTextNode(value) {
2306
+ return isObject$b(value) && typeof value.text === "string";
2307
+ }
2308
+ function isElement$1(value) {
2309
+ return NodeUtils.isElement(value);
2310
+ }
2311
+ function canReplaceNodeText(node) {
2312
+ if (isTextNode(node))
2313
+ return true;
2314
+ if (!NodeUtils.isElement(node))
2315
+ return false;
2316
+ if (NodeUtils.isLineBreakElement(node) || NodeUtils.isMergetagElement(node)) {
2317
+ return true;
2318
+ }
2319
+ if (NodeUtils.isHTMLBlockNodeElement(node)) {
2320
+ return node.children.every(
2321
+ (child) => canReplaceNodeText(child)
2322
+ );
2323
+ }
2324
+ return false;
2325
+ }
2326
+ function canReplaceWithPlainText(element) {
2327
+ return element.children.every(
2328
+ (child) => canReplaceNodeText(child)
2329
+ );
2330
+ }
2331
+ function hasAnyTextNode(element) {
2332
+ return element.children.some((child) => {
2333
+ if (isTextNode(child))
2334
+ return true;
2335
+ if (!NodeUtils.isElement(child))
2336
+ return false;
2337
+ if (NodeUtils.isHTMLBlockNodeElement(child)) {
2338
+ return hasAnyTextNode(child);
2339
+ }
2340
+ return false;
2341
+ });
2342
+ }
2343
+ function textToChildren(text) {
2344
+ return text.split("\n").flatMap((line, index2, lines) => {
2345
+ const nodes = [{ text: line }];
2346
+ if (index2 !== lines.length - 1) {
2347
+ nodes.push({
2348
+ type: ElementType.LINE_BREAK,
2349
+ data: {},
2350
+ attributes: {},
2351
+ children: [{ text: "" }]
2352
+ });
2353
+ }
2354
+ return nodes;
2355
+ });
2356
+ }
2357
+ function isSafeFieldKey(key2) {
2358
+ return typeof key2 === "string" && key2.length > 0 && key2.length <= 80 && !key2.includes("__proto__") && !key2.includes("prototype") && !key2.includes("constructor") && /^[a-zA-Z0-9_.-]+$/.test(key2);
2359
+ }
2360
+ function normalizeAttributeKey(key2) {
2361
+ return key2.replace(/^attributes\./, "");
2362
+ }
2363
+ function normalizeMobileAttributeKey(key2) {
2364
+ return key2.replace(/^mobileAttributes\./, "");
2365
+ }
2366
+ function targetLabel(target) {
2367
+ if ("selected" in target)
2368
+ return t("selected");
2369
+ if ("id" in target && target.id === "__easy_email_ai_agent_no_initial_selection__") {
2370
+ return t("selected: no element was selected when the request started");
2371
+ }
2372
+ if ("id" in target)
2373
+ return `id:${target.id}`;
2374
+ if ("uid" in target)
2375
+ return `uid:${target.uid}`;
2376
+ return `type:${target.type}${typeof target.index === "number" ? `[${target.index}]` : ""}`;
2377
+ }
2378
+ function elementLabel(element) {
2379
+ var _a;
2380
+ return element.title || ((_a = BlockManager.getBlockByType(element.type)) == null ? void 0 : _a.name) || element.type;
2381
+ }
2382
+ function targetFromElement(element, fallback) {
2383
+ if (element.id)
2384
+ return { id: element.id };
2385
+ if (element.uid)
2386
+ return { uid: element.uid };
2387
+ return fallback;
2388
+ }
2389
+ function describeAppliedChange(call) {
2390
+ if (call.name === "update_text")
2391
+ return t("Text updated");
2392
+ if (call.name === "update_attribute")
2393
+ return t("Style or attribute updated");
2394
+ if (call.name === "update_mobile_attribute")
2395
+ return t("Mobile style updated");
2396
+ if (call.name === "update_attributes") {
2397
+ return call.scope === "mobile" ? t("Mobile styles updated") : t("Styles updated");
2398
+ }
2399
+ if (call.name === "update_data")
2400
+ return t("Content setting updated");
2401
+ if (call.name === "replace_children")
2402
+ return t("Content updated");
2403
+ if (call.name === "set_visibility")
2404
+ return t("Visibility updated");
2405
+ if (call.name === "replace_block")
2406
+ return t("Block replaced");
2407
+ if (call.name === "update_link")
2408
+ return t("Link updated");
2409
+ if (call.name === "add_block_after")
2410
+ return t("Block added");
2411
+ if (call.name === "add_block_before")
2412
+ return t("Block added");
2413
+ if (call.name === "duplicate")
2414
+ return t("Duplicated");
2415
+ if (call.name === "delete_node")
2416
+ return t("Deleted");
2417
+ if (call.name === "move_up")
2418
+ return t("Moved up");
2419
+ if (call.name === "move_down")
2420
+ return t("Moved down");
2421
+ if (call.name === "select_node")
2422
+ return t("Selected");
2423
+ return t("Template updated");
2424
+ }
2425
+ function closestBlockEntry(editor, path2) {
2426
+ for (let currentPath = path2; currentPath.length > 0; currentPath = Path.parent(currentPath)) {
2427
+ const node = Node.get(editor, currentPath);
2428
+ if (NodeUtils.isBlockElement(node)) {
2429
+ return [node, currentPath];
2430
+ }
2431
+ }
2432
+ return null;
2433
+ }
2434
+ function changeKey(path2, description) {
2435
+ return `${path2.join(".")}:${description}`;
2436
+ }
2437
+ function isProtectedForStructureEdit(node) {
2438
+ return NodeUtils.isPageElement(node) || NodeUtils.isPageHeaderElement(node) || NodeUtils.isPageFooterElement(node);
2439
+ }
2440
+ function countNodes(children) {
2441
+ return children.reduce((total, child) => {
2442
+ if (!isObject$b(child))
2443
+ return total + 1;
2444
+ const nested = Array.isArray(child.children) ? countNodes(child.children) : 0;
2445
+ return total + 1 + nested;
2446
+ }, 0);
2447
+ }
2448
+ function normalizeChildren(children) {
2449
+ return children.map((child) => {
2450
+ if (isTextNode(child))
2451
+ return child;
2452
+ if (!isElement$1(child)) {
2453
+ throw new Error(t("children must contain Easy Email nodes"));
2454
+ }
2455
+ if (!BlockManager.getBlockByType(child.type)) {
2456
+ throw new Error(`${t("unknown block type")}: ${child.type}`);
2457
+ }
2458
+ return assignIdsToElementTree(child);
2459
+ });
2460
+ }
2461
+ function normalizeBlock(block) {
2462
+ if (!isObject$b(block) || typeof block.type !== "string") {
2463
+ throw new Error(t("block.type is required"));
2464
+ }
2465
+ if (!BlockManager.getBlockByType(block.type)) {
2466
+ throw new Error(`${t("unknown block type")}: ${block.type}`);
2467
+ }
2468
+ return block;
2469
+ }
2470
+ function normalizeElementBlock(block) {
2471
+ const normalized = normalizeBlock(block);
2472
+ return assignIdsToElementTree(__spreadProps(__spreadValues({}, normalized), {
2473
+ data: isObject$b(normalized.data) ? normalized.data : {},
2474
+ attributes: isObject$b(normalized.attributes) ? normalized.attributes : {},
2475
+ children: Array.isArray(normalized.children) ? normalized.children : []
2476
+ }));
2477
+ }
2478
+ function useApplyAiToolCalls() {
2479
+ const editor = useSlate();
2480
+ const lock = useLockState();
2481
+ const selectedNodePath = useSelectedNodePath();
2482
+ const setSelectedNodePath = useSetSelectedNodePath();
2483
+ const { setFieldValue, reset } = useEditorContext();
2484
+ const { addBlock, copyBlock, deleteBlock, moveDown, moveUp } = useElementInteract();
2485
+ const resolveTargetPath = useEventCallback((target) => {
2486
+ if ("selected" in target)
2487
+ return selectedNodePath;
2488
+ const entry = Array.from(
2489
+ Editor.nodes(editor, {
2490
+ at: [],
2491
+ match: (node) => {
2492
+ if (!NodeUtils.isElement(node))
2493
+ return false;
2494
+ const element = node;
2495
+ if ("id" in target)
2496
+ return element.id === target.id;
2497
+ if ("uid" in target)
2498
+ return element.uid === target.uid;
2499
+ return false;
2500
+ }
2501
+ })
2502
+ )[0];
2503
+ if (entry)
2504
+ return entry[1];
2505
+ if ("type" in target) {
2506
+ const targetIndex = typeof target.index === "number" && target.index >= 0 ? Math.floor(target.index) : 0;
2507
+ const typeEntry = Array.from(
2508
+ Editor.nodes(editor, {
2509
+ at: [],
2510
+ match: (node) => NodeUtils.isElement(node) && node.type === target.type
2511
+ })
2512
+ )[targetIndex];
2513
+ return typeEntry ? typeEntry[1] : null;
2514
+ }
2515
+ return null;
2516
+ });
2517
+ const getTargetElement = useEventCallback(
2518
+ (target) => {
2519
+ const path2 = resolveTargetPath(target);
2520
+ if (!path2)
2521
+ return null;
2522
+ const node = Node.get(editor, path2);
2523
+ if (!NodeUtils.isElement(node))
2524
+ return null;
2525
+ return [node, path2];
2526
+ }
2527
+ );
2528
+ return useEventCallback((toolCalls) => {
2529
+ const result = {
2530
+ applied: 0,
2531
+ skipped: 0,
2532
+ errors: [],
2533
+ changes: []
2534
+ };
2535
+ if (lock) {
2536
+ return {
2537
+ applied: 0,
2538
+ skipped: toolCalls.length,
2539
+ errors: [t("editor is locked")]
2540
+ };
2541
+ }
2542
+ const calls = toolCalls.slice(0, MAX_TOOL_CALLS);
2543
+ if (toolCalls.length > MAX_TOOL_CALLS) {
2544
+ result.errors.push(`${t("tool calls truncated to")} ${MAX_TOOL_CALLS}`);
2545
+ }
2546
+ Editor.withoutNormalizing(editor, () => {
2547
+ calls.forEach((call, index2) => {
2548
+ try {
2549
+ if (call.name === "apply_template") {
2550
+ reset(call.template);
2551
+ result.applied += 1;
2552
+ return;
2553
+ }
2554
+ const targetEntry = getTargetElement(call.target);
2555
+ if (!targetEntry) {
2556
+ result.skipped += 1;
2557
+ result.errors.push(
2558
+ `${call.name}: ${t("target not found")} (${targetLabel(call.target)})`
2559
+ );
2560
+ return;
2561
+ }
2562
+ const [element, path2] = targetEntry;
2563
+ const recordChange = () => {
2564
+ var _a, _b;
2565
+ const [blockElement, blockPath] = closestBlockEntry(
2566
+ editor,
2567
+ path2
2568
+ ) || [element, path2];
2569
+ const key2 = changeKey(blockPath, describeAppliedChange(call));
2570
+ if ((_a = result.changes) == null ? void 0 : _a.some((change) => change.id === key2))
2571
+ return;
2572
+ (_b = result.changes) == null ? void 0 : _b.push({
2573
+ id: key2,
2574
+ label: elementLabel(blockElement),
2575
+ description: describeAppliedChange(call),
2576
+ target: targetFromElement(blockElement, call.target),
2577
+ path: [...blockPath]
2578
+ });
2579
+ };
2580
+ if (call.name === "update_text") {
2581
+ if (!canReplaceWithPlainText(element)) {
2582
+ throw new Error(
2583
+ hasAnyTextNode(element) ? t(
2584
+ "target contains mixed content; use a more specific text node"
2585
+ ) : t("target has no editable text")
2586
+ );
2587
+ }
2588
+ setFieldValue(path2, "children", textToChildren(call.text));
2589
+ result.applied += 1;
2590
+ recordChange();
2591
+ return;
2592
+ }
2593
+ if (call.name === "update_attribute") {
2594
+ if (!isSafeFieldKey(call.key))
2595
+ throw new Error(t("invalid attribute key"));
2596
+ if (call.key.startsWith("mobileAttributes.")) {
2597
+ const mobileKey = normalizeMobileAttributeKey(call.key);
2598
+ setFieldValue(
2599
+ path2,
2600
+ `mobileAttributes.${mobileKey}`,
2601
+ call.value === null ? void 0 : call.value
2602
+ );
2603
+ result.applied += 1;
2604
+ recordChange();
2605
+ return;
2606
+ }
2607
+ const attributeKey = normalizeAttributeKey(call.key);
2608
+ setFieldValue(
2609
+ path2,
2610
+ `attributes.${attributeKey}`,
2611
+ call.value === null ? void 0 : call.value
2612
+ );
2613
+ result.applied += 1;
2614
+ recordChange();
2615
+ return;
2616
+ }
2617
+ if (call.name === "update_mobile_attribute") {
2618
+ if (!isSafeFieldKey(call.key))
2619
+ throw new Error(t("invalid mobile attribute key"));
2620
+ const mobileKey = normalizeMobileAttributeKey(call.key);
2621
+ setFieldValue(
2622
+ path2,
2623
+ `mobileAttributes.${mobileKey}`,
2624
+ call.value === null ? void 0 : call.value
2625
+ );
2626
+ result.applied += 1;
2627
+ recordChange();
2628
+ return;
2629
+ }
2630
+ if (call.name === "update_attributes") {
2631
+ if (!isObject$b(call.attributes)) {
2632
+ throw new Error(t("attributes must be an object"));
2633
+ }
2634
+ Object.entries(call.attributes).forEach(([key2, value]) => {
2635
+ if (!isSafeFieldKey(key2)) {
2636
+ throw new Error(`${t("invalid attribute key")}: ${key2}`);
2637
+ }
2638
+ const fieldRoot = call.scope === "mobile" || key2.startsWith("mobileAttributes.") ? "mobileAttributes" : "attributes";
2639
+ const normalizedKey = fieldRoot === "mobileAttributes" ? normalizeMobileAttributeKey(key2) : normalizeAttributeKey(key2);
2640
+ setFieldValue(
2641
+ path2,
2642
+ `${fieldRoot}.${normalizedKey}`,
2643
+ value === null ? void 0 : value
2644
+ );
2645
+ });
2646
+ result.applied += 1;
2647
+ recordChange();
2648
+ return;
2649
+ }
2650
+ if (call.name === "update_data") {
2651
+ if (!isSafeFieldKey(call.key))
2652
+ throw new Error(t("invalid data key"));
2653
+ setFieldValue(
2654
+ path2,
2655
+ `data.${call.key}`,
2656
+ call.value === null ? void 0 : call.value
2657
+ );
2658
+ result.applied += 1;
2659
+ recordChange();
2660
+ return;
2661
+ }
2662
+ if (call.name === "replace_children") {
2663
+ const total = countNodes(call.children);
2664
+ if (total > MAX_REPLACE_CHILDREN_NODES) {
2665
+ throw new Error(
2666
+ `${t("replace_children is too large")} (${total} ${t("nodes")})`
2667
+ );
2668
+ }
2669
+ setFieldValue(path2, "children", normalizeChildren(call.children));
2670
+ result.applied += 1;
2671
+ recordChange();
2672
+ return;
2673
+ }
2674
+ if (call.name === "set_visibility") {
2675
+ if (call.desktop === false && call.mobile === false) {
2676
+ throw new Error(t("at least one device must remain visible"));
2677
+ }
2678
+ const visible = call.desktop === true && call.mobile === false ? "desktop" : call.desktop === false && call.mobile === true ? "mobile" : void 0;
2679
+ setFieldValue(path2, "visible", visible);
2680
+ result.applied += 1;
2681
+ recordChange();
2682
+ return;
2683
+ }
2684
+ if (call.name === "update_link") {
2685
+ if (typeof call.href !== "string")
2686
+ throw new Error(t("href is required"));
2687
+ setFieldValue(path2, "attributes.href", call.href);
2688
+ if (typeof call.blank === "boolean") {
2689
+ setFieldValue(
2690
+ path2,
2691
+ "attributes.target",
2692
+ call.blank ? "_blank" : "_self"
2693
+ );
2694
+ }
2695
+ if (typeof call.title === "string") {
2696
+ setFieldValue(path2, "attributes.title", call.title);
2697
+ }
2698
+ result.applied += 1;
2699
+ recordChange();
2700
+ return;
2701
+ }
2702
+ if (call.name === "select_node") {
2703
+ setSelectedNodePath(path2);
2704
+ result.applied += 1;
2705
+ recordChange();
2706
+ return;
2707
+ }
2708
+ if (isProtectedForStructureEdit(element)) {
2709
+ throw new Error(t("protected node cannot be structurally edited"));
2710
+ }
2711
+ if (call.name === "replace_block") {
2712
+ const replacement = normalizeElementBlock(call.block);
2713
+ Transforms.removeNodes(editor, { at: path2 });
2714
+ Transforms.insertNodes(editor, replacement, { at: path2 });
2715
+ result.applied += 1;
2716
+ recordChange();
2717
+ return;
2718
+ }
2719
+ if (call.name === "move_up") {
2720
+ moveUp(path2);
2721
+ result.applied += 1;
2722
+ recordChange();
2723
+ return;
2724
+ }
2725
+ if (call.name === "move_down") {
2726
+ moveDown(path2);
2727
+ result.applied += 1;
2728
+ recordChange();
2729
+ return;
2730
+ }
2731
+ if (call.name === "duplicate") {
2732
+ copyBlock(path2);
2733
+ result.applied += 1;
2734
+ recordChange();
2735
+ return;
2736
+ }
2737
+ if (call.name === "delete_node") {
2738
+ deleteBlock(path2);
2739
+ result.applied += 1;
2740
+ recordChange();
2741
+ return;
2742
+ }
2743
+ if (call.name === "add_block_after") {
2744
+ addBlock(normalizeBlock(call.block), path2, true);
2745
+ result.applied += 1;
2746
+ recordChange();
2747
+ return;
2748
+ }
2749
+ if (call.name === "add_block_before") {
2750
+ addBlock(normalizeBlock(call.block), path2, false);
2751
+ result.applied += 1;
2752
+ recordChange();
2753
+ return;
2754
+ }
2755
+ result.skipped += 1;
2756
+ result.errors.push(`${call.name}: ${t("unsupported tool")}`);
2757
+ } catch (error2) {
2758
+ result.skipped += 1;
2759
+ result.errors.push(
2760
+ `${index2 + 1}. ${call.name}: ${error2 instanceof Error ? error2.message : String(error2)}`
2761
+ );
2762
+ }
2763
+ });
2764
+ });
2765
+ return result;
2766
+ });
2767
+ }
2299
2768
  const ElementTools$1 = ({ element, nodeElement, path: path2 }) => {
2300
2769
  const editor = useSlate();
2301
2770
  const { copyBlock, deleteBlock } = useElementInteract();
@@ -2493,7 +2962,7 @@ const ElementSelected = ({ element, nodeElement, path: path2 }) => {
2493
2962
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, renderContent);
2494
2963
  };
2495
2964
  const styleText$d = "body {\n --sectionElementOffset: 100px;\n --wrapperElementOffset: 150px;\n}\n\n@media screen and (max-width: 850px) {\n [data-slate-block=page] {\n --sectionElementOffset: 70px;\n --wrapperElementOffset: 100px;\n }\n}\n.section-category-hover {\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n width: calc(100% + 2 * var(--sectionElementOffset));\n transform: translate(calc(-1 * var(--sectionElementOffset)), 0);\n}\n\n.hero-category-hover {\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n width: calc(100% + 2 * var(--sectionElementOffset));\n transform: translate(calc(-1 * var(--sectionElementOffset)), 0);\n}\n\n[data-is-full-width=true].section-category-hover {\n width: calc(100% - 4px);\n transform: none;\n}\n\n[data-is-hero-category=true].element-tools-container {\n width: calc(100% + 2 * var(--sectionElementOffset));\n transform: translate(calc(-1 * var(--sectionElementOffset)), 0);\n}\n\n[data-is-section-category=true].element-tools-container {\n width: calc(100% + 2 * var(--sectionElementOffset));\n transform: translate(calc(-1 * var(--sectionElementOffset)), 0);\n}\n\n[data-is-section-category=true][data-is-full-width=true].element-tools-container {\n width: calc(100% - 4px - 16px);\n transform: none;\n}\n\n.wrapper-category-hover {\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n width: calc(100% + 2 * var(--wrapperElementOffset));\n transform: translate(calc(-1 * var(--wrapperElementOffset)), 0);\n}\n\n[data-is-full-width=true].wrapper-category-hover {\n width: calc(100% - 4px - 16px);\n transform: none;\n}\n\n[data-is-wrapper-category=true].element-tools-container {\n width: calc(100% + 2 * var(--wrapperElementOffset));\n transform: translate(calc(-1 * var(--wrapperElementOffset)), 0);\n position: absolute;\n}\n\n[data-is-wrapper-category=true][data-is-full-width=true].element-tools-container {\n width: calc(100% - 4px);\n transform: none;\n}\n\n.wrapper-category-hover {\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n width: calc(100% + 2 * var(--wrapperElementOffset));\n transform: translate(calc(-1 * var(--wrapperElementOffset)), 0);\n}\n\n[data-is-wrapper-category=true].element-tools-container {\n width: calc(100% + 2 * var(--wrapperElementOffset));\n transform: translate(calc(-1 * var(--wrapperElementOffset)), 0);\n position: absolute;\n}\n\n.amp-interactive-badge {\n position: absolute;\n top: 8px;\n right: 8px;\n padding: 4px 10px;\n background-color: #f57c00;\n color: #fff;\n font-size: 12px;\n font-weight: 600;\n border-radius: 6px;\n white-space: nowrap;\n pointer-events: none;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);\n z-index: 1;\n}\n\n.html-badge {\n position: absolute;\n top: 8px;\n right: 8px;\n padding: 4px 10px;\n background-color: #165dff;\n color: #fff;\n font-size: 12px;\n font-weight: 600;\n border-radius: 6px;\n white-space: nowrap;\n pointer-events: none;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);\n z-index: 1;\n}";
2496
- const stylesText$1 = '.BlockSideBar .arco-tabs-header {\n display: flex;\n width: 100%;\n}\n.BlockSideBar .arco-tabs-header .arco-tabs-header-title {\n flex: 1;\n margin: 0px !important;\n padding: 0 !important;\n height: 60px;\n line-height: 60px;\n position: relative;\n}\n.BlockSideBar .arco-tabs-header .arco-tabs-header-title:hover::after {\n content: "";\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n top: initial;\n height: 2px;\n background-color: var(--color-border-3);\n transition: left 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), width 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);\n}\n.BlockSideBar .arco-tabs-header .arco-tabs-header-title .arco-tabs-header-title-text {\n display: block;\n text-align: center;\n width: 100%;\n}\n.BlockSideBar .arco-tabs-header .arco-tabs-header-title .arco-tabs-header-title-text::before {\n display: none;\n}\n.BlockSideBar .arco-tabs-content {\n padding-top: 0;\n}\n\n.ConfigurationSideBar {\n height: 60px;\n line-height: 60px;\n position: relative;\n border-bottom: 1px solid #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: center;\n color: rgb(var(--primary-6));\n font-weight: 500;\n}';
2965
+ const stylesText$1 = '.BlockSideBar .arco-tabs-header {\n display: flex;\n width: 100%;\n}\n.BlockSideBar .arco-tabs-header .arco-tabs-header-title {\n flex: 1;\n margin: 0px !important;\n padding: 0 !important;\n height: 60px;\n line-height: 60px;\n position: relative;\n}\n.BlockSideBar .arco-tabs-header .arco-tabs-header-title:hover::after {\n content: "";\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n top: initial;\n height: 2px;\n background-color: var(--color-border-3);\n transition: left 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), width 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);\n}\n.BlockSideBar .arco-tabs-header .arco-tabs-header-title .arco-tabs-header-title-text {\n display: block;\n text-align: center;\n width: 100%;\n}\n.BlockSideBar .arco-tabs-header .arco-tabs-header-title .arco-tabs-header-title-text::before {\n display: none;\n}\n.BlockSideBar .arco-tabs-content {\n padding-top: 0;\n}\n.BlockSideBar .easy-email-pro-block-sidebar-ai-agent .eep-ai-agent {\n width: 100%;\n min-width: 0;\n min-height: 0;\n border-left: 0;\n}\n\n.ConfigurationSideBar {\n height: 60px;\n line-height: 60px;\n position: relative;\n border-bottom: 1px solid #e5e7eb;\n display: flex;\n align-items: center;\n justify-content: center;\n color: rgb(var(--primary-6));\n font-weight: 500;\n}';
2497
2966
  const UniversalList = () => {
2498
2967
  const { universalElementSetting } = useEditorProps();
2499
2968
  if (!universalElementSetting)
@@ -3317,9 +3786,9 @@ function useUniqueId(prefix, value) {
3317
3786
  if (value) {
3318
3787
  return value;
3319
3788
  }
3320
- const id = ids[prefix] == null ? 0 : ids[prefix] + 1;
3321
- ids[prefix] = id;
3322
- return prefix + "-" + id;
3789
+ const id2 = ids[prefix] == null ? 0 : ids[prefix] + 1;
3790
+ ids[prefix] = id2;
3791
+ return prefix + "-" + id2;
3323
3792
  }, [prefix, value]);
3324
3793
  }
3325
3794
  function createAdjustmentFn(modifier) {
@@ -3448,17 +3917,17 @@ const hiddenStyles = {
3448
3917
  };
3449
3918
  function HiddenText(_ref) {
3450
3919
  let {
3451
- id,
3920
+ id: id2,
3452
3921
  value
3453
3922
  } = _ref;
3454
3923
  return React__default.createElement("div", {
3455
- id,
3924
+ id: id2,
3456
3925
  style: hiddenStyles
3457
3926
  }, value);
3458
3927
  }
3459
3928
  function LiveRegion(_ref) {
3460
3929
  let {
3461
- id,
3930
+ id: id2,
3462
3931
  announcement,
3463
3932
  ariaLiveType = "assertive"
3464
3933
  } = _ref;
@@ -3475,7 +3944,7 @@ function LiveRegion(_ref) {
3475
3944
  whiteSpace: "nowrap"
3476
3945
  };
3477
3946
  return React__default.createElement("div", {
3478
- id,
3947
+ id: id2,
3479
3948
  style: visuallyHidden,
3480
3949
  role: "status",
3481
3950
  "aria-live": ariaLiveType,
@@ -3746,13 +4215,13 @@ const closestCenter = (_ref) => {
3746
4215
  const collisions = [];
3747
4216
  for (const droppableContainer of droppableContainers) {
3748
4217
  const {
3749
- id
4218
+ id: id2
3750
4219
  } = droppableContainer;
3751
- const rect = droppableRects.get(id);
4220
+ const rect = droppableRects.get(id2);
3752
4221
  if (rect) {
3753
4222
  const distBetween = distanceBetween(centerOfRectangle(rect), centerRect);
3754
4223
  collisions.push({
3755
- id,
4224
+ id: id2,
3756
4225
  data: {
3757
4226
  droppableContainer,
3758
4227
  value: distBetween
@@ -3787,14 +4256,14 @@ const rectIntersection = (_ref) => {
3787
4256
  const collisions = [];
3788
4257
  for (const droppableContainer of droppableContainers) {
3789
4258
  const {
3790
- id
4259
+ id: id2
3791
4260
  } = droppableContainer;
3792
- const rect = droppableRects.get(id);
4261
+ const rect = droppableRects.get(id2);
3793
4262
  if (rect) {
3794
4263
  const intersectionRatio = getIntersectionRatio(rect, collisionRect);
3795
4264
  if (intersectionRatio > 0) {
3796
4265
  collisions.push({
3797
- id,
4266
+ id: id2,
3798
4267
  data: {
3799
4268
  droppableContainer,
3800
4269
  value: intersectionRatio
@@ -4964,16 +5433,16 @@ function useScrollIntent(_ref2) {
4964
5433
  };
4965
5434
  }, [disabled, delta, previousDelta]);
4966
5435
  }
4967
- function useCachedNode(draggableNodes, id) {
4968
- const draggableNode = id !== null ? draggableNodes.get(id) : void 0;
5436
+ function useCachedNode(draggableNodes, id2) {
5437
+ const draggableNode = id2 !== null ? draggableNodes.get(id2) : void 0;
4969
5438
  const node = draggableNode ? draggableNode.node.current : null;
4970
5439
  return useLazyMemo((cachedNode) => {
4971
5440
  var _ref;
4972
- if (id === null) {
5441
+ if (id2 === null) {
4973
5442
  return null;
4974
5443
  }
4975
5444
  return (_ref = node != null ? node : cachedNode) != null ? _ref : null;
4976
- }, [node, id]);
5445
+ }, [node, id2]);
4977
5446
  }
4978
5447
  function useCombineActivators(sensors, getSyntheticHandler) {
4979
5448
  return useMemo(() => sensors.reduce((accumulator, sensor) => {
@@ -5024,7 +5493,7 @@ function useDroppableMeasuring(containers, _ref) {
5024
5493
  if (value === null) {
5025
5494
  return ids2;
5026
5495
  }
5027
- return value.concat(ids2.filter((id) => !value.includes(id)));
5496
+ return value.concat(ids2.filter((id2) => !value.includes(id2)));
5028
5497
  });
5029
5498
  }, [disabledRef]);
5030
5499
  const timeoutId = useRef(null);
@@ -5342,7 +5811,7 @@ function useSensorSetup(sensors) {
5342
5811
  })
5343
5812
  );
5344
5813
  }
5345
- function useSyntheticListeners(listeners, id) {
5814
+ function useSyntheticListeners(listeners, id2) {
5346
5815
  return useMemo(() => {
5347
5816
  return listeners.reduce((acc, _ref) => {
5348
5817
  let {
@@ -5350,11 +5819,11 @@ function useSyntheticListeners(listeners, id) {
5350
5819
  handler
5351
5820
  } = _ref;
5352
5821
  acc[eventName] = (event) => {
5353
- handler(event, id);
5822
+ handler(event, id2);
5354
5823
  };
5355
5824
  return acc;
5356
5825
  }, {});
5357
- }, [listeners, id]);
5826
+ }, [listeners, id2]);
5358
5827
  }
5359
5828
  function useWindowRect(element) {
5360
5829
  return useMemo(() => element ? getWindowClientRect(element) : null, [element]);
@@ -5462,9 +5931,9 @@ const defaultMeasuringConfiguration = {
5462
5931
  }
5463
5932
  };
5464
5933
  class DroppableContainersMap extends Map {
5465
- get(id) {
5934
+ get(id2) {
5466
5935
  var _super$get;
5467
- return id != null ? (_super$get = super.get(id)) != null ? _super$get : void 0 : void 0;
5936
+ return id2 != null ? (_super$get = super.get(id2)) != null ? _super$get : void 0 : void 0;
5468
5937
  }
5469
5938
  toArray() {
5470
5939
  return Array.from(this.values());
@@ -5477,9 +5946,9 @@ class DroppableContainersMap extends Map {
5477
5946
  return !disabled;
5478
5947
  });
5479
5948
  }
5480
- getNodeFor(id) {
5949
+ getNodeFor(id2) {
5481
5950
  var _this$get$node$curren, _this$get;
5482
- return (_this$get$node$curren = (_this$get = this.get(id)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
5951
+ return (_this$get$node$curren = (_this$get = this.get(id2)) == null ? void 0 : _this$get.node.current) != null ? _this$get$node$curren : void 0;
5483
5952
  }
5484
5953
  }
5485
5954
  const defaultPublicContext = {
@@ -5582,10 +6051,10 @@ function reducer(state, action2) {
5582
6051
  element
5583
6052
  } = action2;
5584
6053
  const {
5585
- id
6054
+ id: id2
5586
6055
  } = element;
5587
6056
  const containers = new DroppableContainersMap(state.droppable.containers);
5588
- containers.set(id, element);
6057
+ containers.set(id2, element);
5589
6058
  return __spreadProps(__spreadValues({}, state), {
5590
6059
  droppable: __spreadProps(__spreadValues({}, state.droppable), {
5591
6060
  containers
@@ -5594,16 +6063,16 @@ function reducer(state, action2) {
5594
6063
  }
5595
6064
  case Action.SetDroppableDisabled: {
5596
6065
  const {
5597
- id,
6066
+ id: id2,
5598
6067
  key: key2,
5599
6068
  disabled
5600
6069
  } = action2;
5601
- const element = state.droppable.containers.get(id);
6070
+ const element = state.droppable.containers.get(id2);
5602
6071
  if (!element || key2 !== element.key) {
5603
6072
  return state;
5604
6073
  }
5605
6074
  const containers = new DroppableContainersMap(state.droppable.containers);
5606
- containers.set(id, __spreadProps(__spreadValues({}, element), {
6075
+ containers.set(id2, __spreadProps(__spreadValues({}, element), {
5607
6076
  disabled
5608
6077
  }));
5609
6078
  return __spreadProps(__spreadValues({}, state), {
@@ -5614,15 +6083,15 @@ function reducer(state, action2) {
5614
6083
  }
5615
6084
  case Action.UnregisterDroppable: {
5616
6085
  const {
5617
- id,
6086
+ id: id2,
5618
6087
  key: key2
5619
6088
  } = action2;
5620
- const element = state.droppable.containers.get(id);
6089
+ const element = state.droppable.containers.get(id2);
5621
6090
  if (!element || key2 !== element.key) {
5622
6091
  return state;
5623
6092
  }
5624
6093
  const containers = new DroppableContainersMap(state.droppable.containers);
5625
- containers.delete(id);
6094
+ containers.delete(id2);
5626
6095
  return __spreadProps(__spreadValues({}, state), {
5627
6096
  droppable: __spreadProps(__spreadValues({}, state.droppable), {
5628
6097
  containers
@@ -5767,7 +6236,7 @@ var Status;
5767
6236
  const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
5768
6237
  var _sensorContext$curren, _dragOverlay$nodeRef$, _dragOverlay$rect, _over$rect;
5769
6238
  let _a = _ref, {
5770
- id,
6239
+ id: id2,
5771
6240
  accessibility,
5772
6241
  autoScroll = true,
5773
6242
  children,
@@ -5788,8 +6257,8 @@ const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
5788
6257
  const store = useReducer(reducer, void 0, getInitialState);
5789
6258
  const [state, dispatch] = store;
5790
6259
  const [dispatchMonitorEvent, registerMonitorListener] = useDndMonitorProvider();
5791
- const [status, setStatus] = useState(Status.Uninitialized);
5792
- const isInitialized = status === Status.Initialized;
6260
+ const [status2, setStatus] = useState(Status.Uninitialized);
6261
+ const isInitialized = status2 === Status.Initialized;
5793
6262
  const {
5794
6263
  draggable: {
5795
6264
  active: activeId,
@@ -5818,7 +6287,7 @@ const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
5818
6287
  const [activeSensor, setActiveSensor] = useState(null);
5819
6288
  const [activatorEvent, setActivatorEvent] = useState(null);
5820
6289
  const latestProps = useLatestValue(props, Object.values(props));
5821
- const draggableDescribedById = useUniqueId("DndDescribedBy", id);
6290
+ const draggableDescribedById = useUniqueId("DndDescribedBy", id2);
5822
6291
  const enabledDroppableContainers = useMemo(() => droppableContainers.getEnabled(), [droppableContainers]);
5823
6292
  const measuringConfiguration = useMeasuringConfiguration(measuring);
5824
6293
  const {
@@ -5926,11 +6395,11 @@ const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
5926
6395
  // otherwise they are frozen in time with the stale arguments
5927
6396
  context: sensorContext,
5928
6397
  onStart(initialCoordinates) {
5929
- const id2 = activeRef.current;
5930
- if (id2 == null) {
6398
+ const id3 = activeRef.current;
6399
+ if (id3 == null) {
5931
6400
  return;
5932
6401
  }
5933
- const draggableNode = draggableNodes.get(id2);
6402
+ const draggableNode = draggableNodes.get(id3);
5934
6403
  if (!draggableNode) {
5935
6404
  return;
5936
6405
  }
@@ -5939,7 +6408,7 @@ const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
5939
6408
  } = latestProps.current;
5940
6409
  const event2 = {
5941
6410
  active: {
5942
- id: id2,
6411
+ id: id3,
5943
6412
  data: draggableNode.data,
5944
6413
  rect: activeRects
5945
6414
  }
@@ -5950,7 +6419,7 @@ const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
5950
6419
  dispatch({
5951
6420
  type: Action.DragStart,
5952
6421
  initialCoordinates,
5953
- active: id2
6422
+ active: id3
5954
6423
  });
5955
6424
  dispatchMonitorEvent({
5956
6425
  type: "onDragStart",
@@ -6053,10 +6522,10 @@ const DndContext = /* @__PURE__ */ memo(function DndContext2(_ref) {
6053
6522
  const activators = useCombineActivators(sensors, bindActivatorToSensorInstantiator);
6054
6523
  useSensorSetup(sensors);
6055
6524
  useIsomorphicLayoutEffect(() => {
6056
- if (activeNodeRect && status === Status.Initializing) {
6525
+ if (activeNodeRect && status2 === Status.Initializing) {
6057
6526
  setStatus(Status.Initialized);
6058
6527
  }
6059
- }, [activeNodeRect, status]);
6528
+ }, [activeNodeRect, status2]);
6060
6529
  useEffect(
6061
6530
  () => {
6062
6531
  const {
@@ -6234,7 +6703,7 @@ const defaultRole = "button";
6234
6703
  const ID_PREFIX$1 = "Droppable";
6235
6704
  function useDraggable(_ref) {
6236
6705
  let {
6237
- id,
6706
+ id: id2,
6238
6707
  data,
6239
6708
  disabled = false,
6240
6709
  attributes
@@ -6254,30 +6723,30 @@ function useDraggable(_ref) {
6254
6723
  roleDescription = "draggable",
6255
6724
  tabIndex = 0
6256
6725
  } = attributes != null ? attributes : {};
6257
- const isDragging = (active == null ? void 0 : active.id) === id;
6726
+ const isDragging = (active == null ? void 0 : active.id) === id2;
6258
6727
  const transform = useContext(isDragging ? ActiveDraggableContext : NullContext);
6259
6728
  const [node, setNodeRef] = useNodeRef();
6260
6729
  const [activatorNode, setActivatorNodeRef] = useNodeRef();
6261
- const listeners = useSyntheticListeners(activators, id);
6730
+ const listeners = useSyntheticListeners(activators, id2);
6262
6731
  const dataRef = useLatestValue(data);
6263
6732
  useIsomorphicLayoutEffect(
6264
6733
  () => {
6265
- draggableNodes.set(id, {
6266
- id,
6734
+ draggableNodes.set(id2, {
6735
+ id: id2,
6267
6736
  key: key2,
6268
6737
  node,
6269
6738
  activatorNode,
6270
6739
  data: dataRef
6271
6740
  });
6272
6741
  return () => {
6273
- const node2 = draggableNodes.get(id);
6742
+ const node2 = draggableNodes.get(id2);
6274
6743
  if (node2 && node2.key === key2) {
6275
- draggableNodes.delete(id);
6744
+ draggableNodes.delete(id2);
6276
6745
  }
6277
6746
  };
6278
6747
  },
6279
6748
  // eslint-disable-next-line react-hooks/exhaustive-deps
6280
- [draggableNodes, id]
6749
+ [draggableNodes, id2]
6281
6750
  );
6282
6751
  const memoizedAttributes = useMemo(() => ({
6283
6752
  role,
@@ -6312,7 +6781,7 @@ function useDroppable(_ref) {
6312
6781
  let {
6313
6782
  data,
6314
6783
  disabled = false,
6315
- id,
6784
+ id: id2,
6316
6785
  resizeObserverConfig
6317
6786
  } = _ref;
6318
6787
  const key2 = useUniqueId(ID_PREFIX$1$1);
@@ -6333,7 +6802,7 @@ function useDroppable(_ref) {
6333
6802
  updateMeasurementsFor,
6334
6803
  timeout: resizeObserverTimeout
6335
6804
  } = __spreadValues(__spreadValues({}, defaultResizeObserverConfig), resizeObserverConfig);
6336
- const ids2 = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id);
6805
+ const ids2 = useLatestValue(updateMeasurementsFor != null ? updateMeasurementsFor : id2);
6337
6806
  const handleResize = useCallback(
6338
6807
  () => {
6339
6808
  if (!resizeObserverConnected.current) {
@@ -6382,7 +6851,7 @@ function useDroppable(_ref) {
6382
6851
  dispatch({
6383
6852
  type: Action.RegisterDroppable,
6384
6853
  element: {
6385
- id,
6854
+ id: id2,
6386
6855
  key: key2,
6387
6856
  disabled,
6388
6857
  node: nodeRef,
@@ -6393,27 +6862,27 @@ function useDroppable(_ref) {
6393
6862
  return () => dispatch({
6394
6863
  type: Action.UnregisterDroppable,
6395
6864
  key: key2,
6396
- id
6865
+ id: id2
6397
6866
  });
6398
6867
  },
6399
6868
  // eslint-disable-next-line react-hooks/exhaustive-deps
6400
- [id]
6869
+ [id2]
6401
6870
  );
6402
6871
  useEffect(() => {
6403
6872
  if (disabled !== previous.current.disabled) {
6404
6873
  dispatch({
6405
6874
  type: Action.SetDroppableDisabled,
6406
- id,
6875
+ id: id2,
6407
6876
  key: key2,
6408
6877
  disabled
6409
6878
  });
6410
6879
  previous.current.disabled = disabled;
6411
6880
  }
6412
- }, [id, key2, disabled, dispatch]);
6881
+ }, [id2, key2, disabled, dispatch]);
6413
6882
  return {
6414
6883
  active,
6415
6884
  rect,
6416
- isOver: (over == null ? void 0 : over.id) === id,
6885
+ isOver: (over == null ? void 0 : over.id) === id2,
6417
6886
  node: nodeRef,
6418
6887
  over,
6419
6888
  setNodeRef
@@ -6435,12 +6904,12 @@ function AnimationManager(_ref) {
6435
6904
  return;
6436
6905
  }
6437
6906
  const key2 = clonedChildren == null ? void 0 : clonedChildren.key;
6438
- const id = clonedChildren == null ? void 0 : clonedChildren.props.id;
6439
- if (key2 == null || id == null) {
6907
+ const id2 = clonedChildren == null ? void 0 : clonedChildren.props.id;
6908
+ if (key2 == null || id2 == null) {
6440
6909
  setClonedChildren(null);
6441
6910
  return;
6442
6911
  }
6443
- Promise.resolve(animation(id, element)).then(() => {
6912
+ Promise.resolve(animation(id2, element)).then(() => {
6444
6913
  setClonedChildren(null);
6445
6914
  });
6446
6915
  }, [animation, clonedChildren, element]);
@@ -6580,11 +7049,11 @@ function useDropAnimation(_ref3) {
6580
7049
  droppableContainers,
6581
7050
  measuringConfiguration
6582
7051
  } = _ref3;
6583
- return useEvent((id, node) => {
7052
+ return useEvent((id2, node) => {
6584
7053
  if (config === null) {
6585
7054
  return;
6586
7055
  }
6587
- const activeDraggable = draggableNodes.get(id);
7056
+ const activeDraggable = draggableNodes.get(id2);
6588
7057
  if (!activeDraggable) {
6589
7058
  return;
6590
7059
  }
@@ -6607,7 +7076,7 @@ function useDropAnimation(_ref3) {
6607
7076
  scrollIntoViewIfNeeded(activeNode, measuringConfiguration.draggable.measure);
6608
7077
  return animation({
6609
7078
  active: {
6610
- id,
7079
+ id: id2,
6611
7080
  data: activeDraggable.data,
6612
7081
  node: activeNode,
6613
7082
  rect: measuringConfiguration.draggable.measure(activeNode)
@@ -6686,14 +7155,14 @@ function createDefaultDropAnimation(options2) {
6686
7155
  };
6687
7156
  }
6688
7157
  let key = 0;
6689
- function useKey(id) {
7158
+ function useKey(id2) {
6690
7159
  return useMemo(() => {
6691
- if (id == null) {
7160
+ if (id2 == null) {
6692
7161
  return;
6693
7162
  }
6694
7163
  key++;
6695
7164
  return key;
6696
- }, [id]);
7165
+ }, [id2]);
6697
7166
  }
6698
7167
  const DragOverlay = /* @__PURE__ */ React__default.memo((_ref) => {
6699
7168
  let {
@@ -6776,8 +7245,8 @@ function arrayMove(array, from, to) {
6776
7245
  return newArray;
6777
7246
  }
6778
7247
  function getSortedRects(items, rects) {
6779
- return items.reduce((accumulator, id, index2) => {
6780
- const rect = rects.get(id);
7248
+ return items.reduce((accumulator, id2, index2) => {
7249
+ const rect = rects.get(id2);
6781
7250
  if (rect) {
6782
7251
  accumulator[index2] = rect;
6783
7252
  }
@@ -6905,7 +7374,7 @@ const Context = /* @__PURE__ */ React__default.createContext({
6905
7374
  function SortableContext(_ref) {
6906
7375
  let {
6907
7376
  children,
6908
- id,
7377
+ id: id2,
6909
7378
  items: userDefinedItems,
6910
7379
  strategy = rectSortingStrategy,
6911
7380
  disabled: disabledProp = false
@@ -6917,7 +7386,7 @@ function SortableContext(_ref) {
6917
7386
  over,
6918
7387
  measureDroppableContainers
6919
7388
  } = useDndContext();
6920
- const containerId = useUniqueId(ID_PREFIX, id);
7389
+ const containerId = useUniqueId(ID_PREFIX, id2);
6921
7390
  const useDragOverlay = Boolean(dragOverlay.rect !== null);
6922
7391
  const items = useMemo(() => userDefinedItems.map((item2) => typeof item2 === "object" && "id" in item2 ? item2.id : item2), [userDefinedItems]);
6923
7392
  const isDragging = active != null;
@@ -6956,12 +7425,12 @@ function SortableContext(_ref) {
6956
7425
  }
6957
7426
  const defaultNewIndexGetter = (_ref) => {
6958
7427
  let {
6959
- id,
7428
+ id: id2,
6960
7429
  items,
6961
7430
  activeIndex,
6962
7431
  overIndex
6963
7432
  } = _ref;
6964
- return arrayMove(items, activeIndex, overIndex).indexOf(id);
7433
+ return arrayMove(items, activeIndex, overIndex).indexOf(id2);
6965
7434
  };
6966
7435
  const defaultAnimateLayoutChanges = (_ref2) => {
6967
7436
  let {
@@ -7044,7 +7513,7 @@ function useSortable(_ref) {
7044
7513
  disabled: localDisabled,
7045
7514
  data: customData,
7046
7515
  getNewIndex = defaultNewIndexGetter,
7047
- id,
7516
+ id: id2,
7048
7517
  strategy: localStrategy,
7049
7518
  resizeObserverConfig,
7050
7519
  transition = defaultTransition
@@ -7061,7 +7530,7 @@ function useSortable(_ref) {
7061
7530
  strategy: globalStrategy
7062
7531
  } = useContext(Context);
7063
7532
  const disabled = normalizeLocalDisabled(localDisabled, globalDisabled);
7064
- const index2 = items.indexOf(id);
7533
+ const index2 = items.indexOf(id2);
7065
7534
  const data = useMemo(() => __spreadValues({
7066
7535
  sortable: {
7067
7536
  containerId,
@@ -7069,14 +7538,14 @@ function useSortable(_ref) {
7069
7538
  items
7070
7539
  }
7071
7540
  }, customData), [containerId, customData, index2, items]);
7072
- const itemsAfterCurrentSortable = useMemo(() => items.slice(items.indexOf(id)), [items, id]);
7541
+ const itemsAfterCurrentSortable = useMemo(() => items.slice(items.indexOf(id2)), [items, id2]);
7073
7542
  const {
7074
7543
  rect,
7075
7544
  node,
7076
7545
  isOver,
7077
7546
  setNodeRef: setDroppableNodeRef
7078
7547
  } = useDroppable({
7079
- id,
7548
+ id: id2,
7080
7549
  data,
7081
7550
  disabled: disabled.droppable,
7082
7551
  resizeObserverConfig: __spreadValues({
@@ -7095,7 +7564,7 @@ function useSortable(_ref) {
7095
7564
  setActivatorNodeRef,
7096
7565
  transform
7097
7566
  } = useDraggable({
7098
- id,
7567
+ id: id2,
7099
7568
  data,
7100
7569
  attributes: __spreadValues(__spreadValues({}, defaultAttributes$1), userDefinedAttributes),
7101
7570
  disabled: disabled.draggable
@@ -7114,7 +7583,7 @@ function useSortable(_ref) {
7114
7583
  index: index2
7115
7584
  }) : null;
7116
7585
  const newIndex = isValidIndex(activeIndex) && isValidIndex(overIndex) ? getNewIndex({
7117
- id,
7586
+ id: id2,
7118
7587
  items,
7119
7588
  activeIndex,
7120
7589
  overIndex
@@ -7132,7 +7601,7 @@ function useSortable(_ref) {
7132
7601
  containerId,
7133
7602
  isDragging,
7134
7603
  isSorting,
7135
- id,
7604
+ id: id2,
7136
7605
  index: index2,
7137
7606
  items,
7138
7607
  newIndex: previous.current.newIndex,
@@ -7239,7 +7708,7 @@ const action = "_action_7uv5l_56";
7239
7708
  const itemTitle = "_itemTitle_7uv5l_73";
7240
7709
  const itemCollapse = "_itemCollapse_7uv5l_79";
7241
7710
  const itemChildren = "_itemChildren_7uv5l_100";
7242
- const styles$6 = {
7711
+ const styles$7 = {
7243
7712
  item: item$2,
7244
7713
  itemContent,
7245
7714
  itemActions,
@@ -7347,8 +7816,8 @@ function ElementList({
7347
7816
  setActiveId("");
7348
7817
  setIsLayerItemDragging(false);
7349
7818
  };
7350
- const getComponentById = (id) => {
7351
- return components2.find((component) => component.id === id);
7819
+ const getComponentById = (id2) => {
7820
+ return components2.find((component) => component.id === id2);
7352
7821
  };
7353
7822
  const isDraggingLevel = components2.some((block) => activeId === block.id);
7354
7823
  return /* @__PURE__ */ React__default.createElement("div", { ref: contentRef }, /* @__PURE__ */ React__default.createElement(
@@ -7431,7 +7900,7 @@ function SortableComponentItem({
7431
7900
  const isVoid = BlockManager.getBlockByType(component.block.type).void;
7432
7901
  const hasBlockChildren = !isVoid && component.block.children.every((child) => NodeUtils.isBlockElement(child));
7433
7902
  const hideWhenDragging = isDraggingLevel && !isCurrentDragging;
7434
- return /* @__PURE__ */ React__default.createElement("div", { ref: setNodeRef, style, className: styles$6.sortableItem }, /* @__PURE__ */ React__default.createElement(
7903
+ return /* @__PURE__ */ React__default.createElement("div", { ref: setNodeRef, style, className: styles$7.sortableItem }, /* @__PURE__ */ React__default.createElement(
7435
7904
  ComponentItem,
7436
7905
  {
7437
7906
  component,
@@ -7441,7 +7910,7 @@ function SortableComponentItem({
7441
7910
  onToggleCollapse,
7442
7911
  dragHandleProps: __spreadValues(__spreadValues({}, attributes), listeners)
7443
7912
  }
7444
- ), hasBlockChildren && !isCollapsed && !isDragging && !hideWhenDragging && /* @__PURE__ */ React__default.createElement("div", { className: styles$6.itemChildren }, /* @__PURE__ */ React__default.createElement(
7913
+ ), hasBlockChildren && !isCollapsed && !isDragging && !hideWhenDragging && /* @__PURE__ */ React__default.createElement("div", { className: styles$7.itemChildren }, /* @__PURE__ */ React__default.createElement(
7445
7914
  ElementList,
7446
7915
  {
7447
7916
  blocks: component.block.children,
@@ -7545,11 +8014,11 @@ function ComponentItem({
7545
8014
  setHoverNodePath(null);
7546
8015
  };
7547
8016
  const itemClassName = useMemo(() => {
7548
- const classes = [styles$6.item];
8017
+ const classes = [styles$7.item];
7549
8018
  if (isHovered)
7550
- classes.push(styles$6.itemHovered);
8019
+ classes.push(styles$7.itemHovered);
7551
8020
  if (isSelected)
7552
- classes.push(styles$6.itemSelected);
8021
+ classes.push(styles$7.itemSelected);
7553
8022
  return classes.join(" ");
7554
8023
  }, [isHovered, isSelected]);
7555
8024
  return /* @__PURE__ */ React__default.createElement(
@@ -7560,10 +8029,10 @@ function ComponentItem({
7560
8029
  onMouseEnter: handleMouseEnter,
7561
8030
  onMouseLeave: handleMouseLeave
7562
8031
  },
7563
- /* @__PURE__ */ React__default.createElement("div", { className: styles$6.itemContent }, /* @__PURE__ */ React__default.createElement("div", { className: styles$6.itemTitle }, /* @__PURE__ */ React__default.createElement(
8032
+ /* @__PURE__ */ React__default.createElement("div", { className: styles$7.itemContent }, /* @__PURE__ */ React__default.createElement("div", { className: styles$7.itemTitle }, /* @__PURE__ */ React__default.createElement(
7564
8033
  "div",
7565
8034
  {
7566
- className: styles$6.itemCollapse,
8035
+ className: styles$7.itemCollapse,
7567
8036
  style: { opacity: hasBlockChildren ? 1 : 0 },
7568
8037
  onClick: handleCollapseClick
7569
8038
  },
@@ -7577,28 +8046,28 @@ function ComponentItem({
7577
8046
  },
7578
8047
  collapseIcon
7579
8048
  )
7580
- ), /* @__PURE__ */ React__default.createElement("div", { className: styles$6.itemLabelWrapper }, /* @__PURE__ */ React__default.createElement(
8049
+ ), /* @__PURE__ */ React__default.createElement("div", { className: styles$7.itemLabelWrapper }, /* @__PURE__ */ React__default.createElement(
7581
8050
  SharedComponents.ElementIcon,
7582
8051
  {
7583
8052
  type: component.block.type,
7584
8053
  width: 16,
7585
8054
  height: 16
7586
8055
  }
7587
- ), /* @__PURE__ */ React__default.createElement("div", { className: styles$6.itemLabel }, displayLabel))), /* @__PURE__ */ React__default.createElement(
8056
+ ), /* @__PURE__ */ React__default.createElement("div", { className: styles$7.itemLabel }, displayLabel))), /* @__PURE__ */ React__default.createElement(
7588
8057
  "div",
7589
8058
  {
7590
- className: styles$6.itemActions,
8059
+ className: styles$7.itemActions,
7591
8060
  onClick: (e) => e.stopPropagation()
7592
8061
  },
7593
- /* @__PURE__ */ React__default.createElement("div", { className: styles$6.action, onClick: onCopy }, /* @__PURE__ */ React__default.createElement(IconCopy, null)),
7594
- /* @__PURE__ */ React__default.createElement("div", { className: styles$6.action, onClick: onRemove }, /* @__PURE__ */ React__default.createElement(IconDelete, null)),
8062
+ /* @__PURE__ */ React__default.createElement("div", { className: styles$7.action, onClick: onCopy }, /* @__PURE__ */ React__default.createElement(IconCopy, null)),
8063
+ /* @__PURE__ */ React__default.createElement("div", { className: styles$7.action, onClick: onRemove }, /* @__PURE__ */ React__default.createElement(IconDelete, null)),
7595
8064
  /* @__PURE__ */ React__default.createElement(
7596
8065
  "div",
7597
8066
  __spreadValues({
7598
8067
  style: {
7599
8068
  cursor: "grab"
7600
8069
  },
7601
- className: styles$6.action
8070
+ className: styles$7.action
7602
8071
  }, dragHandleProps),
7603
8072
  /* @__PURE__ */ React__default.createElement("svg", { viewBox: "0 0 20 20", width: "12" }, /* @__PURE__ */ React__default.createElement("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }))
7604
8073
  )
@@ -7761,7 +8230,7 @@ function HeaderFooterItem({ element }) {
7761
8230
  return /* @__PURE__ */ React__default.createElement(
7762
8231
  "div",
7763
8232
  {
7764
- className: styles$6.item,
8233
+ className: styles$7.item,
7765
8234
  onClick,
7766
8235
  onMouseEnter: handleMouseEnter,
7767
8236
  onMouseLeave: handleMouseLeave,
@@ -7777,28 +8246,28 @@ function HeaderFooterItem({ element }) {
7777
8246
  /* @__PURE__ */ React__default.createElement(
7778
8247
  "div",
7779
8248
  {
7780
- className: styles$6.itemContent,
8249
+ className: styles$7.itemContent,
7781
8250
  style: {
7782
8251
  backgroundColor: "transparent",
7783
8252
  padding: "8px 10px"
7784
8253
  }
7785
8254
  },
7786
- /* @__PURE__ */ React__default.createElement("div", { className: styles$6.itemTitle }, /* @__PURE__ */ React__default.createElement("div", { className: styles$6.itemLabelWrapper }, /* @__PURE__ */ React__default.createElement(
8255
+ /* @__PURE__ */ React__default.createElement("div", { className: styles$7.itemTitle }, /* @__PURE__ */ React__default.createElement("div", { className: styles$7.itemLabelWrapper }, /* @__PURE__ */ React__default.createElement(
7787
8256
  SharedComponents.ElementIcon,
7788
8257
  {
7789
8258
  type: element.type,
7790
8259
  width: 16,
7791
8260
  height: 16
7792
8261
  }
7793
- ), /* @__PURE__ */ React__default.createElement("div", { className: styles$6.itemLabel }, label))),
8262
+ ), /* @__PURE__ */ React__default.createElement("div", { className: styles$7.itemLabel }, label))),
7794
8263
  /* @__PURE__ */ React__default.createElement(
7795
8264
  "div",
7796
8265
  {
7797
- className: styles$6.itemActions,
8266
+ className: styles$7.itemActions,
7798
8267
  style: { opacity: 1 },
7799
8268
  onClick: (e) => e.stopPropagation()
7800
8269
  },
7801
- /* @__PURE__ */ React__default.createElement("div", { className: styles$6.action }, /* @__PURE__ */ React__default.createElement(
8270
+ /* @__PURE__ */ React__default.createElement("div", { className: styles$7.action }, /* @__PURE__ */ React__default.createElement(
7802
8271
  "svg",
7803
8272
  {
7804
8273
  viewBox: "0 0 1024 1024",
@@ -7821,6 +8290,7 @@ const BlockSideBar = ({ height }) => {
7821
8290
  const { selectedNode } = useSelectedNode();
7822
8291
  const [activeTab, setActiveTab] = useState("Content");
7823
8292
  const lastActiveTab = useRef(activeTab);
8293
+ const AiAgent = SharedComponents.AiAgent;
7824
8294
  useEffect(() => {
7825
8295
  if (activeTab === "Style" && !selectedNodePath) {
7826
8296
  setSelectedNodePath([0]);
@@ -7930,6 +8400,22 @@ const BlockSideBar = ({ height }) => {
7930
8400
  },
7931
8401
  /* @__PURE__ */ React__default.createElement(BlockLayer, null)
7932
8402
  )
8403
+ ),
8404
+ AiAgent && /* @__PURE__ */ React__default.createElement(
8405
+ Tabs.TabPane,
8406
+ {
8407
+ destroyOnHide: true,
8408
+ key: "AI-Agent",
8409
+ className: "easy-email-pro-block-sidebar-ai-agent",
8410
+ title: /* @__PURE__ */ React__default.createElement("div", { className: "easy-email-pro-block-sidebar-ai-agent-title" }, t("AI"))
8411
+ },
8412
+ /* @__PURE__ */ React__default.createElement(
8413
+ SharedComponents.FullHeightOverlayScrollbars,
8414
+ {
8415
+ height: `calc(${height} - 60px)`
8416
+ },
8417
+ /* @__PURE__ */ React__default.createElement(AiAgent, null)
8418
+ )
7933
8419
  )
7934
8420
  ), !compact && /* @__PURE__ */ React__default.createElement(
7935
8421
  ConfigurationDrawer,
@@ -7940,6 +8426,7 @@ const BlockSideBar = ({ height }) => {
7940
8426
  ), /* @__PURE__ */ React__default.createElement("style", null, stylesText$1));
7941
8427
  }, [
7942
8428
  activeTab,
8429
+ AiAgent,
7943
8430
  compact,
7944
8431
  height,
7945
8432
  onChange,
@@ -8501,7 +8988,7 @@ const TabHeader = (props) => {
8501
8988
  ));
8502
8989
  };
8503
8990
  const hoverUnderline = "_hoverUnderline_8d8dl_1";
8504
- const styles$5 = {
8991
+ const styles$6 = {
8505
8992
  hoverUnderline
8506
8993
  };
8507
8994
  function BlockPaths({
@@ -8563,7 +9050,7 @@ function BlockPaths({
8563
9050
  /* @__PURE__ */ React__default.createElement(
8564
9051
  "span",
8565
9052
  {
8566
- className: styles$5.hoverUnderline,
9053
+ className: styles$6.hoverUnderline,
8567
9054
  onClick: () => setSelectedNodePath(item2.path)
8568
9055
  },
8569
9056
  item2.name
@@ -9254,7 +9741,7 @@ const UniversalElementEditorDrawer = ({ children }) => {
9254
9741
  ]);
9255
9742
  };
9256
9743
  const imageMap = /* @__PURE__ */ new Map();
9257
- function getImageDimensions(urls) {
9744
+ function getImageDimensions$1(urls) {
9258
9745
  return __async(this, null, function* () {
9259
9746
  const result = {};
9260
9747
  const list = Array.isArray(urls) ? urls : [];
@@ -9293,7 +9780,7 @@ const useAmpImageDimensions = () => {
9293
9780
  const fetchImageDimensions = useCallback((urls) => __async(void 0, null, function* () {
9294
9781
  setInited(false);
9295
9782
  try {
9296
- const dimensions = yield getImageDimensions(urls);
9783
+ const dimensions = yield getImageDimensions$1(urls);
9297
9784
  setImageDimensions(dimensions);
9298
9785
  setInited(true);
9299
9786
  } catch (error2) {
@@ -9484,7 +9971,7 @@ var defaultAttributes = {
9484
9971
  * This source code is licensed under the ISC license.
9485
9972
  * See the LICENSE file in the root directory of this source tree.
9486
9973
  */
9487
- const Icon = forwardRef(
9974
+ const Icon$1 = forwardRef(
9488
9975
  (_a, ref) => {
9489
9976
  var _b = _a, {
9490
9977
  color: color2 = "currentColor",
@@ -9531,7 +10018,7 @@ const createLucideIcon = (iconName, iconNode) => {
9531
10018
  const Component2 = forwardRef(
9532
10019
  (_a, ref) => {
9533
10020
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
9534
- return createElement(Icon, __spreadValues({
10021
+ return createElement(Icon$1, __spreadValues({
9535
10022
  ref,
9536
10023
  iconNode,
9537
10024
  className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className)
@@ -9547,43 +10034,55 @@ const createLucideIcon = (iconName, iconNode) => {
9547
10034
  * This source code is licensed under the ISC license.
9548
10035
  * See the LICENSE file in the root directory of this source tree.
9549
10036
  */
9550
- const __iconNode$o = [
10037
+ const __iconNode$q = [
9551
10038
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
9552
10039
  ["polyline", { points: "12 6 12 12 16 14", key: "68esgv" }]
9553
10040
  ];
9554
- const Clock = createLucideIcon("Clock", __iconNode$o);
10041
+ const Clock = createLucideIcon("Clock", __iconNode$q);
9555
10042
  /**
9556
10043
  * @license lucide-react v0.483.0 - ISC
9557
10044
  *
9558
10045
  * This source code is licensed under the ISC license.
9559
10046
  * See the LICENSE file in the root directory of this source tree.
9560
10047
  */
9561
- const __iconNode$n = [
10048
+ const __iconNode$p = [
9562
10049
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
9563
10050
  ["path", { d: "M12 3v18", key: "108xh3" }]
9564
10051
  ];
9565
- const Columns2 = createLucideIcon("Columns2", __iconNode$n);
10052
+ const Columns2 = createLucideIcon("Columns2", __iconNode$p);
9566
10053
  /**
9567
10054
  * @license lucide-react v0.483.0 - ISC
9568
10055
  *
9569
10056
  * This source code is licensed under the ISC license.
9570
10057
  * See the LICENSE file in the root directory of this source tree.
9571
10058
  */
9572
- const __iconNode$m = [
10059
+ const __iconNode$o = [
10060
+ ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
10061
+ ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
10062
+ ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
10063
+ ];
10064
+ const Ellipsis = createLucideIcon("Ellipsis", __iconNode$o);
10065
+ /**
10066
+ * @license lucide-react v0.483.0 - ISC
10067
+ *
10068
+ * This source code is licensed under the ISC license.
10069
+ * See the LICENSE file in the root directory of this source tree.
10070
+ */
10071
+ const __iconNode$n = [
9573
10072
  ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
9574
10073
  ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
9575
10074
  ["path", { d: "M10 9H8", key: "b1mrlr" }],
9576
10075
  ["path", { d: "M16 13H8", key: "t4e002" }],
9577
10076
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
9578
10077
  ];
9579
- const FileText = createLucideIcon("FileText", __iconNode$m);
10078
+ const FileText = createLucideIcon("FileText", __iconNode$n);
9580
10079
  /**
9581
10080
  * @license lucide-react v0.483.0 - ISC
9582
10081
  *
9583
10082
  * This source code is licensed under the ISC license.
9584
10083
  * See the LICENSE file in the root directory of this source tree.
9585
10084
  */
9586
- const __iconNode$l = [
10085
+ const __iconNode$m = [
9587
10086
  ["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
9588
10087
  ["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
9589
10088
  ["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
@@ -9591,151 +10090,151 @@ const __iconNode$l = [
9591
10090
  ["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
9592
10091
  ["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
9593
10092
  ];
9594
- const GripVertical = createLucideIcon("GripVertical", __iconNode$l);
10093
+ const GripVertical = createLucideIcon("GripVertical", __iconNode$m);
9595
10094
  /**
9596
10095
  * @license lucide-react v0.483.0 - ISC
9597
10096
  *
9598
10097
  * This source code is licensed under the ISC license.
9599
10098
  * See the LICENSE file in the root directory of this source tree.
9600
10099
  */
9601
- const __iconNode$k = [
10100
+ const __iconNode$l = [
9602
10101
  ["path", { d: "M4 12h8", key: "17cfdx" }],
9603
10102
  ["path", { d: "M4 18V6", key: "1rz3zl" }],
9604
10103
  ["path", { d: "M12 18V6", key: "zqpxq5" }],
9605
10104
  ["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
9606
10105
  ];
9607
- const Heading1 = createLucideIcon("Heading1", __iconNode$k);
10106
+ const Heading1 = createLucideIcon("Heading1", __iconNode$l);
9608
10107
  /**
9609
10108
  * @license lucide-react v0.483.0 - ISC
9610
10109
  *
9611
10110
  * This source code is licensed under the ISC license.
9612
10111
  * See the LICENSE file in the root directory of this source tree.
9613
10112
  */
9614
- const __iconNode$j = [
10113
+ const __iconNode$k = [
9615
10114
  ["path", { d: "M4 12h8", key: "17cfdx" }],
9616
10115
  ["path", { d: "M4 18V6", key: "1rz3zl" }],
9617
10116
  ["path", { d: "M12 18V6", key: "zqpxq5" }],
9618
10117
  ["path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1", key: "9jr5yi" }]
9619
10118
  ];
9620
- const Heading2 = createLucideIcon("Heading2", __iconNode$j);
10119
+ const Heading2 = createLucideIcon("Heading2", __iconNode$k);
9621
10120
  /**
9622
10121
  * @license lucide-react v0.483.0 - ISC
9623
10122
  *
9624
10123
  * This source code is licensed under the ISC license.
9625
10124
  * See the LICENSE file in the root directory of this source tree.
9626
10125
  */
9627
- const __iconNode$i = [
10126
+ const __iconNode$j = [
9628
10127
  ["path", { d: "M4 12h8", key: "17cfdx" }],
9629
10128
  ["path", { d: "M4 18V6", key: "1rz3zl" }],
9630
10129
  ["path", { d: "M12 18V6", key: "zqpxq5" }],
9631
10130
  ["path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2", key: "68ncm8" }],
9632
10131
  ["path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2", key: "1ejuhz" }]
9633
10132
  ];
9634
- const Heading3 = createLucideIcon("Heading3", __iconNode$i);
10133
+ const Heading3 = createLucideIcon("Heading3", __iconNode$j);
9635
10134
  /**
9636
10135
  * @license lucide-react v0.483.0 - ISC
9637
10136
  *
9638
10137
  * This source code is licensed under the ISC license.
9639
10138
  * See the LICENSE file in the root directory of this source tree.
9640
10139
  */
9641
- const __iconNode$h = [
10140
+ const __iconNode$i = [
9642
10141
  ["path", { d: "M12 18V6", key: "zqpxq5" }],
9643
10142
  ["path", { d: "M17 10v3a1 1 0 0 0 1 1h3", key: "tj5zdr" }],
9644
10143
  ["path", { d: "M21 10v8", key: "1kdml4" }],
9645
10144
  ["path", { d: "M4 12h8", key: "17cfdx" }],
9646
10145
  ["path", { d: "M4 18V6", key: "1rz3zl" }]
9647
10146
  ];
9648
- const Heading4 = createLucideIcon("Heading4", __iconNode$h);
10147
+ const Heading4 = createLucideIcon("Heading4", __iconNode$i);
9649
10148
  /**
9650
10149
  * @license lucide-react v0.483.0 - ISC
9651
10150
  *
9652
10151
  * This source code is licensed under the ISC license.
9653
10152
  * See the LICENSE file in the root directory of this source tree.
9654
10153
  */
9655
- const __iconNode$g = [
10154
+ const __iconNode$h = [
9656
10155
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
9657
10156
  ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
9658
10157
  ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
9659
10158
  ];
9660
- const Image$5 = createLucideIcon("Image", __iconNode$g);
10159
+ const Image$5 = createLucideIcon("Image", __iconNode$h);
9661
10160
  /**
9662
10161
  * @license lucide-react v0.483.0 - ISC
9663
10162
  *
9664
10163
  * This source code is licensed under the ISC license.
9665
10164
  * See the LICENSE file in the root directory of this source tree.
9666
10165
  */
9667
- const __iconNode$f = [
10166
+ const __iconNode$g = [
9668
10167
  ["rect", { width: "20", height: "20", x: "2", y: "2", rx: "5", ry: "5", key: "2e1cvw" }],
9669
10168
  ["path", { d: "M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z", key: "9exkf1" }],
9670
10169
  ["line", { x1: "17.5", x2: "17.51", y1: "6.5", y2: "6.5", key: "r4j83e" }]
9671
10170
  ];
9672
- const Instagram = createLucideIcon("Instagram", __iconNode$f);
10171
+ const Instagram = createLucideIcon("Instagram", __iconNode$g);
9673
10172
  /**
9674
10173
  * @license lucide-react v0.483.0 - ISC
9675
10174
  *
9676
10175
  * This source code is licensed under the ISC license.
9677
10176
  * See the LICENSE file in the root directory of this source tree.
9678
10177
  */
9679
- const __iconNode$e = [
10178
+ const __iconNode$f = [
9680
10179
  ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
9681
10180
  ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
9682
10181
  ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
9683
10182
  ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
9684
10183
  ];
9685
- const LayoutGrid = createLucideIcon("LayoutGrid", __iconNode$e);
10184
+ const LayoutGrid = createLucideIcon("LayoutGrid", __iconNode$f);
9686
10185
  /**
9687
10186
  * @license lucide-react v0.483.0 - ISC
9688
10187
  *
9689
10188
  * This source code is licensed under the ISC license.
9690
10189
  * See the LICENSE file in the root directory of this source tree.
9691
10190
  */
9692
- const __iconNode$d = [
10191
+ const __iconNode$e = [
9693
10192
  ["rect", { width: "18", height: "7", x: "3", y: "3", rx: "1", key: "f1a2em" }],
9694
10193
  ["rect", { width: "9", height: "7", x: "3", y: "14", rx: "1", key: "jqznyg" }],
9695
10194
  ["rect", { width: "5", height: "7", x: "16", y: "14", rx: "1", key: "q5h2i8" }]
9696
10195
  ];
9697
- const LayoutTemplate = createLucideIcon("LayoutTemplate", __iconNode$d);
10196
+ const LayoutTemplate = createLucideIcon("LayoutTemplate", __iconNode$e);
9698
10197
  /**
9699
10198
  * @license lucide-react v0.483.0 - ISC
9700
10199
  *
9701
10200
  * This source code is licensed under the ISC license.
9702
10201
  * See the LICENSE file in the root directory of this source tree.
9703
10202
  */
9704
- const __iconNode$c = [
10203
+ const __iconNode$d = [
9705
10204
  ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
9706
10205
  ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
9707
10206
  ];
9708
- const Link$2 = createLucideIcon("Link", __iconNode$c);
10207
+ const Link$2 = createLucideIcon("Link", __iconNode$d);
9709
10208
  /**
9710
10209
  * @license lucide-react v0.483.0 - ISC
9711
10210
  *
9712
10211
  * This source code is licensed under the ISC license.
9713
10212
  * See the LICENSE file in the root directory of this source tree.
9714
10213
  */
9715
- const __iconNode$b = [
10214
+ const __iconNode$c = [
9716
10215
  ["rect", { width: "20", height: "16", x: "2", y: "4", rx: "2", key: "18n3k1" }],
9717
10216
  ["path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7", key: "1ocrg3" }]
9718
10217
  ];
9719
- const Mail = createLucideIcon("Mail", __iconNode$b);
10218
+ const Mail = createLucideIcon("Mail", __iconNode$c);
9720
10219
  /**
9721
10220
  * @license lucide-react v0.483.0 - ISC
9722
10221
  *
9723
10222
  * This source code is licensed under the ISC license.
9724
10223
  * See the LICENSE file in the root directory of this source tree.
9725
10224
  */
9726
- const __iconNode$a = [
10225
+ const __iconNode$b = [
9727
10226
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
9728
10227
  ["path", { d: "M3 9h18", key: "1pudct" }],
9729
10228
  ["path", { d: "M9 21V9", key: "1oto5p" }]
9730
10229
  ];
9731
- const PanelsTopLeft = createLucideIcon("PanelsTopLeft", __iconNode$a);
10230
+ const PanelsTopLeft = createLucideIcon("PanelsTopLeft", __iconNode$b);
9732
10231
  /**
9733
10232
  * @license lucide-react v0.483.0 - ISC
9734
10233
  *
9735
10234
  * This source code is licensed under the ISC license.
9736
10235
  * See the LICENSE file in the root directory of this source tree.
9737
10236
  */
9738
- const __iconNode$9 = [
10237
+ const __iconNode$a = [
9739
10238
  ["rect", { width: "5", height: "5", x: "3", y: "3", rx: "1", key: "1tu5fj" }],
9740
10239
  ["rect", { width: "5", height: "5", x: "16", y: "3", rx: "1", key: "1v8r4q" }],
9741
10240
  ["rect", { width: "5", height: "5", x: "3", y: "16", rx: "1", key: "1x03jg" }],
@@ -9749,7 +10248,18 @@ const __iconNode$9 = [
9749
10248
  ["path", { d: "M21 12v.01", key: "1lwtk9" }],
9750
10249
  ["path", { d: "M12 21v-1", key: "1880an" }]
9751
10250
  ];
9752
- const QrCode = createLucideIcon("QrCode", __iconNode$9);
10251
+ const QrCode = createLucideIcon("QrCode", __iconNode$a);
10252
+ /**
10253
+ * @license lucide-react v0.483.0 - ISC
10254
+ *
10255
+ * This source code is licensed under the ISC license.
10256
+ * See the LICENSE file in the root directory of this source tree.
10257
+ */
10258
+ const __iconNode$9 = [
10259
+ ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
10260
+ ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
10261
+ ];
10262
+ const RotateCcw = createLucideIcon("RotateCcw", __iconNode$9);
9753
10263
  /**
9754
10264
  * @license lucide-react v0.483.0 - ISC
9755
10265
  *
@@ -10319,8 +10829,8 @@ var OverlayScrollbars$1 = { exports: {} };
10319
10829
  * Gets the CancelAnimationFrame method or it's corresponding polyfill.
10320
10830
  * @returns {*|Function} The CancelAnimationFrame method or it's corresponding polyfill.
10321
10831
  */
10322
- cAF: bind2(VENDORS._jsAPI, 0, "cancelAnimationFrame", false, function(id) {
10323
- return window2.clearTimeout(id);
10832
+ cAF: bind2(VENDORS._jsAPI, 0, "cancelAnimationFrame", false, function(id2) {
10833
+ return window2.clearTimeout(id2);
10324
10834
  }),
10325
10835
  /**
10326
10836
  * Gets the current time.
@@ -15286,11 +15796,13 @@ function mergeHostClassNames(osInstance, className) {
15286
15796
  host.className = `${osClassNames} ${className || ""}`;
15287
15797
  }
15288
15798
  }
15289
- const FullHeightOverlayScrollbars = (props) => {
15799
+ const FullHeightOverlayScrollbars = React__default.forwardRef((props, ref) => {
15290
15800
  const Com = OverlayScrollbarsComponent;
15291
15801
  return /* @__PURE__ */ React__default.createElement(
15292
15802
  Com,
15293
15803
  {
15804
+ ref,
15805
+ className: props.className,
15294
15806
  options: { scrollbars: { autoHide: "scroll" } },
15295
15807
  style: {
15296
15808
  maxHeight: get(props, "maxHeight"),
@@ -15299,7 +15811,8 @@ const FullHeightOverlayScrollbars = (props) => {
15299
15811
  },
15300
15812
  props.children
15301
15813
  );
15302
- };
15814
+ });
15815
+ FullHeightOverlayScrollbars.displayName = "FullHeightOverlayScrollbars";
15303
15816
  const HoveringToolbar$1 = "";
15304
15817
  const getElementPageLayout = (params) => {
15305
15818
  const { edge = 20 } = params;
@@ -20385,9 +20898,9 @@ class InterceptorManager {
20385
20898
  *
20386
20899
  * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
20387
20900
  */
20388
- eject(id) {
20389
- if (this.handlers[id]) {
20390
- this.handlers[id] = null;
20901
+ eject(id2) {
20902
+ if (this.handlers[id2]) {
20903
+ this.handlers[id2] = null;
20391
20904
  }
20392
20905
  }
20393
20906
  /**
@@ -20603,8 +21116,8 @@ const defaults = {
20603
21116
  FormData: platform.classes.FormData,
20604
21117
  Blob: platform.classes.Blob
20605
21118
  },
20606
- validateStatus: function validateStatus(status) {
20607
- return status >= 200 && status < 300;
21119
+ validateStatus: function validateStatus(status2) {
21120
+ return status2 >= 200 && status2 < 300;
20608
21121
  },
20609
21122
  headers: {
20610
21123
  common: {
@@ -21222,22 +21735,22 @@ const adapters = {
21222
21735
  const rejectedReasons = {};
21223
21736
  for (let i = 0; i < length2; i++) {
21224
21737
  nameOrAdapter = adapters2[i];
21225
- let id;
21738
+ let id2;
21226
21739
  adapter = nameOrAdapter;
21227
21740
  if (!isResolvedHandle(nameOrAdapter)) {
21228
- adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
21741
+ adapter = knownAdapters[(id2 = String(nameOrAdapter)).toLowerCase()];
21229
21742
  if (adapter === void 0) {
21230
- throw new AxiosError(`Unknown adapter '${id}'`);
21743
+ throw new AxiosError(`Unknown adapter '${id2}'`);
21231
21744
  }
21232
21745
  }
21233
21746
  if (adapter) {
21234
21747
  break;
21235
21748
  }
21236
- rejectedReasons[id || "#" + i] = adapter;
21749
+ rejectedReasons[id2 || "#" + i] = adapter;
21237
21750
  }
21238
21751
  if (!adapter) {
21239
21752
  const reasons = Object.entries(rejectedReasons).map(
21240
- ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
21753
+ ([id2, state]) => `adapter ${id2} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
21241
21754
  );
21242
21755
  let s = length2 ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
21243
21756
  throw new AxiosError(
@@ -22594,9 +23107,9 @@ function requireOutlayer() {
22594
23107
  }
22595
23108
  this.options = utils2.extend({}, this.constructor.defaults);
22596
23109
  this.option(options2);
22597
- var id = ++GUID;
22598
- this.element.outlayerGUID = id;
22599
- instances[id] = this;
23110
+ var id2 = ++GUID;
23111
+ this.element.outlayerGUID = id2;
23112
+ instances[id2] = this;
22600
23113
  this._create();
22601
23114
  var isInitLayout = this._getOption("initLayout");
22602
23115
  if (isInitLayout) {
@@ -23010,8 +23523,8 @@ function requireOutlayer() {
23010
23523
  item2.destroy();
23011
23524
  });
23012
23525
  this.unbindResize();
23013
- var id = this.element.outlayerGUID;
23014
- delete instances[id];
23526
+ var id2 = this.element.outlayerGUID;
23527
+ delete instances[id2];
23015
23528
  delete this.element.outlayerGUID;
23016
23529
  if (jQuery) {
23017
23530
  jQuery.removeData(this.element, this.constructor.namespace);
@@ -23019,8 +23532,8 @@ function requireOutlayer() {
23019
23532
  };
23020
23533
  Outlayer.data = function(elem) {
23021
23534
  elem = utils2.getQueryElement(elem);
23022
- var id = elem && elem.outlayerGUID;
23023
- return id && instances[id];
23535
+ var id2 = elem && elem.outlayerGUID;
23536
+ return id2 && instances[id2];
23024
23537
  };
23025
23538
  Outlayer.create = function(namespace, options2) {
23026
23539
  var Layout2 = subclass(Outlayer);
@@ -23993,18 +24506,18 @@ var elementUtils = function(options2) {
23993
24506
  var listenerHandler = function(idHandler2) {
23994
24507
  var eventListeners = {};
23995
24508
  function getListeners(element) {
23996
- var id = idHandler2.get(element);
23997
- if (id === void 0) {
24509
+ var id2 = idHandler2.get(element);
24510
+ if (id2 === void 0) {
23998
24511
  return [];
23999
24512
  }
24000
- return eventListeners[id] || [];
24513
+ return eventListeners[id2] || [];
24001
24514
  }
24002
24515
  function addListener(element, listener) {
24003
- var id = idHandler2.get(element);
24004
- if (!eventListeners[id]) {
24005
- eventListeners[id] = [];
24516
+ var id2 = idHandler2.get(element);
24517
+ if (!eventListeners[id2]) {
24518
+ eventListeners[id2] = [];
24006
24519
  }
24007
- eventListeners[id].push(listener);
24520
+ eventListeners[id2].push(listener);
24008
24521
  }
24009
24522
  function removeListener(element, listener) {
24010
24523
  var listeners = getListeners(element);
@@ -24053,9 +24566,9 @@ var idHandler = function(options2) {
24053
24566
  if (!state) {
24054
24567
  throw new Error("setId required the element to have a resize detection state.");
24055
24568
  }
24056
- var id = idGenerator2.generate();
24057
- state.id = id;
24058
- return id;
24569
+ var id2 = idGenerator2.generate();
24570
+ state.id = id2;
24571
+ return id2;
24059
24572
  }
24060
24573
  return {
24061
24574
  get: getId,
@@ -25003,15 +25516,15 @@ var elementResizeDetector = function(options2) {
25003
25516
  stateHandler.initState(element);
25004
25517
  idHandler2.set(element);
25005
25518
  }
25006
- var id = idHandler2.get(element);
25007
- debug && reporter2.log("Attaching listener to element", id, element);
25519
+ var id2 = idHandler2.get(element);
25520
+ debug && reporter2.log("Attaching listener to element", id2, element);
25008
25521
  if (!elementUtils2.isDetectable(element)) {
25009
- debug && reporter2.log(id, "Not detectable.");
25522
+ debug && reporter2.log(id2, "Not detectable.");
25010
25523
  if (elementUtils2.isBusy(element)) {
25011
- debug && reporter2.log(id, "System busy making it detectable");
25524
+ debug && reporter2.log(id2, "System busy making it detectable");
25012
25525
  addListener(callOnAdd, element, listener);
25013
- onReadyCallbacks[id] = onReadyCallbacks[id] || [];
25014
- onReadyCallbacks[id].push(function onReady() {
25526
+ onReadyCallbacks[id2] = onReadyCallbacks[id2] || [];
25527
+ onReadyCallbacks[id2].push(function onReady() {
25015
25528
  elementsReady++;
25016
25529
  if (elementsReady === elements2.length) {
25017
25530
  onReadyCallback();
@@ -25019,10 +25532,10 @@ var elementResizeDetector = function(options2) {
25019
25532
  });
25020
25533
  return;
25021
25534
  }
25022
- debug && reporter2.log(id, "Making detectable...");
25535
+ debug && reporter2.log(id2, "Making detectable...");
25023
25536
  elementUtils2.markBusy(element, true);
25024
25537
  return detectionStrategy.makeDetectable({ debug, important: importantCssRules }, element, function onElementDetectable(element2) {
25025
- debug && reporter2.log(id, "onElementDetectable");
25538
+ debug && reporter2.log(id2, "onElementDetectable");
25026
25539
  if (stateHandler.getState(element2)) {
25027
25540
  elementUtils2.markAsDetectable(element2);
25028
25541
  elementUtils2.markBusy(element2, false);
@@ -25036,22 +25549,22 @@ var elementResizeDetector = function(options2) {
25036
25549
  onResizeCallback(element2);
25037
25550
  }
25038
25551
  }
25039
- if (onReadyCallbacks[id]) {
25040
- forEach(onReadyCallbacks[id], function(callback) {
25552
+ if (onReadyCallbacks[id2]) {
25553
+ forEach(onReadyCallbacks[id2], function(callback) {
25041
25554
  callback();
25042
25555
  });
25043
25556
  }
25044
25557
  } else {
25045
- debug && reporter2.log(id, "Element uninstalled before being detectable.");
25558
+ debug && reporter2.log(id2, "Element uninstalled before being detectable.");
25046
25559
  }
25047
- delete onReadyCallbacks[id];
25560
+ delete onReadyCallbacks[id2];
25048
25561
  elementsReady++;
25049
25562
  if (elementsReady === elements2.length) {
25050
25563
  onReadyCallback();
25051
25564
  }
25052
25565
  });
25053
25566
  }
25054
- debug && reporter2.log(id, "Already detecable, adding listener.");
25567
+ debug && reporter2.log(id2, "Already detecable, adding listener.");
25055
25568
  addListener(callOnAdd, element, listener);
25056
25569
  elementsReady++;
25057
25570
  });
@@ -28921,12 +29434,12 @@ function EditPanelList(props) {
28921
29434
  const [activeId, setActiveId] = useState(null);
28922
29435
  const [activeItem, setActiveItem] = useState(null);
28923
29436
  const getItemId = useCallback((item2) => {
28924
- let id = get(item2, "id") || idMap.get(item2);
28925
- if (!id) {
28926
- id = +(/* @__PURE__ */ new Date()).getTime().toString() + "-" + uniqueId();
28927
- idMap.set(item2, id);
29437
+ let id2 = get(item2, "id") || idMap.get(item2);
29438
+ if (!id2) {
29439
+ id2 = +(/* @__PURE__ */ new Date()).getTime().toString() + "-" + uniqueId();
29440
+ idMap.set(item2, id2);
28928
29441
  }
28929
- return id;
29442
+ return id2;
28930
29443
  }, []);
28931
29444
  const itemIds = useMemo(() => {
28932
29445
  return Array.isArray(value) ? value.map(getItemId) : [];
@@ -29101,7 +29614,7 @@ function EditPanelList(props) {
29101
29614
  }
29102
29615
  const SortableItem = (_e) => {
29103
29616
  var _f = _e, {
29104
- id,
29617
+ id: id2,
29105
29618
  index: index2,
29106
29619
  item: item2,
29107
29620
  onAdd,
@@ -29121,7 +29634,7 @@ const SortableItem = (_e) => {
29121
29634
  transition,
29122
29635
  isDragging
29123
29636
  } = useSortable({
29124
- id
29637
+ id: id2
29125
29638
  });
29126
29639
  const style = {
29127
29640
  transform: CSS.Transform.toString(transform),
@@ -29211,7 +29724,7 @@ const cardItemLeft = "_cardItemLeft_8uw8m_71";
29211
29724
  const cardItemRight = "_cardItemRight_8uw8m_85";
29212
29725
  const selectImage = "_selectImage_8uw8m_93";
29213
29726
  const exportFreeImage = "_exportFreeImage_8uw8m_110";
29214
- const styles$4 = {
29727
+ const styles$5 = {
29215
29728
  container,
29216
29729
  error,
29217
29730
  item,
@@ -29426,7 +29939,7 @@ function ImageUploader(props) {
29426
29939
  );
29427
29940
  const content2 = useMemo(() => {
29428
29941
  if (isUploading) {
29429
- return /* @__PURE__ */ React__default.createElement("div", { className: styles$4["item"] }, /* @__PURE__ */ React__default.createElement("div", { className: classnames$1(styles$4["info"]) }, /* @__PURE__ */ React__default.createElement(Spin, { size: 60 }), /* @__PURE__ */ React__default.createElement("div", { className: styles$4["btn-wrap"] })));
29942
+ return /* @__PURE__ */ React__default.createElement("div", { className: styles$5["item"] }, /* @__PURE__ */ React__default.createElement("div", { className: classnames$1(styles$5["info"]) }, /* @__PURE__ */ React__default.createElement(Spin, { size: 60 }), /* @__PURE__ */ React__default.createElement("div", { className: styles$5["btn-wrap"] })));
29430
29943
  }
29431
29944
  if (!props.value) {
29432
29945
  return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(
@@ -29447,10 +29960,10 @@ function ImageUploader(props) {
29447
29960
  lineHeight: "22px"
29448
29961
  }
29449
29962
  },
29450
- unsplashClientId ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: styles$4.selectImage, onClick: onUpload }, t("Select image")), /* @__PURE__ */ React__default.createElement(
29963
+ unsplashClientId ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("div", { className: styles$5.selectImage, onClick: onUpload }, t("Select image")), /* @__PURE__ */ React__default.createElement(
29451
29964
  "div",
29452
29965
  {
29453
- className: styles$4.exportFreeImage,
29966
+ className: styles$5.exportFreeImage,
29454
29967
  onClick: () => {
29455
29968
  setUnsplashVisible(true);
29456
29969
  setLock(true);
@@ -29504,7 +30017,7 @@ function ImageUploader(props) {
29504
30017
  triggerProps: {
29505
30018
  popupStyle: { display: "inline-flex" }
29506
30019
  },
29507
- triggerElement: /* @__PURE__ */ React__default.createElement("span", { className: styles$4.actionItem }, t("Replace"))
30020
+ triggerElement: /* @__PURE__ */ React__default.createElement("span", { className: styles$5.actionItem }, t("Replace"))
29508
30021
  },
29509
30022
  /* @__PURE__ */ React__default.createElement(Select$1.Option, { value: "1", onClick: onUpload }, t("Select image")),
29510
30023
  /* @__PURE__ */ React__default.createElement(
@@ -29518,10 +30031,10 @@ function ImageUploader(props) {
29518
30031
  },
29519
30032
  t("Export free images")
29520
30033
  )
29521
- ) : /* @__PURE__ */ React__default.createElement("span", { className: styles$4.actionItem, onClick: onUpload }, t("Replace")), enablePreview && /* @__PURE__ */ React__default.createElement("span", null, " ∙ "), enablePreview && /* @__PURE__ */ React__default.createElement(
30034
+ ) : /* @__PURE__ */ React__default.createElement("span", { className: styles$5.actionItem, onClick: onUpload }, t("Replace")), enablePreview && /* @__PURE__ */ React__default.createElement("span", null, " ∙ "), enablePreview && /* @__PURE__ */ React__default.createElement(
29522
30035
  "span",
29523
30036
  {
29524
- className: styles$4.actionItem,
30037
+ className: styles$5.actionItem,
29525
30038
  onClick: () => setPreview(true)
29526
30039
  },
29527
30040
  t("Preview")
@@ -30117,7 +30630,7 @@ const positionControl = "_positionControl_1t3ne_44";
30117
30630
  const percentSign = "_percentSign_1t3ne_50";
30118
30631
  const deleteButton = "_deleteButton_1t3ne_55";
30119
30632
  const sizeInputs = "_sizeInputs_1t3ne_62";
30120
- const styles$3 = {
30633
+ const styles$4 = {
30121
30634
  controlSection,
30122
30635
  controlGroup,
30123
30636
  colorHeader,
@@ -30531,7 +31044,7 @@ function GradientGenerator(props) {
30531
31044
  )
30532
31045
  ))
30533
31046
  }
30534
- ), /* @__PURE__ */ React__default.createElement("div", { className: styles$3.controlSection }, /* @__PURE__ */ React__default.createElement("div", { className: styles$3.controlGroup }, /* @__PURE__ */ React__default.createElement(
31047
+ ), /* @__PURE__ */ React__default.createElement("div", { className: styles$4.controlSection }, /* @__PURE__ */ React__default.createElement("div", { className: styles$4.controlGroup }, /* @__PURE__ */ React__default.createElement(
30535
31048
  Form.Item,
30536
31049
  {
30537
31050
  label: /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(
@@ -30616,7 +31129,7 @@ function GradientGenerator(props) {
30616
31129
  )
30617
31130
  )))
30618
31131
  )
30619
- )), /* @__PURE__ */ React__default.createElement(Divider$2, { style: { margin: "0px 0 10px 0" } }), /* @__PURE__ */ React__default.createElement("div", { className: styles$3.controlGroup }, /* @__PURE__ */ React__default.createElement(Form.Item, { label: t(`Gradient Type`), layout: "vertical" }, /* @__PURE__ */ React__default.createElement(
31132
+ )), /* @__PURE__ */ React__default.createElement(Divider$2, { style: { margin: "0px 0 10px 0" } }), /* @__PURE__ */ React__default.createElement("div", { className: styles$4.controlGroup }, /* @__PURE__ */ React__default.createElement(Form.Item, { label: t(`Gradient Type`), layout: "vertical" }, /* @__PURE__ */ React__default.createElement(
30620
31133
  Select$1,
30621
31134
  {
30622
31135
  style: { width: "100%" },
@@ -30637,7 +31150,7 @@ function GradientGenerator(props) {
30637
31150
  }));
30638
31151
  }
30639
31152
  }
30640
- ))), /* @__PURE__ */ React__default.createElement("div", { className: styles$3.controlGroup }, /* @__PURE__ */ React__default.createElement(Grid.Row, null, /* @__PURE__ */ React__default.createElement(Grid.Col, { span: 11 }, /* @__PURE__ */ React__default.createElement(Form.Item, { label: t(`Width`), layout: "vertical" }, /* @__PURE__ */ React__default.createElement(
31153
+ ))), /* @__PURE__ */ React__default.createElement("div", { className: styles$4.controlGroup }, /* @__PURE__ */ React__default.createElement(Grid.Row, null, /* @__PURE__ */ React__default.createElement(Grid.Col, { span: 11 }, /* @__PURE__ */ React__default.createElement(Form.Item, { label: t(`Width`), layout: "vertical" }, /* @__PURE__ */ React__default.createElement(
30641
31154
  InputNumber,
30642
31155
  {
30643
31156
  style: { width: "100%" },
@@ -30655,7 +31168,7 @@ function GradientGenerator(props) {
30655
31168
  setData(__spreadProps(__spreadValues({}, data), { height: value }));
30656
31169
  }
30657
31170
  }
30658
- ))))), /* @__PURE__ */ React__default.createElement(Divider$2, null), data.type === "linear" && /* @__PURE__ */ React__default.createElement("div", { className: styles$3.controlGroup }, /* @__PURE__ */ React__default.createElement(Form.Item, { label: t(`Angle`), layout: "vertical" }, /* @__PURE__ */ React__default.createElement(
31171
+ ))))), /* @__PURE__ */ React__default.createElement(Divider$2, null), data.type === "linear" && /* @__PURE__ */ React__default.createElement("div", { className: styles$4.controlGroup }, /* @__PURE__ */ React__default.createElement(Form.Item, { label: t(`Angle`), layout: "vertical" }, /* @__PURE__ */ React__default.createElement(
30659
31172
  Slider,
30660
31173
  {
30661
31174
  value: data.angle,
@@ -30668,7 +31181,7 @@ function GradientGenerator(props) {
30668
31181
  step: 1,
30669
31182
  showInput: true
30670
31183
  }
30671
- ))), /* @__PURE__ */ React__default.createElement(Divider$2, null), /* @__PURE__ */ React__default.createElement("div", { className: styles$3.controlGroup }, /* @__PURE__ */ React__default.createElement("div", { className: styles$3.colorHeader }, /* @__PURE__ */ React__default.createElement("div", { className: styles$3.label }, t(`Colors`), " (", colors.length, "/", MAX_COLORS, ")"), /* @__PURE__ */ React__default.createElement(
31184
+ ))), /* @__PURE__ */ React__default.createElement(Divider$2, null), /* @__PURE__ */ React__default.createElement("div", { className: styles$4.controlGroup }, /* @__PURE__ */ React__default.createElement("div", { className: styles$4.colorHeader }, /* @__PURE__ */ React__default.createElement("div", { className: styles$4.label }, t(`Colors`), " (", colors.length, "/", MAX_COLORS, ")"), /* @__PURE__ */ React__default.createElement(
30672
31185
  Button$2,
30673
31186
  {
30674
31187
  type: "text",
@@ -30678,7 +31191,7 @@ function GradientGenerator(props) {
30678
31191
  disabled: colors.length >= MAX_COLORS
30679
31192
  },
30680
31193
  t(`Add Color`)
30681
- )), /* @__PURE__ */ React__default.createElement("div", { className: styles$3.colorList }, colors.map((color2, index2) => /* @__PURE__ */ React__default.createElement("div", { key: color2.id, className: styles$3.colorItem }, /* @__PURE__ */ React__default.createElement("div", { className: styles$3.colorInputs }, /* @__PURE__ */ React__default.createElement(
31194
+ )), /* @__PURE__ */ React__default.createElement("div", { className: styles$4.colorList }, colors.map((color2, index2) => /* @__PURE__ */ React__default.createElement("div", { key: color2.id, className: styles$4.colorItem }, /* @__PURE__ */ React__default.createElement("div", { className: styles$4.colorInputs }, /* @__PURE__ */ React__default.createElement(
30682
31195
  ColorPicker$1,
30683
31196
  {
30684
31197
  value: color2.color,
@@ -30690,7 +31203,7 @@ function GradientGenerator(props) {
30690
31203
  }));
30691
31204
  }
30692
31205
  }
30693
- )), /* @__PURE__ */ React__default.createElement("div", { className: styles$3.positionControl }, /* @__PURE__ */ React__default.createElement(
31206
+ )), /* @__PURE__ */ React__default.createElement("div", { className: styles$4.positionControl }, /* @__PURE__ */ React__default.createElement(
30694
31207
  InputNumber,
30695
31208
  {
30696
31209
  value: color2.position,
@@ -30705,13 +31218,13 @@ function GradientGenerator(props) {
30705
31218
  min: 0,
30706
31219
  max: 100
30707
31220
  }
30708
- ), /* @__PURE__ */ React__default.createElement("span", { className: styles$3.percentSign }, "%"), colors.length > MIN_COLORS && /* @__PURE__ */ React__default.createElement(
31221
+ ), /* @__PURE__ */ React__default.createElement("span", { className: styles$4.percentSign }, "%"), colors.length > MIN_COLORS && /* @__PURE__ */ React__default.createElement(
30709
31222
  Button$2,
30710
31223
  {
30711
31224
  type: "text",
30712
31225
  icon: /* @__PURE__ */ React__default.createElement(IconDelete, null),
30713
31226
  onClick: () => removeColor(index2),
30714
- className: styles$3.deleteButton
31227
+ className: styles$4.deleteButton
30715
31228
  }
30716
31229
  )))))))),
30717
31230
  /* @__PURE__ */ React__default.createElement("canvas", { ref: canvasRef, style: { display: "none" } })
@@ -36218,7 +36731,7 @@ const ConfigurationSideBar = ({ height }) => {
36218
36731
  ));
36219
36732
  };
36220
36733
  const largeTabsHeader = "_largeTabsHeader_d2sio_1";
36221
- const styles$2 = {
36734
+ const styles$3 = {
36222
36735
  largeTabsHeader
36223
36736
  };
36224
36737
  function AddItems(props) {
@@ -36427,12 +36940,12 @@ function WidgetConfigPanel({
36427
36940
  );
36428
36941
  const items = useMemo(() => {
36429
36942
  return widgetElement.data.config.map((item2, index2) => {
36430
- let id = idsMap.current.get(item2);
36431
- if (!id) {
36432
- id = nanoid();
36433
- idsMap.current.set(item2, id);
36943
+ let id2 = idsMap.current.get(item2);
36944
+ if (!id2) {
36945
+ id2 = nanoid();
36946
+ idsMap.current.set(item2, id2);
36434
36947
  }
36435
- return { id, item: item2 };
36948
+ return { id: id2, item: item2 };
36436
36949
  });
36437
36950
  }, [widgetElement.data.config]);
36438
36951
  const itemIds = useMemo(() => {
@@ -36502,7 +37015,7 @@ function WidgetConfigPanel({
36502
37015
  renderTabHeader: (_, DefaultHeader) => /* @__PURE__ */ React__default.createElement(
36503
37016
  "div",
36504
37017
  {
36505
- className: styles$2.largeTabsHeader,
37018
+ className: styles$3.largeTabsHeader,
36506
37019
  style: { display: "flex", alignItems: "center" }
36507
37020
  },
36508
37021
  /* @__PURE__ */ React__default.createElement(DefaultHeader, { style: { flex: 1 } })
@@ -40268,6 +40781,1840 @@ const StandaloneElementSaveButtonPortal = (props) => {
40268
40781
  }, [cacheProps, setStandaloneElementSaveButton]);
40269
40782
  return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);
40270
40783
  };
40784
+ const styles$2 = "";
40785
+ function copyImageUrl(attachment) {
40786
+ return __async(this, null, function* () {
40787
+ const value = attachment.url || attachment.dataUrl;
40788
+ if (!value || typeof navigator === "undefined" || !navigator.clipboard)
40789
+ return;
40790
+ yield navigator.clipboard.writeText(value);
40791
+ });
40792
+ }
40793
+ function getDefaultQuickActions() {
40794
+ return [
40795
+ {
40796
+ label: t("Optimize CTA"),
40797
+ prompt: t(
40798
+ "Improve the main button copy and visual hierarchy so the CTA is clearer without feeling too salesy."
40799
+ )
40800
+ },
40801
+ {
40802
+ label: t("Professional"),
40803
+ prompt: t(
40804
+ "Make the overall design feel more premium, reduce cheap promotion cues, and keep the brand tone polished."
40805
+ )
40806
+ },
40807
+ {
40808
+ label: t("Shorten"),
40809
+ prompt: t(
40810
+ "Shorten the current email copy, keep the core selling points, and make the tone more restrained."
40811
+ )
40812
+ },
40813
+ {
40814
+ label: t("Tone"),
40815
+ prompt: t(
40816
+ "Make the email copy sound clearer, more natural, and more aligned with a polished brand voice."
40817
+ )
40818
+ },
40819
+ {
40820
+ label: t("Improve hero"),
40821
+ prompt: t(
40822
+ "Improve the hero section: make the headline more focused, shorten the supporting copy, and make the CTA stand out."
40823
+ )
40824
+ },
40825
+ {
40826
+ label: t("Align colors"),
40827
+ prompt: t(
40828
+ "Align the brand colors and button colors, reduce visual noise, and make the email feel more cohesive."
40829
+ )
40830
+ },
40831
+ {
40832
+ label: t("Optimize products"),
40833
+ prompt: t(
40834
+ "Optimize the product section layout and text hierarchy so products are easier to browse and compare."
40835
+ )
40836
+ },
40837
+ {
40838
+ label: t("Compact mobile"),
40839
+ prompt: t(
40840
+ "Optimize the mobile layout, reduce crowding and long text, and keep the content readable."
40841
+ )
40842
+ },
40843
+ {
40844
+ label: t("Boost contrast"),
40845
+ prompt: t(
40846
+ "Improve the contrast between the background, body text, and buttons to keep the email readable."
40847
+ )
40848
+ },
40849
+ {
40850
+ label: t("Add urgency"),
40851
+ prompt: t(
40852
+ "Add more promotional energy and urgency without hurting the brand feel."
40853
+ )
40854
+ },
40855
+ {
40856
+ label: t("Softer tone"),
40857
+ prompt: t(
40858
+ "Make the visuals and copy softer, lighter, and more suitable for a lifestyle brand."
40859
+ )
40860
+ },
40861
+ {
40862
+ label: t("Translate to English"),
40863
+ prompt: t(
40864
+ "Translate the main email copy into natural English while keeping the original layout."
40865
+ )
40866
+ },
40867
+ {
40868
+ label: t("Check issues"),
40869
+ prompt: t(
40870
+ "Review the current email for copy, hierarchy, mobile, and CTA issues, then make small improvements directly."
40871
+ )
40872
+ }
40873
+ ];
40874
+ }
40875
+ function getDefaultMessages() {
40876
+ return [
40877
+ {
40878
+ id: "m1",
40879
+ role: "assistant",
40880
+ content: t(
40881
+ "Tell me how you want to change this email. I will generate edits from the current template."
40882
+ ),
40883
+ time: "10:12"
40884
+ },
40885
+ {
40886
+ id: "m2",
40887
+ role: "user",
40888
+ content: t(
40889
+ "Make the hero feel more premium, use less copy, and make the button stand out."
40890
+ ),
40891
+ time: "10:14"
40892
+ },
40893
+ {
40894
+ id: "m3",
40895
+ role: "assistant",
40896
+ content: t(
40897
+ "Sure. I recommend keeping the hero headline within two lines, reducing the supporting copy to one core selling point, and using a more direct CTA verb.\n\nI will prioritize:\n1. Headline hierarchy\n2. Button copy\n3. Hero whitespace\n4. Background and text contrast"
40898
+ ),
40899
+ time: "10:15"
40900
+ },
40901
+ {
40902
+ id: "m4",
40903
+ role: "user",
40904
+ content: t("Make the button copy less salesy and more brand-led."),
40905
+ time: "10:18"
40906
+ },
40907
+ {
40908
+ id: "m5",
40909
+ role: "assistant",
40910
+ content: t(
40911
+ 'Got it. We can change "SHOP COLLECTION" to "Explore the Edit" or "Discover New Arrivals". This copy feels more restrained and works better for a brand-led email.'
40912
+ ),
40913
+ time: "10:19"
40914
+ },
40915
+ {
40916
+ id: "m6",
40917
+ role: "user",
40918
+ content: t("Use this layout as a reference"),
40919
+ time: "10:22",
40920
+ attachments: [
40921
+ {
40922
+ id: "a1",
40923
+ type: "image",
40924
+ name: "layout-reference.png",
40925
+ url: "data:image/svg+xml;utf8," + encodeURIComponent(
40926
+ `<svg xmlns="http://www.w3.org/2000/svg" width="320" height="220" viewBox="0 0 320 220">
40927
+ <rect width="320" height="220" fill="#ffffff"/>
40928
+ <rect x="26" y="18" width="268" height="48" rx="4" fill="#064d67"/>
40929
+ <text x="160" y="47" text-anchor="middle" fill="#ffffff" font-family="Arial" font-size="16" font-weight="700">MORE PROBLEM? MORE IMAGE!</text>
40930
+ <rect x="44" y="84" width="72" height="54" rx="6" fill="#f3fafc" stroke="#90c7d3"/>
40931
+ <path d="M62 124h38M68 114l12-16 13 20 8-11 13 17" fill="none" stroke="#1685a0" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
40932
+ <rect x="132" y="84" width="142" height="9" rx="4" fill="#1f2937"/>
40933
+ <rect x="132" y="101" width="114" height="7" rx="3.5" fill="#94a3b8"/>
40934
+ <rect x="132" y="115" width="126" height="7" rx="3.5" fill="#cbd5e1"/>
40935
+ <rect x="132" y="130" width="82" height="7" rx="3.5" fill="#0f7490"/>
40936
+ <circle cx="80" cy="176" r="30" fill="#f3fafc" stroke="#90c7d3" stroke-width="3"/>
40937
+ <circle cx="80" cy="176" r="17" fill="none" stroke="#1685a0" stroke-width="4"/>
40938
+ <path d="M80 176l31-25" stroke="#ef4444" stroke-width="4" stroke-linecap="round"/>
40939
+ <rect x="132" y="154" width="142" height="9" rx="4" fill="#1f2937"/>
40940
+ <rect x="132" y="171" width="118" height="7" rx="3.5" fill="#94a3b8"/>
40941
+ <rect x="132" y="185" width="132" height="7" rx="3.5" fill="#cbd5e1"/>
40942
+ <rect x="132" y="200" width="82" height="7" rx="3.5" fill="#0f7490"/>
40943
+ </svg>`
40944
+ )
40945
+ }
40946
+ ]
40947
+ },
40948
+ {
40949
+ id: "m7",
40950
+ role: "assistant",
40951
+ content: t(
40952
+ "We can use this structure: keep a strong visual headline area at the top, then use icon plus short-copy groups below. When applying it to the email, I will control each text group so mobile does not feel crowded."
40953
+ ),
40954
+ time: "10:23"
40955
+ },
40956
+ {
40957
+ id: "m8",
40958
+ role: "assistant",
40959
+ content: t(
40960
+ "You can keep giving me more specific directions, such as:\n\nMore modern, softer, stronger promotion, highlight new arrivals, highlight discounts, or make mobile more compact."
40961
+ ),
40962
+ time: "10:24"
40963
+ }
40964
+ ];
40965
+ }
40966
+ function classNames(...names) {
40967
+ return names.filter(Boolean).join(" ");
40968
+ }
40969
+ function sourceTitle(source) {
40970
+ try {
40971
+ return source.title || new URL(source.url).hostname;
40972
+ } catch (e) {
40973
+ return source.title || source.url;
40974
+ }
40975
+ }
40976
+ function quickActionLabel(action2) {
40977
+ return typeof action2 === "string" ? action2 : action2.label;
40978
+ }
40979
+ function quickActionPrompt(action2) {
40980
+ return typeof action2 === "string" ? action2 : action2.prompt;
40981
+ }
40982
+ function fileToAttachment(file) {
40983
+ return new Promise((resolve, reject) => {
40984
+ const reader = new FileReader();
40985
+ reader.onload = () => {
40986
+ resolve({
40987
+ id: `local-${Date.now()}-${Math.random().toString(16).slice(2)}`,
40988
+ type: "image",
40989
+ name: file.name,
40990
+ url: String(reader.result || ""),
40991
+ dataUrl: String(reader.result || ""),
40992
+ mimeType: file.type,
40993
+ size: file.size
40994
+ });
40995
+ };
40996
+ reader.onerror = () => reject(reader.error || new Error("image_read_failed"));
40997
+ reader.readAsDataURL(file);
40998
+ });
40999
+ }
41000
+ function extensionForMime(mimeType) {
41001
+ if (mimeType === "image/jpeg")
41002
+ return "jpg";
41003
+ if (mimeType === "image/webp")
41004
+ return "webp";
41005
+ if (mimeType === "image/gif")
41006
+ return "gif";
41007
+ return "png";
41008
+ }
41009
+ function normalizePastedImage(file, index2) {
41010
+ if (file.name)
41011
+ return file;
41012
+ return new File([file], `pasted-image-${Date.now()}-${index2 + 1}.${extensionForMime(file.type)}`, {
41013
+ type: file.type || "image/png",
41014
+ lastModified: Date.now()
41015
+ });
41016
+ }
41017
+ function imageFilesFromClipboard(event) {
41018
+ const itemFiles = Array.from(event.clipboardData.items || []).filter((item2) => item2.kind === "file" && item2.type.startsWith("image/")).map((item2) => item2.getAsFile()).filter(Boolean);
41019
+ const dataFiles = Array.from(event.clipboardData.files || []).filter(
41020
+ (file) => file.type.startsWith("image/")
41021
+ );
41022
+ const files = itemFiles.length ? itemFiles : dataFiles;
41023
+ return files.map(normalizePastedImage);
41024
+ }
41025
+ function stripUploadStatus(attachment) {
41026
+ const _a = attachment, { uploadStatus } = _a, readyAttachment = __objRest(_a, ["uploadStatus"]);
41027
+ return readyAttachment;
41028
+ }
41029
+ function decisionResponseFromChoice(decision, choice) {
41030
+ return {
41031
+ decisionId: decision.id,
41032
+ choiceId: choice.id,
41033
+ label: choice.label,
41034
+ value: choice.value
41035
+ };
41036
+ }
41037
+ function Icon({
41038
+ name,
41039
+ className
41040
+ }) {
41041
+ const common = {
41042
+ className,
41043
+ width: 16,
41044
+ height: 16,
41045
+ viewBox: "0 0 24 24",
41046
+ fill: "none",
41047
+ stroke: "currentColor",
41048
+ strokeWidth: 2,
41049
+ strokeLinecap: "round",
41050
+ strokeLinejoin: "round",
41051
+ "aria-hidden": true
41052
+ };
41053
+ if (name === "attach") {
41054
+ return /* @__PURE__ */ React__default.createElement("svg", __spreadValues({}, common), /* @__PURE__ */ React__default.createElement("path", { d: "M12 5v14" }), /* @__PURE__ */ React__default.createElement("path", { d: "M5 12h14" }));
41055
+ }
41056
+ return /* @__PURE__ */ React__default.createElement("svg", __spreadValues({}, common), /* @__PURE__ */ React__default.createElement("path", { d: "M12 19V5" }), /* @__PURE__ */ React__default.createElement("path", { d: "m5 12 7-7 7 7" }));
41057
+ }
41058
+ function EasyEmailProAiAgent({
41059
+ className,
41060
+ messages = getDefaultMessages(),
41061
+ activity,
41062
+ disabled = false,
41063
+ sendDisabled = false,
41064
+ quickActions = getDefaultQuickActions(),
41065
+ pendingAction,
41066
+ pendingDecision,
41067
+ placeholder = t("Tell AI how you want to change this email..."),
41068
+ onSend,
41069
+ onUpload,
41070
+ onChooseDecision,
41071
+ onCancelDecision,
41072
+ onRestoreSnapshot,
41073
+ onQuickAction
41074
+ }) {
41075
+ var _a;
41076
+ assertAiAgentFeatureEnabled();
41077
+ const [draft, setDraft] = useState("");
41078
+ const [attachments, setAttachments] = useState([]);
41079
+ const [uploading, setUploading] = useState(false);
41080
+ const [uploadError, setUploadError] = useState("");
41081
+ const [previewAttachment, setPreviewAttachment] = useState(null);
41082
+ const [quickActionsExpanded, setQuickActionsExpanded] = useState(false);
41083
+ const [decisionDraft, setDecisionDraft] = useState("");
41084
+ const [copiedAttachmentId, setCopiedAttachmentId] = useState(null);
41085
+ const inputRef = useRef(null);
41086
+ const textareaRef = useRef(null);
41087
+ const scrollbarsRef = useRef(null);
41088
+ const visibleQuickActions = quickActions.slice(0, 2);
41089
+ const menuQuickActions = quickActions.slice(2);
41090
+ const hasMenuQuickActions = menuQuickActions.length > 0;
41091
+ const activityState = status === "running" || /applying|updating|generating|connecting|sending|uploading|reading|analyzing|preparing|processing|正在|读取|分析|准备|处理中|更新中|生成中|上传中/i.test(activity || "") ? "working" : /not applied|failed|error|失败|未应用/i.test(activity || "") ? "warning" : /updated|applied|generated|ready|完成|已更新|已应用|已生成/i.test(activity || "") ? "success" : "idle";
41092
+ const visibleActivity = activityState === "success" ? "" : activity;
41093
+ const lastSuccessfulAssistantMessageId = activityState === "success" ? (_a = [...messages].reverse().find((message) => message.role === "assistant" && message.status !== "error")) == null ? void 0 : _a.id : null;
41094
+ function scrollThreadToBottom() {
41095
+ const scroll2 = () => {
41096
+ var _a2, _b;
41097
+ const container2 = (_b = (_a2 = scrollbarsRef.current) == null ? void 0 : _a2.osInstance()) == null ? void 0 : _b.getElements().viewport;
41098
+ if (!container2)
41099
+ return;
41100
+ container2.scrollTop = container2.scrollHeight;
41101
+ };
41102
+ scroll2();
41103
+ requestAnimationFrame(() => {
41104
+ scroll2();
41105
+ requestAnimationFrame(scroll2);
41106
+ });
41107
+ }
41108
+ function copyAttachment(attachment) {
41109
+ return __async(this, null, function* () {
41110
+ yield copyImageUrl(attachment);
41111
+ setCopiedAttachmentId(attachment.id);
41112
+ window.setTimeout(() => {
41113
+ setCopiedAttachmentId((current) => current === attachment.id ? null : current);
41114
+ }, 1200);
41115
+ });
41116
+ }
41117
+ useLayoutEffect(() => {
41118
+ scrollThreadToBottom();
41119
+ }, [
41120
+ activity,
41121
+ attachments.length,
41122
+ lastSuccessfulAssistantMessageId,
41123
+ messages,
41124
+ pendingDecision,
41125
+ uploadError
41126
+ ]);
41127
+ useEffect(() => {
41128
+ setDecisionDraft("");
41129
+ }, [pendingDecision == null ? void 0 : pendingDecision.id]);
41130
+ useEffect(() => {
41131
+ const textarea = textareaRef.current;
41132
+ if (!textarea)
41133
+ return;
41134
+ textarea.style.height = "auto";
41135
+ const maxHeight = Number.parseFloat(getComputedStyle(textarea).maxHeight);
41136
+ const nextHeight = Number.isFinite(maxHeight) ? Math.min(textarea.scrollHeight, maxHeight) : textarea.scrollHeight;
41137
+ textarea.style.height = `${nextHeight}px`;
41138
+ textarea.style.overflowY = Number.isFinite(maxHeight) && textarea.scrollHeight > maxHeight ? "auto" : "hidden";
41139
+ }, [draft, placeholder]);
41140
+ function submit() {
41141
+ return __async(this, null, function* () {
41142
+ const value = draft.trim();
41143
+ if (!value && !attachments.length || disabled || sendDisabled || uploading)
41144
+ return;
41145
+ const readyAttachments = attachments.map(stripUploadStatus);
41146
+ const previousDraft = draft;
41147
+ const previousAttachments = attachments;
41148
+ setDraft("");
41149
+ setAttachments([]);
41150
+ setUploadError("");
41151
+ scrollThreadToBottom();
41152
+ try {
41153
+ yield onSend == null ? void 0 : onSend(value || t("Use this image as a reference"), readyAttachments);
41154
+ } catch (error2) {
41155
+ setDraft(previousDraft);
41156
+ setAttachments(previousAttachments);
41157
+ setUploadError(error2 instanceof Error ? error2.message : t("Send failed"));
41158
+ }
41159
+ });
41160
+ }
41161
+ function runQuickAction(action2) {
41162
+ return __async(this, null, function* () {
41163
+ if (disabled || sendDisabled || uploading)
41164
+ return;
41165
+ const prompt = quickActionPrompt(action2);
41166
+ if (!prompt.trim())
41167
+ return;
41168
+ setUploadError("");
41169
+ setQuickActionsExpanded(false);
41170
+ if (onQuickAction) {
41171
+ yield onQuickAction(prompt);
41172
+ return;
41173
+ }
41174
+ const readyAttachments = attachments.map(stripUploadStatus);
41175
+ setDraft("");
41176
+ setAttachments([]);
41177
+ scrollThreadToBottom();
41178
+ yield onSend == null ? void 0 : onSend(prompt, readyAttachments);
41179
+ });
41180
+ }
41181
+ function uploadImageFiles(files) {
41182
+ return __async(this, null, function* () {
41183
+ if (!files.length || disabled || uploading)
41184
+ return;
41185
+ try {
41186
+ const imageFiles = files.filter((file) => file.type.startsWith("image/"));
41187
+ if (!imageFiles.length)
41188
+ return;
41189
+ setUploading(true);
41190
+ setUploadError("");
41191
+ const pendingAttachments = yield Promise.all(
41192
+ imageFiles.map((file) => __async(this, null, function* () {
41193
+ return __spreadProps(__spreadValues({}, yield fileToAttachment(file)), {
41194
+ uploadStatus: "uploading"
41195
+ });
41196
+ }))
41197
+ );
41198
+ setAttachments((current) => [...current, ...pendingAttachments]);
41199
+ const uploaded = yield Promise.all(
41200
+ imageFiles.map(
41201
+ (file, index2) => onUpload ? onUpload(file) : Promise.resolve(pendingAttachments[index2])
41202
+ )
41203
+ );
41204
+ setAttachments(
41205
+ (current) => current.map((attachment) => {
41206
+ const uploadedIndex = pendingAttachments.findIndex(
41207
+ (pending) => pending.id === attachment.id
41208
+ );
41209
+ if (uploadedIndex === -1)
41210
+ return attachment;
41211
+ return stripUploadStatus(uploaded[uploadedIndex]);
41212
+ })
41213
+ );
41214
+ } catch (error2) {
41215
+ setAttachments(
41216
+ (current) => current.filter((attachment) => attachment.uploadStatus !== "uploading")
41217
+ );
41218
+ setUploadError(error2 instanceof Error ? error2.message : t("Image upload failed"));
41219
+ } finally {
41220
+ setUploading(false);
41221
+ if (inputRef.current)
41222
+ inputRef.current.value = "";
41223
+ }
41224
+ });
41225
+ }
41226
+ function uploadFiles(files) {
41227
+ return __async(this, null, function* () {
41228
+ yield uploadImageFiles(Array.from(files || []));
41229
+ });
41230
+ }
41231
+ function pasteImages(event) {
41232
+ const imageFiles = imageFilesFromClipboard(event);
41233
+ if (!imageFiles.length)
41234
+ return;
41235
+ event.preventDefault();
41236
+ void uploadImageFiles(imageFiles);
41237
+ }
41238
+ return /* @__PURE__ */ React__default.createElement("aside", { className: classNames("eep-ai-agent", className), "aria-label": t("AI Agent"), onPaste: pasteImages }, /* @__PURE__ */ React__default.createElement(
41239
+ FullHeightOverlayScrollbars,
41240
+ {
41241
+ ref: scrollbarsRef,
41242
+ height: "100%",
41243
+ className: "eep-ai-agent__body-scrollbar"
41244
+ },
41245
+ /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__body" }, /* @__PURE__ */ React__default.createElement("section", { className: "eep-ai-agent__thread", "aria-label": t("AI conversation") }, messages.map((message) => {
41246
+ var _a2, _b;
41247
+ return /* @__PURE__ */ React__default.createElement("article", { className: classNames("eep-ai-agent__message", `is-${message.role}`), key: message.id }, ((_a2 = message.attachments) == null ? void 0 : _a2.length) ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__attachments", "aria-label": t("Attachments") }, message.attachments.map((attachment) => /* @__PURE__ */ React__default.createElement(
41248
+ "button",
41249
+ {
41250
+ className: "eep-ai-agent__attachment",
41251
+ key: attachment.id,
41252
+ type: "button",
41253
+ onClick: () => setPreviewAttachment(attachment),
41254
+ "aria-label": `${t("View image")}: ${attachment.name}`
41255
+ },
41256
+ /* @__PURE__ */ React__default.createElement("img", { src: attachment.url, alt: attachment.name }),
41257
+ /* @__PURE__ */ React__default.createElement(
41258
+ "span",
41259
+ {
41260
+ className: "eep-ai-agent__attachment-copy",
41261
+ "aria-label": t("Copy image URL"),
41262
+ role: "button",
41263
+ tabIndex: 0,
41264
+ onClick: (event) => {
41265
+ event.stopPropagation();
41266
+ void copyAttachment(attachment);
41267
+ },
41268
+ onKeyDown: (event) => {
41269
+ if (event.key !== "Enter" && event.key !== " ")
41270
+ return;
41271
+ event.preventDefault();
41272
+ event.stopPropagation();
41273
+ void copyAttachment(attachment);
41274
+ }
41275
+ },
41276
+ copiedAttachmentId === attachment.id ? t("Copied") : "⧉"
41277
+ )
41278
+ ))) : null, /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__bubble" }, message.content), ((_b = message.sources) == null ? void 0 : _b.length) ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__sources", "aria-label": t("Sources") }, message.sources.slice(0, 3).map((source) => /* @__PURE__ */ React__default.createElement(
41279
+ "a",
41280
+ {
41281
+ href: source.url,
41282
+ key: source.url,
41283
+ target: "_blank",
41284
+ rel: "noreferrer"
41285
+ },
41286
+ sourceTitle(source)
41287
+ ))) : null, message.role === "assistant" && message.status === "ready" && message.snapshotId && onRestoreSnapshot ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__message-actions" }, /* @__PURE__ */ React__default.createElement(
41288
+ "button",
41289
+ {
41290
+ className: "eep-ai-agent__message-action",
41291
+ type: "button",
41292
+ onClick: () => message.snapshotId && void onRestoreSnapshot(message.snapshotId),
41293
+ title: t("Restore to this state")
41294
+ },
41295
+ /* @__PURE__ */ React__default.createElement(RotateCcw, { size: 12, strokeWidth: 1.75, "aria-hidden": "true" }),
41296
+ /* @__PURE__ */ React__default.createElement("span", null, t("Restore"))
41297
+ )) : null, message.id === lastSuccessfulAssistantMessageId ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__message-success" }, /* @__PURE__ */ React__default.createElement("span", { "aria-hidden": "true" }, "✓"), activity) : null);
41298
+ }), pendingDecision ? /* @__PURE__ */ React__default.createElement("article", { className: "eep-ai-agent__message is-assistant" }, /* @__PURE__ */ React__default.createElement(
41299
+ "div",
41300
+ {
41301
+ className: "eep-ai-agent__decision",
41302
+ role: "group",
41303
+ "aria-label": pendingDecision.title
41304
+ },
41305
+ pendingDecision.image ? /* @__PURE__ */ React__default.createElement(
41306
+ "button",
41307
+ {
41308
+ className: "eep-ai-agent__decision-preview",
41309
+ type: "button",
41310
+ onClick: () => pendingDecision.image && setPreviewAttachment(__spreadProps(__spreadValues({}, pendingDecision.image), {
41311
+ type: "image",
41312
+ url: pendingDecision.image.url || ""
41313
+ })),
41314
+ "aria-label": `${t("View image")}: ${pendingDecision.image.name}`
41315
+ },
41316
+ /* @__PURE__ */ React__default.createElement(
41317
+ "img",
41318
+ {
41319
+ src: pendingDecision.image.url || "",
41320
+ alt: pendingDecision.image.name
41321
+ }
41322
+ )
41323
+ ) : null,
41324
+ /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__decision-head" }, /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__decision-title" }, pendingDecision.title), /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__decision-message" }, pendingDecision.message)), pendingDecision.required ? null : /* @__PURE__ */ React__default.createElement(
41325
+ "button",
41326
+ {
41327
+ className: "eep-ai-agent__decision-cancel",
41328
+ type: "button",
41329
+ onClick: onCancelDecision
41330
+ },
41331
+ t("Cancel")
41332
+ )),
41333
+ /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__decision-choices" }, pendingDecision.choices.map((choice) => /* @__PURE__ */ React__default.createElement(
41334
+ "button",
41335
+ {
41336
+ className: "eep-ai-agent__decision-choice",
41337
+ key: choice.id,
41338
+ type: "button",
41339
+ onClick: () => {
41340
+ void (onChooseDecision == null ? void 0 : onChooseDecision(
41341
+ choice,
41342
+ decisionResponseFromChoice(pendingDecision, choice)
41343
+ ));
41344
+ }
41345
+ },
41346
+ choice.thumbnail ? /* @__PURE__ */ React__default.createElement("img", { src: choice.thumbnail, alt: "" }) : null,
41347
+ /* @__PURE__ */ React__default.createElement("span", null, /* @__PURE__ */ React__default.createElement("strong", null, choice.label), choice.description ? /* @__PURE__ */ React__default.createElement("small", null, choice.description) : null)
41348
+ ))),
41349
+ pendingDecision.allowCustom ? /* @__PURE__ */ React__default.createElement(
41350
+ "form",
41351
+ {
41352
+ className: "eep-ai-agent__decision-custom",
41353
+ onSubmit: (event) => {
41354
+ event.preventDefault();
41355
+ const value = decisionDraft.trim();
41356
+ if (!value)
41357
+ return;
41358
+ const choice = {
41359
+ id: "custom",
41360
+ label: value,
41361
+ prompt: value
41362
+ };
41363
+ void (onChooseDecision == null ? void 0 : onChooseDecision(choice, {
41364
+ decisionId: pendingDecision.id,
41365
+ choiceId: "custom",
41366
+ label: value,
41367
+ customText: value
41368
+ }));
41369
+ }
41370
+ },
41371
+ /* @__PURE__ */ React__default.createElement(
41372
+ "input",
41373
+ {
41374
+ value: decisionDraft,
41375
+ onChange: (event) => setDecisionDraft(event.target.value),
41376
+ placeholder: t("Or describe what you want...")
41377
+ }
41378
+ ),
41379
+ /* @__PURE__ */ React__default.createElement("button", { type: "submit", disabled: !decisionDraft.trim() }, t("Send"))
41380
+ ) : null
41381
+ )) : null))
41382
+ ), /* @__PURE__ */ React__default.createElement("footer", { className: "eep-ai-agent__composer-wrap" }, visibleActivity || uploadError || attachments.length || pendingAction ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__composer-meta" }, attachments.length ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__pending-attachments", "aria-label": t("Pending images") }, attachments.map((attachment) => /* @__PURE__ */ React__default.createElement(
41383
+ "button",
41384
+ {
41385
+ className: "eep-ai-agent__pending-attachment",
41386
+ key: attachment.id,
41387
+ type: "button",
41388
+ onClick: () => setPreviewAttachment(attachment),
41389
+ "aria-label": `${t("View image")}: ${attachment.name}`
41390
+ },
41391
+ /* @__PURE__ */ React__default.createElement("img", { src: attachment.url, alt: attachment.name }),
41392
+ attachment.uploadStatus === "uploading" ? /* @__PURE__ */ React__default.createElement(
41393
+ "span",
41394
+ {
41395
+ className: "eep-ai-agent__pending-attachment-loading",
41396
+ "aria-label": t("Uploading image"),
41397
+ role: "progressbar"
41398
+ }
41399
+ ) : /* @__PURE__ */ React__default.createElement(
41400
+ "span",
41401
+ {
41402
+ "aria-hidden": "true",
41403
+ onClick: (event) => {
41404
+ event.stopPropagation();
41405
+ setAttachments(
41406
+ (current) => current.filter((item2) => item2.id !== attachment.id)
41407
+ );
41408
+ }
41409
+ },
41410
+ "×"
41411
+ )
41412
+ ))) : null, visibleActivity ? /* @__PURE__ */ React__default.createElement(
41413
+ "div",
41414
+ {
41415
+ className: classNames(
41416
+ "eep-ai-agent__activity",
41417
+ activityState === "working" && "is-working",
41418
+ activityState === "success" && "is-success",
41419
+ activityState === "warning" && "is-warning"
41420
+ ),
41421
+ role: activityState === "working" ? "status" : void 0,
41422
+ "aria-live": "polite"
41423
+ },
41424
+ activityState === "working" ? /* @__PURE__ */ React__default.createElement("span", { className: "eep-ai-agent__activity-dots", "aria-hidden": "true" }, /* @__PURE__ */ React__default.createElement("span", null), /* @__PURE__ */ React__default.createElement("span", null), /* @__PURE__ */ React__default.createElement("span", null)) : activityState === "success" ? /* @__PURE__ */ React__default.createElement("span", { className: "eep-ai-agent__activity-icon", "aria-hidden": "true" }, "✓") : activityState === "warning" ? /* @__PURE__ */ React__default.createElement("span", { className: "eep-ai-agent__activity-icon", "aria-hidden": "true" }, "!") : null,
41425
+ /* @__PURE__ */ React__default.createElement("span", { className: "eep-ai-agent__activity-text" }, visibleActivity),
41426
+ activityState === "working" ? /* @__PURE__ */ React__default.createElement("span", { className: "eep-ai-agent__activity-bar", "aria-hidden": "true" }) : null
41427
+ ) : null, uploadError ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__error" }, uploadError) : null, pendingAction ? /* @__PURE__ */ React__default.createElement(
41428
+ "button",
41429
+ {
41430
+ className: "eep-ai-agent__pending-action",
41431
+ type: "button",
41432
+ disabled: disabled || pendingAction.disabled,
41433
+ onClick: () => {
41434
+ void pendingAction.onClick();
41435
+ }
41436
+ },
41437
+ pendingAction.label
41438
+ ) : null) : null, quickActions.length ? /* @__PURE__ */ React__default.createElement(
41439
+ "div",
41440
+ {
41441
+ className: classNames(
41442
+ "eep-ai-agent__quick-actions",
41443
+ quickActionsExpanded && "is-open"
41444
+ ),
41445
+ "aria-label": t("Quick actions")
41446
+ },
41447
+ quickActionsExpanded && hasMenuQuickActions ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__quick-actions-menu" }, menuQuickActions.map((action2, index2) => /* @__PURE__ */ React__default.createElement(
41448
+ "button",
41449
+ {
41450
+ className: "eep-ai-agent__quick-action-menu-item",
41451
+ key: `${quickActionLabel(action2)}-${index2}`,
41452
+ type: "button",
41453
+ disabled: disabled || sendDisabled || uploading,
41454
+ onClick: () => {
41455
+ void runQuickAction(action2);
41456
+ }
41457
+ },
41458
+ quickActionLabel(action2)
41459
+ ))) : null,
41460
+ /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__quick-actions-bar" }, visibleQuickActions.map((action2, index2) => /* @__PURE__ */ React__default.createElement(
41461
+ "button",
41462
+ {
41463
+ className: "eep-ai-agent__quick-action-pill",
41464
+ key: `${quickActionLabel(action2)}-${index2}`,
41465
+ type: "button",
41466
+ disabled: disabled || sendDisabled || uploading,
41467
+ onClick: () => {
41468
+ void runQuickAction(action2);
41469
+ }
41470
+ },
41471
+ quickActionLabel(action2)
41472
+ )), hasMenuQuickActions ? /* @__PURE__ */ React__default.createElement(
41473
+ "button",
41474
+ {
41475
+ className: "eep-ai-agent__quick-action-more",
41476
+ type: "button",
41477
+ disabled: disabled || sendDisabled || uploading,
41478
+ onClick: () => setQuickActionsExpanded((value) => !value),
41479
+ "aria-expanded": quickActionsExpanded,
41480
+ "aria-label": t("More quick actions")
41481
+ },
41482
+ /* @__PURE__ */ React__default.createElement(Ellipsis, { size: 16, strokeWidth: 2.2 })
41483
+ ) : null)
41484
+ ) : null, /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__composer" }, /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__composer-input" }, /* @__PURE__ */ React__default.createElement(
41485
+ "textarea",
41486
+ {
41487
+ ref: textareaRef,
41488
+ value: draft,
41489
+ disabled,
41490
+ placeholder,
41491
+ rows: 1,
41492
+ onChange: (event) => setDraft(event.target.value),
41493
+ onKeyDown: (event) => {
41494
+ if (event.key === "Enter" && !event.shiftKey) {
41495
+ event.preventDefault();
41496
+ submit();
41497
+ }
41498
+ }
41499
+ }
41500
+ ), /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__composer-hint" }, t("Enter to send / Shift + Enter for new line"))), /* @__PURE__ */ React__default.createElement(
41501
+ "input",
41502
+ {
41503
+ ref: inputRef,
41504
+ className: "eep-ai-agent__file-input",
41505
+ type: "file",
41506
+ accept: "image/*",
41507
+ multiple: true,
41508
+ onChange: (event) => uploadFiles(event.currentTarget.files)
41509
+ }
41510
+ ), /* @__PURE__ */ React__default.createElement(
41511
+ "button",
41512
+ {
41513
+ className: "eep-ai-agent__attach",
41514
+ type: "button",
41515
+ disabled: disabled || uploading,
41516
+ onClick: () => {
41517
+ var _a2;
41518
+ return (_a2 = inputRef.current) == null ? void 0 : _a2.click();
41519
+ },
41520
+ "aria-label": t("Add image")
41521
+ },
41522
+ /* @__PURE__ */ React__default.createElement(Icon, { name: "attach" })
41523
+ ), /* @__PURE__ */ React__default.createElement(
41524
+ "button",
41525
+ {
41526
+ className: "eep-ai-agent__send",
41527
+ type: "button",
41528
+ disabled: disabled || sendDisabled || uploading || !draft.trim() && !attachments.length,
41529
+ onClick: submit,
41530
+ "aria-label": t("Send")
41531
+ },
41532
+ /* @__PURE__ */ React__default.createElement(Icon, { name: "send" })
41533
+ ))), previewAttachment ? /* @__PURE__ */ React__default.createElement("div", { className: "eep-ai-agent__lightbox", role: "dialog", "aria-modal": "true", onClick: () => setPreviewAttachment(null) }, /* @__PURE__ */ React__default.createElement(
41534
+ "button",
41535
+ {
41536
+ className: "eep-ai-agent__lightbox-close",
41537
+ type: "button",
41538
+ onClick: () => setPreviewAttachment(null),
41539
+ "aria-label": t("Close image preview")
41540
+ },
41541
+ "×"
41542
+ ), /* @__PURE__ */ React__default.createElement("img", { src: previewAttachment.url, alt: previewAttachment.name, onClick: (event) => event.stopPropagation() })) : null);
41543
+ }
41544
+ const doneStatuses = ["FINISHED", "ERROR"];
41545
+ function getInitialConversation() {
41546
+ return [
41547
+ {
41548
+ id: "agent-welcome",
41549
+ role: "assistant",
41550
+ content: t(
41551
+ "Tell me how you want to change this email. You can also upload reference images. I will adjust the preview from the current template."
41552
+ ),
41553
+ time: formatTime()
41554
+ }
41555
+ ];
41556
+ }
41557
+ function formatTime(date = /* @__PURE__ */ new Date()) {
41558
+ return date.toLocaleTimeString([], {
41559
+ hour: "2-digit",
41560
+ minute: "2-digit",
41561
+ hour12: false
41562
+ });
41563
+ }
41564
+ function id(prefix) {
41565
+ if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
41566
+ return `${prefix}-${crypto.randomUUID()}`;
41567
+ }
41568
+ return `${prefix}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
41569
+ }
41570
+ function isoNow() {
41571
+ return (/* @__PURE__ */ new Date()).toISOString();
41572
+ }
41573
+ function friendlyActivity(text) {
41574
+ if (text.includes("image attachment"))
41575
+ return t("Reading uploaded images...");
41576
+ if (text.includes("Generating image"))
41577
+ return t("Generating image...");
41578
+ if (text.includes("Searching"))
41579
+ return t("Searching the web...");
41580
+ if (text.trim())
41581
+ return t("Understanding your request...");
41582
+ return t("Updating the email...");
41583
+ }
41584
+ function ensureError(error2) {
41585
+ const nextError = error2 instanceof Error ? error2 : new Error(String(error2));
41586
+ if (nextError.message === "Failed to fetch" || nextError.message.includes("NetworkError")) {
41587
+ return new Error(
41588
+ `${t("Cannot connect to AI Proxy")}. ${t("Check the onChat handler or your AI service endpoint.")}`
41589
+ );
41590
+ }
41591
+ return nextError;
41592
+ }
41593
+ function mapAiAttachment(attachment) {
41594
+ return {
41595
+ id: attachment.id,
41596
+ name: attachment.name,
41597
+ mimeType: attachment.mimeType || "image/png",
41598
+ dataUrl: attachment.dataUrl,
41599
+ url: attachment.url,
41600
+ size: attachment.size
41601
+ };
41602
+ }
41603
+ function mapGeneratedImageAttachment(attachment) {
41604
+ return {
41605
+ id: attachment.id,
41606
+ type: "image",
41607
+ name: attachment.name,
41608
+ url: attachment.url || "",
41609
+ mimeType: attachment.mimeType || "image/png",
41610
+ size: attachment.size
41611
+ };
41612
+ }
41613
+ function isRemoteImageUrl(url) {
41614
+ return Boolean(url && !url.startsWith("data:"));
41615
+ }
41616
+ function imageResultText(payload) {
41617
+ const lines = [payload.summary || t("Generated image.")];
41618
+ if (payload.revisedPrompt) {
41619
+ lines.push(`${t("Prompt")}: ${payload.revisedPrompt}`);
41620
+ }
41621
+ return lines.join("\n\n");
41622
+ }
41623
+ function resultText(payload) {
41624
+ if (!payload.valid) {
41625
+ return payload.errors.length ? `${t("This change did not pass validation")}:
41626
+ ${payload.errors.join("\n")}` : t("This change did not pass validation.");
41627
+ }
41628
+ if (payload.summary)
41629
+ return payload.summary;
41630
+ if (payload.template)
41631
+ return t("Updated the email preview.");
41632
+ return t("Done.");
41633
+ }
41634
+ function templateKey(template) {
41635
+ try {
41636
+ return JSON.stringify(template) || "";
41637
+ } catch (e) {
41638
+ return "";
41639
+ }
41640
+ }
41641
+ function pendingText(summary) {
41642
+ return summary ? `${summary}
41643
+
41644
+ ${t("AI changes are ready. Click the button below to apply them.")}` : t("AI changes are ready. Click the button below to apply them.");
41645
+ }
41646
+ function toolCallsText(payload, result) {
41647
+ if (payload.summary) {
41648
+ return `${t("Updated the email preview.")}
41649
+
41650
+ ${payload.summary}`;
41651
+ }
41652
+ if (result && result.applied > 0)
41653
+ return t("Updated the email preview.");
41654
+ return t("Completed local changes.");
41655
+ }
41656
+ function userFacingApplyErrors(errors) {
41657
+ return errors.filter((error2) => !/tool calls truncated/i.test(error2));
41658
+ }
41659
+ function normalizeHistory(history, initialMessages) {
41660
+ var _a;
41661
+ const messages = ((_a = history == null ? void 0 : history.messages) == null ? void 0 : _a.length) ? history.messages : (initialMessages == null ? void 0 : initialMessages.length) ? initialMessages : getInitialConversation();
41662
+ return {
41663
+ messages,
41664
+ currentSnapshotId: history == null ? void 0 : history.currentSnapshotId,
41665
+ snapshots: (history == null ? void 0 : history.snapshots) || []
41666
+ };
41667
+ }
41668
+ function snapshotTitle(reason, index2) {
41669
+ if (reason === "before-ai-run")
41670
+ return index2 <= 1 ? t("Initial") : `v${index2}`;
41671
+ return `v${index2}`;
41672
+ }
41673
+ function useAiAgentSession(options2) {
41674
+ const [historyState, setHistoryState] = useState(
41675
+ normalizeHistory(options2.history, options2.initialMessages)
41676
+ );
41677
+ const [status2, setStatus] = useState("ready");
41678
+ const [activity, setActivity] = useState("");
41679
+ const [pendingChange, setPendingChange] = useState(null);
41680
+ const [pendingDecision, setPendingDecision] = useState(null);
41681
+ const [applyingPendingChange, setApplyingPendingChange] = useState(false);
41682
+ const streamAbortRef = useRef(null);
41683
+ const activeRunRef = useRef(null);
41684
+ const optionsRef = useRef(options2);
41685
+ const historyRef = useRef(historyState);
41686
+ useEffect(() => {
41687
+ optionsRef.current = options2;
41688
+ }, [options2]);
41689
+ useEffect(() => {
41690
+ if (!options2.history)
41691
+ return;
41692
+ const nextHistory = normalizeHistory(
41693
+ options2.history,
41694
+ options2.initialMessages
41695
+ );
41696
+ historyRef.current = nextHistory;
41697
+ setHistoryState(nextHistory);
41698
+ }, [options2.history, options2.initialMessages]);
41699
+ const abortStream = useCallback(() => {
41700
+ var _a;
41701
+ (_a = streamAbortRef.current) == null ? void 0 : _a.abort();
41702
+ streamAbortRef.current = null;
41703
+ }, []);
41704
+ const commitHistory = useCallback(
41705
+ (updater, change) => {
41706
+ var _a, _b;
41707
+ const nextHistory = updater(historyRef.current);
41708
+ historyRef.current = nextHistory;
41709
+ setHistoryState(nextHistory);
41710
+ (_b = (_a = optionsRef.current).onHistoryChange) == null ? void 0 : _b.call(_a, nextHistory, change);
41711
+ return nextHistory;
41712
+ },
41713
+ []
41714
+ );
41715
+ const updateMessage = useCallback(
41716
+ (messageId, patch) => {
41717
+ commitHistory(
41718
+ (history) => __spreadProps(__spreadValues({}, history), {
41719
+ messages: history.messages.map(
41720
+ (message) => message.id === messageId ? __spreadValues(__spreadValues({}, message), patch) : message
41721
+ )
41722
+ }),
41723
+ { type: "message.updated", messageId, patch }
41724
+ );
41725
+ },
41726
+ [commitHistory]
41727
+ );
41728
+ const createSnapshot = useCallback(
41729
+ (reason, messageId, summary, templateOverride) => {
41730
+ if (!optionsRef.current.snapshotsEnabled || !optionsRef.current.onSnapshotCreate) {
41731
+ return null;
41732
+ }
41733
+ const snapshotIndex = (historyRef.current.snapshots || []).length + 1;
41734
+ const snapshot = {
41735
+ id: id("snapshot"),
41736
+ title: snapshotTitle(reason, snapshotIndex),
41737
+ summary,
41738
+ createdAt: isoNow(),
41739
+ reason,
41740
+ messageId,
41741
+ template: templateOverride === void 0 ? optionsRef.current.getTemplate() : templateOverride
41742
+ };
41743
+ const snapshotMeta = {
41744
+ id: snapshot.id,
41745
+ title: snapshot.title,
41746
+ summary: snapshot.summary,
41747
+ createdAt: snapshot.createdAt
41748
+ };
41749
+ void optionsRef.current.onSnapshotCreate(snapshot);
41750
+ commitHistory(
41751
+ (history) => __spreadProps(__spreadValues({}, history), {
41752
+ currentSnapshotId: snapshot.id,
41753
+ snapshots: [...history.snapshots || [], snapshotMeta],
41754
+ messages: messageId ? history.messages.map(
41755
+ (message) => message.id === messageId ? __spreadProps(__spreadValues({}, message), { snapshotId: snapshot.id }) : message
41756
+ ) : history.messages
41757
+ }),
41758
+ { type: "snapshot.created", snapshot: snapshotMeta }
41759
+ );
41760
+ return snapshot;
41761
+ },
41762
+ [commitHistory]
41763
+ );
41764
+ const scheduleAfterApplySnapshot = useCallback(
41765
+ (messageId, summary, templateOverride) => {
41766
+ if (!optionsRef.current.snapshotsEnabled)
41767
+ return;
41768
+ globalThis.setTimeout(() => {
41769
+ createSnapshot("after-ai-apply", messageId, summary, templateOverride);
41770
+ }, 0);
41771
+ },
41772
+ [createSnapshot]
41773
+ );
41774
+ const restoreSnapshot = useCallback(
41775
+ (snapshotId) => __async(this, null, function* () {
41776
+ if (!optionsRef.current.snapshotsEnabled || !optionsRef.current.onRestoreSnapshot) {
41777
+ return;
41778
+ }
41779
+ yield optionsRef.current.onRestoreSnapshot(snapshotId);
41780
+ commitHistory(
41781
+ (history) => __spreadProps(__spreadValues({}, history), {
41782
+ currentSnapshotId: snapshotId
41783
+ }),
41784
+ { type: "snapshot.restored", snapshotId }
41785
+ );
41786
+ }),
41787
+ [commitHistory]
41788
+ );
41789
+ const hasTemplateChanged = useCallback((activeRun) => {
41790
+ if (!activeRun.baseTemplateKey)
41791
+ return false;
41792
+ return templateKey(optionsRef.current.getTemplate()) !== activeRun.baseTemplateKey;
41793
+ }, []);
41794
+ const refreshActiveRunTemplateKey = useCallback((activeRun) => {
41795
+ void Promise.resolve().then(() => {
41796
+ if (activeRunRef.current !== activeRun)
41797
+ return;
41798
+ activeRun.baseTemplateKey = templateKey(optionsRef.current.getTemplate());
41799
+ });
41800
+ }, []);
41801
+ const applyToolCalls = useCallback(
41802
+ (activeRun, payload, toolCalls) => __async(this, null, function* () {
41803
+ var _a, _b, _c;
41804
+ const applyToolCallsHandler = optionsRef.current.onApplyToolCalls;
41805
+ if (!toolCalls.length || !applyToolCallsHandler)
41806
+ return false;
41807
+ setActivity(t("Applying local changes..."));
41808
+ try {
41809
+ const result = yield applyToolCallsHandler(toolCalls, __spreadProps(__spreadValues({}, payload), {
41810
+ toolCalls
41811
+ }));
41812
+ const errors = userFacingApplyErrors(
41813
+ ((_a = result == null ? void 0 : result.errors) == null ? void 0 : _a.filter(Boolean)) || []
41814
+ );
41815
+ updateMessage(activeRun.assistantMessageId, {
41816
+ content: errors.length ? `${payload.summary || t("Some local changes were not applied.")}
41817
+
41818
+ ${t(
41819
+ "Some operations were not applied"
41820
+ )}:
41821
+ ${errors.join("\n")}` : toolCallsText(__spreadProps(__spreadValues({}, payload), { toolCalls }), result),
41822
+ status: "ready"
41823
+ });
41824
+ setActivity(
41825
+ errors.length ? t("Some local changes were not applied") : t("Updated the email preview.")
41826
+ );
41827
+ if ((result == null ? void 0 : result.applied) === void 0 || result.applied > 0) {
41828
+ scheduleAfterApplySnapshot(
41829
+ activeRun.assistantMessageId,
41830
+ payload.summary
41831
+ );
41832
+ }
41833
+ } catch (error2) {
41834
+ const nextError = ensureError(error2);
41835
+ updateMessage(activeRun.assistantMessageId, {
41836
+ content: `${t("Local changes failed")}: ${nextError.message}`,
41837
+ status: "error"
41838
+ });
41839
+ setActivity("");
41840
+ (_c = (_b = optionsRef.current).onError) == null ? void 0 : _c.call(_b, nextError);
41841
+ return false;
41842
+ }
41843
+ return true;
41844
+ }),
41845
+ [scheduleAfterApplySnapshot, updateMessage]
41846
+ );
41847
+ const ensureGeneratedImageUrl = useCallback(
41848
+ (image2) => __async(this, null, function* () {
41849
+ if (isRemoteImageUrl(image2.url))
41850
+ return __spreadProps(__spreadValues({}, image2), { dataUrl: void 0 });
41851
+ const uploadHandler = optionsRef.current.onUploadGeneratedImage;
41852
+ if (!uploadHandler) {
41853
+ throw new Error(t("Generated image upload is not configured"));
41854
+ }
41855
+ const uploaded = yield uploadHandler(image2);
41856
+ if (!isRemoteImageUrl(uploaded.url)) {
41857
+ throw new Error(t("Generated image upload did not return a URL"));
41858
+ }
41859
+ return __spreadProps(__spreadValues({}, uploaded), { dataUrl: void 0 });
41860
+ }),
41861
+ []
41862
+ );
41863
+ const applyTemplateChange = useCallback(
41864
+ (activeRun, template, summary) => {
41865
+ var _a, _b;
41866
+ (_b = (_a = optionsRef.current).onApplyTemplate) == null ? void 0 : _b.call(_a, template);
41867
+ updateMessage(activeRun.assistantMessageId, {
41868
+ content: summary || t("Updated the email preview."),
41869
+ status: "ready"
41870
+ });
41871
+ setActivity(t("Email preview updated"));
41872
+ scheduleAfterApplySnapshot(
41873
+ activeRun.assistantMessageId,
41874
+ summary,
41875
+ template
41876
+ );
41877
+ },
41878
+ [scheduleAfterApplySnapshot, updateMessage]
41879
+ );
41880
+ const applyPendingChange = useCallback(() => __async(this, null, function* () {
41881
+ const pending = pendingChange;
41882
+ if (!pending || applyingPendingChange)
41883
+ return;
41884
+ setApplyingPendingChange(true);
41885
+ try {
41886
+ if (pending.kind === "tool_calls") {
41887
+ const applied = yield applyToolCalls(
41888
+ { assistantMessageId: pending.assistantMessageId },
41889
+ pending.payload,
41890
+ pending.toolCalls
41891
+ );
41892
+ if (!applied)
41893
+ return;
41894
+ } else {
41895
+ applyTemplateChange(
41896
+ { assistantMessageId: pending.assistantMessageId },
41897
+ pending.template,
41898
+ pending.summary
41899
+ );
41900
+ }
41901
+ setPendingChange(null);
41902
+ } finally {
41903
+ setApplyingPendingChange(false);
41904
+ }
41905
+ }), [
41906
+ applyingPendingChange,
41907
+ applyTemplateChange,
41908
+ applyToolCalls,
41909
+ pendingChange
41910
+ ]);
41911
+ const finishActiveRun = useCallback(
41912
+ (nextStatus) => {
41913
+ const activeRun = activeRunRef.current;
41914
+ if (!activeRun || activeRun.done)
41915
+ return;
41916
+ activeRun.done = true;
41917
+ abortStream();
41918
+ activeRunRef.current = null;
41919
+ setActivity("");
41920
+ setStatus(nextStatus === "ERROR" ? "error" : "ready");
41921
+ const assistantMessage = historyRef.current.messages.find(
41922
+ (message) => message.id === activeRun.assistantMessageId
41923
+ );
41924
+ if ((assistantMessage == null ? void 0 : assistantMessage.status) !== "pending_apply") {
41925
+ updateMessage(activeRun.assistantMessageId, {
41926
+ status: nextStatus === "ERROR" ? "error" : "ready"
41927
+ });
41928
+ }
41929
+ },
41930
+ [abortStream, updateMessage]
41931
+ );
41932
+ const failRun = useCallback(
41933
+ (error2, assistantMessageId) => {
41934
+ var _a, _b;
41935
+ abortStream();
41936
+ activeRunRef.current = null;
41937
+ setActivity("");
41938
+ setStatus("error");
41939
+ if (assistantMessageId) {
41940
+ updateMessage(assistantMessageId, {
41941
+ content: `${t("This request failed")}: ${error2.message}`,
41942
+ status: "error"
41943
+ });
41944
+ }
41945
+ (_b = (_a = optionsRef.current).onError) == null ? void 0 : _b.call(_a, error2);
41946
+ },
41947
+ [abortStream, updateMessage]
41948
+ );
41949
+ const handleAgentEvent = useCallback(
41950
+ (activeRun, event) => {
41951
+ if (event.type === "status") {
41952
+ if (event.payload.status === "RUNNING") {
41953
+ setActivity(t("Updating the email..."));
41954
+ }
41955
+ if (doneStatuses.includes(event.payload.status)) {
41956
+ finishActiveRun(event.payload.status);
41957
+ }
41958
+ return;
41959
+ }
41960
+ if (event.type === "input") {
41961
+ setActivity(friendlyActivity(event.payload.text));
41962
+ return;
41963
+ }
41964
+ if (event.type === "usage") {
41965
+ updateMessage(activeRun.assistantMessageId, {
41966
+ usage: event.payload
41967
+ });
41968
+ return;
41969
+ }
41970
+ if (event.type === "sources") {
41971
+ updateMessage(activeRun.assistantMessageId, {
41972
+ sources: event.payload.sources
41973
+ });
41974
+ return;
41975
+ }
41976
+ if (event.type === "easy_email_answer") {
41977
+ updateMessage(activeRun.assistantMessageId, {
41978
+ content: event.payload.answer || t("Sure.")
41979
+ });
41980
+ setActivity("");
41981
+ return;
41982
+ }
41983
+ if (event.type === "decision_request") {
41984
+ setPendingDecision(event.payload);
41985
+ updateMessage(activeRun.assistantMessageId, {
41986
+ content: event.payload.message,
41987
+ status: "pending_apply"
41988
+ });
41989
+ setActivity(t("Waiting for your choice"));
41990
+ return;
41991
+ }
41992
+ if (event.type === "image_result") {
41993
+ void (() => __async(this, null, function* () {
41994
+ var _a, _b;
41995
+ try {
41996
+ const rawGeneratedImage = event.payload.images[0];
41997
+ if (!rawGeneratedImage)
41998
+ throw new Error(t("Generated image is missing"));
41999
+ setActivity(t("Uploading generated image..."));
42000
+ const generatedImage = yield ensureGeneratedImageUrl(rawGeneratedImage);
42001
+ const generatedImageUrl = generatedImage.url || "";
42002
+ const payload = __spreadProps(__spreadValues({}, event.payload), {
42003
+ images: [generatedImage, ...event.payload.images.slice(1)]
42004
+ });
42005
+ const target = imageReplacementTarget(activeRun, payload.target);
42006
+ const imageChoices = imageDecisionChoices(
42007
+ payload,
42008
+ activeRun.editorImages,
42009
+ t("Image")
42010
+ );
42011
+ if (generatedImageUrl && target && payload.intent !== "attach" && canAutoReplaceImageTarget(
42012
+ activeRun,
42013
+ target,
42014
+ payload.confidence
42015
+ ) && optionsRef.current.onApplyToolCalls) {
42016
+ void applyToolCalls(
42017
+ activeRun,
42018
+ {
42019
+ summary: payload.summary || t("Updated the selected image."),
42020
+ toolCalls: []
42021
+ },
42022
+ [
42023
+ {
42024
+ name: "update_attribute",
42025
+ target,
42026
+ key: imageTargetAttributeKey(
42027
+ activeRun.editorImages,
42028
+ target
42029
+ ),
42030
+ value: generatedImageUrl
42031
+ }
42032
+ ]
42033
+ ).then((applied) => {
42034
+ if (applied)
42035
+ refreshActiveRunTemplateKey(activeRun);
42036
+ });
42037
+ updateMessage(activeRun.assistantMessageId, {
42038
+ content: imageResultText(payload),
42039
+ attachments: payload.images.map(mapGeneratedImageAttachment),
42040
+ status: "ready"
42041
+ });
42042
+ setActivity(t("Image generated"));
42043
+ return;
42044
+ }
42045
+ updateMessage(activeRun.assistantMessageId, {
42046
+ content: imageResultText(payload),
42047
+ attachments: payload.images.map(mapGeneratedImageAttachment),
42048
+ status: imageChoices.length ? "pending_apply" : "ready"
42049
+ });
42050
+ if (generatedImageUrl && payload.intent !== "attach" && imageChoices.length) {
42051
+ setPendingDecision({
42052
+ id: activeRun.assistantMessageId,
42053
+ kind: "target_block",
42054
+ title: t("Which image should I replace?"),
42055
+ message: t(
42056
+ "Choose the image block that should use the generated image."
42057
+ ),
42058
+ choices: imageChoices,
42059
+ required: false,
42060
+ image: generatedImage
42061
+ });
42062
+ setActivity(t("Choose which image to replace"));
42063
+ return;
42064
+ }
42065
+ setActivity(t("Image generated"));
42066
+ } catch (error2) {
42067
+ const nextError = ensureError(error2);
42068
+ updateMessage(activeRun.assistantMessageId, {
42069
+ content: `${t("This request failed")}: ${nextError.message}`,
42070
+ status: "error"
42071
+ });
42072
+ setActivity("");
42073
+ (_b = (_a = optionsRef.current).onError) == null ? void 0 : _b.call(_a, nextError);
42074
+ }
42075
+ }))();
42076
+ return;
42077
+ }
42078
+ if (event.type === "easy_email_result") {
42079
+ const payload = event.payload;
42080
+ updateMessage(activeRun.assistantMessageId, {
42081
+ content: resultText(payload)
42082
+ });
42083
+ if (payload.valid && payload.template) {
42084
+ if (hasTemplateChanged(activeRun)) {
42085
+ setPendingChange({
42086
+ kind: "template",
42087
+ assistantMessageId: activeRun.assistantMessageId,
42088
+ template: payload.template,
42089
+ summary: payload.summary
42090
+ });
42091
+ updateMessage(activeRun.assistantMessageId, {
42092
+ content: pendingText(payload.summary),
42093
+ status: "pending_apply"
42094
+ });
42095
+ setActivity(t("AI changes are ready to apply"));
42096
+ return;
42097
+ }
42098
+ applyTemplateChange(activeRun, payload.template, payload.summary);
42099
+ refreshActiveRunTemplateKey(activeRun);
42100
+ }
42101
+ return;
42102
+ }
42103
+ if (event.type === "easy_email_tool_calls") {
42104
+ const payload = normalizeToolCallsPayload(event.payload);
42105
+ const toolCalls = freezeSelectedTargets(
42106
+ payload.toolCalls,
42107
+ activeRun.selectedTarget
42108
+ );
42109
+ if (toolCalls.length && optionsRef.current.onApplyToolCalls) {
42110
+ if (hasTemplateChanged(activeRun)) {
42111
+ setPendingChange({
42112
+ kind: "tool_calls",
42113
+ assistantMessageId: activeRun.assistantMessageId,
42114
+ payload: __spreadProps(__spreadValues({}, payload), { toolCalls }),
42115
+ toolCalls
42116
+ });
42117
+ updateMessage(activeRun.assistantMessageId, {
42118
+ content: pendingText(payload.summary),
42119
+ status: "pending_apply"
42120
+ });
42121
+ setActivity(t("AI changes are ready to apply"));
42122
+ return;
42123
+ }
42124
+ void applyToolCalls(activeRun, payload, toolCalls).then((applied) => {
42125
+ if (applied)
42126
+ refreshActiveRunTemplateKey(activeRun);
42127
+ });
42128
+ return;
42129
+ }
42130
+ if (payload.fallbackTemplate) {
42131
+ if (hasTemplateChanged(activeRun)) {
42132
+ setPendingChange({
42133
+ kind: "template",
42134
+ assistantMessageId: activeRun.assistantMessageId,
42135
+ template: payload.fallbackTemplate,
42136
+ summary: payload.summary
42137
+ });
42138
+ updateMessage(activeRun.assistantMessageId, {
42139
+ content: pendingText(payload.summary),
42140
+ status: "pending_apply"
42141
+ });
42142
+ setActivity(t("AI changes are ready to apply"));
42143
+ return;
42144
+ }
42145
+ applyTemplateChange(
42146
+ activeRun,
42147
+ payload.fallbackTemplate,
42148
+ payload.summary
42149
+ );
42150
+ refreshActiveRunTemplateKey(activeRun);
42151
+ }
42152
+ return;
42153
+ }
42154
+ if (event.type === "error") {
42155
+ failRun(new Error(event.payload.message), activeRun.assistantMessageId);
42156
+ }
42157
+ },
42158
+ [
42159
+ applyTemplateChange,
42160
+ applyToolCalls,
42161
+ failRun,
42162
+ finishActiveRun,
42163
+ hasTemplateChanged,
42164
+ refreshActiveRunTemplateKey,
42165
+ updateMessage
42166
+ ]
42167
+ );
42168
+ const send = useCallback(
42169
+ (_0, ..._1) => __async(this, [_0, ..._1], function* (message, attachments = [], decisionResponse) {
42170
+ var _a, _b, _c;
42171
+ const text = message.trim();
42172
+ if (!text || status2 === "running")
42173
+ return;
42174
+ const template = optionsRef.current.getTemplate();
42175
+ const baseTemplateKey = templateKey(template);
42176
+ const editorContext = (_b = (_a = optionsRef.current).getEditorContext) == null ? void 0 : _b.call(_a);
42177
+ const requestHistory = historyRef.current;
42178
+ const createdAt = isoNow();
42179
+ const userMessage = {
42180
+ id: id("user"),
42181
+ role: "user",
42182
+ content: text,
42183
+ time: formatTime(new Date(createdAt)),
42184
+ createdAt,
42185
+ status: "ready",
42186
+ attachments
42187
+ };
42188
+ const assistantMessage = {
42189
+ id: id("assistant"),
42190
+ role: "assistant",
42191
+ content: attachments.length ? t(
42192
+ "Reference images received. Adjusting the email with the current template..."
42193
+ ) : t("Generating changes from the current email..."),
42194
+ time: formatTime(new Date(createdAt)),
42195
+ createdAt,
42196
+ status: "running"
42197
+ };
42198
+ setPendingChange(null);
42199
+ setPendingDecision(null);
42200
+ commitHistory(
42201
+ (history) => __spreadProps(__spreadValues({}, history), {
42202
+ messages: [...history.messages, userMessage, assistantMessage]
42203
+ }),
42204
+ { type: "message.appended", messages: [userMessage, assistantMessage] }
42205
+ );
42206
+ createSnapshot("before-ai-run", userMessage.id, text, template);
42207
+ setStatus("running");
42208
+ setActivity(t("Sending to AI..."));
42209
+ const activeRun = {
42210
+ assistantMessageId: assistantMessage.id,
42211
+ baseTemplateKey,
42212
+ selectedTarget: selectedTargetFromContext(editorContext),
42213
+ selectedType: ((_c = editorContext == null ? void 0 : editorContext.selected) == null ? void 0 : _c.type) || null,
42214
+ editorImages: editorContext == null ? void 0 : editorContext.images,
42215
+ done: false
42216
+ };
42217
+ const controller = new AbortController();
42218
+ activeRunRef.current = activeRun;
42219
+ streamAbortRef.current = controller;
42220
+ setActivity(t("Connecting live results..."));
42221
+ void (() => __async(this, null, function* () {
42222
+ const result = yield optionsRef.current.onChat({
42223
+ message: text,
42224
+ template,
42225
+ history: requestHistory,
42226
+ editorContext,
42227
+ decisionResponse,
42228
+ images: attachments.map(mapAiAttachment),
42229
+ signal: controller.signal
42230
+ });
42231
+ if (controller.signal.aborted || activeRunRef.current !== activeRun) {
42232
+ return;
42233
+ }
42234
+ yield resolveAiChatResult(result, (event) => {
42235
+ if (controller.signal.aborted || activeRunRef.current !== activeRun) {
42236
+ return;
42237
+ }
42238
+ handleAgentEvent(activeRun, event);
42239
+ });
42240
+ }))().catch((error2) => {
42241
+ if (controller.signal.aborted && !activeRunRef.current)
42242
+ return;
42243
+ failRun(ensureError(error2), assistantMessage.id);
42244
+ });
42245
+ }),
42246
+ [commitHistory, createSnapshot, failRun, handleAgentEvent, status2]
42247
+ );
42248
+ const chooseDecision = useCallback(
42249
+ (choice, response) => __async(this, null, function* () {
42250
+ const decision = pendingDecision;
42251
+ if (!decision)
42252
+ return;
42253
+ setPendingDecision(null);
42254
+ setPendingChange(null);
42255
+ if (decision.kind === "target_block" && decision.image && choice.target) {
42256
+ const imageUrl = decision.image.url || "";
42257
+ if (!imageUrl)
42258
+ return;
42259
+ yield applyToolCalls(
42260
+ { assistantMessageId: decision.id },
42261
+ {
42262
+ summary: t("Replaced the chosen image."),
42263
+ toolCalls: []
42264
+ },
42265
+ [
42266
+ {
42267
+ name: "update_attribute",
42268
+ target: choice.target,
42269
+ key: choiceImageAttributeKey(choice),
42270
+ value: imageUrl
42271
+ }
42272
+ ]
42273
+ );
42274
+ return;
42275
+ }
42276
+ const prompt = choice.prompt || response.customText || `${t("Continue with this option")}: ${choice.label}`;
42277
+ yield send(prompt, [], response);
42278
+ }),
42279
+ [applyToolCalls, pendingDecision, send]
42280
+ );
42281
+ const clearPendingDecision = useCallback(() => {
42282
+ setPendingDecision(null);
42283
+ }, []);
42284
+ const stop = useCallback(() => __async(this, null, function* () {
42285
+ abortStream();
42286
+ activeRunRef.current = null;
42287
+ setActivity("");
42288
+ setStatus("ready");
42289
+ }), [abortStream]);
42290
+ useEffect(() => {
42291
+ return () => abortStream();
42292
+ }, [abortStream]);
42293
+ return {
42294
+ history: historyState,
42295
+ messages: historyState.messages,
42296
+ snapshots: historyState.snapshots || [],
42297
+ currentSnapshotId: historyState.currentSnapshotId,
42298
+ status: status2,
42299
+ activity,
42300
+ pendingChange,
42301
+ pendingDecision,
42302
+ applyingPendingChange,
42303
+ applyPendingChange,
42304
+ chooseDecision,
42305
+ clearPendingDecision,
42306
+ restoreSnapshot,
42307
+ send,
42308
+ stop
42309
+ };
42310
+ }
42311
+ const IMAGE_BLOCK_TYPES = /* @__PURE__ */ new Set(["standard-image", "image"]);
42312
+ const BACKGROUND_IMAGE_BLOCK_TYPES = /* @__PURE__ */ new Set([
42313
+ "section",
42314
+ "wrapper",
42315
+ "hero",
42316
+ "standard-section",
42317
+ "standard-wrapper",
42318
+ "standard-hero"
42319
+ ]);
42320
+ function asEmailTemplate(template, current) {
42321
+ if (!template || typeof template !== "object")
42322
+ return current;
42323
+ const record = template;
42324
+ if (record.content && typeof record.content === "object") {
42325
+ return __spreadValues(__spreadValues({}, current), record);
42326
+ }
42327
+ if (record.type === "page") {
42328
+ return __spreadProps(__spreadValues({}, current), { content: record });
42329
+ }
42330
+ return current;
42331
+ }
42332
+ function createAttachmentId(file) {
42333
+ if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
42334
+ return `image-${crypto.randomUUID()}`;
42335
+ }
42336
+ return `image-${file.name || "upload"}-${Date.now()}`;
42337
+ }
42338
+ function normalizeUploadResult(result, file) {
42339
+ if (typeof result === "string") {
42340
+ return {
42341
+ id: createAttachmentId(file),
42342
+ type: "image",
42343
+ name: file.name || "image",
42344
+ url: result,
42345
+ mimeType: file.type || "image/png",
42346
+ size: file.size
42347
+ };
42348
+ }
42349
+ return __spreadProps(__spreadValues({}, result), {
42350
+ type: "image",
42351
+ name: result.name || file.name || "image",
42352
+ url: result.url || "",
42353
+ mimeType: result.mimeType || file.type || "image/png",
42354
+ size: result.size || file.size
42355
+ });
42356
+ }
42357
+ function dataUrlToFile(attachment) {
42358
+ const dataUrl = attachment.dataUrl || attachment.url || "";
42359
+ const match = dataUrl.match(/^data:([^;,]+)?(;base64)?,([\s\S]*)$/);
42360
+ if (!match)
42361
+ throw new Error(t("Generated image must be uploaded before use"));
42362
+ const mimeType = match[1] || attachment.mimeType || "image/png";
42363
+ const isBase64 = Boolean(match[2]);
42364
+ const raw = isBase64 ? atob(match[3]) : decodeURIComponent(match[3]);
42365
+ const bytes = new Uint8Array(raw.length);
42366
+ for (let index2 = 0; index2 < raw.length; index2 += 1) {
42367
+ bytes[index2] = raw.charCodeAt(index2);
42368
+ }
42369
+ return new File([bytes], attachment.name || "generated-image.png", {
42370
+ type: mimeType,
42371
+ lastModified: Date.now()
42372
+ });
42373
+ }
42374
+ function numberFromUnknown(value) {
42375
+ if (typeof value === "number" && Number.isFinite(value) && value > 0) {
42376
+ return value;
42377
+ }
42378
+ if (typeof value !== "string")
42379
+ return void 0;
42380
+ const match = value.trim().match(/^(\d+(?:\.\d+)?)/);
42381
+ if (!match)
42382
+ return void 0;
42383
+ const nextValue = Number.parseFloat(match[1]);
42384
+ return Number.isFinite(nextValue) && nextValue > 0 ? nextValue : void 0;
42385
+ }
42386
+ function getImageDimensions(node) {
42387
+ const attributes = node.attributes && typeof node.attributes === "object" ? node.attributes : {};
42388
+ const data = node.data && typeof node.data === "object" ? node.data : {};
42389
+ return {
42390
+ width: numberFromUnknown(attributes.width) || numberFromUnknown(attributes["image-width"]) || numberFromUnknown(data.width) || numberFromUnknown(data["image-width"]),
42391
+ height: numberFromUnknown(attributes.height) || numberFromUnknown(attributes["image-height"]) || numberFromUnknown(data.height) || numberFromUnknown(data["image-height"])
42392
+ };
42393
+ }
42394
+ function getImageSrc(node) {
42395
+ const attributes = node.attributes && typeof node.attributes === "object" ? node.attributes : {};
42396
+ const data = node.data && typeof node.data === "object" ? node.data : {};
42397
+ return typeof attributes.src === "string" ? attributes.src : typeof data.src === "string" ? data.src : void 0;
42398
+ }
42399
+ function getBackgroundImageSrc(node) {
42400
+ const attributes = node.attributes && typeof node.attributes === "object" ? node.attributes : {};
42401
+ const data = node.data && typeof node.data === "object" ? node.data : {};
42402
+ return typeof attributes["background-url"] === "string" ? attributes["background-url"] : typeof data["background-url"] === "string" ? data["background-url"] : void 0;
42403
+ }
42404
+ function supportsBackgroundImage(node) {
42405
+ const type = typeof node.type === "string" ? node.type : "";
42406
+ const attributes = node.attributes && typeof node.attributes === "object" ? node.attributes : {};
42407
+ return BACKGROUND_IMAGE_BLOCK_TYPES.has(type) || typeof attributes["background-url"] === "string" || attributes["background-image-enabled"] === true;
42408
+ }
42409
+ function imageAssetTitle(node, source) {
42410
+ if (typeof node.title === "string" && node.title.trim())
42411
+ return node.title;
42412
+ const type = typeof node.type === "string" ? node.type : "";
42413
+ if (source === "background") {
42414
+ if (type.includes("hero"))
42415
+ return t("Hero background");
42416
+ if (type.includes("wrapper"))
42417
+ return t("Container background");
42418
+ if (type.includes("section"))
42419
+ return t("Section background");
42420
+ return t("Background image");
42421
+ }
42422
+ return t("Image");
42423
+ }
42424
+ function selectedDescendants(editor, selectedNodePath) {
42425
+ if (!selectedNodePath)
42426
+ return [];
42427
+ return Array.from(
42428
+ Editor.nodes(editor, {
42429
+ at: selectedNodePath,
42430
+ match: (node, path2) => path2.length > selectedNodePath.length && typeof node.type === "string"
42431
+ })
42432
+ ).map(([node, path2]) => {
42433
+ const element = node;
42434
+ const text = Node.string(node).trim();
42435
+ return {
42436
+ id: typeof element.id === "string" ? element.id : void 0,
42437
+ uid: typeof element.uid === "string" ? element.uid : void 0,
42438
+ type: element.type,
42439
+ path: path2,
42440
+ title: typeof element.title === "string" ? element.title : void 0,
42441
+ text: text || void 0
42442
+ };
42443
+ }).filter((item2) => item2.text || item2.id || item2.uid).slice(0, 80);
42444
+ }
42445
+ function AiAgentPanel({
42446
+ className,
42447
+ disabled,
42448
+ history,
42449
+ onHistoryChange,
42450
+ snapshots,
42451
+ initialMessages,
42452
+ onError,
42453
+ onUpload: uploadOverride,
42454
+ onChat,
42455
+ quickActions,
42456
+ placeholder
42457
+ }) {
42458
+ assertAiAgentFeatureEnabled();
42459
+ const { values, reset } = useEditorContext();
42460
+ const { onUpload: editorUpload } = useEditorProps();
42461
+ const { selectedNode, selectedNodePath } = useSelectedNode();
42462
+ const editor = useSlate();
42463
+ const applyAiToolCalls = useApplyAiToolCalls();
42464
+ const snapshotOptions = snapshots || void 0;
42465
+ const valuesRef = useRef(values);
42466
+ const selectedRef = useRef({ selectedNode, selectedNodePath });
42467
+ useEffect(() => {
42468
+ valuesRef.current = values;
42469
+ }, [values]);
42470
+ useEffect(() => {
42471
+ selectedRef.current = { selectedNode, selectedNodePath };
42472
+ }, [selectedNode, selectedNodePath]);
42473
+ const uploadAttachment = useCallback(
42474
+ (file) => __async(this, null, function* () {
42475
+ const uploadHandler = uploadOverride || editorUpload;
42476
+ if (!uploadHandler) {
42477
+ throw new Error(t("Image upload is not configured"));
42478
+ }
42479
+ const result = yield uploadHandler(file);
42480
+ return normalizeUploadResult(result, file);
42481
+ }),
42482
+ [editorUpload, uploadOverride]
42483
+ );
42484
+ const session = useAiAgentSession({
42485
+ onChat,
42486
+ history,
42487
+ onHistoryChange,
42488
+ initialMessages,
42489
+ onError,
42490
+ snapshotsEnabled: Boolean(snapshotOptions),
42491
+ onSnapshotCreate: snapshotOptions ? snapshotOptions.onCreate : void 0,
42492
+ onRestoreSnapshot: (snapshotOptions == null ? void 0 : snapshotOptions.onRestore) ? (snapshotId) => __async(this, null, function* () {
42493
+ var _a;
42494
+ const snapshot = yield (_a = snapshotOptions.onRestore) == null ? void 0 : _a.call(snapshotOptions, snapshotId);
42495
+ if (!snapshot)
42496
+ return;
42497
+ reset(asEmailTemplate(snapshot.template, valuesRef.current));
42498
+ }) : void 0,
42499
+ onUploadGeneratedImage: (image2) => __async(this, null, function* () {
42500
+ if (image2.url && !image2.url.startsWith("data:")) {
42501
+ return __spreadProps(__spreadValues({}, image2), { dataUrl: void 0 });
42502
+ }
42503
+ const uploaded = yield uploadAttachment(dataUrlToFile(image2));
42504
+ return __spreadProps(__spreadValues({}, image2), {
42505
+ url: uploaded.url,
42506
+ dataUrl: void 0,
42507
+ mimeType: uploaded.mimeType || image2.mimeType,
42508
+ size: uploaded.size || image2.size
42509
+ });
42510
+ }),
42511
+ getTemplate: () => valuesRef.current,
42512
+ getEditorContext: () => {
42513
+ const { selectedNode: selectedNode2, selectedNodePath: selectedNodePath2 } = selectedRef.current;
42514
+ const images = Array.from(
42515
+ Editor.nodes(editor, {
42516
+ at: [],
42517
+ match: (node) => typeof node.type === "string" && (IMAGE_BLOCK_TYPES.has(
42518
+ node.type
42519
+ ) || supportsBackgroundImage(node))
42520
+ })
42521
+ ).map(([node, path2], index2) => {
42522
+ const imageNode = node;
42523
+ const isImageBlock = IMAGE_BLOCK_TYPES.has(imageNode.type);
42524
+ const source = isImageBlock ? "image" : "background";
42525
+ const dimensions = getImageDimensions(imageNode);
42526
+ const layout2 = (() => {
42527
+ try {
42528
+ const domNode = ReactEditor.toDOMNode(editor, node);
42529
+ const rect = domNode.getBoundingClientRect();
42530
+ if (rect.width > 0 && rect.height > 0) {
42531
+ return {
42532
+ width: Math.round(rect.width),
42533
+ height: Math.round(rect.height)
42534
+ };
42535
+ }
42536
+ } catch (e) {
42537
+ }
42538
+ return void 0;
42539
+ })();
42540
+ return {
42541
+ id: typeof imageNode.id === "string" ? imageNode.id : void 0,
42542
+ uid: typeof imageNode.uid === "string" ? imageNode.uid : void 0,
42543
+ type: imageNode.type,
42544
+ path: path2,
42545
+ title: imageAssetTitle(imageNode, source),
42546
+ src: isImageBlock ? getImageSrc(imageNode) : getBackgroundImageSrc(imageNode),
42547
+ source,
42548
+ attributeKey: isImageBlock ? "src" : "background-url",
42549
+ width: (layout2 == null ? void 0 : layout2.width) || dimensions.width,
42550
+ height: (layout2 == null ? void 0 : layout2.height) || dimensions.height,
42551
+ index: index2
42552
+ };
42553
+ });
42554
+ if (!selectedNode2)
42555
+ return { selected: null, images };
42556
+ const layout = (() => {
42557
+ try {
42558
+ const domNode = ReactEditor.toDOMNode(editor, selectedNode2);
42559
+ const rect = domNode.getBoundingClientRect();
42560
+ if (rect.width > 0 && rect.height > 0) {
42561
+ return {
42562
+ width: Math.round(rect.width),
42563
+ height: Math.round(rect.height)
42564
+ };
42565
+ }
42566
+ } catch (e) {
42567
+ }
42568
+ return void 0;
42569
+ })();
42570
+ return {
42571
+ images,
42572
+ selected: {
42573
+ id: selectedNode2.id,
42574
+ uid: selectedNode2.uid,
42575
+ type: selectedNode2.type,
42576
+ path: selectedNodePath2 || void 0,
42577
+ title: selectedNode2.title,
42578
+ attributes: selectedNode2.attributes,
42579
+ data: selectedNode2.data,
42580
+ layout,
42581
+ descendants: selectedDescendants(
42582
+ editor,
42583
+ selectedNodePath2 || void 0
42584
+ )
42585
+ }
42586
+ };
42587
+ },
42588
+ onApplyTemplate: (template) => {
42589
+ reset(asEmailTemplate(template, valuesRef.current));
42590
+ },
42591
+ onApplyToolCalls: applyAiToolCalls
42592
+ });
42593
+ return /* @__PURE__ */ React__default.createElement(
42594
+ EasyEmailProAiAgent,
42595
+ {
42596
+ className,
42597
+ messages: session.messages,
42598
+ status: session.status,
42599
+ activity: session.activity,
42600
+ disabled,
42601
+ sendDisabled: disabled || session.status === "running",
42602
+ quickActions,
42603
+ placeholder,
42604
+ pendingAction: session.pendingChange ? {
42605
+ label: session.applyingPendingChange ? t("Applying...") : t("Apply AI changes"),
42606
+ disabled: session.applyingPendingChange,
42607
+ onClick: session.applyPendingChange
42608
+ } : void 0,
42609
+ pendingDecision: session.pendingDecision,
42610
+ onSend: session.send,
42611
+ onUpload: uploadOverride || editorUpload ? uploadAttachment : void 0,
42612
+ onChooseDecision: session.chooseDecision,
42613
+ onCancelDecision: session.clearPendingDecision,
42614
+ onRestoreSnapshot: (snapshotOptions == null ? void 0 : snapshotOptions.onRestore) ? session.restoreSnapshot : void 0
42615
+ }
42616
+ );
42617
+ }
40271
42618
  const DraggingPlaceholderWrapper = (props) => {
40272
42619
  const isDragover = get(props.attributes, "data-slate-dragover");
40273
42620
  const isDragging = get(props.attributes, "data-slate-dragging");
@@ -42107,7 +44454,8 @@ const SharedComponents = {
42107
44454
  BlocksModal,
42108
44455
  TableTools,
42109
44456
  SocialItem: SocialItem$2,
42110
- NavbarLink: NavbarLink$1
44457
+ NavbarLink: NavbarLink$1,
44458
+ AiAgent: void 0
42111
44459
  };
42112
44460
  const stopEvent$1 = (ev) => {
42113
44461
  ev.stopPropagation();
@@ -44367,6 +46715,7 @@ const Layout = ({ children }) => {
44367
46715
  const Minimalist = { useCreateConfig, Layout };
44368
46716
  const IconFontStyle = styleText$h;
44369
46717
  export {
46718
+ AiAgentPanel,
44370
46719
  AttributeField,
44371
46720
  AttributesPanelWrapper,
44372
46721
  BlockSchemasMap,
@@ -44375,6 +46724,7 @@ export {
44375
46724
  ControllerProvider,
44376
46725
  DraggingProvider,
44377
46726
  DraggingProviderContext,
46727
+ EasyEmailProAiAgent,
44378
46728
  ElementStyles,
44379
46729
  IconFont,
44380
46730
  IconFontStyle,
@@ -44397,11 +46747,15 @@ export {
44397
46747
  getMergeTagsByType,
44398
46748
  italicAdapter,
44399
46749
  mjmlToJson,
46750
+ parseEasyEmailAiStream,
44400
46751
  pixelAdapter,
44401
46752
  pixelNumberAdapter,
44402
46753
  previewLoadImage,
46754
+ resolveAiChatResult2 as resolveAiChatResult,
44403
46755
  sliderAdapter,
44404
46756
  useAddBlock,
46757
+ useAiAgentSession,
46758
+ useApplyAiToolCalls,
44405
46759
  useBlocksDrawer,
44406
46760
  useClearCanvas,
44407
46761
  useColorContext,