markdown-flow-ui 0.3.11 → 0.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/_virtual/index10.cjs +1 -1
- package/dist/_virtual/index10.es.js +3 -2
- package/dist/_virtual/index10.es.js.map +1 -1
- package/dist/_virtual/index11.cjs +1 -1
- package/dist/_virtual/index11.es.js +2 -3
- package/dist/_virtual/index11.es.js.map +1 -1
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index3.es.js +5 -4
- package/dist/_virtual/index3.es.js.map +1 -1
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/_virtual/index4.es.js +4 -5
- package/dist/_virtual/index4.es.js.map +1 -1
- package/dist/_virtual/index6.cjs +1 -1
- package/dist/_virtual/index6.es.js +2 -3
- package/dist/_virtual/index6.es.js.map +1 -1
- package/dist/_virtual/index7.cjs +1 -1
- package/dist/_virtual/index7.es.js +3 -5
- package/dist/_virtual/index7.es.js.map +1 -1
- package/dist/_virtual/index8.cjs +1 -1
- package/dist/_virtual/index8.es.js +5 -2
- package/dist/_virtual/index8.es.js.map +1 -1
- package/dist/_virtual/index9.cjs +1 -1
- package/dist/_virtual/index9.es.js +2 -2
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/ContentRender.cjs +2 -2
- package/dist/components/ContentRender/ContentRender.cjs.map +1 -1
- package/dist/components/ContentRender/ContentRender.d.ts +5 -0
- package/dist/components/ContentRender/ContentRender.es.js +405 -394
- package/dist/components/ContentRender/ContentRender.es.js.map +1 -1
- package/dist/components/ContentRender/ImageInputGroup.cjs +2 -0
- package/dist/components/ContentRender/ImageInputGroup.cjs.map +1 -0
- package/dist/components/ContentRender/ImageInputGroup.d.ts +31 -0
- package/dist/components/ContentRender/ImageInputGroup.es.js +101 -0
- package/dist/components/ContentRender/ImageInputGroup.es.js.map +1 -0
- package/dist/components/ContentRender/MarkdownFlowInput.cjs +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.cjs.map +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.d.ts +5 -0
- package/dist/components/ContentRender/MarkdownFlowInput.es.js +54 -50
- package/dist/components/ContentRender/MarkdownFlowInput.es.js.map +1 -1
- package/dist/components/ContentRender/contentRenderI18n.cjs.map +1 -1
- package/dist/components/ContentRender/contentRenderI18n.d.ts +4 -0
- package/dist/components/ContentRender/contentRenderI18n.es.js.map +1 -1
- package/dist/components/ContentRender/locales/contentRender.json.cjs +1 -1
- package/dist/components/ContentRender/locales/contentRender.json.d.ts +55 -11
- package/dist/components/ContentRender/locales/contentRender.json.es.js +11 -11
- package/dist/components/ContentRender/plugins/CustomVariable.cjs +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.cjs.map +1 -1
- package/dist/components/ContentRender/plugins/CustomVariable.d.ts +4 -1
- package/dist/components/ContentRender/plugins/CustomVariable.es.js +212 -173
- package/dist/components/ContentRender/plugins/CustomVariable.es.js.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.cjs.map +1 -1
- package/dist/components/MarkdownFlow/MarkdownFlow.d.ts +7 -0
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js +63 -53
- package/dist/components/MarkdownFlow/MarkdownFlow.es.js.map +1 -1
- package/dist/components/Slide/Slide.cjs +1 -1
- package/dist/components/Slide/Slide.cjs.map +1 -1
- package/dist/components/Slide/Slide.d.ts +5 -0
- package/dist/components/Slide/Slide.es.js +638 -621
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/utils/interactionResolution.cjs +1 -1
- package/dist/components/Slide/utils/interactionResolution.cjs.map +1 -1
- package/dist/components/Slide/utils/interactionResolution.es.js +15 -15
- package/dist/components/Slide/utils/interactionResolution.es.js.map +1 -1
- package/dist/components/types.d.ts +2 -0
- package/dist/components/ui/inputGroup/textarea.cjs +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/lib/interaction-defaults.cjs +1 -1
- package/dist/lib/interaction-defaults.cjs.map +1 -1
- package/dist/lib/interaction-defaults.d.ts +4 -0
- package/dist/lib/interaction-defaults.es.js +47 -41
- package/dist/lib/interaction-defaults.es.js.map +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/markdown-flow-ui.css +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.cjs +1 -1
- package/dist/node_modules/@braintree/sanitize-url/dist/index.es.js +1 -1
- package/dist/node_modules/classnames/index.cjs +1 -1
- package/dist/node_modules/classnames/index.es.js +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/node_modules/lucide-react/dist/esm/icons/image-plus.cjs +2 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/image-plus.cjs.map +1 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/image-plus.es.js +19 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/image-plus.es.js.map +1 -0
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-6MUBBAK2.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-6MUBBAK2.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-HFQBQIA3.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/chunk-HFQBQIA3.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-MALGAFMO.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/flowDiagram-MALGAFMO.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-23REXITY.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/ganttDiagram-23REXITY.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-5NDRBG5M.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/sequenceDiagram-5NDRBG5M.es.js +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-OMPLPG4O.cjs +1 -1
- package/dist/node_modules/mermaid/dist/chunks/mermaid.core/swimlanesDiagram-OMPLPG4O.es.js +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/node_modules/rc-util/es/ref.cjs +1 -1
- package/dist/node_modules/rc-util/es/ref.es.js +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.cjs +1 -1
- package/dist/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/dist/renderer.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomVariable.es.js","sources":["../../../../src/components/ContentRender/plugins/CustomVariable.tsx"],"sourcesContent":["import React from \"react\";\nimport { normalizeVariableName } from \"remark-flow\";\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 { acceptPlaceholder } from \"../utils/accept-placeholder\";\nimport {\n InputGroup,\n InputGroupTextarea,\n} from \"../../ui/inputGroup/input-group\";\nimport type { MarkdownFlowLocale } from \"../../../lib/locale\";\nimport { cn } from \"../../../lib/utils\";\nimport { getContentRenderLocaleTexts } from \"../contentRenderI18n\";\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 /** Explicit direction for nested input controls. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n /** Explicit language for nested input controls. */\n lang?: string;\n node: CustomVariableNode;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n locale?: MarkdownFlowLocale;\n readonly?: boolean;\n onSend?: (content: OnSendContentParams) => void;\n onPlaceholderAccepted?: () => 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 dir?: CustomVariableProps[\"dir\"];\n lang?: string;\n node: CustomVariableNode;\n readonly?: boolean;\n locale?: MarkdownFlowLocale;\n resolvedDefaultButtonText?: string;\n handleButtonClick: (value: string) => void;\n inputValue: string;\n handleInputChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n handleSendClick: () => void;\n onAcceptPlaceholder: (value: string) => void;\n}\n\nconst SingleSelectSection = ({\n dir,\n lang,\n node,\n readonly,\n locale,\n resolvedDefaultButtonText,\n handleButtonClick,\n inputValue,\n handleInputChange,\n handleSendClick,\n onAcceptPlaceholder,\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-start 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 dir={dir}\n lang={lang}\n disabled={readonly}\n locale={locale}\n placeholder={node.properties.placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onSend={handleSendClick}\n onAcceptPlaceholder={onAcceptPlaceholder}\n title={node.properties.placeholder}\n />\n </span>\n )}\n </span>\n);\n\n// Pure input\ninterface InputSectionProps {\n dir?: CustomVariableProps[\"dir\"];\n lang?: string;\n readonly?: boolean;\n locale?: MarkdownFlowLocale;\n placeholder?: string;\n value: string;\n onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onSend: () => void;\n onAcceptPlaceholder: (value: string) => void;\n}\n\nconst InputSection = ({\n dir,\n lang,\n readonly,\n locale,\n placeholder,\n value,\n onChange,\n onSend,\n onAcceptPlaceholder,\n}: InputSectionProps) => {\n if (!placeholder) {\n return null;\n }\n\n return (\n <MarkdownFlowInput\n dir={dir}\n lang={lang}\n disabled={readonly}\n locale={locale}\n placeholder={placeholder}\n value={value}\n onChange={onChange}\n onSend={onSend}\n onAcceptPlaceholder={onAcceptPlaceholder}\n title={placeholder}\n />\n );\n};\n\n// Define custom variable component\nconst CustomButtonInputVariable = ({\n dir,\n lang,\n node,\n readonly,\n locale,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n onSend,\n confirmButtonText,\n beforeSend = () => true,\n onPlaceholderAccepted,\n}: CustomVariableProps) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedConfirmButtonText =\n confirmButtonText || localeTexts.confirmButtonText;\n const [inputValue, setInputValue] = React.useState(defaultInputText || \"\");\n const [selectedValues, setSelectedValues] = React.useState<string[]>(\n defaultSelectedValues || []\n );\n const interactionDefinitionKey = JSON.stringify({\n buttonTexts: node.properties?.buttonTexts,\n buttonValues: node.properties?.buttonValues,\n isMultiSelect: node.properties?.isMultiSelect,\n placeholder: node.properties?.placeholder,\n variableName: node.properties?.variableName,\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 normalizeVariableName(node.properties?.variableName || \"\") ||\n defaultButtonText ||\n resolvedConfirmButtonText;\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 handleAcceptPlaceholder = (value: string) => {\n setInputValue(value);\n // Observer failures must never prevent editing or submitting an answer.\n try {\n void Promise.resolve(onPlaceholderAccepted?.()).catch(() => {});\n } catch {}\n };\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (\n acceptPlaceholder(\n e,\n node.properties?.placeholder,\n readonly,\n handleAcceptPlaceholder\n )\n ) {\n return;\n }\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 React.useEffect(() => {\n setInputValue(defaultInputText || \"\");\n }, [defaultInputText, interactionDefinitionKey]);\n\n React.useEffect(() => {\n setSelectedValues(defaultSelectedValues || []);\n }, [defaultSelectedValues, interactionDefinitionKey]);\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={resolvedConfirmButtonText}\n handleCheckboxChange={handleCheckboxChange}\n handleInputChange={handleInputChange}\n handleKeyDown={handleKeyDown}\n handleConfirmClick={handleConfirmClick}\n />\n )}\n\n {!isMultiSelect && isSingleSelect && (\n <SingleSelectSection\n dir={dir}\n lang={lang}\n node={singleSelectNode}\n readonly={readonly}\n locale={locale}\n resolvedDefaultButtonText={resolvedDefaultButtonText}\n handleButtonClick={handleButtonClick}\n inputValue={inputValue}\n handleInputChange={handleInputChange}\n handleSendClick={handleSendClick}\n onAcceptPlaceholder={handleAcceptPlaceholder}\n />\n )}\n\n {!isMultiSelect && !isSingleSelect && node.properties?.placeholder && (\n <InputSection\n dir={dir}\n lang={lang}\n readonly={readonly}\n locale={locale}\n placeholder={node.properties.placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onSend={handleSendClick}\n onAcceptPlaceholder={handleAcceptPlaceholder}\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","dir","lang","locale","resolvedDefaultButtonText","handleButtonClick","handleSendClick","onAcceptPlaceholder","Button","MarkdownFlowInput","InputSection","onChange","onSend","CustomButtonInputVariable","defaultButtonText","defaultInputText","defaultSelectedValues","beforeSend","onPlaceholderAccepted","localeTexts","getContentRenderLocaleTexts","resolvedConfirmButtonText","setInputValue","React","setSelectedValues","interactionDefinitionKey","isMultiSelect","baseButtonTexts","shouldUseFallbackButton","fallbackButtonLabel","normalizeVariableName","singleSelectNode","singleSelectButtonTexts","singleSelectButtonValues","isSingleSelect","param","prev","v","noSelection","e","handleAcceptPlaceholder","acceptPlaceholder","valueIndex","textIndex"],"mappings":";;;;;;;;;;AAgEA,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,MAC3B,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACAJ,IAAkB,kCAAkC;AAAA,QACpDE;AAAA,MAAA;AAAA,MAGF,UAAA,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,UAAUH;AAAA,UACV,SAASF;AAAA,UAER,UAAAJ;AAAA,QAAA;AAAA,MAAA;AAAA,IACH;AAAA,EAAA;AAIJ,SACE,gBAAAW,EAAC,QAAA,EAAK,WAAU,+CACd,UAAA;AAAA,IAAA,gBAAAF,EAAC,QAAA,EAAK,WAAU,sCACb,UAAAb,EAAK,YAAY,aAAa,IAAI,CAACgB,GAAMC,MAAU;AAClD,YAAMC,IAAQlB,EAAK,YAAY,eAAeiB,CAAK,GAC7CE,IAAcD,MAAU,SAAYA,IAAQF;AAClD,aACE,gBAAAH;AAAA,QAACO;AAAA,QAAA;AAAA,UAEC,OAAOJ;AAAA,UACP,UAAUf;AAAA,UACV,SAASC,EAAe,SAASiB,CAAW;AAAA,UAC5C,iBAAiB,CAACE,MAChBhB,EAAqBc,GAAaE,CAAO;AAAA,UAE3C,WAAU;AAAA,QAAA;AAAA,QAPLJ;AAAA,MAAA;AAAA,IAUX,CAAC,EAAA,CACH;AAA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AQwB;AAAA,QACR,qBAAqBkC;AAAA,MAAA;AAAA,IAAA;AAAA,EACvB,GAEJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"CustomVariable.es.js","sources":["../../../../src/components/ContentRender/plugins/CustomVariable.tsx"],"sourcesContent":["import React from \"react\";\nimport { normalizeVariableName } from \"remark-flow\";\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 { ImageInputGroup, type ImageInputOptions } from \"../ImageInputGroup\";\nimport { acceptPlaceholder } from \"../utils/accept-placeholder\";\nimport { InputGroupTextarea } from \"../../ui/inputGroup/input-group\";\nimport type { MarkdownFlowLocale } from \"../../../lib/locale\";\nimport { cn } from \"../../../lib/utils\";\nimport { getContentRenderLocaleTexts } from \"../contentRenderI18n\";\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 showImageInput?: boolean;\n imageInput?: ImageInputOptions;\n /** Explicit direction for nested input controls. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n /** Explicit language for nested input controls. */\n lang?: string;\n node: CustomVariableNode;\n defaultButtonText?: string;\n defaultInputText?: string;\n defaultSelectedValues?: string[];\n locale?: MarkdownFlowLocale;\n readonly?: boolean;\n onSend?: (content: OnSendContentParams) => void;\n onPlaceholderAccepted?: () => 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 extends Pick<\n CustomVariableProps,\n \"showImageInput\" | \"imageInput\"\n> {\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 locale?: MarkdownFlowLocale;\n}\n\nconst MultiSelectSection = ({\n node,\n readonly,\n selectedValues,\n inputValue,\n confirmButtonText,\n handleCheckboxChange,\n handleInputChange,\n handleKeyDown,\n handleConfirmClick,\n showImageInput,\n imageInput,\n locale,\n}: MultiSelectSectionProps) => {\n const placeholder = node.properties?.placeholder;\n const confirmDisabled =\n readonly ||\n imageInput?.uploading ||\n (selectedValues.length === 0 &&\n !inputValue?.trim() &&\n !(node.properties?.placeholder && imageInput?.images.length));\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 <ImageInputGroup\n disabled={readonly}\n locale={locale}\n showImageInput={showImageInput}\n imageInput={imageInput}\n className=\"flex-1\"\n >\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 </ImageInputGroup>\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 extends Pick<\n CustomVariableProps,\n \"showImageInput\" | \"imageInput\"\n> {\n dir?: CustomVariableProps[\"dir\"];\n lang?: string;\n node: CustomVariableNode;\n readonly?: boolean;\n locale?: MarkdownFlowLocale;\n resolvedDefaultButtonText?: string;\n handleButtonClick: (value: string) => void;\n inputValue: string;\n handleInputChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n handleSendClick: () => void;\n onAcceptPlaceholder: (value: string) => void;\n}\n\nconst SingleSelectSection = ({\n dir,\n lang,\n node,\n readonly,\n locale,\n resolvedDefaultButtonText,\n handleButtonClick,\n inputValue,\n handleInputChange,\n handleSendClick,\n onAcceptPlaceholder,\n showImageInput,\n imageInput,\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-start 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 showImageInput={showImageInput}\n imageInput={imageInput}\n dir={dir}\n lang={lang}\n disabled={readonly}\n locale={locale}\n placeholder={node.properties.placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onSend={handleSendClick}\n onAcceptPlaceholder={onAcceptPlaceholder}\n title={node.properties.placeholder}\n />\n </span>\n )}\n </span>\n);\n\n// Pure input\ninterface InputSectionProps extends Pick<\n CustomVariableProps,\n \"showImageInput\" | \"imageInput\"\n> {\n dir?: CustomVariableProps[\"dir\"];\n lang?: string;\n readonly?: boolean;\n locale?: MarkdownFlowLocale;\n placeholder?: string;\n value: string;\n onChange: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onSend: () => void;\n onAcceptPlaceholder: (value: string) => void;\n}\n\nconst InputSection = ({\n dir,\n lang,\n readonly,\n locale,\n placeholder,\n value,\n onChange,\n onSend,\n onAcceptPlaceholder,\n showImageInput,\n imageInput,\n}: InputSectionProps) => {\n if (!placeholder) {\n return null;\n }\n\n return (\n <MarkdownFlowInput\n showImageInput={showImageInput}\n imageInput={imageInput}\n dir={dir}\n lang={lang}\n disabled={readonly}\n locale={locale}\n placeholder={placeholder}\n value={value}\n onChange={onChange}\n onSend={onSend}\n onAcceptPlaceholder={onAcceptPlaceholder}\n title={placeholder}\n />\n );\n};\n\n// Define custom variable component\nconst CustomButtonInputVariable = ({\n dir,\n lang,\n node,\n readonly,\n locale,\n defaultButtonText,\n defaultInputText,\n defaultSelectedValues,\n onSend,\n confirmButtonText,\n beforeSend = () => true,\n onPlaceholderAccepted,\n showImageInput,\n imageInput,\n}: CustomVariableProps) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedConfirmButtonText =\n confirmButtonText || localeTexts.confirmButtonText;\n const [inputValue, setInputValue] = React.useState(defaultInputText || \"\");\n const [selectedValues, setSelectedValues] = React.useState<string[]>(\n defaultSelectedValues || []\n );\n const interactionDefinitionKey = JSON.stringify({\n buttonTexts: node.properties?.buttonTexts,\n buttonValues: node.properties?.buttonValues,\n isMultiSelect: node.properties?.isMultiSelect,\n placeholder: node.properties?.placeholder,\n variableName: node.properties?.variableName,\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 normalizeVariableName(node.properties?.variableName || \"\") ||\n defaultButtonText ||\n resolvedConfirmButtonText;\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 send = (param: OnSendContentParams) => {\n if (readonly || imageInput?.uploading) return;\n const images =\n node.properties?.placeholder && imageInput?.images.length\n ? [...imageInput.images]\n : undefined;\n const submission = images\n ? {\n ...param,\n ...(param.buttonText !== undefined && inputValue\n ? { inputText: inputValue }\n : {}),\n images,\n }\n : param;\n if (!beforeSend?.(submission)) return;\n onSend?.(submission);\n };\n\n const handleButtonClick = (value: string) => {\n const param = {\n variableName: node.properties?.variableName || \"\",\n buttonText: value,\n };\n send(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 =\n selectedValues.length === 0 &&\n !inputValue?.trim() &&\n !(node.properties?.placeholder && imageInput?.images.length);\n const param = {\n variableName: node.properties?.variableName || \"\",\n selectedValues,\n inputText: inputValue?.trim() || undefined,\n };\n if (readonly || noSelection) return;\n send(param);\n };\n\n const handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n setInputValue(e.target.value);\n };\n const handleAcceptPlaceholder = (value: string) => {\n setInputValue(value);\n // Observer failures must never prevent editing or submitting an answer.\n try {\n void Promise.resolve(onPlaceholderAccepted?.()).catch(() => {});\n } catch {}\n };\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (\n acceptPlaceholder(\n e,\n node.properties?.placeholder,\n readonly,\n handleAcceptPlaceholder\n )\n ) {\n return;\n }\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 =\n selectedValues.length === 0 &&\n !inputValue.trim() &&\n !imageInput?.images.length;\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 send(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 React.useEffect(() => {\n setInputValue(defaultInputText || \"\");\n }, [defaultInputText, interactionDefinitionKey]);\n\n React.useEffect(() => {\n setSelectedValues(defaultSelectedValues || []);\n }, [defaultSelectedValues, interactionDefinitionKey]);\n\n return (\n <span className=\"custom-variable-container inline-flex items-center flex-wrap\">\n {isMultiSelect && (\n <MultiSelectSection\n locale={locale}\n showImageInput={showImageInput}\n imageInput={imageInput}\n node={node}\n readonly={readonly}\n selectedValues={selectedValues}\n inputValue={inputValue}\n confirmButtonText={resolvedConfirmButtonText}\n handleCheckboxChange={handleCheckboxChange}\n handleInputChange={handleInputChange}\n handleKeyDown={handleKeyDown}\n handleConfirmClick={handleConfirmClick}\n />\n )}\n\n {!isMultiSelect && isSingleSelect && (\n <SingleSelectSection\n showImageInput={showImageInput}\n imageInput={imageInput}\n dir={dir}\n lang={lang}\n node={singleSelectNode}\n readonly={readonly}\n locale={locale}\n resolvedDefaultButtonText={resolvedDefaultButtonText}\n handleButtonClick={handleButtonClick}\n inputValue={inputValue}\n handleInputChange={handleInputChange}\n handleSendClick={handleSendClick}\n onAcceptPlaceholder={handleAcceptPlaceholder}\n />\n )}\n\n {!isMultiSelect && !isSingleSelect && node.properties?.placeholder && (\n <InputSection\n showImageInput={showImageInput}\n imageInput={imageInput}\n dir={dir}\n lang={lang}\n readonly={readonly}\n locale={locale}\n placeholder={node.properties.placeholder}\n value={inputValue}\n onChange={handleInputChange}\n onSend={handleSendClick}\n onAcceptPlaceholder={handleAcceptPlaceholder}\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","showImageInput","imageInput","locale","placeholder","confirmDisabled","renderConfirmButton","extraWrapperClassName","jsx","cn","jsxs","text","index","value","buttonValue","Checkbox","checked","ImageInputGroup","InputGroupTextarea","SingleSelectSection","dir","lang","resolvedDefaultButtonText","handleButtonClick","handleSendClick","onAcceptPlaceholder","Button","MarkdownFlowInput","InputSection","onChange","onSend","CustomButtonInputVariable","defaultButtonText","defaultInputText","defaultSelectedValues","beforeSend","onPlaceholderAccepted","localeTexts","getContentRenderLocaleTexts","resolvedConfirmButtonText","setInputValue","React","setSelectedValues","interactionDefinitionKey","isMultiSelect","baseButtonTexts","shouldUseFallbackButton","fallbackButtonLabel","normalizeVariableName","singleSelectNode","singleSelectButtonTexts","singleSelectButtonValues","isSingleSelect","send","param","images","submission","prev","v","noSelection","e","handleAcceptPlaceholder","acceptPlaceholder","valueIndex","textIndex"],"mappings":";;;;;;;;;;;AAoEA,MAAMA,KAAqB,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;AAAA,EACA,gBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,QAAAC;AACF,MAA+B;AAC7B,QAAMC,IAAcZ,EAAK,YAAY,aAC/Ba,IACJZ,KACAS,GAAY,aACXR,EAAe,WAAW,KACzB,CAACC,GAAY,KAAA,KACb,EAAEH,EAAK,YAAY,eAAeU,GAAY,OAAO,SAEnDI,IAAsB,CAACC,MAC3B,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QACT;AAAA,QACAJ,IAAkB,kCAAkC;AAAA,QACpDE;AAAA,MAAA;AAAA,MAGF,UAAA,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAU;AAAA,UACV,UAAUH;AAAA,UACV,SAASL;AAAA,UAER,UAAAJ;AAAA,QAAA;AAAA,MAAA;AAAA,IACH;AAAA,EAAA;AAIJ,SACE,gBAAAc,EAAC,QAAA,EAAK,WAAU,+CACd,UAAA;AAAA,IAAA,gBAAAF,EAAC,QAAA,EAAK,WAAU,sCACb,UAAAhB,EAAK,YAAY,aAAa,IAAI,CAACmB,GAAMC,MAAU;AAClD,YAAMC,IAAQrB,EAAK,YAAY,eAAeoB,CAAK,GAC7CE,IAAcD,MAAU,SAAYA,IAAQF;AAClD,aACE,gBAAAH;AAAA,QAACO;AAAA,QAAA;AAAA,UAEC,OAAOJ;AAAA,UACP,UAAUlB;AAAA,UACV,SAASC,EA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U,gEACb,UAAA;AAAA,IAAAkC,KACC,gBAAApC;AAAA,MAACjB;AAAA,MAAA;AAAA,QACC,QAAAY;AAAA,QACA,gBAAAF;AAAA,QACA,YAAAC;AAAA,QACA,MAAAV;AAAA,QACA,UAAAC;AAAA,QACA,gBAAAC;AAAA,QACA,YAAAC;AAAA,QACA,mBAAmB4C;AAAA,QACnB,sBAAA1C;AAAA,QACA,mBAAAC;AAAA,QACA,eAAAC;AAAA,QACA,oBAAAC;AAAA,MAAA;AAAA,IAAA;AAAA,IAIH,CAAC4C,KAAiBQ,KACjB,gBAAA5C;AAAA,MAACW;AAAA,MAAA;AAAA,QACC,gBAAAlB;AAAA,QACA,YAAAC;AAAA,QACA,KAAAkB;AAAA,QACA,MAAAC;AAAA,QACA,MAAM4B;AAAA,QACN,UAAAxD;AAAA,QACA,QAAAU;AAAA,QACA,2BAAAmB;AAAA,QACA,mBAAAC;AAAA,QACA,YAAA5B;AAAA,QACA,mBAAAG;AAAA,QACA,iBAAA0B;AAAA,QACA,qBAAqBqC;AAAA,MAAA;AAAA,IAAA;AAAA,IAIxB,CAACjB,KAAiB,CAACQ,KAAkB5D,EAAK,YAAY,eACrD,gBAAAgB;AAAA,MAACoB;AAAA,MAAA;AAAA,QACC,gBAAA3B;AAAA,QACA,YAAAC;AAAA,QACA,KAAAkB;AAAA,QACA,MAAAC;AAAA,QACA,UAAA5B;AAAA,QACA,QAAAU;AAAA,QACA,aAAaX,EAAK,WAAW;AAAA,QAC7B,OAAOG;AAAA,QACP,UAAUG;AAAA,QACV,QAAQ0B;AAAA,QACR,qBAAqBqC;AAAA,MAAA;AAAA,IAAA;AAAA,EACvB,GAEJ;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),k=require("react"),n=require("../../lib/locale.cjs"),M=require("../ContentRender/ContentRender.cjs");require("react-dom/client");require("../ContentRender/utils/inline-code-ranges.cjs");require("../ui/inputGroup/input-group.cjs");;/* empty css */const b=({initialContentList:m=[],locale:t,lang:a,dir:s,customRenderBar:c,onSend:g,onPlaceholderAccepted:w,confirmButtonText:p,copyButtonText:q,copiedButtonText:S,beforeSend:x,interactionDefaultValueOptions:r,showImageInput:d=!1,imageInput:l})=>{const o=d||!!l,B=k.useMemo(()=>o?{...r,allowImages:!0}:r,[o,r]);return i.jsx("div",{className:"markdown-flow",dir:s??n.getMarkdownFlowDirection(t),lang:a??n.getMarkdownFlowLanguage(t),children:m.map((e,C)=>{const u=e.isFinished??!1,F=u?void 0:g,f=x??(()=>!0);return i.jsx(M.default,{content:e.content,userInput:e.userInput,defaultInputText:e.defaultInputText,defaultButtonText:e.defaultButtonText,defaultSelectedValues:e.defaultSelectedValues,readonly:e.readonly,showImageInput:e.showImageInput??(!u&&d),imageInput:e.imageInput??(u?void 0:l),customRenderBar:e.customRenderBar||c,onSend:F,onPlaceholderAccepted:w,beforeSend:f,locale:t,lang:a,dir:s,interactionDefaultValueOptions:B,onClickCustomButtonAfterContent:e.onClickCustomButtonAfterContent,confirmButtonText:p,copyButtonText:q,copiedButtonText:S,dynamicInteractionFormat:e.dynamicInteractionFormat},C)})})};exports.default=b;
|
|
2
2
|
//# sourceMappingURL=MarkdownFlow.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownFlow.cjs","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\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 /**\n * Locale used for built-in UI text when a more specific text prop is not provided.\n * Arabic sets RTL direction; other supported locales set LTR direction.\n * When omitted, direction is inherited from the host and UI text uses the default locale.\n */\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language. */\n lang?: string;\n /** Overrides the locale-derived direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n /** Observes an accepted Tab completion without receiving authored text. */\n onPlaceholderAccepted?: () => 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 locale,\n lang,\n dir,\n customRenderBar,\n onSend: onSendProp,\n onPlaceholderAccepted,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n interactionDefaultValueOptions,\n}) => {\n return (\n <div\n className=\"markdown-flow\"\n dir={dir ?? getMarkdownFlowDirection(locale)}\n lang={lang ?? getMarkdownFlowLanguage(locale)}\n >\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const onSend = isFinished ? undefined : onSendProp;\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 customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n onPlaceholderAccepted={onPlaceholderAccepted}\n beforeSend={beforeSend}\n locale={locale}\n lang={lang}\n dir={dir}\n interactionDefaultValueOptions={
|
|
1
|
+
{"version":3,"file":"MarkdownFlow.cjs","sources":["../../../src/components/MarkdownFlow/MarkdownFlow.tsx"],"sourcesContent":["import React from \"react\";\nimport type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport ContentRender from \"../ContentRender\";\nimport type { ImageInputOptions } from \"../ContentRender/ImageInputGroup\";\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 showImageInput?: boolean;\n imageInput?: ImageInputOptions;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n /**\n * Locale used for built-in UI text when a more specific text prop is not provided.\n * Arabic sets RTL direction; other supported locales set LTR direction.\n * When omitted, direction is inherited from the host and UI text uses the default locale.\n */\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language. */\n lang?: string;\n /** Overrides the locale-derived direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n /** Observes an accepted Tab completion without receiving authored text. */\n onPlaceholderAccepted?: () => 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 /** Show the image picker on unfinished text interactions. Hidden by default. */\n showImageInput?: boolean;\n /** Controlled images for unfinished interactions; history uses each item. */\n imageInput?: ImageInputOptions;\n}\n\nconst MarkdownFlow: React.FC<MarkdownFlowProps> = ({\n initialContentList = [],\n locale,\n lang,\n dir,\n customRenderBar,\n onSend: onSendProp,\n onPlaceholderAccepted,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n interactionDefaultValueOptions,\n showImageInput = false,\n imageInput,\n}) => {\n const imageDefaultsEnabled = showImageInput || Boolean(imageInput);\n const defaultValueOptions = React.useMemo(\n () =>\n imageDefaultsEnabled\n ? { ...interactionDefaultValueOptions, allowImages: true }\n : interactionDefaultValueOptions,\n [imageDefaultsEnabled, interactionDefaultValueOptions]\n );\n return (\n <div\n className=\"markdown-flow\"\n dir={dir ?? getMarkdownFlowDirection(locale)}\n lang={lang ?? getMarkdownFlowLanguage(locale)}\n >\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const onSend = isFinished ? undefined : onSendProp;\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 showImageInput={\n contentInfo.showImageInput ?? (!isFinished && showImageInput)\n }\n imageInput={\n contentInfo.imageInput ?? (!isFinished ? imageInput : undefined)\n }\n customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n onPlaceholderAccepted={onPlaceholderAccepted}\n beforeSend={beforeSend}\n locale={locale}\n lang={lang}\n dir={dir}\n interactionDefaultValueOptions={defaultValueOptions}\n onClickCustomButtonAfterContent={\n contentInfo.onClickCustomButtonAfterContent\n }\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n dynamicInteractionFormat={contentInfo.dynamicInteractionFormat}\n />\n );\n })}\n </div>\n );\n};\n\nexport default MarkdownFlow;\n"],"names":["MarkdownFlow","initialContentList","locale","lang","dir","customRenderBar","onSendProp","onPlaceholderAccepted","confirmButtonText","copyButtonText","copiedButtonText","beforeSendProp","interactionDefaultValueOptions","showImageInput","imageInput","imageDefaultsEnabled","defaultValueOptions","React","jsx","getMarkdownFlowDirection","getMarkdownFlowLanguage","contentInfo","index","isFinished","onSend","beforeSend","ContentRender"],"mappings":"yZAuDA,MAAMA,EAA4C,CAAC,CACjD,mBAAAC,EAAqB,CAAA,EAAC,OACtBC,EACA,KAAAC,EACA,IAAAC,EACA,gBAAAC,EACA,OAAQC,EACR,sBAAAC,EACA,kBAAAC,EACA,eAAAC,EACA,iBAAAC,EACA,WAAYC,EACZ,+BAAAC,EACA,eAAAC,EAAiB,GACjB,WAAAC,CACF,IAAM,CACJ,MAAMC,EAAuBF,GAAkB,EAAQC,EACjDE,EAAsBC,EAAM,QAChC,IACEF,EACI,CAAE,GAAGH,EAAgC,YAAa,IAClDA,EACN,CAACG,EAAsBH,CAA8B,CAAA,EAEvD,OACEM,EAAAA,IAAC,MAAA,CACC,UAAU,gBACV,IAAKd,GAAOe,EAAAA,yBAAyBjB,CAAM,EAC3C,KAAMC,GAAQiB,EAAAA,wBAAwBlB,CAAM,EAE3C,SAAAD,EAAmB,IAAI,CAACoB,EAAaC,IAAU,CAC9C,MAAMC,EAAaF,EAAY,YAAc,GACvCG,EAASD,EAAa,OAAYjB,EAClCmB,EAAad,IAAmB,IAAM,IAC5C,OACEO,EAAAA,IAACQ,EAAAA,QAAA,CAEC,QAASL,EAAY,QACrB,UAAWA,EAAY,UACvB,iBAAkBA,EAAY,iBAC9B,kBAAmBA,EAAY,kBAC/B,sBAAuBA,EAAY,sBACnC,SAAUA,EAAY,SACtB,eACEA,EAAY,iBAAmB,CAACE,GAAcV,GAEhD,WACEQ,EAAY,aAAgBE,EAA0B,OAAbT,GAE3C,gBAAiBO,EAAY,iBAAmBhB,EAChD,OAAAmB,EACA,sBAAAjB,EACA,WAAAkB,EAAA,OACAvB,EACA,KAAAC,EACA,IAAAC,EACA,+BAAgCY,EAChC,gCACEK,EAAY,gCAEd,kBAAAb,EACA,eAAAC,EACA,iBAAAC,EACA,yBAA0BW,EAAY,wBAAA,EA3BjCC,CAAA,CA8BX,CAAC,CAAA,CAAA,CAGP"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { InteractionDefaultValueOptions } from '../../lib/interaction-defaults.js';
|
|
3
3
|
import { MarkdownFlowLocale } from '../../lib/locale.js';
|
|
4
|
+
import { ImageInputOptions } from '../ContentRender/ImageInputGroup.js';
|
|
4
5
|
import { CustomRenderBarProps, OnSendContentParams } from '../types.js';
|
|
5
6
|
export interface MarkdownFlowProps {
|
|
6
7
|
initialContentList?: {
|
|
@@ -11,6 +12,8 @@ export interface MarkdownFlowProps {
|
|
|
11
12
|
defaultButtonText?: string;
|
|
12
13
|
defaultSelectedValues?: string[];
|
|
13
14
|
readonly?: boolean;
|
|
15
|
+
showImageInput?: boolean;
|
|
16
|
+
imageInput?: ImageInputOptions;
|
|
14
17
|
customRenderBar?: CustomRenderBarProps;
|
|
15
18
|
onClickCustomButtonAfterContent?: () => void;
|
|
16
19
|
dynamicInteractionFormat?: string;
|
|
@@ -34,6 +37,10 @@ export interface MarkdownFlowProps {
|
|
|
34
37
|
copiedButtonText?: string;
|
|
35
38
|
beforeSend?: (content: OnSendContentParams) => boolean;
|
|
36
39
|
interactionDefaultValueOptions?: InteractionDefaultValueOptions;
|
|
40
|
+
/** Show the image picker on unfinished text interactions. Hidden by default. */
|
|
41
|
+
showImageInput?: boolean;
|
|
42
|
+
/** Controlled images for unfinished interactions; history uses each item. */
|
|
43
|
+
imageInput?: ImageInputOptions;
|
|
37
44
|
}
|
|
38
45
|
declare const MarkdownFlow: React.FC<MarkdownFlowProps>;
|
|
39
46
|
export default MarkdownFlow;
|
|
@@ -1,61 +1,71 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import S from "react";
|
|
3
|
+
import { getMarkdownFlowLanguage as h, getMarkdownFlowDirection as y } from "../../lib/locale.es.js";
|
|
4
|
+
import M from "../ContentRender/ContentRender.es.js";
|
|
5
5
|
import "react-dom/client";
|
|
6
6
|
import "../ContentRender/utils/inline-code-ranges.es.js";
|
|
7
7
|
import "../ui/inputGroup/input-group.es.js";
|
|
8
8
|
/* empty css */
|
|
9
|
-
const
|
|
10
|
-
initialContentList:
|
|
9
|
+
const D = ({
|
|
10
|
+
initialContentList: l = [],
|
|
11
11
|
locale: t,
|
|
12
|
-
lang:
|
|
13
|
-
dir:
|
|
14
|
-
customRenderBar:
|
|
15
|
-
onSend:
|
|
16
|
-
onPlaceholderAccepted:
|
|
17
|
-
confirmButtonText:
|
|
18
|
-
copyButtonText:
|
|
19
|
-
copiedButtonText:
|
|
20
|
-
beforeSend:
|
|
21
|
-
interactionDefaultValueOptions:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
12
|
+
lang: o,
|
|
13
|
+
dir: d,
|
|
14
|
+
customRenderBar: n,
|
|
15
|
+
onSend: p,
|
|
16
|
+
onPlaceholderAccepted: w,
|
|
17
|
+
confirmButtonText: f,
|
|
18
|
+
copyButtonText: c,
|
|
19
|
+
copiedButtonText: g,
|
|
20
|
+
beforeSend: B,
|
|
21
|
+
interactionDefaultValueOptions: r,
|
|
22
|
+
showImageInput: u = !1,
|
|
23
|
+
imageInput: m
|
|
24
|
+
}) => {
|
|
25
|
+
const s = u || !!m, C = S.useMemo(
|
|
26
|
+
() => s ? { ...r, allowImages: !0 } : r,
|
|
27
|
+
[s, r]
|
|
28
|
+
);
|
|
29
|
+
return /* @__PURE__ */ i(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
className: "markdown-flow",
|
|
33
|
+
dir: d ?? y(t),
|
|
34
|
+
lang: o ?? h(t),
|
|
35
|
+
children: l.map((e, F) => {
|
|
36
|
+
const a = e.isFinished ?? !1, k = a ? void 0 : p, x = B ?? (() => !0);
|
|
37
|
+
return /* @__PURE__ */ i(
|
|
38
|
+
M,
|
|
39
|
+
{
|
|
40
|
+
content: e.content,
|
|
41
|
+
userInput: e.userInput,
|
|
42
|
+
defaultInputText: e.defaultInputText,
|
|
43
|
+
defaultButtonText: e.defaultButtonText,
|
|
44
|
+
defaultSelectedValues: e.defaultSelectedValues,
|
|
45
|
+
readonly: e.readonly,
|
|
46
|
+
showImageInput: e.showImageInput ?? (!a && u),
|
|
47
|
+
imageInput: e.imageInput ?? (a ? void 0 : m),
|
|
48
|
+
customRenderBar: e.customRenderBar || n,
|
|
49
|
+
onSend: k,
|
|
50
|
+
onPlaceholderAccepted: w,
|
|
51
|
+
beforeSend: x,
|
|
52
|
+
locale: t,
|
|
53
|
+
lang: o,
|
|
54
|
+
dir: d,
|
|
55
|
+
interactionDefaultValueOptions: C,
|
|
56
|
+
onClickCustomButtonAfterContent: e.onClickCustomButtonAfterContent,
|
|
57
|
+
confirmButtonText: f,
|
|
58
|
+
copyButtonText: c,
|
|
59
|
+
copiedButtonText: g,
|
|
60
|
+
dynamicInteractionFormat: e.dynamicInteractionFormat
|
|
61
|
+
},
|
|
62
|
+
F
|
|
63
|
+
);
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
};
|
|
58
68
|
export {
|
|
59
|
-
|
|
69
|
+
D as default
|
|
60
70
|
};
|
|
61
71
|
//# 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 type { InteractionDefaultValueOptions } from \"../../lib/interaction-defaults\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\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 /**\n * Locale used for built-in UI text when a more specific text prop is not provided.\n * Arabic sets RTL direction; other supported locales set LTR direction.\n * When omitted, direction is inherited from the host and UI text uses the default locale.\n */\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language. */\n lang?: string;\n /** Overrides the locale-derived direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n /** Observes an accepted Tab completion without receiving authored text. */\n onPlaceholderAccepted?: () => 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 locale,\n lang,\n dir,\n customRenderBar,\n onSend: onSendProp,\n onPlaceholderAccepted,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n interactionDefaultValueOptions,\n}) => {\n return (\n <div\n className=\"markdown-flow\"\n dir={dir ?? getMarkdownFlowDirection(locale)}\n lang={lang ?? getMarkdownFlowLanguage(locale)}\n >\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const onSend = isFinished ? undefined : onSendProp;\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 customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n onPlaceholderAccepted={onPlaceholderAccepted}\n beforeSend={beforeSend}\n locale={locale}\n lang={lang}\n dir={dir}\n interactionDefaultValueOptions={
|
|
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 {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport ContentRender from \"../ContentRender\";\nimport type { ImageInputOptions } from \"../ContentRender/ImageInputGroup\";\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 showImageInput?: boolean;\n imageInput?: ImageInputOptions;\n customRenderBar?: CustomRenderBarProps;\n onClickCustomButtonAfterContent?: () => void;\n dynamicInteractionFormat?: string;\n }[];\n /**\n * Locale used for built-in UI text when a more specific text prop is not provided.\n * Arabic sets RTL direction; other supported locales set LTR direction.\n * When omitted, direction is inherited from the host and UI text uses the default locale.\n */\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language. */\n lang?: string;\n /** Overrides the locale-derived direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n customRenderBar?: CustomRenderBarProps;\n onSend?: (content: OnSendContentParams) => void;\n /** Observes an accepted Tab completion without receiving authored text. */\n onPlaceholderAccepted?: () => 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 /** Show the image picker on unfinished text interactions. Hidden by default. */\n showImageInput?: boolean;\n /** Controlled images for unfinished interactions; history uses each item. */\n imageInput?: ImageInputOptions;\n}\n\nconst MarkdownFlow: React.FC<MarkdownFlowProps> = ({\n initialContentList = [],\n locale,\n lang,\n dir,\n customRenderBar,\n onSend: onSendProp,\n onPlaceholderAccepted,\n confirmButtonText,\n copyButtonText,\n copiedButtonText,\n beforeSend: beforeSendProp,\n interactionDefaultValueOptions,\n showImageInput = false,\n imageInput,\n}) => {\n const imageDefaultsEnabled = showImageInput || Boolean(imageInput);\n const defaultValueOptions = React.useMemo(\n () =>\n imageDefaultsEnabled\n ? { ...interactionDefaultValueOptions, allowImages: true }\n : interactionDefaultValueOptions,\n [imageDefaultsEnabled, interactionDefaultValueOptions]\n );\n return (\n <div\n className=\"markdown-flow\"\n dir={dir ?? getMarkdownFlowDirection(locale)}\n lang={lang ?? getMarkdownFlowLanguage(locale)}\n >\n {initialContentList.map((contentInfo, index) => {\n const isFinished = contentInfo.isFinished ?? false;\n const onSend = isFinished ? undefined : onSendProp;\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 showImageInput={\n contentInfo.showImageInput ?? (!isFinished && showImageInput)\n }\n imageInput={\n contentInfo.imageInput ?? (!isFinished ? imageInput : undefined)\n }\n customRenderBar={contentInfo.customRenderBar || customRenderBar}\n onSend={onSend}\n onPlaceholderAccepted={onPlaceholderAccepted}\n beforeSend={beforeSend}\n locale={locale}\n lang={lang}\n dir={dir}\n interactionDefaultValueOptions={defaultValueOptions}\n onClickCustomButtonAfterContent={\n contentInfo.onClickCustomButtonAfterContent\n }\n confirmButtonText={confirmButtonText}\n copyButtonText={copyButtonText}\n copiedButtonText={copiedButtonText}\n dynamicInteractionFormat={contentInfo.dynamicInteractionFormat}\n />\n );\n })}\n </div>\n );\n};\n\nexport default MarkdownFlow;\n"],"names":["MarkdownFlow","initialContentList","locale","lang","dir","customRenderBar","onSendProp","onPlaceholderAccepted","confirmButtonText","copyButtonText","copiedButtonText","beforeSendProp","interactionDefaultValueOptions","showImageInput","imageInput","imageDefaultsEnabled","defaultValueOptions","React","jsx","getMarkdownFlowDirection","getMarkdownFlowLanguage","contentInfo","index","isFinished","onSend","beforeSend","ContentRender"],"mappings":";;;;;;;;AAuDA,MAAMA,IAA4C,CAAC;AAAA,EACjD,oBAAAC,IAAqB,CAAA;AAAA,EACrB,QAAAC;AAAA,EACA,MAAAC;AAAA,EACA,KAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,QAAQC;AAAA,EACR,uBAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,YAAYC;AAAA,EACZ,gCAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,YAAA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{value:"Module"}});const i=require("react/jsx-runtime"),t=require("react"),Xr=require("../../lib/sandboxInteraction.cjs"),Ie=require("../../lib/utils.cjs"),zr=require("../../lib/useResolvedDirection.cjs"),Ln=require("../../lib/locale.cjs"),$r=require("../ui/loading-overlay-card.cjs"),Qr=require("../ContentRender/ContentRender.cjs"),Fn=require("../ContentRender/IframeSandbox.cjs");require("../ContentRender/utils/inline-code-ranges.cjs");require("../ui/inputGroup/input-group.cjs");const pt=require("../../lib/mobileDevice.cjs"),Zr=require("./Player.cjs"),eo=require("./MarkdownSlideScaling.cjs"),to=require("./SubtitleOverlay.cjs"),no=require("./useSlide.cjs"),ro=require("./useWakePlayerFromIframe.cjs"),oo=require("./utils/playerKeyboardShortcutContext.cjs"),so=require("./utils/playerKeyboardShortcuts.cjs"),Ke=require("./utils/mobileScreenMode.cjs"),ht=require("./utils/interactionPlayback.cjs"),lo=require("./utils/markdownScaling.cjs"),Ht=require("./utils/playerNavigationContext.cjs"),ao=require("./utils/appendedMarkerAdvance.cjs"),Dn=require("./utils/stepAudioProgress.cjs"),qn=require("./utils/playbackSequence.cjs"),Yt=require("./utils/subtitleJumpNavigation.cjs"),Nn=require("./utils/playerCustomActions.cjs"),io=require("./utils/playbackTimeStore.cjs"),uo=require("./utils/interactionResolution.cjs"),co=require("./utils/playerToggleMode.cjs"),Bn=require("./utils/imageOnlyStepVisualReady.cjs"),fo=require("./utils/silentStepAutoAdvance.cjs"),Vn=require("./utils/playerVisibility.cjs"),Hn=require("./slideI18n.cjs");;/* empty css */const yo=require("../../node_modules/lucide-react/dist/esm/icons/chevron-left.cjs"),mo=2e3,po=300,ho=160,go=16,Kn=3e3,gt={x:0,y:0},Wt=.5,bo=typeof window>"u"?t.useEffect:t.useLayoutEffect,So=["button","input","textarea",'[contenteditable=""]','[contenteditable="true"]','[contenteditable="plaintext-only"]'].join(", "),Jt="waitingForAudio",vo=({x:u,y:c})=>({x:Number(u.toFixed(2)),y:Number(c.toFixed(2))}),jn=u=>Math.abs(u)>=Wt,Un=(u,c)=>Math.abs(u.x-c.x)<Wt&&Math.abs(u.y-c.y)<Wt,Io=(u,c)=>typeof u=="string"?u:u[c]??u[Jt]??Hn.DEFAULT_SLIDE_BUFFERING_TEXTS[c],Ao=(u,c)=>typeof u=="string"?u:{...c,...u},Co=(u,c)=>c?u!=="loadingAudio":!1,Yn=t.memo(({content:u,title:c,dragHandleAriaLabel:U,locale:Ae,dir:H,lang:Y,defaultButtonText:Ce,defaultInputText:se,defaultSelectedValues:je,confirmButtonText:bt,copyButtonText:G,copiedButtonText:St,onSend:Ee,onPlaceholderAccepted:Ue,onDragHandlePointerCancel:He,onDragHandlePointerDown:vt,onDragHandlePointerMove:Ye,onDragHandlePointerUp:Ge,readonly:We=!1})=>i.jsxs("div",{className:"slide-player__interaction-card",children:[i.jsx("button",{type:"button",className:"slide-player__interaction-drag-handle","aria-label":U,onPointerCancel:He,onPointerDown:vt,onPointerMove:Ye,onPointerUp:Ge}),i.jsx("div",{className:"slide-player__interaction-header",children:i.jsx("p",{className:"slide-player__interaction-title",children:c})}),i.jsx("div",{className:"slide-player__interaction-body",children:i.jsx(Qr.default,{content:u,locale:Ae,dir:H,lang:Y,defaultButtonText:Ce,defaultInputText:se,defaultSelectedValues:je,confirmButtonText:bt,copyButtonText:G,copiedButtonText:St,onSend:Ee,onPlaceholderAccepted:Ue,readonly:We,sandboxMode:"content"})})]}));Yn.displayName="InteractionOverlayCard";const Eo=(u,c)=>u.length===c.length&&u.every((U,Ae)=>{const H=c[Ae];return U.sequence_number===H?.sequence_number&&U.type===H?.type&&U.content===H?.content}),Gt=u=>u instanceof HTMLElement&&!!u.closest(So),xo=({elementList:u=[],locale:c,playerEnabled:U,playerControlsVisibility:Ae,playerClassName:H,fullscreenHeader:Y,playerCustomActions:Ce,playerCustomActionPauseOnActive:se=!0,bufferingText:je,interactionTitle:bt,interactionTexts:G,playerTexts:St,playerAutoHideDelay:Ee=3e3,markerAutoAdvanceDelay:Ue=mo,showSlideProgress:He=!1,isSlideProgressGenerating:vt=!1,onSlideProgressNavigate:Ye,interactionDefaultValueOptions:Ge,onSend:We,onPlaceholderAccepted:Gn,onPlayerVisibilityChange:It,onMobileViewModeChange:Xt,onStepChange:zt,onPlaybackCheckpoint:Wn,playbackRestoreRequest:N=null,enableKeyboardShortcuts:le=!0,enableIframeScaling:Jn=!0,enableMarkdownScaling:Xn=!0,disableLoadingOverlay:M=!1,className:zn,dir:$n,lang:Qn,onPointerDown:$t,onFocusCapture:Qt,...Zn})=>{const W=$n??Ln.getMarkdownFlowDirection(c),xe=Qn??Ln.getMarkdownFlowLanguage(c),_=t.useMemo(()=>Hn.getSlideLocaleTexts(c),[c]),er=t.useMemo(()=>Ao(je,_.bufferingText),[je,_.bufferingText]),{playerEnabled:tr,playerControlsVisibility:J}=Vn.resolveSlidePlayerVisibility({playerEnabled:U,playerControlsVisibility:Ae}),Je=t.useId(),ae=t.useRef(null),{resolvedDirection:nr}=zr.useResolvedDirection(ae,W),At=t.useRef(null),Xe=t.useRef(null),Zt=t.useRef(null),ie=t.useRef(null),ze=t.useRef(!1),we=t.useRef(null),$e=t.useRef(null),X=t.useRef(null),Re=t.useRef(null),ke=t.useRef(null),ue=t.useRef(null),Pe=t.useRef(null),en=t.useRef([]),ce=t.useRef(!1),B=t.useRef(null),Te=t.useRef(null),tn=t.useRef(0),Ct=t.useRef(null),nn=t.useRef({markerCount:0,currentIndex:-1,canGoNext:!1}),Et=t.useRef(!1),{currentElementList:E,stepElementLists:rn,slideElementList:p,currentIndex:a,audioList:d,audioSlideIndexes:z,currentAudioSequenceIndexes:Qe,currentStepHasSpeakableElement:S,currentInteractionElement:f,canGoPrev:rr,canGoNext:x,handlePrev:on,handleNext:O,handleGoTo:de}=no.default(u),Me=t.useMemo(()=>{if(!(a<0))return p[a]},[a,p]),fe=t.useMemo(()=>E.map((e,n)=>`${e.sequence_number??`${e.type}-${n}`}:${String(e.is_new??"")}`),[E]),sn=p.length,or=sn===1,v=tr&&(p.length>0||d.length>0||!!f),sr=t.useMemo(()=>({enabled:le,ownerId:Je}),[le,Je]),V=t.useCallback(()=>{!le||!v||so.activatePlayerKeyboardShortcutOwner(Je)},[le,Je,v]),w=t.useMemo(()=>Qe.map(e=>d[e]?.audioKey).filter(e=>!!e),[d,Qe]),[lr,_e]=t.useState(!0),[Ze,$]=t.useState(!1),[xt,wt]=t.useState(!0),[Oe,ln]=t.useState(!0),[I,L]=t.useState(null),[et,an]=t.useState(null),Le=t.useRef(null),un=t.useRef(null),[ar,cn]=t.useState(null),[ir,h]=t.useState(!1),[ur,Rt]=t.useState(Jt),[R,tt]=t.useState(!1),nt=t.useRef(new Set),[cr,rt]=t.useState(!1),[dn,dr]=t.useState(!0),[kt,Pt]=t.useState(!1),[g,Tt]=t.useState(),[ye,ot]=t.useState(!1),[fn,st]=t.useState(!1),[A,Mt]=t.useState(gt),[_t,Ot]=t.useState(!1),[fr,me]=t.useState(0),[yn,yr]=t.useState(!1),F=t.useMemo(()=>pt.isMobileDevice(),[]),[lt,Lt]=t.useState(Ke.DEFAULT_MOBILE_VIEW_MODE),[mn,Ft]=t.useState(!1),[mr,pn]=t.useState(()=>F?pt.isLandscapeViewport():!1),pe=t.useMemo(()=>io.createPlaybackTimeStore(),[]),{effectiveMobileViewMode:Q,isImmersiveMobileFullscreen:he,isNativeMobileFullscreen:hn,shouldRotateFullscreenViewport:pr}=t.useMemo(()=>Ke.resolveMobileViewModeState({hasManualMobileViewMode:mn,isMobileDevice:F,mobileViewMode:lt}),[mn,F,mr,lt]),gn=t.useRef(Q),{controlsVisible:D,layoutReserved:at}=Vn.resolveSlidePlayerLayoutState({isAutoVisible:lr,playerControlsVisibility:J,shouldMountPlayer:v}),hr=he&&D,gr=he&&at,br=he||hn,bn=yn&&!F,Sr=t.useCallback(e=>{Ft(!0),Lt(e)},[]),Sn=t.useCallback(()=>{Ft(!1),Lt(Ke.DEFAULT_MOBILE_VIEW_MODE)},[]),vr=t.useCallback(()=>{Sn(),Y?.onBack?.()},[Y,Sn]),k=t.useCallback(()=>{X.current!==null&&(window.clearTimeout(X.current),X.current=null)},[]),P=t.useCallback(()=>{Re.current!==null&&(window.clearTimeout(Re.current),Re.current=null)},[]),it=t.useCallback(()=>{k(),P(),ot(!1),me(0)},[k,P]),ut=t.useCallback(e=>{e&&it(),Pt(e)},[it]),vn=t.useCallback(()=>{it(),Pt(e=>!e)},[it]),Z=t.useCallback(()=>{Mt(e=>e.x===gt.x&&e.y===gt.y?e:gt),Ot(!1),Pe.current=null,ue.current=null},[]),{mountedStepStates:Ir,currentMountedStateIndex:Ar}=t.useMemo(()=>{const e=[],n=new Map;return rn.forEach((r,s)=>{const l=e.findIndex(o=>Eo(o.elementList,r));if(l>=0){e[l]?.sourceStepIndexes.push(s),n.set(s,l);return}e.push({elementList:r,sourceStepIndexes:[s]}),n.set(s,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:a>=0?n.get(a)??-1:-1}},[a,rn]),In=t.useMemo(()=>String(a),[a]),C=t.useMemo(()=>I?d.findIndex(e=>(e.audioKey??"")===I):-1,[d,I]),ct=t.useMemo(()=>C>=0?d[C]:void 0,[d,C]);t.useEffect(()=>{if(!N||N.id===un.current)return;const e=d.findIndex(r=>r.audioKey===N.audioKey);if(e<0)return;const n=z[e];n!=null&&(un.current=N.id,wt(!0),L(N.audioKey),Le.current=N,an(N),a!==n&&de(n))},[d,z,a,de,N]);const Cr=ct?.element?.subtitle_cues??[],dt=t.useMemo(()=>w[0]??"none",[w]),Dt=t.useMemo(()=>({currentElement:Nn.resolvePlayerCustomActionElement({currentAudioIndex:C,currentAudioSequenceIndexes:Qe,audioList:d,currentInteractionElement:g,currentStepElement:Me}),currentIndex:a,currentStepElement:Me,isActive:kt,setActive:ut,toggleActive:vn}),[g,d,C,Qe,a,Me,kt,ut,vn]),ft=t.useMemo(()=>Nn.getPlayerCustomActionCount(Ce,Dt),[Dt,Ce]),qt=ft>0,Nt=qt&&kt,Er=t.useMemo(()=>({"--slide-player-custom-action-count":String(ft),"--slide-player-mobile-control-count":String(ft+4),"--slide-interaction-drag-x":`${A.x}px`,"--slide-interaction-drag-y":`${A.y}px`}),[A.x,A.y,ft]),An=w.length>0,Cn=t.useMemo(()=>f?`${f.sequence_number??"none"}:${String(f.content??"")}`:"none",[f]),ge=t.useMemo(()=>[In,Cn].join("|"),[Cn,In]),xr=t.useMemo(()=>[ge,ct?.audioKey??"none",String(C)].join("|"),[C,ct?.audioKey,ge]),En=!!t.useMemo(()=>!dt||dt==="none"?"":d.find(n=>n.audioKey===dt)?.audioUrl?.trim()??"",[d,dt]),ee=se&&Nt,Fe=t.useMemo(()=>co.shouldUseAutoAdvanceToggle({canGoNext:x,currentAudioIndex:C,currentStepHasSpeakableElement:S,hasInteraction:!!f}),[x,C,f,S]),xn=t.useMemo(()=>fo.resolveSilentStepAutoAdvanceBehavior({currentElementList:E,currentStepHasSpeakableElement:S,currentInteractionElement:f,markerAutoAdvanceDelay:Ue}),[E,f,S,Ue]),wn=xn.delayMs,De=xn.usesImageOnlyDelay,Bt=t.useMemo(()=>`${a}:${fe.join("|")}`,[a,fe]),[wr,Rr]=t.useState(null),Rn=!De||wr===Bt,q=t.useCallback(()=>{ie.current!==null&&(window.clearTimeout(ie.current),ie.current=null)},[]),be=t.useCallback(()=>{we.current!==null&&(window.clearTimeout(we.current),we.current=null)},[]),K=t.useCallback(()=>{$e.current!==null&&(window.clearTimeout($e.current),$e.current=null)},[]),T=t.useCallback((e={})=>{be(),k(),P(),K(),L(null),pe.reset(),h(!1),Rt(Jt),tt(!1),nt.current=new Set,rt(!1),cn(null),e.preservePendingSubtitleJump||(Te.current=null),Tt(void 0),ot(!1),me(0)},[be,K,k,P,pe]),yt=t.useCallback(e=>{tn.current+=1,cn({...e,id:tn.current})},[]),Se=t.useCallback(()=>{const e=Dn.resolvePendingStepAudioKey(w,nt.current);return e?(L(e),!0):!1},[w]),qe=t.useCallback(()=>{k(),P(),ot(!1),me(0),!Se()&&x&&O()},[x,k,P,O,Se]),kn=t.useCallback(e=>{if(P(),!e)return;const n=()=>{Re.current=null,me(ho),ot(!0),B.current=null};Re.current=window.setTimeout(n,po)},[P]),Vt=t.useCallback(()=>ze.current||!!ae.current?.querySelector(".slide-player__controls:hover"),[]),y=t.useCallback((e=Ze)=>{!v||J==="hidden"||(_e(!0),q(),!(J==="visible"||!e||Ee<=0||Vt())&&(ie.current=window.setTimeout(()=>{if(Vt()){ie.current=null;return}_e(!1),ie.current=null},Ee)))},[q,Ze,Vt,Ee,J,v]),Ne=!!Yt.hasResolvedInteractionElement(f),te=!!f&&!Ne,kr=t.useCallback(e=>{wt(e)},[]),j=t.useCallback(e=>{e&&wt(e.shouldContinuePlayback)},[]);t.useEffect(()=>{ln(xt)},[a,xt,se]),t.useEffect(()=>{se&&ut(!1)},[a,se,ut]),t.useEffect(()=>{qt||Pt(!1)},[qt]),t.useEffect(()=>()=>{be(),K(),q(),k(),P()},[be,K,k,P,q]),t.useEffect(()=>{if(!De){K();return}let e=!1,n=null,r=null;const s=()=>{r?.(),r=null},l=()=>{e||(s(),K(),Rr(Bt))},o=()=>{if(e)return;s();const m=Xe.current?.querySelector('[data-active-step="true"]');if(!m)return;const b=Array.from(m.querySelectorAll("iframe"));if(b.length===0||Bn.areImageOnlyStepIframeVisualsReady(b)){l();return}const ne=[],Ve=()=>{e||(n!==null&&window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{n=null,o()}))},Ut=(re,ve,oe)=>{re.addEventListener(ve,oe,{once:!0}),ne.push(()=>re.removeEventListener(ve,oe))};b.forEach(re=>{const ve=re.contentDocument;if(!ve||ve.readyState!=="complete"){Ut(re,"load",Ve);return}Array.from(ve.images).filter(oe=>!oe.complete).forEach(oe=>{Ut(oe,"load",Ve),Ut(oe,"error",Ve)})}),r=()=>{ne.forEach(re=>re())}};return n=window.requestAnimationFrame(()=>{n=null,o()}),$e.current=window.setTimeout(()=>{l()},Bn.DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS),()=>{e=!0,s(),K(),n!==null&&window.cancelAnimationFrame(n)}},[K,E,a,Bt,De]),t.useEffect(()=>(It?.(D),()=>{It?.(!1)}),[It,D]),t.useEffect(()=>{D||(ze.current=!1)},[D]),t.useEffect(()=>{F||lt===Ke.DEFAULT_MOBILE_VIEW_MODE||(Ft(!1),Lt(Ke.DEFAULT_MOBILE_VIEW_MODE))},[F,lt]),t.useEffect(()=>{if(!F){pn(!1);return}const e=()=>{pn(pt.isLandscapeViewport()),Z()},n=()=>{Z()};e(),window.addEventListener("orientationchange",n),window.screen?.orientation?.addEventListener?.("change",n);const r=pt.subscribeMobileDeviceChange(e);return()=>{r(),window.removeEventListener("orientationchange",n),window.screen?.orientation?.removeEventListener?.("change",n)}},[F,Z]),t.useEffect(()=>{Xt?.(Q)},[Q,Xt]),t.useEffect(()=>{gn.current!==Q&&Z(),gn.current=Q},[Q,Z]),t.useEffect(()=>{zt?.(Me,a)},[a,Me,zt]),t.useEffect(()=>{const e=nn.current,n=ao.shouldAutoAdvanceIntoAppendedMarker({previousMarkerCount:e.markerCount,nextMarkerCount:p.length,previousIndex:e.currentIndex,previousCanGoNext:e.canGoNext,nextCanGoNext:x,currentAudioKey:I,hasCompletedCurrentStepAudio:R,hasResolvedCurrentInteraction:Ne,currentStepHasSpeakableElement:S,currentInteractionElement:f,isAutoAdvanceEnabled:Oe,shouldUseSilentStepAutoAdvanceToggle:Fe});nn.current={markerCount:p.length,currentIndex:a,canGoNext:x},n&&O()},[x,I,a,f,S,O,R,Ne,Oe,Fe,p.length]),t.useEffect(()=>{if(!v||J==="hidden"){q(),_e(!1);return}if(J==="visible"){q(),_e(!0);return}Ze||y(!0)},[q,Ze,J,v,y]),t.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.origin===window.location.origin&&Xr.isSandboxInteractionMessage(n.data)&&n.data.eventType==="click"&&v&&(V(),$(!0),y(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[V,v,y]),ro.default({sectionRef:ae,enabled:v,keyboardShortcutsEnabled:le,onKeyboardShortcut:V,onWake:()=>{V(),$(!0),y(!0)}}),t.useEffect(()=>{if(!v){T();return}if(Le.current){Ct.current=ge;return}const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:n}=qn.getPlaybackSequenceTransition({previousResetKey:Ct.current,nextResetKey:ge,currentAudioKey:I,hasCompletedCurrentStepAudio:R});Ct.current=ge;const r=B.current===a&&!!f,s=ht.shouldPresentInteractionOverlay({hasInteraction:!!f,shouldBlockPlaybackForInteraction:te,shouldOpenInteractionOverlayAfterAudio:r,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:Ne,currentStepHasSpeakableElement:S,isPlayerCustomActionActive:Nt}),l=Te.current,o=l?.slideIndex===a;if(e&&T({preservePendingSubtitleJump:o}),!(E.length===0&&!f)&&!ee){if(l?.slideIndex===a&&Yt.canReachSubtitleJumpTarget({currentIndex:a,resolvedCurrentInteractionElement:g,slideElementList:p,targetSlideIndex:l.slideIndex})){Te.current=null,Et.current=!0,L(l.audioKey),yt({audioIndex:l.audioIndex,timeMs:l.timeMs});return}if(f&&Tt(f),s){kn(f);return}if(P(),B.current=null,!te&&n&&!Se()){if(S){if(M){h(!1);return}h(!0);return}if(x&&!(Fe&&!Oe)&&!(De&&!Rn))return we.current=window.setTimeout(()=>{we.current=null,O()},wn),()=>{be()}}}},[g,x,be,E.length,a,f,I,ge,S,De,Rn,wn,O,R,M,Oe,Ne,Nt,te,P,T,yt,kn,v,p,Se,ee,Fe]),t.useEffect(()=>{if(M||ee||!S||te){h(!1);return}if(R){h(!1);return}if(An){h(!1);return}Rt("waitingForAudio"),h(!0)},[An,S,R,M,ee,te]),t.useEffect(()=>{R&&Dn.hasUnplayedStepAudio(w,nt.current)&&tt(!1)},[w,R]),t.useEffect(()=>{if(Le.current)return;const e=Et.current;Et.current=!1,qn.shouldStartDefaultAudioSequence({currentAudioKey:I,currentAudioSequenceLength:w.length,currentStepHasSpeakableElement:S,hasCompletedCurrentStepAudio:R,shouldBlockPlaybackForInteraction:te,shouldPausePlaybackForCustomAction:ee,shouldSkipDefaultAudioStart:e})&&Se()},[I,w,S,R,ee,te,Se]),t.useEffect(()=>{!I||C>=0||L(null)},[C,I]),t.useEffect(()=>{C>=0||pe.reset()},[C,pe]),t.useEffect(()=>{rt(!1)},[xr]);const{interactionDefaults:Pn,interactionDefaultSelectedValues:Pr,hasResolvedInteractionInput:Tn,isInteractionReadonly:Tr,shouldAutoContinueInteraction:Mn}=t.useMemo(()=>uo.resolveSlideInteractionState(g,{interactionDefaultValueOptions:Ge}),[g,Ge]),Mr=!!g?.readonly||Tr,Be=ht.shouldRenderInteractionOverlay({hasActiveInteraction:!!g,isInteractionOverlayOpen:ye}),_r=t.useCallback(e=>{const r=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean).join(", ");Tt(s=>!s||!r?s:{...s,user_input:r}),We?.(e,g),qe()},[g,qe,We]);t.useEffect(()=>{const e=()=>{yr(document.fullscreenElement===ae.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{g&&ye||st(!1)},[g,ye]),t.useEffect(()=>{Z()},[g,Z]),t.useEffect(()=>{if(!Be){me(0);return}const e=ke.current;if(!e)return;const n=()=>{const s=Math.ceil(e.getBoundingClientRect().height);me(s+go)};if(n(),typeof ResizeObserver>"u")return;const r=new ResizeObserver(()=>{n()});return r.observe(e),()=>{r.disconnect()}},[Be]),t.useEffect(()=>{if(k(),!!ye){if(Mn)return X.current=window.setTimeout(()=>{X.current=null,qe()},Kn),()=>{k()};if(!(fn||!Tn))return X.current=window.setTimeout(()=>{X.current=null,qe()},Kn),()=>{k()}}},[k,qe,fn,Tn,ye,Mn]);const Or=(e,n={})=>e?e.type==="slot"?i.jsx(i.Fragment,{children:e.content}):e.type==="html"?i.jsx(Fn.default,{className:"content-render-iframe",disableLoadingOverlay:M,hideFullScreen:!0,locale:c,dir:W,lang:xe,mode:"blackboard",replaceRootScreenHeightWithFull:n.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content,enableScaling:Jn}):i.jsx(Fn.default,{className:"content-render-iframe",disableLoadingOverlay:M,hideFullScreen:!0,locale:c,dir:W,lang:xe,mode:"blackboard",type:"markdown",content:e.content}):null,Lr=(e=[],n=!1)=>{if(e.length===0)return null;const r=e.filter(o=>o.is_renderable!==!1).length,s=n&&Xn?lo.resolveMarkdownScalingMode(e):"disabled",l=e.reduce((o,m,b)=>m.is_renderable!==!1?b:o,-1);return i.jsx(eo.default,{className:"slide-stage__content flex w-full flex-col gap-4",mode:s,children:e.map((o,m)=>{const b=o.type==="html"&&o.is_renderable===!1;return i.jsx("div",{ref:n&&m===l?Zt:null,"aria-hidden":b||void 0,className:Ie.cn("w-full shrink-0",r===1&&o.is_renderable!==!1&&"slide-element--single",b?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:Or(o,{replaceRootScreenHeightWithFull:r===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${m}`)})})},Fr=t.useCallback(()=>{const e=ae.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),_n=t.useCallback(()=>{const e=Xe.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),Kt=t.useCallback(e=>Yt.canReachSubtitleJumpTarget({currentIndex:a,resolvedCurrentInteractionElement:g,slideElementList:p,targetSlideIndex:z[e.audioIndex]}),[g,z,a,p]),Dr=t.useCallback((e,n)=>{const s=d[e.audioIndex]?.audioKey,l=z[e.audioIndex];return!s||l==null||!Kt(e)?!1:(j(n),B.current=null,h(!1),tt(!1),rt(!1),Ht.shouldWakePlayerControlsAfterNavigation(n)&&($(!0),y(!0)),l===a?(Te.current=null,T(),L(s),yt(e),!0):(ce.current=!0,T(),Te.current={audioIndex:e.audioIndex,audioKey:s,slideIndex:l,timeMs:e.timeMs},de(l),!0))},[d,z,Kt,a,de,yt,T,y,j]),qr=t.useCallback(e=>{j(e),ce.current=!0,B.current=null,h(!1),Ht.shouldWakePlayerControlsAfterNavigation(e)&&($(!0),y(!0)),T(),on()},[on,T,y,j]),Nr=t.useCallback(e=>{j(e),ce.current=!0,B.current=null,h(!1),Ht.shouldWakePlayerControlsAfterNavigation(e)&&($(!0),y(!0)),T(),O()},[O,T,y,j]),Br=t.useCallback((e,n)=>{e<0||e>=p.length||e===a||(j(n),ce.current=!0,B.current=null,h(!1),$(!0),y(!0),T(),de(e),Ye?.(p[e],e))},[a,de,Ye,T,y,p,j]),Vr=t.useCallback(({loading:e,reason:n})=>{if(M){h(!1);return}if(!S||R){h(!1);return}e&&n&&Rt(n),h(Co(n,e))},[S,R,M]);t.useEffect(()=>{M&&h(!1)},[M]);const Kr=t.useCallback(e=>{const n=d[e]?.audioKey;if(!n||!I||n!==I)return;nt.current.add(n);const r=w.findIndex(o=>o===n);if(r<0){L(null);return}const s=r+1,l=w[s];if(l){L(l);return}if(L(null),tt(!0),h(!1),x){const o=a+1,m=p[o];En&&m?.type==="interaction"&&(B.current=o),O();return}},[d,x,a,I,w,O,En,p]),jr=t.useCallback(()=>{ze.current=!0,q(),v&&_e(!0)},[q,v]),Ur=t.useCallback(()=>{ze.current=!1,y(!0)},[y]),jt=t.useCallback(e=>{e.stopPropagation(),D&&y(!0)},[D,y]),mt=t.useCallback((e,n)=>{const r=At.current;if(!r)return null;const s=e.getBoundingClientRect(),l=r.getBoundingClientRect();return{minX:n.x+l.left-s.left,maxX:n.x+l.right-s.right,minY:n.y+l.top-s.top,maxY:n.y+l.bottom-s.bottom}},[]);bo(()=>{const e=ke.current;if(!Be||!e){ue.current=null;return}const n=ue.current,r=e.getBoundingClientRect();if(!n||_t){ue.current={left:r.left,top:r.top};return}const s=n.left-r.left,l=n.top-r.top;if(!jn(s)&&!jn(l)){ue.current={left:r.left,top:r.top};return}const o={x:A.x+s,y:A.y+l},m=mt(e,A),b=vo(m?ht.clampInteractionOverlayDragOffset(o,m):o);ue.current={left:r.left+b.x-A.x,top:r.top+b.y-A.y},Un(b,A)||Mt(ne=>Un(ne,b)?ne:b)},[mt,A,_t,at,Be]);const Hr=t.useCallback(e=>{if(jt(e),e.button!==0||!e.currentTarget.isConnected||!ke.current)return;const n=mt(ke.current,A);n&&(e.preventDefault(),e.currentTarget.hasPointerCapture?.(e.pointerId)!==!0&&e.currentTarget.setPointerCapture(e.pointerId),Pe.current={pointerId:e.pointerId,startClientX:e.clientX,startClientY:e.clientY,startOffset:A,bounds:n},Ot(!0))},[mt,A,jt]),Yr=t.useCallback(e=>{const n=Pe.current;!n||n.pointerId!==e.pointerId||(e.preventDefault(),e.stopPropagation(),Mt(ht.clampInteractionOverlayDragOffset({x:n.startOffset.x+e.clientX-n.startClientX,y:n.startOffset.y+e.clientY-n.startClientY},n.bounds)))},[]),On=t.useCallback(e=>{const n=Pe.current;!n||n.pointerId!==e.pointerId||(e.stopPropagation(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),Pe.current=null,Ot(!1))},[]),Gr=t.useCallback(e=>{V(),$t?.(e)},[V,$t]),Wr=t.useCallback(e=>{V(),Qt?.(e)},[V,Qt]),Jr=t.useCallback(()=>{$(!0),y(!0)},[y]);return t.useEffect(()=>{const e=en.current,s=(e.length>0&&e.length<fe.length&&e.every((o,m)=>o===fe[m])?E.slice(e.length):[]).some(o=>o.is_new===!1);if(en.current=fe,!s)return;const l=window.requestAnimationFrame(()=>{const o=Xe.current,m=Zt.current;if(!o||!m)return;const b=o.getBoundingClientRect(),ne=m.getBoundingClientRect(),Ve=o.scrollTop+(ne.top-b.top);o.scrollTo({top:Math.max(Ve,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(l)}},[E,fe]),t.useEffect(()=>{if(!ce.current||(ce.current=!1,E.length===0))return;const e=window.requestAnimationFrame(()=>{_n()});return()=>{window.cancelAnimationFrame(e)}},[E,_n]),i.jsxs("section",{ref:ae,className:Ie.cn("relative h-full w-full",F&&"slide--mobile-device",bn&&"slide--browser-fullscreen",he&&"slide--mobile-landscape",hn&&"slide--mobile-landscape-native",zn),dir:W,lang:xe,onClick:Jr,onFocusCapture:Wr,onPointerDown:Gr,...Zn,children:[br?i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,i.jsxs("div",{ref:At,className:Ie.cn("slide__viewport relative h-full min-h-0 w-full",he&&"slide__viewport--mobile-landscape",he&&!pr&&"slide__viewport--mobile-landscape-native"),children:[hr?i.jsxs("div",{className:"slide-landscape-header",children:[i.jsx("button",{"aria-label":Y?.backAriaLabel??_.fullscreenBackAriaLabel,className:"slide-landscape-header__back",onClick:vr,type:"button",children:i.jsx(yo.default,{className:"slide-landscape-header__icon h-6 w-6",strokeWidth:2.25})}),Y?.content?i.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:Y.content}):null]}):null,i.jsx("div",{className:Ie.cn("h-full min-h-0 w-full",gr&&"slide__viewport-content--with-header",or?"slide-content--single":"grid gap-4"),children:E.length>0?i.jsx("div",{className:"slide-stage",children:i.jsx("div",{ref:Xe,className:"slide-stage__layer w-full",children:Ir.map((e,n)=>{const r=n===Ar;return i.jsx("div",{"data-active-step":r?"true":void 0,"aria-hidden":!r||void 0,className:"w-full h-full",style:{display:r?void 0:"none"},children:Lr(e.elementList,r)},e.sourceStepIndexes[0]??n)})})}):null}),ir?i.jsx($r.default,{message:Io(er,ur),className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,i.jsx(to.default,{extraBottomOffset:fr,hasPlayerGap:at,isEnabled:dn&&cr,playbackTimeStore:pe,subtitleCues:Cr}),Be?i.jsx("div",{ref:ke,"data-player-keyboard-shortcuts-ignore":"true",className:Ie.cn("slide-interaction-overlay",at?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone",_t&&"slide-interaction-overlay--dragging"),onClick:jt,onPointerDownCapture:e=>{Gt(e.target)&&st(!0)},onFocusCapture:e=>{Gt(e.target)&&st(!0)},onInputCapture:e=>{Gt(e.target)&&st(!0)},style:Er,children:i.jsx(Yn,{dir:W,lang:xe,content:String(g?.content??""),dragHandleAriaLabel:G?.dragHandleAriaLabel??_.interactionTexts.dragHandleAriaLabel,locale:c,defaultButtonText:Pn.buttonText??"",defaultInputText:Pn.inputText??"",defaultSelectedValues:Pr,confirmButtonText:G?.confirmButtonText??_.interactionTexts.confirmButtonText,copyButtonText:G?.copyButtonText??_.interactionTexts.copyButtonText,copiedButtonText:G?.copiedButtonText??_.interactionTexts.copiedButtonText,onSend:_r,onPlaceholderAccepted:Gn,onDragHandlePointerCancel:On,onDragHandlePointerDown:Hr,onDragHandlePointerMove:Yr,onDragHandlePointerUp:On,readonly:Mr,title:G?.title??bt??_.interactionTexts.title})}):null,v?i.jsx(oo.PlayerKeyboardShortcutContext.Provider,{value:sr,children:i.jsx(Zr.default,{dir:W==="auto"?nr:W,lang:xe,audioList:d,className:Ie.cn("absolute left-1/2 z-[2] -translate-x-1/2",He?"bottom-9":bn?"bottom-3":"-bottom-3",H,!D&&"pointer-events-none opacity-0"),currentAudioIndex:C,defaultPlaying:xt,enableKeyboardShortcuts:le,isPlaybackPaused:ee,isAutoAdvanceEnabled:Oe,locale:c,isInteractionOpen:ye,isSubtitleEnabled:dn,onAutoAdvanceToggle:ln,onLoadingChange:Vr,onPlaybackStarted:()=>{rt(!0)},onPlaybackCheckpoint:({audioKey:e,isComplete:n,timeMs:r})=>{const s=d.findIndex(o=>o.audioKey===e),l=s>=0?d[s]:void 0;!l?.audioKey||!l.element||Wn?.({audioKey:l.audioKey,element:l.element,isComplete:n,stepIndex:z[s]??a,timeMs:r})},onPlaybackPreferenceChange:kr,onPlaybackTimeChange:pe.setTime,onSubtitleToggle:()=>{dr(e=>!e)},nextDisabled:!x,onEnded:Kr,onFullscreen:Fr,isFullscreen:yn,mobileViewMode:Q,settingsPortalContainer:At.current,onMobileViewModeChange:Sr,onControlsPointerEnter:jr,onControlsPointerLeave:Ur,onNext:Nr,onPrev:qr,onSubtitleJump:Dr,canJumpToSubtitleTarget:Kt,prevDisabled:!rr,showControls:D,slideProgress:He?{ariaLabel:_.slideProgressAriaLabel,currentIndex:a,generatingLabel:_.slideProgressGeneratingLabel,isGenerating:vt,onNavigate:Br,totalSteps:sn}:null,subtitleSeekRequest:ar,playbackRestoreRequest:et&&et.audioKey===ct?.audioKey?{id:et.id,timeMs:et.timeMs}:null,onPlaybackRestoreComplete:e=>{Le.current?.id===e&&(Le.current=null,an(null))},texts:St,customActionContext:Dt,customActions:Ce,useAutoAdvanceToggle:Fe})}):null]})]})};exports.default=xo;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react/jsx-runtime"),t=require("react"),Zr=require("../../lib/sandboxInteraction.cjs"),Ae=require("../../lib/utils.cjs"),eo=require("../../lib/useResolvedDirection.cjs"),Nn=require("../../lib/locale.cjs"),to=require("../ui/loading-overlay-card.cjs"),no=require("../ContentRender/ContentRender.cjs"),Bn=require("../ContentRender/IframeSandbox.cjs");require("../ContentRender/utils/inline-code-ranges.cjs");require("../ui/inputGroup/input-group.cjs");const bt=require("../../lib/mobileDevice.cjs"),ro=require("./Player.cjs"),oo=require("./MarkdownSlideScaling.cjs"),so=require("./SubtitleOverlay.cjs"),lo=require("./useSlide.cjs"),ao=require("./useWakePlayerFromIframe.cjs"),io=require("./utils/playerKeyboardShortcutContext.cjs"),uo=require("./utils/playerKeyboardShortcuts.cjs"),Ue=require("./utils/mobileScreenMode.cjs"),St=require("./utils/interactionPlayback.cjs"),co=require("./utils/markdownScaling.cjs"),Wt=require("./utils/playerNavigationContext.cjs"),fo=require("./utils/appendedMarkerAdvance.cjs"),Vn=require("./utils/stepAudioProgress.cjs"),Kn=require("./utils/playbackSequence.cjs"),Jt=require("./utils/subtitleJumpNavigation.cjs"),jn=require("./utils/playerCustomActions.cjs"),yo=require("./utils/playbackTimeStore.cjs"),mo=require("./utils/interactionResolution.cjs"),po=require("./utils/playerToggleMode.cjs"),Un=require("./utils/imageOnlyStepVisualReady.cjs"),go=require("./utils/silentStepAutoAdvance.cjs"),Hn=require("./utils/playerVisibility.cjs"),Jn=require("./slideI18n.cjs");;/* empty css */const ho=require("../../node_modules/lucide-react/dist/esm/icons/chevron-left.cjs"),bo=2e3,So=300,vo=160,Io=16,Yn=3e3,vt={x:0,y:0},zt=.5,Ao=typeof window>"u"?t.useEffect:t.useLayoutEffect,Co=["button","input","textarea",'[contenteditable=""]','[contenteditable="true"]','[contenteditable="plaintext-only"]'].join(", "),$t="waitingForAudio",Eo=({x:u,y:c})=>({x:Number(u.toFixed(2)),y:Number(c.toFixed(2))}),Gn=u=>Math.abs(u)>=zt,Wn=(u,c)=>Math.abs(u.x-c.x)<zt&&Math.abs(u.y-c.y)<zt,xo=(u,c)=>typeof u=="string"?u:u[c]??u[$t]??Jn.DEFAULT_SLIDE_BUFFERING_TEXTS[c],wo=(u,c)=>typeof u=="string"?u:{...c,...u},Ro=(u,c)=>c?u!=="loadingAudio":!1,Xn=t.memo(({showImageInput:u,imageInput:c,content:U,title:Ce,dragHandleAriaLabel:H,locale:Y,dir:Ee,lang:se,defaultButtonText:He,defaultInputText:It,defaultSelectedValues:G,confirmButtonText:At,copyButtonText:xe,copiedButtonText:Ye,onSend:Ge,onPlaceholderAccepted:Ct,onDragHandlePointerCancel:We,onDragHandlePointerDown:we,onDragHandlePointerMove:Je,onDragHandlePointerUp:le,readonly:Xe=!1})=>i.jsxs("div",{className:"slide-player__interaction-card",children:[i.jsx("button",{type:"button",className:"slide-player__interaction-drag-handle","aria-label":H,onPointerCancel:We,onPointerDown:we,onPointerMove:Je,onPointerUp:le}),i.jsx("div",{className:"slide-player__interaction-header",children:i.jsx("p",{className:"slide-player__interaction-title",children:Ce})}),i.jsx("div",{className:"slide-player__interaction-body",children:i.jsx(no.default,{content:U,showImageInput:u,imageInput:c,locale:Y,dir:Ee,lang:se,defaultButtonText:He,defaultInputText:It,defaultSelectedValues:G,confirmButtonText:At,copyButtonText:xe,copiedButtonText:Ye,onSend:Ge,onPlaceholderAccepted:Ct,readonly:Xe,sandboxMode:"content"})})]}));Xn.displayName="InteractionOverlayCard";const ko=(u,c)=>u.length===c.length&&u.every((U,Ce)=>{const H=c[Ce];return U.sequence_number===H?.sequence_number&&U.type===H?.type&&U.content===H?.content}),Xt=u=>u instanceof HTMLElement&&!!u.closest(Co),Po=({elementList:u=[],locale:c,playerEnabled:U,playerControlsVisibility:Ce,playerClassName:H,fullscreenHeader:Y,playerCustomActions:Ee,playerCustomActionPauseOnActive:se=!0,bufferingText:He,interactionTitle:It,interactionTexts:G,playerTexts:At,playerAutoHideDelay:xe=3e3,markerAutoAdvanceDelay:Ye=bo,showSlideProgress:Ge=!1,isSlideProgressGenerating:Ct=!1,onSlideProgressNavigate:We,interactionDefaultValueOptions:we,showImageInput:Je=!1,imageInput:le,onSend:Xe,onPlaceholderAccepted:zn,onPlayerVisibilityChange:Et,onMobileViewModeChange:Qt,onStepChange:Zt,onPlaybackCheckpoint:$n,playbackRestoreRequest:N=null,enableKeyboardShortcuts:ae=!0,enableIframeScaling:Qn=!0,enableMarkdownScaling:Zn=!0,disableLoadingOverlay:M=!1,className:er,dir:tr,lang:nr,onPointerDown:en,onFocusCapture:tn,...rr})=>{const W=tr??Nn.getMarkdownFlowDirection(c),Re=nr??Nn.getMarkdownFlowLanguage(c),_=t.useMemo(()=>Jn.getSlideLocaleTexts(c),[c]),or=t.useMemo(()=>wo(He,_.bufferingText),[He,_.bufferingText]),{playerEnabled:sr,playerControlsVisibility:J}=Hn.resolveSlidePlayerVisibility({playerEnabled:U,playerControlsVisibility:Ce}),ze=t.useId(),ie=t.useRef(null),{resolvedDirection:lr}=eo.useResolvedDirection(ie,W),xt=t.useRef(null),$e=t.useRef(null),nn=t.useRef(null),ue=t.useRef(null),Qe=t.useRef(!1),ke=t.useRef(null),Ze=t.useRef(null),X=t.useRef(null),Pe=t.useRef(null),Te=t.useRef(null),ce=t.useRef(null),Me=t.useRef(null),rn=t.useRef([]),de=t.useRef(!1),B=t.useRef(null),_e=t.useRef(null),on=t.useRef(0),wt=t.useRef(null),sn=t.useRef({markerCount:0,currentIndex:-1,canGoNext:!1}),Rt=t.useRef(!1),{currentElementList:E,stepElementLists:ln,slideElementList:p,currentIndex:a,audioList:d,audioSlideIndexes:z,currentAudioSequenceIndexes:et,currentStepHasSpeakableElement:S,currentInteractionElement:f,canGoPrev:ar,canGoNext:x,handlePrev:an,handleNext:O,handleGoTo:fe}=lo.default(u),Oe=t.useMemo(()=>{if(!(a<0))return p[a]},[a,p]),ye=t.useMemo(()=>E.map((e,n)=>`${e.sequence_number??`${e.type}-${n}`}:${String(e.is_new??"")}`),[E]),un=p.length,ir=un===1,v=sr&&(p.length>0||d.length>0||!!f),ur=t.useMemo(()=>({enabled:ae,ownerId:ze}),[ae,ze]),V=t.useCallback(()=>{!ae||!v||uo.activatePlayerKeyboardShortcutOwner(ze)},[ae,ze,v]),w=t.useMemo(()=>et.map(e=>d[e]?.audioKey).filter(e=>!!e),[d,et]),[cr,Le]=t.useState(!0),[tt,$]=t.useState(!1),[kt,Pt]=t.useState(!0),[Fe,cn]=t.useState(!0),[I,L]=t.useState(null),[nt,dn]=t.useState(null),De=t.useRef(null),fn=t.useRef(null),[dr,yn]=t.useState(null),[fr,g]=t.useState(!1),[yr,Tt]=t.useState($t),[R,rt]=t.useState(!1),ot=t.useRef(new Set),[mr,st]=t.useState(!1),[mn,pr]=t.useState(!0),[Mt,_t]=t.useState(!1),[h,Ot]=t.useState(),[me,lt]=t.useState(!1),[pn,at]=t.useState(!1),[A,Lt]=t.useState(vt),[Ft,Dt]=t.useState(!1),[gr,pe]=t.useState(0),[gn,hr]=t.useState(!1),F=t.useMemo(()=>bt.isMobileDevice(),[]),[it,qt]=t.useState(Ue.DEFAULT_MOBILE_VIEW_MODE),[hn,Nt]=t.useState(!1),[br,bn]=t.useState(()=>F?bt.isLandscapeViewport():!1),ge=t.useMemo(()=>yo.createPlaybackTimeStore(),[]),{effectiveMobileViewMode:Q,isImmersiveMobileFullscreen:he,isNativeMobileFullscreen:Sn,shouldRotateFullscreenViewport:Sr}=t.useMemo(()=>Ue.resolveMobileViewModeState({hasManualMobileViewMode:hn,isMobileDevice:F,mobileViewMode:it}),[hn,F,br,it]),vn=t.useRef(Q),{controlsVisible:D,layoutReserved:ut}=Hn.resolveSlidePlayerLayoutState({isAutoVisible:cr,playerControlsVisibility:J,shouldMountPlayer:v}),vr=he&&D,Ir=he&&ut,Ar=he||Sn,In=gn&&!F,Cr=t.useCallback(e=>{Nt(!0),qt(e)},[]),An=t.useCallback(()=>{Nt(!1),qt(Ue.DEFAULT_MOBILE_VIEW_MODE)},[]),Er=t.useCallback(()=>{An(),Y?.onBack?.()},[Y,An]),k=t.useCallback(()=>{X.current!==null&&(window.clearTimeout(X.current),X.current=null)},[]),P=t.useCallback(()=>{Pe.current!==null&&(window.clearTimeout(Pe.current),Pe.current=null)},[]),ct=t.useCallback(()=>{k(),P(),lt(!1),pe(0)},[k,P]),dt=t.useCallback(e=>{e&&ct(),_t(e)},[ct]),Cn=t.useCallback(()=>{ct(),_t(e=>!e)},[ct]),Z=t.useCallback(()=>{Lt(e=>e.x===vt.x&&e.y===vt.y?e:vt),Dt(!1),Me.current=null,ce.current=null},[]),{mountedStepStates:xr,currentMountedStateIndex:wr}=t.useMemo(()=>{const e=[],n=new Map;return ln.forEach((r,s)=>{const l=e.findIndex(o=>ko(o.elementList,r));if(l>=0){e[l]?.sourceStepIndexes.push(s),n.set(s,l);return}e.push({elementList:r,sourceStepIndexes:[s]}),n.set(s,e.length-1)}),{mountedStepStates:e,currentMountedStateIndex:a>=0?n.get(a)??-1:-1}},[a,ln]),En=t.useMemo(()=>String(a),[a]),C=t.useMemo(()=>I?d.findIndex(e=>(e.audioKey??"")===I):-1,[d,I]),ft=t.useMemo(()=>C>=0?d[C]:void 0,[d,C]);t.useEffect(()=>{if(!N||N.id===fn.current)return;const e=d.findIndex(r=>r.audioKey===N.audioKey);if(e<0)return;const n=z[e];n!=null&&(fn.current=N.id,Pt(!0),L(N.audioKey),De.current=N,dn(N),a!==n&&fe(n))},[d,z,a,fe,N]);const Rr=ft?.element?.subtitle_cues??[],yt=t.useMemo(()=>w[0]??"none",[w]),Bt=t.useMemo(()=>({currentElement:jn.resolvePlayerCustomActionElement({currentAudioIndex:C,currentAudioSequenceIndexes:et,audioList:d,currentInteractionElement:h,currentStepElement:Oe}),currentIndex:a,currentStepElement:Oe,isActive:Mt,setActive:dt,toggleActive:Cn}),[h,d,C,et,a,Oe,Mt,dt,Cn]),mt=t.useMemo(()=>jn.getPlayerCustomActionCount(Ee,Bt),[Bt,Ee]),Vt=mt>0,Kt=Vt&&Mt,kr=t.useMemo(()=>({"--slide-player-custom-action-count":String(mt),"--slide-player-mobile-control-count":String(mt+4),"--slide-interaction-drag-x":`${A.x}px`,"--slide-interaction-drag-y":`${A.y}px`}),[A.x,A.y,mt]),xn=w.length>0,wn=t.useMemo(()=>f?`${f.sequence_number??"none"}:${String(f.content??"")}`:"none",[f]),be=t.useMemo(()=>[En,wn].join("|"),[wn,En]),Pr=t.useMemo(()=>[be,ft?.audioKey??"none",String(C)].join("|"),[C,ft?.audioKey,be]),Rn=!!t.useMemo(()=>!yt||yt==="none"?"":d.find(n=>n.audioKey===yt)?.audioUrl?.trim()??"",[d,yt]),ee=se&&Kt,qe=t.useMemo(()=>po.shouldUseAutoAdvanceToggle({canGoNext:x,currentAudioIndex:C,currentStepHasSpeakableElement:S,hasInteraction:!!f}),[x,C,f,S]),kn=t.useMemo(()=>go.resolveSilentStepAutoAdvanceBehavior({currentElementList:E,currentStepHasSpeakableElement:S,currentInteractionElement:f,markerAutoAdvanceDelay:Ye}),[E,f,S,Ye]),Pn=kn.delayMs,Ne=kn.usesImageOnlyDelay,jt=t.useMemo(()=>`${a}:${ye.join("|")}`,[a,ye]),[Tr,Mr]=t.useState(null),Tn=!Ne||Tr===jt,q=t.useCallback(()=>{ue.current!==null&&(window.clearTimeout(ue.current),ue.current=null)},[]),Se=t.useCallback(()=>{ke.current!==null&&(window.clearTimeout(ke.current),ke.current=null)},[]),K=t.useCallback(()=>{Ze.current!==null&&(window.clearTimeout(Ze.current),Ze.current=null)},[]),T=t.useCallback((e={})=>{Se(),k(),P(),K(),L(null),ge.reset(),g(!1),Tt($t),rt(!1),ot.current=new Set,st(!1),yn(null),e.preservePendingSubtitleJump||(_e.current=null),Ot(void 0),lt(!1),pe(0)},[Se,K,k,P,ge]),pt=t.useCallback(e=>{on.current+=1,yn({...e,id:on.current})},[]),ve=t.useCallback(()=>{const e=Vn.resolvePendingStepAudioKey(w,ot.current);return e?(L(e),!0):!1},[w]),Be=t.useCallback(()=>{k(),P(),lt(!1),pe(0),!ve()&&x&&O()},[x,k,P,O,ve]),Mn=t.useCallback(e=>{if(P(),!e)return;const n=()=>{Pe.current=null,pe(vo),lt(!0),B.current=null};Pe.current=window.setTimeout(n,So)},[P]),Ut=t.useCallback(()=>Qe.current||!!ie.current?.querySelector(".slide-player__controls:hover"),[]),y=t.useCallback((e=tt)=>{!v||J==="hidden"||(Le(!0),q(),!(J==="visible"||!e||xe<=0||Ut())&&(ue.current=window.setTimeout(()=>{if(Ut()){ue.current=null;return}Le(!1),ue.current=null},xe)))},[q,tt,Ut,xe,J,v]),Ve=!!Jt.hasResolvedInteractionElement(f),te=!!f&&!Ve,_r=t.useCallback(e=>{Pt(e)},[]),j=t.useCallback(e=>{e&&Pt(e.shouldContinuePlayback)},[]);t.useEffect(()=>{cn(kt)},[a,kt,se]),t.useEffect(()=>{se&&dt(!1)},[a,se,dt]),t.useEffect(()=>{Vt||_t(!1)},[Vt]),t.useEffect(()=>()=>{Se(),K(),q(),k(),P()},[Se,K,k,P,q]),t.useEffect(()=>{if(!Ne){K();return}let e=!1,n=null,r=null;const s=()=>{r?.(),r=null},l=()=>{e||(s(),K(),Mr(jt))},o=()=>{if(e)return;s();const m=$e.current?.querySelector('[data-active-step="true"]');if(!m)return;const b=Array.from(m.querySelectorAll("iframe"));if(b.length===0||Un.areImageOnlyStepIframeVisualsReady(b)){l();return}const ne=[],je=()=>{e||(n!==null&&window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{n=null,o()}))},Gt=(re,Ie,oe)=>{re.addEventListener(Ie,oe,{once:!0}),ne.push(()=>re.removeEventListener(Ie,oe))};b.forEach(re=>{const Ie=re.contentDocument;if(!Ie||Ie.readyState!=="complete"){Gt(re,"load",je);return}Array.from(Ie.images).filter(oe=>!oe.complete).forEach(oe=>{Gt(oe,"load",je),Gt(oe,"error",je)})}),r=()=>{ne.forEach(re=>re())}};return n=window.requestAnimationFrame(()=>{n=null,o()}),Ze.current=window.setTimeout(()=>{l()},Un.DEFAULT_IMAGE_ONLY_VISUAL_READY_TIMEOUT_MS),()=>{e=!0,s(),K(),n!==null&&window.cancelAnimationFrame(n)}},[K,E,a,jt,Ne]),t.useEffect(()=>(Et?.(D),()=>{Et?.(!1)}),[Et,D]),t.useEffect(()=>{D||(Qe.current=!1)},[D]),t.useEffect(()=>{F||it===Ue.DEFAULT_MOBILE_VIEW_MODE||(Nt(!1),qt(Ue.DEFAULT_MOBILE_VIEW_MODE))},[F,it]),t.useEffect(()=>{if(!F){bn(!1);return}const e=()=>{bn(bt.isLandscapeViewport()),Z()},n=()=>{Z()};e(),window.addEventListener("orientationchange",n),window.screen?.orientation?.addEventListener?.("change",n);const r=bt.subscribeMobileDeviceChange(e);return()=>{r(),window.removeEventListener("orientationchange",n),window.screen?.orientation?.removeEventListener?.("change",n)}},[F,Z]),t.useEffect(()=>{Qt?.(Q)},[Q,Qt]),t.useEffect(()=>{vn.current!==Q&&Z(),vn.current=Q},[Q,Z]),t.useEffect(()=>{Zt?.(Oe,a)},[a,Oe,Zt]),t.useEffect(()=>{const e=sn.current,n=fo.shouldAutoAdvanceIntoAppendedMarker({previousMarkerCount:e.markerCount,nextMarkerCount:p.length,previousIndex:e.currentIndex,previousCanGoNext:e.canGoNext,nextCanGoNext:x,currentAudioKey:I,hasCompletedCurrentStepAudio:R,hasResolvedCurrentInteraction:Ve,currentStepHasSpeakableElement:S,currentInteractionElement:f,isAutoAdvanceEnabled:Fe,shouldUseSilentStepAutoAdvanceToggle:qe});sn.current={markerCount:p.length,currentIndex:a,canGoNext:x},n&&O()},[x,I,a,f,S,O,R,Ve,Fe,qe,p.length]),t.useEffect(()=>{if(!v||J==="hidden"){q(),Le(!1);return}if(J==="visible"){q(),Le(!0);return}tt||y(!0)},[q,tt,J,v,y]),t.useEffect(()=>{if(typeof window>"u")return;const e=n=>{n.origin===window.location.origin&&Zr.isSandboxInteractionMessage(n.data)&&n.data.eventType==="click"&&v&&(V(),$(!0),y(!0))};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[V,v,y]),ao.default({sectionRef:ie,enabled:v,keyboardShortcutsEnabled:ae,onKeyboardShortcut:V,onWake:()=>{V(),$(!0),y(!0)}}),t.useEffect(()=>{if(!v){T();return}if(De.current){wt.current=be;return}const{hasPlaybackContextChanged:e,shouldInitializeAudioSequence:n}=Kn.getPlaybackSequenceTransition({previousResetKey:wt.current,nextResetKey:be,currentAudioKey:I,hasCompletedCurrentStepAudio:R});wt.current=be;const r=B.current===a&&!!f,s=St.shouldPresentInteractionOverlay({hasInteraction:!!f,shouldBlockPlaybackForInteraction:te,shouldOpenInteractionOverlayAfterAudio:r,hasPlaybackContextChanged:e,hasResolvedCurrentInteraction:Ve,currentStepHasSpeakableElement:S,isPlayerCustomActionActive:Kt}),l=_e.current,o=l?.slideIndex===a;if(e&&T({preservePendingSubtitleJump:o}),!(E.length===0&&!f)&&!ee){if(l?.slideIndex===a&&Jt.canReachSubtitleJumpTarget({currentIndex:a,resolvedCurrentInteractionElement:h,slideElementList:p,targetSlideIndex:l.slideIndex})){_e.current=null,Rt.current=!0,L(l.audioKey),pt({audioIndex:l.audioIndex,timeMs:l.timeMs});return}if(f&&Ot(f),s){Mn(f);return}if(P(),B.current=null,!te&&n&&!ve()){if(S){if(M){g(!1);return}g(!0);return}if(x&&!(qe&&!Fe)&&!(Ne&&!Tn))return ke.current=window.setTimeout(()=>{ke.current=null,O()},Pn),()=>{Se()}}}},[h,x,Se,E.length,a,f,I,be,S,Ne,Tn,Pn,O,R,M,Fe,Ve,Kt,te,P,T,pt,Mn,v,p,ve,ee,qe]),t.useEffect(()=>{if(M||ee||!S||te){g(!1);return}if(R){g(!1);return}if(xn){g(!1);return}Tt("waitingForAudio"),g(!0)},[xn,S,R,M,ee,te]),t.useEffect(()=>{R&&Vn.hasUnplayedStepAudio(w,ot.current)&&rt(!1)},[w,R]),t.useEffect(()=>{if(De.current)return;const e=Rt.current;Rt.current=!1,Kn.shouldStartDefaultAudioSequence({currentAudioKey:I,currentAudioSequenceLength:w.length,currentStepHasSpeakableElement:S,hasCompletedCurrentStepAudio:R,shouldBlockPlaybackForInteraction:te,shouldPausePlaybackForCustomAction:ee,shouldSkipDefaultAudioStart:e})&&ve()},[I,w,S,R,ee,te,ve]),t.useEffect(()=>{!I||C>=0||L(null)},[C,I]),t.useEffect(()=>{C>=0||ge.reset()},[C,ge]),t.useEffect(()=>{st(!1)},[Pr]);const _n=Je||!!le,On=t.useMemo(()=>_n?{...we,allowImages:!0}:we,[_n,we]),{interactionDefaults:gt,interactionDefaultSelectedValues:Or,hasResolvedInteractionInput:Ln,isInteractionReadonly:Lr,shouldAutoContinueInteraction:Fn}=t.useMemo(()=>mo.resolveSlideInteractionState(h,{interactionDefaultValueOptions:On}),[h,On]),Fr=!!h?.readonly||Lr,Ke=St.shouldRenderInteractionOverlay({hasActiveInteraction:!!h,isInteractionOverlayOpen:me}),Dr=t.useCallback(e=>{if(le?.uploading)return;const n=[...e.selectedValues??[],e.inputText?.trim()??"",e.buttonText?.trim()??""].filter(Boolean),r=e.images?.length?JSON.stringify(e):n.join(", ");Ot(s=>!s||!r?s:{...s,user_input:r}),Xe?.(e,h),Be()},[h,Be,Xe,le?.uploading]);t.useEffect(()=>{const e=()=>{hr(document.fullscreenElement===ie.current)};return e(),document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),t.useEffect(()=>{h&&me||at(!1)},[h,me]),t.useEffect(()=>{Z()},[h,Z]),t.useEffect(()=>{if(!Ke){pe(0);return}const e=Te.current;if(!e)return;const n=()=>{const s=Math.ceil(e.getBoundingClientRect().height);pe(s+Io)};if(n(),typeof ResizeObserver>"u")return;const r=new ResizeObserver(()=>{n()});return r.observe(e),()=>{r.disconnect()}},[Ke]),t.useEffect(()=>{if(k(),!!me){if(Fn)return X.current=window.setTimeout(()=>{X.current=null,Be()},Yn),()=>{k()};if(!(pn||!Ln))return X.current=window.setTimeout(()=>{X.current=null,Be()},Yn),()=>{k()}}},[k,Be,pn,Ln,me,Fn]);const qr=(e,n={})=>e?e.type==="slot"?i.jsx(i.Fragment,{children:e.content}):e.type==="html"?i.jsx(Bn.default,{className:"content-render-iframe",disableLoadingOverlay:M,hideFullScreen:!0,locale:c,dir:W,lang:Re,mode:"blackboard",replaceRootScreenHeightWithFull:n.replaceRootScreenHeightWithFull,type:"sandbox",content:e.content,enableScaling:Qn}):i.jsx(Bn.default,{className:"content-render-iframe",disableLoadingOverlay:M,hideFullScreen:!0,locale:c,dir:W,lang:Re,mode:"blackboard",type:"markdown",content:e.content}):null,Nr=(e=[],n=!1)=>{if(e.length===0)return null;const r=e.filter(o=>o.is_renderable!==!1).length,s=n&&Zn?co.resolveMarkdownScalingMode(e):"disabled",l=e.reduce((o,m,b)=>m.is_renderable!==!1?b:o,-1);return i.jsx(oo.default,{className:"slide-stage__content flex w-full flex-col gap-4",mode:s,children:e.map((o,m)=>{const b=o.type==="html"&&o.is_renderable===!1;return i.jsx("div",{ref:n&&m===l?nn:null,"aria-hidden":b||void 0,className:Ae.cn("w-full shrink-0",r===1&&o.is_renderable!==!1&&"slide-element--single",b?"pointer-events-none fixed left-[-200vw] top-0 -z-10 h-[100dvh] w-[100vw] overflow-hidden opacity-0":o.is_renderable===!1&&"hidden"),children:qr(o,{replaceRootScreenHeightWithFull:r===1&&o.type==="html"&&o.is_renderable!==!1})},o.sequence_number??`${o.type}-${m}`)})})},Br=t.useCallback(()=>{const e=ie.current;if(e){if(document.fullscreenElement===e){document.exitFullscreen().catch(()=>{});return}e.requestFullscreen?.().catch(()=>{})}},[]),Dn=t.useCallback(()=>{const e=$e.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[]),Ht=t.useCallback(e=>Jt.canReachSubtitleJumpTarget({currentIndex:a,resolvedCurrentInteractionElement:h,slideElementList:p,targetSlideIndex:z[e.audioIndex]}),[h,z,a,p]),Vr=t.useCallback((e,n)=>{const s=d[e.audioIndex]?.audioKey,l=z[e.audioIndex];return!s||l==null||!Ht(e)?!1:(j(n),B.current=null,g(!1),rt(!1),st(!1),Wt.shouldWakePlayerControlsAfterNavigation(n)&&($(!0),y(!0)),l===a?(_e.current=null,T(),L(s),pt(e),!0):(de.current=!0,T(),_e.current={audioIndex:e.audioIndex,audioKey:s,slideIndex:l,timeMs:e.timeMs},fe(l),!0))},[d,z,Ht,a,fe,pt,T,y,j]),Kr=t.useCallback(e=>{j(e),de.current=!0,B.current=null,g(!1),Wt.shouldWakePlayerControlsAfterNavigation(e)&&($(!0),y(!0)),T(),an()},[an,T,y,j]),jr=t.useCallback(e=>{j(e),de.current=!0,B.current=null,g(!1),Wt.shouldWakePlayerControlsAfterNavigation(e)&&($(!0),y(!0)),T(),O()},[O,T,y,j]),Ur=t.useCallback((e,n)=>{e<0||e>=p.length||e===a||(j(n),de.current=!0,B.current=null,g(!1),$(!0),y(!0),T(),fe(e),We?.(p[e],e))},[a,fe,We,T,y,p,j]),Hr=t.useCallback(({loading:e,reason:n})=>{if(M){g(!1);return}if(!S||R){g(!1);return}e&&n&&Tt(n),g(Ro(n,e))},[S,R,M]);t.useEffect(()=>{M&&g(!1)},[M]);const Yr=t.useCallback(e=>{const n=d[e]?.audioKey;if(!n||!I||n!==I)return;ot.current.add(n);const r=w.findIndex(o=>o===n);if(r<0){L(null);return}const s=r+1,l=w[s];if(l){L(l);return}if(L(null),rt(!0),g(!1),x){const o=a+1,m=p[o];Rn&&m?.type==="interaction"&&(B.current=o),O();return}},[d,x,a,I,w,O,Rn,p]),Gr=t.useCallback(()=>{Qe.current=!0,q(),v&&Le(!0)},[q,v]),Wr=t.useCallback(()=>{Qe.current=!1,y(!0)},[y]),Yt=t.useCallback(e=>{e.stopPropagation(),D&&y(!0)},[D,y]),ht=t.useCallback((e,n)=>{const r=xt.current;if(!r)return null;const s=e.getBoundingClientRect(),l=r.getBoundingClientRect();return{minX:n.x+l.left-s.left,maxX:n.x+l.right-s.right,minY:n.y+l.top-s.top,maxY:n.y+l.bottom-s.bottom}},[]);Ao(()=>{const e=Te.current;if(!Ke||!e){ce.current=null;return}const n=ce.current,r=e.getBoundingClientRect();if(!n||Ft){ce.current={left:r.left,top:r.top};return}const s=n.left-r.left,l=n.top-r.top;if(!Gn(s)&&!Gn(l)){ce.current={left:r.left,top:r.top};return}const o={x:A.x+s,y:A.y+l},m=ht(e,A),b=Eo(m?St.clampInteractionOverlayDragOffset(o,m):o);ce.current={left:r.left+b.x-A.x,top:r.top+b.y-A.y},Wn(b,A)||Lt(ne=>Wn(ne,b)?ne:b)},[ht,A,Ft,ut,Ke]);const Jr=t.useCallback(e=>{if(Yt(e),e.button!==0||!e.currentTarget.isConnected||!Te.current)return;const n=ht(Te.current,A);n&&(e.preventDefault(),e.currentTarget.hasPointerCapture?.(e.pointerId)!==!0&&e.currentTarget.setPointerCapture(e.pointerId),Me.current={pointerId:e.pointerId,startClientX:e.clientX,startClientY:e.clientY,startOffset:A,bounds:n},Dt(!0))},[ht,A,Yt]),Xr=t.useCallback(e=>{const n=Me.current;!n||n.pointerId!==e.pointerId||(e.preventDefault(),e.stopPropagation(),Lt(St.clampInteractionOverlayDragOffset({x:n.startOffset.x+e.clientX-n.startClientX,y:n.startOffset.y+e.clientY-n.startClientY},n.bounds)))},[]),qn=t.useCallback(e=>{const n=Me.current;!n||n.pointerId!==e.pointerId||(e.stopPropagation(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),Me.current=null,Dt(!1))},[]),zr=t.useCallback(e=>{V(),en?.(e)},[V,en]),$r=t.useCallback(e=>{V(),tn?.(e)},[V,tn]),Qr=t.useCallback(()=>{$(!0),y(!0)},[y]);return t.useEffect(()=>{const e=rn.current,s=(e.length>0&&e.length<ye.length&&e.every((o,m)=>o===ye[m])?E.slice(e.length):[]).some(o=>o.is_new===!1);if(rn.current=ye,!s)return;const l=window.requestAnimationFrame(()=>{const o=$e.current,m=nn.current;if(!o||!m)return;const b=o.getBoundingClientRect(),ne=m.getBoundingClientRect(),je=o.scrollTop+(ne.top-b.top);o.scrollTo({top:Math.max(je,0),behavior:"smooth"})});return()=>{window.cancelAnimationFrame(l)}},[E,ye]),t.useEffect(()=>{if(!de.current||(de.current=!1,E.length===0))return;const e=window.requestAnimationFrame(()=>{Dn()});return()=>{window.cancelAnimationFrame(e)}},[E,Dn]),i.jsxs("section",{ref:ie,className:Ae.cn("relative h-full w-full",F&&"slide--mobile-device",In&&"slide--browser-fullscreen",he&&"slide--mobile-landscape",Sn&&"slide--mobile-landscape-native",er),dir:W,lang:Re,onClick:Qr,onFocusCapture:$r,onPointerDown:zr,...rr,children:[Ar?i.jsx("div",{"aria-hidden":"true",className:"pointer-events-none fixed left-0 top-0 z-[9999] h-[100vh] max-h-[100vh] w-[100vw]"}):null,i.jsxs("div",{ref:xt,className:Ae.cn("slide__viewport relative h-full min-h-0 w-full",he&&"slide__viewport--mobile-landscape",he&&!Sr&&"slide__viewport--mobile-landscape-native"),children:[vr?i.jsxs("div",{className:"slide-landscape-header",children:[i.jsx("button",{"aria-label":Y?.backAriaLabel??_.fullscreenBackAriaLabel,className:"slide-landscape-header__back",onClick:Er,type:"button",children:i.jsx(ho.default,{className:"slide-landscape-header__icon h-6 w-6",strokeWidth:2.25})}),Y?.content?i.jsx("div",{className:"min-w-0 flex-1 overflow-hidden",children:Y.content}):null]}):null,i.jsx("div",{className:Ae.cn("h-full min-h-0 w-full",Ir&&"slide__viewport-content--with-header",ir?"slide-content--single":"grid gap-4"),children:E.length>0?i.jsx("div",{className:"slide-stage",children:i.jsx("div",{ref:$e,className:"slide-stage__layer w-full",children:xr.map((e,n)=>{const r=n===wr;return i.jsx("div",{"data-active-step":r?"true":void 0,"aria-hidden":!r||void 0,className:"w-full h-full",style:{display:r?void 0:"none"},children:Nr(e.elementList,r)},e.sourceStepIndexes[0]??n)})})}):null}),fr?i.jsx(to.default,{message:xo(or,yr),className:"absolute left-1/2 top-1/2 z-[3] -translate-x-1/2 -translate-y-1/2"}):null,i.jsx(so.default,{extraBottomOffset:gr,hasPlayerGap:ut,isEnabled:mn&&mr,playbackTimeStore:ge,subtitleCues:Rr}),Ke?i.jsx("div",{ref:Te,"data-player-keyboard-shortcuts-ignore":"true",className:Ae.cn("slide-interaction-overlay",ut?"slide-interaction-overlay--with-player":"slide-interaction-overlay--standalone",Ft&&"slide-interaction-overlay--dragging"),onClick:Yt,onPointerDownCapture:e=>{Xt(e.target)&&at(!0)},onFocusCapture:e=>{Xt(e.target)&&at(!0)},onInputCapture:e=>{Xt(e.target)&&at(!0)},style:kr,children:i.jsx(Xn,{showImageInput:Je,imageInput:le??(gt.images?.length?{images:gt.images}:void 0),dir:W,lang:Re,content:String(h?.content??""),dragHandleAriaLabel:G?.dragHandleAriaLabel??_.interactionTexts.dragHandleAriaLabel,locale:c,defaultButtonText:gt.buttonText??"",defaultInputText:gt.inputText??"",defaultSelectedValues:Or,confirmButtonText:G?.confirmButtonText??_.interactionTexts.confirmButtonText,copyButtonText:G?.copyButtonText??_.interactionTexts.copyButtonText,copiedButtonText:G?.copiedButtonText??_.interactionTexts.copiedButtonText,onSend:Dr,onPlaceholderAccepted:zn,onDragHandlePointerCancel:qn,onDragHandlePointerDown:Jr,onDragHandlePointerMove:Xr,onDragHandlePointerUp:qn,readonly:Fr,title:G?.title??It??_.interactionTexts.title})}):null,v?i.jsx(io.PlayerKeyboardShortcutContext.Provider,{value:ur,children:i.jsx(ro.default,{dir:W==="auto"?lr:W,lang:Re,audioList:d,className:Ae.cn("absolute left-1/2 z-[2] -translate-x-1/2",Ge?"bottom-9":In?"bottom-3":"-bottom-3",H,!D&&"pointer-events-none opacity-0"),currentAudioIndex:C,defaultPlaying:kt,enableKeyboardShortcuts:ae,isPlaybackPaused:ee,isAutoAdvanceEnabled:Fe,locale:c,isInteractionOpen:me,isSubtitleEnabled:mn,onAutoAdvanceToggle:cn,onLoadingChange:Hr,onPlaybackStarted:()=>{st(!0)},onPlaybackCheckpoint:({audioKey:e,isComplete:n,timeMs:r})=>{const s=d.findIndex(o=>o.audioKey===e),l=s>=0?d[s]:void 0;!l?.audioKey||!l.element||$n?.({audioKey:l.audioKey,element:l.element,isComplete:n,stepIndex:z[s]??a,timeMs:r})},onPlaybackPreferenceChange:_r,onPlaybackTimeChange:ge.setTime,onSubtitleToggle:()=>{pr(e=>!e)},nextDisabled:!x,onEnded:Yr,onFullscreen:Br,isFullscreen:gn,mobileViewMode:Q,settingsPortalContainer:xt.current,onMobileViewModeChange:Cr,onControlsPointerEnter:Gr,onControlsPointerLeave:Wr,onNext:jr,onPrev:Kr,onSubtitleJump:Vr,canJumpToSubtitleTarget:Ht,prevDisabled:!ar,showControls:D,slideProgress:Ge?{ariaLabel:_.slideProgressAriaLabel,currentIndex:a,generatingLabel:_.slideProgressGeneratingLabel,isGenerating:Ct,onNavigate:Ur,totalSteps:un}:null,subtitleSeekRequest:dr,playbackRestoreRequest:nt&&nt.audioKey===ft?.audioKey?{id:nt.id,timeMs:nt.timeMs}:null,onPlaybackRestoreComplete:e=>{De.current?.id===e&&(De.current=null,dn(null))},texts:At,customActionContext:Bt,customActions:Ee,useAutoAdvanceToggle:qe})}):null]})]})};exports.default=Po;
|
|
2
2
|
//# sourceMappingURL=Slide.cjs.map
|