@puckeditor/plugin-ai 0.9.0-canary.51cc139e → 0.9.0-canary.53ee4e95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +298 -303
  2. package/dist/index.mjs +174 -179
  3. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -995,7 +995,7 @@ function useChat({
995
995
  // src/components/Chat/index.tsx
996
996
  var import_core5 = require("@puckeditor/core");
997
997
  var import_ai5 = require("ai");
998
- var import_react28 = require("react");
998
+ var import_react27 = require("react");
999
999
  var import_ulid = require("ulid");
1000
1000
 
1001
1001
  // ../utils/lib/get-class-name-factory.ts
@@ -1038,7 +1038,7 @@ var styles_module_default = { "Chat": "_Chat_1ei0a_1", "Chat-header": "_Chat-hea
1038
1038
 
1039
1039
  // src/components/ChatBody/index.tsx
1040
1040
  init_react_import();
1041
- var import_react22 = require("react");
1041
+ var import_react21 = require("react");
1042
1042
  var import_use_stick_to_bottom = require("use-stick-to-bottom");
1043
1043
  var import_react_markdown = __toESM(require("react-markdown"));
1044
1044
 
@@ -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
  }
@@ -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();
@@ -1886,7 +1881,7 @@ var truncateFilename = (name, max = 25) => {
1886
1881
  };
1887
1882
 
1888
1883
  // src/components/PromptForm/index.tsx
1889
- var import_jsx_runtime28 = require("react/jsx-runtime");
1884
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1890
1885
  var cx7 = getClassNameFactory2("PromptForm", styles_module_default8);
1891
1886
  function PromptForm({
1892
1887
  actions,
@@ -1906,13 +1901,13 @@ function PromptForm({
1906
1901
  maxRows = 5,
1907
1902
  value = ""
1908
1903
  }) {
1909
- const hasSetInitialPrompt = (0, import_react19.useRef)(false);
1910
- const [prompt, setPrompt] = (0, import_react19.useState)(value);
1911
- const internalRef = (0, import_react19.useRef)(null);
1912
- const [isDragOver, setIsDragOver] = (0, import_react19.useState)(false);
1913
- 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);
1914
1909
  const canDrop = !!onFileDrop && !isDisabled && !isLoading;
1915
- const handleDragEnter = (0, import_react19.useCallback)(
1910
+ const handleDragEnter = (0, import_react18.useCallback)(
1916
1911
  (e) => {
1917
1912
  e.preventDefault();
1918
1913
  dragCounterRef.current++;
@@ -1922,17 +1917,17 @@ function PromptForm({
1922
1917
  },
1923
1918
  [canDrop]
1924
1919
  );
1925
- const handleDragLeave = (0, import_react19.useCallback)((e) => {
1920
+ const handleDragLeave = (0, import_react18.useCallback)((e) => {
1926
1921
  e.preventDefault();
1927
1922
  dragCounterRef.current--;
1928
1923
  if (dragCounterRef.current === 0) {
1929
1924
  setIsDragOver(false);
1930
1925
  }
1931
1926
  }, []);
1932
- const handleDragOver = (0, import_react19.useCallback)((e) => {
1927
+ const handleDragOver = (0, import_react18.useCallback)((e) => {
1933
1928
  e.preventDefault();
1934
1929
  }, []);
1935
- const handleDrop = (0, import_react19.useCallback)(
1930
+ const handleDrop = (0, import_react18.useCallback)(
1936
1931
  (e) => {
1937
1932
  e.preventDefault();
1938
1933
  dragCounterRef.current = 0;
@@ -1946,7 +1941,7 @@ function PromptForm({
1946
1941
  },
1947
1942
  [canDrop, onFileDrop]
1948
1943
  );
1949
- const handlePaste = (0, import_react19.useCallback)(
1944
+ const handlePaste = (0, import_react18.useCallback)(
1950
1945
  (e) => {
1951
1946
  if (!canDrop) return;
1952
1947
  const files = getFilesFromClipboard(e.clipboardData);
@@ -1956,7 +1951,7 @@ function PromptForm({
1956
1951
  },
1957
1952
  [canDrop, onFileDrop]
1958
1953
  );
1959
- (0, import_react19.useEffect)(() => {
1954
+ (0, import_react18.useEffect)(() => {
1960
1955
  setPrompt(value);
1961
1956
  }, [setPrompt, value]);
1962
1957
  const sendPrompt = async () => {
@@ -1971,7 +1966,7 @@ function PromptForm({
1971
1966
  setPrompt("");
1972
1967
  }
1973
1968
  };
1974
- (0, import_react19.useEffect)(() => {
1969
+ (0, import_react18.useEffect)(() => {
1975
1970
  const currentUrl = new URL(location.href);
1976
1971
  const initialPrompt = currentUrl.searchParams.get("initialPrompt");
1977
1972
  if (!hasSetInitialPrompt.current && initialPrompt && prompt === "") {
@@ -1979,7 +1974,7 @@ function PromptForm({
1979
1974
  setPrompt(initialPrompt);
1980
1975
  }
1981
1976
  }, [setPrompt]);
1982
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
1977
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
1983
1978
  "div",
1984
1979
  {
1985
1980
  className: cx7({
@@ -1994,22 +1989,22 @@ function PromptForm({
1994
1989
  onDragOver: onFileDrop ? handleDragOver : void 0,
1995
1990
  onDrop: onFileDrop ? handleDrop : void 0,
1996
1991
  children: [
1997
- isDragOver ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx7("dropOverlay"), children: [
1998
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Paperclip, { size: 20 }),
1999
- /* @__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" })
2000
1995
  ] }) : null,
2001
- helperText ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: cx7("helper"), children: helperText }) : null,
2002
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx7("inner"), children: [
2003
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: cx7("glow") }),
2004
- /* @__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)(
2005
2000
  "form",
2006
2001
  {
2007
2002
  onSubmit: (e) => {
2008
2003
  e.preventDefault();
2009
2004
  void sendPrompt();
2010
2005
  },
2011
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: cx7("formInner"), children: [
2012
- 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)(
2013
2008
  "div",
2014
2009
  {
2015
2010
  className: [
@@ -2018,29 +2013,29 @@ function PromptForm({
2018
2013
  attachment.status === "failed" ? cx7("attachmentChipFailed") : ""
2019
2014
  ].filter(Boolean).join(" "),
2020
2015
  children: [
2021
- attachment.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2016
+ attachment.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2022
2017
  LoaderCircle,
2023
2018
  {
2024
2019
  className: cx7("attachmentSpinner"),
2025
2020
  size: 14
2026
2021
  }
2027
2022
  ) : null,
2028
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { title: attachment.filename, children: truncateFilename(attachment.filename) }),
2029
- attachment.status === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: cx7("attachmentError"), children: "Failed" }) : null,
2030
- 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)(
2031
2026
  "button",
2032
2027
  {
2033
2028
  className: cx7("attachmentRemove"),
2034
2029
  onClick: () => onRemoveAttachment(attachment.clientId),
2035
2030
  type: "button",
2036
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(X, { size: 12 })
2031
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(X, { size: 12 })
2037
2032
  }
2038
2033
  ) : null
2039
2034
  ]
2040
2035
  },
2041
2036
  attachment.clientId
2042
2037
  )) }) : null,
2043
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2038
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2044
2039
  import_react_textarea_autosize.default,
2045
2040
  {
2046
2041
  className: cx7("input"),
@@ -2071,7 +2066,7 @@ function PromptForm({
2071
2066
  }
2072
2067
  }
2073
2068
  ),
2074
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2069
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2075
2070
  "div",
2076
2071
  {
2077
2072
  className: cx7("actions"),
@@ -2079,7 +2074,7 @@ function PromptForm({
2079
2074
  internalRef?.current?.focus();
2080
2075
  },
2081
2076
  children: [
2082
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2077
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2083
2078
  "div",
2084
2079
  {
2085
2080
  className: cx7("actionsLeft"),
@@ -2087,18 +2082,18 @@ function PromptForm({
2087
2082
  children: actions
2088
2083
  }
2089
2084
  ),
2090
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2085
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2091
2086
  "div",
2092
2087
  {
2093
2088
  className: cx7("actionsRight"),
2094
2089
  onClick: (e) => e.stopPropagation(),
2095
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2090
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2096
2091
  "button",
2097
2092
  {
2098
2093
  className: cx7("actionSubmit"),
2099
2094
  type: "submit",
2100
2095
  disabled: isLoading,
2101
- 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 })
2102
2097
  }
2103
2098
  )
2104
2099
  }
@@ -2117,21 +2112,21 @@ function PromptForm({
2117
2112
 
2118
2113
  // src/lib/context.ts
2119
2114
  init_react_import();
2120
- var import_react20 = require("react");
2121
- var toolStatusContext = (0, import_react20.createContext)({});
2115
+ var import_react19 = require("react");
2116
+ var toolStatusContext = (0, import_react19.createContext)({});
2122
2117
  var ToolStatusProvider = toolStatusContext.Provider;
2123
- var hostContext = (0, import_react20.createContext)(void 0);
2118
+ var hostContext = (0, import_react19.createContext)(void 0);
2124
2119
  var HostProvider = hostContext.Provider;
2125
- var subagentStateContext = (0, import_react20.createContext)({});
2120
+ var subagentStateContext = (0, import_react19.createContext)({});
2126
2121
  var SubagentStateProvider = subagentStateContext.Provider;
2127
2122
 
2128
2123
  // src/lib/use-attachment-url.ts
2129
2124
  init_react_import();
2130
- var import_react21 = require("react");
2125
+ var import_react20 = require("react");
2131
2126
  function useAttachmentUrl(url, endpoint) {
2132
2127
  const isRef = getAttachmentIdFromRef(url) !== null;
2133
- const [fetched, setFetched] = (0, import_react21.useState)();
2134
- (0, import_react21.useEffect)(() => {
2128
+ const [fetched, setFetched] = (0, import_react20.useState)();
2129
+ (0, import_react20.useEffect)(() => {
2135
2130
  if (!isRef) return;
2136
2131
  const controller = new AbortController();
2137
2132
  const loadUrl = async () => {
@@ -2155,7 +2150,7 @@ function useAttachmentUrl(url, endpoint) {
2155
2150
  }
2156
2151
 
2157
2152
  // src/components/ChatBody/index.tsx
2158
- var import_jsx_runtime29 = require("react/jsx-runtime");
2153
+ var import_jsx_runtime28 = require("react/jsx-runtime");
2159
2154
  var cx8 = getClassNameFactory2("Chat", styles_module_default7);
2160
2155
  var cxMessage = getClassNameFactory2("ChatMessage", styles_module_default7);
2161
2156
  function ChatBody({
@@ -2180,7 +2175,7 @@ function ChatBody({
2180
2175
  const lastMessage = hasMessages ? messages[messages.length - 1] : null;
2181
2176
  const lastPart = lastMessage ? lastMessage.parts[lastMessage.parts.length - 1] : null;
2182
2177
  const isLoading = status === "submitted" || status === "streaming" && !lastPart;
2183
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2178
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2184
2179
  "div",
2185
2180
  {
2186
2181
  className: cx8({
@@ -2190,22 +2185,22 @@ function ChatBody({
2190
2185
  isLoading
2191
2186
  }),
2192
2187
  children: [
2193
- children ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("default"), children }) : null,
2194
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("inner"), children: [
2195
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("body"), ref: scrollRef, children: [
2196
- /* @__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)) }),
2197
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("loader"), children: [
2198
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("loaderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Loader, { size: 16 }) }),
2199
- /* @__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..." })
2200
2195
  ] })
2201
2196
  ] }),
2202
- error && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("error"), children: [
2203
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cx8("errorLabel"), children: "Something went wrong." }),
2204
- 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" }) }) })
2205
2200
  ] }),
2206
- userError && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("userError"), children: [
2207
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: userError }),
2208
- 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)(
2209
2204
  "button",
2210
2205
  {
2211
2206
  "aria-label": "Dismiss",
@@ -2213,12 +2208,12 @@ function ChatBody({
2213
2208
  className: cx8("userErrorDismiss"),
2214
2209
  onClick: onDismissUserError,
2215
2210
  type: "button",
2216
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(X, { size: 14 })
2211
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(X, { size: 14 })
2217
2212
  }
2218
2213
  )
2219
2214
  ] }),
2220
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cx8("form"), children: [
2221
- /* @__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)(
2222
2217
  PromptForm,
2223
2218
  {
2224
2219
  actions,
@@ -2232,7 +2227,7 @@ function ChatBody({
2232
2227
  placeholder: "What do you want to build?"
2233
2228
  }
2234
2229
  ),
2235
- 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
2236
2231
  ] })
2237
2232
  ] })
2238
2233
  ]
@@ -2257,17 +2252,17 @@ function mergeReasoningParts(parts) {
2257
2252
  }
2258
2253
  function ChatMessage({ message }) {
2259
2254
  const { role, parts: rawParts } = message;
2260
- const parts = (0, import_react22.useMemo)(() => mergeReasoningParts(rawParts), [rawParts]);
2255
+ const parts = (0, import_react21.useMemo)(() => mergeReasoningParts(rawParts), [rawParts]);
2261
2256
  if (role === "user") {
2262
2257
  const attachmentParts = parts.filter((part) => part.type === "file");
2263
2258
  const otherParts = parts.filter((part) => part.type !== "file");
2264
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2259
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2265
2260
  "div",
2266
2261
  {
2267
2262
  className: cxMessage({ userRole: true }),
2268
2263
  "data-message-id": message.id,
2269
- children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: cxMessage("userBubble"), children: [
2270
- 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)(
2271
2266
  ChatMessagePart,
2272
2267
  {
2273
2268
  part,
@@ -2275,7 +2270,7 @@ function ChatMessage({ message }) {
2275
2270
  },
2276
2271
  `${message.id}-${part.type}-${i}`
2277
2272
  )),
2278
- 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)(
2279
2274
  ChatAttachmentThumbnail,
2280
2275
  {
2281
2276
  filename: part.filename,
@@ -2288,12 +2283,12 @@ function ChatMessage({ message }) {
2288
2283
  }
2289
2284
  );
2290
2285
  }
2291
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2286
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2292
2287
  "div",
2293
2288
  {
2294
2289
  className: cxMessage({ [`${role}Role`]: true }),
2295
2290
  "data-message-id": message.id,
2296
- children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2291
+ children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2297
2292
  ChatMessagePart,
2298
2293
  {
2299
2294
  part,
@@ -2309,13 +2304,13 @@ function ChatAttachmentThumbnail({
2309
2304
  mediaType,
2310
2305
  url
2311
2306
  }) {
2312
- const host = (0, import_react22.useContext)(hostContext);
2307
+ const host = (0, import_react21.useContext)(hostContext);
2313
2308
  const endpoint = host ? `${host.replace(/\/$/, "")}/attachments` : "/api/puck/chat/attachments";
2314
2309
  const resolvedUrl = useAttachmentUrl(url, endpoint);
2315
2310
  const attachmentId = getAttachmentIdFromRef(url);
2316
2311
  const label = filename || attachmentId || "Attachment";
2317
2312
  const isImage = mediaType.startsWith("image/");
2318
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2313
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2319
2314
  "a",
2320
2315
  {
2321
2316
  "aria-label": label,
@@ -2325,8 +2320,8 @@ function ChatAttachmentThumbnail({
2325
2320
  target: "_blank",
2326
2321
  title: label,
2327
2322
  children: [
2328
- isImage ? resolvedUrl && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("img", { alt: label, src: resolvedUrl }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FileText, { size: 20 }),
2329
- /* @__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 })
2330
2325
  ]
2331
2326
  }
2332
2327
  );
@@ -2341,24 +2336,24 @@ function ChatMessageWrapper({
2341
2336
  role
2342
2337
  }) {
2343
2338
  if (role === "assistant" || role === "user") {
2344
- 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 });
2345
2340
  }
2346
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children });
2341
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children });
2347
2342
  }
2348
2343
  function ReasoningBlock({ part }) {
2349
- const startTimeRef = (0, import_react22.useRef)(null);
2350
- const [durationSecs, setDurationSecs] = (0, import_react22.useState)(null);
2344
+ const startTimeRef = (0, import_react21.useRef)(null);
2345
+ const [durationSecs, setDurationSecs] = (0, import_react21.useState)(null);
2351
2346
  if (part.state !== "done" && startTimeRef.current === null) {
2352
2347
  startTimeRef.current = Date.now();
2353
2348
  }
2354
- (0, import_react22.useEffect)(() => {
2349
+ (0, import_react21.useEffect)(() => {
2355
2350
  if (part.state === "done" && startTimeRef.current !== null) {
2356
2351
  setDurationSecs(Math.round((Date.now() - startTimeRef.current) / 1e3));
2357
2352
  }
2358
2353
  }, [part.state]);
2359
2354
  const loading = part.state ? part.state !== "done" : false;
2360
2355
  const label = durationSecs !== null ? `Thought for ${durationSecs}s` : !loading ? "Thought for a while" : "Thinking...";
2361
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2356
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2362
2357
  ChatEvent,
2363
2358
  {
2364
2359
  status: {
@@ -2366,7 +2361,7 @@ function ReasoningBlock({ part }) {
2366
2361
  loading,
2367
2362
  summary: part.text
2368
2363
  },
2369
- icon: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Brain, { size: 18 })
2364
+ icon: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Brain, { size: 18 })
2370
2365
  }
2371
2366
  );
2372
2367
  }
@@ -2375,19 +2370,19 @@ function ChatMessagePart({
2375
2370
  role
2376
2371
  }) {
2377
2372
  if (part.type === "text") {
2378
- 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 }) });
2379
2374
  }
2380
2375
  if (part.type === "reasoning") {
2381
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ReasoningBlock, { part });
2376
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ReasoningBlock, { part });
2382
2377
  }
2383
2378
  if (part.type === "tool-subagent") {
2384
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SubagentBlock, { toolCallId: part.toolCallId });
2379
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SubagentBlock, { toolCallId: part.toolCallId });
2385
2380
  }
2386
2381
  if (part.type.startsWith("tool-")) {
2387
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PuckTool, { ...part });
2382
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PuckTool, { ...part });
2388
2383
  }
2389
2384
  if (part.type === "file") {
2390
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2385
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2391
2386
  ChatAttachment,
2392
2387
  {
2393
2388
  filename: part.filename,
@@ -2403,17 +2398,17 @@ function ChatAttachment({
2403
2398
  mediaType,
2404
2399
  url
2405
2400
  }) {
2406
- const host = (0, import_react22.useContext)(hostContext);
2401
+ const host = (0, import_react21.useContext)(hostContext);
2407
2402
  const endpoint = host ? `${host.replace(/\/$/, "")}/attachments` : "/api/puck/chat/attachments";
2408
2403
  const resolvedUrl = useAttachmentUrl(url, endpoint);
2409
2404
  const attachmentId = getAttachmentIdFromRef(url);
2410
2405
  const label = filename || attachmentId || "Attachment";
2411
2406
  if (mediaType.startsWith("image/")) {
2412
- 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: resolvedUrl && /* @__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 }) }) });
2413
2408
  }
2414
- 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: [
2415
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(FileText, { size: 16 }),
2416
- /* @__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 })
2417
2412
  ] }) });
2418
2413
  }
2419
2414
  function PuckTool({
@@ -2422,68 +2417,68 @@ function PuckTool({
2422
2417
  defaultLabel = "Thinking...",
2423
2418
  type
2424
2419
  }) {
2425
- const toolStatus = (0, import_react22.useContext)(toolStatusContext)[toolCallId];
2420
+ const toolStatus = (0, import_react21.useContext)(toolStatusContext)[toolCallId];
2426
2421
  const outputObj = output;
2427
2422
  const status = outputObj && "status" in outputObj ? outputObj.status : toolStatus ?? { loading: true, label: defaultLabel };
2428
- let icon = (0, import_react22.useMemo)(() => {
2423
+ let icon = (0, import_react21.useMemo)(() => {
2429
2424
  if (type === "tool-write") {
2430
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Pen, { size: 18 });
2425
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Pen, { size: 18 });
2431
2426
  } else if (type === "tool-refreshPageData") {
2432
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(GitPullRequest, { size: 18 });
2427
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(GitPullRequest, { size: 18 });
2433
2428
  } else if (type === "tool-takeScreenshot") {
2434
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Camera, { size: 18 });
2429
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Camera, { size: 18 });
2435
2430
  } else if (type === "tool-fetchUrl") {
2436
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CloudDownload, { size: 18 });
2431
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloudDownload, { size: 18 });
2437
2432
  } else if (type === "tool-screenshotUrl") {
2438
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Camera, { size: 18 });
2433
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Camera, { size: 18 });
2439
2434
  }
2440
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Check, { size: 18 });
2435
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Check, { size: 18 });
2441
2436
  }, [type]);
2442
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ChatEvent, { status, icon });
2437
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ChatEvent, { status, icon });
2443
2438
  }
2444
2439
  function SubagentBlock({ toolCallId }) {
2445
- const subagentState = (0, import_react22.useContext)(subagentStateContext);
2440
+ const subagentState = (0, import_react21.useContext)(subagentStateContext);
2446
2441
  const state = subagentState[toolCallId];
2447
- const toolStatusMap = (0, import_react22.useContext)(toolStatusContext);
2442
+ const toolStatusMap = (0, import_react21.useContext)(toolStatusContext);
2448
2443
  const toolStatus = toolStatusMap[toolCallId];
2449
2444
  const fallbackLabel = toolStatus?.label ?? "Running subagent";
2450
2445
  const label = state?.label ? state.state === "done" ? `${state.agentType} subagent complete` : state.label : fallbackLabel;
2451
2446
  const loading = state ? state.state !== "done" : toolStatus?.loading ?? true;
2452
2447
  const hasBody = !!state && state.parts.length > 0;
2453
2448
  const parts = state?.parts ?? [];
2454
- const [isOpen, setIsOpen] = (0, import_react22.useState)(false);
2455
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2449
+ const [isOpen, setIsOpen] = (0, import_react21.useState)(false);
2450
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2456
2451
  "details",
2457
2452
  {
2458
2453
  className: cxMessage("event"),
2459
2454
  onToggle: (e) => setIsOpen(e.currentTarget.open),
2460
2455
  children: [
2461
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2456
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2462
2457
  "summary",
2463
2458
  {
2464
2459
  className: cxMessage("eventHeader"),
2465
2460
  style: hasBody ? {} : { color: "var(--puck-color-grey-05) !important", cursor: "unset" },
2466
2461
  children: [
2467
- /* @__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 }) }),
2468
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventLabel"), children: label }),
2469
- hasBody && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
2470
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventExpand"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Plus, { size: 12 }) }),
2471
- /* @__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 }) })
2472
2467
  ] })
2473
2468
  ]
2474
2469
  }
2475
2470
  ),
2476
- 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}`)) })
2477
2472
  ]
2478
2473
  }
2479
2474
  );
2480
2475
  }
2481
2476
  function SubagentChildPartRenderer({ part }) {
2482
2477
  if (part.kind === "text") {
2483
- 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 }) });
2484
2479
  }
2485
2480
  if (part.kind === "reasoning") {
2486
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2481
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2487
2482
  ReasoningBlock,
2488
2483
  {
2489
2484
  part: {
@@ -2495,7 +2490,7 @@ function SubagentChildPartRenderer({ part }) {
2495
2490
  );
2496
2491
  }
2497
2492
  if (part.toolName === "subagent") {
2498
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SubagentBlock, { toolCallId: part.childToolCallId });
2493
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(SubagentBlock, { toolCallId: part.childToolCallId });
2499
2494
  }
2500
2495
  const synthesized = {
2501
2496
  toolCallId: part.childToolCallId,
@@ -2504,35 +2499,35 @@ function SubagentChildPartRenderer({ part }) {
2504
2499
  input: part.input,
2505
2500
  output: part.output
2506
2501
  };
2507
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PuckTool, { ...synthesized });
2502
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PuckTool, { ...synthesized });
2508
2503
  }
2509
2504
  function ChatEvent({
2510
2505
  status,
2511
- icon = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Check, { size: 18 })
2506
+ icon = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Check, { size: 18 })
2512
2507
  }) {
2513
- const [isOpen, setIsOpen] = (0, import_react22.useState)(false);
2514
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2508
+ const [isOpen, setIsOpen] = (0, import_react21.useState)(false);
2509
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2515
2510
  "details",
2516
2511
  {
2517
2512
  className: cxMessage("event"),
2518
2513
  onToggle: (e) => setIsOpen(e.currentTarget.open),
2519
2514
  children: [
2520
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2515
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2521
2516
  "summary",
2522
2517
  {
2523
2518
  className: cxMessage("eventHeader"),
2524
2519
  style: status.summary ? {} : { color: "var(--puck-color-grey-05) !important", cursor: "unset" },
2525
2520
  children: [
2526
- /* @__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 }),
2527
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: status.label }),
2528
- status.summary && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
2529
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: cxMessage("eventExpand"), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Plus, { size: 12 }) }),
2530
- /* @__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 }) })
2531
2526
  ] })
2532
2527
  ]
2533
2528
  }
2534
2529
  ),
2535
- 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 }) })
2536
2531
  ]
2537
2532
  }
2538
2533
  );
@@ -2543,12 +2538,12 @@ function ExamplePrompt({
2543
2538
  onClick,
2544
2539
  disabled
2545
2540
  }) {
2546
- const content = /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
2547
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { children: label }),
2548
- /* @__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" }) })
2549
2544
  ] });
2550
2545
  if (href) {
2551
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2546
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2552
2547
  "a",
2553
2548
  {
2554
2549
  className: cx8("examplePrompt"),
@@ -2565,7 +2560,7 @@ function ExamplePrompt({
2565
2560
  }
2566
2561
  );
2567
2562
  }
2568
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2563
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2569
2564
  "button",
2570
2565
  {
2571
2566
  className: cx8("examplePrompt"),
@@ -2605,14 +2600,14 @@ init_react_import();
2605
2600
  var styles_module_default9 = { "DesignModeToggle": "_DesignModeToggle_o5uty_1", "DesignModeToggle-button": "_DesignModeToggle-button_o5uty_8", "DesignModeToggle-button--active": "_DesignModeToggle-button--active_o5uty_28" };
2606
2601
 
2607
2602
  // src/components/DesignModeToggle/index.tsx
2608
- var import_jsx_runtime30 = require("react/jsx-runtime");
2603
+ var import_jsx_runtime29 = require("react/jsx-runtime");
2609
2604
  var cx9 = getClassNameFactory2("DesignModeToggle", styles_module_default9);
2610
2605
  function DesignModeToggle({
2611
2606
  active,
2612
2607
  onToggle,
2613
2608
  disabled
2614
2609
  }) {
2615
- 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)(
2616
2611
  "button",
2617
2612
  {
2618
2613
  className: `${cx9("button")} ${active ? cx9("button--active") : ""}`,
@@ -2621,7 +2616,7 @@ function DesignModeToggle({
2621
2616
  type: "button",
2622
2617
  title: active ? "Disable design mode" : "Enable design mode",
2623
2618
  children: [
2624
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(WandSparkles, { size: 12 }),
2619
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(WandSparkles, { size: 12 }),
2625
2620
  "Design"
2626
2621
  ]
2627
2622
  }
@@ -2635,7 +2630,7 @@ var import_core4 = require("@puckeditor/core");
2635
2630
  // src/lib/design/component.tsx
2636
2631
  init_react_import();
2637
2632
  var import_core3 = require("@puckeditor/core");
2638
- var import_react25 = require("react");
2633
+ var import_react24 = require("react");
2639
2634
 
2640
2635
  // src/lib/morph-html.ts
2641
2636
  init_react_import();
@@ -3748,7 +3743,7 @@ var wireArrayItemEditing = ({
3748
3743
  // src/lib/design/render-html.tsx
3749
3744
  init_react_import();
3750
3745
  var import_htmlparser22 = require("htmlparser2");
3751
- var import_react23 = require("react");
3746
+ var import_react22 = require("react");
3752
3747
  var VOID_ELEMENTS = /* @__PURE__ */ new Set([
3753
3748
  "area",
3754
3749
  "base",
@@ -3811,7 +3806,7 @@ var nodeToReact = (node, slots, key) => {
3811
3806
  if (isEventHandlerAttr2(name)) continue;
3812
3807
  props2[REACT_PROP_NAMES[name] || name] = value;
3813
3808
  }
3814
- return (0, import_react23.createElement)(tag, props2, slots[slotName]);
3809
+ return (0, import_react22.createElement)(tag, props2, slots[slotName]);
3815
3810
  }
3816
3811
  const props = { key };
3817
3812
  for (const [name, value] of Object.entries(attribs)) {
@@ -3823,10 +3818,10 @@ var nodeToReact = (node, slots, key) => {
3823
3818
  }
3824
3819
  }
3825
3820
  if (VOID_ELEMENTS.has(tag)) {
3826
- return (0, import_react23.createElement)(tag, props);
3821
+ return (0, import_react22.createElement)(tag, props);
3827
3822
  }
3828
3823
  const children = el.children.map((child, i) => nodeToReact(child, slots, i)).filter((c) => c !== null);
3829
- return (0, import_react23.createElement)(tag, props, ...children);
3824
+ return (0, import_react22.createElement)(tag, props, ...children);
3830
3825
  };
3831
3826
  var htmlToReactTree = (html, slots) => {
3832
3827
  if (!html) return null;
@@ -3834,14 +3829,14 @@ var htmlToReactTree = (html, slots) => {
3834
3829
  const children = doc.children.map((child, i) => nodeToReact(child, slots, i)).filter((c) => c !== null);
3835
3830
  if (children.length === 0) return null;
3836
3831
  if (children.length === 1) return children[0];
3837
- return (0, import_react23.createElement)(import_react23.Fragment, null, ...children);
3832
+ return (0, import_react22.createElement)(import_react22.Fragment, null, ...children);
3838
3833
  };
3839
3834
 
3840
3835
  // src/lib/design/slot-portal.tsx
3841
3836
  init_react_import();
3842
- var import_react24 = require("react");
3837
+ var import_react23 = require("react");
3843
3838
  var import_react_dom = require("react-dom");
3844
- var import_jsx_runtime31 = require("react/jsx-runtime");
3839
+ var import_jsx_runtime30 = require("react/jsx-runtime");
3845
3840
  var parseInlineStyle = (cssText) => {
3846
3841
  const style = {};
3847
3842
  for (const declaration of cssText.split(";")) {
@@ -3863,13 +3858,13 @@ var SlotPortal = ({
3863
3858
  slotClassName,
3864
3859
  SlotContent
3865
3860
  }) => {
3866
- const [target, setTarget] = (0, import_react24.useState)(null);
3867
- const lastTarget = (0, import_react24.useRef)(null);
3868
- const style = (0, import_react24.useMemo)(
3861
+ const [target, setTarget] = (0, import_react23.useState)(null);
3862
+ const lastTarget = (0, import_react23.useRef)(null);
3863
+ const style = (0, import_react23.useMemo)(
3869
3864
  () => slotStyle ? parseInlineStyle(slotStyle) : void 0,
3870
3865
  [slotStyle]
3871
3866
  );
3872
- (0, import_react24.useEffect)(() => {
3867
+ (0, import_react23.useEffect)(() => {
3873
3868
  const el = entry.querySelector(`[data-puck-slot="${cssEscape(slotName)}"]`);
3874
3869
  if (el !== lastTarget.current) {
3875
3870
  el?.replaceChildren();
@@ -3883,13 +3878,13 @@ var SlotPortal = ({
3883
3878
  }, [entry, html, slotName]);
3884
3879
  if (!target || typeof SlotContent !== "function") return null;
3885
3880
  return (0, import_react_dom.createPortal)(
3886
- /* @__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 }),
3887
3882
  target
3888
3883
  );
3889
3884
  };
3890
3885
 
3891
3886
  // src/lib/design/component.tsx
3892
- var import_jsx_runtime32 = require("react/jsx-runtime");
3887
+ var import_jsx_runtime31 = require("react/jsx-runtime");
3893
3888
  var DESIGN_COMPONENT = Symbol("puck-ai.designComponent");
3894
3889
  var isDesignComponent = (config) => !!config?.[DESIGN_COMPONENT];
3895
3890
  var streamingValues = /* @__PURE__ */ new Map();
@@ -3975,13 +3970,13 @@ function createDesignComponentConfig(registration) {
3975
3970
  }
3976
3971
  return resolvedFields;
3977
3972
  },
3978
- 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 })
3979
3974
  };
3980
3975
  componentConfig[DESIGN_COMPONENT] = true;
3981
3976
  return componentConfig;
3982
3977
  function EditorEntry(renderProps) {
3983
3978
  const getPuck = (0, import_core3.useGetPuck)();
3984
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Entry, { ...renderProps, getPuck });
3979
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Entry, { ...renderProps, getPuck });
3985
3980
  }
3986
3981
  function Entry({
3987
3982
  getPuck,
@@ -3990,11 +3985,11 @@ function createDesignComponentConfig(registration) {
3990
3985
  style,
3991
3986
  ...props
3992
3987
  }) {
3993
- const getSnapshot = (0, import_react25.useCallback)(
3988
+ const getSnapshot = (0, import_react24.useCallback)(
3994
3989
  () => registrationStore.get(name) ?? registration,
3995
3990
  []
3996
3991
  );
3997
- const reg = (0, import_react25.useSyncExternalStore)(
3992
+ const reg = (0, import_react24.useSyncExternalStore)(
3998
3993
  registrationStore.subscribe,
3999
3994
  getSnapshot,
4000
3995
  getSnapshot
@@ -4002,10 +3997,10 @@ function createDesignComponentConfig(registration) {
4002
3997
  const html = reg.html ?? "";
4003
3998
  const styles = reg.styles;
4004
3999
  const script = reg.script;
4005
- const [entryEl, setEntryEl] = (0, import_react25.useState)(null);
4006
- const scriptRef = (0, import_react25.useRef)(null);
4007
- const annotations = (0, import_react25.useMemo)(() => getAnnotations(html), [html]);
4008
- const { attrFields, arrayFields, attrSig, arraySig } = (0, import_react25.useMemo)(() => {
4000
+ const [entryEl, setEntryEl] = (0, import_react24.useState)(null);
4001
+ const scriptRef = (0, import_react24.useRef)(null);
4002
+ const annotations = (0, import_react24.useMemo)(() => getAnnotations(html), [html]);
4003
+ const { attrFields, arrayFields, attrSig, arraySig } = (0, import_react24.useMemo)(() => {
4009
4004
  const attr = [];
4010
4005
  const arrays = [];
4011
4006
  for (const field of annotations.fields) {
@@ -4027,11 +4022,11 @@ function createDesignComponentConfig(registration) {
4027
4022
  arraySig: JSON.stringify(arrays)
4028
4023
  };
4029
4024
  }, [props, annotations]);
4030
- const patchedHtml = (0, import_react25.useMemo)(() => {
4025
+ const patchedHtml = (0, import_react24.useMemo)(() => {
4031
4026
  if (puck.isEditing) return html;
4032
4027
  return patchHtmlAnnotations(html, props);
4033
4028
  }, [html, props, puck.isEditing]);
4034
- const fieldValueAttrs = (0, import_react25.useMemo)(() => {
4029
+ const fieldValueAttrs = (0, import_react24.useMemo)(() => {
4035
4030
  const attrs = {};
4036
4031
  attrs["data-puck-design"] = name;
4037
4032
  for (const field of annotations.fields) {
@@ -4042,17 +4037,17 @@ function createDesignComponentConfig(registration) {
4042
4037
  }
4043
4038
  return attrs;
4044
4039
  }, [annotations, props, puck.isEditing]);
4045
- const editorEntryNode = (0, import_react25.useMemo)(
4046
- () => puck.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ref: setEntryEl }) : null,
4040
+ const editorEntryNode = (0, import_react24.useMemo)(
4041
+ () => puck.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ref: setEntryEl }) : null,
4047
4042
  [puck.isEditing]
4048
4043
  );
4049
- (0, import_react25.useEffect)(() => {
4044
+ (0, import_react24.useEffect)(() => {
4050
4045
  if (!puck.isEditing || !getPuck) return;
4051
4046
  getPuck().resolveDataById(id, "force");
4052
4047
  }, [reg, puck.isEditing, getPuck, id]);
4053
- const fieldWiring = (0, import_react25.useRef)(/* @__PURE__ */ new Map());
4054
- const morphed = (0, import_react25.useRef)(null);
4055
- (0, import_react25.useLayoutEffect)(() => {
4048
+ const fieldWiring = (0, import_react24.useRef)(/* @__PURE__ */ new Map());
4049
+ const morphed = (0, import_react24.useRef)(null);
4050
+ (0, import_react24.useLayoutEffect)(() => {
4056
4051
  if (!puck.isEditing || !entryEl) return;
4057
4052
  if (morphed.current?.el !== entryEl || morphed.current?.html !== html || morphed.current?.attrSig !== attrSig) {
4058
4053
  morphed.current = { el: entryEl, html, attrSig };
@@ -4069,14 +4064,14 @@ function createDesignComponentConfig(registration) {
4069
4064
  });
4070
4065
  }
4071
4066
  });
4072
- (0, import_react25.useEffect)(
4067
+ (0, import_react24.useEffect)(
4073
4068
  () => () => {
4074
4069
  fieldWiring.current.forEach((cleanup) => cleanup());
4075
4070
  fieldWiring.current.clear();
4076
4071
  },
4077
4072
  []
4078
4073
  );
4079
- (0, import_react25.useEffect)(() => {
4074
+ (0, import_react24.useEffect)(() => {
4080
4075
  if (!entryEl || !puck.isEditing) return;
4081
4076
  for (const attr of Array.from(entryEl.attributes)) {
4082
4077
  if ((attr.name === "data-puck-design" || attr.name.startsWith("data-puck-field-value-")) && !(attr.name in fieldValueAttrs)) {
@@ -4089,10 +4084,10 @@ function createDesignComponentConfig(registration) {
4089
4084
  }
4090
4085
  }
4091
4086
  }, [entryEl, fieldValueAttrs]);
4092
- const appliedArrayHtml = (0, import_react25.useRef)(/* @__PURE__ */ new WeakMap());
4093
- const arrayItemWiring = (0, import_react25.useRef)({});
4094
- const appliedArrays = (0, import_react25.useRef)(null);
4095
- (0, import_react25.useEffect)(() => {
4087
+ const appliedArrayHtml = (0, import_react24.useRef)(/* @__PURE__ */ new WeakMap());
4088
+ const arrayItemWiring = (0, import_react24.useRef)({});
4089
+ const appliedArrays = (0, import_react24.useRef)(null);
4090
+ (0, import_react24.useEffect)(() => {
4096
4091
  if (!puck.isEditing || !entryEl || !getPuck) return;
4097
4092
  if (appliedArrays.current?.el === entryEl && appliedArrays.current?.html === html && appliedArrays.current?.sig === arraySig) {
4098
4093
  return;
@@ -4144,7 +4139,7 @@ function createDesignComponentConfig(registration) {
4144
4139
  id,
4145
4140
  getPuck
4146
4141
  ]);
4147
- (0, import_react25.useEffect)(
4142
+ (0, import_react24.useEffect)(
4148
4143
  () => () => {
4149
4144
  Object.values(arrayItemWiring.current).forEach(
4150
4145
  (wiring) => wiring.forEach(({ cleanup }) => cleanup())
@@ -4152,7 +4147,7 @@ function createDesignComponentConfig(registration) {
4152
4147
  },
4153
4148
  []
4154
4149
  );
4155
- (0, import_react25.useEffect)(() => {
4150
+ (0, import_react24.useEffect)(() => {
4156
4151
  if (!script || !entryEl) return;
4157
4152
  scriptRef.current?.remove();
4158
4153
  const doc = entryEl.ownerDocument;
@@ -4170,7 +4165,7 @@ function createDesignComponentConfig(registration) {
4170
4165
  for (const slot of annotations.slots) {
4171
4166
  const Slot = props[slot.name];
4172
4167
  if (typeof Slot === "function") {
4173
- slotContent[slot.name] = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4168
+ slotContent[slot.name] = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4174
4169
  Slot,
4175
4170
  {
4176
4171
  style: slot.style ? parseStyleString(slot.style) : void 0,
@@ -4179,17 +4174,17 @@ function createDesignComponentConfig(registration) {
4179
4174
  );
4180
4175
  }
4181
4176
  }
4182
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
4183
- styles && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: styles }),
4184
- style && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: style }),
4185
- /* @__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) })
4186
4181
  ] });
4187
4182
  }
4188
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_jsx_runtime32.Fragment, { children: [
4189
- styles && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("style", { children: styles }),
4190
- 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 }),
4191
4186
  editorEntryNode,
4192
- entryEl && annotations.slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
4187
+ entryEl && annotations.slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4193
4188
  SlotPortal,
4194
4189
  {
4195
4190
  entry: entryEl,
@@ -4207,8 +4202,8 @@ function createDesignComponentConfig(registration) {
4207
4202
 
4208
4203
  // src/lib/design/globals.tsx
4209
4204
  init_react_import();
4210
- var import_react26 = require("react");
4211
- var import_jsx_runtime33 = require("react/jsx-runtime");
4205
+ var import_react25 = require("react");
4206
+ var import_jsx_runtime32 = require("react/jsx-runtime");
4212
4207
  function getDynamicConfigGlobals(dynamicConfig) {
4213
4208
  if (typeof dynamicConfig !== "object" || dynamicConfig === null) return {};
4214
4209
  const { styles, script } = dynamicConfig;
@@ -4223,9 +4218,9 @@ function DesignGlobals({
4223
4218
  script,
4224
4219
  isEditing
4225
4220
  }) {
4226
- const scriptRef = (0, import_react26.useRef)(null);
4227
- const hostRef = (0, import_react26.useRef)(null);
4228
- (0, import_react26.useEffect)(() => {
4221
+ const scriptRef = (0, import_react25.useRef)(null);
4222
+ const hostRef = (0, import_react25.useRef)(null);
4223
+ (0, import_react25.useEffect)(() => {
4229
4224
  if (!script) return;
4230
4225
  scriptRef.current?.remove();
4231
4226
  const doc = hostRef.current?.ownerDocument ?? document;
@@ -4238,10 +4233,10 @@ function DesignGlobals({
4238
4233
  scriptRef.current = null;
4239
4234
  };
4240
4235
  }, [script]);
4241
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
4242
- isEditing && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("style", { children: INLINE_EDIT_RESET }),
4243
- styles && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("style", { children: styles }),
4244
- 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" } })
4245
4240
  ] });
4246
4241
  }
4247
4242
  var WRAPPED = "__puckAiDesignGlobals";
@@ -4251,8 +4246,8 @@ function withDesignGlobals(root) {
4251
4246
  const userRender = root?.render;
4252
4247
  const render = (props) => {
4253
4248
  const { styles, script } = getDynamicConfigGlobals(props._dynamicConfig);
4254
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
4255
- /* @__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)(
4256
4251
  DesignGlobals,
4257
4252
  {
4258
4253
  styles,
@@ -4274,7 +4269,7 @@ function ensureDesignGlobalsRoot(config) {
4274
4269
  }
4275
4270
 
4276
4271
  // src/lib/design/runtime.tsx
4277
- var import_jsx_runtime34 = require("react/jsx-runtime");
4272
+ var import_jsx_runtime33 = require("react/jsx-runtime");
4278
4273
  var cachedFieldMetadata;
4279
4274
  function detectFieldMetadata(config) {
4280
4275
  for (const comp of Object.values(config.components)) {
@@ -4313,7 +4308,7 @@ function applyConfigFieldMetadata(config, dynamicComponents) {
4313
4308
  var DESIGNED_CATEGORY = "dynamic";
4314
4309
  var dynamicConfigRootField = {
4315
4310
  type: "custom",
4316
- render: () => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", {}),
4311
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", {}),
4317
4312
  ai: {
4318
4313
  exclude: true
4319
4314
  }
@@ -4581,14 +4576,14 @@ var drawScaled = (source, ratio) => {
4581
4576
  const target = document.createElement("canvas");
4582
4577
  target.width = scaleDimension(source.width, ratio);
4583
4578
  target.height = scaleDimension(source.height, ratio);
4584
- const ctx2 = target.getContext("2d");
4585
- if (!ctx2) {
4579
+ const ctx = target.getContext("2d");
4580
+ if (!ctx) {
4586
4581
  releaseCanvas(target);
4587
4582
  return source;
4588
4583
  }
4589
- ctx2.imageSmoothingEnabled = true;
4590
- ctx2.imageSmoothingQuality = "high";
4591
- 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);
4592
4587
  return target;
4593
4588
  };
4594
4589
  var fitCanvas = (canvas) => {
@@ -4669,12 +4664,12 @@ async function postClientToolResponse(host, body) {
4669
4664
  }
4670
4665
 
4671
4666
  // src/components/Chat/index.tsx
4672
- var import_jsx_runtime35 = require("react/jsx-runtime");
4667
+ var import_jsx_runtime34 = require("react/jsx-runtime");
4673
4668
  var q = (0, import_qler.default)();
4674
4669
  var DEFAULT_API_VERSION = "v2";
4675
4670
  var BUILD_OP_DEBOUNCE_MS = 1e3 / 60;
4676
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.";
4677
- var PLUGIN_AI_VERSION = true ? "0.9.0-canary.51cc139e" : "unknown";
4672
+ var PLUGIN_AI_VERSION = true ? "0.9.0-canary.53ee4e95" : "unknown";
4678
4673
  var BENCHMARK = false;
4679
4674
  var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${(0, import_ulid.ulid)()}`;
4680
4675
  var getClassName18 = getClassNameFactory("Chat", styles_module_default);
@@ -4697,32 +4692,32 @@ function Chat2(props) {
4697
4692
  } = chat ?? {};
4698
4693
  const puckDispatch = usePuck((s) => s.dispatch);
4699
4694
  const getPuck = (0, import_core5.useGetPuck)();
4700
- const localChatId = (0, import_react28.useRef)("");
4701
- const inputRef = (0, import_react28.useRef)(null);
4702
- const pluginRef = (0, import_react28.useRef)(null);
4703
- const [mode, setMode] = (0, import_react28.useState)(defaultMode);
4704
- const modeRef = (0, import_react28.useRef)(mode);
4695
+ const localChatId = (0, import_react27.useRef)("");
4696
+ const inputRef = (0, import_react27.useRef)(null);
4697
+ const pluginRef = (0, import_react27.useRef)(null);
4698
+ const [mode, setMode] = (0, import_react27.useState)(defaultMode);
4699
+ const modeRef = (0, import_react27.useRef)(mode);
4705
4700
  const designModeVisible = typeof designMode === "boolean" ? designMode : designMode.visible ?? false;
4706
- (0, import_react28.useEffect)(() => {
4701
+ (0, import_react27.useEffect)(() => {
4707
4702
  modeRef.current = mode;
4708
4703
  }, [mode]);
4709
4704
  const puckData = usePuck((s) => s.appState.data);
4710
- (0, import_react28.useEffect)(() => {
4705
+ (0, import_react27.useEffect)(() => {
4711
4706
  syncDesignComponents(getPuck);
4712
4707
  }, [puckData, getPuck]);
4713
- const [error, setError] = (0, import_react28.useState)();
4714
- const [userError, setUserError] = (0, import_react28.useState)();
4715
- const clientToolEndpointUnavailableRef = (0, import_react28.useRef)(false);
4716
- const stopChatRef = (0, import_react28.useRef)(null);
4717
- const [composerAttachments, setComposerAttachments] = (0, import_react28.useState)([]);
4718
- const removedAttachmentClientIdsRef = (0, import_react28.useRef)(/* @__PURE__ */ new Set());
4719
- const uploadControllersRef = (0, import_react28.useRef)(/* @__PURE__ */ new Map());
4720
- const pendingBuildOpsRef = (0, import_react28.useRef)([]);
4721
- const lastStreamActivityRef = (0, import_react28.useRef)(0);
4722
- const hiddenSinceRef = (0, import_react28.useRef)(null);
4723
- const [toolStatus, setToolStatus] = (0, import_react28.useState)({});
4724
- const [subagentState, setSubagentState] = (0, import_react28.useState)({});
4725
- const attachmentConfig = (0, import_react28.useMemo)(
4708
+ const [error, setError] = (0, import_react27.useState)();
4709
+ const [userError, setUserError] = (0, import_react27.useState)();
4710
+ const clientToolEndpointUnavailableRef = (0, import_react27.useRef)(false);
4711
+ const stopChatRef = (0, import_react27.useRef)(null);
4712
+ const [composerAttachments, setComposerAttachments] = (0, import_react27.useState)([]);
4713
+ const removedAttachmentClientIdsRef = (0, import_react27.useRef)(/* @__PURE__ */ new Set());
4714
+ const uploadControllersRef = (0, import_react27.useRef)(/* @__PURE__ */ new Map());
4715
+ const pendingBuildOpsRef = (0, import_react27.useRef)([]);
4716
+ const lastStreamActivityRef = (0, import_react27.useRef)(0);
4717
+ const hiddenSinceRef = (0, import_react27.useRef)(null);
4718
+ const [toolStatus, setToolStatus] = (0, import_react27.useState)({});
4719
+ const [subagentState, setSubagentState] = (0, import_react27.useState)({});
4720
+ const attachmentConfig = (0, import_react27.useMemo)(
4726
4721
  () => ({
4727
4722
  accept: attachments?.accept ?? defaultAttachmentAccept,
4728
4723
  enabled: attachments?.enabled ?? true,
@@ -4732,14 +4727,14 @@ function Chat2(props) {
4732
4727
  }),
4733
4728
  [attachments, host]
4734
4729
  );
4735
- (0, import_react28.useEffect)(
4730
+ (0, import_react27.useEffect)(
4736
4731
  () => () => {
4737
4732
  uploadControllersRef.current.forEach((controller) => controller.abort());
4738
4733
  uploadControllersRef.current.clear();
4739
4734
  },
4740
4735
  []
4741
4736
  );
4742
- const deleteAttachment = (0, import_react28.useCallback)(
4737
+ const deleteAttachment = (0, import_react27.useCallback)(
4743
4738
  async (attachmentId) => {
4744
4739
  try {
4745
4740
  await fetch(`${attachmentConfig.endpoint}/${attachmentId}`, {
@@ -4751,7 +4746,7 @@ function Chat2(props) {
4751
4746
  },
4752
4747
  [attachmentConfig.endpoint]
4753
4748
  );
4754
- const uploadScreenshot = (0, import_react28.useCallback)(
4749
+ const uploadScreenshot = (0, import_react27.useCallback)(
4755
4750
  async (width, bucketUrl) => {
4756
4751
  try {
4757
4752
  const iframeDocument = document?.getElementById("preview-frame")?.contentDocument?.documentElement ?? null;
@@ -4806,14 +4801,14 @@ function Chat2(props) {
4806
4801
  BUILD_OP_DEBOUNCE_MS,
4807
4802
  { maxWait: BUILD_OP_DEBOUNCE_MS }
4808
4803
  );
4809
- const queueBuildOp = (0, import_react28.useCallback)(
4804
+ const queueBuildOp = (0, import_react27.useCallback)(
4810
4805
  (operation) => {
4811
4806
  pendingBuildOpsRef.current.push(operation);
4812
4807
  debouncedFlushBuildOps();
4813
4808
  },
4814
4809
  [debouncedFlushBuildOps]
4815
4810
  );
4816
- const handleClientToolEndpointUnavailable = (0, import_react28.useCallback)(() => {
4811
+ const handleClientToolEndpointUnavailable = (0, import_react27.useCallback)(() => {
4817
4812
  if (clientToolEndpointUnavailableRef.current) return;
4818
4813
  clientToolEndpointUnavailableRef.current = true;
4819
4814
  setError(CLIENT_TOOL_ENDPOINT_UNAVAILABLE_ERROR_MESSAGE);
@@ -4837,7 +4832,7 @@ function Chat2(props) {
4837
4832
  });
4838
4833
  stopChatRef.current?.();
4839
4834
  }, []);
4840
- const sendClientToolResponse = (0, import_react28.useCallback)(
4835
+ const sendClientToolResponse = (0, import_react27.useCallback)(
4841
4836
  async (body) => {
4842
4837
  try {
4843
4838
  await postClientToolResponse(host, body);
@@ -4847,7 +4842,7 @@ function Chat2(props) {
4847
4842
  },
4848
4843
  [handleClientToolEndpointUnavailable, host]
4849
4844
  );
4850
- const processData = (0, import_react28.useCallback)(
4845
+ const processData = (0, import_react27.useCallback)(
4851
4846
  (dataPart) => {
4852
4847
  lastStreamActivityRef.current = Date.now();
4853
4848
  switch (dataPart.type) {
@@ -5058,21 +5053,21 @@ function Chat2(props) {
5058
5053
  });
5059
5054
  }
5060
5055
  });
5061
- (0, import_react28.useEffect)(() => {
5056
+ (0, import_react27.useEffect)(() => {
5062
5057
  stopChatRef.current = stop;
5063
5058
  return () => {
5064
5059
  stopChatRef.current = null;
5065
5060
  stop();
5066
5061
  };
5067
5062
  }, [stop]);
5068
- const statusRef = (0, import_react28.useRef)(status);
5069
- (0, import_react28.useEffect)(() => {
5063
+ const statusRef = (0, import_react27.useRef)(status);
5064
+ (0, import_react27.useEffect)(() => {
5070
5065
  statusRef.current = status;
5071
5066
  }, [status]);
5072
- (0, import_react28.useEffect)(() => {
5067
+ (0, import_react27.useEffect)(() => {
5073
5068
  lastStreamActivityRef.current = Date.now();
5074
5069
  }, [messages]);
5075
- (0, import_react28.useEffect)(() => {
5070
+ (0, import_react27.useEffect)(() => {
5076
5071
  const FROZEN_HIDDEN_MS = 3 * 6e4;
5077
5072
  const RESUME_GRACE_MS = 12e3;
5078
5073
  const isStreaming = () => statusRef.current === "streaming" || statusRef.current === "submitted";
@@ -5115,12 +5110,12 @@ function Chat2(props) {
5115
5110
  if (graceTimer) clearTimeout(graceTimer);
5116
5111
  };
5117
5112
  }, [stop]);
5118
- const [forcedStatus, setForcedStatus] = (0, import_react28.useState)();
5119
- const resolvedStatus = (0, import_react28.useMemo)(
5113
+ const [forcedStatus, setForcedStatus] = (0, import_react27.useState)();
5114
+ const resolvedStatus = (0, import_react27.useMemo)(
5120
5115
  () => forcedStatus ?? status,
5121
5116
  [status, forcedStatus]
5122
5117
  );
5123
- (0, import_react28.useEffect)(() => {
5118
+ (0, import_react27.useEffect)(() => {
5124
5119
  if (!scrollTrackingId) return;
5125
5120
  dispatchScrollTrackingEvent({
5126
5121
  id: scrollTrackingId,
@@ -5133,7 +5128,7 @@ function Chat2(props) {
5133
5128
  });
5134
5129
  };
5135
5130
  }, [resolvedStatus, scrollTrackingId]);
5136
- (0, import_react28.useEffect)(() => {
5131
+ (0, import_react27.useEffect)(() => {
5137
5132
  window.__PUCK_AI = {
5138
5133
  processData,
5139
5134
  setMessages,
@@ -5344,7 +5339,7 @@ function Chat2(props) {
5344
5339
  if (!target?.attachmentId) return;
5345
5340
  await deleteAttachment(target.attachmentId);
5346
5341
  };
5347
- const messagesWithStatuses = (0, import_react28.useMemo)(() => {
5342
+ const messagesWithStatuses = (0, import_react27.useMemo)(() => {
5348
5343
  return messages.map((msg) => {
5349
5344
  return {
5350
5345
  ...msg,
@@ -5357,13 +5352,13 @@ function Chat2(props) {
5357
5352
  };
5358
5353
  });
5359
5354
  }, [messages, toolStatus]);
5360
- 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)(
5361
5356
  ChatBody,
5362
5357
  {
5363
5358
  messages: messagesWithStatuses,
5364
5359
  onFileDrop: attachmentConfig.enabled ? handleFiles : void 0,
5365
- actions: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
5366
- 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)(
5367
5362
  AttachmentComposer,
5368
5363
  {
5369
5364
  accept: attachmentConfig.accept,
@@ -5376,7 +5371,7 @@ function Chat2(props) {
5376
5371
  typeof chatActions === "function" ? chatActions({
5377
5372
  disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming"
5378
5373
  }) : chatActions,
5379
- designModeVisible ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5374
+ designModeVisible ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5380
5375
  DesignModeToggle,
5381
5376
  {
5382
5377
  active: mode === "design",
@@ -5393,7 +5388,7 @@ function Chat2(props) {
5393
5388
  inputRef,
5394
5389
  status: resolvedStatus,
5395
5390
  examplePrompts: examplePrompts?.map(
5396
- ({ label, href, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5391
+ ({ label, href, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5397
5392
  ExamplePrompt,
5398
5393
  {
5399
5394
  label,
@@ -5412,7 +5407,7 @@ function Chat2(props) {
5412
5407
  },
5413
5408
  userError,
5414
5409
  onDismissUserError: () => setUserError(""),
5415
- children: placeholder ?? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5410
+ children: placeholder ?? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5416
5411
  Placeholder,
5417
5412
  {
5418
5413
  dispatch: puckDispatch,
@@ -5529,10 +5524,10 @@ function AttachmentComposer({
5529
5524
  maxFiles,
5530
5525
  onChange
5531
5526
  }) {
5532
- const id = (0, import_react28.useId)();
5533
- const inputId = (0, import_react28.useMemo)(() => `attachment-input-${id}`, []);
5534
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName18("attachmentControls"), children: [
5535
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5527
+ const id = (0, import_react27.useId)();
5528
+ const inputId = (0, import_react27.useMemo)(() => `attachment-input-${id}`, []);
5529
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName18("attachmentControls"), children: [
5530
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5536
5531
  "input",
5537
5532
  {
5538
5533
  accept: accept.join(","),
@@ -5544,7 +5539,7 @@ function AttachmentComposer({
5544
5539
  type: "file"
5545
5540
  }
5546
5541
  ),
5547
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5542
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5548
5543
  "button",
5549
5544
  {
5550
5545
  "aria-label": "Attach files",
@@ -5553,7 +5548,7 @@ function AttachmentComposer({
5553
5548
  onClick: () => document.getElementById(inputId)?.click(),
5554
5549
  title: "Attach files",
5555
5550
  type: "button",
5556
- children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Paperclip, { size: 14 })
5551
+ children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Paperclip, { size: 14 })
5557
5552
  }
5558
5553
  )
5559
5554
  ] });
@@ -5576,12 +5571,12 @@ function Placeholder({
5576
5571
  }
5577
5572
  }, 10);
5578
5573
  };
5579
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName18("placeholder"), children: [
5580
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassName18("placeholderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Sparkles, { "aria-hidden": "true", size: 28 }) }),
5581
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("strong", { className: getClassName18("placeholderTitle"), children: "Build with AI" }),
5582
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: getClassName18("placeholderDescription"), children: "Describe what you want to create or change." }),
5583
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName18("actions"), children: [
5584
- /* @__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)(
5585
5580
  "button",
5586
5581
  {
5587
5582
  className: getClassName18("action"),
@@ -5590,7 +5585,7 @@ function Placeholder({
5590
5585
  children: "Write a prompt"
5591
5586
  }
5592
5587
  ),
5593
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5588
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
5594
5589
  "button",
5595
5590
  {
5596
5591
  className: getClassName18("actionOutlined"),
@@ -5630,7 +5625,7 @@ function isScrolledIntoView(el) {
5630
5625
 
5631
5626
  // src/components/ScrollTracking/ScrollTracking.tsx
5632
5627
  init_react_import();
5633
- var import_react30 = require("react");
5628
+ var import_react29 = require("react");
5634
5629
 
5635
5630
  // src/lib/scroll-into-view-local.ts
5636
5631
  init_react_import();
@@ -5653,9 +5648,9 @@ function scrollIntoViewLocal(el, win, behavior = "smooth") {
5653
5648
 
5654
5649
  // src/lib/use-frame-mutation-observer.ts
5655
5650
  init_react_import();
5656
- var import_react29 = require("react");
5651
+ var import_react28 = require("react");
5657
5652
  function useFrameMutationObserver(callback) {
5658
- return (0, import_react29.useCallback)(() => {
5653
+ return (0, import_react28.useCallback)(() => {
5659
5654
  const frame = document?.getElementById(
5660
5655
  "preview-frame"
5661
5656
  );
@@ -5700,9 +5695,9 @@ var ScrollTracking = ({
5700
5695
  children,
5701
5696
  trackingId
5702
5697
  }) => {
5703
- const followedRefs = (0, import_react30.useRef)([]);
5704
- const enabledRef = (0, import_react30.useRef)(false);
5705
- (0, import_react30.useEffect)(() => {
5698
+ const followedRefs = (0, import_react29.useRef)([]);
5699
+ const enabledRef = (0, import_react29.useRef)(false);
5700
+ (0, import_react29.useEffect)(() => {
5706
5701
  return subscribeToScrollTrackingEvents(({ id, enabled }) => {
5707
5702
  if (id !== trackingId) return;
5708
5703
  enabledRef.current = enabled;
@@ -5721,7 +5716,7 @@ var ScrollTracking = ({
5721
5716
  });
5722
5717
  }
5723
5718
  });
5724
- (0, import_react30.useEffect)(() => {
5719
+ (0, import_react29.useEffect)(() => {
5725
5720
  follow();
5726
5721
  }, [follow]);
5727
5722
  return children;
@@ -5734,16 +5729,16 @@ var import_core7 = require("@puckeditor/core");
5734
5729
  // src/components/ManageComponents/index.tsx
5735
5730
  init_react_import();
5736
5731
  var import_core6 = require("@puckeditor/core");
5737
- var import_react31 = require("react");
5732
+ var import_react30 = require("react");
5738
5733
 
5739
5734
  // css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/ManageComponents/styles.module.css#css-module
5740
5735
  init_react_import();
5741
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" };
5742
5737
 
5743
5738
  // src/components/ManageComponents/index.tsx
5744
- var import_jsx_runtime36 = require("react/jsx-runtime");
5739
+ var import_jsx_runtime35 = require("react/jsx-runtime");
5745
5740
  var cx10 = getClassNameFactory2("ManageComponents", styles_module_default10);
5746
- var useRegistrations = () => (0, import_react31.useSyncExternalStore)(
5741
+ var useRegistrations = () => (0, import_react30.useSyncExternalStore)(
5747
5742
  registrationStore.subscribe,
5748
5743
  () => registrationStore.getAll(),
5749
5744
  () => registrationStore.getAll()
@@ -5751,9 +5746,9 @@ var useRegistrations = () => (0, import_react31.useSyncExternalStore)(
5751
5746
  function ManageModalContent({ onClose }) {
5752
5747
  const getPuck = (0, import_core6.useGetPuck)();
5753
5748
  const { visible, setVisible } = useModal();
5754
- const [confirmTarget, setConfirmTarget] = (0, import_react31.useState)(null);
5749
+ const [confirmTarget, setConfirmTarget] = (0, import_react30.useState)(null);
5755
5750
  const entries = useRegistrations();
5756
- (0, import_react31.useEffect)(() => {
5751
+ (0, import_react30.useEffect)(() => {
5757
5752
  if (!visible) onClose();
5758
5753
  }, [visible, onClose]);
5759
5754
  const handleDelete = (name) => {
@@ -5764,14 +5759,14 @@ function ManageModalContent({ onClose }) {
5764
5759
  }
5765
5760
  };
5766
5761
  if (confirmTarget) {
5767
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
5762
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
5768
5763
  ActionModal,
5769
5764
  {
5770
5765
  title: "Delete component",
5771
5766
  hideButton: true,
5772
- actions: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Inline, { children: [
5773
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Button, { variant: "secondary", onClick: () => setConfirmTarget(null), children: "Cancel" }),
5774
- /* @__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)(
5775
5770
  Button,
5776
5771
  {
5777
5772
  variant: "danger",
@@ -5780,44 +5775,44 @@ function ManageModalContent({ onClose }) {
5780
5775
  }
5781
5776
  )
5782
5777
  ] }),
5783
- children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { children: [
5778
+ children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { children: [
5784
5779
  "Are you sure you want to delete ",
5785
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("b", { children: confirmTarget.label }),
5780
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("b", { children: confirmTarget.label }),
5786
5781
  "?"
5787
5782
  ] })
5788
5783
  }
5789
5784
  );
5790
5785
  }
5791
- 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: [
5792
- entries.map(([name, reg]) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: cx10("item"), children: [
5793
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: cx10("itemName"), children: reg.label || name }),
5794
- /* @__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)(
5795
5790
  "button",
5796
5791
  {
5797
5792
  className: cx10("delete"),
5798
5793
  onClick: () => setConfirmTarget({ name, label: reg.label || name }),
5799
5794
  type: "button",
5800
5795
  children: [
5801
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Trash2, { size: 12 }),
5796
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Trash2, { size: 12 }),
5802
5797
  "Delete"
5803
5798
  ]
5804
5799
  }
5805
5800
  )
5806
5801
  ] }, name)),
5807
- 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" })
5808
5803
  ] }) });
5809
5804
  }
5810
5805
  function ManageComponentsCta() {
5811
- const [open, setOpen] = (0, import_react31.useState)(false);
5806
+ const [open, setOpen] = (0, import_react30.useState)(false);
5812
5807
  const entries = useRegistrations();
5813
- const handleClose = (0, import_react31.useCallback)(() => setOpen(false), []);
5808
+ const handleClose = (0, import_react30.useCallback)(() => setOpen(false), []);
5814
5809
  if (entries.length === 0) return null;
5815
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
5816
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("button", { className: cx10("cta"), onClick: () => setOpen(true), type: "button", children: [
5817
- /* @__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 }),
5818
5813
  "Manage components"
5819
5814
  ] }),
5820
- 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 }) })
5821
5816
  ] });
5822
5817
  }
5823
5818
 
@@ -5826,22 +5821,22 @@ init_react_import();
5826
5821
  var styles_module_default11 = { "Drawer--empty": "_Drawer--empty_8e8cs_1" };
5827
5822
 
5828
5823
  // src/components/Drawer/index.tsx
5829
- var import_jsx_runtime37 = require("react/jsx-runtime");
5824
+ var import_jsx_runtime36 = require("react/jsx-runtime");
5830
5825
  var usePuck2 = (0, import_core7.createUsePuck)();
5831
5826
  var cx11 = get_class_name_factory_default("Drawer", styles_module_default11);
5832
5827
  var createDrawer = (designModeVisible) => function Drawer({ children }) {
5833
5828
  const config = usePuck2((s) => s.config);
5834
5829
  if (Object.keys(config.components).length === 0) {
5835
- 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" });
5836
5831
  }
5837
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: cx11(), children: [
5832
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: cx11(), children: [
5838
5833
  children,
5839
- designModeVisible && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ManageComponentsCta, {})
5834
+ designModeVisible && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ManageComponentsCta, {})
5840
5835
  ] });
5841
5836
  };
5842
5837
 
5843
5838
  // src/index.tsx
5844
- var import_jsx_runtime38 = require("react/jsx-runtime");
5839
+ var import_jsx_runtime37 = require("react/jsx-runtime");
5845
5840
  function withDynamicConfig(config, data) {
5846
5841
  const registrations = getPersistedRegistrations(data);
5847
5842
  const dynamicConfig = {};
@@ -5878,16 +5873,16 @@ function createAiPlugin(opts) {
5878
5873
  return {
5879
5874
  label: "AI",
5880
5875
  name: "ai",
5881
- render: () => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Chat2, { ...rest, scrollTrackingId }),
5882
- 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, {}),
5883
5878
  mobilePanelHeight: "min-content",
5884
5879
  overrides: {
5885
5880
  drawer: createDrawer(designModeVisible),
5886
5881
  preview: ({ children }) => {
5887
5882
  if (scrollTracking) {
5888
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ScrollTracking, { trackingId: scrollTrackingId, children });
5883
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ScrollTracking, { trackingId: scrollTrackingId, children });
5889
5884
  }
5890
- 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 });
5891
5886
  }
5892
5887
  }
5893
5888
  };