streamlit-nightly 1.39.1.dev20241105__py2.py3-none-any.whl → 1.40.1.dev20241106__py2.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/elements/lib/built_in_chart_utils.py +50 -10
- streamlit/elements/vega_charts.py +15 -8
- streamlit/static/asset-manifest.json +5 -5
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/1086.f6ccb4bb.chunk.js +5 -0
- streamlit/static/static/js/{245.f99a075b.chunk.js → 245.fb265e78.chunk.js} +1 -1
- streamlit/static/static/js/{3224.925d380f.chunk.js → 3224.e7dfcbee.chunk.js} +1 -1
- streamlit/static/static/js/{main.61a89bda.js → main.971cb93d.js} +2 -2
- {streamlit_nightly-1.39.1.dev20241105.dist-info → streamlit_nightly-1.40.1.dev20241106.dist-info}/METADATA +2 -2
- {streamlit_nightly-1.39.1.dev20241105.dist-info → streamlit_nightly-1.40.1.dev20241106.dist-info}/RECORD +15 -15
- streamlit/static/static/js/1086.93ecee4c.chunk.js +0 -5
- /streamlit/static/static/js/{main.61a89bda.js.LICENSE.txt → main.971cb93d.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.39.1.dev20241105.data → streamlit_nightly-1.40.1.dev20241106.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.39.1.dev20241105.dist-info → streamlit_nightly-1.40.1.dev20241106.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.39.1.dev20241105.dist-info → streamlit_nightly-1.40.1.dev20241106.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.39.1.dev20241105.dist-info → streamlit_nightly-1.40.1.dev20241106.dist-info}/top_level.txt +0 -0
@@ -140,7 +140,7 @@ def generate_chart(
|
|
140
140
|
height: int | None = None,
|
141
141
|
# Bar & Area charts only:
|
142
142
|
stack: bool | ChartStackType | None = None,
|
143
|
-
) -> tuple[alt.Chart, AddRowsMetadata]:
|
143
|
+
) -> tuple[alt.Chart | alt.LayerChart, AddRowsMetadata]:
|
144
144
|
"""Function to use the chart's type, data columns and indices to figure out the chart's spec."""
|
145
145
|
import altair as alt
|
146
146
|
|
@@ -208,15 +208,10 @@ def generate_chart(
|
|
208
208
|
)
|
209
209
|
|
210
210
|
# Offset encoding only works for Altair >= 5.0.0
|
211
|
-
|
212
|
-
|
213
|
-
)
|
214
|
-
|
215
|
-
if (
|
216
|
-
is_altair_version_offset_compatible
|
217
|
-
and stack is False
|
218
|
-
and color_column is not None
|
219
|
-
):
|
211
|
+
is_altair_version_5_or_greater = not type_util.is_altair_version_less_than("5.0.0")
|
212
|
+
# Set up offset encoding (creates grouped/non-stacked bar charts, so only applicable
|
213
|
+
# when stack=False).
|
214
|
+
if is_altair_version_5_or_greater and stack is False and color_column is not None:
|
220
215
|
x_offset, y_offset = _get_offset_encoding(chart_type, color_column)
|
221
216
|
chart = chart.encode(xOffset=x_offset, yOffset=y_offset)
|
222
217
|
|
@@ -249,9 +244,54 @@ def generate_chart(
|
|
249
244
|
)
|
250
245
|
)
|
251
246
|
|
247
|
+
if (
|
248
|
+
chart_type is ChartType.LINE
|
249
|
+
and x_column is not None
|
250
|
+
# This is using the new selection API that was added in Altair 5.0.0
|
251
|
+
and is_altair_version_5_or_greater
|
252
|
+
):
|
253
|
+
return _add_improved_hover_tooltips(
|
254
|
+
chart, x_column, width, height
|
255
|
+
).interactive(), add_rows_metadata
|
256
|
+
|
252
257
|
return chart.interactive(), add_rows_metadata
|
253
258
|
|
254
259
|
|
260
|
+
def _add_improved_hover_tooltips(
|
261
|
+
chart: alt.Chart, x_column: str, width: int | None, height: int | None
|
262
|
+
) -> alt.LayerChart:
|
263
|
+
"""Adds improved hover tooltips to an existing line chart."""
|
264
|
+
|
265
|
+
import altair as alt
|
266
|
+
|
267
|
+
# Create a selection that chooses the nearest point & selects based on x-value
|
268
|
+
nearest = alt.selection_point(
|
269
|
+
nearest=True,
|
270
|
+
on="pointerover",
|
271
|
+
fields=[x_column],
|
272
|
+
empty=False,
|
273
|
+
clear="pointerout",
|
274
|
+
)
|
275
|
+
|
276
|
+
# Draw points on the line, and highlight based on selection
|
277
|
+
points = (
|
278
|
+
chart.mark_point(filled=True, size=65)
|
279
|
+
.encode(opacity=alt.condition(nearest, alt.value(1), alt.value(0)))
|
280
|
+
.add_params(nearest)
|
281
|
+
)
|
282
|
+
|
283
|
+
layer_chart = (
|
284
|
+
alt.layer(chart, points)
|
285
|
+
.configure_legend(symbolType="stroke")
|
286
|
+
.properties(
|
287
|
+
width=width or 0,
|
288
|
+
height=height or 0,
|
289
|
+
)
|
290
|
+
)
|
291
|
+
|
292
|
+
return cast(alt.LayerChart, layer_chart)
|
293
|
+
|
294
|
+
|
255
295
|
def prep_chart_data_for_add_rows(
|
256
296
|
data: Data,
|
257
297
|
add_rows_metadata: AddRowsMetadata,
|
@@ -322,7 +322,9 @@ def _marshall_chart_data(
|
|
322
322
|
proto.data.data = dataframe_util.convert_anything_to_arrow_bytes(data)
|
323
323
|
|
324
324
|
|
325
|
-
def _convert_altair_to_vega_lite_spec(
|
325
|
+
def _convert_altair_to_vega_lite_spec(
|
326
|
+
altair_chart: alt.Chart | alt.LayerChart,
|
327
|
+
) -> VegaLiteSpec:
|
326
328
|
"""Convert an Altair chart object to a Vega-Lite chart spec."""
|
327
329
|
import altair as alt
|
328
330
|
|
@@ -449,8 +451,8 @@ def _parse_selection_mode(
|
|
449
451
|
for selection_name in selection_mode:
|
450
452
|
if selection_name not in all_selection_params:
|
451
453
|
raise StreamlitAPIException(
|
452
|
-
f"Selection parameter '{selection_name}' is not defined in the chart
|
453
|
-
f"Available selection parameters are: {all_selection_params}."
|
454
|
+
f"Selection parameter '{selection_name}' is not defined in the chart "
|
455
|
+
f"spec. Available selection parameters are: {all_selection_params}."
|
454
456
|
)
|
455
457
|
return sorted(selection_mode)
|
456
458
|
|
@@ -1219,7 +1221,8 @@ class VegaChartsMixin:
|
|
1219
1221
|
# Offset encodings (used for non-stacked/grouped bar charts) are not supported in Altair < 5.0.0
|
1220
1222
|
if type_util.is_altair_version_less_than("5.0.0") and stack is False:
|
1221
1223
|
raise StreamlitAPIException(
|
1222
|
-
"Streamlit does not support non-stacked (grouped) bar charts with
|
1224
|
+
"Streamlit does not support non-stacked (grouped) bar charts with "
|
1225
|
+
"Altair 4.x. Please upgrade to Version 5."
|
1223
1226
|
)
|
1224
1227
|
|
1225
1228
|
bar_chart_type = (
|
@@ -1784,7 +1787,7 @@ class VegaChartsMixin:
|
|
1784
1787
|
|
1785
1788
|
def _altair_chart(
|
1786
1789
|
self,
|
1787
|
-
altair_chart: alt.Chart,
|
1790
|
+
altair_chart: alt.Chart | alt.LayerChart,
|
1788
1791
|
use_container_width: bool = False,
|
1789
1792
|
theme: Literal["streamlit"] | None = "streamlit",
|
1790
1793
|
key: Key | None = None,
|
@@ -1799,7 +1802,8 @@ class VegaChartsMixin:
|
|
1799
1802
|
|
1800
1803
|
if type_util.is_altair_version_less_than("5.0.0") and on_select != "ignore":
|
1801
1804
|
raise StreamlitAPIException(
|
1802
|
-
"Streamlit does not support selections with Altair 4.x. Please upgrade
|
1805
|
+
"Streamlit does not support selections with Altair 4.x. Please upgrade "
|
1806
|
+
"to Version 5. "
|
1803
1807
|
"If you would like to use Altair 4.x with selections, please upvote "
|
1804
1808
|
"this [Github issue](https://github.com/streamlit/streamlit/issues/8516)."
|
1805
1809
|
)
|
@@ -1835,12 +1839,15 @@ class VegaChartsMixin:
|
|
1835
1839
|
|
1836
1840
|
if theme not in ["streamlit", None]:
|
1837
1841
|
raise StreamlitAPIException(
|
1838
|
-
f'You set theme="{theme}" while Streamlit charts only support
|
1842
|
+
f'You set theme="{theme}" while Streamlit charts only support '
|
1843
|
+
"theme=”streamlit” or theme=None to fallback to the default "
|
1844
|
+
"library theme."
|
1839
1845
|
)
|
1840
1846
|
|
1841
1847
|
if on_select not in ["ignore", "rerun"] and not callable(on_select):
|
1842
1848
|
raise StreamlitAPIException(
|
1843
|
-
f"You have passed {on_select} to `on_select`. But only 'ignore',
|
1849
|
+
f"You have passed {on_select} to `on_select`. But only 'ignore', "
|
1850
|
+
"'rerun', or a callable is supported."
|
1844
1851
|
)
|
1845
1852
|
|
1846
1853
|
key = to_key(key)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.a1bc16b2.css",
|
4
|
-
"main.js": "./static/js/main.
|
4
|
+
"main.js": "./static/js/main.971cb93d.js",
|
5
5
|
"static/js/6679.265ca09c.chunk.js": "./static/js/6679.265ca09c.chunk.js",
|
6
6
|
"static/js/9464.7e9a3c0a.chunk.js": "./static/js/9464.7e9a3c0a.chunk.js",
|
7
7
|
"static/js/9077.721329d6.chunk.js": "./static/js/9077.721329d6.chunk.js",
|
@@ -19,13 +19,13 @@
|
|
19
19
|
"static/js/4827.bf6d34b0.chunk.js": "./static/js/4827.bf6d34b0.chunk.js",
|
20
20
|
"static/js/8237.86c539f3.chunk.js": "./static/js/8237.86c539f3.chunk.js",
|
21
21
|
"static/js/5828.f8572ba4.chunk.js": "./static/js/5828.f8572ba4.chunk.js",
|
22
|
-
"static/js/3224.
|
22
|
+
"static/js/3224.e7dfcbee.chunk.js": "./static/js/3224.e7dfcbee.chunk.js",
|
23
23
|
"static/js/9060.1ec8dc2b.chunk.js": "./static/js/9060.1ec8dc2b.chunk.js",
|
24
24
|
"static/js/5625.a2d9a416.chunk.js": "./static/js/5625.a2d9a416.chunk.js",
|
25
25
|
"static/js/6141.d2879825.chunk.js": "./static/js/6141.d2879825.chunk.js",
|
26
26
|
"static/js/4103.a5610a9d.chunk.js": "./static/js/4103.a5610a9d.chunk.js",
|
27
|
-
"static/js/1086.
|
28
|
-
"static/js/245.
|
27
|
+
"static/js/1086.f6ccb4bb.chunk.js": "./static/js/1086.f6ccb4bb.chunk.js",
|
28
|
+
"static/js/245.fb265e78.chunk.js": "./static/js/245.fb265e78.chunk.js",
|
29
29
|
"static/js/7193.534e7da1.chunk.js": "./static/js/7193.534e7da1.chunk.js",
|
30
30
|
"static/js/3682.8ecb602d.chunk.js": "./static/js/3682.8ecb602d.chunk.js",
|
31
31
|
"static/js/8790.0b98f286.chunk.js": "./static/js/8790.0b98f286.chunk.js",
|
@@ -157,6 +157,6 @@
|
|
157
157
|
},
|
158
158
|
"entrypoints": [
|
159
159
|
"static/css/main.a1bc16b2.css",
|
160
|
-
"static/js/main.
|
160
|
+
"static/js/main.971cb93d.js"
|
161
161
|
]
|
162
162
|
}
|
streamlit/static/index.html
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.971cb93d.js"></script><link href="./static/css/main.a1bc16b2.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[1086],{68035:(e,t,r)=>{r.d(t,{A:()=>c});r(58878);var n=r(25571),o=r(78286),i=r(89653);const a=r(60667).i7`
|
2
|
+
50% {
|
3
|
+
color: rgba(0, 0, 0, 0);
|
4
|
+
}
|
5
|
+
`,s=(0,i.A)("span",{target:"edlqvik0"})((e=>{let{includeDot:t,shouldBlink:r,theme:n}=e;return{...t?{"&::before":{opacity:1,content:'"\u2022"',animation:"none",color:n.colors.gray,margin:`0 ${n.spacing.twoXS}`}}:{},...r?{color:n.colors.red,animationName:`${a}`,animationDuration:"0.5s",animationIterationCount:5}:{}}}),"");var l=r(90782);const c=e=>{let{dirty:t,value:r,inForm:i,maxLength:a,className:c,type:u="single",allowEnterToSubmit:d=!0}=e;const p=[],f=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];p.push((0,l.jsx)(s,{includeDot:p.length>0,shouldBlink:t,children:e},p.length))};if(d){const e=i?"submit form":"apply";if("multiline"===u){f(`Press ${(0,n.u_)()?"\u2318":"Ctrl"}+Enter to ${e}`)}else"single"===u&&f(`Press Enter to ${e}`)}return a&&("chat"!==u||t)&&f(`${r.length}/${a}`,t&&r.length>=a),(0,l.jsx)(o.tp,{"data-testid":"InputInstructions",className:c,children:p})}},1086:(e,t,r)=>{r.r(t),r.d(t,{default:()=>v});var n=r(58878),o=r(8151),i=r(68102),a=r(68622),s=n.forwardRef((function(e,t){return n.createElement(a.I,(0,i.A)({iconAttrs:{fill:"currentColor",xmlns:"http://www.w3.org/2000/svg"},iconVerticalAlign:"middle",iconViewBox:"0 0 24 24"},e,{ref:t}),n.createElement("rect",{width:24,height:24,fill:"none"}),n.createElement("path",{d:"M3 5.51v3.71c0 .46.31.86.76.97L11 12l-7.24 1.81c-.45.11-.76.51-.76.97v3.71c0 .72.73 1.2 1.39.92l15.42-6.49c.82-.34.82-1.5 0-1.84L4.39 4.58C3.73 4.31 3 4.79 3 5.51z"}))}));s.displayName="Send";var l=r(94928),c=r(64611),u=r(68035),d=r(89653),p=r(16795);const f=(0,d.A)("div",{target:"e1d2x3se4"})((e=>{var t;let{theme:r,width:n}=e;return{borderRadius:r.radii.default,display:"flex",backgroundColor:null!==(t=r.colors.widgetBackgroundColor)&&void 0!==t?t:r.colors.secondaryBg,width:`${n}px`}}),""),h=(0,d.A)("div",{target:"e1d2x3se3"})((e=>{let{theme:t}=e;return{backgroundColor:t.colors.transparent,position:"relative",flexGrow:1,borderRadius:t.radii.default,display:"flex",alignItems:"center"}}),""),y=(0,d.A)("button",{target:"e1d2x3se2"})((e=>{let{theme:t,disabled:r,extended:n}=e;const o=(0,p.iq)(t),[i,a]=o?[t.colors.gray60,t.colors.gray80]:[t.colors.gray80,t.colors.gray40];return{border:"none",backgroundColor:t.colors.transparent,borderTopRightRadius:n?"0":t.radii.default,borderTopLeftRadius:n?t.radii.default:"0",borderBottomRightRadius:t.radii.default,display:"inline-flex",alignItems:"center",justifyContent:"center",lineHeight:t.lineHeights.none,margin:t.spacing.none,padding:t.spacing.sm,color:r?i:a,pointerEvents:"auto","&:focus":{outline:"none"},":focus":{outline:"none"},"&:focus-visible":{backgroundColor:o?t.colors.gray10:t.colors.gray90},"&:hover":{backgroundColor:t.colors.primary,color:t.colors.white},"&:disabled, &:disabled:hover, &:disabled:active":{backgroundColor:t.colors.transparent,borderColor:t.colors.transparent,color:t.colors.gray}}}),""),g=(0,d.A)("div",{target:"e1d2x3se1"})({name:"1v03qtz",styles:"display:flex;align-items:flex-end;height:100%;position:absolute;right:0;pointer-events:none"}),b=(0,d.A)("div",{target:"e1d2x3se0"})((e=>{let{theme:t}=e;return{position:"absolute",bottom:"0px",right:`calc(${t.iconSizes.xl} + 2 * ${t.spacing.sm} + ${t.spacing.sm})`}}),"");var m=r(90782);const v=function(e){let{width:t,element:r,widgetMgr:i,fragmentId:a}=e;const d=(0,o.u)(),[p,v]=(0,n.useState)(!1),[x,w]=(0,n.useState)(r.default),[O,j]=(0,n.useState)(0),C=(0,n.useRef)(null),S=(0,n.useRef)({minHeight:0,maxHeight:0}),$=()=>{C.current&&C.current.focus(),x&&(i.setStringTriggerValue(r,x,{fromUi:!0},a),v(!1),w(""),j(0))};(0,n.useEffect)((()=>{if(r.setValue){r.setValue=!1;const e=r.value||"";w(e),v(""!==e)}}),[r]),(0,n.useEffect)((()=>{if(C.current){const{offsetHeight:e}=C.current;S.current.minHeight=e,S.current.maxHeight=6.5*e}}),[C]);const{disabled:A,placeholder:k,maxChars:P}=r,{minHeight:R,maxHeight:E}=S.current,I=!!(O>0&&C.current)&&Math.abs(O-R)>1;return(0,m.jsx)(f,{className:"stChatInput","data-testid":"stChatInput",width:t,children:(0,m.jsxs)(h,{children:[(0,m.jsx)(l.A,{inputRef:C,value:x,placeholder:k,onChange:e=>{const{value:t}=e.target,{maxChars:n}=r;0!==n&&t.length>n||(v(""!==t),w(t),j((()=>{let e=0;const{current:t}=C;if(t){const r=t.placeholder;t.placeholder="",t.style.height="auto",e=t.scrollHeight,t.placeholder=r,t.style.height=""}return e})()))},onKeyDown:e=>{const{metaKey:t,ctrlKey:r,shiftKey:n}=e;(e=>{var t;const{keyCode:r,key:n}=e;return("Enter"===n||13===r||10===r)&&!(!0===(null===(t=e.nativeEvent)||void 0===t?void 0:t.isComposing))})(e)&&!n&&!r&&!t&&(e.preventDefault(),$())},"aria-label":k,disabled:A,rows:1,overrides:{Root:{style:{minHeight:d.sizes.minElementHeight,outline:"none",backgroundColor:d.colors.transparent,borderLeftWidth:d.sizes.borderWidth,borderRightWidth:d.sizes.borderWidth,borderTopWidth:d.sizes.borderWidth,borderBottomWidth:d.sizes.borderWidth,width:`${t}px`}},InputContainer:{style:{backgroundColor:d.colors.transparent}},Input:{props:{"data-testid":"stChatInputTextArea"},style:{lineHeight:d.lineHeights.inputWidget,backgroundColor:d.colors.transparent,"::placeholder":{opacity:"0.7"},height:I?`${O+1}px`:"auto",maxHeight:E?`${E}px`:"none",paddingLeft:d.spacing.sm,paddingBottom:d.spacing.sm,paddingTop:d.spacing.sm,paddingRight:`calc(${d.iconSizes.xl} + 2 * ${d.spacing.sm} + ${d.spacing.sm})`}}}}),t>d.breakpoints.hideWidgetDetails&&(0,m.jsx)(b,{children:(0,m.jsx)(u.A,{dirty:p,value:x,maxLength:P,type:"chat",inForm:!1})}),(0,m.jsx)(g,{children:(0,m.jsx)(y,{onClick:$,disabled:!p||A,extended:I,"data-testid":"stChatInputSubmitButton",children:(0,m.jsx)(c.A,{content:s,size:"xl",color:"inherit"})})})]})})}},94928:(e,t,r)=>{r.d(t,{A:()=>$});var n=r(58878),o=r(35331),i=r(18648),a=r(92850),s=r(57224),l=r(81301);function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){d(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function d(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var p=(0,s.I4)("div",(function(e){return u(u({},(0,l.vt)(u(u({$positive:!1},e),{},{$hasIconTrailing:!1}))),{},{width:e.$resize?"fit-content":"100%"})}));p.displayName="StyledTextAreaRoot",p.displayName="StyledTextAreaRoot";var f=(0,s.I4)("div",(function(e){return(0,l.EO)(u({$positive:!1},e))}));f.displayName="StyledTextareaContainer",f.displayName="StyledTextareaContainer";var h=(0,s.I4)("textarea",(function(e){return u(u({},(0,l.n)(e)),{},{resize:e.$resize||"none"})}));function y(e){return y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},y(e)}function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},g.apply(this,arguments)}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,i=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(l){s=!0,o=l}finally{try{a||null==r.return||r.return()}finally{if(s)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"===typeof e)return m(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return m(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function x(e,t){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},x(e,t)}function w(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=j(e);if(t){var o=j(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===y(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return O(e)}(this,r)}}function O(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function j(e){return j=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},j(e)}function C(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}h.displayName="StyledTextarea",h.displayName="StyledTextarea";var S=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&x(e,t)}(c,e);var t,r,s,l=w(c);function c(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return C(O(e=l.call.apply(l,[this].concat(r))),"state",{isFocused:e.props.autoFocus||!1}),C(O(e),"onFocus",(function(t){e.setState({isFocused:!0}),e.props.onFocus(t)})),C(O(e),"onBlur",(function(t){e.setState({isFocused:!1}),e.props.onBlur(t)})),e}return t=c,(r=[{key:"render",value:function(){var e=this.props.overrides,t=void 0===e?{}:e,r=b((0,o._O)(t.Root,p),2),s=r[0],l=r[1],c=(0,o.Qp)({Input:{component:h},InputContainer:{component:f}},t);return n.createElement(s,g({"data-baseweb":"textarea",$isFocused:this.state.isFocused,$isReadOnly:this.props.readOnly,$disabled:this.props.disabled,$error:this.props.error,$positive:this.props.positive,$required:this.props.required,$resize:this.props.resize},l),n.createElement(i.A,g({},this.props,{type:a.GT.textarea,overrides:c,onFocus:this.onFocus,onBlur:this.onBlur,resize:this.props.resize})))}}])&&v(t.prototype,r),s&&v(t,s),Object.defineProperty(t,"prototype",{writable:!1}),c}(n.Component);C(S,"defaultProps",{autoFocus:!1,disabled:!1,readOnly:!1,error:!1,name:"",onBlur:function(){},onChange:function(){},onKeyDown:function(){},onKeyPress:function(){},onKeyUp:function(){},onFocus:function(){},overrides:{},placeholder:"",required:!1,rows:3,size:a.SK.default});const $=S}}]);
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[245],{245:(e,t,r)=>{r.r(t),r.d(t,{default:()=>G});var o=r(58878),i=r(8151),n=r(35331),a=r(57224);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e){var t=e.$disabled,r=e.$checked,o=e.$isIndeterminate,i=e.$error,n=e.$isHovered,a=e.$isActive,l=e.$theme.colors;return t?r||o?l.tickFillDisabled:l.tickFill:i&&(o||r)?a?l.tickFillErrorSelectedHoverActive:n?l.tickFillErrorSelectedHover:l.tickFillErrorSelected:i?a?l.tickFillErrorHoverActive:n?l.tickFillErrorHover:l.tickFillError:o||r?a?l.tickFillSelectedHoverActive:n?l.tickFillSelectedHover:l.tickFillSelected:a?l.tickFillActive:n?l.tickFillHover:l.tickFill}function u(e){var t=e.$disabled,r=e.$theme.colors;return t?r.contentSecondary:r.contentPrimary}var g=(0,a.I4)("label",(function(e){var t=e.$disabled,r=e.$labelPlacement;return{flexDirection:"top"===r||"bottom"===r?"column":"row",display:"flex",alignItems:"top"===r||"bottom"===r?"center":"flex-start",cursor:t?"not-allowed":"pointer",userSelect:"none"}}));g.displayName="Root",g.displayName="Root";var p=(0,a.I4)("span",(function(e){var t=e.$checked,r=e.$disabled,o=e.$error,i=e.$isIndeterminate,n=e.$theme,a=e.$isFocusVisible,l=n.sizing,c=n.animation,s=r?n.colors.tickMarkFillDisabled:o?n.colors.tickMarkFillError:n.colors.tickMarkFill,u=encodeURIComponent('\n <svg width="14" height="4" viewBox="0 0 14 4" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M14 0.5H0V3.5H14V0.5Z" fill="'.concat(s,'"/>\n </svg>\n ')),g=encodeURIComponent('\n <svg width="17" height="13" viewBox="0 0 17 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M6.50002 12.6L0.400024 6.60002L2.60002 4.40002L6.50002 8.40002L13.9 0.900024L16.1 3.10002L6.50002 12.6Z" fill="'.concat(s,'"/>\n </svg>\n ')),p=n.borders.checkboxBorderRadius,h=function(e){var t=e.$disabled,r=e.$checked,o=e.$error,i=e.$isIndeterminate,n=e.$theme,a=e.$isFocusVisible,l=n.colors;return t?l.tickFillDisabled:r||i?"transparent":o?l.borderNegative:a?l.borderSelected:l.tickBorder}(e);return{flex:"0 0 auto",transitionDuration:c.timing200,transitionTimingFunction:c.easeOutCurve,transitionProperty:"background-image, border-color, background-color",width:l.scale700,height:l.scale700,left:"4px",top:"4px",boxSizing:"border-box",borderLeftStyle:"solid",borderRightStyle:"solid",borderTopStyle:"solid",borderBottomStyle:"solid",borderLeftWidth:"3px",borderRightWidth:"3px",borderTopWidth:"3px",borderBottomWidth:"3px",borderLeftColor:h,borderRightColor:h,borderTopColor:h,borderBottomColor:h,borderTopLeftRadius:p,borderTopRightRadius:p,borderBottomRightRadius:p,borderBottomLeftRadius:p,outline:a&&t?"3px solid ".concat(n.colors.accent):"none",display:"inline-block",verticalAlign:"middle",backgroundImage:i?"url('data:image/svg+xml,".concat(u,"');"):t?"url('data:image/svg+xml,".concat(g,"');"):null,backgroundColor:d(e),backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"contain",marginTop:n.sizing.scale0,marginBottom:n.sizing.scale0,marginLeft:n.sizing.scale0,marginRight:n.sizing.scale0}}));p.displayName="Checkmark",p.displayName="Checkmark";var h=(0,a.I4)("div",(function(e){var t=e.$theme.typography;return c(c(c({verticalAlign:"middle"},function(e){var t,r=e.$labelPlacement,o=void 0===r?"":r,i=e.$theme,n=i.sizing.scale300;switch(o){case"top":t="Bottom";break;case"bottom":t="Top";break;case"left":t="Right";break;default:t="Left"}return"rtl"===i.direction&&"Left"===t?t="Right":"rtl"===i.direction&&"Right"===t&&(t="Left"),s({},"padding".concat(t),n)}(e)),{},{color:u(e)},t.LabelMedium),{},{lineHeight:"24px"})}));h.displayName="Label",h.displayName="Label";var f=(0,a.I4)("input",{opacity:0,width:0,height:0,overflow:"hidden",margin:0,padding:0,position:"absolute"});f.displayName="Input",f.displayName="Input";var m=(0,a.I4)("div",(function(e){var t=e.$theme.colors.toggleFill;return e.$disabled?t=e.$theme.colors.toggleFillDisabled:e.$checked&&e.$error?t=e.$theme.colors.tickFillErrorSelected:e.$checked&&(t=e.$theme.colors.toggleFillChecked),{backgroundColor:t,borderTopLeftRadius:"50%",borderTopRightRadius:"50%",borderBottomRightRadius:"50%",borderBottomLeftRadius:"50%",boxShadow:e.$isFocusVisible?"0 0 0 3px ".concat(e.$theme.colors.accent):e.$isHovered&&!e.$disabled?e.$theme.lighting.shadow500:e.$theme.lighting.shadow400,outline:"none",height:e.$theme.sizing.scale700,width:e.$theme.sizing.scale700,transform:e.$checked?"translateX(".concat("rtl"===e.$theme.direction?"-100%":"100%",")"):null,transition:"transform ".concat(e.$theme.animation.timing200)}}));m.displayName="Toggle",m.displayName="Toggle";var b=(0,a.I4)("div",(function(e){var t=e.$theme.colors.toggleTrackFill;return e.$disabled?t=e.$theme.colors.toggleTrackFillDisabled:e.$error&&e.$checked&&(t=e.$theme.colors.tickFillError),{alignItems:"center",backgroundColor:t,borderTopLeftRadius:"7px",borderTopRightRadius:"7px",borderBottomRightRadius:"7px",borderBottomLeftRadius:"7px",display:"flex",height:e.$theme.sizing.scale550,marginTop:e.$theme.sizing.scale200,marginBottom:e.$theme.sizing.scale100,marginLeft:e.$theme.sizing.scale200,marginRight:e.$theme.sizing.scale100,width:e.$theme.sizing.scale1000}}));b.displayName="ToggleTrack",b.displayName="ToggleTrack";var v=Object.freeze({default:"default",toggle:"toggle",toggle_round:"toggle"}),y=Object.freeze({top:"top",right:"right",bottom:"bottom",left:"left"}),k=r(56498);function $(e){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$(e)}function w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},w.apply(this,arguments)}function F(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function x(e,t){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},x(e,t)}function C(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,o=R(e);if(t){var i=R(this).constructor;r=Reflect.construct(o,arguments,i)}else r=o.apply(this,arguments);return function(e,t){if(t&&("object"===$(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return S(e)}(this,r)}}function S(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}function L(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var T=function(e){return e.stopPropagation()},M=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&x(e,t)}(l,e);var t,r,i,a=C(l);function l(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return L(S(e=a.call.apply(a,[this].concat(r))),"state",{isFocused:e.props.autoFocus||!1,isFocusVisible:!1,isHovered:!1,isActive:!1}),L(S(e),"onMouseEnter",(function(t){e.setState({isHovered:!0}),e.props.onMouseEnter(t)})),L(S(e),"onMouseLeave",(function(t){e.setState({isHovered:!1,isActive:!1}),e.props.onMouseLeave(t)})),L(S(e),"onMouseDown",(function(t){e.setState({isActive:!0}),e.props.onMouseDown(t)})),L(S(e),"onMouseUp",(function(t){e.setState({isActive:!1}),e.props.onMouseUp(t)})),L(S(e),"onFocus",(function(t){e.setState({isFocused:!0}),e.props.onFocus(t),(0,k.pP)(t)&&e.setState({isFocusVisible:!0})})),L(S(e),"onBlur",(function(t){e.setState({isFocused:!1}),e.props.onBlur(t),!1!==e.state.isFocusVisible&&e.setState({isFocusVisible:!1})})),e}return t=l,(r=[{key:"componentDidMount",value:function(){var e=this.props,t=e.autoFocus,r=e.inputRef;t&&r.current&&r.current.focus()}},{key:"render",value:function(){var e=this.props,t=e.overrides,r=void 0===t?{}:t,i=e.onChange,a=e.labelPlacement,l=void 0===a?this.props.checkmarkType===v.toggle?"left":"right":a,c=e.inputRef,s=e.isIndeterminate,d=e.error,u=e.disabled,y=e.value,k=e.name,$=e.type,F=e.checked,x=e.children,C=e.required,S=e.title,R=r.Root,L=r.Checkmark,M=r.Label,O=r.Input,P=r.Toggle,j=r.ToggleTrack,I=(0,n.De)(R)||g,B=(0,n.De)(L)||p,E=(0,n.De)(M)||h,D=(0,n.De)(O)||f,W=(0,n.De)(P)||m,H=(0,n.De)(j)||b,z={onChange:i,onFocus:this.onFocus,onBlur:this.onBlur},V={onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp},_={$isFocused:this.state.isFocused,$isFocusVisible:this.state.isFocusVisible,$isHovered:this.state.isHovered,$isActive:this.state.isActive,$error:d,$checked:F,$isIndeterminate:s,$required:C,$disabled:u,$value:y},A=x&&o.createElement(E,w({$labelPlacement:l},_,(0,n.PC)(M)),this.props.containsInteractiveElement?o.createElement("div",{onClick:function(e){return e.preventDefault()}},x):x);return o.createElement(I,w({"data-baseweb":"checkbox",title:S||null,$labelPlacement:l},_,V,(0,n.PC)(R)),("top"===l||"left"===l)&&A,this.props.checkmarkType===v.toggle?o.createElement(H,w({},_,(0,n.PC)(j)),o.createElement(W,w({},_,(0,n.PC)(P)))):o.createElement(B,w({},_,(0,n.PC)(L))),o.createElement(D,w({value:y,name:k,checked:F,required:C,"aria-label":this.props["aria-label"]||this.props.ariaLabel,"aria-checked":s?"mixed":F,"aria-describedby":this.props["aria-describedby"],"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":d||null,"aria-required":C||null,disabled:u,type:$,ref:c,onClick:T},_,z,(0,n.PC)(O))),("bottom"===l||"right"===l)&&A)}}])&&F(t.prototype,r),i&&F(t,i),Object.defineProperty(t,"prototype",{writable:!1}),l}(o.Component);L(M,"defaultProps",{overrides:{},checked:!1,containsInteractiveElement:!1,disabled:!1,autoFocus:!1,isIndeterminate:!1,inputRef:o.createRef(),error:!1,type:"checkbox",checkmarkType:v.default,onChange:function(){},onMouseEnter:function(){},onMouseLeave:function(){},onMouseDown:function(){},onMouseUp:function(){},onFocus:function(){},onBlur:function(){}});const O=M;var P=r(32735),j=r(25571),I=r(29669),B=r(3101),E=r(16795),D=r(93480),W=r(997),H=r(78286),z=r(4629),V=r(90114),_=r(90782);function A(e){var t;let{width:r,element:n,disabled:a,widgetMgr:l,fragmentId:c}=e;const[s,d]=(0,B.t)({getStateFromWidgetMgr:N,getDefaultStateFromProto:U,getCurrStateFromProto:X,updateWidgetMgrState:q,element:n,widgetMgr:l,fragmentId:c}),u=(0,o.useCallback)((e=>{d({value:e.target.checked,fromUi:!0})}),[d]),g=(0,i.u)(),{colors:p,spacing:h,sizes:f}=g,m=(0,E.iq)(g),b=a?p.fadedText40:p.bodyText;return(0,_.jsx)(V.p,{className:"row-widget stCheckbox","data-testid":"stCheckbox",width:r,children:(0,_.jsx)(O,{checked:s,disabled:a,onChange:u,"aria-label":n.label,checkmarkType:n.type===I.Sc.StyleType.TOGGLE?v.toggle:v.default,labelPlacement:y.right,overrides:{Root:{style:e=>{let{$isFocusVisible:t}=e;return{marginBottom:h.none,marginTop:h.none,backgroundColor:t?p.darkenedBgMix25:"",display:"flex",alignItems:"start"}}},Toggle:{style:e=>{let{$checked:t}=e,r=m?p.bgColor:p.bodyText;return a&&(r=m?p.gray70:p.gray90),{width:`calc(${f.checkbox} - ${g.spacing.twoXS})`,height:`calc(${f.checkbox} - ${g.spacing.twoXS})`,transform:t?`translateX(${f.checkbox})`:"",backgroundColor:r,boxShadow:""}}},ToggleTrack:{style:e=>{let{$checked:t,$isHovered:r}=e,o=p.fadedText40;return r&&!a&&(o=p.fadedText20),t&&!a&&(o=p.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:g.spacing.twoXS,paddingLeft:g.spacing.threeXS,paddingRight:g.spacing.threeXS,width:`calc(2 * ${f.checkbox})`,minWidth:`calc(2 * ${f.checkbox})`,height:f.checkbox,minHeight:f.checkbox,borderBottomLeftRadius:g.radii.full,borderTopLeftRadius:g.radii.full,borderBottomRightRadius:g.radii.full,borderTopRightRadius:g.radii.full,backgroundColor:o}}},Checkmark:{style:e=>{let{$isFocusVisible:t,$checked:r}=e;const o=r&&!a?p.primary:p.fadedText40;return{outline:0,width:f.checkbox,height:f.checkbox,marginTop:g.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:t&&r?`0 0 0 0.2rem ${(0,P.No)(p.primary,.5)}`:"",borderLeftWidth:f.borderWidth,borderRightWidth:f.borderWidth,borderTopWidth:f.borderWidth,borderBottomWidth:f.borderWidth,borderLeftColor:o,borderRightColor:o,borderTopColor:o,borderBottomColor:o}}},Label:{style:{position:"relative",color:b}}},children:(0,_.jsxs)(V.x,{visibility:(0,j.yv)(null===(t=n.labelVisibility)||void 0===t?void 0:t.value),"data-testid":"stWidgetLabel",children:[(0,_.jsx)(z.Ay,{source:n.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),n.help&&(0,_.jsx)(H.Cl,{color:b,children:(0,_.jsx)(D.A,{content:n.help,placement:W.W.TOP_RIGHT})})]})})})}function N(e,t){return e.getBoolValue(t)}function U(e){var t;return null!==(t=e.default)&&void 0!==t?t:null}function X(e){var t;return null!==(t=e.value)&&void 0!==t?t:null}function q(e,t,r,o){t.setBoolValue(e,r.value,{fromUi:r.fromUi},o)}const G=(0,o.memo)(A)},34752:(e,t,r)=>{r.d(t,{X:()=>a,o:()=>n});var o=r(58878),i=r(25571);class n{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,r){(0,i.se)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,i._L)(t)&&(this.formClearListener=e.addFormClearedListener(t,r),this.lastWidgetMgr=e,this.lastFormId=t))}disconnect(){var e;null===(e=this.formClearListener)||void 0===e||e.disconnect(),this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}}function a(e){let{element:t,widgetMgr:r,onFormCleared:n}=e;(0,o.useEffect)((()=>{if(!(0,i._L)(t.formId))return;const e=r.addFormClearedListener(t.formId,n);return()=>{e.disconnect()}}),[t,r,n])}},3101:(e,t,r)=>{r.d(t,{_:()=>a,t:()=>l});var o=r(58878),i=r(34752),n=r(25571);function a(e){let{getStateFromWidgetMgr:t,getDefaultState:r,updateWidgetMgrState:a,element:l,widgetMgr:c,fragmentId:s,onFormCleared:d}=e;const[u,g]=(0,o.useState)((()=>{var e;return null!==(e=t(c,l))&&void 0!==e?e:r(c,l)})),[p,h]=(0,o.useState)({value:u,fromUi:!1});(0,o.useEffect)((()=>{(0,n.hX)(p)||(h(null),g(p.value),a(l,c,p,s))}),[p,a,l,c,s]);const f=(0,o.useCallback)((()=>{h({value:r(c,l),fromUi:!0}),null===d||void 0===d||d()}),[h,l,r,c,d]);return(0,i.X)({widgetMgr:c,element:l,onFormCleared:f}),[u,h]}function l(e){let{getStateFromWidgetMgr:t,getDefaultStateFromProto:r,getCurrStateFromProto:i,updateWidgetMgrState:n,element:l,widgetMgr:c,fragmentId:s,onFormCleared:d}=e;const u=(0,o.useCallback)(((e,t)=>r(t)),[r]),[g,p]=a({getStateFromWidgetMgr:t,getDefaultState:u,updateWidgetMgrState:n,element:l,widgetMgr:c,fragmentId:s,onFormCleared:d});return(0,o.useEffect)((()=>{l.setValue&&(l.setValue=!1,p({value:i(l),fromUi:!1}))}),[l,i,p]),[g,p]}}}]);
|
1
|
+
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[245],{245:(e,t,r)=>{r.r(t),r.d(t,{default:()=>G});var o=r(58878),i=r(8151),n=r(35331),a=r(57224);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e){var t=e.$disabled,r=e.$checked,o=e.$isIndeterminate,i=e.$error,n=e.$isHovered,a=e.$isActive,l=e.$theme.colors;return t?r||o?l.tickFillDisabled:l.tickFill:i&&(o||r)?a?l.tickFillErrorSelectedHoverActive:n?l.tickFillErrorSelectedHover:l.tickFillErrorSelected:i?a?l.tickFillErrorHoverActive:n?l.tickFillErrorHover:l.tickFillError:o||r?a?l.tickFillSelectedHoverActive:n?l.tickFillSelectedHover:l.tickFillSelected:a?l.tickFillActive:n?l.tickFillHover:l.tickFill}function u(e){var t=e.$disabled,r=e.$theme.colors;return t?r.contentSecondary:r.contentPrimary}var g=(0,a.I4)("label",(function(e){var t=e.$disabled,r=e.$labelPlacement;return{flexDirection:"top"===r||"bottom"===r?"column":"row",display:"flex",alignItems:"top"===r||"bottom"===r?"center":"flex-start",cursor:t?"not-allowed":"pointer",userSelect:"none"}}));g.displayName="Root",g.displayName="Root";var p=(0,a.I4)("span",(function(e){var t=e.$checked,r=e.$disabled,o=e.$error,i=e.$isIndeterminate,n=e.$theme,a=e.$isFocusVisible,l=n.sizing,c=n.animation,s=r?n.colors.tickMarkFillDisabled:o?n.colors.tickMarkFillError:n.colors.tickMarkFill,u=encodeURIComponent('\n <svg width="14" height="4" viewBox="0 0 14 4" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M14 0.5H0V3.5H14V0.5Z" fill="'.concat(s,'"/>\n </svg>\n ')),g=encodeURIComponent('\n <svg width="17" height="13" viewBox="0 0 17 13" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M6.50002 12.6L0.400024 6.60002L2.60002 4.40002L6.50002 8.40002L13.9 0.900024L16.1 3.10002L6.50002 12.6Z" fill="'.concat(s,'"/>\n </svg>\n ')),p=n.borders.checkboxBorderRadius,h=function(e){var t=e.$disabled,r=e.$checked,o=e.$error,i=e.$isIndeterminate,n=e.$theme,a=e.$isFocusVisible,l=n.colors;return t?l.tickFillDisabled:r||i?"transparent":o?l.borderNegative:a?l.borderSelected:l.tickBorder}(e);return{flex:"0 0 auto",transitionDuration:c.timing200,transitionTimingFunction:c.easeOutCurve,transitionProperty:"background-image, border-color, background-color",width:l.scale700,height:l.scale700,left:"4px",top:"4px",boxSizing:"border-box",borderLeftStyle:"solid",borderRightStyle:"solid",borderTopStyle:"solid",borderBottomStyle:"solid",borderLeftWidth:"3px",borderRightWidth:"3px",borderTopWidth:"3px",borderBottomWidth:"3px",borderLeftColor:h,borderRightColor:h,borderTopColor:h,borderBottomColor:h,borderTopLeftRadius:p,borderTopRightRadius:p,borderBottomRightRadius:p,borderBottomLeftRadius:p,outline:a&&t?"3px solid ".concat(n.colors.accent):"none",display:"inline-block",verticalAlign:"middle",backgroundImage:i?"url('data:image/svg+xml,".concat(u,"');"):t?"url('data:image/svg+xml,".concat(g,"');"):null,backgroundColor:d(e),backgroundRepeat:"no-repeat",backgroundPosition:"center",backgroundSize:"contain",marginTop:n.sizing.scale0,marginBottom:n.sizing.scale0,marginLeft:n.sizing.scale0,marginRight:n.sizing.scale0}}));p.displayName="Checkmark",p.displayName="Checkmark";var h=(0,a.I4)("div",(function(e){var t=e.$theme.typography;return c(c(c({verticalAlign:"middle"},function(e){var t,r=e.$labelPlacement,o=void 0===r?"":r,i=e.$theme,n=i.sizing.scale300;switch(o){case"top":t="Bottom";break;case"bottom":t="Top";break;case"left":t="Right";break;default:t="Left"}return"rtl"===i.direction&&"Left"===t?t="Right":"rtl"===i.direction&&"Right"===t&&(t="Left"),s({},"padding".concat(t),n)}(e)),{},{color:u(e)},t.LabelMedium),{},{lineHeight:"24px"})}));h.displayName="Label",h.displayName="Label";var m=(0,a.I4)("input",{opacity:0,width:0,height:0,overflow:"hidden",margin:0,padding:0,position:"absolute"});m.displayName="Input",m.displayName="Input";var f=(0,a.I4)("div",(function(e){var t=e.$theme.colors.toggleFill;return e.$disabled?t=e.$theme.colors.toggleFillDisabled:e.$checked&&e.$error?t=e.$theme.colors.tickFillErrorSelected:e.$checked&&(t=e.$theme.colors.toggleFillChecked),{backgroundColor:t,borderTopLeftRadius:"50%",borderTopRightRadius:"50%",borderBottomRightRadius:"50%",borderBottomLeftRadius:"50%",boxShadow:e.$isFocusVisible?"0 0 0 3px ".concat(e.$theme.colors.accent):e.$isHovered&&!e.$disabled?e.$theme.lighting.shadow500:e.$theme.lighting.shadow400,outline:"none",height:e.$theme.sizing.scale700,width:e.$theme.sizing.scale700,transform:e.$checked?"translateX(".concat("rtl"===e.$theme.direction?"-100%":"100%",")"):null,transition:"transform ".concat(e.$theme.animation.timing200)}}));f.displayName="Toggle",f.displayName="Toggle";var b=(0,a.I4)("div",(function(e){var t=e.$theme.colors.toggleTrackFill;return e.$disabled?t=e.$theme.colors.toggleTrackFillDisabled:e.$error&&e.$checked&&(t=e.$theme.colors.tickFillError),{alignItems:"center",backgroundColor:t,borderTopLeftRadius:"7px",borderTopRightRadius:"7px",borderBottomRightRadius:"7px",borderBottomLeftRadius:"7px",display:"flex",height:e.$theme.sizing.scale550,marginTop:e.$theme.sizing.scale200,marginBottom:e.$theme.sizing.scale100,marginLeft:e.$theme.sizing.scale200,marginRight:e.$theme.sizing.scale100,width:e.$theme.sizing.scale1000}}));b.displayName="ToggleTrack",b.displayName="ToggleTrack";var v=Object.freeze({default:"default",toggle:"toggle",toggle_round:"toggle"}),y=Object.freeze({top:"top",right:"right",bottom:"bottom",left:"left"}),k=r(56498);function $(e){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$(e)}function w(){return w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},w.apply(this,arguments)}function F(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function x(e,t){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},x(e,t)}function C(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,o=R(e);if(t){var i=R(this).constructor;r=Reflect.construct(o,arguments,i)}else r=o.apply(this,arguments);return function(e,t){if(t&&("object"===$(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return S(e)}(this,r)}}function S(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R(e){return R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},R(e)}function L(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var T=function(e){return e.stopPropagation()},M=function(e){!function(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&x(e,t)}(l,e);var t,r,i,a=C(l);function l(){var e;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l);for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return L(S(e=a.call.apply(a,[this].concat(r))),"state",{isFocused:e.props.autoFocus||!1,isFocusVisible:!1,isHovered:!1,isActive:!1}),L(S(e),"onMouseEnter",(function(t){e.setState({isHovered:!0}),e.props.onMouseEnter(t)})),L(S(e),"onMouseLeave",(function(t){e.setState({isHovered:!1,isActive:!1}),e.props.onMouseLeave(t)})),L(S(e),"onMouseDown",(function(t){e.setState({isActive:!0}),e.props.onMouseDown(t)})),L(S(e),"onMouseUp",(function(t){e.setState({isActive:!1}),e.props.onMouseUp(t)})),L(S(e),"onFocus",(function(t){e.setState({isFocused:!0}),e.props.onFocus(t),(0,k.pP)(t)&&e.setState({isFocusVisible:!0})})),L(S(e),"onBlur",(function(t){e.setState({isFocused:!1}),e.props.onBlur(t),!1!==e.state.isFocusVisible&&e.setState({isFocusVisible:!1})})),e}return t=l,(r=[{key:"componentDidMount",value:function(){var e=this.props,t=e.autoFocus,r=e.inputRef;t&&r.current&&r.current.focus()}},{key:"render",value:function(){var e=this.props,t=e.overrides,r=void 0===t?{}:t,i=e.onChange,a=e.labelPlacement,l=void 0===a?this.props.checkmarkType===v.toggle?"left":"right":a,c=e.inputRef,s=e.isIndeterminate,d=e.error,u=e.disabled,y=e.value,k=e.name,$=e.type,F=e.checked,x=e.children,C=e.required,S=e.title,R=r.Root,L=r.Checkmark,M=r.Label,O=r.Input,P=r.Toggle,j=r.ToggleTrack,I=(0,n.De)(R)||g,B=(0,n.De)(L)||p,E=(0,n.De)(M)||h,D=(0,n.De)(O)||m,W=(0,n.De)(P)||f,H=(0,n.De)(j)||b,z={onChange:i,onFocus:this.onFocus,onBlur:this.onBlur},V={onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp},_={$isFocused:this.state.isFocused,$isFocusVisible:this.state.isFocusVisible,$isHovered:this.state.isHovered,$isActive:this.state.isActive,$error:d,$checked:F,$isIndeterminate:s,$required:C,$disabled:u,$value:y},A=x&&o.createElement(E,w({$labelPlacement:l},_,(0,n.PC)(M)),this.props.containsInteractiveElement?o.createElement("div",{onClick:function(e){return e.preventDefault()}},x):x);return o.createElement(I,w({"data-baseweb":"checkbox",title:S||null,$labelPlacement:l},_,V,(0,n.PC)(R)),("top"===l||"left"===l)&&A,this.props.checkmarkType===v.toggle?o.createElement(H,w({},_,(0,n.PC)(j)),o.createElement(W,w({},_,(0,n.PC)(P)))):o.createElement(B,w({},_,(0,n.PC)(L))),o.createElement(D,w({value:y,name:k,checked:F,required:C,"aria-label":this.props["aria-label"]||this.props.ariaLabel,"aria-checked":s?"mixed":F,"aria-describedby":this.props["aria-describedby"],"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":d||null,"aria-required":C||null,disabled:u,type:$,ref:c,onClick:T},_,z,(0,n.PC)(O))),("bottom"===l||"right"===l)&&A)}}])&&F(t.prototype,r),i&&F(t,i),Object.defineProperty(t,"prototype",{writable:!1}),l}(o.Component);L(M,"defaultProps",{overrides:{},checked:!1,containsInteractiveElement:!1,disabled:!1,autoFocus:!1,isIndeterminate:!1,inputRef:o.createRef(),error:!1,type:"checkbox",checkmarkType:v.default,onChange:function(){},onMouseEnter:function(){},onMouseLeave:function(){},onMouseDown:function(){},onMouseUp:function(){},onFocus:function(){},onBlur:function(){}});const O=M;var P=r(32735),j=r(25571),I=r(29669),B=r(3101),E=r(16795),D=r(93480),W=r(997),H=r(78286),z=r(4629),V=r(90114),_=r(90782);function A(e){var t;let{width:r,element:n,disabled:a,widgetMgr:l,fragmentId:c}=e;const[s,d]=(0,B.t)({getStateFromWidgetMgr:N,getDefaultStateFromProto:U,getCurrStateFromProto:X,updateWidgetMgrState:q,element:n,widgetMgr:l,fragmentId:c}),u=(0,o.useCallback)((e=>{d({value:e.target.checked,fromUi:!0})}),[d]),g=(0,i.u)(),{colors:p,spacing:h,sizes:m}=g,f=(0,E.iq)(g),b=a?p.fadedText40:p.bodyText;return(0,_.jsx)(V.p,{className:"row-widget stCheckbox","data-testid":"stCheckbox",width:r,children:(0,_.jsx)(O,{checked:s,disabled:a,onChange:u,"aria-label":n.label,checkmarkType:n.type===I.Sc.StyleType.TOGGLE?v.toggle:v.default,labelPlacement:y.right,overrides:{Root:{style:e=>{let{$isFocusVisible:t}=e;return{marginBottom:h.none,marginTop:h.none,backgroundColor:t?p.darkenedBgMix25:"",display:"flex",alignItems:"start"}}},Toggle:{style:e=>{let{$checked:t}=e,r=f?p.bgColor:p.bodyText;return a&&(r=f?p.gray70:p.gray90),{width:`calc(${m.checkbox} - ${g.spacing.twoXS})`,height:`calc(${m.checkbox} - ${g.spacing.twoXS})`,transform:t?`translateX(${m.checkbox})`:"",backgroundColor:r,boxShadow:""}}},ToggleTrack:{style:e=>{let{$checked:t,$isHovered:r}=e,o=p.fadedText40;return r&&!a&&(o=p.fadedText20),t&&!a&&(o=p.primary),{marginRight:0,marginLeft:0,marginBottom:0,marginTop:g.spacing.twoXS,paddingLeft:g.spacing.threeXS,paddingRight:g.spacing.threeXS,width:`calc(2 * ${m.checkbox})`,minWidth:`calc(2 * ${m.checkbox})`,height:m.checkbox,minHeight:m.checkbox,borderBottomLeftRadius:g.radii.full,borderTopLeftRadius:g.radii.full,borderBottomRightRadius:g.radii.full,borderTopRightRadius:g.radii.full,backgroundColor:o}}},Checkmark:{style:e=>{let{$isFocusVisible:t,$checked:r}=e;const o=r&&!a?p.primary:p.fadedText40;return{outline:0,width:m.checkbox,height:m.checkbox,marginTop:g.spacing.twoXS,marginLeft:0,marginBottom:0,boxShadow:t&&r?`0 0 0 0.2rem ${(0,P.No)(p.primary,.5)}`:"",borderLeftWidth:m.borderWidth,borderRightWidth:m.borderWidth,borderTopWidth:m.borderWidth,borderBottomWidth:m.borderWidth,borderLeftColor:o,borderRightColor:o,borderTopColor:o,borderBottomColor:o}}},Label:{style:{lineHeight:g.lineHeights.small,paddingLeft:g.spacing.sm,position:"relative",color:b}}},children:(0,_.jsxs)(V.x,{visibility:(0,j.yv)(null===(t=n.labelVisibility)||void 0===t?void 0:t.value),"data-testid":"stWidgetLabel",children:[(0,_.jsx)(z.Ay,{source:n.label,allowHTML:!1,isLabel:!0,largerLabel:!0}),n.help&&(0,_.jsx)(H.Cl,{color:b,children:(0,_.jsx)(D.A,{content:n.help,placement:W.W.TOP_RIGHT})})]})})})}function N(e,t){return e.getBoolValue(t)}function U(e){var t;return null!==(t=e.default)&&void 0!==t?t:null}function X(e){var t;return null!==(t=e.value)&&void 0!==t?t:null}function q(e,t,r,o){t.setBoolValue(e,r.value,{fromUi:r.fromUi},o)}const G=(0,o.memo)(A)},34752:(e,t,r)=>{r.d(t,{X:()=>a,o:()=>n});var o=r(58878),i=r(25571);class n{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,r){(0,i.se)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,i._L)(t)&&(this.formClearListener=e.addFormClearedListener(t,r),this.lastWidgetMgr=e,this.lastFormId=t))}disconnect(){var e;null===(e=this.formClearListener)||void 0===e||e.disconnect(),this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}}function a(e){let{element:t,widgetMgr:r,onFormCleared:n}=e;(0,o.useEffect)((()=>{if(!(0,i._L)(t.formId))return;const e=r.addFormClearedListener(t.formId,n);return()=>{e.disconnect()}}),[t,r,n])}},3101:(e,t,r)=>{r.d(t,{_:()=>a,t:()=>l});var o=r(58878),i=r(34752),n=r(25571);function a(e){let{getStateFromWidgetMgr:t,getDefaultState:r,updateWidgetMgrState:a,element:l,widgetMgr:c,fragmentId:s,onFormCleared:d}=e;const[u,g]=(0,o.useState)((()=>{var e;return null!==(e=t(c,l))&&void 0!==e?e:r(c,l)})),[p,h]=(0,o.useState)({value:u,fromUi:!1});(0,o.useEffect)((()=>{(0,n.hX)(p)||(h(null),g(p.value),a(l,c,p,s))}),[p,a,l,c,s]);const m=(0,o.useCallback)((()=>{h({value:r(c,l),fromUi:!0}),null===d||void 0===d||d()}),[h,l,r,c,d]);return(0,i.X)({widgetMgr:c,element:l,onFormCleared:m}),[u,h]}function l(e){let{getStateFromWidgetMgr:t,getDefaultStateFromProto:r,getCurrStateFromProto:i,updateWidgetMgrState:n,element:l,widgetMgr:c,fragmentId:s,onFormCleared:d}=e;const u=(0,o.useCallback)(((e,t)=>r(t)),[r]),[g,p]=a({getStateFromWidgetMgr:t,getDefaultState:u,updateWidgetMgrState:n,element:l,widgetMgr:c,fragmentId:s,onFormCleared:d});return(0,o.useEffect)((()=>{l.setValue&&(l.setValue=!1,p({value:i(l),fromUi:!1}))}),[l,i,p]),[g,p]}}}]);
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[3224],{53224:(e,t,n)=>{n.r(t),n.d(t,{default:()=>ye});var r=n(58878),a=n(8151),l=n(19613),i=n(56146),o=n(18364),s=n(95241),d=n(71034),c=n.n(d),u=n(34752),g=n(70691),p=n(25571),f=n(58144),h=n(50609),m=n.n(h),y=n(29669),b=n(67253);var w=n(93480),v=n(997),x=n(70474),C=n(35526);const j=e=>{var t;let{widgetMgr:n,id:a,formId:l,key:i,defaultValue:o}=e;(0,r.useEffect)((()=>{const e=n.getElementState(a,i);(0,p.hX)(e)&&(0,p.se)(o)&&n.setElementState(a,i,o)}),[n,a,i,o]);const[s,d]=(0,r.useState)(null!==(t=n.getElementState(a,i))&&void 0!==t?t:o),c=(0,r.useCallback)((e=>{n.setElementState(a,i,e),d(e)}),[n,a,i]),g=(0,r.useMemo)((()=>({formId:l||""})),[l]),f=(0,r.useCallback)((()=>c(o)),[o,c]);return(0,u.X)({element:g,widgetMgr:n,onFormCleared:f}),[s,c]};var k=n(84152),S=n(55562);const A=(e,t)=>{const{libConfig:{enforceDownloadInNewTab:n=!1}}=r.useContext(k.n);return(0,r.useCallback)((()=>{if(!e)return;const r=(0,S.A)({enforceDownloadInNewTab:n,url:e,filename:t});r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}),[e,n,t])};var U=n(89653),I=n(37888);const R=(0,U.A)("div",{target:"e12wn80j15"})(""),P=(0,U.A)("div",{target:"e12wn80j14"})((e=>{let{theme:t}=e;return{height:t.sizes.largestElementHeight,width:"100%",background:t.colors.secondaryBg,borderRadius:t.radii.default,marginBottom:t.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:t.spacing.xs,paddingRight:t.spacing.sm}}),""),T=(0,U.A)("div",{target:"e12wn80j13"})({name:"82a6rk",styles:"flex:1"}),E=(0,U.A)("div",{target:"e12wn80j12"})((e=>{let{show:t}=e;return{display:t?"block":"none"}}),""),L=(0,U.A)("span",{target:"e12wn80j11"})((e=>{let{theme:t,isPlayingOrRecording:n}=e;return{margin:t.spacing.sm,fontFamily:t.fonts.monospace,color:n?t.colors.bodyText:t.colors.fadedText60,backgroundColor:t.colors.secondaryBg,fontSize:t.fontSizes.sm}}),""),M=(0,U.A)("div",{target:"e12wn80j10"})({name:"1kyw74z",styles:"width:100%;text-align:center;overflow:hidden"}),z=(0,U.A)("span",{target:"e12wn80j9"})((e=>{let{theme:t}=e;return{color:t.colors.bodyText}}),""),F=(0,U.A)("a",{target:"e12wn80j8"})((e=>{let{theme:t}=e;return{color:t.colors.linkText,textDecoration:"underline"}}),""),W=(0,U.A)("div",{target:"e12wn80j7"})((e=>{let{theme:t}=e;return{height:t.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"}}),""),B=(0,U.A)("div",{target:"e12wn80j6"})((e=>{let{theme:t}=e;const n="0.625em";return{opacity:.2,width:"100%",height:n,backgroundSize:n,backgroundImage:`radial-gradient(${t.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),""),X=(0,U.A)("span",{target:"e12wn80j5"})((e=>{let{theme:t}=e;return{"& > button":{color:t.colors.primary,padding:t.spacing.threeXS},"& > button:hover, & > button:focus":{color:t.colors.red}}}),""),O=(0,U.A)("span",{target:"e12wn80j4"})((e=>{let{theme:t}=e;return{"& > button":{padding:t.spacing.threeXS,color:t.colors.fadedText40},"& > button:hover, & > button:focus":{color:t.colors.primary}}}),""),V=(0,U.A)("span",{target:"e12wn80j3"})((e=>{let{theme:t}=e;return{"& > button":{padding:t.spacing.threeXS,color:t.colors.fadedText60},"& > button:hover, & > button:focus":{color:t.colors.bodyText}}}),""),D=(0,U.A)("div",{target:"e12wn80j2"})((e=>{let{theme:t}=e;return{display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:t.spacing.xs,gap:t.spacing.twoXS,marginRight:t.spacing.twoXS}}),""),N=(0,U.A)("div",{target:"e12wn80j1"})((e=>{let{theme:t}=e;return{marginLeft:t.spacing.sm}}),""),_=(0,U.A)(I.x,{target:"e12wn80j0"})((e=>{let{theme:t}=e;return{fontSize:t.fontSizes.sm,width:t.sizes.spinnerSize,height:t.sizes.spinnerSize,borderWidth:t.sizes.spinnerThickness,radius:t.radii.md,justifyContents:"center",padding:t.spacing.none,margin:t.spacing.none,borderColor:t.colors.borderColor,borderTopColor:t.colors.primary,flexGrow:0,flexShrink:0}}),"");var G=n(39095),H=n(90782);const K=()=>(0,H.jsxs)(M,{children:[(0,H.jsx)(z,{children:"This app would like to use your microphone."})," ",(0,H.jsx)(F,{href:G.ML,children:"Learn how to allow access."})]}),$=()=>(0,H.jsx)(W,{children:(0,H.jsx)(B,{})}),Y="00:00",Z=e=>new Date(e).toLocaleTimeString(void 0,{minute:"2-digit",second:"2-digit"});var q=n(96626),J=n(34783),Q=n(37789),ee=n(14757),te=n(88685),ne=n(36459),re=n(84720),ae=n(64611);const le=e=>{let{onClick:t,disabled:n,ariaLabel:r,iconContent:a}=e;return(0,H.jsx)(ne.Ay,{kind:re.KX.BORDERLESS_ICON,onClick:t,disabled:n,"aria-label":r,fluidWidth:!0,"data-testid":"stAudioInputActionButton",children:(0,H.jsx)(ae.A,{content:a,size:"lg",color:"inherit"})})},ie=e=>{let{disabled:t,stopRecording:n}=e;return(0,H.jsx)(X,{children:(0,H.jsx)(le,{onClick:n,disabled:t,ariaLabel:"Stop recording",iconContent:J.X})})},oe=e=>{let{disabled:t,isPlaying:n,onClickPlayPause:r}=e;return(0,H.jsx)(V,{children:n?(0,H.jsx)(le,{onClick:r,disabled:t,ariaLabel:"Pause",iconContent:Q.v}):(0,H.jsx)(le,{onClick:r,disabled:t,ariaLabel:"Play",iconContent:ee.S})})},se=e=>{let{disabled:t,startRecording:n}=e;return(0,H.jsx)(O,{children:(0,H.jsx)(le,{onClick:n,disabled:t,ariaLabel:"Record",iconContent:q.G})})},de=e=>{let{onClick:t}=e;return(0,H.jsx)(V,{children:(0,H.jsx)(le,{disabled:!1,onClick:t,ariaLabel:"Reset",iconContent:te.C})})},ce=e=>{let{disabled:t,isRecording:n,isPlaying:r,isUploading:a,isError:l,recordingUrlExists:i,startRecording:o,stopRecording:s,onClickPlayPause:d,onClear:c}=e;return l?(0,H.jsx)(D,{children:(0,H.jsx)(de,{onClick:c})}):a?(0,H.jsx)(D,{children:(0,H.jsx)(_,{"aria-label":"Uploading"})}):(0,H.jsxs)(D,{children:[n?(0,H.jsx)(ie,{disabled:t,stopRecording:s}):(0,H.jsx)(se,{disabled:t,startRecording:o}),i&&(0,H.jsx)(oe,{disabled:t,isPlaying:r,onClickPlayPause:d})]})},ue=(0,r.memo)(ce);var ge=n(84996);function pe(e,t,n){for(let r=0;r<n.length;r++,t+=2){const a=Math.max(-1,Math.min(1,n[r]));e.setInt16(t,a<0?32768*a:32767*a,!0)}}const fe=async function(e){const t=new window.AudioContext,n=await e.arrayBuffer();let r;try{r=await t.decodeAudioData(n)}catch(u){return void(0,ge.vV)(u)}const a=r.numberOfChannels,l=r.sampleRate,i=r.length*a*2+44,o=new ArrayBuffer(i),s=new DataView(o),d={0:{type:"string",value:"RIFF"},4:{type:"uint32",value:36+2*r.length*a},8:{type:"string",value:"WAVE"},12:{type:"string",value:"fmt "},16:{type:"uint32",value:16},20:{type:"uint16",value:1},22:{type:"uint16",value:a},24:{type:"uint32",value:l},28:{type:"uint32",value:l*a*2},32:{type:"uint16",value:2*a},34:{type:"uint16",value:16},36:{type:"string",value:"data"},40:{type:"uint32",value:r.length*a*2}};Object.entries(d).forEach((e=>{let[t,{type:n,value:r}]=e;const a=parseInt(t,10);"string"===n?function(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}(s,a,r):"uint32"===n?s.setUint32(a,r,!0):"uint16"===n&&s.setUint16(a,r,!0)}));for(let g=0;g<a;g++)pe(s,44+g*r.length*2,r.getChannelData(g));const c=new Uint8Array(o);return new Blob([c],{type:"audio/wav"})},he=()=>(0,H.jsx)(M,{children:(0,H.jsx)(z,{children:"An error has occurred, please try again."})}),me=e=>{var t;let{element:n,uploadClient:d,widgetMgr:h,fragmentId:k,disabled:S}=e;const U=(0,a.u)(),I=(0,C.Z)(U),[M,z]=(0,r.useState)(null),F=r.useRef(null),[W,B]=j({widgetMgr:h,id:n.id,key:"deleteFileUrl",defaultValue:null}),[X,O]=(0,r.useState)(null),[V,D]=(0,r.useState)([]),[_,G]=(0,r.useState)(null),[q,J]=j({widgetMgr:h,id:n.id,key:"recordingUrl",defaultValue:null}),[,Q]=(0,r.useState)(0),ee=()=>{Q((e=>e+1))},[te,ne]=(0,r.useState)(Y),[re,ae]=j({widgetMgr:h,id:n.id,formId:n.formId,key:"recordingTime",defaultValue:Y}),[le,ie]=(0,r.useState)(!1),[oe,se]=(0,r.useState)(!1),[de,ce]=(0,r.useState)(!1),[ge,pe]=(0,r.useState)(!1),[me,ye]=(0,r.useState)(!1),be=n.id,we=n.formId,ve=(0,r.useCallback)((async e=>{let t;if(pe(!0),(0,p.se)(we)&&h.setFormsWithUploadsInProgress(new Set([we])),t="audio/wav"===e.type?e:await fe(e),!t)return void ye(!0);const n=URL.createObjectURL(t),r=new File([t],"audio.wav",{type:t.type});J(n),(async e=>{let{files:t,uploadClient:n,widgetMgr:r,widgetInfo:a,fragmentId:l}=e,i=[];try{i=await n.fetchFileURLs(t)}catch(c){return{successfulUploads:[],failedUploads:t.map((e=>({file:e,error:(0,b.$)(c)})))}}const o=m()(t,i),s=[],d=[];return await Promise.all(o.map((async e=>{let[t,r]=e;if(!t||!r||!r.uploadUrl||!r.fileId)return{file:t,fileUrl:r,error:new Error("No upload URL found")};try{await n.uploadFile({id:r.fileId,formId:a.formId||""},r.uploadUrl,t),s.push({fileUrl:r,file:t})}catch(c){const n=(0,b.$)(c);d.push({file:t,error:n})}}))),r.setFileUploaderStateValue(a,new y.qX({uploadedFileInfo:s.map((e=>{let{file:t,fileUrl:n}=e;return new y.HY({fileId:n.fileId,fileUrls:n,name:t.name,size:t.size})}))}),{fromUi:!0},l),{successfulUploads:s,failedUploads:d}})({files:[r],uploadClient:d,widgetMgr:h,widgetInfo:{id:be,formId:we},fragmentId:k}).then((e=>{let{successfulUploads:t,failedUploads:n}=e;if(n.length>0)return void ye(!0);const r=t[0];r&&r.fileUrl.deleteUrl&&B(r.fileUrl.deleteUrl)})).finally((()=>{(0,p.se)(we)&&h.setFormsWithUploadsInProgress(new Set),pe(!1)}))}),[J,d,h,be,we,k,B]),xe=(0,r.useCallback)((e=>{let{updateWidgetManager:t}=e;(0,p.hX)(M)||(0,p.hX)(W)||(J(null),M.empty(),d.deleteFile(W),ne(Y),ae(Y),B(null),t&&h.setFileUploaderStateValue(n,{},{fromUi:!0},k),ie(!1),(0,p.se)(q)&&URL.revokeObjectURL(q))}),[W,q,d,M,n,h,k,ae,J,B]);(0,r.useEffect)((()=>{if((0,p.hX)(we))return;const e=new u.o;return e.manageFormClearListener(h,we,(()=>{xe({updateWidgetManager:!0})})),()=>e.disconnect()}),[we,xe,h]);const Ce=(0,r.useCallback)((()=>{if(null===F.current)return;const e=l.A.create({container:F.current,waveColor:q?(0,f.au)(U.colors.fadedText40,U.colors.secondaryBg):U.colors.primary,progressColor:U.colors.bodyText,height:(0,f.BY)(U.sizes.largestElementHeight)-8,barWidth:4,barGap:4,barRadius:8,cursorWidth:0,url:null!==q&&void 0!==q?q:void 0});e.on("timeupdate",(e=>{ne(Z(1e3*e))})),e.on("pause",(()=>{ee()}));const t=e.registerPlugin(i.A.create({scrollingWaveform:!1,renderRecordedAudio:!0}));return t.on("record-end",(async e=>{ve(e)})),t.on("record-progress",(e=>{ae(Z(e))})),z(e),O(t),()=>{e&&e.destroy(),t&&t.destroy()}}),[ve]);(0,r.useEffect)((()=>Ce()),[Ce]),(0,r.useEffect)((()=>{c()(I,U)||null===M||void 0===M||M.setOptions({waveColor:q?(0,f.au)(U.colors.fadedText40,U.colors.secondaryBg):U.colors.primary,progressColor:U.colors.bodyText})}),[U,I,q,M]);const je=(0,r.useCallback)((()=>{M&&(M.playPause(),ie(!0),ee())}),[M]),ke=(0,r.useCallback)((async()=>{let e=_;de||(await navigator.mediaDevices.getUserMedia({audio:!0}).then((()=>i.A.getAvailableAudioDevices().then((t=>{if(D(t),t.length>0){const{deviceId:n}=t[0];G(n),e=n}})))).catch((e=>{se(!0)})),ce(!0)),X&&e&&M&&(M.setOptions({waveColor:U.colors.primary}),q&&xe({updateWidgetManager:!1}),X.startRecording({deviceId:e}).then((()=>{ee()})))}),[_,X,U,M,q,xe,de]),Se=(0,r.useCallback)((()=>{X&&(X.stopRecording(),null===M||void 0===M||M.setOptions({waveColor:(0,f.au)(U.colors.fadedText40,U.colors.secondaryBg)}))}),[X,M,U]),Ae=A(q,"recording.wav"),Ue=Boolean(null===X||void 0===X?void 0:X.isRecording()),Ie=Boolean(null===M||void 0===M?void 0:M.isPlaying()),Re=Ue||Ie,Pe=!Ue&&!q&&!oe,Te=oe||Pe||me,Ee=S||oe;return(0,H.jsxs)(R,{className:"stAudioInput","data-testid":"stAudioInput",children:[(0,H.jsx)(x.L,{label:n.label,disabled:Ee,labelVisibility:(0,p.yv)(null===(t=n.labelVisibility)||void 0===t?void 0:t.value),children:n.help&&(0,H.jsx)(N,{children:(0,H.jsx)(w.A,{content:n.help,placement:v.W.TOP})})}),(0,H.jsxs)(P,{children:[(0,H.jsxs)(g.A,{isFullScreen:!1,disableFullscreenMode:!0,target:P,children:[q&&(0,H.jsx)(g.K,{label:"Download as WAV",icon:o.n,onClick:()=>Ae()}),W&&(0,H.jsx)(g.K,{label:"Clear recording",icon:s.e,onClick:()=>xe({updateWidgetManager:!0})})]}),(0,H.jsx)(ue,{isRecording:Ue,isPlaying:Ie,isUploading:ge,isError:me,recordingUrlExists:Boolean(q),startRecording:ke,stopRecording:Se,onClickPlayPause:je,onClear:()=>{xe({updateWidgetManager:!1}),ye(!1)},disabled:Ee}),(0,H.jsxs)(T,{children:[me&&(0,H.jsx)(he,{}),Pe&&(0,H.jsx)($,{}),oe&&(0,H.jsx)(K,{}),(0,H.jsx)(E,{"data-testid":"stAudioInputWaveSurfer",ref:F,show:!Te})]}),(0,H.jsx)(L,{isPlayingOrRecording:Re,"data-testid":"stAudioInputWaveformTimeCode",children:le?te:re})]})]})},ye=(0,r.memo)(me)},35526:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(58878);const a=e=>{const t=(0,r.useRef)();return(0,r.useEffect)((()=>{t.current=e}),[e]),t.current}}}]);
|
1
|
+
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[3224],{53224:(e,t,n)=>{n.r(t),n.d(t,{default:()=>ye});var r=n(58878),a=n(8151),l=n(19613),i=n(56146),o=n(18364),s=n(95241),d=n(71034),c=n.n(d),u=n(34752),g=n(70691),p=n(25571),f=n(58144),h=n(50609),m=n.n(h),y=n(29669),b=n(67253);var w=n(93480),v=n(997),x=n(70474),C=n(35526);const j=e=>{var t;let{widgetMgr:n,id:a,formId:l,key:i,defaultValue:o}=e;(0,r.useEffect)((()=>{const e=n.getElementState(a,i);(0,p.hX)(e)&&(0,p.se)(o)&&n.setElementState(a,i,o)}),[n,a,i,o]);const[s,d]=(0,r.useState)(null!==(t=n.getElementState(a,i))&&void 0!==t?t:o),c=(0,r.useCallback)((e=>{n.setElementState(a,i,e),d(e)}),[n,a,i]),g=(0,r.useMemo)((()=>({formId:l||""})),[l]),f=(0,r.useCallback)((()=>c(o)),[o,c]);return(0,u.X)({element:g,widgetMgr:n,onFormCleared:f}),[s,c]};var k=n(84152),S=n(55562);const A=(e,t)=>{const{libConfig:{enforceDownloadInNewTab:n=!1}}=r.useContext(k.n);return(0,r.useCallback)((()=>{if(!e)return;const r=(0,S.A)({enforceDownloadInNewTab:n,url:e,filename:t});r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)}),[e,n,t])};var U=n(89653),I=n(37888);const R=(0,U.A)("div",{target:"e12wn80j15"})(""),P=(0,U.A)("div",{target:"e12wn80j14"})((e=>{let{theme:t}=e;return{height:t.sizes.largestElementHeight,width:"100%",background:t.colors.secondaryBg,borderRadius:t.radii.default,marginBottom:t.spacing.twoXS,display:"flex",alignItems:"center",position:"relative",paddingLeft:t.spacing.xs,paddingRight:t.spacing.sm}}),""),T=(0,U.A)("div",{target:"e12wn80j13"})({name:"82a6rk",styles:"flex:1"}),E=(0,U.A)("div",{target:"e12wn80j12"})((e=>{let{show:t}=e;return{display:t?"block":"none"}}),""),L=(0,U.A)("span",{target:"e12wn80j11"})((e=>{let{theme:t,isPlayingOrRecording:n}=e;return{margin:t.spacing.sm,fontFamily:t.fonts.monospace,color:n?t.colors.bodyText:t.colors.fadedText60,backgroundColor:t.colors.secondaryBg,fontSize:t.fontSizes.sm}}),""),M=(0,U.A)("div",{target:"e12wn80j10"})({name:"1kyw74z",styles:"width:100%;text-align:center;overflow:hidden"}),z=(0,U.A)("span",{target:"e12wn80j9"})((e=>{let{theme:t}=e;return{color:t.colors.bodyText}}),""),F=(0,U.A)("a",{target:"e12wn80j8"})((e=>{let{theme:t}=e;return{color:t.colors.linkText,textDecoration:"underline"}}),""),W=(0,U.A)("div",{target:"e12wn80j7"})((e=>{let{theme:t}=e;return{height:t.sizes.largestElementHeight,display:"flex",justifyContent:"center",alignItems:"center"}}),""),B=(0,U.A)("div",{target:"e12wn80j6"})((e=>{let{theme:t}=e;const n="0.625em";return{opacity:.2,width:"100%",height:n,backgroundSize:n,backgroundImage:`radial-gradient(${t.colors.fadedText10} 40%, transparent 40%)`,backgroundRepeat:"repeat"}}),""),X=(0,U.A)("span",{target:"e12wn80j5"})((e=>{let{theme:t}=e;return{"& > button":{color:t.colors.primary,padding:t.spacing.threeXS},"& > button:hover, & > button:focus":{color:t.colors.red}}}),""),O=(0,U.A)("span",{target:"e12wn80j4"})((e=>{let{theme:t}=e;return{"& > button":{padding:t.spacing.threeXS,color:t.colors.fadedText40},"& > button:hover, & > button:focus":{color:t.colors.primary}}}),""),D=(0,U.A)("span",{target:"e12wn80j3"})((e=>{let{theme:t}=e;return{"& > button":{padding:t.spacing.threeXS,color:t.colors.fadedText60},"& > button:hover, & > button:focus":{color:t.colors.bodyText}}}),""),V=(0,U.A)("div",{target:"e12wn80j2"})((e=>{let{theme:t}=e;return{display:"flex",justifyContent:"center",alignItems:"center",flexGrow:0,flexShrink:1,padding:t.spacing.xs,gap:t.spacing.twoXS,marginRight:t.spacing.twoXS}}),""),_=(0,U.A)("div",{target:"e12wn80j1"})((e=>{let{theme:t}=e;return{marginLeft:t.spacing.sm}}),""),N=(0,U.A)(I.x,{target:"e12wn80j0"})((e=>{let{theme:t}=e;return{fontSize:t.fontSizes.sm,width:t.sizes.spinnerSize,height:t.sizes.spinnerSize,borderWidth:t.sizes.spinnerThickness,radius:t.radii.md,justifyContents:"center",padding:t.spacing.none,margin:t.spacing.none,borderColor:t.colors.borderColor,borderTopColor:t.colors.primary,flexGrow:0,flexShrink:0}}),"");var G=n(39095),H=n(90782);const $=()=>(0,H.jsxs)(M,{children:[(0,H.jsx)(z,{children:"This app would like to use your microphone."})," ",(0,H.jsx)(F,{href:G.ML,children:"Learn how to allow access."})]}),K=()=>(0,H.jsx)(W,{children:(0,H.jsx)(B,{})}),Y="00:00",Z=e=>new Date(e).toLocaleTimeString(void 0,{minute:"2-digit",second:"2-digit"});var q=n(96626),J=n(34783),Q=n(37789),ee=n(14757),te=n(88685),ne=n(36459),re=n(84720),ae=n(64611);const le=e=>{let{onClick:t,disabled:n,ariaLabel:r,iconContent:a}=e;return(0,H.jsx)(ne.Ay,{kind:re.KX.BORDERLESS_ICON,onClick:t,disabled:n,"aria-label":r,fluidWidth:!0,"data-testid":"stAudioInputActionButton",children:(0,H.jsx)(ae.A,{content:a,size:"lg",color:"inherit"})})},ie=e=>{let{disabled:t,stopRecording:n}=e;return(0,H.jsx)(X,{children:(0,H.jsx)(le,{onClick:n,disabled:t,ariaLabel:"Stop recording",iconContent:J.X})})},oe=e=>{let{disabled:t,isPlaying:n,onClickPlayPause:r}=e;return(0,H.jsx)(D,{children:n?(0,H.jsx)(le,{onClick:r,disabled:t,ariaLabel:"Pause",iconContent:Q.v}):(0,H.jsx)(le,{onClick:r,disabled:t,ariaLabel:"Play",iconContent:ee.S})})},se=e=>{let{disabled:t,startRecording:n}=e;return(0,H.jsx)(O,{children:(0,H.jsx)(le,{onClick:n,disabled:t,ariaLabel:"Record",iconContent:q.G})})},de=e=>{let{onClick:t}=e;return(0,H.jsx)(D,{children:(0,H.jsx)(le,{disabled:!1,onClick:t,ariaLabel:"Reset",iconContent:te.C})})},ce=e=>{let{disabled:t,isRecording:n,isPlaying:r,isUploading:a,isError:l,recordingUrlExists:i,startRecording:o,stopRecording:s,onClickPlayPause:d,onClear:c}=e;return l?(0,H.jsx)(V,{children:(0,H.jsx)(de,{onClick:c})}):a?(0,H.jsx)(V,{children:(0,H.jsx)(N,{"aria-label":"Uploading"})}):(0,H.jsxs)(V,{children:[n?(0,H.jsx)(ie,{disabled:t,stopRecording:s}):(0,H.jsx)(se,{disabled:t,startRecording:o}),i&&(0,H.jsx)(oe,{disabled:t,isPlaying:r,onClickPlayPause:d})]})},ue=(0,r.memo)(ce);var ge=n(84996);function pe(e,t,n){for(let r=0;r<n.length;r++,t+=2){const a=Math.max(-1,Math.min(1,n[r]));e.setInt16(t,a<0?32768*a:32767*a,!0)}}const fe=async function(e){const t=new window.AudioContext,n=await e.arrayBuffer();let r;try{r=await t.decodeAudioData(n)}catch(u){return void(0,ge.vV)(u)}const a=r.numberOfChannels,l=r.sampleRate,i=r.length*a*2+44,o=new ArrayBuffer(i),s=new DataView(o),d={0:{type:"string",value:"RIFF"},4:{type:"uint32",value:36+2*r.length*a},8:{type:"string",value:"WAVE"},12:{type:"string",value:"fmt "},16:{type:"uint32",value:16},20:{type:"uint16",value:1},22:{type:"uint16",value:a},24:{type:"uint32",value:l},28:{type:"uint32",value:l*a*2},32:{type:"uint16",value:2*a},34:{type:"uint16",value:16},36:{type:"string",value:"data"},40:{type:"uint32",value:r.length*a*2}};Object.entries(d).forEach((e=>{let[t,{type:n,value:r}]=e;const a=parseInt(t,10);"string"===n?function(e,t,n){for(let r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}(s,a,r):"uint32"===n?s.setUint32(a,r,!0):"uint16"===n&&s.setUint16(a,r,!0)}));for(let g=0;g<a;g++)pe(s,44+g*r.length*2,r.getChannelData(g));const c=new Uint8Array(o);return new Blob([c],{type:"audio/wav"})},he=()=>(0,H.jsx)(M,{children:(0,H.jsx)(z,{children:"An error has occurred, please try again."})}),me=e=>{var t;let{element:n,uploadClient:d,widgetMgr:h,fragmentId:k,disabled:S}=e;const U=(0,a.u)(),I=(0,C.Z)(U),[M,z]=(0,r.useState)(null),F=r.useRef(null),[W,B]=j({widgetMgr:h,id:n.id,key:"deleteFileUrl",defaultValue:null}),[X,O]=(0,r.useState)(null),[D,V]=(0,r.useState)([]),[N,G]=(0,r.useState)(null),[q,J]=j({widgetMgr:h,id:n.id,key:"recordingUrl",defaultValue:null}),[,Q]=(0,r.useState)(0),ee=()=>{Q((e=>e+1))},[te,ne]=(0,r.useState)(Y),[re,ae]=j({widgetMgr:h,id:n.id,formId:n.formId,key:"recordingTime",defaultValue:Y}),[le,ie]=(0,r.useState)(!1),[oe,se]=(0,r.useState)(!1),[de,ce]=(0,r.useState)(!1),[ge,pe]=(0,r.useState)(!1),[me,ye]=(0,r.useState)(!1),be=n.id,we=n.formId,ve=(0,r.useCallback)((async e=>{let t;if(pe(!0),(0,p.se)(we)&&h.setFormsWithUploadsInProgress(new Set([we])),t="audio/wav"===e.type?e:await fe(e),!t)return void ye(!0);const n=URL.createObjectURL(t),r=(new Date).toISOString().slice(0,16).replace(":","-"),a=new File([t],`${r}_audio.wav`,{type:t.type});J(n),(async e=>{let{files:t,uploadClient:n,widgetMgr:r,widgetInfo:a,fragmentId:l}=e,i=[];try{i=await n.fetchFileURLs(t)}catch(c){return{successfulUploads:[],failedUploads:t.map((e=>({file:e,error:(0,b.$)(c)})))}}const o=m()(t,i),s=[],d=[];return await Promise.all(o.map((async e=>{let[t,r]=e;if(!t||!r||!r.uploadUrl||!r.fileId)return{file:t,fileUrl:r,error:new Error("No upload URL found")};try{await n.uploadFile({id:r.fileId,formId:a.formId||""},r.uploadUrl,t),s.push({fileUrl:r,file:t})}catch(c){const n=(0,b.$)(c);d.push({file:t,error:n})}}))),r.setFileUploaderStateValue(a,new y.qX({uploadedFileInfo:s.map((e=>{let{file:t,fileUrl:n}=e;return new y.HY({fileId:n.fileId,fileUrls:n,name:t.name,size:t.size})}))}),{fromUi:!0},l),{successfulUploads:s,failedUploads:d}})({files:[a],uploadClient:d,widgetMgr:h,widgetInfo:{id:be,formId:we},fragmentId:k}).then((e=>{let{successfulUploads:t,failedUploads:n}=e;if(n.length>0)return void ye(!0);const r=t[0];r&&r.fileUrl.deleteUrl&&B(r.fileUrl.deleteUrl)})).finally((()=>{(0,p.se)(we)&&h.setFormsWithUploadsInProgress(new Set),pe(!1)}))}),[J,d,h,be,we,k,B]),xe=(0,r.useCallback)((e=>{let{updateWidgetManager:t}=e;(0,p.hX)(M)||(0,p.hX)(W)||(J(null),M.empty(),d.deleteFile(W),ne(Y),ae(Y),B(null),t&&h.setFileUploaderStateValue(n,{},{fromUi:!0},k),ie(!1),(0,p.se)(q)&&URL.revokeObjectURL(q))}),[W,q,d,M,n,h,k,ae,J,B]);(0,r.useEffect)((()=>{if((0,p.hX)(we))return;const e=new u.o;return e.manageFormClearListener(h,we,(()=>{xe({updateWidgetManager:!0})})),()=>e.disconnect()}),[we,xe,h]);const Ce=(0,r.useCallback)((()=>{if(null===F.current)return;const e=l.A.create({container:F.current,waveColor:q?(0,f.au)(U.colors.fadedText40,U.colors.secondaryBg):U.colors.primary,progressColor:U.colors.bodyText,height:(0,f.BY)(U.sizes.largestElementHeight)-8,barWidth:4,barGap:4,barRadius:8,cursorWidth:0,url:null!==q&&void 0!==q?q:void 0});e.on("timeupdate",(e=>{ne(Z(1e3*e))})),e.on("pause",(()=>{ee()}));const t=e.registerPlugin(i.A.create({scrollingWaveform:!1,renderRecordedAudio:!0}));return t.on("record-end",(async e=>{ve(e)})),t.on("record-progress",(e=>{ae(Z(e))})),z(e),O(t),()=>{e&&e.destroy(),t&&t.destroy()}}),[ve]);(0,r.useEffect)((()=>Ce()),[Ce]),(0,r.useEffect)((()=>{c()(I,U)||null===M||void 0===M||M.setOptions({waveColor:q?(0,f.au)(U.colors.fadedText40,U.colors.secondaryBg):U.colors.primary,progressColor:U.colors.bodyText})}),[U,I,q,M]);const je=(0,r.useCallback)((()=>{M&&(M.playPause(),ie(!0),ee())}),[M]),ke=(0,r.useCallback)((async()=>{let e=N;de||(await navigator.mediaDevices.getUserMedia({audio:!0}).then((()=>i.A.getAvailableAudioDevices().then((t=>{if(V(t),t.length>0){const{deviceId:n}=t[0];G(n),e=n}})))).catch((e=>{se(!0)})),ce(!0)),X&&e&&M&&(M.setOptions({waveColor:U.colors.primary}),q&&xe({updateWidgetManager:!1}),X.startRecording({deviceId:e}).then((()=>{ee()})))}),[N,X,U,M,q,xe,de]),Se=(0,r.useCallback)((()=>{X&&(X.stopRecording(),null===M||void 0===M||M.setOptions({waveColor:(0,f.au)(U.colors.fadedText40,U.colors.secondaryBg)}))}),[X,M,U]),Ae=A(q,"recording.wav"),Ue=Boolean(null===X||void 0===X?void 0:X.isRecording()),Ie=Boolean(null===M||void 0===M?void 0:M.isPlaying()),Re=Ue||Ie,Pe=!Ue&&!q&&!oe,Te=oe||Pe||me,Ee=S||oe;return(0,H.jsxs)(R,{className:"stAudioInput","data-testid":"stAudioInput",children:[(0,H.jsx)(x.L,{label:n.label,disabled:Ee,labelVisibility:(0,p.yv)(null===(t=n.labelVisibility)||void 0===t?void 0:t.value),children:n.help&&(0,H.jsx)(_,{children:(0,H.jsx)(w.A,{content:n.help,placement:v.W.TOP})})}),(0,H.jsxs)(P,{children:[(0,H.jsxs)(g.A,{isFullScreen:!1,disableFullscreenMode:!0,target:P,children:[q&&(0,H.jsx)(g.K,{label:"Download as WAV",icon:o.n,onClick:()=>Ae()}),W&&(0,H.jsx)(g.K,{label:"Clear recording",icon:s.e,onClick:()=>xe({updateWidgetManager:!0})})]}),(0,H.jsx)(ue,{isRecording:Ue,isPlaying:Ie,isUploading:ge,isError:me,recordingUrlExists:Boolean(q),startRecording:ke,stopRecording:Se,onClickPlayPause:je,onClear:()=>{xe({updateWidgetManager:!1}),ye(!1)},disabled:Ee}),(0,H.jsxs)(T,{children:[me&&(0,H.jsx)(he,{}),Pe&&(0,H.jsx)(K,{}),oe&&(0,H.jsx)($,{}),(0,H.jsx)(E,{"data-testid":"stAudioInputWaveSurfer",ref:F,show:!Te})]}),(0,H.jsx)(L,{isPlayingOrRecording:Re,"data-testid":"stAudioInputWaveformTimeCode",children:le?te:re})]})]})},ye=(0,r.memo)(me)},35526:(e,t,n)=>{n.d(t,{Z:()=>a});var r=n(58878);const a=e=>{const t=(0,r.useRef)();return(0,r.useEffect)((()=>{t.current=e}),[e]),t.current}}}]);
|