streamlit-nightly 1.37.1.dev20240730__py2.py3-none-any.whl → 1.37.1.dev20240801__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.
Files changed (53) hide show
  1. streamlit/commands/execution_control.py +2 -4
  2. streamlit/config.py +15 -0
  3. streamlit/proto/ClientState_pb2.py +2 -2
  4. streamlit/proto/ClientState_pb2.pyi +4 -1
  5. streamlit/runtime/app_session.py +1 -0
  6. streamlit/runtime/fragment.py +1 -1
  7. streamlit/runtime/metrics_util.py +1 -3
  8. streamlit/runtime/scriptrunner/exec_code.py +20 -3
  9. streamlit/runtime/scriptrunner/script_requests.py +2 -7
  10. streamlit/runtime/scriptrunner/script_run_context.py +3 -1
  11. streamlit/runtime/scriptrunner/script_runner.py +15 -5
  12. streamlit/runtime/secrets.py +249 -75
  13. streamlit/runtime/state/session_state.py +4 -8
  14. streamlit/static/asset-manifest.json +20 -20
  15. streamlit/static/index.html +1 -1
  16. streamlit/static/static/js/1074.86034b28.chunk.js +1 -0
  17. streamlit/static/static/js/{1116.f824d083.chunk.js → 1116.d8656dab.chunk.js} +1 -1
  18. streamlit/static/static/js/{1168.14f7c6ff.chunk.js → 1168.aa1401dd.chunk.js} +1 -1
  19. streamlit/static/static/js/{1451.229b62c4.chunk.js → 1451.e9542cc9.chunk.js} +1 -1
  20. streamlit/static/static/js/3599.f1e3cc27.chunk.js +1 -0
  21. streamlit/static/static/js/{4177.69f9f18d.chunk.js → 4177.e5631c43.chunk.js} +1 -1
  22. streamlit/static/static/js/4319.00adb829.chunk.js +1 -0
  23. streamlit/static/static/js/{4335.a695f906.chunk.js → 4335.fb48fd8e.chunk.js} +1 -1
  24. streamlit/static/static/js/4477.b85593dd.chunk.js +1 -0
  25. streamlit/static/static/js/4500.c007e274.chunk.js +1 -0
  26. streamlit/static/static/js/{4666.b9eab191.chunk.js → 4666.c8694d51.chunk.js} +1 -1
  27. streamlit/static/static/js/5106.e53c485c.chunk.js +1 -0
  28. streamlit/static/static/js/5441.a564862e.chunk.js +1 -0
  29. streamlit/static/static/js/6718.7bc66e7a.chunk.js +1 -0
  30. streamlit/static/static/js/7175.14622908.chunk.js +1 -0
  31. streamlit/static/static/js/{7602.85e7b7bf.chunk.js → 7602.b5f7407a.chunk.js} +1 -1
  32. streamlit/static/static/js/{8148.1b2c085e.chunk.js → 8148.c7db8490.chunk.js} +1 -1
  33. streamlit/static/static/js/8691.95ba8af9.chunk.js +1 -0
  34. streamlit/static/static/js/main.66b15329.js +2 -0
  35. streamlit/testing/v1/app_test.py +1 -1
  36. {streamlit_nightly-1.37.1.dev20240730.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/METADATA +1 -1
  37. {streamlit_nightly-1.37.1.dev20240730.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/RECORD +42 -42
  38. streamlit/static/static/js/1074.d1dd1731.chunk.js +0 -1
  39. streamlit/static/static/js/3599.565b1eba.chunk.js +0 -1
  40. streamlit/static/static/js/4319.bf1c86bf.chunk.js +0 -1
  41. streamlit/static/static/js/4477.87935ac8.chunk.js +0 -1
  42. streamlit/static/static/js/4500.be0eb305.chunk.js +0 -1
  43. streamlit/static/static/js/5106.086585ae.chunk.js +0 -1
  44. streamlit/static/static/js/5441.324eb9ab.chunk.js +0 -1
  45. streamlit/static/static/js/6718.2e6586ef.chunk.js +0 -1
  46. streamlit/static/static/js/7175.24e7dd6b.chunk.js +0 -1
  47. streamlit/static/static/js/8691.cb9c04cf.chunk.js +0 -1
  48. streamlit/static/static/js/main.0467dc11.js +0 -2
  49. /streamlit/static/static/js/{main.0467dc11.js.LICENSE.txt → main.66b15329.js.LICENSE.txt} +0 -0
  50. {streamlit_nightly-1.37.1.dev20240730.data → streamlit_nightly-1.37.1.dev20240801.data}/scripts/streamlit.cmd +0 -0
  51. {streamlit_nightly-1.37.1.dev20240730.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/WHEEL +0 -0
  52. {streamlit_nightly-1.37.1.dev20240730.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/entry_points.txt +0 -0
  53. {streamlit_nightly-1.37.1.dev20240730.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/top_level.txt +0 -0
@@ -19,6 +19,7 @@ import threading
19
19
  from copy import deepcopy
20
20
  from typing import (
21
21
  Any,
22
+ Callable,
22
23
  Final,
23
24
  ItemsView,
24
25
  Iterator,
@@ -32,16 +33,98 @@ from blinker import Signal
32
33
 
33
34
  import streamlit as st
34
35
  import streamlit.watcher.path_watcher
35
- from streamlit import file_util, runtime
36
+ from streamlit import runtime
36
37
  from streamlit.logger import get_logger
37
38
 
38
39
  _LOGGER: Final = get_logger(__name__)
39
- SECRETS_FILE_LOCS: Final[list[str]] = [
40
- file_util.get_streamlit_file_path("secrets.toml"),
41
- # NOTE: The order here is important! Project-level secrets should overwrite global
42
- # secrets.
43
- file_util.get_project_streamlit_file_path("secrets.toml"),
44
- ]
40
+
41
+
42
+ class SecretErrorMessages:
43
+ """SecretErrorMessages stores all error messages we use for secrets to allow customization for different environments.
44
+ For example Streamlit Cloud can customize the message to be different than the open source.
45
+
46
+ For internal use, may change in future releases without notice.
47
+ """
48
+
49
+ def __init__(self):
50
+ self.missing_attr_message = lambda attr_name: (
51
+ f'st.secrets has no attribute "{attr_name}". '
52
+ f"Did you forget to add it to secrets.toml, mount it to secret directory, or the app settings on Streamlit Cloud? "
53
+ f"More info: https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management"
54
+ )
55
+ self.missing_key_message = lambda key: (
56
+ f'st.secrets has no key "{key}". '
57
+ f"Did you forget to add it to secrets.toml, mount it to secret directory, or the app settings on Streamlit Cloud? "
58
+ f"More info: https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management"
59
+ )
60
+ self.no_secrets_found = lambda file_paths: (
61
+ f"No secrets found. Valid paths for a secrets.toml file or secret directories are: {', '.join(file_paths)}"
62
+ )
63
+ self.error_parsing_file_at_path = (
64
+ lambda path, ex: f"Error parsing secrets file at {path}: {ex}"
65
+ )
66
+ self.subfolder_path_is_not_a_folder = lambda sub_folder_path: (
67
+ f"{sub_folder_path} is not a folder. "
68
+ "To use directory based secrets, mount every secret in a subfolder under the secret directory"
69
+ )
70
+ self.invalid_secret_path = lambda path: (
71
+ f"Invalid secrets path: {path}: path is not a .toml file or a directory"
72
+ )
73
+
74
+ def set_missing_attr_message(self, message: Callable[[str], str]) -> None:
75
+ """Set the missing attribute error message."""
76
+ self.missing_attr_message = message
77
+
78
+ def set_missing_key_message(self, message: Callable[[str], str]) -> None:
79
+ """Set the missing key error message."""
80
+ self.missing_key_message = message
81
+
82
+ def set_no_secrets_found_message(self, message: Callable[[list[str]], str]) -> None:
83
+ """Set the no secrets found error message."""
84
+ self.no_secrets_found = message
85
+
86
+ def set_error_parsing_file_at_path_message(
87
+ self, message: Callable[[str, Exception], str]
88
+ ) -> None:
89
+ """Set the error parsing file at path error message."""
90
+ self.error_parsing_file_at_path = message
91
+
92
+ def set_subfolder_path_is_not_a_folder_message(
93
+ self, message: Callable[[str], str]
94
+ ) -> None:
95
+ """Set the subfolder path is not a folder error message."""
96
+ self.subfolder_path_is_not_a_folder = message
97
+
98
+ def set_invalid_secret_path_message(self, message: Callable[[str], str]) -> None:
99
+ """Set the invalid secret path error message."""
100
+ self.invalid_secret_path = message
101
+
102
+ def get_missing_attr_message(self, attr_name: str) -> str:
103
+ """Get the missing attribute error message."""
104
+ return self.missing_attr_message(attr_name)
105
+
106
+ def get_missing_key_message(self, key: str) -> str:
107
+ """Get the missing key error message."""
108
+ return self.missing_key_message(key)
109
+
110
+ def get_no_secrets_found_message(self, file_paths: list[str]) -> str:
111
+ """Get the no secrets found error message."""
112
+ return self.no_secrets_found(file_paths)
113
+
114
+ def get_error_parsing_file_at_path_message(self, path: str, ex: Exception) -> str:
115
+ """Get the error parsing file at path error message."""
116
+ return self.error_parsing_file_at_path(path, ex)
117
+
118
+ def get_subfolder_path_is_not_a_folder_message(self, sub_folder_path: str) -> str:
119
+ """Get the subfolder path is not a folder error message."""
120
+ return self.subfolder_path_is_not_a_folder(sub_folder_path)
121
+
122
+ def get_invalid_secret_path_message(self, path: str) -> str:
123
+ """Get the invalid secret path error message."""
124
+ return self.invalid_secret_path(path)
125
+
126
+
127
+ secret_error_messages_singleton: Final = SecretErrorMessages()
45
128
 
46
129
 
47
130
  def _convert_to_dict(obj: Mapping[str, Any] | AttrDict) -> dict[str, Any]:
@@ -52,24 +135,15 @@ def _convert_to_dict(obj: Mapping[str, Any] | AttrDict) -> dict[str, Any]:
52
135
 
53
136
 
54
137
  def _missing_attr_error_message(attr_name: str) -> str:
55
- return (
56
- f'st.secrets has no attribute "{attr_name}". '
57
- f"Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? "
58
- f"More info: https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management"
59
- )
138
+ return secret_error_messages_singleton.get_missing_attr_message(attr_name)
60
139
 
61
140
 
62
141
  def _missing_key_error_message(key: str) -> str:
63
- return (
64
- f'st.secrets has no key "{key}". '
65
- f"Did you forget to add it to secrets.toml or the app settings on Streamlit Cloud? "
66
- f"More info: https://docs.streamlit.io/deploy/streamlit-community-cloud/deploy-your-app/secrets-management"
67
- )
142
+ return secret_error_messages_singleton.get_missing_key_message(key)
68
143
 
69
144
 
70
145
  class AttrDict(Mapping[str, Any]):
71
- """
72
- We use AttrDict to wrap up dictionary values from secrets
146
+ """We use AttrDict to wrap up dictionary values from secrets
73
147
  to provide dot access to nested secrets
74
148
  """
75
149
 
@@ -123,12 +197,12 @@ class Secrets(Mapping[str, Any]):
123
197
  Safe to use from multiple threads.
124
198
  """
125
199
 
126
- def __init__(self, file_paths: list[str]):
200
+ def __init__(self):
127
201
  # Our secrets dict.
128
202
  self._secrets: Mapping[str, Any] | None = None
129
203
  self._lock = threading.RLock()
130
204
  self._file_watchers_installed = False
131
- self._file_paths = file_paths
205
+ self._suppress_print_error_on_exception = False
132
206
 
133
207
  self.file_change_listener = Signal(
134
208
  doc="Emitted when a `secrets.toml` file has been changed."
@@ -143,12 +217,34 @@ class Secrets(Mapping[str, Any]):
143
217
 
144
218
  Thread-safe.
145
219
  """
220
+ prev_suppress_print_error_on_exception = self._suppress_print_error_on_exception
146
221
  try:
147
- self._parse(print_exceptions=False)
222
+ # temporarily suppress printing errors on exceptions, we don't want to print errors
223
+ # in this method since it only loads secrets if they exist
224
+
225
+ self._suppress_print_error_on_exception = True
226
+ self._parse()
227
+
148
228
  return True
149
229
  except FileNotFoundError:
150
230
  # No secrets.toml files exist. That's fine.
151
231
  return False
232
+ finally:
233
+ self._suppress_print_error_on_exception = (
234
+ prev_suppress_print_error_on_exception
235
+ )
236
+
237
+ def set_suppress_print_error_on_exception(
238
+ self, suppress_print_error_on_exception: bool
239
+ ) -> None:
240
+ """Set whether exceptions should be printed when accessing secrets.
241
+ For internal use, may change in future releases without notice."""
242
+ self._suppress_print_error_on_exception = suppress_print_error_on_exception
243
+
244
+ def _print_exception_if_not_suppressed(self, error_msg: str) -> None:
245
+ """Print the given error message if exceptions are not suppressed."""
246
+ if not self._suppress_print_error_on_exception:
247
+ st.error(str(error_msg))
152
248
 
153
249
  def _reset(self) -> None:
154
250
  """Clear the secrets dictionary and remove any secrets that were
@@ -164,7 +260,95 @@ class Secrets(Mapping[str, Any]):
164
260
  self._maybe_delete_environment_variable(k, v)
165
261
  self._secrets = None
166
262
 
167
- def _parse(self, print_exceptions: bool) -> Mapping[str, Any]:
263
+ def _parse_toml_file(self, path: str) -> tuple[Mapping[str, Any], bool]:
264
+ """Parse a TOML file and return the secrets as a dictionary."""
265
+ secrets = {}
266
+ found_secrets_file = False
267
+
268
+ try:
269
+ with open(path, encoding="utf-8") as f:
270
+ secrets_file_str = f.read()
271
+
272
+ found_secrets_file = True
273
+ except FileNotFoundError:
274
+ # the default config for secrets contains two paths. It's likely one of will not have secrets file.
275
+ return {}, False
276
+
277
+ try:
278
+ import toml
279
+
280
+ secrets.update(toml.loads(secrets_file_str))
281
+ except (TypeError, toml.TomlDecodeError) as ex:
282
+ error_msg = (
283
+ secret_error_messages_singleton.get_error_parsing_file_at_path_message(
284
+ path, ex
285
+ )
286
+ )
287
+ self._print_exception_if_not_suppressed(error_msg)
288
+ raise
289
+
290
+ return secrets, found_secrets_file
291
+
292
+ def _parse_directory(self, path: str) -> tuple[Mapping[str, Any], bool]:
293
+ """Parse a directory for secrets. Directory style can be used to support Kubernetes secrets that are mounted to folders.
294
+
295
+ Example structure:
296
+ - top_level_secret_folder
297
+ - user_pass_secret (folder)
298
+ - username (file), content: myuser
299
+ - password (file), content: mypassword
300
+ - my_plain_secret (folder)
301
+ - regular_secret (file), content: mysecret
302
+
303
+ See: https://kubernetes.io/docs/tasks/inject-data-application/distribute-credentials-secure/#create-a-pod-that-has-access-to-the-secret-data-through-a-volume
304
+ And: https://docs.snowflake.com/en/developer-guide/snowpark-container-services/additional-considerations-services-jobs#passing-secrets-in-local-container-files
305
+ """
306
+ secrets: dict[str, Any] = {}
307
+ found_secrets_file = False
308
+
309
+ for dirname in os.listdir(path):
310
+ sub_folder_path = os.path.join(path, dirname)
311
+ if not os.path.isdir(sub_folder_path):
312
+ error_msg = secret_error_messages_singleton.get_subfolder_path_is_not_a_folder_message(
313
+ sub_folder_path
314
+ )
315
+ self._print_exception_if_not_suppressed(error_msg)
316
+ raise ValueError(error_msg)
317
+ sub_secrets = {}
318
+
319
+ for filename in os.listdir(sub_folder_path):
320
+ file_path = os.path.join(sub_folder_path, filename)
321
+
322
+ # ignore folders
323
+ if os.path.isdir(file_path):
324
+ continue
325
+
326
+ with open(file_path) as f:
327
+ sub_secrets[filename] = f.read().strip()
328
+ found_secrets_file = True
329
+
330
+ if len(sub_secrets) == 1:
331
+ # if there's just one file, collapse it so it's directly under `dirname`
332
+ secrets[dirname] = sub_secrets[list(sub_secrets.keys())[0]]
333
+ else:
334
+ secrets[dirname] = sub_secrets
335
+
336
+ return secrets, found_secrets_file
337
+
338
+ def _parse_file_path(self, path: str) -> tuple[Mapping[str, Any], bool]:
339
+ if path.endswith(".toml"):
340
+ return self._parse_toml_file(path)
341
+
342
+ if os.path.isdir(path):
343
+ return self._parse_directory(path)
344
+
345
+ error_msg = secret_error_messages_singleton.get_invalid_secret_path_message(
346
+ path
347
+ )
348
+ self._print_exception_if_not_suppressed(error_msg)
349
+ raise ValueError(error_msg)
350
+
351
+ def _parse(self) -> Mapping[str, Any]:
168
352
  """Parse our secrets.toml files if they're not already parsed.
169
353
  This function is safe to call from multiple threads.
170
354
 
@@ -190,41 +374,23 @@ class Secrets(Mapping[str, Any]):
190
374
  if self._secrets is not None:
191
375
  return self._secrets
192
376
 
193
- # It's fine for a user to only have one secrets.toml file defined, so
194
- # we ignore individual FileNotFoundErrors when attempting to read files
195
- # below and only raise an exception if we weren't able read *any* secrets
196
- # file.
197
- found_secrets_file = False
198
377
  secrets = {}
199
378
 
200
- for path in self._file_paths:
201
- try:
202
- with open(path, encoding="utf-8") as f:
203
- secrets_file_str = f.read()
204
- found_secrets_file = True
205
- except FileNotFoundError:
206
- continue
207
-
208
- try:
209
- import toml
210
-
211
- secrets.update(toml.loads(secrets_file_str))
212
- except:
213
- if print_exceptions:
214
- st.error(f"Error parsing secrets file at {path}")
215
- raise
379
+ file_paths = st.config.get_option("secrets.files")
380
+ found_secrets_file = False
381
+ for path in file_paths:
382
+ path_secrets, found_secrets_file_in_path = self._parse_file_path(path)
383
+ found_secrets_file = found_secrets_file or found_secrets_file_in_path
384
+ secrets.update(path_secrets)
216
385
 
217
386
  if not found_secrets_file:
218
- err_msg = f"No secrets files found. Valid paths for a secrets.toml file are: {', '.join(self._file_paths)}"
219
- if print_exceptions:
220
- st.error(err_msg)
221
- raise FileNotFoundError(err_msg)
222
-
223
- if len([p for p in self._file_paths if os.path.exists(p)]) > 1:
224
- _LOGGER.info(
225
- f"Secrets found in multiple locations: {', '.join(self._file_paths)}. "
226
- "When multiple secret.toml files exist, local secrets will take precedence over global secrets."
387
+ error_msg = (
388
+ secret_error_messages_singleton.get_no_secrets_found_message(
389
+ file_paths
390
+ )
227
391
  )
392
+ self._print_exception_if_not_suppressed(error_msg)
393
+ raise FileNotFoundError(error_msg)
228
394
 
229
395
  for k, v in secrets.items():
230
396
  self._maybe_set_environment_variable(k, v)
@@ -236,7 +402,7 @@ class Secrets(Mapping[str, Any]):
236
402
 
237
403
  def to_dict(self) -> dict[str, Any]:
238
404
  """Converts the secrets store into a nested dictionary, where nested AttrDict objects are also converted into dictionaries."""
239
- secrets = self._parse(True)
405
+ secrets = self._parse()
240
406
  return _convert_to_dict(secrets)
241
407
 
242
408
  @staticmethod
@@ -262,13 +428,21 @@ class Secrets(Mapping[str, Any]):
262
428
  if self._file_watchers_installed:
263
429
  return
264
430
 
265
- for path in self._file_paths:
431
+ file_paths = st.config.get_option("secrets.files")
432
+ for path in file_paths:
266
433
  try:
267
- streamlit.watcher.path_watcher.watch_file(
268
- path,
269
- self._on_secrets_file_changed,
270
- watcher_type="poll",
271
- )
434
+ if path.endswith(".toml"):
435
+ streamlit.watcher.path_watcher.watch_file(
436
+ path,
437
+ self._on_secrets_changed,
438
+ watcher_type="poll",
439
+ )
440
+ else:
441
+ streamlit.watcher.path_watcher.watch_dir(
442
+ path,
443
+ self._on_secrets_changed,
444
+ watcher_type="poll",
445
+ )
272
446
  except FileNotFoundError:
273
447
  # A user may only have one secrets.toml file defined, so we'd expect
274
448
  # FileNotFoundErrors to be raised when attempting to install a
@@ -279,11 +453,11 @@ class Secrets(Mapping[str, Any]):
279
453
  # failed to avoid repeatedly trying to install it.
280
454
  self._file_watchers_installed = True
281
455
 
282
- def _on_secrets_file_changed(self, changed_file_path) -> None:
456
+ def _on_secrets_changed(self, changed_file_path) -> None:
283
457
  with self._lock:
284
- _LOGGER.debug("Secrets file %s changed, reloading", changed_file_path)
458
+ _LOGGER.debug("Secret path %s changed, reloading", changed_file_path)
285
459
  self._reset()
286
- self._parse(print_exceptions=True)
460
+ self._parse()
287
461
 
288
462
  # Emit a signal to notify receivers that the `secrets.toml` file
289
463
  # has been changed.
@@ -296,7 +470,7 @@ class Secrets(Mapping[str, Any]):
296
470
  Thread-safe.
297
471
  """
298
472
  try:
299
- value = self._parse(True)[key]
473
+ value = self._parse()[key]
300
474
  if not isinstance(value, Mapping):
301
475
  return value
302
476
  else:
@@ -314,7 +488,7 @@ class Secrets(Mapping[str, Any]):
314
488
  Thread-safe.
315
489
  """
316
490
  try:
317
- value = self._parse(True)[key]
491
+ value = self._parse()[key]
318
492
  if not isinstance(value, Mapping):
319
493
  return value
320
494
  else:
@@ -329,36 +503,36 @@ class Secrets(Mapping[str, Any]):
329
503
  # the file must already exist.
330
504
  """A string representation of the contents of the dict. Thread-safe."""
331
505
  if not runtime.exists():
332
- return f"{self.__class__.__name__}(file_paths={self._file_paths!r})"
333
- return repr(self._parse(True))
506
+ return f"{self.__class__.__name__}"
507
+ return repr(self._parse())
334
508
 
335
509
  def __len__(self) -> int:
336
510
  """The number of entries in the dict. Thread-safe."""
337
- return len(self._parse(True))
511
+ return len(self._parse())
338
512
 
339
513
  def has_key(self, k: str) -> bool:
340
514
  """True if the given key is in the dict. Thread-safe."""
341
- return k in self._parse(True)
515
+ return k in self._parse()
342
516
 
343
517
  def keys(self) -> KeysView[str]:
344
518
  """A view of the keys in the dict. Thread-safe."""
345
- return self._parse(True).keys()
519
+ return self._parse().keys()
346
520
 
347
521
  def values(self) -> ValuesView[Any]:
348
522
  """A view of the values in the dict. Thread-safe."""
349
- return self._parse(True).values()
523
+ return self._parse().values()
350
524
 
351
525
  def items(self) -> ItemsView[str, Any]:
352
526
  """A view of the key-value items in the dict. Thread-safe."""
353
- return self._parse(True).items()
527
+ return self._parse().items()
354
528
 
355
529
  def __contains__(self, key: Any) -> bool:
356
530
  """True if the given key is in the dict. Thread-safe."""
357
- return key in self._parse(True)
531
+ return key in self._parse()
358
532
 
359
533
  def __iter__(self) -> Iterator[str]:
360
534
  """An iterator over the keys in the dict. Thread-safe."""
361
- return iter(self._parse(True))
535
+ return iter(self._parse())
362
536
 
363
537
 
364
- secrets_singleton: Final = Secrets(SECRETS_FILE_LOCS)
538
+ secrets_singleton: Final = Secrets()
@@ -186,7 +186,7 @@ class WStates(MutableMapping[str, Any]):
186
186
  def remove_stale_widgets(
187
187
  self,
188
188
  active_widget_ids: set[str],
189
- fragment_ids_this_run: set[str] | None,
189
+ fragment_ids_this_run: list[str] | None,
190
190
  ) -> None:
191
191
  """Remove widget state for stale widgets."""
192
192
  self.states = {
@@ -579,13 +579,9 @@ class SessionState:
579
579
  if ctx is None:
580
580
  return
581
581
 
582
- fragment_ids_this_run = (
583
- set(ctx.script_requests.fragment_id_queue) if ctx.script_requests else set()
584
- )
585
-
586
582
  self._new_widget_state.remove_stale_widgets(
587
583
  active_widget_ids,
588
- fragment_ids_this_run,
584
+ ctx.fragment_ids_this_run,
589
585
  )
590
586
 
591
587
  # Remove entries from _old_state corresponding to
@@ -598,7 +594,7 @@ class SessionState:
598
594
  or not _is_stale_widget(
599
595
  self._new_widget_state.widget_metadata.get(k),
600
596
  active_widget_ids,
601
- fragment_ids_this_run,
597
+ ctx.fragment_ids_this_run,
602
598
  )
603
599
  )
604
600
  }
@@ -706,7 +702,7 @@ def _is_internal_key(key: str) -> bool:
706
702
  def _is_stale_widget(
707
703
  metadata: WidgetMetadata[Any] | None,
708
704
  active_widget_ids: set[str],
709
- fragment_ids_this_run: set[str] | None,
705
+ fragment_ids_this_run: list[str] | None,
710
706
  ) -> bool:
711
707
  if not metadata:
712
708
  return True
@@ -1,45 +1,45 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.554f96d9.css",
4
- "main.js": "./static/js/main.0467dc11.js",
4
+ "main.js": "./static/js/main.66b15329.js",
5
5
  "static/js/9336.3e046ad7.chunk.js": "./static/js/9336.3e046ad7.chunk.js",
6
6
  "static/js/9330.2b4c99e0.chunk.js": "./static/js/9330.2b4c99e0.chunk.js",
7
7
  "static/js/2736.7d516fcc.chunk.js": "./static/js/2736.7d516fcc.chunk.js",
8
8
  "static/js/3301.0cd98943.chunk.js": "./static/js/3301.0cd98943.chunk.js",
9
9
  "static/css/8148.49dfd2ce.chunk.css": "./static/css/8148.49dfd2ce.chunk.css",
10
- "static/js/8148.1b2c085e.chunk.js": "./static/js/8148.1b2c085e.chunk.js",
10
+ "static/js/8148.c7db8490.chunk.js": "./static/js/8148.c7db8490.chunk.js",
11
11
  "static/css/5441.e3b876c5.chunk.css": "./static/css/5441.e3b876c5.chunk.css",
12
- "static/js/5441.324eb9ab.chunk.js": "./static/js/5441.324eb9ab.chunk.js",
12
+ "static/js/5441.a564862e.chunk.js": "./static/js/5441.a564862e.chunk.js",
13
13
  "static/js/8427.e051b59f.chunk.js": "./static/js/8427.e051b59f.chunk.js",
14
14
  "static/js/7323.b74cc85b.chunk.js": "./static/js/7323.b74cc85b.chunk.js",
15
15
  "static/js/8536.572570cc.chunk.js": "./static/js/8536.572570cc.chunk.js",
16
16
  "static/js/7805.acc6316a.chunk.js": "./static/js/7805.acc6316a.chunk.js",
17
- "static/js/4500.be0eb305.chunk.js": "./static/js/4500.be0eb305.chunk.js",
17
+ "static/js/4500.c007e274.chunk.js": "./static/js/4500.c007e274.chunk.js",
18
18
  "static/js/1307.36b77087.chunk.js": "./static/js/1307.36b77087.chunk.js",
19
19
  "static/js/2469.31e2695e.chunk.js": "./static/js/2469.31e2695e.chunk.js",
20
20
  "static/js/4113.99983645.chunk.js": "./static/js/4113.99983645.chunk.js",
21
- "static/js/1168.14f7c6ff.chunk.js": "./static/js/1168.14f7c6ff.chunk.js",
21
+ "static/js/1168.aa1401dd.chunk.js": "./static/js/1168.aa1401dd.chunk.js",
22
22
  "static/js/178.7bea8c5d.chunk.js": "./static/js/178.7bea8c5d.chunk.js",
23
23
  "static/js/1792.8bd6ce2a.chunk.js": "./static/js/1792.8bd6ce2a.chunk.js",
24
- "static/js/1116.f824d083.chunk.js": "./static/js/1116.f824d083.chunk.js",
24
+ "static/js/1116.d8656dab.chunk.js": "./static/js/1116.d8656dab.chunk.js",
25
25
  "static/js/3513.7dedbda2.chunk.js": "./static/js/3513.7dedbda2.chunk.js",
26
- "static/js/7602.85e7b7bf.chunk.js": "./static/js/7602.85e7b7bf.chunk.js",
26
+ "static/js/7602.b5f7407a.chunk.js": "./static/js/7602.b5f7407a.chunk.js",
27
27
  "static/js/6013.f6083314.chunk.js": "./static/js/6013.f6083314.chunk.js",
28
- "static/js/4335.a695f906.chunk.js": "./static/js/4335.a695f906.chunk.js",
29
- "static/js/4177.69f9f18d.chunk.js": "./static/js/4177.69f9f18d.chunk.js",
30
- "static/js/1451.229b62c4.chunk.js": "./static/js/1451.229b62c4.chunk.js",
28
+ "static/js/4335.fb48fd8e.chunk.js": "./static/js/4335.fb48fd8e.chunk.js",
29
+ "static/js/4177.e5631c43.chunk.js": "./static/js/4177.e5631c43.chunk.js",
30
+ "static/js/1451.e9542cc9.chunk.js": "./static/js/1451.e9542cc9.chunk.js",
31
31
  "static/js/2634.1249dc7a.chunk.js": "./static/js/2634.1249dc7a.chunk.js",
32
- "static/js/1074.d1dd1731.chunk.js": "./static/js/1074.d1dd1731.chunk.js",
32
+ "static/js/1074.86034b28.chunk.js": "./static/js/1074.86034b28.chunk.js",
33
33
  "static/js/8477.4d2a23c2.chunk.js": "./static/js/8477.4d2a23c2.chunk.js",
34
34
  "static/js/6853.93dd1c4c.chunk.js": "./static/js/6853.93dd1c4c.chunk.js",
35
- "static/js/4477.87935ac8.chunk.js": "./static/js/4477.87935ac8.chunk.js",
36
- "static/js/4319.bf1c86bf.chunk.js": "./static/js/4319.bf1c86bf.chunk.js",
37
- "static/js/5106.086585ae.chunk.js": "./static/js/5106.086585ae.chunk.js",
38
- "static/js/4666.b9eab191.chunk.js": "./static/js/4666.b9eab191.chunk.js",
39
- "static/js/3599.565b1eba.chunk.js": "./static/js/3599.565b1eba.chunk.js",
40
- "static/js/8691.cb9c04cf.chunk.js": "./static/js/8691.cb9c04cf.chunk.js",
41
- "static/js/6718.2e6586ef.chunk.js": "./static/js/6718.2e6586ef.chunk.js",
42
- "static/js/7175.24e7dd6b.chunk.js": "./static/js/7175.24e7dd6b.chunk.js",
35
+ "static/js/4477.b85593dd.chunk.js": "./static/js/4477.b85593dd.chunk.js",
36
+ "static/js/4319.00adb829.chunk.js": "./static/js/4319.00adb829.chunk.js",
37
+ "static/js/5106.e53c485c.chunk.js": "./static/js/5106.e53c485c.chunk.js",
38
+ "static/js/4666.c8694d51.chunk.js": "./static/js/4666.c8694d51.chunk.js",
39
+ "static/js/3599.f1e3cc27.chunk.js": "./static/js/3599.f1e3cc27.chunk.js",
40
+ "static/js/8691.95ba8af9.chunk.js": "./static/js/8691.95ba8af9.chunk.js",
41
+ "static/js/6718.7bc66e7a.chunk.js": "./static/js/6718.7bc66e7a.chunk.js",
42
+ "static/js/7175.14622908.chunk.js": "./static/js/7175.14622908.chunk.js",
43
43
  "static/js/5345.73d26e5d.chunk.js": "./static/js/5345.73d26e5d.chunk.js",
44
44
  "static/js/9865.fd93213d.chunk.js": "./static/js/9865.fd93213d.chunk.js",
45
45
  "static/js/6405.ac5a6f23.chunk.js": "./static/js/6405.ac5a6f23.chunk.js",
@@ -152,6 +152,6 @@
152
152
  },
153
153
  "entrypoints": [
154
154
  "static/css/main.554f96d9.css",
155
- "static/js/main.0467dc11.js"
155
+ "static/js/main.66b15329.js"
156
156
  ]
157
157
  }
@@ -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.0467dc11.js"></script><link href="./static/css/main.554f96d9.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
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.66b15329.js"></script><link href="./static/css/main.554f96d9.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 @@
1
+ "use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[1074],{87814:(e,t,s)=>{s.d(t,{K:()=>o});var i=s(50641);class o{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,s){(0,i.bb)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,i.bM)(t)&&(this.formClearListener=e.addFormClearedListener(t,s),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}}},91074:(e,t,s)=>{s.r(t),s.d(t,{default:()=>C});var i=s(66845),o=s(91706),r=s(81810),l=s.n(r),a=s(25621),n=s(90481),d=s(91034),h=s(12576),p=s(87814),c=s(98478),m=s(86659);const u=(0,s(1515).Z)("div",{target:"e6zijwc0"})((e=>{let{theme:t}=e;return{"span[aria-disabled='true']":{background:t.colors.fadedText05}}}),"");var g=s(8879),v=s(68411),f=s(7978),b=s(97965),S=s(50641),y=s(40864);class w extends i.PureComponent{constructor(){super(...arguments),this.formClearHelper=new p.K,this.state={value:this.initialValue},this.commitWidgetValue=e=>{const{widgetMgr:t,element:s,fragmentId:i}=this.props;t.setIntArrayValue(s,this.state.value,e,i)},this.onFormCleared=()=>{this.setState(((e,t)=>({value:t.element.default})),(()=>this.commitWidgetValue({fromUi:!0})))},this.onChange=e=>{this.props.element.maxSelections&&"select"===e.type&&this.state.value.length>=this.props.element.maxSelections||this.setState(this.generateNewState(e),(()=>{this.commitWidgetValue({fromUi:!0})}))},this.filterOptions=(e,t)=>{if(this.overMaxSelections())return[];const s=e.filter((e=>!this.state.value.includes(Number(e.value))));return(0,b.HX)(s,t)}}overMaxSelections(){return this.props.element.maxSelections>0&&this.state.value.length>=this.props.element.maxSelections}getNoResultsMsg(){const{maxSelections:e}=this.props.element,{value:t}=this.state;if(0===e)return"No results";if(t.length===e){const t=1!==e?"options":"option";return"You can only select up to ".concat(e," ").concat(t,". Remove an option first.")}return"No results"}get initialValue(){const e=this.props.widgetMgr.getIntArrayValue(this.props.element);return void 0!==e?e:this.props.element.default}componentDidMount(){this.props.element.setValue?this.updateFromProtobuf():this.commitWidgetValue({fromUi:!1})}componentDidUpdate(){this.maybeUpdateFromProtobuf()}componentWillUnmount(){this.formClearHelper.disconnect()}maybeUpdateFromProtobuf(){const{setValue:e}=this.props.element;e&&this.updateFromProtobuf()}updateFromProtobuf(){const{value:e}=this.props.element;this.props.element.setValue=!1,this.setState({value:e},(()=>{this.commitWidgetValue({fromUi:!1})}))}get valueFromState(){return this.state.value.map((e=>{const t=this.props.element.options[e];return{value:e.toString(),label:t}}))}generateNewState(e){const t=()=>{var t;const s=null===(t=e.option)||void 0===t?void 0:t.value;return parseInt(s,10)};switch(e.type){case"remove":return{value:l()(this.state.value,t())};case"clear":return{value:[]};case"select":return{value:this.state.value.concat([t()])};default:throw new Error("State transition is unknown: ".concat(e.type))}}render(){var e;const{element:t,theme:s,width:i,widgetMgr:r}=this.props,l={width:i},{options:a}=t,p=0===a.length||this.props.disabled,b=0===a.length?"No options to select.":t.placeholder,w=a.map(((e,t)=>({label:e,value:t.toString()})));this.formClearHelper.manageFormClearListener(r,t.formId,this.onFormCleared);const C=a.length>10;return(0,y.jsxs)("div",{className:"row-widget stMultiSelect","data-testid":"stMultiSelect",style:l,children:[(0,y.jsx)(c.O,{label:t.label,disabled:p,labelVisibility:(0,S.iF)(null===(e=t.labelVisibility)||void 0===e?void 0:e.value),children:t.help&&(0,y.jsx)(m.dT,{children:(0,y.jsx)(g.Z,{content:t.help,placement:v.u.TOP_RIGHT})})}),(0,y.jsx)(u,{children:(0,y.jsx)(d.Z,{options:w,labelKey:"label",valueKey:"value","aria-label":t.label,placeholder:b,type:h.wD.select,multi:!0,onChange:this.onChange,value:this.valueFromState,disabled:p,size:"compact",noResultsMsg:this.getNoResultsMsg(),filterOptions:this.filterOptions,closeOnSelect:!1,overrides:{SelectArrow:{component:n.Z,props:{overrides:{Svg:{style:()=>({width:s.iconSizes.xl,height:s.iconSizes.xl})}}}},IconsContainer:{style:()=>({paddingRight:s.spacing.sm})},ControlContainer:{style:{minHeight:s.sizes.minElementHeight,borderLeftWidth:s.sizes.borderWidth,borderRightWidth:s.sizes.borderWidth,borderTopWidth:s.sizes.borderWidth,borderBottomWidth:s.sizes.borderWidth}},Placeholder:{style:()=>({flex:"inherit"})},ValueContainer:{style:()=>({paddingLeft:s.spacing.sm,paddingTop:0,paddingBottom:0,paddingRight:0})},ClearIcon:{props:{overrides:{Svg:{style:{color:s.colors.darkGray,transform:"scale(1.5)",width:s.spacing.twoXL,":hover":{fill:s.colors.bodyText}}}}}},SearchIcon:{style:{color:s.colors.darkGray}},Tag:{props:{overrides:{Root:{style:{borderTopLeftRadius:s.radii.md,borderTopRightRadius:s.radii.md,borderBottomRightRadius:s.radii.md,borderBottomLeftRadius:s.radii.md,fontSize:s.fontSizes.sm,paddingLeft:s.spacing.sm,marginLeft:0,marginRight:s.spacing.sm,height:"28px"}},Action:{style:{paddingLeft:0}},ActionIcon:{props:{overrides:{Svg:{style:{width:"10px",height:"10px"}}}}},Text:{style:{fontSize:s.fontSizes.md}}}}},MultiValue:{props:{overrides:{Root:{style:{fontSize:s.fontSizes.sm}}}}},Input:{props:{readOnly:o.tq&&!1===C?"readonly":null}},Dropdown:{component:f.Z}}})})]})}}const C=(0,a.b)(w)}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[1116],{81116:(e,t,r)=>{r.r(t),r.d(t,{default:()=>M});var n=r(66845),o=r(25621),i=r(62813),c=r.n(i),a=Object.freeze({radio:"radio",checkbox:"checkbox"}),l=(Object.freeze({change:"change"}),"default"),u=r(80318),s=r(99282),f=(0,r(80745).zo)("div",(function(e){var t=e.$shape,r=e.$length,n=e.$theme,o=1===r?void 0:t!==l?"-".concat(n.sizing.scale100):"-0.5px";return{display:"flex",marginLeft:o,marginRight:o}}));function d(e){return d="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},d(e)}function p(){return p=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},p.apply(this,arguments)}function h(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 y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}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=[],c=!0,a=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);c=!0);}catch(l){a=!0,o=l}finally{try{c||null==r.return||r.return()}finally{if(a)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 g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}function O(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=w(e);if(t){var o=w(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===d(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return E(e)}(this,r)}}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},w(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}f.displayName="StyledRoot",f.displayName="StyledRoot";var j=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&&g(e,t)}(c,e);var t,r,o,i=O(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(E(e=i.call.apply(i,[this].concat(r))),"childRefs",{}),e}return t=c,r=[{key:"render",value:function(){var e=this,t=this.props,r=t.overrides,o=void 0===r?{}:r,i=t.mode,c=void 0===i?a.checkbox:i,d=t.children,h=t.selected,m=t.disabled,v=t.onClick,g=t.kind,O=t.shape,E=t.size,w=b((0,u.jb)(o.Root,f),2),C=w[0],j=w[1],S=this.props["aria-label"]||this.props.ariaLabel,k=c===a.radio,L=n.Children.count(d);return n.createElement(s.R.Consumer,null,(function(t){return n.createElement(C,p({"aria-label":S||t.buttongroup.ariaLabel,"data-baseweb":"button-group",role:k?"radiogroup":"group",$shape:O,$length:d.length},j),n.Children.map(d,(function(t,r){if(!n.isValidElement(t))return null;var o=t.props.isSelected?t.props.isSelected:function(e,t){return!(!Array.isArray(e)&&"number"!==typeof e)&&(Array.isArray(e)?e.includes(t):e===t)}(h,r);return k&&(e.childRefs[r]=n.createRef()),n.cloneElement(t,{disabled:m||t.props.disabled,isSelected:o,ref:k?e.childRefs[r]:void 0,tabIndex:!k||o||k&&(!h||-1===h)&&0===r?0:-1,onKeyDown:function(t){if(k){var r=Number(h)?Number(h):0;if("ArrowUp"===t.key||"ArrowLeft"===t.key){t.preventDefault&&t.preventDefault();var n=r-1<0?L-1:r-1;v&&v(t,n),e.childRefs[n].current&&e.childRefs[n].current.focus()}if("ArrowDown"===t.key||"ArrowRight"===t.key){t.preventDefault&&t.preventDefault();var o=r+1>L-1?0:r+1;v&&v(t,o),e.childRefs[o].current&&e.childRefs[o].current.focus()}}},kind:g,onClick:function(e){m||(t.props.onClick&&t.props.onClick(e),v&&v(e,r))},shape:O,size:E,overrides:y({BaseButton:{style:function(e){var t=e.$theme;return 1===d.length?{}:O!==l?{marginLeft:t.sizing.scale100,marginRight:t.sizing.scale100}:{marginLeft:"0.5px",marginRight:"0.5px"}},props:{"aria-checked":o,role:k?"radio":"checkbox"}}},t.props.overrides)})})))}))}}],r&&v(t.prototype,r),o&&v(t,o),Object.defineProperty(t,"prototype",{writable:!1}),c}(n.Component);C(j,"defaultProps",{disabled:!1,onClick:function(){},shape:l,size:"default",kind:"secondary"});var S=r(81354),k=r(9003),L=r(22704),R=r(16295),_=r(87814),I=r(40864);function P(e,t,r,n){let o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];r.setIntArrayValue(t,e,{fromUi:o},n)}function A(e){return(0,I.jsx)(L.p,{size:"lg",iconValue:e})}function x(e,t,r,o,i){var c;const a=function(e,t,r,n){return r.indexOf(n)>-1||t===R.hE.ClickMode.SINGLE_SELECT&&e===R.hE.SelectionVisualization.ALL_UP_TO_SELECTED&&r.length>0&&n<r[0]}(r,o,i,t),l=function(e,t,r){return e&&r?r:t}(a,null!==(c=e.content)&&void 0!==c?c:"",e.selectedContent),u=!a||e.selectedContent?S.nW.BORDERLESS_ICON:S.nW.BORDERLESS_ICON_ACTIVE;return(0,n.forwardRef)((function(e,t){return(0,I.jsx)(k.ZP,{...e,size:S.V5.XSMALL,kind:u,children:A(l)})}))}const M=function(e){const{disabled:t,element:r,fragmentId:i,widgetMgr:l}=e,{clickMode:u,default:s,options:f,value:d,selectionVisualization:p}=r,h=(0,o.u)(),[y,b]=(0,n.useState)(function(e,t){const r=e.getIntArrayValue(t);return null!==r&&void 0!==r?r:t.default}(l,r)||[]),m=n.useRef(r),v=n.useRef(void 0);(0,n.useEffect)((()=>{if(!r.formId)return;const e=new _.K;return e.manageFormClearListener(l,r.formId,(()=>{b(s)})),()=>{e.disconnect()}}),[r.formId,l,s]);const g=(0,n.useMemo)((()=>JSON.stringify(d)),[d]);let O;(0,n.useEffect)((()=>{const e=JSON.parse(g);if(m.current.setValue)b(e),P(y,m.current,l,i,!1),m.current.setValue=!1;else{if(c()(y,v.current))return;const e=void 0!==v.current;P(y,m.current,l,i,e)}v.current=y}),[y,l,i,g]),u===R.hE.ClickMode.SINGLE_SELECT?O=a.radio:u===R.hE.ClickMode.MULTI_SELECT&&(O=a.checkbox);const E=f.map(((e,t)=>{const r=x(e,t,p,u,y);return(0,I.jsx)(r,{},"".concat(e.content,"-").concat(t))}));return(0,I.jsx)(j,{disabled:t,mode:O,onClick:(e,t)=>{const r=function(e,t,r){return e==R.hE.ClickMode.MULTI_SELECT?function(e,t){return t.includes(e)?t.filter((t=>t!==e)):[...t,e]}(t,null!==r&&void 0!==r?r:[]):[t]}(u,t,y);b(r)},selected:u===R.hE.ClickMode.MULTI_SELECT?y:(w=y,0===w.length?-1:w[0]),overrides:{Root:{style:{flexWrap:"wrap",gap:h.spacing.threeXS},props:{"data-testid":"stButtonGroup"}}},children:E});var w}},87814:(e,t,r)=>{r.d(t,{K:()=>o});var n=r(50641);class o{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,r){null!=this.formClearListener&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,n.bM)(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}}}}]);
1
+ "use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[1116],{81116:(e,t,r)=>{r.r(t),r.d(t,{default:()=>M});var n=r(66845),o=r(25621),i=r(62813),c=r.n(i),a=Object.freeze({radio:"radio",checkbox:"checkbox"}),l=(Object.freeze({change:"change"}),"default"),u=r(80318),s=r(99282),f=(0,r(80745).zo)("div",(function(e){var t=e.$shape,r=e.$length,n=e.$theme,o=1===r?void 0:t!==l?"-".concat(n.sizing.scale100):"-0.5px";return{display:"flex",marginLeft:o,marginRight:o}}));function d(e){return d="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},d(e)}function p(){return p=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},p.apply(this,arguments)}function h(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 y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}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=[],c=!0,a=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);c=!0);}catch(l){a=!0,o=l}finally{try{c||null==r.return||r.return()}finally{if(a)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 g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}function O(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=w(e);if(t){var o=w(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return function(e,t){if(t&&("object"===d(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return E(e)}(this,r)}}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},w(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}f.displayName="StyledRoot",f.displayName="StyledRoot";var j=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&&g(e,t)}(c,e);var t,r,o,i=O(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(E(e=i.call.apply(i,[this].concat(r))),"childRefs",{}),e}return t=c,r=[{key:"render",value:function(){var e=this,t=this.props,r=t.overrides,o=void 0===r?{}:r,i=t.mode,c=void 0===i?a.checkbox:i,d=t.children,h=t.selected,m=t.disabled,v=t.onClick,g=t.kind,O=t.shape,E=t.size,w=b((0,u.jb)(o.Root,f),2),C=w[0],j=w[1],S=this.props["aria-label"]||this.props.ariaLabel,k=c===a.radio,L=n.Children.count(d);return n.createElement(s.R.Consumer,null,(function(t){return n.createElement(C,p({"aria-label":S||t.buttongroup.ariaLabel,"data-baseweb":"button-group",role:k?"radiogroup":"group",$shape:O,$length:d.length},j),n.Children.map(d,(function(t,r){if(!n.isValidElement(t))return null;var o=t.props.isSelected?t.props.isSelected:function(e,t){return!(!Array.isArray(e)&&"number"!==typeof e)&&(Array.isArray(e)?e.includes(t):e===t)}(h,r);return k&&(e.childRefs[r]=n.createRef()),n.cloneElement(t,{disabled:m||t.props.disabled,isSelected:o,ref:k?e.childRefs[r]:void 0,tabIndex:!k||o||k&&(!h||-1===h)&&0===r?0:-1,onKeyDown:function(t){if(k){var r=Number(h)?Number(h):0;if("ArrowUp"===t.key||"ArrowLeft"===t.key){t.preventDefault&&t.preventDefault();var n=r-1<0?L-1:r-1;v&&v(t,n),e.childRefs[n].current&&e.childRefs[n].current.focus()}if("ArrowDown"===t.key||"ArrowRight"===t.key){t.preventDefault&&t.preventDefault();var o=r+1>L-1?0:r+1;v&&v(t,o),e.childRefs[o].current&&e.childRefs[o].current.focus()}}},kind:g,onClick:function(e){m||(t.props.onClick&&t.props.onClick(e),v&&v(e,r))},shape:O,size:E,overrides:y({BaseButton:{style:function(e){var t=e.$theme;return 1===d.length?{}:O!==l?{marginLeft:t.sizing.scale100,marginRight:t.sizing.scale100}:{marginLeft:"0.5px",marginRight:"0.5px"}},props:{"aria-checked":o,role:k?"radio":"checkbox"}}},t.props.overrides)})})))}))}}],r&&v(t.prototype,r),o&&v(t,o),Object.defineProperty(t,"prototype",{writable:!1}),c}(n.Component);C(j,"defaultProps",{disabled:!1,onClick:function(){},shape:l,size:"default",kind:"secondary"});var S=r(81354),k=r(9003),L=r(22704),R=r(16295),_=r(87814),I=r(40864);function P(e,t,r,n){let o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];r.setIntArrayValue(t,e,{fromUi:o},n)}function A(e){return(0,I.jsx)(L.p,{size:"lg",iconValue:e})}function x(e,t,r,o,i){var c;const a=function(e,t,r,n){return r.indexOf(n)>-1||t===R.hE.ClickMode.SINGLE_SELECT&&e===R.hE.SelectionVisualization.ALL_UP_TO_SELECTED&&r.length>0&&n<r[0]}(r,o,i,t),l=function(e,t,r){return e&&r?r:t}(a,null!==(c=e.content)&&void 0!==c?c:"",e.selectedContent),u=!a||e.selectedContent?S.nW.BORDERLESS_ICON:S.nW.BORDERLESS_ICON_ACTIVE;return(0,n.forwardRef)((function(e,t){return(0,I.jsx)(k.ZP,{...e,size:S.V5.XSMALL,kind:u,children:A(l)})}))}const M=function(e){const{disabled:t,element:r,fragmentId:i,widgetMgr:l}=e,{clickMode:u,default:s,options:f,value:d,selectionVisualization:p}=r,h=(0,o.u)(),[y,b]=(0,n.useState)(function(e,t){const r=e.getIntArrayValue(t);return null!==r&&void 0!==r?r:t.default}(l,r)||[]),m=n.useRef(r),v=n.useRef(void 0);(0,n.useEffect)((()=>{if(!r.formId)return;const e=new _.K;return e.manageFormClearListener(l,r.formId,(()=>{b(s)})),()=>{e.disconnect()}}),[r.formId,l,s]);const g=(0,n.useMemo)((()=>JSON.stringify(d)),[d]);let O;(0,n.useEffect)((()=>{const e=JSON.parse(g);if(m.current.setValue)b(e),P(y,m.current,l,i,!1),m.current.setValue=!1;else{if(c()(y,v.current))return;const e=void 0!==v.current;P(y,m.current,l,i,e)}v.current=y}),[y,l,i,g]),u===R.hE.ClickMode.SINGLE_SELECT?O=a.radio:u===R.hE.ClickMode.MULTI_SELECT&&(O=a.checkbox);const E=f.map(((e,t)=>{const r=x(e,t,p,u,y);return(0,I.jsx)(r,{},"".concat(e.content,"-").concat(t))}));return(0,I.jsx)(j,{disabled:t,mode:O,onClick:(e,t)=>{const r=function(e,t,r){return e==R.hE.ClickMode.MULTI_SELECT?function(e,t){return t.includes(e)?t.filter((t=>t!==e)):[...t,e]}(t,null!==r&&void 0!==r?r:[]):[t]}(u,t,y);b(r)},selected:u===R.hE.ClickMode.MULTI_SELECT?y:(w=y,0===w.length?-1:w[0]),overrides:{Root:{style:{flexWrap:"wrap",gap:h.spacing.threeXS},props:{"data-testid":"stButtonGroup"}}},children:E});var w}},87814:(e,t,r)=>{r.d(t,{K:()=>o});var n=r(50641);class o{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,t,r){(0,n.bb)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===t||(this.disconnect(),(0,n.bM)(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}}}}]);