streamlit-nightly 1.53.2.dev20260128__py3-none-any.whl → 1.53.2.dev20260202__py3-none-any.whl
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.
- streamlit/commands/execution_control.py +2 -2
- streamlit/config.py +3 -2
- streamlit/config_util.py +63 -8
- streamlit/delta_generator.py +2 -0
- streamlit/elements/deck_gl_json_chart.py +5 -1
- streamlit/elements/lib/built_in_chart_utils.py +24 -4
- streamlit/elements/lib/color_util.py +20 -1
- streamlit/elements/lib/column_types.py +6 -2
- streamlit/elements/lib/utils.py +6 -6
- streamlit/elements/markdown.py +0 -1
- streamlit/elements/metric.py +2 -1
- streamlit/elements/vega_charts.py +24 -4
- streamlit/elements/widgets/button_group.py +6 -276
- streamlit/elements/widgets/feedback.py +322 -0
- streamlit/elements/widgets/number_input.py +2 -1
- streamlit/elements/widgets/slider.py +2 -1
- streamlit/material_icon_names.py +1 -1
- streamlit/proto/Alert_pb2.py +2 -3
- streamlit/proto/AppPage_pb2.py +2 -3
- streamlit/proto/ArrowData_pb2.py +2 -3
- streamlit/proto/ArrowNamedDataSet_pb2.py +2 -3
- streamlit/proto/ArrowVegaLiteChart_pb2.py +2 -3
- streamlit/proto/Arrow_pb2.py +11 -18
- streamlit/proto/Arrow_pb2.pyi +1 -42
- streamlit/proto/AudioInput_pb2.py +5 -6
- streamlit/proto/AudioInput_pb2.pyi +3 -3
- streamlit/proto/Audio_pb2.py +3 -4
- streamlit/proto/AuthRedirect_pb2.py +2 -3
- streamlit/proto/AutoRerun_pb2.py +2 -3
- streamlit/proto/BackMsg_pb2.py +2 -3
- streamlit/proto/BackMsg_pb2.pyi +2 -10
- streamlit/proto/Balloons_pb2.py +2 -3
- streamlit/proto/Balloons_pb2.pyi +0 -2
- streamlit/proto/BidiComponent_pb2.py +2 -3
- streamlit/proto/Block_pb2.py +36 -43
- streamlit/proto/Block_pb2.pyi +3 -48
- streamlit/proto/ButtonGroup_pb2.py +11 -14
- streamlit/proto/ButtonGroup_pb2.pyi +6 -41
- streamlit/proto/ButtonLikeIconPosition_pb2.py +2 -3
- streamlit/proto/Button_pb2.py +3 -6
- streamlit/proto/Button_pb2.pyi +1 -18
- streamlit/proto/CameraInput_pb2.py +5 -6
- streamlit/proto/CameraInput_pb2.pyi +3 -3
- streamlit/proto/ChatInput_pb2.py +5 -8
- streamlit/proto/ChatInput_pb2.pyi +1 -17
- streamlit/proto/Checkbox_pb2.py +7 -8
- streamlit/proto/Checkbox_pb2.pyi +3 -3
- streamlit/proto/ClientState_pb2.py +2 -3
- streamlit/proto/Code_pb2.py +3 -6
- streamlit/proto/Code_pb2.pyi +1 -18
- streamlit/proto/ColorPicker_pb2.py +5 -6
- streamlit/proto/ColorPicker_pb2.pyi +3 -3
- streamlit/proto/Common_pb2.py +7 -8
- streamlit/proto/Common_pb2.pyi +2 -10
- streamlit/proto/Components_pb2.py +2 -3
- streamlit/proto/DateInput_pb2.py +5 -6
- streamlit/proto/DateInput_pb2.pyi +3 -3
- streamlit/proto/DateTimeInput_pb2.py +5 -6
- streamlit/proto/DateTimeInput_pb2.pyi +3 -3
- streamlit/proto/DeckGlJsonChart_pb2.py +5 -12
- streamlit/proto/DeckGlJsonChart_pb2.pyi +1 -54
- streamlit/proto/Delta_pb2.py +4 -6
- streamlit/proto/Delta_pb2.pyi +5 -14
- streamlit/proto/DocString_pb2.py +2 -3
- streamlit/proto/DownloadButton_pb2.py +2 -3
- streamlit/proto/Element_pb2.py +5 -8
- streamlit/proto/Element_pb2.pyi +9 -29
- streamlit/proto/Empty_pb2.py +2 -3
- streamlit/proto/Exception_pb2.py +2 -3
- streamlit/proto/Favicon_pb2.py +2 -3
- streamlit/proto/Feedback_pb2.py +28 -0
- streamlit/proto/Feedback_pb2.pyi +93 -0
- streamlit/proto/FileUploader_pb2.py +5 -6
- streamlit/proto/FileUploader_pb2.pyi +3 -3
- streamlit/proto/ForwardMsg_pb2.py +12 -18
- streamlit/proto/ForwardMsg_pb2.pyi +4 -48
- streamlit/proto/GapSize_pb2.py +2 -3
- streamlit/proto/GitInfo_pb2.py +2 -3
- streamlit/proto/GraphVizChart_pb2.py +3 -6
- streamlit/proto/GraphVizChart_pb2.pyi +1 -18
- streamlit/proto/Heading_pb2.py +2 -3
- streamlit/proto/HeightConfig_pb2.py +2 -3
- streamlit/proto/Html_pb2.py +2 -3
- streamlit/proto/IFrame_pb2.py +4 -11
- streamlit/proto/IFrame_pb2.pyi +1 -42
- streamlit/proto/Image_pb2.py +5 -8
- streamlit/proto/Image_pb2.pyi +2 -25
- streamlit/proto/Json_pb2.py +2 -3
- streamlit/proto/LabelVisibility_pb2.py +28 -0
- streamlit/proto/{LabelVisibilityMessage_pb2.pyi → LabelVisibility_pb2.pyi} +14 -14
- streamlit/proto/LinkButton_pb2.py +2 -3
- streamlit/proto/Logo_pb2.py +2 -3
- streamlit/proto/Markdown_pb2.py +5 -6
- streamlit/proto/Markdown_pb2.pyi +1 -5
- streamlit/proto/Metric_pb2.py +11 -12
- streamlit/proto/Metric_pb2.pyi +3 -3
- streamlit/proto/MetricsEvent_pb2.py +2 -3
- streamlit/proto/MultiSelect_pb2.py +5 -8
- streamlit/proto/MultiSelect_pb2.pyi +4 -14
- streamlit/proto/Navigation_pb2.py +2 -3
- streamlit/proto/NewSession_pb2.py +39 -28
- streamlit/proto/NewSession_pb2.pyi +44 -20
- streamlit/proto/NumberInput_pb2.py +7 -8
- streamlit/proto/NumberInput_pb2.pyi +3 -3
- streamlit/proto/PageConfig_pb2.py +2 -3
- streamlit/proto/PageInfo_pb2.py +2 -3
- streamlit/proto/PageLink_pb2.py +2 -3
- streamlit/proto/PageNotFound_pb2.py +2 -3
- streamlit/proto/PageProfile_pb2.py +2 -3
- streamlit/proto/ParentMessage_pb2.py +2 -3
- streamlit/proto/PlotlyChart_pb2.py +5 -10
- streamlit/proto/PlotlyChart_pb2.pyi +1 -58
- streamlit/proto/Progress_pb2.py +2 -3
- streamlit/proto/Radio_pb2.py +5 -8
- streamlit/proto/Radio_pb2.pyi +5 -22
- streamlit/proto/RootContainer_pb2.py +2 -3
- streamlit/proto/Selectbox_pb2.py +5 -8
- streamlit/proto/Selectbox_pb2.pyi +5 -25
- streamlit/proto/SessionEvent_pb2.py +2 -3
- streamlit/proto/SessionStatus_pb2.py +2 -3
- streamlit/proto/Skeleton_pb2.py +2 -3
- streamlit/proto/Slider_pb2.py +9 -10
- streamlit/proto/Slider_pb2.pyi +3 -3
- streamlit/proto/Snow_pb2.py +2 -3
- streamlit/proto/Snow_pb2.pyi +0 -2
- streamlit/proto/Space_pb2.py +2 -3
- streamlit/proto/Spinner_pb2.py +2 -3
- streamlit/proto/TextAlignmentConfig_pb2.py +2 -3
- streamlit/proto/TextArea_pb2.py +5 -8
- streamlit/proto/TextArea_pb2.pyi +4 -21
- streamlit/proto/TextInput_pb2.py +7 -8
- streamlit/proto/TextInput_pb2.pyi +3 -3
- streamlit/proto/Text_pb2.py +2 -3
- streamlit/proto/TimeInput_pb2.py +5 -6
- streamlit/proto/TimeInput_pb2.pyi +3 -3
- streamlit/proto/Toast_pb2.py +2 -3
- streamlit/proto/Transient_pb2.py +2 -3
- streamlit/proto/Video_pb2.py +3 -4
- streamlit/proto/WidgetStates_pb2.py +2 -3
- streamlit/proto/WidthConfig_pb2.py +2 -3
- streamlit/proto/openmetrics_data_model_pb2.py +2 -3
- streamlit/runtime/runtime.py +0 -4
- streamlit/static/index.html +2 -2
- streamlit/static/manifest.json +327 -312
- streamlit/static/static/css/{index.BUP6fTcR.css → index.C8MrxwGF.css} +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.D71F8ziR.js → ErrorOutline.esm.CLuz0rSD.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.yTkppsJy.js → FileDownload.esm.CO68LcnZ.js} +1 -1
- streamlit/static/static/js/{FileHelper.hUOqtbwa.js → FileHelper.DAXgY6Ug.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.DN8D_YXO.js → FormClearHelper.zxJ53Nym.js} +1 -1
- streamlit/static/static/js/{InputInstructions.DbssY6d4.js → InputInstructions.CCbg8esE.js} +1 -1
- streamlit/static/static/js/{Particles.BznyVdfo.js → Particles.BJw0A-zv.js} +1 -1
- streamlit/static/static/js/{ProgressBar.C5uBOtcx.js → ProgressBar.BrrHeAEh.js} +2 -2
- streamlit/static/static/js/{StreamlitSyntaxHighlighter.Nf1895x-.js → StreamlitSyntaxHighlighter.DvPLy3zk.js} +1 -1
- streamlit/static/static/js/{TableChart.esm.DHKzVs3a.js → TableChart.esm.BawvAi5p.js} +1 -1
- streamlit/static/static/js/{Toolbar.CQsWYXer.js → Toolbar.CbpscbNb.js} +1 -1
- streamlit/static/static/js/{WidgetLabelHelpIconInline.6xCU76OE.js → WidgetLabelHelpIconInline.DA4S2HFP.js} +1 -1
- streamlit/static/static/js/{base-input.Cs-E6S71.js → base-input.BKKl2eBF.js} +4 -4
- streamlit/static/static/js/{checkbox.OTGupu18.js → checkbox.CB43AKV4.js} +1 -1
- streamlit/static/static/js/{createDownloadLinkElement.DnBEQQbK.js → createDownloadLinkElement.jVwF96ey.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.CxQizSv7.js +1 -0
- streamlit/static/static/js/{downloader.K0GUNeuj.js → downloader.CKlIgsy5.js} +1 -1
- streamlit/static/static/js/{embed.o8HvK3mH.js → embed.BhRb_2n8.js} +1 -1
- streamlit/static/static/js/{es6.BHy5pqTP.js → es6.DPyfPmWm.js} +2 -2
- streamlit/static/static/js/formatNumber.DtfMnnPx.js +1 -0
- streamlit/static/static/js/{iconPosition.2YynQUxu.js → iconPosition.DkZAlu_k.js} +1 -1
- streamlit/static/static/js/{iframeResizer.contentWindow.D5h3hQuU.js → iframeResizer.contentWindow.l5sQWLra.js} +1 -1
- streamlit/static/static/js/{index.BZ-GJVxB.js → index.465nmxtO.js} +2 -2
- streamlit/static/static/js/{index.BPdmXoYW.js → index.6J1N4is3.js} +1 -1
- streamlit/static/static/js/{index.Bfo1cXfC.js → index.AZ9T4EqJ.js} +1 -1
- streamlit/static/static/js/{index.cfuZ69LI.js → index.BAK0CG1Q.js} +1 -1
- streamlit/static/static/js/{index.5zqfJ-in.js → index.BLD3tJ2C.js} +1 -1
- streamlit/static/static/js/{index.CxWzt6oi.js → index.BUlT_mOL.js} +3 -3
- streamlit/static/static/js/{index.DxGXuhh6.js → index.Bc_FQ4Wb.js} +1 -1
- streamlit/static/static/js/{index.DJfMW0Gy.js → index.BpCj2-sQ.js} +1 -1
- streamlit/static/static/js/{index.DLUSo6de.js → index.BzO83wKm.js} +1 -1
- streamlit/static/static/js/index.CAoX2tlo.js +2 -0
- streamlit/static/static/js/{index.CwtpGPHA.js → index.CBbYMKZp.js} +1 -1
- streamlit/static/static/js/{index.Bgf49D1Z.js → index.CL7it7tU.js} +222 -222
- streamlit/static/static/js/{index.DxfYCrPp.js → index.CL_icBXS.js} +1 -1
- streamlit/static/static/js/index.C_19KWNs.js +2 -0
- streamlit/static/static/js/index.CaU3Uv_L.js +1 -0
- streamlit/static/static/js/{index.Dh3PJIlq.js → index.Ccye_uLl.js} +1 -1
- streamlit/static/static/js/{index.C65jHNhe.js → index.CiS4giQ2.js} +1 -1
- streamlit/static/static/js/{index.hlAfdSqC.js → index.Ck64OQhV.js} +1 -1
- streamlit/static/static/js/{index.HmRK3HyC.js → index.CmbqbRMZ.js} +1 -1
- streamlit/static/static/js/{index.8MlRyIxN.js → index.CsEZTo6L.js} +2 -2
- streamlit/static/static/js/{index.DVRCyxMp.js → index.CsIENsKH.js} +1 -1
- streamlit/static/static/js/{index.Bqmx23jK.js → index.Cwg8nWw5.js} +1 -1
- streamlit/static/static/js/{index.CZf7Go1Z.js → index.D83azq2w.js} +1 -1
- streamlit/static/static/js/{index.CUkhn-vu.js → index.DDr-BLbJ.js} +1 -1
- streamlit/static/static/js/{index.iUV9rb8C.js → index.DKoJr0Se.js} +1 -1
- streamlit/static/static/js/{index.C2EoeVjP.js → index.DL_ywOgf.js} +2 -2
- streamlit/static/static/js/{index.q0ceUXt6.js → index.DR6V0uBJ.js} +1 -1
- streamlit/static/static/js/index.DZOGT9vX.js +1 -0
- streamlit/static/static/js/{index.BtuskCwg.js → index.Dac9Jib-.js} +1 -1
- streamlit/static/static/js/{index.6c-qDsD7.js → index.DiBeetOH.js} +1 -1
- streamlit/static/static/js/{index.DlgcEr0f.js → index.DjuMEZ6m.js} +1 -1
- streamlit/static/static/js/{index.DBPWUJsj.js → index.DmWUXdjc.js} +54 -54
- streamlit/static/static/js/{index.DL_yE83J.js → index.DpSc4e1j.js} +2 -2
- streamlit/static/static/js/{index.CgVv04GM.js → index.DzdPUxsx.js} +2 -2
- streamlit/static/static/js/{index.BtRWcqZV.js → index.FioS1Y9m.js} +1 -1
- streamlit/static/static/js/{index.BfMPq234.js → index.L9pOjBEn.js} +3 -3
- streamlit/static/static/js/{index.TjMWsKSH.js → index.LjqoQCm5.js} +3 -3
- streamlit/static/static/js/index.OizPL4jg.js +1 -0
- streamlit/static/static/js/{index.Cb03y5I8.js → index.Q2t_iBn0.js} +1 -1
- streamlit/static/static/js/index.WIMtx3m0.js +2 -0
- streamlit/static/static/js/index.Y9wPTZIf.js +1 -0
- streamlit/static/static/js/{index.COh5V_89.js → index.YutgmD9x.js} +2 -2
- streamlit/static/static/js/{index.BIqcOZ_u.js → index.b_f-McZ5.js} +1 -1
- streamlit/static/static/js/{index.BzTVI_BY.js → index.e6Ry6-Ft.js} +1 -1
- streamlit/static/static/js/index.hnu9U-5g.js +1 -0
- streamlit/static/static/js/{index.C6wyTXhz.js → index.rvbQETlC.js} +1 -1
- streamlit/static/static/js/index.w7yKy9fh.js +6 -0
- streamlit/static/static/js/{index.C7wst9Tm.js → index.y0h42OXL.js} +1 -1
- streamlit/static/static/js/{index.aCorc3Yt.js → index.y5HxPwg9.js} +48 -48
- streamlit/static/static/js/{index.CX0KdFyR.js → index.yHLCvUGh.js} +1 -1
- streamlit/static/static/js/{input.CXGIJ7D6.js → input.CAtwSQ27.js} +1 -1
- streamlit/static/static/js/{main.CCVkbuxC.js → main.VeMVx6VI.js} +1 -1
- streamlit/static/static/js/{memory.CNbnYs2A.js → memory.CxS_lIUn.js} +1 -1
- streamlit/static/static/js/number-overlay-editor.CoqRgZW_.js +9 -0
- streamlit/static/static/js/{pandasStylerUtils.CFSReOTm.js → pandasStylerUtils.DGWgd5sM.js} +1 -1
- streamlit/static/static/js/{sandbox.Bld0L3us.js → sandbox.2mSqEau0.js} +1 -1
- streamlit/static/static/js/sprintfjs.CsoVVZ9k.js +1 -0
- streamlit/static/static/js/{styled-components.BoUHK6TA.js → styled-components.BShfh7J8.js} +1 -1
- streamlit/static/static/js/{throttle.ByDFm7WV.js → throttle.Fq1DQK4p.js} +1 -1
- streamlit/static/static/js/{timepicker.CN6CUZEL.js → timepicker.DmyY-qtn.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.DwMycSpg.js → toConsumableArray.Dvd9AIqV.js} +1 -1
- streamlit/static/static/js/uniqueId.CCajdEK8.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.Bg0ZMUt5.js → useBasicWidgetState.COLQ5AFB.js} +1 -1
- streamlit/static/static/js/{useIntlLocale.DgBUDcPA.js → useIntlLocale.kdIj0ego.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.DDBezxks.js → useTextInputAutoExpand.DkuG1C1S.js} +1 -1
- streamlit/static/static/js/{useUpdateUiValue.Df1h6fXC.js → useUpdateUiValue.-UI_JsjT.js} +1 -1
- streamlit/static/static/js/{useWaveformController.DbWw5MEk.js → useWaveformController.C5PTwL6I.js} +1 -1
- streamlit/static/static/js/{withCalculatedWidth.YaK0HIIP.js → withCalculatedWidth.BREyS0pJ.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.CcWCKoY8.js → withFullScreenWrapper.DYDiEOrW.js} +1 -1
- streamlit/static/static/media/MaterialSymbols-Rounded.CnH1S47a.woff2 +0 -0
- streamlit/testing/v1/app_test.py +21 -5
- streamlit/testing/v1/element_tree.py +81 -4
- streamlit/web/server/server.py +0 -1
- streamlit/web/server/starlette/starlette_app.py +0 -1
- {streamlit_nightly-1.53.2.dev20260128.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/METADATA +10 -25
- {streamlit_nightly-1.53.2.dev20260128.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/RECORD +245 -252
- streamlit/proto/BokehChart_pb2.py +0 -27
- streamlit/proto/BokehChart_pb2.pyi +0 -56
- streamlit/proto/DataFrame_pb2.py +0 -56
- streamlit/proto/DataFrame_pb2.pyi +0 -430
- streamlit/proto/LabelVisibilityMessage_pb2.py +0 -29
- streamlit/proto/NamedDataSet_pb2.py +0 -28
- streamlit/proto/NamedDataSet_pb2.pyi +0 -67
- streamlit/proto/PagesChanged_pb2.py +0 -28
- streamlit/proto/PagesChanged_pb2.pyi +0 -55
- streamlit/proto/VegaLiteChart_pb2.py +0 -29
- streamlit/proto/VegaLiteChart_pb2.pyi +0 -79
- streamlit/static/static/js/data-grid-overlay-editor.COiiMi5r.js +0 -1
- streamlit/static/static/js/formatNumber.BK7h0k2z.js +0 -1
- streamlit/static/static/js/index.BBTKOM0z.js +0 -6
- streamlit/static/static/js/index.CSPY26T2.js +0 -1
- streamlit/static/static/js/index.CYhhEdja.js +0 -1
- streamlit/static/static/js/index.CdsyTabv.js +0 -1
- streamlit/static/static/js/index.CjRU8O1O.js +0 -2
- streamlit/static/static/js/index.Dc5-tFdw.js +0 -2
- streamlit/static/static/js/index.DcngUOyD.js +0 -2
- streamlit/static/static/js/index.VwDKazgt.js +0 -1
- streamlit/static/static/js/number-overlay-editor.CvI6wkld.js +0 -9
- streamlit/static/static/js/sprintf.DpPCfzXw.js +0 -1
- streamlit/static/static/js/uniqueId.DcCWa2cf.js +0 -1
- streamlit/static/static/media/MaterialSymbols-Rounded.C7IFxh57.woff2 +0 -0
- streamlit_nightly-1.53.2.dev20260128.data/scripts/streamlit.cmd +0 -16
- {streamlit_nightly-1.53.2.dev20260128.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.53.2.dev20260128.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.53.2.dev20260128.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,E as S,_ as E,V as ct,z as m,cv as b,ct as Fe,o as A,j as a,P as ue,ax as V,ay as pe,$ as K,b as dt,B as ut,Y as Me,bW as pt,l as gt,k as ft,b6 as ht,cw as mt,e as ie,bP as Re,bQ as wt,aa as vt}from"./index.aCorc3Yt.js";import{u as ke,I as Ct,g as Ve,F as Y,E as ce,b as xt,s as yt,a as Ae}from"./FileHelper.hUOqtbwa.js";import{u as bt}from"./useWaveformController.DbWw5MEk.js";import{I as St}from"./InputInstructions.DbssY6d4.js";import{u as Et,T as It}from"./useTextInputAutoExpand.DDBezxks.js";import{i as zt}from"./inputUtils.CptNuJwn.js";import{T as Rt}from"./TableChart.esm.DHKzVs3a.js";import{E as Vt}from"./ErrorOutline.esm.D71F8ziR.js";import{U as Te}from"./UploadFileInfo.Dr-zDST7.js";import"./base-input.Cs-E6S71.js";var De=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("rect",{width:24,height:24,fill:"none"}),r.createElement("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"}),r.createElement("path",{d:"M14 17H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"}))});De.displayName="Article";var Ue=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"}))});Ue.displayName="Code";var He=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"}))});He.displayName="Description";var Le=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M9.17 6l2 2H20v10H4V6h5.17M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"}))});Le.displayName="Folder";var Ne=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4.86 8.86l-3 3.87L9 13.14 6 17h12l-3.86-5.14z"}))});Ne.displayName="Image";var Be=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M12 3l.01 10.55c-.59-.34-1.27-.55-2-.55a4.001 4.001 0 100 8c2.22 0 3.99-1.79 3.99-4V7h4V3h-6zm-1.99 16c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"}))});Be.displayName="MusicNote";var We=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1-9c0-.55.45-1 1-1s1 .45 1 1v6c0 .55-.45 1-1 1s-1-.45-1-1V5zm6 6c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});We.displayName="MicNone";var Pe=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M15 8v8H5V8h10m1-2H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4V7c0-.55-.45-1-1-1z"}))});Pe.displayName="Videocam";var Oe=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("rect",{width:24,height:24,fill:"none"}),r.createElement("path",{d:"M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1z"}))});Oe.displayName="Add";var $e=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M13 19V7.83l4.88 4.88c.39.39 1.03.39 1.42 0a.996.996 0 000-1.41l-6.59-6.59a.996.996 0 00-1.41 0l-6.6 6.58a.996.996 0 101.41 1.41L11 7.83V19c0 .55.45 1 1 1s1-.45 1-1z"}))});$e.displayName="ArrowUpward";var Xe=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm4.29 12.89a.996.996 0 11-1.41 1.41L12 13.41 9.11 16.3a.996.996 0 11-1.41-1.41L10.59 12 7.71 9.11A.996.996 0 119.12 7.7L12 10.59l2.89-2.89a.996.996 0 111.41 1.41L13.41 12l2.88 2.89z"}))});Xe.displayName="Cancel";var je=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M18 6.7l-8.48 8.48-3.54-3.54a.996.996 0 10-1.41 1.41l4.24 4.24c.39.39 1.02.39 1.41 0l9.18-9.18a.999.999 0 00-.01-1.42c-.37-.38-1-.38-1.39.01z"}))});je.displayName="Check";var _e=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M18.3 5.71a.996.996 0 00-1.41 0L12 10.59 7.11 5.7A.996.996 0 105.7 7.11L10.59 12 5.7 16.89a.996.996 0 101.41 1.41L12 13.41l4.89 4.89a.996.996 0 101.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"}))});_e.displayName="Close";var Ke=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("rect",{width:24,height:24,fill:"none"}),r.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1zm0 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"}))});Ke.displayName="ErrorOutline";const _=ct.getLogger("ChatInput"),At=m("div",{target:"e15xmbo00"})({position:"relative",display:"flex",flexDirection:"column"}),Ft=m("div",{target:"e15xmbo01"})(({theme:e})=>({backgroundColor:e.colors.secondaryBg,border:`${e.sizes.borderWidth} solid`,borderColor:e.colors.widgetBorderColor??e.colors.transparent,position:"relative",display:"flex",flexDirection:"column",alignItems:"stretch",flex:1,paddingTop:e.spacing.md,paddingBottom:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg,gap:e.spacing.sm,borderRadius:e.radii.default,boxSizing:"border-box",":focus-within":{borderColor:e.colors.primary}})),Mt=m("div",{target:"e15xmbo02"})(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing.sm})),kt=m("div",{target:"e15xmbo03"})(({theme:e,isStacked:t})=>({display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",gap:e.spacing.sm,flexWrap:t?"wrap":"nowrap"})),Tt=m("div",{target:"e15xmbo04"})(({isStacked:e})=>({flex:e?"none":1,width:e?"100%":"auto",order:e?-1:0,display:"flex",alignItems:"center",minWidth:0})),Dt=m("div",{target:"e15xmbo05"})(({theme:e})=>({display:"flex",flexDirection:"row",flexShrink:0,gap:e.spacing.sm,alignItems:"center"})),Ut=m("div",{target:"e15xmbo06"})(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing.sm,alignItems:"center"})),Ht=m("div",{target:"e15xmbo07"})(({theme:e})=>({position:"absolute",top:e.spacing.twoXS,right:e.spacing.lg,color:e.colors.fadedText60,fontSize:e.fontSizes.twoSm,textAlign:"right",whiteSpace:"nowrap",pointerEvents:"auto",cursor:"text",zIndex:e.zIndices.priority,"& .stChatInputInstructions":{position:"static"}})),k=m("button",{target:"e15xmbo08"})(({theme:e,disabled:t,hasError:o,primary:p})=>{if(p)return{border:"none",backgroundColor:t?e.colors.darkenedBgMix15:e.colors.primary,borderRadius:e.radii.button,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:e.lineHeights.none,margin:e.spacing.none,padding:e.spacing.xs,width:e.sizes.chatInputPrimaryButtonSize,height:e.sizes.chatInputPrimaryButtonSize,color:t?e.colors.fadedText40:e.colors.white,cursor:t?"not-allowed":"pointer",transition:"background-color 200ms ease","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{boxShadow:e.shadows.focusRing},"&:hover":{backgroundColor:t?e.colors.darkenedBgMix15:e.colors.primary}};const l=()=>o?e.colors.redTextColor:t?e.colors.fadedText40:e.colors.fadedText60;return{border:"none",backgroundColor:e.colors.transparent,borderRadius:e.radii.default,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:e.lineHeights.none,margin:e.spacing.none,padding:e.spacing.none,color:l(),pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{boxShadow:e.shadows.focusRing},"&:hover":{color:o?e.colors.redColor:e.colors.bodyText},"&:active":{color:e.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:e.colors.transparent,borderColor:e.colors.transparent,color:e.colors.fadedText40,cursor:"not-allowed"},"& svg":{width:e.iconSizes.lg,height:e.iconSizes.lg}}}),Lt=m("div",{target:"e15xmbo09"})(({isRecording:e})=>({display:e?"flex":"none",flex:1,alignItems:"center",minWidth:0})),Nt=m("div",{target:"e15xmbo010"})(({theme:e})=>({position:"relative",width:"100%",height:e.sizes.chatInputPrimaryButtonSize,borderRadius:e.radii.default,overflow:"hidden","& > div":{position:"absolute",inset:0}})),Ye=(e,t)=>t===b.Directory?{...e,webkitdirectory:"",multiple:!0}:e,Bt=(e,t)=>{if(!t||t.length===0)return!0;const o=e.name.toLowerCase(),p=o.lastIndexOf(".");if(p===-1||p===o.length-1)return t.some(d=>d===""||d===".");const l=o.substring(p),w=o.substring(p+1);return t.some(d=>{const v=d.toLowerCase();return v.startsWith(".")?l===v:w===v})},Wt=(e,t)=>Bt(e,t)?{isValid:!0}:{isValid:!1,errorMessage:`${e.type||"This type of"} files are not allowed.`},de=e=>{switch(e){case b.None:return"a file";case b.Single:return"a file";case b.Multiple:return"files";case b.Directory:return"a directory";default:return Fe(e),"a file"}},Pt=m("div",{target:"e1lsn30a0"})(({theme:e})=>({backgroundColor:e.colors.transparent,position:"absolute",inset:0,zIndex:e.zIndices.priority,borderRadius:e.radii.chatInput})),Ot=m("div",{target:"e1lsn30a1"})(({theme:e})=>({position:"absolute",inset:0,border:`${e.sizes.borderWidth} solid`,borderColor:e.colors.primary,borderRadius:e.radii.chatInput,backgroundColor:e.colors.secondaryBg,color:e.colors.primary,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:e.fontWeights.bold,pointerEvents:"none",zIndex:e.zIndices.priority})),$t=m("div",{target:"e1lsn30a2"})(({disabled:e})=>({pointerEvents:e?"none":"auto"})),Xt=m("div",{target:"e1lsn30a3"})(({theme:e})=>({lineHeight:e.lineHeights.tight})),jt=m("div",{target:"e1lsn30a4"})(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing.sm})),_t=m("div",{target:"e1lsn30a5"})({flex:"0 0 auto",maxWidth:"100%"}),Kt=m("div",{target:"e1lsn30a6"})(({theme:e,isError:t,isClickable:o})=>({position:"relative",display:"inline-flex",alignItems:"center",width:"fit-content",minWidth:"9rem",maxWidth:"100%",backgroundColor:t?e.colors.redBackgroundColor:e.colors.bgColor,padding:e.spacing.twoXS,paddingRight:e.spacing.twoXL,borderRadius:e.radii.default,gap:e.spacing.sm,cursor:o?"pointer":"default"})),Yt=m("div",{target:"e1lsn30a7"})({display:"flex",flexDirection:"column",minWidth:0}),Gt=m("div",{target:"e1lsn30a8"})(({theme:e,fileStatus:t})=>({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:e.radii.default,width:e.sizes.chatInputFileIconSize,height:e.sizes.chatInputFileIconSize,flexShrink:0,overflow:"hidden",...t==="uploaded"&&{backgroundColor:e.colors.bodyText,color:e.colors.bgColor},...t==="uploading"&&{backgroundColor:e.colors.fadedText10,color:e.colors.fadedText60},...t==="error"&&{backgroundColor:e.colors.redBackgroundColor,color:e.colors.redTextColor}})),qt=m("img",{target:"e1lsn30a9"})({width:"100%",height:"100%",objectFit:"cover"}),Qt=m("div",{target:"e1lsn30a10"})(({theme:e,fileStatus:t})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:t.type==="uploading"?e.colors.fadedText60:e.colors.bodyText})),Jt=m("div",{target:"e1lsn30a11"})(({theme:e})=>({color:e.colors.fadedText60,fontSize:e.fontSizes.sm})),Zt=m("small",{target:"e1lsn30a12"})(({theme:e,isError:t})=>({position:"absolute",top:e.spacing.twoXS,right:e.spacing.twoXS,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:0,"& button":{display:"flex",alignItems:"center",justifyContent:"center",width:"fit-content",height:"fit-content",minHeight:"unset",minWidth:"unset",maxHeight:"unset",maxWidth:"unset",borderRadius:"50%",backgroundColor:"transparent",color:t?e.colors.redTextColor:e.colors.fadedText60,padding:0,overflow:"hidden",boxSizing:"border-box",lineHeight:0,"&:hover":{backgroundColor:"transparent",color:t?e.colors.redColor:e.colors.bodyText}}})),er=m("span",{target:"e1lsn30a13"})({position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0}),tr=({onDrop:e,multiple:t,accept:o,maxSize:p,acceptFile:l,disabled:w})=>{const{getRootProps:d,getInputProps:v}=ke({onDrop:e,multiple:t,accept:o,maxSize:p,useFsAccessApi:!1}),C=Ye(v(),l),c=d({tabIndex:-1});return A($t,{"data-testid":"stChatInputFileUploadButton",disabled:w,...c,children:[a("input",{...C}),a(pe,{content:`Upload or drag and drop ${de(l)}`,placement:ue.TOP,onMouseEnterDelay:500,children:a(k,{type:"button",disabled:w,"aria-label":`Upload ${de(l)}`,children:a(V,{content:Oe,size:"xl",color:"inherit"})})})]})},rr=r.memo(tr),or=({getRootProps:e,getInputProps:t,acceptFile:o})=>{const p=Ye(t(),o);return A(K,{children:[a(Pt,{...e(),children:a("input",{...p})}),a(Ot,{children:`Drag and drop ${de(o)} here`})]})},nr=r.memo(or),Ge=new Set(["jpg","jpeg","png","gif","webp","svg","bmp"]),ar=new Set(["pdf"]),ir=new Set(["csv","tsv","xlsx","xls"]),sr=new Set(["txt","md","json","xml","yaml","yml"]),lr=new Set(["py","js","ts","jsx","tsx","css","html","java","cpp","c","go","rs","rb","php","swift","kt","scala","sh","bash","sql"]),cr=new Set(["mp3","wav","m4a","ogg","flac","aac"]),dr=new Set(["mp4","webm","mov","avi","mkv","wmv"]),ur=new Set(["zip","tar","gz","rar","7z","bz2"]);function qe(e){const t=e.lastIndexOf(".");return t===-1||t===e.length-1?"":e.slice(t+1).toLowerCase()}function pr(e){const t=qe(e);return Ge.has(t)?Ne:ar.has(t)?De:ir.has(t)?Rt:sr.has(t)?He:lr.has(t)?Ue:cr.has(t)?Be:dr.has(t)?Pe:ur.has(t)?Le:Ct}function gr(e){const t=qe(e);return Ge.has(t)}const fr=20;function hr(e,t=fr){if(e.length<=t)return e;const o=e.lastIndexOf(".");if(!(o>0&&o<e.length-1)){const f=Math.floor((t-3)/2),g=f>0?e.slice(-f):"";return`${e.slice(0,f)}...${g}`}const l=e.slice(o),w=e.slice(0,o),d=t-l.length-3;if(d<=0){const f=Math.floor((t-3)/2),g=f>0?e.slice(-f):"";return`${e.slice(0,f)}...${g}`}const v=Math.ceil(d/2),C=Math.floor(d/2),c=C>0?w.slice(-C):"";return`${w.slice(0,v)}...${c}${l}`}function mr(e,t){const o=r.useMemo(()=>!e||!gr(t)?null:URL.createObjectURL(e),[e,t]);return r.useEffect(()=>()=>{o&&URL.revokeObjectURL(o)},[o]),o}const wr=({fileInfo:e,imagePreviewUrl:t})=>{const{type:o}=e.status;switch(o){case"uploading":return a(Me,{iconValue:"spinner",testid:"stChatInputFileIconSpinner",size:"lg"});case"error":return a(V,{content:Vt,size:"lg",testid:"stChatInputFileIconError"});case"uploaded":return t?a(qt,{src:t,alt:e.name,"data-testid":"stChatInputFileImagePreview"}):a(V,{content:pr(e.name),size:"lg"});default:return Fe(o),null}},vr=({fileInfo:e,onDelete:t,onRetry:o})=>{const p=e.status.type,l=p==="error",w=p==="uploading",d=l&&o!==void 0&&e.file!==void 0,v=r.useId(),C=mr(e.file,e.name),c=e.status.type==="error"?e.status.errorMessage:"Upload failed",f=r.useCallback(()=>{d&&o(e)},[d,o,e]),g=r.useCallback(x=>{d&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),o(e))},[d,o,e]),h=r.useCallback(x=>{x.stopPropagation(),t(e.id)},[t,e.id]),T=w?`Cancel upload of ${e.name}`:`Remove ${e.name}`,G=Ve(e.size,Y.Byte),W=`${e.name}, ${G}`,D=A(Kt,{className:"stChatInputFile","data-testid":"stChatInputFile",isError:l,isClickable:d,onClick:d?f:void 0,onKeyDown:d?g:void 0,title:d?"Click to retry upload":void 0,role:d?"button":void 0,tabIndex:d?0:void 0,"aria-label":W,"aria-invalid":l||void 0,"aria-describedby":l?v:void 0,children:[a(Gt,{fileStatus:p,children:a(wr,{fileInfo:e,imagePreviewUrl:C})}),A(Yt,{children:[a(Qt,{className:"stChatInputFileName","data-testid":"stChatInputFileName",title:e.name,fileStatus:e.status,children:hr(e.name)}),a(Jt,{children:Ve(e.size,Y.Byte)})]}),a(Zt,{"data-testid":"stChatInputDeleteBtn",isError:l,children:a(dt,{onClick:h,kind:ut.MINIMAL,"aria-label":T,children:a(V,{content:Xe,size:"md"})})}),l&&A(er,{id:v,role:"alert",children:["Error: ",c]})]});return l?a(pe,{content:c,placement:ue.TOP,error:!0,children:D}):D},Cr=r.memo(vr),xr=({items:e,onDelete:t,onRetry:o})=>a(Xt,{"data-testid":"stChatUploadedFiles",children:a(jt,{children:e.map(p=>a(_t,{children:a(Cr,{fileInfo:p,onDelete:t,onRetry:o})},p.id))})}),yr=r.memo(xr),br=(e,t,o)=>{const p=[],l=[];return e.forEach(w=>{if(w.size>o){l.push({file:w,errors:[{code:ce.FileTooLarge,message:`File is too large. Maximum size is ${o} bytes.`}]});return}const d=Wt(w,t.fileType);if(!d.isValid){l.push({file:w,errors:[{code:ce.FileInvalidType,message:d.errorMessage||"File type not allowed."}]});return}p.push(w)}),{accepted:p,rejected:l}},Sr=({acceptMultipleFiles:e,maxFileSize:t,uploadClient:o,uploadFile:p,addFiles:l,getNextLocalFileId:w,deleteExistingFiles:d,onUploadComplete:v,element:C})=>(c,f)=>{if(c.length>0){const{accepted:g,rejected:h}=br(c,C,t);c=g,f=[...f,...h]}if(!e&&c.length===0&&f.length>1){const g=f.findIndex(h=>h.errors?.[0].code===ce.TooManyFiles);g>=0&&(c.push(f[g].file),f.splice(g,1))}if(!e&&c.length>0&&d(),o.fetchFileURLs(c).then(g=>{pt(g,c).forEach(([h,T])=>{p(h,T)})}).catch(g=>{l(c.map(h=>new Te(h.name,h.size,w(),{type:"error",errorMessage:g},h)))}),f.length>0){const g=f.map(h=>xt(h,w(),t));l(g)}v()},Er=({getNextLocalFileId:e,addFiles:t,updateFile:o,uploadClient:p,element:l,onUploadProgress:w,onUploadComplete:d})=>(v,C)=>{const c=C.webkitRelativePath||C.name,f=new AbortController,g=new Te(c,C.size,e(),{type:"uploading",abortController:f,progress:1},C);t([g]),p.uploadFile({formId:"",...l},v.uploadUrl,C,h=>w(h,g.id),f.signal).then(()=>d(g.id,v)).catch(h=>{h instanceof DOMException&&h.name==="AbortError"||o(g.id,g.setStatus({type:"error",errorMessage:h?h.toString():"Unknown error"}))})};function Ir(e,t,o){return{Root:{style:{minHeight:e.sizes.chatInputTextareaMinHeight,outline:"none",borderLeftWidth:"0",borderRightWidth:"0",borderTopWidth:"0",borderBottomWidth:"0",borderTopLeftRadius:"0",borderTopRightRadius:"0",borderBottomRightRadius:"0",borderBottomLeftRadius:"0",...o}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{fontWeight:e.fontWeights.normal,lineHeight:e.lineHeights.inputWidget,"::placeholder":{color:e.colors.fadedText60},height:t.isExtended?t.height:"auto",maxHeight:t.maxHeight,overflowY:"auto",paddingLeft:e.spacing.none,paddingRight:e.spacing.none,paddingBottom:e.spacing.twoXS,paddingTop:e.spacing.twoXS,width:"100%"}}}}const se=(e,t,o)=>o.map(p=>p.id===e?t:p),le=(e,t)=>t.find(o=>o.id===e);function zr({disabled:e,element:t,widgetMgr:o,fragmentId:p,uploadClient:l}){const w=gt(),{placeholder:d,maxChars:v}=t,C=r.useRef(0),c=r.useRef(null),f=r.useRef(!1),g=r.useRef(null),h=r.useRef(null),{width:T,elementRef:G}=ft(),{innerWidth:W,innerHeight:D}=ht(),[x,q]=r.useState(t.default),[z,F]=r.useState([]),[U,Q]=r.useState(!1),[H,ge]=r.useState(!1),[J,L]=r.useState(null),[M,Z]=r.useState(!1),[Qe,fe]=r.useState(0),ee=t.acceptAudio??!1;r.useEffect(()=>()=>{h.current&&h.current.abort()},[]);const P=Et({textareaRef:c,dependencies:[d,M]}),O=r.useRef(""),$=r.useRef(0),te=r.useRef(null),he=r.useRef(null),N=r.useCallback(n=>{const i=getComputedStyle(n);O.current=`${i.fontWeight} ${i.fontSize} ${i.fontFamily}`;const u=parseFloat(i.paddingLeft)||0,s=parseFloat(i.paddingRight)||0;$.current=n.clientWidth-u-s},[]);r.useLayoutEffect(()=>{const n=c.current;if(!n)return;N(n);const i=new ResizeObserver(()=>N(n));return i.observe(n),()=>i.disconnect()},[N,M]),r.useEffect(()=>{if(x===""){Z(!1);return}if(M)return;const n=c.current;if(!n||(($.current<=0||!O.current)&&N(n),$.current<=0||!O.current))return;te.current||(te.current=document.createElement("canvas"),he.current=te.current.getContext("2d"));const i=he.current;i&&(i.font=O.current,i.measureText(x).width>$.current-10&&Z(!0))},[x,M,N]);const X=r.useMemo(()=>z.some(n=>n.status.type==="uploading")?!1:x!==""||z.length>0,[z,x]),I=mt(t.acceptFile),re=yt(t.maxUploadSizeMb,Y.Megabyte,Y.Byte),me=r.useCallback(n=>F(i=>[...i,...n]),[]),we=r.useCallback(n=>{n.status.type==="uploading"&&n.status.abortController.abort(),n.status.type==="uploaded"&&n.status.fileUrls.deleteUrl&&l.deleteFile(n.status.fileUrls.deleteUrl).catch(i=>{_.error("Failed to delete file from server:",i)})},[l]),ve=r.useCallback(n=>{F(i=>{const u=le(n,i);if(ie(u))return i;we(u);const s=i.filter(y=>y.id!==n);return s.length===0&&fe(y=>y+1),s})},[we]),oe=r.useRef(null),Je=r.useCallback(n=>{!n.file||n.status.type!=="error"||(F(i=>i.filter(u=>u.id!==n.id)),oe.current&&oe.current([n.file],[]))},[]),Ce=r.useCallback(()=>{const n=z.filter(i=>i.status.type==="uploaded").map(i=>{const{name:u,size:s,status:y}=i,{fileId:ae,fileUrls:lt}=y;return new Re({fileId:ae,fileUrls:lt,name:u,size:s})});return new wt({uploadedFileInfo:n})},[z]),xe=()=>C.current++,ne=Sr({acceptMultipleFiles:I===b.Multiple||I===b.Directory,maxFileSize:re,uploadClient:l,uploadFile:Er({getNextLocalFileId:xe,addFiles:me,updateFile:(n,i)=>{F(u=>se(n,i,u))},uploadClient:l,element:t,onUploadProgress:(n,i)=>{F(u=>{const s=le(i,u);if(ie(s)||s.status.type!=="uploading")return u;const y=Math.round(n.loaded*100/n.total);return s.status.progress===y?u:se(i,s.setStatus({type:"uploading",abortController:s.status.abortController,progress:y}),u)})},onUploadComplete:(n,i)=>{F(u=>{const s=le(n,u);return ie(s)||s.status.type!=="uploading"?u:se(s.id,s.setStatus({type:"uploaded",fileId:i.fileId,fileUrls:i}),u)})}}),addFiles:me,getNextLocalFileId:xe,deleteExistingFiles:()=>z.forEach(n=>ve(n.id)),onUploadComplete:()=>{c.current&&c.current.focus()},element:t});oe.current=ne;const{getRootProps:Ze,getInputProps:et}=ke({onDrop:ne,multiple:I===b.Multiple||I===b.Directory,accept:Ae(t.fileType),maxSize:re,useFsAccessApi:!1}),j=r.useCallback(n=>{if(c.current&&c.current.focus(),!X&&!n||e)return;const i=Ce(),u={data:x,fileUploaderState:i,audioFileInfo:n};o.setChatInputValue(t,u,{fromUi:!0},p),z.length>0&&fe(s=>s+1),F([]),q(""),Z(!1),P.clearScrollHeight()},[X,e,x,z.length,Ce,o,t,p,P]),ye=r.useCallback(async n=>{const i=new Date().toISOString().replace(/[:.]/g,"-"),u=new File([n],`audio-${i}.wav`,{type:"audio/wav"});try{ge(!0);const s=await l.fetchFileURLs([u]);if(s.length===0)throw new Error("Failed to get upload URL for audio file");const y=s[0];h.current=new AbortController,await l.uploadFile({formId:"",...t},y.uploadUrl,u,()=>{},h.current.signal);const ae=new Re({fileId:y.fileId,fileUrls:y,name:u.name,size:u.size});j(ae)}catch(s){const y="Recording failed";_.error("Audio upload failed:",s),L(y),c.current&&c.current.focus()}finally{ge(!1)}},[l,t,j]),tt=r.useMemo(()=>({onApprove:ye,onPermissionDenied:()=>{const n="Microphone access denied";L(n),_.error("Permission denied:",n)},onError:n=>{L("Recording failed"),_.error("Recording error:",n)},onRecordStart:()=>{L(null)}}),[ye]),R=bt({containerRef:g,sampleRate:t.audioSampleRate??void 0,events:tt}),be=r.useCallback(()=>{j()},[j]),rt=n=>{const{metaKey:i,ctrlKey:u,shiftKey:s}=n;zt(n)&&!s&&!u&&!i&&(n.preventDefault(),be())},ot=n=>{const{value:i}=n.target;v!==0&&i.length>v||(q(i),P.updateScrollHeight(),J&&L(null))},Se=r.useCallback(async n=>{n.preventDefault(),n.stopPropagation(),!(!ee||e||R.state==="recording")&&await R.start()},[ee,e,R]),nt=r.useCallback(()=>{R.cancel(),c.current&&c.current.focus()},[R]),Ee=r.useCallback(async()=>{const{blob:n}=await R.stop();await R.approve(n)},[R]),Ie=r.useCallback(n=>{Se(n)},[Se]),at=r.useCallback(()=>{Ee()},[Ee]),it=r.useCallback(()=>{c.current&&c.current.focus()},[]);r.useEffect(()=>{if(t.setValue&&!f.current){f.current=!0;const n=t.value||"";q(n)}},[t.setValue,t.value]),r.useEffect(()=>{f.current=!1},[t]),r.useEffect(()=>{const n=s=>{s.preventDefault(),s.stopPropagation(),!U&&s.dataTransfer?.types.includes("Files")&&Q(!0)},i=s=>{s.preventDefault(),s.stopPropagation(),U&&(s.clientX<=0&&s.clientY<=0||s.clientX>=W&&s.clientY>=D)&&Q(!1)},u=s=>{s.preventDefault(),s.stopPropagation(),U&&Q(!1)};return window.addEventListener("dragover",n),window.addEventListener("drop",u),window.addEventListener("dragleave",i),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",u),window.removeEventListener("dragleave",i)}},[U,W,D]);const st=I!==b.None&&U,B=R.state==="recording",ze=!B&&T>vt(w.breakpoints.hideWidgetDetails)&&v>0;return a(At,{className:"stChatInput","data-testid":"stChatInput",ref:G,children:A(Ft,{children:[ze&&a(Ht,{onClick:it,id:"stChatInputInstructions",children:a(St,{dirty:X,value:x,maxLength:v,type:"chat",inForm:!1,className:"stChatInputInstructions"})}),st&&a(nr,{getRootProps:Ze,getInputProps:et,acceptFile:I}),I!==b.None&&z.length>0&&a(Mt,{children:a(yr,{items:[...z],onDelete:ve,onRetry:Je})}),A(kt,{isStacked:M,children:[a(Dt,{children:I!==b.None&&!B&&a(rr,{onDrop:ne,multiple:I===b.Multiple||I===b.Directory,accept:Ae(t.fileType),maxSize:re,acceptFile:I,disabled:e},Qe)}),a(Lt,{isRecording:B,children:a(Nt,{ref:g})}),!B&&a(Tt,{isStacked:M,children:a(It,{inputRef:c,value:x,placeholder:d,onChange:ot,onKeyDown:rt,"aria-label":d,disabled:e,rows:1,"aria-describedby":ze?"stChatInputInstructions":void 0,overrides:Ir(w,P,{width:"100%"})})}),a(Ut,{children:B?A(K,{children:[a(k,{onClick:nt,disabled:e,"data-testid":"stChatInputCancelButton","aria-label":"Cancel recording",children:a(V,{content:_e,size:"lg",color:"inherit"})}),a(k,{onClick:at,disabled:e||H,"data-testid":"stChatInputApproveButton","aria-label":"Submit recording",children:H?a(Me,{size:"lg",iconValue:"spinner"}):a(V,{content:je,size:"lg",color:"inherit"})})]}):A(K,{children:[ee&&a(K,{children:J?a(pe,{content:J,placement:ue.TOP,error:!0,children:a(k,{onClick:Ie,disabled:e||H,hasError:!0,"data-testid":"stChatInputMicButton","aria-label":"Start recording",children:a(V,{content:Ke,size:"xl",color:"inherit"})})}):a(k,{onClick:Ie,disabled:e||H,"data-testid":"stChatInputMicButton","aria-label":"Start recording",children:a(V,{content:We,size:"xl",color:"inherit"})})}),a(k,{onClick:be,disabled:!X||e||H,"data-testid":"stChatInputSubmitButton","aria-label":"Send message",primary:!0,children:a(V,{content:$e,size:"lg",color:"inherit"})})]})})]})]})})}const Lr=r.memo(zr);export{Lr as default};
|
|
1
|
+
import{r,E as S,_ as E,V as ct,z as m,cy as b,cw as Fe,o as A,j as a,P as ue,az as V,aA as pe,$ as K,b as dt,B as ut,Y as Me,bZ as pt,l as gt,k as ft,b8 as ht,cz as mt,e as ie,bS as Re,bT as wt,ac as vt}from"./index.y5HxPwg9.js";import{u as Te,I as Ct,g as Ve,F as Y,E as ce,b as xt,s as yt,a as Ae}from"./FileHelper.DAXgY6Ug.js";import{u as bt}from"./useWaveformController.C5PTwL6I.js";import{I as St}from"./InputInstructions.CCbg8esE.js";import{u as Et,T as It}from"./useTextInputAutoExpand.DkuG1C1S.js";import{i as zt}from"./inputUtils.CptNuJwn.js";import{T as Rt}from"./TableChart.esm.BawvAi5p.js";import{E as Vt}from"./ErrorOutline.esm.CLuz0rSD.js";import{U as ke}from"./UploadFileInfo.Dr-zDST7.js";import"./base-input.BKKl2eBF.js";var De=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("rect",{width:24,height:24,fill:"none"}),r.createElement("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"}),r.createElement("path",{d:"M14 17H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z"}))});De.displayName="Article";var Ue=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"}))});Ue.displayName="Code";var He=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"}))});He.displayName="Description";var Le=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M9.17 6l2 2H20v10H4V6h5.17M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"}))});Le.displayName="Folder";var Ne=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-4.86 8.86l-3 3.87L9 13.14 6 17h12l-3.86-5.14z"}))});Ne.displayName="Image";var Be=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M12 3l.01 10.55c-.59-.34-1.27-.55-2-.55a4.001 4.001 0 100 8c2.22 0 3.99-1.79 3.99-4V7h4V3h-6zm-1.99 16c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"}))});Be.displayName="MusicNote";var We=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm-1-9c0-.55.45-1 1-1s1 .45 1 1v6c0 .55-.45 1-1 1s-1-.45-1-1V5zm6 6c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});We.displayName="MicNone";var Pe=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M15 8v8H5V8h10m1-2H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4V7c0-.55-.45-1-1-1z"}))});Pe.displayName="Videocam";var Oe=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("rect",{width:24,height:24,fill:"none"}),r.createElement("path",{d:"M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1z"}))});Oe.displayName="Add";var $e=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M13 19V7.83l4.88 4.88c.39.39 1.03.39 1.42 0a.996.996 0 000-1.41l-6.59-6.59a.996.996 0 00-1.41 0l-6.6 6.58a.996.996 0 101.41 1.41L11 7.83V19c0 .55.45 1 1 1s1-.45 1-1z"}))});$e.displayName="ArrowUpward";var Xe=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm4.29 12.89a.996.996 0 11-1.41 1.41L12 13.41 9.11 16.3a.996.996 0 11-1.41-1.41L10.59 12 7.71 9.11A.996.996 0 119.12 7.7L12 10.59l2.89-2.89a.996.996 0 111.41 1.41L13.41 12l2.88 2.89z"}))});Xe.displayName="Cancel";var je=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M18 6.7l-8.48 8.48-3.54-3.54a.996.996 0 10-1.41 1.41l4.24 4.24c.39.39 1.02.39 1.41 0l9.18-9.18a.999.999 0 00-.01-1.42c-.37-.38-1-.38-1.39.01z"}))});je.displayName="Check";var _e=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),r.createElement("path",{d:"M18.3 5.71a.996.996 0 00-1.41 0L12 10.59 7.11 5.7A.996.996 0 105.7 7.11L10.59 12 5.7 16.89a.996.996 0 101.41 1.41L12 13.41l4.89 4.89a.996.996 0 101.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z"}))});_e.displayName="Close";var Ke=r.forwardRef(function(e,t){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return r.createElement(S,E({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),r.createElement("rect",{width:24,height:24,fill:"none"}),r.createElement("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1zm0 4c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1z"}))});Ke.displayName="ErrorOutline";const _=ct.getLogger("ChatInput"),At=m("div",{target:"e15xmbo00"})({position:"relative",display:"flex",flexDirection:"column"}),Ft=m("div",{target:"e15xmbo01"})(({theme:e})=>({backgroundColor:e.colors.secondaryBg,border:`${e.sizes.borderWidth} solid`,borderColor:e.colors.widgetBorderColor??e.colors.transparent,position:"relative",display:"flex",flexDirection:"column",alignItems:"stretch",flex:1,paddingTop:e.spacing.md,paddingBottom:e.spacing.md,paddingLeft:e.spacing.lg,paddingRight:e.spacing.lg,gap:e.spacing.sm,borderRadius:e.radii.default,boxSizing:"border-box",":focus-within":{borderColor:e.colors.primary}})),Mt=m("div",{target:"e15xmbo02"})(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing.sm})),Tt=m("div",{target:"e15xmbo03"})(({theme:e,isStacked:t})=>({display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",gap:e.spacing.sm,flexWrap:t?"wrap":"nowrap"})),kt=m("div",{target:"e15xmbo04"})(({isStacked:e})=>({flex:e?"none":1,width:e?"100%":"auto",order:e?-1:0,display:"flex",alignItems:"center",minWidth:0})),Dt=m("div",{target:"e15xmbo05"})(({theme:e})=>({display:"flex",flexDirection:"row",flexShrink:0,gap:e.spacing.sm,alignItems:"center"})),Ut=m("div",{target:"e15xmbo06"})(({theme:e})=>({display:"flex",flexDirection:"row",gap:e.spacing.sm,alignItems:"center"})),Ht=m("div",{target:"e15xmbo07"})(({theme:e})=>({position:"absolute",top:e.spacing.twoXS,right:e.spacing.lg,color:e.colors.fadedText60,fontSize:e.fontSizes.twoSm,textAlign:"right",whiteSpace:"nowrap",pointerEvents:"auto",cursor:"text",zIndex:e.zIndices.priority,"& .stChatInputInstructions":{position:"static"}})),T=m("button",{target:"e15xmbo08"})(({theme:e,disabled:t,hasError:o,primary:p})=>{if(p)return{border:"none",backgroundColor:t?e.colors.darkenedBgMix15:e.colors.primary,borderRadius:e.radii.button,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:e.lineHeights.none,margin:e.spacing.none,padding:e.spacing.xs,width:e.sizes.chatInputPrimaryButtonSize,height:e.sizes.chatInputPrimaryButtonSize,color:t?e.colors.fadedText40:e.colors.white,cursor:t?"not-allowed":"pointer",transition:"background-color 200ms ease","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{boxShadow:e.shadows.focusRing},"&:hover":{backgroundColor:t?e.colors.darkenedBgMix15:e.colors.primary}};const l=()=>o?e.colors.redTextColor:t?e.colors.fadedText40:e.colors.fadedText60;return{border:"none",backgroundColor:e.colors.transparent,borderRadius:e.radii.default,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:e.lineHeights.none,margin:e.spacing.none,padding:e.spacing.none,color:l(),pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{boxShadow:e.shadows.focusRing},"&:hover":{color:o?e.colors.redColor:e.colors.bodyText},"&:active":{color:e.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:e.colors.transparent,borderColor:e.colors.transparent,color:e.colors.fadedText40,cursor:"not-allowed"},"& svg":{width:e.iconSizes.lg,height:e.iconSizes.lg}}}),Lt=m("div",{target:"e15xmbo09"})(({isRecording:e})=>({display:e?"flex":"none",flex:1,alignItems:"center",minWidth:0})),Nt=m("div",{target:"e15xmbo010"})(({theme:e})=>({position:"relative",width:"100%",height:e.sizes.chatInputPrimaryButtonSize,borderRadius:e.radii.default,overflow:"hidden","& > div":{position:"absolute",inset:0}})),Ye=(e,t)=>t===b.Directory?{...e,webkitdirectory:"",multiple:!0}:e,Bt=(e,t)=>{if(!t||t.length===0)return!0;const o=e.name.toLowerCase(),p=o.lastIndexOf(".");if(p===-1||p===o.length-1)return t.some(d=>d===""||d===".");const l=o.substring(p),w=o.substring(p+1);return t.some(d=>{const v=d.toLowerCase();return v.startsWith(".")?l===v:w===v})},Wt=(e,t)=>Bt(e,t)?{isValid:!0}:{isValid:!1,errorMessage:`${e.type||"This type of"} files are not allowed.`},de=e=>{switch(e){case b.None:return"a file";case b.Single:return"a file";case b.Multiple:return"files";case b.Directory:return"a directory";default:return Fe(e),"a file"}},Pt=m("div",{target:"e1lsn30a0"})(({theme:e})=>({backgroundColor:e.colors.transparent,position:"absolute",inset:0,zIndex:e.zIndices.priority,borderRadius:e.radii.chatInput})),Ot=m("div",{target:"e1lsn30a1"})(({theme:e})=>({position:"absolute",inset:0,border:`${e.sizes.borderWidth} solid`,borderColor:e.colors.primary,borderRadius:e.radii.chatInput,backgroundColor:e.colors.secondaryBg,color:e.colors.primary,display:"flex",alignItems:"center",justifyContent:"center",fontWeight:e.fontWeights.bold,pointerEvents:"none",zIndex:e.zIndices.priority})),$t=m("div",{target:"e1lsn30a2"})(({disabled:e})=>({pointerEvents:e?"none":"auto"})),Xt=m("div",{target:"e1lsn30a3"})(({theme:e})=>({lineHeight:e.lineHeights.tight})),jt=m("div",{target:"e1lsn30a4"})(({theme:e})=>({display:"flex",flexWrap:"wrap",gap:e.spacing.sm})),_t=m("div",{target:"e1lsn30a5"})({flex:"0 0 auto",maxWidth:"100%"}),Kt=m("div",{target:"e1lsn30a6"})(({theme:e,isError:t,isClickable:o})=>({position:"relative",display:"inline-flex",alignItems:"center",width:"fit-content",minWidth:"9rem",maxWidth:"100%",backgroundColor:t?e.colors.redBackgroundColor:e.colors.bgColor,padding:e.spacing.twoXS,paddingRight:e.spacing.twoXL,borderRadius:e.radii.default,gap:e.spacing.sm,cursor:o?"pointer":"default"})),Yt=m("div",{target:"e1lsn30a7"})({display:"flex",flexDirection:"column",minWidth:0}),Gt=m("div",{target:"e1lsn30a8"})(({theme:e,fileStatus:t})=>({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:e.radii.default,width:e.sizes.chatInputFileIconSize,height:e.sizes.chatInputFileIconSize,flexShrink:0,overflow:"hidden",...t==="uploaded"&&{backgroundColor:e.colors.bodyText,color:e.colors.bgColor},...t==="uploading"&&{backgroundColor:e.colors.fadedText10,color:e.colors.fadedText60},...t==="error"&&{backgroundColor:e.colors.redBackgroundColor,color:e.colors.redTextColor}})),qt=m("img",{target:"e1lsn30a9"})({width:"100%",height:"100%",objectFit:"cover"}),Zt=m("div",{target:"e1lsn30a10"})(({theme:e,fileStatus:t})=>({overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:t.type==="uploading"?e.colors.fadedText60:e.colors.bodyText})),Jt=m("div",{target:"e1lsn30a11"})(({theme:e})=>({color:e.colors.fadedText60,fontSize:e.fontSizes.sm})),Qt=m("small",{target:"e1lsn30a12"})(({theme:e,isError:t})=>({position:"absolute",top:e.spacing.twoXS,right:e.spacing.twoXS,display:"flex",alignItems:"center",justifyContent:"center",lineHeight:0,"& button":{display:"flex",alignItems:"center",justifyContent:"center",width:"fit-content",height:"fit-content",minHeight:"unset",minWidth:"unset",maxHeight:"unset",maxWidth:"unset",borderRadius:"50%",backgroundColor:"transparent",color:t?e.colors.redTextColor:e.colors.fadedText60,padding:0,overflow:"hidden",boxSizing:"border-box",lineHeight:0,"&:hover":{backgroundColor:"transparent",color:t?e.colors.redColor:e.colors.bodyText}}})),er=m("span",{target:"e1lsn30a13"})({position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0}),tr=({onDrop:e,multiple:t,accept:o,maxSize:p,acceptFile:l,disabled:w})=>{const{getRootProps:d,getInputProps:v}=Te({onDrop:e,multiple:t,accept:o,maxSize:p,useFsAccessApi:!1}),C=Ye(v(),l),c=d({tabIndex:-1});return A($t,{"data-testid":"stChatInputFileUploadButton",disabled:w,...c,children:[a("input",{...C}),a(pe,{content:`Upload or drag and drop ${de(l)}`,placement:ue.TOP,onMouseEnterDelay:500,children:a(T,{type:"button",disabled:w,"aria-label":`Upload ${de(l)}`,children:a(V,{content:Oe,size:"xl",color:"inherit"})})})]})},rr=r.memo(tr),or=({getRootProps:e,getInputProps:t,acceptFile:o})=>{const p=Ye(t(),o);return A(K,{children:[a(Pt,{...e(),children:a("input",{...p})}),a(Ot,{children:`Drag and drop ${de(o)} here`})]})},nr=r.memo(or),Ge=new Set(["jpg","jpeg","png","gif","webp","svg","bmp"]),ar=new Set(["pdf"]),ir=new Set(["csv","tsv","xlsx","xls"]),sr=new Set(["txt","md","json","xml","yaml","yml"]),lr=new Set(["py","js","ts","jsx","tsx","css","html","java","cpp","c","go","rs","rb","php","swift","kt","scala","sh","bash","sql"]),cr=new Set(["mp3","wav","m4a","ogg","flac","aac"]),dr=new Set(["mp4","webm","mov","avi","mkv","wmv"]),ur=new Set(["zip","tar","gz","rar","7z","bz2"]);function qe(e){const t=e.lastIndexOf(".");return t===-1||t===e.length-1?"":e.slice(t+1).toLowerCase()}function pr(e){const t=qe(e);return Ge.has(t)?Ne:ar.has(t)?De:ir.has(t)?Rt:sr.has(t)?He:lr.has(t)?Ue:cr.has(t)?Be:dr.has(t)?Pe:ur.has(t)?Le:Ct}function gr(e){const t=qe(e);return Ge.has(t)}const fr=20;function hr(e,t=fr){if(e.length<=t)return e;const o=e.lastIndexOf(".");if(!(o>0&&o<e.length-1)){const f=Math.floor((t-3)/2),g=f>0?e.slice(-f):"";return`${e.slice(0,f)}...${g}`}const l=e.slice(o),w=e.slice(0,o),d=t-l.length-3;if(d<=0){const f=Math.floor((t-3)/2),g=f>0?e.slice(-f):"";return`${e.slice(0,f)}...${g}`}const v=Math.ceil(d/2),C=Math.floor(d/2),c=C>0?w.slice(-C):"";return`${w.slice(0,v)}...${c}${l}`}function mr(e,t){const o=r.useMemo(()=>!e||!gr(t)?null:URL.createObjectURL(e),[e,t]);return r.useEffect(()=>()=>{o&&URL.revokeObjectURL(o)},[o]),o}const wr=({fileInfo:e,imagePreviewUrl:t})=>{const{type:o}=e.status;switch(o){case"uploading":return a(Me,{iconValue:"spinner",testid:"stChatInputFileIconSpinner",size:"lg"});case"error":return a(V,{content:Vt,size:"lg",testid:"stChatInputFileIconError"});case"uploaded":return t?a(qt,{src:t,alt:e.name,"data-testid":"stChatInputFileImagePreview"}):a(V,{content:pr(e.name),size:"lg"});default:return Fe(o),null}},vr=({fileInfo:e,onDelete:t,onRetry:o})=>{const p=e.status.type,l=p==="error",w=p==="uploading",d=l&&o!==void 0&&e.file!==void 0,v=r.useId(),C=mr(e.file,e.name),c=e.status.type==="error"?e.status.errorMessage:"Upload failed",f=r.useCallback(()=>{d&&o(e)},[d,o,e]),g=r.useCallback(x=>{d&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),o(e))},[d,o,e]),h=r.useCallback(x=>{x.stopPropagation(),t(e.id)},[t,e.id]),k=w?`Cancel upload of ${e.name}`:`Remove ${e.name}`,G=Ve(e.size,Y.Byte),W=`${e.name}, ${G}`,D=A(Kt,{className:"stChatInputFile","data-testid":"stChatInputFile",isError:l,isClickable:d,onClick:d?f:void 0,onKeyDown:d?g:void 0,title:d?"Click to retry upload":void 0,role:d?"button":void 0,tabIndex:d?0:void 0,"aria-label":W,"aria-invalid":l||void 0,"aria-describedby":l?v:void 0,children:[a(Gt,{fileStatus:p,children:a(wr,{fileInfo:e,imagePreviewUrl:C})}),A(Yt,{children:[a(Zt,{className:"stChatInputFileName","data-testid":"stChatInputFileName",title:e.name,fileStatus:e.status,children:hr(e.name)}),a(Jt,{children:Ve(e.size,Y.Byte)})]}),a(Qt,{"data-testid":"stChatInputDeleteBtn",isError:l,children:a(dt,{onClick:h,kind:ut.MINIMAL,"aria-label":k,children:a(V,{content:Xe,size:"md"})})}),l&&A(er,{id:v,role:"alert",children:["Error: ",c]})]});return l?a(pe,{content:c,placement:ue.TOP,error:!0,children:D}):D},Cr=r.memo(vr),xr=({items:e,onDelete:t,onRetry:o})=>a(Xt,{"data-testid":"stChatUploadedFiles",children:a(jt,{children:e.map(p=>a(_t,{children:a(Cr,{fileInfo:p,onDelete:t,onRetry:o})},p.id))})}),yr=r.memo(xr),br=(e,t,o)=>{const p=[],l=[];return e.forEach(w=>{if(w.size>o){l.push({file:w,errors:[{code:ce.FileTooLarge,message:`File is too large. Maximum size is ${o} bytes.`}]});return}const d=Wt(w,t.fileType);if(!d.isValid){l.push({file:w,errors:[{code:ce.FileInvalidType,message:d.errorMessage||"File type not allowed."}]});return}p.push(w)}),{accepted:p,rejected:l}},Sr=({acceptMultipleFiles:e,maxFileSize:t,uploadClient:o,uploadFile:p,addFiles:l,getNextLocalFileId:w,deleteExistingFiles:d,onUploadComplete:v,element:C})=>(c,f)=>{if(c.length>0){const{accepted:g,rejected:h}=br(c,C,t);c=g,f=[...f,...h]}if(!e&&c.length===0&&f.length>1){const g=f.findIndex(h=>h.errors?.[0].code===ce.TooManyFiles);g>=0&&(c.push(f[g].file),f.splice(g,1))}if(!e&&c.length>0&&d(),o.fetchFileURLs(c).then(g=>{pt(g,c).forEach(([h,k])=>{p(h,k)})}).catch(g=>{l(c.map(h=>new ke(h.name,h.size,w(),{type:"error",errorMessage:g},h)))}),f.length>0){const g=f.map(h=>xt(h,w(),t));l(g)}v()},Er=({getNextLocalFileId:e,addFiles:t,updateFile:o,uploadClient:p,element:l,onUploadProgress:w,onUploadComplete:d})=>(v,C)=>{const c=C.webkitRelativePath||C.name,f=new AbortController,g=new ke(c,C.size,e(),{type:"uploading",abortController:f,progress:1},C);t([g]),p.uploadFile({formId:"",...l},v.uploadUrl,C,h=>w(h,g.id),f.signal).then(()=>d(g.id,v)).catch(h=>{h instanceof DOMException&&h.name==="AbortError"||o(g.id,g.setStatus({type:"error",errorMessage:h?h.toString():"Unknown error"}))})};function Ir(e,t,o){return{Root:{style:{minHeight:e.sizes.chatInputTextareaMinHeight,outline:"none",borderLeftWidth:"0",borderRightWidth:"0",borderTopWidth:"0",borderBottomWidth:"0",borderTopLeftRadius:"0",borderTopRightRadius:"0",borderBottomRightRadius:"0",borderBottomLeftRadius:"0",...o}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{fontWeight:e.fontWeights.normal,lineHeight:e.lineHeights.inputWidget,"::placeholder":{color:e.colors.fadedText60},height:t.isExtended?t.height:"auto",maxHeight:t.maxHeight,overflowY:"auto",paddingLeft:e.spacing.none,paddingRight:e.spacing.none,paddingBottom:e.spacing.twoXS,paddingTop:e.spacing.twoXS,width:"100%"}}}}const se=(e,t,o)=>o.map(p=>p.id===e?t:p),le=(e,t)=>t.find(o=>o.id===e);function zr({disabled:e,element:t,widgetMgr:o,fragmentId:p,uploadClient:l}){const w=gt(),{placeholder:d,maxChars:v}=t,C=r.useRef(0),c=r.useRef(null),f=r.useRef(!1),g=r.useRef(null),h=r.useRef(null),{width:k,elementRef:G}=ft(),{innerWidth:W,innerHeight:D}=ht(),[x,q]=r.useState(t.default),[z,F]=r.useState([]),[U,Z]=r.useState(!1),[H,ge]=r.useState(!1),[J,L]=r.useState(null),[M,Q]=r.useState(!1),[Ze,fe]=r.useState(0),ee=t.acceptAudio??!1;r.useEffect(()=>()=>{h.current&&h.current.abort()},[]);const P=Et({textareaRef:c,dependencies:[d,M]}),O=r.useRef(""),$=r.useRef(0),te=r.useRef(null),he=r.useRef(null),N=r.useCallback(n=>{const i=getComputedStyle(n);O.current=`${i.fontWeight} ${i.fontSize} ${i.fontFamily}`;const u=parseFloat(i.paddingLeft)||0,s=parseFloat(i.paddingRight)||0;$.current=n.clientWidth-u-s},[]);r.useLayoutEffect(()=>{const n=c.current;if(!n)return;N(n);const i=new ResizeObserver(()=>N(n));return i.observe(n),()=>i.disconnect()},[N,M]),r.useEffect(()=>{if(x===""){Q(!1);return}if(M)return;const n=c.current;if(!n||(($.current<=0||!O.current)&&N(n),$.current<=0||!O.current))return;te.current||(te.current=document.createElement("canvas"),he.current=te.current.getContext("2d"));const i=he.current;i&&(i.font=O.current,i.measureText(x).width>$.current-10&&Q(!0))},[x,M,N]);const X=r.useMemo(()=>z.some(n=>n.status.type==="uploading")?!1:x!==""||z.length>0,[z,x]),I=mt(t.acceptFile),re=yt(t.maxUploadSizeMb,Y.Megabyte,Y.Byte),me=r.useCallback(n=>F(i=>[...i,...n]),[]),we=r.useCallback(n=>{n.status.type==="uploading"&&n.status.abortController.abort(),n.status.type==="uploaded"&&n.status.fileUrls.deleteUrl&&l.deleteFile(n.status.fileUrls.deleteUrl).catch(i=>{_.error("Failed to delete file from server:",i)})},[l]),ve=r.useCallback(n=>{F(i=>{const u=le(n,i);if(ie(u))return i;we(u);const s=i.filter(y=>y.id!==n);return s.length===0&&fe(y=>y+1),s})},[we]),oe=r.useRef(null),Je=r.useCallback(n=>{!n.file||n.status.type!=="error"||(F(i=>i.filter(u=>u.id!==n.id)),oe.current&&oe.current([n.file],[]))},[]),Ce=r.useCallback(()=>{const n=z.filter(i=>i.status.type==="uploaded").map(i=>{const{name:u,size:s,status:y}=i,{fileId:ae,fileUrls:lt}=y;return new Re({fileId:ae,fileUrls:lt,name:u,size:s})});return new wt({uploadedFileInfo:n})},[z]),xe=()=>C.current++,ne=Sr({acceptMultipleFiles:I===b.Multiple||I===b.Directory,maxFileSize:re,uploadClient:l,uploadFile:Er({getNextLocalFileId:xe,addFiles:me,updateFile:(n,i)=>{F(u=>se(n,i,u))},uploadClient:l,element:t,onUploadProgress:(n,i)=>{F(u=>{const s=le(i,u);if(ie(s)||s.status.type!=="uploading")return u;const y=Math.round(n.loaded*100/n.total);return s.status.progress===y?u:se(i,s.setStatus({type:"uploading",abortController:s.status.abortController,progress:y}),u)})},onUploadComplete:(n,i)=>{F(u=>{const s=le(n,u);return ie(s)||s.status.type!=="uploading"?u:se(s.id,s.setStatus({type:"uploaded",fileId:i.fileId,fileUrls:i}),u)})}}),addFiles:me,getNextLocalFileId:xe,deleteExistingFiles:()=>z.forEach(n=>ve(n.id)),onUploadComplete:()=>{c.current&&c.current.focus()},element:t});oe.current=ne;const{getRootProps:Qe,getInputProps:et}=Te({onDrop:ne,multiple:I===b.Multiple||I===b.Directory,accept:Ae(t.fileType),maxSize:re,useFsAccessApi:!1}),j=r.useCallback(n=>{if(c.current&&c.current.focus(),!X&&!n||e)return;const i=Ce(),u={data:x,fileUploaderState:i,audioFileInfo:n};o.setChatInputValue(t,u,{fromUi:!0},p),z.length>0&&fe(s=>s+1),F([]),q(""),Q(!1),P.clearScrollHeight()},[X,e,x,z.length,Ce,o,t,p,P]),ye=r.useCallback(async n=>{const i=new Date().toISOString().replace(/[:.]/g,"-"),u=new File([n],`audio-${i}.wav`,{type:"audio/wav"});try{ge(!0);const s=await l.fetchFileURLs([u]);if(s.length===0)throw new Error("Failed to get upload URL for audio file");const y=s[0];h.current=new AbortController,await l.uploadFile({formId:"",...t},y.uploadUrl,u,()=>{},h.current.signal);const ae=new Re({fileId:y.fileId,fileUrls:y,name:u.name,size:u.size});j(ae)}catch(s){const y="Recording failed";_.error("Audio upload failed:",s),L(y),c.current&&c.current.focus()}finally{ge(!1)}},[l,t,j]),tt=r.useMemo(()=>({onApprove:ye,onPermissionDenied:()=>{const n="Microphone access denied";L(n),_.error("Permission denied:",n)},onError:n=>{L("Recording failed"),_.error("Recording error:",n)},onRecordStart:()=>{L(null)}}),[ye]),R=bt({containerRef:g,sampleRate:t.audioSampleRate??void 0,events:tt}),be=r.useCallback(()=>{j()},[j]),rt=n=>{const{metaKey:i,ctrlKey:u,shiftKey:s}=n;zt(n)&&!s&&!u&&!i&&(n.preventDefault(),be())},ot=n=>{const{value:i}=n.target;v!==0&&i.length>v||(q(i),P.updateScrollHeight(),J&&L(null))},Se=r.useCallback(async n=>{n.preventDefault(),n.stopPropagation(),!(!ee||e||R.state==="recording")&&await R.start()},[ee,e,R]),nt=r.useCallback(()=>{R.cancel(),c.current&&c.current.focus()},[R]),Ee=r.useCallback(async()=>{const{blob:n}=await R.stop();await R.approve(n)},[R]),Ie=r.useCallback(n=>{Se(n)},[Se]),at=r.useCallback(()=>{Ee()},[Ee]),it=r.useCallback(()=>{c.current&&c.current.focus()},[]);r.useEffect(()=>{if(t.setValue&&!f.current){f.current=!0;const n=t.value||"";q(n)}},[t.setValue,t.value]),r.useEffect(()=>{f.current=!1},[t]),r.useEffect(()=>{const n=s=>{s.preventDefault(),s.stopPropagation(),!U&&s.dataTransfer?.types.includes("Files")&&Z(!0)},i=s=>{s.preventDefault(),s.stopPropagation(),U&&(s.clientX<=0&&s.clientY<=0||s.clientX>=W&&s.clientY>=D)&&Z(!1)},u=s=>{s.preventDefault(),s.stopPropagation(),U&&Z(!1)};return window.addEventListener("dragover",n),window.addEventListener("drop",u),window.addEventListener("dragleave",i),()=>{window.removeEventListener("dragover",n),window.removeEventListener("drop",u),window.removeEventListener("dragleave",i)}},[U,W,D]);const st=I!==b.None&&U,B=R.state==="recording",ze=!B&&k>vt(w.breakpoints.hideWidgetDetails)&&v>0;return a(At,{className:"stChatInput","data-testid":"stChatInput",ref:G,children:A(Ft,{children:[ze&&a(Ht,{onClick:it,id:"stChatInputInstructions",children:a(St,{dirty:X,value:x,maxLength:v,type:"chat",inForm:!1,className:"stChatInputInstructions"})}),st&&a(nr,{getRootProps:Qe,getInputProps:et,acceptFile:I}),I!==b.None&&z.length>0&&a(Mt,{children:a(yr,{items:[...z],onDelete:ve,onRetry:Je})}),A(Tt,{isStacked:M,children:[a(Dt,{children:I!==b.None&&!B&&a(rr,{onDrop:ne,multiple:I===b.Multiple||I===b.Directory,accept:Ae(t.fileType),maxSize:re,acceptFile:I,disabled:e},Ze)}),a(Lt,{isRecording:B,children:a(Nt,{ref:g})}),!B&&a(kt,{isStacked:M,children:a(It,{inputRef:c,value:x,placeholder:d,onChange:ot,onKeyDown:rt,"aria-label":d,disabled:e,rows:1,"aria-describedby":ze?"stChatInputInstructions":void 0,overrides:Ir(w,P,{width:"100%"})})}),a(Ut,{children:B?A(K,{children:[a(T,{onClick:nt,disabled:e,"data-testid":"stChatInputCancelButton","aria-label":"Cancel recording",children:a(V,{content:_e,size:"lg",color:"inherit"})}),a(T,{onClick:at,disabled:e||H,"data-testid":"stChatInputApproveButton","aria-label":"Submit recording",children:H?a(Me,{size:"lg",iconValue:"spinner"}):a(V,{content:je,size:"lg",color:"inherit"})})]}):A(K,{children:[ee&&a(K,{children:J?a(pe,{content:J,placement:ue.TOP,error:!0,children:a(T,{onClick:Ie,disabled:e||H,hasError:!0,"data-testid":"stChatInputMicButton","aria-label":"Start recording",children:a(V,{content:Ke,size:"xl",color:"inherit"})})}):a(T,{onClick:Ie,disabled:e||H,"data-testid":"stChatInputMicButton","aria-label":"Start recording",children:a(V,{content:We,size:"xl",color:"inherit"})})}),a(T,{onClick:be,disabled:!X||e||H,"data-testid":"stChatInputSubmitButton","aria-label":"Send message",primary:!0,children:a(V,{content:$e,size:"lg",color:"inherit"})})]})})]})]})})}const Lr=r.memo(zr);export{Lr as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{V as Q,e as Z,bu as me,bv as ge,z as he,r as d,l as ye,bw as k,aj as _,j as A,aM as pe,bx as H,by as Ee,a0 as be,a1 as Fe,o as Ce,$ as we,aL as Se,n as Ne,S as Oe}from"./index.aCorc3Yt.js";import{bz as nr}from"./index.aCorc3Yt.js";import{w as Ae}from"./withCalculatedWidth.YaK0HIIP.js";import{C as W,a as Y}from"./urls.BwSlolu9.js";import{D as Re,a as Ie}from"./IFrameUtil.DefezniK.js";const v="%[a-f0-9]{2}",G=new RegExp("("+v+")|([^%]+?)","gi"),B=new RegExp("("+v+")+","gi");function T(e,r){try{return[decodeURIComponent(e.join(""))]}catch{}if(e.length===1)return e;r=r||1;const t=e.slice(0,r),n=e.slice(r);return Array.prototype.concat.call([],T(t),T(n))}function _e(e){try{return decodeURIComponent(e)}catch{let r=e.match(G)||[];for(let t=1;t<r.length;t++)e=T(r,t).join(""),r=e.match(G)||[];return e}}function Te(e){const r={"%FE%FF":"��","%FF%FE":"��"};let t=B.exec(e);for(;t;){try{r[t[0]]=decodeURIComponent(t[0])}catch{const a=_e(t[0]);a!==t[0]&&(r[t[0]]=a)}t=B.exec(e)}r["%C2"]="�";const n=Object.keys(r);for(const a of n)e=e.replace(new RegExp(a,"g"),r[a]);return e}function xe(e){if(typeof e!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Te(e)}}function Ue(e,r){const t={};if(Array.isArray(r))for(const n of r){const a=Object.getOwnPropertyDescriptor(e,n);a?.enumerable&&Object.defineProperty(t,n,a)}else for(const n of Reflect.ownKeys(e)){const a=Object.getOwnPropertyDescriptor(e,n);if(a.enumerable){const s=e[n];r(n,s,e)&&Object.defineProperty(t,n,a)}}return t}function ee(e,r){if(!(typeof e=="string"&&typeof r=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e===""||r==="")return[];const t=e.indexOf(r);return t===-1?[]:[e.slice(0,t),e.slice(t+r.length)]}const $e=e=>e==null,Me=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`),x=Symbol("encodeFragmentIdentifier");function Le(e){switch(e.arrayFormat){case"index":return r=>(t,n)=>{const a=t.length;return n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),"[",a,"]"].join("")]:[...t,[c(r,e),"[",c(a,e),"]=",c(n,e)].join("")]};case"bracket":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),"[]"].join("")]:[...t,[c(r,e),"[]=",c(n,e)].join("")];case"colon-list-separator":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),":list="].join("")]:[...t,[c(r,e),":list=",c(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const r=e.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(n,a)=>a===void 0||e.skipNull&&a===null||e.skipEmptyString&&a===""?n:(a=a===null?"":a,n.length===0?[[c(t,e),r,c(a,e)].join("")]:[[n,c(a,e)].join(e.arrayFormatSeparator)])}default:return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,c(r,e)]:[...t,[c(r,e),"=",c(n,e)].join("")]}}function je(e){let r;switch(e.arrayFormat){case"index":return(t,n,a)=>{if(r=/\[(\d*)]$/.exec(t),t=t.replace(/\[\d*]$/,""),!r){a[t]=n;return}a[t]===void 0&&(a[t]={}),a[t][r[1]]=n};case"bracket":return(t,n,a)=>{if(r=/(\[])$/.exec(t),t=t.replace(/\[]$/,""),!r){a[t]=n;return}if(a[t]===void 0){a[t]=[n];return}a[t]=[...a[t],n]};case"colon-list-separator":return(t,n,a)=>{if(r=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!r){a[t]=n;return}if(a[t]===void 0){a[t]=[n];return}a[t]=[...a[t],n]};case"comma":case"separator":return(t,n,a)=>{const o=typeof n=="string"&&n.includes(e.arrayFormatSeparator)?n.split(e.arrayFormatSeparator).map(i=>h(i,e)):n===null?n:h(n,e);a[t]=o};case"bracket-separator":return(t,n,a)=>{const s=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!s){a[t]=n&&h(n,e);return}const o=n===null?[]:h(n,e).split(e.arrayFormatSeparator);if(a[t]===void 0){a[t]=o;return}a[t]=[...a[t],...o]};default:return(t,n,a)=>{if(a[t]===void 0){a[t]=n;return}a[t]=[...[a[t]].flat(),n]}}}function re(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function c(e,r){return r.encode?r.strict?Me(e):encodeURIComponent(e):e}function h(e,r){return r.decode?xe(e):e}function te(e){return Array.isArray(e)?e.sort():typeof e=="object"?te(Object.keys(e)).sort((r,t)=>Number(r)-Number(t)).map(r=>e[r]):e}function ne(e){const r=e.indexOf("#");return r!==-1&&(e=e.slice(0,r)),e}function De(e){let r="";const t=e.indexOf("#");return t!==-1&&(r=e.slice(t)),r}function q(e,r,t){return t==="string"&&typeof e=="string"?e:typeof t=="function"&&typeof e=="string"?t(e):t==="boolean"&&e===null?!0:t==="boolean"&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")?e.toLowerCase()==="true":t==="boolean"&&e!==null&&(e.toLowerCase()==="1"||e.toLowerCase()==="0")?e.toLowerCase()==="1":t==="string[]"&&r.arrayFormat!=="none"&&typeof e=="string"?[e]:t==="number[]"&&r.arrayFormat!=="none"&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?[Number(e)]:t==="number"&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?Number(e):r.parseBooleans&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")?e.toLowerCase()==="true":r.parseNumbers&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?Number(e):e}function U(e){e=ne(e);const r=e.indexOf("?");return r===-1?"":e.slice(r+1)}function $(e,r){r={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...r},re(r.arrayFormatSeparator);const t=je(r),n=Object.create(null);if(typeof e!="string"||(e=e.trim().replace(/^[?#&]/,""),!e))return n;for(const a of e.split("&")){if(a==="")continue;const s=r.decode?a.replaceAll("+"," "):a;let[o,i]=ee(s,"=");o===void 0&&(o=s),i=i===void 0?null:["comma","separator","bracket-separator"].includes(r.arrayFormat)?i:h(i,r),t(h(o,r),i,n)}for(const[a,s]of Object.entries(n))if(typeof s=="object"&&s!==null&&r.types[a]!=="string")for(const[o,i]of Object.entries(s)){const l=r.types[a],f=typeof l=="function"?l:l?l.replace("[]",""):void 0;s[o]=q(i,r,f)}else typeof s=="object"&&s!==null&&r.types[a]==="string"?n[a]=Object.values(s).join(r.arrayFormatSeparator):n[a]=q(s,r,r.types[a]);return r.sort===!1?n:(r.sort===!0?Object.keys(n).sort():Object.keys(n).sort(r.sort)).reduce((a,s)=>{const o=n[s];return a[s]=o&&typeof o=="object"&&!Array.isArray(o)?te(o):o,a},Object.create(null))}function ae(e,r){if(!e)return"";r={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...r},re(r.arrayFormatSeparator);const t=o=>r.skipNull&&$e(e[o])||r.skipEmptyString&&e[o]==="",n=Le(r),a={};for(const[o,i]of Object.entries(e))t(o)||(a[o]=i);const s=Object.keys(a);return r.sort!==!1&&s.sort(r.sort),s.map(o=>{let i=e[o];if(r.replacer&&(i=r.replacer(o,i),i===void 0)||i===void 0)return"";if(i===null)return c(o,r);if(Array.isArray(i)){if(i.length===0&&r.arrayFormat==="bracket-separator")return c(o,r)+"[]";let l=i;return r.replacer&&(l=i.map((f,u)=>r.replacer(`${o}[${u}]`,f)).filter(f=>f!==void 0)),l.reduce(n(o),[]).join("&")}return c(o,r)+"="+c(i,r)}).filter(o=>o.length>0).join("&")}function se(e,r){r={decode:!0,...r};let[t,n]=ee(e,"#");return t===void 0&&(t=e),{url:t?.split("?")?.[0]??"",query:$(U(e),r),...r&&r.parseFragmentIdentifier&&n?{fragmentIdentifier:h(n,r)}:{}}}function oe(e,r){r={encode:!0,strict:!0,[x]:!0,...r};const t=ne(e.url).split("?")[0]||"",n=U(e.url),a={...$(n,{sort:!1,...r}),...e.query};let s=ae(a,r);s&&=`?${s}`;let o=De(e.url);if(typeof e.fragmentIdentifier=="string"){const i=new URL(t);i.hash=e.fragmentIdentifier,o=r[x]?i.hash:`#${e.fragmentIdentifier}`}return`${t}${s}${o}`}function ie(e,r,t){t={parseFragmentIdentifier:!0,[x]:!1,...t};const{url:n,query:a,fragmentIdentifier:s}=se(e,t);return oe({url:n,query:Ue(a,r),fragmentIdentifier:s},t)}function Pe(e,r,t){const n=Array.isArray(r)?a=>!r.includes(a):(a,s)=>!r(a,s);return ie(e,n,t)}const Ve=Object.freeze(Object.defineProperty({__proto__:null,exclude:Pe,extract:U,parse:$,parseUrl:se,pick:ie,stringify:ae,stringifyUrl:oe},Symbol.toStringTag,{value:"Module"}));var S=(function(e){return e.COMPONENT_READY="streamlit:componentReady",e.SET_COMPONENT_VALUE="streamlit:setComponentValue",e.SET_FRAME_HEIGHT="streamlit:setFrameHeight",e})({}),ke=(function(e){return e.RENDER="streamlit:render",e})({});const He=1,F=Q.getLogger("componentUtils");function We(e){return(r,t)=>{if(!e.current)return;const{isReady:n,element:a,widgetMgr:s,setComponentError:o,componentReadyCallback:i,frameHeightCallback:l,fragmentId:f}=e.current,u=n();switch(r){case S.COMPONENT_READY:{const{apiVersion:y}=t;y!==He?o(new Error(`Unrecognized component API version: '${y}'`)):i();break}case S.SET_COMPONENT_VALUE:u?Ge(K(t,"value"),t.dataType,{fromUi:!0},a,s,f):F.warn(`Got ${r} before ${S.COMPONENT_READY}!`);break;case S.SET_FRAME_HEIGHT:u?l(K(t,"height")):F.warn(`Got ${r} before ${S.COMPONENT_READY}!`);break;default:F.warn(`Unrecognized ComponentBackMsgType: ${r}`)}}}function Ye(e,r){const t=JSON.parse(e),n=[];for(const a of r){const{key:s}=a;switch(a.value?.toLowerCase()){case"arrowdataframe":n.push({key:s,value:ge.toObject(a.arrowDataframe)});break;case"bytes":t[s]=a.bytes;break;default:throw new Error(`Unrecognized SpecialArg type: ${a.value}`)}}return[t,n]}function z(e,r,t,n,a){if(!a){F.warn("Can't send ForwardMsg; missing our iframe!");return}if(Z(a.contentWindow)){F.warn("Can't send ForwardMsg; iframe has no contentWindow!");return}a.contentWindow.postMessage({type:ke.RENDER,args:e,dfs:r,disabled:t,theme:{...me(n),font:n.genericFonts.bodyFont}},"*")}function Ge(e,r,t,n,a,s){if(e===void 0){F.warn("handleSetComponentValue: missing 'value' prop");return}switch(r){case"dataframe":a.setArrowValue(n,e,t,s);break;case"bytes":a.setBytesValue(n,e,t,s);break;default:a.setJsonValue(n,e,t,s)}}function K(e,r,t=void 0){return Object.hasOwn(e,r)?e[r]:t}const Be=he("iframe",{target:"edxyb2x0"})(({theme:e,componentReady:r})=>({colorScheme:"normal",border:"none",padding:e.spacing.none,margin:e.spacing.none,display:r?"initial":"none"})),R=Q.getLogger("ComponentInstance"),J=6e4;function qe(e,r,t){let n;Ne(t)&&t!==""?n=t:n=r.getComponentURL(e,"index.html");const a=Oe.CUSTOM_COMPONENT_CLIENT_ID,s=new URL(window.location.href);return n=Ve.stringifyUrl({url:n,query:{streamlitUrl:s.origin+s.pathname,...a&&{__streamlit_parent_client_id:a}}}),n}function X(e,r){let t;return r&&r!==""?t=`Your app is having trouble loading the **${e}** component.
|
|
1
|
+
import{V as Q,e as Z,bx as me,by as ge,z as he,r as d,l as ye,bz as k,al as _,j as A,aO as pe,bA as H,bB as Ee,a0 as be,a1 as Ce,o as Fe,$ as Se,aN as we,n as Ne,S as Oe}from"./index.y5HxPwg9.js";import{bC as nr}from"./index.y5HxPwg9.js";import{w as Ae}from"./withCalculatedWidth.BREyS0pJ.js";import{C as W,a as Y}from"./urls.BwSlolu9.js";import{D as Re,a as Ie}from"./IFrameUtil.DefezniK.js";const v="%[a-f0-9]{2}",G=new RegExp("("+v+")|([^%]+?)","gi"),B=new RegExp("("+v+")+","gi");function T(e,r){try{return[decodeURIComponent(e.join(""))]}catch{}if(e.length===1)return e;r=r||1;const t=e.slice(0,r),n=e.slice(r);return Array.prototype.concat.call([],T(t),T(n))}function _e(e){try{return decodeURIComponent(e)}catch{let r=e.match(G)||[];for(let t=1;t<r.length;t++)e=T(r,t).join(""),r=e.match(G)||[];return e}}function Te(e){const r={"%FE%FF":"��","%FF%FE":"��"};let t=B.exec(e);for(;t;){try{r[t[0]]=decodeURIComponent(t[0])}catch{const a=_e(t[0]);a!==t[0]&&(r[t[0]]=a)}t=B.exec(e)}r["%C2"]="�";const n=Object.keys(r);for(const a of n)e=e.replace(new RegExp(a,"g"),r[a]);return e}function xe(e){if(typeof e!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Te(e)}}function Ue(e,r){const t={};if(Array.isArray(r))for(const n of r){const a=Object.getOwnPropertyDescriptor(e,n);a?.enumerable&&Object.defineProperty(t,n,a)}else for(const n of Reflect.ownKeys(e)){const a=Object.getOwnPropertyDescriptor(e,n);if(a.enumerable){const s=e[n];r(n,s,e)&&Object.defineProperty(t,n,a)}}return t}function ee(e,r){if(!(typeof e=="string"&&typeof r=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e===""||r==="")return[];const t=e.indexOf(r);return t===-1?[]:[e.slice(0,t),e.slice(t+r.length)]}const $e=e=>e==null,Me=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,r=>`%${r.charCodeAt(0).toString(16).toUpperCase()}`),x=Symbol("encodeFragmentIdentifier");function Le(e){switch(e.arrayFormat){case"index":return r=>(t,n)=>{const a=t.length;return n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),"[",a,"]"].join("")]:[...t,[c(r,e),"[",c(a,e),"]=",c(n,e)].join("")]};case"bracket":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),"[]"].join("")]:[...t,[c(r,e),"[]=",c(n,e)].join("")];case"colon-list-separator":return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,[c(r,e),":list="].join("")]:[...t,[c(r,e),":list=",c(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const r=e.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(n,a)=>a===void 0||e.skipNull&&a===null||e.skipEmptyString&&a===""?n:(a=a===null?"":a,n.length===0?[[c(t,e),r,c(a,e)].join("")]:[[n,c(a,e)].join(e.arrayFormatSeparator)])}default:return r=>(t,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?t:n===null?[...t,c(r,e)]:[...t,[c(r,e),"=",c(n,e)].join("")]}}function je(e){let r;switch(e.arrayFormat){case"index":return(t,n,a)=>{if(r=/\[(\d*)]$/.exec(t),t=t.replace(/\[\d*]$/,""),!r){a[t]=n;return}a[t]===void 0&&(a[t]={}),a[t][r[1]]=n};case"bracket":return(t,n,a)=>{if(r=/(\[])$/.exec(t),t=t.replace(/\[]$/,""),!r){a[t]=n;return}if(a[t]===void 0){a[t]=[n];return}a[t]=[...a[t],n]};case"colon-list-separator":return(t,n,a)=>{if(r=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!r){a[t]=n;return}if(a[t]===void 0){a[t]=[n];return}a[t]=[...a[t],n]};case"comma":case"separator":return(t,n,a)=>{const o=typeof n=="string"&&n.includes(e.arrayFormatSeparator)?n.split(e.arrayFormatSeparator).map(i=>h(i,e)):n===null?n:h(n,e);a[t]=o};case"bracket-separator":return(t,n,a)=>{const s=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!s){a[t]=n&&h(n,e);return}const o=n===null?[]:h(n,e).split(e.arrayFormatSeparator);if(a[t]===void 0){a[t]=o;return}a[t]=[...a[t],...o]};default:return(t,n,a)=>{if(a[t]===void 0){a[t]=n;return}a[t]=[...[a[t]].flat(),n]}}}function re(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function c(e,r){return r.encode?r.strict?Me(e):encodeURIComponent(e):e}function h(e,r){return r.decode?xe(e):e}function te(e){return Array.isArray(e)?e.sort():typeof e=="object"?te(Object.keys(e)).sort((r,t)=>Number(r)-Number(t)).map(r=>e[r]):e}function ne(e){const r=e.indexOf("#");return r!==-1&&(e=e.slice(0,r)),e}function De(e){let r="";const t=e.indexOf("#");return t!==-1&&(r=e.slice(t)),r}function q(e,r,t){return t==="string"&&typeof e=="string"?e:typeof t=="function"&&typeof e=="string"?t(e):t==="boolean"&&e===null?!0:t==="boolean"&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")?e.toLowerCase()==="true":t==="boolean"&&e!==null&&(e.toLowerCase()==="1"||e.toLowerCase()==="0")?e.toLowerCase()==="1":t==="string[]"&&r.arrayFormat!=="none"&&typeof e=="string"?[e]:t==="number[]"&&r.arrayFormat!=="none"&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?[Number(e)]:t==="number"&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?Number(e):r.parseBooleans&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")?e.toLowerCase()==="true":r.parseNumbers&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?Number(e):e}function U(e){e=ne(e);const r=e.indexOf("?");return r===-1?"":e.slice(r+1)}function $(e,r){r={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...r},re(r.arrayFormatSeparator);const t=je(r),n=Object.create(null);if(typeof e!="string"||(e=e.trim().replace(/^[?#&]/,""),!e))return n;for(const a of e.split("&")){if(a==="")continue;const s=r.decode?a.replaceAll("+"," "):a;let[o,i]=ee(s,"=");o===void 0&&(o=s),i=i===void 0?null:["comma","separator","bracket-separator"].includes(r.arrayFormat)?i:h(i,r),t(h(o,r),i,n)}for(const[a,s]of Object.entries(n))if(typeof s=="object"&&s!==null&&r.types[a]!=="string")for(const[o,i]of Object.entries(s)){const l=r.types[a],f=typeof l=="function"?l:l?l.replace("[]",""):void 0;s[o]=q(i,r,f)}else typeof s=="object"&&s!==null&&r.types[a]==="string"?n[a]=Object.values(s).join(r.arrayFormatSeparator):n[a]=q(s,r,r.types[a]);return r.sort===!1?n:(r.sort===!0?Object.keys(n).sort():Object.keys(n).sort(r.sort)).reduce((a,s)=>{const o=n[s];return a[s]=o&&typeof o=="object"&&!Array.isArray(o)?te(o):o,a},Object.create(null))}function ae(e,r){if(!e)return"";r={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...r},re(r.arrayFormatSeparator);const t=o=>r.skipNull&&$e(e[o])||r.skipEmptyString&&e[o]==="",n=Le(r),a={};for(const[o,i]of Object.entries(e))t(o)||(a[o]=i);const s=Object.keys(a);return r.sort!==!1&&s.sort(r.sort),s.map(o=>{let i=e[o];if(r.replacer&&(i=r.replacer(o,i),i===void 0)||i===void 0)return"";if(i===null)return c(o,r);if(Array.isArray(i)){if(i.length===0&&r.arrayFormat==="bracket-separator")return c(o,r)+"[]";let l=i;return r.replacer&&(l=i.map((f,u)=>r.replacer(`${o}[${u}]`,f)).filter(f=>f!==void 0)),l.reduce(n(o),[]).join("&")}return c(o,r)+"="+c(i,r)}).filter(o=>o.length>0).join("&")}function se(e,r){r={decode:!0,...r};let[t,n]=ee(e,"#");return t===void 0&&(t=e),{url:t?.split("?")?.[0]??"",query:$(U(e),r),...r&&r.parseFragmentIdentifier&&n?{fragmentIdentifier:h(n,r)}:{}}}function oe(e,r){r={encode:!0,strict:!0,[x]:!0,...r};const t=ne(e.url).split("?")[0]||"",n=U(e.url),a={...$(n,{sort:!1,...r}),...e.query};let s=ae(a,r);s&&=`?${s}`;let o=De(e.url);if(typeof e.fragmentIdentifier=="string"){const i=new URL(t);i.hash=e.fragmentIdentifier,o=r[x]?i.hash:`#${e.fragmentIdentifier}`}return`${t}${s}${o}`}function ie(e,r,t){t={parseFragmentIdentifier:!0,[x]:!1,...t};const{url:n,query:a,fragmentIdentifier:s}=se(e,t);return oe({url:n,query:Ue(a,r),fragmentIdentifier:s},t)}function Pe(e,r,t){const n=Array.isArray(r)?a=>!r.includes(a):(a,s)=>!r(a,s);return ie(e,n,t)}const Ve=Object.freeze(Object.defineProperty({__proto__:null,exclude:Pe,extract:U,parse:$,parseUrl:se,pick:ie,stringify:ae,stringifyUrl:oe},Symbol.toStringTag,{value:"Module"}));var w=(function(e){return e.COMPONENT_READY="streamlit:componentReady",e.SET_COMPONENT_VALUE="streamlit:setComponentValue",e.SET_FRAME_HEIGHT="streamlit:setFrameHeight",e})({}),ke=(function(e){return e.RENDER="streamlit:render",e})({});const He=1,C=Q.getLogger("componentUtils");function We(e){return(r,t)=>{if(!e.current)return;const{isReady:n,element:a,widgetMgr:s,setComponentError:o,componentReadyCallback:i,frameHeightCallback:l,fragmentId:f}=e.current,u=n();switch(r){case w.COMPONENT_READY:{const{apiVersion:y}=t;y!==He?o(new Error(`Unrecognized component API version: '${y}'`)):i();break}case w.SET_COMPONENT_VALUE:u?Ge(K(t,"value"),t.dataType,{fromUi:!0},a,s,f):C.warn(`Got ${r} before ${w.COMPONENT_READY}!`);break;case w.SET_FRAME_HEIGHT:u?l(K(t,"height")):C.warn(`Got ${r} before ${w.COMPONENT_READY}!`);break;default:C.warn(`Unrecognized ComponentBackMsgType: ${r}`)}}}function Ye(e,r){const t=JSON.parse(e),n=[];for(const a of r){const{key:s}=a;switch(a.value?.toLowerCase()){case"arrowdataframe":n.push({key:s,value:ge.toObject(a.arrowDataframe)});break;case"bytes":t[s]=a.bytes;break;default:throw new Error(`Unrecognized SpecialArg type: ${a.value}`)}}return[t,n]}function z(e,r,t,n,a){if(!a){C.warn("Can't send ForwardMsg; missing our iframe!");return}if(Z(a.contentWindow)){C.warn("Can't send ForwardMsg; iframe has no contentWindow!");return}a.contentWindow.postMessage({type:ke.RENDER,args:e,dfs:r,disabled:t,theme:{...me(n),font:n.genericFonts.bodyFont}},"*")}function Ge(e,r,t,n,a,s){if(e===void 0){C.warn("handleSetComponentValue: missing 'value' prop");return}switch(r){case"dataframe":a.setArrowValue(n,e,t,s);break;case"bytes":a.setBytesValue(n,e,t,s);break;default:a.setJsonValue(n,e,t,s)}}function K(e,r,t=void 0){return Object.hasOwn(e,r)?e[r]:t}const Be=he("iframe",{target:"edxyb2x0"})(({theme:e,componentReady:r})=>({colorScheme:"normal",border:"none",padding:e.spacing.none,margin:e.spacing.none,display:r?"initial":"none"})),R=Q.getLogger("ComponentInstance"),J=6e4;function qe(e,r,t){let n;Ne(t)&&t!==""?n=t:n=r.getComponentURL(e,"index.html");const a=Oe.CUSTOM_COMPONENT_CLIENT_ID,s=new URL(window.location.href);return n=Ve.stringifyUrl({url:n,query:{streamlitUrl:s.origin+s.pathname,...a&&{__streamlit_parent_client_id:a}}}),n}function X(e,r){let t;return r&&r!==""?t=`Your app is having trouble loading the **${e}** component.
|
|
2
2
|
The app is attempting to load the component from **${r}**,
|
|
3
3
|
and hasn't received its \`Streamlit.setComponentReady()\` message.
|
|
4
4
|
|
|
@@ -8,4 +8,4 @@ For more troubleshooting help, please see the [Streamlit Component docs](${W}) o
|
|
|
8
8
|
|
|
9
9
|
If this is an installed component that works locally, the app may be having trouble accessing the component frontend assets due to network latency or proxy settings in your app deployment.
|
|
10
10
|
|
|
11
|
-
For more troubleshooting help, please see the [Streamlit Component docs](${W}) or visit our [forums](${Y}).`,t}function ze(e,r,t,n){if(!n)try{return Ye(e,r)}catch(a){const s=
|
|
11
|
+
For more troubleshooting help, please see the [Streamlit Component docs](${W}) or visit our [forums](${Y}).`,t}function ze(e,r,t,n){if(!n)try{return Ye(e,r)}catch(a){const s=we(a);t(s)}return[{},[]]}function Ke(e,r){return e===r||e.length===r.length&&e.every((t,n)=>{const a=r[n];return t.key===a.key&&t.value===a.value})}function Je(e){const r=ye(),[t,n]=d.useState(),{disabled:a,element:s,widgetMgr:o,width:i,fragmentId:l,componentRegistry:f}=e,{componentName:u,jsonArgs:y,specialArgs:ce,url:N}=s,[I,M]=ze(y,ce,n,t),F=d.useMemo(()=>qe(u,f,N),[u,f,N]),m=d.useRef({args:{},dataframeArgs:[]}),L=Ke(m.current.dataframeArgs,M);m.current.args=I,m.current.dataframeArgs=M;const[S,j]=d.useState(),[p,fe]=d.useState(()=>isNaN(I.height)?void 0:I.height),g=d.useRef(!1),E=d.useRef(null),D=d.useRef(),{clear:P}=k(()=>R.warn(X(u,N)),J/4),{clear:V}=k(()=>{_.flushSync(()=>{j(!0)})},J);if(d.useEffect(()=>{f.checkSourceUrlResponse(F,u)},[F,u,f]),d.useEffect(()=>{S&&!g.current&&(R.error(`Client Error: Custom Component ${u} timeout error`),f.sendTimeoutError(F,u))},[S,F,u,f]),d.useEffect(()=>{g.current&&z(m.current.args,m.current.dataframeArgs,a,r,E.current??void 0)},[a,p,L,y,r,i]),d.useEffect(()=>{const b=O=>{if(O===void 0){R.warn("handleSetFrameHeight: missing 'height' prop");return}if(O!==p){if(Z(E.current)){R.warn("handleSetFrameHeight: missing our iframeRef!");return}E.current.height=O.toString(),_.flushSync(()=>{fe(O)})}},le=()=>{z(m.current.args,m.current.dataframeArgs,a,r,E.current??void 0),P(),V(),g.current=!0,_.flushSync(()=>{j(!1)})};D.current={isReady:()=>g.current,element:s,widgetMgr:o,setComponentError:n,componentReadyCallback:le,frameHeightCallback:b,fragmentId:l}},[u,a,s,p,L,S,y,r,o,V,P,l]),d.useEffect(()=>{const b=E.current?.contentWindow??void 0;if(b)return f.registerListener(b,We(D)),()=>{b&&f.deregisterListener(b)}},[f,u]),t)return A(pe,{name:t.name,message:t.message});const ue=!g.current&&!S&&p!==0&&A(Ee,{element:H.create({height:p,style:H.SkeletonStyle.ELEMENT})}),de=!g.current&&S?A(Ce,{body:X(u,N),kind:be.WARNING}):null;return Fe(Se,{children:[ue,de,A(Be,{className:"stCustomComponentV1","data-testid":"stCustomComponentV1",allow:Ie,ref:E,src:F,width:i,height:p??0,scrolling:"no",sandbox:Re,title:u,componentReady:g.current,tabIndex:s.tabIndex??void 0})]})}const er=Ae(d.memo(Je));export{er as ComponentInstance,nr as ComponentRegistry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as c,
|
|
1
|
+
import{z as c,aj as e,c as t,r as n,B as l,j as a,u as C,a as x,D as L,d as S}from"./index.y5HxPwg9.js";import{m as $}from"./iconPosition.DkZAlu_k.js";function R(o,r){switch(o){case t.XSMALL:return{padding:`${r.spacing.twoXS} ${r.spacing.sm}`,fontSize:r.fontSizes.sm};case t.SMALL:return{padding:`${r.spacing.twoXS} ${r.spacing.md}`};case t.LARGE:return{padding:`${r.spacing.md} ${r.spacing.md}`};default:return{padding:`${r.spacing.xs} ${r.spacing.md}`}}}const f=c("a",{target:"e1hofpsd0"})(({containerWidth:o,size:r,theme:i})=>({display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:i.fontWeights.normal,padding:`${i.spacing.xs} ${i.spacing.md}`,borderRadius:i.radii.button,minHeight:i.sizes.minElementHeight,margin:0,lineHeight:i.lineHeights.base,color:i.colors.primary,textDecoration:"none",width:o?"100%":"auto",userSelect:"none","&:visited":{color:i.colors.primary},"&:focus":{outline:"none"},"&:focus-visible":{boxShadow:i.shadows.focusRing},"&:hover":{textDecoration:"none"},"&:active":{textDecoration:"none"},...R(r,i)})),T=c(f,{target:"e1hofpsd1"})(({theme:o})=>({backgroundColor:o.colors.primary,color:o.colors.white,border:`${o.sizes.borderWidth} solid ${o.colors.primary}`,"&:hover, &:focus-visible":{backgroundColor:e(o.colors.primary,.15),borderColor:e(o.colors.primary,.15)},"&:active":{backgroundColor:o.colors.primary,borderColor:e(o.colors.primary,.15)},"&:visited:not(:active)":{color:o.colors.white},"&[disabled], &[disabled]:hover, &[disabled]:active, &[disabled]:visited":{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),w=c(f,{target:"e1hofpsd2"})(({theme:o})=>({backgroundColor:o.colors.lightenedBg05,color:o.colors.bodyText,border:`${o.sizes.borderWidth} solid ${o.colors.borderColor}`,"&:visited":{color:o.colors.bodyText},"&:hover, &:focus-visible":{backgroundColor:o.colors.darkenedBgMix15},"&:active":{backgroundColor:o.colors.darkenedBgMix25},"&[disabled], &[disabled]:hover, &[disabled]:active":{borderColor:o.colors.borderColor,backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),z=c(f,{target:"e1hofpsd3"})(({theme:o})=>({padding:o.spacing.none,backgroundColor:o.colors.transparent,color:o.colors.bodyText,border:"none","&:visited":{color:o.colors.bodyText},"&:hover, &:focus-visible":{color:o.colors.primary},"&:hover:not([disabled]), &:focus-visible:not([disabled])":{"span.stMarkdownColoredText":{color:"inherit !important"}},"&:active":{color:e(o.colors.primary,.25)},"&[disabled], &[disabled]:hover, &[disabled]:active":{backgroundColor:o.colors.transparent,color:o.colors.fadedText40,cursor:"not-allowed"}})),y=n.forwardRef(function({kind:r,size:i,disabled:s,children:d,autoFocus:u,href:b,rel:p,target:k,onClick:B},v){let g=T;return r===l.SECONDARY?g=w:r===l.TERTIARY&&(g=z),a(g,{ref:v,kind:r,size:i||t.MEDIUM,containerWidth:!0,disabled:s||!1,autoFocus:u||!1,href:b,target:k,rel:p,onClick:B,tabIndex:s?-1:0,"data-testid":`stBaseLinkButton-${r}`,children:d})});y.displayName="BaseLinkButton";const A=n.memo(y);function D(o){const{element:r}=o,i=r.shortcut?r.shortcut:void 0;let s=l.SECONDARY;r.type==="primary"?s=l.PRIMARY:r.type==="tertiary"&&(s=l.TERTIARY);const d=n.useRef(null),u=n.useCallback(()=>{r.disabled||d.current?.click()},[r.disabled]),b=n.useCallback(p=>{r.disabled&&p.preventDefault()},[r.disabled]);return C({shortcut:i,disabled:r.disabled,onActivate:u}),a(S,{className:"stLinkButton","data-testid":"stLinkButton",children:a(x,{help:r.help,containerWidth:!0,children:a(A,{ref:d,kind:s,size:t.SMALL,disabled:r.disabled,onClick:b,href:r.url,target:"_blank",rel:"noreferrer","aria-disabled":r.disabled,children:a(L,{icon:r.icon,iconPosition:$(r.iconPosition),label:r.label,shortcut:i})})})})}const I=n.memo(D);export{I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,E as G,_ as Y,z as k,bd as C,e as h,n as J,V as dt,l as pt,k as ft,ab as mt,ac as V,o as B,j as d,p as bt,ad as ht,ae as gt,af as yt,Y as It,az as j}from"./index.y5HxPwg9.js";import{I as Ct}from"./InputInstructions.CCbg8esE.js";import{u as Tt}from"./useBasicWidgetState.COLQ5AFB.js";import{s as St}from"./sprintfjs.CsoVVZ9k.js";import{u as wt}from"./uniqueId.CCajdEK8.js";import{I as vt}from"./input.CAtwSQ27.js";import"./FormClearHelper.zxJ53Nym.js";import"./base-input.BKKl2eBF.js";var Q=a.forwardRef(function(t,e){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return a.createElement(G,Y({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),a.createElement("path",{d:"M0 3v2h8V3H0z"}))});Q.displayName="Minus";var Z=a.forwardRef(function(t,e){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return a.createElement(G,Y({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},t,{ref:e}),a.createElement("path",{d:"M3 0v3H0v2h3v3h2V5h3V3H5V0H3z"}))});Z.displayName="Plus";const xt=k("div",{target:"eaeic2i0"})(({theme:t})=>({display:"flex",flexDirection:"row",flexWrap:"nowrap",alignItems:"center",height:t.sizes.minElementHeight,borderWidth:t.sizes.borderWidth,borderStyle:"solid",borderColor:t.colors.widgetBorderColor??t.colors.secondaryBg,transitionDuration:"200ms",transitionProperty:"border",transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.4, 1)",borderRadius:t.radii.default,overflow:"hidden","&.focused":{borderColor:t.colors.primary},input:{MozAppearance:"textfield","&::-webkit-inner-spin-button, &::-webkit-outer-spin-button":{WebkitAppearance:"none",margin:t.spacing.none}}})),Dt=k("div",{target:"eaeic2i1"})({display:"flex",flexDirection:"row",alignSelf:"stretch"}),K=k("button",{target:"eaeic2i2"})(({theme:t})=>({margin:t.spacing.none,border:"none",height:t.sizes.full,display:"flex",alignItems:"center",width:t.sizes.numberInputControlsWidth,justifyContent:"center",color:t.colors.bodyText,transition:"color 300ms, backgroundColor 300ms",backgroundColor:t.colors.secondaryBg,"&:hover:enabled, &:focus:enabled":{color:t.colors.white,backgroundColor:t.colors.primary,transition:"none",outline:"none"},"&:active":{outline:"none",border:"none"},"&:disabled":{cursor:"not-allowed",color:t.colors.fadedText40}})),Vt=k("div",{target:"eaeic2i3"})(({theme:t,clearable:e})=>({position:"absolute",marginRight:t.spacing.twoXS,left:0,right:`calc(${t.sizes.numberInputControlsWidth} * 2 + ${e?"1em":"0em"})`})),kt=dt.getLogger("NumberInput");function Nt(t){return h(t)||t===""?void 0:t}const tt=t=>{const e=t.toString();if(e.includes("e-")){const o=e.match(/(\d+(?:\.\d+)?)e-(\d+)/);if(o){const i=(o[1]?.split(".")[1]||"").length,n=parseInt(o[2],10);return i+n}return 0}return(e.split(".")[1]||"").length},_=({value:t,format:e,step:o,dataType:i})=>{if(h(t))return null;let n=Nt(e);if(h(n)&&J(o)&&i===C.DataType.FLOAT&&o!==0){const l=tt(o);l>0&&(n=`%0.${l}f`)}if(h(n))return t.toString();try{return St(n,t)}catch(l){return kt.warn(`Error in sprintf(${n}, ${t}): ${l}`),String(t)}},Et=(t,e,o)=>h(t)?!1:t-e>=o,Rt=(t,e,o)=>h(t)?!1:t+e<=o,X=(t,e,o)=>{const i=tt(e);if(i===0)switch(o){case"add":return t+e;case"subtract":return t-e}const n=Math.pow(10,i),l=Math.round(t*n),p=Math.round(e*n);switch(o){case"add":return(l+p)/n;case"subtract":return(l-p)/n}},Ft=({step:t,dataType:e})=>t||(e===C.DataType.INT?1:.01);function q(t,e){return e.dataType===C.DataType.INT?t.getIntValue(e):t.getDoubleValue(e)}function Wt(t){return t.default??null}function zt(t){return t.value??t.default??null}function Bt(t,e,o,i){switch(t.dataType){case C.DataType.INT:e.setIntValue(t,o.value,{fromUi:o.fromUi},i);break;case C.DataType.FLOAT:e.setDoubleValue(t,o.value,{fromUi:o.fromUi},i);break;default:throw new Error("Invalid data type")}}const Lt=({disabled:t,element:e,widgetMgr:o,fragmentId:i})=>{const n=pt(),{dataType:l,formId:p,default:T,format:N,icon:E,min:g,max:y}=e,{width:L,elementRef:et}=ft(),c=a.useMemo(()=>Ft({step:e.step,dataType:e.dataType}),[e.step,e.dataType]),I=a.useCallback(r=>_({value:r,dataType:l,format:N,step:c}),[l,N,c]),[f,w]=a.useState(!1),[b,S]=a.useState(()=>{const r=q(o,e)??T??null;return _({value:r,dataType:l,format:N,step:c})}),[P,U]=Tt({getStateFromWidgetMgr:q,getDefaultStateFromProto:Wt,getCurrStateFromProto:zt,updateWidgetMgrState:Bt,element:e,widgetMgr:o,fragmentId:i,onFormCleared:a.useCallback(()=>{const r=T??null;w(!1),S(I(r))},[T,I])}),[A,H]=a.useState(!1),R=a.useRef(null),[$]=a.useState(()=>wt("number_input_")),M=mt({formId:p}),nt=M?o.allowFormEnterToSubmit(p):f,ot=A&&L>V(n.breakpoints.hideWidgetDetails);a.useEffect(()=>{f||S(I(P))},[P,f,I]);const m=a.useCallback(({value:r,fromUi:s})=>{if(J(r)&&(g>r||r>y)){R.current?.reportValidity();return}const D=r??T??null;U({value:D,fromUi:s}),w(!1),S(I(D))},[g,y,T,I,U]),rt=a.useCallback(()=>{H(!0)},[]);a.useEffect(()=>{const r=R.current;if(r){const s=D=>{D.preventDefault()};return r.addEventListener("wheel",s),()=>{r.removeEventListener("wheel",s)}}},[]);const F=h(e.default)&&!t,at=a.useCallback(r=>{const{value:s}=r.target;s===""?(w(!0),S(null)):(w(!0),S(s))},[]),u=a.useMemo(()=>{if(b===null||b==="")return null;if(e.dataType===C.DataType.INT){const s=parseInt(b,10);return isNaN(s)?null:s}const r=parseFloat(b);return isNaN(r)?null:r},[b,e.dataType]),v=Et(u,c,g),x=Rt(u,c,y),it=a.useCallback(()=>{f&&m({value:u,fromUi:!0}),H(!1)},[f,u,m]),W=a.useCallback(()=>{if(x){const r=X(u??g,c,"add");m({value:r,fromUi:!0})}},[u,g,c,x,m]),z=a.useCallback(()=>{if(v){const r=X(u??y,c,"subtract");m({value:r,fromUi:!0})}},[u,y,c,v,m]),st=a.useCallback(r=>{const{key:s}=r;switch(s){case"ArrowUp":r.preventDefault(),W();break;case"ArrowDown":r.preventDefault(),z();break}},[W,z]),lt=a.useCallback(r=>{r.key==="Enter"&&(f&&m({value:u,fromUi:!0}),o.allowFormEnterToSubmit(p)&&o.submitForm(p,i))},[f,u,m,o,p,i]),ct=V(n.iconSizes.lg)+2*V(n.spacing.twoXS),O=V(n.breakpoints.hideNumberInputControls),ut=E?O+ct:O;return B("div",{className:"stNumberInput","data-testid":"stNumberInput",ref:et,children:[d(gt,{label:e.label,disabled:t,labelVisibility:bt(e.labelVisibility?.value),htmlFor:$,children:e.help&&d(ht,{content:e.help,label:e.label})}),B(xt,{className:A?"focused":"","data-testid":"stNumberInputContainer",children:[d(vt,{type:"number",inputRef:R,value:b??"",placeholder:e.placeholder,onBlur:it,onFocus:rt,onChange:at,onKeyPress:lt,onKeyDown:st,clearable:F,clearOnEscape:F,disabled:t,"aria-label":e.label,startEnhancer:e.icon&&d(It,{"data-testid":"stNumberInputIcon",iconValue:e.icon,size:"lg"}),id:$,overrides:{ClearIconContainer:{style:{padding:0}},ClearIcon:{props:{overrides:{Svg:{style:{color:n.colors.grayTextColor,padding:n.spacing.threeXS,height:n.sizes.clearIconSize,width:n.sizes.clearIconSize,":hover":{fill:n.colors.bodyText}}}}}},Input:{props:{"data-testid":"stNumberInputField",step:c,min:g,max:y,type:"number",inputMode:""},style:{fontWeight:n.fontWeights.normal,lineHeight:n.lineHeights.inputWidget,paddingRight:n.spacing.sm,paddingLeft:n.spacing.md,paddingBottom:n.spacing.sm,paddingTop:n.spacing.sm,"::placeholder":{color:n.colors.fadedText60}}},InputContainer:{style:()=>({borderTopRightRadius:0,borderBottomRightRadius:0})},Root:{style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:0,borderRightWidth:0,borderTopWidth:0,borderBottomWidth:0,paddingRight:0,paddingLeft:E?n.spacing.sm:0}},StartEnhancer:{style:{paddingLeft:0,paddingRight:0,minWidth:n.iconSizes.lg,color:yt(E)?n.colors.fadedText60:"inherit"}}}}),L>ut&&B(Dt,{children:[d(K,{"data-testid":"stNumberInputStepDown",onClick:z,disabled:!v||t,tabIndex:-1,children:d(j,{content:Q,size:"xs",color:v?"inherit":n.colors.fadedText40})}),d(K,{"data-testid":"stNumberInputStepUp",onClick:W,disabled:!x||t,tabIndex:-1,children:d(j,{content:Z,size:"xs",color:x?"inherit":n.colors.fadedText40})})]})]}),ot&&d(Vt,{clearable:F,children:d(Ct,{dirty:f,value:b??"",inForm:M,allowEnterToSubmit:nt})})]})},Kt=a.memo(Lt);export{Kt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,E as H,_ as D,z as k,o as O,j as U,ay as ge,P as he,b as ve,B as me,ax as q,bN as re,al as Se,ag as be,bg as ye,l as Ce,bO as Ue,k as we,aj as Me,e as W,V as xe,bh as Ee,p as Ie,ab as Fe,ac as Re,$ as ke,bP as _e,bQ as Oe}from"./index.aCorc3Yt.js";import{U as ie}from"./UploadFileInfo.Dr-zDST7.js";import{u as Pe}from"./FormClearHelper.DN8D_YXO.js";import{P as Te,S as Le}from"./ProgressBar.C5uBOtcx.js";import{b as We}from"./urls.BwSlolu9.js";var oe=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:a}),n.createElement("rect",{width:24,height:24,fill:"none"}),n.createElement("path",{d:"M20 5h-3.17l-1.24-1.35A1.99 1.99 0 0014.12 3H9.88c-.56 0-1.1.24-1.48.65L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-1.35 8.35l-2.79 2.79c-.32.32-.86.1-.86-.35v-1.75H9v1.75c0 .45-.54.67-.85.35l-2.79-2.79c-.2-.2-.2-.51 0-.71l2.79-2.79a.5.5 0 01.85.36v1.83h6v-1.83c0-.45.54-.67.85-.35l2.79 2.79c.2.19.2.51.01.7z"}))});oe.displayName="SwitchCamera";var ne=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},e,{ref:a}),n.createElement("path",{d:"M.5 1c-.28 0-.5.23-.5.5v4c0 .28.23.5.5.5h5c.28 0 .5-.22.5-.5V4l1 1h1V2H7L6 3V1.5c0-.28-.22-.5-.5-.5h-5z"}))});ne.displayName="Video";var ae=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},e,{ref:a}),n.createElement("path",{d:"M1.41 0L0 1.41l.72.72L2.5 3.94.72 5.72 0 6.41l1.41 1.44.72-.72 1.81-1.81 1.78 1.81.69.72 1.44-1.44-.72-.69-1.81-1.78 1.81-1.81.72-.72L6.41 0l-.69.72L3.94 2.5 2.13.72 1.41 0z"}))});ae.displayName="X";function Ve(e,a){switch(e){case"xsmall":return{padding:`${a.spacing.twoXS} ${a.spacing.sm}`,fontSize:a.fontSizes.sm};case"small":return{padding:`${a.spacing.twoXS} ${a.spacing.md}`};case"large":return{padding:`${a.spacing.md} ${a.spacing.md}`};default:return{padding:`${a.spacing.xs} ${a.spacing.md}`}}}const se=k("div",{target:"exxgkyt0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),G=k("div",{target:"exxgkyt1"})(({theme:e,width:a})=>({backgroundColor:e.colors.secondaryBg,borderRadius:`${e.radii.default} ${e.radii.default} 0 0`,width:"100%",height:a*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),je=k("p",{target:"exxgkyt2"})(({theme:e})=>({marginTop:e.spacing.sm,textAlign:"center"})),Be=k("img",{target:"exxgkyt3"})(({theme:e,opacity:a})=>({borderRadius:`${e.radii.default} ${e.radii.default} 0 0`,objectFit:"contain",opacity:a})),$e=k("a",{target:"exxgkyt4"})(({theme:e})=>({color:e.colors.link,textDecoration:e.linkUnderline?"underline":"none",display:"block"})),ze=k("span",{target:"exxgkyt5"})({display:"flex",alignItems:"center"}),Ae=k("div",{target:"exxgkyt6"})(({theme:e})=>({position:"absolute",top:e.spacing.lg,right:e.spacing.lg,zIndex:e.zIndices.priority,color:e.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ne=k("div",{target:"exxgkyt8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),He=k("button",{target:"exxgkyt9"})(({theme:e})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:e.colors.lightenedBg05,border:`${e.sizes.borderWidth} solid ${e.colors.borderColor}`,borderRadius:`0 0 ${e.radii.default} ${e.radii.default}`,"&:hover":{borderColor:e.colors.primary,color:e.colors.primary},"&:active":{color:e.colors.white,borderColor:e.colors.primary,backgroundColor:e.colors.primary},"&:focus:not(:active)":{borderColor:e.colors.primary,color:e.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:e.colors.fadedText40,borderColor:e.colors.borderColor,backgroundColor:e.colors.lightenedBg05,cursor:"not-allowed"},fontWeight:e.fontWeights.normal,padding:`${e.spacing.xs} ${e.spacing.md}`,margin:e.spacing.none,lineHeight:e.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:e.shadows.focusRing},...Ve("medium",e)}));function De({disabled:e,onClick:a,children:d,progress:h}){return O(He,{disabled:e||!1,onClick:a||(()=>{}),progress:h||null,"data-testid":"stCameraInputButton",children:[d,h?U(Ne,{children:U(Te,{value:h,size:Le.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})}):null]})}const le=n.memo(De);var B=(function(e){return e.USER="user",e.ENVIRONMENT="environment",e})({});const qe=({switchFacingMode:e})=>U(Ae,{"data-testid":"stCameraInputSwitchButton",children:U(ge,{content:"Switch camera",placement:he.TOP_RIGHT,children:U(ve,{kind:me.MINIMAL,onClick:e,children:U(q,{content:oe,size:"twoXL",color:re.white})})})}),Ge=n.memo(qe);var $={exports:{}},Xe=$.exports,te;function Qe(){return te||(te=1,(function(e,a){(function(h,v){e.exports=v(Se())})(Xe,function(d){return(function(h){var v={};function p(o){if(v[o])return v[o].exports;var f=v[o]={i:o,l:!1,exports:{}};return h[o].call(f.exports,f,f.exports,p),f.l=!0,f.exports}return p.m=h,p.c=v,p.d=function(o,f,m){p.o(o,f)||Object.defineProperty(o,f,{enumerable:!0,get:m})},p.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},p.t=function(o,f){if(f&1&&(o=p(o)),f&8||f&4&&typeof o=="object"&&o&&o.__esModule)return o;var m=Object.create(null);if(p.r(m),Object.defineProperty(m,"default",{enumerable:!0,value:o}),f&2&&typeof o!="string")for(var F in o)p.d(m,F,(function(I){return o[I]}).bind(null,F));return m},p.n=function(o){var f=o&&o.__esModule?function(){return o.default}:function(){return o};return p.d(f,"a",f),f},p.o=function(o,f){return Object.prototype.hasOwnProperty.call(o,f)},p.p="",p(p.s="./src/react-webcam.tsx")})({"./src/react-webcam.tsx":(function(h,v,p){p.r(v);var o=p("react"),f=(function(){var b=function(i,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var l in s)s.hasOwnProperty(l)&&(r[l]=s[l])},b(i,t)};return function(i,t){b(i,t);function r(){this.constructor=i}i.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})(),m=function(){return m=Object.assign||function(b){for(var i,t=1,r=arguments.length;t<r;t++){i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(b[s]=i[s])}return b},m.apply(this,arguments)},F=function(b,i){var t={};for(var r in b)Object.prototype.hasOwnProperty.call(b,r)&&i.indexOf(r)<0&&(t[r]=b[r]);if(b!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(b);s<r.length;s++)i.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(b,r[s])&&(t[r[s]]=b[r[s]]);return t};(function(){typeof window>"u"||(navigator.mediaDevices===void 0&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===void 0&&(navigator.mediaDevices.getUserMedia=function(i){var t=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return t?new Promise(function(r,s){t.call(navigator,i,r,s)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function I(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var R=(function(b){f(i,b);function i(t){var r=b.call(this,t)||this;return r.canvas=null,r.ctx=null,r.requestUserMediaId=0,r.unmounted=!1,r.state={hasUserMedia:!1},r}return i.prototype.componentDidMount=function(){var t=this,r=t.state,s=t.props;if(this.unmounted=!1,!I()){s.onUserMediaError("getUserMedia not supported");return}r.hasUserMedia||this.requestUserMedia(),s.children&&typeof s.children!="function"&&console.warn("children must be a function")},i.prototype.componentDidUpdate=function(t){var r=this.props;if(!I()){r.onUserMediaError("getUserMedia not supported");return}var s=JSON.stringify(t.audioConstraints)!==JSON.stringify(r.audioConstraints),l=JSON.stringify(t.videoConstraints)!==JSON.stringify(r.videoConstraints),M=t.minScreenshotWidth!==r.minScreenshotWidth,y=t.minScreenshotHeight!==r.minScreenshotHeight;(l||M||y)&&(this.canvas=null,this.ctx=null),(s||l)&&(this.stopAndCleanup(),this.requestUserMedia())},i.prototype.componentWillUnmount=function(){this.unmounted=!0,this.stopAndCleanup()},i.stopMediaStream=function(t){t&&(t.getVideoTracks&&t.getAudioTracks?(t.getVideoTracks().map(function(r){t.removeTrack(r),r.stop()}),t.getAudioTracks().map(function(r){t.removeTrack(r),r.stop()})):t.stop())},i.prototype.stopAndCleanup=function(){var t=this.state;t.hasUserMedia&&(i.stopMediaStream(this.stream),t.src&&window.URL.revokeObjectURL(t.src))},i.prototype.getScreenshot=function(t){var r=this,s=r.state,l=r.props;if(!s.hasUserMedia)return null;var M=this.getCanvas(t);return M&&M.toDataURL(l.screenshotFormat,l.screenshotQuality)},i.prototype.getCanvas=function(t){var r=this,s=r.state,l=r.props;if(!this.video||!s.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var M=this.video.videoWidth,y=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var C=M/y;M=l.minScreenshotWidth||this.video.clientWidth,y=M/C,l.minScreenshotHeight&&y<l.minScreenshotHeight&&(y=l.minScreenshotHeight,M=y*C)}this.canvas=document.createElement("canvas"),this.canvas.width=t?.width||M,this.canvas.height=t?.height||y,this.ctx=this.canvas.getContext("2d")}var E=this,w=E.ctx,S=E.canvas;return w&&S&&(S.width=t?.width||S.width,S.height=t?.height||S.height,l.mirrored&&(w.translate(S.width,0),w.scale(-1,1)),w.imageSmoothingEnabled=l.imageSmoothing,w.drawImage(this.video,0,0,t?.width||S.width,t?.height||S.height),l.mirrored&&(w.scale(-1,1),w.translate(-S.width,0))),S},i.prototype.requestUserMedia=function(){var t=this,r=this.props,s=function(y,C){var E={video:typeof C<"u"?C:!0};r.audio&&(E.audio=typeof y<"u"?y:!0),t.requestUserMediaId++;var w=t.requestUserMediaId;navigator.mediaDevices.getUserMedia(E).then(function(S){t.unmounted||w!==t.requestUserMediaId?i.stopMediaStream(S):t.handleUserMedia(null,S)}).catch(function(S){t.handleUserMedia(S)})};if("mediaDevices"in navigator)s(r.audioConstraints,r.videoConstraints);else{var l=function(y){return{optional:[{sourceId:y}]}},M=function(y){var C=y.deviceId;return typeof C=="string"?C:Array.isArray(C)&&C.length>0?C[0]:typeof C=="object"&&C.ideal?C.ideal:null};MediaStreamTrack.getSources(function(y){var C=null,E=null;y.forEach(function(_){_.kind==="audio"?C=_.id:_.kind==="video"&&(E=_.id)});var w=M(r.audioConstraints);w&&(C=w);var S=M(r.videoConstraints);S&&(E=S),s(l(C),l(E))})}},i.prototype.handleUserMedia=function(t,r){var s=this.props;if(t||!r){this.setState({hasUserMedia:!1}),s.onUserMediaError(t);return}this.stream=r;try{this.video&&(this.video.srcObject=r),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(r)})}s.onUserMedia(r)},i.prototype.render=function(){var t=this,r=this,s=r.state,l=r.props,M=l.audio;l.forceScreenshotSourceSize;var y=l.disablePictureInPicture;l.onUserMedia,l.onUserMediaError,l.screenshotFormat,l.screenshotQuality,l.minScreenshotWidth,l.minScreenshotHeight,l.audioConstraints,l.videoConstraints,l.imageSmoothing;var C=l.mirrored,E=l.style,w=E===void 0?{}:E,S=l.children,_=F(l,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),z=C?m(m({},w),{transform:(w.transform||"")+" scaleX(-1)"}):w,V={getScreenshot:this.getScreenshot.bind(this)};return o.createElement(o.Fragment,null,o.createElement("video",m({autoPlay:!0,disablePictureInPicture:y,src:s.src,muted:!M,playsInline:!0,ref:function(j){t.video=j},style:z},_)),S&&S(V))},i.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},i})(o.Component);v.default=R}),react:(function(h,v){h.exports=d})}).default})})($)),$.exports}var Je=Qe();const Ke=be(Je),Ye=({width:e})=>O(G,{width:e,children:[U(q,{size:"threeXL",color:re.gray60,content:ne}),O(je,{children:["This app would like to use your camera.",U($e,{href:We,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),Ze=({handleCapture:e,width:a,disabled:d,clearPhotoInProgress:h,setClearPhotoInProgress:v,facingMode:p,setFacingMode:o,testOverride:f})=>{const[m,F]=n.useState(f||"pending"),I=n.useRef(null),[R,b]=n.useState(a),i=n.useCallback(ye(1e3,b),[]);n.useEffect(()=>{i(a)},[a,i]);function t(){if(I.current!==null){const s=I.current.getScreenshot();e(s)}}const r=Ce();return O(se,{"data-testid":"stCameraInputWebcamComponent",children:[m!=="success"&&!d&&!h?U(Ye,{width:R}):Ue()&&U(Ge,{switchFacingMode:o}),U(G,{"data-testid":"stCameraInputWebcamStyledBox",hidden:m!=="success"&&!d&&!h,width:R,children:!d&&U(Ke,{audio:!1,ref:I,screenshotFormat:"image/jpeg",screenshotQuality:1,width:R,height:R*9/16,style:{borderRadius:`${r.radii.default} ${r.radii.default} 0 0`},onUserMediaError:()=>{F("error")},onUserMedia:()=>{F("success"),v(!1)},videoConstraints:{width:{ideal:R},facingMode:p}})}),U(le,{onClick:t,disabled:m!=="success"||d||h,children:"Take Photo"})]})},et=n.memo(Ze),ce="RESTORED_FROM_WIDGET",tt=150,rt=xe.getLogger("CameraInput"),N=e=>{const a=e.filter(d=>d.status.type==="uploaded").map(d=>{const{name:h,size:v,status:p}=d,{fileId:o,fileUrls:f}=p;return new _e({fileId:o,fileUrls:f,name:h,size:v})});return new Oe({uploadedFileInfo:a})},it=(e,a)=>{const d=a.getFileUploaderStateValue(e);if(W(d))return{files:[],nextLocalId:1,imgSrc:null};const{uploadedFileInfo:h}=d;if(W(h)||h.length===0)return{files:[],nextLocalId:1,imgSrc:null};let v=1;const p=h.map(o=>{const f=o.name,m=o.size,F=o.fileId,I=o.fileUrls,R=new ie(f,m,v,{type:"uploaded",fileId:F,fileUrls:I});return v+=1,R});return{files:p,nextLocalId:v,imgSrc:p.length>0?ce:null}};function ot(e,a){return fetch(e).then(d=>d.arrayBuffer()).then(d=>new File([d],a,{type:"image/jpeg"}))}const nt=({element:e,widgetMgr:a,uploadClient:d,disabled:h,fragmentId:v,testOverride:p})=>{const{width:o,elementRef:f}=we(),m=n.useRef(null);m.current===null&&(m.current=it(e,a));const{files:F,nextLocalId:I,imgSrc:R}=m.current,b=n.useRef(I),[i,t]=n.useState(()=>F),r=n.useRef(i);n.useLayoutEffect(()=>{r.current=i},[i]);const[s,l]=n.useState(()=>R),[M,y]=n.useState(!1),[C,E]=n.useState(!0),[w,S]=n.useState(!1),[_,z]=n.useState(B.USER),V=n.useCallback(()=>{const c=b.current;return b.current+=1,c},[]),j=n.useMemo(()=>{const c=u=>u.status.type==="uploading";return i.some(c)?"updating":"ready"},[i]),A=n.useMemo(()=>{if(i.length>0&&i[i.length-1].status.type==="uploading")return i[i.length-1].status.progress},[i]),de=n.useCallback(()=>{z(c=>c===B.USER?B.ENVIRONMENT:B.USER)},[]),P=n.useCallback(c=>r.current.find(u=>u.id===c),[]),X=n.useCallback(c=>{Me.flushSync(()=>{t(u=>[...u,c])})},[]),Q=n.useCallback(c=>{t(u=>u.filter(g=>g.id!==c))},[]),T=n.useCallback((c,u)=>{t(g=>g.map(x=>x.id===c?u:x))},[]),J=n.useCallback((c,u)=>{y(!1);const g=P(c);W(g)||g.status.type!=="uploading"||T(g.id,g.setStatus({type:"uploaded",fileId:u.fileId,fileUrls:u}))},[P,T]),K=n.useCallback((c,u)=>{const g=P(u);if(W(g)||g.status.type!=="uploading")return;const x=Math.round(c.loaded*100/c.total);g.status.progress!==x&&T(u,g.setStatus({type:"uploading",abortController:g.status.abortController,progress:x}))},[P,T]),Y=n.useCallback((c,u)=>{const g=new AbortController,x=new ie(u.name,u.size,V(),{type:"uploading",abortController:g,progress:1});X(x),d.uploadFile(e,c.uploadUrl,u,L=>K(L,x.id),g.signal).then(()=>J(x.id,c)).catch(L=>{L instanceof DOMException&&L.name==="AbortError"||T(x.id,x.setStatus({type:"error",errorMessage:L?L.toString():"Unknown error"}))})},[X,e,V,J,K,T,d]),Z=n.useCallback(c=>{const u=P(c);W(u)||(u.status.type==="uploading"&&u.status.abortController.abort(),u.status.type==="uploaded"&&u.status.fileUrls.deleteUrl&&d.deleteFile(u.status.fileUrls.deleteUrl),Q(c))},[P,Q,d]),ee=n.useCallback(c=>{if(c===null)return Promise.resolve();l(c),y(!0),E(!1);const u=g=>new Promise(x=>setTimeout(x,g));return ot(c,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(g=>d.fetchFileURLs([g]).then(x=>({file:g,fileUrls:x[0]}))).then(({file:g,fileUrls:x})=>Y(x,g)).then(()=>u(tt)).then(()=>{E(!0)}).catch(g=>{rt.error(g)})},[d,Y]),ue=n.useCallback(c=>{ee(c)},[ee]),fe=n.useCallback(()=>{i.length!==0&&(i.forEach(c=>Z(c.id)),l(null),S(!0))},[i,Z]);n.useEffect(()=>{a.getFileUploaderStateValue(e)===void 0&&a.setFileUploaderStateValue(e,N(i),{fromUi:!1},v)},[]),n.useEffect(()=>{if(j!=="ready")return;const c=N(i),u=a.getFileUploaderStateValue(e);Ee(c,u)||a.setFileUploaderStateValue(e,c,{fromUi:!0},v)},[j,i,a,e,v]);const pe=n.useCallback(()=>{t([]),l(null);const c=N([]);a.setFileUploaderStateValue(e,c,{fromUi:!0},v)},[e,v,a]);return Pe({element:e,widgetMgr:a,onFormCleared:pe}),O(se,{className:"stCameraInput","data-testid":"stCameraInput",ref:f,children:[U(Re,{label:e.label,disabled:h,labelVisibility:Ie(e.labelVisibility?.value),children:e.help&&U(Fe,{content:e.help,label:e.label})}),s?O(ke,{children:[U(G,{width:o,children:s!==ce&&U(Be,{src:s,alt:"Snapshot",opacity:M||!C?"50%":"100%",width:o,height:o*9/16})}),U(le,{onClick:fe,progress:A,disabled:!!A||h,children:A?"Uploading...":O(ze,{children:[U(q,{content:ae,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):U(et,{handleCapture:ue,width:o,disabled:h,clearPhotoInProgress:w,setClearPhotoInProgress:S,facingMode:_,setFacingMode:de,testOverride:p})]})},ut=n.memo(nt);export{ut as default};
|
|
1
|
+
import{r as n,E as H,_ as D,z as k,o as O,j as U,aA as ge,P as he,b as ve,B as me,az as q,bQ as re,an as Se,ai as be,bu as ye,l as Ce,bR as Ue,k as we,al as Me,e as W,V as xe,bv as Ee,p as Ie,ad as Fe,ae as Re,$ as ke,bS as _e,bT as Oe}from"./index.y5HxPwg9.js";import{U as ie}from"./UploadFileInfo.Dr-zDST7.js";import{u as Pe}from"./FormClearHelper.zxJ53Nym.js";import{P as Te,S as Le}from"./ProgressBar.BrrHeAEh.js";import{b as We}from"./urls.BwSlolu9.js";var oe=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:a}),n.createElement("rect",{width:24,height:24,fill:"none"}),n.createElement("path",{d:"M20 5h-3.17l-1.24-1.35A1.99 1.99 0 0014.12 3H9.88c-.56 0-1.1.24-1.48.65L7.17 5H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-1.35 8.35l-2.79 2.79c-.32.32-.86.1-.86-.35v-1.75H9v1.75c0 .45-.54.67-.85.35l-2.79-2.79c-.2-.2-.2-.51 0-.71l2.79-2.79a.5.5 0 01.85.36v1.83h6v-1.83c0-.45.54-.67.85-.35l2.79 2.79c.2.19.2.51.01.7z"}))});oe.displayName="SwitchCamera";var ne=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},e,{ref:a}),n.createElement("path",{d:"M.5 1c-.28 0-.5.23-.5.5v4c0 .28.23.5.5.5h5c.28 0 .5-.22.5-.5V4l1 1h1V2H7L6 3V1.5c0-.28-.22-.5-.5-.5h-5z"}))});ne.displayName="Video";var ae=n.forwardRef(function(e,a){var d={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return n.createElement(H,D({iconAttrs:d,iconVerticalAlign:"middle",iconViewBox:"0 0 8 8"},e,{ref:a}),n.createElement("path",{d:"M1.41 0L0 1.41l.72.72L2.5 3.94.72 5.72 0 6.41l1.41 1.44.72-.72 1.81-1.81 1.78 1.81.69.72 1.44-1.44-.72-.69-1.81-1.78 1.81-1.81.72-.72L6.41 0l-.69.72L3.94 2.5 2.13.72 1.41 0z"}))});ae.displayName="X";function Ve(e,a){switch(e){case"xsmall":return{padding:`${a.spacing.twoXS} ${a.spacing.sm}`,fontSize:a.fontSizes.sm};case"small":return{padding:`${a.spacing.twoXS} ${a.spacing.md}`};case"large":return{padding:`${a.spacing.md} ${a.spacing.md}`};default:return{padding:`${a.spacing.xs} ${a.spacing.md}`}}}const se=k("div",{target:"exxgkyt0"})({position:"relative",overflow:"hidden",width:"100%",objectFit:"contain"}),G=k("div",{target:"exxgkyt1"})(({theme:e,width:a})=>({backgroundColor:e.colors.secondaryBg,borderRadius:`${e.radii.default} ${e.radii.default} 0 0`,width:"100%",height:a*9/16,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"})),je=k("p",{target:"exxgkyt2"})(({theme:e})=>({marginTop:e.spacing.sm,textAlign:"center"})),Be=k("img",{target:"exxgkyt3"})(({theme:e,opacity:a})=>({borderRadius:`${e.radii.default} ${e.radii.default} 0 0`,objectFit:"contain",opacity:a})),ze=k("a",{target:"exxgkyt4"})(({theme:e})=>({color:e.colors.link,textDecoration:e.linkUnderline?"underline":"none",display:"block"})),Ae=k("span",{target:"exxgkyt5"})({display:"flex",alignItems:"center"}),$e=k("div",{target:"exxgkyt6"})(({theme:e})=>({position:"absolute",top:e.spacing.lg,right:e.spacing.lg,zIndex:e.zIndices.priority,color:e.colors.fadedText40,mixBlendMode:"difference",opacity:.6})),Ne=k("div",{target:"exxgkyt8"})({height:"fit-content",width:"100%",position:"absolute",bottom:0}),He=k("button",{target:"exxgkyt9"})(({theme:e})=>({position:"relative",display:"inline-flex",flexDirection:"column",alignItems:"center",justifyContent:"center",backgroundColor:e.colors.lightenedBg05,border:`${e.sizes.borderWidth} solid ${e.colors.borderColor}`,borderRadius:`0 0 ${e.radii.default} ${e.radii.default}`,"&:hover":{borderColor:e.colors.primary,color:e.colors.primary},"&:active":{color:e.colors.white,borderColor:e.colors.primary,backgroundColor:e.colors.primary},"&:focus:not(:active)":{borderColor:e.colors.primary,color:e.colors.primary},"&:disabled, &:disabled:hover, &:disabled:active":{color:e.colors.fadedText40,borderColor:e.colors.borderColor,backgroundColor:e.colors.lightenedBg05,cursor:"not-allowed"},fontWeight:e.fontWeights.normal,padding:`${e.spacing.xs} ${e.spacing.md}`,margin:e.spacing.none,lineHeight:e.lineHeights.base,color:"inherit",width:"100%",userSelect:"none","&:focus":{outline:"none"},"&:focus-visible":{boxShadow:e.shadows.focusRing},...Ve("medium",e)}));function De({disabled:e,onClick:a,children:d,progress:h}){return O(He,{disabled:e||!1,onClick:a||(()=>{}),progress:h||null,"data-testid":"stCameraInputButton",children:[d,h?U(Ne,{children:U(Te,{value:h,size:Le.EXTRASMALL,overrides:{Bar:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarProgress:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}},BarContainer:{style:{borderTopLeftRadius:0,borderTopRightRadius:0}}}})}):null]})}const le=n.memo(De);var B=(function(e){return e.USER="user",e.ENVIRONMENT="environment",e})({});const qe=({switchFacingMode:e})=>U($e,{"data-testid":"stCameraInputSwitchButton",children:U(ge,{content:"Switch camera",placement:he.TOP_RIGHT,children:U(ve,{kind:me.MINIMAL,onClick:e,children:U(q,{content:oe,size:"twoXL",color:re.white})})})}),Ge=n.memo(qe);var z={exports:{}},Xe=z.exports,te;function Qe(){return te||(te=1,(function(e,a){(function(h,v){e.exports=v(Se())})(Xe,function(d){return(function(h){var v={};function p(o){if(v[o])return v[o].exports;var f=v[o]={i:o,l:!1,exports:{}};return h[o].call(f.exports,f,f.exports,p),f.l=!0,f.exports}return p.m=h,p.c=v,p.d=function(o,f,m){p.o(o,f)||Object.defineProperty(o,f,{enumerable:!0,get:m})},p.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},p.t=function(o,f){if(f&1&&(o=p(o)),f&8||f&4&&typeof o=="object"&&o&&o.__esModule)return o;var m=Object.create(null);if(p.r(m),Object.defineProperty(m,"default",{enumerable:!0,value:o}),f&2&&typeof o!="string")for(var F in o)p.d(m,F,(function(I){return o[I]}).bind(null,F));return m},p.n=function(o){var f=o&&o.__esModule?function(){return o.default}:function(){return o};return p.d(f,"a",f),f},p.o=function(o,f){return Object.prototype.hasOwnProperty.call(o,f)},p.p="",p(p.s="./src/react-webcam.tsx")})({"./src/react-webcam.tsx":(function(h,v,p){p.r(v);var o=p("react"),f=(function(){var b=function(i,t){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var l in s)s.hasOwnProperty(l)&&(r[l]=s[l])},b(i,t)};return function(i,t){b(i,t);function r(){this.constructor=i}i.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})(),m=function(){return m=Object.assign||function(b){for(var i,t=1,r=arguments.length;t<r;t++){i=arguments[t];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(b[s]=i[s])}return b},m.apply(this,arguments)},F=function(b,i){var t={};for(var r in b)Object.prototype.hasOwnProperty.call(b,r)&&i.indexOf(r)<0&&(t[r]=b[r]);if(b!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(b);s<r.length;s++)i.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(b,r[s])&&(t[r[s]]=b[r[s]]);return t};(function(){typeof window>"u"||(navigator.mediaDevices===void 0&&(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia===void 0&&(navigator.mediaDevices.getUserMedia=function(i){var t=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return t?new Promise(function(r,s){t.call(navigator,i,r,s)}):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}))})();function I(){return!!(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)}var R=(function(b){f(i,b);function i(t){var r=b.call(this,t)||this;return r.canvas=null,r.ctx=null,r.requestUserMediaId=0,r.unmounted=!1,r.state={hasUserMedia:!1},r}return i.prototype.componentDidMount=function(){var t=this,r=t.state,s=t.props;if(this.unmounted=!1,!I()){s.onUserMediaError("getUserMedia not supported");return}r.hasUserMedia||this.requestUserMedia(),s.children&&typeof s.children!="function"&&console.warn("children must be a function")},i.prototype.componentDidUpdate=function(t){var r=this.props;if(!I()){r.onUserMediaError("getUserMedia not supported");return}var s=JSON.stringify(t.audioConstraints)!==JSON.stringify(r.audioConstraints),l=JSON.stringify(t.videoConstraints)!==JSON.stringify(r.videoConstraints),M=t.minScreenshotWidth!==r.minScreenshotWidth,y=t.minScreenshotHeight!==r.minScreenshotHeight;(l||M||y)&&(this.canvas=null,this.ctx=null),(s||l)&&(this.stopAndCleanup(),this.requestUserMedia())},i.prototype.componentWillUnmount=function(){this.unmounted=!0,this.stopAndCleanup()},i.stopMediaStream=function(t){t&&(t.getVideoTracks&&t.getAudioTracks?(t.getVideoTracks().map(function(r){t.removeTrack(r),r.stop()}),t.getAudioTracks().map(function(r){t.removeTrack(r),r.stop()})):t.stop())},i.prototype.stopAndCleanup=function(){var t=this.state;t.hasUserMedia&&(i.stopMediaStream(this.stream),t.src&&window.URL.revokeObjectURL(t.src))},i.prototype.getScreenshot=function(t){var r=this,s=r.state,l=r.props;if(!s.hasUserMedia)return null;var M=this.getCanvas(t);return M&&M.toDataURL(l.screenshotFormat,l.screenshotQuality)},i.prototype.getCanvas=function(t){var r=this,s=r.state,l=r.props;if(!this.video||!s.hasUserMedia||!this.video.videoHeight)return null;if(!this.ctx){var M=this.video.videoWidth,y=this.video.videoHeight;if(!this.props.forceScreenshotSourceSize){var C=M/y;M=l.minScreenshotWidth||this.video.clientWidth,y=M/C,l.minScreenshotHeight&&y<l.minScreenshotHeight&&(y=l.minScreenshotHeight,M=y*C)}this.canvas=document.createElement("canvas"),this.canvas.width=t?.width||M,this.canvas.height=t?.height||y,this.ctx=this.canvas.getContext("2d")}var E=this,w=E.ctx,S=E.canvas;return w&&S&&(S.width=t?.width||S.width,S.height=t?.height||S.height,l.mirrored&&(w.translate(S.width,0),w.scale(-1,1)),w.imageSmoothingEnabled=l.imageSmoothing,w.drawImage(this.video,0,0,t?.width||S.width,t?.height||S.height),l.mirrored&&(w.scale(-1,1),w.translate(-S.width,0))),S},i.prototype.requestUserMedia=function(){var t=this,r=this.props,s=function(y,C){var E={video:typeof C<"u"?C:!0};r.audio&&(E.audio=typeof y<"u"?y:!0),t.requestUserMediaId++;var w=t.requestUserMediaId;navigator.mediaDevices.getUserMedia(E).then(function(S){t.unmounted||w!==t.requestUserMediaId?i.stopMediaStream(S):t.handleUserMedia(null,S)}).catch(function(S){t.handleUserMedia(S)})};if("mediaDevices"in navigator)s(r.audioConstraints,r.videoConstraints);else{var l=function(y){return{optional:[{sourceId:y}]}},M=function(y){var C=y.deviceId;return typeof C=="string"?C:Array.isArray(C)&&C.length>0?C[0]:typeof C=="object"&&C.ideal?C.ideal:null};MediaStreamTrack.getSources(function(y){var C=null,E=null;y.forEach(function(_){_.kind==="audio"?C=_.id:_.kind==="video"&&(E=_.id)});var w=M(r.audioConstraints);w&&(C=w);var S=M(r.videoConstraints);S&&(E=S),s(l(C),l(E))})}},i.prototype.handleUserMedia=function(t,r){var s=this.props;if(t||!r){this.setState({hasUserMedia:!1}),s.onUserMediaError(t);return}this.stream=r;try{this.video&&(this.video.srcObject=r),this.setState({hasUserMedia:!0})}catch{this.setState({hasUserMedia:!0,src:window.URL.createObjectURL(r)})}s.onUserMedia(r)},i.prototype.render=function(){var t=this,r=this,s=r.state,l=r.props,M=l.audio;l.forceScreenshotSourceSize;var y=l.disablePictureInPicture;l.onUserMedia,l.onUserMediaError,l.screenshotFormat,l.screenshotQuality,l.minScreenshotWidth,l.minScreenshotHeight,l.audioConstraints,l.videoConstraints,l.imageSmoothing;var C=l.mirrored,E=l.style,w=E===void 0?{}:E,S=l.children,_=F(l,["audio","forceScreenshotSourceSize","disablePictureInPicture","onUserMedia","onUserMediaError","screenshotFormat","screenshotQuality","minScreenshotWidth","minScreenshotHeight","audioConstraints","videoConstraints","imageSmoothing","mirrored","style","children"]),A=C?m(m({},w),{transform:(w.transform||"")+" scaleX(-1)"}):w,V={getScreenshot:this.getScreenshot.bind(this)};return o.createElement(o.Fragment,null,o.createElement("video",m({autoPlay:!0,disablePictureInPicture:y,src:s.src,muted:!M,playsInline:!0,ref:function(j){t.video=j},style:A},_)),S&&S(V))},i.defaultProps={audio:!1,disablePictureInPicture:!1,forceScreenshotSourceSize:!1,imageSmoothing:!0,mirrored:!1,onUserMedia:function(){},onUserMediaError:function(){},screenshotFormat:"image/webp",screenshotQuality:.92},i})(o.Component);v.default=R}),react:(function(h,v){h.exports=d})}).default})})(z)),z.exports}var Je=Qe();const Ke=be(Je),Ye=({width:e})=>O(G,{width:e,children:[U(q,{size:"threeXL",color:re.gray60,content:ne}),O(je,{children:["This app would like to use your camera.",U(ze,{href:We,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]})]}),Ze=({handleCapture:e,width:a,disabled:d,clearPhotoInProgress:h,setClearPhotoInProgress:v,facingMode:p,setFacingMode:o,testOverride:f})=>{const[m,F]=n.useState(f||"pending"),I=n.useRef(null),[R,b]=n.useState(a),i=n.useCallback(ye(1e3,b),[]);n.useEffect(()=>{i(a)},[a,i]);function t(){if(I.current!==null){const s=I.current.getScreenshot();e(s)}}const r=Ce();return O(se,{"data-testid":"stCameraInputWebcamComponent",children:[m!=="success"&&!d&&!h?U(Ye,{width:R}):Ue()&&U(Ge,{switchFacingMode:o}),U(G,{"data-testid":"stCameraInputWebcamStyledBox",hidden:m!=="success"&&!d&&!h,width:R,children:!d&&U(Ke,{audio:!1,ref:I,screenshotFormat:"image/jpeg",screenshotQuality:1,width:R,height:R*9/16,style:{borderRadius:`${r.radii.default} ${r.radii.default} 0 0`},onUserMediaError:()=>{F("error")},onUserMedia:()=>{F("success"),v(!1)},videoConstraints:{width:{ideal:R},facingMode:p}})}),U(le,{onClick:t,disabled:m!=="success"||d||h,children:"Take Photo"})]})},et=n.memo(Ze),ce="RESTORED_FROM_WIDGET",tt=150,rt=xe.getLogger("CameraInput"),N=e=>{const a=e.filter(d=>d.status.type==="uploaded").map(d=>{const{name:h,size:v,status:p}=d,{fileId:o,fileUrls:f}=p;return new _e({fileId:o,fileUrls:f,name:h,size:v})});return new Oe({uploadedFileInfo:a})},it=(e,a)=>{const d=a.getFileUploaderStateValue(e);if(W(d))return{files:[],nextLocalId:1,imgSrc:null};const{uploadedFileInfo:h}=d;if(W(h)||h.length===0)return{files:[],nextLocalId:1,imgSrc:null};let v=1;const p=h.map(o=>{const f=o.name,m=o.size,F=o.fileId,I=o.fileUrls,R=new ie(f,m,v,{type:"uploaded",fileId:F,fileUrls:I});return v+=1,R});return{files:p,nextLocalId:v,imgSrc:p.length>0?ce:null}};function ot(e,a){return fetch(e).then(d=>d.arrayBuffer()).then(d=>new File([d],a,{type:"image/jpeg"}))}const nt=({element:e,widgetMgr:a,uploadClient:d,disabled:h,fragmentId:v,testOverride:p})=>{const{width:o,elementRef:f}=we(),m=n.useRef(null);m.current===null&&(m.current=it(e,a));const{files:F,nextLocalId:I,imgSrc:R}=m.current,b=n.useRef(I),[i,t]=n.useState(()=>F),r=n.useRef(i);n.useLayoutEffect(()=>{r.current=i},[i]);const[s,l]=n.useState(()=>R),[M,y]=n.useState(!1),[C,E]=n.useState(!0),[w,S]=n.useState(!1),[_,A]=n.useState(B.USER),V=n.useCallback(()=>{const c=b.current;return b.current+=1,c},[]),j=n.useMemo(()=>{const c=u=>u.status.type==="uploading";return i.some(c)?"updating":"ready"},[i]),$=n.useMemo(()=>{if(i.length>0&&i[i.length-1].status.type==="uploading")return i[i.length-1].status.progress},[i]),de=n.useCallback(()=>{A(c=>c===B.USER?B.ENVIRONMENT:B.USER)},[]),P=n.useCallback(c=>r.current.find(u=>u.id===c),[]),X=n.useCallback(c=>{Me.flushSync(()=>{t(u=>[...u,c])})},[]),Q=n.useCallback(c=>{t(u=>u.filter(g=>g.id!==c))},[]),T=n.useCallback((c,u)=>{t(g=>g.map(x=>x.id===c?u:x))},[]),J=n.useCallback((c,u)=>{y(!1);const g=P(c);W(g)||g.status.type!=="uploading"||T(g.id,g.setStatus({type:"uploaded",fileId:u.fileId,fileUrls:u}))},[P,T]),K=n.useCallback((c,u)=>{const g=P(u);if(W(g)||g.status.type!=="uploading")return;const x=Math.round(c.loaded*100/c.total);g.status.progress!==x&&T(u,g.setStatus({type:"uploading",abortController:g.status.abortController,progress:x}))},[P,T]),Y=n.useCallback((c,u)=>{const g=new AbortController,x=new ie(u.name,u.size,V(),{type:"uploading",abortController:g,progress:1});X(x),d.uploadFile(e,c.uploadUrl,u,L=>K(L,x.id),g.signal).then(()=>J(x.id,c)).catch(L=>{L instanceof DOMException&&L.name==="AbortError"||T(x.id,x.setStatus({type:"error",errorMessage:L?L.toString():"Unknown error"}))})},[X,e,V,J,K,T,d]),Z=n.useCallback(c=>{const u=P(c);W(u)||(u.status.type==="uploading"&&u.status.abortController.abort(),u.status.type==="uploaded"&&u.status.fileUrls.deleteUrl&&d.deleteFile(u.status.fileUrls.deleteUrl),Q(c))},[P,Q,d]),ee=n.useCallback(c=>{if(c===null)return Promise.resolve();l(c),y(!0),E(!1);const u=g=>new Promise(x=>setTimeout(x,g));return ot(c,`camera-input-${new Date().toISOString().replace(/:/g,"_")}.jpg`).then(g=>d.fetchFileURLs([g]).then(x=>({file:g,fileUrls:x[0]}))).then(({file:g,fileUrls:x})=>Y(x,g)).then(()=>u(tt)).then(()=>{E(!0)}).catch(g=>{rt.error(g)})},[d,Y]),ue=n.useCallback(c=>{ee(c)},[ee]),fe=n.useCallback(()=>{i.length!==0&&(i.forEach(c=>Z(c.id)),l(null),S(!0))},[i,Z]);n.useEffect(()=>{a.getFileUploaderStateValue(e)===void 0&&a.setFileUploaderStateValue(e,N(i),{fromUi:!1},v)},[]),n.useEffect(()=>{if(j!=="ready")return;const c=N(i),u=a.getFileUploaderStateValue(e);Ee(c,u)||a.setFileUploaderStateValue(e,c,{fromUi:!0},v)},[j,i,a,e,v]);const pe=n.useCallback(()=>{t([]),l(null);const c=N([]);a.setFileUploaderStateValue(e,c,{fromUi:!0},v)},[e,v,a]);return Pe({element:e,widgetMgr:a,onFormCleared:pe}),O(se,{className:"stCameraInput","data-testid":"stCameraInput",ref:f,children:[U(Re,{label:e.label,disabled:h,labelVisibility:Ie(e.labelVisibility?.value),children:e.help&&U(Fe,{content:e.help,label:e.label})}),s?O(ke,{children:[U(G,{width:o,children:s!==ce&&U(Be,{src:s,alt:"Snapshot",opacity:M||!C?"50%":"100%",width:o,height:o*9/16})}),U(le,{onClick:fe,progress:$,disabled:!!$||h,children:$?"Uploading...":O(Ae,{children:[U(q,{content:ae,margin:"0 xs 0 0",size:"sm"})," Clear photo"]})})]}):U(et,{handleCapture:ue,width:o,disabled:h,clearPhotoInProgress:w,setClearPhotoInProgress:S,facingMode:_,setFacingMode:de,testOverride:p})]})},ut=n.memo(nt);export{ut as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as u,B as n,u as d,j as o,a as B,b as m,c as h,D as p,d as f}from"./index.
|
|
1
|
+
import{r as u,B as n,u as d,j as o,a as B,b as m,c as h,D as p,d as f}from"./index.y5HxPwg9.js";import{m as g}from"./iconPosition.DkZAlu_k.js";function b(l){const{disabled:e,element:t,widgetMgr:s,fragmentId:a}=l,r=t.shortcut?t.shortcut:void 0;let i=n.SECONDARY;t.type==="primary"?i=n.PRIMARY:t.type==="tertiary"&&(i=n.TERTIARY);const c=u.useCallback(()=>{e||s.setTriggerValue(t,{fromUi:!0},a)},[e,s,t,a]);return d({shortcut:r,disabled:e,onActivate:c}),o(f,{className:"stButton","data-testid":"stButton",children:o(B,{help:t.help,containerWidth:!0,children:o(m,{kind:i,size:h.SMALL,disabled:e,containerWidth:!0,onClick:c,children:o(p,{icon:t.icon,iconPosition:g(t.iconPosition),label:t.label,shortcut:r})})})})}const A=u.memo(b);export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,E as L,_ as D,L as ze,e as ue,n as F,aL as se,bW as Le,bQ as De,bP as Be,z as p,j as n,Y as Ve,o as x,B as We,ax as Me,b as Ne,l as Oe,aa as He,p as $e,ab as je,P as _e,ac as Xe}from"./index.aCorc3Yt.js";import{u as Ge}from"./useWaveformController.DbWw5MEk.js";import{T as qe,a as ce}from"./Toolbar.CQsWYXer.js";import{u as Ke,F as Qe}from"./FormClearHelper.DN8D_YXO.js";import{c as Ye}from"./createDownloadLinkElement.DnBEQQbK.js";import{E as Je}from"./urls.BwSlolu9.js";import{F as Ze,D as et}from"./FileDownload.esm.yTkppsJy.js";var fe=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("g",{fill:"none"},t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24})),t.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),t.createElement("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});fe.displayName="Mic";var pe=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("rect",{width:24,height:24,fill:"none"}),t.createElement("path",{d:"M8 19c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2v10c0 1.1.9 2 2 2zm6-12v10c0 1.1.9 2 2 2s2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2z"}))});pe.displayName="Pause";var me=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("rect",{width:24,height:24,fill:"none"}),t.createElement("path",{d:"M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18a1 1 0 000-1.69L9.54 5.98A.998.998 0 008 6.82z"}))});me.displayName="PlayArrow";var ge=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),t.createElement("path",{d:"M17.65 6.35a7.95 7.95 0 00-6.48-2.31c-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20a7.98 7.98 0 007.21-4.56c.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53a5.994 5.994 0 01-6.8 3.31c-2.22-.49-4.01-2.3-4.48-4.52A6.002 6.002 0 0112 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71l-.64.65z"}))});ge.displayName="Refresh";var he=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("g",{fill:"none"},t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24})),t.createElement("path",{fillRule:"evenodd",d:"M9 16h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"}))});he.displayName="StopCircle";const tt=(e,r)=>{const{enforceDownloadInNewTab:o=!1}=t.useContext(ze);return t.useCallback(()=>{if(!e)return;const l=Ye({enforceDownloadInNewTab:o,url:e,filename:r});l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l)},[e,o,r])},j=({widgetMgr:e,id:r,formId:o,key:i,defaultValue:l})=>{t.useEffect(()=>{const s=e.getElementState(r,i);ue(s)&&F(l)&&e.setElementState(r,i,l)},[e,r,i,l]);const[R,g]=t.useState(e.getElementState(r,i)??l),c=t.useCallback(s=>{e.setElementState(r,i,s),g(s)},[e,r,i]),v=t.useMemo(()=>({formId:o||""}),[o]),E=t.useCallback(()=>c(l),[l,c]);return Ke({element:v,widgetMgr:e,onFormCleared:E}),[R,c]},rt=async({files:e,uploadClient:r,widgetMgr:o,widgetInfo:i,fragmentId:l,signal:R})=>{let g=[];try{g=await r.fetchFileURLs(e)}catch(s){return{successfulUploads:[],failedUploads:e.map(d=>({file:d,error:se(s)}))}}const c=Le(e,g),v=[],E=[];return await Promise.all(c.map(async([s,d])=>{if(!s||!d?.uploadUrl||!d.fileId)return{file:s,fileUrl:d,error:new Error("No upload URL found")};try{await r.uploadFile({id:d.fileId,formId:i.formId||""},d.uploadUrl,s,void 0,R),v.push({fileUrl:d,file:s})}catch(h){const O=se(h);E.push({file:s,error:O})}})),o.setFileUploaderStateValue(i,new De({uploadedFileInfo:v.map(({file:s,fileUrl:d})=>new Be({fileId:d.fileId,fileUrls:d,name:s.webkitRelativePath||s.name,size:s.size}))}),{fromUi:!0},l),{successfulUploads:v,failedUploads:E}},ot=p("div",{target:"e18uw4vz0"})(),de=p("div",{target:"e18uw4vz1"})(({theme:e,disabled:r})=>({height:e.sizes.largestElementHeight,width:"100%",background:e.colors.secondaryBg,borderRadius:e.radii.default,marginBottom:e.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:e.spacing.xs,paddingRight:e.spacing.sm,border:e.colors.widgetBorderColor?`${e.sizes.borderWidth} solid ${e.colors.widgetBorderColor}`:void 0,cursor:r?"not-allowed":"auto",overflow:"hidden"})),nt=p("div",{target:"e18uw4vz2"})({flex:1}),at=p("div",{target:"e18uw4vz3"})(({show:e,theme:r})=>({display:e?"block":"none",position:"relative",height:r.sizes.largestElementHeight,"& > div":{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center"}})),lt=p("span",{target:"e18uw4vz4"})(({theme:e,isPlayingOrRecording:r,disabled:o})=>({margin:e.spacing.sm,fontFamily:e.fonts.monospace,color:o?e.colors.fadedText40:r?e.colors.bodyText:e.colors.fadedText60,backgroundColor:e.colors.secondaryBg,fontSize:e.fontSizes.sm})),be=p("div",{target:"e18uw4vz5"})({width:"100%",textAlign:"center",overflow:"hidden"}),ve=p("span",{target:"e18uw4vz6"})(({theme:e})=>({color:e.colors.bodyText})),it=p("a",{target:"e18uw4vz7"})(({theme:e})=>({color:e.colors.link,textDecoration:e.linkUnderline?"underline":"none"})),st=p("div",{target:"e18uw4vz8"})(({theme:e})=>({flex:1,height:e.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"})),ct=p("div",{target:"e18uw4vz9"})(({theme:e})=>{const r="0.625em";return{opacity:.2,width:"100%",height:r,backgroundSize:r,backgroundImage:`radial-gradient(${e.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),dt=p("span",{target:"e18uw4vz10"})(({theme:e})=>({"& > button":{color:e.colors.primary,padding:e.spacing.threeXS},"& > button:hover, & > button:focus":{color:e.colors.redColor}})),ut=p("span",{target:"e18uw4vz11"})(({theme:e})=>({"& > button":{padding:e.spacing.threeXS,color:e.colors.fadedText60},"& > button:hover, & > button:focus":{color:e.colors.bodyText}})),ye=p("span",{target:"e18uw4vz12"})(({theme:e})=>({"& > button":{padding:e.spacing.threeXS,color:e.colors.fadedText60},"& > button:hover, & > button:focus":{color:e.colors.bodyText}})),_=p("div",{target:"e18uw4vz13"})(({theme:e})=>({display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:e.spacing.xs,gap:e.spacing.twoXS,marginRight:e.spacing.twoXS})),z=({onClick:e,disabled:r,ariaLabel:o,iconContent:i})=>n(Ne,{kind:We.BORDERLESS_ICON,onClick:e,disabled:r,"aria-label":o,containerWidth:!0,"data-testid":"stAudioInputActionButton",children:n(Me,{content:i,size:"lg",color:"inherit"})}),ft=({disabled:e,stopRecording:r})=>n(dt,{children:n(z,{onClick:r,disabled:e,ariaLabel:"Stop recording",iconContent:he})}),pt=({disabled:e,isPlaying:r,onClickPlayPause:o})=>n(ye,{children:r?n(z,{onClick:o,disabled:e,ariaLabel:"Pause",iconContent:pe}):n(z,{onClick:o,disabled:e,ariaLabel:"Play",iconContent:me})}),mt=({disabled:e,startRecording:r})=>n(ut,{children:n(z,{onClick:r,disabled:e,ariaLabel:"Record",iconContent:fe})}),gt=({onClick:e})=>n(ye,{children:n(z,{disabled:!1,onClick:e,ariaLabel:"Reset",iconContent:ge})}),ht=({disabled:e,isRecording:r,isPlaying:o,isUploading:i,isError:l,recordingUrlExists:R,startRecording:g,stopRecording:c,onClickPlayPause:v,onClear:E})=>l?n(_,{children:n(gt,{onClick:E})}):i?n(_,{children:n(Ve,{size:"base",iconValue:"spinner"})}):x(_,{children:[r?n(ft,{disabled:e,stopRecording:c}):n(mt,{disabled:e,startRecording:g}),R&&n(pt,{disabled:e,isPlaying:o,onClickPlayPause:v})]}),bt=t.memo(ht),vt=()=>n(be,{children:n(ve,{children:"An error has occurred, please try again."})}),yt=t.memo(vt),C="00:00",A=e=>{const r=Math.floor(e/1e3),o=Math.floor(r/60),i=Math.floor(o/60),l=r%60,R=o%60,g=l.toString().padStart(2,"0"),c=R.toString().padStart(2,"0"),v=i.toString().padStart(2,"0");return o<60?`${c}:${g}`:`${v}:${c}:${g}`},wt=()=>x(be,{children:[n(ve,{children:"This app would like to use your microphone."})," ",n(it,{href:Je,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]}),St=t.memo(wt),Ct=()=>n(st,{children:n(ct,{})}),Rt=t.memo(Ct),Et=({element:e,uploadClient:r,widgetMgr:o,fragmentId:i,disabled:l})=>{const R=Oe(),g=t.useRef(null),[c,v]=t.useState(!1),[E,s]=t.useState(!1),[d,h]=t.useState(!1),[O,b]=t.useState(C),[B,V]=j({widgetMgr:o,id:e.id,key:"deleteFileUrl",defaultValue:null}),[m,W]=j({widgetMgr:o,id:e.id,key:"recordingUrl",defaultValue:null}),[H,I]=j({widgetMgr:o,id:e.id,formId:e.formId,key:"recordingTime",defaultValue:C}),U=t.useRef(null),w=t.useRef(null),u=t.useRef(null),X=e.id,S=e.formId,we=t.useCallback(async a=>{U.current&&U.current.abort();const y=new AbortController;U.current=y;try{if(s(!0),F(S)&&o.setFormsWithUploadsInProgress(new Set([S])),y.signal.aborted)return;let f;try{f=URL.createObjectURL(a),w.current&&w.current!==f&&URL.revokeObjectURL(w.current),w.current=f}catch{h(!0),s(!1),F(S)&&o.setFormsWithUploadsInProgress(new Set);return}if(y.signal.aborted){URL.revokeObjectURL(f),w.current=null;return}W(f);const Pe=new Date().toISOString().slice(0,16).replace(/:/g,"-"),Fe=new File([a],`${Pe}_audio.wav`,{type:a.type});try{const{successfulUploads:xe,failedUploads:Te}=await rt({files:[Fe],uploadClient:r,widgetMgr:o,widgetInfo:{id:X,formId:S},fragmentId:i,signal:y.signal});if(y.signal.aborted)return;if(Te.length>0){h(!0);return}h(!1);const ie=xe[0];ie?.fileUrl?.deleteUrl&&V(ie.fileUrl.deleteUrl)}catch{y.signal.aborted||h(!0)}finally{F(S)&&o.setFormsWithUploadsInProgress(new Set),y.signal.aborted||s(!1)}}catch{y.signal.aborted||(h(!0),s(!1)),F(S)&&o.setFormsWithUploadsInProgress(new Set)}},[r,o,X,S,i,V,W]),M=t.useRef(null),G=Ge({containerRef:g,sampleRate:e.sampleRate??void 0,waveformPadding:He(R.spacing.twoXS),events:{onPermissionDenied:()=>{v(!0)},onError:()=>{h(!0)},onRecordStart:()=>{I(C),b(C)},onRecordReady:()=>{const a=A(M.current?.playback.getDurationMs()??0);I(a),b(a)},onApprove:we,onCancel:()=>{I(C),b(C)},onProgressMs:a=>{I(A(a))},onPlaybackPause:()=>{b(A(M.current?.playback.getCurrentTimeMs()??0))},onPlaybackFinish:()=>{b(A(M.current?.playback.getDurationMs()??0))}}});M.current=G;const{state:N,isPlaybackPlaying:P,start:q,stop:K,approve:Q,cancel:Y,playback:{play:J,pause:Z,load:ee,getCurrentTimeMs:T,getDurationMs:te}}=G,k=t.useCallback(async({updateWidgetManager:a,deleteFile:y})=>{const f=m;if(f&&w.current===f&&(URL.revokeObjectURL(f),w.current=null),u.current&&(cancelAnimationFrame(u.current),u.current=null),W(null),V(null),b(C),I(C),Y(),a&&o.setFileUploaderStateValue(e,{},{fromUi:!0},i),y&&B)try{await r.deleteFile(B)}catch{}F(f)&&URL.revokeObjectURL(f)},[B,m,r,Y,e,o,i,I,V,W]);t.useEffect(()=>{const a=()=>{P&&(b(A(T())),u.current=requestAnimationFrame(a))};return P?u.current=requestAnimationFrame(a):u.current&&(cancelAnimationFrame(u.current),u.current=null),()=>{u.current&&(cancelAnimationFrame(u.current),u.current=null)}},[P,T]),t.useEffect(()=>{if(!m)return;let a=!1;return b(H),(async()=>{try{if(await ee(m),a)return;const f=te();f>0&&b(A(f))}catch{a||h(!0)}})(),()=>{a=!0}},[m,H,ee,te]),t.useEffect(()=>{if(ue(S))return;const a=new Qe;return a.manageFormClearListener(o,S,()=>{k({updateWidgetManager:!0,deleteFile:!1})}),()=>a.disconnect()},[S,k,o]),t.useEffect(()=>()=>{U.current&&(U.current.abort(),U.current=null),u.current&&(cancelAnimationFrame(u.current),u.current=null),w.current&&(URL.revokeObjectURL(w.current),w.current=null)},[]);const Se=t.useCallback(async()=>{try{if(P){const a=T();Z(),b(A(a))}else N==="idle"&&m&&(T()<=100&&b(C),await J())}catch{h(!0)}},[P,T,Z,J,m,N]),re=t.useCallback(async()=>{m&&await k({updateWidgetManager:!1,deleteFile:!0});try{b(C),await q()}catch{}},[k,m,q]),oe=t.useCallback(async()=>{try{const{blob:a}=await K();await Q(a)}catch{h(!0)}},[Q,K]),ne=tt(m,"recording.wav"),Ce=t.useCallback(()=>{re()},[re]),Re=t.useCallback(()=>{oe()},[oe]),Ee=t.useCallback(()=>{k({updateWidgetManager:!1,deleteFile:!0}),h(!1)},[k]),ke=t.useCallback(()=>{ne()},[ne]),Ae=t.useCallback(()=>{k({updateWidgetManager:!0,deleteFile:!0})},[k]),$=N==="recording",ae=P,Ie=$?H:O,le=N==="idle"&&!c&&!m,Ue=c||le||d;return x(ot,{className:"stAudioInput","data-testid":"stAudioInput",children:[n(Xe,{label:e.label,disabled:l,labelVisibility:$e(e.labelVisibility?.value),children:e.help&&n(je,{content:e.help,placement:_e.TOP,label:e.label})}),x(de,{disabled:l,children:[x(qe,{isFullScreen:!1,disableFullscreenMode:!0,target:de,children:[m&&n(ce,{label:"Download as WAV",icon:Ze,onClick:ke}),B&&n(ce,{label:"Clear recording",icon:et,onClick:Ae})]}),n(bt,{isRecording:$,isPlaying:ae,isUploading:E,isError:d,recordingUrlExists:!!m,startRecording:Ce,stopRecording:Re,onClickPlayPause:()=>{Se()},onClear:Ee,disabled:l||c}),x(nt,{children:[d&&n(yt,{}),le&&n(Rt,{}),c&&n(St,{}),n(at,{"data-testid":"stAudioInputWaveSurfer",ref:g,show:!Ue})]}),n(lt,{isPlayingOrRecording:$||ae,disabled:l,"data-testid":"stAudioInputWaveformTimeCode",children:Ie})]})]})},Tt=t.memo(Et);export{Tt as default};
|
|
1
|
+
import{r as t,E as L,_ as D,L as ze,e as ue,n as F,aN as se,bZ as Le,bT as De,bS as Be,z as p,j as n,Y as Ve,o as x,B as We,az as Ne,b as Me,l as Oe,ac as He,p as $e,ad as je,P as _e,ae as Xe}from"./index.y5HxPwg9.js";import{u as Ge}from"./useWaveformController.C5PTwL6I.js";import{T as qe,a as ce}from"./Toolbar.CbpscbNb.js";import{u as Ke,F as Ye}from"./FormClearHelper.zxJ53Nym.js";import{c as Ze}from"./createDownloadLinkElement.jVwF96ey.js";import{E as Je}from"./urls.BwSlolu9.js";import{F as Qe,D as et}from"./FileDownload.esm.CO68LcnZ.js";var fe=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("g",{fill:"none"},t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24})),t.createElement("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),t.createElement("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"}))});fe.displayName="Mic";var pe=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("rect",{width:24,height:24,fill:"none"}),t.createElement("path",{d:"M8 19c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2v10c0 1.1.9 2 2 2zm6-12v10c0 1.1.9 2 2 2s2-.9 2-2V7c0-1.1-.9-2-2-2s-2 .9-2 2z"}))});pe.displayName="Pause";var me=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("rect",{width:24,height:24,fill:"none"}),t.createElement("path",{d:"M8 6.82v10.36c0 .79.87 1.27 1.54.84l8.14-5.18a1 1 0 000-1.69L9.54 5.98A.998.998 0 008 6.82z"}))});me.displayName="PlayArrow";var ge=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("path",{fill:"none",d:"M0 0h24v24H0V0z"}),t.createElement("path",{d:"M17.65 6.35a7.95 7.95 0 00-6.48-2.31c-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20a7.98 7.98 0 007.21-4.56c.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53a5.994 5.994 0 01-6.8 3.31c-2.22-.49-4.01-2.3-4.48-4.52A6.002 6.002 0 0112 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71l-.64.65z"}))});ge.displayName="Refresh";var he=t.forwardRef(function(e,r){var o={fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"};return t.createElement(L,D({iconAttrs:o,iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:r}),t.createElement("g",{fill:"none"},t.createElement("rect",{width:24,height:24}),t.createElement("rect",{width:24,height:24})),t.createElement("path",{fillRule:"evenodd",d:"M9 16h6c.55 0 1-.45 1-1V9c0-.55-.45-1-1-1H9c-.55 0-1 .45-1 1v6c0 .55.45 1 1 1zm3-14C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2z"}))});he.displayName="StopCircle";const tt=(e,r)=>{const{enforceDownloadInNewTab:o=!1}=t.useContext(ze);return t.useCallback(()=>{if(!e)return;const l=Ze({enforceDownloadInNewTab:o,url:e,filename:r});l.style.display="none",document.body.appendChild(l),l.click(),document.body.removeChild(l)},[e,o,r])},j=({widgetMgr:e,id:r,formId:o,key:i,defaultValue:l})=>{t.useEffect(()=>{const s=e.getElementState(r,i);ue(s)&&F(l)&&e.setElementState(r,i,l)},[e,r,i,l]);const[R,g]=t.useState(e.getElementState(r,i)??l),c=t.useCallback(s=>{e.setElementState(r,i,s),g(s)},[e,r,i]),v=t.useMemo(()=>({formId:o||""}),[o]),E=t.useCallback(()=>c(l),[l,c]);return Ke({element:v,widgetMgr:e,onFormCleared:E}),[R,c]},rt=async({files:e,uploadClient:r,widgetMgr:o,widgetInfo:i,fragmentId:l,signal:R})=>{let g=[];try{g=await r.fetchFileURLs(e)}catch(s){return{successfulUploads:[],failedUploads:e.map(d=>({file:d,error:se(s)}))}}const c=Le(e,g),v=[],E=[];return await Promise.all(c.map(async([s,d])=>{if(!s||!d?.uploadUrl||!d.fileId)return{file:s,fileUrl:d,error:new Error("No upload URL found")};try{await r.uploadFile({id:d.fileId,formId:i.formId||""},d.uploadUrl,s,void 0,R),v.push({fileUrl:d,file:s})}catch(h){const O=se(h);E.push({file:s,error:O})}})),o.setFileUploaderStateValue(i,new De({uploadedFileInfo:v.map(({file:s,fileUrl:d})=>new Be({fileId:d.fileId,fileUrls:d,name:s.webkitRelativePath||s.name,size:s.size}))}),{fromUi:!0},l),{successfulUploads:v,failedUploads:E}},ot=p("div",{target:"e18uw4vz0"})(),de=p("div",{target:"e18uw4vz1"})(({theme:e,disabled:r})=>({height:e.sizes.largestElementHeight,width:"100%",background:e.colors.secondaryBg,borderRadius:e.radii.default,marginBottom:e.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:e.spacing.xs,paddingRight:e.spacing.sm,border:e.colors.widgetBorderColor?`${e.sizes.borderWidth} solid ${e.colors.widgetBorderColor}`:void 0,cursor:r?"not-allowed":"auto",overflow:"hidden"})),nt=p("div",{target:"e18uw4vz2"})({flex:1}),at=p("div",{target:"e18uw4vz3"})(({show:e,theme:r})=>({display:e?"block":"none",position:"relative",height:r.sizes.largestElementHeight,"& > div":{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",alignItems:"center"}})),lt=p("span",{target:"e18uw4vz4"})(({theme:e,isPlayingOrRecording:r,disabled:o})=>({margin:e.spacing.sm,fontFamily:e.fonts.monospace,color:o?e.colors.fadedText40:r?e.colors.bodyText:e.colors.fadedText60,backgroundColor:e.colors.secondaryBg,fontSize:e.fontSizes.sm})),be=p("div",{target:"e18uw4vz5"})({width:"100%",textAlign:"center",overflow:"hidden"}),ve=p("span",{target:"e18uw4vz6"})(({theme:e})=>({color:e.colors.bodyText})),it=p("a",{target:"e18uw4vz7"})(({theme:e})=>({color:e.colors.link,textDecoration:e.linkUnderline?"underline":"none"})),st=p("div",{target:"e18uw4vz8"})(({theme:e})=>({flex:1,height:e.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"})),ct=p("div",{target:"e18uw4vz9"})(({theme:e})=>{const r="0.625em";return{opacity:.2,width:"100%",height:r,backgroundSize:r,backgroundImage:`radial-gradient(${e.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),dt=p("span",{target:"e18uw4vz10"})(({theme:e})=>({"& > button":{color:e.colors.primary,padding:e.spacing.threeXS},"& > button:hover, & > button:focus":{color:e.colors.redColor}})),ut=p("span",{target:"e18uw4vz11"})(({theme:e})=>({"& > button":{padding:e.spacing.threeXS,color:e.colors.fadedText60},"& > button:hover, & > button:focus":{color:e.colors.bodyText}})),ye=p("span",{target:"e18uw4vz12"})(({theme:e})=>({"& > button":{padding:e.spacing.threeXS,color:e.colors.fadedText60},"& > button:hover, & > button:focus":{color:e.colors.bodyText}})),_=p("div",{target:"e18uw4vz13"})(({theme:e})=>({display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:e.spacing.xs,gap:e.spacing.twoXS,marginRight:e.spacing.twoXS})),z=({onClick:e,disabled:r,ariaLabel:o,iconContent:i})=>n(Me,{kind:We.BORDERLESS_ICON,onClick:e,disabled:r,"aria-label":o,containerWidth:!0,"data-testid":"stAudioInputActionButton",children:n(Ne,{content:i,size:"lg",color:"inherit"})}),ft=({disabled:e,stopRecording:r})=>n(dt,{children:n(z,{onClick:r,disabled:e,ariaLabel:"Stop recording",iconContent:he})}),pt=({disabled:e,isPlaying:r,onClickPlayPause:o})=>n(ye,{children:r?n(z,{onClick:o,disabled:e,ariaLabel:"Pause",iconContent:pe}):n(z,{onClick:o,disabled:e,ariaLabel:"Play",iconContent:me})}),mt=({disabled:e,startRecording:r})=>n(ut,{children:n(z,{onClick:r,disabled:e,ariaLabel:"Record",iconContent:fe})}),gt=({onClick:e})=>n(ye,{children:n(z,{disabled:!1,onClick:e,ariaLabel:"Reset",iconContent:ge})}),ht=({disabled:e,isRecording:r,isPlaying:o,isUploading:i,isError:l,recordingUrlExists:R,startRecording:g,stopRecording:c,onClickPlayPause:v,onClear:E})=>l?n(_,{children:n(gt,{onClick:E})}):i?n(_,{children:n(Ve,{size:"base",iconValue:"spinner"})}):x(_,{children:[r?n(ft,{disabled:e,stopRecording:c}):n(mt,{disabled:e,startRecording:g}),R&&n(pt,{disabled:e,isPlaying:o,onClickPlayPause:v})]}),bt=t.memo(ht),vt=()=>n(be,{children:n(ve,{children:"An error has occurred, please try again."})}),yt=t.memo(vt),C="00:00",A=e=>{const r=Math.floor(e/1e3),o=Math.floor(r/60),i=Math.floor(o/60),l=r%60,R=o%60,g=l.toString().padStart(2,"0"),c=R.toString().padStart(2,"0"),v=i.toString().padStart(2,"0");return o<60?`${c}:${g}`:`${v}:${c}:${g}`},wt=()=>x(be,{children:[n(ve,{children:"This app would like to use your microphone."})," ",n(it,{href:Je,rel:"noopener noreferrer",target:"_blank",children:"Learn how to allow access."})]}),St=t.memo(wt),Ct=()=>n(st,{children:n(ct,{})}),Rt=t.memo(Ct),Et=({element:e,uploadClient:r,widgetMgr:o,fragmentId:i,disabled:l})=>{const R=Oe(),g=t.useRef(null),[c,v]=t.useState(!1),[E,s]=t.useState(!1),[d,h]=t.useState(!1),[O,b]=t.useState(C),[B,V]=j({widgetMgr:o,id:e.id,key:"deleteFileUrl",defaultValue:null}),[m,W]=j({widgetMgr:o,id:e.id,key:"recordingUrl",defaultValue:null}),[H,I]=j({widgetMgr:o,id:e.id,formId:e.formId,key:"recordingTime",defaultValue:C}),U=t.useRef(null),w=t.useRef(null),u=t.useRef(null),X=e.id,S=e.formId,we=t.useCallback(async a=>{U.current&&U.current.abort();const y=new AbortController;U.current=y;try{if(s(!0),F(S)&&o.setFormsWithUploadsInProgress(new Set([S])),y.signal.aborted)return;let f;try{f=URL.createObjectURL(a),w.current&&w.current!==f&&URL.revokeObjectURL(w.current),w.current=f}catch{h(!0),s(!1),F(S)&&o.setFormsWithUploadsInProgress(new Set);return}if(y.signal.aborted){URL.revokeObjectURL(f),w.current=null;return}W(f);const Pe=new Date().toISOString().slice(0,16).replace(/:/g,"-"),Fe=new File([a],`${Pe}_audio.wav`,{type:a.type});try{const{successfulUploads:xe,failedUploads:Te}=await rt({files:[Fe],uploadClient:r,widgetMgr:o,widgetInfo:{id:X,formId:S},fragmentId:i,signal:y.signal});if(y.signal.aborted)return;if(Te.length>0){h(!0);return}h(!1);const ie=xe[0];ie?.fileUrl?.deleteUrl&&V(ie.fileUrl.deleteUrl)}catch{y.signal.aborted||h(!0)}finally{F(S)&&o.setFormsWithUploadsInProgress(new Set),y.signal.aborted||s(!1)}}catch{y.signal.aborted||(h(!0),s(!1)),F(S)&&o.setFormsWithUploadsInProgress(new Set)}},[r,o,X,S,i,V,W]),N=t.useRef(null),G=Ge({containerRef:g,sampleRate:e.sampleRate??void 0,waveformPadding:He(R.spacing.twoXS),events:{onPermissionDenied:()=>{v(!0)},onError:()=>{h(!0)},onRecordStart:()=>{I(C),b(C)},onRecordReady:()=>{const a=A(N.current?.playback.getDurationMs()??0);I(a),b(a)},onApprove:we,onCancel:()=>{I(C),b(C)},onProgressMs:a=>{I(A(a))},onPlaybackPause:()=>{b(A(N.current?.playback.getCurrentTimeMs()??0))},onPlaybackFinish:()=>{b(A(N.current?.playback.getDurationMs()??0))}}});N.current=G;const{state:M,isPlaybackPlaying:P,start:q,stop:K,approve:Y,cancel:Z,playback:{play:J,pause:Q,load:ee,getCurrentTimeMs:T,getDurationMs:te}}=G,k=t.useCallback(async({updateWidgetManager:a,deleteFile:y})=>{const f=m;if(f&&w.current===f&&(URL.revokeObjectURL(f),w.current=null),u.current&&(cancelAnimationFrame(u.current),u.current=null),W(null),V(null),b(C),I(C),Z(),a&&o.setFileUploaderStateValue(e,{},{fromUi:!0},i),y&&B)try{await r.deleteFile(B)}catch{}F(f)&&URL.revokeObjectURL(f)},[B,m,r,Z,e,o,i,I,V,W]);t.useEffect(()=>{const a=()=>{P&&(b(A(T())),u.current=requestAnimationFrame(a))};return P?u.current=requestAnimationFrame(a):u.current&&(cancelAnimationFrame(u.current),u.current=null),()=>{u.current&&(cancelAnimationFrame(u.current),u.current=null)}},[P,T]),t.useEffect(()=>{if(!m)return;let a=!1;return b(H),(async()=>{try{if(await ee(m),a)return;const f=te();f>0&&b(A(f))}catch{a||h(!0)}})(),()=>{a=!0}},[m,H,ee,te]),t.useEffect(()=>{if(ue(S))return;const a=new Ye;return a.manageFormClearListener(o,S,()=>{k({updateWidgetManager:!0,deleteFile:!1})}),()=>a.disconnect()},[S,k,o]),t.useEffect(()=>()=>{U.current&&(U.current.abort(),U.current=null),u.current&&(cancelAnimationFrame(u.current),u.current=null),w.current&&(URL.revokeObjectURL(w.current),w.current=null)},[]);const Se=t.useCallback(async()=>{try{if(P){const a=T();Q(),b(A(a))}else M==="idle"&&m&&(T()<=100&&b(C),await J())}catch{h(!0)}},[P,T,Q,J,m,M]),re=t.useCallback(async()=>{m&&await k({updateWidgetManager:!1,deleteFile:!0});try{b(C),await q()}catch{}},[k,m,q]),oe=t.useCallback(async()=>{try{const{blob:a}=await K();await Y(a)}catch{h(!0)}},[Y,K]),ne=tt(m,"recording.wav"),Ce=t.useCallback(()=>{re()},[re]),Re=t.useCallback(()=>{oe()},[oe]),Ee=t.useCallback(()=>{k({updateWidgetManager:!1,deleteFile:!0}),h(!1)},[k]),ke=t.useCallback(()=>{ne()},[ne]),Ae=t.useCallback(()=>{k({updateWidgetManager:!0,deleteFile:!0})},[k]),$=M==="recording",ae=P,Ie=$?H:O,le=M==="idle"&&!c&&!m,Ue=c||le||d;return x(ot,{className:"stAudioInput","data-testid":"stAudioInput",children:[n(Xe,{label:e.label,disabled:l,labelVisibility:$e(e.labelVisibility?.value),children:e.help&&n(je,{content:e.help,placement:_e.TOP,label:e.label})}),x(de,{disabled:l,children:[x(qe,{isFullScreen:!1,disableFullscreenMode:!0,target:de,children:[m&&n(ce,{label:"Download as WAV",icon:Qe,onClick:ke}),B&&n(ce,{label:"Clear recording",icon:et,onClick:Ae})]}),n(bt,{isRecording:$,isPlaying:ae,isUploading:E,isError:d,recordingUrlExists:!!m,startRecording:Ce,stopRecording:Re,onClickPlayPause:()=>{Se()},onClear:Ee,disabled:l||c}),x(nt,{children:[d&&n(yt,{}),le&&n(Rt,{}),c&&n(St,{}),n(at,{"data-testid":"stAudioInputWaveSurfer",ref:g,show:!Ue})]}),n(lt,{isPlayingOrRecording:$||ae,disabled:l,"data-testid":"stAudioInputWaveformTimeCode",children:Ie})]})]})},Tt=t.memo(Et);export{Tt as default};
|