markdown-flow-ui 0.1.100-beta.2 → 0.1.100-beta.21

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 (90) hide show
  1. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.cjs.js +1 -1
  2. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-input@1.8.0_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-input/es/BaseInput.es.js +1 -1
  3. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.cjs.js +1 -1
  4. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
  5. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.cjs.js +1 -1
  6. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/TextArea.es.js +1 -1
  7. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.cjs.js +1 -1
  8. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/rc-textarea@1.10.2_react-dom@19.0.1_react@19.0.1__react@19.0.1/node_modules/rc-textarea/es/index.es.js +1 -1
  9. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.cjs.js +1 -1
  10. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-custom-variable.es.js +1 -1
  11. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.cjs.js +1 -1
  12. package/dist/Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/remark-flow@0.1.6/node_modules/remark-flow/dist/remark-interaction.es.js +1 -1
  13. package/dist/_virtual/index.cjs3.js +1 -1
  14. package/dist/_virtual/index.cjs4.js +1 -1
  15. package/dist/_virtual/index.es3.js +4 -5
  16. package/dist/_virtual/index.es3.js.map +1 -1
  17. package/dist/_virtual/index.es4.js +5 -4
  18. package/dist/_virtual/index.es4.js.map +1 -1
  19. package/dist/assets/markdown-flow-ui.css +1 -1
  20. package/dist/components/ContentRender/ContentRender.cjs.js +2 -2
  21. package/dist/components/ContentRender/ContentRender.cjs.js.map +1 -1
  22. package/dist/components/ContentRender/ContentRender.d.ts +13 -10
  23. package/dist/components/ContentRender/ContentRender.es.js +175 -158
  24. package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
  25. package/dist/components/ContentRender/IframeSandbox.cjs.js +3 -3
  26. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  27. package/dist/components/ContentRender/IframeSandbox.d.ts +1 -0
  28. package/dist/components/ContentRender/IframeSandbox.es.js +331 -202
  29. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  30. package/dist/components/ContentRender/SandboxApp.cjs.js +3 -3
  31. package/dist/components/ContentRender/SandboxApp.cjs.js.map +1 -1
  32. package/dist/components/ContentRender/SandboxApp.d.ts +4 -0
  33. package/dist/components/ContentRender/SandboxApp.es.js +144 -111
  34. package/dist/components/ContentRender/SandboxApp.es.js.map +1 -1
  35. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js +1 -1
  36. package/dist/components/ContentRender/plugins/CustomVariable.cjs.js.map +1 -1
  37. package/dist/components/ContentRender/plugins/CustomVariable.es.js +68 -64
  38. package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
  39. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js +1 -1
  40. package/dist/components/MarkdownFlow/MarkdownFlow.cjs.js.map +1 -1
  41. package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +3 -0
  42. package/dist/components/MarkdownFlow/MarkdownFlow.es.js +19 -16
  43. package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
  44. package/dist/components/Slide/Player.cjs.js +1 -1
  45. package/dist/components/Slide/Player.cjs.js.map +1 -1
  46. package/dist/components/Slide/Player.d.ts +1 -0
  47. package/dist/components/Slide/Player.es.js +208 -168
  48. package/dist/components/Slide/Player.es.js.map +1 -1
  49. package/dist/components/Slide/Slide.cjs.js +1 -1
  50. package/dist/components/Slide/Slide.cjs.js.map +1 -1
  51. package/dist/components/Slide/Slide.d.ts +13 -0
  52. package/dist/components/Slide/Slide.es.js +374 -255
  53. package/dist/components/Slide/Slide.es.js.map +1 -1
  54. package/dist/components/Slide/Slide.stories.d.ts +21 -1
  55. package/dist/components/Slide/index.d.ts +3 -3
  56. package/dist/components/Slide/types.d.ts +6 -6
  57. package/dist/components/Slide/useSlide.cjs.js +1 -1
  58. package/dist/components/Slide/useSlide.cjs.js.map +1 -1
  59. package/dist/components/Slide/useSlide.d.ts +4 -1
  60. package/dist/components/Slide/useSlide.es.js +115 -81
  61. package/dist/components/Slide/useSlide.es.js.map +1 -1
  62. package/dist/components/Slide/useWakePlayerFromIframe.cjs.js +2 -0
  63. package/dist/components/Slide/useWakePlayerFromIframe.cjs.js.map +1 -0
  64. package/dist/components/Slide/useWakePlayerFromIframe.d.ts +7 -0
  65. package/dist/components/Slide/useWakePlayerFromIframe.es.js +89 -0
  66. package/dist/components/Slide/useWakePlayerFromIframe.es.js.map +1 -0
  67. package/dist/components/index.d.ts +4 -2
  68. package/dist/components/ui/inputGroup/textarea.cjs.js +1 -1
  69. package/dist/components/ui/inputGroup/textarea.es.js +1 -1
  70. package/dist/index.cjs.js +1 -1
  71. package/dist/index.es.js +24 -22
  72. package/dist/lib/interaction-defaults.cjs.js +2 -0
  73. package/dist/lib/interaction-defaults.cjs.js.map +1 -0
  74. package/dist/lib/interaction-defaults.es.js +106 -0
  75. package/dist/lib/interaction-defaults.es.js.map +1 -0
  76. package/dist/lib/sandboxInteraction.cjs.js +2 -0
  77. package/dist/lib/sandboxInteraction.cjs.js.map +1 -0
  78. package/dist/lib/sandboxInteraction.d.ts +8 -0
  79. package/dist/lib/sandboxInteraction.es.js +12 -0
  80. package/dist/lib/sandboxInteraction.es.js.map +1 -0
  81. package/dist/markdown-flow-ui-lib.css +1 -1
  82. package/dist/renderer.cjs.js +1 -1
  83. package/dist/renderer.d.ts +5 -3
  84. package/dist/renderer.es.js +18 -16
  85. package/package.json +17 -2
  86. package/dist/components/Slide/interaction-defaults.cjs.js +0 -2
  87. package/dist/components/Slide/interaction-defaults.cjs.js.map +0 -1
  88. package/dist/components/Slide/interaction-defaults.es.js +0 -85
  89. package/dist/components/Slide/interaction-defaults.es.js.map +0 -1
  90. /package/dist/{components/Slide → lib}/interaction-defaults.d.ts +0 -0
@@ -1,14 +1,14 @@
1
1
  import { j as s } from "../../../_virtual/jsx-runtime.es.js";
2
2
  import j from "react";
3
- import { Button as K } from "../../ui/button.es.js";
4
- import { Checkbox as F } from "../../ui/checkbox.es.js";
3
+ import { Button as F } from "../../ui/button.es.js";
4
+ import { Checkbox as G } from "../../ui/checkbox.es.js";
5
5
  import T from "../MarkdownFlowInput.es.js";
6
- import { InputGroup as G, InputGroupTextarea as O } from "../../ui/inputGroup/input-group.es.js";
7
- import { cn as R } from "../../../lib/utils.es.js";
6
+ import { InputGroup as O, InputGroupTextarea as R } from "../../ui/inputGroup/input-group.es.js";
7
+ import { cn as y } from "../../../lib/utils.es.js";
8
8
  const _ = ({
9
9
  node: e,
10
- readonly: r,
11
- selectedValues: l,
10
+ readonly: l,
11
+ selectedValues: r,
12
12
  inputValue: p,
13
13
  confirmButtonText: m,
14
14
  handleCheckboxChange: x,
@@ -16,13 +16,13 @@ const _ = ({
16
16
  handleKeyDown: o,
17
17
  handleConfirmClick: n
18
18
  }) => {
19
- const u = e.properties?.placeholder, c = r || l.length === 0 && !p?.trim(), v = (i) => /* @__PURE__ */ s.jsx(
19
+ const u = e.properties?.placeholder, c = l || r.length === 0 && !p?.trim(), v = (a) => /* @__PURE__ */ s.jsx(
20
20
  "span",
21
21
  {
22
- className: R(
22
+ className: y(
23
23
  "multi-select-confirm-wrapper flex flex-col items-center",
24
24
  c ? "opacity-50 cursor-not-allowed" : "cursor-pointer",
25
- i
25
+ a
26
26
  ),
27
27
  children: /* @__PURE__ */ s.jsx(
28
28
  "button",
@@ -37,14 +37,14 @@ const _ = ({
37
37
  }
38
38
  );
39
39
  return /* @__PURE__ */ s.jsxs("span", { className: "multi-select-container flex w-full flex-col", children: [
40
- /* @__PURE__ */ s.jsx("span", { className: "flex flex-wrap gap-y-[9px] gap-x-6", children: e.properties?.buttonTexts?.map((i, N) => {
41
- const b = e.properties?.buttonValues?.[N], f = b !== void 0 ? b : i;
40
+ /* @__PURE__ */ s.jsx("span", { className: "flex flex-wrap gap-y-[9px] gap-x-6", children: e.properties?.buttonTexts?.map((a, N) => {
41
+ const b = e.properties?.buttonValues?.[N], f = b !== void 0 ? b : a;
42
42
  return /* @__PURE__ */ s.jsx(
43
- F,
43
+ G,
44
44
  {
45
- label: i,
46
- disabled: r,
47
- checked: l.includes(f),
45
+ label: a,
46
+ disabled: l,
47
+ checked: r.includes(f),
48
48
  onCheckedChange: (d) => x(f, d),
49
49
  className: "text-sm"
50
50
  },
@@ -52,10 +52,10 @@ const _ = ({
52
52
  );
53
53
  }) }),
54
54
  u ? /* @__PURE__ */ s.jsx("span", { className: "block mb-1 w-full max-w-[500px]", children: /* @__PURE__ */ s.jsxs("span", { className: "multi-select-input-row flex w-full items-end gap-3", children: [
55
- /* @__PURE__ */ s.jsx(G, { "data-disabled": r, className: "flex-1", children: /* @__PURE__ */ s.jsx(
56
- O,
55
+ /* @__PURE__ */ s.jsx(O, { "data-disabled": l, className: "flex-1", children: /* @__PURE__ */ s.jsx(
56
+ R,
57
57
  {
58
- disabled: r,
58
+ disabled: l,
59
59
  placeholder: u,
60
60
  value: p,
61
61
  onChange: h,
@@ -69,8 +69,8 @@ const _ = ({
69
69
  ] });
70
70
  }, z = ({
71
71
  node: e,
72
- readonly: r,
73
- resolvedDefaultButtonText: l,
72
+ readonly: l,
73
+ resolvedDefaultButtonText: r,
74
74
  handleButtonClick: p,
75
75
  inputValue: m,
76
76
  handleInputChange: x,
@@ -79,14 +79,18 @@ const _ = ({
79
79
  /* @__PURE__ */ s.jsx("span", { className: "flex flex-wrap gap-y-[9px] gap-x-2", children: e.properties?.buttonTexts?.map((o, n) => {
80
80
  const u = e.properties?.buttonValues?.[n], c = u !== void 0 ? u : o;
81
81
  return /* @__PURE__ */ s.jsx(
82
- K,
82
+ F,
83
83
  {
84
- disabled: r,
84
+ disabled: l,
85
85
  variant: "outline",
86
86
  type: "button",
87
87
  size: "sm",
88
88
  onClick: () => p(c),
89
- className: `cursor-pointer h-8 text-sm hover:bg-gray-200 ${l === o ? "select" : ""}`,
89
+ className: y(
90
+ "max-w-full shrink whitespace-normal break-words text-left leading-5 h-auto min-h-8 px-3 py-1.5",
91
+ "hover:bg-gray-200",
92
+ r === o && "select"
93
+ ),
90
94
  children: o
91
95
  },
92
96
  n
@@ -95,7 +99,7 @@ const _ = ({
95
99
  e.properties?.placeholder && /* @__PURE__ */ s.jsx("span", { className: "mt-[9px] mb-1", children: /* @__PURE__ */ s.jsx(
96
100
  T,
97
101
  {
98
- disabled: r,
102
+ disabled: l,
99
103
  placeholder: e.properties.placeholder,
100
104
  value: m,
101
105
  onChange: x,
@@ -105,24 +109,24 @@ const _ = ({
105
109
  ) })
106
110
  ] }), L = ({
107
111
  readonly: e,
108
- placeholder: r,
109
- value: l,
112
+ placeholder: l,
113
+ value: r,
110
114
  onChange: p,
111
115
  onSend: m
112
- }) => r ? /* @__PURE__ */ s.jsx(
116
+ }) => l ? /* @__PURE__ */ s.jsx(
113
117
  T,
114
118
  {
115
119
  disabled: e,
116
- placeholder: r,
117
- value: l,
120
+ placeholder: l,
121
+ value: r,
118
122
  onChange: p,
119
123
  onSend: m,
120
- title: r
124
+ title: l
121
125
  }
122
- ) : null, Q = ({
126
+ ) : null, W = ({
123
127
  node: e,
124
- readonly: r,
125
- defaultButtonText: l,
128
+ readonly: l,
129
+ defaultButtonText: r,
126
130
  defaultInputText: p,
127
131
  defaultSelectedValues: m,
128
132
  onSend: x,
@@ -132,88 +136,88 @@ const _ = ({
132
136
  }) => {
133
137
  const [n, u] = j.useState(p || ""), [c, v] = j.useState(
134
138
  m || []
135
- ), i = e.properties?.isMultiSelect ?? !1, N = e.properties?.buttonTexts || [], b = !i && N.length === 0 && !e.properties?.placeholder, f = e.properties?.variableName?.trim() || l || "Submit", d = j.useMemo(() => b ? {
139
+ ), a = e.properties?.isMultiSelect ?? !1, N = e.properties?.buttonTexts || [], b = !a && N.length === 0 && !e.properties?.placeholder, f = e.properties?.variableName?.trim() || r || "Submit", d = j.useMemo(() => b ? {
136
140
  ...e,
137
141
  properties: {
138
142
  ...e.properties || {},
139
143
  buttonTexts: [f],
140
144
  buttonValues: [f]
141
145
  }
142
- } : e, [f, e, b]), g = d.properties?.buttonTexts || [], k = d.properties?.buttonValues || [], w = !i && g.length > 0, M = (t) => {
143
- const a = {
146
+ } : e, [f, e, b]), g = d.properties?.buttonTexts || [], w = d.properties?.buttonValues || [], C = !a && g.length > 0, M = (t) => {
147
+ const i = {
144
148
  variableName: e.properties?.variableName || "",
145
149
  buttonText: t
146
150
  };
147
- o?.(a) && x?.(a);
148
- }, y = (t, a) => {
149
- v((I) => a ? [...I, t] : I.filter((E) => E !== t));
151
+ o?.(i) && x?.(i);
152
+ }, B = (t, i) => {
153
+ v((I) => i ? [...I, t] : I.filter((K) => K !== t));
150
154
  }, V = () => {
151
- const t = c.length === 0 && !n?.trim(), a = {
155
+ const t = c.length === 0 && !n?.trim(), i = {
152
156
  variableName: e.properties?.variableName || "",
153
157
  selectedValues: c,
154
158
  inputText: n?.trim() || void 0
155
159
  };
156
- r || t || o?.(a) && x?.(a);
160
+ l || t || o?.(i) && x?.(i);
157
161
  }, S = (t) => {
158
162
  u(t.target.value);
159
- }, B = (t) => {
160
- t.nativeEvent.isComposing || t.keyCode === 229 || t.key === "Enter" && !t.shiftKey && (t.preventDefault(), i ? c.length === 0 && !n.trim() || V() : C());
161
- }, C = () => {
163
+ }, D = (t) => {
164
+ t.nativeEvent.isComposing || t.keyCode === 229 || t.key === "Enter" && !t.shiftKey && (t.preventDefault(), a ? c.length === 0 && !n.trim() || V() : k());
165
+ }, k = () => {
162
166
  const t = {
163
167
  variableName: e.properties?.variableName || "",
164
168
  inputText: n
165
169
  };
166
170
  o?.(t) && x?.(t);
167
- }, D = j.useMemo(() => {
168
- if (!l)
171
+ }, E = j.useMemo(() => {
172
+ if (!r)
169
173
  return;
170
- const t = k.indexOf(l);
174
+ const t = w.indexOf(r);
171
175
  if (t > -1)
172
- return g[t] ?? l;
173
- const a = g.indexOf(l);
174
- if (a > -1)
175
- return g[a];
176
- }, [l, g, k]);
176
+ return g[t] ?? r;
177
+ const i = g.indexOf(r);
178
+ if (i > -1)
179
+ return g[i];
180
+ }, [r, g, w]);
177
181
  return /* @__PURE__ */ s.jsxs("span", { className: "custom-variable-container inline-flex items-center flex-wrap", children: [
178
- i && /* @__PURE__ */ s.jsx(
182
+ a && /* @__PURE__ */ s.jsx(
179
183
  _,
180
184
  {
181
185
  node: e,
182
- readonly: r,
186
+ readonly: l,
183
187
  selectedValues: c,
184
188
  inputValue: n,
185
189
  confirmButtonText: h,
186
- handleCheckboxChange: y,
190
+ handleCheckboxChange: B,
187
191
  handleInputChange: S,
188
- handleKeyDown: B,
192
+ handleKeyDown: D,
189
193
  handleConfirmClick: V
190
194
  }
191
195
  ),
192
- !i && w && /* @__PURE__ */ s.jsx(
196
+ !a && C && /* @__PURE__ */ s.jsx(
193
197
  z,
194
198
  {
195
199
  node: d,
196
- readonly: r,
197
- resolvedDefaultButtonText: D,
200
+ readonly: l,
201
+ resolvedDefaultButtonText: E,
198
202
  handleButtonClick: M,
199
203
  inputValue: n,
200
204
  handleInputChange: S,
201
- handleSendClick: C
205
+ handleSendClick: k
202
206
  }
203
207
  ),
204
- !i && !w && e.properties?.placeholder && /* @__PURE__ */ s.jsx(
208
+ !a && !C && e.properties?.placeholder && /* @__PURE__ */ s.jsx(
205
209
  L,
206
210
  {
207
- readonly: r,
211
+ readonly: l,
208
212
  placeholder: e.properties.placeholder,
209
213
  value: n,
210
214
  onChange: S,
211
- onSend: C
215
+ onSend: k
212
216
  }
213
217
  )
214
218
  ] });
215
219
  };
216
220
  export {
217
- Q as default
221
+ W as default
218
222
  };
219
223
  //# sourceMappingURL=CustomVariable.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomVariable.es.js","sources":["../../../../src/components/ContentRender/plugins/CustomVariable.tsx"],"sourcesContent":["import React from \"react\";\nimport type { Components } from \"react-markdown\";\nimport { OnSendContentParams } from \"../../types\";\nimport { Button } from \"../../ui/button\";\nimport { Checkbox } from \"../../ui/checkbox\";\nimport MarkdownFlowInput from \"../MarkdownFlowInput\";\nimport {\n InputGroup,\n InputGroupTextarea,\n} from \"../../ui/inputGroup/input-group\";\nimport { cn } from \"../../../lib/utils\";\n\n// Define custom variable node type\ninterface CustomVariableNode {\n tagName: \"custom-variable\";\n properties?: {\n variableName?: string;\n buttonTexts?: string[];\n buttonValues?: string[];\n placeholder?: string;\n isMultiSelect?: boolean;\n };\n}\n\n// Define custom variable component Props type\ninterface CustomVariableProps {\n node: CustomVariableNode;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n onSend?: (content: OnSendContentParams) => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n beforeSend?: (param: OnSendContentParams) => boolean;\n}\n\ninterface ComponentsWithCustomVariable extends Components {\n \"custom-variable\"?: React.ComponentType<CustomVariableProps>;\n}\n\n// Multi select section( with checkboxes and input)\ninterface MultiSelectSectionProps {\n node: CustomVariableNode;\n readonly?: boolean;\n selectedValues: string[];\n inputValue: string;\n confirmButtonText: string;\n handleCheckboxChange: (value: string, checked: boolean) => void;\n handleInputChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n handleKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n handleConfirmClick: () => void;\n}\n\nconst MultiSelectSection = ({\n node,\n readonly,\n selectedValues,\n inputValue,\n confirmButtonText,\n handleCheckboxChange,\n handleInputChange,\n handleKeyDown,\n handleConfirmClick,\n}: MultiSelectSectionProps) => {\n const placeholder = node.properties?.placeholder;\n const confirmDisabled =\n readonly || (selectedValues.length === 0 && !inputValue?.trim());\n\n const renderConfirmButton = (extraWrapperClassName?: string) => (\n <span\n className={cn(\n \"multi-select-confirm-wrapper flex flex-col items-center\",\n confirmDisabled ? \"opacity-50 cursor-not-allowed\" : \"cursor-pointer\",\n extraWrapperClassName\n )}\n >\n <button\n type=\"button\"\n className=\"multi-select-confirm-button text-sm font-medium text-primary\"\n disabled={confirmDisabled}\n onClick={handleConfirmClick}\n >\n {confirmButtonText}\n </button>\n </span>\n );\n\n return (\n <span className=\"multi-select-container flex w-full flex-col\">\n <span className=\"flex flex-wrap gap-y-[9px] gap-x-6\">\n {node.properties?.buttonTexts?.map((text, index) => {\n const value = node.properties?.buttonValues?.[index];\n const buttonValue = value !== undefined ? value : text;\n return (\n <Checkbox\n key={index}\n label={text}\n disabled={readonly}\n checked={selectedValues.includes(buttonValue)}\n onCheckedChange={(checked) =>\n handleCheckboxChange(buttonValue, checked)\n }\n className=\"text-sm\"\n />\n );\n })}\n </span>\n {placeholder ? (\n <span className=\"block mb-1 w-full max-w-[500px]\">\n <span className=\"multi-select-input-row flex w-full items-end gap-3\">\n <InputGroup data-disabled={readonly} className=\"flex-1\">\n <InputGroupTextarea\n disabled={readonly}\n placeholder={placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n className=\"text-sm px-3\"\n title={placeholder}\n />\n </InputGroup>\n {renderConfirmButton(\"shrink-0\")}\n </span>\n </span>\n ) : (\n renderConfirmButton(\"self-start multi-select-confirm-wrapper--stacked\")\n )}\n </span>\n );\n};\n\n// Single select section( with buttons and input)\ninterface SingleSelectSectionProps {\n node: CustomVariableNode;\n readonly?: boolean;\n resolvedDefaultButtonText?: string;\n handleButtonClick: (value: string) => void;\n inputValue: string;\n handleInputChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n handleSendClick: () => void;\n}\n\nconst SingleSelectSection = ({\n node,\n readonly,\n resolvedDefaultButtonText,\n handleButtonClick,\n inputValue,\n handleInputChange,\n handleSendClick,\n}: SingleSelectSectionProps) => (\n <span className=\"single-select-container inline-flex w-full flex-col\">\n <span className=\"flex flex-wrap gap-y-[9px] gap-x-2\">\n {node.properties?.buttonTexts?.map((text, index) => {\n const value = node.properties?.buttonValues?.[index];\n const buttonValue = value !== undefined ? value : text;\n return (\n <Button\n key={index}\n disabled={readonly}\n variant=\"outline\"\n type=\"button\"\n size=\"sm\"\n onClick={() => handleButtonClick(buttonValue)}\n className={`cursor-pointer h-8 text-sm hover:bg-gray-200 ${resolvedDefaultButtonText === text ? \"select\" : \"\"}`}\n >\n {text}\n </Button>\n );\n })}\n </span>\n {node.properties?.placeholder && (\n <span className=\"mt-[9px] mb-1\">\n <MarkdownFlowInput\n disabled={readonly}\n placeholder={node.properties.placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onSend={handleSendClick}\n title={node.properties.placeholder}\n />\n </span>\n )}\n </span>\n);\n\n// Pure input\ninterface InputSectionProps {\n readonly?: boolean;\n placeholder?: string;\n value: string;\n onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onSend: () => void;\n}\n\nconst InputSection = ({\n readonly,\n placeholder,\n value,\n onChange,\n onSend,\n}: InputSectionProps) => {\n if (!placeholder) {\n return null;\n }\n\n return (\n <MarkdownFlowInput\n disabled={readonly}\n placeholder={placeholder}\n value={value}\n onChange={onChange}\n onSend={onSend}\n title={placeholder}\n />\n );\n};\n\n// Define custom variable component\nconst CustomButtonInputVariable = ({\n node,\n readonly,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n onSend,\n confirmButtonText = \"Submit\", // Default to English, can be overridden\n beforeSend = () => true,\n}: CustomVariableProps) => {\n const [inputValue, setInputValue] = React.useState(defaultInputText || \"\");\n const [selectedValues, setSelectedValues] = React.useState<string[]>(\n defaultSelectedValues || []\n );\n const isMultiSelect = node.properties?.isMultiSelect ?? false;\n const baseButtonTexts = node.properties?.buttonTexts || [];\n const shouldUseFallbackButton =\n !isMultiSelect &&\n baseButtonTexts.length === 0 &&\n !node.properties?.placeholder;\n const fallbackButtonLabel =\n node.properties?.variableName?.trim() || defaultButtonText || \"Submit\";\n\n const singleSelectNode = React.useMemo<CustomVariableNode>(() => {\n if (!shouldUseFallbackButton) {\n return node;\n }\n return {\n ...node,\n properties: {\n ...(node.properties || {}),\n buttonTexts: [fallbackButtonLabel],\n buttonValues: [fallbackButtonLabel],\n },\n };\n }, [fallbackButtonLabel, node, shouldUseFallbackButton]);\n\n const singleSelectButtonTexts =\n singleSelectNode.properties?.buttonTexts || [];\n const singleSelectButtonValues =\n singleSelectNode.properties?.buttonValues || [];\n const isSingleSelect = !isMultiSelect && singleSelectButtonTexts.length > 0;\n\n const handleButtonClick = (value: string) => {\n const param = {\n variableName: node.properties?.variableName || \"\",\n buttonText: value,\n };\n if (!beforeSend?.(param)) return;\n onSend?.(param);\n };\n\n const handleCheckboxChange = (value: string, checked: boolean) => {\n setSelectedValues((prev) => {\n if (checked) {\n return [...prev, value];\n } else {\n return prev.filter((v) => v !== value);\n }\n });\n };\n\n const handleConfirmClick = () => {\n const noSelection = selectedValues.length === 0 && !inputValue?.trim();\n const param = {\n variableName: node.properties?.variableName || \"\",\n selectedValues,\n inputText: inputValue?.trim() || undefined,\n };\n if (readonly || noSelection) return;\n if (!beforeSend?.(param)) return;\n onSend?.(param);\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setInputValue(e.target.value);\n };\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.nativeEvent.isComposing || e.keyCode === 229) {\n return;\n }\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n if (isMultiSelect) {\n const noSelection = selectedValues.length === 0 && !inputValue.trim();\n if (!noSelection) handleConfirmClick();\n } else {\n handleSendClick();\n }\n }\n };\n const handleSendClick = () => {\n const param = {\n variableName: node.properties?.variableName || \"\",\n inputText: inputValue,\n };\n if (!beforeSend?.(param)) return;\n onSend?.(param);\n };\n\n const resolvedDefaultButtonText = React.useMemo(() => {\n if (!defaultButtonText) {\n return undefined;\n }\n const valueIndex = singleSelectButtonValues.indexOf(defaultButtonText);\n if (valueIndex > -1) {\n return singleSelectButtonTexts[valueIndex] ?? defaultButtonText;\n }\n const textIndex = singleSelectButtonTexts.indexOf(defaultButtonText);\n if (textIndex > -1) {\n return singleSelectButtonTexts[textIndex];\n }\n return undefined;\n }, [defaultButtonText, singleSelectButtonTexts, singleSelectButtonValues]);\n\n return (\n <span className=\"custom-variable-container inline-flex items-center flex-wrap\">\n {isMultiSelect && (\n <MultiSelectSection\n node={node}\n readonly={readonly}\n selectedValues={selectedValues}\n inputValue={inputValue}\n confirmButtonText={confirmButtonText}\n handleCheckboxChange={handleCheckboxChange}\n handleInputChange={handleInputChange}\n handleKeyDown={handleKeyDown}\n handleConfirmClick={handleConfirmClick}\n />\n )}\n\n {!isMultiSelect && isSingleSelect && (\n <SingleSelectSection\n node={singleSelectNode}\n readonly={readonly}\n resolvedDefaultButtonText={resolvedDefaultButtonText}\n handleButtonClick={handleButtonClick}\n inputValue={inputValue}\n handleInputChange={handleInputChange}\n handleSendClick={handleSendClick}\n />\n )}\n\n {!isMultiSelect && !isSingleSelect && node.properties?.placeholder && (\n <InputSection\n readonly={readonly}\n placeholder={node.properties.placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onSend={handleSendClick}\n />\n )}\n </span>\n );\n};\n\nexport default CustomButtonInputVariable;\nexport type {\n ComponentsWithCustomVariable,\n CustomVariableNode,\n CustomVariableProps,\n};\n"],"names":["MultiSelectSection","node","readonly","selectedValues","inputValue","confirmButtonText","handleCheckboxChange","handleInputChange","handleKeyDown","handleConfirmClick","placeholder","confirmDisabled","renderConfirmButton","extraWrapperClassName","jsx","cn","jsxs","text","index","value","buttonValue","Checkbox","checked","InputGroup","InputGroupTextarea","SingleSelectSection","resolvedDefaultButtonText","handleButtonClick","handleSendClick","Button","MarkdownFlowInput","InputSection","onChange","onSend","CustomButtonInputVariable","defaultButtonText","defaultInputText","defaultSelectedValues","beforeSend","setInputValue","React","setSelectedValues","isMultiSelect","baseButtonTexts","shouldUseFallbackButton","fallbackButtonLabel","singleSelectNode","singleSelectButtonTexts","singleSelectButtonValues","isSingleSelect","param","prev","v","noSelection","e","valueIndex","textIndex"],"mappings":";;;;;;;AAsDA,MAAMA,IAAqB,CAAC;AAAA,EAC1B,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,oBAAAC;AACF,MAA+B;AAC7B,QAAMC,IAAcT,EAAK,YAAY,aAC/BU,IACJT,KAAaC,EAAe,WAAW,KAAK,CAACC,GAAY,KAAA,GAErDQ,IAAsB,CAACC,MAC3BC,gBAAAA,EAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACAJ,IAAkB,kCAAkC;AAAA,QACpDE;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Y,GAAyBC,CAAwB,CAAC;AAEzE,SACEhC,gBAAAA,EAAAA,KAAC,QAAA,EAAK,WAAU,gEACb,UAAA;AAAA,IAAA0B,KACC5B,gBAAAA,EAAAA;AAAAA,MAACd;AAAA,MAAA;AAAA,QACC,MAAAC;AAAA,QACA,UAAAC;AAAA,QACA,gBAAAC;AAAA,QACA,YAAAC;AAAA,QACA,mBAAAC;AAAA,QACA,sBAAAC;AAAA,QACA,mBAAAC;AAAA,QACA,eAAAC;AAAA,QACA,oBAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,IAIH,CAACiC,KAAiBO,KACjBnC,gBAAAA,EAAAA;AAAAA,MAACW;AAAA,MAAA;AAAA,QACC,MAAMqB;AAAA,QACN,UAAA5C;AAAA,QACA,2BAAAwB;AAAA,QACA,mBAAAC;AAAA,QACA,YAAAvB;AAAA,QACA,mBAAAG;AAAA,QACA,iBAAAqB;AAAA,MAAA;AAAA,IAAA;AAAA,IAIH,CAACc,KAAiB,CAACO,KAAkBhD,EAAK,YAAY,eACrDa,gBAAAA,EAAAA;AAAAA,MAACiB;AAAA,MAAA;AAAA,QACC,UAAA7B;AAAA,QACA,aAAaD,EAAK,WAAW;AAAA,QAC7B,OAAOG;AAAA,QACP,UAAUG;AAAA,QACV,QAAQqB;AAAA,MAAA;AAAA,IAAA;AAAA,EACV,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"CustomVariable.es.js","sources":["../../../../src/components/ContentRender/plugins/CustomVariable.tsx"],"sourcesContent":["import React from \"react\";\nimport type { Components } from \"react-markdown\";\nimport { OnSendContentParams } from \"../../types\";\nimport { Button } from \"../../ui/button\";\nimport { Checkbox } from \"../../ui/checkbox\";\nimport MarkdownFlowInput from \"../MarkdownFlowInput\";\nimport {\n InputGroup,\n InputGroupTextarea,\n} from \"../../ui/inputGroup/input-group\";\nimport { cn } from \"../../../lib/utils\";\n\n// Define custom variable node type\ninterface CustomVariableNode {\n tagName: \"custom-variable\";\n properties?: {\n variableName?: string;\n buttonTexts?: string[];\n buttonValues?: string[];\n placeholder?: string;\n isMultiSelect?: boolean;\n };\n}\n\n// Define custom variable component Props type\ninterface CustomVariableProps {\n node: CustomVariableNode;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n onSend?: (content: OnSendContentParams) => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n beforeSend?: (param: OnSendContentParams) => boolean;\n}\n\ninterface ComponentsWithCustomVariable extends Components {\n \"custom-variable\"?: React.ComponentType<CustomVariableProps>;\n}\n\n// Multi select section( with checkboxes and input)\ninterface MultiSelectSectionProps {\n node: CustomVariableNode;\n readonly?: boolean;\n selectedValues: string[];\n inputValue: string;\n confirmButtonText: string;\n handleCheckboxChange: (value: string, checked: boolean) => void;\n handleInputChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n handleKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;\n handleConfirmClick: () => void;\n}\n\nconst MultiSelectSection = ({\n node,\n readonly,\n selectedValues,\n inputValue,\n confirmButtonText,\n handleCheckboxChange,\n handleInputChange,\n handleKeyDown,\n handleConfirmClick,\n}: MultiSelectSectionProps) => {\n const placeholder = node.properties?.placeholder;\n const confirmDisabled =\n readonly || (selectedValues.length === 0 && !inputValue?.trim());\n\n const renderConfirmButton = (extraWrapperClassName?: string) => (\n <span\n className={cn(\n \"multi-select-confirm-wrapper flex flex-col items-center\",\n confirmDisabled ? \"opacity-50 cursor-not-allowed\" : \"cursor-pointer\",\n extraWrapperClassName\n )}\n >\n <button\n type=\"button\"\n className=\"multi-select-confirm-button text-sm font-medium text-primary\"\n disabled={confirmDisabled}\n onClick={handleConfirmClick}\n >\n {confirmButtonText}\n </button>\n </span>\n );\n\n return (\n <span className=\"multi-select-container flex w-full flex-col\">\n <span className=\"flex flex-wrap gap-y-[9px] gap-x-6\">\n {node.properties?.buttonTexts?.map((text, index) => {\n const value = node.properties?.buttonValues?.[index];\n const buttonValue = value !== undefined ? value : text;\n return (\n <Checkbox\n key={index}\n label={text}\n disabled={readonly}\n checked={selectedValues.includes(buttonValue)}\n onCheckedChange={(checked) =>\n handleCheckboxChange(buttonValue, checked)\n }\n className=\"text-sm\"\n />\n );\n })}\n </span>\n {placeholder ? (\n <span className=\"block mb-1 w-full max-w-[500px]\">\n <span className=\"multi-select-input-row flex w-full items-end gap-3\">\n <InputGroup data-disabled={readonly} className=\"flex-1\">\n <InputGroupTextarea\n disabled={readonly}\n placeholder={placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onKeyDown={handleKeyDown}\n className=\"text-sm px-3\"\n title={placeholder}\n />\n </InputGroup>\n {renderConfirmButton(\"shrink-0\")}\n </span>\n </span>\n ) : (\n renderConfirmButton(\"self-start multi-select-confirm-wrapper--stacked\")\n )}\n </span>\n );\n};\n\n// Single select section( with buttons and input)\ninterface SingleSelectSectionProps {\n node: CustomVariableNode;\n readonly?: boolean;\n resolvedDefaultButtonText?: string;\n handleButtonClick: (value: string) => void;\n inputValue: string;\n handleInputChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n handleSendClick: () => void;\n}\n\nconst SingleSelectSection = ({\n node,\n readonly,\n resolvedDefaultButtonText,\n handleButtonClick,\n inputValue,\n handleInputChange,\n handleSendClick,\n}: SingleSelectSectionProps) => (\n <span className=\"single-select-container inline-flex w-full flex-col\">\n <span className=\"flex flex-wrap gap-y-[9px] gap-x-2\">\n {node.properties?.buttonTexts?.map((text, index) => {\n const value = node.properties?.buttonValues?.[index];\n const buttonValue = value !== undefined ? value : text;\n return (\n <Button\n key={index}\n disabled={readonly}\n variant=\"outline\"\n type=\"button\"\n size=\"sm\"\n onClick={() => handleButtonClick(buttonValue)}\n className={cn(\n \"max-w-full shrink whitespace-normal break-words text-left leading-5 h-auto min-h-8 px-3 py-1.5\",\n \"hover:bg-gray-200\",\n resolvedDefaultButtonText === text && \"select\"\n )}\n >\n {text}\n </Button>\n );\n })}\n </span>\n {node.properties?.placeholder && (\n <span className=\"mt-[9px] mb-1\">\n <MarkdownFlowInput\n disabled={readonly}\n placeholder={node.properties.placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onSend={handleSendClick}\n title={node.properties.placeholder}\n />\n </span>\n )}\n </span>\n);\n\n// Pure input\ninterface InputSectionProps {\n readonly?: boolean;\n placeholder?: string;\n value: string;\n onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onSend: () => void;\n}\n\nconst InputSection = ({\n readonly,\n placeholder,\n value,\n onChange,\n onSend,\n}: InputSectionProps) => {\n if (!placeholder) {\n return null;\n }\n\n return (\n <MarkdownFlowInput\n disabled={readonly}\n placeholder={placeholder}\n value={value}\n onChange={onChange}\n onSend={onSend}\n title={placeholder}\n />\n );\n};\n\n// Define custom variable component\nconst CustomButtonInputVariable = ({\n node,\n readonly,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n onSend,\n confirmButtonText = \"Submit\", // Default to English, can be overridden\n beforeSend = () => true,\n}: CustomVariableProps) => {\n const [inputValue, setInputValue] = React.useState(defaultInputText || \"\");\n const [selectedValues, setSelectedValues] = React.useState<string[]>(\n defaultSelectedValues || []\n );\n const isMultiSelect = node.properties?.isMultiSelect ?? false;\n const baseButtonTexts = node.properties?.buttonTexts || [];\n const shouldUseFallbackButton =\n !isMultiSelect &&\n baseButtonTexts.length === 0 &&\n !node.properties?.placeholder;\n const fallbackButtonLabel =\n node.properties?.variableName?.trim() || defaultButtonText || \"Submit\";\n\n const singleSelectNode = React.useMemo<CustomVariableNode>(() => {\n if (!shouldUseFallbackButton) {\n return node;\n }\n return {\n ...node,\n properties: {\n ...(node.properties || {}),\n buttonTexts: [fallbackButtonLabel],\n buttonValues: [fallbackButtonLabel],\n },\n };\n }, [fallbackButtonLabel, node, shouldUseFallbackButton]);\n\n const singleSelectButtonTexts =\n singleSelectNode.properties?.buttonTexts || [];\n const singleSelectButtonValues =\n singleSelectNode.properties?.buttonValues || [];\n const isSingleSelect = !isMultiSelect && singleSelectButtonTexts.length > 0;\n\n const handleButtonClick = (value: string) => {\n const param = {\n variableName: node.properties?.variableName || \"\",\n buttonText: value,\n };\n if (!beforeSend?.(param)) return;\n onSend?.(param);\n };\n\n const handleCheckboxChange = (value: string, checked: boolean) => {\n setSelectedValues((prev) => {\n if (checked) {\n return [...prev, value];\n } else {\n return prev.filter((v) => v !== value);\n }\n });\n };\n\n const handleConfirmClick = () => {\n const noSelection = selectedValues.length === 0 && !inputValue?.trim();\n const param = {\n variableName: node.properties?.variableName || \"\",\n selectedValues,\n inputText: inputValue?.trim() || undefined,\n };\n if (readonly || noSelection) return;\n if (!beforeSend?.(param)) return;\n onSend?.(param);\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setInputValue(e.target.value);\n };\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (e.nativeEvent.isComposing || e.keyCode === 229) {\n return;\n }\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n if (isMultiSelect) {\n const noSelection = selectedValues.length === 0 && !inputValue.trim();\n if (!noSelection) handleConfirmClick();\n } else {\n handleSendClick();\n }\n }\n };\n const handleSendClick = () => {\n const param = {\n variableName: node.properties?.variableName || \"\",\n inputText: inputValue,\n };\n if (!beforeSend?.(param)) return;\n onSend?.(param);\n };\n\n const resolvedDefaultButtonText = React.useMemo(() => {\n if (!defaultButtonText) {\n return undefined;\n }\n const valueIndex = singleSelectButtonValues.indexOf(defaultButtonText);\n if (valueIndex > -1) {\n return singleSelectButtonTexts[valueIndex] ?? defaultButtonText;\n }\n const textIndex = singleSelectButtonTexts.indexOf(defaultButtonText);\n if (textIndex > -1) {\n return singleSelectButtonTexts[textIndex];\n }\n return undefined;\n }, [defaultButtonText, singleSelectButtonTexts, singleSelectButtonValues]);\n\n return (\n <span className=\"custom-variable-container inline-flex items-center flex-wrap\">\n {isMultiSelect && (\n <MultiSelectSection\n node={node}\n readonly={readonly}\n selectedValues={selectedValues}\n inputValue={inputValue}\n confirmButtonText={confirmButtonText}\n handleCheckboxChange={handleCheckboxChange}\n handleInputChange={handleInputChange}\n handleKeyDown={handleKeyDown}\n handleConfirmClick={handleConfirmClick}\n />\n )}\n\n {!isMultiSelect && isSingleSelect && (\n <SingleSelectSection\n node={singleSelectNode}\n readonly={readonly}\n resolvedDefaultButtonText={resolvedDefaultButtonText}\n handleButtonClick={handleButtonClick}\n inputValue={inputValue}\n handleInputChange={handleInputChange}\n handleSendClick={handleSendClick}\n />\n )}\n\n {!isMultiSelect && !isSingleSelect && node.properties?.placeholder && (\n <InputSection\n readonly={readonly}\n placeholder={node.properties.placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onSend={handleSendClick}\n />\n )}\n </span>\n );\n};\n\nexport default CustomButtonInputVariable;\nexport type {\n ComponentsWithCustomVariable,\n CustomVariableNode,\n CustomVariableProps,\n};\n"],"names":["MultiSelectSection","node","readonly","selectedValues","inputValue","confirmButtonText","handleCheckboxChange","handleInputChange","handleKeyDown","handleConfirmClick","placeholder","confirmDisabled","renderConfirmButton","extraWrapperClassName","jsx","cn","jsxs","text","index","value","buttonValue","Checkbox","checked","InputGroup","InputGroupTextarea","SingleSelectSection","resolvedDefaultButtonText","handleButtonClick","handleSendClick","Button","MarkdownFlowInput","InputSection","onChange","onSend","CustomButtonInputVariable","defaultButtonText","defaultInputText","defaultSelectedValues","beforeSend","setInputValue","React","setSelectedValues","isMultiSelect","baseButtonTexts","shouldUseFallbackButton","fallbackButtonLabel","singleSelectNode","singleSelectButtonTexts","singleSelectButtonValues","isSingleSelect","param","prev","v","noSelection","e","valueIndex","textIndex"],"mappings":";;;;;;;AAsDA,MAAMA,IAAqB,CAAC;AAAA,EAC1B,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,oBAAAC;AACF,MAA+B;AAC7B,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MAAM;AACpD,QAAI,CAACL;AACH;AAEF,UAAMoB,IAAaP,EAAyB,QAAQb,CAAiB;AACrE,QAAIoB,IAAa;AACf,aAAOR,EAAwBQ,CAAU,KAAKpB;AAEhD,UAAMqB,IAAYT,EAAwB,QAAQZ,CAAiB;AACnE,QAAIqB,IAAY;AACd,aAAOT,EAAwBS,CAAS;AAAA,EAG5C,GAAG,CAACrB,GAAmBY,GAAyBC,CAAwB,CAAC;AAEzE,SACEhC,gBAAAA,EAAAA,KAAC,QAAA,EAAK,WAAU,gEACb,UAAA;AAAA,IAAA0B,KACC5B,gBAAAA,EAAAA;AAAAA,MAACd;AAAA,MAAA;AAAA,QACC,MAAAC;AAAA,QACA,UAAAC;AAAA,QACA,gBAAAC;AAAA,QACA,YAAAC;AAAA,QACA,mBAAAC;AAAA,QACA,sBAAAC;AAAA,QACA,mBAAAC;AAAA,QACA,eAAAC;AAAA,QACA,oBAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,IAIH,CAACiC,KAAiBO,KACjBnC,gBAAAA,EAAAA;AAAAA,MAACW;AAAA,MAAA;AAAA,QACC,MAAMqB;AAAA,QACN,UAAA5C;AAAA,QACA,2BAAAwB;AAAA,QACA,mBAAAC;AAAA,QACA,YAAAvB;AAAA,QACA,mBAAAG;AAAA,QACA,iBAAAqB;AAAA,MAAA;AAAA,IAAA;AAAA,IAIH,CAACc,KAAiB,CAACO,KAAkBhD,EAAK,YAAY,eACrDa,gBAAAA,EAAAA;AAAAA,MAACiB;AAAA,MAAA;AAAA,QACC,UAAA7B;AAAA,QACA,aAAaD,EAAK,WAAW;AAAA,QAC7B,OAAOG;AAAA,QACP,UAAUG;AAAA,QACV,QAAQqB;AAAA,MAAA;AAAA,IAAA;AAAA,EACV,GAEJ;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("../../_virtual/jsx-runtime.cjs.js"),T=require("../ContentRender/ContentRender.cjs.js");require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");require("react");;/* empty css */const B=({initialContentList:n=[],customRenderBar:d,onSend:i,typingSpeed:s,enableTypewriter:o=!1,onBlockComplete:a,confirmButtonText:l,copyButtonText:c,copiedButtonText:m,beforeSend:p})=>u.jsxRuntimeExports.jsx("div",{className:"markdown-flow",children:n.map((e,r)=>{const t=e.isFinished??!1,x=!t&&o,y=t?void 0:i,S=t?void 0:s,f=p??(()=>!0);return u.jsxRuntimeExports.jsx(T.default,{content:e.content,defaultInputText:e.defaultInputText,defaultButtonText:e.defaultButtonText,defaultSelectedValues:e.defaultSelectedValues,readonly:e.readonly,enableTypewriter:x,customRenderBar:e.customRenderBar||d,onSend:y,beforeSend:f,onClickCustomButtonAfterContent:e.onClickCustomButtonAfterContent,typingSpeed:S,confirmButtonText:l,copyButtonText:c,copiedButtonText:m,dynamicInteractionFormat:e.dynamicInteractionFormat,onTypeFinished:()=>{a?.(r)}},r)})});exports.default=B;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("../../_virtual/jsx-runtime.cjs.js"),B=require("../ContentRender/ContentRender.cjs.js");require("../ContentRender/IframeSandbox.cjs.js");require("../ui/inputGroup/input-group.cjs.js");require("react");;/* empty css */const C=({initialContentList:s=[],customRenderBar:n,onSend:d,typingSpeed:i,enableTypewriter:a=!1,onBlockComplete:o,confirmButtonText:l,copyButtonText:c,copiedButtonText:m,beforeSend:p,interactionDefaultValueOptions:x})=>u.jsxRuntimeExports.jsx("div",{className:"markdown-flow",children:s.map((e,r)=>{const t=e.isFinished??!1,y=!t&&a,S=t?void 0:d,T=t?void 0:i,f=p??(()=>!0);return u.jsxRuntimeExports.jsx(B.default,{content:e.content,userInput:e.userInput,defaultInputText:e.defaultInputText,defaultButtonText:e.defaultButtonText,defaultSelectedValues:e.defaultSelectedValues,readonly:e.readonly,enableTypewriter:y,customRenderBar:e.customRenderBar||n,onSend:S,beforeSend:f,interactionDefaultValueOptions:x,onClickCustomButtonAfterContent:e.onClickCustomButtonAfterContent,typingSpeed:T,confirmButtonText:l,copyButtonText:c,copiedButtonText:m,dynamicInteractionFormat:e.dynamicInteractionFormat,onTypeFinished:()=>{o?.(r)}},r)})});exports.default=C;
2
2
  //# sourceMappingURL=MarkdownFlow.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownFlow.cjs.js","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport ContentRender from \"../ContentRender\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport \"./markdownFlow.css\";\n\nexport interface MarkdownFlowProps {\n initialContentList?: {\n content: string;\n isFinished?: boolean;\n defaultInputText?: string;\n defaultButtonText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onBlockComplete?: (blockIndex: number) => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text for code blocks\n copyButtonText?: string;\n // Copied state text for code blocks\n copiedButtonText?: string;\n beforeSend?: (content: OnSendContentParams) => boolean;\n}\n\nconst MarkdownFlow: React.FC<MarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend: onSendProp,\n typingSpeed: typingSpeedProp,\n enableTypewriter = false,\n onBlockComplete,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n}) => {\n return (\n <div className=\"markdown-flow\">\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const enableTypewriterForBlock = !isFinished && enableTypewriter;\n const onSend = isFinished ? undefined : onSendProp;\n const typingSpeed = isFinished ? undefined : typingSpeedProp;\n const beforeSend = beforeSendProp ?? (() => true);\n return (\n <ContentRender\n key={index}\n content={contentInfo.content}\n defaultInputText={contentInfo.defaultInputText}\n defaultButtonText={contentInfo.defaultButtonText}\n defaultSelectedValues={contentInfo.defaultSelectedValues}\n readonly={contentInfo.readonly}\n enableTypewriter={enableTypewriterForBlock}\n customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n beforeSend={beforeSend}\n onClickCustomButtonAfterContent={\n contentInfo.onClickCustomButtonAfterContent\n }\n typingSpeed={typingSpeed}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n dynamicInteractionFormat={contentInfo.dynamicInteractionFormat}\n onTypeFinished={() => {\n onBlockComplete?.(index);\n }}\n />\n );\n })}\n </div>\n );\n};\n\nexport default MarkdownFlow;\n"],"names":["MarkdownFlow","initialContentList","customRenderBar","onSendProp","typingSpeedProp","enableTypewriter","onBlockComplete","confirmButtonText","copyButtonText","copiedButtonText","beforeSendProp","jsx","contentInfo","index","isFinished","enableTypewriterForBlock","onSend","typingSpeed","beforeSend","ContentRender"],"mappings":"0WA+BA,MAAMA,EAA4C,CAAC,CACjD,mBAAAC,EAAqB,CAAA,EACrB,gBAAAC,EACA,OAAQC,EACR,YAAaC,EACb,iBAAAC,EAAmB,GACnB,gBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,WAAYC,CACd,IAEIC,wBAAC,OAAI,UAAU,gBACZ,WAAmB,IAAI,CAACC,EAAaC,IAAU,CAC9C,MAAMC,EAAaF,EAAY,YAAc,GACvCG,EAA2B,CAACD,GAAcT,EAC1CW,EAASF,EAAa,OAAYX,EAClCc,EAAcH,EAAa,OAAYV,EACvCc,EAAaR,IAAmB,IAAM,IAC5C,OACEC,EAAAA,kBAAAA,IAACQ,EAAAA,QAAA,CAEC,QAASP,EAAY,QACrB,iBAAkBA,EAAY,iBAC9B,kBAAmBA,EAAY,kBAC/B,sBAAuBA,EAAY,sBACnC,SAAUA,EAAY,SACtB,iBAAkBG,EAClB,gBAAiBH,EAAY,iBAAmBV,EAChD,OAAAc,EACA,WAAAE,EACA,gCACEN,EAAY,gCAEd,YAAAK,EACA,kBAAAV,EACA,eAAAC,EACA,iBAAAC,EACA,yBAA0BG,EAAY,yBACtC,eAAgB,IAAM,CACpBN,IAAkBO,CAAK,CACzB,CAAA,EApBKA,CAAA,CAuBX,CAAC,CAAA,CACH"}
1
+ {"version":3,"file":"MarkdownFlow.cjs.js","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport ContentRender from \"../ContentRender\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport \"./markdownFlow.css\";\n\nexport interface MarkdownFlowProps {\n initialContentList?: {\n content: string;\n isFinished?: boolean;\n userInput?: string;\n defaultInputText?: string;\n defaultButtonText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onBlockComplete?: (blockIndex: number) => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text for code blocks\n copyButtonText?: string;\n // Copied state text for code blocks\n copiedButtonText?: string;\n beforeSend?: (content: OnSendContentParams) => boolean;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n}\n\nconst MarkdownFlow: React.FC<MarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend: onSendProp,\n typingSpeed: typingSpeedProp,\n enableTypewriter = false,\n onBlockComplete,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n interactionDefaultValueOptions,\n}) => {\n return (\n <div className=\"markdown-flow\">\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const enableTypewriterForBlock = !isFinished && enableTypewriter;\n const onSend = isFinished ? undefined : onSendProp;\n const typingSpeed = isFinished ? undefined : typingSpeedProp;\n const beforeSend = beforeSendProp ?? (() => true);\n return (\n <ContentRender\n key={index}\n content={contentInfo.content}\n userInput={contentInfo.userInput}\n defaultInputText={contentInfo.defaultInputText}\n defaultButtonText={contentInfo.defaultButtonText}\n defaultSelectedValues={contentInfo.defaultSelectedValues}\n readonly={contentInfo.readonly}\n enableTypewriter={enableTypewriterForBlock}\n customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n beforeSend={beforeSend}\n interactionDefaultValueOptions={interactionDefaultValueOptions}\n onClickCustomButtonAfterContent={\n contentInfo.onClickCustomButtonAfterContent\n }\n typingSpeed={typingSpeed}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n dynamicInteractionFormat={contentInfo.dynamicInteractionFormat}\n onTypeFinished={() => {\n onBlockComplete?.(index);\n }}\n />\n );\n })}\n </div>\n );\n};\n\nexport default MarkdownFlow;\n"],"names":["MarkdownFlow","initialContentList","customRenderBar","onSendProp","typingSpeedProp","enableTypewriter","onBlockComplete","confirmButtonText","copyButtonText","copiedButtonText","beforeSendProp","interactionDefaultValueOptions","jsx","contentInfo","index","isFinished","enableTypewriterForBlock","onSend","typingSpeed","beforeSend","ContentRender"],"mappings":"0WAkCA,MAAMA,EAA4C,CAAC,CACjD,mBAAAC,EAAqB,CAAA,EACrB,gBAAAC,EACA,OAAQC,EACR,YAAaC,EACb,iBAAAC,EAAmB,GACnB,gBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,WAAYC,EACZ,+BAAAC,CACF,IAEIC,wBAAC,OAAI,UAAU,gBACZ,WAAmB,IAAI,CAACC,EAAaC,IAAU,CAC9C,MAAMC,EAAaF,EAAY,YAAc,GACvCG,EAA2B,CAACD,GAAcV,EAC1CY,EAASF,EAAa,OAAYZ,EAClCe,EAAcH,EAAa,OAAYX,EACvCe,EAAaT,IAAmB,IAAM,IAC5C,OACEE,EAAAA,kBAAAA,IAACQ,EAAAA,QAAA,CAEC,QAASP,EAAY,QACrB,UAAWA,EAAY,UACvB,iBAAkBA,EAAY,iBAC9B,kBAAmBA,EAAY,kBAC/B,sBAAuBA,EAAY,sBACnC,SAAUA,EAAY,SACtB,iBAAkBG,EAClB,gBAAiBH,EAAY,iBAAmBX,EAChD,OAAAe,EACA,WAAAE,EACA,+BAAAR,EACA,gCACEE,EAAY,gCAEd,YAAAK,EACA,kBAAAX,EACA,eAAAC,EACA,iBAAAC,EACA,yBAA0BI,EAAY,yBACtC,eAAgB,IAAM,CACpBP,IAAkBQ,CAAK,CACzB,CAAA,EAtBKA,CAAA,CAyBX,CAAC,CAAA,CACH"}
@@ -1,9 +1,11 @@
1
1
  import { default as React } from 'react';
2
+ import { InteractionDefaultValueOptions } from '../../lib/interaction-defaults';
2
3
  import { CustomRenderBarProps, OnSendContentParams } from '../types';
3
4
  export interface MarkdownFlowProps {
4
5
  initialContentList?: {
5
6
  content: string;
6
7
  isFinished?: boolean;
8
+ userInput?: string;
7
9
  defaultInputText?: string;
8
10
  defaultButtonText?: string;
9
11
  defaultSelectedValues?: string[];
@@ -21,6 +23,7 @@ export interface MarkdownFlowProps {
21
23
  copyButtonText?: string;
22
24
  copiedButtonText?: string;
23
25
  beforeSend?: (content: OnSendContentParams) => boolean;
26
+ interactionDefaultValueOptions?: InteractionDefaultValueOptions;
24
27
  }
25
28
  declare const MarkdownFlow: React.FC<MarkdownFlowProps>;
26
29
  export default MarkdownFlow;
@@ -1,48 +1,51 @@
1
1
  import { j as o } from "../../_virtual/jsx-runtime.es.js";
2
- import B from "../ContentRender/ContentRender.es.js";
2
+ import C from "../ContentRender/ContentRender.es.js";
3
3
  import "../ContentRender/IframeSandbox.es.js";
4
4
  import "../ui/inputGroup/input-group.es.js";
5
5
  import "react";
6
6
  /* empty css */
7
- const h = ({
7
+ const j = ({
8
8
  initialContentList: a = [],
9
9
  customRenderBar: d,
10
10
  onSend: n,
11
- typingSpeed: i,
12
- enableTypewriter: s = !1,
13
- onBlockComplete: l,
14
- confirmButtonText: u,
11
+ typingSpeed: s,
12
+ enableTypewriter: i = !1,
13
+ onBlockComplete: u,
14
+ confirmButtonText: l,
15
15
  copyButtonText: m,
16
16
  copiedButtonText: p,
17
- beforeSend: c
17
+ beforeSend: c,
18
+ interactionDefaultValueOptions: y
18
19
  }) => /* @__PURE__ */ o.jsx("div", { className: "markdown-flow", children: a.map((e, r) => {
19
- const t = e.isFinished ?? !1, y = !t && s, f = t ? void 0 : n, x = t ? void 0 : i, S = c ?? (() => !0);
20
+ const t = e.isFinished ?? !1, x = !t && i, S = t ? void 0 : n, f = t ? void 0 : s, B = c ?? (() => !0);
20
21
  return /* @__PURE__ */ o.jsx(
21
- B,
22
+ C,
22
23
  {
23
24
  content: e.content,
25
+ userInput: e.userInput,
24
26
  defaultInputText: e.defaultInputText,
25
27
  defaultButtonText: e.defaultButtonText,
26
28
  defaultSelectedValues: e.defaultSelectedValues,
27
29
  readonly: e.readonly,
28
- enableTypewriter: y,
30
+ enableTypewriter: x,
29
31
  customRenderBar: e.customRenderBar || d,
30
- onSend: f,
31
- beforeSend: S,
32
+ onSend: S,
33
+ beforeSend: B,
34
+ interactionDefaultValueOptions: y,
32
35
  onClickCustomButtonAfterContent: e.onClickCustomButtonAfterContent,
33
- typingSpeed: x,
34
- confirmButtonText: u,
36
+ typingSpeed: f,
37
+ confirmButtonText: l,
35
38
  copyButtonText: m,
36
39
  copiedButtonText: p,
37
40
  dynamicInteractionFormat: e.dynamicInteractionFormat,
38
41
  onTypeFinished: () => {
39
- l?.(r);
42
+ u?.(r);
40
43
  }
41
44
  },
42
45
  r
43
46
  );
44
47
  }) });
45
48
  export {
46
- h as default
49
+ j as default
47
50
  };
48
51
  //# sourceMappingURL=MarkdownFlow.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownFlow.es.js","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport ContentRender from \"../ContentRender\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport \"./markdownFlow.css\";\n\nexport interface MarkdownFlowProps {\n initialContentList?: {\n content: string;\n isFinished?: boolean;\n defaultInputText?: string;\n defaultButtonText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onBlockComplete?: (blockIndex: number) => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text for code blocks\n copyButtonText?: string;\n // Copied state text for code blocks\n copiedButtonText?: string;\n beforeSend?: (content: OnSendContentParams) => boolean;\n}\n\nconst MarkdownFlow: React.FC<MarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend: onSendProp,\n typingSpeed: typingSpeedProp,\n enableTypewriter = false,\n onBlockComplete,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n}) => {\n return (\n <div className=\"markdown-flow\">\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const enableTypewriterForBlock = !isFinished && enableTypewriter;\n const onSend = isFinished ? undefined : onSendProp;\n const typingSpeed = isFinished ? undefined : typingSpeedProp;\n const beforeSend = beforeSendProp ?? (() => true);\n return (\n <ContentRender\n key={index}\n content={contentInfo.content}\n defaultInputText={contentInfo.defaultInputText}\n defaultButtonText={contentInfo.defaultButtonText}\n defaultSelectedValues={contentInfo.defaultSelectedValues}\n readonly={contentInfo.readonly}\n enableTypewriter={enableTypewriterForBlock}\n customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n beforeSend={beforeSend}\n onClickCustomButtonAfterContent={\n contentInfo.onClickCustomButtonAfterContent\n }\n typingSpeed={typingSpeed}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n dynamicInteractionFormat={contentInfo.dynamicInteractionFormat}\n onTypeFinished={() => {\n onBlockComplete?.(index);\n }}\n />\n );\n })}\n </div>\n );\n};\n\nexport default MarkdownFlow;\n"],"names":["MarkdownFlow","initialContentList","customRenderBar","onSendProp","typingSpeedProp","enableTypewriter","onBlockComplete","confirmButtonText","copyButtonText","copiedButtonText","beforeSendProp","jsx","contentInfo","index","isFinished","enableTypewriterForBlock","onSend","typingSpeed","beforeSend","ContentRender"],"mappings":";;;;;;AA+BA,MAAMA,IAA4C,CAAC;AAAA,EACjD,oBAAAC,IAAqB,CAAA;AAAA,EACrB,iBAAAC;AAAA,EACA,QAAQC;AAAA,EACR,aAAaC;AAAA,EACb,kBAAAC,IAAmB;AAAA,EACnB,iBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAYC;AACd,MAEIC,gBAAAA,MAAC,SAAI,WAAU,iBACZ,YAAmB,IAAI,CAACC,GAAaC,MAAU;AAC9C,QAAMC,IAAaF,EAAY,cAAc,IACvCG,IAA2B,CAACD,KAAcT,GAC1CW,IAASF,IAAa,SAAYX,GAClCc,IAAcH,IAAa,SAAYV,GACvCc,IAAaR,MAAmB,MAAM;AAC5C,SACEC,gBAAAA,EAAAA;AAAAA,IAACQ;AAAA,IAAA;AAAA,MAEC,SAASP,EAAY;AAAA,MACrB,kBAAkBA,EAAY;AAAA,MAC9B,mBAAmBA,EAAY;AAAA,MAC/B,uBAAuBA,EAAY;AAAA,MACnC,UAAUA,EAAY;AAAA,MACtB,kBAAkBG;AAAA,MAClB,iBAAiBH,EAAY,mBAAmBV;AAAA,MAChD,QAAAc;AAAA,MACA,YAAAE;AAAA,MACA,iCACEN,EAAY;AAAA,MAEd,aAAAK;AAAA,MACA,mBAAAV;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,0BAA0BG,EAAY;AAAA,MACtC,gBAAgB,MAAM;AACpB,QAAAN,IAAkBO,CAAK;AAAA,MACzB;AAAA,IAAA;AAAA,IApBKA;AAAA,EAAA;AAuBX,CAAC,EAAA,CACH;"}
1
+ {"version":3,"file":"MarkdownFlow.es.js","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport ContentRender from \"../ContentRender\";\nimport { CustomRenderBarProps, OnSendContentParams } from \"../types\";\nimport \"./markdownFlow.css\";\n\nexport interface MarkdownFlowProps {\n initialContentList?: {\n content: string;\n isFinished?: boolean;\n userInput?: string;\n defaultInputText?: string;\n defaultButtonText?: string;\n defaultSelectedValues?: string[];\n readonly?: boolean;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n typingSpeed?: number;\n enableTypewriter?: boolean;\n onBlockComplete?: (blockIndex: number) => void;\n // Multi-select confirm button text (i18n support)\n confirmButtonText?: string;\n // Copy button text for code blocks\n copyButtonText?: string;\n // Copied state text for code blocks\n copiedButtonText?: string;\n beforeSend?: (content: OnSendContentParams) => boolean;\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n}\n\nconst MarkdownFlow: React.FC<MarkdownFlowProps> = ({\n initialContentList = [],\n customRenderBar,\n onSend: onSendProp,\n typingSpeed: typingSpeedProp,\n enableTypewriter = false,\n onBlockComplete,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n interactionDefaultValueOptions,\n}) => {\n return (\n <div className=\"markdown-flow\">\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const enableTypewriterForBlock = !isFinished && enableTypewriter;\n const onSend = isFinished ? undefined : onSendProp;\n const typingSpeed = isFinished ? undefined : typingSpeedProp;\n const beforeSend = beforeSendProp ?? (() => true);\n return (\n <ContentRender\n key={index}\n content={contentInfo.content}\n userInput={contentInfo.userInput}\n defaultInputText={contentInfo.defaultInputText}\n defaultButtonText={contentInfo.defaultButtonText}\n defaultSelectedValues={contentInfo.defaultSelectedValues}\n readonly={contentInfo.readonly}\n enableTypewriter={enableTypewriterForBlock}\n customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n beforeSend={beforeSend}\n interactionDefaultValueOptions={interactionDefaultValueOptions}\n onClickCustomButtonAfterContent={\n contentInfo.onClickCustomButtonAfterContent\n }\n typingSpeed={typingSpeed}\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n dynamicInteractionFormat={contentInfo.dynamicInteractionFormat}\n onTypeFinished={() => {\n onBlockComplete?.(index);\n }}\n />\n );\n })}\n </div>\n );\n};\n\nexport default MarkdownFlow;\n"],"names":["MarkdownFlow","initialContentList","customRenderBar","onSendProp","typingSpeedProp","enableTypewriter","onBlockComplete","confirmButtonText","copyButtonText","copiedButtonText","beforeSendProp","interactionDefaultValueOptions","jsx","contentInfo","index","isFinished","enableTypewriterForBlock","onSend","typingSpeed","beforeSend","ContentRender"],"mappings":";;;;;;AAkCA,MAAMA,IAA4C,CAAC;AAAA,EACjD,oBAAAC,IAAqB,CAAA;AAAA,EACrB,iBAAAC;AAAA,EACA,QAAQC;AAAA,EACR,aAAaC;AAAA,EACb,kBAAAC,IAAmB;AAAA,EACnB,iBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,gCAAAC;AACF,MAEIC,gBAAAA,MAAC,SAAI,WAAU,iBACZ,YAAmB,IAAI,CAACC,GAAaC,MAAU;AAC9C,QAAMC,IAAaF,EAAY,cAAc,IACvCG,IAA2B,CAACD,KAAcV,GAC1CY,IAASF,IAAa,SAAYZ,GAClCe,IAAcH,IAAa,SAAYX,GACvCe,IAAaT,MAAmB,MAAM;AAC5C,SACEE,gBAAAA,EAAAA;AAAAA,IAACQ;AAAA,IAAA;AAAA,MAEC,SAASP,EAAY;AAAA,MACrB,WAAWA,EAAY;AAAA,MACvB,kBAAkBA,EAAY;AAAA,MAC9B,mBAAmBA,EAAY;AAAA,MAC/B,uBAAuBA,EAAY;AAAA,MACnC,UAAUA,EAAY;AAAA,MACtB,kBAAkBG;AAAA,MAClB,iBAAiBH,EAAY,mBAAmBX;AAAA,MAChD,QAAAe;AAAA,MACA,YAAAE;AAAA,MACA,gCAAAR;AAAA,MACA,iCACEE,EAAY;AAAA,MAEd,aAAAK;AAAA,MACA,mBAAAX;AAAA,MACA,gBAAAC;AAAA,MACA,kBAAAC;AAAA,MACA,0BAA0BI,EAAY;AAAA,MACtC,gBAAgB,MAAM;AACpB,QAAAP,IAAkBQ,CAAK;AAAA,MACzB;AAAA,IAAA;AAAA,IAtBKA;AAAA,EAAA;AAyBX,CAAC,EAAA,CACH;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("../../_virtual/jsx-runtime.cjs.js"),t=require("react"),T=require("../../lib/utils.cjs.js");;/* empty css */const ee=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js"),te=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js"),re=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js"),se=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js"),ne=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js"),ue=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js"),le=()=>r.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[r.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),r.jsxRuntimeExports.jsx("path",{d:"M12 10H16V24H12V10ZM18 10H22V24H18V10Z",fill:"white"})]}),ce=()=>r.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[r.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),r.jsxRuntimeExports.jsx("path",{d:"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z",fill:"white"})]}),ae=({audioList:L=[],className:Z,currentAudioIndex:s=-1,defaultPlaying:u=!0,onPrev:$,onNext:F,onFullscreen:H,onEnded:M,onPlayRequest:v,onInteractionToggle:U,hasInteraction:B=!1,isInteractionOpen:K=!1,prevDisabled:z=!1,nextDisabled:O=!1,showControls:P=!0,...G})=>{const d=t.useRef(null),R=t.useRef(null),q=t.useRef(null),h=t.useRef(0),o=t.useRef(null),w=t.useRef(void 0),C=t.useRef([]),f=t.useRef(!1),n=t.useRef(!1),i=t.useRef(null),p=t.useRef(!1),[N,l]=t.useState(u),m=s>=0?L[s]:void 0,b=m?.audioUrl,x=t.useMemo(()=>[...m?.audioSegments??[]].sort((e,a)=>e.segment_index-a.segment_index),[m?.audioSegments]),A=`${s}:${m?.serialNumber??"none"}:${b??""}`;t.useEffect(()=>{w.current=m},[m]),t.useEffect(()=>{C.current=x},[x]);const W=t.useCallback(e=>e?e.startsWith("data:")?e:`data:audio/mpeg;base64,${e}`:"",[]),g=t.useCallback(()=>{const e=d.current;e&&(n.current=!1,i.current=null,f.current=!1,p.current=!1,e.pause(),e.removeAttribute("src"),e.load(),R.current=null,h.current=0,o.current=null,l(!1))},[s]),j=t.useCallback(e=>{const a=d.current;if(!a)return!1;const c=a.play();return c&&typeof c.then=="function"&&c.then(()=>{n.current=!1,p.current=!1}).catch(_=>{l(!1)}),!0},[s]),E=t.useCallback((e,a)=>{const c=d.current,_=C.current[e];if(!c||!_)return!1;const y=W(_.audio_data);h.current=e,o.current=null,f.current=!1,p.current=!0,n.current=u;const k=R.current!==y;return k&&(c.pause(),c.removeAttribute("src"),c.load(),R.current=y,c.src=y,c.load()),i.current=0,c.readyState>0&&(c.currentTime=0,i.current=null),u?k?!0:j(`start-segment:${a}`):(n.current=!1,p.current=!1,c.pause(),l(!1),!0)},[s,u,W,j]),S=t.useCallback(()=>{n.current=!1,f.current=!1,p.current=!1,l(!1),s>=0&&M?.(s)},[s,M]),V=t.useCallback(()=>{const e=h.current+1,a=C.current,c=a[e],_=w.current,y=a.some(k=>k.is_final);if(c){E(e,"ended");return}if(_?.isAudioStreaming||!y){h.current=e,o.current=e,f.current=!0,n.current=u,l(u);return}S("segments-completed")},[s,u,S,E]);t.useEffect(()=>{if(q.current===A)return;q.current=A,h.current=0,o.current=null,f.current=!1,n.current=!1,p.current=!1,R.current=null;const e=d.current;e&&(e.pause(),e.removeAttribute("src"),e.load(),l(!1))},[s,A,x.length,b]),t.useEffect(()=>{const e=d.current;if(e){if(!m){g();return}if(b){const a=R.current!==b;if(a&&(e.pause(),e.removeAttribute("src"),e.load(),R.current=b,e.src=b,e.load()),i.current=0,e.readyState>0&&(e.currentTime=0,i.current=null),n.current=u,f.current=!1,p.current=!1,!u){n.current=!1,e.pause(),l(!1);return}a||j("sync-url");return}if(o.current!==null){if(o.current<x.length){E(o.current,"wait-resume");return}f.current=!0,n.current=u,l(u);return}if(!x.length){if(m.isAudioStreaming){o.current=h.current,f.current=!0,n.current=u,l(u);return}g();return}if(!R.current){E(Math.min(h.current,x.length-1),"effect-init");return}if(!u){n.current=!1,e.pause(),l(!1);return}e.paused&&(n.current=!0,j("sync-paused-retry"))}},[m,s,x,b,u,g,E,j]),t.useEffect(()=>g,[g]);const J=t.useCallback(()=>{l(!0)},[s]),Q=t.useCallback(()=>{f.current||p.current||l(!1)},[s]),X=t.useCallback(()=>{const e=d.current;e&&i.current!==null&&(e.currentTime=i.current,i.current=null),!(!n.current||!u)&&j("canplay")},[s,u,j]),Y=t.useCallback(()=>{const e=d.current;e&&i.current!==null&&(e.currentTime=i.current,i.current=null)},[s]),D=t.useCallback(()=>{if(p.current=!1,w.current?.audioUrl||C.current.length===0){S("url-ended");return}V()},[s,S,V]),I=t.useCallback(()=>{l(!1)},[s]);return r.jsxRuntimeExports.jsxs("div",{className:T.cn("slide-player",Z),...G,children:[r.jsxRuntimeExports.jsx("audio",{ref:d,preload:"metadata",playsInline:!0,onLoadedMetadata:Y,onCanPlay:X,onPlay:J,onPause:Q,onEnded:D,onError:I}),P?r.jsxRuntimeExports.jsxs("div",{className:"slide-player__controls",children:[r.jsxRuntimeExports.jsxs("div",{className:"slide-player__group",children:[r.jsxRuntimeExports.jsx("button",{"aria-label":"More options",className:"hidden",type:"button",children:r.jsxRuntimeExports.jsx(ee.default,{className:"slide-player__icon",strokeWidth:2.25})}),r.jsxRuntimeExports.jsx("button",{"aria-label":"Volume",className:"hidden",type:"button",children:r.jsxRuntimeExports.jsx(te.default,{className:"slide-player__icon",strokeWidth:2.25})}),r.jsxRuntimeExports.jsx("button",{"aria-label":"Rewind",className:"slide-player__action",disabled:z,onClick:$,type:"button",children:r.jsxRuntimeExports.jsx(re.default,{className:"slide-player__icon",strokeWidth:2.25})}),r.jsxRuntimeExports.jsx("button",{"aria-label":N?"Pause":"Play",className:"slide-player__toggle",onClick:()=>{const e=d.current;if(!(!e||!m)){if(o.current!==null){if(N){n.current=!1,o.current=null,f.current=!1,l(!1),e.pause();return}v?.(),n.current=!0,l(!0);return}if(!e.src&&x.length>0){v?.(),E(Math.min(h.current,x.length-1),"toggle");return}if(e.paused){v?.(),n.current=!0,j("toggle-resume");return}n.current=!1,e.pause()}},type:"button",children:N?r.jsxRuntimeExports.jsx(le,{}):r.jsxRuntimeExports.jsx(ce,{})}),r.jsxRuntimeExports.jsx("button",{"aria-label":"Forward",className:"slide-player__action",disabled:O,onClick:F,type:"button",children:r.jsxRuntimeExports.jsx(se.default,{className:"slide-player__icon",strokeWidth:2.25})}),r.jsxRuntimeExports.jsx("button",{"aria-label":"Fullscreen",className:"hidden",onClick:H,type:"button",children:r.jsxRuntimeExports.jsx(ne.default,{className:"slide-player__icon",strokeWidth:2.25})})]}),r.jsxRuntimeExports.jsx("div",{className:"slide-player__separator"}),r.jsxRuntimeExports.jsx("div",{className:"slide-player__group",children:r.jsxRuntimeExports.jsx("button",{"aria-label":"Notes",className:T.cn("slide-player__action",K&&"slide-player__action--active"),disabled:!B,onClick:U,type:"button",children:r.jsxRuntimeExports.jsx(ue.default,{className:"slide-player__icon",strokeWidth:2.25})})})]}):null]})};exports.default=ae;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../_virtual/jsx-runtime.cjs.js"),r=require("react"),$=require("../../lib/utils.cjs.js");;/* empty css */const ie=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.cjs.js"),oe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/volume-2.cjs.js"),fe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-ccw.cjs.js"),de=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.cjs.js"),me=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/maximize.cjs.js"),pe=require("../../Documents/ai-shifu/markdown-flow-ui/node_modules/.pnpm/lucide-react@0.525.0_react@19.0.1/node_modules/lucide-react/dist/esm/icons/file-pen-line.cjs.js"),O=new Set,z=x=>{if(typeof document>"u"||!x||O.has(x))return;const _=document.createElement("link");_.rel="preload",_.as="audio",_.href=x,/^https?:/i.test(x)&&(_.crossOrigin="anonymous"),document.head.appendChild(_),O.add(x)},xe=()=>t.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[t.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),t.jsxRuntimeExports.jsx("path",{d:"M12 10H16V24H12V10ZM18 10H22V24H18V10Z",fill:"white"})]}),he=()=>t.jsxRuntimeExports.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"34",height:"34",viewBox:"0 0 34 34",fill:"none",children:[t.jsxRuntimeExports.jsx("path",{d:"M16.6667 33.3333C25.8714 33.3333 33.3333 25.8714 33.3333 16.6667C33.3333 7.46192 25.8714 0 16.6667 0C7.46192 0 0 7.46192 0 16.6667C0 25.8714 7.46192 33.3333 16.6667 33.3333Z",fill:"#0A0A0A"}),t.jsxRuntimeExports.jsx("path",{d:"M13.3333 10L23.3333 16.6667L13.3333 23.3333V10Z",fill:"white"})]}),Re=({audioList:x=[],className:_,currentAudioIndex:a=-1,defaultPlaying:f=!0,onLoadingChange:q,onPrev:G,onNext:J,onFullscreen:Q,onEnded:P,onPlayRequest:U,onInteractionToggle:X,hasInteraction:Y=!1,isInteractionOpen:D=!1,prevDisabled:I=!1,nextDisabled:ee=!1,showControls:re=!0,...te})=>{const h=r.useRef(null),b=r.useRef(null),V=r.useRef(null),E=r.useRef(0),o=r.useRef(null),F=r.useRef(void 0),w=r.useRef([]),K=r.useRef(!1),i=r.useRef(!1),S=r.useRef(null),p=r.useRef(!1),u=r.useRef(!1),m=r.useRef(null),R=r.useRef(!1),[T,l]=r.useState(f),d=a>=0?x[a]:void 0,k=d?.audioUrl,j=r.useMemo(()=>[...d?.audioSegments??[]].sort((e,c)=>e.segment_index-c.segment_index),[d?.audioSegments]),W=`${a}:${d?.audioKey??"none"}`;r.useEffect(()=>{F.current=d},[d]),r.useEffect(()=>{w.current=j},[j]),r.useEffect(()=>{const e=d?.audioUrl,c=a>=0?x[a+1]?.audioUrl:void 0;z(e),z(c)},[x,d?.audioUrl,a]);const n=r.useCallback(e=>{K.current!==e&&(K.current=e,q?.(e))},[q]),L=r.useCallback(e=>e?e.startsWith("data:")?e:`data:audio/mpeg;base64,${e}`:"",[]),Z=r.useCallback(()=>{const e=o.current;return e==null||e<=0?0:w.current.slice(0,e).reduce((c,s)=>c+Math.max(Number(s.duration_ms??0),0),0)/1e3},[]),N=r.useCallback(()=>{const e=h.current;e&&(u.current=!1,i.current=!1,S.current=null,m.current=null,p.current=!1,R.current=!1,e.pause(),e.removeAttribute("src"),e.load(),b.current=null,E.current=0,o.current=null,l(!1),n(!1))},[n]),g=r.useCallback(e=>{const c=h.current;if(!c)return!1;const s=c.play();return s&&typeof s.then=="function"&&s.then(()=>{u.current=!1,R.current=!1}).catch(v=>{l(!1)}),!0},[a]),C=r.useCallback((e,c)=>{const s=h.current,v=w.current[e];if(!s||!v)return!1;const y=L(v.audio_data);E.current=e,o.current=null,p.current=!1,R.current=!0;const M=f&&!i.current;u.current=M,n(!1);const H=b.current!==y;return S.current="segment",H&&(s.pause(),s.removeAttribute("src"),s.load(),b.current=y,s.src=y,s.load()),m.current=0,s.readyState>0&&(s.currentTime=0,m.current=null),M?H?!0:g(`start-segment:${c}`):(u.current=!1,R.current=!1,s.pause(),l(!1),!0)},[f,L,g,n]),A=r.useCallback(e=>{u.current=!1,p.current=!1,R.current=!1,l(!1),n(!1),a>=0&&P?.(a)},[a,P,n]),B=r.useCallback(()=>{const e=E.current+1,c=w.current,s=c[e],v=F.current,y=c.some(M=>M.is_final);if(s){C(e,"ended");return}if(v?.isAudioStreaming||!y){E.current=e,o.current=e,p.current=!0,u.current=f,l(!1),n(!0);return}A("segments-completed")},[f,A,C,n]);r.useEffect(()=>{if(V.current===W)return;V.current=W,E.current=0,o.current=null,p.current=!1,i.current=!1,u.current=!1,R.current=!1,S.current=null,b.current=null,n(!1);const e=h.current;e&&(e.pause(),e.removeAttribute("src"),e.load(),l(!1))},[a,W,j.length,k,n]),r.useEffect(()=>{const e=h.current;if(e){if(!d){N();return}if(k){const c=b.current!==k,s=f&&!i.current;if(S.current==="segment"&&!!b.current&&o.current===null){if(!s){u.current=!1,e.pause(),l(!1);return}e.paused&&(u.current=!0,g("keep-segment-source"));return}if(c){const y=o.current!==null?Z():0;e.pause(),e.removeAttribute("src"),e.load(),b.current=k,S.current="url",e.src=k,e.load(),m.current=y,e.readyState>0&&(e.currentTime=y,m.current=null)}if(u.current=s,p.current=!1,R.current=!1,n(!1),!s){u.current=!1,e.pause(),l(!1);return}c||g("sync-url");return}if(o.current!==null){if(o.current<j.length){if(i.current){l(!1),n(!1);return}C(o.current,"wait-resume");return}p.current=!0,u.current=f&&!i.current,l(!1),n(!i.current);return}if(!j.length){if(d.isAudioStreaming){o.current=E.current,p.current=!0,u.current=f&&!i.current,l(!1),n(!i.current);return}N();return}if(!b.current){C(Math.min(E.current,j.length-1),"effect-init");return}if(!f||i.current){u.current=!1,e.pause(),l(!1);return}e.paused&&(u.current=!0,g("sync-paused-retry"))}},[d,a,j,k,f,N,C,g,Z,n]),r.useEffect(()=>N,[N]);const ne=r.useCallback(()=>{l(!0),n(!1)},[n]),se=r.useCallback(()=>{p.current||R.current||l(!1)},[a]),ue=r.useCallback(()=>{const e=h.current;e&&m.current!==null&&(e.currentTime=m.current,m.current=null),!(!u.current||!f)&&g("canplay")},[a,f,g]),le=r.useCallback(()=>{const e=h.current;e&&m.current!==null&&(e.currentTime=m.current,m.current=null)},[a]),ce=r.useCallback(()=>{const e=S.current==="url"||w.current.length===0;if(R.current=!1,e){A("url-ended");return}B()},[A,B]),ae=r.useCallback(()=>{l(!1),n(!1)},[n]);return t.jsxRuntimeExports.jsxs("div",{className:$.cn("slide-player",_),...te,children:[t.jsxRuntimeExports.jsx("audio",{ref:h,preload:"auto",playsInline:!0,onLoadedMetadata:le,onCanPlay:ue,onPlay:ne,onPause:se,onEnded:ce,onError:ae}),re?t.jsxRuntimeExports.jsxs("div",{className:"slide-player__controls",children:[t.jsxRuntimeExports.jsxs("div",{className:"slide-player__group",children:[t.jsxRuntimeExports.jsx("button",{"aria-label":"More options",className:"hidden",type:"button",children:t.jsxRuntimeExports.jsx(ie.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Volume",className:"hidden",type:"button",children:t.jsxRuntimeExports.jsx(oe.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Rewind",className:"slide-player__action",disabled:I,onClick:G,type:"button",children:t.jsxRuntimeExports.jsx(fe.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":T?"Pause":"Play",className:"slide-player__toggle",onClick:()=>{const e=h.current;if(!(!e||!d)){if(o.current!==null){if(T){u.current=!1,i.current=!0,o.current=null,p.current=!1,l(!1),n(!1),e.pause();return}U?.(),i.current=!1,u.current=!0,n(!0);return}if(!e.src&&j.length>0){U?.(),i.current=!1,C(Math.min(E.current,j.length-1),"toggle");return}if(e.paused){U?.(),i.current=!1,u.current=!0,g("toggle-resume");return}u.current=!1,i.current=!0,e.pause()}},type:"button",children:T?t.jsxRuntimeExports.jsx(xe,{}):t.jsxRuntimeExports.jsx(he,{})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Forward",className:"slide-player__action",disabled:ee,onClick:J,type:"button",children:t.jsxRuntimeExports.jsx(de.default,{className:"slide-player__icon",strokeWidth:2.25})}),t.jsxRuntimeExports.jsx("button",{"aria-label":"Fullscreen",className:"hidden",onClick:Q,type:"button",children:t.jsxRuntimeExports.jsx(me.default,{className:"slide-player__icon",strokeWidth:2.25})})]}),t.jsxRuntimeExports.jsx("div",{className:"slide-player__separator"}),t.jsxRuntimeExports.jsx("div",{className:"slide-player__group",children:t.jsxRuntimeExports.jsx("button",{"aria-label":"Notes",className:$.cn("slide-player__action",D&&"slide-player__action--active"),disabled:!Y,onClick:X,type:"button",children:t.jsxRuntimeExports.jsx(pe.default,{className:"slide-player__icon",strokeWidth:2.25})})})]}):null]})};exports.default=Re;
2
2
  //# sourceMappingURL=Player.cjs.js.map