streamlit-nightly 1.53.2.dev20260131__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/delta_generator.py +2 -0
- 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/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/AudioInput_pb2.py +4 -4
- streamlit/proto/AudioInput_pb2.pyi +3 -3
- streamlit/proto/Audio_pb2.py +2 -2
- streamlit/proto/BackMsg_pb2.pyi +2 -10
- streamlit/proto/Balloons_pb2.pyi +0 -2
- streamlit/proto/Block_pb2.py +35 -35
- streamlit/proto/ButtonGroup_pb2.py +10 -12
- streamlit/proto/ButtonGroup_pb2.pyi +6 -41
- streamlit/proto/Button_pb2.py +2 -2
- streamlit/proto/CameraInput_pb2.py +4 -4
- streamlit/proto/CameraInput_pb2.pyi +3 -3
- streamlit/proto/ChatInput_pb2.py +2 -2
- streamlit/proto/Checkbox_pb2.py +6 -6
- streamlit/proto/Checkbox_pb2.pyi +3 -3
- streamlit/proto/Code_pb2.py +2 -2
- streamlit/proto/ColorPicker_pb2.py +4 -4
- streamlit/proto/ColorPicker_pb2.pyi +3 -3
- streamlit/proto/Common_pb2.py +6 -6
- streamlit/proto/DateInput_pb2.py +4 -4
- streamlit/proto/DateInput_pb2.pyi +3 -3
- streamlit/proto/DateTimeInput_pb2.py +4 -4
- streamlit/proto/DateTimeInput_pb2.pyi +3 -3
- streamlit/proto/DeckGlJsonChart_pb2.py +2 -2
- streamlit/proto/Delta_pb2.py +2 -2
- streamlit/proto/DocString_pb2.py +1 -1
- streamlit/proto/Element_pb2.py +4 -4
- streamlit/proto/Element_pb2.pyi +9 -9
- streamlit/proto/Feedback_pb2.py +28 -0
- streamlit/proto/Feedback_pb2.pyi +93 -0
- streamlit/proto/FileUploader_pb2.py +4 -4
- streamlit/proto/FileUploader_pb2.pyi +3 -3
- streamlit/proto/ForwardMsg_pb2.py +8 -8
- streamlit/proto/GraphVizChart_pb2.py +2 -2
- streamlit/proto/IFrame_pb2.py +3 -3
- streamlit/proto/Image_pb2.py +4 -4
- streamlit/proto/Image_pb2.pyi +1 -7
- streamlit/proto/{BokehChart_pb2.py → LabelVisibility_pb2.py} +7 -5
- streamlit/proto/{LabelVisibilityMessage_pb2.pyi → LabelVisibility_pb2.pyi} +14 -14
- streamlit/proto/Markdown_pb2.py +4 -4
- streamlit/proto/Markdown_pb2.pyi +1 -5
- streamlit/proto/Metric_pb2.py +10 -10
- streamlit/proto/Metric_pb2.pyi +3 -3
- streamlit/proto/MultiSelect_pb2.py +4 -4
- streamlit/proto/MultiSelect_pb2.pyi +3 -3
- streamlit/proto/NewSession_pb2.py +38 -26
- streamlit/proto/NewSession_pb2.pyi +42 -8
- streamlit/proto/NumberInput_pb2.py +6 -6
- streamlit/proto/NumberInput_pb2.pyi +3 -3
- streamlit/proto/PlotlyChart_pb2.py +2 -2
- streamlit/proto/Radio_pb2.py +4 -4
- streamlit/proto/Radio_pb2.pyi +3 -3
- streamlit/proto/Selectbox_pb2.py +4 -4
- streamlit/proto/Selectbox_pb2.pyi +3 -6
- streamlit/proto/Slider_pb2.py +8 -8
- streamlit/proto/Slider_pb2.pyi +3 -3
- streamlit/proto/Snow_pb2.pyi +0 -2
- streamlit/proto/TextArea_pb2.py +4 -4
- streamlit/proto/TextArea_pb2.pyi +3 -3
- streamlit/proto/TextInput_pb2.py +6 -6
- streamlit/proto/TextInput_pb2.pyi +3 -3
- streamlit/proto/TimeInput_pb2.py +4 -4
- streamlit/proto/TimeInput_pb2.pyi +3 -3
- streamlit/proto/Video_pb2.py +2 -2
- streamlit/static/index.html +2 -2
- streamlit/static/manifest.json +324 -309
- streamlit/static/static/css/{index.BUP6fTcR.css → index.C8MrxwGF.css} +1 -1
- streamlit/static/static/js/{ErrorOutline.esm.DC6KVDKK.js → ErrorOutline.esm.CLuz0rSD.js} +1 -1
- streamlit/static/static/js/{FileDownload.esm.Z9hRQIHi.js → FileDownload.esm.CO68LcnZ.js} +1 -1
- streamlit/static/static/js/{FileHelper.DqvW90pm.js → FileHelper.DAXgY6Ug.js} +1 -1
- streamlit/static/static/js/{FormClearHelper.DTFnX0js.js → FormClearHelper.zxJ53Nym.js} +1 -1
- streamlit/static/static/js/{InputInstructions.CdzsN_Va.js → InputInstructions.CCbg8esE.js} +1 -1
- streamlit/static/static/js/{Particles.12xFSjcn.js → Particles.BJw0A-zv.js} +1 -1
- streamlit/static/static/js/{ProgressBar.Dg-oMbWg.js → ProgressBar.BrrHeAEh.js} +2 -2
- streamlit/static/static/js/{StreamlitSyntaxHighlighter.rbzmcipw.js → StreamlitSyntaxHighlighter.DvPLy3zk.js} +1 -1
- streamlit/static/static/js/{TableChart.esm.CzJtGIR-.js → TableChart.esm.BawvAi5p.js} +1 -1
- streamlit/static/static/js/{Toolbar.COH7NaOE.js → Toolbar.CbpscbNb.js} +1 -1
- streamlit/static/static/js/{WidgetLabelHelpIconInline.Dlc8f0Ji.js → WidgetLabelHelpIconInline.DA4S2HFP.js} +1 -1
- streamlit/static/static/js/{base-input.Q-zJLgRK.js → base-input.BKKl2eBF.js} +1 -1
- streamlit/static/static/js/{checkbox.BKgWNdeI.js → checkbox.CB43AKV4.js} +1 -1
- streamlit/static/static/js/{createDownloadLinkElement.6oO-YlYv.js → createDownloadLinkElement.jVwF96ey.js} +1 -1
- streamlit/static/static/js/data-grid-overlay-editor.CxQizSv7.js +1 -0
- streamlit/static/static/js/{downloader.BBXcXdX1.js → downloader.CKlIgsy5.js} +1 -1
- streamlit/static/static/js/{embed.CJzOXYBF.js → embed.BhRb_2n8.js} +1 -1
- streamlit/static/static/js/{es6.CdxPQzwJ.js → es6.DPyfPmWm.js} +2 -2
- streamlit/static/static/js/formatNumber.DtfMnnPx.js +1 -0
- streamlit/static/static/js/{iconPosition.BVScIr6G.js → iconPosition.DkZAlu_k.js} +1 -1
- streamlit/static/static/js/{iframeResizer.contentWindow.D_QHVqPM.js → iframeResizer.contentWindow.l5sQWLra.js} +1 -1
- streamlit/static/static/js/{index.CxoREvnF.js → index.465nmxtO.js} +2 -2
- streamlit/static/static/js/{index.BqbKiDp2.js → index.6J1N4is3.js} +1 -1
- streamlit/static/static/js/{index.CrY1BsL3.js → index.AZ9T4EqJ.js} +1 -1
- streamlit/static/static/js/{index.6DFY6LUF.js → index.BAK0CG1Q.js} +1 -1
- streamlit/static/static/js/{index.BxQxTpWl.js → index.BLD3tJ2C.js} +1 -1
- streamlit/static/static/js/{index.BQnLeHnr.js → index.BUlT_mOL.js} +3 -3
- streamlit/static/static/js/{index.Dud7RRHc.js → index.Bc_FQ4Wb.js} +1 -1
- streamlit/static/static/js/{index.DRoJNzFX.js → index.BpCj2-sQ.js} +1 -1
- streamlit/static/static/js/{index.BED2_zc7.js → index.BzO83wKm.js} +1 -1
- streamlit/static/static/js/index.CAoX2tlo.js +2 -0
- streamlit/static/static/js/{index.bQJYmJ2T.js → index.CBbYMKZp.js} +1 -1
- streamlit/static/static/js/{index.DyfvmNCy.js → index.CL7it7tU.js} +1 -1
- streamlit/static/static/js/{index.BDtN2n7T.js → index.CL_icBXS.js} +1 -1
- streamlit/static/static/js/{index.DAnczAW2.js → index.C_19KWNs.js} +1 -1
- streamlit/static/static/js/index.CaU3Uv_L.js +1 -0
- streamlit/static/static/js/{index.B80gSxrS.js → index.Ccye_uLl.js} +1 -1
- streamlit/static/static/js/{index.YULCxEtm.js → index.CiS4giQ2.js} +1 -1
- streamlit/static/static/js/{index.iXh5nbLZ.js → index.Ck64OQhV.js} +1 -1
- streamlit/static/static/js/{index.D9v2Y8Gk.js → index.CmbqbRMZ.js} +1 -1
- streamlit/static/static/js/{index.DAfIQKfP.js → index.CsEZTo6L.js} +2 -2
- streamlit/static/static/js/{index.BtOoVQt7.js → index.CsIENsKH.js} +1 -1
- streamlit/static/static/js/{index.CUYi3FrD.js → index.Cwg8nWw5.js} +1 -1
- streamlit/static/static/js/{index.GieKl4BG.js → index.D83azq2w.js} +1 -1
- streamlit/static/static/js/{index.CvtybR-u.js → index.DDr-BLbJ.js} +1 -1
- streamlit/static/static/js/{index.CBE2cIbj.js → index.DKoJr0Se.js} +1 -1
- streamlit/static/static/js/{index.DyXcT2tD.js → index.DL_ywOgf.js} +2 -2
- streamlit/static/static/js/{index.BiCbrx53.js → index.DR6V0uBJ.js} +1 -1
- streamlit/static/static/js/index.DZOGT9vX.js +1 -0
- streamlit/static/static/js/{index.BSpYHDvk.js → index.Dac9Jib-.js} +1 -1
- streamlit/static/static/js/{index.DCe7fo-m.js → index.DiBeetOH.js} +1 -1
- streamlit/static/static/js/{index.DrcbvB2t.js → index.DjuMEZ6m.js} +1 -1
- streamlit/static/static/js/{index.DU68jVpM.js → index.DmWUXdjc.js} +5 -5
- streamlit/static/static/js/{index._1zqETQ9.js → index.DpSc4e1j.js} +1 -1
- streamlit/static/static/js/{index.Biyf9aUg.js → index.DzdPUxsx.js} +2 -2
- streamlit/static/static/js/{index.C5oqIM3a.js → index.FioS1Y9m.js} +1 -1
- streamlit/static/static/js/{index.DZmBuE3z.js → index.L9pOjBEn.js} +3 -3
- streamlit/static/static/js/{index.DAyGxxdm.js → index.LjqoQCm5.js} +3 -3
- streamlit/static/static/js/{index.mSdC1FV6.js → index.OizPL4jg.js} +1 -1
- streamlit/static/static/js/{index.BSYebegS.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.BqxwnMem.js → index.YutgmD9x.js} +2 -2
- streamlit/static/static/js/{index.nL1fkE1D.js → index.b_f-McZ5.js} +1 -1
- streamlit/static/static/js/{index.y-pa6LIX.js → index.e6Ry6-Ft.js} +1 -1
- streamlit/static/static/js/index.hnu9U-5g.js +1 -0
- streamlit/static/static/js/{index.D6OexhdL.js → index.rvbQETlC.js} +1 -1
- streamlit/static/static/js/index.w7yKy9fh.js +6 -0
- streamlit/static/static/js/{index.BxMkW82k.js → index.y0h42OXL.js} +1 -1
- streamlit/static/static/js/{index.CPc_uZux.js → index.y5HxPwg9.js} +42 -42
- streamlit/static/static/js/{index.DNfyKqhQ.js → index.yHLCvUGh.js} +1 -1
- streamlit/static/static/js/{input.BcC6sPE_.js → input.CAtwSQ27.js} +1 -1
- streamlit/static/static/js/{main.TU5_aabd.js → main.VeMVx6VI.js} +1 -1
- streamlit/static/static/js/{memory.By_OTlI4.js → memory.CxS_lIUn.js} +1 -1
- streamlit/static/static/js/number-overlay-editor.CoqRgZW_.js +9 -0
- streamlit/static/static/js/{pandasStylerUtils.3IiIKU9-.js → pandasStylerUtils.DGWgd5sM.js} +1 -1
- streamlit/static/static/js/{sandbox.DnxTbWzV.js → sandbox.2mSqEau0.js} +1 -1
- streamlit/static/static/js/sprintfjs.CsoVVZ9k.js +1 -0
- streamlit/static/static/js/{styled-components.BeEcZ0vW.js → styled-components.BShfh7J8.js} +1 -1
- streamlit/static/static/js/{throttle.emUyC44c.js → throttle.Fq1DQK4p.js} +1 -1
- streamlit/static/static/js/{timepicker.DZ_ZufYF.js → timepicker.DmyY-qtn.js} +1 -1
- streamlit/static/static/js/{toConsumableArray.DDV1bN1-.js → toConsumableArray.Dvd9AIqV.js} +1 -1
- streamlit/static/static/js/uniqueId.CCajdEK8.js +1 -0
- streamlit/static/static/js/{useBasicWidgetState.DvpdEDYZ.js → useBasicWidgetState.COLQ5AFB.js} +1 -1
- streamlit/static/static/js/{useIntlLocale.BBDLbTq9.js → useIntlLocale.kdIj0ego.js} +1 -1
- streamlit/static/static/js/{useTextInputAutoExpand.BIApLJKn.js → useTextInputAutoExpand.DkuG1C1S.js} +1 -1
- streamlit/static/static/js/{useUpdateUiValue.DQ4RuJNC.js → useUpdateUiValue.-UI_JsjT.js} +1 -1
- streamlit/static/static/js/{useWaveformController.B0olyXLQ.js → useWaveformController.C5PTwL6I.js} +1 -1
- streamlit/static/static/js/{withCalculatedWidth.DYeqePuh.js → withCalculatedWidth.BREyS0pJ.js} +1 -1
- streamlit/static/static/js/{withFullScreenWrapper.DtkUCO_d.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 +65 -2
- {streamlit_nightly-1.53.2.dev20260131.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.53.2.dev20260131.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/RECORD +175 -173
- streamlit/proto/BokehChart_pb2.pyi +0 -56
- streamlit/proto/LabelVisibilityMessage_pb2.py +0 -28
- streamlit/static/static/js/data-grid-overlay-editor.CO0xdNiG.js +0 -1
- streamlit/static/static/js/formatNumber.DB5irY8c.js +0 -1
- streamlit/static/static/js/index.BBTKOM0z.js +0 -6
- streamlit/static/static/js/index.CE2WIFD1.js +0 -2
- streamlit/static/static/js/index.Cpu2p5bH.js +0 -1
- streamlit/static/static/js/index.CtbETWQK.js +0 -2
- streamlit/static/static/js/index.DhRAGiPR.js +0 -1
- streamlit/static/static/js/index.tuFFlbxa.js +0 -1
- streamlit/static/static/js/number-overlay-editor.FSRaRpbU.js +0 -9
- streamlit/static/static/js/sprintf.DpPCfzXw.js +0 -1
- streamlit/static/static/js/uniqueId.DTwvAE-J.js +0 -1
- streamlit/static/static/media/MaterialSymbols-Rounded.C7IFxh57.woff2 +0 -0
- {streamlit_nightly-1.53.2.dev20260131.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.53.2.dev20260131.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.53.2.dev20260131.dist-info → streamlit_nightly-1.53.2.dev20260202.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{V as Q,e as Z,bw as me,bx as ge,z as he,r as d,l as ye,by as k,aj as _,j as A,aM as pe,bz as H,bA as Ee,a0 as be,a1 as Fe,o as Ce,$ as we,aL as Se,n as Ne,S as Oe}from"./index.CPc_uZux.js";import{bB as nr}from"./index.CPc_uZux.js";import{w as Ae}from"./withCalculatedWidth.DYeqePuh.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 P,j as U,ay as ge,P as he,b as ve,B as me,ax as q,bP as re,al as Se,ag as be,bt as ye,l as Ce,bQ as Ue,k as we,aj as Me,e as W,V as xe,bu as Ee,p as Ie,ab as Fe,ac as Re,$ as ke,bR as _e,bS as Pe}from"./index.CPc_uZux.js";import{U as ie}from"./UploadFileInfo.Dr-zDST7.js";import{u as Oe}from"./FormClearHelper.DTFnX0js.js";import{P as Te,S as Le}from"./ProgressBar.Dg-oMbWg.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 P(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})=>P(G,{width:e,children:[U(q,{size:"threeXL",color:re.gray60,content:ne}),P(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 P(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 Pe({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)},[]),O=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=O(c);W(g)||g.status.type!=="uploading"||T(g.id,g.setStatus({type:"uploaded",fileId:u.fileId,fileUrls:u}))},[O,T]),K=n.useCallback((c,u)=>{const g=O(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}))},[O,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=O(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))},[O,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 Oe({element:e,widgetMgr:a,onFormCleared:pe}),P(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?P(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...":P(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,bY as Le,bS as De,bR 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.CPc_uZux.js";import{u as Ge}from"./useWaveformController.B0olyXLQ.js";import{T as qe,a as ce}from"./Toolbar.COH7NaOE.js";import{u as Ye,F as Ke}from"./FormClearHelper.DTFnX0js.js";import{c as Je}from"./createDownloadLinkElement.6oO-YlYv.js";import{E as Qe}from"./urls.BwSlolu9.js";import{F as Ze,D as et}from"./FileDownload.esm.Z9hRQIHi.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=Je({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 Ye({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:Qe,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:Y,approve:K,cancel:J,playback:{play:Q,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),J(),a&&o.setFileUploaderStateValue(e,{},{fromUi:!0},i),y&&B)try{await r.deleteFile(B)}catch{}F(f)&&URL.revokeObjectURL(f)},[B,m,r,J,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 Ke;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 Q())}catch{h(!0)}},[P,T,Z,Q,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 Y();await K(a)}catch{h(!0)}},[K,Y]),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};
|