@brainbase-labs/chat-widget 0.1.18 → 0.1.20

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.
@@ -1,5 +1,5 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var t=document.createElement("style");t.id="brainbase-chat-styles",t.appendChild(document.createTextNode(':root{--bb-primary-color: #1a1a2e;--bb-primary-hover: #16162a;--bb-primary-light: rgba(26, 26, 46, .1);--bb-accent-color: #6366f1;--bb-accent-hover: #5558e3;--bb-surface-bg: #ffffff;--bb-surface-secondary: #f8f9fb;--bb-surface-tertiary: #f1f3f9;--bb-text-primary: #1a1a2e;--bb-text-secondary: #6b7280;--bb-text-tertiary: #9ca3af;--bb-text-inverse: #ffffff;--bb-user-message-bg: var(--bb-primary-color);--bb-user-message-text: var(--bb-text-inverse);--bb-assistant-message-bg: var(--bb-surface-secondary);--bb-assistant-message-text: var(--bb-text-primary);--bb-border-color: #e5e7eb;--bb-border-color-light: #f1f3f9;--bb-shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);--bb-shadow-md: 0 4px 12px rgba(0, 0, 0, .08);--bb-shadow-lg: 0 12px 40px rgba(0, 0, 0, .12);--bb-shadow-xl: 0 20px 60px rgba(0, 0, 0, .16);--bb-radius-sm: 8px;--bb-radius-md: 12px;--bb-radius-lg: 16px;--bb-radius-xl: 20px;--bb-radius-full: 9999px;--bb-spacing-xs: 4px;--bb-spacing-sm: 8px;--bb-spacing-md: 12px;--bb-spacing-lg: 16px;--bb-spacing-xl: 20px;--bb-spacing-2xl: 24px;--bb-font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--bb-font-size-xs: 11px;--bb-font-size-sm: 13px;--bb-font-size-md: 14px;--bb-font-size-lg: 16px;--bb-font-size-xl: 18px;--bb-font-size-2xl: 24px;--bb-font-weight-normal: 400;--bb-font-weight-medium: 500;--bb-font-weight-semibold: 600;--bb-font-weight-bold: 700;--bb-line-height: 1.5;--bb-transition-fast: .15s ease;--bb-transition-normal: .2s ease;--bb-transition-slow: .3s ease;--bb-widget-width: 400px;--bb-widget-height: 600px;--bb-widget-max-height: 85vh;--bb-toggle-size: 60px}@media(prefers-color-scheme:dark){:root[data-bb-theme=auto]{--bb-surface-bg: #1a1a2e;--bb-surface-secondary: #252542;--bb-surface-tertiary: #2d2d4a;--bb-text-primary: #f8f9fb;--bb-text-secondary: #9ca3af;--bb-text-tertiary: #6b7280;--bb-border-color: #3d3d5c;--bb-border-color-light: #2d2d4a;--bb-assistant-message-bg: var(--bb-surface-secondary);--bb-assistant-message-text: var(--bb-text-primary)}}._header_1p6z5_1{position:relative;overflow:hidden;transition:all .4s cubic-bezier(.4,0,.2,1)}._header_1p6z5_1:not(._compact_1p6z5_9){padding:var(--bb-spacing-xl) var(--bb-spacing-xl) var(--bb-spacing-2xl);min-height:140px}._header_1p6z5_1._compact_1p6z5_9{padding:var(--bb-spacing-lg) var(--bb-spacing-xl);min-height:56px}._headerBackground_1p6z5_20{position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(135deg,var(--bb-primary-color) 0%,color-mix(in srgb,var(--bb-primary-color) 70%,#2d2d5a) 50%,color-mix(in srgb,var(--bb-primary-color) 50%,#1a1a2e) 100%);transition:opacity .4s cubic-bezier(.4,0,.2,1)}._headerBackground_1p6z5_20:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:radial-gradient(ellipse at 30% 20%,rgba(255,255,255,.08) 0%,transparent 50%)}._headerBackground_1p6z5_20:after{content:"";position:absolute;bottom:0;left:0;right:0;height:60px;background:linear-gradient(to top,rgba(0,0,0,.1),transparent);opacity:1;transition:opacity .3s ease}._compact_1p6z5_9 ._headerBackground_1p6z5_20:after{opacity:0}._headerContent_1p6z5_59{position:relative;z-index:1}._topRow_1p6z5_64{display:flex;align-items:center;justify-content:space-between;transition:margin .4s cubic-bezier(.4,0,.2,1)}._header_1p6z5_1:not(._compact_1p6z5_9) ._topRow_1p6z5_64{margin-bottom:var(--bb-spacing-xl)}._compact_1p6z5_9 ._topRow_1p6z5_64{margin-bottom:0}._agentInfo_1p6z5_79{display:flex;align-items:center;gap:var(--bb-spacing-md)}._agentLogo_1p6z5_85{border-radius:var(--bb-radius-md);object-fit:cover;box-shadow:0 2px 8px #0003;transition:all .3s cubic-bezier(.4,0,.2,1)}._header_1p6z5_1:not(._compact_1p6z5_9) ._agentLogo_1p6z5_85{width:36px;height:36px}._compact_1p6z5_9 ._agentLogo_1p6z5_85{width:32px;height:32px}._agentLogoPlaceholder_1p6z5_102{border-radius:var(--bb-radius-md);background:var(--bb-primary-color);display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse);box-shadow:0 2px 8px #0003;transition:all .3s cubic-bezier(.4,0,.2,1)}._header_1p6z5_1:not(._compact_1p6z5_9) ._agentLogoPlaceholder_1p6z5_102{width:36px;height:36px}._compact_1p6z5_9 ._agentLogoPlaceholder_1p6z5_102{width:32px;height:32px}._brainbaseLogo_1p6z5_123{transition:all .3s cubic-bezier(.4,0,.2,1)}._header_1p6z5_1:not(._compact_1p6z5_9) ._brainbaseLogo_1p6z5_123{width:24px;height:24px}._compact_1p6z5_9 ._brainbaseLogo_1p6z5_123{width:22px;height:22px}._agentName_1p6z5_137{color:var(--bb-text-inverse);font-size:var(--bb-font-size-md);font-weight:var(--bb-font-weight-semibold);opacity:.95}._actions_1p6z5_144{display:flex;gap:var(--bb-spacing-sm)}._actionButton_1p6z5_149{width:32px;height:32px;border-radius:var(--bb-radius-full);background:#ffffff1a;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse);transition:background var(--bb-transition-fast),transform var(--bb-transition-fast)}._actionButton_1p6z5_149:hover{background:#fff3;transform:scale(1.05)}._actionButton_1p6z5_149:active{transform:scale(.95)}._actionButton_1p6z5_149:focus-visible{outline:2px solid rgba(255,255,255,.5);outline-offset:2px}._actionButton_1p6z5_149 svg{width:18px;height:18px}._welcomeText_1p6z5_183{color:var(--bb-text-inverse);overflow:hidden;transition:all .4s cubic-bezier(.4,0,.2,1)}._header_1p6z5_1:not(._compact_1p6z5_9) ._welcomeText_1p6z5_183{opacity:1;max-height:100px;transform:translateY(0)}._compact_1p6z5_9 ._welcomeText_1p6z5_183{opacity:0;max-height:0;transform:translateY(-10px);pointer-events:none}._title_1p6z5_202{margin:0;font-size:var(--bb-font-size-2xl);font-weight:var(--bb-font-weight-normal);opacity:.7;line-height:1.2}._subtitle_1p6z5_210{margin:var(--bb-spacing-xs) 0 0;font-size:var(--bb-font-size-2xl);font-weight:var(--bb-font-weight-bold);line-height:1.2}._messageWrapper_1thak_1{display:flex;gap:var(--bb-spacing-md);max-width:85%;animation:_messageSlideIn_1thak_1 .3s ease}@keyframes _messageSlideIn_1thak_1{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}._messageWrapper_1thak_1._user_1thak_19{flex-direction:row-reverse;margin-left:auto}._messageWrapper_1thak_1._assistant_1thak_24{margin-right:auto}._avatar_1thak_28{flex-shrink:0;width:28px;height:28px;border-radius:var(--bb-radius-full);overflow:hidden;margin-top:2px}._avatar_1thak_28 img{width:100%;height:100%;object-fit:cover}._avatarPlaceholder_1thak_43{width:100%;height:100%;background:var(--bb-primary-color);display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse)}._brainbaseLogo_1thak_53{width:18px;height:18px}._messageBubble_1thak_58{padding:var(--bb-spacing-md) var(--bb-spacing-lg);border-radius:var(--bb-radius-lg);position:relative}._user_1thak_19 ._messageBubble_1thak_58{background:var(--bb-user-message-bg);color:var(--bb-user-message-text);border-bottom-right-radius:var(--bb-spacing-xs)}._assistant_1thak_24 ._messageBubble_1thak_58{background:var(--bb-assistant-message-bg);color:var(--bb-assistant-message-text);border-bottom-left-radius:var(--bb-spacing-xs)}._messageBubble_1thak_58._error_1thak_76{background:#fef2f2;border:1px solid #fecaca}._content_1thak_81{font-size:var(--bb-font-size-md);line-height:var(--bb-line-height);word-break:break-word}._user_1thak_19 ._content_1thak_81{white-space:pre-wrap}._content_1thak_81._markdown_1thak_92 p{margin:0}._content_1thak_81._markdown_1thak_92 p+p{margin-top:var(--bb-spacing-sm)}._content_1thak_81._markdown_1thak_92 strong{font-weight:var(--bb-font-weight-semibold)}._content_1thak_81._markdown_1thak_92 em{font-style:italic}._content_1thak_81._markdown_1thak_92 ul,._content_1thak_81._markdown_1thak_92 ol{margin:var(--bb-spacing-sm) 0;padding-left:var(--bb-spacing-lg)}._content_1thak_81._markdown_1thak_92 li{margin:var(--bb-spacing-xs) 0}._content_1thak_81._markdown_1thak_92 li::marker{color:var(--bb-text-secondary)}._content_1thak_81._markdown_1thak_92 code{background:var(--bb-surface-tertiary);padding:2px 6px;border-radius:var(--bb-radius-sm);font-family:SF Mono,Monaco,Courier New,monospace;font-size:.9em}._content_1thak_81._markdown_1thak_92 pre{background:var(--bb-surface-tertiary);padding:var(--bb-spacing-md);border-radius:var(--bb-radius-sm);overflow-x:auto;margin:var(--bb-spacing-sm) 0}._content_1thak_81._markdown_1thak_92 pre code{background:none;padding:0}._content_1thak_81._markdown_1thak_92 a{color:var(--bb-accent-color);text-decoration:none}._content_1thak_81._markdown_1thak_92 a:hover{text-decoration:underline}._content_1thak_81._markdown_1thak_92 blockquote{border-left:3px solid var(--bb-border-color);margin:var(--bb-spacing-sm) 0;padding-left:var(--bb-spacing-md);color:var(--bb-text-secondary)}._content_1thak_81._markdown_1thak_92 hr{border:none;border-top:1px solid var(--bb-border-color);margin:var(--bb-spacing-md) 0}._content_1thak_81._markdown_1thak_92 h1,._content_1thak_81._markdown_1thak_92 h2,._content_1thak_81._markdown_1thak_92 h3,._content_1thak_81._markdown_1thak_92 h4,._content_1thak_81._markdown_1thak_92 h5,._content_1thak_81._markdown_1thak_92 h6{font-weight:var(--bb-font-weight-semibold);margin:var(--bb-spacing-sm) 0 var(--bb-spacing-xs) 0;line-height:1.3}._content_1thak_81._markdown_1thak_92 h1{font-size:1.3em}._content_1thak_81._markdown_1thak_92 h2{font-size:1.2em}._content_1thak_81._markdown_1thak_92 h3{font-size:1.1em}._content_1thak_81._markdown_1thak_92 h4,._content_1thak_81._markdown_1thak_92 h5,._content_1thak_81._markdown_1thak_92 h6{font-size:1em}._cursor_1thak_183{display:inline-block;width:2px;height:1em;background:currentColor;margin-left:2px;animation:_blink_1thak_1 1s infinite;vertical-align:text-bottom}@keyframes _blink_1thak_1{0%,50%{opacity:1}51%,to{opacity:0}}._errorIndicator_1thak_202{display:flex;align-items:center;gap:var(--bb-spacing-xs);margin-top:var(--bb-spacing-sm);color:#ef4444;font-size:var(--bb-font-size-sm)}._errorIndicator_1thak_202 svg{width:14px;height:14px}._toolCall_1wby1_1{display:flex;align-items:center;gap:var(--bb-spacing-md);padding:var(--bb-spacing-md) var(--bb-spacing-lg);background:var(--bb-surface-tertiary);border-radius:var(--bb-radius-md);font-size:var(--bb-font-size-sm);max-width:85%;animation:_slideIn_1wby1_1 .2s ease}@keyframes _slideIn_1wby1_1{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}._iconWrapper_1wby1_24{width:20px;height:20px;display:flex;align-items:center;justify-content:center;flex-shrink:0}._spinner_1wby1_33{width:16px;height:16px;border:2px solid var(--bb-border-color);border-top-color:var(--bb-accent-color);border-radius:var(--bb-radius-full);animation:_spin_1wby1_33 .8s linear infinite}@keyframes _spin_1wby1_33{to{transform:rotate(360deg)}}._checkIcon_1wby1_48{width:16px;height:16px;color:#10b981}._errorIcon_1wby1_54{width:16px;height:16px;color:#ef4444}._content_1wby1_60{display:flex;flex-direction:column;gap:2px}._label_1wby1_66{font-size:var(--bb-font-size-xs);color:var(--bb-text-tertiary);text-transform:uppercase;letter-spacing:.5px}._name_1wby1_73{color:var(--bb-text-secondary);font-weight:var(--bb-font-weight-medium)}._pending_1wby1_78{border-left:3px solid var(--bb-accent-color)}._completed_1wby1_82{border-left:3px solid #10b981}._error_1wby1_54{border-left:3px solid #ef4444;background:#fef2f2}._wrapper_10rss_2{display:flex;align-items:flex-start;gap:var(--bb-spacing-md);max-width:85%;margin-right:auto;animation:_slideIn_10rss_1 .3s ease}@keyframes _slideIn_10rss_1{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}._avatar_10rss_22{flex-shrink:0;width:28px;height:28px;border-radius:var(--bb-radius-full);overflow:hidden;margin-top:2px}._avatar_10rss_22 img{width:100%;height:100%;object-fit:cover}._avatarPlaceholder_10rss_37{width:100%;height:100%;background:var(--bb-primary-color);display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse)}._brainbaseLogo_10rss_47{width:18px;height:18px}._bubble_10rss_52{display:flex;align-items:center;gap:5px;padding:var(--bb-spacing-md) var(--bb-spacing-lg);background:var(--bb-assistant-message-bg);border-radius:var(--bb-radius-lg);border-bottom-left-radius:var(--bb-spacing-xs);min-height:44px}._dot_10rss_63{width:8px;height:8px;background:var(--bb-text-tertiary);border-radius:var(--bb-radius-full);animation:_bounce_10rss_1 1.4s infinite ease-in-out both}._dot_10rss_63:nth-child(1){animation-delay:-.32s}._dot_10rss_63:nth-child(2){animation-delay:-.16s}._dot_10rss_63:nth-child(3){animation-delay:0s}@keyframes _bounce_10rss_1{0%,80%,to{transform:scale(.6);opacity:.4}40%{transform:scale(1);opacity:1}}._messageList_9tkjc_1{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:var(--bb-spacing-xl);display:flex;flex-direction:column;gap:var(--bb-spacing-lg);scroll-behavior:smooth}._messageList_9tkjc_1::-webkit-scrollbar{width:6px}._messageList_9tkjc_1::-webkit-scrollbar-track{background:transparent}._messageList_9tkjc_1::-webkit-scrollbar-thumb{background:var(--bb-border-color);border-radius:var(--bb-radius-full)}._messageList_9tkjc_1::-webkit-scrollbar-thumb:hover{background:var(--bb-text-tertiary)}._emptyState_9tkjc_30{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--bb-text-tertiary);text-align:center;padding:var(--bb-spacing-2xl)}._emptyIcon_9tkjc_41{width:48px;height:48px;margin-bottom:var(--bb-spacing-lg);opacity:.5}._emptyIcon_9tkjc_41 svg{width:100%;height:100%}._emptyText_9tkjc_53{margin:0;font-size:var(--bb-font-size-md)}._inputWrapper_5lgg7_1{padding:var(--bb-spacing-lg);background:var(--bb-surface-bg);border-top:1px solid var(--bb-border-color-light)}._inputContainer_5lgg7_7{display:flex;align-items:flex-end;gap:var(--bb-spacing-sm);padding:var(--bb-spacing-sm) var(--bb-spacing-md);background:var(--bb-surface-secondary);border-radius:var(--bb-radius-xl);border:1px solid var(--bb-border-color);transition:border-color var(--bb-transition-fast),box-shadow var(--bb-transition-fast)}._inputContainer_5lgg7_7:focus-within{border-color:var(--bb-accent-color);box-shadow:0 0 0 3px #6366f11a}._textarea_5lgg7_23{flex:1;border:none;background:transparent;resize:none;font-family:var(--bb-font-family);font-size:var(--bb-font-size-md);line-height:var(--bb-line-height);color:var(--bb-text-primary);padding:var(--bb-spacing-sm) 0;min-height:24px;max-height:150px}._textarea_5lgg7_23::placeholder{color:var(--bb-text-tertiary)}._textarea_5lgg7_23:focus{outline:none}._textarea_5lgg7_23:disabled{opacity:.6;cursor:not-allowed}._sendButton_5lgg7_50{flex-shrink:0;width:36px;height:36px;border-radius:var(--bb-radius-full);background:var(--bb-primary-color);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse);transition:background var(--bb-transition-fast),transform var(--bb-transition-fast)}._sendButton_5lgg7_50:hover:not(:disabled){background:var(--bb-primary-hover);transform:scale(1.05)}._sendButton_5lgg7_50:active:not(:disabled){transform:scale(.98)}._sendButton_5lgg7_50:disabled{opacity:.4;cursor:not-allowed}._sendButton_5lgg7_50:focus-visible{outline:2px solid var(--bb-accent-color);outline-offset:2px}._sendButton_5lgg7_50 svg{width:18px;height:18px}._hint_5lgg7_89{margin-top:var(--bb-spacing-sm);font-size:var(--bb-font-size-xs);color:var(--bb-text-tertiary);text-align:center}._hint_5lgg7_89 kbd{display:inline-block;padding:2px 6px;font-family:var(--bb-font-family);font-size:var(--bb-font-size-xs);background:var(--bb-surface-tertiary);border-radius:4px;border:1px solid var(--bb-border-color)}._poweredBy_9jh5q_1{display:flex;align-items:center;justify-content:center;gap:4px;padding:var(--bb-spacing-sm) var(--bb-spacing-md);background:var(--bb-surface-secondary);border-top:1px solid var(--bb-border-color-light);color:var(--bb-text-tertiary);text-decoration:none;font-size:var(--bb-font-size-xs);font-weight:var(--bb-font-weight-medium);transition:color var(--bb-transition-fast)}._poweredBy_9jh5q_1:hover{color:var(--bb-text-secondary)}._poweredBy_9jh5q_1:hover ._logo_9jh5q_20{opacity:.9}._poweredText_9jh5q_24{opacity:.7}._logo_9jh5q_20{width:12px;height:12px;opacity:.6;transition:opacity var(--bb-transition-fast);margin-left:2px}._text_9jh5q_36{letter-spacing:.01em;font-weight:var(--bb-font-weight-semibold)}._container_m2o9l_1{position:relative;display:flex;flex-direction:column;width:var(--bb-widget-width);height:var(--bb-widget-height);max-height:var(--bb-widget-max-height);background:var(--bb-surface-bg);border-radius:var(--bb-radius-xl);box-shadow:var(--bb-shadow-xl);overflow:hidden;animation:_slideUp_m2o9l_1 .3s ease}@keyframes _slideUp_m2o9l_1{0%{opacity:0;transform:translateY(20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}._body_m2o9l_26{flex:1;display:flex;flex-direction:column;min-height:0;background:var(--bb-surface-bg)}._confirmationOverlay_m2o9l_35{position:absolute;top:0;right:0;bottom:0;left:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:100;animation:_overlayFadeIn_m2o9l_1 .2s ease;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}@keyframes _overlayFadeIn_m2o9l_1{0%{opacity:0}to{opacity:1}}._confirmationDialog_m2o9l_56{background:var(--bb-surface-bg);border-radius:var(--bb-radius-xl);padding:var(--bb-spacing-2xl);margin:var(--bb-spacing-xl);box-shadow:var(--bb-shadow-xl);animation:_dialogSlideUp_m2o9l_1 .25s cubic-bezier(.4,0,.2,1);max-width:300px;width:calc(100% - 48px)}@keyframes _dialogSlideUp_m2o9l_1{0%{opacity:0;transform:translateY(12px) scale(.96)}to{opacity:1;transform:translateY(0) scale(1)}}._confirmationText_m2o9l_78{margin:0 0 var(--bb-spacing-xl);font-size:var(--bb-font-size-md);color:var(--bb-text-primary);line-height:var(--bb-line-height);text-align:center}._confirmationButtons_m2o9l_86{display:flex;gap:var(--bb-spacing-md)}._cancelButton_m2o9l_91,._confirmButton_m2o9l_92{flex:1;padding:var(--bb-spacing-md) var(--bb-spacing-lg);border-radius:var(--bb-radius-md);font-size:var(--bb-font-size-sm);font-weight:var(--bb-font-weight-medium);cursor:pointer;transition:all var(--bb-transition-fast)}._cancelButton_m2o9l_91{background:var(--bb-surface-secondary);border:1px solid var(--bb-border-color);color:var(--bb-text-secondary)}._cancelButton_m2o9l_91:hover{background:var(--bb-surface-tertiary);color:var(--bb-text-primary)}._confirmButton_m2o9l_92{background:#ef4444;border:none;color:#fff}._confirmButton_m2o9l_92:hover{background:#dc2626}._confirmButton_m2o9l_92:active,._cancelButton_m2o9l_91:active{transform:scale(.98)}@media(max-width:480px){._container_m2o9l_1{width:100vw;height:100vh;max-height:100vh;border-radius:0}}._toggleButton_11dqz_1{position:relative;display:flex;align-items:center;justify-content:center;width:var(--bb-toggle-size);height:var(--bb-toggle-size);border-radius:var(--bb-radius-full);background:linear-gradient(135deg,var(--bb-primary-color) 0%,#2d2d5a 100%);border:none;cursor:pointer;box-shadow:var(--bb-shadow-lg);transition:transform var(--bb-transition-normal),box-shadow var(--bb-transition-normal);color:var(--bb-text-inverse)}._toggleButton_11dqz_1:hover{transform:scale(1.05);box-shadow:var(--bb-shadow-xl)}._toggleButton_11dqz_1:active{transform:scale(.98)}._toggleButton_11dqz_1:focus-visible{outline:2px solid var(--bb-accent-color);outline-offset:2px}._icon_11dqz_31{width:28px;height:28px}._agentLogo_11dqz_36{width:36px;height:36px;border-radius:var(--bb-radius-full);object-fit:cover}._unreadBadge_11dqz_43{position:absolute;top:-4px;right:-4px;min-width:20px;height:20px;padding:0 6px;border-radius:var(--bb-radius-full);background:#ef4444;color:#fff;font-size:var(--bb-font-size-xs);font-weight:var(--bb-font-weight-bold);display:flex;align-items:center;justify-content:center;box-shadow:0 2px 4px #0003}._container_kgfgt_1{display:flex;flex-direction:column;width:var(--bb-widget-width);height:var(--bb-widget-height);max-height:var(--bb-widget-max-height);background:var(--bb-surface-bg);border-radius:var(--bb-radius-xl);box-shadow:var(--bb-shadow-xl);overflow:hidden;animation:_slideUp_kgfgt_1 .3s ease}@keyframes _slideUp_kgfgt_1{0%{opacity:0;transform:translateY(20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}._header_kgfgt_25{display:flex;align-items:center;justify-content:space-between;padding:var(--bb-spacing-lg) var(--bb-spacing-xl);background:linear-gradient(135deg,var(--bb-primary-color) 0%,color-mix(in srgb,var(--bb-primary-color) 70%,#2d2d5a) 50%,color-mix(in srgb,var(--bb-primary-color) 50%,#1a1a2e) 100%)}._logoWrapper_kgfgt_38{width:32px;height:32px;display:flex;align-items:center;justify-content:center}._logo_kgfgt_38{width:24px;height:24px}._closeButton_kgfgt_51{width:32px;height:32px;border-radius:var(--bb-radius-full);background:#ffffff1a;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse);transition:background var(--bb-transition-fast)}._closeButton_kgfgt_51:hover{background:#fff3}._closeButton_kgfgt_51 svg{width:18px;height:18px}._content_kgfgt_74{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--bb-spacing-2xl);text-align:center}._iconWrapper_kgfgt_84{width:64px;height:64px;border-radius:var(--bb-radius-full);background:var(--bb-surface-secondary);display:flex;align-items:center;justify-content:center;margin-bottom:var(--bb-spacing-xl)}._errorIcon_kgfgt_95{width:32px;height:32px;color:var(--bb-text-tertiary)}._title_kgfgt_101{margin:0;font-size:var(--bb-font-size-xl);font-weight:var(--bb-font-weight-semibold);color:var(--bb-text-primary);margin-bottom:var(--bb-spacing-sm)}._description_kgfgt_109{margin:0;font-size:var(--bb-font-size-md);color:var(--bb-text-secondary);line-height:var(--bb-line-height);max-width:280px}._retryButton_kgfgt_117{margin-top:var(--bb-spacing-xl);padding:var(--bb-spacing-sm) var(--bb-spacing-xl);border-radius:var(--bb-radius-full);background:var(--bb-primary-color);border:none;color:var(--bb-text-inverse);font-size:var(--bb-font-size-md);font-weight:var(--bb-font-weight-medium);cursor:pointer;transition:all var(--bb-transition-fast)}._retryButton_kgfgt_117:hover{transform:scale(1.02);box-shadow:var(--bb-shadow-md)}._retryButton_kgfgt_117:active{transform:scale(.98)}._footer_kgfgt_139{padding:var(--bb-spacing-md);background:var(--bb-surface-secondary);display:flex;justify-content:center}._poweredBy_kgfgt_146{display:flex;align-items:center;gap:var(--bb-spacing-xs);font-size:var(--bb-font-size-xs);color:var(--bb-text-tertiary);text-decoration:none;transition:color var(--bb-transition-fast)}._poweredBy_kgfgt_146:hover{color:var(--bb-text-secondary)}._footerLogo_kgfgt_160{width:14px;height:14px}@media(max-width:480px){._container_kgfgt_1{width:100vw;height:100vh;max-height:100vh;border-radius:0}}._widget_1ehud_1{font-family:var(--bb-font-family);font-size:var(--bb-font-size-md);line-height:var(--bb-line-height);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}._bottom-right_1ehud_10{position:fixed;bottom:20px;right:20px;z-index:9999}._bottom-left_1ehud_17{position:fixed;bottom:20px;left:20px;z-index:9999}._inline_1ehud_25{position:relative;width:100%;max-width:var(--bb-widget-width)}@media(max-width:480px){._bottom-right_1ehud_10,._bottom-left_1ehud_17{bottom:0;right:0;left:0}}')),document.head.appendChild(t)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}}();
2
- var BrainbaseChat=function(e){"use strict";var t=Object.defineProperty,n=(e,n,r)=>((e,n,r)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r)(e,"symbol"!=typeof n?n+"":n,r);function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l,o,a={exports:{}},i={};function u(){if(l)return i;l=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),u=Symbol.for("react.context"),s=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),p=Symbol.iterator;var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}function v(){}function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||h}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},v.prototype=y.prototype;var k=b.prototype=new v;k.constructor=b,m(k,y.prototype),k.isPureReactComponent=!0;var x=Array.isArray,w=Object.prototype.hasOwnProperty,S={current:null},_={key:!0,ref:!0,__self:!0,__source:!0};function C(t,n,r){var l,o={},a=null,i=null;if(null!=n)for(l in void 0!==n.ref&&(i=n.ref),void 0!==n.key&&(a=""+n.key),n)w.call(n,l)&&!_.hasOwnProperty(l)&&(o[l]=n[l]);var u=arguments.length-2;if(1===u)o.children=r;else if(1<u){for(var s=Array(u),c=0;c<u;c++)s[c]=arguments[c+2];o.children=s}if(t&&t.defaultProps)for(l in u=t.defaultProps)void 0===o[l]&&(o[l]=u[l]);return{$$typeof:e,type:t,key:a,ref:i,props:o,_owner:S.current}}function E(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var N=/\/+/g;function P(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function I(n,r,l,o,a){var i=typeof n;"undefined"!==i&&"boolean"!==i||(n=null);var u=!1;if(null===n)u=!0;else switch(i){case"string":case"number":u=!0;break;case"object":switch(n.$$typeof){case e:case t:u=!0}}if(u)return a=a(u=n),n=""===o?"."+P(u,0):o,x(a)?(l="",null!=n&&(l=n.replace(N,"$&/")+"/"),I(a,r,l,"",function(e){return e})):null!=a&&(E(a)&&(a=function(t,n){return{$$typeof:e,type:t.type,key:n,ref:t.ref,props:t.props,_owner:t._owner}}(a,l+(!a.key||u&&u.key===a.key?"":(""+a.key).replace(N,"$&/")+"/")+n)),r.push(a)),1;if(u=0,o=""===o?".":o+":",x(n))for(var s=0;s<n.length;s++){var c=o+P(i=n[s],s);u+=I(i,r,l,c,a)}else if(c=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(n),"function"==typeof c)for(n=c.call(n),s=0;!(i=n.next()).done;)u+=I(i=i.value,r,l,c=o+P(i,s++),a);else if("object"===i)throw r=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===r?"object with keys {"+Object.keys(n).join(", ")+"}":r)+"). If you meant to render a collection of children, use an array instead.");return u}function T(e,t,n){if(null==e)return e;var r=[],l=0;return I(e,r,"","",function(e){return t.call(n,e,l++)}),r}function L(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var z={current:null},M={transition:null},j={ReactCurrentDispatcher:z,ReactCurrentBatchConfig:M,ReactCurrentOwner:S};function D(){throw Error("act(...) is not supported in production builds of React.")}return i.Children={map:T,forEach:function(e,t,n){T(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return T(e,function(){t++}),t},toArray:function(e){return T(e,function(e){return e})||[]},only:function(e){if(!E(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},i.Component=y,i.Fragment=n,i.Profiler=o,i.PureComponent=b,i.StrictMode=r,i.Suspense=c,i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=j,i.act=D,i.cloneElement=function(t,n,r){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var l=m({},t.props),o=t.key,a=t.ref,i=t._owner;if(null!=n){if(void 0!==n.ref&&(a=n.ref,i=S.current),void 0!==n.key&&(o=""+n.key),t.type&&t.type.defaultProps)var u=t.type.defaultProps;for(s in n)w.call(n,s)&&!_.hasOwnProperty(s)&&(l[s]=void 0===n[s]&&void 0!==u?u[s]:n[s])}var s=arguments.length-2;if(1===s)l.children=r;else if(1<s){u=Array(s);for(var c=0;c<s;c++)u[c]=arguments[c+2];l.children=u}return{$$typeof:e,type:t.type,key:o,ref:a,props:l,_owner:i}},i.createContext=function(e){return(e={$$typeof:u,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},i.createElement=C,i.createFactory=function(e){var t=C.bind(null,e);return t.type=e,t},i.createRef=function(){return{current:null}},i.forwardRef=function(e){return{$$typeof:s,render:e}},i.isValidElement=E,i.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:L}},i.memo=function(e,t){return{$$typeof:f,type:e,compare:void 0===t?null:t}},i.startTransition=function(e){var t=M.transition;M.transition={};try{e()}finally{M.transition=t}},i.unstable_act=D,i.useCallback=function(e,t){return z.current.useCallback(e,t)},i.useContext=function(e){return z.current.useContext(e)},i.useDebugValue=function(){},i.useDeferredValue=function(e){return z.current.useDeferredValue(e)},i.useEffect=function(e,t){return z.current.useEffect(e,t)},i.useId=function(){return z.current.useId()},i.useImperativeHandle=function(e,t,n){return z.current.useImperativeHandle(e,t,n)},i.useInsertionEffect=function(e,t){return z.current.useInsertionEffect(e,t)},i.useLayoutEffect=function(e,t){return z.current.useLayoutEffect(e,t)},i.useMemo=function(e,t){return z.current.useMemo(e,t)},i.useReducer=function(e,t,n){return z.current.useReducer(e,t,n)},i.useRef=function(e){return z.current.useRef(e)},i.useState=function(e){return z.current.useState(e)},i.useSyncExternalStore=function(e,t,n){return z.current.useSyncExternalStore(e,t,n)},i.useTransition=function(){return z.current.useTransition()},i.version="18.3.1",i}function s(){return o||(o=1,a.exports=u()),a.exports}var c=s();const f=r(c);var d,p,h,m,g,y={},v={exports:{}},b={},k={exports:{}},x={};function w(){return p||(p=1,k.exports=(d||(d=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,o=e[r];if(!(0<l(o,t)))break e;e[r]=t,e[n]=o,n=r}}function n(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,o=e.length,a=o>>>1;r<a;){var i=2*(r+1)-1,u=e[i],s=i+1,c=e[s];if(0>l(u,n))s<o&&0>l(c,u)?(e[r]=c,e[s]=n,r=s):(e[r]=u,e[i]=n,r=i);else{if(!(s<o&&0>l(c,n)))break e;e[r]=c,e[s]=n,r=s}}}return t}function l(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,i=a.now();e.unstable_now=function(){return a.now()-i}}var u=[],s=[],c=1,f=null,d=3,p=!1,h=!1,m=!1,g="function"==typeof setTimeout?setTimeout:null,y="function"==typeof clearTimeout?clearTimeout:null,v="undefined"!=typeof setImmediate?setImmediate:null;function b(e){for(var l=n(s);null!==l;){if(null===l.callback)r(s);else{if(!(l.startTime<=e))break;r(s),l.sortIndex=l.expirationTime,t(u,l)}l=n(s)}}function k(e){if(m=!1,b(e),!h)if(null!==n(u))h=!0,z(x);else{var t=n(s);null!==t&&M(k,t.startTime-e)}}function x(t,l){h=!1,m&&(m=!1,y(C),C=-1),p=!0;var o=d;try{for(b(l),f=n(u);null!==f&&(!(f.expirationTime>l)||t&&!P());){var a=f.callback;if("function"==typeof a){f.callback=null,d=f.priorityLevel;var i=a(f.expirationTime<=l);l=e.unstable_now(),"function"==typeof i?f.callback=i:f===n(u)&&r(u),b(l)}else r(u);f=n(u)}if(null!==f)var c=!0;else{var g=n(s);null!==g&&M(k,g.startTime-l),c=!1}return c}finally{f=null,d=o,p=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var w,S=!1,_=null,C=-1,E=5,N=-1;function P(){return!(e.unstable_now()-N<E)}function I(){if(null!==_){var t=e.unstable_now();N=t;var n=!0;try{n=_(!0,t)}finally{n?w():(S=!1,_=null)}}else S=!1}if("function"==typeof v)w=function(){v(I)};else if("undefined"!=typeof MessageChannel){var T=new MessageChannel,L=T.port2;T.port1.onmessage=I,w=function(){L.postMessage(null)}}else w=function(){g(I,0)};function z(e){_=e,S||(S=!0,w())}function M(t,n){C=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){h||p||(h=!0,z(x))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return d},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(e){switch(d){case 1:case 2:case 3:var t=3;break;default:t=d}var n=d;d=t;try{return e()}finally{d=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=d;d=e;try{return t()}finally{d=n}},e.unstable_scheduleCallback=function(r,l,o){var a=e.unstable_now();switch(o="object"==typeof o&&null!==o&&"number"==typeof(o=o.delay)&&0<o?a+o:a,r){case 1:var i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}return r={id:c++,callback:l,priorityLevel:r,startTime:o,expirationTime:i=o+i,sortIndex:-1},o>a?(r.sortIndex=o,t(s,r),null===n(u)&&r===n(s)&&(m?(y(C),C=-1):m=!0,M(k,o-a))):(r.sortIndex=i,t(u,r),h||p||(h=!0,z(x))),r},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(e){var t=d;return function(){var n=d;d=t;try{return e.apply(this,arguments)}finally{d=n}}}}(x)),x)),k.exports}
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var t=document.createElement("style");t.id="brainbase-chat-styles",t.appendChild(document.createTextNode(':root{--bb-primary-color: #1a1a2e;--bb-primary-hover: #16162a;--bb-primary-light: rgba(26, 26, 46, .1);--bb-accent-color: #6366f1;--bb-accent-hover: #5558e3;--bb-focus-color: #6366f1;--bb-focus-shadow: rgba(99, 102, 241, .1);--bb-surface-bg: #ffffff;--bb-surface-secondary: #f8f9fb;--bb-surface-tertiary: #f1f3f9;--bb-text-primary: #1a1a2e;--bb-text-secondary: #6b7280;--bb-text-tertiary: #9ca3af;--bb-text-inverse: #ffffff;--bb-user-message-bg: var(--bb-primary-color);--bb-user-message-text: var(--bb-text-inverse);--bb-assistant-message-bg: var(--bb-surface-secondary);--bb-assistant-message-text: var(--bb-text-primary);--bb-border-color: #e5e7eb;--bb-border-color-light: #f1f3f9;--bb-shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);--bb-shadow-md: 0 4px 12px rgba(0, 0, 0, .08);--bb-shadow-lg: 0 12px 40px rgba(0, 0, 0, .12);--bb-shadow-xl: 0 20px 60px rgba(0, 0, 0, .16);--bb-radius-sm: 8px;--bb-radius-md: 12px;--bb-radius-lg: 16px;--bb-radius-xl: 20px;--bb-radius-full: 9999px;--bb-spacing-xs: 4px;--bb-spacing-sm: 8px;--bb-spacing-md: 12px;--bb-spacing-lg: 16px;--bb-spacing-xl: 20px;--bb-spacing-2xl: 24px;--bb-font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--bb-font-size-xs: 11px;--bb-font-size-sm: 13px;--bb-font-size-md: 14px;--bb-font-size-lg: 16px;--bb-font-size-xl: 18px;--bb-font-size-2xl: 24px;--bb-font-weight-normal: 400;--bb-font-weight-medium: 500;--bb-font-weight-semibold: 600;--bb-font-weight-bold: 700;--bb-line-height: 1.5;--bb-transition-fast: .15s ease;--bb-transition-normal: .2s ease;--bb-transition-slow: .3s ease;--bb-widget-width: 440px;--bb-widget-height: 720px;--bb-widget-max-height: 90vh;--bb-toggle-size: 60px}[data-bb-theme=dark]{--bb-primary-color: #1a1a2e;--bb-primary-hover: #16162a;--bb-primary-light: rgba(26, 26, 46, .3);--bb-surface-bg: #0d0d14;--bb-surface-secondary: #1a1a2e;--bb-surface-tertiary: #252542;--bb-text-primary: #ffffff;--bb-text-secondary: #a1a1aa;--bb-text-tertiary: #71717a;--bb-text-inverse: #0d0d14;--bb-user-message-bg: #f5f5f0;--bb-user-message-text: #1a1a2e;--bb-assistant-message-bg: #1a1a30;--bb-assistant-message-text: #ffffff;--bb-border-color: #2d2d4a;--bb-border-color-light: #1f1f35;--bb-shadow-sm: 0 1px 2px rgba(0, 0, 0, .2);--bb-shadow-md: 0 4px 12px rgba(0, 0, 0, .3);--bb-shadow-lg: 0 12px 40px rgba(0, 0, 0, .4);--bb-shadow-xl: 0 20px 60px rgba(0, 0, 0, .5);--bb-accent-color: #818cf8;--bb-accent-hover: #6366f1;--bb-focus-color: #ffffff;--bb-focus-shadow: rgba(255, 255, 255, .15)}[data-bb-theme=granite]{--bb-primary-color: #374151;--bb-primary-hover: #1f2937;--bb-primary-light: rgba(55, 65, 81, .15);--bb-surface-bg: #1f2937;--bb-surface-secondary: #374151;--bb-surface-tertiary: #4b5563;--bb-text-primary: #f3f4f6;--bb-text-secondary: #d1d5db;--bb-text-tertiary: #9ca3af;--bb-text-inverse: #111827;--bb-user-message-bg: #e5e7eb;--bb-user-message-text: #1f2937;--bb-assistant-message-bg: #4b5563;--bb-assistant-message-text: #f9fafb;--bb-border-color: #4b5563;--bb-border-color-light: #374151;--bb-shadow-sm: 0 1px 2px rgba(0, 0, 0, .15);--bb-shadow-md: 0 4px 12px rgba(0, 0, 0, .25);--bb-shadow-lg: 0 12px 40px rgba(0, 0, 0, .35);--bb-shadow-xl: 0 20px 60px rgba(0, 0, 0, .45);--bb-accent-color: #60a5fa;--bb-accent-hover: #3b82f6}@media(prefers-color-scheme:dark){:root[data-bb-theme=auto]{--bb-surface-bg: #1a1a2e;--bb-surface-secondary: #252542;--bb-surface-tertiary: #2d2d4a;--bb-text-primary: #f8f9fb;--bb-text-secondary: #9ca3af;--bb-text-tertiary: #6b7280;--bb-border-color: #3d3d5c;--bb-border-color-light: #2d2d4a;--bb-assistant-message-bg: var(--bb-surface-secondary);--bb-assistant-message-text: var(--bb-text-primary)}}._header_f8qt7_1{position:relative;overflow:visible;transition:all .4s cubic-bezier(.4,0,.2,1)}._header_f8qt7_1:not(._compact_f8qt7_9){padding:var(--bb-spacing-xl) var(--bb-spacing-xl) var(--bb-spacing-2xl);min-height:140px}._header_f8qt7_1._compact_f8qt7_9{padding:var(--bb-spacing-lg) var(--bb-spacing-xl);min-height:56px}._headerBackground_f8qt7_20{position:absolute;top:0;right:0;bottom:0;left:0;background:var(--bb-primary-color);transition:opacity .4s cubic-bezier(.4,0,.2,1)}._headerBackground_f8qt7_20:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(135deg,transparent 0%,color-mix(in srgb,var(--bb-primary-color) 70%,#2d2d5a) 50%,color-mix(in srgb,var(--bb-primary-color) 50%,#1a1a2e) 100%);opacity:var(--bb-primary-gradient, 0);transition:opacity .3s ease}._headerBackground_f8qt7_20:after{content:"";position:absolute;bottom:0;left:0;right:0;height:60px;background:linear-gradient(to top,rgba(0,0,0,.1),transparent);opacity:var(--bb-primary-gradient, 0);transition:opacity .3s ease}._compact_f8qt7_9 ._headerBackground_f8qt7_20:after{opacity:0}._headerContent_f8qt7_58{position:relative;z-index:1}._topRow_f8qt7_63{display:flex;align-items:center;justify-content:space-between;transition:margin .4s cubic-bezier(.4,0,.2,1)}._header_f8qt7_1:not(._compact_f8qt7_9) ._topRow_f8qt7_63{margin-bottom:var(--bb-spacing-xl)}._compact_f8qt7_9 ._topRow_f8qt7_63{margin-bottom:0}._agentInfo_f8qt7_78{display:flex;align-items:center;gap:var(--bb-spacing-md)}._agentLogo_f8qt7_84{border-radius:var(--bb-radius-sm);object-fit:cover;transition:all .3s cubic-bezier(.4,0,.2,1)}._header_f8qt7_1:not(._compact_f8qt7_9) ._agentLogo_f8qt7_84{width:42px;height:42px}._compact_f8qt7_9 ._agentLogo_f8qt7_84{width:36px;height:36px}._agentLogoPlaceholder_f8qt7_100{border-radius:var(--bb-radius-sm);background:var(--bb-accent-color-custom, var(--bb-primary-color));display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse);transition:all .3s cubic-bezier(.4,0,.2,1)}._header_f8qt7_1:not(._compact_f8qt7_9) ._agentLogoPlaceholder_f8qt7_100{width:42px;height:42px}._compact_f8qt7_9 ._agentLogoPlaceholder_f8qt7_100{width:36px;height:36px}._brainbaseLogo_f8qt7_120{transition:all .3s cubic-bezier(.4,0,.2,1)}._header_f8qt7_1:not(._compact_f8qt7_9) ._brainbaseLogo_f8qt7_120{width:28px;height:28px}._compact_f8qt7_9 ._brainbaseLogo_f8qt7_120{width:24px;height:24px}._backButton_f8qt7_135{width:24px;height:24px;border-radius:var(--bb-radius-full);background:transparent;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-header-text-color, var(--bb-text-inverse));opacity:.8;transition:opacity var(--bb-transition-fast),transform var(--bb-transition-fast);margin-right:2px;margin-left:-4px}._backButton_f8qt7_135:hover{opacity:1}._backButton_f8qt7_135:active{transform:scale(.9)}._backButton_f8qt7_135 svg{width:20px;height:20px}._agentTextWrapper_f8qt7_165{display:flex;flex-direction:column;gap:1px}._agentName_f8qt7_171{color:var(--bb-header-text-color, var(--bb-text-inverse));font-size:var(--bb-agent-name-font-size, 16px);font-weight:var(--bb-font-weight-semibold);opacity:.95;line-height:1.2}._headerSubtitle_f8qt7_179{color:var(--bb-header-text-color, var(--bb-text-inverse));font-size:calc(var(--bb-agent-name-font-size, 16px) - 2px);font-weight:var(--bb-font-weight-normal);opacity:.7;line-height:1.3}._actions_f8qt7_187{display:flex;gap:var(--bb-spacing-sm)}._actionButton_f8qt7_192{width:32px;height:32px;border-radius:var(--bb-radius-full);background:#0000001a;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-header-text-color, var(--bb-text-inverse));transition:background var(--bb-transition-fast),transform var(--bb-transition-fast)}._actionButton_f8qt7_192:hover{background:#fff3;transform:scale(1.05)}._actionButton_f8qt7_192:active{transform:scale(.95)}._actionButton_f8qt7_192:focus-visible{outline:2px solid rgba(255,255,255,.5);outline-offset:2px}._actionButton_f8qt7_192 svg{width:18px;height:18px}._welcomeText_f8qt7_226{color:var(--bb-header-text-color, var(--bb-text-inverse));overflow:visible;transition:all .4s cubic-bezier(.4,0,.2,1)}._header_f8qt7_1:not(._compact_f8qt7_9) ._welcomeText_f8qt7_226{opacity:1;max-height:100px;transform:translateY(0)}._compact_f8qt7_9 ._welcomeText_f8qt7_226{opacity:0;max-height:0;transform:translateY(-10px);pointer-events:none}._title_f8qt7_245{margin:0;font-size:var(--bb-font-size-2xl);font-weight:var(--bb-font-weight-normal);opacity:.7;line-height:1.2}._subtitle_f8qt7_253{margin:var(--bb-spacing-xs) 0 0;font-size:var(--bb-font-size-2xl);font-weight:var(--bb-font-weight-bold);line-height:1.2}._menuContainer_f8qt7_261{position:relative}._dropdown_f8qt7_266{position:absolute;top:calc(100% + 8px);right:0;min-width:180px;background:var(--bb-surface-bg);border-radius:var(--bb-radius-md);box-shadow:var(--bb-shadow-lg);padding:var(--bb-spacing-xs);z-index:9999;animation:_dropdownSlideIn_f8qt7_1 .15s ease}@keyframes _dropdownSlideIn_f8qt7_1{0%{opacity:0;transform:translateY(-4px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}._dropdownItem_f8qt7_290{display:flex;align-items:center;gap:var(--bb-spacing-sm);width:100%;padding:var(--bb-spacing-sm) var(--bb-spacing-md);background:transparent;border:none;border-radius:var(--bb-radius-sm);cursor:pointer;font-family:var(--bb-font-family);font-size:var(--bb-font-size-sm);font-weight:var(--bb-font-weight-medium);color:var(--bb-text-primary);text-align:left;white-space:nowrap;transition:background var(--bb-transition-fast)}._dropdownItem_f8qt7_290:hover{background:var(--bb-surface-secondary)}._dropdownItem_f8qt7_290:active{background:var(--bb-surface-tertiary)}._dropdownItem_f8qt7_290 svg{width:16px;height:16px;min-width:16px;min-height:16px;flex-shrink:0;color:var(--bb-text-secondary)}._dropdownIcon_f8qt7_327{width:16px;height:16px;min-width:16px;min-height:16px;flex-shrink:0;color:var(--bb-text-secondary)}._messageWrapper_1lg4d_1{display:flex;gap:var(--bb-spacing-md);max-width:85%;animation:_messageSlideIn_1lg4d_1 .3s ease}@keyframes _messageSlideIn_1lg4d_1{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}._messageWrapper_1lg4d_1._user_1lg4d_19{flex-direction:row-reverse;margin-left:auto}._messageWrapper_1lg4d_1._assistant_1lg4d_24{margin-right:auto}._avatar_1lg4d_28{flex-shrink:0;width:28px;height:28px;border-radius:var(--bb-radius-full);overflow:hidden;margin-top:2px}._avatar_1lg4d_28 img{width:100%;height:100%;object-fit:cover}._avatarPlaceholder_1lg4d_43{width:100%;height:100%;background:var(--bb-primary-color);display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse)}._brainbaseLogo_1lg4d_53{width:18px;height:18px}._messageBubble_1lg4d_58{padding:var(--bb-spacing-md) var(--bb-spacing-lg);border-radius:22px;position:relative}._user_1lg4d_19 ._messageBubble_1lg4d_58{background:var(--bb-user-message-bg);color:var(--bb-user-message-text);border-bottom-right-radius:6px}._assistant_1lg4d_24 ._messageBubble_1lg4d_58{background:var(--bb-assistant-message-bg);color:var(--bb-assistant-message-text);border-bottom-left-radius:6px}._messageBubble_1lg4d_58._error_1lg4d_76{background:#fef2f2;border:1px solid #fecaca}._content_1lg4d_81{font-size:var(--bb-message-font-size, 15px);line-height:var(--bb-line-height);word-break:break-word}._user_1lg4d_19 ._content_1lg4d_81{white-space:pre-wrap}._content_1lg4d_81._markdown_1lg4d_92 p{margin:0}._content_1lg4d_81._markdown_1lg4d_92 p+p{margin-top:var(--bb-spacing-sm)}._content_1lg4d_81._markdown_1lg4d_92 strong{font-weight:var(--bb-font-weight-semibold)}._content_1lg4d_81._markdown_1lg4d_92 em{font-style:italic}._content_1lg4d_81._markdown_1lg4d_92 ul,._content_1lg4d_81._markdown_1lg4d_92 ol{margin:var(--bb-spacing-sm) 0;padding-left:var(--bb-spacing-lg)}._content_1lg4d_81._markdown_1lg4d_92 li{margin:var(--bb-spacing-xs) 0}._content_1lg4d_81._markdown_1lg4d_92 li::marker{color:var(--bb-text-secondary)}._content_1lg4d_81._markdown_1lg4d_92 code{background:var(--bb-surface-tertiary);padding:2px 6px;border-radius:var(--bb-radius-sm);font-family:SF Mono,Monaco,Courier New,monospace;font-size:.9em}._content_1lg4d_81._markdown_1lg4d_92 pre{background:var(--bb-surface-tertiary);padding:var(--bb-spacing-md);border-radius:var(--bb-radius-sm);overflow-x:auto;margin:var(--bb-spacing-sm) 0}._content_1lg4d_81._markdown_1lg4d_92 pre code{background:none;padding:0}._content_1lg4d_81._markdown_1lg4d_92 a{color:var(--bb-accent-color);text-decoration:none}._content_1lg4d_81._markdown_1lg4d_92 a:hover{text-decoration:underline}._content_1lg4d_81._markdown_1lg4d_92 blockquote{border-left:3px solid var(--bb-border-color);margin:var(--bb-spacing-sm) 0;padding-left:var(--bb-spacing-md);color:var(--bb-text-secondary)}._content_1lg4d_81._markdown_1lg4d_92 hr{border:none;border-top:1px solid var(--bb-border-color);margin:var(--bb-spacing-md) 0}._content_1lg4d_81._markdown_1lg4d_92 h1,._content_1lg4d_81._markdown_1lg4d_92 h2,._content_1lg4d_81._markdown_1lg4d_92 h3,._content_1lg4d_81._markdown_1lg4d_92 h4,._content_1lg4d_81._markdown_1lg4d_92 h5,._content_1lg4d_81._markdown_1lg4d_92 h6{font-weight:var(--bb-font-weight-semibold);margin:var(--bb-spacing-sm) 0 var(--bb-spacing-xs) 0;line-height:1.3}._content_1lg4d_81._markdown_1lg4d_92 h1{font-size:1.3em}._content_1lg4d_81._markdown_1lg4d_92 h2{font-size:1.2em}._content_1lg4d_81._markdown_1lg4d_92 h3{font-size:1.1em}._content_1lg4d_81._markdown_1lg4d_92 h4,._content_1lg4d_81._markdown_1lg4d_92 h5,._content_1lg4d_81._markdown_1lg4d_92 h6{font-size:1em}._cursor_1lg4d_183{display:inline-block;width:2px;height:1em;background:currentColor;margin-left:2px;animation:_blink_1lg4d_1 1s infinite;vertical-align:text-bottom}@keyframes _blink_1lg4d_1{0%,50%{opacity:1}51%,to{opacity:0}}._errorIndicator_1lg4d_202{display:flex;align-items:center;gap:var(--bb-spacing-xs);margin-top:var(--bb-spacing-sm);color:#ef4444;font-size:var(--bb-font-size-sm)}._errorIndicator_1lg4d_202 svg{width:14px;height:14px}._messageContent_1lg4d_219{display:flex;flex-direction:column;gap:var(--bb-spacing-xs);min-width:0}._messageInfo_1lg4d_227{display:flex;align-items:center;gap:var(--bb-spacing-xs);font-size:calc(var(--bb-message-font-size, 15px) - 2px);color:var(--bb-text-tertiary);padding-left:var(--bb-spacing-lg);animation:_slideIn_1lg4d_1 .25s cubic-bezier(.4,0,.2,1)}@keyframes _slideIn_1lg4d_1{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes _slideOut_1lg4d_1{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-4px)}}._messageInfo_1lg4d_227._fadeOut_1lg4d_259{animation:_slideOut_1lg4d_1 .2s cubic-bezier(.4,0,.2,1) forwards}._messageInfo_1lg4d_227 ._agentName_1lg4d_263{font-weight:var(--bb-font-weight-medium);color:var(--bb-text-secondary)}._messageInfo_1lg4d_227 ._agentRole_1lg4d_268{color:var(--bb-text-tertiary)}._messageInfo_1lg4d_227 ._separator_1lg4d_272{color:var(--bb-text-tertiary);opacity:.6}._messageInfo_1lg4d_227 ._timestamp_1lg4d_277{color:var(--bb-text-tertiary)}._toolCall_1wby1_1{display:flex;align-items:center;gap:var(--bb-spacing-md);padding:var(--bb-spacing-md) var(--bb-spacing-lg);background:var(--bb-surface-tertiary);border-radius:var(--bb-radius-md);font-size:var(--bb-font-size-sm);max-width:85%;animation:_slideIn_1wby1_1 .2s ease}@keyframes _slideIn_1wby1_1{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}._iconWrapper_1wby1_24{width:20px;height:20px;display:flex;align-items:center;justify-content:center;flex-shrink:0}._spinner_1wby1_33{width:16px;height:16px;border:2px solid var(--bb-border-color);border-top-color:var(--bb-accent-color);border-radius:var(--bb-radius-full);animation:_spin_1wby1_33 .8s linear infinite}@keyframes _spin_1wby1_33{to{transform:rotate(360deg)}}._checkIcon_1wby1_48{width:16px;height:16px;color:#10b981}._errorIcon_1wby1_54{width:16px;height:16px;color:#ef4444}._content_1wby1_60{display:flex;flex-direction:column;gap:2px}._label_1wby1_66{font-size:var(--bb-font-size-xs);color:var(--bb-text-tertiary);text-transform:uppercase;letter-spacing:.5px}._name_1wby1_73{color:var(--bb-text-secondary);font-weight:var(--bb-font-weight-medium)}._pending_1wby1_78{border-left:3px solid var(--bb-accent-color)}._completed_1wby1_82{border-left:3px solid #10b981}._error_1wby1_54{border-left:3px solid #ef4444;background:#fef2f2}._wrapper_10rss_2{display:flex;align-items:flex-start;gap:var(--bb-spacing-md);max-width:85%;margin-right:auto;animation:_slideIn_10rss_1 .3s ease}@keyframes _slideIn_10rss_1{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}._avatar_10rss_22{flex-shrink:0;width:28px;height:28px;border-radius:var(--bb-radius-full);overflow:hidden;margin-top:2px}._avatar_10rss_22 img{width:100%;height:100%;object-fit:cover}._avatarPlaceholder_10rss_37{width:100%;height:100%;background:var(--bb-primary-color);display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse)}._brainbaseLogo_10rss_47{width:18px;height:18px}._bubble_10rss_52{display:flex;align-items:center;gap:5px;padding:var(--bb-spacing-md) var(--bb-spacing-lg);background:var(--bb-assistant-message-bg);border-radius:var(--bb-radius-lg);border-bottom-left-radius:var(--bb-spacing-xs);min-height:44px}._dot_10rss_63{width:8px;height:8px;background:var(--bb-text-tertiary);border-radius:var(--bb-radius-full);animation:_bounce_10rss_1 1.4s infinite ease-in-out both}._dot_10rss_63:nth-child(1){animation-delay:-.32s}._dot_10rss_63:nth-child(2){animation-delay:-.16s}._dot_10rss_63:nth-child(3){animation-delay:0s}@keyframes _bounce_10rss_1{0%,80%,to{transform:scale(.6);opacity:.4}40%{transform:scale(1);opacity:1}}._messageList_9tkjc_1{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:var(--bb-spacing-xl);display:flex;flex-direction:column;gap:var(--bb-spacing-lg);scroll-behavior:smooth}._messageList_9tkjc_1::-webkit-scrollbar{width:6px}._messageList_9tkjc_1::-webkit-scrollbar-track{background:transparent}._messageList_9tkjc_1::-webkit-scrollbar-thumb{background:var(--bb-border-color);border-radius:var(--bb-radius-full)}._messageList_9tkjc_1::-webkit-scrollbar-thumb:hover{background:var(--bb-text-tertiary)}._emptyState_9tkjc_30{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;color:var(--bb-text-tertiary);text-align:center;padding:var(--bb-spacing-2xl)}._emptyIcon_9tkjc_41{width:48px;height:48px;margin-bottom:var(--bb-spacing-lg);opacity:.5}._emptyIcon_9tkjc_41 svg{width:100%;height:100%}._emptyText_9tkjc_53{margin:0;font-size:var(--bb-font-size-md)}._inputWrapper_6o34z_1{padding:var(--bb-spacing-lg);background:var(--bb-surface-bg);border-top:1px solid var(--bb-border-color-light)}._inputContainer_6o34z_7{display:flex;flex-direction:column;gap:var(--bb-spacing-sm);padding:var(--bb-spacing-md) var(--bb-spacing-lg);background:var(--bb-surface-secondary);border-radius:var(--bb-radius-xl);border:1px solid var(--bb-border-color);transition:border-color var(--bb-transition-fast),box-shadow var(--bb-transition-fast)}._inputContainer_6o34z_7:focus-within{border-color:var(--bb-focus-color, var(--bb-accent-color));box-shadow:0 0 0 3px var(--bb-focus-shadow, rgba(99, 102, 241, .1))}._textarea_6o34z_23{width:100%;border:none;background:transparent;resize:none;font-family:var(--bb-font-family);font-size:var(--bb-font-size-md);line-height:var(--bb-line-height);color:var(--bb-text-primary);padding:0;min-height:24px;max-height:150px}._textarea_6o34z_23::placeholder{color:var(--bb-text-tertiary)}._textarea_6o34z_23:focus{outline:none}._textarea_6o34z_23:disabled{opacity:.6;cursor:not-allowed}._inputActions_6o34z_51{display:flex;align-items:center;justify-content:space-between}._actionIcons_6o34z_57{display:flex;align-items:center;gap:var(--bb-spacing-xs)}._iconButton_6o34z_63{width:32px;height:32px;border-radius:var(--bb-radius-md);background:transparent;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-text-tertiary);transition:color var(--bb-transition-fast),background var(--bb-transition-fast)}._iconButton_6o34z_63:hover:not(:disabled){color:var(--bb-text-secondary);background:var(--bb-surface-tertiary)}._iconButton_6o34z_63:active:not(:disabled){transform:scale(.95)}._iconButton_6o34z_63:disabled{opacity:.4;cursor:not-allowed}._iconButton_6o34z_63 svg{width:20px;height:20px}._sendButton_6o34z_96{flex-shrink:0;width:36px;height:36px;border-radius:var(--bb-radius-full);background:var(--bb-accent-color-custom, var(--bb-primary-color));border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse);transition:background var(--bb-transition-fast),transform var(--bb-transition-fast),opacity var(--bb-transition-fast),filter var(--bb-transition-fast)}._sendButton_6o34z_96:hover:not(:disabled){filter:brightness(.9);transform:scale(1.05)}._sendButton_6o34z_96:active:not(:disabled){transform:scale(.95)}._sendButton_6o34z_96:disabled{opacity:.4;cursor:not-allowed}._sendButton_6o34z_96._audioButton_6o34z_126{opacity:1;cursor:pointer}._sendButton_6o34z_96:focus-visible{outline:2px solid var(--bb-accent-color);outline-offset:2px}._sendButton_6o34z_96 svg{width:18px;height:18px}._sendButton_6o34z_96 svg._audioIcon_6o34z_141{width:22px;height:22px}._poweredBy_9jh5q_1{display:flex;align-items:center;justify-content:center;gap:4px;padding:var(--bb-spacing-sm) var(--bb-spacing-md);background:var(--bb-surface-secondary);border-top:1px solid var(--bb-border-color-light);color:var(--bb-text-tertiary);text-decoration:none;font-size:var(--bb-font-size-xs);font-weight:var(--bb-font-weight-medium);transition:color var(--bb-transition-fast)}._poweredBy_9jh5q_1:hover{color:var(--bb-text-secondary)}._poweredBy_9jh5q_1:hover ._logo_9jh5q_20{opacity:.9}._poweredText_9jh5q_24{opacity:.7}._logo_9jh5q_20{width:12px;height:12px;opacity:.6;transition:opacity var(--bb-transition-fast);margin-left:2px}._text_9jh5q_36{letter-spacing:.01em;font-weight:var(--bb-font-weight-semibold)}._container_1p2zy_1{display:flex;flex-direction:column;height:100%;background:#0a0a0f;position:relative;overflow:hidden}._orbContainer_1p2zy_11{flex:1;cursor:pointer;min-height:200px}._orbContainer_1p2zy_11 canvas{display:block}._status_1p2zy_22{position:absolute;top:16px;left:50%;transform:translate(-50%);color:#fff9;font-size:var(--bb-font-size-sm);z-index:10;text-align:center}._instruction_1p2zy_34{position:absolute;bottom:100px;left:50%;transform:translate(-50%);color:#ffffff80;font-size:var(--bb-font-size-sm);z-index:10;text-align:center;pointer-events:none}._controls_1p2zy_47{position:absolute;bottom:24px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:var(--bb-spacing-md);z-index:10}._controlButton_1p2zy_58{width:48px;height:48px;border-radius:var(--bb-radius-full);border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:transform .15s ease,background .15s ease;background:#ffffff1a;color:#fff}._controlButton_1p2zy_58:hover{transform:scale(1.05);background:#fff3}._controlButton_1p2zy_58:active{transform:scale(.95)}._controlButton_1p2zy_58 svg{width:24px;height:24px}._controlButton_1p2zy_58._muted_1p2zy_86{background:#ef4444cc}._controlButton_1p2zy_58._muted_1p2zy_86:hover{background:#ef4444}._backButton_1p2zy_95{padding:12px 24px;background:#ffffff1a;border:none;border-radius:var(--bb-radius-full);color:#fff;font-size:var(--bb-font-size-sm);cursor:pointer;transition:background .15s ease,transform .15s ease}._backButton_1p2zy_95:hover{background:#fff3;transform:scale(1.02)}._backButton_1p2zy_95:active{transform:scale(.98)}._container_zospk_1{position:relative;display:flex;flex-direction:column;width:var(--bb-widget-width);height:var(--bb-widget-height);max-height:var(--bb-widget-max-height);background:var(--bb-surface-bg);border-radius:var(--bb-radius-xl);box-shadow:var(--bb-shadow-xl);overflow:hidden;overscroll-behavior:contain;transition:width .3s cubic-bezier(.4,0,.2,1),height .3s cubic-bezier(.4,0,.2,1),max-height .3s cubic-bezier(.4,0,.2,1)}._body_zospk_19{flex:1;display:flex;flex-direction:column;min-height:0;overflow:hidden;overscroll-behavior:contain;background:var(--bb-surface-bg)}._confirmationOverlay_zospk_30{position:absolute;top:0;right:0;bottom:0;left:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:100;animation:_overlayFadeIn_zospk_1 .2s ease;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}@keyframes _overlayFadeIn_zospk_1{0%{opacity:0}to{opacity:1}}._confirmationDialog_zospk_51{background:var(--bb-surface-bg);border-radius:var(--bb-radius-xl);padding:var(--bb-spacing-2xl);margin:var(--bb-spacing-xl);box-shadow:var(--bb-shadow-xl);animation:_dialogSlideUp_zospk_1 .25s cubic-bezier(.4,0,.2,1);max-width:300px;width:calc(100% - 48px)}@keyframes _dialogSlideUp_zospk_1{0%{opacity:0;transform:translateY(12px) scale(.96)}to{opacity:1;transform:translateY(0) scale(1)}}._confirmationText_zospk_73{margin:0 0 var(--bb-spacing-xl);font-size:var(--bb-font-size-md);color:var(--bb-text-primary);line-height:var(--bb-line-height);text-align:center}._confirmationButtons_zospk_81{display:flex;gap:var(--bb-spacing-md)}._cancelButton_zospk_86,._confirmButton_zospk_87{flex:1;padding:var(--bb-spacing-md) var(--bb-spacing-lg);border-radius:var(--bb-radius-md);font-size:var(--bb-font-size-sm);font-weight:var(--bb-font-weight-medium);cursor:pointer;transition:all var(--bb-transition-fast)}._cancelButton_zospk_86{background:var(--bb-surface-secondary);border:1px solid var(--bb-border-color);color:var(--bb-text-secondary)}._cancelButton_zospk_86:hover{background:var(--bb-surface-tertiary);color:var(--bb-text-primary)}._confirmButton_zospk_87{background:#ef4444;border:none;color:#fff}._confirmButton_zospk_87:hover{background:#dc2626}._confirmButton_zospk_87:active,._cancelButton_zospk_86:active{transform:scale(.98)}@media(max-width:480px){._container_zospk_1{width:100vw;height:100vh;max-height:100vh;border-radius:0}}._toggleButton_186ig_1{position:relative;display:flex;align-items:center;justify-content:center;width:var(--bb-toggle-size);height:var(--bb-toggle-size);border-radius:var(--bb-radius-full);background:var(--bb-accent-color-custom, var(--bb-primary-color));border:none;cursor:pointer;box-shadow:var(--bb-shadow-lg);transition:transform var(--bb-transition-normal),box-shadow var(--bb-transition-normal),filter var(--bb-transition-normal);color:var(--bb-text-inverse);animation:_buttonAppear_186ig_1 .3s ease}._toggleButton_186ig_1:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:var(--bb-radius-full);background:linear-gradient(135deg,transparent 0%,rgba(0,0,0,.3) 100%);opacity:var(--bb-accent-gradient, 0);pointer-events:none}@keyframes _buttonAppear_186ig_1{0%{opacity:0;transform:scale(.8) rotate(90deg)}to{opacity:1;transform:scale(1) rotate(0)}}._toggleButton_186ig_1:hover{transform:scale(1.05);box-shadow:var(--bb-shadow-xl)}._toggleButton_186ig_1:active{transform:scale(.98)}._toggleButton_186ig_1:focus-visible{outline:2px solid var(--bb-accent-color);outline-offset:2px}._icon_186ig_54{width:28px;height:28px}._customIcon_186ig_59{display:flex;align-items:center;justify-content:center;width:28px;height:28px}._customIcon_186ig_59 svg{width:100%;height:100%}._agentLogo_186ig_72{width:36px;height:36px;border-radius:var(--bb-radius-full);object-fit:cover}._unreadBadge_186ig_79{position:absolute;top:-4px;right:-4px;min-width:20px;height:20px;padding:0 6px;border-radius:var(--bb-radius-full);background:#ef4444;color:#fff;font-size:var(--bb-font-size-xs);font-weight:var(--bb-font-weight-bold);display:flex;align-items:center;justify-content:center;box-shadow:0 2px 4px #0003}._container_kgfgt_1{display:flex;flex-direction:column;width:var(--bb-widget-width);height:var(--bb-widget-height);max-height:var(--bb-widget-max-height);background:var(--bb-surface-bg);border-radius:var(--bb-radius-xl);box-shadow:var(--bb-shadow-xl);overflow:hidden;animation:_slideUp_kgfgt_1 .3s ease}@keyframes _slideUp_kgfgt_1{0%{opacity:0;transform:translateY(20px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}._header_kgfgt_25{display:flex;align-items:center;justify-content:space-between;padding:var(--bb-spacing-lg) var(--bb-spacing-xl);background:linear-gradient(135deg,var(--bb-primary-color) 0%,color-mix(in srgb,var(--bb-primary-color) 70%,#2d2d5a) 50%,color-mix(in srgb,var(--bb-primary-color) 50%,#1a1a2e) 100%)}._logoWrapper_kgfgt_38{width:32px;height:32px;display:flex;align-items:center;justify-content:center}._logo_kgfgt_38{width:24px;height:24px}._closeButton_kgfgt_51{width:32px;height:32px;border-radius:var(--bb-radius-full);background:#ffffff1a;border:none;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse);transition:background var(--bb-transition-fast)}._closeButton_kgfgt_51:hover{background:#fff3}._closeButton_kgfgt_51 svg{width:18px;height:18px}._content_kgfgt_74{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--bb-spacing-2xl);text-align:center}._iconWrapper_kgfgt_84{width:64px;height:64px;border-radius:var(--bb-radius-full);background:var(--bb-surface-secondary);display:flex;align-items:center;justify-content:center;margin-bottom:var(--bb-spacing-xl)}._errorIcon_kgfgt_95{width:32px;height:32px;color:var(--bb-text-tertiary)}._title_kgfgt_101{margin:0;font-size:var(--bb-font-size-xl);font-weight:var(--bb-font-weight-semibold);color:var(--bb-text-primary);margin-bottom:var(--bb-spacing-sm)}._description_kgfgt_109{margin:0;font-size:var(--bb-font-size-md);color:var(--bb-text-secondary);line-height:var(--bb-line-height);max-width:280px}._retryButton_kgfgt_117{margin-top:var(--bb-spacing-xl);padding:var(--bb-spacing-sm) var(--bb-spacing-xl);border-radius:var(--bb-radius-full);background:var(--bb-primary-color);border:none;color:var(--bb-text-inverse);font-size:var(--bb-font-size-md);font-weight:var(--bb-font-weight-medium);cursor:pointer;transition:all var(--bb-transition-fast)}._retryButton_kgfgt_117:hover{transform:scale(1.02);box-shadow:var(--bb-shadow-md)}._retryButton_kgfgt_117:active{transform:scale(.98)}._footer_kgfgt_139{padding:var(--bb-spacing-md);background:var(--bb-surface-secondary);display:flex;justify-content:center}._poweredBy_kgfgt_146{display:flex;align-items:center;gap:var(--bb-spacing-xs);font-size:var(--bb-font-size-xs);color:var(--bb-text-tertiary);text-decoration:none;transition:color var(--bb-transition-fast)}._poweredBy_kgfgt_146:hover{color:var(--bb-text-secondary)}._footerLogo_kgfgt_160{width:14px;height:14px}@media(max-width:480px){._container_kgfgt_1{width:100vw;height:100vh;max-height:100vh;border-radius:0}}._container_cgn0s_1{position:relative;display:flex;flex-direction:column;width:var(--bb-widget-width);height:var(--bb-widget-height);max-height:var(--bb-widget-max-height);background:var(--bb-surface-bg);border-radius:var(--bb-radius-xl);box-shadow:var(--bb-shadow-xl);overflow:hidden;overscroll-behavior:contain;transition:width .3s cubic-bezier(.4,0,.2,1),height .3s cubic-bezier(.4,0,.2,1),max-height .3s cubic-bezier(.4,0,.2,1)}@media(max-width:480px){._container_cgn0s_1{width:100vw;height:100vh;max-height:100vh;border-radius:0}}._header_cgn0s_29{position:relative;padding:var(--bb-spacing-lg) var(--bb-spacing-xl)}._headerBackground_cgn0s_34{position:absolute;top:0;right:0;bottom:0;left:0;background:var(--bb-primary-color)}._headerContent_cgn0s_40{position:relative;z-index:1}._agentInfo_cgn0s_45{display:flex;align-items:center;gap:var(--bb-spacing-md)}._headerLogo_cgn0s_51{width:42px;height:42px;border-radius:var(--bb-radius-sm);object-fit:cover}._headerLogoPlaceholder_cgn0s_58{width:42px;height:42px;border-radius:var(--bb-radius-sm);background:var(--bb-accent-color-custom, var(--bb-primary-color));display:flex;align-items:center;justify-content:center}._headerBrainbaseLogo_cgn0s_68{width:28px;height:28px}._headerAgentName_cgn0s_73{color:var(--bb-header-text-color, var(--bb-text-inverse));font-size:var(--bb-agent-name-font-size, 16px);font-weight:var(--bb-font-weight-semibold)}._content_cgn0s_79{flex:1;overflow-y:auto;padding:var(--bb-spacing-xl);display:flex;flex-direction:column;gap:var(--bb-spacing-xl)}._infoCard_cgn0s_89{display:flex;flex-direction:column;align-items:stretch;padding:0;background:var(--bb-surface-secondary);border:1px solid var(--bb-border-color);border-radius:var(--bb-radius-lg);text-align:left;width:100%;cursor:default;overflow:hidden;transition:background var(--bb-transition-fast),border-color var(--bb-transition-fast),transform var(--bb-transition-fast)}._infoCard_cgn0s_89._clickable_cgn0s_104{cursor:pointer}._infoCard_cgn0s_89._clickable_cgn0s_104:hover{background:var(--bb-surface-tertiary);border-color:var(--bb-text-tertiary);transform:translateY(-2px)}._infoCard_cgn0s_89._clickable_cgn0s_104:active{transform:translateY(0)}._infoCard_cgn0s_89:disabled{cursor:default}._infoImageWrapper_cgn0s_122{width:100%;height:180px;overflow:hidden}._infoImage_cgn0s_122{width:100%;height:100%;object-fit:cover}._infoContent_cgn0s_134{display:flex;align-items:center;justify-content:space-between;padding:var(--bb-spacing-lg);gap:var(--bb-spacing-md)}._infoText_cgn0s_142{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}._infoTitle_cgn0s_150{margin:0;font-size:var(--bb-font-size-lg);font-weight:var(--bb-font-weight-semibold);color:var(--bb-text-primary);line-height:1.3}._infoDescription_cgn0s_158{margin:0;font-size:var(--bb-font-size-sm);color:var(--bb-text-secondary);line-height:1.5;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}._infoChevron_cgn0s_169{flex-shrink:0;width:24px;height:24px;color:var(--bb-text-tertiary)}._askCard_cgn0s_177{display:flex;align-items:center;justify-content:space-between;padding:var(--bb-spacing-lg);background:var(--bb-surface-secondary);border:1px solid var(--bb-border-color);border-radius:var(--bb-radius-lg);cursor:pointer;transition:background var(--bb-transition-fast),border-color var(--bb-transition-fast);text-align:left;width:100%}._askCard_cgn0s_177:hover{background:var(--bb-surface-tertiary);border-color:var(--bb-border-color)}._askContent_cgn0s_196{display:flex;flex-direction:column;gap:2px}._askTitle_cgn0s_202{font-size:var(--bb-font-size-md);font-weight:var(--bb-font-weight-semibold);color:var(--bb-text-primary)}._askSubtitle_cgn0s_208{font-size:var(--bb-font-size-sm);color:var(--bb-text-secondary)}._askIcon_cgn0s_213{display:flex;align-items:center;gap:var(--bb-spacing-sm);color:var(--bb-text-tertiary)}._agentLogo_cgn0s_220{width:24px;height:24px;border-radius:var(--bb-radius-sm);object-fit:cover}._brainbaseLogo_cgn0s_227{width:24px;height:24px}._chevron_cgn0s_232{width:20px;height:20px}._footer_cgn0s_238{display:flex;justify-content:space-around;padding:var(--bb-spacing-md) var(--bb-spacing-lg);background:var(--bb-surface-bg);border-top:1px solid var(--bb-border-color)}._navItem_cgn0s_246{display:flex;flex-direction:column;align-items:center;gap:var(--bb-spacing-xs);padding:var(--bb-spacing-sm) var(--bb-spacing-md);background:transparent;border:none;cursor:pointer;color:var(--bb-text-tertiary);font-size:var(--bb-font-size-xs);font-family:var(--bb-font-family);transition:color var(--bb-transition-fast)}._navItem_cgn0s_246:hover{color:var(--bb-text-secondary)}._navItem_cgn0s_246._active_cgn0s_265{color:var(--bb-text-primary)}._navIcon_cgn0s_269{width:24px;height:24px}._widget_1ntwj_1{font-family:var(--bb-font-family);font-size:var(--bb-font-size-md);line-height:var(--bb-line-height);color:var(--bb-text-primary);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}._bottom-right_1ntwj_11{position:fixed;bottom:20px;right:20px;z-index:9999}._bottom-left_1ntwj_18{position:fixed;bottom:20px;left:20px;z-index:9999}._inline_1ntwj_26{position:relative;width:100%;max-width:var(--bb-widget-width)}@media(max-width:480px){._bottom-right_1ntwj_11,._bottom-left_1ntwj_18{bottom:0;right:0;left:0}}._openContainer_1ntwj_43{display:flex;flex-direction:column;align-items:flex-end;gap:var(--bb-spacing-md)}._collapseButton_1ntwj_51{position:relative;width:var(--bb-toggle-size);height:var(--bb-toggle-size);border-radius:var(--bb-radius-full);background:var(--bb-accent-color-custom, var(--bb-primary-color));border:none;box-shadow:var(--bb-shadow-lg);cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--bb-text-inverse);transition:transform var(--bb-transition-normal),box-shadow var(--bb-transition-normal),filter var(--bb-transition-normal);animation:_buttonAppear_1ntwj_1 .3s ease}._collapseButton_1ntwj_51:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:var(--bb-radius-full);background:linear-gradient(135deg,transparent 0%,rgba(0,0,0,.3) 100%);opacity:var(--bb-accent-gradient, 0);pointer-events:none}@keyframes _buttonAppear_1ntwj_1{0%{opacity:0;transform:scale(.8) rotate(-90deg)}to{opacity:1;transform:scale(1) rotate(0)}}._collapseButton_1ntwj_51:hover{transform:scale(1.05);box-shadow:var(--bb-shadow-xl)}._collapseButton_1ntwj_51:active{transform:scale(.95)}._collapseButton_1ntwj_51 svg{width:28px;height:28px}')),document.head.appendChild(t)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}}();
2
+ var BrainbaseChat=function(e){"use strict";var t=Object.defineProperty,n=(e,n,i)=>((e,n,i)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i)(e,"symbol"!=typeof n?n+"":n,i);function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,o,a={exports:{}},s={};function c(){if(r)return s;r=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),c=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.iterator;var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,g={};function v(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||f}function y(){}function b(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||f}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=v.prototype;var k=b.prototype=new y;k.constructor=b,m(k,v.prototype),k.isPureReactComponent=!0;var S=Array.isArray,C=Object.prototype.hasOwnProperty,T={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function E(t,n,i){var r,o={},a=null,s=null;if(null!=n)for(r in void 0!==n.ref&&(s=n.ref),void 0!==n.key&&(a=""+n.key),n)C.call(n,r)&&!w.hasOwnProperty(r)&&(o[r]=n[r]);var c=arguments.length-2;if(1===c)o.children=i;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];o.children=l}if(t&&t.defaultProps)for(r in c=t.defaultProps)void 0===o[r]&&(o[r]=c[r]);return{$$typeof:e,type:t,key:a,ref:s,props:o,_owner:T.current}}function x(t){return"object"==typeof t&&null!==t&&t.$$typeof===e}var P=/\/+/g;function _(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function R(n,i,r,o,a){var s=typeof n;"undefined"!==s&&"boolean"!==s||(n=null);var c=!1;if(null===n)c=!0;else switch(s){case"string":case"number":c=!0;break;case"object":switch(n.$$typeof){case e:case t:c=!0}}if(c)return a=a(c=n),n=""===o?"."+_(c,0):o,S(a)?(r="",null!=n&&(r=n.replace(P,"$&/")+"/"),R(a,i,r,"",function(e){return e})):null!=a&&(x(a)&&(a=function(t,n){return{$$typeof:e,type:t.type,key:n,ref:t.ref,props:t.props,_owner:t._owner}}(a,r+(!a.key||c&&c.key===a.key?"":(""+a.key).replace(P,"$&/")+"/")+n)),i.push(a)),1;if(c=0,o=""===o?".":o+":",S(n))for(var l=0;l<n.length;l++){var u=o+_(s=n[l],l);c+=R(s,i,r,u,a)}else if(u=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=p&&e[p]||e["@@iterator"])?e:null}(n),"function"==typeof u)for(n=u.call(n),l=0;!(s=n.next()).done;)c+=R(s=s.value,i,r,u=o+_(s,l++),a);else if("object"===s)throw i=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===i?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.");return c}function I(e,t,n){if(null==e)return e;var i=[],r=0;return R(e,i,"","",function(e){return t.call(n,e,r++)}),i}function N(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var O={current:null},M={transition:null},D={ReactCurrentDispatcher:O,ReactCurrentBatchConfig:M,ReactCurrentOwner:T};function L(){throw Error("act(...) is not supported in production builds of React.")}return s.Children={map:I,forEach:function(e,t,n){I(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return I(e,function(){t++}),t},toArray:function(e){return I(e,function(e){return e})||[]},only:function(e){if(!x(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},s.Component=v,s.Fragment=n,s.Profiler=o,s.PureComponent=b,s.StrictMode=i,s.Suspense=u,s.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,s.act=L,s.cloneElement=function(t,n,i){if(null==t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var r=m({},t.props),o=t.key,a=t.ref,s=t._owner;if(null!=n){if(void 0!==n.ref&&(a=n.ref,s=T.current),void 0!==n.key&&(o=""+n.key),t.type&&t.type.defaultProps)var c=t.type.defaultProps;for(l in n)C.call(n,l)&&!w.hasOwnProperty(l)&&(r[l]=void 0===n[l]&&void 0!==c?c[l]:n[l])}var l=arguments.length-2;if(1===l)r.children=i;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];r.children=c}return{$$typeof:e,type:t.type,key:o,ref:a,props:r,_owner:s}},s.createContext=function(e){return(e={$$typeof:c,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},s.createElement=E,s.createFactory=function(e){var t=E.bind(null,e);return t.type=e,t},s.createRef=function(){return{current:null}},s.forwardRef=function(e){return{$$typeof:l,render:e}},s.isValidElement=x,s.lazy=function(e){return{$$typeof:h,_payload:{_status:-1,_result:e},_init:N}},s.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},s.startTransition=function(e){var t=M.transition;M.transition={};try{e()}finally{M.transition=t}},s.unstable_act=L,s.useCallback=function(e,t){return O.current.useCallback(e,t)},s.useContext=function(e){return O.current.useContext(e)},s.useDebugValue=function(){},s.useDeferredValue=function(e){return O.current.useDeferredValue(e)},s.useEffect=function(e,t){return O.current.useEffect(e,t)},s.useId=function(){return O.current.useId()},s.useImperativeHandle=function(e,t,n){return O.current.useImperativeHandle(e,t,n)},s.useInsertionEffect=function(e,t){return O.current.useInsertionEffect(e,t)},s.useLayoutEffect=function(e,t){return O.current.useLayoutEffect(e,t)},s.useMemo=function(e,t){return O.current.useMemo(e,t)},s.useReducer=function(e,t,n){return O.current.useReducer(e,t,n)},s.useRef=function(e){return O.current.useRef(e)},s.useState=function(e){return O.current.useState(e)},s.useSyncExternalStore=function(e,t,n){return O.current.useSyncExternalStore(e,t,n)},s.useTransition=function(){return O.current.useTransition()},s.version="18.3.1",s}function l(){return o||(o=1,a.exports=c()),a.exports}var u=l();const d=i(u);var h,p,f,m,g,v={},y={exports:{}},b={},k={exports:{}},S={};function C(){return p||(p=1,k.exports=(h||(h=1,function(e){function t(e,t){var n=e.length;e.push(t);e:for(;0<n;){var i=n-1>>>1,o=e[i];if(!(0<r(o,t)))break e;e[i]=t,e[n]=o,n=i}}function n(e){return 0===e.length?null:e[0]}function i(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var i=0,o=e.length,a=o>>>1;i<a;){var s=2*(i+1)-1,c=e[s],l=s+1,u=e[l];if(0>r(c,n))l<o&&0>r(u,c)?(e[i]=u,e[l]=n,i=l):(e[i]=c,e[s]=n,i=s);else{if(!(l<o&&0>r(u,n)))break e;e[i]=u,e[l]=n,i=l}}}return t}function r(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,s=a.now();e.unstable_now=function(){return a.now()-s}}var c=[],l=[],u=1,d=null,h=3,p=!1,f=!1,m=!1,g="function"==typeof setTimeout?setTimeout:null,v="function"==typeof clearTimeout?clearTimeout:null,y="undefined"!=typeof setImmediate?setImmediate:null;function b(e){for(var r=n(l);null!==r;){if(null===r.callback)i(l);else{if(!(r.startTime<=e))break;i(l),r.sortIndex=r.expirationTime,t(c,r)}r=n(l)}}function k(e){if(m=!1,b(e),!f)if(null!==n(c))f=!0,O(S);else{var t=n(l);null!==t&&M(k,t.startTime-e)}}function S(t,r){f=!1,m&&(m=!1,v(E),E=-1),p=!0;var o=h;try{for(b(r),d=n(c);null!==d&&(!(d.expirationTime>r)||t&&!_());){var a=d.callback;if("function"==typeof a){d.callback=null,h=d.priorityLevel;var s=a(d.expirationTime<=r);r=e.unstable_now(),"function"==typeof s?d.callback=s:d===n(c)&&i(c),b(r)}else i(c);d=n(c)}if(null!==d)var u=!0;else{var g=n(l);null!==g&&M(k,g.startTime-r),u=!1}return u}finally{d=null,h=o,p=!1}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var C,T=!1,w=null,E=-1,x=5,P=-1;function _(){return!(e.unstable_now()-P<x)}function R(){if(null!==w){var t=e.unstable_now();P=t;var n=!0;try{n=w(!0,t)}finally{n?C():(T=!1,w=null)}}else T=!1}if("function"==typeof y)C=function(){y(R)};else if("undefined"!=typeof MessageChannel){var I=new MessageChannel,N=I.port2;I.port1.onmessage=R,C=function(){N.postMessage(null)}}else C=function(){g(R,0)};function O(e){w=e,T||(T=!0,C())}function M(t,n){E=g(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){f||p||(f=!0,O(S))},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):x=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(e){switch(h){case 1:case 2:case 3:var t=3;break;default:t=h}var n=h;h=t;try{return e()}finally{h=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=h;h=e;try{return t()}finally{h=n}},e.unstable_scheduleCallback=function(i,r,o){var a=e.unstable_now();switch(o="object"==typeof o&&null!==o&&"number"==typeof(o=o.delay)&&0<o?a+o:a,i){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return i={id:u++,callback:r,priorityLevel:i,startTime:o,expirationTime:s=o+s,sortIndex:-1},o>a?(i.sortIndex=o,t(l,i),null===n(c)&&i===n(l)&&(m?(v(E),E=-1):m=!0,M(k,o-a))):(i.sortIndex=s,t(c,i),f||p||(f=!0,O(S))),i},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}}(S)),S)),k.exports}
3
3
  /**
4
4
  * @license React
5
5
  * react-dom.production.min.js
@@ -8,4 +8,23 @@ var BrainbaseChat=function(e){"use strict";var t=Object.defineProperty,n=(e,n,r)
8
8
  *
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
- */function S(){if(h)return b;h=1;var e=s(),t=w();function n(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,l={};function o(e,t){a(e,t),a(e+"Capture",t)}function a(e,t){for(l[e]=t,e=0;e<t.length;e++)r.add(t[e])}var i=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),u=Object.prototype.hasOwnProperty,c=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},d={};function p(e,t,n,r,l,o,a){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var m={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){m[e]=new p(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];m[t]=new p(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){m[e]=new p(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){m[e]=new p(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){m[e]=new p(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){m[e]=new p(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){m[e]=new p(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){m[e]=new p(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){m[e]=new p(e,5,!1,e.toLowerCase(),null,!1,!1)});var g=/[\-:]([a-z])/g;function y(e){return e[1].toUpperCase()}function v(e,t,n,r){var l=m.hasOwnProperty(t)?m[t]:null;(null!==l?0!==l.type:r||!(2<t.length)||"o"!==t[0]&&"O"!==t[0]||"n"!==t[1]&&"N"!==t[1])&&(function(e,t,n,r){if(null==t||function(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==n?!n.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}(t,n,l,r)&&(n=null),r||null===l?function(e){return!!u.call(d,e)||!u.call(f,e)&&(c.test(e)?d[e]=!0:(f[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):l.mustUseProperty?e[l.propertyName]=null===n?3!==l.type&&"":n:(t=l.attributeName,r=l.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(l=l.type)||4===l&&!0===n?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(g,y);m[t]=new p(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){m[e]=new p(e,1,!1,e.toLowerCase(),null,!1,!1)}),m.xlinkHref=new p("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){m[e]=new p(e,1,!1,e.toLowerCase(),null,!0,!0)});var k=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,x=Symbol.for("react.element"),S=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),N=Symbol.for("react.provider"),P=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),j=Symbol.for("react.offscreen"),D=Symbol.iterator;function O(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=D&&e[D]||e["@@iterator"])?e:null}var R,F=Object.assign;function A(e){if(void 0===R)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);R=t&&t[1]||""}return"\n"+R+e}var U=!1;function B(e,t){if(!e||U)return"";U=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(s){var r=s}Reflect.construct(e,[],t)}else{try{t.call()}catch(s){r=s}e.call(t.prototype)}else{try{throw Error()}catch(s){r=s}e()}}catch(s){if(s&&r&&"string"==typeof s.stack){for(var l=s.stack.split("\n"),o=r.stack.split("\n"),a=l.length-1,i=o.length-1;1<=a&&0<=i&&l[a]!==o[i];)i--;for(;1<=a&&0<=i;a--,i--)if(l[a]!==o[i]){if(1!==a||1!==i)do{if(a--,0>--i||l[a]!==o[i]){var u="\n"+l[a].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}}while(1<=a&&0<=i);break}}}finally{U=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?A(e):""}function H(e){switch(e.tag){case 5:return A(e.type);case 16:return A("Lazy");case 13:return A("Suspense");case 19:return A("SuspenseList");case 0:case 2:case 15:return e=B(e.type,!1);case 11:return e=B(e.type.render,!1);case 1:return e=B(e.type,!0);default:return""}}function V(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case _:return"Fragment";case S:return"Portal";case E:return"Profiler";case C:return"StrictMode";case T:return"Suspense";case L:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case P:return(e.displayName||"Context")+".Consumer";case N:return(e._context.displayName||"Context")+".Provider";case I:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case z:return null!==(t=e.displayName||null)?t:V(e.type)||"Memo";case M:t=e._payload,e=e._init;try{return V(e(t))}catch(n){}}return null}function $(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return V(t);case 8:return t===C?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t}return null}function W(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function q(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function Q(e){e._valueTracker||(e._valueTracker=function(e){var t=q(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(e){r=""+e,o.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function K(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=q(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function Y(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function X(e,t){var n=t.checked;return F({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function Z(e,t){var n=null==t.defaultValue?"":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=W(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function J(e,t){null!=(t=t.checked)&&v(e,"checked",t,!1)}function G(e,t){J(e,t);var n=W(t.value),r=t.type;if(null!=n)"number"===r?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===r||"reset"===r)return void e.removeAttribute("value");t.hasOwnProperty("value")?te(e,t.type,n):t.hasOwnProperty("defaultValue")&&te(e,t.type,W(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function ee(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!("submit"!==r&&"reset"!==r||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function te(e,t,n){"number"===t&&Y(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ne=Array.isArray;function re(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l<n.length;l++)t["$"+n[l]]=!0;for(n=0;n<e.length;n++)l=t.hasOwnProperty("$"+e[n].value),e[n].selected!==l&&(e[n].selected=l),l&&r&&(e[n].defaultSelected=!0)}else{for(n=""+W(n),t=null,l=0;l<e.length;l++){if(e[l].value===n)return e[l].selected=!0,void(r&&(e[l].defaultSelected=!0));null!==t||e[l].disabled||(t=e[l])}null!==t&&(t.selected=!0)}}function le(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(n(91));return F({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function oe(e,t){var r=t.value;if(null==r){if(r=t.children,t=t.defaultValue,null!=r){if(null!=t)throw Error(n(92));if(ne(r)){if(1<r.length)throw Error(n(93));r=r[0]}t=r}null==t&&(t=""),r=t}e._wrapperState={initialValue:W(r)}}function ae(e,t){var n=W(t.value),r=W(t.defaultValue);null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=""+r)}function ie(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}function ue(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function se(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?ue(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var ce,fe,de=(fe=function(e,t){if("http://www.w3.org/2000/svg"!==e.namespaceURI||"innerHTML"in e)e.innerHTML=t;else{for((ce=ce||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ce.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction(function(){return fe(e,t)})}:fe);function pe(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var he={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},me=["Webkit","ms","Moz","O"];function ge(e,t,n){return null==t||"boolean"==typeof t||""===t?"":n||"number"!=typeof t||0===t||he.hasOwnProperty(e)&&he[e]?(""+t).trim():t+"px"}function ye(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),l=ge(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}Object.keys(he).forEach(function(e){me.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),he[t]=he[e]})});var ve=F({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function be(e,t){if(t){if(ve[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(n(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(n(60));if("object"!=typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(n(61))}if(null!=t.style&&"object"!=typeof t.style)throw Error(n(62))}}function ke(e,t){if(-1===e.indexOf("-"))return"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var xe=null;function we(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Se=null,_e=null,Ce=null;function Ee(e){if(e=kl(e)){if("function"!=typeof Se)throw Error(n(280));var t=e.stateNode;t&&(t=wl(t),Se(e.stateNode,e.type,t))}}function Ne(e){_e?Ce?Ce.push(e):Ce=[e]:_e=e}function Pe(){if(_e){var e=_e,t=Ce;if(Ce=_e=null,Ee(e),t)for(e=0;e<t.length;e++)Ee(t[e])}}function Ie(e,t){return e(t)}function Te(){}var Le=!1;function ze(e,t,n){if(Le)return e(t,n);Le=!0;try{return Ie(e,t,n)}finally{Le=!1,(null!==_e||null!==Ce)&&(Te(),Pe())}}function Me(e,t){var r=e.stateNode;if(null===r)return null;var l=wl(r);if(null===l)return null;r=l[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(l=!l.disabled)||(l=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!l;break e;default:e=!1}if(e)return null;if(r&&"function"!=typeof r)throw Error(n(231,t,typeof r));return r}var je=!1;if(i)try{var De={};Object.defineProperty(De,"passive",{get:function(){je=!0}}),window.addEventListener("test",De,De),window.removeEventListener("test",De,De)}catch(fe){je=!1}function Oe(e,t,n,r,l,o,a,i,u){var s=Array.prototype.slice.call(arguments,3);try{t.apply(n,s)}catch(c){this.onError(c)}}var Re=!1,Fe=null,Ae=!1,Ue=null,Be={onError:function(e){Re=!0,Fe=e}};function He(e,t,n,r,l,o,a,i,u){Re=!1,Fe=null,Oe.apply(Be,arguments)}function Ve(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function $e(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function We(e){if(Ve(e)!==e)throw Error(n(188))}function qe(e){return null!==(e=function(e){var t=e.alternate;if(!t){if(null===(t=Ve(e)))throw Error(n(188));return t!==e?null:e}for(var r=e,l=t;;){var o=r.return;if(null===o)break;var a=o.alternate;if(null===a){if(null!==(l=o.return)){r=l;continue}break}if(o.child===a.child){for(a=o.child;a;){if(a===r)return We(o),e;if(a===l)return We(o),t;a=a.sibling}throw Error(n(188))}if(r.return!==l.return)r=o,l=a;else{for(var i=!1,u=o.child;u;){if(u===r){i=!0,r=o,l=a;break}if(u===l){i=!0,l=o,r=a;break}u=u.sibling}if(!i){for(u=a.child;u;){if(u===r){i=!0,r=a,l=o;break}if(u===l){i=!0,l=a,r=o;break}u=u.sibling}if(!i)throw Error(n(189))}}if(r.alternate!==l)throw Error(n(190))}if(3!==r.tag)throw Error(n(188));return r.stateNode.current===r?e:t}(e))?Qe(e):null}function Qe(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){var t=Qe(e);if(null!==t)return t;e=e.sibling}return null}var Ke=t.unstable_scheduleCallback,Ye=t.unstable_cancelCallback,Xe=t.unstable_shouldYield,Ze=t.unstable_requestPaint,Je=t.unstable_now,Ge=t.unstable_getCurrentPriorityLevel,et=t.unstable_ImmediatePriority,tt=t.unstable_UserBlockingPriority,nt=t.unstable_NormalPriority,rt=t.unstable_LowPriority,lt=t.unstable_IdlePriority,ot=null,at=null;var it=Math.clz32?Math.clz32:function(e){return e>>>=0,0===e?32:31-(ut(e)/st|0)|0},ut=Math.log,st=Math.LN2;var ct=64,ft=4194304;function dt(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function pt(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,a=268435455&n;if(0!==a){var i=a&~l;0!==i?r=dt(i):0!==(o&=a)&&(r=dt(o))}else 0!==(a=n&~l)?r=dt(a):0!==o&&(r=dt(o));if(0===r)return 0;if(0!==t&&t!==r&&0===(t&l)&&((l=r&-r)>=(o=t&-t)||16===l&&4194240&o))return t;if(4&r&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0<t;)l=1<<(n=31-it(t)),r|=e[n],t&=~l;return r}function ht(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function mt(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function gt(){var e=ct;return!(4194240&(ct<<=1))&&(ct=64),e}function yt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function vt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-it(t)]=n}function bt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-it(n),l=1<<r;l&t|e[r]&t&&(e[r]|=t),n&=~l}}var kt=0;function xt(e){return 1<(e&=-e)?4<e?268435455&e?16:536870912:4:1}var wt,St,_t,Ct,Et,Nt=!1,Pt=[],It=null,Tt=null,Lt=null,zt=new Map,Mt=new Map,jt=[],Dt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Ot(e,t){switch(e){case"focusin":case"focusout":It=null;break;case"dragenter":case"dragleave":Tt=null;break;case"mouseover":case"mouseout":Lt=null;break;case"pointerover":case"pointerout":zt.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mt.delete(t.pointerId)}}function Rt(e,t,n,r,l,o){return null===e||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[l]},null!==t&&(null!==(t=kl(t))&&St(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==l&&-1===t.indexOf(l)&&t.push(l),e)}function Ft(e){var t=bl(e.target);if(null!==t){var n=Ve(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=$e(n)))return e.blockedOn=t,void Et(e.priority,function(){_t(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function At(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Xt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==n)return null!==(t=kl(n))&&St(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);xe=r,n.target.dispatchEvent(r),xe=null,t.shift()}return!0}function Ut(e,t,n){At(e)&&n.delete(t)}function Bt(){Nt=!1,null!==It&&At(It)&&(It=null),null!==Tt&&At(Tt)&&(Tt=null),null!==Lt&&At(Lt)&&(Lt=null),zt.forEach(Ut),Mt.forEach(Ut)}function Ht(e,n){e.blockedOn===n&&(e.blockedOn=null,Nt||(Nt=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Bt)))}function Vt(e){function t(t){return Ht(t,e)}if(0<Pt.length){Ht(Pt[0],e);for(var n=1;n<Pt.length;n++){var r=Pt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==It&&Ht(It,e),null!==Tt&&Ht(Tt,e),null!==Lt&&Ht(Lt,e),zt.forEach(t),Mt.forEach(t),n=0;n<jt.length;n++)(r=jt[n]).blockedOn===e&&(r.blockedOn=null);for(;0<jt.length&&null===(n=jt[0]).blockedOn;)Ft(n),null===n.blockedOn&&jt.shift()}var $t=k.ReactCurrentBatchConfig,Wt=!0;function qt(e,t,n,r){var l=kt,o=$t.transition;$t.transition=null;try{kt=1,Kt(e,t,n,r)}finally{kt=l,$t.transition=o}}function Qt(e,t,n,r){var l=kt,o=$t.transition;$t.transition=null;try{kt=4,Kt(e,t,n,r)}finally{kt=l,$t.transition=o}}function Kt(e,t,n,r){if(Wt){var l=Xt(e,t,n,r);if(null===l)Wr(e,t,r,Yt,n),Ot(e,r);else if(function(e,t,n,r,l){switch(t){case"focusin":return It=Rt(It,e,t,n,r,l),!0;case"dragenter":return Tt=Rt(Tt,e,t,n,r,l),!0;case"mouseover":return Lt=Rt(Lt,e,t,n,r,l),!0;case"pointerover":var o=l.pointerId;return zt.set(o,Rt(zt.get(o)||null,e,t,n,r,l)),!0;case"gotpointercapture":return o=l.pointerId,Mt.set(o,Rt(Mt.get(o)||null,e,t,n,r,l)),!0}return!1}(l,e,t,n,r))r.stopPropagation();else if(Ot(e,r),4&t&&-1<Dt.indexOf(e)){for(;null!==l;){var o=kl(l);if(null!==o&&wt(o),null===(o=Xt(e,t,n,r))&&Wr(e,t,r,Yt,n),o===l)break;l=o}null!==l&&r.stopPropagation()}else Wr(e,t,r,null,n)}}var Yt=null;function Xt(e,t,n,r){if(Yt=null,null!==(e=bl(e=we(r))))if(null===(t=Ve(e)))e=null;else if(13===(n=t.tag)){if(null!==(e=$e(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Yt=e,null}function Zt(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ge()){case et:return 1;case tt:return 4;case nt:case rt:return 16;case lt:return 536870912;default:return 16}default:return 16}}var Jt=null,Gt=null,en=null;function tn(){if(en)return en;var e,t,n=Gt,r=n.length,l="value"in Jt?Jt.value:Jt.textContent,o=l.length;for(e=0;e<r&&n[e]===l[e];e++);var a=r-e;for(t=1;t<=a&&n[r-t]===l[o-t];t++);return en=l.slice(e,1<t?1-t:void 0)}function nn(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function rn(){return!0}function ln(){return!1}function on(e){function t(t,n,r,l,o){for(var a in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=l,this.target=o,this.currentTarget=null,e)e.hasOwnProperty(a)&&(t=e[a],this[a]=t?t(l):l[a]);return this.isDefaultPrevented=(null!=l.defaultPrevented?l.defaultPrevented:!1===l.returnValue)?rn:ln,this.isPropagationStopped=ln,this}return F(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=rn)},persist:function(){},isPersistent:rn}),t}var an,un,sn,cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fn=on(cn),dn=F({},cn,{view:0,detail:0}),pn=on(dn),hn=F({},dn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:En,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==sn&&(sn&&"mousemove"===e.type?(an=e.screenX-sn.screenX,un=e.screenY-sn.screenY):un=an=0,sn=e),an)},movementY:function(e){return"movementY"in e?e.movementY:un}}),mn=on(hn),gn=on(F({},hn,{dataTransfer:0})),yn=on(F({},dn,{relatedTarget:0})),vn=on(F({},cn,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=F({},cn,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),kn=on(bn),xn=on(F({},cn,{data:0})),wn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Sn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},_n={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Cn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=_n[e])&&!!t[e]}function En(){return Cn}var Nn=F({},dn,{key:function(e){if(e.key){var t=wn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=nn(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?Sn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:En,charCode:function(e){return"keypress"===e.type?nn(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?nn(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Pn=on(Nn),In=on(F({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Tn=on(F({},dn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:En})),Ln=on(F({},cn,{propertyName:0,elapsedTime:0,pseudoElement:0})),zn=F({},hn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Mn=on(zn),jn=[9,13,27,32],Dn=i&&"CompositionEvent"in window,On=null;i&&"documentMode"in document&&(On=document.documentMode);var Rn=i&&"TextEvent"in window&&!On,Fn=i&&(!Dn||On&&8<On&&11>=On),An=String.fromCharCode(32),Un=!1;function Bn(e,t){switch(e){case"keyup":return-1!==jn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Hn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var Vn=!1;var $n={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!$n[e.type]:"textarea"===t}function qn(e,t,n,r){Ne(r),0<(t=Qr(t,"onChange")).length&&(n=new fn("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Qn=null,Kn=null;function Yn(e){Ar(e,0)}function Xn(e){if(K(xl(e)))return e}function Zn(e,t){if("change"===e)return t}var Jn=!1;if(i){var Gn;if(i){var er="oninput"in document;if(!er){var tr=document.createElement("div");tr.setAttribute("oninput","return;"),er="function"==typeof tr.oninput}Gn=er}else Gn=!1;Jn=Gn&&(!document.documentMode||9<document.documentMode)}function nr(){Qn&&(Qn.detachEvent("onpropertychange",rr),Kn=Qn=null)}function rr(e){if("value"===e.propertyName&&Xn(Kn)){var t=[];qn(t,Kn,e,we(e)),ze(Yn,t)}}function lr(e,t,n){"focusin"===e?(nr(),Kn=n,(Qn=t).attachEvent("onpropertychange",rr)):"focusout"===e&&nr()}function or(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Xn(Kn)}function ar(e,t){if("click"===e)return Xn(t)}function ir(e,t){if("input"===e||"change"===e)return Xn(t)}var ur="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function sr(e,t){if(ur(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var l=n[r];if(!u.call(t,l)||!ur(e[l],t[l]))return!1}return!0}function cr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fr(e,t){var n,r=cr(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=cr(r)}}function dr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?dr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function pr(){for(var e=window,t=Y();t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=Y((e=t.contentWindow).document)}return t}function hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function mr(e){var t=pr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&dr(n.ownerDocument.documentElement,n)){if(null!==r&&hr(n))if(t=r.start,void 0===(e=r.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=void 0===r.end?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=fr(n,o);var a=fr(n,r);l&&a&&(1!==e.rangeCount||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&((t=t.createRange()).setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"==typeof n.focus&&n.focus(),n=0;n<t.length;n++)(e=t[n]).element.scrollLeft=e.left,e.element.scrollTop=e.top}}var gr=i&&"documentMode"in document&&11>=document.documentMode,yr=null,vr=null,br=null,kr=!1;function xr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;kr||null==yr||yr!==Y(r)||("selectionStart"in(r=yr)&&hr(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},br&&sr(br,r)||(br=r,0<(r=Qr(vr,"onSelect")).length&&(t=new fn("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=yr)))}function wr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Sr={animationend:wr("Animation","AnimationEnd"),animationiteration:wr("Animation","AnimationIteration"),animationstart:wr("Animation","AnimationStart"),transitionend:wr("Transition","TransitionEnd")},_r={},Cr={};function Er(e){if(_r[e])return _r[e];if(!Sr[e])return e;var t,n=Sr[e];for(t in n)if(n.hasOwnProperty(t)&&t in Cr)return _r[e]=n[t];return e}i&&(Cr=document.createElement("div").style,"AnimationEvent"in window||(delete Sr.animationend.animation,delete Sr.animationiteration.animation,delete Sr.animationstart.animation),"TransitionEvent"in window||delete Sr.transitionend.transition);var Nr=Er("animationend"),Pr=Er("animationiteration"),Ir=Er("animationstart"),Tr=Er("transitionend"),Lr=new Map,zr="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Mr(e,t){Lr.set(e,t),o(t,[e])}for(var jr=0;jr<zr.length;jr++){var Dr=zr[jr];Mr(Dr.toLowerCase(),"on"+(Dr[0].toUpperCase()+Dr.slice(1)))}Mr(Nr,"onAnimationEnd"),Mr(Pr,"onAnimationIteration"),Mr(Ir,"onAnimationStart"),Mr("dblclick","onDoubleClick"),Mr("focusin","onFocus"),Mr("focusout","onBlur"),Mr(Tr,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Or="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Rr=new Set("cancel close invalid load scroll toggle".split(" ").concat(Or));function Fr(e,t,r){var l=e.type||"unknown-event";e.currentTarget=r,function(e,t,r,l,o,a,i,u,s){if(He.apply(this,arguments),Re){if(!Re)throw Error(n(198));var c=Fe;Re=!1,Fe=null,Ae||(Ae=!0,Ue=c)}}(l,t,void 0,e),e.currentTarget=null}function Ar(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var r=e[n],l=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var a=r.length-1;0<=a;a--){var i=r[a],u=i.instance,s=i.currentTarget;if(i=i.listener,u!==o&&l.isPropagationStopped())break e;Fr(l,i,s),o=u}else for(a=0;a<r.length;a++){if(u=(i=r[a]).instance,s=i.currentTarget,i=i.listener,u!==o&&l.isPropagationStopped())break e;Fr(l,i,s),o=u}}}if(Ae)throw e=Ue,Ae=!1,Ue=null,e}function Ur(e,t){var n=t[gl];void 0===n&&(n=t[gl]=new Set);var r=e+"__bubble";n.has(r)||($r(t,e,2,!1),n.add(r))}function Br(e,t,n){var r=0;t&&(r|=4),$r(n,e,r,t)}var Hr="_reactListening"+Math.random().toString(36).slice(2);function Vr(e){if(!e[Hr]){e[Hr]=!0,r.forEach(function(t){"selectionchange"!==t&&(Rr.has(t)||Br(t,!1,e),Br(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Hr]||(t[Hr]=!0,Br("selectionchange",!1,t))}}function $r(e,t,n,r){switch(Zt(t)){case 1:var l=qt;break;case 4:l=Qt;break;default:l=Kt}n=l.bind(null,t,n,e),l=void 0,!je||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(l=!0),r?void 0!==l?e.addEventListener(t,n,{capture:!0,passive:l}):e.addEventListener(t,n,!0):void 0!==l?e.addEventListener(t,n,{passive:l}):e.addEventListener(t,n,!1)}function Wr(e,t,n,r,l){var o=r;if(!(1&t||2&t||null===r))e:for(;;){if(null===r)return;var a=r.tag;if(3===a||4===a){var i=r.stateNode.containerInfo;if(i===l||8===i.nodeType&&i.parentNode===l)break;if(4===a)for(a=r.return;null!==a;){var u=a.tag;if((3===u||4===u)&&((u=a.stateNode.containerInfo)===l||8===u.nodeType&&u.parentNode===l))return;a=a.return}for(;null!==i;){if(null===(a=bl(i)))return;if(5===(u=a.tag)||6===u){r=o=a;continue e}i=i.parentNode}}r=r.return}ze(function(){var r=o,l=we(n),a=[];e:{var i=Lr.get(e);if(void 0!==i){var u=fn,s=e;switch(e){case"keypress":if(0===nn(n))break e;case"keydown":case"keyup":u=Pn;break;case"focusin":s="focus",u=yn;break;case"focusout":s="blur",u=yn;break;case"beforeblur":case"afterblur":u=yn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":u=mn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":u=gn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":u=Tn;break;case Nr:case Pr:case Ir:u=vn;break;case Tr:u=Ln;break;case"scroll":u=pn;break;case"wheel":u=Mn;break;case"copy":case"cut":case"paste":u=kn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":u=In}var c=!!(4&t),f=!c&&"scroll"===e,d=c?null!==i?i+"Capture":null:i;c=[];for(var p,h=r;null!==h;){var m=(p=h).stateNode;if(5===p.tag&&null!==m&&(p=m,null!==d&&(null!=(m=Me(h,d))&&c.push(qr(h,m,p)))),f)break;h=h.return}0<c.length&&(i=new u(i,s,null,n,l),a.push({event:i,listeners:c}))}}if(!(7&t)){if(u="mouseout"===e||"pointerout"===e,(!(i="mouseover"===e||"pointerover"===e)||n===xe||!(s=n.relatedTarget||n.fromElement)||!bl(s)&&!s[ml])&&(u||i)&&(i=l.window===l?l:(i=l.ownerDocument)?i.defaultView||i.parentWindow:window,u?(u=r,null!==(s=(s=n.relatedTarget||n.toElement)?bl(s):null)&&(s!==(f=Ve(s))||5!==s.tag&&6!==s.tag)&&(s=null)):(u=null,s=r),u!==s)){if(c=mn,m="onMouseLeave",d="onMouseEnter",h="mouse","pointerout"!==e&&"pointerover"!==e||(c=In,m="onPointerLeave",d="onPointerEnter",h="pointer"),f=null==u?i:xl(u),p=null==s?i:xl(s),(i=new c(m,h+"leave",u,n,l)).target=f,i.relatedTarget=p,m=null,bl(l)===r&&((c=new c(d,h+"enter",s,n,l)).target=p,c.relatedTarget=f,m=c),f=m,u&&s)e:{for(d=s,h=0,p=c=u;p;p=Kr(p))h++;for(p=0,m=d;m;m=Kr(m))p++;for(;0<h-p;)c=Kr(c),h--;for(;0<p-h;)d=Kr(d),p--;for(;h--;){if(c===d||null!==d&&c===d.alternate)break e;c=Kr(c),d=Kr(d)}c=null}else c=null;null!==u&&Yr(a,i,u,c,!1),null!==s&&null!==f&&Yr(a,f,s,c,!0)}if("select"===(u=(i=r?xl(r):window).nodeName&&i.nodeName.toLowerCase())||"input"===u&&"file"===i.type)var g=Zn;else if(Wn(i))if(Jn)g=ir;else{g=or;var y=lr}else(u=i.nodeName)&&"input"===u.toLowerCase()&&("checkbox"===i.type||"radio"===i.type)&&(g=ar);switch(g&&(g=g(e,r))?qn(a,g,n,l):(y&&y(e,i,r),"focusout"===e&&(y=i._wrapperState)&&y.controlled&&"number"===i.type&&te(i,"number",i.value)),y=r?xl(r):window,e){case"focusin":(Wn(y)||"true"===y.contentEditable)&&(yr=y,vr=r,br=null);break;case"focusout":br=vr=yr=null;break;case"mousedown":kr=!0;break;case"contextmenu":case"mouseup":case"dragend":kr=!1,xr(a,n,l);break;case"selectionchange":if(gr)break;case"keydown":case"keyup":xr(a,n,l)}var v;if(Dn)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else Vn?Bn(e,n)&&(b="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(b="onCompositionStart");b&&(Fn&&"ko"!==n.locale&&(Vn||"onCompositionStart"!==b?"onCompositionEnd"===b&&Vn&&(v=tn()):(Gt="value"in(Jt=l)?Jt.value:Jt.textContent,Vn=!0)),0<(y=Qr(r,b)).length&&(b=new xn(b,e,null,n,l),a.push({event:b,listeners:y}),v?b.data=v:null!==(v=Hn(n))&&(b.data=v))),(v=Rn?function(e,t){switch(e){case"compositionend":return Hn(t);case"keypress":return 32!==t.which?null:(Un=!0,An);case"textInput":return(e=t.data)===An&&Un?null:e;default:return null}}(e,n):function(e,t){if(Vn)return"compositionend"===e||!Dn&&Bn(e,t)?(e=tn(),en=Gt=Jt=null,Vn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Fn&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(r=Qr(r,"onBeforeInput")).length&&(l=new xn("onBeforeInput","beforeinput",null,n,l),a.push({event:l,listeners:r}),l.data=v))}Ar(a,t)})}function qr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Qr(e,t){for(var n=t+"Capture",r=[];null!==e;){var l=e,o=l.stateNode;5===l.tag&&null!==o&&(l=o,null!=(o=Me(e,n))&&r.unshift(qr(e,o,l)),null!=(o=Me(e,t))&&r.push(qr(e,o,l))),e=e.return}return r}function Kr(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function Yr(e,t,n,r,l){for(var o=t._reactName,a=[];null!==n&&n!==r;){var i=n,u=i.alternate,s=i.stateNode;if(null!==u&&u===r)break;5===i.tag&&null!==s&&(i=s,l?null!=(u=Me(n,o))&&a.unshift(qr(n,u,i)):l||null!=(u=Me(n,o))&&a.push(qr(n,u,i))),n=n.return}0!==a.length&&e.push({event:t,listeners:a})}var Xr=/\r\n?/g,Zr=/\u0000|\uFFFD/g;function Jr(e){return("string"==typeof e?e:""+e).replace(Xr,"\n").replace(Zr,"")}function Gr(e,t,r){if(t=Jr(t),Jr(e)!==t&&r)throw Error(n(425))}function el(){}var tl=null,nl=null;function rl(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var ll="function"==typeof setTimeout?setTimeout:void 0,ol="function"==typeof clearTimeout?clearTimeout:void 0,al="function"==typeof Promise?Promise:void 0,il="function"==typeof queueMicrotask?queueMicrotask:void 0!==al?function(e){return al.resolve(null).then(e).catch(ul)}:ll;function ul(e){setTimeout(function(){throw e})}function sl(e,t){var n=t,r=0;do{var l=n.nextSibling;if(e.removeChild(n),l&&8===l.nodeType)if("/$"===(n=l.data)){if(0===r)return e.removeChild(l),void Vt(t);r--}else"$"!==n&&"$?"!==n&&"$!"!==n||r++;n=l}while(n);Vt(t)}function cl(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t)break;if("/$"===t)return null}}return e}function fl(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}var dl=Math.random().toString(36).slice(2),pl="__reactFiber$"+dl,hl="__reactProps$"+dl,ml="__reactContainer$"+dl,gl="__reactEvents$"+dl,yl="__reactListeners$"+dl,vl="__reactHandles$"+dl;function bl(e){var t=e[pl];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ml]||n[pl]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=fl(e);null!==e;){if(n=e[pl])return n;e=fl(e)}return t}n=(e=n).parentNode}return null}function kl(e){return!(e=e[pl]||e[ml])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function xl(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(n(33))}function wl(e){return e[hl]||null}var Sl=[],_l=-1;function Cl(e){return{current:e}}function El(e){0>_l||(e.current=Sl[_l],Sl[_l]=null,_l--)}function Nl(e,t){_l++,Sl[_l]=e.current,e.current=t}var Pl={},Il=Cl(Pl),Tl=Cl(!1),Ll=Pl;function zl(e,t){var n=e.type.contextTypes;if(!n)return Pl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l,o={};for(l in n)o[l]=t[l];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function Ml(e){return null!=(e=e.childContextTypes)}function jl(){El(Tl),El(Il)}function Dl(e,t,r){if(Il.current!==Pl)throw Error(n(168));Nl(Il,t),Nl(Tl,r)}function Ol(e,t,r){var l=e.stateNode;if(t=t.childContextTypes,"function"!=typeof l.getChildContext)return r;for(var o in l=l.getChildContext())if(!(o in t))throw Error(n(108,$(e)||"Unknown",o));return F({},r,l)}function Rl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Pl,Ll=Il.current,Nl(Il,e),Nl(Tl,Tl.current),!0}function Fl(e,t,r){var l=e.stateNode;if(!l)throw Error(n(169));r?(e=Ol(e,t,Ll),l.__reactInternalMemoizedMergedChildContext=e,El(Tl),El(Il),Nl(Il,e)):El(Tl),Nl(Tl,r)}var Al=null,Ul=!1,Bl=!1;function Hl(e){null===Al?Al=[e]:Al.push(e)}function Vl(){if(!Bl&&null!==Al){Bl=!0;var e=0,t=kt;try{var n=Al;for(kt=1;e<n.length;e++){var r=n[e];do{r=r(!0)}while(null!==r)}Al=null,Ul=!1}catch(l){throw null!==Al&&(Al=Al.slice(e+1)),Ke(et,Vl),l}finally{kt=t,Bl=!1}}return null}var $l=[],Wl=0,ql=null,Ql=0,Kl=[],Yl=0,Xl=null,Zl=1,Jl="";function Gl(e,t){$l[Wl++]=Ql,$l[Wl++]=ql,ql=e,Ql=t}function eo(e,t,n){Kl[Yl++]=Zl,Kl[Yl++]=Jl,Kl[Yl++]=Xl,Xl=e;var r=Zl;e=Jl;var l=32-it(r)-1;r&=~(1<<l),n+=1;var o=32-it(t)+l;if(30<o){var a=l-l%5;o=(r&(1<<a)-1).toString(32),r>>=a,l-=a,Zl=1<<32-it(t)+l|n<<l|r,Jl=o+e}else Zl=1<<o|n<<l|r,Jl=e}function to(e){null!==e.return&&(Gl(e,1),eo(e,1,0))}function no(e){for(;e===ql;)ql=$l[--Wl],$l[Wl]=null,Ql=$l[--Wl],$l[Wl]=null;for(;e===Xl;)Xl=Kl[--Yl],Kl[Yl]=null,Jl=Kl[--Yl],Kl[Yl]=null,Zl=Kl[--Yl],Kl[Yl]=null}var ro=null,lo=null,oo=!1,ao=null;function io(e,t){var n=zs(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,null===(t=e.deletions)?(e.deletions=[n],e.flags|=16):t.push(n)}function uo(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,ro=e,lo=cl(t.firstChild),!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,ro=e,lo=null,!0);case 13:return null!==(t=8!==t.nodeType?null:t)&&(n=null!==Xl?{id:Zl,overflow:Jl}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},(n=zs(18,null,null,0)).stateNode=t,n.return=e,e.child=n,ro=e,lo=null,!0);default:return!1}}function so(e){return!(!(1&e.mode)||128&e.flags)}function co(e){if(oo){var t=lo;if(t){var r=t;if(!uo(e,t)){if(so(e))throw Error(n(418));t=cl(r.nextSibling);var l=ro;t&&uo(e,t)?io(l,r):(e.flags=-4097&e.flags|2,oo=!1,ro=e)}}else{if(so(e))throw Error(n(418));e.flags=-4097&e.flags|2,oo=!1,ro=e}}}function fo(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;ro=e}function po(e){if(e!==ro)return!1;if(!oo)return fo(e),oo=!0,!1;var t;if((t=3!==e.tag)&&!(t=5!==e.tag)&&(t="head"!==(t=e.type)&&"body"!==t&&!rl(e.type,e.memoizedProps)),t&&(t=lo)){if(so(e))throw ho(),Error(n(418));for(;t;)io(e,t),t=cl(t.nextSibling)}if(fo(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(n(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var r=e.data;if("/$"===r){if(0===t){lo=cl(e.nextSibling);break e}t--}else"$"!==r&&"$!"!==r&&"$?"!==r||t++}e=e.nextSibling}lo=null}}else lo=ro?cl(e.stateNode.nextSibling):null;return!0}function ho(){for(var e=lo;e;)e=cl(e.nextSibling)}function mo(){lo=ro=null,oo=!1}function go(e){null===ao?ao=[e]:ao.push(e)}var yo=k.ReactCurrentBatchConfig;function vo(e,t,r){if(null!==(e=r.ref)&&"function"!=typeof e&&"object"!=typeof e){if(r._owner){if(r=r._owner){if(1!==r.tag)throw Error(n(309));var l=r.stateNode}if(!l)throw Error(n(147,e));var o=l,a=""+e;return null!==t&&null!==t.ref&&"function"==typeof t.ref&&t.ref._stringRef===a?t.ref:((t=function(e){var t=o.refs;null===e?delete t[a]:t[a]=e})._stringRef=a,t)}if("string"!=typeof e)throw Error(n(284));if(!r._owner)throw Error(n(290,e))}return e}function bo(e,t){throw e=Object.prototype.toString.call(t),Error(n(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ko(e){return(0,e._init)(e._payload)}function xo(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function r(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function l(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function o(e,t){return(e=js(e,t)).index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=2,n):r:(t.flags|=2,n):(t.flags|=1048576,n)}function i(t){return e&&null===t.alternate&&(t.flags|=2),t}function u(e,t,n,r){return null===t||6!==t.tag?((t=Fs(n,e.mode,r)).return=e,t):((t=o(t,n)).return=e,t)}function s(e,t,n,r){var l=n.type;return l===_?f(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===l||"object"==typeof l&&null!==l&&l.$$typeof===M&&ko(l)===t.type)?((r=o(t,n.props)).ref=vo(e,t,n),r.return=e,r):((r=Ds(n.type,n.key,n.props,null,e.mode,r)).ref=vo(e,t,n),r.return=e,r)}function c(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=As(n,e.mode,r)).return=e,t):((t=o(t,n.children||[])).return=e,t)}function f(e,t,n,r,l){return null===t||7!==t.tag?((t=Os(n,e.mode,r,l)).return=e,t):((t=o(t,n)).return=e,t)}function d(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t)return(t=Fs(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case x:return(n=Ds(t.type,t.key,t.props,null,e.mode,n)).ref=vo(e,null,t),n.return=e,n;case S:return(t=As(t,e.mode,n)).return=e,t;case M:return d(e,(0,t._init)(t._payload),n)}if(ne(t)||O(t))return(t=Os(t,e.mode,n,null)).return=e,t;bo(e,t)}return null}function p(e,t,n,r){var l=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n)return null!==l?null:u(e,t,""+n,r);if("object"==typeof n&&null!==n){switch(n.$$typeof){case x:return n.key===l?s(e,t,n,r):null;case S:return n.key===l?c(e,t,n,r):null;case M:return p(e,t,(l=n._init)(n._payload),r)}if(ne(n)||O(n))return null!==l?null:f(e,t,n,r,null);bo(e,n)}return null}function h(e,t,n,r,l){if("string"==typeof r&&""!==r||"number"==typeof r)return u(t,e=e.get(n)||null,""+r,l);if("object"==typeof r&&null!==r){switch(r.$$typeof){case x:return s(t,e=e.get(null===r.key?n:r.key)||null,r,l);case S:return c(t,e=e.get(null===r.key?n:r.key)||null,r,l);case M:return h(e,t,n,(0,r._init)(r._payload),l)}if(ne(r)||O(r))return f(t,e=e.get(n)||null,r,l,null);bo(t,r)}return null}return function u(s,c,f,m){if("object"==typeof f&&null!==f&&f.type===_&&null===f.key&&(f=f.props.children),"object"==typeof f&&null!==f){switch(f.$$typeof){case x:e:{for(var g=f.key,y=c;null!==y;){if(y.key===g){if((g=f.type)===_){if(7===y.tag){r(s,y.sibling),(c=o(y,f.props.children)).return=s,s=c;break e}}else if(y.elementType===g||"object"==typeof g&&null!==g&&g.$$typeof===M&&ko(g)===y.type){r(s,y.sibling),(c=o(y,f.props)).ref=vo(s,y,f),c.return=s,s=c;break e}r(s,y);break}t(s,y),y=y.sibling}f.type===_?((c=Os(f.props.children,s.mode,m,f.key)).return=s,s=c):((m=Ds(f.type,f.key,f.props,null,s.mode,m)).ref=vo(s,c,f),m.return=s,s=m)}return i(s);case S:e:{for(y=f.key;null!==c;){if(c.key===y){if(4===c.tag&&c.stateNode.containerInfo===f.containerInfo&&c.stateNode.implementation===f.implementation){r(s,c.sibling),(c=o(c,f.children||[])).return=s,s=c;break e}r(s,c);break}t(s,c),c=c.sibling}(c=As(f,s.mode,m)).return=s,s=c}return i(s);case M:return u(s,c,(y=f._init)(f._payload),m)}if(ne(f))return function(n,o,i,u){for(var s=null,c=null,f=o,m=o=0,g=null;null!==f&&m<i.length;m++){f.index>m?(g=f,f=null):g=f.sibling;var y=p(n,f,i[m],u);if(null===y){null===f&&(f=g);break}e&&f&&null===y.alternate&&t(n,f),o=a(y,o,m),null===c?s=y:c.sibling=y,c=y,f=g}if(m===i.length)return r(n,f),oo&&Gl(n,m),s;if(null===f){for(;m<i.length;m++)null!==(f=d(n,i[m],u))&&(o=a(f,o,m),null===c?s=f:c.sibling=f,c=f);return oo&&Gl(n,m),s}for(f=l(n,f);m<i.length;m++)null!==(g=h(f,n,m,i[m],u))&&(e&&null!==g.alternate&&f.delete(null===g.key?m:g.key),o=a(g,o,m),null===c?s=g:c.sibling=g,c=g);return e&&f.forEach(function(e){return t(n,e)}),oo&&Gl(n,m),s}(s,c,f,m);if(O(f))return function(o,i,u,s){var c=O(u);if("function"!=typeof c)throw Error(n(150));if(null==(u=c.call(u)))throw Error(n(151));for(var f=c=null,m=i,g=i=0,y=null,v=u.next();null!==m&&!v.done;g++,v=u.next()){m.index>g?(y=m,m=null):y=m.sibling;var b=p(o,m,v.value,s);if(null===b){null===m&&(m=y);break}e&&m&&null===b.alternate&&t(o,m),i=a(b,i,g),null===f?c=b:f.sibling=b,f=b,m=y}if(v.done)return r(o,m),oo&&Gl(o,g),c;if(null===m){for(;!v.done;g++,v=u.next())null!==(v=d(o,v.value,s))&&(i=a(v,i,g),null===f?c=v:f.sibling=v,f=v);return oo&&Gl(o,g),c}for(m=l(o,m);!v.done;g++,v=u.next())null!==(v=h(m,o,g,v.value,s))&&(e&&null!==v.alternate&&m.delete(null===v.key?g:v.key),i=a(v,i,g),null===f?c=v:f.sibling=v,f=v);return e&&m.forEach(function(e){return t(o,e)}),oo&&Gl(o,g),c}(s,c,f,m);bo(s,f)}return"string"==typeof f&&""!==f||"number"==typeof f?(f=""+f,null!==c&&6===c.tag?(r(s,c.sibling),(c=o(c,f)).return=s,s=c):(r(s,c),(c=Fs(f,s.mode,m)).return=s,s=c),i(s)):r(s,c)}}var wo=xo(!0),So=xo(!1),_o=Cl(null),Co=null,Eo=null,No=null;function Po(){No=Eo=Co=null}function Io(e){var t=_o.current;El(_o),e._currentValue=t}function To(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Lo(e,t){Co=e,No=Eo=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(ki=!0),e.firstContext=null)}function zo(e){var t=e._currentValue;if(No!==e)if(e={context:e,memoizedValue:t,next:null},null===Eo){if(null===Co)throw Error(n(308));Eo=e,Co.dependencies={lanes:0,firstContext:e}}else Eo=Eo.next=e;return t}var Mo=null;function jo(e){null===Mo?Mo=[e]:Mo.push(e)}function Do(e,t,n,r){var l=t.interleaved;return null===l?(n.next=n,jo(t)):(n.next=l.next,l.next=n),t.interleaved=n,Oo(e,r)}function Oo(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var Ro=!1;function Fo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ao(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Uo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Bo(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,2&Iu){var l=r.pending;return null===l?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Oo(e,n)}return null===(l=r.interleaved)?(t.next=t,jo(r)):(t.next=l.next,l.next=t),r.interleaved=t,Oo(e,n)}function Ho(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,bt(e,n)}}function Vo(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var l=null,o=null;if(null!==(n=n.firstBaseUpdate)){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===o?l=o=a:o=o.next=a,n=n.next}while(null!==n);null===o?l=o=t:o=o.next=t}else l=o=t;return n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function $o(e,t,n,r){var l=e.updateQueue;Ro=!1;var o=l.firstBaseUpdate,a=l.lastBaseUpdate,i=l.shared.pending;if(null!==i){l.shared.pending=null;var u=i,s=u.next;u.next=null,null===a?o=s:a.next=s,a=u;var c=e.alternate;null!==c&&((i=(c=c.updateQueue).lastBaseUpdate)!==a&&(null===i?c.firstBaseUpdate=s:i.next=s,c.lastBaseUpdate=u))}if(null!==o){var f=l.baseState;for(a=0,c=s=u=null,i=o;;){var d=i.lane,p=i.eventTime;if((r&d)===d){null!==c&&(c=c.next={eventTime:p,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var h=e,m=i;switch(d=t,p=n,m.tag){case 1:if("function"==typeof(h=m.payload)){f=h.call(p,f,d);break e}f=h;break e;case 3:h.flags=-65537&h.flags|128;case 0:if(null==(d="function"==typeof(h=m.payload)?h.call(p,f,d):h))break e;f=F({},f,d);break e;case 2:Ro=!0}}null!==i.callback&&0!==i.lane&&(e.flags|=64,null===(d=l.effects)?l.effects=[i]:d.push(i))}else p={eventTime:p,lane:d,tag:i.tag,payload:i.payload,callback:i.callback,next:null},null===c?(s=c=p,u=f):c=c.next=p,a|=d;if(null===(i=i.next)){if(null===(i=l.shared.pending))break;i=(d=i).next,d.next=null,l.lastBaseUpdate=d,l.shared.pending=null}}if(null===c&&(u=f),l.baseState=u,l.firstBaseUpdate=s,l.lastBaseUpdate=c,null!==(t=l.shared.interleaved)){l=t;do{a|=l.lane,l=l.next}while(l!==t)}else null===o&&(l.shared.lanes=0);Ru|=a,e.lanes=a,e.memoizedState=f}}function Wo(e,t,r){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var l=e[t],o=l.callback;if(null!==o){if(l.callback=null,l=r,"function"!=typeof o)throw Error(n(191,o));o.call(l)}}}var qo={},Qo=Cl(qo),Ko=Cl(qo),Yo=Cl(qo);function Xo(e){if(e===qo)throw Error(n(174));return e}function Zo(e,t){switch(Nl(Yo,t),Nl(Ko,e),Nl(Qo,qo),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:se(null,"");break;default:t=se(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}El(Qo),Nl(Qo,t)}function Jo(){El(Qo),El(Ko),El(Yo)}function Go(e){Xo(Yo.current);var t=Xo(Qo.current),n=se(t,e.type);t!==n&&(Nl(Ko,e),Nl(Qo,n))}function ea(e){Ko.current===e&&(El(Qo),El(Ko))}var ta=Cl(0);function na(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||"$!"===n.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(128&t.flags)return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ra=[];function la(){for(var e=0;e<ra.length;e++)ra[e]._workInProgressVersionPrimary=null;ra.length=0}var oa=k.ReactCurrentDispatcher,aa=k.ReactCurrentBatchConfig,ia=0,ua=null,sa=null,ca=null,fa=!1,da=!1,pa=0,ha=0;function ma(){throw Error(n(321))}function ga(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ur(e[n],t[n]))return!1;return!0}function ya(e,t,r,l,o,a){if(ia=a,ua=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,oa.current=null===e||null===e.memoizedState?ei:ti,e=r(l,o),da){a=0;do{if(da=!1,pa=0,25<=a)throw Error(n(301));a+=1,ca=sa=null,t.updateQueue=null,oa.current=ni,e=r(l,o)}while(da)}if(oa.current=Ga,t=null!==sa&&null!==sa.next,ia=0,ca=sa=ua=null,fa=!1,t)throw Error(n(300));return e}function va(){var e=0!==pa;return pa=0,e}function ba(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===ca?ua.memoizedState=ca=e:ca=ca.next=e,ca}function ka(){if(null===sa){var e=ua.alternate;e=null!==e?e.memoizedState:null}else e=sa.next;var t=null===ca?ua.memoizedState:ca.next;if(null!==t)ca=t,sa=e;else{if(null===e)throw Error(n(310));e={memoizedState:(sa=e).memoizedState,baseState:sa.baseState,baseQueue:sa.baseQueue,queue:sa.queue,next:null},null===ca?ua.memoizedState=ca=e:ca=ca.next=e}return ca}function xa(e,t){return"function"==typeof t?t(e):t}function wa(e){var t=ka(),r=t.queue;if(null===r)throw Error(n(311));r.lastRenderedReducer=e;var l=sa,o=l.baseQueue,a=r.pending;if(null!==a){if(null!==o){var i=o.next;o.next=a.next,a.next=i}l.baseQueue=o=a,r.pending=null}if(null!==o){a=o.next,l=l.baseState;var u=i=null,s=null,c=a;do{var f=c.lane;if((ia&f)===f)null!==s&&(s=s.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),l=c.hasEagerState?c.eagerState:e(l,c.action);else{var d={lane:f,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};null===s?(u=s=d,i=l):s=s.next=d,ua.lanes|=f,Ru|=f}c=c.next}while(null!==c&&c!==a);null===s?i=l:s.next=u,ur(l,t.memoizedState)||(ki=!0),t.memoizedState=l,t.baseState=i,t.baseQueue=s,r.lastRenderedState=l}if(null!==(e=r.interleaved)){o=e;do{a=o.lane,ua.lanes|=a,Ru|=a,o=o.next}while(o!==e)}else null===o&&(r.lanes=0);return[t.memoizedState,r.dispatch]}function Sa(e){var t=ka(),r=t.queue;if(null===r)throw Error(n(311));r.lastRenderedReducer=e;var l=r.dispatch,o=r.pending,a=t.memoizedState;if(null!==o){r.pending=null;var i=o=o.next;do{a=e(a,i.action),i=i.next}while(i!==o);ur(a,t.memoizedState)||(ki=!0),t.memoizedState=a,null===t.baseQueue&&(t.baseState=a),r.lastRenderedState=a}return[a,l]}function _a(){}function Ca(e,t){var r=ua,l=ka(),o=t(),a=!ur(l.memoizedState,o);if(a&&(l.memoizedState=o,ki=!0),l=l.queue,Ra(Pa.bind(null,r,l,e),[e]),l.getSnapshot!==t||a||null!==ca&&1&ca.memoizedState.tag){if(r.flags|=2048,za(9,Na.bind(null,r,l,o,t),void 0,null),null===Tu)throw Error(n(349));30&ia||Ea(r,t,o)}return o}function Ea(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=ua.updateQueue)?(t={lastEffect:null,stores:null},ua.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Na(e,t,n,r){t.value=n,t.getSnapshot=r,Ia(t)&&Ta(e)}function Pa(e,t,n){return n(function(){Ia(t)&&Ta(e)})}function Ia(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ur(e,n)}catch(r){return!0}}function Ta(e){var t=Oo(e,1);null!==t&&rs(t,e,1,-1)}function La(e){var t=ba();return"function"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:xa,lastRenderedState:e},t.queue=e,e=e.dispatch=Ya.bind(null,ua,e),[t.memoizedState,e]}function za(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=ua.updateQueue)?(t={lastEffect:null,stores:null},ua.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ma(){return ka().memoizedState}function ja(e,t,n,r){var l=ba();ua.flags|=e,l.memoizedState=za(1|t,n,void 0,void 0===r?null:r)}function Da(e,t,n,r){var l=ka();r=void 0===r?null:r;var o=void 0;if(null!==sa){var a=sa.memoizedState;if(o=a.destroy,null!==r&&ga(r,a.deps))return void(l.memoizedState=za(t,n,o,r))}ua.flags|=e,l.memoizedState=za(1|t,n,o,r)}function Oa(e,t){return ja(8390656,8,e,t)}function Ra(e,t){return Da(2048,8,e,t)}function Fa(e,t){return Da(4,2,e,t)}function Aa(e,t){return Da(4,4,e,t)}function Ua(e,t){return"function"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function Ba(e,t,n){return n=null!=n?n.concat([e]):null,Da(4,4,Ua.bind(null,t,e),n)}function Ha(){}function Va(e,t){var n=ka();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&ga(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function $a(e,t){var n=ka();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&ga(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Wa(e,t,n){return 21&ia?(ur(n,t)||(n=gt(),ua.lanes|=n,Ru|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ki=!0),e.memoizedState=n)}function qa(e,t){var n=kt;kt=0!==n&&4>n?n:4,e(!0);var r=aa.transition;aa.transition={};try{e(!1),t()}finally{kt=n,aa.transition=r}}function Qa(){return ka().memoizedState}function Ka(e,t,n){var r=ns(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Xa(e))Za(t,n);else if(null!==(n=Do(e,t,n,r))){rs(n,e,r,ts()),Ja(n,t,r)}}function Ya(e,t,n){var r=ns(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Xa(e))Za(t,l);else{var o=e.alternate;if(0===e.lanes&&(null===o||0===o.lanes)&&null!==(o=t.lastRenderedReducer))try{var a=t.lastRenderedState,i=o(a,n);if(l.hasEagerState=!0,l.eagerState=i,ur(i,a)){var u=t.interleaved;return null===u?(l.next=l,jo(t)):(l.next=u.next,u.next=l),void(t.interleaved=l)}}catch(s){}null!==(n=Do(e,t,l,r))&&(rs(n,e,r,l=ts()),Ja(n,t,r))}}function Xa(e){var t=e.alternate;return e===ua||null!==t&&t===ua}function Za(e,t){da=fa=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ja(e,t,n){if(4194240&n){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,bt(e,n)}}var Ga={readContext:zo,useCallback:ma,useContext:ma,useEffect:ma,useImperativeHandle:ma,useInsertionEffect:ma,useLayoutEffect:ma,useMemo:ma,useReducer:ma,useRef:ma,useState:ma,useDebugValue:ma,useDeferredValue:ma,useTransition:ma,useMutableSource:ma,useSyncExternalStore:ma,useId:ma,unstable_isNewReconciler:!1},ei={readContext:zo,useCallback:function(e,t){return ba().memoizedState=[e,void 0===t?null:t],e},useContext:zo,useEffect:Oa,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,ja(4194308,4,Ua.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ja(4194308,4,e,t)},useInsertionEffect:function(e,t){return ja(4,2,e,t)},useMemo:function(e,t){var n=ba();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ba();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ka.bind(null,ua,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},ba().memoizedState=e},useState:La,useDebugValue:Ha,useDeferredValue:function(e){return ba().memoizedState=e},useTransition:function(){var e=La(!1),t=e[0];return e=qa.bind(null,e[1]),ba().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var l=ua,o=ba();if(oo){if(void 0===r)throw Error(n(407));r=r()}else{if(r=t(),null===Tu)throw Error(n(349));30&ia||Ea(l,t,r)}o.memoizedState=r;var a={value:r,getSnapshot:t};return o.queue=a,Oa(Pa.bind(null,l,a,e),[e]),l.flags|=2048,za(9,Na.bind(null,l,a,r,t),void 0,null),r},useId:function(){var e=ba(),t=Tu.identifierPrefix;if(oo){var n=Jl;t=":"+t+"R"+(n=(Zl&~(1<<32-it(Zl)-1)).toString(32)+n),0<(n=pa++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=ha++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},ti={readContext:zo,useCallback:Va,useContext:zo,useEffect:Ra,useImperativeHandle:Ba,useInsertionEffect:Fa,useLayoutEffect:Aa,useMemo:$a,useReducer:wa,useRef:Ma,useState:function(){return wa(xa)},useDebugValue:Ha,useDeferredValue:function(e){return Wa(ka(),sa.memoizedState,e)},useTransition:function(){return[wa(xa)[0],ka().memoizedState]},useMutableSource:_a,useSyncExternalStore:Ca,useId:Qa,unstable_isNewReconciler:!1},ni={readContext:zo,useCallback:Va,useContext:zo,useEffect:Ra,useImperativeHandle:Ba,useInsertionEffect:Fa,useLayoutEffect:Aa,useMemo:$a,useReducer:Sa,useRef:Ma,useState:function(){return Sa(xa)},useDebugValue:Ha,useDeferredValue:function(e){var t=ka();return null===sa?t.memoizedState=e:Wa(t,sa.memoizedState,e)},useTransition:function(){return[Sa(xa)[0],ka().memoizedState]},useMutableSource:_a,useSyncExternalStore:Ca,useId:Qa,unstable_isNewReconciler:!1};function ri(e,t){if(e&&e.defaultProps){for(var n in t=F({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function li(e,t,n,r){n=null==(n=n(r,t=e.memoizedState))?t:F({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var oi={isMounted:function(e){return!!(e=e._reactInternals)&&Ve(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=ts(),l=ns(e),o=Uo(r,l);o.payload=t,null!=n&&(o.callback=n),null!==(t=Bo(e,o,l))&&(rs(t,e,l,r),Ho(t,e,l))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=ts(),l=ns(e),o=Uo(r,l);o.tag=1,o.payload=t,null!=n&&(o.callback=n),null!==(t=Bo(e,o,l))&&(rs(t,e,l,r),Ho(t,e,l))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ts(),r=ns(e),l=Uo(n,r);l.tag=2,null!=t&&(l.callback=t),null!==(t=Bo(e,l,r))&&(rs(t,e,r,n),Ho(t,e,r))}};function ai(e,t,n,r,l,o,a){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,o,a):!t.prototype||!t.prototype.isPureReactComponent||(!sr(n,r)||!sr(l,o))}function ii(e,t,n){var r=!1,l=Pl,o=t.contextType;return"object"==typeof o&&null!==o?o=zo(o):(l=Ml(t)?Ll:Il.current,o=(r=null!=(r=t.contextTypes))?zl(e,l):Pl),t=new t(n,o),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=oi,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=l,e.__reactInternalMemoizedMaskedChildContext=o),t}function ui(e,t,n,r){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&oi.enqueueReplaceState(t,t.state,null)}function si(e,t,n,r){var l=e.stateNode;l.props=n,l.state=e.memoizedState,l.refs={},Fo(e);var o=t.contextType;"object"==typeof o&&null!==o?l.context=zo(o):(o=Ml(t)?Ll:Il.current,l.context=zl(e,o)),l.state=e.memoizedState,"function"==typeof(o=t.getDerivedStateFromProps)&&(li(e,t,o,n),l.state=e.memoizedState),"function"==typeof t.getDerivedStateFromProps||"function"==typeof l.getSnapshotBeforeUpdate||"function"!=typeof l.UNSAFE_componentWillMount&&"function"!=typeof l.componentWillMount||(t=l.state,"function"==typeof l.componentWillMount&&l.componentWillMount(),"function"==typeof l.UNSAFE_componentWillMount&&l.UNSAFE_componentWillMount(),t!==l.state&&oi.enqueueReplaceState(l,l.state,null),$o(e,n,l,r),l.state=e.memoizedState),"function"==typeof l.componentDidMount&&(e.flags|=4194308)}function ci(e,t){try{var n="",r=t;do{n+=H(r),r=r.return}while(r);var l=n}catch(o){l="\nError generating stack: "+o.message+"\n"+o.stack}return{value:e,source:t,stack:l,digest:null}}function fi(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function di(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var pi="function"==typeof WeakMap?WeakMap:Map;function hi(e,t,n){(n=Uo(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Wu||(Wu=!0,qu=r),di(0,t)},n}function mi(e,t,n){(n=Uo(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"==typeof r){var l=t.value;n.payload=function(){return r(l)},n.callback=function(){di(0,t)}}var o=e.stateNode;return null!==o&&"function"==typeof o.componentDidCatch&&(n.callback=function(){di(0,t),"function"!=typeof r&&(null===Qu?Qu=new Set([this]):Qu.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function gi(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new pi;var l=new Set;r.set(t,l)}else void 0===(l=r.get(t))&&(l=new Set,r.set(t,l));l.has(n)||(l.add(n),e=Es.bind(null,e,t,n),t.then(e,e))}function yi(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function vi(e,t,n,r,l){return 1&e.mode?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=Uo(-1,1)).tag=2,Bo(n,t,1))),n.lanes|=1),e)}var bi=k.ReactCurrentOwner,ki=!1;function xi(e,t,n,r){t.child=null===e?So(t,null,n,r):wo(t,e.child,n,r)}function wi(e,t,n,r,l){n=n.render;var o=t.ref;return Lo(t,l),r=ya(e,t,n,r,o,l),n=va(),null===e||ki?(oo&&n&&to(t),t.flags|=1,xi(e,t,r,l),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,Wi(e,t,l))}function Si(e,t,n,r,l){if(null===e){var o=n.type;return"function"!=typeof o||Ms(o)||void 0!==o.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Ds(n.type,null,r,t,t.mode,l)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=o,_i(e,t,o,r,l))}if(o=e.child,0===(e.lanes&l)){var a=o.memoizedProps;if((n=null!==(n=n.compare)?n:sr)(a,r)&&e.ref===t.ref)return Wi(e,t,l)}return t.flags|=1,(e=js(o,r)).ref=t.ref,e.return=t,t.child=e}function _i(e,t,n,r,l){if(null!==e){var o=e.memoizedProps;if(sr(o,r)&&e.ref===t.ref){if(ki=!1,t.pendingProps=r=o,0===(e.lanes&l))return t.lanes=e.lanes,Wi(e,t,l);131072&e.flags&&(ki=!0)}}return Ni(e,t,n,r,l)}function Ci(e,t,n){var r=t.pendingProps,l=r.children,o=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(1&t.mode){if(!(1073741824&n))return e=null!==o?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Nl(ju,Mu),Mu|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=null!==o?o.baseLanes:n,Nl(ju,Mu),Mu|=r}else t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Nl(ju,Mu),Mu|=n;else null!==o?(r=o.baseLanes|n,t.memoizedState=null):r=n,Nl(ju,Mu),Mu|=r;return xi(e,t,l,n),t.child}function Ei(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ni(e,t,n,r,l){var o=Ml(n)?Ll:Il.current;return o=zl(t,o),Lo(t,l),n=ya(e,t,n,r,o,l),r=va(),null===e||ki?(oo&&r&&to(t),t.flags|=1,xi(e,t,n,l),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,Wi(e,t,l))}function Pi(e,t,n,r,l){if(Ml(n)){var o=!0;Rl(t)}else o=!1;if(Lo(t,l),null===t.stateNode)$i(e,t),ii(t,n,r),si(t,n,r,l),r=!0;else if(null===e){var a=t.stateNode,i=t.memoizedProps;a.props=i;var u=a.context,s=n.contextType;"object"==typeof s&&null!==s?s=zo(s):s=zl(t,s=Ml(n)?Ll:Il.current);var c=n.getDerivedStateFromProps,f="function"==typeof c||"function"==typeof a.getSnapshotBeforeUpdate;f||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(i!==r||u!==s)&&ui(t,a,r,s),Ro=!1;var d=t.memoizedState;a.state=d,$o(t,r,a,l),u=t.memoizedState,i!==r||d!==u||Tl.current||Ro?("function"==typeof c&&(li(t,n,c,r),u=t.memoizedState),(i=Ro||ai(t,n,i,r,d,u,s))?(f||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(t.flags|=4194308)):("function"==typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),a.props=r,a.state=u,a.context=s,r=i):("function"==typeof a.componentDidMount&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ao(e,t),i=t.memoizedProps,s=t.type===t.elementType?i:ri(t.type,i),a.props=s,f=t.pendingProps,d=a.context,"object"==typeof(u=n.contextType)&&null!==u?u=zo(u):u=zl(t,u=Ml(n)?Ll:Il.current);var p=n.getDerivedStateFromProps;(c="function"==typeof p||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(i!==f||d!==u)&&ui(t,a,r,u),Ro=!1,d=t.memoizedState,a.state=d,$o(t,r,a,l);var h=t.memoizedState;i!==f||d!==h||Tl.current||Ro?("function"==typeof p&&(li(t,n,p,r),h=t.memoizedState),(s=Ro||ai(t,n,s,r,d,h,u)||!1)?(c||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(r,h,u),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(r,h,u)),"function"==typeof a.componentDidUpdate&&(t.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof a.componentDidUpdate||i===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||i===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=h),a.props=r,a.state=h,a.context=u,r=s):("function"!=typeof a.componentDidUpdate||i===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||i===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return Ii(e,t,n,r,o,l)}function Ii(e,t,n,r,l,o){Ei(e,t);var a=!!(128&t.flags);if(!r&&!a)return l&&Fl(t,n,!1),Wi(e,t,o);r=t.stateNode,bi.current=t;var i=a&&"function"!=typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&a?(t.child=wo(t,e.child,null,o),t.child=wo(t,null,i,o)):xi(e,t,i,o),t.memoizedState=r.state,l&&Fl(t,n,!0),t.child}function Ti(e){var t=e.stateNode;t.pendingContext?Dl(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Dl(0,t.context,!1),Zo(e,t.containerInfo)}function Li(e,t,n,r,l){return mo(),go(l),t.flags|=256,xi(e,t,n,r),t.child}var zi,Mi,ji,Di,Oi={dehydrated:null,treeContext:null,retryLane:0};function Ri(e){return{baseLanes:e,cachePool:null,transitions:null}}function Fi(e,t,r){var l,o=t.pendingProps,a=ta.current,i=!1,u=!!(128&t.flags);if((l=u)||(l=(null===e||null!==e.memoizedState)&&!!(2&a)),l?(i=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(a|=1),Nl(ta,1&a),null===e)return co(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(1&t.mode?"$!"===e.data?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(u=o.children,e=o.fallback,i?(o=t.mode,i=t.child,u={mode:"hidden",children:u},1&o||null===i?i=Rs(u,o,0,null):(i.childLanes=0,i.pendingProps=u),e=Os(e,o,r,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Ri(r),t.memoizedState=Oi,e):Ai(t,u));if(null!==(a=e.memoizedState)&&null!==(l=a.dehydrated))return function(e,t,r,l,o,a,i){if(r)return 256&t.flags?(t.flags&=-257,Ui(e,t,i,l=fi(Error(n(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(a=l.fallback,o=t.mode,l=Rs({mode:"visible",children:l.children},o,0,null),(a=Os(a,o,i,null)).flags|=2,l.return=t,a.return=t,l.sibling=a,t.child=l,1&t.mode&&wo(t,e.child,null,i),t.child.memoizedState=Ri(i),t.memoizedState=Oi,a);if(!(1&t.mode))return Ui(e,t,i,null);if("$!"===o.data){if(l=o.nextSibling&&o.nextSibling.dataset)var u=l.dgst;return l=u,Ui(e,t,i,l=fi(a=Error(n(419)),l,void 0))}if(u=0!==(i&e.childLanes),ki||u){if(null!==(l=Tu)){switch(i&-i){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}0!==(o=0!==(o&(l.suspendedLanes|i))?0:o)&&o!==a.retryLane&&(a.retryLane=o,Oo(e,o),rs(l,e,o,-1))}return gs(),Ui(e,t,i,l=fi(Error(n(421))))}return"$?"===o.data?(t.flags|=128,t.child=e.child,t=Ps.bind(null,e),o._reactRetry=t,null):(e=a.treeContext,lo=cl(o.nextSibling),ro=t,oo=!0,ao=null,null!==e&&(Kl[Yl++]=Zl,Kl[Yl++]=Jl,Kl[Yl++]=Xl,Zl=e.id,Jl=e.overflow,Xl=t),t=Ai(t,l.children),t.flags|=4096,t)}(e,t,u,o,l,a,r);if(i){i=o.fallback,u=t.mode,l=(a=e.child).sibling;var s={mode:"hidden",children:o.children};return 1&u||t.child===a?(o=js(a,s)).subtreeFlags=14680064&a.subtreeFlags:((o=t.child).childLanes=0,o.pendingProps=s,t.deletions=null),null!==l?i=js(l,i):(i=Os(i,u,r,null)).flags|=2,i.return=t,o.return=t,o.sibling=i,t.child=o,o=i,i=t.child,u=null===(u=e.child.memoizedState)?Ri(r):{baseLanes:u.baseLanes|r,cachePool:null,transitions:u.transitions},i.memoizedState=u,i.childLanes=e.childLanes&~r,t.memoizedState=Oi,o}return e=(i=e.child).sibling,o=js(i,{mode:"visible",children:o.children}),!(1&t.mode)&&(o.lanes=r),o.return=t,o.sibling=null,null!==e&&(null===(r=t.deletions)?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=o,t.memoizedState=null,o}function Ai(e,t){return(t=Rs({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function Ui(e,t,n,r){return null!==r&&go(r),wo(t,e.child,null,n),(e=Ai(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Bi(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),To(e.return,t,n)}function Hi(e,t,n,r,l){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:l}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=l)}function Vi(e,t,n){var r=t.pendingProps,l=r.revealOrder,o=r.tail;if(xi(e,t,r.children,n),2&(r=ta.current))r=1&r|2,t.flags|=128;else{if(null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Bi(e,n,t);else if(19===e.tag)Bi(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Nl(ta,r),1&t.mode)switch(l){case"forwards":for(n=t.child,l=null;null!==n;)null!==(e=n.alternate)&&null===na(e)&&(l=n),n=n.sibling;null===(n=l)?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),Hi(t,!1,l,n,o);break;case"backwards":for(n=null,l=t.child,t.child=null;null!==l;){if(null!==(e=l.alternate)&&null===na(e)){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}Hi(t,!0,n,null,o);break;case"together":Hi(t,!1,null,null,void 0);break;default:t.memoizedState=null}else t.memoizedState=null;return t.child}function $i(e,t){!(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Wi(e,t,r){if(null!==e&&(t.dependencies=e.dependencies),Ru|=t.lanes,0===(r&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(n(153));if(null!==t.child){for(r=js(e=t.child,e.pendingProps),t.child=r,r.return=t;null!==e.sibling;)e=e.sibling,(r=r.sibling=js(e,e.pendingProps)).return=t;r.sibling=null}return t.child}function qi(e,t){if(!oo)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Qi(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var l=e.child;null!==l;)n|=l.lanes|l.childLanes,r|=14680064&l.subtreeFlags,r|=14680064&l.flags,l.return=e,l=l.sibling;else for(l=e.child;null!==l;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Ki(e,t,r){var o=t.pendingProps;switch(no(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Qi(t),null;case 1:case 17:return Ml(t.type)&&jl(),Qi(t),null;case 3:return o=t.stateNode,Jo(),El(Tl),El(Il),la(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),null!==e&&null!==e.child||(po(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,null!==ao&&(is(ao),ao=null))),Mi(e,t),Qi(t),null;case 5:ea(t);var a=Xo(Yo.current);if(r=t.type,null!==e&&null!=t.stateNode)ji(e,t,r,o,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!o){if(null===t.stateNode)throw Error(n(166));return Qi(t),null}if(e=Xo(Qo.current),po(t)){o=t.stateNode,r=t.type;var i=t.memoizedProps;switch(o[pl]=t,o[hl]=i,e=!!(1&t.mode),r){case"dialog":Ur("cancel",o),Ur("close",o);break;case"iframe":case"object":case"embed":Ur("load",o);break;case"video":case"audio":for(a=0;a<Or.length;a++)Ur(Or[a],o);break;case"source":Ur("error",o);break;case"img":case"image":case"link":Ur("error",o),Ur("load",o);break;case"details":Ur("toggle",o);break;case"input":Z(o,i),Ur("invalid",o);break;case"select":o._wrapperState={wasMultiple:!!i.multiple},Ur("invalid",o);break;case"textarea":oe(o,i),Ur("invalid",o)}for(var u in be(r,i),a=null,i)if(i.hasOwnProperty(u)){var s=i[u];"children"===u?"string"==typeof s?o.textContent!==s&&(!0!==i.suppressHydrationWarning&&Gr(o.textContent,s,e),a=["children",s]):"number"==typeof s&&o.textContent!==""+s&&(!0!==i.suppressHydrationWarning&&Gr(o.textContent,s,e),a=["children",""+s]):l.hasOwnProperty(u)&&null!=s&&"onScroll"===u&&Ur("scroll",o)}switch(r){case"input":Q(o),ee(o,i,!0);break;case"textarea":Q(o),ie(o);break;case"select":case"option":break;default:"function"==typeof i.onClick&&(o.onclick=el)}o=a,t.updateQueue=o,null!==o&&(t.flags|=4)}else{u=9===a.nodeType?a:a.ownerDocument,"http://www.w3.org/1999/xhtml"===e&&(e=ue(r)),"http://www.w3.org/1999/xhtml"===e?"script"===r?((e=u.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"==typeof o.is?e=u.createElement(r,{is:o.is}):(e=u.createElement(r),"select"===r&&(u=e,o.multiple?u.multiple=!0:o.size&&(u.size=o.size))):e=u.createElementNS(e,r),e[pl]=t,e[hl]=o,zi(e,t,!1,!1),t.stateNode=e;e:{switch(u=ke(r,o),r){case"dialog":Ur("cancel",e),Ur("close",e),a=o;break;case"iframe":case"object":case"embed":Ur("load",e),a=o;break;case"video":case"audio":for(a=0;a<Or.length;a++)Ur(Or[a],e);a=o;break;case"source":Ur("error",e),a=o;break;case"img":case"image":case"link":Ur("error",e),Ur("load",e),a=o;break;case"details":Ur("toggle",e),a=o;break;case"input":Z(e,o),a=X(e,o),Ur("invalid",e);break;case"option":default:a=o;break;case"select":e._wrapperState={wasMultiple:!!o.multiple},a=F({},o,{value:void 0}),Ur("invalid",e);break;case"textarea":oe(e,o),a=le(e,o),Ur("invalid",e)}for(i in be(r,a),s=a)if(s.hasOwnProperty(i)){var c=s[i];"style"===i?ye(e,c):"dangerouslySetInnerHTML"===i?null!=(c=c?c.__html:void 0)&&de(e,c):"children"===i?"string"==typeof c?("textarea"!==r||""!==c)&&pe(e,c):"number"==typeof c&&pe(e,""+c):"suppressContentEditableWarning"!==i&&"suppressHydrationWarning"!==i&&"autoFocus"!==i&&(l.hasOwnProperty(i)?null!=c&&"onScroll"===i&&Ur("scroll",e):null!=c&&v(e,i,c,u))}switch(r){case"input":Q(e),ee(e,o,!1);break;case"textarea":Q(e),ie(e);break;case"option":null!=o.value&&e.setAttribute("value",""+W(o.value));break;case"select":e.multiple=!!o.multiple,null!=(i=o.value)?re(e,!!o.multiple,i,!1):null!=o.defaultValue&&re(e,!!o.multiple,o.defaultValue,!0);break;default:"function"==typeof a.onClick&&(e.onclick=el)}switch(r){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}}o&&(t.flags|=4)}null!==t.ref&&(t.flags|=512,t.flags|=2097152)}return Qi(t),null;case 6:if(e&&null!=t.stateNode)Di(e,t,e.memoizedProps,o);else{if("string"!=typeof o&&null===t.stateNode)throw Error(n(166));if(r=Xo(Yo.current),Xo(Qo.current),po(t)){if(o=t.stateNode,r=t.memoizedProps,o[pl]=t,(i=o.nodeValue!==r)&&null!==(e=ro))switch(e.tag){case 3:Gr(o.nodeValue,r,!!(1&e.mode));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Gr(o.nodeValue,r,!!(1&e.mode))}i&&(t.flags|=4)}else(o=(9===r.nodeType?r:r.ownerDocument).createTextNode(o))[pl]=t,t.stateNode=o}return Qi(t),null;case 13:if(El(ta),o=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(oo&&null!==lo&&1&t.mode&&!(128&t.flags))ho(),mo(),t.flags|=98560,i=!1;else if(i=po(t),null!==o&&null!==o.dehydrated){if(null===e){if(!i)throw Error(n(318));if(!(i=null!==(i=t.memoizedState)?i.dehydrated:null))throw Error(n(317));i[pl]=t}else mo(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;Qi(t),i=!1}else null!==ao&&(is(ao),ao=null),i=!0;if(!i)return 65536&t.flags?t:null}return 128&t.flags?(t.lanes=r,t):((o=null!==o)!==(null!==e&&null!==e.memoizedState)&&o&&(t.child.flags|=8192,1&t.mode&&(null===e||1&ta.current?0===Du&&(Du=3):gs())),null!==t.updateQueue&&(t.flags|=4),Qi(t),null);case 4:return Jo(),Mi(e,t),null===e&&Vr(t.stateNode.containerInfo),Qi(t),null;case 10:return Io(t.type._context),Qi(t),null;case 19:if(El(ta),null===(i=t.memoizedState))return Qi(t),null;if(o=!!(128&t.flags),null===(u=i.rendering))if(o)qi(i,!1);else{if(0!==Du||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(u=na(e))){for(t.flags|=128,qi(i,!1),null!==(o=u.updateQueue)&&(t.updateQueue=o,t.flags|=4),t.subtreeFlags=0,o=r,r=t.child;null!==r;)e=o,(i=r).flags&=14680066,null===(u=i.alternate)?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=u.childLanes,i.lanes=u.lanes,i.child=u.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=u.memoizedProps,i.memoizedState=u.memoizedState,i.updateQueue=u.updateQueue,i.type=u.type,e=u.dependencies,i.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),r=r.sibling;return Nl(ta,1&ta.current|2),t.child}e=e.sibling}null!==i.tail&&Je()>Vu&&(t.flags|=128,o=!0,qi(i,!1),t.lanes=4194304)}else{if(!o)if(null!==(e=na(u))){if(t.flags|=128,o=!0,null!==(r=e.updateQueue)&&(t.updateQueue=r,t.flags|=4),qi(i,!0),null===i.tail&&"hidden"===i.tailMode&&!u.alternate&&!oo)return Qi(t),null}else 2*Je()-i.renderingStartTime>Vu&&1073741824!==r&&(t.flags|=128,o=!0,qi(i,!1),t.lanes=4194304);i.isBackwards?(u.sibling=t.child,t.child=u):(null!==(r=i.last)?r.sibling=u:t.child=u,i.last=u)}return null!==i.tail?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Je(),t.sibling=null,r=ta.current,Nl(ta,o?1&r|2:1&r),t):(Qi(t),null);case 22:case 23:return ds(),o=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==o&&(t.flags|=8192),o&&1&t.mode?!!(1073741824&Mu)&&(Qi(t),6&t.subtreeFlags&&(t.flags|=8192)):Qi(t),null;case 24:case 25:return null}throw Error(n(156,t.tag))}function Yi(e,t){switch(no(t),t.tag){case 1:return Ml(t.type)&&jl(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Jo(),El(Tl),El(Il),la(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 5:return ea(t),null;case 13:if(El(ta),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(n(340));mo()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return El(ta),null;case 4:return Jo(),null;case 10:return Io(t.type._context),null;case 22:case 23:return ds(),null;default:return null}}zi=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},Mi=function(){},ji=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,Xo(Qo.current);var a,i=null;switch(n){case"input":o=X(e,o),r=X(e,r),i=[];break;case"select":o=F({},o,{value:void 0}),r=F({},r,{value:void 0}),i=[];break;case"textarea":o=le(e,o),r=le(e,r),i=[];break;default:"function"!=typeof o.onClick&&"function"==typeof r.onClick&&(e.onclick=el)}for(c in be(n,r),n=null,o)if(!r.hasOwnProperty(c)&&o.hasOwnProperty(c)&&null!=o[c])if("style"===c){var u=o[c];for(a in u)u.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else"dangerouslySetInnerHTML"!==c&&"children"!==c&&"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&"autoFocus"!==c&&(l.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in r){var s=r[c];if(u=null!=o?o[c]:void 0,r.hasOwnProperty(c)&&s!==u&&(null!=s||null!=u))if("style"===c)if(u){for(a in u)!u.hasOwnProperty(a)||s&&s.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in s)s.hasOwnProperty(a)&&u[a]!==s[a]&&(n||(n={}),n[a]=s[a])}else n||(i||(i=[]),i.push(c,n)),n=s;else"dangerouslySetInnerHTML"===c?(s=s?s.__html:void 0,u=u?u.__html:void 0,null!=s&&u!==s&&(i=i||[]).push(c,s)):"children"===c?"string"!=typeof s&&"number"!=typeof s||(i=i||[]).push(c,""+s):"suppressContentEditableWarning"!==c&&"suppressHydrationWarning"!==c&&(l.hasOwnProperty(c)?(null!=s&&"onScroll"===c&&Ur("scroll",e),i||u===s||(i=[])):(i=i||[]).push(c,s))}n&&(i=i||[]).push("style",n);var c=i;(t.updateQueue=c)&&(t.flags|=4)}},Di=function(e,t,n,r){n!==r&&(t.flags|=4)};var Xi=!1,Zi=!1,Ji="function"==typeof WeakSet?WeakSet:Set,Gi=null;function eu(e,t){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(r){Cs(e,t,r)}else n.current=null}function tu(e,t,n){try{n()}catch(r){Cs(e,t,r)}}var nu=!1;function ru(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,void 0!==o&&tu(t,n,o)}l=l.next}while(l!==r)}}function lu(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ou(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"==typeof t?t(e):t.current=e}}function au(e){var t=e.alternate;null!==t&&(e.alternate=null,au(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&(delete t[pl],delete t[hl],delete t[gl],delete t[yl],delete t[vl])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function iu(e){return 5===e.tag||3===e.tag||4===e.tag}function uu(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||iu(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function su(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=el));else if(4!==r&&null!==(e=e.child))for(su(e,t,n),e=e.sibling;null!==e;)su(e,t,n),e=e.sibling}function cu(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(cu(e,t,n),e=e.sibling;null!==e;)cu(e,t,n),e=e.sibling}var fu=null,du=!1;function pu(e,t,n){for(n=n.child;null!==n;)hu(e,t,n),n=n.sibling}function hu(e,t,n){if(at&&"function"==typeof at.onCommitFiberUnmount)try{at.onCommitFiberUnmount(ot,n)}catch(i){}switch(n.tag){case 5:Zi||eu(n,t);case 6:var r=fu,l=du;fu=null,pu(e,t,n),du=l,null!==(fu=r)&&(du?(e=fu,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):fu.removeChild(n.stateNode));break;case 18:null!==fu&&(du?(e=fu,n=n.stateNode,8===e.nodeType?sl(e.parentNode,n):1===e.nodeType&&sl(e,n),Vt(e)):sl(fu,n.stateNode));break;case 4:r=fu,l=du,fu=n.stateNode.containerInfo,du=!0,pu(e,t,n),fu=r,du=l;break;case 0:case 11:case 14:case 15:if(!Zi&&(null!==(r=n.updateQueue)&&null!==(r=r.lastEffect))){l=r=r.next;do{var o=l,a=o.destroy;o=o.tag,void 0!==a&&(2&o||4&o)&&tu(n,t,a),l=l.next}while(l!==r)}pu(e,t,n);break;case 1:if(!Zi&&(eu(n,t),"function"==typeof(r=n.stateNode).componentWillUnmount))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(i){Cs(n,t,i)}pu(e,t,n);break;case 21:pu(e,t,n);break;case 22:1&n.mode?(Zi=(r=Zi)||null!==n.memoizedState,pu(e,t,n),Zi=r):pu(e,t,n);break;default:pu(e,t,n)}}function mu(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Ji),t.forEach(function(t){var r=Is.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function gu(e,t){var r=t.deletions;if(null!==r)for(var l=0;l<r.length;l++){var o=r[l];try{var a=e,i=t,u=i;e:for(;null!==u;){switch(u.tag){case 5:fu=u.stateNode,du=!1;break e;case 3:case 4:fu=u.stateNode.containerInfo,du=!0;break e}u=u.return}if(null===fu)throw Error(n(160));hu(a,i,o),fu=null,du=!1;var s=o.alternate;null!==s&&(s.return=null),o.return=null}catch(c){Cs(o,t,c)}}if(12854&t.subtreeFlags)for(t=t.child;null!==t;)yu(t,e),t=t.sibling}function yu(e,t){var r=e.alternate,l=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(gu(t,e),vu(e),4&l){try{ru(3,e,e.return),lu(3,e)}catch(g){Cs(e,e.return,g)}try{ru(5,e,e.return)}catch(g){Cs(e,e.return,g)}}break;case 1:gu(t,e),vu(e),512&l&&null!==r&&eu(r,r.return);break;case 5:if(gu(t,e),vu(e),512&l&&null!==r&&eu(r,r.return),32&e.flags){var o=e.stateNode;try{pe(o,"")}catch(g){Cs(e,e.return,g)}}if(4&l&&null!=(o=e.stateNode)){var a=e.memoizedProps,i=null!==r?r.memoizedProps:a,u=e.type,s=e.updateQueue;if(e.updateQueue=null,null!==s)try{"input"===u&&"radio"===a.type&&null!=a.name&&J(o,a),ke(u,i);var c=ke(u,a);for(i=0;i<s.length;i+=2){var f=s[i],d=s[i+1];"style"===f?ye(o,d):"dangerouslySetInnerHTML"===f?de(o,d):"children"===f?pe(o,d):v(o,f,d,c)}switch(u){case"input":G(o,a);break;case"textarea":ae(o,a);break;case"select":var p=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!a.multiple;var h=a.value;null!=h?re(o,!!a.multiple,h,!1):p!==!!a.multiple&&(null!=a.defaultValue?re(o,!!a.multiple,a.defaultValue,!0):re(o,!!a.multiple,a.multiple?[]:"",!1))}o[hl]=a}catch(g){Cs(e,e.return,g)}}break;case 6:if(gu(t,e),vu(e),4&l){if(null===e.stateNode)throw Error(n(162));o=e.stateNode,a=e.memoizedProps;try{o.nodeValue=a}catch(g){Cs(e,e.return,g)}}break;case 3:if(gu(t,e),vu(e),4&l&&null!==r&&r.memoizedState.isDehydrated)try{Vt(t.containerInfo)}catch(g){Cs(e,e.return,g)}break;case 4:default:gu(t,e),vu(e);break;case 13:gu(t,e),vu(e),8192&(o=e.child).flags&&(a=null!==o.memoizedState,o.stateNode.isHidden=a,!a||null!==o.alternate&&null!==o.alternate.memoizedState||(Hu=Je())),4&l&&mu(e);break;case 22:if(f=null!==r&&null!==r.memoizedState,1&e.mode?(Zi=(c=Zi)||f,gu(t,e),Zi=c):gu(t,e),vu(e),8192&l){if(c=null!==e.memoizedState,(e.stateNode.isHidden=c)&&!f&&1&e.mode)for(Gi=e,f=e.child;null!==f;){for(d=Gi=f;null!==Gi;){switch(h=(p=Gi).child,p.tag){case 0:case 11:case 14:case 15:ru(4,p,p.return);break;case 1:eu(p,p.return);var m=p.stateNode;if("function"==typeof m.componentWillUnmount){l=p,r=p.return;try{t=l,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(g){Cs(l,r,g)}}break;case 5:eu(p,p.return);break;case 22:if(null!==p.memoizedState){wu(d);continue}}null!==h?(h.return=p,Gi=h):wu(d)}f=f.sibling}e:for(f=null,d=e;;){if(5===d.tag){if(null===f){f=d;try{o=d.stateNode,c?"function"==typeof(a=o.style).setProperty?a.setProperty("display","none","important"):a.display="none":(u=d.stateNode,i=null!=(s=d.memoizedProps.style)&&s.hasOwnProperty("display")?s.display:null,u.style.display=ge("display",i))}catch(g){Cs(e,e.return,g)}}}else if(6===d.tag){if(null===f)try{d.stateNode.nodeValue=c?"":d.memoizedProps}catch(g){Cs(e,e.return,g)}}else if((22!==d.tag&&23!==d.tag||null===d.memoizedState||d===e)&&null!==d.child){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;null===d.sibling;){if(null===d.return||d.return===e)break e;f===d&&(f=null),d=d.return}f===d&&(f=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:gu(t,e),vu(e),4&l&&mu(e);case 21:}}function vu(e){var t=e.flags;if(2&t){try{e:{for(var r=e.return;null!==r;){if(iu(r)){var l=r;break e}r=r.return}throw Error(n(160))}switch(l.tag){case 5:var o=l.stateNode;32&l.flags&&(pe(o,""),l.flags&=-33),cu(e,uu(e),o);break;case 3:case 4:var a=l.stateNode.containerInfo;su(e,uu(e),a);break;default:throw Error(n(161))}}catch(i){Cs(e,e.return,i)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function bu(e,t,n){Gi=e,ku(e)}function ku(e,t,n){for(var r=!!(1&e.mode);null!==Gi;){var l=Gi,o=l.child;if(22===l.tag&&r){var a=null!==l.memoizedState||Xi;if(!a){var i=l.alternate,u=null!==i&&null!==i.memoizedState||Zi;i=Xi;var s=Zi;if(Xi=a,(Zi=u)&&!s)for(Gi=l;null!==Gi;)u=(a=Gi).child,22===a.tag&&null!==a.memoizedState?Su(l):null!==u?(u.return=a,Gi=u):Su(l);for(;null!==o;)Gi=o,ku(o),o=o.sibling;Gi=l,Xi=i,Zi=s}xu(e)}else 8772&l.subtreeFlags&&null!==o?(o.return=l,Gi=o):xu(e)}}function xu(e){for(;null!==Gi;){var t=Gi;if(8772&t.flags){var r=t.alternate;try{if(8772&t.flags)switch(t.tag){case 0:case 11:case 15:Zi||lu(5,t);break;case 1:var l=t.stateNode;if(4&t.flags&&!Zi)if(null===r)l.componentDidMount();else{var o=t.elementType===t.type?r.memoizedProps:ri(t.type,r.memoizedProps);l.componentDidUpdate(o,r.memoizedState,l.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;null!==a&&Wo(t,a,l);break;case 3:var i=t.updateQueue;if(null!==i){if(r=null,null!==t.child)switch(t.child.tag){case 5:case 1:r=t.child.stateNode}Wo(t,i,r)}break;case 5:var u=t.stateNode;if(null===r&&4&t.flags){r=u;var s=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":s.autoFocus&&r.focus();break;case"img":s.src&&(r.src=s.src)}}break;case 6:case 4:case 12:case 19:case 17:case 21:case 22:case 23:case 25:break;case 13:if(null===t.memoizedState){var c=t.alternate;if(null!==c){var f=c.memoizedState;if(null!==f){var d=f.dehydrated;null!==d&&Vt(d)}}}break;default:throw Error(n(163))}Zi||512&t.flags&&ou(t)}catch(p){Cs(t,t.return,p)}}if(t===e){Gi=null;break}if(null!==(r=t.sibling)){r.return=t.return,Gi=r;break}Gi=t.return}}function wu(e){for(;null!==Gi;){var t=Gi;if(t===e){Gi=null;break}var n=t.sibling;if(null!==n){n.return=t.return,Gi=n;break}Gi=t.return}}function Su(e){for(;null!==Gi;){var t=Gi;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{lu(4,t)}catch(u){Cs(t,n,u)}break;case 1:var r=t.stateNode;if("function"==typeof r.componentDidMount){var l=t.return;try{r.componentDidMount()}catch(u){Cs(t,l,u)}}var o=t.return;try{ou(t)}catch(u){Cs(t,o,u)}break;case 5:var a=t.return;try{ou(t)}catch(u){Cs(t,a,u)}}}catch(u){Cs(t,t.return,u)}if(t===e){Gi=null;break}var i=t.sibling;if(null!==i){i.return=t.return,Gi=i;break}Gi=t.return}}var _u,Cu=Math.ceil,Eu=k.ReactCurrentDispatcher,Nu=k.ReactCurrentOwner,Pu=k.ReactCurrentBatchConfig,Iu=0,Tu=null,Lu=null,zu=0,Mu=0,ju=Cl(0),Du=0,Ou=null,Ru=0,Fu=0,Au=0,Uu=null,Bu=null,Hu=0,Vu=1/0,$u=null,Wu=!1,qu=null,Qu=null,Ku=!1,Yu=null,Xu=0,Zu=0,Ju=null,Gu=-1,es=0;function ts(){return 6&Iu?Je():-1!==Gu?Gu:Gu=Je()}function ns(e){return 1&e.mode?2&Iu&&0!==zu?zu&-zu:null!==yo.transition?(0===es&&(es=gt()),es):0!==(e=kt)?e:e=void 0===(e=window.event)?16:Zt(e.type):1}function rs(e,t,r,l){if(50<Zu)throw Zu=0,Ju=null,Error(n(185));vt(e,r,l),2&Iu&&e===Tu||(e===Tu&&(!(2&Iu)&&(Fu|=r),4===Du&&us(e,zu)),ls(e,l),1===r&&0===Iu&&!(1&t.mode)&&(Vu=Je()+500,Ul&&Vl()))}function ls(e,t){var n=e.callbackNode;!function(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,l=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-it(o),i=1<<a,u=l[a];-1===u?0!==(i&n)&&0===(i&r)||(l[a]=ht(i,t)):u<=t&&(e.expiredLanes|=i),o&=~i}}(e,t);var r=pt(e,e===Tu?zu:0);if(0===r)null!==n&&Ye(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(null!=n&&Ye(n),1===t)0===e.tag?function(e){Ul=!0,Hl(e)}(ss.bind(null,e)):Hl(ss.bind(null,e)),il(function(){!(6&Iu)&&Vl()}),n=null;else{switch(xt(r)){case 1:n=et;break;case 4:n=tt;break;case 16:default:n=nt;break;case 536870912:n=lt}n=Ts(n,os.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function os(e,t){if(Gu=-1,es=0,6&Iu)throw Error(n(327));var r=e.callbackNode;if(Ss()&&e.callbackNode!==r)return null;var l=pt(e,e===Tu?zu:0);if(0===l)return null;if(30&l||0!==(l&e.expiredLanes)||t)t=ys(e,l);else{t=l;var o=Iu;Iu|=2;var a=ms();for(Tu===e&&zu===t||($u=null,Vu=Je()+500,ps(e,t));;)try{bs();break}catch(u){hs(e,u)}Po(),Eu.current=a,Iu=o,null!==Lu?t=0:(Tu=null,zu=0,t=Du)}if(0!==t){if(2===t&&(0!==(o=mt(e))&&(l=o,t=as(e,o))),1===t)throw r=Ou,ps(e,0),us(e,l),ls(e,Je()),r;if(6===t)us(e,l);else{if(o=e.current.alternate,!(30&l||function(e){for(var t=e;;){if(16384&t.flags){var n=t.updateQueue;if(null!==n&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var l=n[r],o=l.getSnapshot;l=l.value;try{if(!ur(o(),l))return!1}catch(i){return!1}}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(o)||(t=ys(e,l),2===t&&(a=mt(e),0!==a&&(l=a,t=as(e,a))),1!==t)))throw r=Ou,ps(e,0),us(e,l),ls(e,Je()),r;switch(e.finishedWork=o,e.finishedLanes=l,t){case 0:case 1:throw Error(n(345));case 2:case 5:ws(e,Bu,$u);break;case 3:if(us(e,l),(130023424&l)===l&&10<(t=Hu+500-Je())){if(0!==pt(e,0))break;if(((o=e.suspendedLanes)&l)!==l){ts(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=ll(ws.bind(null,e,Bu,$u),t);break}ws(e,Bu,$u);break;case 4:if(us(e,l),(4194240&l)===l)break;for(t=e.eventTimes,o=-1;0<l;){var i=31-it(l);a=1<<i,(i=t[i])>o&&(o=i),l&=~a}if(l=o,10<(l=(120>(l=Je()-l)?120:480>l?480:1080>l?1080:1920>l?1920:3e3>l?3e3:4320>l?4320:1960*Cu(l/1960))-l)){e.timeoutHandle=ll(ws.bind(null,e,Bu,$u),l);break}ws(e,Bu,$u);break;default:throw Error(n(329))}}}return ls(e,Je()),e.callbackNode===r?os.bind(null,e):null}function as(e,t){var n=Uu;return e.current.memoizedState.isDehydrated&&(ps(e,t).flags|=256),2!==(e=ys(e,t))&&(t=Bu,Bu=n,null!==t&&is(t)),e}function is(e){null===Bu?Bu=e:Bu.push.apply(Bu,e)}function us(e,t){for(t&=~Au,t&=~Fu,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-it(t),r=1<<n;e[n]=-1,t&=~r}}function ss(e){if(6&Iu)throw Error(n(327));Ss();var t=pt(e,0);if(!(1&t))return ls(e,Je()),null;var r=ys(e,t);if(0!==e.tag&&2===r){var l=mt(e);0!==l&&(t=l,r=as(e,l))}if(1===r)throw r=Ou,ps(e,0),us(e,t),ls(e,Je()),r;if(6===r)throw Error(n(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ws(e,Bu,$u),ls(e,Je()),null}function cs(e,t){var n=Iu;Iu|=1;try{return e(t)}finally{0===(Iu=n)&&(Vu=Je()+500,Ul&&Vl())}}function fs(e){null!==Yu&&0===Yu.tag&&!(6&Iu)&&Ss();var t=Iu;Iu|=1;var n=Pu.transition,r=kt;try{if(Pu.transition=null,kt=1,e)return e()}finally{kt=r,Pu.transition=n,!(6&(Iu=t))&&Vl()}}function ds(){Mu=ju.current,El(ju)}function ps(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,ol(n)),null!==Lu)for(n=Lu.return;null!==n;){var r=n;switch(no(r),r.tag){case 1:null!=(r=r.type.childContextTypes)&&jl();break;case 3:Jo(),El(Tl),El(Il),la();break;case 5:ea(r);break;case 4:Jo();break;case 13:case 19:El(ta);break;case 10:Io(r.type._context);break;case 22:case 23:ds()}n=n.return}if(Tu=e,Lu=e=js(e.current,null),zu=Mu=t,Du=0,Ou=null,Au=Fu=Ru=0,Bu=Uu=null,null!==Mo){for(t=0;t<Mo.length;t++)if(null!==(r=(n=Mo[t]).interleaved)){n.interleaved=null;var l=r.next,o=n.pending;if(null!==o){var a=o.next;o.next=l,r.next=a}n.pending=r}Mo=null}return e}function hs(e,t){for(;;){var r=Lu;try{if(Po(),oa.current=Ga,fa){for(var l=ua.memoizedState;null!==l;){var o=l.queue;null!==o&&(o.pending=null),l=l.next}fa=!1}if(ia=0,ca=sa=ua=null,da=!1,pa=0,Nu.current=null,null===r||null===r.return){Du=1,Ou=t,Lu=null;break}e:{var a=e,i=r.return,u=r,s=t;if(t=zu,u.flags|=32768,null!==s&&"object"==typeof s&&"function"==typeof s.then){var c=s,f=u,d=f.tag;if(!(1&f.mode||0!==d&&11!==d&&15!==d)){var p=f.alternate;p?(f.updateQueue=p.updateQueue,f.memoizedState=p.memoizedState,f.lanes=p.lanes):(f.updateQueue=null,f.memoizedState=null)}var h=yi(i);if(null!==h){h.flags&=-257,vi(h,i,u,0,t),1&h.mode&&gi(a,c,t),s=c;var m=(t=h).updateQueue;if(null===m){var g=new Set;g.add(s),t.updateQueue=g}else m.add(s);break e}if(!(1&t)){gi(a,c,t),gs();break e}s=Error(n(426))}else if(oo&&1&u.mode){var y=yi(i);if(null!==y){!(65536&y.flags)&&(y.flags|=256),vi(y,i,u,0,t),go(ci(s,u));break e}}a=s=ci(s,u),4!==Du&&(Du=2),null===Uu?Uu=[a]:Uu.push(a),a=i;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t,Vo(a,hi(0,s,t));break e;case 1:u=s;var v=a.type,b=a.stateNode;if(!(128&a.flags||"function"!=typeof v.getDerivedStateFromError&&(null===b||"function"!=typeof b.componentDidCatch||null!==Qu&&Qu.has(b)))){a.flags|=65536,t&=-t,a.lanes|=t,Vo(a,mi(a,u,t));break e}}a=a.return}while(null!==a)}xs(r)}catch(k){t=k,Lu===r&&null!==r&&(Lu=r=r.return);continue}break}}function ms(){var e=Eu.current;return Eu.current=Ga,null===e?Ga:e}function gs(){0!==Du&&3!==Du&&2!==Du||(Du=4),null===Tu||!(268435455&Ru)&&!(268435455&Fu)||us(Tu,zu)}function ys(e,t){var r=Iu;Iu|=2;var l=ms();for(Tu===e&&zu===t||($u=null,ps(e,t));;)try{vs();break}catch(o){hs(e,o)}if(Po(),Iu=r,Eu.current=l,null!==Lu)throw Error(n(261));return Tu=null,zu=0,Du}function vs(){for(;null!==Lu;)ks(Lu)}function bs(){for(;null!==Lu&&!Xe();)ks(Lu)}function ks(e){var t=_u(e.alternate,e,Mu);e.memoizedProps=e.pendingProps,null===t?xs(e):Lu=t,Nu.current=null}function xs(e){var t=e;do{var n=t.alternate;if(e=t.return,32768&t.flags){if(null!==(n=Yi(n,t)))return n.flags&=32767,void(Lu=n);if(null===e)return Du=6,void(Lu=null);e.flags|=32768,e.subtreeFlags=0,e.deletions=null}else if(null!==(n=Ki(n,t,Mu)))return void(Lu=n);if(null!==(t=t.sibling))return void(Lu=t);Lu=t=e}while(null!==t);0===Du&&(Du=5)}function ws(e,t,r){var l=kt,o=Pu.transition;try{Pu.transition=null,kt=1,function(e,t,r,l){do{Ss()}while(null!==Yu);if(6&Iu)throw Error(n(327));r=e.finishedWork;var o=e.finishedLanes;if(null===r)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(n(177));e.callbackNode=null,e.callbackPriority=0;var a=r.lanes|r.childLanes;if(function(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var l=31-it(n),o=1<<l;t[l]=0,r[l]=-1,e[l]=-1,n&=~o}}(e,a),e===Tu&&(Lu=Tu=null,zu=0),!(2064&r.subtreeFlags)&&!(2064&r.flags)||Ku||(Ku=!0,Ts(nt,function(){return Ss(),null})),a=!!(15990&r.flags),!!(15990&r.subtreeFlags)||a){a=Pu.transition,Pu.transition=null;var i=kt;kt=1;var u=Iu;Iu|=4,Nu.current=null,function(e,t){if(tl=Wt,hr(e=pr())){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{var l=(r=(r=e.ownerDocument)&&r.defaultView||window).getSelection&&r.getSelection();if(l&&0!==l.rangeCount){r=l.anchorNode;var o=l.anchorOffset,a=l.focusNode;l=l.focusOffset;try{r.nodeType,a.nodeType}catch(x){r=null;break e}var i=0,u=-1,s=-1,c=0,f=0,d=e,p=null;t:for(;;){for(var h;d!==r||0!==o&&3!==d.nodeType||(u=i+o),d!==a||0!==l&&3!==d.nodeType||(s=i+l),3===d.nodeType&&(i+=d.nodeValue.length),null!==(h=d.firstChild);)p=d,d=h;for(;;){if(d===e)break t;if(p===r&&++c===o&&(u=i),p===a&&++f===l&&(s=i),null!==(h=d.nextSibling))break;p=(d=p).parentNode}d=h}r=-1===u||-1===s?null:{start:u,end:s}}else r=null}r=r||{start:0,end:0}}else r=null;for(nl={focusedElem:e,selectionRange:r},Wt=!1,Gi=t;null!==Gi;)if(e=(t=Gi).child,1028&t.subtreeFlags&&null!==e)e.return=t,Gi=e;else for(;null!==Gi;){t=Gi;try{var m=t.alternate;if(1024&t.flags)switch(t.tag){case 0:case 11:case 15:case 5:case 6:case 4:case 17:break;case 1:if(null!==m){var g=m.memoizedProps,y=m.memoizedState,v=t.stateNode,b=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:ri(t.type,g),y);v.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var k=t.stateNode.containerInfo;1===k.nodeType?k.textContent="":9===k.nodeType&&k.documentElement&&k.removeChild(k.documentElement);break;default:throw Error(n(163))}}catch(x){Cs(t,t.return,x)}if(null!==(e=t.sibling)){e.return=t.return,Gi=e;break}Gi=t.return}m=nu,nu=!1}(e,r),yu(r,e),mr(nl),Wt=!!tl,nl=tl=null,e.current=r,bu(r),Ze(),Iu=u,kt=i,Pu.transition=a}else e.current=r;if(Ku&&(Ku=!1,Yu=e,Xu=o),a=e.pendingLanes,0===a&&(Qu=null),function(e){if(at&&"function"==typeof at.onCommitFiberRoot)try{at.onCommitFiberRoot(ot,e,void 0,!(128&~e.current.flags))}catch(t){}}(r.stateNode),ls(e,Je()),null!==t)for(l=e.onRecoverableError,r=0;r<t.length;r++)o=t[r],l(o.value,{componentStack:o.stack,digest:o.digest});if(Wu)throw Wu=!1,e=qu,qu=null,e;!!(1&Xu)&&0!==e.tag&&Ss(),a=e.pendingLanes,1&a?e===Ju?Zu++:(Zu=0,Ju=e):Zu=0,Vl()}(e,t,r,l)}finally{Pu.transition=o,kt=l}return null}function Ss(){if(null!==Yu){var e=xt(Xu),t=Pu.transition,r=kt;try{if(Pu.transition=null,kt=16>e?16:e,null===Yu)var l=!1;else{if(e=Yu,Yu=null,Xu=0,6&Iu)throw Error(n(331));var o=Iu;for(Iu|=4,Gi=e.current;null!==Gi;){var a=Gi,i=a.child;if(16&Gi.flags){var u=a.deletions;if(null!==u){for(var s=0;s<u.length;s++){var c=u[s];for(Gi=c;null!==Gi;){var f=Gi;switch(f.tag){case 0:case 11:case 15:ru(8,f,a)}var d=f.child;if(null!==d)d.return=f,Gi=d;else for(;null!==Gi;){var p=(f=Gi).sibling,h=f.return;if(au(f),f===c){Gi=null;break}if(null!==p){p.return=h,Gi=p;break}Gi=h}}}var m=a.alternate;if(null!==m){var g=m.child;if(null!==g){m.child=null;do{var y=g.sibling;g.sibling=null,g=y}while(null!==g)}}Gi=a}}if(2064&a.subtreeFlags&&null!==i)i.return=a,Gi=i;else e:for(;null!==Gi;){if(2048&(a=Gi).flags)switch(a.tag){case 0:case 11:case 15:ru(9,a,a.return)}var v=a.sibling;if(null!==v){v.return=a.return,Gi=v;break e}Gi=a.return}}var b=e.current;for(Gi=b;null!==Gi;){var k=(i=Gi).child;if(2064&i.subtreeFlags&&null!==k)k.return=i,Gi=k;else e:for(i=b;null!==Gi;){if(2048&(u=Gi).flags)try{switch(u.tag){case 0:case 11:case 15:lu(9,u)}}catch(w){Cs(u,u.return,w)}if(u===i){Gi=null;break e}var x=u.sibling;if(null!==x){x.return=u.return,Gi=x;break e}Gi=u.return}}if(Iu=o,Vl(),at&&"function"==typeof at.onPostCommitFiberRoot)try{at.onPostCommitFiberRoot(ot,e)}catch(w){}l=!0}return l}finally{kt=r,Pu.transition=t}}return!1}function _s(e,t,n){e=Bo(e,t=hi(0,t=ci(n,t),1),1),t=ts(),null!==e&&(vt(e,1,t),ls(e,t))}function Cs(e,t,n){if(3===e.tag)_s(e,e,n);else for(;null!==t;){if(3===t.tag){_s(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===Qu||!Qu.has(r))){t=Bo(t,e=mi(t,e=ci(n,e),1),1),e=ts(),null!==t&&(vt(t,1,e),ls(t,e));break}}t=t.return}}function Es(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),t=ts(),e.pingedLanes|=e.suspendedLanes&n,Tu===e&&(zu&n)===n&&(4===Du||3===Du&&(130023424&zu)===zu&&500>Je()-Hu?ps(e,0):Au|=n),ls(e,t)}function Ns(e,t){0===t&&(1&e.mode?(t=ft,!(130023424&(ft<<=1))&&(ft=4194304)):t=1);var n=ts();null!==(e=Oo(e,t))&&(vt(e,t,n),ls(e,n))}function Ps(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Ns(e,n)}function Is(e,t){var r=0;switch(e.tag){case 13:var l=e.stateNode,o=e.memoizedState;null!==o&&(r=o.retryLane);break;case 19:l=e.stateNode;break;default:throw Error(n(314))}null!==l&&l.delete(t),Ns(e,r)}function Ts(e,t){return Ke(e,t)}function Ls(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function zs(e,t,n,r){return new Ls(e,t,n,r)}function Ms(e){return!(!(e=e.prototype)||!e.isReactComponent)}function js(e,t){var n=e.alternate;return null===n?((n=zs(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ds(e,t,r,l,o,a){var i=2;if(l=e,"function"==typeof e)Ms(e)&&(i=1);else if("string"==typeof e)i=5;else e:switch(e){case _:return Os(r.children,o,a,t);case C:i=8,o|=8;break;case E:return(e=zs(12,r,t,2|o)).elementType=E,e.lanes=a,e;case T:return(e=zs(13,r,t,o)).elementType=T,e.lanes=a,e;case L:return(e=zs(19,r,t,o)).elementType=L,e.lanes=a,e;case j:return Rs(r,o,a,t);default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case N:i=10;break e;case P:i=9;break e;case I:i=11;break e;case z:i=14;break e;case M:i=16,l=null;break e}throw Error(n(130,null==e?e:typeof e,""))}return(t=zs(i,r,t,o)).elementType=e,t.type=l,t.lanes=a,t}function Os(e,t,n,r){return(e=zs(7,e,r,t)).lanes=n,e}function Rs(e,t,n,r){return(e=zs(22,e,r,t)).elementType=j,e.lanes=n,e.stateNode={isHidden:!1},e}function Fs(e,t,n){return(e=zs(6,e,null,t)).lanes=n,e}function As(e,t,n){return(t=zs(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Us(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=yt(0),this.expirationTimes=yt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=yt(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Bs(e,t,n,r,l,o,a,i,u){return e=new Us(e,t,n,i,u),1===t?(t=1,!0===o&&(t|=8)):t=0,o=zs(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Fo(o),e}function Hs(e){if(!e)return Pl;e:{if(Ve(e=e._reactInternals)!==e||1!==e.tag)throw Error(n(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ml(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(n(171))}if(1===e.tag){var r=e.type;if(Ml(r))return Ol(e,r,t)}return t}function Vs(e,t,n,r,l,o,a,i,u){return(e=Bs(n,r,!0,e,0,o,0,i,u)).context=Hs(null),n=e.current,(o=Uo(r=ts(),l=ns(n))).callback=null!=t?t:null,Bo(n,o,l),e.current.lanes=l,vt(e,l,r),ls(e,r),e}function $s(e,t,n,r){var l=t.current,o=ts(),a=ns(l);return n=Hs(n),null===t.context?t.context=n:t.pendingContext=n,(t=Uo(o,a)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),null!==(e=Bo(l,t,a))&&(rs(e,l,a,o),Ho(e,l,a)),a}function Ws(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function qs(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function Qs(e,t){qs(e,t),(e=e.alternate)&&qs(e,t)}_u=function(e,t,r){if(null!==e)if(e.memoizedProps!==t.pendingProps||Tl.current)ki=!0;else{if(0===(e.lanes&r)&&!(128&t.flags))return ki=!1,function(e,t,n){switch(t.tag){case 3:Ti(t),mo();break;case 5:Go(t);break;case 1:Ml(t.type)&&Rl(t);break;case 4:Zo(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,l=t.memoizedProps.value;Nl(_o,r._currentValue),r._currentValue=l;break;case 13:if(null!==(r=t.memoizedState))return null!==r.dehydrated?(Nl(ta,1&ta.current),t.flags|=128,null):0!==(n&t.child.childLanes)?Fi(e,t,n):(Nl(ta,1&ta.current),null!==(e=Wi(e,t,n))?e.sibling:null);Nl(ta,1&ta.current);break;case 19:if(r=0!==(n&t.childLanes),128&e.flags){if(r)return Vi(e,t,n);t.flags|=128}if(null!==(l=t.memoizedState)&&(l.rendering=null,l.tail=null,l.lastEffect=null),Nl(ta,ta.current),r)break;return null;case 22:case 23:return t.lanes=0,Ci(e,t,n)}return Wi(e,t,n)}(e,t,r);ki=!!(131072&e.flags)}else ki=!1,oo&&1048576&t.flags&&eo(t,Ql,t.index);switch(t.lanes=0,t.tag){case 2:var l=t.type;$i(e,t),e=t.pendingProps;var o=zl(t,Il.current);Lo(t,r),o=ya(null,t,l,e,o,r);var a=va();return t.flags|=1,"object"==typeof o&&null!==o&&"function"==typeof o.render&&void 0===o.$$typeof?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ml(l)?(a=!0,Rl(t)):a=!1,t.memoizedState=null!==o.state&&void 0!==o.state?o.state:null,Fo(t),o.updater=oi,t.stateNode=o,o._reactInternals=t,si(t,l,e,r),t=Ii(null,t,l,!0,a,r)):(t.tag=0,oo&&a&&to(t),xi(null,t,o,r),t=t.child),t;case 16:l=t.elementType;e:{switch($i(e,t),e=t.pendingProps,l=(o=l._init)(l._payload),t.type=l,o=t.tag=function(e){if("function"==typeof e)return Ms(e)?1:0;if(null!=e){if((e=e.$$typeof)===I)return 11;if(e===z)return 14}return 2}(l),e=ri(l,e),o){case 0:t=Ni(null,t,l,e,r);break e;case 1:t=Pi(null,t,l,e,r);break e;case 11:t=wi(null,t,l,e,r);break e;case 14:t=Si(null,t,l,ri(l.type,e),r);break e}throw Error(n(306,l,""))}return t;case 0:return l=t.type,o=t.pendingProps,Ni(e,t,l,o=t.elementType===l?o:ri(l,o),r);case 1:return l=t.type,o=t.pendingProps,Pi(e,t,l,o=t.elementType===l?o:ri(l,o),r);case 3:e:{if(Ti(t),null===e)throw Error(n(387));l=t.pendingProps,o=(a=t.memoizedState).element,Ao(e,t),$o(t,l,null,r);var i=t.memoizedState;if(l=i.element,a.isDehydrated){if(a={element:l,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=a,t.memoizedState=a,256&t.flags){t=Li(e,t,l,r,o=ci(Error(n(423)),t));break e}if(l!==o){t=Li(e,t,l,r,o=ci(Error(n(424)),t));break e}for(lo=cl(t.stateNode.containerInfo.firstChild),ro=t,oo=!0,ao=null,r=So(t,null,l,r),t.child=r;r;)r.flags=-3&r.flags|4096,r=r.sibling}else{if(mo(),l===o){t=Wi(e,t,r);break e}xi(e,t,l,r)}t=t.child}return t;case 5:return Go(t),null===e&&co(t),l=t.type,o=t.pendingProps,a=null!==e?e.memoizedProps:null,i=o.children,rl(l,o)?i=null:null!==a&&rl(l,a)&&(t.flags|=32),Ei(e,t),xi(e,t,i,r),t.child;case 6:return null===e&&co(t),null;case 13:return Fi(e,t,r);case 4:return Zo(t,t.stateNode.containerInfo),l=t.pendingProps,null===e?t.child=wo(t,null,l,r):xi(e,t,l,r),t.child;case 11:return l=t.type,o=t.pendingProps,wi(e,t,l,o=t.elementType===l?o:ri(l,o),r);case 7:return xi(e,t,t.pendingProps,r),t.child;case 8:case 12:return xi(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(l=t.type._context,o=t.pendingProps,a=t.memoizedProps,i=o.value,Nl(_o,l._currentValue),l._currentValue=i,null!==a)if(ur(a.value,i)){if(a.children===o.children&&!Tl.current){t=Wi(e,t,r);break e}}else for(null!==(a=t.child)&&(a.return=t);null!==a;){var u=a.dependencies;if(null!==u){i=a.child;for(var s=u.firstContext;null!==s;){if(s.context===l){if(1===a.tag){(s=Uo(-1,r&-r)).tag=2;var c=a.updateQueue;if(null!==c){var f=(c=c.shared).pending;null===f?s.next=s:(s.next=f.next,f.next=s),c.pending=s}}a.lanes|=r,null!==(s=a.alternate)&&(s.lanes|=r),To(a.return,r,t),u.lanes|=r;break}s=s.next}}else if(10===a.tag)i=a.type===t.type?null:a.child;else if(18===a.tag){if(null===(i=a.return))throw Error(n(341));i.lanes|=r,null!==(u=i.alternate)&&(u.lanes|=r),To(i,r,t),i=a.sibling}else i=a.child;if(null!==i)i.return=a;else for(i=a;null!==i;){if(i===t){i=null;break}if(null!==(a=i.sibling)){a.return=i.return,i=a;break}i=i.return}a=i}xi(e,t,o.children,r),t=t.child}return t;case 9:return o=t.type,l=t.pendingProps.children,Lo(t,r),l=l(o=zo(o)),t.flags|=1,xi(e,t,l,r),t.child;case 14:return o=ri(l=t.type,t.pendingProps),Si(e,t,l,o=ri(l.type,o),r);case 15:return _i(e,t,t.type,t.pendingProps,r);case 17:return l=t.type,o=t.pendingProps,o=t.elementType===l?o:ri(l,o),$i(e,t),t.tag=1,Ml(l)?(e=!0,Rl(t)):e=!1,Lo(t,r),ii(t,l,o),si(t,l,o,r),Ii(null,t,l,!0,e,r);case 19:return Vi(e,t,r);case 22:return Ci(e,t,r)}throw Error(n(156,t.tag))};var Ks="function"==typeof reportError?reportError:function(e){console.error(e)};function Ys(e){this._internalRoot=e}function Xs(e){this._internalRoot=e}function Zs(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function Js(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function Gs(){}function ec(e,t,n,r,l){var o=n._reactRootContainer;if(o){var a=o;if("function"==typeof l){var i=l;l=function(){var e=Ws(a);i.call(e)}}$s(t,a,e,l)}else a=function(e,t,n,r,l){if(l){if("function"==typeof r){var o=r;r=function(){var e=Ws(a);o.call(e)}}var a=Vs(t,r,e,0,null,!1,0,"",Gs);return e._reactRootContainer=a,e[ml]=a.current,Vr(8===e.nodeType?e.parentNode:e),fs(),a}for(;l=e.lastChild;)e.removeChild(l);if("function"==typeof r){var i=r;r=function(){var e=Ws(u);i.call(e)}}var u=Bs(e,0,!1,null,0,!1,0,"",Gs);return e._reactRootContainer=u,e[ml]=u.current,Vr(8===e.nodeType?e.parentNode:e),fs(function(){$s(t,u,n,r)}),u}(n,t,e,l,r);return Ws(a)}Xs.prototype.render=Ys.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(n(409));$s(e,t,null,null)},Xs.prototype.unmount=Ys.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;fs(function(){$s(null,e,null,null)}),t[ml]=null}},Xs.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ct();e={blockedOn:null,target:e,priority:t};for(var n=0;n<jt.length&&0!==t&&t<jt[n].priority;n++);jt.splice(n,0,e),0===n&&Ft(e)}},wt=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=dt(t.pendingLanes);0!==n&&(bt(t,1|n),ls(t,Je()),!(6&Iu)&&(Vu=Je()+500,Vl()))}break;case 13:fs(function(){var t=Oo(e,1);if(null!==t){var n=ts();rs(t,e,1,n)}}),Qs(e,1)}},St=function(e){if(13===e.tag){var t=Oo(e,134217728);if(null!==t)rs(t,e,134217728,ts());Qs(e,134217728)}},_t=function(e){if(13===e.tag){var t=ns(e),n=Oo(e,t);if(null!==n)rs(n,e,t,ts());Qs(e,t)}},Ct=function(){return kt},Et=function(e,t){var n=kt;try{return kt=e,t()}finally{kt=n}},Se=function(e,t,r){switch(t){case"input":if(G(e,r),t=r.name,"radio"===r.type&&null!=t){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<r.length;t++){var l=r[t];if(l!==e&&l.form===e.form){var o=wl(l);if(!o)throw Error(n(90));K(l),G(l,o)}}}break;case"textarea":ae(e,r);break;case"select":null!=(t=r.value)&&re(e,!!r.multiple,t,!1)}},Ie=cs,Te=fs;var tc={usingClientEntryPoint:!1,Events:[kl,xl,wl,Ne,Pe,cs]},nc={findFiberByHostInstance:bl,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},rc={bundleType:nc.bundleType,version:nc.version,rendererPackageName:nc.rendererPackageName,rendererConfig:nc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:k.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=qe(e))?null:e.stateNode},findFiberByHostInstance:nc.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var lc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lc.isDisabled&&lc.supportsFiber)try{ot=lc.inject(rc),at=lc}catch(fe){}}return b.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tc,b.createPortal=function(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!Zs(t))throw Error(n(200));return function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:S,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}(e,t,null,r)},b.createRoot=function(e,t){if(!Zs(e))throw Error(n(299));var r=!1,l="",o=Ks;return null!=t&&(!0===t.unstable_strictMode&&(r=!0),void 0!==t.identifierPrefix&&(l=t.identifierPrefix),void 0!==t.onRecoverableError&&(o=t.onRecoverableError)),t=Bs(e,1,!1,null,0,r,0,l,o),e[ml]=t.current,Vr(8===e.nodeType?e.parentNode:e),new Ys(t)},b.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(n(188));throw e=Object.keys(e).join(","),Error(n(268,e))}return e=null===(e=qe(t))?null:e.stateNode},b.flushSync=function(e){return fs(e)},b.hydrate=function(e,t,r){if(!Js(t))throw Error(n(200));return ec(null,e,t,!0,r)},b.hydrateRoot=function(e,t,r){if(!Zs(e))throw Error(n(405));var l=null!=r&&r.hydratedSources||null,o=!1,a="",i=Ks;if(null!=r&&(!0===r.unstable_strictMode&&(o=!0),void 0!==r.identifierPrefix&&(a=r.identifierPrefix),void 0!==r.onRecoverableError&&(i=r.onRecoverableError)),t=Vs(t,null,e,1,null!=r?r:null,o,0,a,i),e[ml]=t.current,Vr(e),l)for(e=0;e<l.length;e++)o=(o=(r=l[e])._getVersion)(r._source),null==t.mutableSourceEagerHydrationData?t.mutableSourceEagerHydrationData=[r,o]:t.mutableSourceEagerHydrationData.push(r,o);return new Xs(t)},b.render=function(e,t,r){if(!Js(t))throw Error(n(200));return ec(null,e,t,!1,r)},b.unmountComponentAtNode=function(e){if(!Js(e))throw Error(n(40));return!!e._reactRootContainer&&(fs(function(){ec(null,null,e,!1,function(){e._reactRootContainer=null,e[ml]=null})}),!0)},b.unstable_batchedUpdates=cs,b.unstable_renderSubtreeIntoContainer=function(e,t,r,l){if(!Js(r))throw Error(n(200));if(null==e||void 0===e._reactInternals)throw Error(n(38));return ec(e,t,r,!1,l)},b.version="18.3.1-next-f1338f8080-20240426",b}var _,C,E=function(){if(g)return y;g=1;var e=(m||(m=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),v.exports=S()),v.exports);return y.createRoot=e.createRoot,y.hydrateRoot=e.hydrateRoot,y}(),N={exports:{}},P={};var I=(C||(C=1,N.exports=function(){if(_)return P;_=1;var e=s(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,l=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(e,n,a){var i,u={},s=null,c=null;for(i in void 0!==a&&(s=""+a),void 0!==n.key&&(s=""+n.key),void 0!==n.ref&&(c=n.ref),n)r.call(n,i)&&!o.hasOwnProperty(i)&&(u[i]=n[i]);if(e&&e.defaultProps)for(i in n=e.defaultProps)void 0===u[i]&&(u[i]=n[i]);return{$$typeof:t,type:e,key:s,ref:c,props:u,_owner:l.current}}return P.Fragment=n,P.jsx=a,P.jsxs=a,P}()),N.exports);const T="bb-chat-";function L(e,t){try{sessionStorage.setItem(`${T}${e}`,JSON.stringify(t))}catch{}}function z(e){try{sessionStorage.removeItem(`${T}${e}`)}catch{}}function M(e){const{config:t,apiClient:n,mockMode:r,onSessionStart:l,onSessionEnd:o,onMessage:a,onError:i}=e,[u,s]=c.useState([]),[f,d]=c.useState([]),[p,h]=c.useState(!1),[m,g]=c.useState(null),[y,v]=c.useState(null),b=c.useRef(0),k=c.useRef(!1),x=c.useRef({});c.useEffect(()=>{if(k.current)return;k.current=!0;const e=function(e){try{const t=sessionStorage.getItem(`${T}${e}`);return t?JSON.parse(t):null}catch{return null}}(t.embedId);e&&"active"===e.status&&(v(e.sessionId),s(e.messages),d(e.toolCalls),b.current=e.startTime)},[t.embedId]),c.useEffect(()=>{y&&u.length>0&&L(t.embedId,{sessionId:y,deploymentId:t.deploymentId,workerId:t.workerId,flowId:t.flowId,startTime:b.current,messages:u,toolCalls:f,status:"active"})},[y,u,f,t]);const w=c.useCallback(async()=>(b.current=Date.now(),v(null),s([]),d([]),z(t.embedId),""),[t.embedId]),S=c.useCallback((e,t)=>{s(n=>{let r=!1;const l=n.map(n=>n.id===e?(r=!0,{...n,content:t,status:"streaming"}):n);return r||l.push({id:e,role:"assistant",content:t,timestamp:Date.now(),status:"streaming"}),l})},[]),_=c.useCallback((e,n,r)=>{switch(e.type){case"session":{const t=e.data;t.session_id&&(r(t.session_id),t.is_new&&(b.current=Date.now(),null==l||l(t.session_id)));break}case"message":{const t=e.data;t.content&&(x.current[n]=t.content,S(n,t.content));break}case"chunk":{const t=e.data;if(t.content){const e=(x.current[n]??"")+t.content;x.current[n]=e,S(n,e)}break}case"tool_call":{const t=e.data;if(d(e=>{const n=e.findIndex(e=>e.name===t.function&&"pending"===e.status);return-1!==n&&void 0!==t.result?e.map((e,r)=>r===n?{...e,result:t.result,status:"completed"}:e):-1===n?[...e,{id:`tc-${Date.now()}-${Math.random().toString(36).slice(2)}`,name:t.function,arguments:t.args??{},status:"pending",timestamp:Date.now()}]:e}),t.content){const e=t.content;x.current[n]=e,S(n,e)}break}case"waiting":break;case"done":s(e=>e.map(e=>e.id===n?{...e,status:"sent"}:e)),delete x.current[n];break;case"completed":s(e=>{const r=e.map(e=>e.id===n?{...e,status:"sent"}:e);return y&&L(t.embedId,{sessionId:y,deploymentId:t.deploymentId,workerId:t.workerId,flowId:t.flowId,startTime:b.current,messages:r,toolCalls:[],status:"completed"}),r}),delete x.current[n];break;case"error":{const t=e.data;s(e=>e.map(e=>e.id===n?{...e,status:"error",content:t.error??"An error occurred"}:e));break}}},[t,y,l,S]),C=c.useCallback(async(e,t,n)=>{const r=e.getReader(),l=new TextDecoder;let o="";try{for(;;){const{done:e,value:a}=await r.read();if(e)break;let i;for(o+=l.decode(a,{stream:!0});-1!==(i=o.indexOf("\n\n"));){const e=o.slice(0,i);o=o.slice(i+2);for(const r of e.split("\n"))if(r.startsWith("data: "))try{const e=JSON.parse(r.slice(6));_(e,t,n)}catch{}}}}finally{r.releaseLock()}},[_]),E=c.useCallback(async e=>{if(!e.trim())return;const l={id:`user-${Date.now()}`,role:"user",content:e,timestamp:Date.now(),status:"sent"};s(e=>[...e,l]),null==a||a(l);const o=`assistant-${Date.now()}`,u={id:o,role:"assistant",content:"",timestamp:Date.now(),status:"streaming"};s(e=>[...e,u]),h(!0),g(null);const c=e=>{v(e)};try{if(r){const t=n.sendMessage(e);for await(const e of t)_(e,o,c)}else{const r=await n.sendMessage({embedId:t.embedId,message:e,sessionId:y??void 0});await C(r,o,c)}s(e=>e.map(e=>e.id===o&&"streaming"===e.status?{...e,status:"sent"}:e))}catch(f){const e=f instanceof Error?f:new Error("Failed to send message");g(e),null==i||i(e),s(e=>e.map(e=>e.id===o?{...e,status:"error",content:"Failed to get response"}:e))}finally{h(!1)}},[y,n,r,t.embedId,_,C,a,i]),N=c.useCallback(async()=>{if(!y)return;const e={sessionId:y,deploymentId:t.deploymentId,workerId:t.workerId,flowId:t.flowId,startTime:b.current,messages:u,toolCalls:f,status:"completed"};null==o||o(e),z(t.embedId),v(null),s([]),d([])},[y,t,u,f,o]),P=c.useCallback(()=>{s([]),d([])},[]);return{messages:u,toolCalls:f,isLoading:p,error:m,sessionId:y,sendMessage:E,endSession:N,clearMessages:P,startNewSession:w}}const j="https://chat-embed-deployment.onrender.com";const D={embedId:"mock-embed-id",deploymentId:"mock-deployment-id",workerId:"mock-worker-id",flowId:"mock-flow-id",agentName:"AI Assistant",agentLogoUrl:void 0,primaryColor:"#1a1a2e",styling:{}},O=[{trigger:/hello|hi|hey/i,response:"Hello! I'm a demo AI assistant. How can I help you today?",delay:500},{trigger:/weather/i,response:"I'd check the weather for you, but I'm in mock mode! In production, I could use a weather API.",delay:800,toolCalls:[{name:"get_weather",arguments:{location:"San Francisco"},result:{temperature:72,condition:"sunny"}}]},{trigger:/help|support/i,response:"I'm here to help! You can ask me questions, and I'll do my best to assist you. In production, I'd be connected to your agent with full capabilities.",delay:600},{trigger:/pricing|cost|price/i,response:"For pricing information, I'd typically check our database or connect you with the sales team. This is a mock response demonstrating how I'd handle pricing questions.",delay:700,toolCalls:[{name:"lookup_pricing",arguments:{plan:"all"},result:{plans:[{name:"Starter",price:"$29/mo"},{name:"Pro",price:"$99/mo"}]}}]},{trigger:/.*/,response:"I'm running in mock mode. This is a simulated response to demonstrate the chat UI. In production, I'd be connected to your agent!",delay:1e3}];function R(e){return new Promise(t=>setTimeout(t,e))}const F=({className:e,color:t="currentColor",cutoutColor:n="var(--bb-primary-color)"})=>I.jsxs("svg",{className:e,viewBox:"0 0 800 800",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",fill:t}),I.jsx("circle",{cx:"400",cy:"400",r:"400",fill:t}),I.jsx("path",{d:"M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",fill:t}),I.jsx("path",{d:"M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",fill:t}),I.jsx("circle",{cx:"400",cy:"400",r:"350",fill:t}),I.jsx("path",{d:"M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",fill:t}),I.jsx("rect",{x:"399.919",y:"209",width:"270",height:"270",rx:"12",transform:"rotate(45 399.919 209)",fill:n})]}),A="_header_1p6z5_1",U="_compact_1p6z5_9",B="_headerBackground_1p6z5_20",H="_headerContent_1p6z5_59",V="_topRow_1p6z5_64",$="_agentInfo_1p6z5_79",W="_agentLogo_1p6z5_85",q="_agentLogoPlaceholder_1p6z5_102",Q="_brainbaseLogo_1p6z5_123",K="_agentName_1p6z5_137",Y="_actions_1p6z5_144",X="_actionButton_1p6z5_149",Z="_welcomeText_1p6z5_183",J="_title_1p6z5_202",G="_subtitle_1p6z5_210",ee=({agentName:e="AI Assistant",agentLogoUrl:t,welcomeTitle:n,welcomeSubtitle:r,onClose:l,onNewChatRequest:o,showNewChatButton:a=!1,compact:i=!1})=>{const u=n||"Hello there.",s=void 0!==r?r:n?void 0:"How can we help?";return I.jsxs("div",{className:`${A} ${i?U:""}`,children:[I.jsx("div",{className:B}),I.jsxs("div",{className:H,children:[I.jsxs("div",{className:V,children:[I.jsxs("div",{className:$,children:[t?I.jsx("img",{src:t,alt:e,className:W}):I.jsx("div",{className:q,children:I.jsx(F,{className:Q,color:"white",cutoutColor:"var(--bb-primary-color)"})}),I.jsx("span",{className:K,children:e})]}),I.jsxs("div",{className:Y,children:[a&&o&&I.jsx("button",{className:X,onClick:o,"aria-label":"Start new chat",type:"button",children:I.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:I.jsx("path",{d:"M12 5V19M5 12H19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),l&&I.jsx("button",{className:X,onClick:l,"aria-label":"Close chat",type:"button",children:I.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:I.jsx("path",{d:"M6 18L18 6M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),!i&&I.jsxs("div",{className:Z,children:[I.jsx("h1",{className:J,children:u}),s&&I.jsx("p",{className:G,children:s})]})]})]})};function te(){}function ne(){}const re=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,le=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,oe={};function ae(e,t){return(oe.jsx?le:re).test(e)}const ie=/[ \t\n\f\r]/g;function ue(e){return""===e.replace(ie,"")}class se{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function ce(e,t){const n={},r={};for(const l of e)Object.assign(n,l.property),Object.assign(r,l.normal);return new se(n,r,t)}function fe(e){return e.toLowerCase()}se.prototype.normal={},se.prototype.property={},se.prototype.space=void 0;class de{constructor(e,t){this.attribute=t,this.property=e}}de.prototype.attribute="",de.prototype.booleanish=!1,de.prototype.boolean=!1,de.prototype.commaOrSpaceSeparated=!1,de.prototype.commaSeparated=!1,de.prototype.defined=!1,de.prototype.mustUseProperty=!1,de.prototype.number=!1,de.prototype.overloadedBoolean=!1,de.prototype.property="",de.prototype.spaceSeparated=!1,de.prototype.space=void 0;let pe=0;const he=xe(),me=xe(),ge=xe(),ye=xe(),ve=xe(),be=xe(),ke=xe();function xe(){return 2**++pe}const we=Object.freeze(Object.defineProperty({__proto__:null,boolean:he,booleanish:me,commaOrSpaceSeparated:ke,commaSeparated:be,number:ye,overloadedBoolean:ge,spaceSeparated:ve},Symbol.toStringTag,{value:"Module"})),Se=Object.keys(we);class _e extends de{constructor(e,t,n,r){let l=-1;if(super(e,t),Ce(this,"space",r),"number"==typeof n)for(;++l<Se.length;){const e=Se[l];Ce(this,Se[l],(n&we[e])===we[e])}}}function Ce(e,t,n){n&&(e[t]=n)}function Ee(e){const t={},n={};for(const[r,l]of Object.entries(e.properties)){const o=new _e(r,e.transform(e.attributes||{},r),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[fe(r)]=r,n[fe(o.attribute)]=r}return new se(t,n,e.space)}_e.prototype.defined=!0;const Ne=Ee({properties:{ariaActiveDescendant:null,ariaAtomic:me,ariaAutoComplete:null,ariaBusy:me,ariaChecked:me,ariaColCount:ye,ariaColIndex:ye,ariaColSpan:ye,ariaControls:ve,ariaCurrent:null,ariaDescribedBy:ve,ariaDetails:null,ariaDisabled:me,ariaDropEffect:ve,ariaErrorMessage:null,ariaExpanded:me,ariaFlowTo:ve,ariaGrabbed:me,ariaHasPopup:null,ariaHidden:me,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ve,ariaLevel:ye,ariaLive:null,ariaModal:me,ariaMultiLine:me,ariaMultiSelectable:me,ariaOrientation:null,ariaOwns:ve,ariaPlaceholder:null,ariaPosInSet:ye,ariaPressed:me,ariaReadOnly:me,ariaRelevant:null,ariaRequired:me,ariaRoleDescription:ve,ariaRowCount:ye,ariaRowIndex:ye,ariaRowSpan:ye,ariaSelected:me,ariaSetSize:ye,ariaSort:null,ariaValueMax:ye,ariaValueMin:ye,ariaValueNow:ye,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function Pe(e,t){return t in e?e[t]:t}function Ie(e,t){return Pe(e,t.toLowerCase())}const Te=Ee({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:be,acceptCharset:ve,accessKey:ve,action:null,allow:null,allowFullScreen:he,allowPaymentRequest:he,allowUserMedia:he,alt:null,as:null,async:he,autoCapitalize:null,autoComplete:ve,autoFocus:he,autoPlay:he,blocking:ve,capture:null,charSet:null,checked:he,cite:null,className:ve,cols:ye,colSpan:null,content:null,contentEditable:me,controls:he,controlsList:ve,coords:ye|be,crossOrigin:null,data:null,dateTime:null,decoding:null,default:he,defer:he,dir:null,dirName:null,disabled:he,download:ge,draggable:me,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:he,formTarget:null,headers:ve,height:ye,hidden:ge,high:ye,href:null,hrefLang:null,htmlFor:ve,httpEquiv:ve,id:null,imageSizes:null,imageSrcSet:null,inert:he,inputMode:null,integrity:null,is:null,isMap:he,itemId:null,itemProp:ve,itemRef:ve,itemScope:he,itemType:ve,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:he,low:ye,manifest:null,max:null,maxLength:ye,media:null,method:null,min:null,minLength:ye,multiple:he,muted:he,name:null,nonce:null,noModule:he,noValidate:he,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:he,optimum:ye,pattern:null,ping:ve,placeholder:null,playsInline:he,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:he,referrerPolicy:null,rel:ve,required:he,reversed:he,rows:ye,rowSpan:ye,sandbox:ve,scope:null,scoped:he,seamless:he,selected:he,shadowRootClonable:he,shadowRootDelegatesFocus:he,shadowRootMode:null,shape:null,size:ye,sizes:null,slot:null,span:ye,spellCheck:me,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ye,step:null,style:null,tabIndex:ye,target:null,title:null,translate:null,type:null,typeMustMatch:he,useMap:null,value:me,width:ye,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ve,axis:null,background:null,bgColor:null,border:ye,borderColor:null,bottomMargin:ye,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:he,declare:he,event:null,face:null,frame:null,frameBorder:null,hSpace:ye,leftMargin:ye,link:null,longDesc:null,lowSrc:null,marginHeight:ye,marginWidth:ye,noResize:he,noHref:he,noShade:he,noWrap:he,object:null,profile:null,prompt:null,rev:null,rightMargin:ye,rules:null,scheme:null,scrolling:me,standby:null,summary:null,text:null,topMargin:ye,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ye,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:he,disableRemotePlayback:he,prefix:null,property:null,results:ye,security:null,unselectable:null},space:"html",transform:Ie}),Le=Ee({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ke,accentHeight:ye,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ye,amplitude:ye,arabicForm:null,ascent:ye,attributeName:null,attributeType:null,azimuth:ye,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ye,by:null,calcMode:null,capHeight:ye,className:ve,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ye,diffuseConstant:ye,direction:null,display:null,dur:null,divisor:ye,dominantBaseline:null,download:he,dx:null,dy:null,edgeMode:null,editable:null,elevation:ye,enableBackground:null,end:null,event:null,exponent:ye,externalResourcesRequired:null,fill:null,fillOpacity:ye,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:be,g2:be,glyphName:be,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ye,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ye,horizOriginX:ye,horizOriginY:ye,id:null,ideographic:ye,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ye,k:ye,k1:ye,k2:ye,k3:ye,k4:ye,kernelMatrix:ke,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ye,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ye,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ye,overlineThickness:ye,paintOrder:null,panose1:null,path:null,pathLength:ye,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ve,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ye,pointsAtY:ye,pointsAtZ:ye,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ke,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ke,rev:ke,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ke,requiredFeatures:ke,requiredFonts:ke,requiredFormats:ke,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ye,specularExponent:ye,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ye,strikethroughThickness:ye,string:null,stroke:null,strokeDashArray:ke,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ye,strokeOpacity:ye,strokeWidth:null,style:null,surfaceScale:ye,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ke,tabIndex:ye,tableValues:null,target:null,targetX:ye,targetY:ye,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ke,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ye,underlineThickness:ye,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ye,values:null,vAlphabetic:ye,vMathematical:ye,vectorEffect:null,vHanging:ye,vIdeographic:ye,version:null,vertAdvY:ye,vertOriginX:ye,vertOriginY:ye,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ye,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Pe}),ze=Ee({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),Me=Ee({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ie}),je=Ee({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),De={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Oe=/[A-Z]/g,Re=/-[a-z]/g,Fe=/^data[-\w.:]+$/i;function Ae(e){return"-"+e.toLowerCase()}function Ue(e){return e.charAt(1).toUpperCase()}const Be=ce([Ne,Te,ze,Me,je],"html"),He=ce([Ne,Le,ze,Me,je],"svg");var Ve,$e,We,qe={};function Qe(){if(We)return qe;We=1;var e=qe&&qe.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qe,"__esModule",{value:!0}),qe.default=function(e,n){let r=null;if(!e||"string"!=typeof e)return r;const l=(0,t.default)(e),o="function"==typeof n;return l.forEach(e=>{if("declaration"!==e.type)return;const{property:t,value:l}=e;o?n(t,l,e):l&&(r=r||{},r[t]=l)}),r};const t=e(function(){if($e)return Ve;$e=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,i=/^\s+|\s+$/g,u="";function s(e){return e?e.replace(i,u):u}return Ve=function(i,c){if("string"!=typeof i)throw new TypeError("First argument must be a string");if(!i)return[];c=c||{};var f=1,d=1;function p(e){var n=e.match(t);n&&(f+=n.length);var r=e.lastIndexOf("\n");d=~r?e.length-r:d+e.length}function h(){var e={line:f,column:d};return function(t){return t.position=new m(e),v(),t}}function m(e){this.start=e,this.end={line:f,column:d},this.source=c.source}function g(e){var t=new Error(c.source+":"+f+":"+d+": "+e);if(t.reason=e,t.filename=c.source,t.line=f,t.column=d,t.source=i,!c.silent)throw t}function y(e){var t=e.exec(i);if(t){var n=t[0];return p(n),i=i.slice(n.length),t}}function v(){y(n)}function b(e){var t;for(e=e||[];t=k();)!1!==t&&e.push(t);return e}function k(){var e=h();if("/"==i.charAt(0)&&"*"==i.charAt(1)){for(var t=2;u!=i.charAt(t)&&("*"!=i.charAt(t)||"/"!=i.charAt(t+1));)++t;if(t+=2,u===i.charAt(t-1))return g("End of comment missing");var n=i.slice(2,t-2);return d+=2,p(n),i=i.slice(t),d+=2,e({type:"comment",comment:n})}}function x(){var t=h(),n=y(r);if(n){if(k(),!y(l))return g("property missing ':'");var i=y(o),c=t({type:"declaration",property:s(n[0].replace(e,u)),value:i?s(i[0].replace(e,u)):u});return y(a),c}}return m.prototype.content=i,v(),function(){var e,t=[];for(b(t);e=x();)!1!==e&&(t.push(e),b(t));return t}()}}());return qe}var Ke,Ye,Xe,Ze={};function Je(){if(Ke)return Ze;Ke=1,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,o=function(e,t){return t.toUpperCase()},a=function(e,t){return"".concat(t,"-")};return Ze.camelCase=function(i,u){return void 0===u&&(u={}),function(t){return!t||n.test(t)||e.test(t)}(i)?i:(i=i.toLowerCase(),(i=u.reactCompat?i.replace(l,a):i.replace(r,a)).replace(t,o))},Ze}const Ge=r(function(){if(Xe)return Ye;Xe=1;var e=(Ye&&Ye.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Qe()),t=Je();function n(n,r){var l={};return n&&"string"==typeof n?((0,e.default)(n,function(e,n){e&&n&&(l[(0,t.camelCase)(e,r)]=n)}),l):l}return n.default=n,Ye=n}()),et=nt("end"),tt=nt("start");function nt(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function rt(e){return e&&"object"==typeof e?"position"in e||"type"in e?ot(e.position):"start"in e||"end"in e?ot(e):"line"in e||"column"in e?lt(e):"":""}function lt(e){return at(e&&e.line)+":"+at(e&&e.column)}function ot(e){return lt(e&&e.start)+"-"+lt(e&&e.end)}function at(e){return e&&"number"==typeof e?e:1}class it extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",l={},o=!1;if(t&&(l="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!l.cause&&e&&(o=!0,r=e.message,l.cause=e),!l.ruleId&&!l.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?l.ruleId=n:(l.source=n.slice(0,e),l.ruleId=n.slice(e+1))}if(!l.place&&l.ancestors&&l.ancestors){const e=l.ancestors[l.ancestors.length-1];e&&(l.place=e.position)}const a=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=r,this.line=a?a.line:void 0,this.name=rt(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=o&&l.cause&&"string"==typeof l.cause.stack?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}it.prototype.file="",it.prototype.name="",it.prototype.reason="",it.prototype.message="",it.prototype.stack="",it.prototype.column=void 0,it.prototype.line=void 0,it.prototype.ancestors=void 0,it.prototype.cause=void 0,it.prototype.fatal=void 0,it.prototype.place=void 0,it.prototype.ruleId=void 0,it.prototype.source=void 0;const ut={}.hasOwnProperty,st=new Map,ct=/[A-Z]/g,ft=new Set(["table","tbody","thead","tfoot","tr"]),dt=new Set(["td","th"]),pt="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function ht(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=function(e,t){return n;function n(n,r,l,o){const a=Array.isArray(l.children),i=tt(n);return t(r,l,o,a,{columnNumber:i?i.column-1:void 0,fileName:e,lineNumber:i?i.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");r=function(e,t,n){return r;function r(e,r,l,o){const a=Array.isArray(l.children)?n:t;return o?a(r,l,o):a(r,l)}}(0,t.jsx,t.jsxs)}const l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?He:Be,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},o=mt(l,e,void 0);return o&&"string"!=typeof o?o:l.create(e,l.Fragment,{children:o||void 0},void 0)}function mt(e,t,n){return"element"===t.type?function(e,t,n){const r=e.schema;let l=r;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(l=He,e.schema=l);e.ancestors.push(t);const o=kt(e,t.tagName,!1),a=function(e,t){const n={};let r,l;for(l in t.properties)if("children"!==l&&ut.call(t.properties,l)){const o=bt(e,l,t.properties[l]);if(o){const[l,a]=o;e.tableCellAlignToStyle&&"align"===l&&"string"==typeof a&&dt.has(t.tagName)?r=a:n[l]=a}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let i=vt(e,t);ft.has(t.tagName)&&(i=i.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&ue(t.value):ue(t));var t}));return gt(e,a,o,t),yt(a,i),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}xt(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const r=e.schema;let l=r;"svg"===t.name&&"html"===r.space&&(l=He,e.schema=l);e.ancestors.push(t);const o=null===t.name?e.Fragment:kt(e,t.name,!0),a=function(e,t){const n={};for(const r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){const t=r.data.estree.body[0];te(t.type);const l=t.expression;te(l.type);const o=l.properties[0];te(o.type),Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else xt(e,t.position);else{const l=r.name;let o;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){const t=r.value.data.estree.body[0];te(t.type),o=e.evaluater.evaluateExpression(t.expression)}else xt(e,t.position);else o=null===r.value||r.value;n[l]=o}return n}(e,t),i=vt(e,t);return gt(e,a,o,t),yt(a,i),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);xt(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return yt(r,vt(e,t)),e.create(t,e.Fragment,r,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function gt(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function yt(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function vt(e,t){const n=[];let r=-1;const l=e.passKeys?new Map:st;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const e="element"===o.type?o.tagName:"mdxJsxFlowElement"===o.type||"mdxJsxTextElement"===o.type?o.name:void 0;if(e){const t=l.get(e)||0;a=e+"-"+t,l.set(e,t+1)}}const i=mt(e,o,a);void 0!==i&&n.push(i)}return n}function bt(e,t,n){const r=function(e,t){const n=fe(t);let r=t,l=de;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Fe.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(Re,Ue);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!Re.test(e)){let n=e.replace(Oe,Ae);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}l=_e}return new l(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){try{return Ge(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,r=new it("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=pt+"#cannot-parse-style-attribute",r}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)ut.call(e,n)&&(t[wt(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?De[r.property]||r.property:r.attribute,n]}}function kt(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,l=-1;for(;++l<e.length;){const t=ae(e[l])?{type:"Identifier",name:e[l]}:{type:"Literal",value:e[l]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(l&&"Literal"===t.type),optional:!1}:t}r=n}else r=ae(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){const t=r.value;return ut.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);xt(e)}function xt(e,t){const n=new it("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=pt+"#cannot-handle-mdx-estrees-without-createevaluater",n}function wt(e){let t=e.replace(ct,St);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function St(e){return"-"+e.toLowerCase()}const _t={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Ct={};function Et(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Nt(e.children,t,n)}return Array.isArray(e)?Nt(e,t,n):""}function Nt(e,t,n){const r=[];let l=-1;for(;++l<e.length;)r[l]=Et(e[l],t,n);return r.join("")}const Pt=document.createElement("i");function It(e){const t="&"+e+";";Pt.innerHTML=t;const n=Pt.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function Tt(e,t,n,r){const l=e.length;let o,a=0;if(t=t<0?-t>l?0:l+t:t>l?l:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Lt(e,t){return e.length>0?(Tt(e,e.length,0,t),e):t}const zt={}.hasOwnProperty;function Mt(e,t){let n;for(n in t){const r=(zt.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let o;if(l)for(o in l){zt.call(r,o)||(r[o]=[]);const e=l[o];jt(r[o],Array.isArray(e)?e:e?[e]:[])}}}function jt(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);Tt(e,0,0,r)}function Dt(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function Ot(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Rt=Yt(/[A-Za-z]/),Ft=Yt(/[\dA-Za-z]/),At=Yt(/[#-'*+\--9=?A-Z^-~]/);function Ut(e){return null!==e&&(e<32||127===e)}const Bt=Yt(/\d/),Ht=Yt(/[\dA-Fa-f]/),Vt=Yt(/[!-/:-@[-`{-~]/);function $t(e){return null!==e&&e<-2}function Wt(e){return null!==e&&(e<0||32===e)}function qt(e){return-2===e||-1===e||32===e}const Qt=Yt(new RegExp("\\p{P}|\\p{S}","u")),Kt=Yt(/\s/);function Yt(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Xt(e){const t=[];let n=-1,r=0,l=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(37===o&&Ft(e.charCodeAt(n+1))&&Ft(e.charCodeAt(n+2)))l=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(a=String.fromCharCode(o,t),l=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+l+1,a=""),l&&(n+=l,l=0)}return t.join("")+e.slice(r)}function Zt(e,t,n,r){const l=r?r-1:Number.POSITIVE_INFINITY;let o=0;return function(r){if(qt(r))return e.enter(n),a(r);return t(r)};function a(r){return qt(r)&&o++<l?(e.consume(r),a):(e.exit(n),t(r))}}const Jt={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Zt(e,t,"linePrefix")},function(t){return e.enter("paragraph"),r(t)});let n;return t;function r(t){const r=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=r),n=r,l(t)}function l(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):$t(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),l)}}};const Gt={tokenize:function(e){const t=this,n=[];let r,l,o,a=0;return i;function i(r){if(a<n.length){const l=n[a];return t.containerState=l[1],e.attempt(l[0].continuation,u,s)(r)}return s(r)}function u(e){if(a++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&v();const n=t.events.length;let l,o=n;for(;o--;)if("exit"===t.events[o][0]&&"chunkFlow"===t.events[o][1].type){l=t.events[o][1].end;break}y(a);let i=n;for(;i<t.events.length;)t.events[i][1].end={...l},i++;return Tt(t.events,o+1,0,t.events.slice(n)),t.events.length=i,s(e)}return i(e)}function s(l){if(a===n.length){if(!r)return d(l);if(r.currentConstruct&&r.currentConstruct.concrete)return h(l);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(en,c,f)(l)}function c(e){return r&&v(),y(a),d(e)}function f(e){return t.parser.lazy[t.now().line]=a!==n.length,o=t.now().offset,h(e)}function d(n){return t.containerState={},e.attempt(en,p,h)(n)}function p(e){return a++,n.push([t.currentConstruct,t.containerState]),d(e)}function h(n){return null===n?(r&&v(),y(0),void e.consume(n)):(r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:l}),m(n))}function m(n){return null===n?(g(e.exit("chunkFlow"),!0),y(0),void e.consume(n)):$t(n)?(e.consume(n),g(e.exit("chunkFlow")),a=0,t.interrupt=void 0,i):(e.consume(n),m)}function g(e,n){const i=t.sliceStream(e);if(n&&i.push(null),e.previous=l,l&&(l.next=e),l=e,r.defineSkip(e.start),r.write(i),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<o&&(!r.events[e][1].end||r.events[e][1].end.offset>o))return;const n=t.events.length;let l,i,u=n;for(;u--;)if("exit"===t.events[u][0]&&"chunkFlow"===t.events[u][1].type){if(l){i=t.events[u][1].end;break}l=!0}for(y(a),e=n;e<t.events.length;)t.events[e][1].end={...i},e++;Tt(t.events,u+1,0,t.events.slice(n)),t.events.length=e}}function y(r){let l=n.length;for(;l-- >r;){const r=n[l];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){r.write([null]),l=void 0,r=void 0,t.containerState._closeFlow=void 0}}},en={tokenize:function(e,t,n){return Zt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function tn(e){return null===e||Wt(e)||Kt(e)?1:Qt(e)?2:void 0}function nn(e,t,n){const r=[];let l=-1;for(;++l<e.length;){const o=e[l].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const rn={name:"attention",resolveAll:function(e,t){let n,r,l,o,a,i,u,s,c=-1;for(;++c<e.length;)if("enter"===e[c][0]&&"attentionSequence"===e[c][1].type&&e[c][1]._close)for(n=c;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[c][1]).charCodeAt(0)){if((e[n][1]._close||e[c][1]._open)&&(e[c][1].end.offset-e[c][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[c][1].end.offset-e[c][1].start.offset)%3))continue;i=e[n][1].end.offset-e[n][1].start.offset>1&&e[c][1].end.offset-e[c][1].start.offset>1?2:1;const f={...e[n][1].end},d={...e[c][1].start};ln(f,-i),ln(d,i),o={type:i>1?"strongSequence":"emphasisSequence",start:f,end:{...e[n][1].end}},a={type:i>1?"strongSequence":"emphasisSequence",start:{...e[c][1].start},end:d},l={type:i>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[c][1].start}},r={type:i>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[n][1].end={...o.start},e[c][1].start={...a.end},u=[],e[n][1].end.offset-e[n][1].start.offset&&(u=Lt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])),u=Lt(u,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",l,t]]),u=Lt(u,nn(t.parser.constructs.insideSpan.null,e.slice(n+1,c),t)),u=Lt(u,[["exit",l,t],["enter",a,t],["exit",a,t],["exit",r,t]]),e[c][1].end.offset-e[c][1].start.offset?(s=2,u=Lt(u,[["enter",e[c][1],t],["exit",e[c][1],t]])):s=0,Tt(e,n-1,c-n+3,u),c=n+u.length-s-2;break}c=-1;for(;++c<e.length;)"attentionSequence"===e[c][1].type&&(e[c][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,l=tn(r);let o;return function(t){return o=t,e.enter("attentionSequence"),a(t)};function a(i){if(i===o)return e.consume(i),a;const u=e.exit("attentionSequence"),s=tn(i),c=!s||2===s&&l||n.includes(i),f=!l||2===l&&s||n.includes(r);return u._open=Boolean(42===o?c:c&&(l||!f)),u._close=Boolean(42===o?f:f&&(s||!c)),t(i)}}};function ln(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const on={name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l};function l(t){return Rt(t)?(e.consume(t),o):64===t?n(t):u(t)}function o(e){return 43===e||45===e||46===e||Ft(e)?(r=1,a(e)):u(e)}function a(t){return 58===t?(e.consume(t),r=0,i):(43===t||45===t||46===t||Ft(t))&&r++<32?(e.consume(t),a):(r=0,u(t))}function i(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||Ut(r)?n(r):(e.consume(r),i)}function u(t){return 64===t?(e.consume(t),s):At(t)?(e.consume(t),u):n(t)}function s(e){return Ft(e)?c(e):n(e)}function c(n){return 46===n?(e.consume(n),r=0,s):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):f(n)}function f(t){if((45===t||Ft(t))&&r++<63){const n=45===t?f:c;return e.consume(t),n}return n(t)}}};const an={partial:!0,tokenize:function(e,t,n){return function(t){return qt(t)?Zt(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||$t(e)?t(e):n(e)}}};const un={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(qt(t))return Zt(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return l(t)};function l(r){return e.attempt(un,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),l}return n(t)};function l(n){return qt(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const sn={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return Vt(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const cn={name:"characterReference",tokenize:function(e,t,n){const r=this;let l,o,a=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),i};function i(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),l=31,o=Ft,s(t))}function u(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,o=Ht,s):(e.enter("characterReferenceValue"),l=7,o=Bt,s(t))}function s(i){if(59===i&&a){const l=e.exit("characterReferenceValue");return o!==Ft||It(r.sliceSerialize(l))?(e.enter("characterReferenceMarker"),e.consume(i),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(i)}return o(i)&&a++<l?(e.consume(i),s):n(i)}}};const fn={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l};function l(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},dn={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,l={partial:!0,tokenize:function(e,t,n){let l=0;return a;function a(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u}function u(t){return e.enter("codeFencedFence"),qt(t)?Zt(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):s(t)}function s(t){return t===o?(e.enter("codeFencedFenceSequence"),c(t)):n(t)}function c(t){return t===o?(l++,e.consume(t),c):l>=i?(e.exit("codeFencedFenceSequence"),qt(t)?Zt(e,f,"whitespace")(t):f(t)):n(t)}function f(r){return null===r||$t(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let o,a=0,i=0;return function(t){return function(t){const n=r.events[r.events.length-1];return a=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,o=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(t)}(t)};function u(t){return t===o?(i++,e.consume(t),u):i<3?n(t):(e.exit("codeFencedFenceSequence"),qt(t)?Zt(e,s,"whitespace")(t):s(t))}function s(n){return null===n||$t(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(fn,p,v)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),c(n))}function c(t){return null===t||$t(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),s(t)):qt(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Zt(e,f,"whitespace")(t)):96===t&&t===o?n(t):(e.consume(t),c)}function f(t){return null===t||$t(t)?s(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),d(t))}function d(t){return null===t||$t(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),s(t)):96===t&&t===o?n(t):(e.consume(t),d)}function p(t){return e.attempt(l,v,h)(t)}function h(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),m}function m(t){return a>0&&qt(t)?Zt(e,g,"linePrefix",a+1)(t):g(t)}function g(t){return null===t||$t(t)?e.check(fn,p,v)(t):(e.enter("codeFlowValue"),y(t))}function y(t){return null===t||$t(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),y)}function v(n){return e.exit("codeFenced"),t(n)}}};const pn={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),Zt(e,l,"linePrefix",5)(t)};function l(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return null===t?i(t):$t(t)?e.attempt(hn,o,i)(t):(e.enter("codeFlowValue"),a(t))}function a(t){return null===t||$t(t)?(e.exit("codeFlowValue"),o(t)):(e.consume(t),a)}function i(n){return e.exit("codeIndented"),t(n)}}},hn={partial:!0,tokenize:function(e,t,n){const r=this;return l;function l(t){return r.parser.lazy[r.now().line]?n(t):$t(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l):Zt(e,o,"linePrefix",5)(t)}function o(e){const o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):$t(e)?l(e):n(e)}}};const mn={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,l=3;if(!("lineEnding"!==e[l][1].type&&"space"!==e[l][1].type||"lineEnding"!==e[r][1].type&&"space"!==e[r][1].type))for(t=l;++t<r;)if("codeTextData"===e[t][1].type){e[l][1].type="codeTextPadding",e[r][1].type="codeTextPadding",l+=2,r-=2;break}t=l-1,r++;for(;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):t!==r&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,l,o=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),a(t)};function a(t){return 96===t?(e.consume(t),o++,a):(e.exit("codeTextSequence"),i(t))}function i(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),i):96===t?(l=e.enter("codeTextSequence"),r=0,s(t)):$t(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):(e.enter("codeTextData"),u(t))}function u(t){return null===t||32===t||96===t||$t(t)?(e.exit("codeTextData"),i(t)):(e.consume(t),u)}function s(n){return 96===n?(e.consume(n),r++,s):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(l.type="codeTextData",u(n))}}};class gn{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const r=t||0;this.setCursor(Math.trunc(e));const l=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&yn(this.left,n),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),yn(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),yn(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);yn(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);yn(this.left,t.reverse())}}}function yn(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function vn(e){const t={};let n,r,l,o,a,i,u,s=-1;const c=new gn(e);for(;++s<c.length;){for(;s in t;)s=t[s];if(n=c.get(s),s&&"chunkFlow"===n[1].type&&"listItemPrefix"===c.get(s-1)[1].type&&(i=n[1]._tokenizer.events,l=0,l<i.length&&"lineEndingBlank"===i[l][1].type&&(l+=2),l<i.length&&"content"===i[l][1].type))for(;++l<i.length&&"content"!==i[l][1].type;)"chunkText"===i[l][1].type&&(i[l][1]._isInFirstContentOfListItem=!0,l++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,bn(c,s)),s=t[s],u=!0);else if(n[1]._container){for(l=s,r=void 0;l--;)if(o=c.get(l),"lineEnding"===o[1].type||"lineEndingBlank"===o[1].type)"enter"===o[0]&&(r&&(c.get(r)[1].type="lineEndingBlank"),o[1].type="lineEnding",r=l);else if("linePrefix"!==o[1].type&&"listItemIndent"!==o[1].type)break;r&&(n[1].end={...c.get(r)[1].start},a=c.slice(r,s),a.unshift(n),c.splice(r,s-r+1,a))}}return Tt(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!u}function bn(e,t){const n=e.get(t)[1],r=e.get(t)[2];let l=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const i=a.events,u=[],s={};let c,f,d=-1,p=n,h=0,m=0;const g=[m];for(;p;){for(;e.get(++l)[1]!==p;);o.push(l),p._tokenizer||(c=r.sliceStream(p),p.next||c.push(null),f&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(c),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),f=p,p=p.next}for(p=n;++d<i.length;)"exit"===i[d][0]&&"enter"===i[d-1][0]&&i[d][1].type===i[d-1][1].type&&i[d][1].start.line!==i[d][1].end.line&&(m=d+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),d=g.length;d--;){const t=i.slice(g[d],g[d+1]),n=o.pop();u.push([n,n+t.length-1]),e.splice(n,2,t)}for(u.reverse(),d=-1;++d<u.length;)s[h+u[d][0]]=h+u[d][1],h+=u[d][1]-u[d][0]-1;return s}const kn={resolve:function(e){return vn(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?l(t):$t(t)?e.check(xn,o,l)(t):(e.consume(t),r)}function l(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function o(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},xn={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Zt(e,l,"linePrefix")};function l(l){if(null===l||$t(l))return n(l);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}};function wn(e,t,n,r,l,o,a,i,u){const s=u||Number.POSITIVE_INFINITY;let c=0;return function(t){if(60===t)return e.enter(r),e.enter(l),e.enter(o),e.consume(t),e.exit(o),f;if(null===t||32===t||41===t||Ut(t))return n(t);return e.enter(r),e.enter(a),e.enter(i),e.enter("chunkString",{contentType:"string"}),h(t)};function f(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(l),e.exit(r),t):(e.enter(i),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return 62===t?(e.exit("chunkString"),e.exit(i),f(t)):null===t||60===t||$t(t)?n(t):(e.consume(t),92===t?p:d)}function p(t){return 60===t||62===t||92===t?(e.consume(t),d):d(t)}function h(l){return c||null!==l&&41!==l&&!Wt(l)?c<s&&40===l?(e.consume(l),c++,h):41===l?(e.consume(l),c--,h):null===l||32===l||40===l||Ut(l)?n(l):(e.consume(l),92===l?m:h):(e.exit("chunkString"),e.exit(i),e.exit(a),e.exit(r),t(l))}function m(t){return 40===t||41===t||92===t?(e.consume(t),h):h(t)}}function Sn(e,t,n,r,l,o){const a=this;let i,u=0;return function(t){return e.enter(r),e.enter(l),e.consume(t),e.exit(l),e.enter(o),s};function s(f){return u>999||null===f||91===f||93===f&&!i||94===f&&!u&&"_hiddenFootnoteSupport"in a.parser.constructs?n(f):93===f?(e.exit(o),e.enter(l),e.consume(f),e.exit(l),e.exit(r),t):$t(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),s):(e.enter("chunkString",{contentType:"string"}),c(f))}function c(t){return null===t||91===t||93===t||$t(t)||u++>999?(e.exit("chunkString"),s(t)):(e.consume(t),i||(i=!qt(t)),92===t?f:c)}function f(t){return 91===t||92===t||93===t?(e.consume(t),u++,c):c(t)}}function _n(e,t,n,r,l,o){let a;return function(t){if(34===t||39===t||40===t)return e.enter(r),e.enter(l),e.consume(t),e.exit(l),a=40===t?41:t,i;return n(t)};function i(n){return n===a?(e.enter(l),e.consume(n),e.exit(l),e.exit(r),t):(e.enter(o),u(n))}function u(t){return t===a?(e.exit(o),i(a)):null===t?n(t):$t(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Zt(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),s(t))}function s(t){return t===a||null===t||$t(t)?(e.exit("chunkString"),u(t)):(e.consume(t),92===t?c:s)}function c(t){return t===a||92===t?(e.consume(t),s):s(t)}}function Cn(e,t){let n;return function r(l){if($t(l))return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),n=!0,r;if(qt(l))return Zt(e,r,n?"linePrefix":"lineSuffix")(l);return t(l)}}const En={name:"definition",tokenize:function(e,t,n){const r=this;let l;return function(t){return e.enter("definition"),function(t){return Sn.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function o(t){return l=Ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a):n(t)}function a(t){return Wt(t)?Cn(e,i)(t):i(t)}function i(t){return wn(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function u(t){return e.attempt(Nn,s,s)(t)}function s(t){return qt(t)?Zt(e,c,"whitespace")(t):c(t)}function c(o){return null===o||$t(o)?(e.exit("definition"),r.parser.defined.push(l),t(o)):n(o)}}},Nn={partial:!0,tokenize:function(e,t,n){return function(t){return Wt(t)?Cn(e,r)(t):n(t)};function r(t){return _n(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function l(t){return qt(t)?Zt(e,o,"whitespace")(t):o(t)}function o(e){return null===e||$t(e)?t(e):n(e)}}};const Pn={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return $t(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const In={name:"headingAtx",resolve:function(e,t){let n,r,l=e.length-2,o=3;"whitespace"===e[o][1].type&&(o+=2);l-2>o&&"whitespace"===e[l][1].type&&(l-=2);"atxHeadingSequence"===e[l][1].type&&(o===l-1||l-4>o&&"whitespace"===e[l-2][1].type)&&(l-=o+1===l?2:4);l>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[l][1].end},r={type:"chunkText",start:e[o][1].start,end:e[l][1].end,contentType:"text"},Tt(e,o,l-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),l(t)}(t)};function l(t){return 35===t&&r++<6?(e.consume(t),l):null===t||Wt(t)?(e.exit("atxHeadingSequence"),o(t)):n(t)}function o(n){return 35===n?(e.enter("atxHeadingSequence"),a(n)):null===n||$t(n)?(e.exit("atxHeading"),t(n)):qt(n)?Zt(e,o,"whitespace")(n):(e.enter("atxHeadingText"),i(n))}function a(t){return 35===t?(e.consume(t),a):(e.exit("atxHeadingSequence"),o(t))}function i(t){return null===t||35===t||Wt(t)?(e.exit("atxHeadingText"),o(t)):(e.consume(t),i)}}};const Tn=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Ln=["pre","script","style","textarea"],zn={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const r=this;let l,o,a,i,u;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),s}(t)};function s(i){return 33===i?(e.consume(i),c):47===i?(e.consume(i),o=!0,p):63===i?(e.consume(i),l=3,r.interrupt?t:j):Rt(i)?(e.consume(i),a=String.fromCharCode(i),h):n(i)}function c(o){return 45===o?(e.consume(o),l=2,f):91===o?(e.consume(o),l=5,i=0,d):Rt(o)?(e.consume(o),l=4,r.interrupt?t:j):n(o)}function f(l){return 45===l?(e.consume(l),r.interrupt?t:j):n(l)}function d(l){const o="CDATA[";return l===o.charCodeAt(i++)?(e.consume(l),6===i?r.interrupt?t:E:d):n(l)}function p(t){return Rt(t)?(e.consume(t),a=String.fromCharCode(t),h):n(t)}function h(i){if(null===i||47===i||62===i||Wt(i)){const u=47===i,s=a.toLowerCase();return u||o||!Ln.includes(s)?Tn.includes(a.toLowerCase())?(l=6,u?(e.consume(i),m):r.interrupt?t(i):E(i)):(l=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(i):o?g(i):y(i)):(l=1,r.interrupt?t(i):E(i))}return 45===i||Ft(i)?(e.consume(i),a+=String.fromCharCode(i),h):n(i)}function m(l){return 62===l?(e.consume(l),r.interrupt?t:E):n(l)}function g(t){return qt(t)?(e.consume(t),g):_(t)}function y(t){return 47===t?(e.consume(t),_):58===t||95===t||Rt(t)?(e.consume(t),v):qt(t)?(e.consume(t),y):_(t)}function v(t){return 45===t||46===t||58===t||95===t||Ft(t)?(e.consume(t),v):b(t)}function b(t){return 61===t?(e.consume(t),k):qt(t)?(e.consume(t),b):y(t)}function k(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),u=t,x):qt(t)?(e.consume(t),k):w(t)}function x(t){return t===u?(e.consume(t),u=null,S):null===t||$t(t)?n(t):(e.consume(t),x)}function w(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||Wt(t)?b(t):(e.consume(t),w)}function S(e){return 47===e||62===e||qt(e)?y(e):n(e)}function _(t){return 62===t?(e.consume(t),C):n(t)}function C(t){return null===t||$t(t)?E(t):qt(t)?(e.consume(t),C):n(t)}function E(t){return 45===t&&2===l?(e.consume(t),T):60===t&&1===l?(e.consume(t),L):62===t&&4===l?(e.consume(t),D):63===t&&3===l?(e.consume(t),j):93===t&&5===l?(e.consume(t),M):!$t(t)||6!==l&&7!==l?null===t||$t(t)?(e.exit("htmlFlowData"),N(t)):(e.consume(t),E):(e.exit("htmlFlowData"),e.check(Mn,O,N)(t))}function N(t){return e.check(jn,P,O)(t)}function P(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return null===t||$t(t)?N(t):(e.enter("htmlFlowData"),E(t))}function T(t){return 45===t?(e.consume(t),j):E(t)}function L(t){return 47===t?(e.consume(t),a="",z):E(t)}function z(t){if(62===t){const n=a.toLowerCase();return Ln.includes(n)?(e.consume(t),D):E(t)}return Rt(t)&&a.length<8?(e.consume(t),a+=String.fromCharCode(t),z):E(t)}function M(t){return 93===t?(e.consume(t),j):E(t)}function j(t){return 62===t?(e.consume(t),D):45===t&&2===l?(e.consume(t),j):E(t)}function D(t){return null===t||$t(t)?(e.exit("htmlFlowData"),O(t)):(e.consume(t),D)}function O(n){return e.exit("htmlFlow"),t(n)}}},Mn={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(an,t,n)}}},jn={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if($t(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l;return n(t)};function l(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}};const Dn={name:"htmlText",tokenize:function(e,t,n){const r=this;let l,o,a;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),i};function i(t){return 33===t?(e.consume(t),u):47===t?(e.consume(t),k):63===t?(e.consume(t),v):Rt(t)?(e.consume(t),S):n(t)}function u(t){return 45===t?(e.consume(t),s):91===t?(e.consume(t),o=0,p):Rt(t)?(e.consume(t),y):n(t)}function s(t){return 45===t?(e.consume(t),d):n(t)}function c(t){return null===t?n(t):45===t?(e.consume(t),f):$t(t)?(a=c,z(t)):(e.consume(t),c)}function f(t){return 45===t?(e.consume(t),d):c(t)}function d(e){return 62===e?L(e):45===e?f(e):c(e)}function p(t){const r="CDATA[";return t===r.charCodeAt(o++)?(e.consume(t),6===o?h:p):n(t)}function h(t){return null===t?n(t):93===t?(e.consume(t),m):$t(t)?(a=h,z(t)):(e.consume(t),h)}function m(t){return 93===t?(e.consume(t),g):h(t)}function g(t){return 62===t?L(t):93===t?(e.consume(t),g):h(t)}function y(t){return null===t||62===t?L(t):$t(t)?(a=y,z(t)):(e.consume(t),y)}function v(t){return null===t?n(t):63===t?(e.consume(t),b):$t(t)?(a=v,z(t)):(e.consume(t),v)}function b(e){return 62===e?L(e):v(e)}function k(t){return Rt(t)?(e.consume(t),x):n(t)}function x(t){return 45===t||Ft(t)?(e.consume(t),x):w(t)}function w(t){return $t(t)?(a=w,z(t)):qt(t)?(e.consume(t),w):L(t)}function S(t){return 45===t||Ft(t)?(e.consume(t),S):47===t||62===t||Wt(t)?_(t):n(t)}function _(t){return 47===t?(e.consume(t),L):58===t||95===t||Rt(t)?(e.consume(t),C):$t(t)?(a=_,z(t)):qt(t)?(e.consume(t),_):L(t)}function C(t){return 45===t||46===t||58===t||95===t||Ft(t)?(e.consume(t),C):E(t)}function E(t){return 61===t?(e.consume(t),N):$t(t)?(a=E,z(t)):qt(t)?(e.consume(t),E):_(t)}function N(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,P):$t(t)?(a=N,z(t)):qt(t)?(e.consume(t),N):(e.consume(t),I)}function P(t){return t===l?(e.consume(t),l=void 0,T):null===t?n(t):$t(t)?(a=P,z(t)):(e.consume(t),P)}function I(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Wt(t)?_(t):(e.consume(t),I)}function T(e){return 47===e||62===e||Wt(e)?_(e):n(e)}function L(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function z(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return qt(t)?Zt(e,j,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):j(t)}function j(t){return e.enter("htmlTextData"),a(t)}}};const On={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){const e="labelImage"===r.type?4:2;r.type="data",t+=e}}e.length!==n.length&&Tt(e,0,e.length,n);return e},resolveTo:function(e,t){let n,r,l,o,a=e.length,i=0;for(;a--;)if(n=e[a][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(l){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=a,"labelLink"!==n.type)){i=2;break}}else"labelEnd"===n.type&&(l=a);const u={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},s={type:"label",start:{...e[r][1].start},end:{...e[l][1].end}},c={type:"labelText",start:{...e[r+i+2][1].end},end:{...e[l-2][1].start}};return o=[["enter",u,t],["enter",s,t]],o=Lt(o,e.slice(r+1,r+i+3)),o=Lt(o,[["enter",c,t]]),o=Lt(o,nn(t.parser.constructs.insideSpan.null,e.slice(r+i+4,l-3),t)),o=Lt(o,[["exit",c,t],e[l-2],e[l-1],["exit",s,t]]),o=Lt(o,e.slice(l+1)),o=Lt(o,[["exit",u,t]]),Tt(e,r,e.length,o),e},tokenize:function(e,t,n){const r=this;let l,o,a=r.events.length;for(;a--;)if(("labelImage"===r.events[a][1].type||"labelLink"===r.events[a][1].type)&&!r.events[a][1]._balanced){l=r.events[a][1];break}return function(t){if(!l)return n(t);if(l._inactive)return c(t);return o=r.parser.defined.includes(Ot(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),i};function i(t){return 40===t?e.attempt(Rn,s,o?s:c)(t):91===t?e.attempt(Fn,s,o?u:c)(t):o?s(t):c(t)}function u(t){return e.attempt(An,s,c)(t)}function s(e){return t(e)}function c(e){return l._balanced=!0,n(e)}}},Rn={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return Wt(t)?Cn(e,l)(t):l(t)}function l(t){return 41===t?s(t):wn(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function o(t){return Wt(t)?Cn(e,i)(t):s(t)}function a(e){return n(e)}function i(t){return 34===t||39===t||40===t?_n(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):s(t)}function u(t){return Wt(t)?Cn(e,s)(t):s(t)}function s(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},Fn={tokenize:function(e,t,n){const r=this;return function(t){return Sn.call(r,e,l,o,"reference","referenceMarker","referenceString")(t)};function l(e){return r.parser.defined.includes(Ot(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}},An={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}};const Un={name:"labelStartImage",resolveAll:On.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),l};function l(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),o):n(t)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const Bn={name:"labelStartLink",resolveAll:On.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),l};function l(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const Hn={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Zt(e,t,"linePrefix")}}};const Vn={name:"thematicBreak",tokenize:function(e,t,n){let r,l=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,o(e)}(t)};function o(o){return o===r?(e.enter("thematicBreakSequence"),a(o)):l>=3&&(null===o||$t(o))?(e.exit("thematicBreak"),t(o)):n(o)}function a(t){return t===r?(e.consume(t),l++,a):(e.exit("thematicBreakSequence"),qt(t)?Zt(e,o,"whitespace")(t):o(t))}}};const $n={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(an,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Zt(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){if(r.containerState.furtherBlankLines||!qt(n))return r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(n);return r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(qn,t,l)(n)});function l(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,Zt(e,e.attempt($n,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const r=this,l=r.events[r.events.length-1];let o=l&&"linePrefix"===l[1].type?l[2].sliceSerialize(l[1],!0).length:0,a=0;return function(t){const l=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===l?!r.containerState.marker||t===r.containerState.marker:Bt(t)){if(r.containerState.type||(r.containerState.type=l,e.enter(l,{_container:!0})),"listUnordered"===l)return e.enter("listItemPrefix"),42===t||45===t?e.check(Vn,n,u)(t):u(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),i(t)}return n(t)};function i(t){return Bt(t)&&++a<10?(e.consume(t),i):(!r.interrupt||a<2)&&(r.containerState.marker?t===r.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),u(t)):n(t)}function u(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(an,r.interrupt?n:s,e.attempt(Wn,f,c))}function s(e){return r.containerState.initialBlankLine=!0,o++,f(e)}function c(t){return qt(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),f):n(t)}function f(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Wn={partial:!0,tokenize:function(e,t,n){const r=this;return Zt(e,function(e){const l=r.events[r.events.length-1];return!qt(e)&&l&&"listItemPrefixWhitespace"===l[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},qn={partial:!0,tokenize:function(e,t,n){const r=this;return Zt(e,function(e){const l=r.events[r.events.length-1];return l&&"listItemIndent"===l[1].type&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}};const Qn={name:"setextUnderline",resolveTo:function(e,t){let n,r,l,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),l||"definition"!==e[o][1].type||(l=o);const a={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};e[r][1].type="setextHeadingText",l?(e.splice(r,0,["enter",a,t]),e.splice(l+1,0,["exit",e[n][1],t]),e[n][1].end={...e[l][1].end}):e[n][1]=a;return e.push(["exit",a,t]),e},tokenize:function(e,t,n){const r=this;let l;return function(t){let a,i=r.events.length;for(;i--;)if("lineEnding"!==r.events[i][1].type&&"linePrefix"!==r.events[i][1].type&&"content"!==r.events[i][1].type){a="paragraph"===r.events[i][1].type;break}if(!r.parser.lazy[r.now().line]&&(r.interrupt||a))return e.enter("setextHeadingLine"),l=t,function(t){return e.enter("setextHeadingLineSequence"),o(t)}(t);return n(t)};function o(t){return t===l?(e.consume(t),o):(e.exit("setextHeadingLineSequence"),qt(t)?Zt(e,a,"lineSuffix")(t):a(t))}function a(r){return null===r||$t(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const Kn={tokenize:function(e){const t=this,n=e.attempt(an,function(r){if(null===r)return void e.consume(r);return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n},e.attempt(this.parser.constructs.flowInitial,r,Zt(e,e.attempt(this.parser.constructs.flow,r,e.attempt(kn,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}};const Yn={resolveAll:Gn()},Xn=Jn("string"),Zn=Jn("text");function Jn(e){return{resolveAll:Gn("text"===e?er:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],l=t.attempt(r,o,a);return o;function o(e){return u(e)?l(e):a(e)}function a(e){if(null!==e)return t.enter("data"),t.consume(e),i;t.consume(e)}function i(e){return u(e)?(t.exit("data"),l(e)):(t.consume(e),i)}function u(e){if(null===e)return!0;const t=r[e];let l=-1;if(t)for(;++l<t.length;){const e=t[l];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function Gn(e){return function(t,n){let r,l=-1;for(;++l<=t.length;)void 0===r?t[l]&&"data"===t[l][1].type&&(r=l,l++):t[l]&&"data"===t[l][1].type||(l!==r+2&&(t[r][1].end=t[l-1][1].end,t.splice(r+2,l-r-2),l=r+2),r=void 0);return e?e(t,n):t}}function er(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const r=e[n-1][1],l=t.sliceStream(r);let o,a=l.length,i=-1,u=0;for(;a--;){const e=l[a];if("string"==typeof e){for(i=e.length;32===e.charCodeAt(i-1);)u++,i--;if(i)break;i=-1}else if(-2===e)o=!0,u++;else if(-1!==e){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(u=0),u){const l={type:n===e.length||o||u<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?i:r.start._bufferIndex+i,_index:r.start._index+a,line:r.end.line,column:r.end.column-u,offset:r.end.offset-u},end:{...r.end}};r.end={...l.start},r.start.offset===r.end.offset?Object.assign(r,l):(e.splice(n,0,["enter",l,t],["exit",l,t]),n+=2)}n++}return e}const tr={42:$n,43:$n,45:$n,48:$n,49:$n,50:$n,51:$n,52:$n,53:$n,54:$n,55:$n,56:$n,57:$n,62:un},nr={91:En},rr={[-2]:pn,[-1]:pn,32:pn},lr={35:In,42:Vn,45:[Qn,Vn],60:zn,61:Qn,95:Vn,96:dn,126:dn},or={38:cn,92:sn},ar={[-5]:Hn,[-4]:Hn,[-3]:Hn,33:Un,38:cn,42:rn,60:[on,Dn],91:Bn,92:[Pn,sn],93:On,95:rn,96:mn},ir={null:[rn,Yn]},ur=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:nr,disable:{null:[]},document:tr,flow:lr,flowInitial:rr,insideSpan:ir,string:or,text:ar},Symbol.toStringTag,{value:"Module"}));function sr(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const l={},o=[];let a=[],i=[];const u={attempt:g(function(e,t){y(e,t.from)}),check:g(m),consume:function(e){$t(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,v()):-1!==e&&(r.column++,r.offset++);r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++));s.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=d(),s.events.push(["enter",n,s]),i.push(n),n},exit:function(e){const t=i.pop();return t.end=d(),s.events.push(["exit",t,s]),t},interrupt:g(m,{interrupt:!0})},s={code:null,containerState:{},defineSkip:function(e){l[e.line]=e.column,v()},events:[],now:d,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const r=[];let l;for(;++n<e.length;){const o=e[n];let a;if("string"==typeof o)a=o;else switch(o){case-5:a="\r";break;case-4:a="\n";break;case-3:a="\r\n";break;case-2:a=t?" ":"\t";break;case-1:if(!t&&l)continue;a=" ";break;default:a=String.fromCharCode(o)}l=-2===o,r.push(a)}return r.join("")}(f(e),t)},sliceStream:f,write:function(e){if(a=Lt(a,e),p(),null!==a[a.length-1])return[];return y(t,0),s.events=nn(o,s.events,s),s.events}};let c=t.tokenize.call(s,u);return t.resolveAll&&o.push(t),s;function f(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,l=t.end._index,o=t.end._bufferIndex;let a;if(n===l)a=[e[n].slice(r,o)];else{if(a=e.slice(n,l),r>-1){const e=a[0];"string"==typeof e?a[0]=e.slice(r):a.shift()}o>0&&a.push(e[l].slice(0,o))}return a}(a,e)}function d(){const{_bufferIndex:e,_index:t,line:n,column:l,offset:o}=r;return{_bufferIndex:e,_index:t,line:n,column:l,offset:o}}function p(){let e;for(;r._index<a.length;){const t=a[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)h(t.charCodeAt(r._bufferIndex));else h(t)}}function h(e){c=c(e)}function m(e,t){t.restore()}function g(e,t){return function(n,l,o){let a,c,f,p;return Array.isArray(n)?h(n):"tokenize"in n?h([n]):function(e){return t;function t(t){const n=null!==t&&e[t],r=null!==t&&e.null;return h([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function h(e){return a=e,c=0,0===e.length?o:m(e[c])}function m(e){return function(n){p=function(){const e=d(),t=s.previous,n=s.currentConstruct,l=s.events.length,o=Array.from(i);return{from:l,restore:a};function a(){r=e,s.previous=t,s.currentConstruct=n,s.events.length=l,i=o,v()}}(),f=e,e.partial||(s.currentConstruct=e);if(e.name&&s.parser.constructs.disable.null.includes(e.name))return y();return e.tokenize.call(t?Object.assign(Object.create(s),t):s,u,g,y)(n)}}function g(t){return e(f,p),l}function y(e){return p.restore(),++c<a.length?m(a[c]):o}}}function y(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&Tt(s.events,t,s.events.length-t,e.resolve(s.events.slice(t),s)),e.resolveTo&&(s.events=e.resolveTo(s.events,s))}function v(){r.line in l&&r.column<2&&(r.column=l[r.line],r.offset+=l[r.line]-1)}}function cr(e){const t={constructs:function(e){const t={};let n=-1;for(;++n<e.length;)Mt(t,e[n]);return t}([ur,...(e||{}).extensions||[]]),content:n(Jt),defined:[],document:n(Gt),flow:n(Kn),lazy:{},string:n(Xn),text:n(Zn)};return t;function n(e){return function(n){return sr(t,e,n)}}}const fr=/[\0\t\n\r]/g;const dr=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function pr(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Dt(n.slice(t?2:1),t?16:10)}return It(n)||e}const hr={}.hasOwnProperty;function mr(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(te),autolinkProtocol:C,autolinkEmail:C,atxHeading:o(Z),blockQuote:o(q),characterEscape:C,characterReference:C,codeFenced:o(Q),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(Q,a),codeText:o(K,a),codeTextData:C,data:C,codeFlowValue:C,definition:o(Y),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(X),hardBreakEscape:o(J),hardBreakTrailing:o(J),htmlFlow:o(G,a),htmlFlowData:C,htmlText:o(G,a),htmlTextData:C,image:o(ee),label:a,link:o(te),listItem:o(re),listItemValue:d,listOrdered:o(ne,f),listUnordered:o(ne),paragraph:o(le),reference:A,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Z),strong:o(oe),thematicBreak:o(ie)},exit:{atxHeading:u(),atxHeadingSequence:x,autolink:u(),autolinkEmail:W,autolinkProtocol:$,blockQuote:u(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:B,characterReferenceMarkerNumeric:B,characterReferenceValue:H,characterReference:V,codeFenced:u(g),codeFencedFence:m,codeFencedFenceInfo:p,codeFencedFenceMeta:h,codeFlowValue:E,codeIndented:u(y),codeText:u(L),codeTextData:E,data:E,definition:u(),definitionDestinationString:k,definitionLabelString:v,definitionTitleString:b,emphasis:u(),hardBreakEscape:u(P),hardBreakTrailing:u(P),htmlFlow:u(I),htmlFlowData:E,htmlText:u(T),htmlTextData:E,image:u(M),label:D,labelText:j,lineEnding:N,link:u(z),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:U,resourceDestinationString:O,resourceTitleString:R,resource:F,setextHeading:u(_),setextHeadingLineSequence:S,setextHeadingText:w,strong:u(),thematicBreak:u()}};yr(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(e){let r={type:"root",children:[]};const o={stack:[r],tokenStack:[],config:t,enter:i,exit:s,buffer:a,resume:c,data:n},u=[];let f=-1;for(;++f<e.length;)if("listOrdered"===e[f][1].type||"listUnordered"===e[f][1].type)if("enter"===e[f][0])u.push(f);else{f=l(e,u.pop(),f)}for(f=-1;++f<e.length;){const n=t[e[f][0]];hr.call(n,e[f][1].type)&&n[e[f][1].type].call(Object.assign({sliceSerialize:e[f][2].sliceSerialize},o),e[f][1])}if(o.tokenStack.length>0){const e=o.tokenStack[o.tokenStack.length-1];(e[1]||br).call(o,void 0,e[0])}for(r.position={start:gr(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:gr(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},f=-1;++f<t.transforms.length;)r=t.transforms[f](r)||r;return r}function l(e,t,n){let r,l,o,a,i=t-1,u=-1,s=!1;for(;++i<=n;){const t=e[i];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?u++:u--,a=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||a||u||o||(o=i),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!u&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===u&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let a=i;for(l=void 0;a--;){const t=e[a];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;l&&(e[l][1].type="lineEndingBlank",s=!0),t[1].type="lineEnding",l=a}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}o&&(!l||o<l)&&(r._spread=!0),r.end=Object.assign({},l?e[l][1].start:t[1].end),e.splice(l||i,0,["exit",r,t[2]]),i++,n++}if("listItemPrefix"===t[1].type){const l={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=l,e.splice(i,0,["enter",l,t[2]]),i++,n++,o=void 0,a=!0}}}return e[t][1]._spread=s,n}function o(e,t){return n;function n(n){i.call(this,e(n),n),t&&t.call(this,n)}}function a(){this.stack.push({type:"fragment",children:[]})}function i(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:gr(t.start),end:void 0}}function u(e){return t;function t(t){e&&e.call(this,t),s.call(this,t)}}function s(e,t){const n=this.stack.pop(),r=this.tokenStack.pop();if(!r)throw new Error("Cannot close `"+e.type+"` ("+rt({start:e.start,end:e.end})+"): it’s not open");if(r[0].type!==e.type)if(t)t.call(this,e,r[0]);else{(r[1]||br).call(this,e,r[0])}n.position.end=gr(e.end)}function c(){return function(e){return Et(e,"boolean"!=typeof Ct.includeImageAlt||Ct.includeImageAlt,"boolean"!=typeof Ct.includeHtml||Ct.includeHtml)}(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function d(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function h(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function m(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function v(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Ot(this.sliceSerialize(e)).toLowerCase()}function b(){const e=this.resume();this.stack[this.stack.length-1].title=e}function k(){const e=this.resume();this.stack[this.stack.length-1].url=e}function x(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function w(){this.data.setextHeadingSlurpLineEnding=!0}function S(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function _(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ae(),n.position={start:gr(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=gr(e.end)}function N(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=gr(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(C.call(this,e),E.call(this,e))}function P(){this.data.atHardBreak=!0}function I(){const e=this.resume();this.stack[this.stack.length-1].value=e}function T(){const e=this.resume();this.stack[this.stack.length-1].value=e}function L(){const e=this.resume();this.stack[this.stack.length-1].value=e}function z(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function j(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(dr,pr)}(t),n.identifier=Ot(t).toLowerCase()}function D(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function O(){const e=this.resume();this.stack[this.stack.length-1].url=e}function R(){const e=this.resume();this.stack[this.stack.length-1].title=e}function F(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function U(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=Ot(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function B(e){this.data.characterReferenceType=e.type}function H(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;if(n)r=Dt(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=It(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=gr(e.end)}function $(e){E.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function W(e){E.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function q(){return{type:"blockquote",children:[]}}function Q(){return{type:"code",lang:null,meta:null,value:""}}function K(){return{type:"inlineCode",value:""}}function Y(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function X(){return{type:"emphasis",children:[]}}function Z(){return{type:"heading",depth:0,children:[]}}function J(){return{type:"break"}}function G(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function re(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function le(){return{type:"paragraph",children:[]}}function oe(){return{type:"strong",children:[]}}function ae(){return{type:"text",value:""}}function ie(){return{type:"thematicBreak"}}}(n)(function(e){for(;!vn(e););return e}(cr(n).document().write(function(){let e,t=1,n="",r=!0;return function(l,o,a){const i=[];let u,s,c,f,d;for(l=n+("string"==typeof l?l.toString():new TextDecoder(o||void 0).decode(l)),c=0,n="",r&&(65279===l.charCodeAt(0)&&c++,r=void 0);c<l.length;){if(fr.lastIndex=c,u=fr.exec(l),f=u&&void 0!==u.index?u.index:l.length,d=l.charCodeAt(f),!u){n=l.slice(c);break}if(10===d&&c===f&&e)i.push(-3),e=void 0;else switch(e&&(i.push(-5),e=void 0),c<f&&(i.push(l.slice(c,f)),t+=f-c),d){case 0:i.push(65533),t++;break;case 9:for(s=4*Math.ceil(t/4),i.push(-2);t++<s;)i.push(-1);break;case 10:i.push(-4),t=1;break;default:e=!0,t=1}c=f+1}return a&&(e&&i.push(-5),n&&i.push(n),i.push(null)),i}}()(e,t,!0))))}function gr(e){return{line:e.line,column:e.column,offset:e.offset}}function yr(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?yr(e,r):vr(e,r)}}function vr(e,t){let n;for(n in t)if(hr.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function br(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+rt({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+rt({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+rt({start:t.start,end:t.end})+") is still open")}function kr(e){const t=this;t.parser=function(n){return mr(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function xr(e,t){const n=t.referenceType;let r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];const l=e.all(t),o=l[0];o&&"text"===o.type?o.value="["+o.value:l.unshift({type:"text",value:"["});const a=l[l.length-1];return a&&"text"===a.type?a.value+=r:l.push({type:"text",value:r}),l}function wr(e){const t=e.spread;return null==t?e.children.length>1:t}function Sr(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),l=0;const o=[];for(;r;)o.push(_r(t.slice(l,r.index),l>0,!0),r[0]),l=r.index+r[0].length,r=n.exec(t);return o.push(_r(t.slice(l),l>0,!1)),o.join("")}function _r(e,t,n){let r=0,l=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(l-1);for(;9===t||32===t;)l--,t=e.codePointAt(l-1)}return l>r?e.slice(r,l):""}const Cr={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",r={},l=t.lang?t.lang.split(/\s+/):[];l.length>0&&(r.className=["language-"+l[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),l=Xt(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,i=e.footnoteCounts.get(r);void 0===i?(i=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,i+=1,e.footnoteCounts.set(r,i);const u={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+l,id:n+"fnref-"+l+(i>1?"-"+i:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,u);const s={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,s),e.applyData(t,s)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xr(e,t);const l={src:Xt(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(l.title=r.title);const o={type:"element",tagName:"img",properties:l,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){const n={src:Xt(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return xr(e,t);const l={href:Xt(r.url||"")};null!==r.title&&void 0!==r.title&&(l.title=r.title);const o={type:"element",tagName:"a",properties:l,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){const n={href:Xt(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){const r=e.all(t),l=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=wr(n[r])}return t}(n):wr(t),o={},a=[];if("boolean"==typeof t.checked){const e=r[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let i=-1;for(;++i<r.length;){const e=r[i];(l||0!==i||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||l?a.push(e):a.push(...e.children)}const u=r[r.length-1];u&&(l||"element"!==u.type||"p"!==u.tagName)&&a.push({type:"text",value:"\n"});const s={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,s),e.applyData(t,s)},list:function(e,t){const n={},r=e.all(t);let l=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++l<r.length;){const e=r[l];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),r=n.shift(),l=[];if(r){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),l.push(n)}if(n.length>0){const r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=tt(t.children[1]),a=et(t.children[t.children.length-1]);o&&a&&(r.position={start:o,end:a}),l.push(r)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(l,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const r=n?n.children:void 0,l=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,a=o?o.length:t.children.length;let i=-1;const u=[];for(;++i<a;){const n=t.children[i],r={},a=o?o[i]:void 0;a&&(r.align=a);let s={type:"element",tagName:l,properties:r,children:[]};n&&(s.children=e.all(n),e.patch(n,s),s=e.applyData(n,s)),u.push(s)}const s={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,s),e.applyData(t,s)},text:function(e,t){const n={type:"text",value:Sr(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:Er,yaml:Er,definition:Er,footnoteDefinition:Er};function Er(){}const Nr="object"==typeof self?self:globalThis,Pr=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),r=l=>{if(e.has(l))return e.get(l);const[o,a]=t[l];switch(o){case 0:case-1:return n(a,l);case 1:{const e=n([],l);for(const t of a)e.push(r(t));return e}case 2:{const e=n({},l);for(const[t,n]of a)e[r(t)]=r(n);return e}case 3:return n(new Date(a),l);case 4:{const{source:e,flags:t}=a;return n(new RegExp(e,t),l)}case 5:{const e=n(new Map,l);for(const[t,n]of a)e.set(r(t),r(n));return e}case 6:{const e=n(new Set,l);for(const t of a)e.add(r(t));return e}case 7:{const{name:e,message:t}=a;return n(new Nr[e](t),l)}case 8:return n(BigInt(a),l);case"BigInt":return n(Object(BigInt(a)),l);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:e}=new Uint8Array(a);return n(new DataView(e),a)}}return n(new Nr[o](a),l)};return r})(new Map,e)(0),Ir="",{toString:Tr}={},{keys:Lr}=Object,zr=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=Tr.call(e).slice(8,-1);switch(n){case"Array":return[1,Ir];case"Object":return[2,Ir];case"Date":return[3,Ir];case"RegExp":return[4,Ir];case"Map":return[5,Ir];case"Set":return[6,Ir];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Mr=([e,t])=>0===e&&("function"===t||"symbol"===t),jr=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const l=(e,t)=>{const l=r.push(e)-1;return n.set(t,l),l},o=r=>{if(n.has(r))return n.get(r);let[a,i]=zr(r);switch(a){case 0:{let t=r;switch(i){case"bigint":a=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+i);t=null;break;case"undefined":return l([-1],r)}return l([a,t],r)}case 1:{if(i){let e=r;return"DataView"===i?e=new Uint8Array(r.buffer):"ArrayBuffer"===i&&(e=new Uint8Array(r)),l([i,[...e]],r)}const e=[],t=l([a,e],r);for(const n of r)e.push(o(n));return t}case 2:{if(i)switch(i){case"BigInt":return l([i,r.toString()],r);case"Boolean":case"Number":case"String":return l([i,r.valueOf()],r)}if(t&&"toJSON"in r)return o(r.toJSON());const n=[],u=l([a,n],r);for(const t of Lr(r))!e&&Mr(zr(r[t]))||n.push([o(t),o(r[t])]);return u}case 3:return l([a,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return l([a,{source:e,flags:t}],r)}case 5:{const t=[],n=l([a,t],r);for(const[l,a]of r)(e||!Mr(zr(l))&&!Mr(zr(a)))&&t.push([o(l),o(a)]);return n}case 6:{const t=[],n=l([a,t],r);for(const l of r)!e&&Mr(zr(l))||t.push(o(l));return n}}const{message:u}=r;return l([a,{name:i,message:u}],r)};return o})(!(t||n),!!t,new Map,r)(e),r},Dr="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Pr(jr(e,t)):structuredClone(e):(e,t)=>Pr(jr(e,t));function Or(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Rr(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Fr=function(e){if(null==e)return Ur;if("function"==typeof e)return Ar(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Fr(e[n]);return Ar(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}(e):function(e){const t=e;return Ar(n);function n(n){const r=n;let l;for(l in e)if(r[l]!==t[l])return!1;return!0}}(e);if("string"==typeof e)return function(e){return Ar(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function Ar(e){return function(t,n,r){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function Ur(){return!0}const Br=[],Hr=!0,Vr=!1;function $r(e,t,n,r){let l;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):l=t;const o=Fr(l),a=r?-1:1;!function e(l,i,u){const s=l&&"object"==typeof l?l:{};if("string"==typeof s.type){const e="string"==typeof s.tagName?s.tagName:"string"==typeof s.name?s.name:void 0;Object.defineProperty(c,"name",{value:"node ("+l.type+(e?"<"+e+">":"")+")"})}return c;function c(){let s,c,f,d=Br;if((!t||o(l,i,u[u.length-1]||void 0))&&(d=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[Hr,e];return null==e?Br:[e]}(n(l,u)),d[0]===Vr))return d;if("children"in l&&l.children){const t=l;if(t.children&&"skip"!==d[0])for(c=(r?t.children.length:-1)+a,f=u.concat(t);c>-1&&c<t.children.length;){const n=t.children[c];if(s=e(n,c,f)(),s[0]===Vr)return s;c="number"==typeof s[1]?s[1]:c+a}}return d}}(e,void 0,[])()}function Wr(e,t,n,r){let l,o,a;"function"==typeof t&&"function"!=typeof n?(o=void 0,a=t,l=n):(o=t,a=n,l=r),$r(e,o,function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return a(e,r,n)},l)}const qr={}.hasOwnProperty,Qr={};function Kr(e,t){e.position&&(t.position=function(e){const t=tt(e),n=et(e);if(t&&n)return{start:t,end:n}}(e))}function Yr(e,t){let n=t;if(e&&e.data){const t=e.data.hName,r=e.data.hChildren,l=e.data.hProperties;if("string"==typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&l&&Object.assign(n.properties,Dr(l)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function Xr(e,t){const n=t.data||{},r=!("value"in t)||qr.call(n,"hProperties")||qr.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,r),e.applyData(t,r)}function Zr(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function Jr(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function Gr(e,t){const n=function(e,t){const n=t||Qr,r=new Map,l=new Map,o=new Map,a={...Cr,...n.handlers},i={all:function(e){const t=[];if("children"in e){const n=e.children;let r=-1;for(;++r<n.length;){const l=i.one(n[r],e);if(l){if(r&&"break"===n[r-1].type&&(Array.isArray(l)||"text"!==l.type||(l.value=Jr(l.value)),!Array.isArray(l)&&"element"===l.type)){const e=l.children[0];e&&"text"===e.type&&(e.value=Jr(e.value))}Array.isArray(l)?t.push(...l):t.push(l)}}}return t},applyData:Yr,definitionById:r,footnoteById:l,footnoteCounts:o,footnoteOrder:[],handlers:a,one:function(e,t){const n=e.type,r=i.handlers[n];if(qr.call(i.handlers,n)&&r)return r(i,e,t);if(i.options.passThrough&&i.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,r=Dr(n);return r.children=i.all(e),r}return Dr(e)}return(i.options.unknownHandler||Xr)(i,e,t)},options:n,patch:Kr,wrap:Zr};return Wr(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?r:l,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),i}(e,t),r=n.one(e,void 0),l=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Or,r=e.options.footnoteBackLabel||Rr,l=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},i=[];let u=-1;for(;++u<e.footnoteOrder.length;){const l=e.footnoteById.get(e.footnoteOrder[u]);if(!l)continue;const o=e.all(l),a=String(l.identifier).toUpperCase(),s=Xt(a.toLowerCase());let c=0;const f=[],d=e.footnoteCounts.get(a);for(;void 0!==d&&++c<=d;){f.length>0&&f.push({type:"text",value:" "});let e="string"==typeof n?n:n(u,c);"string"==typeof e&&(e={type:"text",value:e}),f.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+s+(c>1?"-"+c:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(u,c),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){const e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...f)}else o.push(...f);const h={type:"element",tagName:"li",properties:{id:t+"fn-"+s},children:e.wrap(o,!0)};e.patch(l,h),i.push(h)}if(0!==i.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Dr(a),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(i,!0)},{type:"text",value:"\n"}]}}(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return l&&o.children.push({type:"text",value:"\n"},l),o}function el(e,t){return e&&"run"in e?async function(n,r){const l=Gr(n,{file:r,...t});await e.run(l,r)}:function(n,r){return Gr(n,{file:r,...e||t})}}function tl(e){if(e)throw e}var nl,rl;var ll=function(){if(rl)return nl;rl=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,l=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===t.call(e)},o=function(n){if(!n||"[object Object]"!==t.call(n))return!1;var r,l=e.call(n,"constructor"),o=n.constructor&&n.constructor.prototype&&e.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!l&&!o)return!1;for(r in n);return void 0===r||e.call(n,r)},a=function(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},i=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(r)return r(t,n).value}return t[n]};return nl=function e(){var t,n,r,u,s,c,f=arguments[0],d=1,p=arguments.length,h=!1;for("boolean"==typeof f&&(h=f,f=arguments[1]||{},d=2),(null==f||"object"!=typeof f&&"function"!=typeof f)&&(f={});d<p;++d)if(null!=(t=arguments[d]))for(n in t)r=i(f,n),f!==(u=i(t,n))&&(h&&u&&(o(u)||(s=l(u)))?(s?(s=!1,c=r&&l(r)?r:[]):c=r&&o(r)?r:{},a(f,{name:n,newValue:e(h,c,u)})):void 0!==u&&a(f,{name:n,newValue:u}));return f},nl}();const ol=r(ll);function al(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function il(){const e=[],t={run:function(...t){let n=-1;const r=t.pop();if("function"!=typeof r)throw new TypeError("Expected function as last argument, not "+r);!function l(o,...a){const i=e[++n];let u=-1;if(o)r(o);else{for(;++u<t.length;)null!==a[u]&&void 0!==a[u]||(a[u]=t[u]);t=a,i?function(e,t){let n;return r;function r(...t){const r=e.length>t.length;let i;r&&t.push(l);try{i=e.apply(this,t)}catch(o){if(r&&n)throw o;return l(o)}r||(i&&i.then&&"function"==typeof i.then?i.then(a,l):i instanceof Error?l(i):a(i))}function l(e,...r){n||(n=!0,t(e,...r))}function a(e){l(null,e)}}(i,l)(...a):r(null,...a)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const ul={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');sl(e);let n,r=0,l=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else l<0&&(n=!0,l=o+1);return l<0?"":e.slice(r,l)}if(t===e)return"";let a=-1,i=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else a<0&&(n=!0,a=o+1),i>-1&&(e.codePointAt(o)===t.codePointAt(i--)?i<0&&(l=o):(i=-1,l=a));r===l?l=a:l<0&&(l=e.length);return e.slice(r,l)},dirname:function(e){if(sl(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){sl(e);let t,n=e.length,r=-1,l=0,o=-1,a=0;for(;n--;){const i=e.codePointAt(n);if(47!==i)r<0&&(t=!0,r=n+1),46===i?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1);else if(t){l=n+1;break}}if(o<0||r<0||0===a||1===a&&o===r-1&&o===l+1)return"";return e.slice(o,r)},join:function(...e){let t,n=-1;for(;++n<e.length;)sl(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){sl(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,l="",o=0,a=-1,i=0,u=-1;for(;++u<=e.length;){if(u<e.length)n=e.codePointAt(u);else{if(47===n)break;n=47}if(47===n){if(a===u-1||1===i);else if(a!==u-1&&2===i){if(l.length<2||2!==o||46!==l.codePointAt(l.length-1)||46!==l.codePointAt(l.length-2))if(l.length>2){if(r=l.lastIndexOf("/"),r!==l.length-1){r<0?(l="",o=0):(l=l.slice(0,r),o=l.length-1-l.lastIndexOf("/")),a=u,i=0;continue}}else if(l.length>0){l="",o=0,a=u,i=0;continue}t&&(l=l.length>0?l+"/..":"..",o=2)}else l.length>0?l+="/"+e.slice(a+1,u):l=e.slice(a+1,u),o=u-a-1;a=u,i=0}else 46===n&&i>-1?i++:i=-1}return l}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function sl(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const cl={cwd:function(){return"/"}};function fl(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function dl(e){if("string"==typeof e)e=new URL(e);else if(!fl(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const pl=["history","path","basename","stem","extname","dirname"];class hl{constructor(e){let t;t=e?fl(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":cl.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<pl.length;){const e=pl[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)pl.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?ul.basename(this.path):void 0}set basename(e){gl(e,"basename"),ml(e,"basename"),this.path=ul.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?ul.dirname(this.path):void 0}set dirname(e){yl(this.basename,"dirname"),this.path=ul.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?ul.extname(this.path):void 0}set extname(e){if(ml(e,"extname"),yl(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=ul.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){fl(e)&&(e=dl(e)),gl(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?ul.basename(this.path,this.extname):void 0}set stem(e){gl(e,"stem"),ml(e,"stem"),this.path=ul.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){const r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){const r=new it(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function ml(e,t){if(e&&e.includes(ul.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ul.sep+"`")}function gl(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function yl(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const vl=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},bl={}.hasOwnProperty;class kl extends vl{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=il()}copy(){const e=new kl;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(ol(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(_l("data",this.frozen),this.namespace[e]=t,this):bl.call(this.namespace,e)&&this.namespace[e]||void 0:e?(_l("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=Nl(e),n=this.parser||this.Parser;return wl("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),wl("process",this.parser||this.Parser),Sl("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,l){const o=Nl(e),a=n.parse(o);function i(e,n){e||!n?l(e):r?r(n):t(void 0,n)}n.run(a,o,function(e,t,r){if(e||!t||!r)return i(e);const l=t,o=n.stringify(l,r);var a;"string"==typeof(a=o)||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(a)?r.value=o:r.result=o,i(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),wl("processSync",this.parser||this.Parser),Sl("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,tl(e),t=r}),El("processSync","process",n),t}run(e,t,n){Cl(e),this.freeze();const r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?l(void 0,n):new Promise(l);function l(l,o){const a=Nl(t);r.run(e,a,function(t,r,a){const i=r||e;t?o(t):l?l(i):n(void 0,i,a)})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){tl(e),n=t,r=!0}),El("runSync","run",r),n}stringify(e,t){this.freeze();const n=Nl(t),r=this.compiler||this.Compiler;return Sl("stringify",r),Cl(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(_l("use",this.frozen),null==e);else if("function"==typeof e)i(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?a(e):o(e)}return this;function l(e){if("function"==typeof e)i(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;i(t,n)}else o(e)}}function o(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(e.plugins),e.settings&&(r.settings=ol(!0,r.settings,e.settings))}function a(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){l(e[t])}}}function i(e,t){let r=-1,l=-1;for(;++r<n.length;)if(n[r][0]===e){l=r;break}if(-1===l)n.push([e,...t]);else if(t.length>0){let[r,...o]=t;const a=n[l][1];al(a)&&al(r)&&(r=ol(!0,a,r)),n[l]=[e,r,...o]}}}}const xl=(new kl).freeze();function wl(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Sl(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function _l(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Cl(e){if(!al(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function El(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Nl(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new hl(e)}const Pl=[],Il={allowDangerousHtml:!0},Tl=/^(https?|ircs?|mailto|xmpp)$/i,Ll=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function zl(e){const t=function(e){const t=e.rehypePlugins||Pl,n=e.remarkPlugins||Pl,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Il}:Il,l=xl().use(kr).use(n).use(el,r).use(t);return l}(e),n=function(e){const t=e.children||"",n=new hl;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,r=t.allowElement,l=t.components,o=t.disallowedElements,a=t.skipHtml,i=t.unwrapDisallowed,u=t.urlTransform||Ml;for(const c of Ll)Object.hasOwn(t,c.from)&&ne((c.from,c.to&&c.to,c.id));return Wr(e,s),ht(e,{Fragment:I.Fragment,components:l,ignoreInvalidStyle:!0,jsx:I.jsx,jsxs:I.jsxs,passKeys:!0,passNode:!0});function s(e,t,l){if("raw"===e.type&&l&&"number"==typeof t)return a?l.children.splice(t,1):l.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in _t)if(Object.hasOwn(_t,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=_t[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=u(String(n||""),t,e))}}if("element"===e.type){let a=n?!n.includes(e.tagName):!!o&&o.includes(e.tagName);if(!a&&r&&"number"==typeof t&&(a=!r(e,t,l)),a&&l&&"number"==typeof t)return i&&e.children?l.children.splice(t,1,...e.children):l.children.splice(t,1),t}}}(t.runSync(t.parse(n),n),e)}function Ml(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),l=e.indexOf("/");return-1===t||-1!==l&&t>l||-1!==n&&t>n||-1!==r&&t>r||Tl.test(e.slice(0,t))?e:""}const jl="_messageWrapper_1thak_1",Dl="_user_1thak_19",Ol="_assistant_1thak_24",Rl="_avatar_1thak_28",Fl="_avatarPlaceholder_1thak_43",Al="_brainbaseLogo_1thak_53",Ul="_messageBubble_1thak_58",Bl="_error_1thak_76",Hl="_content_1thak_81",Vl="_markdown_1thak_92",$l="_cursor_1thak_183",Wl="_errorIndicator_1thak_202",ql=({message:e,agentName:t,agentLogoUrl:n})=>{const r="user"===e.role,l="streaming"===e.status,o="error"===e.status;return I.jsxs("div",{className:`${jl} ${r?Dl:Ol}`,children:[!r&&I.jsx("div",{className:Rl,children:n?I.jsx("img",{src:n,alt:t||"AI"}):I.jsx("div",{className:Fl,children:I.jsx(F,{className:Al,color:"white",cutoutColor:"var(--bb-primary-color)"})})}),I.jsxs("div",{className:`${Ul} ${o?Bl:""}`,role:"article","aria-label":""+(r?"Your message":`${t||"AI"} says`),children:[I.jsxs("div",{className:`${Hl} ${r?"":Vl}`,children:[r?e.content:I.jsx(zl,{components:{a:({href:e,children:t})=>e?I.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):I.jsx(I.Fragment,{children:t})},children:e.content}),l&&I.jsx("span",{className:$l})]}),o&&I.jsxs("div",{className:Wl,children:[I.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",children:[I.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),I.jsx("path",{d:"M12 8V12M12 16H12.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),I.jsx("span",{children:"Failed to send"})]})]})]})},Ql="_toolCall_1wby1_1",Kl="_iconWrapper_1wby1_24",Yl="_spinner_1wby1_33",Xl="_checkIcon_1wby1_48",Zl="_errorIcon_1wby1_54",Jl="_content_1wby1_60",Gl="_label_1wby1_66",eo="_name_1wby1_73",to="_pending_1wby1_78",no="_completed_1wby1_82",ro="_error_1wby1_54",lo=({toolCall:e})=>{const t="pending"===e.status||"executing"===e.status,n="completed"===e.status,r="error"===e.status;return I.jsxs("div",{className:`${Ql} ${t?to:""} ${n?no:""} ${r?ro:""}`,children:[I.jsx("div",{className:Kl,children:t?I.jsx("div",{className:Yl}):n?I.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:Xl,children:I.jsx("path",{d:"M20 6L9 17L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):I.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:Zl,children:I.jsx("path",{d:"M6 18L18 6M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),I.jsxs("div",{className:Jl,children:[I.jsx("span",{className:Gl,children:t?"Running":n?"Completed":"Failed"}),I.jsx("span",{className:eo,children:(l=e.name,l.replace(/_/g," ").replace(/([A-Z])/g," $1").trim().toLowerCase().replace(/^./,e=>e.toUpperCase()))})]})]});var l},oo="_wrapper_10rss_2",ao="_avatar_10rss_22",io="_avatarPlaceholder_10rss_37",uo="_brainbaseLogo_10rss_47",so="_bubble_10rss_52",co="_dot_10rss_63",fo=({agentName:e="AI",agentLogoUrl:t})=>I.jsxs("div",{className:oo,role:"status","aria-label":`${e} is typing`,children:[I.jsx("div",{className:ao,children:t?I.jsx("img",{src:t,alt:e}):I.jsx("div",{className:io,children:I.jsx(F,{className:uo,color:"white",cutoutColor:"var(--bb-primary-color)"})})}),I.jsxs("div",{className:so,children:[I.jsx("span",{className:co}),I.jsx("span",{className:co}),I.jsx("span",{className:co})]})]}),po="_messageList_9tkjc_1",ho="_emptyState_9tkjc_30",mo="_emptyIcon_9tkjc_41",go="_emptyText_9tkjc_53",yo=({messages:e,toolCalls:t=[],isLoading:n,agentName:r,agentLogoUrl:l})=>{var o;const a=c.useRef(null),i=c.useRef(null);c.useEffect(()=>{var e;null==(e=i.current)||e.scrollIntoView({behavior:"smooth"})},[e,t,n]);const u=t.filter(e=>"pending"===e.status||"executing"===e.status);return I.jsxs("div",{className:po,ref:a,role:"log","aria-live":"polite",children:[0===e.length&&!n&&I.jsxs("div",{className:ho,children:[I.jsx("div",{className:mo,children:I.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:I.jsx("path",{d:"M8 12H8.01M12 12H12.01M16 12H16.01M21 12C21 16.4183 16.9706 20 12 20C10.4607 20 9.01172 19.6565 7.74467 19.0511L3 20L4.39499 16.28C3.51156 15.0423 3 13.5743 3 12C3 7.58172 7.02944 4 12 4C16.9706 4 21 7.58172 21 12Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),I.jsx("p",{className:go,children:"Start a conversation"})]}),e.map(e=>I.jsx(ql,{message:e,agentName:r,agentLogoUrl:l},e.id)),u.map(e=>I.jsx(lo,{toolCall:e},e.id)),n&&"user"===(null==(o=e[e.length-1])?void 0:o.role)&&I.jsx(fo,{agentName:r,agentLogoUrl:l}),I.jsx("div",{ref:i})]})},vo="_inputWrapper_5lgg7_1",bo="_inputContainer_5lgg7_7",ko="_textarea_5lgg7_23",xo="_sendButton_5lgg7_50",wo="_hint_5lgg7_89",So=({onSend:e,disabled:t=!1,placeholder:n="Send a message..."})=>{const[r,l]=c.useState(""),o=c.useRef(null),a=c.useCallback(()=>{const e=o.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[]);c.useEffect(()=>{a()},[r,a]);const i=c.useCallback(n=>{null==n||n.preventDefault();const a=r.trim();a&&!t&&(e(a),l(""),o.current&&(o.current.style.height="auto"))},[r,t,e]),u=c.useCallback(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),i())},[i]);return I.jsxs("form",{className:vo,onSubmit:i,children:[I.jsxs("div",{className:bo,children:[I.jsx("textarea",{ref:o,className:ko,value:r,onChange:e=>l(e.target.value),onKeyDown:u,placeholder:n,disabled:t,rows:1,"aria-label":"Message input"}),I.jsx("button",{type:"submit",className:xo,disabled:t||!r.trim(),"aria-label":"Send message",children:I.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:I.jsx("path",{d:"M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),I.jsxs("div",{className:wo,children:["Press ",I.jsx("kbd",{children:"Enter"})," to send, ",I.jsx("kbd",{children:"Shift + Enter"})," for new line"]})]})},_o="_poweredBy_9jh5q_1",Co="_logo_9jh5q_20",Eo="_poweredText_9jh5q_24",No="_text_9jh5q_36",Po=({className:e})=>I.jsxs("svg",{className:e,viewBox:"0 0 800 800",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[I.jsx("path",{d:"M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",fill:"currentColor"}),I.jsx("circle",{cx:"400",cy:"400",r:"400",fill:"currentColor"}),I.jsx("path",{d:"M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",fill:"currentColor"}),I.jsx("path",{d:"M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",fill:"currentColor"}),I.jsx("circle",{cx:"400",cy:"400",r:"350",fill:"currentColor"}),I.jsx("path",{d:"M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",fill:"currentColor"}),I.jsx("rect",{x:"399.919",y:"209",width:"270",height:"270",rx:"12",transform:"rotate(45 399.919 209)",fill:"var(--bb-surface-bg, #ffffff)"})]}),Io=({showBranding:e=!0})=>e?I.jsxs("a",{href:"https://brainbaselabs.com/",target:"_blank",rel:"noopener noreferrer",className:_o,"aria-label":"Powered by Brainbase Labs",children:[I.jsx("span",{className:Eo,children:"Powered by"}),I.jsx(Po,{className:Co}),I.jsx("span",{className:No,children:"Brainbase Labs"})]}):null,To="_container_m2o9l_1",Lo="_body_m2o9l_26",zo="_confirmationOverlay_m2o9l_35",Mo="_confirmationDialog_m2o9l_56",jo="_confirmationText_m2o9l_78",Do="_confirmationButtons_m2o9l_86",Oo="_cancelButton_m2o9l_91",Ro="_confirmButton_m2o9l_92",Fo=({config:e,messages:t,toolCalls:n=[],isLoading:r,onSendMessage:l,onClose:o,onNewChat:a})=>{var i;const[u,s]=c.useState(!1),f=t.length>0;return I.jsxs("div",{className:To,role:"dialog","aria-label":"Chat window",children:[I.jsx(ee,{agentName:e.agentName,agentLogoUrl:e.agentLogoUrl,welcomeTitle:e.welcomeMessage||"Hello there.",welcomeSubtitle:e.welcomeMessage?void 0:"How can we help?",onClose:o,onNewChatRequest:()=>{s(!0)},showNewChatButton:f,compact:f}),I.jsxs("div",{className:Lo,children:[I.jsx(yo,{messages:t,toolCalls:n,isLoading:r,agentName:e.agentName,agentLogoUrl:e.agentLogoUrl}),I.jsx(So,{onSend:l,disabled:r,placeholder:"Ask a question..."})]}),I.jsx(Io,{showBranding:(null==(i=e.styling)?void 0:i.showBranding)??!0}),u&&I.jsx("div",{className:zo,children:I.jsxs("div",{className:Mo,children:[I.jsx("p",{className:jo,children:"End current chat and start a new conversation?"}),I.jsxs("div",{className:Do,children:[I.jsx("button",{className:Oo,onClick:()=>{s(!1)},type:"button",children:"Cancel"}),I.jsx("button",{className:Ro,onClick:()=>{s(!1),null==a||a()},type:"button",children:"End Chat"})]})]})})]})},Ao="_toggleButton_11dqz_1",Uo="_icon_11dqz_31",Bo="_agentLogo_11dqz_36",Ho="_unreadBadge_11dqz_43",Vo=({onClick:e,agentLogoUrl:t,unreadCount:n=0})=>I.jsxs("button",{className:Ao,onClick:e,"aria-label":"Open chat",type:"button",children:[t?I.jsx("img",{src:t,alt:"",className:Bo}):I.jsx("svg",{className:Uo,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:I.jsx("path",{d:"M8 12H8.01M12 12H12.01M16 12H16.01M21 12C21 16.4183 16.9706 20 12 20C10.4607 20 9.01172 19.6565 7.74467 19.0511L3 20L4.39499 16.28C3.51156 15.0423 3 13.5743 3 12C3 7.58172 7.02944 4 12 4C16.9706 4 21 7.58172 21 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),n>0&&I.jsx("span",{className:Ho,children:n>9?"9+":n})]}),$o="_container_kgfgt_1",Wo="_header_kgfgt_25",qo="_logoWrapper_kgfgt_38",Qo="_logo_kgfgt_38",Ko="_closeButton_kgfgt_51",Yo="_content_kgfgt_74",Xo="_iconWrapper_kgfgt_84",Zo="_errorIcon_kgfgt_95",Jo="_title_kgfgt_101",Go="_description_kgfgt_109",ea="_retryButton_kgfgt_117",ta="_footer_kgfgt_139",na="_poweredBy_kgfgt_146",ra="_footerLogo_kgfgt_160",la=({errorType:e,message:t,onRetry:n,onClose:r})=>{const{title:l,description:o,icon:a}=(()=>{switch(e){case"not_found":return{title:"Chat Not Found",description:t||"This chat widget is not configured correctly. Please check the embed ID.",icon:I.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:Zo,children:[I.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),I.jsx("path",{d:"M12 7V13M12 16V16.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})};case"network":return{title:"Connection Error",description:t||"Unable to connect to the chat service. Please check your internet connection.",icon:I.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:Zo,children:[I.jsx("path",{d:"M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z",stroke:"currentColor",strokeWidth:"1.5"}),I.jsx("path",{d:"M8 15L16 9M8 9L16 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})};default:return{title:"Something Went Wrong",description:t||"An unexpected error occurred. Please try again later.",icon:I.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:Zo,children:I.jsx("path",{d:"M12 9V13M12 17H12.01M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}}})();return I.jsxs("div",{className:$o,children:[I.jsxs("div",{className:Wo,children:[I.jsx("div",{className:qo,children:I.jsx(F,{className:Qo,color:"white",cutoutColor:"var(--bb-primary-color)"})}),r&&I.jsx("button",{className:Ko,onClick:r,"aria-label":"Close",type:"button",children:I.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:I.jsx("path",{d:"M6 18L18 6M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),I.jsxs("div",{className:Yo,children:[I.jsx("div",{className:Xo,children:a}),I.jsx("h2",{className:Jo,children:l}),I.jsx("p",{className:Go,children:o}),n&&I.jsx("button",{className:ea,onClick:n,type:"button",children:"Try Again"})]}),I.jsx("div",{className:ta,children:I.jsxs("a",{href:"https://brainbaselabs.com",target:"_blank",rel:"noopener noreferrer",className:na,children:["Powered by"," ",I.jsx(F,{className:ra,color:"var(--bb-text-tertiary)",cutoutColor:"var(--bb-surface-bg)"}),I.jsx("span",{children:"Brainbase Labs"})]})})]})},oa={widget:"_widget_1ehud_1","bottom-right":"_bottom-right_1ehud_10","bottom-left":"_bottom-left_1ehud_17",inline:"_inline_1ehud_25"},aa=({embedId:e,apiBaseUrl:t=j,mockMode:n=!1,mockResponses:r,position:l="bottom-right",defaultOpen:o=!1,primaryColor:a,agentName:i,agentLogoUrl:u,welcomeMessage:s,showBranding:f,className:d,onSessionStart:p,onSessionEnd:h,onMessage:m,onError:g})=>{const[y,v]=c.useState(o),[b,k]=c.useState(null),[x,w]=c.useState(!0),[S,_]=c.useState(null),[C,E]=c.useState(),N=c.useRef(!1),P=c.useMemo(()=>n?function(e,t){const n={...D,...e},r=t??O,l=`mock-session-${Date.now()}`;return{getDeploymentConfig:async e=>(await R(300),n),async*sendMessage(e){yield{type:"session",data:{session_id:l,is_new:!0},timestamp:Date.now()};const t=r.find(t=>"string"==typeof t.trigger?e.toLowerCase().includes(t.trigger.toLowerCase()):t.trigger.test(e))??r[r.length-1];if(await R(t.delay??500),t.toolCalls)for(const r of t.toolCalls)yield{type:"tool_call",data:{function:r.name,args:r.arguments},timestamp:Date.now()},await R(300),yield{type:"tool_call",data:{function:r.name,result:r.result},timestamp:Date.now()},await R(200);const n=t.response.split(" ");let o="";for(const r of n)o+=(o?" ":"")+r,yield{type:"message",data:{content:o,role:"assistant"},timestamp:Date.now()},await R(30+40*Math.random());yield{type:"done",data:{session_id:l},timestamp:Date.now()}}}}({},r):function(e=j){return{async getDeploymentConfig(t){const n=await fetch(`${e}/chat/config/${t}`);if(!n.ok)throw new Error(`Failed to fetch deployment config: ${n.status}`);const r=await n.json();return{embedId:r.embedId,deploymentId:"",workerId:"",flowId:"",welcomeMessage:r.welcomeMessage,agentName:r.agentName,agentLogoUrl:r.agentLogoUrl,primaryColor:r.primaryColor,styling:r.styling}},async sendMessage(t){const n=await fetch(`${e}/chat/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({embed_id:t.embedId,message:t.message,session_id:t.sessionId||void 0,metadata:t.metadata})});if(!n.ok){const e=await n.text();throw new Error(`Failed to send message: ${n.status} - ${e}`)}if(!n.body)throw new Error("No response stream available");return n.body}}}(t),[n,r,t]),T=c.useCallback(async()=>{if(!N.current||!b){w(!0),_(null),E(void 0);try{const t=await P.getDeploymentConfig(e);k(t),N.current=!0}catch(t){const r=t instanceof Error?t:new Error("Failed to load config");r.message.includes("404")?(_("not_found"),E("The chat widget with this embed ID was not found.")):r.message.includes("Failed to fetch")||r.message.includes("network")?_("network"):_("unknown"),n&&(k({embedId:e,deploymentId:"mock-deployment",workerId:"mock-worker",flowId:"mock-flow",primaryColor:"#1a1a2e",agentName:"AI Assistant",styling:{}}),_(null),N.current=!0),null==g||g(r)}finally{w(!1)}}},[e,n,P,g,b]);c.useEffect(()=>{N.current=!1,T()},[e,n,P]);const L=c.useMemo(()=>{const t=b??{embedId:e,deploymentId:"",workerId:"",flowId:""};return{...t,primaryColor:a??t.primaryColor??"#1a1a2e",agentName:i??t.agentName,agentLogoUrl:u??t.agentLogoUrl,welcomeMessage:s??t.welcomeMessage,styling:{...t.styling??{},...void 0!==f?{showBranding:f}:{}}}},[b,e,a,i,u,s,f]),z=M({config:L,apiClient:P,mockMode:n,onSessionStart:p,onSessionEnd:h,onMessage:m,onError:g}),F=c.useMemo(()=>({"--bb-primary-color":L.primaryColor??"#1a1a2e"}),[L.primaryColor]),A=()=>{v(!1)},U=()=>{T()},B="inline"===l;return x?null:S&&!n?B||y?I.jsx("div",{className:`${oa.widget} ${oa[l]} ${d??""}`,style:F,children:I.jsx(la,{errorType:S,message:C,onRetry:U,onClose:B?void 0:A})}):I.jsx("div",{className:`${oa.widget} ${oa[l]} ${d??""}`,style:F,children:I.jsx(Vo,{onClick:()=>v(!0),agentName:i})}):I.jsx("div",{className:`${oa.widget} ${oa[l]} ${d??""}`,style:F,children:y||B?I.jsx(Fo,{config:L,messages:z.messages,isLoading:z.isLoading,onSendMessage:z.sendMessage,onClose:B?void 0:A,onNewChat:()=>{z.endSession(),z.startNewSession()}}):I.jsx(Vo,{onClick:()=>v(!0),agentName:L.agentName,agentLogoUrl:L.agentLogoUrl})})};class ia extends HTMLElement{constructor(){super(...arguments),n(this,"root",null),n(this,"container",null)}static get observedAttributes(){return["embed-id","position","primary-color","agent-name","welcome-message","api-base-url","default-open"]}connectedCallback(){this.container=document.createElement("div"),this.container.className="brainbase-chat-container",this.appendChild(this.container),this.root=E.createRoot(this.container),this.render()}disconnectedCallback(){this.root&&(this.root.unmount(),this.root=null),this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null)}attributeChangedCallback(e,t,n){t!==n&&this.root&&this.render()}render(){if(!this.root)return;const e=this.getProps();e.embedId?this.root.render(f.createElement(aa,e)):console.warn("[Brainbase Chat] embed-id attribute is required")}getProps(){return{embedId:this.getAttribute("embed-id")||"",position:this.getPositionAttribute(),primaryColor:this.getAttribute("primary-color")||void 0,agentName:this.getAttribute("agent-name")||void 0,welcomeMessage:this.getAttribute("welcome-message")||void 0,apiBaseUrl:this.getAttribute("api-base-url")||void 0,defaultOpen:"true"===this.getAttribute("default-open")}}getPositionAttribute(){const e=this.getAttribute("position");return"bottom-left"===e||"inline"===e?e:"bottom-right"}}return"undefined"==typeof customElements||customElements.get("brainbase-chat")||customElements.define("brainbase-chat",ia),"undefined"!=typeof window&&console.log("[Brainbase Chat] Widget loaded and ready"),e.ChatWidgetElement=ia,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
11
+ */function T(){if(f)return b;f=1;var e=l(),t=C();function n(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=new Set,r={};function o(e,t){a(e,t),a(e+"Capture",t)}function a(e,t){for(r[e]=t,e=0;e<t.length;e++)i.add(t[e])}var s=!("undefined"==typeof window||void 0===window.document||void 0===window.document.createElement),c=Object.prototype.hasOwnProperty,u=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,d={},h={};function p(e,t,n,i,r,o,a){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var m={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){m[e]=new p(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];m[t]=new p(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){m[e]=new p(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){m[e]=new p(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){m[e]=new p(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){m[e]=new p(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){m[e]=new p(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){m[e]=new p(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){m[e]=new p(e,5,!1,e.toLowerCase(),null,!1,!1)});var g=/[\-:]([a-z])/g;function v(e){return e[1].toUpperCase()}function y(e,t,n,i){var r=m.hasOwnProperty(t)?m[t]:null;(null!==r?0!==r.type:i||!(2<t.length)||"o"!==t[0]&&"O"!==t[0]||"n"!==t[1]&&"N"!==t[1])&&(function(e,t,n,i){if(null==t||function(e,t,n,i){if(null!==n&&0===n.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!i&&(null!==n?!n.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,n,i))return!0;if(i)return!1;if(null!==n)switch(n.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}(t,n,r,i)&&(n=null),i||null===r?function(e){return!!c.call(h,e)||!c.call(d,e)&&(u.test(e)?h[e]=!0:(d[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):r.mustUseProperty?e[r.propertyName]=null===n?3!==r.type&&"":n:(t=r.attributeName,i=r.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(r=r.type)||4===r&&!0===n?"":""+n,i?e.setAttributeNS(i,t,n):e.setAttribute(t,n))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(g,v);m[t]=new p(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(g,v);m[t]=new p(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(g,v);m[t]=new p(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){m[e]=new p(e,1,!1,e.toLowerCase(),null,!1,!1)}),m.xlinkHref=new p("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){m[e]=new p(e,1,!1,e.toLowerCase(),null,!0,!0)});var k=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,S=Symbol.for("react.element"),T=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),_=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),L=Symbol.iterator;function A(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=L&&e[L]||e["@@iterator"])?e:null}var j,U=Object.assign;function F(e){if(void 0===j)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);j=t&&t[1]||""}return"\n"+j+e}var B=!1;function z(e,t){if(!e||B)return"";B=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(l){var i=l}Reflect.construct(e,[],t)}else{try{t.call()}catch(l){i=l}e.call(t.prototype)}else{try{throw Error()}catch(l){i=l}e()}}catch(l){if(l&&i&&"string"==typeof l.stack){for(var r=l.stack.split("\n"),o=i.stack.split("\n"),a=r.length-1,s=o.length-1;1<=a&&0<=s&&r[a]!==o[s];)s--;for(;1<=a&&0<=s;a--,s--)if(r[a]!==o[s]){if(1!==a||1!==s)do{if(a--,0>--s||r[a]!==o[s]){var c="\n"+r[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}}while(1<=a&&0<=s);break}}}finally{B=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?F(e):""}function V(e){switch(e.tag){case 5:return F(e.type);case 16:return F("Lazy");case 13:return F("Suspense");case 19:return F("SuspenseList");case 0:case 2:case 15:return e=z(e.type,!1);case 11:return e=z(e.type.render,!1);case 1:return e=z(e.type,!0);default:return""}}function q(e){if(null==e)return null;if("function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case w:return"Fragment";case T:return"Portal";case x:return"Profiler";case E:return"StrictMode";case I:return"Suspense";case N:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case _:return(e.displayName||"Context")+".Consumer";case P:return(e._context.displayName||"Context")+".Provider";case R:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case O:return null!==(t=e.displayName||null)?t:q(e.type)||"Memo";case M:t=e._payload,e=e._init;try{return q(e(t))}catch(n){}}return null}function H(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return q(t);case 8:return t===E?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t}return null}function W(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function K(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function G(e){e._valueTracker||(e._valueTracker=function(e){var t=K(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),i=""+e[t];if(!e.hasOwnProperty(t)&&void 0!==n&&"function"==typeof n.get&&"function"==typeof n.set){var r=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){i=""+e,o.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return i},setValue:function(e){i=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function $(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),i="";return e&&(i=K(e)?e.checked?"true":"false":e.value),(e=i)!==n&&(t.setValue(e),!0)}function J(e){if(void 0===(e=e||("undefined"!=typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function Q(e,t){var n=t.checked;return U({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function Y(e,t){var n=null==t.defaultValue?"":t.defaultValue,i=null!=t.checked?t.checked:t.defaultChecked;n=W(null!=t.value?t.value:n),e._wrapperState={initialChecked:i,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function X(e,t){null!=(t=t.checked)&&y(e,"checked",t,!1)}function Z(e,t){X(e,t);var n=W(t.value),i=t.type;if(null!=n)"number"===i?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===i||"reset"===i)return void e.removeAttribute("value");t.hasOwnProperty("value")?te(e,t.type,n):t.hasOwnProperty("defaultValue")&&te(e,t.type,W(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function ee(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var i=t.type;if(!("submit"!==i&&"reset"!==i||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function te(e,t,n){"number"===t&&J(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ne=Array.isArray;function ie(e,t,n,i){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&i&&(e[n].defaultSelected=!0)}else{for(n=""+W(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(i&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function re(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(n(91));return U({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function oe(e,t){var i=t.value;if(null==i){if(i=t.children,t=t.defaultValue,null!=i){if(null!=t)throw Error(n(92));if(ne(i)){if(1<i.length)throw Error(n(93));i=i[0]}t=i}null==t&&(t=""),i=t}e._wrapperState={initialValue:W(i)}}function ae(e,t){var n=W(t.value),i=W(t.defaultValue);null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=i&&(e.defaultValue=""+i)}function se(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}function ce(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function le(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?ce(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var ue,de,he=(de=function(e,t){if("http://www.w3.org/2000/svg"!==e.namespaceURI||"innerHTML"in e)e.innerHTML=t;else{for((ue=ue||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ue.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,i){MSApp.execUnsafeLocalFunction(function(){return de(e,t)})}:de);function pe(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var fe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},me=["Webkit","ms","Moz","O"];function ge(e,t,n){return null==t||"boolean"==typeof t||""===t?"":n||"number"!=typeof t||0===t||fe.hasOwnProperty(e)&&fe[e]?(""+t).trim():t+"px"}function ve(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var i=0===n.indexOf("--"),r=ge(n,t[n],i);"float"===n&&(n="cssFloat"),i?e.setProperty(n,r):e[n]=r}}Object.keys(fe).forEach(function(e){me.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),fe[t]=fe[e]})});var ye=U({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function be(e,t){if(t){if(ye[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(n(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(n(60));if("object"!=typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(n(61))}if(null!=t.style&&"object"!=typeof t.style)throw Error(n(62))}}function ke(e,t){if(-1===e.indexOf("-"))return"string"==typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Se=null;function Ce(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Te=null,we=null,Ee=null;function xe(e){if(e=kr(e)){if("function"!=typeof Te)throw Error(n(280));var t=e.stateNode;t&&(t=Cr(t),Te(e.stateNode,e.type,t))}}function Pe(e){we?Ee?Ee.push(e):Ee=[e]:we=e}function _e(){if(we){var e=we,t=Ee;if(Ee=we=null,xe(e),t)for(e=0;e<t.length;e++)xe(t[e])}}function Re(e,t){return e(t)}function Ie(){}var Ne=!1;function Oe(e,t,n){if(Ne)return e(t,n);Ne=!0;try{return Re(e,t,n)}finally{Ne=!1,(null!==we||null!==Ee)&&(Ie(),_e())}}function Me(e,t){var i=e.stateNode;if(null===i)return null;var r=Cr(i);if(null===r)return null;i=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(i&&"function"!=typeof i)throw Error(n(231,t,typeof i));return i}var De=!1;if(s)try{var Le={};Object.defineProperty(Le,"passive",{get:function(){De=!0}}),window.addEventListener("test",Le,Le),window.removeEventListener("test",Le,Le)}catch(de){De=!1}function Ae(e,t,n,i,r,o,a,s,c){var l=Array.prototype.slice.call(arguments,3);try{t.apply(n,l)}catch(u){this.onError(u)}}var je=!1,Ue=null,Fe=!1,Be=null,ze={onError:function(e){je=!0,Ue=e}};function Ve(e,t,n,i,r,o,a,s,c){je=!1,Ue=null,Ae.apply(ze,arguments)}function qe(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{!!(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function He(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function We(e){if(qe(e)!==e)throw Error(n(188))}function Ke(e){return null!==(e=function(e){var t=e.alternate;if(!t){if(null===(t=qe(e)))throw Error(n(188));return t!==e?null:e}for(var i=e,r=t;;){var o=i.return;if(null===o)break;var a=o.alternate;if(null===a){if(null!==(r=o.return)){i=r;continue}break}if(o.child===a.child){for(a=o.child;a;){if(a===i)return We(o),e;if(a===r)return We(o),t;a=a.sibling}throw Error(n(188))}if(i.return!==r.return)i=o,r=a;else{for(var s=!1,c=o.child;c;){if(c===i){s=!0,i=o,r=a;break}if(c===r){s=!0,r=o,i=a;break}c=c.sibling}if(!s){for(c=a.child;c;){if(c===i){s=!0,i=a,r=o;break}if(c===r){s=!0,r=a,i=o;break}c=c.sibling}if(!s)throw Error(n(189))}}if(i.alternate!==r)throw Error(n(190))}if(3!==i.tag)throw Error(n(188));return i.stateNode.current===i?e:t}(e))?Ge(e):null}function Ge(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){var t=Ge(e);if(null!==t)return t;e=e.sibling}return null}var $e=t.unstable_scheduleCallback,Je=t.unstable_cancelCallback,Qe=t.unstable_shouldYield,Ye=t.unstable_requestPaint,Xe=t.unstable_now,Ze=t.unstable_getCurrentPriorityLevel,et=t.unstable_ImmediatePriority,tt=t.unstable_UserBlockingPriority,nt=t.unstable_NormalPriority,it=t.unstable_LowPriority,rt=t.unstable_IdlePriority,ot=null,at=null;var st=Math.clz32?Math.clz32:function(e){return e>>>=0,0===e?32:31-(ct(e)/lt|0)|0},ct=Math.log,lt=Math.LN2;var ut=64,dt=4194304;function ht(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function pt(e,t){var n=e.pendingLanes;if(0===n)return 0;var i=0,r=e.suspendedLanes,o=e.pingedLanes,a=268435455&n;if(0!==a){var s=a&~r;0!==s?i=ht(s):0!==(o&=a)&&(i=ht(o))}else 0!==(a=n&~r)?i=ht(a):0!==o&&(i=ht(o));if(0===i)return 0;if(0!==t&&t!==i&&0===(t&r)&&((r=i&-i)>=(o=t&-t)||16===r&&4194240&o))return t;if(4&i&&(i|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=i;0<t;)r=1<<(n=31-st(t)),i|=e[n],t&=~r;return i}function ft(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function mt(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function gt(){var e=ut;return!(4194240&(ut<<=1))&&(ut=64),e}function vt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function yt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-st(t)]=n}function bt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var i=31-st(n),r=1<<i;r&t|e[i]&t&&(e[i]|=t),n&=~r}}var kt=0;function St(e){return 1<(e&=-e)?4<e?268435455&e?16:536870912:4:1}var Ct,Tt,wt,Et,xt,Pt=!1,_t=[],Rt=null,It=null,Nt=null,Ot=new Map,Mt=new Map,Dt=[],Lt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function At(e,t){switch(e){case"focusin":case"focusout":Rt=null;break;case"dragenter":case"dragleave":It=null;break;case"mouseover":case"mouseout":Nt=null;break;case"pointerover":case"pointerout":Ot.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mt.delete(t.pointerId)}}function jt(e,t,n,i,r,o){return null===e||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:i,nativeEvent:o,targetContainers:[r]},null!==t&&(null!==(t=kr(t))&&Tt(t)),e):(e.eventSystemFlags|=i,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function Ut(e){var t=br(e.target);if(null!==t){var n=qe(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=He(n)))return e.blockedOn=t,void xt(e.priority,function(){wt(n)})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Ft(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Qt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==n)return null!==(t=kr(n))&&Tt(t),e.blockedOn=n,!1;var i=new(n=e.nativeEvent).constructor(n.type,n);Se=i,n.target.dispatchEvent(i),Se=null,t.shift()}return!0}function Bt(e,t,n){Ft(e)&&n.delete(t)}function zt(){Pt=!1,null!==Rt&&Ft(Rt)&&(Rt=null),null!==It&&Ft(It)&&(It=null),null!==Nt&&Ft(Nt)&&(Nt=null),Ot.forEach(Bt),Mt.forEach(Bt)}function Vt(e,n){e.blockedOn===n&&(e.blockedOn=null,Pt||(Pt=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,zt)))}function qt(e){function t(t){return Vt(t,e)}if(0<_t.length){Vt(_t[0],e);for(var n=1;n<_t.length;n++){var i=_t[n];i.blockedOn===e&&(i.blockedOn=null)}}for(null!==Rt&&Vt(Rt,e),null!==It&&Vt(It,e),null!==Nt&&Vt(Nt,e),Ot.forEach(t),Mt.forEach(t),n=0;n<Dt.length;n++)(i=Dt[n]).blockedOn===e&&(i.blockedOn=null);for(;0<Dt.length&&null===(n=Dt[0]).blockedOn;)Ut(n),null===n.blockedOn&&Dt.shift()}var Ht=k.ReactCurrentBatchConfig,Wt=!0;function Kt(e,t,n,i){var r=kt,o=Ht.transition;Ht.transition=null;try{kt=1,$t(e,t,n,i)}finally{kt=r,Ht.transition=o}}function Gt(e,t,n,i){var r=kt,o=Ht.transition;Ht.transition=null;try{kt=4,$t(e,t,n,i)}finally{kt=r,Ht.transition=o}}function $t(e,t,n,i){if(Wt){var r=Qt(e,t,n,i);if(null===r)Wi(e,t,i,Jt,n),At(e,i);else if(function(e,t,n,i,r){switch(t){case"focusin":return Rt=jt(Rt,e,t,n,i,r),!0;case"dragenter":return It=jt(It,e,t,n,i,r),!0;case"mouseover":return Nt=jt(Nt,e,t,n,i,r),!0;case"pointerover":var o=r.pointerId;return Ot.set(o,jt(Ot.get(o)||null,e,t,n,i,r)),!0;case"gotpointercapture":return o=r.pointerId,Mt.set(o,jt(Mt.get(o)||null,e,t,n,i,r)),!0}return!1}(r,e,t,n,i))i.stopPropagation();else if(At(e,i),4&t&&-1<Lt.indexOf(e)){for(;null!==r;){var o=kr(r);if(null!==o&&Ct(o),null===(o=Qt(e,t,n,i))&&Wi(e,t,i,Jt,n),o===r)break;r=o}null!==r&&i.stopPropagation()}else Wi(e,t,i,null,n)}}var Jt=null;function Qt(e,t,n,i){if(Jt=null,null!==(e=br(e=Ce(i))))if(null===(t=qe(e)))e=null;else if(13===(n=t.tag)){if(null!==(e=He(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Jt=e,null}function Yt(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Ze()){case et:return 1;case tt:return 4;case nt:case it:return 16;case rt:return 536870912;default:return 16}default:return 16}}var Xt=null,Zt=null,en=null;function tn(){if(en)return en;var e,t,n=Zt,i=n.length,r="value"in Xt?Xt.value:Xt.textContent,o=r.length;for(e=0;e<i&&n[e]===r[e];e++);var a=i-e;for(t=1;t<=a&&n[i-t]===r[o-t];t++);return en=r.slice(e,1<t?1-t:void 0)}function nn(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function rn(){return!0}function on(){return!1}function an(e){function t(t,n,i,r,o){for(var a in this._reactName=t,this._targetInst=i,this.type=n,this.nativeEvent=r,this.target=o,this.currentTarget=null,e)e.hasOwnProperty(a)&&(t=e[a],this[a]=t?t(r):r[a]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?rn:on,this.isPropagationStopped=on,this}return U(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!=typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=rn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!=typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=rn)},persist:function(){},isPersistent:rn}),t}var sn,cn,ln,un={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},dn=an(un),hn=U({},un,{view:0,detail:0}),pn=an(hn),fn=U({},hn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ln&&(ln&&"mousemove"===e.type?(sn=e.screenX-ln.screenX,cn=e.screenY-ln.screenY):cn=sn=0,ln=e),sn)},movementY:function(e){return"movementY"in e?e.movementY:cn}}),mn=an(fn),gn=an(U({},fn,{dataTransfer:0})),vn=an(U({},hn,{relatedTarget:0})),yn=an(U({},un,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=U({},un,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),kn=an(bn),Sn=an(U({},un,{data:0})),Cn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Tn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},wn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function En(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=wn[e])&&!!t[e]}function xn(){return En}var Pn=U({},hn,{key:function(e){if(e.key){var t=Cn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=nn(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?Tn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xn,charCode:function(e){return"keypress"===e.type?nn(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?nn(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),_n=an(Pn),Rn=an(U({},fn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),In=an(U({},hn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xn})),Nn=an(U({},un,{propertyName:0,elapsedTime:0,pseudoElement:0})),On=U({},fn,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Mn=an(On),Dn=[9,13,27,32],Ln=s&&"CompositionEvent"in window,An=null;s&&"documentMode"in document&&(An=document.documentMode);var jn=s&&"TextEvent"in window&&!An,Un=s&&(!Ln||An&&8<An&&11>=An),Fn=String.fromCharCode(32),Bn=!1;function zn(e,t){switch(e){case"keyup":return-1!==Dn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vn(e){return"object"==typeof(e=e.detail)&&"data"in e?e.data:null}var qn=!1;var Hn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Hn[e.type]:"textarea"===t}function Kn(e,t,n,i){Pe(i),0<(t=Gi(t,"onChange")).length&&(n=new dn("onChange","change",null,n,i),e.push({event:n,listeners:t}))}var Gn=null,$n=null;function Jn(e){Fi(e,0)}function Qn(e){if($(Sr(e)))return e}function Yn(e,t){if("change"===e)return t}var Xn=!1;if(s){var Zn;if(s){var ei="oninput"in document;if(!ei){var ti=document.createElement("div");ti.setAttribute("oninput","return;"),ei="function"==typeof ti.oninput}Zn=ei}else Zn=!1;Xn=Zn&&(!document.documentMode||9<document.documentMode)}function ni(){Gn&&(Gn.detachEvent("onpropertychange",ii),$n=Gn=null)}function ii(e){if("value"===e.propertyName&&Qn($n)){var t=[];Kn(t,$n,e,Ce(e)),Oe(Jn,t)}}function ri(e,t,n){"focusin"===e?(ni(),$n=n,(Gn=t).attachEvent("onpropertychange",ii)):"focusout"===e&&ni()}function oi(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Qn($n)}function ai(e,t){if("click"===e)return Qn(t)}function si(e,t){if("input"===e||"change"===e)return Qn(t)}var ci="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t};function li(e,t){if(ci(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;var n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(i=0;i<n.length;i++){var r=n[i];if(!c.call(t,r)||!ci(e[r],t[r]))return!1}return!0}function ui(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function di(e,t){var n,i=ui(e);for(e=0;i;){if(3===i.nodeType){if(n=e+i.textContent.length,e<=t&&n>=t)return{node:i,offset:t-e};e=n}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=ui(i)}}function hi(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?hi(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function pi(){for(var e=window,t=J();t instanceof e.HTMLIFrameElement;){try{var n="string"==typeof t.contentWindow.location.href}catch(i){n=!1}if(!n)break;t=J((e=t.contentWindow).document)}return t}function fi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}function mi(e){var t=pi(),n=e.focusedElem,i=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&hi(n.ownerDocument.documentElement,n)){if(null!==i&&fi(n))if(t=i.start,void 0===(e=i.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var r=n.textContent.length,o=Math.min(i.start,r);i=void 0===i.end?o:Math.min(i.end,r),!e.extend&&o>i&&(r=i,i=o,o=r),r=di(n,o);var a=di(n,i);r&&a&&(1!==e.rangeCount||e.anchorNode!==r.node||e.anchorOffset!==r.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&((t=t.createRange()).setStart(r.node,r.offset),e.removeAllRanges(),o>i?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"==typeof n.focus&&n.focus(),n=0;n<t.length;n++)(e=t[n]).element.scrollLeft=e.left,e.element.scrollTop=e.top}}var gi=s&&"documentMode"in document&&11>=document.documentMode,vi=null,yi=null,bi=null,ki=!1;function Si(e,t,n){var i=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;ki||null==vi||vi!==J(i)||("selectionStart"in(i=vi)&&fi(i)?i={start:i.selectionStart,end:i.selectionEnd}:i={anchorNode:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset},bi&&li(bi,i)||(bi=i,0<(i=Gi(yi,"onSelect")).length&&(t=new dn("onSelect","select",null,t,n),e.push({event:t,listeners:i}),t.target=vi)))}function Ci(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Ti={animationend:Ci("Animation","AnimationEnd"),animationiteration:Ci("Animation","AnimationIteration"),animationstart:Ci("Animation","AnimationStart"),transitionend:Ci("Transition","TransitionEnd")},wi={},Ei={};function xi(e){if(wi[e])return wi[e];if(!Ti[e])return e;var t,n=Ti[e];for(t in n)if(n.hasOwnProperty(t)&&t in Ei)return wi[e]=n[t];return e}s&&(Ei=document.createElement("div").style,"AnimationEvent"in window||(delete Ti.animationend.animation,delete Ti.animationiteration.animation,delete Ti.animationstart.animation),"TransitionEvent"in window||delete Ti.transitionend.transition);var Pi=xi("animationend"),_i=xi("animationiteration"),Ri=xi("animationstart"),Ii=xi("transitionend"),Ni=new Map,Oi="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Mi(e,t){Ni.set(e,t),o(t,[e])}for(var Di=0;Di<Oi.length;Di++){var Li=Oi[Di];Mi(Li.toLowerCase(),"on"+(Li[0].toUpperCase()+Li.slice(1)))}Mi(Pi,"onAnimationEnd"),Mi(_i,"onAnimationIteration"),Mi(Ri,"onAnimationStart"),Mi("dblclick","onDoubleClick"),Mi("focusin","onFocus"),Mi("focusout","onBlur"),Mi(Ii,"onTransitionEnd"),a("onMouseEnter",["mouseout","mouseover"]),a("onMouseLeave",["mouseout","mouseover"]),a("onPointerEnter",["pointerout","pointerover"]),a("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ai="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),ji=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ai));function Ui(e,t,i){var r=e.type||"unknown-event";e.currentTarget=i,function(e,t,i,r,o,a,s,c,l){if(Ve.apply(this,arguments),je){if(!je)throw Error(n(198));var u=Ue;je=!1,Ue=null,Fe||(Fe=!0,Be=u)}}(r,t,void 0,e),e.currentTarget=null}function Fi(e,t){t=!!(4&t);for(var n=0;n<e.length;n++){var i=e[n],r=i.event;i=i.listeners;e:{var o=void 0;if(t)for(var a=i.length-1;0<=a;a--){var s=i[a],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==o&&r.isPropagationStopped())break e;Ui(r,s,l),o=c}else for(a=0;a<i.length;a++){if(c=(s=i[a]).instance,l=s.currentTarget,s=s.listener,c!==o&&r.isPropagationStopped())break e;Ui(r,s,l),o=c}}}if(Fe)throw e=Be,Fe=!1,Be=null,e}function Bi(e,t){var n=t[gr];void 0===n&&(n=t[gr]=new Set);var i=e+"__bubble";n.has(i)||(Hi(t,e,2,!1),n.add(i))}function zi(e,t,n){var i=0;t&&(i|=4),Hi(n,e,i,t)}var Vi="_reactListening"+Math.random().toString(36).slice(2);function qi(e){if(!e[Vi]){e[Vi]=!0,i.forEach(function(t){"selectionchange"!==t&&(ji.has(t)||zi(t,!1,e),zi(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Vi]||(t[Vi]=!0,zi("selectionchange",!1,t))}}function Hi(e,t,n,i){switch(Yt(t)){case 1:var r=Kt;break;case 4:r=Gt;break;default:r=$t}n=r.bind(null,t,n,e),r=void 0,!De||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),i?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function Wi(e,t,n,i,r){var o=i;if(!(1&t||2&t||null===i))e:for(;;){if(null===i)return;var a=i.tag;if(3===a||4===a){var s=i.stateNode.containerInfo;if(s===r||8===s.nodeType&&s.parentNode===r)break;if(4===a)for(a=i.return;null!==a;){var c=a.tag;if((3===c||4===c)&&((c=a.stateNode.containerInfo)===r||8===c.nodeType&&c.parentNode===r))return;a=a.return}for(;null!==s;){if(null===(a=br(s)))return;if(5===(c=a.tag)||6===c){i=o=a;continue e}s=s.parentNode}}i=i.return}Oe(function(){var i=o,r=Ce(n),a=[];e:{var s=Ni.get(e);if(void 0!==s){var c=dn,l=e;switch(e){case"keypress":if(0===nn(n))break e;case"keydown":case"keyup":c=_n;break;case"focusin":l="focus",c=vn;break;case"focusout":l="blur",c=vn;break;case"beforeblur":case"afterblur":c=vn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=mn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=gn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=In;break;case Pi:case _i:case Ri:c=yn;break;case Ii:c=Nn;break;case"scroll":c=pn;break;case"wheel":c=Mn;break;case"copy":case"cut":case"paste":c=kn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Rn}var u=!!(4&t),d=!u&&"scroll"===e,h=u?null!==s?s+"Capture":null:s;u=[];for(var p,f=i;null!==f;){var m=(p=f).stateNode;if(5===p.tag&&null!==m&&(p=m,null!==h&&(null!=(m=Me(f,h))&&u.push(Ki(f,m,p)))),d)break;f=f.return}0<u.length&&(s=new c(s,l,null,n,r),a.push({event:s,listeners:u}))}}if(!(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(s="mouseover"===e||"pointerover"===e)||n===Se||!(l=n.relatedTarget||n.fromElement)||!br(l)&&!l[mr])&&(c||s)&&(s=r.window===r?r:(s=r.ownerDocument)?s.defaultView||s.parentWindow:window,c?(c=i,null!==(l=(l=n.relatedTarget||n.toElement)?br(l):null)&&(l!==(d=qe(l))||5!==l.tag&&6!==l.tag)&&(l=null)):(c=null,l=i),c!==l)){if(u=mn,m="onMouseLeave",h="onMouseEnter",f="mouse","pointerout"!==e&&"pointerover"!==e||(u=Rn,m="onPointerLeave",h="onPointerEnter",f="pointer"),d=null==c?s:Sr(c),p=null==l?s:Sr(l),(s=new u(m,f+"leave",c,n,r)).target=d,s.relatedTarget=p,m=null,br(r)===i&&((u=new u(h,f+"enter",l,n,r)).target=p,u.relatedTarget=d,m=u),d=m,c&&l)e:{for(h=l,f=0,p=u=c;p;p=$i(p))f++;for(p=0,m=h;m;m=$i(m))p++;for(;0<f-p;)u=$i(u),f--;for(;0<p-f;)h=$i(h),p--;for(;f--;){if(u===h||null!==h&&u===h.alternate)break e;u=$i(u),h=$i(h)}u=null}else u=null;null!==c&&Ji(a,s,c,u,!1),null!==l&&null!==d&&Ji(a,d,l,u,!0)}if("select"===(c=(s=i?Sr(i):window).nodeName&&s.nodeName.toLowerCase())||"input"===c&&"file"===s.type)var g=Yn;else if(Wn(s))if(Xn)g=si;else{g=oi;var v=ri}else(c=s.nodeName)&&"input"===c.toLowerCase()&&("checkbox"===s.type||"radio"===s.type)&&(g=ai);switch(g&&(g=g(e,i))?Kn(a,g,n,r):(v&&v(e,s,i),"focusout"===e&&(v=s._wrapperState)&&v.controlled&&"number"===s.type&&te(s,"number",s.value)),v=i?Sr(i):window,e){case"focusin":(Wn(v)||"true"===v.contentEditable)&&(vi=v,yi=i,bi=null);break;case"focusout":bi=yi=vi=null;break;case"mousedown":ki=!0;break;case"contextmenu":case"mouseup":case"dragend":ki=!1,Si(a,n,r);break;case"selectionchange":if(gi)break;case"keydown":case"keyup":Si(a,n,r)}var y;if(Ln)e:{switch(e){case"compositionstart":var b="onCompositionStart";break e;case"compositionend":b="onCompositionEnd";break e;case"compositionupdate":b="onCompositionUpdate";break e}b=void 0}else qn?zn(e,n)&&(b="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(b="onCompositionStart");b&&(Un&&"ko"!==n.locale&&(qn||"onCompositionStart"!==b?"onCompositionEnd"===b&&qn&&(y=tn()):(Zt="value"in(Xt=r)?Xt.value:Xt.textContent,qn=!0)),0<(v=Gi(i,b)).length&&(b=new Sn(b,e,null,n,r),a.push({event:b,listeners:v}),y?b.data=y:null!==(y=Vn(n))&&(b.data=y))),(y=jn?function(e,t){switch(e){case"compositionend":return Vn(t);case"keypress":return 32!==t.which?null:(Bn=!0,Fn);case"textInput":return(e=t.data)===Fn&&Bn?null:e;default:return null}}(e,n):function(e,t){if(qn)return"compositionend"===e||!Ln&&zn(e,t)?(e=tn(),en=Zt=Xt=null,qn=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Un&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(i=Gi(i,"onBeforeInput")).length&&(r=new Sn("onBeforeInput","beforeinput",null,n,r),a.push({event:r,listeners:i}),r.data=y))}Fi(a,t)})}function Ki(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Gi(e,t){for(var n=t+"Capture",i=[];null!==e;){var r=e,o=r.stateNode;5===r.tag&&null!==o&&(r=o,null!=(o=Me(e,n))&&i.unshift(Ki(e,o,r)),null!=(o=Me(e,t))&&i.push(Ki(e,o,r))),e=e.return}return i}function $i(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function Ji(e,t,n,i,r){for(var o=t._reactName,a=[];null!==n&&n!==i;){var s=n,c=s.alternate,l=s.stateNode;if(null!==c&&c===i)break;5===s.tag&&null!==l&&(s=l,r?null!=(c=Me(n,o))&&a.unshift(Ki(n,c,s)):r||null!=(c=Me(n,o))&&a.push(Ki(n,c,s))),n=n.return}0!==a.length&&e.push({event:t,listeners:a})}var Qi=/\r\n?/g,Yi=/\u0000|\uFFFD/g;function Xi(e){return("string"==typeof e?e:""+e).replace(Qi,"\n").replace(Yi,"")}function Zi(e,t,i){if(t=Xi(t),Xi(e)!==t&&i)throw Error(n(425))}function er(){}var tr=null,nr=null;function ir(e,t){return"textarea"===e||"noscript"===e||"string"==typeof t.children||"number"==typeof t.children||"object"==typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var rr="function"==typeof setTimeout?setTimeout:void 0,or="function"==typeof clearTimeout?clearTimeout:void 0,ar="function"==typeof Promise?Promise:void 0,sr="function"==typeof queueMicrotask?queueMicrotask:void 0!==ar?function(e){return ar.resolve(null).then(e).catch(cr)}:rr;function cr(e){setTimeout(function(){throw e})}function lr(e,t){var n=t,i=0;do{var r=n.nextSibling;if(e.removeChild(n),r&&8===r.nodeType)if("/$"===(n=r.data)){if(0===i)return e.removeChild(r),void qt(t);i--}else"$"!==n&&"$?"!==n&&"$!"!==n||i++;n=r}while(n);qt(t)}function ur(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t)break;if("/$"===t)return null}}return e}function dr(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}var hr=Math.random().toString(36).slice(2),pr="__reactFiber$"+hr,fr="__reactProps$"+hr,mr="__reactContainer$"+hr,gr="__reactEvents$"+hr,vr="__reactListeners$"+hr,yr="__reactHandles$"+hr;function br(e){var t=e[pr];if(t)return t;for(var n=e.parentNode;n;){if(t=n[mr]||n[pr]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=dr(e);null!==e;){if(n=e[pr])return n;e=dr(e)}return t}n=(e=n).parentNode}return null}function kr(e){return!(e=e[pr]||e[mr])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Sr(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(n(33))}function Cr(e){return e[fr]||null}var Tr=[],wr=-1;function Er(e){return{current:e}}function xr(e){0>wr||(e.current=Tr[wr],Tr[wr]=null,wr--)}function Pr(e,t){wr++,Tr[wr]=e.current,e.current=t}var _r={},Rr=Er(_r),Ir=Er(!1),Nr=_r;function Or(e,t){var n=e.type.contextTypes;if(!n)return _r;var i=e.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===t)return i.__reactInternalMemoizedMaskedChildContext;var r,o={};for(r in n)o[r]=t[r];return i&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function Mr(e){return null!=(e=e.childContextTypes)}function Dr(){xr(Ir),xr(Rr)}function Lr(e,t,i){if(Rr.current!==_r)throw Error(n(168));Pr(Rr,t),Pr(Ir,i)}function Ar(e,t,i){var r=e.stateNode;if(t=t.childContextTypes,"function"!=typeof r.getChildContext)return i;for(var o in r=r.getChildContext())if(!(o in t))throw Error(n(108,H(e)||"Unknown",o));return U({},i,r)}function jr(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||_r,Nr=Rr.current,Pr(Rr,e),Pr(Ir,Ir.current),!0}function Ur(e,t,i){var r=e.stateNode;if(!r)throw Error(n(169));i?(e=Ar(e,t,Nr),r.__reactInternalMemoizedMergedChildContext=e,xr(Ir),xr(Rr),Pr(Rr,e)):xr(Ir),Pr(Ir,i)}var Fr=null,Br=!1,zr=!1;function Vr(e){null===Fr?Fr=[e]:Fr.push(e)}function qr(){if(!zr&&null!==Fr){zr=!0;var e=0,t=kt;try{var n=Fr;for(kt=1;e<n.length;e++){var i=n[e];do{i=i(!0)}while(null!==i)}Fr=null,Br=!1}catch(r){throw null!==Fr&&(Fr=Fr.slice(e+1)),$e(et,qr),r}finally{kt=t,zr=!1}}return null}var Hr=[],Wr=0,Kr=null,Gr=0,$r=[],Jr=0,Qr=null,Yr=1,Xr="";function Zr(e,t){Hr[Wr++]=Gr,Hr[Wr++]=Kr,Kr=e,Gr=t}function eo(e,t,n){$r[Jr++]=Yr,$r[Jr++]=Xr,$r[Jr++]=Qr,Qr=e;var i=Yr;e=Xr;var r=32-st(i)-1;i&=~(1<<r),n+=1;var o=32-st(t)+r;if(30<o){var a=r-r%5;o=(i&(1<<a)-1).toString(32),i>>=a,r-=a,Yr=1<<32-st(t)+r|n<<r|i,Xr=o+e}else Yr=1<<o|n<<r|i,Xr=e}function to(e){null!==e.return&&(Zr(e,1),eo(e,1,0))}function no(e){for(;e===Kr;)Kr=Hr[--Wr],Hr[Wr]=null,Gr=Hr[--Wr],Hr[Wr]=null;for(;e===Qr;)Qr=$r[--Jr],$r[Jr]=null,Xr=$r[--Jr],$r[Jr]=null,Yr=$r[--Jr],$r[Jr]=null}var io=null,ro=null,oo=!1,ao=null;function so(e,t){var n=Ol(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,null===(t=e.deletions)?(e.deletions=[n],e.flags|=16):t.push(n)}function co(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,io=e,ro=ur(t.firstChild),!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,io=e,ro=null,!0);case 13:return null!==(t=8!==t.nodeType?null:t)&&(n=null!==Qr?{id:Yr,overflow:Xr}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},(n=Ol(18,null,null,0)).stateNode=t,n.return=e,e.child=n,io=e,ro=null,!0);default:return!1}}function lo(e){return!(!(1&e.mode)||128&e.flags)}function uo(e){if(oo){var t=ro;if(t){var i=t;if(!co(e,t)){if(lo(e))throw Error(n(418));t=ur(i.nextSibling);var r=io;t&&co(e,t)?so(r,i):(e.flags=-4097&e.flags|2,oo=!1,io=e)}}else{if(lo(e))throw Error(n(418));e.flags=-4097&e.flags|2,oo=!1,io=e}}}function ho(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;io=e}function po(e){if(e!==io)return!1;if(!oo)return ho(e),oo=!0,!1;var t;if((t=3!==e.tag)&&!(t=5!==e.tag)&&(t="head"!==(t=e.type)&&"body"!==t&&!ir(e.type,e.memoizedProps)),t&&(t=ro)){if(lo(e))throw fo(),Error(n(418));for(;t;)so(e,t),t=ur(t.nextSibling)}if(ho(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(n(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var i=e.data;if("/$"===i){if(0===t){ro=ur(e.nextSibling);break e}t--}else"$"!==i&&"$!"!==i&&"$?"!==i||t++}e=e.nextSibling}ro=null}}else ro=io?ur(e.stateNode.nextSibling):null;return!0}function fo(){for(var e=ro;e;)e=ur(e.nextSibling)}function mo(){ro=io=null,oo=!1}function go(e){null===ao?ao=[e]:ao.push(e)}var vo=k.ReactCurrentBatchConfig;function yo(e,t,i){if(null!==(e=i.ref)&&"function"!=typeof e&&"object"!=typeof e){if(i._owner){if(i=i._owner){if(1!==i.tag)throw Error(n(309));var r=i.stateNode}if(!r)throw Error(n(147,e));var o=r,a=""+e;return null!==t&&null!==t.ref&&"function"==typeof t.ref&&t.ref._stringRef===a?t.ref:((t=function(e){var t=o.refs;null===e?delete t[a]:t[a]=e})._stringRef=a,t)}if("string"!=typeof e)throw Error(n(284));if(!i._owner)throw Error(n(290,e))}return e}function bo(e,t){throw e=Object.prototype.toString.call(t),Error(n(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function ko(e){return(0,e._init)(e._payload)}function So(e){function t(t,n){if(e){var i=t.deletions;null===i?(t.deletions=[n],t.flags|=16):i.push(n)}}function i(n,i){if(!e)return null;for(;null!==i;)t(n,i),i=i.sibling;return null}function r(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function o(e,t){return(e=Dl(e,t)).index=0,e.sibling=null,e}function a(t,n,i){return t.index=i,e?null!==(i=t.alternate)?(i=i.index)<n?(t.flags|=2,n):i:(t.flags|=2,n):(t.flags|=1048576,n)}function s(t){return e&&null===t.alternate&&(t.flags|=2),t}function c(e,t,n,i){return null===t||6!==t.tag?((t=Ul(n,e.mode,i)).return=e,t):((t=o(t,n)).return=e,t)}function l(e,t,n,i){var r=n.type;return r===w?d(e,t,n.props.children,i,n.key):null!==t&&(t.elementType===r||"object"==typeof r&&null!==r&&r.$$typeof===M&&ko(r)===t.type)?((i=o(t,n.props)).ref=yo(e,t,n),i.return=e,i):((i=Ll(n.type,n.key,n.props,null,e.mode,i)).ref=yo(e,t,n),i.return=e,i)}function u(e,t,n,i){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Fl(n,e.mode,i)).return=e,t):((t=o(t,n.children||[])).return=e,t)}function d(e,t,n,i,r){return null===t||7!==t.tag?((t=Al(n,e.mode,i,r)).return=e,t):((t=o(t,n)).return=e,t)}function h(e,t,n){if("string"==typeof t&&""!==t||"number"==typeof t)return(t=Ul(""+t,e.mode,n)).return=e,t;if("object"==typeof t&&null!==t){switch(t.$$typeof){case S:return(n=Ll(t.type,t.key,t.props,null,e.mode,n)).ref=yo(e,null,t),n.return=e,n;case T:return(t=Fl(t,e.mode,n)).return=e,t;case M:return h(e,(0,t._init)(t._payload),n)}if(ne(t)||A(t))return(t=Al(t,e.mode,n,null)).return=e,t;bo(e,t)}return null}function p(e,t,n,i){var r=null!==t?t.key:null;if("string"==typeof n&&""!==n||"number"==typeof n)return null!==r?null:c(e,t,""+n,i);if("object"==typeof n&&null!==n){switch(n.$$typeof){case S:return n.key===r?l(e,t,n,i):null;case T:return n.key===r?u(e,t,n,i):null;case M:return p(e,t,(r=n._init)(n._payload),i)}if(ne(n)||A(n))return null!==r?null:d(e,t,n,i,null);bo(e,n)}return null}function f(e,t,n,i,r){if("string"==typeof i&&""!==i||"number"==typeof i)return c(t,e=e.get(n)||null,""+i,r);if("object"==typeof i&&null!==i){switch(i.$$typeof){case S:return l(t,e=e.get(null===i.key?n:i.key)||null,i,r);case T:return u(t,e=e.get(null===i.key?n:i.key)||null,i,r);case M:return f(e,t,n,(0,i._init)(i._payload),r)}if(ne(i)||A(i))return d(t,e=e.get(n)||null,i,r,null);bo(t,i)}return null}return function c(l,u,d,m){if("object"==typeof d&&null!==d&&d.type===w&&null===d.key&&(d=d.props.children),"object"==typeof d&&null!==d){switch(d.$$typeof){case S:e:{for(var g=d.key,v=u;null!==v;){if(v.key===g){if((g=d.type)===w){if(7===v.tag){i(l,v.sibling),(u=o(v,d.props.children)).return=l,l=u;break e}}else if(v.elementType===g||"object"==typeof g&&null!==g&&g.$$typeof===M&&ko(g)===v.type){i(l,v.sibling),(u=o(v,d.props)).ref=yo(l,v,d),u.return=l,l=u;break e}i(l,v);break}t(l,v),v=v.sibling}d.type===w?((u=Al(d.props.children,l.mode,m,d.key)).return=l,l=u):((m=Ll(d.type,d.key,d.props,null,l.mode,m)).ref=yo(l,u,d),m.return=l,l=m)}return s(l);case T:e:{for(v=d.key;null!==u;){if(u.key===v){if(4===u.tag&&u.stateNode.containerInfo===d.containerInfo&&u.stateNode.implementation===d.implementation){i(l,u.sibling),(u=o(u,d.children||[])).return=l,l=u;break e}i(l,u);break}t(l,u),u=u.sibling}(u=Fl(d,l.mode,m)).return=l,l=u}return s(l);case M:return c(l,u,(v=d._init)(d._payload),m)}if(ne(d))return function(n,o,s,c){for(var l=null,u=null,d=o,m=o=0,g=null;null!==d&&m<s.length;m++){d.index>m?(g=d,d=null):g=d.sibling;var v=p(n,d,s[m],c);if(null===v){null===d&&(d=g);break}e&&d&&null===v.alternate&&t(n,d),o=a(v,o,m),null===u?l=v:u.sibling=v,u=v,d=g}if(m===s.length)return i(n,d),oo&&Zr(n,m),l;if(null===d){for(;m<s.length;m++)null!==(d=h(n,s[m],c))&&(o=a(d,o,m),null===u?l=d:u.sibling=d,u=d);return oo&&Zr(n,m),l}for(d=r(n,d);m<s.length;m++)null!==(g=f(d,n,m,s[m],c))&&(e&&null!==g.alternate&&d.delete(null===g.key?m:g.key),o=a(g,o,m),null===u?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(n,e)}),oo&&Zr(n,m),l}(l,u,d,m);if(A(d))return function(o,s,c,l){var u=A(c);if("function"!=typeof u)throw Error(n(150));if(null==(c=u.call(c)))throw Error(n(151));for(var d=u=null,m=s,g=s=0,v=null,y=c.next();null!==m&&!y.done;g++,y=c.next()){m.index>g?(v=m,m=null):v=m.sibling;var b=p(o,m,y.value,l);if(null===b){null===m&&(m=v);break}e&&m&&null===b.alternate&&t(o,m),s=a(b,s,g),null===d?u=b:d.sibling=b,d=b,m=v}if(y.done)return i(o,m),oo&&Zr(o,g),u;if(null===m){for(;!y.done;g++,y=c.next())null!==(y=h(o,y.value,l))&&(s=a(y,s,g),null===d?u=y:d.sibling=y,d=y);return oo&&Zr(o,g),u}for(m=r(o,m);!y.done;g++,y=c.next())null!==(y=f(m,o,g,y.value,l))&&(e&&null!==y.alternate&&m.delete(null===y.key?g:y.key),s=a(y,s,g),null===d?u=y:d.sibling=y,d=y);return e&&m.forEach(function(e){return t(o,e)}),oo&&Zr(o,g),u}(l,u,d,m);bo(l,d)}return"string"==typeof d&&""!==d||"number"==typeof d?(d=""+d,null!==u&&6===u.tag?(i(l,u.sibling),(u=o(u,d)).return=l,l=u):(i(l,u),(u=Ul(d,l.mode,m)).return=l,l=u),s(l)):i(l,u)}}var Co=So(!0),To=So(!1),wo=Er(null),Eo=null,xo=null,Po=null;function _o(){Po=xo=Eo=null}function Ro(e){var t=wo.current;xr(wo),e._currentValue=t}function Io(e,t,n){for(;null!==e;){var i=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==i&&(i.childLanes|=t)):null!==i&&(i.childLanes&t)!==t&&(i.childLanes|=t),e===n)break;e=e.return}}function No(e,t){Eo=e,Po=xo=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(ks=!0),e.firstContext=null)}function Oo(e){var t=e._currentValue;if(Po!==e)if(e={context:e,memoizedValue:t,next:null},null===xo){if(null===Eo)throw Error(n(308));xo=e,Eo.dependencies={lanes:0,firstContext:e}}else xo=xo.next=e;return t}var Mo=null;function Do(e){null===Mo?Mo=[e]:Mo.push(e)}function Lo(e,t,n,i){var r=t.interleaved;return null===r?(n.next=n,Do(t)):(n.next=r.next,r.next=n),t.interleaved=n,Ao(e,i)}function Ao(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var jo=!1;function Uo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Fo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Bo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function zo(e,t,n){var i=e.updateQueue;if(null===i)return null;if(i=i.shared,2&Rc){var r=i.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),i.pending=t,Ao(e,n)}return null===(r=i.interleaved)?(t.next=t,Do(i)):(t.next=r.next,r.next=t),i.interleaved=t,Ao(e,n)}function Vo(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,4194240&n)){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,bt(e,n)}}function qo(e,t){var n=e.updateQueue,i=e.alternate;if(null!==i&&n===(i=i.updateQueue)){var r=null,o=null;if(null!==(n=n.firstBaseUpdate)){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===o?r=o=a:o=o.next=a,n=n.next}while(null!==n);null===o?r=o=t:o=o.next=t}else r=o=t;return n={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:o,shared:i.shared,effects:i.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Ho(e,t,n,i){var r=e.updateQueue;jo=!1;var o=r.firstBaseUpdate,a=r.lastBaseUpdate,s=r.shared.pending;if(null!==s){r.shared.pending=null;var c=s,l=c.next;c.next=null,null===a?o=l:a.next=l,a=c;var u=e.alternate;null!==u&&((s=(u=u.updateQueue).lastBaseUpdate)!==a&&(null===s?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(null!==o){var d=r.baseState;for(a=0,u=l=c=null,s=o;;){var h=s.lane,p=s.eventTime;if((i&h)===h){null!==u&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var f=e,m=s;switch(h=t,p=n,m.tag){case 1:if("function"==typeof(f=m.payload)){d=f.call(p,d,h);break e}d=f;break e;case 3:f.flags=-65537&f.flags|128;case 0:if(null==(h="function"==typeof(f=m.payload)?f.call(p,d,h):f))break e;d=U({},d,h);break e;case 2:jo=!0}}null!==s.callback&&0!==s.lane&&(e.flags|=64,null===(h=r.effects)?r.effects=[s]:h.push(s))}else p={eventTime:p,lane:h,tag:s.tag,payload:s.payload,callback:s.callback,next:null},null===u?(l=u=p,c=d):u=u.next=p,a|=h;if(null===(s=s.next)){if(null===(s=r.shared.pending))break;s=(h=s).next,h.next=null,r.lastBaseUpdate=h,r.shared.pending=null}}if(null===u&&(c=d),r.baseState=c,r.firstBaseUpdate=l,r.lastBaseUpdate=u,null!==(t=r.shared.interleaved)){r=t;do{a|=r.lane,r=r.next}while(r!==t)}else null===o&&(r.shared.lanes=0);jc|=a,e.lanes=a,e.memoizedState=d}}function Wo(e,t,i){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var r=e[t],o=r.callback;if(null!==o){if(r.callback=null,r=i,"function"!=typeof o)throw Error(n(191,o));o.call(r)}}}var Ko={},Go=Er(Ko),$o=Er(Ko),Jo=Er(Ko);function Qo(e){if(e===Ko)throw Error(n(174));return e}function Yo(e,t){switch(Pr(Jo,t),Pr($o,e),Pr(Go,Ko),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:le(null,"");break;default:t=le(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}xr(Go),Pr(Go,t)}function Xo(){xr(Go),xr($o),xr(Jo)}function Zo(e){Qo(Jo.current);var t=Qo(Go.current),n=le(t,e.type);t!==n&&(Pr($o,e),Pr(Go,n))}function ea(e){$o.current===e&&(xr(Go),xr($o))}var ta=Er(0);function na(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||"$!"===n.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(128&t.flags)return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ia=[];function ra(){for(var e=0;e<ia.length;e++)ia[e]._workInProgressVersionPrimary=null;ia.length=0}var oa=k.ReactCurrentDispatcher,aa=k.ReactCurrentBatchConfig,sa=0,ca=null,la=null,ua=null,da=!1,ha=!1,pa=0,fa=0;function ma(){throw Error(n(321))}function ga(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ci(e[n],t[n]))return!1;return!0}function va(e,t,i,r,o,a){if(sa=a,ca=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,oa.current=null===e||null===e.memoizedState?es:ts,e=i(r,o),ha){a=0;do{if(ha=!1,pa=0,25<=a)throw Error(n(301));a+=1,ua=la=null,t.updateQueue=null,oa.current=ns,e=i(r,o)}while(ha)}if(oa.current=Za,t=null!==la&&null!==la.next,sa=0,ua=la=ca=null,da=!1,t)throw Error(n(300));return e}function ya(){var e=0!==pa;return pa=0,e}function ba(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===ua?ca.memoizedState=ua=e:ua=ua.next=e,ua}function ka(){if(null===la){var e=ca.alternate;e=null!==e?e.memoizedState:null}else e=la.next;var t=null===ua?ca.memoizedState:ua.next;if(null!==t)ua=t,la=e;else{if(null===e)throw Error(n(310));e={memoizedState:(la=e).memoizedState,baseState:la.baseState,baseQueue:la.baseQueue,queue:la.queue,next:null},null===ua?ca.memoizedState=ua=e:ua=ua.next=e}return ua}function Sa(e,t){return"function"==typeof t?t(e):t}function Ca(e){var t=ka(),i=t.queue;if(null===i)throw Error(n(311));i.lastRenderedReducer=e;var r=la,o=r.baseQueue,a=i.pending;if(null!==a){if(null!==o){var s=o.next;o.next=a.next,a.next=s}r.baseQueue=o=a,i.pending=null}if(null!==o){a=o.next,r=r.baseState;var c=s=null,l=null,u=a;do{var d=u.lane;if((sa&d)===d)null!==l&&(l=l.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var h={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};null===l?(c=l=h,s=r):l=l.next=h,ca.lanes|=d,jc|=d}u=u.next}while(null!==u&&u!==a);null===l?s=r:l.next=c,ci(r,t.memoizedState)||(ks=!0),t.memoizedState=r,t.baseState=s,t.baseQueue=l,i.lastRenderedState=r}if(null!==(e=i.interleaved)){o=e;do{a=o.lane,ca.lanes|=a,jc|=a,o=o.next}while(o!==e)}else null===o&&(i.lanes=0);return[t.memoizedState,i.dispatch]}function Ta(e){var t=ka(),i=t.queue;if(null===i)throw Error(n(311));i.lastRenderedReducer=e;var r=i.dispatch,o=i.pending,a=t.memoizedState;if(null!==o){i.pending=null;var s=o=o.next;do{a=e(a,s.action),s=s.next}while(s!==o);ci(a,t.memoizedState)||(ks=!0),t.memoizedState=a,null===t.baseQueue&&(t.baseState=a),i.lastRenderedState=a}return[a,r]}function wa(){}function Ea(e,t){var i=ca,r=ka(),o=t(),a=!ci(r.memoizedState,o);if(a&&(r.memoizedState=o,ks=!0),r=r.queue,ja(_a.bind(null,i,r,e),[e]),r.getSnapshot!==t||a||null!==ua&&1&ua.memoizedState.tag){if(i.flags|=2048,Oa(9,Pa.bind(null,i,r,o,t),void 0,null),null===Ic)throw Error(n(349));30&sa||xa(i,t,o)}return o}function xa(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=ca.updateQueue)?(t={lastEffect:null,stores:null},ca.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Pa(e,t,n,i){t.value=n,t.getSnapshot=i,Ra(t)&&Ia(e)}function _a(e,t,n){return n(function(){Ra(t)&&Ia(e)})}function Ra(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ci(e,n)}catch(i){return!0}}function Ia(e){var t=Ao(e,1);null!==t&&il(t,e,1,-1)}function Na(e){var t=ba();return"function"==typeof e&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Sa,lastRenderedState:e},t.queue=e,e=e.dispatch=Ja.bind(null,ca,e),[t.memoizedState,e]}function Oa(e,t,n,i){return e={tag:e,create:t,destroy:n,deps:i,next:null},null===(t=ca.updateQueue)?(t={lastEffect:null,stores:null},ca.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(i=n.next,n.next=e,e.next=i,t.lastEffect=e),e}function Ma(){return ka().memoizedState}function Da(e,t,n,i){var r=ba();ca.flags|=e,r.memoizedState=Oa(1|t,n,void 0,void 0===i?null:i)}function La(e,t,n,i){var r=ka();i=void 0===i?null:i;var o=void 0;if(null!==la){var a=la.memoizedState;if(o=a.destroy,null!==i&&ga(i,a.deps))return void(r.memoizedState=Oa(t,n,o,i))}ca.flags|=e,r.memoizedState=Oa(1|t,n,o,i)}function Aa(e,t){return Da(8390656,8,e,t)}function ja(e,t){return La(2048,8,e,t)}function Ua(e,t){return La(4,2,e,t)}function Fa(e,t){return La(4,4,e,t)}function Ba(e,t){return"function"==typeof t?(e=e(),t(e),function(){t(null)}):null!=t?(e=e(),t.current=e,function(){t.current=null}):void 0}function za(e,t,n){return n=null!=n?n.concat([e]):null,La(4,4,Ba.bind(null,t,e),n)}function Va(){}function qa(e,t){var n=ka();t=void 0===t?null:t;var i=n.memoizedState;return null!==i&&null!==t&&ga(t,i[1])?i[0]:(n.memoizedState=[e,t],e)}function Ha(e,t){var n=ka();t=void 0===t?null:t;var i=n.memoizedState;return null!==i&&null!==t&&ga(t,i[1])?i[0]:(e=e(),n.memoizedState=[e,t],e)}function Wa(e,t,n){return 21&sa?(ci(n,t)||(n=gt(),ca.lanes|=n,jc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ks=!0),e.memoizedState=n)}function Ka(e,t){var n=kt;kt=0!==n&&4>n?n:4,e(!0);var i=aa.transition;aa.transition={};try{e(!1),t()}finally{kt=n,aa.transition=i}}function Ga(){return ka().memoizedState}function $a(e,t,n){var i=nl(e);if(n={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null},Qa(e))Ya(t,n);else if(null!==(n=Lo(e,t,n,i))){il(n,e,i,tl()),Xa(n,t,i)}}function Ja(e,t,n){var i=nl(e),r={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null};if(Qa(e))Ya(t,r);else{var o=e.alternate;if(0===e.lanes&&(null===o||0===o.lanes)&&null!==(o=t.lastRenderedReducer))try{var a=t.lastRenderedState,s=o(a,n);if(r.hasEagerState=!0,r.eagerState=s,ci(s,a)){var c=t.interleaved;return null===c?(r.next=r,Do(t)):(r.next=c.next,c.next=r),void(t.interleaved=r)}}catch(l){}null!==(n=Lo(e,t,r,i))&&(il(n,e,i,r=tl()),Xa(n,t,i))}}function Qa(e){var t=e.alternate;return e===ca||null!==t&&t===ca}function Ya(e,t){ha=da=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Xa(e,t,n){if(4194240&n){var i=t.lanes;n|=i&=e.pendingLanes,t.lanes=n,bt(e,n)}}var Za={readContext:Oo,useCallback:ma,useContext:ma,useEffect:ma,useImperativeHandle:ma,useInsertionEffect:ma,useLayoutEffect:ma,useMemo:ma,useReducer:ma,useRef:ma,useState:ma,useDebugValue:ma,useDeferredValue:ma,useTransition:ma,useMutableSource:ma,useSyncExternalStore:ma,useId:ma,unstable_isNewReconciler:!1},es={readContext:Oo,useCallback:function(e,t){return ba().memoizedState=[e,void 0===t?null:t],e},useContext:Oo,useEffect:Aa,useImperativeHandle:function(e,t,n){return n=null!=n?n.concat([e]):null,Da(4194308,4,Ba.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Da(4194308,4,e,t)},useInsertionEffect:function(e,t){return Da(4,2,e,t)},useMemo:function(e,t){var n=ba();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var i=ba();return t=void 0!==n?n(t):t,i.memoizedState=i.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},i.queue=e,e=e.dispatch=$a.bind(null,ca,e),[i.memoizedState,e]},useRef:function(e){return e={current:e},ba().memoizedState=e},useState:Na,useDebugValue:Va,useDeferredValue:function(e){return ba().memoizedState=e},useTransition:function(){var e=Na(!1),t=e[0];return e=Ka.bind(null,e[1]),ba().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,i){var r=ca,o=ba();if(oo){if(void 0===i)throw Error(n(407));i=i()}else{if(i=t(),null===Ic)throw Error(n(349));30&sa||xa(r,t,i)}o.memoizedState=i;var a={value:i,getSnapshot:t};return o.queue=a,Aa(_a.bind(null,r,a,e),[e]),r.flags|=2048,Oa(9,Pa.bind(null,r,a,i,t),void 0,null),i},useId:function(){var e=ba(),t=Ic.identifierPrefix;if(oo){var n=Xr;t=":"+t+"R"+(n=(Yr&~(1<<32-st(Yr)-1)).toString(32)+n),0<(n=pa++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=fa++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},ts={readContext:Oo,useCallback:qa,useContext:Oo,useEffect:ja,useImperativeHandle:za,useInsertionEffect:Ua,useLayoutEffect:Fa,useMemo:Ha,useReducer:Ca,useRef:Ma,useState:function(){return Ca(Sa)},useDebugValue:Va,useDeferredValue:function(e){return Wa(ka(),la.memoizedState,e)},useTransition:function(){return[Ca(Sa)[0],ka().memoizedState]},useMutableSource:wa,useSyncExternalStore:Ea,useId:Ga,unstable_isNewReconciler:!1},ns={readContext:Oo,useCallback:qa,useContext:Oo,useEffect:ja,useImperativeHandle:za,useInsertionEffect:Ua,useLayoutEffect:Fa,useMemo:Ha,useReducer:Ta,useRef:Ma,useState:function(){return Ta(Sa)},useDebugValue:Va,useDeferredValue:function(e){var t=ka();return null===la?t.memoizedState=e:Wa(t,la.memoizedState,e)},useTransition:function(){return[Ta(Sa)[0],ka().memoizedState]},useMutableSource:wa,useSyncExternalStore:Ea,useId:Ga,unstable_isNewReconciler:!1};function is(e,t){if(e&&e.defaultProps){for(var n in t=U({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function rs(e,t,n,i){n=null==(n=n(i,t=e.memoizedState))?t:U({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var os={isMounted:function(e){return!!(e=e._reactInternals)&&qe(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var i=tl(),r=nl(e),o=Bo(i,r);o.payload=t,null!=n&&(o.callback=n),null!==(t=zo(e,o,r))&&(il(t,e,r,i),Vo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var i=tl(),r=nl(e),o=Bo(i,r);o.tag=1,o.payload=t,null!=n&&(o.callback=n),null!==(t=zo(e,o,r))&&(il(t,e,r,i),Vo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=tl(),i=nl(e),r=Bo(n,i);r.tag=2,null!=t&&(r.callback=t),null!==(t=zo(e,r,i))&&(il(t,e,i,n),Vo(t,e,i))}};function as(e,t,n,i,r,o,a){return"function"==typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(i,o,a):!t.prototype||!t.prototype.isPureReactComponent||(!li(n,i)||!li(r,o))}function ss(e,t,n){var i=!1,r=_r,o=t.contextType;return"object"==typeof o&&null!==o?o=Oo(o):(r=Mr(t)?Nr:Rr.current,o=(i=null!=(i=t.contextTypes))?Or(e,r):_r),t=new t(n,o),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=os,e.stateNode=t,t._reactInternals=e,i&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=r,e.__reactInternalMemoizedMaskedChildContext=o),t}function cs(e,t,n,i){e=t.state,"function"==typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,i),"function"==typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,i),t.state!==e&&os.enqueueReplaceState(t,t.state,null)}function ls(e,t,n,i){var r=e.stateNode;r.props=n,r.state=e.memoizedState,r.refs={},Uo(e);var o=t.contextType;"object"==typeof o&&null!==o?r.context=Oo(o):(o=Mr(t)?Nr:Rr.current,r.context=Or(e,o)),r.state=e.memoizedState,"function"==typeof(o=t.getDerivedStateFromProps)&&(rs(e,t,o,n),r.state=e.memoizedState),"function"==typeof t.getDerivedStateFromProps||"function"==typeof r.getSnapshotBeforeUpdate||"function"!=typeof r.UNSAFE_componentWillMount&&"function"!=typeof r.componentWillMount||(t=r.state,"function"==typeof r.componentWillMount&&r.componentWillMount(),"function"==typeof r.UNSAFE_componentWillMount&&r.UNSAFE_componentWillMount(),t!==r.state&&os.enqueueReplaceState(r,r.state,null),Ho(e,n,r,i),r.state=e.memoizedState),"function"==typeof r.componentDidMount&&(e.flags|=4194308)}function us(e,t){try{var n="",i=t;do{n+=V(i),i=i.return}while(i);var r=n}catch(o){r="\nError generating stack: "+o.message+"\n"+o.stack}return{value:e,source:t,stack:r,digest:null}}function ds(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function hs(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var ps="function"==typeof WeakMap?WeakMap:Map;function fs(e,t,n){(n=Bo(-1,n)).tag=3,n.payload={element:null};var i=t.value;return n.callback=function(){Wc||(Wc=!0,Kc=i),hs(0,t)},n}function ms(e,t,n){(n=Bo(-1,n)).tag=3;var i=e.type.getDerivedStateFromError;if("function"==typeof i){var r=t.value;n.payload=function(){return i(r)},n.callback=function(){hs(0,t)}}var o=e.stateNode;return null!==o&&"function"==typeof o.componentDidCatch&&(n.callback=function(){hs(0,t),"function"!=typeof i&&(null===Gc?Gc=new Set([this]):Gc.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function gs(e,t,n){var i=e.pingCache;if(null===i){i=e.pingCache=new ps;var r=new Set;i.set(t,r)}else void 0===(r=i.get(t))&&(r=new Set,i.set(t,r));r.has(n)||(r.add(n),e=xl.bind(null,e,t,n),t.then(e,e))}function vs(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function ys(e,t,n,i,r){return 1&e.mode?(e.flags|=65536,e.lanes=r,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=Bo(-1,1)).tag=2,zo(n,t,1))),n.lanes|=1),e)}var bs=k.ReactCurrentOwner,ks=!1;function Ss(e,t,n,i){t.child=null===e?To(t,null,n,i):Co(t,e.child,n,i)}function Cs(e,t,n,i,r){n=n.render;var o=t.ref;return No(t,r),i=va(e,t,n,i,o,r),n=ya(),null===e||ks?(oo&&n&&to(t),t.flags|=1,Ss(e,t,i,r),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,Ws(e,t,r))}function Ts(e,t,n,i,r){if(null===e){var o=n.type;return"function"!=typeof o||Ml(o)||void 0!==o.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Ll(n.type,null,i,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=o,ws(e,t,o,i,r))}if(o=e.child,0===(e.lanes&r)){var a=o.memoizedProps;if((n=null!==(n=n.compare)?n:li)(a,i)&&e.ref===t.ref)return Ws(e,t,r)}return t.flags|=1,(e=Dl(o,i)).ref=t.ref,e.return=t,t.child=e}function ws(e,t,n,i,r){if(null!==e){var o=e.memoizedProps;if(li(o,i)&&e.ref===t.ref){if(ks=!1,t.pendingProps=i=o,0===(e.lanes&r))return t.lanes=e.lanes,Ws(e,t,r);131072&e.flags&&(ks=!0)}}return Ps(e,t,n,i,r)}function Es(e,t,n){var i=t.pendingProps,r=i.children,o=null!==e?e.memoizedState:null;if("hidden"===i.mode)if(1&t.mode){if(!(1073741824&n))return e=null!==o?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Pr(Dc,Mc),Mc|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},i=null!==o?o.baseLanes:n,Pr(Dc,Mc),Mc|=i}else t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Pr(Dc,Mc),Mc|=n;else null!==o?(i=o.baseLanes|n,t.memoizedState=null):i=n,Pr(Dc,Mc),Mc|=i;return Ss(e,t,r,n),t.child}function xs(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ps(e,t,n,i,r){var o=Mr(n)?Nr:Rr.current;return o=Or(t,o),No(t,r),n=va(e,t,n,i,o,r),i=ya(),null===e||ks?(oo&&i&&to(t),t.flags|=1,Ss(e,t,n,r),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~r,Ws(e,t,r))}function _s(e,t,n,i,r){if(Mr(n)){var o=!0;jr(t)}else o=!1;if(No(t,r),null===t.stateNode)Hs(e,t),ss(t,n,i),ls(t,n,i,r),i=!0;else if(null===e){var a=t.stateNode,s=t.memoizedProps;a.props=s;var c=a.context,l=n.contextType;"object"==typeof l&&null!==l?l=Oo(l):l=Or(t,l=Mr(n)?Nr:Rr.current);var u=n.getDerivedStateFromProps,d="function"==typeof u||"function"==typeof a.getSnapshotBeforeUpdate;d||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(s!==i||c!==l)&&cs(t,a,i,l),jo=!1;var h=t.memoizedState;a.state=h,Ho(t,i,a,r),c=t.memoizedState,s!==i||h!==c||Ir.current||jo?("function"==typeof u&&(rs(t,n,u,i),c=t.memoizedState),(s=jo||as(t,n,s,i,h,c,l))?(d||"function"!=typeof a.UNSAFE_componentWillMount&&"function"!=typeof a.componentWillMount||("function"==typeof a.componentWillMount&&a.componentWillMount(),"function"==typeof a.UNSAFE_componentWillMount&&a.UNSAFE_componentWillMount()),"function"==typeof a.componentDidMount&&(t.flags|=4194308)):("function"==typeof a.componentDidMount&&(t.flags|=4194308),t.memoizedProps=i,t.memoizedState=c),a.props=i,a.state=c,a.context=l,i=s):("function"==typeof a.componentDidMount&&(t.flags|=4194308),i=!1)}else{a=t.stateNode,Fo(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:is(t.type,s),a.props=l,d=t.pendingProps,h=a.context,"object"==typeof(c=n.contextType)&&null!==c?c=Oo(c):c=Or(t,c=Mr(n)?Nr:Rr.current);var p=n.getDerivedStateFromProps;(u="function"==typeof p||"function"==typeof a.getSnapshotBeforeUpdate)||"function"!=typeof a.UNSAFE_componentWillReceiveProps&&"function"!=typeof a.componentWillReceiveProps||(s!==d||h!==c)&&cs(t,a,i,c),jo=!1,h=t.memoizedState,a.state=h,Ho(t,i,a,r);var f=t.memoizedState;s!==d||h!==f||Ir.current||jo?("function"==typeof p&&(rs(t,n,p,i),f=t.memoizedState),(l=jo||as(t,n,l,i,h,f,c)||!1)?(u||"function"!=typeof a.UNSAFE_componentWillUpdate&&"function"!=typeof a.componentWillUpdate||("function"==typeof a.componentWillUpdate&&a.componentWillUpdate(i,f,c),"function"==typeof a.UNSAFE_componentWillUpdate&&a.UNSAFE_componentWillUpdate(i,f,c)),"function"==typeof a.componentDidUpdate&&(t.flags|=4),"function"==typeof a.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=i,t.memoizedState=f),a.props=i,a.state=f,a.context=c,i=l):("function"!=typeof a.componentDidUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!=typeof a.getSnapshotBeforeUpdate||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),i=!1)}return Rs(e,t,n,i,o,r)}function Rs(e,t,n,i,r,o){xs(e,t);var a=!!(128&t.flags);if(!i&&!a)return r&&Ur(t,n,!1),Ws(e,t,o);i=t.stateNode,bs.current=t;var s=a&&"function"!=typeof n.getDerivedStateFromError?null:i.render();return t.flags|=1,null!==e&&a?(t.child=Co(t,e.child,null,o),t.child=Co(t,null,s,o)):Ss(e,t,s,o),t.memoizedState=i.state,r&&Ur(t,n,!0),t.child}function Is(e){var t=e.stateNode;t.pendingContext?Lr(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Lr(0,t.context,!1),Yo(e,t.containerInfo)}function Ns(e,t,n,i,r){return mo(),go(r),t.flags|=256,Ss(e,t,n,i),t.child}var Os,Ms,Ds,Ls,As={dehydrated:null,treeContext:null,retryLane:0};function js(e){return{baseLanes:e,cachePool:null,transitions:null}}function Us(e,t,i){var r,o=t.pendingProps,a=ta.current,s=!1,c=!!(128&t.flags);if((r=c)||(r=(null===e||null!==e.memoizedState)&&!!(2&a)),r?(s=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(a|=1),Pr(ta,1&a),null===e)return uo(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(1&t.mode?"$!"===e.data?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(c=o.children,e=o.fallback,s?(o=t.mode,s=t.child,c={mode:"hidden",children:c},1&o||null===s?s=jl(c,o,0,null):(s.childLanes=0,s.pendingProps=c),e=Al(e,o,i,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=js(i),t.memoizedState=As,e):Fs(t,c));if(null!==(a=e.memoizedState)&&null!==(r=a.dehydrated))return function(e,t,i,r,o,a,s){if(i)return 256&t.flags?(t.flags&=-257,Bs(e,t,s,r=ds(Error(n(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(a=r.fallback,o=t.mode,r=jl({mode:"visible",children:r.children},o,0,null),(a=Al(a,o,s,null)).flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,1&t.mode&&Co(t,e.child,null,s),t.child.memoizedState=js(s),t.memoizedState=As,a);if(!(1&t.mode))return Bs(e,t,s,null);if("$!"===o.data){if(r=o.nextSibling&&o.nextSibling.dataset)var c=r.dgst;return r=c,Bs(e,t,s,r=ds(a=Error(n(419)),r,void 0))}if(c=0!==(s&e.childLanes),ks||c){if(null!==(r=Ic)){switch(s&-s){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}0!==(o=0!==(o&(r.suspendedLanes|s))?0:o)&&o!==a.retryLane&&(a.retryLane=o,Ao(e,o),il(r,e,o,-1))}return gl(),Bs(e,t,s,r=ds(Error(n(421))))}return"$?"===o.data?(t.flags|=128,t.child=e.child,t=_l.bind(null,e),o._reactRetry=t,null):(e=a.treeContext,ro=ur(o.nextSibling),io=t,oo=!0,ao=null,null!==e&&($r[Jr++]=Yr,$r[Jr++]=Xr,$r[Jr++]=Qr,Yr=e.id,Xr=e.overflow,Qr=t),t=Fs(t,r.children),t.flags|=4096,t)}(e,t,c,o,r,a,i);if(s){s=o.fallback,c=t.mode,r=(a=e.child).sibling;var l={mode:"hidden",children:o.children};return 1&c||t.child===a?(o=Dl(a,l)).subtreeFlags=14680064&a.subtreeFlags:((o=t.child).childLanes=0,o.pendingProps=l,t.deletions=null),null!==r?s=Dl(r,s):(s=Al(s,c,i,null)).flags|=2,s.return=t,o.return=t,o.sibling=s,t.child=o,o=s,s=t.child,c=null===(c=e.child.memoizedState)?js(i):{baseLanes:c.baseLanes|i,cachePool:null,transitions:c.transitions},s.memoizedState=c,s.childLanes=e.childLanes&~i,t.memoizedState=As,o}return e=(s=e.child).sibling,o=Dl(s,{mode:"visible",children:o.children}),!(1&t.mode)&&(o.lanes=i),o.return=t,o.sibling=null,null!==e&&(null===(i=t.deletions)?(t.deletions=[e],t.flags|=16):i.push(e)),t.child=o,t.memoizedState=null,o}function Fs(e,t){return(t=jl({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function Bs(e,t,n,i){return null!==i&&go(i),Co(t,e.child,null,n),(e=Fs(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function zs(e,t,n){e.lanes|=t;var i=e.alternate;null!==i&&(i.lanes|=t),Io(e.return,t,n)}function Vs(e,t,n,i,r){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=i,o.tail=n,o.tailMode=r)}function qs(e,t,n){var i=t.pendingProps,r=i.revealOrder,o=i.tail;if(Ss(e,t,i.children,n),2&(i=ta.current))i=1&i|2,t.flags|=128;else{if(null!==e&&128&e.flags)e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&zs(e,n,t);else if(19===e.tag)zs(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}i&=1}if(Pr(ta,i),1&t.mode)switch(r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===na(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),Vs(t,!1,r,n,o);break;case"backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===na(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}Vs(t,!0,n,null,o);break;case"together":Vs(t,!1,null,null,void 0);break;default:t.memoizedState=null}else t.memoizedState=null;return t.child}function Hs(e,t){!(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ws(e,t,i){if(null!==e&&(t.dependencies=e.dependencies),jc|=t.lanes,0===(i&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(n(153));if(null!==t.child){for(i=Dl(e=t.child,e.pendingProps),t.child=i,i.return=t;null!==e.sibling;)e=e.sibling,(i=i.sibling=Dl(e,e.pendingProps)).return=t;i.sibling=null}return t.child}function Ks(e,t){if(!oo)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var i=null;null!==n;)null!==n.alternate&&(i=n),n=n.sibling;null===i?t||null===e.tail?e.tail=null:e.tail.sibling=null:i.sibling=null}}function Gs(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,i=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=14680064&r.subtreeFlags,i|=14680064&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=i,e.childLanes=n,t}function $s(e,t,i){var o=t.pendingProps;switch(no(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gs(t),null;case 1:case 17:return Mr(t.type)&&Dr(),Gs(t),null;case 3:return o=t.stateNode,Xo(),xr(Ir),xr(Rr),ra(),o.pendingContext&&(o.context=o.pendingContext,o.pendingContext=null),null!==e&&null!==e.child||(po(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&!(256&t.flags)||(t.flags|=1024,null!==ao&&(sl(ao),ao=null))),Ms(e,t),Gs(t),null;case 5:ea(t);var a=Qo(Jo.current);if(i=t.type,null!==e&&null!=t.stateNode)Ds(e,t,i,o,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!o){if(null===t.stateNode)throw Error(n(166));return Gs(t),null}if(e=Qo(Go.current),po(t)){o=t.stateNode,i=t.type;var s=t.memoizedProps;switch(o[pr]=t,o[fr]=s,e=!!(1&t.mode),i){case"dialog":Bi("cancel",o),Bi("close",o);break;case"iframe":case"object":case"embed":Bi("load",o);break;case"video":case"audio":for(a=0;a<Ai.length;a++)Bi(Ai[a],o);break;case"source":Bi("error",o);break;case"img":case"image":case"link":Bi("error",o),Bi("load",o);break;case"details":Bi("toggle",o);break;case"input":Y(o,s),Bi("invalid",o);break;case"select":o._wrapperState={wasMultiple:!!s.multiple},Bi("invalid",o);break;case"textarea":oe(o,s),Bi("invalid",o)}for(var c in be(i,s),a=null,s)if(s.hasOwnProperty(c)){var l=s[c];"children"===c?"string"==typeof l?o.textContent!==l&&(!0!==s.suppressHydrationWarning&&Zi(o.textContent,l,e),a=["children",l]):"number"==typeof l&&o.textContent!==""+l&&(!0!==s.suppressHydrationWarning&&Zi(o.textContent,l,e),a=["children",""+l]):r.hasOwnProperty(c)&&null!=l&&"onScroll"===c&&Bi("scroll",o)}switch(i){case"input":G(o),ee(o,s,!0);break;case"textarea":G(o),se(o);break;case"select":case"option":break;default:"function"==typeof s.onClick&&(o.onclick=er)}o=a,t.updateQueue=o,null!==o&&(t.flags|=4)}else{c=9===a.nodeType?a:a.ownerDocument,"http://www.w3.org/1999/xhtml"===e&&(e=ce(i)),"http://www.w3.org/1999/xhtml"===e?"script"===i?((e=c.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"==typeof o.is?e=c.createElement(i,{is:o.is}):(e=c.createElement(i),"select"===i&&(c=e,o.multiple?c.multiple=!0:o.size&&(c.size=o.size))):e=c.createElementNS(e,i),e[pr]=t,e[fr]=o,Os(e,t,!1,!1),t.stateNode=e;e:{switch(c=ke(i,o),i){case"dialog":Bi("cancel",e),Bi("close",e),a=o;break;case"iframe":case"object":case"embed":Bi("load",e),a=o;break;case"video":case"audio":for(a=0;a<Ai.length;a++)Bi(Ai[a],e);a=o;break;case"source":Bi("error",e),a=o;break;case"img":case"image":case"link":Bi("error",e),Bi("load",e),a=o;break;case"details":Bi("toggle",e),a=o;break;case"input":Y(e,o),a=Q(e,o),Bi("invalid",e);break;case"option":default:a=o;break;case"select":e._wrapperState={wasMultiple:!!o.multiple},a=U({},o,{value:void 0}),Bi("invalid",e);break;case"textarea":oe(e,o),a=re(e,o),Bi("invalid",e)}for(s in be(i,a),l=a)if(l.hasOwnProperty(s)){var u=l[s];"style"===s?ve(e,u):"dangerouslySetInnerHTML"===s?null!=(u=u?u.__html:void 0)&&he(e,u):"children"===s?"string"==typeof u?("textarea"!==i||""!==u)&&pe(e,u):"number"==typeof u&&pe(e,""+u):"suppressContentEditableWarning"!==s&&"suppressHydrationWarning"!==s&&"autoFocus"!==s&&(r.hasOwnProperty(s)?null!=u&&"onScroll"===s&&Bi("scroll",e):null!=u&&y(e,s,u,c))}switch(i){case"input":G(e),ee(e,o,!1);break;case"textarea":G(e),se(e);break;case"option":null!=o.value&&e.setAttribute("value",""+W(o.value));break;case"select":e.multiple=!!o.multiple,null!=(s=o.value)?ie(e,!!o.multiple,s,!1):null!=o.defaultValue&&ie(e,!!o.multiple,o.defaultValue,!0);break;default:"function"==typeof a.onClick&&(e.onclick=er)}switch(i){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}}o&&(t.flags|=4)}null!==t.ref&&(t.flags|=512,t.flags|=2097152)}return Gs(t),null;case 6:if(e&&null!=t.stateNode)Ls(e,t,e.memoizedProps,o);else{if("string"!=typeof o&&null===t.stateNode)throw Error(n(166));if(i=Qo(Jo.current),Qo(Go.current),po(t)){if(o=t.stateNode,i=t.memoizedProps,o[pr]=t,(s=o.nodeValue!==i)&&null!==(e=io))switch(e.tag){case 3:Zi(o.nodeValue,i,!!(1&e.mode));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Zi(o.nodeValue,i,!!(1&e.mode))}s&&(t.flags|=4)}else(o=(9===i.nodeType?i:i.ownerDocument).createTextNode(o))[pr]=t,t.stateNode=o}return Gs(t),null;case 13:if(xr(ta),o=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(oo&&null!==ro&&1&t.mode&&!(128&t.flags))fo(),mo(),t.flags|=98560,s=!1;else if(s=po(t),null!==o&&null!==o.dehydrated){if(null===e){if(!s)throw Error(n(318));if(!(s=null!==(s=t.memoizedState)?s.dehydrated:null))throw Error(n(317));s[pr]=t}else mo(),!(128&t.flags)&&(t.memoizedState=null),t.flags|=4;Gs(t),s=!1}else null!==ao&&(sl(ao),ao=null),s=!0;if(!s)return 65536&t.flags?t:null}return 128&t.flags?(t.lanes=i,t):((o=null!==o)!==(null!==e&&null!==e.memoizedState)&&o&&(t.child.flags|=8192,1&t.mode&&(null===e||1&ta.current?0===Lc&&(Lc=3):gl())),null!==t.updateQueue&&(t.flags|=4),Gs(t),null);case 4:return Xo(),Ms(e,t),null===e&&qi(t.stateNode.containerInfo),Gs(t),null;case 10:return Ro(t.type._context),Gs(t),null;case 19:if(xr(ta),null===(s=t.memoizedState))return Gs(t),null;if(o=!!(128&t.flags),null===(c=s.rendering))if(o)Ks(s,!1);else{if(0!==Lc||null!==e&&128&e.flags)for(e=t.child;null!==e;){if(null!==(c=na(e))){for(t.flags|=128,Ks(s,!1),null!==(o=c.updateQueue)&&(t.updateQueue=o,t.flags|=4),t.subtreeFlags=0,o=i,i=t.child;null!==i;)e=o,(s=i).flags&=14680066,null===(c=s.alternate)?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),i=i.sibling;return Pr(ta,1&ta.current|2),t.child}e=e.sibling}null!==s.tail&&Xe()>qc&&(t.flags|=128,o=!0,Ks(s,!1),t.lanes=4194304)}else{if(!o)if(null!==(e=na(c))){if(t.flags|=128,o=!0,null!==(i=e.updateQueue)&&(t.updateQueue=i,t.flags|=4),Ks(s,!0),null===s.tail&&"hidden"===s.tailMode&&!c.alternate&&!oo)return Gs(t),null}else 2*Xe()-s.renderingStartTime>qc&&1073741824!==i&&(t.flags|=128,o=!0,Ks(s,!1),t.lanes=4194304);s.isBackwards?(c.sibling=t.child,t.child=c):(null!==(i=s.last)?i.sibling=c:t.child=c,s.last=c)}return null!==s.tail?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Xe(),t.sibling=null,i=ta.current,Pr(ta,o?1&i|2:1&i),t):(Gs(t),null);case 22:case 23:return hl(),o=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==o&&(t.flags|=8192),o&&1&t.mode?!!(1073741824&Mc)&&(Gs(t),6&t.subtreeFlags&&(t.flags|=8192)):Gs(t),null;case 24:case 25:return null}throw Error(n(156,t.tag))}function Js(e,t){switch(no(t),t.tag){case 1:return Mr(t.type)&&Dr(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Xo(),xr(Ir),xr(Rr),ra(),65536&(e=t.flags)&&!(128&e)?(t.flags=-65537&e|128,t):null;case 5:return ea(t),null;case 13:if(xr(ta),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(n(340));mo()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return xr(ta),null;case 4:return Xo(),null;case 10:return Ro(t.type._context),null;case 22:case 23:return hl(),null;default:return null}}Os=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},Ms=function(){},Ds=function(e,t,n,i){var o=e.memoizedProps;if(o!==i){e=t.stateNode,Qo(Go.current);var a,s=null;switch(n){case"input":o=Q(e,o),i=Q(e,i),s=[];break;case"select":o=U({},o,{value:void 0}),i=U({},i,{value:void 0}),s=[];break;case"textarea":o=re(e,o),i=re(e,i),s=[];break;default:"function"!=typeof o.onClick&&"function"==typeof i.onClick&&(e.onclick=er)}for(u in be(n,i),n=null,o)if(!i.hasOwnProperty(u)&&o.hasOwnProperty(u)&&null!=o[u])if("style"===u){var c=o[u];for(a in c)c.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else"dangerouslySetInnerHTML"!==u&&"children"!==u&&"suppressContentEditableWarning"!==u&&"suppressHydrationWarning"!==u&&"autoFocus"!==u&&(r.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in i){var l=i[u];if(c=null!=o?o[u]:void 0,i.hasOwnProperty(u)&&l!==c&&(null!=l||null!=c))if("style"===u)if(c){for(a in c)!c.hasOwnProperty(a)||l&&l.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in l)l.hasOwnProperty(a)&&c[a]!==l[a]&&(n||(n={}),n[a]=l[a])}else n||(s||(s=[]),s.push(u,n)),n=l;else"dangerouslySetInnerHTML"===u?(l=l?l.__html:void 0,c=c?c.__html:void 0,null!=l&&c!==l&&(s=s||[]).push(u,l)):"children"===u?"string"!=typeof l&&"number"!=typeof l||(s=s||[]).push(u,""+l):"suppressContentEditableWarning"!==u&&"suppressHydrationWarning"!==u&&(r.hasOwnProperty(u)?(null!=l&&"onScroll"===u&&Bi("scroll",e),s||c===l||(s=[])):(s=s||[]).push(u,l))}n&&(s=s||[]).push("style",n);var u=s;(t.updateQueue=u)&&(t.flags|=4)}},Ls=function(e,t,n,i){n!==i&&(t.flags|=4)};var Qs=!1,Ys=!1,Xs="function"==typeof WeakSet?WeakSet:Set,Zs=null;function ec(e,t){var n=e.ref;if(null!==n)if("function"==typeof n)try{n(null)}catch(i){El(e,t,i)}else n.current=null}function tc(e,t,n){try{n()}catch(i){El(e,t,i)}}var nc=!1;function ic(e,t,n){var i=t.updateQueue;if(null!==(i=null!==i?i.lastEffect:null)){var r=i=i.next;do{if((r.tag&e)===e){var o=r.destroy;r.destroy=void 0,void 0!==o&&tc(t,n,o)}r=r.next}while(r!==i)}}function rc(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var i=n.create;n.destroy=i()}n=n.next}while(n!==t)}}function oc(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"==typeof t?t(e):t.current=e}}function ac(e){var t=e.alternate;null!==t&&(e.alternate=null,ac(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&(delete t[pr],delete t[fr],delete t[gr],delete t[vr],delete t[yr])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function sc(e){return 5===e.tag||3===e.tag||4===e.tag}function cc(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||sc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function lc(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!=(n=n._reactRootContainer)||null!==t.onclick||(t.onclick=er));else if(4!==i&&null!==(e=e.child))for(lc(e,t,n),e=e.sibling;null!==e;)lc(e,t,n),e=e.sibling}function uc(e,t,n){var i=e.tag;if(5===i||6===i)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==i&&null!==(e=e.child))for(uc(e,t,n),e=e.sibling;null!==e;)uc(e,t,n),e=e.sibling}var dc=null,hc=!1;function pc(e,t,n){for(n=n.child;null!==n;)fc(e,t,n),n=n.sibling}function fc(e,t,n){if(at&&"function"==typeof at.onCommitFiberUnmount)try{at.onCommitFiberUnmount(ot,n)}catch(s){}switch(n.tag){case 5:Ys||ec(n,t);case 6:var i=dc,r=hc;dc=null,pc(e,t,n),hc=r,null!==(dc=i)&&(hc?(e=dc,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):dc.removeChild(n.stateNode));break;case 18:null!==dc&&(hc?(e=dc,n=n.stateNode,8===e.nodeType?lr(e.parentNode,n):1===e.nodeType&&lr(e,n),qt(e)):lr(dc,n.stateNode));break;case 4:i=dc,r=hc,dc=n.stateNode.containerInfo,hc=!0,pc(e,t,n),dc=i,hc=r;break;case 0:case 11:case 14:case 15:if(!Ys&&(null!==(i=n.updateQueue)&&null!==(i=i.lastEffect))){r=i=i.next;do{var o=r,a=o.destroy;o=o.tag,void 0!==a&&(2&o||4&o)&&tc(n,t,a),r=r.next}while(r!==i)}pc(e,t,n);break;case 1:if(!Ys&&(ec(n,t),"function"==typeof(i=n.stateNode).componentWillUnmount))try{i.props=n.memoizedProps,i.state=n.memoizedState,i.componentWillUnmount()}catch(s){El(n,t,s)}pc(e,t,n);break;case 21:pc(e,t,n);break;case 22:1&n.mode?(Ys=(i=Ys)||null!==n.memoizedState,pc(e,t,n),Ys=i):pc(e,t,n);break;default:pc(e,t,n)}}function mc(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Xs),t.forEach(function(t){var i=Rl.bind(null,e,t);n.has(t)||(n.add(t),t.then(i,i))})}}function gc(e,t){var i=t.deletions;if(null!==i)for(var r=0;r<i.length;r++){var o=i[r];try{var a=e,s=t,c=s;e:for(;null!==c;){switch(c.tag){case 5:dc=c.stateNode,hc=!1;break e;case 3:case 4:dc=c.stateNode.containerInfo,hc=!0;break e}c=c.return}if(null===dc)throw Error(n(160));fc(a,s,o),dc=null,hc=!1;var l=o.alternate;null!==l&&(l.return=null),o.return=null}catch(u){El(o,t,u)}}if(12854&t.subtreeFlags)for(t=t.child;null!==t;)vc(t,e),t=t.sibling}function vc(e,t){var i=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(gc(t,e),yc(e),4&r){try{ic(3,e,e.return),rc(3,e)}catch(g){El(e,e.return,g)}try{ic(5,e,e.return)}catch(g){El(e,e.return,g)}}break;case 1:gc(t,e),yc(e),512&r&&null!==i&&ec(i,i.return);break;case 5:if(gc(t,e),yc(e),512&r&&null!==i&&ec(i,i.return),32&e.flags){var o=e.stateNode;try{pe(o,"")}catch(g){El(e,e.return,g)}}if(4&r&&null!=(o=e.stateNode)){var a=e.memoizedProps,s=null!==i?i.memoizedProps:a,c=e.type,l=e.updateQueue;if(e.updateQueue=null,null!==l)try{"input"===c&&"radio"===a.type&&null!=a.name&&X(o,a),ke(c,s);var u=ke(c,a);for(s=0;s<l.length;s+=2){var d=l[s],h=l[s+1];"style"===d?ve(o,h):"dangerouslySetInnerHTML"===d?he(o,h):"children"===d?pe(o,h):y(o,d,h,u)}switch(c){case"input":Z(o,a);break;case"textarea":ae(o,a);break;case"select":var p=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!a.multiple;var f=a.value;null!=f?ie(o,!!a.multiple,f,!1):p!==!!a.multiple&&(null!=a.defaultValue?ie(o,!!a.multiple,a.defaultValue,!0):ie(o,!!a.multiple,a.multiple?[]:"",!1))}o[fr]=a}catch(g){El(e,e.return,g)}}break;case 6:if(gc(t,e),yc(e),4&r){if(null===e.stateNode)throw Error(n(162));o=e.stateNode,a=e.memoizedProps;try{o.nodeValue=a}catch(g){El(e,e.return,g)}}break;case 3:if(gc(t,e),yc(e),4&r&&null!==i&&i.memoizedState.isDehydrated)try{qt(t.containerInfo)}catch(g){El(e,e.return,g)}break;case 4:default:gc(t,e),yc(e);break;case 13:gc(t,e),yc(e),8192&(o=e.child).flags&&(a=null!==o.memoizedState,o.stateNode.isHidden=a,!a||null!==o.alternate&&null!==o.alternate.memoizedState||(Vc=Xe())),4&r&&mc(e);break;case 22:if(d=null!==i&&null!==i.memoizedState,1&e.mode?(Ys=(u=Ys)||d,gc(t,e),Ys=u):gc(t,e),yc(e),8192&r){if(u=null!==e.memoizedState,(e.stateNode.isHidden=u)&&!d&&1&e.mode)for(Zs=e,d=e.child;null!==d;){for(h=Zs=d;null!==Zs;){switch(f=(p=Zs).child,p.tag){case 0:case 11:case 14:case 15:ic(4,p,p.return);break;case 1:ec(p,p.return);var m=p.stateNode;if("function"==typeof m.componentWillUnmount){r=p,i=p.return;try{t=r,m.props=t.memoizedProps,m.state=t.memoizedState,m.componentWillUnmount()}catch(g){El(r,i,g)}}break;case 5:ec(p,p.return);break;case 22:if(null!==p.memoizedState){Cc(h);continue}}null!==f?(f.return=p,Zs=f):Cc(h)}d=d.sibling}e:for(d=null,h=e;;){if(5===h.tag){if(null===d){d=h;try{o=h.stateNode,u?"function"==typeof(a=o.style).setProperty?a.setProperty("display","none","important"):a.display="none":(c=h.stateNode,s=null!=(l=h.memoizedProps.style)&&l.hasOwnProperty("display")?l.display:null,c.style.display=ge("display",s))}catch(g){El(e,e.return,g)}}}else if(6===h.tag){if(null===d)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(g){El(e,e.return,g)}}else if((22!==h.tag&&23!==h.tag||null===h.memoizedState||h===e)&&null!==h.child){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;null===h.sibling;){if(null===h.return||h.return===e)break e;d===h&&(d=null),h=h.return}d===h&&(d=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:gc(t,e),yc(e),4&r&&mc(e);case 21:}}function yc(e){var t=e.flags;if(2&t){try{e:{for(var i=e.return;null!==i;){if(sc(i)){var r=i;break e}i=i.return}throw Error(n(160))}switch(r.tag){case 5:var o=r.stateNode;32&r.flags&&(pe(o,""),r.flags&=-33),uc(e,cc(e),o);break;case 3:case 4:var a=r.stateNode.containerInfo;lc(e,cc(e),a);break;default:throw Error(n(161))}}catch(s){El(e,e.return,s)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function bc(e,t,n){Zs=e,kc(e)}function kc(e,t,n){for(var i=!!(1&e.mode);null!==Zs;){var r=Zs,o=r.child;if(22===r.tag&&i){var a=null!==r.memoizedState||Qs;if(!a){var s=r.alternate,c=null!==s&&null!==s.memoizedState||Ys;s=Qs;var l=Ys;if(Qs=a,(Ys=c)&&!l)for(Zs=r;null!==Zs;)c=(a=Zs).child,22===a.tag&&null!==a.memoizedState?Tc(r):null!==c?(c.return=a,Zs=c):Tc(r);for(;null!==o;)Zs=o,kc(o),o=o.sibling;Zs=r,Qs=s,Ys=l}Sc(e)}else 8772&r.subtreeFlags&&null!==o?(o.return=r,Zs=o):Sc(e)}}function Sc(e){for(;null!==Zs;){var t=Zs;if(8772&t.flags){var i=t.alternate;try{if(8772&t.flags)switch(t.tag){case 0:case 11:case 15:Ys||rc(5,t);break;case 1:var r=t.stateNode;if(4&t.flags&&!Ys)if(null===i)r.componentDidMount();else{var o=t.elementType===t.type?i.memoizedProps:is(t.type,i.memoizedProps);r.componentDidUpdate(o,i.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;null!==a&&Wo(t,a,r);break;case 3:var s=t.updateQueue;if(null!==s){if(i=null,null!==t.child)switch(t.child.tag){case 5:case 1:i=t.child.stateNode}Wo(t,s,i)}break;case 5:var c=t.stateNode;if(null===i&&4&t.flags){i=c;var l=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break;case"img":l.src&&(i.src=l.src)}}break;case 6:case 4:case 12:case 19:case 17:case 21:case 22:case 23:case 25:break;case 13:if(null===t.memoizedState){var u=t.alternate;if(null!==u){var d=u.memoizedState;if(null!==d){var h=d.dehydrated;null!==h&&qt(h)}}}break;default:throw Error(n(163))}Ys||512&t.flags&&oc(t)}catch(p){El(t,t.return,p)}}if(t===e){Zs=null;break}if(null!==(i=t.sibling)){i.return=t.return,Zs=i;break}Zs=t.return}}function Cc(e){for(;null!==Zs;){var t=Zs;if(t===e){Zs=null;break}var n=t.sibling;if(null!==n){n.return=t.return,Zs=n;break}Zs=t.return}}function Tc(e){for(;null!==Zs;){var t=Zs;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{rc(4,t)}catch(c){El(t,n,c)}break;case 1:var i=t.stateNode;if("function"==typeof i.componentDidMount){var r=t.return;try{i.componentDidMount()}catch(c){El(t,r,c)}}var o=t.return;try{oc(t)}catch(c){El(t,o,c)}break;case 5:var a=t.return;try{oc(t)}catch(c){El(t,a,c)}}}catch(c){El(t,t.return,c)}if(t===e){Zs=null;break}var s=t.sibling;if(null!==s){s.return=t.return,Zs=s;break}Zs=t.return}}var wc,Ec=Math.ceil,xc=k.ReactCurrentDispatcher,Pc=k.ReactCurrentOwner,_c=k.ReactCurrentBatchConfig,Rc=0,Ic=null,Nc=null,Oc=0,Mc=0,Dc=Er(0),Lc=0,Ac=null,jc=0,Uc=0,Fc=0,Bc=null,zc=null,Vc=0,qc=1/0,Hc=null,Wc=!1,Kc=null,Gc=null,$c=!1,Jc=null,Qc=0,Yc=0,Xc=null,Zc=-1,el=0;function tl(){return 6&Rc?Xe():-1!==Zc?Zc:Zc=Xe()}function nl(e){return 1&e.mode?2&Rc&&0!==Oc?Oc&-Oc:null!==vo.transition?(0===el&&(el=gt()),el):0!==(e=kt)?e:e=void 0===(e=window.event)?16:Yt(e.type):1}function il(e,t,i,r){if(50<Yc)throw Yc=0,Xc=null,Error(n(185));yt(e,i,r),2&Rc&&e===Ic||(e===Ic&&(!(2&Rc)&&(Uc|=i),4===Lc&&cl(e,Oc)),rl(e,r),1===i&&0===Rc&&!(1&t.mode)&&(qc=Xe()+500,Br&&qr()))}function rl(e,t){var n=e.callbackNode;!function(e,t){for(var n=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-st(o),s=1<<a,c=r[a];-1===c?0!==(s&n)&&0===(s&i)||(r[a]=ft(s,t)):c<=t&&(e.expiredLanes|=s),o&=~s}}(e,t);var i=pt(e,e===Ic?Oc:0);if(0===i)null!==n&&Je(n),e.callbackNode=null,e.callbackPriority=0;else if(t=i&-i,e.callbackPriority!==t){if(null!=n&&Je(n),1===t)0===e.tag?function(e){Br=!0,Vr(e)}(ll.bind(null,e)):Vr(ll.bind(null,e)),sr(function(){!(6&Rc)&&qr()}),n=null;else{switch(St(i)){case 1:n=et;break;case 4:n=tt;break;case 16:default:n=nt;break;case 536870912:n=rt}n=Il(n,ol.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function ol(e,t){if(Zc=-1,el=0,6&Rc)throw Error(n(327));var i=e.callbackNode;if(Tl()&&e.callbackNode!==i)return null;var r=pt(e,e===Ic?Oc:0);if(0===r)return null;if(30&r||0!==(r&e.expiredLanes)||t)t=vl(e,r);else{t=r;var o=Rc;Rc|=2;var a=ml();for(Ic===e&&Oc===t||(Hc=null,qc=Xe()+500,pl(e,t));;)try{bl();break}catch(c){fl(e,c)}_o(),xc.current=a,Rc=o,null!==Nc?t=0:(Ic=null,Oc=0,t=Lc)}if(0!==t){if(2===t&&(0!==(o=mt(e))&&(r=o,t=al(e,o))),1===t)throw i=Ac,pl(e,0),cl(e,r),rl(e,Xe()),i;if(6===t)cl(e,r);else{if(o=e.current.alternate,!(30&r||function(e){for(var t=e;;){if(16384&t.flags){var n=t.updateQueue;if(null!==n&&null!==(n=n.stores))for(var i=0;i<n.length;i++){var r=n[i],o=r.getSnapshot;r=r.value;try{if(!ci(o(),r))return!1}catch(s){return!1}}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(o)||(t=vl(e,r),2===t&&(a=mt(e),0!==a&&(r=a,t=al(e,a))),1!==t)))throw i=Ac,pl(e,0),cl(e,r),rl(e,Xe()),i;switch(e.finishedWork=o,e.finishedLanes=r,t){case 0:case 1:throw Error(n(345));case 2:case 5:Cl(e,zc,Hc);break;case 3:if(cl(e,r),(130023424&r)===r&&10<(t=Vc+500-Xe())){if(0!==pt(e,0))break;if(((o=e.suspendedLanes)&r)!==r){tl(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=rr(Cl.bind(null,e,zc,Hc),t);break}Cl(e,zc,Hc);break;case 4:if(cl(e,r),(4194240&r)===r)break;for(t=e.eventTimes,o=-1;0<r;){var s=31-st(r);a=1<<s,(s=t[s])>o&&(o=s),r&=~a}if(r=o,10<(r=(120>(r=Xe()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ec(r/1960))-r)){e.timeoutHandle=rr(Cl.bind(null,e,zc,Hc),r);break}Cl(e,zc,Hc);break;default:throw Error(n(329))}}}return rl(e,Xe()),e.callbackNode===i?ol.bind(null,e):null}function al(e,t){var n=Bc;return e.current.memoizedState.isDehydrated&&(pl(e,t).flags|=256),2!==(e=vl(e,t))&&(t=zc,zc=n,null!==t&&sl(t)),e}function sl(e){null===zc?zc=e:zc.push.apply(zc,e)}function cl(e,t){for(t&=~Fc,t&=~Uc,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-st(t),i=1<<n;e[n]=-1,t&=~i}}function ll(e){if(6&Rc)throw Error(n(327));Tl();var t=pt(e,0);if(!(1&t))return rl(e,Xe()),null;var i=vl(e,t);if(0!==e.tag&&2===i){var r=mt(e);0!==r&&(t=r,i=al(e,r))}if(1===i)throw i=Ac,pl(e,0),cl(e,t),rl(e,Xe()),i;if(6===i)throw Error(n(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Cl(e,zc,Hc),rl(e,Xe()),null}function ul(e,t){var n=Rc;Rc|=1;try{return e(t)}finally{0===(Rc=n)&&(qc=Xe()+500,Br&&qr())}}function dl(e){null!==Jc&&0===Jc.tag&&!(6&Rc)&&Tl();var t=Rc;Rc|=1;var n=_c.transition,i=kt;try{if(_c.transition=null,kt=1,e)return e()}finally{kt=i,_c.transition=n,!(6&(Rc=t))&&qr()}}function hl(){Mc=Dc.current,xr(Dc)}function pl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,or(n)),null!==Nc)for(n=Nc.return;null!==n;){var i=n;switch(no(i),i.tag){case 1:null!=(i=i.type.childContextTypes)&&Dr();break;case 3:Xo(),xr(Ir),xr(Rr),ra();break;case 5:ea(i);break;case 4:Xo();break;case 13:case 19:xr(ta);break;case 10:Ro(i.type._context);break;case 22:case 23:hl()}n=n.return}if(Ic=e,Nc=e=Dl(e.current,null),Oc=Mc=t,Lc=0,Ac=null,Fc=Uc=jc=0,zc=Bc=null,null!==Mo){for(t=0;t<Mo.length;t++)if(null!==(i=(n=Mo[t]).interleaved)){n.interleaved=null;var r=i.next,o=n.pending;if(null!==o){var a=o.next;o.next=r,i.next=a}n.pending=i}Mo=null}return e}function fl(e,t){for(;;){var i=Nc;try{if(_o(),oa.current=Za,da){for(var r=ca.memoizedState;null!==r;){var o=r.queue;null!==o&&(o.pending=null),r=r.next}da=!1}if(sa=0,ua=la=ca=null,ha=!1,pa=0,Pc.current=null,null===i||null===i.return){Lc=1,Ac=t,Nc=null;break}e:{var a=e,s=i.return,c=i,l=t;if(t=Oc,c.flags|=32768,null!==l&&"object"==typeof l&&"function"==typeof l.then){var u=l,d=c,h=d.tag;if(!(1&d.mode||0!==h&&11!==h&&15!==h)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var f=vs(s);if(null!==f){f.flags&=-257,ys(f,s,c,0,t),1&f.mode&&gs(a,u,t),l=u;var m=(t=f).updateQueue;if(null===m){var g=new Set;g.add(l),t.updateQueue=g}else m.add(l);break e}if(!(1&t)){gs(a,u,t),gl();break e}l=Error(n(426))}else if(oo&&1&c.mode){var v=vs(s);if(null!==v){!(65536&v.flags)&&(v.flags|=256),ys(v,s,c,0,t),go(us(l,c));break e}}a=l=us(l,c),4!==Lc&&(Lc=2),null===Bc?Bc=[a]:Bc.push(a),a=s;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t,qo(a,fs(0,l,t));break e;case 1:c=l;var y=a.type,b=a.stateNode;if(!(128&a.flags||"function"!=typeof y.getDerivedStateFromError&&(null===b||"function"!=typeof b.componentDidCatch||null!==Gc&&Gc.has(b)))){a.flags|=65536,t&=-t,a.lanes|=t,qo(a,ms(a,c,t));break e}}a=a.return}while(null!==a)}Sl(i)}catch(k){t=k,Nc===i&&null!==i&&(Nc=i=i.return);continue}break}}function ml(){var e=xc.current;return xc.current=Za,null===e?Za:e}function gl(){0!==Lc&&3!==Lc&&2!==Lc||(Lc=4),null===Ic||!(268435455&jc)&&!(268435455&Uc)||cl(Ic,Oc)}function vl(e,t){var i=Rc;Rc|=2;var r=ml();for(Ic===e&&Oc===t||(Hc=null,pl(e,t));;)try{yl();break}catch(o){fl(e,o)}if(_o(),Rc=i,xc.current=r,null!==Nc)throw Error(n(261));return Ic=null,Oc=0,Lc}function yl(){for(;null!==Nc;)kl(Nc)}function bl(){for(;null!==Nc&&!Qe();)kl(Nc)}function kl(e){var t=wc(e.alternate,e,Mc);e.memoizedProps=e.pendingProps,null===t?Sl(e):Nc=t,Pc.current=null}function Sl(e){var t=e;do{var n=t.alternate;if(e=t.return,32768&t.flags){if(null!==(n=Js(n,t)))return n.flags&=32767,void(Nc=n);if(null===e)return Lc=6,void(Nc=null);e.flags|=32768,e.subtreeFlags=0,e.deletions=null}else if(null!==(n=$s(n,t,Mc)))return void(Nc=n);if(null!==(t=t.sibling))return void(Nc=t);Nc=t=e}while(null!==t);0===Lc&&(Lc=5)}function Cl(e,t,i){var r=kt,o=_c.transition;try{_c.transition=null,kt=1,function(e,t,i,r){do{Tl()}while(null!==Jc);if(6&Rc)throw Error(n(327));i=e.finishedWork;var o=e.finishedLanes;if(null===i)return null;if(e.finishedWork=null,e.finishedLanes=0,i===e.current)throw Error(n(177));e.callbackNode=null,e.callbackPriority=0;var a=i.lanes|i.childLanes;if(function(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var i=e.eventTimes;for(e=e.expirationTimes;0<n;){var r=31-st(n),o=1<<r;t[r]=0,i[r]=-1,e[r]=-1,n&=~o}}(e,a),e===Ic&&(Nc=Ic=null,Oc=0),!(2064&i.subtreeFlags)&&!(2064&i.flags)||$c||($c=!0,Il(nt,function(){return Tl(),null})),a=!!(15990&i.flags),!!(15990&i.subtreeFlags)||a){a=_c.transition,_c.transition=null;var s=kt;kt=1;var c=Rc;Rc|=4,Pc.current=null,function(e,t){if(tr=Wt,fi(e=pi())){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(i=(i=e.ownerDocument)&&i.defaultView||window).getSelection&&i.getSelection();if(r&&0!==r.rangeCount){i=r.anchorNode;var o=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{i.nodeType,a.nodeType}catch(S){i=null;break e}var s=0,c=-1,l=-1,u=0,d=0,h=e,p=null;t:for(;;){for(var f;h!==i||0!==o&&3!==h.nodeType||(c=s+o),h!==a||0!==r&&3!==h.nodeType||(l=s+r),3===h.nodeType&&(s+=h.nodeValue.length),null!==(f=h.firstChild);)p=h,h=f;for(;;){if(h===e)break t;if(p===i&&++u===o&&(c=s),p===a&&++d===r&&(l=s),null!==(f=h.nextSibling))break;p=(h=p).parentNode}h=f}i=-1===c||-1===l?null:{start:c,end:l}}else i=null}i=i||{start:0,end:0}}else i=null;for(nr={focusedElem:e,selectionRange:i},Wt=!1,Zs=t;null!==Zs;)if(e=(t=Zs).child,1028&t.subtreeFlags&&null!==e)e.return=t,Zs=e;else for(;null!==Zs;){t=Zs;try{var m=t.alternate;if(1024&t.flags)switch(t.tag){case 0:case 11:case 15:case 5:case 6:case 4:case 17:break;case 1:if(null!==m){var g=m.memoizedProps,v=m.memoizedState,y=t.stateNode,b=y.getSnapshotBeforeUpdate(t.elementType===t.type?g:is(t.type,g),v);y.__reactInternalSnapshotBeforeUpdate=b}break;case 3:var k=t.stateNode.containerInfo;1===k.nodeType?k.textContent="":9===k.nodeType&&k.documentElement&&k.removeChild(k.documentElement);break;default:throw Error(n(163))}}catch(S){El(t,t.return,S)}if(null!==(e=t.sibling)){e.return=t.return,Zs=e;break}Zs=t.return}m=nc,nc=!1}(e,i),vc(i,e),mi(nr),Wt=!!tr,nr=tr=null,e.current=i,bc(i),Ye(),Rc=c,kt=s,_c.transition=a}else e.current=i;if($c&&($c=!1,Jc=e,Qc=o),a=e.pendingLanes,0===a&&(Gc=null),function(e){if(at&&"function"==typeof at.onCommitFiberRoot)try{at.onCommitFiberRoot(ot,e,void 0,!(128&~e.current.flags))}catch(t){}}(i.stateNode),rl(e,Xe()),null!==t)for(r=e.onRecoverableError,i=0;i<t.length;i++)o=t[i],r(o.value,{componentStack:o.stack,digest:o.digest});if(Wc)throw Wc=!1,e=Kc,Kc=null,e;!!(1&Qc)&&0!==e.tag&&Tl(),a=e.pendingLanes,1&a?e===Xc?Yc++:(Yc=0,Xc=e):Yc=0,qr()}(e,t,i,r)}finally{_c.transition=o,kt=r}return null}function Tl(){if(null!==Jc){var e=St(Qc),t=_c.transition,i=kt;try{if(_c.transition=null,kt=16>e?16:e,null===Jc)var r=!1;else{if(e=Jc,Jc=null,Qc=0,6&Rc)throw Error(n(331));var o=Rc;for(Rc|=4,Zs=e.current;null!==Zs;){var a=Zs,s=a.child;if(16&Zs.flags){var c=a.deletions;if(null!==c){for(var l=0;l<c.length;l++){var u=c[l];for(Zs=u;null!==Zs;){var d=Zs;switch(d.tag){case 0:case 11:case 15:ic(8,d,a)}var h=d.child;if(null!==h)h.return=d,Zs=h;else for(;null!==Zs;){var p=(d=Zs).sibling,f=d.return;if(ac(d),d===u){Zs=null;break}if(null!==p){p.return=f,Zs=p;break}Zs=f}}}var m=a.alternate;if(null!==m){var g=m.child;if(null!==g){m.child=null;do{var v=g.sibling;g.sibling=null,g=v}while(null!==g)}}Zs=a}}if(2064&a.subtreeFlags&&null!==s)s.return=a,Zs=s;else e:for(;null!==Zs;){if(2048&(a=Zs).flags)switch(a.tag){case 0:case 11:case 15:ic(9,a,a.return)}var y=a.sibling;if(null!==y){y.return=a.return,Zs=y;break e}Zs=a.return}}var b=e.current;for(Zs=b;null!==Zs;){var k=(s=Zs).child;if(2064&s.subtreeFlags&&null!==k)k.return=s,Zs=k;else e:for(s=b;null!==Zs;){if(2048&(c=Zs).flags)try{switch(c.tag){case 0:case 11:case 15:rc(9,c)}}catch(C){El(c,c.return,C)}if(c===s){Zs=null;break e}var S=c.sibling;if(null!==S){S.return=c.return,Zs=S;break e}Zs=c.return}}if(Rc=o,qr(),at&&"function"==typeof at.onPostCommitFiberRoot)try{at.onPostCommitFiberRoot(ot,e)}catch(C){}r=!0}return r}finally{kt=i,_c.transition=t}}return!1}function wl(e,t,n){e=zo(e,t=fs(0,t=us(n,t),1),1),t=tl(),null!==e&&(yt(e,1,t),rl(e,t))}function El(e,t,n){if(3===e.tag)wl(e,e,n);else for(;null!==t;){if(3===t.tag){wl(t,e,n);break}if(1===t.tag){var i=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===Gc||!Gc.has(i))){t=zo(t,e=ms(t,e=us(n,e),1),1),e=tl(),null!==t&&(yt(t,1,e),rl(t,e));break}}t=t.return}}function xl(e,t,n){var i=e.pingCache;null!==i&&i.delete(t),t=tl(),e.pingedLanes|=e.suspendedLanes&n,Ic===e&&(Oc&n)===n&&(4===Lc||3===Lc&&(130023424&Oc)===Oc&&500>Xe()-Vc?pl(e,0):Fc|=n),rl(e,t)}function Pl(e,t){0===t&&(1&e.mode?(t=dt,!(130023424&(dt<<=1))&&(dt=4194304)):t=1);var n=tl();null!==(e=Ao(e,t))&&(yt(e,t,n),rl(e,n))}function _l(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Pl(e,n)}function Rl(e,t){var i=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;null!==o&&(i=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(n(314))}null!==r&&r.delete(t),Pl(e,i)}function Il(e,t){return $e(e,t)}function Nl(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ol(e,t,n,i){return new Nl(e,t,n,i)}function Ml(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Dl(e,t){var n=e.alternate;return null===n?((n=Ol(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ll(e,t,i,r,o,a){var s=2;if(r=e,"function"==typeof e)Ml(e)&&(s=1);else if("string"==typeof e)s=5;else e:switch(e){case w:return Al(i.children,o,a,t);case E:s=8,o|=8;break;case x:return(e=Ol(12,i,t,2|o)).elementType=x,e.lanes=a,e;case I:return(e=Ol(13,i,t,o)).elementType=I,e.lanes=a,e;case N:return(e=Ol(19,i,t,o)).elementType=N,e.lanes=a,e;case D:return jl(i,o,a,t);default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case P:s=10;break e;case _:s=9;break e;case R:s=11;break e;case O:s=14;break e;case M:s=16,r=null;break e}throw Error(n(130,null==e?e:typeof e,""))}return(t=Ol(s,i,t,o)).elementType=e,t.type=r,t.lanes=a,t}function Al(e,t,n,i){return(e=Ol(7,e,i,t)).lanes=n,e}function jl(e,t,n,i){return(e=Ol(22,e,i,t)).elementType=D,e.lanes=n,e.stateNode={isHidden:!1},e}function Ul(e,t,n){return(e=Ol(6,e,null,t)).lanes=n,e}function Fl(e,t,n){return(t=Ol(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Bl(e,t,n,i,r){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=vt(0),this.expirationTimes=vt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=vt(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function zl(e,t,n,i,r,o,a,s,c){return e=new Bl(e,t,n,s,c),1===t?(t=1,!0===o&&(t|=8)):t=0,o=Ol(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:i,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Uo(o),e}function Vl(e){if(!e)return _r;e:{if(qe(e=e._reactInternals)!==e||1!==e.tag)throw Error(n(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Mr(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(n(171))}if(1===e.tag){var i=e.type;if(Mr(i))return Ar(e,i,t)}return t}function ql(e,t,n,i,r,o,a,s,c){return(e=zl(n,i,!0,e,0,o,0,s,c)).context=Vl(null),n=e.current,(o=Bo(i=tl(),r=nl(n))).callback=null!=t?t:null,zo(n,o,r),e.current.lanes=r,yt(e,r,i),rl(e,i),e}function Hl(e,t,n,i){var r=t.current,o=tl(),a=nl(r);return n=Vl(n),null===t.context?t.context=n:t.pendingContext=n,(t=Bo(o,a)).payload={element:e},null!==(i=void 0===i?null:i)&&(t.callback=i),null!==(e=zo(r,t,a))&&(il(e,r,a,o),Vo(e,r,a)),a}function Wl(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function Kl(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function Gl(e,t){Kl(e,t),(e=e.alternate)&&Kl(e,t)}wc=function(e,t,i){if(null!==e)if(e.memoizedProps!==t.pendingProps||Ir.current)ks=!0;else{if(0===(e.lanes&i)&&!(128&t.flags))return ks=!1,function(e,t,n){switch(t.tag){case 3:Is(t),mo();break;case 5:Zo(t);break;case 1:Mr(t.type)&&jr(t);break;case 4:Yo(t,t.stateNode.containerInfo);break;case 10:var i=t.type._context,r=t.memoizedProps.value;Pr(wo,i._currentValue),i._currentValue=r;break;case 13:if(null!==(i=t.memoizedState))return null!==i.dehydrated?(Pr(ta,1&ta.current),t.flags|=128,null):0!==(n&t.child.childLanes)?Us(e,t,n):(Pr(ta,1&ta.current),null!==(e=Ws(e,t,n))?e.sibling:null);Pr(ta,1&ta.current);break;case 19:if(i=0!==(n&t.childLanes),128&e.flags){if(i)return qs(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),Pr(ta,ta.current),i)break;return null;case 22:case 23:return t.lanes=0,Es(e,t,n)}return Ws(e,t,n)}(e,t,i);ks=!!(131072&e.flags)}else ks=!1,oo&&1048576&t.flags&&eo(t,Gr,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Hs(e,t),e=t.pendingProps;var o=Or(t,Rr.current);No(t,i),o=va(null,t,r,e,o,i);var a=ya();return t.flags|=1,"object"==typeof o&&null!==o&&"function"==typeof o.render&&void 0===o.$$typeof?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Mr(r)?(a=!0,jr(t)):a=!1,t.memoizedState=null!==o.state&&void 0!==o.state?o.state:null,Uo(t),o.updater=os,t.stateNode=o,o._reactInternals=t,ls(t,r,e,i),t=Rs(null,t,r,!0,a,i)):(t.tag=0,oo&&a&&to(t),Ss(null,t,o,i),t=t.child),t;case 16:r=t.elementType;e:{switch(Hs(e,t),e=t.pendingProps,r=(o=r._init)(r._payload),t.type=r,o=t.tag=function(e){if("function"==typeof e)return Ml(e)?1:0;if(null!=e){if((e=e.$$typeof)===R)return 11;if(e===O)return 14}return 2}(r),e=is(r,e),o){case 0:t=Ps(null,t,r,e,i);break e;case 1:t=_s(null,t,r,e,i);break e;case 11:t=Cs(null,t,r,e,i);break e;case 14:t=Ts(null,t,r,is(r.type,e),i);break e}throw Error(n(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,Ps(e,t,r,o=t.elementType===r?o:is(r,o),i);case 1:return r=t.type,o=t.pendingProps,_s(e,t,r,o=t.elementType===r?o:is(r,o),i);case 3:e:{if(Is(t),null===e)throw Error(n(387));r=t.pendingProps,o=(a=t.memoizedState).element,Fo(e,t),Ho(t,r,null,i);var s=t.memoizedState;if(r=s.element,a.isDehydrated){if(a={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=a,t.memoizedState=a,256&t.flags){t=Ns(e,t,r,i,o=us(Error(n(423)),t));break e}if(r!==o){t=Ns(e,t,r,i,o=us(Error(n(424)),t));break e}for(ro=ur(t.stateNode.containerInfo.firstChild),io=t,oo=!0,ao=null,i=To(t,null,r,i),t.child=i;i;)i.flags=-3&i.flags|4096,i=i.sibling}else{if(mo(),r===o){t=Ws(e,t,i);break e}Ss(e,t,r,i)}t=t.child}return t;case 5:return Zo(t),null===e&&uo(t),r=t.type,o=t.pendingProps,a=null!==e?e.memoizedProps:null,s=o.children,ir(r,o)?s=null:null!==a&&ir(r,a)&&(t.flags|=32),xs(e,t),Ss(e,t,s,i),t.child;case 6:return null===e&&uo(t),null;case 13:return Us(e,t,i);case 4:return Yo(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=Co(t,null,r,i):Ss(e,t,r,i),t.child;case 11:return r=t.type,o=t.pendingProps,Cs(e,t,r,o=t.elementType===r?o:is(r,o),i);case 7:return Ss(e,t,t.pendingProps,i),t.child;case 8:case 12:return Ss(e,t,t.pendingProps.children,i),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,a=t.memoizedProps,s=o.value,Pr(wo,r._currentValue),r._currentValue=s,null!==a)if(ci(a.value,s)){if(a.children===o.children&&!Ir.current){t=Ws(e,t,i);break e}}else for(null!==(a=t.child)&&(a.return=t);null!==a;){var c=a.dependencies;if(null!==c){s=a.child;for(var l=c.firstContext;null!==l;){if(l.context===r){if(1===a.tag){(l=Bo(-1,i&-i)).tag=2;var u=a.updateQueue;if(null!==u){var d=(u=u.shared).pending;null===d?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}a.lanes|=i,null!==(l=a.alternate)&&(l.lanes|=i),Io(a.return,i,t),c.lanes|=i;break}l=l.next}}else if(10===a.tag)s=a.type===t.type?null:a.child;else if(18===a.tag){if(null===(s=a.return))throw Error(n(341));s.lanes|=i,null!==(c=s.alternate)&&(c.lanes|=i),Io(s,i,t),s=a.sibling}else s=a.child;if(null!==s)s.return=a;else for(s=a;null!==s;){if(s===t){s=null;break}if(null!==(a=s.sibling)){a.return=s.return,s=a;break}s=s.return}a=s}Ss(e,t,o.children,i),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,No(t,i),r=r(o=Oo(o)),t.flags|=1,Ss(e,t,r,i),t.child;case 14:return o=is(r=t.type,t.pendingProps),Ts(e,t,r,o=is(r.type,o),i);case 15:return ws(e,t,t.type,t.pendingProps,i);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:is(r,o),Hs(e,t),t.tag=1,Mr(r)?(e=!0,jr(t)):e=!1,No(t,i),ss(t,r,o),ls(t,r,o,i),Rs(null,t,r,!0,e,i);case 19:return qs(e,t,i);case 22:return Es(e,t,i)}throw Error(n(156,t.tag))};var $l="function"==typeof reportError?reportError:function(e){console.error(e)};function Jl(e){this._internalRoot=e}function Ql(e){this._internalRoot=e}function Yl(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function Xl(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function Zl(){}function eu(e,t,n,i,r){var o=n._reactRootContainer;if(o){var a=o;if("function"==typeof r){var s=r;r=function(){var e=Wl(a);s.call(e)}}Hl(t,a,e,r)}else a=function(e,t,n,i,r){if(r){if("function"==typeof i){var o=i;i=function(){var e=Wl(a);o.call(e)}}var a=ql(t,i,e,0,null,!1,0,"",Zl);return e._reactRootContainer=a,e[mr]=a.current,qi(8===e.nodeType?e.parentNode:e),dl(),a}for(;r=e.lastChild;)e.removeChild(r);if("function"==typeof i){var s=i;i=function(){var e=Wl(c);s.call(e)}}var c=zl(e,0,!1,null,0,!1,0,"",Zl);return e._reactRootContainer=c,e[mr]=c.current,qi(8===e.nodeType?e.parentNode:e),dl(function(){Hl(t,c,n,i)}),c}(n,t,e,r,i);return Wl(a)}Ql.prototype.render=Jl.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(n(409));Hl(e,t,null,null)},Ql.prototype.unmount=Jl.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;dl(function(){Hl(null,e,null,null)}),t[mr]=null}},Ql.prototype.unstable_scheduleHydration=function(e){if(e){var t=Et();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Dt.length&&0!==t&&t<Dt[n].priority;n++);Dt.splice(n,0,e),0===n&&Ut(e)}},Ct=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=ht(t.pendingLanes);0!==n&&(bt(t,1|n),rl(t,Xe()),!(6&Rc)&&(qc=Xe()+500,qr()))}break;case 13:dl(function(){var t=Ao(e,1);if(null!==t){var n=tl();il(t,e,1,n)}}),Gl(e,1)}},Tt=function(e){if(13===e.tag){var t=Ao(e,134217728);if(null!==t)il(t,e,134217728,tl());Gl(e,134217728)}},wt=function(e){if(13===e.tag){var t=nl(e),n=Ao(e,t);if(null!==n)il(n,e,t,tl());Gl(e,t)}},Et=function(){return kt},xt=function(e,t){var n=kt;try{return kt=e,t()}finally{kt=n}},Te=function(e,t,i){switch(t){case"input":if(Z(e,i),t=i.name,"radio"===i.type&&null!=t){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<i.length;t++){var r=i[t];if(r!==e&&r.form===e.form){var o=Cr(r);if(!o)throw Error(n(90));$(r),Z(r,o)}}}break;case"textarea":ae(e,i);break;case"select":null!=(t=i.value)&&ie(e,!!i.multiple,t,!1)}},Re=ul,Ie=dl;var tu={usingClientEntryPoint:!1,Events:[kr,Sr,Cr,Pe,_e,ul]},nu={findFiberByHostInstance:br,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},iu={bundleType:nu.bundleType,version:nu.version,rendererPackageName:nu.rendererPackageName,rendererConfig:nu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:k.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=Ke(e))?null:e.stateNode},findFiberByHostInstance:nu.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ru.isDisabled&&ru.supportsFiber)try{ot=ru.inject(iu),at=ru}catch(de){}}return b.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=tu,b.createPortal=function(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!Yl(t))throw Error(n(200));return function(e,t,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:T,key:null==i?null:""+i,children:e,containerInfo:t,implementation:n}}(e,t,null,i)},b.createRoot=function(e,t){if(!Yl(e))throw Error(n(299));var i=!1,r="",o=$l;return null!=t&&(!0===t.unstable_strictMode&&(i=!0),void 0!==t.identifierPrefix&&(r=t.identifierPrefix),void 0!==t.onRecoverableError&&(o=t.onRecoverableError)),t=zl(e,1,!1,null,0,i,0,r,o),e[mr]=t.current,qi(8===e.nodeType?e.parentNode:e),new Jl(t)},b.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternals;if(void 0===t){if("function"==typeof e.render)throw Error(n(188));throw e=Object.keys(e).join(","),Error(n(268,e))}return e=null===(e=Ke(t))?null:e.stateNode},b.flushSync=function(e){return dl(e)},b.hydrate=function(e,t,i){if(!Xl(t))throw Error(n(200));return eu(null,e,t,!0,i)},b.hydrateRoot=function(e,t,i){if(!Yl(e))throw Error(n(405));var r=null!=i&&i.hydratedSources||null,o=!1,a="",s=$l;if(null!=i&&(!0===i.unstable_strictMode&&(o=!0),void 0!==i.identifierPrefix&&(a=i.identifierPrefix),void 0!==i.onRecoverableError&&(s=i.onRecoverableError)),t=ql(t,null,e,1,null!=i?i:null,o,0,a,s),e[mr]=t.current,qi(e),r)for(e=0;e<r.length;e++)o=(o=(i=r[e])._getVersion)(i._source),null==t.mutableSourceEagerHydrationData?t.mutableSourceEagerHydrationData=[i,o]:t.mutableSourceEagerHydrationData.push(i,o);return new Ql(t)},b.render=function(e,t,i){if(!Xl(t))throw Error(n(200));return eu(null,e,t,!1,i)},b.unmountComponentAtNode=function(e){if(!Xl(e))throw Error(n(40));return!!e._reactRootContainer&&(dl(function(){eu(null,null,e,!1,function(){e._reactRootContainer=null,e[mr]=null})}),!0)},b.unstable_batchedUpdates=ul,b.unstable_renderSubtreeIntoContainer=function(e,t,i,r){if(!Xl(i))throw Error(n(200));if(null==e||void 0===e._reactInternals)throw Error(n(38));return eu(e,t,i,!1,r)},b.version="18.3.1-next-f1338f8080-20240426",b}var w,E,x=function(){if(g)return v;g=1;var e=(m||(m=1,function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),y.exports=T()),y.exports);return v.createRoot=e.createRoot,v.hydrateRoot=e.hydrateRoot,v}(),P={exports:{}},_={};var R=(E||(E=1,P.exports=function(){if(w)return _;w=1;var e=l(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function a(e,n,a){var s,c={},l=null,u=null;for(s in void 0!==a&&(l=""+a),void 0!==n.key&&(l=""+n.key),void 0!==n.ref&&(u=n.ref),n)i.call(n,s)&&!o.hasOwnProperty(s)&&(c[s]=n[s]);if(e&&e.defaultProps)for(s in n=e.defaultProps)void 0===c[s]&&(c[s]=n[s]);return{$$typeof:t,type:e,key:l,ref:u,props:c,_owner:r.current}}return _.Fragment=n,_.jsx=a,_.jsxs=a,_}()),P.exports);const I="bb-chat-";function N(e,t){try{sessionStorage.setItem(`${I}${e}`,JSON.stringify(t))}catch{}}function O(e){try{sessionStorage.removeItem(`${I}${e}`)}catch{}}function M(e){const{config:t,apiClient:n,mockMode:i,streamMessages:r=!1,artificialDelay:o,onSessionStart:a,onSessionEnd:s,onMessage:c,onError:l}=e,[d,h]=u.useState([]),[p,f]=u.useState([]),[m,g]=u.useState(!1),[v,y]=u.useState(!1),[b,k]=u.useState(null),[S,C]=u.useState(null),T=u.useRef(0),w=u.useRef(!1),E=u.useRef({}),x=u.useRef(null),P=u.useRef(null),_=u.useCallback(()=>{if(!o)return 0;const[e,t]=o;return 1e3*(e+Math.random()*(t-e))},[o]);u.useEffect(()=>{if(w.current)return;w.current=!0;const e=function(e){try{const t=sessionStorage.getItem(`${I}${e}`);return t?JSON.parse(t):null}catch{return null}}(t.embedId);e&&"active"===e.status&&(C(e.sessionId),h(e.messages),f(e.toolCalls),T.current=e.startTime)},[t.embedId]),u.useEffect(()=>{S&&d.length>0&&N(t.embedId,{sessionId:S,deploymentId:t.deploymentId,workerId:t.workerId,flowId:t.flowId,startTime:T.current,messages:d,toolCalls:p,status:"active"})},[S,d,p,t]);const R=u.useCallback(async()=>(T.current=Date.now(),C(null),h([]),f([]),O(t.embedId),""),[t.embedId]),M=u.useCallback((e,t,n)=>{h(i=>{let r=!1;const o=i.map(i=>i.id===e?(r=!0,{...i,content:t,status:n}):i);return r||o.push({id:e,role:"assistant",content:t,timestamp:Date.now(),status:n}),o})},[]),D=u.useCallback((e,t,n=!1)=>{if(r||n)if(n&&o){const n=_();P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{M(e,t,"sent")},n)}else M(e,t,n?"sent":"streaming")},[r,o,_,M]),L=u.useCallback((e,n,i)=>{switch(e.type){case"session":{const t=e.data;t.session_id&&(i(t.session_id),t.is_new&&(T.current=Date.now(),null==a||a(t.session_id)));break}case"message":{const t=e.data;t.content&&(E.current[n]=t.content,D(n,t.content));break}case"chunk":{const t=e.data;if(t.content){const e=(E.current[n]??"")+t.content;E.current[n]=e,D(n,e)}break}case"tool_call":{const t=e.data;if(f(e=>{const n=e.findIndex(e=>e.name===t.function&&"pending"===e.status);return-1!==n&&void 0!==t.result?e.map((e,i)=>i===n?{...e,result:t.result,status:"completed"}:e):-1===n?[...e,{id:`tc-${Date.now()}-${Math.random().toString(36).slice(2)}`,name:t.function,arguments:t.args??{},status:"pending",timestamp:Date.now()}]:e}),t.content){const e=t.content;E.current[n]=e,D(n,e)}break}case"waiting":break;case"done":if(r)h(e=>e.map(e=>e.id===n?{...e,status:"sent"}:e));else{const e=E.current[n]??"";e&&D(n,e,!0)}delete E.current[n];break;case"completed":if(!r){const e=E.current[n]??"";e&&D(n,e,!0)}h(e=>{const i=e.map(e=>e.id===n?{...e,status:"sent"}:e);return S&&N(t.embedId,{sessionId:S,deploymentId:t.deploymentId,workerId:t.workerId,flowId:t.flowId,startTime:T.current,messages:i,toolCalls:[],status:"completed"}),i}),delete E.current[n];break;case"error":{const t=e.data;h(e=>e.map(e=>e.id===n?{...e,status:"error",content:t.error??"An error occurred"}:e));break}}},[t,S,r,a,D]),A=u.useCallback(async(e,t,n)=>{const i=e.getReader(),r=new TextDecoder;let o="";try{for(;;){const{done:e,value:a}=await i.read();if(e)break;let s;for(o+=r.decode(a,{stream:!0});-1!==(s=o.indexOf("\n\n"));){const e=o.slice(0,s);o=o.slice(s+2);for(const i of e.split("\n"))if(i.startsWith("data: "))try{const e=JSON.parse(i.slice(6));L(e,t,n)}catch{}}}}finally{i.releaseLock()}},[L]),j=u.useCallback(async e=>{if(!e.trim())return;const o={id:`user-${Date.now()}`,role:"user",content:e,timestamp:Date.now(),status:"sent"};h(e=>[...e,o]),null==c||c(o);const a=`assistant-${Date.now()}`;if(r){const e={id:a,role:"assistant",content:"",timestamp:Date.now(),status:"streaming"};h(t=>[...t,e])}g(!0),k(null),x.current&&clearTimeout(x.current);const s=1e3+_();x.current=setTimeout(()=>{y(!0)},s);const u=e=>{C(e)};try{if(i){const t=n.sendMessage(e);for await(const e of t)L(e,a,u)}else{const i=await n.sendMessage({embedId:t.embedId,message:e,sessionId:S??void 0});await A(i,a,u)}r&&h(e=>e.map(e=>e.id===a&&"streaming"===e.status?{...e,status:"sent"}:e))}catch(d){const e=d instanceof Error?d:new Error("Failed to send message");k(e),null==l||l(e),r&&h(e=>e.map(e=>e.id===a?{...e,status:"error",content:"Failed to get response"}:e))}finally{x.current&&(clearTimeout(x.current),x.current=null),y(!1),g(!1)}},[S,n,i,r,_,t.embedId,L,A,c,l]),U=u.useCallback(async()=>{const e=`assistant-${Date.now()}`;if(r){const t={id:e,role:"assistant",content:"",timestamp:Date.now(),status:"streaming"};h(e=>[...e,t])}g(!0),k(null),x.current&&clearTimeout(x.current);const o=1e3+_();x.current=setTimeout(()=>{y(!0)},o);const a=e=>{C(e)};try{const o="";if(i){const t=n.sendMessage(o);for await(const n of t)L(n,e,a)}else{const i=await n.sendMessage({embedId:t.embedId,message:o,sessionId:S??void 0});await A(i,e,a)}r&&h(t=>t.map(t=>t.id===e&&"streaming"===t.status?{...t,status:"sent"}:t))}catch(s){const t=s instanceof Error?s:new Error("Failed to send message");k(t),null==l||l(t),r&&h(t=>t.map(t=>t.id===e?{...t,status:"error",content:"Failed to get response"}:t))}finally{x.current&&(clearTimeout(x.current),x.current=null),y(!1),g(!1)}},[S,n,i,r,_,t.embedId,L,A,l]),F=u.useCallback(async()=>{if(!S)return;const e={sessionId:S,deploymentId:t.deploymentId,workerId:t.workerId,flowId:t.flowId,startTime:T.current,messages:d,toolCalls:p,status:"completed"};null==s||s(e),O(t.embedId),C(null),h([]),f([])},[S,t,d,p,s]),B=u.useCallback(()=>{h([]),f([])},[]);return{messages:d,toolCalls:p,isLoading:m,showTypingIndicator:v,error:b,sessionId:S,sendMessage:j,sendTriggerMessage:U,endSession:F,clearMessages:B,startNewSession:R}}const D="https://chat-embed-deployment.onrender.com";const L={embedId:"mock-embed-id",deploymentId:"mock-deployment-id",workerId:"mock-worker-id",flowId:"mock-flow-id",agentName:"AI Assistant",agentRole:"AI Agent",agentLogoUrl:void 0,primaryColor:"#1a1a2e",styling:{}},A=[{trigger:/hello|hi|hey/i,response:"Hello! I'm a demo AI assistant. How can I help you today?",delay:500},{trigger:/weather/i,response:"I'd check the weather for you, but I'm in mock mode! In production, I could use a weather API.",delay:800,toolCalls:[{name:"get_weather",arguments:{location:"San Francisco"},result:{temperature:72,condition:"sunny"}}]},{trigger:/help|support/i,response:"I'm here to help! You can ask me questions, and I'll do my best to assist you. In production, I'd be connected to your agent with full capabilities.",delay:600},{trigger:/pricing|cost|price/i,response:"For pricing information, I'd typically check our database or connect you with the sales team. This is a mock response demonstrating how I'd handle pricing questions.",delay:700,toolCalls:[{name:"lookup_pricing",arguments:{plan:"all"},result:{plans:[{name:"Starter",price:"$29/mo"},{name:"Pro",price:"$99/mo"}]}}]},{trigger:/.*/,response:"I'm running in mock mode. This is a simulated response to demonstrate the chat UI. In production, I'd be connected to your agent!",delay:1e3}];function j(e){return new Promise(t=>setTimeout(t,e))}const U=({className:e,color:t="currentColor",cutoutColor:n="var(--bb-primary-color)"})=>R.jsxs("svg",{className:e,viewBox:"0 0 800 800",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[R.jsx("path",{d:"M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",fill:t}),R.jsx("circle",{cx:"400",cy:"400",r:"400",fill:t}),R.jsx("path",{d:"M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",fill:t}),R.jsx("path",{d:"M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",fill:t}),R.jsx("circle",{cx:"400",cy:"400",r:"350",fill:t}),R.jsx("path",{d:"M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",fill:t}),R.jsx("rect",{x:"399.919",y:"209",width:"270",height:"270",rx:"12",transform:"rotate(45 399.919 209)",fill:n})]}),F="_header_f8qt7_1",B="_compact_f8qt7_9",z="_headerBackground_f8qt7_20",V="_headerContent_f8qt7_58",q="_topRow_f8qt7_63",H="_agentInfo_f8qt7_78",W="_agentLogo_f8qt7_84",K="_agentLogoPlaceholder_f8qt7_100",G="_brainbaseLogo_f8qt7_120",$="_backButton_f8qt7_135",J="_agentTextWrapper_f8qt7_165",Q="_agentName_f8qt7_171",Y="_headerSubtitle_f8qt7_179",X="_actions_f8qt7_187",Z="_actionButton_f8qt7_192",ee="_welcomeText_f8qt7_226",te="_title_f8qt7_245",ne="_subtitle_f8qt7_253",ie="_menuContainer_f8qt7_261",re="_dropdown_f8qt7_266",oe="_dropdownItem_f8qt7_290",ae="_dropdownIcon_f8qt7_327",se=({agentName:e="AI Assistant",agentLogoUrl:t,headerSubtitle:n,welcomeTitle:i,welcomeSubtitle:r,onClose:o,onBack:a,onNewChatRequest:s,onExpandWindow:c,onDownloadTranscript:l,showMenuButton:d=!1,isExpanded:h=!1,compact:p=!1})=>{const[f,m]=u.useState(!1),g=u.useRef(null);u.useEffect(()=>{const e=e=>{g.current&&!g.current.contains(e.target)&&m(!1)};return f&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[f]);const v=i||"Hello there.",y=void 0!==r?r:i?void 0:"How can we help?",b=e=>{e(),m(!1)};return R.jsxs("div",{className:`${F} ${p?B:""}`,children:[R.jsx("div",{className:z}),R.jsxs("div",{className:V,children:[R.jsxs("div",{className:q,children:[R.jsxs("div",{className:H,children:[R.jsx("button",{className:$,onClick:a,"aria-label":"Back",type:"button",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:R.jsx("path",{d:"M15 18L9 12L15 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),t?R.jsx("img",{src:t,alt:e,className:W}):R.jsx("div",{className:K,children:R.jsx(U,{className:G,color:"white",cutoutColor:"var(--bb-primary-color)"})}),R.jsxs("div",{className:J,children:[R.jsx("span",{className:Q,children:e}),n&&R.jsx("span",{className:Y,children:n})]})]}),R.jsxs("div",{className:X,children:[d&&R.jsxs("div",{className:ie,ref:g,children:[R.jsx("button",{className:Z,onClick:()=>m(!f),"aria-label":"Open menu","aria-expanded":f,type:"button",children:R.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[R.jsx("circle",{cx:"5",cy:"12",r:"2"}),R.jsx("circle",{cx:"12",cy:"12",r:"2"}),R.jsx("circle",{cx:"19",cy:"12",r:"2"})]})}),f&&R.jsxs("div",{className:re,children:[c&&R.jsx("button",{className:oe,onClick:()=>b(c),type:"button",children:h?R.jsxs(R.Fragment,{children:[R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:ae,children:R.jsx("path",{d:"M4 14H10V20M10 14L3 21M20 10H14V4M14 10L21 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),R.jsx("span",{children:"Minimize"})]}):R.jsxs(R.Fragment,{children:[R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:ae,children:R.jsx("path",{d:"M15 3H21V9M21 3L13 11M9 21H3V15M3 21L11 13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),R.jsx("span",{children:"Expand window"})]})}),l&&R.jsxs("button",{className:oe,onClick:()=>b(l),type:"button",children:[R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:ae,children:R.jsx("path",{d:"M21 15V19C21 20.1046 20.1046 21 19 21H5C3.89543 21 3 20.1046 3 19V15M7 10L12 15M12 15L17 10M12 15V3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),R.jsx("span",{children:"Download transcript"})]}),s&&R.jsxs("button",{className:oe,onClick:()=>b(s),type:"button",children:[R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:ae,children:R.jsx("path",{d:"M12 5V19M5 12H19",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),R.jsx("span",{children:"New chat"})]})]})]}),o&&R.jsx("button",{className:Z,onClick:o,"aria-label":"Close chat",type:"button",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:R.jsx("path",{d:"M6 18L18 6M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),!p&&R.jsxs("div",{className:ee,children:[R.jsx("h1",{className:te,children:v}),y&&R.jsx("p",{className:ne,children:y})]})]})]})};function ce(){}function le(){}const ue=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,de=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,he={};function pe(e,t){return(he.jsx?de:ue).test(e)}const fe=/[ \t\n\f\r]/g;function me(e){return""===e.replace(fe,"")}class ge{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function ve(e,t){const n={},i={};for(const r of e)Object.assign(n,r.property),Object.assign(i,r.normal);return new ge(n,i,t)}function ye(e){return e.toLowerCase()}ge.prototype.normal={},ge.prototype.property={},ge.prototype.space=void 0;class be{constructor(e,t){this.attribute=t,this.property=e}}be.prototype.attribute="",be.prototype.booleanish=!1,be.prototype.boolean=!1,be.prototype.commaOrSpaceSeparated=!1,be.prototype.commaSeparated=!1,be.prototype.defined=!1,be.prototype.mustUseProperty=!1,be.prototype.number=!1,be.prototype.overloadedBoolean=!1,be.prototype.property="",be.prototype.spaceSeparated=!1,be.prototype.space=void 0;let ke=0;const Se=_e(),Ce=_e(),Te=_e(),we=_e(),Ee=_e(),xe=_e(),Pe=_e();function _e(){return 2**++ke}const Re=Object.freeze(Object.defineProperty({__proto__:null,boolean:Se,booleanish:Ce,commaOrSpaceSeparated:Pe,commaSeparated:xe,number:we,overloadedBoolean:Te,spaceSeparated:Ee},Symbol.toStringTag,{value:"Module"})),Ie=Object.keys(Re);class Ne extends be{constructor(e,t,n,i){let r=-1;if(super(e,t),Oe(this,"space",i),"number"==typeof n)for(;++r<Ie.length;){const e=Ie[r];Oe(this,Ie[r],(n&Re[e])===Re[e])}}}function Oe(e,t,n){n&&(e[t]=n)}function Me(e){const t={},n={};for(const[i,r]of Object.entries(e.properties)){const o=new Ne(i,e.transform(e.attributes||{},i),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),t[i]=o,n[ye(i)]=i,n[ye(o.attribute)]=i}return new ge(t,n,e.space)}Ne.prototype.defined=!0;const De=Me({properties:{ariaActiveDescendant:null,ariaAtomic:Ce,ariaAutoComplete:null,ariaBusy:Ce,ariaChecked:Ce,ariaColCount:we,ariaColIndex:we,ariaColSpan:we,ariaControls:Ee,ariaCurrent:null,ariaDescribedBy:Ee,ariaDetails:null,ariaDisabled:Ce,ariaDropEffect:Ee,ariaErrorMessage:null,ariaExpanded:Ce,ariaFlowTo:Ee,ariaGrabbed:Ce,ariaHasPopup:null,ariaHidden:Ce,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Ee,ariaLevel:we,ariaLive:null,ariaModal:Ce,ariaMultiLine:Ce,ariaMultiSelectable:Ce,ariaOrientation:null,ariaOwns:Ee,ariaPlaceholder:null,ariaPosInSet:we,ariaPressed:Ce,ariaReadOnly:Ce,ariaRelevant:null,ariaRequired:Ce,ariaRoleDescription:Ee,ariaRowCount:we,ariaRowIndex:we,ariaRowSpan:we,ariaSelected:Ce,ariaSetSize:we,ariaSort:null,ariaValueMax:we,ariaValueMin:we,ariaValueNow:we,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function Le(e,t){return t in e?e[t]:t}function Ae(e,t){return Le(e,t.toLowerCase())}const je=Me({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:xe,acceptCharset:Ee,accessKey:Ee,action:null,allow:null,allowFullScreen:Se,allowPaymentRequest:Se,allowUserMedia:Se,alt:null,as:null,async:Se,autoCapitalize:null,autoComplete:Ee,autoFocus:Se,autoPlay:Se,blocking:Ee,capture:null,charSet:null,checked:Se,cite:null,className:Ee,cols:we,colSpan:null,content:null,contentEditable:Ce,controls:Se,controlsList:Ee,coords:we|xe,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Se,defer:Se,dir:null,dirName:null,disabled:Se,download:Te,draggable:Ce,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Se,formTarget:null,headers:Ee,height:we,hidden:Te,high:we,href:null,hrefLang:null,htmlFor:Ee,httpEquiv:Ee,id:null,imageSizes:null,imageSrcSet:null,inert:Se,inputMode:null,integrity:null,is:null,isMap:Se,itemId:null,itemProp:Ee,itemRef:Ee,itemScope:Se,itemType:Ee,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Se,low:we,manifest:null,max:null,maxLength:we,media:null,method:null,min:null,minLength:we,multiple:Se,muted:Se,name:null,nonce:null,noModule:Se,noValidate:Se,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Se,optimum:we,pattern:null,ping:Ee,placeholder:null,playsInline:Se,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Se,referrerPolicy:null,rel:Ee,required:Se,reversed:Se,rows:we,rowSpan:we,sandbox:Ee,scope:null,scoped:Se,seamless:Se,selected:Se,shadowRootClonable:Se,shadowRootDelegatesFocus:Se,shadowRootMode:null,shape:null,size:we,sizes:null,slot:null,span:we,spellCheck:Ce,src:null,srcDoc:null,srcLang:null,srcSet:null,start:we,step:null,style:null,tabIndex:we,target:null,title:null,translate:null,type:null,typeMustMatch:Se,useMap:null,value:Ce,width:we,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Ee,axis:null,background:null,bgColor:null,border:we,borderColor:null,bottomMargin:we,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Se,declare:Se,event:null,face:null,frame:null,frameBorder:null,hSpace:we,leftMargin:we,link:null,longDesc:null,lowSrc:null,marginHeight:we,marginWidth:we,noResize:Se,noHref:Se,noShade:Se,noWrap:Se,object:null,profile:null,prompt:null,rev:null,rightMargin:we,rules:null,scheme:null,scrolling:Ce,standby:null,summary:null,text:null,topMargin:we,valueType:null,version:null,vAlign:null,vLink:null,vSpace:we,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Se,disableRemotePlayback:Se,prefix:null,property:null,results:we,security:null,unselectable:null},space:"html",transform:Ae}),Ue=Me({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Pe,accentHeight:we,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:we,amplitude:we,arabicForm:null,ascent:we,attributeName:null,attributeType:null,azimuth:we,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:we,by:null,calcMode:null,capHeight:we,className:Ee,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:we,diffuseConstant:we,direction:null,display:null,dur:null,divisor:we,dominantBaseline:null,download:Se,dx:null,dy:null,edgeMode:null,editable:null,elevation:we,enableBackground:null,end:null,event:null,exponent:we,externalResourcesRequired:null,fill:null,fillOpacity:we,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:xe,g2:xe,glyphName:xe,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:we,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:we,horizOriginX:we,horizOriginY:we,id:null,ideographic:we,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:we,k:we,k1:we,k2:we,k3:we,k4:we,kernelMatrix:Pe,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:we,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:we,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:we,overlineThickness:we,paintOrder:null,panose1:null,path:null,pathLength:we,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Ee,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:we,pointsAtY:we,pointsAtZ:we,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Pe,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Pe,rev:Pe,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Pe,requiredFeatures:Pe,requiredFonts:Pe,requiredFormats:Pe,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:we,specularExponent:we,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:we,strikethroughThickness:we,string:null,stroke:null,strokeDashArray:Pe,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:we,strokeOpacity:we,strokeWidth:null,style:null,surfaceScale:we,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Pe,tabIndex:we,tableValues:null,target:null,targetX:we,targetY:we,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Pe,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:we,underlineThickness:we,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:we,values:null,vAlphabetic:we,vMathematical:we,vectorEffect:null,vHanging:we,vIdeographic:we,version:null,vertAdvY:we,vertOriginX:we,vertOriginY:we,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:we,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Le}),Fe=Me({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),Be=Me({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ae}),ze=Me({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),Ve={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},qe=/[A-Z]/g,He=/-[a-z]/g,We=/^data[-\w.:]+$/i;function Ke(e){return"-"+e.toLowerCase()}function Ge(e){return e.charAt(1).toUpperCase()}const $e=ve([De,je,Fe,Be,ze],"html"),Je=ve([De,Ue,Fe,Be,ze],"svg");var Qe,Ye,Xe,Ze={};function et(){if(Xe)return Ze;Xe=1;var e=Ze&&Ze.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.default=function(e,n){let i=null;if(!e||"string"!=typeof e)return i;const r=(0,t.default)(e),o="function"==typeof n;return r.forEach(e=>{if("declaration"!==e.type)return;const{property:t,value:r}=e;o?n(t,r,e):r&&(i=i||{},i[t]=r)}),i};const t=e(function(){if(Ye)return Qe;Ye=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,r=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,s=/^\s+|\s+$/g,c="";function l(e){return e?e.replace(s,c):c}return Qe=function(s,u){if("string"!=typeof s)throw new TypeError("First argument must be a string");if(!s)return[];u=u||{};var d=1,h=1;function p(e){var n=e.match(t);n&&(d+=n.length);var i=e.lastIndexOf("\n");h=~i?e.length-i:h+e.length}function f(){var e={line:d,column:h};return function(t){return t.position=new m(e),y(),t}}function m(e){this.start=e,this.end={line:d,column:h},this.source=u.source}function g(e){var t=new Error(u.source+":"+d+":"+h+": "+e);if(t.reason=e,t.filename=u.source,t.line=d,t.column=h,t.source=s,!u.silent)throw t}function v(e){var t=e.exec(s);if(t){var n=t[0];return p(n),s=s.slice(n.length),t}}function y(){v(n)}function b(e){var t;for(e=e||[];t=k();)!1!==t&&e.push(t);return e}function k(){var e=f();if("/"==s.charAt(0)&&"*"==s.charAt(1)){for(var t=2;c!=s.charAt(t)&&("*"!=s.charAt(t)||"/"!=s.charAt(t+1));)++t;if(t+=2,c===s.charAt(t-1))return g("End of comment missing");var n=s.slice(2,t-2);return h+=2,p(n),s=s.slice(t),h+=2,e({type:"comment",comment:n})}}function S(){var t=f(),n=v(i);if(n){if(k(),!v(r))return g("property missing ':'");var s=v(o),u=t({type:"declaration",property:l(n[0].replace(e,c)),value:s?l(s[0].replace(e,c)):c});return v(a),u}}return m.prototype.content=s,y(),function(){var e,t=[];for(b(t);e=S();)!1!==e&&(t.push(e),b(t));return t}()}}());return Ze}var tt,nt,it,rt={};function ot(){if(tt)return rt;tt=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,r=/^-(ms)-/,o=function(e,t){return t.toUpperCase()},a=function(e,t){return"".concat(t,"-")};return rt.camelCase=function(s,c){return void 0===c&&(c={}),function(t){return!t||n.test(t)||e.test(t)}(s)?s:(s=s.toLowerCase(),(s=c.reactCompat?s.replace(r,a):s.replace(i,a)).replace(t,o))},rt}const at=i(function(){if(it)return nt;it=1;var e=(nt&&nt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(et()),t=ot();function n(n,i){var r={};return n&&"string"==typeof n?((0,e.default)(n,function(e,n){e&&n&&(r[(0,t.camelCase)(e,i)]=n)}),r):r}return n.default=n,nt=n}()),st=lt("end"),ct=lt("start");function lt(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function ut(e){return e&&"object"==typeof e?"position"in e||"type"in e?ht(e.position):"start"in e||"end"in e?ht(e):"line"in e||"column"in e?dt(e):"":""}function dt(e){return pt(e&&e.line)+":"+pt(e&&e.column)}function ht(e){return dt(e&&e.start)+"-"+dt(e&&e.end)}function pt(e){return e&&"number"==typeof e?e:1}class ft extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let i="",r={},o=!1;if(t&&(r="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?i=e:!r.cause&&e&&(o=!0,i=e.message,r.cause=e),!r.ruleId&&!r.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?r.ruleId=n:(r.source=n.slice(0,e),r.ruleId=n.slice(e+1))}if(!r.place&&r.ancestors&&r.ancestors){const e=r.ancestors[r.ancestors.length-1];e&&(r.place=e.position)}const a=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=ut(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=o&&r.cause&&"string"==typeof r.cause.stack?r.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}ft.prototype.file="",ft.prototype.name="",ft.prototype.reason="",ft.prototype.message="",ft.prototype.stack="",ft.prototype.column=void 0,ft.prototype.line=void 0,ft.prototype.ancestors=void 0,ft.prototype.cause=void 0,ft.prototype.fatal=void 0,ft.prototype.place=void 0,ft.prototype.ruleId=void 0,ft.prototype.source=void 0;const mt={}.hasOwnProperty,gt=new Map,vt=/[A-Z]/g,yt=new Set(["table","tbody","thead","tfoot","tr"]),bt=new Set(["td","th"]),kt="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function St(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let i;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=function(e,t){return n;function n(n,i,r,o){const a=Array.isArray(r.children),s=ct(n);return t(i,r,o,a,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");i=function(e,t,n){return i;function i(e,i,r,o){const a=Array.isArray(r.children)?n:t;return o?a(i,r,o):a(i,r)}}(0,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:i,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?Je:$e,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},o=Ct(r,e,void 0);return o&&"string"!=typeof o?o:r.create(e,r.Fragment,{children:o||void 0},void 0)}function Ct(e,t,n){return"element"===t.type?function(e,t,n){const i=e.schema;let r=i;"svg"===t.tagName.toLowerCase()&&"html"===i.space&&(r=Je,e.schema=r);e.ancestors.push(t);const o=Pt(e,t.tagName,!1),a=function(e,t){const n={};let i,r;for(r in t.properties)if("children"!==r&&mt.call(t.properties,r)){const o=xt(e,r,t.properties[r]);if(o){const[r,a]=o;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof a&&bt.has(t.tagName)?i=a:n[r]=a}}if(i){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=i}return n}(e,t);let s=Et(e,t);yt.has(t.tagName)&&(s=s.filter(function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&me(t.value):me(t));var t}));return Tt(e,a,o,t),wt(a,s),e.ancestors.pop(),e.schema=i,e.create(t,o,a,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}_t(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const i=e.schema;let r=i;"svg"===t.name&&"html"===i.space&&(r=Je,e.schema=r);e.ancestors.push(t);const o=null===t.name?e.Fragment:Pt(e,t.name,!0),a=function(e,t){const n={};for(const i of t.attributes)if("mdxJsxExpressionAttribute"===i.type)if(i.data&&i.data.estree&&e.evaluater){const t=i.data.estree.body[0];ce(t.type);const r=t.expression;ce(r.type);const o=r.properties[0];ce(o.type),Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else _t(e,t.position);else{const r=i.name;let o;if(i.value&&"object"==typeof i.value)if(i.value.data&&i.value.data.estree&&e.evaluater){const t=i.value.data.estree.body[0];ce(t.type),o=e.evaluater.evaluateExpression(t.expression)}else _t(e,t.position);else o=null===i.value||i.value;n[r]=o}return n}(e,t),s=Et(e,t);return Tt(e,a,o,t),wt(a,s),e.ancestors.pop(),e.schema=i,e.create(t,o,a,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);_t(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const i={};return wt(i,Et(e,t)),e.create(t,e.Fragment,i,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function Tt(e,t,n,i){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=i)}function wt(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Et(e,t){const n=[];let i=-1;const r=e.passKeys?new Map:gt;for(;++i<t.children.length;){const o=t.children[i];let a;if(e.passKeys){const e="element"===o.type?o.tagName:"mdxJsxFlowElement"===o.type||"mdxJsxTextElement"===o.type?o.name:void 0;if(e){const t=r.get(e)||0;a=e+"-"+t,r.set(e,t+1)}}const s=Ct(e,o,a);void 0!==s&&n.push(s)}return n}function xt(e,t,n){const i=function(e,t){const n=ye(t);let i=t,r=be;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&We.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(He,Ge);i="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!He.test(e)){let n=e.replace(qe,Ke);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}r=Ne}return new r(i,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=i.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===i.property){let t="object"==typeof n?n:function(e,t){try{return at(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,i=new ft("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=kt+"#cannot-parse-style-attribute",i}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)mt.call(e,n)&&(t[Rt(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&i.space?Ve[i.property]||i.property:i.attribute,n]}}function Pt(e,t,n){let i;if(n)if(t.includes(".")){const e=t.split(".");let n,r=-1;for(;++r<e.length;){const t=pe(e[r])?{type:"Identifier",name:e[r]}:{type:"Literal",value:e[r]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(r&&"Literal"===t.type),optional:!1}:t}i=n}else i=pe(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else i={type:"Literal",value:t};if("Literal"===i.type){const t=i.value;return mt.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(i);_t(e)}function _t(e,t){const n=new ft("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=kt+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Rt(e){let t=e.replace(vt,It);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function It(e){return"-"+e.toLowerCase()}const Nt={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Ot={};function Mt(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Dt(e.children,t,n)}return Array.isArray(e)?Dt(e,t,n):""}function Dt(e,t,n){const i=[];let r=-1;for(;++r<e.length;)i[r]=Mt(e[r],t,n);return i.join("")}const Lt=document.createElement("i");function At(e){const t="&"+e+";";Lt.innerHTML=t;const n=Lt.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function jt(e,t,n,i){const r=e.length;let o,a=0;if(t=t<0?-t>r?0:r+t:t>r?r:t,n=n>0?n:0,i.length<1e4)o=Array.from(i),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<i.length;)o=i.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Ut(e,t){return e.length>0?(jt(e,e.length,0,t),e):t}const Ft={}.hasOwnProperty;function Bt(e,t){let n;for(n in t){const i=(Ft.call(e,n)?e[n]:void 0)||(e[n]={}),r=t[n];let o;if(r)for(o in r){Ft.call(i,o)||(i[o]=[]);const e=r[o];zt(i[o],Array.isArray(e)?e:e?[e]:[])}}}function zt(e,t){let n=-1;const i=[];for(;++n<t.length;)("after"===t[n].add?e:i).push(t[n]);jt(e,0,0,i)}function Vt(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function qt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ht=nn(/[A-Za-z]/),Wt=nn(/[\dA-Za-z]/),Kt=nn(/[#-'*+\--9=?A-Z^-~]/);function Gt(e){return null!==e&&(e<32||127===e)}const $t=nn(/\d/),Jt=nn(/[\dA-Fa-f]/),Qt=nn(/[!-/:-@[-`{-~]/);function Yt(e){return null!==e&&e<-2}function Xt(e){return null!==e&&(e<0||32===e)}function Zt(e){return-2===e||-1===e||32===e}const en=nn(new RegExp("\\p{P}|\\p{S}","u")),tn=nn(/\s/);function nn(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function rn(e){const t=[];let n=-1,i=0,r=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(37===o&&Wt(e.charCodeAt(n+1))&&Wt(e.charCodeAt(n+2)))r=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(a=String.fromCharCode(o,t),r=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(i,n),encodeURIComponent(a)),i=n+r+1,a=""),r&&(n+=r,r=0)}return t.join("")+e.slice(i)}function on(e,t,n,i){const r=i?i-1:Number.POSITIVE_INFINITY;let o=0;return function(i){if(Zt(i))return e.enter(n),a(i);return t(i)};function a(i){return Zt(i)&&o++<r?(e.consume(i),a):(e.exit(n),t(i))}}const an={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),on(e,t,"linePrefix")},function(t){return e.enter("paragraph"),i(t)});let n;return t;function i(t){const i=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=i),n=i,r(t)}function r(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):Yt(t)?(e.consume(t),e.exit("chunkText"),i):(e.consume(t),r)}}};const sn={tokenize:function(e){const t=this,n=[];let i,r,o,a=0;return s;function s(i){if(a<n.length){const r=n[a];return t.containerState=r[1],e.attempt(r[0].continuation,c,l)(i)}return l(i)}function c(e){if(a++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&y();const n=t.events.length;let r,o=n;for(;o--;)if("exit"===t.events[o][0]&&"chunkFlow"===t.events[o][1].type){r=t.events[o][1].end;break}v(a);let s=n;for(;s<t.events.length;)t.events[s][1].end={...r},s++;return jt(t.events,o+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(r){if(a===n.length){if(!i)return h(r);if(i.currentConstruct&&i.currentConstruct.concrete)return f(r);t.interrupt=Boolean(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(cn,u,d)(r)}function u(e){return i&&y(),v(a),h(e)}function d(e){return t.parser.lazy[t.now().line]=a!==n.length,o=t.now().offset,f(e)}function h(n){return t.containerState={},e.attempt(cn,p,f)(n)}function p(e){return a++,n.push([t.currentConstruct,t.containerState]),h(e)}function f(n){return null===n?(i&&y(),v(0),void e.consume(n)):(i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:r}),m(n))}function m(n){return null===n?(g(e.exit("chunkFlow"),!0),v(0),void e.consume(n)):Yt(n)?(e.consume(n),g(e.exit("chunkFlow")),a=0,t.interrupt=void 0,s):(e.consume(n),m)}function g(e,n){const s=t.sliceStream(e);if(n&&s.push(null),e.previous=r,r&&(r.next=e),r=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;const n=t.events.length;let r,s,c=n;for(;c--;)if("exit"===t.events[c][0]&&"chunkFlow"===t.events[c][1].type){if(r){s=t.events[c][1].end;break}r=!0}for(v(a),e=n;e<t.events.length;)t.events[e][1].end={...s},e++;jt(t.events,c+1,0,t.events.slice(n)),t.events.length=e}}function v(i){let r=n.length;for(;r-- >i;){const i=n[r];t.containerState=i[1],i[0].exit.call(t,e)}n.length=i}function y(){i.write([null]),r=void 0,i=void 0,t.containerState._closeFlow=void 0}}},cn={tokenize:function(e,t,n){return on(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function ln(e){return null===e||Xt(e)||tn(e)?1:en(e)?2:void 0}function un(e,t,n){const i=[];let r=-1;for(;++r<e.length;){const o=e[r].resolveAll;o&&!i.includes(o)&&(t=o(t,n),i.push(o))}return t}const dn={name:"attention",resolveAll:function(e,t){let n,i,r,o,a,s,c,l,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close)for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;s=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const d={...e[n][1].end},h={...e[u][1].start};hn(d,-s),hn(h,s),o={type:s>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},a={type:s>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},r={type:s>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[u][1].start}},i={type:s>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[n][1].end={...o.start},e[u][1].start={...a.end},c=[],e[n][1].end.offset-e[n][1].start.offset&&(c=Ut(c,[["enter",e[n][1],t],["exit",e[n][1],t]])),c=Ut(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",r,t]]),c=Ut(c,un(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),c=Ut(c,[["exit",r,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[u][1].end.offset-e[u][1].start.offset?(l=2,c=Ut(c,[["enter",e[u][1],t],["exit",e[u][1],t]])):l=0,jt(e,n-1,u-n+3,c),u=n+c.length-l-2;break}u=-1;for(;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,i=this.previous,r=ln(i);let o;return function(t){return o=t,e.enter("attentionSequence"),a(t)};function a(s){if(s===o)return e.consume(s),a;const c=e.exit("attentionSequence"),l=ln(s),u=!l||2===l&&r||n.includes(s),d=!r||2===r&&l||n.includes(i);return c._open=Boolean(42===o?u:u&&(r||!d)),c._close=Boolean(42===o?d:d&&(l||!u)),t(s)}}};function hn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const pn={name:"autolink",tokenize:function(e,t,n){let i=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),r};function r(t){return Ht(t)?(e.consume(t),o):64===t?n(t):c(t)}function o(e){return 43===e||45===e||46===e||Wt(e)?(i=1,a(e)):c(e)}function a(t){return 58===t?(e.consume(t),i=0,s):(43===t||45===t||46===t||Wt(t))&&i++<32?(e.consume(t),a):(i=0,c(t))}function s(i){return 62===i?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(i),e.exit("autolinkMarker"),e.exit("autolink"),t):null===i||32===i||60===i||Gt(i)?n(i):(e.consume(i),s)}function c(t){return 64===t?(e.consume(t),l):Kt(t)?(e.consume(t),c):n(t)}function l(e){return Wt(e)?u(e):n(e)}function u(n){return 46===n?(e.consume(n),i=0,l):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):d(n)}function d(t){if((45===t||Wt(t))&&i++<63){const n=45===t?d:u;return e.consume(t),n}return n(t)}}};const fn={partial:!0,tokenize:function(e,t,n){return function(t){return Zt(t)?on(e,i,"linePrefix")(t):i(t)};function i(e){return null===e||Yt(e)?t(e):n(e)}}};const mn={continuation:{tokenize:function(e,t,n){const i=this;return function(t){if(Zt(t))return on(e,r,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return r(t)};function r(i){return e.attempt(mn,t,n)(i)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const i=this;return function(t){if(62===t){const n=i.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),r}return n(t)};function r(n){return Zt(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const gn={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),i};function i(i){return Qt(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}};const vn={name:"characterReference",tokenize:function(e,t,n){const i=this;let r,o,a=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s};function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),r=31,o=Wt,l(t))}function c(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,o=Jt,l):(e.enter("characterReferenceValue"),r=7,o=$t,l(t))}function l(s){if(59===s&&a){const r=e.exit("characterReferenceValue");return o!==Wt||At(i.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(s)}return o(s)&&a++<r?(e.consume(s),l):n(s)}}};const yn={partial:!0,tokenize:function(e,t,n){const i=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r};function r(e){return i.parser.lazy[i.now().line]?n(e):t(e)}}},bn={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const i=this,r={partial:!0,tokenize:function(e,t,n){let r=0;return a;function a(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),c}function c(t){return e.enter("codeFencedFence"),Zt(t)?on(e,l,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===o?(e.enter("codeFencedFenceSequence"),u(t)):n(t)}function u(t){return t===o?(r++,e.consume(t),u):r>=s?(e.exit("codeFencedFenceSequence"),Zt(t)?on(e,d,"whitespace")(t):d(t)):n(t)}function d(i){return null===i||Yt(i)?(e.exit("codeFencedFence"),t(i)):n(i)}}};let o,a=0,s=0;return function(t){return function(t){const n=i.events[i.events.length-1];return a=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,o=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(t)}(t)};function c(t){return t===o?(s++,e.consume(t),c):s<3?n(t):(e.exit("codeFencedFenceSequence"),Zt(t)?on(e,l,"whitespace")(t):l(t))}function l(n){return null===n||Yt(n)?(e.exit("codeFencedFence"),i.interrupt?t(n):e.check(yn,p,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(n))}function u(t){return null===t||Yt(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),l(t)):Zt(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),on(e,d,"whitespace")(t)):96===t&&t===o?n(t):(e.consume(t),u)}function d(t){return null===t||Yt(t)?l(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||Yt(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),l(t)):96===t&&t===o?n(t):(e.consume(t),h)}function p(t){return e.attempt(r,y,f)(t)}function f(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),m}function m(t){return a>0&&Zt(t)?on(e,g,"linePrefix",a+1)(t):g(t)}function g(t){return null===t||Yt(t)?e.check(yn,p,y)(t):(e.enter("codeFlowValue"),v(t))}function v(t){return null===t||Yt(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),v)}function y(n){return e.exit("codeFenced"),t(n)}}};const kn={name:"codeIndented",tokenize:function(e,t,n){const i=this;return function(t){return e.enter("codeIndented"),on(e,r,"linePrefix",5)(t)};function r(e){const t=i.events[i.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return null===t?s(t):Yt(t)?e.attempt(Sn,o,s)(t):(e.enter("codeFlowValue"),a(t))}function a(t){return null===t||Yt(t)?(e.exit("codeFlowValue"),o(t)):(e.consume(t),a)}function s(n){return e.exit("codeIndented"),t(n)}}},Sn={partial:!0,tokenize:function(e,t,n){const i=this;return r;function r(t){return i.parser.lazy[i.now().line]?n(t):Yt(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r):on(e,o,"linePrefix",5)(t)}function o(e){const o=i.events[i.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):Yt(e)?r(e):n(e)}}};const Cn={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,i=e.length-4,r=3;if(!("lineEnding"!==e[r][1].type&&"space"!==e[r][1].type||"lineEnding"!==e[i][1].type&&"space"!==e[i][1].type))for(t=r;++t<i;)if("codeTextData"===e[t][1].type){e[r][1].type="codeTextPadding",e[i][1].type="codeTextPadding",r+=2,i-=2;break}t=r-1,i++;for(;++t<=i;)void 0===n?t!==i&&"lineEnding"!==e[t][1].type&&(n=t):t!==i&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),i-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let i,r,o=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),a(t)};function a(t){return 96===t?(e.consume(t),o++,a):(e.exit("codeTextSequence"),s(t))}function s(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),s):96===t?(r=e.enter("codeTextSequence"),i=0,l(t)):Yt(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):(e.enter("codeTextData"),c(t))}function c(t){return null===t||32===t||96===t||Yt(t)?(e.exit("codeTextData"),s(t)):(e.consume(t),c)}function l(n){return 96===n?(e.consume(n),i++,l):i===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(r.type="codeTextData",c(n))}}};class Tn{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const i=t||0;this.setCursor(Math.trunc(e));const r=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return n&&wn(this.left,n),r.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),wn(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),wn(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);wn(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);wn(this.left,t.reverse())}}}function wn(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function En(e){const t={};let n,i,r,o,a,s,c,l=-1;const u=new Tn(e);for(;++l<u.length;){for(;l in t;)l=t[l];if(n=u.get(l),l&&"chunkFlow"===n[1].type&&"listItemPrefix"===u.get(l-1)[1].type&&(s=n[1]._tokenizer.events,r=0,r<s.length&&"lineEndingBlank"===s[r][1].type&&(r+=2),r<s.length&&"content"===s[r][1].type))for(;++r<s.length&&"content"!==s[r][1].type;)"chunkText"===s[r][1].type&&(s[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,xn(u,l)),l=t[l],c=!0);else if(n[1]._container){for(r=l,i=void 0;r--;)if(o=u.get(r),"lineEnding"===o[1].type||"lineEndingBlank"===o[1].type)"enter"===o[0]&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=r);else if("linePrefix"!==o[1].type&&"listItemIndent"!==o[1].type)break;i&&(n[1].end={...u.get(i)[1].start},a=u.slice(i,l),a.unshift(n),u.splice(i,l-i+1,a))}}return jt(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function xn(e,t){const n=e.get(t)[1],i=e.get(t)[2];let r=t-1;const o=[];let a=n._tokenizer;a||(a=i.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const s=a.events,c=[],l={};let u,d,h=-1,p=n,f=0,m=0;const g=[m];for(;p;){for(;e.get(++r)[1]!==p;);o.push(r),p._tokenizer||(u=i.sliceStream(p),p.next||u.push(null),d&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(u),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++h<s.length;)"exit"===s[h][0]&&"enter"===s[h-1][0]&&s[h][1].type===s[h-1][1].type&&s[h][1].start.line!==s[h][1].end.line&&(m=h+1,g.push(m),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),h=g.length;h--;){const t=s.slice(g[h],g[h+1]),n=o.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),h=-1;++h<c.length;)l[f+c[h][0]]=f+c[h][1],f+=c[h][1]-c[h][0]-1;return l}const Pn={resolve:function(e){return En(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(t)};function i(t){return null===t?r(t):Yt(t)?e.check(_n,o,r)(t):(e.consume(t),i)}function r(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function o(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}},_n={partial:!0,tokenize:function(e,t,n){const i=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),on(e,r,"linePrefix")};function r(r){if(null===r||Yt(r))return n(r);const o=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(r):e.interrupt(i.parser.constructs.flow,n,t)(r)}}};function Rn(e,t,n,i,r,o,a,s,c){const l=c||Number.POSITIVE_INFINITY;let u=0;return function(t){if(60===t)return e.enter(i),e.enter(r),e.enter(o),e.consume(t),e.exit(o),d;if(null===t||32===t||41===t||Gt(t))return n(t);return e.enter(i),e.enter(a),e.enter(s),e.enter("chunkString",{contentType:"string"}),f(t)};function d(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(r),e.exit(i),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(s),d(t)):null===t||60===t||Yt(t)?n(t):(e.consume(t),92===t?p:h)}function p(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function f(r){return u||null!==r&&41!==r&&!Xt(r)?u<l&&40===r?(e.consume(r),u++,f):41===r?(e.consume(r),u--,f):null===r||32===r||40===r||Gt(r)?n(r):(e.consume(r),92===r?m:f):(e.exit("chunkString"),e.exit(s),e.exit(a),e.exit(i),t(r))}function m(t){return 40===t||41===t||92===t?(e.consume(t),f):f(t)}}function In(e,t,n,i,r,o){const a=this;let s,c=0;return function(t){return e.enter(i),e.enter(r),e.consume(t),e.exit(r),e.enter(o),l};function l(d){return c>999||null===d||91===d||93===d&&!s||94===d&&!c&&"_hiddenFootnoteSupport"in a.parser.constructs?n(d):93===d?(e.exit(o),e.enter(r),e.consume(d),e.exit(r),e.exit(i),t):Yt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||Yt(t)||c++>999?(e.exit("chunkString"),l(t)):(e.consume(t),s||(s=!Zt(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),c++,u):u(t)}}function Nn(e,t,n,i,r,o){let a;return function(t){if(34===t||39===t||40===t)return e.enter(i),e.enter(r),e.consume(t),e.exit(r),a=40===t?41:t,s;return n(t)};function s(n){return n===a?(e.enter(r),e.consume(n),e.exit(r),e.exit(i),t):(e.enter(o),c(n))}function c(t){return t===a?(e.exit(o),s(a)):null===t?n(t):Yt(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),on(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),l(t))}function l(t){return t===a||null===t||Yt(t)?(e.exit("chunkString"),c(t)):(e.consume(t),92===t?u:l)}function u(t){return t===a||92===t?(e.consume(t),l):l(t)}}function On(e,t){let n;return function i(r){if(Yt(r))return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,i;if(Zt(r))return on(e,i,n?"linePrefix":"lineSuffix")(r);return t(r)}}const Mn={name:"definition",tokenize:function(e,t,n){const i=this;let r;return function(t){return e.enter("definition"),function(t){return In.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function o(t){return r=qt(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a):n(t)}function a(t){return Xt(t)?On(e,s)(t):s(t)}function s(t){return Rn(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function c(t){return e.attempt(Dn,l,l)(t)}function l(t){return Zt(t)?on(e,u,"whitespace")(t):u(t)}function u(o){return null===o||Yt(o)?(e.exit("definition"),i.parser.defined.push(r),t(o)):n(o)}}},Dn={partial:!0,tokenize:function(e,t,n){return function(t){return Xt(t)?On(e,i)(t):n(t)};function i(t){return Nn(e,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function r(t){return Zt(t)?on(e,o,"whitespace")(t):o(t)}function o(e){return null===e||Yt(e)?t(e):n(e)}}};const Ln={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),i};function i(i){return Yt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}};const An={name:"headingAtx",resolve:function(e,t){let n,i,r=e.length-2,o=3;"whitespace"===e[o][1].type&&(o+=2);r-2>o&&"whitespace"===e[r][1].type&&(r-=2);"atxHeadingSequence"===e[r][1].type&&(o===r-1||r-4>o&&"whitespace"===e[r-2][1].type)&&(r-=o+1===r?2:4);r>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[r][1].end},i={type:"chunkText",start:e[o][1].start,end:e[r][1].end,contentType:"text"},jt(e,o,r-o+1,[["enter",n,t],["enter",i,t],["exit",i,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let i=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),r(t)}(t)};function r(t){return 35===t&&i++<6?(e.consume(t),r):null===t||Xt(t)?(e.exit("atxHeadingSequence"),o(t)):n(t)}function o(n){return 35===n?(e.enter("atxHeadingSequence"),a(n)):null===n||Yt(n)?(e.exit("atxHeading"),t(n)):Zt(n)?on(e,o,"whitespace")(n):(e.enter("atxHeadingText"),s(n))}function a(t){return 35===t?(e.consume(t),a):(e.exit("atxHeadingSequence"),o(t))}function s(t){return null===t||35===t||Xt(t)?(e.exit("atxHeadingText"),o(t)):(e.consume(t),s)}}};const jn=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Un=["pre","script","style","textarea"],Fn={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const i=this;let r,o,a,s,c;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),l}(t)};function l(s){return 33===s?(e.consume(s),u):47===s?(e.consume(s),o=!0,p):63===s?(e.consume(s),r=3,i.interrupt?t:D):Ht(s)?(e.consume(s),a=String.fromCharCode(s),f):n(s)}function u(o){return 45===o?(e.consume(o),r=2,d):91===o?(e.consume(o),r=5,s=0,h):Ht(o)?(e.consume(o),r=4,i.interrupt?t:D):n(o)}function d(r){return 45===r?(e.consume(r),i.interrupt?t:D):n(r)}function h(r){const o="CDATA[";return r===o.charCodeAt(s++)?(e.consume(r),6===s?i.interrupt?t:x:h):n(r)}function p(t){return Ht(t)?(e.consume(t),a=String.fromCharCode(t),f):n(t)}function f(s){if(null===s||47===s||62===s||Xt(s)){const c=47===s,l=a.toLowerCase();return c||o||!Un.includes(l)?jn.includes(a.toLowerCase())?(r=6,c?(e.consume(s),m):i.interrupt?t(s):x(s)):(r=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(s):o?g(s):v(s)):(r=1,i.interrupt?t(s):x(s))}return 45===s||Wt(s)?(e.consume(s),a+=String.fromCharCode(s),f):n(s)}function m(r){return 62===r?(e.consume(r),i.interrupt?t:x):n(r)}function g(t){return Zt(t)?(e.consume(t),g):w(t)}function v(t){return 47===t?(e.consume(t),w):58===t||95===t||Ht(t)?(e.consume(t),y):Zt(t)?(e.consume(t),v):w(t)}function y(t){return 45===t||46===t||58===t||95===t||Wt(t)?(e.consume(t),y):b(t)}function b(t){return 61===t?(e.consume(t),k):Zt(t)?(e.consume(t),b):v(t)}function k(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),c=t,S):Zt(t)?(e.consume(t),k):C(t)}function S(t){return t===c?(e.consume(t),c=null,T):null===t||Yt(t)?n(t):(e.consume(t),S)}function C(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||Xt(t)?b(t):(e.consume(t),C)}function T(e){return 47===e||62===e||Zt(e)?v(e):n(e)}function w(t){return 62===t?(e.consume(t),E):n(t)}function E(t){return null===t||Yt(t)?x(t):Zt(t)?(e.consume(t),E):n(t)}function x(t){return 45===t&&2===r?(e.consume(t),I):60===t&&1===r?(e.consume(t),N):62===t&&4===r?(e.consume(t),L):63===t&&3===r?(e.consume(t),D):93===t&&5===r?(e.consume(t),M):!Yt(t)||6!==r&&7!==r?null===t||Yt(t)?(e.exit("htmlFlowData"),P(t)):(e.consume(t),x):(e.exit("htmlFlowData"),e.check(Bn,A,P)(t))}function P(t){return e.check(zn,_,A)(t)}function _(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),R}function R(t){return null===t||Yt(t)?P(t):(e.enter("htmlFlowData"),x(t))}function I(t){return 45===t?(e.consume(t),D):x(t)}function N(t){return 47===t?(e.consume(t),a="",O):x(t)}function O(t){if(62===t){const n=a.toLowerCase();return Un.includes(n)?(e.consume(t),L):x(t)}return Ht(t)&&a.length<8?(e.consume(t),a+=String.fromCharCode(t),O):x(t)}function M(t){return 93===t?(e.consume(t),D):x(t)}function D(t){return 62===t?(e.consume(t),L):45===t&&2===r?(e.consume(t),D):x(t)}function L(t){return null===t||Yt(t)?(e.exit("htmlFlowData"),A(t)):(e.consume(t),L)}function A(n){return e.exit("htmlFlow"),t(n)}}},Bn={partial:!0,tokenize:function(e,t,n){return function(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(fn,t,n)}}},zn={partial:!0,tokenize:function(e,t,n){const i=this;return function(t){if(Yt(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r;return n(t)};function r(e){return i.parser.lazy[i.now().line]?n(e):t(e)}}};const Vn={name:"htmlText",tokenize:function(e,t,n){const i=this;let r,o,a;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s};function s(t){return 33===t?(e.consume(t),c):47===t?(e.consume(t),k):63===t?(e.consume(t),y):Ht(t)?(e.consume(t),T):n(t)}function c(t){return 45===t?(e.consume(t),l):91===t?(e.consume(t),o=0,p):Ht(t)?(e.consume(t),v):n(t)}function l(t){return 45===t?(e.consume(t),h):n(t)}function u(t){return null===t?n(t):45===t?(e.consume(t),d):Yt(t)?(a=u,O(t)):(e.consume(t),u)}function d(t){return 45===t?(e.consume(t),h):u(t)}function h(e){return 62===e?N(e):45===e?d(e):u(e)}function p(t){const i="CDATA[";return t===i.charCodeAt(o++)?(e.consume(t),6===o?f:p):n(t)}function f(t){return null===t?n(t):93===t?(e.consume(t),m):Yt(t)?(a=f,O(t)):(e.consume(t),f)}function m(t){return 93===t?(e.consume(t),g):f(t)}function g(t){return 62===t?N(t):93===t?(e.consume(t),g):f(t)}function v(t){return null===t||62===t?N(t):Yt(t)?(a=v,O(t)):(e.consume(t),v)}function y(t){return null===t?n(t):63===t?(e.consume(t),b):Yt(t)?(a=y,O(t)):(e.consume(t),y)}function b(e){return 62===e?N(e):y(e)}function k(t){return Ht(t)?(e.consume(t),S):n(t)}function S(t){return 45===t||Wt(t)?(e.consume(t),S):C(t)}function C(t){return Yt(t)?(a=C,O(t)):Zt(t)?(e.consume(t),C):N(t)}function T(t){return 45===t||Wt(t)?(e.consume(t),T):47===t||62===t||Xt(t)?w(t):n(t)}function w(t){return 47===t?(e.consume(t),N):58===t||95===t||Ht(t)?(e.consume(t),E):Yt(t)?(a=w,O(t)):Zt(t)?(e.consume(t),w):N(t)}function E(t){return 45===t||46===t||58===t||95===t||Wt(t)?(e.consume(t),E):x(t)}function x(t){return 61===t?(e.consume(t),P):Yt(t)?(a=x,O(t)):Zt(t)?(e.consume(t),x):w(t)}function P(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,_):Yt(t)?(a=P,O(t)):Zt(t)?(e.consume(t),P):(e.consume(t),R)}function _(t){return t===r?(e.consume(t),r=void 0,I):null===t?n(t):Yt(t)?(a=_,O(t)):(e.consume(t),_)}function R(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Xt(t)?w(t):(e.consume(t),R)}function I(e){return 47===e||62===e||Xt(e)?w(e):n(e)}function N(i){return 62===i?(e.consume(i),e.exit("htmlTextData"),e.exit("htmlText"),t):n(i)}function O(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),M}function M(t){return Zt(t)?on(e,D,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):D(t)}function D(t){return e.enter("htmlTextData"),a(t)}}};const qn={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const i=e[t][1];if(n.push(e[t]),"labelImage"===i.type||"labelLink"===i.type||"labelEnd"===i.type){const e="labelImage"===i.type?4:2;i.type="data",t+=e}}e.length!==n.length&&jt(e,0,e.length,n);return e},resolveTo:function(e,t){let n,i,r,o,a=e.length,s=0;for(;a--;)if(n=e[a][1],i){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(r){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(i=a,"labelLink"!==n.type)){s=2;break}}else"labelEnd"===n.type&&(r=a);const c={type:"labelLink"===e[i][1].type?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},l={type:"label",start:{...e[i][1].start},end:{...e[r][1].end}},u={type:"labelText",start:{...e[i+s+2][1].end},end:{...e[r-2][1].start}};return o=[["enter",c,t],["enter",l,t]],o=Ut(o,e.slice(i+1,i+s+3)),o=Ut(o,[["enter",u,t]]),o=Ut(o,un(t.parser.constructs.insideSpan.null,e.slice(i+s+4,r-3),t)),o=Ut(o,[["exit",u,t],e[r-2],e[r-1],["exit",l,t]]),o=Ut(o,e.slice(r+1)),o=Ut(o,[["exit",c,t]]),jt(e,i,e.length,o),e},tokenize:function(e,t,n){const i=this;let r,o,a=i.events.length;for(;a--;)if(("labelImage"===i.events[a][1].type||"labelLink"===i.events[a][1].type)&&!i.events[a][1]._balanced){r=i.events[a][1];break}return function(t){if(!r)return n(t);if(r._inactive)return u(t);return o=i.parser.defined.includes(qt(i.sliceSerialize({start:r.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s};function s(t){return 40===t?e.attempt(Hn,l,o?l:u)(t):91===t?e.attempt(Wn,l,o?c:u)(t):o?l(t):u(t)}function c(t){return e.attempt(Kn,l,u)(t)}function l(e){return t(e)}function u(e){return r._balanced=!0,n(e)}}},Hn={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),i};function i(t){return Xt(t)?On(e,r)(t):r(t)}function r(t){return 41===t?l(t):Rn(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function o(t){return Xt(t)?On(e,s)(t):l(t)}function a(e){return n(e)}function s(t){return 34===t||39===t||40===t?Nn(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):l(t)}function c(t){return Xt(t)?On(e,l)(t):l(t)}function l(i){return 41===i?(e.enter("resourceMarker"),e.consume(i),e.exit("resourceMarker"),e.exit("resource"),t):n(i)}}},Wn={tokenize:function(e,t,n){const i=this;return function(t){return In.call(i,e,r,o,"reference","referenceMarker","referenceString")(t)};function r(e){return i.parser.defined.includes(qt(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}},Kn={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),i};function i(i){return 93===i?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}};const Gn={name:"labelStartImage",resolveAll:qn.resolveAll,tokenize:function(e,t,n){const i=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),r};function r(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),o):n(t)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in i.parser.constructs?n(e):t(e)}}};const $n={name:"labelStartLink",resolveAll:qn.resolveAll,tokenize:function(e,t,n){const i=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),r};function r(e){return 94===e&&"_hiddenFootnoteSupport"in i.parser.constructs?n(e):t(e)}}};const Jn={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),on(e,t,"linePrefix")}}};const Qn={name:"thematicBreak",tokenize:function(e,t,n){let i,r=0;return function(t){return e.enter("thematicBreak"),function(e){return i=e,o(e)}(t)};function o(o){return o===i?(e.enter("thematicBreakSequence"),a(o)):r>=3&&(null===o||Yt(o))?(e.exit("thematicBreak"),t(o)):n(o)}function a(t){return t===i?(e.consume(t),r++,a):(e.exit("thematicBreakSequence"),Zt(t)?on(e,o,"whitespace")(t):o(t))}}};const Yn={continuation:{tokenize:function(e,t,n){const i=this;return i.containerState._closeFlow=void 0,e.check(fn,function(n){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,on(e,t,"listItemIndent",i.containerState.size+1)(n)},function(n){if(i.containerState.furtherBlankLines||!Zt(n))return i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,r(n);return i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(Zn,t,r)(n)});function r(r){return i.containerState._closeFlow=!0,i.interrupt=void 0,on(e,e.attempt(Yn,t,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(r)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const i=this,r=i.events[i.events.length-1];let o=r&&"linePrefix"===r[1].type?r[2].sliceSerialize(r[1],!0).length:0,a=0;return function(t){const r=i.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===r?!i.containerState.marker||t===i.containerState.marker:$t(t)){if(i.containerState.type||(i.containerState.type=r,e.enter(r,{_container:!0})),"listUnordered"===r)return e.enter("listItemPrefix"),42===t||45===t?e.check(Qn,n,c)(t):c(t);if(!i.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),s(t)}return n(t)};function s(t){return $t(t)&&++a<10?(e.consume(t),s):(!i.interrupt||a<2)&&(i.containerState.marker?t===i.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),c(t)):n(t)}function c(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||t,e.check(fn,i.interrupt?n:l,e.attempt(Xn,d,u))}function l(e){return i.containerState.initialBlankLine=!0,o++,d(e)}function u(t){return Zt(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):n(t)}function d(n){return i.containerState.size=o+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Xn={partial:!0,tokenize:function(e,t,n){const i=this;return on(e,function(e){const r=i.events[i.events.length-1];return!Zt(e)&&r&&"listItemPrefixWhitespace"===r[1].type?t(e):n(e)},"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Zn={partial:!0,tokenize:function(e,t,n){const i=this;return on(e,function(e){const r=i.events[i.events.length-1];return r&&"listItemIndent"===r[1].type&&r[2].sliceSerialize(r[1],!0).length===i.containerState.size?t(e):n(e)},"listItemIndent",i.containerState.size+1)}};const ei={name:"setextUnderline",resolveTo:function(e,t){let n,i,r,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(i=o)}else"content"===e[o][1].type&&e.splice(o,1),r||"definition"!==e[o][1].type||(r=o);const a={type:"setextHeading",start:{...e[n][1].start},end:{...e[e.length-1][1].end}};e[i][1].type="setextHeadingText",r?(e.splice(i,0,["enter",a,t]),e.splice(r+1,0,["exit",e[n][1],t]),e[n][1].end={...e[r][1].end}):e[n][1]=a;return e.push(["exit",a,t]),e},tokenize:function(e,t,n){const i=this;let r;return function(t){let a,s=i.events.length;for(;s--;)if("lineEnding"!==i.events[s][1].type&&"linePrefix"!==i.events[s][1].type&&"content"!==i.events[s][1].type){a="paragraph"===i.events[s][1].type;break}if(!i.parser.lazy[i.now().line]&&(i.interrupt||a))return e.enter("setextHeadingLine"),r=t,function(t){return e.enter("setextHeadingLineSequence"),o(t)}(t);return n(t)};function o(t){return t===r?(e.consume(t),o):(e.exit("setextHeadingLineSequence"),Zt(t)?on(e,a,"lineSuffix")(t):a(t))}function a(i){return null===i||Yt(i)?(e.exit("setextHeadingLine"),t(i)):n(i)}}};const ti={tokenize:function(e){const t=this,n=e.attempt(fn,function(i){if(null===i)return void e.consume(i);return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n},e.attempt(this.parser.constructs.flowInitial,i,on(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Pn,i)),"linePrefix")));return n;function i(i){if(null!==i)return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(i)}}};const ni={resolveAll:ai()},ii=oi("string"),ri=oi("text");function oi(e){return{resolveAll:ai("text"===e?si:void 0),tokenize:function(t){const n=this,i=this.parser.constructs[e],r=t.attempt(i,o,a);return o;function o(e){return c(e)?r(e):a(e)}function a(e){if(null!==e)return t.enter("data"),t.consume(e),s;t.consume(e)}function s(e){return c(e)?(t.exit("data"),r(e)):(t.consume(e),s)}function c(e){if(null===e)return!0;const t=i[e];let r=-1;if(t)for(;++r<t.length;){const e=t[r];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function ai(e){return function(t,n){let i,r=-1;for(;++r<=t.length;)void 0===i?t[r]&&"data"===t[r][1].type&&(i=r,r++):t[r]&&"data"===t[r][1].type||(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function si(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const i=e[n-1][1],r=t.sliceStream(i);let o,a=r.length,s=-1,c=0;for(;a--;){const e=r[a];if("string"==typeof e){for(s=e.length;32===e.charCodeAt(s-1);)c++,s--;if(s)break;s=-1}else if(-2===e)o=!0,c++;else if(-1!==e){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const r={type:n===e.length||o||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?s:i.start._bufferIndex+s,_index:i.start._index+a,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...r.start},i.start.offset===i.end.offset?Object.assign(i,r):(e.splice(n,0,["enter",r,t],["exit",r,t]),n+=2)}n++}return e}const ci={42:Yn,43:Yn,45:Yn,48:Yn,49:Yn,50:Yn,51:Yn,52:Yn,53:Yn,54:Yn,55:Yn,56:Yn,57:Yn,62:mn},li={91:Mn},ui={[-2]:kn,[-1]:kn,32:kn},di={35:An,42:Qn,45:[ei,Qn],60:Fn,61:ei,95:Qn,96:bn,126:bn},hi={38:vn,92:gn},pi={[-5]:Jn,[-4]:Jn,[-3]:Jn,33:Gn,38:vn,42:dn,60:[pn,Vn],91:$n,92:[Ln,gn],93:qn,95:dn,96:Cn},fi={null:[dn,ni]},mi=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:li,disable:{null:[]},document:ci,flow:di,flowInitial:ui,insideSpan:fi,string:hi,text:pi},Symbol.toStringTag,{value:"Module"}));function gi(e,t,n){let i={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},o=[];let a=[],s=[];const c={attempt:g(function(e,t){v(e,t.from)}),check:g(m),consume:function(e){Yt(e)?(i.line++,i.column=1,i.offset+=-3===e?2:1,y()):-1!==e&&(i.column++,i.offset++);i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===a[i._index].length&&(i._bufferIndex=-1,i._index++));l.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=h(),l.events.push(["enter",n,l]),s.push(n),n},exit:function(e){const t=s.pop();return t.end=h(),l.events.push(["exit",t,l]),t},interrupt:g(m,{interrupt:!0})},l={code:null,containerState:{},defineSkip:function(e){r[e.line]=e.column,y()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const i=[];let r;for(;++n<e.length;){const o=e[n];let a;if("string"==typeof o)a=o;else switch(o){case-5:a="\r";break;case-4:a="\n";break;case-3:a="\r\n";break;case-2:a=t?" ":"\t";break;case-1:if(!t&&r)continue;a=" ";break;default:a=String.fromCharCode(o)}r=-2===o,i.push(a)}return i.join("")}(d(e),t)},sliceStream:d,write:function(e){if(a=Ut(a,e),p(),null!==a[a.length-1])return[];return v(t,0),l.events=un(o,l.events,l),l.events}};let u=t.tokenize.call(l,c);return t.resolveAll&&o.push(t),l;function d(e){return function(e,t){const n=t.start._index,i=t.start._bufferIndex,r=t.end._index,o=t.end._bufferIndex;let a;if(n===r)a=[e[n].slice(i,o)];else{if(a=e.slice(n,r),i>-1){const e=a[0];"string"==typeof e?a[0]=e.slice(i):a.shift()}o>0&&a.push(e[r].slice(0,o))}return a}(a,e)}function h(){const{_bufferIndex:e,_index:t,line:n,column:r,offset:o}=i;return{_bufferIndex:e,_index:t,line:n,column:r,offset:o}}function p(){let e;for(;i._index<a.length;){const t=a[i._index];if("string"==typeof t)for(e=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===e&&i._bufferIndex<t.length;)f(t.charCodeAt(i._bufferIndex));else f(t)}}function f(e){u=u(e)}function m(e,t){t.restore()}function g(e,t){return function(n,r,o){let a,u,d,p;return Array.isArray(n)?f(n):"tokenize"in n?f([n]):function(e){return t;function t(t){const n=null!==t&&e[t],i=null!==t&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(i)?i:i?[i]:[]])(t)}}(n);function f(e){return a=e,u=0,0===e.length?o:m(e[u])}function m(e){return function(n){p=function(){const e=h(),t=l.previous,n=l.currentConstruct,r=l.events.length,o=Array.from(s);return{from:r,restore:a};function a(){i=e,l.previous=t,l.currentConstruct=n,l.events.length=r,s=o,y()}}(),d=e,e.partial||(l.currentConstruct=e);if(e.name&&l.parser.constructs.disable.null.includes(e.name))return v();return e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,g,v)(n)}}function g(t){return e(d,p),r}function v(e){return p.restore(),++u<a.length?m(a[u]):o}}}function v(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&jt(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function y(){i.line in r&&i.column<2&&(i.column=r[i.line],i.offset+=r[i.line]-1)}}function vi(e){const t={constructs:function(e){const t={};let n=-1;for(;++n<e.length;)Bt(t,e[n]);return t}([mi,...(e||{}).extensions||[]]),content:n(an),defined:[],document:n(sn),flow:n(ti),lazy:{},string:n(ii),text:n(ri)};return t;function n(e){return function(n){return gi(t,e,n)}}}const yi=/[\0\t\n\r]/g;const bi=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ki(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Vt(n.slice(t?2:1),t?16:10)}return At(n)||e}const Si={}.hasOwnProperty;function Ci(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(te),autolinkProtocol:E,autolinkEmail:E,atxHeading:o(Y),blockQuote:o(K),characterEscape:E,characterReference:E,codeFenced:o(G),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(G,a),codeText:o($,a),codeTextData:E,data:E,codeFlowValue:E,definition:o(J),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(Q),hardBreakEscape:o(X),hardBreakTrailing:o(X),htmlFlow:o(Z,a),htmlFlowData:E,htmlText:o(Z,a),htmlTextData:E,image:o(ee),label:a,link:o(te),listItem:o(ie),listItemValue:h,listOrdered:o(ne,d),listUnordered:o(ne),paragraph:o(re),reference:F,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Y),strong:o(oe),thematicBreak:o(se)},exit:{atxHeading:c(),atxHeadingSequence:S,autolink:c(),autolinkEmail:W,autolinkProtocol:H,blockQuote:c(),characterEscapeValue:x,characterReferenceMarkerHexadecimal:z,characterReferenceMarkerNumeric:z,characterReferenceValue:V,characterReference:q,codeFenced:c(g),codeFencedFence:m,codeFencedFenceInfo:p,codeFencedFenceMeta:f,codeFlowValue:x,codeIndented:c(v),codeText:c(N),codeTextData:x,data:x,definition:c(),definitionDestinationString:k,definitionLabelString:y,definitionTitleString:b,emphasis:c(),hardBreakEscape:c(_),hardBreakTrailing:c(_),htmlFlow:c(R),htmlFlowData:x,htmlText:c(I),htmlTextData:x,image:c(M),label:L,labelText:D,lineEnding:P,link:c(O),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:B,resourceDestinationString:A,resourceTitleString:j,resource:U,setextHeading:c(w),setextHeadingLineSequence:T,setextHeadingText:C,strong:c(),thematicBreak:c()}};wi(t,(e||{}).mdastExtensions||[]);const n={};return i;function i(e){let i={type:"root",children:[]};const o={stack:[i],tokenStack:[],config:t,enter:s,exit:l,buffer:a,resume:u,data:n},c=[];let d=-1;for(;++d<e.length;)if("listOrdered"===e[d][1].type||"listUnordered"===e[d][1].type)if("enter"===e[d][0])c.push(d);else{d=r(e,c.pop(),d)}for(d=-1;++d<e.length;){const n=t[e[d][0]];Si.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},o),e[d][1])}if(o.tokenStack.length>0){const e=o.tokenStack[o.tokenStack.length-1];(e[1]||xi).call(o,void 0,e[0])}for(i.position={start:Ti(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Ti(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)i=t.transforms[d](i)||i;return i}function r(e,t,n){let i,r,o,a,s=t-1,c=-1,l=!1;for(;++s<=n;){const t=e[s];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?c++:c--,a=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!i||a||c||o||(o=s),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!c&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===c&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(i){let a=s;for(r=void 0;a--;){const t=e[a];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;r&&(e[r][1].type="lineEndingBlank",l=!0),t[1].type="lineEnding",r=a}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}o&&(!r||o<r)&&(i._spread=!0),i.end=Object.assign({},r?e[r][1].start:t[1].end),e.splice(r||s,0,["exit",i,t[2]]),s++,n++}if("listItemPrefix"===t[1].type){const r={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};i=r,e.splice(s,0,["enter",r,t[2]]),s++,n++,o=void 0,a=!0}}}return e[t][1]._spread=l,n}function o(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function a(){this.stack.push({type:"fragment",children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Ti(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){const n=this.stack.pop(),i=this.tokenStack.pop();if(!i)throw new Error("Cannot close `"+e.type+"` ("+ut({start:e.start,end:e.end})+"): it’s not open");if(i[0].type!==e.type)if(t)t.call(this,e,i[0]);else{(i[1]||xi).call(this,e,i[0])}n.position.end=Ti(e.end)}function u(){return function(e){return Mt(e,"boolean"!=typeof Ot.includeImageAlt||Ot.includeImageAlt,"boolean"!=typeof Ot.includeHtml||Ot.includeHtml)}(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function h(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function f(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function m(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function y(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=qt(this.sliceSerialize(e)).toLowerCase()}function b(){const e=this.resume();this.stack[this.stack.length-1].title=e}function k(){const e=this.resume();this.stack[this.stack.length-1].url=e}function S(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function T(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function E(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ae(),n.position={start:Ti(e.start),end:void 0},t.push(n)),this.stack.push(n)}function x(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Ti(e.end)}function P(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=Ti(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(E.call(this,e),x.call(this,e))}function _(){this.data.atHardBreak=!0}function R(){const e=this.resume();this.stack[this.stack.length-1].value=e}function I(){const e=this.resume();this.stack[this.stack.length-1].value=e}function N(){const e=this.resume();this.stack[this.stack.length-1].value=e}function O(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function D(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(bi,ki)}(t),n.identifier=qt(t).toLowerCase()}function L(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function A(){const e=this.resume();this.stack[this.stack.length-1].url=e}function j(){const e=this.resume();this.stack[this.stack.length-1].title=e}function U(){this.data.inReference=void 0}function F(){this.data.referenceType="collapsed"}function B(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=qt(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function z(e){this.data.characterReferenceType=e.type}function V(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let i;if(n)i=Vt(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{i=At(t)}this.stack[this.stack.length-1].value+=i}function q(e){this.stack.pop().position.end=Ti(e.end)}function H(e){x.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function W(e){x.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function K(){return{type:"blockquote",children:[]}}function G(){return{type:"code",lang:null,meta:null,value:""}}function $(){return{type:"inlineCode",value:""}}function J(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Q(){return{type:"emphasis",children:[]}}function Y(){return{type:"heading",depth:0,children:[]}}function X(){return{type:"break"}}function Z(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function ie(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function oe(){return{type:"strong",children:[]}}function ae(){return{type:"text",value:""}}function se(){return{type:"thematicBreak"}}}(n)(function(e){for(;!En(e););return e}(vi(n).document().write(function(){let e,t=1,n="",i=!0;return function(r,o,a){const s=[];let c,l,u,d,h;for(r=n+("string"==typeof r?r.toString():new TextDecoder(o||void 0).decode(r)),u=0,n="",i&&(65279===r.charCodeAt(0)&&u++,i=void 0);u<r.length;){if(yi.lastIndex=u,c=yi.exec(r),d=c&&void 0!==c.index?c.index:r.length,h=r.charCodeAt(d),!c){n=r.slice(u);break}if(10===h&&u===d&&e)s.push(-3),e=void 0;else switch(e&&(s.push(-5),e=void 0),u<d&&(s.push(r.slice(u,d)),t+=d-u),h){case 0:s.push(65533),t++;break;case 9:for(l=4*Math.ceil(t/4),s.push(-2);t++<l;)s.push(-1);break;case 10:s.push(-4),t=1;break;default:e=!0,t=1}u=d+1}return a&&(e&&s.push(-5),n&&s.push(n),s.push(null)),s}}()(e,t,!0))))}function Ti(e){return{line:e.line,column:e.column,offset:e.offset}}function wi(e,t){let n=-1;for(;++n<t.length;){const i=t[n];Array.isArray(i)?wi(e,i):Ei(e,i)}}function Ei(e,t){let n;for(n in t)if(Si.call(t,n))switch(n){case"canContainEols":{const i=t[n];i&&e[n].push(...i);break}case"transforms":{const i=t[n];i&&e[n].push(...i);break}case"enter":case"exit":{const i=t[n];i&&Object.assign(e[n],i);break}}}function xi(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ut({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ut({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ut({start:t.start,end:t.end})+") is still open")}function Pi(e){const t=this;t.parser=function(n){return Ci(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function _i(e,t){const n=t.referenceType;let i="]";if("collapsed"===n?i+="[]":"full"===n&&(i+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+i}];const r=e.all(t),o=r[0];o&&"text"===o.type?o.value="["+o.value:r.unshift({type:"text",value:"["});const a=r[r.length-1];return a&&"text"===a.type?a.value+=i:r.push({type:"text",value:i}),r}function Ri(e){const t=e.spread;return null==t?e.children.length>1:t}function Ii(e){const t=String(e),n=/\r?\n|\r/g;let i=n.exec(t),r=0;const o=[];for(;i;)o.push(Ni(t.slice(r,i.index),r>0,!0),i[0]),r=i.index+i[0].length,i=n.exec(t);return o.push(Ni(t.slice(r),r>0,!1)),o.join("")}function Ni(e,t,n){let i=0,r=e.length;if(t){let t=e.codePointAt(i);for(;9===t||32===t;)i++,t=e.codePointAt(i)}if(n){let t=e.codePointAt(r-1);for(;9===t||32===t;)r--,t=e.codePointAt(r-1)}return r>i?e.slice(i,r):""}const Oi={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",i={},r=t.lang?t.lang.split(/\s+/):[];r.length>0&&(i.className=["language-"+r[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),r=rn(i.toLowerCase()),o=e.footnoteOrder.indexOf(i);let a,s=e.footnoteCounts.get(i);void 0===s?(s=0,e.footnoteOrder.push(i),a=e.footnoteOrder.length):a=o+1,s+=1,e.footnoteCounts.set(i,s);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const l={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return _i(e,t);const r={src:rn(i.url||""),alt:t.alt};null!==i.title&&void 0!==i.title&&(r.title=i.title);const o={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){const n={src:rn(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const i={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,i),e.applyData(t,i)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const i={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,i),e.applyData(t,i)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),i=e.definitionById.get(n);if(!i)return _i(e,t);const r={href:rn(i.url||"")};null!==i.title&&void 0!==i.title&&(r.title=i.title);const o={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){const n={href:rn(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const i={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},listItem:function(e,t,n){const i=e.all(t),r=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let i=-1;for(;!t&&++i<n.length;)t=Ri(n[i])}return t}(n):Ri(t),o={},a=[];if("boolean"==typeof t.checked){const e=i[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},i.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let s=-1;for(;++s<i.length;){const e=i[s];(r||0!==s||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||r?a.push(e):a.push(...e.children)}const c=i[i.length-1];c&&(r||"element"!==c.type||"p"!==c.tagName)&&a.push({type:"text",value:"\n"});const l={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,l),e.applyData(t,l)},list:function(e,t){const n={},i=e.all(t);let r=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++r<i.length;){const e=i[r];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),i=n.shift(),r=[];if(i){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([i],!0)};e.patch(t.children[0],n),r.push(n)}if(n.length>0){const i={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=ct(t.children[1]),a=st(t.children[t.children.length-1]);o&&a&&(i.position={start:o,end:a}),r.push(i)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const i=n?n.children:void 0,r=0===(i?i.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,a=o?o.length:t.children.length;let s=-1;const c=[];for(;++s<a;){const n=t.children[s],i={},a=o?o[s]:void 0;a&&(i.align=a);let l={type:"element",tagName:r,properties:i,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}const l={type:"element",tagName:"tr",properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)},text:function(e,t){const n={type:"text",value:Ii(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:Mi,yaml:Mi,definition:Mi,footnoteDefinition:Mi};function Mi(){}const Di="object"==typeof self?self:globalThis,Li=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),i=r=>{if(e.has(r))return e.get(r);const[o,a]=t[r];switch(o){case 0:case-1:return n(a,r);case 1:{const e=n([],r);for(const t of a)e.push(i(t));return e}case 2:{const e=n({},r);for(const[t,n]of a)e[i(t)]=i(n);return e}case 3:return n(new Date(a),r);case 4:{const{source:e,flags:t}=a;return n(new RegExp(e,t),r)}case 5:{const e=n(new Map,r);for(const[t,n]of a)e.set(i(t),i(n));return e}case 6:{const e=n(new Set,r);for(const t of a)e.add(i(t));return e}case 7:{const{name:e,message:t}=a;return n(new Di[e](t),r)}case 8:return n(BigInt(a),r);case"BigInt":return n(Object(BigInt(a)),r);case"ArrayBuffer":return n(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:e}=new Uint8Array(a);return n(new DataView(e),a)}}return n(new Di[o](a),r)};return i})(new Map,e)(0),Ai="",{toString:ji}={},{keys:Ui}=Object,Fi=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=ji.call(e).slice(8,-1);switch(n){case"Array":return[1,Ai];case"Object":return[2,Ai];case"Date":return[3,Ai];case"RegExp":return[4,Ai];case"Map":return[5,Ai];case"Set":return[6,Ai];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},Bi=([e,t])=>0===e&&("function"===t||"symbol"===t),zi=(e,{json:t,lossy:n}={})=>{const i=[];return((e,t,n,i)=>{const r=(e,t)=>{const r=i.push(e)-1;return n.set(t,r),r},o=i=>{if(n.has(i))return n.get(i);let[a,s]=Fi(i);switch(a){case 0:{let t=i;switch(s){case"bigint":a=8,t=i.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+s);t=null;break;case"undefined":return r([-1],i)}return r([a,t],i)}case 1:{if(s){let e=i;return"DataView"===s?e=new Uint8Array(i.buffer):"ArrayBuffer"===s&&(e=new Uint8Array(i)),r([s,[...e]],i)}const e=[],t=r([a,e],i);for(const n of i)e.push(o(n));return t}case 2:{if(s)switch(s){case"BigInt":return r([s,i.toString()],i);case"Boolean":case"Number":case"String":return r([s,i.valueOf()],i)}if(t&&"toJSON"in i)return o(i.toJSON());const n=[],c=r([a,n],i);for(const t of Ui(i))!e&&Bi(Fi(i[t]))||n.push([o(t),o(i[t])]);return c}case 3:return r([a,i.toISOString()],i);case 4:{const{source:e,flags:t}=i;return r([a,{source:e,flags:t}],i)}case 5:{const t=[],n=r([a,t],i);for(const[r,a]of i)(e||!Bi(Fi(r))&&!Bi(Fi(a)))&&t.push([o(r),o(a)]);return n}case 6:{const t=[],n=r([a,t],i);for(const r of i)!e&&Bi(Fi(r))||t.push(o(r));return n}}const{message:c}=i;return r([a,{name:s,message:c}],i)};return o})(!(t||n),!!t,new Map,i)(e),i},Vi="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Li(zi(e,t)):structuredClone(e):(e,t)=>Li(zi(e,t));function qi(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function Hi(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const Wi=function(e){if(null==e)return Gi;if("function"==typeof e)return Ki(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Wi(e[n]);return Ki(i);function i(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}(e):function(e){const t=e;return Ki(n);function n(n){const i=n;let r;for(r in e)if(i[r]!==t[r])return!1;return!0}}(e);if("string"==typeof e)return function(e){return Ki(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function Ki(e){return function(t,n,i){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,i||void 0))}}function Gi(){return!0}const $i=[],Ji=!0,Qi=!1;function Yi(e,t,n,i){let r;"function"==typeof t&&"function"!=typeof n?(i=n,n=t):r=t;const o=Wi(r),a=i?-1:1;!function e(r,s,c){const l=r&&"object"==typeof r?r:{};if("string"==typeof l.type){const e="string"==typeof l.tagName?l.tagName:"string"==typeof l.name?l.name:void 0;Object.defineProperty(u,"name",{value:"node ("+r.type+(e?"<"+e+">":"")+")"})}return u;function u(){let l,u,d,h=$i;if((!t||o(r,s,c[c.length-1]||void 0))&&(h=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[Ji,e];return null==e?$i:[e]}(n(r,c)),h[0]===Qi))return h;if("children"in r&&r.children){const t=r;if(t.children&&"skip"!==h[0])for(u=(i?t.children.length:-1)+a,d=c.concat(t);u>-1&&u<t.children.length;){const n=t.children[u];if(l=e(n,u,d)(),l[0]===Qi)return l;u="number"==typeof l[1]?l[1]:u+a}}return h}}(e,void 0,[])()}function Xi(e,t,n,i){let r,o,a;"function"==typeof t&&"function"!=typeof n?(o=void 0,a=t,r=n):(o=t,a=n,r=i),Yi(e,o,function(e,t){const n=t[t.length-1],i=n?n.children.indexOf(e):void 0;return a(e,i,n)},r)}const Zi={}.hasOwnProperty,er={};function tr(e,t){e.position&&(t.position=function(e){const t=ct(e),n=st(e);if(t&&n)return{start:t,end:n}}(e))}function nr(e,t){let n=t;if(e&&e.data){const t=e.data.hName,i=e.data.hChildren,r=e.data.hProperties;if("string"==typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&r&&Object.assign(n.properties,Vi(r)),"children"in n&&n.children&&null!=i&&(n.children=i)}return n}function ir(e,t){const n=t.data||{},i=!("value"in t)||Zi.call(n,"hProperties")||Zi.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,i),e.applyData(t,i)}function rr(e,t){const n=[];let i=-1;for(t&&n.push({type:"text",value:"\n"});++i<e.length;)i&&n.push({type:"text",value:"\n"}),n.push(e[i]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function or(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function ar(e,t){const n=function(e,t){const n=t||er,i=new Map,r=new Map,o=new Map,a={...Oi,...n.handlers},s={all:function(e){const t=[];if("children"in e){const n=e.children;let i=-1;for(;++i<n.length;){const r=s.one(n[i],e);if(r){if(i&&"break"===n[i-1].type&&(Array.isArray(r)||"text"!==r.type||(r.value=or(r.value)),!Array.isArray(r)&&"element"===r.type)){const e=r.children[0];e&&"text"===e.type&&(e.value=or(e.value))}Array.isArray(r)?t.push(...r):t.push(r)}}}return t},applyData:nr,definitionById:i,footnoteById:r,footnoteCounts:o,footnoteOrder:[],handlers:a,one:function(e,t){const n=e.type,i=s.handlers[n];if(Zi.call(s.handlers,n)&&i)return i(s,e,t);if(s.options.passThrough&&s.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,i=Vi(n);return i.children=s.all(e),i}return Vi(e)}return(s.options.unknownHandler||ir)(s,e,t)},options:n,patch:tr,wrap:rr};return Xi(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?i:r,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),s}(e,t),i=n.one(e,void 0),r=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||qi,i=e.options.footnoteBackLabel||Hi,r=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[];let c=-1;for(;++c<e.footnoteOrder.length;){const r=e.footnoteById.get(e.footnoteOrder[c]);if(!r)continue;const o=e.all(r),a=String(r.identifier).toUpperCase(),l=rn(a.toLowerCase());let u=0;const d=[],h=e.footnoteCounts.get(a);for(;void 0!==h&&++u<=h;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(c,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+l+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof i?i:i(c,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){const e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...d)}else o.push(...d);const f={type:"element",tagName:"li",properties:{id:t+"fn-"+l},children:e.wrap(o,!0)};e.patch(r,f),s.push(f)}if(0!==s.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Vi(a),id:"footnote-label"},children:[{type:"text",value:r}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:"\n"}]}}(n),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return r&&o.children.push({type:"text",value:"\n"},r),o}function sr(e,t){return e&&"run"in e?async function(n,i){const r=ar(n,{file:i,...t});await e.run(r,i)}:function(n,i){return ar(n,{file:i,...e||t})}}function cr(e){if(e)throw e}var lr,ur;var dr=function(){if(ur)return lr;ur=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===t.call(e)},o=function(n){if(!n||"[object Object]"!==t.call(n))return!1;var i,r=e.call(n,"constructor"),o=n.constructor&&n.constructor.prototype&&e.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!r&&!o)return!1;for(i in n);return void 0===i||e.call(n,i)},a=function(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},s=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(i)return i(t,n).value}return t[n]};return lr=function e(){var t,n,i,c,l,u,d=arguments[0],h=1,p=arguments.length,f=!1;for("boolean"==typeof d&&(f=d,d=arguments[1]||{},h=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});h<p;++h)if(null!=(t=arguments[h]))for(n in t)i=s(d,n),d!==(c=s(t,n))&&(f&&c&&(o(c)||(l=r(c)))?(l?(l=!1,u=i&&r(i)?i:[]):u=i&&o(i)?i:{},a(d,{name:n,newValue:e(f,u,c)})):void 0!==c&&a(d,{name:n,newValue:c}));return d},lr}();const hr=i(dr);function pr(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function fr(){const e=[],t={run:function(...t){let n=-1;const i=t.pop();if("function"!=typeof i)throw new TypeError("Expected function as last argument, not "+i);!function r(o,...a){const s=e[++n];let c=-1;if(o)i(o);else{for(;++c<t.length;)null!==a[c]&&void 0!==a[c]||(a[c]=t[c]);t=a,s?function(e,t){let n;return i;function i(...t){const i=e.length>t.length;let s;i&&t.push(r);try{s=e.apply(this,t)}catch(o){if(i&&n)throw o;return r(o)}i||(s&&s.then&&"function"==typeof s.then?s.then(a,r):s instanceof Error?r(s):a(s))}function r(e,...i){n||(n=!0,t(e,...i))}function a(e){r(null,e)}}(s,r)(...a):i(null,...a)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const mr={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');gr(e);let n,i=0,r=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){i=o+1;break}}else r<0&&(n=!0,r=o+1);return r<0?"":e.slice(i,r)}if(t===e)return"";let a=-1,s=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){i=o+1;break}}else a<0&&(n=!0,a=o+1),s>-1&&(e.codePointAt(o)===t.codePointAt(s--)?s<0&&(r=o):(s=-1,r=a));i===r?r=a:r<0&&(r=e.length);return e.slice(i,r)},dirname:function(e){if(gr(e),0===e.length)return".";let t,n=-1,i=e.length;for(;--i;)if(47===e.codePointAt(i)){if(t){n=i;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){gr(e);let t,n=e.length,i=-1,r=0,o=-1,a=0;for(;n--;){const s=e.codePointAt(n);if(47!==s)i<0&&(t=!0,i=n+1),46===s?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1);else if(t){r=n+1;break}}if(o<0||i<0||0===a||1===a&&o===i-1&&o===r+1)return"";return e.slice(o,i)},join:function(...e){let t,n=-1;for(;++n<e.length;)gr(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){gr(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,i,r="",o=0,a=-1,s=0,c=-1;for(;++c<=e.length;){if(c<e.length)n=e.codePointAt(c);else{if(47===n)break;n=47}if(47===n){if(a===c-1||1===s);else if(a!==c-1&&2===s){if(r.length<2||2!==o||46!==r.codePointAt(r.length-1)||46!==r.codePointAt(r.length-2))if(r.length>2){if(i=r.lastIndexOf("/"),i!==r.length-1){i<0?(r="",o=0):(r=r.slice(0,i),o=r.length-1-r.lastIndexOf("/")),a=c,s=0;continue}}else if(r.length>0){r="",o=0,a=c,s=0;continue}t&&(r=r.length>0?r+"/..":"..",o=2)}else r.length>0?r+="/"+e.slice(a+1,c):r=e.slice(a+1,c),o=c-a-1;a=c,s=0}else 46===n&&s>-1?s++:s=-1}return r}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function gr(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const vr={cwd:function(){return"/"}};function yr(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function br(e){if("string"==typeof e)e=new URL(e);else if(!yr(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const kr=["history","path","basename","stem","extname","dirname"];class Sr{constructor(e){let t;t=e?yr(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":vr.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,i=-1;for(;++i<kr.length;){const e=kr[i];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)kr.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?mr.basename(this.path):void 0}set basename(e){Tr(e,"basename"),Cr(e,"basename"),this.path=mr.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?mr.dirname(this.path):void 0}set dirname(e){wr(this.basename,"dirname"),this.path=mr.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?mr.extname(this.path):void 0}set extname(e){if(Cr(e,"extname"),wr(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=mr.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){yr(e)&&(e=br(e)),Tr(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?mr.basename(this.path,this.extname):void 0}set stem(e){Tr(e,"stem"),Cr(e,"stem"),this.path=mr.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const i=this.message(e,t,n);throw i.fatal=!0,i}info(e,t,n){const i=this.message(e,t,n);return i.fatal=void 0,i}message(e,t,n){const i=new ft(e,t,n);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(e){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function Cr(e,t){if(e&&e.includes(mr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+mr.sep+"`")}function Tr(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function wr(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const Er=function(e){const t=this.constructor.prototype,n=t[e],i=function(){return n.apply(i,arguments)};return Object.setPrototypeOf(i,t),i},xr={}.hasOwnProperty;class Pr extends Er{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=fr()}copy(){const e=new Pr;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(hr(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(Nr("data",this.frozen),this.namespace[e]=t,this):xr.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Nr("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const i=t.call(e,...n);"function"==typeof i&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=Dr(e),n=this.parser||this.Parser;return Rr("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),Rr("process",this.parser||this.Parser),Ir("process",this.compiler||this.Compiler),t?i(void 0,t):new Promise(i);function i(i,r){const o=Dr(e),a=n.parse(o);function s(e,n){e||!n?r(e):i?i(n):t(void 0,n)}n.run(a,o,function(e,t,i){if(e||!t||!i)return s(e);const r=t,o=n.stringify(r,i);var a;"string"==typeof(a=o)||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(a)?i.value=o:i.result=o,s(e,i)})}}processSync(e){let t,n=!1;return this.freeze(),Rr("processSync",this.parser||this.Parser),Ir("processSync",this.compiler||this.Compiler),this.process(e,function(e,i){n=!0,cr(e),t=i}),Mr("processSync","process",n),t}run(e,t,n){Or(e),this.freeze();const i=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?r(void 0,n):new Promise(r);function r(r,o){const a=Dr(t);i.run(e,a,function(t,i,a){const s=i||e;t?o(t):r?r(s):n(void 0,s,a)})}}runSync(e,t){let n,i=!1;return this.run(e,t,function(e,t){cr(e),n=t,i=!0}),Mr("runSync","run",i),n}stringify(e,t){this.freeze();const n=Dr(t),i=this.compiler||this.Compiler;return Ir("stringify",i),Or(e),i(e,n)}use(e,...t){const n=this.attachers,i=this.namespace;if(Nr("use",this.frozen),null==e);else if("function"==typeof e)s(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?a(e):o(e)}return this;function r(e){if("function"==typeof e)s(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;s(t,n)}else o(e)}}function o(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");a(e.plugins),e.settings&&(i.settings=hr(!0,i.settings,e.settings))}function a(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){r(e[t])}}}function s(e,t){let i=-1,r=-1;for(;++i<n.length;)if(n[i][0]===e){r=i;break}if(-1===r)n.push([e,...t]);else if(t.length>0){let[i,...o]=t;const a=n[r][1];pr(a)&&pr(i)&&(i=hr(!0,a,i)),n[r]=[e,i,...o]}}}}const _r=(new Pr).freeze();function Rr(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Ir(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function Nr(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Or(e){if(!pr(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function Mr(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Dr(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new Sr(e)}const Lr=[],Ar={allowDangerousHtml:!0},jr=/^(https?|ircs?|mailto|xmpp)$/i,Ur=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Fr(e){const t=function(e){const t=e.rehypePlugins||Lr,n=e.remarkPlugins||Lr,i=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ar}:Ar,r=_r().use(Pi).use(n).use(sr,i).use(t);return r}(e),n=function(e){const t=e.children||"",n=new Sr;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,i=t.allowElement,r=t.components,o=t.disallowedElements,a=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||Br;for(const u of Ur)Object.hasOwn(t,u.from)&&le((u.from,u.to&&u.to,u.id));return Xi(e,l),St(e,{Fragment:R.Fragment,components:r,ignoreInvalidStyle:!0,jsx:R.jsx,jsxs:R.jsxs,passKeys:!0,passNode:!0});function l(e,t,r){if("raw"===e.type&&r&&"number"==typeof t)return a?r.children.splice(t,1):r.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in Nt)if(Object.hasOwn(Nt,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],i=Nt[t];(null===i||i.includes(e.tagName))&&(e.properties[t]=c(String(n||""),t,e))}}if("element"===e.type){let a=n?!n.includes(e.tagName):!!o&&o.includes(e.tagName);if(!a&&i&&"number"==typeof t&&(a=!i(e,t,r)),a&&r&&"number"==typeof t)return s&&e.children?r.children.splice(t,1,...e.children):r.children.splice(t,1),t}}}(t.runSync(t.parse(n),n),e)}function Br(e){const t=e.indexOf(":"),n=e.indexOf("?"),i=e.indexOf("#"),r=e.indexOf("/");return-1===t||-1!==r&&t>r||-1!==n&&t>n||-1!==i&&t>i||jr.test(e.slice(0,t))?e:""}const zr={messageWrapper:"_messageWrapper_1lg4d_1",user:"_user_1lg4d_19",assistant:"_assistant_1lg4d_24",messageBubble:"_messageBubble_1lg4d_58",error:"_error_1lg4d_76",content:"_content_1lg4d_81",markdown:"_markdown_1lg4d_92",cursor:"_cursor_1lg4d_183",errorIndicator:"_errorIndicator_1lg4d_202",messageContent:"_messageContent_1lg4d_219",messageInfo:"_messageInfo_1lg4d_227",fadeOut:"_fadeOut_1lg4d_259",agentName:"_agentName_1lg4d_263",agentRole:"_agentRole_1lg4d_268",separator:"_separator_1lg4d_272",timestamp:"_timestamp_1lg4d_277"},Vr=e=>{const t=Date.now()-e,n=Math.floor(t/6e4),i=Math.floor(t/36e5),r=Math.floor(t/864e5);return n<1?"Just now":n<60?`${n}m`:i<24?`${i}h`:`${r}d`},qr=({message:e,agentName:t,agentRole:n,isLastAssistantMessage:i=!1})=>{const[r,o]=u.useState(!1),[a,s]=u.useState(!1),[c,l]=u.useState(!1),d="user"===e.role,h="streaming"===e.status,p="error"===e.status,f="assistant"===e.role,m=f&&(i||r);u.useEffect(()=>{if(m&&!a)l(!1),s(!0);else if(!m&&a){l(!0);const e=setTimeout(()=>{s(!1),l(!1)},200);return()=>clearTimeout(e)}},[m,a]);const g=[zr.messageWrapper,d?zr.user:zr.assistant,f&&!i?zr.clickable:""].filter(Boolean).join(" ");return R.jsx("div",{className:g,onClick:()=>{f&&!i&&o(!r)},children:R.jsxs("div",{className:zr.messageContent,children:[R.jsxs("div",{className:`${zr.messageBubble} ${p?zr.error:""}`,role:"article","aria-label":""+(d?"Your message":`${t||"AI"} says`),children:[R.jsxs("div",{className:`${zr.content} ${d?"":zr.markdown}`,children:[d?e.content:R.jsx(Fr,{components:{a:({href:e,children:t})=>e?R.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):R.jsx(R.Fragment,{children:t})},children:e.content}),h&&R.jsx("span",{className:zr.cursor})]}),p&&R.jsxs("div",{className:zr.errorIndicator,children:[R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",children:[R.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),R.jsx("path",{d:"M12 8V12M12 16H12.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),R.jsx("span",{children:"Failed to send"})]})]}),a&&R.jsxs("div",{className:`${zr.messageInfo} ${c?zr.fadeOut:""}`,children:[R.jsx("span",{className:zr.agentName,children:t||"AI"}),n&&R.jsxs(R.Fragment,{children:[R.jsx("span",{className:zr.separator,children:"•"}),R.jsx("span",{className:zr.agentRole,children:n})]}),R.jsx("span",{className:zr.separator,children:"•"}),R.jsx("span",{className:zr.timestamp,children:Vr(e.timestamp)})]})]})})},Hr="_toolCall_1wby1_1",Wr="_iconWrapper_1wby1_24",Kr="_spinner_1wby1_33",Gr="_checkIcon_1wby1_48",$r="_errorIcon_1wby1_54",Jr="_content_1wby1_60",Qr="_label_1wby1_66",Yr="_name_1wby1_73",Xr="_pending_1wby1_78",Zr="_completed_1wby1_82",eo="_error_1wby1_54",to=({toolCall:e})=>{const t="pending"===e.status||"executing"===e.status,n="completed"===e.status,i="error"===e.status;return R.jsxs("div",{className:`${Hr} ${t?Xr:""} ${n?Zr:""} ${i?eo:""}`,children:[R.jsx("div",{className:Wr,children:t?R.jsx("div",{className:Kr}):n?R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:Gr,children:R.jsx("path",{d:"M20 6L9 17L4 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:$r,children:R.jsx("path",{d:"M6 18L18 6M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),R.jsxs("div",{className:Jr,children:[R.jsx("span",{className:Qr,children:t?"Running":n?"Completed":"Failed"}),R.jsx("span",{className:Yr,children:(r=e.name,r.replace(/_/g," ").replace(/([A-Z])/g," $1").trim().toLowerCase().replace(/^./,e=>e.toUpperCase()))})]})]});var r},no="_wrapper_10rss_2",io="_avatar_10rss_22",ro="_avatarPlaceholder_10rss_37",oo="_brainbaseLogo_10rss_47",ao="_bubble_10rss_52",so="_dot_10rss_63",co=({agentName:e="AI",agentLogoUrl:t})=>R.jsxs("div",{className:no,role:"status","aria-label":`${e} is typing`,children:[R.jsx("div",{className:io,children:t?R.jsx("img",{src:t,alt:e}):R.jsx("div",{className:ro,children:R.jsx(U,{className:oo,color:"white",cutoutColor:"var(--bb-primary-color)"})})}),R.jsxs("div",{className:ao,children:[R.jsx("span",{className:so}),R.jsx("span",{className:so}),R.jsx("span",{className:so})]})]}),lo="_messageList_9tkjc_1",uo="_emptyState_9tkjc_30",ho="_emptyIcon_9tkjc_41",po="_emptyText_9tkjc_53",fo=({messages:e,toolCalls:t=[],isLoading:n,showTypingIndicator:i=!1,agentName:r,agentRole:o,agentLogoUrl:a})=>{const s=e.reduce((e,t,n)=>"assistant"===t.role?n:e,-1),c=u.useRef(null),l=u.useRef(null),d=u.useRef(e.length),h=u.useRef(t.length);u.useEffect(()=>{const n=e.length>d.current,r=t.length>h.current;if(n||r||i){const e=c.current;e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})}d.current=e.length,h.current=t.length},[e.length,t.length,i]);const p=t.filter(e=>"pending"===e.status||"executing"===e.status);return R.jsxs("div",{className:lo,ref:c,role:"log","aria-live":"polite",children:[0===e.length&&!n&&R.jsxs("div",{className:uo,children:[R.jsx("div",{className:ho,children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:R.jsx("path",{d:"M8 12H8.01M12 12H12.01M16 12H16.01M21 12C21 16.4183 16.9706 20 12 20C10.4607 20 9.01172 19.6565 7.74467 19.0511L3 20L4.39499 16.28C3.51156 15.0423 3 13.5743 3 12C3 7.58172 7.02944 4 12 4C16.9706 4 21 7.58172 21 12Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),R.jsx("p",{className:po,children:"Start a conversation"})]}),e.map((e,t)=>R.jsx(qr,{message:e,agentName:r,agentRole:o,isLastAssistantMessage:t===s},e.id)),p.map(e=>R.jsx(to,{toolCall:e},e.id)),i&&R.jsx(co,{agentName:r,agentLogoUrl:a}),R.jsx("div",{ref:l})]})},mo="_inputWrapper_6o34z_1",go="_inputContainer_6o34z_7",vo="_textarea_6o34z_23",yo="_inputActions_6o34z_51",bo="_actionIcons_6o34z_57",ko="_iconButton_6o34z_63",So="_sendButton_6o34z_96",Co="_audioButton_6o34z_126",To="_audioIcon_6o34z_141",wo=({onSend:e,disabled:t=!1,placeholder:n="Message...",onAttachment:i,onEmoji:r,onGif:o,onVoice:a})=>{const[s,c]=u.useState(""),l=u.useRef(null),d=u.useCallback(()=>{const e=l.current;e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[]);u.useEffect(()=>{d()},[s,d]);const h=u.useCallback(n=>{null==n||n.preventDefault();const i=s.trim();i&&!t&&(e(i),c(""),l.current&&(l.current.style.height="auto"))},[s,t,e]),p=u.useCallback(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),h())},[h]);return R.jsx("form",{className:mo,onSubmit:h,children:R.jsxs("div",{className:go,children:[R.jsx("textarea",{ref:l,className:vo,value:s,onChange:e=>c(e.target.value),onKeyDown:p,placeholder:n,disabled:t,rows:1,"aria-label":"Message input"}),R.jsxs("div",{className:yo,children:[R.jsxs("div",{className:bo,children:[i&&R.jsx("button",{type:"button",className:ko,onClick:i,disabled:t,"aria-label":"Attach file",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:R.jsx("path",{d:"M21.44 11.05L12.25 20.24C11.1242 21.3658 9.59723 21.9983 8.005 21.9983C6.41277 21.9983 4.88584 21.3658 3.76 20.24C2.63416 19.1142 2.00166 17.5872 2.00166 15.995C2.00166 14.4028 2.63416 12.8758 3.76 11.75L12.33 3.18C13.0806 2.42975 14.0991 2.00127 15.16 2.00127C16.2209 2.00127 17.2394 2.42975 17.99 3.18C18.7403 3.93063 19.1687 4.94905 19.1687 6.01C19.1687 7.07095 18.7403 8.08937 17.99 8.84L9.41 17.41C9.03472 17.7853 8.52573 17.9961 7.995 17.9961C7.46427 17.9961 6.95528 17.7853 6.58 17.41C6.20472 17.0347 5.99389 16.5257 5.99389 15.995C5.99389 15.4643 6.20472 14.9553 6.58 14.58L15.07 6.1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),r&&R.jsx("button",{type:"button",className:ko,onClick:r,disabled:t,"aria-label":"Add emoji",children:R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",children:[R.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2"}),R.jsx("path",{d:"M8 14C8 14 9.5 16 12 16C14.5 16 16 14 16 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),R.jsx("circle",{cx:"9",cy:"9",r:"1",fill:"currentColor"}),R.jsx("circle",{cx:"15",cy:"9",r:"1",fill:"currentColor"})]})}),o&&R.jsx("button",{type:"button",className:ko,onClick:o,disabled:t,"aria-label":"Add GIF",children:R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",children:[R.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"2"}),R.jsx("path",{d:"M8 10V14M8 12H10M8 10H10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),R.jsx("path",{d:"M13 10V14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),R.jsx("path",{d:"M16 10V14M16 10H18M16 12H17.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),a&&R.jsx("button",{type:"button",className:ko,onClick:a,disabled:t,"aria-label":"Voice message",children:R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",children:[R.jsx("rect",{x:"9",y:"2",width:"6",height:"11",rx:"3",stroke:"currentColor",strokeWidth:"2"}),R.jsx("path",{d:"M5 10V11C5 14.866 8.13401 18 12 18C15.866 18 19 14.866 19 11V10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),R.jsx("path",{d:"M12 18V22M12 22H8M12 22H16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]}),R.jsx("button",{type:s.trim()?"submit":"button",className:`${So} ${s.trim()?"":Co}`,disabled:t,"aria-label":s.trim()?"Send message":"Voice message",onClick:s.trim()?void 0:a,children:s.trim()?R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:R.jsx("path",{d:"M12 19V5M12 5L5 12M12 5L19 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})}):R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:To,children:[R.jsx("path",{d:"M4 10V14",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),R.jsx("path",{d:"M9 6V18",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),R.jsx("path",{d:"M14 8V16",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),R.jsx("path",{d:"M19 10V14",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})})]})]})})},Eo="_poweredBy_9jh5q_1",xo="_logo_9jh5q_20",Po="_poweredText_9jh5q_24",_o="_text_9jh5q_36",Ro=({className:e})=>R.jsxs("svg",{className:e,viewBox:"0 0 800 800",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[R.jsx("path",{d:"M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",fill:"currentColor"}),R.jsx("circle",{cx:"400",cy:"400",r:"400",fill:"currentColor"}),R.jsx("path",{d:"M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",fill:"currentColor"}),R.jsx("path",{d:"M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",fill:"currentColor"}),R.jsx("circle",{cx:"400",cy:"400",r:"350",fill:"currentColor"}),R.jsx("path",{d:"M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",fill:"currentColor"}),R.jsx("rect",{x:"399.919",y:"209",width:"270",height:"270",rx:"12",transform:"rotate(45 399.919 209)",fill:"var(--bb-surface-bg, #ffffff)"})]}),Io=({showBranding:e=!0})=>e?R.jsxs("a",{href:"https://brainbaselabs.com/",target:"_blank",rel:"noopener noreferrer",className:Eo,"aria-label":"Powered by Brainbase Labs",children:[R.jsx("span",{className:Po,children:"Powered by"}),R.jsx(Ro,{className:xo}),R.jsx("span",{className:_o,children:"Brainbase Labs"})]}):null;function No(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if("default"!==n&&!(n in e)){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}var Oo=Object.defineProperty,Mo=(e,t,n)=>((e,t,n)=>t in e?Oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class Do{constructor(){Mo(this,"_locking"),Mo(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){let e;this._locks+=1;const t=new Promise(t=>e=()=>{this._locks-=1,t()}),n=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),n}}function Lo(e,t){if(!e)throw new Error(t)}function Ao(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function jo(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function Uo(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}const Fo=Symbol("@bufbuild/protobuf/enum-type");function Bo(e){const t=e[Fo];return Lo(t,"missing enum type on enum object"),t}function zo(e,t,n,i){e[Fo]=Vo(t,n.map(t=>({no:t.no,name:t.name,localName:e[t.no]})))}function Vo(e,t,n){const i=Object.create(null),r=Object.create(null),o=[];for(const a of t){const e=Ho(a);o.push(e),i[a.name]=e,r[a.no]=e}return{typeName:e,values:o,findName:e=>i[e],findNumber:e=>r[e]}}function qo(e,t,n){const i={};for(const r of t){const e=Ho(r);i[e.localName]=e.no,i[e.no]=e.localName}return zo(i,e,t),i}function Ho(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class Wo{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType().runtime.bin,i=n.makeReadOptions(t);return n.readMessage(this,i.readerFactory(e),e.byteLength,i),this}fromJson(e,t){const n=this.getType(),i=n.runtime.json,r=i.makeReadOptions(t);return i.readMessage(n,e,r,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(i){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(i instanceof Error?i.message:String(i)))}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),i=n.writerFactory();return t.writeMessage(this,i,n),i.finish()}toJson(e){const t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Ko(){let e=0,t=0;for(let i=0;i<28;i+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<i,!(128&n))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let i=3;i<=31;i+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<i,!(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Go(e,t,n){for(let o=0;o<28;o+=7){const i=e>>>o,r=!(i>>>7==0&&0==t),a=255&(r?128|i:i);if(n.push(a),!r)return}const i=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|i:i)),r){for(let e=3;e<31;e+=7){const i=t>>>e,r=!(i>>>7==0),o=255&(r?128|i:i);if(n.push(o),!r)return}n.push(t>>>31&1)}}const $o=4294967296;function Jo(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let i=0,r=0;function o(t,o){const a=Number(e.slice(t,o));r*=n,i=i*n+a,i>=$o&&(r+=i/$o|0,i%=$o)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),t?Xo(i,r):Yo(i,r)}function Qo(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String($o*t+e);const n=16777215&(e>>>24|t<<8),i=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*i,o=n+8147497*i,a=2*i;const s=1e7;return r>=s&&(o+=Math.floor(r/s),r%=s),o>=s&&(a+=Math.floor(o/s),o%=s),a.toString()+Zo(o)+Zo(r)}function Yo(e,t){return{lo:0|e,hi:0|t}}function Xo(e,t){return t=~t,e?e=1+~e:t+=1,Yo(e,t)}const Zo=e=>{const t=String(e);return"0000000".slice(t.length)+t};function ea(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function ta(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let n=5;128&e&&n<10;n++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}const na=function(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"object"!=typeof process.env||"1"!==process.env.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const i="bigint"==typeof e?e:BigInt(e);if(i>n||i<t)throw new Error("int64 invalid: ".concat(e));return i},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<i)throw new Error("uint64 invalid: ".concat(e));return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}const t=e=>Lo(/^-?[0-9]+$/.test(e),"int64 invalid: ".concat(e)),n=e=>Lo(/^[0-9]+$/.test(e),"uint64 invalid: ".concat(e));return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),t(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),n(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),t(e),Jo(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),n(e),Jo(e)),dec:(e,t)=>function(e,t){let n=Yo(e,t);const i=2147483648&n.hi;i&&(n=Xo(n.lo,n.hi));const r=Qo(n.lo,n.hi);return i?"-"+r:r}(e,t),uDec:(e,t)=>Qo(e,t)}}();var ia,ra,oa,aa,sa,ca;function la(e,t,n){if(t===n)return!0;if(e==ia.BYTES){if(!(t instanceof Uint8Array&&n instanceof Uint8Array))return!1;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case ia.UINT64:case ia.FIXED64:case ia.INT64:case ia.SFIXED64:case ia.SINT64:return t==n}return!1}function ua(e,t){switch(e){case ia.BOOL:return!1;case ia.UINT64:case ia.FIXED64:case ia.INT64:case ia.SFIXED64:case ia.SINT64:return 0==t?na.zero:"0";case ia.DOUBLE:case ia.FLOAT:return 0;case ia.BYTES:return new Uint8Array(0);case ia.STRING:return"";default:return 0}}function da(e,t){switch(e){case ia.BOOL:return!1===t;case ia.STRING:return""===t;case ia.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}(ra=ia||(ia={}))[ra.DOUBLE=1]="DOUBLE",ra[ra.FLOAT=2]="FLOAT",ra[ra.INT64=3]="INT64",ra[ra.UINT64=4]="UINT64",ra[ra.INT32=5]="INT32",ra[ra.FIXED64=6]="FIXED64",ra[ra.FIXED32=7]="FIXED32",ra[ra.BOOL=8]="BOOL",ra[ra.STRING=9]="STRING",ra[ra.BYTES=12]="BYTES",ra[ra.UINT32=13]="UINT32",ra[ra.SFIXED32=15]="SFIXED32",ra[ra.SFIXED64=16]="SFIXED64",ra[ra.SINT32=17]="SINT32",ra[ra.SINT64=18]="SINT64",(aa=oa||(oa={}))[aa.BIGINT=0]="BIGINT",aa[aa.STRING=1]="STRING",(ca=sa||(sa={}))[ca.Varint=0]="Varint",ca[ca.Bit64=1]="Bit64",ca[ca.LengthDelimited=2]="LengthDelimited",ca[ca.StartGroup=3]="StartGroup",ca[ca.EndGroup=4]="EndGroup",ca[ca.Bit32=5]="Bit32";class ha{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let t=new Uint8Array(e),n=0;for(let i=0;i<this.chunks.length;i++)t.set(this.chunks[i],n),n+=this.chunks[i].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(jo(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return Ao(e),ea(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Uo(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){jo(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Ao(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Ao(e),ea(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=na.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),i=na.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=na.enc(e);return Go(t.lo,t.hi,this.buf),this}sint64(e){let t=na.enc(e),n=t.hi>>31;return Go(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=na.uEnc(e);return Go(t.lo,t.hi,this.buf),this}}class pa{constructor(e,t){this.varint64=Ko,this.uint32=ta,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case sa.Varint:for(;128&this.buf[this.pos++];);break;case sa.Bit64:this.pos+=4;case sa.Bit32:this.pos+=4;break;case sa.LengthDelimited:let n=this.uint32();this.pos+=n;break;case sa.StartGroup:for(;;){const[e,n]=this.tag();if(n===sa.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(n,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return na.dec(...this.varint64())}uint64(){return na.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,na.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return na.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return na.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function fa(e){const t=e.field.localName,n=Object.create(null);return n[t]=function(e){const t=e.field;if(t.repeated)return[];if(void 0!==t.default)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return ua(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}(e),[n,()=>n[t]]}let ma="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ga=[];for(let tv=0;tv<ma.length;tv++)ga[ma[tv].charCodeAt(0)]=tv;ga["-".charCodeAt(0)]=ma.indexOf("+"),ga["_".charCodeAt(0)]=ma.indexOf("/");const va={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,i=new Uint8Array(t),r=0,o=0,a=0;for(let s=0;s<e.length;s++){if(n=ga[e.charCodeAt(s)],void 0===n)switch(e[s]){case"=":o=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(o){case 0:a=n,o=1;break;case 1:i[r++]=a<<2|(48&n)>>4,a=n,o=2;break;case 2:i[r++]=(15&a)<<4|(60&n)>>2,a=n,o=3;break;case 3:i[r++]=(3&a)<<6|n,o=0}}if(1==o)throw Error("invalid base64 string.");return i.subarray(0,r)},enc(e){let t,n="",i=0,r=0;for(let o=0;o<e.length;o++)switch(t=e[o],i){case 0:n+=ma[t>>2],r=(3&t)<<4,i=1;break;case 1:n+=ma[r|t>>4],r=(15&t)<<2,i=2;break;case 2:n+=ma[r|t>>6],n+=ma[63&t],i=0}return i&&(n+=ma[r],n+="=",1==i&&(n+="=")),n}};function ya(e,t,n){Sa(t,e);const i=t.runtime.bin.makeReadOptions(n),r=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter(e=>e.no===t.no)}(e.getType().runtime.bin.listUnknownFields(e),t.field),[o,a]=fa(t);for(const s of r)t.runtime.bin.readField(o,i.readerFactory(s.data),t.field,s.wireType,i);return a()}function ba(e,t,n,i){Sa(t,e);const r=t.runtime.bin.makeReadOptions(i),o=t.runtime.bin.makeWriteOptions(i);if(ka(e,t)){const n=e.getType().runtime.bin.listUnknownFields(e).filter(e=>e.no!=t.field.no);e.getType().runtime.bin.discardUnknownFields(e);for(const t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const a=o.writerFactory();let s=t.field;s.opt||s.repeated||"enum"!=s.kind&&"scalar"!=s.kind||(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,n,a,o);const c=r.readerFactory(a.finish());for(;c.pos<c.len;){const[t,n]=c.tag(),i=c.skip(n,t);e.getType().runtime.bin.onUnknownField(e,t,n,i)}}function ka(e,t){const n=e.getType();return t.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(e).find(e=>e.no==t.field.no)}function Sa(e,t){Lo(e.extendee.typeName==t.getType().typeName,"extension ".concat(e.typeName," can only be applied to message ").concat(e.extendee.typeName))}function Ca(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?void 0!==t[n]:"enum"==e.kind?t[n]!==e.T.values[0].no:!da(e.T,t[n]);case"message":return void 0!==t[n];case"map":return Object.keys(t[n]).length>0}}function Ta(e,t){const n=e.localName,i=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=i?e.T.values[0].no:void 0;break;case"scalar":t[n]=i?ua(e.T,e.L):void 0;break;case"message":t[n]=void 0}}function wa(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(Wo.prototype).every(t=>t in e&&"function"==typeof e[t]))return!1;const n=e.getType();return null!==n&&"function"==typeof n&&"typeName"in n&&"string"==typeof n.typeName&&(void 0===t||n.typeName==t.typeName)}function Ea(e,t){return wa(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}ia.DOUBLE,ia.FLOAT,ia.INT64,ia.UINT64,ia.INT32,ia.UINT32,ia.BOOL,ia.STRING,ia.BYTES;const xa={ignoreUnknownFields:!1},Pa={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function _a(e){return e?Object.assign(Object.assign({},xa),e):xa}function Ra(e){return e?Object.assign(Object.assign({},Pa),e):Pa}const Ia=Symbol(),Na=Symbol();function Oa(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":'"'.concat(e.split('"').join('\\"'),'"');default:return String(e)}}function Ma(e,t,n,i,r){let o=n.localName;if(n.repeated){if(Lo("map"!=n.kind),null===t)return;if(!Array.isArray(t))throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Oa(t)));const s=e[o];for(const e of t){if(null===e)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Oa(e)));switch(n.kind){case"message":s.push(n.T.fromJson(e,i));break;case"enum":const t=Aa(n.T,e,i.ignoreUnknownFields,!0);t!==Na&&s.push(t);break;case"scalar":try{s.push(La(n.T,e,n.L,!0))}catch(a){let t="cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Oa(e));throw a instanceof Error&&a.message.length>0&&(t+=": ".concat(a.message)),new Error(t)}}}}else if("map"==n.kind){if(null===t)return;if("object"!=typeof t||Array.isArray(t))throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Oa(t)));const s=e[o];for(const[e,o]of Object.entries(t)){if(null===o)throw new Error("cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: map value null"));let c;try{c=Da(n.K,e)}catch(a){let e="cannot decode map key for field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Oa(t));throw a instanceof Error&&a.message.length>0&&(e+=": ".concat(a.message)),new Error(e)}switch(n.V.kind){case"message":s[c]=n.V.T.fromJson(o,i);break;case"enum":const e=Aa(n.V.T,o,i.ignoreUnknownFields,!0);e!==Na&&(s[c]=e);break;case"scalar":try{s[c]=La(n.V.T,o,oa.BIGINT,!0)}catch(a){let e="cannot decode map value for field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Oa(t));throw a instanceof Error&&a.message.length>0&&(e+=": ".concat(a.message)),new Error(e)}}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:o},o="value"),n.kind){case"message":const s=n.T;if(null===t&&"google.protobuf.Value"!=s.typeName)return;let c=e[o];wa(c)?c.fromJson(t,i):(e[o]=c=s.fromJson(t,i),s.fieldWrapper&&!n.oneof&&(e[o]=s.fieldWrapper.unwrapField(c)));break;case"enum":const l=Aa(n.T,t,i.ignoreUnknownFields,!1);switch(l){case Ia:Ta(n,e);break;case Na:break;default:e[o]=l}break;case"scalar":try{const i=La(n.T,t,n.L,!1);if(i===Ia)Ta(n,e);else e[o]=i}catch(a){let e="cannot decode field ".concat(r.typeName,".").concat(n.name," from JSON: ").concat(Oa(t));throw a instanceof Error&&a.message.length>0&&(e+=": ".concat(a.message)),new Error(e)}}}function Da(e,t){if(e===ia.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return La(e,t,oa.BIGINT,!0).toString()}function La(e,t,n,i){if(null===t)return i?ua(e,n):Ia;switch(e){case ia.DOUBLE:case ia.FLOAT:if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const i=Number(t);if(Number.isNaN(i))break;if(!Number.isFinite(i))break;return e==ia.FLOAT&&Uo(i),i;case ia.INT32:case ia.FIXED32:case ia.SFIXED32:case ia.SINT32:case ia.UINT32:let o;if("number"==typeof t?o=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(o=Number(t)),void 0===o)break;return e==ia.UINT32||e==ia.FIXED32?jo(o):Ao(o),o;case ia.INT64:case ia.SFIXED64:case ia.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const a=na.parse(t);return n?a.toString():a;case ia.FIXED64:case ia.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const s=na.uParse(t);return n?s.toString():s;case ia.BOOL:if("boolean"!=typeof t)break;return t;case ia.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(r){throw new Error("invalid UTF8")}return t;case ia.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return va.dec(t)}throw new Error}function Aa(e,t,n,i){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:i?e.values[0].no:Ia;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const i=e.findName(t);if(void 0!==i)return i.no;if(n)return Na}throw new Error("cannot decode enum ".concat(e.typeName," from JSON: ").concat(Oa(t)))}function ja(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function Ua(e,t,n){if("map"==e.kind){Lo("object"==typeof t&&null!=t);const i={},r=Object.entries(t);switch(e.V.kind){case"scalar":for(const[n,o]of r)i[n.toString()]=Ba(e.V.T,o);break;case"message":for(const[e,o]of r)i[e.toString()]=o.toJson(n);break;case"enum":const t=e.V.T;for(const[e,o]of r)i[e.toString()]=Fa(t,o,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?i:void 0}if(e.repeated){Lo(Array.isArray(t));const i=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++)i.push(Ba(e.T,t[n]));break;case"enum":for(let r=0;r<t.length;r++)i.push(Fa(e.T,t[r],n.enumAsInteger));break;case"message":for(let e=0;e<t.length;e++)i.push(t[e].toJson(n))}return n.emitDefaultValues||i.length>0?i:void 0}switch(e.kind){case"scalar":return Ba(e.T,t);case"enum":return Fa(e.T,t,n.enumAsInteger);case"message":return Ea(e.T,t).toJson(n)}}function Fa(e,t,n){var i;if(Lo("number"==typeof t),"google.protobuf.NullValue"==e.typeName)return null;if(n)return t;const r=e.findNumber(t);return null!==(i=null==r?void 0:r.name)&&void 0!==i?i:t}function Ba(e,t){switch(e){case ia.INT32:case ia.SFIXED32:case ia.SINT32:case ia.FIXED32:case ia.UINT32:return Lo("number"==typeof t),t;case ia.FLOAT:case ia.DOUBLE:return Lo("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case ia.STRING:return Lo("string"==typeof t),t;case ia.BOOL:return Lo("boolean"==typeof t),t;case ia.UINT64:case ia.FIXED64:case ia.INT64:case ia.SFIXED64:case ia.SINT64:return Lo("bigint"==typeof t||"string"==typeof t||"number"==typeof t),t.toString();case ia.BYTES:return Lo(t instanceof Uint8Array),va.enc(t)}}const za=Symbol("@bufbuild/protobuf/unknown-fields"),Va={readUnknownFields:!0,readerFactory:e=>new pa(e)},qa={writeUnknownFields:!0,writerFactory:()=>new ha};function Ha(e){return e?Object.assign(Object.assign({},Va),e):Va}function Wa(e){return e?Object.assign(Object.assign({},qa),e):qa}function Ka(e,t,n,i,r){let{repeated:o,localName:a}=n;switch(n.oneof&&((e=e[n.oneof.localName]).case!=a&&delete e.value,e.case=a,a="value"),n.kind){case"scalar":case"enum":const s="enum"==n.kind?ia.INT32:n.T;let c=Ja;if("scalar"==n.kind&&n.L>0&&(c=$a),o){let n=e[a];if(i==sa.LengthDelimited&&s!=ia.STRING&&s!=ia.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(c(t,s))}else n.push(c(t,s))}else e[a]=c(t,s);break;case"message":const l=n.T;o?e[a].push(Ga(t,new l,r,n)):wa(e[a])?Ga(t,e[a],r,n):(e[a]=Ga(t,new l,r,n),!l.fieldWrapper||n.oneof||n.repeated||(e[a]=l.fieldWrapper.unwrapField(e[a])));break;case"map":let[u,d]=function(e,t,n){const i=t.uint32(),r=t.pos+i;let o,a;for(;t.pos<r;){const[i]=t.tag();switch(i){case 1:o=Ja(t,e.K);break;case 2:switch(e.V.kind){case"scalar":a=Ja(t,e.V.T);break;case"enum":a=t.int32();break;case"message":a=Ga(t,new e.V.T,n,void 0)}}}void 0===o&&(o=ua(e.K,oa.BIGINT));"string"!=typeof o&&"number"!=typeof o&&(o=o.toString());if(void 0===a)switch(e.V.kind){case"scalar":a=ua(e.V.T,oa.BIGINT);break;case"enum":a=e.V.T.values[0].no;break;case"message":a=new e.V.T}return[o,a]}(n,t,r);e[a][u]=d}}function Ga(e,t,n,i){const r=t.getType().runtime.bin,o=null==i?void 0:i.delimited;return r.readMessage(t,e,o?i.no:e.uint32(),n,o),t}function $a(e,t){const n=Ja(e,t);return"bigint"==typeof n?n.toString():n}function Ja(e,t){switch(t){case ia.STRING:return e.string();case ia.BOOL:return e.bool();case ia.DOUBLE:return e.double();case ia.FLOAT:return e.float();case ia.INT32:return e.int32();case ia.INT64:return e.int64();case ia.UINT64:return e.uint64();case ia.FIXED64:return e.fixed64();case ia.BYTES:return e.bytes();case ia.FIXED32:return e.fixed32();case ia.SFIXED32:return e.sfixed32();case ia.SFIXED64:return e.sfixed64();case ia.SINT64:return e.sint64();case ia.UINT32:return e.uint32();case ia.SINT32:return e.sint32()}}function Qa(e,t,n,i){Lo(void 0!==t);const r=e.repeated;switch(e.kind){case"scalar":case"enum":let o="enum"==e.kind?ia.INT32:e.T;if(r)if(Lo(Array.isArray(t)),e.packed)!function(e,t,n,i){if(!i.length)return;e.tag(n,sa.LengthDelimited).fork();let[,r]=es(t);for(let o=0;o<i.length;o++)e[r](i[o]);e.join()}(n,o,e.no,t);else for(const i of t)Za(n,o,e.no,i);else Za(n,o,e.no,t);break;case"message":if(r){Lo(Array.isArray(t));for(const r of t)Xa(n,i,e,r)}else Xa(n,i,e,t);break;case"map":Lo("object"==typeof t&&null!=t);for(const[r,a]of Object.entries(t))Ya(n,i,e,r,a)}}function Ya(e,t,n,i,r){e.tag(n.no,sa.LengthDelimited),e.fork();let o=i;switch(n.K){case ia.INT32:case ia.FIXED32:case ia.UINT32:case ia.SFIXED32:case ia.SINT32:o=Number.parseInt(i);break;case ia.BOOL:Lo("true"==i||"false"==i),o="true"==i}switch(Za(e,n.K,1,o),n.V.kind){case"scalar":Za(e,n.V.T,2,r);break;case"enum":Za(e,ia.INT32,2,r);break;case"message":Lo(void 0!==r),e.tag(2,sa.LengthDelimited).bytes(r.toBinary(t))}e.join()}function Xa(e,t,n,i){const r=Ea(n.T,i);n.delimited?e.tag(n.no,sa.StartGroup).raw(r.toBinary(t)).tag(n.no,sa.EndGroup):e.tag(n.no,sa.LengthDelimited).bytes(r.toBinary(t))}function Za(e,t,n,i){Lo(void 0!==i);let[r,o]=es(t);e.tag(n,r)[o](i)}function es(e){let t=sa.Varint;switch(e){case ia.BYTES:case ia.STRING:t=sa.LengthDelimited;break;case ia.DOUBLE:case ia.FIXED64:case ia.SFIXED64:t=sa.Bit64;break;case ia.FIXED32:case ia.SFIXED32:case ia.FLOAT:t=sa.Bit32}return[t,ia[e].toLowerCase()]}function ts(e){if(void 0===e)return e;if(wa(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function ns(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class is{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,t)=>e.no-t.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function rs(e,t){const n=as(e);return t?n:ds(us(n))}const os=as;function as(e){let t=!1;const n=[];for(let i=0;i<e.length;i++){let r=e.charAt(i);switch(r){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),t=!1;break;default:t&&(t=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const ss=new Set(["constructor","toString","toJSON","valueOf"]),cs=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),ls=e=>"".concat(e,"$"),us=e=>cs.has(e)?ls(e):e,ds=e=>ss.has(e)?ls(e):e;class hs{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=rs(e,!1)}addField(e){Lo(e.oneof===this,"field ".concat(e.name," not one of ").concat(this.name)),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}}const ps=(fs=e=>new is(e,e=>function(e){var t,n,i,r,o,a;const s=[];let c;for(const l of"function"==typeof e?e():e){const e=l;if(e.localName=rs(l.name,void 0!==l.oneof),e.jsonName=null!==(t=l.jsonName)&&void 0!==t?t:os(l.name),e.repeated=null!==(n=l.repeated)&&void 0!==n&&n,"scalar"==l.kind&&(e.L=null!==(i=l.L)&&void 0!==i?i:oa.BIGINT),e.delimited=null!==(r=l.delimited)&&void 0!==r&&r,e.req=null!==(o=l.req)&&void 0!==o&&o,e.opt=null!==(a=l.opt)&&void 0!==a&&a,void 0===l.packed&&(e.packed="enum"==l.kind||"scalar"==l.kind&&l.T!=ia.BYTES&&l.T!=ia.STRING),void 0!==l.oneof){const t="string"==typeof l.oneof?l.oneof:l.oneof.name;c&&c.name==t||(c=new hs(t)),e.oneof=c,c.addField(e)}s.push(e)}return s}(e)),ms=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,i=e;if(t.repeated)i[n]=[];else switch(t.kind){case"oneof":i[n]={case:void 0};break;case"enum":i[n]=0;break;case"map":i[n]={};break;case"scalar":i[n]=ua(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:_a,makeWriteOptions:Ra,readMessage(e,t,n,i){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error("cannot decode message ".concat(e.typeName," from JSON: ").concat(Oa(t)));i=null!=i?i:new e;const r=new Map,o=n.typeRegistry;for(const[a,s]of Object.entries(t)){const t=e.fields.findJsonName(a);if(t){if(t.oneof){if(null===s&&"scalar"==t.kind)continue;const n=r.get(t.oneof);if(void 0!==n)throw new Error("cannot decode message ".concat(e.typeName,' from JSON: multiple keys for oneof "').concat(t.oneof.name,'" present: "').concat(n,'", "').concat(a,'"'));r.set(t.oneof,a)}Ma(i,s,t,n,e)}else{let t=!1;if((null==o?void 0:o.findExtension)&&a.startsWith("[")&&a.endsWith("]")){const r=o.findExtension(a.substring(1,a.length-1));if(r&&r.extendee.typeName==e.typeName){t=!0;const[e,o]=fa(r);Ma(e,s,r.field,n,r),ba(i,r,o(),n)}}if(!t&&!n.ignoreUnknownFields)throw new Error("cannot decode message ".concat(e.typeName,' from JSON: key "').concat(a,'" is unknown'))}}return i},writeMessage(e,t){const n=e.getType(),i={};let r;try{for(r of n.fields.byNumber()){if(!Ca(r,e)){if(r.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!ja(r))continue}const n=Ua(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t);void 0!==n&&(i[t.useProtoFieldName?r.name:r.jsonName]=n)}const o=t.typeRegistry;if(null==o?void 0:o.findExtensionFor)for(const r of n.runtime.bin.listUnknownFields(e)){const a=o.findExtensionFor(n.typeName,r.no);if(a&&ka(e,a)){const n=ya(e,a,t),r=Ua(a.field,n,t);void 0!==r&&(i[a.field.jsonName]=r)}}}catch(o){const e=r?"cannot encode field ".concat(n.typeName,".").concat(r.name," to JSON"):"cannot encode message ".concat(n.typeName," to JSON"),t=o instanceof Error?o.message:String(o);throw new Error(e+(t.length>0?": ".concat(t):""))}return i},readScalar:(e,t,n)=>La(e,t,null!=n?n:oa.BIGINT,!0),writeScalar(e,t,n){if(void 0!==t)return n||da(e,t)?Ba(e,t):void 0},debug:Oa},bin:{makeReadOptions:Ha,makeWriteOptions:Wa,listUnknownFields(e){var t;return null!==(t=e[za])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[za]},writeUnknownFields(e,t){const n=e[za];if(n)for(const i of n)t.tag(i.no,i.wireType).raw(i.data)},onUnknownField(e,t,n,i){const r=e;Array.isArray(r[za])||(r[za]=[]),r[za].push({no:t,wireType:n,data:i})},readMessage(e,t,n,i,r){const o=e.getType(),a=r?t.len:t.pos+n;let s,c;for(;t.pos<a&&([s,c]=t.tag(),!0!==r||c!=sa.EndGroup);){const n=o.fields.find(s);if(!n){const n=t.skip(c,s);i.readUnknownFields&&this.onUnknownField(e,s,c,n);continue}Ka(e,t,n,c,i)}if(r&&(c!=sa.EndGroup||s!==n))throw new Error("invalid end group tag")},readField:Ka,writeMessage(e,t,n){const i=e.getType();for(const r of i.fields.byNumber())if(Ca(r,e))Qa(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t,n);else if(r.req)throw new Error("cannot encode field ".concat(i.typeName,".").concat(r.name," to binary: required field not set"));return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,i){void 0!==t&&Qa(e,t,n,i)}},util:Object.assign(Object.assign({},{setEnumType:zo,initPartial(e,t){if(void 0===e)return;const n=t.getType();for(const i of n.fields.byMember()){const n=i.localName,r=t,o=e;if(null!=o[n])switch(i.kind){case"oneof":const e=o[n].case;if(void 0===e)continue;const t=i.findField(e);let a=o[n].value;t&&"message"==t.kind&&!wa(a,t.T)?a=new t.T(a):t&&"scalar"===t.kind&&t.T===ia.BYTES&&(a=ns(a)),r[n]={case:e,value:a};break;case"scalar":case"enum":let s=o[n];i.T===ia.BYTES&&(s=i.repeated?s.map(ns):ns(s)),r[n]=s;break;case"map":switch(i.V.kind){case"scalar":case"enum":if(i.V.T===ia.BYTES)for(const[t,i]of Object.entries(o[n]))r[n][t]=ns(i);else Object.assign(r[n],o[n]);break;case"message":const e=i.V.T;for(const t of Object.keys(o[n])){let i=o[n][t];e.fieldWrapper||(i=new e(i)),r[n][t]=i}}break;case"message":const c=i.T;if(i.repeated)r[n]=o[n].map(e=>wa(e,c)?e:new c(e));else{const e=o[n];c.fieldWrapper?"google.protobuf.BytesValue"===c.typeName?r[n]=ns(e):r[n]=e:r[n]=wa(e,c)?e:new c(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every(e=>{const i=t[e.localName],r=n[e.localName];if(e.repeated){if(i.length!==r.length)return!1;switch(e.kind){case"message":return i.every((t,n)=>e.T.equals(t,r[n]));case"scalar":return i.every((t,n)=>la(e.T,t,r[n]));case"enum":return i.every((e,t)=>la(ia.INT32,e,r[t]))}throw new Error("repeated cannot contain ".concat(e.kind))}switch(e.kind){case"message":let t=i,n=r;return e.T.fieldWrapper&&(void 0===t||wa(t)||(t=e.T.fieldWrapper.wrapField(t)),void 0===n||wa(n)||(n=e.T.fieldWrapper.wrapField(n))),e.T.equals(t,n);case"enum":return la(ia.INT32,i,r);case"scalar":return la(e.T,i,r);case"oneof":if(i.case!==r.case)return!1;const o=e.findField(i.case);if(void 0===o)return!0;switch(o.kind){case"message":return o.T.equals(i.value,r.value);case"enum":return la(ia.INT32,i.value,r.value);case"scalar":return la(o.T,i.value,r.value)}throw new Error("oneof cannot contain ".concat(o.kind));case"map":const a=Object.keys(i).concat(Object.keys(r));switch(e.V.kind){case"message":const t=e.V.T;return a.every(e=>t.equals(i[e],r[e]));case"enum":return a.every(e=>la(ia.INT32,i[e],r[e]));case"scalar":const n=e.V.T;return a.every(e=>la(n,i[e],r[e]))}}}),clone(e){const t=e.getType(),n=new t,i=n;for(const r of t.fields.byMember()){const t=e[r.localName];let n;if(r.repeated)n=t.map(ts);else if("map"==r.kind){n=i[r.localName];for(const[e,i]of Object.entries(t))n[e]=ts(i)}else n="oneof"==r.kind?r.findField(t.case)?{case:t.case,value:ts(t.value)}:{case:void 0}:ts(t);i[r.localName]=n}for(const r of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(i,r.no,r.wireType,r.data);return n}}),{newFieldList:fs,initFields:ms}),makeMessageType(e,t,n){return function(e,t,n,i){var r;const o=null!==(r=null==i?void 0:i.localName)&&void 0!==r?r:t.substring(t.lastIndexOf(".")+1),a={[o]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[o];return Object.setPrototypeOf(a.prototype,new Wo),Object.assign(a,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new a).fromBinary(e,t),fromJson:(e,t)=>(new a).fromJson(e,t),fromJsonString:(e,t)=>(new a).fromJsonString(e,t),equals:(t,n)=>e.util.equals(a,t,n)}),a}(this,e,t,n)},makeEnum:qo,makeEnumType:Vo,getEnumType:Bo,makeExtension(e,t,n){return function(e,t,n,i){let r;return{typeName:t,extendee:n,get field(){if(!r){const n="function"==typeof i?i():i;n.name=t.split(".").pop(),n.jsonName="[".concat(t,"]"),r=e.util.newFieldList([n]).list()[0]}return r},runtime:e}}(this,e,t,n)}});var fs,ms;class gs extends Wo{constructor(e){super(),this.seconds=na.zero,this.nanos=0,ps.util.initPartial(e,this)}fromJson(e,t){if("string"!=typeof e)throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(ps.json.debug(e)));const n=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=na.parse(i/1e3),this.nanos=0,n[7]&&(this.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),this}toJson(e){const t=1e3*Number(this.seconds);if(t<Date.parse("0001-01-01T00:00:00Z")||t>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let n="Z";if(this.nanos>0){const e=(this.nanos+1e9).toString().substring(1);n="000000"===e.substring(3)?"."+e.substring(0,3)+"Z":"000"===e.substring(6)?"."+e.substring(0,6)+"Z":"."+e+"Z"}return new Date(t).toISOString().replace(".000Z",n)}toDate(){return new Date(1e3*Number(this.seconds)+Math.ceil(this.nanos/1e6))}static now(){return gs.fromDate(new Date)}static fromDate(e){const t=e.getTime();return new gs({seconds:na.parse(Math.floor(t/1e3)),nanos:t%1e3*1e6})}static fromBinary(e,t){return(new gs).fromBinary(e,t)}static fromJson(e,t){return(new gs).fromJson(e,t)}static fromJsonString(e,t){return(new gs).fromJsonString(e,t)}static equals(e,t){return ps.util.equals(gs,e,t)}}gs.runtime=ps,gs.typeName="google.protobuf.Timestamp",gs.fields=ps.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const vs=ps.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:gs},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:ys,repeated:!0},{no:5,name:"events",kind:"message",T:ks,repeated:!0}]),ys=ps.makeMessageType("livekit.TimeSeriesMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:bs,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),bs=ps.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:gs},{no:3,name:"value",kind:"scalar",T:2}]),ks=ps.makeMessageType("livekit.EventMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:gs},{no:7,name:"normalized_end_timestamp",kind:"message",T:gs,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),Ss=ps.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"PREFER_REGRESSION"},{no:1,name:"SIMULCAST"},{no:2,name:"REGRESSION"}]),Cs=ps.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),Ts=ps.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),ws=ps.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),Es=ps.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),xs=ps.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),Ps=ps.makeEnum("livekit.DisconnectReason",[{no:0,name:"UNKNOWN_REASON"},{no:1,name:"CLIENT_INITIATED"},{no:2,name:"DUPLICATE_IDENTITY"},{no:3,name:"SERVER_SHUTDOWN"},{no:4,name:"PARTICIPANT_REMOVED"},{no:5,name:"ROOM_DELETED"},{no:6,name:"STATE_MISMATCH"},{no:7,name:"JOIN_FAILURE"},{no:8,name:"MIGRATION"},{no:9,name:"SIGNAL_CLOSE"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"},{no:14,name:"CONNECTION_TIMEOUT"},{no:15,name:"MEDIA_FAILURE"}]),_s=ps.makeEnum("livekit.ReconnectReason",[{no:0,name:"RR_UNKNOWN"},{no:1,name:"RR_SIGNAL_DISCONNECTED"},{no:2,name:"RR_PUBLISHER_FAILED"},{no:3,name:"RR_SUBSCRIBER_FAILED"},{no:4,name:"RR_SWITCH_CANDIDATE"}]),Rs=ps.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),Is=ps.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"},{no:6,name:"TF_PRECONNECT_BUFFER"}]),Ns=ps.makeMessageType("livekit.Room",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"empty_timeout",kind:"scalar",T:13},{no:14,name:"departure_timeout",kind:"scalar",T:13},{no:4,name:"max_participants",kind:"scalar",T:13},{no:5,name:"creation_time",kind:"scalar",T:3},{no:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:Os,repeated:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"num_participants",kind:"scalar",T:13},{no:11,name:"num_publishers",kind:"scalar",T:13},{no:10,name:"active_recording",kind:"scalar",T:8},{no:13,name:"version",kind:"message",T:hc}]),Os=ps.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),Ms=ps.makeMessageType("livekit.ParticipantPermission",()=>[{no:1,name:"can_subscribe",kind:"scalar",T:8},{no:2,name:"can_publish",kind:"scalar",T:8},{no:3,name:"can_publish_data",kind:"scalar",T:8},{no:9,name:"can_publish_sources",kind:"enum",T:ps.getEnumType(Ts),repeated:!0},{no:7,name:"hidden",kind:"scalar",T:8},{no:8,name:"recorder",kind:"scalar",T:8},{no:10,name:"can_update_metadata",kind:"scalar",T:8},{no:11,name:"agent",kind:"scalar",T:8},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8}]),Ds=ps.makeMessageType("livekit.ParticipantInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:ps.getEnumType(Ls)},{no:4,name:"tracks",kind:"message",T:Bs,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",kind:"scalar",T:3},{no:9,name:"name",kind:"scalar",T:9},{no:10,name:"version",kind:"scalar",T:13},{no:11,name:"permission",kind:"message",T:Ms},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:ps.getEnumType(As)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:ps.getEnumType(Ps)},{no:18,name:"kind_details",kind:"enum",T:ps.getEnumType(js),repeated:!0}]),Ls=ps.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),As=ps.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"},{no:7,name:"CONNECTOR"}]),js=ps.makeEnum("livekit.ParticipantInfo.KindDetail",[{no:0,name:"CLOUD_AGENT"},{no:1,name:"FORWARDED"}]),Us=ps.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),Fs=ps.makeMessageType("livekit.SimulcastCodecInfo",()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"mid",kind:"scalar",T:9},{no:3,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:zs,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:ps.getEnumType(Vs)},{no:6,name:"sdp_cid",kind:"scalar",T:9}]),Bs=ps.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:ps.getEnumType(Cs)},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"muted",kind:"scalar",T:8},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"simulcast",kind:"scalar",T:8},{no:8,name:"disable_dtx",kind:"scalar",T:8},{no:9,name:"source",kind:"enum",T:ps.getEnumType(Ts)},{no:10,name:"layers",kind:"message",T:zs,repeated:!0},{no:11,name:"mime_type",kind:"scalar",T:9},{no:12,name:"mid",kind:"scalar",T:9},{no:13,name:"codecs",kind:"message",T:Fs,repeated:!0},{no:14,name:"stereo",kind:"scalar",T:8},{no:15,name:"disable_red",kind:"scalar",T:8},{no:16,name:"encryption",kind:"enum",T:ps.getEnumType(Us)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:hc},{no:19,name:"audio_features",kind:"enum",T:ps.getEnumType(Is),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:ps.getEnumType(Ss)}]),zs=ps.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:ps.getEnumType(ws)},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13},{no:4,name:"bitrate",kind:"scalar",T:13},{no:5,name:"ssrc",kind:"scalar",T:13},{no:6,name:"spatial_layer",kind:"scalar",T:5},{no:7,name:"rid",kind:"scalar",T:9}]),Vs=ps.makeEnum("livekit.VideoLayer.Mode",[{no:0,name:"MODE_UNUSED"},{no:1,name:"ONE_SPATIAL_LAYER_PER_STREAM"},{no:2,name:"MULTIPLE_SPATIAL_LAYERS_PER_STREAM"},{no:3,name:"ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR"}]),qs=ps.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:ps.getEnumType(Hs)},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:2,name:"user",kind:"message",T:Js,oneof:"value"},{no:3,name:"speaker",kind:"message",T:Gs,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:Qs,oneof:"value"},{no:7,name:"transcription",kind:"message",T:Ys,oneof:"value"},{no:8,name:"metrics",kind:"message",T:vs,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:Zs,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:ec,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:tc,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:nc,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:gc,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:vc,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:yc,oneof:"value"},{no:18,name:"encrypted_packet",kind:"message",T:Ws,oneof:"value"},{no:16,name:"sequence",kind:"scalar",T:13},{no:17,name:"participant_sid",kind:"scalar",T:9}]),Hs=ps.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),Ws=ps.makeMessageType("livekit.EncryptedPacket",()=>[{no:1,name:"encryption_type",kind:"enum",T:ps.getEnumType(Us)},{no:2,name:"iv",kind:"scalar",T:12},{no:3,name:"key_index",kind:"scalar",T:13},{no:4,name:"encrypted_value",kind:"scalar",T:12}]),Ks=ps.makeMessageType("livekit.EncryptedPacketPayload",()=>[{no:1,name:"user",kind:"message",T:Js,oneof:"value"},{no:3,name:"chat_message",kind:"message",T:Zs,oneof:"value"},{no:4,name:"rpc_request",kind:"message",T:ec,oneof:"value"},{no:5,name:"rpc_ack",kind:"message",T:tc,oneof:"value"},{no:6,name:"rpc_response",kind:"message",T:nc,oneof:"value"},{no:7,name:"stream_header",kind:"message",T:gc,oneof:"value"},{no:8,name:"stream_chunk",kind:"message",T:vc,oneof:"value"},{no:9,name:"stream_trailer",kind:"message",T:yc,oneof:"value"}]),Gs=ps.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:$s,repeated:!0}]),$s=ps.makeMessageType("livekit.SpeakerInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"level",kind:"scalar",T:2},{no:3,name:"active",kind:"scalar",T:8}]),Js=ps.makeMessageType("livekit.UserPacket",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:5,name:"participant_identity",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"destination_sids",kind:"scalar",T:9,repeated:!0},{no:6,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:4,name:"topic",kind:"scalar",T:9,opt:!0},{no:8,name:"id",kind:"scalar",T:9,opt:!0},{no:9,name:"start_time",kind:"scalar",T:4,opt:!0},{no:10,name:"end_time",kind:"scalar",T:4,opt:!0},{no:11,name:"nonce",kind:"scalar",T:12}]),Qs=ps.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),Ys=ps.makeMessageType("livekit.Transcription",()=>[{no:2,name:"transcribed_participant_identity",kind:"scalar",T:9},{no:3,name:"track_id",kind:"scalar",T:9},{no:4,name:"segments",kind:"message",T:Xs,repeated:!0}]),Xs=ps.makeMessageType("livekit.TranscriptionSegment",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"start_time",kind:"scalar",T:4},{no:4,name:"end_time",kind:"scalar",T:4},{no:5,name:"final",kind:"scalar",T:8},{no:6,name:"language",kind:"scalar",T:9}]),Zs=ps.makeMessageType("livekit.ChatMessage",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"edit_timestamp",kind:"scalar",T:3,opt:!0},{no:4,name:"message",kind:"scalar",T:9},{no:5,name:"deleted",kind:"scalar",T:8},{no:6,name:"generated",kind:"scalar",T:8}]),ec=ps.makeMessageType("livekit.RpcRequest",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"payload",kind:"scalar",T:9},{no:4,name:"response_timeout_ms",kind:"scalar",T:13},{no:5,name:"version",kind:"scalar",T:13}]),tc=ps.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),nc=ps.makeMessageType("livekit.RpcResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:9,oneof:"value"},{no:3,name:"error",kind:"message",T:ic,oneof:"value"}]),ic=ps.makeMessageType("livekit.RpcError",()=>[{no:1,name:"code",kind:"scalar",T:13},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:9}]),rc=ps.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),oc=ps.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:ps.getEnumType(ac)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"region",kind:"scalar",T:9},{no:5,name:"node_id",kind:"scalar",T:9},{no:6,name:"debug_info",kind:"scalar",T:9},{no:7,name:"agent_protocol",kind:"scalar",T:5}]),ac=ps.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),sc=ps.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:ps.getEnumType(cc)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"os",kind:"scalar",T:9},{no:5,name:"os_version",kind:"scalar",T:9},{no:6,name:"device_model",kind:"scalar",T:9},{no:7,name:"browser",kind:"scalar",T:9},{no:8,name:"browser_version",kind:"scalar",T:9},{no:9,name:"address",kind:"scalar",T:9},{no:10,name:"network",kind:"scalar",T:9},{no:11,name:"other_sdks",kind:"scalar",T:9}]),cc=ps.makeEnum("livekit.ClientInfo.SDK",[{no:0,name:"UNKNOWN"},{no:1,name:"JS"},{no:2,name:"SWIFT"},{no:3,name:"ANDROID"},{no:4,name:"FLUTTER"},{no:5,name:"GO"},{no:6,name:"UNITY"},{no:7,name:"REACT_NATIVE"},{no:8,name:"RUST"},{no:9,name:"PYTHON"},{no:10,name:"CPP"},{no:11,name:"UNITY_WEB"},{no:12,name:"NODE"},{no:13,name:"UNREAL"},{no:14,name:"ESP32"}]),lc=ps.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:uc},{no:2,name:"screen",kind:"message",T:uc},{no:3,name:"resume_connection",kind:"enum",T:ps.getEnumType(xs)},{no:4,name:"disabled_codecs",kind:"message",T:dc},{no:5,name:"force_relay",kind:"enum",T:ps.getEnumType(xs)}]),uc=ps.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:ps.getEnumType(xs)}]),dc=ps.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:Os,repeated:!0},{no:2,name:"publish",kind:"message",T:Os,repeated:!0}]),hc=ps.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),pc=ps.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),fc=ps.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:ps.getEnumType(pc)},{no:2,name:"version",kind:"scalar",T:5},{no:3,name:"reply_to_stream_id",kind:"scalar",T:9},{no:4,name:"attached_stream_ids",kind:"scalar",T:9,repeated:!0},{no:5,name:"generated",kind:"scalar",T:8}],{localName:"DataStream_TextHeader"}),mc=ps.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),gc=ps.makeMessageType("livekit.DataStream.Header",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"mime_type",kind:"scalar",T:9},{no:5,name:"total_length",kind:"scalar",T:4,opt:!0},{no:7,name:"encryption_type",kind:"enum",T:ps.getEnumType(Us)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:fc,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:mc,oneof:"content_header"}],{localName:"DataStream_Header"}),vc=ps.makeMessageType("livekit.DataStream.Chunk",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"chunk_index",kind:"scalar",T:4},{no:3,name:"content",kind:"scalar",T:12},{no:4,name:"version",kind:"scalar",T:5},{no:5,name:"iv",kind:"scalar",T:12,opt:!0}],{localName:"DataStream_Chunk"}),yc=ps.makeMessageType("livekit.DataStream.Trailer",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"reason",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}],{localName:"DataStream_Trailer"}),bc=ps.makeMessageType("livekit.SubscribedAudioCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"enabled",kind:"scalar",T:8}]),kc=ps.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),Sc=ps.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),Cc=ps.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),Tc=ps.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:Mc,oneof:"message"},{no:2,name:"answer",kind:"message",T:Mc,oneof:"message"},{no:3,name:"trickle",kind:"message",T:Pc,oneof:"message"},{no:4,name:"add_track",kind:"message",T:xc,oneof:"message"},{no:5,name:"mute",kind:"message",T:_c,oneof:"message"},{no:6,name:"subscription",kind:"message",T:Lc,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:Ac,oneof:"message"},{no:8,name:"leave",kind:"message",T:Fc,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:zc,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:tl,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:rl,oneof:"message"},{no:13,name:"simulate",kind:"message",T:sl,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:Vc,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:cl,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:jc,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:Uc,oneof:"message"}]),wc=ps.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:Rc,oneof:"message"},{no:2,name:"answer",kind:"message",T:Mc,oneof:"message"},{no:3,name:"offer",kind:"message",T:Mc,oneof:"message"},{no:4,name:"trickle",kind:"message",T:Pc,oneof:"message"},{no:5,name:"update",kind:"message",T:Dc,oneof:"message"},{no:6,name:"track_published",kind:"message",T:Nc,oneof:"message"},{no:8,name:"leave",kind:"message",T:Fc,oneof:"message"},{no:9,name:"mute",kind:"message",T:_c,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:Hc,oneof:"message"},{no:11,name:"room_update",kind:"message",T:Wc,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:Gc,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:Jc,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:Xc,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:nl,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:Oc,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:Ic,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:ll,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:hl,oneof:"message"},{no:22,name:"request_response",kind:"message",T:pl,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:ml,oneof:"message"},{no:24,name:"room_moved",kind:"message",T:il,oneof:"message"},{no:25,name:"media_sections_requirement",kind:"message",T:kl,oneof:"message"},{no:26,name:"subscribed_audio_codec_update",kind:"message",T:Zc,oneof:"message"}]),Ec=ps.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:zs,repeated:!0},{no:5,name:"video_layer_mode",kind:"enum",T:ps.getEnumType(Vs)}]),xc=ps.makeMessageType("livekit.AddTrackRequest",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:ps.getEnumType(Cs)},{no:4,name:"width",kind:"scalar",T:13},{no:5,name:"height",kind:"scalar",T:13},{no:6,name:"muted",kind:"scalar",T:8},{no:7,name:"disable_dtx",kind:"scalar",T:8},{no:8,name:"source",kind:"enum",T:ps.getEnumType(Ts)},{no:9,name:"layers",kind:"message",T:zs,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:Ec,repeated:!0},{no:11,name:"sid",kind:"scalar",T:9},{no:12,name:"stereo",kind:"scalar",T:8},{no:13,name:"disable_red",kind:"scalar",T:8},{no:14,name:"encryption",kind:"enum",T:ps.getEnumType(Us)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:ps.getEnumType(Ss)},{no:17,name:"audio_features",kind:"enum",T:ps.getEnumType(Is),repeated:!0}]),Pc=ps.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:ps.getEnumType(kc)},{no:3,name:"final",kind:"scalar",T:8}]),_c=ps.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),Rc=ps.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:Ns},{no:2,name:"participant",kind:"message",T:Ds},{no:3,name:"other_participants",kind:"message",T:Ds,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:qc,repeated:!0},{no:6,name:"subscriber_primary",kind:"scalar",T:8},{no:7,name:"alternative_url",kind:"scalar",T:9},{no:8,name:"client_configuration",kind:"message",T:lc},{no:9,name:"server_region",kind:"scalar",T:9},{no:10,name:"ping_timeout",kind:"scalar",T:5},{no:11,name:"ping_interval",kind:"scalar",T:5},{no:12,name:"server_info",kind:"message",T:oc},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:Os,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),Ic=ps.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:qc,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:lc},{no:3,name:"server_info",kind:"message",T:oc},{no:4,name:"last_message_seq",kind:"scalar",T:13}]),Nc=ps.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:Bs}]),Oc=ps.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),Mc=ps.makeMessageType("livekit.SessionDescription",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9},{no:3,name:"id",kind:"scalar",T:13},{no:4,name:"mid_to_track_id",kind:"map",K:9,V:{kind:"scalar",T:9}}]),Dc=ps.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:Ds,repeated:!0}]),Lc=ps.makeMessageType("livekit.UpdateSubscription",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"participant_tracks",kind:"message",T:rc,repeated:!0}]),Ac=ps.makeMessageType("livekit.UpdateTrackSettings",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:3,name:"disabled",kind:"scalar",T:8},{no:4,name:"quality",kind:"enum",T:ps.getEnumType(ws)},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"fps",kind:"scalar",T:13},{no:8,name:"priority",kind:"scalar",T:13}]),jc=ps.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:ps.getEnumType(Is),repeated:!0}]),Uc=ps.makeMessageType("livekit.UpdateLocalVideoTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13}]),Fc=ps.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:ps.getEnumType(Ps)},{no:3,name:"action",kind:"enum",T:ps.getEnumType(Bc)},{no:4,name:"regions",kind:"message",T:ul}]),Bc=ps.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),zc=ps.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:zs,repeated:!0}]),Vc=ps.makeMessageType("livekit.UpdateParticipantMetadata",()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:4,name:"request_id",kind:"scalar",T:13}]),qc=ps.makeMessageType("livekit.ICEServer",()=>[{no:1,name:"urls",kind:"scalar",T:9,repeated:!0},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"credential",kind:"scalar",T:9}]),Hc=ps.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:$s,repeated:!0}]),Wc=ps.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:Ns}]),Kc=ps.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:ps.getEnumType(Es)},{no:3,name:"score",kind:"scalar",T:2}]),Gc=ps.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:Kc,repeated:!0}]),$c=ps.makeMessageType("livekit.StreamStateInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:ps.getEnumType(Sc)}]),Jc=ps.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:$c,repeated:!0}]),Qc=ps.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:ps.getEnumType(ws)},{no:2,name:"enabled",kind:"scalar",T:8}]),Yc=ps.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:Qc,repeated:!0}]),Xc=ps.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:Qc,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:Yc,repeated:!0}]),Zc=ps.makeMessageType("livekit.SubscribedAudioCodecUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_audio_codecs",kind:"message",T:bc,repeated:!0}]),el=ps.makeMessageType("livekit.TrackPermission",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"all_tracks",kind:"scalar",T:8},{no:3,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:4,name:"participant_identity",kind:"scalar",T:9}]),tl=ps.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:el,repeated:!0}]),nl=ps.makeMessageType("livekit.SubscriptionPermissionUpdate",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"allowed",kind:"scalar",T:8}]),il=ps.makeMessageType("livekit.RoomMovedResponse",()=>[{no:1,name:"room",kind:"message",T:Ns},{no:2,name:"token",kind:"scalar",T:9},{no:3,name:"participant",kind:"message",T:Ds},{no:4,name:"other_participants",kind:"message",T:Ds,repeated:!0}]),rl=ps.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:Mc},{no:2,name:"subscription",kind:"message",T:Lc},{no:3,name:"publish_tracks",kind:"message",T:Nc,repeated:!0},{no:4,name:"data_channels",kind:"message",T:al,repeated:!0},{no:5,name:"offer",kind:"message",T:Mc},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0},{no:7,name:"datachannel_receive_states",kind:"message",T:ol,repeated:!0}]),ol=ps.makeMessageType("livekit.DataChannelReceiveState",()=>[{no:1,name:"publisher_sid",kind:"scalar",T:9},{no:2,name:"last_seq",kind:"scalar",T:13}]),al=ps.makeMessageType("livekit.DataChannelInfo",()=>[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:13},{no:3,name:"target",kind:"enum",T:ps.getEnumType(kc)}]),sl=ps.makeMessageType("livekit.SimulateScenario",()=>[{no:1,name:"speaker_update",kind:"scalar",T:5,oneof:"scenario"},{no:2,name:"node_failure",kind:"scalar",T:8,oneof:"scenario"},{no:3,name:"migration",kind:"scalar",T:8,oneof:"scenario"},{no:4,name:"server_leave",kind:"scalar",T:8,oneof:"scenario"},{no:5,name:"switch_candidate_protocol",kind:"enum",T:ps.getEnumType(Cc),oneof:"scenario"},{no:6,name:"subscriber_bandwidth",kind:"scalar",T:3,oneof:"scenario"},{no:7,name:"disconnect_signal_on_resume",kind:"scalar",T:8,oneof:"scenario"},{no:8,name:"disconnect_signal_on_resume_no_messages",kind:"scalar",T:8,oneof:"scenario"},{no:9,name:"leave_request_full_reconnect",kind:"scalar",T:8,oneof:"scenario"}]),cl=ps.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),ll=ps.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),ul=ps.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:dl,repeated:!0}]),dl=ps.makeMessageType("livekit.RegionInfo",()=>[{no:1,name:"region",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9},{no:3,name:"distance",kind:"scalar",T:3}]),hl=ps.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:ps.getEnumType(Rs)}]),pl=ps.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:ps.getEnumType(fl)},{no:3,name:"message",kind:"scalar",T:9},{no:4,name:"trickle",kind:"message",T:Pc,oneof:"request"},{no:5,name:"add_track",kind:"message",T:xc,oneof:"request"},{no:6,name:"mute",kind:"message",T:_c,oneof:"request"},{no:7,name:"update_metadata",kind:"message",T:Vc,oneof:"request"},{no:8,name:"update_audio_track",kind:"message",T:jc,oneof:"request"},{no:9,name:"update_video_track",kind:"message",T:Uc,oneof:"request"}]),fl=ps.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"},{no:4,name:"QUEUED"},{no:5,name:"UNSUPPORTED_TYPE"},{no:6,name:"UNCLASSIFIED_ERROR"}]),ml=ps.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),gl=ps.makeMessageType("livekit.ConnectionSettings",()=>[{no:1,name:"auto_subscribe",kind:"scalar",T:8},{no:2,name:"adaptive_stream",kind:"scalar",T:8},{no:3,name:"subscriber_allow_pause",kind:"scalar",T:8,opt:!0},{no:4,name:"disable_ice_lite",kind:"scalar",T:8}]),vl=ps.makeMessageType("livekit.JoinRequest",()=>[{no:1,name:"client_info",kind:"message",T:sc},{no:2,name:"connection_settings",kind:"message",T:gl},{no:3,name:"metadata",kind:"scalar",T:9},{no:4,name:"participant_attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:5,name:"add_track_requests",kind:"message",T:xc,repeated:!0},{no:6,name:"publisher_offer",kind:"message",T:Mc},{no:7,name:"reconnect",kind:"scalar",T:8},{no:8,name:"reconnect_reason",kind:"enum",T:ps.getEnumType(_s)},{no:9,name:"participant_sid",kind:"scalar",T:9},{no:10,name:"sync_state",kind:"message",T:rl}]),yl=ps.makeMessageType("livekit.WrappedJoinRequest",()=>[{no:1,name:"compression",kind:"enum",T:ps.getEnumType(bl)},{no:2,name:"join_request",kind:"scalar",T:12}]),bl=ps.makeEnum("livekit.WrappedJoinRequest.Compression",[{no:0,name:"NONE"},{no:1,name:"GZIP"}]),kl=ps.makeMessageType("livekit.MediaSectionsRequirement",()=>[{no:1,name:"num_audios",kind:"scalar",T:13},{no:2,name:"num_videos",kind:"scalar",T:13}]);function Sl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Cl,Tl={exports:{}};var wl,El,xl,Pl,_l,Rl,Il,Nl=(Cl||(Cl=1,El=Tl.exports,xl=function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],r={},o=null;function a(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(i){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(){for(var n=this.getLevel(),r=0;r<i.length;r++){var o=i[r];this[o]=r<n?e:this.methodFactory(o,n,this.name)}if(this.log=this.debug,typeof console===t&&n<this.levels.SILENT)return"No console available for logging"}function l(e){return function(){typeof console!==t&&(c.call(this),this[e].apply(this,arguments))}}function u(i,r,o){return function(i){return"debug"===i&&(i="log"),typeof console!==t&&("trace"===i&&n?s:void 0!==console[i]?a(console,i):void 0!==console.log?a(console,"log"):e)}(i)||l.apply(this,arguments)}function d(e,n){var a,s,l,d=this,h="loglevel";function p(){var e;if(typeof window!==t&&h){try{e=window.localStorage[h]}catch(o){}if(typeof e===t)try{var n=window.document.cookie,i=encodeURIComponent(h),r=n.indexOf(i+"=");-1!==r&&(e=/^([^;]+)/.exec(n.slice(r+i.length+1))[1])}catch(o){}return void 0===d.levels[e]&&(e=void 0),e}}function f(e){var t=e;if("string"==typeof t&&void 0!==d.levels[t.toUpperCase()]&&(t=d.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=d.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?h+=":"+e:"symbol"==typeof e&&(h=void 0),d.name=e,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=n||u,d.getLevel=function(){return null!=l?l:null!=s?s:a},d.setLevel=function(e,n){return l=f(e),!1!==n&&function(e){var n=(i[e]||"silent").toUpperCase();if(typeof window!==t&&h){try{return void(window.localStorage[h]=n)}catch(r){}try{window.document.cookie=encodeURIComponent(h)+"="+n+";"}catch(r){}}}(l),c.call(d)},d.setDefaultLevel=function(e){s=f(e),p()||d.setLevel(e,!1)},d.resetLevel=function(){l=null,function(){if(typeof window!==t&&h){try{window.localStorage.removeItem(h)}catch(e){}try{window.document.cookie=encodeURIComponent(h)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}(),c.call(d)},d.enableAll=function(e){d.setLevel(d.levels.TRACE,e)},d.disableAll=function(e){d.setLevel(d.levels.SILENT,e)},d.rebuild=function(){if(o!==d&&(a=f(o.getLevel())),c.call(d),o===d)for(var e in r)r[e].rebuild()},a=f(o?o.getLevel():"WARN");var m=p();null!=m&&(l=f(m)),c.call(d)}(o=new d).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=r[e];return t||(t=r[e]=new d(e,o.methodFactory)),t};var h=typeof window!==t?window.log:void 0;return o.noConflict=function(){return typeof window!==t&&window.log===o&&(window.log=h),o},o.getLoggers=function(){return r},o.default=o,o},(wl=Tl).exports?wl.exports=xl():El.log=xl()),Tl.exports);(_l=Pl||(Pl={}))[_l.trace=0]="trace",_l[_l.debug=1]="debug",_l[_l.info=2]="info",_l[_l.warn=3]="warn",_l[_l.error=4]="error",_l[_l.silent=5]="silent",(Il=Rl||(Rl={})).Default="livekit",Il.Room="livekit-room",Il.TokenSource="livekit-token-source",Il.Participant="livekit-participant",Il.Track="livekit-track",Il.Publication="livekit-track-publication",Il.Engine="livekit-engine",Il.Signal="livekit-signal",Il.PCManager="livekit-pc-manager",Il.PCTransport="livekit-pc-transport",Il.E2EE="lk-e2ee";let Ol=Nl.getLogger("livekit");function Ml(e){const t=Nl.getLogger(e);return t.setDefaultLevel(Ol.getLevel()),t}Object.values(Rl).map(e=>Nl.getLogger(e)),Ol.setDefaultLevel(Pl.info);const Dl=Nl.getLogger("lk-e2ee"),Ll=7e3,Al=[0,300,1200,2700,4800,Ll,Ll,Ll,Ll,Ll];function jl(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{c(i.next(e))}catch(t){o(t)}}function s(e){try{c(i.throw(e))}catch(t){o(t)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((i=i.apply(e,t||[])).next())})}function Ul(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Fl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=Ul(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise(function(i,r){(function(e,t,n,i){Promise.resolve(i).then(function(t){e({value:t,done:n})},t)})(i,r,(t=e[n](t)).done,t.value)})}}}"function"==typeof SuppressedError&&SuppressedError;var Bl,zl={exports:{}};var Vl=function(){if(Bl)return zl.exports;Bl=1;var e,t="object"==typeof Reflect?Reflect:null,n=t&&"function"==typeof t.apply?t.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};e=t&&"function"==typeof t.ownKeys?t.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function r(){r.init.call(this)}zl.exports=r,zl.exports.once=function(e,t){return new Promise(function(n,i){function r(n){e.removeListener(t,o),i(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),n([].slice.call(arguments))}f(e,t,o,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&f(e,"error",t,n)}(e,r,{once:!0})})},r.EventEmitter=r,r.prototype._events=void 0,r.prototype._eventsCount=0,r.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function s(e){return void 0===e._maxListeners?r.defaultMaxListeners:e._maxListeners}function c(e,t,n,i){var r,o,c,l;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),c=o[t]),void 0===c)c=o[t]=n,++e._eventsCount;else if("function"==typeof c?c=o[t]=i?[n,c]:[c,n]:i?c.unshift(n):c.push(n),(r=s(e))>0&&c.length>r&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=c.length,l=u,console&&console.warn&&console.warn(l)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=l.bind(i);return r.listener=n,i.wrapFn=r,r}function d(e,t,n){var i=e._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(r):p(r,r.length)}function h(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),i=0;i<t;++i)n[i]=e[i];return n}function f(e,t,n,i){if("function"==typeof e.on)i.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function r(o){i.once&&e.removeEventListener(t,r),n(o)})}}return Object.defineProperty(r,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),r.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},r.prototype.getMaxListeners=function(){return s(this)},r.prototype.emit=function(e){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r="error"===e,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var l=c.length,u=p(c,l);for(i=0;i<l;++i)n(u[i],this,t)}return!0},r.prototype.addListener=function(e,t){return c(this,e,t,!1)},r.prototype.on=r.prototype.addListener,r.prototype.prependListener=function(e,t){return c(this,e,t,!0)},r.prototype.once=function(e,t){return a(t),this.on(e,u(this,e,t)),this},r.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,u(this,e,t)),this},r.prototype.removeListener=function(e,t){var n,i,r,o,s;if(a(t),void 0===(i=this._events))return this;if(void 0===(n=i[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(r=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,r=o;break}if(r<0)return this;0===r?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,r),1===n.length&&(i[e]=n[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},r.prototype.off=r.prototype.removeListener,r.prototype.removeAllListeners=function(e){var t,n,i;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var r,o=Object.keys(n);for(i=0;i<o.length;++i)"removeListener"!==(r=o[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},r.prototype.listeners=function(e){return d(this,e,!0)},r.prototype.rawListeners=function(e){return d(this,e,!1)},r.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},r.prototype.listenerCount=h,r.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]},zl.exports}();let ql=!0,Hl=!0;function Wl(e,t,n){const i=e.match(t);return i&&i.length>=n&&parseFloat(i[n],10)}function Kl(e,t,n){if(!e.RTCPeerConnection)return;const i=e.RTCPeerConnection.prototype,r=i.addEventListener;i.addEventListener=function(e,i){if(e!==t)return r.apply(this,arguments);const o=e=>{const t=n(e);t&&(i.handleEvent?i.handleEvent(t):i(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(i,o),r.apply(this,[e,o])};const o=i.removeEventListener;i.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const i=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,i])},Object.defineProperty(i,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function Gl(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(ql=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function $l(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(Hl=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Jl(){if("object"==typeof window){if(ql)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Ql(e,t){Hl&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Yl(e){return"[object Object]"===Object.prototype.toString.call(e)}function Xl(e){return Yl(e)?Object.keys(e).reduce(function(t,n){const i=Yl(e[n]),r=i?Xl(e[n]):e[n],o=i&&!Object.keys(r).length;return void 0===r||o?t:Object.assign(t,{[n]:r})},{}):e}function Zl(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach(i=>{i.endsWith("Id")?Zl(e,e.get(t[i]),n):i.endsWith("Ids")&&t[i].forEach(t=>{Zl(e,e.get(t),n)})}))}function eu(e,t,n){const i=n?"outbound-rtp":"inbound-rtp",r=new Map;if(null===t)return r;const o=[];return e.forEach(e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)}),o.forEach(t=>{e.forEach(n=>{n.type===i&&n.trackId===t.id&&Zl(e,n,r)})}),r}const tu=Jl;function nu(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const i=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach(n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const i="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==i.exact&&"number"==typeof i.exact&&(i.min=i.max=i.exact);const r=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==i.ideal){t.optional=t.optional||[];let e={};"number"==typeof i.ideal?(e[r("min",n)]=i.ideal,t.optional.push(e),e={},e[r("max",n)]=i.ideal,t.optional.push(e)):(e[r("",n)]=i.ideal,t.optional.push(e))}void 0!==i.exact&&"number"!=typeof i.exact?(t.mandatory=t.mandatory||{},t.mandatory[r("",n)]=i.exact):["min","max"].forEach(e=>{void 0!==i[e]&&(t.mandatory=t.mandatory||{},t.mandatory[r(e,n)]=i[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},r=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=i(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const a=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then(n=>{let a=(n=n.filter(e=>"videoinput"===e.kind)).find(e=>t.some(t=>e.label.toLowerCase().includes(t)));return!a&&n.length&&t.includes("back")&&(a=n[n.length-1]),a&&(e.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=i(e.video),tu("chrome: "+JSON.stringify(e)),r(e)})}e.video=i(e.video)}return tu("chrome: "+JSON.stringify(e)),r(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,i){r(e,e=>{n.webkitGetUserMedia(e,t,e=>{i&&i(o(e))})})}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return r(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop()}),new DOMException("","NotFoundError");return e},e=>Promise.reject(o(e))))}}}function iu(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function ru(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",n=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===n.track.id):{track:n.track};const r=new Event("track");r.track=n.track,r.receiver=i,r.transceiver={receiver:i},r.streams=[t.stream],this.dispatchEvent(r)}),t.stream.getTracks().forEach(n=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===n.id):{track:n};const r=new Event("track");r.track=n,r.receiver=i,r.transceiver={receiver:i},r.streams=[t.stream],this.dispatchEvent(r)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Kl(e,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function ou(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){let r=n.apply(this,arguments);return r||(r=t(this,e),this._senders.push(r)),r};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){i.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach(e=>{const t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),1)})}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function au(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>eu(t,e.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),Kl(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then(t=>eu(t,e.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,n,i;return this.getSenders().forEach(n=>{n.track===e&&(t?i=!0:t=n)}),this.getReceivers().forEach(t=>(t.track===e&&(n?i=!0:n=t),t.track===e)),i||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function su(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const i=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(i)&&this._shimmedLocalStreams[n.id].push(i):this._shimmedLocalStreams[n.id]=[n,i],i};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")});const t=this.getSenders();n.apply(this,arguments);const i=this.getSenders().filter(e=>-1===t.indexOf(e));this._shimmedLocalStreams[e.id]=[e].concat(i)};const i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],i.apply(this,arguments)};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{const n=this._shimmedLocalStreams[t].indexOf(e);-1!==n&&this._shimmedLocalStreams[t].splice(n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]}),r.apply(this,arguments)}}function cu(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return su(e);const n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[t.id]){const n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}i.apply(this,[t])};const r=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const i=e._reverseStreams[t],r=e._streams[i.id];n=n.replace(new RegExp(r.id,"g"),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find(e=>e===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(e=>e.track===t))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const r=this._streams[n.id];if(r)r.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const i=new e.MediaStream([t]);this._streams[n.id]=i,this._reverseStreams[i.id]=n,this.addStream(i)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[t=>{const n=o(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then(e=>o(this,e))}};e.RTCPeerConnection.prototype[t]=i[t]});const a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{const i=e._reverseStreams[t],r=e._streams[i.id];n=n.replace(new RegExp(i.id,"g"),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};const s=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=s.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(n=>{this._streams[n].getTracks().find(t=>e.track===t)&&(t=this._streams[n])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function lu(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]})}function uu(e,t){Kl(e,"negotiationneeded",e=>{const n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e})}var du=Object.freeze({__proto__:null,fixNegotiationNeeded:uu,shimAddTrackRemoveTrack:cu,shimAddTrackRemoveTrackWithNative:su,shimGetSendersWithDtmf:ou,shimGetUserMedia:nu,shimMediaStream:iu,shimOnTrack:ru,shimPeerConnection:lu,shimSenderReceiverGetStats:au});function hu(e,t){const n=e&&e.navigator,i=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,i){Ql("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,i)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return"object"==typeof n&&"object"==typeof n.audio&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,"autoGainControl","mozAutoGainControl"),e(n.audio,"noiseSuppression","mozNoiseSuppression")),t(n)},i&&i.prototype.getSettings){const t=i.prototype.getSettings;i.prototype.getSettings=function(){const n=t.apply(this,arguments);return e(n,"mozAutoGainControl","autoGainControl"),e(n,"mozNoiseSuppression","noiseSuppression"),n}}if(i&&i.prototype.applyConstraints){const t=i.prototype.applyConstraints;i.prototype.applyConstraints=function(n){return"audio"===this.kind&&"object"==typeof n&&(n=JSON.parse(JSON.stringify(n)),e(n,"autoGainControl","mozAutoGainControl"),e(n,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[n])}}}}function pu(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function fu(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(t){const n=e.RTCPeerConnection.prototype[t],i={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=i[t]});const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,r,o]=arguments;return i.apply(this,[e||null]).then(e=>{if(t.version<53&&!r)try{e.forEach(e=>{e.type=n[e.type]||e.type})}catch(i){if("TypeError"!==i.name)throw i;e.forEach((t,i)=>{e.set(i,Object.assign({},t,{type:n[t.type]||t.type}))})}return e}).then(r,o)}}function mu(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function gu(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),Kl(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function vu(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){Ql("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function yu(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function bu(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const n=e.length>0;n&&e.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const i=t.apply(this,arguments);if(n){const{sender:t}=i,n=t.getParameters();(!("encodings"in n)||1===n.encodings.length&&0===Object.keys(n.encodings[0]).length)&&(n.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(n).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return i})}function ku(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Su(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function Cu(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}var Tu=Object.freeze({__proto__:null,shimAddTransceiver:bu,shimCreateAnswer:Cu,shimCreateOffer:Su,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})},shimGetParameters:ku,shimGetUserMedia:hu,shimOnTrack:pu,shimPeerConnection:fu,shimRTCDataChannel:yu,shimReceiverGetStats:gu,shimRemoveStream:vu,shimSenderGetStats:mu});function wu(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(n=>t.call(this,n,e)),e.getVideoTracks().forEach(n=>t.call(this,n,e))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return i&&i.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach(e=>{n.includes(e.track)&&this.removeTrack(e)})})}}function Eu(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)})})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const n=new Event("addstream");n.stream=t,e.dispatchEvent(n)})}),t.apply(e,arguments)}}}function xu(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,n=t.createOffer,i=t.createAnswer,r=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],r=n.apply(this,[i]);return t?(r.then(e,t),Promise.resolve()):r},t.createAnswer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],r=i.apply(this,[n]);return t?(r.then(e,t),Promise.resolve()):r};let s=function(e,t,n){const i=r.apply(this,[e]);return n?(i.then(t,n),Promise.resolve()):i};t.setLocalDescription=s,s=function(e,t,n){const i=o.apply(this,[e]);return n?(i.then(t,n),Promise.resolve()):i},t.setRemoteDescription=s,s=function(e,t,n){const i=a.apply(this,[e]);return n?(i.then(t,n),Promise.resolve()):i},t.addIceCandidate=s}function Pu(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n(_u(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,i){t.mediaDevices.getUserMedia(e).then(n,i)}.bind(t))}function _u(e){return e&&void 0!==e.video?Object.assign({},e,{video:Xl(e.video)}):e}function Ru(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){const t=[];for(let n=0;n<e.iceServers.length;n++){let i=e.iceServers[n];void 0===i.urls&&i.url?(Ql("RTCIceServer.url","RTCIceServer.urls"),i=JSON.parse(JSON.stringify(i)),i.urls=i.url,delete i.url,t.push(i)):t.push(e.iceServers[n])}e.iceServers=t}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function Iu(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Nu(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const n=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Ou(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Mu,Du=Object.freeze({__proto__:null,shimAudioContext:Ou,shimCallbacksAPI:xu,shimConstraints:_u,shimCreateOfferLegacy:Nu,shimGetUserMedia:Pu,shimLocalStreamsAPI:wu,shimRTCIceServerUrls:Ru,shimRemoteStreamsAPI:Eu,shimTrackEventTransceiver:Iu}),Lu={exports:{}};var Au=(Mu||(Mu=1,function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map(e=>e.trim())},t.splitSections=function(e){return e.split("\nm=").map((e,t)=>(t>0?"m="+e:e).trim()+"\r\n")},t.getDescription=function(e){const n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){const n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter(e=>0===e.indexOf(n))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const n={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let i=8;i<t.length;i+=2)switch(t[i]){case"raddr":n.relatedAddress=t[i+1];break;case"rport":n.relatedPort=parseInt(t[i+1],10);break;case"tcptype":n.tcpType=t[i+1];break;case"ufrag":n.ufrag=t[i+1],n.usernameFragment=t[i+1];break;default:void 0===n[t[i]]&&(n[t[i]]=t[i+1])}return n},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const n=e.component;"rtp"===n?t.push(1):"rtcp"===n?t.push(2):t.push(n),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const i=e.type;return t.push("typ"),t.push(i),"host"!==i&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let n;const i=e.substring(e.indexOf(" ")+1).split(";");for(let r=0;r<i.length;r++)n=i[r].trim().split("="),t[n[0].trim()]=n[1];return t},t.writeFmtp=function(e){let t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const i=[];Object.keys(e.parameters).forEach(t=>{void 0!==e.parameters[t]?i.push(t+"="+e.parameters[t]):i.push(t)}),t+="a=fmtp:"+n+" "+i.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(e=>{t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),n={ssrc:parseInt(e.substring(7,t),10)},i=e.indexOf(":",t);return i>-1?(n.attribute=e.substring(t+1,i),n.value=e.substring(i+1)):n.attribute=e.substring(t+1),n},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map(e=>parseInt(e,10))}},t.getMid=function(e){const n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(e=>{n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){const i=t.matchPrefix(e+n,"a=ice-ufrag:")[0],r=t.matchPrefix(e+n,"a=ice-pwd:")[0];return i&&r?{usernameFragment:i.substring(12),password:r.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=t.splitLines(e)[0].split(" ");n.profile=i[2];for(let o=3;o<i.length;o++){const r=i[o],a=t.matchPrefix(e,"a=rtpmap:"+r+" ")[0];if(a){const i=t.parseRtpMap(a),o=t.matchPrefix(e,"a=fmtp:"+r+" ");switch(i.parameters=o.length?t.parseFmtp(o[0]):{},i.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+r+" ").map(t.parseRtcpFb),n.codecs.push(i),i.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(i.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach(e=>{n.headerExtensions.push(t.parseExtmap(e))});const r=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return n.codecs.forEach(e=>{r.forEach(t=>{e.rtcpFeedback.find(e=>e.type===t.type&&e.parameter===t.parameter)||e.rtcpFeedback.push(t)})}),n},t.writeRtpDescription=function(e,n){let i="";i+="m="+e+" ",i+=n.codecs.length>0?"9":"0",i+=" "+(n.profile||"UDP/TLS/RTP/SAVPF")+" ",i+=n.codecs.map(e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType).join(" ")+"\r\n",i+="c=IN IP4 0.0.0.0\r\n",i+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach(e=>{i+=t.writeRtpMap(e),i+=t.writeFmtp(e),i+=t.writeRtcpFb(e)});let r=0;return n.codecs.forEach(e=>{e.maxptime>r&&(r=e.maxptime)}),r>0&&(i+="a=maxptime:"+r+"\r\n"),n.headerExtensions&&n.headerExtensions.forEach(e=>{i+=t.writeExtmap(e)}),i},t.parseRtpEncodingParameters=function(e){const n=[],i=t.parseRtpParameters(e),r=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map(e=>t.parseSsrcMedia(e)).filter(e=>"cname"===e.attribute),s=a.length>0&&a[0].ssrc;let c;const l=t.matchPrefix(e,"a=ssrc-group:FID").map(e=>e.substring(17).split(" ").map(e=>parseInt(e,10)));l.length>0&&l[0].length>1&&l[0][0]===s&&(c=l[0][1]),i.codecs.forEach(e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&c&&(t.rtx={ssrc:c}),n.push(t),r&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:s,mechanism:o?"red+ulpfec":"red"},n.push(t))}}),0===n.length&&s&&n.push({ssrc:s});let u=t.matchPrefix(e,"b=");return u.length&&(u=0===u[0].indexOf("b=TIAS:")?parseInt(u[0].substring(7),10):0===u[0].indexOf("b=AS:")?1e3*parseInt(u[0].substring(5),10)*.95-16e3:void 0,n.forEach(e=>{e.maxBitrate=u})),n},t.parseRtcpParameters=function(e){const n={},i=t.matchPrefix(e,"a=ssrc:").map(e=>t.parseSsrcMedia(e)).filter(e=>"cname"===e.attribute)[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);const r=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=r.length>0,n.compound=0===r.length;const o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let n;const i=t.matchPrefix(e,"a=msid:");if(1===i.length)return n=i[0].substring(7).split(" "),{stream:n[0],track:n[1]};const r=t.matchPrefix(e,"a=ssrc:").map(e=>t.parseSsrcMedia(e)).filter(e=>"msid"===e.attribute);return r.length>0?(n=r[0].value.split(" "),{stream:n[0],track:n[1]}):void 0},t.parseSctpDescription=function(e){const n=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");let r;i.length>0&&(r=parseInt(i[0].substring(19),10)),isNaN(r)&&(r=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:n.fmt,maxMessageSize:r};const a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){const e=a[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){let n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,n,i){let r;const o=void 0!==n?n:2;return r=e||t.generateSessionId(),"v=0\r\no="+(i||"thisisadapterortc")+" "+r+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,n){const i=t.splitLines(e);for(let t=0;t<i.length;t++)switch(i[t]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[t].substring(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const n=t.splitLines(e)[0].substring(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){const n=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const n=t.splitLines(e);for(let t=0;t<n.length;t++)if(n[t].length<2||"="!==n[t].charAt(1))return!1;return!0},e.exports=t}(Lu)),Lu.exports),ju=Sl(Au),Uu=No({__proto__:null,default:ju},[Au]);function Fu(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){const n=new t(e),i=ju.parseCandidate(e.candidate);for(const e in i)e in n||Object.defineProperty(n,e,{value:i[e]});return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,Kl(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function Bu(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||Kl(e,"icecandidate",e=>{if(e.candidate){const t=ju.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e})}function zu(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=ju.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=ju.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),n=function(e){let n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n}(e),i=function(e,n){let i=65536;"firefox"===t.browser&&57===t.version&&(i=65535);const r=ju.matchPrefix(e.sdp,"a=max-message-size:");return r.length>0?i=parseInt(r[0].substring(19),10):"firefox"===t.browser&&-1!==n&&(i=2147483637),i}(arguments[0],e);let r;r=0===n&&0===i?Number.POSITIVE_INFINITY:0===n||0===i?Math.max(n,i):Math.min(n,i);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>r}),this._sctp=o}return n.apply(this,arguments)}}function Vu(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const n=e.send;e.send=function(){const i=arguments[0],r=i.length||i.size||i.byteLength;if("open"===e.readyState&&t.sctp&&r>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return t(e,this),e},Kl(e,"datachannel",e=>(t(e.channel,e.target),e))}function qu(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}})}function Hu(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t._safariVersion>=13.1)return;const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const n=t.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function Wu(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function Ku(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.setLocalDescription;n&&0!==n.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return n.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}if(e.sdp||"offer"!==e.type&&"answer"!==e.type)return n.apply(this,[e]);return("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then(e=>n.apply(this,[e]))})}var Gu=Object.freeze({__proto__:null,removeExtmapAllowMixed:Hu,shimAddIceCandidateNullOrEmpty:Wu,shimConnectionState:qu,shimMaxMessageSize:zu,shimParameterlessSetLocalDescription:Ku,shimRTCIceCandidate:Fu,shimRTCIceCandidateRelayProtocol:Bu,shimSendThrowTypeError:Vu});!function(){let{window:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const n=Jl,i=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:n}=e;if(n.userAgentData&&n.userAgentData.brands){const e=n.userAgentData.brands.find(e=>"Chromium"===e.brand);if(e)return{browser:"chrome",version:parseInt(e.version,10)}}if(n.mozGetUserMedia)t.browser="firefox",t.version=parseInt(Wl(n.userAgent,/Firefox\/(\d+)\./,1));else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=parseInt(Wl(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2));else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=parseInt(Wl(n.userAgent,/AppleWebKit\/(\d+)\./,1)),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype,t._safariVersion=Wl(n.userAgent,/Version\/(\d+(\.?\d+))/,1)}return t}(e),r={browserDetails:i,commonShim:Gu,extractVersion:Wl,disableLog:Gl,disableWarnings:$l,sdp:Uu};switch(i.browser){case"chrome":if(!du||!lu||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),r;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),r;n("adapter.js shimming chrome."),r.browserShim=du,Wu(e,i),Ku(e),nu(e,i),iu(e),lu(e,i),ru(e),cu(e,i),ou(e),au(e),uu(e,i),Fu(e),Bu(e),qu(e),zu(e,i),Vu(e),Hu(e,i);break;case"firefox":if(!Tu||!fu||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),r;n("adapter.js shimming firefox."),r.browserShim=Tu,Wu(e,i),Ku(e),hu(e,i),fu(e,i),pu(e),vu(e),mu(e),gu(e),yu(e),bu(e),ku(e),Su(e),Cu(e),Fu(e),qu(e),zu(e,i),Vu(e);break;case"safari":if(!Du||!t.shimSafari)return n("Safari shim is not included in this adapter release."),r;n("adapter.js shimming safari."),r.browserShim=Du,Wu(e,i),Ku(e),Ru(e),Nu(e),xu(e),wu(e),Eu(e),Iu(e),Pu(e),Ou(e),Fu(e),Bu(e),zu(e,i),Vu(e),Hu(e,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});class $u extends Promise{constructor(e){super(e)}catch(e){return super.catch(e)}static reject(e){return super.reject(e)}static all(e){return super.all(e)}static race(e){return super.race(e)}}const Ju=/version\/(\d+(\.?_?\d+)+)/i;let Qu;function Yu(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if("undefined"==typeof navigator)return;const n=navigator.userAgent.toLowerCase();if(void 0===Qu||t){const e=Xu.find(e=>{let{test:t}=e;return t.test(n)});Qu=null==e?void 0:e.describe(n)}return Qu}const Xu=[{test:/firefox|iceweasel|fxios/i,describe:e=>({name:"Firefox",version:Zu(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e),os:e.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:ed(e)})},{test:/chrom|crios|crmo/i,describe:e=>({name:"Chrome",version:Zu(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e),os:e.toLowerCase().includes("crios")?"iOS":void 0,osVersion:ed(e)})},{test:/safari|applewebkit/i,describe:e=>({name:"Safari",version:Zu(Ju,e),os:e.includes("mobile/")?"iOS":"macOS",osVersion:ed(e)})}];function Zu(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const i=t.match(e);return i&&i.length>=n&&i[n]||""}function ed(e){return e.includes("mac os")?Zu(/\(.+?(\d+_\d+(:?_\d+)?)/,e,1).replace(/_/g,"."):void 0}class td extends Error{constructor(e,t){super(t||"an error has occured"),this.name="LiveKitError",this.code=e}}var nd,id,rd,od,ad,sd,cd,ld,ud,dd,hd,pd,fd,md;(id=nd||(nd={}))[id.NotAllowed=0]="NotAllowed",id[id.ServerUnreachable=1]="ServerUnreachable",id[id.InternalError=2]="InternalError",id[id.Cancelled=3]="Cancelled",id[id.LeaveRequest=4]="LeaveRequest",id[id.Timeout=5]="Timeout",id[id.WebSocket=6]="WebSocket",id[id.ServiceNotFound=7]="ServiceNotFound";class gd extends td{constructor(e,t,n,i){super(1,e),this.name="ConnectionError",this.status=n,this.reason=t,this.context=i,this.reasonName=nd[t]}static notAllowed(e,t,n){return new gd(e,nd.NotAllowed,t,n)}static timeout(e){return new gd(e,nd.Timeout)}static leaveRequest(e,t){return new gd(e,nd.LeaveRequest,void 0,t)}static internal(e,t){return new gd(e,nd.InternalError,void 0,t)}static cancelled(e){return new gd(e,nd.Cancelled)}static serverUnreachable(e,t){return new gd(e,nd.ServerUnreachable,t)}static websocket(e,t,n){return new gd(e,nd.WebSocket,t,n)}static serviceNotFound(e,t){return new gd(e,nd.ServiceNotFound,void 0,t)}}class vd extends td{constructor(e){super(21,null!=e?e:"device is unsupported"),this.name="DeviceUnsupportedError"}}class yd extends td{constructor(e){super(20,null!=e?e:"track is invalid"),this.name="TrackInvalidError"}}class bd extends td{constructor(e){super(10,null!=e?e:"unsupported server"),this.name="UnsupportedServer"}}class kd extends td{constructor(e){super(12,null!=e?e:"unexpected connection state"),this.name="UnexpectedConnectionState"}}class Sd extends td{constructor(e){super(13,null!=e?e:"unable to negotiate"),this.name="NegotiationError"}}class Cd extends td{constructor(e,t){super(15,e),this.name="PublishTrackError",this.status=t}}class Td extends td{constructor(e,t){super(15,e),this.name="SignalRequestError",this.reason=t,this.reasonName="string"==typeof t?t:fl[t]}}(od=rd||(rd={}))[od.AlreadyOpened=0]="AlreadyOpened",od[od.AbnormalEnd=1]="AbnormalEnd",od[od.DecodeFailed=2]="DecodeFailed",od[od.LengthExceeded=3]="LengthExceeded",od[od.Incomplete=4]="Incomplete",od[od.HandlerAlreadyRegistered=7]="HandlerAlreadyRegistered",od[od.EncryptionTypeMismatch=8]="EncryptionTypeMismatch";class wd extends td{constructor(e,t){super(16,e),this.name="DataStreamError",this.reason=t,this.reasonName=rd[t]}}class Ed extends td{constructor(e){super(18,e),this.name="SignalReconnectError"}}(sd=ad||(ad={})).PermissionDenied="PermissionDenied",sd.NotFound="NotFound",sd.DeviceInUse="DeviceInUse",sd.Other="Other",function(e){e.getFailure=function(t){if(t&&"name"in t)return"NotFoundError"===t.name||"DevicesNotFoundError"===t.name?e.NotFound:"NotAllowedError"===t.name||"PermissionDeniedError"===t.name?e.PermissionDenied:"NotReadableError"===t.name||"TrackStartError"===t.name?e.DeviceInUse:e.Other}}(ad||(ad={}));class xd{}xd.setTimeout=function(){return setTimeout(...arguments)},xd.setInterval=function(){return setInterval(...arguments)},xd.clearTimeout=function(){return clearTimeout(...arguments)},xd.clearInterval=function(){return clearInterval(...arguments)},(ld=cd||(cd={})).Connected="connected",ld.Reconnecting="reconnecting",ld.SignalReconnecting="signalReconnecting",ld.Reconnected="reconnected",ld.Disconnected="disconnected",ld.ConnectionStateChanged="connectionStateChanged",ld.Moved="moved",ld.MediaDevicesChanged="mediaDevicesChanged",ld.ParticipantConnected="participantConnected",ld.ParticipantDisconnected="participantDisconnected",ld.TrackPublished="trackPublished",ld.TrackSubscribed="trackSubscribed",ld.TrackSubscriptionFailed="trackSubscriptionFailed",ld.TrackUnpublished="trackUnpublished",ld.TrackUnsubscribed="trackUnsubscribed",ld.TrackMuted="trackMuted",ld.TrackUnmuted="trackUnmuted",ld.LocalTrackPublished="localTrackPublished",ld.LocalTrackUnpublished="localTrackUnpublished",ld.LocalAudioSilenceDetected="localAudioSilenceDetected",ld.ActiveSpeakersChanged="activeSpeakersChanged",ld.ParticipantMetadataChanged="participantMetadataChanged",ld.ParticipantNameChanged="participantNameChanged",ld.ParticipantAttributesChanged="participantAttributesChanged",ld.ParticipantActive="participantActive",ld.RoomMetadataChanged="roomMetadataChanged",ld.DataReceived="dataReceived",ld.SipDTMFReceived="sipDTMFReceived",ld.TranscriptionReceived="transcriptionReceived",ld.ConnectionQualityChanged="connectionQualityChanged",ld.TrackStreamStateChanged="trackStreamStateChanged",ld.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",ld.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",ld.AudioPlaybackStatusChanged="audioPlaybackChanged",ld.VideoPlaybackStatusChanged="videoPlaybackChanged",ld.MediaDevicesError="mediaDevicesError",ld.ParticipantPermissionsChanged="participantPermissionsChanged",ld.SignalConnected="signalConnected",ld.RecordingStatusChanged="recordingStatusChanged",ld.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",ld.EncryptionError="encryptionError",ld.DCBufferStatusChanged="dcBufferStatusChanged",ld.ActiveDeviceChanged="activeDeviceChanged",ld.ChatMessage="chatMessage",ld.LocalTrackSubscribed="localTrackSubscribed",ld.MetricsReceived="metricsReceived",(dd=ud||(ud={})).TrackPublished="trackPublished",dd.TrackSubscribed="trackSubscribed",dd.TrackSubscriptionFailed="trackSubscriptionFailed",dd.TrackUnpublished="trackUnpublished",dd.TrackUnsubscribed="trackUnsubscribed",dd.TrackMuted="trackMuted",dd.TrackUnmuted="trackUnmuted",dd.LocalTrackPublished="localTrackPublished",dd.LocalTrackUnpublished="localTrackUnpublished",dd.LocalTrackCpuConstrained="localTrackCpuConstrained",dd.LocalSenderCreated="localSenderCreated",dd.ParticipantMetadataChanged="participantMetadataChanged",dd.ParticipantNameChanged="participantNameChanged",dd.DataReceived="dataReceived",dd.SipDTMFReceived="sipDTMFReceived",dd.TranscriptionReceived="transcriptionReceived",dd.IsSpeakingChanged="isSpeakingChanged",dd.ConnectionQualityChanged="connectionQualityChanged",dd.TrackStreamStateChanged="trackStreamStateChanged",dd.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",dd.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",dd.TrackCpuConstrained="trackCpuConstrained",dd.MediaDevicesError="mediaDevicesError",dd.AudioStreamAcquired="audioStreamAcquired",dd.ParticipantPermissionsChanged="participantPermissionsChanged",dd.PCTrackAdded="pcTrackAdded",dd.AttributesChanged="attributesChanged",dd.LocalTrackSubscribed="localTrackSubscribed",dd.ChatMessage="chatMessage",dd.Active="active",(pd=hd||(hd={})).TransportsCreated="transportsCreated",pd.Connected="connected",pd.Disconnected="disconnected",pd.Resuming="resuming",pd.Resumed="resumed",pd.Restarting="restarting",pd.Restarted="restarted",pd.SignalResumed="signalResumed",pd.SignalRestarted="signalRestarted",pd.Closing="closing",pd.MediaTrackAdded="mediaTrackAdded",pd.ActiveSpeakersUpdate="activeSpeakersUpdate",pd.DataPacketReceived="dataPacketReceived",pd.RTPVideoMapUpdate="rtpVideoMapUpdate",pd.DCBufferStatusChanged="dcBufferStatusChanged",pd.ParticipantUpdate="participantUpdate",pd.RoomUpdate="roomUpdate",pd.SpeakersChanged="speakersChanged",pd.StreamStateChanged="streamStateChanged",pd.ConnectionQualityUpdate="connectionQualityUpdate",pd.SubscriptionError="subscriptionError",pd.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",pd.RemoteMute="remoteMute",pd.SubscribedQualityUpdate="subscribedQualityUpdate",pd.LocalTrackUnpublished="localTrackUnpublished",pd.LocalTrackSubscribed="localTrackSubscribed",pd.Offline="offline",pd.SignalRequestResponse="signalRequestResponse",pd.SignalConnected="signalConnected",pd.RoomMoved="roomMoved",(md=fd||(fd={})).Message="message",md.Muted="muted",md.Unmuted="unmuted",md.Restarted="restarted",md.Ended="ended",md.Subscribed="subscribed",md.Unsubscribed="unsubscribed",md.CpuConstrained="cpuConstrained",md.UpdateSettings="updateSettings",md.UpdateSubscription="updateSubscription",md.AudioPlaybackStarted="audioPlaybackStarted",md.AudioPlaybackFailed="audioPlaybackFailed",md.AudioSilenceDetected="audioSilenceDetected",md.VisibilityChanged="visibilityChanged",md.VideoDimensionsChanged="videoDimensionsChanged",md.VideoPlaybackStarted="videoPlaybackStarted",md.VideoPlaybackFailed="videoPlaybackFailed",md.ElementAttached="elementAttached",md.ElementDetached="elementDetached",md.UpstreamPaused="upstreamPaused",md.UpstreamResumed="upstreamResumed",md.SubscriptionPermissionChanged="subscriptionPermissionChanged",md.SubscriptionStatusChanged="subscriptionStatusChanged",md.SubscriptionFailed="subscriptionFailed",md.TrackProcessorUpdate="trackProcessorUpdate",md.AudioTrackFeatureUpdate="audioTrackFeatureUpdate",md.TranscriptionReceived="transcriptionReceived",md.TimeSyncUpdate="timeSyncUpdate",md.PreConnectBufferFlushed="preConnectBufferFlushed";class Pd{constructor(e,t,n,i,r){if("object"==typeof e)this.width=e.width,this.height=e.height,this.aspectRatio=e.aspectRatio,this.encoding={maxBitrate:e.maxBitrate,maxFramerate:e.maxFramerate,priority:e.priority};else{if(void 0===t||void 0===n)throw new TypeError("Unsupported options: provide at least width, height and maxBitrate");this.width=e,this.height=t,this.aspectRatio=e/t,this.encoding={maxBitrate:n,maxFramerate:i,priority:r}}}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}const _d=["vp8","h264"],Rd=["vp8","h264","vp9","av1","h265"];const Id=function(e){return!!_d.find(t=>t===e)};var Nd,Od,Md,Dd;(Od=Nd||(Nd={}))[Od.PREFER_REGRESSION=0]="PREFER_REGRESSION",Od[Od.SIMULCAST=1]="SIMULCAST",Od[Od.REGRESSION=2]="REGRESSION",(Dd=Md||(Md={})).telephone={maxBitrate:12e3},Dd.speech={maxBitrate:24e3},Dd.music={maxBitrate:48e3},Dd.musicStereo={maxBitrate:64e3},Dd.musicHighQuality={maxBitrate:96e3},Dd.musicHighQualityStereo={maxBitrate:128e3};const Ld={h90:new Pd(160,90,9e4,20),h180:new Pd(320,180,16e4,20),h216:new Pd(384,216,18e4,20),h360:new Pd(640,360,45e4,20),h540:new Pd(960,540,8e5,25),h720:new Pd(1280,720,17e5,30),h1080:new Pd(1920,1080,3e6,30),h1440:new Pd(2560,1440,5e6,30),h2160:new Pd(3840,2160,8e6,30)},Ad={h120:new Pd(160,120,7e4,20),h180:new Pd(240,180,125e3,20),h240:new Pd(320,240,14e4,20),h360:new Pd(480,360,33e4,20),h480:new Pd(640,480,5e5,20),h540:new Pd(720,540,6e5,25),h720:new Pd(960,720,13e5,30),h1080:new Pd(1440,1080,23e5,30),h1440:new Pd(1920,1440,38e5,30)},jd={h360fps3:new Pd(640,360,2e5,3,"medium"),h360fps15:new Pd(640,360,4e5,15,"medium"),h720fps5:new Pd(1280,720,8e5,5,"medium"),h720fps15:new Pd(1280,720,15e5,15,"medium"),h720fps30:new Pd(1280,720,2e6,30,"medium"),h1080fps15:new Pd(1920,1080,25e5,15,"medium"),h1080fps30:new Pd(1920,1080,5e6,30,"medium"),original:new Pd(0,0,7e6,30,"medium")};function Ud(e,t,n){var i,r,o,a;const{optionsWithoutProcessor:s,audioProcessor:c,videoProcessor:l}=$d(null!=e?e:{}),u=null==t?void 0:t.processor,d=null==n?void 0:n.processor,h=null!=s?s:{};return!0===h.audio&&(h.audio={}),!0===h.video&&(h.video={}),h.audio&&(Fd(h.audio,t),null!==(i=(o=h.audio).deviceId)&&void 0!==i||(o.deviceId={ideal:"default"}),(c||u)&&(h.audio.processor=null!=c?c:u)),h.video&&(Fd(h.video,n),null!==(r=(a=h.video).deviceId)&&void 0!==r||(a.deviceId={ideal:"default"}),(l||d)&&(h.video.processor=null!=l?l:d)),h}function Fd(e,t){return Object.keys(t).forEach(n=>{void 0===e[n]&&(e[n]=t[n])}),e}function Bd(e){var t,n,i,r;const o={};if(e.video)if("object"==typeof e.video){const n={},r=n,a=e.video;Object.keys(a).forEach(e=>{if("resolution"===e)Fd(r,a.resolution);else r[e]=a[e]}),o.video=n,null!==(t=(i=o.video).deviceId)&&void 0!==t||(i.deviceId={ideal:"default"})}else o.video=!!e.video&&{deviceId:{ideal:"default"}};else o.video=!1;return e.audio?"object"==typeof e.audio?(o.audio=e.audio,null!==(n=(r=o.audio).deviceId)&&void 0!==n||(r.deviceId={ideal:"default"})):o.audio={deviceId:{ideal:"default"}}:o.audio=!1,o}function zd(e){return jl(this,arguments,void 0,function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;return function*(){const n=Vd();if(n){const i=n.createAnalyser();i.fftSize=2048;const r=i.frequencyBinCount,o=new Uint8Array(r);n.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(i),yield ih(t),i.getByteTimeDomainData(o);const a=o.some(e=>128!==e&&0!==e);return n.close(),!a}return!1}()})}function Vd(){var e;const t="undefined"!=typeof window&&(window.AudioContext||window.webkitAudioContext);if(t){const n=new t({latencyHint:"interactive"});if("suspended"===n.state&&"undefined"!=typeof window&&(null===(e=window.document)||void 0===e?void 0:e.body)){const e=()=>jl(this,void 0,void 0,function*(){var t;try{"suspended"===n.state&&(yield n.resume())}catch(i){console.warn("Error trying to auto-resume audio context",i)}finally{null===(t=window.document.body)||void 0===t||t.removeEventListener("click",e)}});n.addEventListener("statechange",()=>{var t;"closed"===n.state&&(null===(t=window.document.body)||void 0===t||t.removeEventListener("click",e))}),window.document.body.addEventListener("click",e)}return n}}function qd(e){return"audioinput"===e?Zd.Source.Microphone:"videoinput"===e?Zd.Source.Camera:Zd.Source.Unknown}function Hd(e){return e===Zd.Source.Microphone?"audioinput":e===Zd.Source.Camera?"videoinput":void 0}function Wd(e){return e.split("/")[1].toLowerCase()}function Kd(e){const t=[];return e.forEach(e=>{void 0!==e.track&&t.push(new Nc({cid:e.track.mediaStreamID,track:e.trackInfo}))}),t}function Gd(e){return"mediaStreamTrack"in e?{trackID:e.sid,source:e.source,muted:e.isMuted,enabled:e.mediaStreamTrack.enabled,kind:e.kind,streamID:e.mediaStreamID,streamTrackID:e.mediaStreamTrack.id}:{trackID:e.trackSid,enabled:e.isEnabled,muted:e.isMuted,trackInfo:Object.assign({mimeType:e.mimeType,name:e.trackName,encrypted:e.isEncrypted,kind:e.kind,source:e.source},e.track?Gd(e.track):{})}}function $d(e){const t=Object.assign({},e);let n,i;return"object"==typeof t.audio&&t.audio.processor&&(n=t.audio.processor,t.audio=Object.assign(Object.assign({},t.audio),{processor:void 0})),"object"==typeof t.video&&t.video.processor&&(i=t.video.processor,t.video=Object.assign(Object.assign({},t.video),{processor:void 0})),{audioProcessor:n,videoProcessor:i,optionsWithoutProcessor:(r=t,void 0===r?r:"function"==typeof structuredClone?"object"==typeof r&&null!==r?structuredClone(Object.assign({},r)):structuredClone(r):JSON.parse(JSON.stringify(r)))};var r}function Jd(e,t){return e.width*e.height<t.width*t.height}const Qd=[];var Yd,Xd;(Xd=Yd||(Yd={}))[Xd.LOW=0]="LOW",Xd[Xd.MEDIUM=1]="MEDIUM",Xd[Xd.HIGH=2]="HIGH";class Zd extends Vl.EventEmitter{get streamState(){return this._streamState}setStreamState(e){this._streamState=e}constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i;super(),this.attachedElements=[],this.isMuted=!1,this._streamState=Zd.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=Ol,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),"hidden"===document.visibilityState?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),5e3):this.handleAppVisibilityChanged()},this.log=Ml(null!==(i=n.loggerName)&&void 0!==i?i:Rl.Track),this.loggerContextCb=n.loggerContextCb,this.setMaxListeners(100),this.kind=t,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=Zd.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},null===(e=this.loggerContextCb)||void 0===e?void 0:e.call(this)),Gd(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let t="audio";this.kind===Zd.Kind.Video&&(t="video"),0===this.attachedElements.length&&this.kind===Zd.Kind.Video&&this.addAppVisibilityListener(),e||("audio"===t&&(Qd.forEach(t=>{null!==t.parentElement||e||(e=t)}),e&&Qd.splice(Qd.indexOf(e),1)),e||(e=document.createElement(t))),this.attachedElements.includes(e)||this.attachedElements.push(e),eh(this.mediaStreamTrack,e);const n=e.srcObject.getTracks(),i=n.some(e=>"audio"===e.kind);return e.play().then(()=>{this.emit(i?fd.AudioPlaybackStarted:fd.VideoPlaybackStarted)}).catch(t=>{"NotAllowedError"===t.name?this.emit(i?fd.AudioPlaybackFailed:fd.VideoPlaybackFailed,t):"AbortError"===t.name?Ol.debug("".concat(i?"audio":"video"," playback aborted, likely due to new play request")):Ol.warn("could not playback ".concat(i?"audio":"video"),t),i&&e&&n.some(e=>"video"===e.kind)&&"NotAllowedError"===t.name&&(e.muted=!0,e.play().catch(()=>{}))}),this.emit(fd.ElementAttached,e),e}detach(e){try{if(e){th(this.mediaStreamTrack,e);const t=this.attachedElements.indexOf(e);return t>=0&&(this.attachedElements.splice(t,1),this.recycleElement(e),this.emit(fd.ElementDetached,e)),e}const t=[];return this.attachedElements.forEach(e=>{th(this.mediaStreamTrack,e),t.push(e),this.recycleElement(e),this.emit(fd.ElementDetached,e)}),this.attachedElements=[],t}finally{0===this.attachedElements.length&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=Ml(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let t=!0;e.pause(),Qd.forEach(e=>{e.parentElement||(t=!1)}),t&&Qd.push(e)}}handleAppVisibilityChanged(){return jl(this,void 0,void 0,function*(){this.isInBackground="hidden"===document.visibilityState,this.isInBackground||this.kind!==Zd.Kind.Video||setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){ph()?(this.isInBackground="hidden"===document.visibilityState,document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){ph()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function eh(e,t){let n,i;n=t.srcObject instanceof MediaStream?t.srcObject:new MediaStream,i="audio"===e.kind?n.getAudioTracks():n.getVideoTracks(),i.includes(e)||(i.forEach(e=>{n.removeTrack(e)}),n.addTrack(e)),uh()&&t instanceof HTMLVideoElement||(t.autoplay=!0),t.muted=0===n.getAudioTracks().length,t instanceof HTMLVideoElement&&(t.playsInline=!0),t.srcObject!==n&&(t.srcObject=n,(uh()||ch())&&t instanceof HTMLVideoElement&&setTimeout(()=>{t.srcObject=n,t.play().catch(()=>{})},0))}function th(e,t){if(t.srcObject instanceof MediaStream){const n=t.srcObject;n.removeTrack(e),n.getTracks().length>0?t.srcObject=n:t.srcObject=null}}!function(e){let t;var n;let i;var r;let o;var a;(n=t=e.Kind||(e.Kind={})).Audio="audio",n.Video="video",n.Unknown="unknown",(r=i=e.Source||(e.Source={})).Camera="camera",r.Microphone="microphone",r.ScreenShare="screen_share",r.ScreenShareAudio="screen_share_audio",r.Unknown="unknown",(a=o=e.StreamState||(e.StreamState={})).Active="active",a.Paused="paused",a.Unknown="unknown",e.kindToProto=function(e){switch(e){case t.Audio:return Cs.AUDIO;case t.Video:return Cs.VIDEO;default:return Cs.DATA}},e.kindFromProto=function(e){switch(e){case Cs.AUDIO:return t.Audio;case Cs.VIDEO:return t.Video;default:return t.Unknown}},e.sourceToProto=function(e){switch(e){case i.Camera:return Ts.CAMERA;case i.Microphone:return Ts.MICROPHONE;case i.ScreenShare:return Ts.SCREEN_SHARE;case i.ScreenShareAudio:return Ts.SCREEN_SHARE_AUDIO;default:return Ts.UNKNOWN}},e.sourceFromProto=function(e){switch(e){case Ts.CAMERA:return i.Camera;case Ts.MICROPHONE:return i.Microphone;case Ts.SCREEN_SHARE:return i.ScreenShare;case Ts.SCREEN_SHARE_AUDIO:return i.ScreenShareAudio;default:return i.Unknown}},e.streamStateFromProto=function(e){switch(e){case Sc.ACTIVE:return o.Active;case Sc.PAUSED:return o.Paused;default:return o.Unknown}}}(Zd||(Zd={}));const nh="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function ih(e){return new $u(t=>xd.setTimeout(t,e))}function rh(){return"addTransceiver"in RTCPeerConnection.prototype}function oh(){return"addTrack"in RTCPeerConnection.prototype}function ah(e){return"av1"===e||"vp9"===e}function sh(e){return!(!document||dh())&&(e||(e=document.createElement("audio")),"setSinkId"in e)}function ch(){var e;return"Firefox"===(null===(e=Yu())||void 0===e?void 0:e.name)}function lh(){const e=Yu();return!!e&&"Chrome"===e.name&&"iOS"!==e.os}function uh(){var e;return"Safari"===(null===(e=Yu())||void 0===e?void 0:e.name)}function dh(){const e=Yu();return"Safari"===(null==e?void 0:e.name)||"iOS"===(null==e?void 0:e.os)}function hh(){var e,t;return!!ph()&&(null!==(t=null===(e=navigator.userAgentData)||void 0===e?void 0:e.mobile)&&void 0!==t?t:/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent))}function ph(){return"undefined"!=typeof document}function fh(){return"ReactNative"==navigator.product}function mh(e){return e.hostname.endsWith(".livekit.cloud")||e.hostname.endsWith(".livekit.run")}function gh(e){return mh(e)?e.hostname.split(".")[0]:null}function vh(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function yh(){if(!fh())return;let e=vh();return e?e.platform:void 0}function bh(){if(ph())return window.devicePixelRatio;if(fh()){let e=vh();if(e)return e.devicePixelRatio}return 1}function kh(e,t){const n=e.split("."),i=t.split("."),r=Math.min(n.length,i.length);for(let o=0;o<r;++o){const e=parseInt(n[o],10),t=parseInt(i[o],10);if(e>t)return 1;if(e<t)return-1;if(o===r-1&&e===t)return 0}return""===e&&""!==t?-1:""===t?1:n.length==i.length?0:n.length<i.length?-1:1}function Sh(e){for(const t of e)t.target.handleResize(t)}function Ch(e){for(const t of e)t.target.handleVisibilityChanged(t)}let Th=null;const wh=()=>(Th||(Th=new ResizeObserver(Sh)),Th);let Eh=null;const xh=()=>(Eh||(Eh=new IntersectionObserver(Ch,{root:null,rootMargin:"0px"})),Eh);function Ph(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=document.createElement("canvas");r.width=e,r.height=t;const o=r.getContext("2d");null==o||o.fillRect(0,0,r.width,r.height),i&&o&&(o.beginPath(),o.arc(e/2,t/2,50,0,2*Math.PI,!0),o.closePath(),o.fillStyle="grey",o.fill());const a=r.captureStream(),[s]=a.getTracks();if(!s)throw Error("Could not get empty media stream video track");return s.enabled=n,s}let _h;function Rh(){if(!_h){const e=new AudioContext,t=e.createOscillator(),n=e.createGain();n.gain.setValueAtTime(0,0);const i=e.createMediaStreamDestination();if(t.connect(n),n.connect(i),t.start(),[_h]=i.stream.getAudioTracks(),!_h)throw Error("Could not get empty media stream audio track");_h.enabled=!1}return _h.clone()}class Ih{get isResolved(){return this._isResolved}constructor(e,t){this._isResolved=!1,this.onFinally=t,this.promise=new Promise((t,n)=>jl(this,void 0,void 0,function*(){this.resolve=t,this.reject=n,e&&(yield e(t,n))})).finally(()=>{var e;this._isResolved=!0,null===(e=this.onFinally)||void 0===e||e.call(this)})}}function Nh(e){if("string"==typeof e||"number"==typeof e)return e;if(Array.isArray(e))return e[0];if(void 0!==e.exact)return Array.isArray(e.exact)?e.exact[0]:e.exact;if(void 0!==e.ideal)return Array.isArray(e.ideal)?e.ideal[0]:e.ideal;throw Error("could not unwrap constraint")}function Oh(e){return e.startsWith("ws")?e.replace(/^(ws)/,"http"):e}function Mh(e){switch(e.reason){case nd.LeaveRequest:return e.context;case nd.Cancelled:return Ps.CLIENT_INITIATED;case nd.NotAllowed:return Ps.USER_REJECTED;case nd.ServerUnreachable:return Ps.JOIN_FAILURE;default:return Ps.UNKNOWN_REASON}}function Dh(e){return void 0!==e?Number(e):void 0}function Lh(e){return void 0!==e?BigInt(e):void 0}function Ah(e){return!!e&&!(e instanceof MediaStreamTrack)&&e.isLocal}function jh(e){return!!e&&e.kind==Zd.Kind.Audio}function Uh(e){return!!e&&e.kind==Zd.Kind.Video}function Fh(e){return Ah(e)&&Uh(e)}function Bh(e){return Ah(e)&&jh(e)}function zh(e){return!!e&&!e.isLocal}function Vh(e){return!!e&&!e.isLocal}function qh(e){return zh(e)&&Uh(e)}function Hh(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=function(e,t){const n=new URL(function(e){return e.startsWith("http")?e.replace(/^(http)/,"ws"):e}(e));return t.forEach((e,t)=>{n.searchParams.set(t,e)}),Kh(n,"rtc")}(e,t);return n?i:Kh(i,"v1")}function Wh(e){return e.endsWith("/")?e:"".concat(e,"/")}function Kh(e,t){return e.pathname="".concat(Wh(e.pathname)).concat(t),e}function Gh(e){if("string"==typeof e)return wc.fromJson(JSON.parse(e),{ignoreUnknownFields:!0});if(e instanceof ArrayBuffer)return wc.fromBinary(new Uint8Array(e));throw new Error("could not decode websocket message: ".concat(typeof e))}const $h="lk_e2ee";var Jh,Qh,Yh,Xh,Zh,ep,tp,np;function ip(){return void 0!==window.RTCRtpSender&&void 0!==window.RTCRtpSender.prototype.createEncodedStreams||rp()}function rp(){return void 0!==window.RTCRtpScriptTransform}(Qh=Jh||(Jh={})).SetKey="setKey",Qh.RatchetRequest="ratchetRequest",Qh.KeyRatcheted="keyRatcheted",(Yh||(Yh={})).KeyRatcheted="keyRatcheted",(Zh=Xh||(Xh={})).ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",Zh.EncryptionError="encryptionError",(ep||(ep={})).Error="cryptorError";Vl.EventEmitter;(np=tp||(tp={}))[np.InvalidKey=0]="InvalidKey",np[np.MissingKey=1]="MissingKey",np[np.InternalError=2]="InternalError";class op extends Vl.EventEmitter{constructor(e,t){super(),this.decryptDataRequests=new Map,this.encryptDataRequests=new Map,this.onWorkerMessage=e=>{var t,n;const{kind:i,data:r}=e.data;switch(i){case"error":if(Ol.error(r.error.message),r.uuid){const e=this.decryptDataRequests.get(r.uuid);if(null==e?void 0:e.reject){e.reject(r.error);break}const t=this.encryptDataRequests.get(r.uuid);if(null==t?void 0:t.reject){t.reject(r.error);break}}this.emit(Xh.EncryptionError,r.error,r.participantIdentity);break;case"initAck":r.enabled&&this.keyProvider.getKeys().forEach(e=>{this.postKey(e)});break;case"enable":if(r.enabled&&this.keyProvider.getKeys().forEach(e=>{this.postKey(e)}),this.encryptionEnabled!==r.enabled&&r.participantIdentity===(null===(t=this.room)||void 0===t?void 0:t.localParticipant.identity))this.emit(Xh.ParticipantEncryptionStatusChanged,r.enabled,this.room.localParticipant),this.encryptionEnabled=r.enabled;else if(r.participantIdentity){const e=null===(n=this.room)||void 0===n?void 0:n.getParticipantByIdentity(r.participantIdentity);if(!e)throw TypeError("couldn't set encryption status, participant not found".concat(r.participantIdentity));this.emit(Xh.ParticipantEncryptionStatusChanged,r.enabled,e)}break;case"ratchetKey":this.keyProvider.emit(Jh.KeyRatcheted,r.ratchetResult,r.participantIdentity,r.keyIndex);break;case"decryptDataResponse":const e=this.decryptDataRequests.get(r.uuid);(null==e?void 0:e.resolve)&&e.resolve(r);break;case"encryptDataResponse":const i=this.encryptDataRequests.get(r.uuid);(null==i?void 0:i.resolve)&&i.resolve(r)}},this.onWorkerError=e=>{Ol.error("e2ee worker encountered an error:",{error:e.error}),this.emit(Xh.EncryptionError,e.error,void 0)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1,this.dataChannelEncryptionEnabled=t}get isEnabled(){return this.encryptionEnabled}get isDataChannelEncryptionEnabled(){return this.isEnabled&&this.dataChannelEncryptionEnabled}setup(e){if(!ip())throw new vd("tried to setup end-to-end encryption on an unsupported browser");if(Ol.info("setting up e2ee"),e!==this.room){this.room=e,this.setupEventListeners(e,this.keyProvider);const t={kind:"init",data:{keyProviderOptions:this.keyProvider.getOptions(),loglevel:Dl.getLevel()}};this.worker&&(Ol.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(t))}}setParticipantCryptorEnabled(e,t){Ol.debug("set e2ee to ".concat(e," for participant ").concat(t)),this.postEnable(e,t)}setSifTrailer(e){e&&0!==e.length?this.postSifTrailer(e):Ol.warn("ignoring server sent trailer as it's empty")}setupEngine(e){e.on(hd.RTPVideoMapUpdate,e=>{this.postRTPMap(e)})}setupEventListeners(e,t){e.on(cd.TrackPublished,(e,t)=>this.setParticipantCryptorEnabled(e.trackInfo.encryption!==Us.NONE,t.identity)),e.on(cd.ConnectionStateChanged,t=>{t===Qf.Connected&&e.remoteParticipants.forEach(e=>{e.trackPublications.forEach(t=>{this.setParticipantCryptorEnabled(t.trackInfo.encryption!==Us.NONE,e.identity)})})}).on(cd.TrackUnsubscribed,(e,t,n)=>{var i;const r={kind:"removeTransform",data:{participantIdentity:n.identity,trackId:e.mediaStreamID}};null===(i=this.worker)||void 0===i||i.postMessage(r)}).on(cd.TrackSubscribed,(e,t,n)=>{this.setupE2EEReceiver(e,n.identity,t.trackInfo)}).on(cd.SignalConnected,()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");t.getKeys().forEach(e=>{this.postKey(e)}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(ud.LocalSenderCreated,(e,t)=>jl(this,void 0,void 0,function*(){this.setupE2EESender(t,e)})),e.localParticipant.on(ud.LocalTrackPublished,e=>{if(!Uh(e.track)||!dh())return;const t={kind:"updateCodec",data:{trackId:e.track.mediaStreamID,codec:Wd(e.trackInfo.codecs[0].mimeType),participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(t)}),t.on(Jh.SetKey,e=>this.postKey(e)).on(Jh.RatchetRequest,(e,t)=>this.postRatchetRequest(e,t))}encryptData(e){return jl(this,void 0,void 0,function*(){if(!this.worker)throw Error("could not encrypt data, worker is missing");const t=crypto.randomUUID(),n={kind:"encryptDataRequest",data:{uuid:t,payload:e,participantIdentity:this.room.localParticipant.identity}},i=new Ih;return i.onFinally=()=>{this.encryptDataRequests.delete(t)},this.encryptDataRequests.set(t,i),this.worker.postMessage(n),i.promise})}handleEncryptedData(e,t,n,i){if(!this.worker)throw Error("could not handle encrypted data, worker is missing");const r=crypto.randomUUID(),o={kind:"decryptDataRequest",data:{uuid:r,payload:e,iv:t,participantIdentity:n,keyIndex:i}},a=new Ih;return a.onFinally=()=>{this.decryptDataRequests.delete(r)},this.decryptDataRequests.set(r,a),this.worker.postMessage(o),a.promise}postRatchetRequest(e,t){if(!this.worker)throw Error("could not ratchet key, worker is missing");const n={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:t}};this.worker.postMessage(n)}postKey(e){let{key:t,participantIdentity:n,keyIndex:i}=e;var r;if(!this.worker)throw Error("could not set key, worker is missing");const o={kind:"setKey",data:{participantIdentity:n,isPublisher:n===(null===(r=this.room)||void 0===r?void 0:r.localParticipant.identity),key:t,keyIndex:i}};this.worker.postMessage(o)}postEnable(e,t){if(!this.worker)throw new ReferenceError("failed to enable e2ee, worker is not ready");{const n={kind:"enable",data:{enabled:e,participantIdentity:t}};this.worker.postMessage(n)}}postRTPMap(e){var t;if(!this.worker)throw TypeError("could not post rtp map, worker is missing");if(!(null===(t=this.room)||void 0===t?void 0:t.localParticipant.identity))throw TypeError("could not post rtp map, local participant identity is missing");const n={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(n)}postSifTrailer(e){if(!this.worker)throw Error("could not post SIF trailer, worker is missing");const t={kind:"setSifTrailer",data:{trailer:e}};this.worker.postMessage(t)}setupE2EEReceiver(e,t,n){if(e.receiver){if(!(null==n?void 0:n.mimeType)||""===n.mimeType)throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");this.handleReceiver(e.receiver,e.mediaStreamID,t,"video"===e.kind?Wd(n.mimeType):void 0)}}setupE2EESender(e,t){Ah(e)&&t?this.handleSender(t,e.mediaStreamID,void 0):t||Ol.warn("early return because sender is not ready")}handleReceiver(e,t,n,i){return jl(this,void 0,void 0,function*(){if(this.worker){if(rp()&&!lh()){const r={kind:"decode",participantIdentity:n,trackId:t,codec:i};e.transform=new RTCRtpScriptTransform(this.worker,r)}else{if($h in e&&i){const e={kind:"updateCodec",data:{trackId:t,codec:i,participantIdentity:n}};return void this.worker.postMessage(e)}let r=e.writableStream,o=e.readableStream;if(!r||!o){const t=e.createEncodedStreams();e.writableStream=t.writable,r=t.writable,e.readableStream=t.readable,o=t.readable}const a={kind:"decode",data:{readableStream:o,writableStream:r,trackId:t,codec:i,participantIdentity:n,isReuse:$h in e}};this.worker.postMessage(a,[o,r])}e[$h]=!0}})}handleSender(e,t,n){var i;if(!($h in e)&&this.worker){if(!(null===(i=this.room)||void 0===i?void 0:i.localParticipant.identity)||""===this.room.localParticipant.identity)throw TypeError("local identity needs to be known in order to set up encrypted sender");if(rp()&&!lh()){Ol.info("initialize script transform");const i={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:t,codec:n};e.transform=new RTCRtpScriptTransform(this.worker,i)}else{Ol.info("initialize encoded streams");const i=e.createEncodedStreams(),r={kind:"encode",data:{readableStream:i.readable,writableStream:i.writable,codec:n,trackId:t,participantIdentity:this.room.localParticipant.identity,isReuse:!1}};this.worker.postMessage(r,[i.readable,i.writable])}e[$h]=!0}}}class ap{constructor(){this.failedConnectionAttempts=new Map,this.backOffPromises=new Map}static getInstance(){return this._instance||(this._instance=new ap),this._instance}addFailedConnectionAttempt(e){var t;const n=gh(new URL(e));if(!n)return;let i=null!==(t=this.failedConnectionAttempts.get(n))&&void 0!==t?t:0;this.failedConnectionAttempts.set(n,i+1),this.backOffPromises.set(n,ih(Math.min(500*Math.pow(2,i),15e3)))}getBackOffPromise(e){const t=new URL(e),n=t&&gh(t);return n&&this.backOffPromises.get(n)||Promise.resolve()}resetFailedConnectionAttempts(e){const t=new URL(e),n=t&&gh(t);n&&(this.failedConnectionAttempts.set(n,0),this.backOffPromises.set(n,Promise.resolve()))}resetAll(){this.backOffPromises.clear(),this.failedConnectionAttempts.clear()}}ap._instance=null;const sp="default";class cp{constructor(){this._previousDevices=[]}static getInstance(){return void 0===this.instance&&(this.instance=new cp),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return jl(this,arguments,void 0,function(e){var t=this;let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function*(){var i;if((null===(i=cp.userMediaPromiseMap)||void 0===i?void 0:i.size)>0){Ol.debug("awaiting getUserMedia promise");try{e?yield cp.userMediaPromiseMap.get(e):yield Promise.all(cp.userMediaPromiseMap.values())}catch(o){Ol.warn("error waiting for media permissons")}}let r=yield navigator.mediaDevices.enumerateDevices();if(n&&(!uh()||!t.hasDeviceInUse(e))){if(0===r.filter(t=>t.kind===e).length||r.some(t=>{const n=""===t.label,i=!e||t.kind===e;return n&&i})){const t={video:"audioinput"!==e&&"audiooutput"!==e,audio:"videoinput"!==e&&{deviceId:{ideal:"default"}}},n=yield navigator.mediaDevices.getUserMedia(t);r=yield navigator.mediaDevices.enumerateDevices(),n.getTracks().forEach(e=>{e.stop()})}}return t._previousDevices=r,e&&(r=r.filter(t=>t.kind===e)),r}()})}normalizeDeviceId(e,t,n){return jl(this,void 0,void 0,function*(){if(t!==sp)return t;const i=yield this.getDevices(e),r=i.find(e=>e.deviceId===sp);if(!r)return void Ol.warn("could not reliably determine default device");const o=i.find(e=>e.deviceId!==sp&&e.groupId===(null!=n?n:r.groupId));if(o)return null==o?void 0:o.deviceId;Ol.warn("could not reliably determine default device")})}hasDeviceInUse(e){return e?cp.userMediaPromiseMap.has(e):cp.userMediaPromiseMap.size>0}}var lp,up;cp.mediaDeviceKinds=["audioinput","audiooutput","videoinput"],cp.userMediaPromiseMap=new Map,(up=lp||(lp={}))[up.WAITING=0]="WAITING",up[up.RUNNING=1]="RUNNING",up[up.COMPLETED=2]="COMPLETED";class dp{constructor(){this.pendingTasks=new Map,this.taskMutex=new Do,this.nextTaskIndex=0}run(e){return jl(this,void 0,void 0,function*(){const t={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:lp.WAITING};this.pendingTasks.set(t.id,t);const n=yield this.taskMutex.lock();try{return t.executedAt=Date.now(),t.status=lp.RUNNING,yield e()}finally{t.status=lp.COMPLETED,this.pendingTasks.delete(t.id),n()}})}flush(){return jl(this,void 0,void 0,function*(){return this.run(()=>jl(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}}class hp{get readyState(){return this.ws.readyState}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n,i;if(null===(n=t.signal)||void 0===n?void 0:n.aborted)throw new DOMException("This operation was aborted","AbortError");this.url=e;const r=new WebSocket(e,null!==(i=t.protocols)&&void 0!==i?i:[]);r.binaryType="arraybuffer",this.ws=r;const o=function(){let{closeCode:e,reason:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return r.close(e,t)};this.opened=new $u((e,t)=>{const n=()=>{t(gd.websocket("Encountered websocket error during connection establishment"))};r.onopen=()=>{e({readable:new ReadableStream({start(e){r.onmessage=t=>{let{data:n}=t;return e.enqueue(n)},r.onerror=t=>e.error(t)},cancel:o}),writable:new WritableStream({write(e){r.send(e)},abort(){r.close()},close:o}),protocol:r.protocol,extensions:r.extensions}),r.removeEventListener("error",n)},r.addEventListener("error",n)}),this.closed=new $u((e,t)=>{const n=()=>jl(this,void 0,void 0,function*(){const n=new $u(e=>{r.readyState!==WebSocket.CLOSED&&r.addEventListener("close",t=>{e(t)},{once:!0})}),i=yield $u.race([ih(250),n]);i?e(i):t(gd.websocket("Encountered unspecified websocket error without a timely close event"))});r.onclose=t=>{let{code:i,reason:o}=t;e({closeCode:i,reason:o}),r.removeEventListener("error",n)},r.addEventListener("error",n)}),t.signal&&(t.signal.onabort=()=>r.close()),this.close=o}}const pp=["syncState","trickle","offer","answer","simulate","leave"];var fp,mp;(mp=fp||(fp={}))[mp.CONNECTING=0]="CONNECTING",mp[mp.CONNECTED=1]="CONNECTED",mp[mp.RECONNECTING=2]="RECONNECTING",mp[mp.DISCONNECTING=3]="DISCONNECTING",mp[mp.DISCONNECTED=4]="DISCONNECTED";class gp{get currentState(){return this.state}get isDisconnected(){return this.state===fp.DISCONNECTING||this.state===fp.DISCONNECTED}get isEstablishingConnection(){return this.state===fp.CONNECTING||this.state===fp.RECONNECTING}getNextRequestId(){return this._requestId+=1,this._requestId}constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;this.rtt=0,this.state=fp.DISCONNECTED,this.log=Ol,this._requestId=0,this.useV0SignalPath=!1,this.resetCallbacks=()=>{this.onAnswer=void 0,this.onLeave=void 0,this.onLocalTrackPublished=void 0,this.onLocalTrackUnpublished=void 0,this.onNegotiateRequested=void 0,this.onOffer=void 0,this.onRemoteMuteChanged=void 0,this.onSubscribedQualityUpdate=void 0,this.onTokenRefresh=void 0,this.onTrickle=void 0,this.onClose=void 0,this.onMediaSectionsRequirement=void 0},this.log=Ml(null!==(n=t.loggerName)&&void 0!==n?n:Rl.Signal),this.loggerContextCb=t.loggerContextCb,this.useJSON=e,this.requestQueue=new dp,this.queuedRequests=[],this.closingLock=new Do,this.connectionLock=new Do,this.state=fp.DISCONNECTED}get logContext(){var e,t;return null!==(t=null===(e=this.loggerContextCb)||void 0===e?void 0:e.call(this))&&void 0!==t?t:{}}join(e,t,n,i){return jl(this,arguments,void 0,function(e,t,n,i){var r=this;let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return function*(){r.state=fp.CONNECTING,r.options=n;return yield r.connect(e,t,n,i,o)}()})}reconnect(e,t,n,i){return jl(this,void 0,void 0,function*(){if(!this.options)return void this.log.warn("attempted to reconnect without signal options being set, ignoring",this.logContext);this.state=fp.RECONNECTING,this.clearPingInterval();return yield this.connect(e,t,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:n,reconnectReason:i}),void 0,this.useV0SignalPath)})}connect(e,t,n,i){return jl(this,arguments,void 0,function(e,t,n,i){var r=this;let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return function*(){const a=yield r.connectionLock.lock();r.connectOptions=n,r.useV0SignalPath=o;const s=function(){var e;const t=new sc({sdk:cc.JS,protocol:16,version:"2.17.0"});return fh()&&(t.os=null!==(e=yh())&&void 0!==e?e:""),t}(),c=o?function(e,t,n){var i;const r=new URLSearchParams;r.set("access_token",e),n.reconnect&&(r.set("reconnect","1"),n.sid&&r.set("sid",n.sid));r.set("auto_subscribe",n.autoSubscribe?"1":"0"),r.set("sdk",fh()?"reactnative":"js"),r.set("version",t.version),r.set("protocol",t.protocol.toString()),t.deviceModel&&r.set("device_model",t.deviceModel);t.os&&r.set("os",t.os);t.osVersion&&r.set("os_version",t.osVersion);t.browser&&r.set("browser",t.browser);t.browserVersion&&r.set("browser_version",t.browserVersion);n.adaptiveStream&&r.set("adaptive_stream","1");n.reconnectReason&&r.set("reconnect_reason",n.reconnectReason.toString());(null===(i=navigator.connection)||void 0===i?void 0:i.type)&&r.set("network",navigator.connection.type);return r}(t,s,n):function(e,t,n){const i=new URLSearchParams;i.set("access_token",e);const r=new vl({clientInfo:t,connectionSettings:new gl({autoSubscribe:!!n.autoSubscribe,adaptiveStream:!!n.adaptiveStream}),reconnect:!!n.reconnect,participantSid:n.sid?n.sid:void 0});n.reconnectReason&&(r.reconnectReason=n.reconnectReason);const o=new yl({joinRequest:r.toBinary()});return i.set("join_request",btoa(new TextDecoder("utf-8").decode(o.toBinary()))),i}(t,s,n),l=Hh(e,c,o).toString(),u=(d=l,Kh(new URL(Oh(d)),"validate")).toString();var d;return new Promise((e,t)=>jl(r,void 0,void 0,function*(){var r,o;try{let a=!1;const c=e=>jl(this,void 0,void 0,function*(){if(a)return;a=!0;const n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Unknown reason";if(!(e instanceof AbortSignal))return t;const n=e.reason;switch(typeof n){case"string":return n;case"object":return n instanceof Error?n.message:t;default:return"toString"in n?n.toString():t}}(e instanceof Event?e.currentTarget:e,"Abort handler called");this.streamWriter&&!this.isDisconnected?this.sendLeave().then(()=>this.close(n)).catch(e=>{this.log.error(e),this.close()}):this.close(),d(),t(gd.cancelled(n))});null==i||i.addEventListener("abort",c);const d=()=>{clearTimeout(h),null==i||i.removeEventListener("abort",c)},h=setTimeout(()=>{c(gd.timeout("room connection has timed out (signal)"))},n.websocketTimeout),p=(e,t)=>{this.handleSignalConnected(e,h,t)},f=new URL(l);f.searchParams.has("access_token")&&f.searchParams.set("access_token","<redacted>"),this.log.debug("connecting to ".concat(f),Object.assign({reconnect:n.reconnect,reconnectReason:n.reconnectReason},this.logContext)),this.ws&&(yield this.close(!1)),this.ws=new hp(l);try{this.ws.closed.then(e=>{var n;this.isEstablishingConnection&&t(gd.internal("Websocket got closed during a (re)connection attempt: ".concat(e.reason))),1e3!==e.closeCode&&(this.log.warn("websocket closed",Object.assign(Object.assign({},this.logContext),{reason:e.reason,code:e.closeCode,wasClean:1e3===e.closeCode,state:this.state})),this.state===fp.CONNECTED&&this.handleOnClose(null!==(n=e.reason)&&void 0!==n?n:"Unexpected WS error"))}).catch(e=>{this.isEstablishingConnection&&t(gd.internal("Websocket error during a (re)connection attempt: ".concat(e)))});const i=yield this.ws.opened.catch(e=>jl(this,void 0,void 0,function*(){if(this.state!==fp.CONNECTED){this.state=fp.DISCONNECTED,clearTimeout(h);const n=yield this.handleConnectionError(e,u);return void t(n)}this.handleWSError(e),t(e)}));if(clearTimeout(h),!i)return;const a=i.readable.getReader();this.streamWriter=i.writable.getWriter();const s=yield a.read();if(a.releaseLock(),!s.value)throw gd.internal("no message received as first message");const c=Gh(s.value),l=this.validateFirstMessage(c,null!==(r=n.reconnect)&&void 0!==r&&r);if(!l.isValid)return void t(l.error);"join"===(null===(o=c.message)||void 0===o?void 0:o.case)&&(this.pingTimeoutDuration=c.message.value.pingTimeout,this.pingIntervalDuration=c.message.value.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&this.log.debug("ping config",Object.assign(Object.assign({},this.logContext),{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration})));p(i,l.shouldProcessFirstMessage?c:void 0),e(l.response)}catch(s){t(s)}finally{d()}}finally{a()}}))}()})}startReadingLoop(e,t){return jl(this,void 0,void 0,function*(){for(t&&this.handleSignalResponse(t);;){this.signalLatency&&(yield ih(this.signalLatency));const{done:t,value:n}=yield e.read();if(t)break;const i=Gh(n);this.handleSignalResponse(i)}})}close(){return jl(this,arguments,void 0,function(){var e=this;let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Close method called on signal client";return function*(){if([fp.DISCONNECTING||fp.DISCONNECTED].includes(e.state))return void e.log.debug("ignoring signal close as it's already in disconnecting state");const i=yield e.closingLock.lock();try{if(e.clearPingInterval(),t&&(e.state=fp.DISCONNECTING),e.ws){e.ws.close({closeCode:1e3,reason:n});const t=e.ws.closed;e.ws=void 0,e.streamWriter=void 0,yield Promise.race([t,ih(250)])}}catch(r){e.log.debug("websocket error while closing",Object.assign(Object.assign({},e.logContext),{error:r}))}finally{t&&(e.state=fp.DISCONNECTED),i()}}()})}sendOffer(e,t){this.log.debug("sending offer",Object.assign(Object.assign({},this.logContext),{offerSdp:e.sdp})),this.sendRequest({case:"offer",value:yp(e,t)})}sendAnswer(e,t){return this.log.debug("sending answer",Object.assign(Object.assign({},this.logContext),{answerSdp:e.sdp})),this.sendRequest({case:"answer",value:yp(e,t)})}sendIceCandidate(e,t){return this.log.debug("sending ice candidate",Object.assign(Object.assign({},this.logContext),{candidate:e})),this.sendRequest({case:"trickle",value:new Pc({candidateInit:JSON.stringify(e),target:t})})}sendMuteTrack(e,t){return this.sendRequest({case:"mute",value:new _c({sid:e,muted:t})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,t){return jl(this,arguments,void 0,function(e,t){var n=this;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function*(){const r=n.getNextRequestId();return yield n.sendRequest({case:"updateMetadata",value:new Vc({requestId:r,metadata:e,name:t,attributes:i})}),r}()})}sendUpdateTrackSettings(e){this.sendRequest({case:"trackSetting",value:e})}sendUpdateSubscription(e){return this.sendRequest({case:"subscription",value:e})}sendSyncState(e){return this.sendRequest({case:"syncState",value:e})}sendUpdateVideoLayers(e,t){return this.sendRequest({case:"updateLayers",value:new zc({trackSid:e,layers:t})})}sendUpdateSubscriptionPermissions(e,t){return this.sendRequest({case:"subscriptionPermission",value:new tl({allParticipants:e,trackPermissions:t})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:na.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new cl({timestamp:na.parse(Date.now()),rtt:na.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,t){return this.sendRequest({case:"updateAudioTrack",value:new jc({trackSid:e,features:t})})}sendLeave(){return this.sendRequest({case:"leave",value:new Fc({reason:Ps.CLIENT_INITIATED,action:Bc.DISCONNECT})})}sendRequest(e){return jl(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function*(){const i=!n&&!function(e){const t=pp.indexOf(e.case)>=0;return Ol.trace("request allowed to bypass queue:",{canPass:t,req:e}),t}(e);if(i&&t.state===fp.RECONNECTING)return void t.queuedRequests.push(()=>jl(t,void 0,void 0,function*(){yield this.sendRequest(e,!0)}));if(n||(yield t.requestQueue.flush()),t.signalLatency&&(yield ih(t.signalLatency)),t.isDisconnected)return void t.log.debug("skipping signal request (type: ".concat(e.case,") - SignalClient disconnected"));if(!t.streamWriter)return void t.log.error("cannot send signal request before connected, type: ".concat(null==e?void 0:e.case),t.logContext);const r=new Tc({message:e});try{t.useJSON?yield t.streamWriter.write(r.toJsonString()):yield t.streamWriter.write(r.toBinary())}catch(o){t.log.error("error sending signal message",Object.assign(Object.assign({},t.logContext),{error:o}))}}()})}handleSignalResponse(e){var t,n;const i=e.message;if(null==i)return void this.log.debug("received unsupported message",this.logContext);let r=!1;if("answer"===i.case){const e=vp(i.value);this.onAnswer&&this.onAnswer(e,i.value.id,i.value.midToTrackId)}else if("offer"===i.case){const e=vp(i.value);this.onOffer&&this.onOffer(e,i.value.id,i.value.midToTrackId)}else if("trickle"===i.case){const e=JSON.parse(i.value.candidateInit);this.onTrickle&&this.onTrickle(e,i.value.target)}else"update"===i.case?this.onParticipantUpdate&&this.onParticipantUpdate(null!==(t=i.value.participants)&&void 0!==t?t:[]):"trackPublished"===i.case?this.onLocalTrackPublished&&this.onLocalTrackPublished(i.value):"speakersChanged"===i.case?this.onSpeakersChanged&&this.onSpeakersChanged(null!==(n=i.value.speakers)&&void 0!==n?n:[]):"leave"===i.case?this.onLeave&&this.onLeave(i.value):"mute"===i.case?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(i.value.sid,i.value.muted):"roomUpdate"===i.case?this.onRoomUpdate&&i.value.room&&this.onRoomUpdate(i.value.room):"connectionQuality"===i.case?this.onConnectionQuality&&this.onConnectionQuality(i.value):"streamStateUpdate"===i.case?this.onStreamStateUpdate&&this.onStreamStateUpdate(i.value):"subscribedQualityUpdate"===i.case?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(i.value):"subscriptionPermissionUpdate"===i.case?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(i.value):"refreshToken"===i.case?this.onTokenRefresh&&this.onTokenRefresh(i.value):"trackUnpublished"===i.case?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(i.value):"subscriptionResponse"===i.case?this.onSubscriptionError&&this.onSubscriptionError(i.value):"pong"===i.case||("pongResp"===i.case?(this.rtt=Date.now()-Number.parseInt(i.value.lastPingTimestamp.toString()),this.resetPingTimeout(),r=!0):"requestResponse"===i.case?this.onRequestResponse&&this.onRequestResponse(i.value):"trackSubscribed"===i.case?this.onLocalTrackSubscribed&&this.onLocalTrackSubscribed(i.value.trackSid):"roomMoved"===i.case?(this.onTokenRefresh&&this.onTokenRefresh(i.value.token),this.onRoomMoved&&this.onRoomMoved(i.value)):"mediaSectionsRequirement"===i.case?this.onMediaSectionsRequirement&&this.onMediaSectionsRequirement(i.value):this.log.debug("unsupported message",Object.assign(Object.assign({},this.logContext),{msgCase:i.case})));r||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return jl(this,void 0,void 0,function*(){if(this.state===fp.DISCONNECTED)return;const t=this.onClose;yield this.close(void 0,e),this.log.debug("websocket connection closed: ".concat(e),Object.assign(Object.assign({},this.logContext),{reason:e})),t&&t(e)})}handleWSError(e){this.log.error("websocket error",Object.assign(Object.assign({},this.logContext),{error:e}))}resetPingTimeout(){this.clearPingTimeout(),this.pingTimeoutDuration?this.pingTimeout=xd.setTimeout(()=>{this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-1e3*this.pingTimeoutDuration).toUTCString()),this.logContext),this.handleOnClose("ping timeout")},1e3*this.pingTimeoutDuration):this.log.warn("ping timeout duration not set",this.logContext)}clearPingTimeout(){this.pingTimeout&&xd.clearTimeout(this.pingTimeout)}startPingInterval(){this.clearPingInterval(),this.resetPingTimeout(),this.pingIntervalDuration?(this.log.debug("start ping interval",this.logContext),this.pingInterval=xd.setInterval(()=>{this.sendPing()},1e3*this.pingIntervalDuration)):this.log.warn("ping interval duration not set",this.logContext)}clearPingInterval(){this.log.debug("clearing ping interval",this.logContext),this.clearPingTimeout(),this.pingInterval&&xd.clearInterval(this.pingInterval)}handleSignalConnected(e,t,n){this.state=fp.CONNECTED,clearTimeout(t),this.startPingInterval(),this.startReadingLoop(e.readable.getReader(),n)}validateFirstMessage(e,t){var n,i,r,o,a;return"join"===(null===(n=e.message)||void 0===n?void 0:n.case)?{isValid:!0,response:e.message.value}:this.state===fp.RECONNECTING&&"leave"!==(null===(i=e.message)||void 0===i?void 0:i.case)?"reconnect"===(null===(r=e.message)||void 0===r?void 0:r.case)?{isValid:!0,response:e.message.value}:(this.log.debug("declaring signal reconnected without reconnect response received",this.logContext),{isValid:!0,response:void 0,shouldProcessFirstMessage:!0}):this.isEstablishingConnection&&"leave"===(null===(o=e.message)||void 0===o?void 0:o.case)?{isValid:!1,error:gd.leaveRequest("Received leave request while trying to (re)connect",e.message.value.reason)}:t?{isValid:!1,error:gd.internal("Unexpected first message")}:{isValid:!1,error:gd.internal("did not receive join response, got ".concat(null===(a=e.message)||void 0===a?void 0:a.case," instead"))}}handleConnectionError(e,t){return jl(this,void 0,void 0,function*(){try{const n=yield fetch(t);switch(n.status){case 404:return gd.serviceNotFound("v1 RTC path not found. Consider upgrading your LiveKit server version","v0-rtc");case 401:case 403:const e=yield n.text();return gd.notAllowed(e,n.status)}return e instanceof gd?e:gd.internal("Encountered unknown websocket error during connection: ".concat(e),{status:n.status,statusText:n.statusText})}catch(n){return n instanceof gd?n:gd.serverUnreachable(n instanceof Error?n.message:"server was not reachable")}})}}function vp(e){const t={type:"offer",sdp:e.sdp};switch(e.type){case"answer":case"offer":case"pranswer":case"rollback":t.type=e.type}return t}function yp(e,t){return new Mc({sdp:e.sdp,type:e.type,id:t})}class bp{constructor(){this.buffer=[],this._totalSize=0}push(e){this.buffer.push(e),this._totalSize+=e.data.byteLength}pop(){const e=this.buffer.shift();return e&&(this._totalSize-=e.data.byteLength),e}getAll(){return this.buffer.slice()}popToSequence(e){for(;this.buffer.length>0;){if(!(this.buffer[0].sequence<=e))break;this.pop()}}alignBufferedAmount(e){for(;this.buffer.length>0;){const t=this.buffer[0];if(this._totalSize-t.data.byteLength<=e)break;this.pop()}}get length(){return this.buffer.length}}class kp{constructor(e){this._map=new Map,this._lastCleanup=0,this.ttl=e}set(e,t){const n=Date.now();n-this._lastCleanup>this.ttl/2&&this.cleanup();const i=n+this.ttl;return this._map.set(e,{value:t,expiresAt:i}),this}get(e){const t=this._map.get(e);if(t){if(!(t.expiresAt<Date.now()))return t.value;this._map.delete(e)}}has(e){const t=this._map.get(e);return!!t&&(!(t.expiresAt<Date.now())||(this._map.delete(e),!1))}delete(e){return this._map.delete(e)}clear(){this._map.clear()}cleanup(){const e=Date.now();for(const[t,n]of this._map.entries())n.expiresAt<e&&this._map.delete(t);this._lastCleanup=e}get size(){return this.cleanup(),this._map.size}forEach(e){this.cleanup();for(const[t,n]of this._map.entries())n.expiresAt>=Date.now()&&e(n.value,t,this.asValueMap())}map(e){this.cleanup();const t=[],n=this.asValueMap();for(const[i,r]of n.entries())t.push(e(r,i,n));return t}asValueMap(){const e=new Map;for(const[t,n]of this._map.entries())n.expiresAt>=Date.now()&&e.set(t,n.value);return e}}var Sp,Cp,Tp,wp,Ep,xp={},Pp={},_p={exports:{}};function Rp(){if(Sp)return _p.exports;Sp=1;var e=_p.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};return Object.keys(e).forEach(function(t){e[t].forEach(function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")})}),_p.exports}function Ip(){return Cp||(Cp=1,function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,i){var r=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:r&&!n[e.name]&&(n[e.name]={});var o=e.push?{}:r?n[e.name]:n;!function(e,n,i,r){if(r&&!i)n[r]=t(e[1]);else for(var o=0;o<i.length;o+=1)null!=e[o+1]&&(n[i[o]]=t(e[o+1]))}(i.match(e.reg),o,e.names,e.name),e.push&&n[e.push].push(o)},i=Rp(),r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(r).forEach(function(e){var t=e[0],r=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;s<(i[t]||[]).length;s+=1){var c=i[t][s];if(c.reg.test(r))return n(c,a,r)}}),t.media=o,t};var o=function(e,n){var i=n.split(/=(.+)/,2);return 2===i.length?e[i[0]]=t(i[1]):1===i.length&&n.length>1&&(e[i[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],i=e.split(" ").map(t),r=0;r<i.length;r+=3)n.push({component:i[r],ip:i[r+1],port:i[r+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map(function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})})},e.parseSimulcastStreamList=function(e){return e.split(";").map(function(e){return e.split(",").map(function(e){var n,i=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),i=!0),{scid:n,paused:i}})})}}(Pp)),Pp}function Np(){if(wp)return Tp;wp=1;var e=Rp(),t=/%[sdv%]/g,n=function(e){var n=1,i=arguments,r=i.length;return e.replace(t,function(e){if(n>=r)return e;var t=i[n];switch(n+=1,e){case"%%":return"%";case"%s":return String(t);case"%d":return Number(t);case"%v":return""}})},i=function(e,t,i){var r=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var a=t.names[o];t.name?r.push(i[t.name][a]):r.push(i[t.names[o]])}else r.push(i[t.name]);return n.apply(null,r)},r=["v","o","s","i","u","e","p","c","b","t","r","z","a"],o=["i","c","b","a"];return Tp=function(t,n){n=n||{},null==t.version&&(t.version=0),null==t.name&&(t.name=" "),t.media.forEach(function(e){null==e.payloads&&(e.payloads="")});var a=n.outerOrder||r,s=n.innerOrder||o,c=[];return a.forEach(function(n){e[n].forEach(function(e){e.name in t&&null!=t[e.name]?c.push(i(n,e,t)):e.push in t&&null!=t[e.push]&&t[e.push].forEach(function(t){c.push(i(n,e,t))})})}),t.media.forEach(function(t){c.push(i("m",e.m[0],t)),s.forEach(function(n){e[n].forEach(function(e){e.name in t&&null!=t[e.name]?c.push(i(n,e,t)):e.push in t&&null!=t[e.push]&&t[e.push].forEach(function(t){c.push(i(n,e,t))})})})}),c.join("\r\n")+"\r\n"}}var Op=function(){if(Ep)return xp;Ep=1;var e=Ip(),t=Np(),n=Rp();return xp.grammar=n,xp.write=t,xp.parse=e.parse,xp.parseParams=e.parseParams,xp.parseFmtpConfig=e.parseFmtpConfig,xp.parsePayloads=e.parsePayloads,xp.parseRemoteCandidates=e.parseRemoteCandidates,xp.parseImageAttributes=e.parseImageAttributes,xp.parseSimulcastStreamList=e.parseSimulcastStreamList,xp}();function Mp(e,t,n){var i,r,o;void 0===t&&(t=50),void 0===n&&(n={});var a=null!=(i=n.isImmediate)&&i,s=null!=(r=n.callback)&&r,c=n.maxWait,l=Date.now(),u=[];var d=function(){var n=[].slice.call(arguments),i=this;return new Promise(function(r,d){var h=a&&void 0===o;if(void 0!==o&&clearTimeout(o),o=setTimeout(function(){if(o=void 0,l=Date.now(),!a){var t=e.apply(i,n);s&&s(t),u.forEach(function(e){return(0,e.resolve)(t)}),u=[]}},function(){if(void 0!==c){var e=Date.now()-l;if(e+t>=c)return c-e}return t}()),h){var p=e.apply(i,n);return s&&s(p),r(p)}u.push({resolve:r,reject:d})})};return d.cancel=function(e){void 0!==o&&clearTimeout(o),u.forEach(function(t){return(0,t.reject)(e)}),u=[]},d}const Dp="negotiationStarted",Lp="negotiationComplete",Ap="rtpVideoPayloadTypes";class jp extends Vl.EventEmitter{get pc(){return this._pc||(this._pc=this.createPC()),this._pc}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;super(),this.log=Ol,this.ddExtID=0,this.latestOfferId=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=Mp(e=>jl(this,void 0,void 0,function*(){this.emit(Dp);try{yield this.createAndSendOffer()}catch(t){if(!e)throw t;e(t)}}),20),this.close=()=>{this._pc&&(this._pc.close(),this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.ondatachannel=null,this._pc.onnegotiationneeded=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ondatachannel=null,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc=null)},this.log=Ml(null!==(n=t.loggerName)&&void 0!==n?n:Rl.PCTransport),this.loggerOptions=t,this.config=e,this._pc=this.createPC(),this.offerLock=new Do}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=e=>{var t;e.candidate&&(null===(t=this.onIceCandidate)||void 0===t||t.call(this,e.candidate))},e.onicecandidateerror=e=>{var t;null===(t=this.onIceCandidateError)||void 0===t||t.call(this,e)},e.oniceconnectionstatechange=()=>{var t;null===(t=this.onIceConnectionStateChange)||void 0===t||t.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var t;null===(t=this.onSignalingStatechange)||void 0===t||t.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var t;null===(t=this.onConnectionStateChange)||void 0===t||t.call(this,e.connectionState)},e.ondatachannel=e=>{var t;null===(t=this.onDataChannel)||void 0===t||t.call(this,e)},e.ontrack=e=>{var t;null===(t=this.onTrack)||void 0===t||t.call(this,e)},e}get logContext(){var e,t;return Object.assign({},null===(t=(e=this.loggerOptions).loggerContextCb)||void 0===t?void 0:t.call(e))}get isICEConnected(){return null!==this._pc&&("connected"===this.pc.iceConnectionState||"completed"===this.pc.iceConnectionState)}addIceCandidate(e){return jl(this,void 0,void 0,function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)})}setRemoteDescription(e,t){return jl(this,void 0,void 0,function*(){var n;if("answer"===e.type&&this.latestOfferId>0&&t>0&&t!==this.latestOfferId)return this.log.warn("ignoring answer for old offer",Object.assign(Object.assign({},this.logContext),{offerId:t,latestOfferId:this.latestOfferId})),!1;let i;if("offer"===e.type){let{stereoMids:t,nackMids:n}=function(e){var t;const n=[],i=[],r=Op.parse(null!==(t=e.sdp)&&void 0!==t?t:"");let o=0;return r.media.forEach(e=>{var t;const r=Bp(e.mid);"audio"===e.type&&(e.rtp.some(e=>"opus"===e.codec&&(o=e.payload,!0)),(null===(t=e.rtcpFb)||void 0===t?void 0:t.some(e=>e.payload===o&&"nack"===e.type))&&i.push(r),e.fmtp.some(e=>e.payload===o&&(e.config.includes("sprop-stereo=1")&&n.push(r),!0)))}),{stereoMids:n,nackMids:i}}(e);this.remoteStereoMids=t,this.remoteNackMids=n}else if("answer"===e.type){const t=Op.parse(null!==(n=e.sdp)&&void 0!==n?n:"");t.media.forEach(e=>{const t=Bp(e.mid);"audio"===e.type&&this.trackBitrates.some(n=>{if(!n.transceiver||t!=n.transceiver.mid)return!1;let i=0;if(e.rtp.some(e=>e.codec.toUpperCase()===n.codec.toUpperCase()&&(i=e.payload,!0)),0===i)return!0;let r=!1;for(const t of e.fmtp)if(t.payload===i){t.config=t.config.split(";").filter(e=>!e.includes("maxaveragebitrate")).join(";"),n.maxbr>0&&(t.config+=";maxaveragebitrate=".concat(1e3*n.maxbr)),r=!0;break}return r||n.maxbr>0&&e.fmtp.push({payload:i,config:"maxaveragebitrate=".concat(1e3*n.maxbr)}),!0})}),i=Op.write(t)}if(yield this.setMungedSDP(e,i,!0),this.pendingCandidates.forEach(e=>{this.pc.addIceCandidate(e)}),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate)this.renegotiate=!1,yield this.createAndSendOffer();else if("answer"===e.type&&(this.emit(Lp),e.sdp)){Op.parse(e.sdp).media.forEach(e=>{"video"===e.type&&this.emit(Ap,e.rtp)})}return!0})}createAndSendOffer(e){return jl(this,void 0,void 0,function*(){var t;const n=yield this.offerLock.lock();try{if(void 0===this.onOffer)return;if((null==e?void 0:e.iceRestart)&&(this.log.debug("restarting ICE",this.logContext),this.restartingIce=!0),this._pc&&"have-local-offer"===this._pc.signalingState){const t=this._pc.remoteDescription;if(!(null==e?void 0:e.iceRestart)||!t)return void(this.renegotiate=!0);yield this._pc.setRemoteDescription(t)}else if(!this._pc||"closed"===this._pc.signalingState)return void this.log.warn("could not createOffer with closed peer connection",this.logContext);this.log.debug("starting to negotiate",this.logContext);const n=this.latestOfferId+1;this.latestOfferId=n;const i=yield this.pc.createOffer(e);this.log.debug("original offer",Object.assign({sdp:i.sdp},this.logContext));const r=Op.parse(null!==(t=i.sdp)&&void 0!==t?t:"");if(r.media.forEach(e=>{Fp(e),"audio"===e.type?Up(e,["all"],[]):"video"===e.type&&this.trackBitrates.some(t=>{if(!e.msid||!t.cid||!e.msid.includes(t.cid))return!1;let n=0;if(e.rtp.some(e=>e.codec.toUpperCase()===t.codec.toUpperCase()&&(n=e.payload,!0)),0===n)return!0;if(ah(t.codec)&&!uh()&&this.ensureVideoDDExtensionForSVC(e,r),!ah(t.codec))return!0;const i=Math.round(.7*t.maxbr);for(const r of e.fmtp)if(r.payload===n){r.config.includes("x-google-start-bitrate")||(r.config+=";x-google-start-bitrate=".concat(i));break}return!0})}),this.latestOfferId>n)return void this.log.warn("latestOfferId mismatch",Object.assign(Object.assign({},this.logContext),{latestOfferId:this.latestOfferId,offerId:n}));yield this.setMungedSDP(i,Op.write(r)),this.onOffer(i,this.latestOfferId)}finally{n()}})}createAndSetAnswer(){return jl(this,void 0,void 0,function*(){var e;const t=yield this.pc.createAnswer(),n=Op.parse(null!==(e=t.sdp)&&void 0!==e?e:"");return n.media.forEach(e=>{Fp(e),"audio"===e.type&&Up(e,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(t,Op.write(n)),t})}createDataChannel(e,t){return this.pc.createDataChannel(e,t)}addTransceiver(e,t){return this.pc.addTransceiver(e,t)}addTransceiverOfKind(e,t){return this.pc.addTransceiver(e,t)}addTrack(e){if(!this._pc)throw new kd("PC closed, cannot add track");return this._pc.addTrack(e)}setTrackCodecBitrate(e){this.trackBitrates.push(e)}setConfiguration(e){var t;if(!this._pc)throw new kd("PC closed, cannot configure");return null===(t=this._pc)||void 0===t?void 0:t.setConfiguration(e)}canRemoveTrack(){var e;return!!(null===(e=this._pc)||void 0===e?void 0:e.removeTrack)}removeTrack(e){var t;return null===(t=this._pc)||void 0===t?void 0:t.removeTrack(e)}getConnectionState(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.connectionState)&&void 0!==t?t:"closed"}getICEConnectionState(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.iceConnectionState)&&void 0!==t?t:"closed"}getSignallingState(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.signalingState)&&void 0!==t?t:"closed"}getTransceivers(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.getTransceivers())&&void 0!==t?t:[]}getSenders(){var e,t;return null!==(t=null===(e=this._pc)||void 0===e?void 0:e.getSenders())&&void 0!==t?t:[]}getLocalDescription(){var e;return null===(e=this._pc)||void 0===e?void 0:e.localDescription}getRemoteDescription(){var e;return null===(e=this.pc)||void 0===e?void 0:e.remoteDescription}getStats(){return this.pc.getStats()}getConnectedAddress(){return jl(this,void 0,void 0,function*(){var e;if(!this._pc)return;let t="";const n=new Map,i=new Map;if((yield this._pc.getStats()).forEach(e=>{switch(e.type){case"transport":t=e.selectedCandidatePairId;break;case"candidate-pair":""===t&&e.selected&&(t=e.id),n.set(e.id,e);break;case"remote-candidate":i.set(e.id,"".concat(e.address,":").concat(e.port))}}),""===t)return;const r=null===(e=n.get(t))||void 0===e?void 0:e.remoteCandidateId;return void 0!==r?i.get(r):void 0})}setMungedSDP(e,t,n){return jl(this,void 0,void 0,function*(){if(t){const r=e.sdp;e.sdp=t;try{return this.log.debug("setting munged ".concat(n?"remote":"local"," description"),this.logContext),void(n?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e))}catch(i){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:i,sdp:t})),e.sdp=r}}try{n?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e)}catch(i){let t="unknown error";i instanceof Error?t=i.message:"string"==typeof i&&(t=i);const r={error:t,sdp:e.sdp};throw!n&&this.pc.remoteDescription&&(r.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:r})),new Sd(t)}})}ensureVideoDDExtensionForSVC(e,t){var n,i;if(!(null===(n=e.ext)||void 0===n?void 0:n.some(e=>e.uri===nh))){if(0===this.ddExtID){let e=0;t.media.forEach(t=>{var n;"video"===t.type&&(null===(n=t.ext)||void 0===n||n.forEach(t=>{t.value>e&&(e=t.value)}))}),this.ddExtID=e+1}null===(i=e.ext)||void 0===i||i.push({value:this.ddExtID,uri:nh})}}}function Up(e,t,n){const i=Bp(e.mid);let r=0;e.rtp.some(e=>"opus"===e.codec&&(r=e.payload,!0)),r>0&&(e.rtcpFb||(e.rtcpFb=[]),n.includes(i)&&!e.rtcpFb.some(e=>e.payload===r&&"nack"===e.type)&&e.rtcpFb.push({payload:r,type:"nack"}),(t.includes(i)||1===t.length&&"all"===t[0])&&e.fmtp.some(e=>e.payload===r&&(e.config.includes("stereo=1")||(e.config+=";stereo=1"),!0)))}function Fp(e){if(e.connection){const t=e.connection.ip.indexOf(":")>=0;(4===e.connection.version&&t||6===e.connection.version&&!t)&&(e.connection.ip="0.0.0.0",e.connection.version=4)}}function Bp(e){return"number"==typeof e?e.toFixed(0):e}const zp="vp8",Vp={audioPreset:Md.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:jd.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:zp,backupCodec:!0,preConnectBuffer:!1},qp={deviceId:{ideal:"default"},autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},Hp={deviceId:{ideal:"default"},resolution:Ld.h720.resolution},Wp={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new class{constructor(e){this._retryDelays=void 0!==e?[...e]:Al}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+1e3*Math.random()}},disconnectOnPageLeave:!0,webAudioMix:!1,singlePeerConnection:!0},Kp={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var Gp,$p;($p=Gp||(Gp={}))[$p.NEW=0]="NEW",$p[$p.CONNECTING=1]="CONNECTING",$p[$p.CONNECTED=2]="CONNECTED",$p[$p.FAILED=3]="FAILED",$p[$p.CLOSING=4]="CLOSING",$p[$p.CLOSED=5]="CLOSED";class Jp{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}get mode(){return this._mode}constructor(e,t,n){var i;this.peerConnectionTimeout=Kp.peerConnectionTimeout,this.log=Ol,this.updateState=()=>{var e,t;const n=this.state,i=this.requiredTransports.map(e=>e.getConnectionState());i.every(e=>"connected"===e)?this.state=Gp.CONNECTED:i.some(e=>"failed"===e)?this.state=Gp.FAILED:i.some(e=>"connecting"===e)?this.state=Gp.CONNECTING:i.every(e=>"closed"===e)?this.state=Gp.CLOSED:i.some(e=>"closed"===e)?this.state=Gp.CLOSING:i.every(e=>"new"===e)&&(this.state=Gp.NEW),n!==this.state&&(this.log.debug("pc state change: from ".concat(Gp[n]," to ").concat(Gp[this.state]),this.logContext),null===(e=this.onStateChange)||void 0===e||e.call(this,this.state,this.publisher.getConnectionState(),null===(t=this.subscriber)||void 0===t?void 0:t.getConnectionState()))},this.log=Ml(null!==(i=n.loggerName)&&void 0!==i?i:Rl.PCManager),this.loggerOptions=n,this.isPublisherConnectionRequired="subscriber-primary"!==t,this.isSubscriberConnectionRequired="subscriber-primary"===t,this.publisher=new jp(e,n),this._mode=t,"publisher-only"!==t&&(this.subscriber=new jp(e,n),this.subscriber.onConnectionStateChange=this.updateState,this.subscriber.onIceConnectionStateChange=this.updateState,this.subscriber.onSignalingStatechange=this.updateState,this.subscriber.onIceCandidate=e=>{var t;null===(t=this.onIceCandidate)||void 0===t||t.call(this,e,kc.SUBSCRIBER)},this.subscriber.onDataChannel=e=>{var t;null===(t=this.onDataChannel)||void 0===t||t.call(this,e)},this.subscriber.onTrack=e=>{var t;null===(t=this.onTrack)||void 0===t||t.call(this,e)}),this.publisher.onConnectionStateChange=this.updateState,this.publisher.onIceConnectionStateChange=this.updateState,this.publisher.onSignalingStatechange=this.updateState,this.publisher.onIceCandidate=e=>{var t;null===(t=this.onIceCandidate)||void 0===t||t.call(this,e,kc.PUBLISHER)},this.publisher.onTrack=e=>{var t;null===(t=this.onTrack)||void 0===t||t.call(this,e)},this.publisher.onOffer=(e,t)=>{var n;null===(n=this.onPublisherOffer)||void 0===n||n.call(this,e,t)},this.state=Gp.NEW,this.connectionLock=new Do,this.remoteOfferLock=new Do}get logContext(){var e,t;return Object.assign({},null===(t=(e=this.loggerOptions).loggerContextCb)||void 0===t?void 0:t.call(e))}requirePublisher(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.isPublisherConnectionRequired=e,this.updateState()}createAndSendPublisherOffer(e){return this.publisher.createAndSendOffer(e)}setPublisherAnswer(e,t){return this.publisher.setRemoteDescription(e,t)}removeTrack(e){return this.publisher.removeTrack(e)}close(){return jl(this,void 0,void 0,function*(){var e;if(this.publisher&&"closed"!==this.publisher.getSignallingState()){const e=this.publisher;for(const n of e.getSenders())try{e.canRemoveTrack()&&e.removeTrack(n)}catch(t){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:t}))}}yield Promise.all([this.publisher.close(),null===(e=this.subscriber)||void 0===e?void 0:e.close()]),this.updateState()})}triggerIceRestart(){return jl(this,void 0,void 0,function*(){this.subscriber&&(this.subscriber.restartingIce=!0),this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,t){return jl(this,void 0,void 0,function*(){var n;t===kc.PUBLISHER?yield this.publisher.addIceCandidate(e):yield null===(n=this.subscriber)||void 0===n?void 0:n.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e,t){return jl(this,void 0,void 0,function*(){var n,i,r;this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:null===(n=this.subscriber)||void 0===n?void 0:n.getSignallingState().toString()}));const o=yield this.remoteOfferLock.lock();try{if(!(yield null===(i=this.subscriber)||void 0===i?void 0:i.setRemoteDescription(e,t)))return;return yield null===(r=this.subscriber)||void 0===r?void 0:r.createAndSetAnswer()}finally{o()}})}updateConfiguration(e,t){var n;this.publisher.setConfiguration(e),null===(n=this.subscriber)||void 0===n||n.setConfiguration(e),t&&this.triggerIceRestart()}ensurePCTransportConnection(e,t){return jl(this,void 0,void 0,function*(){var n;const i=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&"connected"!==this.publisher.getConnectionState()&&"connecting"!==this.publisher.getConnectionState()&&(this.log.debug("negotiation required, start negotiating",this.logContext),this.publisher.negotiate()),yield Promise.all(null===(n=this.requiredTransports)||void 0===n?void 0:n.map(n=>this.ensureTransportConnected(n,e,t)))}finally{i()}})}negotiate(e){return jl(this,void 0,void 0,function*(){return new $u((t,n)=>jl(this,void 0,void 0,function*(){const i=setTimeout(()=>{n(new Sd("negotiation timed out"))},this.peerConnectionTimeout);e.signal.addEventListener("abort",()=>{clearTimeout(i),n(new Sd("negotiation aborted"))}),this.publisher.once(Dp,()=>{e.signal.aborted||this.publisher.once(Lp,()=>{clearTimeout(i),t()})}),yield this.publisher.negotiate(e=>{clearTimeout(i),e instanceof Error?n(e):n(new Error(String(e)))})}))})}addPublisherTransceiver(e,t){return this.publisher.addTransceiver(e,t)}addPublisherTransceiverOfKind(e,t){return this.publisher.addTransceiverOfKind(e,t)}getMidForReceiver(e){const t=(this.subscriber?this.subscriber.getTransceivers():this.publisher.getTransceivers()).find(t=>t.receiver===e);return null==t?void 0:t.mid}addPublisherTrack(e){return this.publisher.addTrack(e)}createPublisherDataChannel(e,t){return this.publisher.createDataChannel(e,t)}getConnectedAddress(e){return e===kc.PUBLISHER||e===kc.SUBSCRIBER?this.publisher.getConnectedAddress():this.requiredTransports[0].getConnectedAddress()}get requiredTransports(){const e=[];return this.isPublisherConnectionRequired&&e.push(this.publisher),this.isSubscriberConnectionRequired&&this.subscriber&&e.push(this.subscriber),e}ensureTransportConnected(e,t){return jl(this,arguments,void 0,function(e,t){var n=this;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.peerConnectionTimeout;return function*(){if("connected"!==e.getConnectionState())return new Promise((e,r)=>jl(n,void 0,void 0,function*(){const n=()=>{this.log.warn("abort transport connection",this.logContext),xd.clearTimeout(o),r(gd.cancelled("room connection has been cancelled"))};(null==t?void 0:t.signal.aborted)&&n(),null==t||t.signal.addEventListener("abort",n);const o=xd.setTimeout(()=>{null==t||t.signal.removeEventListener("abort",n),r(gd.internal("could not establish pc connection"))},i);for(;this.state!==Gp.CONNECTED;)if(yield ih(50),null==t?void 0:t.signal.aborted)return void r(gd.cancelled("room connection has been cancelled"));xd.clearTimeout(o),null==t||t.signal.removeEventListener("abort",n),e()}))}()})}}class Qp{static fetchRegionSettings(e,t,n){return jl(this,void 0,void 0,function*(){const i=yield Qp.fetchLock.lock();try{const i=yield fetch("".concat(function(e){return"".concat(e.protocol.replace("ws","http"),"//").concat(e.host,"/settings")}(e),"/regions"),{headers:{authorization:"Bearer ".concat(t)},signal:n});if(i.ok){const e=function(e){var t;const n=e.get("Cache-Control");if(n){const e=null===(t=n.match(/(?:^|[,\s])max-age=(\d+)/))||void 0===t?void 0:t[1];if(e)return parseInt(e,10)}}(i.headers),t=e?1e3*e:5e3;return{regionSettings:yield i.json(),updatedAtInMs:Date.now(),maxAgeInMs:t}}throw 401===i.status?gd.notAllowed("Could not fetch region settings: ".concat(i.statusText),i.status):gd.internal("Could not fetch region settings: ".concat(i.statusText))}catch(r){throw r instanceof gd?r:(null==n?void 0:n.aborted)?gd.cancelled("Region fetching was aborted"):gd.serverUnreachable("Could not fetch region settings, ".concat(r instanceof Error?"".concat(r.name,": ").concat(r.message):r))}finally{i()}})}static scheduleRefetch(e,t,n){return jl(this,void 0,void 0,function*(){const i=Qp.settingsTimeouts.get(e.hostname);clearTimeout(i),Qp.settingsTimeouts.set(e.hostname,setTimeout(()=>jl(this,void 0,void 0,function*(){try{const n=yield Qp.fetchRegionSettings(e,t);Qp.updateCachedRegionSettings(e,t,n)}catch(i){if(i instanceof gd&&i.reason===nd.NotAllowed)return void Ol.debug("token is not valid, cancelling auto region refresh");Ol.debug("auto refetching of region settings failed",{error:i}),Qp.scheduleRefetch(e,t,n)}}),n))})}static updateCachedRegionSettings(e,t,n){Qp.cache.set(e.hostname,n),Qp.scheduleRefetch(e,t,n.maxAgeInMs)}static stopRefetch(e){const t=Qp.settingsTimeouts.get(e);t&&(clearTimeout(t),Qp.settingsTimeouts.delete(e))}static scheduleCleanup(e){let t=Qp.connectionTrackers.get(e);t&&(t.cleanupTimeout&&clearTimeout(t.cleanupTimeout),t.cleanupTimeout=setTimeout(()=>{const t=Qp.connectionTrackers.get(e);t&&0===t.connectionCount&&(Ol.debug("stopping region refetch after disconnect delay",{hostname:e}),Qp.stopRefetch(e)),t&&(t.cleanupTimeout=void 0)},3e4))}static cancelCleanup(e){const t=Qp.connectionTrackers.get(e);(null==t?void 0:t.cleanupTimeout)&&(clearTimeout(t.cleanupTimeout),t.cleanupTimeout=void 0)}notifyConnected(){const e=this.serverUrl.hostname;let t=Qp.connectionTrackers.get(e);t||(t={connectionCount:0},Qp.connectionTrackers.set(e,t)),t.connectionCount++,Qp.cancelCleanup(e)}notifyDisconnected(){const e=this.serverUrl.hostname,t=Qp.connectionTrackers.get(e);t&&(t.connectionCount=Math.max(0,t.connectionCount-1),0===t.connectionCount&&Qp.scheduleCleanup(e))}constructor(e,t){this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=t}updateToken(e){this.token=e}isCloud(){return mh(this.serverUrl)}getServerUrl(){return this.serverUrl}fetchRegionSettings(e){return jl(this,void 0,void 0,function*(){return Qp.fetchRegionSettings(this.serverUrl,this.token,e)})}getNextBestRegionUrl(e){return jl(this,void 0,void 0,function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");let t=Qp.cache.get(this.serverUrl.hostname);(!t||Date.now()-t.updatedAtInMs>t.maxAgeInMs)&&(t=yield this.fetchRegionSettings(e),Qp.updateCachedRegionSettings(this.serverUrl,this.token,t));const n=t.regionSettings.regions.filter(e=>!this.attemptedRegions.find(t=>t.url===e.url));if(n.length>0){const e=n[0];return this.attemptedRegions.push(e),Ol.debug("next region: ".concat(e.region)),e.url}return null})}resetAttempts(){this.attemptedRegions=[]}setServerReportedRegions(e){Qp.updateCachedRegionSettings(this.serverUrl,this.token,e)}}Qp.cache=new Map,Qp.settingsTimeouts=new Map,Qp.connectionTrackers=new Map,Qp.fetchLock=new Do;class Yp extends Error{constructor(e,t,n){super(t),this.code=e,this.message=Zp(t,Yp.MAX_MESSAGE_BYTES),this.data=n?Zp(n,Yp.MAX_DATA_BYTES):void 0}static fromProto(e){return new Yp(e.code,e.message,e.data)}toProto(){return new ic({code:this.code,message:this.message,data:this.data})}static builtIn(e,t){return new Yp(Yp.ErrorCode[e],Yp.ErrorMessage[e],t)}}Yp.MAX_MESSAGE_BYTES=256,Yp.MAX_DATA_BYTES=15360,Yp.ErrorCode={APPLICATION_ERROR:1500,CONNECTION_TIMEOUT:1501,RESPONSE_TIMEOUT:1502,RECIPIENT_DISCONNECTED:1503,RESPONSE_PAYLOAD_TOO_LARGE:1504,SEND_FAILED:1505,UNSUPPORTED_METHOD:1400,RECIPIENT_NOT_FOUND:1401,REQUEST_PAYLOAD_TOO_LARGE:1402,UNSUPPORTED_SERVER:1403,UNSUPPORTED_VERSION:1404},Yp.ErrorMessage={APPLICATION_ERROR:"Application error in method handler",CONNECTION_TIMEOUT:"Connection timeout",RESPONSE_TIMEOUT:"Response timeout",RECIPIENT_DISCONNECTED:"Recipient disconnected",RESPONSE_PAYLOAD_TOO_LARGE:"Response payload too large",SEND_FAILED:"Failed to send",UNSUPPORTED_METHOD:"Method not supported at destination",RECIPIENT_NOT_FOUND:"Recipient not found",REQUEST_PAYLOAD_TOO_LARGE:"Request payload too large",UNSUPPORTED_SERVER:"RPC not supported by server",UNSUPPORTED_VERSION:"Unsupported RPC version"};function Xp(e){return(new TextEncoder).encode(e).length}function Zp(e,t){if(Xp(e)<=t)return e;let n=0,i=e.length;const r=new TextEncoder;for(;n<i;){const o=Math.floor((n+i+1)/2);r.encode(e.slice(0,o)).length<=t?n=o:i=o-1}return e.slice(0,n)}const ef=2e3;function tf(e,t){if(!t)return 0;let n,i;return"bytesReceived"in e?(n=e.bytesReceived,i=t.bytesReceived):"bytesSent"in e&&(n=e.bytesSent,i=t.bytesSent),void 0===n||void 0===i||void 0===e.timestamp||void 0===t.timestamp?0:8*(n-i)*1e3/(e.timestamp-t.timestamp)}const nf="undefined"!=typeof MediaRecorder;const rf=nf?MediaRecorder:class{constructor(){throw new Error("MediaRecorder is not available in this environment")}};class of extends rf{constructor(e,t){if(!nf)throw new Error("MediaRecorder is not available in this environment");let n,i;super(new MediaStream([e.mediaStreamTrack]),t);const r=()=>{this.removeEventListener("dataavailable",n),this.removeEventListener("stop",r),this.removeEventListener("error",o),null==i||i.close(),i=void 0},o=e=>{null==i||i.error(e),this.removeEventListener("dataavailable",n),this.removeEventListener("stop",r),this.removeEventListener("error",o),i=void 0};this.byteStream=new ReadableStream({start:e=>{i=e,n=t=>jl(this,void 0,void 0,function*(){let n;if(t.data.arrayBuffer){const e=yield t.data.arrayBuffer();n=new Uint8Array(e)}else{if(!t.data.byteArray)throw new Error("no data available!");n=t.data.byteArray}void 0!==i&&e.enqueue(n)}),this.addEventListener("dataavailable",n)},cancel:()=>{r()}}),this.addEventListener("stop",r),this.addEventListener("error",o)}}class af extends Zd{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}get hasPreConnectBuffer(){return!!this.localTrackRecorder}constructor(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];super(e,t,arguments.length>4?arguments[4]:void 0),this.manuallyStopped=!1,this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch(()=>this.log.debug("track mute bounce got cancelled by an unmute event",this.logContext)),this.debouncedTrackMuteHandler=Mp(()=>jl(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>jl(this,void 0,void 0,function*(){this.debouncedTrackMuteHandler.cancel("unmute"),yield this.resumeUpstream()}),this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),this.emit(fd.Ended,this)},this.reacquireTrack=!1,this.providedByUser=i,this.muteLock=new Do,this.pauseUpstreamLock=new Do,this.trackChangeLock=new Do,this.trackChangeLock.lock().then(t=>jl(this,void 0,void 0,function*(){try{yield this.setMediaStreamTrack(e,!0)}finally{t()}})),this._constraints=e.getConstraints(),n&&(this._constraints=n)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==Zd.Kind.Video)return;const{width:e,height:t}=this._mediaStreamTrack.getSettings();return e&&t?{width:e,height:t}:void 0}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){var e,t;return null!==(t=null===(e=this.processor)||void 0===e?void 0:e.processedTrack)&&void 0!==t?t:this._mediaStreamTrack}get isLocal(){return!0}getSourceTrackSettings(){return this._mediaStreamTrack.getSettings()}setMediaStreamTrack(e,t){return jl(this,void 0,void 0,function*(){var n;if(e===this._mediaStreamTrack&&!t)return;let i;if(this._mediaStreamTrack&&(this.attachedElements.forEach(e=>{th(this._mediaStreamTrack,e)}),this.debouncedTrackMuteHandler.cancel("new-track"),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent)),this.mediaStream=new MediaStream([e]),e&&(e.addEventListener("ended",this.handleEnded),e.addEventListener("mute",this.handleTrackMuteEvent),e.addEventListener("unmute",this.handleTrackUnmuteEvent),this._constraints=e.getConstraints()),this.processor&&e){if(this.log.debug("restarting processor",this.logContext),"unknown"===this.kind)throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(eh(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement}),i=this.processor.processedTrack}this.sender&&"closed"!==(null===(n=this.sender.transport)||void 0===n?void 0:n.state)&&(yield this.sender.replaceTrack(null!=i?i:e)),this.providedByUser||this._mediaStreamTrack===e||this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach(t=>{eh(null!=i?i:e,t)}))})}waitForDimensions(){return jl(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3;return function*(){var n;if(e.kind===Zd.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");"iOS"===(null===(n=Yu())||void 0===n?void 0:n.os)&&(yield ih(10));const i=Date.now();for(;Date.now()-i<t;){const t=e.dimensions;if(t)return t;yield ih(50)}throw new yd("unable to get track dimensions after timeout")}()})}setDeviceId(e){return jl(this,void 0,void 0,function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===Nh(e)||(this._constraints.deviceId=e,!!this.isMuted||(yield this.restartTrack(),Nh(e)===this._mediaStreamTrack.getSettings().deviceId))})}getDeviceId(){return jl(this,arguments,void 0,function(){var e=this;let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function*(){if(e.source===Zd.Source.ScreenShare)return;const{deviceId:n,groupId:i}=e._mediaStreamTrack.getSettings(),r=e.kind===Zd.Kind.Audio?"audioinput":"videoinput";return t?cp.getInstance().normalizeDeviceId(r,n,i):n}()})}mute(){return jl(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return jl(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,t){return jl(this,void 0,void 0,function*(){const n=yield this.trackChangeLock.lock();try{if(!this.sender)throw new yd("unable to replace an unpublished track");let n,i;return"boolean"==typeof t?n=t:void 0!==t&&(n=t.userProvidedTrack,i=t.stopProcessor),this.providedByUser=null==n||n,this.log.debug("replace MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(e),i&&this.processor&&(yield this.internalStopProcessor()),this}finally{n()}})}restart(e){return jl(this,void 0,void 0,function*(){this.manuallyStopped=!1;const t=yield this.trackChangeLock.lock();try{e||(e=this._constraints);const{deviceId:t,facingMode:n}=e,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["deviceId","facingMode"]);this.log.debug("restarting track with constraints",Object.assign(Object.assign({},this.logContext),{constraints:e}));const r={audio:!1,video:!1};this.kind===Zd.Kind.Video?r.video=!t&&!n||{deviceId:t,facingMode:n}:r.audio=!t||Object.assign({deviceId:t},i),this.attachedElements.forEach(e=>{th(this.mediaStreamTrack,e)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const o=(yield navigator.mediaDevices.getUserMedia(r)).getTracks()[0];return this.kind===Zd.Kind.Video&&(yield o.applyConstraints(i)),o.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(o),this._constraints=e,this.emit(fd.Restarted,this),this.manuallyStopped&&(this.log.warn("track was stopped during a restart, stopping restarted track",this.logContext),this.stop()),this}finally{t()}})}setTrackMuted(e){this.log.debug("setting ".concat(this.kind," track ").concat(e?"muted":"unmuted"),this.logContext),this.isMuted===e&&this._mediaStreamTrack.enabled!==e||(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?fd.Muted:fd.Unmuted,this))}get needsReAcquisition(){return"live"!==this._mediaStreamTrack.readyState||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return jl(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),hh()&&(this.log.debug("visibility changed, is in Background: ".concat(this.isInBackground),this.logContext),this.isInBackground||!this.needsReAcquisition||this.isUserProvided||this.isMuted||(this.log.debug("track needs to be reacquired, restarting ".concat(this.source),this.logContext),yield this.restart(),this.reacquireTrack=!1))})}stop(){var e;this.manuallyStopped=!0,super.stop(),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),null===(e=this.processor)||void 0===e||e.destroy(),this.processor=void 0}pauseUpstream(){return jl(this,void 0,void 0,function*(){var e;const t=yield this.pauseUpstreamLock.lock();try{if(!0===this._isUpstreamPaused)return;if(!this.sender)return void this.log.warn("unable to pause upstream for an unpublished track",this.logContext);this._isUpstreamPaused=!0,this.emit(fd.UpstreamPaused,this);const t=Yu();if("Safari"===(null==t?void 0:t.name)&&kh(t.version,"12.0")<0)throw new vd("pauseUpstream is not supported on Safari < 12.");"closed"!==(null===(e=this.sender.transport)||void 0===e?void 0:e.state)&&(yield this.sender.replaceTrack(null))}finally{t()}})}resumeUpstream(){return jl(this,void 0,void 0,function*(){var e;const t=yield this.pauseUpstreamLock.lock();try{if(!1===this._isUpstreamPaused)return;if(!this.sender)return void this.log.warn("unable to resume upstream for an unpublished track",this.logContext);this._isUpstreamPaused=!1,this.emit(fd.UpstreamResumed,this),"closed"!==(null===(e=this.sender.transport)||void 0===e?void 0:e.state)&&(yield this.sender.replaceTrack(this.mediaStreamTrack))}finally{t()}})}getRTCStatsReport(){return jl(this,void 0,void 0,function*(){var e;if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return;return yield this.sender.getStats()})}setProcessor(e){return jl(this,arguments,void 0,function(e){var t=this;let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function*(){var i;const r=yield t.trackChangeLock.lock();try{t.log.debug("setting up processor",t.logContext);const r=document.createElement(t.kind),o={kind:t.kind,track:t._mediaStreamTrack,element:r,audioContext:t.audioContext};if(yield e.init(o),t.log.debug("processor initialized",t.logContext),t.processor&&(yield t.internalStopProcessor()),"unknown"===t.kind)throw TypeError("cannot set processor on track of unknown kind");if(eh(t._mediaStreamTrack,r),r.muted=!0,r.play().catch(e=>{e instanceof DOMException&&"AbortError"===e.name?(t.log.warn("failed to play processor element, retrying",Object.assign(Object.assign({},t.logContext),{error:e})),setTimeout(()=>{r.play().catch(e=>{t.log.error("failed to play processor element",Object.assign(Object.assign({},t.logContext),{err:e}))})},100)):t.log.error("failed to play processor element",Object.assign(Object.assign({},t.logContext),{error:e}))}),t.processor=e,t.processorElement=r,t.processor.processedTrack){for(const e of t.attachedElements)e!==t.processorElement&&n&&(th(t._mediaStreamTrack,e),eh(t.processor.processedTrack,e));yield null===(i=t.sender)||void 0===i?void 0:i.replaceTrack(t.processor.processedTrack)}t.emit(fd.TrackProcessorUpdate,t.processor)}finally{r()}}()})}getProcessor(){return this.processor}stopProcessor(){return jl(this,arguments,void 0,function(){var e=this;let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function*(){const n=yield e.trackChangeLock.lock();try{yield e.internalStopProcessor(t)}finally{n()}}()})}internalStopProcessor(){return jl(this,arguments,void 0,function(){var e=this;let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function*(){var n,i;e.processor&&(e.log.debug("stopping processor",e.logContext),null===(n=e.processor.processedTrack)||void 0===n||n.stop(),yield e.processor.destroy(),e.processor=void 0,t||(null===(i=e.processorElement)||void 0===i||i.remove(),e.processorElement=void 0),yield e._mediaStreamTrack.applyConstraints(e._constraints),yield e.setMediaStreamTrack(e._mediaStreamTrack,!0),e.emit(fd.TrackProcessorUpdate))}()})}startPreConnectBuffer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100;if(nf)if(this.localTrackRecorder)this.log.warn("preconnect buffer already started");else{{let e="audio/webm;codecs=opus";MediaRecorder.isTypeSupported(e)||(e="video/mp4"),this.localTrackRecorder=new of(this,{mimeType:e})}this.localTrackRecorder.start(e),this.autoStopPreConnectBuffer=setTimeout(()=>{this.log.warn("preconnect buffer timed out, stopping recording automatically",this.logContext),this.stopPreConnectBuffer()},1e4)}else this.log.warn("MediaRecorder is not available, cannot start preconnect buffer",this.logContext)}stopPreConnectBuffer(){clearTimeout(this.autoStopPreConnectBuffer),this.localTrackRecorder&&(this.localTrackRecorder.stop(),this.localTrackRecorder=void 0)}getPreConnectBuffer(){var e;return null===(e=this.localTrackRecorder)||void 0===e?void 0:e.byteStream}getPreConnectBufferMimeType(){var e;return null===(e=this.localTrackRecorder)||void 0===e?void 0:e.mimeType}}class sf extends af{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;super(e,Zd.Kind.Audio,t,n,r),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>jl(this,void 0,void 0,function*(){if(!this.sender)return void(this._currentBitrate=0);let e;try{e=yield this.getSenderStats()}catch(t){return void this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:t}))}e&&this.prevStats&&(this._currentBitrate=tf(e,this.prevStats)),this.prevStats=e}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit(fd.AudioTrackFeatureUpdate,this,Is.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit(fd.AudioTrackFeatureUpdate,this,Is.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=i,this.checkForSilence()}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return jl(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===Zd.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(this.log.debug("stopping mic track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return jl(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{if(!this.isMuted)return this.log.debug("Track already unmuted",this.logContext),this;const t=this._constraints.deviceId&&this._mediaStreamTrack.getSettings().deviceId!==Nh(this._constraints.deviceId);return this.source!==Zd.Source.Microphone||!this.stopOnMute&&"ended"!==this._mediaStreamTrack.readyState&&!t||this.isUserProvided||(this.log.debug("reacquiring mic track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this}finally{t()}})}restartTrack(e){return jl(this,void 0,void 0,function*(){let t;if(e){const n=Bd({audio:e});"boolean"!=typeof n.audio&&(t=n.audio)}yield this.restart(t)})}restart(e){const t=Object.create(null,{restart:{get:()=>super.restart}});return jl(this,void 0,void 0,function*(){const n=yield t.restart.call(this,e);return this.checkForSilence(),n})}startMonitor(){ph()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},ef)))}setProcessor(e){return jl(this,void 0,void 0,function*(){var t;const n=yield this.trackChangeLock.lock();try{if(!fh()&&!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.internalStopProcessor());const n={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext};this.log.debug("setting up audio processor ".concat(e.name),this.logContext),yield e.init(n),this.processor=e,this.processor.processedTrack&&(yield null===(t=this.sender)||void 0===t?void 0:t.replaceTrack(this.processor.processedTrack),this.processor.processedTrack.addEventListener("enable-lk-krisp-noise-filter",this.handleKrispNoiseFilterEnable),this.processor.processedTrack.addEventListener("disable-lk-krisp-noise-filter",this.handleKrispNoiseFilterDisable)),this.emit(fd.TrackProcessorUpdate,this.processor)}finally{n()}})}setAudioContext(e){this.audioContext=e}getSenderStats(){return jl(this,void 0,void 0,function*(){var e;if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return;let t;return(yield this.sender.getStats()).forEach(e=>{"outbound-rtp"===e.type&&(t={type:"audio",streamId:e.id,packetsSent:e.packetsSent,packetsLost:e.packetsLost,bytesSent:e.bytesSent,timestamp:e.timestamp,roundTripTime:e.roundTripTime,jitter:e.jitter})}),t})}checkForSilence(){return jl(this,void 0,void 0,function*(){const e=yield zd(this);return e&&(this.isMuted||this.log.debug("silence detected on local audio track",this.logContext),this.emit(fd.AudioSilenceDetected)),e})}}const cf=Object.values(Ld),lf=Object.values(Ad),uf=Object.values(jd),df=[Ld.h180,Ld.h360],hf=[Ad.h180,Ad.h360],pf=["q","h","f"];function ff(e,t,n,i){var r,o;let a=null==i?void 0:i.videoEncoding;e&&(a=null==i?void 0:i.screenShareEncoding);const s=null==i?void 0:i.simulcast,c=null==i?void 0:i.scalabilityMode,l=null==i?void 0:i.videoCodec;if(!a&&!s&&!c||!t||!n)return[{}];a||(a=function(e,t,n,i){const r=function(e,t,n){if(e)return uf;const i=t>n?t/n:n/t;if(Math.abs(i-16/9)<Math.abs(i-4/3))return cf;return lf}(e,t,n);let{encoding:o}=r[0];const a=Math.max(t,n);for(let s=0;s<r.length;s+=1){const e=r[s];if(o=e.encoding,e.width>=a)break}if(i)switch(i){case"av1":case"h265":o=Object.assign({},o),o.maxBitrate=.7*o.maxBitrate;break;case"vp9":o=Object.assign({},o),o.maxBitrate=.85*o.maxBitrate}return o}(e,t,n,l),Ol.debug("using video encoding",a));const u=a.maxFramerate,d=new Pd(t,n,a.maxBitrate,a.maxFramerate,a.priority);if(c&&ah(l)){const e=new yf(c),t=[];if(e.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(c));const n=Yu();if(dh()||fh()||"Chrome"===(null==n?void 0:n.name)&&kh(null==n?void 0:n.version,"113")<0){const i="h"==e.suffix?2:3,r=function(e){return e||(e=Yu()),"Safari"===(null==e?void 0:e.name)&&kh(e.version,"18.3")>0||"iOS"===(null==e?void 0:e.os)&&!!(null==e?void 0:e.osVersion)&&kh(e.osVersion,"18.3")>0}(n);for(let n=0;n<e.spatial;n+=1)t.push({rid:pf[2-n],maxBitrate:a.maxBitrate/Math.pow(i,n),maxFramerate:d.encoding.maxFramerate,scaleResolutionDownBy:r?Math.pow(2,n):void 0});t[0].scalabilityMode=c}else t.push({maxBitrate:a.maxBitrate,maxFramerate:d.encoding.maxFramerate,scalabilityMode:c});return d.encoding.priority&&(t[0].priority=d.encoding.priority,t[0].networkPriority=d.encoding.priority),Ol.debug("using svc encoding",{encodings:t}),t}if(!s)return[a];let h,p=[];if(p=e?null!==(r=vf(null==i?void 0:i.screenShareSimulcastLayers))&&void 0!==r?r:mf(e,d):null!==(o=vf(null==i?void 0:i.videoSimulcastLayers))&&void 0!==o?o:mf(e,d),p.length>0){const e=p[0];p.length>1&&([,h]=p);const i=Math.max(t,n);if(i>=960&&h)return gf(t,n,[e,h,d],u);if(i>=480)return gf(t,n,[e,d],u)}return gf(t,n,[d])}function mf(e,t){if(e)return[{scaleResolutionDownBy:2,fps:(n=t).encoding.maxFramerate}].map(e=>{var t,i;return new Pd(Math.floor(n.width/e.scaleResolutionDownBy),Math.floor(n.height/e.scaleResolutionDownBy),Math.max(15e4,Math.floor(n.encoding.maxBitrate/(Math.pow(e.scaleResolutionDownBy,2)*((null!==(t=n.encoding.maxFramerate)&&void 0!==t?t:30)/(null!==(i=e.fps)&&void 0!==i?i:30))))),e.fps,n.encoding.priority)});var n;const{width:i,height:r}=t,o=i>r?i/r:r/i;return Math.abs(o-16/9)<Math.abs(o-4/3)?df:hf}function gf(e,t,n,i){const r=[];if(n.forEach((n,o)=>{if(o>=pf.length)return;const a=Math.min(e,t),s={rid:pf[o],scaleResolutionDownBy:Math.max(1,a/Math.min(n.width,n.height)),maxBitrate:n.encoding.maxBitrate},c=i&&n.encoding.maxFramerate?Math.min(i,n.encoding.maxFramerate):n.encoding.maxFramerate;c&&(s.maxFramerate=c);const l=ch()||0===o;n.encoding.priority&&l&&(s.priority=n.encoding.priority,s.networkPriority=n.encoding.priority),r.push(s)}),fh()&&"ios"===yh()){let e;r.forEach(t=>{e?t.maxFramerate&&t.maxFramerate>e&&(e=t.maxFramerate):e=t.maxFramerate});let t=!0;r.forEach(n=>{var i;n.maxFramerate!=e&&(t&&(t=!1,Ol.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),Ol.info('Setting framerate of encoding "'.concat(null!==(i=n.rid)&&void 0!==i?i:"",'" to ').concat(e)),n.maxFramerate=e)})}return r}function vf(e){if(e)return e.sort((e,t)=>{const{encoding:n}=e,{encoding:i}=t;return n.maxBitrate>i.maxBitrate?1:n.maxBitrate<i.maxBitrate?-1:n.maxBitrate===i.maxBitrate&&n.maxFramerate&&i.maxFramerate?n.maxFramerate>i.maxFramerate?1:-1:0})}class yf{constructor(e){const t=e.match(/^L(\d)T(\d)(h|_KEY|_KEY_SHIFT){0,1}$/);if(!t)throw new Error("invalid scalability mode");if(this.spatial=parseInt(t[1]),this.temporal=parseInt(t[2]),t.length>3)switch(t[3]){case"h":case"_KEY":case"_KEY_SHIFT":this.suffix=t[3]}}toString(){var e;return"L".concat(this.spatial,"T").concat(this.temporal).concat(null!==(e=this.suffix)&&void 0!==e?e:"")}}class bf extends af{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0;super(e,Zd.Kind.Video,t,n,i),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.isCpuConstrained=!1,this.optimizeForPerformance=!1,this.monitorSender=()=>jl(this,void 0,void 0,function*(){if(!this.sender)return void(this._currentBitrate=0);let e;try{e=yield this.getSenderStats()}catch(i){return void this.log.error("could not get video sender stats",Object.assign(Object.assign({},this.logContext),{error:i}))}const t=new Map(e.map(e=>[e.rid,e])),n=e.some(e=>"cpu"===e.qualityLimitationReason);if(n!==this.isCpuConstrained&&(this.isCpuConstrained=n,this.isCpuConstrained&&this.emit(fd.CpuConstrained)),this.prevStats){let e=0;t.forEach((t,n)=>{var i;const r=null===(i=this.prevStats)||void 0===i?void 0:i.get(n);e+=tf(t,r)}),this._currentBitrate=e}this.prevStats=t}),this.senderLock=new Do}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var t;if(this.signalClient=e,!ph())return;const n=null===(t=this.sender)||void 0===t?void 0:t.getParameters();n&&(this.encodings=n.encodings),this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},ef))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return jl(this,void 0,void 0,function*(){var t,n,i,r,o;yield e.pauseUpstream.call(this);try{for(var a,s=!0,c=Fl(this.simulcastCodecs.values());!(t=(a=yield c.next()).done);s=!0){r=a.value,s=!1;const e=r;yield null===(o=e.sender)||void 0===o?void 0:o.replaceTrack(null)}}catch(l){n={error:l}}finally{try{s||t||!(i=c.return)||(yield i.call(c))}finally{if(n)throw n.error}}})}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return jl(this,void 0,void 0,function*(){var t,n,i,r,o;yield e.resumeUpstream.call(this);try{for(var a,s=!0,c=Fl(this.simulcastCodecs.values());!(t=(a=yield c.next()).done);s=!0){r=a.value,s=!1;const e=r;yield null===(o=e.sender)||void 0===o?void 0:o.replaceTrack(e.mediaStreamTrack)}}catch(l){n={error:l}}finally{try{s||t||!(i=c.return)||(yield i.call(c))}finally{if(n)throw n.error}}})}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return jl(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source!==Zd.Source.Camera||this.isUserProvided||(this.log.debug("stopping camera track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return jl(this,void 0,void 0,function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.source!==Zd.Source.Camera||this.isUserProvided||(this.log.debug("reacquiring camera track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this):(this.log.debug("Track already unmuted",this.logContext),this)}finally{t()}})}setTrackMuted(e){super.setTrackMuted(e);for(const t of this.simulcastCodecs.values())t.mediaStreamTrack.enabled=!e}getSenderStats(){return jl(this,void 0,void 0,function*(){var e;if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return[];const t=[],n=yield this.sender.getStats();return n.forEach(e=>{var i;if("outbound-rtp"===e.type){const r={type:"video",streamId:e.id,frameHeight:e.frameHeight,frameWidth:e.frameWidth,framesPerSecond:e.framesPerSecond,framesSent:e.framesSent,firCount:e.firCount,pliCount:e.pliCount,nackCount:e.nackCount,packetsSent:e.packetsSent,bytesSent:e.bytesSent,qualityLimitationReason:e.qualityLimitationReason,qualityLimitationDurations:e.qualityLimitationDurations,qualityLimitationResolutionChanges:e.qualityLimitationResolutionChanges,rid:null!==(i=e.rid)&&void 0!==i?i:e.id,retransmittedPacketsSent:e.retransmittedPacketsSent,targetBitrate:e.targetBitrate,timestamp:e.timestamp},o=n.get(e.remoteId);o&&(r.jitter=o.jitter,r.packetsLost=o.packetsLost,r.roundTripTime=o.roundTripTime),t.push(r)}}),t.sort((e,t)=>{var n,i;return(null!==(n=t.frameWidth)&&void 0!==n?n:0)-(null!==(i=e.frameWidth)&&void 0!==i?i:0)}),t})}setPublishingQuality(e){const t=[];for(let n=Yd.LOW;n<=Yd.HIGH;n+=1)t.push(new Qc({quality:n,enabled:n<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(ah(this.codec),t)}restartTrack(e){return jl(this,void 0,void 0,function*(){var t,n,i,r,o;let a;if(e){const t=Bd({video:e});"boolean"!=typeof t.video&&(a=t.video)}yield this.restart(a),this.isCpuConstrained=!1;try{for(var s,c=!0,l=Fl(this.simulcastCodecs.values());!(t=(s=yield l.next()).done);c=!0){r=s.value,c=!1;const e=r;e.sender&&"closed"!==(null===(o=e.sender.transport)||void 0===o?void 0:o.state)&&(e.mediaStreamTrack=this.mediaStreamTrack.clone(),yield e.sender.replaceTrack(e.mediaStreamTrack))}}catch(u){n={error:u}}finally{try{c||t||!(i=l.return)||(yield i.call(l))}finally{if(n)throw n.error}}})}setProcessor(e){const t=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return jl(this,arguments,void 0,function(e){var n=this;let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function*(){var r,o,a,s,c,l;if(yield t.setProcessor.call(n,e,i),null===(c=n.processor)||void 0===c?void 0:c.processedTrack)try{for(var u,d=!0,h=Fl(n.simulcastCodecs.values());!(r=(u=yield h.next()).done);d=!0){s=u.value,d=!1;const e=s;yield null===(l=e.sender)||void 0===l?void 0:l.replaceTrack(n.processor.processedTrack)}}catch(p){o={error:p}}finally{try{d||r||!(a=h.return)||(yield a.call(h))}finally{if(o)throw o.error}}}()})}setDegradationPreference(e){return jl(this,void 0,void 0,function*(){if(this.degradationPreference=e,this.sender)try{this.log.debug("setting degradationPreference to ".concat(e),this.logContext);const t=this.sender.getParameters();t.degradationPreference=e,this.sender.setParameters(t)}catch(t){this.log.warn("failed to set degradationPreference",Object.assign({error:t},this.logContext))}})}addSimulcastTrack(e,t){if(this.simulcastCodecs.has(e))return void this.log.error("".concat(e," already added, skipping adding simulcast codec"),this.logContext);const n={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:t};return this.simulcastCodecs.set(e,n),n}setSimulcastTrackSender(e,t){const n=this.simulcastCodecs.get(e);n&&(n.sender=t,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},5e3))}setPublishingCodecs(e){return jl(this,void 0,void 0,function*(){var t,n,i,r,o,a,s;if(this.log.debug("setting publishing codecs",Object.assign(Object.assign({},this.logContext),{codecs:e,currentCodec:this.codec})),!this.codec&&e.length>0)return yield this.setPublishingLayers(ah(e[0].codec),e[0].qualities),[];this.subscribedCodecs=e;const c=[];try{for(t=!0,n=Fl(e);!(r=(i=yield n.next()).done);t=!0){s=i.value,t=!1;const e=s;if(this.codec&&this.codec!==e.codec){const t=this.simulcastCodecs.get(e.codec);if(this.log.debug("try setPublishingCodec for ".concat(e.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:t})),t&&t.sender)t.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(e.codec),this.logContext),yield kf(t.sender,t.encodings,e.qualities,this.senderLock,ah(e.codec),this.log,this.logContext));else for(const n of e.qualities)if(n.enabled){c.push(e.codec);break}}else yield this.setPublishingLayers(ah(e.codec),e.qualities)}}catch(l){o={error:l}}finally{try{t||r||!(a=n.return)||(yield a.call(n))}finally{if(o)throw o.error}}return c})}setPublishingLayers(e,t){return jl(this,void 0,void 0,function*(){this.optimizeForPerformance?this.log.info("skipping setPublishingLayers due to optimized publishing performance",Object.assign(Object.assign({},this.logContext),{qualities:t})):(this.log.debug("setting publishing layers",Object.assign(Object.assign({},this.logContext),{qualities:t})),this.sender&&this.encodings&&(yield kf(this.sender,this.encodings,t,this.senderLock,e,this.log,this.logContext)))})}prioritizePerformance(){return jl(this,void 0,void 0,function*(){if(!this.sender)throw new Error("sender not found");const e=yield this.senderLock.lock();try{this.optimizeForPerformance=!0;const e=this.sender.getParameters();e.encodings=e.encodings.map((e,t)=>{var n;return Object.assign(Object.assign({},e),{active:0===t,scaleResolutionDownBy:Math.max(1,Math.ceil((null!==(n=this.mediaStreamTrack.getSettings().height)&&void 0!==n?n:360)/360)),scalabilityMode:0===t&&ah(this.codec)?"L1T3":void 0,maxFramerate:0===t?15:0,maxBitrate:0===t?e.maxBitrate:0})}),this.log.debug("setting performance optimised encodings",Object.assign(Object.assign({},this.logContext),{encodings:e.encodings})),this.encodings=e.encodings,yield this.sender.setParameters(e)}catch(t){this.log.error("failed to set performance optimised encodings",Object.assign(Object.assign({},this.logContext),{error:t})),this.optimizeForPerformance=!1}finally{e()}})}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return jl(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),hh()&&this.isInBackground&&this.source===Zd.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function kf(e,t,n,i,r,o,a){return jl(this,void 0,void 0,function*(){const s=yield i.lock();o.debug("setPublishingLayersForSender",Object.assign(Object.assign({},a),{sender:e,qualities:n,senderEncodings:t}));try{const i=e.getParameters(),{encodings:s}=i;if(!s)return;if(s.length!==t.length)return void o.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},a),{encodings:s,senderEncodings:t}));let c=!1;if(!1&&s[0].scalabilityMode);else{if(r){n.some(e=>e.enabled)&&n.forEach(e=>e.enabled=!0)}s.forEach((e,i)=>{var r;let s=null!==(r=e.rid)&&void 0!==r?r:"";""===s&&(s="q");const l=Sf(s),u=n.find(e=>e.quality===l);u&&e.active!==u.enabled&&(c=!0,e.active=u.enabled,o.debug("setting layer ".concat(u.quality," to ").concat(e.active?"enabled":"disabled"),a),ch()&&(u.enabled?(e.scaleResolutionDownBy=t[i].scaleResolutionDownBy,e.maxBitrate=t[i].maxBitrate,e.maxFrameRate=t[i].maxFrameRate):(e.scaleResolutionDownBy=4,e.maxBitrate=10,e.maxFrameRate=2)))})}c&&(i.encodings=s,o.debug("setting encodings",Object.assign(Object.assign({},a),{encodings:i.encodings})),yield e.setParameters(i))}finally{s()}})}function Sf(e){switch(e){case"f":default:return Yd.HIGH;case"h":return Yd.MEDIUM;case"q":return Yd.LOW}}function Cf(e,t,n,i){if(!n)return[new zs({quality:Yd.HIGH,width:e,height:t,bitrate:0,ssrc:0})];if(i){const i=n[0].scalabilityMode,r=new yf(i),o=[],a="h"==r.suffix?1.5:2,s="h"==r.suffix?2:3;for(let c=0;c<r.spatial;c+=1)o.push(new zs({quality:Math.min(Yd.HIGH,r.spatial-1)-c,width:Math.ceil(e/Math.pow(a,c)),height:Math.ceil(t/Math.pow(a,c)),bitrate:n[0].maxBitrate?Math.ceil(n[0].maxBitrate/Math.pow(s,c)):0,ssrc:0}));return o}return n.map(n=>{var i,r,o;const a=null!==(i=n.scaleResolutionDownBy)&&void 0!==i?i:1;let s=Sf(null!==(r=n.rid)&&void 0!==r?r:"");return new zs({quality:s,width:Math.ceil(e/a),height:Math.ceil(t/a),bitrate:null!==(o=n.maxBitrate)&&void 0!==o?o:0,ssrc:0})})}const Tf="_lossy",wf="_reliable",Ef="leave-reconnect";var xf,Pf;(Pf=xf||(xf={}))[Pf.New=0]="New",Pf[Pf.Connected=1]="Connected",Pf[Pf.Disconnected=2]="Disconnected",Pf[Pf.Reconnecting=3]="Reconnecting",Pf[Pf.Closed=4]="Closed";class _f extends Vl.EventEmitter{get isClosed(){return this._isClosed}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){var t;super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=Kp.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.latestRemoteOfferId=0,this.subscriberPrimary=!1,this.pcState=xf.New,this._isClosed=!0,this.pendingTrackResolvers={},this.reconnectAttempts=0,this.reconnectStart=0,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.shouldFailNext=!1,this.log=Ol,this.reliableDataSequence=1,this.reliableMessageBuffer=new bp,this.reliableReceivedState=new kp(3e4),this.lossyDataStatCurrentBytes=0,this.lossyDataStatByterate=0,this.lossyDataDropCount=0,this.midToTrackId={},this.isWaitingForNetworkReconnect=!1,this.handleDataChannel=e=>jl(this,[e],void 0,function(e){var t=this;let{channel:n}=e;return function*(){if(n){if(n.label===wf)t.reliableDCSub=n;else{if(n.label!==Tf)return;t.lossyDCSub=n}t.log.debug("on data channel ".concat(n.id,", ").concat(n.label),t.logContext),n.onmessage=t.handleDataMessage}}()}),this.handleDataMessage=e=>jl(this,void 0,void 0,function*(){var t,n,i,r,o;const a=yield this.dataProcessLock.lock();try{let a;if(e.data instanceof ArrayBuffer)a=e.data;else{if(!(e.data instanceof Blob))return void this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:e.data}));a=yield e.data.arrayBuffer()}const s=qs.fromBinary(new Uint8Array(a));if(s.sequence>0&&""!==s.participantSid){const e=this.reliableReceivedState.get(s.participantSid);if(e&&s.sequence<=e)return;this.reliableReceivedState.set(s.participantSid,s.sequence)}if("speaker"===(null===(t=s.value)||void 0===t?void 0:t.case))this.emit(hd.ActiveSpeakersUpdate,s.value.value.speakers);else if("encryptedPacket"===(null===(n=s.value)||void 0===n?void 0:n.case)){if(!this.e2eeManager)return void this.log.error("Received encrypted packet but E2EE not set up",this.logContext);const e=yield null===(i=this.e2eeManager)||void 0===i?void 0:i.handleEncryptedData(s.value.value.encryptedValue,s.value.value.iv,s.participantIdentity,s.value.value.keyIndex),t=Ks.fromBinary(e.payload),n=new qs({value:t.value,participantIdentity:s.participantIdentity,participantSid:s.participantSid});"user"===(null===(r=n.value)||void 0===r?void 0:r.case)&&Rf(n,n.value.value),this.emit(hd.DataPacketReceived,n,s.value.value.encryptionType)}else"user"===(null===(o=s.value)||void 0===o?void 0:o.case)&&Rf(s,s.value.value),this.emit(hd.DataPacketReceived,s,Us.NONE)}finally{a()}}),this.handleDataError=e=>{const t=0===e.currentTarget.maxRetransmits?"lossy":"reliable";if(e instanceof ErrorEvent&&e.error){const{error:n}=e.error;this.log.error("DataChannel error on ".concat(t,": ").concat(e.message),Object.assign(Object.assign({},this.logContext),{error:n}))}else this.log.error("Unknown DataChannel error on ".concat(t),Object.assign(Object.assign({},this.logContext),{event:e}))},this.handleBufferedAmountLow=e=>{const t=0===e.currentTarget.maxRetransmits?Hs.LOSSY:Hs.RELIABLE;this.updateAndEmitDCBufferStatus(t)},this.handleDisconnect=(e,t)=>{if(this._isClosed)return;this.log.warn("".concat(e," disconnected"),this.logContext),0===this.reconnectAttempts&&(this.reconnectStart=Date.now());const n=e=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(e,"ms. giving up"),this.logContext),this.emit(hd.Disconnected),this.close()},i=Date.now()-this.reconnectStart;let r=this.getNextRetryDelay({elapsedMs:i,retryCount:this.reconnectAttempts});null!==r?(e===Ef&&(r=0),this.log.debug("reconnecting in ".concat(r,"ms"),this.logContext),this.clearReconnectTimeout(),this.token&&this.regionUrlProvider&&this.regionUrlProvider.updateToken(this.token),this.reconnectTimeout=xd.setTimeout(()=>this.attemptReconnect(t).finally(()=>this.reconnectTimeout=void 0),r)):n(i)},this.waitForRestarted=()=>new Promise((e,t)=>{this.pcState===xf.Connected&&e();const n=()=>{this.off(hd.Disconnected,i),e()},i=()=>{this.off(hd.Restarted,n),t()};this.once(hd.Restarted,n),this.once(hd.Disconnected,i)}),this.updateAndEmitDCBufferStatus=e=>{if(e===Hs.RELIABLE){const t=this.dataChannelForKind(e);t&&this.reliableMessageBuffer.alignBufferedAmount(t.bufferedAmount)}const t=this.isBufferStatusLow(e);void 0!==t&&t!==this.dcBufferStatus.get(e)&&(this.dcBufferStatus.set(e,t),this.emit(hd.DCBufferStatusChanged,t,e))},this.isBufferStatusLow=e=>{const t=this.dataChannelForKind(e);if(t)return t.bufferedAmount<=t.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>jl(this,void 0,void 0,function*(){if(!this.url)return;(yield fetch(Oh(this.url),{method:"HEAD"}).then(e=>e.ok).catch(()=>!1))&&(this.log.info("detected network reconnected"),(this.client.currentState===fp.RECONNECTING||this.isWaitingForNetworkReconnect&&this.client.currentState===fp.CONNECTED)&&(this.clearReconnectTimeout(),this.attemptReconnect(_s.RR_SIGNAL_DISCONNECTED),this.isWaitingForNetworkReconnect=!1))}),this.handleBrowserOffline=()=>jl(this,void 0,void 0,function*(){if(this.url)try{yield Promise.race([fetch(Oh(this.url),{method:"HEAD"}),ih(4e3).then(()=>Promise.reject())])}catch(e){!1===window.navigator.onLine&&(this.log.info("detected network interruption"),this.isWaitingForNetworkReconnect=!0)}}),this.log=Ml(null!==(t=e.loggerName)&&void 0!==t?t:Rl.Engine),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new gp(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.closingLock=new Do,this.dataProcessLock=new Do,this.dcBufferStatus=new Map([[Hs.LOSSY,!0],[Hs.RELIABLE,!0]]),this.client.onParticipantUpdate=e=>this.emit(hd.ParticipantUpdate,e),this.client.onConnectionQuality=e=>this.emit(hd.ConnectionQualityUpdate,e),this.client.onRoomUpdate=e=>this.emit(hd.RoomUpdate,e),this.client.onSubscriptionError=e=>this.emit(hd.SubscriptionError,e),this.client.onSubscriptionPermissionUpdate=e=>this.emit(hd.SubscriptionPermissionUpdate,e),this.client.onSpeakersChanged=e=>this.emit(hd.SpeakersChanged,e),this.client.onStreamStateUpdate=e=>this.emit(hd.StreamStateChanged,e),this.client.onRequestResponse=e=>this.emit(hd.SignalRequestResponse,e)}get logContext(){var e,t,n,i,r,o;return{room:null===(t=null===(e=this.latestJoinResponse)||void 0===e?void 0:e.room)||void 0===t?void 0:t.name,roomID:null===(i=null===(n=this.latestJoinResponse)||void 0===n?void 0:n.room)||void 0===i?void 0:i.sid,participant:null===(o=null===(r=this.latestJoinResponse)||void 0===r?void 0:r.participant)||void 0===o?void 0:o.identity,pID:this.participantSid}}join(e,t,n,i){return jl(this,arguments,void 0,function(e,t,n,i){var r=this;let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return function*(){r.url=e,r.token=t,r.signalOpts=n,r.maxJoinAttempts=n.maxRetries;try{r.joinAttempts+=1,r.setupSignalClientCallbacks();const a=yield r.client.join(e,t,n,i,o);return r._isClosed=!1,r.latestJoinResponse=a,r.subscriberPrimary=a.subscriberPrimary,r.pcManager||(yield r.configure(a,!o)),r.subscriberPrimary&&!a.fastPublish||r.negotiate().catch(e=>{Ol.error(e,r.logContext)}),r.registerOnLineListener(),r.clientConfiguration=a.clientConfiguration,r.emit(hd.SignalConnected,a),a}catch(a){if(a instanceof gd)if(a.reason===nd.ServerUnreachable){if(r.log.warn("Couldn't connect to server, attempt ".concat(r.joinAttempts," of ").concat(r.maxJoinAttempts),r.logContext),r.joinAttempts<r.maxJoinAttempts)return r.join(e,t,n,i,o)}else if(a.reason===nd.ServiceNotFound)return r.log.warn("Initial connection failed: ".concat(a.message," – Retrying")),r.join(e,t,n,i,!0);throw a}}()})}close(){return jl(this,void 0,void 0,function*(){const e=yield this.closingLock.lock();if(this.isClosed)e();else try{this._isClosed=!0,this.joinAttempts=0,this.emit(hd.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),this.cleanupLossyDataStats(),yield this.cleanupPeerConnections(),yield this.cleanupClient()}finally{e()}})}cleanupPeerConnections(){return jl(this,void 0,void 0,function*(){var e;yield null===(e=this.pcManager)||void 0===e?void 0:e.close(),this.pcManager=void 0;const t=e=>{e&&(e.close(),e.onbufferedamountlow=null,e.onclose=null,e.onclosing=null,e.onerror=null,e.onmessage=null,e.onopen=null)};t(this.lossyDC),t(this.lossyDCSub),t(this.reliableDC),t(this.reliableDCSub),this.lossyDC=void 0,this.lossyDCSub=void 0,this.reliableDC=void 0,this.reliableDCSub=void 0,this.reliableMessageBuffer=new bp,this.reliableDataSequence=1,this.reliableReceivedState.clear()})}cleanupLossyDataStats(){this.lossyDataStatByterate=0,this.lossyDataStatCurrentBytes=0,this.lossyDataStatInterval&&(clearInterval(this.lossyDataStatInterval),this.lossyDataStatInterval=void 0),this.lossyDataDropCount=0}cleanupClient(){return jl(this,void 0,void 0,function*(){yield this.client.close(),this.client.resetCallbacks()})}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new yd("a track with the same ID has already been published");return new Promise((t,n)=>{const i=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],n(gd.timeout("publication of local track timed out, no response from server"))},1e4);this.pendingTrackResolvers[e.cid]={resolve:e=>{clearTimeout(i),t(e)},reject:()=>{clearTimeout(i),n(new Error("Cancelled publication by calling unpublish"))}},this.client.sendAddTrack(e)})}removeTrack(e){if(e.track&&this.pendingTrackResolvers[e.track.id]){const{reject:t}=this.pendingTrackResolvers[e.track.id];t&&t(),delete this.pendingTrackResolvers[e.track.id]}try{return this.pcManager.removeTrack(e),!0}catch(t){this.log.warn("failed to remove track",Object.assign(Object.assign({},this.logContext),{error:t}))}return!1}updateMuteStatus(e,t){this.client.sendMuteTrack(e,t)}get dataSubscriberReadyState(){var e;return null===(e=this.reliableDCSub)||void 0===e?void 0:e.readyState}getConnectedServerAddress(){return jl(this,void 0,void 0,function*(){var e;return null===(e=this.pcManager)||void 0===e?void 0:e.getConnectedAddress()})}setRegionUrlProvider(e){this.regionUrlProvider=e}configure(e,t){return jl(this,void 0,void 0,function*(){var n,i;if(this.pcManager&&this.pcManager.currentState!==Gp.NEW)return;this.participantSid=null===(n=e.participant)||void 0===n?void 0:n.sid;const r=this.makeRTCConfiguration(e);var o;this.pcManager=new Jp(r,t?"publisher-only":e.subscriberPrimary?"subscriber-primary":"publisher-primary",this.loggerOptions),this.emit(hd.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(e,t)=>{this.client.sendIceCandidate(e,t)},this.pcManager.onPublisherOffer=(e,t)=>{this.client.sendOffer(e,t)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(t,n,i)=>jl(this,void 0,void 0,function*(){if(this.log.debug("primary PC state changed ".concat(t),this.logContext),["closed","disconnected","failed"].includes(n)&&(this.publisherConnectionPromise=void 0),t===Gp.CONNECTED){const t=this.pcState===xf.New;this.pcState=xf.Connected,t&&this.emit(hd.Connected,e)}else t===Gp.FAILED&&(this.pcState!==xf.Connected&&this.pcState!==xf.Reconnecting||(this.pcState=xf.Disconnected,this.handleDisconnect("peerconnection failed","failed"===i?_s.RR_SUBSCRIBER_FAILED:_s.RR_PUBLISHER_FAILED)));const r=this.client.isDisconnected||this.client.currentState===fp.RECONNECTING,o=[Gp.FAILED,Gp.CLOSING,Gp.CLOSED].includes(t);r&&o&&!this._isClosed&&this.emit(hd.Offline)}),this.pcManager.onTrack=e=>{0!==e.streams.length&&this.emit(hd.MediaTrackAdded,e.track,e.streams[0],e.receiver)},void 0!==(o=null===(i=e.serverInfo)||void 0===i?void 0:i.protocol)&&o>13||this.createDataChannels()})}setupSignalClientCallbacks(){this.client.onAnswer=(e,t,n)=>jl(this,void 0,void 0,function*(){this.pcManager&&(this.log.debug("received server answer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,midToTrackId:n})),this.midToTrackId=n,yield this.pcManager.setPublisherAnswer(e,t))}),this.client.onTrickle=(e,t)=>{this.pcManager&&(this.log.debug("got ICE candidate from peer",Object.assign(Object.assign({},this.logContext),{candidate:e,target:t})),this.pcManager.addIceCandidate(e,t))},this.client.onOffer=(e,t,n)=>jl(this,void 0,void 0,function*(){if(this.latestRemoteOfferId=t,!this.pcManager)return;this.midToTrackId=n;const i=yield this.pcManager.createSubscriberAnswerFromOffer(e,t);i&&this.client.sendAnswer(i,t)}),this.client.onLocalTrackPublished=e=>{var t;if(this.log.debug("received trackPublishedResponse",Object.assign(Object.assign({},this.logContext),{cid:e.cid,track:null===(t=e.track)||void 0===t?void 0:t.sid})),!this.pendingTrackResolvers[e.cid])return void this.log.error("missing track resolver for ".concat(e.cid),Object.assign(Object.assign({},this.logContext),{cid:e.cid}));const{resolve:n}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],n(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(hd.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(hd.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{var t;this.token=e,null===(t=this.regionUrlProvider)||void 0===t||t.updateToken(e)},this.client.onRemoteMuteChanged=(e,t)=>{this.emit(hd.RemoteMute,e,t)},this.client.onSubscribedQualityUpdate=e=>{this.emit(hd.SubscribedQualityUpdate,e)},this.client.onRoomMoved=e=>{var t;this.participantSid=null===(t=e.participant)||void 0===t?void 0:t.sid,this.latestJoinResponse&&(this.latestJoinResponse.room=e.room),this.emit(hd.RoomMoved,e)},this.client.onMediaSectionsRequirement=e=>{var t,n;const i={direction:"recvonly"};for(let r=0;r<e.numAudios;r++)null===(t=this.pcManager)||void 0===t||t.addPublisherTransceiverOfKind("audio",i);for(let r=0;r<e.numVideos;r++)null===(n=this.pcManager)||void 0===n||n.addPublisherTransceiverOfKind("video",i);this.negotiate()},this.client.onClose=()=>{this.handleDisconnect("signal",_s.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=e=>{switch(this.log.debug("client leave request",Object.assign(Object.assign({},this.logContext),{reason:null==e?void 0:e.reason})),e.regions&&this.regionUrlProvider&&(this.log.debug("updating regions",this.logContext),this.regionUrlProvider.setServerReportedRegions({updatedAtInMs:Date.now(),maxAgeInMs:5e3,regionSettings:e.regions})),e.action){case Bc.DISCONNECT:this.emit(hd.Disconnected,null==e?void 0:e.reason),this.close();break;case Bc.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(Ef);break;case Bc.RESUME:this.handleDisconnect(Ef)}}}makeRTCConfiguration(e){var t;const n=Object.assign({},this.rtcConfig);if((null===(t=this.signalOpts)||void 0===t?void 0:t.e2eeEnabled)&&(this.log.debug("E2EE - setting up transports with insertable streams",this.logContext),n.encodedInsertableStreams=!0),e.iceServers&&!n.iceServers){const t=[];e.iceServers.forEach(e=>{const n={urls:e.urls};e.username&&(n.username=e.username),e.credential&&(n.credential=e.credential),t.push(n)}),n.iceServers=t}return e.clientConfiguration&&e.clientConfiguration.forceRelay===xs.ENABLED&&(n.iceTransportPolicy="relay"),n.sdpSemantics="unified-plan",n.continualGatheringPolicy="gather_continually",n}createDataChannels(){this.pcManager&&(this.lossyDC&&(this.lossyDC.onmessage=null,this.lossyDC.onerror=null),this.reliableDC&&(this.reliableDC.onmessage=null,this.reliableDC.onerror=null),this.lossyDC=this.pcManager.createPublisherDataChannel(Tf,{ordered:!1,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel(wf,{ordered:!0}),this.lossyDC.onmessage=this.handleDataMessage,this.reliableDC.onmessage=this.handleDataMessage,this.lossyDC.onerror=this.handleDataError,this.reliableDC.onerror=this.handleDataError,this.lossyDC.bufferedAmountLowThreshold=65535,this.reliableDC.bufferedAmountLowThreshold=65535,this.lossyDC.onbufferedamountlow=this.handleBufferedAmountLow,this.reliableDC.onbufferedamountlow=this.handleBufferedAmountLow,this.cleanupLossyDataStats(),this.lossyDataStatInterval=setInterval(()=>{this.lossyDataStatByterate=this.lossyDataStatCurrentBytes,this.lossyDataStatCurrentBytes=0;const e=this.dataChannelForKind(Hs.LOSSY);if(e){const t=this.lossyDataStatByterate/10;e.bufferedAmountLowThreshold=Math.min(Math.max(t,8192),262144)}},1e3))}createSender(e,t,n){return jl(this,void 0,void 0,function*(){if(rh()){return yield this.createTransceiverRTCRtpSender(e,t,n)}if(oh()){this.log.warn("using add-track fallback",this.logContext);return yield this.createRTCRtpSender(e.mediaStreamTrack)}throw new kd("Required webRTC APIs not supported on this device")})}createSimulcastSender(e,t,n,i){return jl(this,void 0,void 0,function*(){if(rh())return this.createSimulcastTransceiverSender(e,t,n,i);if(oh())return this.log.debug("using add-track fallback",this.logContext),this.createRTCRtpSender(e.mediaStreamTrack);throw new kd("Cannot stream on this device")})}createTransceiverRTCRtpSender(e,t,n){return jl(this,void 0,void 0,function*(){if(!this.pcManager)throw new kd("publisher is closed");const i=[];e.mediaStream&&i.push(e.mediaStream),Uh(e)&&(e.codec=t.videoCodec);const r={direction:"sendonly",streams:i};n&&(r.sendEncodings=n);return(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,r)).sender})}createSimulcastTransceiverSender(e,t,n,i){return jl(this,void 0,void 0,function*(){if(!this.pcManager)throw new kd("publisher is closed");const r={direction:"sendonly"};i&&(r.sendEncodings=i);const o=yield this.pcManager.addPublisherTransceiver(t.mediaStreamTrack,r);if(n.videoCodec)return e.setSimulcastTrackSender(n.videoCodec,o.sender),o.sender})}createRTCRtpSender(e){return jl(this,void 0,void 0,function*(){if(!this.pcManager)throw new kd("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return jl(this,void 0,void 0,function*(){var t,n,i;if(!this._isClosed)if(this.attemptingReconnect)Ol.warn("already attempting reconnect, returning early",this.logContext);else{(null===(t=this.clientConfiguration)||void 0===t?void 0:t.resumeConnection)!==xs.DISABLED&&(null!==(i=null===(n=this.pcManager)||void 0===n?void 0:n.currentState)&&void 0!==i?i:Gp.NEW)!==Gp.NEW||(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(r){this.reconnectAttempts+=1;let e=!0;r instanceof kd?(this.log.debug("received unrecoverable error",Object.assign(Object.assign({},this.logContext),{error:r})),e=!1):r instanceof Ed||(this.fullReconnectOnNext=!0),e?this.handleDisconnect("reconnect",_s.RR_UNKNOWN):(this.log.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up"),this.logContext),this.emit(hd.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}})}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(t){this.log.warn("encountered error in reconnect policy",Object.assign(Object.assign({},this.logContext),{error:t}))}return null}restartConnection(e){return jl(this,void 0,void 0,function*(){var t,n,i;try{if(!this.url||!this.token)throw new kd("could not reconnect, url or token not saved");let n;this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts),this.logContext),this.emit(hd.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present",this.logContext),new Ed;n=yield this.join(null!=e?e:this.url,this.token,this.signalOpts,void 0,!this.options.singlePeerConnection)}catch(r){if(r instanceof gd&&r.reason===nd.NotAllowed)throw new kd("could not reconnect, token might be expired");throw new Ed}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(hd.SignalRestarted,n),yield this.waitForPCReconnected(),this.client.currentState!==fp.CONNECTED)throw new Ed("Signal connection got severed during reconnect");null===(t=this.regionUrlProvider)||void 0===t||t.resetAttempts(),this.emit(hd.Restarted)}catch(o){const e=yield null===(n=this.regionUrlProvider)||void 0===n?void 0:n.getNextBestRegionUrl();if(e)return void(yield this.restartConnection(e));throw null===(i=this.regionUrlProvider)||void 0===i||i.resetAttempts(),o}})}resumeConnection(e){return jl(this,void 0,void 0,function*(){var t;if(!this.url||!this.token)throw new kd("could not reconnect, url or token not saved");if(!this.pcManager)throw new kd("publisher and subscriber connections unset");let n;this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts),this.logContext),this.emit(hd.Resuming);try{this.setupSignalClientCallbacks(),n=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(i){let e="";if(i instanceof Error&&(e=i.message,this.log.error(i.message,Object.assign(Object.assign({},this.logContext),{error:i}))),i instanceof gd&&i.reason===nd.NotAllowed)throw new kd("could not reconnect, token might be expired");if(i instanceof gd&&i.reason===nd.LeaveRequest)throw i;throw new Ed(e)}if(this.emit(hd.SignalResumed),n){const e=this.makeRTCConfiguration(n);this.pcManager.updateConfiguration(e),this.latestJoinResponse&&(this.latestJoinResponse.serverInfo=n.serverInfo)}else this.log.warn("Did not receive reconnect response",this.logContext);if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(yield this.pcManager.triggerIceRestart(),yield this.waitForPCReconnected(),this.client.currentState!==fp.CONNECTED)throw new Ed("Signal connection got severed during reconnect");this.client.setReconnected(),"open"===(null===(t=this.reliableDC)||void 0===t?void 0:t.readyState)&&null===this.reliableDC.id&&this.createDataChannels(),(null==n?void 0:n.lastMessageSeq)&&this.resendReliableMessagesForResume(n.lastMessageSeq),this.emit(hd.Resumed)})}waitForPCInitialConnection(e,t){return jl(this,void 0,void 0,function*(){if(!this.pcManager)throw new kd("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(t,e)})}waitForPCReconnected(){return jl(this,void 0,void 0,function*(){this.pcState=xf.Reconnecting,this.log.debug("waiting for peer connection to reconnect",this.logContext);try{if(yield ih(2e3),!this.pcManager)throw new kd("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=xf.Connected}catch(e){throw this.pcState=xf.Disconnected,gd.internal("could not establish PC connection, ".concat(e.message))}})}publishRpcResponse(e,t,n,i){return jl(this,void 0,void 0,function*(){const r=new qs({destinationIdentities:[e],kind:Hs.RELIABLE,value:{case:"rpcResponse",value:new nc({requestId:t,value:i?{case:"error",value:i.toProto()}:{case:"payload",value:null!=n?n:""}})}});yield this.sendDataPacket(r,Hs.RELIABLE)})}publishRpcAck(e,t){return jl(this,void 0,void 0,function*(){const n=new qs({destinationIdentities:[e],kind:Hs.RELIABLE,value:{case:"rpcAck",value:new tc({requestId:t})}});yield this.sendDataPacket(n,Hs.RELIABLE)})}sendDataPacket(e,t){return jl(this,void 0,void 0,function*(){if(yield this.ensurePublisherConnected(t),this.e2eeManager&&this.e2eeManager.isDataChannelEncryptionEnabled){const t=function(e){var t,n,i,r,o;if("sipDtmf"!==(null===(t=e.value)||void 0===t?void 0:t.case)&&"metrics"!==(null===(n=e.value)||void 0===n?void 0:n.case)&&"speaker"!==(null===(i=e.value)||void 0===i?void 0:i.case)&&"transcription"!==(null===(r=e.value)||void 0===r?void 0:r.case)&&"encryptedPacket"!==(null===(o=e.value)||void 0===o?void 0:o.case))return new Ks({value:e.value})}(e);if(t){const n=yield this.e2eeManager.encryptData(t.toBinary());e.value={case:"encryptedPacket",value:new Ws({encryptedValue:n.payload,iv:n.iv,keyIndex:n.keyIndex})}}}t===Hs.RELIABLE&&(e.sequence=this.reliableDataSequence,this.reliableDataSequence+=1);const n=e.toBinary(),i=this.dataChannelForKind(t);if(i){if(t===Hs.RELIABLE)yield this.waitForBufferStatusLow(t),this.reliableMessageBuffer.push({data:n,sequence:e.sequence});else{if(!this.isBufferStatusLow(t))return this.lossyDataDropCount+=1,void(this.lossyDataDropCount%100==0&&this.log.warn("dropping lossy data channel messages, total dropped: ".concat(this.lossyDataDropCount),this.logContext));this.lossyDataStatCurrentBytes+=n.byteLength}if(this.attemptingReconnect)return;i.send(n)}this.updateAndEmitDCBufferStatus(t)})}resendReliableMessagesForResume(e){return jl(this,void 0,void 0,function*(){yield this.ensurePublisherConnected(Hs.RELIABLE);const t=this.dataChannelForKind(Hs.RELIABLE);t&&(this.reliableMessageBuffer.popToSequence(e),this.reliableMessageBuffer.getAll().forEach(e=>{t.send(e.data)})),this.updateAndEmitDCBufferStatus(Hs.RELIABLE)})}waitForBufferStatusLow(e){return new $u((t,n)=>jl(this,void 0,void 0,function*(){if(this.isBufferStatusLow(e))t();else{const i=()=>n(new kd("engine closed"));for(this.once(hd.Closing,i);!this.dcBufferStatus.get(e);)yield ih(10);this.off(hd.Closing,i),t()}}))}ensureDataTransportConnected(e){return jl(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscriberPrimary;return function*(){var i;if(!t.pcManager)throw new kd("PC manager is closed");const r=n?t.pcManager.subscriber:t.pcManager.publisher,o=n?"Subscriber":"Publisher";if(!r)throw gd.internal("".concat(o," connection not set"));let a=!1;n||t.dataChannelForKind(e,n)||(t.createDataChannels(),a=!0),a||n||t.pcManager.publisher.isICEConnected||"checking"===t.pcManager.publisher.getICEConnectionState()||(a=!0),a&&t.negotiate().catch(e=>{Ol.error(e,t.logContext)});const s=t.dataChannelForKind(e,n);if("open"===(null==s?void 0:s.readyState))return;const c=(new Date).getTime()+t.peerConnectionTimeout;for(;(new Date).getTime()<c;){if(r.isICEConnected&&"open"===(null===(i=t.dataChannelForKind(e,n))||void 0===i?void 0:i.readyState))return;yield ih(50)}throw gd.internal("could not establish ".concat(o," connection, state: ").concat(r.getICEConnectionState()))}()})}ensurePublisherConnected(e){return jl(this,void 0,void 0,function*(){this.publisherConnectionPromise||(this.publisherConnectionPromise=this.ensureDataTransportConnected(e,!1)),yield this.publisherConnectionPromise})}verifyTransport(){return!!this.pcManager&&(this.pcManager.currentState===Gp.CONNECTED&&!(!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED))}negotiate(){return jl(this,void 0,void 0,function*(){return new $u((e,t)=>jl(this,void 0,void 0,function*(){if(!this.pcManager)return void t(new Sd("PC manager is closed"));this.pcManager.requirePublisher(),0!=this.pcManager.publisher.getTransceivers().length||this.lossyDC||this.reliableDC||this.createDataChannels();const n=new AbortController,i=()=>{n.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),e()};this.isClosed&&t(new Sd("cannot negotiate on closed engine")),this.on(hd.Closing,i),this.pcManager.publisher.once(Ap,e=>{const t=new Map;e.forEach(e=>{const n=e.codec.toLowerCase();var i;i=n,Rd.includes(i)&&t.set(e.payload,n)}),this.emit(hd.RTPVideoMapUpdate,t)});try{yield this.pcManager.negotiate(n),e()}catch(r){r instanceof Sd&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",_s.RR_UNKNOWN),r instanceof Error?t(r):t(new Error(String(r)))}finally{this.off(hd.Closing,i)}}))})}dataChannelForKind(e,t){if(t){if(e===Hs.LOSSY)return this.lossyDCSub;if(e===Hs.RELIABLE)return this.reliableDCSub}else{if(e===Hs.LOSSY)return this.lossyDC;if(e===Hs.RELIABLE)return this.reliableDC}}sendSyncState(e,t){var n,i,r,o;if(!this.pcManager)return void this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);const a=this.pcManager.publisher.getLocalDescription(),s=this.pcManager.publisher.getRemoteDescription(),c=null===(n=this.pcManager.subscriber)||void 0===n?void 0:n.getRemoteDescription(),l=null===(i=this.pcManager.subscriber)||void 0===i?void 0:i.getLocalDescription(),u=null===(o=null===(r=this.signalOpts)||void 0===r?void 0:r.autoSubscribe)||void 0===o||o,d=new Array,h=new Array;e.forEach(e=>{e.isDesired!==u&&d.push(e.trackSid),e.isEnabled||h.push(e.trackSid)}),this.client.sendSyncState(new rl({answer:"publisher-only"===this.pcManager.mode?s?yp({sdp:s.sdp,type:s.type}):void 0:l?yp({sdp:l.sdp,type:l.type}):void 0,offer:"publisher-only"===this.pcManager.mode?a?yp({sdp:a.sdp,type:a.type}):void 0:c?yp({sdp:c.sdp,type:c.type}):void 0,subscription:new Lc({trackSids:d,subscribe:!u,participantTracks:[]}),publishTracks:Kd(t),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:h,datachannelReceiveStates:this.reliableReceivedState.map((e,t)=>new ol({publisherSid:t,lastSeq:e}))}))}failNext(){this.shouldFailNext=!0}dataChannelsInfo(){const e=[],t=(t,n)=>{void 0!==(null==t?void 0:t.id)&&null!==t.id&&e.push(new al({label:t.label,id:t.id,target:n}))};return t(this.dataChannelForKind(Hs.LOSSY),kc.PUBLISHER),t(this.dataChannelForKind(Hs.RELIABLE),kc.PUBLISHER),t(this.dataChannelForKind(Hs.LOSSY,!0),kc.SUBSCRIBER),t(this.dataChannelForKind(Hs.RELIABLE,!0),kc.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&xd.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){ph()&&(window.addEventListener("online",this.handleBrowserOnLine),window.addEventListener("offline",this.handleBrowserOffline))}deregisterOnLineListener(){ph()&&(window.removeEventListener("online",this.handleBrowserOnLine),window.removeEventListener("offline",this.handleBrowserOffline))}getTrackIdForReceiver(e){var t;const n=null===(t=this.pcManager)||void 0===t?void 0:t.getMidForReceiver(e);if(n){const e=Object.entries(this.midToTrackId).find(e=>{let[t]=e;return t===n});if(e)return e[1]}}}function Rf(e,t){const n=e.participantIdentity?e.participantIdentity:t.participantIdentity;e.participantIdentity=n,t.participantIdentity=n;const i=0!==e.destinationIdentities.length?e.destinationIdentities:t.destinationIdentities;e.destinationIdentities=i,t.destinationIdentities=i}class If{get info(){return this._info}validateBytesReceived(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if("number"==typeof this.totalByteSize&&0!==this.totalByteSize){if(e&&this.bytesReceived<this.totalByteSize)throw new wd("Not enough chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, only received ").concat(this.bytesReceived," bytes"),rd.Incomplete);if(this.bytesReceived>this.totalByteSize)throw new wd("Extra chunk(s) received - expected ".concat(this.totalByteSize," bytes of data total, received ").concat(this.bytesReceived," bytes"),rd.LengthExceeded)}}constructor(e,t,n,i){this.reader=t,this.totalByteSize=n,this._info=e,this.bytesReceived=0,this.outOfBandFailureRejectingFuture=i}}class Nf extends If{handleChunkReceived(e){var t;this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();const n=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;null===(t=this.onProgress)||void 0===t||t.call(this,n)}[Symbol.asyncIterator](){const e=this.reader.getReader();let t=new Ih,n=null,i=null;if(this.signal){const e=this.signal;i=()=>{var n;null===(n=t.reject)||void 0===n||n.call(t,e.reason)},e.addEventListener("abort",i),n=e}const r=()=>{e.releaseLock(),n&&i&&n.removeEventListener("abort",i),this.signal=void 0};return{next:()=>jl(this,void 0,void 0,function*(){var n,i;try{const{done:r,value:o}=yield Promise.race([e.read(),t.promise,null!==(i=null===(n=this.outOfBandFailureRejectingFuture)||void 0===n?void 0:n.promise)&&void 0!==i?i:new Promise(()=>{})]);return r?(this.validateBytesReceived(!0),{done:!0,value:void 0}):(this.handleChunkReceived(o),{done:!1,value:o.content})}catch(o){throw r(),o}}),return(){return jl(this,void 0,void 0,function*(){return r(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return jl(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){var n,i,r,o;let a=new Set;const s=t.signal?e.withAbortSignal(t.signal):e;try{for(var c,l=!0,u=Fl(s);!(n=(c=yield u.next()).done);l=!0){o=c.value,l=!1;const e=o;a.add(e)}}catch(d){i={error:d}}finally{try{l||n||!(r=u.return)||(yield r.call(u))}finally{if(i)throw i.error}}return Array.from(a)}()})}}class Of extends If{constructor(e,t,n,i){super(e,t,n,i),this.receivedChunks=new Map}handleChunkReceived(e){var t;const n=Dh(e.chunkIndex),i=this.receivedChunks.get(n);if(i&&i.version>e.version)return;this.receivedChunks.set(n,e),this.bytesReceived+=e.content.byteLength,this.validateBytesReceived();const r=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;null===(t=this.onProgress)||void 0===t||t.call(this,r)}[Symbol.asyncIterator](){const e=this.reader.getReader(),t=new TextDecoder("utf-8",{fatal:!0});let n=new Ih,i=null,r=null;if(this.signal){const e=this.signal;r=()=>{var t;null===(t=n.reject)||void 0===t||t.call(n,e.reason)},e.addEventListener("abort",r),i=e}const o=()=>{e.releaseLock(),i&&r&&i.removeEventListener("abort",r),this.signal=void 0};return{next:()=>jl(this,void 0,void 0,function*(){var i,r;try{const{done:o,value:s}=yield Promise.race([e.read(),n.promise,null!==(r=null===(i=this.outOfBandFailureRejectingFuture)||void 0===i?void 0:i.promise)&&void 0!==r?r:new Promise(()=>{})]);if(o)return this.validateBytesReceived(!0),{done:!0,value:void 0};{let e;this.handleChunkReceived(s);try{e=t.decode(s.content)}catch(a){throw new wd("Cannot decode datastream chunk ".concat(s.chunkIndex," as text: ").concat(a),rd.DecodeFailed)}return{done:!1,value:e}}}catch(a){throw o(),a}}),return(){return jl(this,void 0,void 0,function*(){return o(),{done:!0,value:void 0}})}}}withAbortSignal(e){return this.signal=e,this}readAll(){return jl(this,arguments,void 0,function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){var n,i,r,o;let a="";const s=t.signal?e.withAbortSignal(t.signal):e;try{for(var c,l=!0,u=Fl(s);!(n=(c=yield u.next()).done);l=!0){o=c.value,l=!1;a+=o}}catch(d){i={error:d}}finally{try{l||n||!(r=u.return)||(yield r.call(u))}finally{if(i)throw i.error}}return a}()})}}class Mf{constructor(){this.log=Ol,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map}registerTextStreamHandler(e,t){if(this.textStreamHandlers.has(e))throw new wd('A text stream handler for topic "'.concat(e,'" has already been set.'),rd.HandlerAlreadyRegistered);this.textStreamHandlers.set(e,t)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,t){if(this.byteStreamHandlers.has(e))throw new wd('A byte stream handler for topic "'.concat(e,'" has already been set.'),rd.HandlerAlreadyRegistered);this.byteStreamHandlers.set(e,t)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}clearControllers(){this.byteStreamControllers.clear(),this.textStreamControllers.clear()}validateParticipantHasNoActiveDataStreams(e){var t,n,i,r;const o=Array.from(this.textStreamControllers.entries()).filter(t=>t[1].sendingParticipantIdentity===e),a=Array.from(this.byteStreamControllers.entries()).filter(t=>t[1].sendingParticipantIdentity===e);if(o.length>0||a.length>0){const s=new wd("Participant ".concat(e," unexpectedly disconnected in the middle of sending data"),rd.AbnormalEnd);for(const[e,i]of a)null===(n=(t=i.outOfBandFailureRejectingFuture).reject)||void 0===n||n.call(t,s),this.byteStreamControllers.delete(e);for(const[e,t]of o)null===(r=(i=t.outOfBandFailureRejectingFuture).reject)||void 0===r||r.call(i,s),this.textStreamControllers.delete(e)}}handleDataStreamPacket(e,t){return jl(this,void 0,void 0,function*(){switch(e.value.case){case"streamHeader":return this.handleStreamHeader(e.value.value,e.participantIdentity,t);case"streamChunk":return this.handleStreamChunk(e.value.value,t);case"streamTrailer":return this.handleStreamTrailer(e.value.value,t);default:throw new Error('DataPacket of value "'.concat(e.value.case,'" is not data stream related!'))}})}handleStreamHeader(e,t,n){return jl(this,void 0,void 0,function*(){var i;if("byteHeader"===e.contentHeader.case){const r=this.byteStreamHandlers.get(e.topic);if(!r)return void this.log.debug("ignoring incoming byte stream due to no handler for topic",e.topic);let o;const a=new Ih;a.promise.catch(e=>{this.log.error(e)});const s={id:e.streamId,name:null!==(i=e.contentHeader.value.name)&&void 0!==i?i:"unknown",mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Dh(e.timestamp),attributes:e.attributes,encryptionType:n},c=new ReadableStream({start:n=>{if(o=n,this.textStreamControllers.has(e.streamId))throw new wd("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),rd.AlreadyOpened);this.byteStreamControllers.set(e.streamId,{info:s,controller:o,startTime:Date.now(),sendingParticipantIdentity:t,outOfBandFailureRejectingFuture:a})}});r(new Nf(s,c,Dh(e.totalLength),a),{identity:t})}else if("textHeader"===e.contentHeader.case){const i=this.textStreamHandlers.get(e.topic);if(!i)return void this.log.debug("ignoring incoming text stream due to no handler for topic",e.topic);let r;const o=new Ih;o.promise.catch(e=>{this.log.error(e)});const a={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes,encryptionType:n},s=new ReadableStream({start:n=>{if(r=n,this.textStreamControllers.has(e.streamId))throw new wd("A data stream read is already in progress for a stream with id ".concat(e.streamId,"."),rd.AlreadyOpened);this.textStreamControllers.set(e.streamId,{info:a,controller:r,startTime:Date.now(),sendingParticipantIdentity:t,outOfBandFailureRejectingFuture:o})}});i(new Of(a,s,Dh(e.totalLength),o),{identity:t})}})}handleStreamChunk(e,t){const n=this.byteStreamControllers.get(e.streamId);n&&(n.info.encryptionType!==t?(n.controller.error(new wd("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(n.info.encryptionType),rd.EncryptionTypeMismatch)),this.byteStreamControllers.delete(e.streamId)):e.content.length>0&&n.controller.enqueue(e));const i=this.textStreamControllers.get(e.streamId);i&&(i.info.encryptionType!==t?(i.controller.error(new wd("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(i.info.encryptionType),rd.EncryptionTypeMismatch)),this.textStreamControllers.delete(e.streamId)):e.content.length>0&&i.controller.enqueue(e))}handleStreamTrailer(e,t){const n=this.textStreamControllers.get(e.streamId);n&&(n.info.encryptionType!==t?n.controller.error(new wd("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(n.info.encryptionType),rd.EncryptionTypeMismatch)):(n.info.attributes=Object.assign(Object.assign({},n.info.attributes),e.attributes),n.controller.close(),this.textStreamControllers.delete(e.streamId)));const i=this.byteStreamControllers.get(e.streamId);i&&(i.info.encryptionType!==t?i.controller.error(new wd("Encryption type mismatch for stream ".concat(e.streamId,". Expected ").concat(t,", got ").concat(i.info.encryptionType),rd.EncryptionTypeMismatch)):(i.info.attributes=Object.assign(Object.assign({},i.info.attributes),e.attributes),i.controller.close()),this.byteStreamControllers.delete(e.streamId))}}class Df{constructor(e,t,n){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=n,this.info=t}write(e){return this.defaultWriter.write(e)}close(){return jl(this,void 0,void 0,function*(){var e;yield this.defaultWriter.close(),this.defaultWriter.releaseLock(),null===(e=this.onClose)||void 0===e||e.call(this)})}}class Lf extends Df{}class Af extends Df{}class jf{constructor(e,t){this.engine=e,this.log=t}setupEngine(e){this.engine=e}sendText(e,t){return jl(this,void 0,void 0,function*(){var n;const i=crypto.randomUUID(),r=(new TextEncoder).encode(e).byteLength,o=null===(n=null==t?void 0:t.attachments)||void 0===n?void 0:n.map(()=>crypto.randomUUID()),a=new Array(o?o.length+1:1).fill(0),s=(e,n)=>{var i;a[n]=e;const r=a.reduce((e,t)=>e+t,0);null===(i=null==t?void 0:t.onProgress)||void 0===i||i.call(t,r)},c=yield this.streamText({streamId:i,totalSize:r,destinationIdentities:null==t?void 0:t.destinationIdentities,topic:null==t?void 0:t.topic,attachedStreamIds:o,attributes:null==t?void 0:t.attributes});return yield c.write(e),s(1,0),yield c.close(),(null==t?void 0:t.attachments)&&o&&(yield Promise.all(t.attachments.map((e,n)=>jl(this,void 0,void 0,function*(){return this._sendFile(o[n],e,{topic:t.topic,mimeType:e.type,onProgress:e=>{s(e,n+1)}})})))),c.info})}streamText(e){return jl(this,void 0,void 0,function*(){var t,n,i;const r=null!==(t=null==e?void 0:e.streamId)&&void 0!==t?t:crypto.randomUUID(),o={id:r,mimeType:"text/plain",timestamp:Date.now(),topic:null!==(n=null==e?void 0:e.topic)&&void 0!==n?n:"",size:null==e?void 0:e.totalSize,attributes:null==e?void 0:e.attributes,encryptionType:(null===(i=this.engine.e2eeManager)||void 0===i?void 0:i.isDataChannelEncryptionEnabled)?Us.GCM:Us.NONE},a=new gc({streamId:r,mimeType:o.mimeType,topic:o.topic,timestamp:Lh(o.timestamp),totalLength:Lh(null==e?void 0:e.totalSize),attributes:o.attributes,contentHeader:{case:"textHeader",value:new fc({version:null==e?void 0:e.version,attachedStreamIds:null==e?void 0:e.attachedStreamIds,replyToStreamId:null==e?void 0:e.replyToStreamId,operationType:"update"===(null==e?void 0:e.type)?pc.UPDATE:pc.CREATE})}}),s=null==e?void 0:e.destinationIdentities,c=new qs({destinationIdentities:s,value:{case:"streamHeader",value:a}});yield this.engine.sendDataPacket(c,Hs.RELIABLE);let l=0;const u=this.engine,d=new WritableStream({write(e){return jl(this,void 0,void 0,function*(){for(const t of function(e,t){const n=[];let i=(new TextEncoder).encode(e);for(;i.length>t;){let e=t;for(;e>0;){const t=i[e];if(void 0!==t&&128!=(192&t))break;e--}n.push(i.slice(0,e)),i=i.slice(e)}return i.length>0&&n.push(i),n}(e,15e3)){const e=new vc({content:t,streamId:r,chunkIndex:Lh(l)}),n=new qs({destinationIdentities:s,value:{case:"streamChunk",value:e}});yield u.sendDataPacket(n,Hs.RELIABLE),l+=1}})},close(){return jl(this,void 0,void 0,function*(){const e=new yc({streamId:r}),t=new qs({destinationIdentities:s,value:{case:"streamTrailer",value:e}});yield u.sendDataPacket(t,Hs.RELIABLE)})},abort(e){console.log("Sink error:",e)}});let h=()=>jl(this,void 0,void 0,function*(){yield p.close()});u.once(hd.Closing,h);const p=new Lf(d,o,()=>this.engine.off(hd.Closing,h));return p})}sendFile(e,t){return jl(this,void 0,void 0,function*(){const n=crypto.randomUUID();return yield this._sendFile(n,e,t),{id:n}})}_sendFile(e,t,n){return jl(this,void 0,void 0,function*(){var i;const r=yield this.streamBytes({streamId:e,totalSize:t.size,name:t.name,mimeType:null!==(i=null==n?void 0:n.mimeType)&&void 0!==i?i:t.type,topic:null==n?void 0:n.topic,destinationIdentities:null==n?void 0:n.destinationIdentities}),o=t.stream().getReader();for(;;){const{done:e,value:t}=yield o.read();if(e)break;yield r.write(t)}return yield r.close(),r.info})}streamBytes(e){return jl(this,void 0,void 0,function*(){var t,n,i,r,o,a;const s=null!==(t=null==e?void 0:e.streamId)&&void 0!==t?t:crypto.randomUUID(),c=null==e?void 0:e.destinationIdentities,l={id:s,mimeType:null!==(n=null==e?void 0:e.mimeType)&&void 0!==n?n:"application/octet-stream",topic:null!==(i=null==e?void 0:e.topic)&&void 0!==i?i:"",timestamp:Date.now(),attributes:null==e?void 0:e.attributes,size:null==e?void 0:e.totalSize,name:null!==(r=null==e?void 0:e.name)&&void 0!==r?r:"unknown",encryptionType:(null===(o=this.engine.e2eeManager)||void 0===o?void 0:o.isDataChannelEncryptionEnabled)?Us.GCM:Us.NONE},u=new gc({totalLength:Lh(null!==(a=l.size)&&void 0!==a?a:0),mimeType:l.mimeType,streamId:s,topic:l.topic,timestamp:Lh(Date.now()),attributes:l.attributes,contentHeader:{case:"byteHeader",value:new mc({name:l.name})}}),d=new qs({destinationIdentities:c,value:{case:"streamHeader",value:u}});yield this.engine.sendDataPacket(d,Hs.RELIABLE);let h=0;const p=new Do,f=this.engine,m=this.log,g=new WritableStream({write(e){return jl(this,void 0,void 0,function*(){const t=yield p.lock();let n=0;try{for(;n<e.byteLength;){const t=e.slice(n,n+15e3),i=new qs({destinationIdentities:c,value:{case:"streamChunk",value:new vc({content:t,streamId:s,chunkIndex:Lh(h)})}});yield f.sendDataPacket(i,Hs.RELIABLE),h+=1,n+=t.byteLength}}finally{t()}})},close(){return jl(this,void 0,void 0,function*(){const e=new yc({streamId:s}),t=new qs({destinationIdentities:c,value:{case:"streamTrailer",value:e}});yield f.sendDataPacket(t,Hs.RELIABLE)})},abort(e){m.error("Sink error:",e)}});return new Af(g,l)})}}class Uf extends Zd{constructor(e,t,n,i,r){super(e,n,r),this.sid=t,this.receiver=i}get isLocal(){return!1}setMuted(e){this.isMuted!==e&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?fd.Muted:fd.Unmuted,this))}setMediaStream(e){this.mediaStream=e;const t=n=>{n.track===this._mediaStreamTrack&&(e.removeEventListener("removetrack",t),this.receiver&&"playoutDelayHint"in this.receiver&&(this.receiver.playoutDelayHint=void 0),this.receiver=void 0,this._currentBitrate=0,this.emit(fd.Ended,this))};e.addEventListener("removetrack",t)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){return jl(this,void 0,void 0,function*(){var e;if(!(null===(e=this.receiver)||void 0===e?void 0:e.getStats))return;return yield this.receiver.getStats()})}setPlayoutDelay(e){this.receiver?"playoutDelayHint"in this.receiver?this.receiver.playoutDelayHint=e:this.log.warn("Playout delay not supported in this browser"):this.log.warn("Cannot set playout delay, track already ended")}getPlayoutDelay(){if(this.receiver){if("playoutDelayHint"in this.receiver)return this.receiver.playoutDelayHint;this.log.warn("Playout delay not supported in this browser")}else this.log.warn("Cannot get playout delay, track already ended");return 0}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval(()=>this.monitorReceiver(),ef)),"undefined"!=typeof RTCRtpReceiver&&"getSynchronizationSources"in RTCRtpReceiver&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){const e=()=>{var t;this.timeSyncHandle=requestAnimationFrame(()=>e());const n=null===(t=this.receiver)||void 0===t?void 0:t.getSynchronizationSources()[0];if(n){const{timestamp:e,rtpTimestamp:t}=n;t&&this.rtpTimestamp!==t&&(this.emit(fd.TimeSyncUpdate,{timestamp:e,rtpTimestamp:t}),this.rtpTimestamp=t)}};e()}}class Ff extends Uf{constructor(e,t,n,i,r,o){super(e,t,Zd.Kind.Audio,n,o),this.monitorReceiver=()=>jl(this,void 0,void 0,function*(){if(!this.receiver)return void(this._currentBitrate=0);const e=yield this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=tf(e,this.prevStats)),this.prevStats=e}),this.audioContext=i,this.webAudioPluginNodes=[],r&&(this.sinkId=r.deviceId)}setVolume(e){var t;for(const n of this.attachedElements)this.audioContext?null===(t=this.gainNode)||void 0===t||t.gain.setTargetAtTime(e,0,.1):n.volume=e;fh()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(fh())return 1;let e=0;return this.attachedElements.forEach(t=>{t.volume>e&&(e=t.volume)}),e}setSinkId(e){return jl(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(t=>{if(sh(t))return t.setSinkId(e)}))})}attach(e){const t=0===this.attachedElements.length;return e?super.attach(e):e=super.attach(),this.sinkId&&sh(e)&&e.setSinkId(this.sinkId).catch(e=>{this.log.error("Failed to set sink id on remote audio track",e,this.logContext)}),this.audioContext&&t&&(this.log.debug("using audio context mapping",this.logContext),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),this.elementVolume&&this.setVolume(this.elementVolume),e}detach(e){let t;return e?(t=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(t=super.detach(),this.disconnectWebAudio()),t}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(e,t){this.disconnectWebAudio(),this.sourceNode=e.createMediaStreamSource(t.srcObject);let n=this.sourceNode;this.webAudioPluginNodes.forEach(e=>{n.connect(e),n=e}),this.gainNode=e.createGain(),n.connect(this.gainNode),this.gainNode.connect(e.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),"running"!==e.state&&e.resume().then(()=>{"running"!==e.state&&this.emit(fd.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))}).catch(e=>{this.emit(fd.AudioPlaybackFailed,e)})}disconnectWebAudio(){var e,t;null===(e=this.gainNode)||void 0===e||e.disconnect(),null===(t=this.sourceNode)||void 0===t||t.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return jl(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;let e;return(yield this.receiver.getStats()).forEach(t=>{"inbound-rtp"===t.type&&(e={type:"audio",streamId:t.id,timestamp:t.timestamp,jitter:t.jitter,bytesReceived:t.bytesReceived,concealedSamples:t.concealedSamples,concealmentEvents:t.concealmentEvents,silentConcealedSamples:t.silentConcealedSamples,silentConcealmentEvents:t.silentConcealmentEvents,totalAudioEnergy:t.totalAudioEnergy,totalSamplesDuration:t.totalSamplesDuration})}),e})}}class Bf extends Uf{constructor(e,t,n,i,r){super(e,t,Zd.Kind.Video,n,r),this.elementInfos=[],this.monitorReceiver=()=>jl(this,void 0,void 0,function*(){if(!this.receiver)return void(this._currentBitrate=0);const e=yield this.getReceiverStats();e&&this.prevStats&&this.receiver&&(this._currentBitrate=tf(e,this.prevStats)),this.prevStats=e}),this.debouncedHandleResize=Mp(()=>{this.updateDimensions()},100),this.adaptiveStreamSettings=i}get isAdaptiveStream(){return void 0!==this.adaptiveStreamSettings}setStreamState(e){super.setStreamState(e),this.log.debug("setStreamState",e),this.isAdaptiveStream&&e===Zd.StreamState.Active&&this.updateVisibility()}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(t=>{e?th(this._mediaStreamTrack,t):eh(this._mediaStreamTrack,t)})}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&void 0===this.elementInfos.find(t=>t.element===e)){const t=new zf(e);this.observeElementInfo(t)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&void 0===this.elementInfos.find(t=>t===e)?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):this.log.warn("visibility resize observer not triggered",this.logContext)}stopObservingElementInfo(e){if(!this.isAdaptiveStream)return void this.log.warn("stopObservingElementInfo ignored",this.logContext);const t=this.elementInfos.filter(t=>t===e);for(const n of t)n.stopObserving();this.elementInfos=this.elementInfos.filter(t=>t!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){let t=[];if(e)return this.stopObservingElement(e),super.detach(e);t=super.detach();for(const n of t)this.stopObservingElement(n);return t}getDecoderImplementation(){var e;return null===(e=this.prevStats)||void 0===e?void 0:e.decoderImplementation}getReceiverStats(){return jl(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let t,n="",i=new Map;return e.forEach(e=>{"inbound-rtp"===e.type?(n=e.codecId,t={type:"video",streamId:e.id,framesDecoded:e.framesDecoded,framesDropped:e.framesDropped,framesReceived:e.framesReceived,packetsReceived:e.packetsReceived,packetsLost:e.packetsLost,frameWidth:e.frameWidth,frameHeight:e.frameHeight,pliCount:e.pliCount,firCount:e.firCount,nackCount:e.nackCount,jitter:e.jitter,timestamp:e.timestamp,bytesReceived:e.bytesReceived,decoderImplementation:e.decoderImplementation}):"codec"===e.type&&i.set(e.id,e)}),t&&""!==n&&i.get(n)&&(t.mimeType=i.get(n).mimeType),t})}stopObservingElement(e){const t=this.elementInfos.filter(t=>t.element===e);for(const n of t)this.stopObservingElementInfo(n)}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return jl(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()})}updateVisibility(e){var t,n;const i=this.elementInfos.reduce((e,t)=>Math.max(e,t.visibilityChangedAt||0),0),r=!(null!==(n=null===(t=this.adaptiveStreamSettings)||void 0===t?void 0:t.pauseVideoInBackground)&&void 0!==n&&!n)&&this.isInBackground,o=this.elementInfos.some(e=>e.pictureInPicture),a=this.elementInfos.some(e=>e.visible)&&!r||o;(this.lastVisible!==a||e)&&(!a&&Date.now()-i<100?xd.setTimeout(()=>{this.updateVisibility()},100):(this.lastVisible=a,this.emit(fd.VisibilityChanged,a,this)))}updateDimensions(){var e,t;let n=0,i=0;const r=this.getPixelDensity();for(const o of this.elementInfos){const e=o.width()*r,t=o.height()*r;e+t>n+i&&(n=e,i=t)}(null===(e=this.lastDimensions)||void 0===e?void 0:e.width)===n&&(null===(t=this.lastDimensions)||void 0===t?void 0:t.height)===i||(this.lastDimensions={width:n,height:i},this.emit(fd.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const t=null===(e=this.adaptiveStreamSettings)||void 0===e?void 0:e.pixelDensity;if("screen"===t)return bh();if(!t){return bh()>2?2:1}return t}}class zf{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,t){this.onVisibilityChanged=e=>{var t;const{target:n,isIntersecting:i}=e;n===this.element&&(this.isIntersecting=i,this.isPiP=Vf(this.element),this.visibilityChangedAt=Date.now(),null===(t=this.handleVisibilityChanged)||void 0===t||t.call(this))},this.onEnterPiP=()=>{var e,t,n;null===(t=null===(e=window.documentPictureInPicture)||void 0===e?void 0:e.window)||void 0===t||t.addEventListener("pagehide",this.onLeavePiP),this.isPiP=Vf(this.element),null===(n=this.handleVisibilityChanged)||void 0===n||n.call(this)},this.onLeavePiP=()=>{var e;this.isPiP=Vf(this.element),null===(e=this.handleVisibilityChanged)||void 0===e||e.call(this)},this.element=e,this.isIntersecting=null!=t?t:qf(e),this.isPiP=ph()&&Vf(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,t,n;this.isIntersecting=qf(this.element),this.isPiP=Vf(this.element),this.element.handleResize=()=>{var e;null===(e=this.handleResize)||void 0===e||e.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,xh().observe(this.element),wh().observe(this.element),this.element.addEventListener("enterpictureinpicture",this.onEnterPiP),this.element.addEventListener("leavepictureinpicture",this.onLeavePiP),null===(e=window.documentPictureInPicture)||void 0===e||e.addEventListener("enter",this.onEnterPiP),null===(n=null===(t=window.documentPictureInPicture)||void 0===t?void 0:t.window)||void 0===n||n.addEventListener("pagehide",this.onLeavePiP)}stopObserving(){var e,t,n,i,r;null===(e=xh())||void 0===e||e.unobserve(this.element),null===(t=wh())||void 0===t||t.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP),null===(n=window.documentPictureInPicture)||void 0===n||n.removeEventListener("enter",this.onEnterPiP),null===(r=null===(i=window.documentPictureInPicture)||void 0===i?void 0:i.window)||void 0===r||r.removeEventListener("pagehide",this.onLeavePiP)}}function Vf(e){var t,n;return document.pictureInPictureElement===e||!!(null===(t=window.documentPictureInPicture)||void 0===t?void 0:t.window)&&qf(e,null===(n=window.documentPictureInPicture)||void 0===n?void 0:n.window)}function qf(e,t){const n=t||window;let i=e.offsetTop,r=e.offsetLeft;const o=e.offsetWidth,a=e.offsetHeight,{hidden:s}=e,{display:c}=getComputedStyle(e);for(;e.offsetParent;)i+=(e=e.offsetParent).offsetTop,r+=e.offsetLeft;return i<n.pageYOffset+n.innerHeight&&r<n.pageXOffset+n.innerWidth&&i+a>n.pageYOffset&&r+o>n.pageXOffset&&!s&&"none"!==c}class Hf extends Vl.EventEmitter{constructor(e,t,n,i){var r;super(),this.metadataMuted=!1,this.encryption=Us.NONE,this.log=Ol,this.handleMuted=()=>{this.emit(fd.Muted)},this.handleUnmuted=()=>{this.emit(fd.Unmuted)},this.log=Ml(null!==(r=null==i?void 0:i.loggerName)&&void 0!==r?r:Rl.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=t,this.trackName=n,this.source=Zd.Source.Unknown}setTrack(e){this.track&&(this.track.off(fd.Muted,this.handleMuted),this.track.off(fd.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on(fd.Muted,this.handleMuted),e.on(fd.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},null===(e=this.loggerContextCb)||void 0===e?void 0:e.call(this)),Gd(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return void 0!==this.track}get isEncrypted(){return this.encryption!==Us.NONE}get audioTrack(){if(jh(this.track))return this.track}get videoTrack(){if(Uh(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=Zd.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===Zd.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.encryption=e.encryption,this.trackInfo=e,this.log.debug("update publication info",Object.assign(Object.assign({},this.logContext),{info:e}))}}var Wf,Kf,Gf,$f,Jf,Qf,Yf;Wf=Hf||(Hf={}),(Kf=Wf.SubscriptionStatus||(Wf.SubscriptionStatus={})).Desired="desired",Kf.Subscribed="subscribed",Kf.Unsubscribed="unsubscribed",(Gf=Wf.PermissionStatus||(Wf.PermissionStatus={})).Allowed="allowed",Gf.NotAllowed="not_allowed";class Xf extends Hf{get isUpstreamPaused(){var e;return null===(e=this.track)||void 0===e?void 0:e.isUpstreamPaused}constructor(e,t,n,i){super(e,t.sid,t.name,i),this.track=void 0,this.handleTrackEnded=()=>{this.emit(fd.Ended)},this.handleCpuConstrained=()=>{this.track&&Uh(this.track)&&this.emit(fd.CpuConstrained,this.track)},this.updateInfo(t),this.setTrack(n)}setTrack(e){this.track&&(this.track.off(fd.Ended,this.handleTrackEnded),this.track.off(fd.CpuConstrained,this.handleCpuConstrained)),super.setTrack(e),e&&(e.on(fd.Ended,this.handleTrackEnded),e.on(fd.CpuConstrained,this.handleCpuConstrained))}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}get isLocal(){return!0}mute(){return jl(this,void 0,void 0,function*(){var e;return null===(e=this.track)||void 0===e?void 0:e.mute()})}unmute(){return jl(this,void 0,void 0,function*(){var e;return null===(e=this.track)||void 0===e?void 0:e.unmute()})}pauseUpstream(){return jl(this,void 0,void 0,function*(){var e;yield null===(e=this.track)||void 0===e?void 0:e.pauseUpstream()})}resumeUpstream(){return jl(this,void 0,void 0,function*(){var e;yield null===(e=this.track)||void 0===e?void 0:e.resumeUpstream()})}getTrackFeatures(){var e;if(jh(this.track)){const t=this.track.getSourceTrackSettings(),n=new Set;return t.autoGainControl&&n.add(Is.TF_AUTO_GAIN_CONTROL),t.echoCancellation&&n.add(Is.TF_ECHO_CANCELLATION),t.noiseSuppression&&n.add(Is.TF_NOISE_SUPPRESSION),t.channelCount&&t.channelCount>1&&n.add(Is.TF_STEREO),(null===(e=this.options)||void 0===e?void 0:e.dtx)||n.add(Is.TF_NO_DTX),this.track.enhancedNoiseCancellation&&n.add(Is.TF_ENHANCED_NOISE_CANCELLATION),Array.from(n.values())}return[]}}function Zf(e,t){return jl(this,void 0,void 0,function*(){null!=e||(e={});let n=!1;const{audioProcessor:i,videoProcessor:r,optionsWithoutProcessor:o}=$d(e);let a=o.audio,s=o.video;if(i&&"object"==typeof o.audio&&(o.audio.processor=i),r&&"object"==typeof o.video&&(o.video.processor=r),e.audio&&"object"==typeof o.audio&&"string"==typeof o.audio.deviceId){const e=o.audio.deviceId;o.audio.deviceId={exact:e},n=!0,a=Object.assign(Object.assign({},o.audio),{deviceId:{ideal:e}})}if(o.video&&"object"==typeof o.video&&"string"==typeof o.video.deviceId){const e=o.video.deviceId;o.video.deviceId={exact:e},n=!0,s=Object.assign(Object.assign({},o.video),{deviceId:{ideal:e}})}!0===o.audio?o.audio={deviceId:"default"}:"object"==typeof o.audio&&null!==o.audio&&(o.audio=Object.assign(Object.assign({},o.audio),{deviceId:o.audio.deviceId||"default"})),!0===o.video?o.video={deviceId:"default"}:"object"!=typeof o.video||o.video.deviceId||(o.video.deviceId="default");const c=Ud(o,qp,Hp),l=Bd(c),u=navigator.mediaDevices.getUserMedia(l);o.audio&&(cp.userMediaPromiseMap.set("audioinput",u),u.catch(()=>cp.userMediaPromiseMap.delete("audioinput"))),o.video&&(cp.userMediaPromiseMap.set("videoinput",u),u.catch(()=>cp.userMediaPromiseMap.delete("videoinput")));try{const e=yield u;return yield Promise.all(e.getTracks().map(n=>jl(this,void 0,void 0,function*(){const o="audio"===n.kind;let a,s=o?c.audio:c.video;"boolean"!=typeof s&&s||(s={});const u=o?l.audio:l.video;"boolean"!=typeof u&&(a=u);const d=n.getSettings().deviceId;(null==a?void 0:a.deviceId)&&Nh(a.deviceId)!==d?a.deviceId=d:a||(a={deviceId:d});const h=function(e,t,n){switch(e.kind){case"audio":return new sf(e,t,!1,void 0,n);case"video":return new bf(e,t,!1,n);default:throw new yd("unsupported track type: ".concat(e.kind))}}(n,a,t);return h.kind===Zd.Kind.Video?h.source=Zd.Source.Camera:h.kind===Zd.Kind.Audio&&(h.source=Zd.Source.Microphone),h.mediaStream=e,jh(h)&&i?yield h.setProcessor(i):Uh(h)&&r&&(yield h.setProcessor(r)),h})))}catch(d){if(!n)throw d;return Zf(Object.assign(Object.assign({},e),{audio:a,video:s}),t)}})}(Jf=$f||($f={})).Excellent="excellent",Jf.Good="good",Jf.Poor="poor",Jf.Lost="lost",Jf.Unknown="unknown";class em extends Vl.EventEmitter{get logContext(){var e,t;return Object.assign({},null===(t=null===(e=this.loggerOptions)||void 0===e?void 0:e.loggerContextCb)||void 0===t?void 0:t.call(e))}get isEncrypted(){return this.trackPublications.size>0&&Array.from(this.trackPublications.values()).every(e=>e.isEncrypted)}get isAgent(){var e;return(null===(e=this.permissions)||void 0===e?void 0:e.agent)||this.kind===As.AGENT}get isActive(){var e;return(null===(e=this.participantInfo)||void 0===e?void 0:e.state)===Ls.ACTIVE}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,t,n,i,r,o){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:As.STANDARD;var s;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=$f.Unknown,this.log=Ol,this.log=Ml(null!==(s=null==o?void 0:o.loggerName)&&void 0!==s?s:Rl.Participant),this.loggerOptions=o,this.setMaxListeners(100),this.sid=e,this.identity=t,this.name=n,this.metadata=i,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=a,this._attributes=null!=r?r:{}}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(e){for(const[,t]of this.trackPublications)if(t.source===e)return t}getTrackPublicationByName(e){for(const[,t]of this.trackPublications)if(t.trackName===e)return t}waitUntilActive(){return this.isActive?Promise.resolve():(this.activeFuture||(this.activeFuture=new Ih,this.once(ud.Active,()=>{var e,t;null===(t=null===(e=this.activeFuture)||void 0===e?void 0:e.resolve)||void 0===t||t.call(e),this.activeFuture=void 0})),this.activeFuture.promise)}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const t=this.getTrackPublication(Zd.Source.Camera);return!(null===(e=null==t?void 0:t.isMuted)||void 0===e||e)}get isMicrophoneEnabled(){var e;const t=this.getTrackPublication(Zd.Source.Microphone);return!(null===(e=null==t?void 0:t.isMuted)||void 0===e||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(Zd.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(1e3*Number.parseInt(this.participantInfo.joinedAt.toString())):new Date}updateInfo(e){var t;return!(this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version)&&(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),this._setAttributes(e.attributes),e.state===Ls.ACTIVE&&(null===(t=this.participantInfo)||void 0===t?void 0:t.state)!==Ls.ACTIVE&&this.emit(ud.Active),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,!0)}_setMetadata(e){const t=this.metadata!==e,n=this.metadata;this.metadata=e,t&&this.emit(ud.ParticipantMetadataChanged,n)}_setName(e){const t=this.name!==e;this.name=e,t&&this.emit(ud.ParticipantNameChanged,e)}_setAttributes(e){const t=function(e,t){var n;void 0===e&&(e={}),void 0===t&&(t={});const i=[...Object.keys(t),...Object.keys(e)],r={};for(const o of i)e[o]!==t[o]&&(r[o]=null!==(n=t[o])&&void 0!==n?n:"");return r}(this.attributes,e);this._attributes=e,Object.keys(t).length>0&&this.emit(ud.AttributesChanged,t)}setPermissions(e){var t,n,i,r,o,a;const s=this.permissions,c=e.canPublish!==(null===(t=this.permissions)||void 0===t?void 0:t.canPublish)||e.canSubscribe!==(null===(n=this.permissions)||void 0===n?void 0:n.canSubscribe)||e.canPublishData!==(null===(i=this.permissions)||void 0===i?void 0:i.canPublishData)||e.hidden!==(null===(r=this.permissions)||void 0===r?void 0:r.hidden)||e.recorder!==(null===(o=this.permissions)||void 0===o?void 0:o.recorder)||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((e,t)=>{var n;return e!==(null===(n=this.permissions)||void 0===n?void 0:n.canPublishSources[t])})||e.canSubscribeMetrics!==(null===(a=this.permissions)||void 0===a?void 0:a.canSubscribeMetrics);return this.permissions=e,c&&this.emit(ud.ParticipantPermissionsChanged,s),c}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(ud.IsSpeakingChanged,e))}setConnectionQuality(e){const t=this._connectionQuality;this._connectionQuality=function(e){switch(e){case Es.EXCELLENT:return $f.Excellent;case Es.GOOD:return $f.Good;case Es.POOR:return $f.Poor;case Es.LOST:return $f.Lost;default:return $f.Unknown}}(e),t!==this._connectionQuality&&this.emit(ud.ConnectionQualityChanged,this._connectionQuality)}setDisconnected(){var e,t;this.activeFuture&&(null===(t=(e=this.activeFuture).reject)||void 0===t||t.call(e,new Error("Participant disconnected")),this.activeFuture=void 0)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach(t=>jh(t.track)&&t.track.setAudioContext(e))}addTrackPublication(e){e.on(fd.Muted,()=>{this.emit(ud.TrackMuted,e)}),e.on(fd.Unmuted,()=>{this.emit(ud.TrackUnmuted,e)});const t=e;switch(t.track&&(t.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case Zd.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case Zd.Kind.Video:this.videoTrackPublications.set(e.trackSid,e)}}}class tm extends em{constructor(e,t,n,i,r,o){super(e,t,void 0,void 0,void 0,{loggerName:i.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=Us.NONE,this.enabledPublishVideoCodecs=[],this.pendingAcks=new Map,this.pendingResponses=new Map,this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new Ih)},this.handleReconnected=()=>{var e,t;null===(t=null===(e=this.reconnectFuture)||void 0===e?void 0:e.resolve)||void 0===t||t.call(e),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleClosing=()=>{var e,t,n,i,r,o;this.reconnectFuture&&(this.reconnectFuture.promise.catch(e=>this.log.warn(e.message,this.logContext)),null===(t=null===(e=this.reconnectFuture)||void 0===e?void 0:e.reject)||void 0===t||t.call(e,new Error("Got disconnected during reconnection attempt")),this.reconnectFuture=void 0),this.signalConnectedFuture&&(null===(i=(n=this.signalConnectedFuture).reject)||void 0===i||i.call(n,new Error("Got disconnected without signal connected")),this.signalConnectedFuture=void 0),null===(o=null===(r=this.activeAgentFuture)||void 0===r?void 0:r.reject)||void 0===o||o.call(r,new Error("Got disconnected without active agent present")),this.activeAgentFuture=void 0,this.firstActiveAgent=void 0},this.handleSignalConnected=e=>{var t,n;e.participant&&this.updateInfo(e.participant),this.signalConnectedFuture||(this.signalConnectedFuture=new Ih),null===(n=(t=this.signalConnectedFuture).resolve)||void 0===n||n.call(t)},this.handleSignalRequestResponse=e=>{const{requestId:t,reason:n,message:i}=e,r=this.pendingSignalRequests.get(t);r&&(n!==fl.OK&&r.reject(new Td(i,n)),this.pendingSignalRequests.delete(t))},this.handleDataPacket=e=>{switch(e.value.case){case"rpcResponse":let t=e.value.value,n=null,i=null;"payload"===t.value.case?n=t.value.value:"error"===t.value.case&&(i=Yp.fromProto(t.value.value)),this.handleIncomingRpcResponse(t.requestId,n,i);break;case"rpcAck":let r=e.value.value;this.handleIncomingRpcAck(r.requestId)}},this.updateTrackSubscriptionPermissions=()=>{this.log.debug("updating track subscription permissions",Object.assign(Object.assign({},this.logContext),{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions})),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map(e=>function(e){var t,n,i;if(!e.participantSid&&!e.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new el({participantIdentity:null!==(t=e.participantIdentity)&&void 0!==t?t:"",participantSid:null!==(n=e.participantSid)&&void 0!==n?n:"",allTracks:null!==(i=e.allowAll)&&void 0!==i&&i,trackSids:e.allowedTrackSids||[]})}(e)))},this.onTrackUnmuted=e=>{this.onTrackMuted(e,e.isUpstreamPaused)},this.onTrackMuted=(e,t)=>{void 0===t&&(t=!0),e.sid?this.engine.updateMuteStatus(e.sid,t):this.log.error("could not update mute status for unpublished track",Object.assign(Object.assign({},this.logContext),Gd(e)))},this.onTrackUpstreamPaused=e=>{this.log.debug("upstream paused",Object.assign(Object.assign({},this.logContext),Gd(e))),this.onTrackMuted(e,!0)},this.onTrackUpstreamResumed=e=>{this.log.debug("upstream resumed",Object.assign(Object.assign({},this.logContext),Gd(e))),this.onTrackMuted(e,e.isMuted)},this.onTrackFeatureUpdate=e=>{const t=this.audioTrackPublications.get(e.sid);t?this.engine.client.sendUpdateLocalAudioTrack(t.trackSid,t.getTrackFeatures()):this.log.warn("Could not update local audio track settings, missing publication for track ".concat(e.sid),this.logContext)},this.onTrackCpuConstrained=(e,t)=>{this.log.debug("track cpu constrained",Object.assign(Object.assign({},this.logContext),Gd(t))),this.emit(ud.LocalTrackCpuConstrained,e,t)},this.handleSubscribedQualityUpdate=e=>jl(this,void 0,void 0,function*(){var t,n,i,r,o;if(!(null===(o=this.roomOptions)||void 0===o?void 0:o.dynacast))return;const a=this.videoTrackPublications.get(e.trackSid);if(!a)return void this.log.warn("received subscribed quality update for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:e.trackSid}));if(!a.videoTrack)return;const s=yield a.videoTrack.setPublishingCodecs(e.subscribedCodecs);try{for(var c,l=!0,u=Fl(s);!(t=(c=yield u.next()).done);l=!0){r=c.value,l=!1;const e=r;Id(e)&&(this.log.debug("publish ".concat(e," for ").concat(a.videoTrack.sid),Object.assign(Object.assign({},this.logContext),Gd(a))),yield this.publishAdditionalCodecForTrack(a.videoTrack,e,a.options))}}catch(d){n={error:d}}finally{try{l||t||!(i=u.return)||(yield i.call(u))}finally{if(n)throw n.error}}}),this.handleLocalTrackUnpublished=e=>{const t=this.trackPublications.get(e.trackSid);t?this.unpublishTrack(t.track):this.log.warn("received unpublished event for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:e.trackSid}))},this.handleTrackEnded=e=>jl(this,void 0,void 0,function*(){if(e.source===Zd.Source.ScreenShare||e.source===Zd.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",Object.assign(Object.assign({},this.logContext),Gd(e))),this.unpublishTrack(e);else if(e.isUserProvided)yield e.mute();else if(Bh(e)||Fh(e))try{if(ph())try{const t=yield null===navigator||void 0===navigator?void 0:navigator.permissions.query({name:e.source===Zd.Source.Camera?"camera":"microphone"});if(t&&"denied"===t.state)throw this.log.warn("user has revoked access to ".concat(e.source),Object.assign(Object.assign({},this.logContext),Gd(e))),t.onchange=()=>{"denied"!==t.state&&(e.isMuted||e.restartTrack(),t.onchange=null)},new Error("GetUserMedia Permission denied")}catch(t){}e.isMuted||(this.log.debug("track ended, attempting to use a different device",Object.assign(Object.assign({},this.logContext),Gd(e))),Bh(e)?yield e.restartTrack({deviceId:"default"}):yield e.restartTrack())}catch(t){this.log.warn("could not restart track, muting instead",Object.assign(Object.assign({},this.logContext),Gd(e))),yield e.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=n,this.roomOptions=i,this.setupEngine(n),this.activeDeviceMap=new Map([["audioinput","default"],["videoinput","default"],["audiooutput","default"]]),this.pendingSignalRequests=new Map,this.rpcHandlers=r,this.roomOutgoingDataStreamManager=o}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==Us.NONE}getTrackPublication(e){const t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){const t=super.getTrackPublicationByName(e);if(t)return t}setupEngine(e){var t;this.engine=e,this.engine.on(hd.RemoteMute,(e,t)=>{const n=this.trackPublications.get(e);n&&n.track&&(t?n.mute():n.unmute())}),(null===(t=this.signalConnectedFuture)||void 0===t?void 0:t.isResolved)&&(this.signalConnectedFuture=void 0),this.engine.on(hd.Connected,this.handleReconnected).on(hd.SignalConnected,this.handleSignalConnected).on(hd.SignalRestarted,this.handleReconnected).on(hd.SignalResumed,this.handleReconnected).on(hd.Restarting,this.handleReconnecting).on(hd.Resuming,this.handleReconnecting).on(hd.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(hd.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(hd.Closing,this.handleClosing).on(hd.SignalRequestResponse,this.handleSignalRequestResponse).on(hd.DataPacketReceived,this.handleDataPacket)}setMetadata(e){return jl(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return jl(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return jl(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return jl(this,arguments,void 0,function(e){var t=this;let{metadata:n,name:i,attributes:r}=e;return function*(){return new $u((e,o)=>jl(t,void 0,void 0,function*(){var t,a;try{let s=!1;const c=yield this.engine.client.sendUpdateLocalMetadata(null!==(t=null!=n?n:this.metadata)&&void 0!==t?t:"",null!==(a=null!=i?i:this.name)&&void 0!==a?a:"",r),l=performance.now();for(this.pendingSignalRequests.set(c,{resolve:e,reject:e=>{o(e),s=!0},values:{name:i,metadata:n,attributes:r}});performance.now()-l<5e3&&!s;){if((!i||this.name===i)&&(!n||this.metadata===n)&&(!r||Object.entries(r).every(e=>{let[t,n]=e;return this.attributes[t]===n||""===n&&!this.attributes[t]})))return this.pendingSignalRequests.delete(c),void e();yield ih(50)}o(new Td("Request to update local metadata timed out","TimeoutError"))}catch(s){s instanceof Error?o(s):o(new Error(String(s)))}}))}()})}setCameraEnabled(e,t,n){return this.setTrackEnabled(Zd.Source.Camera,e,t,n)}setMicrophoneEnabled(e,t,n){return this.setTrackEnabled(Zd.Source.Microphone,e,t,n)}setScreenShareEnabled(e,t,n){return this.setTrackEnabled(Zd.Source.ScreenShare,e,t,n)}setE2EEEnabled(e){return jl(this,void 0,void 0,function*(){this.encryptionType=e?Us.GCM:Us.NONE,yield this.republishAllTracks(void 0,!1)})}setTrackEnabled(e,t,n,i){return jl(this,void 0,void 0,function*(){var r,o;this.log.debug("setTrackEnabled",Object.assign(Object.assign({},this.logContext),{source:e,enabled:t})),this.republishPromise&&(yield this.republishPromise);let a=this.getTrackPublication(e);if(t)if(a)yield a.unmute();else{let t;if(this.pendingPublishing.has(e)){const t=yield this.waitForPendingPublicationOfSource(e);return t||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e})),yield null==t?void 0:t.unmute(),t}this.pendingPublishing.add(e);try{switch(e){case Zd.Source.Camera:t=yield this.createTracks({video:null===(r=n)||void 0===r||r});break;case Zd.Source.Microphone:t=yield this.createTracks({audio:null===(o=n)||void 0===o||o});break;case Zd.Source.ScreenShare:t=yield this.createScreenTracks(Object.assign({},n));break;default:throw new yd(e)}}catch(s){throw null==t||t.forEach(e=>{e.stop()}),s instanceof Error&&this.emit(ud.MediaDevicesError,s,Hd(e)),this.pendingPublishing.delete(e),s}for(const i of t){const t=Object.assign(Object.assign({},this.roomOptions.publishDefaults),n);e===Zd.Source.Microphone&&jh(i)&&t.preConnectBuffer&&(this.log.info("starting preconnect buffer for microphone",Object.assign({},this.logContext)),i.startPreConnectBuffer())}try{const e=[];for(const r of t)this.log.info("publishing track",Object.assign(Object.assign({},this.logContext),Gd(r))),e.push(this.publishTrack(r,i));const n=yield Promise.all(e);[a]=n}catch(s){throw null==t||t.forEach(e=>{e.stop()}),s}finally{this.pendingPublishing.delete(e)}}else if(!(null==a?void 0:a.track)&&this.pendingPublishing.has(e)&&(a=yield this.waitForPendingPublicationOfSource(e),a||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e}))),a&&a.track)if(e===Zd.Source.ScreenShare){a=yield this.unpublishTrack(a.track);const e=this.getTrackPublication(Zd.Source.ScreenShareAudio);e&&e.track&&this.unpublishTrack(e.track)}else yield a.mute();return a})}enableCameraAndMicrophone(){return jl(this,void 0,void 0,function*(){if(!this.pendingPublishing.has(Zd.Source.Camera)&&!this.pendingPublishing.has(Zd.Source.Microphone)){this.pendingPublishing.add(Zd.Source.Camera),this.pendingPublishing.add(Zd.Source.Microphone);try{const e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map(e=>this.publishTrack(e)))}finally{this.pendingPublishing.delete(Zd.Source.Camera),this.pendingPublishing.delete(Zd.Source.Microphone)}}})}createTracks(e){return jl(this,void 0,void 0,function*(){var t,n;null!=e||(e={});const i=Ud(e,null===(t=this.roomOptions)||void 0===t?void 0:t.audioCaptureDefaults,null===(n=this.roomOptions)||void 0===n?void 0:n.videoCaptureDefaults);try{const e=yield Zf(i,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});return e.map(e=>(jh(e)&&(this.microphoneError=void 0,e.setAudioContext(this.audioContext),e.source=Zd.Source.Microphone,this.emit(ud.AudioStreamAcquired)),Uh(e)&&(this.cameraError=void 0,e.source=Zd.Source.Camera),e))}catch(r){throw r instanceof Error&&(e.audio&&(this.microphoneError=r),e.video&&(this.cameraError=r)),r}})}createScreenTracks(e){return jl(this,void 0,void 0,function*(){if(void 0===e&&(e={}),void 0===navigator.mediaDevices.getDisplayMedia)throw new vd("getDisplayMedia not supported");void 0!==e.resolution||function(){const e=Yu();return"Safari"===(null==e?void 0:e.name)&&e.version.startsWith("17.")||"iOS"===(null==e?void 0:e.os)&&!!(null==e?void 0:e.osVersion)&&kh(e.osVersion,"17")>=0}()||(e.resolution=jd.h1080fps30.resolution);const t=function(e){var t,n;let i=null===(t=e.video)||void 0===t||t;return e.resolution&&e.resolution.width>0&&e.resolution.height>0&&(i="boolean"==typeof i?{}:i,i=uh()?Object.assign(Object.assign({},i),{width:{max:e.resolution.width},height:{max:e.resolution.height},frameRate:e.resolution.frameRate}):Object.assign(Object.assign({},i),{width:{ideal:e.resolution.width},height:{ideal:e.resolution.height},frameRate:e.resolution.frameRate})),{audio:null!==(n=e.audio)&&void 0!==n&&n,video:i,controller:e.controller,selfBrowserSurface:e.selfBrowserSurface,surfaceSwitching:e.surfaceSwitching,systemAudio:e.systemAudio,preferCurrentTab:e.preferCurrentTab}}(e),n=yield navigator.mediaDevices.getDisplayMedia(t),i=n.getVideoTracks();if(0===i.length)throw new yd("no video track found");const r=new bf(i[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});r.source=Zd.Source.ScreenShare,e.contentHint&&(r.mediaStreamTrack.contentHint=e.contentHint);const o=[r];if(n.getAudioTracks().length>0){this.emit(ud.AudioStreamAcquired);const e=new sf(n.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});e.source=Zd.Source.ScreenShareAudio,o.push(e)}return o})}publishTrack(e,t){return jl(this,void 0,void 0,function*(){return this.publishOrRepublishTrack(e,t)})}publishOrRepublishTrack(e,t){return jl(this,arguments,void 0,function(e,t){var n=this;let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function*(){var r,o,a,s;let c,l;if(Bh(e)&&e.setAudioContext(n.audioContext),yield null===(r=n.reconnectFuture)||void 0===r?void 0:r.promise,n.republishPromise&&!i&&(yield n.republishPromise),Ah(e)&&n.pendingPublishPromises.has(e)&&(yield n.pendingPublishPromises.get(e)),e instanceof MediaStreamTrack)c=e.getConstraints();else{let t;switch(c=e.constraints,e.source){case Zd.Source.Microphone:t="audioinput";break;case Zd.Source.Camera:t="videoinput"}t&&n.activeDeviceMap.has(t)&&(c=Object.assign(Object.assign({},c),{deviceId:n.activeDeviceMap.get(t)}))}if(e instanceof MediaStreamTrack)switch(e.kind){case"audio":e=new sf(e,c,!0,n.audioContext,{loggerName:n.roomOptions.loggerName,loggerContextCb:()=>n.logContext});break;case"video":e=new bf(e,c,!0,{loggerName:n.roomOptions.loggerName,loggerContextCb:()=>n.logContext});break;default:throw new yd("unsupported MediaStreamTrack kind ".concat(e.kind))}else e.updateLoggerOptions({loggerName:n.roomOptions.loggerName,loggerContextCb:()=>n.logContext});if(n.trackPublications.forEach(t=>{t.track&&t.track===e&&(l=t)}),l)return n.log.warn("track has already been published, skipping",Object.assign(Object.assign({},n.logContext),Gd(l))),l;const u=Object.assign(Object.assign({},n.roomOptions.publishDefaults),t),d="channelCount"in e.mediaStreamTrack.getSettings()&&2===e.mediaStreamTrack.getSettings().channelCount||2===e.mediaStreamTrack.getConstraints().channelCount,h=null!==(o=u.forceStereo)&&void 0!==o?o:d;h&&(void 0===u.dtx&&n.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",Object.assign(Object.assign({},n.logContext),Gd(e))),void 0===u.red&&n.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),null!==(a=u.dtx)&&void 0!==a||(u.dtx=!1),null!==(s=u.red)&&void 0!==s||(u.red=!1)),!function(){const e=Yu(),t="17.2";if(e)return"Safari"!==e.name&&"iOS"!==e.os||!!("iOS"===e.os&&e.osVersion&&kh(e.osVersion,t)>=0)||"Safari"===e.name&&kh(e.version,t)>=0}()&&n.roomOptions.e2ee&&(n.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2",Object.assign({},n.logContext)),u.simulcast=!1),u.source&&(e.source=u.source);const p=new Promise((t,i)=>jl(n,void 0,void 0,function*(){try{if(this.engine.client.currentState!==fp.CONNECTED){this.log.debug("deferring track publication until signal is connected",Object.assign(Object.assign({},this.logContext),{track:Gd(e)}));let n=!1;const r=setTimeout(()=>{n=!0,e.stop(),i(new Cd("publishing rejected as engine not connected within timeout",408))},15e3);if(yield this.waitUntilEngineConnected(),clearTimeout(r),n)return;const o=yield this.publish(e,u,h);t(o)}else try{const n=yield this.publish(e,u,h);t(n)}catch(n){i(n)}}catch(n){i(n)}}));n.pendingPublishPromises.set(e,p);try{return yield p}catch(f){throw f}finally{n.pendingPublishPromises.delete(e)}}()})}waitUntilEngineConnected(){return this.signalConnectedFuture||(this.signalConnectedFuture=new Ih),this.signalConnectedFuture.promise}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",Object.assign(Object.assign({},this.logContext),Gd(e))),!1;const{canPublish:t,canPublishSources:n}=this.permissions;return!(!t||0!==n.length&&!n.map(e=>function(e){switch(e){case Ts.CAMERA:return Zd.Source.Camera;case Ts.MICROPHONE:return Zd.Source.Microphone;case Ts.SCREEN_SHARE:return Zd.Source.ScreenShare;case Ts.SCREEN_SHARE_AUDIO:return Zd.Source.ScreenShareAudio;default:return Zd.Source.Unknown}}(e)).includes(e.source))||(this.log.warn("insufficient permissions to publish",Object.assign(Object.assign({},this.logContext),Gd(e))),!1)}publish(e,t,n){return jl(this,void 0,void 0,function*(){var i,r,o,a,s,c,l,u,d,h;if(!this.hasPermissionsToPublish(e))throw new Cd("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find(t=>Ah(e)&&t.source===e.source)&&e.source!==Zd.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),Object.assign(Object.assign({},this.logContext),Gd(e))),t.stopMicTrackOnMute&&jh(e)&&(e.stopOnMute=!0),e.source===Zd.Source.ScreenShare&&ch()&&(t.simulcast=!1),"av1"!==t.videoCodec||function(){if(!("getCapabilities"in RTCRtpSender))return!1;if(uh()||ch())return!1;const e=RTCRtpSender.getCapabilities("video");let t=!1;if(e)for(const n of e.codecs)if("video/av1"===n.mimeType.toLowerCase()){t=!0;break}return t}()||(t.videoCodec=void 0),"vp9"!==t.videoCodec||function(){if(!("getCapabilities"in RTCRtpSender))return!1;if(ch())return!1;if(uh()){const e=Yu();if((null==e?void 0:e.version)&&kh(e.version,"16")<0)return!1;if("iOS"===(null==e?void 0:e.os)&&(null==e?void 0:e.osVersion)&&kh(e.osVersion,"16")<0)return!1}const e=RTCRtpSender.getCapabilities("video");let t=!1;if(e)for(const n of e.codecs)if("video/vp9"===n.mimeType.toLowerCase()){t=!0;break}return t}()||(t.videoCodec=void 0),void 0===t.videoCodec&&(t.videoCodec=zp),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(e=>t.videoCodec===Wd(e.mime))||(t.videoCodec=Wd(this.enabledPublishVideoCodecs[0].mime)));const p=t.videoCodec;e.on(fd.Muted,this.onTrackMuted),e.on(fd.Unmuted,this.onTrackUnmuted),e.on(fd.Ended,this.handleTrackEnded),e.on(fd.UpstreamPaused,this.onTrackUpstreamPaused),e.on(fd.UpstreamResumed,this.onTrackUpstreamResumed),e.on(fd.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);const f=[],m=!(null===(i=t.dtx)||void 0===i||i),g=e.getSourceTrackSettings();g.autoGainControl&&f.push(Is.TF_AUTO_GAIN_CONTROL),g.echoCancellation&&f.push(Is.TF_ECHO_CANCELLATION),g.noiseSuppression&&f.push(Is.TF_NOISE_SUPPRESSION),g.channelCount&&g.channelCount>1&&f.push(Is.TF_STEREO),m&&f.push(Is.TF_NO_DTX),Bh(e)&&e.hasPreConnectBuffer&&f.push(Is.TF_PRECONNECT_BUFFER);const v=new xc({cid:e.mediaStreamTrack.id,name:t.name,type:Zd.kindToProto(e.kind),muted:e.isMuted,source:Zd.sourceToProto(e.source),disableDtx:m,encryption:this.encryptionType,stereo:n,disableRed:this.isE2EEEnabled||!(null===(r=t.red)||void 0===r||r),stream:null==t?void 0:t.stream,backupCodecPolicy:null==t?void 0:t.backupCodecPolicy,audioFeatures:f});let y;if(e.kind===Zd.Kind.Video){let n={width:0,height:0};try{n=yield e.waitForDimensions()}catch(T){const t=null!==(a=null===(o=this.roomOptions.videoCaptureDefaults)||void 0===o?void 0:o.resolution)&&void 0!==a?a:Ld.h720.resolution;n={width:t.width,height:t.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign(Object.assign({},this.logContext),Gd(e)),{dims:n}))}v.width=n.width,v.height=n.height,Fh(e)&&(ah(p)&&(e.source===Zd.Source.ScreenShare&&(t.scalabilityMode="L1T3","contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint="motion",this.log.info("forcing contentHint to motion for screenshare with SVC codecs",Object.assign(Object.assign({},this.logContext),Gd(e))))),t.scalabilityMode=null!==(s=t.scalabilityMode)&&void 0!==s?s:"L3T3_KEY"),v.simulcastCodecs=[new Ec({codec:p,cid:e.mediaStreamTrack.id})],!0===t.backupCodec&&(t.backupCodec={codec:zp}),t.backupCodec&&p!==t.backupCodec.codec&&v.encryption===Us.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),v.simulcastCodecs.push(new Ec({codec:t.backupCodec.codec,cid:""})))),y=ff(e.source===Zd.Source.ScreenShare,v.width,v.height,t),v.layers=Cf(v.width,v.height,y,ah(t.videoCodec))}else e.kind===Zd.Kind.Audio&&(y=[{maxBitrate:null===(c=t.audioPreset)||void 0===c?void 0:c.maxBitrate,priority:null!==(u=null===(l=t.audioPreset)||void 0===l?void 0:l.priority)&&void 0!==u?u:"high",networkPriority:null!==(h=null===(d=t.audioPreset)||void 0===d?void 0:d.priority)&&void 0!==h?h:"high"}]);if(!this.engine||this.engine.isClosed)throw new kd("cannot publish track when not connected");const b=()=>jl(this,void 0,void 0,function*(){var n,i,r;if(!this.engine.pcManager)throw new kd("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,t,y),this.emit(ud.LocalSenderCreated,e.sender,e),Fh(e)&&(null!==(n=t.degradationPreference)&&void 0!==n||(t.degradationPreference=function(e){return e.source===Zd.Source.ScreenShare||e.constraints.height&&Nh(e.constraints.height)>=1080?"maintain-resolution":"balanced"}(e)),e.setDegradationPreference(t.degradationPreference)),y)if(ch()&&e.kind===Zd.Kind.Audio){let t;for(const n of this.engine.pcManager.publisher.getTransceivers())if(n.sender===e.sender){t=n;break}t&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:t,codec:"opus",maxbr:(null===(i=y[0])||void 0===i?void 0:i.maxBitrate)?y[0].maxBitrate/1e3:0})}else e.codec&&ah(e.codec)&&(null===(r=y[0])||void 0===r?void 0:r.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:v.cid,codec:e.codec,maxbr:y[0].maxBitrate/1e3});yield this.engine.negotiate()});let k;const S=new Promise((t,n)=>jl(this,void 0,void 0,function*(){var i;try{k=yield this.engine.addTrack(v),t(k)}catch(r){e.sender&&(null===(i=this.engine.pcManager)||void 0===i?void 0:i.publisher)&&(this.engine.pcManager.publisher.removeTrack(e.sender),yield this.engine.negotiate().catch(t=>{this.log.error("failed to negotiate after removing track due to failed add track request",Object.assign(Object.assign(Object.assign({},this.logContext),Gd(e)),{error:t}))})),n(r)}}));if(this.enabledPublishVideoCodecs.length>0){const e=yield Promise.all([S,b()]);k=e[0]}else{let n;if(k=yield S,k.codecs.forEach(e=>{void 0===n&&(n=e.mimeType)}),n&&e.kind===Zd.Kind.Video){const i=Wd(n);i!==p&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign(Object.assign({},this.logContext),Gd(e)),{codec:i})),t.videoCodec=i,y=ff(e.source===Zd.Source.ScreenShare,v.width,v.height,t))}yield b()}const C=new Xf(e.kind,k,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});if(C.on(fd.CpuConstrained,e=>this.onTrackCpuConstrained(e,C)),C.options=t,e.sid=k.sid,this.log.debug("publishing ".concat(e.kind," with encodings"),Object.assign(Object.assign({},this.logContext),{encodings:y,trackInfo:k})),Fh(e)?e.startMonitor(this.engine.client):Bh(e)&&e.startMonitor(),this.addTrackPublication(C),this.emit(ud.LocalTrackPublished,C),Bh(e)&&k.audioFeatures.includes(Is.TF_PRECONNECT_BUFFER)){const t=e.getPreConnectBuffer(),n=e.getPreConnectBufferMimeType();if(this.on(ud.LocalTrackSubscribed,t=>{if(t.trackSid===k.sid){if(!e.hasPreConnectBuffer)return void this.log.warn("subscribe event came to late, buffer already closed",this.logContext);this.log.debug("finished recording preconnect buffer",Object.assign(Object.assign({},this.logContext),Gd(e))),e.stopPreConnectBuffer()}}),t){new Promise((i,r)=>jl(this,void 0,void 0,function*(){var o,a,s,c,l,u;try{this.log.debug("waiting for agent",Object.assign(Object.assign({},this.logContext),Gd(e)));const m=setTimeout(()=>{r(new Error("agent not active within 10 seconds"))},1e4),v=yield this.waitUntilActiveAgentPresent();clearTimeout(m),this.log.debug("sending preconnect buffer",Object.assign(Object.assign({},this.logContext),Gd(e)));const y=yield this.streamBytes({name:"preconnect-buffer",mimeType:n,topic:"lk.agent.pre-connect-audio-buffer",destinationIdentities:[v.identity],attributes:{trackId:C.trackSid,sampleRate:String(null!==(l=g.sampleRate)&&void 0!==l?l:"48000"),channels:String(null!==(u=g.channelCount)&&void 0!==u?u:"1")}});try{for(var d,h=!0,p=Fl(t);!(o=(d=yield p.next()).done);h=!0){c=d.value,h=!1;const e=c;yield y.write(e)}}catch(f){a={error:f}}finally{try{h||o||!(s=p.return)||(yield s.call(p))}finally{if(a)throw a.error}}yield y.close(),i()}catch(T){r(T)}})).then(()=>{this.log.debug("preconnect buffer sent successfully",Object.assign(Object.assign({},this.logContext),Gd(e)))}).catch(t=>{this.log.error("error sending preconnect buffer",Object.assign(Object.assign(Object.assign({},this.logContext),Gd(e)),{error:t}))})}}return C})}get isLocal(){return!0}publishAdditionalCodecForTrack(e,t,n){return jl(this,void 0,void 0,function*(){var i;if(this.encryptionType!==Us.NONE)return;let r;if(this.trackPublications.forEach(t=>{t.track&&t.track===e&&(r=t)}),!r)throw new yd("track is not published");if(!Fh(e))throw new yd("track is not a video track");const o=Object.assign(Object.assign({},null===(i=this.roomOptions)||void 0===i?void 0:i.publishDefaults),n),a=function(e,t,n){var i,r,o,a;if(!n.backupCodec||!0===n.backupCodec||n.backupCodec.codec===n.videoCodec)return;t!==n.backupCodec.codec&&Ol.warn("requested a different codec than specified as backup",{serverRequested:t,backup:n.backupCodec.codec}),n.videoCodec=t,n.videoEncoding=n.backupCodec.encoding;const s=e.mediaStreamTrack.getSettings(),c=null!==(i=s.width)&&void 0!==i?i:null===(r=e.dimensions)||void 0===r?void 0:r.width,l=null!==(o=s.height)&&void 0!==o?o:null===(a=e.dimensions)||void 0===a?void 0:a.height;return e.source===Zd.Source.ScreenShare&&n.simulcast&&(n.simulcast=!1),ff(e.source===Zd.Source.ScreenShare,c,l,n)}(e,t,o);if(!a)return void this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",Object.assign(Object.assign({},this.logContext),Gd(e)));const s=e.addSimulcastTrack(t,a);if(!s)return;const c=new xc({cid:s.mediaStreamTrack.id,type:Zd.kindToProto(e.kind),muted:e.isMuted,source:Zd.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:o.videoCodec,cid:s.mediaStreamTrack.id}]});if(c.layers=Cf(c.width,c.height,a),!this.engine||this.engine.isClosed)throw new kd("cannot publish track when not connected");const l=(yield Promise.all([this.engine.addTrack(c),(()=>jl(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,s,o,a),yield this.engine.negotiate()}))()]))[0];this.log.debug("published ".concat(t," for track ").concat(e.sid),Object.assign(Object.assign({},this.logContext),{encodings:a,trackInfo:l}))})}unpublishTrack(e,t){return jl(this,void 0,void 0,function*(){var n,i;if(Ah(e)){const t=this.pendingPublishPromises.get(e);t&&(this.log.info("awaiting publish promise before attempting to unpublish",Object.assign(Object.assign({},this.logContext),Gd(e))),yield t)}const r=this.getPublicationForTrack(e),o=r?Gd(r):void 0;if(this.log.debug("unpublishing track",Object.assign(Object.assign({},this.logContext),o)),!r||!r.track)return void this.log.warn("track was not unpublished because no publication was found",Object.assign(Object.assign({},this.logContext),o));(e=r.track).off(fd.Muted,this.onTrackMuted),e.off(fd.Unmuted,this.onTrackUnmuted),e.off(fd.Ended,this.handleTrackEnded),e.off(fd.UpstreamPaused,this.onTrackUpstreamPaused),e.off(fd.UpstreamResumed,this.onTrackUpstreamResumed),e.off(fd.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),void 0===t&&(t=null===(i=null===(n=this.roomOptions)||void 0===n?void 0:n.stopLocalTrackOnUnpublish)||void 0===i||i),t?e.stop():e.stopMonitor();let a=!1;const s=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentState<Gp.FAILED&&s)try{for(const e of this.engine.pcManager.publisher.getTransceivers())e.sender===s&&(e.direction="inactive",a=!0);if(this.engine.removeTrack(s)&&(a=!0),Fh(e)){for(const[,t]of e.simulcastCodecs)t.sender&&(this.engine.removeTrack(t.sender)&&(a=!0),t.sender=void 0);e.simulcastCodecs.clear()}}catch(c){this.log.warn("failed to unpublish track",Object.assign(Object.assign(Object.assign({},this.logContext),o),{error:c}))}switch(this.trackPublications.delete(r.trackSid),r.kind){case Zd.Kind.Audio:this.audioTrackPublications.delete(r.trackSid);break;case Zd.Kind.Video:this.videoTrackPublications.delete(r.trackSid)}return this.emit(ud.LocalTrackUnpublished,r),r.setTrack(void 0),a&&(yield this.engine.negotiate()),r})}unpublishTracks(e){return jl(this,void 0,void 0,function*(){return(yield Promise.all(e.map(e=>this.unpublishTrack(e)))).filter(e=>!!e)})}republishAllTracks(e){return jl(this,arguments,void 0,function(e){var t=this;let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function*(){t.republishPromise&&(yield t.republishPromise),t.republishPromise=new $u((i,r)=>jl(t,void 0,void 0,function*(){try{const t=[];this.trackPublications.forEach(n=>{n.track&&(e&&(n.options=Object.assign(Object.assign({},n.options),e)),t.push(n))}),yield Promise.all(t.map(e=>jl(this,void 0,void 0,function*(){const t=e.track;yield this.unpublishTrack(t,!1),!n||t.isMuted||t.source===Zd.Source.ScreenShare||t.source===Zd.Source.ScreenShareAudio||!Bh(t)&&!Fh(t)||t.isUserProvided||(this.log.debug("restarting existing track",Object.assign(Object.assign({},this.logContext),{track:e.trackSid})),yield t.restartTrack()),yield this.publishOrRepublishTrack(t,e.options,!0)}))),i()}catch(t){t instanceof Error?r(t):r(new Error(String(t)))}finally{this.republishPromise=void 0}})),yield t.republishPromise}()})}publishData(e){return jl(this,arguments,void 0,function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){const i=n.reliable?Hs.RELIABLE:Hs.LOSSY,r=n.destinationIdentities,o=n.topic;let a=new Js({participantIdentity:t.identity,payload:e,destinationIdentities:r,topic:o});const s=new qs({kind:i,value:{case:"user",value:a}});yield t.engine.sendDataPacket(s,i)}()})}publishDtmf(e,t){return jl(this,void 0,void 0,function*(){const n=new qs({kind:Hs.RELIABLE,value:{case:"sipDtmf",value:new Qs({code:e,digit:t})}});yield this.engine.sendDataPacket(n,Hs.RELIABLE)})}sendChatMessage(e,t){return jl(this,void 0,void 0,function*(){const n={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:null==t?void 0:t.attachments},i=new qs({value:{case:"chatMessage",value:new Zs(Object.assign(Object.assign({},n),{timestamp:na.parse(n.timestamp)}))}});return yield this.engine.sendDataPacket(i,Hs.RELIABLE),this.emit(ud.ChatMessage,n),n})}editChatMessage(e,t){return jl(this,void 0,void 0,function*(){const n=Object.assign(Object.assign({},t),{message:e,editTimestamp:Date.now()}),i=new qs({value:{case:"chatMessage",value:new Zs(Object.assign(Object.assign({},n),{timestamp:na.parse(n.timestamp),editTimestamp:na.parse(n.editTimestamp)}))}});return yield this.engine.sendDataPacket(i,Hs.RELIABLE),this.emit(ud.ChatMessage,n),n})}sendText(e,t){return jl(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendText(e,t)})}streamText(e){return jl(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamText(e)})}sendFile(e,t){return jl(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.sendFile(e,t)})}streamBytes(e){return jl(this,void 0,void 0,function*(){return this.roomOutgoingDataStreamManager.streamBytes(e)})}performRpc(e){let{destinationIdentity:t,method:n,payload:i,responseTimeout:r=15e3}=e;return new $u((e,o)=>jl(this,void 0,void 0,function*(){var a,s,c,l;if(Xp(i)>15360)return void o(Yp.builtIn("REQUEST_PAYLOAD_TOO_LARGE"));if((null===(s=null===(a=this.engine.latestJoinResponse)||void 0===a?void 0:a.serverInfo)||void 0===s?void 0:s.version)&&kh(null===(l=null===(c=this.engine.latestJoinResponse)||void 0===c?void 0:c.serverInfo)||void 0===l?void 0:l.version,"1.8.0")<0)return void o(Yp.builtIn("UNSUPPORTED_SERVER"));const u=Math.max(r,8e3),d=crypto.randomUUID();yield this.publishRpcRequest(t,d,n,i,u);const h=setTimeout(()=>{this.pendingAcks.delete(d),o(Yp.builtIn("CONNECTION_TIMEOUT")),this.pendingResponses.delete(d),clearTimeout(p)},7e3);this.pendingAcks.set(d,{resolve:()=>{clearTimeout(h)},participantIdentity:t});const p=setTimeout(()=>{this.pendingResponses.delete(d),o(Yp.builtIn("RESPONSE_TIMEOUT"))},r);this.pendingResponses.set(d,{resolve:(t,n)=>{clearTimeout(p),this.pendingAcks.has(d)&&(this.log.warn("RPC response received before ack",d),this.pendingAcks.delete(d),clearTimeout(h)),n?o(n):e(null!=t?t:"")},participantIdentity:t})}))}registerRpcMethod(e,t){this.rpcHandlers.has(e)&&this.log.warn("you're overriding the RPC handler for method ".concat(e,", in the future this will throw an error")),this.rpcHandlers.set(e,t)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}setTrackSubscriptionPermissions(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];this.participantTrackPermissions=t,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}handleIncomingRpcAck(e){const t=this.pendingAcks.get(e);t?(t.resolve(),this.pendingAcks.delete(e)):console.error("Ack received for unexpected RPC request",e)}handleIncomingRpcResponse(e,t,n){const i=this.pendingResponses.get(e);i?(i.resolve(t,n),this.pendingResponses.delete(e)):console.error("Response received for unexpected RPC request",e)}publishRpcRequest(e,t,n,i,r){return jl(this,void 0,void 0,function*(){const o=new qs({destinationIdentities:[e],kind:Hs.RELIABLE,value:{case:"rpcRequest",value:new ec({id:t,method:n,payload:i,responseTimeoutMs:r,version:1})}});yield this.engine.sendDataPacket(o,Hs.RELIABLE)})}handleParticipantDisconnected(e){for(const[t,{participantIdentity:n}]of this.pendingAcks)n===e&&this.pendingAcks.delete(t);for(const[t,{participantIdentity:n,resolve:i}]of this.pendingResponses)n===e&&(i(null,Yp.builtIn("RECIPIENT_DISCONNECTED")),this.pendingResponses.delete(t))}setEnabledPublishCodecs(e){this.enabledPublishVideoCodecs=e.filter(e=>"video"===e.mime.split("/")[0].toLowerCase())}updateInfo(e){return!!super.updateInfo(e)&&(e.tracks.forEach(e=>{var t,n;const i=this.trackPublications.get(e.sid);if(i){const r=i.isMuted||null!==(n=null===(t=i.track)||void 0===t?void 0:t.isUpstreamPaused)&&void 0!==n&&n;r!==e.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign(Object.assign({},this.logContext),Gd(i)),{mutedOnServer:r})),this.engine.client.sendMuteTrack(e.sid,r))}}),!0)}setActiveAgent(e){var t,n,i,r;this.firstActiveAgent=e,e&&!this.firstActiveAgent&&(this.firstActiveAgent=e),e?null===(n=null===(t=this.activeAgentFuture)||void 0===t?void 0:t.resolve)||void 0===n||n.call(t,e):null===(r=null===(i=this.activeAgentFuture)||void 0===i?void 0:i.reject)||void 0===r||r.call(i,new Error("Agent disconnected")),this.activeAgentFuture=void 0}waitUntilActiveAgentPresent(){return this.firstActiveAgent?Promise.resolve(this.firstActiveAgent):(this.activeAgentFuture||(this.activeAgentFuture=new Ih),this.activeAgentFuture.promise)}getPublicationForTrack(e){let t;return this.trackPublications.forEach(n=>{const i=n.track;i&&(e instanceof MediaStreamTrack?(Bh(i)||Fh(i))&&i.mediaStreamTrack===e&&(t=n):e===i&&(t=n))}),t}waitForPendingPublicationOfSource(e){return jl(this,void 0,void 0,function*(){const t=Date.now();for(;Date.now()<t+1e4;){const t=Array.from(this.pendingPublishPromises.entries()).find(t=>{let[n]=t;return n.source===e});if(t)return t[1];yield ih(20)}})}}class nm extends Hf{constructor(e,t,n,i){super(e,t.sid,t.name,i),this.track=void 0,this.allowed=!0,this.requestedDisabled=void 0,this.visible=!0,this.handleEnded=e=>{this.setTrack(void 0),this.emit(fd.Ended,e)},this.handleVisibilityChange=e=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(e),this.logContext),this.visible=e,this.emitTrackUpdate()},this.handleVideoDimensionsChange=e=>{this.log.debug("adaptivestream video dimensions ".concat(e.width,"x").concat(e.height),this.logContext),this.videoDimensionsAdaptiveStream=e,this.emitTrackUpdate()},this.subscribed=n,this.updateInfo(t)}setSubscribed(e){const t=this.subscriptionStatus,n=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);const i=new Lc({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new rc({participantSid:"",trackSids:[this.trackSid]})]});this.emit(fd.UpdateSubscription,i),this.emitSubscriptionUpdateIfChanged(t),this.emitPermissionUpdateIfChanged(n)}get subscriptionStatus(){return!1===this.subscribed?Hf.SubscriptionStatus.Unsubscribed:super.isSubscribed?Hf.SubscriptionStatus.Subscribed:Hf.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?Hf.PermissionStatus.Allowed:Hf.PermissionStatus.NotAllowed}get isSubscribed(){return!1!==this.subscribed&&super.isSubscribed}get isDesired(){return!1!==this.subscribed}get isEnabled(){return void 0!==this.requestedDisabled?!this.requestedDisabled:!this.isAdaptiveStream||this.visible}get isLocal(){return!1}setEnabled(e){this.isManualOperationAllowed()&&this.requestedDisabled!==!e&&(this.requestedDisabled=!e,this.emitTrackUpdate())}setVideoQuality(e){this.isManualOperationAllowed()&&this.requestedMaxQuality!==e&&(this.requestedMaxQuality=e,this.requestedVideoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var t,n;this.isManualOperationAllowed()&&((null===(t=this.requestedVideoDimensions)||void 0===t?void 0:t.width)===e.width&&(null===(n=this.requestedVideoDimensions)||void 0===n?void 0:n.height)===e.height||(qh(this.track)&&(this.requestedVideoDimensions=e),this.requestedMaxQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&qh(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){var e;return null!==(e=this.requestedMaxQuality)&&void 0!==e?e:Yd.HIGH}setTrack(e){const t=this.subscriptionStatus,n=this.permissionStatus,i=this.track;i!==e&&(i&&(i.off(fd.VideoDimensionsChanged,this.handleVideoDimensionsChange),i.off(fd.VisibilityChanged,this.handleVisibilityChange),i.off(fd.Ended,this.handleEnded),i.detach(),i.stopMonitor(),this.emit(fd.Unsubscribed,i)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on(fd.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on(fd.VisibilityChanged,this.handleVisibilityChange),e.on(fd.Ended,this.handleEnded),this.emit(fd.Subscribed,e)),this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(t))}setAllowed(e){const t=this.subscriptionStatus,n=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(n),this.emitSubscriptionUpdateIfChanged(t)}setSubscriptionError(e){this.emit(fd.SubscriptionFailed,e)}updateInfo(e){super.updateInfo(e);const t=this.metadataMuted;this.metadataMuted=e.muted,this.track?this.track.setMuted(e.muted):t!==e.muted&&this.emit(e.muted?fd.Muted:fd.Unmuted)}emitSubscriptionUpdateIfChanged(e){const t=this.subscriptionStatus;e!==t&&this.emit(fd.SubscriptionStatusChanged,t,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit(fd.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return!!this.isDesired||(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return qh(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new Ac({trackSids:[this.trackSid],disabled:!this.isEnabled,fps:this.fps});if(this.kind===Zd.Kind.Video){let r=this.requestedVideoDimensions;if(void 0!==this.videoDimensionsAdaptiveStream)if(r){Jd(this.videoDimensionsAdaptiveStream,r)&&(this.log.debug("using adaptive stream dimensions instead of requested",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),r=this.videoDimensionsAdaptiveStream)}else if(void 0!==this.requestedMaxQuality&&this.trackInfo){const e=(t=this.trackInfo,n=this.requestedMaxQuality,null===(i=t.layers)||void 0===i?void 0:i.find(e=>e.quality===n));e&&Jd(this.videoDimensionsAdaptiveStream,e)&&(this.log.debug("using adaptive stream dimensions instead of max quality layer",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),r=this.videoDimensionsAdaptiveStream)}else this.log.debug("using adaptive stream dimensions",Object.assign(Object.assign({},this.logContext),this.videoDimensionsAdaptiveStream)),r=this.videoDimensionsAdaptiveStream;r?(e.width=Math.ceil(r.width),e.height=Math.ceil(r.height)):void 0!==this.requestedMaxQuality?(this.log.debug("using requested max quality",Object.assign(Object.assign({},this.logContext),{quality:this.requestedMaxQuality})),e.quality=this.requestedMaxQuality):(this.log.debug("using default quality",Object.assign(Object.assign({},this.logContext),{quality:Yd.HIGH})),e.quality=Yd.HIGH)}var t,n,i;this.emit(fd.UpdateSettings,e)}}class im extends em{static fromParticipantInfo(e,t,n){return new im(e,t.sid,t.identity,t.name,t.metadata,t.attributes,n,t.kind)}get logContext(){return Object.assign(Object.assign({},super.logContext),{rpID:this.sid,remoteParticipant:this.identity})}constructor(e,t,n,i,r,o,a){super(t,n||"",i,r,o,a,arguments.length>7&&void 0!==arguments[7]?arguments[7]:As.STANDARD),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.volumeMap=new Map}addTrackPublication(e){super.addTrackPublication(e),e.on(fd.UpdateSettings,t=>{this.log.debug("send update settings",Object.assign(Object.assign(Object.assign({},this.logContext),Gd(e)),{settings:t})),this.signalClient.sendUpdateTrackSettings(t)}),e.on(fd.UpdateSubscription,e=>{e.participantTracks.forEach(e=>{e.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(e)}),e.on(fd.SubscriptionPermissionChanged,t=>{this.emit(ud.TrackSubscriptionPermissionChanged,e,t)}),e.on(fd.SubscriptionStatusChanged,t=>{this.emit(ud.TrackSubscriptionStatusChanged,e,t)}),e.on(fd.Subscribed,t=>{this.emit(ud.TrackSubscribed,t,e)}),e.on(fd.Unsubscribed,t=>{this.emit(ud.TrackUnsubscribed,t,e)}),e.on(fd.SubscriptionFailed,t=>{this.emit(ud.TrackSubscriptionFailed,e.trackSid,t)})}getTrackPublication(e){const t=super.getTrackPublication(e);if(t)return t}getTrackPublicationByName(e){const t=super.getTrackPublicationByName(e);if(t)return t}setVolume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Zd.Source.Microphone;this.volumeMap.set(t,e);const n=this.getTrackPublication(t);n&&n.track&&n.track.setVolume(e)}getVolume(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Zd.Source.Microphone;const t=this.getTrackPublication(e);return t&&t.track?t.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,t,n,i,r,o){let a=this.getTrackPublicationBySid(t);if(a||t.startsWith("TR")||this.trackPublications.forEach(t=>{a||e.kind!==t.kind.toString()||(a=t)}),!a)return 0===o?(this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:t})),void this.emit(ud.TrackSubscriptionFailed,t)):(void 0===o&&(o=20),void setTimeout(()=>{this.addSubscribedMediaTrack(e,t,n,i,r,o-1)},150));if("ended"===e.readyState)return this.log.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",Object.assign(Object.assign({},this.logContext),Gd(a))),void this.emit(ud.TrackSubscriptionFailed,t);let s;return s="video"===e.kind?new Bf(e,t,i,r):new Ff(e,t,i,this.audioContext,this.audioOutput),s.source=a.source,s.isMuted=a.isMuted,s.setMediaStream(n),s.start(),a.setTrack(s),this.volumeMap.has(a.source)&&zh(s)&&jh(s)&&s.setVolume(this.volumeMap.get(a.source)),a}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;const t=new Map,n=new Map;return e.tracks.forEach(e=>{var i,r;let o=this.getTrackPublicationBySid(e.sid);if(o)o.updateInfo(e);else{const t=Zd.kindFromProto(e.type);if(!t)return;o=new nm(t,e,null===(i=this.signalClient.connectOptions)||void 0===i?void 0:i.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:null===(r=this.loggerOptions)||void 0===r?void 0:r.loggerName}),o.updateInfo(e),n.set(e.sid,o);const a=Array.from(this.trackPublications.values()).find(e=>e.source===(null==o?void 0:o.source));a&&o.source!==Zd.Source.Unknown&&this.log.debug("received a second track publication for ".concat(this.identity," with the same source: ").concat(o.source),Object.assign(Object.assign({},this.logContext),{oldTrack:Gd(a),newTrack:Gd(o)})),this.addTrackPublication(o)}t.set(e.sid,o)}),this.trackPublications.forEach(e=>{t.has(e.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),Gd(e))),this.unpublishTrack(e.trackSid,!0))}),n.forEach(e=>{this.emit(ud.TrackPublished,e)}),!0}unpublishTrack(e,t){const n=this.trackPublications.get(e);if(!n)return;const{track:i}=n;switch(i&&(i.stop(),n.setTrack(void 0)),this.trackPublications.delete(e),n.kind){case Zd.Kind.Audio:this.audioTrackPublications.delete(e);break;case Zd.Kind.Video:this.videoTrackPublications.delete(e)}t&&this.emit(ud.TrackUnpublished,n)}setAudioOutput(e){return jl(this,void 0,void 0,function*(){this.audioOutput=e;const t=[];this.audioTrackPublications.forEach(n=>{var i;jh(n.track)&&zh(n.track)&&t.push(n.track.setSinkId(null!==(i=e.deviceId)&&void 0!==i?i:"default"))}),yield Promise.all(t)})}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return this.log.trace("participant event",Object.assign(Object.assign({},this.logContext),{event:e,args:n})),super.emit(e,...n)}}(Yf=Qf||(Qf={})).Disconnected="disconnected",Yf.Connecting="connecting",Yf.Connected="connected",Yf.Reconnecting="reconnecting",Yf.SignalReconnecting="signalReconnecting";class rm extends Vl.EventEmitter{get hasE2EESetup(){return void 0!==this.e2eeManager}constructor(e){var t,n,i,r,o;if(super(),t=this,this.state=Qf.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.isVideoPlaybackBlocked=!1,this.log=Ol,this.bufferedEvents=[],this.isResuming=!1,this.rpcHandlers=new Map,this.connect=(e,t,n)=>jl(this,void 0,void 0,function*(){var i;if("undefined"==typeof RTCPeerConnection||!rh()&&!oh())throw fh()?Error("WebRTC isn't detected, have you called registerGlobals?"):Error("LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.");const r=yield this.disconnectLock.lock();if(this.state===Qf.Connected)return this.log.info("already connected to room ".concat(this.name),this.logContext),r(),Promise.resolve();if(this.connectFuture)return r(),this.connectFuture.promise;this.setAndEmitConnectionState(Qf.Connecting),(null===(i=this.regionUrlProvider)||void 0===i?void 0:i.getServerUrl().toString())!==Wh(e)&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),mh(new URL(e))&&(void 0===this.regionUrlProvider?this.regionUrlProvider=new Qp(e,t):this.regionUrlProvider.updateToken(t),this.regionUrlProvider.fetchRegionSettings().then(e=>{var t;null===(t=this.regionUrlProvider)||void 0===t||t.setServerReportedRegions(e)}).catch(e=>{this.log.warn("could not fetch region settings",Object.assign(Object.assign({},this.logContext),{error:e}))}));const o=(i,a,s)=>jl(this,void 0,void 0,function*(){var c,l;this.abortController&&this.abortController.abort();const u=new AbortController;this.abortController=u,null==r||r();try{if(yield ap.getInstance().getBackOffPromise(e),u.signal.aborted)throw gd.cancelled("Connection attempt aborted");yield this.attemptConnection(null!=s?s:e,t,n,u),this.abortController=void 0,i()}catch(d){if(this.regionUrlProvider&&d instanceof gd&&d.reason!==nd.Cancelled&&d.reason!==nd.NotAllowed){let t=null;try{this.log.debug("Fetching next region"),t=yield this.regionUrlProvider.getNextBestRegionUrl(null===(c=this.abortController)||void 0===c?void 0:c.signal)}catch(h){if(h instanceof gd&&(401===h.status||h.reason===nd.Cancelled))return this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),void a(h)}[nd.InternalError,nd.ServerUnreachable,nd.Timeout].includes(d.reason)&&(this.log.debug("Adding failed connection attempt to back off"),ap.getInstance().addFailedConnectionAttempt(e)),t&&!(null===(l=this.abortController)||void 0===l?void 0:l.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(d.message,". Retrying with another region: ").concat(t),this.logContext),this.recreateEngine(),yield o(i,a,t)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,Mh(d)),a(d))}else{let e=Ps.UNKNOWN_REASON;d instanceof gd&&(e=Mh(d)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e),a(d)}}}),a=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new Ih((e,t)=>{o(e,t,a)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(e,t,n,i,r,o)=>jl(this,void 0,void 0,function*(){var a,s,c;const l=yield n.join(e,t,{autoSubscribe:i.autoSubscribe,adaptiveStream:"object"==typeof r.adaptiveStream||r.adaptiveStream,maxRetries:i.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:i.websocketTimeout},o.signal,!r.singlePeerConnection);let u=l.serverInfo;if(u||(u={version:l.serverVersion,region:l.serverRegion}),this.serverInfo=u,this.log.debug("connected to Livekit Server ".concat(Object.entries(u).map(e=>{let[t,n]=e;return"".concat(t,": ").concat(n)}).join(", ")),{room:null===(a=l.room)||void 0===a?void 0:a.name,roomSid:null===(s=l.room)||void 0===s?void 0:s.sid,identity:null===(c=l.participant)||void 0===c?void 0:c.identity}),!u.version)throw new bd("unknown server version");return"0.15.1"===u.version&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version",this.logContext),r.dynacast=!1),l}),this.applyJoinResponse=e=>{const t=e.participant;if(this.localParticipant.sid=t.sid,this.localParticipant.identity=t.identity,this.localParticipant.setEnabledPublishCodecs(e.enabledPublishCodecs),this.e2eeManager)try{this.e2eeManager.setSifTrailer(e.sifTrailer)}catch(n){this.log.error(n instanceof Error?n.message:"Could not set SifTrailer",Object.assign(Object.assign({},this.logContext),{error:n}))}this.handleParticipantUpdates([t,...e.otherParticipants]),e.room&&this.handleRoomUpdate(e.room)},this.attemptConnection=(e,t,n,i)=>jl(this,void 0,void 0,function*(){var r,o;this.state===Qf.Reconnecting||this.isResuming||(null===(r=this.engine)||void 0===r?void 0:r.pendingReconnect)?(this.log.info("Reconnection attempt replaced by new connection attempt",this.logContext),this.recreateEngine()):this.maybeCreateEngine(),(null===(o=this.regionUrlProvider)||void 0===o?void 0:o.isCloud())&&this.engine.setRegionUrlProvider(this.regionUrlProvider),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},Kp),n),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const n=yield this.connectSignal(e,t,this.engine,this.connOptions,this.options,i);this.applyJoinResponse(n),this.setupLocalParticipantEvents(),this.emit(cd.SignalConnected)}catch(a){yield this.engine.close(),this.recreateEngine();const e=i.signal.aborted?gd.cancelled("Signal connection aborted"):gd.serverUnreachable("could not establish signal connection");throw a instanceof Error&&(e.message="".concat(e.message,": ").concat(a.message)),a instanceof gd&&(e.reason=a.reason,e.status=a.status),this.log.debug("error trying to establish signal connection",Object.assign(Object.assign({},this.logContext),{error:a})),e}if(i.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),gd.cancelled("Connection attempt aborted");try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,i)}catch(s){throw yield this.engine.close(),this.recreateEngine(),s}ph()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),ph()&&window.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(Qf.Connected),this.emit(cd.Connected),ap.getInstance().resetFailedConnectionAttempts(e),this.registerConnectionReconcile(),this.regionUrlProvider&&this.regionUrlProvider.notifyConnected()}),this.disconnect=function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];return jl(t,[...n],void 0,function(){var e=this;let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return function*(){var n,i,r;const o=yield e.disconnectLock.lock();try{if(e.state===Qf.Disconnected)return void e.log.debug("already disconnected",e.logContext);if(e.log.info("disconnect from room",Object.assign({},e.logContext)),e.state===Qf.Connecting||e.state===Qf.Reconnecting||e.isResuming){const t="Abort connection attempt due to user initiated disconnect";e.log.warn(t,e.logContext),null===(n=e.abortController)||void 0===n||n.abort(t),null===(r=null===(i=e.connectFuture)||void 0===i?void 0:i.reject)||void 0===r||r.call(i,gd.cancelled("Client initiated disconnect")),e.connectFuture=void 0}e.engine&&(e.engine.client.isDisconnected||(yield e.engine.client.sendLeave()),yield e.engine.close()),e.handleDisconnect(t,Ps.CLIENT_INITIATED),e.engine=void 0}finally{o()}}()})},this.onPageLeave=()=>jl(this,void 0,void 0,function*(){this.log.info("Page leave detected, disconnecting",this.logContext),yield this.disconnect()}),this.startAudio=()=>jl(this,void 0,void 0,function*(){const e=[],t=Yu();if(t&&"iOS"===t.os){const t="livekit-dummy-audio-el";let n=document.getElementById(t);if(!n){n=document.createElement("audio"),n.id=t,n.autoplay=!0,n.hidden=!0;const e=Rh();e.enabled=!0;const i=new MediaStream([e]);n.srcObject=i,document.addEventListener("visibilitychange",()=>{n&&(n.srcObject=document.hidden?null:i,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status",this.logContext),this.startAudio()))}),document.body.append(n),this.once(cd.Disconnected,()=>{null==n||n.remove(),n=null})}e.push(n)}this.remoteParticipants.forEach(t=>{t.audioTrackPublications.forEach(t=>{t.track&&t.track.attachedElements.forEach(t=>{e.push(t)})})});try{yield Promise.all([this.acquireAudioContext(),...e.map(e=>(e.muted=!1,e.play()))]),this.handleAudioPlaybackStarted()}catch(n){throw this.handleAudioPlaybackFailed(n),n}}),this.startVideo=()=>jl(this,void 0,void 0,function*(){const e=[];for(const t of this.remoteParticipants.values())t.videoTrackPublications.forEach(t=>{var n;null===(n=t.track)||void 0===n||n.attachedElements.forEach(t=>{e.includes(t)||e.push(t)})});yield Promise.all(e.map(e=>e.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(e=>{"NotAllowedError"===e.name?this.handleVideoPlaybackFailed():this.log.warn("Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler",this.logContext)})}),this.handleRestarting=()=>{this.clearConnectionReconcile(),this.isResuming=!1;for(const e of this.remoteParticipants.values())this.handleParticipantDisconnected(e.identity,e);this.setAndEmitConnectionState(Qf.Reconnecting)&&this.emit(cd.Reconnecting)},this.handleSignalRestarted=e=>jl(this,void 0,void 0,function*(){this.log.debug("signal reconnected to server, region ".concat(e.serverRegion),Object.assign(Object.assign({},this.logContext),{region:e.serverRegion})),this.bufferedEvents=[],this.applyJoinResponse(e);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(t){this.log.error("error trying to re-publish tracks after reconnection",Object.assign(Object.assign({},this.logContext),{error:t}))}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",Object.assign(Object.assign({},this.logContext),{region:e.serverRegion}))}catch(n){return}this.setAndEmitConnectionState(Qf.Connected),this.emit(cd.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=e=>{e.forEach(e=>{var t;if(e.identity===this.localParticipant.identity)return void this.localParticipant.updateInfo(e);""===e.identity&&(e.identity=null!==(t=this.sidToIdentity.get(e.sid))&&void 0!==t?t:"");let n=this.remoteParticipants.get(e.identity);e.state===Ls.DISCONNECTED?this.handleParticipantDisconnected(e.identity,n):n=this.getOrCreateParticipant(e.identity,e)})},this.handleActiveSpeakersUpdate=e=>{const t=[],n={};e.forEach(e=>{if(n[e.sid]=!0,e.sid===this.localParticipant.sid)this.localParticipant.audioLevel=e.level,this.localParticipant.setIsSpeaking(!0),t.push(this.localParticipant);else{const n=this.getRemoteParticipantBySid(e.sid);n&&(n.audioLevel=e.level,n.setIsSpeaking(!0),t.push(n))}}),n[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(e=>{n[e.sid]||(e.audioLevel=0,e.setIsSpeaking(!1))}),this.activeSpeakers=t,this.emitWhenConnected(cd.ActiveSpeakersChanged,t)},this.handleSpeakersChanged=e=>{const t=new Map;this.activeSpeakers.forEach(e=>{const n=this.remoteParticipants.get(e.identity);n&&n.sid!==e.sid||t.set(e.sid,e)}),e.forEach(e=>{let n=this.getRemoteParticipantBySid(e.sid);e.sid===this.localParticipant.sid&&(n=this.localParticipant),n&&(n.audioLevel=e.level,n.setIsSpeaking(e.active),e.active?t.set(e.sid,n):t.delete(e.sid))});const n=Array.from(t.values());n.sort((e,t)=>t.audioLevel-e.audioLevel),this.activeSpeakers=n,this.emitWhenConnected(cd.ActiveSpeakersChanged,n)},this.handleStreamStateUpdate=e=>{e.streamStates.forEach(e=>{const t=this.getRemoteParticipantBySid(e.participantSid);if(!t)return;const n=t.getTrackPublicationBySid(e.trackSid);if(!n||!n.track)return;const i=Zd.streamStateFromProto(e.state);n.track.setStreamState(i),i!==n.track.streamState&&(t.emit(ud.TrackStreamStateChanged,n,n.track.streamState),this.emitWhenConnected(cd.TrackStreamStateChanged,n,n.track.streamState,t))})},this.handleSubscriptionPermissionUpdate=e=>{const t=this.getRemoteParticipantBySid(e.participantSid);if(!t)return;const n=t.getTrackPublicationBySid(e.trackSid);n&&n.setAllowed(e.allowed)},this.handleSubscriptionError=e=>{const t=Array.from(this.remoteParticipants.values()).find(t=>t.trackPublications.has(e.trackSid));if(!t)return;const n=t.getTrackPublicationBySid(e.trackSid);n&&n.setSubscriptionError(e.err)},this.handleDataPacket=(e,t)=>{const n=this.remoteParticipants.get(e.participantIdentity);if("user"===e.value.case)this.handleUserPacket(n,e.value.value,e.kind,t);else if("transcription"===e.value.case)this.handleTranscription(n,e.value.value);else if("sipDtmf"===e.value.case)this.handleSipDtmf(n,e.value.value);else if("chatMessage"===e.value.case)this.handleChatMessage(n,e.value.value);else if("metrics"===e.value.case)this.handleMetrics(e.value.value,n);else if("streamHeader"===e.value.case||"streamChunk"===e.value.case||"streamTrailer"===e.value.case)this.handleDataStream(e,t);else if("rpcRequest"===e.value.case){const t=e.value.value;this.handleIncomingRpcRequest(e.participantIdentity,t.id,t.method,t.payload,t.responseTimeoutMs,t.version)}},this.handleUserPacket=(e,t,n,i)=>{this.emit(cd.DataReceived,t.payload,e,n,t.topic,i),null==e||e.emit(ud.DataReceived,t.payload,n,i)},this.handleSipDtmf=(e,t)=>{this.emit(cd.SipDTMFReceived,t,e),null==e||e.emit(ud.SipDTMFReceived,t)},this.handleTranscription=(e,t)=>{const n=t.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(t.transcribedParticipantIdentity),i=null==n?void 0:n.trackPublications.get(t.trackId),r=function(e,t){return e.segments.map(e=>{let{id:n,text:i,language:r,startTime:o,endTime:a,final:s}=e;var c;const l=null!==(c=t.get(n))&&void 0!==c?c:Date.now(),u=Date.now();return s?t.delete(n):t.set(n,l),{id:n,text:i,startTime:Number.parseInt(o.toString()),endTime:Number.parseInt(a.toString()),final:s,language:r,firstReceivedTime:l,lastReceivedTime:u}})}(t,this.transcriptionReceivedTimes);null==i||i.emit(fd.TranscriptionReceived,r),null==n||n.emit(ud.TranscriptionReceived,r,i),this.emit(cd.TranscriptionReceived,r,n,i)},this.handleChatMessage=(e,t)=>{const n=function(e){const{id:t,timestamp:n,message:i,editTimestamp:r}=e;return{id:t,timestamp:Number.parseInt(n.toString()),editTimestamp:r?Number.parseInt(r.toString()):void 0,message:i}}(t);this.emit(cd.ChatMessage,n,e)},this.handleMetrics=(e,t)=>{this.emit(cd.MetricsReceived,e,t)},this.handleDataStream=(e,t)=>{this.incomingDataStreamManager.handleDataStreamPacket(e,t)},this.bufferedSegments=new Map,this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(cd.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=e=>{this.log.warn("could not playback audio",Object.assign(Object.assign({},this.logContext),{error:e})),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(cd.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(cd.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(cd.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>jl(this,void 0,void 0,function*(){var e;"iOS"!==(null===(e=Yu())||void 0===e?void 0:e.os)&&(yield this.selectDefaultDevices()),this.emit(cd.MediaDevicesChanged)}),this.handleRoomUpdate=e=>{const t=this.roomInfo;this.roomInfo=e,t&&t.metadata!==e.metadata&&this.emitWhenConnected(cd.RoomMetadataChanged,e.metadata),(null==t?void 0:t.activeRecording)!==e.activeRecording&&this.emitWhenConnected(cd.RecordingStatusChanged,e.activeRecording)},this.handleConnectionQualityUpdate=e=>{e.updates.forEach(e=>{if(e.participantSid===this.localParticipant.sid)return void this.localParticipant.setConnectionQuality(e.quality);const t=this.getRemoteParticipantBySid(e.participantSid);t&&t.setConnectionQuality(e.quality)})},this.onLocalParticipantMetadataChanged=e=>{this.emit(cd.ParticipantMetadataChanged,e,this.localParticipant)},this.onLocalParticipantNameChanged=e=>{this.emit(cd.ParticipantNameChanged,e,this.localParticipant)},this.onLocalAttributesChanged=e=>{this.emit(cd.ParticipantAttributesChanged,e,this.localParticipant)},this.onLocalTrackMuted=e=>{this.emit(cd.TrackMuted,e,this.localParticipant)},this.onLocalTrackUnmuted=e=>{this.emit(cd.TrackUnmuted,e,this.localParticipant)},this.onTrackProcessorUpdate=e=>{var t;null===(t=null==e?void 0:e.onPublish)||void 0===t||t.call(e,this)},this.onLocalTrackPublished=e=>jl(this,void 0,void 0,function*(){var t,n,i,r,o,a;if(null===(t=e.track)||void 0===t||t.on(fd.TrackProcessorUpdate,this.onTrackProcessorUpdate),null===(n=e.track)||void 0===n||n.on(fd.Restarted,this.onLocalTrackRestarted),null===(o=null===(r=null===(i=e.track)||void 0===i?void 0:i.getProcessor())||void 0===r?void 0:r.onPublish)||void 0===o||o.call(r,this),this.emit(cd.LocalTrackPublished,e,this.localParticipant),Bh(e.track)){(yield e.track.checkForSilence())&&this.emit(cd.LocalAudioSilenceDetected,e)}const s=yield null===(a=e.track)||void 0===a?void 0:a.getDeviceId(!1),c=Hd(e.source);c&&s&&s!==this.localParticipant.activeDeviceMap.get(c)&&(this.localParticipant.activeDeviceMap.set(c,s),this.emit(cd.ActiveDeviceChanged,c,s))}),this.onLocalTrackUnpublished=e=>{var t,n;null===(t=e.track)||void 0===t||t.off(fd.TrackProcessorUpdate,this.onTrackProcessorUpdate),null===(n=e.track)||void 0===n||n.off(fd.Restarted,this.onLocalTrackRestarted),this.emit(cd.LocalTrackUnpublished,e,this.localParticipant)},this.onLocalTrackRestarted=e=>jl(this,void 0,void 0,function*(){const t=yield e.getDeviceId(!1),n=Hd(e.source);n&&t&&t!==this.localParticipant.activeDeviceMap.get(n)&&(this.log.debug("local track restarted, setting ".concat(n," ").concat(t," active"),this.logContext),this.localParticipant.activeDeviceMap.set(n,t),this.emit(cd.ActiveDeviceChanged,n,t))}),this.onLocalConnectionQualityChanged=e=>{this.emit(cd.ConnectionQualityChanged,e,this.localParticipant)},this.onMediaDevicesError=(e,t)=>{this.emit(cd.MediaDevicesError,e,t)},this.onLocalParticipantPermissionsChanged=e=>{this.emit(cd.ParticipantPermissionsChanged,e,this.localParticipant)},this.onLocalChatMessageSent=e=>{this.emit(cd.ChatMessage,e,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},Wp),e),this.log=Ml(null!==(n=this.options.loggerName)&&void 0!==n?n:Rl.Room),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},qp),null==e?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},Hp),null==e?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},Vp),null==e?void 0:e.publishDefaults),this.maybeCreateEngine(),this.incomingDataStreamManager=new Mf,this.outgoingDataStreamManager=new jf(this.engine,this.log),this.disconnectLock=new Do,this.localParticipant=new tm("","",this.engine,this.options,this.rpcHandlers,this.outgoingDataStreamManager),(this.options.e2ee||this.options.encryption)&&this.setupE2EE(),this.engine.e2eeManager=this.e2eeManager,this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",Nh(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",Nh(this.options.audioCaptureDefaults.deviceId)),(null===(i=this.options.audioOutput)||void 0===i?void 0:i.deviceId)&&this.switchActiveDevice("audiooutput",Nh(this.options.audioOutput.deviceId)).catch(e=>this.log.warn("Could not set audio output: ".concat(e.message),this.logContext)),ph()){const e=new AbortController;null===(o=null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)||void 0===o||o.call(r,"devicechange",this.handleDeviceChange,{signal:e.signal}),rm.cleanupRegistry&&rm.cleanupRegistry.register(this,()=>{e.abort()})}}registerTextStreamHandler(e,t){return this.incomingDataStreamManager.registerTextStreamHandler(e,t)}unregisterTextStreamHandler(e){return this.incomingDataStreamManager.unregisterTextStreamHandler(e)}registerByteStreamHandler(e,t){return this.incomingDataStreamManager.registerByteStreamHandler(e,t)}unregisterByteStreamHandler(e){return this.incomingDataStreamManager.unregisterByteStreamHandler(e)}registerRpcMethod(e,t){if(this.rpcHandlers.has(e))throw Error("RPC handler already registered for method ".concat(e,", unregisterRpcMethod before trying to register again"));this.rpcHandlers.set(e,t)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}setE2EEEnabled(e){return jl(this,void 0,void 0,function*(){if(!this.e2eeManager)throw Error("e2ee not configured, please set e2ee settings within the room options");yield Promise.all([this.localParticipant.setE2EEEnabled(e)]),""!==this.localParticipant.identity&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity)})}setupE2EE(){var e;const t=!!this.options.encryption,n=this.options.encryption||this.options.e2ee;n&&("e2eeManager"in n?(this.e2eeManager=n.e2eeManager,this.e2eeManager.isDataChannelEncryptionEnabled=t):this.e2eeManager=new op(n,t),this.e2eeManager.on(Xh.ParticipantEncryptionStatusChanged,(e,t)=>{t.isLocal&&(this.isE2EEEnabled=e),this.emit(cd.ParticipantEncryptionStatusChanged,e,t)}),this.e2eeManager.on(Xh.EncryptionError,(e,t)=>{const n=t?this.getParticipantByIdentity(t):void 0;this.emit(cd.EncryptionError,e,n)}),null===(e=this.e2eeManager)||void 0===e||e.setup(this))}get logContext(){var e;return{room:this.name,roomID:null===(e=this.roomInfo)||void 0===e?void 0:e.sid,participant:this.localParticipant.identity,pID:this.localParticipant.sid}}get isRecording(){var e,t;return null!==(t=null===(e=this.roomInfo)||void 0===e?void 0:e.activeRecording)&&void 0!==t&&t}getSid(){return this.state===Qf.Disconnected?$u.resolve(""):this.roomInfo&&""!==this.roomInfo.sid?$u.resolve(this.roomInfo.sid):new $u((e,t)=>{const n=t=>{""!==t.sid&&(this.engine.off(hd.RoomUpdate,n),e(t.sid))};this.engine.on(hd.RoomUpdate,n),this.once(cd.Disconnected,()=>{this.engine.off(hd.RoomUpdate,n),t(new kd("Room disconnected before room server id was available"))})})}get name(){var e,t;return null!==(t=null===(e=this.roomInfo)||void 0===e?void 0:e.name)&&void 0!==t?t:""}get metadata(){var e;return null===(e=this.roomInfo)||void 0===e?void 0:e.metadata}get numParticipants(){var e,t;return null!==(t=null===(e=this.roomInfo)||void 0===e?void 0:e.numParticipants)&&void 0!==t?t:0}get numPublishers(){var e,t;return null!==(t=null===(e=this.roomInfo)||void 0===e?void 0:e.numPublishers)&&void 0!==t?t:0}maybeCreateEngine(){this.engine&&!this.engine.isClosed||(this.engine=new _f(this.options),this.engine.e2eeManager=this.e2eeManager,this.engine.on(hd.ParticipantUpdate,this.handleParticipantUpdates).on(hd.RoomUpdate,this.handleRoomUpdate).on(hd.SpeakersChanged,this.handleSpeakersChanged).on(hd.StreamStateChanged,this.handleStreamStateUpdate).on(hd.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(hd.SubscriptionError,this.handleSubscriptionError).on(hd.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(hd.MediaTrackAdded,(e,t,n)=>{this.onTrackAdded(e,t,n)}).on(hd.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(hd.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(hd.DataPacketReceived,this.handleDataPacket).on(hd.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.info("Resuming signal connection",this.logContext),this.setAndEmitConnectionState(Qf.SignalReconnecting)&&this.emit(cd.SignalReconnecting)}).on(hd.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.info("Resumed signal connection",this.logContext),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(Qf.Connected)&&this.emit(cd.Reconnected)}).on(hd.SignalResumed,()=>{this.bufferedEvents=[],(this.state===Qf.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(hd.Restarting,this.handleRestarting).on(hd.SignalRestarted,this.handleSignalRestarted).on(hd.Offline,()=>{this.setAndEmitConnectionState(Qf.Reconnecting)&&this.emit(cd.Reconnecting)}).on(hd.DCBufferStatusChanged,(e,t)=>{this.emit(cd.DCBufferStatusChanged,e,t)}).on(hd.LocalTrackSubscribed,e=>{const t=this.localParticipant.getTrackPublications().find(t=>{let{trackSid:n}=t;return n===e});t?(this.localParticipant.emit(ud.LocalTrackSubscribed,t),this.emitWhenConnected(cd.LocalTrackSubscribed,t,this.localParticipant)):this.log.warn("could not find local track subscription for subscribed event",this.logContext)}).on(hd.RoomMoved,e=>{this.log.debug("room moved",e),e.room&&this.handleRoomUpdate(e.room),this.remoteParticipants.forEach((e,t)=>{this.handleParticipantDisconnected(t,e)}),this.emit(cd.Moved,e.room.name),e.participant?this.handleParticipantUpdates([e.participant,...e.otherParticipants]):this.handleParticipantUpdates(e.otherParticipants)}),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine),this.outgoingDataStreamManager&&this.outgoingDataStreamManager.setupEngine(this.engine))}static getLocalDevices(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return cp.getInstance().getDevices(e,t)}prepareConnection(e,t){return jl(this,void 0,void 0,function*(){if(this.state===Qf.Disconnected){this.log.debug("prepareConnection to ".concat(e),this.logContext);try{if(mh(new URL(e))&&t){this.regionUrlProvider=new Qp(e,t);const n=yield this.regionUrlProvider.getNextBestRegionUrl();n&&this.state===Qf.Disconnected&&(this.regionUrl=n,yield fetch(Oh(n),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(n),this.logContext))}else yield fetch(Oh(e),{method:"HEAD"})}catch(n){this.log.warn("could not prepare connection",Object.assign(Object.assign({},this.logContext),{error:n}))}}})}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,t){return jl(this,void 0,void 0,function*(){let n,i=()=>jl(this,void 0,void 0,function*(){});switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"speaker":n=new sl({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":n=new sl({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":n=new sl({scenario:{case:"serverLeave",value:!0}});break;case"migration":n=new sl({scenario:{case:"migration",value:!0}});break;case"resume-reconnect":this.engine.failNext(),yield this.engine.client.handleOnClose("simulate resume-disconnect");break;case"disconnect-signal-on-resume":i=()=>jl(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),n=new sl({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":i=()=>jl(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),n=new sl({scenario:{case:"disconnectSignalOnResumeNoMessages",value:!0}});break;case"full-reconnect":this.engine.fullReconnectOnNext=!0,yield this.engine.client.handleOnClose("simulate full-reconnect");break;case"force-tcp":case"force-tls":n=new sl({scenario:{case:"switchCandidateProtocol",value:"force-tls"===e?2:1}}),i=()=>jl(this,void 0,void 0,function*(){const e=this.engine.client.onLeave;e&&e(new Fc({reason:Ps.CLIENT_INITIATED,action:Bc.RECONNECT}))});break;case"subscriber-bandwidth":if(void 0===t||"number"!=typeof t)throw new Error("subscriber-bandwidth requires a number as argument");n=new sl({scenario:{case:"subscriberBandwidth",value:Lh(t)}});break;case"leave-full-reconnect":n=new sl({scenario:{case:"leaveRequestFullReconnect",value:!0}})}n&&(yield this.engine.client.sendSimulateScenario(n),yield i())})}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(e,t){return jl(this,arguments,void 0,function(e,t){var n=this;let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function*(){var r,o,a,s,c,l,u;let d=!0,h=!1;const p=i?{exact:t}:t;if("audioinput"===e){h=0===n.localParticipant.audioTrackPublications.size;const t=null!==(r=n.getActiveDevice(e))&&void 0!==r?r:n.options.audioCaptureDefaults.deviceId;n.options.audioCaptureDefaults.deviceId=p;const i=Array.from(n.localParticipant.audioTrackPublications.values()).filter(e=>e.source===Zd.Source.Microphone);try{d=(yield Promise.all(i.map(e=>{var t;return null===(t=e.audioTrack)||void 0===t?void 0:t.setDeviceId(p)}))).every(e=>!0===e)}catch(f){throw n.options.audioCaptureDefaults.deviceId=t,f}const o=i.some(e=>{var t,n;return null!==(n=null===(t=e.track)||void 0===t?void 0:t.isMuted)&&void 0!==n&&n});d&&o&&(h=!0)}else if("videoinput"===e){h=0===n.localParticipant.videoTrackPublications.size;const t=null!==(o=n.getActiveDevice(e))&&void 0!==o?o:n.options.videoCaptureDefaults.deviceId;n.options.videoCaptureDefaults.deviceId=p;const i=Array.from(n.localParticipant.videoTrackPublications.values()).filter(e=>e.source===Zd.Source.Camera);try{d=(yield Promise.all(i.map(e=>{var t;return null===(t=e.videoTrack)||void 0===t?void 0:t.setDeviceId(p)}))).every(e=>!0===e)}catch(f){throw n.options.videoCaptureDefaults.deviceId=t,f}const r=i.some(e=>{var t,n;return null!==(n=null===(t=e.track)||void 0===t?void 0:t.isMuted)&&void 0!==n&&n});d&&r&&(h=!0)}else if("audiooutput"===e){if(h=!0,!sh()&&!n.options.webAudioMix||n.options.webAudioMix&&n.audioContext&&!("setSinkId"in n.audioContext))throw new Error("cannot switch audio output, the current browser does not support it");n.options.webAudioMix&&(t=null!==(a=yield cp.getInstance().normalizeDeviceId("audiooutput",t))&&void 0!==a?a:""),null!==(s=(u=n.options).audioOutput)&&void 0!==s||(u.audioOutput={});const i=null!==(c=n.getActiveDevice(e))&&void 0!==c?c:n.options.audioOutput.deviceId;n.options.audioOutput.deviceId=t;try{n.options.webAudioMix&&(null===(l=n.audioContext)||void 0===l||l.setSinkId(t)),yield Promise.all(Array.from(n.remoteParticipants.values()).map(e=>e.setAudioOutput({deviceId:t})))}catch(f){throw n.options.audioOutput.deviceId=i,f}}return h&&(n.localParticipant.activeDeviceMap.set(e,t),n.emit(cd.ActiveDeviceChanged,e,t)),d}()})}setupLocalParticipantEvents(){this.localParticipant.on(ud.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(ud.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(ud.AttributesChanged,this.onLocalAttributesChanged).on(ud.TrackMuted,this.onLocalTrackMuted).on(ud.TrackUnmuted,this.onLocalTrackUnmuted).on(ud.LocalTrackPublished,this.onLocalTrackPublished).on(ud.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(ud.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(ud.MediaDevicesError,this.onMediaDevicesError).on(ud.AudioStreamAcquired,this.startAudio).on(ud.ChatMessage,this.onLocalChatMessageSent).on(ud.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(){var e;null===(e=this.engine)||void 0===e||e.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(e,t,n){if(this.state===Qf.Connecting||this.state===Qf.Reconnecting){const i=()=>{this.log.debug("deferring on track for later",{mediaTrackId:e.id,mediaStreamId:t.id,tracksInStream:t.getTracks().map(e=>e.id)}),this.onTrackAdded(e,t,n),r()},r=()=>{this.off(cd.Reconnected,i),this.off(cd.Connected,i),this.off(cd.Disconnected,r)};return this.once(cd.Reconnected,i),this.once(cd.Connected,i),void this.once(cd.Disconnected,r)}if(this.state===Qf.Disconnected)return void this.log.warn("skipping incoming track after Room disconnected",this.logContext);if("ended"===e.readyState)return void this.log.info("skipping incoming track as it already ended",this.logContext);const i=function(e){const t=e.split("|");return t.length>1?[t[0],e.substr(t[0].length+1)]:[e,""]}(t.id),r=i[0];let o=i[1],a=e.id;if(o&&o.startsWith("TR")&&(a=o),r===this.localParticipant.sid)return void this.log.warn("tried to create RemoteParticipant for local participant",this.logContext);const s=Array.from(this.remoteParticipants.values()).find(e=>e.sid===r);if(!s)return void this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(r),this.logContext);if(!a.startsWith("TR")){const e=this.engine.getTrackIdForReceiver(n);if(!e)return void this.log.error("Tried to add a track whose 'sid' could not be found for a participant, that's not present. Sid: ".concat(r),this.logContext);a=e}let c;a.startsWith("TR")||this.log.warn("Tried to add a track whose 'sid' could not be determined for a participant, that's not present. Sid: ".concat(r,", streamId: ").concat(o,", trackId: ").concat(a),Object.assign(Object.assign({},this.logContext),{rpID:r,streamId:o,trackId:a})),this.options.adaptiveStream&&(c="object"==typeof this.options.adaptiveStream?this.options.adaptiveStream:{});const l=s.addSubscribedMediaTrack(e,a,t,n,c);(null==l?void 0:l.isEncrypted)&&!this.e2eeManager&&this.emit(cd.EncryptionError,new Error("Encrypted ".concat(l.source," track received from participant ").concat(s.sid,", but room does not have encryption enabled!")))}handleDisconnect(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1?arguments[1]:void 0;var n,i;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.incomingDataStreamManager.clearControllers(),this.state!==Qf.Disconnected){this.regionUrl=void 0,this.regionUrlProvider&&this.regionUrlProvider.notifyDisconnected();try{this.remoteParticipants.forEach(e=>{e.trackPublications.forEach(t=>{e.unpublishTrack(t.trackSid)})}),this.localParticipant.trackPublications.forEach(t=>{var n,i,r;t.track&&this.localParticipant.unpublishTrack(t.track,e),e?(null===(n=t.track)||void 0===n||n.detach(),null===(i=t.track)||void 0===i||i.stop()):null===(r=t.track)||void 0===r||r.stopMonitor()}),this.localParticipant.off(ud.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(ud.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(ud.AttributesChanged,this.onLocalAttributesChanged).off(ud.TrackMuted,this.onLocalTrackMuted).off(ud.TrackUnmuted,this.onLocalTrackUnmuted).off(ud.LocalTrackPublished,this.onLocalTrackPublished).off(ud.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(ud.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(ud.MediaDevicesError,this.onMediaDevicesError).off(ud.AudioStreamAcquired,this.startAudio).off(ud.ChatMessage,this.onLocalChatMessageSent).off(ud.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.trackPublications.clear(),this.localParticipant.videoTrackPublications.clear(),this.localParticipant.audioTrackPublications.clear(),this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.activeSpeakers=[],this.audioContext&&"boolean"==typeof this.options.webAudioMix&&(this.audioContext.close(),this.audioContext=void 0),ph()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),null===(i=null===(n=navigator.mediaDevices)||void 0===n?void 0:n.removeEventListener)||void 0===i||i.call(n,"devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(Qf.Disconnected),this.emit(cd.Disconnected,t)}}}handleParticipantDisconnected(e,t){var n;this.remoteParticipants.delete(e),t&&(this.incomingDataStreamManager.validateParticipantHasNoActiveDataStreams(e),t.trackPublications.forEach(e=>{t.unpublishTrack(e.trackSid,!0)}),this.emit(cd.ParticipantDisconnected,t),t.setDisconnected(),null===(n=this.localParticipant)||void 0===n||n.handleParticipantDisconnected(t.identity))}handleIncomingRpcRequest(e,t,n,i,r,o){return jl(this,void 0,void 0,function*(){if(yield this.engine.publishRpcAck(e,t),1!==o)return void(yield this.engine.publishRpcResponse(e,t,null,Yp.builtIn("UNSUPPORTED_VERSION")));const a=this.rpcHandlers.get(n);if(!a)return void(yield this.engine.publishRpcResponse(e,t,null,Yp.builtIn("UNSUPPORTED_METHOD")));let s=null,c=null;try{const o=yield a({requestId:t,callerIdentity:e,payload:i,responseTimeout:r});Xp(o)>15360?(s=Yp.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"),this.log.warn("RPC Response payload too large for ".concat(n))):c=o}catch(l){l instanceof Yp?s=l:(this.log.warn("Uncaught error returned by RPC handler for ".concat(n,". Returning APPLICATION_ERROR instead."),l),s=Yp.builtIn("APPLICATION_ERROR"))}yield this.engine.publishRpcResponse(e,t,c,s)})}selectDefaultDevices(){return jl(this,void 0,void 0,function*(){var e,t,n;const i=cp.getInstance().previousDevices,r=yield cp.getInstance().getDevices(void 0,!1),o=Yu();if("Chrome"===(null==o?void 0:o.name)&&"iOS"!==o.os)for(let s of r){const e=i.find(e=>e.deviceId===s.deviceId);e&&""!==e.label&&e.kind===s.kind&&e.label!==s.label&&"default"===this.getActiveDevice(s.kind)&&this.emit(cd.ActiveDeviceChanged,s.kind,s.deviceId)}const a=["audiooutput","audioinput","videoinput"];for(let s of a){const o=qd(s),a=this.localParticipant.getTrackPublication(o);if(a&&(null===(e=a.track)||void 0===e?void 0:e.isUserProvided))continue;const c=r.filter(e=>e.kind===s),l=this.getActiveDevice(s);l===(null===(t=i.filter(e=>e.kind===s)[0])||void 0===t?void 0:t.deviceId)&&c.length>0&&(null===(n=c[0])||void 0===n?void 0:n.deviceId)!==l?yield this.switchActiveDevice(s,c[0].deviceId):"audioinput"===s&&!dh()||"videoinput"===s||!(c.length>0)||c.find(e=>e.deviceId===this.getActiveDevice(s))||"audiooutput"===s&&dh()||(yield this.switchActiveDevice(s,c[0].deviceId))}})}acquireAudioContext(){return jl(this,void 0,void 0,function*(){var e,t;if("boolean"!=typeof this.options.webAudioMix&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:this.audioContext&&"closed"!==this.audioContext.state||(this.audioContext=null!==(e=Vd())&&void 0!==e?e:void 0),this.options.webAudioMix&&this.remoteParticipants.forEach(e=>e.setAudioContext(this.audioContext)),this.localParticipant.setAudioContext(this.audioContext),this.audioContext&&"suspended"===this.audioContext.state)try{yield Promise.race([this.audioContext.resume(),ih(200)])}catch(i){this.log.warn("Could not resume audio context",Object.assign(Object.assign({},this.logContext),{error:i}))}const n="running"===(null===(t=this.audioContext)||void 0===t?void 0:t.state);n!==this.canPlaybackAudio&&(this.audioEnabled=n,this.emit(cd.AudioPlaybackStatusChanged,n))})}createParticipant(e,t){var n;let i;return i=t?im.fromParticipantInfo(this.engine.client,t,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}):new im(this.engine.client,"",e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&i.setAudioContext(this.audioContext),(null===(n=this.options.audioOutput)||void 0===n?void 0:n.deviceId)&&i.setAudioOutput(this.options.audioOutput).catch(e=>this.log.warn("Could not set audio output: ".concat(e.message),this.logContext)),i}getOrCreateParticipant(e,t){if(this.remoteParticipants.has(e)){const n=this.remoteParticipants.get(e);if(t){n.updateInfo(t)&&this.sidToIdentity.set(t.sid,t.identity)}return n}const n=this.createParticipant(e,t);return this.remoteParticipants.set(e,n),this.sidToIdentity.set(t.sid,t.identity),this.emitWhenConnected(cd.ParticipantConnected,n),n.on(ud.TrackPublished,e=>{this.emitWhenConnected(cd.TrackPublished,e,n)}).on(ud.TrackSubscribed,(e,t)=>{e.kind===Zd.Kind.Audio?(e.on(fd.AudioPlaybackStarted,this.handleAudioPlaybackStarted),e.on(fd.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):e.kind===Zd.Kind.Video&&(e.on(fd.VideoPlaybackFailed,this.handleVideoPlaybackFailed),e.on(fd.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emit(cd.TrackSubscribed,e,t,n)}).on(ud.TrackUnpublished,e=>{this.emit(cd.TrackUnpublished,e,n)}).on(ud.TrackUnsubscribed,(e,t)=>{this.emit(cd.TrackUnsubscribed,e,t,n)}).on(ud.TrackMuted,e=>{this.emitWhenConnected(cd.TrackMuted,e,n)}).on(ud.TrackUnmuted,e=>{this.emitWhenConnected(cd.TrackUnmuted,e,n)}).on(ud.ParticipantMetadataChanged,e=>{this.emitWhenConnected(cd.ParticipantMetadataChanged,e,n)}).on(ud.ParticipantNameChanged,e=>{this.emitWhenConnected(cd.ParticipantNameChanged,e,n)}).on(ud.AttributesChanged,e=>{this.emitWhenConnected(cd.ParticipantAttributesChanged,e,n)}).on(ud.ConnectionQualityChanged,e=>{this.emitWhenConnected(cd.ConnectionQualityChanged,e,n)}).on(ud.ParticipantPermissionsChanged,e=>{this.emitWhenConnected(cd.ParticipantPermissionsChanged,e,n)}).on(ud.TrackSubscriptionStatusChanged,(e,t)=>{this.emitWhenConnected(cd.TrackSubscriptionStatusChanged,e,t,n)}).on(ud.TrackSubscriptionFailed,(e,t)=>{this.emit(cd.TrackSubscriptionFailed,e,n,t)}).on(ud.TrackSubscriptionPermissionChanged,(e,t)=>{this.emitWhenConnected(cd.TrackSubscriptionPermissionChanged,e,t,n)}).on(ud.Active,()=>{this.emitWhenConnected(cd.ParticipantActive,n),n.kind===As.AGENT&&this.localParticipant.setActiveAgent(n)}),t&&n.updateInfo(t),n}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce((e,t)=>(e.push(...t.getTrackPublications()),e),[]),t=this.localParticipant.getTrackPublications();this.engine.sendSyncState(e,t)}updateSubscriptions(){for(const e of this.remoteParticipants.values())for(const t of e.videoTrackPublications.values())t.isSubscribed&&Vh(t)&&t.emitTrackUpdate()}getRemoteParticipantBySid(e){const t=this.sidToIdentity.get(e);if(t)return this.remoteParticipants.get(t)}registerConnectionReconcile(){this.clearConnectionReconcile();let e=0;this.connectionReconcileInterval=xd.setInterval(()=>{this.engine&&!this.engine.isClosed&&this.engine.verifyTransport()?e=0:(e++,this.log.warn("detected connection state mismatch",Object.assign(Object.assign({},this.logContext),{numFailures:e,engine:this.engine?{closed:this.engine.isClosed,transportsConnected:this.engine.verifyTransport()}:void 0})),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,Ps.STATE_MISMATCH)))},4e3)}clearConnectionReconcile(){this.connectionReconcileInterval&&xd.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e!==this.state&&(this.state=e,this.emit(cd.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let[t,n]=e;this.emit(t,...n)}),this.bufferedEvents=[]}emitWhenConnected(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(this.state===Qf.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,n]);else if(this.state===Qf.Connected)return this.emit(e,...n);return!1}simulateParticipants(e){return jl(this,void 0,void 0,function*(){var t,n,i,r;const o=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),a=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new Ns({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:na.parse((new Date).getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new Ds({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(cd.SignalConnected),this.emit(cd.Connected),this.setAndEmitConnectionState(Qf.Connected),o.video){const e=new Xf(Zd.Kind.Video,new Bs({source:Ts.CAMERA,sid:Math.floor(1e4*Math.random()).toString(),type:Cs.AUDIO,name:"video-dummy"}),new bf(o.useRealTracks&&(null===(t=window.navigator.mediaDevices)||void 0===t?void 0:t.getUserMedia)?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:Ph(160*(null!==(n=a.aspectRatios[0])&&void 0!==n?n:1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(e),this.localParticipant.emit(ud.LocalTrackPublished,e)}if(o.audio){const e=new Xf(Zd.Kind.Audio,new Bs({source:Ts.MICROPHONE,sid:Math.floor(1e4*Math.random()).toString(),type:Cs.AUDIO}),new sf(o.useRealTracks&&(null===(i=navigator.mediaDevices)||void 0===i?void 0:i.getUserMedia)?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:Rh(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(e),this.localParticipant.emit(ud.LocalTrackPublished,e)}for(let e=0;e<a.count-1;e+=1){let t=new Ds({sid:Math.floor(1e4*Math.random()).toString(),identity:"simulated-".concat(e),state:Ls.ACTIVE,tracks:[],joinedAt:na.parse(Date.now())});const n=this.getOrCreateParticipant(t.identity,t);if(a.video){const i=Ph(160*(null!==(r=a.aspectRatios[e%a.aspectRatios.length])&&void 0!==r?r:1),160,!1,!0),o=new Bs({source:Ts.CAMERA,sid:Math.floor(1e4*Math.random()).toString(),type:Cs.AUDIO});n.addSubscribedMediaTrack(i,o.sid,new MediaStream([i]),new RTCRtpReceiver),t.tracks=[...t.tracks,o]}if(a.audio){const e=Rh(),i=new Bs({source:Ts.MICROPHONE,sid:Math.floor(1e4*Math.random()).toString(),type:Cs.AUDIO});n.addSubscribedMediaTrack(e,i.sid,new MediaStream([e]),new RTCRtpReceiver),t.tracks=[...t.tracks,i]}n.updateInfo(t)}})}emit(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(e!==cd.ActiveSpeakersChanged&&e!==cd.TranscriptionReceived){const t=om(n).filter(e=>void 0!==e);e!==cd.TrackSubscribed&&e!==cd.TrackUnsubscribed||this.log.trace("subscribe trace: ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:t})),this.log.debug("room event ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:t}))}return super.emit(e,...n)}}function om(e){return e.map(e=>{if(e)return Array.isArray(e)?om(e):"object"==typeof e?"logContext"in e?e.logContext:void 0:e})}var am,sm;rm.cleanupRegistry="undefined"!=typeof FinalizationRegistry&&new FinalizationRegistry(e=>{e()}),(sm=am||(am={}))[sm.IDLE=0]="IDLE",sm[sm.RUNNING=1]="RUNNING",sm[sm.SKIPPED=2]="SKIPPED",sm[sm.SUCCESS=3]="SUCCESS",sm[sm.FAILED=4]="FAILED";Vl.EventEmitter;Vl.EventEmitter;function cm(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new TextEncoder,new TextDecoder;class lm extends Error{constructor(e,t){var n;super(e,t),cm(this,"code","ERR_JOSE_GENERIC"),this.name=this.constructor.name,null===(n=Error.captureStackTrace)||void 0===n||n.call(Error,this,this.constructor)}}cm(lm,"code","ERR_JOSE_GENERIC");cm(class extends lm{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:i,payload:t}}),cm(this,"code","ERR_JWT_CLAIM_VALIDATION_FAILED"),cm(this,"claim",void 0),cm(this,"reason",void 0),cm(this,"payload",void 0),this.claim=n,this.reason=i,this.payload=t}},"code","ERR_JWT_CLAIM_VALIDATION_FAILED");cm(class extends lm{constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"unspecified",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unspecified";super(e,{cause:{claim:n,reason:i,payload:t}}),cm(this,"code","ERR_JWT_EXPIRED"),cm(this,"claim",void 0),cm(this,"reason",void 0),cm(this,"payload",void 0),this.claim=n,this.reason=i,this.payload=t}},"code","ERR_JWT_EXPIRED");cm(class extends lm{constructor(){super(...arguments),cm(this,"code","ERR_JOSE_ALG_NOT_ALLOWED")}},"code","ERR_JOSE_ALG_NOT_ALLOWED");cm(class extends lm{constructor(){super(...arguments),cm(this,"code","ERR_JOSE_NOT_SUPPORTED")}},"code","ERR_JOSE_NOT_SUPPORTED");cm(class extends lm{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"decryption operation failed",arguments.length>1?arguments[1]:void 0),cm(this,"code","ERR_JWE_DECRYPTION_FAILED")}},"code","ERR_JWE_DECRYPTION_FAILED");cm(class extends lm{constructor(){super(...arguments),cm(this,"code","ERR_JWE_INVALID")}},"code","ERR_JWE_INVALID");cm(class extends lm{constructor(){super(...arguments),cm(this,"code","ERR_JWS_INVALID")}},"code","ERR_JWS_INVALID");cm(class extends lm{constructor(){super(...arguments),cm(this,"code","ERR_JWT_INVALID")}},"code","ERR_JWT_INVALID");cm(class extends lm{constructor(){super(...arguments),cm(this,"code","ERR_JWK_INVALID")}},"code","ERR_JWK_INVALID");cm(class extends lm{constructor(){super(...arguments),cm(this,"code","ERR_JWKS_INVALID")}},"code","ERR_JWKS_INVALID");cm(class extends lm{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"no applicable key found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),cm(this,"code","ERR_JWKS_NO_MATCHING_KEY")}},"code","ERR_JWKS_NO_MATCHING_KEY");cm(class extends lm{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"multiple matching keys found in the JSON Web Key Set",arguments.length>1?arguments[1]:void 0),cm(this,Symbol.asyncIterator,void 0),cm(this,"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS")}},"code","ERR_JWKS_MULTIPLE_MATCHING_KEYS");cm(class extends lm{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"request timed out",arguments.length>1?arguments[1]:void 0),cm(this,"code","ERR_JWKS_TIMEOUT")}},"code","ERR_JWKS_TIMEOUT");cm(class extends lm{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"signature verification failed",arguments.length>1?arguments[1]:void 0),cm(this,"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED")}},"code","ERR_JWS_SIGNATURE_VERIFICATION_FAILED");const um="_container_1p2zy_1",dm="_orbContainer_1p2zy_11",hm="_status_1p2zy_22",pm="_instruction_1p2zy_34",fm="_controls_1p2zy_47",mm="_controlButton_1p2zy_58",gm="_muted_1p2zy_86",vm="_backButton_1p2zy_95",ym=({tokenUrl:e,agentName:t="voice-agent",onClose:n})=>{const i=u.useRef(null),[r,o]=u.useState(""),[a,s]=u.useState(!1),[c,l]=u.useState(!1),[d,h]=u.useState(!1),p=u.useRef(null),f=u.useRef(null),m=u.useRef(null),g=u.useRef(null),v=u.useRef(null),y=u.useRef(null),b=u.useRef(null),k=u.useRef(0),S=u.useRef(null),C=u.useRef(!1),T=u.useRef(0),w=u.useRef(0),E=u.useRef(null),x=u.useCallback(()=>{let e=0,t=0;if(g.current&&y.current){g.current.getByteFrequencyData(y.current);e=y.current.reduce((e,t)=>e+t,0)/y.current.length/255}if(v.current&&b.current){v.current.getByteFrequencyData(b.current);t=b.current.reduce((e,t)=>e+t,0)/b.current.length/255}const n=Math.max(e,t);return k.current+=.25*(n-k.current),k.current},[]),P=async e=>{m.current||(m.current=new(window.AudioContext||window.webkitAudioContext)),"suspended"===m.current.state&&await m.current.resume();try{const t=new MediaStream([e.mediaStreamTrack]),n=m.current.createMediaStreamSource(t);g.current=m.current.createAnalyser(),g.current.fftSize=256,n.connect(g.current),y.current=new Uint8Array(g.current.frequencyBinCount)}catch(t){console.error("Failed to set up local audio analyser:",t)}};u.useEffect(()=>{if(C.current)return;const e=e=>new Promise((t,n)=>{if(e.includes("three")&&window.THREE)return void t();if(e.includes("gsap")&&window.gsap)return void t();const i=document.createElement("script");i.src=e,i.onload=()=>t(),i.onerror=n,document.head.appendChild(i)});(async()=>{try{if(await e("https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"),await e("https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"),!i.current||!window.THREE)return;C.current=!0;const t=window.THREE,n=i.current,r=new t.Scene,o=n.clientWidth,a=n.clientHeight,s=new t.PerspectiveCamera(75,o/a,.1,1e3),c=new t.WebGLRenderer({antialias:!0,alpha:!0});E.current=c,c.setSize(o,a),c.setPixelRatio(Math.min(window.devicePixelRatio,2)),n.appendChild(c.domElement),s.position.z=300;const l=12e3,u=new Float32Array(3*l),d=new Float32Array(3*l),h=new Float32Array(l),p=new Float32Array(3*l),m=new Float32Array(3*l),g=50,v=22,y=60;for(let e=0;e<l;e++){const t=Math.random()*Math.PI*2,n=Math.random()*Math.PI*2,i=v*Math.sqrt(Math.random());p[3*e]=(g+i*Math.cos(n))*Math.cos(t),p[3*e+1]=(g+i*Math.cos(n))*Math.sin(t),p[3*e+2]=i*Math.sin(n);const r=y*Math.cbrt(Math.random()),o=Math.random()*Math.PI*2,a=Math.acos(2*Math.random()-1);m[3*e]=r*Math.sin(a)*Math.cos(o),m[3*e+1]=r*Math.sin(a)*Math.sin(o),m[3*e+2]=r*Math.cos(a),u[3*e]=p[3*e],u[3*e+1]=p[3*e+1],u[3*e+2]=p[3*e+2];const s=.8+.2*Math.random();d[3*e]=s,d[3*e+1]=s,d[3*e+2]=s,h[e]=1.4+1*Math.random()}const b=new t.BufferGeometry;b.setAttribute("position",new t.BufferAttribute(u,3)),b.setAttribute("torusPos",new t.BufferAttribute(p,3)),b.setAttribute("spherePos",new t.BufferAttribute(m,3)),b.setAttribute("color",new t.BufferAttribute(d,3)),b.setAttribute("size",new t.BufferAttribute(h,1));const k=new t.ShaderMaterial({uniforms:{time:{value:0},mouse:{value:new t.Vector3(9999,9999,0)},hoverRadius:{value:35},hoverStrength:{value:30},audioAmplitude:{value:0},audioExpansion:{value:100},isConnected:{value:0}},vertexShader:"\n attribute float size;\n attribute vec3 color;\n attribute vec3 torusPos;\n attribute vec3 spherePos;\n varying vec3 vColor;\n uniform float time;\n uniform vec3 mouse;\n uniform float hoverRadius;\n uniform float hoverStrength;\n uniform float audioAmplitude;\n uniform float audioExpansion;\n uniform float isConnected;\n \n float hash(vec3 p) {\n p = fract(p * 0.3183099 + 0.1);\n p *= 17.0;\n return fract(p.x * p.y * p.z * (p.x + p.y + p.z));\n }\n \n float noise(vec3 p) {\n vec3 i = floor(p);\n vec3 f = fract(p);\n f = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(mix(hash(i), hash(i + vec3(1,0,0)), f.x),\n mix(hash(i + vec3(0,1,0)), hash(i + vec3(1,1,0)), f.x), f.y),\n mix(mix(hash(i + vec3(0,0,1)), hash(i + vec3(1,0,1)), f.x),\n mix(hash(i + vec3(0,1,1)), hash(i + vec3(1,1,1)), f.x), f.y), f.z);\n }\n \n void main() {\n vec3 disconnectedColor = vec3(0.7, 0.85, 0.87);\n vec3 connectedColor = color;\n vColor = mix(disconnectedColor, connectedColor, isConnected);\n \n vec3 basePos = mix(torusPos, spherePos, isConnected);\n vec3 pos = basePos;\n \n float distFromCenter = length(basePos);\n vec3 dirFromCenter = normalize(basePos);\n float audioNoise = noise(basePos * 0.02 + time * 2.0);\n float expansion = audioAmplitude * audioExpansion * (0.5 + audioNoise);\n pos += dirFromCenter * expansion;\n \n float turbulence = audioAmplitude * 40.0;\n pos.x += sin(time * 3.0 + position.y * 0.05) * turbulence * audioNoise;\n pos.y += cos(time * 3.0 + position.x * 0.05) * turbulence * audioNoise;\n pos.z += sin(time * 2.0 + position.z * 0.05) * turbulence * audioNoise;\n \n vec3 toMouse = pos - mouse;\n float dist = length(toMouse);\n \n float noiseVal = noise(basePos * 0.05 + time * 0.5);\n float featheredRadius = hoverRadius * (0.6 + noiseVal * 0.8);\n \n if (dist < featheredRadius && dist > 0.0) {\n vec3 pushDir = normalize(toMouse);\n float falloff = 1.0 - smoothstep(0.0, featheredRadius, dist);\n falloff = pow(falloff, 0.5);\n \n float angleNoise = noise(basePos * 0.1 + time) * 2.0 - 1.0;\n pushDir.x += angleNoise * 0.3;\n pushDir.y += noise(basePos * 0.1 - time) * 0.3 - 0.15;\n pushDir = normalize(pushDir);\n \n float pushAmount = falloff * hoverStrength * (0.7 + noiseVal * 0.6);\n pos += pushDir * pushAmount;\n }\n \n float flowSpeed = 0.3;\n float swirl = time * flowSpeed;\n \n float angle = atan(basePos.z, basePos.x);\n float flowOffset = sin(swirl + angle * 2.0) * 4.0;\n \n float torusFlow = 1.0 - isConnected;\n \n pos.x += sin(time * 0.5 + basePos.y * 0.02 + angle) * 3.0 * torusFlow;\n pos.z += cos(time * 0.5 + basePos.y * 0.02 + angle) * 3.0 * torusFlow;\n pos.y += flowOffset * torusFlow;\n \n pos.x += sin(time * 0.8 + basePos.y * 0.05) * 2.0;\n pos.y += cos(time * 0.6 + basePos.x * 0.03) * 2.0;\n pos.z += sin(time * 0.7 + basePos.z * 0.04) * 2.0;\n \n vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);\n float sizeBoost = 1.0 + audioAmplitude * 0.5;\n gl_PointSize = size * sizeBoost * (200.0 / -mvPosition.z);\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n varying vec3 vColor;\n \n void main() {\n float dist = length(gl_PointCoord - vec2(0.5));\n if (dist > 0.5) discard;\n \n float alpha = 1.0 - smoothstep(0.3, 0.5, dist);\n gl_FragColor = vec4(vColor, alpha);\n }\n ",transparent:!0,depthWrite:!1,blending:t.AdditiveBlending});S.current=k;const P=new t.Points(b,k);r.add(P);const _=new t.Vector2,R=new t.Vector3,I=new t.Matrix4,N=e=>{const t=n.getBoundingClientRect();_.x=(e.clientX-t.left)/t.width*2-1,_.y=-(e.clientY-t.top)/t.height*2+1,R.set(_.x,_.y,.5),R.unproject(s);const i=R.sub(s.position).normalize(),r=-s.position.z/i.z,o=s.position.clone().add(i.multiplyScalar(r));I.copy(P.matrixWorld).invert(),o.applyMatrix4(I),k.uniforms.mouse.value.copy(o)},O=()=>{k.uniforms.mouse.value.set(9999,9999,0)};n.addEventListener("mousemove",N),n.addEventListener("mouseleave",O);const M=new ResizeObserver(()=>{const e=n.clientWidth,t=n.clientHeight;s.aspect=e/t,s.updateProjectionMatrix(),c.setSize(e,t)});M.observe(n);let D=0;const L=()=>{f.current=requestAnimationFrame(L),D+=.01,k.uniforms.time.value=D;const e=x();k.uniforms.audioAmplitude.value=e,w.current+=.05*(T.current-w.current),k.uniforms.isConnected.value=w.current,P.updateMatrixWorld(),c.render(r,s)};return L(),()=>{n.removeEventListener("mousemove",N),n.removeEventListener("mouseleave",O),M.disconnect(),f.current&&cancelAnimationFrame(f.current),c.dispose()}}catch(t){console.error("Failed to initialize scene:",t)}})()},[x]);const _=async()=>{if(!c){l(!0),o(""),m.current||(m.current=new(window.AudioContext||window.webkitAudioContext)),"suspended"===m.current.state&&await m.current.resume();try{const n={};t&&t.trim()&&(n.room_config={agents:[{agentName:t.trim()}]});const i=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),r=await i.json(),a=new rm({adaptiveStream:!0,dynacast:!0});p.current=a,a.on(cd.Connected,()=>{o(""),s(!0),l(!1),T.current=1}),a.on(cd.Disconnected,()=>{document.querySelectorAll("audio").forEach(e=>{e.pause(),e.srcObject=null,e.remove()}),o(""),s(!1),l(!1),g.current=null,v.current=null,y.current=null,b.current=null,k.current=0,T.current=0}),a.on(cd.ParticipantConnected,()=>{o("")}),a.on(cd.TrackSubscribed,(e,t,n)=>{e.kind===Zd.Kind.Audio&&((async e=>{m.current||(m.current=new(window.AudioContext||window.webkitAudioContext)),"suspended"===m.current.state&&await m.current.resume();const t=e.attach();t.style.display="none",t.autoplay=!0,t.setAttribute("playsinline","true"),document.body.appendChild(t);try{await t.play()}catch{console.log("Audio play failed, will retry on interaction")}const n=new MediaStream([e.mediaStreamTrack]),i=m.current.createMediaStreamSource(n);v.current=m.current.createAnalyser(),v.current.fftSize=256,i.connect(v.current),b.current=new Uint8Array(v.current.frequencyBinCount)})(e),o(""))}),a.on(cd.LocalTrackPublished,e=>{e.track&&e.track.kind===Zd.Kind.Audio&&P(e.track)}),await a.connect(r.server_url,r.participant_token),await a.localParticipant.setMicrophoneEnabled(!0);a.localParticipant.audioTrackPublications.forEach(e=>{e.track&&P(e.track)})}catch(n){console.error("Connection failed:",n),o("Connection failed"),l(!1)}}},I=async()=>{if(p.current){try{await p.current.localParticipant.setMicrophoneEnabled(!1)}catch{}p.current.disconnect(!0),p.current=null}document.querySelectorAll("audio").forEach(e=>{e.pause(),e.srcObject=null,e.remove()}),g.current=null,v.current=null,y.current=null,b.current=null,k.current=0,s(!1),h(!1),o(""),T.current=0,n()};return u.useEffect(()=>()=>{p.current&&(p.current.disconnect(!0),p.current=null),f.current&&cancelAnimationFrame(f.current),E.current&&E.current.dispose();document.querySelectorAll("audio").forEach(e=>{e.pause(),e.srcObject=null,e.remove()})},[]),R.jsxs("div",{className:um,children:[r&&R.jsx("div",{className:hm,children:r}),R.jsx("div",{ref:i,className:dm,onClick:()=>{a?I():c||_()}}),R.jsx("div",{className:pm,children:c?"Connecting...":a?"Tap orb to end call":"Tap orb to start"}),R.jsxs("div",{className:fm,children:[a&&R.jsx("button",{onClick:async e=>{if(e.stopPropagation(),p.current){const e=!d;await p.current.localParticipant.setMicrophoneEnabled(!e),h(e),e||setTimeout(()=>{if(p.current){p.current.localParticipant.audioTrackPublications.forEach(e=>{e.track&&P(e.track)})}},100)}},className:`${mm} ${d?gm:""}`,title:d?"Unmute microphone":"Mute microphone",type:"button",children:d?R.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:R.jsx("path",{d:"M19 11h-1.7c0 .74-.16 1.43-.43 2.05l1.23 1.23c.56-.98.9-2.09.9-3.28zm-4.02.17c0-.06.02-.11.02-.17V5c0-1.66-1.34-3-3-3S9 3.34 9 5v.18l5.98 5.99zM4.27 3L3 4.27l6.01 6.01V11c0 1.66 1.33 3 2.99 3 .22 0 .44-.03.65-.08l1.66 1.66c-.71.33-1.5.52-2.31.52-2.76 0-5.3-2.1-5.3-5.1H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c.91-.13 1.77-.45 2.54-.9L19.73 21 21 19.73 4.27 3z"})}):R.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",children:[R.jsx("path",{d:"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3z"}),R.jsx("path",{d:"M17 11c0 2.76-2.24 5-5 5s-5-2.24-5-5H5c0 3.53 2.61 6.43 6 6.92V21h2v-3.08c3.39-.49 6-3.39 6-6.92h-2z"})]})}),R.jsx("button",{onClick:I,className:vm,type:"button",children:"Back to chat"})]})]})},bm="_container_zospk_1",km="_body_zospk_19",Sm="_confirmationOverlay_zospk_30",Cm="_confirmationDialog_zospk_51",Tm="_confirmationText_zospk_73",wm="_confirmationButtons_zospk_81",Em="_cancelButton_zospk_86",xm="_confirmButton_zospk_87",Pm=({config:e,messages:t,toolCalls:n=[],isLoading:i,showTypingIndicator:r=!1,isExpanded:o=!1,headerSubtitle:a,voiceTokenUrl:s,voiceAgentName:c="voice-agent",enableVoiceMode:l=!1,onSendMessage:d,onClose:h,onBack:p,onNewChat:f,onExpandWindow:m})=>{var g;const[v,y]=u.useState(!1),[b,k]=u.useState(!1),S=t.length>0,C=l&&!!s;return R.jsxs("div",{className:bm,role:"dialog","aria-label":"Chat window",children:[R.jsx(se,{agentName:e.agentName,agentLogoUrl:e.agentLogoUrl,headerSubtitle:a,welcomeTitle:e.welcomeMessage||"Hello there.",welcomeSubtitle:e.welcomeMessage?void 0:"How can we help?",onClose:h,onBack:p,onNewChatRequest:()=>{y(!0)},onExpandWindow:m,onDownloadTranscript:S?()=>{if(0===t.length)return;const n=t.map(t=>{const n="user"===t.role?"You":e.agentName||"Assistant";return`[${new Date(t.timestamp).toLocaleString()}] ${n}:\n${t.content}\n`}).join("\n"),i=new Blob([n],{type:"text/plain"}),r=URL.createObjectURL(i),o=document.createElement("a");o.href=r,o.download=`chat-transcript-${(new Date).toISOString().split("T")[0]}.txt`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(r)}:void 0,showMenuButton:S,isExpanded:o,compact:S}),R.jsx("div",{className:km,children:b&&C?R.jsx(ym,{tokenUrl:s,agentName:c,onClose:()=>{k(!1)},accentColor:e.primaryColor}):R.jsxs(R.Fragment,{children:[R.jsx(fo,{messages:t,toolCalls:n,isLoading:i,showTypingIndicator:r,agentName:e.agentName,agentRole:e.agentRole,agentLogoUrl:e.agentLogoUrl}),R.jsx(wo,{onSend:d,disabled:i,placeholder:"Message...",onAttachment:()=>{},onEmoji:()=>{},onGif:()=>{},onVoice:C?()=>{C&&k(!0)}:void 0})]})}),R.jsx(Io,{showBranding:(null==(g=e.styling)?void 0:g.showBranding)??!0}),v&&R.jsx("div",{className:Sm,children:R.jsxs("div",{className:Cm,children:[R.jsx("p",{className:Tm,children:"End current chat and start a new conversation?"}),R.jsxs("div",{className:wm,children:[R.jsx("button",{className:Em,onClick:()=>{y(!1)},type:"button",children:"Cancel"}),R.jsx("button",{className:xm,onClick:()=>{y(!1),null==f||f()},type:"button",children:"End Chat"})]})]})})]})},_m=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),Rm=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)};
12
+ /**
13
+ * @license lucide-react v0.563.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */
18
+ var Im={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};
19
+ /**
20
+ * @license lucide-react v0.563.0 - ISC
21
+ *
22
+ * This source code is licensed under the ISC license.
23
+ * See the LICENSE file in the root directory of this source tree.
24
+ */const Nm=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1},Om=u.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:o,iconNode:a,...s},c)=>u.createElement("svg",{ref:c,...Im,width:t,height:t,stroke:e,strokeWidth:i?24*Number(n)/Number(t):n,className:_m("lucide",r),...!o&&!Nm(s)&&{"aria-hidden":"true"},...s},[...a.map(([e,t])=>u.createElement(e,t)),...Array.isArray(o)?o:[o]])),Mm=(e,t)=>{const n=u.forwardRef(({className:n,...i},r)=>{return u.createElement(Om,{ref:r,iconNode:t,className:_m(`lucide-${o=Rm(e),o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...i});var o});return n.displayName=Rm(e),n},Dm=Mm("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),Lm=Mm("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),Am=Mm("coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]),jm=Mm("headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]),Um=Mm("heart",[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]]),Fm=Mm("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]),Bm=Mm("message-circle",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]),zm=Mm("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),Vm=Mm("messages-square",[["path",{d:"M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z",key:"1n2ejm"}],["path",{d:"M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1",key:"1qfcsi"}]]),qm=Mm("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]),Hm=Mm("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),Wm=Mm("smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]),Km=Mm("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]),Gm=Mm("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),$m=Mm("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),Jm=Mm("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Qm={"message-circle":Bm,"message-square":zm,"messages-square":Vm,"help-circle":Lm,headphones:jm,bot:Dm,sparkles:Km,send:Hm,mail:Fm,phone:qm,users:$m,heart:Um,star:Gm,zap:Jm,coffee:Am,smile:Wm},Ym=Object.keys(Qm);
25
+ /**
26
+ * @license lucide-react v0.563.0 - ISC
27
+ *
28
+ * This source code is licensed under the ISC license.
29
+ * See the LICENSE file in the root directory of this source tree.
30
+ */function Xm(e){const t=Qm[e];return t?R.jsx(t,{}):(console.warn(`[Brainbase Chat] Unknown icon name: "${e}". Available icons: ${Ym.join(", ")}`),null)}const Zm="_toggleButton_186ig_1",eg="_icon_186ig_54",tg="_customIcon_186ig_59",ng="_agentLogo_186ig_72",ig="_unreadBadge_186ig_79",rg=({onClick:e,agentLogoUrl:t,unreadCount:n=0,customIcon:i})=>R.jsxs("button",{className:Zm,onClick:e,"aria-label":"Open chat",type:"button",children:[i?"string"==typeof i?i in Qm?R.jsx("span",{className:tg,children:Xm(i)}):R.jsx("img",{src:i,alt:"",className:ng}):R.jsx("span",{className:tg,children:i}):t?R.jsx("img",{src:t,alt:"",className:ng}):R.jsx(Bm,{className:eg}),n>0&&R.jsx("span",{className:ig,children:n>9?"9+":n})]}),og="_container_kgfgt_1",ag="_header_kgfgt_25",sg="_logoWrapper_kgfgt_38",cg="_logo_kgfgt_38",lg="_closeButton_kgfgt_51",ug="_content_kgfgt_74",dg="_iconWrapper_kgfgt_84",hg="_errorIcon_kgfgt_95",pg="_title_kgfgt_101",fg="_description_kgfgt_109",mg="_retryButton_kgfgt_117",gg="_footer_kgfgt_139",vg="_poweredBy_kgfgt_146",yg="_footerLogo_kgfgt_160",bg=({errorType:e,message:t,onRetry:n,onClose:i})=>{const{title:r,description:o,icon:a}=(()=>{switch(e){case"not_found":return{title:"Chat Not Found",description:t||"This chat widget is not configured correctly. Please check the embed ID.",icon:R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:hg,children:[R.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),R.jsx("path",{d:"M12 7V13M12 16V16.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})};case"network":return{title:"Connection Error",description:t||"Unable to connect to the chat service. Please check your internet connection.",icon:R.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",className:hg,children:[R.jsx("path",{d:"M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z",stroke:"currentColor",strokeWidth:"1.5"}),R.jsx("path",{d:"M8 15L16 9M8 9L16 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})};default:return{title:"Something Went Wrong",description:t||"An unexpected error occurred. Please try again later.",icon:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:hg,children:R.jsx("path",{d:"M12 9V13M12 17H12.01M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}}})();return R.jsxs("div",{className:og,children:[R.jsxs("div",{className:ag,children:[R.jsx("div",{className:sg,children:R.jsx(U,{className:cg,color:"white",cutoutColor:"var(--bb-primary-color)"})}),i&&R.jsx("button",{className:lg,onClick:i,"aria-label":"Close",type:"button",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:R.jsx("path",{d:"M6 18L18 6M6 6L18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),R.jsxs("div",{className:ug,children:[R.jsx("div",{className:dg,children:a}),R.jsx("h2",{className:pg,children:r}),R.jsx("p",{className:fg,children:o}),n&&R.jsx("button",{className:mg,onClick:n,type:"button",children:"Try Again"})]}),R.jsx("div",{className:gg,children:R.jsxs("a",{href:"https://brainbaselabs.com",target:"_blank",rel:"noopener noreferrer",className:vg,children:["Powered by"," ",R.jsx(U,{className:yg,color:"var(--bb-text-tertiary)",cutoutColor:"var(--bb-surface-bg)"}),R.jsx("span",{children:"Brainbase Labs"})]})})]})},kg="_container_cgn0s_1",Sg="_header_cgn0s_29",Cg="_headerBackground_cgn0s_34",Tg="_headerContent_cgn0s_40",wg="_agentInfo_cgn0s_45",Eg="_headerLogo_cgn0s_51",xg="_headerLogoPlaceholder_cgn0s_58",Pg="_headerBrainbaseLogo_cgn0s_68",_g="_headerAgentName_cgn0s_73",Rg="_content_cgn0s_79",Ig="_infoCard_cgn0s_89",Ng="_clickable_cgn0s_104",Og="_infoImageWrapper_cgn0s_122",Mg="_infoImage_cgn0s_122",Dg="_infoContent_cgn0s_134",Lg="_infoText_cgn0s_142",Ag="_infoTitle_cgn0s_150",jg="_infoDescription_cgn0s_158",Ug="_infoChevron_cgn0s_169",Fg="_askCard_cgn0s_177",Bg="_askContent_cgn0s_196",zg="_askTitle_cgn0s_202",Vg="_askSubtitle_cgn0s_208",qg="_askIcon_cgn0s_213",Hg="_agentLogo_cgn0s_220",Wg="_brainbaseLogo_cgn0s_227",Kg="_chevron_cgn0s_232",Gg="_footer_cgn0s_238",$g="_navItem_cgn0s_246",Jg="_active_cgn0s_265",Qg="_navIcon_cgn0s_269",Yg=({agentName:e="AI Assistant",agentLogoUrl:t,homeImage:n,homeTitle:i,homeDescription:r,homeLink:o,onStartChat:a,onNavigate:s,currentPage:c})=>R.jsxs("div",{className:kg,children:[R.jsxs("div",{className:Sg,children:[R.jsx("div",{className:Cg}),R.jsx("div",{className:Tg,children:R.jsxs("div",{className:wg,children:[t?R.jsx("img",{src:t,alt:e,className:Eg}):R.jsx("div",{className:xg,children:R.jsx(U,{className:Pg,color:"white",cutoutColor:"var(--bb-primary-color)"})}),R.jsx("span",{className:_g,children:e})]})})]}),R.jsxs("div",{className:Rg,children:[R.jsxs("button",{className:Fg,onClick:a,type:"button",children:[R.jsxs("div",{className:Bg,children:[R.jsx("span",{className:zg,children:"Ask a question"}),R.jsxs("span",{className:Vg,children:[e," and team can help"]})]}),R.jsxs("div",{className:qg,children:[t?R.jsx("img",{src:t,alt:"",className:Hg}):R.jsx(U,{className:Wg,color:"currentColor"}),R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:Kg,children:R.jsx("path",{d:"M9 18L15 12L9 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]}),(n||i||r)&&R.jsxs("button",{className:`${Ig} ${o?Ng:""}`,onClick:o?()=>{o&&window.open(o,"_blank","noopener,noreferrer")}:void 0,type:"button",disabled:!o,children:[n&&R.jsx("div",{className:Og,children:R.jsx("img",{src:n,alt:"",className:Mg})}),R.jsxs("div",{className:Dg,children:[R.jsxs("div",{className:Lg,children:[i&&R.jsx("h3",{className:Ag,children:i}),r&&R.jsx("p",{className:jg,children:r})]}),o&&R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:Ug,children:R.jsx("path",{d:"M9 18L15 12L9 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]}),R.jsxs("nav",{className:Gg,children:[R.jsxs("button",{className:`${$g} ${"home"===c?Jg:""}`,onClick:()=>s("home"),type:"button",children:[R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:Qg,children:R.jsx("path",{d:"M3 12L5 10M5 10L12 3L19 10M5 10V20C5 20.5523 5.44772 21 6 21H9M19 10L21 12M19 10V20C19 20.5523 18.5523 21 18 21H15M9 21C9.55228 21 10 20.5523 10 20V16C10 15.4477 10.4477 15 11 15H13C13.5523 15 14 15.4477 14 16V20C14 20.5523 14.4477 21 15 21M9 21H15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),R.jsx("span",{children:"Home"})]}),R.jsxs("button",{className:`${$g} ${"messages"===c?Jg:""}`,onClick:()=>s("messages"),type:"button",children:[R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",className:Qg,children:R.jsx("path",{d:"M8 12H8.01M12 12H12.01M16 12H16.01M21 12C21 16.4183 16.9706 20 12 20C10.4607 20 9.01172 19.6565 7.74467 19.0511L3 20L4.39499 16.28C3.51156 15.0423 3 13.5743 3 12C3 7.58172 7.02944 4 12 4C16.9706 4 21 7.58172 21 12Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),R.jsx("span",{children:"Messages"})]})]})]}),Xg={widget:"_widget_1ntwj_1","bottom-right":"_bottom-right_1ntwj_11","bottom-left":"_bottom-left_1ntwj_18",inline:"_inline_1ntwj_26",openContainer:"_openContainer_1ntwj_43",collapseButton:"_collapseButton_1ntwj_51",buttonAppear:"_buttonAppear_1ntwj_1"},Zg=({embedId:e,apiBaseUrl:t=D,mockMode:n=!1,mockResponses:i,position:r="bottom-right",defaultOpen:o=!1,primaryColor:a,accentColor:s,primaryGradient:c=!1,accentGradient:l=!1,headerTextColor:d,streamMessages:h=!1,artificialDelay:p,homeImage:f,homeTitle:m,homeDescription:g,homeLink:v,timeToOpen:y,voiceTokenUrl:b,voiceAgentName:k="voice-agent",enableVoiceMode:S=!1,showCollapseButton:C=!0,agentName:T,agentRole:w,headerSubtitle:E,agentLogoUrl:x,agentNameFontSize:P=16,toggleIcon:_,welcomeMessage:I,showBranding:N,width:O=440,height:U=720,expandedWidth:F=640,expandedHeight:B=800,messageFontSize:z=15,theme:V="light",className:q,onSessionStart:H,onSessionEnd:W,onMessage:K,onError:G})=>{const[$,J]=u.useState(o),[Q,Y]=u.useState(!1),[X,Z]=u.useState("chat"),[ee,te]=u.useState(null),[ne,ie]=u.useState(!0),[re,oe]=u.useState(null),[ae,se]=u.useState(),ce=u.useRef(!1),le=u.useRef(!1),ue=u.useMemo(()=>n?function(e,t){const n={...L,...e},i=t??A,r=`mock-session-${Date.now()}`;return{getDeploymentConfig:async e=>(await j(300),n),async*sendMessage(e){yield{type:"session",data:{session_id:r,is_new:!0},timestamp:Date.now()};const t=i.find(t=>"string"==typeof t.trigger?e.toLowerCase().includes(t.trigger.toLowerCase()):t.trigger.test(e))??i[i.length-1];if(await j(t.delay??500),t.toolCalls)for(const i of t.toolCalls)yield{type:"tool_call",data:{function:i.name,args:i.arguments},timestamp:Date.now()},await j(300),yield{type:"tool_call",data:{function:i.name,result:i.result},timestamp:Date.now()},await j(200);const n=t.response.split(" ");let o="";for(const i of n)o+=(o?" ":"")+i,yield{type:"message",data:{content:o,role:"assistant"},timestamp:Date.now()},await j(30+40*Math.random());yield{type:"done",data:{session_id:r},timestamp:Date.now()}}}}({},i):function(e=D){return{async getDeploymentConfig(t){const n=await fetch(`${e}/chat/config/${t}`);if(!n.ok)throw new Error(`Failed to fetch deployment config: ${n.status}`);const i=await n.json();return{embedId:i.embedId,deploymentId:"",workerId:"",flowId:"",welcomeMessage:i.welcomeMessage,agentName:i.agentName,agentRole:i.agentRole,agentLogoUrl:i.agentLogoUrl,primaryColor:i.primaryColor,styling:i.styling}},async sendMessage(t){const n=await fetch(`${e}/chat/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({embed_id:t.embedId,message:t.message,session_id:t.sessionId||void 0,metadata:t.metadata})});if(!n.ok){const e=await n.text();throw new Error(`Failed to send message: ${n.status} - ${e}`)}if(!n.body)throw new Error("No response stream available");return n.body}}}(t),[n,i,t]),de=u.useCallback(async()=>{if(!ce.current||!ee){ie(!0),oe(null),se(void 0);try{const t=await ue.getDeploymentConfig(e);te(t),ce.current=!0}catch(t){const i=t instanceof Error?t:new Error("Failed to load config");i.message.includes("404")?(oe("not_found"),se("The chat widget with this embed ID was not found.")):i.message.includes("Failed to fetch")||i.message.includes("network")?oe("network"):oe("unknown"),n&&(te({embedId:e,deploymentId:"mock-deployment",workerId:"mock-worker",flowId:"mock-flow",primaryColor:"#1a1a2e",agentName:"AI Assistant",styling:{}}),oe(null),ce.current=!0),null==G||G(i)}finally{ie(!1)}}},[e,n,ue,G,ee]);u.useEffect(()=>{ce.current=!1,de()},[e,n,ue]);const he=u.useMemo(()=>{const t=ee??{embedId:e,deploymentId:"",workerId:"",flowId:""};return{...t,primaryColor:a??t.primaryColor??"#1a1a2e",agentName:T??t.agentName,agentRole:w??t.agentRole,agentLogoUrl:x??t.agentLogoUrl,welcomeMessage:I??t.welcomeMessage,styling:{...t.styling??{},...void 0!==N?{showBranding:N}:{}}}},[ee,e,a,T,w,x,I,N]),pe=M({config:he,apiClient:ue,mockMode:n,streamMessages:h,artificialDelay:p,onSessionStart:H,onSessionEnd:W,onMessage:K,onError:G});u.useEffect(()=>{if(!y||le.current||$||ne)return;const e=setTimeout(()=>{le.current||$||(le.current=!0,J(!0),Z("chat"),pe.sendTriggerMessage())},1e3*y);return()=>clearTimeout(e)},[y,$,ne,pe]);const fe=s??he.primaryColor??"#1a1a2e",me=d??("granite"===V?"#9ca3af":"#000000"),ge=u.useMemo(()=>({"--bb-primary-color":he.primaryColor??"#1a1a2e","--bb-accent-color-custom":fe,"--bb-primary-gradient":c?"1":"0","--bb-accent-gradient":l?"1":"0","--bb-header-text-color":me,"--bb-widget-width":Q?`${F}px`:`${O}px`,"--bb-widget-height":Q?`${B}px`:`${U}px`,"--bb-message-font-size":`${z}px`,"--bb-agent-name-font-size":`${P}px`}),[he.primaryColor,fe,c,l,me,Q,O,U,F,B,z,P]),ve=()=>{J(!1)},ye=()=>{de()},be="inline"===r;if(ne)return null;if(re&&!n)return be||$?R.jsx("div",{className:`${Xg.widget} ${Xg[r]} ${q??""}`,style:ge,"data-bb-theme":V,children:R.jsx(bg,{errorType:re,message:ae,onRetry:ye,onClose:be?void 0:ve})}):R.jsx("div",{className:`${Xg.widget} ${Xg[r]} ${q??""}`,style:ge,"data-bb-theme":V,children:R.jsx(rg,{onClick:()=>J(!0),agentName:T,customIcon:_})});const ke=[Xg.widget,Xg[r],q??""].filter(Boolean).join(" ");return R.jsx("div",{className:ke,style:ge,"data-bb-theme":V,children:$||be?R.jsxs("div",{className:Xg.openContainer,children:["home"===X?R.jsx(Yg,{agentName:he.agentName,agentLogoUrl:he.agentLogoUrl,homeImage:f,homeTitle:m,homeDescription:g,homeLink:v,onStartChat:()=>{Z("chat")},onNavigate:e=>{Z("messages"===e?"chat":e)},currentPage:"home"}):R.jsx(Pm,{config:he,messages:pe.messages,isLoading:pe.isLoading,showTypingIndicator:pe.showTypingIndicator,isExpanded:Q,headerSubtitle:E,voiceTokenUrl:b,voiceAgentName:k,enableVoiceMode:S,onSendMessage:pe.sendMessage,onClose:be?void 0:ve,onBack:()=>{Z("home")},onNewChat:()=>{pe.endSession(),pe.startNewSession()},onExpandWindow:be?void 0:()=>{Y(!Q)}}),!be&&C&&R.jsx("button",{className:Xg.collapseButton,onClick:ve,"aria-label":"Close chat",type:"button",children:R.jsx("svg",{viewBox:"0 0 24 24",fill:"none",children:R.jsx("path",{d:"M6 9L12 15L18 9",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}):R.jsx(rg,{onClick:()=>J(!0),agentName:he.agentName,agentLogoUrl:he.agentLogoUrl,customIcon:_})})};class ev extends HTMLElement{constructor(){super(...arguments),n(this,"root",null),n(this,"container",null)}static get observedAttributes(){return["embed-id","position","primary-color","agent-name","agent-role","welcome-message","api-base-url","default-open","toggle-icon","width","height","message-font-size","theme","header-subtitle","agent-name-font-size","accent-color","primary-gradient","accent-gradient","header-text-color","stream-messages","artificial-delay","home-image","home-title","home-description","home-link","time-to-open","voice-token-url","voice-agent-name","enable-voice-mode","show-collapse-button"]}connectedCallback(){this.container=document.createElement("div"),this.container.className="brainbase-chat-container",this.appendChild(this.container),this.root=x.createRoot(this.container),this.render()}disconnectedCallback(){this.root&&(this.root.unmount(),this.root=null),this.container&&this.container.parentNode&&(this.container.parentNode.removeChild(this.container),this.container=null)}attributeChangedCallback(e,t,n){t!==n&&this.root&&this.render()}render(){if(!this.root)return;const e=this.getProps();e.embedId?this.root.render(d.createElement(Zg,e)):console.warn("[Brainbase Chat] embed-id attribute is required")}getProps(){const e=this.getAttribute("width"),t=this.getAttribute("height"),n=this.getAttribute("message-font-size"),i=this.getAttribute("agent-name-font-size"),r=this.getAttribute("time-to-open");return{embedId:this.getAttribute("embed-id")||"",position:this.getPositionAttribute(),primaryColor:this.getAttribute("primary-color")||void 0,accentColor:this.getAttribute("accent-color")||void 0,primaryGradient:"true"===this.getAttribute("primary-gradient"),accentGradient:"true"===this.getAttribute("accent-gradient"),headerTextColor:this.getAttribute("header-text-color")||void 0,streamMessages:"true"===this.getAttribute("stream-messages"),artificialDelay:this.getArtificialDelayAttribute(),homeImage:this.getAttribute("home-image")||void 0,homeTitle:this.getAttribute("home-title")||void 0,homeDescription:this.getAttribute("home-description")||void 0,homeLink:this.getAttribute("home-link")||void 0,timeToOpen:r?parseFloat(r):void 0,voiceTokenUrl:this.getAttribute("voice-token-url")||void 0,voiceAgentName:this.getAttribute("voice-agent-name")||void 0,enableVoiceMode:"true"===this.getAttribute("enable-voice-mode"),showCollapseButton:"false"!==this.getAttribute("show-collapse-button"),agentName:this.getAttribute("agent-name")||void 0,agentRole:this.getAttribute("agent-role")||void 0,headerSubtitle:this.getAttribute("header-subtitle")||void 0,welcomeMessage:this.getAttribute("welcome-message")||void 0,apiBaseUrl:this.getAttribute("api-base-url")||void 0,defaultOpen:"true"===this.getAttribute("default-open"),toggleIcon:this.getAttribute("toggle-icon")||void 0,width:e?parseInt(e,10):void 0,height:t?parseInt(t,10):void 0,messageFontSize:n?parseInt(n,10):void 0,agentNameFontSize:i?parseInt(i,10):void 0,theme:this.getThemeAttribute()}}getThemeAttribute(){const e=this.getAttribute("theme");if("dark"===e||"granite"===e||"light"===e)return e}getArtificialDelayAttribute(){const e=this.getAttribute("artificial-delay");if(!e)return;const t=e.split(/[,-]/).map(e=>parseFloat(e.trim()));return 2!==t.length||isNaN(t[0])||isNaN(t[1])?void 0:[t[0],t[1]]}getPositionAttribute(){const e=this.getAttribute("position");return"bottom-left"===e||"inline"===e?e:"bottom-right"}}return"undefined"==typeof customElements||customElements.get("brainbase-chat")||customElements.define("brainbase-chat",ev),"undefined"!=typeof window&&console.log("[Brainbase Chat] Widget loaded and ready"),e.ChatWidgetElement=ev,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});