streamlit-nightly 1.37.1.dev20240731__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.
- streamlit/commands/execution_control.py +2 -4
- streamlit/config.py +15 -0
- streamlit/proto/ClientState_pb2.py +2 -2
- streamlit/proto/ClientState_pb2.pyi +4 -1
- streamlit/runtime/app_session.py +1 -0
- streamlit/runtime/fragment.py +1 -1
- streamlit/runtime/metrics_util.py +1 -3
- streamlit/runtime/scriptrunner/exec_code.py +20 -3
- streamlit/runtime/scriptrunner/script_requests.py +2 -7
- streamlit/runtime/scriptrunner/script_run_context.py +3 -1
- streamlit/runtime/scriptrunner/script_runner.py +15 -5
- streamlit/runtime/secrets.py +249 -75
- streamlit/runtime/state/session_state.py +4 -8
- streamlit/static/asset-manifest.json +3 -3
- streamlit/static/index.html +1 -1
- streamlit/static/static/js/{1168.6baadc46.chunk.js → 1168.aa1401dd.chunk.js} +1 -1
- streamlit/static/static/js/main.66b15329.js +2 -0
- streamlit/testing/v1/app_test.py +1 -1
- {streamlit_nightly-1.37.1.dev20240731.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/METADATA +1 -1
- {streamlit_nightly-1.37.1.dev20240731.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/RECORD +25 -25
- streamlit/static/static/js/main.02598bc8.js +0 -2
- /streamlit/static/static/js/{main.02598bc8.js.LICENSE.txt → main.66b15329.js.LICENSE.txt} +0 -0
- {streamlit_nightly-1.37.1.dev20240731.data → streamlit_nightly-1.37.1.dev20240801.data}/scripts/streamlit.cmd +0 -0
- {streamlit_nightly-1.37.1.dev20240731.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/WHEEL +0 -0
- {streamlit_nightly-1.37.1.dev20240731.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/entry_points.txt +0 -0
- {streamlit_nightly-1.37.1.dev20240731.dist-info → streamlit_nightly-1.37.1.dev20240801.dist-info}/top_level.txt +0 -0
streamlit/runtime/secrets.py
CHANGED
@@ -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
|
36
|
+
from streamlit import runtime
|
36
37
|
from streamlit.logger import get_logger
|
37
38
|
|
38
39
|
_LOGGER: Final = get_logger(__name__)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
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.
|
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
|
-
|
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
|
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
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
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
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
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(
|
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
|
-
|
431
|
+
file_paths = st.config.get_option("secrets.files")
|
432
|
+
for path in file_paths:
|
266
433
|
try:
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
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
|
456
|
+
def _on_secrets_changed(self, changed_file_path) -> None:
|
283
457
|
with self._lock:
|
284
|
-
_LOGGER.debug("
|
458
|
+
_LOGGER.debug("Secret path %s changed, reloading", changed_file_path)
|
285
459
|
self._reset()
|
286
|
-
self._parse(
|
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(
|
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(
|
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__}
|
333
|
-
return repr(self._parse(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
535
|
+
return iter(self._parse())
|
362
536
|
|
363
537
|
|
364
|
-
secrets_singleton: Final = Secrets(
|
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:
|
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:
|
705
|
+
fragment_ids_this_run: list[str] | None,
|
710
706
|
) -> bool:
|
711
707
|
if not metadata:
|
712
708
|
return True
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"files": {
|
3
3
|
"main.css": "./static/css/main.554f96d9.css",
|
4
|
-
"main.js": "./static/js/main.
|
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",
|
@@ -18,7 +18,7 @@
|
|
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.
|
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
24
|
"static/js/1116.d8656dab.chunk.js": "./static/js/1116.d8656dab.chunk.js",
|
@@ -152,6 +152,6 @@
|
|
152
152
|
},
|
153
153
|
"entrypoints": [
|
154
154
|
"static/css/main.554f96d9.css",
|
155
|
-
"static/js/main.
|
155
|
+
"static/js/main.66b15329.js"
|
156
156
|
]
|
157
157
|
}
|
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.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>
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[1168],{71168:(e,o,t)=>{t.r(o),t.d(o,{default:()=>w});var l=t(66845),n=t(25621),i=t(42736),r=t(16295),s=t(23593),c=t(50641),a=t(87814),d=t(96825),p=t.n(d),u=t(27466),h=t(63765),m=t(23849);function f(e,o,t){return e=function(e,o){return(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll("#000032",(0,u.By)(o))).replaceAll("#000033",(0,u.He)(o))).replaceAll("#000034",(0,u.Iy)(o)?o.colors.blue80:o.colors.blue40)).replaceAll("#000035",(0,u.ny)(o))).replaceAll("#000036",(0,u.Xy)(o))).replaceAll("#000037",(0,u.yq)(o))).replaceAll("#000038",o.colors.bgColor)).replaceAll("#000039",o.colors.fadedText05)).replaceAll("#000040",o.colors.bgMix)}(e,o),e=function(e,o,t){const l="#000001",n="#000002",i="#000003",r="#000004",s="#000005",c="#000006",a="#000007",d="#000008",p="#000009",h="#000010";if("streamlit"===t){const t=(0,u.iY)(o);e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,t[0])).replaceAll(n,t[1])).replaceAll(i,t[2])).replaceAll(r,t[3])).replaceAll(s,t[4])).replaceAll(c,t[5])).replaceAll(a,t[6])).replaceAll(d,t[7])).replaceAll(p,t[8])).replaceAll(h,t[9])}else e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,"#636efa")).replaceAll(n,"#EF553B")).replaceAll(i,"#00cc96")).replaceAll(r,"#ab63fa")).replaceAll(s,"#FFA15A")).replaceAll(c,"#19d3f3")).replaceAll(a,"#FF6692")).replaceAll(d,"#B6E880")).replaceAll(p,"#FF97FF")).replaceAll(h,"#FECB52");return e}(e,o,t),e=function(e,o,t){const l="#000011",n="#000012",i="#000013",r="#000014",s="#000015",c="#000016",a="#000017",d="#000018",p="#000019",h="#000020";if("streamlit"===t){const t=(0,u.Gy)(o);e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,t[0])).replaceAll(n,t[1])).replaceAll(i,t[2])).replaceAll(r,t[3])).replaceAll(s,t[4])).replaceAll(c,t[5])).replaceAll(a,t[6])).replaceAll(d,t[7])).replaceAll(p,t[8])).replaceAll(h,t[9])}else e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,"#0d0887")).replaceAll(n,"#46039f")).replaceAll(i,"#7201a8")).replaceAll(r,"#9c179e")).replaceAll(s,"#bd3786")).replaceAll(c,"#d8576b")).replaceAll(a,"#ed7953")).replaceAll(d,"#fb9f3a")).replaceAll(p,"#fdca26")).replaceAll(h,"#f0f921");return e}(e,o,t),e=function(e,o,t){const l="#000021",n="#000022",i="#000023",r="#000024",s="#000025",c="#000026",a="#000027",d="#000028",p="#000029",h="#000030",m="#000031";if("streamlit"===t){const t=(0,u.ru)(o);e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,t[0])).replaceAll(n,t[1])).replaceAll(i,t[2])).replaceAll(r,t[3])).replaceAll(s,t[4])).replaceAll(c,t[5])).replaceAll(a,t[6])).replaceAll(d,t[7])).replaceAll(p,t[8])).replaceAll(h,t[9])).replaceAll(m,t[10])}else e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,"#8e0152")).replaceAll(n,"#c51b7d")).replaceAll(i,"#de77ae")).replaceAll(r,"#f1b6da")).replaceAll(s,"#fde0ef")).replaceAll(c,"#f7f7f7")).replaceAll(a,"#e6f5d0")).replaceAll(d,"#b8e186")).replaceAll(p,"#7fbc41")).replaceAll(h,"#4d9221")).replaceAll(m,"#276419");return e}(e,o,t),e}function y(e,o){try{!function(e,o){const{genericFonts:t,colors:l,fontSizes:n}=o,i={font:{color:(0,u.Xy)(o),family:t.bodyFont,size:n.twoSmPx},title:{color:l.headingColor,subtitleColor:l.bodyText,font:{family:t.headingFont,size:n.mdPx,color:l.headingColor},pad:{l:o.spacing.twoXSPx},xanchor:"left",x:0},legend:{title:{font:{size:n.twoSmPx,color:(0,u.Xy)(o)},side:"top"},valign:"top",bordercolor:l.transparent,borderwidth:o.spacing.nonePx,font:{size:n.twoSmPx,color:(0,u.yq)(o)}},paper_bgcolor:l.bgColor,plot_bgcolor:l.bgColor,yaxis:{ticklabelposition:"outside",zerolinecolor:(0,u.ny)(o),title:{font:{color:(0,u.Xy)(o),size:n.smPx},standoff:o.spacing.twoXLPx},tickcolor:(0,u.ny)(o),tickfont:{color:(0,u.Xy)(o),size:n.twoSmPx},gridcolor:(0,u.ny)(o),minor:{gridcolor:(0,u.ny)(o)},automargin:!0},xaxis:{zerolinecolor:(0,u.ny)(o),gridcolor:(0,u.ny)(o),showgrid:!1,tickfont:{color:(0,u.Xy)(o),size:n.twoSmPx},tickcolor:(0,u.ny)(o),title:{font:{color:(0,u.Xy)(o),size:n.smPx},standoff:o.spacing.xlPx},minor:{gridcolor:(0,u.ny)(o)},zeroline:!1,automargin:!0,rangeselector:{bgcolor:l.bgColor,bordercolor:(0,u.ny)(o),borderwidth:1,x:0}},margin:{pad:o.spacing.smPx,r:o.spacing.nonePx,l:o.spacing.nonePx},hoverlabel:{bgcolor:l.bgColor,bordercolor:l.fadedText10,font:{color:(0,u.Xy)(o),family:t.bodyFont,size:n.twoSmPx}},coloraxis:{colorbar:{thickness:16,xpad:o.spacing.twoXLPx,ticklabelposition:"outside",outlinecolor:l.transparent,outlinewidth:8,len:.75,y:.5745,title:{font:{color:(0,u.Xy)(o),size:n.smPx}},tickfont:{color:(0,u.Xy)(o),size:n.twoSmPx}}},ternary:{gridcolor:(0,u.Xy)(o),bgcolor:l.bgColor,title:{font:{family:t.bodyFont,size:n.smPx}},color:(0,u.Xy)(o),aaxis:{gridcolor:(0,u.Xy)(o),linecolor:(0,u.Xy)(o),tickfont:{family:t.bodyFont,size:n.twoSmPx}},baxis:{linecolor:(0,u.Xy)(o),gridcolor:(0,u.Xy)(o),tickfont:{family:t.bodyFont,size:n.twoSmPx}},caxis:{linecolor:(0,u.Xy)(o),gridcolor:(0,u.Xy)(o),tickfont:{family:t.bodyFont,size:n.twoSmPx}}}};p()(e,i)}(e.layout.template.layout,o)}catch(t){const e=(0,h.b)(t);(0,m.H)(e)}"title"in e.layout&&(e.layout.title=p()(e.layout.title,{text:"<b>".concat(e.layout.title.text,"</b>")}))}var g=t(40864);const x={width:600,height:470,name:"fullscreen-expand",path:"M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z"},b={width:600,height:470,name:"fullscreen-collapse",path:"M160 64c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H32c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V64zM32 320c-17.7 0-32 14.3-32 32s14.3 32 32 32H96v64c0 17.7 14.3 32 32 32s32-14.3 32-32V352c0-17.7-14.3-32-32-32H32zM352 64c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H352V64zM320 320c-17.7 0-32 14.3-32 32v96c0 17.7 14.3 32 32 32s32-14.3 32-32V384h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H320z"};function v(e,o,t){const l=JSON.parse(f(JSON.stringify(e),t,o));return"streamlit"===o?y(l,t):l.layout=function(e,o){const{colors:t,genericFonts:l}=o,n={font:{color:t.bodyText,family:l.bodyFont},paper_bgcolor:t.bgColor,plot_bgcolor:t.secondaryBg};return{...e,font:{...n.font,...e.font},paper_bgcolor:e.paper_bgcolor||n.paper_bgcolor,plot_bgcolor:e.plot_bgcolor||n.plot_bgcolor}}(l.layout,t),l}function A(e,o,t,l){if(!e)return;const n={selection:{points:[],point_indices:[],box:[],lasso:[]}},i=new Set,s=[],a=[],d=[],{selections:p,points:u}=e;if(u&&u.forEach((function(e){d.push({...e,legendgroup:e.data.legendgroup||void 0,data:void 0,fullData:void 0}),(0,c.bb)(e.pointIndex)&&i.add(e.pointIndex),(0,c.bb)(e.pointIndices)&&e.pointIndices.length>0&&e.pointIndices.forEach((e=>i.add(e)))})),p&&p.forEach((e=>{if("rect"===e.type){const o=function(e){return"x0"in e&&"x1"in e&&"y0"in e&&"y1"in e?{x:[e.x0,e.x1],y:[e.y0,e.y1]}:{x:[],y:[]}}(e),t={xref:e.xref,yref:e.yref,x:o.x,y:o.y};s.push(t)}if("path"===e.type){const o=function(e){if(""===e)return{x:[],y:[]};const o=e.replace("M","").replace("Z","").split("L"),t=[],l=[];return o.forEach((e=>{const[o,n]=e.split(",").map(Number);t.push(o),l.push(n)})),{x:t,y:l}}(e.path),t={xref:e.xref,yref:e.yref,x:o.x,y:o.y};a.push(t)}})),n.selection.point_indices=Array.from(i),n.selection.points=d.map((e=>(0,c.KI)(e))),n.selection.box=s,n.selection.lasso=a,n.selection.box.length>0&&!t.selectionMode.includes(r.hP.SelectionMode.BOX))return;if(n.selection.lasso.length>0&&!t.selectionMode.includes(r.hP.SelectionMode.LASSO))return;const h=o.getStringValue(t),m=JSON.stringify(n);h!==m&&o.setStringValue(t,m,{fromUi:!0},l)}const w=(0,s.Z)((function(e){var o,t,s,c,d;let{element:p,width:u,height:h,widgetMgr:m,disabled:f,fragmentId:y,isFullScreen:w,expand:S,collapse:z,disableFullscreenMode:F}=e;const C=(0,n.u)(),M=(0,l.useMemo)((()=>p.spec?JSON.parse(p.spec):{layout:{},data:[],frames:void 0}),[p.id,p.spec]),[P,k]=(0,l.useState)((()=>{const e=m.getElementState(p.id,"figure");return e||v(M,p.theme,C)})),I=p.selectionMode.length>0&&!f,E=I&&p.selectionMode.includes(r.hP.SelectionMode.LASSO),X=I&&p.selectionMode.includes(r.hP.SelectionMode.BOX),L=I&&p.selectionMode.includes(r.hP.SelectionMode.POINTS),T=(0,l.useMemo)((()=>{if(!p.config)return{};const e=JSON.parse(p.config);if(F||(e.modeBarButtonsToAdd=[{name:w?"Close fullscreen":"Fullscreen",icon:w?b:x,click:()=>{w&&z?z():S&&S()}}]),!e.modeBarButtonsToRemove){e.displaylogo=!1;const o=["sendDataToCloud"];I?(E||o.push("lasso2d"),X||o.push("select2d")):o.push("lasso2d","select2d"),e.modeBarButtonsToRemove=o}return e}),[p.id,p.config,w,F,I,E,X,z,S]);(0,l.useEffect)((()=>{k((e=>v(e,p.theme,C)))}),[p.id,C,p.theme]),(0,l.useEffect)((()=>{let e=M.layout.clickmode,o=M.layout.hovermode,t=M.layout.dragmode;f?(e="none",t="pan"):I&&(M.layout.clickmode||(e=L?"event+select":"none"),M.layout.hovermode||(o="closest"),M.layout.dragmode||(t=L?"pan":X?"select":E?"lasso":"pan")),k((l=>l.layout.clickmode===e&&l.layout.hovermode===o&&l.layout.dragmode===t?l:{...l,layout:{...l.layout,clickmode:e,hovermode:o,dragmode:t}}))}),[p.id,I,L,X,E,f]);let W=-1===u?null===(o=P.layout)||void 0===o?void 0:o.width:Math.max(p.useContainerWidth?u:Math.min(null!==(t=M.layout.width)&&void 0!==t?t:u,u),150),_=M.layout.height;w&&(W=u,_=h),P.layout.height===_&&P.layout.width===W||k((e=>({...e,layout:{...e.layout,height:_,width:W}})));const O=(0,l.useCallback)((e=>{A(e,m,p,y)}),[p.id,m,y]),V=(0,l.useCallback)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];!function(e,o,t){const l=e.getStringValue(o),n=JSON.stringify({selection:{points:[],point_indices:[],box:[],lasso:[]}});l!==n&&e.setStringValue(o,n,{fromUi:!0},t)}(m,p,y),e&&setTimeout((()=>{k((e=>({...e,data:e.data.map((e=>({...e,selectedpoints:null}))),layout:{...e.layout,selections:[]}})))}),50)}),[p.id,m,y]);return(0,l.useEffect)((()=>{if(!p.formId||!I)return;const e=new a.K;return e.manageFormClearListener(m,p.formId,V),()=>{e.disconnect()}}),[p.formId,m,I,V]),(0,l.useEffect)((()=>{var e,o,t;if(!I)return;let l;l="select"===(null===(e=P.layout)||void 0===e?void 0:e.dragmode)||"lasso"===(null===(o=P.layout)||void 0===o?void 0:o.dragmode)?"event":L?"event+select":"none",(null===(t=P.layout)||void 0===t?void 0:t.clickmode)!==l&&k((e=>({...e,layout:{...e.layout,clickmode:l}})))}),[null===(s=P.layout)||void 0===s?void 0:s.dragmode]),(0,g.jsx)(i.Z,{className:"stPlotlyChart",data:P.data,layout:P.layout,config:T,frames:null!==(c=P.frames)&&void 0!==c?c:void 0,style:{visibility:void 0===(null===(d=P.layout)||void 0===d?void 0:d.width)?"hidden":void 0},onSelected:I?O:()=>{},onDoubleClick:I?()=>V():void 0,onDeselect:I?()=>{V(!1)}:void 0,onInitialized:e=>{m.setElementState(p.id,"figure",e)},onUpdate:e=>{m.setElementState(p.id,"figure",e),k(e)}},w?"fullscreen":"original")}),!0)},23593:(e,o,t)=>{t.d(o,{Z:()=>g});var l=t(66845),n=t(13005),i=t.n(n),r=t(25621),s=t(82218),c=t(97781),a=t(46927),d=t(66694),p=t(1515);const u=(0,p.Z)("button",{target:"e1vs0wn31"})((e=>{let{isExpanded:o,theme:t}=e;const l=o?{right:"0.4rem",top:"0.5rem",backgroundColor:"transparent"}:{right:"-3.0rem",top:"-0.375rem",opacity:0,transform:"scale(0)",backgroundColor:t.colors.lightenedBg05};return{position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",zIndex:t.zIndices.sidebar+1,height:"2.5rem",width:"2.5rem",transition:"opacity 300ms 150ms, transform 300ms 150ms",border:"none",color:t.colors.fadedText60,borderRadius:"50%",...l,"&:focus":{outline:"none"},"&:active, &:focus-visible, &:hover":{opacity:1,outline:"none",transform:"scale(1)",color:t.colors.bodyText,transition:"none"}}}),""),h=(0,p.Z)("div",{target:"e1vs0wn30"})((e=>{let{theme:o,isExpanded:t}=e;return{"&:hover":{[u]:{opacity:1,transform:"scale(1)",transition:"none"}},...t?{position:"fixed",top:0,left:0,bottom:0,right:0,background:o.colors.bgColor,zIndex:o.zIndices.fullscreenWrapper,padding:o.spacing.md,paddingTop:"2.875rem",overflow:["auto","overlay"],display:"flex",alignItems:"center",justifyContent:"center"}:{}}}),"");var m=t(40864);class f extends l.PureComponent{constructor(e){super(e),this.context=void 0,this.controlKeys=e=>{const{expanded:o}=this.state;27===e.keyCode&&o&&this.zoomOut()},this.zoomIn=()=>{document.body.style.overflow="hidden",this.context.setFullScreen(!0),this.setState({expanded:!0})},this.zoomOut=()=>{document.body.style.overflow="unset",this.context.setFullScreen(!1),this.setState({expanded:!1})},this.convertScssRemValueToPixels=e=>parseFloat(e)*parseFloat(getComputedStyle(document.documentElement).fontSize),this.getWindowDimensions=()=>{const e=this.convertScssRemValueToPixels(this.props.theme.spacing.md),o=this.convertScssRemValueToPixels("2.875rem");return{fullWidth:window.innerWidth-2*e,fullHeight:window.innerHeight-(e+o)}},this.updateWindowDimensions=()=>{this.setState(this.getWindowDimensions())},this.state={expanded:!1,...this.getWindowDimensions()}}componentDidMount(){window.addEventListener("resize",this.updateWindowDimensions),document.addEventListener("keydown",this.controlKeys,!1)}componentWillUnmount(){window.removeEventListener("resize",this.updateWindowDimensions),document.removeEventListener("keydown",this.controlKeys,!1)}render(){const{expanded:e,fullWidth:o,fullHeight:t}=this.state,{children:l,width:n,height:i,disableFullscreenMode:r}=this.props;let d=s.d,p=this.zoomIn,f="View fullscreen";return e&&(d=c.m,p=this.zoomOut,f="Exit fullscreen"),(0,m.jsxs)(h,{isExpanded:e,"data-testid":"stFullScreenFrame",children:[!r&&(0,m.jsx)(u,{"data-testid":"StyledFullScreenButton",onClick:p,title:f,isExpanded:e,children:(0,m.jsx)(a.Z,{content:d})}),l(e?{width:o,height:t,expanded:e,expand:this.zoomIn,collapse:this.zoomOut}:{width:n,height:i,expanded:e,expand:this.zoomIn,collapse:this.zoomOut})]})}}f.contextType=d.E;const y=(0,r.b)(f);const g=function(e){let o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];class t extends l.PureComponent{constructor(){super(...arguments),this.render=()=>{const{width:t,height:l,disableFullscreenMode:n}=this.props;return(0,m.jsx)(y,{width:t,height:l,disableFullscreenMode:o||n,children:o=>{let{width:t,height:l,expanded:n,expand:i,collapse:r}=o;return(0,m.jsx)(e,{...this.props,width:t,height:l,isFullScreen:n,expand:i,collapse:r})}})}}}return t.displayName="withFullScreenWrapper(".concat(e.displayName||e.name,")"),i()(t,e)}},87814:(e,o,t)=>{t.d(o,{K:()=>n});var l=t(50641);class n{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,o,t){(0,l.bb)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===o||(this.disconnect(),(0,l.bM)(o)&&(this.formClearListener=e.addFormClearedListener(o,t),this.lastWidgetMgr=e,this.lastFormId=o))}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([[1168],{71168:(e,o,t)=>{t.r(o),t.d(o,{default:()=>w});var l=t(66845),n=t(25621),i=t(42736),r=t(16295),s=t(23593),c=t(50641),a=t(87814),d=t(96825),p=t.n(d),u=t(27466),h=t(63765),m=t(23849);function f(e,o,t){return e=function(e,o){return(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll("#000032",(0,u.By)(o))).replaceAll("#000033",(0,u.He)(o))).replaceAll("#000034",(0,u.Iy)(o)?o.colors.blue80:o.colors.blue40)).replaceAll("#000035",(0,u.ny)(o))).replaceAll("#000036",(0,u.Xy)(o))).replaceAll("#000037",(0,u.yq)(o))).replaceAll("#000038",o.colors.bgColor)).replaceAll("#000039",o.colors.fadedText05)).replaceAll("#000040",o.colors.bgMix)}(e,o),e=function(e,o,t){const l="#000001",n="#000002",i="#000003",r="#000004",s="#000005",c="#000006",a="#000007",d="#000008",p="#000009",h="#000010";if("streamlit"===t){const t=(0,u.iY)(o);e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,t[0])).replaceAll(n,t[1])).replaceAll(i,t[2])).replaceAll(r,t[3])).replaceAll(s,t[4])).replaceAll(c,t[5])).replaceAll(a,t[6])).replaceAll(d,t[7])).replaceAll(p,t[8])).replaceAll(h,t[9])}else e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,"#636efa")).replaceAll(n,"#EF553B")).replaceAll(i,"#00cc96")).replaceAll(r,"#ab63fa")).replaceAll(s,"#FFA15A")).replaceAll(c,"#19d3f3")).replaceAll(a,"#FF6692")).replaceAll(d,"#B6E880")).replaceAll(p,"#FF97FF")).replaceAll(h,"#FECB52");return e}(e,o,t),e=function(e,o,t){const l="#000011",n="#000012",i="#000013",r="#000014",s="#000015",c="#000016",a="#000017",d="#000018",p="#000019",h="#000020";if("streamlit"===t){const t=(0,u.Gy)(o);e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,t[0])).replaceAll(n,t[1])).replaceAll(i,t[2])).replaceAll(r,t[3])).replaceAll(s,t[4])).replaceAll(c,t[5])).replaceAll(a,t[6])).replaceAll(d,t[7])).replaceAll(p,t[8])).replaceAll(h,t[9])}else e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,"#0d0887")).replaceAll(n,"#46039f")).replaceAll(i,"#7201a8")).replaceAll(r,"#9c179e")).replaceAll(s,"#bd3786")).replaceAll(c,"#d8576b")).replaceAll(a,"#ed7953")).replaceAll(d,"#fb9f3a")).replaceAll(p,"#fdca26")).replaceAll(h,"#f0f921");return e}(e,o,t),e=function(e,o,t){const l="#000021",n="#000022",i="#000023",r="#000024",s="#000025",c="#000026",a="#000027",d="#000028",p="#000029",h="#000030",m="#000031";if("streamlit"===t){const t=(0,u.ru)(o);e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,t[0])).replaceAll(n,t[1])).replaceAll(i,t[2])).replaceAll(r,t[3])).replaceAll(s,t[4])).replaceAll(c,t[5])).replaceAll(a,t[6])).replaceAll(d,t[7])).replaceAll(p,t[8])).replaceAll(h,t[9])).replaceAll(m,t[10])}else e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replaceAll(l,"#8e0152")).replaceAll(n,"#c51b7d")).replaceAll(i,"#de77ae")).replaceAll(r,"#f1b6da")).replaceAll(s,"#fde0ef")).replaceAll(c,"#f7f7f7")).replaceAll(a,"#e6f5d0")).replaceAll(d,"#b8e186")).replaceAll(p,"#7fbc41")).replaceAll(h,"#4d9221")).replaceAll(m,"#276419");return e}(e,o,t),e}function y(e,o){try{!function(e,o){const{genericFonts:t,colors:l,fontSizes:n}=o,i={font:{color:(0,u.Xy)(o),family:t.bodyFont,size:n.twoSmPx},title:{color:l.headingColor,subtitleColor:l.bodyText,font:{family:t.headingFont,size:n.mdPx,color:l.headingColor},pad:{l:o.spacing.twoXSPx},xanchor:"left",x:0},legend:{title:{font:{size:n.twoSmPx,color:(0,u.Xy)(o)},side:"top"},valign:"top",bordercolor:l.transparent,borderwidth:o.spacing.nonePx,font:{size:n.twoSmPx,color:(0,u.yq)(o)}},paper_bgcolor:l.bgColor,plot_bgcolor:l.bgColor,yaxis:{ticklabelposition:"outside",zerolinecolor:(0,u.ny)(o),title:{font:{color:(0,u.Xy)(o),size:n.smPx},standoff:o.spacing.twoXLPx},tickcolor:(0,u.ny)(o),tickfont:{color:(0,u.Xy)(o),size:n.twoSmPx},gridcolor:(0,u.ny)(o),minor:{gridcolor:(0,u.ny)(o)},automargin:!0},xaxis:{zerolinecolor:(0,u.ny)(o),gridcolor:(0,u.ny)(o),showgrid:!1,tickfont:{color:(0,u.Xy)(o),size:n.twoSmPx},tickcolor:(0,u.ny)(o),title:{font:{color:(0,u.Xy)(o),size:n.smPx},standoff:o.spacing.xlPx},minor:{gridcolor:(0,u.ny)(o)},zeroline:!1,automargin:!0,rangeselector:{bgcolor:l.bgColor,bordercolor:(0,u.ny)(o),borderwidth:1,x:0}},margin:{pad:o.spacing.smPx,r:o.spacing.nonePx,l:o.spacing.nonePx},hoverlabel:{bgcolor:l.bgColor,bordercolor:l.fadedText10,font:{color:(0,u.Xy)(o),family:t.bodyFont,size:n.twoSmPx}},coloraxis:{colorbar:{thickness:16,xpad:o.spacing.twoXLPx,ticklabelposition:"outside",outlinecolor:l.transparent,outlinewidth:8,len:.75,y:.5745,title:{font:{color:(0,u.Xy)(o),size:n.smPx}},tickfont:{color:(0,u.Xy)(o),size:n.twoSmPx}}},ternary:{gridcolor:(0,u.Xy)(o),bgcolor:l.bgColor,title:{font:{family:t.bodyFont,size:n.smPx}},color:(0,u.Xy)(o),aaxis:{gridcolor:(0,u.Xy)(o),linecolor:(0,u.Xy)(o),tickfont:{family:t.bodyFont,size:n.twoSmPx}},baxis:{linecolor:(0,u.Xy)(o),gridcolor:(0,u.Xy)(o),tickfont:{family:t.bodyFont,size:n.twoSmPx}},caxis:{linecolor:(0,u.Xy)(o),gridcolor:(0,u.Xy)(o),tickfont:{family:t.bodyFont,size:n.twoSmPx}}}};p()(e,i)}(e.layout.template.layout,o)}catch(t){const e=(0,h.b)(t);(0,m.H)(e)}"title"in e.layout&&(e.layout.title=p()(e.layout.title,{text:"<b>".concat(e.layout.title.text,"</b>")}))}var g=t(40864);const x={width:600,height:470,name:"fullscreen-expand",path:"M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z"},b={width:600,height:470,name:"fullscreen-collapse",path:"M160 64c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H32c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V64zM32 320c-17.7 0-32 14.3-32 32s14.3 32 32 32H96v64c0 17.7 14.3 32 32 32s32-14.3 32-32V352c0-17.7-14.3-32-32-32H32zM352 64c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H352V64zM320 320c-17.7 0-32 14.3-32 32v96c0 17.7 14.3 32 32 32s32-14.3 32-32V384h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H320z"};function v(e,o,t){const l=JSON.parse(f(JSON.stringify(e),t,o));return"streamlit"===o?y(l,t):l.layout=function(e,o){const{colors:t,genericFonts:l}=o,n={font:{color:t.bodyText,family:l.bodyFont},paper_bgcolor:t.bgColor,plot_bgcolor:t.secondaryBg};return{...e,font:{...n.font,...e.font},paper_bgcolor:e.paper_bgcolor||n.paper_bgcolor,plot_bgcolor:e.plot_bgcolor||n.plot_bgcolor}}(l.layout,t),l}function A(e,o,t,l){if(!e)return;const n={selection:{points:[],point_indices:[],box:[],lasso:[]}},i=new Set,s=[],a=[],d=[],{selections:p,points:u}=e;if(u&&u.forEach((function(e){d.push({...e,legendgroup:e.data.legendgroup||void 0,data:void 0,fullData:void 0}),(0,c.bb)(e.pointIndex)&&i.add(e.pointIndex),(0,c.bb)(e.pointIndices)&&e.pointIndices.length>0&&e.pointIndices.forEach((e=>i.add(e)))})),p&&p.forEach((e=>{if("rect"===e.type){const o=function(e){return"x0"in e&&"x1"in e&&"y0"in e&&"y1"in e?{x:[e.x0,e.x1],y:[e.y0,e.y1]}:{x:[],y:[]}}(e),t={xref:e.xref,yref:e.yref,x:o.x,y:o.y};s.push(t)}if("path"===e.type){const o=function(e){if(""===e)return{x:[],y:[]};const o=e.replace("M","").replace("Z","").split("L"),t=[],l=[];return o.forEach((e=>{const[o,n]=e.split(",").map(Number);t.push(o),l.push(n)})),{x:t,y:l}}(e.path),t={xref:e.xref,yref:e.yref,x:o.x,y:o.y};a.push(t)}})),n.selection.point_indices=Array.from(i),n.selection.points=d.map((e=>(0,c.KI)(e))),n.selection.box=s,n.selection.lasso=a,n.selection.box.length>0&&!t.selectionMode.includes(r.hP.SelectionMode.BOX))return;if(n.selection.lasso.length>0&&!t.selectionMode.includes(r.hP.SelectionMode.LASSO))return;const h=o.getStringValue(t),m=JSON.stringify(n);h!==m&&o.setStringValue(t,m,{fromUi:!0},l)}const w=(0,s.Z)((function(e){var o,t,s,c,d;let{element:p,width:u,height:h,widgetMgr:m,disabled:f,fragmentId:y,isFullScreen:w,expand:S,collapse:z,disableFullscreenMode:F}=e;const C=(0,n.u)(),M=(0,l.useMemo)((()=>p.spec?JSON.parse(p.spec):{layout:{},data:[],frames:void 0}),[p.id,p.spec]),[P,k]=(0,l.useState)((()=>{const e=m.getElementState(p.id,"figure");return e||v(M,p.theme,C)})),I=p.selectionMode.length>0&&!f,E=I&&p.selectionMode.includes(r.hP.SelectionMode.LASSO),X=I&&p.selectionMode.includes(r.hP.SelectionMode.BOX),T=I&&p.selectionMode.includes(r.hP.SelectionMode.POINTS),B=(0,l.useMemo)((()=>{if(!p.config)return{};const e=JSON.parse(p.config);var o;F||(e.modeBarButtonsToAdd=[{name:w?"Close fullscreen":"Fullscreen",icon:w?b:x,click:()=>{w&&z?z():S&&S()}},...null!==(o=e.modeBarButtonsToAdd)&&void 0!==o?o:[]]);if(!e.modeBarButtonsToRemove){e.displaylogo=!1;const o=["sendDataToCloud"];I?(E||o.push("lasso2d"),X||o.push("select2d")):o.push("lasso2d","select2d"),e.modeBarButtonsToRemove=o}return e}),[p.id,p.config,w,F,I,E,X,z,S]);(0,l.useEffect)((()=>{k((e=>v(e,p.theme,C)))}),[p.id,C,p.theme]),(0,l.useEffect)((()=>{let e=M.layout.clickmode,o=M.layout.hovermode,t=M.layout.dragmode;f?(e="none",t="pan"):I&&(M.layout.clickmode||(e=T?"event+select":"none"),M.layout.hovermode||(o="closest"),M.layout.dragmode||(t=T?"pan":X?"select":E?"lasso":"pan")),k((l=>l.layout.clickmode===e&&l.layout.hovermode===o&&l.layout.dragmode===t?l:{...l,layout:{...l.layout,clickmode:e,hovermode:o,dragmode:t}}))}),[p.id,I,T,X,E,f]);let L=-1===u?null===(o=P.layout)||void 0===o?void 0:o.width:Math.max(p.useContainerWidth?u:Math.min(null!==(t=M.layout.width)&&void 0!==t?t:u,u),150),W=M.layout.height;w&&(L=u,W=h),P.layout.height===W&&P.layout.width===L||k((e=>({...e,layout:{...e.layout,height:W,width:L}})));const _=(0,l.useCallback)((e=>{A(e,m,p,y)}),[p.id,m,y]),O=(0,l.useCallback)((function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];!function(e,o,t){const l=e.getStringValue(o),n=JSON.stringify({selection:{points:[],point_indices:[],box:[],lasso:[]}});l!==n&&e.setStringValue(o,n,{fromUi:!0},t)}(m,p,y),e&&setTimeout((()=>{k((e=>({...e,data:e.data.map((e=>({...e,selectedpoints:null}))),layout:{...e.layout,selections:[]}})))}),50)}),[p.id,m,y]);return(0,l.useEffect)((()=>{if(!p.formId||!I)return;const e=new a.K;return e.manageFormClearListener(m,p.formId,O),()=>{e.disconnect()}}),[p.formId,m,I,O]),(0,l.useEffect)((()=>{var e,o,t;if(!I)return;let l;l="select"===(null===(e=P.layout)||void 0===e?void 0:e.dragmode)||"lasso"===(null===(o=P.layout)||void 0===o?void 0:o.dragmode)?"event":T?"event+select":"none",(null===(t=P.layout)||void 0===t?void 0:t.clickmode)!==l&&k((e=>({...e,layout:{...e.layout,clickmode:l}})))}),[null===(s=P.layout)||void 0===s?void 0:s.dragmode]),(0,g.jsx)(i.Z,{className:"stPlotlyChart",data:P.data,layout:P.layout,config:B,frames:null!==(c=P.frames)&&void 0!==c?c:void 0,style:{visibility:void 0===(null===(d=P.layout)||void 0===d?void 0:d.width)?"hidden":void 0},onSelected:I?_:()=>{},onDoubleClick:I?()=>O():void 0,onDeselect:I?()=>{O(!1)}:void 0,onInitialized:e=>{m.setElementState(p.id,"figure",e)},onUpdate:e=>{m.setElementState(p.id,"figure",e),k(e)}},w?"fullscreen":"original")}),!0)},23593:(e,o,t)=>{t.d(o,{Z:()=>g});var l=t(66845),n=t(13005),i=t.n(n),r=t(25621),s=t(82218),c=t(97781),a=t(46927),d=t(66694),p=t(1515);const u=(0,p.Z)("button",{target:"e1vs0wn31"})((e=>{let{isExpanded:o,theme:t}=e;const l=o?{right:"0.4rem",top:"0.5rem",backgroundColor:"transparent"}:{right:"-3.0rem",top:"-0.375rem",opacity:0,transform:"scale(0)",backgroundColor:t.colors.lightenedBg05};return{position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",zIndex:t.zIndices.sidebar+1,height:"2.5rem",width:"2.5rem",transition:"opacity 300ms 150ms, transform 300ms 150ms",border:"none",color:t.colors.fadedText60,borderRadius:"50%",...l,"&:focus":{outline:"none"},"&:active, &:focus-visible, &:hover":{opacity:1,outline:"none",transform:"scale(1)",color:t.colors.bodyText,transition:"none"}}}),""),h=(0,p.Z)("div",{target:"e1vs0wn30"})((e=>{let{theme:o,isExpanded:t}=e;return{"&:hover":{[u]:{opacity:1,transform:"scale(1)",transition:"none"}},...t?{position:"fixed",top:0,left:0,bottom:0,right:0,background:o.colors.bgColor,zIndex:o.zIndices.fullscreenWrapper,padding:o.spacing.md,paddingTop:"2.875rem",overflow:["auto","overlay"],display:"flex",alignItems:"center",justifyContent:"center"}:{}}}),"");var m=t(40864);class f extends l.PureComponent{constructor(e){super(e),this.context=void 0,this.controlKeys=e=>{const{expanded:o}=this.state;27===e.keyCode&&o&&this.zoomOut()},this.zoomIn=()=>{document.body.style.overflow="hidden",this.context.setFullScreen(!0),this.setState({expanded:!0})},this.zoomOut=()=>{document.body.style.overflow="unset",this.context.setFullScreen(!1),this.setState({expanded:!1})},this.convertScssRemValueToPixels=e=>parseFloat(e)*parseFloat(getComputedStyle(document.documentElement).fontSize),this.getWindowDimensions=()=>{const e=this.convertScssRemValueToPixels(this.props.theme.spacing.md),o=this.convertScssRemValueToPixels("2.875rem");return{fullWidth:window.innerWidth-2*e,fullHeight:window.innerHeight-(e+o)}},this.updateWindowDimensions=()=>{this.setState(this.getWindowDimensions())},this.state={expanded:!1,...this.getWindowDimensions()}}componentDidMount(){window.addEventListener("resize",this.updateWindowDimensions),document.addEventListener("keydown",this.controlKeys,!1)}componentWillUnmount(){window.removeEventListener("resize",this.updateWindowDimensions),document.removeEventListener("keydown",this.controlKeys,!1)}render(){const{expanded:e,fullWidth:o,fullHeight:t}=this.state,{children:l,width:n,height:i,disableFullscreenMode:r}=this.props;let d=s.d,p=this.zoomIn,f="View fullscreen";return e&&(d=c.m,p=this.zoomOut,f="Exit fullscreen"),(0,m.jsxs)(h,{isExpanded:e,"data-testid":"stFullScreenFrame",children:[!r&&(0,m.jsx)(u,{"data-testid":"StyledFullScreenButton",onClick:p,title:f,isExpanded:e,children:(0,m.jsx)(a.Z,{content:d})}),l(e?{width:o,height:t,expanded:e,expand:this.zoomIn,collapse:this.zoomOut}:{width:n,height:i,expanded:e,expand:this.zoomIn,collapse:this.zoomOut})]})}}f.contextType=d.E;const y=(0,r.b)(f);const g=function(e){let o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];class t extends l.PureComponent{constructor(){super(...arguments),this.render=()=>{const{width:t,height:l,disableFullscreenMode:n}=this.props;return(0,m.jsx)(y,{width:t,height:l,disableFullscreenMode:o||n,children:o=>{let{width:t,height:l,expanded:n,expand:i,collapse:r}=o;return(0,m.jsx)(e,{...this.props,width:t,height:l,isFullScreen:n,expand:i,collapse:r})}})}}}return t.displayName="withFullScreenWrapper(".concat(e.displayName||e.name,")"),i()(t,e)}},87814:(e,o,t)=>{t.d(o,{K:()=>n});var l=t(50641);class n{constructor(){this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}manageFormClearListener(e,o,t){(0,l.bb)(this.formClearListener)&&this.lastWidgetMgr===e&&this.lastFormId===o||(this.disconnect(),(0,l.bM)(o)&&(this.formClearListener=e.addFormClearedListener(o,t),this.lastWidgetMgr=e,this.lastFormId=o))}disconnect(){var e;null===(e=this.formClearListener)||void 0===e||e.disconnect(),this.formClearListener=void 0,this.lastWidgetMgr=void 0,this.lastFormId=void 0}}}}]);
|