@puckeditor/plugin-ai 0.9.0-canary.c31f0e8f → 0.9.0-canary.c5c8a6ec

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1097,7 +1097,7 @@ init_react_import();
1097
1097
 
1098
1098
  // css-module:/home/runner/work/platform/platform/packages/platform-client/components/Modal/Modal.module.css#css-module
1099
1099
  init_react_import();
1100
- var Modal_module_default = { "Modal-background": "_Modal-background_1bedq_1", "Modal--visible": "_Modal--visible_1bedq_16", "Modal-modal": "_Modal-modal_1bedq_22" };
1100
+ var Modal_module_default = { "Modal-background": "_Modal-background_mocy5_1", "Modal--visible": "_Modal--visible_mocy5_16", "Modal-modal": "_Modal-modal_mocy5_22" };
1101
1101
 
1102
1102
  // ../platform-client/components/Modal/Modal.tsx
1103
1103
  var import_react9 = require("react");
@@ -1200,12 +1200,13 @@ var Button = ({
1200
1200
  secondary: variant === "secondary",
1201
1201
  danger: variant === "danger",
1202
1202
  ghost: variant === "ghost",
1203
- disabled,
1203
+ // Disabled while its click is still running, too.
1204
+ disabled: disabled || loading,
1204
1205
  fullWidth,
1205
1206
  [size]: true
1206
1207
  }),
1207
1208
  onClick: (e) => {
1208
- if (disabled) {
1209
+ if (disabled || loading) {
1209
1210
  e.preventDefault();
1210
1211
  return;
1211
1212
  }
@@ -1593,7 +1594,7 @@ var import_react15 = require("react");
1593
1594
 
1594
1595
  // css-module:/home/runner/work/platform/platform/packages/platform-client/components/Menu/styles.module.css#css-module
1595
1596
  init_react_import();
1596
- var styles_module_default4 = { "Menu": "_Menu_1tu16_1", "Menu-content": "_Menu-content_1tu16_6", "Menu-sections": "_Menu-sections_1tu16_11", "Menu-action": "_Menu-action_1tu16_22", "Menu-list": "_Menu-list_1tu16_44", "Menu-item": "_Menu-item_1tu16_55", "Menu-item--disabled": "_Menu-item--disabled_1tu16_83" };
1597
+ var styles_module_default4 = { "Menu": "_Menu_1jr57_1", "Menu-content": "_Menu-content_1jr57_6", "Menu-sections": "_Menu-sections_1jr57_11", "Menu-action": "_Menu-action_1jr57_22", "Menu-list": "_Menu-list_1jr57_44", "Menu-item": "_Menu-item_1jr57_55", "Menu-item--disabled": "_Menu-item--disabled_1jr57_84" };
1597
1598
 
1598
1599
  // ../platform-client/components/Menu/index.tsx
1599
1600
  var import_jsx_runtime17 = require("react/jsx-runtime");
@@ -1704,7 +1705,7 @@ init_react_import();
1704
1705
 
1705
1706
  // css-module:/home/runner/work/platform/platform/packages/platform-client/components/Tag/Tag.module.css#css-module
1706
1707
  init_react_import();
1707
- var Tag_module_default = { "Tag": "_Tag_s2h0n_1", "Tag--borderless": "_Tag--borderless_s2h0n_21", "Tag--colorBlue": "_Tag--colorBlue_s2h0n_25", "Tag--colorGreen": "_Tag--colorGreen_s2h0n_29", "Tag--colorRed": "_Tag--colorRed_s2h0n_33", "Tag--colorMuted": "_Tag--colorMuted_s2h0n_37", "Tag-sprite": "_Tag-sprite_s2h0n_41", "Tag--pulse": "_Tag--pulse_s2h0n_45", "pulse": "_pulse_s2h0n_1", "Tag-label": "_Tag-label_s2h0n_79" };
1708
+ var Tag_module_default = { "Tag": "_Tag_162k8_1", "Tag--borderless": "_Tag--borderless_162k8_21", "Tag--colorBlue": "_Tag--colorBlue_162k8_25", "Tag--colorGreen": "_Tag--colorGreen_162k8_30", "Tag--colorRed": "_Tag--colorRed_162k8_34", "Tag--colorMuted": "_Tag--colorMuted_162k8_38", "Tag-sprite": "_Tag-sprite_162k8_42", "Tag--pulse": "_Tag--pulse_162k8_46", "pulse": "_pulse_162k8_1", "Tag-label": "_Tag-label_162k8_80" };
1708
1709
 
1709
1710
  // ../platform-client/components/Tag/Tag.tsx
1710
1711
  var import_jsx_runtime22 = require("react/jsx-runtime");
@@ -1758,19 +1759,13 @@ var styles_module_default6 = { "Viewport": "_Viewport_1vvhm_3", "Viewport--stand
1758
1759
  var import_jsx_runtime26 = require("react/jsx-runtime");
1759
1760
  var cx6 = getClassNameFactory("Viewport", styles_module_default6);
1760
1761
 
1761
- // ../platform-client/context/editor.tsx
1762
- init_react_import();
1763
- var import_react18 = require("react");
1764
- var import_jsx_runtime27 = require("react/jsx-runtime");
1765
- var ctx = (0, import_react18.createContext)({});
1766
-
1767
1762
  // css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
1768
1763
  init_react_import();
1769
1764
  var styles_module_default7 = { "Chat": "_Chat_5z5yi_1", "Chat--hasMessages": "_Chat--hasMessages_5z5yi_17", "Chat-inner": "_Chat-inner_5z5yi_28", "Chat--hasChildren": "_Chat--hasChildren_5z5yi_40", "Chat-body": "_Chat-body_5z5yi_45", "Chat--isLoading": "_Chat--isLoading_5z5yi_52", "Chat-messages": "_Chat-messages_5z5yi_56", "Chat-form": "_Chat-form_5z5yi_63", "Chat--hideInput": "_Chat--hideInput_5z5yi_68", "Chat-formHelper": "_Chat-formHelper_5z5yi_82", "Chat-examplePrompts": "_Chat-examplePrompts_5z5yi_97", "Chat-examplePrompt": "_Chat-examplePrompt_5z5yi_97", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_5z5yi_134", "Chat-default": "_Chat-default_5z5yi_139", "ChatMessage": "_ChatMessage_5z5yi_155", "ChatMessage--userRole": "_ChatMessage--userRole_5z5yi_164", "ChatMessage-userBubble": "_ChatMessage-userBubble_5z5yi_164", "ChatMessage-userAttachments": "_ChatMessage-userAttachments_5z5yi_175", "ChatMessage-thumbnail": "_ChatMessage-thumbnail_5z5yi_181", "ChatMessage-thumbnailLabel": "_ChatMessage-thumbnailLabel_5z5yi_211", "ChatMessage-text": "_ChatMessage-text_5z5yi_284", "ChatMessage-event": "_ChatMessage-event_5z5yi_319", "ChatMessage-eventBody": "_ChatMessage-eventBody_5z5yi_323", "ChatMessage-eventCollapse": "_ChatMessage-eventCollapse_5z5yi_332", "ChatMessage-eventHeader": "_ChatMessage-eventHeader_5z5yi_336", "ChatMessage-eventExpand": "_ChatMessage-eventExpand_5z5yi_336", "ChatMessage-eventIcon": "_ChatMessage-eventIcon_5z5yi_362", "ChatMessage-eventLabel": "_ChatMessage-eventLabel_5z5yi_366", "ChatMessage-attachmentImage": "_ChatMessage-attachmentImage_5z5yi_380", "ChatMessage-attachmentFile": "_ChatMessage-attachmentFile_5z5yi_397", "Chat-loader": "_Chat-loader_5z5yi_420", "Chat-loaderIcon": "_Chat-loaderIcon_5z5yi_430", "Chat-error": "_Chat-error_5z5yi_434", "Chat-errorLabel": "_Chat-errorLabel_5z5yi_443", "Chat-errorAction": "_Chat-errorAction_5z5yi_447", "Chat-userError": "_Chat-userError_5z5yi_451", "Chat-userErrorDismiss": "_Chat-userErrorDismiss_5z5yi_461" };
1770
1765
 
1771
1766
  // src/components/PromptForm/index.tsx
1772
1767
  init_react_import();
1773
- var import_react19 = require("react");
1768
+ var import_react18 = require("react");
1774
1769
 
1775
1770
  // css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/PromptForm/styles.module.css#css-module
1776
1771
  init_react_import();
@@ -1814,6 +1809,42 @@ var matchesAccept = (file, accept) => {
1814
1809
  return file.type === entry;
1815
1810
  });
1816
1811
  };
1812
+ var documentExtensionByMediaType = {
1813
+ "application/msword": "doc",
1814
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
1815
+ "text/markdown": "md",
1816
+ "application/pdf": "pdf",
1817
+ "text/plain": "txt"
1818
+ };
1819
+ var mediaTypeToExtension = (mediaType) => {
1820
+ const mapped = documentExtensionByMediaType[mediaType];
1821
+ if (mapped) {
1822
+ return mapped;
1823
+ }
1824
+ const subtype = mediaType.split("/")[1] ?? "";
1825
+ return subtype.split("+")[0] || "bin";
1826
+ };
1827
+ var getFilesFromClipboard = (data) => {
1828
+ const files = [];
1829
+ for (const item of data.items ? Array.from(data.items) : []) {
1830
+ if (item.kind === "file") {
1831
+ const file = item.getAsFile();
1832
+ if (file) {
1833
+ files.push(file);
1834
+ }
1835
+ }
1836
+ }
1837
+ if (files.length === 0 && data.files) {
1838
+ files.push(...Array.from(data.files));
1839
+ }
1840
+ return files.map(
1841
+ (file, index) => file.name ? file : new File(
1842
+ [file],
1843
+ `pasted-${Date.now()}-${index}.${mediaTypeToExtension(file.type)}`,
1844
+ { type: file.type }
1845
+ )
1846
+ );
1847
+ };
1817
1848
  var getAttachmentIdFromRef = (url) => url.startsWith("attachment://") ? url.slice("attachment://".length) : null;
1818
1849
  var resolveAttachmentUrl = (url, attachmentEndpoint) => {
1819
1850
  if (!attachmentEndpoint) {
@@ -1825,6 +1856,20 @@ var resolveAttachmentUrl = (url, attachmentEndpoint) => {
1825
1856
  }
1826
1857
  return `${attachmentEndpoint.replace(/\/$/, "")}/${attachmentId}`;
1827
1858
  };
1859
+ var fetchAttachmentUrl = async (endpoint, signal) => {
1860
+ const response = await fetch(endpoint, { redirect: "manual", signal });
1861
+ if (response.type === "opaqueredirect" || response.status >= 300 && response.status < 400) {
1862
+ return endpoint;
1863
+ }
1864
+ if (!response.ok) {
1865
+ throw new Error(`Attachment URL request failed with ${response.status}`);
1866
+ }
1867
+ const { url } = await response.json();
1868
+ if (typeof url !== "string" || !url) {
1869
+ throw new Error("Attachment URL response did not include a url");
1870
+ }
1871
+ return url;
1872
+ };
1828
1873
  var isInternalMessage = (text) => text.startsWith(INTERNAL_MESSAGE_PREFIX);
1829
1874
  var truncateFilename = (name, max = 25) => {
1830
1875
  if (name.length <= max) return name;
@@ -1836,7 +1881,7 @@ var truncateFilename = (name, max = 25) => {
1836
1881
  };
1837
1882
 
1838
1883
  // src/components/PromptForm/index.tsx
1839
- var import_jsx_runtime28 = require("react/jsx-runtime");
1884
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1840
1885
  var cx7 = getClassNameFactory2("PromptForm", styles_module_default8);
1841
1886
  function PromptForm({
1842
1887
  actions,
@@ -1856,13 +1901,13 @@ function PromptForm({
1856
1901
  maxRows = 5,
1857
1902
  value = ""
1858
1903
  }) {
1859
- const hasSetInitialPrompt = (0, import_react19.useRef)(false);
1860
- const [prompt, setPrompt] = (0, import_react19.useState)(value);
1861
- const internalRef = (0, import_react19.useRef)(null);
1862
- const [isDragOver, setIsDragOver] = (0, import_react19.useState)(false);
1863
- const dragCounterRef = (0, import_react19.useRef)(0);
1904
+ const hasSetInitialPrompt = (0, import_react18.useRef)(false);
1905
+ const [prompt, setPrompt] = (0, import_react18.useState)(value);
1906
+ const internalRef = (0, import_react18.useRef)(null);
1907
+ const [isDragOver, setIsDragOver] = (0, import_react18.useState)(false);
1908
+ const dragCounterRef = (0, import_react18.useRef)(0);
1864
1909
  const canDrop = !!onFileDrop && !isDisabled && !isLoading;
1865
- const handleDragEnter = (0, import_react19.useCallback)(
1910
+ const handleDragEnter = (0, import_react18.useCallback)(
1866
1911
  (e) => {
1867
1912
  e.preventDefault();
1868
1913
  dragCounterRef.current++;
@@ -1872,17 +1917,17 @@ function PromptForm({
1872
1917
  },
1873
1918
  [canDrop]
1874
1919
  );
1875
- const handleDragLeave = (0, import_react19.useCallback)((e) => {
1920
+ const handleDragLeave = (0, import_react18.useCallback)((e) => {
1876
1921
  e.preventDefault();
1877
1922
  dragCounterRef.current--;
1878
1923
  if (dragCounterRef.current === 0) {
1879
1924
  setIsDragOver(false);
1880
1925
  }
1881
1926
  }, []);
1882
- const handleDragOver = (0, import_react19.useCallback)((e) => {
1927
+ const handleDragOver = (0, import_react18.useCallback)((e) => {
1883
1928
  e.preventDefault();
1884
1929
  }, []);
1885
- const handleDrop = (0, import_react19.useCallback)(
1930
+ const handleDrop = (0, import_react18.useCallback)(
1886
1931
  (e) => {
1887
1932
  e.preventDefault();
1888
1933
  dragCounterRef.current = 0;
@@ -1896,7 +1941,17 @@ function PromptForm({
1896
1941
  },
1897
1942
  [canDrop, onFileDrop]
1898
1943
  );
1899
- (0, import_react19.useEffect)(() => {
1944
+ const handlePaste = (0, import_react18.useCallback)(
1945
+ (e) => {
1946
+ if (!canDrop) return;
1947
+ const files = getFilesFromClipboard(e.clipboardData);
1948
+ if (files.length === 0) return;
1949
+ e.preventDefault();
1950
+ onFileDrop(files);
1951
+ },
1952
+ [canDrop, onFileDrop]
1953
+ );
1954
+ (0, import_react18.useEffect)(() => {
1900
1955
  setPrompt(value);
1901
1956
  }, [setPrompt, value]);
1902
1957
  const sendPrompt = async () => {
@@ -1911,7 +1966,7 @@ function PromptForm({
1911
1966
  setPrompt("");
1912
1967
  }
1913
1968
  };
1914
- (0, import_react19.useEffect)(() => {
1969
+ (0, import_react18.useEffect)(() => {
1915
1970
  const currentUrl = new URL(location.href);
1916
1971
  const initialPrompt = currentUrl.searchParams.get("initialPrompt");
1917
1972
  if (!hasSetInitialPrompt.current && initialPrompt && prompt === "") {
@@ -1919,7 +1974,7 @@ function PromptForm({
1919
1974
  setPrompt(initialPrompt);
1920
1975
  }
1921
1976
  }, [setPrompt]);
1922
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
1977
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
1923
1978
  "div",
1924
1979
  {
1925
1980
  className: cx7({
@@ -1934,22 +1989,22 @@ function PromptForm({
1934
1989
  onDragOver: onFileDrop ? handleDragOver : void 0,
1935
1990
  onDrop: onFileDrop ? handleDrop : void 0,
1936
1991
  children: [
1937
- isDragOver ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx7("dropOverlay"), children: [
1938
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Paperclip, { size: 20 }),
1939
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: "Attach file" })
1992
+ isDragOver ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: cx7("dropOverlay"), children: [
1993
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Paperclip, { size: 20 }),
1994
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: "Attach file" })
1940
1995
  ] }) : null,
1941
- helperText ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx7("helper"), children: helperText }) : null,
1942
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx7("inner"), children: [
1943
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: cx7("glow") }),
1944
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
1996
+ helperText ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx7("helper"), children: helperText }) : null,
1997
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: cx7("inner"), children: [
1998
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cx7("glow") }),
1999
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1945
2000
  "form",
1946
2001
  {
1947
2002
  onSubmit: (e) => {
1948
2003
  e.preventDefault();
1949
2004
  void sendPrompt();
1950
2005
  },
1951
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx7("formInner"), children: [
1952
- attachments && attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx7("attachments"), children: attachments.map((attachment) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2006
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: cx7("formInner"), children: [
2007
+ attachments && attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cx7("attachments"), children: attachments.map((attachment) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
1953
2008
  "div",
1954
2009
  {
1955
2010
  className: [
@@ -1958,29 +2013,29 @@ function PromptForm({
1958
2013
  attachment.status === "failed" ? cx7("attachmentChipFailed") : ""
1959
2014
  ].filter(Boolean).join(" "),
1960
2015
  children: [
1961
- attachment.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2016
+ attachment.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1962
2017
  LoaderCircle,
1963
2018
  {
1964
2019
  className: cx7("attachmentSpinner"),
1965
2020
  size: 14
1966
2021
  }
1967
2022
  ) : null,
1968
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { title: attachment.filename, children: truncateFilename(attachment.filename) }),
1969
- attachment.status === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: cx7("attachmentError"), children: "Failed" }) : null,
1970
- onRemoveAttachment ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2023
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { title: attachment.filename, children: truncateFilename(attachment.filename) }),
2024
+ attachment.status === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cx7("attachmentError"), children: "Failed" }) : null,
2025
+ onRemoveAttachment ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1971
2026
  "button",
1972
2027
  {
1973
2028
  className: cx7("attachmentRemove"),
1974
2029
  onClick: () => onRemoveAttachment(attachment.clientId),
1975
2030
  type: "button",
1976
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(X, { size: 12 })
2031
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(X, { size: 12 })
1977
2032
  }
1978
2033
  ) : null
1979
2034
  ]
1980
2035
  },
1981
2036
  attachment.clientId
1982
2037
  )) }) : null,
1983
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2038
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
1984
2039
  import_react_textarea_autosize.default,
1985
2040
  {
1986
2041
  className: cx7("input"),
@@ -1997,6 +2052,7 @@ function PromptForm({
1997
2052
  internalRef.current = node;
1998
2053
  },
1999
2054
  onChange: (e) => setPrompt(e.target.value),
2055
+ onPaste: onFileDrop ? handlePaste : void 0,
2000
2056
  onKeyDown: (e) => {
2001
2057
  if (!e.shiftKey && e.key === "Enter") {
2002
2058
  e.preventDefault();
@@ -2010,7 +2066,7 @@ function PromptForm({
2010
2066
  }
2011
2067
  }
2012
2068
  ),
2013
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2069
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2014
2070
  "div",
2015
2071
  {
2016
2072
  className: cx7("actions"),
@@ -2018,7 +2074,7 @@ function PromptForm({
2018
2074
  internalRef?.current?.focus();
2019
2075
  },
2020
2076
  children: [
2021
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2077
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2022
2078
  "div",
2023
2079
  {
2024
2080
  className: cx7("actionsLeft"),
@@ -2026,18 +2082,18 @@ function PromptForm({
2026
2082
  children: actions
2027
2083
  }
2028
2084
  ),
2029
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2085
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2030
2086
  "div",
2031
2087
  {
2032
2088
  className: cx7("actionsRight"),
2033
2089
  onClick: (e) => e.stopPropagation(),
2034
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2090
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2035
2091
  "button",
2036
2092
  {
2037
2093
  className: cx7("actionSubmit"),
2038
2094
  type: "submit",
2039
2095
  disabled: isLoading,
2040
- children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 18 }) : cta ?? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ArrowUp, { size: 24 })
2096
+ children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Loader, { size: 18 }) : cta ?? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ArrowUp, { size: 24 })
2041
2097
  }
2042
2098
  )
2043
2099
  }
@@ -2056,16 +2112,45 @@ function PromptForm({
2056
2112
 
2057
2113
  // src/lib/context.ts
2058
2114
  init_react_import();
2059
- var import_react20 = require("react");
2060
- var toolStatusContext = (0, import_react20.createContext)({});
2115
+ var import_react19 = require("react");
2116
+ var toolStatusContext = (0, import_react19.createContext)({});
2061
2117
  var ToolStatusProvider = toolStatusContext.Provider;
2062
- var hostContext = (0, import_react20.createContext)(void 0);
2118
+ var hostContext = (0, import_react19.createContext)(void 0);
2063
2119
  var HostProvider = hostContext.Provider;
2064
- var subagentStateContext = (0, import_react20.createContext)({});
2120
+ var subagentStateContext = (0, import_react19.createContext)({});
2065
2121
  var SubagentStateProvider = subagentStateContext.Provider;
2066
2122
 
2123
+ // src/lib/use-attachment-url.ts
2124
+ init_react_import();
2125
+ var import_react20 = require("react");
2126
+ function useAttachmentUrl(url, endpoint) {
2127
+ const isRef = getAttachmentIdFromRef(url) !== null;
2128
+ const [fetched, setFetched] = (0, import_react20.useState)();
2129
+ (0, import_react20.useEffect)(() => {
2130
+ if (!isRef) return;
2131
+ const controller = new AbortController();
2132
+ const loadUrl = async () => {
2133
+ try {
2134
+ const resolved = await fetchAttachmentUrl(
2135
+ resolveAttachmentUrl(url, endpoint),
2136
+ controller.signal
2137
+ );
2138
+ setFetched({ ref: url, url: resolved });
2139
+ } catch (error) {
2140
+ if (!controller.signal.aborted) {
2141
+ console.error("Failed to load attachment:", error);
2142
+ }
2143
+ }
2144
+ };
2145
+ loadUrl();
2146
+ return () => controller.abort();
2147
+ }, [isRef, url, endpoint]);
2148
+ if (!isRef) return url;
2149
+ return fetched?.ref === url ? fetched.url : void 0;
2150
+ }
2151
+
2067
2152
  // src/components/ChatBody/index.tsx
2068
- var import_jsx_runtime29 = require("react/jsx-runtime");
2153
+ var import_jsx_runtime28 = require("react/jsx-runtime");
2069
2154
  var cx8 = getClassNameFactory2("Chat", styles_module_default7);
2070
2155
  var cxMessage = getClassNameFactory2("ChatMessage", styles_module_default7);
2071
2156
  function ChatBody({
@@ -2090,7 +2175,7 @@ function ChatBody({
2090
2175
  const lastMessage = hasMessages ? messages[messages.length - 1] : null;
2091
2176
  const lastPart = lastMessage ? lastMessage.parts[lastMessage.parts.length - 1] : null;
2092
2177
  const isLoading = status === "submitted" || status === "streaming" && !lastPart;
2093
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2178
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2094
2179
  "div",
2095
2180
  {
2096
2181
  className: cx8({
@@ -2100,22 +2185,22 @@ function ChatBody({
2100
2185
  isLoading
2101
2186
  }),
2102
2187
  children: [
2103
- children ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("default"), children }) : null,
2104
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("inner"), children: [
2105
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("body"), ref: scrollRef, children: [
2106
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("messages"), ref: contentRef, children: messages.toReversed().filter((message) => !shouldHideMessage(message)).map((message) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChatMessage, { message }, message.id)) }),
2107
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("loader"), children: [
2108
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("loaderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }),
2109
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: "Thinking..." })
2188
+ children ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx8("default"), children }) : null,
2189
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx8("inner"), children: [
2190
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx8("body"), ref: scrollRef, children: [
2191
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx8("messages"), ref: contentRef, children: messages.toReversed().filter((message) => !shouldHideMessage(message)).map((message) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChatMessage, { message }, message.id)) }),
2192
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx8("loader"), children: [
2193
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx8("loaderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 16 }) }),
2194
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: "Thinking..." })
2110
2195
  ] })
2111
2196
  ] }),
2112
- error && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("error"), children: [
2113
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("errorLabel"), children: "Something went wrong." }),
2114
- handleRetry && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("errorAction"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(RotateCcw, { size: "14" }) }) })
2197
+ error && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx8("error"), children: [
2198
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx8("errorLabel"), children: "Something went wrong." }),
2199
+ handleRetry && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx8("errorAction"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(RotateCcw, { size: "14" }) }) })
2115
2200
  ] }),
2116
- userError && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("userError"), children: [
2117
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: userError }),
2118
- onDismissUserError && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2201
+ userError && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx8("userError"), children: [
2202
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: userError }),
2203
+ onDismissUserError && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2119
2204
  "button",
2120
2205
  {
2121
2206
  "aria-label": "Dismiss",
@@ -2123,12 +2208,12 @@ function ChatBody({
2123
2208
  className: cx8("userErrorDismiss"),
2124
2209
  onClick: onDismissUserError,
2125
2210
  type: "button",
2126
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(X, { size: 14 })
2211
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(X, { size: 14 })
2127
2212
  }
2128
2213
  )
2129
2214
  ] }),
2130
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("form"), children: [
2131
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2215
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx8("form"), children: [
2216
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2132
2217
  PromptForm,
2133
2218
  {
2134
2219
  actions,
@@ -2142,7 +2227,7 @@ function ChatBody({
2142
2227
  placeholder: "What do you want to build?"
2143
2228
  }
2144
2229
  ),
2145
- examplePrompts ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("examplePrompts"), children: examplePrompts }) : null
2230
+ examplePrompts ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx8("examplePrompts"), children: examplePrompts }) : null
2146
2231
  ] })
2147
2232
  ] })
2148
2233
  ]
@@ -2171,13 +2256,13 @@ function ChatMessage({ message }) {
2171
2256
  if (role === "user") {
2172
2257
  const attachmentParts = parts.filter((part) => part.type === "file");
2173
2258
  const otherParts = parts.filter((part) => part.type !== "file");
2174
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2259
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2175
2260
  "div",
2176
2261
  {
2177
2262
  className: cxMessage({ userRole: true }),
2178
2263
  "data-message-id": message.id,
2179
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cxMessage("userBubble"), children: [
2180
- otherParts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2264
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cxMessage("userBubble"), children: [
2265
+ otherParts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2181
2266
  ChatMessagePart,
2182
2267
  {
2183
2268
  part,
@@ -2185,7 +2270,7 @@ function ChatMessage({ message }) {
2185
2270
  },
2186
2271
  `${message.id}-${part.type}-${i}`
2187
2272
  )),
2188
- attachmentParts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("userAttachments"), children: attachmentParts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2273
+ attachmentParts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("userAttachments"), children: attachmentParts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2189
2274
  ChatAttachmentThumbnail,
2190
2275
  {
2191
2276
  filename: part.filename,
@@ -2198,12 +2283,12 @@ function ChatMessage({ message }) {
2198
2283
  }
2199
2284
  );
2200
2285
  }
2201
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2286
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2202
2287
  "div",
2203
2288
  {
2204
2289
  className: cxMessage({ [`${role}Role`]: true }),
2205
2290
  "data-message-id": message.id,
2206
- children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2291
+ children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2207
2292
  ChatMessagePart,
2208
2293
  {
2209
2294
  part,
@@ -2221,11 +2306,11 @@ function ChatAttachmentThumbnail({
2221
2306
  }) {
2222
2307
  const host = (0, import_react21.useContext)(hostContext);
2223
2308
  const endpoint = host ? `${host.replace(/\/$/, "")}/attachments` : "/api/puck/chat/attachments";
2224
- const resolvedUrl = resolveAttachmentUrl(url, endpoint);
2309
+ const resolvedUrl = useAttachmentUrl(url, endpoint);
2225
2310
  const attachmentId = getAttachmentIdFromRef(url);
2226
2311
  const label = filename || attachmentId || "Attachment";
2227
2312
  const isImage = mediaType.startsWith("image/");
2228
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2313
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2229
2314
  "a",
2230
2315
  {
2231
2316
  "aria-label": label,
@@ -2235,8 +2320,8 @@ function ChatAttachmentThumbnail({
2235
2320
  target: "_blank",
2236
2321
  title: label,
2237
2322
  children: [
2238
- isImage ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("img", { alt: label, src: resolvedUrl }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FileText, { size: 20 }),
2239
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: cxMessage("thumbnailLabel"), children: label })
2323
+ isImage ? resolvedUrl && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("img", { alt: label, src: resolvedUrl }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FileText, { size: 20 }),
2324
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: cxMessage("thumbnailLabel"), children: label })
2240
2325
  ]
2241
2326
  }
2242
2327
  );
@@ -2251,9 +2336,9 @@ function ChatMessageWrapper({
2251
2336
  role
2252
2337
  }) {
2253
2338
  if (role === "assistant" || role === "user") {
2254
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react_markdown.default, { children });
2339
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react_markdown.default, { children });
2255
2340
  }
2256
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children });
2341
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children });
2257
2342
  }
2258
2343
  function ReasoningBlock({ part }) {
2259
2344
  const startTimeRef = (0, import_react21.useRef)(null);
@@ -2268,7 +2353,7 @@ function ReasoningBlock({ part }) {
2268
2353
  }, [part.state]);
2269
2354
  const loading = part.state ? part.state !== "done" : false;
2270
2355
  const label = durationSecs !== null ? `Thought for ${durationSecs}s` : !loading ? "Thought for a while" : "Thinking...";
2271
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2356
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2272
2357
  ChatEvent,
2273
2358
  {
2274
2359
  status: {
@@ -2276,7 +2361,7 @@ function ReasoningBlock({ part }) {
2276
2361
  loading,
2277
2362
  summary: part.text
2278
2363
  },
2279
- icon: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Brain, { size: 18 })
2364
+ icon: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Brain, { size: 18 })
2280
2365
  }
2281
2366
  );
2282
2367
  }
@@ -2285,19 +2370,19 @@ function ChatMessagePart({
2285
2370
  role
2286
2371
  }) {
2287
2372
  if (part.type === "text") {
2288
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("text"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChatMessageWrapper, { role, children: part.text }) });
2373
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("text"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChatMessageWrapper, { role, children: part.text }) });
2289
2374
  }
2290
2375
  if (part.type === "reasoning") {
2291
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ReasoningBlock, { part });
2376
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ReasoningBlock, { part });
2292
2377
  }
2293
2378
  if (part.type === "tool-subagent") {
2294
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SubagentBlock, { toolCallId: part.toolCallId });
2379
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SubagentBlock, { toolCallId: part.toolCallId });
2295
2380
  }
2296
2381
  if (part.type.startsWith("tool-")) {
2297
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PuckTool, { ...part });
2382
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PuckTool, { ...part });
2298
2383
  }
2299
2384
  if (part.type === "file") {
2300
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2385
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2301
2386
  ChatAttachment,
2302
2387
  {
2303
2388
  filename: part.filename,
@@ -2315,15 +2400,15 @@ function ChatAttachment({
2315
2400
  }) {
2316
2401
  const host = (0, import_react21.useContext)(hostContext);
2317
2402
  const endpoint = host ? `${host.replace(/\/$/, "")}/attachments` : "/api/puck/chat/attachments";
2318
- const resolvedUrl = resolveAttachmentUrl(url, endpoint);
2403
+ const resolvedUrl = useAttachmentUrl(url, endpoint);
2319
2404
  const attachmentId = getAttachmentIdFromRef(url);
2320
2405
  const label = filename || attachmentId || "Attachment";
2321
2406
  if (mediaType.startsWith("image/")) {
2322
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("attachmentImage"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("a", { href: resolvedUrl, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("img", { alt: label, src: resolvedUrl }) }) });
2407
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("attachmentImage"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { href: resolvedUrl, target: "_blank", rel: "noreferrer", children: resolvedUrl && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("img", { alt: label, src: resolvedUrl }) }) });
2323
2408
  }
2324
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("attachmentFile"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("a", { href: resolvedUrl, target: "_blank", rel: "noreferrer", children: [
2325
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FileText, { size: 16 }),
2326
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: label })
2409
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("attachmentFile"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("a", { href: resolvedUrl, target: "_blank", rel: "noreferrer", children: [
2410
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FileText, { size: 16 }),
2411
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: label })
2327
2412
  ] }) });
2328
2413
  }
2329
2414
  function PuckTool({
@@ -2337,19 +2422,19 @@ function PuckTool({
2337
2422
  const status = outputObj && "status" in outputObj ? outputObj.status : toolStatus ?? { loading: true, label: defaultLabel };
2338
2423
  let icon = (0, import_react21.useMemo)(() => {
2339
2424
  if (type === "tool-write") {
2340
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Pen, { size: 18 });
2425
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Pen, { size: 18 });
2341
2426
  } else if (type === "tool-refreshPageData") {
2342
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(GitPullRequest, { size: 18 });
2427
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(GitPullRequest, { size: 18 });
2343
2428
  } else if (type === "tool-takeScreenshot") {
2344
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Camera, { size: 18 });
2429
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Camera, { size: 18 });
2345
2430
  } else if (type === "tool-fetchUrl") {
2346
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CloudDownload, { size: 18 });
2431
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloudDownload, { size: 18 });
2347
2432
  } else if (type === "tool-screenshotUrl") {
2348
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Camera, { size: 18 });
2433
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Camera, { size: 18 });
2349
2434
  }
2350
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Check, { size: 18 });
2435
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Check, { size: 18 });
2351
2436
  }, [type]);
2352
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChatEvent, { status, icon });
2437
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChatEvent, { status, icon });
2353
2438
  }
2354
2439
  function SubagentBlock({ toolCallId }) {
2355
2440
  const subagentState = (0, import_react21.useContext)(subagentStateContext);
@@ -2362,38 +2447,38 @@ function SubagentBlock({ toolCallId }) {
2362
2447
  const hasBody = !!state && state.parts.length > 0;
2363
2448
  const parts = state?.parts ?? [];
2364
2449
  const [isOpen, setIsOpen] = (0, import_react21.useState)(false);
2365
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2450
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2366
2451
  "details",
2367
2452
  {
2368
2453
  className: cxMessage("event"),
2369
2454
  onToggle: (e) => setIsOpen(e.currentTarget.open),
2370
2455
  children: [
2371
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2456
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2372
2457
  "summary",
2373
2458
  {
2374
2459
  className: cxMessage("eventHeader"),
2375
2460
  style: hasBody ? {} : { color: "var(--puck-color-grey-05) !important", cursor: "unset" },
2376
2461
  children: [
2377
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventIcon"), children: loading ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Bot, { size: 18 }) }),
2378
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventLabel"), children: label }),
2379
- hasBody && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
2380
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventExpand"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Plus, { size: 12 }) }),
2381
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventCollapse"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Minus, { size: 12 }) })
2462
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventIcon"), children: loading ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Bot, { size: 18 }) }),
2463
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventLabel"), children: label }),
2464
+ hasBody && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
2465
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventExpand"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Plus, { size: 12 }) }),
2466
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventCollapse"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Minus, { size: 12 }) })
2382
2467
  ] })
2383
2468
  ]
2384
2469
  }
2385
2470
  ),
2386
- hasBody && isOpen && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventBody"), children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SubagentChildPartRenderer, { part }, `${toolCallId}-${i}`)) })
2471
+ hasBody && isOpen && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventBody"), children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SubagentChildPartRenderer, { part }, `${toolCallId}-${i}`)) })
2387
2472
  ]
2388
2473
  }
2389
2474
  );
2390
2475
  }
2391
2476
  function SubagentChildPartRenderer({ part }) {
2392
2477
  if (part.kind === "text") {
2393
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("text"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react_markdown.default, { children: part.text }) });
2478
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("text"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react_markdown.default, { children: part.text }) });
2394
2479
  }
2395
2480
  if (part.kind === "reasoning") {
2396
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2481
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2397
2482
  ReasoningBlock,
2398
2483
  {
2399
2484
  part: {
@@ -2405,7 +2490,7 @@ function SubagentChildPartRenderer({ part }) {
2405
2490
  );
2406
2491
  }
2407
2492
  if (part.toolName === "subagent") {
2408
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SubagentBlock, { toolCallId: part.childToolCallId });
2493
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SubagentBlock, { toolCallId: part.childToolCallId });
2409
2494
  }
2410
2495
  const synthesized = {
2411
2496
  toolCallId: part.childToolCallId,
@@ -2414,35 +2499,35 @@ function SubagentChildPartRenderer({ part }) {
2414
2499
  input: part.input,
2415
2500
  output: part.output
2416
2501
  };
2417
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PuckTool, { ...synthesized });
2502
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PuckTool, { ...synthesized });
2418
2503
  }
2419
2504
  function ChatEvent({
2420
2505
  status,
2421
- icon = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Check, { size: 18 })
2506
+ icon = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Check, { size: 18 })
2422
2507
  }) {
2423
2508
  const [isOpen, setIsOpen] = (0, import_react21.useState)(false);
2424
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2509
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2425
2510
  "details",
2426
2511
  {
2427
2512
  className: cxMessage("event"),
2428
2513
  onToggle: (e) => setIsOpen(e.currentTarget.open),
2429
2514
  children: [
2430
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2515
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2431
2516
  "summary",
2432
2517
  {
2433
2518
  className: cxMessage("eventHeader"),
2434
2519
  style: status.summary ? {} : { color: "var(--puck-color-grey-05) !important", cursor: "unset" },
2435
2520
  children: [
2436
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventIcon"), children: status.error ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(TriangleAlert, { size: 18 }) : status.loading ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) : icon }),
2437
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: status.label }),
2438
- status.summary && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
2439
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventExpand"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Plus, { size: 12 }) }),
2440
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventCollapse"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Minus, { size: 12 }) })
2521
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventIcon"), children: status.error ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TriangleAlert, { size: 18 }) : status.loading ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Loader, { size: 16 }) : icon }),
2522
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: status.label }),
2523
+ status.summary && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
2524
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventExpand"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Plus, { size: 12 }) }),
2525
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventCollapse"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Minus, { size: 12 }) })
2441
2526
  ] })
2442
2527
  ]
2443
2528
  }
2444
2529
  ),
2445
- status.summary && isOpen && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventBody"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react_markdown.default, { children: status.summary }) })
2530
+ status.summary && isOpen && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cxMessage("eventBody"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_react_markdown.default, { children: status.summary }) })
2446
2531
  ]
2447
2532
  }
2448
2533
  );
@@ -2453,12 +2538,12 @@ function ExamplePrompt({
2453
2538
  onClick,
2454
2539
  disabled
2455
2540
  }) {
2456
- const content = /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
2457
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: label }),
2458
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("examplePromptArrow"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ArrowUp, { size: "16" }) })
2541
+ const content = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
2542
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: label }),
2543
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx8("examplePromptArrow"), children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ArrowUp, { size: "16" }) })
2459
2544
  ] });
2460
2545
  if (href) {
2461
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2546
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2462
2547
  "a",
2463
2548
  {
2464
2549
  className: cx8("examplePrompt"),
@@ -2475,7 +2560,7 @@ function ExamplePrompt({
2475
2560
  }
2476
2561
  );
2477
2562
  }
2478
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2563
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2479
2564
  "button",
2480
2565
  {
2481
2566
  className: cx8("examplePrompt"),
@@ -2515,14 +2600,14 @@ init_react_import();
2515
2600
  var styles_module_default9 = { "DesignModeToggle": "_DesignModeToggle_o5uty_1", "DesignModeToggle-button": "_DesignModeToggle-button_o5uty_8", "DesignModeToggle-button--active": "_DesignModeToggle-button--active_o5uty_28" };
2516
2601
 
2517
2602
  // src/components/DesignModeToggle/index.tsx
2518
- var import_jsx_runtime30 = require("react/jsx-runtime");
2603
+ var import_jsx_runtime29 = require("react/jsx-runtime");
2519
2604
  var cx9 = getClassNameFactory2("DesignModeToggle", styles_module_default9);
2520
2605
  function DesignModeToggle({
2521
2606
  active,
2522
2607
  onToggle,
2523
2608
  disabled
2524
2609
  }) {
2525
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: cx9(), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
2610
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx9(), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2526
2611
  "button",
2527
2612
  {
2528
2613
  className: `${cx9("button")} ${active ? cx9("button--active") : ""}`,
@@ -2531,7 +2616,7 @@ function DesignModeToggle({
2531
2616
  type: "button",
2532
2617
  title: active ? "Disable design mode" : "Enable design mode",
2533
2618
  children: [
2534
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(WandSparkles, { size: 12 }),
2619
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(WandSparkles, { size: 12 }),
2535
2620
  "Design"
2536
2621
  ]
2537
2622
  }
@@ -3751,7 +3836,7 @@ var htmlToReactTree = (html, slots) => {
3751
3836
  init_react_import();
3752
3837
  var import_react23 = require("react");
3753
3838
  var import_react_dom = require("react-dom");
3754
- var import_jsx_runtime31 = require("react/jsx-runtime");
3839
+ var import_jsx_runtime30 = require("react/jsx-runtime");
3755
3840
  var parseInlineStyle = (cssText) => {
3756
3841
  const style = {};
3757
3842
  for (const declaration of cssText.split(";")) {
@@ -3793,13 +3878,13 @@ var SlotPortal = ({
3793
3878
  }, [entry, html, slotName]);
3794
3879
  if (!target || typeof SlotContent !== "function") return null;
3795
3880
  return (0, import_react_dom.createPortal)(
3796
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(SlotContent, { style, className: slotClassName || void 0 }),
3881
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(SlotContent, { style, className: slotClassName || void 0 }),
3797
3882
  target
3798
3883
  );
3799
3884
  };
3800
3885
 
3801
3886
  // src/lib/design/component.tsx
3802
- var import_jsx_runtime32 = require("react/jsx-runtime");
3887
+ var import_jsx_runtime31 = require("react/jsx-runtime");
3803
3888
  var DESIGN_COMPONENT = Symbol("puck-ai.designComponent");
3804
3889
  var isDesignComponent = (config) => !!config?.[DESIGN_COMPONENT];
3805
3890
  var streamingValues = /* @__PURE__ */ new Map();
@@ -3885,13 +3970,13 @@ function createDesignComponentConfig(registration) {
3885
3970
  }
3886
3971
  return resolvedFields;
3887
3972
  },
3888
- render: (renderProps) => renderProps.puck?.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(EditorEntry, { ...renderProps }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Entry, { ...renderProps, getPuck: null })
3973
+ render: (renderProps) => renderProps.puck?.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(EditorEntry, { ...renderProps }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Entry, { ...renderProps, getPuck: null })
3889
3974
  };
3890
3975
  componentConfig[DESIGN_COMPONENT] = true;
3891
3976
  return componentConfig;
3892
3977
  function EditorEntry(renderProps) {
3893
3978
  const getPuck = (0, import_core3.useGetPuck)();
3894
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Entry, { ...renderProps, getPuck });
3979
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Entry, { ...renderProps, getPuck });
3895
3980
  }
3896
3981
  function Entry({
3897
3982
  getPuck,
@@ -3953,7 +4038,7 @@ function createDesignComponentConfig(registration) {
3953
4038
  return attrs;
3954
4039
  }, [annotations, props, puck.isEditing]);
3955
4040
  const editorEntryNode = (0, import_react24.useMemo)(
3956
- () => puck.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ref: setEntryEl }) : null,
4041
+ () => puck.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ref: setEntryEl }) : null,
3957
4042
  [puck.isEditing]
3958
4043
  );
3959
4044
  (0, import_react24.useEffect)(() => {
@@ -4080,7 +4165,7 @@ function createDesignComponentConfig(registration) {
4080
4165
  for (const slot of annotations.slots) {
4081
4166
  const Slot = props[slot.name];
4082
4167
  if (typeof Slot === "function") {
4083
- slotContent[slot.name] = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4168
+ slotContent[slot.name] = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4084
4169
  Slot,
4085
4170
  {
4086
4171
  style: slot.style ? parseStyleString(slot.style) : void 0,
@@ -4089,17 +4174,17 @@ function createDesignComponentConfig(registration) {
4089
4174
  );
4090
4175
  }
4091
4176
  }
4092
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
4093
- styles && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: styles }),
4094
- style && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: style }),
4095
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ref: setEntryEl, ...fieldValueAttrs, children: htmlToReactTree(patchedHtml, slotContent) })
4177
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
4178
+ styles && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("style", { children: styles }),
4179
+ style && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("style", { children: style }),
4180
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ref: setEntryEl, ...fieldValueAttrs, children: htmlToReactTree(patchedHtml, slotContent) })
4096
4181
  ] });
4097
4182
  }
4098
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
4099
- styles && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: styles }),
4100
- style && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: style }),
4183
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
4184
+ styles && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("style", { children: styles }),
4185
+ style && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("style", { children: style }),
4101
4186
  editorEntryNode,
4102
- entryEl && annotations.slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4187
+ entryEl && annotations.slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4103
4188
  SlotPortal,
4104
4189
  {
4105
4190
  entry: entryEl,
@@ -4118,7 +4203,7 @@ function createDesignComponentConfig(registration) {
4118
4203
  // src/lib/design/globals.tsx
4119
4204
  init_react_import();
4120
4205
  var import_react25 = require("react");
4121
- var import_jsx_runtime33 = require("react/jsx-runtime");
4206
+ var import_jsx_runtime32 = require("react/jsx-runtime");
4122
4207
  function getDynamicConfigGlobals(dynamicConfig) {
4123
4208
  if (typeof dynamicConfig !== "object" || dynamicConfig === null) return {};
4124
4209
  const { styles, script } = dynamicConfig;
@@ -4148,10 +4233,10 @@ function DesignGlobals({
4148
4233
  scriptRef.current = null;
4149
4234
  };
4150
4235
  }, [script]);
4151
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
4152
- isEditing && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("style", { children: INLINE_EDIT_RESET }),
4153
- styles && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("style", { children: styles }),
4154
- script && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ref: hostRef, style: { display: "none" } })
4236
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
4237
+ isEditing && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: INLINE_EDIT_RESET }),
4238
+ styles && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: styles }),
4239
+ script && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ref: hostRef, style: { display: "none" } })
4155
4240
  ] });
4156
4241
  }
4157
4242
  var WRAPPED = "__puckAiDesignGlobals";
@@ -4161,8 +4246,8 @@ function withDesignGlobals(root) {
4161
4246
  const userRender = root?.render;
4162
4247
  const render = (props) => {
4163
4248
  const { styles, script } = getDynamicConfigGlobals(props._dynamicConfig);
4164
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
4165
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
4249
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
4250
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4166
4251
  DesignGlobals,
4167
4252
  {
4168
4253
  styles,
@@ -4184,7 +4269,7 @@ function ensureDesignGlobalsRoot(config) {
4184
4269
  }
4185
4270
 
4186
4271
  // src/lib/design/runtime.tsx
4187
- var import_jsx_runtime34 = require("react/jsx-runtime");
4272
+ var import_jsx_runtime33 = require("react/jsx-runtime");
4188
4273
  var cachedFieldMetadata;
4189
4274
  function detectFieldMetadata(config) {
4190
4275
  for (const comp of Object.values(config.components)) {
@@ -4223,7 +4308,7 @@ function applyConfigFieldMetadata(config, dynamicComponents) {
4223
4308
  var DESIGNED_CATEGORY = "dynamic";
4224
4309
  var dynamicConfigRootField = {
4225
4310
  type: "custom",
4226
- render: () => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {}),
4311
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", {}),
4227
4312
  ai: {
4228
4313
  exclude: true
4229
4314
  }
@@ -4473,6 +4558,14 @@ var getDocumentSize = (root) => {
4473
4558
  };
4474
4559
  };
4475
4560
 
4561
+ // src/lib/screenshot-overflow.ts
4562
+ init_react_import();
4563
+ var applyBrowserOverflowStylesTo = (document2) => {
4564
+ for (const element of [document2.documentElement, document2.body]) {
4565
+ element?.style.setProperty("overflow", "visible", "important");
4566
+ }
4567
+ };
4568
+
4476
4569
  // src/lib/capture-screenshot.ts
4477
4570
  var editorOnlyClassPrefixes = ["_DraggableComponent--hover", "_ActionBar"];
4478
4571
  var releaseCanvas = (canvas) => {
@@ -4483,14 +4576,14 @@ var drawScaled = (source, ratio) => {
4483
4576
  const target = document.createElement("canvas");
4484
4577
  target.width = scaleDimension(source.width, ratio);
4485
4578
  target.height = scaleDimension(source.height, ratio);
4486
- const ctx2 = target.getContext("2d");
4487
- if (!ctx2) {
4579
+ const ctx = target.getContext("2d");
4580
+ if (!ctx) {
4488
4581
  releaseCanvas(target);
4489
4582
  return source;
4490
4583
  }
4491
- ctx2.imageSmoothingEnabled = true;
4492
- ctx2.imageSmoothingQuality = "high";
4493
- ctx2.drawImage(source, 0, 0, target.width, target.height);
4584
+ ctx.imageSmoothingEnabled = true;
4585
+ ctx.imageSmoothingQuality = "high";
4586
+ ctx.drawImage(source, 0, 0, target.width, target.height);
4494
4587
  return target;
4495
4588
  };
4496
4589
  var fitCanvas = (canvas) => {
@@ -4541,6 +4634,7 @@ var captureScreenshot = async (root, { scale = CAPTURE_SCALE, quality = 0.8, wid
4541
4634
  allowTaint: false,
4542
4635
  useCORS: true,
4543
4636
  scrollY: 0,
4637
+ onclone: applyBrowserOverflowStylesTo,
4544
4638
  ignoreElements: (el) => Array.from(el.classList).some(
4545
4639
  (c) => editorOnlyClassPrefixes.some((prefix) => c.startsWith(prefix))
4546
4640
  )
@@ -4570,12 +4664,12 @@ async function postClientToolResponse(host, body) {
4570
4664
  }
4571
4665
 
4572
4666
  // src/components/Chat/index.tsx
4573
- var import_jsx_runtime35 = require("react/jsx-runtime");
4667
+ var import_jsx_runtime34 = require("react/jsx-runtime");
4574
4668
  var q = (0, import_qler.default)();
4575
4669
  var DEFAULT_API_VERSION = "v2";
4576
4670
  var BUILD_OP_DEBOUNCE_MS = 1e3 / 60;
4577
4671
  var CLIENT_TOOL_ENDPOINT_UNAVAILABLE_ERROR_MESSAGE = "Unable to verify the page data. Please enable the `/chat/tool` endpoint on the server and try again.";
4578
- var PLUGIN_AI_VERSION = true ? "0.9.0-canary.c31f0e8f" : "unknown";
4672
+ var PLUGIN_AI_VERSION = true ? "0.9.0-canary.c5c8a6ec" : "unknown";
4579
4673
  var BENCHMARK = false;
4580
4674
  var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${(0, import_ulid.ulid)()}`;
4581
4675
  var getClassName18 = getClassNameFactory("Chat", styles_module_default);
@@ -4777,12 +4871,14 @@ function Chat2(props) {
4777
4871
  }
4778
4872
  case "data-client-request": {
4779
4873
  const { requestId, action } = dataPart.data;
4874
+ const chatId = localChatId.current || void 0;
4780
4875
  if (action === "getPageData") {
4781
4876
  debouncedFlushBuildOps.flush();
4782
4877
  q.wait().then(() => {
4783
4878
  const { appState } = getPuck();
4784
4879
  return sendClientToolResponse({
4785
4880
  id: requestId,
4881
+ chatId,
4786
4882
  responses: [{ action, output: appState.data }]
4787
4883
  });
4788
4884
  }).catch((e) => {
@@ -4812,12 +4908,14 @@ function Chat2(props) {
4812
4908
  }
4813
4909
  return sendClientToolResponse({
4814
4910
  id: requestId,
4911
+ chatId,
4815
4912
  responses: [{ action, output: { sizeBytes: blob.size } }]
4816
4913
  });
4817
4914
  }).catch((e) => {
4818
4915
  console.error("Failed to respond to client request:", e);
4819
4916
  return sendClientToolResponse({
4820
4917
  id: requestId,
4918
+ chatId,
4821
4919
  responses: [{ action, output: { sizeBytes: 0 } }]
4822
4920
  });
4823
4921
  });
@@ -5254,13 +5352,13 @@ function Chat2(props) {
5254
5352
  };
5255
5353
  });
5256
5354
  }, [messages, toolStatus]);
5257
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName18(), ref: pluginRef, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(HostProvider, { value: host, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ToolStatusProvider, { value: toolStatus, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(SubagentStateProvider, { value: subagentState, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5355
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: getClassName18(), ref: pluginRef, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(HostProvider, { value: host, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(ToolStatusProvider, { value: toolStatus, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(SubagentStateProvider, { value: subagentState, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5258
5356
  ChatBody,
5259
5357
  {
5260
5358
  messages: messagesWithStatuses,
5261
5359
  onFileDrop: attachmentConfig.enabled ? handleFiles : void 0,
5262
- actions: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
5263
- attachmentConfig.enabled ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5360
+ actions: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
5361
+ attachmentConfig.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5264
5362
  AttachmentComposer,
5265
5363
  {
5266
5364
  accept: attachmentConfig.accept,
@@ -5273,7 +5371,7 @@ function Chat2(props) {
5273
5371
  typeof chatActions === "function" ? chatActions({
5274
5372
  disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming"
5275
5373
  }) : chatActions,
5276
- designModeVisible ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5374
+ designModeVisible ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5277
5375
  DesignModeToggle,
5278
5376
  {
5279
5377
  active: mode === "design",
@@ -5290,7 +5388,7 @@ function Chat2(props) {
5290
5388
  inputRef,
5291
5389
  status: resolvedStatus,
5292
5390
  examplePrompts: examplePrompts?.map(
5293
- ({ label, href, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5391
+ ({ label, href, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5294
5392
  ExamplePrompt,
5295
5393
  {
5296
5394
  label,
@@ -5309,7 +5407,7 @@ function Chat2(props) {
5309
5407
  },
5310
5408
  userError,
5311
5409
  onDismissUserError: () => setUserError(""),
5312
- children: placeholder ?? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5410
+ children: placeholder ?? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5313
5411
  Placeholder,
5314
5412
  {
5315
5413
  dispatch: puckDispatch,
@@ -5428,8 +5526,8 @@ function AttachmentComposer({
5428
5526
  }) {
5429
5527
  const id = (0, import_react27.useId)();
5430
5528
  const inputId = (0, import_react27.useMemo)(() => `attachment-input-${id}`, []);
5431
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName18("attachmentControls"), children: [
5432
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5529
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName18("attachmentControls"), children: [
5530
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5433
5531
  "input",
5434
5532
  {
5435
5533
  accept: accept.join(","),
@@ -5441,7 +5539,7 @@ function AttachmentComposer({
5441
5539
  type: "file"
5442
5540
  }
5443
5541
  ),
5444
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5542
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5445
5543
  "button",
5446
5544
  {
5447
5545
  "aria-label": "Attach files",
@@ -5450,7 +5548,7 @@ function AttachmentComposer({
5450
5548
  onClick: () => document.getElementById(inputId)?.click(),
5451
5549
  title: "Attach files",
5452
5550
  type: "button",
5453
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Paperclip, { size: 14 })
5551
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Paperclip, { size: 14 })
5454
5552
  }
5455
5553
  )
5456
5554
  ] });
@@ -5473,12 +5571,12 @@ function Placeholder({
5473
5571
  }
5474
5572
  }, 10);
5475
5573
  };
5476
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName18("placeholder"), children: [
5477
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassName18("placeholderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Sparkles, { "aria-hidden": "true", size: 28 }) }),
5478
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("strong", { className: getClassName18("placeholderTitle"), children: "Build with AI" }),
5479
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassName18("placeholderDescription"), children: "Describe what you want to create or change." }),
5480
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName18("actions"), children: [
5481
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5574
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName18("placeholder"), children: [
5575
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: getClassName18("placeholderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Sparkles, { "aria-hidden": "true", size: 28 }) }),
5576
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("strong", { className: getClassName18("placeholderTitle"), children: "Build with AI" }),
5577
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: getClassName18("placeholderDescription"), children: "Describe what you want to create or change." }),
5578
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName18("actions"), children: [
5579
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5482
5580
  "button",
5483
5581
  {
5484
5582
  className: getClassName18("action"),
@@ -5487,7 +5585,7 @@ function Placeholder({
5487
5585
  children: "Write a prompt"
5488
5586
  }
5489
5587
  ),
5490
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5588
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5491
5589
  "button",
5492
5590
  {
5493
5591
  className: getClassName18("actionOutlined"),
@@ -5638,7 +5736,7 @@ init_react_import();
5638
5736
  var styles_module_default10 = { "ManageComponents-cta": "_ManageComponents-cta_xifz3_1", "ManageComponents-list": "_ManageComponents-list_xifz3_22", "ManageComponents-item": "_ManageComponents-item_xifz3_29", "ManageComponents-delete": "_ManageComponents-delete_xifz3_41", "ManageComponents-empty": "_ManageComponents-empty_xifz3_57" };
5639
5737
 
5640
5738
  // src/components/ManageComponents/index.tsx
5641
- var import_jsx_runtime36 = require("react/jsx-runtime");
5739
+ var import_jsx_runtime35 = require("react/jsx-runtime");
5642
5740
  var cx10 = getClassNameFactory2("ManageComponents", styles_module_default10);
5643
5741
  var useRegistrations = () => (0, import_react30.useSyncExternalStore)(
5644
5742
  registrationStore.subscribe,
@@ -5661,14 +5759,14 @@ function ManageModalContent({ onClose }) {
5661
5759
  }
5662
5760
  };
5663
5761
  if (confirmTarget) {
5664
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5762
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5665
5763
  ActionModal,
5666
5764
  {
5667
5765
  title: "Delete component",
5668
5766
  hideButton: true,
5669
- actions: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Inline, { children: [
5670
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Button, { variant: "secondary", onClick: () => setConfirmTarget(null), children: "Cancel" }),
5671
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5767
+ actions: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Inline, { children: [
5768
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { variant: "secondary", onClick: () => setConfirmTarget(null), children: "Cancel" }),
5769
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5672
5770
  Button,
5673
5771
  {
5674
5772
  variant: "danger",
@@ -5677,31 +5775,31 @@ function ManageModalContent({ onClose }) {
5677
5775
  }
5678
5776
  )
5679
5777
  ] }),
5680
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { children: [
5778
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { children: [
5681
5779
  "Are you sure you want to delete ",
5682
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("b", { children: confirmTarget.label }),
5780
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("b", { children: confirmTarget.label }),
5683
5781
  "?"
5684
5782
  ] })
5685
5783
  }
5686
5784
  );
5687
5785
  }
5688
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ActionModal, { title: "Manage components", hideButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: cx10("list"), children: [
5689
- entries.map(([name, reg]) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: cx10("item"), children: [
5690
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: cx10("itemName"), children: reg.label || name }),
5691
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
5786
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ActionModal, { title: "Manage components", hideButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: cx10("list"), children: [
5787
+ entries.map(([name, reg]) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: cx10("item"), children: [
5788
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: cx10("itemName"), children: reg.label || name }),
5789
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
5692
5790
  "button",
5693
5791
  {
5694
5792
  className: cx10("delete"),
5695
5793
  onClick: () => setConfirmTarget({ name, label: reg.label || name }),
5696
5794
  type: "button",
5697
5795
  children: [
5698
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Trash2, { size: 12 }),
5796
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Trash2, { size: 12 }),
5699
5797
  "Delete"
5700
5798
  ]
5701
5799
  }
5702
5800
  )
5703
5801
  ] }, name)),
5704
- entries.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: cx10("empty"), children: "No dynamic components" })
5802
+ entries.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: cx10("empty"), children: "No dynamic components" })
5705
5803
  ] }) });
5706
5804
  }
5707
5805
  function ManageComponentsCta() {
@@ -5709,12 +5807,12 @@ function ManageComponentsCta() {
5709
5807
  const entries = useRegistrations();
5710
5808
  const handleClose = (0, import_react30.useCallback)(() => setOpen(false), []);
5711
5809
  if (entries.length === 0) return null;
5712
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
5713
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("button", { className: cx10("cta"), onClick: () => setOpen(true), type: "button", children: [
5714
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Settings, { size: 14 }),
5810
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
5811
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("button", { className: cx10("cta"), onClick: () => setOpen(true), type: "button", children: [
5812
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Settings, { size: 14 }),
5715
5813
  "Manage components"
5716
5814
  ] }),
5717
- open && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ModalProvider, { defaultVisible: true, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ManageModalContent, { onClose: handleClose }) })
5815
+ open && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ModalProvider, { defaultVisible: true, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ManageModalContent, { onClose: handleClose }) })
5718
5816
  ] });
5719
5817
  }
5720
5818
 
@@ -5723,22 +5821,22 @@ init_react_import();
5723
5821
  var styles_module_default11 = { "Drawer--empty": "_Drawer--empty_8e8cs_1" };
5724
5822
 
5725
5823
  // src/components/Drawer/index.tsx
5726
- var import_jsx_runtime37 = require("react/jsx-runtime");
5824
+ var import_jsx_runtime36 = require("react/jsx-runtime");
5727
5825
  var usePuck2 = (0, import_core7.createUsePuck)();
5728
5826
  var cx11 = get_class_name_factory_default("Drawer", styles_module_default11);
5729
5827
  var createDrawer = (designModeVisible) => function Drawer({ children }) {
5730
5828
  const config = usePuck2((s) => s.config);
5731
5829
  if (Object.keys(config.components).length === 0) {
5732
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: cx11({ empty: true }), children: "No blocks" });
5830
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: cx11({ empty: true }), children: "No blocks" });
5733
5831
  }
5734
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: cx11(), children: [
5832
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: cx11(), children: [
5735
5833
  children,
5736
- designModeVisible && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ManageComponentsCta, {})
5834
+ designModeVisible && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ManageComponentsCta, {})
5737
5835
  ] });
5738
5836
  };
5739
5837
 
5740
5838
  // src/index.tsx
5741
- var import_jsx_runtime38 = require("react/jsx-runtime");
5839
+ var import_jsx_runtime37 = require("react/jsx-runtime");
5742
5840
  function withDynamicConfig(config, data) {
5743
5841
  const registrations = getPersistedRegistrations(data);
5744
5842
  const dynamicConfig = {};
@@ -5775,16 +5873,16 @@ function createAiPlugin(opts) {
5775
5873
  return {
5776
5874
  label: "AI",
5777
5875
  name: "ai",
5778
- render: () => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Chat2, { ...rest, scrollTrackingId }),
5779
- icon: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Bot, {}),
5876
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Chat2, { ...rest, scrollTrackingId }),
5877
+ icon: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Bot, {}),
5780
5878
  mobilePanelHeight: "min-content",
5781
5879
  overrides: {
5782
5880
  drawer: createDrawer(designModeVisible),
5783
5881
  preview: ({ children }) => {
5784
5882
  if (scrollTracking) {
5785
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ScrollTracking, { trackingId: scrollTrackingId, children });
5883
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ScrollTracking, { trackingId: scrollTrackingId, children });
5786
5884
  }
5787
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
5885
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_jsx_runtime37.Fragment, { children });
5788
5886
  }
5789
5887
  }
5790
5888
  };